From 9393ee2e29e29e5446303cb756650b0003c1168c Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Wed, 25 Apr 2018 18:58:02 +0100 Subject: [PATCH 1/1] Import quassel_0.12.5.orig.tar.bz2 [dgit import orig quassel_0.12.5.orig.tar.bz2] --- .gitattributes | 2 + .gitignore | 8 + .travis.yml | 73 + .tx/config | 8 + 3rdparty/miniz/miniz.c | 4916 ++++++ 3rdparty/sha512/sha512.c | 797 + 3rdparty/sha512/sha512.h | 209 + AUTHORS | 4 + CMakeLists.txt | 676 + COPYING | 17 + ChangeLog | 424 + Doxyfile | 286 + INSTALL | 134 + README.md | 61 + appveyor.ini | 31 + appveyor.yml | 38 + cmake/COPYING-CMAKE-SCRIPTS | 26 + cmake/FindExecInfo.cmake | 29 + cmake/FindIndicateQt.cmake | 28 + cmake/FindLibraryWithDebug.cmake | 113 + cmake/FindPhonon.cmake | 37 + cmake/FindQCA2-QT5.cmake | 61 + cmake/FindQCA2.cmake | 48 + cmake/GetGitRevisionDescription.cmake | 124 + cmake/GetGitRevisionDescription.cmake.in | 38 + cmake/QuasselCompileSettings.cmake | 87 + cmake/QuasselInstallDirs.cmake | 65 + cmake/QuasselMacros.cmake | 125 + cmake/README | 5 + data/CMakeLists.txt | 30 + data/data.qrc | 6 + data/networks.ini | 51 + data/quassel.appdata.xml | 41 + data/quassel.desktop | 76 + data/quassel.notifyrc | 177 + data/quasselclient.appdata.xml | 41 + data/quasselclient.desktop | 75 + data/scripts/inxi | 14740 ++++++++++++++++ data/scripts/mpris | 66 + data/stylesheets/LinuxDolt-bluestheme.qss | 111 + data/stylesheets/default.qss | 103 + data/stylesheets/jussi01-darktheme.qss | 106 + data/stylesheets/m4yer.qss | 155 + dev-notes/DockManager-spec.txt | 74 + dev-notes/QT4_TARGET_DIRECTORIES | 1 + dev-notes/Quassel.kdevelop | 215 + dev-notes/README.kdevelop | 7 + dev-notes/blanksettingspage.cpp | 74 + dev-notes/blanksettingspage.h | 52 + dev-notes/code_policy.txt | 26 + dev-notes/obsolete/buffermgmtpage.ui | 717 + dev-notes/obsolete/usermgmtpage.ui | 109 + dev-notes/quassel.desc | 1 + dev-notes/qxt-check | 4 + doc/build-static-quassel | 43 + gpl-2.0.txt | 339 + gpl-3.0.txt | 674 + icons/CMakeLists.txt | 41 + icons/README.Oxygen | 18 + icons/hicolor.qrc | 27 + icons/hicolor/128x128/apps/quassel.png | Bin 0 -> 20667 bytes .../128x128/status/quassel-inactive.png | Bin 0 -> 15731 bytes .../128x128/status/quassel-message.png | Bin 0 -> 15924 bytes icons/hicolor/16x16/actions/im-user-away.png | Bin 0 -> 841 bytes .../hicolor/16x16/actions/im-user-offline.png | Bin 0 -> 708 bytes icons/hicolor/16x16/actions/im-user.png | Bin 0 -> 746 bytes icons/hicolor/16x16/apps/quassel.png | Bin 0 -> 976 bytes .../16x16/status/irc-channel-joined.png | Bin 0 -> 864 bytes .../16x16/status/irc-channel-parted.png | Bin 0 -> 894 bytes .../hicolor/16x16/status/quassel-inactive.png | Bin 0 -> 1175 bytes .../hicolor/16x16/status/quassel-message.png | Bin 0 -> 1063 bytes icons/hicolor/22x22/apps/quassel.png | Bin 0 -> 1528 bytes .../hicolor/22x22/status/quassel-inactive.png | Bin 0 -> 1834 bytes .../hicolor/22x22/status/quassel-message.png | Bin 0 -> 1620 bytes icons/hicolor/32x32/apps/quassel.png | Bin 0 -> 2621 bytes .../hicolor/32x32/status/quassel-inactive.png | Bin 0 -> 2979 bytes .../hicolor/32x32/status/quassel-message.png | Bin 0 -> 2683 bytes icons/hicolor/48x48/apps/quassel.png | Bin 0 -> 4739 bytes .../hicolor/48x48/status/quassel-inactive.png | Bin 0 -> 4960 bytes .../hicolor/48x48/status/quassel-message.png | Bin 0 -> 3678 bytes icons/hicolor/64x64/apps/quassel.png | Bin 0 -> 7165 bytes .../hicolor/64x64/status/quassel-inactive.png | Bin 0 -> 7199 bytes .../hicolor/64x64/status/quassel-message.png | Bin 0 -> 6831 bytes .../scalable/status/irc-channel-joined.svgz | Bin 0 -> 29853 bytes .../scalable/status/irc-channel-parted.svgz | Bin 0 -> 9317 bytes icons/import/blacklisted-icons | 4 + icons/import/extra-icons | 1 + icons/import/import_oxygen.pl | 139 + icons/oxygen.qrc | 291 + .../128x128/actions/application-exit.png | Bin 0 -> 11200 bytes icons/oxygen/128x128/actions/configure.png | Bin 0 -> 11056 bytes .../oxygen/128x128/actions/document-edit.png | Bin 0 -> 10668 bytes icons/oxygen/128x128/actions/edit-find.png | Bin 0 -> 14259 bytes icons/oxygen/128x128/actions/go-down.png | Bin 0 -> 8800 bytes icons/oxygen/128x128/actions/go-next.png | Bin 0 -> 9668 bytes icons/oxygen/128x128/actions/go-previous.png | Bin 0 -> 9960 bytes icons/oxygen/128x128/actions/go-up.png | Bin 0 -> 9172 bytes .../128x128/actions/im-ban-kick-user.png | Bin 0 -> 15607 bytes icons/oxygen/128x128/actions/im-ban-user.png | Bin 0 -> 15044 bytes icons/oxygen/128x128/actions/im-kick-user.png | Bin 0 -> 14917 bytes icons/oxygen/128x128/actions/im-user-away.png | Bin 0 -> 16253 bytes .../128x128/actions/im-user-offline.png | Bin 0 -> 10886 bytes icons/oxygen/128x128/actions/im-user.png | Bin 0 -> 13797 bytes .../oxygen/128x128/actions/list-add-user.png | Bin 0 -> 12419 bytes .../128x128/actions/mail-message-new.png | Bin 0 -> 40042 bytes .../128x128/actions/tools-report-bug.png | Bin 0 -> 12933 bytes icons/oxygen/128x128/apps/quassel.png | Bin 0 -> 20087 bytes .../oxygen/128x128/devices/network-wired.png | Bin 0 -> 12938 bytes .../128x128/status/dialog-information.png | Bin 0 -> 11467 bytes icons/oxygen/128x128/status/security-high.png | Bin 0 -> 10816 bytes icons/oxygen/128x128/status/security-low.png | Bin 0 -> 11140 bytes .../oxygen/16x16/actions/application-exit.png | Bin 0 -> 842 bytes .../16x16/actions/configure-shortcuts.png | Bin 0 -> 847 bytes icons/oxygen/16x16/actions/configure.png | Bin 0 -> 717 bytes icons/oxygen/16x16/actions/dialog-cancel.png | Bin 0 -> 848 bytes icons/oxygen/16x16/actions/dialog-close.png | Bin 0 -> 813 bytes icons/oxygen/16x16/actions/document-edit.png | Bin 0 -> 726 bytes .../oxygen/16x16/actions/document-encrypt.png | Bin 0 -> 561 bytes icons/oxygen/16x16/actions/document-open.png | Bin 0 -> 727 bytes .../actions/edit-clear-locationbar-ltr.png | Bin 0 -> 897 bytes .../actions/edit-clear-locationbar-rtl.png | Bin 0 -> 644 bytes icons/oxygen/16x16/actions/edit-copy.png | Bin 0 -> 485 bytes icons/oxygen/16x16/actions/edit-delete.png | Bin 0 -> 640 bytes icons/oxygen/16x16/actions/edit-find.png | Bin 0 -> 626 bytes icons/oxygen/16x16/actions/edit-rename.png | Bin 0 -> 245 bytes icons/oxygen/16x16/actions/flag-blue.png | Bin 0 -> 1691 bytes .../16x16/actions/format-fill-color.png | Bin 0 -> 985 bytes .../16x16/actions/format-list-unordered.png | Bin 0 -> 309 bytes .../oxygen/16x16/actions/format-text-bold.png | Bin 0 -> 463 bytes .../16x16/actions/format-text-color.png | Bin 0 -> 601 bytes .../16x16/actions/format-text-italic.png | Bin 0 -> 331 bytes .../16x16/actions/format-text-underline.png | Bin 0 -> 392 bytes icons/oxygen/16x16/actions/go-down.png | Bin 0 -> 623 bytes icons/oxygen/16x16/actions/go-next-view.png | Bin 0 -> 570 bytes icons/oxygen/16x16/actions/go-next.png | Bin 0 -> 721 bytes .../oxygen/16x16/actions/go-previous-view.png | Bin 0 -> 575 bytes icons/oxygen/16x16/actions/go-previous.png | Bin 0 -> 634 bytes icons/oxygen/16x16/actions/go-up.png | Bin 0 -> 672 bytes icons/oxygen/16x16/actions/help-about.png | Bin 0 -> 803 bytes .../oxygen/16x16/actions/im-ban-kick-user.png | Bin 0 -> 834 bytes icons/oxygen/16x16/actions/im-ban-user.png | Bin 0 -> 830 bytes icons/oxygen/16x16/actions/im-kick-user.png | Bin 0 -> 842 bytes icons/oxygen/16x16/actions/im-user-away.png | Bin 0 -> 841 bytes .../oxygen/16x16/actions/im-user-offline.png | Bin 0 -> 708 bytes icons/oxygen/16x16/actions/im-user.png | Bin 0 -> 746 bytes .../16x16/actions/irc-close-channel.png | Bin 0 -> 1030 bytes .../oxygen/16x16/actions/irc-join-channel.png | Bin 0 -> 995 bytes icons/oxygen/16x16/actions/irc-operator.png | Bin 0 -> 748 bytes .../16x16/actions/irc-remove-operator.png | Bin 0 -> 860 bytes icons/oxygen/16x16/actions/irc-unvoice.png | Bin 0 -> 850 bytes icons/oxygen/16x16/actions/irc-voice.png | Bin 0 -> 754 bytes icons/oxygen/16x16/actions/list-add-user.png | Bin 0 -> 821 bytes icons/oxygen/16x16/actions/list-add.png | Bin 0 -> 564 bytes .../oxygen/16x16/actions/list-remove-user.png | Bin 0 -> 707 bytes .../oxygen/16x16/actions/mail-message-new.png | Bin 0 -> 803 bytes .../16x16/actions/media-playback-start.png | Bin 0 -> 501 bytes .../oxygen/16x16/actions/network-connect.png | Bin 0 -> 762 bytes .../16x16/actions/network-disconnect.png | Bin 0 -> 538 bytes icons/oxygen/16x16/actions/show-menu.png | Bin 0 -> 498 bytes .../oxygen/16x16/actions/tools-report-bug.png | Bin 0 -> 733 bytes .../oxygen/16x16/actions/view-fullscreen.png | Bin 0 -> 396 bytes icons/oxygen/16x16/actions/view-refresh.png | Bin 0 -> 931 bytes icons/oxygen/16x16/actions/zoom-in.png | Bin 0 -> 867 bytes icons/oxygen/16x16/actions/zoom-original.png | Bin 0 -> 863 bytes icons/oxygen/16x16/actions/zoom-out.png | Bin 0 -> 884 bytes icons/oxygen/16x16/apps/quassel.png | Bin 0 -> 975 bytes icons/oxygen/16x16/devices/network-wired.png | Bin 0 -> 604 bytes .../16x16/status/dialog-information.png | Bin 0 -> 803 bytes icons/oxygen/16x16/status/security-high.png | Bin 0 -> 682 bytes icons/oxygen/16x16/status/security-low.png | Bin 0 -> 669 bytes icons/oxygen/16x16/status/user-away.png | Bin 0 -> 778 bytes .../oxygen/22x22/actions/application-exit.png | Bin 0 -> 1134 bytes .../22x22/actions/configure-shortcuts.png | Bin 0 -> 1141 bytes icons/oxygen/22x22/actions/configure.png | Bin 0 -> 1101 bytes icons/oxygen/22x22/actions/dialog-cancel.png | Bin 0 -> 1343 bytes icons/oxygen/22x22/actions/dialog-close.png | Bin 0 -> 1251 bytes icons/oxygen/22x22/actions/document-edit.png | Bin 0 -> 1061 bytes .../oxygen/22x22/actions/document-encrypt.png | Bin 0 -> 647 bytes icons/oxygen/22x22/actions/document-open.png | Bin 0 -> 1125 bytes .../actions/edit-clear-locationbar-ltr.png | Bin 0 -> 1259 bytes .../actions/edit-clear-locationbar-rtl.png | Bin 0 -> 859 bytes icons/oxygen/22x22/actions/edit-copy.png | Bin 0 -> 515 bytes icons/oxygen/22x22/actions/edit-delete.png | Bin 0 -> 1121 bytes icons/oxygen/22x22/actions/edit-find.png | Bin 0 -> 942 bytes icons/oxygen/22x22/actions/edit-rename.png | Bin 0 -> 353 bytes icons/oxygen/22x22/actions/flag-blue.png | Bin 0 -> 2557 bytes .../22x22/actions/format-fill-color.png | Bin 0 -> 1445 bytes .../22x22/actions/format-list-unordered.png | Bin 0 -> 314 bytes .../oxygen/22x22/actions/format-text-bold.png | Bin 0 -> 667 bytes .../22x22/actions/format-text-color.png | Bin 0 -> 825 bytes .../22x22/actions/format-text-italic.png | Bin 0 -> 630 bytes .../22x22/actions/format-text-underline.png | Bin 0 -> 537 bytes icons/oxygen/22x22/actions/go-down.png | Bin 0 -> 892 bytes icons/oxygen/22x22/actions/go-next-view.png | Bin 0 -> 810 bytes icons/oxygen/22x22/actions/go-next.png | Bin 0 -> 940 bytes .../oxygen/22x22/actions/go-previous-view.png | Bin 0 -> 817 bytes icons/oxygen/22x22/actions/go-previous.png | Bin 0 -> 907 bytes icons/oxygen/22x22/actions/go-up.png | Bin 0 -> 929 bytes icons/oxygen/22x22/actions/help-about.png | Bin 0 -> 1145 bytes .../oxygen/22x22/actions/im-ban-kick-user.png | Bin 0 -> 1268 bytes icons/oxygen/22x22/actions/im-ban-user.png | Bin 0 -> 1258 bytes icons/oxygen/22x22/actions/im-kick-user.png | Bin 0 -> 1250 bytes icons/oxygen/22x22/actions/im-user-away.png | Bin 0 -> 1276 bytes .../oxygen/22x22/actions/im-user-offline.png | Bin 0 -> 1034 bytes icons/oxygen/22x22/actions/im-user.png | Bin 0 -> 1109 bytes .../22x22/actions/irc-close-channel.png | Bin 0 -> 1550 bytes .../oxygen/22x22/actions/irc-join-channel.png | Bin 0 -> 1513 bytes icons/oxygen/22x22/actions/irc-operator.png | Bin 0 -> 1107 bytes .../22x22/actions/irc-remove-operator.png | Bin 0 -> 1337 bytes icons/oxygen/22x22/actions/irc-unvoice.png | Bin 0 -> 1268 bytes icons/oxygen/22x22/actions/irc-voice.png | Bin 0 -> 1074 bytes icons/oxygen/22x22/actions/list-add-user.png | Bin 0 -> 1203 bytes icons/oxygen/22x22/actions/list-add.png | Bin 0 -> 907 bytes .../oxygen/22x22/actions/list-remove-user.png | Bin 0 -> 1058 bytes .../oxygen/22x22/actions/mail-message-new.png | Bin 0 -> 1174 bytes .../22x22/actions/media-playback-start.png | Bin 0 -> 736 bytes .../oxygen/22x22/actions/network-connect.png | Bin 0 -> 1145 bytes .../22x22/actions/network-disconnect.png | Bin 0 -> 760 bytes icons/oxygen/22x22/actions/show-menu.png | Bin 0 -> 670 bytes .../oxygen/22x22/actions/tools-report-bug.png | Bin 0 -> 1080 bytes .../oxygen/22x22/actions/view-fullscreen.png | Bin 0 -> 381 bytes icons/oxygen/22x22/actions/view-refresh.png | Bin 0 -> 1283 bytes icons/oxygen/22x22/actions/zoom-in.png | Bin 0 -> 1172 bytes icons/oxygen/22x22/actions/zoom-original.png | Bin 0 -> 1197 bytes icons/oxygen/22x22/actions/zoom-out.png | Bin 0 -> 1149 bytes icons/oxygen/22x22/apps/quassel.png | Bin 0 -> 1516 bytes icons/oxygen/22x22/devices/network-wired.png | Bin 0 -> 860 bytes .../22x22/status/dialog-information.png | Bin 0 -> 1145 bytes icons/oxygen/22x22/status/security-high.png | Bin 0 -> 1051 bytes icons/oxygen/22x22/status/security-low.png | Bin 0 -> 1069 bytes icons/oxygen/22x22/status/user-away.png | Bin 0 -> 3368 bytes icons/oxygen/256x256/apps/quassel.png | Bin 0 -> 60585 bytes .../oxygen/256x256/devices/network-wired.png | Bin 0 -> 37011 bytes .../oxygen/32x32/actions/application-exit.png | Bin 0 -> 1760 bytes .../32x32/actions/configure-shortcuts.png | Bin 0 -> 1826 bytes icons/oxygen/32x32/actions/configure.png | Bin 0 -> 1450 bytes icons/oxygen/32x32/actions/dialog-cancel.png | Bin 0 -> 2207 bytes icons/oxygen/32x32/actions/dialog-close.png | Bin 0 -> 2085 bytes icons/oxygen/32x32/actions/document-edit.png | Bin 0 -> 1700 bytes .../oxygen/32x32/actions/document-encrypt.png | Bin 0 -> 1052 bytes icons/oxygen/32x32/actions/document-open.png | Bin 0 -> 1798 bytes .../actions/edit-clear-locationbar-ltr.png | Bin 0 -> 1902 bytes .../actions/edit-clear-locationbar-rtl.png | Bin 0 -> 1333 bytes icons/oxygen/32x32/actions/edit-copy.png | Bin 0 -> 860 bytes icons/oxygen/32x32/actions/edit-delete.png | Bin 0 -> 1333 bytes icons/oxygen/32x32/actions/edit-find.png | Bin 0 -> 1705 bytes icons/oxygen/32x32/actions/edit-rename.png | Bin 0 -> 496 bytes icons/oxygen/32x32/actions/flag-blue.png | Bin 0 -> 4256 bytes .../32x32/actions/format-fill-color.png | Bin 0 -> 2508 bytes .../32x32/actions/format-list-unordered.png | Bin 0 -> 348 bytes .../oxygen/32x32/actions/format-text-bold.png | Bin 0 -> 1645 bytes .../32x32/actions/format-text-color.png | Bin 0 -> 1184 bytes .../32x32/actions/format-text-italic.png | Bin 0 -> 929 bytes .../32x32/actions/format-text-underline.png | Bin 0 -> 964 bytes icons/oxygen/32x32/actions/go-down.png | Bin 0 -> 1437 bytes icons/oxygen/32x32/actions/go-next-view.png | Bin 0 -> 1187 bytes icons/oxygen/32x32/actions/go-next.png | Bin 0 -> 1473 bytes .../oxygen/32x32/actions/go-previous-view.png | Bin 0 -> 1226 bytes icons/oxygen/32x32/actions/go-previous.png | Bin 0 -> 1536 bytes icons/oxygen/32x32/actions/go-up.png | Bin 0 -> 1517 bytes icons/oxygen/32x32/actions/help-about.png | Bin 0 -> 1636 bytes .../oxygen/32x32/actions/im-ban-kick-user.png | Bin 0 -> 2135 bytes icons/oxygen/32x32/actions/im-ban-user.png | Bin 0 -> 2127 bytes icons/oxygen/32x32/actions/im-kick-user.png | Bin 0 -> 2099 bytes icons/oxygen/32x32/actions/im-user-away.png | Bin 0 -> 2176 bytes .../oxygen/32x32/actions/im-user-offline.png | Bin 0 -> 1632 bytes icons/oxygen/32x32/actions/im-user.png | Bin 0 -> 1831 bytes .../32x32/actions/irc-close-channel.png | Bin 0 -> 2404 bytes .../oxygen/32x32/actions/irc-join-channel.png | Bin 0 -> 2501 bytes icons/oxygen/32x32/actions/irc-operator.png | Bin 0 -> 1688 bytes .../32x32/actions/irc-remove-operator.png | Bin 0 -> 2176 bytes icons/oxygen/32x32/actions/irc-unvoice.png | Bin 0 -> 2104 bytes icons/oxygen/32x32/actions/irc-voice.png | Bin 0 -> 1567 bytes icons/oxygen/32x32/actions/list-add-user.png | Bin 0 -> 1715 bytes icons/oxygen/32x32/actions/list-add.png | Bin 0 -> 1487 bytes .../oxygen/32x32/actions/list-remove-user.png | Bin 0 -> 1661 bytes .../oxygen/32x32/actions/mail-message-new.png | Bin 0 -> 1811 bytes .../32x32/actions/media-playback-start.png | Bin 0 -> 1177 bytes .../oxygen/32x32/actions/network-connect.png | Bin 0 -> 1679 bytes .../32x32/actions/network-disconnect.png | Bin 0 -> 1276 bytes icons/oxygen/32x32/actions/show-menu.png | Bin 0 -> 869 bytes .../oxygen/32x32/actions/tools-report-bug.png | Bin 0 -> 1709 bytes .../oxygen/32x32/actions/view-fullscreen.png | Bin 0 -> 472 bytes icons/oxygen/32x32/actions/view-refresh.png | Bin 0 -> 2182 bytes icons/oxygen/32x32/actions/zoom-in.png | Bin 0 -> 1842 bytes icons/oxygen/32x32/actions/zoom-original.png | Bin 0 -> 1847 bytes icons/oxygen/32x32/actions/zoom-out.png | Bin 0 -> 1783 bytes icons/oxygen/32x32/apps/quassel.png | Bin 0 -> 2605 bytes icons/oxygen/32x32/devices/network-wired.png | Bin 0 -> 1267 bytes .../32x32/status/dialog-information.png | Bin 0 -> 1636 bytes icons/oxygen/32x32/status/security-high.png | Bin 0 -> 1628 bytes icons/oxygen/32x32/status/security-low.png | Bin 0 -> 1650 bytes icons/oxygen/32x32/status/user-away.png | Bin 0 -> 2027 bytes .../oxygen/48x48/actions/application-exit.png | Bin 0 -> 3017 bytes .../48x48/actions/configure-shortcuts.png | Bin 0 -> 3079 bytes icons/oxygen/48x48/actions/configure.png | Bin 0 -> 2575 bytes icons/oxygen/48x48/actions/dialog-cancel.png | Bin 0 -> 3809 bytes icons/oxygen/48x48/actions/dialog-close.png | Bin 0 -> 3751 bytes icons/oxygen/48x48/actions/document-edit.png | Bin 0 -> 2955 bytes .../oxygen/48x48/actions/document-encrypt.png | Bin 0 -> 1835 bytes icons/oxygen/48x48/actions/document-open.png | Bin 0 -> 2798 bytes .../actions/edit-clear-locationbar-ltr.png | Bin 0 -> 2936 bytes .../actions/edit-clear-locationbar-rtl.png | Bin 0 -> 2204 bytes icons/oxygen/48x48/actions/edit-copy.png | Bin 0 -> 1380 bytes icons/oxygen/48x48/actions/edit-delete.png | Bin 0 -> 2176 bytes icons/oxygen/48x48/actions/edit-find.png | Bin 0 -> 3136 bytes icons/oxygen/48x48/actions/edit-rename.png | Bin 0 -> 748 bytes icons/oxygen/48x48/actions/flag-blue.png | Bin 0 -> 2171 bytes .../48x48/actions/format-fill-color.png | Bin 0 -> 4242 bytes .../48x48/actions/format-list-unordered.png | Bin 0 -> 435 bytes .../oxygen/48x48/actions/format-text-bold.png | Bin 0 -> 1330 bytes .../48x48/actions/format-text-color.png | Bin 0 -> 1739 bytes .../48x48/actions/format-text-italic.png | Bin 0 -> 1321 bytes .../48x48/actions/format-text-underline.png | Bin 0 -> 1170 bytes icons/oxygen/48x48/actions/go-down.png | Bin 0 -> 2404 bytes icons/oxygen/48x48/actions/go-next-view.png | Bin 0 -> 2001 bytes icons/oxygen/48x48/actions/go-next.png | Bin 0 -> 2425 bytes .../oxygen/48x48/actions/go-previous-view.png | Bin 0 -> 2011 bytes icons/oxygen/48x48/actions/go-previous.png | Bin 0 -> 2522 bytes icons/oxygen/48x48/actions/go-up.png | Bin 0 -> 2426 bytes icons/oxygen/48x48/actions/help-about.png | Bin 0 -> 2742 bytes .../oxygen/48x48/actions/im-ban-kick-user.png | Bin 0 -> 3788 bytes icons/oxygen/48x48/actions/im-ban-user.png | Bin 0 -> 3710 bytes icons/oxygen/48x48/actions/im-kick-user.png | Bin 0 -> 3727 bytes icons/oxygen/48x48/actions/im-user-away.png | Bin 0 -> 3873 bytes .../oxygen/48x48/actions/im-user-offline.png | Bin 0 -> 2760 bytes icons/oxygen/48x48/actions/im-user.png | Bin 0 -> 3253 bytes .../48x48/actions/irc-close-channel.png | Bin 0 -> 4344 bytes .../oxygen/48x48/actions/irc-join-channel.png | Bin 0 -> 4495 bytes icons/oxygen/48x48/actions/irc-operator.png | Bin 0 -> 2904 bytes .../48x48/actions/irc-remove-operator.png | Bin 0 -> 3967 bytes icons/oxygen/48x48/actions/irc-unvoice.png | Bin 0 -> 3804 bytes icons/oxygen/48x48/actions/irc-voice.png | Bin 0 -> 2716 bytes icons/oxygen/48x48/actions/list-add-user.png | Bin 0 -> 3014 bytes icons/oxygen/48x48/actions/list-add.png | Bin 0 -> 2658 bytes .../oxygen/48x48/actions/list-remove-user.png | Bin 0 -> 2940 bytes .../oxygen/48x48/actions/mail-message-new.png | Bin 0 -> 3306 bytes .../48x48/actions/media-playback-start.png | Bin 0 -> 1932 bytes .../oxygen/48x48/actions/network-connect.png | Bin 0 -> 2879 bytes .../48x48/actions/network-disconnect.png | Bin 0 -> 1881 bytes icons/oxygen/48x48/actions/show-menu.png | Bin 0 -> 1204 bytes .../oxygen/48x48/actions/tools-report-bug.png | Bin 0 -> 3166 bytes .../oxygen/48x48/actions/view-fullscreen.png | Bin 0 -> 883 bytes icons/oxygen/48x48/actions/view-refresh.png | Bin 0 -> 3743 bytes icons/oxygen/48x48/actions/zoom-in.png | Bin 0 -> 3034 bytes icons/oxygen/48x48/actions/zoom-original.png | Bin 0 -> 3027 bytes icons/oxygen/48x48/actions/zoom-out.png | Bin 0 -> 2939 bytes icons/oxygen/48x48/apps/quassel.png | Bin 0 -> 4719 bytes icons/oxygen/48x48/devices/network-wired.png | Bin 0 -> 2016 bytes .../48x48/status/dialog-information.png | Bin 0 -> 2742 bytes icons/oxygen/48x48/status/security-high.png | Bin 0 -> 2976 bytes icons/oxygen/48x48/status/security-low.png | Bin 0 -> 3051 bytes icons/oxygen/48x48/status/user-away.png | Bin 0 -> 11774 bytes .../oxygen/64x64/actions/application-exit.png | Bin 0 -> 4277 bytes icons/oxygen/64x64/actions/configure.png | Bin 0 -> 4000 bytes icons/oxygen/64x64/actions/document-edit.png | Bin 0 -> 4626 bytes icons/oxygen/64x64/actions/edit-find.png | Bin 0 -> 4870 bytes icons/oxygen/64x64/actions/go-down.png | Bin 0 -> 3375 bytes icons/oxygen/64x64/actions/go-next.png | Bin 0 -> 3498 bytes icons/oxygen/64x64/actions/go-previous.png | Bin 0 -> 3624 bytes icons/oxygen/64x64/actions/go-up.png | Bin 0 -> 3398 bytes .../oxygen/64x64/actions/im-ban-kick-user.png | Bin 0 -> 5645 bytes icons/oxygen/64x64/actions/im-ban-user.png | Bin 0 -> 5497 bytes icons/oxygen/64x64/actions/im-kick-user.png | Bin 0 -> 5506 bytes icons/oxygen/64x64/actions/im-user-away.png | Bin 0 -> 5829 bytes .../oxygen/64x64/actions/im-user-offline.png | Bin 0 -> 3982 bytes icons/oxygen/64x64/actions/im-user.png | Bin 0 -> 4886 bytes icons/oxygen/64x64/actions/list-add-user.png | Bin 0 -> 4468 bytes .../oxygen/64x64/actions/tools-report-bug.png | Bin 0 -> 4882 bytes icons/oxygen/64x64/apps/quassel.png | Bin 0 -> 7137 bytes icons/oxygen/64x64/devices/network-wired.png | Bin 0 -> 2735 bytes .../64x64/status/dialog-information.png | Bin 0 -> 4255 bytes icons/oxygen/64x64/status/security-high.png | Bin 0 -> 4359 bytes icons/oxygen/64x64/status/security-low.png | Bin 0 -> 4446 bytes icons/oxygen/64x64/status/user-away.png | Bin 0 -> 18514 bytes icons/oxygen/AUTHORS | 24 + icons/oxygen/CONTRIBUTING | 8 + icons/oxygen/COPYING | 216 + icons/oxygen/index.theme | 497 + .../scalable/actions/application-exit.svgz | Bin 0 -> 6400 bytes .../scalable/actions/configure-shortcuts.svgz | Bin 0 -> 15632 bytes icons/oxygen/scalable/actions/configure.svgz | Bin 0 -> 17618 bytes .../scalable/actions/dialog-cancel.svgz | Bin 0 -> 6047 bytes .../oxygen/scalable/actions/dialog-close.svgz | Bin 0 -> 2629 bytes .../scalable/actions/document-edit.svgz | Bin 0 -> 37598 bytes .../scalable/actions/document-encrypt.svgz | Bin 0 -> 20158 bytes .../actions/edit-clear-locationbar-ltr.svgz | Bin 0 -> 4604 bytes .../actions/edit-clear-locationbar-rtl.svgz | Bin 0 -> 4406 bytes icons/oxygen/scalable/actions/edit-copy.svgz | Bin 0 -> 3146 bytes .../oxygen/scalable/actions/edit-delete.svgz | Bin 0 -> 19200 bytes icons/oxygen/scalable/actions/edit-find.svgz | Bin 0 -> 16615 bytes .../oxygen/scalable/actions/edit-rename.svgz | Bin 0 -> 5170 bytes icons/oxygen/scalable/actions/flag-blue.svgz | Bin 0 -> 4933 bytes .../scalable/actions/format-fill-color.svgz | Bin 0 -> 10344 bytes .../scalable/actions/format-text-color.svgz | Bin 0 -> 53012 bytes icons/oxygen/scalable/actions/go-down.svgz | Bin 0 -> 6582 bytes .../oxygen/scalable/actions/go-next-view.svgz | Bin 0 -> 2834 bytes icons/oxygen/scalable/actions/go-next.svgz | Bin 0 -> 5473 bytes .../scalable/actions/go-previous-view.svgz | Bin 0 -> 2829 bytes .../oxygen/scalable/actions/go-previous.svgz | Bin 0 -> 5690 bytes icons/oxygen/scalable/actions/go-up.svgz | Bin 0 -> 6122 bytes .../scalable/actions/im-ban-kick-user.svgz | Bin 0 -> 23158 bytes .../oxygen/scalable/actions/im-ban-user.svgz | Bin 0 -> 11095 bytes .../oxygen/scalable/actions/im-kick-user.svgz | Bin 0 -> 9108 bytes .../oxygen/scalable/actions/im-user-away.svgz | Bin 0 -> 16762 bytes .../scalable/actions/im-user-offline.svgz | Bin 0 -> 6789 bytes icons/oxygen/scalable/actions/im-user.svgz | Bin 0 -> 17120 bytes .../scalable/actions/irc-close-channel.svgz | Bin 0 -> 11328 bytes .../scalable/actions/irc-join-channel.svgz | Bin 0 -> 30366 bytes .../oxygen/scalable/actions/irc-operator.svgz | Bin 0 -> 23191 bytes .../scalable/actions/irc-remove-operator.svgz | Bin 0 -> 30223 bytes .../oxygen/scalable/actions/irc-unvoice.svgz | Bin 0 -> 11643 bytes icons/oxygen/scalable/actions/irc-voice.svgz | Bin 0 -> 7045 bytes .../scalable/actions/list-add-user.svgz | Bin 0 -> 21138 bytes icons/oxygen/scalable/actions/list-add.svgz | Bin 0 -> 3730 bytes .../scalable/actions/list-remove-user.svgz | Bin 0 -> 25544 bytes .../actions/media-playback-start.svgz | Bin 0 -> 1916 bytes .../scalable/actions/network-connect.svgz | Bin 0 -> 7341 bytes .../scalable/actions/network-disconnect.svgz | Bin 0 -> 5582 bytes icons/oxygen/scalable/actions/show-menu.svgz | Bin 0 -> 144990 bytes .../scalable/actions/tools-report-bug.svgz | Bin 0 -> 20091 bytes .../scalable/actions/view-fullscreen.svgz | Bin 0 -> 26973 bytes .../oxygen/scalable/actions/view-refresh.svgz | Bin 0 -> 7398 bytes icons/oxygen/scalable/apps/quassel.svgz | Bin 0 -> 202877 bytes .../scalable/devices/network-wired.svgz | Bin 0 -> 30777 bytes .../scalable/status/dialog-information.svgz | Bin 0 -> 14132 bytes .../oxygen/scalable/status/security-high.svgz | Bin 0 -> 3854 bytes .../oxygen/scalable/status/security-low.svgz | Bin 0 -> 4266 bytes icons/oxygen/scalable/status/user-away.svgz | Bin 0 -> 2438 bytes interfaces/org.freedesktop.DockItem.xml | 23 + interfaces/org.freedesktop.DockManager.xml | 43 + interfaces/org.freedesktop.Notifications.xml | 37 + interfaces/org.kde.StatusNotifierItem.xml | 95 + interfaces/org.kde.StatusNotifierWatcher.xml | 43 + pics/CMakeLists.txt | 28 + pics/README.qt-logo | 3 + pics/kde-vdg.png | Bin 0 -> 1196 bytes pics/pics.qrc | 9 + pics/qt-logo-32.png | Bin 0 -> 629 bytes pics/qt-logo.png | Bin 0 -> 2238 bytes pics/quassel-eye.png | Bin 0 -> 2604 bytes pics/quassel-logo.png | Bin 0 -> 89681 bytes pics/quassel-logo.svgz | Bin 0 -> 220482 bytes pics/quassel.icns | Bin 0 -> 50647 bytes pics/quassel.ico | Bin 0 -> 388598 bytes pics/win32.rc | 1 + po/CMakeLists.txt | 70 + po/LINGUAS | 36 + po/README.Translations | 36 + po/cs.po | 6755 +++++++ po/da.po | 6746 +++++++ po/de.po | 6749 +++++++ po/el.po | 6748 +++++++ po/en_GB.po | 6740 +++++++ po/en_US.po | 6738 +++++++ po/eo.po | 6741 +++++++ po/es.po | 6746 +++++++ po/et.po | 6740 +++++++ po/fi.po | 6745 +++++++ po/fr.po | 6748 +++++++ po/gl.po | 6743 +++++++ po/hi.po | 6740 +++++++ po/hu.po | 6741 +++++++ po/it.po | 6741 +++++++ po/ja.po | 6729 +++++++ po/ko.po | 6731 +++++++ po/lt.po | 6750 +++++++ po/mr.po | 6740 +++++++ po/nb.po | 6745 +++++++ po/nl.po | 6743 +++++++ po/oc.po | 6741 +++++++ po/pa.po | 6740 +++++++ po/pl.po | 6763 +++++++ po/pt.po | 6740 +++++++ po/pt_BR.po | 6744 +++++++ po/pull-from-transifex.sh | 35 + po/quassel.pot | 7849 ++++++++ po/quassel.pot.patch | 14 + po/ro.po | 6752 +++++++ po/ru.po | 6765 +++++++ po/sl.po | 6763 +++++++ po/sq.po | 6740 +++++++ po/sr.po | 6751 +++++++ po/sv.po | 6741 +++++++ po/tr.po | 6745 +++++++ po/uk.po | 6752 +++++++ po/update-pot.sh | 6 + po/update.sh | 10 + po/zh_CN.po | 6730 +++++++ po/zh_TW.po | 6727 +++++++ scripts/build/Info.plist | 36 + scripts/build/NullsoftInstaller.nsi | 271 + scripts/build/SnoreNotify.nsh | 22 + scripts/build/macosx_DeployApp.py | 258 + scripts/build/macosx_makePackage.sh | 85 + scripts/build/macosx_makebundle.py | 72 + scripts/convert_mirc_servers_ini.pl | 33 + scripts/manage/format_source.cfg | 176 + scripts/manage/format_source.sh | 32 + scripts/tx-sync.sh | 12 + snap.wrapper | 21 + snapcraft.yaml | 34 + src/CMakeLists.txt | 96 + src/client/CMakeLists.txt | 50 + src/client/abstractmessageprocessor.cpp | 28 + src/client/abstractmessageprocessor.h | 48 + src/client/abstractui.h | 57 + src/client/backlogrequester.cpp | 146 + src/client/backlogrequester.h | 122 + src/client/backlogsettings.h | 51 + src/client/buffermodel.cpp | 173 + src/client/buffermodel.h | 80 + src/client/buffersettings.cpp | 58 + src/client/buffersettings.h | 64 + src/client/bufferviewoverlay.cpp | 338 + src/client/bufferviewoverlay.h | 94 + src/client/client.cpp | 713 + src/client/client.h | 277 + src/client/clientaliasmanager.cpp | 35 + src/client/clientaliasmanager.h | 41 + src/client/clientauthhandler.cpp | 539 + src/client/clientauthhandler.h | 122 + src/client/clientbacklogmanager.cpp | 188 + src/client/clientbacklogmanager.h | 78 + src/client/clientbufferviewconfig.cpp | 42 + src/client/clientbufferviewconfig.h | 47 + src/client/clientbufferviewmanager.cpp | 65 + src/client/clientbufferviewmanager.h | 48 + src/client/clientcoreinfo.h | 50 + src/client/clientidentity.cpp | 126 + src/client/clientidentity.h | 95 + src/client/clientignorelistmanager.cpp | 60 + src/client/clientignorelistmanager.h | 53 + src/client/clientirclisthelper.cpp | 59 + src/client/clientirclisthelper.h | 52 + src/client/clientsettings.cpp | 426 + src/client/clientsettings.h | 192 + src/client/clienttransfer.cpp | 102 + src/client/clienttransfer.h | 57 + src/client/clienttransfermanager.cpp | 71 + src/client/clienttransfermanager.h | 52 + src/client/clientuserinputhandler.cpp | 141 + src/client/clientuserinputhandler.h | 61 + src/client/coreaccount.cpp | 184 + src/client/coreaccount.h | 98 + src/client/coreaccountmodel.cpp | 257 + src/client/coreaccountmodel.h | 92 + src/client/coreconnection.cpp | 531 + src/client/coreconnection.h | 186 + src/client/execwrapper.cpp | 143 + src/client/execwrapper.h | 60 + src/client/irclistmodel.cpp | 99 + src/client/irclistmodel.h | 55 + src/client/messagefilter.cpp | 246 + src/client/messagefilter.h | 74 + src/client/messagemodel.cpp | 516 + src/client/messagemodel.h | 168 + src/client/networkmodel.cpp | 1488 ++ src/client/networkmodel.h | 391 + src/client/selectionmodelsynchronizer.cpp | 280 + src/client/selectionmodelsynchronizer.h | 72 + src/client/treemodel.cpp | 679 + src/client/treemodel.h | 213 + src/common/CMakeLists.txt | 106 + src/common/abstractcliparser.h | 78 + src/common/aliasmanager.cpp | 213 + src/common/aliasmanager.h | 80 + src/common/authhandler.cpp | 92 + src/common/authhandler.h | 77 + src/common/backlogmanager.cpp | 35 + src/common/backlogmanager.h | 49 + src/common/basichandler.cpp | 106 + src/common/basichandler.h | 56 + src/common/bufferinfo.cpp | 101 + src/common/bufferinfo.h | 88 + src/common/buffersyncer.cpp | 146 + src/common/buffersyncer.h | 88 + src/common/bufferviewconfig.cpp | 296 + src/common/bufferviewconfig.h | 144 + src/common/bufferviewmanager.cpp | 105 + src/common/bufferviewmanager.h | 79 + src/common/cliparser.cpp | 240 + src/common/cliparser.h | 52 + src/common/compressor.cpp | 273 + src/common/compressor.h | 94 + src/common/coreinfo.h | 45 + src/common/ctcpevent.cpp | 53 + src/common/ctcpevent.h | 95 + src/common/event.cpp | 125 + src/common/event.h | 85 + src/common/eventmanager.cpp | 356 + src/common/eventmanager.h | 197 + src/common/identity.cpp | 396 + src/common/identity.h | 192 + src/common/ignorelistmanager.cpp | 217 + src/common/ignorelistmanager.h | 162 + src/common/internalpeer.cpp | 211 + src/common/internalpeer.h | 97 + src/common/ircchannel.cpp | 620 + src/common/ircchannel.h | 155 + src/common/ircevent.cpp | 85 + src/common/ircevent.h | 142 + src/common/irclisthelper.cpp | 23 + src/common/irclisthelper.h | 58 + src/common/ircuser.cpp | 394 + src/common/ircuser.h | 211 + src/common/keyevent.cpp | 47 + src/common/keyevent.h | 79 + src/common/logbacktrace_unix.cpp | 97 + src/common/logbacktrace_win.cpp | 227 + src/common/logger.cpp | 145 + src/common/logger.h | 76 + src/common/mac_utils.cpp | 38 + src/common/mac_utils.h | 29 + src/common/main.cpp | 226 + src/common/message.cpp | 83 + src/common/message.h | 113 + src/common/messageevent.cpp | 92 + src/common/messageevent.h | 85 + src/common/network.cpp | 1095 ++ src/common/network.h | 441 + src/common/networkconfig.cpp | 121 + src/common/networkconfig.h | 110 + src/common/networkevent.cpp | 104 + src/common/networkevent.h | 158 + src/common/peer.cpp | 56 + src/common/peer.h | 122 + src/common/peerfactory.cpp | 60 + src/common/peerfactory.h | 50 + src/common/presetnetworks.cpp | 93 + src/common/presetnetworks.h | 40 + src/common/protocol.h | 235 + .../protocols/datastream/datastreampeer.cpp | 407 + .../protocols/datastream/datastreampeer.h | 84 + src/common/protocols/legacy/legacypeer.cpp | 555 + src/common/protocols/legacy/legacypeer.h | 87 + src/common/qt5cliparser.cpp | 72 + src/common/qt5cliparser.h | 42 + src/common/quassel.cpp | 584 + src/common/quassel.h | 202 + src/common/remotepeer.cpp | 276 + src/common/remotepeer.h | 107 + src/common/serializers/serializers.cpp | 676 + src/common/serializers/serializers.h | 117 + src/common/settings.cpp | 163 + src/common/settings.h | 138 + src/common/signalproxy.cpp | 1003 ++ src/common/signalproxy.h | 229 + src/common/syncableobject.cpp | 237 + src/common/syncableobject.h | 118 + src/common/transfer.cpp | 182 + src/common/transfer.h | 129 + src/common/transfermanager.cpp | 59 + src/common/transfermanager.h | 56 + src/common/types.h | 138 + src/common/util.cpp | 202 + src/common/util.h | 78 + src/core/CMakeLists.txt | 72 + ...e_000_alter_buffer_add_markerlinemsgid.sql | 2 + .../16/upgrade_000_alter_network_add_sasl.sql | 4 + .../PostgreSQL/17/delete_backlog_by_uid.sql | 2 + .../17/delete_backlog_for_buffer.sql | 2 + .../17/delete_backlog_for_network.sql | 2 + .../17/delete_buffer_for_bufferid.sql | 2 + .../PostgreSQL/17/delete_buffers_by_uid.sql | 2 + .../17/delete_buffers_for_network.sql | 2 + .../SQL/PostgreSQL/17/delete_identity.sql | 2 + .../17/delete_ircservers_for_network.sql | 2 + src/core/SQL/PostgreSQL/17/delete_network.sql | 2 + .../PostgreSQL/17/delete_networks_by_uid.sql | 2 + src/core/SQL/PostgreSQL/17/delete_nicks.sql | 2 + .../SQL/PostgreSQL/17/delete_quasseluser.sql | 2 + src/core/SQL/PostgreSQL/17/insert_buffer.sql | 3 + .../SQL/PostgreSQL/17/insert_identity.sql | 3 + src/core/SQL/PostgreSQL/17/insert_message.sql | 3 + src/core/SQL/PostgreSQL/17/insert_network.sql | 3 + src/core/SQL/PostgreSQL/17/insert_nick.sql | 2 + .../SQL/PostgreSQL/17/insert_quasseluser.sql | 3 + src/core/SQL/PostgreSQL/17/insert_sender.sql | 3 + src/core/SQL/PostgreSQL/17/insert_server.sql | 2 + .../SQL/PostgreSQL/17/insert_user_setting.sql | 2 + .../PostgreSQL/17/migrate_write_backlog.sql | 2 + .../PostgreSQL/17/migrate_write_buffer.sql | 2 + .../PostgreSQL/17/migrate_write_identity.sql | 3 + .../17/migrate_write_identity_nick.sql | 2 + .../PostgreSQL/17/migrate_write_ircserver.sql | 2 + .../PostgreSQL/17/migrate_write_network.sql | 2 + .../17/migrate_write_quasseluser.sql | 2 + .../PostgreSQL/17/migrate_write_sender.sql | 2 + .../17/migrate_write_usersetting.sql | 2 + .../SQL/PostgreSQL/17/select_authuser.sql | 3 + .../SQL/PostgreSQL/17/select_bufferByName.sql | 3 + .../SQL/PostgreSQL/17/select_bufferExists.sql | 3 + .../SQL/PostgreSQL/17/select_buffer_by_id.sql | 3 + .../17/select_buffer_lastseen_messages.sql | 3 + .../17/select_buffer_markerlinemsgids.sql | 3 + src/core/SQL/PostgreSQL/17/select_buffers.sql | 4 + .../17/select_buffers_for_network.sql | 4 + .../PostgreSQL/17/select_checkidentity.sql | 3 + .../17/select_connected_networks.sql | 3 + .../SQL/PostgreSQL/17/select_identities.sql | 6 + .../SQL/PostgreSQL/17/select_internaluser.sql | 2 + .../SQL/PostgreSQL/17/select_messages.sql | 6 + .../SQL/PostgreSQL/17/select_messagesAll.sql | 7 + .../PostgreSQL/17/select_messagesAllNew.sql | 6 + .../17/select_messagesNewerThan.sql | 6 + .../PostgreSQL/17/select_messagesRange.sql | 8 + .../PostgreSQL/17/select_networkExists.sql | 3 + .../PostgreSQL/17/select_network_awaymsg.sql | 3 + .../PostgreSQL/17/select_network_usermode.sql | 3 + .../17/select_networks_for_user.sql | 6 + src/core/SQL/PostgreSQL/17/select_nicks.sql | 4 + .../17/select_persistent_channels.sql | 3 + .../SQL/PostgreSQL/17/select_senderid.sql | 3 + .../17/select_servers_for_network.sql | 3 + .../SQL/PostgreSQL/17/select_user_setting.sql | 3 + src/core/SQL/PostgreSQL/17/select_userid.sql | 3 + .../PostgreSQL/17/setup_000_quasseluser.sql | 6 + .../SQL/PostgreSQL/17/setup_010_sender.sql | 4 + .../SQL/PostgreSQL/17/setup_020_identity.sql | 24 + .../PostgreSQL/17/setup_030_identity_nick.sql | 6 + .../SQL/PostgreSQL/17/setup_040_network.sql | 28 + .../SQL/PostgreSQL/17/setup_050_buffer.sql | 14 + .../SQL/PostgreSQL/17/setup_060_backlog.sql | 9 + .../SQL/PostgreSQL/17/setup_070_coreinfo.sql | 4 + .../PostgreSQL/17/setup_080_ircservers.sql | 16 + .../PostgreSQL/17/setup_090_backlog_idx.sql | 1 + .../PostgreSQL/17/setup_100_user_setting.sql | 6 + .../17/setup_110_alter_sender_seq.sql | 1 + .../17/setup_120_alter_messageid_seq.sql | 1 + .../PostgreSQL/17/update_backlog_bufferid.sql | 3 + .../PostgreSQL/17/update_buffer_lastseen.sql | 3 + .../17/update_buffer_markerlinemsgid.sql | 3 + .../SQL/PostgreSQL/17/update_buffer_name.sql | 3 + .../17/update_buffer_persistent_channel.sql | 3 + .../17/update_buffer_set_channel_key.sql | 3 + .../SQL/PostgreSQL/17/update_identity.sql | 21 + src/core/SQL/PostgreSQL/17/update_network.sql | 21 + .../17/update_network_connected.sql | 3 + .../17/update_network_set_awaymsg.sql | 3 + .../17/update_network_set_usermode.sql | 3 + .../SQL/PostgreSQL/17/update_user_setting.sql | 3 + .../SQL/PostgreSQL/17/update_username.sql | 3 + .../SQL/PostgreSQL/17/update_userpassword.sql | 3 + ..._alter_quasseluser_add_passwordversion.sql | 3 + .../SQLite/1/upgrade_000_drop_coreinfo.sql | 1 + .../SQLite/1/upgrade_010_create_coreinfo.sql | 3 + .../1/upgrade_020_update_schemaversion.sql | 1 + .../SQLite/10/upgrade_000_switch_to_msgid.sql | 3 + .../10/upgrade_010_rename_buffer_table.sql | 1 + .../10/upgrade_020_create_buffer_table.sql | 12 + .../10/upgrade_030_copy_buffer_table.sql | 2 + .../10/upgrade_040_drop_buffer_old_table.sql | 1 + .../11/upgrade_000_create_user_setting.sql | 6 + .../SQLite/12/upgrade_000_create_identity.sql | 24 + .../12/upgrade_010_create_identity_nick.sql | 6 + .../12/upgrade_020_rename_servertable.sql | 1 + .../12/upgrade_030_create_ircserver.sql | 16 + .../SQLite/12/upgrade_040_copy_ircserver.sql | 2 + .../12/upgrade_050_drop_ircserverold.sql | 1 + .../13/upgrade_000_create_buffer_user_idx.sql | 1 + .../upgrade_010_create_buffer_cname_idx.sql | 2 + .../upgrade_020_create_buffer_cname_idx.sql | 2 + .../14/upgrade_000_rename_networktable.sql | 1 + .../14/upgrade_010_create_networktable.sql | 25 + .../14/upgrade_030_copy_networktable.sql | 2 + .../SQLite/14/upgrade_040_drop_networkold.sql | 1 + .../SQLite/15/upgrade_000_fix_ircservers.sql | 3 + .../SQL/SQLite/15/upgrade_000_fix_network.sql | 7 + ...e_000_alter_buffer_add_markerlinemsgid.sql | 2 + .../17/upgrade_000_alter_network_add_sasl.sql | 3 + .../17/upgrade_001_alter_network_add_sasl.sql | 3 + .../17/upgrade_002_alter_network_add_sasl.sql | 3 + .../SQL/SQLite/18/delete_backlog_by_uid.sql | 2 + .../SQLite/18/delete_backlog_for_buffer.sql | 2 + .../SQLite/18/delete_backlog_for_network.sql | 2 + .../SQLite/18/delete_buffer_for_bufferid.sql | 2 + .../SQL/SQLite/18/delete_buffers_by_uid.sql | 2 + .../SQLite/18/delete_buffers_for_network.sql | 2 + src/core/SQL/SQLite/18/delete_identity.sql | 2 + .../18/delete_ircservers_for_network.sql | 2 + src/core/SQL/SQLite/18/delete_network.sql | 3 + .../SQL/SQLite/18/delete_networks_by_uid.sql | 2 + src/core/SQL/SQLite/18/delete_nicks.sql | 2 + src/core/SQL/SQLite/18/delete_quasseluser.sql | 2 + src/core/SQL/SQLite/18/insert_buffer.sql | 2 + src/core/SQL/SQLite/18/insert_identity.sql | 2 + src/core/SQL/SQLite/18/insert_message.sql | 2 + src/core/SQL/SQLite/18/insert_network.sql | 4 + src/core/SQL/SQLite/18/insert_nick.sql | 2 + src/core/SQL/SQLite/18/insert_quasseluser.sql | 2 + src/core/SQL/SQLite/18/insert_sender.sql | 2 + src/core/SQL/SQLite/18/insert_server.sql | 2 + .../SQL/SQLite/18/insert_user_setting.sql | 2 + .../SQL/SQLite/18/migrate_read_backlog.sql | 4 + .../SQL/SQLite/18/migrate_read_buffer.sql | 2 + .../SQL/SQLite/18/migrate_read_identity.sql | 4 + .../SQLite/18/migrate_read_identity_nick.sql | 2 + .../SQL/SQLite/18/migrate_read_ircserver.sql | 2 + .../SQL/SQLite/18/migrate_read_network.sql | 6 + .../SQLite/18/migrate_read_quasseluser.sql | 2 + .../SQL/SQLite/18/migrate_read_sender.sql | 5 + .../SQLite/18/migrate_read_usersetting.sql | 3 + src/core/SQL/SQLite/18/select_authuser.sql | 3 + .../SQL/SQLite/18/select_bufferByName.sql | 3 + .../SQL/SQLite/18/select_bufferExists.sql | 3 + .../SQL/SQLite/18/select_buffer_by_id.sql | 3 + .../18/select_buffer_lastseen_messages.sql | 3 + .../18/select_buffer_markerlinemsgids.sql | 3 + src/core/SQL/SQLite/18/select_buffers.sql | 4 + .../SQLite/18/select_buffers_for_merge.sql | 3 + .../SQLite/18/select_buffers_for_network.sql | 4 + .../SQL/SQLite/18/select_checkidentity.sql | 3 + .../SQLite/18/select_connected_networks.sql | 3 + src/core/SQL/SQLite/18/select_identities.sql | 6 + .../SQL/SQLite/18/select_internaluser.sql | 2 + src/core/SQL/SQLite/18/select_messages.sql | 8 + src/core/SQL/SQLite/18/select_messagesAll.sql | 8 + .../SQL/SQLite/18/select_messagesAllNew.sql | 7 + .../SQLite/18/select_messagesNewerThan.sql | 7 + .../SQL/SQLite/18/select_messagesNewestK.sql | 6 + .../SQL/SQLite/18/select_networkExists.sql | 3 + .../SQL/SQLite/18/select_network_awaymsg.sql | 3 + .../SQL/SQLite/18/select_network_usermode.sql | 3 + .../SQLite/18/select_networks_for_user.sql | 6 + src/core/SQL/SQLite/18/select_nicks.sql | 4 + .../SQLite/18/select_persistent_channels.sql | 3 + .../SQLite/18/select_servers_for_network.sql | 3 + .../SQL/SQLite/18/select_user_setting.sql | 3 + src/core/SQL/SQLite/18/select_userid.sql | 3 + .../SQL/SQLite/18/setup_000_quasseluser.sql | 6 + src/core/SQL/SQLite/18/setup_010_sender.sql | 6 + src/core/SQL/SQLite/18/setup_020_network.sql | 28 + src/core/SQL/SQLite/18/setup_030_buffer.sql | 13 + .../SQL/SQLite/18/setup_040_buffer_idx.sql | 2 + .../SQLite/18/setup_050_buffer_cname_idx.sql | 2 + src/core/SQL/SQLite/18/setup_060_backlog.sql | 8 + src/core/SQL/SQLite/18/setup_070_coreinfo.sql | 3 + .../SQL/SQLite/18/setup_080_ircservers.sql | 16 + .../SQL/SQLite/18/setup_090_backlog_idx.sql | 1 + .../SQL/SQLite/18/setup_100_backlog_idx2.sql | 1 + .../SQLite/18/setup_110_buffer_user_idx.sql | 1 + .../SQL/SQLite/18/setup_120_user_setting.sql | 6 + src/core/SQL/SQLite/18/setup_130_identity.sql | 24 + .../SQL/SQLite/18/setup_140_identity_nick.sql | 6 + .../SQL/SQLite/18/update_backlog_bufferid.sql | 3 + .../SQL/SQLite/18/update_buffer_lastseen.sql | 3 + .../18/update_buffer_markerlinemsgid.sql | 3 + src/core/SQL/SQLite/18/update_buffer_name.sql | 3 + .../18/update_buffer_persistent_channel.sql | 3 + .../18/update_buffer_set_channel_key.sql | 3 + src/core/SQL/SQLite/18/update_identity.sql | 21 + src/core/SQL/SQLite/18/update_network.sql | 20 + .../SQLite/18/update_network_connected.sql | 3 + .../SQLite/18/update_network_set_awaymsg.sql | 3 + .../SQLite/18/update_network_set_usermode.sql | 3 + .../SQL/SQLite/18/update_user_setting.sql | 3 + src/core/SQL/SQLite/18/update_username.sql | 3 + .../SQL/SQLite/18/update_userpassword.sql | 3 + ..._alter_quasseluser_add_passwordversion.sql | 2 + .../SQLite/2/upgrade_000_drop_buffergroup.sql | 1 + .../2/upgrade_010_update_schemaversion.sql | 3 + .../3/upgrade_000_update_backlog_flags.sql | 1 + .../3/upgrade_010_update_schemaversion.sql | 3 + .../4/upgrade_000_rename_buffertable.sql | 1 + .../4/upgrade_010_create_buffertable.sql | 8 + .../SQLite/4/upgrade_020_copy_buffertable.sql | 2 + .../4/upgrade_030_drop_oldbuffertable.sql | 1 + .../4/upgrade_040_create_buffer_idx.sql | 2 + .../4/upgrade_050_create_buffer_cname_idx.sql | 2 + .../5/upgrade_000_rename_networktable.sql | 1 + .../5/upgrade_010_create_newnetworktable.sql | 19 + .../5/upgrade_020_copy_networktable.sql | 2 + .../5/upgrade_030_drop_oldnetworktable.sql | 1 + .../5/upgrade_180_create_ircservers.sql | 9 + .../6/upgrade_000_alter_buffertable.sql | 2 + .../6/upgrade_010_set_statusbuffertype.sql | 3 + .../6/upgrade_020_set_channelbuffertype.sql | 3 + .../6/upgrade_030_set_querybuffertype.sql | 3 + .../SQLite/6/upgrade_040_update_msgtype.sql | 1 + .../SQLite/6/upgrade_050_update_msgtype.sql | 1 + .../SQLite/6/upgrade_060_update_msgtype.sql | 1 + .../SQLite/6/upgrade_070_update_msgtype.sql | 1 + .../SQLite/6/upgrade_080_update_msgtype.sql | 1 + .../SQLite/6/upgrade_090_update_msgtype.sql | 1 + .../SQLite/6/upgrade_100_update_msgtype.sql | 1 + .../SQLite/6/upgrade_110_update_msgtype.sql | 1 + .../SQLite/6/upgrade_120_update_msgtype.sql | 1 + .../SQLite/6/upgrade_130_update_msgtype.sql | 1 + .../SQLite/6/upgrade_140_update_msgtype.sql | 1 + .../SQLite/6/upgrade_150_update_msgtype.sql | 1 + .../SQLite/6/upgrade_160_update_msgtype.sql | 1 + .../7/upgrade_000_rename_networktable.sql | 1 + .../7/upgrade_010_create_newnetworktable.sql | 20 + .../7/upgrade_020_copy_networktable.sql | 2 + .../7/upgrade_030_drop_oldnetworktable.sql | 1 + .../upgrade_040_alter_buffer_add_lastseen.sql | 1 + ...pgrade_000_alter_network_add_connected.sql | 2 + .../8/upgrade_010_alter_buffer_add_key.sql | 2 + .../8/upgrade_020_alter_buffer_add_joined.sql | 2 + ..._update_buffer_set_joined_for_channels.sql | 3 + .../9/upgrade_000_create_backlog_idx.sql | 1 + .../9/upgrade_010_create_backlog_idx2.sql | 1 + .../9/upgrade_020_create_buffer_idx.sql | 1 + src/core/SQL/upgradeSchema.sh | 26 + src/core/UPDATE_SQL_RESOURCE.sh | 11 + src/core/abstractsqlstorage.cpp | 573 + src/core/abstractsqlstorage.h | 337 + src/core/cipher.cpp | 496 + src/core/cipher.h | 55 + src/core/core.cpp | 973 + src/core/core.h | 594 + src/core/corealiasmanager.cpp | 70 + src/core/corealiasmanager.h | 49 + src/core/coreapplication.cpp | 117 + src/core/coreapplication.h | 78 + src/core/coreauthhandler.cpp | 256 + src/core/coreauthhandler.h | 71 + src/core/corebacklogmanager.cpp | 117 + src/core/corebacklogmanager.h | 47 + src/core/corebasichandler.cpp | 150 + src/core/corebasichandler.h | 105 + src/core/corebuffersyncer.cpp | 183 + src/core/corebuffersyncer.h | 69 + src/core/corebufferviewconfig.cpp | 35 + src/core/corebufferviewconfig.h | 46 + src/core/corebufferviewmanager.cpp | 104 + src/core/corebufferviewmanager.h | 51 + src/core/corecoreinfo.cpp | 44 + src/core/corecoreinfo.h | 50 + src/core/coreeventmanager.h | 45 + src/core/coreidentity.cpp | 138 + src/core/coreidentity.h | 115 + src/core/coreignorelistmanager.cpp | 70 + src/core/coreignorelistmanager.h | 59 + src/core/coreircchannel.cpp | 88 + src/core/coreircchannel.h | 58 + src/core/coreirclisthelper.cpp | 99 + src/core/coreirclisthelper.h | 65 + src/core/coreircuser.cpp | 49 + src/core/coreircuser.h | 52 + src/core/corenetwork.cpp | 1123 ++ src/core/corenetwork.h | 335 + src/core/corenetworkconfig.cpp | 49 + src/core/corenetworkconfig.h | 52 + src/core/coresession.cpp | 693 + src/core/coresession.h | 237 + src/core/coresessioneventprocessor.cpp | 1118 ++ src/core/coresessioneventprocessor.h | 159 + src/core/coresettings.cpp | 63 + src/core/coresettings.h | 42 + src/core/coretransfer.cpp | 188 + src/core/coretransfer.h | 64 + src/core/coretransfermanager.cpp | 55 + src/core/coretransfermanager.h | 50 + src/core/coreuserinputhandler.cpp | 918 + src/core/coreuserinputhandler.h | 114 + src/core/coreusersettings.cpp | 91 + src/core/coreusersettings.h | 56 + src/core/ctcpparser.cpp | 372 + src/core/ctcpparser.h | 102 + src/core/eventstringifier.cpp | 751 + src/core/eventstringifier.h | 126 + src/core/ircparser.cpp | 329 + src/core/ircparser.h | 57 + src/core/netsplit.cpp | 187 + src/core/netsplit.h | 143 + src/core/oidentdconfiggenerator.cpp | 145 + src/core/oidentdconfiggenerator.h | 91 + src/core/postgresqlstorage.cpp | 2015 +++ src/core/postgresqlstorage.h | 185 + src/core/sessionthread.cpp | 130 + src/core/sessionthread.h | 74 + src/core/sql.qrc | 250 + src/core/sqlitestorage.cpp | 1997 +++ src/core/sqlitestorage.h | 169 + src/core/sslserver.cpp | 246 + src/core/sslserver.h | 91 + src/core/storage.cpp | 115 + src/core/storage.h | 431 + src/qtui/CMakeLists.txt | 201 + src/qtui/aboutdlg.cpp | 119 + src/qtui/aboutdlg.h | 49 + src/qtui/awaylogfilter.cpp | 60 + src/qtui/awaylogfilter.h | 39 + src/qtui/awaylogview.cpp | 56 + src/qtui/awaylogview.h | 38 + src/qtui/bufferwidget.cpp | 301 + src/qtui/bufferwidget.h | 80 + src/qtui/channellistdlg.cpp | 178 + src/qtui/channellistdlg.h | 70 + src/qtui/chatitem.cpp | 937 + src/qtui/chatitem.h | 307 + src/qtui/chatline.cpp | 300 + src/qtui/chatline.h | 117 + src/qtui/chatlinemodel.cpp | 86 + src/qtui/chatlinemodel.h | 74 + src/qtui/chatlinemodelitem.cpp | 247 + src/qtui/chatlinemodelitem.h | 73 + src/qtui/chatmonitorfilter.cpp | 206 + src/qtui/chatmonitorfilter.h | 75 + src/qtui/chatmonitorview.cpp | 125 + src/qtui/chatmonitorview.h | 52 + src/qtui/chatscene.cpp | 1313 ++ src/qtui/chatscene.h | 253 + src/qtui/chatview.cpp | 461 + src/qtui/chatview.h | 124 + src/qtui/chatviewsearchbar.cpp | 80 + src/qtui/chatviewsearchbar.h | 63 + src/qtui/chatviewsearchcontroller.cpp | 486 + src/qtui/chatviewsearchcontroller.h | 122 + src/qtui/chatviewsettings.cpp | 41 + src/qtui/chatviewsettings.h | 57 + src/qtui/columnhandleitem.cpp | 167 + src/qtui/columnhandleitem.h | 77 + src/qtui/coreconfigwizard.cpp | 424 + src/qtui/coreconfigwizard.h | 173 + src/qtui/coreconnectdlg.cpp | 107 + src/qtui/coreconnectdlg.h | 65 + src/qtui/coreconnectionstatuswidget.cpp | 101 + src/qtui/coreconnectionstatuswidget.h | 54 + src/qtui/coreinfodlg.cpp | 60 + src/qtui/coreinfodlg.h | 52 + src/qtui/debugbufferviewoverlay.cpp | 107 + src/qtui/debugbufferviewoverlay.h | 56 + src/qtui/debugconsole.cpp | 51 + src/qtui/debugconsole.h | 48 + src/qtui/debuglogwidget.cpp | 41 + src/qtui/debuglogwidget.h | 41 + src/qtui/debugmessagemodelfilter.cpp | 59 + src/qtui/debugmessagemodelfilter.h | 37 + src/qtui/dockmanagernotificationbackend.cpp | 227 + src/qtui/dockmanagernotificationbackend.h | 82 + src/qtui/indicatornotificationbackend.cpp | 227 + src/qtui/indicatornotificationbackend.h | 90 + src/qtui/inputwidget.cpp | 651 + src/qtui/inputwidget.h | 122 + src/qtui/ircconnectionwizard.cpp | 178 + src/qtui/ircconnectionwizard.h | 95 + src/qtui/knotificationbackend.cpp | 179 + src/qtui/knotificationbackend.h | 73 + src/qtui/legacysystemtray.cpp | 192 + src/qtui/legacysystemtray.h | 92 + src/qtui/mainpage.cpp | 45 + src/qtui/mainpage.h | 38 + src/qtui/mainwin.cpp | 1740 ++ src/qtui/mainwin.h | 229 + src/qtui/markerlineitem.cpp | 74 + src/qtui/markerlineitem.h | 58 + src/qtui/monoapplication.cpp | 85 + src/qtui/monoapplication.h | 55 + src/qtui/msgprocessorstatuswidget.cpp | 42 + src/qtui/msgprocessorstatuswidget.h | 41 + src/qtui/nicklistwidget.cpp | 245 + src/qtui/nicklistwidget.h | 86 + src/qtui/osxnotificationbackend.h | 66 + src/qtui/osxnotificationbackend.mm | 126 + src/qtui/passwordchangedlg.cpp | 75 + src/qtui/passwordchangedlg.h | 42 + src/qtui/phononnotificationbackend.cpp | 210 + src/qtui/phononnotificationbackend.h | 85 + src/qtui/qtui.cpp | 250 + src/qtui/qtui.h | 96 + src/qtui/qtuiapplication.cpp | 215 + src/qtui/qtuiapplication.h | 71 + src/qtui/qtuimessageprocessor.cpp | 201 + src/qtui/qtuimessageprocessor.h | 81 + src/qtui/qtuisettings.cpp | 64 + src/qtui/qtuisettings.h | 54 + src/qtui/qtuistyle.cpp | 175 + src/qtui/qtuistyle.h | 54 + src/qtui/receivefiledlg.cpp | 47 + src/qtui/receivefiledlg.h | 43 + src/qtui/settingsdlg.cpp | 252 + src/qtui/settingsdlg.h | 67 + src/qtui/settingspagedlg.cpp | 135 + src/qtui/settingspagedlg.h | 53 + src/qtui/settingspages/aliasesmodel.cpp | 283 + src/qtui/settingspages/aliasesmodel.h | 95 + .../settingspages/aliasessettingspage.cpp | 86 + src/qtui/settingspages/aliasessettingspage.h | 55 + src/qtui/settingspages/aliasessettingspage.ui | 68 + .../settingspages/appearancesettingspage.cpp | 269 + .../settingspages/appearancesettingspage.h | 66 + .../settingspages/appearancesettingspage.ui | 495 + .../settingspages/backlogsettingspage.cpp | 78 + src/qtui/settingspages/backlogsettingspage.h | 52 + src/qtui/settingspages/backlogsettingspage.ui | 477 + src/qtui/settingspages/buffervieweditdlg.ui | 91 + .../settingspages/bufferviewsettingspage.cpp | 594 + .../settingspages/bufferviewsettingspage.h | 112 + .../settingspages/bufferviewsettingspage.ui | 251 + .../settingspages/chatmonitorsettingspage.cpp | 279 + .../settingspages/chatmonitorsettingspage.h | 62 + .../settingspages/chatmonitorsettingspage.ui | 230 + .../settingspages/chatviewsettingspage.cpp | 53 + src/qtui/settingspages/chatviewsettingspage.h | 48 + .../settingspages/chatviewsettingspage.ui | 894 + .../settingspages/connectionsettingspage.cpp | 119 + .../settingspages/connectionsettingspage.h | 54 + .../settingspages/connectionsettingspage.ui | 283 + src/qtui/settingspages/coreaccounteditdlg.ui | 351 + .../settingspages/coreaccountsettingspage.cpp | 335 + .../settingspages/coreaccountsettingspage.h | 134 + .../settingspages/coreaccountsettingspage.ui | 232 + .../coreconnectionsettingspage.cpp | 96 + .../coreconnectionsettingspage.h | 59 + .../coreconnectionsettingspage.ui | 268 + src/qtui/settingspages/createidentitydlg.ui | 151 + .../settingspages/highlightsettingspage.cpp | 294 + .../settingspages/highlightsettingspage.h | 73 + .../settingspages/highlightsettingspage.ui | 162 + .../settingspages/identitiessettingspage.cpp | 496 + .../settingspages/identitiessettingspage.h | 132 + .../settingspages/identitiessettingspage.ui | 114 + src/qtui/settingspages/identityeditwidget.cpp | 439 + src/qtui/settingspages/identityeditwidget.h | 116 + src/qtui/settingspages/identityeditwidget.ui | 795 + src/qtui/settingspages/ignorelisteditdlg.ui | 289 + src/qtui/settingspages/ignorelistmodel.cpp | 327 + src/qtui/settingspages/ignorelistmodel.h | 99 + .../settingspages/ignorelistsettingspage.cpp | 357 + .../settingspages/ignorelistsettingspage.h | 105 + .../settingspages/ignorelistsettingspage.ui | 83 + .../settingspages/inputwidgetsettingspage.cpp | 33 + .../settingspages/inputwidgetsettingspage.h | 43 + .../settingspages/inputwidgetsettingspage.ui | 360 + .../settingspages/itemviewsettingspage.cpp | 82 + src/qtui/settingspages/itemviewsettingspage.h | 56 + .../settingspages/itemviewsettingspage.ui | 473 + src/qtui/settingspages/keysequencewidget.cpp | 404 + src/qtui/settingspages/keysequencewidget.h | 110 + src/qtui/settingspages/networkadddlg.ui | 257 + src/qtui/settingspages/networkeditdlg.ui | 90 + .../settingspages/networkssettingspage.cpp | 966 + src/qtui/settingspages/networkssettingspage.h | 182 + .../settingspages/networkssettingspage.ui | 839 + src/qtui/settingspages/nickeditdlg.ui | 96 + .../notificationssettingspage.cpp | 87 + .../settingspages/notificationssettingspage.h | 56 + src/qtui/settingspages/previewbufferview.h | 39 + src/qtui/settingspages/saveidentitiesdlg.ui | 127 + src/qtui/settingspages/servereditdlg.ui | 356 + src/qtui/settingspages/settingspages.cmake | 50 + src/qtui/settingspages/shortcutsmodel.cpp | 254 + src/qtui/settingspages/shortcutsmodel.h | 98 + .../settingspages/shortcutssettingspage.cpp | 176 + .../settingspages/shortcutssettingspage.h | 76 + .../settingspages/shortcutssettingspage.ui | 123 + .../settingspages/topicwidgetsettingspage.cpp | 29 + .../settingspages/topicwidgetsettingspage.h | 43 + .../settingspages/topicwidgetsettingspage.ui | 162 + src/qtui/simplenetworkeditor.cpp | 156 + src/qtui/simplenetworkeditor.h | 62 + src/qtui/snorenotificationbackend.cpp | 182 + src/qtui/snorenotificationbackend.h | 81 + src/qtui/sslinfodlg.cpp | 104 + src/qtui/sslinfodlg.h | 57 + src/qtui/statusnotifieritem.cpp | 360 + src/qtui/statusnotifieritem.h | 102 + src/qtui/statusnotifieritemdbus.cpp | 367 + src/qtui/statusnotifieritemdbus.h | 251 + src/qtui/systemtray.cpp | 201 + src/qtui/systemtray.h | 140 + src/qtui/systraynotificationbackend.cpp | 202 + src/qtui/systraynotificationbackend.h | 82 + src/qtui/taskbarnotificationbackend.cpp | 144 + src/qtui/taskbarnotificationbackend.h | 77 + src/qtui/titlesetter.cpp | 64 + src/qtui/titlesetter.h | 45 + src/qtui/topicwidget.cpp | 291 + src/qtui/topicwidget.h | 70 + src/qtui/ui/aboutdlg.ui | 247 + src/qtui/ui/bufferviewwidget.ui | 56 + src/qtui/ui/bufferwidget.ui | 76 + src/qtui/ui/channellistdlg.ui | 169 + src/qtui/ui/chatviewsearchbar.ui | 113 + src/qtui/ui/coreconfigwizardadminuserpage.ui | 97 + src/qtui/ui/coreconfigwizardintropage.ui | 30 + .../coreconfigwizardstorageselectionpage.ui | 92 + src/qtui/ui/coreconfigwizardsyncpage.ui | 116 + src/qtui/ui/coreconnectauthdlg.ui | 128 + src/qtui/ui/coreconnectionstatuswidget.ui | 67 + src/qtui/ui/coreinfodlg.ui | 130 + src/qtui/ui/debugbufferviewoverlay.ui | 48 + src/qtui/ui/debugconsole.ui | 103 + src/qtui/ui/debuglogwidget.ui | 83 + .../ui/indicatornotificationconfigwidget.ui | 44 + src/qtui/ui/inputwidget.ui | 313 + src/qtui/ui/msgprocessorstatuswidget.ui | 55 + src/qtui/ui/nicklistwidget.ui | 52 + src/qtui/ui/passwordchangedlg.ui | 124 + src/qtui/ui/phononnotificationconfigwidget.ui | 113 + src/qtui/ui/receivefiledlg.ui | 74 + src/qtui/ui/settingsdlg.ui | 88 + src/qtui/ui/settingspagedlg.ui | 71 + src/qtui/ui/simplenetworkeditor.ui | 271 + src/qtui/ui/snorentificationconfigwidget.ui | 64 + src/qtui/ui/sslinfodlg.ui | 521 + src/qtui/ui/topicwidget.ui | 133 + src/qtui/verticaldock.cpp | 108 + src/qtui/verticaldock.h | 70 + src/qtui/webpreviewitem.cpp | 100 + src/qtui/webpreviewitem.h | 42 + src/uisupport/CMakeLists.txt | 64 + src/uisupport/aboutdata.cpp | 330 + src/uisupport/aboutdata.h | 196 + src/uisupport/abstractbuffercontainer.cpp | 133 + src/uisupport/abstractbuffercontainer.h | 90 + src/uisupport/abstractitemview.cpp | 56 + src/uisupport/abstractitemview.h | 63 + src/uisupport/abstractnotificationbackend.h | 73 + src/uisupport/action.cpp | 136 + src/uisupport/action.h | 93 + src/uisupport/actioncollection.cpp | 308 + src/uisupport/actioncollection.h | 140 + src/uisupport/bufferhotlistfilter.cpp | 84 + src/uisupport/bufferhotlistfilter.h | 44 + src/uisupport/bufferview.cpp | 727 + src/uisupport/bufferview.h | 183 + src/uisupport/bufferviewfilter.cpp | 551 + src/uisupport/bufferviewfilter.h | 107 + src/uisupport/bufferviewoverlayfilter.cpp | 112 + src/uisupport/bufferviewoverlayfilter.h | 50 + src/uisupport/clearablelineedit.cpp | 59 + src/uisupport/clearablelineedit.h | 46 + src/uisupport/clickable.cpp | 128 + src/uisupport/clickable.h | 69 + src/uisupport/clickablelabel.cpp | 39 + src/uisupport/clickablelabel.h | 41 + src/uisupport/colorbutton.cpp | 69 + src/uisupport/colorbutton.h | 52 + src/uisupport/contextmenuactionprovider.cpp | 524 + src/uisupport/contextmenuactionprovider.h | 79 + src/uisupport/flatproxymodel.cpp | 735 + src/uisupport/flatproxymodel.h | 126 + src/uisupport/fontselector.cpp | 70 + src/uisupport/fontselector.h | 55 + src/uisupport/graphicalui.cpp | 336 + src/uisupport/graphicalui.h | 140 + src/uisupport/kcmdlinewrapper.cpp | 69 + src/uisupport/kcmdlinewrapper.h | 47 + src/uisupport/multilineedit.cpp | 806 + src/uisupport/multilineedit.h | 143 + src/uisupport/networkmodelcontroller.cpp | 606 + src/uisupport/networkmodelcontroller.h | 213 + src/uisupport/nickview.cpp | 152 + src/uisupport/nickview.h | 59 + src/uisupport/nickviewfilter.cpp | 64 + src/uisupport/nickviewfilter.h | 50 + src/uisupport/qssparser.cpp | 731 + src/uisupport/qssparser.h | 76 + src/uisupport/resizingstackedwidget.cpp | 42 + src/uisupport/resizingstackedwidget.h | 40 + src/uisupport/settingspage.cpp | 248 + src/uisupport/settingspage.h | 162 + src/uisupport/styledlabel.cpp | 283 + src/uisupport/styledlabel.h | 94 + src/uisupport/tabcompleter.cpp | 235 + src/uisupport/tabcompleter.h | 81 + src/uisupport/toolbaractionprovider.cpp | 227 + src/uisupport/toolbaractionprovider.h | 72 + src/uisupport/treeviewtouch.cpp | 89 + src/uisupport/treeviewtouch.h | 66 + src/uisupport/uisettings.cpp | 188 + src/uisupport/uisettings.h | 92 + src/uisupport/uistyle.cpp | 900 + src/uisupport/uistyle.h | 234 + version.h.in | 14 + 1269 files changed, 378805 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 .tx/config create mode 100644 3rdparty/miniz/miniz.c create mode 100644 3rdparty/sha512/sha512.c create mode 100644 3rdparty/sha512/sha512.h create mode 100644 AUTHORS create mode 100644 CMakeLists.txt create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 Doxyfile create mode 100644 INSTALL create mode 100644 README.md create mode 100644 appveyor.ini create mode 100644 appveyor.yml create mode 100644 cmake/COPYING-CMAKE-SCRIPTS create mode 100644 cmake/FindExecInfo.cmake create mode 100644 cmake/FindIndicateQt.cmake create mode 100644 cmake/FindLibraryWithDebug.cmake create mode 100644 cmake/FindPhonon.cmake create mode 100644 cmake/FindQCA2-QT5.cmake create mode 100644 cmake/FindQCA2.cmake create mode 100644 cmake/GetGitRevisionDescription.cmake create mode 100644 cmake/GetGitRevisionDescription.cmake.in create mode 100644 cmake/QuasselCompileSettings.cmake create mode 100644 cmake/QuasselInstallDirs.cmake create mode 100644 cmake/QuasselMacros.cmake create mode 100644 cmake/README create mode 100644 data/CMakeLists.txt create mode 100644 data/data.qrc create mode 100644 data/networks.ini create mode 100644 data/quassel.appdata.xml create mode 100644 data/quassel.desktop create mode 100644 data/quassel.notifyrc create mode 100644 data/quasselclient.appdata.xml create mode 100644 data/quasselclient.desktop create mode 100755 data/scripts/inxi create mode 100755 data/scripts/mpris create mode 100644 data/stylesheets/LinuxDolt-bluestheme.qss create mode 100644 data/stylesheets/default.qss create mode 100644 data/stylesheets/jussi01-darktheme.qss create mode 100644 data/stylesheets/m4yer.qss create mode 100644 dev-notes/DockManager-spec.txt create mode 100644 dev-notes/QT4_TARGET_DIRECTORIES create mode 100644 dev-notes/Quassel.kdevelop create mode 100644 dev-notes/README.kdevelop create mode 100644 dev-notes/blanksettingspage.cpp create mode 100644 dev-notes/blanksettingspage.h create mode 100644 dev-notes/code_policy.txt create mode 100644 dev-notes/obsolete/buffermgmtpage.ui create mode 100644 dev-notes/obsolete/usermgmtpage.ui create mode 100644 dev-notes/quassel.desc create mode 100644 dev-notes/qxt-check create mode 100644 doc/build-static-quassel create mode 100644 gpl-2.0.txt create mode 100644 gpl-3.0.txt create mode 100644 icons/CMakeLists.txt create mode 100644 icons/README.Oxygen create mode 100644 icons/hicolor.qrc create mode 100644 icons/hicolor/128x128/apps/quassel.png create mode 100644 icons/hicolor/128x128/status/quassel-inactive.png create mode 100644 icons/hicolor/128x128/status/quassel-message.png create mode 100644 icons/hicolor/16x16/actions/im-user-away.png create mode 100644 icons/hicolor/16x16/actions/im-user-offline.png create mode 100644 icons/hicolor/16x16/actions/im-user.png create mode 100644 icons/hicolor/16x16/apps/quassel.png create mode 100644 icons/hicolor/16x16/status/irc-channel-joined.png create mode 100644 icons/hicolor/16x16/status/irc-channel-parted.png create mode 100644 icons/hicolor/16x16/status/quassel-inactive.png create mode 100644 icons/hicolor/16x16/status/quassel-message.png create mode 100644 icons/hicolor/22x22/apps/quassel.png create mode 100644 icons/hicolor/22x22/status/quassel-inactive.png create mode 100644 icons/hicolor/22x22/status/quassel-message.png create mode 100644 icons/hicolor/32x32/apps/quassel.png create mode 100644 icons/hicolor/32x32/status/quassel-inactive.png create mode 100644 icons/hicolor/32x32/status/quassel-message.png create mode 100644 icons/hicolor/48x48/apps/quassel.png create mode 100644 icons/hicolor/48x48/status/quassel-inactive.png create mode 100644 icons/hicolor/48x48/status/quassel-message.png create mode 100644 icons/hicolor/64x64/apps/quassel.png create mode 100644 icons/hicolor/64x64/status/quassel-inactive.png create mode 100644 icons/hicolor/64x64/status/quassel-message.png create mode 100644 icons/hicolor/scalable/status/irc-channel-joined.svgz create mode 100644 icons/hicolor/scalable/status/irc-channel-parted.svgz create mode 100644 icons/import/blacklisted-icons create mode 100644 icons/import/extra-icons create mode 100755 icons/import/import_oxygen.pl create mode 100644 icons/oxygen.qrc create mode 100644 icons/oxygen/128x128/actions/application-exit.png create mode 100644 icons/oxygen/128x128/actions/configure.png create mode 100644 icons/oxygen/128x128/actions/document-edit.png create mode 100644 icons/oxygen/128x128/actions/edit-find.png create mode 100644 icons/oxygen/128x128/actions/go-down.png create mode 100644 icons/oxygen/128x128/actions/go-next.png create mode 100644 icons/oxygen/128x128/actions/go-previous.png create mode 100644 icons/oxygen/128x128/actions/go-up.png create mode 100644 icons/oxygen/128x128/actions/im-ban-kick-user.png create mode 100644 icons/oxygen/128x128/actions/im-ban-user.png create mode 100644 icons/oxygen/128x128/actions/im-kick-user.png create mode 100644 icons/oxygen/128x128/actions/im-user-away.png create mode 100644 icons/oxygen/128x128/actions/im-user-offline.png create mode 100644 icons/oxygen/128x128/actions/im-user.png create mode 100644 icons/oxygen/128x128/actions/list-add-user.png create mode 100644 icons/oxygen/128x128/actions/mail-message-new.png create mode 100644 icons/oxygen/128x128/actions/tools-report-bug.png create mode 100644 icons/oxygen/128x128/apps/quassel.png create mode 100644 icons/oxygen/128x128/devices/network-wired.png create mode 100644 icons/oxygen/128x128/status/dialog-information.png create mode 100644 icons/oxygen/128x128/status/security-high.png create mode 100644 icons/oxygen/128x128/status/security-low.png create mode 100644 icons/oxygen/16x16/actions/application-exit.png create mode 100644 icons/oxygen/16x16/actions/configure-shortcuts.png create mode 100644 icons/oxygen/16x16/actions/configure.png create mode 100644 icons/oxygen/16x16/actions/dialog-cancel.png create mode 100644 icons/oxygen/16x16/actions/dialog-close.png create mode 100644 icons/oxygen/16x16/actions/document-edit.png create mode 100644 icons/oxygen/16x16/actions/document-encrypt.png create mode 100644 icons/oxygen/16x16/actions/document-open.png create mode 100644 icons/oxygen/16x16/actions/edit-clear-locationbar-ltr.png create mode 100644 icons/oxygen/16x16/actions/edit-clear-locationbar-rtl.png create mode 100644 icons/oxygen/16x16/actions/edit-copy.png create mode 100644 icons/oxygen/16x16/actions/edit-delete.png create mode 100644 icons/oxygen/16x16/actions/edit-find.png create mode 100644 icons/oxygen/16x16/actions/edit-rename.png create mode 100644 icons/oxygen/16x16/actions/flag-blue.png create mode 100644 icons/oxygen/16x16/actions/format-fill-color.png create mode 100644 icons/oxygen/16x16/actions/format-list-unordered.png create mode 100644 icons/oxygen/16x16/actions/format-text-bold.png create mode 100644 icons/oxygen/16x16/actions/format-text-color.png create mode 100644 icons/oxygen/16x16/actions/format-text-italic.png create mode 100644 icons/oxygen/16x16/actions/format-text-underline.png create mode 100644 icons/oxygen/16x16/actions/go-down.png create mode 100644 icons/oxygen/16x16/actions/go-next-view.png create mode 100644 icons/oxygen/16x16/actions/go-next.png create mode 100644 icons/oxygen/16x16/actions/go-previous-view.png create mode 100644 icons/oxygen/16x16/actions/go-previous.png create mode 100644 icons/oxygen/16x16/actions/go-up.png create mode 100644 icons/oxygen/16x16/actions/help-about.png create mode 100644 icons/oxygen/16x16/actions/im-ban-kick-user.png create mode 100644 icons/oxygen/16x16/actions/im-ban-user.png create mode 100644 icons/oxygen/16x16/actions/im-kick-user.png create mode 100644 icons/oxygen/16x16/actions/im-user-away.png create mode 100644 icons/oxygen/16x16/actions/im-user-offline.png create mode 100644 icons/oxygen/16x16/actions/im-user.png create mode 100644 icons/oxygen/16x16/actions/irc-close-channel.png create mode 100644 icons/oxygen/16x16/actions/irc-join-channel.png create mode 100644 icons/oxygen/16x16/actions/irc-operator.png create mode 100644 icons/oxygen/16x16/actions/irc-remove-operator.png create mode 100644 icons/oxygen/16x16/actions/irc-unvoice.png create mode 100644 icons/oxygen/16x16/actions/irc-voice.png create mode 100644 icons/oxygen/16x16/actions/list-add-user.png create mode 100644 icons/oxygen/16x16/actions/list-add.png create mode 100644 icons/oxygen/16x16/actions/list-remove-user.png create mode 100644 icons/oxygen/16x16/actions/mail-message-new.png create mode 100644 icons/oxygen/16x16/actions/media-playback-start.png create mode 100644 icons/oxygen/16x16/actions/network-connect.png create mode 100644 icons/oxygen/16x16/actions/network-disconnect.png create mode 100644 icons/oxygen/16x16/actions/show-menu.png create mode 100644 icons/oxygen/16x16/actions/tools-report-bug.png create mode 100644 icons/oxygen/16x16/actions/view-fullscreen.png create mode 100644 icons/oxygen/16x16/actions/view-refresh.png create mode 100644 icons/oxygen/16x16/actions/zoom-in.png create mode 100644 icons/oxygen/16x16/actions/zoom-original.png create mode 100644 icons/oxygen/16x16/actions/zoom-out.png create mode 100644 icons/oxygen/16x16/apps/quassel.png create mode 100644 icons/oxygen/16x16/devices/network-wired.png create mode 100644 icons/oxygen/16x16/status/dialog-information.png create mode 100644 icons/oxygen/16x16/status/security-high.png create mode 100644 icons/oxygen/16x16/status/security-low.png create mode 100644 icons/oxygen/16x16/status/user-away.png create mode 100644 icons/oxygen/22x22/actions/application-exit.png create mode 100644 icons/oxygen/22x22/actions/configure-shortcuts.png create mode 100644 icons/oxygen/22x22/actions/configure.png create mode 100644 icons/oxygen/22x22/actions/dialog-cancel.png create mode 100644 icons/oxygen/22x22/actions/dialog-close.png create mode 100644 icons/oxygen/22x22/actions/document-edit.png create mode 100644 icons/oxygen/22x22/actions/document-encrypt.png create mode 100644 icons/oxygen/22x22/actions/document-open.png create mode 100644 icons/oxygen/22x22/actions/edit-clear-locationbar-ltr.png create mode 100644 icons/oxygen/22x22/actions/edit-clear-locationbar-rtl.png create mode 100644 icons/oxygen/22x22/actions/edit-copy.png create mode 100644 icons/oxygen/22x22/actions/edit-delete.png create mode 100644 icons/oxygen/22x22/actions/edit-find.png create mode 100644 icons/oxygen/22x22/actions/edit-rename.png create mode 100644 icons/oxygen/22x22/actions/flag-blue.png create mode 100644 icons/oxygen/22x22/actions/format-fill-color.png create mode 100644 icons/oxygen/22x22/actions/format-list-unordered.png create mode 100644 icons/oxygen/22x22/actions/format-text-bold.png create mode 100644 icons/oxygen/22x22/actions/format-text-color.png create mode 100644 icons/oxygen/22x22/actions/format-text-italic.png create mode 100644 icons/oxygen/22x22/actions/format-text-underline.png create mode 100644 icons/oxygen/22x22/actions/go-down.png create mode 100644 icons/oxygen/22x22/actions/go-next-view.png create mode 100644 icons/oxygen/22x22/actions/go-next.png create mode 100644 icons/oxygen/22x22/actions/go-previous-view.png create mode 100644 icons/oxygen/22x22/actions/go-previous.png create mode 100644 icons/oxygen/22x22/actions/go-up.png create mode 100644 icons/oxygen/22x22/actions/help-about.png create mode 100644 icons/oxygen/22x22/actions/im-ban-kick-user.png create mode 100644 icons/oxygen/22x22/actions/im-ban-user.png create mode 100644 icons/oxygen/22x22/actions/im-kick-user.png create mode 100644 icons/oxygen/22x22/actions/im-user-away.png create mode 100644 icons/oxygen/22x22/actions/im-user-offline.png create mode 100644 icons/oxygen/22x22/actions/im-user.png create mode 100644 icons/oxygen/22x22/actions/irc-close-channel.png create mode 100644 icons/oxygen/22x22/actions/irc-join-channel.png create mode 100644 icons/oxygen/22x22/actions/irc-operator.png create mode 100644 icons/oxygen/22x22/actions/irc-remove-operator.png create mode 100644 icons/oxygen/22x22/actions/irc-unvoice.png create mode 100644 icons/oxygen/22x22/actions/irc-voice.png create mode 100644 icons/oxygen/22x22/actions/list-add-user.png create mode 100644 icons/oxygen/22x22/actions/list-add.png create mode 100644 icons/oxygen/22x22/actions/list-remove-user.png create mode 100644 icons/oxygen/22x22/actions/mail-message-new.png create mode 100644 icons/oxygen/22x22/actions/media-playback-start.png create mode 100644 icons/oxygen/22x22/actions/network-connect.png create mode 100644 icons/oxygen/22x22/actions/network-disconnect.png create mode 100644 icons/oxygen/22x22/actions/show-menu.png create mode 100644 icons/oxygen/22x22/actions/tools-report-bug.png create mode 100644 icons/oxygen/22x22/actions/view-fullscreen.png create mode 100644 icons/oxygen/22x22/actions/view-refresh.png create mode 100644 icons/oxygen/22x22/actions/zoom-in.png create mode 100644 icons/oxygen/22x22/actions/zoom-original.png create mode 100644 icons/oxygen/22x22/actions/zoom-out.png create mode 100644 icons/oxygen/22x22/apps/quassel.png create mode 100644 icons/oxygen/22x22/devices/network-wired.png create mode 100644 icons/oxygen/22x22/status/dialog-information.png create mode 100644 icons/oxygen/22x22/status/security-high.png create mode 100644 icons/oxygen/22x22/status/security-low.png create mode 100644 icons/oxygen/22x22/status/user-away.png create mode 100644 icons/oxygen/256x256/apps/quassel.png create mode 100644 icons/oxygen/256x256/devices/network-wired.png create mode 100644 icons/oxygen/32x32/actions/application-exit.png create mode 100644 icons/oxygen/32x32/actions/configure-shortcuts.png create mode 100644 icons/oxygen/32x32/actions/configure.png create mode 100644 icons/oxygen/32x32/actions/dialog-cancel.png create mode 100644 icons/oxygen/32x32/actions/dialog-close.png create mode 100644 icons/oxygen/32x32/actions/document-edit.png create mode 100644 icons/oxygen/32x32/actions/document-encrypt.png create mode 100644 icons/oxygen/32x32/actions/document-open.png create mode 100644 icons/oxygen/32x32/actions/edit-clear-locationbar-ltr.png create mode 100644 icons/oxygen/32x32/actions/edit-clear-locationbar-rtl.png create mode 100644 icons/oxygen/32x32/actions/edit-copy.png create mode 100644 icons/oxygen/32x32/actions/edit-delete.png create mode 100644 icons/oxygen/32x32/actions/edit-find.png create mode 100644 icons/oxygen/32x32/actions/edit-rename.png create mode 100644 icons/oxygen/32x32/actions/flag-blue.png create mode 100644 icons/oxygen/32x32/actions/format-fill-color.png create mode 100644 icons/oxygen/32x32/actions/format-list-unordered.png create mode 100644 icons/oxygen/32x32/actions/format-text-bold.png create mode 100644 icons/oxygen/32x32/actions/format-text-color.png create mode 100644 icons/oxygen/32x32/actions/format-text-italic.png create mode 100644 icons/oxygen/32x32/actions/format-text-underline.png create mode 100644 icons/oxygen/32x32/actions/go-down.png create mode 100644 icons/oxygen/32x32/actions/go-next-view.png create mode 100644 icons/oxygen/32x32/actions/go-next.png create mode 100644 icons/oxygen/32x32/actions/go-previous-view.png create mode 100644 icons/oxygen/32x32/actions/go-previous.png create mode 100644 icons/oxygen/32x32/actions/go-up.png create mode 100644 icons/oxygen/32x32/actions/help-about.png create mode 100644 icons/oxygen/32x32/actions/im-ban-kick-user.png create mode 100644 icons/oxygen/32x32/actions/im-ban-user.png create mode 100644 icons/oxygen/32x32/actions/im-kick-user.png create mode 100644 icons/oxygen/32x32/actions/im-user-away.png create mode 100644 icons/oxygen/32x32/actions/im-user-offline.png create mode 100644 icons/oxygen/32x32/actions/im-user.png create mode 100644 icons/oxygen/32x32/actions/irc-close-channel.png create mode 100644 icons/oxygen/32x32/actions/irc-join-channel.png create mode 100644 icons/oxygen/32x32/actions/irc-operator.png create mode 100644 icons/oxygen/32x32/actions/irc-remove-operator.png create mode 100644 icons/oxygen/32x32/actions/irc-unvoice.png create mode 100644 icons/oxygen/32x32/actions/irc-voice.png create mode 100644 icons/oxygen/32x32/actions/list-add-user.png create mode 100644 icons/oxygen/32x32/actions/list-add.png create mode 100644 icons/oxygen/32x32/actions/list-remove-user.png create mode 100644 icons/oxygen/32x32/actions/mail-message-new.png create mode 100644 icons/oxygen/32x32/actions/media-playback-start.png create mode 100644 icons/oxygen/32x32/actions/network-connect.png create mode 100644 icons/oxygen/32x32/actions/network-disconnect.png create mode 100644 icons/oxygen/32x32/actions/show-menu.png create mode 100644 icons/oxygen/32x32/actions/tools-report-bug.png create mode 100644 icons/oxygen/32x32/actions/view-fullscreen.png create mode 100644 icons/oxygen/32x32/actions/view-refresh.png create mode 100644 icons/oxygen/32x32/actions/zoom-in.png create mode 100644 icons/oxygen/32x32/actions/zoom-original.png create mode 100644 icons/oxygen/32x32/actions/zoom-out.png create mode 100644 icons/oxygen/32x32/apps/quassel.png create mode 100644 icons/oxygen/32x32/devices/network-wired.png create mode 100644 icons/oxygen/32x32/status/dialog-information.png create mode 100644 icons/oxygen/32x32/status/security-high.png create mode 100644 icons/oxygen/32x32/status/security-low.png create mode 100644 icons/oxygen/32x32/status/user-away.png create mode 100644 icons/oxygen/48x48/actions/application-exit.png create mode 100644 icons/oxygen/48x48/actions/configure-shortcuts.png create mode 100644 icons/oxygen/48x48/actions/configure.png create mode 100644 icons/oxygen/48x48/actions/dialog-cancel.png create mode 100644 icons/oxygen/48x48/actions/dialog-close.png create mode 100644 icons/oxygen/48x48/actions/document-edit.png create mode 100644 icons/oxygen/48x48/actions/document-encrypt.png create mode 100644 icons/oxygen/48x48/actions/document-open.png create mode 100644 icons/oxygen/48x48/actions/edit-clear-locationbar-ltr.png create mode 100644 icons/oxygen/48x48/actions/edit-clear-locationbar-rtl.png create mode 100644 icons/oxygen/48x48/actions/edit-copy.png create mode 100644 icons/oxygen/48x48/actions/edit-delete.png create mode 100644 icons/oxygen/48x48/actions/edit-find.png create mode 100644 icons/oxygen/48x48/actions/edit-rename.png create mode 100644 icons/oxygen/48x48/actions/flag-blue.png create mode 100644 icons/oxygen/48x48/actions/format-fill-color.png create mode 100644 icons/oxygen/48x48/actions/format-list-unordered.png create mode 100644 icons/oxygen/48x48/actions/format-text-bold.png create mode 100644 icons/oxygen/48x48/actions/format-text-color.png create mode 100644 icons/oxygen/48x48/actions/format-text-italic.png create mode 100644 icons/oxygen/48x48/actions/format-text-underline.png create mode 100644 icons/oxygen/48x48/actions/go-down.png create mode 100644 icons/oxygen/48x48/actions/go-next-view.png create mode 100644 icons/oxygen/48x48/actions/go-next.png create mode 100644 icons/oxygen/48x48/actions/go-previous-view.png create mode 100644 icons/oxygen/48x48/actions/go-previous.png create mode 100644 icons/oxygen/48x48/actions/go-up.png create mode 100644 icons/oxygen/48x48/actions/help-about.png create mode 100644 icons/oxygen/48x48/actions/im-ban-kick-user.png create mode 100644 icons/oxygen/48x48/actions/im-ban-user.png create mode 100644 icons/oxygen/48x48/actions/im-kick-user.png create mode 100644 icons/oxygen/48x48/actions/im-user-away.png create mode 100644 icons/oxygen/48x48/actions/im-user-offline.png create mode 100644 icons/oxygen/48x48/actions/im-user.png create mode 100644 icons/oxygen/48x48/actions/irc-close-channel.png create mode 100644 icons/oxygen/48x48/actions/irc-join-channel.png create mode 100644 icons/oxygen/48x48/actions/irc-operator.png create mode 100644 icons/oxygen/48x48/actions/irc-remove-operator.png create mode 100644 icons/oxygen/48x48/actions/irc-unvoice.png create mode 100644 icons/oxygen/48x48/actions/irc-voice.png create mode 100644 icons/oxygen/48x48/actions/list-add-user.png create mode 100644 icons/oxygen/48x48/actions/list-add.png create mode 100644 icons/oxygen/48x48/actions/list-remove-user.png create mode 100644 icons/oxygen/48x48/actions/mail-message-new.png create mode 100644 icons/oxygen/48x48/actions/media-playback-start.png create mode 100644 icons/oxygen/48x48/actions/network-connect.png create mode 100644 icons/oxygen/48x48/actions/network-disconnect.png create mode 100644 icons/oxygen/48x48/actions/show-menu.png create mode 100644 icons/oxygen/48x48/actions/tools-report-bug.png create mode 100644 icons/oxygen/48x48/actions/view-fullscreen.png create mode 100644 icons/oxygen/48x48/actions/view-refresh.png create mode 100644 icons/oxygen/48x48/actions/zoom-in.png create mode 100644 icons/oxygen/48x48/actions/zoom-original.png create mode 100644 icons/oxygen/48x48/actions/zoom-out.png create mode 100644 icons/oxygen/48x48/apps/quassel.png create mode 100644 icons/oxygen/48x48/devices/network-wired.png create mode 100644 icons/oxygen/48x48/status/dialog-information.png create mode 100644 icons/oxygen/48x48/status/security-high.png create mode 100644 icons/oxygen/48x48/status/security-low.png create mode 100644 icons/oxygen/48x48/status/user-away.png create mode 100644 icons/oxygen/64x64/actions/application-exit.png create mode 100644 icons/oxygen/64x64/actions/configure.png create mode 100644 icons/oxygen/64x64/actions/document-edit.png create mode 100644 icons/oxygen/64x64/actions/edit-find.png create mode 100644 icons/oxygen/64x64/actions/go-down.png create mode 100644 icons/oxygen/64x64/actions/go-next.png create mode 100644 icons/oxygen/64x64/actions/go-previous.png create mode 100644 icons/oxygen/64x64/actions/go-up.png create mode 100644 icons/oxygen/64x64/actions/im-ban-kick-user.png create mode 100644 icons/oxygen/64x64/actions/im-ban-user.png create mode 100644 icons/oxygen/64x64/actions/im-kick-user.png create mode 100644 icons/oxygen/64x64/actions/im-user-away.png create mode 100644 icons/oxygen/64x64/actions/im-user-offline.png create mode 100644 icons/oxygen/64x64/actions/im-user.png create mode 100644 icons/oxygen/64x64/actions/list-add-user.png create mode 100644 icons/oxygen/64x64/actions/tools-report-bug.png create mode 100644 icons/oxygen/64x64/apps/quassel.png create mode 100644 icons/oxygen/64x64/devices/network-wired.png create mode 100644 icons/oxygen/64x64/status/dialog-information.png create mode 100644 icons/oxygen/64x64/status/security-high.png create mode 100644 icons/oxygen/64x64/status/security-low.png create mode 100644 icons/oxygen/64x64/status/user-away.png create mode 100644 icons/oxygen/AUTHORS create mode 100644 icons/oxygen/CONTRIBUTING create mode 100644 icons/oxygen/COPYING create mode 100644 icons/oxygen/index.theme create mode 100644 icons/oxygen/scalable/actions/application-exit.svgz create mode 100644 icons/oxygen/scalable/actions/configure-shortcuts.svgz create mode 100644 icons/oxygen/scalable/actions/configure.svgz create mode 100644 icons/oxygen/scalable/actions/dialog-cancel.svgz create mode 100644 icons/oxygen/scalable/actions/dialog-close.svgz create mode 100644 icons/oxygen/scalable/actions/document-edit.svgz create mode 100644 icons/oxygen/scalable/actions/document-encrypt.svgz create mode 100644 icons/oxygen/scalable/actions/edit-clear-locationbar-ltr.svgz create mode 100644 icons/oxygen/scalable/actions/edit-clear-locationbar-rtl.svgz create mode 100644 icons/oxygen/scalable/actions/edit-copy.svgz create mode 100644 icons/oxygen/scalable/actions/edit-delete.svgz create mode 100644 icons/oxygen/scalable/actions/edit-find.svgz create mode 100644 icons/oxygen/scalable/actions/edit-rename.svgz create mode 100644 icons/oxygen/scalable/actions/flag-blue.svgz create mode 100644 icons/oxygen/scalable/actions/format-fill-color.svgz create mode 100644 icons/oxygen/scalable/actions/format-text-color.svgz create mode 100644 icons/oxygen/scalable/actions/go-down.svgz create mode 100644 icons/oxygen/scalable/actions/go-next-view.svgz create mode 100644 icons/oxygen/scalable/actions/go-next.svgz create mode 100644 icons/oxygen/scalable/actions/go-previous-view.svgz create mode 100644 icons/oxygen/scalable/actions/go-previous.svgz create mode 100644 icons/oxygen/scalable/actions/go-up.svgz create mode 100644 icons/oxygen/scalable/actions/im-ban-kick-user.svgz create mode 100644 icons/oxygen/scalable/actions/im-ban-user.svgz create mode 100644 icons/oxygen/scalable/actions/im-kick-user.svgz create mode 100644 icons/oxygen/scalable/actions/im-user-away.svgz create mode 100644 icons/oxygen/scalable/actions/im-user-offline.svgz create mode 100644 icons/oxygen/scalable/actions/im-user.svgz create mode 100644 icons/oxygen/scalable/actions/irc-close-channel.svgz create mode 100644 icons/oxygen/scalable/actions/irc-join-channel.svgz create mode 100644 icons/oxygen/scalable/actions/irc-operator.svgz create mode 100644 icons/oxygen/scalable/actions/irc-remove-operator.svgz create mode 100644 icons/oxygen/scalable/actions/irc-unvoice.svgz create mode 100644 icons/oxygen/scalable/actions/irc-voice.svgz create mode 100644 icons/oxygen/scalable/actions/list-add-user.svgz create mode 100644 icons/oxygen/scalable/actions/list-add.svgz create mode 100644 icons/oxygen/scalable/actions/list-remove-user.svgz create mode 100644 icons/oxygen/scalable/actions/media-playback-start.svgz create mode 100644 icons/oxygen/scalable/actions/network-connect.svgz create mode 100644 icons/oxygen/scalable/actions/network-disconnect.svgz create mode 100644 icons/oxygen/scalable/actions/show-menu.svgz create mode 100644 icons/oxygen/scalable/actions/tools-report-bug.svgz create mode 100644 icons/oxygen/scalable/actions/view-fullscreen.svgz create mode 100644 icons/oxygen/scalable/actions/view-refresh.svgz create mode 100644 icons/oxygen/scalable/apps/quassel.svgz create mode 100644 icons/oxygen/scalable/devices/network-wired.svgz create mode 100644 icons/oxygen/scalable/status/dialog-information.svgz create mode 100644 icons/oxygen/scalable/status/security-high.svgz create mode 100644 icons/oxygen/scalable/status/security-low.svgz create mode 100644 icons/oxygen/scalable/status/user-away.svgz create mode 100644 interfaces/org.freedesktop.DockItem.xml create mode 100644 interfaces/org.freedesktop.DockManager.xml create mode 100644 interfaces/org.freedesktop.Notifications.xml create mode 100644 interfaces/org.kde.StatusNotifierItem.xml create mode 100644 interfaces/org.kde.StatusNotifierWatcher.xml create mode 100644 pics/CMakeLists.txt create mode 100644 pics/README.qt-logo create mode 100644 pics/kde-vdg.png create mode 100644 pics/pics.qrc create mode 100644 pics/qt-logo-32.png create mode 100644 pics/qt-logo.png create mode 100644 pics/quassel-eye.png create mode 100644 pics/quassel-logo.png create mode 100644 pics/quassel-logo.svgz create mode 100644 pics/quassel.icns create mode 100644 pics/quassel.ico create mode 100644 pics/win32.rc create mode 100644 po/CMakeLists.txt create mode 100644 po/LINGUAS create mode 100644 po/README.Translations create mode 100644 po/cs.po create mode 100644 po/da.po create mode 100644 po/de.po create mode 100644 po/el.po create mode 100644 po/en_GB.po create mode 100644 po/en_US.po create mode 100644 po/eo.po create mode 100644 po/es.po create mode 100644 po/et.po create mode 100644 po/fi.po create mode 100644 po/fr.po create mode 100644 po/gl.po create mode 100644 po/hi.po create mode 100644 po/hu.po create mode 100644 po/it.po create mode 100644 po/ja.po create mode 100644 po/ko.po create mode 100644 po/lt.po create mode 100644 po/mr.po create mode 100644 po/nb.po create mode 100644 po/nl.po create mode 100644 po/oc.po create mode 100644 po/pa.po create mode 100644 po/pl.po create mode 100644 po/pt.po create mode 100644 po/pt_BR.po create mode 100755 po/pull-from-transifex.sh create mode 100644 po/quassel.pot create mode 100644 po/quassel.pot.patch create mode 100644 po/ro.po create mode 100644 po/ru.po create mode 100644 po/sl.po create mode 100644 po/sq.po create mode 100644 po/sr.po create mode 100644 po/sv.po create mode 100644 po/tr.po create mode 100644 po/uk.po create mode 100755 po/update-pot.sh create mode 100755 po/update.sh create mode 100644 po/zh_CN.po create mode 100644 po/zh_TW.po create mode 100644 scripts/build/Info.plist create mode 100644 scripts/build/NullsoftInstaller.nsi create mode 100644 scripts/build/SnoreNotify.nsh create mode 100755 scripts/build/macosx_DeployApp.py create mode 100755 scripts/build/macosx_makePackage.sh create mode 100755 scripts/build/macosx_makebundle.py create mode 100755 scripts/convert_mirc_servers_ini.pl create mode 100644 scripts/manage/format_source.cfg create mode 100755 scripts/manage/format_source.sh create mode 100755 scripts/tx-sync.sh create mode 100755 snap.wrapper create mode 100644 snapcraft.yaml create mode 100644 src/CMakeLists.txt create mode 100644 src/client/CMakeLists.txt create mode 100644 src/client/abstractmessageprocessor.cpp create mode 100644 src/client/abstractmessageprocessor.h create mode 100644 src/client/abstractui.h create mode 100644 src/client/backlogrequester.cpp create mode 100644 src/client/backlogrequester.h create mode 100644 src/client/backlogsettings.h create mode 100644 src/client/buffermodel.cpp create mode 100644 src/client/buffermodel.h create mode 100644 src/client/buffersettings.cpp create mode 100644 src/client/buffersettings.h create mode 100644 src/client/bufferviewoverlay.cpp create mode 100644 src/client/bufferviewoverlay.h create mode 100644 src/client/client.cpp create mode 100644 src/client/client.h create mode 100644 src/client/clientaliasmanager.cpp create mode 100644 src/client/clientaliasmanager.h create mode 100644 src/client/clientauthhandler.cpp create mode 100644 src/client/clientauthhandler.h create mode 100644 src/client/clientbacklogmanager.cpp create mode 100644 src/client/clientbacklogmanager.h create mode 100644 src/client/clientbufferviewconfig.cpp create mode 100644 src/client/clientbufferviewconfig.h create mode 100644 src/client/clientbufferviewmanager.cpp create mode 100644 src/client/clientbufferviewmanager.h create mode 100644 src/client/clientcoreinfo.h create mode 100644 src/client/clientidentity.cpp create mode 100644 src/client/clientidentity.h create mode 100644 src/client/clientignorelistmanager.cpp create mode 100644 src/client/clientignorelistmanager.h create mode 100644 src/client/clientirclisthelper.cpp create mode 100644 src/client/clientirclisthelper.h create mode 100644 src/client/clientsettings.cpp create mode 100644 src/client/clientsettings.h create mode 100644 src/client/clienttransfer.cpp create mode 100644 src/client/clienttransfer.h create mode 100644 src/client/clienttransfermanager.cpp create mode 100644 src/client/clienttransfermanager.h create mode 100644 src/client/clientuserinputhandler.cpp create mode 100644 src/client/clientuserinputhandler.h create mode 100644 src/client/coreaccount.cpp create mode 100644 src/client/coreaccount.h create mode 100644 src/client/coreaccountmodel.cpp create mode 100644 src/client/coreaccountmodel.h create mode 100644 src/client/coreconnection.cpp create mode 100644 src/client/coreconnection.h create mode 100644 src/client/execwrapper.cpp create mode 100644 src/client/execwrapper.h create mode 100644 src/client/irclistmodel.cpp create mode 100644 src/client/irclistmodel.h create mode 100644 src/client/messagefilter.cpp create mode 100644 src/client/messagefilter.h create mode 100644 src/client/messagemodel.cpp create mode 100644 src/client/messagemodel.h create mode 100644 src/client/networkmodel.cpp create mode 100644 src/client/networkmodel.h create mode 100644 src/client/selectionmodelsynchronizer.cpp create mode 100644 src/client/selectionmodelsynchronizer.h create mode 100644 src/client/treemodel.cpp create mode 100644 src/client/treemodel.h create mode 100644 src/common/CMakeLists.txt create mode 100644 src/common/abstractcliparser.h create mode 100644 src/common/aliasmanager.cpp create mode 100644 src/common/aliasmanager.h create mode 100644 src/common/authhandler.cpp create mode 100644 src/common/authhandler.h create mode 100644 src/common/backlogmanager.cpp create mode 100644 src/common/backlogmanager.h create mode 100644 src/common/basichandler.cpp create mode 100644 src/common/basichandler.h create mode 100644 src/common/bufferinfo.cpp create mode 100644 src/common/bufferinfo.h create mode 100644 src/common/buffersyncer.cpp create mode 100644 src/common/buffersyncer.h create mode 100644 src/common/bufferviewconfig.cpp create mode 100644 src/common/bufferviewconfig.h create mode 100644 src/common/bufferviewmanager.cpp create mode 100644 src/common/bufferviewmanager.h create mode 100644 src/common/cliparser.cpp create mode 100644 src/common/cliparser.h create mode 100644 src/common/compressor.cpp create mode 100644 src/common/compressor.h create mode 100644 src/common/coreinfo.h create mode 100644 src/common/ctcpevent.cpp create mode 100644 src/common/ctcpevent.h create mode 100644 src/common/event.cpp create mode 100644 src/common/event.h create mode 100644 src/common/eventmanager.cpp create mode 100644 src/common/eventmanager.h create mode 100644 src/common/identity.cpp create mode 100644 src/common/identity.h create mode 100644 src/common/ignorelistmanager.cpp create mode 100644 src/common/ignorelistmanager.h create mode 100644 src/common/internalpeer.cpp create mode 100644 src/common/internalpeer.h create mode 100644 src/common/ircchannel.cpp create mode 100644 src/common/ircchannel.h create mode 100644 src/common/ircevent.cpp create mode 100644 src/common/ircevent.h create mode 100644 src/common/irclisthelper.cpp create mode 100644 src/common/irclisthelper.h create mode 100644 src/common/ircuser.cpp create mode 100644 src/common/ircuser.h create mode 100644 src/common/keyevent.cpp create mode 100644 src/common/keyevent.h create mode 100644 src/common/logbacktrace_unix.cpp create mode 100644 src/common/logbacktrace_win.cpp create mode 100644 src/common/logger.cpp create mode 100644 src/common/logger.h create mode 100644 src/common/mac_utils.cpp create mode 100644 src/common/mac_utils.h create mode 100644 src/common/main.cpp create mode 100644 src/common/message.cpp create mode 100644 src/common/message.h create mode 100644 src/common/messageevent.cpp create mode 100644 src/common/messageevent.h create mode 100644 src/common/network.cpp create mode 100644 src/common/network.h create mode 100644 src/common/networkconfig.cpp create mode 100644 src/common/networkconfig.h create mode 100644 src/common/networkevent.cpp create mode 100644 src/common/networkevent.h create mode 100644 src/common/peer.cpp create mode 100644 src/common/peer.h create mode 100644 src/common/peerfactory.cpp create mode 100644 src/common/peerfactory.h create mode 100644 src/common/presetnetworks.cpp create mode 100644 src/common/presetnetworks.h create mode 100644 src/common/protocol.h create mode 100644 src/common/protocols/datastream/datastreampeer.cpp create mode 100644 src/common/protocols/datastream/datastreampeer.h create mode 100644 src/common/protocols/legacy/legacypeer.cpp create mode 100644 src/common/protocols/legacy/legacypeer.h create mode 100644 src/common/qt5cliparser.cpp create mode 100644 src/common/qt5cliparser.h create mode 100644 src/common/quassel.cpp create mode 100644 src/common/quassel.h create mode 100644 src/common/remotepeer.cpp create mode 100644 src/common/remotepeer.h create mode 100644 src/common/serializers/serializers.cpp create mode 100644 src/common/serializers/serializers.h create mode 100644 src/common/settings.cpp create mode 100644 src/common/settings.h create mode 100644 src/common/signalproxy.cpp create mode 100644 src/common/signalproxy.h create mode 100644 src/common/syncableobject.cpp create mode 100644 src/common/syncableobject.h create mode 100644 src/common/transfer.cpp create mode 100644 src/common/transfer.h create mode 100644 src/common/transfermanager.cpp create mode 100644 src/common/transfermanager.h create mode 100644 src/common/types.h create mode 100644 src/common/util.cpp create mode 100644 src/common/util.h create mode 100644 src/core/CMakeLists.txt create mode 100644 src/core/SQL/PostgreSQL/15/upgrade_000_alter_buffer_add_markerlinemsgid.sql create mode 100644 src/core/SQL/PostgreSQL/16/upgrade_000_alter_network_add_sasl.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_backlog_by_uid.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_backlog_for_buffer.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_backlog_for_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_buffer_for_bufferid.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_buffers_by_uid.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_buffers_for_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_identity.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_ircservers_for_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_networks_by_uid.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_nicks.sql create mode 100644 src/core/SQL/PostgreSQL/17/delete_quasseluser.sql create mode 100644 src/core/SQL/PostgreSQL/17/insert_buffer.sql create mode 100644 src/core/SQL/PostgreSQL/17/insert_identity.sql create mode 100644 src/core/SQL/PostgreSQL/17/insert_message.sql create mode 100644 src/core/SQL/PostgreSQL/17/insert_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/insert_nick.sql create mode 100644 src/core/SQL/PostgreSQL/17/insert_quasseluser.sql create mode 100644 src/core/SQL/PostgreSQL/17/insert_sender.sql create mode 100644 src/core/SQL/PostgreSQL/17/insert_server.sql create mode 100644 src/core/SQL/PostgreSQL/17/insert_user_setting.sql create mode 100644 src/core/SQL/PostgreSQL/17/migrate_write_backlog.sql create mode 100644 src/core/SQL/PostgreSQL/17/migrate_write_buffer.sql create mode 100644 src/core/SQL/PostgreSQL/17/migrate_write_identity.sql create mode 100644 src/core/SQL/PostgreSQL/17/migrate_write_identity_nick.sql create mode 100644 src/core/SQL/PostgreSQL/17/migrate_write_ircserver.sql create mode 100644 src/core/SQL/PostgreSQL/17/migrate_write_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/migrate_write_quasseluser.sql create mode 100644 src/core/SQL/PostgreSQL/17/migrate_write_sender.sql create mode 100644 src/core/SQL/PostgreSQL/17/migrate_write_usersetting.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_authuser.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_bufferByName.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_bufferExists.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_buffer_by_id.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_buffer_lastseen_messages.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_buffer_markerlinemsgids.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_buffers.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_buffers_for_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_checkidentity.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_connected_networks.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_identities.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_internaluser.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_messages.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_messagesAll.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_messagesAllNew.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_messagesNewerThan.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_messagesRange.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_networkExists.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_network_awaymsg.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_network_usermode.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_networks_for_user.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_nicks.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_persistent_channels.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_senderid.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_servers_for_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_user_setting.sql create mode 100644 src/core/SQL/PostgreSQL/17/select_userid.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_000_quasseluser.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_010_sender.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_020_identity.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_030_identity_nick.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_040_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_050_buffer.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_060_backlog.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_070_coreinfo.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_080_ircservers.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_090_backlog_idx.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_100_user_setting.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_110_alter_sender_seq.sql create mode 100644 src/core/SQL/PostgreSQL/17/setup_120_alter_messageid_seq.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_backlog_bufferid.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_buffer_lastseen.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_buffer_markerlinemsgid.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_buffer_name.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_buffer_persistent_channel.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_buffer_set_channel_key.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_identity.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_network.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_network_connected.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_network_set_awaymsg.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_network_set_usermode.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_user_setting.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_username.sql create mode 100644 src/core/SQL/PostgreSQL/17/update_userpassword.sql create mode 100644 src/core/SQL/PostgreSQL/17/upgrade_000_alter_quasseluser_add_passwordversion.sql create mode 100644 src/core/SQL/SQLite/1/upgrade_000_drop_coreinfo.sql create mode 100644 src/core/SQL/SQLite/1/upgrade_010_create_coreinfo.sql create mode 100644 src/core/SQL/SQLite/1/upgrade_020_update_schemaversion.sql create mode 100644 src/core/SQL/SQLite/10/upgrade_000_switch_to_msgid.sql create mode 100644 src/core/SQL/SQLite/10/upgrade_010_rename_buffer_table.sql create mode 100644 src/core/SQL/SQLite/10/upgrade_020_create_buffer_table.sql create mode 100644 src/core/SQL/SQLite/10/upgrade_030_copy_buffer_table.sql create mode 100644 src/core/SQL/SQLite/10/upgrade_040_drop_buffer_old_table.sql create mode 100644 src/core/SQL/SQLite/11/upgrade_000_create_user_setting.sql create mode 100644 src/core/SQL/SQLite/12/upgrade_000_create_identity.sql create mode 100644 src/core/SQL/SQLite/12/upgrade_010_create_identity_nick.sql create mode 100644 src/core/SQL/SQLite/12/upgrade_020_rename_servertable.sql create mode 100644 src/core/SQL/SQLite/12/upgrade_030_create_ircserver.sql create mode 100644 src/core/SQL/SQLite/12/upgrade_040_copy_ircserver.sql create mode 100644 src/core/SQL/SQLite/12/upgrade_050_drop_ircserverold.sql create mode 100644 src/core/SQL/SQLite/13/upgrade_000_create_buffer_user_idx.sql create mode 100644 src/core/SQL/SQLite/13/upgrade_010_create_buffer_cname_idx.sql create mode 100644 src/core/SQL/SQLite/13/upgrade_020_create_buffer_cname_idx.sql create mode 100644 src/core/SQL/SQLite/14/upgrade_000_rename_networktable.sql create mode 100644 src/core/SQL/SQLite/14/upgrade_010_create_networktable.sql create mode 100644 src/core/SQL/SQLite/14/upgrade_030_copy_networktable.sql create mode 100644 src/core/SQL/SQLite/14/upgrade_040_drop_networkold.sql create mode 100644 src/core/SQL/SQLite/15/upgrade_000_fix_ircservers.sql create mode 100644 src/core/SQL/SQLite/15/upgrade_000_fix_network.sql create mode 100644 src/core/SQL/SQLite/16/upgrade_000_alter_buffer_add_markerlinemsgid.sql create mode 100644 src/core/SQL/SQLite/17/upgrade_000_alter_network_add_sasl.sql create mode 100644 src/core/SQL/SQLite/17/upgrade_001_alter_network_add_sasl.sql create mode 100644 src/core/SQL/SQLite/17/upgrade_002_alter_network_add_sasl.sql create mode 100644 src/core/SQL/SQLite/18/delete_backlog_by_uid.sql create mode 100644 src/core/SQL/SQLite/18/delete_backlog_for_buffer.sql create mode 100644 src/core/SQL/SQLite/18/delete_backlog_for_network.sql create mode 100644 src/core/SQL/SQLite/18/delete_buffer_for_bufferid.sql create mode 100644 src/core/SQL/SQLite/18/delete_buffers_by_uid.sql create mode 100644 src/core/SQL/SQLite/18/delete_buffers_for_network.sql create mode 100644 src/core/SQL/SQLite/18/delete_identity.sql create mode 100644 src/core/SQL/SQLite/18/delete_ircservers_for_network.sql create mode 100644 src/core/SQL/SQLite/18/delete_network.sql create mode 100644 src/core/SQL/SQLite/18/delete_networks_by_uid.sql create mode 100644 src/core/SQL/SQLite/18/delete_nicks.sql create mode 100644 src/core/SQL/SQLite/18/delete_quasseluser.sql create mode 100644 src/core/SQL/SQLite/18/insert_buffer.sql create mode 100644 src/core/SQL/SQLite/18/insert_identity.sql create mode 100644 src/core/SQL/SQLite/18/insert_message.sql create mode 100644 src/core/SQL/SQLite/18/insert_network.sql create mode 100644 src/core/SQL/SQLite/18/insert_nick.sql create mode 100644 src/core/SQL/SQLite/18/insert_quasseluser.sql create mode 100644 src/core/SQL/SQLite/18/insert_sender.sql create mode 100644 src/core/SQL/SQLite/18/insert_server.sql create mode 100644 src/core/SQL/SQLite/18/insert_user_setting.sql create mode 100644 src/core/SQL/SQLite/18/migrate_read_backlog.sql create mode 100644 src/core/SQL/SQLite/18/migrate_read_buffer.sql create mode 100644 src/core/SQL/SQLite/18/migrate_read_identity.sql create mode 100644 src/core/SQL/SQLite/18/migrate_read_identity_nick.sql create mode 100644 src/core/SQL/SQLite/18/migrate_read_ircserver.sql create mode 100644 src/core/SQL/SQLite/18/migrate_read_network.sql create mode 100644 src/core/SQL/SQLite/18/migrate_read_quasseluser.sql create mode 100644 src/core/SQL/SQLite/18/migrate_read_sender.sql create mode 100644 src/core/SQL/SQLite/18/migrate_read_usersetting.sql create mode 100644 src/core/SQL/SQLite/18/select_authuser.sql create mode 100644 src/core/SQL/SQLite/18/select_bufferByName.sql create mode 100644 src/core/SQL/SQLite/18/select_bufferExists.sql create mode 100644 src/core/SQL/SQLite/18/select_buffer_by_id.sql create mode 100644 src/core/SQL/SQLite/18/select_buffer_lastseen_messages.sql create mode 100644 src/core/SQL/SQLite/18/select_buffer_markerlinemsgids.sql create mode 100644 src/core/SQL/SQLite/18/select_buffers.sql create mode 100644 src/core/SQL/SQLite/18/select_buffers_for_merge.sql create mode 100644 src/core/SQL/SQLite/18/select_buffers_for_network.sql create mode 100644 src/core/SQL/SQLite/18/select_checkidentity.sql create mode 100644 src/core/SQL/SQLite/18/select_connected_networks.sql create mode 100644 src/core/SQL/SQLite/18/select_identities.sql create mode 100644 src/core/SQL/SQLite/18/select_internaluser.sql create mode 100644 src/core/SQL/SQLite/18/select_messages.sql create mode 100644 src/core/SQL/SQLite/18/select_messagesAll.sql create mode 100644 src/core/SQL/SQLite/18/select_messagesAllNew.sql create mode 100644 src/core/SQL/SQLite/18/select_messagesNewerThan.sql create mode 100644 src/core/SQL/SQLite/18/select_messagesNewestK.sql create mode 100644 src/core/SQL/SQLite/18/select_networkExists.sql create mode 100644 src/core/SQL/SQLite/18/select_network_awaymsg.sql create mode 100644 src/core/SQL/SQLite/18/select_network_usermode.sql create mode 100644 src/core/SQL/SQLite/18/select_networks_for_user.sql create mode 100644 src/core/SQL/SQLite/18/select_nicks.sql create mode 100644 src/core/SQL/SQLite/18/select_persistent_channels.sql create mode 100644 src/core/SQL/SQLite/18/select_servers_for_network.sql create mode 100644 src/core/SQL/SQLite/18/select_user_setting.sql create mode 100644 src/core/SQL/SQLite/18/select_userid.sql create mode 100644 src/core/SQL/SQLite/18/setup_000_quasseluser.sql create mode 100644 src/core/SQL/SQLite/18/setup_010_sender.sql create mode 100644 src/core/SQL/SQLite/18/setup_020_network.sql create mode 100644 src/core/SQL/SQLite/18/setup_030_buffer.sql create mode 100644 src/core/SQL/SQLite/18/setup_040_buffer_idx.sql create mode 100644 src/core/SQL/SQLite/18/setup_050_buffer_cname_idx.sql create mode 100644 src/core/SQL/SQLite/18/setup_060_backlog.sql create mode 100644 src/core/SQL/SQLite/18/setup_070_coreinfo.sql create mode 100644 src/core/SQL/SQLite/18/setup_080_ircservers.sql create mode 100644 src/core/SQL/SQLite/18/setup_090_backlog_idx.sql create mode 100644 src/core/SQL/SQLite/18/setup_100_backlog_idx2.sql create mode 100644 src/core/SQL/SQLite/18/setup_110_buffer_user_idx.sql create mode 100644 src/core/SQL/SQLite/18/setup_120_user_setting.sql create mode 100644 src/core/SQL/SQLite/18/setup_130_identity.sql create mode 100644 src/core/SQL/SQLite/18/setup_140_identity_nick.sql create mode 100644 src/core/SQL/SQLite/18/update_backlog_bufferid.sql create mode 100644 src/core/SQL/SQLite/18/update_buffer_lastseen.sql create mode 100644 src/core/SQL/SQLite/18/update_buffer_markerlinemsgid.sql create mode 100644 src/core/SQL/SQLite/18/update_buffer_name.sql create mode 100644 src/core/SQL/SQLite/18/update_buffer_persistent_channel.sql create mode 100644 src/core/SQL/SQLite/18/update_buffer_set_channel_key.sql create mode 100644 src/core/SQL/SQLite/18/update_identity.sql create mode 100644 src/core/SQL/SQLite/18/update_network.sql create mode 100644 src/core/SQL/SQLite/18/update_network_connected.sql create mode 100644 src/core/SQL/SQLite/18/update_network_set_awaymsg.sql create mode 100644 src/core/SQL/SQLite/18/update_network_set_usermode.sql create mode 100644 src/core/SQL/SQLite/18/update_user_setting.sql create mode 100644 src/core/SQL/SQLite/18/update_username.sql create mode 100644 src/core/SQL/SQLite/18/update_userpassword.sql create mode 100644 src/core/SQL/SQLite/18/upgrade_000_alter_quasseluser_add_passwordversion.sql create mode 100644 src/core/SQL/SQLite/2/upgrade_000_drop_buffergroup.sql create mode 100644 src/core/SQL/SQLite/2/upgrade_010_update_schemaversion.sql create mode 100644 src/core/SQL/SQLite/3/upgrade_000_update_backlog_flags.sql create mode 100644 src/core/SQL/SQLite/3/upgrade_010_update_schemaversion.sql create mode 100644 src/core/SQL/SQLite/4/upgrade_000_rename_buffertable.sql create mode 100644 src/core/SQL/SQLite/4/upgrade_010_create_buffertable.sql create mode 100644 src/core/SQL/SQLite/4/upgrade_020_copy_buffertable.sql create mode 100644 src/core/SQL/SQLite/4/upgrade_030_drop_oldbuffertable.sql create mode 100644 src/core/SQL/SQLite/4/upgrade_040_create_buffer_idx.sql create mode 100644 src/core/SQL/SQLite/4/upgrade_050_create_buffer_cname_idx.sql create mode 100644 src/core/SQL/SQLite/5/upgrade_000_rename_networktable.sql create mode 100644 src/core/SQL/SQLite/5/upgrade_010_create_newnetworktable.sql create mode 100644 src/core/SQL/SQLite/5/upgrade_020_copy_networktable.sql create mode 100644 src/core/SQL/SQLite/5/upgrade_030_drop_oldnetworktable.sql create mode 100644 src/core/SQL/SQLite/5/upgrade_180_create_ircservers.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_000_alter_buffertable.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_010_set_statusbuffertype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_020_set_channelbuffertype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_030_set_querybuffertype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_040_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_050_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_060_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_070_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_080_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_090_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_100_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_110_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_120_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_130_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_140_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_150_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/6/upgrade_160_update_msgtype.sql create mode 100644 src/core/SQL/SQLite/7/upgrade_000_rename_networktable.sql create mode 100644 src/core/SQL/SQLite/7/upgrade_010_create_newnetworktable.sql create mode 100644 src/core/SQL/SQLite/7/upgrade_020_copy_networktable.sql create mode 100644 src/core/SQL/SQLite/7/upgrade_030_drop_oldnetworktable.sql create mode 100644 src/core/SQL/SQLite/7/upgrade_040_alter_buffer_add_lastseen.sql create mode 100644 src/core/SQL/SQLite/8/upgrade_000_alter_network_add_connected.sql create mode 100644 src/core/SQL/SQLite/8/upgrade_010_alter_buffer_add_key.sql create mode 100644 src/core/SQL/SQLite/8/upgrade_020_alter_buffer_add_joined.sql create mode 100644 src/core/SQL/SQLite/8/upgrade_030_update_buffer_set_joined_for_channels.sql create mode 100644 src/core/SQL/SQLite/9/upgrade_000_create_backlog_idx.sql create mode 100644 src/core/SQL/SQLite/9/upgrade_010_create_backlog_idx2.sql create mode 100644 src/core/SQL/SQLite/9/upgrade_020_create_buffer_idx.sql create mode 100755 src/core/SQL/upgradeSchema.sh create mode 100755 src/core/UPDATE_SQL_RESOURCE.sh create mode 100644 src/core/abstractsqlstorage.cpp create mode 100644 src/core/abstractsqlstorage.h create mode 100644 src/core/cipher.cpp create mode 100644 src/core/cipher.h create mode 100644 src/core/core.cpp create mode 100644 src/core/core.h create mode 100644 src/core/corealiasmanager.cpp create mode 100644 src/core/corealiasmanager.h create mode 100644 src/core/coreapplication.cpp create mode 100644 src/core/coreapplication.h create mode 100644 src/core/coreauthhandler.cpp create mode 100644 src/core/coreauthhandler.h create mode 100644 src/core/corebacklogmanager.cpp create mode 100644 src/core/corebacklogmanager.h create mode 100644 src/core/corebasichandler.cpp create mode 100644 src/core/corebasichandler.h create mode 100644 src/core/corebuffersyncer.cpp create mode 100644 src/core/corebuffersyncer.h create mode 100644 src/core/corebufferviewconfig.cpp create mode 100644 src/core/corebufferviewconfig.h create mode 100644 src/core/corebufferviewmanager.cpp create mode 100644 src/core/corebufferviewmanager.h create mode 100644 src/core/corecoreinfo.cpp create mode 100644 src/core/corecoreinfo.h create mode 100644 src/core/coreeventmanager.h create mode 100644 src/core/coreidentity.cpp create mode 100644 src/core/coreidentity.h create mode 100644 src/core/coreignorelistmanager.cpp create mode 100644 src/core/coreignorelistmanager.h create mode 100644 src/core/coreircchannel.cpp create mode 100644 src/core/coreircchannel.h create mode 100644 src/core/coreirclisthelper.cpp create mode 100644 src/core/coreirclisthelper.h create mode 100644 src/core/coreircuser.cpp create mode 100644 src/core/coreircuser.h create mode 100644 src/core/corenetwork.cpp create mode 100644 src/core/corenetwork.h create mode 100644 src/core/corenetworkconfig.cpp create mode 100644 src/core/corenetworkconfig.h create mode 100644 src/core/coresession.cpp create mode 100644 src/core/coresession.h create mode 100644 src/core/coresessioneventprocessor.cpp create mode 100644 src/core/coresessioneventprocessor.h create mode 100644 src/core/coresettings.cpp create mode 100644 src/core/coresettings.h create mode 100644 src/core/coretransfer.cpp create mode 100644 src/core/coretransfer.h create mode 100644 src/core/coretransfermanager.cpp create mode 100644 src/core/coretransfermanager.h create mode 100644 src/core/coreuserinputhandler.cpp create mode 100644 src/core/coreuserinputhandler.h create mode 100644 src/core/coreusersettings.cpp create mode 100644 src/core/coreusersettings.h create mode 100644 src/core/ctcpparser.cpp create mode 100644 src/core/ctcpparser.h create mode 100644 src/core/eventstringifier.cpp create mode 100644 src/core/eventstringifier.h create mode 100644 src/core/ircparser.cpp create mode 100644 src/core/ircparser.h create mode 100644 src/core/netsplit.cpp create mode 100644 src/core/netsplit.h create mode 100644 src/core/oidentdconfiggenerator.cpp create mode 100644 src/core/oidentdconfiggenerator.h create mode 100644 src/core/postgresqlstorage.cpp create mode 100644 src/core/postgresqlstorage.h create mode 100644 src/core/sessionthread.cpp create mode 100644 src/core/sessionthread.h create mode 100644 src/core/sql.qrc create mode 100644 src/core/sqlitestorage.cpp create mode 100644 src/core/sqlitestorage.h create mode 100644 src/core/sslserver.cpp create mode 100644 src/core/sslserver.h create mode 100644 src/core/storage.cpp create mode 100644 src/core/storage.h create mode 100644 src/qtui/CMakeLists.txt create mode 100644 src/qtui/aboutdlg.cpp create mode 100644 src/qtui/aboutdlg.h create mode 100644 src/qtui/awaylogfilter.cpp create mode 100644 src/qtui/awaylogfilter.h create mode 100644 src/qtui/awaylogview.cpp create mode 100644 src/qtui/awaylogview.h create mode 100644 src/qtui/bufferwidget.cpp create mode 100644 src/qtui/bufferwidget.h create mode 100644 src/qtui/channellistdlg.cpp create mode 100644 src/qtui/channellistdlg.h create mode 100644 src/qtui/chatitem.cpp create mode 100644 src/qtui/chatitem.h create mode 100644 src/qtui/chatline.cpp create mode 100644 src/qtui/chatline.h create mode 100644 src/qtui/chatlinemodel.cpp create mode 100644 src/qtui/chatlinemodel.h create mode 100644 src/qtui/chatlinemodelitem.cpp create mode 100644 src/qtui/chatlinemodelitem.h create mode 100644 src/qtui/chatmonitorfilter.cpp create mode 100644 src/qtui/chatmonitorfilter.h create mode 100644 src/qtui/chatmonitorview.cpp create mode 100644 src/qtui/chatmonitorview.h create mode 100644 src/qtui/chatscene.cpp create mode 100644 src/qtui/chatscene.h create mode 100644 src/qtui/chatview.cpp create mode 100644 src/qtui/chatview.h create mode 100644 src/qtui/chatviewsearchbar.cpp create mode 100644 src/qtui/chatviewsearchbar.h create mode 100644 src/qtui/chatviewsearchcontroller.cpp create mode 100644 src/qtui/chatviewsearchcontroller.h create mode 100644 src/qtui/chatviewsettings.cpp create mode 100644 src/qtui/chatviewsettings.h create mode 100644 src/qtui/columnhandleitem.cpp create mode 100644 src/qtui/columnhandleitem.h create mode 100644 src/qtui/coreconfigwizard.cpp create mode 100644 src/qtui/coreconfigwizard.h create mode 100644 src/qtui/coreconnectdlg.cpp create mode 100644 src/qtui/coreconnectdlg.h create mode 100644 src/qtui/coreconnectionstatuswidget.cpp create mode 100644 src/qtui/coreconnectionstatuswidget.h create mode 100644 src/qtui/coreinfodlg.cpp create mode 100644 src/qtui/coreinfodlg.h create mode 100644 src/qtui/debugbufferviewoverlay.cpp create mode 100644 src/qtui/debugbufferviewoverlay.h create mode 100644 src/qtui/debugconsole.cpp create mode 100644 src/qtui/debugconsole.h create mode 100644 src/qtui/debuglogwidget.cpp create mode 100644 src/qtui/debuglogwidget.h create mode 100644 src/qtui/debugmessagemodelfilter.cpp create mode 100644 src/qtui/debugmessagemodelfilter.h create mode 100644 src/qtui/dockmanagernotificationbackend.cpp create mode 100644 src/qtui/dockmanagernotificationbackend.h create mode 100644 src/qtui/indicatornotificationbackend.cpp create mode 100644 src/qtui/indicatornotificationbackend.h create mode 100644 src/qtui/inputwidget.cpp create mode 100644 src/qtui/inputwidget.h create mode 100644 src/qtui/ircconnectionwizard.cpp create mode 100644 src/qtui/ircconnectionwizard.h create mode 100644 src/qtui/knotificationbackend.cpp create mode 100644 src/qtui/knotificationbackend.h create mode 100644 src/qtui/legacysystemtray.cpp create mode 100644 src/qtui/legacysystemtray.h create mode 100644 src/qtui/mainpage.cpp create mode 100644 src/qtui/mainpage.h create mode 100644 src/qtui/mainwin.cpp create mode 100644 src/qtui/mainwin.h create mode 100644 src/qtui/markerlineitem.cpp create mode 100644 src/qtui/markerlineitem.h create mode 100644 src/qtui/monoapplication.cpp create mode 100644 src/qtui/monoapplication.h create mode 100644 src/qtui/msgprocessorstatuswidget.cpp create mode 100644 src/qtui/msgprocessorstatuswidget.h create mode 100644 src/qtui/nicklistwidget.cpp create mode 100644 src/qtui/nicklistwidget.h create mode 100644 src/qtui/osxnotificationbackend.h create mode 100644 src/qtui/osxnotificationbackend.mm create mode 100644 src/qtui/passwordchangedlg.cpp create mode 100644 src/qtui/passwordchangedlg.h create mode 100644 src/qtui/phononnotificationbackend.cpp create mode 100644 src/qtui/phononnotificationbackend.h create mode 100644 src/qtui/qtui.cpp create mode 100644 src/qtui/qtui.h create mode 100644 src/qtui/qtuiapplication.cpp create mode 100644 src/qtui/qtuiapplication.h create mode 100644 src/qtui/qtuimessageprocessor.cpp create mode 100644 src/qtui/qtuimessageprocessor.h create mode 100644 src/qtui/qtuisettings.cpp create mode 100644 src/qtui/qtuisettings.h create mode 100644 src/qtui/qtuistyle.cpp create mode 100644 src/qtui/qtuistyle.h create mode 100644 src/qtui/receivefiledlg.cpp create mode 100644 src/qtui/receivefiledlg.h create mode 100644 src/qtui/settingsdlg.cpp create mode 100644 src/qtui/settingsdlg.h create mode 100644 src/qtui/settingspagedlg.cpp create mode 100644 src/qtui/settingspagedlg.h create mode 100644 src/qtui/settingspages/aliasesmodel.cpp create mode 100644 src/qtui/settingspages/aliasesmodel.h create mode 100644 src/qtui/settingspages/aliasessettingspage.cpp create mode 100644 src/qtui/settingspages/aliasessettingspage.h create mode 100644 src/qtui/settingspages/aliasessettingspage.ui create mode 100644 src/qtui/settingspages/appearancesettingspage.cpp create mode 100644 src/qtui/settingspages/appearancesettingspage.h create mode 100644 src/qtui/settingspages/appearancesettingspage.ui create mode 100644 src/qtui/settingspages/backlogsettingspage.cpp create mode 100644 src/qtui/settingspages/backlogsettingspage.h create mode 100644 src/qtui/settingspages/backlogsettingspage.ui create mode 100644 src/qtui/settingspages/buffervieweditdlg.ui create mode 100644 src/qtui/settingspages/bufferviewsettingspage.cpp create mode 100644 src/qtui/settingspages/bufferviewsettingspage.h create mode 100644 src/qtui/settingspages/bufferviewsettingspage.ui create mode 100644 src/qtui/settingspages/chatmonitorsettingspage.cpp create mode 100644 src/qtui/settingspages/chatmonitorsettingspage.h create mode 100644 src/qtui/settingspages/chatmonitorsettingspage.ui create mode 100644 src/qtui/settingspages/chatviewsettingspage.cpp create mode 100644 src/qtui/settingspages/chatviewsettingspage.h create mode 100644 src/qtui/settingspages/chatviewsettingspage.ui create mode 100644 src/qtui/settingspages/connectionsettingspage.cpp create mode 100644 src/qtui/settingspages/connectionsettingspage.h create mode 100644 src/qtui/settingspages/connectionsettingspage.ui create mode 100644 src/qtui/settingspages/coreaccounteditdlg.ui create mode 100644 src/qtui/settingspages/coreaccountsettingspage.cpp create mode 100644 src/qtui/settingspages/coreaccountsettingspage.h create mode 100644 src/qtui/settingspages/coreaccountsettingspage.ui create mode 100644 src/qtui/settingspages/coreconnectionsettingspage.cpp create mode 100644 src/qtui/settingspages/coreconnectionsettingspage.h create mode 100644 src/qtui/settingspages/coreconnectionsettingspage.ui create mode 100644 src/qtui/settingspages/createidentitydlg.ui create mode 100644 src/qtui/settingspages/highlightsettingspage.cpp create mode 100644 src/qtui/settingspages/highlightsettingspage.h create mode 100644 src/qtui/settingspages/highlightsettingspage.ui create mode 100644 src/qtui/settingspages/identitiessettingspage.cpp create mode 100644 src/qtui/settingspages/identitiessettingspage.h create mode 100644 src/qtui/settingspages/identitiessettingspage.ui create mode 100644 src/qtui/settingspages/identityeditwidget.cpp create mode 100644 src/qtui/settingspages/identityeditwidget.h create mode 100644 src/qtui/settingspages/identityeditwidget.ui create mode 100644 src/qtui/settingspages/ignorelisteditdlg.ui create mode 100644 src/qtui/settingspages/ignorelistmodel.cpp create mode 100644 src/qtui/settingspages/ignorelistmodel.h create mode 100644 src/qtui/settingspages/ignorelistsettingspage.cpp create mode 100644 src/qtui/settingspages/ignorelistsettingspage.h create mode 100644 src/qtui/settingspages/ignorelistsettingspage.ui create mode 100644 src/qtui/settingspages/inputwidgetsettingspage.cpp create mode 100644 src/qtui/settingspages/inputwidgetsettingspage.h create mode 100644 src/qtui/settingspages/inputwidgetsettingspage.ui create mode 100644 src/qtui/settingspages/itemviewsettingspage.cpp create mode 100644 src/qtui/settingspages/itemviewsettingspage.h create mode 100644 src/qtui/settingspages/itemviewsettingspage.ui create mode 100644 src/qtui/settingspages/keysequencewidget.cpp create mode 100644 src/qtui/settingspages/keysequencewidget.h create mode 100644 src/qtui/settingspages/networkadddlg.ui create mode 100644 src/qtui/settingspages/networkeditdlg.ui create mode 100644 src/qtui/settingspages/networkssettingspage.cpp create mode 100644 src/qtui/settingspages/networkssettingspage.h create mode 100644 src/qtui/settingspages/networkssettingspage.ui create mode 100644 src/qtui/settingspages/nickeditdlg.ui create mode 100644 src/qtui/settingspages/notificationssettingspage.cpp create mode 100644 src/qtui/settingspages/notificationssettingspage.h create mode 100644 src/qtui/settingspages/previewbufferview.h create mode 100644 src/qtui/settingspages/saveidentitiesdlg.ui create mode 100644 src/qtui/settingspages/servereditdlg.ui create mode 100644 src/qtui/settingspages/settingspages.cmake create mode 100644 src/qtui/settingspages/shortcutsmodel.cpp create mode 100644 src/qtui/settingspages/shortcutsmodel.h create mode 100644 src/qtui/settingspages/shortcutssettingspage.cpp create mode 100644 src/qtui/settingspages/shortcutssettingspage.h create mode 100644 src/qtui/settingspages/shortcutssettingspage.ui create mode 100644 src/qtui/settingspages/topicwidgetsettingspage.cpp create mode 100644 src/qtui/settingspages/topicwidgetsettingspage.h create mode 100644 src/qtui/settingspages/topicwidgetsettingspage.ui create mode 100644 src/qtui/simplenetworkeditor.cpp create mode 100644 src/qtui/simplenetworkeditor.h create mode 100644 src/qtui/snorenotificationbackend.cpp create mode 100644 src/qtui/snorenotificationbackend.h create mode 100644 src/qtui/sslinfodlg.cpp create mode 100644 src/qtui/sslinfodlg.h create mode 100644 src/qtui/statusnotifieritem.cpp create mode 100644 src/qtui/statusnotifieritem.h create mode 100644 src/qtui/statusnotifieritemdbus.cpp create mode 100644 src/qtui/statusnotifieritemdbus.h create mode 100644 src/qtui/systemtray.cpp create mode 100644 src/qtui/systemtray.h create mode 100644 src/qtui/systraynotificationbackend.cpp create mode 100644 src/qtui/systraynotificationbackend.h create mode 100644 src/qtui/taskbarnotificationbackend.cpp create mode 100644 src/qtui/taskbarnotificationbackend.h create mode 100644 src/qtui/titlesetter.cpp create mode 100644 src/qtui/titlesetter.h create mode 100644 src/qtui/topicwidget.cpp create mode 100644 src/qtui/topicwidget.h create mode 100644 src/qtui/ui/aboutdlg.ui create mode 100644 src/qtui/ui/bufferviewwidget.ui create mode 100644 src/qtui/ui/bufferwidget.ui create mode 100644 src/qtui/ui/channellistdlg.ui create mode 100644 src/qtui/ui/chatviewsearchbar.ui create mode 100644 src/qtui/ui/coreconfigwizardadminuserpage.ui create mode 100644 src/qtui/ui/coreconfigwizardintropage.ui create mode 100644 src/qtui/ui/coreconfigwizardstorageselectionpage.ui create mode 100644 src/qtui/ui/coreconfigwizardsyncpage.ui create mode 100644 src/qtui/ui/coreconnectauthdlg.ui create mode 100644 src/qtui/ui/coreconnectionstatuswidget.ui create mode 100644 src/qtui/ui/coreinfodlg.ui create mode 100644 src/qtui/ui/debugbufferviewoverlay.ui create mode 100644 src/qtui/ui/debugconsole.ui create mode 100644 src/qtui/ui/debuglogwidget.ui create mode 100644 src/qtui/ui/indicatornotificationconfigwidget.ui create mode 100644 src/qtui/ui/inputwidget.ui create mode 100644 src/qtui/ui/msgprocessorstatuswidget.ui create mode 100644 src/qtui/ui/nicklistwidget.ui create mode 100644 src/qtui/ui/passwordchangedlg.ui create mode 100644 src/qtui/ui/phononnotificationconfigwidget.ui create mode 100644 src/qtui/ui/receivefiledlg.ui create mode 100644 src/qtui/ui/settingsdlg.ui create mode 100644 src/qtui/ui/settingspagedlg.ui create mode 100644 src/qtui/ui/simplenetworkeditor.ui create mode 100644 src/qtui/ui/snorentificationconfigwidget.ui create mode 100644 src/qtui/ui/sslinfodlg.ui create mode 100644 src/qtui/ui/topicwidget.ui create mode 100644 src/qtui/verticaldock.cpp create mode 100644 src/qtui/verticaldock.h create mode 100644 src/qtui/webpreviewitem.cpp create mode 100644 src/qtui/webpreviewitem.h create mode 100644 src/uisupport/CMakeLists.txt create mode 100644 src/uisupport/aboutdata.cpp create mode 100644 src/uisupport/aboutdata.h create mode 100644 src/uisupport/abstractbuffercontainer.cpp create mode 100644 src/uisupport/abstractbuffercontainer.h create mode 100644 src/uisupport/abstractitemview.cpp create mode 100644 src/uisupport/abstractitemview.h create mode 100644 src/uisupport/abstractnotificationbackend.h create mode 100644 src/uisupport/action.cpp create mode 100644 src/uisupport/action.h create mode 100644 src/uisupport/actioncollection.cpp create mode 100644 src/uisupport/actioncollection.h create mode 100644 src/uisupport/bufferhotlistfilter.cpp create mode 100644 src/uisupport/bufferhotlistfilter.h create mode 100644 src/uisupport/bufferview.cpp create mode 100644 src/uisupport/bufferview.h create mode 100644 src/uisupport/bufferviewfilter.cpp create mode 100644 src/uisupport/bufferviewfilter.h create mode 100644 src/uisupport/bufferviewoverlayfilter.cpp create mode 100644 src/uisupport/bufferviewoverlayfilter.h create mode 100644 src/uisupport/clearablelineedit.cpp create mode 100644 src/uisupport/clearablelineedit.h create mode 100644 src/uisupport/clickable.cpp create mode 100644 src/uisupport/clickable.h create mode 100644 src/uisupport/clickablelabel.cpp create mode 100644 src/uisupport/clickablelabel.h create mode 100644 src/uisupport/colorbutton.cpp create mode 100644 src/uisupport/colorbutton.h create mode 100644 src/uisupport/contextmenuactionprovider.cpp create mode 100644 src/uisupport/contextmenuactionprovider.h create mode 100644 src/uisupport/flatproxymodel.cpp create mode 100644 src/uisupport/flatproxymodel.h create mode 100644 src/uisupport/fontselector.cpp create mode 100644 src/uisupport/fontselector.h create mode 100644 src/uisupport/graphicalui.cpp create mode 100644 src/uisupport/graphicalui.h create mode 100644 src/uisupport/kcmdlinewrapper.cpp create mode 100644 src/uisupport/kcmdlinewrapper.h create mode 100644 src/uisupport/multilineedit.cpp create mode 100644 src/uisupport/multilineedit.h create mode 100644 src/uisupport/networkmodelcontroller.cpp create mode 100644 src/uisupport/networkmodelcontroller.h create mode 100644 src/uisupport/nickview.cpp create mode 100644 src/uisupport/nickview.h create mode 100644 src/uisupport/nickviewfilter.cpp create mode 100644 src/uisupport/nickviewfilter.h create mode 100644 src/uisupport/qssparser.cpp create mode 100644 src/uisupport/qssparser.h create mode 100644 src/uisupport/resizingstackedwidget.cpp create mode 100644 src/uisupport/resizingstackedwidget.h create mode 100644 src/uisupport/settingspage.cpp create mode 100644 src/uisupport/settingspage.h create mode 100644 src/uisupport/styledlabel.cpp create mode 100644 src/uisupport/styledlabel.h create mode 100644 src/uisupport/tabcompleter.cpp create mode 100644 src/uisupport/tabcompleter.h create mode 100644 src/uisupport/toolbaractionprovider.cpp create mode 100644 src/uisupport/toolbaractionprovider.h create mode 100644 src/uisupport/treeviewtouch.cpp create mode 100644 src/uisupport/treeviewtouch.h create mode 100644 src/uisupport/uisettings.cpp create mode 100644 src/uisupport/uisettings.h create mode 100644 src/uisupport/uistyle.cpp create mode 100644 src/uisupport/uistyle.h create mode 100644 version.h.in diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d1af528 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +version.h.in export-subst +icons/oxygen_quassel export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1b8b291 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +/build* +*.pyc +tags +/.idea +/cmake-build-* + +# Qt Creator configuration +CMakeLists.txt.user diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5f48a06 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,73 @@ +os: + - linux + +sudo: required +dist: trusty + +language: cpp +cache: ccache + +compiler: + - gcc + - clang + +env: + - QT_VERSION=qt4 + - QT_VERSION=qt5 + +matrix: + include: + - os: osx + compiler: gcc + env: QT_VERSION=qt5 + exclude: + - compiler: clang + env: QT_VERSION=qt4 + +install: |- + if [ "$TRAVIS_OS_NAME" == "linux" ] + then + sudo apt-get -qy install libqt5webkit5-dev qttools5-dev qtscript5-dev + sudo apt-get -qy install libdbusmenu-qt-dev libdbusmenu-qt5-dev + sudo apt-get -qy install libphonon-dev libphonon4qt5-dev + sudo apt-get -qy install libqca2-dev + sudo apt-get -qy install qt4-dev-tools qttools5-dev-tools + sudo apt-get -qy install libphonon4qt5experimental4 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=805096 + elif [ "$TRAVIS_OS_NAME" == "osx" ] + then + brew update + brew install ninja qt5 + fi + +script: |- + mkdir build + cd build + if [ "$TRAVIS_OS_NAME" == "linux" ] + then + if [ "$QT_VERSION" = "qt4" ]; then cmake ..; fi + if [ "$QT_VERSION" = "qt5" ]; then cmake -DUSE_QT5=ON ..; fi + make + elif [ "$TRAVIS_OS_NAME" == "osx" ] + then + PATH=$PATH:/usr/local/opt/qt5/bin + if [[ "$TRAVIS_TAG" != "" && "$GH_TOKEN" != "" ]] + then + cmake -G"Ninja" .. -DCMAKE_BUILD_TYPE=Release -DUSE_QT5=ON -DWANT_CORE=ON -DWANT_QTCLIENT=ON -DWANT_MONO=ON -DDEPLOY=ON + else + cmake -G"Ninja" .. -DCMAKE_BUILD_TYPE=Release -DUSE_QT5=ON -DWANT_CORE=ON -DWANT_QTCLIENT=ON -DWANT_MONO=ON + fi + ninja install + fi + +deploy: + provider: releases + api_key: "${GH_TOKEN}" + file_glob: true + file: + - "QuasselClient_MacOSX-x86_64_*.dmg" + - "QuasselCore_MacOSX-x86_64_*.dmg" + - "QuasselMono_MacOSX-x86_64_*.dmg" + skip_cleanup: true + on: + tags: true + condition: "$TRAVIS_OS_NAME == 'osx' && $GH_TOKEN != ''" diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..c64d3bc --- /dev/null +++ b/.tx/config @@ -0,0 +1,8 @@ +[main] +host = https://www.transifex.com + +[quassel.master] +file_filter = po/.po +source_file = po/quassel.pot +source_lang = en +type = PO diff --git a/3rdparty/miniz/miniz.c b/3rdparty/miniz/miniz.c new file mode 100644 index 0000000..4805823 --- /dev/null +++ b/3rdparty/miniz/miniz.c @@ -0,0 +1,4916 @@ +/* miniz.c v1.15 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing + See "unlicense" statement at the end of this file. + Rich Geldreich , last updated Oct. 13, 2013 + Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt + + Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define + MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros). + + * Change History + 10/13/13 v1.15 r4 - Interim bugfix release while I work on the next major release with Zip64 support (almost there!): + - Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug + would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place() + (which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag). + - Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size + - Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries. + Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice). + - Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes + - mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed + - Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6. + - Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti + - Merged MZ_FORCEINLINE fix from hdeanclark + - Fix include before config #ifdef, thanks emil.brink + - Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can + set it to 1 for real-time compression). + - Merged in some compiler fixes from paulharris's github repro. + - Retested this build under Windows (VS 2010, including static analysis), tcc 0.9.26, gcc v4.6 and clang v3.3. + - Added example6.c, which dumps an image of the mandelbrot set to a PNG file. + - Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more. + - In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled + - In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch + 5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include (thanks fermtect). + 5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit. + - Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. + - Eliminated a bunch of warnings when compiling with GCC 32-bit/64. + - Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly + "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning). + - Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. + - Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. + - Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. + - Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.) + - Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). + 4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's. + level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson for the feedback/bug report. + 5/28/11 v1.11 - Added statement from unlicense.org + 5/27/11 v1.10 - Substantial compressor optimizations: + - Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a + - Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86). + - Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types. + - Refactored the compression code for better readability and maintainability. + - Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large + drop in throughput on some files). + 5/15/11 v1.09 - Initial stable release. + + * Low-level Deflate/Inflate implementation notes: + + Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or + greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses + approximately as well as zlib. + + Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function + coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory + block large enough to hold the entire file. + + The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation. + + * zlib-style API notes: + + miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in + zlib replacement in many apps: + The z_stream struct, optional memory allocation callbacks + deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound + inflateInit/inflateInit2/inflate/inflateEnd + compress, compress2, compressBound, uncompress + CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines. + Supports raw deflate streams or standard zlib streams with adler-32 checking. + + Limitations: + The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries. + I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but + there are no guarantees that miniz.c pulls this off perfectly. + + * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by + Alex Evans. Supports 1-4 bytes/pixel images. + + * ZIP archive API notes: + + The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to + get the job done with minimal fuss. There are simple API's to retrieve file information, read files from + existing archives, create new archives, append new files to existing archives, or clone archive data from + one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h), + or you can specify custom file read/write callbacks. + + - Archive reading: Just call this function to read a single file from a disk archive: + + void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, + size_t *pSize, mz_uint zip_flags); + + For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central + directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files. + + - Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file: + + int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); + + The locate operation can optionally check file comments too, which (as one example) can be used to identify + multiple versions of the same file in an archive. This function uses a simple linear search through the central + directory, so it's not very fast. + + Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and + retrieve detailed info on each file by calling mz_zip_reader_file_stat(). + + - Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data + to disk and builds an exact image of the central directory in memory. The central directory image is written + all at once at the end of the archive file when the archive is finalized. + + The archive writer can optionally align each file's local header and file data to any power of 2 alignment, + which can be useful when the archive will be read from optical media. Also, the writer supports placing + arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still + readable by any ZIP tool. + + - Archive appending: The simple way to add a single file to an archive is to call this function: + + mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, + const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); + + The archive will be created if it doesn't already exist, otherwise it'll be appended to. + Note the appending is done in-place and is not an atomic operation, so if something goes wrong + during the operation it's possible the archive could be left without a central directory (although the local + file headers and file data will be fine, so the archive will be recoverable). + + For more complex archive modification scenarios: + 1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to + preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the + compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and + you're done. This is safe but requires a bunch of temporary disk space or heap memory. + + 2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(), + append new files as needed, then finalize the archive which will write an updated central directory to the + original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a + possibility that the archive's central directory could be lost with this method if anything goes wrong, though. + + - ZIP archive support limitations: + No zip64 or spanning support. Extraction functions can only handle unencrypted, stored or deflated files. + Requires streams capable of seeking. + + * This is a header file library, like stb_image.c. To get only a header file, either cut and paste the + below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it. + + * Important: For best perf. be sure to customize the below macros for your target platform: + #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 + #define MINIZ_LITTLE_ENDIAN 1 + #define MINIZ_HAS_64BIT_REGISTERS 1 + + * On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz + uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files + (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes). +*/ + +#ifndef MINIZ_HEADER_INCLUDED +#define MINIZ_HEADER_INCLUDED + +#include + +// Defines to completely disable specific portions of miniz.c: +// If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. + +// Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. +#define MINIZ_NO_STDIO + +// If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the current time, or +// get/set file times, and the C run-time funcs that get/set times won't be called. +// The current downside is the times written to your archives will be from 1979. +#define MINIZ_NO_TIME + +// Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. +#define MINIZ_NO_ARCHIVE_APIS + +// Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive API's. +#define MINIZ_NO_ARCHIVE_WRITING_APIS + +// Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's. +//#define MINIZ_NO_ZLIB_APIS + +// Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. +//#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES + +// Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc. +// Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc +// callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user +// functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. +//#define MINIZ_NO_MALLOC + +#if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) + // TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux + #define MINIZ_NO_TIME +#endif + +#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS) + #include +#endif + +#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) +// MINIZ_X86_OR_X64_CPU is only used to help set the below macros. +#define MINIZ_X86_OR_X64_CPU 1 +#endif + +#if (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU +// Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. +#define MINIZ_LITTLE_ENDIAN 1 +#endif + +#if MINIZ_X86_OR_X64_CPU +// Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. +#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 +#endif + +#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__) +// Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). +#define MINIZ_HAS_64BIT_REGISTERS 1 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// ------------------- zlib-style API Definitions. + +// For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! +typedef unsigned long mz_ulong; + +// mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap. +void mz_free(void *p); + +#define MZ_ADLER32_INIT (1) +// mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL. +mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len); + +#define MZ_CRC32_INIT (0) +// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. +mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len); + +// Compression strategies. +enum { MZ_DEFAULT_STRATEGY = 0, MZ_FILTERED = 1, MZ_HUFFMAN_ONLY = 2, MZ_RLE = 3, MZ_FIXED = 4 }; + +// Method +#define MZ_DEFLATED 8 + +#ifndef MINIZ_NO_ZLIB_APIS + +// Heap allocation callbacks. +// Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. +typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); +typedef void (*mz_free_func)(void *opaque, void *address); +typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size); + +#define MZ_VERSION "9.1.15" +#define MZ_VERNUM 0x91F0 +#define MZ_VER_MAJOR 9 +#define MZ_VER_MINOR 1 +#define MZ_VER_REVISION 15 +#define MZ_VER_SUBREVISION 0 + +// Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs). +enum { MZ_NO_FLUSH = 0, MZ_PARTIAL_FLUSH = 1, MZ_SYNC_FLUSH = 2, MZ_FULL_FLUSH = 3, MZ_FINISH = 4, MZ_BLOCK = 5 }; + +// Return status codes. MZ_PARAM_ERROR is non-standard. +enum { MZ_OK = 0, MZ_STREAM_END = 1, MZ_NEED_DICT = 2, MZ_ERRNO = -1, MZ_STREAM_ERROR = -2, MZ_DATA_ERROR = -3, MZ_MEM_ERROR = -4, MZ_BUF_ERROR = -5, MZ_VERSION_ERROR = -6, MZ_PARAM_ERROR = -10000 }; + +// Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. +enum { MZ_NO_COMPRESSION = 0, MZ_BEST_SPEED = 1, MZ_BEST_COMPRESSION = 9, MZ_UBER_COMPRESSION = 10, MZ_DEFAULT_LEVEL = 6, MZ_DEFAULT_COMPRESSION = -1 }; + +// Window bits +#define MZ_DEFAULT_WINDOW_BITS 15 + +struct mz_internal_state; + +// Compression/decompression stream struct. +typedef struct mz_stream_s +{ + const unsigned char *next_in; // pointer to next byte to read + unsigned int avail_in; // number of bytes available at next_in + mz_ulong total_in; // total number of bytes consumed so far + + unsigned char *next_out; // pointer to next byte to write + unsigned int avail_out; // number of bytes that can be written to next_out + mz_ulong total_out; // total number of bytes produced so far + + char *msg; // error msg (unused) + struct mz_internal_state *state; // internal state, allocated by zalloc/zfree + + mz_alloc_func zalloc; // optional heap allocation function (defaults to malloc) + mz_free_func zfree; // optional heap free function (defaults to free) + void *opaque; // heap alloc function user pointer + + int data_type; // data_type (unused) + mz_ulong adler; // adler32 of the source or uncompressed data + mz_ulong reserved; // not used +} mz_stream; + +typedef mz_stream *mz_streamp; + +// Returns the version string of miniz.c. +const char *mz_version(void); + +// mz_deflateInit() initializes a compressor with default options: +// Parameters: +// pStream must point to an initialized mz_stream struct. +// level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION]. +// level 1 enables a specially optimized compression function that's been optimized purely for performance, not ratio. +// (This special func. is currently only enabled when MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.) +// Return values: +// MZ_OK on success. +// MZ_STREAM_ERROR if the stream is bogus. +// MZ_PARAM_ERROR if the input parameters are bogus. +// MZ_MEM_ERROR on out of memory. +int mz_deflateInit(mz_streamp pStream, int level); + +// mz_deflateInit2() is like mz_deflate(), except with more control: +// Additional parameters: +// method must be MZ_DEFLATED +// window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer) +// mem_level must be between [1, 9] (it's checked but ignored by miniz.c) +int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy); + +// Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). +int mz_deflateReset(mz_streamp pStream); + +// mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible. +// Parameters: +// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. +// flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or MZ_FINISH. +// Return values: +// MZ_OK on success (when flushing, or if more input is needed but not available, and/or there's more output to be written but the output buffer is full). +// MZ_STREAM_END if all input has been consumed and all output bytes have been written. Don't call mz_deflate() on the stream anymore. +// MZ_STREAM_ERROR if the stream is bogus. +// MZ_PARAM_ERROR if one of the parameters is invalid. +// MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.) +int mz_deflate(mz_streamp pStream, int flush); + +// mz_deflateEnd() deinitializes a compressor: +// Return values: +// MZ_OK on success. +// MZ_STREAM_ERROR if the stream is bogus. +int mz_deflateEnd(mz_streamp pStream); + +// mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH. +mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len); + +// Single-call compression functions mz_compress() and mz_compress2(): +// Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure. +int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); +int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level); + +// mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). +mz_ulong mz_compressBound(mz_ulong source_len); + +// Initializes a decompressor. +int mz_inflateInit(mz_streamp pStream); + +// mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer: +// window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate). +int mz_inflateInit2(mz_streamp pStream, int window_bits); + +// Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible. +// Parameters: +// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. +// flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH. +// On the first call, if flush is MZ_FINISH it's assumed the input and output buffers are both sized large enough to decompress the entire stream in a single call (this is slightly faster). +// MZ_FINISH implies that there are no more source bytes available beside what's already in the input buffer, and that the output buffer is large enough to hold the rest of the decompressed data. +// Return values: +// MZ_OK on success. Either more input is needed but not available, and/or there's more output to be written but the output buffer is full. +// MZ_STREAM_END if all needed input has been consumed and all output bytes have been written. For zlib streams, the adler-32 of the decompressed data has also been verified. +// MZ_STREAM_ERROR if the stream is bogus. +// MZ_DATA_ERROR if the deflate stream is invalid. +// MZ_PARAM_ERROR if one of the parameters is invalid. +// MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again +// with more input data, or with more room in the output buffer (except when using single call decompression, described above). +int mz_inflate(mz_streamp pStream, int flush); + +// Deinitializes a decompressor. +int mz_inflateEnd(mz_streamp pStream); + +// Single-call decompression. +// Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. +int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); + +// Returns a string description of the specified error code, or NULL if the error code is invalid. +const char *mz_error(int err); + +// Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports. +// Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project. +#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES + typedef unsigned char Byte; + typedef unsigned int uInt; + typedef mz_ulong uLong; + typedef Byte Bytef; + typedef uInt uIntf; + typedef char charf; + typedef int intf; + typedef void *voidpf; + typedef uLong uLongf; + typedef void *voidp; + typedef void *const voidpc; + #define Z_NULL 0 + #define Z_NO_FLUSH MZ_NO_FLUSH + #define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH + #define Z_SYNC_FLUSH MZ_SYNC_FLUSH + #define Z_FULL_FLUSH MZ_FULL_FLUSH + #define Z_FINISH MZ_FINISH + #define Z_BLOCK MZ_BLOCK + #define Z_OK MZ_OK + #define Z_STREAM_END MZ_STREAM_END + #define Z_NEED_DICT MZ_NEED_DICT + #define Z_ERRNO MZ_ERRNO + #define Z_STREAM_ERROR MZ_STREAM_ERROR + #define Z_DATA_ERROR MZ_DATA_ERROR + #define Z_MEM_ERROR MZ_MEM_ERROR + #define Z_BUF_ERROR MZ_BUF_ERROR + #define Z_VERSION_ERROR MZ_VERSION_ERROR + #define Z_PARAM_ERROR MZ_PARAM_ERROR + #define Z_NO_COMPRESSION MZ_NO_COMPRESSION + #define Z_BEST_SPEED MZ_BEST_SPEED + #define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION + #define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION + #define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY + #define Z_FILTERED MZ_FILTERED + #define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY + #define Z_RLE MZ_RLE + #define Z_FIXED MZ_FIXED + #define Z_DEFLATED MZ_DEFLATED + #define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS + #define alloc_func mz_alloc_func + #define free_func mz_free_func + #define internal_state mz_internal_state + #define z_stream mz_stream + #define deflateInit mz_deflateInit + #define deflateInit2 mz_deflateInit2 + #define deflateReset mz_deflateReset + #define deflate mz_deflate + #define deflateEnd mz_deflateEnd + #define deflateBound mz_deflateBound + #define compress mz_compress + #define compress2 mz_compress2 + #define compressBound mz_compressBound + #define inflateInit mz_inflateInit + #define inflateInit2 mz_inflateInit2 + #define inflate mz_inflate + #define inflateEnd mz_inflateEnd + #define uncompress mz_uncompress + #define crc32 mz_crc32 + #define adler32 mz_adler32 + #define MAX_WBITS 15 + #define MAX_MEM_LEVEL 9 + #define zError mz_error + #define ZLIB_VERSION MZ_VERSION + #define ZLIB_VERNUM MZ_VERNUM + #define ZLIB_VER_MAJOR MZ_VER_MAJOR + #define ZLIB_VER_MINOR MZ_VER_MINOR + #define ZLIB_VER_REVISION MZ_VER_REVISION + #define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION + #define zlibVersion mz_version + #define zlib_version mz_version() +#endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES + +#endif // MINIZ_NO_ZLIB_APIS + +// ------------------- Types and macros + +typedef unsigned char mz_uint8; +typedef signed short mz_int16; +typedef unsigned short mz_uint16; +typedef unsigned int mz_uint32; +typedef unsigned int mz_uint; +typedef long long mz_int64; +typedef unsigned long long mz_uint64; +typedef int mz_bool; + +#define MZ_FALSE (0) +#define MZ_TRUE (1) + +// An attempt to work around MSVC's spammy "warning C4127: conditional expression is constant" message. +#ifdef _MSC_VER + #define MZ_MACRO_END while (0, 0) +#else + #define MZ_MACRO_END while (0) +#endif + +// ------------------- ZIP archive reading/writing + +#ifndef MINIZ_NO_ARCHIVE_APIS + +enum +{ + MZ_ZIP_MAX_IO_BUF_SIZE = 64*1024, + MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 260, + MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 256 +}; + +typedef struct +{ + mz_uint32 m_file_index; + mz_uint32 m_central_dir_ofs; + mz_uint16 m_version_made_by; + mz_uint16 m_version_needed; + mz_uint16 m_bit_flag; + mz_uint16 m_method; +#ifndef MINIZ_NO_TIME + time_t m_time; +#endif + mz_uint32 m_crc32; + mz_uint64 m_comp_size; + mz_uint64 m_uncomp_size; + mz_uint16 m_internal_attr; + mz_uint32 m_external_attr; + mz_uint64 m_local_header_ofs; + mz_uint32 m_comment_size; + char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]; + char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]; +} mz_zip_archive_file_stat; + +typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n); +typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n); + +struct mz_zip_internal_state_tag; +typedef struct mz_zip_internal_state_tag mz_zip_internal_state; + +typedef enum +{ + MZ_ZIP_MODE_INVALID = 0, + MZ_ZIP_MODE_READING = 1, + MZ_ZIP_MODE_WRITING = 2, + MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 +} mz_zip_mode; + +typedef struct mz_zip_archive_tag +{ + mz_uint64 m_archive_size; + mz_uint64 m_central_directory_file_ofs; + mz_uint m_total_files; + mz_zip_mode m_zip_mode; + + mz_uint m_file_offset_alignment; + + mz_alloc_func m_pAlloc; + mz_free_func m_pFree; + mz_realloc_func m_pRealloc; + void *m_pAlloc_opaque; + + mz_file_read_func m_pRead; + mz_file_write_func m_pWrite; + void *m_pIO_opaque; + + mz_zip_internal_state *m_pState; + +} mz_zip_archive; + +typedef enum +{ + MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, + MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, + MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, + MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800 +} mz_zip_flags; + +// ZIP archive reading + +// Inits a ZIP archive reader. +// These functions read and validate the archive's central directory. +mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags); +mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags); + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags); +#endif + +// Returns the total number of files in the archive. +mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip); + +// Returns detailed information about an archive file entry. +mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat); + +// Determines if an archive file entry is a directory entry. +mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index); +mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index); + +// Retrieves the filename of an archive file entry. +// Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. +mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size); + +// Attempts to locates a file in the archive's central directory. +// Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH +// Returns -1 if the file cannot be found. +int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); + +// Extracts a archive file to a memory buffer using no memory allocation. +mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); +mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); + +// Extracts a archive file to a memory buffer. +mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags); +mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags); + +// Extracts a archive file to a dynamically allocated heap buffer. +void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags); +void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags); + +// Extracts a archive file using a callback function to output the file's data. +mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); +mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); + +#ifndef MINIZ_NO_STDIO +// Extracts a archive file to a disk file and sets its last accessed and modified times. +// This function only extracts files, not archive directory records. +mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags); +mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags); +#endif + +// Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. +mz_bool mz_zip_reader_end(mz_zip_archive *pZip); + +// ZIP archive writing + +#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS + +// Inits a ZIP archive writer. +mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size); +mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size); + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning); +#endif + +// Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. +// For archives opened using mz_zip_reader_init_file, pFilename must be the archive's filename so it can be reopened for writing. If the file can't be reopened, mz_zip_reader_end() will be called. +// For archives opened using mz_zip_reader_init_mem, the memory block must be growable using the realloc callback (which defaults to realloc unless you've overridden it). +// Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. +// Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before +// the archive is finalized the file's central directory will be hosed. +mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename); + +// Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. +// To add a directory entry, call this method with an archive name ending in a forwardslash with empty buffer. +// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. +mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags); +mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32); + +#ifndef MINIZ_NO_STDIO +// Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. +// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. +mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); +#endif + +// Adds a file to an archive by fully cloning the data from another archive. +// This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data, and comment fields. +mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index); + +// Finalizes the archive by writing the central directory records followed by the end of central directory record. +// After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). +// An archive must be manually finalized by calling this function for it to be valid. +mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip); +mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize); + +// Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. +// Note for the archive to be valid, it must have been finalized before ending. +mz_bool mz_zip_writer_end(mz_zip_archive *pZip); + +// Misc. high-level helper functions: + +// mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) appends a memory blob to a ZIP archive. +// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. +mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); + +// Reads a single file from an archive into a heap block. +// Returns NULL on failure. +void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags); + +#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS + +#endif // #ifndef MINIZ_NO_ARCHIVE_APIS + +// ------------------- Low-level Decompression API Definitions + +// Decompression flags used by tinfl_decompress(). +// TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. +// TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. +// TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). +// TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. +enum +{ + TINFL_FLAG_PARSE_ZLIB_HEADER = 1, + TINFL_FLAG_HAS_MORE_INPUT = 2, + TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4, + TINFL_FLAG_COMPUTE_ADLER32 = 8 +}; + +// High level decompression functions: +// tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc(). +// On entry: +// pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress. +// On return: +// Function returns a pointer to the decompressed data, or NULL on failure. +// *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. +// The caller must call mz_free() on the returned block when it's no longer needed. +void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); + +// tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. +// Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. +#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1)) +size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); + +// tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. +// Returns 1 on success or 0 on failure. +typedef int (*tinfl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); +int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); + +struct tinfl_decompressor_tag; typedef struct tinfl_decompressor_tag tinfl_decompressor; + +// Max size of LZ dictionary. +#define TINFL_LZ_DICT_SIZE 32768 + +// Return status. +typedef enum +{ + TINFL_STATUS_BAD_PARAM = -3, + TINFL_STATUS_ADLER32_MISMATCH = -2, + TINFL_STATUS_FAILED = -1, + TINFL_STATUS_DONE = 0, + TINFL_STATUS_NEEDS_MORE_INPUT = 1, + TINFL_STATUS_HAS_MORE_OUTPUT = 2 +} tinfl_status; + +// Initializes the decompressor to its initial state. +#define tinfl_init(r) do { (r)->m_state = 0; } MZ_MACRO_END +#define tinfl_get_adler32(r) (r)->m_check_adler32 + +// Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. +// This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. +tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags); + +// Internal/private bits follow. +enum +{ + TINFL_MAX_HUFF_TABLES = 3, TINFL_MAX_HUFF_SYMBOLS_0 = 288, TINFL_MAX_HUFF_SYMBOLS_1 = 32, TINFL_MAX_HUFF_SYMBOLS_2 = 19, + TINFL_FAST_LOOKUP_BITS = 10, TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS +}; + +typedef struct +{ + mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]; + mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2]; +} tinfl_huff_table; + +#if defined MINIZ_HAS_64BIT_REGISTERS && MINIZ_HAS_64BIT_REGISTERS + #define TINFL_USE_64BIT_BITBUF 1 +#endif + +#if defined TINFL_USE_64BIT_BITBUF && TINFL_USE_64BIT_BITBUF + typedef mz_uint64 tinfl_bit_buf_t; + #define TINFL_BITBUF_SIZE (64) +#else + typedef mz_uint32 tinfl_bit_buf_t; + #define TINFL_BITBUF_SIZE (32) +#endif + +struct tinfl_decompressor_tag +{ + mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES]; + tinfl_bit_buf_t m_bit_buf; + size_t m_dist_from_out_buf_start; + tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]; + mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137]; +}; + +// ------------------- Low-level Compression API Definitions + +// Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently). +#define TDEFL_LESS_MEMORY 0 + +// tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search): +// TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression). +enum +{ + TDEFL_HUFFMAN_ONLY = 0, TDEFL_DEFAULT_MAX_PROBES = 128, TDEFL_MAX_PROBES_MASK = 0xFFF +}; + +// TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data. +// TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers). +// TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing. +// TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory). +// TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) +// TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. +// TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. +// TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. +// The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). +enum +{ + TDEFL_WRITE_ZLIB_HEADER = 0x01000, + TDEFL_COMPUTE_ADLER32 = 0x02000, + TDEFL_GREEDY_PARSING_FLAG = 0x04000, + TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000, + TDEFL_RLE_MATCHES = 0x10000, + TDEFL_FILTER_MATCHES = 0x20000, + TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000, + TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000 +}; + +// High level compression functions: +// tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc(). +// On entry: +// pSrc_buf, src_buf_len: Pointer and size of source block to compress. +// flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression. +// On return: +// Function returns a pointer to the compressed data, or NULL on failure. +// *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. +// The caller must free() the returned block when it's no longer needed. +void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); + +// tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. +// Returns 0 on failure. +size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); + +// Compresses an image to a compressed PNG file in memory. +// On entry: +// pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. +// The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. +// level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL +// If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps). +// On return: +// Function returns a pointer to the compressed data, or NULL on failure. +// *pLen_out will be set to the size of the PNG image file. +// The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. +void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip); +void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out); + +// Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. +typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); + +// tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. +mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); + +enum { TDEFL_MAX_HUFF_TABLES = 3, TDEFL_MAX_HUFF_SYMBOLS_0 = 288, TDEFL_MAX_HUFF_SYMBOLS_1 = 32, TDEFL_MAX_HUFF_SYMBOLS_2 = 19, TDEFL_LZ_DICT_SIZE = 32768, TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, TDEFL_MIN_MATCH_LEN = 3, TDEFL_MAX_MATCH_LEN = 258 }; + +// TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). +#if TDEFL_LESS_MEMORY +enum { TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 12, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; +#else +enum { TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 15, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; +#endif + +// The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. +typedef enum +{ + TDEFL_STATUS_BAD_PARAM = -2, + TDEFL_STATUS_PUT_BUF_FAILED = -1, + TDEFL_STATUS_OKAY = 0, + TDEFL_STATUS_DONE = 1, +} tdefl_status; + +// Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums +typedef enum +{ + TDEFL_NO_FLUSH = 0, + TDEFL_SYNC_FLUSH = 2, + TDEFL_FULL_FLUSH = 3, + TDEFL_FINISH = 4 +} tdefl_flush; + +// tdefl's compression state structure. +typedef struct +{ + tdefl_put_buf_func_ptr m_pPut_buf_func; + void *m_pPut_buf_user; + mz_uint m_flags, m_max_probes[2]; + int m_greedy_parsing; + mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; + mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; + mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer; + mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish; + tdefl_status m_prev_return_status; + const void *m_pIn_buf; + void *m_pOut_buf; + size_t *m_pIn_buf_size, *m_pOut_buf_size; + tdefl_flush m_flush; + const mz_uint8 *m_pSrc; + size_t m_src_buf_left, m_out_buf_ofs; + mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1]; + mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; + mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; + mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; + mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]; + mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]; + mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]; + mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]; +} tdefl_compressor; + +// Initializes the compressor. +// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory. +// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression. +// If pBut_buf_func is NULL the user should always call the tdefl_compress() API. +// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) +tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); + +// Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible. +tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush); + +// tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. +// tdefl_compress_buffer() always consumes the entire input buffer. +tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush); + +tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d); +mz_uint32 tdefl_get_adler32(tdefl_compressor *d); + +// Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't defined, because it uses some of its macros. +#ifndef MINIZ_NO_ZLIB_APIS +// Create tdefl_compress() flags given zlib-style compression parameters. +// level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) +// window_bits may be -15 (raw deflate) or 15 (zlib) +// strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED +mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); +#endif // #ifndef MINIZ_NO_ZLIB_APIS + +#ifdef __cplusplus +} +#endif + +#endif // MINIZ_HEADER_INCLUDED + +// ------------------- End of Header: Implementation follows. (If you only want the header, define MINIZ_HEADER_FILE_ONLY.) + +#ifndef MINIZ_HEADER_FILE_ONLY + +typedef unsigned char mz_validate_uint16[sizeof(mz_uint16)==2 ? 1 : -1]; +typedef unsigned char mz_validate_uint32[sizeof(mz_uint32)==4 ? 1 : -1]; +typedef unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 : -1]; + +#include +#include + +#define MZ_ASSERT(x) assert(x) + +#ifdef MINIZ_NO_MALLOC + #define MZ_MALLOC(x) NULL + #define MZ_FREE(x) (void)x, ((void)0) + #define MZ_REALLOC(p, x) NULL +#else + #define MZ_MALLOC(x) malloc(x) + #define MZ_FREE(x) free(x) + #define MZ_REALLOC(p, x) realloc(p, x) +#endif + +#define MZ_MAX(a,b) (((a)>(b))?(a):(b)) +#define MZ_MIN(a,b) (((a)<(b))?(a):(b)) +#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN + #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) + #define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) +#else + #define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U)) + #define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U)) +#endif + +#ifdef _MSC_VER + #define MZ_FORCEINLINE __forceinline +#elif defined(__GNUC__) + #define MZ_FORCEINLINE inline __attribute__((__always_inline__)) +#else + #define MZ_FORCEINLINE inline +#endif + +#ifdef __cplusplus + extern "C" { +#endif + +// ------------------- zlib-style API's + +mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) +{ + mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); size_t block_len = buf_len % 5552; + if (!ptr) return MZ_ADLER32_INIT; + while (buf_len) { + for (i = 0; i + 7 < block_len; i += 8, ptr += 8) { + s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; + s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; + } + for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1; + s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; + } + return (s2 << 16) + s1; +} + +// Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C implementation that balances processor cache usage against speed": http://www.geocities.com/malbrain/ +mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) +{ + static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, + 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c }; + mz_uint32 crcu32 = (mz_uint32)crc; + if (!ptr) return MZ_CRC32_INIT; + crcu32 = ~crcu32; while (buf_len--) { mz_uint8 b = *ptr++; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; } + return ~crcu32; +} + +void mz_free(void *p) +{ + MZ_FREE(p); +} + +#ifndef MINIZ_NO_ZLIB_APIS + +static void *def_alloc_func(void *opaque, size_t items, size_t size) { (void)opaque, (void)items, (void)size; return MZ_MALLOC(items * size); } +static void def_free_func(void *opaque, void *address) { (void)opaque, (void)address; MZ_FREE(address); } +static void *def_realloc_func(void *opaque, void *address, size_t items, size_t size) { (void)opaque, (void)address, (void)items, (void)size; return MZ_REALLOC(address, items * size); } + +const char *mz_version(void) +{ + return MZ_VERSION; +} + +int mz_deflateInit(mz_streamp pStream, int level) +{ + return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY); +} + +int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy) +{ + tdefl_compressor *pComp; + mz_uint comp_flags = TDEFL_COMPUTE_ADLER32 | tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy); + + if (!pStream) return MZ_STREAM_ERROR; + if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS))) return MZ_PARAM_ERROR; + + pStream->data_type = 0; + pStream->adler = MZ_ADLER32_INIT; + pStream->msg = NULL; + pStream->reserved = 0; + pStream->total_in = 0; + pStream->total_out = 0; + if (!pStream->zalloc) pStream->zalloc = def_alloc_func; + if (!pStream->zfree) pStream->zfree = def_free_func; + + pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, sizeof(tdefl_compressor)); + if (!pComp) + return MZ_MEM_ERROR; + + pStream->state = (struct mz_internal_state *)pComp; + + if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY) + { + mz_deflateEnd(pStream); + return MZ_PARAM_ERROR; + } + + return MZ_OK; +} + +int mz_deflateReset(mz_streamp pStream) +{ + if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || (!pStream->zfree)) return MZ_STREAM_ERROR; + pStream->total_in = pStream->total_out = 0; + tdefl_init((tdefl_compressor*)pStream->state, NULL, NULL, ((tdefl_compressor*)pStream->state)->m_flags); + return MZ_OK; +} + +int mz_deflate(mz_streamp pStream, int flush) +{ + size_t in_bytes, out_bytes; + mz_ulong orig_total_in, orig_total_out; + int mz_status = MZ_OK; + + if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || (!pStream->next_out)) return MZ_STREAM_ERROR; + if (!pStream->avail_out) return MZ_BUF_ERROR; + + if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; + + if (((tdefl_compressor*)pStream->state)->m_prev_return_status == TDEFL_STATUS_DONE) + return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR; + + orig_total_in = pStream->total_in; orig_total_out = pStream->total_out; + for ( ; ; ) + { + tdefl_status defl_status; + in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; + + defl_status = tdefl_compress((tdefl_compressor*)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush); + pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; + pStream->total_in += (mz_uint)in_bytes; pStream->adler = tdefl_get_adler32((tdefl_compressor*)pStream->state); + + pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; + pStream->total_out += (mz_uint)out_bytes; + + if (defl_status < 0) + { + mz_status = MZ_STREAM_ERROR; + break; + } + else if (defl_status == TDEFL_STATUS_DONE) + { + mz_status = MZ_STREAM_END; + break; + } + else if (!pStream->avail_out) + break; + else if ((!pStream->avail_in) && (flush != MZ_FINISH)) + { + if ((flush) || (pStream->total_in != orig_total_in) || (pStream->total_out != orig_total_out)) + break; + return MZ_BUF_ERROR; // Can't make forward progress without some input. + } + } + return mz_status; +} + +int mz_deflateEnd(mz_streamp pStream) +{ + if (!pStream) return MZ_STREAM_ERROR; + if (pStream->state) + { + pStream->zfree(pStream->opaque, pStream->state); + pStream->state = NULL; + } + return MZ_OK; +} + +mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) +{ + (void)pStream; + // This is really over conservative. (And lame, but it's actually pretty tricky to compute a true upper bound given the way tdefl's blocking works.) + return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5); +} + +int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level) +{ + int status; + mz_stream stream; + memset(&stream, 0, sizeof(stream)); + + // In case mz_ulong is 64-bits (argh I hate longs). + if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; + + stream.next_in = pSource; + stream.avail_in = (mz_uint32)source_len; + stream.next_out = pDest; + stream.avail_out = (mz_uint32)*pDest_len; + + status = mz_deflateInit(&stream, level); + if (status != MZ_OK) return status; + + status = mz_deflate(&stream, MZ_FINISH); + if (status != MZ_STREAM_END) + { + mz_deflateEnd(&stream); + return (status == MZ_OK) ? MZ_BUF_ERROR : status; + } + + *pDest_len = stream.total_out; + return mz_deflateEnd(&stream); +} + +int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) +{ + return mz_compress2(pDest, pDest_len, pSource, source_len, MZ_DEFAULT_COMPRESSION); +} + +mz_ulong mz_compressBound(mz_ulong source_len) +{ + return mz_deflateBound(NULL, source_len); +} + +typedef struct +{ + tinfl_decompressor m_decomp; + mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed; int m_window_bits; + mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]; + tinfl_status m_last_status; +} inflate_state; + +int mz_inflateInit2(mz_streamp pStream, int window_bits) +{ + inflate_state *pDecomp; + if (!pStream) return MZ_STREAM_ERROR; + if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS)) return MZ_PARAM_ERROR; + + pStream->data_type = 0; + pStream->adler = 0; + pStream->msg = NULL; + pStream->total_in = 0; + pStream->total_out = 0; + pStream->reserved = 0; + if (!pStream->zalloc) pStream->zalloc = def_alloc_func; + if (!pStream->zfree) pStream->zfree = def_free_func; + + pDecomp = (inflate_state*)pStream->zalloc(pStream->opaque, 1, sizeof(inflate_state)); + if (!pDecomp) return MZ_MEM_ERROR; + + pStream->state = (struct mz_internal_state *)pDecomp; + + tinfl_init(&pDecomp->m_decomp); + pDecomp->m_dict_ofs = 0; + pDecomp->m_dict_avail = 0; + pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT; + pDecomp->m_first_call = 1; + pDecomp->m_has_flushed = 0; + pDecomp->m_window_bits = window_bits; + + return MZ_OK; +} + +int mz_inflateInit(mz_streamp pStream) +{ + return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS); +} + +int mz_inflate(mz_streamp pStream, int flush) +{ + inflate_state* pState; + mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32; + size_t in_bytes, out_bytes, orig_avail_in; + tinfl_status status; + + if ((!pStream) || (!pStream->state)) return MZ_STREAM_ERROR; + if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; + if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; + + pState = (inflate_state*)pStream->state; + if (pState->m_window_bits > 0) decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER; + orig_avail_in = pStream->avail_in; + + first_call = pState->m_first_call; pState->m_first_call = 0; + if (pState->m_last_status < 0) return MZ_DATA_ERROR; + + if (pState->m_has_flushed && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; + pState->m_has_flushed |= (flush == MZ_FINISH); + + if ((flush == MZ_FINISH) && (first_call)) + { + // MZ_FINISH on the first call implies that the input and output buffers are large enough to hold the entire compressed/decompressed file. + decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF; + in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; + status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags); + pState->m_last_status = status; + pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes; + pStream->adler = tinfl_get_adler32(&pState->m_decomp); + pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; pStream->total_out += (mz_uint)out_bytes; + + if (status < 0) + return MZ_DATA_ERROR; + else if (status != TINFL_STATUS_DONE) + { + pState->m_last_status = TINFL_STATUS_FAILED; + return MZ_BUF_ERROR; + } + return MZ_STREAM_END; + } + // flush != MZ_FINISH then we must assume there's more input. + if (flush != MZ_FINISH) decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT; + + if (pState->m_dict_avail) + { + n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); + memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); + pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; + pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); + return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; + } + + for ( ; ; ) + { + in_bytes = pStream->avail_in; + out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs; + + status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags); + pState->m_last_status = status; + + pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; + pStream->total_in += (mz_uint)in_bytes; pStream->adler = tinfl_get_adler32(&pState->m_decomp); + + pState->m_dict_avail = (mz_uint)out_bytes; + + n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); + memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); + pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; + pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); + + if (status < 0) + return MZ_DATA_ERROR; // Stream is corrupted (there could be some uncompressed data left in the output dictionary - oh well). + else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in)) + return MZ_BUF_ERROR; // Signal caller that we can't make forward progress without supplying more input or by setting flush to MZ_FINISH. + else if (flush == MZ_FINISH) + { + // The output buffer MUST be large to hold the remaining uncompressed data when flush==MZ_FINISH. + if (status == TINFL_STATUS_DONE) + return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END; + // status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's at least 1 more byte on the way. If there's no more room left in the output buffer then something is wrong. + else if (!pStream->avail_out) + return MZ_BUF_ERROR; + } + else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail)) + break; + } + + return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; +} + +int mz_inflateEnd(mz_streamp pStream) +{ + if (!pStream) + return MZ_STREAM_ERROR; + if (pStream->state) + { + pStream->zfree(pStream->opaque, pStream->state); + pStream->state = NULL; + } + return MZ_OK; +} + +int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) +{ + mz_stream stream; + int status; + memset(&stream, 0, sizeof(stream)); + + // In case mz_ulong is 64-bits (argh I hate longs). + if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; + + stream.next_in = pSource; + stream.avail_in = (mz_uint32)source_len; + stream.next_out = pDest; + stream.avail_out = (mz_uint32)*pDest_len; + + status = mz_inflateInit(&stream); + if (status != MZ_OK) + return status; + + status = mz_inflate(&stream, MZ_FINISH); + if (status != MZ_STREAM_END) + { + mz_inflateEnd(&stream); + return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR : status; + } + *pDest_len = stream.total_out; + + return mz_inflateEnd(&stream); +} + +const char *mz_error(int err) +{ + static struct { int m_err; const char *m_pDesc; } s_error_descs[] = + { + { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, + { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" } + }; + mz_uint i; for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) if (s_error_descs[i].m_err == err) return s_error_descs[i].m_pDesc; + return NULL; +} + +#endif //MINIZ_NO_ZLIB_APIS + +// ------------------- Low-level Decompression (completely independent from all compression API's) + +#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) +#define TINFL_MEMSET(p, c, l) memset(p, c, l) + +#define TINFL_CR_BEGIN switch(r->m_state) { case 0: +#define TINFL_CR_RETURN(state_index, result) do { status = result; r->m_state = state_index; goto common_exit; case state_index:; } MZ_MACRO_END +#define TINFL_CR_RETURN_FOREVER(state_index, result) do { for ( ; ; ) { TINFL_CR_RETURN(state_index, result); } } MZ_MACRO_END +#define TINFL_CR_FINISH } + +// TODO: If the caller has indicated that there's no more input, and we attempt to read beyond the input buf, then something is wrong with the input because the inflator never +// reads ahead more than it needs to. Currently TINFL_GET_BYTE() pads the end of the stream with 0's in this scenario. +#define TINFL_GET_BYTE(state_index, c) do { \ + if (pIn_buf_cur >= pIn_buf_end) { \ + for ( ; ; ) { \ + if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) { \ + TINFL_CR_RETURN(state_index, TINFL_STATUS_NEEDS_MORE_INPUT); \ + if (pIn_buf_cur < pIn_buf_end) { \ + c = *pIn_buf_cur++; \ + break; \ + } \ + } else { \ + c = 0; \ + break; \ + } \ + } \ + } else c = *pIn_buf_cur++; } MZ_MACRO_END + +#define TINFL_NEED_BITS(state_index, n) do { mz_uint c; TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; } while (num_bits < (mz_uint)(n)) +#define TINFL_SKIP_BITS(state_index, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END +#define TINFL_GET_BITS(state_index, b, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } b = bit_buf & ((1 << (n)) - 1); bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END + +// TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes remaining in the input buffer falls below 2. +// It reads just enough bytes from the input stream that are needed to decode the next Huffman code (and absolutely no more). It works by trying to fully decode a +// Huffman code by using whatever bits are currently present in the bit buffer. If this fails, it reads another byte, and tries again until it succeeds or until the +// bit buffer contains >=15 bits (deflate's max. Huffman code size). +#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \ + do { \ + temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \ + if (temp >= 0) { \ + code_len = temp >> 9; \ + if ((code_len) && (num_bits >= code_len)) \ + break; \ + } else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \ + code_len = TINFL_FAST_LOOKUP_BITS; \ + do { \ + temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ + } while ((temp < 0) && (num_bits >= (code_len + 1))); if (temp >= 0) break; \ + } TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; \ + } while (num_bits < 15); + +// TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read +// beyond the final byte of the deflate stream. (In other words, when this macro wants to read another byte from the input, it REALLY needs another byte in order to fully +// decode the next Huffman code.) Handling this properly is particularly important on raw deflate (non-zlib) streams, which aren't followed by a byte aligned adler-32. +// The slow path is only executed at the very end of the input buffer. +#define TINFL_HUFF_DECODE(state_index, sym, pHuff) do { \ + int temp; mz_uint code_len, c; \ + if (num_bits < 15) { \ + if ((pIn_buf_end - pIn_buf_cur) < 2) { \ + TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \ + } else { \ + bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); pIn_buf_cur += 2; num_bits += 16; \ + } \ + } \ + if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \ + code_len = temp >> 9, temp &= 511; \ + else { \ + code_len = TINFL_FAST_LOOKUP_BITS; do { temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; } while (temp < 0); \ + } sym = temp; bit_buf >>= code_len; num_bits -= code_len; } MZ_MACRO_END + +tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags) +{ + static const int s_length_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; + static const int s_length_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; + static const int s_dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; + static const int s_dist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + static const mz_uint8 s_length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; + static const int s_min_table_sizes[3] = { 257, 1, 4 }; + + tinfl_status status = TINFL_STATUS_FAILED; mz_uint32 num_bits, dist, counter, num_extra; tinfl_bit_buf_t bit_buf; + const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; + mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; + size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; + + // Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). + if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) { *pIn_buf_size = *pOut_buf_size = 0; return TINFL_STATUS_BAD_PARAM; } + + num_bits = r->m_num_bits; bit_buf = r->m_bit_buf; dist = r->m_dist; counter = r->m_counter; num_extra = r->m_num_extra; dist_from_out_buf_start = r->m_dist_from_out_buf_start; + TINFL_CR_BEGIN + + bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0; r->m_z_adler32 = r->m_check_adler32 = 1; + if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) + { + TINFL_GET_BYTE(1, r->m_zhdr0); TINFL_GET_BYTE(2, r->m_zhdr1); + counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8)); + if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)(1U << (8U + (r->m_zhdr0 >> 4))))); + if (counter) { TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED); } + } + + do + { + TINFL_GET_BITS(3, r->m_final, 3); r->m_type = r->m_final >> 1; + if (r->m_type == 0) + { + TINFL_SKIP_BITS(5, num_bits & 7); + for (counter = 0; counter < 4; ++counter) { if (num_bits) TINFL_GET_BITS(6, r->m_raw_header[counter], 8); else TINFL_GET_BYTE(7, r->m_raw_header[counter]); } + if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) != (mz_uint)(0xFFFF ^ (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) { TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED); } + while ((counter) && (num_bits)) + { + TINFL_GET_BITS(51, dist, 8); + while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT); } + *pOut_buf_cur++ = (mz_uint8)dist; + counter--; + } + while (counter) + { + size_t n; while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT); } + while (pIn_buf_cur >= pIn_buf_end) + { + if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) + { + TINFL_CR_RETURN(38, TINFL_STATUS_NEEDS_MORE_INPUT); + } + else + { + TINFL_CR_RETURN_FOREVER(40, TINFL_STATUS_FAILED); + } + } + n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur), (size_t)(pIn_buf_end - pIn_buf_cur)), counter); + TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); pIn_buf_cur += n; pOut_buf_cur += n; counter -= (mz_uint)n; + } + } + else if (r->m_type == 3) + { + TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED); + } + else + { + if (r->m_type == 1) + { + mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i; + r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32); + for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8; + } + else + { + for (counter = 0; counter < 3; counter++) { TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]); r->m_table_sizes[counter] += s_min_table_sizes[counter]; } + MZ_CLEAR_OBJ(r->m_tables[2].m_code_size); for (counter = 0; counter < r->m_table_sizes[2]; counter++) { mz_uint s; TINFL_GET_BITS(14, s, 3); r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; } + r->m_table_sizes[2] = 19; + } + for ( ; (int)r->m_type >= 0; r->m_type--) + { + int tree_next, tree_cur; tinfl_huff_table *pTable; + mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; pTable = &r->m_tables[r->m_type]; MZ_CLEAR_OBJ(total_syms); MZ_CLEAR_OBJ(pTable->m_look_up); MZ_CLEAR_OBJ(pTable->m_tree); + for (i = 0; i < r->m_table_sizes[r->m_type]; ++i) total_syms[pTable->m_code_size[i]]++; + used_syms = 0, total = 0; next_code[0] = next_code[1] = 0; + for (i = 1; i <= 15; ++i) { used_syms += total_syms[i]; next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); } + if ((65536 != total) && (used_syms > 1)) + { + TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED); + } + for (tree_next = -1, sym_index = 0; sym_index < r->m_table_sizes[r->m_type]; ++sym_index) + { + mz_uint rev_code = 0, l, cur_code, code_size = pTable->m_code_size[sym_index]; if (!code_size) continue; + cur_code = next_code[code_size]++; for (l = code_size; l > 0; l--, cur_code >>= 1) rev_code = (rev_code << 1) | (cur_code & 1); + if (code_size <= TINFL_FAST_LOOKUP_BITS) { mz_int16 k = (mz_int16)((code_size << 9) | sym_index); while (rev_code < TINFL_FAST_LOOKUP_SIZE) { pTable->m_look_up[rev_code] = k; rev_code += (1 << code_size); } continue; } + if (0 == (tree_cur = pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)])) { pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } + rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1); + for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--) + { + tree_cur -= ((rev_code >>= 1) & 1); + if (!pTable->m_tree[-tree_cur - 1]) { pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } else tree_cur = pTable->m_tree[-tree_cur - 1]; + } + tree_cur -= ((rev_code >>= 1) & 1); pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index; + } + if (r->m_type == 2) + { + for (counter = 0; counter < (r->m_table_sizes[0] + r->m_table_sizes[1]); ) + { + mz_uint s; TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]); if (dist < 16) { r->m_len_codes[counter++] = (mz_uint8)dist; continue; } + if ((dist == 16) && (!counter)) + { + TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED); + } + num_extra = "\02\03\07"[dist - 16]; TINFL_GET_BITS(18, s, num_extra); s += "\03\03\013"[dist - 16]; + TINFL_MEMSET(r->m_len_codes + counter, (dist == 16) ? r->m_len_codes[counter - 1] : 0, s); counter += s; + } + if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter) + { + TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED); + } + TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes, r->m_table_sizes[0]); TINFL_MEMCPY(r->m_tables[1].m_code_size, r->m_len_codes + r->m_table_sizes[0], r->m_table_sizes[1]); + } + } + for ( ; ; ) + { + mz_uint8 *pSrc; + for ( ; ; ) + { + if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2)) + { + TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]); + if (counter >= 256) + break; + while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT); } + *pOut_buf_cur++ = (mz_uint8)counter; + } + else + { + int sym2; mz_uint code_len; +#if TINFL_USE_64BIT_BITBUF + if (num_bits < 30) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits); pIn_buf_cur += 4; num_bits += 32; } +#else + if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } +#endif + if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) + code_len = sym2 >> 9; + else + { + code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); + } + counter = sym2; bit_buf >>= code_len; num_bits -= code_len; + if (counter & 256) + break; + +#if !TINFL_USE_64BIT_BITBUF + if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } +#endif + if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) + code_len = sym2 >> 9; + else + { + code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); + } + bit_buf >>= code_len; num_bits -= code_len; + + pOut_buf_cur[0] = (mz_uint8)counter; + if (sym2 & 256) + { + pOut_buf_cur++; + counter = sym2; + break; + } + pOut_buf_cur[1] = (mz_uint8)sym2; + pOut_buf_cur += 2; + } + } + if ((counter &= 511) == 256) break; + + num_extra = s_length_extra[counter - 257]; counter = s_length_base[counter - 257]; + if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(25, extra_bits, num_extra); counter += extra_bits; } + + TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]); + num_extra = s_dist_extra[dist]; dist = s_dist_base[dist]; + if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(27, extra_bits, num_extra); dist += extra_bits; } + + dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start; + if ((dist > dist_from_out_buf_start) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) + { + TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED); + } + + pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask); + + if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end) + { + while (counter--) + { + while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT); } + *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask]; + } + continue; + } +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES + else if ((counter >= 9) && (counter <= dist)) + { + const mz_uint8 *pSrc_end = pSrc + (counter & ~7); + do + { + ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0]; + ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1]; + pOut_buf_cur += 8; + } while ((pSrc += 8) < pSrc_end); + if ((counter &= 7) < 3) + { + if (counter) + { + pOut_buf_cur[0] = pSrc[0]; + if (counter > 1) + pOut_buf_cur[1] = pSrc[1]; + pOut_buf_cur += counter; + } + continue; + } + } +#endif + do + { + pOut_buf_cur[0] = pSrc[0]; + pOut_buf_cur[1] = pSrc[1]; + pOut_buf_cur[2] = pSrc[2]; + pOut_buf_cur += 3; pSrc += 3; + } while ((int)(counter -= 3) > 2); + if ((int)counter > 0) + { + pOut_buf_cur[0] = pSrc[0]; + if ((int)counter > 1) + pOut_buf_cur[1] = pSrc[1]; + pOut_buf_cur += counter; + } + } + } + } while (!(r->m_final & 1)); + if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) + { + TINFL_SKIP_BITS(32, num_bits & 7); for (counter = 0; counter < 4; ++counter) { mz_uint s; if (num_bits) TINFL_GET_BITS(41, s, 8); else TINFL_GET_BYTE(42, s); r->m_z_adler32 = (r->m_z_adler32 << 8) | s; } + } + TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE); + TINFL_CR_FINISH + +common_exit: + r->m_num_bits = num_bits; r->m_bit_buf = bit_buf; r->m_dist = dist; r->m_counter = counter; r->m_num_extra = num_extra; r->m_dist_from_out_buf_start = dist_from_out_buf_start; + *pIn_buf_size = pIn_buf_cur - pIn_buf_next; *pOut_buf_size = pOut_buf_cur - pOut_buf_next; + if ((decomp_flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) && (status >= 0)) + { + const mz_uint8 *ptr = pOut_buf_next; size_t buf_len = *pOut_buf_size; + mz_uint32 i, s1 = r->m_check_adler32 & 0xffff, s2 = r->m_check_adler32 >> 16; size_t block_len = buf_len % 5552; + while (buf_len) + { + for (i = 0; i + 7 < block_len; i += 8, ptr += 8) + { + s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; + s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; + } + for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1; + s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; + } + r->m_check_adler32 = (s2 << 16) + s1; if ((status == TINFL_STATUS_DONE) && (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) && (r->m_check_adler32 != r->m_z_adler32)) status = TINFL_STATUS_ADLER32_MISMATCH; + } + return status; +} + +// Higher level helper functions. +void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) +{ + tinfl_decompressor decomp; void *pBuf = NULL, *pNew_buf; size_t src_buf_ofs = 0, out_buf_capacity = 0; + *pOut_len = 0; + tinfl_init(&decomp); + for ( ; ; ) + { + size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity; + tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8*)pBuf, pBuf ? (mz_uint8*)pBuf + *pOut_len : NULL, &dst_buf_size, + (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); + if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) + { + MZ_FREE(pBuf); *pOut_len = 0; return NULL; + } + src_buf_ofs += src_buf_size; + *pOut_len += dst_buf_size; + if (status == TINFL_STATUS_DONE) break; + new_out_buf_capacity = out_buf_capacity * 2; if (new_out_buf_capacity < 128) new_out_buf_capacity = 128; + pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity); + if (!pNew_buf) + { + MZ_FREE(pBuf); *pOut_len = 0; return NULL; + } + pBuf = pNew_buf; out_buf_capacity = new_out_buf_capacity; + } + return pBuf; +} + +size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) +{ + tinfl_decompressor decomp; tinfl_status status; tinfl_init(&decomp); + status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf, &src_buf_len, (mz_uint8*)pOut_buf, (mz_uint8*)pOut_buf, &out_buf_len, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); + return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED : out_buf_len; +} + +int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) +{ + int result = 0; + tinfl_decompressor decomp; + mz_uint8 *pDict = (mz_uint8*)MZ_MALLOC(TINFL_LZ_DICT_SIZE); size_t in_buf_ofs = 0, dict_ofs = 0; + if (!pDict) + return TINFL_STATUS_FAILED; + tinfl_init(&decomp); + for ( ; ; ) + { + size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs; + tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pIn_buf + in_buf_ofs, &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size, + (flags & ~(TINFL_FLAG_HAS_MORE_INPUT | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))); + in_buf_ofs += in_buf_size; + if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user))) + break; + if (status != TINFL_STATUS_HAS_MORE_OUTPUT) + { + result = (status == TINFL_STATUS_DONE); + break; + } + dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1); + } + MZ_FREE(pDict); + *pIn_buf_size = in_buf_ofs; + return result; +} + +// ------------------- Low-level Compression (independent from all decompression API's) + +// Purposely making these tables static for faster init and thread safety. +static const mz_uint16 s_tdefl_len_sym[256] = { + 257,258,259,260,261,262,263,264,265,265,266,266,267,267,268,268,269,269,269,269,270,270,270,270,271,271,271,271,272,272,272,272, + 273,273,273,273,273,273,273,273,274,274,274,274,274,274,274,274,275,275,275,275,275,275,275,275,276,276,276,276,276,276,276,276, + 277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278, + 279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280, + 281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281, + 282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282, + 283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283, + 284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,285 }; + +static const mz_uint8 s_tdefl_len_extra[256] = { + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0 }; + +static const mz_uint8 s_tdefl_small_dist_sym[512] = { + 0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11, + 11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, + 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14, + 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, + 14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, + 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16, + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17, + 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, + 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, + 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17 }; + +static const mz_uint8 s_tdefl_small_dist_extra[512] = { + 0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7 }; + +static const mz_uint8 s_tdefl_large_dist_sym[128] = { + 0,0,18,19,20,20,21,21,22,22,22,22,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26, + 26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, + 28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29 }; + +static const mz_uint8 s_tdefl_large_dist_extra[128] = { + 0,0,8,8,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, + 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, + 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13 }; + +// Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted values. +typedef struct { mz_uint16 m_key, m_sym_index; } tdefl_sym_freq; +static tdefl_sym_freq* tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq* pSyms0, tdefl_sym_freq* pSyms1) +{ + mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2]; tdefl_sym_freq* pCur_syms = pSyms0, *pNew_syms = pSyms1; MZ_CLEAR_OBJ(hist); + for (i = 0; i < num_syms; i++) { mz_uint freq = pSyms0[i].m_key; hist[freq & 0xFF]++; hist[256 + ((freq >> 8) & 0xFF)]++; } + while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) total_passes--; + for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8) + { + const mz_uint32* pHist = &hist[pass << 8]; + mz_uint offsets[256], cur_ofs = 0; + for (i = 0; i < 256; i++) { offsets[i] = cur_ofs; cur_ofs += pHist[i]; } + for (i = 0; i < num_syms; i++) pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i]; + { tdefl_sym_freq* t = pCur_syms; pCur_syms = pNew_syms; pNew_syms = t; } + } + return pCur_syms; +} + +// tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat, alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996. +static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n) +{ + int root, leaf, next, avbl, used, dpth; + if (n==0) return; else if (n==1) { A[0].m_key = 1; return; } + A[0].m_key += A[1].m_key; root = 0; leaf = 2; + for (next=1; next < n-1; next++) + { + if (leaf>=n || A[root].m_key=n || (root=0; next--) A[next].m_key = A[A[next].m_key].m_key+1; + avbl = 1; used = dpth = 0; root = n-2; next = n-1; + while (avbl>0) + { + while (root>=0 && (int)A[root].m_key==dpth) { used++; root--; } + while (avbl>used) { A[next--].m_key = (mz_uint16)(dpth); avbl--; } + avbl = 2*used; dpth++; used = 0; + } +} + +// Limits canonical Huffman code table's max code size. +enum { TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32 }; +static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size) +{ + int i; mz_uint32 total = 0; if (code_list_len <= 1) return; + for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++) pNum_codes[max_code_size] += pNum_codes[i]; + for (i = max_code_size; i > 0; i--) total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i)); + while (total != (1UL << max_code_size)) + { + pNum_codes[max_code_size]--; + for (i = max_code_size - 1; i > 0; i--) if (pNum_codes[i]) { pNum_codes[i]--; pNum_codes[i + 1] += 2; break; } + total--; + } +} + +static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table) +{ + int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE]; mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1]; MZ_CLEAR_OBJ(num_codes); + if (static_table) + { + for (i = 0; i < table_len; i++) num_codes[d->m_huff_code_sizes[table_num][i]]++; + } + else + { + tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], *pSyms; + int num_used_syms = 0; + const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0]; + for (i = 0; i < table_len; i++) if (pSym_count[i]) { syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i]; syms0[num_used_syms++].m_sym_index = (mz_uint16)i; } + + pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1); tdefl_calculate_minimum_redundancy(pSyms, num_used_syms); + + for (i = 0; i < num_used_syms; i++) num_codes[pSyms[i].m_key]++; + + tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit); + + MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]); MZ_CLEAR_OBJ(d->m_huff_codes[table_num]); + for (i = 1, j = num_used_syms; i <= code_size_limit; i++) + for (l = num_codes[i]; l > 0; l--) d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i); + } + + next_code[1] = 0; for (j = 0, i = 2; i <= code_size_limit; i++) next_code[i] = j = ((j + num_codes[i - 1]) << 1); + + for (i = 0; i < table_len; i++) + { + mz_uint rev_code = 0, code, code_size; if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0) continue; + code = next_code[code_size]++; for (l = code_size; l > 0; l--, code >>= 1) rev_code = (rev_code << 1) | (code & 1); + d->m_huff_codes[table_num][i] = (mz_uint16)rev_code; + } +} + +#define TDEFL_PUT_BITS(b, l) do { \ + mz_uint bits = b; mz_uint len = l; MZ_ASSERT(bits <= ((1U << len) - 1U)); \ + d->m_bit_buffer |= (bits << d->m_bits_in); d->m_bits_in += len; \ + while (d->m_bits_in >= 8) { \ + if (d->m_pOutput_buf < d->m_pOutput_buf_end) \ + *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \ + d->m_bit_buffer >>= 8; \ + d->m_bits_in -= 8; \ + } \ +} MZ_MACRO_END + +#define TDEFL_RLE_PREV_CODE_SIZE() { if (rle_repeat_count) { \ + if (rle_repeat_count < 3) { \ + d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \ + while (rle_repeat_count--) packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \ + } else { \ + d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); packed_code_sizes[num_packed_code_sizes++] = 16; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3); \ +} rle_repeat_count = 0; } } + +#define TDEFL_RLE_ZERO_CODE_SIZE() { if (rle_z_count) { \ + if (rle_z_count < 3) { \ + d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); while (rle_z_count--) packed_code_sizes[num_packed_code_sizes++] = 0; \ + } else if (rle_z_count <= 10) { \ + d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); packed_code_sizes[num_packed_code_sizes++] = 17; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3); \ + } else { \ + d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); packed_code_sizes[num_packed_code_sizes++] = 18; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \ +} rle_z_count = 0; } } + +static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; + +static void tdefl_start_dynamic_block(tdefl_compressor *d) +{ + int num_lit_codes, num_dist_codes, num_bit_lengths; mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index; + mz_uint8 code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], prev_code_size = 0xFF; + + d->m_huff_count[0][256] = 1; + + tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE); + tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE); + + for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--) if (d->m_huff_code_sizes[0][num_lit_codes - 1]) break; + for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--) if (d->m_huff_code_sizes[1][num_dist_codes - 1]) break; + + memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes); + memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], num_dist_codes); + total_code_sizes_to_pack = num_lit_codes + num_dist_codes; num_packed_code_sizes = 0; rle_z_count = 0; rle_repeat_count = 0; + + memset(&d->m_huff_count[2][0], 0, sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2); + for (i = 0; i < total_code_sizes_to_pack; i++) + { + mz_uint8 code_size = code_sizes_to_pack[i]; + if (!code_size) + { + TDEFL_RLE_PREV_CODE_SIZE(); + if (++rle_z_count == 138) { TDEFL_RLE_ZERO_CODE_SIZE(); } + } + else + { + TDEFL_RLE_ZERO_CODE_SIZE(); + if (code_size != prev_code_size) + { + TDEFL_RLE_PREV_CODE_SIZE(); + d->m_huff_count[2][code_size] = (mz_uint16)(d->m_huff_count[2][code_size] + 1); packed_code_sizes[num_packed_code_sizes++] = code_size; + } + else if (++rle_repeat_count == 6) + { + TDEFL_RLE_PREV_CODE_SIZE(); + } + } + prev_code_size = code_size; + } + if (rle_repeat_count) { TDEFL_RLE_PREV_CODE_SIZE(); } else { TDEFL_RLE_ZERO_CODE_SIZE(); } + + tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE); + + TDEFL_PUT_BITS(2, 2); + + TDEFL_PUT_BITS(num_lit_codes - 257, 5); + TDEFL_PUT_BITS(num_dist_codes - 1, 5); + + for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--) if (d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]]) break; + num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1)); TDEFL_PUT_BITS(num_bit_lengths - 4, 4); + for (i = 0; (int)i < num_bit_lengths; i++) TDEFL_PUT_BITS(d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3); + + for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes; ) + { + mz_uint code = packed_code_sizes[packed_code_sizes_index++]; MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2); + TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]); + if (code >= 16) TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++], "\02\03\07"[code - 16]); + } +} + +static void tdefl_start_static_block(tdefl_compressor *d) +{ + mz_uint i; + mz_uint8 *p = &d->m_huff_code_sizes[0][0]; + + for (i = 0; i <= 143; ++i) *p++ = 8; + for ( ; i <= 255; ++i) *p++ = 9; + for ( ; i <= 279; ++i) *p++ = 7; + for ( ; i <= 287; ++i) *p++ = 8; + + memset(d->m_huff_code_sizes[1], 5, 32); + + tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE); + tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE); + + TDEFL_PUT_BITS(1, 2); +} + +static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS +static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) +{ + mz_uint flags; + mz_uint8 *pLZ_codes; + mz_uint8 *pOutput_buf = d->m_pOutput_buf; + mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf; + mz_uint64 bit_buffer = d->m_bit_buffer; + mz_uint bits_in = d->m_bits_in; + +#define TDEFL_PUT_BITS_FAST(b, l) { bit_buffer |= (((mz_uint64)(b)) << bits_in); bits_in += (l); } + + flags = 1; + for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1) + { + if (flags == 1) + flags = *pLZ_codes++ | 0x100; + + if (flags & 1) + { + mz_uint s0, s1, n0, n1, sym, num_extra_bits; + mz_uint match_len = pLZ_codes[0], match_dist = *(const mz_uint16 *)(pLZ_codes + 1); pLZ_codes += 3; + + MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); + TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); + + // This sequence coaxes MSVC into using cmov's vs. jmp's. + s0 = s_tdefl_small_dist_sym[match_dist & 511]; + n0 = s_tdefl_small_dist_extra[match_dist & 511]; + s1 = s_tdefl_large_dist_sym[match_dist >> 8]; + n1 = s_tdefl_large_dist_extra[match_dist >> 8]; + sym = (match_dist < 512) ? s0 : s1; + num_extra_bits = (match_dist < 512) ? n0 : n1; + + MZ_ASSERT(d->m_huff_code_sizes[1][sym]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); + TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); + } + else + { + mz_uint lit = *pLZ_codes++; + MZ_ASSERT(d->m_huff_code_sizes[0][lit]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); + + if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) + { + flags >>= 1; + lit = *pLZ_codes++; + MZ_ASSERT(d->m_huff_code_sizes[0][lit]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); + + if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) + { + flags >>= 1; + lit = *pLZ_codes++; + MZ_ASSERT(d->m_huff_code_sizes[0][lit]); + TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); + } + } + } + + if (pOutput_buf >= d->m_pOutput_buf_end) + return MZ_FALSE; + + *(mz_uint64*)pOutput_buf = bit_buffer; + pOutput_buf += (bits_in >> 3); + bit_buffer >>= (bits_in & ~7); + bits_in &= 7; + } + +#undef TDEFL_PUT_BITS_FAST + + d->m_pOutput_buf = pOutput_buf; + d->m_bits_in = 0; + d->m_bit_buffer = 0; + + while (bits_in) + { + mz_uint32 n = MZ_MIN(bits_in, 16); + TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n); + bit_buffer >>= n; + bits_in -= n; + } + + TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); + + return (d->m_pOutput_buf < d->m_pOutput_buf_end); +} +#else +static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) +{ + mz_uint flags; + mz_uint8 *pLZ_codes; + + flags = 1; + for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1) + { + if (flags == 1) + flags = *pLZ_codes++ | 0x100; + if (flags & 1) + { + mz_uint sym, num_extra_bits; + mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3; + + MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); + TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); + TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); + + if (match_dist < 512) + { + sym = s_tdefl_small_dist_sym[match_dist]; num_extra_bits = s_tdefl_small_dist_extra[match_dist]; + } + else + { + sym = s_tdefl_large_dist_sym[match_dist >> 8]; num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8]; + } + MZ_ASSERT(d->m_huff_code_sizes[1][sym]); + TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); + TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); + } + else + { + mz_uint lit = *pLZ_codes++; + MZ_ASSERT(d->m_huff_code_sizes[0][lit]); + TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); + } + } + + TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); + + return (d->m_pOutput_buf < d->m_pOutput_buf_end); +} +#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS + +static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) +{ + if (static_block) + tdefl_start_static_block(d); + else + tdefl_start_dynamic_block(d); + return tdefl_compress_lz_codes(d); +} + +static int tdefl_flush_block(tdefl_compressor *d, int flush) +{ + mz_uint saved_bit_buf, saved_bits_in; + mz_uint8 *pSaved_output_buf; + mz_bool comp_block_succeeded = MZ_FALSE; + int n, use_raw_block = ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size; + mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) : d->m_output_buf; + + d->m_pOutput_buf = pOutput_buf_start; + d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16; + + MZ_ASSERT(!d->m_output_flush_remaining); + d->m_output_flush_ofs = 0; + d->m_output_flush_remaining = 0; + + *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left); + d->m_pLZ_code_buf -= (d->m_num_flags_left == 8); + + if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index)) + { + TDEFL_PUT_BITS(0x78, 8); TDEFL_PUT_BITS(0x01, 8); + } + + TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1); + + pSaved_output_buf = d->m_pOutput_buf; saved_bit_buf = d->m_bit_buffer; saved_bits_in = d->m_bits_in; + + if (!use_raw_block) + comp_block_succeeded = tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || (d->m_total_lz_bytes < 48)); + + // If the block gets expanded, forget the current contents of the output buffer and send a raw block instead. + if ( ((use_raw_block) || ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= d->m_total_lz_bytes))) && + ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size) ) + { + mz_uint i; d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; + TDEFL_PUT_BITS(0, 2); + if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } + for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF) + { + TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16); + } + for (i = 0; i < d->m_total_lz_bytes; ++i) + { + TDEFL_PUT_BITS(d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], 8); + } + } + // Check for the extremely unlikely (if not impossible) case of the compressed block not fitting into the output buffer when using dynamic codes. + else if (!comp_block_succeeded) + { + d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; + tdefl_compress_block(d, MZ_TRUE); + } + + if (flush) + { + if (flush == TDEFL_FINISH) + { + if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } + if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) { mz_uint i, a = d->m_adler32; for (i = 0; i < 4; i++) { TDEFL_PUT_BITS((a >> 24) & 0xFF, 8); a <<= 8; } } + } + else + { + mz_uint i, z = 0; TDEFL_PUT_BITS(0, 3); if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } for (i = 2; i; --i, z ^= 0xFFFF) { TDEFL_PUT_BITS(z & 0xFFFF, 16); } + } + } + + MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end); + + memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); + memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); + + d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes; d->m_total_lz_bytes = 0; d->m_block_index++; + + if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0) + { + if (d->m_pPut_buf_func) + { + *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; + if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user)) + return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED); + } + else if (pOutput_buf_start == d->m_output_buf) + { + int bytes_to_copy = (int)MZ_MIN((size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs)); + memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy); + d->m_out_buf_ofs += bytes_to_copy; + if ((n -= bytes_to_copy) != 0) + { + d->m_output_flush_ofs = bytes_to_copy; + d->m_output_flush_remaining = n; + } + } + else + { + d->m_out_buf_ofs += n; + } + } + + return d->m_output_flush_remaining; +} + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES +#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16*)(p) +static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) +{ + mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; + mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; + const mz_uint16 *s = (const mz_uint16*)(d->m_dict + pos), *p, *q; + mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s); + MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; + for ( ; ; ) + { + for ( ; ; ) + { + if (--num_probes_left == 0) return; + #define TDEFL_PROBE \ + next_probe_pos = d->m_next[probe_pos]; \ + if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ + probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ + if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break; + TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; + } + if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32; + do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && + (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); + if (!probe_len) + { + *pMatch_dist = dist; *pMatch_len = MZ_MIN(max_match_len, TDEFL_MAX_MATCH_LEN); break; + } + else if ((probe_len = ((mz_uint)(p - s) * 2) + (mz_uint)(*(const mz_uint8*)p == *(const mz_uint8*)q)) > match_len) + { + *pMatch_dist = dist; if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) == max_match_len) break; + c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]); + } + } +} +#else +static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) +{ + mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; + mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; + const mz_uint8 *s = d->m_dict + pos, *p, *q; + mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1]; + MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; + for ( ; ; ) + { + for ( ; ; ) + { + if (--num_probes_left == 0) return; + #define TDEFL_PROBE \ + next_probe_pos = d->m_next[probe_pos]; \ + if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ + probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ + if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) break; + TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; + } + if (!dist) break; p = s; q = d->m_dict + probe_pos; for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break; + if (probe_len > match_len) + { + *pMatch_dist = dist; if ((*pMatch_len = match_len = probe_len) == max_match_len) return; + c0 = d->m_dict[pos + match_len]; c1 = d->m_dict[pos + match_len - 1]; + } + } +} +#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN +static mz_bool tdefl_compress_fast(tdefl_compressor *d) +{ + // Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. + mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left; + mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags; + mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; + + while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) + { + const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096; + mz_uint dst_pos = (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; + mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size); + d->m_src_buf_left -= num_bytes_to_process; + lookahead_size += num_bytes_to_process; + + while (num_bytes_to_process) + { + mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process); + memcpy(d->m_dict + dst_pos, d->m_pSrc, n); + if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) + memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos)); + d->m_pSrc += n; + dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK; + num_bytes_to_process -= n; + } + + dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size); + if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) break; + + while (lookahead_size >= 4) + { + mz_uint cur_match_dist, cur_match_len = 1; + mz_uint8 *pCur_dict = d->m_dict + cur_pos; + mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF; + mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK; + mz_uint probe_pos = d->m_hash[hash]; + d->m_hash[hash] = (mz_uint16)lookahead_pos; + + if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((*(const mz_uint32 *)(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram)) + { + const mz_uint16 *p = (const mz_uint16 *)pCur_dict; + const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos); + mz_uint32 probe_len = 32; + do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && + (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); + cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q); + if (!probe_len) + cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0; + + if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || ((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U))) + { + cur_match_len = 1; + *pLZ_code_buf++ = (mz_uint8)first_trigram; + *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); + d->m_huff_count[0][(mz_uint8)first_trigram]++; + } + else + { + mz_uint32 s0, s1; + cur_match_len = MZ_MIN(cur_match_len, lookahead_size); + + MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 1) && (cur_match_dist <= TDEFL_LZ_DICT_SIZE)); + + cur_match_dist--; + + pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN); + *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist; + pLZ_code_buf += 3; + *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80); + + s0 = s_tdefl_small_dist_sym[cur_match_dist & 511]; + s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8]; + d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++; + + d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - TDEFL_MIN_MATCH_LEN]]++; + } + } + else + { + *pLZ_code_buf++ = (mz_uint8)first_trigram; + *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); + d->m_huff_count[0][(mz_uint8)first_trigram]++; + } + + if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } + + total_lz_bytes += cur_match_len; + lookahead_pos += cur_match_len; + dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE); + cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK; + MZ_ASSERT(lookahead_size >= cur_match_len); + lookahead_size -= cur_match_len; + + if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) + { + int n; + d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; + d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; + if ((n = tdefl_flush_block(d, 0)) != 0) + return (n < 0) ? MZ_FALSE : MZ_TRUE; + total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; + } + } + + while (lookahead_size) + { + mz_uint8 lit = d->m_dict[cur_pos]; + + total_lz_bytes++; + *pLZ_code_buf++ = lit; + *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); + if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } + + d->m_huff_count[0][lit]++; + + lookahead_pos++; + dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE); + cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; + lookahead_size--; + + if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) + { + int n; + d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; + d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; + if ((n = tdefl_flush_block(d, 0)) != 0) + return (n < 0) ? MZ_FALSE : MZ_TRUE; + total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; + } + } + } + + d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; + d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; + return MZ_TRUE; +} +#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN + +static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit) +{ + d->m_total_lz_bytes++; + *d->m_pLZ_code_buf++ = lit; + *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } + d->m_huff_count[0][lit]++; +} + +static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist) +{ + mz_uint32 s0, s1; + + MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) && (match_dist <= TDEFL_LZ_DICT_SIZE)); + + d->m_total_lz_bytes += match_len; + + d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN); + + match_dist -= 1; + d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF); + d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8); d->m_pLZ_code_buf += 3; + + *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } + + s0 = s_tdefl_small_dist_sym[match_dist & 511]; s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; + d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; + + if (match_len >= TDEFL_MIN_MATCH_LEN) d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; +} + +static mz_bool tdefl_compress_normal(tdefl_compressor *d) +{ + const mz_uint8 *pSrc = d->m_pSrc; size_t src_buf_left = d->m_src_buf_left; + tdefl_flush flush = d->m_flush; + + while ((src_buf_left) || ((flush) && (d->m_lookahead_size))) + { + mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos; + // Update dictionary and hash chains. Keeps the lookahead size equal to TDEFL_MAX_MATCH_LEN. + if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1)) + { + mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK, ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2; + mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK]; + mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size); + const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process; + src_buf_left -= num_bytes_to_process; + d->m_lookahead_size += num_bytes_to_process; + while (pSrc != pSrc_end) + { + mz_uint8 c = *pSrc++; d->m_dict[dst_pos] = c; if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; + hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); + d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); + dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; ins_pos++; + } + } + else + { + while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) + { + mz_uint8 c = *pSrc++; + mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; + src_buf_left--; + d->m_dict[dst_pos] = c; + if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) + d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; + if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN) + { + mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2; + mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << (TDEFL_LZ_HASH_SHIFT * 2)) ^ (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); + d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); + } + } + } + d->m_dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size); + if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) + break; + + // Simple lazy/greedy parsing state machine. + len_to_move = 1; cur_match_dist = 0; cur_match_len = d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1); cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; + if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS)) + { + if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) + { + mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK]; + cur_match_len = 0; while (cur_match_len < d->m_lookahead_size) { if (d->m_dict[cur_pos + cur_match_len] != c) break; cur_match_len++; } + if (cur_match_len < TDEFL_MIN_MATCH_LEN) cur_match_len = 0; else cur_match_dist = 1; + } + } + else + { + tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size, d->m_lookahead_size, &cur_match_dist, &cur_match_len); + } + if (((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U)) || (cur_pos == cur_match_dist) || ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5))) + { + cur_match_dist = cur_match_len = 0; + } + if (d->m_saved_match_len) + { + if (cur_match_len > d->m_saved_match_len) + { + tdefl_record_literal(d, (mz_uint8)d->m_saved_lit); + if (cur_match_len >= 128) + { + tdefl_record_match(d, cur_match_len, cur_match_dist); + d->m_saved_match_len = 0; len_to_move = cur_match_len; + } + else + { + d->m_saved_lit = d->m_dict[cur_pos]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; + } + } + else + { + tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist); + len_to_move = d->m_saved_match_len - 1; d->m_saved_match_len = 0; + } + } + else if (!cur_match_dist) + tdefl_record_literal(d, d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]); + else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || (cur_match_len >= 128)) + { + tdefl_record_match(d, cur_match_len, cur_match_dist); + len_to_move = cur_match_len; + } + else + { + d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; + } + // Move the lookahead forward by len_to_move bytes. + d->m_lookahead_pos += len_to_move; + MZ_ASSERT(d->m_lookahead_size >= len_to_move); + d->m_lookahead_size -= len_to_move; + d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, TDEFL_LZ_DICT_SIZE); + // Check if it's time to flush the current LZ codes to the internal output buffer. + if ( (d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) || + ( (d->m_total_lz_bytes > 31*1024) && (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= d->m_total_lz_bytes) || (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) ) + { + int n; + d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; + if ((n = tdefl_flush_block(d, 0)) != 0) + return (n < 0) ? MZ_FALSE : MZ_TRUE; + } + } + + d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; + return MZ_TRUE; +} + +static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d) +{ + if (d->m_pIn_buf_size) + { + *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; + } + + if (d->m_pOut_buf_size) + { + size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs, d->m_output_flush_remaining); + memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf + d->m_output_flush_ofs, n); + d->m_output_flush_ofs += (mz_uint)n; + d->m_output_flush_remaining -= (mz_uint)n; + d->m_out_buf_ofs += n; + + *d->m_pOut_buf_size = d->m_out_buf_ofs; + } + + return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE : TDEFL_STATUS_OKAY; +} + +tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush) +{ + if (!d) + { + if (pIn_buf_size) *pIn_buf_size = 0; + if (pOut_buf_size) *pOut_buf_size = 0; + return TDEFL_STATUS_BAD_PARAM; + } + + d->m_pIn_buf = pIn_buf; d->m_pIn_buf_size = pIn_buf_size; + d->m_pOut_buf = pOut_buf; d->m_pOut_buf_size = pOut_buf_size; + d->m_pSrc = (const mz_uint8 *)(pIn_buf); d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0; + d->m_out_buf_ofs = 0; + d->m_flush = flush; + + if ( ((d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (d->m_prev_return_status != TDEFL_STATUS_OKAY) || + (d->m_wants_to_finish && (flush != TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf) ) + { + if (pIn_buf_size) *pIn_buf_size = 0; + if (pOut_buf_size) *pOut_buf_size = 0; + return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM); + } + d->m_wants_to_finish |= (flush == TDEFL_FINISH); + + if ((d->m_output_flush_remaining) || (d->m_finished)) + return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); + +#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN + if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && + ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && + ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0)) + { + if (!tdefl_compress_fast(d)) + return d->m_prev_return_status; + } + else +#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN + { + if (!tdefl_compress_normal(d)) + return d->m_prev_return_status; + } + + if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && (pIn_buf)) + d->m_adler32 = (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, d->m_pSrc - (const mz_uint8 *)pIn_buf); + + if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && (!d->m_output_flush_remaining)) + { + if (tdefl_flush_block(d, flush) < 0) + return d->m_prev_return_status; + d->m_finished = (flush == TDEFL_FINISH); + if (flush == TDEFL_FULL_FLUSH) { MZ_CLEAR_OBJ(d->m_hash); MZ_CLEAR_OBJ(d->m_next); d->m_dict_size = 0; } + } + + return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); +} + +tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush) +{ + MZ_ASSERT(d->m_pPut_buf_func); return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush); +} + +tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) +{ + d->m_pPut_buf_func = pPut_buf_func; d->m_pPut_buf_user = pPut_buf_user; + d->m_flags = (mz_uint)(flags); d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3; d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0; + d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3; + if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG)) MZ_CLEAR_OBJ(d->m_hash); + d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0; + d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0; + d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; + d->m_pOutput_buf = d->m_output_buf; d->m_pOutput_buf_end = d->m_output_buf; d->m_prev_return_status = TDEFL_STATUS_OKAY; + d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0; d->m_adler32 = 1; + d->m_pIn_buf = NULL; d->m_pOut_buf = NULL; + d->m_pIn_buf_size = NULL; d->m_pOut_buf_size = NULL; + d->m_flush = TDEFL_NO_FLUSH; d->m_pSrc = NULL; d->m_src_buf_left = 0; d->m_out_buf_ofs = 0; + memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); + memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); + return TDEFL_STATUS_OKAY; +} + +tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) +{ + return d->m_prev_return_status; +} + +mz_uint32 tdefl_get_adler32(tdefl_compressor *d) +{ + return d->m_adler32; +} + +mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) +{ + tdefl_compressor *pComp; mz_bool succeeded; if (((buf_len) && (!pBuf)) || (!pPut_buf_func)) return MZ_FALSE; + pComp = (tdefl_compressor*)MZ_MALLOC(sizeof(tdefl_compressor)); if (!pComp) return MZ_FALSE; + succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) == TDEFL_STATUS_OKAY); + succeeded = succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) == TDEFL_STATUS_DONE); + MZ_FREE(pComp); return succeeded; +} + +typedef struct +{ + size_t m_size, m_capacity; + mz_uint8 *m_pBuf; + mz_bool m_expandable; +} tdefl_output_buffer; + +static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser) +{ + tdefl_output_buffer *p = (tdefl_output_buffer *)pUser; + size_t new_size = p->m_size + len; + if (new_size > p->m_capacity) + { + size_t new_capacity = p->m_capacity; mz_uint8 *pNew_buf; if (!p->m_expandable) return MZ_FALSE; + do { new_capacity = MZ_MAX(128U, new_capacity << 1U); } while (new_size > new_capacity); + pNew_buf = (mz_uint8*)MZ_REALLOC(p->m_pBuf, new_capacity); if (!pNew_buf) return MZ_FALSE; + p->m_pBuf = pNew_buf; p->m_capacity = new_capacity; + } + memcpy((mz_uint8*)p->m_pBuf + p->m_size, pBuf, len); p->m_size = new_size; + return MZ_TRUE; +} + +void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) +{ + tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); + if (!pOut_len) return MZ_FALSE; else *pOut_len = 0; + out_buf.m_expandable = MZ_TRUE; + if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return NULL; + *pOut_len = out_buf.m_size; return out_buf.m_pBuf; +} + +size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) +{ + tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); + if (!pOut_buf) return 0; + out_buf.m_pBuf = (mz_uint8*)pOut_buf; out_buf.m_capacity = out_buf_len; + if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return 0; + return out_buf.m_size; +} + +#ifndef MINIZ_NO_ZLIB_APIS +static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; + +// level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files). +mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy) +{ + mz_uint comp_flags = s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0); + if (window_bits > 0) comp_flags |= TDEFL_WRITE_ZLIB_HEADER; + + if (!level) comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS; + else if (strategy == MZ_FILTERED) comp_flags |= TDEFL_FILTER_MATCHES; + else if (strategy == MZ_HUFFMAN_ONLY) comp_flags &= ~TDEFL_MAX_PROBES_MASK; + else if (strategy == MZ_FIXED) comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS; + else if (strategy == MZ_RLE) comp_flags |= TDEFL_RLE_MATCHES; + + return comp_flags; +} +#endif //MINIZ_NO_ZLIB_APIS + +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable:4204) // nonstandard extension used : non-constant aggregate initializer (also supported by GNU C and C99, so no big deal) +#endif + +// Simple PNG writer function by Alex Evans, 2011. Released into the public domain: https://gist.github.com/908299, more context at +// http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. +// This is actually a modification of Alex's original code so PNG files generated by this function pass pngcheck. +void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip) +{ + // Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was defined. + static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; + tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); tdefl_output_buffer out_buf; int i, bpl = w * num_chans, y, z; mz_uint32 c; *pLen_out = 0; + if (!pComp) return NULL; + MZ_CLEAR_OBJ(out_buf); out_buf.m_expandable = MZ_TRUE; out_buf.m_capacity = 57+MZ_MAX(64, (1+bpl)*h); if (NULL == (out_buf.m_pBuf = (mz_uint8*)MZ_MALLOC(out_buf.m_capacity))) { MZ_FREE(pComp); return NULL; } + // write dummy header + for (z = 41; z; --z) tdefl_output_buffer_putter(&z, 1, &out_buf); + // compress image data + tdefl_init(pComp, tdefl_output_buffer_putter, &out_buf, s_tdefl_png_num_probes[MZ_MIN(10, level)] | TDEFL_WRITE_ZLIB_HEADER); + for (y = 0; y < h; ++y) { tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH); tdefl_compress_buffer(pComp, (mz_uint8*)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH); } + if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE) { MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } + // write real header + *pLen_out = out_buf.m_size-41; + { + static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06}; + mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, + 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,chans[num_chans],0,0,0,0,0,0,0, + (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; + c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24); + memcpy(out_buf.m_pBuf, pnghdr, 41); + } + // write footer (IDAT CRC-32, followed by IEND chunk) + if (!tdefl_output_buffer_putter("\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf)) { *pLen_out = 0; MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } + c = (mz_uint32)mz_crc32(MZ_CRC32_INIT,out_buf.m_pBuf+41-4, *pLen_out+4); for (i=0; i<4; ++i, c<<=8) (out_buf.m_pBuf+out_buf.m_size-16)[i] = (mz_uint8)(c >> 24); + // compute final size of file, grab compressed data buffer and return + *pLen_out += 57; MZ_FREE(pComp); return out_buf.m_pBuf; +} +void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out) +{ + // Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's where #defined out) + return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE); +} + +#ifdef _MSC_VER +#pragma warning (pop) +#endif + +// ------------------- .ZIP archive reading + +#ifndef MINIZ_NO_ARCHIVE_APIS + +#ifdef MINIZ_NO_STDIO + #define MZ_FILE void * +#else + #include + #include + + #if defined(_MSC_VER) || defined(__MINGW64__) + static FILE *mz_fopen(const char *pFilename, const char *pMode) + { + FILE* pFile = NULL; + fopen_s(&pFile, pFilename, pMode); + return pFile; + } + static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream) + { + FILE* pFile = NULL; + if (freopen_s(&pFile, pPath, pMode, pStream)) + return NULL; + return pFile; + } + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN mz_fopen + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 _ftelli64 + #define MZ_FSEEK64 _fseeki64 + #define MZ_FILE_STAT_STRUCT _stat + #define MZ_FILE_STAT _stat + #define MZ_FFLUSH fflush + #define MZ_FREOPEN mz_freopen + #define MZ_DELETE_FILE remove + #elif defined(__MINGW32__) + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN(f, m) fopen(f, m) + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 ftello64 + #define MZ_FSEEK64 fseeko64 + #define MZ_FILE_STAT_STRUCT _stat + #define MZ_FILE_STAT _stat + #define MZ_FFLUSH fflush + #define MZ_FREOPEN(f, m, s) freopen(f, m, s) + #define MZ_DELETE_FILE remove + #elif defined(__TINYC__) + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN(f, m) fopen(f, m) + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 ftell + #define MZ_FSEEK64 fseek + #define MZ_FILE_STAT_STRUCT stat + #define MZ_FILE_STAT stat + #define MZ_FFLUSH fflush + #define MZ_FREOPEN(f, m, s) freopen(f, m, s) + #define MZ_DELETE_FILE remove + #elif defined(__GNUC__) && _LARGEFILE64_SOURCE + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN(f, m) fopen64(f, m) + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 ftello64 + #define MZ_FSEEK64 fseeko64 + #define MZ_FILE_STAT_STRUCT stat64 + #define MZ_FILE_STAT stat64 + #define MZ_FFLUSH fflush + #define MZ_FREOPEN(p, m, s) freopen64(p, m, s) + #define MZ_DELETE_FILE remove + #else + #ifndef MINIZ_NO_TIME + #include + #endif + #define MZ_FILE FILE + #define MZ_FOPEN(f, m) fopen(f, m) + #define MZ_FCLOSE fclose + #define MZ_FREAD fread + #define MZ_FWRITE fwrite + #define MZ_FTELL64 ftello + #define MZ_FSEEK64 fseeko + #define MZ_FILE_STAT_STRUCT stat + #define MZ_FILE_STAT stat + #define MZ_FFLUSH fflush + #define MZ_FREOPEN(f, m, s) freopen(f, m, s) + #define MZ_DELETE_FILE remove + #endif // #ifdef _MSC_VER +#endif // #ifdef MINIZ_NO_STDIO + +#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c)) + +// Various ZIP archive enums. To completely avoid cross platform compiler alignment and platform endian issues, miniz.c doesn't use structs for any of this stuff. +enum +{ + // ZIP archive identifiers and record sizes + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50, MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50, MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50, + MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22, + // Central directory header record offsets + MZ_ZIP_CDH_SIG_OFS = 0, MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4, MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6, MZ_ZIP_CDH_BIT_FLAG_OFS = 8, + MZ_ZIP_CDH_METHOD_OFS = 10, MZ_ZIP_CDH_FILE_TIME_OFS = 12, MZ_ZIP_CDH_FILE_DATE_OFS = 14, MZ_ZIP_CDH_CRC32_OFS = 16, + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20, MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24, MZ_ZIP_CDH_FILENAME_LEN_OFS = 28, MZ_ZIP_CDH_EXTRA_LEN_OFS = 30, + MZ_ZIP_CDH_COMMENT_LEN_OFS = 32, MZ_ZIP_CDH_DISK_START_OFS = 34, MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36, MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38, MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42, + // Local directory header offsets + MZ_ZIP_LDH_SIG_OFS = 0, MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4, MZ_ZIP_LDH_BIT_FLAG_OFS = 6, MZ_ZIP_LDH_METHOD_OFS = 8, MZ_ZIP_LDH_FILE_TIME_OFS = 10, + MZ_ZIP_LDH_FILE_DATE_OFS = 12, MZ_ZIP_LDH_CRC32_OFS = 14, MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18, MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22, + MZ_ZIP_LDH_FILENAME_LEN_OFS = 26, MZ_ZIP_LDH_EXTRA_LEN_OFS = 28, + // End of central directory offsets + MZ_ZIP_ECDH_SIG_OFS = 0, MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4, MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6, MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8, + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10, MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12, MZ_ZIP_ECDH_CDIR_OFS_OFS = 16, MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20, +}; + +typedef struct +{ + void *m_p; + size_t m_size, m_capacity; + mz_uint m_element_size; +} mz_zip_array; + +struct mz_zip_internal_state_tag +{ + mz_zip_array m_central_dir; + mz_zip_array m_central_dir_offsets; + mz_zip_array m_sorted_central_dir_offsets; + MZ_FILE *m_pFile; + void *m_pMem; + size_t m_mem_size; + size_t m_mem_capacity; +}; + +#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size +#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index] + +static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray) +{ + pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p); + memset(pArray, 0, sizeof(mz_zip_array)); +} + +static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing) +{ + void *pNew_p; size_t new_capacity = min_new_capacity; MZ_ASSERT(pArray->m_element_size); if (pArray->m_capacity >= min_new_capacity) return MZ_TRUE; + if (growing) { new_capacity = MZ_MAX(1, pArray->m_capacity); while (new_capacity < min_new_capacity) new_capacity *= 2; } + if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p, pArray->m_element_size, new_capacity))) return MZ_FALSE; + pArray->m_p = pNew_p; pArray->m_capacity = new_capacity; + return MZ_TRUE; +} + +static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing) +{ + if (new_capacity > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing)) return MZ_FALSE; } + return MZ_TRUE; +} + +static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing) +{ + if (new_size > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing)) return MZ_FALSE; } + pArray->m_size = new_size; + return MZ_TRUE; +} + +static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n) +{ + return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE); +} + +static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n) +{ + size_t orig_size = pArray->m_size; if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE)) return MZ_FALSE; + memcpy((mz_uint8*)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size); + return MZ_TRUE; +} + +#ifndef MINIZ_NO_TIME +static time_t mz_zip_dos_to_time_t(int dos_time, int dos_date) +{ + struct tm tm; + memset(&tm, 0, sizeof(tm)); tm.tm_isdst = -1; + tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; tm.tm_mon = ((dos_date >> 5) & 15) - 1; tm.tm_mday = dos_date & 31; + tm.tm_hour = (dos_time >> 11) & 31; tm.tm_min = (dos_time >> 5) & 63; tm.tm_sec = (dos_time << 1) & 62; + return mktime(&tm); +} + +static void mz_zip_time_to_dos_time(time_t time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) +{ +#ifdef _MSC_VER + struct tm tm_struct; + struct tm *tm = &tm_struct; + errno_t err = localtime_s(tm, &time); + if (err) + { + *pDOS_date = 0; *pDOS_time = 0; + return; + } +#else + struct tm *tm = localtime(&time); +#endif + *pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1)); + *pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday); +} +#endif + +#ifndef MINIZ_NO_STDIO +static mz_bool mz_zip_get_file_modified_time(const char *pFilename, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) +{ +#ifdef MINIZ_NO_TIME + (void)pFilename; *pDOS_date = *pDOS_time = 0; +#else + struct MZ_FILE_STAT_STRUCT file_stat; + // On Linux with x86 glibc, this call will fail on large files (>= 0x80000000 bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh. + if (MZ_FILE_STAT(pFilename, &file_stat) != 0) + return MZ_FALSE; + mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date); +#endif // #ifdef MINIZ_NO_TIME + return MZ_TRUE; +} + +#ifndef MINIZ_NO_TIME +static mz_bool mz_zip_set_file_times(const char *pFilename, time_t access_time, time_t modified_time) +{ + struct utimbuf t; t.actime = access_time; t.modtime = modified_time; + return !utime(pFilename, &t); +} +#endif // #ifndef MINIZ_NO_TIME +#endif // #ifndef MINIZ_NO_STDIO + +static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint32 flags) +{ + (void)flags; + if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) + return MZ_FALSE; + + if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; + if (!pZip->m_pFree) pZip->m_pFree = def_free_func; + if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; + + pZip->m_zip_mode = MZ_ZIP_MODE_READING; + pZip->m_archive_size = 0; + pZip->m_central_directory_file_ofs = 0; + pZip->m_total_files = 0; + + if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) + return MZ_FALSE; + memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); + return MZ_TRUE; +} + +static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index) +{ + const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; + const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index)); + mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS); + mz_uint8 l = 0, r = 0; + pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; + pE = pL + MZ_MIN(l_len, r_len); + while (pL < pE) + { + if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) + break; + pL++; pR++; + } + return (pL == pE) ? (l_len < r_len) : (l < r); +} + +#define MZ_SWAP_UINT32(a, b) do { mz_uint32 t = a; a = b; b = t; } MZ_MACRO_END + +// Heap sort of lowercased filenames, used to help accelerate plain central directory searches by mz_zip_reader_locate_file(). (Could also use qsort(), but it could allocate memory.) +static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip) +{ + mz_zip_internal_state *pState = pZip->m_pState; + const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; + const mz_zip_array *pCentral_dir = &pState->m_central_dir; + mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); + const int size = pZip->m_total_files; + int start = (size - 2) >> 1, end; + while (start >= 0) + { + int child, root = start; + for ( ; ; ) + { + if ((child = (root << 1) + 1) >= size) + break; + child += (((child + 1) < size) && (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1]))); + if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) + break; + MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; + } + start--; + } + + end = size - 1; + while (end > 0) + { + int child, root = 0; + MZ_SWAP_UINT32(pIndices[end], pIndices[0]); + for ( ; ; ) + { + if ((child = (root << 1) + 1) >= end) + break; + child += (((child + 1) < end) && mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1])); + if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) + break; + MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; + } + end--; + } +} + +static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint32 flags) +{ + mz_uint cdir_size, num_this_disk, cdir_disk_index; + mz_uint64 cdir_ofs; + mz_int64 cur_file_ofs; + const mz_uint8 *p; + mz_uint32 buf_u32[4096 / sizeof(mz_uint32)]; mz_uint8 *pBuf = (mz_uint8 *)buf_u32; + mz_bool sort_central_dir = ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0); + // Basic sanity checks - reject files which are too small, and check the first 4 bytes of the file to make sure a local header is there. + if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) + return MZ_FALSE; + // Find the end of central directory record by scanning the file from the end towards the beginning. + cur_file_ofs = MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0); + for ( ; ; ) + { + int i, n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs); + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n) + return MZ_FALSE; + for (i = n - 4; i >= 0; --i) + if (MZ_READ_LE32(pBuf + i) == MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) + break; + if (i >= 0) + { + cur_file_ofs += i; + break; + } + if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >= (0xFFFF + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE))) + return MZ_FALSE; + cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0); + } + // Read and verify the end of central directory record. + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) + return MZ_FALSE; + if ((MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) || + ((pZip->m_total_files = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS)) != MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS))) + return MZ_FALSE; + + num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS); + cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS); + if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1))) + return MZ_FALSE; + + if ((cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS)) < pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) + return MZ_FALSE; + + cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS); + if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size) + return MZ_FALSE; + + pZip->m_central_directory_file_ofs = cdir_ofs; + + if (pZip->m_total_files) + { + mz_uint i, n; + + // Read the entire central directory into a heap block, and allocate another heap block to hold the unsorted central dir file record offsets, and another to hold the sorted indices. + if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) || + (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE))) + return MZ_FALSE; + + if (sort_central_dir) + { + if (!mz_zip_array_resize(pZip, &pZip->m_pState->m_sorted_central_dir_offsets, pZip->m_total_files, MZ_FALSE)) + return MZ_FALSE; + } + + if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs, pZip->m_pState->m_central_dir.m_p, cdir_size) != cdir_size) + return MZ_FALSE; + + // Now create an index into the central directory file records, do some basic sanity checking on each record, and check for zip64 entries (which are not yet supported). + p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p; + for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i) + { + mz_uint total_header_size, comp_size, decomp_size, disk_index; + if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG)) + return MZ_FALSE; + MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, i) = (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p); + if (sort_central_dir) + MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets, mz_uint32, i) = i; + comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); + decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); + if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) || (comp_size == 0xFFFFFFFF)) + return MZ_FALSE; + disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS); + if ((disk_index != num_this_disk) && (disk_index != 1)) + return MZ_FALSE; + if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size) + return MZ_FALSE; + if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) > n) + return MZ_FALSE; + n -= total_header_size; p += total_header_size; + } + } + + if (sort_central_dir) + mz_zip_reader_sort_central_dir_offsets_by_filename(pZip); + + return MZ_TRUE; +} + +mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags) +{ + if ((!pZip) || (!pZip->m_pRead)) + return MZ_FALSE; + if (!mz_zip_reader_init_internal(pZip, flags)) + return MZ_FALSE; + pZip->m_archive_size = size; + if (!mz_zip_reader_read_central_dir(pZip, flags)) + { + mz_zip_reader_end(pZip); + return MZ_FALSE; + } + return MZ_TRUE; +} + +static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) +{ + mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; + size_t s = (file_ofs >= pZip->m_archive_size) ? 0 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n); + memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s); + return s; +} + +mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags) +{ + if (!mz_zip_reader_init_internal(pZip, flags)) + return MZ_FALSE; + pZip->m_archive_size = size; + pZip->m_pRead = mz_zip_mem_read_func; + pZip->m_pIO_opaque = pZip; +#ifdef __cplusplus + pZip->m_pState->m_pMem = const_cast(pMem); +#else + pZip->m_pState->m_pMem = (void *)pMem; +#endif + pZip->m_pState->m_mem_size = size; + if (!mz_zip_reader_read_central_dir(pZip, flags)) + { + mz_zip_reader_end(pZip); + return MZ_FALSE; + } + return MZ_TRUE; +} + +#ifndef MINIZ_NO_STDIO +static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) +{ + mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; + mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); + if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) + return 0; + return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile); +} + +mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags) +{ + mz_uint64 file_size; + MZ_FILE *pFile = MZ_FOPEN(pFilename, "rb"); + if (!pFile) + return MZ_FALSE; + if (MZ_FSEEK64(pFile, 0, SEEK_END)) + { + MZ_FCLOSE(pFile); + return MZ_FALSE; + } + file_size = MZ_FTELL64(pFile); + if (!mz_zip_reader_init_internal(pZip, flags)) + { + MZ_FCLOSE(pFile); + return MZ_FALSE; + } + pZip->m_pRead = mz_zip_file_read_func; + pZip->m_pIO_opaque = pZip; + pZip->m_pState->m_pFile = pFile; + pZip->m_archive_size = file_size; + if (!mz_zip_reader_read_central_dir(pZip, flags)) + { + mz_zip_reader_end(pZip); + return MZ_FALSE; + } + return MZ_TRUE; +} +#endif // #ifndef MINIZ_NO_STDIO + +mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) +{ + return pZip ? pZip->m_total_files : 0; +} + +static MZ_FORCEINLINE const mz_uint8 *mz_zip_reader_get_cdh(mz_zip_archive *pZip, mz_uint file_index) +{ + if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) + return NULL; + return &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); +} + +mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index) +{ + mz_uint m_bit_flag; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + if (!p) + return MZ_FALSE; + m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); + return (m_bit_flag & 1); +} + +mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index) +{ + mz_uint filename_len, external_attr; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + if (!p) + return MZ_FALSE; + + // First see if the filename ends with a '/' character. + filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); + if (filename_len) + { + if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/') + return MZ_TRUE; + } + + // Bugfix: This code was also checking if the internal attribute was non-zero, which wasn't correct. + // Most/all zip writers (hopefully) set DOS file/directory attributes in the low 16-bits, so check for the DOS directory flag and ignore the source OS ID in the created by field. + // FIXME: Remove this check? Is it necessary - we already check the filename. + external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); + if ((external_attr & 0x10) != 0) + return MZ_TRUE; + + return MZ_FALSE; +} + +mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat) +{ + mz_uint n; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + if ((!p) || (!pStat)) + return MZ_FALSE; + + // Unpack the central directory record. + pStat->m_file_index = file_index; + pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index); + pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS); + pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS); + pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); + pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS); +#ifndef MINIZ_NO_TIME + pStat->m_time = mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS)); +#endif + pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS); + pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); + pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); + pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS); + pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); + pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS); + + // Copy as much of the filename and comment as possible. + n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1); + memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); pStat->m_filename[n] = '\0'; + + n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1); + pStat->m_comment_size = n; + memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n); pStat->m_comment[n] = '\0'; + + return MZ_TRUE; +} + +mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size) +{ + mz_uint n; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + if (!p) { if (filename_buf_size) pFilename[0] = '\0'; return 0; } + n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); + if (filename_buf_size) + { + n = MZ_MIN(n, filename_buf_size - 1); + memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); + pFilename[n] = '\0'; + } + return n + 1; +} + +static MZ_FORCEINLINE mz_bool mz_zip_reader_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags) +{ + mz_uint i; + if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE) + return 0 == memcmp(pA, pB, len); + for (i = 0; i < len; ++i) + if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i])) + return MZ_FALSE; + return MZ_TRUE; +} + +static MZ_FORCEINLINE int mz_zip_reader_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len) +{ + const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; + mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS); + mz_uint8 l = 0, r = 0; + pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; + pE = pL + MZ_MIN(l_len, r_len); + while (pL < pE) + { + if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) + break; + pL++; pR++; + } + return (pL == pE) ? (int)(l_len - r_len) : (l - r); +} + +static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename) +{ + mz_zip_internal_state *pState = pZip->m_pState; + const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; + const mz_zip_array *pCentral_dir = &pState->m_central_dir; + mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); + const int size = pZip->m_total_files; + const mz_uint filename_len = (mz_uint)strlen(pFilename); + int l = 0, h = size - 1; + while (l <= h) + { + int m = (l + h) >> 1, file_index = pIndices[m], comp = mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len); + if (!comp) + return file_index; + else if (comp < 0) + l = m + 1; + else + h = m - 1; + } + return -1; +} + +int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags) +{ + mz_uint file_index; size_t name_len, comment_len; + if ((!pZip) || (!pZip->m_pState) || (!pName) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) + return -1; + if (((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size)) + return mz_zip_reader_locate_file_binary_search(pZip, pName); + name_len = strlen(pName); if (name_len > 0xFFFF) return -1; + comment_len = pComment ? strlen(pComment) : 0; if (comment_len > 0xFFFF) return -1; + for (file_index = 0; file_index < pZip->m_total_files; file_index++) + { + const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); + mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS); + const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; + if (filename_len < name_len) + continue; + if (comment_len) + { + mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS); + const char *pFile_comment = pFilename + filename_len + file_extra_len; + if ((file_comment_len != comment_len) || (!mz_zip_reader_string_equal(pComment, pFile_comment, file_comment_len, flags))) + continue; + } + if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len)) + { + int ofs = filename_len - 1; + do + { + if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || (pFilename[ofs] == ':')) + break; + } while (--ofs >= 0); + ofs++; + pFilename += ofs; filename_len -= ofs; + } + if ((filename_len == name_len) && (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags))) + return file_index; + } + return -1; +} + +mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) +{ + int status = TINFL_STATUS_DONE; + mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail; + mz_zip_archive_file_stat file_stat; + void *pRead_buf; + mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; + tinfl_decompressor inflator; + + if ((buf_size) && (!pBuf)) + return MZ_FALSE; + + if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) + return MZ_FALSE; + + // Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes) + if (!file_stat.m_comp_size) + return MZ_TRUE; + + // Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers). + // I'm torn how to handle this case - should it fail instead? + if (mz_zip_reader_is_file_a_directory(pZip, file_index)) + return MZ_TRUE; + + // Encryption and patch files are not supported. + if (file_stat.m_bit_flag & (1 | 32)) + return MZ_FALSE; + + // This function only supports stored and deflate. + if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) + return MZ_FALSE; + + // Ensure supplied output buffer is large enough. + needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size; + if (buf_size < needed_size) + return MZ_FALSE; + + // Read and parse the local directory entry. + cur_file_ofs = file_stat.m_local_header_ofs; + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) + return MZ_FALSE; + if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) + return MZ_FALSE; + + cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); + if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) + return MZ_FALSE; + + if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) + { + // The file is stored or the caller has requested the compressed data. + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, (size_t)needed_size) != needed_size) + return MZ_FALSE; + return ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) != 0) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) == file_stat.m_crc32); + } + + // Decompress the file either directly from memory or from a file input buffer. + tinfl_init(&inflator); + + if (pZip->m_pState->m_pMem) + { + // Read directly from the archive in memory. + pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; + read_buf_size = read_buf_avail = file_stat.m_comp_size; + comp_remaining = 0; + } + else if (pUser_read_buf) + { + // Use a user provided read buffer. + if (!user_read_buf_size) + return MZ_FALSE; + pRead_buf = (mz_uint8 *)pUser_read_buf; + read_buf_size = user_read_buf_size; + read_buf_avail = 0; + comp_remaining = file_stat.m_comp_size; + } + else + { + // Temporarily allocate a read buffer. + read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE); +#ifdef _MSC_VER + if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) +#else + if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) +#endif + return MZ_FALSE; + if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) + return MZ_FALSE; + read_buf_avail = 0; + comp_remaining = file_stat.m_comp_size; + } + + do + { + size_t in_buf_size, out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs); + if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) + { + read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) + { + status = TINFL_STATUS_FAILED; + break; + } + cur_file_ofs += read_buf_avail; + comp_remaining -= read_buf_avail; + read_buf_ofs = 0; + } + in_buf_size = (size_t)read_buf_avail; + status = tinfl_decompress(&inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF | (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0)); + read_buf_avail -= in_buf_size; + read_buf_ofs += in_buf_size; + out_buf_ofs += out_buf_size; + } while (status == TINFL_STATUS_NEEDS_MORE_INPUT); + + if (status == TINFL_STATUS_DONE) + { + // Make sure the entire file was decompressed, and check its CRC. + if ((out_buf_ofs != file_stat.m_uncomp_size) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32)) + status = TINFL_STATUS_FAILED; + } + + if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf)) + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + + return status == TINFL_STATUS_DONE; +} + +mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) +{ + int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); + if (file_index < 0) + return MZ_FALSE; + return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size); +} + +mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags) +{ + return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, NULL, 0); +} + +mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags) +{ + return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, buf_size, flags, NULL, 0); +} + +void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags) +{ + mz_uint64 comp_size, uncomp_size, alloc_size; + const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); + void *pBuf; + + if (pSize) + *pSize = 0; + if (!p) + return NULL; + + comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); + uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); + + alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size; +#ifdef _MSC_VER + if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) +#else + if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) +#endif + return NULL; + if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size))) + return NULL; + + if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size, flags)) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return NULL; + } + + if (pSize) *pSize = (size_t)alloc_size; + return pBuf; +} + +void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags) +{ + int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); + if (file_index < 0) + { + if (pSize) *pSize = 0; + return MZ_FALSE; + } + return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags); +} + +mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) +{ + int status = TINFL_STATUS_DONE; mz_uint file_crc32 = MZ_CRC32_INIT; + mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs; + mz_zip_archive_file_stat file_stat; + void *pRead_buf = NULL; void *pWrite_buf = NULL; + mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; + + if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) + return MZ_FALSE; + + // Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes) + if (!file_stat.m_comp_size) + return MZ_TRUE; + + // Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers). + // I'm torn how to handle this case - should it fail instead? + if (mz_zip_reader_is_file_a_directory(pZip, file_index)) + return MZ_TRUE; + + // Encryption and patch files are not supported. + if (file_stat.m_bit_flag & (1 | 32)) + return MZ_FALSE; + + // This function only supports stored and deflate. + if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) + return MZ_FALSE; + + // Read and parse the local directory entry. + cur_file_ofs = file_stat.m_local_header_ofs; + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) + return MZ_FALSE; + if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) + return MZ_FALSE; + + cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); + if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) + return MZ_FALSE; + + // Decompress the file either directly from memory or from a file input buffer. + if (pZip->m_pState->m_pMem) + { + pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; + read_buf_size = read_buf_avail = file_stat.m_comp_size; + comp_remaining = 0; + } + else + { + read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE); + if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) + return MZ_FALSE; + read_buf_avail = 0; + comp_remaining = file_stat.m_comp_size; + } + + if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) + { + // The file is stored or the caller has requested the compressed data. + if (pZip->m_pState->m_pMem) + { +#ifdef _MSC_VER + if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) +#else + if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) +#endif + return MZ_FALSE; + if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size) + status = TINFL_STATUS_FAILED; + else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) + file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)file_stat.m_comp_size); + cur_file_ofs += file_stat.m_comp_size; + out_buf_ofs += file_stat.m_comp_size; + comp_remaining = 0; + } + else + { + while (comp_remaining) + { + read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) + { + status = TINFL_STATUS_FAILED; + break; + } + + if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) + file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail); + + if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) + { + status = TINFL_STATUS_FAILED; + break; + } + cur_file_ofs += read_buf_avail; + out_buf_ofs += read_buf_avail; + comp_remaining -= read_buf_avail; + } + } + } + else + { + tinfl_decompressor inflator; + tinfl_init(&inflator); + + if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE))) + status = TINFL_STATUS_FAILED; + else + { + do + { + mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); + size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); + if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) + { + read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); + if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) + { + status = TINFL_STATUS_FAILED; + break; + } + cur_file_ofs += read_buf_avail; + comp_remaining -= read_buf_avail; + read_buf_ofs = 0; + } + + in_buf_size = (size_t)read_buf_avail; + status = tinfl_decompress(&inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size, comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0); + read_buf_avail -= in_buf_size; + read_buf_ofs += in_buf_size; + + if (out_buf_size) + { + if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size) + { + status = TINFL_STATUS_FAILED; + break; + } + file_crc32 = (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size); + if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size) + { + status = TINFL_STATUS_FAILED; + break; + } + } + } while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) || (status == TINFL_STATUS_HAS_MORE_OUTPUT)); + } + } + + if ((status == TINFL_STATUS_DONE) && (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) + { + // Make sure the entire file was decompressed, and check its CRC. + if ((out_buf_ofs != file_stat.m_uncomp_size) || (file_crc32 != file_stat.m_crc32)) + status = TINFL_STATUS_FAILED; + } + + if (!pZip->m_pState->m_pMem) + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + if (pWrite_buf) + pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf); + + return status == TINFL_STATUS_DONE; +} + +mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) +{ + int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); + if (file_index < 0) + return MZ_FALSE; + return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, flags); +} + +#ifndef MINIZ_NO_STDIO +static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n) +{ + (void)ofs; return MZ_FWRITE(pBuf, 1, n, (MZ_FILE*)pOpaque); +} + +mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags) +{ + mz_bool status; + mz_zip_archive_file_stat file_stat; + MZ_FILE *pFile; + if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) + return MZ_FALSE; + pFile = MZ_FOPEN(pDst_filename, "wb"); + if (!pFile) + return MZ_FALSE; + status = mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_file_write_callback, pFile, flags); + if (MZ_FCLOSE(pFile) == EOF) + return MZ_FALSE; +#ifndef MINIZ_NO_TIME + if (status) + mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time); +#endif + return status; +} +#endif // #ifndef MINIZ_NO_STDIO + +mz_bool mz_zip_reader_end(mz_zip_archive *pZip) +{ + if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) + return MZ_FALSE; + + if (pZip->m_pState) + { + mz_zip_internal_state *pState = pZip->m_pState; pZip->m_pState = NULL; + mz_zip_array_clear(pZip, &pState->m_central_dir); + mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); + mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); + +#ifndef MINIZ_NO_STDIO + if (pState->m_pFile) + { + MZ_FCLOSE(pState->m_pFile); + pState->m_pFile = NULL; + } +#endif // #ifndef MINIZ_NO_STDIO + + pZip->m_pFree(pZip->m_pAlloc_opaque, pState); + } + pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; + + return MZ_TRUE; +} + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags) +{ + int file_index = mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags); + if (file_index < 0) + return MZ_FALSE; + return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags); +} +#endif + +// ------------------- .ZIP archive writing + +#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS + +static void mz_write_le16(mz_uint8 *p, mz_uint16 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); } +static void mz_write_le32(mz_uint8 *p, mz_uint32 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); p[2] = (mz_uint8)(v >> 16); p[3] = (mz_uint8)(v >> 24); } +#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v)) +#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v)) + +mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) +{ + if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) + return MZ_FALSE; + + if (pZip->m_file_offset_alignment) + { + // Ensure user specified file offset alignment is a power of 2. + if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1)) + return MZ_FALSE; + } + + if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; + if (!pZip->m_pFree) pZip->m_pFree = def_free_func; + if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; + + pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; + pZip->m_archive_size = existing_size; + pZip->m_central_directory_file_ofs = 0; + pZip->m_total_files = 0; + + if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) + return MZ_FALSE; + memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); + MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); + return MZ_TRUE; +} + +static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) +{ + mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; + mz_zip_internal_state *pState = pZip->m_pState; + mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size); +#ifdef _MSC_VER + if ((!n) || ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) +#else + if ((!n) || ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) +#endif + return 0; + if (new_size > pState->m_mem_capacity) + { + void *pNew_block; + size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity); while (new_capacity < new_size) new_capacity *= 2; + if (NULL == (pNew_block = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity))) + return 0; + pState->m_pMem = pNew_block; pState->m_mem_capacity = new_capacity; + } + memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n); + pState->m_mem_size = (size_t)new_size; + return n; +} + +mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size) +{ + pZip->m_pWrite = mz_zip_heap_write_func; + pZip->m_pIO_opaque = pZip; + if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) + return MZ_FALSE; + if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning))) + { + if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, initial_allocation_size))) + { + mz_zip_writer_end(pZip); + return MZ_FALSE; + } + pZip->m_pState->m_mem_capacity = initial_allocation_size; + } + return MZ_TRUE; +} + +#ifndef MINIZ_NO_STDIO +static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) +{ + mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; + mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); + if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) + return 0; + return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile); +} + +mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning) +{ + MZ_FILE *pFile; + pZip->m_pWrite = mz_zip_file_write_func; + pZip->m_pIO_opaque = pZip; + if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) + return MZ_FALSE; + if (NULL == (pFile = MZ_FOPEN(pFilename, "wb"))) + { + mz_zip_writer_end(pZip); + return MZ_FALSE; + } + pZip->m_pState->m_pFile = pFile; + if (size_to_reserve_at_beginning) + { + mz_uint64 cur_ofs = 0; char buf[4096]; MZ_CLEAR_OBJ(buf); + do + { + size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n) + { + mz_zip_writer_end(pZip); + return MZ_FALSE; + } + cur_ofs += n; size_to_reserve_at_beginning -= n; + } while (size_to_reserve_at_beginning); + } + return MZ_TRUE; +} +#endif // #ifndef MINIZ_NO_STDIO + +mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename) +{ + mz_zip_internal_state *pState; + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) + return MZ_FALSE; + // No sense in trying to write to an archive that's already at the support max size + if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) + return MZ_FALSE; + + pState = pZip->m_pState; + + if (pState->m_pFile) + { +#ifdef MINIZ_NO_STDIO + pFilename; return MZ_FALSE; +#else + // Archive is being read from stdio - try to reopen as writable. + if (pZip->m_pIO_opaque != pZip) + return MZ_FALSE; + if (!pFilename) + return MZ_FALSE; + pZip->m_pWrite = mz_zip_file_write_func; + if (NULL == (pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile))) + { + // The mz_zip_archive is now in a bogus state because pState->m_pFile is NULL, so just close it. + mz_zip_reader_end(pZip); + return MZ_FALSE; + } +#endif // #ifdef MINIZ_NO_STDIO + } + else if (pState->m_pMem) + { + // Archive lives in a memory block. Assume it's from the heap that we can resize using the realloc callback. + if (pZip->m_pIO_opaque != pZip) + return MZ_FALSE; + pState->m_mem_capacity = pState->m_mem_size; + pZip->m_pWrite = mz_zip_heap_write_func; + } + // Archive is being read via a user provided read function - make sure the user has specified a write function too. + else if (!pZip->m_pWrite) + return MZ_FALSE; + + // Start writing new files at the archive's current central directory location. + pZip->m_archive_size = pZip->m_central_directory_file_ofs; + pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; + pZip->m_central_directory_file_ofs = 0; + + return MZ_TRUE; +} + +mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags) +{ + return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, level_and_flags, 0, 0); +} + +typedef struct +{ + mz_zip_archive *m_pZip; + mz_uint64 m_cur_archive_file_ofs; + mz_uint64 m_comp_size; +} mz_zip_writer_add_state; + +static mz_bool mz_zip_writer_add_put_buf_callback(const void* pBuf, int len, void *pUser) +{ + mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser; + if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque, pState->m_cur_archive_file_ofs, pBuf, len) != len) + return MZ_FALSE; + pState->m_cur_archive_file_ofs += len; + pState->m_comp_size += len; + return MZ_TRUE; +} + +static mz_bool mz_zip_writer_create_local_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date) +{ + (void)pZip; + memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE); + MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date); + MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32); + MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, comp_size); + MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, uncomp_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size); + return MZ_TRUE; +} + +static mz_bool mz_zip_writer_create_central_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) +{ + (void)pZip; + memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, comp_size); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, uncomp_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size); + MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes); + MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_header_ofs); + return MZ_TRUE; +} + +static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size, const void *pExtra, mz_uint16 extra_size, const void *pComment, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) +{ + mz_zip_internal_state *pState = pZip->m_pState; + mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size; + size_t orig_central_dir_size = pState->m_central_dir.m_size; + mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; + + // No zip64 support yet + if ((local_header_ofs > 0xFFFFFFFF) || (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + comment_size) > 0xFFFFFFFF)) + return MZ_FALSE; + + if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, extra_size, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes)) + return MZ_FALSE; + + if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) || + (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) || + (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) || + (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) || + (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, ¢ral_dir_ofs, 1))) + { + // Try to push the central directory array back into its original state. + mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); + return MZ_FALSE; + } + + return MZ_TRUE; +} + +static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name) +{ + // Basic ZIP archive filename validity checks: Valid filenames cannot start with a forward slash, cannot contain a drive letter, and cannot use DOS-style backward slashes. + if (*pArchive_name == '/') + return MZ_FALSE; + while (*pArchive_name) + { + if ((*pArchive_name == '\\') || (*pArchive_name == ':')) + return MZ_FALSE; + pArchive_name++; + } + return MZ_TRUE; +} + +static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip) +{ + mz_uint32 n; + if (!pZip->m_file_offset_alignment) + return 0; + n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1)); + return (pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1); +} + +static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n) +{ + char buf[4096]; + memset(buf, 0, MZ_MIN(sizeof(buf), n)); + while (n) + { + mz_uint32 s = MZ_MIN(sizeof(buf), n); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s) + return MZ_FALSE; + cur_file_ofs += s; n -= s; + } + return MZ_TRUE; +} + +mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32) +{ + mz_uint16 method = 0, dos_time = 0, dos_date = 0; + mz_uint level, ext_attributes = 0, num_alignment_padding_bytes; + mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0; + size_t archive_name_size; + mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; + tdefl_compressor *pComp = NULL; + mz_bool store_data_uncompressed; + mz_zip_internal_state *pState; + + if ((int)level_and_flags < 0) + level_and_flags = MZ_DEFAULT_LEVEL; + level = level_and_flags & 0xF; + store_data_uncompressed = ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)); + + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || (!pArchive_name) || ((comment_size) && (!pComment)) || (pZip->m_total_files == 0xFFFF) || (level > MZ_UBER_COMPRESSION)) + return MZ_FALSE; + + pState = pZip->m_pState; + + if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size)) + return MZ_FALSE; + // No zip64 support yet + if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) + return MZ_FALSE; + if (!mz_zip_writer_validate_archive_name(pArchive_name)) + return MZ_FALSE; + +#ifndef MINIZ_NO_TIME + { + time_t cur_time; time(&cur_time); + mz_zip_time_to_dos_time(cur_time, &dos_time, &dos_date); + } +#endif // #ifndef MINIZ_NO_TIME + + archive_name_size = strlen(pArchive_name); + if (archive_name_size > 0xFFFF) + return MZ_FALSE; + + num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); + + // no zip64 support yet + if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) + return MZ_FALSE; + + if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/')) + { + // Set DOS Subdirectory attribute bit. + ext_attributes |= 0x10; + // Subdirectories cannot contain data. + if ((buf_size) || (uncomp_size)) + return MZ_FALSE; + } + + // Try to do any allocations before writing to the archive, so if an allocation fails the file remains unmodified. (A good idea if we're doing an in-place modification.) + if ((!mz_zip_array_ensure_room(pZip, &pState->m_central_dir, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size)) || (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1))) + return MZ_FALSE; + + if ((!store_data_uncompressed) && (buf_size)) + { + if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)))) + return MZ_FALSE; + } + + if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + return MZ_FALSE; + } + local_dir_header_ofs += num_alignment_padding_bytes; + if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } + cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); + + MZ_CLEAR_OBJ(local_dir_header); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + return MZ_FALSE; + } + cur_archive_file_ofs += archive_name_size; + + if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) + { + uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8*)pBuf, buf_size); + uncomp_size = buf_size; + if (uncomp_size <= 3) + { + level = 0; + store_data_uncompressed = MZ_TRUE; + } + } + + if (store_data_uncompressed) + { + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf, buf_size) != buf_size) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + return MZ_FALSE; + } + + cur_archive_file_ofs += buf_size; + comp_size = buf_size; + + if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) + method = MZ_DEFLATED; + } + else if (buf_size) + { + mz_zip_writer_add_state state; + + state.m_pZip = pZip; + state.m_cur_archive_file_ofs = cur_archive_file_ofs; + state.m_comp_size = 0; + + if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) || + (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) != TDEFL_STATUS_DONE)) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + return MZ_FALSE; + } + + comp_size = state.m_comp_size; + cur_archive_file_ofs = state.m_cur_archive_file_ofs; + + method = MZ_DEFLATED; + } + + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + pComp = NULL; + + // no zip64 support yet + if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) + return MZ_FALSE; + + if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) + return MZ_FALSE; + + if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) + return MZ_FALSE; + + if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) + return MZ_FALSE; + + pZip->m_total_files++; + pZip->m_archive_size = cur_archive_file_ofs; + + return MZ_TRUE; +} + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) +{ + mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes; + mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0; + mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, comp_size = 0; + size_t archive_name_size; + mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; + MZ_FILE *pSrc_file = NULL; + + if ((int)level_and_flags < 0) + level_and_flags = MZ_DEFAULT_LEVEL; + level = level_and_flags & 0xF; + + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) + return MZ_FALSE; + if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) + return MZ_FALSE; + if (!mz_zip_writer_validate_archive_name(pArchive_name)) + return MZ_FALSE; + + archive_name_size = strlen(pArchive_name); + if (archive_name_size > 0xFFFF) + return MZ_FALSE; + + num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); + + // no zip64 support yet + if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) + return MZ_FALSE; + + if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date)) + return MZ_FALSE; + + pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); + if (!pSrc_file) + return MZ_FALSE; + MZ_FSEEK64(pSrc_file, 0, SEEK_END); + uncomp_size = MZ_FTELL64(pSrc_file); + MZ_FSEEK64(pSrc_file, 0, SEEK_SET); + + if (uncomp_size > 0xFFFFFFFF) + { + // No zip64 support yet + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + if (uncomp_size <= 3) + level = 0; + + if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) + { + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + local_dir_header_ofs += num_alignment_padding_bytes; + if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } + cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); + + MZ_CLEAR_OBJ(local_dir_header); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) + { + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + cur_archive_file_ofs += archive_name_size; + + if (uncomp_size) + { + mz_uint64 uncomp_remaining = uncomp_size; + void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE); + if (!pRead_buf) + { + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + + if (!level) + { + while (uncomp_remaining) + { + mz_uint n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining); + if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n)) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n); + uncomp_remaining -= n; + cur_archive_file_ofs += n; + } + comp_size = uncomp_size; + } + else + { + mz_bool result = MZ_FALSE; + mz_zip_writer_add_state state; + tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)); + if (!pComp) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + + state.m_pZip = pZip; + state.m_cur_archive_file_ofs = cur_archive_file_ofs; + state.m_comp_size = 0; + + if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + + for ( ; ; ) + { + size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, MZ_ZIP_MAX_IO_BUF_SIZE); + tdefl_status status; + + if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size) + break; + + uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size); + uncomp_remaining -= in_buf_size; + + status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size, uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH); + if (status == TDEFL_STATUS_DONE) + { + result = MZ_TRUE; + break; + } + else if (status != TDEFL_STATUS_OKAY) + break; + } + + pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); + + if (!result) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + MZ_FCLOSE(pSrc_file); + return MZ_FALSE; + } + + comp_size = state.m_comp_size; + cur_archive_file_ofs = state.m_cur_archive_file_ofs; + + method = MZ_DEFLATED; + } + + pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); + } + + MZ_FCLOSE(pSrc_file); pSrc_file = NULL; + + // no zip64 support yet + if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) + return MZ_FALSE; + + if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) + return MZ_FALSE; + + if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) + return MZ_FALSE; + + if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) + return MZ_FALSE; + + pZip->m_total_files++; + pZip->m_archive_size = cur_archive_file_ofs; + + return MZ_TRUE; +} +#endif // #ifndef MINIZ_NO_STDIO + +mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index) +{ + mz_uint n, bit_flags, num_alignment_padding_bytes; + mz_uint64 comp_bytes_remaining, local_dir_header_ofs; + mz_uint64 cur_src_file_ofs, cur_dst_file_ofs; + mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; + mz_uint8 central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; + size_t orig_central_dir_size; + mz_zip_internal_state *pState; + void *pBuf; const mz_uint8 *pSrc_central_header; + + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) + return MZ_FALSE; + if (NULL == (pSrc_central_header = mz_zip_reader_get_cdh(pSource_zip, file_index))) + return MZ_FALSE; + pState = pZip->m_pState; + + num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); + + // no zip64 support yet + if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) + return MZ_FALSE; + + cur_src_file_ofs = MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS); + cur_dst_file_ofs = pZip->m_archive_size; + + if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) + return MZ_FALSE; + if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) + return MZ_FALSE; + cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; + + if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes)) + return MZ_FALSE; + cur_dst_file_ofs += num_alignment_padding_bytes; + local_dir_header_ofs = cur_dst_file_ofs; + if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } + + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) + return MZ_FALSE; + cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; + + n = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); + comp_bytes_remaining = n + MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); + + if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(sizeof(mz_uint32) * 4, MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining))))) + return MZ_FALSE; + + while (comp_bytes_remaining) + { + n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining); + if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return MZ_FALSE; + } + cur_src_file_ofs += n; + + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return MZ_FALSE; + } + cur_dst_file_ofs += n; + + comp_bytes_remaining -= n; + } + + bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS); + if (bit_flags & 8) + { + // Copy data descriptor + if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return MZ_FALSE; + } + + n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == 0x08074b50) ? 4 : 3); + if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return MZ_FALSE; + } + + cur_src_file_ofs += n; + cur_dst_file_ofs += n; + } + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + + // no zip64 support yet + if (cur_dst_file_ofs > 0xFFFFFFFF) + return MZ_FALSE; + + orig_central_dir_size = pState->m_central_dir.m_size; + + memcpy(central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); + MZ_WRITE_LE32(central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_dir_header_ofs); + if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) + return MZ_FALSE; + + n = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS); + if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n)) + { + mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); + return MZ_FALSE; + } + + if (pState->m_central_dir.m_size > 0xFFFFFFFF) + return MZ_FALSE; + n = (mz_uint32)orig_central_dir_size; + if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1)) + { + mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); + return MZ_FALSE; + } + + pZip->m_total_files++; + pZip->m_archive_size = cur_dst_file_ofs; + + return MZ_TRUE; +} + +mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip) +{ + mz_zip_internal_state *pState; + mz_uint64 central_dir_ofs, central_dir_size; + mz_uint8 hdr[MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE]; + + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) + return MZ_FALSE; + + pState = pZip->m_pState; + + // no zip64 support yet + if ((pZip->m_total_files > 0xFFFF) || ((pZip->m_archive_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) + return MZ_FALSE; + + central_dir_ofs = 0; + central_dir_size = 0; + if (pZip->m_total_files) + { + // Write central directory + central_dir_ofs = pZip->m_archive_size; + central_dir_size = pState->m_central_dir.m_size; + pZip->m_central_directory_file_ofs = central_dir_ofs; + if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs, pState->m_central_dir.m_p, (size_t)central_dir_size) != central_dir_size) + return MZ_FALSE; + pZip->m_archive_size += central_dir_size; + } + + // Write end of central directory record + MZ_CLEAR_OBJ(hdr); + MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG); + MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, pZip->m_total_files); + MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files); + MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, central_dir_size); + MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, central_dir_ofs); + + if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, sizeof(hdr)) != sizeof(hdr)) + return MZ_FALSE; +#ifndef MINIZ_NO_STDIO + if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF)) + return MZ_FALSE; +#endif // #ifndef MINIZ_NO_STDIO + + pZip->m_archive_size += sizeof(hdr); + + pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED; + return MZ_TRUE; +} + +mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize) +{ + if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pSize)) + return MZ_FALSE; + if (pZip->m_pWrite != mz_zip_heap_write_func) + return MZ_FALSE; + if (!mz_zip_writer_finalize_archive(pZip)) + return MZ_FALSE; + + *pBuf = pZip->m_pState->m_pMem; + *pSize = pZip->m_pState->m_mem_size; + pZip->m_pState->m_pMem = NULL; + pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0; + return MZ_TRUE; +} + +mz_bool mz_zip_writer_end(mz_zip_archive *pZip) +{ + mz_zip_internal_state *pState; + mz_bool status = MZ_TRUE; + if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED))) + return MZ_FALSE; + + pState = pZip->m_pState; + pZip->m_pState = NULL; + mz_zip_array_clear(pZip, &pState->m_central_dir); + mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); + mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); + +#ifndef MINIZ_NO_STDIO + if (pState->m_pFile) + { + MZ_FCLOSE(pState->m_pFile); + pState->m_pFile = NULL; + } +#endif // #ifndef MINIZ_NO_STDIO + + if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem)) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem); + pState->m_pMem = NULL; + } + + pZip->m_pFree(pZip->m_pAlloc_opaque, pState); + pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; + return status; +} + +#ifndef MINIZ_NO_STDIO +mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) +{ + mz_bool status, created_new_archive = MZ_FALSE; + mz_zip_archive zip_archive; + struct MZ_FILE_STAT_STRUCT file_stat; + MZ_CLEAR_OBJ(zip_archive); + if ((int)level_and_flags < 0) + level_and_flags = MZ_DEFAULT_LEVEL; + if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION)) + return MZ_FALSE; + if (!mz_zip_writer_validate_archive_name(pArchive_name)) + return MZ_FALSE; + if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0) + { + // Create a new archive. + if (!mz_zip_writer_init_file(&zip_archive, pZip_filename, 0)) + return MZ_FALSE; + created_new_archive = MZ_TRUE; + } + else + { + // Append to an existing archive. + if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) + return MZ_FALSE; + if (!mz_zip_writer_init_from_reader(&zip_archive, pZip_filename)) + { + mz_zip_reader_end(&zip_archive); + return MZ_FALSE; + } + } + status = mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0); + // Always finalize, even if adding failed for some reason, so we have a valid central directory. (This may not always succeed, but we can try.) + if (!mz_zip_writer_finalize_archive(&zip_archive)) + status = MZ_FALSE; + if (!mz_zip_writer_end(&zip_archive)) + status = MZ_FALSE; + if ((!status) && (created_new_archive)) + { + // It's a new archive and something went wrong, so just delete it. + int ignoredStatus = MZ_DELETE_FILE(pZip_filename); + (void)ignoredStatus; + } + return status; +} + +void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags) +{ + int file_index; + mz_zip_archive zip_archive; + void *p = NULL; + + if (pSize) + *pSize = 0; + + if ((!pZip_filename) || (!pArchive_name)) + return NULL; + + MZ_CLEAR_OBJ(zip_archive); + if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) + return NULL; + + if ((file_index = mz_zip_reader_locate_file(&zip_archive, pArchive_name, NULL, flags)) >= 0) + p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags); + + mz_zip_reader_end(&zip_archive); + return p; +} + +#endif // #ifndef MINIZ_NO_STDIO + +#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS + +#endif // #ifndef MINIZ_NO_ARCHIVE_APIS + +#ifdef __cplusplus +} +#endif + +#endif // MINIZ_HEADER_FILE_ONLY + +/* + This is free and unencumbered software released into the public domain. + + Anyone is free to copy, modify, publish, use, compile, sell, or + distribute this software, either in source code form or as a compiled + binary, for any purpose, commercial or non-commercial, and by any + means. + + In jurisdictions that recognize copyright laws, the author or authors + of this software dedicate any and all copyright interest in the + software to the public domain. We make this dedication for the benefit + of the public at large and to the detriment of our heirs and + successors. We intend this dedication to be an overt act of + relinquishment in perpetuity of all present and future rights to this + software under copyright law. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + + For more information, please refer to +*/ diff --git a/3rdparty/sha512/sha512.c b/3rdparty/sha512/sha512.c new file mode 100644 index 0000000..742d556 --- /dev/null +++ b/3rdparty/sha512/sha512.c @@ -0,0 +1,797 @@ +/* + * FIPS-180-2 compliant SHA-384/512 implementation + * + * Copyright (C) 2006-2014, ARM Limited, All Rights Reserved + * + * This file is part of mbed TLS (https://polarssl.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +/* + * The SHA-512 Secure Hash Standard was published by NIST in 2002. + * + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf + */ + +// Don't include polarssl/config.h since we are compiling outside of PolarSSL +/* +#if !defined(POLARSSL_CONFIG_FILE) +#include "polarssl/config.h" +#else +#include POLARSSL_CONFIG_FILE +#endif +*/ + +// Don't require defining POLARSSL_SHA512_C +//#if defined(POLARSSL_SHA512_C) + +#include "sha512.h" + +#if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST) +#include +#endif + +#if defined(POLARSSL_PLATFORM_C) +#include "polarssl/platform.h" +#else +#define polarssl_printf printf +#endif + +/* Implementation that should never be optimized out by the compiler */ +static void polarssl_zeroize( void *v, size_t n ) { + volatile unsigned char *p = v; while( n-- ) *p++ = 0; +} + +#if !defined(POLARSSL_SHA512_ALT) + +/* + * 64-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT64_BE +#define GET_UINT64_BE(n,b,i) \ +{ \ + (n) = ( (uint64_t) (b)[(i) ] << 56 ) \ + | ( (uint64_t) (b)[(i) + 1] << 48 ) \ + | ( (uint64_t) (b)[(i) + 2] << 40 ) \ + | ( (uint64_t) (b)[(i) + 3] << 32 ) \ + | ( (uint64_t) (b)[(i) + 4] << 24 ) \ + | ( (uint64_t) (b)[(i) + 5] << 16 ) \ + | ( (uint64_t) (b)[(i) + 6] << 8 ) \ + | ( (uint64_t) (b)[(i) + 7] ); \ +} +#endif /* GET_UINT64_BE */ + +#ifndef PUT_UINT64_BE +#define PUT_UINT64_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 56 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 48 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 40 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) >> 32 ); \ + (b)[(i) + 4] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 5] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 6] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 7] = (unsigned char) ( (n) ); \ +} +#endif /* PUT_UINT64_BE */ + +/* + * Round constants + */ +static const uint64_t K[80] = +{ + UL64(0x428A2F98D728AE22), UL64(0x7137449123EF65CD), + UL64(0xB5C0FBCFEC4D3B2F), UL64(0xE9B5DBA58189DBBC), + UL64(0x3956C25BF348B538), UL64(0x59F111F1B605D019), + UL64(0x923F82A4AF194F9B), UL64(0xAB1C5ED5DA6D8118), + UL64(0xD807AA98A3030242), UL64(0x12835B0145706FBE), + UL64(0x243185BE4EE4B28C), UL64(0x550C7DC3D5FFB4E2), + UL64(0x72BE5D74F27B896F), UL64(0x80DEB1FE3B1696B1), + UL64(0x9BDC06A725C71235), UL64(0xC19BF174CF692694), + UL64(0xE49B69C19EF14AD2), UL64(0xEFBE4786384F25E3), + UL64(0x0FC19DC68B8CD5B5), UL64(0x240CA1CC77AC9C65), + UL64(0x2DE92C6F592B0275), UL64(0x4A7484AA6EA6E483), + UL64(0x5CB0A9DCBD41FBD4), UL64(0x76F988DA831153B5), + UL64(0x983E5152EE66DFAB), UL64(0xA831C66D2DB43210), + UL64(0xB00327C898FB213F), UL64(0xBF597FC7BEEF0EE4), + UL64(0xC6E00BF33DA88FC2), UL64(0xD5A79147930AA725), + UL64(0x06CA6351E003826F), UL64(0x142929670A0E6E70), + UL64(0x27B70A8546D22FFC), UL64(0x2E1B21385C26C926), + UL64(0x4D2C6DFC5AC42AED), UL64(0x53380D139D95B3DF), + UL64(0x650A73548BAF63DE), UL64(0x766A0ABB3C77B2A8), + UL64(0x81C2C92E47EDAEE6), UL64(0x92722C851482353B), + UL64(0xA2BFE8A14CF10364), UL64(0xA81A664BBC423001), + UL64(0xC24B8B70D0F89791), UL64(0xC76C51A30654BE30), + UL64(0xD192E819D6EF5218), UL64(0xD69906245565A910), + UL64(0xF40E35855771202A), UL64(0x106AA07032BBD1B8), + UL64(0x19A4C116B8D2D0C8), UL64(0x1E376C085141AB53), + UL64(0x2748774CDF8EEB99), UL64(0x34B0BCB5E19B48A8), + UL64(0x391C0CB3C5C95A63), UL64(0x4ED8AA4AE3418ACB), + UL64(0x5B9CCA4F7763E373), UL64(0x682E6FF3D6B2B8A3), + UL64(0x748F82EE5DEFB2FC), UL64(0x78A5636F43172F60), + UL64(0x84C87814A1F0AB72), UL64(0x8CC702081A6439EC), + UL64(0x90BEFFFA23631E28), UL64(0xA4506CEBDE82BDE9), + UL64(0xBEF9A3F7B2C67915), UL64(0xC67178F2E372532B), + UL64(0xCA273ECEEA26619C), UL64(0xD186B8C721C0C207), + UL64(0xEADA7DD6CDE0EB1E), UL64(0xF57D4F7FEE6ED178), + UL64(0x06F067AA72176FBA), UL64(0x0A637DC5A2C898A6), + UL64(0x113F9804BEF90DAE), UL64(0x1B710B35131C471B), + UL64(0x28DB77F523047D84), UL64(0x32CAAB7B40C72493), + UL64(0x3C9EBE0A15C9BEBC), UL64(0x431D67C49C100D4C), + UL64(0x4CC5D4BECB3E42B6), UL64(0x597F299CFC657E2A), + UL64(0x5FCB6FAB3AD6FAEC), UL64(0x6C44198C4A475817) +}; + +void sha512_init( sha512_context *ctx ) +{ + memset( ctx, 0, sizeof( sha512_context ) ); +} + +void sha512_free( sha512_context *ctx ) +{ + if( ctx == NULL ) + return; + + polarssl_zeroize( ctx, sizeof( sha512_context ) ); +} + +/* + * SHA-512 context setup + */ +void sha512_starts( sha512_context *ctx, int is384 ) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + if( is384 == 0 ) + { + /* SHA-512 */ + ctx->state[0] = UL64(0x6A09E667F3BCC908); + ctx->state[1] = UL64(0xBB67AE8584CAA73B); + ctx->state[2] = UL64(0x3C6EF372FE94F82B); + ctx->state[3] = UL64(0xA54FF53A5F1D36F1); + ctx->state[4] = UL64(0x510E527FADE682D1); + ctx->state[5] = UL64(0x9B05688C2B3E6C1F); + ctx->state[6] = UL64(0x1F83D9ABFB41BD6B); + ctx->state[7] = UL64(0x5BE0CD19137E2179); + } + else + { + /* SHA-384 */ + ctx->state[0] = UL64(0xCBBB9D5DC1059ED8); + ctx->state[1] = UL64(0x629A292A367CD507); + ctx->state[2] = UL64(0x9159015A3070DD17); + ctx->state[3] = UL64(0x152FECD8F70E5939); + ctx->state[4] = UL64(0x67332667FFC00B31); + ctx->state[5] = UL64(0x8EB44A8768581511); + ctx->state[6] = UL64(0xDB0C2E0D64F98FA7); + ctx->state[7] = UL64(0x47B5481DBEFA4FA4); + } + + ctx->is384 = is384; +} + +void sha512_process( sha512_context *ctx, const unsigned char data[128] ) +{ + int i; + uint64_t temp1, temp2, W[80]; + uint64_t A, B, C, D, E, F, G, H; + +#define SHR(x,n) (x >> n) +#define ROTR(x,n) (SHR(x,n) | (x << (64 - n))) + +#define S0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7)) +#define S1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6)) + +#define S2(x) (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39)) +#define S3(x) (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41)) + +#define F0(x,y,z) ((x & y) | (z & (x | y))) +#define F1(x,y,z) (z ^ (x & (y ^ z))) + +#define P(a,b,c,d,e,f,g,h,x,K) \ +{ \ + temp1 = h + S3(e) + F1(e,f,g) + K + x; \ + temp2 = S2(a) + F0(a,b,c); \ + d += temp1; h = temp1 + temp2; \ +} + + for( i = 0; i < 16; i++ ) + { + GET_UINT64_BE( W[i], data, i << 3 ); + } + + for( ; i < 80; i++ ) + { + W[i] = S1(W[i - 2]) + W[i - 7] + + S0(W[i - 15]) + W[i - 16]; + } + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + E = ctx->state[4]; + F = ctx->state[5]; + G = ctx->state[6]; + H = ctx->state[7]; + i = 0; + + do + { + P( A, B, C, D, E, F, G, H, W[i], K[i] ); i++; + P( H, A, B, C, D, E, F, G, W[i], K[i] ); i++; + P( G, H, A, B, C, D, E, F, W[i], K[i] ); i++; + P( F, G, H, A, B, C, D, E, W[i], K[i] ); i++; + P( E, F, G, H, A, B, C, D, W[i], K[i] ); i++; + P( D, E, F, G, H, A, B, C, W[i], K[i] ); i++; + P( C, D, E, F, G, H, A, B, W[i], K[i] ); i++; + P( B, C, D, E, F, G, H, A, W[i], K[i] ); i++; + } + while( i < 80 ); + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; + ctx->state[4] += E; + ctx->state[5] += F; + ctx->state[6] += G; + ctx->state[7] += H; +} + +/* + * SHA-512 process buffer + */ +void sha512_update( sha512_context *ctx, const unsigned char *input, + size_t ilen ) +{ + size_t fill; + unsigned int left; + + if( ilen == 0 ) + return; + + left = (unsigned int) (ctx->total[0] & 0x7F); + fill = 128 - left; + + ctx->total[0] += (uint64_t) ilen; + + if( ctx->total[0] < (uint64_t) ilen ) + ctx->total[1]++; + + if( left && ilen >= fill ) + { + memcpy( (void *) (ctx->buffer + left), input, fill ); + sha512_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; + } + + while( ilen >= 128 ) + { + sha512_process( ctx, input ); + input += 128; + ilen -= 128; + } + + if( ilen > 0 ) + memcpy( (void *) (ctx->buffer + left), input, ilen ); +} + +static const unsigned char sha512_padding[128] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* + * SHA-512 final digest + */ +void sha512_finish( sha512_context *ctx, unsigned char output[64] ) +{ + size_t last, padn; + uint64_t high, low; + unsigned char msglen[16]; + + high = ( ctx->total[0] >> 61 ) + | ( ctx->total[1] << 3 ); + low = ( ctx->total[0] << 3 ); + + PUT_UINT64_BE( high, msglen, 0 ); + PUT_UINT64_BE( low, msglen, 8 ); + + last = (size_t)( ctx->total[0] & 0x7F ); + padn = ( last < 112 ) ? ( 112 - last ) : ( 240 - last ); + + sha512_update( ctx, sha512_padding, padn ); + sha512_update( ctx, msglen, 16 ); + + PUT_UINT64_BE( ctx->state[0], output, 0 ); + PUT_UINT64_BE( ctx->state[1], output, 8 ); + PUT_UINT64_BE( ctx->state[2], output, 16 ); + PUT_UINT64_BE( ctx->state[3], output, 24 ); + PUT_UINT64_BE( ctx->state[4], output, 32 ); + PUT_UINT64_BE( ctx->state[5], output, 40 ); + + if( ctx->is384 == 0 ) + { + PUT_UINT64_BE( ctx->state[6], output, 48 ); + PUT_UINT64_BE( ctx->state[7], output, 56 ); + } +} + +#endif /* !POLARSSL_SHA512_ALT */ + +/* + * output = SHA-512( input buffer ) + */ +void sha512( const unsigned char *input, size_t ilen, + unsigned char output[64], int is384 ) +{ + sha512_context ctx; + + sha512_init( &ctx ); + sha512_starts( &ctx, is384 ); + sha512_update( &ctx, input, ilen ); + sha512_finish( &ctx, output ); + sha512_free( &ctx ); +} + +#if defined(POLARSSL_FS_IO) +/* + * output = SHA-512( file contents ) + */ +int sha512_file( const char *path, unsigned char output[64], int is384 ) +{ + FILE *f; + size_t n; + sha512_context ctx; + unsigned char buf[1024]; + + if( ( f = fopen( path, "rb" ) ) == NULL ) + return( POLARSSL_ERR_SHA512_FILE_IO_ERROR ); + + sha512_init( &ctx ); + sha512_starts( &ctx, is384 ); + + while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) + sha512_update( &ctx, buf, n ); + + sha512_finish( &ctx, output ); + sha512_free( &ctx ); + + if( ferror( f ) != 0 ) + { + fclose( f ); + return( POLARSSL_ERR_SHA512_FILE_IO_ERROR ); + } + + fclose( f ); + return( 0 ); +} +#endif /* POLARSSL_FS_IO */ + +/* + * SHA-512 HMAC context setup + */ +void sha512_hmac_starts( sha512_context *ctx, const unsigned char *key, + size_t keylen, int is384 ) +{ + size_t i; + unsigned char sum[64]; + + if( keylen > 128 ) + { + sha512( key, keylen, sum, is384 ); + keylen = ( is384 ) ? 48 : 64; + key = sum; + } + + memset( ctx->ipad, 0x36, 128 ); + memset( ctx->opad, 0x5C, 128 ); + + for( i = 0; i < keylen; i++ ) + { + ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); + ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); + } + + sha512_starts( ctx, is384 ); + sha512_update( ctx, ctx->ipad, 128 ); + + polarssl_zeroize( sum, sizeof( sum ) ); +} + +/* + * SHA-512 HMAC process buffer + */ +void sha512_hmac_update( sha512_context *ctx, + const unsigned char *input, size_t ilen ) +{ + sha512_update( ctx, input, ilen ); +} + +/* + * SHA-512 HMAC final digest + */ +void sha512_hmac_finish( sha512_context *ctx, unsigned char output[64] ) +{ + int is384, hlen; + unsigned char tmpbuf[64]; + + is384 = ctx->is384; + hlen = ( is384 == 0 ) ? 64 : 48; + + sha512_finish( ctx, tmpbuf ); + sha512_starts( ctx, is384 ); + sha512_update( ctx, ctx->opad, 128 ); + sha512_update( ctx, tmpbuf, hlen ); + sha512_finish( ctx, output ); + + polarssl_zeroize( tmpbuf, sizeof( tmpbuf ) ); +} + +/* + * SHA-512 HMAC context reset + */ +void sha512_hmac_reset( sha512_context *ctx ) +{ + sha512_starts( ctx, ctx->is384 ); + sha512_update( ctx, ctx->ipad, 128 ); +} + +/* + * output = HMAC-SHA-512( hmac key, input buffer ) + */ +void sha512_hmac( const unsigned char *key, size_t keylen, + const unsigned char *input, size_t ilen, + unsigned char output[64], int is384 ) +{ + sha512_context ctx; + + sha512_init( &ctx ); + sha512_hmac_starts( &ctx, key, keylen, is384 ); + sha512_hmac_update( &ctx, input, ilen ); + sha512_hmac_finish( &ctx, output ); + sha512_free( &ctx ); +} + +#if defined(POLARSSL_SELF_TEST) + +/* + * FIPS-180-2 test vectors + */ +static unsigned char sha512_test_buf[3][113] = +{ + { "abc" }, + { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" + "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" }, + { "" } +}; + +static const int sha512_test_buflen[3] = +{ + 3, 112, 1000 +}; + +static const unsigned char sha512_test_sum[6][64] = +{ + /* + * SHA-384 test vectors + */ + { 0xCB, 0x00, 0x75, 0x3F, 0x45, 0xA3, 0x5E, 0x8B, + 0xB5, 0xA0, 0x3D, 0x69, 0x9A, 0xC6, 0x50, 0x07, + 0x27, 0x2C, 0x32, 0xAB, 0x0E, 0xDE, 0xD1, 0x63, + 0x1A, 0x8B, 0x60, 0x5A, 0x43, 0xFF, 0x5B, 0xED, + 0x80, 0x86, 0x07, 0x2B, 0xA1, 0xE7, 0xCC, 0x23, + 0x58, 0xBA, 0xEC, 0xA1, 0x34, 0xC8, 0x25, 0xA7 }, + { 0x09, 0x33, 0x0C, 0x33, 0xF7, 0x11, 0x47, 0xE8, + 0x3D, 0x19, 0x2F, 0xC7, 0x82, 0xCD, 0x1B, 0x47, + 0x53, 0x11, 0x1B, 0x17, 0x3B, 0x3B, 0x05, 0xD2, + 0x2F, 0xA0, 0x80, 0x86, 0xE3, 0xB0, 0xF7, 0x12, + 0xFC, 0xC7, 0xC7, 0x1A, 0x55, 0x7E, 0x2D, 0xB9, + 0x66, 0xC3, 0xE9, 0xFA, 0x91, 0x74, 0x60, 0x39 }, + { 0x9D, 0x0E, 0x18, 0x09, 0x71, 0x64, 0x74, 0xCB, + 0x08, 0x6E, 0x83, 0x4E, 0x31, 0x0A, 0x4A, 0x1C, + 0xED, 0x14, 0x9E, 0x9C, 0x00, 0xF2, 0x48, 0x52, + 0x79, 0x72, 0xCE, 0xC5, 0x70, 0x4C, 0x2A, 0x5B, + 0x07, 0xB8, 0xB3, 0xDC, 0x38, 0xEC, 0xC4, 0xEB, + 0xAE, 0x97, 0xDD, 0xD8, 0x7F, 0x3D, 0x89, 0x85 }, + + /* + * SHA-512 test vectors + */ + { 0xDD, 0xAF, 0x35, 0xA1, 0x93, 0x61, 0x7A, 0xBA, + 0xCC, 0x41, 0x73, 0x49, 0xAE, 0x20, 0x41, 0x31, + 0x12, 0xE6, 0xFA, 0x4E, 0x89, 0xA9, 0x7E, 0xA2, + 0x0A, 0x9E, 0xEE, 0xE6, 0x4B, 0x55, 0xD3, 0x9A, + 0x21, 0x92, 0x99, 0x2A, 0x27, 0x4F, 0xC1, 0xA8, + 0x36, 0xBA, 0x3C, 0x23, 0xA3, 0xFE, 0xEB, 0xBD, + 0x45, 0x4D, 0x44, 0x23, 0x64, 0x3C, 0xE8, 0x0E, + 0x2A, 0x9A, 0xC9, 0x4F, 0xA5, 0x4C, 0xA4, 0x9F }, + { 0x8E, 0x95, 0x9B, 0x75, 0xDA, 0xE3, 0x13, 0xDA, + 0x8C, 0xF4, 0xF7, 0x28, 0x14, 0xFC, 0x14, 0x3F, + 0x8F, 0x77, 0x79, 0xC6, 0xEB, 0x9F, 0x7F, 0xA1, + 0x72, 0x99, 0xAE, 0xAD, 0xB6, 0x88, 0x90, 0x18, + 0x50, 0x1D, 0x28, 0x9E, 0x49, 0x00, 0xF7, 0xE4, + 0x33, 0x1B, 0x99, 0xDE, 0xC4, 0xB5, 0x43, 0x3A, + 0xC7, 0xD3, 0x29, 0xEE, 0xB6, 0xDD, 0x26, 0x54, + 0x5E, 0x96, 0xE5, 0x5B, 0x87, 0x4B, 0xE9, 0x09 }, + { 0xE7, 0x18, 0x48, 0x3D, 0x0C, 0xE7, 0x69, 0x64, + 0x4E, 0x2E, 0x42, 0xC7, 0xBC, 0x15, 0xB4, 0x63, + 0x8E, 0x1F, 0x98, 0xB1, 0x3B, 0x20, 0x44, 0x28, + 0x56, 0x32, 0xA8, 0x03, 0xAF, 0xA9, 0x73, 0xEB, + 0xDE, 0x0F, 0xF2, 0x44, 0x87, 0x7E, 0xA6, 0x0A, + 0x4C, 0xB0, 0x43, 0x2C, 0xE5, 0x77, 0xC3, 0x1B, + 0xEB, 0x00, 0x9C, 0x5C, 0x2C, 0x49, 0xAA, 0x2E, + 0x4E, 0xAD, 0xB2, 0x17, 0xAD, 0x8C, 0xC0, 0x9B } +}; + +/* + * RFC 4231 test vectors + */ +static unsigned char sha512_hmac_test_key[7][26] = +{ + { "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B" + "\x0B\x0B\x0B\x0B" }, + { "Jefe" }, + { "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" + "\xAA\xAA\xAA\xAA" }, + { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10" + "\x11\x12\x13\x14\x15\x16\x17\x18\x19" }, + { "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C" + "\x0C\x0C\x0C\x0C" }, + { "" }, /* 0xAA 131 times */ + { "" } +}; + +static const int sha512_hmac_test_keylen[7] = +{ + 20, 4, 20, 25, 20, 131, 131 +}; + +static unsigned char sha512_hmac_test_buf[7][153] = +{ + { "Hi There" }, + { "what do ya want for nothing?" }, + { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" + "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" + "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" + "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" + "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" }, + { "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" + "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" + "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" + "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" + "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" }, + { "Test With Truncation" }, + { "Test Using Larger Than Block-Size Key - Hash Key First" }, + { "This is a test using a larger than block-size key " + "and a larger than block-size data. The key needs to " + "be hashed before being used by the HMAC algorithm." } +}; + +static const int sha512_hmac_test_buflen[7] = +{ + 8, 28, 50, 50, 20, 54, 152 +}; + +static const unsigned char sha512_hmac_test_sum[14][64] = +{ + /* + * HMAC-SHA-384 test vectors + */ + { 0xAF, 0xD0, 0x39, 0x44, 0xD8, 0x48, 0x95, 0x62, + 0x6B, 0x08, 0x25, 0xF4, 0xAB, 0x46, 0x90, 0x7F, + 0x15, 0xF9, 0xDA, 0xDB, 0xE4, 0x10, 0x1E, 0xC6, + 0x82, 0xAA, 0x03, 0x4C, 0x7C, 0xEB, 0xC5, 0x9C, + 0xFA, 0xEA, 0x9E, 0xA9, 0x07, 0x6E, 0xDE, 0x7F, + 0x4A, 0xF1, 0x52, 0xE8, 0xB2, 0xFA, 0x9C, 0xB6 }, + { 0xAF, 0x45, 0xD2, 0xE3, 0x76, 0x48, 0x40, 0x31, + 0x61, 0x7F, 0x78, 0xD2, 0xB5, 0x8A, 0x6B, 0x1B, + 0x9C, 0x7E, 0xF4, 0x64, 0xF5, 0xA0, 0x1B, 0x47, + 0xE4, 0x2E, 0xC3, 0x73, 0x63, 0x22, 0x44, 0x5E, + 0x8E, 0x22, 0x40, 0xCA, 0x5E, 0x69, 0xE2, 0xC7, + 0x8B, 0x32, 0x39, 0xEC, 0xFA, 0xB2, 0x16, 0x49 }, + { 0x88, 0x06, 0x26, 0x08, 0xD3, 0xE6, 0xAD, 0x8A, + 0x0A, 0xA2, 0xAC, 0xE0, 0x14, 0xC8, 0xA8, 0x6F, + 0x0A, 0xA6, 0x35, 0xD9, 0x47, 0xAC, 0x9F, 0xEB, + 0xE8, 0x3E, 0xF4, 0xE5, 0x59, 0x66, 0x14, 0x4B, + 0x2A, 0x5A, 0xB3, 0x9D, 0xC1, 0x38, 0x14, 0xB9, + 0x4E, 0x3A, 0xB6, 0xE1, 0x01, 0xA3, 0x4F, 0x27 }, + { 0x3E, 0x8A, 0x69, 0xB7, 0x78, 0x3C, 0x25, 0x85, + 0x19, 0x33, 0xAB, 0x62, 0x90, 0xAF, 0x6C, 0xA7, + 0x7A, 0x99, 0x81, 0x48, 0x08, 0x50, 0x00, 0x9C, + 0xC5, 0x57, 0x7C, 0x6E, 0x1F, 0x57, 0x3B, 0x4E, + 0x68, 0x01, 0xDD, 0x23, 0xC4, 0xA7, 0xD6, 0x79, + 0xCC, 0xF8, 0xA3, 0x86, 0xC6, 0x74, 0xCF, 0xFB }, + { 0x3A, 0xBF, 0x34, 0xC3, 0x50, 0x3B, 0x2A, 0x23, + 0xA4, 0x6E, 0xFC, 0x61, 0x9B, 0xAE, 0xF8, 0x97 }, + { 0x4E, 0xCE, 0x08, 0x44, 0x85, 0x81, 0x3E, 0x90, + 0x88, 0xD2, 0xC6, 0x3A, 0x04, 0x1B, 0xC5, 0xB4, + 0x4F, 0x9E, 0xF1, 0x01, 0x2A, 0x2B, 0x58, 0x8F, + 0x3C, 0xD1, 0x1F, 0x05, 0x03, 0x3A, 0xC4, 0xC6, + 0x0C, 0x2E, 0xF6, 0xAB, 0x40, 0x30, 0xFE, 0x82, + 0x96, 0x24, 0x8D, 0xF1, 0x63, 0xF4, 0x49, 0x52 }, + { 0x66, 0x17, 0x17, 0x8E, 0x94, 0x1F, 0x02, 0x0D, + 0x35, 0x1E, 0x2F, 0x25, 0x4E, 0x8F, 0xD3, 0x2C, + 0x60, 0x24, 0x20, 0xFE, 0xB0, 0xB8, 0xFB, 0x9A, + 0xDC, 0xCE, 0xBB, 0x82, 0x46, 0x1E, 0x99, 0xC5, + 0xA6, 0x78, 0xCC, 0x31, 0xE7, 0x99, 0x17, 0x6D, + 0x38, 0x60, 0xE6, 0x11, 0x0C, 0x46, 0x52, 0x3E }, + + /* + * HMAC-SHA-512 test vectors + */ + { 0x87, 0xAA, 0x7C, 0xDE, 0xA5, 0xEF, 0x61, 0x9D, + 0x4F, 0xF0, 0xB4, 0x24, 0x1A, 0x1D, 0x6C, 0xB0, + 0x23, 0x79, 0xF4, 0xE2, 0xCE, 0x4E, 0xC2, 0x78, + 0x7A, 0xD0, 0xB3, 0x05, 0x45, 0xE1, 0x7C, 0xDE, + 0xDA, 0xA8, 0x33, 0xB7, 0xD6, 0xB8, 0xA7, 0x02, + 0x03, 0x8B, 0x27, 0x4E, 0xAE, 0xA3, 0xF4, 0xE4, + 0xBE, 0x9D, 0x91, 0x4E, 0xEB, 0x61, 0xF1, 0x70, + 0x2E, 0x69, 0x6C, 0x20, 0x3A, 0x12, 0x68, 0x54 }, + { 0x16, 0x4B, 0x7A, 0x7B, 0xFC, 0xF8, 0x19, 0xE2, + 0xE3, 0x95, 0xFB, 0xE7, 0x3B, 0x56, 0xE0, 0xA3, + 0x87, 0xBD, 0x64, 0x22, 0x2E, 0x83, 0x1F, 0xD6, + 0x10, 0x27, 0x0C, 0xD7, 0xEA, 0x25, 0x05, 0x54, + 0x97, 0x58, 0xBF, 0x75, 0xC0, 0x5A, 0x99, 0x4A, + 0x6D, 0x03, 0x4F, 0x65, 0xF8, 0xF0, 0xE6, 0xFD, + 0xCA, 0xEA, 0xB1, 0xA3, 0x4D, 0x4A, 0x6B, 0x4B, + 0x63, 0x6E, 0x07, 0x0A, 0x38, 0xBC, 0xE7, 0x37 }, + { 0xFA, 0x73, 0xB0, 0x08, 0x9D, 0x56, 0xA2, 0x84, + 0xEF, 0xB0, 0xF0, 0x75, 0x6C, 0x89, 0x0B, 0xE9, + 0xB1, 0xB5, 0xDB, 0xDD, 0x8E, 0xE8, 0x1A, 0x36, + 0x55, 0xF8, 0x3E, 0x33, 0xB2, 0x27, 0x9D, 0x39, + 0xBF, 0x3E, 0x84, 0x82, 0x79, 0xA7, 0x22, 0xC8, + 0x06, 0xB4, 0x85, 0xA4, 0x7E, 0x67, 0xC8, 0x07, + 0xB9, 0x46, 0xA3, 0x37, 0xBE, 0xE8, 0x94, 0x26, + 0x74, 0x27, 0x88, 0x59, 0xE1, 0x32, 0x92, 0xFB }, + { 0xB0, 0xBA, 0x46, 0x56, 0x37, 0x45, 0x8C, 0x69, + 0x90, 0xE5, 0xA8, 0xC5, 0xF6, 0x1D, 0x4A, 0xF7, + 0xE5, 0x76, 0xD9, 0x7F, 0xF9, 0x4B, 0x87, 0x2D, + 0xE7, 0x6F, 0x80, 0x50, 0x36, 0x1E, 0xE3, 0xDB, + 0xA9, 0x1C, 0xA5, 0xC1, 0x1A, 0xA2, 0x5E, 0xB4, + 0xD6, 0x79, 0x27, 0x5C, 0xC5, 0x78, 0x80, 0x63, + 0xA5, 0xF1, 0x97, 0x41, 0x12, 0x0C, 0x4F, 0x2D, + 0xE2, 0xAD, 0xEB, 0xEB, 0x10, 0xA2, 0x98, 0xDD }, + { 0x41, 0x5F, 0xAD, 0x62, 0x71, 0x58, 0x0A, 0x53, + 0x1D, 0x41, 0x79, 0xBC, 0x89, 0x1D, 0x87, 0xA6 }, + { 0x80, 0xB2, 0x42, 0x63, 0xC7, 0xC1, 0xA3, 0xEB, + 0xB7, 0x14, 0x93, 0xC1, 0xDD, 0x7B, 0xE8, 0xB4, + 0x9B, 0x46, 0xD1, 0xF4, 0x1B, 0x4A, 0xEE, 0xC1, + 0x12, 0x1B, 0x01, 0x37, 0x83, 0xF8, 0xF3, 0x52, + 0x6B, 0x56, 0xD0, 0x37, 0xE0, 0x5F, 0x25, 0x98, + 0xBD, 0x0F, 0xD2, 0x21, 0x5D, 0x6A, 0x1E, 0x52, + 0x95, 0xE6, 0x4F, 0x73, 0xF6, 0x3F, 0x0A, 0xEC, + 0x8B, 0x91, 0x5A, 0x98, 0x5D, 0x78, 0x65, 0x98 }, + { 0xE3, 0x7B, 0x6A, 0x77, 0x5D, 0xC8, 0x7D, 0xBA, + 0xA4, 0xDF, 0xA9, 0xF9, 0x6E, 0x5E, 0x3F, 0xFD, + 0xDE, 0xBD, 0x71, 0xF8, 0x86, 0x72, 0x89, 0x86, + 0x5D, 0xF5, 0xA3, 0x2D, 0x20, 0xCD, 0xC9, 0x44, + 0xB6, 0x02, 0x2C, 0xAC, 0x3C, 0x49, 0x82, 0xB1, + 0x0D, 0x5E, 0xEB, 0x55, 0xC3, 0xE4, 0xDE, 0x15, + 0x13, 0x46, 0x76, 0xFB, 0x6D, 0xE0, 0x44, 0x60, + 0x65, 0xC9, 0x74, 0x40, 0xFA, 0x8C, 0x6A, 0x58 } +}; + +/* + * Checkup routine + */ +int sha512_self_test( int verbose ) +{ + int i, j, k, buflen, ret = 0; + unsigned char buf[1024]; + unsigned char sha512sum[64]; + sha512_context ctx; + + sha512_init( &ctx ); + + for( i = 0; i < 6; i++ ) + { + j = i % 3; + k = i < 3; + + if( verbose != 0 ) + polarssl_printf( " SHA-%d test #%d: ", 512 - k * 128, j + 1 ); + + sha512_starts( &ctx, k ); + + if( j == 2 ) + { + memset( buf, 'a', buflen = 1000 ); + + for( j = 0; j < 1000; j++ ) + sha512_update( &ctx, buf, buflen ); + } + else + sha512_update( &ctx, sha512_test_buf[j], + sha512_test_buflen[j] ); + + sha512_finish( &ctx, sha512sum ); + + if( memcmp( sha512sum, sha512_test_sum[i], 64 - k * 16 ) != 0 ) + { + if( verbose != 0 ) + polarssl_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + polarssl_printf( "passed\n" ); + } + + if( verbose != 0 ) + polarssl_printf( "\n" ); + + for( i = 0; i < 14; i++ ) + { + j = i % 7; + k = i < 7; + + if( verbose != 0 ) + polarssl_printf( " HMAC-SHA-%d test #%d: ", 512 - k * 128, j + 1 ); + + if( j == 5 || j == 6 ) + { + memset( buf, '\xAA', buflen = 131 ); + sha512_hmac_starts( &ctx, buf, buflen, k ); + } + else + sha512_hmac_starts( &ctx, sha512_hmac_test_key[j], + sha512_hmac_test_keylen[j], k ); + + sha512_hmac_update( &ctx, sha512_hmac_test_buf[j], + sha512_hmac_test_buflen[j] ); + + sha512_hmac_finish( &ctx, sha512sum ); + + buflen = ( j == 4 ) ? 16 : 64 - k * 16; + + if( memcmp( sha512sum, sha512_hmac_test_sum[i], buflen ) != 0 ) + { + if( verbose != 0 ) + polarssl_printf( "failed\n" ); + + ret = 1; + goto exit; + } + + if( verbose != 0 ) + polarssl_printf( "passed\n" ); + } + + if( verbose != 0 ) + polarssl_printf( "\n" ); + +exit: + sha512_free( &ctx ); + + return( ret ); +} + +#endif /* POLARSSL_SELF_TEST */ + +//#endif /* POLARSSL_SHA512_C */ diff --git a/3rdparty/sha512/sha512.h b/3rdparty/sha512/sha512.h new file mode 100644 index 0000000..22ea97a --- /dev/null +++ b/3rdparty/sha512/sha512.h @@ -0,0 +1,209 @@ +/** + * \file sha512.h + * + * \brief SHA-384 and SHA-512 cryptographic hash function + * + * Copyright (C) 2006-2014, ARM Limited, All Rights Reserved + * + * This file is part of mbed TLS (https://polarssl.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef POLARSSL_SHA512_H +#define POLARSSL_SHA512_H + +// Don't include polarssl/config.h since we are compiling outside of PolarSSL +/* +#if !defined(POLARSSL_CONFIG_FILE) +#include "config.h" +#else +#include POLARSSL_CONFIG_FILE +#endif +*/ + +#include + +#if defined(_MSC_VER) || defined(__WATCOMC__) + #define UL64(x) x##ui64 + typedef unsigned __int64 uint64_t; +#else + #include + #define UL64(x) x##ULL +#endif + +#define POLARSSL_ERR_SHA512_FILE_IO_ERROR -0x007A /**< Read/write error in file. */ + +#if !defined(POLARSSL_SHA512_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief SHA-512 context structure + */ +typedef struct +{ + uint64_t total[2]; /*!< number of bytes processed */ + uint64_t state[8]; /*!< intermediate digest state */ + unsigned char buffer[128]; /*!< data block being processed */ + + unsigned char ipad[128]; /*!< HMAC: inner padding */ + unsigned char opad[128]; /*!< HMAC: outer padding */ + int is384; /*!< 0 => SHA-512, else SHA-384 */ +} +sha512_context; + +/** + * \brief Initialize SHA-512 context + * + * \param ctx SHA-512 context to be initialized + */ +void sha512_init( sha512_context *ctx ); + +/** + * \brief Clear SHA-512 context + * + * \param ctx SHA-512 context to be cleared + */ +void sha512_free( sha512_context *ctx ); + +/** + * \brief SHA-512 context setup + * + * \param ctx context to be initialized + * \param is384 0 = use SHA512, 1 = use SHA384 + */ +void sha512_starts( sha512_context *ctx, int is384 ); + +/** + * \brief SHA-512 process buffer + * + * \param ctx SHA-512 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void sha512_update( sha512_context *ctx, const unsigned char *input, + size_t ilen ); + +/** + * \brief SHA-512 final digest + * + * \param ctx SHA-512 context + * \param output SHA-384/512 checksum result + */ +void sha512_finish( sha512_context *ctx, unsigned char output[64] ); + +#ifdef __cplusplus +} +#endif + +#else /* POLARSSL_SHA512_ALT */ +#include "sha512_alt.h" +#endif /* POLARSSL_SHA512_ALT */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Output = SHA-512( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output SHA-384/512 checksum result + * \param is384 0 = use SHA512, 1 = use SHA384 + */ +void sha512( const unsigned char *input, size_t ilen, + unsigned char output[64], int is384 ); + +/** + * \brief Output = SHA-512( file contents ) + * + * \param path input file name + * \param output SHA-384/512 checksum result + * \param is384 0 = use SHA512, 1 = use SHA384 + * + * \return 0 if successful, or POLARSSL_ERR_SHA512_FILE_IO_ERROR + */ +int sha512_file( const char *path, unsigned char output[64], int is384 ); + +/** + * \brief SHA-512 HMAC context setup + * + * \param ctx HMAC context to be initialized + * \param is384 0 = use SHA512, 1 = use SHA384 + * \param key HMAC secret key + * \param keylen length of the HMAC key + */ +void sha512_hmac_starts( sha512_context *ctx, const unsigned char *key, + size_t keylen, int is384 ); + +/** + * \brief SHA-512 HMAC process buffer + * + * \param ctx HMAC context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void sha512_hmac_update( sha512_context *ctx, const unsigned char *input, + size_t ilen ); + +/** + * \brief SHA-512 HMAC final digest + * + * \param ctx HMAC context + * \param output SHA-384/512 HMAC checksum result + */ +void sha512_hmac_finish( sha512_context *ctx, unsigned char output[64] ); + +/** + * \brief SHA-512 HMAC context reset + * + * \param ctx HMAC context to be reset + */ +void sha512_hmac_reset( sha512_context *ctx ); + +/** + * \brief Output = HMAC-SHA-512( hmac key, input buffer ) + * + * \param key HMAC secret key + * \param keylen length of the HMAC key + * \param input buffer holding the data + * \param ilen length of the input data + * \param output HMAC-SHA-384/512 result + * \param is384 0 = use SHA512, 1 = use SHA384 + */ +void sha512_hmac( const unsigned char *key, size_t keylen, + const unsigned char *input, size_t ilen, + unsigned char output[64], int is384 ); + +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int sha512_self_test( int verbose ); + +/* Internal use */ +void sha512_process( sha512_context *ctx, const unsigned char data[128] ); + +#ifdef __cplusplus +} +#endif + +#endif /* sha512.h */ diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..88e7107 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Manuel 'Sputnick' Nickschas +Marcus 'EgS' Eggenberger +Alexander 'phon' von Renteln +John 'nox' Hand diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1762959 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,676 @@ +# Main CMake file for building Quassel IRC +# +# See INSTALL for possible CMake options (or read the code, Luke) +##################################################################### + +# General setup +##################################################################### + +project(QuasselIRC) + +# Versions +set(QUASSEL_MAJOR 0) +set(QUASSEL_MINOR 12) +set(QUASSEL_PATCH 5) +set(QUASSEL_VERSION_STRING "0.12.5") + +# Output CMake version and build type for debug reasons +message(STATUS "Using CMake ${CMAKE_VERSION}") +message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}") + +# Tell CMake about or own modules +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + +# General conveniences +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# Include various CMake modules... +include(CMakePushCheckState) +include(CheckFunctionExists) +include(CheckIncludeFile) +include(CheckCXXSourceCompiles) +include(CMakeDependentOption) +include(FeatureSummary) + +# ... and our own stuff +include(QuasselCompileSettings) +include(QuasselMacros) + + +# Options and variables that can be set on the command line +##################################################################### + +# First, choose a Qt version. We support USE_QT4 and USE_QT5; if neither is set, prefer Qt4 for now +option(USE_QT5 "Enable support for Qt5 (disables KDE integration)" OFF) +if (USE_QT4) # takes precedence + set(USE_QT5 OFF) +else() + if (NOT USE_QT5) + set(USE_QT4 ON) + endif() +endif() + +# Select the binaries to build +option(WANT_CORE "Build the core (server) binary" ON) +option(WANT_QTCLIENT "Build the client-only binary" ON) +option(WANT_MONO "Build the monolithic (all-in-one) binary" ON) +add_feature_info(WANT_CORE WANT_CORE "Build the core (server) binary") +add_feature_info(WANT_QTCLIENT WANT_QTCLIENT "Build the client-only binary (requires a core to connect to)") +add_feature_info(WANT_MONO WANT_MONO "Build the monolithic (all-in-one) binary") + +# Whether to enable KDE integration (work in progress for Qt5 / KDE Frameworks) +# Note that when building with Qt5, WITH_KDE enables integration with higher-tier KDE frameworks that +# require runtime support. We still optionally make use of certain Tier 1 frameworks even if WITH_KDE +# is disabled. +if (USE_QT4) + option(WITH_KDE "KDE4 integration" OFF) + add_feature_info(WITH_KDE WITH_KDE "Enable KDE4 integration") +else() + option(WITH_KDE "Integration with the KDE Frameworks runtime environment") + add_feature_info(WITH_KDE WITH_KDE "Integrate with the KDE Frameworks runtime environment") +endif() + +cmake_dependent_option(WITH_OXYGEN "Install Oxygen icon set (usually shipped with KDE)" ON "NOT WITH_KDE" OFF) +if (NOT WITH_KDE) + add_feature_info(WITH_OXYGEN WITH_OXYGEN "Install Oxygen icon set") +endif() + +# For this, the feature info is added after we know if QtWebkit is installed +option(WITH_WEBKIT "WebKit support (for link previews) (legacy)" OFF) + +# For this, the feature info is added after we know if QtWebEngine is installed +option(WITH_WEBENGINE "WebEngine support (for link previews)" ON) + +if (APPLE) + # Notification Center is only available in > 10.8, which is Darwin v12 + if (NOT CMAKE_SYSTEM_VERSION VERSION_LESS 12) + option(WITH_NOTIFICATION_CENTER "OS X Notification Center support" ON) + add_feature_info(WITH_NOTIFICATION_CENTER WITH_NOTIFICATION_CENTER "Use the OS X Notification Center") + endif() + find_library(CARBON_LIBRARY Carbon) + mark_as_advanced(CARBON_LIBRARY) + link_libraries(${CARBON_LIBRARY}) +endif() + +# Always embed on Windows, OSX or for a static build; never embed when enabling KDE integration +set(EMBED_DEFAULT OFF) +if (STATIC OR WIN32 OR APPLE) + set(EMBED_DEFAULT ON) +endif() +cmake_dependent_option(EMBED_DATA "Embed icons and translations into the binaries instead of installing them" ${EMBED_DEFAULT} + "NOT STATIC;NOT WIN32;NOT WITH_KDE" ${EMBED_DEFAULT}) +if (NOT EMBED_DEFAULT) + add_feature_info(EMBED_DATA EMBED_DATA "Embed icons and translations in the binaries instead of installing them") +endif() + +# The following options are not for end-user consumption, so don't list them in the feature summary +cmake_dependent_option(DEPLOY "Add required libs to bundle resources and create a dmg. Note: requires Qt to be built with 10.4u SDK" OFF "APPLE" OFF) + +# Handle with care +set(QT_PATH "" CACHE PATH "Path to a Qt4 installation to use instead of the system Qt (e.g. for static builds)") + +# Static builds are not supported and require some manual setup! Don't enable unless you know what you're doing (we don't know either) +cmake_dependent_option(STATIC "Enable static building (not supported)" OFF "NOT WITH_KDE" OFF) + +# For static builds, arbitrary extra libs might need to be linked +# Define a comma-separated list here +# e.g. for pgsql, we need -DLINK_EXTRA=pq;crypt +set(LINK_EXTRA "" CACHE STRING "Semicolon-separated list of libraries to be linked") +if (LINK_EXTRA) + string(REPLACE "," ";" LINK_EXTRA ${LINK_EXTRA}) + link_libraries(${LINK_EXTRA}) +endif() + + +# Setup CMake +##################################################################### + +if (USE_QT5 AND WITH_KDE) + cmake_minimum_required(VERSION 2.8.12) +else() + cmake_minimum_required(VERSION 2.8.9) +endif() + +# Setting COMPILE_DEFINITIONS_ is deprecated since CMake 3.0 in favor of generator expressions. +# These have existed since CMake 2.8.10; until we depend on that, we have to explicitly enable the old policy. +if (POLICY CMP0043) + cmake_policy(SET CMP0043 OLD) +endif() + +# Honor visibility settings for all target types +if (POLICY CMP0063) + cmake_policy(SET CMP0063 NEW) +endif() + +# Don't automoc generated files +if (POLICY CMP0071) + cmake_policy(SET CMP0071 OLD) +endif() + + +# Simplify later checks +##################################################################### + +if (WANT_MONO OR WANT_QTCLIENT) + set(BUILD_GUI true) +endif() +if (WANT_MONO OR WANT_CORE) + set(BUILD_CORE true) +endif() + + +# Set up Qt +##################################################################### + +# Find package dependencies +# +# Note that you can forcefully disable optional packages +# using -DCMAKE_DISABLE_FIND_PACKAGE_=TRUE +##################################################################### + +if (USE_QT5) + message(STATUS "Building for Qt5...") + set(QT_MIN_VERSION "5.2.0") + add_definitions(-DHAVE_QT5) + + find_package(Qt5Core ${QT_MIN_VERSION} QUIET) + set_package_properties(Qt5Core PROPERTIES TYPE REQUIRED + URL "http://qt.digia.com" + DESCRIPTION "contains core functionality for Qt" + ) + # find_package without REQUIRED won't check for the version properly; also, older Qt5 versions + # used Qt5Core_VERSION_STRING... let's just make sure here that we bail out here if our Qt5 is not new enough. + if (NOT Qt5Core_VERSION OR Qt5Core_VERSION VERSION_LESS ${QT_MIN_VERSION}) + message(FATAL_ERROR "Could NOT find Qt5 >= version ${QT_MIN_VERSION}!") + endif() + + find_package(Qt5Network QUIET) + set_package_properties(Qt5Network PROPERTIES TYPE REQUIRED + DESCRIPTION "the network module for Qt5" + ) + + if (BUILD_GUI) + find_package(Qt5Gui QUIET) + set_package_properties(Qt5Gui PROPERTIES TYPE REQUIRED + DESCRIPTION "the GUI module for Qt5" + ) + find_package(Qt5Widgets QUIET) + set_package_properties(Qt5Widgets PROPERTIES TYPE REQUIRED + DESCRIPTION "the widgets module for Qt5" + ) + + if (NOT WIN32) + find_package(Qt5DBus QUIET) + set_package_properties(Qt5DBus PROPERTIES TYPE RECOMMENDED + URL "http://qt.digia.com" + DESCRIPTION "D-Bus support for Qt5" + PURPOSE "Needed for supporting D-Bus-based notifications and tray icon, used by most modern desktop environments" + ) + if (Qt5DBus_FOUND) + find_package(dbusmenu-qt5 QUIET CONFIG) + set_package_properties(dbusmenu-qt5 PROPERTIES TYPE RECOMMENDED + URL "https://launchpad.net/libdbusmenu-qt" + DESCRIPTION "a library implementing the DBusMenu specification" + PURPOSE "Required for having a context menu for the D-Bus-based tray icon" + ) + endif() + endif() + + find_package(Phonon4Qt5 QUIET) + set_package_properties(Phonon4Qt5 PROPERTIES TYPE RECOMMENDED + URL "https://projects.kde.org/projects/kdesupport/phonon" + DESCRIPTION "a multimedia abstraction library" + PURPOSE "Required for audio notifications" + ) + + find_package(LibsnoreQt5 0.7.0 QUIET) + set_package_properties(LibsnoreQt5 PROPERTIES TYPE OPTIONAL + URL "https://projects.kde.org/projects/playground/libs/snorenotify" + DESCRIPTION "a cross-platform notification framework" + PURPOSE "Enable support for the snorenotify framework" + ) + if(LibsnoreQt5_FOUND) + find_package(LibsnoreSettingsQt5) + set_package_properties(LibsnoreSettingsQt5 PROPERTIES TYPE REQUIRED + URL "https://projects.kde.org/projects/playground/libs/snorenotify" + DESCRIPTION "a cross-platform notification framework" + PURPOSE "Enable support for the snorenotify framework" + ) + endif() + + + if (WITH_WEBKIT) + find_package(Qt5WebKit QUIET) + set_package_properties(Qt5WebKit PROPERTIES TYPE RECOMMENDED + URL "http://qt.digia.com" + DESCRIPTION "a WebKit implementation for Qt" + PURPOSE "Needed for displaying previews for URLs in chat" + ) + if (Qt5WebKit_FOUND) + find_package(Qt5WebKitWidgets QUIET) + set_package_properties(Qt5WebKitWidgets PROPERTIES TYPE RECOMMENDED + URL "http://qt.digia.com" + DESCRIPTION "widgets for Qt's WebKit implementation" + PURPOSE "Needed for displaying previews for URLs in chat" + ) + endif() + endif() + + if (WITH_WEBKIT AND Qt5WebKitWidgets_FOUND) + set(HAVE_WEBKIT true) + endif() + add_feature_info("WITH_WEBKIT, QtWebKit and QtWebKitWidgets modules" HAVE_WEBKIT "Support showing previews for URLs in chat (legacy)") + + if (WITH_WEBENGINE) + find_package(Qt5WebEngine QUIET) + set_package_properties(Qt5WebEngine PROPERTIES TYPE RECOMMENDED + URL "http://qt.digia.com" + DESCRIPTION "a WebEngine implementation for Qt" + PURPOSE "Needed for displaying previews for URLs in chat" + ) + if (Qt5WebEngine_FOUND) + find_package(Qt5WebEngineWidgets QUIET) + set_package_properties(Qt5WebEngineWidgets PROPERTIES TYPE RECOMMENDED + URL "http://qt.digia.com" + DESCRIPTION "widgets for Qt's WebEngine implementation" + PURPOSE "Needed for displaying previews for URLs in chat" + ) + endif() + endif() + + if (WITH_WEBENGINE AND Qt5WebEngineWidgets_FOUND) + set(HAVE_WEBENGINE true) + endif() + add_feature_info("WITH_WEBENGINE, QtWebEngine and QtWebEngineWidgets modules" HAVE_WEBENGINE "Support showing previews for URLs in chat") + + # KDE Frameworks + ################ + + if (WITH_KDE) + set(ecm_find_type "REQUIRED") + else() + # Even with KDE integration disabled, we optionally use tier1 frameworks if we find them + set(ecm_find_type "RECOMMENDED") + endif() + + # extra-cmake-modules + find_package(ECM NO_MODULE QUIET) + set_package_properties(ECM PROPERTIES TYPE ${ecm_find_type} + URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules" + DESCRIPTION "extra modules for CMake, maintained by the KDE project" + PURPOSE "Required to find KDE Frameworks components" + ) + + if (ECM_FOUND) + list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + endif() + + if (WITH_KDE) + find_package(KF5 COMPONENTS ConfigWidgets CoreAddons Notifications NotifyConfig TextWidgets WidgetsAddons XmlGui QUIET) + set_package_properties(KF5 PROPERTIES TYPE REQUIRED + URL "http://www.kde.org" + DESCRIPTION "KDE Frameworks" + PURPOSE "Required for integration into the Plasma desktop" + ) + + endif() + + endif(BUILD_GUI) + + if (BUILD_CORE) + find_package(Qt5Script QUIET) + set_package_properties(Qt5Script PROPERTIES TYPE REQUIRED + DESCRIPTION "provides scripting support for Qt5" + ) + find_package(Qt5Sql QUIET) + set_package_properties(Qt5Sql PROPERTIES TYPE REQUIRED + DESCRIPTION "the database support module for Qt5" + ) + + find_package(QCA2-QT5) + set_package_properties(QCA2-QT5 PROPERTIES TYPE RECOMMENDED + URL "https://projects.kde.org/projects/kdesupport/qca" + DESCRIPTION "Qt Cryptographic Architecture" + PURPOSE "Required for encryption support" + ) + + endif(BUILD_CORE) + + find_package(Qt5LinguistTools QUIET) + set_package_properties(Qt5LinguistTools PROPERTIES TYPE RECOMMENDED + DESCRIPTION "contains tools for handling translation files" + PURPOSE "Required for having translations" + ) + + # Some Qt5 versions do not define a target for lconvert, so we need to find it ourselves + if (Qt5LinguistTools_FOUND) + if (NOT TARGET Qt5::lconvert AND TARGET Qt5::lrelease) + get_target_property(_lrelease_location Qt5::lrelease LOCATION) + get_filename_component(_lrelease_path ${_lrelease_location} PATH) + find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt5 lconvert PATHS ${_lrelease_path} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + elseif(TARGET Qt5::lconvert AND NOT Qt5_LCONVERT_EXECUTABLE) + # Newer Qt5 versions define the target, but not the Qt5_LCONVERT_EXECUTABLE variable for some reason + get_target_property(QT_LCONVERT_EXECUTABLE Qt5::lconvert LOCATION) + endif() + + # Compatibility with the Qt4 variables + set(QT_LRELEASE_EXECUTABLE ${Qt5_LRELEASE_EXECUTABLE}) + set(QT_LUPDATE_EXECUTABLE ${Qt5_LUPDATE_EXECUTABLE}) + if (Qt5_LCONVERT_EXECUTABLE) + set(QT_LCONVERT_EXECUTABLE ${Qt5_LCONVERT_EXECUTABLE}) + endif() + endif() + +else(USE_QT5) + message(STATUS "Building for Qt4...") + set(QT_MIN_VERSION "4.8.0") + + # Select a Qt installation here, if you don't want to use system Qt + if(QT_PATH) + # FindQt4 will look for the qmake binary in $PATH, so we just prepend QT_PATH + set(ENV{PATH} ${QT_PATH}/bin:$ENV{PATH}) + endif() + + find_package(Qt4 ${QT_MIN_VERSION} QUIET REQUIRED) + + if (BUILD_GUI) + add_feature_info("QtDBus module" QT_QTDBUS_FOUND "Needed for supporting D-Bus-based notifications and tray icon, used by most modern desktop environments") + if (QT_QTDBUS_FOUND) + find_package(dbusmenu-qt QUIET CONFIG) + set_package_properties(dbusmenu-qt PROPERTIES TYPE RECOMMENDED + URL "https://launchpad.net/libdbusmenu-qt" + DESCRIPTION "a library implementing the DBusMenu specification" + PURPOSE "Required for having a context menu for the D-Bus-based tray icon" + ) + endif() + + if (WITH_WEBKIT AND QT_QTWEBKIT_FOUND) + set(HAVE_WEBKIT true) + endif() + add_feature_info("WITH_WEBKIT and QtWebKit module" HAVE_WEBKIT "Support showing previews for URLs in chat") + + if (WITH_KDE) + # KDE has overzealous CFLAGS making miniz not compile, so save our old flags + set(_cflags ${CMAKE_C_FLAGS}) + find_package(KDE4 4.4 QUIET) + set_package_properties(KDE4 PROPERTIES TYPE REQUIRED + URL "http://www.kde.org" + DESCRIPTION "a world-class desktop environment" + PURPOSE "Enables various bits for improving integration with KDE" + ) + set(CMAKE_C_FLAGS ${_cflags}) + + else(WITH_KDE) + find_package(Phonon QUIET) + set_package_properties(Phonon PROPERTIES TYPE RECOMMENDED + URL "https://projects.kde.org/projects/kdesupport/phonon" + DESCRIPTION "a multimedia abstraction library" + PURPOSE "Required for audio notifications" + ) + endif(WITH_KDE) + + find_package(IndicateQt QUIET) + set_package_properties(IndicateQt PROPERTIES TYPE OPTIONAL + URL "https://launchpad.net/libindicate-qt/" + DESCRIPTION "a library to raise flags on DBus for other components of the desktop to pick up and visualize" + PURPOSE "Provides integration into the Ayatana notification system used by e.g. Ubuntu" + ) + + endif(BUILD_GUI) + + if (BUILD_CORE) + + find_package(QCA2 QUIET) + set_package_properties(QCA2 PROPERTIES TYPE RECOMMENDED + URL "https://projects.kde.org/projects/kdesupport/qca" + DESCRIPTION "Qt Cryptographic Architecture" + PURPOSE "Required for encryption support" + ) + + + endif() + + # Qt4 does not consider lconvert relevant, so they don't support finding it... + # Rather than shipping hacked buildsys files, let's just infer the path from lrelease + if (QT_LRELEASE_EXECUTABLE) + get_filename_component(_lrelease_path ${QT_LRELEASE_EXECUTABLE} PATH) + find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt4 lconvert PATHS ${_lrelease_path} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif() +endif() + + +# Non-Qt-based packages + +# zlib for compression, however we can always fall back to miniz +find_package(ZLIB QUIET) +set_package_properties(ZLIB PROPERTIES TYPE RECOMMENDED + URL "http://www.zlib.net" + DESCRIPTION "a popular compression library" + PURPOSE "Use the most common library for protocol compression, instead of the bundled miniz implementation" +) + + +if (NOT WIN32) + # Execinfo is needed for generating backtraces + find_package(ExecInfo QUIET) + set_package_properties(ExecInfo PROPERTIES TYPE OPTIONAL + DESCRIPTION "a library for inspecting backtraces" + PURPOSE "Used for generating backtraces in case of a crash" + ) +endif() + +# Check for SSL support in Qt +# As there's no easy way to get Qt's configuration in particular for Qt5, let's just compile +# a small test program checking the defines. This works for both Qt4 and Qt5. +cmake_push_check_state(RESET) +set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES} ${Qt5Core_INCLUDE_DIRS}) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +if (USE_QT5 AND Qt5_POSITION_INDEPENDENT_CODE) + set(CMAKE_REQUIRED_FLAGS "-fPIC -DQT_NO_VERSION_TAGGING") +endif() + +check_cxx_source_compiles(" + #include \"qglobal.h\" + #if defined QT_NO_SSL + # error \"No SSL support\" + #endif + int main() {}" + HAVE_SSL) +cmake_pop_check_state() + +# Additional compile settings +##################################################################### + +# This sets -fPIC and friends if required by the installed Qt5 library +if (USE_QT5 AND Qt5_POSITION_INDEPENDENT_CODE) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif() + +# Needed to compile with mingw without kde +if (MINGW AND NOT KDE4_FOUND) + add_definitions(-D_WIN32_WINNT=0x0500) + message(STATUS "Added _WIN32_WINNT=0x0500 definition for MinGW") + # workaround for bug in mingw gcc 4.0 + add_definitions(-U__STRICT_ANSI__) +endif() + +# Sanitize compiler flags - old versions of KDE set -ansi, which breaks -std=c++11 +if (CMAKE_COMPILER_IS_GNUCXX) + string(REPLACE "-ansi" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) +endif() + + +# Setup KDE / KDE Frameworks +##################################################################### + +# We want to do this up here, so we have the necessary variables and defines set before +# compiling anything + +if (KDE4_FOUND) + # We always use external icons for KDE4 support, since we use its iconloader rather than Qt's + set(EMBED_DATA OFF) + + # Better have the compile flags global, even for the core, to avoid problems with linking the mono client + add_definitions(-DHAVE_KDE -DHAVE_KDE4 ${KDE4_DEFINITIONS}) + set(WITH_KDE4 TRUE) +endif() + +if (USE_QT5 AND WITH_KDE) + # If KDE Frameworks are present, they're most probably providing Qt5 integration including icon loading + set(EMBED_DATA OFF) + + include(KDEInstallDirs) + include(KDECompilerSettings) + include(KDECMakeSettings) + + add_definitions(-DHAVE_KDE -DHAVE_KF5) + set(WITH_KF5 TRUE) +endif() + +# This needs to come after setting up KDE integration, so we can use KDE-specific paths +include(QuasselInstallDirs) + +# Various config-dependent checks and settings +##################################################################### + +if (NOT ZLIB_FOUND) + message(STATUS "zlib NOT found, using bundled miniz for compression") + if (${CMAKE_SIZEOF_VOID_P} EQUAL 4) + message(STATUS "WARNING: This may be slow on 32 bit systems!") + endif() +endif() + +if (HAVE_SSL) + add_definitions(-DHAVE_SSL) +endif() +add_feature_info("SSL support in Qt" HAVE_SSL "Use secure network connections") + +# Check for syslog support +if (NOT WIN32) + check_include_file(syslog.h HAVE_SYSLOG) + add_feature_info("syslog.h" HAVE_SYSLOG "Provide support for logging to the syslog") +endif() + +add_feature_info("Qt Linguist Tools" QT_LCONVERT_EXECUTABLE "Translation support for Quassel") + +if (EMBED_DATA) + message(STATUS "Embedding data files into the binary") +else() + message(STATUS "Installing data files separately") +endif() + +if (INDICATEQT_FOUND) + add_definitions(-DXDG_APPS_INSTALL_DIR=${CMAKE_INSTALL_APPDIR}) +endif() + +if (NOT WIN32) + check_function_exists(umask HAVE_UMASK) + if(HAVE_UMASK) + add_definitions(-DHAVE_UMASK) + endif(HAVE_UMASK) +endif() + + +# Windows-specific stuff +##################################################################### + +if (WIN32) + link_libraries(imm32 winmm dbghelp Secur32) # missing by default :/ + if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX") + set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBUGINFO "/debug /INCREMENTAL:YES /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:YES /NODEFAULTLIB:libcmt") + set(CMAKE_EXE_LINKER_FLAGS_DEBUGFULL "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") + link_libraries(Version dwmapi shlwapi) + if (USE_QT5) + set(QT_QTMAIN_LIBRARY Qt5::WinMain) + endif() + endif() + if(HAVE_SSL AND STATIC) + find_package(OpenSSL REQUIRED) + link_libraries(${OPENSSL_LIBRARIES} ${OPENSSL_EAY_LIBRARIES}) + endif() +endif() + + +# Static builds (very much non-portable, so don't use -DSTATIC +# unless you know what you do!) +##################################################################### + +if(STATIC AND CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}") + link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs + if (HAVE_SSL) + set(QUASSEL_SSL_LIBRARIES ssl crypto) # these miss in static builds + endif() +endif() + + +# Generate version information from Git +##################################################################### + +include(GetGitRevisionDescription) +get_git_head_revision(GIT_REFSPEC GIT_HEAD) +git_describe(GIT_DESCRIBE --long) + +# If in a Git repo we can get the commit-date from a git command +if (GIT_HEAD) + execute_process( + COMMAND git -c log.showsignature=false show -s --format=%ct + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() + +# If not in a Git repo try to read GIT_HEAD and GIT_DESCRIBE from +# enviroment +if (NOT GIT_HEAD OR NOT GIT_DESCRIBE) + if (DEFINED ENV{GIT_HEAD}) + set(GIT_HEAD $ENV{GIT_HEAD}) + endif () + if (DEFINED ENV{GIT_DESCRIBE}) + set(GIT_DESCRIBE $ENV{GIT_DESCRIBE}) + endif() +endif() + +# Sanitize things if we're not in a Git repo +if (NOT GIT_HEAD OR NOT GIT_DESCRIBE) + set(GIT_HEAD "") + set(GIT_DESCRIBE "") + set(GIT_COMMIT_DATE 0) +endif() + +configure_file(version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY) + +# Prepare the build +##################################################################### + +# These variables will be added to the main targets (CORE, QTCLIENT, MONO) +set(COMMON_DEPS ${RC_WIN32}) +set(CORE_DEPS ) +set(CLIENT_DEPS ) + +# Add needed subdirs - the order is important, since src needs some vars set by other dirs +add_subdirectory(data) +add_subdirectory(icons) +add_subdirectory(pics) +add_subdirectory(po) + + +# Set up and display feature summary +##################################################################### + +feature_summary(WHAT ALL + INCLUDE_QUIET_PACKAGES + FATAL_ON_MISSING_REQUIRED_PACKAGES +) + +# Finally, compile the sources +# We want this after displaying the feature summary to avoid ugly +# CMake backtraces in case a required Qt5 module is missing +##################################################################### + +add_subdirectory(src) diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..73ff929 --- /dev/null +++ b/COPYING @@ -0,0 +1,17 @@ + Quassel IRC, a next-generation distributed IRC Client +==================================================================== + + Copyright (C) 2005, 2006, 2007, 2008, 2009 by the Quassel IRC Team + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) version 3. + +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. + +The license texts for both the GPLv2 and GPLv3 are provided with this +source code release in the files "gpl-2.0.txt" and "gpl-3.0.txt". diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..567a8bc --- /dev/null +++ b/ChangeLog @@ -0,0 +1,424 @@ +ChangeLog for Quassel IRC +========================= +This is not a full ChangeLog, but rather an end-user FeatureLog that is supposed +to provide a list of new features between Quassel versions. As such, it only +contains end-user visible, mostly major new features. It does not contain (most) +bugfixes, nor is it guaranteed to be complete or up-to-date at all. Also, it does +start at 0.3.0 only, since this was the first version widely available. + +Please have a look at for a +list of closed bug/feature reports (which still does not cover bugs we have +fixed but which were never reported, of course), and for a full list of +changes, the git history at is your friend. + +Without further ado, let's start: + +Version 0.12.5 (2018-04-24) +=========================== + +* Make "/ " use the rest of the message as a literal +* Use commit date instead of build date to support reproducible builds +* Support Qt 5.6 through Qt 5.10 +* Automated OSX builds (via Travis) +* Update deployment and CI settings for OSX and Windows +* Better HIDPI support with recent Qt 5 versions +* Snapcraft packaging support +* Inxi version bump +* Prioritization of PING/PONG messages to prevent timeouts +* Improved touch screen support (scrolling etc.) +* WebEngine support for URL previews (deprecates WebKit support with Qt 5) +* Disable WebKit by default due to it being unmaintained and a security risk +* Strip format codes when checking for highlights +* Properly disconnect from networks when shutting down +* Reload SSL certificates on signal SIGHUP +* Add AppData metadata for quassel and quasselclient +* Allow channel buffer merges +* Improve dock and tray handling on OSX +* Split user messages on newlines, as per the RFC +* Join channels on double-click in platforms other than OSX and Windows +* Support Elliptic Curve keys for client<->core connections on Qt 5.5+ +* Add sanity checks for QDataStream deserialization (e.g. for size) +* Prevent clients from trying to login to an unconfigured core, avoiding a crash +* Various bugfixes +* Some code cleanups +* Translation updates + +Version 0.12.4 (2016-04-24) +=========================== + +* Handle STATUSMSG messages (recently abused for query spam) +* Link previews are enabled again in Windows builds +* Fix core crash caused by clients sending invalid handshake data +* Fix session management with Qt 5 +* Fix connection issues with non-compliant ircds +* Translation updates + +Version 0.12.3 (2016-02-09) +=========================== + +* Fix activity filters when selecting buffers in custom ChatViews +* Fix default shortcuts when integrated with KDE Frameworks +* Introduce support for Appveyor CI (automated Windows builds) +* Support SnoreNotify 0.7 +* Various cleanups and performance improvements +* Various build system fixes +* Channel keys are again remembered between syncs +* Support for Qt 5.5 +* Network (re)connection fixes +* Fix possible message loss when running multiple core users on a psql database +* Command line option for specifying SSL certificates and keys +* Many smaller fixes + +Version 0.12.2 (2015-04-23) +=========================== + +* Fix PostgreSQL not re-initializing after reconnect (raising CVE-2013-4422 from the dead) +* Remove warning on startup due to a change in Kdelibs4ConfigMigrator + +Version 0.12.1 (2015-04-21) +=========================== + +* Emergency fix for behavior change in Qt5's psql driver regarding timezones + +Version 0.12.0 (2015-04-15) +=========================== + +* Full support for KDE Frameworks +* Properly split messages with multi-byte encodings and/or encryption +* Improve core password hashing algorithm + NOTE: This upgrades the database schema, so no downgrades are possible! +* Remote password change +* Core connection improvements +* Build system improvements +* PostgreSQL connection improvements +* Improve Qt 5 support +* Qt 4.8+ or Qt 5.2+ now required +* Several tweaks and fixes +* Translation updates + +Version 0.11.0 (2014-09-23) +=========================== + +* New build requirements: + - C++11 capable compiler (gcc 4.7+, clang 3.3+, MSVC 2013+) + - cmake 2.8.9+ +* Full support for Qt 5.2+ in addition to Qt 4.6+ +* Completely revamp the build system, making use of "new" CMake features + +Version 0.10.1 (2014-09-23) +=========================== + +* Fix buffer hotlist sorting +* Split CTCP messages if they're too long +* Make database problems more obvious +* Fix backlog loading for QuasselDroid +* Properly save the toolbar state on Mac OSX +* Fix a crash with KDE's network detection +* Various other fixes + +Version 0.10.0 (2014-03-25) +=========================== + +* Refactor lots of the protocol and connection code +* Introduce connection probing for reliably negotiating protocol features +* Introduce the new DataStream protocol with streaming compression +* Option for forcing the core to only accept SSL connections +* Support for the Snore notification backend +* Allow searching the web for selected text +* Connection-related fixes +* Allow for hiding inactive networks +* Enable line wrap in the input field +* Show backlog messages in the Chat Monitor +* Remove SSL protocol selection, always use auto-negotiation for best results +* Highlight rules are now case-insensitive by default +* New and updated translations +* Bump inxi version (for /sysinfo) +* Use the raster rendering engine by default on OSX (should improve performance) + +Version 0.9.3 (2014-03-25) +========================== + +* Notification fixes +* Improve reliability of SSL connections +* Save toolbar state properly on Mac +* Prevent user interaction with the web preview +* Fix fullscreen mode +* Fix spurious crash caused by shaky ircd connections +* Fix adding an unneeded colon to custom commands +* Avoid Qt's DNS cache to properly handle round-robin DNS records + +Version 0.9.2 (2013-11-26) +========================== + +* Don't crash if /topic contains newlines +* Fix SSL-related issues +* Fix Phonon notifications not playing sound +* Pingout if connection drops during SASL auth phase +* Prevent messages from being sent to status buffers +* Make sure manipulated/buggy clients cannot access backlog of other core users +* Fix context menu issues + +Version 0.9.1 (2013-10-11) +========================== + +* Fix security issue with Qt 4.8.5 and PostgreSQL +* Phonon notifications for Mac OS X +* Convert tabs in messages into 8 spaces +* Silence superfluous QCA warnings +* Various key- and encryption-related fixes +* Ignore formatting in clickables +* Enable warnings when compiling with Clang +* Updated translations +* Various other small fixes and improvements + +Version 0.9.0 (2013-04-16) +========================== + +* Halfop support +* Channel-specific highlights +* Support for intermediate CA certificates +* Support the DockManager interface +* OSX Notification Center support +* DH1080 key exchange +* SASL EXTERNAL support +* Improvements for Retina displays on OSX +* Supporting to start minimized to tray +* Rudimentary support for Qt5 (obsolete again because upstream changed too much) +* Refactor of SignalProxy, network and protocol code +* First pieces of the coming protocol abstraction +* Build system improvements +* Various bugfixes +* New and updated translations +* Reformatted ALL the source code + +Version 0.8.0 (2012-03-20) +========================== + +* Make tab completion key configurable +* Syslog support for the core +* Make the core more robust against random invalid input +* oidentd support +* Build system improvements +* Many new and updated translations +* Various bugfixes + +Version 0.7.4 (2012-03-20) +-------------------------- + +* Improve keyboard navigation +* Bump Oxygen icons +* Conform with icon naming spec +* Remove JS support from webpreview +* Fix support for Qt 4.8 +* Several bugfixes and cleanups + +Version 0.7.3 (2011-09-08) +-------------------------- + +* Fix a core crash + +Version 0.7.2 (2011-03-24) +-------------------------- + +* PostgreSQL improvements +* Various bugfixes + +Version 0.7.1 (2010-09-21) +-------------------------- + +* Critical fixes for CTCP and connection handshake + +Version 0.7.0 (2010-09-14) +========================== + +* Improved DE integration, support for dbusmenu +* Bump Qt dependency: we need Qt 4.6 for client and monolithic now +* Fullscreen mode (F11) +* CTCP CLIENTINFO support +* Shortcuts for navigation between chats (Alt+Left/Right/Up/Down) +* Add blowfish encryption (/setkey and /delkey; needs QCA2) +* Shortcut editing for all platforms (!KDE) +* Improved handling of invites +* New tray icon for highlights +* Global away +* Emacs-style keybindings for the input line +* Improved markerline behavior + - Allow manual setting (Ctrl+R) + - Provide shortcut for jumping to the markerline (Ctrl+K) +* New languages: el, gl, ja +* Many bugfixes + +Version 0.6.1 (2010-04-16) +-------------------------- + +* Critical bugfixes + +Version 0.6.0 (2010-04-14) +========================== + +* New languages: en_GB, es, nl, oc, pt, pt_BR, sq, sv, uk, zh_CN +* Updated existing languages +* Restore last selected buffer on restart +* Optional per-chat history +* SASL authentication support (e.g. supported by Freenode) +* Allow inputting formatted (colored/bold/...) text in the inputline +* Support the StatusNotifierItem DBus spec + - Replace old-style tray icon where supported (currently KDE >= 4.4) + - Integrate freedesktop notifications support (libnotify or knotify) +* Systemtray refactoring + - Replace animation by blinking icon + - Properly handle notifications and mainwindow toggle +* Improved URL detection +* Sender column is now clickable (double click opens query) +* Improved notification handling +* ChatView performance improvements +* Many buildsystem fixes + - Improved handling of icons + - Updated cmake macros + - Support building with MinGW + - Support KDE on non-X11 platforms + - Better handling of SSL libraries +* Solid network state detection support (with KDE) +* Settingspage refactoring +* Improved handling of SSL certificates +* Completely reworked the client/core connection + - New settingspage for managing core accounts + - Streamlined login/sync process + - Configurable timeout + - Automatic reconnect to core +* Send unknown commands to server +* New stylesheets +* Use gettext for translations + +Version 0.5.2 (2010-01-18) +-------------------------- + +* CTCP ignore +* Buildsystem fixes + +Version 0.5.1 (2009-11-21) +-------------------------- + +* Many Bugfixes +* Updated translations +* Fix issues with Qt >= 4.6 + +Version 0.5.0 (2009-10-14) +========================== + +* Tons of bugfixes +* Many translation updates +* Use DrKonqi/Apport to provide backtraces in case of a crash +* Support for Ayatana's Message Indicator (libindicate; *buntu specific feature for now) +* Fix wordwrap issues +* Improved notification behavior (highlighted channels can now be cycled) +* Improved icon packaging (don't install them if KDE is available and current enough) +* Menubar can now be hidden (Ctrl+M to toggle) +* Ignore list support +* Vast performance improvements in the handling of synced objects + - Core startup/shutdown now almost instant + - Joining/leaving large channels much more efficient +* Netsplit detection +* New topic widget dynamically resizes to show all of the topic +* Usability tweaks + - Reworked configuration dialogs + - Renamed "Buffer" to "Chat" throughout in all user-visible strings +* Introduce stylesheet-based (QSS) styling for ChatView and the whole application +* Allow configuration of ping timeouts and auto-WHO +* Make toolbars configurable in KDE +* Alt+A shortcut for jumping to cycle through active buffers +* Properly remember the mainwindow state on shutdown/restart +* Multiline input support +* Improved systray notifications +* Lazy backlog fetching for hidden buffers +* Improved flood control +* Spell check support (requires KDE integration) +* /exec support for executing external scripts/programs +* CLI interface for managing core users with quasselcore rather than a script +* Improved ping timeout detection +* PostgreSQL database backend support +* Smart nickname completion (most recently active) + +Version 0.4.3 (2009-08-26) +-------------------------- + +* Bugfixes and translation updates + +Version 0.4.2 (2009-05-20) +-------------------------- + +* Bugfixes and translation updates + +Version 0.4.1 (2009-03-18) +-------------------------- + +* Bugfixes and translation updates + +Version 0.4.0 (2009-02-17) +========================== + +* Buffer view font can now be changed +* Colored nicknames +* Wizard for setting up identity and networks on first run +* Paste protection warns if you try to paste many lines +* Use login name and real name for default identity +* Add toolbar to main window +* Away log window showing highlighted messages while you're away +* Settings dialog streamlining +* Animated system tray icon +* Shiny new Oxygen icons all over the place, including our new app icon +* Build system improvements +* Put all config and data files in one location and make that configurable +* Allow presetting networks and a list of channels to join on first start +* Change and improve CLI argument handling +* All buffer views are now customizable +* Streamlined monolithic client +* Many usability improvements +* Method for easily hiding and unhiding buffers in buffer views +* Renaming and merging of query buffers +* Improved SSL certificate handling +* Optional support for KDE4 + - KNotify support + - KDE icon and color theme support + - Editable shortcuts +* Core now supports a proxy for connections to IRC +* Core supports SSL certs and keys for IRC connections +* Chat Monitor configuration dialog +* Audio notifications +* Clickable channel names in ChatView +* Context menus in ChatView and BufferViews +* Respect the separate clipboards (Ctrl+C / X11 selection) on X11 +* Improved mouse handling: + - Double/triple click selections + - Drag'n'Drop + +Version 0.3.1 (2008-11-20) +-------------------------- + +* Nick changes and day change messages can now be hidden +* Web previews and status icons can be disabled +* Icons for Online/Away/Offline status of queries +* Load Qt's default translations +* Add new settings for proper message redirection +* Add context menu to links +* Automatic backtraces on Windows +* Add russian translation +* Cut off the sender column on the left in ChatView +* Enable away on detach +* Backlog amount (initial and dynamic) can now be configured +* Shift Up/Down scrolls the ChatView +* Page Up/Down scrolls the ChatView +* ChatView Zoom with Ctrl + / Ctrl - +* Join/Part/Quit... events can now be hidden in ChatView +* Monolithic build features zero configuration: Click'n'Run +* Monolithic build now uses a proper (socket-less) internal connection +* Ctrl+L focuses input line +* Improve notification handling, use proper D-Bus notifications +* Day change messages in ChatView +* Web Preview on hovering over a link (requires QtWebkit) +* Allow icons to be installed externally, optionally use system Oxygen theme +* Improve URL handling in ChatView (underline, single-click invocation) + +Version 0.3.0 (2008-08-27) +========================== +The first widely available release of Quassel IRC. diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..d7495d3 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,286 @@ +# Doxyfile 1.5.3 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = "Quassel IRC " +PROJECT_NUMBER = Pre-Release +OUTPUT_DIRECTORY = doc +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class " \ + "The $name widget " \ + "The $name file " \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = YES +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = / +STRIP_FROM_INC_PATH = /home/sputnick/devel/local-quassel/ +SHORT_NAMES = YES +JAVADOC_AUTOBRIEF = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = YES +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 4 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +CPP_CLI_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = YES +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = YES +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = YES +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = NO +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = YES +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text " +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = src +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.C \ + *.CC \ + *.C++ \ + *.II \ + *.I++ \ + *.H \ + *.HH \ + *.H++ \ + *.CS \ + *.PHP \ + *.PHP3 \ + *.M \ + *.MM \ + *.C \ + *.H \ + *.tlh \ + *.diff \ + *.patch \ + *.moc \ + *.xpm \ + *.dox +RECURSIVE = YES +EXCLUDE = src/contrib +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = YES +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +HTML_DYNAMIC_SECTIONS = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = YES +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = /usr/include/qt4 +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = NO +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = quassel.tag +ALLEXTERNALS = YES +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = NO +MSCGEN_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = YES +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = YES diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..58b3159 --- /dev/null +++ b/INSTALL @@ -0,0 +1,134 @@ +Quassel IRC - Installation Notes +================================ + +These should help you to install Quassel IRC from source. Note that this focuses +mostly on building on Linux; please feel free to send patches for build +instructions on other platforms. We are not familiar with them. + +There are three versions of Quassel that can be built: + +* quasselcore - The server daemon. Typically runs on a headless server and + is permanently online. The core connects to IRC and stores + both settings and backlog. +* quasselclient - The GUI client. Requires a running quasselcore to connect to. + Upon connection, the client will fetch all session data and + a certain amount of backlog from the core and restore its + session almost as if you were never gone. +* quassel - This standalone version, often called "monolithic" or + "mono client", contains both a client and a core and can be + used like a "normal" IRC client, without having to setup + a server daemon. + +Prerequisites +------------- + +Of course, for building Quassel you need the usual set of build tools, for +example a compiler. As we use a subset of the C++11 standard, we require a +fairly recent compiler: + +- gcc 4.7+ (available for most platforms), or +- Clang 3.2+ (available for most platforms), or +- XCode 4.6+ (available for Max OS X and based on Clang), or +- Visual C++ Nov 2013 CTP (available for Windows™), or +- any other compiler with decent C++11 support + +Furthermore, CMake 2.8.9 or later is required (2.8.12 for KDE Frameworks). + +As Quassel is a Qt application, you need the Qt SDK, either Qt 4.8+ or Qt 5.2+. + +There are several optional dependencies; we will talk about that later. + +Compiling Quassel - short version +--------------------------------- + +Quassel uses CMake as its build system. The canonical way to build any CMake- +based project is as follows: + +cd /path/to/source +mkdir build +cd build +cmake .. +make +make install + +Compiling Quassel - long version +-------------------------------- + +First of all, it is highly recommended for any CMake-based project to be built +in a separate build directory rather than in-source. That way, your source +checkout remains pristine, and you can easily remove any build artifacts by just +deleting the build directory. This directory can be located anywhere; in the +short example above, we've just created a directory called "build" inside the +source checkout. + +From inside the build directory, you can then run the "cmake" command, followed +by the path to the source. Additionally, you can append various options. Note +that CMake caches the options you provide on the command line, so if you rerun +it later in the same build directory, you don't need to specify them again. + +Quassel supports several options to enable or disable features, and can make +use of several optional dependencies if installed. CMake will give a nice +summary of all that after its run, so we'll just mention the most important +options here: + +-DWANT_(CORE|QTCLIENT|MONO)=(ON|OFF) + Allow to choose which Quassel binaries to build. + +-DUSE_QT5=ON + Build against Qt5 instead of the default Qt4. Note that you should empty + your build directory when switching between Qt versions, otherwise weird + things may happen. + +-DWITH_KDE=ON + Enable integration into KDE4 (with Qt4) or KDE Frameworks (with Qt5). + +-DWITH_OXYGEN=(ON|OFF) + Install the parts of the Oxygen icon set Quassel uses. Oxygen is the default + icon set for KDE4, and thus already available on systems where KDE4 is + installed. By default, WITH_OXYGEN is ON iff WITH_KDE is OFF. If you are + sure that you have the icon set already installed on your system regardless, + use this option to disable installing the bundled icons. + +-DWITH_BREEZE=(ON|OFF) + Alternative icon set to Oxygen. + By default, WITH_BREEZE is OFF. + +-DWITH_BREEZE_DARK=(ON|OFF) + Alternative icon set to Oxygen. + By default, WITH_BREEZE_DARK is OFF. + +-DWITH_WEBENGINE=(ON|OFF) + Use WebEngine for showing previews of webpages linked in the chat. Requires + the QtWebEngine module to be available, and increases the client's RAM usage + by *a lot* if enabled at runtime. Only available for Qt5. The default is ON. + +-DWITH_WEBKIT=OFF + Use WebKit for showing previews of webpages linked in the chat. Requires + the QtWebKit module to be available, and increases the client's RAM usage + by *a lot* if enabled at runtime. + Note that WebKit support is deprecated and mostly unmaintained in Qt, and + should no longer be used for security reasons. The default is OFF. + +-DEMBED_DATA=(ON|OFF) + Specifies whether Quassel's data files (icons, translations and so on) + should be installed normally, or embedded into the binaries. The latter is + useful if you want to run Quassel from the build directory, or don't want + to use a standard installation. In particular, EMBED_DATA defaults to ON + on Windows and OS X, and to OFF on Linux. + +You can find the list of optional packages for additional features in CMake's +feature summary; install missing packages for enabling the functionality listed +in the explanation. If you want to forcefully disable an optional feature, use +-DCMAKE_DISABLE_FIND_PACKAGE_Foo=TRUE, where "Foo" is the package name listed. + +Quassel also supports the usual CMake options, most importantly + +-DCMAKE_INSTALL_PREFIX=/prefix/path - specify the installation prefix +-DCMAKE_BUILD_TYPE=(Debug|Release|RelWithDebug) - specify the build type + +If you want to narrow down the languages to be installed, you can set the +LINGUAS environment variable with a space-separated list of language codes, +for example LINGUAS="de en_US". + +After running CMake, you can just run "make" in the build directory, and +"make install" for installing the result into the installation prefix. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2c46718 --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +Quassel IRC [![Linux Build Status](https://travis-ci.org/quassel/quassel.svg?branch=master)](https://travis-ci.org/quassel/quassel) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/quassel/quassel?branch=master&svg=true)](https://ci.appveyor.com/project/quassel/quassel/branch/master) +=============== + +[Quassel IRC][web-home] is a modern, cross-platform, distributed IRC client, +meaning that one (or multiple) client(s) can attach to and detach from a +central core -- much like the popular combination of screen and a text-based +IRC client such as WeeChat, but graphical. + +Not only do we aim to bring a pleasurable, comfortable chatting experience to +all major platforms, but it's free - as in beer and as in speech, since we +distribute Quassel under [the GPL](https://www.gnu.org/licenses/gpl.html), and +you are welcome to download and see for yourself! + +## Release notes +You can find the current release notes on the [Quassel IRC homepage][web-home], +as well as in this repository's [```ChangeLog```][repo-changelog]. + +## Quick reference + +On first run of the Quassel core, it will wait for a client to connect +and present a first-run wizard that will allow you to create the database +and one admin user for the core-side storage. + +* To add more users, run: ```quasselcore --add-user``` +* To change the password of an existing user: ```quasselcore --change-userpass=username``` + +On some systems, you may need to specify ```--configdir```, e.g. +```quasselcore --configdir=/var/lib/quassel [command]```. + +The ```manageusers.py``` script is deprecated and should no longer be used. + +To learn more, see [the Quassel project wiki][docs-wiki] for in-depth +documentation. + +## Getting involved + +IRC is the preferred means of getting in touch with the developers. + +The Quassel IRC Team can be contacted on **```Freenode/#quassel```** +(or **```#quassel.de```**). If you have trouble getting Quassel to connect, +you can use [Freenode's webchat][help-freenode]. + +We always welcome new users in our channels! + +You can learn more and reach out to us in several ways: +* [Visit our homepage][web-home] +* [Submit and browse issues on the bugtracker][dev-bugs] + * Github issues are not used, but [pull requests][dev-pr-new] are accepted! +* [Email the dev team - devel@quassel-irc.org][dev-email] + +Thanks for reading, + +~ *The Quassel IRC Team* + +[web-home]: https://quassel-irc.org +[dev-bugs]: https://bugs.quassel-irc.org +[dev-email]: mailto:devel@quassel-irc.org +[dev-pr-new]: https://github.com/quassel/quassel/pull/new/master +[docs-wiki]: https://bugs.quassel-irc.org/projects/quassel-irc/wiki +[help-freenode]: https://webchat.freenode.net?channels=%23quassel +[repo-changelog]: ChangeLog diff --git a/appveyor.ini b/appveyor.ini new file mode 100644 index 0000000..8189a03 --- /dev/null +++ b/appveyor.ini @@ -0,0 +1,31 @@ +[General] +Command = craft +Branch = master +ShallowClone = True + +# Variables defined here override the default value +# The variable names are casesensitive +[Variables] +#Root = D:\qt-sdk + +# Settings applicable for all Crafts matrices +# Settings are Category/key=value +# Category is case sensitive +[GeneralSettings] +Paths/Python = C:\Python36 +Paths/Python27 = C:\Python27 +ShortPath/Enabled = False +Compile/BuildType = Release +ContinuousIntegration/Enabled = True +Packager/PackageType = MultiCollectionPackager + +[BlueprintSettings] +qt-apps/quassel.version = master + +binary/mysql.ignored = True + +[windows-msvc2017_32-cl] +General/ABI = windows-msvc2017_32-cl + +[windows-msvc2017_64-cl] +General/ABI = windows-msvc2017_64-cl diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..30d9dc1 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,38 @@ +version: '{build}' + +image: Visual Studio 2017 + +init: +- ps: | + function craft() { + & C:\python36\python.exe "C:\CraftMaster\$env:TARGET\craft\bin\craft.py" $args + if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE} + } + +install: +- ps: | + mkdir C:\CraftMaster | Out-Null + #use cmd to silence powershell behaviour for stderr + & cmd /C "git clone -q --depth=1 git://anongit.kde.org/craftmaster.git C:\CraftMaster\CraftMaster 2>&1" + & C:\python36\python.exe C:\CraftMaster\CraftMaster\CraftMaster.py --config $env:APPVEYOR_BUILD_FOLDER\appveyor.ini --target $env:TARGET + craft -p quassel + craft nsis + craft --install-deps quassel + +build_script: +- ps: | + craft --no-cache --src-dir $env:APPVEYOR_BUILD_FOLDER quassel + +test_script: +- ps: | + craft --src-dir $env:APPVEYOR_BUILD_FOLDER --test quassel + +on_success: +- ps: | + craft --src-dir $env:APPVEYOR_BUILD_FOLDER --package quassel + Get-ChildItem C:\CraftMaster\$env:TARGET\tmp\* | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } + +environment: + matrix: + - TARGET: windows-msvc2017_64-cl + - TARGET: windows-msvc2017_32-cl diff --git a/cmake/COPYING-CMAKE-SCRIPTS b/cmake/COPYING-CMAKE-SCRIPTS new file mode 100644 index 0000000..cb8a990 --- /dev/null +++ b/cmake/COPYING-CMAKE-SCRIPTS @@ -0,0 +1,26 @@ +This is the standard license for CMake scripts. Please note that some +of the CMake scripts we bundle come with their own license as indicated +in the file, in which case that one applies. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cmake/FindExecInfo.cmake b/cmake/FindExecInfo.cmake new file mode 100644 index 0000000..042a115 --- /dev/null +++ b/cmake/FindExecInfo.cmake @@ -0,0 +1,29 @@ +# Set up execinfo + +# The problem with this library is that it is built-in in the Linux glib, +# while on systems like FreeBSD, it is installed separately and thus needs to be linked to. +# Therefore, we search for the header to see if the it's available in the first place. +# If it is available, we try to locate the library to figure out whether it is built-in or not. + +find_path(EXECINFO_INCLUDES "execinfo.h") + +if(EXECINFO_INCLUDES STREQUAL "EXECINFO_INCLUDES-NOTFOUND") + set(EXECINFO_INCLUDES "") +else(EXECINFO_INCLUDES STREQUAL "EXECINFO_INCLUDES-NOTFOUND") + # We found the header file's include dir. + + # Now determine if it's built-in or not, by searching the library file. + find_library(EXECINFO_LIBRARIES "execinfo") + + if(EXECINFO_LIBRARIES STREQUAL "EXECINFO_LIBRARIES-NOTFOUND") + # Built-in, no further action is needed + set(EXECINFO_LIBRARIES "") + message(STATUS "Found execinfo (built-in)") + else(EXECINFO_LIBRARIES STREQUAL "EXECINFO_LIBRARIES-NOTFOUND") + # It's an external library. + message(STATUS "Found execinfo: ${EXECINFO_LIBRARIES}") + endif(EXECINFO_LIBRARIES STREQUAL "EXECINFO_LIBRARIES-NOTFOUND") + + set(EXECINFO_FOUND true) + +endif(EXECINFO_INCLUDES STREQUAL "EXECINFO_INCLUDES-NOTFOUND") diff --git a/cmake/FindIndicateQt.cmake b/cmake/FindIndicateQt.cmake new file mode 100644 index 0000000..5279c06 --- /dev/null +++ b/cmake/FindIndicateQt.cmake @@ -0,0 +1,28 @@ +# CMake wrapper for finding indicate-qt +# This is not very flexible (e.g. no version check), but allows using +# a normal find_package call and thus support for feature_summary +# +# (C) 2014 by the Quassel Project +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# +# Once found, sets the standard set of variables: +# INDICATEQT_FOUND - IndicateQt available in the system +# INDICATEQT_LIBRARIES - Libraries to link with +# INDICATEQT_INCLUDE_DIRS - Include directories containing the headers +# +############################################################################## + +include(FindPackageHandleStandardArgs) + +if (USE_QT4) + # requires PkgConfig for now; patches for finding it directly welcome! + find_package(PkgConfig QUIET) + if (PKG_CONFIG_FOUND) + pkg_check_modules(INDICATEQT QUIET indicate-qt>=0.2.1) + endif() +endif() + +find_package_handle_standard_args(IndicateQt DEFAULT_MSG INDICATEQT_LIBRARIES INDICATEQT_INCLUDE_DIRS) +mark_as_advanced(INDICATEQT_LIBRARIES INDICATEQT_INCLUDE_DIRS) diff --git a/cmake/FindLibraryWithDebug.cmake b/cmake/FindLibraryWithDebug.cmake new file mode 100644 index 0000000..58cd730 --- /dev/null +++ b/cmake/FindLibraryWithDebug.cmake @@ -0,0 +1,113 @@ +# +# FIND_LIBRARY_WITH_DEBUG +# -> enhanced FIND_LIBRARY to allow the search for an +# optional debug library with a WIN32_DEBUG_POSTFIX similar +# to CMAKE_DEBUG_POSTFIX when creating a shared lib +# it has to be the second and third argument + +# Copyright (c) 2007, Christian Ehrlicher, +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +MACRO(FIND_LIBRARY_WITH_DEBUG var_name win32_dbg_postfix_name dgb_postfix libname) + + IF(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX") + + # no WIN32_DEBUG_POSTFIX -> simply pass all arguments to FIND_LIBRARY + FIND_LIBRARY(${var_name} + ${win32_dbg_postfix_name} + ${dgb_postfix} + ${libname} + ${ARGN} + ) + + ELSE(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX") + + IF(NOT WIN32) + # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX + + FIND_LIBRARY(${var_name} ${libname} ${ARGN}) + + ELSE(NOT WIN32) + + # 1. get all possible libnames + SET(args ${ARGN}) + SET(newargs "") + SET(libnames_release "") + SET(libnames_debug "") + + LIST(LENGTH args listCount) + + IF("${libname}" STREQUAL "NAMES") + SET(append_rest 0) + LIST(APPEND args " ") + + FOREACH(i RANGE ${listCount}) + LIST(GET args ${i} val) + + IF(append_rest) + LIST(APPEND newargs ${val}) + ELSE(append_rest) + IF("${val}" STREQUAL "PATHS") + LIST(APPEND newargs ${val}) + SET(append_rest 1) + ELSE("${val}" STREQUAL "PATHS") + LIST(APPEND libnames_release "${val}") + LIST(APPEND libnames_debug "${val}${dgb_postfix}") + ENDIF("${val}" STREQUAL "PATHS") + ENDIF(append_rest) + + ENDFOREACH(i) + + ELSE("${libname}" STREQUAL "NAMES") + + # just one name + LIST(APPEND libnames_release "${libname}") + LIST(APPEND libnames_debug "${libname}${dgb_postfix}") + + SET(newargs ${args}) + + ENDIF("${libname}" STREQUAL "NAMES") + + # search the release lib + FIND_LIBRARY(${var_name}_RELEASE + NAMES ${libnames_release} + ${newargs} + ) + + # search the debug lib + FIND_LIBRARY(${var_name}_DEBUG + NAMES ${libnames_debug} + ${newargs} + ) + + IF(${var_name}_RELEASE AND ${var_name}_DEBUG) + + # both libs found + SET(${var_name} optimized ${${var_name}_RELEASE} + debug ${${var_name}_DEBUG}) + + ELSE(${var_name}_RELEASE AND ${var_name}_DEBUG) + + IF(${var_name}_RELEASE) + + # only release found + SET(${var_name} ${${var_name}_RELEASE}) + + ELSE(${var_name}_RELEASE) + + # only debug (or nothing) found + SET(${var_name} ${${var_name}_DEBUG}) + + ENDIF(${var_name}_RELEASE) + + ENDIF(${var_name}_RELEASE AND ${var_name}_DEBUG) + + MARK_AS_ADVANCED(${var_name}_RELEASE) + MARK_AS_ADVANCED(${var_name}_DEBUG) + + ENDIF(NOT WIN32) + + ENDIF(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX") + +ENDMACRO(FIND_LIBRARY_WITH_DEBUG) diff --git a/cmake/FindPhonon.cmake b/cmake/FindPhonon.cmake new file mode 100644 index 0000000..cd9e5cb --- /dev/null +++ b/cmake/FindPhonon.cmake @@ -0,0 +1,37 @@ +# Find libphonon +# Once done this will define +# +# PHONON_FOUND - system has Phonon Library +# PHONON_INCLUDES - the Phonon include directory +# PHONON_LIBS - link these to use Phonon +# PHONON_VERSION - the version of the Phonon Library + +# Copyright (c) 2008, Matthias Kretz +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +macro(_phonon_find_version) + set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/phonon/phononnamespace.h") + if (APPLE AND EXISTS "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h") + set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h") + endif (APPLE AND EXISTS "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h") + file(READ ${_phonon_namespace_header_file} _phonon_header LIMIT 5000 OFFSET 1000) + string(REGEX MATCH "define PHONON_VERSION_STR \"(4\\.[0-9]+\\.[0-9a-z]+)\"" _phonon_version_match "${_phonon_header}") + set(PHONON_VERSION "${CMAKE_MATCH_1}") +endmacro(_phonon_find_version) + +# the dirs listed with HINTS are searched before the default sets of dirs +find_library(PHONON_LIBRARY NAMES phonon HINTS ${KDE4_LIB_INSTALL_DIR} ${QT_LIBRARY_DIR}) +find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h HINTS ${KDE4_INCLUDE_INSTALL_DIR} ${QT_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} ${QT_LIBRARY_DIR}) + +if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY) + set(PHONON_LIBS ${phonon_LIB_DEPENDS} ${PHONON_LIBRARY}) + set(PHONON_INCLUDES ${PHONON_INCLUDE_DIR}/KDE ${PHONON_INCLUDE_DIR}) + _phonon_find_version() +endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Phonon DEFAULT_MSG PHONON_INCLUDE_DIR PHONON_LIBRARY) + +mark_as_advanced(PHONON_INCLUDE_DIR PHONON_LIBRARY) diff --git a/cmake/FindQCA2-QT5.cmake b/cmake/FindQCA2-QT5.cmake new file mode 100644 index 0000000..e4a4888 --- /dev/null +++ b/cmake/FindQCA2-QT5.cmake @@ -0,0 +1,61 @@ +# - Try to find QCA2 (Qt Cryptography Architecture 2) for QT5 +# Once done this will define +# +# QCA2-QT5_FOUND - system has QCA2-QT5 +# QCA2-QT5_INCLUDE_DIR - the QCA2-QT5 include directory +# QCA2-QT5_LIBRARIES - the libraries needed to use QCA2-QT5 +# QCA2-QT5_DEFINITIONS - Compiler switches required for using QCA2-QT5 +# +# use pkg-config to get the directories and then use these values +# in the FIND_PATH() and FIND_LIBRARY() calls + +# Copyright (c) 2006, Michael Larouche, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +include(FindPackageHandleStandardArgs) + +find_package(Qca-qt5 QUIET) +if(Qca-qt5_FOUND) + + set(QCA2-QT5_INCLUDE_DIR ${CMAKE_PREFIX_PATH}/include)#just to have any value as the real include dir is imported by linking to qca-qt5 + set(QCA2-QT5_LIBRARIES qca-qt5) + + find_package_handle_standard_args(QCA2-QT5 DEFAULT_MSG QCA2-QT5_LIBRARIES QCA2-QT5_INCLUDE_DIR) + + mark_as_advanced(QCA2-QT5_INCLUDE_DIR QCA2-QT5_LIBRARIES) +else() + +include(FindLibraryWithDebug) + +if (QCA2-QT5_INCLUDE_DIR AND QCA2-QT5_LIBRARIES) + + # in cache already + set(QCA2-QT5_FOUND TRUE) + +else (QCA2-QT5_INCLUDE_DIR AND QCA2-QT5_LIBRARIES) + + + if (NOT WIN32) + find_package(PkgConfig) + pkg_check_modules(PC_QCA2-QT5 QUIET qca2-qt5) + set(QCA2-QT5_DEFINITIONS ${PC_QCA2-QT5_CFLAGS_OTHER}) + endif (NOT WIN32) + + find_library_with_debug(QCA2-QT5_LIBRARIES + WIN32_DEBUG_POSTFIX d + NAMES qca-qt5 + HINTS ${PC_QCA2-QT5_LIBDIR} ${PC_QCA2-QT5_LIBRARY_DIRS} + ) + + find_path(QCA2-QT5_INCLUDE_DIR QtCrypto + HINTS ${PC_QCA2-QT5_INCLUDEDIR} ${PC_QCA2-QT5_INCLUDE_DIRS} + PATH_SUFFIXES QtCrypto) + + find_package_handle_standard_args(QCA2-QT5 DEFAULT_MSG QCA2-QT5_LIBRARIES QCA2-QT5_INCLUDE_DIR) + + mark_as_advanced(QCA2-QT5_INCLUDE_DIR QCA2-QT5_LIBRARIES) + +endif (QCA2-QT5_INCLUDE_DIR AND QCA2-QT5_LIBRARIES) +endif() diff --git a/cmake/FindQCA2.cmake b/cmake/FindQCA2.cmake new file mode 100644 index 0000000..e2d8f2a --- /dev/null +++ b/cmake/FindQCA2.cmake @@ -0,0 +1,48 @@ +# - Try to find QCA2 (Qt Cryptography Architecture 2) +# Once done this will define +# +# QCA2_FOUND - system has QCA2 +# QCA2_INCLUDE_DIR - the QCA2 include directory +# QCA2_LIBRARIES - the libraries needed to use QCA2 +# QCA2_DEFINITIONS - Compiler switches required for using QCA2 +# +# use pkg-config to get the directories and then use these values +# in the FIND_PATH() and FIND_LIBRARY() calls + +# Copyright (c) 2006, Michael Larouche, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +include(FindLibraryWithDebug) + +if (QCA2_INCLUDE_DIR AND QCA2_LIBRARIES) + + # in cache already + set(QCA2_FOUND TRUE) + +else (QCA2_INCLUDE_DIR AND QCA2_LIBRARIES) + + + if (NOT WIN32) + find_package(PkgConfig) + pkg_check_modules(PC_QCA2 QUIET qca2) + set(QCA2_DEFINITIONS ${PC_QCA2_CFLAGS_OTHER}) + endif (NOT WIN32) + + find_library_with_debug(QCA2_LIBRARIES + WIN32_DEBUG_POSTFIX d + NAMES qca + HINTS ${PC_QCA2_LIBDIR} ${PC_QCA2_LIBRARY_DIRS} + ) + + find_path(QCA2_INCLUDE_DIR QtCrypto + HINTS ${PC_QCA2_INCLUDEDIR} ${PC_QCA2_INCLUDE_DIRS} + PATH_SUFFIXES QtCrypto) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(QCA2 DEFAULT_MSG QCA2_LIBRARIES QCA2_INCLUDE_DIR) + + mark_as_advanced(QCA2_INCLUDE_DIR QCA2_LIBRARIES) + +endif (QCA2_INCLUDE_DIR AND QCA2_LIBRARIES) diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 0000000..10e3707 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,124 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_DIR "${CMAKE_SOURCE_DIR}/.git") + if(NOT EXISTS "${GIT_DIR}") # .git dir not found + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${hash} + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + message(STATUS "RES ${res} OUT ${out}") + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 0000000..888ce13 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,38 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") + configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + set(HEAD_HASH "${HEAD_REF}") + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/cmake/QuasselCompileSettings.cmake b/cmake/QuasselCompileSettings.cmake new file mode 100644 index 0000000..f48dfb2 --- /dev/null +++ b/cmake/QuasselCompileSettings.cmake @@ -0,0 +1,87 @@ +# This file contains compile flags and general build configuration for Quassel +# +# (C) 2014 by the Quassel Project +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +include(CheckCXXCompilerFlag) + +if (CMAKE_CONFIGURATION_TYPES) + set(CMAKE_CONFIGURATION_TYPES Release RelWithDebInfo Debug Debugfull Profile) + set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "These are the configuration types we support" FORCE) +endif() + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo Debug Debugfull Profile" FORCE) +endif() + +# Qt debug flags +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG QT_DEBUG) +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUGFULL QT_DEBUG) +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG NDEBUG) +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG NDEBUG) +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_PROFILE QT_NO_DEBUG NDEBUG) +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG NDEBUG) + +if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_DEBUG NDEBUG) +endif() + +# Enable various flags on gcc +if (CMAKE_COMPILER_IS_GNUCXX) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7") + message(WARNING "Your compiler is too old; we expect at least GCC 4.7. Your build will likely fail.") + endif() + + # Let's just hope that all gccs support these options and skip the tests... + # -fno-strict-aliasing is needed apparently for Qt < 4.6 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wnon-virtual-dtor -fno-strict-aliasing -Wundef -Wcast-align -Wpointer-arith -Wformat-security -fno-check-new -fno-common") + # set(CMAKE_CXX_FLAGS_RELEASE "-O2") # use CMake default + # set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2") # use CMake default + set(CMAKE_CXX_FLAGS_DEBUG "-g -ggdb -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline") + set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -ggdb -fno-inline") + set(CMAKE_CXX_FLAGS_PROFILE "-g3 -ggdb -fno-inline -ftest-coverage -fprofile-arcs") + + check_cxx_compiler_flag(-Woverloaded-virtual CXX_W_OVERLOADED_VIRTUAL) + if(CXX_W_OVERLOADED_VIRTUAL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual") + endif() + + # Just for miniz + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function -Wno-undef -fno-strict-aliasing") + +# ... and for Clang +elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.1") + message(WARNING "Your compiler is too old; we expect at least Clang 3.1. Your build will likely fail.") + endif() + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wextra -Wpointer-arith -Wformat-security -Woverloaded-virtual -fno-common -Wno-deprecated-register") + # set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG") # Use CMake default + # set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DQT_NO_DEBUG") # Use CMake default + set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-inline") + set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline") + set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs") + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function -Wno-undef -fno-strict-aliasing") + +# For MSVC, at least do a version sanity check... +elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "18.0") + message(WARNING "Your compiler is too old; we expect at least Visual Studio Nov 2013 CTP (MSVC 18). Your build will likely fail.") + endif() + + # ... and enable exception handling (required for STL types) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") + +# Unknown/unsupported compiler +else() + message(WARNING "Unknown or unsupported compiler. Make sure to enable C++11 support. Good luck.") +endif() + +# Mac build stuff +if (APPLE AND DEPLOY) + set(CMAKE_OSX_ARCHITECTURES "x86_64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.9 -stdlib=libc++") +endif() diff --git a/cmake/QuasselInstallDirs.cmake b/cmake/QuasselInstallDirs.cmake new file mode 100644 index 0000000..9075a80 --- /dev/null +++ b/cmake/QuasselInstallDirs.cmake @@ -0,0 +1,65 @@ +# This file sets up install locations for Quassel +# +# (C) 2015 by the Quassel Project +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +# Setup install locations +##################################################################### + +# We support the CMake standard variables (CMAKE_INSTALL__DIR), +# which can be overridden on the command line. If KDE integration is enabled, +# we make use of its settings. + +if (NOT WITH_KDE) + if (WIN32) + # On Windows, we have to guess good paths + # We must check if the variables are already defined on the command line + if (NOT DEFINED CMAKE_INSTALL_BINDIR) + set(CMAKE_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Install path for binaries") + endif() + if (NOT DEFINED CMAKE_INSTALL_DATADIR) + set(CMAKE_INSTALL_DATADIR "$ENV{APPDATA}/quassel-irc.org/share/apps" CACHE PATH "Install path for data files") + endif() + if (NOT DEFINED CMAKE_INSTALL_ICONDIR) + set(CMAKE_INSTALL_ICONDIR "$ENV{APPDATA}/quassel-irc.org/share/icons" CACHE PATH "Install path for icons") + endif() + if (NOT DEFINED CMAKE_INSTALL_APPDIR) + set(CMAKE_INSTALL_APPDIR "$ENV{APPDATA}/quassel-irc.org/share/applications" CACHE PATH "Install path for .desktop files") + endif() + else() + # This sets the standard variables; however it doesn't know about icons and apps + include(GNUInstallDirs) + + # Special treatment for paths relative to DATAROOTDIR, as found in GNUInstallDirs + if (NOT CMAKE_INSTALL_ICONDIR) + set(CMAKE_INSTALL_ICONDIR "" CACHE PATH "Install path for icons") + set(CMAKE_INSTALL_ICONDIR "${CMAKE_INSTALL_DATAROOTDIR}/icons") + endif() + if (NOT CMAKE_INSTALL_APPDIR) + set(CMAKE_INSTALL_APPDIR "" CACHE PATH "Install path for .desktop files") + set(CMAKE_INSTALL_APPDIR "${CMAKE_INSTALL_DATAROOTDIR}/applications") + endif() + endif() +else() + if (WITH_KDE4) + # FindKDE4Internal.cmake sets its own set of variables, however with deprecated names + if (NOT DEFINED CMAKE_INSTALL_BINDIR) + set(CMAKE_INSTALL_BINDIR "${BIN_INSTALL_DIR}" CACHE PATH "Install path for binaries") + endif() + if (NOT DEFINED CMAKE_INSTALL_DATADIR) + set(CMAKE_INSTALL_DATADIR "${DATA_INSTALL_DIR}" CACHE PATH "Install path for data files") + endif() + if (NOT DEFINED CMAKE_INSTALL_ICONDIR) + set(CMAKE_INSTALL_ICONDIR "${ICON_INSTALL_DIR}" CACHE PATH "Install path for icons") + endif() + if (NOT DEFINED CMAKE_INSTALL_APPDIR) + set(CMAKE_INSTALL_APPDIR "${XDG_APPS_INSTALL_DIR}" CACHE PATH "Install path for .desktop files") + endif() + endif() + + # KF5 does the correct thing, so we don't need to do anything + # We have already included KDEInstallDirs at this point. +endif() diff --git a/cmake/QuasselMacros.cmake b/cmake/QuasselMacros.cmake new file mode 100644 index 0000000..652c004 --- /dev/null +++ b/cmake/QuasselMacros.cmake @@ -0,0 +1,125 @@ +# This file contains various macros useful for building Quassel. +# +# (C) 2014 by the Quassel Project +# +# The qt4_use_modules function was taken from CMake's Qt4Macros.cmake: +# (C) 2005-2009 Kitware, Inc. +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +############################ +# Macros for dealing with Qt +############################ + +# CMake gained this function in 2.8.10. To be able to use older versions, we've copied +# this here. If present, the function from CMake will take precedence and our copy will be ignored. +function(qt4_use_modules _target _link_type) + if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE") + set(modules ${ARGN}) + set(link_type ${_link_type}) + else() + set(modules ${_link_type} ${ARGN}) + endif() + foreach(_module ${modules}) + string(TOUPPER ${_module} _ucmodule) + set(_targetPrefix QT_QT${_ucmodule}) + if (_ucmodule STREQUAL QAXCONTAINER OR _ucmodule STREQUAL QAXSERVER) + if (NOT QT_Q${_ucmodule}_FOUND) + message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.") + endif() + set(_targetPrefix QT_Q${_ucmodule}) + else() + if (NOT QT_QT${_ucmodule}_FOUND) + message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.") + endif() + if ("${_ucmodule}" STREQUAL "MAIN") + message(FATAL_ERROR "Can not use \"${_module}\" module with qt4_use_modules.") + endif() + endif() + target_link_libraries(${_target} ${link_type} ${${_targetPrefix}_LIBRARIES}) + set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${${_targetPrefix}_INCLUDE_DIR} ${QT_HEADERS_DIR} ${QT_MKSPECS_DIR}/default) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${${_targetPrefix}_COMPILE_DEFINITIONS}) + endforeach() +endfunction() + +# Some wrappers for simplifying dual-Qt support + +function(qt_use_modules) + if (USE_QT5) + qt5_use_modules(${ARGN}) + else() + qt4_use_modules(${ARGN}) + endif() +endfunction() + +function(qt_wrap_ui _var) + if (USE_QT5) + qt5_wrap_ui(var ${ARGN}) + else() + qt4_wrap_ui(var ${ARGN}) + endif() + set(${_var} ${${_var}} ${var} PARENT_SCOPE) +endfunction() + +function(qt_add_resources _var) + if (USE_QT5) + qt5_add_resources(var ${ARGN}) + else() + qt4_add_resources(var ${ARGN}) + endif() + set(${_var} ${${_var}} ${var} PARENT_SCOPE) +endfunction() + +function(qt_add_dbus_interface _var) + if (USE_QT5) + qt5_add_dbus_interface(var ${ARGN}) + else() + qt4_add_dbus_interface(var ${ARGN}) + endif() + set(${_var} ${${_var}} ${var} PARENT_SCOPE) +endfunction() + +function(qt_add_dbus_adaptor _var) + if (USE_QT5) + qt5_add_dbus_adaptor(var ${ARGN}) + else() + qt4_add_dbus_adaptor(var ${ARGN}) + endif() + set(${_var} ${${_var}} ${var} PARENT_SCOPE) +endfunction() + +###################################### +# Macros for dealing with translations +###################################### + +# This generates a .ts from a .po file +macro(generate_ts outvar basename) + set(input ${basename}.po) + set(output ${CMAKE_BINARY_DIR}/po/${basename}.ts) + add_custom_command(OUTPUT ${output} + COMMAND ${QT_LCONVERT_EXECUTABLE} + ARGS -i ${input} + -of ts + -o ${output} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po +# This is a workaround to add (duplicate) strings that lconvert missed to the .ts + COMMAND ${QT_LUPDATE_EXECUTABLE} + ARGS -silent + ${CMAKE_SOURCE_DIR}/src/ + -ts ${output} + DEPENDS ${basename}.po) + set(${outvar} ${output}) +endmacro(generate_ts outvar basename) + +# This generates a .qm from a .ts file +macro(generate_qm outvar basename) + set(input ${CMAKE_BINARY_DIR}/po/${basename}.ts) + set(output ${CMAKE_BINARY_DIR}/po/${basename}.qm) + add_custom_command(OUTPUT ${output} + COMMAND ${QT_LRELEASE_EXECUTABLE} + ARGS -silent + ${input} + DEPENDS ${basename}.ts) + set(${outvar} ${output}) +endmacro(generate_qm outvar basename) diff --git a/cmake/README b/cmake/README new file mode 100644 index 0000000..b53bc32 --- /dev/null +++ b/cmake/README @@ -0,0 +1,5 @@ +We bundle some CMake scripts that are not part of CMake itself, for convenience +on platforms that do not have a standard location for packages to put their +CMake support into. Most of those scripts originate from the KDE community; +some are from other sources. Please see the files themselves for copyright +and license statements. diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt new file mode 100644 index 0000000..5c6762d --- /dev/null +++ b/data/CMakeLists.txt @@ -0,0 +1,30 @@ +if (BUILD_GUI) + if (KDE4_FOUND OR (UNIX AND NOT APPLE)) + if (WANT_QTCLIENT) + install(FILES quasselclient.desktop DESTINATION ${CMAKE_INSTALL_APPDIR}) + endif() + + if (WANT_MONO) + install(FILES quassel.desktop DESTINATION ${CMAKE_INSTALL_APPDIR}) + endif() + + if (WITH_KDE4) + install(FILES quassel.notifyrc DESTINATION ${CMAKE_INSTALL_DATADIR}/quassel) + endif() + + if (WITH_KF5) + install(FILES quassel.notifyrc DESTINATION ${CMAKE_INSTALL_KNOTIFY5RCDIR}) + endif() + endif() + + if (EMBED_DATA) + set(CLIENT_RCS ${CLIENT_RCS} ${CMAKE_CURRENT_SOURCE_DIR}/data.qrc PARENT_SCOPE) + else() + install(FILES networks.ini DESTINATION ${CMAKE_INSTALL_DATADIR}/quassel) + install(DIRECTORY stylesheets DESTINATION ${CMAKE_INSTALL_DATADIR}/quassel) + endif() + + if (NOT WIN32) + install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_DATADIR}/quassel USE_SOURCE_PERMISSIONS) + endif() +endif() diff --git a/data/data.qrc b/data/data.qrc new file mode 100644 index 0000000..78a9ed8 --- /dev/null +++ b/data/data.qrc @@ -0,0 +1,6 @@ + + + stylesheets/default.qss + networks.ini + + diff --git a/data/networks.ini b/data/networks.ini new file mode 100644 index 0000000..f860d35 --- /dev/null +++ b/data/networks.ini @@ -0,0 +1,51 @@ +; This is a list of popular IRC networks. +; Feel free to send comments and suggestions to devel quassel-irc.org. + +; To have Quassel add a network by default and join some channels on first connect, put +; the following in the network's section: +; Default=Yes +; DefaultChannels=#channel1,#channel2,#channel3 + +[Aniverse] +Servers=irc.aniverse.com:6661 + +[DALnet] +Servers=irc.dal.net:6660,mesra.kl.my.dal.net:6665,mesra.kl.my.dal.net:7000,hotspeed.sg.as.dal.net:6665,hotspeed.sg.as.dal.net:7000,powertech.no.eu.dal.net:6665,powertech.no.eu.dal.net:7000,rumble.fl.us.dal.net:6665,rumble.fl.us.dal.net:7000,broadway.ny.us.dal.net:6665,broadway.ny.us.dal.net:7000 + +[EFnet] +Servers=irc.efnet.info:6667,irc.efnet.org:6667,irc.inter.net.il:6667,irc.igs.ca:6665,irc.inet.tele.dk:6661,efnet.cs.hut.fi:6667,irc.pte.hu:6665,irc.pte.hu:7000,irc.pte.hu:9000,efnet.xs4all.nl:6661,irc.efnet.nl:6660,irc.homelien.no:6666,irc.homelien.no:6667,irc.homelien.no:7000,irc.daxnet.no:6666,irc.daxnet.no:7000,irc.efnet.pl:6667,irc.du.se:6666,irc.du.se:7000,efnet.demon.co.uk:6665,irc.blackened.com:6665,irc.easynews.com:6660,irc.easynews.com:6665,irc.easynews.com:7000,irc.blessed.net:6665,irc.he.net:6665,irc.he.net:7000,irc.prison.net:6666,irc.wh.verio.net:6665,irc.colosolutions.net:6665,irc.colosolutions.net:7000,irc.mindspring.com:6660,irc.mindspring.com:7000,irc.servercentral.net:6660,irc.servercentral.net:7000,irc.umich.edu:6664,irc.umn.edu:6665,irc.choopa.net:6666,irc.choopa.net:7000,irc.nac.net:6665,irc.nac.net:7000 + +[EntertheGame] +Servers=irc.enterthegame.com:6667 + +[Freenode] +Default=Yes +DefaultChannels=#quassel +Servers=chat.freenode.net:6665,chat.freenode.net:7000 + +[GalaxyNet] +Servers=irc.galaxynet.org:6662,irc.galaxynet.org:7000,boston.ma.us.galaxynet.org:6661 + +[GameSurge] +Servers=irc.gamesurge.net:6667,irc.eu.gamesurge.net:6667 + +[GamesNET] +Servers=irc.gamesnet.net:6667 + +[IRCnet] +Servers=irc.ircnet.com:6667,open.ircnet.net:6666,irc.us.ircnet.net:6665,ircnet.netvision.net.il:6666,irc.tokyo.wide.ad.jp:6666,irc.freebsd.org.tw:6666,linz.irc.at:6666,vienna.irc.at:6666,ircnet.realroot.be:6666,irc.datacomm.ch:6664,irc.felk.cvut.cz:6667,random.ircd.de:6666,irc.dotsrc.org:6666,irc.ircnet.ee:6666,irc.cs.hut.fi:6667,ircnet.club-internet.fr:6666,atw.irc.hu:6667,irc.simnet.is:6660,irc.eutelia.it:6664,irc.eutelia.it:7000,irc.tin.it:6665,irc.apollo.lv:6666,irc.apollo.lv:7000,irc.uunet.nl:6660,irc.xs4all.nl:6660,irc.snt.utwente.nl:6660,irc.ifi.uio.no:6667,irc.pvv.ntnu.no:6667,lublin.irc.pl:6666,warszawa.irc.pl:6666,irc.ludd.luth.se:6661,irc.swipnet.se:6660,irc.swipnet.se:8000,irc.arnes.si:6666,irc.link.si:6666,irc.nextra.sk:6666,ircnet.demon.co.uk:6665,ircnet.eversible.com:6665,ircnet.choopa.net:6665 + +[Mozilla] +Servers=irc.mozilla.org:6667 + +[OFTC] +Servers=irc.oftc.net:6667 + +[QuakeNet] +Servers=irc.quakenet.org:6667,de.quakenet.org:6667,se.quakenet.org:6667,uk.quakenet.org:6667,us.quakenet.org:6667 + +[Undernet] +Servers=eu.undernet.org:6667,us.undernet.org:6667,elsene.be.eu.undernet.org:6667,elsene.be.eu.undernet.org:7000,helsinki.fi.eu.Undernet.org:6666,zagreb.hr.eu.undernet.org:6666,zagreb.hr.eu.undernet.org:9999,ede.nl.eu.undernet.org:6660,oslo.no.eu.undernet.org:6666,london.uk.eu.undernet.org:6660,london.uk.eu.undernet.org:7000,mesa.az.us.undernet.org:6660,mesa.az.us.undernet.org:6665,mesa.az.us.undernet.org:7000,newyork.ny.us.undernet.org:6660,newyork.ny.us.undernet.org:7000 + +[euIRCnet] +Servers=irc.euirc.net:6665 diff --git a/data/quassel.appdata.xml b/data/quassel.appdata.xml new file mode 100644 index 0000000..50905ce --- /dev/null +++ b/data/quassel.appdata.xml @@ -0,0 +1,41 @@ + + + + quassel.desktop + CC0-1.0 + GPL-2.0 or GPL-3.0 + Quassel + Modern IRC client + +

+Quassel IRC is a modern, cross-platform, distributed IRC client, meaning that +one (or multiple) client(s) can attach to and detach from a central core: much +like the popular combination of screen and a text-based IRC client such as +WeeChat, but graphical. In addition to this unique feature, we aim to bring a +pleasurable, comfortable chatting experience to all major platforms, making +communication with your peers not only convenient, but also available everywhere. +

+

+And the best of all: It's free - as in beer and as in speech. +

+

+This application is the "monolithic" build of Quassel; it can be used on its own +without setting up a core. +

+
+ + + https://quassel-irc.org/files/images/20080914-011743-quasselkde4.preview.png + Quassel, with a dark theme enabled + + + https://quassel-irc.org/files/images/quassel_win7.preview.png + +The default quassel white theme. Quassel runs on all major desktop platforms, +and many smartphones as well. + + + + +
+ diff --git a/data/quassel.desktop b/data/quassel.desktop new file mode 100644 index 0000000..a067eb6 --- /dev/null +++ b/data/quassel.desktop @@ -0,0 +1,76 @@ +[Desktop Entry] +Type=Application +Version=1.0 +Name=Quassel IRC +Name[ast]=Quassel IRC +Name[ca]=Xat IRC Quassel +Name[de]=Quassel IRC +Name[en_GB]=Quassel IRC +Name[es]=IRC Quassel +Name[et]=Quassel IRC +Name[fi]=Quassel IRC +Name[fr]=Quassel IRC +Name[gl]=IRC Quassel +Name[hu]=Quassel IRC +Name[it]=Quassel IRC +Name[ko]=Quassel IRC +Name[nb]=Quassel IRC +Name[nl]=Quassel IRC +Name[oc]=Quassel IRC +Name[pl]=Quassel IRC +Name[pt_BR]=Quassel IRC +Name[ru]=Quassel IRC +Name[sq]=Quassel IRC +Name[sv]=Quassel IRC +Name[tr]=Quassel IRC +Name[uk]=Quassel IRC +Name[zh_CN]=Quassel IRC +GenericName=IRC Client +GenericName[ast]=Veceru IRC +GenericName[ca]=Client d'IRC +GenericName[de]=IRC-Client +GenericName[en_GB]=IRC Client +GenericName[es]=Cliente IRC +GenericName[et]=IRC klient +GenericName[fi]=IRC-asiakas +GenericName[fr]=Client IRC +GenericName[gl]=Cliente de IRC +GenericName[hu]=IRC-kliens +GenericName[it]=Client IRC +GenericName[ko]=IRC 클라이언트 +GenericName[nb]=IRC-klient +GenericName[nl]=IRC-client +GenericName[oc]=Client IRC +GenericName[pl]=Klient IRC +GenericName[pt_BR]=Cliente IRC +GenericName[ru]=IRC клиент +GenericName[sq]=IRC Klient +GenericName[sv]=IRC-klient +GenericName[tr]=IRC İstemci +GenericName[uk]=Клієнт IRC +GenericName[zh_CN]=IRC 客户端 +Comment=Distributed IRC client with central core component +Comment[ast]=Veceru IRC distribuyíu con un componente central +Comment[ca]=Client d'IRC distribuït amb un component de nucli central +Comment[de]=Dezentralisierter IRC-Client mit einem zentralen Kern +Comment[en_GB]=Distributed IRC client with central core component +Comment[es]=Cliente IRC distribuido con un componente central +Comment[et]=Hajus IRC klient koos keskse tuumkomponendiga +Comment[fi]=Hajautettu IRC-asiakas, jolla keskitetty ydinkomponentti +Comment[fr]=Client IRC distribué avec composant essentiel centralisé +Comment[gl]=Cliente de IRC distribuído cun compoñente principal central +Comment[hu]=Elosztott IRC-kliens központi alapkomponenssel +Comment[it]=Client IRC distribuito con componente centrale +Comment[nl]=IRC-client met centraal kerncomponent +Comment[oc]=Client IRC distribuit amb component essencial centralizat +Comment[pt_BR]=Cliente IRC distribuido com o compotente central core +Comment[ru]=Распределённый клиент IRC с центральным ядром +Comment[sq]=Klient i shpërndarë IRC me përbërës qendror +Comment[sv]=Distribuerad IRC-klient med central kärnkomponent +Comment[uk]=Клієнт IRC з центральним ядром +Comment[zh_CN]=带有中央核心组件的分布式 IRC 客户端 +Icon=quassel +TryExec=quassel +Exec=quassel +Categories=Qt;Network;Chat;IRCClient; +X-DBUS-ServiceName=org.quassel-irc.quassel diff --git a/data/quassel.notifyrc b/data/quassel.notifyrc new file mode 100644 index 0000000..3cf96ff --- /dev/null +++ b/data/quassel.notifyrc @@ -0,0 +1,177 @@ +[Global] +IconName=quassel +Comment=Quassel IRC +Comment[ast]=Quassel IRC +Comment[ca]=Xat IRC Quassel +Comment[de]=Quassel IRC +Comment[en_GB]=Quassel IRC +Comment[es]=IRC Quassel +Comment[et]=Quassel IRC +Comment[fi]=Quassel IRC +Comment[fr]=Quassel IRC +Comment[gl]=IRC Quassel +Comment[hu]=Quassel IRC +Comment[it]=Quassel IRC +Comment[ko]=Quassel IRC +Comment[nb]=Quassel IRC +Comment[nl]=Quassel IRC +Comment[oc]=Quassel IRC +Comment[pl]=Quassel IRC +Comment[pt_BR]=Quassel IRC +Comment[ru]=Quassel IRC +Comment[sq]=Quassel IRC +Comment[sv]=Quassel IRC +Comment[tr]=Quassel IRC +Comment[uk]=Quassel IRC +Comment[zh_CN]=Quassel IRC + +[Event/Highlight] +Name=Highlight +Name[ast]=Resaltar +Name[ca]=Realçament +Name[de]=Hervorgehoben +Name[en_GB]=Highlight +Name[es]=Resaltado +Name[et]=Esiletõst +Name[fi]=Korosta +Name[gl]=Resaltar +Name[it]=In evidenza +Name[nb]=Uthev +Name[nl]=Accentueren +Name[oc]=Susbrilhança +Name[pl]=Podświetlenie +Name[pt_BR]=Realçar +Name[ru]=Подсветка +Name[sq]=Thekso +Name[tr]=Vurgulama +Name[uk]=Підсвічування +Name[zh_CN]=高亮显示 +Comment=A highlighted message has arrived +Comment[ast]=Aportó un mensax resaltáu +Comment[ca]=Ha arrivat un missatge realçat +Comment[de]=Eine hervorgehobene Nachricht ist angekommen +Comment[en_GB]=A highlighted message has arrived +Comment[es]=A llegado un mensaje resaltado +Comment[et]=Saabunud on esiletõstetud sõnum +Comment[fi]=Korostettu viesti saapunut +Comment[gl]=Chegou unha mensaxe resaltada +Comment[it]=È arrivato un nuovo messaggio evidenziato +Comment[nb]=En uthevet beskjed er mottatt +Comment[nl]=Er is een geaccentueerd bericht ontvangen +Comment[pl]=Nadeszła podświetlona wiadomość +Comment[pt_BR]=Realçar quando uma mensagem chegar +Comment[sq]=Një mesazh i theksuar ka mbërritur +Comment[sv]=Ett markerat meddelande har anlänt +Comment[tr]=Vurgulanmış bir ileti geldi +Comment[uk]=Надійшло підсвічене повідомлення +Comment[zh_CN]=收到一条高亮显示的信息 +Sound=KDE-Im-Highlight-Msg.ogg +Action=Sound|Popup|Taskbar + +[Event/HighlightFocused] +Name=Highlight when focused +Name[ast]=Resaltáu cuandu ta nel focu +Name[ca]=Realçament en tenir el focus +Name[de]=Hervorgehoben und fokussiert +Name[en_GB]=Highlight when focused +Name[es]=Resaltado cuando está en el foco +Name[et]=Tõsta esile kui fokusseeritud +Name[gl]=Resaltado cando está en foco +Name[it]=In evidenza quando in primo piano +Name[nb]=Uthev ved fokus +Name[nl]=Accentueren wanneer venster actief +Name[pt_BR]=Realçar quando focado +Name[sq]=Përzgjidh kur fokusohet +Name[uk]=Підсвічування у фокусі +Name[zh_CN]=被聚焦时高亮显示 +Comment=A highlighted message has arrived while Quassel is focused +Comment[ast]=Aportó un mensax resaltáu mientres s'enfocaba Quassel +Comment[ca]=Ha arribat un missatge realçat mentre el Quassel tenia el focus +Comment[de]=Eine hervorgehobene Nachricht ist angekommen, während Quassel fokussiert war +Comment[en_GB]=A highlighted message has arrived while Quassel is focused +Comment[es]=Ha llegado un mensaje resaltado mientras se enfocaba Quassel +Comment[et]=Kui Quassel on fokusseeritud saabus esiletõstetud sõnum +Comment[gl]=Chegou unha mensaxee resaltada mentres se enfocaba Quassel +Comment[it]=È arrivato un nuovo messaggio evidenziato mentre Quassel è in primo piano +Comment[nb]=En uthevet beskjed er mottatt mens Quassel har fokus +Comment[nl]=Een geaccentueerd bericht is ontvangen terwijl het Quessel-venster actief is +Comment[pt_BR]=Mensagem realçada quando chegar enquando o Quassel estiver focado +Comment[sq]=një mesazh i përzgjedhur ka mbërritur kur Quassel ishte në fokus +Comment[uk]=Під час перебування Quassel у фокусі надійшло підсвічене повідомлення +Comment[zh_CN]=当Quassel被聚焦时,收到一条高亮显示的信息 +Sound=KDE-Im-Highlight-Msg.ogg +Action=Taskbar + +[Event/PrivMsg] +Name=Private Message +Name[ast]=Mensax priváu +Name[ca]=Missatge privat +Name[de]=Private Nachricht +Name[en_GB]=Private Message +Name[es]=Mensaje privado +Name[et]=Isiklik sõnum +Name[fi]=Yksityisviesti +Name[gl]=Mensaxe privada +Name[it]=Messaggio privato +Name[nb]=Privat melding +Name[nl]=Privé-bericht +Name[oc]=Messatge Privat +Name[pl]=Prywatna wiadomość +Name[pt_BR]=Mensagem privada +Name[ru]=Личное сообщение +Name[sq]=Mesazh Privat +Name[sv]=Privat meddelande +Name[tr]=Özel Mesaj +Name[uk]=Особисте повідомлення +Name[zh_CN]=私人短信息 +Comment=A private message (query) has arrived +Comment[ast]=Aportó un mensax priváu (consulta) +Comment[ca]=Ha arribat un missatge privat (sol·licitud) +Comment[de]=Eine private Nachricht (Anfrage) ist angekommen +Comment[en_GB]=A private message (query) has arrived +Comment[es]=Ha llegado un mensaje privado (consulta) +Comment[et]=Saabunud on isiklik sõnum (päring) +Comment[gl]=Chegou unha mensaxe privada (consulta) +Comment[it]=È arrivato un nuovo messaggio privato (query) +Comment[nb]=En privat melding (query) er mottatt +Comment[nl]=Een privé-bericht (query) is ontvangen +Comment[pl]=Nadeszła prywatna wiadomość (zapytanie) +Comment[pt_BR]=Uma mensagem privada (consulta) chegou +Comment[ru]=Получено личное сообщение (запрос) +Comment[sq]=një mesazh privat (kërkesë) ka mbërritur +Comment[tr]=Bir özel mesaj (sorgusu) ulaştı +Comment[uk]=Надійшло особисте повідомлення (повідомлення діалогу) +Comment[zh_CN]=收到一条私人短信息(询问) +Sound=KDE-Im-Message-In.ogg +Action=Sound|Popup|Taskbar + +[Event/PrivMsgFocused] +Name=Private message when focused +Name[ast]=Mensax priváu cuandu ta nel focu +Name[ca]=Missatge privat en tenir el focus +Name[de]=Private Nachricht und fokussiert +Name[en_GB]=Private message when focused +Name[es]=Mensaje privado cuando está en el foco +Name[gl]=Mensaxe privada cando está en foco +Name[it]=Messaggio privato mentre in primo piano +Name[nl]=Privé-bericht terwijl het Quassel-venster actief is +Name[pt_BR]=Mensagem privada quando focada +Name[sq]=Mesazh Privat kur Fokusohet +Name[sv]=Privat meddelande när fokuserad +Name[uk]=Особисте повідомлення під час фокусування +Name[zh_CN]=被聚焦时的私人短信息 +Comment=A private message (query) has arrived while Quassel is focused +Comment[ast]=Aportó un mensax priváu (consulta) mientres s'enfocaba Quassel +Comment[ca]=Ha arribat un missatge privat (sol·licitud) mentre el Quassel tenia el focus +Comment[de]=Eine private Nachricht (Anfrage) ist angekommen, während Quassel fokussiert war +Comment[en_GB]=A private message (query) has arrived while Quassel is focused +Comment[es]=Ha llegado un mensaje privado (consulta) mientras se enfocaba Quassel +Comment[gl]=Chegou unha mensaxe privada (consulta) mentres se enfocaba Quassel +Comment[it]=È arrivato un messaggio privato (query) mentre Quassel è in primo piano +Comment[nl]=Een privé-bericht (query) is ontvangen terwijl het Quassel-venster actief is +Comment[pt_BR]=Uma mensagem privada (consulta) chegou enquanto o Quassel está focado +Comment[sq]=Një masazh privat (kërkesë) ka mbërritur kur Quassel ishte i fokusuar +Comment[uk]=Під час перебування Quassel у фокусі надійшло особисте повідомлення (повідомлення з діалогу) +Comment[zh_CN]=当Quassel被聚焦时,收到一条私人短信息(询问) +Sound=KDE-Im-Message-In.ogg +Action=Taskbar diff --git a/data/quasselclient.appdata.xml b/data/quasselclient.appdata.xml new file mode 100644 index 0000000..47c283a --- /dev/null +++ b/data/quasselclient.appdata.xml @@ -0,0 +1,41 @@ + + + + quasselclient.desktop + CC0-1.0 + GPL-2.0 or GPL-3.0 + Quassel Client + Modern distributed IRC client + +

+Quassel IRC is a modern, cross-platform, distributed IRC client, meaning that +one (or multiple) client(s) can attach to and detach from a central core: much +like the popular combination of screen and a text-based IRC client such as +WeeChat, but graphical. In addition to this unique feature, we aim to bring a +pleasurable, comfortable chatting experience to all major platforms, making +communication with your peers not only convenient, but also available everywhere. +

+

+And the best of all: It's free - as in beer and as in speech. +

+

+This application is the client-only version of Quassel. You must first set up +(or have been given an account on) the quassel core before using this. +

+
+ + + https://quassel-irc.org/files/images/20080914-011743-quasselkde4.preview.png + Quassel, with a dark theme enabled + + + https://quassel-irc.org/files/images/quassel_win7.preview.png + +The default quassel white theme. Quassel runs on all major desktop platforms, +and many smartphones as well. + + + + +
+ diff --git a/data/quasselclient.desktop b/data/quasselclient.desktop new file mode 100644 index 0000000..5be24ce --- /dev/null +++ b/data/quasselclient.desktop @@ -0,0 +1,75 @@ +[Desktop Entry] +Type=Application +Version=1.0 +Name=Quassel IRC (Client only) +Name[ast]=IRC Quassel (namái veceru) +Name[ca]=Xat IRC Quassel (només el client) +Name[de]=Quassel IRC (nur Client) +Name[en_GB]=Quassel IRC (Client only) +Name[es]=IRC Quassel (sólo cliente) +Name[et]=Quassel IRC (ainult klient) +Name[fi]=Quassel IRC (vain asiakas) +Name[fr]=Quassel IRC (client uniquement) +Name[gl]=Quassel IRC (só cliente) +Name[hu]=Quassel IRC (Csak kliens) +Name[it]=Quassel IRC (solo client) +Name[ko]=Quassel IRC (클라이언트만) +Name[nl]=Quassel IRC (alleen client) +Name[oc]=Quassel IRC (client unicament) +Name[pl]=Quassel IRC (tylko klient) +Name[pt_BR]=Quassel IRC (Apenas cliente) +Name[ru]=Quassel IRC (только клиент) +Name[sq]=Quassel IRC (Vetëm klient) +Name[sv]=Quassel IRC (endast klient) +Name[tr]=Quassel IRC (sadece İstemci) +Name[uk]=Quassel IRC (лише клієнт) +Name[zh_CN]=Quassel IRC (仅仅包含客户端) +GenericName=IRC Client +GenericName[ast]=Veceru IRC +GenericName[ca]=Client d'IRC +GenericName[de]=IRC-Client +GenericName[en_GB]=IRC Client +GenericName[es]=Cliente IRC +GenericName[et]=IRC klient +GenericName[fi]=IRC-asiakas +GenericName[fr]=Client IRC +GenericName[gl]=Cliente de IRC +GenericName[hu]=IRC-kliens +GenericName[it]=Client IRC +GenericName[ko]=IRC 클라이언트 +GenericName[nb]=IRC-klient +GenericName[nl]=IRC-client +GenericName[oc]=Client IRC +GenericName[pl]=Klient IRC +GenericName[pt_BR]=Cliente IRC +GenericName[ru]=IRC клиент +GenericName[sq]=IRC Klient +GenericName[sv]=IRC-klient +GenericName[tr]=IRC İstemci +GenericName[uk]=Клієнт IRC +GenericName[zh_CN]=IRC 客户端 +Comment=Distributed IRC client with central core component +Comment[ast]=Veceru IRC distribuyíu con un componente central +Comment[ca]=Client d'IRC distribuït amb un component de nucli central +Comment[de]=Dezentralisierter IRC-Client mit einem zentralen Kern +Comment[en_GB]=Distributed IRC client with central core component +Comment[es]=Cliente IRC distribuido con un componente central +Comment[et]=Hajus IRC klient koos keskse tuumkomponendiga +Comment[fi]=Hajautettu IRC-asiakas, jolla keskitetty ydinkomponentti +Comment[fr]=Client IRC distribué avec composant essentiel centralisé +Comment[gl]=Cliente de IRC distribuído cun compoñente principal central +Comment[hu]=Elosztott IRC-kliens központi alapkomponenssel +Comment[it]=Client IRC distribuito con componente centrale +Comment[nl]=IRC-client met centraal kerncomponent +Comment[oc]=Client IRC distribuit amb component essencial centralizat +Comment[pt_BR]=Cliente IRC distribuido com o compotente central core +Comment[ru]=Распределённый клиент IRC с центральным ядром +Comment[sq]=Klient i shpërndarë IRC me përbërës qendror +Comment[sv]=Distribuerad IRC-klient med central kärnkomponent +Comment[uk]=Клієнт IRC з центральним ядром +Comment[zh_CN]=带有中央核心组件的分布式 IRC 客户端 +Icon=quassel +TryExec=quasselclient +Exec=quasselclient +Categories=Qt;Network;Chat;IRCClient; +X-DBUS-ServiceName=org.quassel-irc.quasselclient diff --git a/data/scripts/inxi b/data/scripts/inxi new file mode 100755 index 0000000..fc9550f --- /dev/null +++ b/data/scripts/inxi @@ -0,0 +1,14740 @@ +#!/usr/bin/env bash +######################################################################## +#### Script Name: inxi +#### Version: 2.3.0 +#### Date: 2016-04-18 +#### Patch Number: 00 +######################################################################## +#### SPECIAL THANKS +######################################################################## +#### Special thanks to all those in #lsc and #smxi for their tireless +#### dedication helping test inxi modules. +######################################################################## +#### ABOUT INXI +######################################################################## +#### inxi is a fork of infobash 3.02, the original bash sys info tool by locsmif +#### As time permits functionality improvements and recoding will occur. +#### +#### inxi, the universal, portable, system information tool for irc. +#### Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII, +#### Gaim/Pidgin, Weechat, KVIrc and Kopete. +#### Original infobash author and copyright holder: +#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif +#### inxi version: Copyright (C) 2008-2016 Scott Rogers & Harald Hope +#### Further fixes (listed as known): Horst Tritremmel +#### Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch +#### Jarett.Stevens - dmidecde -M patch for older systems with the /sys +#### +#### Current script home page/wiki/git: https://github.com/smxi/inxi +#### Documentation/wiki pages will move to http://smxi.org soon. +#### Script forums: http://techpatterns.com/forums/forum-33.html +#### IRC support: irc.oftc.net channel #smxi +#### Version control: +#### * https://github.com/smxi/inxi +#### * git: git pull https://github.com/smxi/inxi master +#### * svn checkout url: https://github.com/smxi/inxi +#### +#### This program is free software; you can redistribute it and/or modify +#### it under the terms of the GNU General Public License as published by +#### the Free Software Foundation; either version 3 of the License, or +#### (at your option) any later version. +#### +#### 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. +#### +#### You should have received a copy of the GNU General Public License +#### along with this program. If not, see . +#### +#### If you don't understand what Free Software is, please read (or reread) +#### this page: http://www.gnu.org/philosophy/free-sw.html +######################################################################## + +#### +#### PACKAGE NAME NOTES +#### * Package names in (...) are the Debian Squeeze package name. Check your +#### distro for proper package name by doing this: which +#### then find what package owns that application file. Or run --recommends +#### which shows package names for Debian/Ubuntu, Arch, and Fedora/Redhat/Suse +#### +#### DEPENDENCIES +#### * bash >=3.0 (bash); df, readlink, stty, tr, uname, wc (coreutils); +#### gawk (gawk); grep (grep); lspci (pciutils); +#### ps, find (findutils) +#### * Also the proc filesystem should be present and mounted for Linux +#### * Some features, like -M and -d will not work, or will work incompletely, +#### if /sys is missing +#### +#### Apparently unpatched bash 3.0 has arrays broken; bug reports: +#### http://ftp.gnu.org/gnu/bash/bash-3.0-patches/bash30-008 +#### http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00144.html +#### Bash 3.1 for proper array use +#### +#### Arrays work in bash 2.05b, but "grep -Em" does not +#### +#### RECOMMENDS (Needed to run certain features, listed by option) +#### -A - for output of usb audio information: lsusb (usbutils) +#### -Ax -Nx - for audio/network module version: modinfo (module-init-tools) +#### -Dx - for hdd temp output (root only default): hddtemp (hddtemp) +#### For user level hdd temp output: sudo (sudo) +#### Note: requires user action for this feature to run as user (edit /etc/sudoers file) +#### -G - full graphics output requires: glxinfo (mesa-utils); xdpyinfo (X11-utils); +#### xrandr (x11-xserver-utils) +#### -i - IP information, local/wan - ip (iproute) legacy, not used if ip present: ifconfig (net-tools) +#### -I - uptime (procps, check Debian if changed) +#### -Ix - view current runlevel while not in X window system (or with -x): runlevel (sysvinit) +#### -m - all systems, dmidecode, unless someone can find a better way. +#### -M - for older systems whose kernel does not have /sys data for machine, dmidecode (dmidecode) +#### -o - for unmounted file system information in unmounted drives (root only default): file (file) +#### Note: requires user action for this feature to run as user (edit /etc/sudoers file) +#### For user level unmounted file system type output: sudo (sudo) +#### -s For any sensors output, fan, temp, etc: sensors (lm-sensors) +#### Note: requires setup of lm-sensors (sensors-detect and adding modules/modprobe/reboot, +#### and ideally, pwmconfig) prior to full output being available. +#### -S For desktop environment, user must be in X and have xprop installed (in X11-utils) +######################################################################## +#### BSD Adjustments +#### * sed -i '' form supported by using SED_I="-i ''". +#### * Note: New BSD sed supports using -r instead of -E for compatibility with gnu sed +#### However, older, like FreeBSD 7.x, does not have -r so using SED_RX='-E' for this. +#### * Gnu grep options can be used if the function component is only run in linux +#### These are the options that bsd grep does not support that inxi uses: -m -o +#### so make sure if you use those to have them in gnu/linux only sections. +#### It appears that freebsd uses gnu grep but openbsd uses bsd grep, however. +#### * BSD ps does not support --without-headers option, and also does not support --sort