summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore236
-rw-r--r--Doxyfile69
-rw-r--r--LGPL_EXCEPTION.txt22
-rw-r--r--README85
-rw-r--r--admin/buildscript.py72
-rw-r--r--binarysign/README35
-rw-r--r--binarysign/TestPublisher.cerbin0 -> 449 bytes
-rw-r--r--binarysign/TestPublisher.derbin0 -> 609 bytes
-rw-r--r--binarysign/TestPublisher.pem15
-rw-r--r--binarysign/TestPublisher.pvkbin0 -> 636 bytes
-rw-r--r--binarysign/TestPublisher.spcbin0 -> 496 bytes
-rw-r--r--binarysign/scripts/generate-keys.sh29
-rw-r--r--binarysign/sign.sh5
-rw-r--r--binarysign/testcert.cerbin0 -> 539 bytes
-rw-r--r--binarysign/testcert.pvkbin0 -> 636 bytes
-rw-r--r--doc/classic.css295
-rw-r--r--doc/doc.intermediate.manifest15
-rw-r--r--doc/doc.pri64
-rw-r--r--doc/doc.pro1
-rw-r--r--doc/fixnavi.pl70
-rw-r--r--doc/images/qt-logo.pngbin0 -> 1471 bytes
-rw-r--r--doc/installerfw.qdoc652
-rw-r--r--doc/installerfw.qdocconf231
-rw-r--r--doc/noninteractive.qdoc127
-rw-r--r--doc/qt-defines.qdocconf66
-rw-r--r--doc/qt-html-templates.qdocconf149
-rw-r--r--doc/scripting.qdoc305
-rw-r--r--doc/templates/images/api_examples.pngbin0 -> 1302 bytes
-rw-r--r--doc/templates/images/api_lookup.pngbin0 -> 1879 bytes
-rw-r--r--doc/templates/images/api_topics.pngbin0 -> 1216 bytes
-rw-r--r--doc/templates/images/arrow_down.pngbin0 -> 177 bytes
-rw-r--r--doc/templates/images/bg_l.pngbin0 -> 139 bytes
-rw-r--r--doc/templates/images/bg_l_blank.pngbin0 -> 123 bytes
-rw-r--r--doc/templates/images/bg_ll.pngbin0 -> 514 bytes
-rw-r--r--doc/templates/images/bg_ll_blank.pngbin0 -> 320 bytes
-rw-r--r--doc/templates/images/bg_lr.pngbin0 -> 458 bytes
-rw-r--r--doc/templates/images/bg_r.pngbin0 -> 136 bytes
-rw-r--r--doc/templates/images/bg_ul.pngbin0 -> 516 bytes
-rw-r--r--doc/templates/images/bg_ul_blank.pngbin0 -> 304 bytes
-rw-r--r--doc/templates/images/bg_ur.pngbin0 -> 437 bytes
-rw-r--r--doc/templates/images/bg_ur_blank.pngbin0 -> 437 bytes
-rw-r--r--doc/templates/images/box_bg.pngbin0 -> 129 bytes
-rw-r--r--doc/templates/images/breadcrumb.pngbin0 -> 195 bytes
-rw-r--r--doc/templates/images/bullet_dn.pngbin0 -> 230 bytes
-rw-r--r--doc/templates/images/bullet_gt.pngbin0 -> 185 bytes
-rw-r--r--doc/templates/images/bullet_sq.pngbin0 -> 117 bytes
-rw-r--r--doc/templates/images/bullet_up.pngbin0 -> 253 bytes
-rw-r--r--doc/templates/images/content_bg.pngbin0 -> 1498 bytes
-rw-r--r--doc/templates/images/feedbackground.pngbin0 -> 263 bytes
-rw-r--r--doc/templates/images/form_bg.pngbin0 -> 390 bytes
-rw-r--r--doc/templates/images/header.pngbin0 -> 3768 bytes
-rw-r--r--doc/templates/images/header_bg.pngbin0 -> 114 bytes
-rw-r--r--doc/templates/images/horBar.pngbin0 -> 2807 bytes
-rw-r--r--doc/templates/images/page.pngbin0 -> 3102 bytes
-rw-r--r--doc/templates/images/page_bg.pngbin0 -> 126 bytes
-rw-r--r--doc/templates/images/print.pngbin0 -> 575 bytes
-rw-r--r--doc/templates/images/qt_guide.pngbin0 -> 12685 bytes
-rw-r--r--doc/templates/images/qt_icon.pngbin0 -> 4775 bytes
-rw-r--r--doc/templates/images/qt_ref_doc.pngbin0 -> 2600 bytes
-rw-r--r--doc/templates/images/qt_tools.pngbin0 -> 17508 bytes
-rw-r--r--doc/templates/images/sep.pngbin0 -> 120 bytes
-rw-r--r--doc/templates/images/spinner.gifbin0 -> 2037 bytes
-rw-r--r--doc/templates/images/sprites-combined.pngbin0 -> 62534 bytes
-rw-r--r--doc/templates/scripts/functions.js192
-rw-r--r--doc/templates/scripts/jquery.js152
-rw-r--r--doc/templates/scripts/narrow.js78
-rw-r--r--doc/templates/scripts/superfish.js121
-rw-r--r--doc/templates/style/OfflineStyle.css836
-rw-r--r--doc/templates/style/narrow.css250
-rw-r--r--doc/templates/style/style.css1218
-rw-r--r--doc/templates/style/style_ie6.css54
-rw-r--r--doc/templates/style/style_ie7.css19
-rw-r--r--doc/templates/style/style_ie8.css0
-rw-r--r--doc/templates/style/superfish.css51
-rw-r--r--doc/templates/style/superfish_skin.css83
-rw-r--r--doc/tutorial.qdoc83
-rw-r--r--examples/RepositoryExchangeTutorial.txt11
-rw-r--r--examples/config/config.xml22
-rw-r--r--examples/config/license.txt84
-rw-r--r--examples/config/logo.pngbin0 -> 1592 bytes
-rw-r--r--examples/config/qticon.icnsbin0 -> 162568 bytes
-rw-r--r--examples/config/qticon.icobin0 -> 355574 bytes
-rw-r--r--examples/config/qticon.pngbin0 -> 2109 bytes
-rw-r--r--examples/config/watermark.pngbin0 -> 14462 bytes
-rw-r--r--examples/examples.pro7
-rw-r--r--examples/packages/generateindex.sh13
-rw-r--r--examples/packages/generatetranslation.sh76
-rw-r--r--examples/packages/index.xml9
-rw-r--r--examples/testapp/components.xml13
-rw-r--r--examples/testapp/config.xml47
-rw-r--r--examples/testapp/config/config.xml20
-rw-r--r--examples/testapp/logo.pngbin0 -> 5437 bytes
-rw-r--r--examples/testapp/main.cpp46
-rw-r--r--examples/testapp/mainwindow.cpp182
-rw-r--r--examples/testapp/mainwindow.h48
-rw-r--r--examples/testapp/packages/com.nokia.testapp/meta/installscript.js18
-rw-r--r--examples/testapp/packages/com.nokia.testapp/meta/package.xml9
-rw-r--r--examples/testapp/testapp.pro19
-rw-r--r--examples/testapp/testapp.qrc8
-rw-r--r--examples/testcases/result-example.xml37
-rw-r--r--examples/testcases/testcase1/packagemanagement.qs35
-rw-r--r--examples/testcases/testcase1/test-uninstall.qs30
-rw-r--r--examples/testcases/testcase1/testcase1.cfg5
-rw-r--r--examples/testcases/testcase1/testscript.qs69
-rw-r--r--examples/testreturn/main.cpp70
-rw-r--r--examples/testreturn/testreturn.pro10
-rw-r--r--examples/testvm-configs/franks-host-config.cfg5
-rw-r--r--examples/testvm-configs/franks-test-vm.cfg7
-rw-r--r--examples/testvm-configs/mikes-host-config.cfg4
-rw-r--r--examples/testvm-configs/mikes-test-vm.cfg7
-rw-r--r--examples/tutorial/config/config.xml10
-rw-r--r--examples/tutorial/config/license.txt1
-rw-r--r--examples/tutorial/packages/com.vendor.product/data/installcontent.txt2
-rw-r--r--examples/tutorial/packages/com.vendor.product/meta/packages.xml8
-rw-r--r--examples/updater/components.xml409
-rw-r--r--examples/updater/config.xml29
-rw-r--r--examples/updater/main.cpp60
-rw-r--r--examples/updater/updater.cpp174
-rw-r--r--examples/updater/updater.h45
-rw-r--r--examples/updater/updater.pro12
-rw-r--r--examples/updater/updater.qrc5
-rw-r--r--examples/updaterplugin/Updater.pluginspec9
-rw-r--r--examples/updaterplugin/config.xml15
-rw-r--r--examples/updaterplugin/config/config.xml17
-rw-r--r--examples/updaterplugin/packages/com.nokia.qtcreator/meta/installscript.js50
-rw-r--r--examples/updaterplugin/packages/com.nokia.qtcreator/meta/package.xml9
-rw-r--r--examples/updaterplugin/updaterplugin.cpp256
-rw-r--r--examples/updaterplugin/updaterplugin.h61
-rw-r--r--examples/updaterplugin/updaterplugin.pro37
-rw-r--r--examples/updaterplugin/updaterplugin.qrc5
-rw-r--r--examples/updaterplugin/updatersettingspage.cpp125
-rw-r--r--examples/updaterplugin/updatersettingspage.h59
-rw-r--r--installerbuilder/archivegen/archive.cpp82
-rw-r--r--installerbuilder/archivegen/archivegen.pro18
-rw-r--r--installerbuilder/binarycreator/binarycreator.cpp698
-rw-r--r--installerbuilder/binarycreator/binarycreator.pro25
-rw-r--r--installerbuilder/binarycreator/binarycreator.qrc8
-rw-r--r--installerbuilder/binarycreator/rcc/qcorecmdlineargs_p.h72
-rw-r--r--installerbuilder/binarycreator/rcc/rcc.cpp967
-rw-r--r--installerbuilder/binarycreator/rcc/rcc.h153
-rw-r--r--installerbuilder/binarycreator/rcc/rccmain.cpp264
-rw-r--r--installerbuilder/binarycreator/resources/copylibsintobundle.sh161
-rw-r--r--installerbuilder/binarycreator/resources/default_icon_mac.icnsbin0 -> 118992 bytes
-rw-r--r--installerbuilder/binarycreator/resources/mkdmg.sh37
-rw-r--r--installerbuilder/common/binaryformat.cpp952
-rw-r--r--installerbuilder/common/binaryformat.h208
-rw-r--r--installerbuilder/common/binaryformatengine.cpp304
-rw-r--r--installerbuilder/common/binaryformatengine.h73
-rw-r--r--installerbuilder/common/binaryformatenginehandler.cpp115
-rw-r--r--installerbuilder/common/binaryformatenginehandler.h61
-rw-r--r--installerbuilder/common/blockingbuffer.cpp126
-rw-r--r--installerbuilder/common/blockingbuffer.h47
-rw-r--r--installerbuilder/common/consolepasswordprovider.h53
-rw-r--r--installerbuilder/common/errors.h48
-rw-r--r--installerbuilder/common/fileutils.cpp468
-rw-r--r--installerbuilder/common/fileutils.h103
-rw-r--r--installerbuilder/common/installersettings.cpp314
-rw-r--r--installerbuilder/common/installersettings.h90
-rw-r--r--installerbuilder/common/kd7zengine.cpp679
-rw-r--r--installerbuilder/common/kd7zengine.h73
-rw-r--r--installerbuilder/common/kd7zenginehandler.cpp41
-rw-r--r--installerbuilder/common/kd7zenginehandler.h39
-rw-r--r--installerbuilder/common/libeay32.dllbin0 -> 1526468 bytes
-rw-r--r--installerbuilder/common/libssl32.dllbin0 -> 309080 bytes
-rw-r--r--installerbuilder/common/openssl.qrc7
-rw-r--r--installerbuilder/common/range.h88
-rw-r--r--installerbuilder/common/repository.cpp58
-rw-r--r--installerbuilder/common/repository.h59
-rw-r--r--installerbuilder/common/repositorygen.cpp802
-rw-r--r--installerbuilder/common/repositorygen.h53
-rw-r--r--installerbuilder/common/utils.cpp221
-rw-r--r--installerbuilder/common/utils.h119
-rw-r--r--installerbuilder/common/zipjob.cpp216
-rw-r--r--installerbuilder/common/zipjob.h87
-rw-r--r--installerbuilder/create-test-installer.bat1
-rw-r--r--installerbuilder/create-test-installer.sh1
-rw-r--r--installerbuilder/installerbase/installerbase.cpp372
-rw-r--r--installerbuilder/installerbase/installerbase.exe.manifest14
-rw-r--r--installerbuilder/installerbase/installerbase.icobin0 -> 25214 bytes
-rw-r--r--installerbuilder/installerbase/installerbase.pro41
-rw-r--r--installerbuilder/installerbase/installerbase.qrc5
-rw-r--r--installerbuilder/installerbase/installerbase.rc7
-rw-r--r--installerbuilder/installerbase/installerbasecommons.cpp232
-rw-r--r--installerbuilder/installerbase/installerbasecommons.h123
-rw-r--r--installerbuilder/installerbase/maintabwidget.cpp71
-rw-r--r--installerbuilder/installerbase/maintabwidget.h49
-rw-r--r--installerbuilder/installerbase/tabcontroller.cpp538
-rw-r--r--installerbuilder/installerbase/tabcontroller.h97
-rw-r--r--installerbuilder/installerbuilder.dox790
-rw-r--r--installerbuilder/installerbuilder.pro10
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/aes.h148
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1.h1329
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1_mac.h571
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1t.h893
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/bio.h776
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/blowfish.h129
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/bn.h855
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/buffer.h118
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/cast.h107
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/comp.h80
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/conf.h254
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/conf_api.h89
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/crypto.h619
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/des.h245
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/des_old.h446
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dh.h245
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dsa.h324
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dso.h368
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dtls1.h218
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/e_os2.h279
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ebcdic.h19
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ec.h526
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ecdh.h123
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ecdsa.h271
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/engine.h801
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/err.h330
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/evp.h1059
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/fips.h163
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/fips_rand.h77
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/hmac.h109
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/idea.h103
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/krb5_asn.h256
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/kssl.h179
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/lhash.h200
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md2.h95
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md4.h120
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md5.h120
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/obj_mac.h3775
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/objects.h1049
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ocsp.h623
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/opensslconf.h255
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/opensslv.h89
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ossl_typ.h183
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pem.h782
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pem2.h70
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pkcs12.h333
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pkcs7.h464
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pq_compat.h152
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pqueue.h95
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rand.h167
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rc2.h103
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rc4.h90
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ripemd.h106
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rsa.h496
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/safestack.h2030
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/sha.h203
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl.h2075
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl2.h268
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl23.h83
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl3.h565
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/stack.h109
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/store.h554
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/symhacks.h409
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/tls1.h407
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/tmdiff.h93
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/txt_db.h109
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ui.h381
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509.h1355
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509_vfy.h531
-rw-r--r--installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509v3.h922
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp1253
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h240
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_static_init.pri15
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/p7zip.pri5
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/p7zip.pro3
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zBuf.h39
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zBuf2.c45
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrc.c36
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrc.h30
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrcT8.c43
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zStream.c169
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zVersion.h7
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Aes.c262
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Aes.h54
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Alloc.c127
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Alloc.h42
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra.c133
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra.h68
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra86.c85
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BraIA64.c67
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BwtSort.c516
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BwtSort.h30
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/CpuArch.h80
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Delta.c62
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Delta.h23
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/HuffEnc.c148
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/HuffEnc.h27
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFind.c761
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFind.h115
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFindMt.c793
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFindMt.h105
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzHash.h54
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Dec.c356
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Dec.h84
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Enc.c484
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Enc.h66
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaDec.c1007
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaDec.h231
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaEnc.c2268
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaEnc.h80
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Dec.c61
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Dec.h51
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Enc.c113
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Enc.h78
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/MtCoder.c327
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/MtCoder.h102
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/RotateDefs.h20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sha256.c204
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sha256.h30
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sort.c95
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sort.h20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Threads.c690
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Threads.h196
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Types.h216
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Xz.c88
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Xz.h256
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzCrc64.c33
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzCrc64.h30
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzDec.c875
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzEnc.c497
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzEnc.h25
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzIn.c307
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zCompressionMode.cpp3
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zCompressionMode.h51
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zDecode.cpp332
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zDecode.h68
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zEncode.cpp453
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zEncode.h55
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zExtract.cpp273
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderInStream.cpp130
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderInStream.h66
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderOutStream.cpp140
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderOutStream.h56
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandler.cpp493
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandler.h119
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandlerOut.cpp477
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHeader.cpp27
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHeader.h97
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zIn.cpp1257
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zIn.h245
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zItem.h258
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zOut.cpp874
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zOut.h156
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zProperties.cpp163
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zProperties.h22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zRegister.cpp18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zSpecStream.cpp24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zSpecStream.h35
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zUpdate.cpp1208
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zUpdate.h88
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ArchiveExports.cpp127
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ArjHandler.cpp799
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Bz2Handler.cpp428
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabBlockInStream.cpp189
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabBlockInStream.h44
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHandler.cpp822
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHandler.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHeader.cpp15
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHeader.h44
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabIn.cpp290
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabIn.h166
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabItem.h63
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabRegister.cpp13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHandler.cpp721
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHandler.h29
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHeader.cpp24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHeader.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmIn.cpp940
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmIn.h244
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmRegister.cpp13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComHandler.cpp239
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComHandler.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComIn.cpp359
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComIn.h117
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComRegister.cpp13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2.cpp121
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2.h175
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2MT.cpp230
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2MT.h80
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2ST.cpp239
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2ST.h88
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CrossThreadProgress.cpp15
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CrossThreadProgress.h37
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/DummyOutStream.cpp22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/DummyOutStream.h24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/FindSignature.cpp62
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/FindSignature.h12
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/HandlerOut.cpp623
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/HandlerOut.h87
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/InStreamWithCRC.cpp40
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/InStreamWithCRC.h67
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ItemNameUtils.cpp61
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ItemNameUtils.h24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/MultiStream.cpp201
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/MultiStream.h76
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithCRC.h36
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithSha1.h36
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ParseProperties.cpp177
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ParseProperties.h18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/CpioHandler.cpp625
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DebHandler.cpp394
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DllExports2.cpp74
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DmgHandler.cpp778
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ElfHandler.cpp535
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/FatHandler.cpp983
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/GzHandler.cpp820
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsHandler.cpp244
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsHandler.h26
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsIn.cpp480
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsIn.h154
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsRegister.cpp13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/IArchive.h234
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHandler.cpp278
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHandler.h30
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHeader.cpp21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHeader.h61
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoIn.cpp452
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoIn.h300
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoItem.h141
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoRegister.cpp13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/LzhHandler.cpp783
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/LzmaHandler.cpp436
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MachoHandler.cpp468
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MbrHandler.cpp508
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MubHandler.cpp267
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisDecode.cpp141
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisDecode.h47
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisHandler.cpp489
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisHandler.h43
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisIn.cpp1448
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisIn.h184
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisRegister.cpp14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/NtfsHandler.cpp1725
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/PeHandler.cpp912
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHandler.cpp838
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHandler.h60
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHeader.cpp21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHeader.h224
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarIn.cpp511
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarIn.h126
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarItem.cpp55
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarItem.h79
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarRegister.cpp13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp78
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarVolumeInStream.h49
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/RpmHandler.cpp297
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/SplitHandler.cpp370
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandler.cpp338
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandler.h59
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandlerOut.cpp117
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHeader.cpp25
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHeader.h108
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarIn.cpp181
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarIn.h18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarItem.h69
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarOut.cpp186
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarOut.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarRegister.cpp18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarUpdate.cpp139
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarUpdate.h34
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfHandler.cpp500
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfHandler.h38
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfIn.cpp876
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfIn.h375
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfRegister.cpp13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/VhdHandler.cpp731
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimHandler.cpp619
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimHandler.h66
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimIn.cpp570
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimIn.h235
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimRegister.cpp13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/XarHandler.cpp586
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/XzHandler.cpp714
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ZHandler.cpp171
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipAddCommon.cpp345
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipAddCommon.h59
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipCompressionMode.h39
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandler.cpp823
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandler.h96
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp508
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHeader.cpp36
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHeader.h276
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipIn.cpp851
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipIn.h123
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItem.cpp181
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItem.h281
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItemEx.h34
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipOut.cpp280
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipOut.h56
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipRegister.cpp18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipUpdate.cpp855
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipUpdate.h58
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Bundles/SFXCon/Main.cpp441
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/CMAKE/CMakeLists_Alone.txt251
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/CMAKE/generate.sh14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CWrappers.cpp127
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CWrappers.h46
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CreateCoder.cpp292
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CreateCoder.h98
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilePathAutoRename.cpp55
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilePathAutoRename.h10
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FileStreams.cpp274
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FileStreams.h141
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilterCoder.cpp255
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilterCoder.h143
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InBuffer.cpp80
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InBuffer.h81
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InOutTempBuffer.cpp122
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InOutTempBuffer.h55
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LimitedStreams.cpp154
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LimitedStreams.h124
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LockedStream.cpp23
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LockedStream.h38
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MemBlocks.cpp183
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MemBlocks.h71
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodId.cpp27
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodId.h10
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodProps.cpp99
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodProps.h41
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OffsetStream.cpp35
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OffsetStream.h25
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutBuffer.cpp116
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutBuffer.h64
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutMemStream.cpp142
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutMemStream.h96
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressMt.cpp53
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressMt.h46
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressUtils.cpp42
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressUtils.h34
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/RegisterArc.h38
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/RegisterCodec.h35
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamBinder.cpp161
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamBinder.h48
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamObjects.cpp68
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamObjects.h117
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamUtils.cpp56
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamUtils.h13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/VirtThread.cpp46
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/VirtThread.h23
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder1.cpp315
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder1.h98
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder2.cpp90
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder2.h59
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Const.h54
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Crc.cpp26
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Crc.h31
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Decoder.cpp813
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Decoder.h173
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Encoder.cpp895
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Encoder.h245
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Register.cpp20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Coder.cpp390
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Coder.h125
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Register.cpp19
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjCoder.cpp15
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjCoder.h19
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjRegister.cpp19
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlDecoder.cpp24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlDecoder.h142
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlEncoder.h60
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitmDecoder.h66
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitmEncoder.h52
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchCoder.cpp19
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchCoder.h44
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchMisc.cpp37
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchMisc.h14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchRegister.cpp30
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ByteSwap.cpp73
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CodecExports.cpp160
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyCoder.cpp67
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyCoder.h34
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyRegister.cpp14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Deflate64Register.cpp20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateConst.h134
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateDecoder.cpp353
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateDecoder.h157
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateEncoder.cpp984
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateEncoder.h211
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateNsisRegister.cpp14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateRegister.cpp21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeltaFilter.cpp112
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DllExports.cpp39
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DllExports2.cpp28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/HuffmanDecoder.h89
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeDecoder.cpp219
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeDecoder.h57
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp89
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeHuffmanDecoder.h34
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp531
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp1018
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h49
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp311
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzOutWindow.cpp14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzOutWindow.h66
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzhDecoder.cpp220
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzhDecoder.h106
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Decoder.cpp189
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Decoder.h73
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Encoder.cpp94
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Encoder.h36
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Register.cpp20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaDecoder.cpp239
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaDecoder.h76
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaEncoder.cpp149
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaEncoder.h36
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaRegister.cpp20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx.h61
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx86Converter.cpp90
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx86Converter.h46
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzxDecoder.cpp387
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzxDecoder.h161
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Mtf8.h196
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PPMD_Alone/PpmdAlone.cpp348
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdContext.h490
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecode.h156
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecoder.cpp183
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecoder.h87
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncode.h142
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncoder.cpp148
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncoder.h79
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdRegister.cpp21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdSubAlloc.h293
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdType.h14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/QuantumDecoder.cpp171
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/QuantumDecoder.h287
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RangeCoder.h205
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RangeCoderBit.h114
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar1Decoder.cpp478
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar1Decoder.h88
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar2Decoder.cpp389
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar2Decoder.h174
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Decoder.cpp834
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Decoder.h301
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Vm.cpp1091
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Vm.h179
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RarCodecsRegister.cpp26
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ShrinkDecoder.cpp145
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ShrinkDecoder.h38
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZDecoder.cpp159
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZDecoder.h42
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZlibDecoder.cpp94
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZlibDecoder.h46
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.cpp244
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.h117
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAesRegister.cpp18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.cpp109
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.h39
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.cpp57
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.h45
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp83
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.cpp107
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.cpp133
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.h50
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.cpp139
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.h59
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.cpp211
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.h68
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.cpp209
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.h116
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.cpp128
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.h71
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.cpp177
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.h53
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/ICoder.h179
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IDecl.h15
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IPassword.h24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IProgress.h33
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IStream.h58
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/MyVersion.h11
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/PropID.h75
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/Agent.cpp615
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/Agent.h232
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentOut.cpp535
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentProxy.cpp246
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentProxy.h53
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolder.cpp59
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp121
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp214
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/IFolderArchive.h73
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp121
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/UpdateCallbackAgent.h19
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Client7z/Client7z.cpp853
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/ClientCodec/ClientCodec.cpp370
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveCommandLine.cpp1009
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveCommandLine.h107
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp490
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveExtractCallback.h143
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveName.cpp54
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveName.h10
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp133
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveOpenCallback.h104
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/CompressCall.cpp446
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/CompressCall.h30
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DefaultName.cpp35
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DefaultName.h11
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DirItem.h69
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/EnumDirItems.cpp361
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/EnumDirItems.h26
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExitCode.h27
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Extract.cpp253
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Extract.h76
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractMode.h31
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractingFilePath.cpp141
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractingFilePath.h13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/HandlerLoader.h38
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/IFileExtractCallback.h46
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/LoadCodecs.cpp697
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/LoadCodecs.h220
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/OpenArchive.cpp509
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/OpenArchive.h86
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/PropIDUtils.cpp96
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/PropIDUtils.h12
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Property.h14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SetProperties.cpp79
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SetProperties.h10
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SortUtils.cpp22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SortUtils.h10
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/TempFiles.cpp22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/TempFiles.h16
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Update.cpp908
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Update.h166
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateAction.cpp64
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateAction.h57
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateCallback.cpp249
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateCallback.h76
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdatePair.cpp158
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdatePair.h25
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateProduce.cpp58
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateProduce.h36
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/WorkDir.cpp69
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/WorkDir.h10
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ZipRegistry.cpp417
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ZipRegistry.h98
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ConsoleClose.cpp49
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ConsoleClose.h26
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp228
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ExtractCallbackConsole.h73
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/List.cpp616
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/List.h20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/Main.cpp642
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/MainAr.cpp157
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/OpenCallbackConsole.cpp58
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/OpenCallbackConsole.h24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/PercentPrinter.cpp90
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/PercentPrinter.h31
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp261
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UpdateCallbackConsole.h63
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UserInputUtils.cpp90
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UserInputUtils.h24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Explorer/MyMessages.cpp58
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Explorer/MyMessages.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/App.cpp910
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/App.h344
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/AppState.h114
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ClassDefs.cpp17
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog.cpp53
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog.h25
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialogRes.h4
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog_rc.cpp57
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog.cpp82
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog.h30
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialogRes.h8
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog_rc.cpp73
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ExtractCallback.cpp478
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ExtractCallback.h150
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FM.cpp914
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FM_rc.cpp970
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSDrives.h.out49
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolder.cpp701
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolder.h120
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolderCopy.cpp523
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp165
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h9
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FormatUtils.cpp40
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FormatUtils.h18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/HelpUtils.h10
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/IFolder.h157
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/LangUtils.cpp208
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/LangUtils.h41
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog.cpp96
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog.h32
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialogRes.h3
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog_rc.cpp55
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog.cpp76
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog.h22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialogRes.h3
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog_rc.cpp81
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MyLoadMenu.cpp733
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MyLoadMenu.h20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/NetFolder.h.OUT56
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OpenCallback.cpp122
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OpenCallback.h92
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog.cpp126
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog.h34
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialogRes.h19
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog_rc.cpp96
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/Panel.cpp1100
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/Panel.h577
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelCopy.cpp228
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelCrc.cpp368
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelFolderChange.cpp597
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelItemOpen.cpp621
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelItems.cpp828
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelListNotify.cpp429
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelMenu.cpp621
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelOperations.cpp470
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSelect.cpp305
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSort.cpp163
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSplitFile.cpp528
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog.cpp50
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialogRes.h4
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog_rc.cpp63
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PluginInterface.h42
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PluginLoader.h32
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgramLocation.cpp20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgramLocation.h10
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2.cpp507
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2.h242
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2Res.h26
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2_rc.cpp171
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialogRes.h3
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyName.cpp109
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyName.h10
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyNameRes.h52
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryAssociations.cpp301
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryAssociations.h44
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryPlugins.h32
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryUtils.cpp152
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryUtils.h46
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RootFolder.cpp278
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RootFolder.h38
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog.cpp89
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog.h27
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialogRes.h8
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog_rc.cpp79
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitUtils.cpp85
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitUtils.h15
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/StringUtils.cpp68
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/StringUtils.h13
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SysIconUtils.cpp167
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SysIconUtils.h51
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/TextPairs.cpp189
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/TextPairs.h31
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/UpdateCallback100.cpp106
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/UpdateCallback100.h72
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ViewSettings.cpp426
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ViewSettings.h100
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Add2PNG.h20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/AddPNG.h22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Copy2PNG.h22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/CopyPNG.h26
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Delete2PNG.h23
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/DeletePNG.h26
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Extract2PNG.h18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/ExtractPNG.h18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Info2PNG.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/InfoPNG.h22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Move2PNG.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/MovePNG.h25
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/ParentFolder.h91
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Test2PNG.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/TestPNG.h25
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/resource.h168
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/wxFM.cpp345
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.cpp581
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.h131
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialogRes.h54
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog_rc.cpp245
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.cpp1455
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.h184
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialogRes.h52
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog_rc.cpp283
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.cpp374
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.h77
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialogRes.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog_rc.cpp145
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.cpp230
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.h20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractRes.h19
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/GUI.cpp294
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp256
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.h53
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.cpp389
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.h19
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/resource.h49
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/wxGUI.cpp575
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/AutoPtr.h35
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Buffer.h77
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CRC.cpp7
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/C_FileIO.cpp88
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/C_FileIO.h47
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ComTry.h18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CommandLineParser.cpp233
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CommandLineParser.h72
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Defs.h20
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/DynamicBuffer.h47
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/IntToString.cpp66
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/IntToString.h17
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Lang.cpp130
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Lang.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ListFileUtils.cpp75
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ListFileUtils.h11
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyCom.h225
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyException.h14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyGuidDef.h65
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyInitGuid.h15
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyMap.cpp140
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyMap.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyString.cpp164
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyString.h598
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyUnknown.h24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyVector.cpp87
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyVector.h250
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyWindows.cpp111
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyWindows.h228
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyXml.cpp209
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyXml.h40
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/NewHandler.h16
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdInStream.cpp84
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdInStream.h32
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdOutStream.cpp93
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdOutStream.h35
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringConvert.cpp104
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringConvert.h73
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringToInt.cpp90
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringToInt.h18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/TextConfig.cpp138
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/TextConfig.h22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Types.h11
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/UTFConvert.cpp145
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/UTFConvert.h11
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Wildcard.cpp461
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Wildcard.h80
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/COM.cpp37
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/COM.h61
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Clipboard.cpp159
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Clipboard.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/CommonDialog.h17
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ComboBox.h67
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Controls.cpp467
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Dialog.cpp525
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Dialog.h172
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/DialogImpl.h61
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Edit.h24
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ListView.h157
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ProgressBar.h34
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Static.h23
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/StatusBar.h56
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Window2.cpp211
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Window2.h107
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/DLL.cpp193
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/DLL.h48
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Defs.h23
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Error.cpp64
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Error.h33
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileDir.cpp987
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileDir.h87
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileFind.cpp657
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileFind.h147
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileIO.cpp578
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileIO.h115
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileName.cpp50
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileName.h26
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Handle.h37
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariant.cpp332
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariant.h58
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantConversions.cpp152
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantConversions.h14
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantUtils.cpp77
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantUtils.h28
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Registry.cpp252
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Registry.h107
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/ResourceString.h22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Shell.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization.cpp159
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization.h187
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization2.h264
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/System.cpp178
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/System.h16
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Thread.h38
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Time.cpp86
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Time.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Window.cpp92
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Window.h43
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/basetyps.h19
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/tchar.h89
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/windows.h194
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/StdAfx.h109
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/config.h61
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/initguid.h4
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myAddExeFlag.cpp25
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myGetTickCount.cpp8
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myPrivate.h17
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/mySplitCommandLine.cpp82
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/test_emul.cpp385
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/wine_GetXXXDefaultLangID.cpp731
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/wine_date_and_time.cpp397
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/ChangeLog780
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/7zC.txt194
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/7zFormat.txt469
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/License.txt52
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/add.htm87
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/bench.htm79
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/delete.htm59
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/extract.htm91
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/extract_full.htm68
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/index.htm33
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/list.htm77
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/style.css232
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/test.htm46
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/update.htm66
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/exit_codes.htm27
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/index.htm29
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/style.css232
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_exclude.htm56
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_include.htm83
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_no.htm52
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/charset.htm49
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/exclude.htm60
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/include.htm87
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/index.htm63
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/list_tech.htm36
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/method.htm587
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/output_dir.htm52
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/overwrite.htm56
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/password.htm54
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/recurse.htm83
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/sfx.htm156
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ssc.htm50
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stdin.htm47
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stdout.htm50
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stop_switch.htm31
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/style.css232
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/type.htm77
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/update.htm176
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/volume.htm49
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/working_dir.htm55
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/yes.htm48
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/syntax.htm120
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/Methods.txt137
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/copying.txt504
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/history.txt431
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/lzma.txt591
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/readme.txt181
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/unRarLicense.txt41
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/README263
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/TODO30
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/unix.pri217
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/unix.pro232
-rw-r--r--installerbuilder/libinstaller/NQSDevAgreement.txt204
-rw-r--r--installerbuilder/libinstaller/NQSThirdPartyAgreement.txt1019
-rw-r--r--installerbuilder/libinstaller/adminauthorization.cpp70
-rw-r--r--installerbuilder/libinstaller/adminauthorization.h75
-rw-r--r--installerbuilder/libinstaller/adminauthorization_mac.cpp104
-rw-r--r--installerbuilder/libinstaller/adminauthorization_win.cpp154
-rw-r--r--installerbuilder/libinstaller/adminauthorization_x11.cpp279
-rw-r--r--installerbuilder/libinstaller/componentselectiondialog.cpp210
-rw-r--r--installerbuilder/libinstaller/componentselectiondialog.h67
-rw-r--r--installerbuilder/libinstaller/componentselectiondialog.ui182
-rw-r--r--installerbuilder/libinstaller/content.qrc6
-rw-r--r--installerbuilder/libinstaller/copydirectoryoperation.cpp229
-rw-r--r--installerbuilder/libinstaller/copydirectoryoperation.h72
-rw-r--r--installerbuilder/libinstaller/createdesktopentryoperation.cpp210
-rw-r--r--installerbuilder/libinstaller/createdesktopentryoperation.h50
-rw-r--r--installerbuilder/libinstaller/createshortcutoperation.cpp344
-rw-r--r--installerbuilder/libinstaller/createshortcutoperation.h48
-rw-r--r--installerbuilder/libinstaller/cryptosignatureverifier.h64
-rw-r--r--installerbuilder/libinstaller/de_de.ts742
-rw-r--r--installerbuilder/libinstaller/downloadarchivesjob.cpp341
-rw-r--r--installerbuilder/libinstaller/downloadarchivesjob.h98
-rw-r--r--installerbuilder/libinstaller/elevatedexecuteoperation.cpp235
-rw-r--r--installerbuilder/libinstaller/elevatedexecuteoperation.h60
-rw-r--r--installerbuilder/libinstaller/environmentvariablesoperation.cpp239
-rw-r--r--installerbuilder/libinstaller/environmentvariablesoperation.h53
-rw-r--r--installerbuilder/libinstaller/extractarchiveoperation.cpp198
-rw-r--r--installerbuilder/libinstaller/extractarchiveoperation.h66
-rw-r--r--installerbuilder/libinstaller/extractarchiveoperation_p.h207
-rw-r--r--installerbuilder/libinstaller/fakestopprocessforupdateoperation.cpp138
-rw-r--r--installerbuilder/libinstaller/fakestopprocessforupdateoperation.h49
-rw-r--r--installerbuilder/libinstaller/files-to-patch-linux72
-rw-r--r--installerbuilder/libinstaller/files-to-patch-macx61
-rw-r--r--installerbuilder/libinstaller/files-to-patch-windows60
-rw-r--r--installerbuilder/libinstaller/fsengineclient.cpp1634
-rw-r--r--installerbuilder/libinstaller/fsengineclient.h234
-rw-r--r--installerbuilder/libinstaller/fsengineserver.cpp830
-rw-r--r--installerbuilder/libinstaller/fsengineserver.h80
-rw-r--r--installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp183
-rw-r--r--installerbuilder/libinstaller/getrepositoriesmetainfojob.h98
-rw-r--r--installerbuilder/libinstaller/getrepositorymetainfojob.cpp425
-rw-r--r--installerbuilder/libinstaller/getrepositorymetainfojob.h110
-rw-r--r--installerbuilder/libinstaller/globalsettingsoperation.cpp128
-rw-r--r--installerbuilder/libinstaller/globalsettingsoperation.h53
-rw-r--r--installerbuilder/libinstaller/init.cpp204
-rw-r--r--installerbuilder/libinstaller/init.h35
-rw-r--r--installerbuilder/libinstaller/installationprogressdialog.cpp87
-rw-r--r--installerbuilder/libinstaller/installationprogressdialog.h53
-rw-r--r--installerbuilder/libinstaller/installer_global.h51
-rw-r--r--installerbuilder/libinstaller/installerbase.qrc8
-rw-r--r--installerbuilder/libinstaller/installiconsoperation.cpp327
-rw-r--r--installerbuilder/libinstaller/installiconsoperation.h57
-rw-r--r--installerbuilder/libinstaller/kdmmappedfileiodevice.cpp108
-rw-r--r--installerbuilder/libinstaller/kdmmappedfileiodevice.h60
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDAutoPointer1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDByteSize1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDGenericFactory1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDJob1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDLockfile1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDMetaMethodIterator1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDRunOnceChecker1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDSaveFile1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDSelfRestarter1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDSysInfo1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDToolsCore.pri42
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/KDWatchdog1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.cpp577
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.h147
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.cpp90
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.h51
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.cpp250
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.h90
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.cpp148
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.h104
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.cpp90
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.h47
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_p.h52
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_unix.cpp77
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_win.cpp69
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.cpp493
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.h85
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.cpp133
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.h46
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.cpp476
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.h83
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.cpp78
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.h42
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.cpp191
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.h116
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_mac.cpp119
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_win.cpp323
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_x11.cpp163
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.cpp54
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.h135
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.cpp89
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.h52
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.cpp115
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.h60
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.cpp225
-rw-r--r--installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.h66
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/Application1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloader1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloaderFactory1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater20
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater.pri73
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/PackagesInfo1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerificationResult1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerifier1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/Update1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/UpdateFinder1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperation1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperationFactory1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/UpdateSourcesInfo1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/UpdatesDialog1
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/addupdatesourcedialog.ui193
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/environment.cpp55
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/environment.h36
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdater.h62
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.cpp324
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.h93
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.cpp743
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.h99
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.cpp1165
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.h105
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader_p.h243
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp129
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h71
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp566
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.h117
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.cpp134
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.h53
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp88
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.h65
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp135
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h85
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.cpp46
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.h46
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.cpp440
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.h99
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp131
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h71
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor.cpp220
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor_p.h58
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.cpp313
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.h86
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.cpp892
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.h70
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp481
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.h64
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.cpp417
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.h91
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp116
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h65
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.cpp1120
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.h184
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp305
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.h57
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp372
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h99
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp511
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h112
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp375
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.h68
-rw-r--r--installerbuilder/libinstaller/kdtools/KDUpdater/updatesdialog.ui245
-rw-r--r--installerbuilder/libinstaller/kdtools/LICENSE.LGPL488
-rw-r--r--installerbuilder/libinstaller/lazyplaintextedit.cpp89
-rw-r--r--installerbuilder/libinstaller/lazyplaintextedit.h48
-rw-r--r--installerbuilder/libinstaller/libinstaller.pri48
-rw-r--r--installerbuilder/libinstaller/libinstaller.pro186
-rw-r--r--installerbuilder/libinstaller/licenseoperation.cpp117
-rw-r--r--installerbuilder/libinstaller/licenseoperation.h54
-rw-r--r--installerbuilder/libinstaller/linereplaceoperation.cpp125
-rw-r--r--installerbuilder/libinstaller/linereplaceoperation.h47
-rw-r--r--installerbuilder/libinstaller/macrelocateqt.cpp224
-rw-r--r--installerbuilder/libinstaller/macrelocateqt.h56
-rw-r--r--installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp217
-rw-r--r--installerbuilder/libinstaller/macreplaceinstallnamesoperation.h61
-rw-r--r--installerbuilder/libinstaller/messageboxhandler.cpp216
-rw-r--r--installerbuilder/libinstaller/messageboxhandler.h110
-rw-r--r--installerbuilder/libinstaller/minimumprogressoperation.cpp72
-rw-r--r--installerbuilder/libinstaller/minimumprogressoperation.h54
-rw-r--r--installerbuilder/libinstaller/patch_file_lists.qrc7
-rw-r--r--installerbuilder/libinstaller/performinstallationform.cpp177
-rw-r--r--installerbuilder/libinstaller/performinstallationform.h75
-rw-r--r--installerbuilder/libinstaller/progresscoordinator.cpp267
-rw-r--r--installerbuilder/libinstaller/progresscoordinator.h79
-rw-r--r--installerbuilder/libinstaller/qinstaller.cpp3356
-rw-r--r--installerbuilder/libinstaller/qinstaller.h266
-rw-r--r--installerbuilder/libinstaller/qinstallercomponent.cpp1103
-rw-r--r--installerbuilder/libinstaller/qinstallercomponent.h197
-rw-r--r--installerbuilder/libinstaller/qinstallercomponentmodel.cpp522
-rw-r--r--installerbuilder/libinstaller/qinstallercomponentmodel.h95
-rw-r--r--installerbuilder/libinstaller/qinstallerglobal.h76
-rw-r--r--installerbuilder/libinstaller/qinstallergui.cpp1721
-rw-r--r--installerbuilder/libinstaller/qinstallergui.h374
-rw-r--r--installerbuilder/libinstaller/qtpatch.cpp237
-rw-r--r--installerbuilder/libinstaller/qtpatch.h52
-rw-r--r--installerbuilder/libinstaller/qtpatchoperation.cpp349
-rw-r--r--installerbuilder/libinstaller/qtpatchoperation.h48
-rw-r--r--installerbuilder/libinstaller/registerdocumentationoperation.cpp154
-rw-r--r--installerbuilder/libinstaller/registerdocumentationoperation.h48
-rw-r--r--installerbuilder/libinstaller/registerfiletypeoperation.cpp215
-rw-r--r--installerbuilder/libinstaller/registerfiletypeoperation.h48
-rw-r--r--installerbuilder/libinstaller/registerqtoperation.cpp134
-rw-r--r--installerbuilder/libinstaller/registerqtoperation.h48
-rw-r--r--installerbuilder/libinstaller/replaceoperation.cpp117
-rw-r--r--installerbuilder/libinstaller/replaceoperation.h47
-rw-r--r--installerbuilder/libinstaller/selfrestartoperation.cpp88
-rw-r--r--installerbuilder/libinstaller/selfrestartoperation.h48
-rw-r--r--installerbuilder/libinstaller/setdemospathonqtoperation.cpp132
-rw-r--r--installerbuilder/libinstaller/setdemospathonqtoperation.h49
-rw-r--r--installerbuilder/libinstaller/setexamplespathonqtoperation.cpp133
-rw-r--r--installerbuilder/libinstaller/setexamplespathonqtoperation.h49
-rw-r--r--installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp155
-rw-r--r--installerbuilder/libinstaller/setimportspathonqtcoreoperation.h49
-rw-r--r--installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp155
-rw-r--r--installerbuilder/libinstaller/setpluginpathonqtcoreoperation.h49
-rw-r--r--installerbuilder/libinstaller/setqtcreatorvalueoperation.cpp120
-rw-r--r--installerbuilder/libinstaller/setqtcreatorvalueoperation.h49
-rw-r--r--installerbuilder/libinstaller/simplemovefileoperation.cpp124
-rw-r--r--installerbuilder/libinstaller/simplemovefileoperation.h54
-rw-r--r--installerbuilder/libinstaller/sv_se.ts742
-rw-r--r--installerbuilder/libinstaller/updateagent.cpp126
-rw-r--r--installerbuilder/libinstaller/updateagent.h56
-rw-r--r--installerbuilder/libinstaller/updater.cpp324
-rw-r--r--installerbuilder/libinstaller/updater.h64
-rw-r--r--installerbuilder/libinstaller/updatesettings.cpp170
-rw-r--r--installerbuilder/libinstaller/updatesettings.h79
-rw-r--r--installerbuilder/libinstaller/updatesettingsdialog.cpp83
-rw-r--r--installerbuilder/libinstaller/updatesettingsdialog.h58
-rw-r--r--installerbuilder/libinstaller/updatesettingsdialog.ui39
-rw-r--r--installerbuilder/libinstaller/updatesettingswidget.cpp161
-rw-r--r--installerbuilder/libinstaller/updatesettingswidget.h64
-rw-r--r--installerbuilder/libinstaller/updatesettingswidget.ui286
-rw-r--r--installerbuilder/operationrunner/operationrunner.cpp92
-rw-r--r--installerbuilder/operationrunner/operationrunner.pro18
-rw-r--r--installerbuilder/repogen/repogen.cpp171
-rw-r--r--installerbuilder/repogen/repogen.pro18
-rw-r--r--installerbuilder/tests/environmentvariable/environmentvariable.pro20
-rw-r--r--installerbuilder/tests/environmentvariable/environmentvariabletest.cpp99
-rw-r--r--installerbuilder/tests/environmentvariable/environmentvariabletest.h43
-rw-r--r--installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.cpp162
-rw-r--r--installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.h46
-rw-r--r--installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.pro20
-rw-r--r--installerbuilder/tests/kd7zenginetest/kd7zenginetest.cpp377
-rw-r--r--installerbuilder/tests/kd7zenginetest/kd7zenginetest.h45
-rw-r--r--installerbuilder/tests/kd7zenginetest/kd7zenginetest.pro16
-rw-r--r--installerbuilder/tests/test-noarchive.7z190
-rw-r--r--installerbuilder/tests/test1.7zbin0 -> 282 bytes
-rw-r--r--installerbuilder/tests/test2.7zbin0 -> 629 bytes
-rw-r--r--installerbuilder/tests/tests.pro11
-rw-r--r--installerfw.pro10
-rw-r--r--maddehelper/maddehelper.pro12
-rw-r--r--maddehelper/main.cpp306
-rw-r--r--repogenfromonlinerepo/downloadmanager.cpp172
-rw-r--r--repogenfromonlinerepo/downloadmanager.h84
-rw-r--r--repogenfromonlinerepo/main.cpp306
-rw-r--r--repogenfromonlinerepo/repogenfromonlinerepo.pro16
-rw-r--r--repogenfromonlinerepo/textprogressbar.cpp98
-rw-r--r--repogenfromonlinerepo/textprogressbar.h63
-rw-r--r--test-framework/README312
-rw-r--r--test-framework/checker/run.py51
-rw-r--r--test-framework/checker/scripts/generate-filelist.py41
-rw-r--r--test-framework/checker/testrunner/__init__.py1
-rw-r--r--test-framework/checker/testrunner/files.py33
-rw-r--r--test-framework/checker/testrunner/logger.py0
-rw-r--r--test-framework/checker/testrunner/registry.py21
-rw-r--r--test-framework/checker/testrunner/testexception.py5
-rw-r--r--test-framework/checker/testrunner/testrunner.py90
-rw-r--r--test-framework/site/TestCases/testcase-linux64/checker/testinstall.filelist5
-rw-r--r--test-framework/site/TestCases/testcase-linux64/testcase-linux64.cfg5
-rw-r--r--test-framework/site/TestCases/testcase-linux64/testscript.qs67
-rw-r--r--test-framework/site/TestCases/testcase1/checker/testinstall.filelist5
-rw-r--r--test-framework/site/TestCases/testcase1/testcase1.cfg5
-rw-r--r--test-framework/site/TestCases/testcase1/testscript.qs67
-rw-r--r--test-framework/site/VMConfigs/LinuxUbuntu9.1064Bit.cfg8
-rw-r--r--test-framework/site/VMConfigs/WindowsVista32Bit.cfg9
-rw-r--r--test-framework/site/VMConfigs/WindowsVista64Bit.cfg9
-rw-r--r--test-framework/site/VMConfigs/WindowsXp32Bit.cfg9
-rw-r--r--test-framework/site/VMConfigs/WindowsXp64Bit.cfg9
-rw-r--r--test-framework/site/host-config.cfg37
-rw-r--r--test-framework/site/listVMs.sh1
-rw-r--r--test-framework/tests/simpletest.py11
-rw-r--r--test-framework/tests/testfiles/test.filelist3
-rw-r--r--test-framework/vmware/cdashreporter.py156
-rw-r--r--test-framework/vmware/control.py220
-rw-r--r--test-framework/vmware/ftpsource.py117
-rw-r--r--test-framework/vmware/guest.py160
-rw-r--r--test-framework/vmware/guestconfig.py11
-rw-r--r--test-framework/vmware/reporter.py96
-rw-r--r--test-framework/vmware/result.py148
-rw-r--r--test-framework/vmware/run-test.py111
-rw-r--r--test-framework/vmware/run.py106
-rw-r--r--test-framework/vmware/source.py36
-rw-r--r--test-framework/vmware/testcase.py70
-rw-r--r--test-framework/vmware/utils.py59
-rw-r--r--test-framework/vmware/virtualmachine.py177
-rw-r--r--test-framework/vmware/xmlutils.py13
1353 files changed, 241799 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..7bacc11f3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,236 @@
+# This file is used to ignore files which are generated in the Qt build system
+# ----------------------------------------------------------------------------
+
+examples/*/*/*
+!examples/*/*/*[.]*
+!examples/*/*/README
+examples/*/*/*[.]app
+!examples/declarative/*
+!examples/tutorials/*
+!examples/ja_JP/*/*
+demos/*/*
+!demos/spectrum/*
+demos/spectrum/bin
+!demos/*/*[.]*
+demos/*/*[.]app
+!demos/declarative/*
+config.tests/*/*/*
+!config.tests/*/*/*[.]*
+config.tests/*/*/*[.]app
+
+callgrind.out.*
+pcviewer.cfg
+*~
+*.a
+*.la
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.swp
+*.rej
+*.so
+*.pbxuser
+*.mode1
+*.mode1v3
+*_pch.h.cpp
+*_resource.rc
+.#*
+*.*#
+core
+.qmake.cache
+.qmake.vars
+*.prl
+tags
+.DS_Store
+*.debug
+Makefile*
+!qmake/Makefile.win32*
+!qmake/Makefile.unix
+*.prl
+*.app
+*.pro.user
+*.gcov
+bin/Qt*.dll
+bin/assistant*
+bin/designer*
+bin/dumpcpp*
+bin/idc*
+bin/linguist*
+bin/lrelease*
+bin/lupdate*
+bin/lconvert*
+bin/moc*
+bin/makeqpf*
+bin/pixeltool*
+bin/qmake*
+bin/qdoc3*
+bin/qt3to4*
+bin/qtdemo*
+bin/qttracereplay*
+bin/rcc*
+bin/uic*
+bin/patternist*
+bin/phonon*
+bin/qcollectiongenerator*
+bin/qdbus*
+bin/qhelpconverter*
+bin/qhelpgenerator*
+bin/qtconfig*
+bin/xmlpatterns*
+bin/cetest*
+bin/collectiongenerator
+bin/helpconverter
+bin/helpgenerator
+bin/kmap2qmap*
+bin/qlalr*
+bin/qmlconv*
+bin/qmldebugger*
+bin/qml*
+bin/qttracereplay*
+configure.cache
+config.status
+mkspecs/default
+mkspecs/qconfig.pri
+moc_*.cpp
+qmake/qmake.exe
+qmake/Makefile.bak
+src/corelib/global/qconfig.cpp
+src/corelib/global/qconfig.h
+src/corelib/global/qconfig.h.qmake
+src/tools/uic/qclass_lib_map.h
+ui_*.h
+tests/auto/qprocess/test*/*.exe
+tests/auto/qtcpsocket/stressTest/*.exe
+tests/auto/qprocess/fileWriterProcess/*.exe
+tests/auto/qmake/testdata/quotedfilenames/*.exe
+tests/auto/compilerwarnings/*.exe
+tests/auto/qmake/testdata/quotedfilenames/test.cpp
+tests/auto/qprocess/fileWriterProcess.txt
+.com.apple.timemachine.supported
+tests/auto/qlibrary/libmylib.so*
+tests/auto/qresourceengine/runtime_resource.rcc
+tools/qtestlib/chart/chart*
+tools/qtestlib/updater/updater*
+tools/activeqt/testcon/testcon.tlb
+translations/*.qm
+translations/*_untranslated.ts
+qrc_*.cpp
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.vcxproj
+*.vcxproj.filters
+*.vcxproj.user
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# WebKit temp files
+src/3rdparty/webkit/WebCore/mocinclude.tmp
+src/3rdparty/webkit/includes.txt
+src/3rdparty/webkit/includes2.txt
+
+# Symlinks generated by configure
+tools/qvfb/qvfbhdr.h
+tools/qvfb/qlock_p.h
+tools/qvfb/qlock.cpp
+tools/qvfb/qwssignalhandler.cpp
+tools/qvfb/qwssignalhandler_p.h
+.DS_Store
+.pch
+.rcc
+*.app
+config.status
+config.tests/unix/cups/cups
+config.tests/unix/getaddrinfo/getaddrinfo
+config.tests/unix/getifaddrs/getifaddrs
+config.tests/unix/iconv/iconv
+config.tests/unix/ipv6/ipv6
+config.tests/unix/ipv6ifname/ipv6ifname
+config.tests/unix/largefile/largefile
+config.tests/unix/nis/nis
+config.tests/unix/odbc/odbc
+config.tests/unix/openssl/openssl
+config.tests/unix/stl/stl
+config.tests/unix/zlib/zlib
+config.tests/unix/3dnow/3dnow
+config.tests/unix/mmx/mmx
+config.tests/unix/sse/sse
+config.tests/unix/sse2/sse2
+
+
+
+# Directories to ignore
+# ---------------------
+
+debug
+examples/tools/plugandpaint/plugins
+include/*
+include/*/*
+lib/*
+!lib/fonts
+!lib/README
+plugins/*/*
+release
+tmp
+doc-build
+doc/html/*
+doc/qch
+doc-build
+.rcc
+.pch
+.metadata
+
+# Symbian build system generated files
+# ---------------------
+
+ABLD.BAT
+bld.inf
+*.mmp
+*.mk
+*.rss
+*.loc
+!s60main.rss
+*.pkg
+plugin_commonu.def
+*.qtplugin
+*.sis
+*.sisx
+*.lst
+*.exe
+*.mif
+*.rsc
+*.sym
+*.lib
+
+# Generated by abldfast.bat from devtools.
+.abldsteps.*
+
+# Carbide project files
+# ---------------------
+.project
+.cproject
+.make.cache
+*.d
+
+qtc-debugging-helper
+src/corelib/lib
+src/network/lib
+src/xml/lib/
diff --git a/Doxyfile b/Doxyfile
new file mode 100644
index 000000000..eb310cbdb
--- /dev/null
+++ b/Doxyfile
@@ -0,0 +1,69 @@
+PROJECT_NAME = Installer Builder
+OUTPUT_DIRECTORY = doc
+HTML_OUTPUT = refman
+INHERIT_DOCS = NO
+DISTRIBUTE_GROUP_DOC = YES
+TAB_SIZE = 8
+EXTRACT_PRIVATE = YES
+EXTRACT_STATIC = YES
+HIDE_UNDOC_MEMBERS = YES
+HIDE_UNDOC_CLASSES = YES
+HIDE_FRIEND_COMPOUNDS = YES
+CASE_SENSE_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+SORT_MEMBER_DOCS = NO
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = YES
+QUIET = YES
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_LOGFILE = doxygen.log
+INPUT = installerbuilder
+ALIASES = "inv=\invariant" \
+ "since_l=\nThis library was introduced in KDTools " \
+ "since_c=\nThis class was introduced in KDTools " \
+ "since_f=\nThis function was introduced in KDTools " \
+ "since_e=\nThis enumeration was introduced in KDTools " \
+ "since_p=\nThis property was introduced in KDTools " \
+ "since_v=\nThis enumeration value was introduced in KDTools " \
+ "reimp=\internal"
+FILE_PATTERNS = [a-z]*.cpp [a-z]*.h *.dox
+RECURSIVE = YES
+EXCLUDE = installerbuilder/tests
+EXCLUDE_PATTERNS = moc_*.cpp ui_*.h qrc_*.cpp
+EXAMPLE_PATH = examples
+EXAMPLE_PATTERNS = [a-z]*.cpp [a-z]*.h
+EXAMPLE_RECURSIVE = YES
+#IMAGE_PATH = images
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION = NO
+VERBATIM_HEADERS = YES
+GENERATE_HTML = YES
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = YES
+EXPAND_ONLY_PREDEF = YES
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+PREDEFINED = \
+ "DOXYGEN_PROPERTY(x)=Q_PROPERTY(x)" \
+ "Q_PRIVATE_SLOT(x,y)=" \
+ "KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR(x):=public:operator unspecified_bool_type() const;" \
+ "KDAB_USING_SAFE_BOOL_OPERATOR(x):=public:operator unspecified_bool_type() const;" \
+ "CONST=" \
+ DOXYGEN_RUN
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+TAGFILES = \
+ qt4.tag=http://doc.trolltech.com/4.3 \
+ libstdc++.tag=http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen
+GENERATE_TAGFILE = kdt.tag
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = NO
+PERL_PATH = /usr/bin/perl
+#HTML_FOOTER = images/footer.html
+GENERATE_TODOLIST = NO
diff --git a/LGPL_EXCEPTION.txt b/LGPL_EXCEPTION.txt
new file mode 100644
index 000000000..8f73eca77
--- /dev/null
+++ b/LGPL_EXCEPTION.txt
@@ -0,0 +1,22 @@
+Nokia Qt LGPL Exception version 1.1
+
+As an additional permission to the GNU Lesser General Public License version
+2.1, the object code form of a "work that uses the Library" may incorporate
+material from a header file that is part of the Library. You may distribute
+such object code under terms of your choice, provided that:
+ (i) the header files of the Library have not been modified; and
+ (ii) the incorporated material is limited to numerical parameters, data
+ structure layouts, accessors, macros, inline functions and
+ templates; and
+ (iii) you comply with the terms of Section 6 of the GNU Lesser General
+ Public License version 2.1.
+
+Moreover, you may apply this exception to a modified version of the Library,
+provided that such modification does not involve copying material from the
+Library into the modified Library's header files unless such material is
+limited to (i) numerical parameters; (ii) data structure layouts;
+(iii) accessors; and (iv) small macros, templates and inline functions of
+five lines or less in length.
+
+Furthermore, you are not required to apply this additional permission to a
+modified version of the Library.
diff --git a/README b/README
new file mode 100644
index 000000000..7f9dc9de9
--- /dev/null
+++ b/README
@@ -0,0 +1,85 @@
+These are instructions for the Nokia SDK installer.
+
+== Qt configuration ==
+
+Recommended configure options:
+
+Windows static/release:
+
+configure -static -release -no-webkit -platform win32-msvc2008 -no-phonon -fast -no-dbus -no-opengl -exceptions -nomake demos -nomake examples -confirm-license -commercial
+
+
+
+== Tested Platforms ==
+
+Platforms tested so far:
+
+On all platforms: Qt 4.5.2
+
+Linux 32bit, gcc 4.3.3: CI, tested, works
+Linux 64bit, gcc 4.3.3: CI, tested, works
+OS X 10.5 32 bit, gcc 4.0.1: CI, tested, works
+OS X 10.6 32 bit: not tested
+OS X 10.6 64 bit: not tested
+Windows 32 bit XP, MSVC 2005/2008: CI, tested, works
+Windows Vista 32 bit: not tested
+Windows Vista 64 bit: not tested
+
+
+== Build ==
+
+Shared build of the actual installer lib is not supported any longer.
+Only examples/updaterplugin, the Qt Creator plugin, is build shared.
+
+Note: To build the Qt Creator plugin, an environment variable QTCREATOR_SOURCE_PATH
+containing the path to the Qt Creator source directory needs to be set:
+
+export QTCREATOR_SOURCE_PATH=~/Downloads/qt-creator-1.3.0/
+or
+set QTCREATOR_SOURCE_PATH=C:\Downloads\qt-creator-1.3.0\
+
+To build an installer, it is advised to use a statically linked Qt. The Creator plugin
+needs to be linked against a shared Qt, though.
+
+
+=== Static/Debug/Unix ===
+
+cd installer/kdtools/kdtools
+./configure.sh -static -debug
+make
+cd /path/to/installer
+./configure.sh -static -debug
+make
+
+== Static/Debug/Windows ==
+
+cd installer\kdtools\kdtools
+configure.bat -static -debug
+nmake
+cd P:\ath\to\installer
+configure.bat -static -debug
+nmake
+
+== Create an Installer ==
+
+To create an installer, use binarycreator:
+
+in windows;
+cd installerbuilder
+bin\binarycreator.exe -t bin\installerbase.exe -p ..\examples\packages -c ..\examples\config createdinstaller.exe com.nokia.sdk
+
+in unix;
+cd installerbuilder
+bin/binarycreator -t bin/installerbase -p ../examples/packages -c ../examples/config createdinstaller com.nokia.sdk
+
+This creates an installer "createdinstaller.exe" from the installerbase binary and the components required by the com.nokia.sdk package.
+
+
+== Create an Archive ==
+
+To create an 7zip archive named qt-copy.7z that contains the directory qt-copy use:
+
+cd /path/where/qt-copy/is/located
+7z a -t7z -mx=9 -ms=off -l qt-copy.7z qt-copy
+
+
diff --git a/admin/buildscript.py b/admin/buildscript.py
new file mode 100644
index 000000000..5d5e5bc35
--- /dev/null
+++ b/admin/buildscript.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+import copy, platform, os, re
+from AutobuildCore.Configuration import Configuration
+from AutobuildCore.Project import Project
+from AutobuildCore.helpers.build_script_helpers import DebugN
+from AutobuildCore.helpers.build_script_helpers import AddToPathCollection
+from AutobuildCore.helpers.platformdefs import PlatformDefs
+from AutobuildCore.helpers.exceptdefs import AutobuildException
+from AutobuildCore import autobuildRoot
+from AutobuildCore import Callback
+
+hiddenFileIdent = '.'
+
+buildSequenceSwitches = ''
+
+#if 'Windows' in platform.platform():
+# buildSequenceSwitches += ',disable-conf-bin-package'
+# hiddenFileIdent = '_'
+
+
+class KDToolsBuilder( Callback.ConfigurationCallback ):
+ def __init__( self, platform ):
+ Callback.ConfigurationCallback.__init__( self, 'KD Tools Builder' )
+ self.__platform = platform
+
+ def preBuildCallback( self, job ):
+ config = job.configuration()
+ project = config.project()
+ kdtoolsFolder = job.buildDir() + os.sep + 'kdtools' + os.sep + 'kdtools'
+ if 'Windows' in self.__platform:
+ confcmd = 'configure.bat ' + config.getOptions()
+ else:
+ confcmd = './configure.sh ' + config.getOptions()
+ step = job.executomat().step( 'conf-configure' )
+ step.addPreCommand( confcmd, kdtoolsFolder )
+ defs = PlatformDefs.GivePlatformDefs()
+ makecmd = defs.makeProgram()
+ step.addPreCommand( makecmd, kdtoolsFolder )
+ maketestcmd = defs.makeProgram() + ' test'
+ step.addPreCommand( maketestcmd, kdtoolsFolder )
+ AddToPathCollection( defs.libPathVariable() , kdtoolsFolder + os.sep + 'lib' )
+
+scmPath = 'svn+ssh://svn.kdab.net/home/SVN-klaralv/projects/Nokia/SDK'
+product = Project( 'Installer' )
+
+product.setScmUrl( scmPath + '/trunk' )
+#product.setPackageLocation( 'svn.kdab.net:/home/build/autobuild/packages/kdchart' )
+product.setBuildSequenceSwitches( 's', buildSequenceSwitches )
+product.setBuildSequenceSwitches( 'f', buildSequenceSwitches )
+product.getSettings().addRecipientOnSuccess( 'nokia-sdk@kdab.net' )
+product.getSettings().addRecipientOnFailure( 'nokia-sdk@kdab.net' )
+
+debug = Configuration( product, 'Debug' )
+debug.addCallback( KDToolsBuilder( platform.platform() ) )
+debug.setBuilder('autotools')
+debug.setPackageDependencies( [ 'Qt-4.[5-9].?-Static-Debug' ] )
+debug.setBuildMode( 'inSource' )
+debug.setOptions( '-static -debug' )
+debug.setBuildTypes('MCDFE')
+
+release = copy.copy( debug ) # use debug as the base configuration
+release.setConfigName( 'Release' )
+release.setPackageDependencies( [ 'Qt-4.[5-9].?-Static-Release' ] )
+release.setOptions( '-static -release' )
+release.setBuildTypes( 'MCDSFE' ) # snapshots are release builds
+
+
+jobs = [ debug, release ]
+#jobs = [ debug, eval ]
+
+product.build( jobs )
diff --git a/binarysign/README b/binarysign/README
new file mode 100644
index 000000000..3c9ef95cc
--- /dev/null
+++ b/binarysign/README
@@ -0,0 +1,35 @@
+== How to create a test certificate ==
+
+Install the .net SDK (for makecert and signtool)
+In theory, it should also work with openssl >= 0.9.9, but I have 0.9.8 everywhere and 1.0.0beta didn't compile.
+
+On an SDK prompt, type
+
+makecert -r -pe -ss TestCertStoreName -n "CN=SDK Test Certificate" -sv testcert.pvk testcert.cer
+
+
+PASSPHRASE => The checked in testcert.pvk has the passphrase "test"
+
+== How to sign a binary ==
+
+These are the steps I took to create a test signature. You need test certificate (.cer from above), test private key (.pvk from above) and the binary to sign.
+
+signtool signwizard
+
+* Choose the .exe to sign
+* Next
+* Choose Custom
+* Next
+* Choose "Select From File", select testcert.cer
+* Next
+* Browse..., select testcert.pvk
+* Next
+* Enter passphrase
+* Choose hash algorithm. Tested with sha1.
+* Next
+* Next
+* Enter something for description and web location
+* Next
+* Next
+* Finish
+
diff --git a/binarysign/TestPublisher.cer b/binarysign/TestPublisher.cer
new file mode 100644
index 000000000..1aff4f9f6
--- /dev/null
+++ b/binarysign/TestPublisher.cer
Binary files differ
diff --git a/binarysign/TestPublisher.der b/binarysign/TestPublisher.der
new file mode 100644
index 000000000..b95ace196
--- /dev/null
+++ b/binarysign/TestPublisher.der
Binary files differ
diff --git a/binarysign/TestPublisher.pem b/binarysign/TestPublisher.pem
new file mode 100644
index 000000000..f696dbfdd
--- /dev/null
+++ b/binarysign/TestPublisher.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDvgUoPb83ezhUlxjK84ua5ZCNdoIZUF5DoU64nJ6fLCd1xXKQ6
+w9Kdn3jAIiAUVzGWNv6PBlO0J/ywFl+vo2D/aRx6ilyXunWdXnlYZx5bxetrMQtR
+nrUvfYqEylzVAthFuFJptcSTOcS16b5WljYB+hvbq025eOq6H1PlDWh9zwIDAQAB
+AoGBAO446RNFn723ua0i4KCkB93qzop3+mR2NDoB0b08Ylc/7rSs8uVIlZsWXaKt
+zr6so7PH65cTMfqFs37qIi6vEO/OZQRlxDj0pNM0mVgogSFXZK3TIWgzCIxtgrCw
+PVwgE9akwD0tiT45OpRZaBouh8w8mhXIUXLbsoA+p/jeglnRAkEA983y0VYLugeU
+1spTR+mf2BEgCZInmCakyvvCz3ThGGWwtGDt/gDeprSFgP8FXGzOQ+Z9bPwskPjt
+1c499fhjFQJBAPdtErA76DupO54bICpUp7m0+uv4lOY7mdczvVeirtiUMD2TZScj
+jduoo0HHlvJ5uknM1PAxgevHrsQA5A5OZlMCQAekRTmpYqEw/KkHAjx0euZp2MgS
+xr/NaUWNL/u/yfU7pZBacNxlYHhZlshclOi9vjqfz/xdZm5uDr+KJaUBLOUCQQCC
+YtA+XtN63Su1ncXNiN76Vg0E3PJagX4IkhNtYyWQrEbfrBTaEzpmTu/5chxxmwQ4
+b+Cm0vAMOCY4099aSqZRAkBDmslMna035kmp6Lm3hnawFwYp1IhhptPJfbWrn9bi
+in04qSbpd2GlhZeTL62HSuOjkhq9jog7/Ql8GoDlYXtu
+-----END RSA PRIVATE KEY-----
diff --git a/binarysign/TestPublisher.pvk b/binarysign/TestPublisher.pvk
new file mode 100644
index 000000000..9552c1ad7
--- /dev/null
+++ b/binarysign/TestPublisher.pvk
Binary files differ
diff --git a/binarysign/TestPublisher.spc b/binarysign/TestPublisher.spc
new file mode 100644
index 000000000..130142fca
--- /dev/null
+++ b/binarysign/TestPublisher.spc
Binary files differ
diff --git a/binarysign/scripts/generate-keys.sh b/binarysign/scripts/generate-keys.sh
new file mode 100644
index 000000000..2d4f19c32
--- /dev/null
+++ b/binarysign/scripts/generate-keys.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+if [ -z "$1" ]; then
+ echo "Usage: generate-keys.sh certname"
+ exit 1
+fi
+
+NAME=$1
+
+echo Creating RSA key...
+
+openssl genrsa -out $NAME-rsaprivkey.pem 1024
+openssl rsa -in $NAME-rsaprivkey.pem -pubout -outform DER -out $NAME-rsapubkey.der
+openssl pkcs8 -topk8 -inform PEM -outform DER -in $NAME-rsaprivkey.pem -out $NAME-rsaprivkey.der -nocrypt
+
+echo Creating DSA key...
+
+openssl dsaparam -out $NAME-dsaparam.pem 1024
+openssl gendsa -out $NAME-dsaprivkey.pem $NAME-dsaparam.pem
+
+openssl dsa -in $NAME-dsaprivkey.pem -outform DER -pubout -out $NAME-dsapubkey.der
+openssl pkcs8 -topk8 -inform PEM -outform DER -in $NAME-dsaprivkey.pem -out $NAME-dsaprivkey.der -nocrypt
+
+echo Creating X.509 Certificate...
+
+openssl genrsa -des3 -out $NAME-ca.key 4096
+openssl req -new -x509 -days 365 -key $NAME-ca.key -outform DER -out $NAME-ca.cer
+openssl req -new -x509 -days 365 -key $NAME-ca.key -out $NAME-ca.crt
+openssl crl2pkcs7 -nocrl -certfile $NAME-ca.cer -out $NAME-ca.p7b -certfile $NAME-ca.crt
diff --git a/binarysign/sign.sh b/binarysign/sign.sh
new file mode 100644
index 000000000..3377b91ce
--- /dev/null
+++ b/binarysign/sign.sh
@@ -0,0 +1,5 @@
+ osslsigncode -spc TestPublisher.spc -key TestPublisher.der \
+ -n "The Installer" -i http://www.yourwebsite.com/ \
+ -in $1.exe -out $1-signed.exe
+
+
diff --git a/binarysign/testcert.cer b/binarysign/testcert.cer
new file mode 100644
index 000000000..69e550a57
--- /dev/null
+++ b/binarysign/testcert.cer
Binary files differ
diff --git a/binarysign/testcert.pvk b/binarysign/testcert.pvk
new file mode 100644
index 000000000..306de11a1
--- /dev/null
+++ b/binarysign/testcert.pvk
Binary files differ
diff --git a/doc/classic.css b/doc/classic.css
new file mode 100644
index 000000000..f97bdbeab
--- /dev/null
+++ b/doc/classic.css
@@ -0,0 +1,295 @@
+BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV {
+ font-family: Arial, Geneva, Helvetica, sans-serif;
+}
+H1 {
+ text-align: center;
+ font-size: 160%;
+}
+H2 {
+ font-size: 120%;
+}
+H3 {
+ font-size: 100%;
+}
+
+h3.fn,span.fn
+{
+ background-color: #eee;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #ddd;
+ font-weight: bold;
+ padding: 6px 0px 6px 10px;
+ margin: 42px 0px 0px 0px;
+}
+
+hr {
+ border: 0;
+ color: #a0a0a0;
+ background-color: #ccc;
+ height: 1px;
+ width: 100%;
+ text-align: left;
+ margin: 34px 0px 34px 0px;
+}
+
+table.valuelist {
+ border-width: 1px 1px 1px 1px;
+ border-style: solid;
+ border-color: #dddddd;
+ border-collapse: collapse;
+ background-color: #f0f0f0;
+}
+
+table.indextable {
+ border-width: 1px 1px 1px 1px;
+ border-collapse: collapse;
+ background-color: #f0f0f0;
+ border-color:#555;
+ font-size: 110%;
+}
+
+table td.largeindex {
+ border-width: 1px 1px 1px 1px;
+ border-collapse: collapse;
+ background-color: #f0f0f0;
+ border-color:#555;
+ font-size: 120%;
+}
+
+table.valuelist th {
+ border-width: 1px 1px 1px 2px;
+ padding: 4px;
+ border-style: solid;
+ border-color: #666;
+ color:white;
+ background-color:#666;
+}
+
+th.titleheader {
+ border-width: 1px 0px 1px 0px;
+ padding: 4px;
+ border-style: solid;
+ border-color: #444;
+ color:white;
+ background-color:#555555;
+ font-size: 110%;
+}
+
+th.largeheader {
+ border-width: 1px 0px 1px 0px;
+ padding: 4px;
+ border-style: solid;
+ border-color: #444;
+ color:white;
+ background-color:#555555;
+ font-size: 120%;
+}
+
+p {
+
+ margin-left: 4px;
+ margin-top: 8px;
+ margin-bottom: 8px;
+}
+
+a:link
+{
+ color: #0046ad;
+ text-decoration: none
+}
+
+a:visited
+{
+ color: #672967;
+ text-decoration: none
+}
+
+a.obsolete
+{
+ color: #661100;
+ text-decoration: none
+}
+
+a.compat
+{
+ color: #661100;
+ text-decoration: none
+}
+
+a.obsolete:visited
+{
+ color: #995500;
+ text-decoration: none
+}
+
+a.compat:visited
+{
+ color: #995500;
+ text-decoration: none
+}
+
+body
+{
+ background: #ffffff;
+ color: black
+}
+
+table.generic, table.annotated
+{
+ border-width: 1px;
+ border-color:#bbb;
+ border-style:solid;
+ border-collapse:collapse;
+}
+
+table td.memItemLeft {
+ width: 180px;
+ padding: 2px 0px 0px 8px;
+ margin: 4px;
+ border-width: 1px;
+ border-color: #E0E0E0;
+ border-style: none;
+ font-size: 100%;
+ white-space: nowrap
+}
+
+table td.memItemRight {
+ padding: 2px 8px 0px 8px;
+ margin: 4px;
+ border-width: 1px;
+ border-color: #E0E0E0;
+ border-style: none;
+ font-size: 100%;
+}
+
+table tr.odd {
+ background: #f0f0f0;
+ color: black;
+}
+
+table tr.even {
+ background: #e4e4e4;
+ color: black;
+}
+
+table.annotated th {
+ padding: 3px;
+ text-align: left
+}
+
+table.annotated td {
+ padding: 3px;
+}
+
+table tr pre
+{
+ padding-top: 0px;
+ padding-bottom: 0px;
+ padding-left: 0px;
+ padding-right: 0px;
+ border: none;
+ background: none
+}
+
+tr.qt-style
+{
+ background: #96E066;
+ color: black
+}
+
+body pre
+{
+ padding: 0.2em;
+ border: #e7e7e7 1px solid;
+ background: #f1f1f1;
+ color: black
+}
+
+table tr.qt-code pre
+{
+ padding: 0.2em;
+ border: #e7e7e7 1px solid;
+ background: #f1f1f1;
+ color: black
+}
+
+span.preprocessor, span.preprocessor a
+{
+ color: darkblue;
+}
+
+span.comment
+{
+ color: darkred;
+ font-style: italic
+}
+
+span.string,span.char
+{
+ color: darkgreen;
+}
+
+.title
+{
+ text-align: center
+}
+
+.subtitle
+{
+ font-size: 0.8em
+}
+
+.small-subtitle
+{
+ font-size: 0.65em
+}
+
+.qmlitem {
+ padding: 0;
+}
+
+.qmlname {
+ white-space: nowrap;
+ font-weight: bold;
+ font-size: 125%;
+}
+
+.qmltype {
+ font-weight: bold;
+ font-size: 125%;
+}
+
+.qmlproto, .qmldoc {
+ // border-top: 1px solid #84b0c7;
+}
+
+.qmlproto {
+ padding: 0;
+ //background-color: #e4e4e4;//#d5e1e8;
+ //font-weight: bold;
+ //-webkit-border-top-left-radius: 8px;
+ //-webkit-border-top-right-radius: 8px;
+ //-moz-border-radius-topleft: 8px;
+ //-moz-border-radius-topright: 8px;
+}
+
+.qmldoc {
+ border-top: 1px solid #e4e4e4;
+ //padding: 2px 5px;
+ //background-color: #eef3f5;
+ //border-top-width: 0;
+ //-webkit-border-bottom-left-radius: 8px;
+ //-webkit-border-bottom-right-radius: 8px;
+ //-moz-border-radius-bottomleft: 8px;
+ //-moz-border-radius-bottomright: 8px;
+}
+
+.qmldoc p, .qmldoc dl, .qmldoc ul {
+ //margin: 6px 0;
+}
+
+*.qmlitem p {
+ //margin-top: 0px;
+ //margin-bottom: 0px;
+}
diff --git a/doc/doc.intermediate.manifest b/doc/doc.intermediate.manifest
new file mode 100644
index 000000000..27087c685
--- /dev/null
+++ b/doc/doc.intermediate.manifest
@@ -0,0 +1,15 @@
+<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
+<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level='asInvoker' uiAccess='false' />
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*' />
+ </dependentAssembly>
+ </dependency>
+</assembly>
diff --git a/doc/doc.pri b/doc/doc.pri
new file mode 100644
index 000000000..b37049592
--- /dev/null
+++ b/doc/doc.pri
@@ -0,0 +1,64 @@
+# Adapted from doc/doc.pri in Qt Creator.
+
+QDOC_BIN = $$[QT_INSTALL_BINS]/qdoc3
+win32:QDOC_BIN = $$replace(QDOC_BIN, "/", "\\")
+
+unix {
+ QDOC = SRCDIR=$$PWD OUTDIR=$$OUT_PWD/doc/html QT_MOBILITY_SOURCE_PATH=$$QT_MOBILITY_SOURCE_PATH $$QDOC_BIN
+ HELPGENERATOR = $$[QT_INSTALL_BINS]/qhelpgenerator
+} else {
+ QDOC = set SRCDIR=$$PWD&& set OUTDIR=$$OUT_PWD/doc/html&& set QT_MOBILITY_SOURCE_PATH=$$QT_MOBILITY_SOURCE_PATH&& $$QDOC_BIN
+ # Always run qhelpgenerator inside its own cmd; this is a workaround for
+ # an unusual bug which causes qhelpgenerator.exe to do nothing
+ HELPGENERATOR = cmd /C $$replace($$list($$[QT_INSTALL_BINS]/qhelpgenerator.exe), "/", "\\")
+}
+
+QHP_FILE = $$OUT_PWD/doc/html/installerfw.qhp
+QCH_FILE = $$OUT_PWD/doc/installerfw.qch
+
+HELP_DEP_FILES = $$PWD/installerfw.qdoc \
+ $$PWD/scripting.qdoc \
+ $$PWD/installerfw.qdocconf
+
+unix {
+html_docs.commands = $$QDOC $$PWD/installerfw.qdocconf
+} else {
+html_docs.commands = \"$$QDOC $$PWD/installerfw.qdocconf\"
+}
+html_docs.depends += $$HELP_DEP_FILES
+html_docs.files = $$QHP_FILE
+
+unix {
+html_docs_online.commands = $$QDOC $$PWD/installerfw.qdocconf
+} else {
+html_docs_online.commands = \"$$QDOC $$PWD/installerfw.qdocconf\"
+}
+html_docs_online.depends += $$HELP_DEP_FILES
+html_docs_online.files = $$QHP_FILE
+
+qch_docs.commands = $$HELPGENERATOR -o $$QCH_FILE $$QHP_FILE
+qch_docs.depends += html_docs
+qch_docs.files = $$QCH_FILE
+
+unix:!macx {
+ qch_docs.path = $$PREFIX/doc
+ qch_docs.CONFIG += no_check_exist
+ INSTALLS += qch_docs
+}
+
+docs_online.depends = html_docs_online
+QMAKE_EXTRA_TARGETS += html_docs_online docs_online
+
+macx {
+ DOC_DIR = "$${OUT_PWD}/bin/Simulator.app/Contents/Resources/doc"
+ cp_docs.commands = mkdir -p \"$${DOC_DIR}\" ; $${QMAKE_COPY} \"$${QCH_FILE}\" \"$${DOC_DIR}\"
+ cp_docs.depends += qch_docs
+ docs.depends = cp_docs
+ QMAKE_EXTRA_TARGETS += html_docs qch_docs cp_docs docs ht
+}
+!macx {
+ docs.depends = qch_docs
+ QMAKE_EXTRA_TARGETS += html_docs qch_docs docs
+}
+
+OTHER_FILES = $$HELP_DEP_FILES
diff --git a/doc/doc.pro b/doc/doc.pro
new file mode 100644
index 000000000..3f6993ba8
--- /dev/null
+++ b/doc/doc.pro
@@ -0,0 +1 @@
+include (doc.pri)
diff --git a/doc/fixnavi.pl b/doc/fixnavi.pl
new file mode 100644
index 000000000..bf6acaa38
--- /dev/null
+++ b/doc/fixnavi.pl
@@ -0,0 +1,70 @@
+#! /usr/bin/perl -w
+
+use strict;
+
+@ARGV == 1 or die "usage: $0 <qdoc-file>\n";
+my $file = $ARGV[0];
+open FILE, $file or die "File $file cannot be opened.\n";
+my @toc = ();
+my %title2page = ();
+my $doctitle = "";
+my $curpage = "";
+my $intoc = 0;
+while (<FILE>) {
+ if (keys(%title2page) == 1 && /^\h*\\list/) {
+ $intoc++;
+ } elsif (!$intoc) {
+ if (/^\h*\\page\h+(\H+)/) {
+ $curpage = $1;
+ } elsif (/^\h*\\title\h+(.+)$/) {
+ if ($curpage eq "") {
+ die "Title '$1' appears in no \\page.\n";
+ }
+ $title2page{$1} = $curpage;
+ $doctitle = $1 if (!$doctitle);
+ $curpage = "";
+ }
+ } else {
+ if (/^\h*\\endlist/) {
+ $intoc--;
+ } elsif (/^\h*\\o\h+\\l\h*{(.*)}$/) {
+ push @toc, $1;
+ }
+ }
+}
+close FILE;
+
+my %prev = ();
+my %next = ();
+my $last = $doctitle;
+for my $title (@toc) {
+ $next{$last} = $title2page{$title};
+ $prev{$title} = $title2page{$last};
+ $last = $title;
+}
+
+open IN, $file or die "File $file cannot be opened a second time?!\n";
+open OUT, '>'.$file.".out" or die "File $file.out cannot be created.\n";
+my $cutting = 0;
+while (<IN>) {
+ if (!$cutting) {
+ if (/^\h*\\contentspage/) {
+ $cutting = 1;
+ }
+ } else {
+ if (/^\h*\\title\h+(.+)$/) {
+ print OUT " \\previouspage ".$prev{$1} if ($prev{$1});
+ print OUT " \\page ".$title2page{$1};
+ print OUT " \\nextpage ".$next{$1} if ($next{$1});
+ print OUT "\n";
+ $cutting = 0;
+ } else {
+ next;
+ }
+ }
+ print OUT $_;
+}
+close OUT;
+close IN;
+
+rename($file.".out", $file) or die "Cannot replace $file with new version.\n";
diff --git a/doc/images/qt-logo.png b/doc/images/qt-logo.png
new file mode 100644
index 000000000..3e2e480b3
--- /dev/null
+++ b/doc/images/qt-logo.png
Binary files differ
diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc
new file mode 100644
index 000000000..f60978b58
--- /dev/null
+++ b/doc/installerfw.qdoc
@@ -0,0 +1,652 @@
+// **********************************************************************
+// NOTE: the sections are not ordered by their logical order to avoid
+// reshuffling the file each time the index order changes (i.e., often).
+// Run the fixnavi.pl script to adjust the links to the index order.
+// **********************************************************************
+
+/*!
+ \contentspage{index.html}{InstallerFramework}
+ \page index.html
+ \nextpage ifw-globalconfig.html
+
+ \title Qt Installer Framework Manual
+
+ \section1 Version 1.0.1
+
+ The Qt Installer Framework provides a set of tools and utilities to
+ create installers for all supported desktop Qt platforms.
+
+ Tested platforms currently include:
+ \list
+ \o Microsoft Windows (Windows XP and following)
+ \o Linux (Ubuntu 7.04 and following)
+ \o Mac OS-X (10.6 and following)
+ \endlist
+
+ Those installers can either be stand-alone or download contant from a
+ networking resource via http transfer. For installers fetching data from
+ a webserver, tools are available to post install items after the initial
+ setup as well as update mechanisms are provided as soon as those are
+ published on the server.
+
+
+ \note Currently there is no bug report system setup for the Qt Installer
+ Framework itself as it is not productized. Please report bugs and
+ suggestions to the developers personally via email.
+
+ \list
+ \o Structure of a installer creation setup
+ \list
+ \o \l{Global Configuration}
+ \o \l{Component Description}
+ \o \l{Included Tools}
+ \endlist
+ \o \l{Tutorial}
+ \o Enhanced instructions
+ \list
+ \o \l{Creating online installers}
+ \o \l{Pure offline installers}
+ \o \l{Creating updates}
+ \o \l{Non Interactive Installation}
+ \endlist
+ \o \l{Known Issues}
+ \endlist
+*/
+
+/*!
+ \contentspage index.html
+ \previouspage index.html
+ \page ifw-globalconfig.html
+ \nextpage ifw-component-description.html
+
+ \title Global Configuration
+
+ For creation of installer binaries and online repositories, you need to
+ provide a config directory. This directory needs to contain at least a file
+ named \bold{config.xml} containing XML information about how to build the
+ installer.
+
+ This file can look like this:
+
+ \code
+<?xml version="1.0"?>
+<Installer>
+ <Name>Some Application</Name>
+ <Version>1.0.0</Version>
+ <Title>Some Application Setup</Title>
+ <Publisher>Your Company</Publisher>
+ <ProductUrl>http://www.your-fantastic-company.com</ProductUrl>
+ <Logo>logo.png</Logo>
+ <License>license.txt</License>
+ <Watermark>watermark.png</Watermark>
+ <RunProgram></RunProgram>
+ <RunProgramDescription></RunProgramDescription>
+ <StartMenuDir>Some Application Entry Dir</StartMenuDir>
+
+ <PublicKey>
+ -----BEGIN PUBLIC KEY-----
+ ... key values ...
+ -----END PUBLIC KEY-----
+ </PublicKey>
+
+ <PrivateKey>
+ -----BEGIN RSA PRIVATE KEY-----
+ Proc-Type: 4,ENCRYPTED
+ DEK-Info: DES-EDE3-CBC,C9D3A294C3702C32
+ ... key values ...
+ -----END RSA PRIVATE KEY-----
+ </PrivateKey>
+
+ <Icon>installericon</Icon>
+
+ <!-- @homeDir@ and @rootDir@ are some of the supported vars -->
+ <TargetDir>@homeDir@/testinstall</TargetDir>
+ <RemoteRepositories>
+ <Repository>
+ <Url>http://www.your-repo-location/packages/</Url>
+ <Required>false</Required>
+ </Repository>
+ </RemoteRepositories>
+</Installer>
+ \endcode
+
+ The following settings are contained in this file.
+
+ \list
+ \o \bold{ Name} The name of the product being installed
+ \o \bold{ Version} The version of the product being installed
+ \o \bold{ Title} The title text of the generated installer, i.e. its name
+ \o \bold{ MaintenanceTitle} The title text of the generated maintenance tool, i.e. its name
+ \o \bold{ Pushblisher} The publisher of the software
+ \o \bold{ ProductUrl} URL of the product
+ \o \bold{ Logo} Filename for a logo used as QWizard::LogoPixmap
+ \o \bold{ License} Filename of the license text to be accepted by the installing user
+ \o \bold{ Watermark} Filename for a watermark used as QWizard::WatermarkPixmap
+ \o \bold{ Background} Filename for an image used as QWizard::BackgroundPixmap
+ \o \bold{ RunProgram} Command executed after the installer is done, if the user accepts it
+ \o \bold{ RunProgramDescription} Text shown next to the checkbox for running the program. Defaults to "Run <Name>"
+ \o \bold{ StartMenuDir} Name of the predefined group in the Windows Start Menu
+ \o \bold{ Icon} Filename of the installer icon. On Windows, .ico is appended, on Mac, .icns is appended and on Linux, .png is appended.
+ \o \bold{ PublicKey} RSA public key to be used to verify component signatures
+ \o \bold{ PrivateKey} RSA private key to be used to sign components
+ \o \bold{ TargetDir} Predefined target directory for installation
+ \o \bold{ RemoteRepositories} List of remote repositories
+ \o \bold{ UninstallerName} File name of the generated uninstaller. Defaults to "uninstall". The platform specific executable suffixs is appended.
+ \endlist
+
+ It is suggested that you place all files that are reffered inside the
+ configuration also into the config directory. However, you can also use
+ relative paths, which the tools will resolve relative to the location of
+ the config.xml file.
+
+ \bold{Remote Repositories}
+
+ The installer configuration file can contain a list of several remote
+ repositories. Each of them has two properties. The first one is the
+ repository URL. In the example above, this is
+ "http://www.your-repo-location/packages/" The URL needs to contain a file
+ Updates.xml listing the available packages. See \l{Creating online installers}{Online Repository generation}
+ to read more about online repositories. The second parameter is called
+ "Required". If you set this to true, the installer won't work if this
+ repository is not available. In case the repository is accessed after an
+ installation, this will cause the maintenance tool to reject installation.
+ However, uninstallation is still possible. If you set it to false, the
+ installer will continue to work, but exclude any configuration which should
+ be on the server.
+*/
+
+/*!
+ \contentspage index.html
+ \previouspage ifw-globalconfig.html
+ \page ifw-component-description.html
+ \nextpage ifw-tools.html
+
+ \title Component Description
+
+ \section1 Documentation on how to create installer components.
+
+ The Installer is based on the idea of having several components, which are
+ either embedded in the installer itself or loaded from a remote repository.
+ For both, embedding components into the installer and creating an online
+ repository, you need to keep your components in a certain format readable
+ by the installer.
+
+ \section1 Directory Structure
+
+ All components need to be located inside the same root directory, which is
+ called \bold{package directory}. Components
+ are identified by a domain-like identifier. This has to be the name of the
+ directory the component data has to be placed in. Within this directory,
+ two subdirectories have to exist, called \bold{data} and \bold{meta}.
+
+ A package directory can look like this:
+ \code
+ -packages
+ - com.vendor.root
+ - data
+ - meta
+ - com.vendor.root.component1
+ - data
+ - meta
+ - com.vendor.root.component1.subcomponent1
+ - data
+ - meta
+ - com.vendor.root.component2
+ - data
+ - meta
+ \endcode
+
+
+ \section1 Contents of the meta data directory
+
+ The meta data directory contains all files which are not to be extracted by
+ the installer but contain information about deployment and the installation
+ process.
+
+ \section2 package.xml
+
+ The file package.xml is the main source of information about the component.
+ The format of this file is XML and has for instance the following shape:
+
+ \code
+ <?xml version="1.0"?>
+ <Package>
+ <Name>QtGui</Name>
+ <Description>Qt gui libraries</Description>
+ <Version>1.2.3</Version>
+ <ReleaseDate>2009-04-23</ReleaseDate>
+ <Identifier>com.vendor.root.component2</Identifier>
+ <Dependencies>com.vendor.root.component1</Dependencies>
+ <Virtual>false</Virtual>
+ <Script>installscript.qs</Script>
+ <UserInterfaces>
+ <UserInteface>specialpage.ui</UserInterface>
+ <UserInteface>errorpage.ui</UserInterface>
+ </UserInterfaces>
+ <Translations>
+ <Translation>sv_se.qm</Translation>
+ <Translation>de_de.qm</Translation>
+ </Translations>
+ </Package>
+ \endcode
+
+ \section3 package value list
+
+ \list
+ \o \bold{VisibleName} The human readable name of the component - required.
+ \o \bold{Description} The human readable description of the component - required.
+ \o \bold{Version} The version number of the component - required.
+ \o \bold{ReleaseDate} The day this component version was released - optional.
+ \o \bold{Name} domain-like identification for this component - required.
+ \o \bold{Dependencies} Comma-separated list of dependencies - optional.
+ \o \bold{Virtual} Set to true if this is a virtual component not showing up in the installer.
+ \o \bold{SortingPriority} Priority of this component when visible in the tree. Lowest priority number is on top.
+ \o \bold{InstallPriority} Priority of this component when getting installed. Lowest priority number is first.
+ \o \bold{Script} File name of a script being loaded - optional.
+ \o \bold{UserInterfaces} One ore more file names of user interfaces being loaded - optional.
+ \o \bold{Translations} One ore more file names of translations being loaded - optional.
+ \o \bold{UpdateText} A description added to the component description if the component is an update - optional.
+ \o \bold{NewComponent} If this flag is set the component appears as an update if its not installed - optional.
+ \o \bold{Important} The package is marked as important. This is relevant for updates found with UpdateAgent.
+ \o \bold{ForcedInstallation} This packages must always be installed and can't get unchecked by the user.
+ \o \bold{AutoSelectOn} Define boolean expressions with other components names to define when this components gets autoselected.
+ \endlist
+
+ \section2 Additional features
+
+ Additonally, all files named in the package.xml - scripts, user interfaces
+ and translations - have to be in the meta data directory. Referring to
+ previous example, the directory structure looks like this:
+
+ \code
+ -packages
+ - com.vendor.root.component2
+ - data
+ - meta
+ - de_de.qm
+ - errorpage.ui
+ - installscript.qs
+ - package.xml
+ - specialpage.ui
+ - sv_se.qm
+ \endcode
+
+ \section3 Scripting
+
+ Each component can utilize ECMA scripting to perform additional operations
+ at any time of the installation process. Typical use cases are file
+ manipulations like moving, copying, patching.
+
+ For all full documentation on scripting, see \l{Component Scripting}{here}.
+
+ \section3 Component Dependencies
+
+ Each component can have one or more components it depends on. This can be
+ other real or virtual components. Every dependency as defined via its
+ identifier and optionally its version. The version, if given, is separated
+ by the identifier by a dash ('-') and can be prefixed by a comparision
+ operator like '=', '>', '<', '>=' or '<=', which means that the version of
+ the matching package is compared to the required version and has to be
+ equal, greater, less, greater or equal or less or equal as the version
+ number given in the dependency. If no comparision operator is given, it
+ defaults to '='.
+
+ \section3 Component Translation
+
+ As the installer makes use of the Qt Translation system, all user readable
+ output can be translated to other languages. To make this work for strings
+ contained in component scripts and user interfaces, components can provide
+ QTranslator files, which get loaded by the installation system when loading
+ the component. The Installer always loads the translation file with a name
+ matching the current system locale. For the system locale being German
+ (Germany), this would be de_de.qm.
+
+ Inside of scripts, you have to use the function qsTr() for literal text.
+ Additionally your script can contain a method Component.prototype.retranslateUi
+ which is called whenever the language of the Installer has changed, i.e.
+ after your translation file was loaded.
+
+ The context being used for translation is the basename of the script file
+ when using qsTr or the class name of the UI file when translating an user
+ interface.
+
+ \section3 Component User Interfaces
+
+ A component can contain one or more user interface files, which are placed
+ into the installer by the script. The installer is automatically loading
+ all ui files listed in the package.xml. You can access the loaded widgets
+ by calling QInstaller::Component::userInterface with the class name of the
+ widget:
+
+ \code
+ component.userInterface( "MyPage" ).checkbox.checked = true;
+ \endcode
+
+ There are two ways of inserting custom user interface widgets into the
+ installer: Inserting them as a single widget or inserting them as their own
+ page.
+
+ To insert them as a single widget, use QInstaller::Installer::addWizardPageItem.
+ From within the script, this is done by:
+
+ \code
+ // add the instance of MyWidget to the component selection page
+ installer.addWizardPageItem( component, "MyWidget", QInstaller.ComponentSelection );
+ \endcode
+
+ To add a completely new page into the Installer, you need to specify in
+ front of which page you want to add it. Adding the page is done with
+ QInstaller::Installer::addWizardPage.
+
+ \code
+ // add the instance of MyPage in front of the "Ready to Installation" page
+ installer.addWizardPage( component, "MyPage", QInstaller.ReadyForInstallation );
+ \endcode
+
+ \section2 Contents of the data directory
+
+ The data directory contains all the content, which will be extracted during
+ the installation phasis. There are multiple options of content:
+
+ \list
+ \o Copy all the files into the data location. The directory structure will
+ be identical between the on in the data location and the installation
+ directory. Before the installer is created, the included tools will create
+ a 7zip archive.
+ \o Create a .7z archive via archivegen, which is included in the Installer
+ Framework.
+ \o Place a 7zip compatible archive into the data directory.
+ \endlist
+
+ \note Each of those ways has advantages and disadvantages. From our experience,
+ using archivegen provides the best solution due to faster creation time
+ and compatilibility with 7zip.
+*/
+
+/*!
+ \contentspage index.html
+ \previouspage ifw-component-description.html
+ \page ifw-tools.html
+ \nextpage ifw-tutorial.html
+
+ \title Included Tools
+
+ \section1 installerbase
+ \bold installerbase describes the core installer itself. All data and meta
+ information will be packed to this binary. For the installer creation
+ process you will not need to call it directly.
+
+ \section1 binarycreator
+ Installers are created using binarycreator. This applies to online as well
+ as offline installers.
+
+ In the offline case the component information and their data is appended to
+ the binary, allowing extraction and post installation scripts to work
+ without any internet connection.
+
+ Online installers store the location of the repository and on startup load
+ the component information, not the data. Hence binarycreator does only a
+ partial job in the online case.
+
+ You can also create hybrid installers, which store some component locally
+ and receive others via a network connection. For more information, continue
+ reading at ###TODO insert link here.
+
+ For technical inside on the implementation of data integration into the
+ installer binary, read the information on QInstaller::BinaryContent ###TODO insert link here.
+ Please note that changing this configuration requires a recompilation of
+ installerbase.
+
+ \section2 Usage
+
+ binarycreator expects the following parameters:
+ \code
+ -t or --template file Use file as input file
+ This is the binary used to append component information.
+ On Windows, this defaults to be installerbase.exe in the current working directory. On Unix, installerbase is used.
+
+ -p or --packages directory Use directory as packaces directory
+ Specifies the directory to get package, i.e. component information from. See Component Definition to find out how this directory need to look like. This setting defaults to the current working directory.
+
+ -n or --nodeps Add only the selected packages to the compile. Don't add their dependencies.
+
+ -c or --config directory Use directory as config directory
+ Specifies the directory to be used for Installer Configuration.
+
+ -e or --exclude p1,...,pn Mark a comma separated list of packages to be retrieved from an online repository, i.e. not to be completely included in the installer binary.
+
+ -v or --verbose Verbose output. Add this if you are into lots of debug output.
+ \endcode
+
+ These parameters are followed by the name of the target binary and a list
+ of packages to be availabe for installation. Note that not only these
+ packages will be inside of the installer, but even all their dependencies
+ and all packages sharing the same prefix, as long as you add the --nodeps
+ flag.
+
+ On Windows, the name of the target binary is automatically extended with
+ .exe, if it wasn't already added by the user. On Mac, the target will be
+ created as application bundle with extension .app, which as automatically
+ added, if not supplied. Additionally, the user can use a .dmg extension,
+ which will create a DMG disk image containing an .app bundle.
+
+ \section2 Example
+ \section3 Offline installer
+ \code
+ binarycreator.exe -c installer-config SDKInstaller.exe com.nokia.sdk
+ \endcode
+ This commands puts com.nokia.sdk as well as all packages com.nokia.sdk
+ depends on into the installer binary SDKInstaller.exe. Additionally, this
+ binary will contain all packages prefixed with com.nokia.sdk.*
+
+ \section3 Online installer
+ \code
+ binarycreator.exe -c installer-config -e com.nokia.sdk.qt,com.nokia.qtcreator SDKInstaller.exe com.nokia.sdk
+ \endcode
+
+ The same as above, except that the data for com.nokia.sdk.qt and
+ com.nokia.qtcreator will be downloaded from a remote repository.
+
+ If your config.xml contains a RSA private key, components and data will be
+ signed with it. On installer runtime, this signature will be used to verify
+ the components. Note that the private key is not embedded in the installer
+ binary. If your private key is protected with a password, you will be asked
+ to provide the password.
+
+ \section2 Platform specific notes
+ \section3 Mac OS X
+
+ If the target binary is suffixed with .app, a shiny Mac OS X application bundle will be created
+ The icon set in the config.xml is extended with ".icns" and used as icon for a created bundle
+
+ \section3 Windows
+
+ The icon set in the config.xml is extended with ".ico" and used as application icon for the .exe file.
+
+ \section3 Linux
+
+ The icon set in the config.xml is extended with ".png" and used as window icon.
+
+ \section1 repogen
+
+ To generate online repositories, use the tool repogen.
+ \section2 Usage
+
+ repogen expects the following parameters in this order:
+ \list
+ \o \bold Packages directory Directory containing the packages. Same as for binarycreator.
+ \o \bold Configuration directory Directory containing the installer configuration. Same as for binarycreator.
+ \o \bold Repository directory Target directory to generate the repository. Must not yeut exist.
+ \o \bold Components List of components to be placed into the repository. Includes dependencies.
+ \endlist
+
+ If your config.xml contains a RSA private key, components and data will be
+ signed with it. On installer runtime, this signature will be used to verify
+ the components. Note that the private key is not put into the repository.
+ If your private key is protected with a password, you will be asked to
+ provide the password.
+
+ When the repository has been created, you can upload it to anywhere. Just
+ put the location into the installer configuration when creating an installer
+ for it.
+
+ \section3 Example
+ \code
+ repogen.exe packages installer-config repository com.nokia.sdk.qt com.nokia.sdk.qtcreator
+ \endcode
+
+ This command creates a repository inside of repository containing
+ com.nokia.sdk.qt and com.nokia.sdk.qtcreator, including all dependencies.
+*/
+
+/*!
+ \contentspage index.html
+ \previouspage ifw-tutorial.html
+ \page ifw-online-installers.html
+ \nextpage ifw-offline-installers.html
+
+ \title Creating online installers
+
+ \section1 Configuration changes
+ Online installers fetch the repository description in addition to the one
+ stored inside of the binary. The technical effort is very little. Inside
+ the global \a{config.xml} file, you need to add the location of your
+ repository like this:
+ \code
+ <RemoteRepositories>
+ <Repository>
+ <Url>http://www.yourcompany.com/repository</Url>
+ <Required>false</Required>
+ </Repository>
+ </RemoteRepositories>
+ \endcode
+
+ The \a Required tag describes, if the installer should go forward even
+ without accessing the server.
+
+ \section2 Creating the binaries
+ You will not need to change any of the arguments to create installer
+ binaries. The process of creating installer binaries is documented
+ \l{binarycreator}{here}.
+
+ \section2 Reducing the size of online installers
+ Even if a remote location is specified, this does not exclude the
+ components to be added to the installer binary itself. This results
+ in a bigger installer binary, which checks for the online repository.
+ This has the advantage, that if no newer version is available on the
+ server, the user will spare the additional download.
+
+ However, this is sometimes not the desired scenario. Instead the online
+ installer should not contain any data and fetch all its data from the
+ network connection.
+
+ To achieve this, use the \a{-n} parameter of binary creator and only add
+ the root component to the installer. Usually the root component is empty
+ and hence only adds the xml description of the root. For more information
+ and a list of available options, please refer to \l{binarycreator}{here}.
+*/
+
+/*!
+ \contentspage index.html
+ \previouspage ifw-online-installers.html
+ \page ifw-offline-installers.html
+ \nextpage ifw-updates.html
+
+ \title Pure offline installers
+
+ Pure offline installers describe the scenario in which the installer
+ does not try to connect to an online repository at all during the install
+ step. However, post installation as well as receiving updates will use
+ the description stored in the meta configuration (\a{config.xml}).
+
+ This is especially useful in cases where a corporate firewall does not
+ allow to connect to servers, but a successful installation is demanded.
+
+ To create such installers, \l{binarycreator} has the \a{--offline-only}
+ option which will output a installation binary with above settings.
+*/
+
+/*!
+ \contentspage index.html
+ \previouspage ifw-offline-installers.html
+ \page ifw-updates.html
+ \nextpage ifw-knownissues.html
+
+ \title Creating updates
+
+ Creating online installers has the advantage that updates can be promoted
+ to the users who have the product installed. This section describes the
+ steps to promote an update.
+
+ \section1 Configuration changes
+
+ The maintenance/updater tool downloads the update description on startup
+ and then compares the installed version with the promoted one on the server.
+ If the online version number is greater than the local one, the component
+ is displayed in the list of available updates.
+
+ To achieve this, the \a{Version} tag of the components needs to be increased.
+
+ \section1 Recreating the repository
+ The easiest solution to provide an update is to recreate the online
+ repository and then upload it to the server location. This can be achieved
+ by reusing \l{repogen}.
+
+ \section1 Partial updates
+ \section2 Scenario description
+ Sometimes a full update of the whole repository might not be welcomed. The
+ reasons might be
+ \list
+ \o The size of the repository is very big, so that uploading takes a
+ significant amount of time
+ \o Updates need to be provided to a separate entity, where only changed
+ elements should be delivered to.
+ \endlist
+
+ \note repogen recreates the 7zip archives each time it is being called. As
+ 7zip stores the timestamp of included files (which get moved/copied during
+ this process), the sha sum of each archive changes. SHA sums are used to
+ verify the download of the archive and hence the SHA needs to match to the
+ 7zip. As the SHAs are stored inside the global \a{Updates.xml} you will be
+ forced to upload the full repository. This can be circumvented by using the
+ \a{--single} option of repogen.
+
+ \section2 Implementation
+ When recreating the online repository, use the \a{--single} parameter. This
+ takes an existing repository as input and only changes the components,
+ which are specified as additional parameters. Only those SHA sums will be
+ changed in the global configuration as well.
+
+ \section3 Uploading partial updates
+ Assuming the repository has been updated like in above description, you will
+ not have to upload the whole repository again. Instead only the following
+ items are required:
+ \list
+ \o The component directory (usually something alike
+ \a{com.vendor.foo.updatedpart}.
+ \o The global \a{Updates.xml} stored in the root directory of the online
+ repository.
+ \endlist
+
+ \note The order of uploading is very important. In case you update the
+ repository on a live server, you should first update the component and
+ only afterwards the xml configuration. As the archive names include the
+ versioning the user will be provided with the old package until the update
+ has finished.
+
+*/
+
+/*!
+ \contentspage index.html
+ \previouspage ifw-updates.html
+ \page ifw-knownissues.html
+ \nextpage index.html
+
+ \title Known Issues
+
+ Of course none yet, but as long as there is no bugtracker, add those here...
+
+ Some of the items can be seen on the Nokia Qt SDK bugtracking system
+ \l{http://bugreports.qt.nokia.com/browse/QTSDK}{here}.
+*/
+
diff --git a/doc/installerfw.qdocconf b/doc/installerfw.qdocconf
new file mode 100644
index 000000000..fb56c561a
--- /dev/null
+++ b/doc/installerfw.qdocconf
@@ -0,0 +1,231 @@
+# Run qdoc from the directory that contains this file.
+include(qt-html-templates.qdocconf)
+
+project = installerfw
+description = "Qt Installer Framework Manual"
+
+headers =
+# $$SIMULATOR_DEPENDENCY_PATH/include/remotecontrolwidget/locationui.h
+sources =
+# $$SRCDIR/../src/ui/sensorsui.cpp \
+
+headerdirs =
+sourcedirs = $SRCDIR
+imagedirs = $SRCDIR/images $SRCDIR/templates/images
+outputdir = $OUTDIR
+exampledirs = $SRCDIR
+indexes = qt.index
+
+include(qt-defines.qdocconf)
+
+sources.fileextensions = "installerfw.qdoc scripting.qdoc tutorial.qdoc noninteractive.qdoc"
+
+
+qhp.projects = InstallerFramework
+qhp.InstallerFramework.file = installerfw.qhp
+qhp.InstallerFramework.namespace = com.nokia.qt.installerfw.101
+qhp.InstallerFramework.virtualFolder = doc
+qhp.InstallerFramework.indexTitle = Qt Installer Framework Manual
+qhp.InstallerFramework.indexRoot =
+qhp.InstallerFramework.filterAttributes = installerfw
+qhp.InstallerFramework.customFilters.InstallerFramework.name = Qt Installer Framework 1.0.0
+qhp.InstallerFramework.customFilters.InstallerFramework.filterAttributes = installerfw
+
+qhp.InstallerFramework.subprojects = scripting manual
+qhp.InstallerFramework.subprojects.scripting.title = Scripting
+qhp.InstallerFramework.subprojects.scripting.indexTitle = Installer Framework Scripting
+qhp.InstallerFramework.subprojects.scripting.selectors = class
+qhp.InstallerFramework.subprojects.scripting.sortPages = true
+
+
+qhp.InstallerFramework.subprojects.manual.title = Qt Installer Framework Manual
+qhp.InstallerFramework.subprojects.manual.indexTitle = Qt Installer Framework Manual
+qhp.InstallerFramework.subprojects.manual.type = manual
+
+qhp.InstallerFramework.extraFiles = \
+ style/OfflineStyle.css \
+ style/style.css \
+ style/style_ie6.css \
+ style/style_ie7.css \
+ style/style_ie8.css \
+ images/qt-logo.png \
+ scripts/functions.js \
+ scripts/jquery.js \
+ images/qt-logo \
+ images/trolltech-logo \
+ images/api_examples.png \
+ images/api_lookup.png \
+ images/arrow_down.png \
+ images/bg_ll.png \
+ images/bg_l.png \
+ images/bg_lr.png \
+ images/bg_r.png \
+ images/bg_ul_blank.png \
+ images/bg_ll_blank.png \
+ images/bg_l_blank.png \
+ images/breadcrumb.png \
+ images/bullet_dn.png \
+ images/bullet_gt.png \
+ images/bullet_sq.png \
+ images/box_bg.png \
+ images/feedbackground.png \
+ images/horBar.png \
+ images/page_bg.png \
+ images/page.png \
+ images/sprites-combined.png \
+ images/bullet_up.png
+# macros.qdocconf
+
+macro.aring.HTML = "&aring;"
+macro.Auml.HTML = "&Auml;"
+macro.author = "\\bold{Author:}"
+macro.br.HTML = "<br />"
+macro.BR.HTML = "<br />"
+macro.aacute.HTML = "&aacute;"
+macro.eacute.HTML = "&eacute;"
+macro.iacute.HTML = "&iacute;"
+macro.gui = "\\bold"
+macro.hr.HTML = "<hr />"
+macro.key = "\\bold"
+macro.menu = "\\bold"
+macro.note = "\\bold{Note:}"
+macro.oslash.HTML = "&oslash;"
+macro.ouml.HTML = "&ouml;"
+macro.QA = "\\e{Qt Assistant}"
+macro.QD = "\\e{Qt Designer}"
+macro.QL = "\\e{Qt Linguist}"
+macro.param = "\\e"
+macro.raisedaster.HTML = "<sup>*</sup>"
+macro.reg.HTML = "<sup>&reg;</sup>"
+macro.return = "Returns"
+macro.starslash = "\\c{*/}"
+macro.uuml.HTML = "&uuml;"
+macro.mdash.HTML = "&mdash;"
+
+# compat.qdocconf
+
+alias.i = e
+alias.include = input
+
+macro.0 = "\\\\0"
+macro.b = "\\\\b"
+macro.n = "\\\\n"
+macro.r = "\\\\r"
+macro.i = "\\o"
+macro.i11 = "\\o{1,1}"
+macro.i12 = "\\o{1,2}"
+macro.i13 = "\\o{1,3}"
+macro.i14 = "\\o{1,4}"
+macro.i15 = "\\o{1,5}"
+macro.i16 = "\\o{1,6}"
+macro.i17 = "\\o{1,7}"
+macro.i18 = "\\o{1,8}"
+macro.i19 = "\\o{1,9}"
+macro.i21 = "\\o{2,1}"
+macro.i31 = "\\o{3,1}"
+macro.i41 = "\\o{4,1}"
+macro.i51 = "\\o{5,1}"
+macro.i61 = "\\o{6,1}"
+macro.i71 = "\\o{7,1}"
+macro.i81 = "\\o{8,1}"
+macro.i91 = "\\o{9,1}"
+macro.img = "\\image"
+macro.endquote = "\\endquotation"
+spurious = "Missing comma in .*" \
+ "Missing pattern .*"
+
+# Doxygen compatibility commands
+
+macro.see = "\\sa"
+macro.function = "\\fn"
+
+# qt-cpp-ignore.qdocconf
+
+Cpp.ignoretokens = QAXFACTORY_EXPORT \
+ QDESIGNER_COMPONENTS_LIBRARY \
+ QDESIGNER_EXTENSION_LIBRARY \
+ QDESIGNER_SDK_LIBRARY \
+ QDESIGNER_SHARED_LIBRARY \
+ QDESIGNER_UILIB_LIBRARY \
+ QM_EXPORT_CANVAS \
+ QM_EXPORT_DNS \
+ QM_EXPORT_DOM \
+ QM_EXPORT_FTP \
+ QM_EXPORT_HTTP \
+ QM_EXPORT_ICONVIEW \
+ QM_EXPORT_NETWORK \
+ QM_EXPORT_OPENGL \
+ QM_EXPORT_SQL \
+ QM_EXPORT_TABLE \
+ QM_EXPORT_WORKSPACE \
+ QM_EXPORT_XML \
+ QT_ASCII_CAST_WARN \
+ QT_ASCII_CAST_WARN_CONSTRUCTOR \
+ QT_BEGIN_HEADER \
+ QT_DESIGNER_STATIC \
+ QT_END_HEADER \
+ QT_FASTCALL \
+ QT_WIDGET_PLUGIN_EXPORT \
+ Q_COMPAT_EXPORT \
+ Q_CORE_EXPORT \
+ Q_EXPLICIT \
+ Q_EXPORT \
+ Q_EXPORT_CODECS_CN \
+ Q_EXPORT_CODECS_JP \
+ Q_EXPORT_CODECS_KR \
+ Q_EXPORT_PLUGIN \
+ Q_GFX_INLINE \
+ Q_GUI_EXPORT \
+ Q_GUI_EXPORT_INLINE \
+ Q_GUI_EXPORT_STYLE_CDE \
+ Q_GUI_EXPORT_STYLE_COMPACT \
+ Q_GUI_EXPORT_STYLE_MAC \
+ Q_GUI_EXPORT_STYLE_MOTIF \
+ Q_GUI_EXPORT_STYLE_MOTIFPLUS \
+ Q_GUI_EXPORT_STYLE_PLATINUM \
+ Q_GUI_EXPORT_STYLE_POCKETPC \
+ Q_GUI_EXPORT_STYLE_SGI \
+ Q_GUI_EXPORT_STYLE_WINDOWS \
+ Q_GUI_EXPORT_STYLE_WINDOWSXP \
+ QHELP_EXPORT \
+ Q_INLINE_TEMPLATE \
+ Q_INTERNAL_WIN_NO_THROW \
+ Q_NETWORK_EXPORT \
+ Q_OPENGL_EXPORT \
+ Q_OUTOFLINE_TEMPLATE \
+ Q_SQL_EXPORT \
+ Q_SVG_EXPORT \
+ Q_SCRIPT_EXPORT \
+ Q_TESTLIB_EXPORT \
+ Q_TYPENAME \
+ Q_XML_EXPORT \
+ Q_XMLSTREAM_EXPORT \
+ Q_XMLPATTERNS_EXPORT \
+ QDBUS_EXPORT \
+ QT_BEGIN_NAMESPACE \
+ QT_BEGIN_INCLUDE_NAMESPACE \
+ QT_END_NAMESPACE \
+ QT_END_INCLUDE_NAMESPACE \
+ PHONON_EXPORT \
+ EXTENSIONSYSTEM_EXPORT \
+ Q_INVOKABLE
+Cpp.ignoredirectives = Q_DECLARE_HANDLE \
+ Q_DECLARE_INTERFACE \
+ Q_DECLARE_METATYPE \
+ Q_DECLARE_OPERATORS_FOR_FLAGS \
+ Q_DECLARE_PRIVATE \
+ Q_DECLARE_PUBLIC \
+ Q_DECLARE_SHARED \
+ Q_DECLARE_TR_FUNCTIONS \
+ Q_DECLARE_TYPEINFO \
+ Q_DISABLE_COPY \
+ QT_FORWARD_DECLARE_CLASS \
+ Q_DUMMY_COMPARISON_OPERATOR \
+ Q_ENUMS \
+ Q_FLAGS \
+ Q_INTERFACES \
+ __attribute__ \
+ K_DECLARE_PRIVATE \
+ PHONON_OBJECT \
+ PHONON_HEIR
+
diff --git a/doc/noninteractive.qdoc b/doc/noninteractive.qdoc
new file mode 100644
index 000000000..1a6be992a
--- /dev/null
+++ b/doc/noninteractive.qdoc
@@ -0,0 +1,127 @@
+/*!
+ \contentspage{index.html}{InstallerFramework}
+ \page noninteractive.html
+
+ \title Non Interactive Installation
+
+ \section1 Installer Page Callbacks
+
+ \section2 builtinpages Built-in pages
+
+ \section3 IntroductionPageCallback
+ Wizard buttons:
+ \list
+ \o Next
+ \o Cancel
+ \endlist
+
+ \section3 LicenseAgreementPageCallback
+ Wizard buttons:
+ \list
+ \o Next
+ \o Cancel
+ \o Back
+ \endlist
+
+ Radio buttons:
+ \list
+ \o acceptLicenseRB (radio button): Accepts the license Agreement (unchecked by default)
+ \o rejectLicenseRB (radio button): Rejects the license Agreement (checked by default)
+ \endlist
+
+ \section3 TargetDirectoryPageCallback
+ Wizard buttons:
+ \list
+ \o Next
+ \o Cancel
+ \o Back
+ \endlist
+
+ targetDirectoryLE (line edit): The target directory for installation
+
+ \section3 ComponentSelectionPageCallback
+ Wizard buttons:
+ \list
+ \o Next
+ \o Cancel
+ \o Back
+ \endlist
+
+ Methods:
+ \list
+ \o selectComponent( id ): selects the component with the ID id (string)
+ \o deselectComponent( id ): deselects the component with the ID id (string)
+ \endlist
+
+ In uninstallation mode, additional controls are available:
+ \list
+ \o uninstallAllComponentsRB (radio button): Uninstall all components (default)
+ \o keepSelectedComponentsRB (radio button): Uninstall only unselected components (deselectComponent/selectComponent to modify them)
+ \endlist
+
+ \section3 ReadyForInstallationPageCallback
+ Wizard buttons:
+ \list
+ \o Next ("Install")
+ \o Cancel
+ \o Back
+ \endlist
+
+ \section3 PerformInstallationPage
+
+ details.button (push button): Shows/hides installation details
+
+ Wizard buttons:
+ \list
+ \o Cancel
+ \endlist
+
+ \section3 FinishedPageCallback
+
+ Wizard buttons:
+ \list
+ \o Finish
+ \endlist
+
+ \section2 Custom Pages
+
+ Custom pages are registered as \a{Dynamic${ObjectName}}, where \a{${ObjectName}}
+ is the object name set in the UI file.
+ Thus the callback called is \a{Dynamic${ObjectName}Callback()}. Widgets can
+ be addressed using their object names (from the UI file):
+ \code
+ var page = pageWidgetByObjectName( "DynamicSomePage" )
+ page.myButton.click //direct child of the UI file's widgte
+ page.someFancyWidget.subWidget.setText( "foobar" ) // nested widget
+ \endcode
+
+
+ \section1 Message Boxes
+ \table
+ \header
+ \o Identifier
+ \o Possible Answers
+ \o Description
+ \row
+ \o cancelInstallation
+ \o Yes, No
+ \o Confirmation for canceling the installation (Cancel button in the wizard)
+ \row
+ \o overwriteTargetDirectory
+ \o Yes, No
+ \o Confirmation to use an already existing directory as target
+ \row
+ \o installationError
+ \o Ok
+ \o A fatal error occurred while performing the installation
+ \row
+ \o installationErrorWithRetry
+ \o Retry, Ignore, Cancel
+ \o An error occurred while performing the installation, Retry possible
+ \row
+ \o metaInfoJobError
+ \o Ok
+ \o Error occurred retrieving meta information (online installer)
+ \endtable
+
+*/
diff --git a/doc/qt-defines.qdocconf b/doc/qt-defines.qdocconf
new file mode 100644
index 000000000..a6b4c8d26
--- /dev/null
+++ b/doc/qt-defines.qdocconf
@@ -0,0 +1,66 @@
+defines = Q_QDOC \
+ QT_.*_SUPPORT \
+ QT_.*_LIB \
+ QT_COMPAT \
+ QT_KEYPAD_NAVIGATION \
+ QT_NO_EGL \
+ QT3_SUPPORT \
+ Q_WS_.* \
+ Q_OS_.* \
+ Q_BYTE_ORDER \
+ QT_DEPRECATED \
+ Q_NO_USING_KEYWORD \
+ __cplusplus
+
+versionsym = QT_VERSION_STR
+
+codeindent = 1
+
+# Files not referenced in any qdoc file (last four needed by qtdemo)
+# See also qhp.Qt.extraFiles
+extraimages.HTML = qt-logo \
+ trolltech-logo \
+ api_examples.png \
+ api_lookup.png \
+ arrow_down.png \
+ bg_ll.png \
+ bg_l.png \
+ bg_lr.png \
+ bg_r.png \
+ bg_ul_blank.png \
+ bg_ll_blank.png \
+ bg_l_blank.png \
+ breadcrumb.png \
+ bullet_dn.png \
+ bullet_gt.png \
+ bullet_sq.png \
+ box_bg.png \
+ feedbackground.png \
+ horBar.png \
+ page_bg.png \
+ page.png \
+ sprites-combined.png \
+ qtcreator-screenshots.png
+
+# This stuff is used by the new doc format.
+scriptdirs = $SRCDIR/templates/scripts
+styledirs = $SRCDIR/templates/style
+
+scripts.HTML = functions.js \
+ shBrushCpp.js \
+ shCore.js \
+ shLegacy.js \
+ narrow.js \
+ superfish.js \
+ jquery.js
+
+styles.HTML = style.css \
+ shCore.css \
+ shThemeDefault.css \
+ narrow.css \
+ superfish.css \
+ superfish_skin.css \
+ OfflineStyle.css \
+ style_ie6.css \
+ style_ie7.css \
+ style_ie8.css
diff --git a/doc/qt-html-templates.qdocconf b/doc/qt-html-templates.qdocconf
new file mode 100644
index 000000000..60674311f
--- /dev/null
+++ b/doc/qt-html-templates.qdocconf
@@ -0,0 +1,149 @@
+HTML.stylesheets = style/style.css \
+ style/OfflineStyle.css \
+ style/style_ie7.css \
+ style/style_ie8.css \
+ style/style_ie6.css
+
+HTML.postheader = " <div class=\"header\" id=\"qtdocheader\">\n" \
+ " <div class=\"content\"> \n" \
+ " <div id=\"nav-logo\">\n" \
+ " <a href=\"index.html\">Home</a></div>\n" \
+ " <a href=\"index.html\" class=\"qtref\"><span>Qt Installer Framework Manual</span></a>\n" \
+ " <div id=\"narrowsearch\"><form onsubmit=\"return false;\" action=\"\" id=\"qtdocsearch\">\n" \
+ " <fieldset>\n" \
+ " <input type=\"text\" value=\"\" id=\"pageType\" name=\"searchstring\">\n" \
+ " </fieldset>\n" \
+ " </form></div>\n" \
+ " <div id=\"nav-topright\">\n" \
+ " <ul>\n" \
+ " <li class=\"nav-topright-home\"><a href=\"http://qt.nokia.com/\">Qt HOME</a></li>\n" \
+ " <li class=\"nav-topright-dev\"><a href=\"http://qt.nokia.com/developer\">DEV</a></li>\n" \
+ " <li class=\"nav-topright-labs\"><a href=\"http://labs.qt.nokia.com/blogs/\">LABS</a></li>\n" \
+ " <li class=\"nav-topright-doc nav-topright-doc-active\"><a href=\"http://doc.qt.nokia.com/\">\n" \
+ " DOC</a></li>\n" \
+ " <li class=\"nav-topright-blog\"><a href=\"http://blog.qt.nokia.com/\">BLOG</a></li>\n" \
+ " <li class=\"nav-topright-shop\"><a title=\"SHOP\" href=\"http://shop.qt.nokia.com\">SHOP</a></li>\n" \
+ " </ul>\n" \
+ " </div>\n" \
+ " <div id=\"shortCut\">\n" \
+ " <ul>\n" \
+ " <li class=\"shortCut-topleft-inactive\"><span><a href=\"index.html\">Qt Installer Framework 1.0.1</a></span></li>\n" \
+ " <li class=\"shortCut-topleft-active\"><a href=\"http://qt.nokia.com/doc/\">ALL VERSIONS" \
+ " </a></li>\n" \
+ " </ul>\n" \
+ " </div>\n" \
+ " </div>\n" \
+ " </div>\n" \
+ " <div class=\"wrapper\">\n" \
+ " <div class=\"hd\">\n" \
+ " <span></span>\n" \
+ " </div>\n" \
+ " <div class=\"bd group\">\n" \
+ " <div class=\"sidebar\">\n" \
+ " <div class=\"searchlabel\">\n" \
+ " Search index:</div>\n" \
+ " <div class=\"search\">\n" \
+ " <form id=\"qtdocsearch\" action=\"\" onsubmit=\"return false;\">\n" \
+ " <fieldset>\n" \
+ " <input type=\"text\" name=\"searchstring\" id=\"pageType\" value=\"\" />\n" \
+ " </fieldset>\n" \
+ " </form>\n" \
+ " </div>\n" \
+ " <div class=\"box first bottombar\" id=\"lookup\">\n" \
+ " <h2 title=\"API Lookup\"><span></span>\n" \
+ " API Lookup</h2>\n" \
+ " <div id=\"list001\" class=\"list\">\n" \
+ " <ul id=\"ul001\" >\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/classes.html\">Class index</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/functions.html\">Function index</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/modules.html\">Modules</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/namespaces.html\">Namespaces</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/qtglobal.html\">Global stuff</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/qdeclarativeelements.html\">QML elements</a></li>\n" \
+ " </ul> \n" \
+ " </div>\n" \
+ " </div>\n" \
+ " <div class=\"box bottombar\" id=\"topics\">\n" \
+ " <h2 title=\"Qt Topics\"><span></span>\n" \
+ " Qt Topics</h2>\n" \
+ " <div id=\"list002\" class=\"list\">\n" \
+ " <ul id=\"ul002\" >\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/qt-basic-concepts.html\">Basic Qt architecture</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/declarativeui.html\">Device UI's &amp; Qt Quick</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/qt-gui-concepts.html\">Desktop UI components</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/platform-specific.html\">Platform-specific info</a></li>\n" \
+ " </ul> \n" \
+ " </div>\n" \
+ " </div>\n" \
+ " <div class=\"box\" id=\"examples\">\n" \
+ " <h2 title=\"Examples\"><span></span>\n" \
+ " Examples</h2>\n" \
+ " <div id=\"list003\" class=\"list\">\n" \
+ " <ul id=\"ul003\">\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/all-examples.html\">Examples</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/tutorials.html\">Tutorials</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/demos.html\">Demos</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/qdeclarativeexamples.html\">QML Examples</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"http://doc.qt.nokia.com/latest/qdeclarativeexamples.html#Demos\">QML Demos</a></li>\n" \
+ " </ul> \n" \
+ " </div>\n" \
+ " </div>\n" \
+ " </div>\n" \
+ " <div class=\"wrap\">\n" \
+ " <div class=\"toolbar\">\n" \
+ " <div class=\"breadcrumb toolblock\">\n" \
+ " <ul>\n" \
+ " <li class=\"first\"><a href=\"index.html\">Home</a></li>\n" \
+ " <!-- Bread crumbs goes here -->\n"
+
+HTML.postpostheader = " </ul>\n" \
+ " </div>\n" \
+ " <div class=\"toolbuttons toolblock\">\n" \
+ " <ul>\n" \
+ " <li id=\"smallA\" class=\"t_button\">A</li>\n" \
+ " <li id=\"medA\" class=\"t_button active\">A</li>\n" \
+ " <li id=\"bigA\" class=\"t_button\">A</li>\n" \
+ " <li id=\"print\" class=\"t_button\"><a href=\"javascript:this.print();\">\n" \
+ " <span>Print</span></a></li>\n" \
+ " </ul>\n" \
+ " </div>\n" \
+ " </div>\n" \
+ " <div class=\"content\">\n"
+
+HTML.footer = " <!-- /div -->\n" \
+ " <div class=\"feedback t_button\">\n" \
+ " [+] Documentation Feedback</div>\n" \
+ " </div>\n" \
+ " </div>\n" \
+ " <div class=\"ft\">\n" \
+ " <span></span>\n" \
+ " </div>\n" \
+ " </div> \n" \
+ " <div class=\"footer\">\n" \
+ " <p>\n" \
+ " <acronym title=\"Copyright\">&copy;</acronym> 2008-2010 Nokia Corporation and/or its\n" \
+ " subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation \n" \
+ " in Finland and/or other countries worldwide.</p>\n" \
+ " <p>\n" \
+ " All other trademarks are property of their respective owners. <a title=\"Privacy Policy\"\n" \
+ " href=\"http://qt.nokia.com/about/privacy-policy\">Privacy Policy</a></p>\n" \
+ " </div>\n" \
+ " <div id=\"feedbackBox\">\n" \
+ " <div id=\"feedcloseX\" class=\"feedclose t_button\">X</div>\n" \
+ " <form id=\"feedform\" action=\"http://doc.qt.nokia.com/docFeedbck/feedback.php\" method=\"get\">\n" \
+ " <p><textarea id=\"feedbox\" name=\"feedText\" rows=\"5\" cols=\"40\">Please submit you feedback...</textarea></p>\n" \
+ " <p><input id=\"feedsubmit\" class=\"feedclose\" type=\"submit\" name=\"feedback\" /></p>\n" \
+ " </form>\n" \
+ " </div>\n" \
+ " <div id=\"blurpage\">\n" \
+ " </div>\n" \
+ "<script type=\"text/javascript\">\n" \
+ " var _gaq = _gaq || [];\n" \
+ " _gaq.push([\'_setAccount\', \'UA-4457116-5\']);\n" \
+ " _gaq.push([\'_trackPageview\']);\n" \
+ " (function() {\n" \
+ " var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;\n" \
+ " ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';\n" \
+ " var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);\n" \
+ " })();\n" \
+ "</script>\n"
diff --git a/doc/scripting.qdoc b/doc/scripting.qdoc
new file mode 100644
index 000000000..ece1e0fce
--- /dev/null
+++ b/doc/scripting.qdoc
@@ -0,0 +1,305 @@
+/*!
+ \contentspage{index.html}{InstallerFramework}
+ \page scripting.html
+
+ \title Component Scripting
+
+ \section1 Scripting abilities inside of components
+
+ Each component can specify one script, which is loaded and run by the
+ installer. The format has to be compatible to QScriptEngine.
+
+ \section1 Contruction
+
+ The script has to provide an object Component, which will be created by the
+ Installer when loading the script. Therefore the script must contains at
+ least a function Component(), which can do all the initialization needed,
+ like putting user interfaces in place or connecting signals/slots:
+
+ \code
+ function Component()
+ {
+ // let's assume we have a user interface ErrorPage - which should not be complete
+ installer.addWizardPage( component, "ErrorPage", QInstaller.ReadyForInstallation );
+ component.userInterface( "ErrorPage" ).complete = false;
+ }
+ \endcode
+
+ The example above places the user interface "ErrorPage" (which is the class
+ name of the ui file loaded from errorpage.ui) in front of the installer
+ page "Ready for Installation" and sets his completeness to false. See the
+ documentation for addWizardPage and userInterface for details.
+
+ \section1 Installer Hooks
+
+ You can add several hook methods into your script:
+
+ \list
+ \o \bold{Component.prototype.retranslateUi} is called, whenever the language of the Installer changes.
+ \o \bold{Component.prototype.createOperations} - see QInstaller::Component::createOperations
+ \o \bold{Component.prototype.createOperationsForArchive} - see QInstaller::Component::createOperationsForArchive
+ \o \bold{Component.prototype.createOperationsForPath} - see QInstaller::Component::createOperationsForPath
+ \endlist
+
+ \section1 Global variables
+
+ The Installer puts the following symbols into the scripts space:
+
+ \list
+ \o \bold{installer} A reference to the component's Installer
+ \o \bold{component} A reference to the component's Component
+ \endlist
+
+ All methods marked with \a Q_INVOKABLE as well as all signals, slots and
+ properties can be used by the script.
+
+ \section1 Message boxes
+
+ You can show a QMessageBox from within the script by using:
+
+ \code
+ QMessageBox.critical
+ QMessageBox.information
+ QMessageBox.question
+ QMessageBox.warning
+ \endcode
+
+ For your convenience, the values for QMessageBox::StandardButton are made
+ available by using QMessageBox.Ok, QMessageBox.Open, ...
+
+ \section1 Adding operations to the component
+
+ In certain situations if it very useful to add custom operations after
+ extracting the content. Those include copying files as well as patching
+ content of files, etc.
+ Update operations can be created and added to the installation from within
+ a script using QInstaller::Component::addOperation.
+ Every operation has an unique key used for identification and up to five
+ parameters. Inside of the parameters, you can use variables as set in
+ QInstaller::Installer::setValue. See the list of
+ \l{Predefined variables}{predefined variables}.
+
+ Following a list of all available operations, which
+ can be added to a installation script.
+
+ \section2 Copy
+
+ \bold Syntax: "Copy" \a source \a target
+
+ Copies a file from \a source to \a target.
+
+
+ \section2 Move
+
+ \bold Syntax: "Move" \a source \a target
+
+ Moves a file from \a source to \a target.
+
+
+ \section2 Delete
+
+ \bold Syntax: "Delete" \a filename
+
+ Deletes the file specified by \a filename.
+
+
+ \section2 Mkdir
+
+ \bold Syntax: "Mkdir" \a path
+
+ Creates the directory path \a path.
+
+
+ \section2 Rmdir
+
+ \bold Syntax: "Rmdir" \a path
+
+ Removes the directory path \a path.
+
+
+ \section2 AppendFile
+
+ \bold Syntax: "AppendFile" \a filename \a text
+
+ Appends \a text to the file specified by \a filename. \a is threated as ASCII text.
+
+
+ \section2 PrependFile
+
+ \bold Syntax: "PrependFile" \a filename \a text
+
+ Prepends \a text to the file specified by \a filename. \a is threated as ASCII text.
+
+
+ \section2 Execute
+
+ \bold Syntax: "Execute" [{\a exitcodes}] \a command [\a parameter1 [\a parameter2 [\a parameter3 [\a parameter4]]]]
+
+ Executes the command specified by \a command. Up to four parameters can be passed.
+
+ Optionally, you can pass a comma separated list of numbers in {} as first argument, which defines the "valid" exit codes
+ of the process, i.e. the codes the execution is considered being successful. This defaults to "{0}".
+
+ \section2 CreateShortcut
+
+ \bold Syntax: "CreateShortcut" \a filename \a linkname [\a arguments]
+
+ Creates a shortcut from the file specified by \a filename to \a linkname.
+ On Windows, this will create a .lnk file which can have \a arguments, on Unix this will create a symobic link.
+
+
+ \section2 CreateDesktopEntry
+
+ \bold Syntax: "CreateDesktopEntry" \a filename \a "key=value[\nkey2=value2[\nkey3=value3]]]"
+
+ Creates an INI-file like .desktop file as specified by freedesktop.org
+ If \a filename is absolute, the desktop entry is stored there. Otherwise it's stored in locations defined in $XDG_DATA_DIRS/applications
+ or $XDG_DATA_HOME/applications, including the default pathes for boths, as defined by freedesktop.org.
+
+ The key/value pairs are written in the file.
+
+ The file is set to a encoding of UTF-8.
+
+ \section2 InstallIcons
+
+ \bold Syntax: "InstallIcons" \a directory
+
+ Installs the contents of \a directory into a location as specified by freedesktop.org, i.e. in any of $XDG_DATA_DIRS/icons or /usr/share/icons
+ or $HOME/.icons. The files are removed from their initial location. Make sure to add this operation after the operation extracting them form the archive.
+
+ \section2 Extract
+
+ \bold Syntax: "Extract" \a archive \a targetdirectory
+
+ Extracts \a archive to \a targetdirectory
+
+
+ \section2 GlobalConfig
+
+ \bold Syntax: "GlobalConfig" \a company \a application \a key \a value <br>
+ \a or <br>
+ \bold Syntax: "GlobalConfig" \a filename \a key \a value
+
+ Stores \a value for \a key in a configuration file. The configuration file is either
+ specified by \a filename (using QSettings::NativeFormat, which might be the Windows registry)
+ or via the \a application and the \a company name.
+
+
+ \section2 EnvironmentVariable
+
+ \bold Syntax: "EnvironmentVariable" \a key \a value [[\a persistent] \a system]
+
+ Sets the envirnoment variable \a key to a \a value. If \a persistent is set to true, the variable
+ will be set persistently. This is currently only supported on Windows. If \a system is set to true, the
+ persistent variable will be set system wide, not only for the current user.
+
+
+ \section2 RegisterFileType
+
+ \bold Syntax: "RegisterFileType" \a extension \a command [\a description [\a contentType [\a icon]]].
+
+ Registers the file type with \a extension to be opened via \a command. Optionally, you can specify
+ a \a description, a \a contentType and an \a icon. This is currently only supported on Windows.
+
+
+ \section1 Custom Operations
+
+ It is possible to register custom installation operations in the Installer. This works by deriving KDUpdater::UpdateOperation.
+ See the following code to know which methods must be implemented:
+
+ \code
+ #include <KDUpdater/UpdateOperation>
+
+ class CustomOperation : public KDUpdater::UpdateOperation
+ {
+ public:
+ CustomOperation()
+ {
+ setName( "CustomOperation" );
+ }
+
+ void backup()
+ {
+ // do whatever is needed to restore the state in undoOperation()
+ }
+
+ bool performOperation()
+ {
+ const QStringList args = arguments();
+ // do whatever is needed to do for the given arguments
+
+ bool success = ...;
+ return success;
+ }
+
+ void undoOperation()
+ {
+ // restore the previous state, as saved in backup()
+ }
+
+ bool testOperation()
+ {
+ // currently unused
+ return true;
+ }
+
+ CustomOperation* clone() const
+ {
+ return new CustomOperation;
+ }
+
+ QDomDocument toXml()
+ {
+ // automatically adds the operation's arguments and everything set via setValue
+ QDomDocument doc = KDUpdater::UpdateOperation::toXml();
+
+ // if you need any information to undo the operation you did,
+ // add them to the doc here
+
+ return doc;
+ }
+
+ bool fromXml( const QDomDocument& doc )
+ {
+ // automatically loads the operation's arguments and everything set via setValue
+ if( !KDUpdater::UpdateOperation::fromXml( doc ) )
+ return false;
+
+ // if you need any information to undo the operation you did,
+ // read them from the doc here
+
+ return true;
+ }
+ };
+ \endcode
+
+ Finally, you need to register your custom operation class:
+ \code
+ #include <KDupdater/UpdateOperationFactory>
+
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< CustomOperation >( "CustomOperation" );
+ \endcode
+
+ Now you can use your operation in the installer like every other of the predefined operations.
+
+ \section1 Predefined variables
+
+ Inside scripts you can use predefined variables to ease directory access. Those variables are
+
+ \list
+ \o \bold ProductName The name of the product to be installed as defined in config.xml
+ \o \bold ProductVersion The version of the product to be installed as defined in config.xml
+ \o \bold Title The title of the installation program as defined in config.xml
+ \o \bold Publisher The publisher of the installation program as defined in config.xml
+ \o \bold Url Product URL as defined in config.xml
+ \o \bold StartMenuDir Start menu group as defined in config.xml. Applies only to Microsoft Windows
+ \o \bold LicenseFile File name of the program license as defined in config.xml
+ \o \bold TargetDir Target directory for installation as selected by the user.
+ \o \bold DesktopDir Directory containing the user's desktop.
+ \o \bold os The current platform, might be "x11", "win" or "mac"
+ \endlist
+
+ \note You can use these variables inside of the parameter list for
+ installation operations. \a{"{TargetDir}/settings.xml"} might be expanded
+ to \a{"C:/Program Files/My Program/settings.xml"}.
+*/
diff --git a/doc/templates/images/api_examples.png b/doc/templates/images/api_examples.png
new file mode 100644
index 000000000..1fcbc96bd
--- /dev/null
+++ b/doc/templates/images/api_examples.png
Binary files differ
diff --git a/doc/templates/images/api_lookup.png b/doc/templates/images/api_lookup.png
new file mode 100644
index 000000000..1cffd5e35
--- /dev/null
+++ b/doc/templates/images/api_lookup.png
Binary files differ
diff --git a/doc/templates/images/api_topics.png b/doc/templates/images/api_topics.png
new file mode 100644
index 000000000..a76a6c3ed
--- /dev/null
+++ b/doc/templates/images/api_topics.png
Binary files differ
diff --git a/doc/templates/images/arrow_down.png b/doc/templates/images/arrow_down.png
new file mode 100644
index 000000000..9d01e97f6
--- /dev/null
+++ b/doc/templates/images/arrow_down.png
Binary files differ
diff --git a/doc/templates/images/bg_l.png b/doc/templates/images/bg_l.png
new file mode 100644
index 000000000..95470c78c
--- /dev/null
+++ b/doc/templates/images/bg_l.png
Binary files differ
diff --git a/doc/templates/images/bg_l_blank.png b/doc/templates/images/bg_l_blank.png
new file mode 100644
index 000000000..e0eca3f1c
--- /dev/null
+++ b/doc/templates/images/bg_l_blank.png
Binary files differ
diff --git a/doc/templates/images/bg_ll.png b/doc/templates/images/bg_ll.png
new file mode 100644
index 000000000..99796e7b5
--- /dev/null
+++ b/doc/templates/images/bg_ll.png
Binary files differ
diff --git a/doc/templates/images/bg_ll_blank.png b/doc/templates/images/bg_ll_blank.png
new file mode 100644
index 000000000..95a1c45e0
--- /dev/null
+++ b/doc/templates/images/bg_ll_blank.png
Binary files differ
diff --git a/doc/templates/images/bg_lr.png b/doc/templates/images/bg_lr.png
new file mode 100644
index 000000000..fef1d17bb
--- /dev/null
+++ b/doc/templates/images/bg_lr.png
Binary files differ
diff --git a/doc/templates/images/bg_r.png b/doc/templates/images/bg_r.png
new file mode 100644
index 000000000..42a35a546
--- /dev/null
+++ b/doc/templates/images/bg_r.png
Binary files differ
diff --git a/doc/templates/images/bg_ul.png b/doc/templates/images/bg_ul.png
new file mode 100644
index 000000000..303181f18
--- /dev/null
+++ b/doc/templates/images/bg_ul.png
Binary files differ
diff --git a/doc/templates/images/bg_ul_blank.png b/doc/templates/images/bg_ul_blank.png
new file mode 100644
index 000000000..70512614c
--- /dev/null
+++ b/doc/templates/images/bg_ul_blank.png
Binary files differ
diff --git a/doc/templates/images/bg_ur.png b/doc/templates/images/bg_ur.png
new file mode 100644
index 000000000..bfa51a4ce
--- /dev/null
+++ b/doc/templates/images/bg_ur.png
Binary files differ
diff --git a/doc/templates/images/bg_ur_blank.png b/doc/templates/images/bg_ur_blank.png
new file mode 100644
index 000000000..57799616c
--- /dev/null
+++ b/doc/templates/images/bg_ur_blank.png
Binary files differ
diff --git a/doc/templates/images/box_bg.png b/doc/templates/images/box_bg.png
new file mode 100644
index 000000000..232655a81
--- /dev/null
+++ b/doc/templates/images/box_bg.png
Binary files differ
diff --git a/doc/templates/images/breadcrumb.png b/doc/templates/images/breadcrumb.png
new file mode 100644
index 000000000..f0571ce1b
--- /dev/null
+++ b/doc/templates/images/breadcrumb.png
Binary files differ
diff --git a/doc/templates/images/bullet_dn.png b/doc/templates/images/bullet_dn.png
new file mode 100644
index 000000000..f7762472e
--- /dev/null
+++ b/doc/templates/images/bullet_dn.png
Binary files differ
diff --git a/doc/templates/images/bullet_gt.png b/doc/templates/images/bullet_gt.png
new file mode 100644
index 000000000..88759256c
--- /dev/null
+++ b/doc/templates/images/bullet_gt.png
Binary files differ
diff --git a/doc/templates/images/bullet_sq.png b/doc/templates/images/bullet_sq.png
new file mode 100644
index 000000000..db85ee340
--- /dev/null
+++ b/doc/templates/images/bullet_sq.png
Binary files differ
diff --git a/doc/templates/images/bullet_up.png b/doc/templates/images/bullet_up.png
new file mode 100644
index 000000000..285e7411b
--- /dev/null
+++ b/doc/templates/images/bullet_up.png
Binary files differ
diff --git a/doc/templates/images/content_bg.png b/doc/templates/images/content_bg.png
new file mode 100644
index 000000000..416397d04
--- /dev/null
+++ b/doc/templates/images/content_bg.png
Binary files differ
diff --git a/doc/templates/images/feedbackground.png b/doc/templates/images/feedbackground.png
new file mode 100644
index 000000000..3a38d995d
--- /dev/null
+++ b/doc/templates/images/feedbackground.png
Binary files differ
diff --git a/doc/templates/images/form_bg.png b/doc/templates/images/form_bg.png
new file mode 100644
index 000000000..bf2ee5446
--- /dev/null
+++ b/doc/templates/images/form_bg.png
Binary files differ
diff --git a/doc/templates/images/header.png b/doc/templates/images/header.png
new file mode 100644
index 000000000..3c68d9c52
--- /dev/null
+++ b/doc/templates/images/header.png
Binary files differ
diff --git a/doc/templates/images/header_bg.png b/doc/templates/images/header_bg.png
new file mode 100644
index 000000000..a436aa61e
--- /dev/null
+++ b/doc/templates/images/header_bg.png
Binary files differ
diff --git a/doc/templates/images/horBar.png b/doc/templates/images/horBar.png
new file mode 100644
index 000000000..100fe91c6
--- /dev/null
+++ b/doc/templates/images/horBar.png
Binary files differ
diff --git a/doc/templates/images/page.png b/doc/templates/images/page.png
new file mode 100644
index 000000000..1db151bd3
--- /dev/null
+++ b/doc/templates/images/page.png
Binary files differ
diff --git a/doc/templates/images/page_bg.png b/doc/templates/images/page_bg.png
new file mode 100644
index 000000000..fb7d051a2
--- /dev/null
+++ b/doc/templates/images/page_bg.png
Binary files differ
diff --git a/doc/templates/images/print.png b/doc/templates/images/print.png
new file mode 100644
index 000000000..4581da187
--- /dev/null
+++ b/doc/templates/images/print.png
Binary files differ
diff --git a/doc/templates/images/qt_guide.png b/doc/templates/images/qt_guide.png
new file mode 100644
index 000000000..9f53a052e
--- /dev/null
+++ b/doc/templates/images/qt_guide.png
Binary files differ
diff --git a/doc/templates/images/qt_icon.png b/doc/templates/images/qt_icon.png
new file mode 100644
index 000000000..fbaee3584
--- /dev/null
+++ b/doc/templates/images/qt_icon.png
Binary files differ
diff --git a/doc/templates/images/qt_ref_doc.png b/doc/templates/images/qt_ref_doc.png
new file mode 100644
index 000000000..141488b86
--- /dev/null
+++ b/doc/templates/images/qt_ref_doc.png
Binary files differ
diff --git a/doc/templates/images/qt_tools.png b/doc/templates/images/qt_tools.png
new file mode 100644
index 000000000..cc2417981
--- /dev/null
+++ b/doc/templates/images/qt_tools.png
Binary files differ
diff --git a/doc/templates/images/sep.png b/doc/templates/images/sep.png
new file mode 100644
index 000000000..c895646f2
--- /dev/null
+++ b/doc/templates/images/sep.png
Binary files differ
diff --git a/doc/templates/images/spinner.gif b/doc/templates/images/spinner.gif
new file mode 100644
index 000000000..1ed786f2e
--- /dev/null
+++ b/doc/templates/images/spinner.gif
Binary files differ
diff --git a/doc/templates/images/sprites-combined.png b/doc/templates/images/sprites-combined.png
new file mode 100644
index 000000000..3a48b21f6
--- /dev/null
+++ b/doc/templates/images/sprites-combined.png
Binary files differ
diff --git a/doc/templates/scripts/functions.js b/doc/templates/scripts/functions.js
new file mode 100644
index 000000000..58a024859
--- /dev/null
+++ b/doc/templates/scripts/functions.js
@@ -0,0 +1,192 @@
+/* START non link areas where cursor should change to pointing hand */
+$('.t_button').mouseover(function() {
+ $('.t_button').css('cursor','pointer');
+ /*document.getElementById(this.id).style.cursor='pointer';*/
+});
+/* END non link areas */
+$('#smallA').click(function() {
+ $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','smaller');
+ $('.t_button').removeClass('active')
+ $(this).addClass('active')
+});
+
+$('#medA').click(function() {
+ $('.content .heading').css('font','600 16px/1 Arial');
+ $('.content h1').css('font','600 18px/1.2 Arial');
+ $('.content h2').css('font','600 16px/1.2 Arial');
+ $('.content h3').css('font','600 14px/1.2 Arial');
+ $('.content p').css('font','13px/20px Verdana');
+ $('.content li').css('font','400 13px/1 Verdana');
+ $('.content li').css('line-height','14px');
+ $('.content .toc li').css('font', 'normal 10px/1.2 Verdana');
+ $('.content table').css('font','13px/1.2 Verdana');
+ $('.content .heading').css('font','600 16px/1 Arial');
+ $('.content .indexboxcont li').css('font','600 13px/1 Verdana');
+ $('.t_button').removeClass('active')
+ $(this).addClass('active')
+});
+
+$('#bigA').click(function() {
+ $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','large');
+ $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('line-height','25px');
+ $('.t_button').removeClass('active')
+ $(this).addClass('active')
+});
+
+$('.feedclose').click(function() {
+ $('.bd').show();
+ $('.hd').show();
+ $('.footer').show();
+ $('#feedbackBox').hide();
+ $('#blurpage').hide();
+});
+
+$('.feedback').click(function() {
+ $('.bd').hide();
+ $('.hd').hide();
+ $('.footer').hide();
+ $('#feedbackBox').show();
+ $('#blurpage').show();
+});
+var lookupCount = 0;
+var articleCount = 0;
+var exampleCount = 0;
+var qturl = ""; // change from "http://doc.qt.nokia.com/4.6/" to 0 so we can have relative links
+
+function processNokiaData(response){
+ var propertyTags = response.getElementsByTagName('page');
+
+ for (var i=0; i< propertyTags.length; i++) {
+ var linkStart = "<li class=\"liveResult\"><a href='"+qturl+"";
+ var linkEnd = "</a></li>";
+
+ if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'APIPage'){
+ lookupCount++;
+
+
+ for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){
+ full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue;
+ full_li_element = full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd;
+
+ $('#ul001').append(full_li_element);
+ $('#ul001 .defaultLink').css('display','none');
+
+ }
+ }
+
+ if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Article'){
+ articleCount++;
+
+
+ for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){
+ full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue;
+ full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ;
+
+ $('#ul002').append(full_li_element);
+ $('#ul002 .defaultLink').css('display','none');
+
+ }
+ }
+ if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Example'){
+ exampleCount++;
+
+
+ for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){
+ full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue;
+ full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ;
+
+ $('#ul003').append(full_li_element);
+ $('#ul003 .defaultLink').css('display','none');
+
+ }
+ }
+ if(i==propertyTags.length){$('#pageType').removeClass('loading');}
+
+ }
+
+ if(lookupCount == 0){$('#ul001').prepend('<li class=\"liveResult noMatch\">Found no result</li>');$('#ul001 li').css('display','block');$('.sidebar .search form input').removeClass('loading');}
+ if(articleCount == 0){$('#ul002').prepend('<li class=\"liveResult noMatch\">Found no result</li>');$('#ul002 li').css('display','block');}
+ if(exampleCount == 0){$('#ul003').prepend('<li class=\"liveResult noMatch\">Found no result</li>');$('#ul003 li').css('display','block');}
+ // reset count variables;
+ lookupCount=0;
+ articleCount = 0;
+ exampleCount = 0;
+
+}
+//build regular expression object to find empty string or any number of blank
+var blankRE=/^\s*$/;
+function CheckEmptyAndLoadList()
+{
+ var pageUrl = window.location.href;
+ var pageVal = $('title').html();
+ $('#feedUrl').remove();
+ $('#pageVal').remove();
+ $('#feedform').append('<input id="feedUrl" name="feedUrl" value="'+pageUrl+'" style="display:none;">');
+ $('#feedform').append('<input id="pageVal" name="pageVal" value="'+pageVal+'" style="display:none;">');
+ $('.liveResult').remove();
+ $('.defaultLink').css('display','block');
+ var value = document.getElementById('pageType').value;
+ if((blankRE.test(value)) || (value.length < 3))
+ {
+ //empty inputbox
+ // load default li elements into the ul if empty
+ // loadAllList(); // replaced
+ $('.defaultLink').css('display','block');
+ // $('.liveResult').css('display','none');
+ }else{
+ $('.defaultLink').css('display','none');
+ }
+}
+/*
+$(window).resize(function(){
+if($(window).width()<400)
+ $('body').addClass('offline');
+else
+ $('body').removeClass('offline');
+ });
+ */
+// Loads on doc ready
+ $(document).ready(function () {
+ //alert(pageUrl);
+ //$('#pageUrl').attr('foo',pageUrl);
+ var pageTitle = $('title').html();
+ var currentString = $('#pageType').val() ;
+ if(currentString.length < 1){
+ $('.defaultLink').css('display','block');
+ CheckEmptyAndLoadList();
+ }
+
+ $('#pageType').keyup(function () {
+ var searchString = $('#pageType').val() ;
+ if ((searchString == null) || (searchString.length < 3)) {
+ $('#pageType').removeClass('loading');
+ $('.liveResult').remove(); // replaces removeResults();
+ CheckEmptyAndLoadList();
+ $('.report').remove();
+ // debug$('.content').prepend('<li>too short or blank</li>'); // debug
+ return;
+ }
+ if (this.timer) clearTimeout(this.timer);
+ this.timer = setTimeout(function () {
+ $('#pageType').addClass('loading');
+ // debug$('.content').prepend('<li>new search started </li>');// debug
+ // debug$('.content').prepend('<p class=\"report\">Search string ' +searchString +'</p>'); // debug
+
+ $.ajax({
+ contentType: "application/x-www-form-urlencoded",
+ url: 'http://' + location.host + '/nokiasearch/GetDataServlet',
+ data: 'searchString='+searchString,
+ dataType:'xml',
+ type: 'post',
+ success: function (response, textStatus) {
+
+ $('.liveResult').remove(); // replaces removeResults();
+ $('#pageType').removeClass('loading');
+
+ processNokiaData(response);
+
+ }
+ });
+ }, 500);
+ });
+ });
diff --git a/doc/templates/scripts/jquery.js b/doc/templates/scripts/jquery.js
new file mode 100644
index 000000000..0c7294c90
--- /dev/null
+++ b/doc/templates/scripts/jquery.js
@@ -0,0 +1,152 @@
+/*!
+ * jQuery JavaScript Library v1.4.1
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Mon Jan 25 19:43:33 2010 -0500
+ */
+(function(z,v){function la(){if(!c.isReady){try{r.documentElement.doScroll("left")}catch(a){setTimeout(la,1);return}c.ready()}}function Ma(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,i){var j=a.length;if(typeof b==="object"){for(var n in b)X(a,n,b[n],f,e,d);return a}if(d!==v){f=!i&&f&&c.isFunction(d);for(n=0;n<j;n++)e(a[n],b,f?d.call(a[n],n,e(a[n],b)):d,i);return a}return j?
+e(a[0],b):null}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function ma(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function na(a){var b,d=[],f=[],e=arguments,i,j,n,o,m,s,x=c.extend({},c.data(this,"events").live);if(!(a.button&&a.type==="click")){for(o in x){j=x[o];if(j.live===a.type||j.altLive&&c.inArray(a.type,j.altLive)>-1){i=j.data;i.beforeFilter&&i.beforeFilter[a.type]&&!i.beforeFilter[a.type](a)||f.push(j.selector)}else delete x[o]}i=c(a.target).closest(f,
+a.currentTarget);m=0;for(s=i.length;m<s;m++)for(o in x){j=x[o];n=i[m].elem;f=null;if(i[m].selector===j.selector){if(j.live==="mouseenter"||j.live==="mouseleave")f=c(a.relatedTarget).closest(j.selector)[0];if(!f||f!==n)d.push({elem:n,fn:j})}}m=0;for(s=d.length;m<s;m++){i=d[m];a.currentTarget=i.elem;a.data=i.fn.data;if(i.fn.apply(i.elem,e)===false){b=false;break}}return b}}function oa(a,b){return"live."+(a?a+".":"")+b.replace(/\./g,"`").replace(/ /g,"&")}function pa(a){return!a||!a.parentNode||a.parentNode.nodeType===
+11}function qa(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var i in f)for(var j in f[i])c.event.add(this,i,f[i][j],f[i][j].data)}}})}function ra(a,b,d){var f,e,i;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&a[0].indexOf("<option")<0&&(c.support.checkClone||!sa.test(a[0]))){e=true;if(i=c.fragments[a[0]])if(i!==1)f=i}if(!f){b=b&&b[0]?b[0].ownerDocument||b[0]:r;f=b.createDocumentFragment();
+c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=i?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(ta.concat.apply([],ta.slice(0,b)),function(){d[this]=a});return d}function ua(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Na=z.jQuery,Oa=z.$,r=z.document,S,Pa=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Qa=/^.[^:#\[\.,]*$/,Ra=/\S/,Sa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Ta=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,O=navigator.userAgent,
+va=false,P=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,Q=Array.prototype.slice,wa=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(typeof a==="string")if((d=Pa.exec(a))&&(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:r;if(a=Ta.exec(a))if(c.isPlainObject(b)){a=[r.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=ra([d[1]],
+[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}}else{if(b=r.getElementById(d[2])){if(b.id!==d[2])return S.find(a);this.length=1;this[0]=b}this.context=r;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=r;a=r.getElementsByTagName(a)}else return!b||b.jquery?(b||S).find(a):c(b).find(a);else if(c.isFunction(a))return S.ready(a);if(a.selector!==v){this.selector=a.selector;this.context=a.context}return c.isArray(a)?this.setArray(a):c.makeArray(a,
+this)},selector:"",jquery:"1.4.1",length:0,size:function(){return this.length},toArray:function(){return Q.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){a=c(a||null);a.prevObject=this;a.context=this.context;if(b==="find")a.selector=this.selector+(this.selector?" ":"")+d;else if(b)a.selector=this.selector+"."+b+"("+d+")";return a},setArray:function(a){this.length=0;ba.apply(this,a);return this},each:function(a,b){return c.each(this,
+a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(r,c);else P&&P.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(Q.apply(this,arguments),"slice",Q.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};
+c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,i,j,n;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(i in e){j=a[i];n=e[i];if(a!==n)if(f&&n&&(c.isPlainObject(n)||c.isArray(n))){j=j&&(c.isPlainObject(j)||c.isArray(j))?j:c.isArray(n)?[]:{};a[i]=c.extend(f,j,n)}else if(n!==v)a[i]=n}return a};c.extend({noConflict:function(a){z.$=
+Oa;if(a)z.jQuery=Na;return c},isReady:false,ready:function(){if(!c.isReady){if(!r.body)return setTimeout(c.ready,13);c.isReady=true;if(P){for(var a,b=0;a=P[b++];)a.call(r,c);P=null}c.fn.triggerHandler&&c(r).triggerHandler("ready")}},bindReady:function(){if(!va){va=true;if(r.readyState==="complete")return c.ready();if(r.addEventListener){r.addEventListener("DOMContentLoaded",L,false);z.addEventListener("load",c.ready,false)}else if(r.attachEvent){r.attachEvent("onreadystatechange",L);z.attachEvent("onload",
+c.ready);var a=false;try{a=z.frameElement==null}catch(b){}r.documentElement.doScroll&&a&&la()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,"isPrototypeOf"))return false;var b;for(b in a);return b===v||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;
+return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return z.JSON&&z.JSON.parse?z.JSON.parse(a):(new Function("return "+a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Ra.test(a)){var b=r.getElementsByTagName("head")[0]||
+r.documentElement,d=r.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(r.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,i=a.length,j=i===v||c.isFunction(a);if(d)if(j)for(f in a){if(b.apply(a[f],d)===false)break}else for(;e<i;){if(b.apply(a[e++],d)===false)break}else if(j)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=
+a[0];e<i&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Sa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==
+v;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,i=a.length;e<i;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,i=0,j=a.length;i<j;i++){e=b(a[i],i,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=v}else if(b&&!c.isFunction(b)){d=b;b=v}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},
+uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});O=c.uaMatch(O);if(O.browser){c.browser[O.browser]=true;c.browser.version=O.version}if(c.browser.webkit)c.browser.safari=true;if(wa)c.inArray=function(a,b){return wa.call(b,a)};S=c(r);if(r.addEventListener)L=function(){r.removeEventListener("DOMContentLoaded",
+L,false);c.ready()};else if(r.attachEvent)L=function(){if(r.readyState==="complete"){r.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=r.documentElement,b=r.createElement("script"),d=r.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var e=d.getElementsByTagName("*"),i=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!i)){c.support=
+{leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(i.getAttribute("style")),hrefNormalized:i.getAttribute("href")==="/a",opacity:/^0.55$/.test(i.style.opacity),cssFloat:!!i.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:r.createElement("select").appendChild(r.createElement("option")).selected,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};
+b.type="text/javascript";try{b.appendChild(r.createTextNode("window."+f+"=1;"))}catch(j){}a.insertBefore(b,a.firstChild);if(z[f]){c.support.scriptEval=true;delete z[f]}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function n(){c.support.noCloneEvent=false;d.detachEvent("onclick",n)});d.cloneNode(true).fireEvent("onclick")}d=r.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=r.createDocumentFragment();a.appendChild(d.firstChild);
+c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var n=r.createElement("div");n.style.width=n.style.paddingLeft="1px";r.body.appendChild(n);c.boxModel=c.support.boxModel=n.offsetWidth===2;r.body.removeChild(n).style.display="none"});a=function(n){var o=r.createElement("div");n="on"+n;var m=n in o;if(!m){o.setAttribute(n,"return;");m=typeof o[n]==="function"}return m};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=i=null}})();c.props=
+{"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ua=0,xa={},Va={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==z?xa:a;var f=a[G],e=c.cache;if(!b&&!f)return null;f||(f=++Ua);if(typeof b==="object"){a[G]=f;e=e[f]=c.extend(true,
+{},b)}else e=e[f]?e[f]:typeof d==="undefined"?Va:(e[f]={});if(d!==v){a[G]=f;e[b]=d}return typeof b==="string"?e[b]:e}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==z?xa:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{try{delete a[G]}catch(i){a.removeAttribute&&a.removeAttribute(G)}delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,
+a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===v){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===v&&this.length)f=c.data(this[0],a);return f===v&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);
+return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===v)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||
+a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var ya=/[\n\t]/g,ca=/\s+/,Wa=/\r/g,Xa=/href|src|style/,Ya=/(button|input)/i,Za=/(button|input|object|select|textarea)/i,$a=/^(a|area)$/i,za=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(o){var m=
+c(this);m.addClass(a.call(this,o,m.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className)for(var i=" "+e.className+" ",j=0,n=b.length;j<n;j++){if(i.indexOf(" "+b[j]+" ")<0)e.className+=" "+b[j]}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(o){var m=c(this);m.removeClass(a.call(this,o,m.attr("class")))});if(a&&typeof a==="string"||a===v)for(var b=(a||"").split(ca),
+d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var i=(" "+e.className+" ").replace(ya," "),j=0,n=b.length;j<n;j++)i=i.replace(" "+b[j]+" "," ");e.className=i.substring(1,i.length-1)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var i=c(this);i.toggleClass(a.call(this,e,i.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,i=0,j=c(this),n=b,o=
+a.split(ca);e=o[i++];){n=f?n:!j.hasClass(e);j[n?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(ya," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===v){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||
+{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var i=b?d:0;for(d=b?d+1:e.length;i<d;i++){var j=e[i];if(j.selected){a=c(j).val();if(b)return a;f.push(a)}}return f}if(za.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Wa,"")}return v}var n=c.isFunction(a);return this.each(function(o){var m=c(this),s=a;if(this.nodeType===1){if(n)s=a.call(this,o,m.val());
+if(typeof s==="number")s+="";if(c.isArray(s)&&za.test(this.type))this.checked=c.inArray(m.val(),s)>=0;else if(c.nodeName(this,"select")){var x=c.makeArray(s);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),x)>=0});if(!x.length)this.selectedIndex=-1}else this.value=s}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return v;if(f&&b in c.attrFn)return c(a)[b](d);
+f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==v;b=f&&c.props[b]||b;if(a.nodeType===1){var i=Xa.test(b);if(b in a&&f&&!i){if(e){b==="type"&&Ya.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:Za.test(a.nodeName)||$a.test(a.nodeName)&&a.href?0:v;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=
+""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&i?a.getAttribute(b,2):a.getAttribute(b);return a===null?v:a}return c.style(a,b,d)}});var ab=function(a){return a.replace(/[^\w\s\.\|`]/g,function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==z&&!a.frameElement)a=z;if(!d.guid)d.guid=c.guid++;if(f!==v){d=c.proxy(d);d.data=f}var e=c.data(a,"events")||c.data(a,"events",{}),i=c.data(a,"handle"),j;if(!i){j=
+function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(j.elem,arguments):v};i=c.data(a,"handle",j)}if(i){i.elem=a;b=b.split(/\s+/);for(var n,o=0;n=b[o++];){var m=n.split(".");n=m.shift();if(o>1){d=c.proxy(d);if(f!==v)d.data=f}d.type=m.slice(0).sort().join(".");var s=e[n],x=this.special[n]||{};if(!s){s=e[n]={};if(!x.setup||x.setup.call(a,f,m,d)===false)if(a.addEventListener)a.addEventListener(n,i,false);else a.attachEvent&&a.attachEvent("on"+n,i)}if(x.add)if((m=x.add.call(a,
+d,f,m,s))&&c.isFunction(m)){m.guid=m.guid||d.guid;m.data=m.data||d.data;m.type=m.type||d.type;d=m}s[d.guid]=d;this.global[n]=true}a=null}}},global:{},remove:function(a,b,d){if(!(a.nodeType===3||a.nodeType===8)){var f=c.data(a,"events"),e,i,j;if(f){if(b===v||typeof b==="string"&&b.charAt(0)===".")for(i in f)this.remove(a,i+(b||""));else{if(b.type){d=b.handler;b=b.type}b=b.split(/\s+/);for(var n=0;i=b[n++];){var o=i.split(".");i=o.shift();var m=!o.length,s=c.map(o.slice(0).sort(),ab);s=new RegExp("(^|\\.)"+
+s.join("\\.(?:.*\\.)?")+"(\\.|$)");var x=this.special[i]||{};if(f[i]){if(d){j=f[i][d.guid];delete f[i][d.guid]}else for(var A in f[i])if(m||s.test(f[i][A].type))delete f[i][A];x.remove&&x.remove.call(a,o,j);for(e in f[i])break;if(!e){if(!x.teardown||x.teardown.call(a,o)===false)if(a.removeEventListener)a.removeEventListener(i,c.data(a,"handle"),false);else a.detachEvent&&a.detachEvent("on"+i,c.data(a,"handle"));e=null;delete f[i]}}}}for(e in f)break;if(!e){if(A=c.data(a,"handle"))A.elem=null;c.removeData(a,
+"events");c.removeData(a,"handle")}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();this.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return v;a.result=v;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,
+b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(i){}if(!a.isPropagationStopped()&&f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){d=a.target;var j;if(!(c.nodeName(d,"a")&&e==="click")&&!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()])){try{if(d[e]){if(j=d["on"+e])d["on"+e]=null;this.triggered=true;d[e]()}}catch(n){}if(j)d["on"+e]=j;this.triggered=false}}},handle:function(a){var b,
+d;a=arguments[0]=c.event.fix(a||z.event);a.currentTarget=this;d=a.type.split(".");a.type=d.shift();b=!d.length&&!a.exclusive;var f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)");d=(c.data(this,"events")||{})[a.type];for(var e in d){var i=d[e];if(b||f.test(i.type)){a.handler=i;a.data=i.data;i=i.apply(this,arguments);if(i!==v){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||r;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=r.documentElement;d=r.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
+d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==v)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a,b){c.extend(a,b||{});a.guid+=b.selector+b.live;b.liveProxy=a;c.event.add(this,b.live,na,b)},remove:function(a){if(a.length){var b=
+0,d=new RegExp("(^|\\.)"+a[0]+"(\\.|$)");c.each(c.data(this,"events").live||{},function(){d.test(this.type)&&b++});b<1&&c.event.remove(this,a[0],na)}},special:{}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};
+c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,isImmediatePropagationStopped:Y};var Aa=function(a){for(var b=
+a.relatedTarget;b&&b!==this;)try{b=b.parentNode}catch(d){break}if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}},Ba=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ba:Aa,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ba:Aa)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(a,b,d){if(this.nodeName.toLowerCase()!==
+"form"){c.event.add(this,"click.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="submit"||i==="image")&&c(e).closest("form").length)return ma("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="text"||i==="password")&&c(e).closest("form").length&&f.keyCode===13)return ma("submit",this,arguments)})}else return false},remove:function(a,b){c.event.remove(this,"click.specialSubmit"+(b?"."+b.guid:""));c.event.remove(this,
+"keypress.specialSubmit"+(b?"."+b.guid:""))}};if(!c.support.changeBubbles){var da=/textarea|input|select/i;function Ca(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d}function ea(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Ca(d);if(a.type!=="focusout"||
+d.type!=="radio")c.data(d,"_change_data",e);if(!(f===v||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}}c.event.special.change={filters:{focusout:ea,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return ea.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return ea.call(this,a)},beforeactivate:function(a){a=
+a.target;a.nodeName.toLowerCase()==="input"&&a.type==="radio"&&c.data(a,"_change_data",Ca(a))}},setup:function(a,b,d){for(var f in T)c.event.add(this,f+".specialChange."+d.guid,T[f]);return da.test(this.nodeName)},remove:function(a,b){for(var d in T)c.event.remove(this,d+".specialChange"+(b?"."+b.guid:""),T[d]);return da.test(this.nodeName)}};var T=c.event.special.change.filters}r.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,
+f)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var i in d)this[b](i,f,d[i],e);return this}if(c.isFunction(f)){e=f;f=v}var j=b==="one"?c.proxy(e,function(n){c(this).unbind(n,j);return e.apply(this,arguments)}):e;return d==="unload"&&b!=="one"?this.one(d,f,e):this.each(function(){c.event.add(this,d,j,f)})}});c.fn.extend({unbind:function(a,
+b){if(typeof a==="object"&&!a.preventDefault){for(var d in a)this.unbind(d,a[d]);return this}return this.each(function(){c.event.remove(this,a,b)})},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+
+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e){var i,j=0;if(c.isFunction(f)){e=f;f=v}for(d=(d||"").split(/\s+/);(i=d[j++])!=null;){i=i==="focus"?"focusin":i==="blur"?"focusout":i==="hover"?d.push("mouseleave")&&"mouseenter":i;b==="live"?c(this.context).bind(oa(i,this.selector),{data:f,selector:this.selector,
+live:i},e):c(this.context).unbind(oa(i,this.selector),e?{guid:e.guid+this.selector+i}:null)}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});z.attachEvent&&!z.addEventListener&&z.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});
+(function(){function a(g){for(var h="",k,l=0;g[l];l++){k=g[l];if(k.nodeType===3||k.nodeType===4)h+=k.nodeValue;else if(k.nodeType!==8)h+=a(k.childNodes)}return h}function b(g,h,k,l,q,p){q=0;for(var u=l.length;q<u;q++){var t=l[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===k){y=l[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=k;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}l[q]=y}}}function d(g,h,k,l,q,p){q=0;for(var u=l.length;q<u;q++){var t=l[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===
+k){y=l[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=k;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(o.filter(h,[t]).length>0){y=t;break}}t=t[g]}l[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,i=Object.prototype.toString,j=false,n=true;[0,0].sort(function(){n=false;return 0});var o=function(g,h,k,l){k=k||[];var q=h=h||r;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||
+typeof g!=="string")return k;for(var p=[],u,t,y,R,H=true,M=w(h),I=g;(f.exec(""),u=f.exec(I))!==null;){I=u[3];p.push(u[1]);if(u[2]){R=u[3];break}}if(p.length>1&&s.exec(g))if(p.length===2&&m.relative[p[0]])t=fa(p[0]+p[1],h);else for(t=m.relative[p[0]]?[h]:o(p.shift(),h);p.length;){g=p.shift();if(m.relative[g])g+=p.shift();t=fa(g,t)}else{if(!l&&p.length>1&&h.nodeType===9&&!M&&m.match.ID.test(p[0])&&!m.match.ID.test(p[p.length-1])){u=o.find(p.shift(),h,M);h=u.expr?o.filter(u.expr,u.set)[0]:u.set[0]}if(h){u=
+l?{expr:p.pop(),set:A(l)}:o.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=u.expr?o.filter(u.expr,u.set):u.set;if(p.length>0)y=A(t);else H=false;for(;p.length;){var D=p.pop();u=D;if(m.relative[D])u=p.pop();else D="";if(u==null)u=h;m.relative[D](y,u,M)}}else y=[]}y||(y=t);y||o.error(D||g);if(i.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))k.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&
+y[g].nodeType===1&&k.push(t[g]);else k.push.apply(k,y);else A(y,k);if(R){o(R,q,k,l);o.uniqueSort(k)}return k};o.uniqueSort=function(g){if(C){j=n;g.sort(C);if(j)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};o.matches=function(g,h){return o(g,null,null,h)};o.find=function(g,h,k){var l,q;if(!g)return[];for(var p=0,u=m.order.length;p<u;p++){var t=m.order[p];if(q=m.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");l=m.find[t](q,
+h,k);if(l!=null){g=g.replace(m.match[t],"");break}}}}l||(l=h.getElementsByTagName("*"));return{set:l,expr:g}};o.filter=function(g,h,k,l){for(var q=g,p=[],u=h,t,y,R=h&&h[0]&&w(h[0]);g&&h.length;){for(var H in m.filter)if((t=m.leftMatch[H].exec(g))!=null&&t[2]){var M=m.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-1)!=="\\"){if(u===p)p=[];if(m.preFilter[H])if(t=m.preFilter[H](t,u,k,p,l,R)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=u[U])!=null;U++)if(D){I=M(D,t,U,u);var Da=
+l^!!I;if(k&&I!=null)if(Da)y=true;else u[U]=false;else if(Da){p.push(D);y=true}}if(I!==v){k||(u=p);g=g.replace(m.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)o.error(g);else break;q=g}return u};o.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var m=o.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},relative:{"+":function(g,h){var k=typeof h==="string",l=k&&!/\W/.test(h);k=k&&!l;if(l)h=h.toLowerCase();l=0;for(var q=g.length,
+p;l<q;l++)if(p=g[l]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[l]=k||p&&p.nodeName.toLowerCase()===h?p||false:p===h}k&&o.filter(h,g,true)},">":function(g,h){var k=typeof h==="string";if(k&&!/\W/.test(h)){h=h.toLowerCase();for(var l=0,q=g.length;l<q;l++){var p=g[l];if(p){k=p.parentNode;g[l]=k.nodeName.toLowerCase()===h?k:false}}}else{l=0;for(q=g.length;l<q;l++)if(p=g[l])g[l]=k?p.parentNode:p.parentNode===h;k&&o.filter(h,g,true)}},"":function(g,h,k){var l=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=
+h=h.toLowerCase();q=b}q("parentNode",h,l,g,p,k)},"~":function(g,h,k){var l=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,l,g,p,k)}},find:{ID:function(g,h,k){if(typeof h.getElementById!=="undefined"&&!k)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var k=[];h=h.getElementsByName(g[1]);for(var l=0,q=h.length;l<q;l++)h[l].getAttribute("name")===g[1]&&k.push(h[l]);return k.length===0?null:k}},
+TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,k,l,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var u;(u=h[p])!=null;p++)if(u)if(q^(u.className&&(" "+u.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))k||l.push(u);else if(k)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&
+"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,k,l,q,p){h=g[1].replace(/\\/g,"");if(!p&&m.attrMap[h])g[1]=m.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,k,l,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=o(g[3],null,null,h);else{g=o.filter(g[3],h,k,true^q);k||l.push.apply(l,g);return false}else if(m.match.POS.test(g[0])||m.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);
+return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,k){return!!o(k[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===
+g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,h){return h===0},last:function(g,h,k,l){return h===l.length-1},even:function(g,h){return h%2===
+0},odd:function(g,h){return h%2===1},lt:function(g,h,k){return h<k[3]-0},gt:function(g,h,k){return h>k[3]-0},nth:function(g,h,k){return k[3]-0===h},eq:function(g,h,k){return k[3]-0===h}},filter:{PSEUDO:function(g,h,k,l){var q=h[1],p=m.filters[q];if(p)return p(g,k,h,l);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=h[3];k=0;for(l=h.length;k<l;k++)if(h[k]===g)return false;return true}else o.error("Syntax error, unrecognized expression: "+
+q)},CHILD:function(g,h){var k=h[1],l=g;switch(k){case "only":case "first":for(;l=l.previousSibling;)if(l.nodeType===1)return false;if(k==="first")return true;l=g;case "last":for(;l=l.nextSibling;)if(l.nodeType===1)return false;return true;case "nth":k=h[2];var q=h[3];if(k===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var u=0;for(l=p.firstChild;l;l=l.nextSibling)if(l.nodeType===1)l.nodeIndex=++u;p.sizcache=h}g=g.nodeIndex-q;return k===0?g===0:g%k===0&&g/k>=
+0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var k=h[1];g=m.attrHandle[k]?m.attrHandle[k](g):g[k]!=null?g[k]:g.getAttribute(k);k=g+"";var l=h[2];h=h[4];return g==null?l==="!=":l==="="?k===h:l==="*="?k.indexOf(h)>=0:l==="~="?(" "+k+" ").indexOf(h)>=0:!h?k&&g!==false:l==="!="?k!==h:l==="^="?
+k.indexOf(h)===0:l==="$="?k.substr(k.length-h.length)===h:l==="|="?k===h||k.substr(0,h.length+1)===h+"-":false},POS:function(g,h,k,l){var q=m.setFilters[h[2]];if(q)return q(g,k,h,l)}}},s=m.match.POS;for(var x in m.match){m.match[x]=new RegExp(m.match[x].source+/(?![^\[]*\])(?![^\(]*\))/.source);m.leftMatch[x]=new RegExp(/(^(?:.|\r|\n)*?)/.source+m.match[x].source.replace(/\\(\d+)/g,function(g,h){return"\\"+(h-0+1)}))}var A=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};
+try{Array.prototype.slice.call(r.documentElement.childNodes,0)}catch(B){A=function(g,h){h=h||[];if(i.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var k=0,l=g.length;k<l;k++)h.push(g[k]);else for(k=0;g[k];k++)h.push(g[k]);return h}}var C;if(r.documentElement.compareDocumentPosition)C=function(g,h){if(!g.compareDocumentPosition||!h.compareDocumentPosition){if(g==h)j=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===
+h?0:1;if(g===0)j=true;return g};else if("sourceIndex"in r.documentElement)C=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)j=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)j=true;return g};else if(r.createRange)C=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)j=true;return g.ownerDocument?-1:1}var k=g.ownerDocument.createRange(),l=h.ownerDocument.createRange();k.setStart(g,0);k.setEnd(g,0);l.setStart(h,0);l.setEnd(h,0);g=k.compareBoundaryPoints(Range.START_TO_END,
+l);if(g===0)j=true;return g};(function(){var g=r.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var k=r.documentElement;k.insertBefore(g,k.firstChild);if(r.getElementById(h)){m.find.ID=function(l,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(l[1]))?q.id===l[1]||typeof q.getAttributeNode!=="undefined"&&q.getAttributeNode("id").nodeValue===l[1]?[q]:v:[]};m.filter.ID=function(l,q){var p=typeof l.getAttributeNode!=="undefined"&&l.getAttributeNode("id");
+return l.nodeType===1&&p&&p.nodeValue===q}}k.removeChild(g);k=g=null})();(function(){var g=r.createElement("div");g.appendChild(r.createComment(""));if(g.getElementsByTagName("*").length>0)m.find.TAG=function(h,k){k=k.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var l=0;k[l];l++)k[l].nodeType===1&&h.push(k[l]);k=h}return k};g.innerHTML="<a href='#'></a>";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")m.attrHandle.href=function(h){return h.getAttribute("href",
+2)};g=null})();r.querySelectorAll&&function(){var g=o,h=r.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){o=function(l,q,p,u){q=q||r;if(!u&&q.nodeType===9&&!w(q))try{return A(q.querySelectorAll(l),p)}catch(t){}return g(l,q,p,u)};for(var k in g)o[k]=g[k];h=null}}();(function(){var g=r.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===
+0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){m.order.splice(1,0,"CLASS");m.find.CLASS=function(h,k,l){if(typeof k.getElementsByClassName!=="undefined"&&!l)return k.getElementsByClassName(h[1])};g=null}}})();var E=r.compareDocumentPosition?function(g,h){return g.compareDocumentPosition(h)&16}:function(g,h){return g!==h&&(g.contains?g.contains(h):true)},w=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},fa=function(g,h){var k=[],
+l="",q;for(h=h.nodeType?[h]:h;q=m.match.PSEUDO.exec(g);){l+=q[0];g=g.replace(m.match.PSEUDO,"")}g=m.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)o(g,h[q],k);return o.filter(l,k)};c.find=o;c.expr=o.selectors;c.expr[":"]=c.expr.filters;c.unique=o.uniqueSort;c.getText=a;c.isXMLDoc=w;c.contains=E})();var bb=/Until$/,cb=/^(?:parents|prevUntil|prevAll)/,db=/,/;Q=Array.prototype.slice;var Ea=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,i){return!!b.call(e,i,e)===d});else if(b.nodeType)return c.grep(a,
+function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Qa.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;c.find(a,this[f],b);if(f>0)for(var i=d;i<b.length;i++)for(var j=0;j<d;j++)if(b[j]===b[i]){b.splice(i--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=
+0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ea(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ea(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,i={},j;if(f&&a.length){e=0;for(var n=a.length;e<n;e++){j=a[e];i[j]||(i[j]=c.expr.match.POS.test(j)?c(j,b||this.context):j)}for(;f&&f.ownerDocument&&f!==b;){for(j in i){e=i[j];if(e.jquery?e.index(f)>
+-1:c(f).is(e)){d.push({selector:j,elem:f});delete i[j]}}f=f.parentNode}}return d}var o=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(m,s){for(;s&&s.ownerDocument&&s!==b;){if(o?o.index(s)>-1:c(s).is(a))return s;s=s.parentNode}return null})},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),
+a);return this.pushStack(pa(a[0])||pa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},
+nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);bb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):
+e;if((this.length>1||db.test(f))&&cb.test(a))e=e.reverse();return this.pushStack(e,a,Q.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===v||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==
+b&&d.push(a);return d}});var Fa=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ga=/(<([\w:]+)[^>]*?)\/>/g,eb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,Ha=/<([\w:]+)/,fb=/<tbody/i,gb=/<|&\w+;/,sa=/checked\s*(?:[^=]|=\s*.checked.)/i,Ia=function(a,b,d){return eb.test(d)?a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],
+col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==v)return this.empty().append((this[0]&&this[0].ownerDocument||r).createTextNode(a));return c.getText(this)},
+wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?
+d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,
+false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&
+!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Fa,"").replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){qa(this,b);qa(this.find("*"),b.find("*"))}return b},html:function(a){if(a===v)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Fa,""):null;else if(typeof a==="string"&&!/<script/i.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(Ha.exec(a)||
+["",""])[1].toLowerCase()]){a=a.replace(Ga,Ia);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var i=c(this),j=i.html();i.empty().append(function(){return a.call(this,e,j)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,
+b,f))});else a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(s){return c.nodeName(s,"table")?s.getElementsByTagName("tbody")[0]||s.appendChild(s.ownerDocument.createElement("tbody")):s}var e,i,j=a[0],n=[];if(!c.support.checkClone&&arguments.length===3&&typeof j===
+"string"&&sa.test(j))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(j))return this.each(function(s){var x=c(this);a[0]=j.call(this,s,b?x.html():v);x.domManip(a,b,d)});if(this[0]){e=a[0]&&a[0].parentNode&&a[0].parentNode.nodeType===11?{fragment:a[0].parentNode}:ra(a,this,n);if(i=e.fragment.firstChild){b=b&&c.nodeName(i,"tr");for(var o=0,m=this.length;o<m;o++)d.call(b?f(this[o],i):this[o],e.cacheable||this.length>1||o>0?e.fragment.cloneNode(true):e.fragment)}n&&c.each(n,
+Ma)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);for(var e=0,i=d.length;e<i;e++){var j=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),j);f=f.concat(j)}return this.pushStack(f,a,d.selector)}});c.each({remove:function(a,b){if(!a||c.filter(a,[this]).length){if(!b&&this.nodeType===1){c.cleanData(this.getElementsByTagName("*"));c.cleanData([this])}this.parentNode&&
+this.parentNode.removeChild(this)}},empty:function(){for(this.nodeType===1&&c.cleanData(this.getElementsByTagName("*"));this.firstChild;)this.removeChild(this.firstChild)}},function(a,b){c.fn[a]=function(){return this.each(b,arguments)}});c.extend({clean:function(a,b,d,f){b=b||r;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||r;var e=[];c.each(a,function(i,j){if(typeof j==="number")j+="";if(j){if(typeof j==="string"&&!gb.test(j))j=b.createTextNode(j);else if(typeof j===
+"string"){j=j.replace(Ga,Ia);var n=(Ha.exec(j)||["",""])[1].toLowerCase(),o=F[n]||F._default,m=o[0];i=b.createElement("div");for(i.innerHTML=o[1]+j+o[2];m--;)i=i.lastChild;if(!c.support.tbody){m=fb.test(j);n=n==="table"&&!m?i.firstChild&&i.firstChild.childNodes:o[1]==="<table>"&&!m?i.childNodes:[];for(o=n.length-1;o>=0;--o)c.nodeName(n[o],"tbody")&&!n[o].childNodes.length&&n[o].parentNode.removeChild(n[o])}!c.support.leadingWhitespace&&V.test(j)&&i.insertBefore(b.createTextNode(V.exec(j)[0]),i.firstChild);
+j=c.makeArray(i.childNodes)}if(j.nodeType)e.push(j);else e=c.merge(e,j)}});if(d)for(a=0;e[a];a++)if(f&&c.nodeName(e[a],"script")&&(!e[a].type||e[a].type.toLowerCase()==="text/javascript"))f.push(e[a].parentNode?e[a].parentNode.removeChild(e[a]):e[a]);else{e[a].nodeType===1&&e.splice.apply(e,[a+1,0].concat(c.makeArray(e[a].getElementsByTagName("script"))));d.appendChild(e[a])}return e},cleanData:function(a){for(var b=0,d;(d=a[b])!=null;b++){c.event.remove(d);c.removeData(d)}}});var hb=/z-?index|font-?weight|opacity|zoom|line-?height/i,
+Ja=/alpha\([^)]*\)/,Ka=/opacity=([^)]*)/,ga=/float/i,ha=/-([a-z])/ig,ib=/([A-Z])/g,jb=/^-?\d+(?:px)?$/i,kb=/^-?\d/,lb={position:"absolute",visibility:"hidden",display:"block"},mb=["Left","Right"],nb=["Top","Bottom"],ob=r.defaultView&&r.defaultView.getComputedStyle,La=c.support.cssFloat?"cssFloat":"styleFloat",ia=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===v)return c.curCSS(d,f);if(typeof e==="number"&&!hb.test(f))e+="px";c.style(d,f,e)})};
+c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return v;if((b==="width"||b==="height")&&parseFloat(d)<0)d=v;var f=a.style||a,e=d!==v;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=Ja.test(a)?a.replace(Ja,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Ka.exec(f.filter)[1])/100+"":""}if(ga.test(b))b=La;b=b.replace(ha,ia);if(e)f[b]=d;return f[b]},css:function(a,
+b,d,f){if(b==="width"||b==="height"){var e,i=b==="width"?mb:nb;function j(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(i,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,"border"+this+"Width",true))||0})}a.offsetWidth!==0?j():c.swap(a,lb,j);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&
+a.currentStyle){f=Ka.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ga.test(b))b=La;if(!d&&e&&e[b])f=e[b];else if(ob){if(ga.test(b))b="float";b=b.replace(ib,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ha,ia);f=a.currentStyle[b]||a.currentStyle[d];if(!jb.test(f)&&kb.test(f)){b=e.left;var i=a.runtimeStyle.left;a.runtimeStyle.left=
+a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=i}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var pb=
+J(),qb=/<script(.|\s)*?\/script>/gi,rb=/select|textarea/i,sb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ja=/\?/,tb=/(\?|&)_=.*?(&|$)/,ub=/^(\w+:)?\/\/([^\/?#]+)/,vb=/%20/g;c.fn.extend({_load:c.fn.load,load:function(a,b,d){if(typeof a!=="string")return this._load(a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=
+c.param(b,c.ajaxSettings.traditional);f="POST"}var i=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(j,n){if(n==="success"||n==="notmodified")i.html(e?c("<div />").append(j.responseText.replace(qb,"")).find(e):j.responseText);d&&i.each(d,[j.responseText,n,j])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&
+(this.checked||rb.test(this.nodeName)||sb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,
+b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:z.XMLHttpRequest&&(z.location.protocol!=="file:"||!z.ActiveXObject)?function(){return new z.XMLHttpRequest}:
+function(){try{return new z.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&e.success.call(o,n,j,w);e.global&&f("ajaxSuccess",[w,e])}function d(){e.complete&&e.complete.call(o,w,j);e.global&&f("ajaxComplete",[w,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}
+function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),i,j,n,o=a&&a.context||e,m=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(m==="GET")N.test(e.url)||(e.url+=(ja.test(e.url)?"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||
+N.test(e.url))){i=e.jsonpCallback||"jsonp"+pb++;if(e.data)e.data=(e.data+"").replace(N,"="+i+"$1");e.url=e.url.replace(N,"="+i+"$1");e.dataType="script";z[i]=z[i]||function(q){n=q;b();d();z[i]=v;try{delete z[i]}catch(p){}A&&A.removeChild(B)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===false&&m==="GET"){var s=J(),x=e.url.replace(tb,"$1_="+s+"$2");e.url=x+(x===e.url?(ja.test(e.url)?"&":"?")+"_="+s:"")}if(e.data&&m==="GET")e.url+=(ja.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&
+c.event.trigger("ajaxStart");s=(s=ub.exec(e.url))&&(s[1]&&s[1]!==location.protocol||s[2]!==location.host);if(e.dataType==="script"&&m==="GET"&&s){var A=r.getElementsByTagName("head")[0]||r.documentElement,B=r.createElement("script");B.src=e.url;if(e.scriptCharset)B.charset=e.scriptCharset;if(!i){var C=false;B.onload=B.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;b();d();B.onload=B.onreadystatechange=null;A&&B.parentNode&&
+A.removeChild(B)}}}A.insertBefore(B,A.firstChild);return v}var E=false,w=e.xhr();if(w){e.username?w.open(m,e.url,e.async,e.username,e.password):w.open(m,e.url,e.async);try{if(e.data||a&&a.contentType)w.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[e.url]);c.etag[e.url]&&w.setRequestHeader("If-None-Match",c.etag[e.url])}s||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",
+e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(fa){}if(e.beforeSend&&e.beforeSend.call(o,w,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");w.abort();return false}e.global&&f("ajaxSend",[w,e]);var g=w.onreadystatechange=function(q){if(!w||w.readyState===0||q==="abort"){E||d();E=true;if(w)w.onreadystatechange=c.noop}else if(!E&&w&&(w.readyState===4||q==="timeout")){E=true;w.onreadystatechange=c.noop;j=q==="timeout"?"timeout":!c.httpSuccess(w)?
+"error":e.ifModified&&c.httpNotModified(w,e.url)?"notmodified":"success";var p;if(j==="success")try{n=c.httpData(w,e.dataType,e)}catch(u){j="parsererror";p=u}if(j==="success"||j==="notmodified")i||b();else c.handleError(e,w,j,p);d();q==="timeout"&&w.abort();if(e.async)w=null}};try{var h=w.abort;w.abort=function(){w&&h.call(w);g("abort")}}catch(k){}e.async&&e.timeout>0&&setTimeout(function(){w&&!E&&g("timeout")},e.timeout);try{w.send(m==="POST"||m==="PUT"||m==="DELETE"?e.data:null)}catch(l){c.handleError(e,
+w,null,l);d()}e.async||g();return w}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=
+f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(j,n){if(c.isArray(n))c.each(n,
+function(o,m){b?f(j,m):d(j+"["+(typeof m==="object"||c.isArray(m)?o:"")+"]",m)});else!b&&n!=null&&typeof n==="object"?c.each(n,function(o,m){d(j+"["+o+"]",m)}):f(j,n)}function f(j,n){n=c.isFunction(n)?n():n;e[e.length]=encodeURIComponent(j)+"="+encodeURIComponent(n)}var e=[];if(b===v)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var i in a)d(i,a[i]);return e.join("&").replace(vb,"+")}});var ka={},wb=/toggle|show|hide/,xb=/^([+-]=)?([\d+-.]+)(.*)$/,
+W,ta=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(ka[d])f=ka[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();
+ka[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&
+c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var i=c.extend({},e),j,n=this.nodeType===1&&c(this).is(":hidden"),
+o=this;for(j in a){var m=j.replace(ha,ia);if(j!==m){a[m]=a[j];delete a[j];j=m}if(a[j]==="hide"&&n||a[j]==="show"&&!n)return i.complete.call(this);if((j==="height"||j==="width")&&this.style){i.display=c.css(this,"display");i.overflow=this.style.overflow}if(c.isArray(a[j])){(i.specialEasing=i.specialEasing||{})[j]=a[j][1];a[j]=a[j][0]}}if(i.overflow!=null)this.style.overflow="hidden";i.curAnim=c.extend({},a);c.each(a,function(s,x){var A=new c.fx(o,i,s);if(wb.test(x))A[x==="toggle"?n?"show":"hide":x](a);
+else{var B=xb.exec(x),C=A.cur(true)||0;if(B){x=parseFloat(B[2]);var E=B[3]||"px";if(E!=="px"){o.style[s]=(x||1)+E;C=(x||1)/A.cur(true)*C;o.style[s]=C+E}if(B[1])x=(B[1]==="-="?-1:1)*x+C;A.custom(C,x,E)}else A.custom(C,x,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",
+1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration==="number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,
+b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==
+null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(i){return e.step(i)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop===
+"width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=
+this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=
+c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=
+null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in r.documentElement?function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),
+f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=this[0];if(a)return this.each(function(s){c.offset.setOffset(this,a,s)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=
+b,e=b.ownerDocument,i,j=e.documentElement,n=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var o=b.offsetTop,m=b.offsetLeft;(b=b.parentNode)&&b!==n&&b!==j;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;i=e?e.getComputedStyle(b,null):b.currentStyle;o-=b.scrollTop;m-=b.scrollLeft;if(b===d){o+=b.offsetTop;m+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){o+=parseFloat(i.borderTopWidth)||
+0;m+=parseFloat(i.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&i.overflow!=="visible"){o+=parseFloat(i.borderTopWidth)||0;m+=parseFloat(i.borderLeftWidth)||0}f=i}if(f.position==="relative"||f.position==="static"){o+=n.offsetTop;m+=n.offsetLeft}if(c.offset.supportsFixedPosition&&f.position==="fixed"){o+=Math.max(j.scrollTop,n.scrollTop);m+=Math.max(j.scrollLeft,n.scrollLeft)}return{top:o,left:m}};c.offset={initialize:function(){var a=r.body,b=r.createElement("div"),
+d,f,e,i=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";a.insertBefore(b,a.firstChild);
+d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i;a.removeChild(b);c.offset.initialize=c.noop},
+bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),i=parseInt(c.curCSS(a,"top",true),10)||0,j=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,d,e);d={top:b.top-e.top+i,left:b.left-
+e.left+j};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=
+this.offsetParent||r.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],i;if(!e)return null;if(f!==v)return this.each(function(){if(i=ua(this))i.scrollTo(!a?f:c(i).scrollLeft(),a?f:c(i).scrollTop());else this[d]=f});else return(i=ua(e))?"pageXOffset"in i?i[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&i.document.documentElement[d]||i.document.body[d]:e[d]}});
+c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(i){var j=c(this);j[d](f.call(this,i,j[d]()))});return"scrollTo"in e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||
+e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===v?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});z.jQuery=z.$=c})(window);
diff --git a/doc/templates/scripts/narrow.js b/doc/templates/scripts/narrow.js
new file mode 100644
index 000000000..12d0ce89d
--- /dev/null
+++ b/doc/templates/scripts/narrow.js
@@ -0,0 +1,78 @@
+var narrowInit = function() {
+ /* TODO:
+ Could probably be more efficient, not hardcoding each element to be created
+ */
+ // 1: Create search form
+ var narrowSearch = $('<div id="narrowsearch"></div>');
+ var searchform = $("#qtdocsearch");
+ narrowSearch.append(searchform);
+ $("#qtdocheader .content .qtref").after(narrowSearch);
+
+ // 2: Create dropdowns
+ var narrowmenu = $('<ul id="narrowmenu" class="sf-menu"></ul>');
+
+ // Lookup
+ var lookuptext = $("#lookup h2").attr("title");
+ $("#lookup ul").removeAttr("id");
+ $("#lookup ul li").removeAttr("class");
+ $("#lookup ul li").removeAttr("style");
+ var lookupul = $("#lookup ul");
+ var lookuplist = $('<li></li>');
+ var lookuplink = $('<a href="#"></a>');
+ lookuplink.append(lookuptext);
+ lookuplist.append(lookuplink);
+ lookuplist.append(lookupul);
+ narrowmenu.append(lookuplist);
+
+ // Topics
+ var topicstext = $("#topics h2").attr("title");
+ $("#topics ul").removeAttr("id");
+ $("#topics ul li").removeAttr("class");
+ $("#topics ul li").removeAttr("style");
+ var topicsul = $("#topics ul");
+ var topicslist = $('<li></li>');
+ var topicslink = $('<a href="#"></a>');
+ topicslink.append(topicstext);
+ topicslist.append(topicslink);
+ topicslist.append(topicsul);
+ narrowmenu.append(topicslist);
+
+ // Examples
+ var examplestext = $("#examples h2").attr("title");
+ $("#examples ul").removeAttr("id");
+ $("#examples ul li").removeAttr("class");
+ $("#examples ul li").removeAttr("style");
+ var examplesul = $("#examples ul");
+ var exampleslist = $('<li></li>');
+ var exampleslink = $('<a href="#"></a>');
+ exampleslink.append(examplestext);
+ exampleslist.append(exampleslink);
+ exampleslist.append(examplesul);
+ narrowmenu.append(exampleslist);
+
+ $("#shortCut").after(narrowmenu);
+ $('ul#narrowmenu').superfish({
+ delay: 100,
+ autoArrows: false,
+ disableHI: true
+ });
+}
+
+$(document).ready(function(){
+ if ($('body').hasClass('narrow')) {
+ narrowInit();
+ }
+});
+
+$(window).bind('resize', function () {
+ if($(window).width()<600) {
+ $('body').addClass('narrow');
+
+ if ($("#narrowsearch").length == 0) {
+ narrowInit();
+ }
+ }
+ else {
+ $('body').removeClass('narrow');
+ }
+}); \ No newline at end of file
diff --git a/doc/templates/scripts/superfish.js b/doc/templates/scripts/superfish.js
new file mode 100644
index 000000000..c6a9c7de0
--- /dev/null
+++ b/doc/templates/scripts/superfish.js
@@ -0,0 +1,121 @@
+
+/*
+ * Superfish v1.4.8 - jQuery menu widget
+ * Copyright (c) 2008 Joel Birch
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
+ */
+
+;(function($){
+ $.fn.superfish = function(op){
+
+ var sf = $.fn.superfish,
+ c = sf.c,
+ $arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
+ over = function(){
+ var $$ = $(this), menu = getMenu($$);
+ clearTimeout(menu.sfTimer);
+ $$.showSuperfishUl().siblings().hideSuperfishUl();
+ },
+ out = function(){
+ var $$ = $(this), menu = getMenu($$), o = sf.op;
+ clearTimeout(menu.sfTimer);
+ menu.sfTimer=setTimeout(function(){
+ o.retainPath=($.inArray($$[0],o.$path)>-1);
+ $$.hideSuperfishUl();
+ if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
+ },o.delay);
+ },
+ getMenu = function($menu){
+ var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
+ sf.op = sf.o[menu.serial];
+ return menu;
+ },
+ addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
+
+ return this.each(function() {
+ var s = this.serial = sf.o.length;
+ var o = $.extend({},sf.defaults,op);
+ o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
+ $(this).addClass([o.hoverClass,c.bcClass].join(' '))
+ .filter('li:has(ul)').removeClass(o.pathClass);
+ });
+ sf.o[s] = sf.op = o;
+
+ $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
+ if (o.autoArrows) addArrow( $('>a:first-child',this) );
+ })
+ .not('.'+c.bcClass)
+ .hideSuperfishUl();
+
+ var $a = $('a',this);
+ $a.each(function(i){
+ var $li = $a.eq(i).parents('li');
+ $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
+ });
+ o.onInit.call(this);
+
+ }).each(function() {
+ var menuClasses = [c.menuClass];
+ if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
+ $(this).addClass(menuClasses.join(' '));
+ });
+ };
+
+ var sf = $.fn.superfish;
+ sf.o = [];
+ sf.op = {};
+ sf.IE7fix = function(){
+ var o = sf.op;
+ if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
+ this.toggleClass(sf.c.shadowClass+'-off');
+ };
+ sf.c = {
+ bcClass : 'sf-breadcrumb',
+ menuClass : 'sf-js-enabled',
+ anchorClass : 'sf-with-ul',
+ arrowClass : 'sf-sub-indicator',
+ shadowClass : 'sf-shadow'
+ };
+ sf.defaults = {
+ hoverClass : 'sfHover',
+ pathClass : 'overideThisToUse',
+ pathLevels : 1,
+ delay : 800,
+ animation : {opacity:'show'},
+ speed : 'normal',
+ autoArrows : true,
+ dropShadows : true,
+ disableHI : false, // true disables hoverIntent detection
+ onInit : function(){}, // callback functions
+ onBeforeShow: function(){},
+ onShow : function(){},
+ onHide : function(){}
+ };
+ $.fn.extend({
+ hideSuperfishUl : function(){
+ var o = sf.op,
+ not = (o.retainPath===true) ? o.$path : '';
+ o.retainPath = false;
+ var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
+ .find('>ul').hide().css('visibility','hidden');
+ o.onHide.call($ul);
+ return this;
+ },
+ showSuperfishUl : function(){
+ var o = sf.op,
+ sh = sf.c.shadowClass+'-off',
+ $ul = this.addClass(o.hoverClass)
+ .find('>ul:hidden').css('visibility','visible');
+ sf.IE7fix.call($ul);
+ o.onBeforeShow.call($ul);
+ $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
+ return this;
+ }
+ });
+
+})(jQuery);
diff --git a/doc/templates/style/OfflineStyle.css b/doc/templates/style/OfflineStyle.css
new file mode 100644
index 000000000..51ea3541b
--- /dev/null
+++ b/doc/templates/style/OfflineStyle.css
@@ -0,0 +1,836 @@
+@media screen
+{
+ html
+ {
+ color: #000000;
+ background: #FFFFFF;
+ }
+ body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td
+ {
+ margin: 0;
+ padding: 0;
+ }
+ table
+ {
+ border-collapse: collapse;
+ border-spacing: 0;
+ }
+ fieldset, img
+ {
+ border: 0;
+ }
+ address, caption, cite, code, dfn, em, strong, th, var, optgroup
+ {
+ font-style: inherit;
+ font-weight: inherit;
+ }
+ del, ins
+ {
+ text-decoration: none;
+ }
+ li
+ {
+ list-style: none;
+ }
+ caption, th
+ {
+ text-align: left;
+ }
+ h1, h2, h3, h4, h5, h6
+ {
+ font-size: 100%;
+ }
+ q:before, q:after
+ {
+ content: '';
+ }
+ abbr, acronym
+ {
+ border: 0;
+ font-variant: normal;
+ }
+ sup
+ {
+ vertical-align: baseline;
+ }
+ sub
+ {
+ vertical-align: baseline;
+ }
+ tt, .qmlreadonly span, .qmldefault span
+ {
+ word-spacing:5px;
+ }
+ .heading
+ {
+ font: normal 600 16px/1.0 Arial;
+ }
+ .subtitle
+ {
+ font-size: 13px;
+ }
+ .small-subtitle
+ {
+ font-size: 13px;
+ }
+ legend
+ {
+ color: #000000;
+ }
+ input, button, textarea, select, optgroup, option
+ {
+ font-family: inherit;
+ font-size: inherit;
+ font-style: inherit;
+ font-weight: inherit;
+ }
+ input, button, textarea, select
+ {
+ font-size: 100%;
+ }
+ body
+ {
+ font: normal 13px/1.2 Verdana;
+ color: #363534;
+ }
+ strong
+ {
+ font-weight: bold;
+ }
+ em
+ {
+ font-style: italic;
+ }
+ a
+ {
+ color: #00732f;
+ text-decoration: none;
+ }
+ .header, .footer, .wrapper
+ {
+ /*min-width: 600px;*/
+ max-width: 1500px;
+ margin: 0 5px;
+ }
+ .wrapper
+ {
+ position:relative;
+ top:50px;
+ }
+ .wrapper .bd
+ {
+ position: relative;
+ }
+
+ .header, .footer
+ {
+ display: block;
+ clear: both;
+ overflow: hidden;
+ }
+ .header
+ {
+ height: 115px;
+ position: relative;
+ }
+
+
+ .header .qtref
+ {
+ position: absolute;
+ top: 28px;
+ left: 88px;
+ width: 302px;
+ height: 22px;
+ }
+ .header .qtref span
+ {
+ display: block;
+ height: 22px;
+ }
+ .wrap .content h1
+ {
+ font: 600 18px/1.2 Arial;
+ }
+ .wrap .content h2
+ {
+ font: 600 16px/1.2 Arial;
+ }
+ .wrap .content h3
+ {
+ font: 600 14px/1.2 Arial;
+ }
+ .wrap .content h4
+ {
+ font: 600 12px/1.2 Arial;
+ }
+
+ .wrap .content p
+ {
+ line-height: 20px;
+ padding: 5px;
+ }
+ .wrap .content table p
+ {
+ line-height: 20px;
+ padding: 0px;
+ }
+ .wrap .content ul
+ {
+ padding-left: 25px;
+ padding-top: 10px;
+ }
+ a:hover
+ {
+ color: #4c0033;
+ text-decoration: underline;
+ }
+ .content a:visited
+ {
+ color: #4c0033;
+ text-decoration: none;
+ }
+ .content a:visited:hover
+ {
+ color: #4c0033;
+ text-decoration: underline;
+ }
+
+ pre
+ {
+ border: 1px solid #DDDDDD;
+ margin: 0 20px 10px 10px;
+ padding: 20px 15px 20px 20px;
+ overflow-x: auto;
+ }
+ table, pre
+ {
+ -moz-border-radius: 7px 7px 7px 7px;
+ background-color: #F6F6F6;
+ border: 1px solid #E6E6E6;
+ border-collapse: separate;
+ font-size: 11px;
+ /*min-width: 395px;*/
+ margin-bottom: 25px;
+ display: inline-block;
+ }
+ thead
+ {
+ margin-top: 5px;
+ font:600 12px/1.2 Arial;
+ }
+ th
+ {
+ padding: 5px 15px 5px 15px;
+ background-color: #E1E1E1;
+ /* border-bottom: 1px solid #E6E6E6;*/
+ border-left: 1px solid #E6E6E6;
+ /* border-right: 1px solid #E6E6E6;*/
+ }
+ td
+ {
+ padding: 3px 15px 3px 20px;
+ /* border-left: 1px solid #E6E6E6;
+ border-right: 1px solid #E6E6E6;*/
+ }
+ tr.odd td:hover, tr.even td:hover
+ {
+ /* border-right: 1px solid #C3C3C3;
+ border-left: 1px solid #C3C3C3;*/
+ }
+
+ td.rightAlign
+ {
+ padding: 3px 15px 3px 10px;
+ }
+ table tr.odd
+ {
+ border-left: 1px solid #E6E6E6;
+ background-color: #F6F6F6;
+ color: #66666E;
+ }
+ table tr.even
+ {
+ border-left: 1px solid #E6E6E6;
+ background-color: #ffffff;
+ color: #66666E;
+ }
+ table tr.odd td:hover, table tr.even td:hover
+ {
+ background-color: #E6E6E6;
+ }
+
+ span.comment
+ {
+ color: #8B0000;
+ font-style: italic;
+ }
+ span.string, span.char
+ {
+ color: #254117;
+ }
+
+ .qmltype
+ {
+ text-align: center;
+ font-size: 160%;
+ }
+ .qmlreadonly
+ {
+ float: right;
+ color: #254117;
+ }
+
+ .qmldefault
+ {
+ float: right;
+ color: red;
+ }
+
+ .footer
+ {
+ border-top:1px solid #E5E5E5;
+ min-height: 100px;
+ color: #797775;
+ font: normal 9px/1 Verdana;
+ text-align: center;
+ padding-top: 40px;
+ margin: 0;
+ }
+
+
+ .wrap
+ {
+ margin: 0 5px 0 5px;
+ }
+ .wrap .toolbar
+ {
+ display:block;
+ }
+
+ .wrap .breadcrumb ul li
+ {
+ float: left;
+ background: url(../images/breadcrumb.png) no-repeat 0 5px;
+ padding-left: 15px;
+ margin-left: 15px;
+ font-weight: bold;
+ }
+ .wrap .breadcrumb ul li.last
+ {
+ font-weight: normal;
+ }
+ .wrap .breadcrumb ul li a
+ {
+ /* color: #363534;*/
+ color: #00732F;
+ }
+ .wrap .breadcrumb ul li.first
+ {
+ background-image: none;
+ padding-left: 0;
+ margin-left: 0;
+ }
+ .wrap .content
+ {
+ word-wrap:break-word;
+ }
+ .wrap .content li
+ {
+ padding-left: 12px;
+ background: url(../images/bullet_sq.png) no-repeat 0 5px;
+ font: inherit;
+ /* color: #44a51c;*/
+ margin-bottom: 10px;
+ }
+
+ .wrap .content ol li {
+ background:none;
+ font: inherit;
+ margin-bottom:10px;
+ padding-left: 0px;
+ }
+
+ .wrap .content ol li {
+ list-style-type:decimal;
+ }
+
+ .wrap .content .descr ol li {
+ margin-left: 45px;
+
+ }
+
+ .offline .wrap .content
+ {
+ padding-top: 15px;
+ }
+
+ .header:after, .footer:after, .breadcrumb:after, .wrap .content:after, .group:after
+ {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+ }
+
+ hr
+ {
+ background-color: #E6E6E6;
+ border: 1px solid #E6E6E6;
+ height: 1px;
+ width: 100%;
+ text-align: left;
+ margin: 5px 0px 5px 0px;
+ }
+
+ .content .alignedsummary
+ {
+ margin: 5px;
+ width:100%;
+ }
+
+
+ .toc
+ {
+ float: right;
+ -moz-border-radius: 7px 7px 7px 7px;
+ background-color: #F6F6F6;
+ border: 1px solid #DDDDDD;
+ margin: 0 20px 10px 10px;
+ padding: 20px 15px 20px 20px;
+ height: auto;
+ width: 200px;
+ }
+
+ .toc h3, .generic a
+ {
+ font: 600 12px/1.2 Arial;
+ }
+
+ .wrap .content .toc ul
+ {
+ padding-left: 0px;
+ }
+
+
+ .wrap .content .toc .level2
+ {
+ margin-left: 15px;
+ }
+
+ .wrap .content .toc .level3
+ {
+ margin-left: 30px;
+ }
+
+ .content .toc li
+ {
+ font: normal 10px/1.2 Verdana;
+ background: url(../images/bullet_dn.png) no-repeat 0 5px;
+ }
+
+
+ .generic{
+ max-width:75%;
+ }
+ .generic td{
+ padding:0;
+ }
+
+ .generic .odd .alphaChar{
+ background-color: #F6F6F6;
+ }
+
+ .generic .even .alphaChar{
+ background-color: #FFFFFF;
+ }
+
+ .highlightedCode
+ {
+ margin:10px;
+ }
+
+ .flowList{
+ vertical-align:top;
+ }
+ .alphaChar{
+ width:100%;
+ background-color:#F6F6F6;
+ border:1px solid #E6E6E6;
+ font-size:12pt;
+ padding-left:10px;
+ margin-top:10px;
+ margin-bottom:10px;
+ }
+
+ .flowList dl{
+ }
+ .flowList dd{
+ display:inline-block;
+ margin-left:10px;
+ width:250px;
+ }
+ .wrap .content .flowList p{
+ padding:0px;
+ }
+
+ .relpage
+ {
+ -moz-border-radius: 7px 7px 7px 7px;
+ border: 1px solid #DDDDDD;
+ padding: 25px 25px;
+ clear: both;
+ }
+ .relpage ul
+ {
+ float: none;
+ padding: 15px;
+ }
+ .content .relpage li
+ {
+ font: normal 11px/1.2 Verdana;
+ }
+ h3.fn, span.fn
+ {
+ background-color: #F6F6F6;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #E6E6E6;
+ font-weight: bold;
+ word-spacing:3px;
+ }
+
+ .functionIndex {
+ font-size:12pt;
+ word-spacing:10px;
+ margin-bottom:10px;
+ background-color: #F6F6F6;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #E6E6E6;
+ width:100%;
+ }
+
+ .centerAlign { text-align:center;}
+ .rightAlign {text-align:right;}
+ .leftAlign {text-align:left;}
+ .topAlign{vertical-align:top }
+ .functionIndex a{display:inline-block;}
+
+ /* start index box */
+ .indexbox
+ {
+ width: 100%;
+ display:inline-block;
+ }
+
+ .indexboxcont { display: block; }
+
+ .indexboxbar
+ {
+ border-bottom:1px solid #E5E5E5;
+ margin-bottom: 25px;
+ }
+
+ .indexboxcont .section
+ {
+ display: inline-block;
+ padding:0 2% 0 1%;
+ vertical-align:top;
+ }
+
+ .indexboxcont .section {
+ float: left;
+ }
+
+ .indexboxcont .section p
+ {
+ padding-top: 20px;
+ padding-bottom: 20px;
+ }
+ .indexboxcont .sectionlist
+ {
+ display: inline-block;
+ vertical-align:top;
+ padding: 0;
+ }
+ .indexboxcont .sectionlist ul
+ {
+ margin-bottom: 20px;
+ }
+
+ .indexboxcont .sectionlist ul li
+ {
+ line-height: 12px;
+ }
+
+ .content .indexboxcont li
+ {
+ font: normal 600 13px/1 Verdana;
+ }
+
+ .indexbox a:hover, .indexbox a:visited:hover
+ {
+ color: #4c0033;
+ text-decoration: underline;
+ }
+
+ .indexbox a:visited
+ {
+ color: #00732f;
+ text-decoration: none;
+ }
+
+ .indexbox .indexIcon {
+ width: 11%;
+ }
+
+
+ .indexboxcont:after
+ {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+ }
+
+ body.offline
+ {
+ background-image: none;
+ }
+
+ .offline .footer {
+ margin: 0;
+ }
+ .offline .header
+ {
+ width: 100%;
+ margin: 0;
+ height: auto;
+ background-color: #ffffff;
+ padding: 10px 0 5px 0;
+ overflow: visible;
+ border-bottom: solid #E5E5E5 1px;
+ z-index:1;
+ position:fixed;
+ }
+
+ .offline .header .content
+ {
+ }
+ .offline .header .qtref
+ {
+ color: #00732F;
+ position: static;
+ float: left;
+ margin-left: 5px;
+ font: bold 18px/1 Arial;
+ }
+
+ .offline .header .qtref:visited
+ {
+ color: #00732F;
+ }
+ .offline .header .qtref:hover
+ {
+ color: #00732F;
+ text-decoration:none;
+ }
+ .offline .header .qtref span
+ {
+ background-image: none;
+ text-indent: 0;
+ text-decoration:none;
+ }
+
+ .offline .wrap
+ {
+ margin: 0 5px 0 5px;
+ }
+
+ .offline .wrap .toolbar
+ {
+ display:block;
+ padding-top:5px;
+ }
+
+ .offline .wrap .breadcrumb ul li {
+ font-weight: normal;
+ }
+
+ .offline .wrap .breadcrumb ul li a {
+ /*color: #44a51c;*/
+ }
+
+ .offline .wrap .breadcrumb ul li.last a {
+ /*color: #363534;*/
+ }
+
+
+
+ .narrow .indexboxcont .section {
+ width: 64%;
+ padding-left: 0;
+ }
+
+ .narrow .indexboxcont .sectionlist {
+ width: 32.5%;
+ }
+
+ .header .icon,
+ .sidebar,
+ .feedback,
+ .t_button,
+ .feedback,
+ #feedbackBox,
+ #feedback,
+ #blurpage,
+ .indexbox .indexIcon span,
+ .wrapper .hd,
+ .offline .indexbox .indexIcon,
+ .offline .header #nav-logo,
+ #offlinemenu,
+ #offlinesearch,
+ .offline .header #nav-topright,
+ .offline .header #shortCut ,
+ .offline .wrapper .hd,
+ .offline .wrapper .ft,
+ .offline .sidebar,
+ .offline .wrap .feedback
+ {
+ display:none;
+ }
+
+ /* end offline mode */
+#narrowmenu {
+ display: none;
+ float: right;
+ margin: 15px 40px 0 0;
+ font-size: 11px;
+ }
+
+ .narrow #narrowmenu {
+ display: block;
+ }
+
+ #narrowsearch{
+ display:none;
+ }
+
+ #narrowmenu ul
+ {
+ border-bottom:solid 1px #E5E5E5;
+ border-left:solid 1px #E5E5E5;
+ border-right:solid 1px #E5E5E5;
+ }
+
+ #narrowmenu a {
+ line-height: 1.1;
+ background: url(../images/arrow_down.png) no-repeat 100% 50%;
+ white-space: nowrap;
+ padding: 0 16px 0 5px;
+ }
+
+ #narrowmenu li {
+ margin-left: 20px;
+ }
+
+ #narrowmenu li li {
+ margin: 0 0 5px 0;
+ }
+
+ #narrowmenu li li a {
+ padding: 0;
+ background-image: none;
+ }
+
+ #narrowmenu li,
+ #narrowmenu li ul {
+ background-color: #fff;
+ }
+
+ #narrowmenu li ul {
+ width: auto;
+ padding: 5px;
+ margin-top:-15px;
+ }
+
+ .sf-menu li:hover ul, .sf-menu li.sfHover ul {
+ top: 1.2em;
+ }
+.sf-menu, .sf-menu * {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+.sf-menu {
+ line-height: 1.0;
+}
+.sf-menu ul {
+ position: absolute;
+ top: -999em;
+ width: 10em; /* left offset of submenus need to match (see below) */
+}
+.sf-menu ul li {
+ width: 100%;
+}
+.sf-menu li:hover {
+ visibility: inherit; /* fixes IE7 'sticky bug' */
+}
+.sf-menu li {
+ float: left;
+ position: relative;
+}
+.sf-menu a {
+ display: block;
+ position: relative;
+}
+.sf-menu li:hover ul,
+.sf-menu li.sfHover ul {
+ left: 0;
+ top: 2.5em; /* match top ul list item height */
+ z-index: 99;
+}
+ul.sf-menu li:hover li ul,
+ul.sf-menu li.sfHover li ul {
+ top: -999em;
+}
+ul.sf-menu li li:hover ul,
+ul.sf-menu li li.sfHover ul {
+ left: 10em; /* match ul width */
+ top: 0;
+}
+ul.sf-menu li li:hover li ul,
+ul.sf-menu li li.sfHover li ul {
+ top: -999em;
+}
+ul.sf-menu li li li:hover ul,
+ul.sf-menu li li li.sfHover ul {
+ left: 10em; /* match ul width */
+ top: 0;
+}
+
+}
+/* end of screen media */
+
+/* start of print media */
+
+@media print
+{
+ input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft
+ {
+ display: none;
+ background: none;
+ }
+ .content
+ {
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ background: none;
+ display: block;
+ }
+}
+/* end of print media */
diff --git a/doc/templates/style/narrow.css b/doc/templates/style/narrow.css
new file mode 100644
index 000000000..05159aa56
--- /dev/null
+++ b/doc/templates/style/narrow.css
@@ -0,0 +1,250 @@
+ /* start narrow mode */
+
+ body.narrow
+ {
+ background-image: none;
+ }
+
+ .narrow a {
+ color: #44a51c;
+ }
+
+ .narrow .header, .narrow .header .content, .narrow .footer, .narrow .wrapper {
+ margin: 0 7px;
+ min-width: 300px;
+ }
+
+ .narrow .footer {
+ margin: 0;
+ }
+ .narrow .header
+ {
+ width: 100%;
+ margin: 0;
+ height: auto;
+ background: #fff url(../images/header_bg.png) repeat-x 0 100%;
+ padding: 10px 0 5px 0;
+ overflow: visible;
+ }
+
+ .narrow .header .content
+ {
+ }
+
+ .narrow .header #nav-logo
+ {
+ display: none;
+ }
+
+ .narrow .header .qtref
+ {
+ width: auto;
+ height: auto;
+ color: #363534;
+ position: static;
+ float: left;
+ margin-left: 25px;
+ font: bold 18px/1 Arial;
+ }
+
+ .narrow .header .qtref a
+ {
+ color: #363534;
+ }
+
+ .narrow .header .qtref span
+ {
+ background-image: none;
+ text-indent: 0;
+ }
+
+ .narrow .header #nav-topright
+ {
+ display: none;
+ }
+
+ .narrow .header #shortCut
+ {
+ clear: both;
+ font-weight: normal;
+ position: static;
+ float: left;
+ margin: 15px 0 0 25px;
+ overflow: hidden;
+ padding: 0;
+ height: auto;
+ }
+
+ .narrow .header #shortCut ul
+ {
+ float: none;
+ margin: 0;
+ width: auto;
+ font-size: 11px;
+ }
+
+ .narrow .header #shortCut ul li
+ {
+ background-image: none;
+ }
+
+ .narrow .header #shortCut ul .shortCut-topleft-active,
+ .narrow .header #shortCut ul .shortCut-topleft-inactive
+ {
+ background-image: none;
+ height: auto;
+ padding: 0;
+ width: auto;
+ }
+ .narrow .header #shortCut ul li a
+ {
+ color: #44a51c;
+ }
+
+ .narrow .wrapper .hd
+ {
+ background: url(../images/bg_ul_blank.png) no-repeat 0 0;
+ }
+
+ .narrow .wrapper .bd
+ {
+ background: url(../images/bg_l_blank.png) repeat-y 0 0;
+ }
+
+ .narrow .wrapper .ft
+ {
+ background: url(../images/bg_ll_blank.png) no-repeat 0 0;
+ }
+
+ .narrow .sidebar
+ {
+ display: none;
+ }
+
+ .narrow .wrap
+ {
+ margin: 0 5px 0 5px;
+ }
+
+ .narrow .wrap .toolbar
+ {
+ border-bottom: none;
+ }
+
+ .narrow .wrap .content
+ {
+ padding-top: 15px;
+ }
+
+ .narrow .wrap .feedback
+ {
+ display: none;
+ }
+
+ .narrow .wrap .breadcrumb ul li {
+ font-weight: normal;
+ }
+
+ .narrow .wrap .breadcrumb ul li a {
+ color: #44a51c;
+ }
+
+ .narrow .wrap .breadcrumb ul li.last a {
+ color: #363534;
+ }
+
+ #narrowsearch {
+ display: none;
+ }
+
+ .narrow #narrowsearch {
+ display: block;
+ float: right;
+ margin-right: 25px;
+ _position: relative;
+ }
+
+ .narrow #narrowsearch fieldset {
+ _position: absolute;
+ _margin-top: -1px;
+ }
+
+ .narrow #narrowsearch {
+ background: url("http://doc.qt.nokia.com/prototype/html/images/sprites-combined.png") no-repeat scroll -6px -348px transparent;
+ height: 21px;
+ padding: 2px 0 0 5px;
+ width: 167px;
+ }
+
+ .narrow #narrowsearch input {
+ border: none;
+ font: 13px/1.2 Verdana;
+ height: 19px;
+ outline: none;
+ padding: 0;
+ width: 158px;
+ *border: 1px solid #fff;
+ *height: 17px;
+ _height: 18px;
+ }
+
+ .narrow .indexbox .indexIcon {
+ display: none;
+ }
+
+ .narrow .indexboxcont .section {
+ width: 64%;
+ padding-left: 0;
+ }
+
+ .narrow .indexboxcont .sectionlist {
+ width: 32.5%;
+ }
+
+ #narrowmenu {
+ display: none;
+ float: right;
+ margin: 15px 40px 0 0;
+ font-size: 11px;
+ }
+
+ .narrow #narrowmenu {
+ display: block;
+ }
+
+ #narrowmenu a {
+ line-height: 1.1;
+ background: url(../images/arrow_down.png) no-repeat 100% 50%;
+ white-space: nowrap;
+ padding: 0 16px 0 5px;
+ }
+
+ #narrowmenu li {
+ margin-left: 20px;
+ }
+
+ #narrowmenu li li {
+ margin: 0 0 5px 0;
+ }
+
+ #narrowmenu li li a {
+ padding: 0;
+ background-image: none;
+ }
+
+ #narrowmenu li,
+ #narrowmenu li ul {
+ background-color: #fff;
+ margin-top:-1px;
+ }
+
+ #narrowmenu li ul {
+ width: auto;
+ padding: 5px;
+ }
+
+ .sf-menu li:hover ul, .sf-menu li.sfHover ul {
+ top: 1.2em;
+ }
+
+ /* end narrow mode */
diff --git a/doc/templates/style/style.css b/doc/templates/style/style.css
new file mode 100644
index 000000000..90cfa2c21
--- /dev/null
+++ b/doc/templates/style/style.css
@@ -0,0 +1,1218 @@
+@media screen
+{
+ html
+ {
+ color: #000000;
+ background: #FFFFFF;
+ }
+ body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td
+ {
+ margin: 0;
+ padding: 0;
+ }
+ table
+ {
+ border-collapse: collapse;
+ border-spacing: 0;
+ }
+ fieldset, img
+ {
+ border: 0;
+ }
+ address, caption, cite, code, dfn, em, strong, th, var, optgroup
+ {
+ font-style: inherit;
+ font-weight: inherit;
+ }
+ del, ins
+ {
+ text-decoration: none;
+ }
+ li
+ {
+ list-style: none;
+ }
+ caption, th
+ {
+ text-align: left;
+ }
+ h1, h2, h3, h4, h5, h6
+ {
+ font-size: 100%;
+/* font-weight: normal; */
+ }
+ q:before, q:after
+ {
+ content: '';
+ }
+ abbr, acronym
+ {
+ border: 0;
+ font-variant: normal;
+ }
+ sup
+ {
+ vertical-align: baseline;
+ }
+ sub
+ {
+ vertical-align: baseline;
+ }
+ tt, .qmlreadonly span, .qmldefault span
+ {
+ word-spacing:5px;
+ }
+ .heading
+ {
+ font: normal 600 16px/1.0 Arial;
+ padding-bottom: 15px;
+ }
+ .subtitle
+ {
+ font-size: 13px;
+ }
+ .small-subtitle
+ {
+ font-size: 13px;
+ }
+ legend
+ {
+ color: #000000;
+ }
+ input, button, textarea, select, optgroup, option
+ {
+ font-family: inherit;
+ font-size: inherit;
+ font-style: inherit;
+ font-weight: inherit;
+ }
+ input, button, textarea, select
+ {
+ font-size: 100%;
+ }
+ html
+ {
+ background-color: #e5e5e5;
+ }
+ body
+ {
+ background: #e6e7e8 url(../images/page_bg.png) repeat-x 0 0;
+ font: normal 13px/1.2 Verdana;
+ color: #363534;
+ }
+ strong
+ {
+ font-weight: bold;
+ }
+ em
+ {
+ font-style: italic;
+ }
+ a
+ {
+ color: #00732f;
+ text-decoration: none;
+ }
+ .header, .footer, .wrapper
+ {
+ min-width: 600px;
+ max-width: 1500px;
+ margin: 0 30px;
+ }
+ .wrapper
+ {
+ background: url(../images/bg_r.png) repeat-y 100% 0;
+ }
+ .wrapper .hd
+ {
+ padding-left: 216px;
+ height: 15px;
+ background: url(../images/page.png) no-repeat 0 0;
+ overflow: hidden;
+ }
+ .offline .wrapper .hd
+ {
+ background: url(../images/page.png) no-repeat 0 -15px;
+ }
+ .wrapper .hd span
+ {
+ height: 15px;
+ display: block;
+ overflow: hidden;
+ background: url(../images/page.png) no-repeat 100% -30px;
+ }
+ .wrapper .bd
+ {
+ background: url(../images/bg_l.png) repeat-y 0 0;
+ position: relative;
+ }
+ .offline .wrapper .bd
+ {
+ background: url(../images/bg_l_blank.png) repeat-y 0 0;
+ }
+ .wrapper .ft
+ {
+ padding-left: 216px;
+ height: 15px;
+ background: url(../images/page.png) no-repeat 0 -75px;
+ overflow: hidden;
+ }
+ .offline .wrapper .ft
+ {
+ background: url(../images/page.png) no-repeat 0 -90px;
+ }
+ .wrapper .ft span
+ {
+ height: 15px;
+ display: block;
+ background: url(../images/page.png) no-repeat 100% -60px;
+ overflow: hidden;
+ }
+ .header, .footer
+ {
+ display: block;
+ clear: both;
+ overflow: hidden;
+ }
+ .header
+ {
+ height: 115px;
+ position: relative;
+ }
+ .header .icon
+ {
+ position: absolute;
+ top: 13px;
+ left: 0;
+ }
+ .header .qtref
+ {
+ position: absolute;
+ top: 28px;
+ left: 88px;
+ width: 302px;
+ height: 22px;
+ }
+ .header .qtref span
+ {
+ display: block;
+ width: 302px;
+ height: 22px;
+ text-indent: -999em;
+ background: url(../images/sprites-combined.png) no-repeat -78px -235px;
+ }
+
+ .sidebar
+ {
+ float: left;
+ margin-left: 5px;
+ width: 200px;
+ font-size: 11px;
+ }
+
+ .offline .sidebar, .offline .feedback, .offline .t_button
+ {
+ display: none;
+ }
+
+ .sidebar .searchlabel
+ {
+ padding: 0 0 2px 17px;
+ font: normal bold 11px/1.2 Verdana;
+ }
+
+ .sidebar .search
+ {
+ padding: 0 15px 0 16px;
+ }
+
+ .sidebar .search form
+ {
+ background: url(../images/sprites-combined.png) no-repeat -6px -348px;
+ height:21px;
+ padding:2px 0 0 5px;
+ width:167px;
+ }
+
+ .sidebar .search form input#pageType
+ {
+ width: 158px;
+ height: 19px;
+ padding: 0;
+ border: none;
+ outline: none;
+ font: 13px/1.2 Verdana;
+ }
+
+ .sidebar .box
+ {
+ padding: 17px 15px 5px 16px;
+ }
+
+ .sidebar .box .first
+ {
+ background-image: none;
+ }
+
+ .sidebar .box h2
+ {
+ font: normal 18px/1.2 Arial;
+ padding: 0;
+ min-height: 32px;
+ }
+ .sidebar .box h2 span
+ {
+ overflow: hidden;
+ display: inline-block;
+ }
+ .sidebar .box#lookup h2
+ {
+ background-image: none;
+ }
+ .sidebar #lookup.box h2 span
+ {
+ background: url(../images/sprites-combined.png) no-repeat -6px -311px;
+ width: 27px;
+ height: 35px;
+ margin-right: 13px;
+ }
+ .sidebar .box#topics h2
+ {
+ background-image: none;
+ }
+ .sidebar #topics.box h2 span
+ {
+ background: url(../images/sprites-combined.png) no-repeat -94px -311px;
+ width: 27px;
+ height: 32px;
+ margin-right: 13px;
+ }
+ .sidebar .box#examples h2
+ {
+ background-image: none;
+ }
+ .sidebar #examples.box h2 span
+ {
+ background: url(../images/sprites-combined.png) no-repeat -48px -311px;
+ width: 30px;
+ height: 31px;
+ margin-right: 9px;
+ }
+
+ .sidebar .box .list
+ {
+ display: block;
+ max-height:200px;
+ overflow-y:auto;
+ overflow-x:none;
+ }
+ .sidebar .box .live
+ {
+ display: none;
+ height: 100px;
+ overflow: auto;
+ }
+ .list li a:hover, .live li a:hover
+ {
+ text-decoration: underline;
+ }
+ .sidebar .box ul
+ {
+ padding:10px;
+ }
+ .sidebar .box ul li
+ {
+ padding-left: 12px;
+ background: url(../images/bullet_gt.png) no-repeat 0 5px;
+ margin-bottom: 5px;
+ }
+ .sidebar .bottombar
+ {
+ background: url(../images/box_bg.png) repeat-x 0 bottom;
+ }
+ .wrap
+ {
+ margin: 0 5px 0 208px;
+ overflow: visible;
+ }
+ .offline .wrap
+ {
+ margin: 0 5px 0 5px;
+ }
+ .wrap .toolbar
+ {
+ background-color: #fafafa;
+ border-bottom: 1px solid #d1d1d1;
+ height: 20px;
+ position: relative;
+ }
+ .wrap .toolbar .toolblock
+ {
+ position: absolute;
+ }
+ .wrap .toolbar .breadcrumb
+ {
+ font-size: 11px;
+ line-height: 1;
+ padding: 0 0 10px 21px;
+ height: 10px;
+ }
+ .wrap .toolbar .toolbuttons
+ {
+ padding: 0 0 10px 21px;
+ right: 5px;
+ vertical-align: middle;
+ overflow: hidden;
+ }
+ .wrap .toolbar .toolbuttons .active
+ {
+ color: #00732F;
+ }
+ .wrap .toolbar .toolbuttons ul
+ {
+ float: right;
+ }
+ .wrap .toolbar .toolbuttons li
+ {
+ float: left;
+ text-indent: -10px;
+ margin-top: -5px;
+ margin-right: 15px;
+ font-weight: bold;
+ color: #B0ADAB;
+ }
+
+ .toolbuttons #print
+ {
+ border-left: 1px solid #c5c4c4;
+ margin-top: 0;
+ padding-left: 7px;
+ text-indent: 0;
+ }
+ .toolbuttons #print a
+ {
+ width: 16px;
+ height: 16px;
+ }
+
+ .toolbuttons #print a span
+ {
+ width: 16px;
+ height: 16px;
+ text-indent: -999em;
+ display: block;
+ overflow: hidden;
+ background: url(../images/sprites-combined.png) no-repeat -137px -311px;
+ }
+
+ .toolbuttons #smallA
+ {
+ font-size: 10pt;
+ }
+ .toolbuttons #medA
+ {
+ font-size: 12pt;
+ }
+ .toolbuttons #bigA
+ {
+ font-size: 14pt;
+ margin-right: 7px;
+ }
+
+ #smallA:hover, #medA:hover, #bigA:hover
+ {
+ color: #00732F;
+ }
+
+ .offline .wrap .breadcrumb
+ {
+ }
+
+ .wrap .breadcrumb ul
+ {
+ }
+ .wrap .breadcrumb ul li
+ {
+ float: left;
+ background: url(../images/breadcrumb.png) no-repeat 0 3px;
+ padding-left: 15px;
+ margin-left: 15px;
+ font-weight: bold;
+ }
+ .wrap .breadcrumb ul li.last
+ {
+ font-weight: normal;
+ }
+ .wrap .breadcrumb ul li a
+ {
+ color: #363534;
+ }
+ .wrap .breadcrumb ul li.first
+ {
+ background-image: none;
+ padding-left: 0;
+ margin-left: 0;
+ }
+ .wrap .content
+ {
+ padding: 30px;
+ word-wrap: break-word;
+ }
+
+ .wrap .content li
+ {
+ padding-left: 12px;
+ background: url(../images/bullet_sq.png) no-repeat 0 5px;
+ font: normal 400 10pt/1 Verdana;
+ /* color: #44a51c;*/
+ margin-bottom: 10px;
+ }
+ .content li:hover
+ {
+ /* text-decoration: underline;*/
+ }
+
+ .wrap .content ol li {
+ background:none;
+ font: inherit;
+ margin-bottom:10px;
+ padding-left: 0px
+ }
+
+ .wrap .content ol li {
+ list-style-type:decimal;
+ }
+
+ .wrap .content .descr ol li {
+ margin-left: 45px;
+ }
+
+ .wrap .content {
+ padding-top: 15px;
+ }
+
+ .wrap .content ol img {
+ vertical-align: middle;
+ }
+ .wrap .content ul img {
+ vertical-align: middle;
+ }
+
+ .wrap .content h1
+ {
+ font: 600 18px/1.2 Arial;
+ }
+ .wrap .content h2
+ {
+ font: 600 16px/1.2 Arial;
+ }
+ .wrap .content h3
+ {
+ font: 600 14px/1.2 Arial;
+ }
+ .wrap .content p
+ {
+ line-height: 20px;
+ padding: 5px;
+ }
+ .wrap .content table p
+ {
+ line-height: 20px;
+ padding: 0px;
+ }
+ .wrap .content ul
+ {
+ padding-left: 25px;
+ padding-top: 10px;
+ }
+ a:hover
+ {
+ color: #4c0033;
+ text-decoration: underline;
+ }
+ .content a:visited
+ {
+ color: #4c0033;
+ text-decoration: none;
+ }
+ .content a:visited:hover
+ {
+ color: #4c0033;
+ text-decoration: underline;
+ } .footer
+ {
+ min-height: 100px;
+ color: #797775;
+ font: normal 9px/1 Verdana;
+ text-align: center;
+ padding-top: 40px;
+ background-color: #E6E7E8;
+ margin: 0;
+ }
+ .feedback
+ {
+ float: none;
+ position: absolute;
+ right: 15px;
+ bottom: 10px;
+ font: normal 8px/1 Verdana;
+ color: #B0ADAB;
+ }
+ .feedback:hover
+ {
+ float: right;
+ font: normal 8px/1 Verdana;
+ color: #00732F;
+ text-decoration: underline;
+ }
+ .header:after, .footer:after, .breadcrumb:after, .wrap .content:after, .group:after
+ {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+ }
+ #nav-topright
+ {
+ height: 70px;
+ }
+
+ #nav-topright ul
+ {
+ list-style-type: none;
+ float: right;
+ width: 370px;
+ margin-top: 11px;
+ }
+
+ #nav-topright li
+ {
+ display: inline-block;
+ margin-right: 20px;
+ float: left;
+ }
+
+ #nav-topright li.nav-topright-last
+ {
+ margin-right: 0;
+ }
+
+ #nav-topright li a
+ {
+ background: transparent url(../images/sprites-combined.png) no-repeat;
+ height: 18px;
+ display: block;
+ overflow: hidden;
+ text-indent: -9999px;
+ }
+
+ #nav-topright li.nav-topright-home a
+ {
+ width: 65px;
+ background-position: -2px -91px;
+ }
+
+ #nav-topright li.nav-topright-home a:hover
+ {
+ background-position: -2px -117px;
+ }
+
+
+ #nav-topright li.nav-topright-dev a
+ {
+ width: 30px;
+ background-position: -76px -91px;
+ }
+
+ #nav-topright li.nav-topright-dev a:hover
+ {
+ background-position: -76px -117px;
+ }
+
+
+ #nav-topright li.nav-topright-labs a
+ {
+ width: 40px;
+ background-position: -114px -91px;
+ }
+
+ #nav-topright li.nav-topright-labs a:hover
+ {
+ background-position: -114px -117px;
+ }
+
+ #nav-topright li.nav-topright-doc a
+ {
+ width: 32px;
+ background-position: -162px -91px;
+ }
+
+ #nav-topright li.nav-topright-doc a:hover, #nav-topright li.nav-topright-doc-active a
+ {
+ background-position: -162px -117px;
+ }
+
+ #nav-topright li.nav-topright-blog a
+ {
+ width: 40px;
+ background-position: -203px -91px;
+ }
+
+ #nav-topright li.nav-topright-blog a:hover, #nav-topright li.nav-topright-blog-active a
+ {
+ background-position: -203px -117px;
+ }
+
+ #nav-topright li.nav-topright-shop a
+ {
+ width: 40px;
+ background-position: -252px -91px;
+ }
+
+ #nav-topright li.nav-topright-shop a:hover, #nav-topright li.nav-topright-shop-active a
+ {
+ background-position: -252px -117px;
+ }
+
+ #nav-logo
+ {
+ background: transparent url(../images/sprites-combined.png ) no-repeat 0 -225px;
+ left: -3px;
+ position: absolute;
+ width: 75px;
+ height: 75px;
+ top: 13px;
+ }
+ #nav-logo a
+ {
+ width: 75px;
+ height: 75px;
+ display: block;
+ text-indent: -9999px;
+ overflow: hidden;
+ }
+
+
+ .shortCut-topleft-inactive
+ {
+ padding-left: 3px;
+ padding-right: 3px;
+ background: transparent url( ../images/sprites-combined.png) no-repeat 0px -58px;
+ height: 20px;
+ }
+ .shortCut-topleft-inactive span
+ {
+ font-variant: normal;
+ }
+ .shortCut-topleft-inactive span a:hover, .shortCut-topleft-active a:hover
+ {
+ text-decoration:none;
+ }
+ #shortCut
+ {
+ padding-top: 10px;
+ font-weight: bolder;
+ color: #b0adab;
+ }
+ #shortCut ul
+ {
+ list-style-type: none;
+ float: left;
+ margin-left: 100px;
+ }
+ #shortCut li
+ {
+ display: inline-block;
+ margin-right: 25px;
+ float: left;
+ white-space: nowrap;
+ }
+ #shortCut li a
+ {
+ color: #b0adab;
+ }
+ #shortCut li a:hover
+ {
+ color: #44a51c;
+ }
+
+ hr
+ {
+ background-color: #E6E6E6;
+ border: 1px solid #E6E6E6;
+ height: 1px;
+ width: 100%;
+ text-align: left;
+ margin: 15px 0px 15px 0px;
+ }
+
+ .content .alignedsummary
+ {
+ margin: 15px;
+ }
+ pre
+ {
+ border: 1px solid #DDDDDD;
+ margin: 0 20px 10px 10px;
+ padding: 20px 15px 20px 20px;
+ overflow-x: auto;
+ }
+ table, pre
+ {
+ -moz-border-radius: 7px 7px 7px 7px;
+ background-color: #F6F6F6;
+ border: 1px solid #E6E6E6;
+ border-collapse: separate;
+ font-size: 11px;
+ /*min-width: 395px;*/
+ margin-bottom: 25px;
+ display: inline-block;
+ }
+ thead
+ {
+ margin-top: 5px;
+ font:600 12px/1.2 Arial;
+ }
+ th
+ {
+ padding: 5px 15px 5px 15px;
+ background-color: #E1E1E1;
+ /* border-bottom: 1px solid #E6E6E6;*/
+ border-left: 1px solid #E6E6E6;
+ /* border-right: 1px solid #E6E6E6;*/
+ }
+ td
+ {
+ padding: 3px 15px 3px 20px;
+ /* border-left: 1px solid #E6E6E6;
+ border-right: 1px solid #E6E6E6;*/
+ }
+ tr.odd td:hover, tr.even td:hover
+ {
+ /* border-right: 1px solid #C3C3C3;
+ border-left: 1px solid #C3C3C3;*/
+ }
+
+ td.rightAlign
+ {
+ padding: 3px 15px 3px 10px;
+ }
+ table tr.odd
+ {
+ border-left: 1px solid #E6E6E6;
+ background-color: #F6F6F6;
+ color: #66666E;
+ }
+ table tr.even
+ {
+ border-left: 1px solid #E6E6E6;
+ background-color: #ffffff;
+ color: #66666E;
+ }
+ table tr.odd td:hover, table tr.even td:hover
+ {
+ background-color: #E6E6E6;
+ }
+
+ span.comment
+ {
+ color: #8B0000;
+ font-style: italic;
+ }
+ span.string, span.char
+ {
+ color: #254117;
+ }
+
+ .qmltype
+ {
+ text-align: center;
+ font-size: 160%;
+ }
+ .qmlreadonly
+ {
+ float: right;
+ color: #254117;
+ }
+
+ .qmldefault
+ {
+ float: right;
+ color: red;
+ }
+
+ .qmldoc
+ {
+ }
+
+ *.qmlitem p
+ {
+ }
+
+ #feedbackBox
+ {
+ display: none;
+ -moz-border-radius: 7px 7px 7px 7px;
+ border: 1px solid #DDDDDD;
+ position: fixed;
+ top: 100px;
+ left: 33%;
+ height: 190px;
+ width: 400px;
+ padding: 5px;
+ background-color: #e6e7e8;
+ z-index: 4;
+ }
+ #feedcloseX
+ {
+ display: inline;
+ padding: 5px 5px 0 0;
+ margin-bottom: 3px;
+ color: #363534;
+ font-weight: 600;
+ float: right;
+ text-decoration: none;
+ }
+
+ #feedbox
+ {
+ display: inline;
+ width: 370px;
+ height: 120px;
+ margin: 0px 25px 10px 15px;
+ }
+ #feedsubmit
+ {
+ display: inline;
+ float: right;
+ margin: 4px 32px 0 0;
+ }
+ #blurpage
+ {
+ display: none;
+ position: fixed;
+ float: none;
+ top: 0px;
+ left: 0px;
+ right: 0px;
+ bottom: 0px;
+ background: transparent url(../images/feedbackground.png) 0 0;
+ z-index: 3;
+ }
+ .toc
+ {
+ float: right;
+ -moz-border-radius: 7px 7px 7px 7px;
+ background-color: #F6F6F6;
+ border: 1px solid #DDDDDD;
+ margin: 0 20px 10px 10px;
+ padding: 20px 15px 20px 20px;
+ height: auto;
+ width: 200px;
+ }
+
+ .toc h3, .generic a
+ {
+ font: 600 12px/1.2 Arial;
+ }
+
+ .generic{
+ max-width:75%;
+ }
+ .generic td{
+ padding:0;
+ }
+
+ .generic .odd .alphaChar{
+ background-color: #F6F6F6;
+ }
+
+ .generic .even .alphaChar{
+ background-color: #FFFFFF;
+ }
+
+ .alignedsummary{}
+ .propsummary{}
+ .memItemLeft{}
+ .memItemRight{}
+ .bottomAlign{}
+ .highlightedCode
+ {
+ margin:10px;
+ }
+ .LegaleseLeft{}
+ .valuelist{}
+ .annotated{}
+ .obsolete{}
+ .compat{}
+ .flags{}
+ .qmlsummary{}
+ .qmlitem{}
+ .qmlproto{}
+ .qmlname{}
+ .qmlreadonly{}
+ .qmldefault{}
+ .qmldoc{}
+ .qt-style{}
+ .redFont{}
+ code{}
+
+ .wrap .content .toc ul
+ {
+ padding-left: 0px;
+ }
+
+
+ .wrap .content .toc .level2
+ {
+ margin-left: 15px;
+ }
+
+ .wrap .content .toc .level3
+ {
+ margin-left: 30px;
+ }
+
+ .content .toc li
+ {
+ font: normal 10px/1.2 Verdana;
+ background: url(../images/bullet_dn.png) no-repeat 0 5px;
+ }
+
+ .relpage
+ {
+ -moz-border-radius: 7px 7px 7px 7px;
+ border: 1px solid #DDDDDD;
+ padding: 25px 25px;
+ clear: both;
+ }
+ .relpage ul
+ {
+ float: none;
+ padding: 15px;
+ }
+ .content .relpage li
+ {
+ font: normal 11px/1.2 Verdana;
+ }
+ h3.fn, span.fn
+ {
+ background-color: #F6F6F6;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #E6E6E6;
+ font-weight: bold;
+ word-spacing:3px;
+ }
+
+ .functionIndex {
+ font-size:12pt;
+ word-spacing:10px;
+ margin-bottom:10px;
+ background-color: #F6F6F6;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #E6E6E6;
+ width:100%;
+ }
+
+ .centerAlign
+ {
+ text-align:center;
+ }
+
+ .rightAlign
+ {
+ text-align:right;
+ }
+
+
+ .leftAlign
+ {
+ text-align:left;
+ }
+
+ .topAlign{
+ vertical-align:top
+ }
+
+ .functionIndex a{
+ display:inline-block;
+ }
+
+ /* start index box */
+ .indexbox
+ {
+ width: 100%;
+ display:inline-block;
+ }
+
+ .indexboxcont
+ {
+ display: block;
+ /* overflow: hidden;*/
+ }
+
+ .indexboxbar
+ {
+ background: transparent url(../images/horBar.png ) repeat-x left bottom;
+ margin-bottom: 25px;
+ /* background-image: none;
+ border-bottom: 1px solid #e2e2e2;*/
+ }
+
+ .indexboxcont .section
+ {
+ display: inline-block;
+ width: 49%;
+ *width:42%;
+ _width:42%;
+ padding:0 2% 0 1%;
+ vertical-align:top;
+
+}
+
+ .indexboxcont .indexIcon
+ {
+ width: 11%;
+ *width:18%;
+ _width:18%;
+ overflow:hidden;
+
+}
+
+.indexboxcont .section {
+ float: left;
+}
+
+ .indexboxcont .section p
+ {
+ padding-top: 20px;
+ padding-bottom: 20px;
+ }
+ .indexboxcont .sectionlist
+ {
+ display: inline-block;
+ vertical-align:top;
+ width: 32.5%;
+ padding: 0;
+ }
+ .indexboxcont .sectionlist ul
+ {
+ margin-bottom: 20px;
+ }
+
+ .indexboxcont .sectionlist ul li
+ {
+ line-height: 12px;
+ }
+
+ .content .indexboxcont li
+ {
+ font: normal 600 13px/1 Verdana;
+ }
+
+ .indexbox a:hover, .indexbox a:visited:hover
+ {
+ color: #4c0033;
+ text-decoration: underline;
+ }
+
+ .indexbox a:visited
+ {
+ color: #00732f;
+ text-decoration: none;
+ }
+
+ .indexbox .indexIcon {
+ width: 11%;
+ }
+
+
+ .indexbox .indexIcon span
+ {
+ display: block;
+ }
+
+ .indexbox.guide .indexIcon span
+ {
+ width: 96px;
+ height: 137px;
+ background: url(../images/sprites-combined.png) no-repeat -5px -376px;
+ padding: 0;
+ }
+
+ .indexbox.tools .indexIcon span
+ {
+ width: 115px;
+ height: 137px;
+ background: url(../images/sprites-combined.png) no-repeat -111px -376px;
+ padding: 0;
+ }
+ .indexboxcont:after
+ {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+ }
+
+.sidebar .search form input.loading
+{
+ background:url("../images/spinner.gif") no-repeat scroll right center transparent;
+}
+
+ /* end of screen media */
+
+.flowList{
+vertical-align:top;
+}
+.alphaChar{
+width:100%;
+background-color:#F6F6F6;
+border:1px solid #E6E6E6;
+font-size:12pt;
+padding-left:10px;
+margin-top:10px;
+margin-bottom:10px;
+}
+
+.flowList dl{
+}
+.flowList dd{
+display:inline-block;
+margin-left:10px;
+width:250px;
+}
+.wrap .content .flowList p{
+padding:0px;
+}
+pre.highlightedCode {
+ display: block;
+ overflow:hidden;
+}
+
+}
+/* end of screen media */
+
+/* start of print media */
+
+@media print
+{
+ input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft
+ {
+ display: none;
+ background: none;
+ }
+ .content
+ {
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ background: none;
+ display: block;
+ }
+}
+/* end of print media */
diff --git a/doc/templates/style/style_ie6.css b/doc/templates/style/style_ie6.css
new file mode 100644
index 000000000..16fb8505d
--- /dev/null
+++ b/doc/templates/style/style_ie6.css
@@ -0,0 +1,54 @@
+.indexbox, .indexboxcont, .group {
+ zoom: 1;
+ height: 1%;
+}
+
+.sidebar {
+ margin-left: 3px;
+ width: 199px;
+ overflow: hidden;
+}
+
+.sidebar .search form {
+ position: relative;
+}
+
+.sidebar .search form fieldset {
+ position: absolute;
+ margin-top: -1px;
+}
+
+.sidebar .search form input#searchstring {
+ border: 1px solid #fff;
+ height: 18px;
+}
+
+.wrap {
+ zoom: 1;
+}
+
+.content,
+.toolbar {
+ zoom: 1;
+ margin-left: -3px;
+ position: relative;
+}
+
+.indexbox {
+ clear: both;
+}
+
+.indexboxcont .section {
+ zoom: 1;
+ float: left;
+}
+
+.indexboxcont .sectionlist {
+ zoom: 1;
+ float: left;
+}
+
+.wrap .toolbar .toolbuttons li {
+ text-indent: 0;
+ margin-right: 8px;
+} \ No newline at end of file
diff --git a/doc/templates/style/style_ie7.css b/doc/templates/style/style_ie7.css
new file mode 100644
index 000000000..afbff5f88
--- /dev/null
+++ b/doc/templates/style/style_ie7.css
@@ -0,0 +1,19 @@
+.indexbox, .indexboxcont, .group {
+ min-height: 1px;
+}
+
+.sidebar .search form input#searchstring {
+ border: 1px solid #fff;
+ height: 17px;
+}
+
+
+.indexboxcont .section {
+ zoom: 1;
+ float: left;
+}
+
+.indexboxcont .sectionlist {
+ zoom: 1;
+ float: left;
+}
diff --git a/doc/templates/style/style_ie8.css b/doc/templates/style/style_ie8.css
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/doc/templates/style/style_ie8.css
diff --git a/doc/templates/style/superfish.css b/doc/templates/style/superfish.css
new file mode 100644
index 000000000..0cf0f7dc9
--- /dev/null
+++ b/doc/templates/style/superfish.css
@@ -0,0 +1,51 @@
+.sf-menu, .sf-menu * {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+.sf-menu {
+ line-height: 1.0;
+}
+.sf-menu ul {
+ position: absolute;
+ top: -999em;
+ width: 10em; /* left offset of submenus need to match (see below) */
+}
+.sf-menu ul li {
+ width: 100%;
+}
+.sf-menu li:hover {
+ visibility: inherit; /* fixes IE7 'sticky bug' */
+}
+.sf-menu li {
+ float: left;
+ position: relative;
+}
+.sf-menu a {
+ display: block;
+ position: relative;
+}
+.sf-menu li:hover ul,
+.sf-menu li.sfHover ul {
+ left: 0;
+ top: 2.5em; /* match top ul list item height */
+ z-index: 99;
+}
+ul.sf-menu li:hover li ul,
+ul.sf-menu li.sfHover li ul {
+ top: -999em;
+}
+ul.sf-menu li li:hover ul,
+ul.sf-menu li li.sfHover ul {
+ left: 10em; /* match ul width */
+ top: 0;
+}
+ul.sf-menu li li:hover li ul,
+ul.sf-menu li li.sfHover li ul {
+ top: -999em;
+}
+ul.sf-menu li li li:hover ul,
+ul.sf-menu li li li.sfHover ul {
+ left: 10em; /* match ul width */
+ top: 0;
+}
diff --git a/doc/templates/style/superfish_skin.css b/doc/templates/style/superfish_skin.css
new file mode 100644
index 000000000..8d84827c4
--- /dev/null
+++ b/doc/templates/style/superfish_skin.css
@@ -0,0 +1,83 @@
+
+/*** DEMO SKIN ***/
+.sf-menu {
+ float: left;
+ margin-bottom: 1em;
+}
+.sf-menu a {
+ border-left: 1px solid #fff;
+ border-top: 1px solid #CFDEFF;
+ padding: .75em 1em;
+ text-decoration:none;
+}
+.sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/
+ color: #13a;
+}
+.sf-menu li {
+ background: #BDD2FF;
+}
+.sf-menu li li {
+ background: #AABDE6;
+}
+.sf-menu li li li {
+ background: #9AAEDB;
+}
+.sf-menu li:hover, .sf-menu li.sfHover,
+.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
+ background: #CFDEFF;
+ outline: 0;
+}
+
+/*** arrows **/
+.sf-menu a.sf-with-ul {
+ padding-right: 2.25em;
+ min-width: 1px; /* trigger IE7 hasLayout so spans position accurately */
+}
+.sf-sub-indicator {
+ position: absolute;
+ display: block;
+ right: .75em;
+ top: 1.05em; /* IE6 only */
+ width: 10px;
+ height: 10px;
+ text-indent: -999em;
+ overflow: hidden;
+ background: url('../images/arrows-ffffff.png') no-repeat -10px -100px; /* 8-bit indexed alpha png. IE6 gets solid image only */
+}
+a > .sf-sub-indicator { /* give all except IE6 the correct values */
+ top: .8em;
+ background-position: 0 -100px; /* use translucent arrow for modern browsers*/
+}
+/* apply hovers to modern browsers */
+a:focus > .sf-sub-indicator,
+a:hover > .sf-sub-indicator,
+a:active > .sf-sub-indicator,
+li:hover > a > .sf-sub-indicator,
+li.sfHover > a > .sf-sub-indicator {
+ background-position: -10px -100px; /* arrow hovers for modern browsers*/
+}
+
+/* point right for anchors in subs */
+.sf-menu ul .sf-sub-indicator { background-position: -10px 0; }
+.sf-menu ul a > .sf-sub-indicator { background-position: 0 0; }
+/* apply hovers to modern browsers */
+.sf-menu ul a:focus > .sf-sub-indicator,
+.sf-menu ul a:hover > .sf-sub-indicator,
+.sf-menu ul a:active > .sf-sub-indicator,
+.sf-menu ul li:hover > a > .sf-sub-indicator,
+.sf-menu ul li.sfHover > a > .sf-sub-indicator {
+ background-position: -10px 0; /* arrow hovers for modern browsers*/
+}
+
+/*** shadows for all but IE6 ***/
+.sf-shadow ul {
+ background: url('../images/shadow.png') no-repeat bottom right;
+ padding: 0 8px 9px 0;
+ -moz-border-radius-bottomleft: 17px;
+ -moz-border-radius-topright: 17px;
+ -webkit-border-top-right-radius: 17px;
+ -webkit-border-bottom-left-radius: 17px;
+}
+.sf-shadow ul.sf-shadow-off {
+ background: transparent;
+}
diff --git a/doc/tutorial.qdoc b/doc/tutorial.qdoc
new file mode 100644
index 000000000..4b9c6109b
--- /dev/null
+++ b/doc/tutorial.qdoc
@@ -0,0 +1,83 @@
+/*!
+ \contentspage index.html
+ \previouspage ifw-tools.html
+ \page ifw-tutorial.html
+ \nextpage ifw-online-installers.html
+
+ \title Tutorial
+
+ This tutorial is designed to guide through the first steps to create
+ a simple installer for a small project.
+
+ \section1 Directory structure
+
+ First, we create a directory structure which will reflect the design
+ of the installer as well as allow extensibility.
+
+ In this example, it will look like this:
+
+ \code
+ - tutorial
+ - config
+ - packages
+ - com.vendor.product
+ - data
+ - meta
+ \endcode
+
+ \section1 Global configuration
+
+ Inside the \a config directory we create a config.xml file, which contains
+ the following data:
+
+ \quotefile ../examples/tutorial/config/config.xml
+
+ The \a license section describes the location of the license file. This
+ license will be displayed when the user starts the installer.
+
+ \quotefile ../examples/tutorial/config/license.txt
+
+ \note If you aim for installers on multiple platforms including Windows
+ please make sure that the lineendings of the license file is in CRLF
+ format. While the linux version manages to display windows lineending
+ correctly, this does not apply the other way around.
+
+ \section1 Meta package information
+
+ In this easy scenario the installer handles only one component, which is
+ named \a{com.vendor.product}. The installer needs to know a couple of
+ information about this component, which is stored in a file called
+ \a{packages.xml} inside the meta directory. It has the following shape:
+
+ \quotefile ../examples/tutorial/packages/com.vendor.product/meta/packages.xml
+
+ \section1 Installer content
+
+ Content to be installed is stored inside the data directory of each
+ component. As in this tutorial there is only one component, we place the
+ data into \a{packages/com.vendor.product/data}. The example already contains
+ a file for testing purposes, but you can place basically anything inside
+ there. For packaging rules and options, please read the
+ \l{Contents of the data directory}{detailed information}.
+
+ \section1 Creating the installer binary
+
+ Now everything is prepared to create the first installer. Switch to the
+ \a tutorial directory in your command line. Enter the following command:
+
+ \section2 Windows
+ \code
+ <location-of-the-ifw>\binarycreator.exe -t <location-of-the-ifw>\installerbase.exe -p packages -c config YourInstaller.exe com.vendor.product
+ \endcode
+
+ \section2 Linux / Mac OS-X
+ \code
+ <location-of-the-ifw>/binarycreator -t <location-of-the-ifw>/installerbase -p packages -c config YourInstaller com.vendor.product
+ \endcode
+
+ Afterwards the installer has been created in the current directory and you
+ ship those binaries.
+
+*/
+
+
diff --git a/examples/RepositoryExchangeTutorial.txt b/examples/RepositoryExchangeTutorial.txt
new file mode 100644
index 000000000..280e20ac7
--- /dev/null
+++ b/examples/RepositoryExchangeTutorial.txt
@@ -0,0 +1,11 @@
+To exchange an online repository during update process do the following steps.
+
+1. navigate to the source folder of installerbase ( from trunk this is installerbuilder/installerbase )
+2. open the installerbase.qrc and add an entry pointing to overrideconfig.xml
+3. copy the config.xml file in the installerbase source folder rename it to overrideconfig.xml
+4. rebuild installerbase
+
+The override config is now shipped with the installerbase.exe and always overrides the old given config until
+a new installerbase.exe is shipped without this resource.
+
+
diff --git a/examples/config/config.xml b/examples/config/config.xml
new file mode 100644
index 000000000..6da2208ec
--- /dev/null
+++ b/examples/config/config.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>Test App</Name>
+ <Version>1.0.0</Version>
+ <Title>Test App_Hurra</Title>
+ <MaintenanceTitle>Test App_MAN</MaintenanceTitle>
+ <Publisher>Nokia</Publisher>
+ <ProductUrl>http://qt.nokia.com</ProductUrl>
+ <Icon>qticon</Icon>
+ <Watermark>watermark.png</Watermark>
+ <UninstallerName>TestAppUninstaller</UninstallerName>
+ <RemoteRepositories>
+ <Repository>
+ <Url>http://www.kdab.com/~bjoern/sha1repo</Url>
+ <Required>false</Required>
+ </Repository>
+ </RemoteRepositories>
+
+ <!-- @homeDir@ and @rootDir@ are some of the supported vars -->
+ <TargetDir>@homeDir@/testinstall</TargetDir>
+ <AdminTargetDir>/opt</AdminTargetDir>
+</Installer>
diff --git a/examples/config/license.txt b/examples/config/license.txt
new file mode 100644
index 000000000..a55990fe3
--- /dev/null
+++ b/examples/config/license.txt
@@ -0,0 +1,84 @@
+For individuals and/or legal entities resident in the American Continent (including those resident in Canada, South America, and the United States of America), the applicable licensing terms are specified under the heading "Trolltech Technology Preview License
+Agreement: American Continent".
+
+For individuals and/or legal entities not resident in the American Continent, the applicable licensing terms are specified under the heading "Trolltech Technology Preview License Agreement: Norway".
+
+TROLLTECH TECHNOLOGY PREVIEW LICENSE AGREEMENT: AMERICAN CONTINENT Agreement version 2.0
+IMPORTANT-READ CAREFULLY:
+
+1. This Trolltech Technology Preview License Agreement ("Agreement") is a legal agreement between you (either an individual or a legal entity) and Trolltech, Inc. ("Trolltech"), and pertains to the Trolltech software product(s) accompanying this Agreement, which include(s) computer software and may include "online" or electronic documentation, associated media, and printed materials, including the source code, example programs and the documentation ("Licensed Software").
+
+2. The Licensed Software is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. Trolltech retains all rights not expressly granted. No title, property rights or copyright in the Licensed Software or in any modifications to the Licensed Software shall pass to the Licensee under any circumstances. The Licensed Software is licensed, not sold.
+
+3. By installing, copying, or otherwise using the Licensed Software, Licensee agrees to be bound by the terms of this Agreement. If Licensee does not agree to the terms of this Agreement, Licensee should not install, copy, or otherwise use the Licensed Software.
+
+4. Upon Licensee's acceptance of the terms and conditions of this Agreement, Trolltech grants Licensee the right to use the Licensed Software in the manner provided below.
+
+5. Trolltech grants to Licensee as an individual a personal, non-exclusive, non-transferable license to make and use copies of the Licensed Software for the sole purpose of evaluating and testing the Licensed Software and/or providing feedback to Trolltech. Licensee may install copies of the Licensed Software on an unlimited number of computers provided that Licensee is the only individual using the Licensed Software. If Licensee is an entity, Trolltech grants Licensee the right to designate one, and only one, individual within Licensee's organization who shall have the sole right to use the Licensed Software in the manner provided in this Agreement. Licensee may, at any time, but not more frequently than once every six (6) months, designate another individual to replace the current designated user by notifying Trolltech, so long as there is no more than one (1) designated user at any given time
+
+6. Licensee may not loan, rent, lease, or license the Licensed Software or any copy of it. Licensee may not alter or remove any details of ownership, copyright, trademark or other property right connected with the Licensed Software. Licensee may not modify or distribute the Licensed Software. Licensee may not distribute any software statically or dynamically linked with the Licensed Software.
+
+7. This Licensed Software is time-limited. All rights granted to Licensee in this Agreement will be void three (3) months after Licensee received the Licensed Software.
+
+8. The Licensed Software may provide links to third party libraries or code (collectively "Third Party Libraries") to implement various functions. Third Party Libraries do not comprise part of the Licensed Software. In some cases, access to Third Party Libraries may be included along with the Licensed Software delivery as a convenience for development and testing only. Such source code and libraries as are or may be listed in the ".../src/3rdparty" source tree delivered with the Licensed Software, as may be amended from time to time, do not comprise the Licensed Software. Licensee acknowledges (1) that some Third Party Libraries may require additional licensing of copyright and patents from the owners of such, and (2) that distribution of any of the Licensed Software referencing any portion of a Third Party Library may require appropriate licensing from such third parties.
+
+9. Pre-Release Code, Non-Commercial Use: The Licensed Software contains Pre-release Code that is not at the level of performance and compatibility of a final, generally available, product offering. The Licensed Software may not operate correctly and may be substantially modified prior to the first commercial shipment, if any. Trolltech is not obligated to make this or any later version of the Licensed Software commercially available. The License Software is "Not for Commercial Use" and may only be used for the purposes described in Section 5. You may not use the Licensed Software in a live operating environment where it may be relied upon to perform in the same manner as a commercially released product or with data that has not been sufficiently backed up.
+
+10. WARRANTY DISCLAIMER: THE LICENSED SOFTWARE IS LICENSED TO LICENSEE "AS IS". TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, TROLLTECH ON BEHALF OF ITSELF AND ITS SUPPLIERS, DISCLAIMS ALL WARRANTIES AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT WITH REGARD TO THE LICENSED SOFTWARE.
+
+11. LIMITATION OF LIABILITY: IF, TROLLTECH'S WARRANTY DISCLAIMER NOTWITHSTANDING, TROLLTECH IS HELD LIABLE TO LICENSEE, WHETHER IN CONTRACT, TORT OR ANY OTHER LEGAL THEORY, BASED ON THE LICENSED SOFTWARE, TROLLTECH'S ENTIRE LIABILITY TO LICENSEE AND LICENSEE'S EXCLUSIVE REMEDY SHALL BE, AT TROLLTECH'S OPTION, EITHER (A) RETURN OF THE PRICE LICENSEE PAID FOR THE LICENSED SOFTWARE, OR (B) REPAIR OR REPLACEMENT OF THE LICENSED SOFTWARE, PROVIDED LICENSEE RETURNS TO TROLLTECH ALL COPIES OF THE LICENSED SOFTWARE AS ORIGINALLY DELIVERED TO LICENSEE. TROLLTECH SHALL NOT UNDER ANY CIRCUMSTANCES BE LIABLE TO LICENSEE BASED ON FAILURE OF THE LICENSED SOFTWARE IF THE FAILURE RESULTED FROM ACCIDENT, ABUSE OR MISAPPLICATION, NOR SHALL TROLLTECH UNDER ANY CIRCUMSTANCES BE LIABLE FOR SPECIAL DAMAGES, PUNITIVE OR EXEMPLARY DAMAGES, DAMAGES FOR LOSS OF PROFITS OR INTERRUPTION OF BUSINESS OR FOR LOSS OR CORRUPTION OF DATA. ANY AWARD OF DAMAGES FROM TROLLTECH TO LICENSEE SHALL NOT EXCEED THE TOTAL AMOUNT LICENSEE HAS PAID TO TROLLTECH IN CONNECTION WITH THIS AGREEMENT.
+
+12. Termination: Without prejudice to any other rights, Trolltech may terminate this Agreement if Licensee fails to comply with the terms and conditions of this Agreement. In such event, Licensee must destroy all copies of the Licensed Software and all of its components.
+
+13. Export Restrictions: Licensee agrees not to export or re-export the Licensed Software, any part thereof, or any process or service that is the direct product of the Licensed Software. Licensee may not sell, resell, or otherwise transfer for value, the Licensed Software (the foregoing collectively referred to as the "Restricted Components"), to any country, person, entity or end user subject to U.S. export restrictions. Licensee specifically agrees not to export or re-export any of the Restricted Components (i) to any country to which the U.S. has embargoed or restricted the export of goods or services, which currently include, but are not necessarily limited to Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria, or to any national of any such country, wherever located, who intends to transmit or transport the Restricted Components back to such country; (ii) to any end-user who Licensee knows or has reason to know will utilize the Restricted Components in the design, development or production of nuclear, chemical or biological weapons; or (iii) to any end-user who has been prohibited from participating in U.S. export transactions by any federal agency of the U.S. government. Licensee warrants and represents that neither the U.S. Commerce Department, Bureau of Export Administration nor any other U.S. federal agency has suspended, revoked or denied Licensee's export privileges.
+
+14. Government End Users: A "U.S. Government End User" shall mean any agency or entity of the government of the United States. The following shall apply if Licensee is a U.S. Government End User. The Licensed Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire the Licensed Software with only those rights set forth herein. The Licensed Software (including related documentation) is provided to U.S. Government End Users: (a) only as a commercial end item; and (b) only pursuant to this Agreement.
+
+15. Compliance with local laws: Licensee shall comply with all applicable laws and regulations relating to the Licensed Software in the United States and in other countries in which Licensee uses or modifies the Licensed Software. Without limiting the generality of the foregoing, Licensee shall not export, re-export, disclose or distribute any of the Licensed Software in violation of any applicable laws or regulations, including the export laws and regulations of the United States, and shall comply with all such laws and regulations.
+
+16. Entire Agreement: This Agreement constitutes the complete agreement between the parties and supersedes all prior or contemporaneous discussions, representations, and proposals, written or oral, with respect to the subject matters discussed herein. No modification of this Agreement will be effective unless contained in a writing executed by an authorized representative of each party. No term or condition contained in Licensee's purchase order will apply unless expressly accepted by Trolltech in writing. If any provision of the Agreement is found void or unenforceable, the remainder will remain valid and enforceable according to its terms. If any remedy provided is determined to have failed for its essential purpose, all limitations of liability and exclusions of damages set forth in this Agreement shall remain in effect.
+
+17. Governing law, legal venue: This Agreement shall be construed, interpreted and governed by the laws of the State of California, USA. Any action or proceeding arising from or relating to this Agreement shall be brought in a federal court in the Northern District of California or in the State Court in Santa Clara County, California, and each party irrevocably submits to the personal jurisdiction of any such court in any such action or proceeding. The Agreement gives Licensee specific legal rights; Licensee may have others, which vary from state to state and from country to country. Trolltech reserves all rights not specifically granted in this Agreement.
+
+
+
+
+For legal entities and/or individuals residing in any country other than Canada, the United States of America or South America:
+TROLLTECH TECHNOLOGY PREVIEW LICENSE AGREEMENT: NORWAY
+
+Agreement version 2.0
+IMPORTANT-READ CAREFULLY:
+
+1. This Trolltech Technology Preview License Agreement ("Agreement") is a legal agreement between you (either an individual or a legal entity) and Trolltech ASA ("Trolltech"), and pertains to the Trolltech software product(s) accompanying this Agreement, which include(s) computer software and may include "online" or electronic documentation, associated media, and printed materials, including the source code, example programs and the documentation ("Licensed Software").
+
+2. The Licensed Software is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. Trolltech retains all rights not expressly granted. No title, property rights or copyright in the Licensed Software or in any modifications to the Licensed Software shall pass to the Licensee under any circumstances. The Licensed Software is licensed, not sold.
+
+3. By installing, copying, or otherwise using the Licensed Software, Licensee agrees to be bound by the terms of this Agreement. If Licensee does not agree to the terms of this Agreement, Licensee should not install, copy, or otherwise use the Licensed Software.
+
+4. Upon Licensee's acceptance of the terms and conditions of this Agreement, Trolltech grants Licensee the right to use the Licensed Software in the manner provided below.
+
+5. Trolltech grants to Licensee as an individual a personal, non-exclusive, non-transferable license to make and use copies of the Licensed Software for the sole purpose of evaluating and testing the Licensed Software and/or providing feedback to Trolltech. Licensee may install copies of the Licensed Software on an unlimited number of computers provided that Licensee is the only individual using the Licensed Software. If Licensee is an entity, Trolltech grants Licensee the right to designate one, and only one, individual within Licensee's organization who shall have the sole right to use the Licensed Software in the manner provided in this Agreement. Licensee may, at any time, but not more frequently than once every six (6) months, designate another individual to replace the current designated user by notifying Trolltech, so long as there is no more than one (1) designated user at any given time
+
+6. Licensee may not loan, rent, lease, or license the Licensed Software or any copy of it. Licensee may not alter or remove any details of ownership, copyright, trademark or other property right connected with the Licensed Software. Licensee may not modify or distribute the Licensed Software. Licensee may not distribute any software statically or dynamically linked with the Licensed Software.
+
+7. This Licensed Software is time-limited. All rights granted to Licensee in this Agreement will be void three (3) months after Licensee received the Licensed Software.
+
+8. The Licensed Software may provide links to third party libraries or code (collectively "Third Party Libraries") to implement various functions. Third Party Libraries do not comprise part of the Licensed Software. In some cases, access to Third Party Libraries may be included along with the Licensed Software delivery as a convenience for development and testing only. Such source code and libraries as are or may be listed in the ".../src/3rdparty" source tree delivered with the Licensed Software, as may be amended from time to time, do not comprise the Licensed Software. Licensee acknowledges (1) that some Third Party Libraries may require additional licensing of copyright and patents from the owners of such, and (2) that distribution of any of the Licensed Software referencing any portion of a Third Party Library may require appropriate licensing from such third parties.
+
+9. Pre-Release Code, Non-Commercial Use: The Licensed Software contains Pre-release Code that is not at the level of performance and compatibility of a final, generally available, product offering. The Licensed Software may not operate correctly and may be substantially modified prior to the first commercial shipment, if any. Trolltech is not obligated to make this or any later version of the Licensed Software commercially available. The License Software is "Not for Commercial Use" and may only be used for the purposes described in Section 5. You may not use the Licensed Software in a live operating environment where it may be relied upon to perform in the same manner as a commercially released product or with data that has not been sufficiently backed up.
+
+10. WARRANTY DISCLAIMER: THE LICENSED SOFTWARE IS LICENSED TO LICENSEE "AS IS". TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, TROLLTECH ON BEHALF OF ITSELF AND ITS SUPPLIERS, DISCLAIMS ALL WARRANTIES AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT WITH REGARD TO THE LICENSED SOFTWARE.
+
+11. LIMITATION OF LIABILITY: IF, TROLLTECH'S WARRANTY DISCLAIMER NOTWITHSTANDING, TROLLTECH IS HELD LIABLE TO LICENSEE, WHETHER IN CONTRACT, TORT OR ANY OTHER LEGAL THEORY, BASED ON THE LICENSED SOFTWARE, TROLLTECH'S ENTIRE LIABILITY TO LICENSEE AND LICENSEE'S EXCLUSIVE REMEDY SHALL BE, AT TROLLTECH'S OPTION, EITHER (A) RETURN OF THE PRICE LICENSEE PAID FOR THE LICENSED SOFTWARE, OR (B) REPAIR OR REPLACEMENT OF THE LICENSED SOFTWARE, PROVIDED LICENSEE RETURNS TO TROLLTECH ALL COPIES OF THE LICENSED SOFTWARE AS ORIGINALLY DELIVERED TO LICENSEE. TROLLTECH SHALL NOT UNDER ANY CIRCUMSTANCES BE LIABLE TO LICENSEE BASED ON FAILURE OF THE LICENSED SOFTWARE IF THE FAILURE RESULTED FROM ACCIDENT, ABUSE OR MISAPPLICATION, NOR SHALL TROLLTECH UNDER ANY CIRCUMSTANCES BE LIABLE FOR SPECIAL DAMAGES, PUNITIVE OR EXEMPLARY DAMAGES, DAMAGES FOR LOSS OF PROFITS OR INTERRUPTION OF BUSINESS OR FOR LOSS OR CORRUPTION OF DATA. ANY AWARD OF DAMAGES FROM TROLLTECH TO LICENSEE SHALL NOT EXCEED THE TOTAL AMOUNT LICENSEE HAS PAID TO TROLLTECH IN CONNECTION WITH THIS AGREEMENT.
+
+12. Termination: Without prejudice to any other rights, Trolltech may terminate this Agreement if Licensee fails to comply with the terms and conditions of this Agreement. In such event, Licensee must destroy all copies of the Licensed Software and all of its components.
+
+13. Export Restrictions: Licensee agrees not to export or re-export the Licensed Software, any part thereof, or any process or service that is the direct product of the Licensed Software. Licensee may not sell, resell, or otherwise transfer for value, the Licensed Software (the foregoing collectively referred to as the "Restricted Components"), to any country, person, entity or end user subject to U.S. export restrictions. Licensee specifically agrees not to export or re-export any of the Restricted Components (i) to any country to which the U.S. has embargoed or restricted the export of goods or services, which currently include, but are not necessarily limited to Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria, or to any national of any such country, wherever located, who intends to transmit or transport the Restricted Components back to such country; (ii) to any end-user who Licensee knows or has reason to know will utilize the Restricted Components in the design, development or production of nuclear, chemical or biological weapons; or (iii) to any end-user who has been prohibited from participating in U.S. export transactions by any federal agency of the U.S. government. Licensee warrants and represents that neither the U.S. Commerce Department, Bureau of Export Administration nor any other U.S. federal agency has suspended, revoked or denied Licensee's export privileges.
+
+14. Government End Users: A "U.S. Government End User" shall mean any agency or entity of the government of the United States. The following shall apply if Licensee is a U.S. Government End User. The Licensed Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire the Licensed Software with only those rights set forth herein. The Licensed Software (including related documentation) is provided to U.S. Government End Users: (a) only as a commercial end item; and (b) only pursuant to this Agreement.
+
+15. Compliance with local laws: Licensee shall comply with all applicable laws and regulations relating to the Licensed Software in the United States and in other countries in which Licensee uses or modifies the Licensed Software. Without limiting the generality of the foregoing, Licensee shall not export, re-export, disclose or distribute any of the Licensed Software in violation of any applicable laws or regulations, including the export laws and regulations of the United States, and shall comply with all such laws and regulations.
+
+16. Entire Agreement: This Agreement constitutes the complete agreement between the parties and supersedes all prior or contemporaneous discussions, representations, and proposals, written or oral, with respect to the subject matters discussed herein. No modification of this Agreement will be effective unless contained in a writing executed by an authorized representative of each party. No term or condition contained in Licensee's purchase order will apply unless expressly accepted by Trolltech in writing. If any provision of the Agreement is found void or unenforceable, the remainder will remain valid and enforceable according to its terms. If any remedy provided is determined to have failed for its essential purpose, all limitations of liability and exclusions of damages set forth in this Agreement shall remain in effect.
+
+17. Governing law, legal venue: This Agreement shall be construed, interpreted and governed by the laws of Norway, the legal venue to be Oslo City Court. Trolltech reserves all rights not specifically granted in this Agreement.
diff --git a/examples/config/logo.png b/examples/config/logo.png
new file mode 100644
index 000000000..8a9562614
--- /dev/null
+++ b/examples/config/logo.png
Binary files differ
diff --git a/examples/config/qticon.icns b/examples/config/qticon.icns
new file mode 100644
index 000000000..6291dd397
--- /dev/null
+++ b/examples/config/qticon.icns
Binary files differ
diff --git a/examples/config/qticon.ico b/examples/config/qticon.ico
new file mode 100644
index 000000000..9e1b83f1b
--- /dev/null
+++ b/examples/config/qticon.ico
Binary files differ
diff --git a/examples/config/qticon.png b/examples/config/qticon.png
new file mode 100644
index 000000000..d68b205cd
--- /dev/null
+++ b/examples/config/qticon.png
Binary files differ
diff --git a/examples/config/watermark.png b/examples/config/watermark.png
new file mode 100644
index 000000000..b07780d9d
--- /dev/null
+++ b/examples/config/watermark.png
Binary files differ
diff --git a/examples/examples.pro b/examples/examples.pro
new file mode 100644
index 000000000..623d96691
--- /dev/null
+++ b/examples/examples.pro
@@ -0,0 +1,7 @@
+TEMPLATE = subdirs
+CONFIG += ordered
+SUBDIRS += testapp
+SUBDIRS += updater
+
+IDE_BUILD_TREE = "$$(QTCREATOR_SOURCE_PATH)"
+!isEmpty( IDE_BUILD_TREE ):SUBDIRS += updaterplugin
diff --git a/examples/packages/generateindex.sh b/examples/packages/generateindex.sh
new file mode 100644
index 000000000..746f376d6
--- /dev/null
+++ b/examples/packages/generateindex.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+echo "<Components>"
+for i in `find . -maxdepth 1 -type d -not -name \\\.*`; do
+ echo "Processing $i..." >&2
+ if [ -f "$i/meta/package.xml" ]; then
+ echo "<Component>$i</Component>"
+ else
+ echo "Ignoring $i: Could not find meta/package.xml" >&2
+ fi
+done
+echo "</Components>"
+
diff --git a/examples/packages/generatetranslation.sh b/examples/packages/generatetranslation.sh
new file mode 100644
index 000000000..ec4c8784b
--- /dev/null
+++ b/examples/packages/generatetranslation.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 scriptfile [uifiles]*" >/dev/stderr
+ exit 1
+fi
+
+FILE="$TMPDIR/$(basename $0).$RANDOM.$$.tmp"
+FILE2="$TMPDIR/$(basename $0).$RANDOM.$$.tmp"
+FILE3="$TMPDIR/$(basename $0).$RANDOM.$$.tmp"
+
+CONTEXT=`basename $1 | sed -e 's,\([^.]*\)\..*,\1,'`
+
+# first work on the script file
+sed -ne 's/qsTr *( *"\(\([^"\\]*\(\\.\)*\)*\)"/\
+TRANSLATE\1TRANSLATE\
+/pg' $1 | sed -ne 's,^TRANSLATE\(.*\)TRANSLATE$,\1,p' |
+sed -e 's/\\"/";/g' |
+sed -e 's/</\&lt;/g' > $FILE
+
+# remove duplicates
+sort -u $FILE > $FILE3
+mv $FILE3 $FILE
+
+echo "<?xml version=\"1.0\" encoding=\"utf8\"?>" > $FILE2
+echo "<!DOCTYPE TS><TS version=\"1.1\">" >> $FILE2
+echo "<context>" >> $FILE2
+echo " <name>$CONTEXT</name>" >> $FILE2
+
+sed -e 's/\(.*\)/ <message>\
+ <source>\1<\/source>\
+ <translation type="unfinished"><\/translation>\
+ <\/message>/' < $FILE >> $FILE2
+
+echo "</context>" >> $FILE2
+
+
+while [ $# -gt 1 ]; do
+shift
+
+CONTEXT=`sed -ne 's,.*<class>\([^<]*\)</class>.*,\1,p' $1`
+
+echo "<context>" >> $FILE2
+echo " <name>$CONTEXT</name>" >> $FILE2
+
+# then work on the ui files
+sed -ne 's/<string>\([^<\\]*\)<\/string>/\
+TRANSLATE\1TRANSLATE\
+/pg' $1 | sed -ne 's,^TRANSLATE\(.*\)TRANSLATE$,\1,p' |
+sed -e 's/\\"/";/g' |
+sed -e 's/</\&lt;/g' > $FILE
+
+# remove duplicates
+sort -u $FILE > $FILE3
+mv $FILE3 $FILE
+
+
+
+sed -e 's/\(.*\)/ <message>\
+ <source>\1<\/source>\
+ <translation type="unfinished"><\/translation>\
+ <\/message>/' < $FILE >> $FILE2
+
+
+echo "</context>" >> $FILE2
+
+done
+
+echo "</TS>" >> $FILE2
+
+cat $FILE2
+
+rm $FILE
+rm $FILE2
+
+exit 0
diff --git a/examples/packages/index.xml b/examples/packages/index.xml
new file mode 100644
index 000000000..94f091a44
--- /dev/null
+++ b/examples/packages/index.xml
@@ -0,0 +1,9 @@
+<Components>
+<Component>./qtcore</Component>
+<Component>./qtgui</Component>
+<Component>./qt</Component>
+<Component>./qtcreator</Component>
+<Component>./dbus4win</Component>
+<Component>./nokiasdk</Component>
+<Component>./python</Component>
+</Components>
diff --git a/examples/testapp/components.xml b/examples/testapp/components.xml
new file mode 100644
index 000000000..ce4e15ad5
--- /dev/null
+++ b/examples/testapp/components.xml
@@ -0,0 +1,13 @@
+<Packages>
+ <ApplicationName>Test App</ApplicationName>
+ <ApplicationVersion>1</ApplicationVersion>
+ <Package>
+ <Name>Test App</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2009-12-01</InstallDate>
+ </Package>
+</Packages>
diff --git a/examples/testapp/config.xml b/examples/testapp/config.xml
new file mode 100644
index 000000000..26b2f0980
--- /dev/null
+++ b/examples/testapp/config.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>Test App</Name>
+ <Version>1</Version>
+ <Title>Test App</Title>
+ <Publisher>Nokia</Publisher>
+ <ProductUrl>http://qt.nokia.com</ProductUrl>
+
+ <PublicKey>
+ -----BEGIN PUBLIC KEY-----
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDzdb8ti9Ss5kmEY5rGf2HFEsj0
+ W6dXOXRIO4W3XXr37Rzc8JI4UMZd6lEcxF9mdnoqOOyhHQABI8/CB2t9HTsZPRPC
+ TCq43QLMfVMgI6A5Cgetv6osvZFgNG3nFAlRkLHw2gLO/zxoblY0wPq5p4xmYRh4
+ f/YjsgYeA2v9V9FBAQIDAQAB
+ -----END PUBLIC KEY-----
+ </PublicKey>
+
+ <PrivateKey>
+ -----BEGIN RSA PRIVATE KEY-----
+ Proc-Type: 4,ENCRYPTED
+ DEK-Info: DES-EDE3-CBC,C9D3A294C3702C32
+
+ unYGknjGs+FX+E5Bze/Kk2OZAvpJkYKhhJFJkiPekPy6FLPKDZX0oPyvNFjMnNPG
+ wXNQe7Yr2WVMlFFmm92yCFXyzIrokr5Q8mUZEb1aJKHPCjTk4gmfOSCnwYrqPcLk
+ XdFdr6e+yVsbaJ0zahPFQfaj4fUac9cK/qrMzwn1SxzYgW5+ZNp4KZVhWUkl8SE8
+ TiwDMCN3wLNHzrSZr65A6XFKw5euSyCqcaqDH+tvxvmFZjb8QBhFf9APlTAQKcoK
+ NrMGaUCOC96WDcKkj2iNLOUrp5vylo0/YDWKQdIsGHWGFV7L+M0aJgobdjKKXBKa
+ ywqVhjgMo0e/cS/Ywtfuj9A3K6PnOrizYL+ukTAWfJdxdU8p91BhuoFR4CsYAJAW
+ LZl/EfkCfJHOWgauGFkpvvaaIQMifJ6XObMZUVkYEi8e3jHxA653NmQIXRHoGgTW
+ pr7T/AvZgTdrY0AuMcFHaWvKYrJD0CNwLtA7I+kcEMMa0c9Q2ryI8/qLYSRMMpDk
+ fsUIiciPelpnruKGp8OQsrMPpmbDG2gYDA3y4aL7DDzZc8vx3ElsXcOU+Ri7asKR
+ 1fRhhK7tFI+IhU6oHPM1QkX+85hZQR6Rr7w1dapBITCxv/uepJQJfEeur/utn1wB
+ EvSr8OSLgxFS7Nuc2R4vtHDb09DCSOqj0310GgtvI7NkrJqjx/dOmxjUEw29vRw6
+ 1iaV7JrEkAlXn0cJRXaZ4ujxoIx2lBKoDDrQ8n1OUMxKDqKF/NWWh6yrCcsuG2kN
+ NBZ0kDxCbqe0cyKeCAFjtjUF1TsiAeXXZt+M3s12sKE0B5BXuir74A==
+ -----END RSA PRIVATE KEY-----
+ </PrivateKey>
+
+ <!-- @homeDir@ and @rootDir@ are some of the supported vars -->
+ <TargetDir>@homeDir@/testinstall</TargetDir>
+ <RemoteRepositories>
+ <Repository>
+ <Url>http://www.kdab.com/~christoph/testapp</Url>
+ <Required>true</Required>
+ </Repository>
+ </RemoteRepositories>
+</Installer>
diff --git a/examples/testapp/config/config.xml b/examples/testapp/config/config.xml
new file mode 100644
index 000000000..f020d92e4
--- /dev/null
+++ b/examples/testapp/config/config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>Test App</Name>
+ <Version>1</Version>
+ <Title>Test App</Title>
+ <Publisher>Nokia</Publisher>
+ <ProductUrl>http://qt.nokia.com</ProductUrl>
+
+ <PublicKey>
+ -----BEGIN PUBLIC KEY-----
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDzdb8ti9Ss5kmEY5rGf2HFEsj0
+ W6dXOXRIO4W3XXr37Rzc8JI4UMZd6lEcxF9mdnoqOOyhHQABI8/CB2t9HTsZPRPC
+ TCq43QLMfVMgI6A5Cgetv6osvZFgNG3nFAlRkLHw2gLO/zxoblY0wPq5p4xmYRh4
+ f/YjsgYeA2v9V9FBAQIDAQAB
+ -----END PUBLIC KEY-----
+ </PublicKey>
+
+ <!-- @homeDir@ and @rootDir@ are some of the supported vars -->
+ <TargetDir>@homeDir@/testinstall</TargetDir>
+</Installer>
diff --git a/examples/testapp/logo.png b/examples/testapp/logo.png
new file mode 100644
index 000000000..3d5865a60
--- /dev/null
+++ b/examples/testapp/logo.png
Binary files differ
diff --git a/examples/testapp/main.cpp b/examples/testapp/main.cpp
new file mode 100644
index 000000000..3012c333f
--- /dev/null
+++ b/examples/testapp/main.cpp
@@ -0,0 +1,46 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <QApplication>
+#include "mainwindow.h"
+#include <KDToolsCore/KDSelfRestarter>
+
+int main( int argc, char** argv ) {
+ const KDSelfRestarter restarter( argc, argv );
+ QStringList args;
+ for ( int i = 0; i < argc; ++i )
+ args << QString::fromLocal8Bit( argv[i] );
+ QApplication app( argc, argv );
+ MainWindow mw( args );
+ mw.show();
+ return app.exec();
+}
diff --git a/examples/testapp/mainwindow.cpp b/examples/testapp/mainwindow.cpp
new file mode 100644
index 000000000..4a6fd1618
--- /dev/null
+++ b/examples/testapp/mainwindow.cpp
@@ -0,0 +1,182 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "mainwindow.h"
+
+#include <memory>
+
+#include <QAbstractButton>
+#include <QApplication>
+#include <QLabel>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QProgressDialog>
+#include <QStringList>
+
+#include <KDToolsCore/KDAutoPointer>
+#include <KDToolsCore/KDSelfRestarter>
+
+#include <KDUpdater/Application>
+#include <KDUpdater/PackagesInfo>
+#include <KDUpdater/UpdateFinder>
+#include <KDUpdater/UpdateSourcesInfo>
+
+#include "common/binaryformatenginehandler.h"
+#include "common/binaryformat.h"
+#include "componentselectiondialog.h"
+#include "getrepositorymetainfojob.h"
+#include "common/errors.h"
+#include "common/fileutils.h"
+#include "init.h"
+#include "updateagent.h"
+
+#include "updatesettings.h"
+#include "updatesettingsdialog.h"
+
+using namespace QInstaller;
+
+MainWindow::MainWindow( const QStringList& args, QWidget* parent ) : QMainWindow( parent ) {
+
+ QInstaller::init();
+
+ QMenuBar* mbar = menuBar();
+ QMenu* fm = mbar->addMenu( QObject::tr("File") );
+ fm->addAction( QObject::tr("Check for Updates"), this, SLOT(checkForUpdates()), QKeySequence( QLatin1String("Ctrl+U") ) );
+ fm->addAction( QObject::tr("Update Settings"), this, SLOT(editUpdateSettings()) );
+ fm->addAction( QObject::tr("Quit"), QApplication::instance(), SLOT(quit()), QKeySequence( QLatin1String("Ctrl+Q") ) );
+ QLabel* label = new QLabel( this );
+ label->setAlignment( Qt::AlignCenter );
+ setCentralWidget( label );
+ label->setText( QString::fromLatin1("Version: %1\n").arg( m_installer.settings().applicationVersion() ) + args.join( QLatin1String(" ") ) );
+ updaterapp.packagesInfo()->setApplicationName( m_settings.applicationName() );
+ updaterapp.packagesInfo()->setApplicationVersion( m_settings.applicationVersion() );
+
+ UpdateAgent* const agent = new UpdateAgent( this );
+ connect( agent, SIGNAL( updatesAvailable() ), this, SLOT( updatesAvailable() ) );
+}
+
+void MainWindow::editUpdateSettings()
+{
+ UpdateSettingsDialog dialog( this );
+ connect( &dialog, SIGNAL( checkForUpdates() ), this, SLOT( checkForUpdates() ) );
+ dialog.exec();
+}
+
+void MainWindow::checkForUpdates() {
+ std::auto_ptr< QInstallerCreator::BinaryFormatEngineHandler > handler( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
+ handler->setComponentIndex( QInstallerCreator::ComponentIndex() );
+
+ UpdateSettings settings;
+
+ try
+ {
+ m_installer.setRemoteRepositories( settings.repositories() );
+ settings.setLastCheck( QDateTime::currentDateTime() );
+
+ // no updates for us
+ if( m_installer.components().isEmpty() )
+ {
+ QMessageBox::information( this, tr( "Check for Updates" ), tr( "There are currently no updates available for you." ) );
+ return;
+ }
+
+ // set the target directory to the actual one
+ m_installer.setValue( QLatin1String( "TargetDir" ), QFileInfo( updaterapp.packagesInfo()->fileName() ).absolutePath() );
+
+ // this will automatically mork components as to get installed
+ ComponentSelectionDialog componentSelection( &m_installer, this );
+ if( componentSelection.exec() == QDialog::Rejected )
+ return;
+
+ QProgressDialog dialog( this );
+ dialog.setRange( 0, 100 );
+ dialog.show();
+ connect( &dialog, SIGNAL( canceled() ), &m_installer, SLOT( interrupt() ) );
+ connect( &m_installer, SIGNAL( installationProgressTextChanged( QString ) ), &dialog, SLOT( setLabelText( QString ) ) );
+ connect( &m_installer, SIGNAL( installationProgressChanged( int ) ), &dialog, SLOT( setValue( int ) ) );
+ m_installer.installSelectedComponents();
+ updatesInstalled();
+ }
+ catch( const QInstaller::Error& error )
+ {
+ QMessageBox::critical( this, tr( "Check for Updates" ), tr( "Error while installing updates:\n%1" ).arg( error.what() ) );
+ m_installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ }
+ catch( ... )
+ {
+ QMessageBox::critical( this, tr( "Check for Updates" ), tr( "Unknown error while installing updates." ) );
+ m_installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ }
+}
+
+void MainWindow::updatesAvailable()
+{
+ KDAutoPointer<QMessageBox> box( new QMessageBox( this ) );
+ box->setWindowTitle( tr("Updates Available") );
+ box->setText( tr("Software updates are available for your computer. Do you want to install them?") );
+ box->setStandardButtons( QMessageBox::Yes|QMessageBox::No );
+ box->button( QMessageBox::Yes )->setText( tr( "Continue" ) );
+ box->button( QMessageBox::No )->setText( tr( "Not Now" ) );
+ box->exec();
+ if ( !box )
+ return;
+ if ( box->clickedButton() == box->button( QMessageBox::Yes ) )
+ checkForUpdates();
+}
+
+void MainWindow::updatesInstalled()
+{
+ // only ask that dumb question if a SelfUpdateOperation was executed
+ if( !KDSelfRestarter::restartOnQuit() )
+ {
+ QMessageBox::information( this, tr( "Updates Installed" ), tr( "Installation complete." ) );
+ return;
+ }
+
+ KDAutoPointer<QMessageBox> box( new QMessageBox( this ) );
+ box->setWindowTitle( tr("Updates Installed" ) );
+ box->setText( tr("Installation complete, you need to restart the application for the changes to take effect.") );
+ box->setStandardButtons( QMessageBox::Yes|QMessageBox::No );
+ box->button( QMessageBox::Yes )->setText( tr("Restart Now") );
+ box->button( QMessageBox::No )->setText( tr("Restart Later") );
+ box->exec();
+ if ( !box )
+ return;
+ if ( box->clickedButton() == box->button( QMessageBox::Yes ) )
+ QCoreApplication::quit();
+ else
+ KDSelfRestarter::setRestartOnQuit( false );
+}
+
diff --git a/examples/testapp/mainwindow.h b/examples/testapp/mainwindow.h
new file mode 100644
index 000000000..c0611eaab
--- /dev/null
+++ b/examples/testapp/mainwindow.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <QMainWindow>
+
+#include <KDUpdater/Application>
+
+#include "qinstaller.h"
+#include "common/installersettings.h"
+
+class MainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ explicit MainWindow( const QStringList& args, QWidget* parent=0 );
+
+private Q_SLOTS:
+ void editUpdateSettings();
+ void checkForUpdates();
+ void updatesInstalled();
+ void updatesAvailable();
+
+private:
+ KDUpdater::Application updaterapp;
+ QInstaller::Installer m_installer;
+ QInstaller::InstallerSettings m_settings;
+};
diff --git a/examples/testapp/packages/com.nokia.testapp/meta/installscript.js b/examples/testapp/packages/com.nokia.testapp/meta/installscript.js
new file mode 100644
index 000000000..d1dded25b
--- /dev/null
+++ b/examples/testapp/packages/com.nokia.testapp/meta/installscript.js
@@ -0,0 +1,18 @@
+function Component()
+{
+ if( installer.isUpdater() )
+ {
+ if( installer.value( "os" ) == "win" )
+ component.addDownloadableArchive( "testapp.exe" );
+ else
+ component.addDownloadableArchive( "testapp.app.7z" );
+ }
+}
+
+Component.prototype.createOperationsForArchive = function( archive )
+{
+ component.createOperationsForArchive( archive );
+
+ if( installer.isUpdater() )
+ component.addOperation( "SelfRestart" );
+}
diff --git a/examples/testapp/packages/com.nokia.testapp/meta/package.xml b/examples/testapp/packages/com.nokia.testapp/meta/package.xml
new file mode 100644
index 000000000..071a2c807
--- /dev/null
+++ b/examples/testapp/packages/com.nokia.testapp/meta/package.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<Package>
+ <DisplayName>Test App</DisplayName>
+ <Description>Installs the complete Nokia SDK.</Description>
+ <Version>1</Version>
+ <ReleaseDate>2009-12-03</ReleaseDate>
+ <Name>com.nokia.testapp</Name>
+ <Script>installscript.js</Script>
+</Package>
diff --git a/examples/testapp/testapp.pro b/examples/testapp/testapp.pro
new file mode 100644
index 000000000..f32b09f0a
--- /dev/null
+++ b/examples/testapp/testapp.pro
@@ -0,0 +1,19 @@
+TEMPLATE = app
+TARGET =
+
+include( ../../installerbuilder/libinstaller/libinstaller.pri )
+LIBS = -L$$OUT_PWD/../../installerbuilder/lib -linstaller $$LIBS
+
+DESTDIR = packages/com.nokia.testapp/data
+
+QT += script network xml sql
+CONFIG += uitools help
+QTPLUGIN += qsqlite
+
+# Input
+HEADERS += mainwindow.h
+SOURCES += main.cpp mainwindow.cpp
+RESOURCES += testapp.qrc
+
+macx:QMAKE_POST_LINK = ($$OUT_PWD/../../installerbuilder/bin/binarycreator -p packages -c config -t ../../installerbuilder/bin/installerbase TestAppInstaller.app com.nokia.testapp)
+win32:QMAKE_POST_LINK = ($$OUT_PWD\..\..\installerbuilder\bin\binarycreator.exe -p $$PWD\packages -c $$PWD\config -t $$OUT_PWD\..\..\installerbuilder\bin\installerbase.exe TestAppInstaller.exe com.nokia.testapp)
diff --git a/examples/testapp/testapp.qrc b/examples/testapp/testapp.qrc
new file mode 100644
index 000000000..89c08ca9e
--- /dev/null
+++ b/examples/testapp/testapp.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/metadata/installer-config">
+ <file>config.xml</file>
+ </qresource>
+ <qresource>
+ <file>logo.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/testcases/result-example.xml b/examples/testcases/result-example.xml
new file mode 100644
index 000000000..937625b3c
--- /dev/null
+++ b/examples/testcases/result-example.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8""?>
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:tf="http://sdk.nokia.com/test-framework/ns/1.0">
+ <entry>
+ <title>ab12cd34ef - installer-20090310.exe - checks failed :-(</title>
+ <updated>2010-03-10T14:00Z</updated>
+ <tf:host>test-machine_1.local</tf:host>
+ <tf:testStart>2010-03-10T13:00Z</tf:testStart>
+ <tf:testEnd>2010-03-10T13:49Z</tf:testEnd>
+
+ <tf:installer>
+ <tf:sourceUrl>ftp://buildmachine/installers/installer-20090310.exe</tf:sourceUrl>
+ <tf:revision>ab12cd34ef</tf:revision> <!-- if we have sth like that -->
+ <tf:platform>windows</tf:platform>
+ </tf:installer>
+ <tf:virtualMachine>
+ <tf:path>/home/testuser/VMs/WindowsXp/WindowsXp.vmx</tf:path>
+ <tf:platform>windows</tf:platform>
+ <tf:snapshot>base</tf:snapshot>
+ </tf:virtualMachine>
+ <tf:testCase>
+ <tf:name>Basic Installation</tf:name>
+ <tf:path>/home/testuser/testcases/basic/basic.cfg</tf:path>
+ <tf:installScript>/home/testuser/testcases/basic/testscript.qs</tf:installScript>
+ </tf:testCase>
+ <tf:installationResult>
+ <tf:exitCode>0</tf:exitCode>
+ <tf:exitStatus>normal</tf:exitStatus>
+ <tf:summary>NoError</tf:summary>
+ </tf:installationResult>
+ <tf:checkerResult>
+ <tf:item type="files">c:\sdk\bin\qmake.exe: md5 sum mismatch: expected: abcd1234 actual: 1234abcd</tf:item>
+ <tf:summary>InstallerError</tf:summary>
+ </tf:checkerResult>
+ <tf:internalErrors/>
+ <tf:errorSummary>InstallerError</tf:summary>
+ </entry>
+</feed>
diff --git a/examples/testcases/testcase1/packagemanagement.qs b/examples/testcases/testcase1/packagemanagement.qs
new file mode 100644
index 000000000..3c6dcfdeb
--- /dev/null
+++ b/examples/testcases/testcase1/packagemanagement.qs
@@ -0,0 +1,35 @@
+function Controller()
+{
+ installer.autoRejectMessageBoxes
+ this.componentSelectionCounter = 0
+}
+
+Controller.prototype.UpdaterSelectedCallback = function()
+{
+ tabController.setCurrentTab( TabController.PACKAGE_MANAGER )
+}
+
+Controller.prototype.ComponentSelectionPageCallback = function()
+{
+ if ( this.componentSelectionCounter == 0 ) {
+ print( "first time, uninstall" )
+ var page = gui.pageWidgetByObjectName( "ComponentSelectionPage" )
+ page.deselectComponent( "com.nokia.sdk.doc.qtcreator" )
+ gui.clickButton( buttons.NextButton, 3000 )
+ this.componentSelectionCounter += 1
+ } else {
+ print( "second time, click cancel" )
+ gui.clickButton( buttons.CancelButton )
+ }
+}
+
+
+Controller.prototype.ReadyForInstallationPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.FinishedPageCallback = function()
+{
+ gui.clickButton( buttons.CommitButton )
+}
diff --git a/examples/testcases/testcase1/test-uninstall.qs b/examples/testcases/testcase1/test-uninstall.qs
new file mode 100644
index 000000000..c2d707fe1
--- /dev/null
+++ b/examples/testcases/testcase1/test-uninstall.qs
@@ -0,0 +1,30 @@
+function Controller()
+{
+ installer.autoRejectMessageBoxes
+}
+
+
+Controller.prototype.IntroductionPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.ComponentSelectionPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "ComponentSelectionPage" )
+ page.keepSelectedComponentsRB.setChecked( true )
+ page.deselectComponent( "com.nokia.sdk.qt.gui" )
+ page.deselectComponent( "hgrmpfl (non-existing package)" ) // bad case for component lookup
+ page.selectComponent( "hgrmpfl2 (another non-existing package)" ) // bad case for component lookup
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.ReadyForInstallationPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.FinishedPageCallback = function()
+{
+ gui.clickButton( buttons.FinishButton )
+}
diff --git a/examples/testcases/testcase1/testcase1.cfg b/examples/testcases/testcase1/testcase1.cfg
new file mode 100644
index 000000000..d66c7d56c
--- /dev/null
+++ b/examples/testcases/testcase1/testcase1.cfg
@@ -0,0 +1,5 @@
+[General]
+installscript=testscript.qs
+platforms=windows,linux
+targetDirectory=c:\Users\kdab\Desktop\testinstall
+checkerTestDir=checker
diff --git a/examples/testcases/testcase1/testscript.qs b/examples/testcases/testcase1/testscript.qs
new file mode 100644
index 000000000..a19c0f9de
--- /dev/null
+++ b/examples/testcases/testcase1/testscript.qs
@@ -0,0 +1,69 @@
+function Controller()
+{
+ installer.autoRejectMessageBoxes
+ installer.setMessageBoxAutomaticAnswer( "overwriteTargetDirectory", QMessageBox.Yes )
+}
+
+
+Controller.prototype.IntroductionPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.LicenseAgreementPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "LicenseAgreementPage" )
+ page.acceptLicenseRB.setChecked( true )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.TargetDirectoryPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "TargetDirectoryPage" )
+ page.targetDirectoryLE.setText( "c:\\Users\\kdab\\Desktop\\testinstall" )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.ComponentSelectionPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "ComponentSelectionPage" )
+ page.deselectComponent( "com.nokia.sdk.qtcreator" )
+ page.deselectComponent( "hgrmpfl (non-existing package)" ) // bad case for component lookup
+ page.selectComponent( "hgrmpfl2 (another non-existing package)" ) // bad case for component lookup
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.DynamicQtGuiPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "DynamicQtGuiPage" )
+ page.checkBoxLib.setChecked( false )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.DynamicErrorPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "DynamicErrorPage" )
+ page.checkBoxMakeSure.setChecked( true )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.ReadyForInstallationPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.StartMenuDirectoryPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.PerformInstallationPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "PerformInstallationPage" )
+ page.details.button.click
+}
+
+Controller.prototype.FinishedPageCallback = function()
+{
+ gui.clickButton( buttons.FinishButton )
+}
diff --git a/examples/testreturn/main.cpp b/examples/testreturn/main.cpp
new file mode 100644
index 000000000..390029243
--- /dev/null
+++ b/examples/testreturn/main.cpp
@@ -0,0 +1,70 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <QFile>
+#include <QString>
+#include <iostream>
+
+static void crash() {
+ QString* nemesis = 0;
+ nemesis->clear();
+}
+
+int main( int argc, char** argv ) {
+ std::cout << "Hello." << std::endl;
+ if ( argc < 2 )
+ return 0;
+ const QString arg = QString::fromLocal8Bit( argv[1] );
+ bool ok = false;
+ const int num = arg.toInt( &ok );
+ if ( ok )
+ return num;
+ if ( arg == QLatin1String("crash") ) {
+ std::cout << "Yeth, mather. I Crath." << std::endl;
+ crash();
+ }
+ if ( arg == QLatin1String("--script") ) {
+ const QString fn = QString::fromLocal8Bit( argv[2] );
+ QFile f( fn );
+ if ( !f.open( QIODevice::ReadOnly ) ) {
+ std::cerr << "Could not open file for reading: " << qPrintable(f.errorString()) << std::endl;
+ crash();
+ }
+ bool ok;
+ const int rv = QString::fromLatin1( f.readAll() ).toInt( &ok );
+ if ( ok )
+ return rv;
+ else
+ crash();
+ }
+
+}
diff --git a/examples/testreturn/testreturn.pro b/examples/testreturn/testreturn.pro
new file mode 100644
index 000000000..a99a57b7a
--- /dev/null
+++ b/examples/testreturn/testreturn.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT -= gui
+CONFIG += console
+
+# Input
+SOURCES += main.cpp
diff --git a/examples/testvm-configs/franks-host-config.cfg b/examples/testvm-configs/franks-host-config.cfg
new file mode 100644
index 000000000..bddb76af9
--- /dev/null
+++ b/examples/testvm-configs/franks-host-config.cfg
@@ -0,0 +1,5 @@
+[General]
+vmrun=vmrun
+checkerInstallation=/home/frank/workspace-eclipse/test-framework/checker
+testcase0=TestCases/testcase1/testcase1.cfg
+vm0=VMs/NokiaTestVistaVM.cfg
diff --git a/examples/testvm-configs/franks-test-vm.cfg b/examples/testvm-configs/franks-test-vm.cfg
new file mode 100644
index 000000000..9bd0a113e
--- /dev/null
+++ b/examples/testvm-configs/franks-test-vm.cfg
@@ -0,0 +1,7 @@
+[General]
+snapshot=base
+username=kdab
+password=kdab
+vmx=NokiaTestVistaVM/WindowsVista32Bit.vmx
+tempDir=c:\Users\kdab\Desktop
+os=windows
diff --git a/examples/testvm-configs/mikes-host-config.cfg b/examples/testvm-configs/mikes-host-config.cfg
new file mode 100644
index 000000000..42fb37d79
--- /dev/null
+++ b/examples/testvm-configs/mikes-host-config.cfg
@@ -0,0 +1,4 @@
+[General]
+checkerInstallation=/Users/mike/Documents/KDAB/NokiaSDK/installer/test-framework/checker
+testcase0=/Users/mike/Documents/KDAB/NokiaSDK/installer/examples/testcases/testcase1/testcase1.cfg
+vm0=/Users/mike/Documents/KDAB/NokiaSDK/installer/examples/testvm-configs/mikes-test-vm.cfg \ No newline at end of file
diff --git a/examples/testvm-configs/mikes-test-vm.cfg b/examples/testvm-configs/mikes-test-vm.cfg
new file mode 100644
index 000000000..cc8fa4179
--- /dev/null
+++ b/examples/testvm-configs/mikes-test-vm.cfg
@@ -0,0 +1,7 @@
+[General]
+snapshot=base
+username=nokia
+password=nokia
+vmx=/Users/mike/Documents/Virtual Machines.localized/Nokia.vmwarevm/Nokia.vmx
+tempDir=c:\Users\nokia\Desktop
+os=windows \ No newline at end of file
diff --git a/examples/tutorial/config/config.xml b/examples/tutorial/config/config.xml
new file mode 100644
index 000000000..eb1ba45d0
--- /dev/null
+++ b/examples/tutorial/config/config.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>Your application</Name>
+ <Version>1.2.3</Version>
+ <Title>Your application Installer</Title>
+ <Publisher>Your vendor</Publisher>
+ <License>license.txt</License>
+ <StartMenuDir>Super App</StartMenuDir>
+ <TargetDir>@rootDir@InstallationDirectory</TargetDir>
+</Installer>
diff --git a/examples/tutorial/config/license.txt b/examples/tutorial/config/license.txt
new file mode 100644
index 000000000..61a94dce7
--- /dev/null
+++ b/examples/tutorial/config/license.txt
@@ -0,0 +1 @@
+The fantastic license, have you heard of the Beer Public License Agreement yet?
diff --git a/examples/tutorial/packages/com.vendor.product/data/installcontent.txt b/examples/tutorial/packages/com.vendor.product/data/installcontent.txt
new file mode 100644
index 000000000..f40001983
--- /dev/null
+++ b/examples/tutorial/packages/com.vendor.product/data/installcontent.txt
@@ -0,0 +1,2 @@
+This file will be installed into the target directory....
+
diff --git a/examples/tutorial/packages/com.vendor.product/meta/packages.xml b/examples/tutorial/packages/com.vendor.product/meta/packages.xml
new file mode 100644
index 000000000..0c84f6dde
--- /dev/null
+++ b/examples/tutorial/packages/com.vendor.product/meta/packages.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<Package>
+ <DisplayName>The root component</DisplayName>
+ <Description>Install this example.</Description>
+ <Version>0.1.0-1</Version>
+ <ReleaseDate>2010-09-21</ReleaseDate>
+ <Name>com.vendor.product</Name>
+</Package>
diff --git a/examples/updater/components.xml b/examples/updater/components.xml
new file mode 100644
index 000000000..6d45206a7
--- /dev/null
+++ b/examples/updater/components.xml
@@ -0,0 +1,409 @@
+<Packages>
+ <ApplicationName>Qt SDK</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <Package>
+ <Name>com.nokia.ndk</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.2.0</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.api</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.api.qtmobility</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.api.qtmobility.maemo</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.symbian.readme</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.misc.vcredist_x86</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.api.qtmobility.simulator2008</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.simulator.qtmingw</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.api.qtmobility.simulatormingw</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.api.qtmobility.symbian</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.api.qtmobility.symbian.462</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.documentation</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.2.0</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.documentation.qmake</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.documentation.qt</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.documentation.qtcreator</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.documentation.qtdesigner</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.documentation.qtlinguist</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.documentation.qtmobility</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.documentation.simulator</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.misc</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.misc.examples</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.3</Version>
+ <LastUpdateDate>2010-03-30</LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.misc.examples.46</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.4</Version>
+ <LastUpdateDate>2010-03-30</LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.misc.mingw</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>4.4.0</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.misc.qtsources</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.misc.qtsources.462</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.qtcreator.application</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>1.3.80</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.linguist</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>4.7.0</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.maemo</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.maemo.462</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.maemo.readme</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.maemo.usbdriver</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.qtcreator</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.4</Version>
+ <LastUpdateDate>2010-03-30</LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.qtcreator.gdb</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.qtcreator.jom</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.8.0</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.simulator</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.simulator.application</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.3</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.simulator.qt2008</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.symbian</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.symbian.462</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.symbian.462.devicefiles</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.1</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.symbian.462.gcce</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>4.3.3</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.symbian.462.sdk</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.tools.maemo.462.madde</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.5.0</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+ <Package>
+ <Name>com.nokia.ndk.api.qtmobility.maemo.462</Name>
+ <Pixmap></Pixmap>
+ <Title></Title>
+ <Description></Description>
+ <Version>0.0.2</Version>
+ <LastUpdateDate></LastUpdateDate>
+ <InstallDate>2010-03-29</InstallDate>
+ </Package>
+</Packages>
diff --git a/examples/updater/config.xml b/examples/updater/config.xml
new file mode 100644
index 000000000..c024c941e
--- /dev/null
+++ b/examples/updater/config.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>Qt SDK</Name>
+ <Version>0.9.0</Version>
+ <Title>Qt SDK</Title>
+ <MaintenanceTitle>Maintain Qt SDK</MaintenanceTitle>
+ <Publisher>Nokia</Publisher>
+ <Logo>logo.png</Logo>
+ <LogoSmall>logo-small.png</LogoSmall>
+ <Icon>logo-small</Icon>
+ <License>license.txt</License>
+ <Watermark>watermark.png</Watermark>
+ <RunProgram></RunProgram>
+ <StartMenuDir>Qt SDK - Release Candidate</StartMenuDir>
+ <UninstallerName>SDKMaintenanceTool</UninstallerName>
+
+ <!-- @homeDir@ and @rootDir@ are some of the supported vars -->
+ <TargetDir>@homeDir@/NokiaQtSDK</TargetDir>
+
+ <RemoteRepositories>
+ <Repository>
+<!--
+ <Url>http://schnappie.nokia.troll.no/alpha/onlinendk</Url>
+-->
+ <Url>http://hegel.europe.nokia.com/projects/ndk/installers/linux/x64/online_nokiaqtsdk_repo</Url>
+ <Required>true</Required>
+ </Repository>
+ </RemoteRepositories>
+</Installer>
diff --git a/examples/updater/main.cpp b/examples/updater/main.cpp
new file mode 100644
index 000000000..687ef7855
--- /dev/null
+++ b/examples/updater/main.cpp
@@ -0,0 +1,60 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <QApplication>
+#include <QStringList>
+
+#include "updater.h"
+#include "common/utils.h"
+
+int main( int argc, char* argv[] )
+{
+ bool checkonly = false;
+ {
+ QCoreApplication app( argc, argv );
+ checkonly = app.arguments().contains( QLatin1String( "--check-only" ) );
+ QInstaller::setVerbose( app.arguments().contains( QLatin1String( "--verbose" ) ) );
+ }
+
+ if( checkonly )
+ {
+ QCoreApplication app( argc, argv );
+ Updater u;
+ return u.checkForUpdates( true ) ? 0 : 1;
+ }
+ else
+ {
+ QApplication app( argc, argv );
+ Updater u;
+ return u.checkForUpdates( false ) ? 0 : 1;
+ }
+}
diff --git a/examples/updater/updater.cpp b/examples/updater/updater.cpp
new file mode 100644
index 000000000..c5a75ebbb
--- /dev/null
+++ b/examples/updater/updater.cpp
@@ -0,0 +1,174 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updater.h"
+
+#include <QDateTime>
+#include <QDomDocument>
+#include <QProgressDialog>
+
+#include "common/binaryformat.h"
+#include "common/binaryformatenginehandler.h"
+#include "common/errors.h"
+
+#include "componentselectiondialog.h"
+#include "qinstaller.h"
+#include "qinstallercomponent.h"
+#include "qinstallercomponentmodel.h"
+#include "updatesettings.h"
+#include "init.h"
+
+#include <KDUpdater/Application>
+#include <KDUpdater/PackagesInfo>
+
+#include <KDToolsCore/KDAutoPointer>
+
+#include <iostream>
+
+using namespace QInstaller;
+
+class Updater::Private
+{
+public:
+ KDUpdater::Application updaterapp;
+ Installer installer;
+};
+
+Updater::Updater( QObject* parent )
+ : QObject( parent )
+{
+ QInstaller::init();
+}
+
+Updater::~Updater()
+{
+}
+
+bool Updater::checkForUpdates( bool checkonly )
+{
+ d->installer.setLinearComponentList( true );
+
+ std::auto_ptr< QInstallerCreator::BinaryFormatEngineHandler > handler( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
+ handler->setComponentIndex( QInstallerCreator::ComponentIndex() );
+
+ UpdateSettings settings;
+ KDAutoPointer< ComponentSelectionDialog > dialog( checkonly ? 0 : new ComponentSelectionDialog( &d->installer ) );
+ if( !checkonly )
+ dialog->show();
+
+ ComponentModel::setVirtualComponentsVisible( true );
+
+ try
+ {
+ KDAutoPointer< QProgressDialog > progress( checkonly ? 0 : new QProgressDialog( dialog.get() ) );
+ if( !checkonly )
+ {
+ progress->setLabelText( tr( "Checking for updates..." ) );
+ progress->setRange( 0, 0 );
+ progress->show();
+ }
+
+ settings.setLastCheck( QDateTime::currentDateTime() );
+ d->installer.setRemoteRepositories( settings.repositories() );
+ d->installer.setValue( QLatin1String( "TargetDir" ), QFileInfo( d->updaterapp.packagesInfo()->fileName() ).absolutePath() );
+ }
+ catch( const Error& error )
+ {
+ if( !checkonly )
+ QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Error while checking for updates:\n%1" ).arg( error.what() ) );
+ settings.setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+ catch( ... )
+ {
+ if( !checkonly )
+ QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Unknown error while checking for updates." ) );
+ settings.setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+
+ const QList< Component* > components = d->installer.components( true );
+
+ // no updates for us
+ if( components.isEmpty() && !checkonly )
+ {
+ QMessageBox::information( dialog.get(), tr( "Check for Updates" ), tr( "There are currently no updates available for you." ) );
+ return false;
+ }
+
+ if( checkonly )
+ {
+ QDomDocument doc;
+ QDomElement root = doc.createElement( QLatin1String( "updates" ) );
+ doc.appendChild( root );
+ for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
+ {
+ QDomElement update = doc.createElement( QLatin1String( "update" ) );
+ update.setAttribute( QLatin1String( "name" ), (*it)->value( QLatin1String( "DisplayName" ) ) );
+ update.setAttribute( QLatin1String( "version" ), (*it)->value( QLatin1String( "Version" ) ) );
+ update.setAttribute( QLatin1String( "size" ), (*it)->value( QLatin1String( "UncompressedSize" ) ) );
+ root.appendChild( update );
+ }
+ std::cout << doc.toString( 4 ).toStdString() << std::endl;
+ return true;
+ }
+
+ if( dialog->exec() == QDialog::Rejected )
+ return false;
+
+ try
+ {
+ QProgressDialog dialog;
+ dialog.setRange( 0, 100 );
+ dialog.show();
+ connect( &dialog, SIGNAL( canceled() ), &d->installer, SLOT( interrupt() ) );
+ connect( &d->installer, SIGNAL( installationProgressTextChanged( QString ) ), &dialog, SLOT( setLabelText( QString ) ) );
+ connect( &d->installer, SIGNAL( installationProgressChanged( int ) ), &dialog, SLOT( setValue( int ) ) );
+ d->installer.installSelectedComponents();
+ }
+ catch( const Error& error )
+ {
+ QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Error while installing updates:\n%1" ).arg( error.what() ) );
+ d->installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+ catch( ... )
+ {
+ QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Unknown error while installing updates." ) );
+ d->installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+
+ return true;
+}
diff --git a/examples/updater/updater.h b/examples/updater/updater.h
new file mode 100644
index 000000000..e4e42059b
--- /dev/null
+++ b/examples/updater/updater.h
@@ -0,0 +1,45 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef UPDATER_H
+#define UPDATER_H
+
+#include <QtCore/QObject>
+#include <KDToolsCore/pimpl_ptr.h>
+
+class Updater : public QObject
+{
+public:
+ explicit Updater( QObject* parent = 0 );
+ ~Updater();
+
+ bool checkForUpdates( bool checkonly = false );
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+#endif
diff --git a/examples/updater/updater.pro b/examples/updater/updater.pro
new file mode 100644
index 000000000..c4662b3fd
--- /dev/null
+++ b/examples/updater/updater.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+TARGET = Updater
+
+include( ../../installerbuilder/libinstaller/libinstaller.pri )
+LIBS = -L$$OUT_PWD/../../installerbuilder/lib -linstaller $$LIBS
+
+QT += gui
+
+CONFIG += uitools
+
+SOURCES += main.cpp
+RESOURCES += updater.qrc
diff --git a/examples/updater/updater.qrc b/examples/updater/updater.qrc
new file mode 100644
index 000000000..962b28d51
--- /dev/null
+++ b/examples/updater/updater.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/metadata/installer-config">
+ <file>config.xml</file>
+ </qresource>
+</RCC>
diff --git a/examples/updaterplugin/Updater.pluginspec b/examples/updaterplugin/Updater.pluginspec
new file mode 100644
index 000000000..f5c5206bd
--- /dev/null
+++ b/examples/updaterplugin/Updater.pluginspec
@@ -0,0 +1,9 @@
+<plugin name="Updater" version="0.0.1" compatVersion="0.0.1">
+ <vendor>KDAB</vendor>
+ <copyright>(C) 2009 Klarälvdalens Datakonsult AB</copyright>
+ <license>We're not licensing that stuff at all :-)</license>
+ <description>Updater for Qt Creator and plugins</description>
+ <url>http://qt.nokia.com</url>
+ <dependencyList>
+ </dependencyList>
+</plugin>
diff --git a/examples/updaterplugin/config.xml b/examples/updaterplugin/config.xml
new file mode 100644
index 000000000..1ed83b993
--- /dev/null
+++ b/examples/updaterplugin/config.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>Qt Creator</Name>
+ <Version>1</Version>
+ <Title>Qt Creator</Title>
+ <Publisher>Nokia</Publisher>
+ <ProductUrl>http://qt.nokia.com</ProductUrl>
+
+ <RemoteRepositories>
+ <Repository>
+ <Url>http://www.kdab.com/~christoph/qtcreator/</Url>
+ <Required>true</Required>
+ </Repository>
+ </RemoteRepositories>
+</Installer>
diff --git a/examples/updaterplugin/config/config.xml b/examples/updaterplugin/config/config.xml
new file mode 100644
index 000000000..4bd742565
--- /dev/null
+++ b/examples/updaterplugin/config/config.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>Qt Creator</Name>
+ <Version>1</Version>
+ <Title>Qt Creator</Title>
+ <Publisher>Nokia</Publisher>
+ <ProductUrl>http://qt.nokia.com</ProductUrl>
+
+ <!-- @homeDir@ and @rootDir@ are some of the supported vars -->
+ <TargetDir>@homeDir@/testinstall</TargetDir>
+ <RemoteRepositories>
+ <Repository>
+ <Url>http://www.kdab.com/~christoph/qtcreator/</Url>
+ <Required>true</Required>
+ </Repository>
+ </RemoteRepositories>
+</Installer>
diff --git a/examples/updaterplugin/packages/com.nokia.qtcreator/meta/installscript.js b/examples/updaterplugin/packages/com.nokia.qtcreator/meta/installscript.js
new file mode 100644
index 000000000..d8f4a1572
--- /dev/null
+++ b/examples/updaterplugin/packages/com.nokia.qtcreator/meta/installscript.js
@@ -0,0 +1,50 @@
+function Component()
+{
+ if( installer.value( "os" ) == "win" )
+ {
+ component.addDownloadableArchive( "bin.7z" );
+ component.addDownloadableArchive( "installer.dll" );
+ component.addDownloadableArchive( "KDToolsCore2.dll" );
+ component.addDownloadableArchive( "KDUpdater2.dll" );
+ component.addDownloadableArchive( "lib.7z" );
+ component.addDownloadableArchive( "LICENSE" );
+ component.addDownloadableArchive( "Qt Creator.url" );
+ component.addDownloadableArchive( "share.7z" );
+ component.addDownloadableArchive( "uninst.exe" );
+ component.addDownloadableArchive( "Updater.dll" );
+ component.addDownloadableArchive( "Updater.pluginspec" );
+ }
+ else if( installer.value( "os" ) == "mac" )
+ {
+ component.addDownloadableArchive( "libUpdater.dylib" );
+ component.addDownloadableArchive( "Updater.pluginspec" );
+ component.addDownloadableArchive( "Qt Creator.app.7z" );
+ }
+}
+
+Component.prototype.createOperations = function( archive )
+{
+ if( installer.value( "os" ) == "win" )
+ {
+ component.createOperationsForArchive( "bin.7z" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/installer.dll", "@TargetDir@/bin/installer.dll" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/KDToolsCore2.dll", "@TargetDir@/bin/KDToolsCore2.dll" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/KDUpdater2.dll", "@TargetDir@/bin/KDUpdater2.dll" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/LICENSE", "@TargetDir@/LICENSE" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/Qt Creator.url", "@TargetDir@/Qt Creator.url" );
+ component.createOperationsForArchive( "lib.7z" );
+ component.createOperationsForArchive( "share.7z" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/uninst.exe", "@TargetDir@/uninst.exe" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/Updater.dll", "@TargetDir@/lib/qtcreator/plugins/Nokia/Updater.dll" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/Updater.pluginspec", "@TargetDir@/lib/qtcreator/plugins/Nokia/Updater.pluginspec" );
+ }
+ else if( installer.value( "os" ) == "mac" )
+ {
+ component.createOperationsForArchive( "Qt Creator.app.7z" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/libUpdater.dylib", "@TargetDir@/Qt Creator.app/Contents/PlugIns/Nokia/libUpdater.dylib" );
+ component.addOperation( "Copy", "installer://com.nokia.qtcreator/Updater.pluginspec", "@TargetDir@/Qt Creator.app/Contents/PlugIns/Nokia/Updater.pluginspec" );
+ }
+
+ if( installer.isUpdater() )
+ component.addOperation( "SelfRestart" );
+}
diff --git a/examples/updaterplugin/packages/com.nokia.qtcreator/meta/package.xml b/examples/updaterplugin/packages/com.nokia.qtcreator/meta/package.xml
new file mode 100644
index 000000000..21f06857b
--- /dev/null
+++ b/examples/updaterplugin/packages/com.nokia.qtcreator/meta/package.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<Package>
+ <DisplayName>Qt Creator</DisplayName>
+ <Description>Installs Qt Creator.</Description>
+ <Version>1</Version>
+ <ReleaseDate>2009-12-03</ReleaseDate>
+ <Name>com.nokia.qtcreator</Name>
+ <Script>installscript.js</Script>
+</Package>
diff --git a/examples/updaterplugin/updaterplugin.cpp b/examples/updaterplugin/updaterplugin.cpp
new file mode 100644
index 000000000..37ac72023
--- /dev/null
+++ b/examples/updaterplugin/updaterplugin.cpp
@@ -0,0 +1,256 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updaterplugin.h"
+
+#include <QAbstractButton>
+#include <QApplication>
+#include <QFileInfo>
+#include <QMessageBox>
+#include <QProgressDialog>
+#include <QStringList>
+#include <QtPlugin>
+
+#include "componentselectiondialog.h"
+#include "updateagent.h"
+#include "updatesettings.h"
+#include "updatesettingsdialog.h"
+
+#include "common/binaryformat.h"
+#include "common/binaryformatenginehandler.h"
+#include "common/errors.h"
+#include "common/installersettings.h"
+#include "init.h"
+#include "qinstaller.h"
+#include "updatersettingspage.h"
+
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/icore.h>
+
+#include <KDUpdater/Application>
+#include <KDUpdater/PackagesInfo>
+
+#include <KDToolsCore/KDAutoPointer>
+#include <KDToolsCore/KDSelfRestarter>
+
+using namespace Updater;
+using namespace Updater::Internal;
+using namespace QInstaller;
+
+class UpdaterPlugin::Private
+{
+public:
+ Private( UpdaterPlugin* qq )
+ : q( qq ),
+ agent( 0 )
+ {
+ QInstaller::init();
+ }
+
+private:
+ UpdaterPlugin* const q;
+
+public:
+ void checkForUpdates()
+ {
+ std::auto_ptr< QInstallerCreator::BinaryFormatEngineHandler > handler( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
+ handler->setComponentIndex( QInstallerCreator::ComponentIndex() );
+
+ UpdateSettings settings;
+
+ try
+ {
+ settings.setLastCheck( QDateTime::currentDateTime() );
+ installer.setRemoteRepositories( settings.repositories() );
+
+ // no updates for us
+ if( installer.components().isEmpty() )
+ {
+ QMessageBox::information( qApp->activeWindow(), tr( "Check for Updates" ), tr( "There are currently no updates available for you." ) );
+ return;
+ }
+
+ // set the target directory to the actual one
+ installer.setValue( QLatin1String( "TargetDir" ), QFileInfo( updaterapp.packagesInfo()->fileName() ).absolutePath() );
+
+ // this will automatically mork components as to get installed
+ ComponentSelectionDialog componentSelection( &installer );
+ if( componentSelection.exec() == QDialog::Rejected )
+ return;
+
+ QProgressDialog dialog;
+ dialog.setRange( 0, 100 );
+ dialog.show();
+ connect( &dialog, SIGNAL( canceled() ), &installer, SLOT( interrupt() ) );
+ connect( &installer, SIGNAL( installationProgressTextChanged( QString ) ), &dialog, SLOT( setLabelText( QString ) ) );
+ connect( &installer, SIGNAL( installationProgressChanged( int ) ), &dialog, SLOT( setValue( int ) ) );
+ installer.installSelectedComponents();
+ updatesInstalled();
+ }
+ catch( const QInstaller::Error& error )
+ {
+ QMessageBox::critical( qApp->activeWindow(), tr( "Check for Updates" ), tr( "Error while installing updates:\n%1" ).arg( error.what() ) );
+ installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ }
+ catch( ... )
+ {
+ QMessageBox::critical( qApp->activeWindow(), tr( "Check for Updates" ), tr( "Unknown error while installing updates." ) );
+ installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ }
+ }
+
+ void updatesAvailable()
+ {
+ KDAutoPointer< QMessageBox > box( new QMessageBox( qApp->activeWindow() ) );
+ box->setWindowTitle( tr( "Updates Available" ) );
+ box->setText( tr( "Software updates are available for your computer. Do you want to install them?" ) );
+ box->setStandardButtons( QMessageBox::Yes | QMessageBox::No );
+ box->button( QMessageBox::Yes )->setText( tr( "Continue" ) );
+ box->button( QMessageBox::No )->setText( tr( "Not Now" ) );
+ box->exec();
+ if ( !box )
+ return;
+ if ( box->clickedButton() == box->button( QMessageBox::Yes ) )
+ checkForUpdates();
+ }
+
+ void updatesInstalled()
+ {
+ // only ask that dumb question if a SelfUpdateOperation was executed
+ if( !KDSelfRestarter::restartOnQuit() )
+ {
+ QMessageBox::information( qApp->activeWindow(), tr( "Updates Installed" ), tr( "Installation complete." ) );
+ return;
+ }
+
+ KDAutoPointer< QMessageBox > box( new QMessageBox( qApp->activeWindow() ) );
+ box->setWindowTitle( tr( "Updates Installed" ) );
+ box->setText( tr( "Installation complete, you need to restart the application for the changes to take effect." ) );
+ box->setStandardButtons( QMessageBox::Yes | QMessageBox::No );
+ box->button( QMessageBox::Yes )->setText( tr( "Restart Now" ) );
+ box->button( QMessageBox::No )->setText( tr( "Restart Later" ) );
+ box->exec();
+ if ( !box )
+ return;
+ if ( box->clickedButton() == box->button( QMessageBox::Yes ) )
+ QCoreApplication::quit();
+ else
+ KDSelfRestarter::setRestartOnQuit( false );
+ }
+
+ void configureUpdater()
+ {
+ UpdateSettingsDialog dialog( qApp->activeWindow() );
+ connect( &dialog, SIGNAL( checkForUpdates() ), q, SLOT( checkForUpdates() ), Qt::QueuedConnection );
+ dialog.exec();
+ }
+
+ KDUpdater::Application updaterapp;
+ Installer installer;
+ UpdateAgent* agent;
+};
+
+UpdaterPlugin::UpdaterPlugin()
+ : d( new Private( this ) )
+{
+ if( !KDSelfRestarter::hasInstance() )
+ {
+ const KDSelfRestarter* const restarter = new KDSelfRestarter;
+ Q_UNUSED( restarter )
+ }
+}
+
+UpdaterPlugin::~UpdaterPlugin()
+{
+}
+
+/*!
+ \reimpl
+*/
+bool UpdaterPlugin::initialize( const QStringList& arguments, QString* error_message )
+{
+ Q_UNUSED( arguments )
+
+ try
+ {
+ InstallerSettings::fromFileAndPrefix( QLatin1String( ":/metadata/installer-config/config.xml" ), QLatin1String( ":/metadata/installer-config/" ) );
+ }
+ catch ( const Error& e )
+ {
+ if( error_message )
+ *error_message = e.message();
+ return false;
+ }
+
+
+ Core::ActionManager* const am = Core::ICore::instance()->actionManager();
+ Core::ActionContainer* const ac = am->actionContainer( Core::Constants::M_FILE );
+
+ UpdateSettings::setSettingsSource( Core::ICore::instance()->settings() );
+
+ d->agent = new UpdateAgent( this );
+
+ QAction* const checkForUpdates = ac->menu()->addAction( tr( "Check for Updates" ), this, SLOT( checkForUpdates() ) );
+ checkForUpdates->setMenuRole( QAction::ApplicationSpecificRole );
+
+ QAction* const updateSettings = ac->menu()->addAction( tr( "Updater Settings" ), this, SLOT( configureUpdater() ) );
+ updateSettings->setMenuRole( QAction::ApplicationSpecificRole );
+
+ UpdaterSettingsPage* const page = new UpdaterSettingsPage;
+ connect( page, SIGNAL( checkForUpdates() ), this, SLOT( checkForUpdates() ) );
+ addAutoReleasedObject( page );
+
+ if( error_message )
+ error_message->clear();
+ return true;
+}
+
+/*!
+ \reimpl
+*/
+void UpdaterPlugin::shutdown()
+{
+}
+
+/*!
+ \reimpl
+*/
+void UpdaterPlugin::extensionsInitialized()
+{
+}
+
+#include "moc_updaterplugin.cpp"
+
+Q_EXPORT_PLUGIN( UpdaterPlugin )
diff --git a/examples/updaterplugin/updaterplugin.h b/examples/updaterplugin/updaterplugin.h
new file mode 100644
index 000000000..e3c3a69b0
--- /dev/null
+++ b/examples/updaterplugin/updaterplugin.h
@@ -0,0 +1,61 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef UPDATERPLUGIN_H
+#define UPDATERPLUGIN_H
+
+#include <extensionsystem/iplugin.h>
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+namespace Updater
+{
+namespace Internal
+{
+class UpdaterPlugin : public ExtensionSystem::IPlugin
+{
+ Q_OBJECT
+
+public:
+ UpdaterPlugin();
+ ~UpdaterPlugin();
+
+protected:
+ // implementation of ExtensionSystem::IPlugin
+ bool initialize( const QStringList& arguments, QString* error_message );
+ void shutdown();
+ void extensionsInitialized();
+
+private:
+ Q_PRIVATE_SLOT( d, void checkForUpdates() )
+ Q_PRIVATE_SLOT( d, void configureUpdater() )
+
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+}
+}
+
+#endif
diff --git a/examples/updaterplugin/updaterplugin.pro b/examples/updaterplugin/updaterplugin.pro
new file mode 100644
index 000000000..14af657fa
--- /dev/null
+++ b/examples/updaterplugin/updaterplugin.pro
@@ -0,0 +1,37 @@
+TEMPLATE = lib
+TARGET = Updater
+
+include( ../../installerbuilder/libinstaller/libinstaller.pri )
+
+# maybe wo should not build a static plugin for Qt Creator
+CONFIG -= static
+CONFIG -= staticlib
+CONFIG += shared
+
+#PROVIDER = KDAB
+IDE_PLUGIN_PATH = PlugInst
+
+IDE_BUILD_TREE = "$$(QTCREATOR_SOURCE_PATH)"
+include($$(QTCREATOR_SOURCE_PATH)/src/qtcreatorplugin.pri)
+include($$(QTCREATOR_SOURCE_PATH)/src/libs/extensionsystem/extensionsystem.pri)
+include($$(QTCREATOR_SOURCE_PATH)/src/plugins/coreplugin/coreplugin.pri)
+
+QT += gui
+
+CONFIG += uitools
+
+LIBS = -L../../installerbuilder/lib -linstaller $$LIBS
+
+DEST=$$DESTDIR/libUpdater.dylib
+# this will make sure we are using the Qt from the QtCreater.app bundle
+ddlib="$"$lib
+macx:QMAKE_POST_LINK = for lib in `otool -L \"$${DEST}\" | sed -ne \'s,.*\\(libQt[^ ]*\\).*,\1,p\'`; do install_name_tool -change $$[QT_INSTALL_LIBS]/$${ddlib} @executable_path/../Frameworks/$${ddlib} \"$${DEST}\"; done;
+macx:QMAKE_POST_LINK += ../../installerbuilder/bin/binarycreator -p packages -c config -t ../../installerbuilder/bin/installerbase -e com.nokia.qtcreator QtCreatorInstaller.app com.nokia.qtcreator ;
+
+SOURCES += updaterplugin.cpp updatersettingspage.cpp
+
+HEADERS += updaterplugin.h updatersettingspage.h
+
+RESOURCES += updaterplugin.qrc
+
+OTHER_FILES += Updater.pluginspec
diff --git a/examples/updaterplugin/updaterplugin.qrc b/examples/updaterplugin/updaterplugin.qrc
new file mode 100644
index 000000000..962b28d51
--- /dev/null
+++ b/examples/updaterplugin/updaterplugin.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/metadata/installer-config">
+ <file>config.xml</file>
+ </qresource>
+</RCC>
diff --git a/examples/updaterplugin/updatersettingspage.cpp b/examples/updaterplugin/updatersettingspage.cpp
new file mode 100644
index 000000000..bf8ae9344
--- /dev/null
+++ b/examples/updaterplugin/updatersettingspage.cpp
@@ -0,0 +1,125 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updatersettingspage.h"
+
+#include "updatesettingswidget.h"
+
+#include <KDToolsCore/KDAutoPointer>
+
+using namespace QInstaller;
+
+class UpdaterSettingsPage::Private
+{
+public:
+ Private()
+ : widget( 0 )
+ {
+ }
+
+ KDAutoPointer< UpdateSettingsWidget > widget;
+};
+
+UpdaterSettingsPage::UpdaterSettingsPage( QObject* parent )
+ : Core::IOptionsPage( parent )
+{
+}
+
+UpdaterSettingsPage::~UpdaterSettingsPage()
+{
+}
+
+/*!
+ \reimpl
+*/
+QString UpdaterSettingsPage::id() const
+{
+ return QLatin1String( "UpdaterSettings" );
+}
+
+/*!
+ \reimpl
+*/
+QString UpdaterSettingsPage::trName() const
+{
+ return tr( "Updater Settings" );
+}
+
+/*!
+ \reimpl
+*/
+QString UpdaterSettingsPage::category() const
+{
+ return QLatin1String( "General" );
+}
+
+/*!
+ \reimpl
+*/
+QString UpdaterSettingsPage::trCategory() const
+{
+ return displayCategory();
+}
+
+/*!
+ \reimpl
+ */
+QString UpdaterSettingsPage::displayCategory() const
+{
+ return tr( "General" );
+}
+
+/*!
+ \reimpl
+*/
+QWidget* UpdaterSettingsPage::createPage( QWidget* parent )
+{
+ d->widget.reset( new UpdateSettingsWidget( parent ) );
+ connect( d->widget.get(), SIGNAL( checkForUpdates() ), this, SIGNAL( checkForUpdates() ) );
+ return d->widget.get();
+}
+
+/*!
+ \reimpl
+*/
+void UpdaterSettingsPage::apply()
+{
+ d->widget->accept();
+}
+
+/*!
+ \reimpl
+*/
+void UpdaterSettingsPage::finish()
+{
+ d->widget.reset();
+}
diff --git a/examples/updaterplugin/updatersettingspage.h b/examples/updaterplugin/updatersettingspage.h
new file mode 100644
index 000000000..c9bfce65c
--- /dev/null
+++ b/examples/updaterplugin/updatersettingspage.h
@@ -0,0 +1,59 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef UPDATERSETTINGSPAGE_H
+#define UPDATERSETTINGSPAGE_H
+
+#include <coreplugin/dialogs/ioptionspage.h>
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+class UpdaterSettingsPage : public Core::IOptionsPage
+{
+ Q_OBJECT
+public:
+ explicit UpdaterSettingsPage( QObject* parent = 0 );
+ ~UpdaterSettingsPage();
+
+ QString id() const;
+ QString trName() const;
+ QString category() const;
+ QString displayCategory() const;
+ QString trCategory() const;
+
+ QWidget* createPage( QWidget* parent );
+
+ void apply();
+ void finish();
+
+Q_SIGNALS:
+ void checkForUpdates();
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+#endif
diff --git a/installerbuilder/archivegen/archive.cpp b/installerbuilder/archivegen/archive.cpp
new file mode 100644
index 000000000..0e473b867
--- /dev/null
+++ b/installerbuilder/archivegen/archive.cpp
@@ -0,0 +1,82 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <common/errors.h>
+#include <common/utils.h>
+#include <common/repositorygen.h>
+#include <common/installersettings.h>
+
+#include "lib7z_facade.h"
+#include "init.h"
+
+#include <QCoreApplication>
+#include <QFileInfo>
+#include <QString>
+#include <QStringList>
+
+#include <iostream>
+
+using namespace QInstaller;
+using namespace Lib7z;
+
+static void printUsage()
+{
+ const QString appName = QFileInfo( QCoreApplication::applicationFilePath() ).fileName();
+ std::cout << "Usage: " << appName << " directory archive.7z" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Example:" << std::endl;
+ std::cout << " " << appName << " someDirectory foobar.7z" << std::endl;
+}
+
+int main(int argc, char **argv)
+{
+ try {
+ QCoreApplication app(argc, argv);
+ init();
+
+ setVerbose( true );
+
+ if( app.arguments().count() < 3 )
+ {
+ printUsage();
+ return 1;
+ }
+
+ QInstaller::compressDirectory(app.arguments().at(1), app.arguments().at(2));
+ return 0;
+ } catch ( const Lib7z::SevenZipException& e ) {
+ std::cerr << e.message() << std::endl;
+ } catch ( const QInstaller::Error& e ) {
+ std::cerr << e.message() << std::endl;
+ }
+ return 1;
+}
diff --git a/installerbuilder/archivegen/archivegen.pro b/installerbuilder/archivegen/archivegen.pro
new file mode 100644
index 000000000..6ee903da7
--- /dev/null
+++ b/installerbuilder/archivegen/archivegen.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = archivegen
+DEPENDPATH += . .. ../common
+INCLUDEPATH += . ..
+
+DESTDIR = ../bin
+
+CONFIG += console
+CONFIG -= app_bundle
+
+QT += xml
+
+include(../libinstaller/libinstaller.pri)
+
+# Input
+SOURCES += archive.cpp \
+ ../common/repositorygen.cpp
+HEADERS += ../common/repositorygen.h
diff --git a/installerbuilder/binarycreator/binarycreator.cpp b/installerbuilder/binarycreator/binarycreator.cpp
new file mode 100644
index 000000000..de80a8715
--- /dev/null
+++ b/installerbuilder/binarycreator/binarycreator.cpp
@@ -0,0 +1,698 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <common/repositorygen.h>
+#include <common/errors.h>
+#include <common/binaryformat.h>
+#include <common/installersettings.h>
+#include <common/fileutils.h>
+#include <common/utils.h>
+#include <common/consolepasswordprovider.h>
+
+#include <KDToolsCore/KDSaveFile>
+#include <KDUpdater/KDUpdater>
+
+#include <QCoreApplication>
+#include <QDebug>
+#include <QDir>
+#include <QDirIterator>
+#include <QDomAttr>
+#include <QDomDocument>
+#include <QFile>
+#include <QFileInfo>
+#include <QSettings>
+#include <QTemporaryFile>
+#include <QVector>
+
+#include <fstream>
+#include <iostream>
+
+#ifndef Q_WS_WIN
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
+#include "init.h"
+
+using namespace QInstaller;
+using namespace QInstallerCreator;
+
+typedef QVector<PackageInfo> PackageInfoVector;
+
+struct Input {
+ QString installerExePath;
+ QString outputPath;
+ QString binaryResourcePath;
+ ComponentIndex components;
+ Range<qint64> componentIndexSegment;
+ Range<qint64> resourcePos;
+ Range<qint64> operationsPos;
+};
+
+class BundleBackup
+{
+public:
+ explicit BundleBackup(const QString &bundle = QString())
+ : bundle(bundle)
+ {
+ if (!bundle.isEmpty() && QFileInfo(bundle).exists()) {
+ backup = generateTemporaryFileName(bundle);
+ QFile::rename(bundle, backup);
+ }
+ }
+ ~BundleBackup()
+ {
+ if (!backup.isEmpty()) {
+ removeDirectory(bundle);
+ QFile::rename(backup, bundle);
+ }
+ }
+
+ void release() const {
+ if (!backup.isEmpty())
+ removeDirectory(backup);
+ backup.clear();
+ }
+
+private:
+ const QString bundle;
+ mutable QString backup;
+};
+
+static int assemble(Input input, const QString &configdir)
+{
+ const QString configfile = QFileInfo(configdir, QLatin1String("config.xml")).absoluteFilePath();
+ const QInstaller::InstallerSettings settings =
+ QInstaller::InstallerSettings::fromFileAndPrefix(configfile, configdir);
+
+#ifdef Q_WS_MAC
+ if (QFileInfo(input.installerExePath).isBundle()) {
+ const QString bundle = input.installerExePath;
+ // if the input file was a bundle
+ const QSettings s(QString::fromLatin1("%1/Contents/Info.plist").arg(input.installerExePath),
+ QSettings::NativeFormat);
+ input.installerExePath = QString::fromLatin1("%1/Contents/MacOS/%2").arg(bundle)
+ .arg(s.value(QLatin1String("CFBundleExecutable"),
+ QFileInfo(input.installerExePath).baseName()).toString());
+ }
+
+ const bool createDMG = input.outputPath.endsWith(QLatin1String(".dmg"));
+ if (createDMG)
+ input.outputPath.replace(input.outputPath.length() - 4, 4, QLatin1String(".app"));
+
+ const bool isBundle = input.outputPath.endsWith(QLatin1String(".app"));
+ const QString bundle = isBundle ? input.outputPath : QString();
+ const BundleBackup bundleBackup(bundle);
+
+ if (isBundle) {
+ // output should be a bundle
+ const QFileInfo fi(input.outputPath);
+ QInstaller::mkpath(fi.filePath() + QLatin1String("/Contents/MacOS"));
+ QInstaller::mkpath(fi.filePath() + QLatin1String("/Contents/Resources"));
+
+ QFile pkgInfo(fi.filePath() + QLatin1String("/Contents/PkgInfo"));
+ pkgInfo.open(QIODevice::WriteOnly);
+ QTextStream pkgInfoStream(&pkgInfo);
+ pkgInfoStream << QLatin1String("APPL????") << endl;
+
+ const QString iconFile = QFile::exists(settings.icon()) ? settings.icon()
+ : QString::fromLatin1(":/resources/default_icon_mac.icns");
+ const QString iconTargetFile = fi.baseName() + QLatin1String(".icns");
+ QFile::copy(iconFile, fi.filePath() + QLatin1String("/Contents/Resources/") + iconTargetFile);
+
+ QFile infoPList(fi.filePath() + QLatin1String("/Contents/Info.plist"));
+ infoPList.open(QIODevice::WriteOnly);
+ QTextStream plistStream(&infoPList);
+ plistStream << QLatin1String("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") << endl;
+ plistStream << QLatin1String("<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs"
+ "/PropertyList.dtd\">") << endl;
+ plistStream << QLatin1String("<plist version=\"0.9\">") << endl;
+ plistStream << QLatin1String("<dict>") << endl;
+ plistStream << QLatin1String(" <key>CFBundleIconFile</key>") << endl;
+ plistStream << QLatin1String(" <string>") << iconTargetFile << QLatin1String("</string>")
+ << endl;
+ plistStream << QLatin1String(" <key>CFBundlePackageType</key>") << endl;
+ plistStream << QLatin1String(" <string>APPL</string>") << endl;
+ plistStream << QLatin1String(" <key>CFBundleGetInfoString</key>") << endl;
+ plistStream << QLatin1String(" <string>Created by Qt/QMake</string>") << endl;
+ plistStream << QLatin1String(" <key>CFBundleSignature</key>") << endl;
+ plistStream << QLatin1String(" <string> ???? </string>") << endl;
+ plistStream << QLatin1String(" <key>CFBundleExecutable</key>") << endl;
+ plistStream << QLatin1String(" <string>") << fi.baseName() << QLatin1String("</string>")
+ << endl;
+ plistStream << QLatin1String(" <key>CFBundleIdentifier</key>") << endl;
+ plistStream << QLatin1String(" <string>com.yourcompany.installerbase</string>") << endl;
+ plistStream << QLatin1String(" <key>NOTE</key>") << endl;
+ plistStream << QLatin1String(" <string>This file was generated by Qt/QMake.</string>")
+ << endl;
+ plistStream << QLatin1String("</dict>") << endl;
+ plistStream << QLatin1String("</plist>") << endl;
+
+ input.outputPath = QString::fromLatin1("%1/Contents/MacOS/%2").arg(input.outputPath)
+ .arg(fi.baseName());
+ }
+#endif
+
+ QTemporaryFile file(input.outputPath);
+ if (!file.open()) {
+ throw Error(QObject::tr("Could not copy %1 to %2: %3").arg(input.installerExePath,
+ input.outputPath, file.errorString()));
+ }
+
+ const QString tempFile = file.fileName();
+ file.close();
+ file.remove();
+
+ QFile instExe(input.installerExePath);
+ if (!instExe.copy(tempFile)) {
+ throw Error(QObject::tr("Could not copy %1 to %2: %3").arg(instExe.fileName(), tempFile,
+ instExe.errorString()));
+ }
+ input.installerExePath = tempFile;
+
+#if defined(Q_OS_WIN)
+ // setting the windows icon must happen before we append our binary data - otherwise they get lost :-/
+ if (QFile::exists(settings.icon())) {
+ // no error handling as this is not fatal
+ setApplicationIcon(tempFile, settings.icon());
+ }
+#elif defined(Q_WS_MAC)
+ if (isBundle) {
+ // no error handling as this is not fatal
+ const QString copyscript = QDir::temp().absoluteFilePath(QLatin1String("copylibsintobundle.sh"));
+ QFile::copy(QLatin1String(":/resources/copylibsintobundle.sh"), copyscript);
+ QFile::rename(tempFile, input.outputPath);
+ ::chmod(qPrintable(copyscript), 0755);
+ QProcess p;
+ p.start(copyscript, QStringList() << bundle);
+ p.waitForFinished();
+ QFile::rename(input.outputPath, tempFile);
+ QFile::remove(copyscript);
+ }
+#endif
+
+ KDSaveFile out(input.outputPath);
+ try {
+ openForWrite(&out, input.outputPath);
+
+ QFile exe(input.installerExePath);
+ openForRead(&exe, exe.fileName());
+ appendFileData(&out, &exe);
+
+ const qint64 dataBlockStart = out.pos();
+ verbose() << "Data block starts at " << dataBlockStart << std::endl;
+ QFile res(input.binaryResourcePath);
+ openForRead(&res, res.fileName());
+ appendFileData(&out, &res);
+ input.resourcePos = Range<qint64>::fromStartAndEnd(out.pos() - res.size(), out.pos())
+ .moved(-dataBlockStart);
+
+ // zero operations cause we are not the uninstaller
+ const qint64 operationsStart = out.pos();
+ appendInt64(&out, 0);
+ appendInt64(&out, 0);
+ input.operationsPos = Range<qint64>::fromStartAndEnd(operationsStart, out.pos())
+ .moved(-dataBlockStart);
+
+ // component index:
+ input.components.writeComponentData(&out, -dataBlockStart);
+ const qint64 compIndexStart = out.pos() - dataBlockStart;
+ input.components.writeIndex(&out, -dataBlockStart);
+ input.componentIndexSegment = Range<qint64>::fromStartAndEnd(compIndexStart, out.pos()
+ - dataBlockStart);
+
+ verbose() << "Component index: [" << input.componentIndexSegment.start() << ":"
+ << input.componentIndexSegment.end() << "]" << std::endl;
+ appendInt64Range(&out, input.componentIndexSegment);
+ appendInt64Range(&out, input.resourcePos);
+ appendInt64Range(&out, input.operationsPos);
+ appendInt64(&out, 1); // we have just 1 resource atm
+
+ //data block size, from end of .exe to end of file
+ appendInt64(&out, out.pos() + 3 * sizeof(qint64) - dataBlockStart);
+ appendInt64(&out, QInstaller::MagicInstallerMarker);
+ appendInt64(&out, QInstaller::MagicCookie);
+
+ } catch (const Error &e) {
+ qCritical("Error occurred while assembling the installer: %s", qPrintable(e.message()));
+ QFile::remove(tempFile);
+ return 1;
+ }
+
+ if (!out.commit(KDSaveFile::OverwriteExistingFile)) {
+ qCritical("Could not write installer to %s: %s", qPrintable(out.fileName()),
+ qPrintable(out.errorString()));
+ QFile::remove(tempFile);
+ return 1;
+ }
+#ifndef Q_OS_WIN
+ ::chmod(qPrintable(out.fileName()), 0755);
+#endif
+ QFile::remove(tempFile);
+
+#ifdef Q_WS_MAC
+ bundleBackup.release();
+
+ if (createDMG) {
+ verbose() << "creating a DMG disk image...";
+ // no error handling as this is not fatal
+ const QString mkdmgscript = QDir::temp().absoluteFilePath(QLatin1String("mkdmg.sh"));
+ QFile::copy(QLatin1String(":/resources/mkdmg.sh"), mkdmgscript);
+ ::chmod(qPrintable(mkdmgscript), 0755);
+ QProcess p;
+ p.start(mkdmgscript, QStringList() << QFileInfo(out.fileName()).baseName() << bundle);
+ p.waitForFinished();
+ QFile::remove(mkdmgscript);
+ verbose() << "done." << mkdmgscript << std::endl;
+ }
+#endif
+
+ return 0;
+}
+
+QT_BEGIN_NAMESPACE
+int runRcc(int argc, char *argv[]);
+QT_END_NAMESPACE
+
+static int runRcc(const QStringList &args)
+{
+ const int argc = args.count();
+ QVector<char*> argv(argc, 0);
+ for (int i = 0; i < argc; ++i)
+ argv[i] = qstrdup(qPrintable(args[i]));
+
+ const int result = runRcc(argc, argv.data());
+
+ for (int i = 0; i < argc; ++i)
+ delete [] argv[i];
+
+ return result;
+}
+
+class WorkingDirectoryChange
+{
+public:
+ explicit WorkingDirectoryChange(const QString& path)
+ : oldPath(QDir::currentPath())
+ {
+ QDir::setCurrent(path);
+ }
+
+ virtual ~WorkingDirectoryChange()
+ {
+ QDir::setCurrent(oldPath);
+ }
+
+private:
+ const QString oldPath;
+};
+
+static QString createBinaryResourceFile(const QString &directory)
+{
+ QTemporaryFile projectFile(directory + QString::fromLatin1("/rccprojectXXXXXX.qrc"));
+ if (!projectFile.open())
+ throw Error(QObject::tr("Could not create temporary file for generated rcc project file"));
+ const QString projectFileName = QFileInfo(projectFile.fileName()).absoluteFilePath();
+ projectFile.close();
+
+ const QString binaryName = generateTemporaryFileName();
+
+ const WorkingDirectoryChange wd(directory);
+
+ // 1. create the .qrc file
+ runRcc(QStringList() << QString::fromLatin1("rcc") << QString::fromLatin1("-project")
+ << QString::fromLatin1("-o") << projectFileName);
+
+ // 2. create the binary resource file from the .qrc file
+ runRcc(QStringList() << QString::fromLatin1("rcc") << QString::fromLatin1("-binary")
+ << QString::fromLatin1("-o") << binaryName << projectFileName);
+
+ return binaryName;
+}
+
+static void printUsage()
+{
+ const QString appName = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
+ std::cout << "Usage: " << appName << " [options] target package1 [package2 ...]" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Options:" << std::endl;
+ std::cout << " -t|--template file Use file as installer template binary" << std::endl;
+ std::cout << " If this parameter is not given, the template used"
+ << std::endl;
+ std::cout << " defaults to installerbase" << std::endl;
+ std::cout << " -p|--packages dir The directory containing the available packages."
+ << std::endl;
+ std::cout << " Defaults to the current working directory." << std::endl;
+ std::cout << " -c|--config dir The directory containing the installer configuration "
+ "files to use." << std::endl;
+ std::cout << " Mandatory." << std::endl;
+ std::cout << " -n|--nodeps Don't add dependencies of package1...n into the "
+ "installer (for online installers)" << std::endl;
+ std::cout << " -e|--exclude p1,...,pn exclude the given packages and their dependencies from "
+ "the binary (for online installers)" << std::endl;
+ std::cout << " --offline-only Forces the installer to act as an offline installer, "
+ "i.e. never access online repositories" << std::endl;
+ std::cout << " -v|--verbose Verbose output" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Packages are to be found in the current working directory and get listed as "
+ "their names" << std::endl << std::endl;
+ std::cout << "Example (offline installer):" << std::endl;
+ std::cout << " " << appName << " -c installer-config -t installerbase SDKInstaller.exe "
+ "com.nokia.sdk" << std::endl;
+ std::cout << "Creates an offline installer for the SDK, containing all dependencies." << std::endl;
+ std::cout << std::endl;
+ std::cout << "Example (online installer):" << std::endl;
+ std::cout << " " << appName << " -c installer-config -t installerbase -e com.nokia.sdk.qt,"
+ "com.nokia.qtcreator SDKInstaller.exe com.nokia.sdk" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Creates an installer for the SDK without qt and qt creator." << std::endl;
+ std::cout << std::endl;
+}
+
+static QString createMetaDataDirectory(const PackageInfoVector &packages,
+ const QString &packagesDir, const QString &configdir)
+{
+ const QString configfile = QFileInfo(configdir, "config.xml").absoluteFilePath();
+ const QInstaller::InstallerSettings settings =
+ QInstaller::InstallerSettings::fromFileAndPrefix(configfile, QString());
+
+ const QString metapath = createTemporaryDirectory();
+ generateMetaDataDirectory(metapath, packagesDir, packages, settings.applicationName(),
+ settings.applicationVersion());
+
+ const QString configCopy = metapath + QLatin1String("/installer-config");
+ QInstaller::mkdir(configCopy);
+ QString absoluteConfigPath = QFileInfo(configdir).absoluteFilePath();
+
+ QDirIterator it(absoluteConfigPath, QDir::Files | QDir::NoDotAndDotDot,
+ QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ const QString next = it.next();
+ if (next.contains("/.")) // skip files that are in directories starting with a point
+ continue;
+
+ verbose() << " Found configuration file: " << next << std::endl;
+ const QFileInfo sourceFileInfo(next);
+ const QString source = sourceFileInfo.absoluteFilePath();
+ const QFileInfo targetFileInfo(configCopy, QFileInfo(next).fileName());
+ const QDir targetDir = targetFileInfo.dir();
+ if (!targetDir.exists())
+ QInstaller::mkpath(targetFileInfo.absolutePath());
+ const QString target = targetFileInfo.absoluteFilePath();
+
+ if (!QFile::copy(source, target))
+ throw Error(QObject::tr("Could not copy %1.").arg(source));
+
+ if (sourceFileInfo.fileName().toLower() == QLatin1String("config.xml")) {
+ // if we just copied the config.xml, make sure to remove the RSA private key from it :-o
+ QFile configXml(targetDir.filePath(QLatin1String("config.xml")));
+ configXml.open(QIODevice::ReadOnly);
+ QDomDocument dom;
+ dom.setContent(&configXml);
+ configXml.close();
+ QDomElement doc = dom.documentElement();
+ QDomElement privateKey = doc.elementsByTagName(QLatin1String("PrivateKey")).item(0).toElement();
+ if (!privateKey.isNull()) {
+ verbose() << " It contains the RSA private key, removing it...";
+ if (doc.removeChild(privateKey).isNull())
+ throw Error(QObject::tr("Could not remove the private key from config.xml"));
+ }
+
+ // afterward, iterater over all child elements, searching for relative file names
+ const QDomNodeList children = doc.childNodes();
+ for (int i = 0; i < children.count(); ++i) {
+ QDomElement el = children.at(i).toElement();
+ if (el.isNull())
+ continue;
+
+ QFileInfo fi(absoluteConfigPath, el.text());
+#if defined(Q_WS_MAC)
+ const QFileInfo fiIcon(absoluteConfigPath, el.text() + QLatin1String(".icns"));
+#elif defined(Q_WS_WIN)
+ const QFileInfo fiIcon(absoluteConfigPath, el.text() + QLatin1String(".ico"));
+#else
+ const QFileInfo fiIcon(absoluteConfigPath, el.text() + QLatin1String(".png"));
+#endif
+ if (!fi.exists() && fiIcon.exists())
+ fi = fiIcon;
+
+ if (!fi.exists() || fi.absolutePath() == QFileInfo(configdir).dir().absolutePath())
+ continue;
+
+ if (fi.isDir())
+ continue;
+
+ const QString newName = el.text().replace(QRegExp(QLatin1String("\\\\|/|\\.")),
+ QLatin1String("_"));
+
+ if (!QFile::exists(targetDir.absoluteFilePath(newName))) {
+ if (!QFile::copy(fi.absoluteFilePath(), targetDir.absoluteFilePath(newName)))
+ throw Error(QObject::tr("Could not copy %1.").arg(el.text()));
+ }
+ el.removeChild(el.firstChild());
+ el.appendChild(dom.createTextNode(newName));
+ }
+
+ openForWrite(&configXml, configXml.fileName());
+ QTextStream stream(&configXml);
+ dom.save(stream, 4);
+ verbose() << " done." << std::endl;
+ }
+ }
+ return metapath;
+}
+
+static int printErrorAndUsageAndExit(const QString &err)
+{
+ std::cerr << qPrintable(err) << std::endl << std::endl;
+ printUsage();
+ return 1;
+}
+
+static PackageInfoVector filterBlacklisted(PackageInfoVector packages, const QStringList &blacklist)
+{
+ for (int i = packages.size() - 1; i >= 0; --i)
+ if (blacklist.contains(packages[i].name))
+ packages.remove(i);
+ return packages;
+}
+
+/**
+ * Usage:
+ * binarycreator: [--help|-h] [-p|--packages packages directory] [-t|--template binary]
+ * -c|--config confdir target component ...
+ *
+ * template defaults to installerbase[.exe] in the same directory
+ */
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ init();
+
+ const QStringList args = app.arguments().mid(1);
+ QStringList components;
+#ifdef Q_WS_WIN
+ QString templateBinary = QString::fromLatin1("installerbase.exe");
+#else
+ QString templateBinary = QString::fromLatin1("installerbase");
+#endif
+ QString target;
+ QString confdir;
+ QString packagesDirectory = QDir::currentPath();
+ QStringList excludedPackages;
+ bool nodeps = false;
+ bool offlineOnly = false;
+
+ for (QStringList::const_iterator it = args.begin(); it != args.end(); ++it) {
+ if (*it == QString::fromLatin1("-h") || *it == QString::fromLatin1("--help")) {
+ printUsage();
+ return 0;
+ } else if (*it == QString::fromLatin1("-p") || *it == QString::fromLatin1("--packages")) {
+ ++it;
+ if (it == args.end()) {
+ return printErrorAndUsageAndExit(QObject::tr("Error: Packages parameter missing "
+ "argument"));
+ }
+ if (!QFileInfo(*it).exists()) {
+ return printErrorAndUsageAndExit(QObject::tr("Error: Package directory not found "
+ "at the specified location"));
+ }
+ packagesDirectory = *it;
+ } else if (*it == QLatin1String("-e") || *it == QLatin1String("--exclude")) {
+ ++it;
+ if (it == args.end() || it->startsWith(QLatin1String("-")))
+ return printErrorAndUsageAndExit(QObject::tr("Error: Package to exclude missing"));
+ excludedPackages = it->split(QLatin1Char(','));
+ } else if (*it == QString::fromLatin1("-v") || *it == QString::fromLatin1("--verbose")) {
+ setVerbose(true);
+ } else if (*it == QString::fromLatin1("-n") || *it == QString::fromLatin1("--nodeps")) {
+ nodeps = true;
+ } else if (*it == QString::fromLatin1("--offline-only")) {
+ offlineOnly = true;
+ } else if (*it == QString::fromLatin1("-t") || *it == QString::fromLatin1("--template")) {
+ ++it;
+ if (it == args.end()) {
+ return printErrorAndUsageAndExit(QObject::tr("Error: Template parameter missing "
+ "argument"));
+ }
+ if (!QFileInfo(*it).exists()) {
+ return printErrorAndUsageAndExit(QObject::tr("Error: Template not found at the "
+ "specified location"));
+ }
+ templateBinary = *it;
+ } else if (*it == QLatin1String("-c") || *it == QLatin1String("--config")) {
+ ++it;
+ if (it == args.end())
+ return printErrorAndUsageAndExit(QObject::tr("Error: Config parameter missing argument"));
+ const QFileInfo fi(*it);
+ if (!fi.exists()) {
+ return printErrorAndUsageAndExit(QObject::tr("Error: Config directory %1 not found "
+ "at the specified location").arg(*it));
+ }
+ if (!fi.isDir()) {
+ return printErrorAndUsageAndExit(QObject::tr("Error: Configuration %1 is not a "
+ "directory").arg(*it));
+ }
+ if (!fi.isReadable()) {
+ return printErrorAndUsageAndExit(QObject::tr("Error: Config directory %1 is not "
+ "readable").arg(*it));
+ }
+ confdir = *it;
+ } else {
+ if (target.isEmpty())
+ target = *it;
+ else
+ components.push_back(*it);
+ }
+ }
+
+ if (target.isEmpty())
+ return printErrorAndUsageAndExit(QObject::tr("Error: Target parameter missing"));
+
+ if (components.isEmpty())
+ return printErrorAndUsageAndExit(QObject::tr("Error: No components selected"));
+
+ if (confdir.isEmpty())
+ return printErrorAndUsageAndExit(QObject::tr("Error: No configuration directory selected"));
+
+ verbose() << "Parsed arguments, ok." << std::endl;
+
+ try {
+ const PackageInfoVector packageList = createListOfPackages(components, packagesDirectory,
+ !nodeps);
+ const PackageInfoVector packages = filterBlacklisted(packageList, excludedPackages);
+ const QString metaDir = createMetaDataDirectory(packages, packagesDirectory, confdir);
+ {
+ QSettings confInternal(metaDir + "/config/config-internal.ini", QSettings::IniFormat);
+ confInternal.setValue(QLatin1String("offlineOnly"), offlineOnly);
+ }
+ const QString resourceFile = createBinaryResourceFile(metaDir);
+
+ const QString configfile = QFileInfo(confdir, QLatin1String("config.xml")).absoluteFilePath();
+ const QInstaller::InstallerSettings settings =
+ QInstaller::InstallerSettings::fromFileAndPrefix(configfile, confdir);
+ const QByteArray privateKey = settings.privateKey();
+
+ Input input;
+ input.installerExePath = templateBinary;
+ input.binaryResourcePath = resourceFile;
+ input.outputPath = target;
+#if defined(Q_WS_MAC)
+ // on mac, we enforce building a bundle
+ if (!input.outputPath.endsWith(QLatin1String(".app"))
+ && !input.outputPath.endsWith(QLatin1String(".dmg"))) {
+ input.outputPath += QLatin1String(".app");
+ }
+#elif defined(Q_WS_WIN)
+ // on windows, we add .exe
+ if (!input.outputPath.endsWith(QLatin1String(".exe")))
+ input.outputPath += QLatin1String(".exe");
+#endif
+
+ KDUpdaterCrypto crypto;
+ crypto.setPrivateKey(privateKey);
+ ConsolePasswordProvider passwordProvider;
+ crypto.setPrivatePasswordProvider(&passwordProvider);
+ crypto.setPublicKey(settings.publicKey());
+
+ // now put the packages into the components section of the binary:
+ for (PackageInfoVector::const_iterator it = packages.begin(); it != packages.end(); ++it) {
+ verbose() << "Creating component info for " << it->name << std::endl;
+
+ Component comp;
+ comp.setName(it->name.toUtf8());
+ // append everything within the data directory
+ const QFileInfoList archives = QDir(QString::fromLatin1("%1/data").arg(it->directory))
+ .entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files);
+ Q_FOREACH(const QFileInfo &archive, archives) {
+ const QSharedPointer<Archive> arch(new Archive(archive.absoluteFilePath()));
+ verbose() << " Appending " << archive.filePath() << " (" << arch->size() << " bytes)"
+ << std::endl;
+ comp.appendArchive(arch);
+ if (!privateKey.isEmpty()) {
+ verbose() << " Appending a RSA signature..." << std::endl;
+ const QByteArray signature = crypto.sign(arch.data());
+ if (signature.isEmpty())
+ throw Error(QObject::tr("Could not create a RSA signature"));
+
+ if (!crypto.verify(arch.data(), signature)) {
+ throw Error(QObject::tr("Created RSA signature could not be verified. Is "
+ "the given public key wrong?"));
+ }
+ verbose() << " Appending " << archive.fileName() << ".sig ("
+ << signature.size() << " bytes)" << std::endl;
+ const QSharedPointer< Archive > sigArch(new Archive(arch->name() + ".sig",
+ signature));
+ comp.appendArchive(sigArch);
+ }
+ }
+ input.components.insertComponent(comp);
+ }
+
+ verbose() << "Creating the binary" << std::endl;
+ const int result = assemble(input, confdir);
+
+ // cleanup
+ verbose() << "Cleaning up..." << std::endl;
+ QFile::remove(resourceFile);
+ removeDirectory(metaDir);
+
+ return result;
+ } catch(const Error &e) {
+ std::cerr << e.message() << std::endl;
+ return 1;
+ } catch(...) {
+ std::cerr << "Unknown exception caught" << std::endl;
+ return 1;
+ }
+}
diff --git a/installerbuilder/binarycreator/binarycreator.pro b/installerbuilder/binarycreator/binarycreator.pro
new file mode 100644
index 000000000..237ce9952
--- /dev/null
+++ b/installerbuilder/binarycreator/binarycreator.pro
@@ -0,0 +1,25 @@
+TEMPLATE = app
+TARGET = binarycreator
+
+DEPENDPATH += . ..
+INCLUDEPATH += . .. rcc
+
+DESTDIR = ../bin
+
+CONFIG += console
+CONFIG -= app_bundle
+
+include(../libinstaller/libinstaller.pri)
+
+RESOURCES += binarycreator.qrc
+
+# Input
+SOURCES = binarycreator.cpp \
+ rcc/rcc.cpp \
+ rcc/rccmain.cpp \
+ ../common/repositorygen.cpp
+
+HEADERS = rcc/rcc.h
+
+win32:OBJECTS_DIR = .obj
+win32:LIBS += Shell32.lib
diff --git a/installerbuilder/binarycreator/binarycreator.qrc b/installerbuilder/binarycreator/binarycreator.qrc
new file mode 100644
index 000000000..b73ae19bc
--- /dev/null
+++ b/installerbuilder/binarycreator/binarycreator.qrc
@@ -0,0 +1,8 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>resources/default_icon_mac.icns</file>
+ <file>resources/copylibsintobundle.sh</file>
+ <file>resources/mkdmg.sh</file>
+ <file alias="resources/installerbase.ico">../installerbase/installerbase.ico</file>
+</qresource>
+</RCC>
diff --git a/installerbuilder/binarycreator/rcc/qcorecmdlineargs_p.h b/installerbuilder/binarycreator/rcc/qcorecmdlineargs_p.h
new file mode 100644
index 000000000..0f6c48dbb
--- /dev/null
+++ b/installerbuilder/binarycreator/rcc/qcorecmdlineargs_p.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCORECMDLINEARGS_P_H
+#define QCORECMDLINEARGS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qstring.h"
+#include "QtCore/qstringlist.h"
+
+QT_BEGIN_NAMESPACE
+
+static inline QStringList qCmdLineArgs(int argc, char *argv[])
+{
+ QStringList args;
+ for (int i = 0; i != argc; ++i)
+ args += QString::fromLocal8Bit(argv[i]);
+ return args;
+}
+
+
+QT_END_NAMESPACE
+
+#endif // QCORECMDLINEARGS_WIN_P_H
diff --git a/installerbuilder/binarycreator/rcc/rcc.cpp b/installerbuilder/binarycreator/rcc/rcc.cpp
new file mode 100644
index 000000000..4cd155dd3
--- /dev/null
+++ b/installerbuilder/binarycreator/rcc/rcc.cpp
@@ -0,0 +1,967 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "rcc.h"
+
+#include <QtCore/QByteArray>
+#include <QtCore/QDateTime>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QDirIterator>
+#include <QtCore/QFile>
+#include <QtCore/QIODevice>
+#include <QtCore/QLocale>
+#include <QtCore/QStack>
+
+#include <QtXml/QDomDocument>
+
+QT_BEGIN_NAMESPACE
+
+enum {
+ CONSTANT_USENAMESPACE = 1,
+ CONSTANT_COMPRESSLEVEL_DEFAULT = -1,
+ CONSTANT_COMPRESSTHRESHOLD_DEFAULT = 70
+};
+
+
+#define writeString(s) write(s, sizeof(s))
+
+void RCCResourceLibrary::write(const char *str, int len)
+{
+ --len; // trailing \0 on string literals...
+ int n = m_out.size();
+ m_out.resize(n + len);
+ memcpy(m_out.data() + n, str, len);
+}
+
+void RCCResourceLibrary::writeByteArray(const QByteArray &other)
+{
+ m_out.append(other);
+}
+
+static inline QString msgOpenReadFailed(const QString &fname, const QString &why)
+{
+ return QString::fromUtf8("Unable to open %1 for reading: %2\n").arg(fname).arg(why);
+}
+
+
+///////////////////////////////////////////////////////////
+//
+// RCCFileInfo
+//
+///////////////////////////////////////////////////////////
+
+class RCCFileInfo
+{
+public:
+ enum Flags
+ {
+ NoFlags = 0x00,
+ Compressed = 0x01,
+ Directory = 0x02
+ };
+
+ RCCFileInfo(const QString &name = QString(), const QFileInfo &fileInfo = QFileInfo(),
+ QLocale::Language language = QLocale::C,
+ QLocale::Country country = QLocale::AnyCountry,
+ uint flags = NoFlags,
+ int compressLevel = CONSTANT_COMPRESSLEVEL_DEFAULT,
+ int compressThreshold = CONSTANT_COMPRESSTHRESHOLD_DEFAULT);
+ ~RCCFileInfo();
+
+ QString resourceName() const;
+
+public:
+ qint64 writeDataBlob(RCCResourceLibrary &lib, qint64 offset, QString *errorMessage);
+ qint64 writeDataName(RCCResourceLibrary &, qint64 offset);
+ void writeDataInfo(RCCResourceLibrary &lib);
+
+ int m_flags;
+ QString m_name;
+ QLocale::Language m_language;
+ QLocale::Country m_country;
+ QFileInfo m_fileInfo;
+ RCCFileInfo *m_parent;
+ QHash<QString, RCCFileInfo*> m_children;
+ int m_compressLevel;
+ int m_compressThreshold;
+
+ qint64 m_nameOffset;
+ qint64 m_dataOffset;
+ qint64 m_childOffset;
+};
+
+RCCFileInfo::RCCFileInfo(const QString &name, const QFileInfo &fileInfo,
+ QLocale::Language language, QLocale::Country country, uint flags,
+ int compressLevel, int compressThreshold)
+{
+ m_name = name;
+ m_fileInfo = fileInfo;
+ m_language = language;
+ m_country = country;
+ m_flags = flags;
+ m_parent = 0;
+ m_nameOffset = 0;
+ m_dataOffset = 0;
+ m_childOffset = 0;
+ m_compressLevel = compressLevel;
+ m_compressThreshold = compressThreshold;
+}
+
+RCCFileInfo::~RCCFileInfo()
+{
+ qDeleteAll(m_children);
+}
+
+QString RCCFileInfo::resourceName() const
+{
+ QString resource = m_name;
+ for (RCCFileInfo *p = m_parent; p; p = p->m_parent)
+ resource = resource.prepend(p->m_name + QLatin1Char('/'));
+ return QLatin1Char(':') + resource;
+}
+
+void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib)
+{
+ const bool text = (lib.m_format == RCCResourceLibrary::C_Code);
+ //some info
+ if (text) {
+ if (m_language != QLocale::C) {
+ lib.writeString(" // ");
+ lib.writeByteArray(resourceName().toLocal8Bit());
+ lib.writeString(" [");
+ lib.writeByteArray(QByteArray::number(m_country));
+ lib.writeString("::");
+ lib.writeByteArray(QByteArray::number(m_language));
+ lib.writeString("[\n ");
+ } else {
+ lib.writeString(" // ");
+ lib.writeByteArray(resourceName().toLocal8Bit());
+ lib.writeString("\n ");
+ }
+ }
+
+ //pointer data
+ if (m_flags & RCCFileInfo::Directory) {
+ // name offset
+ lib.writeNumber4(m_nameOffset);
+
+ // flags
+ lib.writeNumber2(m_flags);
+
+ // child count
+ lib.writeNumber4(m_children.size());
+
+ // first child offset
+ lib.writeNumber4(m_childOffset);
+ } else {
+ // name offset
+ lib.writeNumber4(m_nameOffset);
+
+ // flags
+ lib.writeNumber2(m_flags);
+
+ // locale
+ lib.writeNumber2(m_country);
+ lib.writeNumber2(m_language);
+
+ //data offset
+ lib.writeNumber4(m_dataOffset);
+ }
+ if (text)
+ lib.writeChar('\n');
+}
+
+qint64 RCCFileInfo::writeDataBlob(RCCResourceLibrary &lib, qint64 offset,
+ QString *errorMessage)
+{
+ const bool text = (lib.m_format == RCCResourceLibrary::C_Code);
+
+ //capture the offset
+ m_dataOffset = offset;
+
+ //find the data to be written
+ QFile file(m_fileInfo.absoluteFilePath());
+ if (!file.open(QFile::ReadOnly)) {
+ *errorMessage = msgOpenReadFailed(m_fileInfo.absoluteFilePath(), file.errorString());
+ return 0;
+ }
+ QByteArray data = file.readAll();
+
+#ifndef QT_NO_COMPRESS
+ // Check if compression is useful for this file
+ if (m_compressLevel != 0 && data.size() != 0) {
+ QByteArray compressed =
+ qCompress(reinterpret_cast<uchar *>(data.data()), data.size(), m_compressLevel);
+
+ int compressRatio = int(100.0 * (data.size() - compressed.size()) / data.size());
+ if (compressRatio >= m_compressThreshold) {
+ data = compressed;
+ m_flags |= Compressed;
+ }
+ }
+#endif // QT_NO_COMPRESS
+
+ // some info
+ if (text) {
+ lib.writeString(" // ");
+ lib.writeByteArray(m_fileInfo.absoluteFilePath().toLocal8Bit());
+ lib.writeString("\n ");
+ }
+
+ // write the length
+
+ lib.writeNumber4(data.size());
+ if (text)
+ lib.writeString("\n ");
+ offset += 4;
+
+ // write the payload
+ const char *p = data.constData();
+ if (text) {
+ for (int i = data.size(), j = 0; --i >= 0; --j) {
+ lib.writeHex(*p++);
+ if (j == 0) {
+ lib.writeString("\n ");
+ j = 16;
+ }
+ }
+ } else {
+ for (int i = data.size(); --i >= 0; )
+ lib.writeChar(*p++);
+ }
+ offset += data.size();
+
+ // done
+ if (text)
+ lib.writeString("\n ");
+ return offset;
+}
+
+qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset)
+{
+ const bool text = (lib.m_format == RCCResourceLibrary::C_Code);
+
+ // capture the offset
+ m_nameOffset = offset;
+
+ // some info
+ if (text) {
+ lib.writeString(" // ");
+ lib.writeByteArray(m_name.toLocal8Bit());
+ lib.writeString("\n ");
+ }
+
+ // write the length
+ lib.writeNumber2(m_name.length());
+ if (text)
+ lib.writeString("\n ");
+ offset += 2;
+
+ // write the hash
+ lib.writeNumber4(qHash(m_name));
+ if (text)
+ lib.writeString("\n ");
+ offset += 4;
+
+ // write the m_name
+ const QChar *unicode = m_name.unicode();
+ for (int i = 0; i < m_name.length(); ++i) {
+ lib.writeNumber2(unicode[i].unicode());
+ if (text && i % 16 == 0)
+ lib.writeString("\n ");
+ }
+ offset += m_name.length()*2;
+
+ // done
+ if (text)
+ lib.writeString("\n ");
+ return offset;
+}
+
+
+///////////////////////////////////////////////////////////
+//
+// RCCResourceLibrary
+//
+///////////////////////////////////////////////////////////
+
+RCCResourceLibrary::Strings::Strings() :
+ TAG_RCC(QLatin1String("RCC")),
+ TAG_RESOURCE(QLatin1String("qresource")),
+ TAG_FILE(QLatin1String("file")),
+ ATTRIBUTE_LANG(QLatin1String("lang")),
+ ATTRIBUTE_PREFIX(QLatin1String("prefix")),
+ ATTRIBUTE_ALIAS(QLatin1String("alias")),
+ ATTRIBUTE_THRESHOLD(QLatin1String("threshold")),
+ ATTRIBUTE_COMPRESS(QLatin1String("compress"))
+{
+}
+
+RCCResourceLibrary::RCCResourceLibrary()
+ : m_root(0),
+ m_format(C_Code),
+ m_verbose(false),
+ m_compressLevel(CONSTANT_COMPRESSLEVEL_DEFAULT),
+ m_compressThreshold(CONSTANT_COMPRESSTHRESHOLD_DEFAULT),
+ m_treeOffset(0),
+ m_namesOffset(0),
+ m_dataOffset(0),
+ m_useNameSpace(CONSTANT_USENAMESPACE),
+ m_errorDevice(0)
+{
+ m_out.reserve(30 * 1000 * 1000);
+}
+
+RCCResourceLibrary::~RCCResourceLibrary()
+{
+ delete m_root;
+}
+
+bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
+ const QString &fname, QString currentPath, bool ignoreErrors)
+{
+ Q_ASSERT(m_errorDevice);
+ const QChar slash = QLatin1Char('/');
+ if (!currentPath.isEmpty() && !currentPath.endsWith(slash))
+ currentPath += slash;
+
+ QDomDocument document;
+ {
+ QString errorMsg;
+ int errorLine = 0;
+ int errorColumn = 0;
+ if (!document.setContent(inputDevice, &errorMsg, &errorLine, &errorColumn)) {
+ if (ignoreErrors)
+ return true;
+ const QString msg = QString::fromUtf8("RCC Parse Error: '%1' Line: %2 Column: %3 [%4]\n").arg(fname).arg(errorLine).arg(errorColumn).arg(errorMsg);
+ m_errorDevice->write(msg.toUtf8());
+ return false;
+ }
+ }
+
+ QDomElement domRoot = document.firstChildElement(m_strings.TAG_RCC).toElement();
+ if (!domRoot.isNull() && domRoot.tagName() == m_strings.TAG_RCC) {
+ for (QDomNode node = domRoot.firstChild(); !node.isNull(); node = node.nextSibling()) {
+ if (!node.isElement())
+ continue;
+
+ QDomElement child = node.toElement();
+ if (!child.isNull() && child.tagName() == m_strings.TAG_RESOURCE) {
+ QLocale::Language language = QLocale::c().language();
+ QLocale::Country country = QLocale::c().country();
+
+ if (child.hasAttribute(m_strings.ATTRIBUTE_LANG)) {
+ QString attribute = child.attribute(m_strings.ATTRIBUTE_LANG);
+ QLocale lang = QLocale(attribute);
+ language = lang.language();
+ if (2 == attribute.length()) {
+ // Language only
+ country = QLocale::AnyCountry;
+ } else {
+ country = lang.country();
+ }
+ }
+
+ QString prefix;
+ if (child.hasAttribute(m_strings.ATTRIBUTE_PREFIX))
+ prefix = child.attribute(m_strings.ATTRIBUTE_PREFIX);
+ if (!prefix.startsWith(slash))
+ prefix.prepend(slash);
+ if (!prefix.endsWith(slash))
+ prefix += slash;
+
+ for (QDomNode res = child.firstChild(); !res.isNull(); res = res.nextSibling()) {
+ if (res.isElement() && res.toElement().tagName() == m_strings.TAG_FILE) {
+
+ QString fileName(res.firstChild().toText().data());
+ if (fileName.isEmpty()) {
+ const QString msg = QString::fromUtf8("RCC: Warning: Null node in XML of '%1'\n").arg(fname);
+ m_errorDevice->write(msg.toUtf8());
+ }
+ QString alias;
+ if (res.toElement().hasAttribute(m_strings.ATTRIBUTE_ALIAS))
+ alias = res.toElement().attribute(m_strings.ATTRIBUTE_ALIAS);
+ else
+ alias = fileName;
+
+ int compressLevel = m_compressLevel;
+ if (res.toElement().hasAttribute(m_strings.ATTRIBUTE_COMPRESS))
+ compressLevel = res.toElement().attribute(m_strings.ATTRIBUTE_COMPRESS).toInt();
+ int compressThreshold = m_compressThreshold;
+ if (res.toElement().hasAttribute(m_strings.ATTRIBUTE_THRESHOLD))
+ compressThreshold = res.toElement().attribute(m_strings.ATTRIBUTE_THRESHOLD).toInt();
+
+ // Special case for -no-compress. Overrides all other settings.
+ if (m_compressLevel == -2)
+ compressLevel = 0;
+
+ alias = QDir::cleanPath(alias);
+ while (alias.startsWith(QLatin1String("../")))
+ alias.remove(0, 3);
+ alias = QDir::cleanPath(m_resourceRoot) + prefix + alias;
+
+ QString absFileName = fileName;
+ if (QDir::isRelativePath(absFileName))
+ absFileName.prepend(currentPath);
+ QFileInfo file(absFileName);
+ if (!file.exists()) {
+ m_failedResources.push_back(absFileName);
+ const QString msg = QString::fromUtf8("RCC: Error in '%1': Cannot find file '%2'\n").arg(fname).arg(fileName);
+ m_errorDevice->write(msg.toUtf8());
+ if (ignoreErrors)
+ continue;
+ else
+ return false;
+ } else if (file.isFile()) {
+ const bool arc = addFile(alias, RCCFileInfo(alias.section(slash, -1), file, language, country,
+ RCCFileInfo::NoFlags, compressLevel, compressThreshold));
+ if (!arc)
+ m_failedResources.push_back(absFileName);
+ } else {
+ QDir dir;
+ if (file.isDir()) {
+ dir.setPath(file.filePath());
+ } else {
+ dir.setPath(file.path());
+ dir.setNameFilters(QStringList(file.fileName()));
+ if (alias.endsWith(file.fileName()))
+ alias = alias.left(alias.length()-file.fileName().length());
+ }
+ if (!alias.endsWith(slash))
+ alias += slash;
+ QDirIterator it(dir, QDirIterator::FollowSymlinks|QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ it.next();
+ QFileInfo child(it.fileInfo());
+ if (child.fileName() != QLatin1String(".") && child.fileName() != QLatin1String("..")) {
+ const bool arc = addFile(alias + child.fileName(),
+ RCCFileInfo(child.fileName(), child, language, country,
+ RCCFileInfo::NoFlags, compressLevel, compressThreshold));
+ if (!arc)
+ m_failedResources.push_back(child.fileName());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (m_root == 0) {
+ const QString msg = QString::fromUtf8("RCC: Warning: No resources in '%1'.\n").arg(fname);
+ m_errorDevice->write(msg.toUtf8());
+ if (!ignoreErrors && m_format == Binary) {
+ // create dummy entry, otherwise loading qith QResource will crash
+ m_root = new RCCFileInfo(QString(), QFileInfo(),
+ QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
+ }
+ }
+
+ return true;
+}
+
+bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file)
+{
+ Q_ASSERT(m_errorDevice);
+ if (file.m_fileInfo.size() > 0xffffffff) {
+ const QString msg = QString::fromUtf8("File too big: %1\n").arg(file.m_fileInfo.absoluteFilePath());
+ m_errorDevice->write(msg.toUtf8());
+ return false;
+ }
+ if (!m_root)
+ m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
+
+ RCCFileInfo *parent = m_root;
+ const QStringList nodes = alias.split(QLatin1Char('/'));
+ for (int i = 1; i < nodes.size()-1; ++i) {
+ const QString node = nodes.at(i);
+ if (node.isEmpty())
+ continue;
+ if (!parent->m_children.contains(node)) {
+ RCCFileInfo *s = new RCCFileInfo(node, QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
+ s->m_parent = parent;
+ parent->m_children.insert(node, s);
+ parent = s;
+ } else {
+ parent = parent->m_children[node];
+ }
+ }
+
+ const QString filename = nodes.at(nodes.size()-1);
+ RCCFileInfo *s = new RCCFileInfo(file);
+ s->m_parent = parent;
+ parent->m_children.insertMulti(filename, s);
+ return true;
+}
+
+void RCCResourceLibrary::reset()
+{
+ if (m_root) {
+ delete m_root;
+ m_root = 0;
+ }
+ m_errorDevice = 0;
+ m_failedResources.clear();
+}
+
+
+bool RCCResourceLibrary::readFiles(bool ignoreErrors, QIODevice &errorDevice)
+{
+ reset();
+ m_errorDevice = &errorDevice;
+ //read in data
+ if (m_verbose) {
+ const QString msg = QString::fromUtf8("Processing %1 files [%2]\n")
+ .arg(m_fileNames.size()).arg(static_cast<int>(ignoreErrors));
+ m_errorDevice->write(msg.toUtf8());
+ }
+ for (int i = 0; i < m_fileNames.size(); ++i) {
+ QFile fileIn;
+ QString fname = m_fileNames.at(i);
+ QString pwd;
+ if (fname == QLatin1String("-")) {
+ fname = QLatin1String("(stdin)");
+ pwd = QDir::currentPath();
+ fileIn.setFileName(fname);
+ if (!fileIn.open(stdin, QIODevice::ReadOnly)) {
+ m_errorDevice->write(msgOpenReadFailed(fname, fileIn.errorString()).toUtf8());
+ return false;
+ }
+ } else {
+ pwd = QFileInfo(fname).path();
+ fileIn.setFileName(fname);
+ if (!fileIn.open(QIODevice::ReadOnly)) {
+ m_errorDevice->write(msgOpenReadFailed(fname, fileIn.errorString()).toUtf8());
+ return false;
+ }
+ }
+ if (m_verbose) {
+ const QString msg = QString::fromUtf8("Interpreting %1\n").arg(fname);
+ m_errorDevice->write(msg.toUtf8());
+ }
+
+ if (!interpretResourceFile(&fileIn, fname, pwd, ignoreErrors))
+ return false;
+ }
+ return true;
+}
+
+QStringList RCCResourceLibrary::dataFiles() const
+{
+ QStringList ret;
+ QStack<RCCFileInfo*> pending;
+
+ if (!m_root)
+ return ret;
+ pending.push(m_root);
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+ for (QHash<QString, RCCFileInfo*>::iterator it = file->m_children.begin();
+ it != file->m_children.end(); ++it) {
+ RCCFileInfo *child = it.value();
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ ret.append(child->m_fileInfo.filePath());
+ }
+ }
+ return ret;
+}
+
+// Determine map of resource identifier (':/newPrefix/images/p1.png') to file via recursion
+static void resourceDataFileMapRecursion(const RCCFileInfo *m_root, const QString &path, RCCResourceLibrary::ResourceDataFileMap &m)
+{
+ typedef QHash<QString, RCCFileInfo*>::const_iterator ChildConstIterator;
+ const QChar slash = QLatin1Char('/');
+ const ChildConstIterator cend = m_root->m_children.constEnd();
+ for (ChildConstIterator it = m_root->m_children.constBegin(); it != cend; ++it) {
+ const RCCFileInfo *child = it.value();
+ QString childName = path;
+ childName += slash;
+ childName += child->m_name;
+ if (child->m_flags & RCCFileInfo::Directory) {
+ resourceDataFileMapRecursion(child, childName, m);
+ } else {
+ m.insert(childName, child->m_fileInfo.filePath());
+ }
+ }
+}
+
+RCCResourceLibrary::ResourceDataFileMap RCCResourceLibrary::resourceDataFileMap() const
+{
+ ResourceDataFileMap rc;
+ if (m_root)
+ resourceDataFileMapRecursion(m_root, QString(QLatin1Char(':')), rc);
+ return rc;
+}
+
+bool RCCResourceLibrary::output(QIODevice &outDevice, QIODevice &errorDevice)
+{
+ m_errorDevice = &errorDevice;
+ //write out
+ if (m_verbose)
+ m_errorDevice->write("Outputting code\n");
+ if (!writeHeader()) {
+ m_errorDevice->write("Could not write header\n");
+ return false;
+ }
+ if (m_root) {
+ if (!writeDataBlobs()) {
+ m_errorDevice->write("Could not write data blobs.\n");
+ return false;
+ }
+ if (!writeDataNames()) {
+ m_errorDevice->write("Could not write file names\n");
+ return false;
+ }
+ if (!writeDataStructure()) {
+ m_errorDevice->write("Could not write data tree\n");
+ return false;
+ }
+ }
+ if (!writeInitializer()) {
+ m_errorDevice->write("Could not write footer\n");
+ return false;
+ }
+ outDevice.write(m_out, m_out.size());
+ return true;
+}
+
+void RCCResourceLibrary::writeHex(quint8 tmp)
+{
+ const char * const digits = "0123456789abcdef";
+ writeChar('0');
+ writeChar('x');
+ if (tmp < 16) {
+ writeChar(digits[tmp]);
+ } else {
+ writeChar(digits[tmp >> 4]);
+ writeChar(digits[tmp & 0xf]);
+ }
+ writeChar(',');
+}
+
+void RCCResourceLibrary::writeNumber2(quint16 number)
+{
+ if (m_format == RCCResourceLibrary::Binary) {
+ writeChar(number >> 8);
+ writeChar(number);
+ } else {
+ writeHex(number >> 8);
+ writeHex(number);
+ }
+}
+
+void RCCResourceLibrary::writeNumber4(quint32 number)
+{
+ if (m_format == RCCResourceLibrary::Binary) {
+ writeChar(number >> 24);
+ writeChar(number >> 16);
+ writeChar(number >> 8);
+ writeChar(number);
+ } else {
+ writeHex(number >> 24);
+ writeHex(number >> 16);
+ writeHex(number >> 8);
+ writeHex(number);
+ }
+}
+
+bool RCCResourceLibrary::writeHeader()
+{
+ if (m_format == C_Code) {
+ writeString("/****************************************************************************\n");
+ writeString("** Resource object code\n");
+ writeString("**\n");
+ writeString("** Created: ");
+ writeByteArray(QDateTime::currentDateTime().toString().toLatin1());
+ writeString("\n** by: The Resource Compiler for Qt version ");
+ writeByteArray(QT_VERSION_STR);
+ writeString("\n**\n");
+ writeString("** WARNING! All changes made in this file will be lost!\n");
+ writeString( "*****************************************************************************/\n\n");
+ writeString("#include <QtCore/qglobal.h>\n\n");
+ } else if (m_format == Binary) {
+ writeString("qres");
+ writeNumber4(0);
+ writeNumber4(0);
+ writeNumber4(0);
+ writeNumber4(0);
+ }
+ return true;
+}
+
+bool RCCResourceLibrary::writeDataBlobs()
+{
+ Q_ASSERT(m_errorDevice);
+ if (m_format == C_Code)
+ writeString("static const unsigned char qt_resource_data[] = {\n");
+ else if (m_format == Binary)
+ m_dataOffset = m_out.size();
+ QStack<RCCFileInfo*> pending;
+
+ if (!m_root)
+ return false;
+
+ pending.push(m_root);
+ qint64 offset = 0;
+ QString errorMessage;
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+ for (QHash<QString, RCCFileInfo*>::iterator it = file->m_children.begin();
+ it != file->m_children.end(); ++it) {
+ RCCFileInfo *child = it.value();
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ else {
+ offset = child->writeDataBlob(*this, offset, &errorMessage);
+ if (offset == 0)
+ m_errorDevice->write(errorMessage.toUtf8());
+ }
+ }
+ }
+ if (m_format == C_Code)
+ writeString("\n};\n\n");
+ return true;
+}
+
+bool RCCResourceLibrary::writeDataNames()
+{
+ if (m_format == C_Code)
+ writeString("static const unsigned char qt_resource_name[] = {\n");
+ else if (m_format == Binary)
+ m_namesOffset = m_out.size();
+
+ QHash<QString, int> names;
+ QStack<RCCFileInfo*> pending;
+
+ if (!m_root)
+ return false;
+
+ pending.push(m_root);
+ qint64 offset = 0;
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+ for (QHash<QString, RCCFileInfo*>::iterator it = file->m_children.begin();
+ it != file->m_children.end(); ++it) {
+ RCCFileInfo *child = it.value();
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ if (names.contains(child->m_name)) {
+ child->m_nameOffset = names.value(child->m_name);
+ } else {
+ names.insert(child->m_name, offset);
+ offset = child->writeDataName(*this, offset);
+ }
+ }
+ }
+ if (m_format == C_Code)
+ writeString("\n};\n\n");
+ return true;
+}
+
+static bool qt_rcc_compare_hash(const RCCFileInfo *left, const RCCFileInfo *right)
+{
+ return qHash(left->m_name) < qHash(right->m_name);
+}
+
+bool RCCResourceLibrary::writeDataStructure()
+{
+ if (m_format == C_Code)
+ writeString("static const unsigned char qt_resource_struct[] = {\n");
+ else if (m_format == Binary)
+ m_treeOffset = m_out.size();
+ QStack<RCCFileInfo*> pending;
+
+ if (!m_root)
+ return false;
+
+ //calculate the child offsets (flat)
+ pending.push(m_root);
+ int offset = 1;
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+ file->m_childOffset = offset;
+
+ //sort by hash value for binary lookup
+ QList<RCCFileInfo*> m_children = file->m_children.values();
+ qSort(m_children.begin(), m_children.end(), qt_rcc_compare_hash);
+
+ //write out the actual data now
+ for (int i = 0; i < m_children.size(); ++i) {
+ RCCFileInfo *child = m_children.at(i);
+ ++offset;
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ }
+ }
+
+ //write out the structure (ie iterate again!)
+ pending.push(m_root);
+ m_root->writeDataInfo(*this);
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+
+ //sort by hash value for binary lookup
+ QList<RCCFileInfo*> m_children = file->m_children.values();
+ qSort(m_children.begin(), m_children.end(), qt_rcc_compare_hash);
+
+ //write out the actual data now
+ for (int i = 0; i < m_children.size(); ++i) {
+ RCCFileInfo *child = m_children.at(i);
+ child->writeDataInfo(*this);
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ }
+ }
+ if (m_format == C_Code)
+ writeString("\n};\n\n");
+
+ return true;
+}
+
+void RCCResourceLibrary::writeMangleNamespaceFunction(const QByteArray &name)
+{
+ if (m_useNameSpace) {
+ writeString("QT_MANGLE_NAMESPACE(");
+ writeByteArray(name);
+ writeChar(')');
+ } else {
+ writeByteArray(name);
+ }
+}
+
+void RCCResourceLibrary::writeAddNamespaceFunction(const QByteArray &name)
+{
+ if (m_useNameSpace) {
+ writeString("QT_PREPEND_NAMESPACE(");
+ writeByteArray(name);
+ writeChar(')');
+ } else {
+ writeByteArray(name);
+ }
+}
+
+bool RCCResourceLibrary::writeInitializer()
+{
+ if (m_format == C_Code) {
+ //write("\nQT_BEGIN_NAMESPACE\n");
+ QString initName = m_initName;
+ if (!initName.isEmpty()) {
+ initName.prepend(QLatin1Char('_'));
+ initName.replace(QRegExp(QLatin1String("[^a-zA-Z0-9_]")), QLatin1String("_"));
+ }
+
+ //init
+ if (m_useNameSpace)
+ writeString("QT_BEGIN_NAMESPACE\n\n");
+ if (m_root) {
+ writeString("extern bool qRegisterResourceData\n "
+ "(int, const unsigned char *, "
+ "const unsigned char *, const unsigned char *);\n\n");
+ writeString("extern bool qUnregisterResourceData\n "
+ "(int, const unsigned char *, "
+ "const unsigned char *, const unsigned char *);\n\n");
+ }
+ if (m_useNameSpace)
+ writeString("QT_END_NAMESPACE\n\n\n");
+ QString initResources = QLatin1String("qInitResources");
+ initResources += initName;
+ writeString("int ");
+ writeMangleNamespaceFunction(initResources.toLatin1());
+ writeString("()\n{\n");
+
+ if (m_root) {
+ writeString(" ");
+ writeAddNamespaceFunction("qRegisterResourceData");
+ writeString("\n (0x01, qt_resource_struct, "
+ "qt_resource_name, qt_resource_data);\n");
+ }
+ writeString(" return 1;\n");
+ writeString("}\n\n");
+ writeString("Q_CONSTRUCTOR_FUNCTION(");
+ writeMangleNamespaceFunction(initResources.toLatin1());
+ writeString(")\n\n");
+
+ //cleanup
+ QString cleanResources = QLatin1String("qCleanupResources");
+ cleanResources += initName;
+ writeString("int ");
+ writeMangleNamespaceFunction(cleanResources.toLatin1());
+ writeString("()\n{\n");
+ if (m_root) {
+ writeString(" ");
+ writeAddNamespaceFunction("qUnregisterResourceData");
+ writeString("\n (0x01, qt_resource_struct, "
+ "qt_resource_name, qt_resource_data);\n");
+ }
+ writeString(" return 1;\n");
+ writeString("}\n\n");
+ writeString("Q_DESTRUCTOR_FUNCTION(");
+ writeMangleNamespaceFunction(cleanResources.toLatin1());
+ writeString(")\n\n");
+ } else if (m_format == Binary) {
+ int i = 4;
+ char *p = m_out.data();
+ p[i++] = 0; // 0x01
+ p[i++] = 0;
+ p[i++] = 0;
+ p[i++] = 1;
+
+ p[i++] = (m_treeOffset >> 24) & 0xff;
+ p[i++] = (m_treeOffset >> 16) & 0xff;
+ p[i++] = (m_treeOffset >> 8) & 0xff;
+ p[i++] = (m_treeOffset >> 0) & 0xff;
+
+ p[i++] = (m_dataOffset >> 24) & 0xff;
+ p[i++] = (m_dataOffset >> 16) & 0xff;
+ p[i++] = (m_dataOffset >> 8) & 0xff;
+ p[i++] = (m_dataOffset >> 0) & 0xff;
+
+ p[i++] = (m_namesOffset >> 24) & 0xff;
+ p[i++] = (m_namesOffset >> 16) & 0xff;
+ p[i++] = (m_namesOffset >> 8) & 0xff;
+ p[i++] = (m_namesOffset >> 0) & 0xff;
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/installerbuilder/binarycreator/rcc/rcc.h b/installerbuilder/binarycreator/rcc/rcc.h
new file mode 100644
index 000000000..66b8339d1
--- /dev/null
+++ b/installerbuilder/binarycreator/rcc/rcc.h
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RCC_H
+#define RCC_H
+
+#include <QtCore/QStringList>
+#include <QtCore/QHash>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class RCCFileInfo;
+class QIODevice;
+class QTextStream;
+
+
+class RCCResourceLibrary
+{
+ RCCResourceLibrary(const RCCResourceLibrary &);
+ RCCResourceLibrary &operator=(const RCCResourceLibrary &);
+
+public:
+ RCCResourceLibrary();
+ ~RCCResourceLibrary();
+
+ bool output(QIODevice &out, QIODevice &errorDevice);
+
+ bool readFiles(bool ignoreErrors, QIODevice &errorDevice);
+
+ enum Format { Binary, C_Code };
+ void setFormat(Format f) { m_format = f; }
+ Format format() const { return m_format; }
+
+ void setInputFiles(const QStringList &files) { m_fileNames = files; }
+ QStringList inputFiles() const { return m_fileNames; }
+
+ QStringList dataFiles() const;
+
+ // Return a map of resource identifier (':/newPrefix/images/p1.png') to file.
+ typedef QHash<QString, QString> ResourceDataFileMap;
+ ResourceDataFileMap resourceDataFileMap() const;
+
+ void setVerbose(bool b) { m_verbose = b; }
+ bool verbose() const { return m_verbose; }
+
+ void setInitName(const QString &name) { m_initName = name; }
+ QString initName() const { return m_initName; }
+
+ void setCompressLevel(int c) { m_compressLevel = c; }
+ int compressLevel() const { return m_compressLevel; }
+
+ void setCompressThreshold(int t) { m_compressThreshold = t; }
+ int compressThreshold() const { return m_compressThreshold; }
+
+ void setResourceRoot(const QString &root) { m_resourceRoot = root; }
+ QString resourceRoot() const { return m_resourceRoot; }
+
+ void setUseNameSpace(bool v) { m_useNameSpace = v; }
+ bool useNameSpace() const { return m_useNameSpace; }
+
+ QStringList failedResources() const { return m_failedResources; }
+
+private:
+ struct Strings {
+ Strings();
+ const QString TAG_RCC;
+ const QString TAG_RESOURCE;
+ const QString TAG_FILE;
+ const QString ATTRIBUTE_LANG;
+ const QString ATTRIBUTE_PREFIX;
+ const QString ATTRIBUTE_ALIAS;
+ const QString ATTRIBUTE_THRESHOLD;
+ const QString ATTRIBUTE_COMPRESS;
+ };
+ friend class RCCFileInfo;
+ void reset();
+ bool addFile(const QString &alias, const RCCFileInfo &file);
+ bool interpretResourceFile(QIODevice *inputDevice, const QString &file,
+ QString currentPath = QString(), bool ignoreErrors = false);
+ bool writeHeader();
+ bool writeDataBlobs();
+ bool writeDataNames();
+ bool writeDataStructure();
+ bool writeInitializer();
+ void writeMangleNamespaceFunction(const QByteArray &name);
+ void writeAddNamespaceFunction(const QByteArray &name);
+ void writeHex(quint8 number);
+ void writeNumber2(quint16 number);
+ void writeNumber4(quint32 number);
+ void writeChar(char c) { m_out.append(c); }
+ void writeByteArray(const QByteArray &);
+ void write(const char *, int len);
+
+ const Strings m_strings;
+ RCCFileInfo *m_root;
+ QStringList m_fileNames;
+ QString m_resourceRoot;
+ QString m_initName;
+ Format m_format;
+ bool m_verbose;
+ int m_compressLevel;
+ int m_compressThreshold;
+ int m_treeOffset;
+ int m_namesOffset;
+ int m_dataOffset;
+ bool m_useNameSpace;
+ QStringList m_failedResources;
+ QIODevice *m_errorDevice;
+ QByteArray m_out;
+};
+
+QT_END_NAMESPACE
+
+#endif // RCC_H
diff --git a/installerbuilder/binarycreator/rcc/rccmain.cpp b/installerbuilder/binarycreator/rcc/rccmain.cpp
new file mode 100644
index 000000000..2ab985445
--- /dev/null
+++ b/installerbuilder/binarycreator/rcc/rccmain.cpp
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <rcc.h>
+#include "qcorecmdlineargs_p.h"
+
+#include <QDebug>
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+#include <QTextStream>
+
+QT_BEGIN_NAMESPACE
+
+void showHelp(const QString &argv0, const QString &error)
+{
+ fprintf(stderr, "Qt resource compiler\n");
+ if (!error.isEmpty())
+ fprintf(stderr, "%s: %s\n", qPrintable(argv0), qPrintable(error));
+ fprintf(stderr, "Usage: %s [options] <inputs>\n\n"
+ "Options:\n"
+ " -o file write output to file rather than stdout\n"
+ " -name name create an external initialization function with name\n"
+ " -threshold level threshold to consider compressing files\n"
+ " -compress level compress input files by level\n"
+ " -root path prefix resource access path with root path\n"
+ " -no-compress disable all compression\n"
+ " -binary output a binary file for use as a dynamic resource\n"
+ " -namespace turn off namespace macros\n"
+ " -project Output a resource file containing all\n"
+ " files from the current directory\n"
+ " -version display version\n"
+ " -help display this information\n",
+ qPrintable(argv0));
+}
+
+void dumpRecursive(const QDir &dir, QTextStream &out)
+{
+ QFileInfoList entries = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot
+ | QDir::NoSymLinks);
+ foreach (QFileInfo entry, entries) {
+ if (entry.isDir()) {
+ dumpRecursive(entry.filePath(), out);
+ } else {
+ out << QLatin1String("<file>")
+ << entry.filePath()
+ << QLatin1String("</file>\n");
+ }
+ }
+}
+
+int createProject(const QString &outFileName)
+{
+ QDir currentDir = QDir::current();
+ QString currentDirName = currentDir.dirName();
+ if (currentDirName.isEmpty())
+ currentDirName = QLatin1String("root");
+
+ QFile file;
+ bool isOk = false;
+ if (outFileName.isEmpty()) {
+ isOk = file.open(stdout, QFile::WriteOnly | QFile::Text);
+ } else {
+ file.setFileName(outFileName);
+ isOk = file.open(QFile::WriteOnly | QFile::Text);
+ }
+ if (!isOk) {
+ fprintf(stderr, "Unable to open %s: %s\n",
+ outFileName.isEmpty() ? qPrintable(outFileName) : "standard output",
+ qPrintable(file.errorString()));
+ return 1;
+ }
+
+ QTextStream out(&file);
+ out << QLatin1String("<!DOCTYPE RCC><RCC version=\"1.0\">\n"
+ "<qresource>\n");
+
+ // use "." as dir to get relative file pathes
+ dumpRecursive(QDir(QLatin1String(".")), out);
+
+ out << QLatin1String("</qresource>\n"
+ "</RCC>\n");
+
+ return 0;
+}
+
+int runRcc(int argc, char *argv[])
+{
+ QString outFilename;
+ bool helpRequested = false;
+ bool list = false;
+ bool projectRequested = false;
+ QStringList filenamesIn;
+
+ QStringList args = qCmdLineArgs(argc, argv);
+
+ RCCResourceLibrary library;
+
+ //parse options
+ QString errorMsg;
+ for (int i = 1; i < args.count() && errorMsg.isEmpty(); i++) {
+ if (args[i].isEmpty())
+ continue;
+ if (args[i][0] == QLatin1Char('-')) { // option
+ QString opt = args[i];
+ if (opt == QLatin1String("-o")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing output name");
+ break;
+ }
+ outFilename = args[++i];
+ } else if (opt == QLatin1String("-name")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing target name");
+ break;
+ }
+ library.setInitName(args[++i]);
+ } else if (opt == QLatin1String("-root")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing root path");
+ break;
+ }
+ library.setResourceRoot(QDir::cleanPath(args[++i]));
+ if (library.resourceRoot().isEmpty()
+ || library.resourceRoot().at(0) != QLatin1Char('/'))
+ errorMsg = QLatin1String("Root must start with a /");
+ } else if (opt == QLatin1String("-compress")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing compression level");
+ break;
+ }
+ library.setCompressLevel(args[++i].toInt());
+ } else if (opt == QLatin1String("-threshold")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing compression threshold");
+ break;
+ }
+ library.setCompressThreshold(args[++i].toInt());
+ } else if (opt == QLatin1String("-binary")) {
+ library.setFormat(RCCResourceLibrary::Binary);
+ } else if (opt == QLatin1String("-namespace")) {
+ library.setUseNameSpace(!library.useNameSpace());
+ } else if (opt == QLatin1String("-verbose")) {
+ library.setVerbose(true);
+ } else if (opt == QLatin1String("-list")) {
+ list = true;
+ } else if (opt == QLatin1String("-version") || opt == QLatin1String("-v")) {
+ fprintf(stderr, "Qt Resource Compiler version %s\n", QT_VERSION_STR);
+ return 1;
+ } else if (opt == QLatin1String("-help") || opt == QLatin1String("-h")) {
+ helpRequested = true;
+ } else if (opt == QLatin1String("-no-compress")) {
+ library.setCompressLevel(-2);
+ } else if (opt == QLatin1String("-project")) {
+ projectRequested = true;
+ } else {
+ errorMsg = QString::fromLatin1("Unknown option: '%1'").arg(args[i]);
+ }
+ } else {
+ if (!QFile::exists(args[i])) {
+ qWarning("%s: File does not exist '%s'",
+ qPrintable(args[0]), qPrintable(args[i]));
+ return 1;
+ }
+ filenamesIn.append(args[i]);
+ }
+ }
+
+ if (projectRequested && !helpRequested) {
+ return createProject(outFilename);
+ }
+
+ if (!filenamesIn.size() || !errorMsg.isEmpty() || helpRequested) {
+ showHelp(args[0], errorMsg);
+ return 1;
+ }
+ QFile errorDevice;
+ errorDevice.open(stderr, QIODevice::WriteOnly|QIODevice::Text);
+
+ if (library.verbose())
+ errorDevice.write("Qt resource compiler\n");
+
+ library.setInputFiles(filenamesIn);
+
+ if (!library.readFiles(list, errorDevice))
+ return 1;
+
+ // open output
+ QFile out;
+ QIODevice::OpenMode mode = QIODevice::WriteOnly;
+ if (library.format() == RCCResourceLibrary::C_Code)
+ mode |= QIODevice::Text;
+
+ if (outFilename.isEmpty() || outFilename == QLatin1String("-")) {
+ // using this overload close() only flushes.
+ out.open(stdout, mode);
+ } else {
+ out.setFileName(outFilename);
+ if (!out.open(mode)) {
+ const QString msg = QString::fromUtf8("Unable to open %1 for writing: %2\n").arg(outFilename).arg(out.errorString());
+ errorDevice.write(msg.toUtf8());
+ return 1;
+ }
+ }
+
+ // do the task
+ if (list) {
+ const QStringList data = library.dataFiles();
+ for (int i = 0; i < data.size(); ++i) {
+ out.write(qPrintable(QDir::cleanPath(data.at(i))));
+ out.write("\n");
+ }
+ return 0;
+ }
+
+ return library.output(out, errorDevice) ? 0 : 1;
+}
+
+QT_END_NAMESPACE
+
+#if 0
+int main(int argc, char *argv[])
+{
+ return QT_PREPEND_NAMESPACE(runRcc)(argc, argv);
+}
+#endif
diff --git a/installerbuilder/binarycreator/resources/copylibsintobundle.sh b/installerbuilder/binarycreator/resources/copylibsintobundle.sh
new file mode 100644
index 000000000..2b997f9b5
--- /dev/null
+++ b/installerbuilder/binarycreator/resources/copylibsintobundle.sh
@@ -0,0 +1,161 @@
+#!/bin/sh
+
+# this script puts all libs directly needed by the bundle into it
+
+QTDIR=""
+IS_DEBUG=0
+HAVE_CORE=0
+HAVE_SVG=0
+HAVE_PHONON=0
+HAVE_SCRIPT=0
+HAVE_SQL=0
+HAVE_WEBKIT=0
+
+function handleFile()
+{
+ local FILE=$1
+ local BUNDLE=$2
+
+ # all dynamic libs directly needed by the bundle, which are not in /System/Library or in /usr/lib (which are system default libs, which we don't want)
+ local LIBS=`otool -L $FILE | grep -v 'executable_path' | grep -v '/System/Library' | grep -v '/usr/lib' | grep '/' | sed -ne 's,^ *\(.*\) (.*,\1,p'`
+
+ local lib
+ for lib in $LIBS; do
+ local NAME=`basename $lib`
+
+ if echo $NAME | grep 'QtCore' >/dev/null; then
+ HAVE_CORE=1
+ QTDIR=`echo $lib | sed -ne 's,^\(.*\)/lib/[^/]*QtCore.*$,\1,p'`
+ if echo $NAME | grep 'debug' >/dev/null; then
+ IS_DEBUG=1
+ fi
+ elif echo $NAME | grep 'QtSvg' >/dev/null; then
+ HAVE_SVG=1
+ elif echo $NAME | grep 'phonon' >/dev/null; then
+ HAVE_PHONON=1
+ elif echo $NAME | grep 'QtScript' >/dev/null; then
+ HAVE_SCRIPT=1
+ elif echo $NAME | grep 'QtSql' >/dev/null; then
+ HAVE_SQL=1
+ elif echo $NAME | grep 'QtWebKit' >/dev/null; then
+ HAVE_WEBKIT=1
+ fi
+
+ if [ `basename $FILE` != $NAME ]; then
+
+ # this part handles libraries which are Mac OS X frameworks
+ if echo $lib | grep '\.framework' >/dev/null; then
+ local FRAMEWORKPATH=`echo $lib | sed -ne 's,\(.*\.framework\).*,\1,p'`
+ local FRAMEWORKNAME=`basename $FRAMEWORKPATH`
+ local NEWFRAMEWORKPATH=`echo $lib | sed -ne "s,.*\($FRAMEWORKNAME\),\1,p"`
+
+ # Qt installed via the precompled binaries...
+ if [ $FRAMEWORKPATH = $FRAMEWORKNAME ]; then
+ FRAMEWORKPATH="/Library/Frameworks/$FRAMEWORKNAME"
+ if [ ! -e "$FRAMEWORKPATH" ]; then
+ echo "Framework $FRAMEWORKNAME not found."
+ exit 1
+ fi
+ fi
+
+ if [ ! -e "$BUNDLE/Contents/Frameworks/$NEWFRAMEWORKPATH" ]; then
+ echo Embedding framework $FRAMEWORKNAME
+
+
+ # copy the framework into the bundle
+ cp -R $FRAMEWORKPATH $BUNDLE/Contents/Frameworks
+ # remove debug libs we've copied
+ find $BUNDLE/Contents/Frameworks/$FRAMEWORKNAME -regex '.*_debug\(\.dSYM\)*' | xargs rm -rf
+
+ handleFile "$BUNDLE/Contents/Frameworks/$NEWFRAMEWORKPATH" "$BUNDLE"
+ fi
+ # and inform the dynamic linker about this
+ install_name_tool -change $lib @executable_path/../Frameworks/$NEWFRAMEWORKPATH $FILE
+
+
+ # this part handles 'normal' dynamic libraries (.dylib)
+ else
+ if [ ! -e "$BUNDLE/Contents/Frameworks/$NAME" ]; then
+ echo Embedding library $NAME
+
+ # Qt installed via the precompled binaries...
+ if [ $lib = $NAME ]; then
+ lib="/Library/Frameworks/$NAME"
+ if [ ! -e "$lib" ]; then
+ lib="/usr/lib/$NAME"
+ fi
+ if [ ! -e "$lib" ]; then
+ echo "Library $NAME not found."
+ exit 1
+ fi
+ fi
+
+ # copy the lib into the bundle
+ cp $lib $BUNDLE/Contents/Frameworks
+ handleFile "$BUNDLE/Contents/Frameworks/$NAME" "$BUNDLE"
+ fi
+
+ # and inform the dynamic linker about this
+ install_name_tool -change $lib @executable_path/../Frameworks/$NAME $FILE
+ fi
+
+ fi
+ done
+}
+
+function handleQtPlugins()
+{
+ local PLUGINPATH=$QTDIR/plugins
+
+ # QTDIR was not found, then we're using /Developer/Applications/Qt
+ if [ "$PLUGINPATH" = "/plugins" ]; then
+ PLUGINPATH="/Developer/Applications/Qt/plugins"
+ fi
+
+ CLASS=$1
+ EXECUTABLE=$2
+ BUNDLE=$3
+ mkdir -p $BUNDLE/Contents/plugins/$CLASS
+ echo Add $CLASS plugins
+ for plugin in `ls $PLUGINPATH/$CLASS/*`; do
+ plugin=`basename $plugin`
+ if echo $plugin | grep 'debug' >/dev/null; then
+ #if [ $IS_DEBUG -eq 1 ]; then
+ cp "$PLUGINPATH/$CLASS/$plugin" $BUNDLE/Contents/plugins/$CLASS
+ install_name_tool -change $plugin @executable_path/../plugins/$CLASS/$plugin $EXECUTABLE
+ handleFile $BUNDLE/Contents/plugins/$CLASS/$plugin $BUNDLE
+ #fi
+ else
+ #if [ $IS_DEBUG -eq 0 ]; then
+ cp "$PLUGINPATH/$CLASS/$plugin" $BUNDLE/Contents/plugins/$CLASS
+ install_name_tool -change $plugin @executable_path/../plugins/$CLASS/$plugin $EXECUTABLE
+ handleFile $BUNDLE/Contents/plugins/$CLASS/$plugin $BUNDLE
+ #fi
+ fi
+ done
+}
+
+# the app bundle we're working with
+BUNDLE=$1
+# the executable inside of the bundle
+EXECUTABLE=$BUNDLE/Contents/MacOS/`xargs < $BUNDLE/Contents/Info.plist | sed -ne 's,.*<key>CFBundleExecutable</key> <string>\([^<]*\)</string>.*,\1,p'`
+
+mkdir -p $BUNDLE/Contents/Frameworks
+
+handleFile $EXECUTABLE $BUNDLE
+
+if [ $HAVE_CORE -eq 1 ]; then
+ handleQtPlugins "imageformats" "$EXECUTABLE" "$BUNDLE"
+fi
+if [ $HAVE_SVG -eq 1 ]; then
+ handleQtPlugins "iconengines" "$EXECUTABLE" "$BUNDLE"
+fi
+if [ $HAVE_PHONON -eq 1 ]; then
+ handleQtPlugins "phonon_backend" "$EXECUTABLE" "$BUNDLE"
+fi
+if [ $HAVE_SQL -eq 1 ]; then
+ handleQtPlugins "sqldrivers" "$EXECUTABLE" "$BUNDLE"
+fi
+if [ $HAVE_WEBKIT -eq 1 ]; then
+ handleQtPlugins "codecs" "$EXECUTABLE" "$BUNDLE"
+fi
diff --git a/installerbuilder/binarycreator/resources/default_icon_mac.icns b/installerbuilder/binarycreator/resources/default_icon_mac.icns
new file mode 100644
index 000000000..8d870d649
--- /dev/null
+++ b/installerbuilder/binarycreator/resources/default_icon_mac.icns
Binary files differ
diff --git a/installerbuilder/binarycreator/resources/mkdmg.sh b/installerbuilder/binarycreator/resources/mkdmg.sh
new file mode 100644
index 000000000..46606c125
--- /dev/null
+++ b/installerbuilder/binarycreator/resources/mkdmg.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Creates a disk image (dmg) on Mac OS X from the command line.
+# usage:
+# mkdmg <volname> <vers> <srcdir>
+#
+# Where <volname> is the name to use for the mounted image, <vers> is the version
+# number of the volume and <srcdir> is where the contents to put on the dmg are.
+#
+# The result will be a file called <volname>-<vers>.dmg
+
+if [ $# != 2 ]; then
+ echo "usage: mkdmg.sh volname srcdir"
+ exit 0
+fi
+
+VOL="$1"
+FILES="$2"
+PATHNAME=`dirname $FILES`
+
+DMG=`mktemp "/tmp/$VOL.XXXXXX.dmg"`
+
+# create temporary disk image and format, ejecting when done
+SIZE=`du -sk ${FILES} | sed -n 's,^\([0-9]*\).*,\1,p'`
+SIZE=$((${SIZE}/1000+1))
+hdiutil create "$DMG" -megabytes ${SIZE} -ov -volname "$VOL" -type UDIF -fs HFS+ >/dev/null
+DISK=`hdid "$DMG" | sed -ne 's,^\(.*\) *Apple_H.*,\1,p'`
+MOUNT=`hdid "$DMG" | sed -ne 's,^.*Apple_HFS[^/]*\(/.*\)$,\1,p'`
+
+# mount and copy files onto volume
+cp -R "$PATHNAME/`basename $FILES`" "$MOUNT"
+hdiutil eject $DISK >/dev/null
+
+# convert to compressed image, delete temp image
+rm -f "$PATHNAME/${VOL}.dmg"
+hdiutil convert "$DMG" -format UDZO -o "$PATHNAME/${VOL}.dmg" >/dev/null
+rm -f "$DMG"
diff --git a/installerbuilder/common/binaryformat.cpp b/installerbuilder/common/binaryformat.cpp
new file mode 100644
index 000000000..d418d0f98
--- /dev/null
+++ b/installerbuilder/common/binaryformat.cpp
@@ -0,0 +1,952 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "binaryformat.h"
+#include "errors.h"
+#include "fileutils.h"
+#include "utils.h"
+#include "zipjob.h"
+
+#include "lib7z_facade.h"
+
+#include <QDir>
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QDebug>
+#include <QResource>
+#include <QTemporaryFile>
+#include <QThreadPool>
+#include <QVector>
+
+#include "common/kd7zenginehandler.h"
+
+#include <KDUpdater/UpdateOperation>
+#include <KDUpdater/UpdateOperationFactory>
+
+#include <cassert>
+#include <cerrno>
+
+using namespace QInstaller;
+using namespace QInstallerCreator;
+
+/*
+TRANSLATOR QInstallerCreator::Archive
+*/
+
+/*
+TRANSLATOR QInstallerCreator::Component
+*/
+
+static inline QByteArray &theBuffer(int size)
+{
+ static QByteArray b;
+ if (size > b.size())
+ b.resize( size );
+ return b;
+}
+
+void QInstaller::appendFileData(QIODevice *out, QIODevice *in)
+{
+ assert( !in->isSequential() );
+ const qint64 size = in->size();
+ blockingCopy( in, out, size );
+}
+
+
+void QInstaller::retrieveFileData(QIODevice *out, QIODevice *in)
+{
+ qint64 size = QInstaller::retrieveInt64(in);
+ appendData( in, out, size );
+/* QByteArray &b = theBuffer(size);
+ blockingRead(in, b.data(), size);
+ blockingWrite(out, b.constData(), size);*/
+}
+
+void QInstaller::appendInt64(QIODevice *out, qint64 n)
+{
+ blockingWrite(out, reinterpret_cast<const char*>( &n ), sizeof(n));
+}
+
+void QInstaller::appendInt64Range( QIODevice* out, const Range<qint64>& r ) {
+ appendInt64( out, r.start() );
+ appendInt64( out, r.length() );
+}
+
+qint64 QInstaller::retrieveInt64(QIODevice *in)
+{
+ qint64 n = 0;
+ blockingRead( in, reinterpret_cast<char*>( &n ), sizeof(n) );
+ return n;
+}
+
+Range< qint64 > QInstaller::retrieveInt64Range( QIODevice* in )
+{
+ const quint64 start = retrieveInt64( in );
+ const quint64 length = retrieveInt64( in );
+ return Range< qint64 >::fromStartAndLength( start, length );
+}
+
+
+
+#if 0
+// Faster or not?
+static void appendFileData(QIODevice *out, const QString &fileName)
+{
+ QFile file(fileName);
+ openForRead(file);
+ qint64 size = file.size();
+ QInstaller::appendInt64(out, size);
+ if (size == 0)
+ return;
+ uchar *data = file.map(0, size);
+ if (!data)
+ throw Error(QInstaller::tr("Cannot map file %1").arg(file.fileName()));
+ blockingWrite(out, (const char *)data, size);
+ if (!file.unmap(data))
+ throw Error(QInstaller::tr("Cannot unmap file %1").arg(file.fileName()));
+}
+#endif
+
+void QInstaller::appendData(QIODevice *out, QIODevice *in, qint64 size)
+{
+ while( size > 0 )
+ {
+ const qint64 nextSize = qMin( size, 16384LL );
+ QByteArray &b = theBuffer( nextSize );
+ blockingRead( in, b.data(), nextSize );
+ blockingWrite( out, b.constData(), nextSize );
+ size -= nextSize;
+ }
+}
+
+void QInstaller::appendString(QIODevice *out, const QString &str)
+{
+ appendByteArray( out, str.toUtf8() );
+}
+
+void QInstaller::appendByteArray(QIODevice *out, const QByteArray &ba)
+{
+ appendInt64(out, ba.size());
+ blockingWrite(out, ba.constData(), ba.size());
+}
+
+void QInstaller::appendStringList(QIODevice *out, const QStringList &list)
+{
+ appendInt64( out, list.size() );
+ Q_FOREACH ( const QString &s, list )
+ appendString(out, s);
+}
+
+void QInstaller::appendDictionary(QIODevice *out, const QHash<QString,QString>& dict)
+{
+ appendInt64(out, dict.size());
+ Q_FOREACH (const QString &key, dict.keys()) {
+ appendString(out, key);
+ appendString(out, dict.value(key));
+ }
+}
+
+QString QInstaller::retrieveString(QIODevice *in)
+{
+ const QByteArray b = retrieveByteArray( in );
+ return QString::fromUtf8( b );
+}
+
+QByteArray QInstaller::retrieveByteArray(QIODevice *in)
+{
+ QByteArray ba;
+ const qint64 n = retrieveInt64( in );
+ ba.resize( n );
+ blockingRead( in, ba.data(), n );
+ return ba;
+}
+
+QStringList QInstaller::retrieveStringList(QIODevice *in)
+{
+ QStringList list;
+ for(qint64 i = retrieveInt64(in); --i >= 0; )
+ list << retrieveString(in);
+ return list;
+}
+
+QHash<QString,QString> QInstaller::retrieveDictionary(QIODevice *in)
+{
+ QHash<QString,QString> dict;
+ for (qint64 i = retrieveInt64(in); --i >= 0; ) {
+ QString key = retrieveString(in);
+ dict.insert(key, retrieveString(in));
+ }
+ return dict;
+}
+
+qint64 QInstaller::findMagicCookie( QFile* in ) {
+ assert( in );
+ assert( in->isOpen() );
+ assert( in->isReadable() );
+ const qint64 oldPos = in->pos();
+ const qint64 MAX_SEARCH = 1024 * 1024; // stop searching after one MB
+ qint64 searched = 0;
+ try {
+ while ( searched < MAX_SEARCH ) {
+ const qint64 pos = in->size() - searched - sizeof( qint64 );
+ if ( pos < 0 )
+ throw Error( QObject::tr("Searched whole file, no marker found") );
+ if ( !in->seek( pos ) )
+ throw Error( QObject::tr("Could not seek to %1 in file %2: %3.").arg( QString::number(pos), in->fileName(), in->errorString() ) );
+ const quint64 num = static_cast<quint64>( retrieveInt64( in ) );
+ if ( num == MagicCookie ) {
+ in->seek( oldPos );
+ return pos;
+ }
+ searched += 1;
+ }
+ throw Error( QObject::tr("No marker found, stopped after %1 bytes").arg( QString::number( MAX_SEARCH ) ) );
+ } catch ( const Error& err ) {
+ in->seek( oldPos );
+ throw err;
+ } catch ( ... ) {
+ in->seek( oldPos );
+ throw Error( QObject::tr("No marker found, unknown exception caught.") );
+ }
+ return -1; // never reached
+}
+
+/**
+ * Creates an archive providing the data in \a path.
+ * \a path can be a path to a file or to a directory. If it's a file, it's considered to be
+ * pre-zipped and gets delivered as it is. If it's a directory, it gets zipped by Archive.
+ */
+Archive::Archive( const QString& path )
+ : m_device( 0 ),
+ m_isTempFile( false ),
+ m_path( path ),
+ m_name( QFileInfo( path ).fileName().toUtf8() )
+{
+}
+
+Archive::Archive( const QByteArray& identifier, const QByteArray& data )
+ : m_device( 0 ),
+ m_isTempFile( true ),
+ m_path( generateTemporaryFileName() ),
+ m_name( identifier )
+{
+ QFile file( m_path );
+ file.open( QIODevice::WriteOnly );
+ file.write( data );
+}
+
+/**
+ * Creates an archive identified by \a identifier providing a data \a segment within a \a device.
+ */
+Archive::Archive( const QByteArray& identifier, QIODevice* device, const Range< qint64 >& segment )
+ : m_device( device ),
+ m_segment( segment ),
+ m_isTempFile( false ),
+ m_name( identifier )
+{
+}
+
+Archive::~Archive()
+{
+ if( isOpen() )
+ close();
+ if( m_isTempFile )
+ QFile::remove( m_path );
+}
+
+/**
+ * Copies the archives contents to the path \a name.
+ *
+ * If the archive is a zipped directory, \a name is threated as a directory. The archive
+ * gets extracted there.
+ *
+ * If the archive is a plain file and \a name an existing directory, it gets created
+ * with it's name. Otherwise it gets saved as \a name.
+ * Note that if a file with the \a name already exists, copy() return false (i.e. Archive will not overwrite it).
+ */
+bool Archive::copy( const QString& name )
+{
+ if( isZippedDirectory() )
+ {
+ const QFileInfo fi( name );
+ if( fi.exists() && !fi.isDir() )
+ return false;
+ errno = 0;
+ if( !fi.exists() && !QDir().mkpath( fi.absoluteFilePath() ) ) {
+ setErrorString( tr("Could not create %1: %2").arg( name, QString::fromLocal8Bit( strerror( errno ) ) ) );
+ return false;
+ }
+
+ UnzipJob job;
+ if( isOpen() )
+ close();
+ open( QIODevice::ReadOnly );
+ job.setInputDevice( this );
+ job.setOutputPath( fi.absoluteFilePath() );
+
+ job.run();
+
+ close();
+
+ return true;
+ }
+ else
+ {
+ if( isOpen() )
+ close();
+
+ open( QIODevice::ReadOnly );
+
+ QFile target( QFileInfo( name ).isDir() ? QString::fromLatin1( "%1/%2" ).arg( name ).arg( QString::fromUtf8( m_name.data(), m_name.count() ) ) : name );
+ if( target.exists() )
+ return false;
+ target.open( QIODevice::WriteOnly );
+ blockingCopy( this, &target, size() );
+
+ close();
+ return true;
+ }
+}
+
+/**
+ * \reimp
+ */
+bool Archive::seek( qint64 pos )
+{
+ if( m_inputFile.isOpen() )
+ return m_inputFile.seek( pos ) && QIODevice::seek( pos );
+ return QIODevice::seek( pos );
+}
+
+/**
+ * Returns true, if this archive was created by zipping a directory.
+ */
+bool Archive::isZippedDirectory() const
+{
+ if( m_device == 0 )
+ {
+ // easy, just check wheter it's a dir
+ return QFileInfo( m_path ).isDir();
+ }
+ else
+ {
+ // more complex, check the zip header magic
+ Archive* const arch = const_cast< Archive* >( this );
+
+ const bool opened = !isOpen();
+ if( opened )
+ arch->open( QIODevice::ReadOnly );
+ const qint64 p = pos();
+ arch->seek( 0 );
+
+ const QByteArray ba = arch->read( 4 );
+ const bool result = ba == QByteArray( "\x50\x4b\x03\04" );
+
+ arch->seek( p );
+ if( opened )
+ arch->close();
+ return result;
+ }
+}
+
+QByteArray Archive::name() const
+{
+ return m_name;
+}
+
+void Archive::setName( const QByteArray& name )
+{
+ m_name = name;
+}
+
+/**
+ * \reimpl
+ */
+void Archive::close()
+{
+ m_inputFile.close();
+ if( QFileInfo( m_path ).isDir() )
+ m_inputFile.remove();
+ QIODevice::close();
+}
+
+/**
+ * \reimp
+ */
+bool Archive::open( OpenMode mode )
+{
+ if( isOpen() )
+ return false;
+
+ const bool writeOnly = ( mode & QIODevice::WriteOnly ) != QIODevice::NotOpen;
+ const bool append = ( mode & QIODevice::Append ) != QIODevice::NotOpen;
+
+ // no write support
+ if( writeOnly || append )
+ return false;
+
+ if( m_device != 0 )
+ return QIODevice::open( mode );
+
+ // we
+
+ const QFileInfo fi( m_path );
+ if( fi.isFile() )
+ {
+ m_inputFile.setFileName( m_path );
+ if( !m_inputFile.open( mode ) ) {
+ setErrorString( tr("Could not open archive file %1 for reading.").arg( m_path ) );
+ return false;
+ }
+
+/* if ( !Lib7z::isSupportedArchive( &m_inputFile ) ) {
+ setErrorString( tr("Not in a supported archive format: %1").arg( m_path ) );
+ m_inputFile.close();
+ return false;
+ }*/
+
+ setOpenMode( mode );
+ return true;
+ }
+
+ if( fi.isDir() )
+ {
+ if( m_inputFile.fileName().isEmpty() || !m_inputFile.exists() )
+ {
+ if( !createZippedFile() )
+ return false;
+ }
+ Q_ASSERT( !m_inputFile.fileName().isEmpty() );
+ if( !m_inputFile.open( mode ) )
+ return false;
+ setOpenMode( mode );
+ return true;
+ }
+
+ setErrorString(tr("Could not create archive from %1: Not a file.").arg( m_path ) );
+ return false;
+}
+
+bool Archive::createZippedFile()
+{
+ QTemporaryFile file;
+ file.setAutoRemove( false );
+ if ( !file.open() )
+ return false;
+ m_inputFile.setFileName( file.fileName() );
+ file.close();
+ m_inputFile.open( QIODevice::ReadWrite );
+ try {
+ Lib7z::createArchive( &m_inputFile, m_path );
+ } catch( Lib7z::SevenZipException &e ) {
+ m_inputFile.close();
+ setErrorString( e.message() );
+ return false;
+ }
+ if( !Lib7z::isSupportedArchive( &m_inputFile ) )
+ {
+ m_inputFile.close();
+ setErrorString( tr( "Error while packing directory at %1" ).arg( m_path ) );
+ return false;
+ }
+ m_inputFile.close();
+ return true;
+}
+
+/**
+ * \reimp
+ */
+qint64 Archive::size() const
+{
+ // if we got a device, we just pass the length of the segment
+ if( m_device != 0 )
+ return m_segment.length();
+
+ const QFileInfo fi( m_path );
+ // if we got a regular file, we pass the size of the file
+ if( fi.isFile() )
+ return fi.size();
+ else if( fi.isDir() )
+ {
+ if( m_inputFile.fileName().isEmpty() || !m_inputFile.exists() )
+ {
+ if( !const_cast< Archive* >( this )->createZippedFile() )
+ throw Error(QObject::tr("Cannot create zipped file for path %1: %2").arg( m_path, errorString() ) );
+ }
+ Q_ASSERT( !m_inputFile.fileName().isEmpty() );
+ return m_inputFile.size();
+ }
+ return 0;
+}
+
+/**
+ * \reimp
+ */
+qint64 Archive::readData( char* data, qint64 maxSize )
+{
+ if( m_device == 0 )
+ return m_inputFile.read( data, maxSize );
+
+ const qint64 p = m_device->pos();
+ m_device->seek( m_segment.start() + pos() );
+ const qint64 amountRead = m_device->read( data, qMin< quint64 >( maxSize, m_segment.length() - pos() ) );
+ m_device->seek( p );
+ return amountRead;
+}
+
+/**
+ * \reimp
+ */
+qint64 Archive::writeData( const char* data, qint64 maxSize )
+{
+ Q_UNUSED( data );
+ Q_UNUSED( maxSize );
+ // should never be called, as we're read only
+ return -1;
+}
+
+QByteArray Component::name() const {
+ return m_name;
+}
+
+void Component::setName( const QByteArray& ba ) {
+ m_name = ba;
+}
+
+Range<qint64> Component::binarySegment() const {
+ return m_binarySegment;
+}
+
+void Component::setBinarySegment( const Range<qint64>& r ) {
+ m_binarySegment = r;
+}
+
+Component Component::readFromIndexEntry( QIODevice* in, qint64 offset )
+{
+ Component c;
+ c.m_name = retrieveByteArray( in );
+ c.m_binarySegment = retrieveInt64Range( in ).moved( offset );
+
+ c.readData( in, offset );
+
+ return c;
+}
+
+void Component::writeIndexEntry( QIODevice* out, qint64 positionOffset ) const
+{
+ appendByteArray( out, m_name );
+ const Range<qint64> relative = m_binarySegment.moved( positionOffset );
+ appendInt64( out, binarySegment().start() );
+ appendInt64( out, binarySegment().length() );
+}
+
+void Component::writeData( QIODevice* out, qint64 offset ) const {
+ const qint64 dataBegin = out->pos() + offset;
+
+ appendInt64( out, m_archives.count() );
+
+ qint64 start = out->pos() + offset;
+
+ // add 16 + 16 + number of name characters for each archive (the size of the table)
+ for( QVector< QSharedPointer< Archive > >::const_iterator it = m_archives.begin(); it != m_archives.end(); ++it )
+ start += 3 * sizeof( qint64 ) + (*it)->name().count();
+
+ QList< qint64 > starts;
+
+ for( QVector< QSharedPointer< Archive > >::const_iterator it = m_archives.begin(); it != m_archives.end(); ++it )
+ {
+ const Archive* const arch = (*it).data();
+ appendByteArray( out, arch->name() );
+ starts.push_back( start );
+ appendInt64Range( out, Range< qint64 >::fromStartAndLength( start, arch->size() ) );
+ start += arch->size();
+ }
+
+ for( QVector< QSharedPointer< Archive > >::const_iterator it = m_archives.begin(); it != m_archives.end(); ++it )
+ {
+ if( !(*it)->open( QIODevice::ReadOnly ) )
+ throw Error( tr("Could not open archive %1: %2").arg( QLatin1String( (*it)->name() ), (*it)->errorString() ) );
+ const qint64 expectedStart = starts.takeFirst();
+ const qint64 actualStart = out->pos() + offset;
+ Q_UNUSED( expectedStart );
+ Q_UNUSED( actualStart );
+ Q_ASSERT( expectedStart == actualStart );
+ blockingCopy( it->data(), out, (*it)->size() );
+ }
+
+ m_binarySegment = Range<qint64>::fromStartAndEnd( dataBegin, out->pos() + offset );
+}
+
+void Component::readData( QIODevice* in, qint64 offset )
+{
+ const qint64 pos = in->pos();
+
+ in->seek( m_binarySegment.start() );
+ const qint64 count = retrieveInt64( in );
+
+ QVector< QByteArray > names;
+ QVector< Range< qint64 > > ranges;
+ for( int i = 0; i < count; ++i )
+ {
+ names.push_back( retrieveByteArray( in ) );
+ ranges.push_back( retrieveInt64Range( in ).moved( offset ) );
+ }
+
+ for( int i = 0; i < ranges.count(); ++i )
+ m_archives.push_back( QSharedPointer< Archive >( new Archive( names.at( i ), in, ranges.at( i ) ) ) );
+
+ in->seek( pos );
+}
+
+QString Component::dataDirectory() const {
+ return m_dataDirectory;
+}
+
+void Component::setDataDirectory( const QString& path ) {
+ m_dataDirectory = path;
+}
+
+bool Component::operator<( const Component& other ) const {
+ if ( m_name != other.name() )
+ return m_name < other.m_name;
+ return m_binarySegment < other.m_binarySegment;
+}
+
+bool Component::operator==( const Component& other ) const {
+ return m_name == other.m_name && m_binarySegment == other.m_binarySegment;
+}
+
+Component ComponentIndex::componentByName( const QByteArray& id ) const {
+ return m_components.value( id );
+}
+
+/**
+ * Destroys this component.
+ */
+Component::~Component()
+{
+}
+
+/**
+ * Appends \a archive to this component.
+ * The componet takes ownership of \a archive.
+ */
+void Component::appendArchive( const QSharedPointer<Archive>& archive )
+{
+ assert( archive );
+ archive->setParent( 0 );
+ m_archives.push_back( archive );
+}
+
+/**
+ * Returns the archives associated with this component.
+ */
+QVector< QSharedPointer<Archive> > Component::archives() const
+{
+ return m_archives;
+}
+
+QSharedPointer<Archive> Component::archiveByName( const QByteArray& name ) const
+{
+ Q_FOREACH( const QSharedPointer<Archive>& i, m_archives )
+ if( i->name() == name )
+ return i;
+ return QSharedPointer<Archive>();
+}
+
+void ComponentIndex::insertComponent( const Component& c )
+{
+ m_components.insert( c.name(), c );
+}
+
+int ComponentIndex::componentCount() const
+{
+ return m_components.size();
+}
+
+void ComponentIndex::removeComponent( const QByteArray& name ) {
+ m_components.remove( name );
+}
+
+QVector<Component> ComponentIndex::components() const {
+ return m_components.values().toVector();
+}
+
+void ComponentIndex::writeComponentData( QIODevice* out, qint64 offset ) const {
+ appendInt64( out, componentCount() );
+
+ for( QHash< QByteArray, Component >::const_iterator it = m_components.begin(); it != m_components.end(); ++it )
+ it->writeData( out, offset );
+}
+
+KD7zEngineHandler* ComponentIndex::zipHandler = 0;
+
+ComponentIndex::ComponentIndex()
+{
+ if( zipHandler == 0 ) {
+ // TODO: this one get leaked
+ zipHandler = new KD7zEngineHandler;
+ }
+}
+
+ComponentIndex ComponentIndex::read( QIODevice* dev, qint64 offset )
+{
+ ComponentIndex result;
+ const qint64 size = retrieveInt64( dev );
+ for( int i = 0; i < size; ++i )
+ result.insertComponent( Component::readFromIndexEntry( dev, offset ) );
+ retrieveInt64( dev );
+ return result;
+}
+
+void ComponentIndex::writeIndex( QIODevice* out, qint64 offset ) const
+{
+ // Q: why do we write the size twice?
+ // A: for us to be able to read it beginning from the end of the file as well
+ appendInt64( out, componentCount() );
+ Q_FOREACH( const Component& i, components() )
+ i.writeIndexEntry( out, offset );
+ appendInt64( out, componentCount() );
+}
+
+/*!
+ \internal
+ Registers the resource found at \a segment within \a file into the Qt resource system.
+ */
+static const uchar* addResourceFromBinary( QFile* file, const Range< qint64 >& segment )
+{
+ if ( segment.length() <= 0 )
+ return 0;
+
+ const uchar* const mapped = file->map( segment.start(), segment.length() );
+ if ( !mapped )
+ throw Error( QObject::tr("Could not mmap in-binary resource. (offset=%1, length=%2").arg( QString::number( segment.start() ), QString::number( segment.length() ) ) );
+
+ if ( !QResource::registerResource( mapped, QLatin1String(":/metadata") ) )
+ throw Error( QObject::tr("Could not register in-binary resource.") );
+
+ return mapped;
+}
+
+BinaryContent::BinaryContent( const QString& path )
+ : file( new QFile( path ) ),
+ handler( components ),
+ magicmaker( 0 ),
+ dataBlockStart( 0 )
+{
+}
+
+BinaryContent::~BinaryContent()
+{
+ for( QVector< const uchar* >::const_iterator it = mappings.begin(); it != mappings.end(); ++it )
+ QResource::unregisterResource( *it );
+}
+
+/*!
+ \internal
+ Registers the Qt resources embedded in this binary.
+ */
+int BinaryContent::registerEmbeddedQResources()
+{
+ if( !file->isOpen() )
+ if( !file->open( QIODevice::ReadOnly ))
+ throw Error( QObject::tr("Could not open binary %1: %2").arg( file->fileName(), file->errorString() ) );
+ Q_FOREACH( const Range<qint64>& i, metadataResourceSegments )
+ mappings.push_back( addResourceFromBinary( file.data(), i ) );
+ //file->close();
+ return mappings.count();
+}
+
+/*!
+ \internal
+ \fn static BinaryContent BinaryContent::readFromApplicationFile()
+ Reads BinaryContent stored in the current application binary.
+ */
+BinaryContent BinaryContent::readFromApplicationFile()
+{
+ return BinaryContent::readFromBinary( QCoreApplication::applicationFilePath() );
+}
+
+/*!
+ * \class QInstaller::BinaryContent
+ *
+ * BinaryContent handles binary information embedded into executables.
+ * Qt resources as well as component information can be stored.
+ *
+ * Explanation of the binary blob at the end of the file:
+ *
+ * \verbatim
+ * Meta data segment 0
+ * Meta data segment ...
+ * Meta data segment n
+ * ------------------------------------------------------
+ * Component data segment 0
+ * Component data segment ..
+ * Component data segment n
+ * ------------------------------------------------------
+ * Component index segment
+ * ------------------------------------------------------
+ * quint64 offset of component index segment
+ * quint64 length of component index segment
+ * ------------------------------------------------------
+ * quint64 offset of meta data segment 0
+ * quint64 length of meta data segment 0
+ * quint64 offset of meta data segment ..
+ * quint64 length of meta data segment ..
+ * quint64 offset of meta data segment n
+ * quint64 length of meta data segment n
+ * ------------------------------------------------------
+ * quint64 number of meta data segments
+ * quint64 Magic cookie (0xc2 0x63 0x0a 0x1c 0x99 0xd6 0x68 0xf8)
+ * <eof>
+ *
+ * All offsets are addresses relative to the end of the file.
+ *
+ * Meta data segments are stored as Qt resources, which must be "mounted"
+ * via QResource::registerResource()
+ *
+ * Component index segment:
+ * quint64 number of index entries
+ * QString identifier of component 0
+ * quint64 offset of component data segment 0
+ * quint64 length of component data segment 0
+ * QString identifier of component ..
+ * quint64 offset of component data segment ..
+ * quint64 length of component data segment ..
+ * QString identifier of component n
+ * quint64 offset of component data segment n
+ * quint64 length of component data segment n
+ * quint64 number of index entries
+ *
+ * Component data segment:
+ * quint64 number of archives in this component
+ * QString name of archive 0
+ * quint64 offset of archive 0
+ * quint64 length of archive 0
+ * QString name of archive ..
+ * quint64 offset of archive ..
+ * quint64 length of archive ..
+ * QString name of archive n
+ * quint64 offset of archive n
+ * quint64 length of archive n
+ * Archive 0
+ * Archive ..
+ * Archive n
+ * \endverbatim
+ */
+
+BinaryContent BinaryContent::readFromBinary( const QString& path ) {
+ BinaryContent c( path );
+
+ QFile* const file = c.file.data();
+
+ if ( !file->open( QIODevice::ReadOnly ) )
+ throw Error( QObject::tr("Could not open binary %1: %2").arg( path, file->errorString()) );
+
+ const qint64 cookiepos = findMagicCookie( file );
+ Q_ASSERT( cookiepos >= 0 );
+ const qint64 endOfData = cookiepos + sizeof( qint64 );
+ const qint64 indexSize = 6 * sizeof( qint64 );
+ if ( !file->seek( endOfData - indexSize ) )
+ throw Error( QObject::tr("Could not seek to binary layout section") );
+
+ qint64 operationsStart = retrieveInt64( file );
+ /*qint64 operationsEnd = */ retrieveInt64( file ); // don't care
+ const qint64 count = retrieveInt64( file );
+ const qint64 dataBlockSize = retrieveInt64( file );
+ const qint64 dataBlockStart = endOfData - dataBlockSize;
+
+ operationsStart += dataBlockStart;
+ //operationsEnd += dataBlockStart;
+ c.magicmaker = retrieveInt64( file );
+
+ const quint64 magicCookie = retrieveInt64( file );
+ Q_UNUSED( magicCookie );
+ Q_ASSERT( magicCookie == MagicCookie );
+
+ const qint64 resourceSectionSize = 2 * sizeof( qint64 ) * count;
+ for( int i = 0; i < count; ++i )
+ {
+ if ( !file->seek(endOfData - indexSize - 2 * sizeof( qint64 ) * ( i + 1 ) ) )
+ throw Error( QObject::tr("Could not seek to metadata index") );
+ const qint64 metadataResourceOffset = retrieveInt64( file ) + dataBlockStart;
+ const qint64 metadataResourceLength = retrieveInt64( file );
+ c.metadataResourceSegments.push_back( Range< qint64 >::fromStartAndLength( metadataResourceOffset, metadataResourceLength ) );
+ }
+
+ if ( !file->seek( operationsStart ) )
+ throw Error( QObject::tr("Could not seek to operation list") );
+ QStack<KDUpdater::UpdateOperation*> performedOperations;
+ const qint64 operationsCount = retrieveInt64(file);
+ verbose() << "operationsCount=" << operationsCount << std::endl;
+
+ for(int i = operationsCount; --i >= 0; )
+ {
+ const QString name = retrieveString( file );
+ const QString xml = retrieveString( file );
+ KDUpdater::UpdateOperation* const op = KDUpdater::UpdateOperationFactory::instance().create( name );
+ QString debugXmlString(xml);
+ debugXmlString.truncate(1000);
+ verbose() << "Operation name=" << name << " xml=\n" << debugXmlString << std::endl;
+ Q_ASSERT_X(op, "BinaryContent::readFromBinary", QString::fromLatin1("Invalid operation name='%1'").arg(name).toLatin1());
+ if( ! op->fromXml( xml ))
+ qWarning() << "Failed to load XML for operation=" << name;
+ performedOperations.push(op);
+ }
+ c.performedOperations = performedOperations;
+
+ // seek to the position of the component index
+ if ( !file->seek( endOfData - indexSize - resourceSectionSize - 2 * sizeof( qint64 ) ) )
+ throw Error( QObject::tr("Could not seek to component index information") );
+
+ const qint64 compIndexStart = retrieveInt64( file ) + dataBlockStart;
+ if ( !file->seek( compIndexStart ) )
+ throw Error( QObject::tr("Could not seek to component index") );
+
+
+ c.components = QInstallerCreator::ComponentIndex::read( file, dataBlockStart );
+ c.handler.setComponentIndex( c.components );
+
+ const QVector< QInstallerCreator::Component > comps = c.components.components();
+ verbose() << "components loaded:" << comps.count() << std::endl;
+ for( QVector< QInstallerCreator::Component >::const_iterator it = comps.begin(); it != comps.end(); ++it )
+ {
+ verbose() << "loaded " << it->name();
+ const QVector<QSharedPointer<Archive> > archives = it->archives();
+ verbose() << " having " << archives.count() << " archives:" << std::endl;
+ Q_FOREACH( const QSharedPointer<Archive>& arch, archives )
+ {
+ verbose() << " " << arch->name() << " (" << arch->size() << " bytes)" << std::endl;
+ }
+ }
+ return c;
+}
diff --git a/installerbuilder/common/binaryformat.h b/installerbuilder/common/binaryformat.h
new file mode 100644
index 000000000..493a0329d
--- /dev/null
+++ b/installerbuilder/common/binaryformat.h
@@ -0,0 +1,208 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef BINARYFORMAT_H
+#define BINARYFORMAT_H
+
+#include "range.h"
+
+#include <QByteArray>
+#include <QCoreApplication>
+#include <QFile>
+#include <QHash>
+#include <QIODevice>
+#include <QStack>
+#include <QString>
+#include <QSharedPointer>
+
+#include "binaryformatenginehandler.h"
+#include "installer_global.h"
+
+class QFile;
+class KD7zEngineHandler;
+
+namespace KDUpdater
+{
+ class UpdateOperation;
+}
+
+namespace QInstaller
+{
+ qint64 INSTALLER_EXPORT findMagicCookie( QFile* file );
+
+ void INSTALLER_EXPORT appendFileData(QIODevice *out, QIODevice *in);
+ void INSTALLER_EXPORT appendInt64( QIODevice* out, qint64 n );
+ void INSTALLER_EXPORT appendInt64Range( QIODevice* out, const Range<qint64>& r );
+ void INSTALLER_EXPORT appendData(QIODevice *out, QIODevice *in, qint64 size);
+ void INSTALLER_EXPORT appendByteArray(QIODevice *out, const QByteArray &ba);
+ void INSTALLER_EXPORT appendString(QIODevice *out, const QString &str);
+ void INSTALLER_EXPORT appendStringList(QIODevice *out, const QStringList &list);
+ void INSTALLER_EXPORT appendDictionary(QIODevice *out, const QHash<QString,QString>& dict);
+
+ void INSTALLER_EXPORT retrieveFileData(QIODevice *out, QIODevice *in);
+ qint64 INSTALLER_EXPORT retrieveInt64( QIODevice* in );
+ Range<qint64> INSTALLER_EXPORT retrieveInt64Range( QIODevice* in );
+ QByteArray INSTALLER_EXPORT retrieveByteArray(QIODevice *in);
+ QString INSTALLER_EXPORT retrieveString(QIODevice *in);
+ QStringList INSTALLER_EXPORT retrieveStringList(QIODevice *in);
+ QHash<QString,QString> INSTALLER_EXPORT retrieveDictionary(QIODevice *in);
+
+ //static qint64 magicInstallerMarker = (0xdea0d345UL << 32) + 0x12023233UL;
+ //static qint64 magicUninstallerMarker = (0xdea0d345UL << 32) + 0x12023234UL;
+ static const qint64 MagicInstallerMarker = 0x12023233UL;
+ static const qint64 MagicUninstallerMarker = 0x12023234UL;
+
+ // this cookie is put at the end of the file to determine wheter we have data
+ static const quint64 MagicCookie = 0xc2630a1c99d668f8LL;
+
+}
+
+namespace QInstallerCreator
+{
+ class Component;
+
+ class INSTALLER_EXPORT Archive : public QIODevice
+ {
+ Q_OBJECT
+ public:
+ explicit Archive( const QString& path );
+ Archive( const QByteArray& name, const QByteArray& data );
+ Archive( const QByteArray& name, QIODevice* device, const Range< qint64 >& segment );
+ ~Archive();
+
+ bool open( OpenMode mode );
+ void close();
+
+ bool seek( qint64 pos );
+ qint64 size() const;
+
+ bool createZippedFile();
+ bool isZippedDirectory() const;
+ bool copy( const QString& name );
+
+ QByteArray name() const;
+ void setName( const QByteArray& name );
+
+ protected:
+ qint64 readData( char* data, qint64 maxSize );
+ qint64 writeData( const char* data, qint64 maxSize );
+
+ Range< qint64 > binarySegment() const;
+
+ private:
+ //used when when reading from the installer
+ QIODevice* const m_device;
+ const Range<qint64> m_segment;
+
+ //used when creating the installer, archive input file
+ QFile m_inputFile;
+ const bool m_isTempFile;
+ const QString m_path;
+ QByteArray m_name;
+ };
+
+ class INSTALLER_EXPORT Component
+ {
+ Q_DECLARE_TR_FUNCTIONS(Component);
+ public:
+ virtual ~Component();
+
+ static Component readFromIndexEntry( QIODevice* dev, qint64 offset );
+ void writeIndexEntry( QIODevice* dev, qint64 offset ) const;
+
+ void writeData( QIODevice* dev, qint64 positionOffset ) const;
+ void readData( QIODevice* dev, qint64 offset );
+
+ QByteArray name() const;
+ void setName( const QByteArray& ba );
+
+ QString dataDirectory() const;
+ void setDataDirectory( const QString& path );
+
+ Range<qint64> binarySegment() const;
+ void setBinarySegment( const Range<qint64>& r );
+
+ void appendArchive( const QSharedPointer<Archive>& archive );
+ QSharedPointer<Archive> archiveByName( const QByteArray& name ) const;
+ QVector< QSharedPointer<Archive> > archives() const;
+
+ bool operator<( const Component& other ) const;
+ bool operator==( const Component& other ) const;
+
+ private:
+ QByteArray m_name;
+ QVector< QSharedPointer< Archive > > m_archives;
+ mutable Range<qint64> m_binarySegment;
+ QString m_dataDirectory;
+ };
+
+
+ class INSTALLER_EXPORT ComponentIndex
+ {
+ public:
+ ComponentIndex();
+ static ComponentIndex read( QIODevice* dev, qint64 offset );
+ void writeIndex( QIODevice* dev, qint64 offset ) const;
+ void writeComponentData( QIODevice* dev, qint64 offset ) const;
+ Component componentByName( const QByteArray& ) const;
+ void insertComponent( const Component& );
+ void removeComponent( const QByteArray& name );
+ QVector<Component> components() const;
+ int componentCount() const;
+
+ protected:
+ static KD7zEngineHandler* zipHandler;
+
+ private:
+ QHash<QByteArray,Component> m_components;
+ };
+}
+
+namespace QInstaller
+{
+ class INSTALLER_EXPORT BinaryContent
+ {
+ explicit BinaryContent( const QString& path );
+
+ public:
+ virtual ~BinaryContent();
+
+ static BinaryContent readFromApplicationFile();
+ static BinaryContent readFromBinary( const QString& path );
+
+ int registerEmbeddedQResources();
+
+ QSharedPointer<QFile> file;
+ QInstallerCreator::ComponentIndex components;
+ QInstallerCreator::BinaryFormatEngineHandler handler;
+ QVector< Range< qint64 > > metadataResourceSegments;
+ QVector< const uchar* > mappings;
+ qint64 magicmaker;
+ qint64 dataBlockStart;
+ QStack<KDUpdater::UpdateOperation*> performedOperations;
+ };
+}
+
+#endif // BINARYFORMAT_H
diff --git a/installerbuilder/common/binaryformatengine.cpp b/installerbuilder/common/binaryformatengine.cpp
new file mode 100644
index 000000000..176072d8a
--- /dev/null
+++ b/installerbuilder/common/binaryformatengine.cpp
@@ -0,0 +1,304 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "binaryformatengine.h"
+
+using namespace QInstallerCreator;
+
+namespace
+{
+class StringListIterator : public QAbstractFileEngineIterator
+{
+public:
+ StringListIterator( const QStringList& list, QDir::Filters filters, const QStringList& nameFilters )
+ : QAbstractFileEngineIterator( filters, nameFilters ),
+ list( list ),
+ index( -1 )
+ {
+ }
+
+ bool hasNext() const
+ {
+ return index < list.size() - 1;
+ }
+
+ QString next()
+ {
+ if( !hasNext() )
+ return QString();
+ ++index;
+ return currentFilePath();
+ }
+
+ QString currentFileName() const
+ {
+ return index < 0 ? QString() : list[ index ];
+ }
+
+private:
+ const QStringList list;
+ int index;
+};
+}
+
+BinaryFormatEngine::BinaryFormatEngine( const ComponentIndex& index, const QString& fileName )
+ : m_index( index )
+ , m_hasComponent( false )
+ , m_hasArchive( false )
+ , m_archive( 0 )
+{
+ setArchive( fileName );
+}
+
+BinaryFormatEngine::~BinaryFormatEngine()
+{
+}
+
+void BinaryFormatEngine::setArchive( const QString& file )
+{
+ m_fileNamePath = file;
+
+ static const QChar sep = QChar::fromLatin1( '/' );
+ static const QString prefix = QString::fromLatin1( "installer://" );
+ Q_ASSERT( file.toLower().startsWith( prefix ) );
+
+ // cut the prefix
+ QString path = file.mid( prefix.length() );
+ while( path.endsWith( sep ) )
+ path.chop( 1 );
+
+ QString arch;
+ const QString comp = path.section( sep, 0, 0 );
+ m_hasComponent = !comp.isEmpty();
+ m_hasArchive = path.contains( sep );
+ if( m_hasArchive )
+ arch = path.section( sep, 1, 1 );
+
+ m_component = m_index.componentByName( comp.toUtf8() );
+ m_archive = m_component.archiveByName( arch.toUtf8() );
+}
+
+/**
+ * \reimp
+ */
+void BinaryFormatEngine::setFileName( const QString& file )
+{
+ setArchive( file );
+}
+
+/**
+ * \reimp
+ */
+bool BinaryFormatEngine::close()
+{
+ if( m_archive == 0 )
+ return false;
+
+ const bool result = m_archive->isOpen();
+ m_archive->close();
+ return result;
+}
+
+/**
+ * \reimp
+ */
+bool BinaryFormatEngine::open( QIODevice::OpenMode mode )
+{
+ return m_archive == 0 ? false : m_archive->open( mode );
+}
+
+/**
+ * \reimp
+ */
+qint64 BinaryFormatEngine::pos() const
+{
+ return m_archive == 0 ? 0 : m_archive->pos();
+}
+
+/**
+ * \reimp
+ */
+qint64 BinaryFormatEngine::read( char* data, qint64 maxlen )
+{
+ return m_archive == 0 ? -1 : m_archive->read( data, maxlen );
+}
+
+/**
+ * \reimp
+ */
+bool BinaryFormatEngine::seek( qint64 offset )
+{
+ return m_archive == 0 ? false : m_archive->seek( offset );
+}
+
+/**
+ * \reimp
+ */
+QString BinaryFormatEngine::fileName( FileName file ) const
+{
+ switch( file )
+ {
+ case BaseName:
+ return m_fileNamePath.section( QChar::fromLatin1( '/' ), -1, -1, QString::SectionSkipEmpty );
+ case PathName:
+ case AbsolutePathName:
+ case CanonicalPathName:
+ return m_fileNamePath.section( QChar::fromLatin1( '/' ), 0, -2, QString::SectionSkipEmpty );
+ case DefaultName:
+ case AbsoluteName:
+ case CanonicalName:
+ return m_fileNamePath;
+ default:
+ return QString();
+ }
+}
+
+/**
+ * \reimp
+ */
+bool BinaryFormatEngine::copy( const QString& newName )
+{
+ if( QFile::exists( newName ) )
+ return false;
+
+ QFile target( newName );
+ if( !target.open( QIODevice::WriteOnly ) )
+ return false;
+
+ qint64 bytesLeft = size();
+ if( !open( QIODevice::ReadOnly ) )
+ return false;
+
+ char data[ 4096 ];
+ while( bytesLeft > 0 )
+ {
+ const qint64 len = qMin< qint64 >( bytesLeft, 4096 );
+ const qint64 bytesRead = read( data, len );
+ if( bytesRead != len )
+ {
+ close();
+ return false;
+ }
+ const qint64 bytesWritten = target.write( data, len );
+ if( bytesWritten != len )
+ {
+ close();
+ return false;
+ }
+ bytesLeft -= len;
+ }
+ close();
+
+ return true;
+}
+
+/**
+ * \reimp
+ */
+QAbstractFileEngine::FileFlags BinaryFormatEngine::fileFlags( FileFlags type ) const
+{
+ FileFlags result;
+ if( ( type & FileType ) && m_archive != 0 )
+ result |= FileType;
+ if( ( type & DirectoryType ) && !m_hasArchive )
+ result |= DirectoryType;
+ if( ( type & ExistsFlag ) && m_hasArchive && m_archive != 0 )
+ result |= ExistsFlag;
+ if( ( type & ExistsFlag ) && !m_hasArchive && !m_component.name().isEmpty() )
+ result |= ExistsFlag;
+
+ return result;
+}
+
+/**
+ * \reimp
+ */
+QAbstractFileEngineIterator* BinaryFormatEngine::beginEntryList( QDir::Filters filters, const QStringList& filterNames )
+{
+ const QStringList entries = entryList( filters, filterNames );
+ return new StringListIterator( entries, filters, filterNames );
+}
+
+/**
+ * \reimp
+ */
+QStringList BinaryFormatEngine::entryList( QDir::Filters filters, const QStringList& filterNames ) const
+{
+ if( m_hasArchive )
+ return QStringList();
+
+ QStringList result;
+
+ if( m_hasComponent && ( filters & QDir::Files ) )
+ {
+ const QVector< QSharedPointer<Archive> > archives = m_component.archives();
+ Q_FOREACH( const QSharedPointer<Archive>& i, archives )
+ result.push_back( QString::fromUtf8( i->name() ) );
+ }
+ else if( !m_hasComponent && ( filters & QDir::Dirs ) )
+ {
+ const QVector< Component > components = m_index.components();
+ Q_FOREACH( const Component& i, components )
+ result.push_back( QString::fromUtf8( i.name() ) );
+ }
+
+ if( filterNames.isEmpty() )
+ return result;
+
+ QList< QRegExp > regexps;
+ Q_FOREACH( const QString& i, filterNames )
+ regexps.push_back( QRegExp( i, Qt::CaseInsensitive, QRegExp::Wildcard ) );
+
+ QStringList entries;
+ Q_FOREACH( const QString& i, result )
+ {
+ bool matched = false;
+ Q_FOREACH( const QRegExp& reg, regexps )
+ {
+ matched = reg.exactMatch( i );
+ if( matched )
+ break;
+ }
+ if( matched )
+ entries.push_back( i );
+ }
+
+ return entries;
+}
+
+/**
+ * \reimp
+ */
+qint64 BinaryFormatEngine::size() const
+{
+ return m_archive == 0 ? 0 : m_archive->size();
+}
diff --git a/installerbuilder/common/binaryformatengine.h b/installerbuilder/common/binaryformatengine.h
new file mode 100644
index 000000000..d6f4e49e6
--- /dev/null
+++ b/installerbuilder/common/binaryformatengine.h
@@ -0,0 +1,73 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef BINARYFORMATENGINE_H
+#define BINARYFORMATENGINE_H
+
+#include <QAbstractFileEngine>
+
+#include "binaryformat.h"
+
+namespace QInstallerCreator
+{
+
+class BinaryFormatEngine : public QAbstractFileEngine
+{
+public:
+ BinaryFormatEngine( const ComponentIndex& index, const QString& fileName );
+ ~BinaryFormatEngine();
+
+ void setFileName( const QString& file );
+
+ Iterator* beginEntryList( QDir::Filters filters, const QStringList& filterNames );
+
+ bool copy( const QString& newName );
+
+ bool close();
+ bool open( QIODevice::OpenMode mode );
+ qint64 pos() const;
+ qint64 read( char* data, qint64 maxlen );
+ bool seek( qint64 offset );
+ qint64 size() const;
+
+ QString fileName( FileName file = DefaultName ) const;
+ FileFlags fileFlags( FileFlags type = FileInfoAll ) const;
+ QStringList entryList( QDir::Filters filters, const QStringList& filterNames ) const;
+
+protected:
+ void setArchive( const QString& file );
+
+private:
+ const ComponentIndex m_index;
+ bool m_hasComponent;
+ bool m_hasArchive;
+ Component m_component;
+ QSharedPointer<Archive> m_archive;
+ QString m_fileNamePath;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/common/binaryformatenginehandler.cpp b/installerbuilder/common/binaryformatenginehandler.cpp
new file mode 100644
index 000000000..7442c1b19
--- /dev/null
+++ b/installerbuilder/common/binaryformatenginehandler.cpp
@@ -0,0 +1,115 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "binaryformatenginehandler.h"
+#include "binaryformatengine.h"
+#include "binaryformat.h"
+
+#include <QDebug>
+#include <QFile>
+#include <QFSFileEngine>
+
+using namespace QInstallerCreator;
+
+static BinaryFormatEngineHandler* s_instance = 0;
+
+
+class BinaryFormatEngineHandler::Private
+{
+public:
+ Private( const ComponentIndex& i )
+ : index( i )
+ {
+ }
+
+ ComponentIndex index;
+};
+
+BinaryFormatEngineHandler::BinaryFormatEngineHandler( const ComponentIndex& index )
+ : d( new Private( index ) )
+{
+ s_instance = this;
+}
+
+BinaryFormatEngineHandler::BinaryFormatEngineHandler( const BinaryFormatEngineHandler& other )
+ : QAbstractFileEngineHandler(),
+ d( new Private( other.d->index ) )
+{
+ s_instance = this;
+}
+
+BinaryFormatEngineHandler::~BinaryFormatEngineHandler()
+{
+ if( s_instance == this )
+ s_instance = 0;
+}
+
+void BinaryFormatEngineHandler::setComponentIndex( const ComponentIndex& index )
+{
+ d->index = index;
+}
+
+QAbstractFileEngine* BinaryFormatEngineHandler::create( const QString& fileName ) const
+{
+ return fileName.startsWith( QLatin1String( "installer://" ), Qt::CaseInsensitive ) ? new BinaryFormatEngine( d->index, fileName ) : 0;
+}
+
+BinaryFormatEngineHandler* BinaryFormatEngineHandler::instance()
+{
+ return s_instance;
+}
+
+void BinaryFormatEngineHandler::registerArchive( const QString& pathName, const QString& archive )
+{
+ static const QChar sep = QChar::fromLatin1( '/' );
+ static const QString prefix = QString::fromLatin1( "installer://" );
+ Q_ASSERT( pathName.toLower().startsWith( prefix ) );
+
+ // cut the prefix
+ QString path = pathName.mid( prefix.length() );
+ while( path.endsWith( sep ) )
+ path.chop( 1 );
+
+ const QString comp = path.section( sep, 0, 0 );
+ const QString archiveName = path.section( sep, 1, 1 );
+
+ Component c = d->index.componentByName( comp.toUtf8() );
+ if( c.name().isEmpty() )
+ c.setName( comp.toUtf8() );
+
+ QList< QSharedPointer< Archive > > registered;
+ QSharedPointer< Archive > newArchive( new Archive( archive ) );
+ newArchive->setName( archiveName.toUtf8() );
+ registered.push_back( newArchive );
+ c.appendArchive( newArchive );
+ d->index.insertComponent( c );
+}
diff --git a/installerbuilder/common/binaryformatenginehandler.h b/installerbuilder/common/binaryformatenginehandler.h
new file mode 100644
index 000000000..1d1a77c41
--- /dev/null
+++ b/installerbuilder/common/binaryformatenginehandler.h
@@ -0,0 +1,61 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef BINARYFORMATENGINEHANDLER_H
+#define BINARYFORMATENGINEHANDLER_H
+
+#include <QtCore/QAbstractFileEngineHandler>
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include "installer_global.h"
+
+namespace QInstallerCreator
+{
+
+class ComponentIndex;
+
+class INSTALLER_EXPORT BinaryFormatEngineHandler : public QAbstractFileEngineHandler
+{
+public:
+ explicit BinaryFormatEngineHandler( const ComponentIndex& index );
+ BinaryFormatEngineHandler( const BinaryFormatEngineHandler& other );
+ ~BinaryFormatEngineHandler();
+ QAbstractFileEngine* create( const QString& fileName ) const;
+
+ void setComponentIndex( const ComponentIndex& index );
+
+ static BinaryFormatEngineHandler* instance();
+
+ void registerArchive( const QString& fileName, const QString& path );
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/common/blockingbuffer.cpp b/installerbuilder/common/blockingbuffer.cpp
new file mode 100644
index 000000000..8879c9c8c
--- /dev/null
+++ b/installerbuilder/common/blockingbuffer.cpp
@@ -0,0 +1,126 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "blockingbuffer.h"
+
+#include <QByteArray>
+#include <QMutex>
+#include <QMutexLocker>
+#include <QWaitCondition>
+
+#include <cassert>
+
+using namespace QInstaller;
+
+class BlockingBuffer::Private {
+public:
+ explicit Private( int siz ) : size( siz ), readPos( 0 ), writePos( 0 ), closed( false ), mutex( QMutex::Recursive ) {
+ data.resize( size );
+ }
+
+ int bytesFree() const {
+ return size - bytesUsed();
+ }
+
+ int bytesUsed() const {
+ return writePos >= readPos ? ( writePos - readPos ) : ( size - readPos + writePos );
+ }
+
+ const int size;
+ QByteArray data;
+ int readPos;
+ int writePos;
+ bool closed;
+ QMutex mutex;
+ QWaitCondition canWrite;
+ QWaitCondition canRead;
+};
+
+BlockingBuffer::BlockingBuffer( int size ) : d( new Private( size ) ) {
+}
+
+BlockingBuffer::~BlockingBuffer() {
+ delete d;
+}
+
+qint64 BlockingBuffer::read( char* buf, qint64 max ) {
+ assert( max >= 0 );
+ if ( max == 0 )
+ return 0;
+ const QMutexLocker lock( &d->mutex );
+ while ( d->bytesUsed() == 0 && !d->closed )
+ d->canRead.wait( &d->mutex );
+ const int actual = qMin<int>( max, d->bytesUsed() );
+ if ( actual == 0 ) // closed
+ return 0;
+
+ const int untilEnd = qMin( d->size - 1 - d->readPos, actual );
+ memcpy( buf, d->data.constData() + d->readPos, untilEnd );
+ d->readPos = ( d->readPos + untilEnd ) % d->size;
+ const int left = actual - untilEnd;
+ if ( left > 0 ) {
+ memcpy( buf + untilEnd, d->data.constData(), left );
+ d->readPos = left;
+ }
+
+ d->canWrite.wakeAll();
+ return actual;
+}
+
+qint64 BlockingBuffer::write( const char* buf, qint64 max ) {
+ assert( max >= 0 );
+ if ( max == 0 )
+ return 0;
+ const QMutexLocker lock( &d->mutex );
+ while ( d->bytesFree() == 0 && !d->closed )
+ d->canWrite.wait( &d->mutex );
+ if ( d->closed ) // closed, writing fails
+ return -1;
+ const int actual = qMin<int>( max, d->bytesFree() );
+ assert( actual > 0 );
+ const int untilEnd = qMin( d->size - 1 - d->readPos, actual );
+ memcpy( d->data.data() + d->writePos, buf, untilEnd );
+ d->writePos = ( d->writePos + untilEnd ) % d->size;
+ const int left = actual - untilEnd;
+ if ( left > 0 ) {
+ memcpy( d->data.data(), buf + untilEnd, left );
+ d->writePos = left;
+ }
+
+ d->canRead.wakeAll();
+ return actual;
+}
+
+void BlockingBuffer::close() {
+ const QMutexLocker lock( &d->mutex );
+ d->closed = true;
+}
diff --git a/installerbuilder/common/blockingbuffer.h b/installerbuilder/common/blockingbuffer.h
new file mode 100644
index 000000000..2868e3650
--- /dev/null
+++ b/installerbuilder/common/blockingbuffer.h
@@ -0,0 +1,47 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef BLOCKINGBUFFER_H
+#define BLOCKINGBUFFER_H
+
+#include <QtGlobal>
+
+namespace QInstaller {
+ class BlockingBuffer {
+ public:
+ explicit BlockingBuffer( int size );
+ ~BlockingBuffer();
+
+ qint64 read( char* buf, qint64 max);
+ qint64 write( const char* buf, qint64 max );
+ void close();
+
+ private:
+ class Private;
+ Private* const d;
+ };
+}
+
+#endif // BLOCKINGBUFFER_H
diff --git a/installerbuilder/common/consolepasswordprovider.h b/installerbuilder/common/consolepasswordprovider.h
new file mode 100644
index 000000000..faabed7cf
--- /dev/null
+++ b/installerbuilder/common/consolepasswordprovider.h
@@ -0,0 +1,53 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef CONSOLEPASSWORDPROVIDER_H
+#define CONSOLEPASSWORDPROVIDER_H
+
+#include <KDUpdater/kdupdatercrypto.h>
+
+#include <iostream>
+#include <string>
+
+class ConsolePasswordProvider : public KDUpdaterCrypto::PasswordProvider
+{
+public:
+ QByteArray password() const
+ {
+ if( m_password.isNull() )
+ {
+ std::cout << QObject::tr( "Please type the password needed to unlock the private RSA key:" ).toStdString() << std::endl;
+ std::string p;
+ std::cin >> p;
+ m_password = QByteArray( p.c_str() );
+ }
+ return m_password;
+ }
+
+private:
+ mutable QByteArray m_password;
+};
+
+#endif
diff --git a/installerbuilder/common/errors.h b/installerbuilder/common/errors.h
new file mode 100644
index 000000000..e5ccd5f15
--- /dev/null
+++ b/installerbuilder/common/errors.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef ERRORS_H
+#define ERRORS_H
+
+#include <QString>
+#include <QDebug>
+
+#include <stdexcept>
+
+namespace QInstaller {
+ class Error : public std::runtime_error
+ {
+ public:
+ explicit Error(const QString &m) : std::runtime_error( m.toStdString() ), m_message ( m ) {
+ qWarning()<<"Error-Exception:"<<m;
+ }
+ virtual ~Error() throw() {}
+ QString message() const { return m_message; }
+ private:
+ QString m_message;
+ };
+}
+
+#endif // ERRORS_H
diff --git a/installerbuilder/common/fileutils.cpp b/installerbuilder/common/fileutils.cpp
new file mode 100644
index 000000000..04fa9ae94
--- /dev/null
+++ b/installerbuilder/common/fileutils.cpp
@@ -0,0 +1,468 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "fileutils.h"
+#include <common/errors.h>
+#include <common/utils.h>
+
+#include <QDateTime>
+#include <QDir>
+#include <QDirIterator>
+#include <QEventLoop>
+#include <QFileInfo>
+#include <QString>
+#include <QTemporaryFile>
+#include <QThread>
+#include <QUrl>
+
+#include <cassert>
+#include <cerrno>
+
+using namespace QInstaller;
+
+TempDirDeleter::TempDirDeleter( const QString& path )
+ : m_paths( QStringList() << path )
+{
+}
+
+TempDirDeleter::TempDirDeleter( const QStringList& paths_ )
+ : m_paths( paths_ )
+{
+}
+
+TempDirDeleter::~TempDirDeleter()
+{
+ for( QStringList::const_iterator it = m_paths.constBegin(); it != m_paths.constEnd(); ++it )
+ {
+ const QString& path = *it;
+ if( !path.isEmpty() )
+ try {
+ removeDirectory( path );
+ } catch ( const Error& e ) {
+ qCritical() << Q_FUNC_INFO << "Exception caught:" << e.message();
+ } catch ( ... ) {
+ qCritical() << Q_FUNC_INFO << "Unknown exception caught.";
+ }
+ }
+}
+
+void TempDirDeleter::passAndReleaseAll( TempDirDeleter& tdd ) {
+ tdd.m_paths = m_paths;
+ releaseAll();
+}
+
+void TempDirDeleter::passAndRelease( TempDirDeleter& tdd, const QString& path ) {
+ tdd.add( path );
+ release( path );
+}
+
+void TempDirDeleter::releaseAll() {
+ m_paths.clear();
+}
+
+void TempDirDeleter::release( const QString& path ) {
+ m_paths.removeAll( path );
+}
+
+QStringList TempDirDeleter::paths() const {
+ return m_paths;
+}
+
+void TempDirDeleter::add( const QString& path )
+{
+ if( !m_paths.contains( path ) )
+ m_paths.push_back( path );
+}
+
+void TempDirDeleter::add( const QStringList& paths )
+{
+ for( QStringList::const_iterator it = paths.begin(); it != paths.end(); ++it )
+ add( *it );
+}
+
+bool QInstaller::isLocalUrl( const QUrl& url ) {
+ return url.scheme().isEmpty() || url.scheme().toLower() == QLatin1String("file");
+}
+
+QString QInstaller::pathFromUrl( const QUrl& url )
+{
+ if( isLocalUrl( url ) )
+ return url.toLocalFile();
+ const QString str = url.toString();
+ if ( url.scheme() == QLatin1String("resource") )
+ return str.mid( QString::fromLatin1("resource").length() );
+ return str;
+}
+
+
+void QInstaller::openForWrite(QIODevice* dev, const QString& name)
+{
+ assert( dev );
+ if (!dev->open(QIODevice::WriteOnly))
+ throw Error(QObject::tr("Cannot open file %1 for writing: %2").arg( name, dev->errorString() ) );
+}
+
+void QInstaller::openForRead(QIODevice* dev, const QString& name)
+{
+ assert( dev );
+ if (!dev->open(QIODevice::ReadOnly))
+ throw Error(QObject::tr( "Cannot open file %1 for reading: %2" ).arg( name, dev->errorString() ) );
+}
+
+qint64 QInstaller::blockingWrite(QIODevice *out, const char *buffer, qint64 size)
+{
+ qint64 left = size;
+ while (left > 0) {
+ const qint64 n = out->write(buffer, left);
+ if (n < 0)
+ throw Error( QObject::tr("Write failed after %1 bytes: %2").arg( QString::number(size-left), out->errorString() ) );
+ left -= n;
+ }
+ return size;
+}
+
+qint64 QInstaller::blockingWrite(QIODevice *out, const QByteArray& ba)
+{
+ return blockingWrite( out, ba.constData(), ba.size() );
+}
+
+qint64 QInstaller::blockingRead(QIODevice *in, char *buffer, qint64 size)
+{
+ if ( in->atEnd() )
+ return 0;
+ qint64 left = size;
+ while (left > 0) {
+ const qint64 n = in->read(buffer, left);
+ if ( n < 0 )
+ throw Error( QObject::tr("Read failed after %1 bytes: %2").arg( QString::number(size-left), in->errorString() ) );
+
+ left -= n;
+ buffer += n;
+ }
+ return size;
+}
+
+void QInstaller::blockingCopy( QIODevice* in, QIODevice* out, qint64 size )
+{
+ static const qint64 blockSize = 4096;
+ QByteArray ba( blockSize, '\0' );
+ qint64 actual = qMin( blockSize, size );
+ while( actual > 0 )
+ {
+ blockingRead( in, ba.data(), actual );
+ blockingWrite( out, ba.constData(), actual );
+ size -= actual;
+ actual = qMin( blockSize, size );
+ }
+}
+
+void QInstaller::removeDirectory( const QString& path, bool ignoreErrors )
+{
+ if ( path.isEmpty() ) // QDir( "" ) points to the working directory! We never want to remove that one.
+ return;
+
+ QDirIterator it( path, QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden );
+ while( it.hasNext() )
+ {
+ it.next();
+ const QFileInfo fi = it.fileInfo();
+
+ if( fi.isDir() && !fi.isSymLink() )
+ {
+ removeDirectory( fi.filePath(), ignoreErrors );
+ }
+ else
+ {
+ QFile f( fi.filePath() );
+ if( !f.remove() && !ignoreErrors )
+ throw Error( QObject::tr("Could not remove file %1: %2").arg( f.fileName(), f.errorString() ) );
+ }
+ }
+
+ errno = 0;
+ if ( !QDir().rmdir( path ) && !ignoreErrors )
+ throw Error( QObject::tr("Could not remove folder %1: %2").arg( path, QLatin1String(strerror(errno)) ) );
+}
+
+/*!
+ \internal
+ */
+class RemoveDirectoryThread : public QThread
+{
+public:
+ explicit RemoveDirectoryThread( const QString& path, bool ignoreErrors = false, QObject* parent = 0 )
+ : QThread( parent ),
+ p( path ),
+ ignore( ignoreErrors )
+ {
+ }
+
+ const QString& error() const
+ {
+ return err;
+ }
+
+protected:
+ /*!
+ \reimp
+ */
+ void run()
+ {
+ try
+ {
+ removeDirectory( p, ignore );
+ }
+ catch( const Error& e )
+ {
+ err = e.message();
+ }
+ }
+
+private:
+ QString err;
+ const QString p;
+ const bool ignore;
+};
+
+void QInstaller::removeDirectoryThreaded( const QString& path, bool ignoreErrors )
+{
+ RemoveDirectoryThread thread( path, ignoreErrors );
+ QEventLoop loop;
+ QObject::connect( &thread, SIGNAL( finished() ), &loop, SLOT( quit() ) );
+ thread.start();
+ loop.exec();
+ if( !thread.error().isEmpty() )
+ throw Error( thread.error() );
+}
+
+void QInstaller::copyDirectoryContents( const QString& sourceDir, const QString& targetDir ) {
+ verbose() << "Copying " << sourceDir << " to " << targetDir << std::endl;
+ Q_ASSERT( QFileInfo( sourceDir ).isDir() );
+ Q_ASSERT( !QFileInfo( targetDir ).exists() || QFileInfo( targetDir ).isDir() );
+ if ( !QDir().mkpath( targetDir ) )
+ throw Error( QObject::tr("Could not create folder %1").arg( targetDir ) );
+
+ QDirIterator it( sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries );
+ while( it.hasNext() )
+ {
+ const QFileInfo i( it.next() );
+ if( i.isDir() )
+ {
+ copyDirectoryContents( QDir( sourceDir ).absoluteFilePath( i.fileName() ), QDir( targetDir ).absoluteFilePath( i.fileName() ) );
+ }
+ else
+ {
+ QFile f( i.filePath() );
+ const QString target = QDir( targetDir ).absoluteFilePath( i.fileName() );
+ if( !f.copy( target ) )
+ throw Error( QObject::tr("Could not copy file from %1 to %2: %3").arg( f.fileName(), target, f.errorString() ) );
+ }
+ }
+}
+
+void QInstaller::moveDirectoryContents( const QString& sourceDir, const QString& targetDir ) {
+ verbose() << "Moving " << sourceDir << " to " << targetDir << std::endl;
+ Q_ASSERT( QFileInfo( sourceDir ).isDir() );
+ Q_ASSERT( !QFileInfo( targetDir ).exists() || QFileInfo( targetDir ).isDir() );
+ if ( !QDir().mkpath( targetDir ) )
+ throw Error( QObject::tr("Could not create folder %1").arg( targetDir ) );
+
+ QDirIterator it( sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries );
+ while( it.hasNext() )
+ {
+ const QFileInfo i( it.next() );
+ if( i.isDir() )
+ {
+ moveDirectoryContents( QDir( sourceDir ).absoluteFilePath( i.fileName() ), QDir( targetDir ).absoluteFilePath( i.fileName() ) );
+ }
+ else
+ {
+ QFile f( i.filePath() );
+ const QString target = QDir( targetDir ).absoluteFilePath( i.fileName() );
+ if( !f.rename( target ) )
+ throw Error( QObject::tr("Could not move file from %1 to %2: %3").arg( f.fileName(), target, f.errorString() ) );
+ }
+ }
+}
+
+void QInstaller::mkdir( const QString& path ) {
+ errno = 0;
+ if ( !QDir().mkdir( QFileInfo( path ).absoluteFilePath() ) )
+ throw Error( QObject::tr("Could not create folder %1: %2" ).arg( path, QString::fromLocal8Bit( strerror( errno ) ) ) );
+}
+
+void QInstaller::mkpath( const QString& path ) {
+ errno = 0;
+ if ( !QDir().mkpath( QFileInfo( path ).absoluteFilePath() ) )
+ throw Error( QObject::tr("Could not create folder %1: %2" ).arg( path, QString::fromLocal8Bit( strerror( errno ) ) ) );
+}
+
+QString QInstaller::generateTemporaryFileName( const QString& templ )
+{
+ if ( templ.isEmpty() )
+ {
+ QTemporaryFile f;
+ if ( !f.open() )
+ throw Error( QObject::tr("Could not open temporary file: %1").arg( f.errorString() ) );
+ return f.fileName();
+ }
+ else
+ {
+ static const QString characters = QLatin1String( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" );
+/* const QFileInfo fi( path );
+ const QString dir = fi.absolutePath();
+ const QString file = fi.fileName();*/
+ QString suffix;
+ qsrand( qrand() * QDateTime::currentDateTime().toTime_t() );
+ for( int i = 0; i < 5; ++i )
+ suffix += characters[ qrand() % characters.length() ];
+ const QString tmp = QLatin1String( "%1.tmp.%2.%3" );
+ int count = 1;
+ while ( QFile::exists( tmp.arg( templ, suffix ).arg( count ) ) )
+ ++count;
+ QFile f( tmp.arg( templ, suffix ).arg( count ) );
+ if( !f.open( QIODevice::WriteOnly ) )
+ throw Error( QObject::tr("Could not open temporary file for template %1: %2").arg( templ, f.errorString() ) );
+ f.remove();
+ return f.fileName();
+ }
+}
+
+QString QInstaller::createTemporaryDirectory( const QString& templ ) {
+ const QString t = QDir::tempPath() + QLatin1String("/") + templ + QLatin1String("XXXXXX");
+ QTemporaryFile f( t );
+ if ( !f.open() )
+ throw Error( QObject::tr("Could not create temporary folder for template %1: %2").arg( t, f.errorString() ) );
+ const QString path = f.fileName() + QString::fromLatin1( "meta" );
+ verbose() << "Creating meta data directory at " << path << std::endl;
+
+ QInstaller::mkpath( path );
+ return path;
+}
+
+#ifdef Q_WS_WIN
+#include <windows.h>
+
+#pragma pack( push )
+#pragma pack(2)
+
+typedef struct
+{
+BYTE bWidth; // Width, in pixels, of the image
+BYTE bHeight; // Height, in pixels, of the image
+BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
+BYTE bReserved; // Reserved
+WORD wPlanes; // Color Planes
+WORD wBitCount; // Bits per pixel
+DWORD dwBytesInRes; // how many bytes in this resource?
+DWORD dwImageOffset; // the ID
+} ICONDIRENTRY;
+
+typedef struct
+{
+WORD idReserved; // Reserved (must be 0)
+WORD idType; // Resource type (1 for icons)
+WORD idCount; // How many images?
+ICONDIRENTRY idEntries[1]; // The entries for each image
+} ICONDIR;
+
+typedef struct
+{
+BYTE bWidth; // Width, in pixels, of the image
+BYTE bHeight; // Height, in pixels, of the image
+BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
+BYTE bReserved; // Reserved
+WORD wPlanes; // Color Planes
+WORD wBitCount; // Bits per pixel
+DWORD dwBytesInRes; // how many bytes in this resource?
+WORD nID; // the ID
+} GRPICONDIRENTRY, *LPGRPICONDIRENTRY;
+
+typedef struct
+{
+WORD idReserved; // Reserved (must be 0)
+WORD idType; // Resource type (1 for icons)
+WORD idCount; // How many images?
+GRPICONDIRENTRY idEntries[1]; // The entries for each image
+} GRPICONDIR, *LPGRPICONDIR;
+
+
+#pragma pack( pop )
+
+void QInstaller::setApplicationIcon( const QString& application, const QString& icon )
+{
+ wchar_t* const path = new wchar_t[ application.length() + 1 ];
+ QDir::toNativeSeparators( application ).toWCharArray( path );
+ path[ application.length() ] = 0;
+
+ HANDLE updateRes = BeginUpdateResource( path, false );
+ delete[] path;
+
+ QFile iconFile( icon );
+ if( !iconFile.open( QIODevice::ReadOnly ) )
+ return;
+
+ QByteArray temp = iconFile.readAll();
+
+ ICONDIR* ig = reinterpret_cast< ICONDIR* >( temp.data() );
+
+ DWORD newSize = sizeof( GRPICONDIR ) + sizeof( GRPICONDIRENTRY ) * ( ig->idCount - 1 );
+ GRPICONDIR* newDir = reinterpret_cast< GRPICONDIR* >( new char[ newSize ] );
+ newDir->idReserved = ig->idReserved;
+ newDir->idType = ig->idType;
+ newDir->idCount = ig->idCount;
+
+ for( int i = 0; i < ig->idCount; ++i )
+ {
+ char* temp1 = temp.data() + ig->idEntries[ i ].dwImageOffset;
+ DWORD size1 = ig->idEntries[ i ].dwBytesInRes;
+
+ newDir->idEntries[ i ].bWidth = ig->idEntries[ i ].bWidth;
+ newDir->idEntries[ i ].bHeight = ig->idEntries[ i ].bHeight;
+ newDir->idEntries[ i ].bColorCount = ig->idEntries[ i ].bColorCount;
+ newDir->idEntries[ i ].bReserved = ig->idEntries[ i ].bReserved;
+ newDir->idEntries[ i ].wPlanes = ig->idEntries[ i ].wPlanes;
+ newDir->idEntries[ i ].wBitCount = ig->idEntries[ i ].wBitCount;
+ newDir->idEntries[ i ].dwBytesInRes = ig->idEntries[ i ].dwBytesInRes;
+ newDir->idEntries[ i ].nID = i + 1;
+
+ UpdateResource( updateRes, RT_ICON, MAKEINTRESOURCE( i + 1 ),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), temp1, size1 );
+ }
+
+ UpdateResource( updateRes, RT_GROUP_ICON, L"IDI_ICON1", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newDir, newSize );
+
+ delete[] newDir;
+
+ EndUpdateResource( updateRes, false );
+}
+#endif
diff --git a/installerbuilder/common/fileutils.h b/installerbuilder/common/fileutils.h
new file mode 100644
index 000000000..efed7930e
--- /dev/null
+++ b/installerbuilder/common/fileutils.h
@@ -0,0 +1,103 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_FILEUTILS_H
+#define QINSTALLER_FILEUTILS_H
+
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+
+#include "installer_global.h"
+
+class QByteArray;
+class QIODevice;
+class QUrl;
+
+namespace QInstaller {
+ void INSTALLER_EXPORT openForWrite(QIODevice* dev, const QString& name);
+ void INSTALLER_EXPORT openForRead(QIODevice* dev, const QString& name);
+
+ qint64 INSTALLER_EXPORT blockingRead( QIODevice* in, char *buffer, qint64 size );
+ qint64 INSTALLER_EXPORT blockingWrite( QIODevice* out, const char* buffer, qint64 size);
+ qint64 INSTALLER_EXPORT blockingWrite( QIODevice* out, const QByteArray& ba );
+ void INSTALLER_EXPORT blockingCopy( QIODevice* in, QIODevice* out, qint64 size );
+
+ /**
+ * Removes the directory at \a path recursively.
+ * @param path The directory to remove
+ * @param ignoreErrors if @p true, errors will be silently ignored. Otherwise an exception will be thrown if removing fails.
+ *
+ * @throws QInstaller::Error if the directory cannot be removed and ignoreErrors is @p false
+ */
+ void INSTALLER_EXPORT removeDirectory( const QString& path, bool ignoreErrors = false );
+ void INSTALLER_EXPORT removeDirectoryThreaded( const QString& path, bool ignoreErrors = false );
+
+ /**
+ * Creates a temporary directory
+ * @throws QInstaller::Error if creating the temporary directory fails
+ */
+ QString INSTALLER_EXPORT createTemporaryDirectory( const QString& templ=QString() );
+
+ QString INSTALLER_EXPORT generateTemporaryFileName( const QString& templ=QString() );
+
+ void INSTALLER_EXPORT moveDirectoryContents( const QString& sourceDir, const QString& targetDir );
+ void INSTALLER_EXPORT copyDirectoryContents( const QString& sourceDir, const QString& targetDir );
+
+ bool INSTALLER_EXPORT isLocalUrl( const QUrl& url );
+ QString INSTALLER_EXPORT pathFromUrl( const QUrl& url );
+
+ void INSTALLER_EXPORT mkdir( const QString& path );
+ void INSTALLER_EXPORT mkpath( const QString& path );
+
+#ifdef Q_WS_WIN
+ /**
+ * Sets the .ico file at \a icon as application icon for \a application.
+ */
+ void INSTALLER_EXPORT setApplicationIcon( const QString& application, const QString& icon );
+
+#endif
+
+ class INSTALLER_EXPORT TempDirDeleter
+ {
+ public:
+ explicit TempDirDeleter( const QString& path );
+ explicit TempDirDeleter( const QStringList& paths = QStringList() );
+ ~TempDirDeleter();
+ void releaseAll();
+ void release( const QString& path );
+ void passAndReleaseAll( TempDirDeleter& tdd );
+ void passAndRelease( TempDirDeleter& tdd, const QString& path );
+
+ void add( const QString& path );
+ void add( const QStringList& paths );
+ QStringList paths() const;
+
+ private:
+ Q_DISABLE_COPY(TempDirDeleter)
+ QStringList m_paths;
+ };
+}
+
+#endif // QINSTALLER_FILEUTILS_H
diff --git a/installerbuilder/common/installersettings.cpp b/installerbuilder/common/installersettings.cpp
new file mode 100644
index 000000000..c1bfab728
--- /dev/null
+++ b/installerbuilder/common/installersettings.cpp
@@ -0,0 +1,314 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "installersettings.h"
+
+#include "common/errors.h"
+#include "common/repository.h"
+
+#include <QDomDocument>
+
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+#include <QSharedData>
+#include <QStringList>
+
+using namespace QInstaller;
+
+/*
+TRANSLATOR QInstaller::InstallerSettings
+*/
+
+class InstallerSettings::Private : public QSharedData {
+public:
+ QString prefix;
+ QString logo;
+ QString logoSmall;
+ QString title;
+ QString maintenanceTitle;
+ QString name;
+ QString version;
+ QString publisher;
+ QString url;
+ QString watermark;
+ QString background;
+ QString runProgram;
+ QString runProgramDescription;
+ QString startMenuDir;
+ QString targetDir;
+ QString adminTargetDir;
+ QString icon;
+ QString uninstallerName;
+ QString uninstallerIniFile;
+ QList<Repository> repositories;
+ QStringList certificateFiles;
+ QByteArray privateKey;
+ QByteArray publicKey;
+
+ QString makeAbsolutePath( const QString& p ) const {
+ if ( QFileInfo( p ).isAbsolute() )
+ return p;
+ return prefix + QLatin1String("/") + p;
+ }
+};
+
+
+static QString readChild( const QDomElement& el, const QString& child, const QString& defValue=QString() ) {
+ const QDomNodeList list = el.elementsByTagName( child );
+ if ( list.size() > 1 )
+ throw Error( QObject::tr("Multiple %1 elements found, but only one allowed.").arg( child ) );
+ return list.isEmpty() ? defValue : list.at( 0 ).toElement().text();
+}
+
+#if 0
+static QStringList readChildList( const QDomElement& el, const QString& child ) {
+ const QDomNodeList list = el.elementsByTagName( child );
+ QStringList res;
+ for ( int i = 0; i < list.size(); ++i )
+ res += list.at( i ).toElement().text();
+ return res;
+}
+#endif
+
+InstallerSettings::InstallerSettings( const InstallerSettings& other ) : d( other.d ) {}
+
+InstallerSettings& InstallerSettings::operator=( const InstallerSettings& other ) {
+ InstallerSettings copy( other );
+ std::swap( d, copy.d );
+ return *this;
+}
+
+static QString splitTrimmed( const QString& string )
+{
+ if( string.isEmpty() )
+ return QString();
+
+ QStringList result;
+ const QStringList input = string.split( QRegExp( QLatin1String( "\n|\r\n" ) ) );
+ for( QStringList::const_iterator it = input.begin(); it != input.end(); ++it )
+ {
+ const QString line = it->trimmed();
+ result.push_back( line );
+ }
+ result.push_back( QString() );
+ return result.join( QLatin1String( "\n" ) );
+}
+
+InstallerSettings InstallerSettings::fromFileAndPrefix( const QString& path, const QString& prefix ) {
+ QDomDocument doc;
+ QFile file( path );
+ QFile overrideConfig( QLatin1String( ":/overrideconfig.xml" ) );
+ if ( overrideConfig.exists() )
+ file.setFileName( overrideConfig.fileName() );
+ if ( !file.open( QIODevice::ReadOnly ) )
+ throw Error( tr("Could not open settings file %1 for reading: %2").arg( path, file.errorString() ) );
+ QString msg;
+ int line = 0;
+ int col = 0;
+ if ( !doc.setContent( &file, &msg, &line, &col ) )
+ throw Error( tr("Could not parse settings file %1: %2:%3: %4").arg( path,
+ QString::number( line ),
+ QString::number( col ),
+ msg ) );
+ const QDomElement root = doc.documentElement();
+ if ( root.tagName() != QLatin1String( "Installer" ) )
+ throw Error( tr("%1 is not valid: Installer root node expected") );
+
+ InstallerSettings s;
+ s.d->prefix = prefix;
+ s.d->logo = readChild( root, QLatin1String("Logo") );
+ s.d->logoSmall = readChild( root, QLatin1String("LogoSmall") );
+ s.d->title = readChild( root, QLatin1String("Title") );
+ s.d->maintenanceTitle = readChild( root, QLatin1String("MaintenanceTitle") );
+ s.d->name = readChild( root, QLatin1String("Name") );
+ s.d->version = readChild( root, QLatin1String("Version") );
+ s.d->publisher = readChild( root, QLatin1String("Publisher") );
+ s.d->url = readChild( root, QLatin1String("ProductUrl") );
+ s.d->watermark = readChild( root, QLatin1String("Watermark") );
+ s.d->background = readChild( root, QLatin1String("Background") );
+ s.d->runProgram = readChild( root, QLatin1String("RunProgram") );
+ s.d->runProgramDescription = readChild( root, QLatin1String("RunProgramDescription") );
+ s.d->startMenuDir = readChild( root, QLatin1String("StartMenuDir") );
+ s.d->targetDir = readChild( root, QLatin1String("TargetDir") );
+ s.d->adminTargetDir = readChild( root, QLatin1String("AdminTargetDir") );
+ s.d->icon = readChild( root, QLatin1String( "Icon" ) );
+ s.d->uninstallerName = readChild( root, QLatin1String( "UninstallerName" ), QLatin1String("uninstall") );
+ s.d->uninstallerIniFile = readChild( root, QLatin1String("UninstallerIniFile"), s.d->uninstallerName + QLatin1String(".ini") );
+ s.d->privateKey = splitTrimmed( readChild( root, QLatin1String( "PrivateKey" ) ) ).toLatin1();
+ s.d->publicKey = splitTrimmed( readChild( root, QLatin1String( "PublicKey" ) ) ).toLatin1();
+
+ const QDomNodeList reposTags = root.elementsByTagName( QLatin1String("RemoteRepositories") );
+ if ( reposTags.size() > 1 )
+ throw Error( tr("Multiple RemoteRepositories elements found, but only one allowed.") );
+ if ( !reposTags.isEmpty() ) {
+ const QDomNodeList repos = reposTags.at( 0 ).toElement().elementsByTagName( QLatin1String("Repository") );
+ for ( int i = 0; i < repos.size(); ++i ) {
+ Repository r;
+ const QDomNodeList children = repos.at( i ).childNodes();
+ for ( int j = 0; j < children.size(); ++j ) {
+ if ( children.at( j ).toElement().tagName() == QLatin1String( "Url" ) )
+ r.setUrl( children.at( j ).toElement().text() );
+ if ( children.at( j ).toElement().tagName() == QLatin1String( "Required" ) )
+ r.setRequired( children.at( j ).toElement().text() == QLatin1String("true") );
+ }
+ s.d->repositories.append( r );
+ }
+ }
+
+ const QDomNodeList certs = root.elementsByTagName( QLatin1String("SigningCertificate") );
+ for ( int i=0; i < certs.size(); ++i ) {
+ const QString str = certs.at( i ).toElement().text();
+ if ( str.isEmpty() )
+ continue;
+ s.d->certificateFiles.push_back( s.d->makeAbsolutePath( str ) );
+ }
+ return s;
+}
+
+InstallerSettings::InstallerSettings() : d( new Private ) {
+}
+
+QString InstallerSettings::maintenanceTitle() const
+{
+ return d->maintenanceTitle;
+}
+
+InstallerSettings::~InstallerSettings() {
+}
+
+QString InstallerSettings::logo() const {
+ return d->makeAbsolutePath( d->logo );
+}
+
+QString InstallerSettings::logoSmall() const {
+ return d->makeAbsolutePath( d->logoSmall );
+}
+
+QString InstallerSettings::title() const {
+ return d->title;
+}
+
+QString InstallerSettings::applicationName() const {
+ return d->name;
+}
+
+QString InstallerSettings::applicationVersion() const {
+ return d->version;
+}
+
+QString InstallerSettings::publisher() const {
+ return d->publisher;
+}
+
+QString InstallerSettings::url() const {
+ return d->url;
+}
+
+QString InstallerSettings::watermark() const {
+ return d->makeAbsolutePath( d->watermark );
+}
+
+QString InstallerSettings::background() const
+{
+ return d->makeAbsolutePath( d->background );
+}
+
+QString InstallerSettings::icon() const
+{
+#if defined( Q_WS_MAC )
+ return d->makeAbsolutePath( d->icon ) + QLatin1String( ".icns" );
+#elif defined( Q_WS_WIN )
+ return d->makeAbsolutePath( d->icon ) + QLatin1String( ".ico" );
+#else
+ return d->makeAbsolutePath( d->icon ) + QLatin1String( ".png" );
+#endif
+}
+
+QString InstallerSettings::uninstallerName() const
+{
+ if( d->uninstallerName.isEmpty() )
+ return QLatin1String( "uninstall" );
+ return d->uninstallerName;
+}
+
+QString InstallerSettings::uninstallerIniFile() const
+{
+ return d->uninstallerIniFile;
+}
+
+QString InstallerSettings::runProgram() const {
+ return d->runProgram;
+}
+
+QString InstallerSettings::runProgramDescription() const
+{
+ return d->runProgramDescription;
+}
+
+QString InstallerSettings::startMenuDir() const {
+ return d->startMenuDir;
+}
+
+QString InstallerSettings::targetDir() const {
+ return d->targetDir;
+}
+
+QString InstallerSettings::adminTargetDir() const {
+ return d->adminTargetDir;
+}
+
+QList<Repository> InstallerSettings::repositories() const {
+ return d->repositories;
+}
+
+QStringList InstallerSettings::certificateFiles() const {
+ return d->certificateFiles;
+}
+
+QByteArray InstallerSettings::privateKey() const
+{
+ return d->privateKey;
+}
+
+QByteArray InstallerSettings::publicKey() const
+{
+ return d->publicKey;
+}
+
+void InstallerSettings::setTemporaryRepositories(const QList<Repository> &repos, bool replace)
+{
+ if (replace)
+ d->repositories = repos;
+ else
+ d->repositories.append(repos);
+}
diff --git a/installerbuilder/common/installersettings.h b/installerbuilder/common/installersettings.h
new file mode 100644
index 000000000..342d8fcd4
--- /dev/null
+++ b/installerbuilder/common/installersettings.h
@@ -0,0 +1,90 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef INSTALLERSETTINGS_H
+#define INSTALLERSETTINGS_H
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QSharedDataPointer>
+
+#include "installer_global.h"
+
+namespace QInstaller {
+
+ class Repository;
+
+ class INSTALLER_EXPORT InstallerSettings {
+ Q_DECLARE_TR_FUNCTIONS(InstallerSettings)
+ public:
+ /**
+ * @throws QInstallerError
+ */
+ static InstallerSettings fromFileAndPrefix( const QString& path, const QString& prefix );
+
+ explicit InstallerSettings();
+ InstallerSettings( const InstallerSettings& other );
+ ~InstallerSettings();
+
+ InstallerSettings& operator=( const InstallerSettings& other );
+
+ bool isValid() const;
+
+ QString logo() const;
+ QString logoSmall() const;
+ QString title() const;
+ QString maintenanceTitle() const;
+ QString publisher() const;
+ QString url() const;
+ QString watermark() const;
+ QString background() const;
+ QString icon() const;
+
+ QString applicationName() const;
+ QString applicationVersion() const;
+
+ QString runProgram() const;
+ QString runProgramDescription() const;
+ QString startMenuDir() const;
+ QString targetDir() const;
+ QString adminTargetDir() const;
+
+ QString uninstallerName() const;
+ QString uninstallerIniFile() const;
+
+ QByteArray privateKey() const;
+ QByteArray publicKey() const;
+
+ QList<Repository> repositories() const;
+ void setTemporaryRepositories(const QList<Repository> &repos, bool replace);
+
+ QStringList certificateFiles() const;
+
+ private:
+ class Private;
+ QSharedDataPointer<Private> d;
+ };
+}
+
+#endif // INSTALLERSETTINGS_H
diff --git a/installerbuilder/common/kd7zengine.cpp b/installerbuilder/common/kd7zengine.cpp
new file mode 100644
index 000000000..71298b326
--- /dev/null
+++ b/installerbuilder/common/kd7zengine.cpp
@@ -0,0 +1,679 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "kd7zengine.h"
+
+#include <QBuffer>
+#include <QDateTime>
+#include <QDebug>
+#include <QDir>
+#include <QMap>
+#include <QSet>
+#include <QTextCodec>
+
+#include "lib7z_facade.h"
+
+static QMap< QString, QFile* > archives;
+static QMap< QString, QVector< Lib7z::File > > currentContents;
+static QMap< QString, QHash< QString, const Lib7z::File* > > currentFiles;
+
+namespace
+{
+
+static bool matches( const QList< QRegExp >& regexps, QDir::Filters filters, const Lib7z::File& n )
+{
+ const QString fileName = n.path.section( QChar::fromLatin1( '/' ), -1, -1, QString::SectionSkipEmpty );
+
+ static QLatin1Char sep( '/' );
+
+ // check for directories filter
+ if( ( filters & QDir::Dirs ) == 0 && n.isDirectory )
+ return false;
+
+ // check for files filter
+ if( ( filters & QDir::Files ) == 0 && !n.isDirectory )
+ return false;
+
+ // check for name filter
+ if( !regexps.isEmpty() )
+ {
+ bool matched = false;
+ for( QList< QRegExp >::const_iterator it = regexps.begin(); it != regexps.end(); ++it )
+ {
+ matched = it->exactMatch( fileName );
+ if ( matched )
+ break;
+ }
+ return matched;
+ }
+ return true;
+}
+}
+
+class KD7zEngine::Private
+{
+public:
+ Private( KD7zEngine* q )
+ : q( q ),
+ flags( 0 ),
+ mode( QIODevice::NotOpen )
+ {
+ }
+
+private:
+ KD7zEngine* const q;
+
+public:
+ void setFileName( const QString& file )
+ {
+ const QString oldZipFileName = zipFileName;
+ providedFileName = file;
+
+ static const QLatin1Char sep( '/' );
+
+ static const QString prefix = QString::fromLatin1( "7z://" );
+ Q_ASSERT( file.toLower().startsWith( prefix ) );
+ zipFileName = file.mid( prefix.length() );
+ zipFileName.replace( QLatin1Char( '\\' ), sep );
+
+ QDir dir( zipFileName );
+ int i = -1;
+ while( !dir.exists() )
+ dir = QDir( zipFileName.section( sep, 0, i-- ) );
+
+ zipFileName = zipFileName.section( sep, 0, i + 2 );
+ fileName = file.mid( prefix.length() + zipFileName.length() );
+
+ while( fileName.endsWith( sep ) )
+ fileName.chop( 1 );
+ while( fileName.startsWith( sep ) )
+ fileName.remove( 0, 1 );
+
+ flags = 0;
+ q->close();
+ currentFile = Lib7z::File();
+ }
+
+ /**
+ * Taken from qfsfileengine.cpp
+ */
+ static QString canonicalized(const QString &path)
+ {
+ if (path.isEmpty())
+ return path;
+
+ QFileInfo fi;
+ const QChar slash(QLatin1Char('/'));
+ QString tmpPath = path;
+ int separatorPos = 0;
+ QSet<QString> nonSymlinks;
+ QSet<QString> known;
+
+ known.insert(path);
+ do {
+#ifdef Q_OS_WIN
+ // UNC, skip past the first two elements
+ if (separatorPos == 0 && tmpPath.startsWith(QLatin1String("//")))
+ separatorPos = tmpPath.indexOf(slash, 2);
+ if (separatorPos != -1)
+#endif
+ separatorPos = tmpPath.indexOf(slash, separatorPos + 1);
+ QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos);
+ if (!nonSymlinks.contains(prefix)) {
+ fi.setFile(prefix);
+ if (fi.isSymLink()) {
+ QString target = fi.symLinkTarget();
+ if (separatorPos != -1) {
+ if (fi.isDir() && !target.endsWith(slash))
+ target.append(slash);
+ target.append(tmpPath.mid(separatorPos));
+ }
+ tmpPath = QDir::cleanPath(target);
+ separatorPos = 0;
+
+ if (known.contains(tmpPath))
+ return QString();
+ known.insert(tmpPath);
+ } else {
+ nonSymlinks.insert(prefix);
+ }
+ }
+ } while (separatorPos != -1);
+
+ return QDir::cleanPath(tmpPath);
+ }
+
+ QFile* archive() const
+ {
+ if( archives[ zipFileName ] == 0 )
+ archives[ zipFileName ] = new QFile( zipFileName );
+ return archives[ zipFileName ];
+ }
+
+ const Lib7z::File& file() const
+ {
+ if( currentFile.path.isEmpty() )
+ currentFile = file( fileName );
+ return currentFile;
+ }
+
+ const QVector< Lib7z::File >& list() const
+ {
+ if( currentContents[ zipFileName ].isEmpty() )
+ {
+ QFile* const archive = this->archive();
+ try {
+ if( !archive->open( QIODevice::ReadOnly ) ) {
+ qWarning("Could not open %s for reading", qPrintable(zipFileName) );
+ return currentContents[ zipFileName ];
+ }
+ currentContents[ zipFileName ] = Lib7z::listArchive( archive );
+ } catch ( const Lib7z::SevenZipException& e ) {
+ qWarning() << e.message();
+ }
+ archive->close();
+ }
+ return currentContents[ zipFileName ];
+ }
+
+ Lib7z::File file( const QString& path ) const
+ {
+ QString p = QDir::cleanPath( path ).toLower();
+ const QLatin1Char sep( '/' );
+ while( p.endsWith( sep ) )
+ p.chop( 1 );
+ while( p.startsWith( sep ) )
+ p.remove( 0, 1 );
+
+ const Lib7z::File* const f = currentFiles[ zipFileName ][ p ];
+ if( f != 0 )
+ return *f;
+
+ const QVector<Lib7z::File>& files = list();
+ for( QVector< Lib7z::File >::const_iterator it = files.begin(); it != files.end(); ++it )
+ {
+ QString n = it->path.toLower();
+ while( n.endsWith( sep ) )
+ n.chop( 1 );
+
+ currentFiles[ zipFileName ][ n ] = &(*it);
+
+ if( p == n )
+ return *it;
+ }
+
+ return Lib7z::File();
+ }
+
+ QString providedFileName;
+ QString zipFileName;
+ QString fileName;
+
+ mutable FileFlags flags;
+
+ Lib7z::File openFile;
+ QIODevice::OpenMode mode;
+ QBuffer buffer;
+
+ mutable Lib7z::File currentFile;
+};
+
+class KD7zEngineIterator : public QAbstractFileEngineIterator
+{
+public:
+ KD7zEngineIterator( const QStringList& entries, QDir::Filters filters, const QStringList& nameFilters )
+ : QAbstractFileEngineIterator( filters, nameFilters ),
+ list( entries ),
+ index( -1 )
+ {
+ }
+
+ ~KD7zEngineIterator()
+ {
+ }
+
+ /**
+ * \reimp
+ */
+ bool hasNext() const
+ {
+ return index < list.size() - 1;
+ }
+
+ /**
+ * \reimp
+ */
+ QString next()
+ {
+ if( !hasNext() )
+ return QString();
+ ++index;
+ return currentFilePath();
+ }
+
+ /**
+ * \reimp
+ */
+ QString currentFileName() const
+ {
+ return index < 0 ? QString() : list[ index ];
+ }
+
+private:
+ const QStringList list;
+ int index;
+};
+
+KD7zEngine::KD7zEngine( const QString& fileName )
+ : d( new Private( this ) )
+{
+ d->setFileName( fileName );
+}
+
+KD7zEngine::~KD7zEngine()
+{
+ //delete d;
+}
+
+/**
+ * \reimp
+ */
+QStringList KD7zEngine::entryList( QDir::Filters filters, const QStringList& filterNames ) const
+{
+ QStringList result;
+
+ const QVector<Lib7z::File>& files = d->list();
+
+ static QLatin1Char sep( '/' );
+
+ QString p = QDir::cleanPath( d->fileName ).toLower();
+ if( !p.endsWith( sep ) )
+ p += sep;
+ while( p.startsWith( sep ) )
+ p.remove( 0, 1 );
+
+ const int slashes = p.count( sep );
+
+ QList< QRegExp > regexps;
+ for( QStringList::const_iterator it = filterNames.begin(); it != filterNames.end(); ++it )
+ regexps.push_back( QRegExp( *it, Qt::CaseInsensitive, QRegExp::Wildcard ) );
+
+ for( QVector< Lib7z::File >::const_iterator it = files.begin(); it != files.end(); ++it )
+ {
+ const QString n = it->path;
+ if( !n.toLower().startsWith( p ) || n == p || ( n.count( sep ) != slashes ) )
+ continue;
+
+ if( slashes != n.left( n.length() - 1 ).count( sep ) )
+ continue;
+
+ if( matches( regexps, filters, *it ) )
+ result.push_back( n.section( sep, -1, -1, QString::SectionSkipEmpty ) );
+ }
+
+ return result;
+}
+
+/**
+ * \reimp
+ */
+QAbstractFileEngine::Iterator* KD7zEngine::beginEntryList( QDir::Filters filters, const QStringList& filterNames )
+{
+ return new KD7zEngineIterator( entryList( filters, filterNames ), filters, filterNames );
+}
+
+/**
+ * \reimp
+ */
+bool KD7zEngine::caseSensitive() const
+{
+ return false;
+}
+
+/**
+ * \reimp
+ */
+void KD7zEngine::setFileName( const QString& file )
+{
+ d->setFileName( file );
+}
+
+/**
+ * \reimp
+ */
+QString KD7zEngine::fileName( FileName file ) const
+{
+ static const QLatin1Char sep( '/' );
+ switch( file )
+ {
+ case DefaultName:
+ return d->providedFileName;
+ case BaseName:
+ return QString::fromLatin1( "7z://%1%2" ).arg( d->zipFileName ).arg( d->fileName ).section( QChar::fromLatin1( '/' ), -1 );
+ case PathName:
+ return QString::fromLatin1( "7z://%1%2" ).arg( d->zipFileName ).arg( d->fileName ).section( QChar::fromLatin1( '/' ), 0, -2 );
+ case AbsoluteName:
+ {
+ if( d->zipFileName.startsWith( sep ) )
+ return QDir::cleanPath( d->providedFileName );
+ return QDir::cleanPath( QString::fromLatin1( "%1/%2" ).arg( QDir::currentPath(), d->providedFileName ) );
+ }
+ case AbsolutePathName:
+ return fileName( AbsoluteName ).section( sep, 0, -2 );
+ case CanonicalName:
+ return Private::canonicalized( fileName( AbsoluteName ) );
+ case CanonicalPathName:
+ return fileName( CanonicalName ).section( sep, 0, -2 );
+ case BundleName:
+ case LinkName:
+ default:
+ return QString();
+ }
+}
+
+/**
+ * \reimp
+ */
+bool KD7zEngine::open( QIODevice::OpenMode mode )
+{
+ //FIXME: should be unused cause we are using KDUpdater operations for extracting now
+
+ if( d->mode != QIODevice::NotOpen )
+ return false;
+
+ const Lib7z::File file = d->file();
+ if( file.isDirectory )
+ return false; // can't open a directory, dude...
+
+ if( mode & QIODevice::WriteOnly )
+ return false; // no write support yet
+
+ d->openFile = file;
+ d->mode = mode;
+
+ d->buffer.setData( QByteArray() );
+ d->buffer.open( QIODevice::WriteOnly );
+
+ QFile* f = d->archive();
+ if( !f->open( QIODevice::ReadOnly ) )
+ return false;
+
+ bool error = true;
+ try {
+ Lib7z::extractArchive( f, d->openFile, &d->buffer );
+ error = false;
+ d->buffer.close();
+ d->buffer.open( mode );
+ f->close();
+ } catch( const Lib7z::SevenZipException& e ) {
+ qWarning() << e.message();
+ d->buffer.close();
+ f->close();
+ }
+
+ return !error;
+}
+
+/**
+ * \reimp
+ */
+bool KD7zEngine::flush()
+{
+#ifdef SEVENZ_PORT
+ return d->openFileWrite != 0;
+#else
+ return false;
+#endif
+}
+
+/**
+ * \reimp
+ */
+bool KD7zEngine::close()
+{
+ if( d->mode == QIODevice::NotOpen )
+ return false;
+
+ flush();
+ d->mode = QIODevice::NotOpen;
+ d->openFile = Lib7z::File();
+ d->buffer.close();
+ d->buffer.setData( QByteArray() );
+ return true;
+}
+
+/**
+ * \reimp
+ */
+bool KD7zEngine::atEnd() const
+{
+ return d->buffer.atEnd();
+}
+
+/**
+ * \reimp
+ */
+bool KD7zEngine::seek( qint64 offset )
+{
+ return d->buffer.seek( offset );
+}
+
+/**
+ * \reimp
+ */
+qint64 KD7zEngine::pos() const
+{
+ return d->buffer.pos();
+}
+
+/**
+ * \reimp
+ */
+bool KD7zEngine::copy( const QString& newName )
+{
+ //FIXME: should be unused cause we are using KDUpdater operations for extracting now
+
+ QFile* f = d->archive();
+ if( !f->open( QIODevice::ReadOnly ) )
+ return false;
+
+ QFile target( newName );
+ if( !target.open( QIODevice::WriteOnly ) )
+ {
+ f->close();
+ return false;
+ }
+
+ try
+ {
+ qDebug()<<"Extract from"<<d->zipFileName<<"to"<<newName;
+ Lib7z::extractArchive( f, d->file(), &target );
+ f->close();
+ return true;
+ }
+ catch( const Lib7z::SevenZipException& e )
+ {
+ qWarning() << e.message();
+ f->close();
+ return false;
+ }
+}
+
+/**
+ * \reimp
+ */
+qint64 KD7zEngine::read( char* data, qint64 maxlen )
+{
+ return d->buffer.read( data, maxlen );
+}
+
+/**
+ * \reimp
+ */
+qint64 KD7zEngine::write( const char* data, qint64 len )
+{
+#ifdef SEVENZ_PORT
+ const unsigned int l = static_cast< unsigned int >( qMin( len, 0x7fffffffLL ) );
+ return zipWriteInFileInZip( d->openFileWrite, data, l ) == 0 ? l : -1;
+#else
+ Q_UNUSED(data);
+ Q_UNUSED(len);
+ return -1;
+#endif
+}
+
+/**
+ * \reimp
+ */
+qint64 KD7zEngine::size() const
+{
+ const Lib7z::File file = d->file();
+ return file.uncompressedSize;
+}
+
+/**
+ * \reimpl
+ */
+QDateTime KD7zEngine::fileTime( FileTime time ) const
+{
+ const Lib7z::File file = d->file();
+
+ switch( time )
+ {
+ case CreationTime:
+ if( d->fileName.isEmpty() )
+ return QFileInfo( d->zipFileName ).created();
+ case ModificationTime:
+ return d->fileName.isEmpty() ? QFileInfo( d->zipFileName ).lastModified() : file.mtime;
+ case AccessTime:
+ return QFileInfo( d->zipFileName ).lastRead();
+ default:
+ return QDateTime();
+ }
+}
+
+/**
+ * \reimpl
+ */
+bool KD7zEngine::mkdir( const QString& dirName, bool createParentDirectories ) const
+{
+#ifdef SEVENZ_PORT
+ Q_UNUSED( createParentDirectories );
+ static const QChar sep = QChar::fromLatin1( '/' );
+ QString path;
+ const QString root = QString::fromLatin1( "zip://%1" ).arg( d->zipFileName );
+ const QString dir = dirName.mid( root.length() );
+
+ for( int i = 0; i <= dir.count( sep ); ++i )
+ {
+ path += sep + dir.section( sep, i, i );
+
+ if( !QDir( root + path ).exists() )
+ {
+ QString fileName = QString::fromLatin1( "%1/" ).arg( path );
+ QFile file( d->zipFileName );
+
+ zipFile openFileWrite = zipOpen( QFile::encodeName( d->zipFileName ).data(), file.exists() && file.size() > 0 ? APPEND_STATUS_ADDINZIP : APPEND_STATUS_CREATE );
+ zip_fileinfo zi;
+ const QDateTime dt = QDateTime::currentDateTime();
+ zi.tmz_date.tm_sec = dt.time().second();
+ zi.tmz_date.tm_min = dt.time().minute();
+ zi.tmz_date.tm_hour = dt.time().hour();
+ zi.tmz_date.tm_mday = dt.date().day();
+ zi.tmz_date.tm_mon = dt.date().month() - 1;
+ zi.tmz_date.tm_year = dt.date().year();
+ zi.dosDate = 0;
+ zi.internal_fa = 0;
+ zi.external_fa = 0;
+ while( fileName.startsWith( sep ) )
+ fileName.remove( 0, 1 );
+
+ if( fileName.isEmpty() )
+ continue;
+
+ const bool result = zipOpenNewFileInZip( openFileWrite, QFile::encodeName( fileName ).data(),
+ &zi, 0, 0, 0, 0, 0, Z_DEFLATED, Z_DEFAULT_COMPRESSION ) == ZIP_OK;
+ if( result )
+ zipCloseFileInZip( openFileWrite );
+ zipClose( openFileWrite, 0 );
+ if( !result )
+ return false;
+ }
+ }
+ return true;
+#else
+ Q_UNUSED(dirName);
+ Q_UNUSED(createParentDirectories);
+ return false;
+#endif
+}
+
+/**
+ * \reimp
+ */
+QAbstractFileEngine::FileFlags KD7zEngine::fileFlags( FileFlags type ) const
+{
+ FileFlags result;
+
+ static const QLatin1Char sep( '/' );
+ static const QString sepString( sep );
+
+ if( !QFile::exists( d->zipFileName ) )
+ return result;
+
+ if( d->flags != 0 && ( type & Refresh ) == 0 )
+ return d->flags;
+
+ const Lib7z::File file = d->file();
+ const QString name = file.path;
+
+ if( type & ExistsFlag )
+ {
+ if( d->fileName.isEmpty() || d->fileName == sepString )
+ result |= ExistsFlag;
+ else if( !name.isEmpty() )
+ result |= ExistsFlag;
+ }
+ if( ( type & FileType ) && !name.isEmpty() && !file.isDirectory )
+ result |= FileType;
+ if( ( ( type & DirectoryType ) && file.isDirectory ) || ( name.isEmpty() && ( result & ExistsFlag ) ) )
+ result |= DirectoryType;
+ if( ( type & DirectoryType ) && ( d->fileName.isEmpty() || d->fileName == sepString ) )
+ result |= DirectoryType;
+
+ if( ( type & 0x7777 ) )
+ result |= ( static_cast< QAbstractFileEngine::FileFlags >( static_cast< quint32 >( file.permissions ) ) & type );
+
+ d->flags = result;
+
+ return result;
+}
diff --git a/installerbuilder/common/kd7zengine.h b/installerbuilder/common/kd7zengine.h
new file mode 100644
index 000000000..71cd7da77
--- /dev/null
+++ b/installerbuilder/common/kd7zengine.h
@@ -0,0 +1,73 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef KD7ZENGINE_H
+#define KD7ZENGINE_H
+
+#include <QtCore/QAbstractFileEngine>
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include "installer_global.h"
+
+class INSTALLER_EXPORT KD7zEngine : public QAbstractFileEngine
+{
+public:
+ explicit KD7zEngine( const QString& fileName );
+ ~KD7zEngine();
+
+ bool caseSensitive() const;
+
+ FileFlags fileFlags( FileFlags type = FileInfoAll ) const;
+ QString fileName( FileName file = DefaultName ) const;
+ QDateTime fileTime( FileTime time ) const;
+
+ bool copy( const QString& newName );
+
+ bool atEnd() const;
+ qint64 size() const;
+
+ bool seek( qint64 offset );
+ qint64 pos() const;
+
+ bool open( QIODevice::OpenMode mode );
+ bool close();
+ bool flush();
+
+ bool mkdir( const QString& dirName, bool createParentDirectories ) const;
+
+ QStringList entryList( QDir::Filters filters, const QStringList& filterNames ) const;
+ Iterator* beginEntryList( QDir::Filters filters, const QStringList& filterNames );
+
+ void setFileName( const QString& file );
+
+ qint64 read( char* data, qint64 maxlen );
+ qint64 write( const char* data, qint64 len );
+
+private:
+ class Private;
+ kdtools::pimpl_ptr<Private> d;
+};
+
+#endif // KD7ZENGINE_H
diff --git a/installerbuilder/common/kd7zenginehandler.cpp b/installerbuilder/common/kd7zenginehandler.cpp
new file mode 100644
index 000000000..7fbe7ed90
--- /dev/null
+++ b/installerbuilder/common/kd7zenginehandler.cpp
@@ -0,0 +1,41 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "kd7zenginehandler.h"
+
+#include "kd7zengine.h"
+
+QAbstractFileEngine* KD7zEngineHandler::create( const QString& fileName ) const
+{
+ return fileName.startsWith( QString::fromLatin1( "7z://" ), Qt::CaseInsensitive ) ? new KD7zEngine( fileName ) : 0;
+}
+
diff --git a/installerbuilder/common/kd7zenginehandler.h b/installerbuilder/common/kd7zenginehandler.h
new file mode 100644
index 000000000..4c06d983e
--- /dev/null
+++ b/installerbuilder/common/kd7zenginehandler.h
@@ -0,0 +1,39 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef KD7ZENGINEHANDLER_H
+#define KD7ZENGINEHANDLER_H
+
+#include <QtCore/QAbstractFileEngineHandler>
+
+#include "installer_global.h"
+
+class INSTALLER_EXPORT KD7zEngineHandler : public QAbstractFileEngineHandler
+{
+public:
+ QAbstractFileEngine* create( const QString& filename ) const;
+};
+
+#endif // KD7ZENGINEHANDLER_H
diff --git a/installerbuilder/common/libeay32.dll b/installerbuilder/common/libeay32.dll
new file mode 100644
index 000000000..433463cb6
--- /dev/null
+++ b/installerbuilder/common/libeay32.dll
Binary files differ
diff --git a/installerbuilder/common/libssl32.dll b/installerbuilder/common/libssl32.dll
new file mode 100644
index 000000000..6d7f4468f
--- /dev/null
+++ b/installerbuilder/common/libssl32.dll
Binary files differ
diff --git a/installerbuilder/common/openssl.qrc b/installerbuilder/common/openssl.qrc
new file mode 100644
index 000000000..1168d5906
--- /dev/null
+++ b/installerbuilder/common/openssl.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+<qresource prefix="/openssllibs">
+ <file>libssl32.dll</file>
+ <file>libeay32.dll</file>
+</qresource>
+</RCC> \ No newline at end of file
diff --git a/installerbuilder/common/range.h b/installerbuilder/common/range.h
new file mode 100644
index 000000000..37625921c
--- /dev/null
+++ b/installerbuilder/common/range.h
@@ -0,0 +1,88 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef RANGE_H
+#define RANGE_H
+
+#include <algorithm>
+
+template <typename T>
+class Range {
+public:
+ static Range<T> fromStartAndEnd( const T& start, const T& end ) {
+ Range<T> r;
+ r.m_start = start;
+ r.m_end = end;
+ return r;
+ }
+
+ static Range<T> fromStartAndLength( const T& start, const T& length ) {
+ Range<T> r;
+ r.m_start = start;
+ r.m_end = start + length;
+ return r;
+ }
+
+ Range() : m_start( 0 ), m_end( 0 ) {}
+
+ T start() const { return m_start; }
+
+ T end() const { return m_end; }
+
+ void move( const T& by ) {
+ m_start += by;
+ m_end += by;
+ }
+
+ Range<T> moved( const T& by ) const {
+ Range<T> b = *this;
+ b.move( by );
+ return b;
+ }
+
+ T length() const { return m_end - m_start; }
+
+ Range<T> normalized() const {
+ Range<T> r2( *this );
+ if ( r2.m_start > r2.m_end )
+ std::swap( r2.m_start, r2.m_end );
+ return r2;
+ }
+
+ bool operator==( const Range<T>& other ) const {
+ return m_start == other.m_start && m_end && other.m_end;
+ }
+ bool operator<( const Range<T>& other ) const {
+ if ( m_start != other.m_start )
+ return m_start < other.m_start;
+ return m_end < other.m_end;
+ }
+
+private:
+ T m_start;
+ T m_end;
+};
+
+#endif /* RANGE_H_ */
diff --git a/installerbuilder/common/repository.cpp b/installerbuilder/common/repository.cpp
new file mode 100644
index 000000000..ecd4d8a98
--- /dev/null
+++ b/installerbuilder/common/repository.cpp
@@ -0,0 +1,58 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "repository.h"
+
+using namespace QInstaller;
+
+Repository::Repository() : m_required( false ) {
+}
+
+void Repository::setUrl( const QUrl& url ) {
+ m_url = url;
+}
+
+bool Repository::isValid() const {
+ return m_url.isValid();
+}
+
+QUrl Repository::url() const {
+ return m_url;
+}
+
+void Repository::setRequired( bool r ) {
+ m_required = r;
+}
+
+bool Repository::required() const {
+ return m_required;
+}
diff --git a/installerbuilder/common/repository.h b/installerbuilder/common/repository.h
new file mode 100644
index 000000000..e6680b9f0
--- /dev/null
+++ b/installerbuilder/common/repository.h
@@ -0,0 +1,59 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef REPOSITORY_H
+#define REPOSITORY_H
+
+#include <QUrl>
+
+#include "installer_global.h"
+
+namespace QInstaller {
+ class INSTALLER_EXPORT Repository
+ {
+ public:
+ Repository();
+
+ void setUrl( const QUrl& url );
+ QUrl url() const;
+
+ bool isValid() const;
+
+ void setRequired( bool r );
+
+ /**
+ * returns whether the repository is required for installation. If a
+ * required repository cannot be reached or an error occurrs accessing
+ * it, the installer will fail.
+ */
+ bool required() const;
+
+ private:
+ bool m_required;
+ QUrl m_url;
+ };
+}
+
+#endif // REPOSITORY_H
diff --git a/installerbuilder/common/repositorygen.cpp b/installerbuilder/common/repositorygen.cpp
new file mode 100644
index 000000000..3a1a533cd
--- /dev/null
+++ b/installerbuilder/common/repositorygen.cpp
@@ -0,0 +1,802 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "repositorygen.h"
+
+#include <common/fileutils.h>
+#include <common/errors.h>
+#include <common/utils.h>
+#include <common/consolepasswordprovider.h>
+#include <common/installersettings.h>
+
+#include <KDUpdater/KDUpdater>
+
+#include <QCryptographicHash>
+#include <QDir>
+#include <QDirIterator>
+#include <QDomAttr>
+#include <QDomDocument>
+#include <QTemporaryFile>
+
+#include "lib7z_facade.h"
+
+#include <cassert>
+
+using namespace QInstaller;
+
+static bool operator==(const PackageInfo& lhs, const PackageInfo& rhs)
+{
+ return lhs.name == rhs.name && lhs.version == rhs.version;
+}
+
+static QVector<PackageInfo> collectAvailablePackages(const QString& packagesDirectory)
+{
+ verbose() << "Collecting information about available packages..." << std::endl;
+
+ QVector< PackageInfo > dict;
+ const QFileInfoList entries = QDir(packagesDirectory)
+ .entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ for (QFileInfoList::const_iterator it = entries.begin(); it != entries.end(); ++it) {
+ verbose() << " found subdirectory \"" << it->fileName() << "\"";
+ QFile file(QString::fromLatin1("%1/meta/package.xml").arg(it->filePath()));
+ if (!file.exists()) {
+ verbose() << ", but it contains no package information (meta/package.xml missing)"
+ << std::endl;
+ throw QInstaller::Error(QObject::tr("Component %1 does not contain a package "
+ "description.").arg(it->fileName()));
+ }
+
+ file.open(QIODevice::ReadOnly);
+
+ QDomDocument doc;
+ QString errorMessage;
+ int errorLine = 0;
+ int errorColumn = 0;
+ if (!doc.setContent(&file, &errorMessage, &errorLine, &errorColumn)) {
+ verbose() << ", but it's package description is invalid. Error at " << errorLine
+ << ", " << errorColumn << ": " << errorMessage << std::endl;
+ throw QInstaller::Error(QObject::tr("Component package description for %1 is invalid. "
+ "Error at %2, %3 : %4").arg(it->fileName(), QString::number(errorLine),
+ QString::number(errorColumn), errorMessage));
+ }
+
+ const QString name = doc.firstChildElement(QString::fromLatin1("Package"))
+ .firstChildElement(QLatin1String("Name")).text();
+ if (name != it->fileName()) {
+ throw QInstaller::Error(QObject::tr("Component folder name must match component name: "
+ "\"%1\" in %2/").arg(name, it->fileName()));
+ }
+
+ PackageInfo info;
+ info.name = name;
+ info.version = doc.firstChildElement(QString::fromLatin1("Package")).
+ firstChildElement(QString::fromLatin1("Version")).text();
+ info.dependencies = doc.firstChildElement(QString::fromLatin1("Package")).
+ firstChildElement(QString::fromLatin1("Dependencies")).text().split(QLatin1String(","),
+ QString::SkipEmptyParts);
+ info.directory = it->filePath();
+ dict.push_back(info);
+
+ verbose() << ", it provides the package " <<name;
+ if (!info.version.isEmpty())
+ verbose() << "-" << info.version;
+ verbose() << std::endl;
+ }
+
+ if (dict.isEmpty())
+ verbose() << "No available packages found at the specified location." << std::endl;
+
+ return dict;
+}
+
+static PackageInfo findMatchingPackage(const QString& name, const QVector< PackageInfo >& available)
+{
+ const QString id = name.contains(QChar::fromLatin1('-'))
+ ? name.section(QChar::fromLatin1('-'), 0, 0) : name;
+ QString version = name.contains(QChar::fromLatin1('-'))
+ ? name.section(QChar::fromLatin1('-'), 1, -1) : QString();
+
+ QRegExp compEx(QLatin1String("([<=>]+)(.*)"));
+ const QString comparator = compEx.exactMatch(version)
+ ? compEx.cap(1) : QString::fromLatin1("=");
+ version = compEx.exactMatch(version) ? compEx.cap(2) : version;
+
+ const bool allowEqual = comparator.contains(QLatin1Char('='));
+ const bool allowLess = comparator.contains(QLatin1Char('<'));
+ const bool allowMore = comparator.contains(QLatin1Char('>'));
+
+ for (QVector< PackageInfo >::const_iterator it = available.begin(); it != available.end(); ++it) {
+ if (it->name != id)
+ continue;
+
+ if (allowEqual && (version.isEmpty() || it->version == version))
+ return *it;
+ else if (allowLess && KDUpdater::compareVersion(version, it->version) > 0)
+ return *it;
+ else if (allowMore && KDUpdater::compareVersion(version, it->version) < 0)
+ return *it;
+ }
+
+ return PackageInfo();
+}
+
+/**
+ * Returns true, when the \a package's identifier starts with, but not equals \a prefix.
+ */
+static bool packageHasPrefix(const PackageInfo& package, const QString& prefix)
+{
+ return package.name.startsWith(prefix) && package.name.mid(prefix.length(), 1)
+ == QString::fromLatin1(".");
+}
+
+/**
+ * Returns true, whel all \a packages start with \a prefix
+ */
+static bool allPackagesHavePrefix(const QVector< PackageInfo >& packages, const QString& prefix)
+{
+ for (QVector< PackageInfo >::const_iterator it = packages.begin(); it != packages.end(); ++it) {
+ if (!packageHasPrefix(*it, prefix))
+ return false;
+ }
+ return true;
+}
+
+/**
+ * Returns all packages out of \a all starting with \a prefix.
+ */
+static QVector< PackageInfo > packagesWithPrefix(const QVector< PackageInfo >& all,
+ const QString& prefix)
+{
+ QVector< PackageInfo > result;
+ for (QVector< PackageInfo >::const_iterator it = all.begin(); it != all.end(); ++it) {
+ if (packageHasPrefix(*it, prefix))
+ result.push_back(*it);
+ }
+ return result;
+}
+
+static QVector< PackageInfo > calculateNeededPackages(const QStringList& components,
+ const QVector< PackageInfo >& available, bool addDependencies = true)
+{
+ QVector< PackageInfo > result;
+
+ for (QStringList::const_iterator it = components.begin(); it != components.end(); ++it) {
+ static bool recursion = false;
+ static QStringList hitComponents;
+
+ if (!recursion)
+ hitComponents.clear();
+
+ if (hitComponents.contains(*it))
+ throw Error(QObject::tr("Circular dependencies detected").arg(*it));
+ hitComponents.push_back(*it);
+
+ recursion = true;
+
+ verbose() << "Trying to find a package for name " << *it << "... ";
+ const PackageInfo info = findMatchingPackage(*it, available);
+ if (info.name.isEmpty()) {
+ verbose() << "Not found :-o" << std::endl;
+ verbose() << " Couldn't find package for component " << *it << " bailing out..."
+ << std::endl;
+ throw Error(QObject::tr("Couldn't find package for component %1").arg(*it));
+ }
+ verbose() << "Found." << std::endl;
+ if (!result.contains(info)) {
+ result.push_back(info);
+
+ if (addDependencies) {
+ QVector< PackageInfo > dependencies;
+
+ if (!info.dependencies.isEmpty()) {
+ verbose() << " It depends on:" << std::endl;
+ for (QStringList::const_iterator dep = info.dependencies.begin();
+ dep != info.dependencies.end(); ++dep)
+ verbose() << " " << *dep << std::endl;
+ dependencies += calculateNeededPackages(info.dependencies, available);
+ }
+ // append all child items, as this package was requested explicitely
+ dependencies += packagesWithPrefix(available, info.name);
+
+ for (QVector< PackageInfo >::const_iterator dep = dependencies.begin();
+ dep != dependencies.end(); ++dep) {
+ if (result.contains(*dep))
+ continue;
+
+ result += *dep;
+ const QVector< PackageInfo > depdeps = calculateNeededPackages(QStringList()
+ << dep->name, available);
+ for (QVector< PackageInfo >::const_iterator dep2 = depdeps.begin();
+ dep2 != depdeps.end(); ++dep2)
+ if (!result.contains(*dep2))
+ result += *dep2;
+ }
+ }
+ }
+
+ recursion = false;
+ }
+
+ return result;
+}
+
+namespace {
+ struct ArchiveFile {
+ ArchiveFile() : uncompressedSize(0) {}
+ quint64 uncompressedSize;
+ QByteArray sha1sum;
+ QString fileName;
+ };
+}
+
+void QInstaller::compressDirectory(const QString& path, const QString& archivePath)
+{
+ if (!QFileInfo(path).exists())
+ throw QInstaller::Error(QObject::tr("Folder %1 does not exist").arg(path));
+
+ if (!QFileInfo(path).isDir())
+ throw QInstaller::Error(QObject::tr("%1 is not a folder").arg(path));
+
+ QFile archive(archivePath);
+ openForWrite(&archive, archivePath);
+ Lib7z::createArchive(&archive, path);
+}
+
+void QInstaller::compressMetaDirectories(const QString& configDir, const QString& repoDir)
+{
+ const QString configfile = QFileInfo(configDir, QLatin1String("config.xml")).absoluteFilePath();
+ const QInstaller::InstallerSettings settings =
+ QInstaller::InstallerSettings::fromFileAndPrefix(configfile, configDir);
+
+ KDUpdaterCrypto crypto;
+ crypto.setPrivateKey(settings.privateKey());
+ ConsolePasswordProvider passwordProvider;
+ crypto.setPrivatePasswordProvider(&passwordProvider);
+
+ QDir dir(repoDir);
+ const QStringList sub = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
+ Q_FOREACH (const QString& i, sub) {
+ QDir sd(dir);
+ sd.cd(i);
+ const QString absPath = sd.absolutePath();
+ const QString fn = QLatin1String("meta.7z");
+ const QString tmpTarget = repoDir + QLatin1String("/") +fn;
+ compressDirectory(absPath, tmpTarget);
+ QFile tmp(tmpTarget);
+ const QString finalTarget = absPath + QLatin1String("/") + fn;
+ if (!tmp.rename(finalTarget)) {
+ throw QInstaller::Error(QObject::tr("Could not move %1 to %2").arg(tmpTarget,
+ finalTarget));
+ }
+
+ // if we have a private key, sign the meta.7z file
+ if (!settings.privateKey().isEmpty()) {
+ verbose() << "Adding a RSA signature to " << finalTarget << std::endl;
+ const QByteArray signature = crypto.sign(finalTarget);
+ QFile sigFile(finalTarget + QLatin1String(".sig"));
+ if (!sigFile.open(QIODevice::WriteOnly)) {
+ throw QInstaller::Error(QObject::tr("Could not open %1 for writing")
+ .arg(finalTarget));
+ }
+ sigFile.write(signature);
+ }
+ }
+}
+
+void QInstaller::generateMetaDataDirectory(const QString& metapath_, const QString& dataDir,
+ const QVector< PackageInfo >& packages, const QString& appName, const QString& appVersion)
+{
+ QString metapath = metapath_;
+ if (QFileInfo(metapath).isRelative())
+ metapath = QDir::cleanPath(QDir::current().absoluteFilePath(metapath));
+ verbose() << "Generating meta data..." << std::endl;
+
+ if (!QFile::exists(metapath))
+ QInstaller::mkpath(metapath);
+
+ QDomDocument doc;
+ QDomElement root;
+ // use existing Updates.xml, if any
+ QFile existingUpdatesXml(QFileInfo(dataDir, QLatin1String("Updates.xml")).absoluteFilePath());
+ if (!existingUpdatesXml.open(QIODevice::ReadOnly) || !doc.setContent(&existingUpdatesXml)) {
+ root = doc.createElement("Updates");
+ root.appendChild(doc.createElement("ApplicationName")).appendChild(
+ doc.createTextNode(appName));
+ root.appendChild(doc.createElement("ApplicationVersion")).appendChild(
+ doc.createTextNode(appVersion));
+ root.appendChild(doc.createElement("Checksum")).appendChild(
+ doc.createTextNode(QLatin1String("true")));
+ } else {
+ root = doc.documentElement();
+ }
+
+ for (QVector< PackageInfo >::const_iterator it = packages.begin(); it != packages.end(); ++it) {
+ const QString packageXmlPath = QString::fromLatin1("%1/meta/package.xml").arg(it->directory);
+ verbose() << " Generating meta data for package " << it->name << " using "
+ << packageXmlPath << std::endl;;
+
+ // remove existing entry for thes component from existing Updates.xml
+ const QDomNodeList packageNodes = root.childNodes();
+ for (int i = 0; i < packageNodes.count(); ++i) {
+ const QDomNode node = packageNodes.at(i);
+ if (node.nodeName() != QLatin1String("PackageUpdate"))
+ continue;
+ if (node.firstChildElement(QLatin1String("Name")).text() != it->name)
+ continue;
+ root.removeChild(node);
+ --i;
+ }
+
+ QDomDocument packageXml;
+ QFile file(packageXmlPath);
+ openForRead(&file, packageXmlPath);
+ QString errMsg;
+ int col = 0;
+ int line = 0;
+ if (!packageXml.setContent(&file, &errMsg, &line, &col)) {
+ throw Error(QObject::tr("Could not parse %1: %2:%3: %4 (%5)").arg(packageXmlPath,
+ QString::number(line), QString::number(col), errMsg, it->name));
+ }
+ const QDomNode package = packageXml.firstChildElement("Package");
+
+ QDomElement update = doc.createElement("PackageUpdate");
+
+ const QDomNodeList childNodes = package.childNodes();
+ for (int i = 0; i < childNodes.count(); ++i) {
+ const QDomNode node = childNodes.at(i);
+ // just skip the comments...
+ if (node.isComment())
+ continue;
+ const QString key = node.nodeName();
+ if (key == QString::fromLatin1("UserInterfaces"))
+ continue;
+ if (key == QString::fromLatin1("Translations"))
+ continue;
+ if (key == QString::fromLatin1("Licenses"))
+ continue;
+ const QString value = node.toElement().text();
+ update.appendChild(doc.createElement(key)).appendChild(doc.createTextNode(value));
+ }
+
+ // get the size of the data
+ quint64 componentSize = 0;
+ quint64 compressedComponentSize = 0;
+
+ const QString cmpDataDir = QString::fromLatin1("%1/%2").arg(dataDir, it->name);
+ const QFileInfoList entries = !QDir(cmpDataDir + QLatin1String("/data")).exists()
+ ? QDir(cmpDataDir).entryInfoList(QDir::Files | QDir::NoDotAndDotDot)
+ : QDir(cmpDataDir + QLatin1String("/data")).entryInfoList(QDir::Files
+ | QDir::Dirs | QDir::NoDotAndDotDot);
+ QVector<ArchiveFile> archiveFiles;
+
+ Q_FOREACH (const QFileInfo& fi, entries) {
+ if (fi.isHidden())
+ continue;
+
+ try {
+ if (fi.isDir()) {
+ QDirIterator recursDirIt(fi.filePath(), QDirIterator::Subdirectories);
+ while (recursDirIt.hasNext()) {
+ componentSize += QFile(recursDirIt.next()).size();
+ compressedComponentSize += QFile(recursDirIt.next()).size();
+ }
+ } else if (Lib7z::isSupportedArchive(fi.filePath())) {
+ // if it's an archive already, list it's files and sum the uncompressed sizes
+ QFile archive(fi.filePath());
+ compressedComponentSize += archive.size();
+ archive.open(QIODevice::ReadOnly);
+ const QVector< Lib7z::File > files = Lib7z::listArchive(&archive);
+ for (QVector< Lib7z::File >::const_iterator fileIt = files.begin();
+ fileIt != files.end(); ++fileIt) {
+ componentSize += fileIt->uncompressedSize;
+ }
+ } else {
+ // otherwise just add it's size
+ componentSize += fi.size();
+ compressedComponentSize += fi.size();
+ }
+ } catch(...) {
+ // ignore, that's just about the sizes - and size doesn't matter, you know?
+ }
+ }
+
+ // add fake update files
+ const QStringList platforms = QStringList() << "Windows" << "MacOSX" << "Linux";
+ Q_FOREACH (const QString& platform, platforms) {
+ QDomElement file = doc.createElement("UpdateFile");
+ file.setAttribute("OS", platform);
+ file.setAttribute("UncompressedSize", componentSize);
+ file.setAttribute("CompressedSize", compressedComponentSize);
+ file.appendChild(doc.createTextNode(QLatin1String("(null)")));
+ update.appendChild(file);
+ }
+
+ root.appendChild(update);
+
+ if (!QDir(metapath).mkpath(it->name))
+ throw Error(QObject::tr("Could not create directory %1").arg(it->name));
+
+ // copy scripts
+ const QString script = package.firstChildElement("Script").text();
+ if (!script.isEmpty()) {
+ verbose() << " Copying associated script " << script << " into the meta package...";
+ if (!QFile::copy(QString::fromLatin1("%1/meta/%2").arg(it->directory, script),
+ QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, script))) {
+ verbose() << "failed!" << std::endl;
+ throw Error(QObject::tr("Could not copy the scriot %1 to its target location (%2)")
+ .arg(script, it->name));
+ } else {
+ verbose() << std::endl;
+ }
+ }
+
+ // copy user interfaces
+ const QDomNodeList uiNodes = package.firstChildElement("UserInterfaces").childNodes();
+ QStringList userinterfaces;
+ for (int i = 0; i < uiNodes.count(); ++i) {
+ const QDomNode node = uiNodes.at(i);
+ if (node.nodeName() != QString::fromLatin1("UserInterface"))
+ continue;
+
+ const QDir dir(QString::fromLatin1("%1/meta").arg(it->directory));
+ const QStringList uis = dir.entryList(QStringList(node.toElement().text()), QDir::Files);
+ if (uis.isEmpty()) {
+ throw Error(QObject::tr("Couldn't find any user interface matching %1 while copying "
+ "user interfaces of %2").arg(node.toElement().text(), it->name));
+ }
+
+ for (QStringList::const_iterator ui = uis.begin(); ui != uis.end(); ++ui) {
+ verbose() << " Copying associated user interface " << *ui << " into the meta "
+ "package...";
+ userinterfaces.push_back(*ui);
+ if (!QFile::copy(QString::fromLatin1("%1/meta/%2").arg(it->directory, *ui),
+ QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, *ui))) {
+ verbose() << "failed!" << std::endl;
+ throw Error(QObject::tr("Could not copy the UI file %1 to its target location "
+ "(%2)").arg(*ui, it->name));
+ } else {
+ verbose() << std::endl;
+ }
+ }
+ }
+
+ if (!userinterfaces.isEmpty()) {
+ update.appendChild(doc.createElement(QString::fromLatin1("UserInterfaces")))
+ .appendChild(doc.createTextNode(userinterfaces.join(QChar::fromLatin1(','))));
+ }
+
+ // copy translations
+ const QDomNodeList qmNodes = package.firstChildElement("Translations").childNodes();
+ QStringList translations;
+ for (int i = 0; i < qmNodes.count(); ++i) {
+ const QDomNode node = qmNodes.at(i);
+ if (node.nodeName() != QString::fromLatin1("Translation"))
+ continue;
+
+ const QDir dir(QString::fromLatin1("%1/meta").arg(it->directory));
+ const QStringList qms = dir.entryList(QStringList(node.toElement().text()), QDir::Files);
+ if (qms.isEmpty()) {
+ throw Error(QObject::tr("Could not find any user interface matching %1 while "
+ "copying user interfaces of %2").arg(node.toElement().text(), it->name));
+ }
+
+ for (QStringList::const_iterator qm = qms.begin(); qm != qms.end(); ++qm) {
+ verbose() << " Copying associated translation " << *qm << " into the meta "
+ "package...";
+ translations.push_back(*qm);
+ if (!QFile::copy(QString::fromLatin1("%1/meta/%2").arg(it->directory, *qm),
+ QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, *qm))) {
+ verbose() << "failed!" << std::endl;
+ throw Error(QObject::tr("Could not copy the translation %1 to its target "
+ "location (%2)").arg(*qm, it->name));
+ } else {
+ verbose() << std::endl;
+ }
+ }
+ }
+
+ if (!translations.isEmpty()) {
+ update.appendChild(doc.createElement(QString::fromLatin1("Translations")))
+ .appendChild(doc.createTextNode(translations.join(QChar::fromLatin1(','))));
+ }
+
+ // copy license files
+ const QDomNodeList licenseNodes = package.firstChildElement("Licenses").childNodes();
+ for (int i = 0; i < licenseNodes.count(); ++i) {
+ const QDomNode licenseNode = licenseNodes.at(i);
+ if (licenseNode.nodeName() == QLatin1String("License")) {
+ const QString &licenseFile =
+ licenseNode.toElement().attributeNode(QLatin1String("file")).value();
+ const QString &sourceFile =
+ QString::fromLatin1("%1/meta/%2").arg(it->directory).arg(licenseFile);
+ if (!QFile::exists(sourceFile)) {
+ throw Error(QObject::tr("Could not find any license matching %1 while "
+ "copying license files of %2").arg(licenseFile, it->name));
+ }
+
+ verbose() << " Copying associated license file " << licenseFile << " into "
+ "the meta package...";
+ if (!QFile::copy(sourceFile, QString::fromLatin1("%1/%2/%3")
+ .arg(metapath, it->name, licenseFile))) {
+ verbose() << "failed!" << std::endl;
+ throw Error(QObject::tr("Could not copy the license file %1 to its "
+ "target location (%2)").arg(licenseFile, it->name));
+ } else {
+ verbose() << std::endl;
+ }
+ }
+ }
+
+ if (licenseNodes.count() > 0)
+ update.appendChild(package.firstChildElement("Licenses").cloneNode());
+ }
+
+ doc.appendChild(root);
+
+ const QString updatesXmlFile = QFileInfo(metapath, "Updates.xml").absoluteFilePath();
+ QFile updatesXml(updatesXmlFile);
+
+ openForWrite(&updatesXml, updatesXmlFile);
+ blockingWrite(&updatesXml, doc.toByteArray());
+}
+
+QVector<PackageInfo> QInstaller::createListOfPackages(const QStringList& components,
+ const QString& packagesDirectory, bool addDependencies)
+{
+ const QVector< PackageInfo > available = collectAvailablePackages(packagesDirectory);
+ verbose() << "Calculating dependencies for selected packages..." << std::endl;
+ QVector<PackageInfo> needed = calculateNeededPackages(components, available, addDependencies);
+
+ verbose() << "The following packages will be placed in the installer:" << std::endl;
+ Q_FOREACH (const PackageInfo& i, needed) {
+ verbose() << " " << i.name;
+ if (!i.version.isEmpty())
+ verbose() << "-" << i.version;
+ verbose() << std::endl;
+ }
+
+ // now just append the virtual parents (not including all their descendants!)
+ // like... if com.nokia.sdk.qt.qtcore was passed, even com.nokia.sdk.qt will show up in the tree
+ if (addDependencies) {
+ for (int i = 0; i < needed.count(); ++i) {
+ const PackageInfo& package = needed[ i ];
+ const QString name = package.name;
+ const QString version = package.version;
+ QString id = name.section(QChar::fromLatin1('.'), 0, -2);
+ while (!id.isEmpty()) {
+ PackageInfo info;
+ if (!version.isEmpty())
+ info = findMatchingPackage(QString::fromLatin1("%1-%2").arg(id, version), available);
+ if (info.name.isEmpty())
+ info = findMatchingPackage(id, available);
+ if (!info.name.isEmpty() && !allPackagesHavePrefix(needed, id) && !needed.contains(info)) {
+ verbose() << "Adding " << info.name << " as it is the virtual parent item of "
+ << name << std::endl;
+ needed.push_back(info);
+ }
+ id = id.section(QChar::fromLatin1('.'), 0, -2);
+ }
+ }
+ }
+
+ return needed;
+}
+
+QMap<QString, QString> QInstaller::buildPathToVersionMap(const QVector<PackageInfo>& info)
+{
+ QMap<QString, QString> map;
+ Q_FOREACH (PackageInfo inf, info) {
+ map[inf.name] = inf.version;
+ }
+ return map;
+}
+
+static void writeSHA1ToNodeWithName(QDomDocument& doc, QDomNodeList& list, const QByteArray& sha1sum,
+ const QString& nodename)
+{
+ verbose() << "searching sha1sum node for " << nodename << std::endl;
+ for (int i = 0; i < list.size(); ++i) {
+ QDomNode curNode = list.at(i);
+ QDomNode nameTag = curNode.firstChildElement(QLatin1String("Name"));
+ if (!nameTag.isNull() && nameTag.toElement().text() == nodename) {
+ QDomNode sha1Node = doc.createElement(QLatin1String("SHA1"));
+ sha1Node.appendChild(doc.createTextNode(QString::fromLatin1(sha1sum.toHex().constData())));
+ curNode.appendChild(sha1Node);
+ }
+ }
+}
+
+void QInstaller::compressMetaDirectories(const QString& configDir, const QString& repoDir,
+ const QString& baseDir, const QMap<QString, QString>& versionMapping)
+{
+ const QString configfile = QFileInfo(configDir, QLatin1String("config.xml")).absoluteFilePath();
+ const QInstaller::InstallerSettings settings =
+ QInstaller::InstallerSettings::fromFileAndPrefix(configfile, configDir);
+
+ KDUpdaterCrypto crypto;
+ crypto.setPrivateKey(settings.privateKey());
+ ConsolePasswordProvider passwordProvider;
+ crypto.setPrivatePasswordProvider(&passwordProvider);
+ QDomDocument doc;
+ QDomElement root;
+ // use existing Updates.xml, if any
+ QFile existingUpdatesXml(QFileInfo(QDir(repoDir), QLatin1String("Updates.xml")).absoluteFilePath());
+ if (!existingUpdatesXml.open(QIODevice::ReadOnly) || !doc.setContent(&existingUpdatesXml)) {
+ verbose() << "Could not find Updates.xml" << std::endl;
+ } else {
+ root = doc.documentElement();
+ }
+ existingUpdatesXml.close();
+
+ QDir dir(repoDir);
+ const QStringList sub = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
+ QDomNodeList elements = doc.elementsByTagName(QLatin1String("PackageUpdate"));
+ Q_FOREACH (const QString& i, sub) {
+ QDir sd(dir);
+ sd.cd(i);
+ const QString path = QString(i).remove(baseDir);
+ const QString versionPrefix = versionMapping[path];
+ if (path.isNull())
+ continue;
+ const QString absPath = sd.absolutePath();
+ const QString fn = QLatin1String(versionPrefix.toLatin1() + "meta.7z");
+ const QString tmpTarget = repoDir + QLatin1String("/") +fn;
+ compressDirectory(absPath, tmpTarget);
+ QFile tmp(tmpTarget);
+ tmp.open(QFile::ReadOnly);
+ QByteArray fileToCheck = tmp.readAll();
+ QByteArray sha1Sum = QCryptographicHash::hash(fileToCheck, QCryptographicHash::Sha1);
+ writeSHA1ToNodeWithName(doc, elements, sha1Sum, path);
+ const QString finalTarget = absPath + QLatin1String("/") + fn;
+ if (!tmp.rename(finalTarget))
+ throw QInstaller::Error(QObject::tr("Could not move %1 to %2").arg(tmpTarget, finalTarget));
+
+ // if we have a private key, sign the meta.7z file
+ if (!settings.privateKey().isEmpty()) {
+ verbose() << "Adding a RSA signature to " << finalTarget << std::endl;
+ const QByteArray signature = crypto.sign(finalTarget);
+ QFile sigFile(finalTarget + QLatin1String(".sig"));
+ if (!sigFile.open(QIODevice::WriteOnly))
+ throw QInstaller::Error(QObject::tr("Could not open %1 for writing").arg(finalTarget));
+
+ sigFile.write(signature);
+ }
+ }
+ openForWrite(&existingUpdatesXml, existingUpdatesXml.fileName());
+ blockingWrite(&existingUpdatesXml, doc.toByteArray());
+ existingUpdatesXml.close();
+}
+
+void QInstaller::copyComponentData(const QString& packageDir, const QString& configDir,
+ const QString& repoDir, const QVector<PackageInfo>& infos)
+{
+ const QString configfile = QFileInfo(configDir, QLatin1String("config.xml")).absoluteFilePath();
+ const QInstaller::InstallerSettings settings =
+ QInstaller::InstallerSettings::fromFileAndPrefix(configfile, configDir);
+
+ KDUpdaterCrypto crypto;
+ crypto.setPrivateKey(settings.privateKey());
+ ConsolePasswordProvider passwordProvider;
+ crypto.setPrivatePasswordProvider(&passwordProvider);
+
+ Q_FOREACH (const PackageInfo& info, infos) {
+ const QString i = info.name;
+ verbose() << "Copying component data for " << i << std::endl;
+ const QString dataDirPath = QString::fromLatin1("%1/%2/data").arg(packageDir, i);
+ const QDir dataDir(dataDirPath);
+ if (!QDir().mkpath(QString::fromLatin1("%1/%2").arg(repoDir, i))) {
+ throw QInstaller::Error(QObject::tr("Could not create repository folder for "
+ "component %1").arg(i));
+ }
+
+ const QStringList files = dataDir.entryList(QDir::Files);
+ Q_FOREACH (const QString& file, files) {
+ QFile tmp(dataDir.absoluteFilePath(file));
+ openForRead(&tmp, tmp.fileName());
+
+ const QString target = QString::fromLatin1("%1/%2/%4%3").arg(repoDir, i, file,
+ info.version);
+ verbose() << QString::fromLatin1("Copying archive from %1 to %2").arg(tmp.fileName(),
+ target) << std::endl;
+ if (!tmp.copy(target)) {
+ throw QInstaller::Error(QObject::tr("Could not copy %1 to %2: %3")
+ .arg(tmp.fileName(), target, tmp.errorString()));
+ }
+ QFile archiveFile(target);
+ QString archiveHashFileName = archiveFile.fileName();
+ archiveHashFileName += QLatin1String(".sha1");
+ verbose() << "Hash is stored in "<< archiveHashFileName << std::endl;
+ QFile archiveHashFile(archiveHashFileName);
+ try {
+ openForRead(&archiveFile, archiveFile.fileName());
+ openForWrite(&archiveHashFile, archiveHashFile.fileName());
+ const QByteArray archiveData = archiveFile.readAll();
+ archiveFile.close();
+ const QByteArray hashOfArchiveData = QCryptographicHash::hash(archiveData,
+ QCryptographicHash::Sha1).toHex();
+ archiveHashFile.write(hashOfArchiveData);
+ archiveHashFile.close();
+
+ } catch(const Error& /*e*/) {
+ //verbose() << e.message() << std::endl;
+ archiveHashFile.close();
+ archiveFile.close();
+ throw;
+ }
+ }
+
+ const QStringList dirs = dataDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
+ Q_FOREACH (const QString& dir, dirs) {
+ verbose() << "Compressing data directory " << dir << std::endl;
+ const QString archiveName = QString::fromLatin1("%1/%2/%4%3.7z").arg(repoDir, i, dir,
+ info.version);
+ compressDirectory(dataDir.absoluteFilePath(dir), archiveName);
+ verbose() << "Creating hash of archive "<< archiveName << std::endl;
+ QFile archiveFile(archiveName);
+ QString archiveHashFileName = archiveFile.fileName();
+ archiveHashFileName += QLatin1String(".sha1");
+ verbose() << "Hash is stored in "<< archiveHashFileName << std::endl;
+ QFile archiveHashFile(archiveHashFileName);
+ try {
+ openForRead(&archiveFile, archiveFile.fileName());
+ openForWrite(&archiveHashFile, archiveHashFile.fileName());
+ const QByteArray archiveData = archiveFile.readAll();
+ archiveFile.close();
+ const QByteArray hashOfArchiveData = QCryptographicHash::hash(archiveData,
+ QCryptographicHash::Sha1).toHex();
+ archiveHashFile.write(hashOfArchiveData);
+ archiveHashFile.close();
+ } catch(const Error& /*e*/) {
+ //std::cerr << e.message() << std::endl;
+ archiveHashFile.close();
+ archiveFile.close();
+ throw;
+ }
+ }
+
+ // if we have a private key, sign all target files - including those we compressed ourself
+ if (!settings.privateKey().isEmpty()) {
+ const QDir compDataDir(QString::fromLatin1("%1/%2").arg(repoDir, i));
+ const QStringList targetFiles = compDataDir.entryList(QDir::Files);
+ for (QStringList::const_iterator it = targetFiles.begin(); it != targetFiles.end(); ++it) {
+ verbose() << "Adding a RSA signature to " << *it << std::endl;
+ const QByteArray signature = crypto.sign(compDataDir.absoluteFilePath(*it));
+ QFile sigFile(compDataDir.absoluteFilePath(*it) + QLatin1String(".sig"));
+ if (!sigFile.open(QIODevice::WriteOnly)) {
+ throw QInstaller::Error(QObject::tr("Could not open %1 for writing: %2")
+ .arg(sigFile.fileName(), sigFile.errorString()));
+ }
+ sigFile.write(signature);
+ }
+ }
+ }
+}
diff --git a/installerbuilder/common/repositorygen.h b/installerbuilder/common/repositorygen.h
new file mode 100644
index 000000000..0c092ae6d
--- /dev/null
+++ b/installerbuilder/common/repositorygen.h
@@ -0,0 +1,53 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_REPOSITORYGEN_H
+#define QINSTALLER_REPOSITORYGEN_H
+
+#include <QString>
+#include <QStringList>
+
+template <typename T> class QVector;
+
+namespace QInstaller {
+ struct PackageInfo {
+ QString name;
+ QString version;
+ QString directory;
+ QStringList dependencies;
+ };
+
+
+ QMap<QString, QString> buildPathToVersionMap( const QVector<PackageInfo>& info );
+ void compressMetaDirectories( const QString& configDir, const QString& repoDir, const QString& baseDir, const QMap<QString, QString>& versionMapping );
+ void compressMetaDirectories( const QString& configDir, const QString& repoDir );
+ void compressDirectory( const QString& path, const QString& archivePath );
+ void copyComponentData( const QString& packageDir, const QString& configDir, const QString& repoDir, const QVector<PackageInfo>& infos );
+ void generateMetaDataDirectory( const QString& outDir, const QString& dataDir, const QVector<PackageInfo>& packages, const QString& appName, const QString& appVersion );
+ QVector<PackageInfo> createListOfPackages( const QStringList& components, const QString& packagesDirectory, bool addDependencies = true );
+ void generateMetaDataDirectory( const QString& outDir, const QString& dataDir, const QVector<PackageInfo>& packages, const QString& appName, const QString& appVersion );
+}
+
+#endif // QINSTALLER_REPOSITORYGEN_H
diff --git a/installerbuilder/common/utils.cpp b/installerbuilder/common/utils.cpp
new file mode 100644
index 000000000..31d92f6be
--- /dev/null
+++ b/installerbuilder/common/utils.cpp
@@ -0,0 +1,221 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "utils.h"
+
+#include <QByteArray>
+#include <QHash>
+#include <QIODevice>
+#include <QProcessEnvironment>
+#include <QtCore/QDateTime>
+#include <QString>
+#include <QUrl>
+#include <QFileInfo>
+#include <QDir>
+
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+static bool verb = false;
+
+void QInstaller::setVerbose( bool v ) {
+ verb = v;
+}
+
+bool QInstaller::isVerbose()
+{
+ return verb;
+}
+
+#ifdef Q_WS_WIN
+void qWinMsgHandler(QtMsgType t, const char* str);
+
+class debugstream : public std::ostream
+{
+ class buf : public std::stringbuf
+ {
+ public:
+ buf()
+ {
+ }
+ int sync()
+ {
+ std::string s = str();
+ if( s[ s.length() - 1 ] == '\n' )
+ s[ s.length() - 1 ] = '\0'; // remove \n
+ qWinMsgHandler( QtDebugMsg, s.c_str() );
+ std::cout << s << std::endl;
+ str( std::string() );
+ return 0;
+ }
+ };
+public:
+ debugstream()
+ : std::ostream( &b )
+ {
+ }
+private:
+ buf b;
+};
+#endif
+
+std::ostream& QInstaller::stdverbose()
+{
+ static std::fstream null;
+#ifdef Q_WS_WIN
+ // TODO: this one get leaked
+ static debugstream& stream = *(new debugstream);
+#else
+ static std::ostream& stream = std::cout;
+#endif
+ if( verb )
+ return stream;
+ else
+ return null;
+}
+
+std::ostream& QInstaller::operator<<( std::ostream& os, const QUrl& url )
+{
+ return os << "QUrl( " << url.toString() << ")";
+}
+
+std::ostream& QInstaller::operator<<( std::ostream& os, const QString& string )
+{
+ return os << qPrintable(string);
+}
+
+std::ostream& QInstaller::operator<<( std::ostream& os, const QByteArray& array )
+{
+ return os << '"' << QString::fromAscii( array ) << '"';
+}
+
+//TODO from kdupdaterfiledownloader.cpp, use that one once merged
+QByteArray QInstaller::calculateHash( QIODevice* device, QCryptographicHash::Algorithm algo ) {
+ Q_ASSERT( device );
+ QCryptographicHash hash( algo );
+ QByteArray buffer;
+ buffer.resize( 512 * 1024 );
+ while ( true ) {
+ const qint64 numRead = device->read( buffer.data(), buffer.size() );
+ if ( numRead <= 0 )
+ return hash.result();
+ hash.addData( buffer.constData(), numRead );
+ }
+ return QByteArray(); // never reached
+}
+
+
+QString QInstaller::replaceVariables(const QHash<QString,QString>& vars, const QString &str)
+{
+ QString res;
+ int pos = 0;
+ while (true) {
+ int pos1 = str.indexOf( QLatin1Char( '@' ), pos);
+ if (pos1 == -1)
+ break;
+ int pos2 = str.indexOf( QLatin1Char( '@' ), pos1 + 1);
+ if (pos2 == -1)
+ break;
+ res += str.mid(pos, pos1 - pos);
+ QString name = str.mid(pos1 + 1, pos2 - pos1 - 1);
+ res += vars.value(name);
+ pos = pos2 + 1;
+ }
+ res += str.mid(pos);
+ return res;
+}
+
+QString QInstaller::replaceWindowsEnvironmentVariables(const QString &str)
+{
+ const QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ QString res;
+ int pos = 0;
+ while (true) {
+ int pos1 = str.indexOf( QLatin1Char( '%' ), pos);
+ if (pos1 == -1)
+ break;
+ int pos2 = str.indexOf( QLatin1Char( '%' ), pos1 + 1);
+ if (pos2 == -1)
+ break;
+ res += str.mid(pos, pos1 - pos);
+ QString name = str.mid(pos1 + 1, pos2 - pos1 - 1);
+ res += env.value(name);
+ pos = pos2 + 1;
+ }
+ res += str.mid(pos);
+ return res;
+}
+
+QInstaller::VerboseWriter::VerboseWriter(QObject *parent) : QObject(parent)
+{
+ preFileBuffer.open(QIODevice::ReadWrite);
+ stream.setDevice(&preFileBuffer);
+}
+
+QInstaller::VerboseWriter::~VerboseWriter()
+{
+ stream.flush();
+ if (logFileName.isEmpty()) // binarycreator
+ return;
+ //if the installer installed nothing - there is no target directory - where the logfile can be saved
+ if (!QFileInfo(logFileName).absoluteDir().exists()) {
+ return;
+ }
+ QFile output(logFileName);
+ if (!output.open(QIODevice::ReadWrite | QIODevice::Append))
+ qFatal("Could not open logfile!");
+ QString logInfo;
+ logInfo += QLatin1String("*************************************");
+ logInfo += QString::fromLatin1("Invoked:") + QDateTime::currentDateTime().toString();
+ output.write(logInfo.toLocal8Bit());
+ output.write(preFileBuffer.data());
+ output.close();
+}
+
+void QInstaller::VerboseWriter::setOutputStream(const QString &fileName)
+{
+ logFileName = fileName;
+}
+
+
+Q_GLOBAL_STATIC(QInstaller::VerboseWriter, verboseWriter);
+
+QInstaller::VerboseWriter* QInstaller::VerboseWriter::instance()
+{
+ return verboseWriter();
+}
+
+QInstaller::VerboseWriter& QInstaller::verbose()
+{
+ return *verboseWriter();
+}
diff --git a/installerbuilder/common/utils.h b/installerbuilder/common/utils.h
new file mode 100644
index 000000000..6d43e602f
--- /dev/null
+++ b/installerbuilder/common/utils.h
@@ -0,0 +1,119 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_UTILS_H
+#define QINSTALLER_UTILS_H
+
+#include <QtCore/QCryptographicHash>
+#include <QtCore/QFile>
+#include <QtCore/QTextStream>
+#include <QtCore/QBuffer>
+#include <QtCore/QUrl>
+
+#include "installer_global.h"
+
+#include <ostream>
+
+class QByteArray;
+class QIODevice;
+class QString;
+class QUrl;
+
+template< typename T >
+class QList;
+
+template<typename K, typename V> class QHash;
+
+namespace QInstaller
+{
+ QByteArray INSTALLER_EXPORT calculateHash( QIODevice* device, QCryptographicHash::Algorithm algo );
+
+ QString INSTALLER_EXPORT replaceVariables( const QHash<QString,QString>& vars, const QString &str );
+ QString INSTALLER_EXPORT replaceWindowsEnvironmentVariables( const QString &str );
+
+ void INSTALLER_EXPORT setVerbose( bool v );
+ bool INSTALLER_EXPORT isVerbose();
+
+ INSTALLER_EXPORT std::ostream& stdverbose();
+
+
+ INSTALLER_EXPORT std::ostream& operator<<( std::ostream& os, const QUrl& url );
+ INSTALLER_EXPORT std::ostream& operator<<( std::ostream& os, const QString& string );
+ INSTALLER_EXPORT std::ostream& operator<<( std::ostream& os, const QByteArray& array );
+ template< typename T >
+ std::ostream& operator<<( std::ostream& os, const QList< T >& list )
+ {
+ os << "(";
+ for( typename QList< T >::const_iterator it = list.begin(); it != list.end(); ++it )
+ os << *it;
+ os << ");";
+ return os;
+ }
+
+ class VerboseWriter;
+ INSTALLER_EXPORT VerboseWriter& verbose();
+
+ class INSTALLER_EXPORT VerboseWriter : public QObject
+ {
+ Q_OBJECT
+ public:
+ VerboseWriter(QObject* parent = 0);
+ ~VerboseWriter();
+
+ static VerboseWriter* instance();
+
+ inline VerboseWriter &operator<<(bool t) { stdverbose() << t; stream << (t ? "true" : "false"); return *this; }
+ inline VerboseWriter &operator<<(int t) { stdverbose() << t; stream << t; return *this; }
+ inline VerboseWriter &operator<<(qint64 t) { stdverbose() << t; stream << t; return *this; }
+ inline VerboseWriter &operator<<(quint64 t) { stdverbose() << t; stream << t; return *this; }
+ inline VerboseWriter &operator<<(double t) { stdverbose() << t; stream << t; return *this; }
+ inline VerboseWriter &operator<<(std::string &t) { stdverbose() << t; stream << QString::fromStdString(t); return *this; }
+ inline VerboseWriter &operator<<(const QByteArray &t) { stdverbose() << t; stream << t; return *this; }
+ inline VerboseWriter &operator<<(const QString &t) { stdverbose() << t; stream << t; return *this; }
+ inline VerboseWriter &operator<<(const QLatin1String &t) { stdverbose() << t; stream << t; return *this; }
+ inline VerboseWriter &operator<<(const char *t) { stdverbose() << t; stream << t; return *this; }
+ inline VerboseWriter &operator<<(const QUrl &t) { return verbose() << t.toString(); }
+ template< typename T >
+ VerboseWriter& operator<<(const QList< T >& list )
+ {
+ verbose() << "List ( ";
+ for( typename QList< T >::const_iterator it = list.begin(); it != list.end(); ++it )
+ verbose() << *it <<"; ";
+ return verbose() << ");";
+ }
+
+ inline VerboseWriter &operator<<(std::ostream& (*f)(std::ostream &s)) { stdverbose() << *f; stream << "\n"; return *this; }
+ public slots:
+ void setOutputStream(const QString &fileName);
+
+ private:
+ QTextStream stream;
+ QBuffer preFileBuffer;
+ QString logFileName;
+ };
+
+}
+
+#endif // QINSTALLER_UTILS_H
diff --git a/installerbuilder/common/zipjob.cpp b/installerbuilder/common/zipjob.cpp
new file mode 100644
index 000000000..0b3018279
--- /dev/null
+++ b/installerbuilder/common/zipjob.cpp
@@ -0,0 +1,216 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <common/zipjob.h>
+
+#include <QDebug>
+#include <QDir>
+#include <QStringList>
+#include <QMetaType>
+
+#include <cassert>
+#include <climits>
+
+class ZipJob::Private {
+ ZipJob* const q;
+public:
+ explicit Private( ZipJob* qq ) :
+ q( qq ),
+ outputDevice( 0 ),
+ process( 0 )
+ {
+ }
+
+ QIODevice* outputDevice;
+ QDir workingDir;
+ QProcess* process;
+ QStringList filesToArchive;
+};
+
+Q_DECLARE_METATYPE( QProcess::ExitStatus );
+
+ZipJob::ZipJob()
+ : QObject(),
+ QRunnable(),
+ d( new Private( this ) )
+{
+ qRegisterMetaType< QProcess::ExitStatus >();
+}
+
+ZipJob::~ZipJob() {
+ delete d;
+}
+
+void ZipJob::run() {
+ assert( !d->process );
+ d->process = new QProcess;
+ d->process->setWorkingDirectory( d->workingDir.absolutePath() );
+ QStringList args;
+ args << QLatin1String( "-" ) << QLatin1String( "-r" ) << d->filesToArchive;
+ connect( d->process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)) );
+ connect( d->process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)) );
+ connect( d->process, SIGNAL(readyReadStandardOutput()), this, SLOT(processReadyReadStandardOutput()) );
+
+ d->process->start( QLatin1String( "zip" ), args );
+ if ( !d->process->waitForStarted() ) {
+ //TODO handle
+ }
+
+ if ( !d->process->waitForFinished( INT_MAX ) ) {
+ //TODO handle
+ }
+
+ delete d->process;
+ d->process = 0;
+ // emit result
+}
+
+void ZipJob::processError( QProcess::ProcessError ) {
+ emit error();
+}
+
+void ZipJob::processFinished( int, QProcess::ExitStatus ) {
+ emit finished();
+}
+
+void ZipJob::processReadyReadStandardOutput() {
+ const QByteArray buf = d->process->readAll();
+ const qint64 toWrite = buf.size();
+ qint64 written = 0;
+ while ( written < toWrite ) {
+ const qint64 num = d->outputDevice->write( buf.constData() + written, toWrite - written );
+ if ( num < 0 ) {
+ //TODO: handle error
+ return;
+ }
+ written += num;
+ }
+}
+
+void ZipJob::setOutputDevice( QIODevice* device )
+{
+ d->outputDevice = device;
+}
+
+void ZipJob::setWorkingDirectory( const QDir& dir ) {
+ d->workingDir = dir;
+}
+
+void ZipJob::setFilesToArchive( const QStringList& files ) {
+ d->filesToArchive = files;
+}
+
+class UnzipJob::Private {
+ UnzipJob* const q;
+public:
+ explicit Private( UnzipJob* qq )
+ : q( qq ),
+ inputDevice( 0 )
+ {
+ }
+
+public:
+ QIODevice* inputDevice;
+ QString outputPath;
+ QStringList filesToExtract;
+};
+
+UnzipJob::UnzipJob()
+ : QObject(),
+ QRunnable(),
+ d( new Private( this ) )
+{
+ qRegisterMetaType< QProcess::ExitStatus >();
+}
+
+UnzipJob::~UnzipJob() {
+ delete d;
+}
+
+void UnzipJob::setInputDevice( QIODevice* device )
+{
+ d->inputDevice = device;
+}
+
+void UnzipJob::setOutputPath( const QString& path )
+{
+ d->outputPath = path;
+}
+
+void UnzipJob::processError( QProcess::ProcessError )
+{
+ emit error();
+}
+
+void UnzipJob::run()
+{
+ QProcess process;
+ // TODO: this won't work on Windows... grmpfl, but on Mac and Linux, at least...
+ QStringList args;
+ args << QLatin1String( "/dev/stdin" );
+ if( !d->filesToExtract.isEmpty() )
+ args << QLatin1String( "-x" ) << d->filesToExtract;
+ process.setWorkingDirectory( d->outputPath );
+ process.start( QLatin1String( "unzip" ), args );
+ connect( &process, SIGNAL( error( QProcess::ProcessError ) ), this, SLOT( processError( QProcess::ProcessError ) ) );
+ connect( &process, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( processFinished( int, QProcess::ExitStatus ) ) );
+ if( !process.waitForStarted() )
+ {
+ // TODO handle
+ return;
+ }
+
+ const int bufferSize = 4096;
+ QByteArray buffer;
+ while( d->inputDevice->bytesAvailable() > 0 || d->inputDevice->waitForReadyRead( INT_MAX ) )
+ {
+ buffer = d->inputDevice->read( bufferSize );
+ process.write( buffer );
+ process.waitForBytesWritten( INT_MAX );
+ }
+ process.closeWriteChannel();
+
+ if( !process.waitForFinished( INT_MAX ) )
+ {
+ // TODO handle
+ }
+}
+
+void UnzipJob::processFinished( int, QProcess::ExitStatus )
+{
+ emit finished();
+}
+
+void UnzipJob::setFilesToExtract( const QStringList& files )
+{
+ d->filesToExtract = files;
+}
diff --git a/installerbuilder/common/zipjob.h b/installerbuilder/common/zipjob.h
new file mode 100644
index 000000000..8107482d6
--- /dev/null
+++ b/installerbuilder/common/zipjob.h
@@ -0,0 +1,87 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef ZIPJOB_H
+#define ZIPJOB_H
+
+#include <QProcess>
+#include <QRunnable>
+
+class QDir;
+class QIODevice;
+class QStringList;
+
+class ZipJob : public QObject, public QRunnable {
+ Q_OBJECT
+public:
+ ZipJob();
+ ~ZipJob();
+
+ void setOutputDevice( QIODevice* device );
+ void setWorkingDirectory( const QDir& dir );
+ void setFilesToArchive( const QStringList& files );
+
+ /* reimp */ void run();
+
+Q_SIGNALS:
+ void finished();
+ void error();
+
+private Q_SLOTS:
+ void processError( QProcess::ProcessError );
+ void processFinished( int, QProcess::ExitStatus );
+ void processReadyReadStandardOutput();
+
+private:
+ class Private;
+ Private* const d;
+};
+
+class UnzipJob : public QObject, public QRunnable {
+ Q_OBJECT
+public:
+ UnzipJob();
+ ~UnzipJob();
+
+ void setInputDevice( QIODevice* device );
+ void setOutputPath( const QString& path );
+ void setFilesToExtract( const QStringList& files );
+
+ /* reimp */ void run();
+
+Q_SIGNALS:
+ void finished();
+ void error();
+
+private Q_SLOTS:
+ void processError( QProcess::ProcessError );
+ void processFinished( int, QProcess::ExitStatus );
+
+private:
+ class Private;
+ Private* const d;
+};
+
+#endif // ZIPJOB_H
diff --git a/installerbuilder/create-test-installer.bat b/installerbuilder/create-test-installer.bat
new file mode 100644
index 000000000..0140e891f
--- /dev/null
+++ b/installerbuilder/create-test-installer.bat
@@ -0,0 +1 @@
+bin\binarycreator -t bin\installerbase.exe -v -p ..\examples\packages -c ..\examples\config --offline-only test-installer.exe com.nokia.sdk
diff --git a/installerbuilder/create-test-installer.sh b/installerbuilder/create-test-installer.sh
new file mode 100644
index 000000000..b2a6229f5
--- /dev/null
+++ b/installerbuilder/create-test-installer.sh
@@ -0,0 +1 @@
+./bin/binarycreator -t bin/installerbase -v -p ../examples/packages -c ../examples/config test-installer -e com.nokia.sdk.installerbase --offline-only com.nokia.sdk
diff --git a/installerbuilder/installerbase/installerbase.cpp b/installerbuilder/installerbase/installerbase.cpp
new file mode 100644
index 000000000..e30a6c097
--- /dev/null
+++ b/installerbuilder/installerbase/installerbase.cpp
@@ -0,0 +1,372 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+
+// This file contains the base part of the installer.
+// It lists the files and features the installer should handle.
+
+#include "qinstaller.h"
+#include "qinstallercomponentmodel.h"
+#include "qinstallercomponent.h"
+#include "qinstallergui.h"
+#include "qinstallerglobal.h"
+#include "init.h"
+#include "lib7z_facade.h"
+#include "common/installersettings.h"
+#include "common/fileutils.h"
+#include "common/utils.h"
+#include "fsengineserver.h"
+#include "updater.h"
+
+#include <QtCore/QBuffer>
+#include <QtCore/QDir>
+#include <QtCore/QDirIterator>
+#include <QtCore/QFileInfo>
+#include <QtCore/QResource>
+#include <QtCore/QObject>
+#include <QtCore/QSharedPointer>
+#include <QtCore/QTimer>
+#include <QtCore/QTranslator>
+#include <QtCore/QUrl>
+#include <QtCore/QPointer>
+#include <QtCore/QSettings>
+#include <QtCore/QThread>
+
+#include <QtGui/QApplication>
+#include <QtGui/QTabWidget>
+#include <QtGui/QLabel>
+#include <QtGui/QMessageBox>
+#include <QtGui/QVBoxLayout>
+
+#include <QtNetwork/QNetworkProxyFactory>
+
+#include <KDToolsCore/KDSelfRestarter>
+#include <KDToolsCore/KDRunOnceChecker>
+
+#include <KDUpdater/Application>
+#include <KDUpdater/UpdateSourcesInfo>
+#include <KDUpdater/PackagesInfo>
+#include <KDUpdater/Update>
+#include <KDUpdater/UpdateFinder>
+#include <KDUpdater/UpdateOperationFactory>
+
+#include <KDUpdater/UpdateOperation>
+
+// QInstallerGui is base of the Gui part of an installer, i.e.
+// the "main installer wizard". In the simplest case it's just
+// a sequence of "standard" wizard pages. A few commonly used
+// ones are provided already in qinstallergui.h.
+
+#include "common/binaryformat.h"
+#include "common/binaryformatenginehandler.h"
+#include "common/errors.h"
+#include "common/range.h"
+
+#include <iostream>
+#include <memory>
+
+#include "installerbasecommons.h"
+#include "maintabwidget.h"
+#include "tabcontroller.h"
+
+using namespace QInstaller;
+using namespace QInstallerCreator;
+
+class Sleep : public QThread
+{
+public:
+ static void sleep(unsigned long ms)
+ {
+ QThread::usleep(ms);
+ }
+};
+
+static void printUsage(bool isInstaller, const QString &productName,
+ const QString &installerBinaryPath)
+{
+ QString str;
+ if (isInstaller) {
+ str = QString::fromLatin1(" [--script <scriptfile>] [<name>=<value>...]\n"
+ "\n Runs the %1 installer\n"
+ "\n --script runs the the installer non-interactively, without UI, using the "
+ "script <scriptfile> to perform the installation.\n").arg(productName);
+ } else {
+ str = QString::fromLatin1(" [<name>=<value>...]\n\n Runs the %1 uninstaller.\n")
+ .arg(productName);
+ }
+ str = QLatin1String("\nUsage: ") + installerBinaryPath + str;
+ std::cerr << qPrintable(str) << std::endl;
+}
+
+int main(int argc, char *argv[])
+{
+ qsrand(QDateTime::currentDateTime().toTime_t());
+ const KDSelfRestarter restarter(argc, argv);
+ KDRunOnceChecker runCheck(QLatin1String("lockmyApp1234865.lock"));
+
+ try {
+
+ {
+ QCoreApplication app(argc, argv);
+ const QStringList args = app.arguments();
+
+ // this isthe FSEngineServer as an admin rights process upon request:
+ if (args.count() >= 3 && args[1] == QLatin1String("--startserver")) {
+#ifdef FSENGINE_TCP
+ FSEngineServer* const server = new FSEngineServer(args[2].toInt());
+#else
+ FSEngineServer* const server = new FSEngineServer(args[2]);
+#endif
+ if (args.count() >= 4)
+ server->setAuthorizationKey(args[3]);
+ QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()));
+ return app.exec();
+ }
+
+ if (args.contains(QLatin1String("--proxy")))
+ QNetworkProxyFactory::setUseSystemConfiguration(true);
+
+ if (args.contains(QLatin1String("--checkupdates"))) {
+ if (runCheck.isRunning(KDRunOnceChecker::ProcessList))
+ return 0;
+
+ QInstaller::setVerbose(args.contains(QLatin1String("--verbose")));
+ QInstaller::init();
+ // load the embedded binary resource
+ BinaryContent content = BinaryContent::readFromApplicationFile();
+ content.registerEmbeddedQResources();
+ Updater u;
+ return u.checkForUpdates(true) ? 0 : 1;
+ }
+ }
+
+ QApplication app(argc, argv);
+ if (runCheck.isRunning(KDRunOnceChecker::ProcessList)) {
+ if (runCheck.isRunning(KDRunOnceChecker::Lockfile))
+ return 0;
+
+ while (runCheck.isRunning(KDRunOnceChecker::ProcessList))
+ Sleep::sleep(1);
+ }
+
+ const QStringList args = app.arguments();
+
+ // from here, the "normal" installer binary is running
+ if (args.contains(QLatin1String("--verbose")) || args.contains(QLatin1String("Verbose")))
+ QInstaller::setVerbose(true);
+
+ verbose() << "This is installerbase version " << INSTALLERBASE_VERSION << std::endl;
+ verbose() << "ARGS: " << args << std::endl;
+
+ // install the default translator
+ const QString localeFile =
+ QString::fromLatin1(":/translations/qt_%1").arg(QLocale::system().name());
+ {
+ QTranslator* const translator = new QTranslator(&app);
+ translator->load(localeFile);
+ app.installTranslator(translator);
+ }
+
+ // install "our" default translator
+ const QString ourLocaleFile =
+ QString::fromLatin1(":/translations/%1.qm").arg(QLocale().name().toLower());
+ if (QFile::exists(ourLocaleFile))
+ {
+ QTranslator* const translator = new QTranslator(&app);
+ translator->load(ourLocaleFile);
+ app.installTranslator(translator);
+ }
+
+ verbose() << "resource tree before loading the in-binary resource: " << std::endl;
+
+ QDir dir(QLatin1String(":/"));
+ Q_FOREACH (const QString &i, dir.entryList()) {
+ const QByteArray ba = i.toUtf8();
+ verbose() << ba.constData() << std::endl;
+ }
+
+ // register custom operations before reading the binary content cause they may used in
+ // the uninstaller for the recorded list of during the installation performed operations.
+ QInstaller::init();
+
+ // load the embedded binary resource
+ BinaryContent content = BinaryContent::readFromApplicationFile();
+ content.registerEmbeddedQResources();
+
+ verbose() << "resource tree after loading the in-binary resource: " << std::endl;
+
+ dir = QDir(QLatin1String(":/"));
+ Q_FOREACH (const QString &i, dir.entryList())
+ verbose() << QString::fromLatin1(":/%1").arg(i) << std::endl;
+
+ dir = QDir(QLatin1String(":/metadata/"));
+ Q_FOREACH (const QString &i, dir.entryList())
+ verbose() << QString::fromLatin1(":/metadata/%1").arg(i) << std::endl;
+
+ KDUpdater::Application updaterapp;
+ QInstaller::Installer installer(content.magicmaker, content.performedOperations);
+ installer.setUpdaterApplication(&updaterapp);
+
+ const QString productName = installer.value(QLatin1String("ProductName"));
+
+ QString controlScript;
+ bool isUpdater = false;
+ QHash<QString, QString> params;
+ for (int i = 1; i < args.size(); ++i) {
+ const QString &argument = args.at(i);
+ if (argument.isEmpty())
+ continue;
+
+ if (argument.contains(QLatin1Char('='))) {
+ const QString name = argument.section(QLatin1Char('='), 0, 0);
+ const QString value = argument.section(QLatin1Char('='), 1, 1);
+ params.insert(name, value);
+ installer.setValue(name, value);
+ } else if (argument == QLatin1String("--script") || argument == QLatin1String("Script")) {
+ ++i;
+ if (i < args.size()) {
+ controlScript = args.at(i);
+ if (!QFileInfo(controlScript).exists())
+ return INST_FAILED;
+ } else {
+ return INST_FAILED;
+ }
+ } else if (argument == QLatin1String("--verbose") || argument == QLatin1String("Verbose")) {
+ installer.setVerbose(true);
+ } else if (argument == QLatin1String("--proxy")) {
+ QNetworkProxyFactory::setUseSystemConfiguration(true);
+ } else if (argument == QLatin1String("--show-virtual-components")
+ || argument == QLatin1String("ShowVirtualComponents")) {
+ QInstaller::ComponentModel::setVirtualComponentsVisible(true);
+ QFont f;
+ f.setItalic(true);
+ QInstaller::ComponentModel::setVirtualComponentsFont(f);
+ } else if (argument == QLatin1String("--manage-packages")
+ || argument == QLatin1String("ManagePackages")) {
+ installer.setPackageManager();
+ } else if (argument == QLatin1String("--updater") || argument == QLatin1String("Updater")) {
+ isUpdater = true && !installer.isInstaller();
+ } else if (argument == QLatin1String("--help") || argument == QLatin1String("-h")) {
+ return INST_SUCCESS;
+ } else if (argument == QLatin1String("--addTempRepository")
+ || argument == QLatin1String("--setTempRepository")) {
+ ++i;
+ if (i >= args.size()) {
+ std::cerr << "No repository specified" << std::endl;
+ return INST_FAILED;
+ }
+
+ QList<Repository> repoList;
+ QStringList items = args.at(i).split(QLatin1Char(','));
+ foreach(const QString &item, items) {
+ verbose() << "Adding custom repository:" << item << std::endl;
+ Repository rep;
+ rep.setUrl(item);
+ rep.setRequired(true);
+ repoList.append(rep);
+ }
+
+ // We cannot use setRemoteRepositories as that is a synchronous call which "
+ // tries to get the data from server and this isn't what we want at this point
+ const bool replace = (argument == QLatin1String("--setTempRepository"));
+ installer.setTemporaryRepositories(repoList, replace);
+ } else {
+ std::cerr << "Unknown option: " << argument << std::endl;
+ return INST_FAILED;
+ }
+ }
+
+ if (!installer.isInstaller())
+ installer.setPackageManager();
+
+ updaterapp.packagesInfo()->setApplicationName(productName);
+ updaterapp.packagesInfo()->setApplicationVersion(installer
+ .value(QLatin1String("ProductVersion")));
+ updaterapp.addUpdateSource(productName, productName, QString(),
+ QUrl(QLatin1String("resource://metadata/")), 0);
+
+ // Create the wizard gui
+ TabController controller(0);
+ controller.setInstaller(&installer);
+ controller.setInstallerParams(params);
+ controller.setApplication(&updaterapp);
+ controller.setControlScript(controlScript);
+
+ if (installer.isInstaller()) {
+ controller.setInstallerGui(new QtInstallerGui(&installer));
+ } else {
+ controller.setTabWidget(new MainTabWidget());
+ controller.setInstallerGui(new QtUninstallerGui(&installer));
+ }
+
+ int val = isUpdater ? controller.initUpdater() : controller.initPackageManager();
+ if (val != TabController::SUCCESS)
+ return val;
+
+ const int result = app.exec();
+ if (result != 0)
+ return result;
+
+ if (installer.finishedWithSuccess())
+ return INST_SUCCESS;
+
+ const int status = installer.status();
+ const TabController::Status controllerState = controller.getState();
+
+ Q_ASSERT(status == Installer::InstallerFailed || status == Installer::InstallerSucceeded
+ || status == Installer::InstallerCanceledByUser);
+
+ if (controllerState == TabController::SUCCESS)
+ return INST_SUCCESS;
+
+ switch (status) {
+ case Installer::InstallerSucceeded:
+ return INST_SUCCESS;
+
+ case Installer::InstallerCanceledByUser:
+ return INST_CANCELED;
+
+ case Installer::InstallerFailed:
+ default:
+ break;
+ }
+ return INST_FAILED;
+ } catch(const Error &e) {
+ std::cerr << qPrintable(e.message()) << std::endl;
+ } catch (const std::exception &e) {
+ std::cerr << e.what() << std::endl;
+ } catch(...) {
+ std::cerr << "Unknown error, aborting." << std::endl;
+ }
+
+ return INST_FAILED;
+}
diff --git a/installerbuilder/installerbase/installerbase.exe.manifest b/installerbuilder/installerbase/installerbase.exe.manifest
new file mode 100644
index 000000000..f90824fd0
--- /dev/null
+++ b/installerbuilder/installerbase/installerbase.exe.manifest
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
+ manifestVersion="1.0">
+ <!-- Make sure Vista UAC does not believe installerbase is an installer -->
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel
+ level="asInvoker"
+ uiAccess="false"/>
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+</assembly>
diff --git a/installerbuilder/installerbase/installerbase.ico b/installerbuilder/installerbase/installerbase.ico
new file mode 100644
index 000000000..79bd163de
--- /dev/null
+++ b/installerbuilder/installerbase/installerbase.ico
Binary files differ
diff --git a/installerbuilder/installerbase/installerbase.pro b/installerbuilder/installerbase/installerbase.pro
new file mode 100644
index 000000000..73c74d474
--- /dev/null
+++ b/installerbuilder/installerbase/installerbase.pro
@@ -0,0 +1,41 @@
+TEMPLATE = app
+TARGET = installerbase
+
+DEPENDPATH += . ..
+INCLUDEPATH += . ..
+
+DEFINES += QT_NO_CAST_FROM_ASCII
+
+win32:RC_FILE = installerbase.rc
+
+DESTDIR = ../bin
+
+CONFIG += help
+QTPLUGIN += qsqlite
+
+CONFIG -= app_bundle
+
+include(../libinstaller/libinstaller.pri)
+
+QT += network
+
+HEADERS += tabcontroller.h \
+ installerbasecommons.h \
+ maintabwidget.h
+
+SOURCES = installerbase.cpp \
+ tabcontroller.cpp \
+ installerbasecommons.cpp \
+ maintabwidget.cpp
+
+RESOURCES += installerbase.qrc
+
+win32-msvc2005 {
+ CONFIG += embed_manifest_exe #msvc2008 is doing this automaticaly
+}
+
+embed_manifest_exe:win32-msvc2005 {
+ # The default configuration embed_manifest_exe overrides the manifest file
+ # already embedded via RC_FILE. Vs2008 already have the necessary manifest entry
+ QMAKE_POST_LINK += $$quote(mt.exe -updateresource:$$DESTDIR/$${TARGET}.exe -manifest \"$${PWD}\\$${TARGET}.exe.manifest\")
+}
diff --git a/installerbuilder/installerbase/installerbase.qrc b/installerbuilder/installerbase/installerbase.qrc
new file mode 100644
index 000000000..cc04e0f06
--- /dev/null
+++ b/installerbuilder/installerbase/installerbase.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+
+</qresource>
+</RCC>
diff --git a/installerbuilder/installerbase/installerbase.rc b/installerbuilder/installerbase/installerbase.rc
new file mode 100644
index 000000000..c423d3360
--- /dev/null
+++ b/installerbuilder/installerbase/installerbase.rc
@@ -0,0 +1,7 @@
+IDI_ICON1 ICON DISCARDABLE
+"installerbase.ico"
+
+#define RT_MANIFEST 24
+#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
+
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "installerbase.exe.manifest"
diff --git a/installerbuilder/installerbase/installerbasecommons.cpp b/installerbuilder/installerbase/installerbasecommons.cpp
new file mode 100644
index 000000000..80a95075e
--- /dev/null
+++ b/installerbuilder/installerbase/installerbasecommons.cpp
@@ -0,0 +1,232 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "installerbasecommons.h"
+
+#include <qinstaller.h>
+#include <qinstallergui.h>
+#include <QFileInfo>
+#include <QLabel>
+#include <QDir>
+#include <QTimer>
+#include <QVBoxLayout>
+
+#include <qinstallercomponent.h>
+
+#include "installerbasecommons.h"
+
+TargetDirectoryPageImpl::TargetDirectoryPageImpl(QInstaller::Installer *installer)
+ : QInstaller::TargetDirectoryPage(installer)
+{
+ QPalette palette;
+ palette.setColor(QPalette::WindowText, Qt::red);
+
+ m_warningLabel = new QLabel(this);
+ m_warningLabel->setPalette(palette);
+
+ insertWidget(m_warningLabel, QLatin1String( "MessageLabel" ), 2);
+}
+
+QString TargetDirectoryPageImpl::targetDirWarning() const {
+ const QString td = targetDir();
+ if ( td.contains( QLatin1Char( ' ' ) ) )
+ return TargetDirectoryPageImpl::tr("The installation path must not contain any space.");
+ const QFileInfo targetDirInfo = QFileInfo( td );
+// if ( targetDirInfo.isDir() && !targetDirInfo.isWritable() )
+// return TargetDirectoryPageImpl::tr("Cannot write to folder %1.").arg( td );
+ const QString parentDir = QFileInfo( td ).dir().absolutePath();
+// if ( !targetDirInfo.exists() && !QFileInfo( parentDir ).isWritable() )
+// return TargetDirectoryPageImpl::tr("Cannot write to folder %1.").arg( parentDir );
+ return QString();
+}
+
+bool TargetDirectoryPageImpl::isComplete() const
+{
+ const QString warning = targetDirWarning();
+ m_warningLabel->setText(warning);
+
+ return warning.isEmpty();
+}
+
+bool TargetDirectoryPageImpl::askQuestion( const QString& identifier, const QString& message ) {
+ QMessageBox::StandardButton bt = MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ identifier,
+ TargetDirectoryPageImpl::tr("Warning"),
+ message,
+ QMessageBox::Yes | QMessageBox::No);
+ QTimer::singleShot( 100, wizard()->page( nextId() ), SLOT( repaint() ) );
+ return bt == QMessageBox::Yes;
+}
+
+bool TargetDirectoryPageImpl::failWithWarning( const QString& identifier, const QString& message ) {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ identifier,
+ TargetDirectoryPageImpl::tr("Warning"),
+ message);
+ QTimer::singleShot( 100, wizard()->page( nextId() ), SLOT( repaint() ) );
+ return false;
+}
+
+bool TargetDirectoryPageImpl::validatePage()
+{
+ if ( !isVisible() )
+ return true;
+
+ const QFileInfo targetDirInfo = QFileInfo(targetDir());
+ const QDir dir( targetDir() );
+ if (targetDirInfo.isDir()) {
+ QFileInfo fi2(targetDir() + QDir::separator() + installer()->uninstallerName());
+ if ( dir == QDir::root() )
+ {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("forbiddenTargetDirectory"),
+ tr( "Error" ),
+ tr( "As the install directory is completely deleted installing in %1 is forbidden" ).arg( QDir::rootPath() ),
+ QMessageBox::Ok);
+ return false;
+ }
+ if (fi2.exists())
+ return askQuestion( QLatin1String("overwriteTargetDirectory"), TargetDirectoryPageImpl::tr("The folder you selected exists already and "
+ "contains an installation.\nDo you want to overwrite it?") );
+ else
+ return askQuestion( QLatin1String("overwriteTargetDirectory"),
+ tr( "You have selected an existing, non-empty folder for installation.\n"
+ "Note that it will be completely wiped on uninstallation of this application.\n"
+ "It is not advisable to install into this folder as installation might fail.\n"
+ "Do you want to continue?" ) );
+ }
+ return true;
+}
+
+QtInstallerGui::QtInstallerGui(QInstaller::Installer *installer)
+ : QInstaller::Gui(installer, 0)
+{
+ //addPage(new QInstaller::TargetDirectoryPage(installer));
+ setPage( QInstaller::Installer::TargetDirectory, new TargetDirectoryPageImpl( installer ) );
+ setPage( QInstaller::Installer::ComponentSelection, new QInstaller::ComponentSelectionPage( m_installer ) );
+ setPage( QInstaller::Installer::LicenseCheck, new QInstaller::LicenseAgreementPage( installer ) );
+#ifdef Q_OS_WIN
+ setPage( QInstaller::Installer::StartMenuSelection, new QInstaller::StartMenuDirectoryPage( installer ) );
+#endif
+ setPage( QInstaller::Installer::ReadyForInstallation, new QInstaller::ReadyForInstallationPage( installer ) );
+ setPage( QInstaller::Installer::PerformInstallation, new QInstaller::PerformInstallationPage( installer ) );
+ setPage( QInstaller::Installer::InstallationFinished, new QInstaller::FinishedPage( installer ) );
+
+ bool ok = false;
+ const int startPage = installer->value( QLatin1String( "GuiStartPage" ) ).toInt( &ok );
+ if( ok )
+ setStartId( startPage );
+}
+
+void QtInstallerGui::init()
+{
+ if( m_installer->components( true ).count() == 1 )
+ {
+ wizardPageVisibilityChangeRequested( false, QInstaller::Installer::ComponentSelection );
+ Q_ASSERT( ! m_installer->components().isEmpty() );
+ m_installer->components().first()->setSelected( true );
+ }
+}
+
+// -- QtUninstallerGui
+
+QtUninstallerGui::QtUninstallerGui(QInstaller::Installer *installer)
+ : QInstaller::Gui(installer, 0)
+{
+ setPage(QInstaller::Installer::ComponentSelection,
+ new QInstaller::ComponentSelectionPage(m_installer));
+ setPage(QInstaller::Installer::LicenseCheck, new QInstaller::LicenseAgreementPage(installer));
+ setPage(QInstaller::Installer::ReadyForInstallation,
+ new QInstaller::ReadyForInstallationPage(installer));
+ setPage(QInstaller::Installer::PerformInstallation,
+ new QInstaller::PerformInstallationPage(installer));
+ setPage(QInstaller::Installer::InstallationFinished, new QInstaller::FinishedPage(installer));
+
+ if (installer->isPackageManager()) {
+ RestartPage* p = new QInstaller::RestartPage(installer);
+ connect(p, SIGNAL(restart()), this, SIGNAL(gotRestarted()));
+ setPage(QInstaller::Installer::InstallationFinished + 1, p);
+ setPage(QInstaller::Installer::InstallationFinished + 2, new QInstaller::Page(installer));
+ }
+}
+
+void QtUninstallerGui::init()
+{
+ if(m_installer->components().isEmpty()) {
+ wizardPageVisibilityChangeRequested(false, QInstaller::Installer::ComponentSelection);
+ wizardPageVisibilityChangeRequested(false, QInstaller::Installer::LicenseCheck);
+ }
+}
+
+int QtUninstallerGui::nextId() const
+{
+ const int next = QWizard::nextId();
+ if (next == QInstaller::Installer::LicenseCheck) {
+ const int nextNextId = pageIds().value(pageIds().indexOf(next)+ 1, -1);
+ if (!m_installer->isPackageManager() && !m_installer->isUpdater())
+ return nextNextId;
+
+ QList<QInstaller::Component*> components = m_installer->componentsToInstall(true);
+ if (components.isEmpty())
+ return nextNextId;
+
+ bool foundLicense = false;
+ foreach (QInstaller::Component* component, components) {
+ if (component->isInstalled())
+ continue;
+ foundLicense |= !component->licenses().isEmpty();
+ }
+ return foundLicense ? next : nextNextId;
+ }
+ return next;
+}
+
+// -- GetMetaInfoProgressWidget
+
+GetMetaInfoProgressWidget::GetMetaInfoProgressWidget( QWidget* parent )
+ : QWidget( parent )
+{
+ QVBoxLayout* layout = new QVBoxLayout( this );
+ setLayout(layout);
+ m_label = new QLabel;
+ m_label->setWordWrap( true );
+ m_label->setText( tr("Retrieving information from remote installation sources...") );
+ layout->addWidget( m_label );
+}
+QString GetMetaInfoProgressWidget::text() const
+{
+ return m_label->text();
+}
+void GetMetaInfoProgressWidget::message( KDJob*, const QString& msg )
+{
+ m_label->setText( msg );
+}
diff --git a/installerbuilder/installerbase/installerbasecommons.h b/installerbuilder/installerbase/installerbasecommons.h
new file mode 100644
index 000000000..da0502515
--- /dev/null
+++ b/installerbuilder/installerbase/installerbasecommons.h
@@ -0,0 +1,123 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef INSTALLERBASECOMMONS_H
+#define INSTALLERBASECOMMONS_H
+
+#include <QObject>
+#include <qinstallergui.h>
+
+
+
+class QFileInfo;
+class QLabel;
+class QString;
+//class
+
+namespace QInstaller{
+ class Installer;
+}
+
+using namespace QInstaller;
+//using namespace QInstallerCreator;
+
+// A custom target directory selection based due to the no-space
+// restriction...
+
+class TargetDirectoryPageImpl : public QInstaller::TargetDirectoryPage
+{
+ Q_OBJECT
+public:
+ explicit TargetDirectoryPageImpl(QInstaller::Installer *installer);
+
+ QString targetDirWarning() const;
+
+ bool isComplete() const;
+
+ bool askQuestion( const QString& identifier, const QString& message );
+
+ bool failWithWarning( const QString& identifier, const QString& message );
+
+ bool validatePage();
+
+private:
+ QLabel *m_warningLabel;
+};
+
+////////////////////////////////////////////////////////////////////
+//
+// QtInstallerGui
+//
+////////////////////////////////////////////////////////////////////
+
+class QtInstallerGui : public QInstaller::Gui
+{
+ Q_OBJECT
+
+public:
+ explicit QtInstallerGui(QInstaller::Installer *installer);
+
+ virtual void init();
+};
+
+
+////////////////////////////////////////////////////////////////////
+//
+// QtUninstallerGui
+//
+////////////////////////////////////////////////////////////////////
+
+class QtUninstallerGui : public QInstaller::Gui
+{
+ Q_OBJECT
+
+public:
+ explicit QtUninstallerGui(QInstaller::Installer *installer);
+
+ virtual void init();
+ virtual int nextId() const;
+};
+
+class GetMetaInfoProgressWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit GetMetaInfoProgressWidget( QWidget* parent = 0 );
+ QString text() const;
+
+public Q_SLOTS:
+ void message(KDJob*, const QString & msg);
+
+private:
+ QLabel *m_label;
+};
+
+
+const int INST_SUCCESS = 0;
+const int INST_FAILED = 1;
+const int INST_CANCELED = 2;
+
+#endif // INSTALLERBASECOMMONS_H
diff --git a/installerbuilder/installerbase/maintabwidget.cpp b/installerbuilder/installerbase/maintabwidget.cpp
new file mode 100644
index 000000000..dd3ae0815
--- /dev/null
+++ b/installerbuilder/installerbase/maintabwidget.cpp
@@ -0,0 +1,71 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "maintabwidget.h"
+#include <QCloseEvent>
+
+class MainTabWidget::Private
+{
+public:
+ bool closeAllowed;
+};
+
+MainTabWidget::MainTabWidget( QWidget* parent )
+ : QTabWidget( parent ), d ( new Private () )
+{
+ d->closeAllowed = false;
+ setWindowFlags( windowFlags() | Qt::Dialog );
+}
+
+void MainTabWidget::setCloseWithoutWarning( bool value )
+{
+ d->closeAllowed = value;
+}
+
+MainTabWidget::~MainTabWidget()
+{
+}
+
+void MainTabWidget::closeEvent ( QCloseEvent * event )
+{
+ if ( d->closeAllowed )
+ {
+ QTabWidget::closeEvent( event );
+ //event->accept();
+ }
+ else
+ {
+ emit closeRequested();
+ event->ignore();
+ }
+}
+
diff --git a/installerbuilder/installerbase/maintabwidget.h b/installerbuilder/installerbase/maintabwidget.h
new file mode 100644
index 000000000..12c8301dc
--- /dev/null
+++ b/installerbuilder/installerbase/maintabwidget.h
@@ -0,0 +1,49 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef MAINTABWIDGET_H
+#define MAINTABWIDGET_H
+
+#include <QTabWidget>
+
+#include <KDToolsCore/pimpl_ptr>
+
+class MainTabWidget : public QTabWidget
+{
+Q_OBJECT
+public:
+ explicit MainTabWidget( QWidget* parent = 0 );
+ ~MainTabWidget(); //reimpl
+ void setCloseWithoutWarning( bool value );
+Q_SIGNALS:
+ void closeRequested();
+protected:
+ void closeEvent( QCloseEvent * event ); //reimpl
+private:
+ class Private;
+ kdtools::pimpl_ptr<Private> d;
+};
+
+#endif // MAINTABWIDGET_H
diff --git a/installerbuilder/installerbase/tabcontroller.cpp b/installerbuilder/installerbase/tabcontroller.cpp
new file mode 100644
index 000000000..cd62296a8
--- /dev/null
+++ b/installerbuilder/installerbase/tabcontroller.cpp
@@ -0,0 +1,538 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "tabcontroller.h"
+
+#include "installerbasecommons.h"
+#include "maintabwidget.h"
+
+#include <KDUpdater/Application>
+#include <KDUpdater/UpdateFinder>
+#include <KDUpdater/UpdateSourcesInfo>
+#include <KDUpdater/PackagesInfo>
+
+#include <common/installersettings.h>
+#include <common/utils.h>
+#include <common/errors.h>
+
+#include <componentselectiondialog.h>
+#include <getrepositoriesmetainfojob.h>
+#include <qinstaller.h>
+#include <qinstallercomponent.h>
+#include <updater.h>
+#include <qinstallergui.h>
+
+#include <QtCore/QDebug>
+#include <QtCore/QHash>
+#include <QtCore/QPointer>
+
+#include <QtGui/QDialog>
+#include <QtGui/QProgressDialog>
+
+#include <QtScript/QScriptEngine>
+
+#include <QtXml/QDomDocument>
+#include <QtXml/QDomElement>
+
+class TabController::Private
+{
+public:
+ Private();
+ ~Private();
+ void preselectInstalledPackages();
+
+ QHash<QString, QString> m_params;
+ bool m_updaterInitialized;
+ bool m_packageManagerInitialized;
+ bool m_init;
+ QPointer<QInstaller::Gui> m_gui;
+ QScopedPointer <Updater> m_updater;
+ MainTabWidget* m_updaterGuiWidget;
+ QInstaller::Installer *m_installer;
+ KDUpdater::Application *m_app;
+ QString m_controlScript;
+ int m_Tab_Pos_Updater;
+ int m_Tab_Pos_PackageManager;
+ TabController::Status m_state;
+ bool m_repoReached;
+ bool m_repoUpdateNeeded;
+};
+
+TabController::Private::Private()
+ :
+ m_updaterInitialized(false),
+ m_packageManagerInitialized(false),
+ m_init(false),
+ m_gui(0),
+ m_updater(0),
+ m_updaterGuiWidget(0),
+ m_installer(0),
+ m_app(0),
+ m_Tab_Pos_Updater(0),
+ m_Tab_Pos_PackageManager(0),
+ m_state(SUCCESS),
+ m_repoReached(true),
+ m_repoUpdateNeeded(true)
+{
+}
+
+TabController::Private::~Private()
+{
+ delete m_updaterGuiWidget;
+ delete m_gui;
+}
+
+// the package manager should preselect the currently installed packages
+void TabController::Private::preselectInstalledPackages()
+{
+ Q_ASSERT(m_installer->isPackageManager());
+
+ QList<QInstaller::Component*>::const_iterator it;
+ const QList<QInstaller::Component*> components = m_installer->components(true);
+ for (it = components.begin(); it != components.end(); ++it) {
+ QInstaller::Component* const comp = *it;
+ const bool selected = m_app->packagesInfo()->findPackageInfo(comp->name()) > -1;
+ comp->setSelected(selected, InstallerMode, Component::InitializeComponentTreeSelectMode);
+ comp->setEnabled(m_repoReached || selected);
+ }
+}
+
+// -- TabController
+
+TabController::TabController(QObject *parent)
+ : QObject(parent)
+ , d(new Private)
+{
+}
+
+TabController::~TabController()
+{
+ delete d;
+}
+
+void TabController::setCurrentTab(int tab)
+{
+ if (!d->m_updaterGuiWidget)
+ return;
+
+ d->m_updaterGuiWidget->setCurrentIndex((tab == PACKAGE_MANAGER_TAB)
+ ? d->m_Tab_Pos_PackageManager : d->m_Tab_Pos_Updater);
+ d->m_gui->callControlScriptMethod(QLatin1String((tab == PACKAGE_MANAGER_TAB)
+ ? "PackageManagerSelectedCallback" : "UpdaterSelectedCallback"));
+}
+
+void TabController::setInstallerParams(const QHash<QString, QString> &params)
+{
+ d->m_params = params;
+}
+
+void TabController::setInstallerGui(QInstaller::Gui *gui)
+{
+ d->m_gui = gui;
+ connect(d->m_gui, SIGNAL(gotRestarted()), this, SLOT(restartWizard()));
+}
+
+void TabController::setInstaller(QInstaller::Installer *installer)
+{
+ d->m_installer = installer;
+}
+
+void TabController::setTabWidget(MainTabWidget *widget)
+{
+ d->m_updaterGuiWidget = widget;
+}
+
+int TabController::initUpdater()
+{
+ init(UPDATER_TAB);
+
+ d->m_updaterGuiWidget->show();
+ d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_PackageManager, false);
+
+ if (d->m_repoUpdateNeeded) {
+ int result = checkRepositories();
+ if (result != INST_SUCCESS)
+ return result;
+ }
+
+ d->m_updaterInitialized = true;
+ d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_PackageManager, true);
+
+ return INST_SUCCESS;
+}
+
+void TabController::setApplication(KDUpdater::Application *app)
+{
+ d->m_app = app;
+}
+
+void TabController::setControlScript (const QString &script)
+{
+ d->m_controlScript = script;
+}
+
+void TabController::init(Tabs curTab)
+{
+ if (d->m_updaterGuiWidget && !d->m_init) {
+ d->m_updater.reset(new Updater);
+ d->m_updater->setInstaller(d->m_installer);
+
+ ComponentSelectionDialog* w = new ComponentSelectionDialog(d->m_installer);
+ d->m_updater->setUpdaterGui(w);
+ d->m_updater->init();
+ d->m_Tab_Pos_Updater = d->m_updaterGuiWidget->addTab(w, QLatin1String("Updater"));
+ d->m_Tab_Pos_PackageManager = d->m_updaterGuiWidget->addTab(d->m_gui,
+ QLatin1String("Package manager"));
+
+ if (d->m_updaterGuiWidget->widget(d->m_Tab_Pos_Updater)->layout())
+ verbose() << " tab widget updater tab has layout " << std::endl;
+
+ if (d->m_updaterGuiWidget->widget(d->m_Tab_Pos_PackageManager)->layout())
+ verbose() << " tab widget package tab has layout " << std::endl;
+
+ if (d->m_updaterGuiWidget->layout())
+ verbose() << " tab has layout " << std::endl;
+
+ if (curTab == PACKAGE_MANAGER_TAB)
+ d->m_updaterGuiWidget->setCurrentIndex(d->m_Tab_Pos_PackageManager);
+
+ connect(d->m_updater.data(), SIGNAL(updateFinished(bool)), this, SLOT(updaterFinished(bool)));
+ connect(d->m_updater.data(), SIGNAL(updateFinished(bool)), w, SLOT(refreshDialog()));
+ connect(w, SIGNAL(rejected()), this, SLOT(updaterFinishedWithError()));
+ connect(w, SIGNAL(finished(int)), this, SLOT(updaterFinished(int)));
+ connect(this, SIGNAL(refresh()), w, SLOT(refreshDialog()));
+ connect(d->m_gui, SIGNAL(accepted()), this, SLOT(finished()));
+ connect(d->m_gui, SIGNAL(rejected()), this, SLOT(finished()));
+ connect(d->m_updaterGuiWidget, SIGNAL(currentChanged(int)), this, SLOT(changeCurrentTab(int)));
+ connect(d->m_updaterGuiWidget, SIGNAL(closeRequested()), this, SLOT(close()),
+ Qt::QueuedConnection);
+ connect(d->m_installer, SIGNAL(installationStarted()), this, SLOT(disableUpdaterTab()));
+ connect(d->m_installer, SIGNAL(uninstallationStarted()), this, SLOT(disableUpdaterTab()));
+ d->m_init = true;
+ d->m_updaterGuiWidget->setWindowTitle(d->m_installer->value(QLatin1String("MaintenanceTitle")));
+ }
+}
+
+void TabController::close()
+{
+ if (d->m_updaterGuiWidget && !d->m_gui.isNull())
+ d->m_gui->cancelButtonClicked();
+}
+
+void TabController::disableUpdaterTab()
+{
+ d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, false);
+}
+
+void TabController::enableUpdaterTab()
+{
+ d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, true);
+}
+
+void TabController::restartWizard()
+{
+ enableUpdaterTab();
+ d->m_installer->reset(d->m_params);
+ checkRepositories();
+
+ if (d->m_installer->isPackageManager())
+ d->preselectInstalledPackages();
+}
+
+void TabController::finished()
+{
+ d->m_installer->writeUninstaller();
+ d->m_updaterGuiWidget->setCloseWithoutWarning(true);
+ bool res = d->m_updaterGuiWidget->close();
+ bool res2 = d->m_updaterGuiWidget->close();
+ verbose() << " widget was closed ? : " << res << " " << res2 << std::endl;
+}
+
+void TabController::updaterFinishedWithError()
+{
+ d->m_installer->writeUninstaller();
+ d->m_state = CANCELED;
+
+ if (d->m_updaterGuiWidget && !d->m_gui.isNull())
+ d->m_gui->rejectWithoutPrompt();
+
+ finished();
+}
+
+TabController::Status TabController::getState() const
+{
+ return d->m_state;
+}
+
+int TabController::checkRepositories()
+{
+ using namespace QInstaller;
+
+ const bool isInstaller = d->m_installer->isInstaller();
+ GetRepositoriesMetaInfoJob metaInfoJob(d->m_installer->settings().publicKey(),
+ d->m_installer->isPackageManager());
+ if ((isInstaller && !d->m_installer->isOfflineOnly()) || (d->m_installer->isPackageManager()))
+ metaInfoJob.setRepositories(d->m_installer->settings().repositories());
+
+ GetMetaInfoProgressWidget *metaProgress = 0;
+ QScopedPointer<QProgressDialog> progressDialog(0);
+ if (isInstaller) {
+ metaProgress = new GetMetaInfoProgressWidget(d->m_gui->introductionPage());
+ d->m_gui->introductionPage()->setWidget(metaProgress);
+ // disable the 'next' button while performing update
+ d->m_gui->introductionPage()->setComplete(false);
+ metaInfoJob.connect(&metaInfoJob, SIGNAL(infoMessage(KDJob*, QString)), metaProgress,
+ SLOT(message(KDJob*, QString)));
+
+ // show the wizard-gui as early as possible
+ d->m_gui->connect(d->m_gui, SIGNAL(rejected()), &metaInfoJob, SLOT(doCancel()),
+ Qt::QueuedConnection);
+ d->m_gui->setWindowModality(Qt::WindowModal);
+ d->m_gui->show();
+ } else {
+ progressDialog.reset(new QProgressDialog(d->m_updaterGuiWidget));
+ progressDialog->setModal(true);
+ progressDialog->setLabelText(tr("Checking repository..."));
+ progressDialog->setRange(0, 0);
+ connect (progressDialog.data(), SIGNAL(canceled()), &metaInfoJob, SLOT(doCancel()),
+ Qt::QueuedConnection);
+ progressDialog->show();
+ }
+
+ if (d->m_updaterGuiWidget) {
+ d->m_updaterGuiWidget->setWindowModality(Qt::WindowModal);
+ d->m_updaterGuiWidget->show();
+ } else {
+ d->m_gui->setWindowModality(Qt::WindowModal);
+ d->m_gui->show();
+ }
+
+ // start...
+ try {
+ metaInfoJob.setAutoDelete(false);
+ metaInfoJob.start();
+ metaInfoJob.waitForFinished();
+ d->m_repoReached = true;
+ } catch (const Error &e) {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("Unknown error"), tr("Unknown error"), e.message(), QMessageBox::Ok,
+ QMessageBox::Ok);
+ }
+
+ if (metaInfoJob.isCanceled() || metaInfoJob.error() == KDJob::Canceled)
+ return INST_CANCELED;
+
+ if (metaInfoJob.error() == GetRepositoriesMetaInfoJob::UserIgnoreError) {
+ d->m_repoReached = false;
+ } else if (metaInfoJob.error() != KDJob::NoError) {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("metaInfoJobError"), QObject::tr("Error"), metaInfoJob.errorString());
+ return INST_FAILED;
+ }
+
+ const QInstaller::TempDirDeleter tempDirDeleter(metaInfoJob.releaseTemporaryDirectories());
+ const QStringList tempDirs = tempDirDeleter.paths();
+
+ foreach (const QString &i, tempDirs) {
+ if (i.isEmpty())
+ continue;
+ verbose() << "addUpdateSource()" << QUrl::fromLocalFile(i) << std::endl;
+ const QString updatesXmlPath = i + QLatin1String("/Updates.xml");
+
+ QFile updatesFile(updatesXmlPath);
+ try {
+ openForRead(&updatesFile, updatesFile.fileName());
+ } catch(const Error &e) {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("Open error"), tr("Error parsing Updates.xml"), e.message());
+ return INST_FAILED;
+ }
+
+ verbose() << "Path to Update.xml " << qPrintable(updatesXmlPath) << std::endl;
+
+ QString err;
+ int line = 0;
+ int col = 0;
+ QDomDocument doc;
+ if (!doc.setContent(&updatesFile, &err, &line, &col)) {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("parseError"), tr("Error parsing Updates.xml"),
+ tr("Parse error in File %4 : %1 at line %2 col %3").arg(err, QString::number(line),
+ QString::number(col), updatesFile.fileName()));
+ return INST_FAILED;
+ }
+
+ const QDomNode checksum = doc.documentElement().firstChildElement(QLatin1String("Checksum"));
+ if (!checksum.isNull()) {
+ const QDomElement checksumElem = checksum.toElement();
+ d->m_installer->setTestChecksum(checksumElem.text() == QLatin1String("true"));
+ }
+
+ verbose() << "addUpdateSource()" << QUrl::fromLocalFile(i) << std::endl;
+ const QString productName = d->m_installer->value(QLatin1String("ProductName"));
+ d->m_app->addUpdateSource(productName, productName, QString(), QUrl::fromLocalFile(i), 1);
+ }
+
+ // The changes done above by adding update source don't count as modification that
+ // need to be saved cause they will be re-set on the next start anyway. This does
+ // prevent creating of xml files not needed atm. We can still set the modified
+ // state later once real things changed that we like to restore at the next startup.
+ d->m_app->updateSourcesInfo()->setModified(false);
+
+ // create the packages info
+ KDUpdater::UpdateFinder* const updateFinder = new KDUpdater::UpdateFinder(d->m_app);
+ QObject::connect(updateFinder, SIGNAL(error(int, QString)), d->m_app, SLOT(printError(int, QString)));
+ updateFinder->setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage);
+ updateFinder->run();
+
+ try {
+ // now create installable components
+ d->m_installer->createComponents(updateFinder->updates(), metaInfoJob);
+ } catch (const Error &e) {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("createComponentsError"), QObject::tr("Error"), e.message());
+ }
+
+ if (d->m_installer->status() == QInstaller::Installer::InstallerFailed)
+ return INST_FAILED;
+
+ // we need at least one component else the installer makes no
+ // sense cause nothing can be installed.
+ if (isInstaller)
+ Q_ASSERT(!d->m_installer->components().isEmpty());
+ d->m_repoUpdateNeeded = false;
+
+ if (metaProgress)
+ metaProgress->close();
+ emit refresh();
+
+ if (d->m_updaterGuiWidget)
+ d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, d->m_repoReached);
+
+ return INST_SUCCESS;
+}
+
+void TabController::updaterFinished(bool error)
+{
+ if (d->m_installer->needsRestart())
+ updaterFinishedWithError();
+ else if (!error)
+ checkRepositories();
+}
+
+void TabController::updaterFinished(int val)
+{
+ if (val != QDialog::Accepted) {
+ if (d->m_updaterGuiWidget && !d->m_gui.isNull())
+ d->m_gui->rejectWithoutPrompt();
+ finished();
+ }
+}
+
+void TabController::canceled()
+{
+ d->m_installer->writeUninstaller();
+ d->m_updaterGuiWidget->setCloseWithoutWarning(true);
+}
+
+int TabController::initPackageManager()
+{
+ init(PACKAGE_MANAGER_TAB);
+
+ if (d->m_updaterGuiWidget)
+ d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, false);
+
+ // this should called as early as possible, to handle checkRepositories error messageboxes for
+ // example
+ if (!d->m_controlScript.isEmpty()) {
+ verbose() << "Non-interactive installation using script: " << qPrintable(d->m_controlScript)
+ << std::endl;
+ d->m_gui->loadControlScript(d->m_controlScript);
+ QScriptEngine* engine = d->m_gui->controlScriptEngine();
+ QScriptValue tabControllerValues = engine->newArray();
+
+ tabControllerValues.setProperty(QLatin1String("UPDATER"),
+ engine->newVariant(static_cast<int>(TabController::UPDATER_TAB)));
+ tabControllerValues.setProperty(QLatin1String("PACKAGE_MANAGER"),
+ engine->newVariant(static_cast<int>(TabController::PACKAGE_MANAGER_TAB)));
+
+ tabControllerValues.setProperty(QLatin1String("UPDATER_TAB"),
+ engine->newVariant(static_cast<int>(TabController::UPDATER_TAB)));
+ tabControllerValues.setProperty(QLatin1String("PACKAGE_MANAGER_TAB"),
+ engine->newVariant(static_cast<int>(TabController::PACKAGE_MANAGER_TAB)));
+
+ engine->globalObject().setProperty(QLatin1String("TabController"), tabControllerValues);
+ engine->globalObject().setProperty(QLatin1String("tabController"), engine->newQObject(this));
+ if (d->m_updater && d->m_updater->updaterGui()) {
+ Q_ASSERT(d->m_updater->updaterGui());
+ engine->globalObject().setProperty(QLatin1String("updaterGui"),
+ engine->newQObject(d->m_updater->updaterGui() ));
+ }
+ }
+
+ if (d->m_repoUpdateNeeded) {
+ int result = checkRepositories();
+ if (result != INST_SUCCESS && d->m_repoReached)
+ return result;
+ }
+
+ // initialize the gui.
+ d->m_gui->init();
+
+ if (d->m_installer->isPackageManager())
+ d->preselectInstalledPackages();
+
+ if (d->m_installer->isInstaller()) {
+ // everything done, enable the 'next' button
+ d->m_gui->introductionPage()->setComplete(true);
+ }
+
+ d->m_packageManagerInitialized = true;
+ if (d->m_updaterGuiWidget)
+ d->m_updaterGuiWidget->setTabEnabled(d->m_Tab_Pos_Updater, true);
+
+ setCurrentTab(PACKAGE_MANAGER_TAB); //calls callback
+ d->m_gui->triggerControlScriptForCurrentPage();
+
+ return INST_SUCCESS;
+}
+
+void TabController::changeCurrentTab(int index)
+{
+ if (index == d->m_Tab_Pos_PackageManager) {
+ if (!d->m_packageManagerInitialized)
+ initPackageManager();
+ } else {
+ if (!d->m_updaterInitialized)
+ initUpdater();
+ }
+}
diff --git a/installerbuilder/installerbase/tabcontroller.h b/installerbuilder/installerbase/tabcontroller.h
new file mode 100644
index 000000000..12a62f73e
--- /dev/null
+++ b/installerbuilder/installerbase/tabcontroller.h
@@ -0,0 +1,97 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef TABCONTROLLER_H
+#define TABCONTROLLER_H
+
+#include <QtCore/QHash>
+#include <QtCore/QObject>
+
+namespace QInstaller {
+ class Installer;
+ class Gui;
+}
+
+namespace KDUpdater {
+ class Application;
+}
+
+class MainTabWidget;
+
+class TabController : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(TabController)
+
+public:
+ enum Tabs {
+ UPDATER_TAB,
+ PACKAGE_MANAGER_TAB
+ };
+
+ enum Status {
+ SUCCESS = 0,
+ CANCELED = 1,
+ FAILED = 2
+ };
+
+ explicit TabController(QObject *parent = 0);
+ ~TabController();
+ int initUpdater();
+ int initPackageManager();
+ int checkRepositories();
+ void setInstaller(QInstaller::Installer *installer);
+ void setTabWidget(MainTabWidget *widget);
+ void setApplication(KDUpdater::Application *app);
+ void setInstallerGui(QInstaller::Gui *gui);
+ void setControlScript(const QString &script);
+ void setInstallerParams(const QHash<QString, QString> &params);
+ Status getState() const;
+ Q_INVOKABLE void setCurrentTab(int tab);
+
+Q_SIGNALS:
+ void refresh();
+
+private Q_SLOTS:
+ void changeCurrentTab(int index);
+ void canceled();
+ void finished();
+ void restartWizard();
+ void disableUpdaterTab();
+ void enableUpdaterTab();
+ void updaterFinished(int val = 0);
+ void updaterFinished(bool error);
+ void updaterFinishedWithError();
+ void close();
+
+private:
+ void init(Tabs curTab);
+
+private:
+ class Private;
+ Private *const d;
+};
+
+#endif // TABCONTROLLER_H
diff --git a/installerbuilder/installerbuilder.dox b/installerbuilder/installerbuilder.dox
new file mode 100644
index 000000000..3bc9237f4
--- /dev/null
+++ b/installerbuilder/installerbuilder.dox
@@ -0,0 +1,790 @@
+// -*- mode:c++ -*-
+/*!
+ \page component-definition Component Definition
+ \brief Documentation on how to create installer components.
+
+ The Installer is based on the idea of having several components, which are either embedded in the
+ installer itself or loaded from a remote repository. For both, embedding components into the installer
+ and creating an online repository, you need to keep your components in a certain format readable
+ by the installer.
+
+ \section directory-structure Directory Structure
+
+ Components are identified by a domain-like identifier. This
+ has to be the name of the directory the component data has to be placed in.
+ Within this directory, two subdirectories for \ref data "data" and \ref metadata "meta data" have to exist.
+
+ A packages directory can look like this:
+
+ \verbatim
+ -packages
+ - com.nokia.sdk
+ - data
+ - meta
+ - com.nokia.sdk.qt
+ - data
+ - meta
+ - com.nokia.sdk.qt
+ - data
+ - meta
+ \endverbatim
+
+ \section metadata Contents of the meta data directory
+
+ The meta data directory contains all files which are not to be deployed by the installer but contain
+ information about deployment.
+
+ \subsection packagexml package.xml
+
+ The file package.xml is the main source of information about the component. It's in XML and can look like this:
+
+ \verbatim
+ <?xml version="1.0"?>
+ <Package>
+ <Name>QtGui</Name>
+ <Description>Qt gui libraries</Description>
+ <Version>4.5.1</Version>
+ <ReleaseDate>2009-04-23</ReleaseDate>
+ <Identifier>com.nokia.sdk.qt.gui</Identifier>
+ <Dependencies>com.nokia.sdk.qt.core-4.5.1</Dependencies>
+ <Virtual>false</Virtual>
+ <Script>installscript.qs</Script>
+ <UserInterfaces>
+ <UserInteface>specialpage.ui</UserInterface>
+ <UserInteface>errorpage.ui</UserInterface>
+ </UserInterfaces>
+ <Translations>
+ <Translation>sv_se.qm</Translation>
+ <Translation>de_de.qm</Translation>
+ </Translations>
+ </Package>
+ \endverbatim
+
+ In the example above, you see several XML tags which are filled with values. The following tag names - values - are allowed:
+
+ \li \b VisibleName The human readable name of the component - \a required.
+ \li \b Description The human readable description of the component - \a required.
+ \li \b Version The version number of the component - \a required.
+ \li \b ReleaseDate The day this component version was released - \a optional.
+ \li \b Name domain-like identification for this component - \a required.
+ \li \b Dependencies Comma-separated list of \ref componentdependencies "dependencies" - \a optional.
+ \li \b Virtual Set to true if this is a virtual component not showing up in the installer.
+ \li \b SortingPriority Priority of this component when visible in the tree. Lowest priority number is on top.
+ \li \b InstallPriority Priority of this component when getting installed. Lowest priority number is first.
+ \li \b Script File name of a \ref componentscripting "script" being loaded - \a optional.
+ \li \b UserInterfaces One ore more file names of \ref componentuserinterfaces "user interfaces" being loaded - \a optional.
+ \li \b Translations One ore more file names of \ref componenttranslation "translations" being loaded - \a optional.
+ \li \b UpdateText A description added to the component description if the component is an update - \a optional.
+ \li \b NewComponent If this flag is set the component appears as an update if its not installed - \a optional.
+ \li \b Important The package is marked as important. This is relevant for updates found with UpdateAgent.
+ \li \b ForcedInstallation This packages must always be installed and can't get unchecked by the user.
+ \li \b AutoSelectOn Define boolean expressions with other components names to define when this components gets autoselected.
+
+ \subsection stuff Scripts, User interfaces and translations
+
+ Additonally, all files named in the package.xml - scripts, user interfaces and translations - have to be in the meta data directory.
+ In the example above, this should look like that:
+
+ \verbatim
+ -packages
+ - com.nokia.sdk.qt.gui
+ - data
+ - meta
+ - de_de.qm
+ - errorpage.ui
+ - installscript.qs
+ - package.xml
+ - specialpage.ui
+ - sv_se.qm
+ \endverbatim
+
+
+ \subsection componentdependencies Component Dependencies
+
+ Each component can have one or more components it depends on. This can be other real or virtual components. Every
+ dependency as defined via its identifier and optionally its version. The version, if given, is separated by the identifier
+ by a dash ('-') and can be prefixed by a comparision operator like '=', '>', '<', '>=' or '<=', which means that the version
+ of the matching package is compared to the required version and has to be \a equal, \a greater, \a less, \a greater \a or \a equal or
+ \a less \a or \a equal as the version number given in the dependency. If no comparision operator is given, it defaults to '='.
+
+ \subsection componenttranslation Component Translation
+
+ As the installer makes use of the Qt Translation system, all user readable output can be translated to other languages. To make this
+ work for strings contained in component scripts and user interfaces, components can provide QTranslator files, which get loaded by the
+ installation system when loading the component. The Installer always loads the translation file with a name matching the current system
+ locale. For the system locale being German (Germany), this would be de_de.qm.
+
+ Inside of scripts, you have to use the function qsTr() for literal text. Additionally your script can contain a method
+ Component.prototype.retranslateUi which is called whenever the language of the Installer has changed, i.e. after your translation file
+ was loaded.
+
+ The context being used for translation is the basename of the script file when using qsTr or the class name of the UI file when translating
+ an user interface.
+
+ \subsection componentuserinterfaces Component User Interfaces
+
+ A component can contain one or more user interface files, which are placed into the installer by the script. The installer is automatically
+ loading all ui files listed in the package.xml. You can access the loaded widgets by calling QInstaller::Component::userInterface with the class
+ name of the widget:
+
+ \code
+ component.userInterface( "MyPage" ).checkbox.checked = true; \endcode
+
+ There are two ways of inserting custom user interface widgets into the installer: Inserting them as a single widget or inserting them as their
+ own page.
+
+ To insert them as a single widget, use #QInstaller::Installer::addWizardPageItem. From within the script, this is done by:
+
+ \code
+ // add the instance of MyWidget to the component selection page
+ installer.addWizardPageItem( component, "MyWidget", QInstaller.ComponentSelection ); \endcode
+
+ To add a completely new page into the Installer, you need to specify in front of which page you want to add it.
+ Adding the page is done with #QInstaller::Installer::addWizardPage.
+ \code
+ // add the instance of MyPage in front of the "Ready to Installation" page
+ installer.addWizardPage( component, "MyPage", QInstaller.ReadyForInstallation ); \endcode
+
+ \section data Contents of the data directory
+
+ The data section can contain plain files or directories. Directories will be compressed to 7z archives on creation.
+ Plain files will be put into the installer as they are.
+
+ \note We recommend you to put 7zip compatible archives into the data directory.
+
+
+
+
+
+
+
+
+
+ \page componentscripting Component Scripting
+ \brief Documentation about the scripting abilities inside of components.
+
+ Each component can specify one script handled by the Installer. It has to be compatible to QScriptEngine.
+
+ \section constructor Construction
+
+ The script has to provide an object Component, which will be created by the Installer when loading the script.
+ Therefore the script must contains at least a function Component(), which can do all the initialization needed,
+ like putting user interfaces in place or connecting signals/slots:
+
+ \verbatim
+ function Component()
+ {
+ // let's assume we have a user interface ErrorPage - which should not be complete
+ installer.addWizardPage( component, "ErrorPage", QInstaller.ReadyForInstallation );
+ component.userInterface( "ErrorPage" ).complete = false;
+ }
+ \endverbatim
+
+ The example above places the user interface "ErrorPage" (which is the class name of the ui file loaded from errorpage.ui) in
+ front of the installer page "Ready for Installation" and sets his completeness to false. See the documentation for
+ \link QInstaller::Installer::addWizardPage addWizardPage \endlink and
+ \link QInstaller::Component::userInterface userInterface \endlink for details.
+
+ \section hooks Hooks called by the Installer
+
+ You can add several hook methods into your script:
+
+ \b Component.prototype.retranslateUi is called, whenever the language of the Installer changes.
+
+ \b Component.prototype.createOperations- see \link QInstaller::Component::createOperations \endlink
+
+ \b Component.prototype.createOperationsForArchive - see \link QInstaller::Component::createOperationsForArchive \endlink
+
+ \b Component.prototype.createOperationsForPath - see \link QInstaller::Component::createOperationsForPath \endlink
+
+ \section globalvariables Global variables
+
+ The Installer puts the following symbols into the scripts space:
+
+ \li \b installer A reference to the component's \link QInstaller::Installer Installer \endlink
+ \li \b component A reference to the component's \link QInstaller::Component Component \endlink
+
+ All methods marked with Q_INVOKABLE as well as all signals, slots and properties can be used by the script.
+
+ \section messageboxes Message boxes
+
+ You can show a QMessageBox from within the script by using:
+ \li QMessageBox.critical
+ \li QMessageBox.information
+ \li QMessageBox.question
+ \li QMessageBox.warning
+
+ For your convenience, the values for QMessageBox::StandardButton are made available by using QMessageBox.Ok, QMessageBox.Open, ...
+
+
+
+
+
+ \page installer The Installer
+ \brief Documentation about everything with installation.
+
+ \section installeroperations Installer Operations
+
+ Update operations can be created and added to the installation from within a script using \link QInstaller::Component::addOperation Component::addOperation. \endlink
+ Every operation has an unique key used for identification and up to five parameters. Inside of the parameters, you can use variables as set in
+ \link QInstaller::Installer::setValue Installer::setValue. \endlink See the \link predefinedvariables list of predefined variables. \endlink.
+
+ This is a short list of available installer operations and their use.
+
+
+ \subsection Copy
+
+ \b Syntax: "Copy" \a source \a target
+
+ Copies a file from \a source to \a target.
+
+
+ \subsection Move
+
+ \b Syntax: "Move" \a source \a target
+
+ Moves a file from \a source to \a target.
+
+
+ \subsection Delete
+
+ \b Syntax: "Delete" \a filename
+
+ Deletes the file specified by \a filename.
+
+
+ \subsection Mkdir
+
+ \b Syntax: "Mkdir" \a path
+
+ Creates the directory path \a path.
+
+
+ \subsection Rmdir
+
+ \b Syntax: "Rmdir" \a path
+
+ Removes the directory path \a path.
+
+
+ \subsection AppendFile
+
+ \b Syntax: "AppendFile" \a filename \a text
+
+ Appends \a text to the file specified by \a filename. \a is threated as ASCII text.
+
+
+ \subsection PrepenFile
+
+ \b Syntax: "PrependFile" \a filename \a text
+
+ Prepends \a text to the file specified by \a filename. \a is threated as ASCII text.
+
+
+ \subsection Execute
+
+ \b Syntax: "Execute" [{\aexitcodes}] \a command [\a parameter1 [\a parameter2 [\a parameter3 [\a parameter4]]]]
+
+ Executes the command specified by \a command. Up to four parameters can be passed.
+
+ Optionally, you can pass a comma separated list of numbers in {} as first argument, which defines the "valid" exit codes
+ of the process, i.e. the codes the execution is considered being successful. This defaults to "{0}".
+
+ \subsection CreateShortcut
+
+ \b Syntax: "CreateShortcut" \a filename \a linkname [\a arguments]
+
+ Creates a shortcut from the file specified by \a filename to \a linkname.
+ On Windows, this will create a .lnk file which can have \a arguments, on Unix this will create a symobic link.
+
+
+ \subsection CreateDesktopEntry
+
+ \b Syntax: "CreateDesktopEntry" \a filename \a "key=value[\nkey2=value2[\nkey3=value3]]]"
+
+ Creates an INI-file like .desktop file as specified by freedesktop.org
+ If \a filename is absolute, the desktop entry is stored there. Otherwise it's stored in locations defined in $XDG_DATA_DIRS/applications
+ or $XDG_DATA_HOME/applications, including the default pathes for boths, as defined by freedesktop.org.
+
+ The key/value pairs are written in the file.
+
+ The file is set to a encoding of UTF-8.
+
+ \subsection InstallIcons
+
+ \b Syntax: "InstallIcons" \a directory
+
+ Installs the contents of \a directory into a location as specified by freedesktop.org, i.e. in any of $XDG_DATA_DIRS/icons or /usr/share/icons
+ or $HOME/.icons. The files are removed from their initial location. Make sure to add this operation after the operation extracting them form the archive.
+
+ \subsection Extract
+
+ \b Syntax: "Extract" \a archive \a targetdirectory
+
+ Extracts \a archive to \a targetdirectory
+
+
+ \subsection GlobalConfig
+
+ \b Syntax: "GlobalConfig" \a company \a application \a key \a value <br>
+ \a or <br>
+ \b Syntax: "GlobalConfig" \a filename \a key \a value
+
+ Stores \a value for \a key in a configuration file. The configuration file is either
+ specified by \a filename (using QSettings::NativeFormat, which might be the Windows registry)
+ or via the \a application and the \a company name.
+
+
+ \subsection EnvironmentVariable
+
+ \b Syntax: "EnvironmentVariable" \a key \a value [[\a persistent] \a system]
+
+ Sets the envirnoment variable \a key to a \a value. If \a persistent is set to true, the variable
+ will be set persistently. This is currently only supported on Windows. If \a system is set to true, the
+ persistent variable will be set system wide, not only for the current user.
+
+
+ \subsection RegisterFileType
+
+ \b Syntax: "RegisterFileType" \a extension \a command [\a description [\a contentType [\a icon]]].
+
+ Registers the file type with \a extension to be opened via \a command. Optionally, you can specify
+ a \a description, a \a contentType and an \a icon. This is currently only supported on Windows.
+
+
+ \section sec_customoperations Custom Operations
+
+ It is possible to register custom installation operations in the Installer. This works by deriving KDUpdater::UpdateOperation.
+ See the following code to know which methods must be implemented:
+
+ \code
+ #include <KDUpdater/UpdateOperation>
+
+ class CustomOperation : public KDUpdater::UpdateOperation
+ {
+ public:
+ CustomOperation()
+ {
+ setName( "CustomOperation" );
+ }
+
+ void backup()
+ {
+ // do whatever is needed to restore the state in undoOperation()
+ }
+
+ bool performOperation()
+ {
+ const QStringList args = arguments();
+ // do whatever is needed to do for the given arguments
+
+ bool success = ...;
+ return success;
+ }
+
+ void undoOperation()
+ {
+ // restore the previous state, as saved in backup()
+ }
+
+ bool testOperation()
+ {
+ // currently unused
+ return true;
+ }
+
+ CustomOperation* clone() const
+ {
+ return new CustomOperation;
+ }
+
+ QDomDocument toXml()
+ {
+ // automatically adds the operation's arguments and everything set via setValue
+ QDomDocument doc = KDUpdater::UpdateOperation::toXml();
+
+ // if you need any information to undo the operation you did,
+ // add them to the doc here
+
+ return doc;
+ }
+
+ bool fromXml( const QDomDocument& doc )
+ {
+ // automatically loads the operation's arguments and everything set via setValue
+ if( !KDUpdater::UpdateOperation::fromXml( doc ) )
+ return false;
+
+ // if you need any information to undo the operation you did,
+ // read them from the doc here
+
+ return true;
+ }
+ };
+ \endcode
+
+ Finally, you need to register your custom operation class:
+ \code
+ #include <KDupdater/UpdateOperationFactory>
+
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< CustomOperation >( "CustomOperation" );
+ \endcode
+
+ Now you can use your operation in the installer like every other of the predefined operations.
+
+
+ \page toolchain Toolchain
+ \brief Documentation about the different tools coming with the Installerbuilder
+
+ \section binarycreator Installer Binary Creation
+
+ Installer Binaries are created using binarycreator. This is done by appending information about
+ components and even their data, in case of an offline installer, to a basic binary. Read
+ QInstaller::BinaryContent to know how this works. If you only want to use the provided installerbase, you
+ don't need to care about this.
+
+ \subsection Usage
+
+ binarycreator expects the following parameters:
+
+ \li <b>-t \a or --template \a file</b> Use \a file as input file <br>
+ This is the binary used to append component information. <br>
+ On Windows, this defaults to be installerbase.exe in the current working directory.
+ On Unix, installerbase is used.
+
+ \li <b>-p \a or --packages \a directory</b> Use \a directory as packaces directory <br>
+ Specifies the directory to get package, i.e. component information from. See
+ \link component-definition Component Definition \endlink to find out how this directory need
+ to look like. This setting defaults to the current working directory.
+
+ \li <b>-n \a or --nodeps</b> Add only the selected packages to the compile. Don't add their dependencies.
+
+ \li <b>-c \a or --config \a directory</b> Use \a directory as config directory <br>
+ Specifies the directory to be used for \link installer-config Installer Configuration. \endlink
+
+ \li <b>-e \a or --exclude \a p1,...,pn</b> Mark a comma separated list of packages to be retrieved
+ from an online repository, i.e. not to be completely included in the installer binary.
+
+ \li <b>-v \a or --verbose</b> Verbose output. Add this if you are into lots of debug output.
+
+ These parameters are followed by the name of the target binary and a list of packages to be
+ availabe for installation. Note that not only these packages will be inside of the installer, but
+ even all their dependencies and all packages sharing the same prefix, as long as you add the --nodeps flag.
+
+ On Windows, the name of the target binary is automatically extended with .exe, if it wasn't already added by the user.
+ On Mac, the target will be created as application bundle with extension .app, which as automatically added, if not supplied. Additionally, the user can use a .dmg extension, which will create a DMG disk image containing an .app bundle.
+
+ \subsubsection Example
+
+ <b>Offline installer</b>
+
+ \verbatim
+ binarycreator.exe -c installer-config SDKInstaller.exe com.nokia.sdk\endverbatim
+
+ This commands puts com.nokia.sdk as well as all packages com.nokia.sdk depends on into the installer
+ binary SDKInstaller.exe. Additionally, this binary will contain all packages prefixed with
+ com.nokia.sdk.*
+
+ <b>Online installer</b>
+
+ \verbatim
+ binarycreator.exe -c installer-config -e com.nokia.sdk.qt,com.nokia.qtcreator SDKInstaller.exe com.nokia.sdk\endverbatim
+
+ The same as above, except that the data for com.nokia.sdk.qt and com.nokia.qtcreator will be downloaded
+ from a remote repository.
+
+ If your config.xml contains a RSA private key, components and data will be signed with it. On installer
+ runtime, this signature will be used to verify the components. Note that the private key is \b not
+ embedded in the installer binary. If your private key is protected with a password, you will be asked
+ to provide the password.
+
+ \subsection binacycreatorplatformspecific Platform specific notes
+
+ \subsubsection mac Mac OS X
+
+ \li If the target binary is suffixed with .app, a shiny Mac OS X application bundle will be created
+ \li The icon set in the config.xml is extended with ".icns" and used as icon for a created bundle
+
+ \subsubsection win Windows
+
+ \li The icon set in the config.xml is extended with ".ico" and used as application icon for the .exe file.
+
+ \subsection lin Linux
+
+ \li The icon set in the config.xml is extended with ".png" and used as window icon.
+
+ \section sec_repogen Online Repository generation
+
+ To generate online repositories, use the tool repogen.
+
+ \subsection Usage
+
+ repogen expects the following parameters in this order:
+
+ \li <b>Packages directory</b> Directory containing the packages. Same as for binarycreator.
+ \li <b>Configuration directory</b> Directory containing the installer configuration. Same as for binarycreator.
+ \li <b>Repository directory</b> Target directory to generate the repository. Must not yeut exist.
+ \li <b>Components</b> List of components to be placed into the repository. Includes dependencies.
+
+ If your config.xml contains a RSA private key, components and data will be signed with it. On installer
+ runtime, this signature will be used to verify the components. Note that the private key is \b not
+ put into the repository. If your private key is protected with a password, you will be asked
+ to provide the password.
+
+ When the repository has been created, you can upload it to anywhere. Just put the location into
+ the \link installer-config installer configuration\endlink when creating an installer for it.
+
+ \subsection Example
+
+ \verbatim
+ repogen.exe packages installer-config repository com.nokia.sdk.qt com.nokia.sdk.qtcreator\endverbatim
+
+ This command creates a repository inside of \a repository containing com.nokia.sdk.qt and
+ com.nokia.sdk.qtcreator, including all dependencies.
+
+
+ \page installer-config Installer Configuration
+ \brief Explanation about how to configure the created installer
+
+ For creation of installer binaries and online repositories, you need to provide a config directory.
+ This directory needs to contain at least a file named config.xml containing XML information about
+ how to build the installer.
+
+ This file can look like this:
+ \verbatim
+<?xml version="1.0"?>
+<Installer>
+ <Name>Nokia SDK</Name>
+ <Version>1.0.0</Version>
+ <Title>Nokia SDK Setup</Title>
+ <Publisher>Nokia</Publisher>
+ <ProductUrl>http://qt.nokia.com</ProductUrl>
+ <Logo>logo.png</Logo>
+ <License>license.txt</License>
+ <Watermark>watermark.png</Watermark>
+ <RunProgram></RunProgram>
+ <RunProgramDescription></RunProgramDescription>
+ <StartMenuDir>Nokia SDK</StartMenuDir>
+
+ <PublicKey>
+ -----BEGIN PUBLIC KEY-----
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDzdb8ti9Ss5kmEY5rGf2HFEsj0
+ W6dXOXRIO4W3XXr37Rzc8JI4UMZd6lEcxF9mdnoqOOyhHQABI8/CB2t9HTsZPRPC
+ TCq43QLMfVMgI6A5Cgetv6osvZFgNG3nFAlRkLHw2gLO/zxoblY0wPq5p4xmYRh4
+ f/YjsgYeA2v9V9FBAQIDAQAB
+ -----END PUBLIC KEY-----
+ </PublicKey>
+
+ <PrivateKey>
+ -----BEGIN RSA PRIVATE KEY-----
+ Proc-Type: 4,ENCRYPTED
+ DEK-Info: DES-EDE3-CBC,C9D3A294C3702C32
+
+ unYGknjGs+FX+E5Bze/Kk2OZAvpJkYKhhJFJkiPekPy6FLPKDZX0oPyvNFjMnNPG
+ wXNQe7Yr2WVMlFFmm92yCFXyzIrokr5Q8mUZEb1aJKHPCjTk4gmfOSCnwYrqPcLk
+ XdFdr6e+yVsbaJ0zahPFQfaj4fUac9cK/qrMzwn1SxzYgW5+ZNp4KZVhWUkl8SE8
+ TiwDMCN3wLNHzrSZr65A6XFKw5euSyCqcaqDH+tvxvmFZjb8QBhFf9APlTAQKcoK
+ NrMGaUCOC96WDcKkj2iNLOUrp5vylo0/YDWKQdIsGHWGFV7L+M0aJgobdjKKXBKa
+ ywqVhjgMo0e/cS/Ywtfuj9A3K6PnOrizYL+ukTAWfJdxdU8p91BhuoFR4CsYAJAW
+ LZl/EfkCfJHOWgauGFkpvvaaIQMifJ6XObMZUVkYEi8e3jHxA653NmQIXRHoGgTW
+ pr7T/AvZgTdrY0AuMcFHaWvKYrJD0CNwLtA7I+kcEMMa0c9Q2ryI8/qLYSRMMpDk
+ fsUIiciPelpnruKGp8OQsrMPpmbDG2gYDA3y4aL7DDzZc8vx3ElsXcOU+Ri7asKR
+ 1fRhhK7tFI+IhU6oHPM1QkX+85hZQR6Rr7w1dapBITCxv/uepJQJfEeur/utn1wB
+ EvSr8OSLgxFS7Nuc2R4vtHDb09DCSOqj0310GgtvI7NkrJqjx/dOmxjUEw29vRw6
+ 1iaV7JrEkAlXn0cJRXaZ4ujxoIx2lBKoDDrQ8n1OUMxKDqKF/NWWh6yrCcsuG2kN
+ NBZ0kDxCbqe0cyKeCAFjtjUF1TsiAeXXZt+M3s12sKE0B5BXuir74A==
+ -----END RSA PRIVATE KEY-----
+ </PrivateKey>
+
+ <Icon>qticon</Icon>
+
+ <!-- @homeDir@ and @rootDir@ are some of the supported vars -->
+ <TargetDir>@homeDir@/testinstall</TargetDir>
+ <RemoteRepositories>
+ <Repository>
+       <Url>http://qt.nokia.com/packages/</Url>
+           <Required>false</Required>
+        </Repository>
+ </RemoteRepositories>
+</Installer> \endverbatim
+
+ \section Settings
+
+ The following settings are contained in this file. All of them are actually optional.
+
+ \li \b Name The name of the product being installed
+ \li \b Version The version of the product being installed
+ \li \b Title The title text of the generated installer, i.e. its name
+ \li \b MaintenanceTitle The title text of the generated maintenance tool, i.e. its name
+ \li \b Pushblisher The publisher of the software
+ \li \b ProductUrl URL of the product
+ \li \b Logo Filename for a logo used as QWizard::LogoPixmap
+ \li \b License Filename of the license text to be accepted by the installing user
+ \li \b Watermark Filename for a watermark used as QWizard::WatermarkPixmap
+ \li \b Background Filename for an image used as QWizard::BackgroundPixmap
+ \li \b RunProgram Command executed after the installer is done, if the user accepts it
+ \li \b RunProgramDescription Text shown next to the checkbox for running the program. Defaults to "Run <Name>"
+ \li \b StartMenuDir Name of the predefined group in the Windows Start Menu
+ \li \b Icon Filename of the installer icon. On Windows, .ico is appended, on Mac, .icns is appended and on Linux, .png is appended.
+ \li \b PublicKey RSA public key to be used to verify component signatures
+ \li \b PrivateKey RSA private key to be used to sign components
+ \li \b TargetDir Predefined target directory for installation
+ \li \b RemoteRepositories List of \ref sec_repogen "remote repositories"
+ \li \b UninstallerName File name of the generated uninstaller. Defaults to "uninstall". The platform specific executable suffixs is appended.
+
+ \section remoterepo Remote Repositories
+
+ The installer configuration file can contain a list of several remote repositories. Each of them has
+ two properties. The first one is the repository URL. In the example above, this is "http://qt.nokia.com/packages/"
+ The URL needs to contain a file Updates.xml listing the available packages. See \ref sec_repogen
+ to read more about online repositories. The second parameter is "Required". If you set this to true,
+ the installer won't work if this repository is not available. If you set it to false, it is working, but just without
+ the packages from there.
+
+
+ \page predefinedvariables Predefined variables
+ \brief List over the predefined variables inside of the installer and their meaning
+
+ \li ProductName The name of the product to be installed as defined in config.xml
+ \li ProductVersion The version of the product to be installed as defined in config.xml
+ \li Title The title of the installation program as defined in config.xml
+ \li Publisher The publisher of the installation program as defined in config.xml
+ \li Url Product URL as defined in config.xml
+ \li StartMenuDir Start menu group as defined in config.xml. Applies only to Microsoft Windows
+ \li LicenseFile File name of the program license as defined in config.xml
+ \li TargetDir Target directory for installation as selected by the user.
+ \li DesktopDir Directory containing the user's desktop.
+ \li os The current platform, might be "x11", "win" or "mac"
+
+ \note You can use these variables inside of the parameter list for installation operations.
+ "{TargetDir}/settings.xml" might be expanded to "C:/Program Files/My Program/settings.xml".
+
+ \page non-interactive-installation
+ \brief page and scripted messagebox handling
+
+ \section Installer Page Callbacks
+
+ \subsection builtinpages Built-in pages
+
+ \subsubsection IntroductionPageCallback
+ Wizard buttons:
+ \li Next
+ \li Cancel
+
+ \subsubsection LicenseAgreementPageCallback
+ Wizard buttons:
+ \li Next
+ \li Cancel
+ \li Back
+
+ Radio buttons:
+ \li acceptLicenseRB (radio button): Accepts the license Agreement (unchecked by default)
+ \li rejectLicenseRB (radio button): Rejects the license Agreement (checked by default)
+
+ \subsubsection TargetDirectoryPageCallback
+
+ Wizard buttons:
+ \li Next
+ \li Cancel
+ \li Back
+
+ targetDirectoryLE (line edit): The target directory for installation
+
+ \subsubsection ComponentSelectionPageCallback
+
+ Wizard buttons:
+ \li Next
+ \li Cancel
+ \li Back
+
+ Methods:
+
+ \li selectComponent( id ): selects the component with the ID id (string)
+ \li deselectComponent( id ): deselects the component with the ID id (string)
+
+ In uninstallation mode, additional controls are available:
+
+ \li uninstallAllComponentsRB (radio button): Uninstall all components (default)
+ \li keepSelectedComponentsRB (radio button): Uninstall only unselected components (deselectComponent/selectComponent to modify them)
+
+ \subsubsection ReadyForInstallationPageCallback
+
+ Wizard buttons:
+ \li Next ("Install")
+ \li Cancel
+ \li Back
+
+ \subsubsection PerformInstallationPage
+
+ details.button (push button): Shows/hides installation details
+
+ Wizard buttons: Cancel
+
+ \subsubsection FinishedPageCallback
+
+ Wizard buttons:
+ \li Finish
+
+\subsection Custom Pages
+
+Custom pages are registered as Dynamic${ObjectName}, where ${ObjectName} is the object name set in the UI file.
+Thus the callback called is Dynamic${ObjectName}Callback(). Widgets can be addressed using their object names (from the UI file):
+
+var page = pageWidgetByObjectName( "DynamicSomePage" )
+page.myButton.click //direct child of the UI file's widgte
+page.someFancyWidget.subWidget.setText( "foobar" ) // nested widget
+
+
+ \section messageboxes
+ <table>
+ <tr>
+ <th>Identifier</th>
+ <th>Possible Answers</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>cancelInstallation</td>
+ <td>Yes, No</td>
+ <td>Confirmation for canceling the installation (Cancel button in the wizard)</td>
+ </tr>
+ <tr>
+ <td>overwriteTargetDirectory</td>
+ <td>Yes, No</td>
+ <td>Confirmation to use an already existing directory as target</td>
+ </tr>
+ <tr>
+ <td>installationError</td>
+ <td>Ok</td>
+ <td>A fatal error occurred while performing the installation</td>
+ </tr>
+ <tr>
+ <td>installationErrorWithRetry</td>
+ <td>Retry, Ignore, Cancel</td>
+ <td>An error occurred while performing the installation, Retry possible</td>
+ </tr>
+ <tr>
+ <td>metaInfoJobError</td>
+ <td>Ok</td>
+ <td>Error occurred retrieving meta information (online installer)</td>
+ </tr>
+ </table>
+ \page testnokia testing of the nokia installer
+ \brief List of the pages and their components from the nokia installer
+
+ \section customized pages
+
+ \subsection TargetDirectoryPage
+ The target directory page got a custom UI file called InstallationKindWidget
+ that contains two radio buttons.
+ Radio buttons:
+
+ \li CustomRadioButton (radio button): Shows the ComponentSelectionPage (unchecked by default)
+ \li FullRadioButton (radio button): Marks all available packages for installation (checked by default)
+
+ Be aware with the version from 2010_04_06_16_39 setting the CustomRadioButton to checked has no
+ effect other than marking the button if next ist clicked the full installation is still performed.
+ Only a mouseklick changes the installation behavior as the script uses a buttonReleasedSignal to
+ change that behavior.
+
+
+*/
diff --git a/installerbuilder/installerbuilder.pro b/installerbuilder/installerbuilder.pro
new file mode 100644
index 000000000..de74df5c0
--- /dev/null
+++ b/installerbuilder/installerbuilder.pro
@@ -0,0 +1,10 @@
+TEMPLATE = subdirs
+CONFIG += ordered
+SUBDIRS += libinstaller installerbase binarycreator repogen operationrunner archivegen #tests
+
+#test.commands=(cd tests && $(MAKE) test)
+
+#test.target=test
+#test.depends = $(TARGET)
+#QMAKE_EXTRA_TARGETS += test
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/aes.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/aes.h
new file mode 100644
index 000000000..450f2b405
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/aes.h
@@ -0,0 +1,148 @@
+/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
+/* ====================================================================
+ * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ */
+
+#ifndef HEADER_AES_H
+#define HEADER_AES_H
+
+#include <openssl/opensslconf.h>
+
+#ifdef OPENSSL_NO_AES
+#error AES is disabled.
+#endif
+
+#define AES_ENCRYPT 1
+#define AES_DECRYPT 0
+
+/* Because array size can't be a const in C, the following two are macros.
+ Both sizes are in bytes. */
+#define AES_MAXNR 14
+#define AES_BLOCK_SIZE 16
+
+#ifdef OPENSSL_FIPS
+#define FIPS_AES_SIZE_T int
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* This should be a hidden type, but EVP requires that the size be known */
+struct aes_key_st {
+#ifdef AES_LONG
+ unsigned long rd_key[4 *(AES_MAXNR + 1)];
+#else
+ unsigned int rd_key[4 *(AES_MAXNR + 1)];
+#endif
+ int rounds;
+};
+typedef struct aes_key_st AES_KEY;
+
+const char *AES_options(void);
+
+int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
+ AES_KEY *key);
+int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
+ AES_KEY *key);
+
+void AES_encrypt(const unsigned char *in, unsigned char *out,
+ const AES_KEY *key);
+void AES_decrypt(const unsigned char *in, unsigned char *out,
+ const AES_KEY *key);
+
+void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
+ const AES_KEY *key, const int enc);
+void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
+ const unsigned long length, const AES_KEY *key,
+ unsigned char *ivec, const int enc);
+void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
+ const unsigned long length, const AES_KEY *key,
+ unsigned char *ivec, int *num, const int enc);
+void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
+ const unsigned long length, const AES_KEY *key,
+ unsigned char *ivec, int *num, const int enc);
+void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
+ const unsigned long length, const AES_KEY *key,
+ unsigned char *ivec, int *num, const int enc);
+void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
+ const int nbits,const AES_KEY *key,
+ unsigned char *ivec,const int enc);
+void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
+ const unsigned long length, const AES_KEY *key,
+ unsigned char *ivec, int *num);
+void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
+ const unsigned long length, const AES_KEY *key,
+ unsigned char ivec[AES_BLOCK_SIZE],
+ unsigned char ecount_buf[AES_BLOCK_SIZE],
+ unsigned int *num);
+
+/* For IGE, see also http://www.links.org/files/openssl-ige.pdf */
+/* NB: the IV is _two_ blocks long */
+void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
+ const unsigned long length, const AES_KEY *key,
+ unsigned char *ivec, const int enc);
+/* NB: the IV is _four_ blocks long */
+void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
+ const unsigned long length, const AES_KEY *key,
+ const AES_KEY *key2, const unsigned char *ivec,
+ const int enc);
+
+int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
+ unsigned char *out,
+ const unsigned char *in, unsigned int inlen);
+int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
+ unsigned char *out,
+ const unsigned char *in, unsigned int inlen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !HEADER_AES_H */
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1.h
new file mode 100644
index 000000000..e3385226d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1.h
@@ -0,0 +1,1329 @@
+/* crypto/asn1/asn1.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_ASN1_H
+#define HEADER_ASN1_H
+
+#include <time.h>
+#include <openssl/e_os2.h>
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+#include <openssl/stack.h>
+#include <openssl/safestack.h>
+
+#include <openssl/symhacks.h>
+
+#include <openssl/ossl_typ.h>
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/bn.h>
+#endif
+
+#ifdef OPENSSL_BUILD_SHLIBCRYPTO
+# undef OPENSSL_EXTERN
+# define OPENSSL_EXTERN OPENSSL_EXPORT
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define V_ASN1_UNIVERSAL 0x00
+#define V_ASN1_APPLICATION 0x40
+#define V_ASN1_CONTEXT_SPECIFIC 0x80
+#define V_ASN1_PRIVATE 0xc0
+
+#define V_ASN1_CONSTRUCTED 0x20
+#define V_ASN1_PRIMITIVE_TAG 0x1f
+#define V_ASN1_PRIMATIVE_TAG 0x1f
+
+#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */
+#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */
+#define V_ASN1_ANY -4 /* used in ASN1 template code */
+
+#define V_ASN1_NEG 0x100 /* negative flag */
+
+#define V_ASN1_UNDEF -1
+#define V_ASN1_EOC 0
+#define V_ASN1_BOOLEAN 1 /**/
+#define V_ASN1_INTEGER 2
+#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG)
+#define V_ASN1_BIT_STRING 3
+#define V_ASN1_OCTET_STRING 4
+#define V_ASN1_NULL 5
+#define V_ASN1_OBJECT 6
+#define V_ASN1_OBJECT_DESCRIPTOR 7
+#define V_ASN1_EXTERNAL 8
+#define V_ASN1_REAL 9
+#define V_ASN1_ENUMERATED 10
+#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG)
+#define V_ASN1_UTF8STRING 12
+#define V_ASN1_SEQUENCE 16
+#define V_ASN1_SET 17
+#define V_ASN1_NUMERICSTRING 18 /**/
+#define V_ASN1_PRINTABLESTRING 19
+#define V_ASN1_T61STRING 20
+#define V_ASN1_TELETEXSTRING 20 /* alias */
+#define V_ASN1_VIDEOTEXSTRING 21 /**/
+#define V_ASN1_IA5STRING 22
+#define V_ASN1_UTCTIME 23
+#define V_ASN1_GENERALIZEDTIME 24 /**/
+#define V_ASN1_GRAPHICSTRING 25 /**/
+#define V_ASN1_ISO64STRING 26 /**/
+#define V_ASN1_VISIBLESTRING 26 /* alias */
+#define V_ASN1_GENERALSTRING 27 /**/
+#define V_ASN1_UNIVERSALSTRING 28 /**/
+#define V_ASN1_BMPSTRING 30
+
+/* For use with d2i_ASN1_type_bytes() */
+#define B_ASN1_NUMERICSTRING 0x0001
+#define B_ASN1_PRINTABLESTRING 0x0002
+#define B_ASN1_T61STRING 0x0004
+#define B_ASN1_TELETEXSTRING 0x0004
+#define B_ASN1_VIDEOTEXSTRING 0x0008
+#define B_ASN1_IA5STRING 0x0010
+#define B_ASN1_GRAPHICSTRING 0x0020
+#define B_ASN1_ISO64STRING 0x0040
+#define B_ASN1_VISIBLESTRING 0x0040
+#define B_ASN1_GENERALSTRING 0x0080
+#define B_ASN1_UNIVERSALSTRING 0x0100
+#define B_ASN1_OCTET_STRING 0x0200
+#define B_ASN1_BIT_STRING 0x0400
+#define B_ASN1_BMPSTRING 0x0800
+#define B_ASN1_UNKNOWN 0x1000
+#define B_ASN1_UTF8STRING 0x2000
+#define B_ASN1_UTCTIME 0x4000
+#define B_ASN1_GENERALIZEDTIME 0x8000
+#define B_ASN1_SEQUENCE 0x10000
+
+/* For use with ASN1_mbstring_copy() */
+#define MBSTRING_FLAG 0x1000
+#define MBSTRING_UTF8 (MBSTRING_FLAG)
+#define MBSTRING_ASC (MBSTRING_FLAG|1)
+#define MBSTRING_BMP (MBSTRING_FLAG|2)
+#define MBSTRING_UNIV (MBSTRING_FLAG|4)
+
+#define SMIME_OLDMIME 0x400
+#define SMIME_CRLFEOL 0x800
+#define SMIME_STREAM 0x1000
+
+struct X509_algor_st;
+DECLARE_STACK_OF(X509_ALGOR)
+
+#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */
+#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */
+
+/* We MUST make sure that, except for constness, asn1_ctx_st and
+ asn1_const_ctx are exactly the same. Fortunately, as soon as
+ the old ASN1 parsing macros are gone, we can throw this away
+ as well... */
+typedef struct asn1_ctx_st
+ {
+ unsigned char *p;/* work char pointer */
+ int eos; /* end of sequence read for indefinite encoding */
+ int error; /* error code to use when returning an error */
+ int inf; /* constructed if 0x20, indefinite is 0x21 */
+ int tag; /* tag from last 'get object' */
+ int xclass; /* class from last 'get object' */
+ long slen; /* length of last 'get object' */
+ unsigned char *max; /* largest value of p allowed */
+ unsigned char *q;/* temporary variable */
+ unsigned char **pp;/* variable */
+ int line; /* used in error processing */
+ } ASN1_CTX;
+
+typedef struct asn1_const_ctx_st
+ {
+ const unsigned char *p;/* work char pointer */
+ int eos; /* end of sequence read for indefinite encoding */
+ int error; /* error code to use when returning an error */
+ int inf; /* constructed if 0x20, indefinite is 0x21 */
+ int tag; /* tag from last 'get object' */
+ int xclass; /* class from last 'get object' */
+ long slen; /* length of last 'get object' */
+ const unsigned char *max; /* largest value of p allowed */
+ const unsigned char *q;/* temporary variable */
+ const unsigned char **pp;/* variable */
+ int line; /* used in error processing */
+ } ASN1_const_CTX;
+
+/* These are used internally in the ASN1_OBJECT to keep track of
+ * whether the names and data need to be free()ed */
+#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */
+#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */
+#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */
+#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */
+typedef struct asn1_object_st
+ {
+ const char *sn,*ln;
+ int nid;
+ int length;
+ unsigned char *data;
+ int flags; /* Should we free this one */
+ } ASN1_OBJECT;
+
+#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */
+/* This indicates that the ASN1_STRING is not a real value but just a place
+ * holder for the location where indefinite length constructed data should
+ * be inserted in the memory buffer
+ */
+#define ASN1_STRING_FLAG_NDEF 0x010
+
+/* This flag is used by the CMS code to indicate that a string is not
+ * complete and is a place holder for content when it had all been
+ * accessed. The flag will be reset when content has been written to it.
+ */
+#define ASN1_STRING_FLAG_CONT 0x020
+
+/* This is the base type that holds just about everything :-) */
+typedef struct asn1_string_st
+ {
+ int length;
+ int type;
+ unsigned char *data;
+ /* The value of the following field depends on the type being
+ * held. It is mostly being used for BIT_STRING so if the
+ * input data has a non-zero 'unused bits' value, it will be
+ * handled correctly */
+ long flags;
+ } ASN1_STRING;
+
+/* ASN1_ENCODING structure: this is used to save the received
+ * encoding of an ASN1 type. This is useful to get round
+ * problems with invalid encodings which can break signatures.
+ */
+
+typedef struct ASN1_ENCODING_st
+ {
+ unsigned char *enc; /* DER encoding */
+ long len; /* Length of encoding */
+ int modified; /* set to 1 if 'enc' is invalid */
+ } ASN1_ENCODING;
+
+/* Used with ASN1 LONG type: if a long is set to this it is omitted */
+#define ASN1_LONG_UNDEF 0x7fffffffL
+
+#define STABLE_FLAGS_MALLOC 0x01
+#define STABLE_NO_MASK 0x02
+#define DIRSTRING_TYPE \
+ (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
+#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
+
+typedef struct asn1_string_table_st {
+ int nid;
+ long minsize;
+ long maxsize;
+ unsigned long mask;
+ unsigned long flags;
+} ASN1_STRING_TABLE;
+
+DECLARE_STACK_OF(ASN1_STRING_TABLE)
+
+/* size limits: this stuff is taken straight from RFC2459 */
+
+#define ub_name 32768
+#define ub_common_name 64
+#define ub_locality_name 128
+#define ub_state_name 128
+#define ub_organization_name 64
+#define ub_organization_unit_name 64
+#define ub_title 64
+#define ub_email_address 128
+
+/* Declarations for template structures: for full definitions
+ * see asn1t.h
+ */
+typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
+typedef struct ASN1_ITEM_st ASN1_ITEM;
+typedef struct ASN1_TLC_st ASN1_TLC;
+/* This is just an opaque pointer */
+typedef struct ASN1_VALUE_st ASN1_VALUE;
+
+/* Declare ASN1 functions: the implement macro in in asn1t.h */
+
+#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
+
+#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \
+ DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)
+
+#define DECLARE_ASN1_FUNCTIONS_name(type, name) \
+ DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
+ DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)
+
+#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
+ DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
+ DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
+
+#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
+ type *d2i_##name(type **a, const unsigned char **in, long len); \
+ int i2d_##name(type *a, unsigned char **out); \
+ DECLARE_ASN1_ITEM(itname)
+
+#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
+ type *d2i_##name(type **a, const unsigned char **in, long len); \
+ int i2d_##name(const type *a, unsigned char **out); \
+ DECLARE_ASN1_ITEM(name)
+
+#define DECLARE_ASN1_NDEF_FUNCTION(name) \
+ int i2d_##name##_NDEF(name *a, unsigned char **out);
+
+#define DECLARE_ASN1_FUNCTIONS_const(name) \
+ DECLARE_ASN1_ALLOC_FUNCTIONS(name) \
+ DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)
+
+#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
+ type *name##_new(void); \
+ void name##_free(type *a);
+
+#define D2I_OF(type) type *(*)(type **,const unsigned char **,long)
+#define I2D_OF(type) int (*)(type *,unsigned char **)
+#define I2D_OF_const(type) int (*)(const type *,unsigned char **)
+
+#define CHECKED_D2I_OF(type, d2i) \
+ ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))
+#define CHECKED_I2D_OF(type, i2d) \
+ ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))
+#define CHECKED_NEW_OF(type, xnew) \
+ ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))
+#define CHECKED_PTR_OF(type, p) \
+ ((void*) (1 ? p : (type*)0))
+#define CHECKED_PPTR_OF(type, p) \
+ ((void**) (1 ? p : (type**)0))
+
+#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)
+#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)
+#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)
+
+TYPEDEF_D2I2D_OF(void);
+
+/* The following macros and typedefs allow an ASN1_ITEM
+ * to be embedded in a structure and referenced. Since
+ * the ASN1_ITEM pointers need to be globally accessible
+ * (possibly from shared libraries) they may exist in
+ * different forms. On platforms that support it the
+ * ASN1_ITEM structure itself will be globally exported.
+ * Other platforms will export a function that returns
+ * an ASN1_ITEM pointer.
+ *
+ * To handle both cases transparently the macros below
+ * should be used instead of hard coding an ASN1_ITEM
+ * pointer in a structure.
+ *
+ * The structure will look like this:
+ *
+ * typedef struct SOMETHING_st {
+ * ...
+ * ASN1_ITEM_EXP *iptr;
+ * ...
+ * } SOMETHING;
+ *
+ * It would be initialised as e.g.:
+ *
+ * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};
+ *
+ * and the actual pointer extracted with:
+ *
+ * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);
+ *
+ * Finally an ASN1_ITEM pointer can be extracted from an
+ * appropriate reference with: ASN1_ITEM_rptr(X509). This
+ * would be used when a function takes an ASN1_ITEM * argument.
+ *
+ */
+
+#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
+
+/* ASN1_ITEM pointer exported type */
+typedef const ASN1_ITEM ASN1_ITEM_EXP;
+
+/* Macro to obtain ASN1_ITEM pointer from exported type */
+#define ASN1_ITEM_ptr(iptr) (iptr)
+
+/* Macro to include ASN1_ITEM pointer from base type */
+#define ASN1_ITEM_ref(iptr) (&(iptr##_it))
+
+#define ASN1_ITEM_rptr(ref) (&(ref##_it))
+
+#define DECLARE_ASN1_ITEM(name) \
+ OPENSSL_EXTERN const ASN1_ITEM name##_it;
+
+#else
+
+/* Platforms that can't easily handle shared global variables are declared
+ * as functions returning ASN1_ITEM pointers.
+ */
+
+/* ASN1_ITEM pointer exported type */
+typedef const ASN1_ITEM * ASN1_ITEM_EXP(void);
+
+/* Macro to obtain ASN1_ITEM pointer from exported type */
+#define ASN1_ITEM_ptr(iptr) (iptr())
+
+/* Macro to include ASN1_ITEM pointer from base type */
+#define ASN1_ITEM_ref(iptr) (iptr##_it)
+
+#define ASN1_ITEM_rptr(ref) (ref##_it())
+
+#define DECLARE_ASN1_ITEM(name) \
+ const ASN1_ITEM * name##_it(void);
+
+#endif
+
+/* Parameters used by ASN1_STRING_print_ex() */
+
+/* These determine which characters to escape:
+ * RFC2253 special characters, control characters and
+ * MSB set characters
+ */
+
+#define ASN1_STRFLGS_ESC_2253 1
+#define ASN1_STRFLGS_ESC_CTRL 2
+#define ASN1_STRFLGS_ESC_MSB 4
+
+
+/* This flag determines how we do escaping: normally
+ * RC2253 backslash only, set this to use backslash and
+ * quote.
+ */
+
+#define ASN1_STRFLGS_ESC_QUOTE 8
+
+
+/* These three flags are internal use only. */
+
+/* Character is a valid PrintableString character */
+#define CHARTYPE_PRINTABLESTRING 0x10
+/* Character needs escaping if it is the first character */
+#define CHARTYPE_FIRST_ESC_2253 0x20
+/* Character needs escaping if it is the last character */
+#define CHARTYPE_LAST_ESC_2253 0x40
+
+/* NB the internal flags are safely reused below by flags
+ * handled at the top level.
+ */
+
+/* If this is set we convert all character strings
+ * to UTF8 first
+ */
+
+#define ASN1_STRFLGS_UTF8_CONVERT 0x10
+
+/* If this is set we don't attempt to interpret content:
+ * just assume all strings are 1 byte per character. This
+ * will produce some pretty odd looking output!
+ */
+
+#define ASN1_STRFLGS_IGNORE_TYPE 0x20
+
+/* If this is set we include the string type in the output */
+#define ASN1_STRFLGS_SHOW_TYPE 0x40
+
+/* This determines which strings to display and which to
+ * 'dump' (hex dump of content octets or DER encoding). We can
+ * only dump non character strings or everything. If we
+ * don't dump 'unknown' they are interpreted as character
+ * strings with 1 octet per character and are subject to
+ * the usual escaping options.
+ */
+
+#define ASN1_STRFLGS_DUMP_ALL 0x80
+#define ASN1_STRFLGS_DUMP_UNKNOWN 0x100
+
+/* These determine what 'dumping' does, we can dump the
+ * content octets or the DER encoding: both use the
+ * RFC2253 #XXXXX notation.
+ */
+
+#define ASN1_STRFLGS_DUMP_DER 0x200
+
+/* All the string flags consistent with RFC2253,
+ * escaping control characters isn't essential in
+ * RFC2253 but it is advisable anyway.
+ */
+
+#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \
+ ASN1_STRFLGS_ESC_CTRL | \
+ ASN1_STRFLGS_ESC_MSB | \
+ ASN1_STRFLGS_UTF8_CONVERT | \
+ ASN1_STRFLGS_DUMP_UNKNOWN | \
+ ASN1_STRFLGS_DUMP_DER)
+
+DECLARE_STACK_OF(ASN1_INTEGER)
+DECLARE_ASN1_SET_OF(ASN1_INTEGER)
+
+DECLARE_STACK_OF(ASN1_GENERALSTRING)
+
+typedef struct asn1_type_st
+ {
+ int type;
+ union {
+ char *ptr;
+ ASN1_BOOLEAN boolean;
+ ASN1_STRING * asn1_string;
+ ASN1_OBJECT * object;
+ ASN1_INTEGER * integer;
+ ASN1_ENUMERATED * enumerated;
+ ASN1_BIT_STRING * bit_string;
+ ASN1_OCTET_STRING * octet_string;
+ ASN1_PRINTABLESTRING * printablestring;
+ ASN1_T61STRING * t61string;
+ ASN1_IA5STRING * ia5string;
+ ASN1_GENERALSTRING * generalstring;
+ ASN1_BMPSTRING * bmpstring;
+ ASN1_UNIVERSALSTRING * universalstring;
+ ASN1_UTCTIME * utctime;
+ ASN1_GENERALIZEDTIME * generalizedtime;
+ ASN1_VISIBLESTRING * visiblestring;
+ ASN1_UTF8STRING * utf8string;
+ /* set and sequence are left complete and still
+ * contain the set or sequence bytes */
+ ASN1_STRING * set;
+ ASN1_STRING * sequence;
+ ASN1_VALUE * asn1_value;
+ } value;
+ } ASN1_TYPE;
+
+DECLARE_STACK_OF(ASN1_TYPE)
+DECLARE_ASN1_SET_OF(ASN1_TYPE)
+
+typedef struct asn1_method_st
+ {
+ i2d_of_void *i2d;
+ d2i_of_void *d2i;
+ void *(*create)(void);
+ void (*destroy)(void *);
+ } ASN1_METHOD;
+
+/* This is used when parsing some Netscape objects */
+typedef struct asn1_header_st
+ {
+ ASN1_OCTET_STRING *header;
+ void *data;
+ ASN1_METHOD *meth;
+ } ASN1_HEADER;
+
+/* This is used to contain a list of bit names */
+typedef struct BIT_STRING_BITNAME_st {
+ int bitnum;
+ const char *lname;
+ const char *sname;
+} BIT_STRING_BITNAME;
+
+
+#define M_ASN1_STRING_length(x) ((x)->length)
+#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n))
+#define M_ASN1_STRING_type(x) ((x)->type)
+#define M_ASN1_STRING_data(x) ((x)->data)
+
+/* Macros for string operations */
+#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\
+ ASN1_STRING_type_new(V_ASN1_BIT_STRING)
+#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\
+ ASN1_STRING_dup((ASN1_STRING *)a)
+#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\
+ (ASN1_STRING *)a,(ASN1_STRING *)b)
+#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
+
+#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\
+ ASN1_STRING_type_new(V_ASN1_INTEGER)
+#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a)
+#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\
+ (ASN1_STRING *)a,(ASN1_STRING *)b)
+
+#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\
+ ASN1_STRING_type_new(V_ASN1_ENUMERATED)
+#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a)
+#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\
+ (ASN1_STRING *)a,(ASN1_STRING *)b)
+
+#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\
+ ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
+#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\
+ ASN1_STRING_dup((ASN1_STRING *)a)
+#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\
+ (ASN1_STRING *)a,(ASN1_STRING *)b)
+#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
+#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b)
+#define M_i2d_ASN1_OCTET_STRING(a,pp) \
+ i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\
+ V_ASN1_UNIVERSAL)
+
+#define B_ASN1_TIME \
+ B_ASN1_UTCTIME | \
+ B_ASN1_GENERALIZEDTIME
+
+#define B_ASN1_PRINTABLE \
+ B_ASN1_NUMERICSTRING| \
+ B_ASN1_PRINTABLESTRING| \
+ B_ASN1_T61STRING| \
+ B_ASN1_IA5STRING| \
+ B_ASN1_BIT_STRING| \
+ B_ASN1_UNIVERSALSTRING|\
+ B_ASN1_BMPSTRING|\
+ B_ASN1_UTF8STRING|\
+ B_ASN1_SEQUENCE|\
+ B_ASN1_UNKNOWN
+
+#define B_ASN1_DIRECTORYSTRING \
+ B_ASN1_PRINTABLESTRING| \
+ B_ASN1_TELETEXSTRING|\
+ B_ASN1_BMPSTRING|\
+ B_ASN1_UNIVERSALSTRING|\
+ B_ASN1_UTF8STRING
+
+#define B_ASN1_DISPLAYTEXT \
+ B_ASN1_IA5STRING| \
+ B_ASN1_VISIBLESTRING| \
+ B_ASN1_BMPSTRING|\
+ B_ASN1_UTF8STRING
+
+#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING)
+#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
+ pp,a->type,V_ASN1_UNIVERSAL)
+#define M_d2i_ASN1_PRINTABLE(a,pp,l) \
+ d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
+ B_ASN1_PRINTABLE)
+
+#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
+#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
+ pp,a->type,V_ASN1_UNIVERSAL)
+#define M_d2i_DIRECTORYSTRING(a,pp,l) \
+ d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
+ B_ASN1_DIRECTORYSTRING)
+
+#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
+#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
+ pp,a->type,V_ASN1_UNIVERSAL)
+#define M_d2i_DISPLAYTEXT(a,pp,l) \
+ d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
+ B_ASN1_DISPLAYTEXT)
+
+#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\
+ ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
+#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \
+ i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\
+ V_ASN1_UNIVERSAL)
+#define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \
+ (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\
+ ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)
+
+#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\
+ ASN1_STRING_type_new(V_ASN1_T61STRING)
+#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_ASN1_T61STRING(a,pp) \
+ i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\
+ V_ASN1_UNIVERSAL)
+#define M_d2i_ASN1_T61STRING(a,pp,l) \
+ (ASN1_T61STRING *)d2i_ASN1_type_bytes\
+ ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)
+
+#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\
+ ASN1_STRING_type_new(V_ASN1_IA5STRING)
+#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_ASN1_IA5STRING_dup(a) \
+ (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a)
+#define M_i2d_ASN1_IA5STRING(a,pp) \
+ i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\
+ V_ASN1_UNIVERSAL)
+#define M_d2i_ASN1_IA5STRING(a,pp,l) \
+ (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\
+ B_ASN1_IA5STRING)
+
+#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\
+ ASN1_STRING_type_new(V_ASN1_UTCTIME)
+#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a)
+
+#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\
+ ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)
+#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\
+ (ASN1_STRING *)a)
+
+#define M_ASN1_TIME_new() (ASN1_TIME *)\
+ ASN1_STRING_type_new(V_ASN1_UTCTIME)
+#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a)
+
+#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\
+ ASN1_STRING_type_new(V_ASN1_GENERALSTRING)
+#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_ASN1_GENERALSTRING(a,pp) \
+ i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\
+ V_ASN1_UNIVERSAL)
+#define M_d2i_ASN1_GENERALSTRING(a,pp,l) \
+ (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\
+ ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)
+
+#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\
+ ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)
+#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \
+ i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\
+ V_ASN1_UNIVERSAL)
+#define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \
+ (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\
+ ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)
+
+#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\
+ ASN1_STRING_type_new(V_ASN1_BMPSTRING)
+#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_ASN1_BMPSTRING(a,pp) \
+ i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\
+ V_ASN1_UNIVERSAL)
+#define M_d2i_ASN1_BMPSTRING(a,pp,l) \
+ (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\
+ ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)
+
+#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\
+ ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
+#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_ASN1_VISIBLESTRING(a,pp) \
+ i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\
+ V_ASN1_UNIVERSAL)
+#define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \
+ (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\
+ ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)
+
+#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\
+ ASN1_STRING_type_new(V_ASN1_UTF8STRING)
+#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
+#define M_i2d_ASN1_UTF8STRING(a,pp) \
+ i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\
+ V_ASN1_UNIVERSAL)
+#define M_d2i_ASN1_UTF8STRING(a,pp,l) \
+ (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\
+ ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING)
+
+ /* for the is_set parameter to i2d_ASN1_SET */
+#define IS_SEQUENCE 0
+#define IS_SET 1
+
+DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
+
+int ASN1_TYPE_get(ASN1_TYPE *a);
+void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
+int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
+
+ASN1_OBJECT * ASN1_OBJECT_new(void );
+void ASN1_OBJECT_free(ASN1_OBJECT *a);
+int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
+ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
+ long length);
+ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
+ long length);
+
+DECLARE_ASN1_ITEM(ASN1_OBJECT)
+
+DECLARE_STACK_OF(ASN1_OBJECT)
+DECLARE_ASN1_SET_OF(ASN1_OBJECT)
+
+ASN1_STRING * ASN1_STRING_new(void);
+void ASN1_STRING_free(ASN1_STRING *a);
+ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a);
+ASN1_STRING * ASN1_STRING_type_new(int type );
+int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b);
+ /* Since this is used to store all sorts of things, via macros, for now, make
+ its data void * */
+int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
+void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
+int ASN1_STRING_length(ASN1_STRING *x);
+void ASN1_STRING_length_set(ASN1_STRING *x, int n);
+int ASN1_STRING_type(ASN1_STRING *x);
+unsigned char * ASN1_STRING_data(ASN1_STRING *x);
+
+DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
+int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
+ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp,
+ long length);
+int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
+ int length );
+int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
+int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
+
+#ifndef OPENSSL_NO_BIO
+int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
+ BIT_STRING_BITNAME *tbl, int indent);
+#endif
+int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
+int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
+ BIT_STRING_BITNAME *tbl);
+
+int i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
+int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length);
+
+DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
+int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
+ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp,
+ long length);
+ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp,
+ long length);
+ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x);
+int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y);
+
+DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
+
+int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
+ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
+int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
+int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
+#if 0
+time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
+#endif
+
+int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
+ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
+int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
+
+DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
+ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a);
+int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b);
+int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len);
+
+DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
+DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
+DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
+DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
+DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
+
+int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
+int UTF8_putc(unsigned char *str, int len, unsigned long value);
+
+DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
+
+DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
+DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
+DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
+DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)
+DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)
+DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
+DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
+DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
+DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
+
+DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
+
+ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
+int ASN1_TIME_check(ASN1_TIME *t);
+ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
+
+int i2d_ASN1_SET(STACK *a, unsigned char **pp,
+ i2d_of_void *i2d, int ex_tag, int ex_class, int is_set);
+STACK * d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length,
+ d2i_of_void *d2i, void (*free_func)(void *),
+ int ex_tag, int ex_class);
+
+#ifndef OPENSSL_NO_BIO
+int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
+int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
+int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
+int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size);
+int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a);
+int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size);
+int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);
+#endif
+int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a);
+
+int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num);
+ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len,
+ const char *sn, const char *ln);
+
+int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
+long ASN1_INTEGER_get(ASN1_INTEGER *a);
+ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai);
+BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn);
+
+int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
+long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);
+ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);
+BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn);
+
+/* General */
+/* given a string, return the correct type, max is the maximum length */
+int ASN1_PRINTABLE_type(const unsigned char *s, int max);
+
+int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);
+ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
+ long length, int Ptag, int Pclass);
+unsigned long ASN1_tag2bit(int tag);
+/* type is one or more of the B_ASN1_ values. */
+ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp,
+ long length,int type);
+
+/* PARSING */
+int asn1_Finish(ASN1_CTX *c);
+int asn1_const_Finish(ASN1_const_CTX *c);
+
+/* SPECIALS */
+int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
+ int *pclass, long omax);
+int ASN1_check_infinite_end(unsigned char **p,long len);
+int ASN1_const_check_infinite_end(const unsigned char **p,long len);
+void ASN1_put_object(unsigned char **pp, int constructed, int length,
+ int tag, int xclass);
+int ASN1_put_eoc(unsigned char **pp);
+int ASN1_object_size(int constructed, int length, int tag);
+
+/* Used to implement other functions */
+void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x);
+
+#define ASN1_dup_of(type,i2d,d2i,x) \
+ ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \
+ CHECKED_D2I_OF(type, d2i), \
+ CHECKED_PTR_OF(type, x)))
+
+#define ASN1_dup_of_const(type,i2d,d2i,x) \
+ ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \
+ CHECKED_D2I_OF(type, d2i), \
+ CHECKED_PTR_OF(const type, x)))
+
+void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
+
+/* ASN1 alloc/free macros for when a type is only used internally */
+
+#define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))
+#define M_ASN1_free_of(x, type) \
+ ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))
+
+#ifndef OPENSSL_NO_FP_API
+void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x);
+
+#define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \
+ ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \
+ CHECKED_D2I_OF(type, d2i), \
+ in, \
+ CHECKED_PPTR_OF(type, x)))
+
+void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
+int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x);
+
+#define ASN1_i2d_fp_of(type,i2d,out,x) \
+ (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \
+ out, \
+ CHECKED_PTR_OF(type, x)))
+
+#define ASN1_i2d_fp_of_const(type,i2d,out,x) \
+ (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \
+ out, \
+ CHECKED_PTR_OF(const type, x)))
+
+int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
+int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
+#endif
+
+int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
+
+#ifndef OPENSSL_NO_BIO
+void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x);
+
+#define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \
+ ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \
+ CHECKED_D2I_OF(type, d2i), \
+ in, \
+ CHECKED_PPTR_OF(type, x)))
+
+void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
+int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x);
+
+#define ASN1_i2d_bio_of(type,i2d,out,x) \
+ (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \
+ out, \
+ CHECKED_PTR_OF(type, x)))
+
+#define ASN1_i2d_bio_of_const(type,i2d,out,x) \
+ (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \
+ out, \
+ CHECKED_PTR_OF(const type, x)))
+
+int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
+int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
+int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a);
+int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
+int ASN1_STRING_print(BIO *bp,ASN1_STRING *v);
+int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
+int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent);
+int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump);
+#endif
+const char *ASN1_tag2str(int tag);
+
+/* Used to load and write netscape format cert/key */
+int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp);
+ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a,const unsigned char **pp, long length);
+ASN1_HEADER *ASN1_HEADER_new(void );
+void ASN1_HEADER_free(ASN1_HEADER *a);
+
+int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
+
+/* Not used that much at this point, except for the first two */
+ASN1_METHOD *X509_asn1_meth(void);
+ASN1_METHOD *RSAPrivateKey_asn1_meth(void);
+ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void);
+ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void);
+
+int ASN1_TYPE_set_octetstring(ASN1_TYPE *a,
+ unsigned char *data, int len);
+int ASN1_TYPE_get_octetstring(ASN1_TYPE *a,
+ unsigned char *data, int max_len);
+int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
+ unsigned char *data, int len);
+int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
+ unsigned char *data, int max_len);
+
+STACK *ASN1_seq_unpack(const unsigned char *buf, int len,
+ d2i_of_void *d2i, void (*free_func)(void *));
+unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d,
+ unsigned char **buf, int *len );
+void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
+void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
+ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
+ ASN1_OCTET_STRING **oct);
+
+#define ASN1_pack_string_of(type,obj,i2d,oct) \
+ (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \
+ CHECKED_I2D_OF(type, i2d), \
+ oct))
+
+ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct);
+
+void ASN1_STRING_set_default_mask(unsigned long mask);
+int ASN1_STRING_set_default_mask_asc(char *p);
+unsigned long ASN1_STRING_get_default_mask(void);
+int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
+ int inform, unsigned long mask);
+int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
+ int inform, unsigned long mask,
+ long minsize, long maxsize);
+
+ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
+ const unsigned char *in, int inlen, int inform, int nid);
+ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
+int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
+void ASN1_STRING_TABLE_cleanup(void);
+
+/* ASN1 template functions */
+
+/* Old API compatible functions */
+ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
+void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
+ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it);
+int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
+int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
+
+void ASN1_add_oid_module(void);
+
+ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);
+ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);
+
+typedef int asn1_output_data_fn(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
+ const ASN1_ITEM *it);
+
+int int_smime_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
+ int ctype_nid, int econt_nid,
+ STACK_OF(X509_ALGOR) *mdalgs,
+ asn1_output_data_fn *data_fn,
+ const ASN1_ITEM *it);
+ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_ASN1_strings(void);
+
+/* Error codes for the ASN1 functions. */
+
+/* Function codes. */
+#define ASN1_F_A2D_ASN1_OBJECT 100
+#define ASN1_F_A2I_ASN1_ENUMERATED 101
+#define ASN1_F_A2I_ASN1_INTEGER 102
+#define ASN1_F_A2I_ASN1_STRING 103
+#define ASN1_F_APPEND_EXP 176
+#define ASN1_F_ASN1_BIT_STRING_SET_BIT 183
+#define ASN1_F_ASN1_CB 177
+#define ASN1_F_ASN1_CHECK_TLEN 104
+#define ASN1_F_ASN1_COLLATE_PRIMITIVE 105
+#define ASN1_F_ASN1_COLLECT 106
+#define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108
+#define ASN1_F_ASN1_D2I_FP 109
+#define ASN1_F_ASN1_D2I_READ_BIO 107
+#define ASN1_F_ASN1_DIGEST 184
+#define ASN1_F_ASN1_DO_ADB 110
+#define ASN1_F_ASN1_DUP 111
+#define ASN1_F_ASN1_ENUMERATED_SET 112
+#define ASN1_F_ASN1_ENUMERATED_TO_BN 113
+#define ASN1_F_ASN1_EX_C2I 204
+#define ASN1_F_ASN1_FIND_END 190
+#define ASN1_F_ASN1_GENERALIZEDTIME_SET 185
+#define ASN1_F_ASN1_GENERATE_V3 178
+#define ASN1_F_ASN1_GET_OBJECT 114
+#define ASN1_F_ASN1_HEADER_NEW 115
+#define ASN1_F_ASN1_I2D_BIO 116
+#define ASN1_F_ASN1_I2D_FP 117
+#define ASN1_F_ASN1_INTEGER_SET 118
+#define ASN1_F_ASN1_INTEGER_TO_BN 119
+#define ASN1_F_ASN1_ITEM_D2I_FP 206
+#define ASN1_F_ASN1_ITEM_DUP 191
+#define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW 121
+#define ASN1_F_ASN1_ITEM_EX_D2I 120
+#define ASN1_F_ASN1_ITEM_I2D_BIO 192
+#define ASN1_F_ASN1_ITEM_I2D_FP 193
+#define ASN1_F_ASN1_ITEM_PACK 198
+#define ASN1_F_ASN1_ITEM_SIGN 195
+#define ASN1_F_ASN1_ITEM_UNPACK 199
+#define ASN1_F_ASN1_ITEM_VERIFY 197
+#define ASN1_F_ASN1_MBSTRING_NCOPY 122
+#define ASN1_F_ASN1_OBJECT_NEW 123
+#define ASN1_F_ASN1_OUTPUT_DATA 207
+#define ASN1_F_ASN1_PACK_STRING 124
+#define ASN1_F_ASN1_PCTX_NEW 205
+#define ASN1_F_ASN1_PKCS5_PBE_SET 125
+#define ASN1_F_ASN1_SEQ_PACK 126
+#define ASN1_F_ASN1_SEQ_UNPACK 127
+#define ASN1_F_ASN1_SIGN 128
+#define ASN1_F_ASN1_STR2TYPE 179
+#define ASN1_F_ASN1_STRING_SET 186
+#define ASN1_F_ASN1_STRING_TABLE_ADD 129
+#define ASN1_F_ASN1_STRING_TYPE_NEW 130
+#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132
+#define ASN1_F_ASN1_TEMPLATE_NEW 133
+#define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131
+#define ASN1_F_ASN1_TIME_SET 175
+#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134
+#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135
+#define ASN1_F_ASN1_UNPACK_STRING 136
+#define ASN1_F_ASN1_UTCTIME_SET 187
+#define ASN1_F_ASN1_VERIFY 137
+#define ASN1_F_B64_READ_ASN1 208
+#define ASN1_F_B64_WRITE_ASN1 209
+#define ASN1_F_BITSTR_CB 180
+#define ASN1_F_BN_TO_ASN1_ENUMERATED 138
+#define ASN1_F_BN_TO_ASN1_INTEGER 139
+#define ASN1_F_C2I_ASN1_BIT_STRING 189
+#define ASN1_F_C2I_ASN1_INTEGER 194
+#define ASN1_F_C2I_ASN1_OBJECT 196
+#define ASN1_F_COLLECT_DATA 140
+#define ASN1_F_D2I_ASN1_BIT_STRING 141
+#define ASN1_F_D2I_ASN1_BOOLEAN 142
+#define ASN1_F_D2I_ASN1_BYTES 143
+#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 144
+#define ASN1_F_D2I_ASN1_HEADER 145
+#define ASN1_F_D2I_ASN1_INTEGER 146
+#define ASN1_F_D2I_ASN1_OBJECT 147
+#define ASN1_F_D2I_ASN1_SET 148
+#define ASN1_F_D2I_ASN1_TYPE_BYTES 149
+#define ASN1_F_D2I_ASN1_UINTEGER 150
+#define ASN1_F_D2I_ASN1_UTCTIME 151
+#define ASN1_F_D2I_NETSCAPE_RSA 152
+#define ASN1_F_D2I_NETSCAPE_RSA_2 153
+#define ASN1_F_D2I_PRIVATEKEY 154
+#define ASN1_F_D2I_PUBLICKEY 155
+#define ASN1_F_D2I_RSA_NET 200
+#define ASN1_F_D2I_RSA_NET_2 201
+#define ASN1_F_D2I_X509 156
+#define ASN1_F_D2I_X509_CINF 157
+#define ASN1_F_D2I_X509_PKEY 159
+#define ASN1_F_I2D_ASN1_SET 188
+#define ASN1_F_I2D_ASN1_TIME 160
+#define ASN1_F_I2D_DSA_PUBKEY 161
+#define ASN1_F_I2D_EC_PUBKEY 181
+#define ASN1_F_I2D_PRIVATEKEY 163
+#define ASN1_F_I2D_PUBLICKEY 164
+#define ASN1_F_I2D_RSA_NET 162
+#define ASN1_F_I2D_RSA_PUBKEY 165
+#define ASN1_F_LONG_C2I 166
+#define ASN1_F_OID_MODULE_INIT 174
+#define ASN1_F_PARSE_TAGGING 182
+#define ASN1_F_PKCS5_PBE2_SET 167
+#define ASN1_F_PKCS5_PBE_SET 202
+#define ASN1_F_SMIME_READ_ASN1 210
+#define ASN1_F_SMIME_TEXT 211
+#define ASN1_F_X509_CINF_NEW 168
+#define ASN1_F_X509_CRL_ADD0_REVOKED 169
+#define ASN1_F_X509_INFO_NEW 170
+#define ASN1_F_X509_NAME_ENCODE 203
+#define ASN1_F_X509_NAME_EX_D2I 158
+#define ASN1_F_X509_NAME_EX_NEW 171
+#define ASN1_F_X509_NEW 172
+#define ASN1_F_X509_PKEY_NEW 173
+
+/* Reason codes. */
+#define ASN1_R_ADDING_OBJECT 171
+#define ASN1_R_ASN1_PARSE_ERROR 198
+#define ASN1_R_ASN1_SIG_PARSE_ERROR 199
+#define ASN1_R_AUX_ERROR 100
+#define ASN1_R_BAD_CLASS 101
+#define ASN1_R_BAD_OBJECT_HEADER 102
+#define ASN1_R_BAD_PASSWORD_READ 103
+#define ASN1_R_BAD_TAG 104
+#define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 210
+#define ASN1_R_BN_LIB 105
+#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106
+#define ASN1_R_BUFFER_TOO_SMALL 107
+#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108
+#define ASN1_R_DATA_IS_WRONG 109
+#define ASN1_R_DECODE_ERROR 110
+#define ASN1_R_DECODING_ERROR 111
+#define ASN1_R_DEPTH_EXCEEDED 174
+#define ASN1_R_ENCODE_ERROR 112
+#define ASN1_R_ERROR_GETTING_TIME 173
+#define ASN1_R_ERROR_LOADING_SECTION 172
+#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113
+#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114
+#define ASN1_R_EXPECTING_AN_INTEGER 115
+#define ASN1_R_EXPECTING_AN_OBJECT 116
+#define ASN1_R_EXPECTING_A_BOOLEAN 117
+#define ASN1_R_EXPECTING_A_TIME 118
+#define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119
+#define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120
+#define ASN1_R_FIELD_MISSING 121
+#define ASN1_R_FIRST_NUM_TOO_LARGE 122
+#define ASN1_R_HEADER_TOO_LONG 123
+#define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175
+#define ASN1_R_ILLEGAL_BOOLEAN 176
+#define ASN1_R_ILLEGAL_CHARACTERS 124
+#define ASN1_R_ILLEGAL_FORMAT 177
+#define ASN1_R_ILLEGAL_HEX 178
+#define ASN1_R_ILLEGAL_IMPLICIT_TAG 179
+#define ASN1_R_ILLEGAL_INTEGER 180
+#define ASN1_R_ILLEGAL_NESTED_TAGGING 181
+#define ASN1_R_ILLEGAL_NULL 125
+#define ASN1_R_ILLEGAL_NULL_VALUE 182
+#define ASN1_R_ILLEGAL_OBJECT 183
+#define ASN1_R_ILLEGAL_OPTIONAL_ANY 126
+#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170
+#define ASN1_R_ILLEGAL_TAGGED_ANY 127
+#define ASN1_R_ILLEGAL_TIME_VALUE 184
+#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185
+#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128
+#define ASN1_R_INVALID_BMPSTRING_LENGTH 129
+#define ASN1_R_INVALID_DIGIT 130
+#define ASN1_R_INVALID_MIME_TYPE 200
+#define ASN1_R_INVALID_MODIFIER 186
+#define ASN1_R_INVALID_NUMBER 187
+#define ASN1_R_INVALID_SEPARATOR 131
+#define ASN1_R_INVALID_TIME_FORMAT 132
+#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133
+#define ASN1_R_INVALID_UTF8STRING 134
+#define ASN1_R_IV_TOO_LARGE 135
+#define ASN1_R_LENGTH_ERROR 136
+#define ASN1_R_LIST_ERROR 188
+#define ASN1_R_MIME_NO_CONTENT_TYPE 201
+#define ASN1_R_MIME_PARSE_ERROR 202
+#define ASN1_R_MIME_SIG_PARSE_ERROR 203
+#define ASN1_R_MISSING_EOC 137
+#define ASN1_R_MISSING_SECOND_NUMBER 138
+#define ASN1_R_MISSING_VALUE 189
+#define ASN1_R_MSTRING_NOT_UNIVERSAL 139
+#define ASN1_R_MSTRING_WRONG_TAG 140
+#define ASN1_R_NESTED_ASN1_STRING 197
+#define ASN1_R_NON_HEX_CHARACTERS 141
+#define ASN1_R_NOT_ASCII_FORMAT 190
+#define ASN1_R_NOT_ENOUGH_DATA 142
+#define ASN1_R_NO_CONTENT_TYPE 204
+#define ASN1_R_NO_MATCHING_CHOICE_TYPE 143
+#define ASN1_R_NO_MULTIPART_BODY_FAILURE 205
+#define ASN1_R_NO_MULTIPART_BOUNDARY 206
+#define ASN1_R_NO_SIG_CONTENT_TYPE 207
+#define ASN1_R_NULL_IS_WRONG_LENGTH 144
+#define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191
+#define ASN1_R_ODD_NUMBER_OF_CHARS 145
+#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 146
+#define ASN1_R_SECOND_NUMBER_TOO_LARGE 147
+#define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148
+#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149
+#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192
+#define ASN1_R_SHORT_LINE 150
+#define ASN1_R_SIG_INVALID_MIME_TYPE 208
+#define ASN1_R_STREAMING_NOT_SUPPORTED 209
+#define ASN1_R_STRING_TOO_LONG 151
+#define ASN1_R_STRING_TOO_SHORT 152
+#define ASN1_R_TAG_VALUE_TOO_HIGH 153
+#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154
+#define ASN1_R_TIME_NOT_ASCII_FORMAT 193
+#define ASN1_R_TOO_LONG 155
+#define ASN1_R_TYPE_NOT_CONSTRUCTED 156
+#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157
+#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158
+#define ASN1_R_UNEXPECTED_EOC 159
+#define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 211
+#define ASN1_R_UNKNOWN_FORMAT 160
+#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161
+#define ASN1_R_UNKNOWN_OBJECT_TYPE 162
+#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163
+#define ASN1_R_UNKNOWN_TAG 194
+#define ASN1_R_UNKOWN_FORMAT 195
+#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164
+#define ASN1_R_UNSUPPORTED_CIPHER 165
+#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166
+#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167
+#define ASN1_R_UNSUPPORTED_TYPE 196
+#define ASN1_R_WRONG_TAG 168
+#define ASN1_R_WRONG_TYPE 169
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1_mac.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1_mac.h
new file mode 100644
index 000000000..d958ca60d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1_mac.h
@@ -0,0 +1,571 @@
+/* crypto/asn1/asn1_mac.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_ASN1_MAC_H
+#define HEADER_ASN1_MAC_H
+
+#include <openssl/asn1.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef ASN1_MAC_ERR_LIB
+#define ASN1_MAC_ERR_LIB ERR_LIB_ASN1
+#endif
+
+#define ASN1_MAC_H_err(f,r,line) \
+ ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))
+
+#define M_ASN1_D2I_vars(a,type,func) \
+ ASN1_const_CTX c; \
+ type ret=NULL; \
+ \
+ c.pp=(const unsigned char **)pp; \
+ c.q= *(const unsigned char **)pp; \
+ c.error=ERR_R_NESTED_ASN1_ERROR; \
+ if ((a == NULL) || ((*a) == NULL)) \
+ { if ((ret=(type)func()) == NULL) \
+ { c.line=__LINE__; goto err; } } \
+ else ret=(*a);
+
+#define M_ASN1_D2I_Init() \
+ c.p= *(const unsigned char **)pp; \
+ c.max=(length == 0)?0:(c.p+length);
+
+#define M_ASN1_D2I_Finish_2(a) \
+ if (!asn1_const_Finish(&c)) \
+ { c.line=__LINE__; goto err; } \
+ *(const unsigned char **)pp=c.p; \
+ if (a != NULL) (*a)=ret; \
+ return(ret);
+
+#define M_ASN1_D2I_Finish(a,func,e) \
+ M_ASN1_D2I_Finish_2(a); \
+err:\
+ ASN1_MAC_H_err((e),c.error,c.line); \
+ asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \
+ if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
+ return(NULL)
+
+#define M_ASN1_D2I_start_sequence() \
+ if (!asn1_GetSequence(&c,&length)) \
+ { c.line=__LINE__; goto err; }
+/* Begin reading ASN1 without a surrounding sequence */
+#define M_ASN1_D2I_begin() \
+ c.slen = length;
+
+/* End reading ASN1 with no check on length */
+#define M_ASN1_D2I_Finish_nolen(a, func, e) \
+ *pp=c.p; \
+ if (a != NULL) (*a)=ret; \
+ return(ret); \
+err:\
+ ASN1_MAC_H_err((e),c.error,c.line); \
+ asn1_add_error(*pp,(int)(c.q- *pp)); \
+ if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
+ return(NULL)
+
+#define M_ASN1_D2I_end_sequence() \
+ (((c.inf&1) == 0)?(c.slen <= 0): \
+ (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen)))
+
+/* Don't use this with d2i_ASN1_BOOLEAN() */
+#define M_ASN1_D2I_get(b, func) \
+ c.q=c.p; \
+ if (func(&(b),&c.p,c.slen) == NULL) \
+ {c.line=__LINE__; goto err; } \
+ c.slen-=(c.p-c.q);
+
+/* Don't use this with d2i_ASN1_BOOLEAN() */
+#define M_ASN1_D2I_get_x(type,b,func) \
+ c.q=c.p; \
+ if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \
+ {c.line=__LINE__; goto err; } \
+ c.slen-=(c.p-c.q);
+
+/* use this instead () */
+#define M_ASN1_D2I_get_int(b,func) \
+ c.q=c.p; \
+ if (func(&(b),&c.p,c.slen) < 0) \
+ {c.line=__LINE__; goto err; } \
+ c.slen-=(c.p-c.q);
+
+#define M_ASN1_D2I_get_opt(b,func,type) \
+ if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \
+ == (V_ASN1_UNIVERSAL|(type)))) \
+ { \
+ M_ASN1_D2I_get(b,func); \
+ }
+
+#define M_ASN1_D2I_get_imp(b,func, type) \
+ M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \
+ c.q=c.p; \
+ if (func(&(b),&c.p,c.slen) == NULL) \
+ {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \
+ c.slen-=(c.p-c.q);\
+ M_ASN1_next_prev=_tmp;
+
+#define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \
+ if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \
+ (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \
+ { \
+ unsigned char _tmp = M_ASN1_next; \
+ M_ASN1_D2I_get_imp(b,func, type);\
+ }
+
+#define M_ASN1_D2I_get_set(r,func,free_func) \
+ M_ASN1_D2I_get_imp_set(r,func,free_func, \
+ V_ASN1_SET,V_ASN1_UNIVERSAL);
+
+#define M_ASN1_D2I_get_set_type(type,r,func,free_func) \
+ M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \
+ V_ASN1_SET,V_ASN1_UNIVERSAL);
+
+#define M_ASN1_D2I_get_set_opt(r,func,free_func) \
+ if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
+ V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
+ { M_ASN1_D2I_get_set(r,func,free_func); }
+
+#define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \
+ if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
+ V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
+ { M_ASN1_D2I_get_set_type(type,r,func,free_func); }
+
+#define M_ASN1_I2D_len_SET_opt(a,f) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ M_ASN1_I2D_len_SET(a,f);
+
+#define M_ASN1_I2D_put_SET_opt(a,f) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ M_ASN1_I2D_put_SET(a,f);
+
+#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ M_ASN1_I2D_put_SEQUENCE(a,f);
+
+#define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \
+ if ((a != NULL) && (sk_##type##_num(a) != 0)) \
+ M_ASN1_I2D_put_SEQUENCE_type(type,a,f);
+
+#define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \
+ if ((c.slen != 0) && \
+ (M_ASN1_next == \
+ (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\
+ { \
+ M_ASN1_D2I_get_imp_set(b,func,free_func,\
+ tag,V_ASN1_CONTEXT_SPECIFIC); \
+ }
+
+#define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \
+ if ((c.slen != 0) && \
+ (M_ASN1_next == \
+ (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\
+ { \
+ M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\
+ tag,V_ASN1_CONTEXT_SPECIFIC); \
+ }
+
+#define M_ASN1_D2I_get_seq(r,func,free_func) \
+ M_ASN1_D2I_get_imp_set(r,func,free_func,\
+ V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
+
+#define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \
+ M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\
+ V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)
+
+#define M_ASN1_D2I_get_seq_opt(r,func,free_func) \
+ if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
+ V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\
+ { M_ASN1_D2I_get_seq(r,func,free_func); }
+
+#define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \
+ if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
+ V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\
+ { M_ASN1_D2I_get_seq_type(type,r,func,free_func); }
+
+#define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \
+ M_ASN1_D2I_get_imp_set(r,func,free_func,\
+ x,V_ASN1_CONTEXT_SPECIFIC);
+
+#define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \
+ M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\
+ x,V_ASN1_CONTEXT_SPECIFIC);
+
+#define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \
+ c.q=c.p; \
+ if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\
+ (void (*)())free_func,a,b) == NULL) \
+ { c.line=__LINE__; goto err; } \
+ c.slen-=(c.p-c.q);
+
+#define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \
+ c.q=c.p; \
+ if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\
+ free_func,a,b) == NULL) \
+ { c.line=__LINE__; goto err; } \
+ c.slen-=(c.p-c.q);
+
+#define M_ASN1_D2I_get_set_strings(r,func,a,b) \
+ c.q=c.p; \
+ if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \
+ { c.line=__LINE__; goto err; } \
+ c.slen-=(c.p-c.q);
+
+#define M_ASN1_D2I_get_EXP_opt(r,func,tag) \
+ if ((c.slen != 0L) && (M_ASN1_next == \
+ (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
+ { \
+ int Tinf,Ttag,Tclass; \
+ long Tlen; \
+ \
+ c.q=c.p; \
+ Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
+ if (Tinf & 0x80) \
+ { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
+ c.line=__LINE__; goto err; } \
+ if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
+ Tlen = c.slen - (c.p - c.q) - 2; \
+ if (func(&(r),&c.p,Tlen) == NULL) \
+ { c.line=__LINE__; goto err; } \
+ if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
+ Tlen = c.slen - (c.p - c.q); \
+ if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \
+ { c.error=ERR_R_MISSING_ASN1_EOS; \
+ c.line=__LINE__; goto err; } \
+ }\
+ c.slen-=(c.p-c.q); \
+ }
+
+#define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \
+ if ((c.slen != 0) && (M_ASN1_next == \
+ (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
+ { \
+ int Tinf,Ttag,Tclass; \
+ long Tlen; \
+ \
+ c.q=c.p; \
+ Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
+ if (Tinf & 0x80) \
+ { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
+ c.line=__LINE__; goto err; } \
+ if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
+ Tlen = c.slen - (c.p - c.q) - 2; \
+ if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \
+ (void (*)())free_func, \
+ b,V_ASN1_UNIVERSAL) == NULL) \
+ { c.line=__LINE__; goto err; } \
+ if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
+ Tlen = c.slen - (c.p - c.q); \
+ if(!ASN1_check_infinite_end(&c.p, Tlen)) \
+ { c.error=ERR_R_MISSING_ASN1_EOS; \
+ c.line=__LINE__; goto err; } \
+ }\
+ c.slen-=(c.p-c.q); \
+ }
+
+#define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \
+ if ((c.slen != 0) && (M_ASN1_next == \
+ (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
+ { \
+ int Tinf,Ttag,Tclass; \
+ long Tlen; \
+ \
+ c.q=c.p; \
+ Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
+ if (Tinf & 0x80) \
+ { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
+ c.line=__LINE__; goto err; } \
+ if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
+ Tlen = c.slen - (c.p - c.q) - 2; \
+ if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \
+ free_func,b,V_ASN1_UNIVERSAL) == NULL) \
+ { c.line=__LINE__; goto err; } \
+ if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
+ Tlen = c.slen - (c.p - c.q); \
+ if(!ASN1_check_infinite_end(&c.p, Tlen)) \
+ { c.error=ERR_R_MISSING_ASN1_EOS; \
+ c.line=__LINE__; goto err; } \
+ }\
+ c.slen-=(c.p-c.q); \
+ }
+
+/* New macros */
+#define M_ASN1_New_Malloc(ret,type) \
+ if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \
+ { c.line=__LINE__; goto err2; }
+
+#define M_ASN1_New(arg,func) \
+ if (((arg)=func()) == NULL) return(NULL)
+
+#define M_ASN1_New_Error(a) \
+/* err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \
+ return(NULL);*/ \
+ err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \
+ return(NULL)
+
+
+/* BIG UGLY WARNING! This is so damn ugly I wanna puke. Unfortunately,
+ some macros that use ASN1_const_CTX still insist on writing in the input
+ stream. ARGH! ARGH! ARGH! Let's get rid of this macro package.
+ Please? -- Richard Levitte */
+#define M_ASN1_next (*((unsigned char *)(c.p)))
+#define M_ASN1_next_prev (*((unsigned char *)(c.q)))
+
+/*************************************************/
+
+#define M_ASN1_I2D_vars(a) int r=0,ret=0; \
+ unsigned char *p; \
+ if (a == NULL) return(0)
+
+/* Length Macros */
+#define M_ASN1_I2D_len(a,f) ret+=f(a,NULL)
+#define M_ASN1_I2D_len_IMP_opt(a,f) if (a != NULL) M_ASN1_I2D_len(a,f)
+
+#define M_ASN1_I2D_len_SET(a,f) \
+ ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);
+
+#define M_ASN1_I2D_len_SET_type(type,a,f) \
+ ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \
+ V_ASN1_UNIVERSAL,IS_SET);
+
+#define M_ASN1_I2D_len_SEQUENCE(a,f) \
+ ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \
+ IS_SEQUENCE);
+
+#define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \
+ ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \
+ V_ASN1_UNIVERSAL,IS_SEQUENCE)
+
+#define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ M_ASN1_I2D_len_SEQUENCE(a,f);
+
+#define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \
+ if ((a != NULL) && (sk_##type##_num(a) != 0)) \
+ M_ASN1_I2D_len_SEQUENCE_type(type,a,f);
+
+#define M_ASN1_I2D_len_IMP_SET(a,f,x) \
+ ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET);
+
+#define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \
+ ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
+ V_ASN1_CONTEXT_SPECIFIC,IS_SET);
+
+#define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
+ IS_SET);
+
+#define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \
+ if ((a != NULL) && (sk_##type##_num(a) != 0)) \
+ ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
+ V_ASN1_CONTEXT_SPECIFIC,IS_SET);
+
+#define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \
+ ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
+ IS_SEQUENCE);
+
+#define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
+ IS_SEQUENCE);
+
+#define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \
+ if ((a != NULL) && (sk_##type##_num(a) != 0)) \
+ ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
+ V_ASN1_CONTEXT_SPECIFIC, \
+ IS_SEQUENCE);
+
+#define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \
+ if (a != NULL)\
+ { \
+ v=f(a,NULL); \
+ ret+=ASN1_object_size(1,v,mtag); \
+ }
+
+#define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \
+ if ((a != NULL) && (sk_num(a) != 0))\
+ { \
+ v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \
+ ret+=ASN1_object_size(1,v,mtag); \
+ }
+
+#define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \
+ if ((a != NULL) && (sk_num(a) != 0))\
+ { \
+ v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \
+ IS_SEQUENCE); \
+ ret+=ASN1_object_size(1,v,mtag); \
+ }
+
+#define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \
+ if ((a != NULL) && (sk_##type##_num(a) != 0))\
+ { \
+ v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \
+ V_ASN1_UNIVERSAL, \
+ IS_SEQUENCE); \
+ ret+=ASN1_object_size(1,v,mtag); \
+ }
+
+/* Put Macros */
+#define M_ASN1_I2D_put(a,f) f(a,&p)
+
+#define M_ASN1_I2D_put_IMP_opt(a,f,t) \
+ if (a != NULL) \
+ { \
+ unsigned char *q=p; \
+ f(a,&p); \
+ *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\
+ }
+
+#define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\
+ V_ASN1_UNIVERSAL,IS_SET)
+#define M_ASN1_I2D_put_SET_type(type,a,f) \
+ i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET)
+#define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\
+ V_ASN1_CONTEXT_SPECIFIC,IS_SET)
+#define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \
+ i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET)
+#define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\
+ V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE)
+
+#define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\
+ V_ASN1_UNIVERSAL,IS_SEQUENCE)
+
+#define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \
+ i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \
+ IS_SEQUENCE)
+
+#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ M_ASN1_I2D_put_SEQUENCE(a,f);
+
+#define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \
+ IS_SET); }
+
+#define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \
+ if ((a != NULL) && (sk_##type##_num(a) != 0)) \
+ { i2d_ASN1_SET_OF_##type(a,&p,f,x, \
+ V_ASN1_CONTEXT_SPECIFIC, \
+ IS_SET); }
+
+#define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \
+ IS_SEQUENCE); }
+
+#define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \
+ if ((a != NULL) && (sk_##type##_num(a) != 0)) \
+ { i2d_ASN1_SET_OF_##type(a,&p,f,x, \
+ V_ASN1_CONTEXT_SPECIFIC, \
+ IS_SEQUENCE); }
+
+#define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \
+ if (a != NULL) \
+ { \
+ ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \
+ f(a,&p); \
+ }
+
+#define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ { \
+ ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
+ i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \
+ }
+
+#define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \
+ if ((a != NULL) && (sk_num(a) != 0)) \
+ { \
+ ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
+ i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \
+ }
+
+#define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \
+ if ((a != NULL) && (sk_##type##_num(a) != 0)) \
+ { \
+ ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
+ i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \
+ IS_SEQUENCE); \
+ }
+
+#define M_ASN1_I2D_seq_total() \
+ r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \
+ if (pp == NULL) return(r); \
+ p= *pp; \
+ ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)
+
+#define M_ASN1_I2D_INF_seq_start(tag,ctx) \
+ *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \
+ *(p++)=0x80
+
+#define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00
+
+#define M_ASN1_I2D_finish() *pp=p; \
+ return(r);
+
+int asn1_GetSequence(ASN1_const_CTX *c, long *length);
+void asn1_add_error(const unsigned char *address,int offset);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1t.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1t.h
new file mode 100644
index 000000000..ac14f9415
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/asn1t.h
@@ -0,0 +1,893 @@
+/* asn1t.h */
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
+ * project 2000.
+ */
+/* ====================================================================
+ * Copyright (c) 2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+#ifndef HEADER_ASN1T_H
+#define HEADER_ASN1T_H
+
+#include <stddef.h>
+#include <openssl/e_os2.h>
+#include <openssl/asn1.h>
+
+#ifdef OPENSSL_BUILD_SHLIBCRYPTO
+# undef OPENSSL_EXTERN
+# define OPENSSL_EXTERN OPENSSL_EXPORT
+#endif
+
+/* ASN1 template defines, structures and functions */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
+
+/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
+#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
+
+
+/* Macros for start and end of ASN1_ITEM definition */
+
+#define ASN1_ITEM_start(itname) \
+ OPENSSL_GLOBAL const ASN1_ITEM itname##_it = {
+
+#define ASN1_ITEM_end(itname) \
+ };
+
+#else
+
+/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
+#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr()))
+
+
+/* Macros for start and end of ASN1_ITEM definition */
+
+#define ASN1_ITEM_start(itname) \
+ const ASN1_ITEM * itname##_it(void) \
+ { \
+ static const ASN1_ITEM local_it = {
+
+#define ASN1_ITEM_end(itname) \
+ }; \
+ return &local_it; \
+ }
+
+#endif
+
+
+/* Macros to aid ASN1 template writing */
+
+#define ASN1_ITEM_TEMPLATE(tname) \
+ static const ASN1_TEMPLATE tname##_item_tt
+
+#define ASN1_ITEM_TEMPLATE_END(tname) \
+ ;\
+ ASN1_ITEM_start(tname) \
+ ASN1_ITYPE_PRIMITIVE,\
+ -1,\
+ &tname##_item_tt,\
+ 0,\
+ NULL,\
+ 0,\
+ #tname \
+ ASN1_ITEM_end(tname)
+
+
+/* This is a ASN1 type which just embeds a template */
+
+/* This pair helps declare a SEQUENCE. We can do:
+ *
+ * ASN1_SEQUENCE(stname) = {
+ * ... SEQUENCE components ...
+ * } ASN1_SEQUENCE_END(stname)
+ *
+ * This will produce an ASN1_ITEM called stname_it
+ * for a structure called stname.
+ *
+ * If you want the same structure but a different
+ * name then use:
+ *
+ * ASN1_SEQUENCE(itname) = {
+ * ... SEQUENCE components ...
+ * } ASN1_SEQUENCE_END_name(stname, itname)
+ *
+ * This will create an item called itname_it using
+ * a structure called stname.
+ */
+
+#define ASN1_SEQUENCE(tname) \
+ static const ASN1_TEMPLATE tname##_seq_tt[]
+
+#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
+
+#define ASN1_SEQUENCE_END_name(stname, tname) \
+ ;\
+ ASN1_ITEM_start(tname) \
+ ASN1_ITYPE_SEQUENCE,\
+ V_ASN1_SEQUENCE,\
+ tname##_seq_tt,\
+ sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
+ NULL,\
+ sizeof(stname),\
+ #stname \
+ ASN1_ITEM_end(tname)
+
+#define ASN1_NDEF_SEQUENCE(tname) \
+ ASN1_SEQUENCE(tname)
+
+#define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
+ ASN1_SEQUENCE_cb(tname, cb)
+
+#define ASN1_SEQUENCE_cb(tname, cb) \
+ static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
+ ASN1_SEQUENCE(tname)
+
+#define ASN1_BROKEN_SEQUENCE(tname) \
+ static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
+ ASN1_SEQUENCE(tname)
+
+#define ASN1_SEQUENCE_ref(tname, cb, lck) \
+ static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \
+ ASN1_SEQUENCE(tname)
+
+#define ASN1_SEQUENCE_enc(tname, enc, cb) \
+ static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
+ ASN1_SEQUENCE(tname)
+
+#define ASN1_NDEF_SEQUENCE_END(tname) \
+ ;\
+ ASN1_ITEM_start(tname) \
+ ASN1_ITYPE_NDEF_SEQUENCE,\
+ V_ASN1_SEQUENCE,\
+ tname##_seq_tt,\
+ sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
+ NULL,\
+ sizeof(tname),\
+ #tname \
+ ASN1_ITEM_end(tname)
+
+#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
+
+#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
+
+#define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
+
+#define ASN1_SEQUENCE_END_ref(stname, tname) \
+ ;\
+ ASN1_ITEM_start(tname) \
+ ASN1_ITYPE_SEQUENCE,\
+ V_ASN1_SEQUENCE,\
+ tname##_seq_tt,\
+ sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
+ &tname##_aux,\
+ sizeof(stname),\
+ #stname \
+ ASN1_ITEM_end(tname)
+
+
+/* This pair helps declare a CHOICE type. We can do:
+ *
+ * ASN1_CHOICE(chname) = {
+ * ... CHOICE options ...
+ * ASN1_CHOICE_END(chname)
+ *
+ * This will produce an ASN1_ITEM called chname_it
+ * for a structure called chname. The structure
+ * definition must look like this:
+ * typedef struct {
+ * int type;
+ * union {
+ * ASN1_SOMETHING *opt1;
+ * ASN1_SOMEOTHER *opt2;
+ * } value;
+ * } chname;
+ *
+ * the name of the selector must be 'type'.
+ * to use an alternative selector name use the
+ * ASN1_CHOICE_END_selector() version.
+ */
+
+#define ASN1_CHOICE(tname) \
+ static const ASN1_TEMPLATE tname##_ch_tt[]
+
+#define ASN1_CHOICE_cb(tname, cb) \
+ static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
+ ASN1_CHOICE(tname)
+
+#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
+
+#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
+
+#define ASN1_CHOICE_END_selector(stname, tname, selname) \
+ ;\
+ ASN1_ITEM_start(tname) \
+ ASN1_ITYPE_CHOICE,\
+ offsetof(stname,selname) ,\
+ tname##_ch_tt,\
+ sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
+ NULL,\
+ sizeof(stname),\
+ #stname \
+ ASN1_ITEM_end(tname)
+
+#define ASN1_CHOICE_END_cb(stname, tname, selname) \
+ ;\
+ ASN1_ITEM_start(tname) \
+ ASN1_ITYPE_CHOICE,\
+ offsetof(stname,selname) ,\
+ tname##_ch_tt,\
+ sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
+ &tname##_aux,\
+ sizeof(stname),\
+ #stname \
+ ASN1_ITEM_end(tname)
+
+/* This helps with the template wrapper form of ASN1_ITEM */
+
+#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
+ (flags), (tag), 0,\
+ #name, ASN1_ITEM_ref(type) }
+
+/* These help with SEQUENCE or CHOICE components */
+
+/* used to declare other types */
+
+#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
+ (flags), (tag), offsetof(stname, field),\
+ #field, ASN1_ITEM_ref(type) }
+
+/* used when the structure is combined with the parent */
+
+#define ASN1_EX_COMBINE(flags, tag, type) { \
+ (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) }
+
+/* implicit and explicit helper macros */
+
+#define ASN1_IMP_EX(stname, field, type, tag, ex) \
+ ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)
+
+#define ASN1_EXP_EX(stname, field, type, tag, ex) \
+ ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)
+
+/* Any defined by macros: the field used is in the table itself */
+
+#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
+#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
+#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
+#else
+#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
+#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }
+#endif
+/* Plain simple type */
+#define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
+
+/* OPTIONAL simple type */
+#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
+
+/* IMPLICIT tagged simple type */
+#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
+
+/* IMPLICIT tagged OPTIONAL simple type */
+#define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
+
+/* Same as above but EXPLICIT */
+
+#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
+#define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
+
+/* SEQUENCE OF type */
+#define ASN1_SEQUENCE_OF(stname, field, type) \
+ ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
+
+/* OPTIONAL SEQUENCE OF */
+#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
+ ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
+
+/* Same as above but for SET OF */
+
+#define ASN1_SET_OF(stname, field, type) \
+ ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
+
+#define ASN1_SET_OF_OPT(stname, field, type) \
+ ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
+
+/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
+
+#define ASN1_IMP_SET_OF(stname, field, type, tag) \
+ ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
+
+#define ASN1_EXP_SET_OF(stname, field, type, tag) \
+ ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
+
+#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
+ ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
+
+#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
+ ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
+
+#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
+ ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
+
+#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
+ ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
+
+#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
+ ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
+
+#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
+ ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
+
+/* EXPLICIT using indefinite length constructed form */
+#define ASN1_NDEF_EXP(stname, field, type, tag) \
+ ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
+
+/* EXPLICIT OPTIONAL using indefinite length constructed form */
+#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
+ ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
+
+/* Macros for the ASN1_ADB structure */
+
+#define ASN1_ADB(name) \
+ static const ASN1_ADB_TABLE name##_adbtbl[]
+
+#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
+
+#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
+ ;\
+ static const ASN1_ADB name##_adb = {\
+ flags,\
+ offsetof(name, field),\
+ app_table,\
+ name##_adbtbl,\
+ sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
+ def,\
+ none\
+ }
+
+#else
+
+#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
+ ;\
+ static const ASN1_ITEM *name##_adb(void) \
+ { \
+ static const ASN1_ADB internal_adb = \
+ {\
+ flags,\
+ offsetof(name, field),\
+ app_table,\
+ name##_adbtbl,\
+ sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
+ def,\
+ none\
+ }; \
+ return (const ASN1_ITEM *) &internal_adb; \
+ } \
+ void dummy_function(void)
+
+#endif
+
+#define ADB_ENTRY(val, template) {val, template}
+
+#define ASN1_ADB_TEMPLATE(name) \
+ static const ASN1_TEMPLATE name##_tt
+
+/* This is the ASN1 template structure that defines
+ * a wrapper round the actual type. It determines the
+ * actual position of the field in the value structure,
+ * various flags such as OPTIONAL and the field name.
+ */
+
+struct ASN1_TEMPLATE_st {
+unsigned long flags; /* Various flags */
+long tag; /* tag, not used if no tagging */
+unsigned long offset; /* Offset of this field in structure */
+#ifndef NO_ASN1_FIELD_NAMES
+const char *field_name; /* Field name */
+#endif
+ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */
+};
+
+/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
+
+#define ASN1_TEMPLATE_item(t) (t->item_ptr)
+#define ASN1_TEMPLATE_adb(t) (t->item_ptr)
+
+typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
+typedef struct ASN1_ADB_st ASN1_ADB;
+
+struct ASN1_ADB_st {
+ unsigned long flags; /* Various flags */
+ unsigned long offset; /* Offset of selector field */
+ STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */
+ const ASN1_ADB_TABLE *tbl; /* Table of possible types */
+ long tblcount; /* Number of entries in tbl */
+ const ASN1_TEMPLATE *default_tt; /* Type to use if no match */
+ const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */
+};
+
+struct ASN1_ADB_TABLE_st {
+ long value; /* NID for an object or value for an int */
+ const ASN1_TEMPLATE tt; /* item for this value */
+};
+
+/* template flags */
+
+/* Field is optional */
+#define ASN1_TFLG_OPTIONAL (0x1)
+
+/* Field is a SET OF */
+#define ASN1_TFLG_SET_OF (0x1 << 1)
+
+/* Field is a SEQUENCE OF */
+#define ASN1_TFLG_SEQUENCE_OF (0x2 << 1)
+
+/* Special case: this refers to a SET OF that
+ * will be sorted into DER order when encoded *and*
+ * the corresponding STACK will be modified to match
+ * the new order.
+ */
+#define ASN1_TFLG_SET_ORDER (0x3 << 1)
+
+/* Mask for SET OF or SEQUENCE OF */
+#define ASN1_TFLG_SK_MASK (0x3 << 1)
+
+/* These flags mean the tag should be taken from the
+ * tag field. If EXPLICIT then the underlying type
+ * is used for the inner tag.
+ */
+
+/* IMPLICIT tagging */
+#define ASN1_TFLG_IMPTAG (0x1 << 3)
+
+
+/* EXPLICIT tagging, inner tag from underlying type */
+#define ASN1_TFLG_EXPTAG (0x2 << 3)
+
+#define ASN1_TFLG_TAG_MASK (0x3 << 3)
+
+/* context specific IMPLICIT */
+#define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT
+
+/* context specific EXPLICIT */
+#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT
+
+/* If tagging is in force these determine the
+ * type of tag to use. Otherwise the tag is
+ * determined by the underlying type. These
+ * values reflect the actual octet format.
+ */
+
+/* Universal tag */
+#define ASN1_TFLG_UNIVERSAL (0x0<<6)
+/* Application tag */
+#define ASN1_TFLG_APPLICATION (0x1<<6)
+/* Context specific tag */
+#define ASN1_TFLG_CONTEXT (0x2<<6)
+/* Private tag */
+#define ASN1_TFLG_PRIVATE (0x3<<6)
+
+#define ASN1_TFLG_TAG_CLASS (0x3<<6)
+
+/* These are for ANY DEFINED BY type. In this case
+ * the 'item' field points to an ASN1_ADB structure
+ * which contains a table of values to decode the
+ * relevant type
+ */
+
+#define ASN1_TFLG_ADB_MASK (0x3<<8)
+
+#define ASN1_TFLG_ADB_OID (0x1<<8)
+
+#define ASN1_TFLG_ADB_INT (0x1<<9)
+
+/* This flag means a parent structure is passed
+ * instead of the field: this is useful is a
+ * SEQUENCE is being combined with a CHOICE for
+ * example. Since this means the structure and
+ * item name will differ we need to use the
+ * ASN1_CHOICE_END_name() macro for example.
+ */
+
+#define ASN1_TFLG_COMBINE (0x1<<10)
+
+/* This flag when present in a SEQUENCE OF, SET OF
+ * or EXPLICIT causes indefinite length constructed
+ * encoding to be used if required.
+ */
+
+#define ASN1_TFLG_NDEF (0x1<<11)
+
+/* This is the actual ASN1 item itself */
+
+struct ASN1_ITEM_st {
+char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */
+long utype; /* underlying type */
+const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */
+long tcount; /* Number of templates if SEQUENCE or CHOICE */
+const void *funcs; /* functions that handle this type */
+long size; /* Structure size (usually)*/
+#ifndef NO_ASN1_FIELD_NAMES
+const char *sname; /* Structure name */
+#endif
+};
+
+/* These are values for the itype field and
+ * determine how the type is interpreted.
+ *
+ * For PRIMITIVE types the underlying type
+ * determines the behaviour if items is NULL.
+ *
+ * Otherwise templates must contain a single
+ * template and the type is treated in the
+ * same way as the type specified in the template.
+ *
+ * For SEQUENCE types the templates field points
+ * to the members, the size field is the
+ * structure size.
+ *
+ * For CHOICE types the templates field points
+ * to each possible member (typically a union)
+ * and the 'size' field is the offset of the
+ * selector.
+ *
+ * The 'funcs' field is used for application
+ * specific functions.
+ *
+ * For COMPAT types the funcs field gives a
+ * set of functions that handle this type, this
+ * supports the old d2i, i2d convention.
+ *
+ * The EXTERN type uses a new style d2i/i2d.
+ * The new style should be used where possible
+ * because it avoids things like the d2i IMPLICIT
+ * hack.
+ *
+ * MSTRING is a multiple string type, it is used
+ * for a CHOICE of character strings where the
+ * actual strings all occupy an ASN1_STRING
+ * structure. In this case the 'utype' field
+ * has a special meaning, it is used as a mask
+ * of acceptable types using the B_ASN1 constants.
+ *
+ * NDEF_SEQUENCE is the same as SEQUENCE except
+ * that it will use indefinite length constructed
+ * encoding if requested.
+ *
+ */
+
+#define ASN1_ITYPE_PRIMITIVE 0x0
+
+#define ASN1_ITYPE_SEQUENCE 0x1
+
+#define ASN1_ITYPE_CHOICE 0x2
+
+#define ASN1_ITYPE_COMPAT 0x3
+
+#define ASN1_ITYPE_EXTERN 0x4
+
+#define ASN1_ITYPE_MSTRING 0x5
+
+#define ASN1_ITYPE_NDEF_SEQUENCE 0x6
+
+/* Cache for ASN1 tag and length, so we
+ * don't keep re-reading it for things
+ * like CHOICE
+ */
+
+struct ASN1_TLC_st{
+ char valid; /* Values below are valid */
+ int ret; /* return value */
+ long plen; /* length */
+ int ptag; /* class value */
+ int pclass; /* class value */
+ int hdrlen; /* header length */
+};
+
+/* Typedefs for ASN1 function pointers */
+
+typedef ASN1_VALUE * ASN1_new_func(void);
+typedef void ASN1_free_func(ASN1_VALUE *a);
+typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, long length);
+typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in);
+
+typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it,
+ int tag, int aclass, char opt, ASN1_TLC *ctx);
+
+typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass);
+typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
+typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
+
+typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
+typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
+
+typedef struct ASN1_COMPAT_FUNCS_st {
+ ASN1_new_func *asn1_new;
+ ASN1_free_func *asn1_free;
+ ASN1_d2i_func *asn1_d2i;
+ ASN1_i2d_func *asn1_i2d;
+} ASN1_COMPAT_FUNCS;
+
+typedef struct ASN1_EXTERN_FUNCS_st {
+ void *app_data;
+ ASN1_ex_new_func *asn1_ex_new;
+ ASN1_ex_free_func *asn1_ex_free;
+ ASN1_ex_free_func *asn1_ex_clear;
+ ASN1_ex_d2i *asn1_ex_d2i;
+ ASN1_ex_i2d *asn1_ex_i2d;
+} ASN1_EXTERN_FUNCS;
+
+typedef struct ASN1_PRIMITIVE_FUNCS_st {
+ void *app_data;
+ unsigned long flags;
+ ASN1_ex_new_func *prim_new;
+ ASN1_ex_free_func *prim_free;
+ ASN1_ex_free_func *prim_clear;
+ ASN1_primitive_c2i *prim_c2i;
+ ASN1_primitive_i2c *prim_i2c;
+} ASN1_PRIMITIVE_FUNCS;
+
+/* This is the ASN1_AUX structure: it handles various
+ * miscellaneous requirements. For example the use of
+ * reference counts and an informational callback.
+ *
+ * The "informational callback" is called at various
+ * points during the ASN1 encoding and decoding. It can
+ * be used to provide minor customisation of the structures
+ * used. This is most useful where the supplied routines
+ * *almost* do the right thing but need some extra help
+ * at a few points. If the callback returns zero then
+ * it is assumed a fatal error has occurred and the
+ * main operation should be abandoned.
+ *
+ * If major changes in the default behaviour are required
+ * then an external type is more appropriate.
+ */
+
+typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it);
+
+typedef struct ASN1_AUX_st {
+ void *app_data;
+ int flags;
+ int ref_offset; /* Offset of reference value */
+ int ref_lock; /* Lock type to use */
+ ASN1_aux_cb *asn1_cb;
+ int enc_offset; /* Offset of ASN1_ENCODING structure */
+} ASN1_AUX;
+
+/* Flags in ASN1_AUX */
+
+/* Use a reference count */
+#define ASN1_AFLG_REFCOUNT 1
+/* Save the encoding of structure (useful for signatures) */
+#define ASN1_AFLG_ENCODING 2
+/* The Sequence length is invalid */
+#define ASN1_AFLG_BROKEN 4
+
+/* operation values for asn1_cb */
+
+#define ASN1_OP_NEW_PRE 0
+#define ASN1_OP_NEW_POST 1
+#define ASN1_OP_FREE_PRE 2
+#define ASN1_OP_FREE_POST 3
+#define ASN1_OP_D2I_PRE 4
+#define ASN1_OP_D2I_POST 5
+#define ASN1_OP_I2D_PRE 6
+#define ASN1_OP_I2D_POST 7
+
+/* Macro to implement a primitive type */
+#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
+#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
+ ASN1_ITEM_start(itname) \
+ ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
+ ASN1_ITEM_end(itname)
+
+/* Macro to implement a multi string type */
+#define IMPLEMENT_ASN1_MSTRING(itname, mask) \
+ ASN1_ITEM_start(itname) \
+ ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
+ ASN1_ITEM_end(itname)
+
+/* Macro to implement an ASN1_ITEM in terms of old style funcs */
+
+#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)
+
+#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \
+ static const ASN1_COMPAT_FUNCS sname##_ff = { \
+ (ASN1_new_func *)sname##_new, \
+ (ASN1_free_func *)sname##_free, \
+ (ASN1_d2i_func *)d2i_##sname, \
+ (ASN1_i2d_func *)i2d_##sname, \
+ }; \
+ ASN1_ITEM_start(sname) \
+ ASN1_ITYPE_COMPAT, \
+ tag, \
+ NULL, \
+ 0, \
+ &sname##_ff, \
+ 0, \
+ #sname \
+ ASN1_ITEM_end(sname)
+
+#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
+ ASN1_ITEM_start(sname) \
+ ASN1_ITYPE_EXTERN, \
+ tag, \
+ NULL, \
+ 0, \
+ &fptrs, \
+ 0, \
+ #sname \
+ ASN1_ITEM_end(sname)
+
+/* Macro to implement standard functions in terms of ASN1_ITEM structures */
+
+#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
+
+#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
+
+#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
+ IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
+
+#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
+ IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
+
+#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
+ stname *fname##_new(void) \
+ { \
+ return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
+ } \
+ void fname##_free(stname *a) \
+ { \
+ ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
+ }
+
+#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
+ IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
+ IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
+
+#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
+ stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
+ { \
+ return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
+ } \
+ int i2d_##fname(stname *a, unsigned char **out) \
+ { \
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
+ }
+
+#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
+ int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
+ { \
+ return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
+ }
+
+/* This includes evil casts to remove const: they will go away when full
+ * ASN1 constification is done.
+ */
+#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
+ stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
+ { \
+ return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
+ } \
+ int i2d_##fname(const stname *a, unsigned char **out) \
+ { \
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
+ }
+
+#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
+ stname * stname##_dup(stname *x) \
+ { \
+ return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
+ }
+
+#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
+ IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
+
+#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \
+ IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
+ IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
+
+/* external definitions for primitive types */
+
+DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
+DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
+DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
+DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
+DECLARE_ASN1_ITEM(CBIGNUM)
+DECLARE_ASN1_ITEM(BIGNUM)
+DECLARE_ASN1_ITEM(LONG)
+DECLARE_ASN1_ITEM(ZLONG)
+
+DECLARE_STACK_OF(ASN1_VALUE)
+
+/* Functions used internally by the ASN1 code */
+
+int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
+void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
+int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
+int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
+
+void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
+int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt);
+int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it,
+ int tag, int aclass, char opt, ASN1_TLC *ctx);
+
+int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass);
+int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt);
+void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
+
+int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
+int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
+
+int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
+int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it);
+
+ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
+
+const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr);
+
+int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);
+
+void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);
+void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
+int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it);
+int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/bio.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/bio.h
new file mode 100644
index 000000000..cecb6a720
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/bio.h
@@ -0,0 +1,776 @@
+/* crypto/bio/bio.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_BIO_H
+#define HEADER_BIO_H
+
+#include <openssl/e_os2.h>
+
+#ifndef OPENSSL_NO_FP_API
+# include <stdio.h>
+#endif
+#include <stdarg.h>
+
+#include <openssl/crypto.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These are the 'types' of BIOs */
+#define BIO_TYPE_NONE 0
+#define BIO_TYPE_MEM (1|0x0400)
+#define BIO_TYPE_FILE (2|0x0400)
+
+#define BIO_TYPE_FD (4|0x0400|0x0100)
+#define BIO_TYPE_SOCKET (5|0x0400|0x0100)
+#define BIO_TYPE_NULL (6|0x0400)
+#define BIO_TYPE_SSL (7|0x0200)
+#define BIO_TYPE_MD (8|0x0200) /* passive filter */
+#define BIO_TYPE_BUFFER (9|0x0200) /* filter */
+#define BIO_TYPE_CIPHER (10|0x0200) /* filter */
+#define BIO_TYPE_BASE64 (11|0x0200) /* filter */
+#define BIO_TYPE_CONNECT (12|0x0400|0x0100) /* socket - connect */
+#define BIO_TYPE_ACCEPT (13|0x0400|0x0100) /* socket for accept */
+#define BIO_TYPE_PROXY_CLIENT (14|0x0200) /* client proxy BIO */
+#define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */
+#define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */
+#define BIO_TYPE_NULL_FILTER (17|0x0200)
+#define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */
+#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */
+#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */
+#define BIO_TYPE_DGRAM (21|0x0400|0x0100)
+#define BIO_TYPE_COMP (23|0x0200) /* filter */
+
+#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
+#define BIO_TYPE_FILTER 0x0200
+#define BIO_TYPE_SOURCE_SINK 0x0400
+
+/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
+ * BIO_set_fp(in,stdin,BIO_NOCLOSE); */
+#define BIO_NOCLOSE 0x00
+#define BIO_CLOSE 0x01
+
+/* These are used in the following macros and are passed to
+ * BIO_ctrl() */
+#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */
+#define BIO_CTRL_EOF 2 /* opt - are we at the eof */
+#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */
+#define BIO_CTRL_SET 4 /* man - set the 'IO' type */
+#define BIO_CTRL_GET 5 /* man - get the 'IO' type */
+#define BIO_CTRL_PUSH 6 /* opt - internal, used to signify change */
+#define BIO_CTRL_POP 7 /* opt - internal, used to signify change */
+#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */
+#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */
+#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */
+#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */
+#define BIO_CTRL_DUP 12 /* man - extra stuff for 'duped' BIO */
+#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */
+/* callback is int cb(BIO *bio,state,ret); */
+#define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback function */
+#define BIO_CTRL_GET_CALLBACK 15 /* opt - set callback function */
+
+#define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */
+
+/* dgram BIO stuff */
+#define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */
+#define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally
+ * connected socket to be
+ * passed in */
+#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */
+#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */
+#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */
+#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */
+
+#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */
+#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */
+
+/* #ifdef IP_MTU_DISCOVER */
+#define BIO_CTRL_DGRAM_MTU_DISCOVER 39 /* set DF bit on egress packets */
+/* #endif */
+
+#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */
+#define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */
+#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for
+ * MTU. want to use this
+ * if asking the kernel
+ * fails */
+
+#define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU
+ * was exceed in the
+ * previous write
+ * operation */
+
+#define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */
+
+
+/* modifiers */
+#define BIO_FP_READ 0x02
+#define BIO_FP_WRITE 0x04
+#define BIO_FP_APPEND 0x08
+#define BIO_FP_TEXT 0x10
+
+#define BIO_FLAGS_READ 0x01
+#define BIO_FLAGS_WRITE 0x02
+#define BIO_FLAGS_IO_SPECIAL 0x04
+#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
+#define BIO_FLAGS_SHOULD_RETRY 0x08
+#ifndef BIO_FLAGS_UPLINK
+/* "UPLINK" flag denotes file descriptors provided by application.
+ It defaults to 0, as most platforms don't require UPLINK interface. */
+#define BIO_FLAGS_UPLINK 0
+#endif
+
+/* Used in BIO_gethostbyname() */
+#define BIO_GHBN_CTRL_HITS 1
+#define BIO_GHBN_CTRL_MISSES 2
+#define BIO_GHBN_CTRL_CACHE_SIZE 3
+#define BIO_GHBN_CTRL_GET_ENTRY 4
+#define BIO_GHBN_CTRL_FLUSH 5
+
+/* Mostly used in the SSL BIO */
+/* Not used anymore
+ * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10
+ * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20
+ * #define BIO_FLAGS_PROTOCOL_STARTUP 0x40
+ */
+
+#define BIO_FLAGS_BASE64_NO_NL 0x100
+
+/* This is used with memory BIOs: it means we shouldn't free up or change the
+ * data in any way.
+ */
+#define BIO_FLAGS_MEM_RDONLY 0x200
+
+typedef struct bio_st BIO;
+
+void BIO_set_flags(BIO *b, int flags);
+int BIO_test_flags(const BIO *b, int flags);
+void BIO_clear_flags(BIO *b, int flags);
+
+#define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
+#define BIO_set_retry_special(b) \
+ BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
+#define BIO_set_retry_read(b) \
+ BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
+#define BIO_set_retry_write(b) \
+ BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
+
+/* These are normally used internally in BIOs */
+#define BIO_clear_retry_flags(b) \
+ BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
+#define BIO_get_retry_flags(b) \
+ BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
+
+/* These should be used by the application to tell why we should retry */
+#define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ)
+#define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE)
+#define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
+#define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS)
+#define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
+
+/* The next three are used in conjunction with the
+ * BIO_should_io_special() condition. After this returns true,
+ * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO
+ * stack and return the 'reason' for the special and the offending BIO.
+ * Given a BIO, BIO_get_retry_reason(bio) will return the code. */
+/* Returned from the SSL bio when the certificate retrieval code had an error */
+#define BIO_RR_SSL_X509_LOOKUP 0x01
+/* Returned from the connect BIO when a connect would have blocked */
+#define BIO_RR_CONNECT 0x02
+/* Returned from the accept BIO when an accept would have blocked */
+#define BIO_RR_ACCEPT 0x03
+
+/* These are passed by the BIO callback */
+#define BIO_CB_FREE 0x01
+#define BIO_CB_READ 0x02
+#define BIO_CB_WRITE 0x03
+#define BIO_CB_PUTS 0x04
+#define BIO_CB_GETS 0x05
+#define BIO_CB_CTRL 0x06
+
+/* The callback is called before and after the underling operation,
+ * The BIO_CB_RETURN flag indicates if it is after the call */
+#define BIO_CB_RETURN 0x80
+#define BIO_CB_return(a) ((a)|BIO_CB_RETURN))
+#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN))
+#define BIO_cb_post(a) ((a)&BIO_CB_RETURN)
+
+long (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long);
+void BIO_set_callback(BIO *b,
+ long (*callback)(struct bio_st *,int,const char *,int, long,long));
+char *BIO_get_callback_arg(const BIO *b);
+void BIO_set_callback_arg(BIO *b, char *arg);
+
+const char * BIO_method_name(const BIO *b);
+int BIO_method_type(const BIO *b);
+
+typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
+
+#ifndef OPENSSL_SYS_WIN16
+typedef struct bio_method_st
+ {
+ int type;
+ const char *name;
+ int (*bwrite)(BIO *, const char *, int);
+ int (*bread)(BIO *, char *, int);
+ int (*bputs)(BIO *, const char *);
+ int (*bgets)(BIO *, char *, int);
+ long (*ctrl)(BIO *, int, long, void *);
+ int (*create)(BIO *);
+ int (*destroy)(BIO *);
+ long (*callback_ctrl)(BIO *, int, bio_info_cb *);
+ } BIO_METHOD;
+#else
+typedef struct bio_method_st
+ {
+ int type;
+ const char *name;
+ int (_far *bwrite)();
+ int (_far *bread)();
+ int (_far *bputs)();
+ int (_far *bgets)();
+ long (_far *ctrl)();
+ int (_far *create)();
+ int (_far *destroy)();
+ long (_far *callback_ctrl)();
+ } BIO_METHOD;
+#endif
+
+struct bio_st
+ {
+ BIO_METHOD *method;
+ /* bio, mode, argp, argi, argl, ret */
+ long (*callback)(struct bio_st *,int,const char *,int, long,long);
+ char *cb_arg; /* first argument for the callback */
+
+ int init;
+ int shutdown;
+ int flags; /* extra storage */
+ int retry_reason;
+ int num;
+ void *ptr;
+ struct bio_st *next_bio; /* used by filter BIOs */
+ struct bio_st *prev_bio; /* used by filter BIOs */
+ int references;
+ unsigned long num_read;
+ unsigned long num_write;
+
+ CRYPTO_EX_DATA ex_data;
+ };
+
+DECLARE_STACK_OF(BIO)
+
+typedef struct bio_f_buffer_ctx_struct
+ {
+ /* BIO *bio; */ /* this is now in the BIO struct */
+ int ibuf_size; /* how big is the input buffer */
+ int obuf_size; /* how big is the output buffer */
+
+ char *ibuf; /* the char array */
+ int ibuf_len; /* how many bytes are in it */
+ int ibuf_off; /* write/read offset */
+
+ char *obuf; /* the char array */
+ int obuf_len; /* how many bytes are in it */
+ int obuf_off; /* write/read offset */
+ } BIO_F_BUFFER_CTX;
+
+/* connect BIO stuff */
+#define BIO_CONN_S_BEFORE 1
+#define BIO_CONN_S_GET_IP 2
+#define BIO_CONN_S_GET_PORT 3
+#define BIO_CONN_S_CREATE_SOCKET 4
+#define BIO_CONN_S_CONNECT 5
+#define BIO_CONN_S_OK 6
+#define BIO_CONN_S_BLOCKED_CONNECT 7
+#define BIO_CONN_S_NBIO 8
+/*#define BIO_CONN_get_param_hostname BIO_ctrl */
+
+#define BIO_C_SET_CONNECT 100
+#define BIO_C_DO_STATE_MACHINE 101
+#define BIO_C_SET_NBIO 102
+#define BIO_C_SET_PROXY_PARAM 103
+#define BIO_C_SET_FD 104
+#define BIO_C_GET_FD 105
+#define BIO_C_SET_FILE_PTR 106
+#define BIO_C_GET_FILE_PTR 107
+#define BIO_C_SET_FILENAME 108
+#define BIO_C_SET_SSL 109
+#define BIO_C_GET_SSL 110
+#define BIO_C_SET_MD 111
+#define BIO_C_GET_MD 112
+#define BIO_C_GET_CIPHER_STATUS 113
+#define BIO_C_SET_BUF_MEM 114
+#define BIO_C_GET_BUF_MEM_PTR 115
+#define BIO_C_GET_BUFF_NUM_LINES 116
+#define BIO_C_SET_BUFF_SIZE 117
+#define BIO_C_SET_ACCEPT 118
+#define BIO_C_SSL_MODE 119
+#define BIO_C_GET_MD_CTX 120
+#define BIO_C_GET_PROXY_PARAM 121
+#define BIO_C_SET_BUFF_READ_DATA 122 /* data to read first */
+#define BIO_C_GET_CONNECT 123
+#define BIO_C_GET_ACCEPT 124
+#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125
+#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126
+#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127
+#define BIO_C_FILE_SEEK 128
+#define BIO_C_GET_CIPHER_CTX 129
+#define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/
+#define BIO_C_SET_BIND_MODE 131
+#define BIO_C_GET_BIND_MODE 132
+#define BIO_C_FILE_TELL 133
+#define BIO_C_GET_SOCKS 134
+#define BIO_C_SET_SOCKS 135
+
+#define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */
+#define BIO_C_GET_WRITE_BUF_SIZE 137
+#define BIO_C_MAKE_BIO_PAIR 138
+#define BIO_C_DESTROY_BIO_PAIR 139
+#define BIO_C_GET_WRITE_GUARANTEE 140
+#define BIO_C_GET_READ_REQUEST 141
+#define BIO_C_SHUTDOWN_WR 142
+#define BIO_C_NREAD0 143
+#define BIO_C_NREAD 144
+#define BIO_C_NWRITE0 145
+#define BIO_C_NWRITE 146
+#define BIO_C_RESET_READ_REQUEST 147
+#define BIO_C_SET_MD_CTX 148
+
+
+#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
+#define BIO_get_app_data(s) BIO_get_ex_data(s,0)
+
+/* BIO_s_connect() and BIO_s_socks4a_connect() */
+#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
+#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
+#define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
+#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
+#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
+#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
+#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
+#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3)
+
+
+#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
+
+/* BIO_s_accept_socket() */
+#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
+#define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
+/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
+#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL)
+#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)
+
+#define BIO_BIND_NORMAL 0
+#define BIO_BIND_REUSEADDR_IF_UNUSED 1
+#define BIO_BIND_REUSEADDR 2
+#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
+#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
+
+#define BIO_do_connect(b) BIO_do_handshake(b)
+#define BIO_do_accept(b) BIO_do_handshake(b)
+#define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
+
+/* BIO_s_proxy_client() */
+#define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))
+#define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))
+/* BIO_set_nbio(b,n) */
+#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
+/* BIO *BIO_get_filter_bio(BIO *bio); */
+#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
+#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
+#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)
+
+#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)
+#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))
+#define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))
+#define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)
+
+#define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
+#define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
+
+#define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
+#define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
+
+#define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
+#define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
+
+/* name is cast to lose const, but might be better to route through a function
+ so we can do it safely */
+#ifdef CONST_STRICT
+/* If you are wondering why this isn't defined, its because CONST_STRICT is
+ * purely a compile-time kludge to allow const to be checked.
+ */
+int BIO_read_filename(BIO *b,const char *name);
+#else
+#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
+ BIO_CLOSE|BIO_FP_READ,(char *)name)
+#endif
+#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
+ BIO_CLOSE|BIO_FP_WRITE,name)
+#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
+ BIO_CLOSE|BIO_FP_APPEND,name)
+#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
+ BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
+
+/* WARNING WARNING, this ups the reference count on the read bio of the
+ * SSL structure. This is because the ssl read BIO is now pointed to by
+ * the next_bio field in the bio. So when you free the BIO, make sure
+ * you are doing a BIO_free_all() to catch the underlying BIO. */
+#define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
+#define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
+#define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
+#define BIO_set_ssl_renegotiate_bytes(b,num) \
+ BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
+#define BIO_get_num_renegotiates(b) \
+ BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL);
+#define BIO_set_ssl_renegotiate_timeout(b,seconds) \
+ BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);
+
+/* defined in evp.h */
+/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
+
+#define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
+#define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
+#define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
+#define BIO_set_mem_eof_return(b,v) \
+ BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
+
+/* For the BIO_f_buffer() type */
+#define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
+#define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
+#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
+#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
+#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
+
+/* Don't use the next one unless you know what you are doing :-) */
+#define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
+
+#define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
+#define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
+#define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
+#define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
+#define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
+#define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
+/* ...pending macros have inappropriate return type */
+size_t BIO_ctrl_pending(BIO *b);
+size_t BIO_ctrl_wpending(BIO *b);
+#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
+#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
+ cbp)
+#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
+
+/* For the BIO_f_buffer() type */
+#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
+
+/* For BIO_s_bio() */
+#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
+#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
+#define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
+#define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
+#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
+/* macros with inappropriate type -- but ...pending macros use int too: */
+#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
+#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
+size_t BIO_ctrl_get_write_guarantee(BIO *b);
+size_t BIO_ctrl_get_read_request(BIO *b);
+int BIO_ctrl_reset_read_request(BIO *b);
+
+/* ctrl macros for dgram */
+#define BIO_ctrl_dgram_connect(b,peer) \
+ (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)
+#define BIO_ctrl_set_connected(b, state, peer) \
+ (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)
+#define BIO_dgram_recv_timedout(b) \
+ (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
+#define BIO_dgram_send_timedout(b) \
+ (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
+#define BIO_dgram_set_peer(b,peer) \
+ (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
+
+/* These two aren't currently implemented */
+/* int BIO_get_ex_num(BIO *bio); */
+/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
+int BIO_set_ex_data(BIO *bio,int idx,void *data);
+void *BIO_get_ex_data(BIO *bio,int idx);
+int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+unsigned long BIO_number_read(BIO *bio);
+unsigned long BIO_number_written(BIO *bio);
+
+# ifndef OPENSSL_NO_FP_API
+# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL)
+BIO_METHOD *BIO_s_file_internal(void);
+BIO *BIO_new_file_internal(char *filename, char *mode);
+BIO *BIO_new_fp_internal(FILE *stream, int close_flag);
+# define BIO_s_file BIO_s_file_internal
+# define BIO_new_file BIO_new_file_internal
+# define BIO_new_fp BIO_new_fp_internal
+# else /* FP_API */
+BIO_METHOD *BIO_s_file(void );
+BIO *BIO_new_file(const char *filename, const char *mode);
+BIO *BIO_new_fp(FILE *stream, int close_flag);
+# define BIO_s_file_internal BIO_s_file
+# define BIO_new_file_internal BIO_new_file
+# define BIO_new_fp_internal BIO_s_file
+# endif /* FP_API */
+# endif
+BIO * BIO_new(BIO_METHOD *type);
+int BIO_set(BIO *a,BIO_METHOD *type);
+int BIO_free(BIO *a);
+void BIO_vfree(BIO *a);
+int BIO_read(BIO *b, void *data, int len);
+int BIO_gets(BIO *bp,char *buf, int size);
+int BIO_write(BIO *b, const void *data, int len);
+int BIO_puts(BIO *bp,const char *buf);
+int BIO_indent(BIO *b,int indent,int max);
+long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
+long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
+char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
+long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
+BIO * BIO_push(BIO *b,BIO *append);
+BIO * BIO_pop(BIO *b);
+void BIO_free_all(BIO *a);
+BIO * BIO_find_type(BIO *b,int bio_type);
+BIO * BIO_next(BIO *b);
+BIO * BIO_get_retry_BIO(BIO *bio, int *reason);
+int BIO_get_retry_reason(BIO *bio);
+BIO * BIO_dup_chain(BIO *in);
+
+int BIO_nread0(BIO *bio, char **buf);
+int BIO_nread(BIO *bio, char **buf, int num);
+int BIO_nwrite0(BIO *bio, char **buf);
+int BIO_nwrite(BIO *bio, char **buf, int num);
+
+#ifndef OPENSSL_SYS_WIN16
+long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
+ long argl,long ret);
+#else
+long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
+ long argl,long ret);
+#endif
+
+BIO_METHOD *BIO_s_mem(void);
+BIO *BIO_new_mem_buf(void *buf, int len);
+BIO_METHOD *BIO_s_socket(void);
+BIO_METHOD *BIO_s_connect(void);
+BIO_METHOD *BIO_s_accept(void);
+BIO_METHOD *BIO_s_fd(void);
+#ifndef OPENSSL_SYS_OS2
+BIO_METHOD *BIO_s_log(void);
+#endif
+BIO_METHOD *BIO_s_bio(void);
+BIO_METHOD *BIO_s_null(void);
+BIO_METHOD *BIO_f_null(void);
+BIO_METHOD *BIO_f_buffer(void);
+#ifdef OPENSSL_SYS_VMS
+BIO_METHOD *BIO_f_linebuffer(void);
+#endif
+BIO_METHOD *BIO_f_nbio_test(void);
+#ifndef OPENSSL_NO_DGRAM
+BIO_METHOD *BIO_s_datagram(void);
+#endif
+
+/* BIO_METHOD *BIO_f_ber(void); */
+
+int BIO_sock_should_retry(int i);
+int BIO_sock_non_fatal_error(int error);
+int BIO_dgram_non_fatal_error(int error);
+
+int BIO_fd_should_retry(int i);
+int BIO_fd_non_fatal_error(int error);
+int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u),
+ void *u, const char *s, int len);
+int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
+ void *u, const char *s, int len, int indent);
+int BIO_dump(BIO *b,const char *bytes,int len);
+int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
+#ifndef OPENSSL_NO_FP_API
+int BIO_dump_fp(FILE *fp, const char *s, int len);
+int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
+#endif
+struct hostent *BIO_gethostbyname(const char *name);
+/* We might want a thread-safe interface too:
+ * struct hostent *BIO_gethostbyname_r(const char *name,
+ * struct hostent *result, void *buffer, size_t buflen);
+ * or something similar (caller allocates a struct hostent,
+ * pointed to by "result", and additional buffer space for the various
+ * substructures; if the buffer does not suffice, NULL is returned
+ * and an appropriate error code is set).
+ */
+int BIO_sock_error(int sock);
+int BIO_socket_ioctl(int fd, long type, void *arg);
+int BIO_socket_nbio(int fd,int mode);
+int BIO_get_port(const char *str, unsigned short *port_ptr);
+int BIO_get_host_ip(const char *str, unsigned char *ip);
+int BIO_get_accept_socket(char *host_port,int mode);
+int BIO_accept(int sock,char **ip_port);
+int BIO_sock_init(void );
+void BIO_sock_cleanup(void);
+int BIO_set_tcp_ndelay(int sock,int turn_on);
+
+BIO *BIO_new_socket(int sock, int close_flag);
+BIO *BIO_new_dgram(int fd, int close_flag);
+BIO *BIO_new_fd(int fd, int close_flag);
+BIO *BIO_new_connect(char *host_port);
+BIO *BIO_new_accept(char *host_port);
+
+int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
+ BIO **bio2, size_t writebuf2);
+/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
+ * Otherwise returns 0 and sets *bio1 and *bio2 to NULL.
+ * Size 0 uses default value.
+ */
+
+void BIO_copy_next_retry(BIO *b);
+
+/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/
+
+#ifdef __GNUC__
+# define __bio_h__attr__ __attribute__
+#else
+# define __bio_h__attr__(x)
+#endif
+int BIO_printf(BIO *bio, const char *format, ...)
+ __bio_h__attr__((__format__(__printf__,2,3)));
+int BIO_vprintf(BIO *bio, const char *format, va_list args)
+ __bio_h__attr__((__format__(__printf__,2,0)));
+int BIO_snprintf(char *buf, size_t n, const char *format, ...)
+ __bio_h__attr__((__format__(__printf__,3,4)));
+int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
+ __bio_h__attr__((__format__(__printf__,3,0)));
+#undef __bio_h__attr__
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_BIO_strings(void);
+
+/* Error codes for the BIO functions. */
+
+/* Function codes. */
+#define BIO_F_ACPT_STATE 100
+#define BIO_F_BIO_ACCEPT 101
+#define BIO_F_BIO_BER_GET_HEADER 102
+#define BIO_F_BIO_CALLBACK_CTRL 131
+#define BIO_F_BIO_CTRL 103
+#define BIO_F_BIO_GETHOSTBYNAME 120
+#define BIO_F_BIO_GETS 104
+#define BIO_F_BIO_GET_ACCEPT_SOCKET 105
+#define BIO_F_BIO_GET_HOST_IP 106
+#define BIO_F_BIO_GET_PORT 107
+#define BIO_F_BIO_MAKE_PAIR 121
+#define BIO_F_BIO_NEW 108
+#define BIO_F_BIO_NEW_FILE 109
+#define BIO_F_BIO_NEW_MEM_BUF 126
+#define BIO_F_BIO_NREAD 123
+#define BIO_F_BIO_NREAD0 124
+#define BIO_F_BIO_NWRITE 125
+#define BIO_F_BIO_NWRITE0 122
+#define BIO_F_BIO_PUTS 110
+#define BIO_F_BIO_READ 111
+#define BIO_F_BIO_SOCK_INIT 112
+#define BIO_F_BIO_WRITE 113
+#define BIO_F_BUFFER_CTRL 114
+#define BIO_F_CONN_CTRL 127
+#define BIO_F_CONN_STATE 115
+#define BIO_F_FILE_CTRL 116
+#define BIO_F_FILE_READ 130
+#define BIO_F_LINEBUFFER_CTRL 129
+#define BIO_F_MEM_READ 128
+#define BIO_F_MEM_WRITE 117
+#define BIO_F_SSL_NEW 118
+#define BIO_F_WSASTARTUP 119
+
+/* Reason codes. */
+#define BIO_R_ACCEPT_ERROR 100
+#define BIO_R_BAD_FOPEN_MODE 101
+#define BIO_R_BAD_HOSTNAME_LOOKUP 102
+#define BIO_R_BROKEN_PIPE 124
+#define BIO_R_CONNECT_ERROR 103
+#define BIO_R_EOF_ON_MEMORY_BIO 127
+#define BIO_R_ERROR_SETTING_NBIO 104
+#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105
+#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106
+#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107
+#define BIO_R_INVALID_ARGUMENT 125
+#define BIO_R_INVALID_IP_ADDRESS 108
+#define BIO_R_IN_USE 123
+#define BIO_R_KEEPALIVE 109
+#define BIO_R_NBIO_CONNECT_ERROR 110
+#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111
+#define BIO_R_NO_HOSTNAME_SPECIFIED 112
+#define BIO_R_NO_PORT_DEFINED 113
+#define BIO_R_NO_PORT_SPECIFIED 114
+#define BIO_R_NO_SUCH_FILE 128
+#define BIO_R_NULL_PARAMETER 115
+#define BIO_R_TAG_MISMATCH 116
+#define BIO_R_UNABLE_TO_BIND_SOCKET 117
+#define BIO_R_UNABLE_TO_CREATE_SOCKET 118
+#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119
+#define BIO_R_UNINITIALIZED 120
+#define BIO_R_UNSUPPORTED_METHOD 121
+#define BIO_R_WRITE_TO_READ_ONLY_BIO 126
+#define BIO_R_WSASTARTUP 122
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/blowfish.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/blowfish.h
new file mode 100644
index 000000000..d24ffccb6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/blowfish.h
@@ -0,0 +1,129 @@
+/* crypto/bf/blowfish.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_BLOWFISH_H
+#define HEADER_BLOWFISH_H
+
+#include <openssl/e_os2.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef OPENSSL_NO_BF
+#error BF is disabled.
+#endif
+
+#define BF_ENCRYPT 1
+#define BF_DECRYPT 0
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * ! BF_LONG has to be at least 32 bits wide. If it's wider, then !
+ * ! BF_LONG_LOG2 has to be defined along. !
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ */
+
+#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
+#define BF_LONG unsigned long
+#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
+#define BF_LONG unsigned long
+#define BF_LONG_LOG2 3
+/*
+ * _CRAY note. I could declare short, but I have no idea what impact
+ * does it have on performance on none-T3E machines. I could declare
+ * int, but at least on C90 sizeof(int) can be chosen at compile time.
+ * So I've chosen long...
+ * <appro@fy.chalmers.se>
+ */
+#else
+#define BF_LONG unsigned int
+#endif
+
+#define BF_ROUNDS 16
+#define BF_BLOCK 8
+
+typedef struct bf_key_st
+ {
+ BF_LONG P[BF_ROUNDS+2];
+ BF_LONG S[4*256];
+ } BF_KEY;
+
+#ifdef OPENSSL_FIPS
+void private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);
+#endif
+void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
+
+void BF_encrypt(BF_LONG *data,const BF_KEY *key);
+void BF_decrypt(BF_LONG *data,const BF_KEY *key);
+
+void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
+ const BF_KEY *key, int enc);
+void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
+ const BF_KEY *schedule, unsigned char *ivec, int enc);
+void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length,
+ const BF_KEY *schedule, unsigned char *ivec, int *num, int enc);
+void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length,
+ const BF_KEY *schedule, unsigned char *ivec, int *num);
+const char *BF_options(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/bn.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/bn.h
new file mode 100644
index 000000000..f1719a587
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/bn.h
@@ -0,0 +1,855 @@
+/* crypto/bn/bn.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ *
+ * Portions of the attached software ("Contribution") are developed by
+ * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
+ *
+ * The Contribution is licensed pursuant to the Eric Young open source
+ * license provided above.
+ *
+ * The binary polynomial arithmetic software is originally written by
+ * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
+ *
+ */
+
+#ifndef HEADER_BN_H
+#define HEADER_BN_H
+
+#include <openssl/e_os2.h>
+#ifndef OPENSSL_NO_FP_API
+#include <stdio.h> /* FILE */
+#endif
+#include <openssl/ossl_typ.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These preprocessor symbols control various aspects of the bignum headers and
+ * library code. They're not defined by any "normal" configuration, as they are
+ * intended for development and testing purposes. NB: defining all three can be
+ * useful for debugging application code as well as openssl itself.
+ *
+ * BN_DEBUG - turn on various debugging alterations to the bignum code
+ * BN_DEBUG_RAND - uses random poisoning of unused words to trip up
+ * mismanagement of bignum internals. You must also define BN_DEBUG.
+ */
+/* #define BN_DEBUG */
+/* #define BN_DEBUG_RAND */
+
+#define BN_MUL_COMBA
+#define BN_SQR_COMBA
+#define BN_RECURSION
+
+/* This next option uses the C libraries (2 word)/(1 word) function.
+ * If it is not defined, I use my C version (which is slower).
+ * The reason for this flag is that when the particular C compiler
+ * library routine is used, and the library is linked with a different
+ * compiler, the library is missing. This mostly happens when the
+ * library is built with gcc and then linked using normal cc. This would
+ * be a common occurrence because gcc normally produces code that is
+ * 2 times faster than system compilers for the big number stuff.
+ * For machines with only one compiler (or shared libraries), this should
+ * be on. Again this in only really a problem on machines
+ * using "long long's", are 32bit, and are not using my assembler code. */
+#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \
+ defined(OPENSSL_SYS_WIN32) || defined(linux)
+# ifndef BN_DIV2W
+# define BN_DIV2W
+# endif
+#endif
+
+/* assuming long is 64bit - this is the DEC Alpha
+ * unsigned long long is only 64 bits :-(, don't define
+ * BN_LLONG for the DEC Alpha */
+#ifdef SIXTY_FOUR_BIT_LONG
+#define BN_ULLONG unsigned long long
+#define BN_ULONG unsigned long
+#define BN_LONG long
+#define BN_BITS 128
+#define BN_BYTES 8
+#define BN_BITS2 64
+#define BN_BITS4 32
+#define BN_MASK (0xffffffffffffffffffffffffffffffffLL)
+#define BN_MASK2 (0xffffffffffffffffL)
+#define BN_MASK2l (0xffffffffL)
+#define BN_MASK2h (0xffffffff00000000L)
+#define BN_MASK2h1 (0xffffffff80000000L)
+#define BN_TBIT (0x8000000000000000L)
+#define BN_DEC_CONV (10000000000000000000UL)
+#define BN_DEC_FMT1 "%lu"
+#define BN_DEC_FMT2 "%019lu"
+#define BN_DEC_NUM 19
+#endif
+
+/* This is where the long long data type is 64 bits, but long is 32.
+ * For machines where there are 64bit registers, this is the mode to use.
+ * IRIX, on R4000 and above should use this mode, along with the relevant
+ * assembler code :-). Do NOT define BN_LLONG.
+ */
+#ifdef SIXTY_FOUR_BIT
+#undef BN_LLONG
+#undef BN_ULLONG
+#define BN_ULONG unsigned long long
+#define BN_LONG long long
+#define BN_BITS 128
+#define BN_BYTES 8
+#define BN_BITS2 64
+#define BN_BITS4 32
+#define BN_MASK2 (0xffffffffffffffffLL)
+#define BN_MASK2l (0xffffffffL)
+#define BN_MASK2h (0xffffffff00000000LL)
+#define BN_MASK2h1 (0xffffffff80000000LL)
+#define BN_TBIT (0x8000000000000000LL)
+#define BN_DEC_CONV (10000000000000000000ULL)
+#define BN_DEC_FMT1 "%llu"
+#define BN_DEC_FMT2 "%019llu"
+#define BN_DEC_NUM 19
+#endif
+
+#ifdef THIRTY_TWO_BIT
+#ifdef BN_LLONG
+# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__)
+# define BN_ULLONG unsigned __int64
+# else
+# define BN_ULLONG unsigned long long
+# endif
+#endif
+#define BN_ULONG unsigned long
+#define BN_LONG long
+#define BN_BITS 64
+#define BN_BYTES 4
+#define BN_BITS2 32
+#define BN_BITS4 16
+#ifdef OPENSSL_SYS_WIN32
+/* VC++ doesn't like the LL suffix */
+#define BN_MASK (0xffffffffffffffffL)
+#else
+#define BN_MASK (0xffffffffffffffffLL)
+#endif
+#define BN_MASK2 (0xffffffffL)
+#define BN_MASK2l (0xffff)
+#define BN_MASK2h1 (0xffff8000L)
+#define BN_MASK2h (0xffff0000L)
+#define BN_TBIT (0x80000000L)
+#define BN_DEC_CONV (1000000000L)
+#define BN_DEC_FMT1 "%lu"
+#define BN_DEC_FMT2 "%09lu"
+#define BN_DEC_NUM 9
+#endif
+
+#ifdef SIXTEEN_BIT
+#ifndef BN_DIV2W
+#define BN_DIV2W
+#endif
+#define BN_ULLONG unsigned long
+#define BN_ULONG unsigned short
+#define BN_LONG short
+#define BN_BITS 32
+#define BN_BYTES 2
+#define BN_BITS2 16
+#define BN_BITS4 8
+#define BN_MASK (0xffffffff)
+#define BN_MASK2 (0xffff)
+#define BN_MASK2l (0xff)
+#define BN_MASK2h1 (0xff80)
+#define BN_MASK2h (0xff00)
+#define BN_TBIT (0x8000)
+#define BN_DEC_CONV (100000)
+#define BN_DEC_FMT1 "%u"
+#define BN_DEC_FMT2 "%05u"
+#define BN_DEC_NUM 5
+#endif
+
+#ifdef EIGHT_BIT
+#ifndef BN_DIV2W
+#define BN_DIV2W
+#endif
+#define BN_ULLONG unsigned short
+#define BN_ULONG unsigned char
+#define BN_LONG char
+#define BN_BITS 16
+#define BN_BYTES 1
+#define BN_BITS2 8
+#define BN_BITS4 4
+#define BN_MASK (0xffff)
+#define BN_MASK2 (0xff)
+#define BN_MASK2l (0xf)
+#define BN_MASK2h1 (0xf8)
+#define BN_MASK2h (0xf0)
+#define BN_TBIT (0x80)
+#define BN_DEC_CONV (100)
+#define BN_DEC_FMT1 "%u"
+#define BN_DEC_FMT2 "%02u"
+#define BN_DEC_NUM 2
+#endif
+
+#define BN_DEFAULT_BITS 1280
+
+#define BN_FLG_MALLOCED 0x01
+#define BN_FLG_STATIC_DATA 0x02
+#define BN_FLG_CONSTTIME 0x04 /* avoid leaking exponent information through timing,
+ * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,
+ * BN_div() will call BN_div_no_branch,
+ * BN_mod_inverse() will call BN_mod_inverse_no_branch.
+ */
+
+#ifndef OPENSSL_NO_DEPRECATED
+#define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME /* deprecated name for the flag */
+ /* avoid leaking exponent information through timings
+ * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */
+#endif
+
+#ifndef OPENSSL_NO_DEPRECATED
+#define BN_FLG_FREE 0x8000 /* used for debuging */
+#endif
+#define BN_set_flags(b,n) ((b)->flags|=(n))
+#define BN_get_flags(b,n) ((b)->flags&(n))
+
+/* get a clone of a BIGNUM with changed flags, for *temporary* use only
+ * (the two BIGNUMs cannot not be used in parallel!) */
+#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \
+ (dest)->top=(b)->top, \
+ (dest)->dmax=(b)->dmax, \
+ (dest)->neg=(b)->neg, \
+ (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \
+ | ((b)->flags & ~BN_FLG_MALLOCED) \
+ | BN_FLG_STATIC_DATA \
+ | (n)))
+
+/* Already declared in ossl_typ.h */
+#if 0
+typedef struct bignum_st BIGNUM;
+/* Used for temp variables (declaration hidden in bn_lcl.h) */
+typedef struct bignum_ctx BN_CTX;
+typedef struct bn_blinding_st BN_BLINDING;
+typedef struct bn_mont_ctx_st BN_MONT_CTX;
+typedef struct bn_recp_ctx_st BN_RECP_CTX;
+typedef struct bn_gencb_st BN_GENCB;
+#endif
+
+struct bignum_st
+ {
+ BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
+ int top; /* Index of last used d +1. */
+ /* The next are internal book keeping for bn_expand. */
+ int dmax; /* Size of the d array. */
+ int neg; /* one if the number is negative */
+ int flags;
+ };
+
+/* Used for montgomery multiplication */
+struct bn_mont_ctx_st
+ {
+ int ri; /* number of bits in R */
+ BIGNUM RR; /* used to convert to montgomery form */
+ BIGNUM N; /* The modulus */
+ BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
+ * (Ni is only stored for bignum algorithm) */
+#if 0
+ /* OpenSSL 0.9.9 preview: */
+ BN_ULONG n0[2];/* least significant word(s) of Ni */
+#else
+ BN_ULONG n0; /* least significant word of Ni */
+#endif
+ int flags;
+ };
+
+/* Used for reciprocal division/mod functions
+ * It cannot be shared between threads
+ */
+struct bn_recp_ctx_st
+ {
+ BIGNUM N; /* the divisor */
+ BIGNUM Nr; /* the reciprocal */
+ int num_bits;
+ int shift;
+ int flags;
+ };
+
+/* Used for slow "generation" functions. */
+struct bn_gencb_st
+ {
+ unsigned int ver; /* To handle binary (in)compatibility */
+ void *arg; /* callback-specific data */
+ union
+ {
+ /* if(ver==1) - handles old style callbacks */
+ void (*cb_1)(int, int, void *);
+ /* if(ver==2) - new callback style */
+ int (*cb_2)(int, int, BN_GENCB *);
+ } cb;
+ };
+/* Wrapper function to make using BN_GENCB easier, */
+int BN_GENCB_call(BN_GENCB *cb, int a, int b);
+/* Macro to populate a BN_GENCB structure with an "old"-style callback */
+#define BN_GENCB_set_old(gencb, callback, cb_arg) { \
+ BN_GENCB *tmp_gencb = (gencb); \
+ tmp_gencb->ver = 1; \
+ tmp_gencb->arg = (cb_arg); \
+ tmp_gencb->cb.cb_1 = (callback); }
+/* Macro to populate a BN_GENCB structure with a "new"-style callback */
+#define BN_GENCB_set(gencb, callback, cb_arg) { \
+ BN_GENCB *tmp_gencb = (gencb); \
+ tmp_gencb->ver = 2; \
+ tmp_gencb->arg = (cb_arg); \
+ tmp_gencb->cb.cb_2 = (callback); }
+
+#define BN_prime_checks 0 /* default: select number of iterations
+ based on the size of the number */
+
+/* number of Miller-Rabin iterations for an error rate of less than 2^-80
+ * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook
+ * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
+ * original paper: Damgaard, Landrock, Pomerance: Average case error estimates
+ * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */
+#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
+ (b) >= 850 ? 3 : \
+ (b) >= 650 ? 4 : \
+ (b) >= 550 ? 5 : \
+ (b) >= 450 ? 6 : \
+ (b) >= 400 ? 7 : \
+ (b) >= 350 ? 8 : \
+ (b) >= 300 ? 9 : \
+ (b) >= 250 ? 12 : \
+ (b) >= 200 ? 15 : \
+ (b) >= 150 ? 18 : \
+ /* b >= 100 */ 27)
+
+#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
+
+/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */
+#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \
+ (((w) == 0) && ((a)->top == 0)))
+#define BN_is_zero(a) ((a)->top == 0)
+#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg)
+#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))
+#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1))
+
+#define BN_one(a) (BN_set_word((a),1))
+#define BN_zero_ex(a) \
+ do { \
+ BIGNUM *_tmp_bn = (a); \
+ _tmp_bn->top = 0; \
+ _tmp_bn->neg = 0; \
+ } while(0)
+#ifdef OPENSSL_NO_DEPRECATED
+#define BN_zero(a) BN_zero_ex(a)
+#else
+#define BN_zero(a) (BN_set_word((a),0))
+#endif
+
+const BIGNUM *BN_value_one(void);
+char * BN_options(void);
+BN_CTX *BN_CTX_new(void);
+#ifndef OPENSSL_NO_DEPRECATED
+void BN_CTX_init(BN_CTX *c);
+#endif
+void BN_CTX_free(BN_CTX *c);
+void BN_CTX_start(BN_CTX *ctx);
+BIGNUM *BN_CTX_get(BN_CTX *ctx);
+void BN_CTX_end(BN_CTX *ctx);
+int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
+int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
+int BN_num_bits(const BIGNUM *a);
+int BN_num_bits_word(BN_ULONG);
+BIGNUM *BN_new(void);
+void BN_init(BIGNUM *);
+void BN_clear_free(BIGNUM *a);
+BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
+void BN_swap(BIGNUM *a, BIGNUM *b);
+BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
+int BN_bn2bin(const BIGNUM *a, unsigned char *to);
+BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret);
+int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
+int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
+int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx);
+/** BN_set_negative sets sign of a BIGNUM
+ * \param b pointer to the BIGNUM object
+ * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise
+ */
+void BN_set_negative(BIGNUM *b, int n);
+/** BN_is_negative returns 1 if the BIGNUM is negative
+ * \param a pointer to the BIGNUM object
+ * \return 1 if a < 0 and 0 otherwise
+ */
+#define BN_is_negative(a) ((a)->neg != 0)
+
+int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
+ BN_CTX *ctx);
+#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))
+int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
+int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
+int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
+int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
+int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
+int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
+ const BIGNUM *m, BN_CTX *ctx);
+int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
+int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
+int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
+int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx);
+int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
+
+BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
+BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
+int BN_mul_word(BIGNUM *a, BN_ULONG w);
+int BN_add_word(BIGNUM *a, BN_ULONG w);
+int BN_sub_word(BIGNUM *a, BN_ULONG w);
+int BN_set_word(BIGNUM *a, BN_ULONG w);
+BN_ULONG BN_get_word(const BIGNUM *a);
+
+int BN_cmp(const BIGNUM *a, const BIGNUM *b);
+void BN_free(BIGNUM *a);
+int BN_is_bit_set(const BIGNUM *a, int n);
+int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
+int BN_lshift1(BIGNUM *r, const BIGNUM *a);
+int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx);
+
+int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m,BN_CTX *ctx);
+int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
+int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
+int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
+int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
+ const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m,
+ BN_CTX *ctx,BN_MONT_CTX *m_ctx);
+int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m,BN_CTX *ctx);
+
+int BN_mask_bits(BIGNUM *a,int n);
+#ifndef OPENSSL_NO_FP_API
+int BN_print_fp(FILE *fp, const BIGNUM *a);
+#endif
+#ifdef HEADER_BIO_H
+int BN_print(BIO *fp, const BIGNUM *a);
+#else
+int BN_print(void *fp, const BIGNUM *a);
+#endif
+int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
+int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
+int BN_rshift1(BIGNUM *r, const BIGNUM *a);
+void BN_clear(BIGNUM *a);
+BIGNUM *BN_dup(const BIGNUM *a);
+int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
+int BN_set_bit(BIGNUM *a, int n);
+int BN_clear_bit(BIGNUM *a, int n);
+char * BN_bn2hex(const BIGNUM *a);
+char * BN_bn2dec(const BIGNUM *a);
+int BN_hex2bn(BIGNUM **a, const char *str);
+int BN_dec2bn(BIGNUM **a, const char *str);
+int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
+int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */
+BIGNUM *BN_mod_inverse(BIGNUM *ret,
+ const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
+BIGNUM *BN_mod_sqrt(BIGNUM *ret,
+ const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
+
+/* Deprecated versions */
+#ifndef OPENSSL_NO_DEPRECATED
+BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,
+ const BIGNUM *add, const BIGNUM *rem,
+ void (*callback)(int,int,void *),void *cb_arg);
+int BN_is_prime(const BIGNUM *p,int nchecks,
+ void (*callback)(int,int,void *),
+ BN_CTX *ctx,void *cb_arg);
+int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
+ void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
+ int do_trial_division);
+#endif /* !defined(OPENSSL_NO_DEPRECATED) */
+
+/* Newer versions */
+int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add,
+ const BIGNUM *rem, BN_GENCB *cb);
+int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
+int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
+ int do_trial_division, BN_GENCB *cb);
+
+int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
+
+int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
+ const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2,
+ const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
+int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
+ BIGNUM *Xp1, BIGNUM *Xp2,
+ const BIGNUM *Xp,
+ const BIGNUM *e, BN_CTX *ctx,
+ BN_GENCB *cb);
+
+BN_MONT_CTX *BN_MONT_CTX_new(void );
+void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
+int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
+ BN_MONT_CTX *mont, BN_CTX *ctx);
+#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
+ (r),(a),&((mont)->RR),(mont),(ctx))
+int BN_from_montgomery(BIGNUM *r,const BIGNUM *a,
+ BN_MONT_CTX *mont, BN_CTX *ctx);
+void BN_MONT_CTX_free(BN_MONT_CTX *mont);
+int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx);
+BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
+BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
+ const BIGNUM *mod, BN_CTX *ctx);
+
+/* BN_BLINDING flags */
+#define BN_BLINDING_NO_UPDATE 0x00000001
+#define BN_BLINDING_NO_RECREATE 0x00000002
+
+BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, /* const */ BIGNUM *mod);
+void BN_BLINDING_free(BN_BLINDING *b);
+int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
+int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
+int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
+int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
+int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
+unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
+void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
+unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
+void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
+BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
+ const BIGNUM *e, /* const */ BIGNUM *m, BN_CTX *ctx,
+ int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
+ BN_MONT_CTX *m_ctx);
+
+#ifndef OPENSSL_NO_DEPRECATED
+void BN_set_params(int mul,int high,int low,int mont);
+int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */
+#endif
+
+void BN_RECP_CTX_init(BN_RECP_CTX *recp);
+BN_RECP_CTX *BN_RECP_CTX_new(void);
+void BN_RECP_CTX_free(BN_RECP_CTX *recp);
+int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx);
+int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
+ BN_RECP_CTX *recp,BN_CTX *ctx);
+int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx);
+int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
+ BN_RECP_CTX *recp, BN_CTX *ctx);
+
+/* Functions for arithmetic over binary polynomials represented by BIGNUMs.
+ *
+ * The BIGNUM::neg property of BIGNUMs representing binary polynomials is
+ * ignored.
+ *
+ * Note that input arguments are not const so that their bit arrays can
+ * be expanded to the appropriate size if needed.
+ */
+
+int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/
+#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)
+int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/
+int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
+ const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */
+int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ BN_CTX *ctx); /* r = (a * a) mod p */
+int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p,
+ BN_CTX *ctx); /* r = (1 / b) mod p */
+int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
+ const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */
+int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
+ const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */
+int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ BN_CTX *ctx); /* r = sqrt(a) mod p */
+int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ BN_CTX *ctx); /* r^2 + r = a mod p */
+#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))
+/* Some functions allow for representation of the irreducible polynomials
+ * as an unsigned int[], say p. The irreducible f(t) is then of the form:
+ * t^p[0] + t^p[1] + ... + t^p[k]
+ * where m = p[0] > p[1] > ... > p[k] = 0.
+ */
+int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]);
+ /* r = a mod p */
+int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
+ const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */
+int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[],
+ BN_CTX *ctx); /* r = (a * a) mod p */
+int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[],
+ BN_CTX *ctx); /* r = (1 / b) mod p */
+int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
+ const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */
+int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
+ const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */
+int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
+ const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */
+int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
+ const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */
+int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max);
+int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a);
+
+/* faster mod functions for the 'NIST primes'
+ * 0 <= a < p^2 */
+int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
+int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
+int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
+int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
+int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
+
+const BIGNUM *BN_get0_nist_prime_192(void);
+const BIGNUM *BN_get0_nist_prime_224(void);
+const BIGNUM *BN_get0_nist_prime_256(void);
+const BIGNUM *BN_get0_nist_prime_384(void);
+const BIGNUM *BN_get0_nist_prime_521(void);
+
+/* library internal functions */
+
+#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
+ (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
+#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
+BIGNUM *bn_expand2(BIGNUM *a, int words);
+#ifndef OPENSSL_NO_DEPRECATED
+BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
+#endif
+
+/* Bignum consistency macros
+ * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from
+ * bignum data after direct manipulations on the data. There is also an
+ * "internal" macro, bn_check_top(), for verifying that there are no leading
+ * zeroes. Unfortunately, some auditing is required due to the fact that
+ * bn_fix_top() has become an overabused duct-tape because bignum data is
+ * occasionally passed around in an inconsistent state. So the following
+ * changes have been made to sort this out;
+ * - bn_fix_top()s implementation has been moved to bn_correct_top()
+ * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and
+ * bn_check_top() is as before.
+ * - if BN_DEBUG *is* defined;
+ * - bn_check_top() tries to pollute unused words even if the bignum 'top' is
+ * consistent. (ed: only if BN_DEBUG_RAND is defined)
+ * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything.
+ * The idea is to have debug builds flag up inconsistent bignums when they
+ * occur. If that occurs in a bn_fix_top(), we examine the code in question; if
+ * the use of bn_fix_top() was appropriate (ie. it follows directly after code
+ * that manipulates the bignum) it is converted to bn_correct_top(), and if it
+ * was not appropriate, we convert it permanently to bn_check_top() and track
+ * down the cause of the bug. Eventually, no internal code should be using the
+ * bn_fix_top() macro. External applications and libraries should try this with
+ * their own code too, both in terms of building against the openssl headers
+ * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it
+ * defined. This not only improves external code, it provides more test
+ * coverage for openssl's own code.
+ */
+
+#ifdef BN_DEBUG
+
+/* We only need assert() when debugging */
+#include <assert.h>
+
+#ifdef BN_DEBUG_RAND
+/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */
+#ifndef RAND_pseudo_bytes
+int RAND_pseudo_bytes(unsigned char *buf,int num);
+#define BN_DEBUG_TRIX
+#endif
+#define bn_pollute(a) \
+ do { \
+ const BIGNUM *_bnum1 = (a); \
+ if(_bnum1->top < _bnum1->dmax) { \
+ unsigned char _tmp_char; \
+ /* We cast away const without the compiler knowing, any \
+ * *genuinely* constant variables that aren't mutable \
+ * wouldn't be constructed with top!=dmax. */ \
+ BN_ULONG *_not_const; \
+ memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \
+ RAND_pseudo_bytes(&_tmp_char, 1); \
+ memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \
+ (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \
+ } \
+ } while(0)
+#ifdef BN_DEBUG_TRIX
+#undef RAND_pseudo_bytes
+#endif
+#else
+#define bn_pollute(a)
+#endif
+#define bn_check_top(a) \
+ do { \
+ const BIGNUM *_bnum2 = (a); \
+ if (_bnum2 != NULL) { \
+ assert((_bnum2->top == 0) || \
+ (_bnum2->d[_bnum2->top - 1] != 0)); \
+ bn_pollute(_bnum2); \
+ } \
+ } while(0)
+
+#define bn_fix_top(a) bn_check_top(a)
+
+#else /* !BN_DEBUG */
+
+#define bn_pollute(a)
+#define bn_check_top(a)
+#define bn_fix_top(a) bn_correct_top(a)
+
+#endif
+
+#define bn_correct_top(a) \
+ { \
+ BN_ULONG *ftl; \
+ if ((a)->top > 0) \
+ { \
+ for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
+ if (*(ftl--)) break; \
+ } \
+ bn_pollute(a); \
+ }
+
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
+BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
+void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
+BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
+BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
+BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
+
+/* Primes from RFC 2409 */
+BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
+BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);
+
+/* Primes from RFC 3526 */
+BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);
+BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);
+BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);
+BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
+BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
+BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
+
+int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_BN_strings(void);
+
+/* Error codes for the BN functions. */
+
+/* Function codes. */
+#define BN_F_BNRAND 127
+#define BN_F_BN_BLINDING_CONVERT_EX 100
+#define BN_F_BN_BLINDING_CREATE_PARAM 128
+#define BN_F_BN_BLINDING_INVERT_EX 101
+#define BN_F_BN_BLINDING_NEW 102
+#define BN_F_BN_BLINDING_UPDATE 103
+#define BN_F_BN_BN2DEC 104
+#define BN_F_BN_BN2HEX 105
+#define BN_F_BN_CTX_GET 116
+#define BN_F_BN_CTX_NEW 106
+#define BN_F_BN_CTX_START 129
+#define BN_F_BN_DIV 107
+#define BN_F_BN_DIV_NO_BRANCH 138
+#define BN_F_BN_DIV_RECP 130
+#define BN_F_BN_EXP 123
+#define BN_F_BN_EXPAND2 108
+#define BN_F_BN_EXPAND_INTERNAL 120
+#define BN_F_BN_GF2M_MOD 131
+#define BN_F_BN_GF2M_MOD_EXP 132
+#define BN_F_BN_GF2M_MOD_MUL 133
+#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134
+#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135
+#define BN_F_BN_GF2M_MOD_SQR 136
+#define BN_F_BN_GF2M_MOD_SQRT 137
+#define BN_F_BN_MOD_EXP2_MONT 118
+#define BN_F_BN_MOD_EXP_MONT 109
+#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124
+#define BN_F_BN_MOD_EXP_MONT_WORD 117
+#define BN_F_BN_MOD_EXP_RECP 125
+#define BN_F_BN_MOD_EXP_SIMPLE 126
+#define BN_F_BN_MOD_INVERSE 110
+#define BN_F_BN_MOD_INVERSE_NO_BRANCH 139
+#define BN_F_BN_MOD_LSHIFT_QUICK 119
+#define BN_F_BN_MOD_MUL_RECIPROCAL 111
+#define BN_F_BN_MOD_SQRT 121
+#define BN_F_BN_MPI2BN 112
+#define BN_F_BN_NEW 113
+#define BN_F_BN_RAND 114
+#define BN_F_BN_RAND_RANGE 122
+#define BN_F_BN_USUB 115
+
+/* Reason codes. */
+#define BN_R_ARG2_LT_ARG3 100
+#define BN_R_BAD_RECIPROCAL 101
+#define BN_R_BIGNUM_TOO_LONG 114
+#define BN_R_CALLED_WITH_EVEN_MODULUS 102
+#define BN_R_DIV_BY_ZERO 103
+#define BN_R_ENCODING_ERROR 104
+#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
+#define BN_R_INPUT_NOT_REDUCED 110
+#define BN_R_INVALID_LENGTH 106
+#define BN_R_INVALID_RANGE 115
+#define BN_R_NOT_A_SQUARE 111
+#define BN_R_NOT_INITIALIZED 107
+#define BN_R_NO_INVERSE 108
+#define BN_R_NO_SOLUTION 116
+#define BN_R_P_IS_NOT_PRIME 112
+#define BN_R_TOO_MANY_ITERATIONS 113
+#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/buffer.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/buffer.h
new file mode 100644
index 000000000..1db960745
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/buffer.h
@@ -0,0 +1,118 @@
+/* crypto/buffer/buffer.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_BUFFER_H
+#define HEADER_BUFFER_H
+
+#include <openssl/ossl_typ.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+
+#if !defined(NO_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
+/* Already declared in ossl_typ.h */
+/* typedef struct buf_mem_st BUF_MEM; */
+
+struct buf_mem_st
+ {
+ int length; /* current number of bytes */
+ char *data;
+ int max; /* size of buffer */
+ };
+
+BUF_MEM *BUF_MEM_new(void);
+void BUF_MEM_free(BUF_MEM *a);
+int BUF_MEM_grow(BUF_MEM *str, int len);
+int BUF_MEM_grow_clean(BUF_MEM *str, int len);
+char * BUF_strdup(const char *str);
+char * BUF_strndup(const char *str, size_t siz);
+void * BUF_memdup(const void *data, size_t siz);
+
+/* safe string functions */
+size_t BUF_strlcpy(char *dst,const char *src,size_t siz);
+size_t BUF_strlcat(char *dst,const char *src,size_t siz);
+
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_BUF_strings(void);
+
+/* Error codes for the BUF functions. */
+
+/* Function codes. */
+#define BUF_F_BUF_MEMDUP 103
+#define BUF_F_BUF_MEM_GROW 100
+#define BUF_F_BUF_MEM_GROW_CLEAN 105
+#define BUF_F_BUF_MEM_NEW 101
+#define BUF_F_BUF_STRDUP 102
+#define BUF_F_BUF_STRNDUP 104
+
+/* Reason codes. */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/cast.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/cast.h
new file mode 100644
index 000000000..1faf5806a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/cast.h
@@ -0,0 +1,107 @@
+/* crypto/cast/cast.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_CAST_H
+#define HEADER_CAST_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <openssl/opensslconf.h>
+
+#ifdef OPENSSL_NO_CAST
+#error CAST is disabled.
+#endif
+
+#define CAST_ENCRYPT 1
+#define CAST_DECRYPT 0
+
+#define CAST_LONG unsigned long
+
+#define CAST_BLOCK 8
+#define CAST_KEY_LENGTH 16
+
+typedef struct cast_key_st
+ {
+ CAST_LONG data[32];
+ int short_key; /* Use reduced rounds for short key */
+ } CAST_KEY;
+
+#ifdef OPENSSL_FIPS
+void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
+#endif
+void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
+void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key,
+ int enc);
+void CAST_encrypt(CAST_LONG *data,CAST_KEY *key);
+void CAST_decrypt(CAST_LONG *data,CAST_KEY *key);
+void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
+ CAST_KEY *ks, unsigned char *iv, int enc);
+void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
+ long length, CAST_KEY *schedule, unsigned char *ivec,
+ int *num, int enc);
+void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
+ long length, CAST_KEY *schedule, unsigned char *ivec,
+ int *num);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/comp.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/comp.h
new file mode 100644
index 000000000..4b405c7d4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/comp.h
@@ -0,0 +1,80 @@
+
+#ifndef HEADER_COMP_H
+#define HEADER_COMP_H
+
+#include <openssl/crypto.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct comp_ctx_st COMP_CTX;
+
+typedef struct comp_method_st
+ {
+ int type; /* NID for compression library */
+ const char *name; /* A text string to identify the library */
+ int (*init)(COMP_CTX *ctx);
+ void (*finish)(COMP_CTX *ctx);
+ int (*compress)(COMP_CTX *ctx,
+ unsigned char *out, unsigned int olen,
+ unsigned char *in, unsigned int ilen);
+ int (*expand)(COMP_CTX *ctx,
+ unsigned char *out, unsigned int olen,
+ unsigned char *in, unsigned int ilen);
+ /* The following two do NOTHING, but are kept for backward compatibility */
+ long (*ctrl)(void);
+ long (*callback_ctrl)(void);
+ } COMP_METHOD;
+
+struct comp_ctx_st
+ {
+ COMP_METHOD *meth;
+ unsigned long compress_in;
+ unsigned long compress_out;
+ unsigned long expand_in;
+ unsigned long expand_out;
+
+ CRYPTO_EX_DATA ex_data;
+ };
+
+
+COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
+void COMP_CTX_free(COMP_CTX *ctx);
+int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
+ unsigned char *in, int ilen);
+int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
+ unsigned char *in, int ilen);
+COMP_METHOD *COMP_rle(void );
+COMP_METHOD *COMP_zlib(void );
+void COMP_zlib_cleanup(void);
+
+#ifdef HEADER_BIO_H
+#ifdef ZLIB
+BIO_METHOD *BIO_f_zlib(void);
+#endif
+#endif
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_COMP_strings(void);
+
+/* Error codes for the COMP functions. */
+
+/* Function codes. */
+#define COMP_F_BIO_ZLIB_FLUSH 99
+#define COMP_F_BIO_ZLIB_NEW 100
+#define COMP_F_BIO_ZLIB_READ 101
+#define COMP_F_BIO_ZLIB_WRITE 102
+
+/* Reason codes. */
+#define COMP_R_ZLIB_DEFLATE_ERROR 99
+#define COMP_R_ZLIB_INFLATE_ERROR 100
+#define COMP_R_ZLIB_NOT_SUPPORTED 101
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/conf.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/conf.h
new file mode 100644
index 000000000..8aa06bc5e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/conf.h
@@ -0,0 +1,254 @@
+/* crypto/conf/conf.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_CONF_H
+#define HEADER_CONF_H
+
+#include <openssl/bio.h>
+#include <openssl/lhash.h>
+#include <openssl/stack.h>
+#include <openssl/safestack.h>
+#include <openssl/e_os2.h>
+
+#include <openssl/ossl_typ.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+ {
+ char *section;
+ char *name;
+ char *value;
+ } CONF_VALUE;
+
+DECLARE_STACK_OF(CONF_VALUE)
+DECLARE_STACK_OF(CONF_MODULE)
+DECLARE_STACK_OF(CONF_IMODULE)
+
+struct conf_st;
+struct conf_method_st;
+typedef struct conf_method_st CONF_METHOD;
+
+struct conf_method_st
+ {
+ const char *name;
+ CONF *(*create)(CONF_METHOD *meth);
+ int (*init)(CONF *conf);
+ int (*destroy)(CONF *conf);
+ int (*destroy_data)(CONF *conf);
+ int (*load_bio)(CONF *conf, BIO *bp, long *eline);
+ int (*dump)(const CONF *conf, BIO *bp);
+ int (*is_number)(const CONF *conf, char c);
+ int (*to_int)(const CONF *conf, char c);
+ int (*load)(CONF *conf, const char *name, long *eline);
+ };
+
+/* Module definitions */
+
+typedef struct conf_imodule_st CONF_IMODULE;
+typedef struct conf_module_st CONF_MODULE;
+
+/* DSO module function typedefs */
+typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf);
+typedef void conf_finish_func(CONF_IMODULE *md);
+
+#define CONF_MFLAGS_IGNORE_ERRORS 0x1
+#define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2
+#define CONF_MFLAGS_SILENT 0x4
+#define CONF_MFLAGS_NO_DSO 0x8
+#define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10
+#define CONF_MFLAGS_DEFAULT_SECTION 0x20
+
+int CONF_set_default_method(CONF_METHOD *meth);
+void CONF_set_nconf(CONF *conf,LHASH *hash);
+LHASH *CONF_load(LHASH *conf,const char *file,long *eline);
+#ifndef OPENSSL_NO_FP_API
+LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline);
+#endif
+LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline);
+STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section);
+char *CONF_get_string(LHASH *conf,const char *group,const char *name);
+long CONF_get_number(LHASH *conf,const char *group,const char *name);
+void CONF_free(LHASH *conf);
+int CONF_dump_fp(LHASH *conf, FILE *out);
+int CONF_dump_bio(LHASH *conf, BIO *out);
+
+void OPENSSL_config(const char *config_name);
+void OPENSSL_no_config(void);
+
+/* New conf code. The semantics are different from the functions above.
+ If that wasn't the case, the above functions would have been replaced */
+
+struct conf_st
+ {
+ CONF_METHOD *meth;
+ void *meth_data;
+ LHASH *data;
+ };
+
+CONF *NCONF_new(CONF_METHOD *meth);
+CONF_METHOD *NCONF_default(void);
+CONF_METHOD *NCONF_WIN32(void);
+#if 0 /* Just to give you an idea of what I have in mind */
+CONF_METHOD *NCONF_XML(void);
+#endif
+void NCONF_free(CONF *conf);
+void NCONF_free_data(CONF *conf);
+
+int NCONF_load(CONF *conf,const char *file,long *eline);
+#ifndef OPENSSL_NO_FP_API
+int NCONF_load_fp(CONF *conf, FILE *fp,long *eline);
+#endif
+int NCONF_load_bio(CONF *conf, BIO *bp,long *eline);
+STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section);
+char *NCONF_get_string(const CONF *conf,const char *group,const char *name);
+int NCONF_get_number_e(const CONF *conf,const char *group,const char *name,
+ long *result);
+int NCONF_dump_fp(const CONF *conf, FILE *out);
+int NCONF_dump_bio(const CONF *conf, BIO *out);
+
+#if 0 /* The following function has no error checking,
+ and should therefore be avoided */
+long NCONF_get_number(CONF *conf,char *group,char *name);
+#else
+#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)
+#endif
+
+/* Module functions */
+
+int CONF_modules_load(const CONF *cnf, const char *appname,
+ unsigned long flags);
+int CONF_modules_load_file(const char *filename, const char *appname,
+ unsigned long flags);
+void CONF_modules_unload(int all);
+void CONF_modules_finish(void);
+void CONF_modules_free(void);
+int CONF_module_add(const char *name, conf_init_func *ifunc,
+ conf_finish_func *ffunc);
+
+const char *CONF_imodule_get_name(const CONF_IMODULE *md);
+const char *CONF_imodule_get_value(const CONF_IMODULE *md);
+void *CONF_imodule_get_usr_data(const CONF_IMODULE *md);
+void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);
+CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);
+unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);
+void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);
+void *CONF_module_get_usr_data(CONF_MODULE *pmod);
+void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);
+
+char *CONF_get1_default_config_file(void);
+
+int CONF_parse_list(const char *list, int sep, int nospc,
+ int (*list_cb)(const char *elem, int len, void *usr), void *arg);
+
+void OPENSSL_load_builtin_modules(void);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_CONF_strings(void);
+
+/* Error codes for the CONF functions. */
+
+/* Function codes. */
+#define CONF_F_CONF_DUMP_FP 104
+#define CONF_F_CONF_LOAD 100
+#define CONF_F_CONF_LOAD_BIO 102
+#define CONF_F_CONF_LOAD_FP 103
+#define CONF_F_CONF_MODULES_LOAD 116
+#define CONF_F_DEF_LOAD 120
+#define CONF_F_DEF_LOAD_BIO 121
+#define CONF_F_MODULE_INIT 115
+#define CONF_F_MODULE_LOAD_DSO 117
+#define CONF_F_MODULE_RUN 118
+#define CONF_F_NCONF_DUMP_BIO 105
+#define CONF_F_NCONF_DUMP_FP 106
+#define CONF_F_NCONF_GET_NUMBER 107
+#define CONF_F_NCONF_GET_NUMBER_E 112
+#define CONF_F_NCONF_GET_SECTION 108
+#define CONF_F_NCONF_GET_STRING 109
+#define CONF_F_NCONF_LOAD 113
+#define CONF_F_NCONF_LOAD_BIO 110
+#define CONF_F_NCONF_LOAD_FP 114
+#define CONF_F_NCONF_NEW 111
+#define CONF_F_STR_COPY 101
+
+/* Reason codes. */
+#define CONF_R_ERROR_LOADING_DSO 110
+#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
+#define CONF_R_MISSING_EQUAL_SIGN 101
+#define CONF_R_MISSING_FINISH_FUNCTION 111
+#define CONF_R_MISSING_INIT_FUNCTION 112
+#define CONF_R_MODULE_INITIALIZATION_ERROR 109
+#define CONF_R_NO_CLOSE_BRACE 102
+#define CONF_R_NO_CONF 105
+#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106
+#define CONF_R_NO_SECTION 107
+#define CONF_R_NO_SUCH_FILE 114
+#define CONF_R_NO_VALUE 108
+#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103
+#define CONF_R_UNKNOWN_MODULE_NAME 113
+#define CONF_R_VARIABLE_HAS_NO_VALUE 104
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/conf_api.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/conf_api.h
new file mode 100644
index 000000000..87a954aff
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/conf_api.h
@@ -0,0 +1,89 @@
+/* conf_api.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_CONF_API_H
+#define HEADER_CONF_API_H
+
+#include <openssl/lhash.h>
+#include <openssl/conf.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Up until OpenSSL 0.9.5a, this was new_section */
+CONF_VALUE *_CONF_new_section(CONF *conf, const char *section);
+/* Up until OpenSSL 0.9.5a, this was get_section */
+CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);
+/* Up until OpenSSL 0.9.5a, this was CONF_get_section */
+STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,
+ const char *section);
+
+int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);
+char *_CONF_get_string(const CONF *conf, const char *section,
+ const char *name);
+long _CONF_get_number(const CONF *conf, const char *section, const char *name);
+
+int _CONF_new_data(CONF *conf);
+void _CONF_free_data(CONF *conf);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/crypto.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/crypto.h
new file mode 100644
index 000000000..0e4fb0723
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/crypto.h
@@ -0,0 +1,619 @@
+/* crypto/crypto.h */
+/* ====================================================================
+ * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ * ECDH support in OpenSSL originally developed by
+ * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
+ */
+
+#ifndef HEADER_CRYPTO_H
+#define HEADER_CRYPTO_H
+
+#include <stdlib.h>
+
+#include <openssl/e_os2.h>
+
+#ifndef OPENSSL_NO_FP_API
+#include <stdio.h>
+#endif
+
+#include <openssl/stack.h>
+#include <openssl/safestack.h>
+#include <openssl/opensslv.h>
+#include <openssl/ossl_typ.h>
+
+#ifdef CHARSET_EBCDIC
+#include <openssl/ebcdic.h>
+#endif
+
+/* Resolve problems on some operating systems with symbol names that clash
+ one way or another */
+#include <openssl/symhacks.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Backward compatibility to SSLeay */
+/* This is more to be used to check the correct DLL is being used
+ * in the MS world. */
+#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
+#define SSLEAY_VERSION 0
+/* #define SSLEAY_OPTIONS 1 no longer supported */
+#define SSLEAY_CFLAGS 2
+#define SSLEAY_BUILT_ON 3
+#define SSLEAY_PLATFORM 4
+#define SSLEAY_DIR 5
+
+/* Already declared in ossl_typ.h */
+#if 0
+typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
+/* Called when a new object is created */
+typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
+ int idx, long argl, void *argp);
+/* Called when an object is free()ed */
+typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
+ int idx, long argl, void *argp);
+/* Called when we need to dup an object */
+typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
+ int idx, long argl, void *argp);
+#endif
+
+/* A generic structure to pass assorted data in a expandable way */
+typedef struct openssl_item_st
+ {
+ int code;
+ void *value; /* Not used for flag attributes */
+ size_t value_size; /* Max size of value for output, length for input */
+ size_t *value_length; /* Returned length of value for output */
+ } OPENSSL_ITEM;
+
+
+/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
+ * names in cryptlib.c
+ */
+
+#define CRYPTO_LOCK_ERR 1
+#define CRYPTO_LOCK_EX_DATA 2
+#define CRYPTO_LOCK_X509 3
+#define CRYPTO_LOCK_X509_INFO 4
+#define CRYPTO_LOCK_X509_PKEY 5
+#define CRYPTO_LOCK_X509_CRL 6
+#define CRYPTO_LOCK_X509_REQ 7
+#define CRYPTO_LOCK_DSA 8
+#define CRYPTO_LOCK_RSA 9
+#define CRYPTO_LOCK_EVP_PKEY 10
+#define CRYPTO_LOCK_X509_STORE 11
+#define CRYPTO_LOCK_SSL_CTX 12
+#define CRYPTO_LOCK_SSL_CERT 13
+#define CRYPTO_LOCK_SSL_SESSION 14
+#define CRYPTO_LOCK_SSL_SESS_CERT 15
+#define CRYPTO_LOCK_SSL 16
+#define CRYPTO_LOCK_SSL_METHOD 17
+#define CRYPTO_LOCK_RAND 18
+#define CRYPTO_LOCK_RAND2 19
+#define CRYPTO_LOCK_MALLOC 20
+#define CRYPTO_LOCK_BIO 21
+#define CRYPTO_LOCK_GETHOSTBYNAME 22
+#define CRYPTO_LOCK_GETSERVBYNAME 23
+#define CRYPTO_LOCK_READDIR 24
+#define CRYPTO_LOCK_RSA_BLINDING 25
+#define CRYPTO_LOCK_DH 26
+#define CRYPTO_LOCK_MALLOC2 27
+#define CRYPTO_LOCK_DSO 28
+#define CRYPTO_LOCK_DYNLOCK 29
+#define CRYPTO_LOCK_ENGINE 30
+#define CRYPTO_LOCK_UI 31
+#define CRYPTO_LOCK_ECDSA 32
+#define CRYPTO_LOCK_EC 33
+#define CRYPTO_LOCK_ECDH 34
+#define CRYPTO_LOCK_BN 35
+#define CRYPTO_LOCK_EC_PRE_COMP 36
+#define CRYPTO_LOCK_STORE 37
+#define CRYPTO_LOCK_COMP 38
+#ifndef OPENSSL_FIPS
+#define CRYPTO_NUM_LOCKS 39
+#else
+#define CRYPTO_LOCK_FIPS 39
+#define CRYPTO_LOCK_FIPS2 40
+#define CRYPTO_NUM_LOCKS 41
+#endif
+
+#define CRYPTO_LOCK 1
+#define CRYPTO_UNLOCK 2
+#define CRYPTO_READ 4
+#define CRYPTO_WRITE 8
+
+#ifndef OPENSSL_NO_LOCKING
+#ifndef CRYPTO_w_lock
+#define CRYPTO_w_lock(type) \
+ CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
+#define CRYPTO_w_unlock(type) \
+ CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
+#define CRYPTO_r_lock(type) \
+ CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
+#define CRYPTO_r_unlock(type) \
+ CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
+#define CRYPTO_add(addr,amount,type) \
+ CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
+#endif
+#else
+#define CRYPTO_w_lock(a)
+#define CRYPTO_w_unlock(a)
+#define CRYPTO_r_lock(a)
+#define CRYPTO_r_unlock(a)
+#define CRYPTO_add(a,b,c) ((*(a))+=(b))
+#endif
+
+/* Some applications as well as some parts of OpenSSL need to allocate
+ and deallocate locks in a dynamic fashion. The following typedef
+ makes this possible in a type-safe manner. */
+/* struct CRYPTO_dynlock_value has to be defined by the application. */
+typedef struct
+ {
+ int references;
+ struct CRYPTO_dynlock_value *data;
+ } CRYPTO_dynlock;
+
+
+/* The following can be used to detect memory leaks in the SSLeay library.
+ * It used, it turns on malloc checking */
+
+#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */
+#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */
+#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */
+#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */
+
+/* The following are bit values to turn on or off options connected to the
+ * malloc checking functionality */
+
+/* Adds time to the memory checking information */
+#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */
+/* Adds thread number to the memory checking information */
+#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */
+
+#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
+
+
+/* predec of the BIO type */
+typedef struct bio_st BIO_dummy;
+
+struct crypto_ex_data_st
+ {
+ STACK *sk;
+ int dummy; /* gcc is screwing up this data structure :-( */
+ };
+
+/* This stuff is basically class callback functions
+ * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
+
+typedef struct crypto_ex_data_func_st
+ {
+ long argl; /* Arbitary long */
+ void *argp; /* Arbitary void * */
+ CRYPTO_EX_new *new_func;
+ CRYPTO_EX_free *free_func;
+ CRYPTO_EX_dup *dup_func;
+ } CRYPTO_EX_DATA_FUNCS;
+
+DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
+
+/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
+ * entry.
+ */
+
+#define CRYPTO_EX_INDEX_BIO 0
+#define CRYPTO_EX_INDEX_SSL 1
+#define CRYPTO_EX_INDEX_SSL_CTX 2
+#define CRYPTO_EX_INDEX_SSL_SESSION 3
+#define CRYPTO_EX_INDEX_X509_STORE 4
+#define CRYPTO_EX_INDEX_X509_STORE_CTX 5
+#define CRYPTO_EX_INDEX_RSA 6
+#define CRYPTO_EX_INDEX_DSA 7
+#define CRYPTO_EX_INDEX_DH 8
+#define CRYPTO_EX_INDEX_ENGINE 9
+#define CRYPTO_EX_INDEX_X509 10
+#define CRYPTO_EX_INDEX_UI 11
+#define CRYPTO_EX_INDEX_ECDSA 12
+#define CRYPTO_EX_INDEX_ECDH 13
+#define CRYPTO_EX_INDEX_COMP 14
+#define CRYPTO_EX_INDEX_STORE 15
+
+/* Dynamically assigned indexes start from this value (don't use directly, use
+ * via CRYPTO_ex_data_new_class). */
+#define CRYPTO_EX_INDEX_USER 100
+
+
+/* This is the default callbacks, but we can have others as well:
+ * this is needed in Win32 where the application malloc and the
+ * library malloc may not be the same.
+ */
+#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
+ malloc, realloc, free)
+
+#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
+# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
+# define CRYPTO_MDEBUG
+# endif
+#endif
+
+/* Set standard debugging functions (not done by default
+ * unless CRYPTO_MDEBUG is defined) */
+void CRYPTO_malloc_debug_init(void);
+
+int CRYPTO_mem_ctrl(int mode);
+int CRYPTO_is_mem_check_on(void);
+
+/* for applications */
+#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
+#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
+
+/* for library-internal use */
+#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
+#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
+#define is_MemCheck_on() CRYPTO_is_mem_check_on()
+
+#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
+#define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
+#define OPENSSL_realloc(addr,num) \
+ CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
+#define OPENSSL_realloc_clean(addr,old_num,num) \
+ CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
+#define OPENSSL_remalloc(addr,num) \
+ CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
+#define OPENSSL_freeFunc CRYPTO_free
+#define OPENSSL_free(addr) CRYPTO_free(addr)
+
+#define OPENSSL_malloc_locked(num) \
+ CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
+#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
+
+
+const char *SSLeay_version(int type);
+unsigned long SSLeay(void);
+
+int OPENSSL_issetugid(void);
+
+/* An opaque type representing an implementation of "ex_data" support */
+typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
+/* Return an opaque pointer to the current "ex_data" implementation */
+const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
+/* Sets the "ex_data" implementation to be used (if it's not too late) */
+int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
+/* Get a new "ex_data" class, and return the corresponding "class_index" */
+int CRYPTO_ex_data_new_class(void);
+/* Within a given class, get/register a new index */
+int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
+ CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+ CRYPTO_EX_free *free_func);
+/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
+ * class (invokes whatever per-class callbacks are applicable) */
+int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
+int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
+ CRYPTO_EX_DATA *from);
+void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
+/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
+ * (relative to the class type involved) */
+int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
+void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
+/* This function cleans up all "ex_data" state. It mustn't be called under
+ * potential race-conditions. */
+void CRYPTO_cleanup_all_ex_data(void);
+
+int CRYPTO_get_new_lockid(char *name);
+
+int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
+void CRYPTO_lock(int mode, int type,const char *file,int line);
+void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
+ const char *file,int line));
+void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
+ int line);
+void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
+ const char *file, int line));
+int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
+ const char *file,int line);
+void CRYPTO_set_id_callback(unsigned long (*func)(void));
+unsigned long (*CRYPTO_get_id_callback(void))(void);
+unsigned long CRYPTO_thread_id(void);
+const char *CRYPTO_get_lock_name(int type);
+int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
+ int line);
+
+void int_CRYPTO_set_do_dynlock_callback(
+ void (*do_dynlock_cb)(int mode, int type, const char *file, int line));
+
+int CRYPTO_get_new_dynlockid(void);
+void CRYPTO_destroy_dynlockid(int i);
+struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
+void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
+void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
+void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
+struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
+void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
+void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
+
+/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
+ * call the latter last if you need different functions */
+int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
+int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
+int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
+ void *(*r)(void *,size_t,const char *,int),
+ void (*f)(void *));
+int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
+ void (*free_func)(void *));
+int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
+ void (*r)(void *,void *,int,const char *,int,int),
+ void (*f)(void *,int),
+ void (*so)(long),
+ long (*go)(void));
+void CRYPTO_set_mem_info_functions(
+ int (*push_info_fn)(const char *info, const char *file, int line),
+ int (*pop_info_fn)(void),
+ int (*remove_all_info_fn)(void));
+void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
+void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
+void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
+ void *(**r)(void *, size_t,const char *,int),
+ void (**f)(void *));
+void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
+ void (**f)(void *));
+void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
+ void (**r)(void *,void *,int,const char *,int,int),
+ void (**f)(void *,int),
+ void (**so)(long),
+ long (**go)(void));
+
+void *CRYPTO_malloc_locked(int num, const char *file, int line);
+void CRYPTO_free_locked(void *);
+void *CRYPTO_malloc(int num, const char *file, int line);
+char *CRYPTO_strdup(const char *str, const char *file, int line);
+void CRYPTO_free(void *);
+void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
+void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
+ int line);
+void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
+
+void OPENSSL_cleanse(void *ptr, size_t len);
+
+void CRYPTO_set_mem_debug_options(long bits);
+long CRYPTO_get_mem_debug_options(void);
+
+#define CRYPTO_push_info(info) \
+ CRYPTO_push_info_(info, __FILE__, __LINE__);
+int CRYPTO_push_info_(const char *info, const char *file, int line);
+int CRYPTO_pop_info(void);
+int CRYPTO_remove_all_info(void);
+
+
+/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
+ * used as default in CRYPTO_MDEBUG compilations): */
+/* The last argument has the following significance:
+ *
+ * 0: called before the actual memory allocation has taken place
+ * 1: called after the actual memory allocation has taken place
+ */
+void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
+void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
+void CRYPTO_dbg_free(void *addr,int before_p);
+/* Tell the debugging code about options. By default, the following values
+ * apply:
+ *
+ * 0: Clear all options.
+ * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option.
+ * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option.
+ * V_CRYPTO_MDEBUG_ALL (3): 1 + 2
+ */
+void CRYPTO_dbg_set_options(long bits);
+long CRYPTO_dbg_get_options(void);
+
+int CRYPTO_dbg_push_info(const char *info, const char *file, int line);
+int CRYPTO_dbg_pop_info(void);
+int CRYPTO_dbg_remove_all_info(void);
+
+#ifndef OPENSSL_NO_FP_API
+void CRYPTO_mem_leaks_fp(FILE *);
+#endif
+void CRYPTO_mem_leaks(struct bio_st *bio);
+/* unsigned long order, char *file, int line, int num_bytes, char *addr */
+typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
+void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
+
+/* die if we have to */
+void OpenSSLDie(const char *file,int line,const char *assertion);
+#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
+
+unsigned long *OPENSSL_ia32cap_loc(void);
+#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
+int OPENSSL_isservice(void);
+
+#ifdef OPENSSL_FIPS
+#define FIPS_ERROR_IGNORED(alg) OpenSSLDie(__FILE__, __LINE__, \
+ alg " previous FIPS forbidden algorithm error ignored");
+
+#define FIPS_BAD_ABORT(alg) OpenSSLDie(__FILE__, __LINE__, \
+ #alg " Algorithm forbidden in FIPS mode");
+
+#ifdef OPENSSL_FIPS_STRICT
+#define FIPS_BAD_ALGORITHM(alg) FIPS_BAD_ABORT(alg)
+#else
+#define FIPS_BAD_ALGORITHM(alg) \
+ { \
+ FIPSerr(FIPS_F_HASH_FINAL,FIPS_R_NON_FIPS_METHOD); \
+ ERR_add_error_data(2, "Algorithm=", #alg); \
+ return 0; \
+ }
+#endif
+
+/* Low level digest API blocking macro */
+
+#define FIPS_NON_FIPS_MD_Init(alg) \
+ int alg##_Init(alg##_CTX *c) \
+ { \
+ if (FIPS_mode()) \
+ FIPS_BAD_ALGORITHM(alg) \
+ return private_##alg##_Init(c); \
+ } \
+ int private_##alg##_Init(alg##_CTX *c)
+
+/* For ciphers the API often varies from cipher to cipher and each needs to
+ * be treated as a special case. Variable key length ciphers (Blowfish, RC4,
+ * CAST) however are very similar and can use a blocking macro.
+ */
+
+#define FIPS_NON_FIPS_VCIPHER_Init(alg) \
+ void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data) \
+ { \
+ if (FIPS_mode()) \
+ FIPS_BAD_ABORT(alg) \
+ private_##alg##_set_key(key, len, data); \
+ } \
+ void private_##alg##_set_key(alg##_KEY *key, int len, \
+ const unsigned char *data)
+
+#else
+
+#define FIPS_NON_FIPS_VCIPHER_Init(alg) \
+ void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data)
+
+#define FIPS_NON_FIPS_MD_Init(alg) \
+ int alg##_Init(alg##_CTX *c)
+
+#endif /* def OPENSSL_FIPS */
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_CRYPTO_strings(void);
+
+#define OPENSSL_HAVE_INIT 1
+void OPENSSL_init(void);
+
+/* Error codes for the CRYPTO functions. */
+
+/* Function codes. */
+#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
+#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103
+#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
+#define CRYPTO_F_CRYPTO_SET_EX_DATA 102
+#define CRYPTO_F_DEF_ADD_INDEX 104
+#define CRYPTO_F_DEF_GET_CLASS 105
+#define CRYPTO_F_INT_DUP_EX_DATA 106
+#define CRYPTO_F_INT_FREE_EX_DATA 107
+#define CRYPTO_F_INT_NEW_EX_DATA 108
+
+/* Reason codes. */
+#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/des.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/des.h
new file mode 100644
index 000000000..92b666359
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/des.h
@@ -0,0 +1,245 @@
+/* crypto/des/des.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_NEW_DES_H
+#define HEADER_NEW_DES_H
+
+#include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES,
+ DES_LONG (via openssl/opensslconf.h */
+
+#ifdef OPENSSL_NO_DES
+#error DES is disabled.
+#endif
+
+#ifdef OPENSSL_BUILD_SHLIBCRYPTO
+# undef OPENSSL_EXTERN
+# define OPENSSL_EXTERN OPENSSL_EXPORT
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned char DES_cblock[8];
+typedef /* const */ unsigned char const_DES_cblock[8];
+/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock *
+ * and const_DES_cblock * are incompatible pointer types. */
+
+typedef struct DES_ks
+ {
+ union
+ {
+ DES_cblock cblock;
+ /* make sure things are correct size on machines with
+ * 8 byte longs */
+ DES_LONG deslong[2];
+ } ks[16];
+ } DES_key_schedule;
+
+#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT
+# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT
+# define OPENSSL_ENABLE_OLD_DES_SUPPORT
+# endif
+#endif
+
+#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT
+# include <openssl/des_old.h>
+#endif
+
+#define DES_KEY_SZ (sizeof(DES_cblock))
+#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))
+
+#define DES_ENCRYPT 1
+#define DES_DECRYPT 0
+
+#define DES_CBC_MODE 0
+#define DES_PCBC_MODE 1
+
+#define DES_ecb2_encrypt(i,o,k1,k2,e) \
+ DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
+
+#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
+ DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
+
+#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
+ DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
+
+#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
+ DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
+
+OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */
+#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)
+OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */
+#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)
+
+const char *DES_options(void);
+void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
+ DES_key_schedule *ks1,DES_key_schedule *ks2,
+ DES_key_schedule *ks3, int enc);
+DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output,
+ long length,DES_key_schedule *schedule,
+ const_DES_cblock *ivec);
+/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */
+void DES_cbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,DES_key_schedule *schedule,DES_cblock *ivec,
+ int enc);
+void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,DES_key_schedule *schedule,DES_cblock *ivec,
+ int enc);
+void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,DES_key_schedule *schedule,DES_cblock *ivec,
+ const_DES_cblock *inw,const_DES_cblock *outw,int enc);
+void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
+ long length,DES_key_schedule *schedule,DES_cblock *ivec,
+ int enc);
+void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output,
+ DES_key_schedule *ks,int enc);
+
+/* This is the DES encryption function that gets called by just about
+ every other DES routine in the library. You should not use this
+ function except to implement 'modes' of DES. I say this because the
+ functions that call this routine do the conversion from 'char *' to
+ long, and this needs to be done to make sure 'non-aligned' memory
+ access do not occur. The characters are loaded 'little endian'.
+ Data is a pointer to 2 unsigned long's and ks is the
+ DES_key_schedule to use. enc, is non zero specifies encryption,
+ zero if decryption. */
+void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc);
+
+/* This functions is the same as DES_encrypt1() except that the DES
+ initial permutation (IP) and final permutation (FP) have been left
+ out. As for DES_encrypt1(), you should not use this function.
+ It is used by the routines in the library that implement triple DES.
+ IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same
+ as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */
+void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc);
+
+void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
+ DES_key_schedule *ks2, DES_key_schedule *ks3);
+void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
+ DES_key_schedule *ks2, DES_key_schedule *ks3);
+void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,
+ DES_key_schedule *ks1,DES_key_schedule *ks2,
+ DES_key_schedule *ks3,DES_cblock *ivec,int enc);
+void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out,
+ long length,
+ DES_key_schedule *ks1,DES_key_schedule *ks2,
+ DES_key_schedule *ks3,
+ DES_cblock *ivec1,DES_cblock *ivec2,
+ int enc);
+void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out,
+ long length,DES_key_schedule *ks1,
+ DES_key_schedule *ks2,DES_key_schedule *ks3,
+ DES_cblock *ivec,int *num,int enc);
+void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out,
+ int numbits,long length,DES_key_schedule *ks1,
+ DES_key_schedule *ks2,DES_key_schedule *ks3,
+ DES_cblock *ivec,int enc);
+void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out,
+ long length,DES_key_schedule *ks1,
+ DES_key_schedule *ks2,DES_key_schedule *ks3,
+ DES_cblock *ivec,int *num);
+#if 0
+void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white,
+ DES_cblock *out_white);
+#endif
+
+int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched,
+ DES_cblock *iv);
+int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched,
+ DES_cblock *iv);
+char *DES_fcrypt(const char *buf,const char *salt, char *ret);
+char *DES_crypt(const char *buf,const char *salt);
+void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
+ long length,DES_key_schedule *schedule,DES_cblock *ivec);
+void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,DES_key_schedule *schedule,DES_cblock *ivec,
+ int enc);
+DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[],
+ long length,int out_count,DES_cblock *seed);
+int DES_random_key(DES_cblock *ret);
+void DES_set_odd_parity(DES_cblock *key);
+int DES_check_key_parity(const_DES_cblock *key);
+int DES_is_weak_key(const_DES_cblock *key);
+/* DES_set_key (= set_key = DES_key_sched = key_sched) calls
+ * DES_set_key_checked if global variable DES_check_key is set,
+ * DES_set_key_unchecked otherwise. */
+int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule);
+int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule);
+int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule);
+void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule);
+void DES_string_to_key(const char *str,DES_cblock *key);
+void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2);
+void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
+ DES_key_schedule *schedule,DES_cblock *ivec,int *num,
+ int enc);
+void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
+ DES_key_schedule *schedule,DES_cblock *ivec,int *num);
+
+int DES_read_password(DES_cblock *key, const char *prompt, int verify);
+int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
+ int verify);
+
+#define DES_fixup_key_parity DES_set_odd_parity
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/des_old.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/des_old.h
new file mode 100644
index 000000000..2b2c37235
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/des_old.h
@@ -0,0 +1,446 @@
+/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */
+
+/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
+ *
+ * The function names in here are deprecated and are only present to
+ * provide an interface compatible with openssl 0.9.6 and older as
+ * well as libdes. OpenSSL now provides functions where "des_" has
+ * been replaced with "DES_" in the names, to make it possible to
+ * make incompatible changes that are needed for C type security and
+ * other stuff.
+ *
+ * This include files has two compatibility modes:
+ *
+ * - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API
+ * that is compatible with libdes and SSLeay.
+ * - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an
+ * API that is compatible with OpenSSL 0.9.5x to 0.9.6x.
+ *
+ * Note that these modes break earlier snapshots of OpenSSL, where
+ * libdes compatibility was the only available mode or (later on) the
+ * prefered compatibility mode. However, after much consideration
+ * (and more or less violent discussions with external parties), it
+ * was concluded that OpenSSL should be compatible with earlier versions
+ * of itself before anything else. Also, in all honesty, libdes is
+ * an old beast that shouldn't really be used any more.
+ *
+ * Please consider starting to use the DES_ functions rather than the
+ * des_ ones. The des_ functions will disappear completely before
+ * OpenSSL 1.0!
+ *
+ * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
+ */
+
+/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
+ * project 2001.
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_DES_H
+#define HEADER_DES_H
+
+#include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */
+
+#ifdef OPENSSL_NO_DES
+#error DES is disabled.
+#endif
+
+#ifndef HEADER_NEW_DES_H
+#error You must include des.h, not des_old.h directly.
+#endif
+
+#ifdef _KERBEROS_DES_H
+#error <openssl/des_old.h> replaces <kerberos/des.h>.
+#endif
+
+#include <openssl/symhacks.h>
+
+#ifdef OPENSSL_BUILD_SHLIBCRYPTO
+# undef OPENSSL_EXTERN
+# define OPENSSL_EXTERN OPENSSL_EXPORT
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _
+#undef _
+#endif
+
+typedef unsigned char _ossl_old_des_cblock[8];
+typedef struct _ossl_old_des_ks_struct
+ {
+ union {
+ _ossl_old_des_cblock _;
+ /* make sure things are correct size on machines with
+ * 8 byte longs */
+ DES_LONG pad[2];
+ } ks;
+ } _ossl_old_des_key_schedule[16];
+
+#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY
+#define des_cblock DES_cblock
+#define const_des_cblock const_DES_cblock
+#define des_key_schedule DES_key_schedule
+#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
+ DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e))
+#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
+ DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e))
+#define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\
+ DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e))
+#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
+ DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e))
+#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
+ DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n))
+#define des_options()\
+ DES_options()
+#define des_cbc_cksum(i,o,l,k,iv)\
+ DES_cbc_cksum((i),(o),(l),&(k),(iv))
+#define des_cbc_encrypt(i,o,l,k,iv,e)\
+ DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))
+#define des_ncbc_encrypt(i,o,l,k,iv,e)\
+ DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e))
+#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
+ DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e))
+#define des_cfb_encrypt(i,o,n,l,k,iv,e)\
+ DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e))
+#define des_ecb_encrypt(i,o,k,e)\
+ DES_ecb_encrypt((i),(o),&(k),(e))
+#define des_encrypt1(d,k,e)\
+ DES_encrypt1((d),&(k),(e))
+#define des_encrypt2(d,k,e)\
+ DES_encrypt2((d),&(k),(e))
+#define des_encrypt3(d,k1,k2,k3)\
+ DES_encrypt3((d),&(k1),&(k2),&(k3))
+#define des_decrypt3(d,k1,k2,k3)\
+ DES_decrypt3((d),&(k1),&(k2),&(k3))
+#define des_xwhite_in2out(k,i,o)\
+ DES_xwhite_in2out((k),(i),(o))
+#define des_enc_read(f,b,l,k,iv)\
+ DES_enc_read((f),(b),(l),&(k),(iv))
+#define des_enc_write(f,b,l,k,iv)\
+ DES_enc_write((f),(b),(l),&(k),(iv))
+#define des_fcrypt(b,s,r)\
+ DES_fcrypt((b),(s),(r))
+#if 0
+#define des_crypt(b,s)\
+ DES_crypt((b),(s))
+#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
+#define crypt(b,s)\
+ DES_crypt((b),(s))
+#endif
+#endif
+#define des_ofb_encrypt(i,o,n,l,k,iv)\
+ DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))
+#define des_pcbc_encrypt(i,o,l,k,iv,e)\
+ DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e))
+#define des_quad_cksum(i,o,l,c,s)\
+ DES_quad_cksum((i),(o),(l),(c),(s))
+#define des_random_seed(k)\
+ _ossl_096_des_random_seed((k))
+#define des_random_key(r)\
+ DES_random_key((r))
+#define des_read_password(k,p,v) \
+ DES_read_password((k),(p),(v))
+#define des_read_2passwords(k1,k2,p,v) \
+ DES_read_2passwords((k1),(k2),(p),(v))
+#define des_set_odd_parity(k)\
+ DES_set_odd_parity((k))
+#define des_check_key_parity(k)\
+ DES_check_key_parity((k))
+#define des_is_weak_key(k)\
+ DES_is_weak_key((k))
+#define des_set_key(k,ks)\
+ DES_set_key((k),&(ks))
+#define des_key_sched(k,ks)\
+ DES_key_sched((k),&(ks))
+#define des_set_key_checked(k,ks)\
+ DES_set_key_checked((k),&(ks))
+#define des_set_key_unchecked(k,ks)\
+ DES_set_key_unchecked((k),&(ks))
+#define des_string_to_key(s,k)\
+ DES_string_to_key((s),(k))
+#define des_string_to_2keys(s,k1,k2)\
+ DES_string_to_2keys((s),(k1),(k2))
+#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
+ DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e))
+#define des_ofb64_encrypt(i,o,l,ks,iv,n)\
+ DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n))
+
+
+#define des_ecb2_encrypt(i,o,k1,k2,e) \
+ des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
+
+#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
+ des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
+
+#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
+ des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
+
+#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
+ des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
+
+#define des_check_key DES_check_key
+#define des_rw_mode DES_rw_mode
+#else /* libdes compatibility */
+/* Map all symbol names to _ossl_old_des_* form, so we avoid all
+ clashes with libdes */
+#define des_cblock _ossl_old_des_cblock
+#define des_key_schedule _ossl_old_des_key_schedule
+#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
+ _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))
+#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
+ _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))
+#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
+ _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e))
+#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
+ _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))
+#define des_options()\
+ _ossl_old_des_options()
+#define des_cbc_cksum(i,o,l,k,iv)\
+ _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))
+#define des_cbc_encrypt(i,o,l,k,iv,e)\
+ _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))
+#define des_ncbc_encrypt(i,o,l,k,iv,e)\
+ _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))
+#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
+ _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))
+#define des_cfb_encrypt(i,o,n,l,k,iv,e)\
+ _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e))
+#define des_ecb_encrypt(i,o,k,e)\
+ _ossl_old_des_ecb_encrypt((i),(o),(k),(e))
+#define des_encrypt(d,k,e)\
+ _ossl_old_des_encrypt((d),(k),(e))
+#define des_encrypt2(d,k,e)\
+ _ossl_old_des_encrypt2((d),(k),(e))
+#define des_encrypt3(d,k1,k2,k3)\
+ _ossl_old_des_encrypt3((d),(k1),(k2),(k3))
+#define des_decrypt3(d,k1,k2,k3)\
+ _ossl_old_des_decrypt3((d),(k1),(k2),(k3))
+#define des_xwhite_in2out(k,i,o)\
+ _ossl_old_des_xwhite_in2out((k),(i),(o))
+#define des_enc_read(f,b,l,k,iv)\
+ _ossl_old_des_enc_read((f),(b),(l),(k),(iv))
+#define des_enc_write(f,b,l,k,iv)\
+ _ossl_old_des_enc_write((f),(b),(l),(k),(iv))
+#define des_fcrypt(b,s,r)\
+ _ossl_old_des_fcrypt((b),(s),(r))
+#define des_crypt(b,s)\
+ _ossl_old_des_crypt((b),(s))
+#if 0
+#define crypt(b,s)\
+ _ossl_old_crypt((b),(s))
+#endif
+#define des_ofb_encrypt(i,o,n,l,k,iv)\
+ _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))
+#define des_pcbc_encrypt(i,o,l,k,iv,e)\
+ _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))
+#define des_quad_cksum(i,o,l,c,s)\
+ _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))
+#define des_random_seed(k)\
+ _ossl_old_des_random_seed((k))
+#define des_random_key(r)\
+ _ossl_old_des_random_key((r))
+#define des_read_password(k,p,v) \
+ _ossl_old_des_read_password((k),(p),(v))
+#define des_read_2passwords(k1,k2,p,v) \
+ _ossl_old_des_read_2passwords((k1),(k2),(p),(v))
+#define des_set_odd_parity(k)\
+ _ossl_old_des_set_odd_parity((k))
+#define des_is_weak_key(k)\
+ _ossl_old_des_is_weak_key((k))
+#define des_set_key(k,ks)\
+ _ossl_old_des_set_key((k),(ks))
+#define des_key_sched(k,ks)\
+ _ossl_old_des_key_sched((k),(ks))
+#define des_string_to_key(s,k)\
+ _ossl_old_des_string_to_key((s),(k))
+#define des_string_to_2keys(s,k1,k2)\
+ _ossl_old_des_string_to_2keys((s),(k1),(k2))
+#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
+ _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))
+#define des_ofb64_encrypt(i,o,l,ks,iv,n)\
+ _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))
+
+
+#define des_ecb2_encrypt(i,o,k1,k2,e) \
+ des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
+
+#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
+ des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
+
+#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
+ des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
+
+#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
+ des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
+
+#define des_check_key DES_check_key
+#define des_rw_mode DES_rw_mode
+#endif
+
+const char *_ossl_old_des_options(void);
+void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
+ _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2,
+ _ossl_old_des_key_schedule ks3, int enc);
+DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
+ long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
+void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
+ _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
+void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
+ _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
+void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
+ _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,
+ _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc);
+void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
+ long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
+void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
+ _ossl_old_des_key_schedule ks,int enc);
+void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
+void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
+void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
+ _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3);
+void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
+ _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3);
+void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output,
+ long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
+ _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc);
+void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
+ long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
+ _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc);
+void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
+ long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
+ _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num);
+#if 0
+void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white),
+ _ossl_old_des_cblock (*out_white));
+#endif
+
+int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
+ _ossl_old_des_cblock *iv);
+int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
+ _ossl_old_des_cblock *iv);
+char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret);
+char *_ossl_old_des_crypt(const char *buf,const char *salt);
+#if !defined(PERL5) && !defined(NeXT)
+char *_ossl_old_crypt(const char *buf,const char *salt);
+#endif
+void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out,
+ int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
+void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
+ _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
+DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
+ long length,int out_count,_ossl_old_des_cblock *seed);
+void _ossl_old_des_random_seed(_ossl_old_des_cblock key);
+void _ossl_old_des_random_key(_ossl_old_des_cblock ret);
+int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify);
+int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2,
+ const char *prompt,int verify);
+void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);
+int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);
+int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
+int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
+void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key);
+void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2);
+void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
+ _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc);
+void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
+ _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num);
+
+void _ossl_096_des_random_seed(des_cblock *key);
+
+/* The following definitions provide compatibility with the MIT Kerberos
+ * library. The _ossl_old_des_key_schedule structure is not binary compatible. */
+
+#define _KERBEROS_DES_H
+
+#define KRBDES_ENCRYPT DES_ENCRYPT
+#define KRBDES_DECRYPT DES_DECRYPT
+
+#ifdef KERBEROS
+# define ENCRYPT DES_ENCRYPT
+# define DECRYPT DES_DECRYPT
+#endif
+
+#ifndef NCOMPAT
+# define C_Block des_cblock
+# define Key_schedule des_key_schedule
+# define KEY_SZ DES_KEY_SZ
+# define string_to_key des_string_to_key
+# define read_pw_string des_read_pw_string
+# define random_key des_random_key
+# define pcbc_encrypt des_pcbc_encrypt
+# define set_key des_set_key
+# define key_sched des_key_sched
+# define ecb_encrypt des_ecb_encrypt
+# define cbc_encrypt des_cbc_encrypt
+# define ncbc_encrypt des_ncbc_encrypt
+# define xcbc_encrypt des_xcbc_encrypt
+# define cbc_cksum des_cbc_cksum
+# define quad_cksum des_quad_cksum
+# define check_parity des_check_key_parity
+#endif
+
+#define des_fixup_key_parity DES_fixup_key_parity
+
+#ifdef __cplusplus
+}
+#endif
+
+/* for DES_read_pw_string et al */
+#include <openssl/ui_compat.h>
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dh.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dh.h
new file mode 100644
index 000000000..10475ac4b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dh.h
@@ -0,0 +1,245 @@
+/* crypto/dh/dh.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_DH_H
+#define HEADER_DH_H
+
+#include <openssl/e_os2.h>
+
+#ifdef OPENSSL_NO_DH
+#error DH is disabled.
+#endif
+
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+#include <openssl/ossl_typ.h>
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/bn.h>
+#endif
+
+#ifndef OPENSSL_DH_MAX_MODULUS_BITS
+# define OPENSSL_DH_MAX_MODULUS_BITS 10000
+#endif
+
+#define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024
+
+#define DH_FLAG_CACHE_MONT_P 0x01
+#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH
+ * implementation now uses constant time
+ * modular exponentiation for secret exponents
+ * by default. This flag causes the
+ * faster variable sliding window method to
+ * be used for all exponents.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Already defined in ossl_typ.h */
+/* typedef struct dh_st DH; */
+/* typedef struct dh_method DH_METHOD; */
+
+struct dh_method
+ {
+ const char *name;
+ /* Methods here */
+ int (*generate_key)(DH *dh);
+ int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh);
+ int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a,
+ const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
+ BN_MONT_CTX *m_ctx); /* Can be null */
+
+ int (*init)(DH *dh);
+ int (*finish)(DH *dh);
+ int flags;
+ char *app_data;
+ /* If this is non-NULL, it will be used to generate parameters */
+ int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb);
+ };
+
+struct dh_st
+ {
+ /* This first argument is used to pick up errors when
+ * a DH is passed instead of a EVP_PKEY */
+ int pad;
+ int version;
+ BIGNUM *p;
+ BIGNUM *g;
+ long length; /* optional */
+ BIGNUM *pub_key; /* g^x */
+ BIGNUM *priv_key; /* x */
+
+ int flags;
+ BN_MONT_CTX *method_mont_p;
+ /* Place holders if we want to do X9.42 DH */
+ BIGNUM *q;
+ BIGNUM *j;
+ unsigned char *seed;
+ int seedlen;
+ BIGNUM *counter;
+
+ int references;
+ CRYPTO_EX_DATA ex_data;
+ const DH_METHOD *meth;
+ ENGINE *engine;
+ };
+
+#define DH_GENERATOR_2 2
+/* #define DH_GENERATOR_3 3 */
+#define DH_GENERATOR_5 5
+
+/* DH_check error codes */
+#define DH_CHECK_P_NOT_PRIME 0x01
+#define DH_CHECK_P_NOT_SAFE_PRIME 0x02
+#define DH_UNABLE_TO_CHECK_GENERATOR 0x04
+#define DH_NOT_SUITABLE_GENERATOR 0x08
+
+/* DH_check_pub_key error codes */
+#define DH_CHECK_PUBKEY_TOO_SMALL 0x01
+#define DH_CHECK_PUBKEY_TOO_LARGE 0x02
+
+/* primes p where (p-1)/2 is prime too are called "safe"; we define
+ this for backward compatibility: */
+#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
+
+#define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x)
+#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
+ (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
+#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
+ (unsigned char *)(x))
+#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
+#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
+
+const DH_METHOD *DH_OpenSSL(void);
+
+#ifdef OPENSSL_FIPS
+DH * FIPS_dh_new(void);
+void FIPS_dh_free(DH *dh);
+#endif
+
+void DH_set_default_method(const DH_METHOD *meth);
+const DH_METHOD *DH_get_default_method(void);
+int DH_set_method(DH *dh, const DH_METHOD *meth);
+DH *DH_new_method(ENGINE *engine);
+
+DH * DH_new(void);
+void DH_free(DH *dh);
+int DH_up_ref(DH *dh);
+int DH_size(const DH *dh);
+int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int DH_set_ex_data(DH *d, int idx, void *arg);
+void *DH_get_ex_data(DH *d, int idx);
+
+/* Deprecated version */
+#ifndef OPENSSL_NO_DEPRECATED
+DH * DH_generate_parameters(int prime_len,int generator,
+ void (*callback)(int,int,void *),void *cb_arg);
+#endif /* !defined(OPENSSL_NO_DEPRECATED) */
+
+/* New version */
+int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb);
+
+int DH_check(const DH *dh,int *codes);
+int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes);
+int DH_generate_key(DH *dh);
+int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh);
+DH * d2i_DHparams(DH **a,const unsigned char **pp, long length);
+int i2d_DHparams(const DH *a,unsigned char **pp);
+#ifndef OPENSSL_NO_FP_API
+int DHparams_print_fp(FILE *fp, const DH *x);
+#endif
+#ifndef OPENSSL_NO_BIO
+int DHparams_print(BIO *bp, const DH *x);
+#else
+int DHparams_print(char *bp, const DH *x);
+#endif
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_DH_strings(void);
+
+/* Error codes for the DH functions. */
+
+/* Function codes. */
+#define DH_F_COMPUTE_KEY 102
+#define DH_F_DHPARAMS_PRINT 100
+#define DH_F_DHPARAMS_PRINT_FP 101
+#define DH_F_DH_BUILTIN_GENPARAMS 106
+#define DH_F_DH_COMPUTE_KEY 107
+#define DH_F_DH_GENERATE_KEY 108
+#define DH_F_DH_GENERATE_PARAMETERS 109
+#define DH_F_DH_NEW_METHOD 105
+#define DH_F_GENERATE_KEY 103
+#define DH_F_GENERATE_PARAMETERS 104
+
+/* Reason codes. */
+#define DH_R_BAD_GENERATOR 101
+#define DH_R_INVALID_PUBKEY 102
+#define DH_R_KEY_SIZE_TOO_SMALL 104
+#define DH_R_MODULUS_TOO_LARGE 103
+#define DH_R_NO_PRIVATE_VALUE 100
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dsa.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dsa.h
new file mode 100644
index 000000000..702c50d6d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dsa.h
@@ -0,0 +1,324 @@
+/* crypto/dsa/dsa.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+/*
+ * The DSS routines are based on patches supplied by
+ * Steven Schoch <schoch@sheba.arc.nasa.gov>. He basically did the
+ * work and I have just tweaked them a little to fit into my
+ * stylistic vision for SSLeay :-) */
+
+#ifndef HEADER_DSA_H
+#define HEADER_DSA_H
+
+#include <openssl/e_os2.h>
+
+#ifdef OPENSSL_NO_DSA
+#error DSA is disabled.
+#endif
+
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+#include <openssl/crypto.h>
+#include <openssl/ossl_typ.h>
+
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/bn.h>
+#ifndef OPENSSL_NO_DH
+# include <openssl/dh.h>
+#endif
+#endif
+
+#ifndef OPENSSL_DSA_MAX_MODULUS_BITS
+# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
+#endif
+
+#define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024
+
+#define DSA_FLAG_CACHE_MONT_P 0x01
+#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA
+ * implementation now uses constant time
+ * modular exponentiation for secret exponents
+ * by default. This flag causes the
+ * faster variable sliding window method to
+ * be used for all exponents.
+ */
+
+/* If this flag is set the DSA method is FIPS compliant and can be used
+ * in FIPS mode. This is set in the validated module method. If an
+ * application sets this flag in its own methods it is its reposibility
+ * to ensure the result is compliant.
+ */
+
+#define DSA_FLAG_FIPS_METHOD 0x0400
+
+/* If this flag is set the operations normally disabled in FIPS mode are
+ * permitted it is then the applications responsibility to ensure that the
+ * usage is compliant.
+ */
+
+#define DSA_FLAG_NON_FIPS_ALLOW 0x0400
+
+#ifdef OPENSSL_FIPS
+#define FIPS_DSA_SIZE_T int
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Already defined in ossl_typ.h */
+/* typedef struct dsa_st DSA; */
+/* typedef struct dsa_method DSA_METHOD; */
+
+typedef struct DSA_SIG_st
+ {
+ BIGNUM *r;
+ BIGNUM *s;
+ } DSA_SIG;
+
+struct dsa_method
+ {
+ const char *name;
+ DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa);
+ int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
+ BIGNUM **rp);
+ int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
+ DSA_SIG *sig, DSA *dsa);
+ int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
+ BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
+ BN_MONT_CTX *in_mont);
+ int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx,
+ BN_MONT_CTX *m_ctx); /* Can be null */
+ int (*init)(DSA *dsa);
+ int (*finish)(DSA *dsa);
+ int flags;
+ char *app_data;
+ /* If this is non-NULL, it is used to generate DSA parameters */
+ int (*dsa_paramgen)(DSA *dsa, int bits,
+ unsigned char *seed, int seed_len,
+ int *counter_ret, unsigned long *h_ret,
+ BN_GENCB *cb);
+ /* If this is non-NULL, it is used to generate DSA keys */
+ int (*dsa_keygen)(DSA *dsa);
+ };
+
+struct dsa_st
+ {
+ /* This first variable is used to pick up errors where
+ * a DSA is passed instead of of a EVP_PKEY */
+ int pad;
+ long version;
+ int write_params;
+ BIGNUM *p;
+ BIGNUM *q; /* == 20 */
+ BIGNUM *g;
+
+ BIGNUM *pub_key; /* y public key */
+ BIGNUM *priv_key; /* x private key */
+
+ BIGNUM *kinv; /* Signing pre-calc */
+ BIGNUM *r; /* Signing pre-calc */
+
+ int flags;
+ /* Normally used to cache montgomery values */
+ BN_MONT_CTX *method_mont_p;
+ int references;
+ CRYPTO_EX_DATA ex_data;
+ const DSA_METHOD *meth;
+ /* functional reference if 'meth' is ENGINE-provided */
+ ENGINE *engine;
+ };
+
+#define DSAparams_dup(x) ASN1_dup_of_const(DSA,i2d_DSAparams,d2i_DSAparams,x)
+#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
+ (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))
+#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \
+ (unsigned char *)(x))
+#define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)
+#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)
+
+
+DSA_SIG * DSA_SIG_new(void);
+void DSA_SIG_free(DSA_SIG *a);
+int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
+DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
+
+DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
+int DSA_do_verify(const unsigned char *dgst,int dgst_len,
+ DSA_SIG *sig,DSA *dsa);
+
+const DSA_METHOD *DSA_OpenSSL(void);
+
+void DSA_set_default_method(const DSA_METHOD *);
+const DSA_METHOD *DSA_get_default_method(void);
+int DSA_set_method(DSA *dsa, const DSA_METHOD *);
+
+#ifdef OPENSSL_FIPS
+DSA * FIPS_dsa_new(void);
+void FIPS_dsa_free (DSA *r);
+#endif
+
+DSA * DSA_new(void);
+DSA * DSA_new_method(ENGINE *engine);
+void DSA_free (DSA *r);
+/* "up" the DSA object's reference count */
+int DSA_up_ref(DSA *r);
+int DSA_size(const DSA *);
+ /* next 4 return -1 on error */
+int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp);
+int DSA_sign(int type,const unsigned char *dgst,int dlen,
+ unsigned char *sig, unsigned int *siglen, DSA *dsa);
+int DSA_verify(int type,const unsigned char *dgst,int dgst_len,
+ const unsigned char *sigbuf, int siglen, DSA *dsa);
+int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int DSA_set_ex_data(DSA *d, int idx, void *arg);
+void *DSA_get_ex_data(DSA *d, int idx);
+
+DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
+DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
+DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
+
+/* Deprecated version */
+#ifndef OPENSSL_NO_DEPRECATED
+DSA * DSA_generate_parameters(int bits,
+ unsigned char *seed,int seed_len,
+ int *counter_ret, unsigned long *h_ret,void
+ (*callback)(int, int, void *),void *cb_arg);
+#endif /* !defined(OPENSSL_NO_DEPRECATED) */
+
+/* New version */
+int DSA_generate_parameters_ex(DSA *dsa, int bits,
+ unsigned char *seed,int seed_len,
+ int *counter_ret, unsigned long *h_ret, BN_GENCB *cb);
+
+int DSA_generate_key(DSA *a);
+int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
+int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
+int i2d_DSAparams(const DSA *a,unsigned char **pp);
+
+#ifndef OPENSSL_NO_BIO
+int DSAparams_print(BIO *bp, const DSA *x);
+int DSA_print(BIO *bp, const DSA *x, int off);
+#endif
+#ifndef OPENSSL_NO_FP_API
+int DSAparams_print_fp(FILE *fp, const DSA *x);
+int DSA_print_fp(FILE *bp, const DSA *x, int off);
+#endif
+
+#define DSS_prime_checks 50
+/* Primality test according to FIPS PUB 186[-1], Appendix 2.1:
+ * 50 rounds of Rabin-Miller */
+#define DSA_is_prime(n, callback, cb_arg) \
+ BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
+
+#ifndef OPENSSL_NO_DH
+/* Convert DSA structure (key or just parameters) into DH structure
+ * (be careful to avoid small subgroup attacks when using this!) */
+DH *DSA_dup_DH(const DSA *r);
+#endif
+
+#ifdef OPENSSL_FIPS
+int FIPS_dsa_sig_encode(unsigned char *out, DSA_SIG *sig);
+int FIPS_dsa_sig_decode(DSA_SIG *sig, const unsigned char *in, int inlen);
+#endif
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_DSA_strings(void);
+
+/* Error codes for the DSA functions. */
+
+/* Function codes. */
+#define DSA_F_D2I_DSA_SIG 110
+#define DSA_F_DSAPARAMS_PRINT 100
+#define DSA_F_DSAPARAMS_PRINT_FP 101
+#define DSA_F_DSA_BUILTIN_KEYGEN 119
+#define DSA_F_DSA_BUILTIN_PARAMGEN 118
+#define DSA_F_DSA_DO_SIGN 112
+#define DSA_F_DSA_DO_VERIFY 113
+#define DSA_F_DSA_GENERATE_PARAMETERS 117
+#define DSA_F_DSA_NEW_METHOD 103
+#define DSA_F_DSA_PRINT 104
+#define DSA_F_DSA_PRINT_FP 105
+#define DSA_F_DSA_SET_DEFAULT_METHOD 115
+#define DSA_F_DSA_SET_METHOD 116
+#define DSA_F_DSA_SIGN 106
+#define DSA_F_DSA_SIGN_SETUP 107
+#define DSA_F_DSA_SIG_NEW 109
+#define DSA_F_DSA_VERIFY 108
+#define DSA_F_I2D_DSA_SIG 111
+#define DSA_F_SIG_CB 114
+
+/* Reason codes. */
+#define DSA_R_BAD_Q_VALUE 102
+#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
+#define DSA_R_KEY_SIZE_TOO_SMALL 106
+#define DSA_R_MISSING_PARAMETERS 101
+#define DSA_R_MODULUS_TOO_LARGE 103
+#define DSA_R_NON_FIPS_METHOD 104
+#define DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 105
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dso.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dso.h
new file mode 100644
index 000000000..3e51913a7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dso.h
@@ -0,0 +1,368 @@
+/* dso.h -*- mode:C; c-file-style: "eay" -*- */
+/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
+ * project 2000.
+ */
+/* ====================================================================
+ * Copyright (c) 2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_DSO_H
+#define HEADER_DSO_H
+
+#include <openssl/crypto.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These values are used as commands to DSO_ctrl() */
+#define DSO_CTRL_GET_FLAGS 1
+#define DSO_CTRL_SET_FLAGS 2
+#define DSO_CTRL_OR_FLAGS 3
+
+/* By default, DSO_load() will translate the provided filename into a form
+ * typical for the platform (more specifically the DSO_METHOD) using the
+ * dso_name_converter function of the method. Eg. win32 will transform "blah"
+ * into "blah.dll", and dlfcn will transform it into "libblah.so". The
+ * behaviour can be overriden by setting the name_converter callback in the DSO
+ * object (using DSO_set_name_converter()). This callback could even utilise
+ * the DSO_METHOD's converter too if it only wants to override behaviour for
+ * one or two possible DSO methods. However, the following flag can be set in a
+ * DSO to prevent *any* native name-translation at all - eg. if the caller has
+ * prompted the user for a path to a driver library so the filename should be
+ * interpreted as-is. */
+#define DSO_FLAG_NO_NAME_TRANSLATION 0x01
+/* An extra flag to give if only the extension should be added as
+ * translation. This is obviously only of importance on Unix and
+ * other operating systems where the translation also may prefix
+ * the name with something, like 'lib', and ignored everywhere else.
+ * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used
+ * at the same time. */
+#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02
+
+/* The following flag controls the translation of symbol names to upper
+ * case. This is currently only being implemented for OpenVMS.
+ */
+#define DSO_FLAG_UPCASE_SYMBOL 0x10
+
+/* This flag loads the library with public symbols.
+ * Meaning: The exported symbols of this library are public
+ * to all libraries loaded after this library.
+ * At the moment only implemented in unix.
+ */
+#define DSO_FLAG_GLOBAL_SYMBOLS 0x20
+
+
+typedef void (*DSO_FUNC_TYPE)(void);
+
+typedef struct dso_st DSO;
+
+/* The function prototype used for method functions (or caller-provided
+ * callbacks) that transform filenames. They are passed a DSO structure pointer
+ * (or NULL if they are to be used independantly of a DSO object) and a
+ * filename to transform. They should either return NULL (if there is an error
+ * condition) or a newly allocated string containing the transformed form that
+ * the caller will need to free with OPENSSL_free() when done. */
+typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *);
+/* The function prototype used for method functions (or caller-provided
+ * callbacks) that merge two file specifications. They are passed a
+ * DSO structure pointer (or NULL if they are to be used independantly of
+ * a DSO object) and two file specifications to merge. They should
+ * either return NULL (if there is an error condition) or a newly allocated
+ * string containing the result of merging that the caller will need
+ * to free with OPENSSL_free() when done.
+ * Here, merging means that bits and pieces are taken from each of the
+ * file specifications and added together in whatever fashion that is
+ * sensible for the DSO method in question. The only rule that really
+ * applies is that if the two specification contain pieces of the same
+ * type, the copy from the first string takes priority. One could see
+ * it as the first specification is the one given by the user and the
+ * second being a bunch of defaults to add on if they're missing in the
+ * first. */
+typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *);
+
+typedef struct dso_meth_st
+ {
+ const char *name;
+ /* Loads a shared library, NB: new DSO_METHODs must ensure that a
+ * successful load populates the loaded_filename field, and likewise a
+ * successful unload OPENSSL_frees and NULLs it out. */
+ int (*dso_load)(DSO *dso);
+ /* Unloads a shared library */
+ int (*dso_unload)(DSO *dso);
+ /* Binds a variable */
+ void *(*dso_bind_var)(DSO *dso, const char *symname);
+ /* Binds a function - assumes a return type of DSO_FUNC_TYPE.
+ * This should be cast to the real function prototype by the
+ * caller. Platforms that don't have compatible representations
+ * for different prototypes (this is possible within ANSI C)
+ * are highly unlikely to have shared libraries at all, let
+ * alone a DSO_METHOD implemented for them. */
+ DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname);
+
+/* I don't think this would actually be used in any circumstances. */
+#if 0
+ /* Unbinds a variable */
+ int (*dso_unbind_var)(DSO *dso, char *symname, void *symptr);
+ /* Unbinds a function */
+ int (*dso_unbind_func)(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
+#endif
+ /* The generic (yuck) "ctrl()" function. NB: Negative return
+ * values (rather than zero) indicate errors. */
+ long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg);
+ /* The default DSO_METHOD-specific function for converting filenames to
+ * a canonical native form. */
+ DSO_NAME_CONVERTER_FUNC dso_name_converter;
+ /* The default DSO_METHOD-specific function for converting filenames to
+ * a canonical native form. */
+ DSO_MERGER_FUNC dso_merger;
+
+ /* [De]Initialisation handlers. */
+ int (*init)(DSO *dso);
+ int (*finish)(DSO *dso);
+ } DSO_METHOD;
+
+/**********************************************************************/
+/* The low-level handle type used to refer to a loaded shared library */
+
+struct dso_st
+ {
+ DSO_METHOD *meth;
+ /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS
+ * doesn't use anything but will need to cache the filename
+ * for use in the dso_bind handler. All in all, let each
+ * method control its own destiny. "Handles" and such go in
+ * a STACK. */
+ STACK *meth_data;
+ int references;
+ int flags;
+ /* For use by applications etc ... use this for your bits'n'pieces,
+ * don't touch meth_data! */
+ CRYPTO_EX_DATA ex_data;
+ /* If this callback function pointer is set to non-NULL, then it will
+ * be used in DSO_load() in place of meth->dso_name_converter. NB: This
+ * should normally set using DSO_set_name_converter(). */
+ DSO_NAME_CONVERTER_FUNC name_converter;
+ /* If this callback function pointer is set to non-NULL, then it will
+ * be used in DSO_load() in place of meth->dso_merger. NB: This
+ * should normally set using DSO_set_merger(). */
+ DSO_MERGER_FUNC merger;
+ /* This is populated with (a copy of) the platform-independant
+ * filename used for this DSO. */
+ char *filename;
+ /* This is populated with (a copy of) the translated filename by which
+ * the DSO was actually loaded. It is NULL iff the DSO is not currently
+ * loaded. NB: This is here because the filename translation process
+ * may involve a callback being invoked more than once not only to
+ * convert to a platform-specific form, but also to try different
+ * filenames in the process of trying to perform a load. As such, this
+ * variable can be used to indicate (a) whether this DSO structure
+ * corresponds to a loaded library or not, and (b) the filename with
+ * which it was actually loaded. */
+ char *loaded_filename;
+ };
+
+
+DSO * DSO_new(void);
+DSO * DSO_new_method(DSO_METHOD *method);
+int DSO_free(DSO *dso);
+int DSO_flags(DSO *dso);
+int DSO_up_ref(DSO *dso);
+long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);
+
+/* This function sets the DSO's name_converter callback. If it is non-NULL,
+ * then it will be used instead of the associated DSO_METHOD's function. If
+ * oldcb is non-NULL then it is set to the function pointer value being
+ * replaced. Return value is non-zero for success. */
+int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,
+ DSO_NAME_CONVERTER_FUNC *oldcb);
+/* These functions can be used to get/set the platform-independant filename
+ * used for a DSO. NB: set will fail if the DSO is already loaded. */
+const char *DSO_get_filename(DSO *dso);
+int DSO_set_filename(DSO *dso, const char *filename);
+/* This function will invoke the DSO's name_converter callback to translate a
+ * filename, or if the callback isn't set it will instead use the DSO_METHOD's
+ * converter. If "filename" is NULL, the "filename" in the DSO itself will be
+ * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is
+ * simply duplicated. NB: This function is usually called from within a
+ * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that
+ * caller-created DSO_METHODs can do the same thing. A non-NULL return value
+ * will need to be OPENSSL_free()'d. */
+char *DSO_convert_filename(DSO *dso, const char *filename);
+/* This function will invoke the DSO's merger callback to merge two file
+ * specifications, or if the callback isn't set it will instead use the
+ * DSO_METHOD's merger. A non-NULL return value will need to be
+ * OPENSSL_free()'d. */
+char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2);
+/* If the DSO is currently loaded, this returns the filename that it was loaded
+ * under, otherwise it returns NULL. So it is also useful as a test as to
+ * whether the DSO is currently loaded. NB: This will not necessarily return
+ * the same value as DSO_convert_filename(dso, dso->filename), because the
+ * DSO_METHOD's load function may have tried a variety of filenames (with
+ * and/or without the aid of the converters) before settling on the one it
+ * actually loaded. */
+const char *DSO_get_loaded_filename(DSO *dso);
+
+void DSO_set_default_method(DSO_METHOD *meth);
+DSO_METHOD *DSO_get_default_method(void);
+DSO_METHOD *DSO_get_method(DSO *dso);
+DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth);
+
+/* The all-singing all-dancing load function, you normally pass NULL
+ * for the first and third parameters. Use DSO_up and DSO_free for
+ * subsequent reference count handling. Any flags passed in will be set
+ * in the constructed DSO after its init() function but before the
+ * load operation. If 'dso' is non-NULL, 'flags' is ignored. */
+DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags);
+
+/* This function binds to a variable inside a shared library. */
+void *DSO_bind_var(DSO *dso, const char *symname);
+
+/* This function binds to a function inside a shared library. */
+DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname);
+
+/* This method is the default, but will beg, borrow, or steal whatever
+ * method should be the default on any particular platform (including
+ * DSO_METH_null() if necessary). */
+DSO_METHOD *DSO_METHOD_openssl(void);
+
+/* This method is defined for all platforms - if a platform has no
+ * DSO support then this will be the only method! */
+DSO_METHOD *DSO_METHOD_null(void);
+
+/* If DSO_DLFCN is defined, the standard dlfcn.h-style functions
+ * (dlopen, dlclose, dlsym, etc) will be used and incorporated into
+ * this method. If not, this method will return NULL. */
+DSO_METHOD *DSO_METHOD_dlfcn(void);
+
+/* If DSO_DL is defined, the standard dl.h-style functions (shl_load,
+ * shl_unload, shl_findsym, etc) will be used and incorporated into
+ * this method. If not, this method will return NULL. */
+DSO_METHOD *DSO_METHOD_dl(void);
+
+/* If WIN32 is defined, use DLLs. If not, return NULL. */
+DSO_METHOD *DSO_METHOD_win32(void);
+
+/* If VMS is defined, use shared images. If not, return NULL. */
+DSO_METHOD *DSO_METHOD_vms(void);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_DSO_strings(void);
+
+/* Error codes for the DSO functions. */
+
+/* Function codes. */
+#define DSO_F_DLFCN_BIND_FUNC 100
+#define DSO_F_DLFCN_BIND_VAR 101
+#define DSO_F_DLFCN_LOAD 102
+#define DSO_F_DLFCN_MERGER 130
+#define DSO_F_DLFCN_NAME_CONVERTER 123
+#define DSO_F_DLFCN_UNLOAD 103
+#define DSO_F_DL_BIND_FUNC 104
+#define DSO_F_DL_BIND_VAR 105
+#define DSO_F_DL_LOAD 106
+#define DSO_F_DL_MERGER 131
+#define DSO_F_DL_NAME_CONVERTER 124
+#define DSO_F_DL_UNLOAD 107
+#define DSO_F_DSO_BIND_FUNC 108
+#define DSO_F_DSO_BIND_VAR 109
+#define DSO_F_DSO_CONVERT_FILENAME 126
+#define DSO_F_DSO_CTRL 110
+#define DSO_F_DSO_FREE 111
+#define DSO_F_DSO_GET_FILENAME 127
+#define DSO_F_DSO_GET_LOADED_FILENAME 128
+#define DSO_F_DSO_LOAD 112
+#define DSO_F_DSO_MERGE 132
+#define DSO_F_DSO_NEW_METHOD 113
+#define DSO_F_DSO_SET_FILENAME 129
+#define DSO_F_DSO_SET_NAME_CONVERTER 122
+#define DSO_F_DSO_UP_REF 114
+#define DSO_F_VMS_BIND_SYM 115
+#define DSO_F_VMS_LOAD 116
+#define DSO_F_VMS_MERGER 133
+#define DSO_F_VMS_UNLOAD 117
+#define DSO_F_WIN32_BIND_FUNC 118
+#define DSO_F_WIN32_BIND_VAR 119
+#define DSO_F_WIN32_JOINER 135
+#define DSO_F_WIN32_LOAD 120
+#define DSO_F_WIN32_MERGER 134
+#define DSO_F_WIN32_NAME_CONVERTER 125
+#define DSO_F_WIN32_SPLITTER 136
+#define DSO_F_WIN32_UNLOAD 121
+
+/* Reason codes. */
+#define DSO_R_CTRL_FAILED 100
+#define DSO_R_DSO_ALREADY_LOADED 110
+#define DSO_R_EMPTY_FILE_STRUCTURE 113
+#define DSO_R_FAILURE 114
+#define DSO_R_FILENAME_TOO_BIG 101
+#define DSO_R_FINISH_FAILED 102
+#define DSO_R_INCORRECT_FILE_SYNTAX 115
+#define DSO_R_LOAD_FAILED 103
+#define DSO_R_NAME_TRANSLATION_FAILED 109
+#define DSO_R_NO_FILENAME 111
+#define DSO_R_NO_FILE_SPECIFICATION 116
+#define DSO_R_NULL_HANDLE 104
+#define DSO_R_SET_FILENAME_FAILED 112
+#define DSO_R_STACK_ERROR 105
+#define DSO_R_SYM_FAILURE 106
+#define DSO_R_UNLOAD_FAILED 107
+#define DSO_R_UNSUPPORTED 108
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dtls1.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dtls1.h
new file mode 100644
index 000000000..f159d3711
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/dtls1.h
@@ -0,0 +1,218 @@
+/* ssl/dtls1.h */
+/*
+ * DTLS implementation written by Nagendra Modadugu
+ * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
+ */
+/* ====================================================================
+ * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_DTLS1_H
+#define HEADER_DTLS1_H
+
+#include <openssl/buffer.h>
+#include <openssl/pqueue.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DTLS1_VERSION 0xFEFF
+#define DTLS1_BAD_VER 0x0100
+
+#if 0
+/* this alert description is not specified anywhere... */
+#define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110
+#endif
+
+/* lengths of messages */
+#define DTLS1_COOKIE_LENGTH 32
+
+#define DTLS1_RT_HEADER_LENGTH 13
+
+#define DTLS1_HM_HEADER_LENGTH 12
+
+#define DTLS1_HM_BAD_FRAGMENT -2
+#define DTLS1_HM_FRAGMENT_RETRY -3
+
+#define DTLS1_CCS_HEADER_LENGTH 1
+
+#ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE
+#define DTLS1_AL_HEADER_LENGTH 7
+#else
+#define DTLS1_AL_HEADER_LENGTH 2
+#endif
+
+
+typedef struct dtls1_bitmap_st
+ {
+ PQ_64BIT map;
+ unsigned long length; /* sizeof the bitmap in bits */
+ PQ_64BIT max_seq_num; /* max record number seen so far */
+ } DTLS1_BITMAP;
+
+struct hm_header_st
+ {
+ unsigned char type;
+ unsigned long msg_len;
+ unsigned short seq;
+ unsigned long frag_off;
+ unsigned long frag_len;
+ unsigned int is_ccs;
+ };
+
+struct ccs_header_st
+ {
+ unsigned char type;
+ unsigned short seq;
+ };
+
+struct dtls1_timeout_st
+ {
+ /* Number of read timeouts so far */
+ unsigned int read_timeouts;
+
+ /* Number of write timeouts so far */
+ unsigned int write_timeouts;
+
+ /* Number of alerts received so far */
+ unsigned int num_alerts;
+ };
+
+typedef struct record_pqueue_st
+ {
+ unsigned short epoch;
+ pqueue q;
+ } record_pqueue;
+
+typedef struct hm_fragment_st
+ {
+ struct hm_header_st msg_header;
+ unsigned char *fragment;
+ } hm_fragment;
+
+typedef struct dtls1_state_st
+ {
+ unsigned int send_cookie;
+ unsigned char cookie[DTLS1_COOKIE_LENGTH];
+ unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH];
+ unsigned int cookie_len;
+
+ /*
+ * The current data and handshake epoch. This is initially
+ * undefined, and starts at zero once the initial handshake is
+ * completed
+ */
+ unsigned short r_epoch;
+ unsigned short w_epoch;
+
+ /* records being received in the current epoch */
+ DTLS1_BITMAP bitmap;
+
+ /* renegotiation starts a new set of sequence numbers */
+ DTLS1_BITMAP next_bitmap;
+
+ /* handshake message numbers */
+ unsigned short handshake_write_seq;
+ unsigned short next_handshake_write_seq;
+
+ unsigned short handshake_read_seq;
+
+ /* Received handshake records (processed and unprocessed) */
+ record_pqueue unprocessed_rcds;
+ record_pqueue processed_rcds;
+
+ /* Buffered handshake messages */
+ pqueue buffered_messages;
+
+ /* Buffered (sent) handshake records */
+ pqueue sent_messages;
+
+ unsigned int mtu; /* max wire packet size */
+
+ struct hm_header_st w_msg_hdr;
+ struct hm_header_st r_msg_hdr;
+
+ struct dtls1_timeout_st timeout;
+
+ /* storage for Alert/Handshake protocol data received but not
+ * yet processed by ssl3_read_bytes: */
+ unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH];
+ unsigned int alert_fragment_len;
+ unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH];
+ unsigned int handshake_fragment_len;
+
+ unsigned int retransmitting;
+
+ } DTLS1_STATE;
+
+typedef struct dtls1_record_data_st
+ {
+ unsigned char *packet;
+ unsigned int packet_length;
+ SSL3_BUFFER rbuf;
+ SSL3_RECORD rrec;
+ } DTLS1_RECORD_DATA;
+
+
+/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */
+#define DTLS1_TMO_READ_COUNT 2
+#define DTLS1_TMO_WRITE_COUNT 2
+
+#define DTLS1_TMO_ALERT_COUNT 12
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/e_os2.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/e_os2.h
new file mode 100644
index 000000000..9da0b6544
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/e_os2.h
@@ -0,0 +1,279 @@
+/* e_os2.h */
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#include <openssl/opensslconf.h>
+
+#ifndef HEADER_E_OS2_H
+#define HEADER_E_OS2_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************
+ * Detect operating systems. This probably needs completing.
+ * The result is that at least one OPENSSL_SYS_os macro should be defined.
+ * However, if none is defined, Unix is assumed.
+ **/
+
+#define OPENSSL_SYS_UNIX
+
+/* ----------------------- Macintosh, before MacOS X ----------------------- */
+#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_MACINTOSH_CLASSIC
+#endif
+
+/* ----------------------- NetWare ----------------------------------------- */
+#if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_NETWARE
+#endif
+
+/* ---------------------- Microsoft operating systems ---------------------- */
+
+/* Note that MSDOS actually denotes 32-bit environments running on top of
+ MS-DOS, such as DJGPP one. */
+#if defined(OPENSSL_SYSNAME_MSDOS)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_MSDOS
+#endif
+
+/* For 32 bit environment, there seems to be the CygWin environment and then
+ all the others that try to do the same thing Microsoft does... */
+#if defined(OPENSSL_SYSNAME_UWIN)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_WIN32_UWIN
+#else
+# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_WIN32_CYGWIN
+# else
+# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_WIN32
+# endif
+# if defined(OPENSSL_SYSNAME_WINNT)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_WINNT
+# endif
+# if defined(OPENSSL_SYSNAME_WINCE)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_WINCE
+# endif
+# endif
+#endif
+
+/* Anything that tries to look like Microsoft is "Windows" */
+#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_WINDOWS
+# ifndef OPENSSL_SYS_MSDOS
+# define OPENSSL_SYS_MSDOS
+# endif
+#endif
+
+/* DLL settings. This part is a bit tough, because it's up to the application
+ implementor how he or she will link the application, so it requires some
+ macro to be used. */
+#ifdef OPENSSL_SYS_WINDOWS
+# ifndef OPENSSL_OPT_WINDLL
+# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that
+ DLL linkage should be used */
+# define OPENSSL_OPT_WINDLL
+# endif
+# endif
+#endif
+
+/* -------------------------------- OpenVMS -------------------------------- */
+#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_VMS
+# if defined(__DECC)
+# define OPENSSL_SYS_VMS_DECC
+# elif defined(__DECCXX)
+# define OPENSSL_SYS_VMS_DECC
+# define OPENSSL_SYS_VMS_DECCXX
+# else
+# define OPENSSL_SYS_VMS_NODECC
+# endif
+#endif
+
+/* --------------------------------- OS/2 ---------------------------------- */
+#if defined(__EMX__) || defined(__OS2__)
+# undef OPENSSL_SYS_UNIX
+# define OPENSSL_SYS_OS2
+#endif
+
+/* --------------------------------- Unix ---------------------------------- */
+#ifdef OPENSSL_SYS_UNIX
+# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX)
+# define OPENSSL_SYS_LINUX
+# endif
+# ifdef OPENSSL_SYSNAME_MPE
+# define OPENSSL_SYS_MPE
+# endif
+# ifdef OPENSSL_SYSNAME_SNI
+# define OPENSSL_SYS_SNI
+# endif
+# ifdef OPENSSL_SYSNAME_ULTRASPARC
+# define OPENSSL_SYS_ULTRASPARC
+# endif
+# ifdef OPENSSL_SYSNAME_NEWS4
+# define OPENSSL_SYS_NEWS4
+# endif
+# ifdef OPENSSL_SYSNAME_MACOSX
+# define OPENSSL_SYS_MACOSX
+# endif
+# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY
+# define OPENSSL_SYS_MACOSX_RHAPSODY
+# define OPENSSL_SYS_MACOSX
+# endif
+# ifdef OPENSSL_SYSNAME_SUNOS
+# define OPENSSL_SYS_SUNOS
+#endif
+# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY)
+# define OPENSSL_SYS_CRAY
+# endif
+# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX)
+# define OPENSSL_SYS_AIX
+# endif
+#endif
+
+/* --------------------------------- VOS ----------------------------------- */
+#ifdef OPENSSL_SYSNAME_VOS
+# define OPENSSL_SYS_VOS
+#endif
+
+/* ------------------------------- VxWorks --------------------------------- */
+#ifdef OPENSSL_SYSNAME_VXWORKS
+# define OPENSSL_SYS_VXWORKS
+#endif
+
+/**
+ * That's it for OS-specific stuff
+ *****************************************************************************/
+
+
+/* Specials for I/O an exit */
+#ifdef OPENSSL_SYS_MSDOS
+# define OPENSSL_UNISTD_IO <io.h>
+# define OPENSSL_DECLARE_EXIT extern void exit(int);
+#else
+# define OPENSSL_UNISTD_IO OPENSSL_UNISTD
+# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */
+#endif
+
+/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare
+ certain global symbols that, with some compilers under VMS, have to be
+ defined and declared explicitely with globaldef and globalref.
+ Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare
+ DLL exports and imports for compilers under Win32. These are a little
+ more complicated to use. Basically, for any library that exports some
+ global variables, the following code must be present in the header file
+ that declares them, before OPENSSL_EXTERN is used:
+
+ #ifdef SOME_BUILD_FLAG_MACRO
+ # undef OPENSSL_EXTERN
+ # define OPENSSL_EXTERN OPENSSL_EXPORT
+ #endif
+
+ The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL
+ have some generally sensible values, and for OPENSSL_EXTERN to have the
+ value OPENSSL_IMPORT.
+*/
+
+#if defined(OPENSSL_SYS_VMS_NODECC)
+# define OPENSSL_EXPORT globalref
+# define OPENSSL_IMPORT globalref
+# define OPENSSL_GLOBAL globaldef
+#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
+# define OPENSSL_EXPORT extern __declspec(dllexport)
+# define OPENSSL_IMPORT extern __declspec(dllimport)
+# define OPENSSL_GLOBAL
+#else
+# define OPENSSL_EXPORT extern
+# define OPENSSL_IMPORT extern
+# define OPENSSL_GLOBAL
+#endif
+#define OPENSSL_EXTERN OPENSSL_IMPORT
+
+/* Macros to allow global variables to be reached through function calls when
+ required (if a shared library version requvres it, for example.
+ The way it's done allows definitions like this:
+
+ // in foobar.c
+ OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0;
+ // in foobar.h
+ OPENSSL_DECLARE_GLOBAL(int,foobar);
+ #define foobar OPENSSL_GLOBAL_REF(foobar)
+*/
+#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION
+# define OPENSSL_IMPLEMENT_GLOBAL(type,name) \
+ extern type _hide_##name; \
+ type *_shadow_##name(void) { return &_hide_##name; } \
+ static type _hide_##name
+# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)
+# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))
+#else
+# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name
+# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name
+# define OPENSSL_GLOBAL_REF(name) _shadow_##name
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ebcdic.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ebcdic.h
new file mode 100644
index 000000000..6d65afcf9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ebcdic.h
@@ -0,0 +1,19 @@
+/* crypto/ebcdic.h */
+
+#ifndef HEADER_EBCDIC_H
+#define HEADER_EBCDIC_H
+
+#include <sys/types.h>
+
+/* Avoid name clashes with other applications */
+#define os_toascii _openssl_os_toascii
+#define os_toebcdic _openssl_os_toebcdic
+#define ebcdic2ascii _openssl_ebcdic2ascii
+#define ascii2ebcdic _openssl_ascii2ebcdic
+
+extern const unsigned char os_toascii[256];
+extern const unsigned char os_toebcdic[256];
+void *ebcdic2ascii(void *dest, const void *srce, size_t count);
+void *ascii2ebcdic(void *dest, const void *srce, size_t count);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ec.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ec.h
new file mode 100644
index 000000000..8bc2a235b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ec.h
@@ -0,0 +1,526 @@
+/* crypto/ec/ec.h */
+/*
+ * Originally written by Bodo Moeller for the OpenSSL project.
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ *
+ * Portions of the attached software ("Contribution") are developed by
+ * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
+ *
+ * The Contribution is licensed pursuant to the OpenSSL open source
+ * license provided above.
+ *
+ * The elliptic curve binary polynomial software is originally written by
+ * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
+ *
+ */
+
+#ifndef HEADER_EC_H
+#define HEADER_EC_H
+
+#include <openssl/opensslconf.h>
+
+#ifdef OPENSSL_NO_EC
+#error EC is disabled.
+#endif
+
+#include <openssl/asn1.h>
+#include <openssl/symhacks.h>
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/bn.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#elif defined(__SUNPRO_C)
+# if __SUNPRO_C >= 0x520
+# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
+# endif
+#endif
+
+
+#ifndef OPENSSL_ECC_MAX_FIELD_BITS
+# define OPENSSL_ECC_MAX_FIELD_BITS 661
+#endif
+
+typedef enum {
+ /* values as defined in X9.62 (ECDSA) and elsewhere */
+ POINT_CONVERSION_COMPRESSED = 2,
+ POINT_CONVERSION_UNCOMPRESSED = 4,
+ POINT_CONVERSION_HYBRID = 6
+} point_conversion_form_t;
+
+
+typedef struct ec_method_st EC_METHOD;
+
+typedef struct ec_group_st
+ /*
+ EC_METHOD *meth;
+ -- field definition
+ -- curve coefficients
+ -- optional generator with associated information (order, cofactor)
+ -- optional extra data (precomputed table for fast computation of multiples of generator)
+ -- ASN1 stuff
+ */
+ EC_GROUP;
+
+typedef struct ec_point_st EC_POINT;
+
+
+/* EC_METHODs for curves over GF(p).
+ * EC_GFp_simple_method provides the basis for the optimized methods.
+ */
+const EC_METHOD *EC_GFp_simple_method(void);
+const EC_METHOD *EC_GFp_mont_method(void);
+const EC_METHOD *EC_GFp_nist_method(void);
+
+/* EC_METHOD for curves over GF(2^m).
+ */
+const EC_METHOD *EC_GF2m_simple_method(void);
+
+
+EC_GROUP *EC_GROUP_new(const EC_METHOD *);
+void EC_GROUP_free(EC_GROUP *);
+void EC_GROUP_clear_free(EC_GROUP *);
+int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *);
+EC_GROUP *EC_GROUP_dup(const EC_GROUP *);
+
+const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *);
+int EC_METHOD_get_field_type(const EC_METHOD *);
+
+int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
+const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *);
+int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *);
+int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *);
+
+void EC_GROUP_set_curve_name(EC_GROUP *, int nid);
+int EC_GROUP_get_curve_name(const EC_GROUP *);
+
+void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag);
+int EC_GROUP_get_asn1_flag(const EC_GROUP *);
+
+void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t);
+point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
+
+unsigned char *EC_GROUP_get0_seed(const EC_GROUP *);
+size_t EC_GROUP_get_seed_len(const EC_GROUP *);
+size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
+
+int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
+int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *);
+int EC_GROUP_set_curve_GF2m(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
+int EC_GROUP_get_curve_GF2m(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *);
+
+/* returns the number of bits needed to represent a field element */
+int EC_GROUP_get_degree(const EC_GROUP *);
+
+/* EC_GROUP_check() returns 1 if 'group' defines a valid group, 0 otherwise */
+int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
+/* EC_GROUP_check_discriminant() returns 1 if the discriminant of the
+ * elliptic curve is not zero, 0 otherwise */
+int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *);
+
+/* EC_GROUP_cmp() returns 0 if both groups are equal and 1 otherwise */
+int EC_GROUP_cmp(const EC_GROUP *, const EC_GROUP *, BN_CTX *);
+
+/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*()
+ * after choosing an appropriate EC_METHOD */
+EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
+EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
+
+/* EC_GROUP_new_by_curve_name() creates a EC_GROUP structure
+ * specified by a curve name (in form of a NID) */
+EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
+/* handling of internal curves */
+typedef struct {
+ int nid;
+ const char *comment;
+ } EC_builtin_curve;
+/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number
+ * of all available curves or zero if a error occurred.
+ * In case r ist not zero nitems EC_builtin_curve structures
+ * are filled with the data of the first nitems internal groups */
+size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
+
+
+/* EC_POINT functions */
+
+EC_POINT *EC_POINT_new(const EC_GROUP *);
+void EC_POINT_free(EC_POINT *);
+void EC_POINT_clear_free(EC_POINT *);
+int EC_POINT_copy(EC_POINT *, const EC_POINT *);
+EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *);
+
+const EC_METHOD *EC_POINT_method_of(const EC_POINT *);
+
+int EC_POINT_set_to_infinity(const EC_GROUP *, EC_POINT *);
+int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *);
+int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *,
+ BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *);
+int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x, const BIGNUM *y, BN_CTX *);
+int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *,
+ BIGNUM *x, BIGNUM *y, BN_CTX *);
+int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x, int y_bit, BN_CTX *);
+
+int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x, const BIGNUM *y, BN_CTX *);
+int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, const EC_POINT *,
+ BIGNUM *x, BIGNUM *y, BN_CTX *);
+int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x, int y_bit, BN_CTX *);
+
+size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form,
+ unsigned char *buf, size_t len, BN_CTX *);
+int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *,
+ const unsigned char *buf, size_t len, BN_CTX *);
+
+/* other interfaces to point2oct/oct2point: */
+BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
+ point_conversion_form_t form, BIGNUM *, BN_CTX *);
+EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
+ EC_POINT *, BN_CTX *);
+char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
+ point_conversion_form_t form, BN_CTX *);
+EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
+ EC_POINT *, BN_CTX *);
+
+int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
+int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
+int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
+
+int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *);
+int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);
+int EC_POINT_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
+
+int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
+int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
+
+
+int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *);
+int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *);
+
+/* EC_GROUP_precompute_mult() stores multiples of generator for faster point multiplication */
+int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *);
+/* EC_GROUP_have_precompute_mult() reports whether such precomputation has been done */
+int EC_GROUP_have_precompute_mult(const EC_GROUP *);
+
+
+
+/* ASN1 stuff */
+
+/* EC_GROUP_get_basis_type() returns the NID of the basis type
+ * used to represent the field elements */
+int EC_GROUP_get_basis_type(const EC_GROUP *);
+int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
+int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
+ unsigned int *k2, unsigned int *k3);
+
+#define OPENSSL_EC_NAMED_CURVE 0x001
+
+typedef struct ecpk_parameters_st ECPKPARAMETERS;
+
+EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
+int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
+
+#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
+#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
+#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
+ (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
+#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
+ (unsigned char *)(x))
+
+#ifndef OPENSSL_NO_BIO
+int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
+#endif
+#ifndef OPENSSL_NO_FP_API
+int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
+#endif
+
+/* the EC_KEY stuff */
+typedef struct ec_key_st EC_KEY;
+
+/* some values for the encoding_flag */
+#define EC_PKEY_NO_PARAMETERS 0x001
+#define EC_PKEY_NO_PUBKEY 0x002
+
+EC_KEY *EC_KEY_new(void);
+EC_KEY *EC_KEY_new_by_curve_name(int nid);
+void EC_KEY_free(EC_KEY *);
+EC_KEY *EC_KEY_copy(EC_KEY *, const EC_KEY *);
+EC_KEY *EC_KEY_dup(const EC_KEY *);
+
+int EC_KEY_up_ref(EC_KEY *);
+
+const EC_GROUP *EC_KEY_get0_group(const EC_KEY *);
+int EC_KEY_set_group(EC_KEY *, const EC_GROUP *);
+const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *);
+int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *);
+const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *);
+int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *);
+unsigned EC_KEY_get_enc_flags(const EC_KEY *);
+void EC_KEY_set_enc_flags(EC_KEY *, unsigned int);
+point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *);
+void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t);
+/* functions to set/get method specific data */
+void *EC_KEY_get_key_method_data(EC_KEY *,
+ void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
+void EC_KEY_insert_key_method_data(EC_KEY *, void *data,
+ void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
+/* wrapper functions for the underlying EC_GROUP object */
+void EC_KEY_set_asn1_flag(EC_KEY *, int);
+int EC_KEY_precompute_mult(EC_KEY *, BN_CTX *ctx);
+
+/* EC_KEY_generate_key() creates a ec private (public) key */
+int EC_KEY_generate_key(EC_KEY *);
+/* EC_KEY_check_key() */
+int EC_KEY_check_key(const EC_KEY *);
+
+/* de- and encoding functions for SEC1 ECPrivateKey */
+EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len);
+int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out);
+/* de- and encoding functions for EC parameters */
+EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len);
+int i2d_ECParameters(EC_KEY *a, unsigned char **out);
+/* de- and encoding functions for EC public key
+ * (octet string, not DER -- hence 'o2i' and 'i2o') */
+EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len);
+int i2o_ECPublicKey(EC_KEY *a, unsigned char **out);
+
+#ifndef OPENSSL_NO_BIO
+int ECParameters_print(BIO *bp, const EC_KEY *x);
+int EC_KEY_print(BIO *bp, const EC_KEY *x, int off);
+#endif
+#ifndef OPENSSL_NO_FP_API
+int ECParameters_print_fp(FILE *fp, const EC_KEY *x);
+int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off);
+#endif
+
+#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
+
+#ifndef __cplusplus
+#if defined(__SUNPRO_C)
+# if __SUNPRO_C >= 0x520
+# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
+# endif
+# endif
+#endif
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_EC_strings(void);
+
+/* Error codes for the EC functions. */
+
+/* Function codes. */
+#define EC_F_COMPUTE_WNAF 143
+#define EC_F_D2I_ECPARAMETERS 144
+#define EC_F_D2I_ECPKPARAMETERS 145
+#define EC_F_D2I_ECPRIVATEKEY 146
+#define EC_F_ECPARAMETERS_PRINT 147
+#define EC_F_ECPARAMETERS_PRINT_FP 148
+#define EC_F_ECPKPARAMETERS_PRINT 149
+#define EC_F_ECPKPARAMETERS_PRINT_FP 150
+#define EC_F_ECP_NIST_MOD_192 203
+#define EC_F_ECP_NIST_MOD_224 204
+#define EC_F_ECP_NIST_MOD_256 205
+#define EC_F_ECP_NIST_MOD_521 206
+#define EC_F_EC_ASN1_GROUP2CURVE 153
+#define EC_F_EC_ASN1_GROUP2FIELDID 154
+#define EC_F_EC_ASN1_GROUP2PARAMETERS 155
+#define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156
+#define EC_F_EC_ASN1_PARAMETERS2GROUP 157
+#define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158
+#define EC_F_EC_EX_DATA_SET_DATA 211
+#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208
+#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159
+#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195
+#define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160
+#define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161
+#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
+#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
+#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164
+#define EC_F_EC_GFP_MONT_FIELD_DECODE 133
+#define EC_F_EC_GFP_MONT_FIELD_ENCODE 134
+#define EC_F_EC_GFP_MONT_FIELD_MUL 131
+#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209
+#define EC_F_EC_GFP_MONT_FIELD_SQR 132
+#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189
+#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135
+#define EC_F_EC_GFP_NIST_FIELD_MUL 200
+#define EC_F_EC_GFP_NIST_FIELD_SQR 201
+#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202
+#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165
+#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166
+#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100
+#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101
+#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
+#define EC_F_EC_GFP_SIMPLE_OCT2POINT 103
+#define EC_F_EC_GFP_SIMPLE_POINT2OCT 104
+#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137
+#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167
+#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
+#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168
+#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
+#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169
+#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
+#define EC_F_EC_GROUP_CHECK 170
+#define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
+#define EC_F_EC_GROUP_COPY 106
+#define EC_F_EC_GROUP_GET0_GENERATOR 139
+#define EC_F_EC_GROUP_GET_COFACTOR 140
+#define EC_F_EC_GROUP_GET_CURVE_GF2M 172
+#define EC_F_EC_GROUP_GET_CURVE_GFP 130
+#define EC_F_EC_GROUP_GET_DEGREE 173
+#define EC_F_EC_GROUP_GET_ORDER 141
+#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193
+#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194
+#define EC_F_EC_GROUP_NEW 108
+#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174
+#define EC_F_EC_GROUP_NEW_FROM_DATA 175
+#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142
+#define EC_F_EC_GROUP_SET_CURVE_GF2M 176
+#define EC_F_EC_GROUP_SET_CURVE_GFP 109
+#define EC_F_EC_GROUP_SET_EXTRA_DATA 110
+#define EC_F_EC_GROUP_SET_GENERATOR 111
+#define EC_F_EC_KEY_CHECK_KEY 177
+#define EC_F_EC_KEY_COPY 178
+#define EC_F_EC_KEY_GENERATE_KEY 179
+#define EC_F_EC_KEY_NEW 182
+#define EC_F_EC_KEY_PRINT 180
+#define EC_F_EC_KEY_PRINT_FP 181
+#define EC_F_EC_POINTS_MAKE_AFFINE 136
+#define EC_F_EC_POINTS_MUL 138
+#define EC_F_EC_POINT_ADD 112
+#define EC_F_EC_POINT_CMP 113
+#define EC_F_EC_POINT_COPY 114
+#define EC_F_EC_POINT_DBL 115
+#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
+#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
+#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
+#define EC_F_EC_POINT_INVERT 210
+#define EC_F_EC_POINT_IS_AT_INFINITY 118
+#define EC_F_EC_POINT_IS_ON_CURVE 119
+#define EC_F_EC_POINT_MAKE_AFFINE 120
+#define EC_F_EC_POINT_MUL 184
+#define EC_F_EC_POINT_NEW 121
+#define EC_F_EC_POINT_OCT2POINT 122
+#define EC_F_EC_POINT_POINT2OCT 123
+#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
+#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
+#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
+#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
+#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
+#define EC_F_EC_POINT_SET_TO_INFINITY 127
+#define EC_F_EC_PRE_COMP_DUP 207
+#define EC_F_EC_PRE_COMP_NEW 196
+#define EC_F_EC_WNAF_MUL 187
+#define EC_F_EC_WNAF_PRECOMPUTE_MULT 188
+#define EC_F_I2D_ECPARAMETERS 190
+#define EC_F_I2D_ECPKPARAMETERS 191
+#define EC_F_I2D_ECPRIVATEKEY 192
+#define EC_F_I2O_ECPUBLICKEY 151
+#define EC_F_O2I_ECPUBLICKEY 152
+
+/* Reason codes. */
+#define EC_R_ASN1_ERROR 115
+#define EC_R_ASN1_UNKNOWN_FIELD 116
+#define EC_R_BUFFER_TOO_SMALL 100
+#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
+#define EC_R_DISCRIMINANT_IS_ZERO 118
+#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
+#define EC_R_FIELD_TOO_LARGE 138
+#define EC_R_GROUP2PKPARAMETERS_FAILURE 120
+#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
+#define EC_R_INCOMPATIBLE_OBJECTS 101
+#define EC_R_INVALID_ARGUMENT 112
+#define EC_R_INVALID_COMPRESSED_POINT 110
+#define EC_R_INVALID_COMPRESSION_BIT 109
+#define EC_R_INVALID_ENCODING 102
+#define EC_R_INVALID_FIELD 103
+#define EC_R_INVALID_FORM 104
+#define EC_R_INVALID_GROUP_ORDER 122
+#define EC_R_INVALID_PENTANOMIAL_BASIS 132
+#define EC_R_INVALID_PRIVATE_KEY 123
+#define EC_R_INVALID_TRINOMIAL_BASIS 137
+#define EC_R_MISSING_PARAMETERS 124
+#define EC_R_MISSING_PRIVATE_KEY 125
+#define EC_R_NOT_A_NIST_PRIME 135
+#define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136
+#define EC_R_NOT_IMPLEMENTED 126
+#define EC_R_NOT_INITIALIZED 111
+#define EC_R_NO_FIELD_MOD 133
+#define EC_R_PASSED_NULL_PARAMETER 134
+#define EC_R_PKPARAMETERS2GROUP_FAILURE 127
+#define EC_R_POINT_AT_INFINITY 106
+#define EC_R_POINT_IS_NOT_ON_CURVE 107
+#define EC_R_SLOT_FULL 108
+#define EC_R_UNDEFINED_GENERATOR 113
+#define EC_R_UNDEFINED_ORDER 128
+#define EC_R_UNKNOWN_GROUP 129
+#define EC_R_UNKNOWN_ORDER 114
+#define EC_R_UNSUPPORTED_FIELD 131
+#define EC_R_WRONG_ORDER 130
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ecdh.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ecdh.h
new file mode 100644
index 000000000..b4b58ee65
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ecdh.h
@@ -0,0 +1,123 @@
+/* crypto/ecdh/ecdh.h */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ *
+ * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
+ * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
+ * to the OpenSSL project.
+ *
+ * The ECC Code is licensed pursuant to the OpenSSL open source
+ * license provided below.
+ *
+ * The ECDH software is originally written by Douglas Stebila of
+ * Sun Microsystems Laboratories.
+ *
+ */
+/* ====================================================================
+ * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+#ifndef HEADER_ECDH_H
+#define HEADER_ECDH_H
+
+#include <openssl/opensslconf.h>
+
+#ifdef OPENSSL_NO_ECDH
+#error ECDH is disabled.
+#endif
+
+#include <openssl/ec.h>
+#include <openssl/ossl_typ.h>
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/bn.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const ECDH_METHOD *ECDH_OpenSSL(void);
+
+void ECDH_set_default_method(const ECDH_METHOD *);
+const ECDH_METHOD *ECDH_get_default_method(void);
+int ECDH_set_method(EC_KEY *, const ECDH_METHOD *);
+
+int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh,
+ void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));
+
+int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new
+ *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);
+void *ECDH_get_ex_data(EC_KEY *d, int idx);
+
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_ECDH_strings(void);
+
+/* Error codes for the ECDH functions. */
+
+/* Function codes. */
+#define ECDH_F_ECDH_COMPUTE_KEY 100
+#define ECDH_F_ECDH_DATA_NEW_METHOD 101
+
+/* Reason codes. */
+#define ECDH_R_KDF_FAILED 102
+#define ECDH_R_NO_PRIVATE_VALUE 100
+#define ECDH_R_POINT_ARITHMETIC_FAILURE 101
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ecdsa.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ecdsa.h
new file mode 100644
index 000000000..f20c8ee73
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ecdsa.h
@@ -0,0 +1,271 @@
+/* crypto/ecdsa/ecdsa.h */
+/**
+ * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions
+ * \author Written by Nils Larsch for the OpenSSL project
+ */
+/* ====================================================================
+ * Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+#ifndef HEADER_ECDSA_H
+#define HEADER_ECDSA_H
+
+#include <openssl/opensslconf.h>
+
+#ifdef OPENSSL_NO_ECDSA
+#error ECDSA is disabled.
+#endif
+
+#include <openssl/ec.h>
+#include <openssl/ossl_typ.h>
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/bn.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ECDSA_SIG_st
+ {
+ BIGNUM *r;
+ BIGNUM *s;
+ } ECDSA_SIG;
+
+/** ECDSA_SIG *ECDSA_SIG_new(void)
+ * allocates and initialize a ECDSA_SIG structure
+ * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
+ */
+ECDSA_SIG *ECDSA_SIG_new(void);
+
+/** ECDSA_SIG_free
+ * frees a ECDSA_SIG structure
+ * \param a pointer to the ECDSA_SIG structure
+ */
+void ECDSA_SIG_free(ECDSA_SIG *a);
+
+/** i2d_ECDSA_SIG
+ * DER encode content of ECDSA_SIG object (note: this function modifies *pp
+ * (*pp += length of the DER encoded signature)).
+ * \param a pointer to the ECDSA_SIG object
+ * \param pp pointer to a unsigned char pointer for the output or NULL
+ * \return the length of the DER encoded ECDSA_SIG object or 0
+ */
+int i2d_ECDSA_SIG(const ECDSA_SIG *a, unsigned char **pp);
+
+/** d2i_ECDSA_SIG
+ * decodes a DER encoded ECDSA signature (note: this function changes *pp
+ * (*pp += len)).
+ * \param v pointer to ECDSA_SIG pointer (may be NULL)
+ * \param pp buffer with the DER encoded signature
+ * \param len bufferlength
+ * \return pointer to the decoded ECDSA_SIG structure (or NULL)
+ */
+ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **v, const unsigned char **pp, long len);
+
+/** ECDSA_do_sign
+ * computes the ECDSA signature of the given hash value using
+ * the supplied private key and returns the created signature.
+ * \param dgst pointer to the hash value
+ * \param dgst_len length of the hash value
+ * \param eckey pointer to the EC_KEY object containing a private EC key
+ * \return pointer to a ECDSA_SIG structure or NULL
+ */
+ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey);
+
+/** ECDSA_do_sign_ex
+ * computes ECDSA signature of a given hash value using the supplied
+ * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
+ * \param dgst pointer to the hash value to sign
+ * \param dgstlen length of the hash value
+ * \param kinv optional pointer to a pre-computed inverse k
+ * \param rp optional pointer to the pre-computed rp value (see
+ * ECDSA_sign_setup
+ * \param eckey pointer to the EC_KEY object containing a private EC key
+ * \return pointer to a ECDSA_SIG structure or NULL
+ */
+ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,
+ const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);
+
+/** ECDSA_do_verify
+ * verifies that the supplied signature is a valid ECDSA
+ * signature of the supplied hash value using the supplied public key.
+ * \param dgst pointer to the hash value
+ * \param dgst_len length of the hash value
+ * \param sig pointer to the ECDSA_SIG structure
+ * \param eckey pointer to the EC_KEY object containing a public EC key
+ * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error
+ */
+int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
+ const ECDSA_SIG *sig, EC_KEY* eckey);
+
+const ECDSA_METHOD *ECDSA_OpenSSL(void);
+
+/** ECDSA_set_default_method
+ * sets the default ECDSA method
+ * \param meth the new default ECDSA_METHOD
+ */
+void ECDSA_set_default_method(const ECDSA_METHOD *meth);
+
+/** ECDSA_get_default_method
+ * returns the default ECDSA method
+ * \return pointer to ECDSA_METHOD structure containing the default method
+ */
+const ECDSA_METHOD *ECDSA_get_default_method(void);
+
+/** ECDSA_set_method
+ * sets method to be used for the ECDSA operations
+ * \param eckey pointer to the EC_KEY object
+ * \param meth pointer to the new method
+ * \return 1 on success and 0 otherwise
+ */
+int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);
+
+/** ECDSA_size
+ * returns the maximum length of the DER encoded signature
+ * \param eckey pointer to a EC_KEY object
+ * \return numbers of bytes required for the DER encoded signature
+ */
+int ECDSA_size(const EC_KEY *eckey);
+
+/** ECDSA_sign_setup
+ * precompute parts of the signing operation.
+ * \param eckey pointer to the EC_KEY object containing a private EC key
+ * \param ctx pointer to a BN_CTX object (may be NULL)
+ * \param kinv pointer to a BIGNUM pointer for the inverse of k
+ * \param rp pointer to a BIGNUM pointer for x coordinate of k * generator
+ * \return 1 on success and 0 otherwise
+ */
+int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv,
+ BIGNUM **rp);
+
+/** ECDSA_sign
+ * computes ECDSA signature of a given hash value using the supplied
+ * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
+ * \param type this parameter is ignored
+ * \param dgst pointer to the hash value to sign
+ * \param dgstlen length of the hash value
+ * \param sig buffer to hold the DER encoded signature
+ * \param siglen pointer to the length of the returned signature
+ * \param eckey pointer to the EC_KEY object containing a private EC key
+ * \return 1 on success and 0 otherwise
+ */
+int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
+ unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
+
+
+/** ECDSA_sign_ex
+ * computes ECDSA signature of a given hash value using the supplied
+ * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
+ * \param type this parameter is ignored
+ * \param dgst pointer to the hash value to sign
+ * \param dgstlen length of the hash value
+ * \param sig buffer to hold the DER encoded signature
+ * \param siglen pointer to the length of the returned signature
+ * \param kinv optional pointer to a pre-computed inverse k
+ * \param rp optional pointer to the pre-computed rp value (see
+ * ECDSA_sign_setup
+ * \param eckey pointer to the EC_KEY object containing a private EC key
+ * \return 1 on success and 0 otherwise
+ */
+int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,
+ unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv,
+ const BIGNUM *rp, EC_KEY *eckey);
+
+/** ECDSA_verify
+ * verifies that the given signature is valid ECDSA signature
+ * of the supplied hash value using the specified public key.
+ * \param type this parameter is ignored
+ * \param dgst pointer to the hash value
+ * \param dgstlen length of the hash value
+ * \param sig pointer to the DER encoded signature
+ * \param siglen length of the DER encoded signature
+ * \param eckey pointer to the EC_KEY object containing a public EC key
+ * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error
+ */
+int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
+ const unsigned char *sig, int siglen, EC_KEY *eckey);
+
+/* the standard ex_data functions */
+int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new
+ *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg);
+void *ECDSA_get_ex_data(EC_KEY *d, int idx);
+
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_ECDSA_strings(void);
+
+/* Error codes for the ECDSA functions. */
+
+/* Function codes. */
+#define ECDSA_F_ECDSA_DATA_NEW_METHOD 100
+#define ECDSA_F_ECDSA_DO_SIGN 101
+#define ECDSA_F_ECDSA_DO_VERIFY 102
+#define ECDSA_F_ECDSA_SIGN_SETUP 103
+
+/* Reason codes. */
+#define ECDSA_R_BAD_SIGNATURE 100
+#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 101
+#define ECDSA_R_ERR_EC_LIB 102
+#define ECDSA_R_MISSING_PARAMETERS 103
+#define ECDSA_R_NEED_NEW_SETUP_VALUES 106
+#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104
+#define ECDSA_R_SIGNATURE_MALLOC_FAILED 105
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/engine.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/engine.h
new file mode 100644
index 000000000..f503595ec
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/engine.h
@@ -0,0 +1,801 @@
+/* openssl/engine.h */
+/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
+ * project 2000.
+ */
+/* ====================================================================
+ * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ * ECDH support in OpenSSL originally developed by
+ * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
+ */
+
+#ifndef HEADER_ENGINE_H
+#define HEADER_ENGINE_H
+
+#include <openssl/opensslconf.h>
+
+#ifdef OPENSSL_NO_ENGINE
+#error ENGINE is disabled.
+#endif
+
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/bn.h>
+#ifndef OPENSSL_NO_RSA
+#include <openssl/rsa.h>
+#endif
+#ifndef OPENSSL_NO_DSA
+#include <openssl/dsa.h>
+#endif
+#ifndef OPENSSL_NO_DH
+#include <openssl/dh.h>
+#endif
+#ifndef OPENSSL_NO_ECDH
+#include <openssl/ecdh.h>
+#endif
+#ifndef OPENSSL_NO_ECDSA
+#include <openssl/ecdsa.h>
+#endif
+#include <openssl/rand.h>
+#include <openssl/store.h>
+#include <openssl/ui.h>
+#include <openssl/err.h>
+#endif
+
+#include <openssl/x509.h>
+
+#include <openssl/ossl_typ.h>
+#include <openssl/symhacks.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These flags are used to control combinations of algorithm (methods)
+ * by bitwise "OR"ing. */
+#define ENGINE_METHOD_RSA (unsigned int)0x0001
+#define ENGINE_METHOD_DSA (unsigned int)0x0002
+#define ENGINE_METHOD_DH (unsigned int)0x0004
+#define ENGINE_METHOD_RAND (unsigned int)0x0008
+#define ENGINE_METHOD_ECDH (unsigned int)0x0010
+#define ENGINE_METHOD_ECDSA (unsigned int)0x0020
+#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040
+#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080
+#define ENGINE_METHOD_STORE (unsigned int)0x0100
+/* Obvious all-or-nothing cases. */
+#define ENGINE_METHOD_ALL (unsigned int)0xFFFF
+#define ENGINE_METHOD_NONE (unsigned int)0x0000
+
+/* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used
+ * internally to control registration of ENGINE implementations, and can be set
+ * by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to
+ * initialise registered ENGINEs if they are not already initialised. */
+#define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001
+
+/* ENGINE flags that can be set by ENGINE_set_flags(). */
+/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ /* Not used */
+
+/* This flag is for ENGINEs that wish to handle the various 'CMD'-related
+ * control commands on their own. Without this flag, ENGINE_ctrl() handles these
+ * control commands on behalf of the ENGINE using their "cmd_defns" data. */
+#define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002
+
+/* This flag is for ENGINEs who return new duplicate structures when found via
+ * "ENGINE_by_id()". When an ENGINE must store state (eg. if ENGINE_ctrl()
+ * commands are called in sequence as part of some stateful process like
+ * key-generation setup and execution), it can set this flag - then each attempt
+ * to obtain the ENGINE will result in it being copied into a new structure.
+ * Normally, ENGINEs don't declare this flag so ENGINE_by_id() just increments
+ * the existing ENGINE's structural reference count. */
+#define ENGINE_FLAGS_BY_ID_COPY (int)0x0004
+
+/* ENGINEs can support their own command types, and these flags are used in
+ * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input each
+ * command expects. Currently only numeric and string input is supported. If a
+ * control command supports none of the _NUMERIC, _STRING, or _NO_INPUT options,
+ * then it is regarded as an "internal" control command - and not for use in
+ * config setting situations. As such, they're not available to the
+ * ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() access. Changes to
+ * this list of 'command types' should be reflected carefully in
+ * ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). */
+
+/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */
+#define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001
+/* accepts string input (cast from 'void*' to 'const char *', 4th parameter to
+ * ENGINE_ctrl) */
+#define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002
+/* Indicates that the control command takes *no* input. Ie. the control command
+ * is unparameterised. */
+#define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004
+/* Indicates that the control command is internal. This control command won't
+ * be shown in any output, and is only usable through the ENGINE_ctrl_cmd()
+ * function. */
+#define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008
+
+/* NB: These 3 control commands are deprecated and should not be used. ENGINEs
+ * relying on these commands should compile conditional support for
+ * compatibility (eg. if these symbols are defined) but should also migrate the
+ * same functionality to their own ENGINE-specific control functions that can be
+ * "discovered" by calling applications. The fact these control commands
+ * wouldn't be "executable" (ie. usable by text-based config) doesn't change the
+ * fact that application code can find and use them without requiring per-ENGINE
+ * hacking. */
+
+/* These flags are used to tell the ctrl function what should be done.
+ * All command numbers are shared between all engines, even if some don't
+ * make sense to some engines. In such a case, they do nothing but return
+ * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */
+#define ENGINE_CTRL_SET_LOGSTREAM 1
+#define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2
+#define ENGINE_CTRL_HUP 3 /* Close and reinitialise any
+ handles/connections etc. */
+#define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */
+#define ENGINE_CTRL_SET_CALLBACK_DATA 5 /* User-specific data, used
+ when calling the password
+ callback and the user
+ interface */
+#define ENGINE_CTRL_LOAD_CONFIGURATION 6 /* Load a configuration, given
+ a string that represents a
+ file name or so */
+#define ENGINE_CTRL_LOAD_SECTION 7 /* Load data from a given
+ section in the already loaded
+ configuration */
+
+/* These control commands allow an application to deal with an arbitrary engine
+ * in a dynamic way. Warn: Negative return values indicate errors FOR THESE
+ * COMMANDS because zero is used to indicate 'end-of-list'. Other commands,
+ * including ENGINE-specific command types, return zero for an error.
+ *
+ * An ENGINE can choose to implement these ctrl functions, and can internally
+ * manage things however it chooses - it does so by setting the
+ * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise the
+ * ENGINE_ctrl() code handles this on the ENGINE's behalf using the cmd_defns
+ * data (set using ENGINE_set_cmd_defns()). This means an ENGINE's ctrl()
+ * handler need only implement its own commands - the above "meta" commands will
+ * be taken care of. */
+
+/* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", then
+ * all the remaining control commands will return failure, so it is worth
+ * checking this first if the caller is trying to "discover" the engine's
+ * capabilities and doesn't want errors generated unnecessarily. */
+#define ENGINE_CTRL_HAS_CTRL_FUNCTION 10
+/* Returns a positive command number for the first command supported by the
+ * engine. Returns zero if no ctrl commands are supported. */
+#define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11
+/* The 'long' argument specifies a command implemented by the engine, and the
+ * return value is the next command supported, or zero if there are no more. */
+#define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12
+/* The 'void*' argument is a command name (cast from 'const char *'), and the
+ * return value is the command that corresponds to it. */
+#define ENGINE_CTRL_GET_CMD_FROM_NAME 13
+/* The next two allow a command to be converted into its corresponding string
+ * form. In each case, the 'long' argument supplies the command. In the NAME_LEN
+ * case, the return value is the length of the command name (not counting a
+ * trailing EOL). In the NAME case, the 'void*' argument must be a string buffer
+ * large enough, and it will be populated with the name of the command (WITH a
+ * trailing EOL). */
+#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14
+#define ENGINE_CTRL_GET_NAME_FROM_CMD 15
+/* The next two are similar but give a "short description" of a command. */
+#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16
+#define ENGINE_CTRL_GET_DESC_FROM_CMD 17
+/* With this command, the return value is the OR'd combination of
+ * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given
+ * engine-specific ctrl command expects. */
+#define ENGINE_CTRL_GET_CMD_FLAGS 18
+
+/* ENGINE implementations should start the numbering of their own control
+ * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */
+#define ENGINE_CMD_BASE 200
+
+/* NB: These 2 nCipher "chil" control commands are deprecated, and their
+ * functionality is now available through ENGINE-specific control commands
+ * (exposed through the above-mentioned 'CMD'-handling). Code using these 2
+ * commands should be migrated to the more general command handling before these
+ * are removed. */
+
+/* Flags specific to the nCipher "chil" engine */
+#define ENGINE_CTRL_CHIL_SET_FORKCHECK 100
+ /* Depending on the value of the (long)i argument, this sets or
+ * unsets the SimpleForkCheck flag in the CHIL API to enable or
+ * disable checking and workarounds for applications that fork().
+ */
+#define ENGINE_CTRL_CHIL_NO_LOCKING 101
+ /* This prevents the initialisation function from providing mutex
+ * callbacks to the nCipher library. */
+
+/* If an ENGINE supports its own specific control commands and wishes the
+ * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on its
+ * behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN entries
+ * to ENGINE_set_cmd_defns(). It should also implement a ctrl() handler that
+ * supports the stated commands (ie. the "cmd_num" entries as described by the
+ * array). NB: The array must be ordered in increasing order of cmd_num.
+ * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set
+ * to zero and/or cmd_name set to NULL. */
+typedef struct ENGINE_CMD_DEFN_st
+ {
+ unsigned int cmd_num; /* The command number */
+ const char *cmd_name; /* The command name itself */
+ const char *cmd_desc; /* A short description of the command */
+ unsigned int cmd_flags; /* The input the command expects */
+ } ENGINE_CMD_DEFN;
+
+/* Generic function pointer */
+typedef int (*ENGINE_GEN_FUNC_PTR)(void);
+/* Generic function pointer taking no arguments */
+typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *);
+/* Specific control function pointer */
+typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void));
+/* Generic load_key function pointer */
+typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,
+ UI_METHOD *ui_method, void *callback_data);
+typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl,
+ STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **pkey,
+ STACK_OF(X509) **pother, UI_METHOD *ui_method, void *callback_data);
+/* These callback types are for an ENGINE's handler for cipher and digest logic.
+ * These handlers have these prototypes;
+ * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid);
+ * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);
+ * Looking at how to implement these handlers in the case of cipher support, if
+ * the framework wants the EVP_CIPHER for 'nid', it will call;
+ * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure)
+ * If the framework wants a list of supported 'nid's, it will call;
+ * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error)
+ */
+/* Returns to a pointer to the array of supported cipher 'nid's. If the second
+ * parameter is non-NULL it is set to the size of the returned array. */
+typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int);
+typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int);
+
+/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE
+ * structures where the pointers have a "structural reference". This means that
+ * their reference is to allowed access to the structure but it does not imply
+ * that the structure is functional. To simply increment or decrement the
+ * structural reference count, use ENGINE_by_id and ENGINE_free. NB: This is not
+ * required when iterating using ENGINE_get_next as it will automatically
+ * decrement the structural reference count of the "current" ENGINE and
+ * increment the structural reference count of the ENGINE it returns (unless it
+ * is NULL). */
+
+/* Get the first/last "ENGINE" type available. */
+ENGINE *ENGINE_get_first(void);
+ENGINE *ENGINE_get_last(void);
+/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
+ENGINE *ENGINE_get_next(ENGINE *e);
+ENGINE *ENGINE_get_prev(ENGINE *e);
+/* Add another "ENGINE" type into the array. */
+int ENGINE_add(ENGINE *e);
+/* Remove an existing "ENGINE" type from the array. */
+int ENGINE_remove(ENGINE *e);
+/* Retrieve an engine from the list by its unique "id" value. */
+ENGINE *ENGINE_by_id(const char *id);
+/* Add all the built-in engines. */
+void ENGINE_load_openssl(void);
+void ENGINE_load_dynamic(void);
+#ifndef OPENSSL_NO_STATIC_ENGINE
+void ENGINE_load_4758cca(void);
+void ENGINE_load_aep(void);
+void ENGINE_load_atalla(void);
+void ENGINE_load_chil(void);
+void ENGINE_load_cswift(void);
+#ifndef OPENSSL_NO_GMP
+void ENGINE_load_gmp(void);
+#endif
+void ENGINE_load_nuron(void);
+void ENGINE_load_sureware(void);
+void ENGINE_load_ubsec(void);
+#endif
+void ENGINE_load_cryptodev(void);
+void ENGINE_load_padlock(void);
+void ENGINE_load_builtin_engines(void);
+#ifndef OPENSSL_NO_CAPIENG
+void ENGINE_load_capi(void);
+#endif
+
+/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
+ * "registry" handling. */
+unsigned int ENGINE_get_table_flags(void);
+void ENGINE_set_table_flags(unsigned int flags);
+
+/* Manage registration of ENGINEs per "table". For each type, there are 3
+ * functions;
+ * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one)
+ * ENGINE_unregister_***(e) - unregister the implementation from 'e'
+ * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list
+ * Cleanup is automatically registered from each table when required, so
+ * ENGINE_cleanup() will reverse any "register" operations. */
+
+int ENGINE_register_RSA(ENGINE *e);
+void ENGINE_unregister_RSA(ENGINE *e);
+void ENGINE_register_all_RSA(void);
+
+int ENGINE_register_DSA(ENGINE *e);
+void ENGINE_unregister_DSA(ENGINE *e);
+void ENGINE_register_all_DSA(void);
+
+int ENGINE_register_ECDH(ENGINE *e);
+void ENGINE_unregister_ECDH(ENGINE *e);
+void ENGINE_register_all_ECDH(void);
+
+int ENGINE_register_ECDSA(ENGINE *e);
+void ENGINE_unregister_ECDSA(ENGINE *e);
+void ENGINE_register_all_ECDSA(void);
+
+int ENGINE_register_DH(ENGINE *e);
+void ENGINE_unregister_DH(ENGINE *e);
+void ENGINE_register_all_DH(void);
+
+int ENGINE_register_RAND(ENGINE *e);
+void ENGINE_unregister_RAND(ENGINE *e);
+void ENGINE_register_all_RAND(void);
+
+int ENGINE_register_STORE(ENGINE *e);
+void ENGINE_unregister_STORE(ENGINE *e);
+void ENGINE_register_all_STORE(void);
+
+int ENGINE_register_ciphers(ENGINE *e);
+void ENGINE_unregister_ciphers(ENGINE *e);
+void ENGINE_register_all_ciphers(void);
+
+int ENGINE_register_digests(ENGINE *e);
+void ENGINE_unregister_digests(ENGINE *e);
+void ENGINE_register_all_digests(void);
+
+/* These functions register all support from the above categories. Note, use of
+ * these functions can result in static linkage of code your application may not
+ * need. If you only need a subset of functionality, consider using more
+ * selective initialisation. */
+int ENGINE_register_complete(ENGINE *e);
+int ENGINE_register_all_complete(void);
+
+/* Send parametrised control commands to the engine. The possibilities to send
+ * down an integer, a pointer to data or a function pointer are provided. Any of
+ * the parameters may or may not be NULL, depending on the command number. In
+ * actuality, this function only requires a structural (rather than functional)
+ * reference to an engine, but many control commands may require the engine be
+ * functional. The caller should be aware of trying commands that require an
+ * operational ENGINE, and only use functional references in such situations. */
+int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void));
+
+/* This function tests if an ENGINE-specific command is usable as a "setting".
+ * Eg. in an application's config file that gets processed through
+ * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to
+ * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). */
+int ENGINE_cmd_is_executable(ENGINE *e, int cmd);
+
+/* This function works like ENGINE_ctrl() with the exception of taking a
+ * command name instead of a command number, and can handle optional commands.
+ * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to
+ * use the cmd_name and cmd_optional. */
+int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
+ long i, void *p, void (*f)(void), int cmd_optional);
+
+/* This function passes a command-name and argument to an ENGINE. The cmd_name
+ * is converted to a command number and the control command is called using
+ * 'arg' as an argument (unless the ENGINE doesn't support such a command, in
+ * which case no control command is called). The command is checked for input
+ * flags, and if necessary the argument will be converted to a numeric value. If
+ * cmd_optional is non-zero, then if the ENGINE doesn't support the given
+ * cmd_name the return value will be success anyway. This function is intended
+ * for applications to use so that users (or config files) can supply
+ * engine-specific config data to the ENGINE at run-time to control behaviour of
+ * specific engines. As such, it shouldn't be used for calling ENGINE_ctrl()
+ * functions that return data, deal with binary data, or that are otherwise
+ * supposed to be used directly through ENGINE_ctrl() in application code. Any
+ * "return" data from an ENGINE_ctrl() operation in this function will be lost -
+ * the return value is interpreted as failure if the return value is zero,
+ * success otherwise, and this function returns a boolean value as a result. In
+ * other words, vendors of 'ENGINE'-enabled devices should write ENGINE
+ * implementations with parameterisations that work in this scheme, so that
+ * compliant ENGINE-based applications can work consistently with the same
+ * configuration for the same ENGINE-enabled devices, across applications. */
+int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
+ int cmd_optional);
+
+/* These functions are useful for manufacturing new ENGINE structures. They
+ * don't address reference counting at all - one uses them to populate an ENGINE
+ * structure with personalised implementations of things prior to using it
+ * directly or adding it to the builtin ENGINE list in OpenSSL. These are also
+ * here so that the ENGINE structure doesn't have to be exposed and break binary
+ * compatibility! */
+ENGINE *ENGINE_new(void);
+int ENGINE_free(ENGINE *e);
+int ENGINE_up_ref(ENGINE *e);
+int ENGINE_set_id(ENGINE *e, const char *id);
+int ENGINE_set_name(ENGINE *e, const char *name);
+int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
+int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
+int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth);
+int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth);
+int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
+int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
+int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth);
+int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
+int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
+int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
+int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
+int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f);
+int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);
+int ENGINE_set_load_ssl_client_cert_function(ENGINE *e,
+ ENGINE_SSL_CLIENT_CERT_PTR loadssl_f);
+int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
+int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
+int ENGINE_set_flags(ENGINE *e, int flags);
+int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
+/* These functions allow control over any per-structure ENGINE data. */
+int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
+void *ENGINE_get_ex_data(const ENGINE *e, int idx);
+
+/* This function cleans up anything that needs it. Eg. the ENGINE_add() function
+ * automatically ensures the list cleanup function is registered to be called
+ * from ENGINE_cleanup(). Similarly, all ENGINE_register_*** functions ensure
+ * ENGINE_cleanup() will clean up after them. */
+void ENGINE_cleanup(void);
+
+/* These return values from within the ENGINE structure. These can be useful
+ * with functional references as well as structural references - it depends
+ * which you obtained. Using the result for functional purposes if you only
+ * obtained a structural reference may be problematic! */
+const char *ENGINE_get_id(const ENGINE *e);
+const char *ENGINE_get_name(const ENGINE *e);
+const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
+const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
+const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e);
+const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e);
+const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
+const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
+const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e);
+ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
+ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
+ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
+ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
+ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);
+ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
+ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE *e);
+ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
+ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
+const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
+const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
+const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
+int ENGINE_get_flags(const ENGINE *e);
+
+/* FUNCTIONAL functions. These functions deal with ENGINE structures
+ * that have (or will) be initialised for use. Broadly speaking, the
+ * structural functions are useful for iterating the list of available
+ * engine types, creating new engine types, and other "list" operations.
+ * These functions actually deal with ENGINEs that are to be used. As
+ * such these functions can fail (if applicable) when particular
+ * engines are unavailable - eg. if a hardware accelerator is not
+ * attached or not functioning correctly. Each ENGINE has 2 reference
+ * counts; structural and functional. Every time a functional reference
+ * is obtained or released, a corresponding structural reference is
+ * automatically obtained or released too. */
+
+/* Initialise a engine type for use (or up its reference count if it's
+ * already in use). This will fail if the engine is not currently
+ * operational and cannot initialise. */
+int ENGINE_init(ENGINE *e);
+/* Free a functional reference to a engine type. This does not require
+ * a corresponding call to ENGINE_free as it also releases a structural
+ * reference. */
+int ENGINE_finish(ENGINE *e);
+
+/* The following functions handle keys that are stored in some secondary
+ * location, handled by the engine. The storage may be on a card or
+ * whatever. */
+EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
+ UI_METHOD *ui_method, void *callback_data);
+EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
+ UI_METHOD *ui_method, void *callback_data);
+int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
+ STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **ppkey,
+ STACK_OF(X509) **pother,
+ UI_METHOD *ui_method, void *callback_data);
+
+/* This returns a pointer for the current ENGINE structure that
+ * is (by default) performing any RSA operations. The value returned
+ * is an incremented reference, so it should be free'd (ENGINE_finish)
+ * before it is discarded. */
+ENGINE *ENGINE_get_default_RSA(void);
+/* Same for the other "methods" */
+ENGINE *ENGINE_get_default_DSA(void);
+ENGINE *ENGINE_get_default_ECDH(void);
+ENGINE *ENGINE_get_default_ECDSA(void);
+ENGINE *ENGINE_get_default_DH(void);
+ENGINE *ENGINE_get_default_RAND(void);
+/* These functions can be used to get a functional reference to perform
+ * ciphering or digesting corresponding to "nid". */
+ENGINE *ENGINE_get_cipher_engine(int nid);
+ENGINE *ENGINE_get_digest_engine(int nid);
+
+/* This sets a new default ENGINE structure for performing RSA
+ * operations. If the result is non-zero (success) then the ENGINE
+ * structure will have had its reference count up'd so the caller
+ * should still free their own reference 'e'. */
+int ENGINE_set_default_RSA(ENGINE *e);
+int ENGINE_set_default_string(ENGINE *e, const char *def_list);
+/* Same for the other "methods" */
+int ENGINE_set_default_DSA(ENGINE *e);
+int ENGINE_set_default_ECDH(ENGINE *e);
+int ENGINE_set_default_ECDSA(ENGINE *e);
+int ENGINE_set_default_DH(ENGINE *e);
+int ENGINE_set_default_RAND(ENGINE *e);
+int ENGINE_set_default_ciphers(ENGINE *e);
+int ENGINE_set_default_digests(ENGINE *e);
+
+/* The combination "set" - the flags are bitwise "OR"d from the
+ * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()"
+ * function, this function can result in unnecessary static linkage. If your
+ * application requires only specific functionality, consider using more
+ * selective functions. */
+int ENGINE_set_default(ENGINE *e, unsigned int flags);
+
+void ENGINE_add_conf_module(void);
+
+/* Deprecated functions ... */
+/* int ENGINE_clear_defaults(void); */
+
+/**************************/
+/* DYNAMIC ENGINE SUPPORT */
+/**************************/
+
+/* Binary/behaviour compatibility levels */
+#define OSSL_DYNAMIC_VERSION (unsigned long)0x00020000
+/* Binary versions older than this are too old for us (whether we're a loader or
+ * a loadee) */
+#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00020000
+
+/* When compiling an ENGINE entirely as an external shared library, loadable by
+ * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure
+ * type provides the calling application's (or library's) error functionality
+ * and memory management function pointers to the loaded library. These should
+ * be used/set in the loaded library code so that the loading application's
+ * 'state' will be used/changed in all operations. The 'static_state' pointer
+ * allows the loaded library to know if it shares the same static data as the
+ * calling application (or library), and thus whether these callbacks need to be
+ * set or not. */
+typedef void *(*dyn_MEM_malloc_cb)(size_t);
+typedef void *(*dyn_MEM_realloc_cb)(void *, size_t);
+typedef void (*dyn_MEM_free_cb)(void *);
+typedef struct st_dynamic_MEM_fns {
+ dyn_MEM_malloc_cb malloc_cb;
+ dyn_MEM_realloc_cb realloc_cb;
+ dyn_MEM_free_cb free_cb;
+ } dynamic_MEM_fns;
+/* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use
+ * these types so we (and any other dependant code) can simplify a bit?? */
+typedef void (*dyn_lock_locking_cb)(int,int,const char *,int);
+typedef int (*dyn_lock_add_lock_cb)(int*,int,int,const char *,int);
+typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)(
+ const char *,int);
+typedef void (*dyn_dynlock_lock_cb)(int,struct CRYPTO_dynlock_value *,
+ const char *,int);
+typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *,
+ const char *,int);
+typedef struct st_dynamic_LOCK_fns {
+ dyn_lock_locking_cb lock_locking_cb;
+ dyn_lock_add_lock_cb lock_add_lock_cb;
+ dyn_dynlock_create_cb dynlock_create_cb;
+ dyn_dynlock_lock_cb dynlock_lock_cb;
+ dyn_dynlock_destroy_cb dynlock_destroy_cb;
+ } dynamic_LOCK_fns;
+/* The top-level structure */
+typedef struct st_dynamic_fns {
+ void *static_state;
+ const ERR_FNS *err_fns;
+ const CRYPTO_EX_DATA_IMPL *ex_data_fns;
+ dynamic_MEM_fns mem_fns;
+ dynamic_LOCK_fns lock_fns;
+ } dynamic_fns;
+
+/* The version checking function should be of this prototype. NB: The
+ * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code.
+ * If this function returns zero, it indicates a (potential) version
+ * incompatibility and the loaded library doesn't believe it can proceed.
+ * Otherwise, the returned value is the (latest) version supported by the
+ * loading library. The loader may still decide that the loaded code's version
+ * is unsatisfactory and could veto the load. The function is expected to
+ * be implemented with the symbol name "v_check", and a default implementation
+ * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */
+typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version);
+#define IMPLEMENT_DYNAMIC_CHECK_FN() \
+ OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \
+ if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \
+ return 0; }
+
+/* This function is passed the ENGINE structure to initialise with its own
+ * function and command settings. It should not adjust the structural or
+ * functional reference counts. If this function returns zero, (a) the load will
+ * be aborted, (b) the previous ENGINE state will be memcpy'd back onto the
+ * structure, and (c) the shared library will be unloaded. So implementations
+ * should do their own internal cleanup in failure circumstances otherwise they
+ * could leak. The 'id' parameter, if non-NULL, represents the ENGINE id that
+ * the loader is looking for. If this is NULL, the shared library can choose to
+ * return failure or to initialise a 'default' ENGINE. If non-NULL, the shared
+ * library must initialise only an ENGINE matching the passed 'id'. The function
+ * is expected to be implemented with the symbol name "bind_engine". A standard
+ * implementation can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where
+ * the parameter 'fn' is a callback function that populates the ENGINE structure
+ * and returns an int value (zero for failure). 'fn' should have prototype;
+ * [static] int fn(ENGINE *e, const char *id); */
+typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id,
+ const dynamic_fns *fns);
+#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \
+ OPENSSL_EXPORT \
+ int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \
+ if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \
+ if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \
+ fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \
+ return 0; \
+ CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \
+ CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \
+ CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \
+ CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \
+ CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \
+ if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \
+ return 0; \
+ if(!ERR_set_implementation(fns->err_fns)) return 0; \
+ skip_cbs: \
+ if(!fn(e,id)) return 0; \
+ return 1; }
+
+/* If the loading application (or library) and the loaded ENGINE library share
+ * the same static data (eg. they're both dynamically linked to the same
+ * libcrypto.so) we need a way to avoid trying to set system callbacks - this
+ * would fail, and for the same reason that it's unnecessary to try. If the
+ * loaded ENGINE has (or gets from through the loader) its own copy of the
+ * libcrypto static data, we will need to set the callbacks. The easiest way to
+ * detect this is to have a function that returns a pointer to some static data
+ * and let the loading application and loaded ENGINE compare their respective
+ * values. */
+void *ENGINE_get_static_state(void);
+
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
+void ENGINE_setup_bsd_cryptodev(void);
+#endif
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_ENGINE_strings(void);
+
+/* Error codes for the ENGINE functions. */
+
+/* Function codes. */
+#define ENGINE_F_DYNAMIC_CTRL 180
+#define ENGINE_F_DYNAMIC_GET_DATA_CTX 181
+#define ENGINE_F_DYNAMIC_LOAD 182
+#define ENGINE_F_DYNAMIC_SET_DATA_CTX 183
+#define ENGINE_F_ENGINE_ADD 105
+#define ENGINE_F_ENGINE_BY_ID 106
+#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170
+#define ENGINE_F_ENGINE_CTRL 142
+#define ENGINE_F_ENGINE_CTRL_CMD 178
+#define ENGINE_F_ENGINE_CTRL_CMD_STRING 171
+#define ENGINE_F_ENGINE_FINISH 107
+#define ENGINE_F_ENGINE_FREE_UTIL 108
+#define ENGINE_F_ENGINE_GET_CIPHER 185
+#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177
+#define ENGINE_F_ENGINE_GET_DIGEST 186
+#define ENGINE_F_ENGINE_GET_NEXT 115
+#define ENGINE_F_ENGINE_GET_PREV 116
+#define ENGINE_F_ENGINE_INIT 119
+#define ENGINE_F_ENGINE_LIST_ADD 120
+#define ENGINE_F_ENGINE_LIST_REMOVE 121
+#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150
+#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151
+#define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 192
+#define ENGINE_F_ENGINE_NEW 122
+#define ENGINE_F_ENGINE_REMOVE 123
+#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189
+#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126
+#define ENGINE_F_ENGINE_SET_ID 129
+#define ENGINE_F_ENGINE_SET_NAME 130
+#define ENGINE_F_ENGINE_TABLE_REGISTER 184
+#define ENGINE_F_ENGINE_UNLOAD_KEY 152
+#define ENGINE_F_ENGINE_UNLOCKED_FINISH 191
+#define ENGINE_F_ENGINE_UP_REF 190
+#define ENGINE_F_INT_CTRL_HELPER 172
+#define ENGINE_F_INT_ENGINE_CONFIGURE 188
+#define ENGINE_F_INT_ENGINE_MODULE_INIT 187
+#define ENGINE_F_LOG_MESSAGE 141
+
+/* Reason codes. */
+#define ENGINE_R_ALREADY_LOADED 100
+#define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133
+#define ENGINE_R_CMD_NOT_EXECUTABLE 134
+#define ENGINE_R_COMMAND_TAKES_INPUT 135
+#define ENGINE_R_COMMAND_TAKES_NO_INPUT 136
+#define ENGINE_R_CONFLICTING_ENGINE_ID 103
+#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119
+#define ENGINE_R_DH_NOT_IMPLEMENTED 139
+#define ENGINE_R_DSA_NOT_IMPLEMENTED 140
+#define ENGINE_R_DSO_FAILURE 104
+#define ENGINE_R_DSO_NOT_FOUND 132
+#define ENGINE_R_ENGINES_SECTION_ERROR 148
+#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105
+#define ENGINE_R_ENGINE_SECTION_ERROR 149
+#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128
+#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129
+#define ENGINE_R_FINISH_FAILED 106
+#define ENGINE_R_GET_HANDLE_FAILED 107
+#define ENGINE_R_ID_OR_NAME_MISSING 108
+#define ENGINE_R_INIT_FAILED 109
+#define ENGINE_R_INTERNAL_LIST_ERROR 110
+#define ENGINE_R_INVALID_ARGUMENT 143
+#define ENGINE_R_INVALID_CMD_NAME 137
+#define ENGINE_R_INVALID_CMD_NUMBER 138
+#define ENGINE_R_INVALID_INIT_VALUE 151
+#define ENGINE_R_INVALID_STRING 150
+#define ENGINE_R_NOT_INITIALISED 117
+#define ENGINE_R_NOT_LOADED 112
+#define ENGINE_R_NO_CONTROL_FUNCTION 120
+#define ENGINE_R_NO_INDEX 144
+#define ENGINE_R_NO_LOAD_FUNCTION 125
+#define ENGINE_R_NO_REFERENCE 130
+#define ENGINE_R_NO_SUCH_ENGINE 116
+#define ENGINE_R_NO_UNLOAD_FUNCTION 126
+#define ENGINE_R_PROVIDE_PARAMETERS 113
+#define ENGINE_R_RSA_NOT_IMPLEMENTED 141
+#define ENGINE_R_UNIMPLEMENTED_CIPHER 146
+#define ENGINE_R_UNIMPLEMENTED_DIGEST 147
+#define ENGINE_R_VERSION_INCOMPATIBILITY 145
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/err.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/err.h
new file mode 100644
index 000000000..dcac41523
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/err.h
@@ -0,0 +1,330 @@
+/* crypto/err/err.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_ERR_H
+#define HEADER_ERR_H
+
+#include <openssl/e_os2.h>
+
+#ifndef OPENSSL_NO_FP_API
+#include <stdio.h>
+#include <stdlib.h>
+#endif
+
+#include <openssl/ossl_typ.h>
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+#ifndef OPENSSL_NO_LHASH
+#include <openssl/lhash.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef OPENSSL_NO_ERR
+#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e)
+#else
+#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0)
+#endif
+
+#include <errno.h>
+
+#define ERR_TXT_MALLOCED 0x01
+#define ERR_TXT_STRING 0x02
+
+#define ERR_FLAG_MARK 0x01
+
+#define ERR_NUM_ERRORS 16
+typedef struct err_state_st
+ {
+ unsigned long pid;
+ int err_flags[ERR_NUM_ERRORS];
+ unsigned long err_buffer[ERR_NUM_ERRORS];
+ char *err_data[ERR_NUM_ERRORS];
+ int err_data_flags[ERR_NUM_ERRORS];
+ const char *err_file[ERR_NUM_ERRORS];
+ int err_line[ERR_NUM_ERRORS];
+ int top,bottom;
+ } ERR_STATE;
+
+/* library */
+#define ERR_LIB_NONE 1
+#define ERR_LIB_SYS 2
+#define ERR_LIB_BN 3
+#define ERR_LIB_RSA 4
+#define ERR_LIB_DH 5
+#define ERR_LIB_EVP 6
+#define ERR_LIB_BUF 7
+#define ERR_LIB_OBJ 8
+#define ERR_LIB_PEM 9
+#define ERR_LIB_DSA 10
+#define ERR_LIB_X509 11
+/* #define ERR_LIB_METH 12 */
+#define ERR_LIB_ASN1 13
+#define ERR_LIB_CONF 14
+#define ERR_LIB_CRYPTO 15
+#define ERR_LIB_EC 16
+#define ERR_LIB_SSL 20
+/* #define ERR_LIB_SSL23 21 */
+/* #define ERR_LIB_SSL2 22 */
+/* #define ERR_LIB_SSL3 23 */
+/* #define ERR_LIB_RSAREF 30 */
+/* #define ERR_LIB_PROXY 31 */
+#define ERR_LIB_BIO 32
+#define ERR_LIB_PKCS7 33
+#define ERR_LIB_X509V3 34
+#define ERR_LIB_PKCS12 35
+#define ERR_LIB_RAND 36
+#define ERR_LIB_DSO 37
+#define ERR_LIB_ENGINE 38
+#define ERR_LIB_OCSP 39
+#define ERR_LIB_UI 40
+#define ERR_LIB_COMP 41
+#define ERR_LIB_ECDSA 42
+#define ERR_LIB_ECDH 43
+#define ERR_LIB_STORE 44
+#define ERR_LIB_FIPS 45
+#define ERR_LIB_CMS 46
+#define ERR_LIB_JPAKE 47
+
+#define ERR_LIB_USER 128
+
+#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)
+#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)
+#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)
+#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)
+#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)
+#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)
+#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)
+#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)
+#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)
+#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)
+#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)
+#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)
+#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)
+#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)
+#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)
+#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)
+#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)
+#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)
+#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)
+#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)
+#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)
+#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)
+#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)
+#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)
+#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)
+#define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)
+#define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)
+#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)
+#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)
+#define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)
+#define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)
+
+/* Borland C seems too stupid to be able to shift and do longs in
+ * the pre-processor :-( */
+#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)*0x1000000)| \
+ ((((unsigned long)f)&0xfffL)*0x1000)| \
+ ((((unsigned long)r)&0xfffL)))
+#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL)
+#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL)
+#define ERR_GET_REASON(l) (int)((l)&0xfffL)
+#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL)
+
+
+/* OS functions */
+#define SYS_F_FOPEN 1
+#define SYS_F_CONNECT 2
+#define SYS_F_GETSERVBYNAME 3
+#define SYS_F_SOCKET 4
+#define SYS_F_IOCTLSOCKET 5
+#define SYS_F_BIND 6
+#define SYS_F_LISTEN 7
+#define SYS_F_ACCEPT 8
+#define SYS_F_WSASTARTUP 9 /* Winsock stuff */
+#define SYS_F_OPENDIR 10
+#define SYS_F_FREAD 11
+
+
+/* reasons */
+#define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */
+#define ERR_R_BN_LIB ERR_LIB_BN /* 3 */
+#define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */
+#define ERR_R_DH_LIB ERR_LIB_DH /* 5 */
+#define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */
+#define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */
+#define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */
+#define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */
+#define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */
+#define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */
+#define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */
+#define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */
+#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */
+#define ERR_R_EC_LIB ERR_LIB_EC /* 16 */
+#define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */
+#define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */
+#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */
+#define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */
+#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */
+#define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */
+#define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */
+#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */
+#define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */
+#define ERR_R_UI_LIB ERR_LIB_UI /* 40 */
+#define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */
+#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA /* 42 */
+#define ERR_R_ECDH_LIB ERR_LIB_ECDH /* 43 */
+#define ERR_R_STORE_LIB ERR_LIB_STORE /* 44 */
+
+#define ERR_R_NESTED_ASN1_ERROR 58
+#define ERR_R_BAD_ASN1_OBJECT_HEADER 59
+#define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60
+#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61
+#define ERR_R_ASN1_LENGTH_MISMATCH 62
+#define ERR_R_MISSING_ASN1_EOS 63
+
+/* fatal error */
+#define ERR_R_FATAL 64
+#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL)
+#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL)
+#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL)
+#define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL)
+#define ERR_R_DISABLED (5|ERR_R_FATAL)
+
+/* 99 is the maximum possible ERR_R_... code, higher values
+ * are reserved for the individual libraries */
+
+
+typedef struct ERR_string_data_st
+ {
+ unsigned long error;
+ const char *string;
+ } ERR_STRING_DATA;
+
+void ERR_put_error(int lib, int func,int reason,const char *file,int line);
+void ERR_set_error_data(char *data,int flags);
+
+unsigned long ERR_get_error(void);
+unsigned long ERR_get_error_line(const char **file,int *line);
+unsigned long ERR_get_error_line_data(const char **file,int *line,
+ const char **data, int *flags);
+unsigned long ERR_peek_error(void);
+unsigned long ERR_peek_error_line(const char **file,int *line);
+unsigned long ERR_peek_error_line_data(const char **file,int *line,
+ const char **data,int *flags);
+unsigned long ERR_peek_last_error(void);
+unsigned long ERR_peek_last_error_line(const char **file,int *line);
+unsigned long ERR_peek_last_error_line_data(const char **file,int *line,
+ const char **data,int *flags);
+void ERR_clear_error(void );
+char *ERR_error_string(unsigned long e,char *buf);
+void ERR_error_string_n(unsigned long e, char *buf, size_t len);
+const char *ERR_lib_error_string(unsigned long e);
+const char *ERR_func_error_string(unsigned long e);
+const char *ERR_reason_error_string(unsigned long e);
+void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
+ void *u);
+#ifndef OPENSSL_NO_FP_API
+void ERR_print_errors_fp(FILE *fp);
+#endif
+#ifndef OPENSSL_NO_BIO
+void ERR_print_errors(BIO *bp);
+void ERR_add_error_data(int num, ...);
+#endif
+void ERR_load_strings(int lib,ERR_STRING_DATA str[]);
+void ERR_unload_strings(int lib,ERR_STRING_DATA str[]);
+void ERR_load_ERR_strings(void);
+void ERR_load_crypto_strings(void);
+void ERR_free_strings(void);
+
+void ERR_remove_state(unsigned long pid); /* if zero we look it up */
+ERR_STATE *ERR_get_state(void);
+
+#ifndef OPENSSL_NO_LHASH
+LHASH *ERR_get_string_table(void);
+LHASH *ERR_get_err_state_table(void);
+void ERR_release_err_state_table(LHASH **hash);
+#endif
+
+int ERR_get_next_error_library(void);
+
+int ERR_set_mark(void);
+int ERR_pop_to_mark(void);
+
+#ifdef OPENSSL_FIPS
+void int_ERR_set_state_func(ERR_STATE *(*get_func)(void),
+ void (*remove_func)(unsigned long pid));
+void int_ERR_lib_init(void);
+#endif
+
+/* Already defined in ossl_typ.h */
+/* typedef struct st_ERR_FNS ERR_FNS; */
+/* An application can use this function and provide the return value to loaded
+ * modules that should use the application's ERR state/functionality */
+const ERR_FNS *ERR_get_implementation(void);
+/* A loaded module should call this function prior to any ERR operations using
+ * the application's "ERR_FNS". */
+int ERR_set_implementation(const ERR_FNS *fns);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/evp.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/evp.h
new file mode 100644
index 000000000..79c097181
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/evp.h
@@ -0,0 +1,1059 @@
+/* crypto/evp/evp.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_ENVELOPE_H
+#define HEADER_ENVELOPE_H
+
+#ifdef OPENSSL_ALGORITHM_DEFINES
+# include <openssl/opensslconf.h>
+#else
+# define OPENSSL_ALGORITHM_DEFINES
+# include <openssl/opensslconf.h>
+# undef OPENSSL_ALGORITHM_DEFINES
+#endif
+
+#include <openssl/ossl_typ.h>
+
+#include <openssl/symhacks.h>
+
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+
+#ifdef OPENSSL_FIPS
+#include <openssl/fips.h>
+#endif
+
+/*
+#define EVP_RC2_KEY_SIZE 16
+#define EVP_RC4_KEY_SIZE 16
+#define EVP_BLOWFISH_KEY_SIZE 16
+#define EVP_CAST5_KEY_SIZE 16
+#define EVP_RC5_32_12_16_KEY_SIZE 16
+*/
+#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */
+#define EVP_MAX_KEY_LENGTH 32
+#define EVP_MAX_IV_LENGTH 16
+#define EVP_MAX_BLOCK_LENGTH 32
+
+#define PKCS5_SALT_LEN 8
+/* Default PKCS#5 iteration count */
+#define PKCS5_DEFAULT_ITER 2048
+
+#include <openssl/objects.h>
+
+#define EVP_PK_RSA 0x0001
+#define EVP_PK_DSA 0x0002
+#define EVP_PK_DH 0x0004
+#define EVP_PK_EC 0x0008
+#define EVP_PKT_SIGN 0x0010
+#define EVP_PKT_ENC 0x0020
+#define EVP_PKT_EXCH 0x0040
+#define EVP_PKS_RSA 0x0100
+#define EVP_PKS_DSA 0x0200
+#define EVP_PKS_EC 0x0400
+#define EVP_PKT_EXP 0x1000 /* <= 512 bit key */
+
+#define EVP_PKEY_NONE NID_undef
+#define EVP_PKEY_RSA NID_rsaEncryption
+#define EVP_PKEY_RSA2 NID_rsa
+#define EVP_PKEY_DSA NID_dsa
+#define EVP_PKEY_DSA1 NID_dsa_2
+#define EVP_PKEY_DSA2 NID_dsaWithSHA
+#define EVP_PKEY_DSA3 NID_dsaWithSHA1
+#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
+#define EVP_PKEY_DH NID_dhKeyAgreement
+#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Type needs to be a bit field
+ * Sub-type needs to be for variations on the method, as in, can it do
+ * arbitrary encryption.... */
+struct evp_pkey_st
+ {
+ int type;
+ int save_type;
+ int references;
+ union {
+ char *ptr;
+#ifndef OPENSSL_NO_RSA
+ struct rsa_st *rsa; /* RSA */
+#endif
+#ifndef OPENSSL_NO_DSA
+ struct dsa_st *dsa; /* DSA */
+#endif
+#ifndef OPENSSL_NO_DH
+ struct dh_st *dh; /* DH */
+#endif
+#ifndef OPENSSL_NO_EC
+ struct ec_key_st *ec; /* ECC */
+#endif
+ } pkey;
+ int save_parameters;
+ STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
+ } /* EVP_PKEY */;
+
+#define EVP_PKEY_MO_SIGN 0x0001
+#define EVP_PKEY_MO_VERIFY 0x0002
+#define EVP_PKEY_MO_ENCRYPT 0x0004
+#define EVP_PKEY_MO_DECRYPT 0x0008
+
+#if 0
+/* This structure is required to tie the message digest and signing together.
+ * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or
+ * oid, md and pkey.
+ * This is required because for various smart-card perform the digest and
+ * signing/verification on-board. To handle this case, the specific
+ * EVP_MD and EVP_PKEY_METHODs need to be closely associated.
+ * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it.
+ * This can either be software or a token to provide the required low level
+ * routines.
+ */
+typedef struct evp_pkey_md_st
+ {
+ int oid;
+ EVP_MD *md;
+ EVP_PKEY_METHOD *pkey;
+ } EVP_PKEY_MD;
+
+#define EVP_rsa_md2() \
+ EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\
+ EVP_rsa_pkcs1(),EVP_md2())
+#define EVP_rsa_md5() \
+ EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\
+ EVP_rsa_pkcs1(),EVP_md5())
+#define EVP_rsa_sha0() \
+ EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\
+ EVP_rsa_pkcs1(),EVP_sha())
+#define EVP_rsa_sha1() \
+ EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\
+ EVP_rsa_pkcs1(),EVP_sha1())
+#define EVP_rsa_ripemd160() \
+ EVP_PKEY_MD_add(NID_ripemd160WithRSA,\
+ EVP_rsa_pkcs1(),EVP_ripemd160())
+#define EVP_rsa_mdc2() \
+ EVP_PKEY_MD_add(NID_mdc2WithRSA,\
+ EVP_rsa_octet_string(),EVP_mdc2())
+#define EVP_dsa_sha() \
+ EVP_PKEY_MD_add(NID_dsaWithSHA,\
+ EVP_dsa(),EVP_sha())
+#define EVP_dsa_sha1() \
+ EVP_PKEY_MD_add(NID_dsaWithSHA1,\
+ EVP_dsa(),EVP_sha1())
+
+typedef struct evp_pkey_method_st
+ {
+ char *name;
+ int flags;
+ int type; /* RSA, DSA, an SSLeay specific constant */
+ int oid; /* For the pub-key type */
+ int encrypt_oid; /* pub/priv key encryption */
+
+ int (*sign)();
+ int (*verify)();
+ struct {
+ int (*set)(); /* get and/or set the underlying type */
+ int (*get)();
+ int (*encrypt)();
+ int (*decrypt)();
+ int (*i2d)();
+ int (*d2i)();
+ int (*dup)();
+ } pub,priv;
+ int (*set_asn1_parameters)();
+ int (*get_asn1_parameters)();
+ } EVP_PKEY_METHOD;
+#endif
+
+#ifndef EVP_MD
+struct env_md_st
+ {
+ int type;
+ int pkey_type;
+ int md_size;
+ unsigned long flags;
+ int (*init)(EVP_MD_CTX *ctx);
+ int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count);
+ int (*final)(EVP_MD_CTX *ctx,unsigned char *md);
+ int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from);
+ int (*cleanup)(EVP_MD_CTX *ctx);
+
+ /* FIXME: prototype these some day */
+ int (*sign)(int type, const unsigned char *m, unsigned int m_length,
+ unsigned char *sigret, unsigned int *siglen, void *key);
+ int (*verify)(int type, const unsigned char *m, unsigned int m_length,
+ const unsigned char *sigbuf, unsigned int siglen,
+ void *key);
+ int required_pkey_type[5]; /*EVP_PKEY_xxx */
+ int block_size;
+ int ctx_size; /* how big does the ctx->md_data need to be */
+ } /* EVP_MD */;
+
+typedef int evp_sign_method(int type,const unsigned char *m,
+ unsigned int m_length,unsigned char *sigret,
+ unsigned int *siglen, void *key);
+typedef int evp_verify_method(int type,const unsigned char *m,
+ unsigned int m_length,const unsigned char *sigbuf,
+ unsigned int siglen, void *key);
+
+typedef struct
+ {
+ EVP_MD_CTX *mctx;
+ void *key;
+ } EVP_MD_SVCTX;
+
+#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single
+ * block */
+
+#define EVP_MD_FLAG_FIPS 0x0400 /* Note if suitable for use in FIPS mode */
+
+#define EVP_MD_FLAG_SVCTX 0x0800 /* pass EVP_MD_SVCTX to sign/verify */
+
+#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0}
+
+#ifndef OPENSSL_NO_DSA
+#define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \
+ (evp_verify_method *)DSA_verify, \
+ {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \
+ EVP_PKEY_DSA4,0}
+#else
+#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method
+#endif
+
+#ifndef OPENSSL_NO_ECDSA
+#define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \
+ (evp_verify_method *)ECDSA_verify, \
+ {EVP_PKEY_EC,0,0,0}
+#else
+#define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method
+#endif
+
+#ifndef OPENSSL_NO_RSA
+#define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \
+ (evp_verify_method *)RSA_verify, \
+ {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
+#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \
+ (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \
+ (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \
+ {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
+#else
+#define EVP_PKEY_RSA_method EVP_PKEY_NULL_method
+#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method
+#endif
+
+#endif /* !EVP_MD */
+
+struct env_md_ctx_st
+ {
+ const EVP_MD *digest;
+ ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */
+ unsigned long flags;
+ void *md_data;
+ } /* EVP_MD_CTX */;
+
+/* values for EVP_MD_CTX flags */
+
+#define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called
+ * once only */
+#define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been
+ * cleaned */
+#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data
+ * in EVP_MD_CTX_cleanup */
+#define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008 /* Allow use of non FIPS digest
+ * in FIPS mode */
+
+#define EVP_MD_CTX_FLAG_PAD_MASK 0xF0 /* RSA mode to use */
+#define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00 /* PKCS#1 v1.5 mode */
+#define EVP_MD_CTX_FLAG_PAD_X931 0x10 /* X9.31 mode */
+#define EVP_MD_CTX_FLAG_PAD_PSS 0x20 /* PSS mode */
+#define M_EVP_MD_CTX_FLAG_PSS_SALT(ctx) \
+ ((ctx->flags>>16) &0xFFFF) /* seed length */
+#define EVP_MD_CTX_FLAG_PSS_MDLEN 0xFFFF /* salt len same as digest */
+#define EVP_MD_CTX_FLAG_PSS_MREC 0xFFFE /* salt max or auto recovered */
+
+struct evp_cipher_st
+ {
+ int nid;
+ int block_size;
+ int key_len; /* Default value for variable length ciphers */
+ int iv_len;
+ unsigned long flags; /* Various flags */
+ int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+ const unsigned char *iv, int enc); /* init key */
+ int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */
+ int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
+ int ctx_size; /* how big ctx->cipher_data needs to be */
+ int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
+ int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */
+ int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */
+ void *app_data; /* Application data */
+ } /* EVP_CIPHER */;
+
+/* Values for cipher flags */
+
+/* Modes for ciphers */
+
+#define EVP_CIPH_STREAM_CIPHER 0x0
+#define EVP_CIPH_ECB_MODE 0x1
+#define EVP_CIPH_CBC_MODE 0x2
+#define EVP_CIPH_CFB_MODE 0x3
+#define EVP_CIPH_OFB_MODE 0x4
+#define EVP_CIPH_MODE 0x7
+/* Set if variable length cipher */
+#define EVP_CIPH_VARIABLE_LENGTH 0x8
+/* Set if the iv handling should be done by the cipher itself */
+#define EVP_CIPH_CUSTOM_IV 0x10
+/* Set if the cipher's init() function should be called if key is NULL */
+#define EVP_CIPH_ALWAYS_CALL_INIT 0x20
+/* Call ctrl() to init cipher parameters */
+#define EVP_CIPH_CTRL_INIT 0x40
+/* Don't use standard key length function */
+#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80
+/* Don't use standard block padding */
+#define EVP_CIPH_NO_PADDING 0x100
+/* cipher handles random key generation */
+#define EVP_CIPH_RAND_KEY 0x200
+/* Note if suitable for use in FIPS mode */
+#define EVP_CIPH_FLAG_FIPS 0x400
+/* Allow non FIPS cipher in FIPS mode */
+#define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x800
+/* Allow use default ASN1 get/set iv */
+#define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000
+/* Buffer length in bits not bytes: CFB1 mode only */
+#define EVP_CIPH_FLAG_LENGTH_BITS 0x2000
+
+/* ctrl() values */
+
+#define EVP_CTRL_INIT 0x0
+#define EVP_CTRL_SET_KEY_LENGTH 0x1
+#define EVP_CTRL_GET_RC2_KEY_BITS 0x2
+#define EVP_CTRL_SET_RC2_KEY_BITS 0x3
+#define EVP_CTRL_GET_RC5_ROUNDS 0x4
+#define EVP_CTRL_SET_RC5_ROUNDS 0x5
+#define EVP_CTRL_RAND_KEY 0x6
+
+typedef struct evp_cipher_info_st
+ {
+ const EVP_CIPHER *cipher;
+ unsigned char iv[EVP_MAX_IV_LENGTH];
+ } EVP_CIPHER_INFO;
+
+struct evp_cipher_ctx_st
+ {
+ const EVP_CIPHER *cipher;
+ ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */
+ int encrypt; /* encrypt or decrypt */
+ int buf_len; /* number we have left */
+
+ unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
+ unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
+ unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */
+ int num; /* used by cfb/ofb mode */
+
+ void *app_data; /* application stuff */
+ int key_len; /* May change for variable length cipher */
+ unsigned long flags; /* Various flags */
+ void *cipher_data; /* per EVP data */
+ int final_used;
+ int block_mask;
+ unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */
+ } /* EVP_CIPHER_CTX */;
+
+typedef struct evp_Encode_Ctx_st
+ {
+ int num; /* number saved in a partial encode/decode */
+ int length; /* The length is either the output line length
+ * (in input bytes) or the shortest input line
+ * length that is ok. Once decoding begins,
+ * the length is adjusted up each time a longer
+ * line is decoded */
+ unsigned char enc_data[80]; /* data to encode */
+ int line_num; /* number read on current line */
+ int expect_nl;
+ } EVP_ENCODE_CTX;
+
+/* Password based encryption function */
+typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
+ ASN1_TYPE *param, const EVP_CIPHER *cipher,
+ const EVP_MD *md, int en_de);
+
+#ifndef OPENSSL_NO_RSA
+#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
+ (char *)(rsa))
+#endif
+
+#ifndef OPENSSL_NO_DSA
+#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
+ (char *)(dsa))
+#endif
+
+#ifndef OPENSSL_NO_DH
+#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
+ (char *)(dh))
+#endif
+
+#ifndef OPENSSL_NO_EC
+#define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\
+ (char *)(eckey))
+#endif
+
+/* Add some extra combinations */
+#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
+#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
+#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
+#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
+
+/* Macros to reduce FIPS dependencies: do NOT use in applications */
+#define M_EVP_MD_size(e) ((e)->md_size)
+#define M_EVP_MD_block_size(e) ((e)->block_size)
+#define M_EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
+#define M_EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs))
+#define M_EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs))
+#define M_EVP_MD_type(e) ((e)->type)
+#define M_EVP_MD_CTX_type(e) M_EVP_MD_type(M_EVP_MD_CTX_md(e))
+#define M_EVP_MD_CTX_md(e) ((e)->digest)
+
+#define M_EVP_CIPHER_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
+
+int EVP_MD_type(const EVP_MD *md);
+#define EVP_MD_nid(e) EVP_MD_type(e)
+#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
+int EVP_MD_pkey_type(const EVP_MD *md);
+int EVP_MD_size(const EVP_MD *md);
+int EVP_MD_block_size(const EVP_MD *md);
+
+const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
+#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
+#define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e))
+#define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e))
+
+int EVP_CIPHER_nid(const EVP_CIPHER *cipher);
+#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
+int EVP_CIPHER_block_size(const EVP_CIPHER *cipher);
+int EVP_CIPHER_key_length(const EVP_CIPHER *cipher);
+int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);
+unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);
+#define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)
+
+const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
+int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);
+int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);
+int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);
+int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);
+void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
+void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
+#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
+unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);
+#define EVP_CIPHER_CTX_mode(e) (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE)
+
+#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80)
+#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80)
+
+#define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
+#define EVP_SignInit(a,b) EVP_DigestInit(a,b)
+#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
+#define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
+#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
+#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
+#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
+#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
+
+#ifdef CONST_STRICT
+void BIO_set_md(BIO *,const EVP_MD *md);
+#else
+# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)
+#endif
+#define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)
+#define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)
+#define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp)
+#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
+#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)
+
+int EVP_Cipher(EVP_CIPHER_CTX *c,
+ unsigned char *out,
+ const unsigned char *in,
+ unsigned int inl);
+
+#define EVP_add_cipher_alias(n,alias) \
+ OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
+#define EVP_add_digest_alias(n,alias) \
+ OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))
+#define EVP_delete_cipher_alias(alias) \
+ OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
+#define EVP_delete_digest_alias(alias) \
+ OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
+
+void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
+int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
+EVP_MD_CTX *EVP_MD_CTX_create(void);
+void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
+int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
+void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
+void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
+int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx,int flags);
+int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
+int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d,
+ size_t cnt);
+int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
+int EVP_Digest(const void *data, size_t count,
+ unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl);
+
+int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);
+int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
+int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
+
+int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
+void EVP_set_pw_prompt(const char *prompt);
+char * EVP_get_pw_prompt(void);
+
+int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
+ const unsigned char *salt, const unsigned char *data,
+ int datal, int count, unsigned char *key,unsigned char *iv);
+
+void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);
+void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);
+int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx,int flags);
+
+int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
+ const unsigned char *key, const unsigned char *iv);
+int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
+ const unsigned char *key, const unsigned char *iv);
+int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ int *outl, const unsigned char *in, int inl);
+int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
+int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
+
+int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
+ const unsigned char *key, const unsigned char *iv);
+int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
+ const unsigned char *key, const unsigned char *iv);
+int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ int *outl, const unsigned char *in, int inl);
+int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
+int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
+
+int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
+ const unsigned char *key,const unsigned char *iv,
+ int enc);
+int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
+ const unsigned char *key,const unsigned char *iv,
+ int enc);
+int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ int *outl, const unsigned char *in, int inl);
+int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
+int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
+
+int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
+ EVP_PKEY *pkey);
+
+int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf,
+ unsigned int siglen,EVP_PKEY *pkey);
+
+int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,
+ const unsigned char *ek, int ekl, const unsigned char *iv,
+ EVP_PKEY *priv);
+int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
+
+int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
+ unsigned char **ek, int *ekl, unsigned char *iv,
+ EVP_PKEY **pubk, int npubk);
+int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
+
+void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
+void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
+ const unsigned char *in,int inl);
+void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
+int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
+
+void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
+int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
+ const unsigned char *in, int inl);
+int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
+ char *out, int *outl);
+int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
+
+void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
+int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
+EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
+void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
+int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
+int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
+int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
+int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
+
+#ifndef OPENSSL_NO_BIO
+BIO_METHOD *BIO_f_md(void);
+BIO_METHOD *BIO_f_base64(void);
+BIO_METHOD *BIO_f_cipher(void);
+BIO_METHOD *BIO_f_reliable(void);
+void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k,
+ const unsigned char *i, int enc);
+#endif
+
+const EVP_MD *EVP_md_null(void);
+#ifndef OPENSSL_NO_MD2
+const EVP_MD *EVP_md2(void);
+#endif
+#ifndef OPENSSL_NO_MD4
+const EVP_MD *EVP_md4(void);
+#endif
+#ifndef OPENSSL_NO_MD5
+const EVP_MD *EVP_md5(void);
+#endif
+#ifndef OPENSSL_NO_SHA
+const EVP_MD *EVP_sha(void);
+const EVP_MD *EVP_sha1(void);
+const EVP_MD *EVP_dss(void);
+const EVP_MD *EVP_dss1(void);
+const EVP_MD *EVP_ecdsa(void);
+#endif
+#ifndef OPENSSL_NO_SHA256
+const EVP_MD *EVP_sha224(void);
+const EVP_MD *EVP_sha256(void);
+#endif
+#ifndef OPENSSL_NO_SHA512
+const EVP_MD *EVP_sha384(void);
+const EVP_MD *EVP_sha512(void);
+#endif
+#ifndef OPENSSL_NO_MDC2
+const EVP_MD *EVP_mdc2(void);
+#endif
+#ifndef OPENSSL_NO_RIPEMD
+const EVP_MD *EVP_ripemd160(void);
+#endif
+const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
+#ifndef OPENSSL_NO_DES
+const EVP_CIPHER *EVP_des_ecb(void);
+const EVP_CIPHER *EVP_des_ede(void);
+const EVP_CIPHER *EVP_des_ede3(void);
+const EVP_CIPHER *EVP_des_ede_ecb(void);
+const EVP_CIPHER *EVP_des_ede3_ecb(void);
+const EVP_CIPHER *EVP_des_cfb64(void);
+# define EVP_des_cfb EVP_des_cfb64
+const EVP_CIPHER *EVP_des_cfb1(void);
+const EVP_CIPHER *EVP_des_cfb8(void);
+const EVP_CIPHER *EVP_des_ede_cfb64(void);
+# define EVP_des_ede_cfb EVP_des_ede_cfb64
+#if 0
+const EVP_CIPHER *EVP_des_ede_cfb1(void);
+const EVP_CIPHER *EVP_des_ede_cfb8(void);
+#endif
+const EVP_CIPHER *EVP_des_ede3_cfb64(void);
+# define EVP_des_ede3_cfb EVP_des_ede3_cfb64
+const EVP_CIPHER *EVP_des_ede3_cfb1(void);
+const EVP_CIPHER *EVP_des_ede3_cfb8(void);
+const EVP_CIPHER *EVP_des_ofb(void);
+const EVP_CIPHER *EVP_des_ede_ofb(void);
+const EVP_CIPHER *EVP_des_ede3_ofb(void);
+const EVP_CIPHER *EVP_des_cbc(void);
+const EVP_CIPHER *EVP_des_ede_cbc(void);
+const EVP_CIPHER *EVP_des_ede3_cbc(void);
+const EVP_CIPHER *EVP_desx_cbc(void);
+/* This should now be supported through the dev_crypto ENGINE. But also, why are
+ * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */
+#if 0
+# ifdef OPENSSL_OPENBSD_DEV_CRYPTO
+const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);
+const EVP_CIPHER *EVP_dev_crypto_rc4(void);
+const EVP_MD *EVP_dev_crypto_md5(void);
+# endif
+#endif
+#endif
+#ifndef OPENSSL_NO_RC4
+const EVP_CIPHER *EVP_rc4(void);
+const EVP_CIPHER *EVP_rc4_40(void);
+#endif
+#ifndef OPENSSL_NO_IDEA
+const EVP_CIPHER *EVP_idea_ecb(void);
+const EVP_CIPHER *EVP_idea_cfb64(void);
+# define EVP_idea_cfb EVP_idea_cfb64
+const EVP_CIPHER *EVP_idea_ofb(void);
+const EVP_CIPHER *EVP_idea_cbc(void);
+#endif
+#ifndef OPENSSL_NO_RC2
+const EVP_CIPHER *EVP_rc2_ecb(void);
+const EVP_CIPHER *EVP_rc2_cbc(void);
+const EVP_CIPHER *EVP_rc2_40_cbc(void);
+const EVP_CIPHER *EVP_rc2_64_cbc(void);
+const EVP_CIPHER *EVP_rc2_cfb64(void);
+# define EVP_rc2_cfb EVP_rc2_cfb64
+const EVP_CIPHER *EVP_rc2_ofb(void);
+#endif
+#ifndef OPENSSL_NO_BF
+const EVP_CIPHER *EVP_bf_ecb(void);
+const EVP_CIPHER *EVP_bf_cbc(void);
+const EVP_CIPHER *EVP_bf_cfb64(void);
+# define EVP_bf_cfb EVP_bf_cfb64
+const EVP_CIPHER *EVP_bf_ofb(void);
+#endif
+#ifndef OPENSSL_NO_CAST
+const EVP_CIPHER *EVP_cast5_ecb(void);
+const EVP_CIPHER *EVP_cast5_cbc(void);
+const EVP_CIPHER *EVP_cast5_cfb64(void);
+# define EVP_cast5_cfb EVP_cast5_cfb64
+const EVP_CIPHER *EVP_cast5_ofb(void);
+#endif
+#ifndef OPENSSL_NO_RC5
+const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
+const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
+const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);
+# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64
+const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
+#endif
+#ifndef OPENSSL_NO_AES
+const EVP_CIPHER *EVP_aes_128_ecb(void);
+const EVP_CIPHER *EVP_aes_128_cbc(void);
+const EVP_CIPHER *EVP_aes_128_cfb1(void);
+const EVP_CIPHER *EVP_aes_128_cfb8(void);
+const EVP_CIPHER *EVP_aes_128_cfb128(void);
+# define EVP_aes_128_cfb EVP_aes_128_cfb128
+const EVP_CIPHER *EVP_aes_128_ofb(void);
+#if 0
+const EVP_CIPHER *EVP_aes_128_ctr(void);
+#endif
+const EVP_CIPHER *EVP_aes_192_ecb(void);
+const EVP_CIPHER *EVP_aes_192_cbc(void);
+const EVP_CIPHER *EVP_aes_192_cfb1(void);
+const EVP_CIPHER *EVP_aes_192_cfb8(void);
+const EVP_CIPHER *EVP_aes_192_cfb128(void);
+# define EVP_aes_192_cfb EVP_aes_192_cfb128
+const EVP_CIPHER *EVP_aes_192_ofb(void);
+#if 0
+const EVP_CIPHER *EVP_aes_192_ctr(void);
+#endif
+const EVP_CIPHER *EVP_aes_256_ecb(void);
+const EVP_CIPHER *EVP_aes_256_cbc(void);
+const EVP_CIPHER *EVP_aes_256_cfb1(void);
+const EVP_CIPHER *EVP_aes_256_cfb8(void);
+const EVP_CIPHER *EVP_aes_256_cfb128(void);
+# define EVP_aes_256_cfb EVP_aes_256_cfb128
+const EVP_CIPHER *EVP_aes_256_ofb(void);
+#if 0
+const EVP_CIPHER *EVP_aes_256_ctr(void);
+#endif
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+const EVP_CIPHER *EVP_camellia_128_ecb(void);
+const EVP_CIPHER *EVP_camellia_128_cbc(void);
+const EVP_CIPHER *EVP_camellia_128_cfb1(void);
+const EVP_CIPHER *EVP_camellia_128_cfb8(void);
+const EVP_CIPHER *EVP_camellia_128_cfb128(void);
+# define EVP_camellia_128_cfb EVP_camellia_128_cfb128
+const EVP_CIPHER *EVP_camellia_128_ofb(void);
+const EVP_CIPHER *EVP_camellia_192_ecb(void);
+const EVP_CIPHER *EVP_camellia_192_cbc(void);
+const EVP_CIPHER *EVP_camellia_192_cfb1(void);
+const EVP_CIPHER *EVP_camellia_192_cfb8(void);
+const EVP_CIPHER *EVP_camellia_192_cfb128(void);
+# define EVP_camellia_192_cfb EVP_camellia_192_cfb128
+const EVP_CIPHER *EVP_camellia_192_ofb(void);
+const EVP_CIPHER *EVP_camellia_256_ecb(void);
+const EVP_CIPHER *EVP_camellia_256_cbc(void);
+const EVP_CIPHER *EVP_camellia_256_cfb1(void);
+const EVP_CIPHER *EVP_camellia_256_cfb8(void);
+const EVP_CIPHER *EVP_camellia_256_cfb128(void);
+# define EVP_camellia_256_cfb EVP_camellia_256_cfb128
+const EVP_CIPHER *EVP_camellia_256_ofb(void);
+#endif
+
+#ifndef OPENSSL_NO_SEED
+const EVP_CIPHER *EVP_seed_ecb(void);
+const EVP_CIPHER *EVP_seed_cbc(void);
+const EVP_CIPHER *EVP_seed_cfb128(void);
+# define EVP_seed_cfb EVP_seed_cfb128
+const EVP_CIPHER *EVP_seed_ofb(void);
+#endif
+
+void OPENSSL_add_all_algorithms_noconf(void);
+void OPENSSL_add_all_algorithms_conf(void);
+
+#ifdef OPENSSL_LOAD_CONF
+#define OpenSSL_add_all_algorithms() \
+ OPENSSL_add_all_algorithms_conf()
+#else
+#define OpenSSL_add_all_algorithms() \
+ OPENSSL_add_all_algorithms_noconf()
+#endif
+
+void OpenSSL_add_all_ciphers(void);
+void OpenSSL_add_all_digests(void);
+#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()
+#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
+#define SSLeay_add_all_digests() OpenSSL_add_all_digests()
+
+int EVP_add_cipher(const EVP_CIPHER *cipher);
+int EVP_add_digest(const EVP_MD *digest);
+
+const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
+const EVP_MD *EVP_get_digestbyname(const char *name);
+void EVP_cleanup(void);
+
+int EVP_PKEY_decrypt(unsigned char *dec_key,
+ const unsigned char *enc_key,int enc_key_len,
+ EVP_PKEY *private_key);
+int EVP_PKEY_encrypt(unsigned char *enc_key,
+ const unsigned char *key,int key_len,
+ EVP_PKEY *pub_key);
+int EVP_PKEY_type(int type);
+int EVP_PKEY_bits(EVP_PKEY *pkey);
+int EVP_PKEY_size(EVP_PKEY *pkey);
+int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
+
+#ifndef OPENSSL_NO_RSA
+struct rsa_st;
+int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key);
+struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
+#endif
+#ifndef OPENSSL_NO_DSA
+struct dsa_st;
+int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key);
+struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
+#endif
+#ifndef OPENSSL_NO_DH
+struct dh_st;
+int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key);
+struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
+#endif
+#ifndef OPENSSL_NO_EC
+struct ec_key_st;
+int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key);
+struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
+#endif
+
+EVP_PKEY * EVP_PKEY_new(void);
+void EVP_PKEY_free(EVP_PKEY *pkey);
+
+EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp,
+ long length);
+int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
+
+EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp,
+ long length);
+EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
+ long length);
+int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
+
+int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
+int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
+int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
+int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
+
+int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
+
+int EVP_CIPHER_type(const EVP_CIPHER *ctx);
+
+/* calls methods */
+int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
+int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
+
+/* These are used by EVP_CIPHER methods */
+int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
+int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
+
+/* PKCS5 password based encryption */
+int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
+ ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
+ int en_de);
+int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
+ const unsigned char *salt, int saltlen, int iter,
+ int keylen, unsigned char *out);
+int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
+ ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
+ int en_de);
+
+void PKCS5_PBE_add(void);
+
+int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
+ ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
+int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
+ EVP_PBE_KEYGEN *keygen);
+void EVP_PBE_cleanup(void);
+
+#ifdef OPENSSL_FIPS
+#ifndef OPENSSL_NO_ENGINE
+void int_EVP_MD_set_engine_callbacks(
+ int (*eng_md_init)(ENGINE *impl),
+ int (*eng_md_fin)(ENGINE *impl),
+ int (*eng_md_evp)
+ (EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl));
+void int_EVP_MD_init_engine_callbacks(void);
+void int_EVP_CIPHER_set_engine_callbacks(
+ int (*eng_ciph_fin)(ENGINE *impl),
+ int (*eng_ciph_evp)
+ (EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pciph, ENGINE *impl));
+void int_EVP_CIPHER_init_engine_callbacks(void);
+#endif
+#endif
+
+void EVP_add_alg_module(void);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_EVP_strings(void);
+
+/* Error codes for the EVP functions. */
+
+/* Function codes. */
+#define EVP_F_AES_INIT_KEY 133
+#define EVP_F_ALG_MODULE_INIT 138
+#define EVP_F_CAMELLIA_INIT_KEY 159
+#define EVP_F_D2I_PKEY 100
+#define EVP_F_DO_EVP_ENC_ENGINE 140
+#define EVP_F_DO_EVP_ENC_ENGINE_FULL 141
+#define EVP_F_DO_EVP_MD_ENGINE 139
+#define EVP_F_DO_EVP_MD_ENGINE_FULL 142
+#define EVP_F_DSAPKEY2PKCS8 134
+#define EVP_F_DSA_PKEY2PKCS8 135
+#define EVP_F_ECDSA_PKEY2PKCS8 129
+#define EVP_F_ECKEY_PKEY2PKCS8 132
+#define EVP_F_EVP_CIPHERINIT 137
+#define EVP_F_EVP_CIPHERINIT_EX 123
+#define EVP_F_EVP_CIPHER_CTX_CTRL 124
+#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
+#define EVP_F_EVP_DECRYPTFINAL_EX 101
+#define EVP_F_EVP_DIGESTINIT 136
+#define EVP_F_EVP_DIGESTINIT_EX 128
+#define EVP_F_EVP_ENCRYPTFINAL_EX 127
+#define EVP_F_EVP_MD_CTX_COPY_EX 110
+#define EVP_F_EVP_OPENINIT 102
+#define EVP_F_EVP_PBE_ALG_ADD 115
+#define EVP_F_EVP_PBE_CIPHERINIT 116
+#define EVP_F_EVP_PKCS82PKEY 111
+#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113
+#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
+#define EVP_F_EVP_PKEY_DECRYPT 104
+#define EVP_F_EVP_PKEY_ENCRYPT 105
+#define EVP_F_EVP_PKEY_GET1_DH 119
+#define EVP_F_EVP_PKEY_GET1_DSA 120
+#define EVP_F_EVP_PKEY_GET1_ECDSA 130
+#define EVP_F_EVP_PKEY_GET1_EC_KEY 131
+#define EVP_F_EVP_PKEY_GET1_RSA 121
+#define EVP_F_EVP_PKEY_NEW 106
+#define EVP_F_EVP_RIJNDAEL 126
+#define EVP_F_EVP_SIGNFINAL 107
+#define EVP_F_EVP_VERIFYFINAL 108
+#define EVP_F_PKCS5_PBE_KEYIVGEN 117
+#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118
+#define EVP_F_PKCS8_SET_BROKEN 112
+#define EVP_F_RC2_MAGIC_TO_METH 109
+#define EVP_F_RC5_CTRL 125
+
+/* Reason codes. */
+#define EVP_R_AES_KEY_SETUP_FAILED 143
+#define EVP_R_ASN1_LIB 140
+#define EVP_R_BAD_BLOCK_LENGTH 136
+#define EVP_R_BAD_DECRYPT 100
+#define EVP_R_BAD_KEY_LENGTH 137
+#define EVP_R_BN_DECODE_ERROR 112
+#define EVP_R_BN_PUBKEY_ERROR 113
+#define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157
+#define EVP_R_CIPHER_PARAMETER_ERROR 122
+#define EVP_R_CTRL_NOT_IMPLEMENTED 132
+#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133
+#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138
+#define EVP_R_DECODE_ERROR 114
+#define EVP_R_DIFFERENT_KEY_TYPES 101
+#define EVP_R_DISABLED_FOR_FIPS 144
+#define EVP_R_ENCODE_ERROR 115
+#define EVP_R_ERROR_LOADING_SECTION 145
+#define EVP_R_ERROR_SETTING_FIPS_MODE 146
+#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
+#define EVP_R_EXPECTING_AN_RSA_KEY 127
+#define EVP_R_EXPECTING_A_DH_KEY 128
+#define EVP_R_EXPECTING_A_DSA_KEY 129
+#define EVP_R_EXPECTING_A_ECDSA_KEY 141
+#define EVP_R_EXPECTING_A_EC_KEY 142
+#define EVP_R_FIPS_MODE_NOT_SUPPORTED 147
+#define EVP_R_INITIALIZATION_ERROR 134
+#define EVP_R_INPUT_NOT_INITIALIZED 111
+#define EVP_R_INVALID_FIPS_MODE 148
+#define EVP_R_INVALID_KEY_LENGTH 130
+#define EVP_R_IV_TOO_LARGE 102
+#define EVP_R_KEYGEN_FAILURE 120
+#define EVP_R_MISSING_PARAMETERS 103
+#define EVP_R_NO_CIPHER_SET 131
+#define EVP_R_NO_DIGEST_SET 139
+#define EVP_R_NO_DSA_PARAMETERS 116
+#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
+#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
+#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117
+#define EVP_R_PUBLIC_KEY_NOT_RSA 106
+#define EVP_R_UNKNOWN_OPTION 149
+#define EVP_R_UNKNOWN_PBE_ALGORITHM 121
+#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135
+#define EVP_R_UNSUPPORTED_CIPHER 107
+#define EVP_R_UNSUPPORTED_KEYLENGTH 123
+#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124
+#define EVP_R_UNSUPPORTED_KEY_SIZE 108
+#define EVP_R_UNSUPPORTED_PRF 125
+#define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118
+#define EVP_R_UNSUPPORTED_SALT_TYPE 126
+#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109
+#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110
+#define EVP_R_SEED_KEY_SETUP_FAILED 162
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/fips.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/fips.h
new file mode 100644
index 000000000..42bdcf259
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/fips.h
@@ -0,0 +1,163 @@
+/* ====================================================================
+ * Copyright (c) 2003 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ *
+ */
+
+#include <openssl/opensslconf.h>
+
+#ifndef OPENSSL_FIPS
+#error FIPS is disabled.
+#endif
+
+#ifdef OPENSSL_FIPS
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct dsa_st;
+struct evp_pkey_st;
+struct env_md_st;
+struct evp_cipher_st;
+struct evp_cipher_ctx_st;
+
+int FIPS_mode_set(int onoff);
+int FIPS_mode(void);
+const void *FIPS_rand_check(void);
+int FIPS_selftest_failed(void);
+void FIPS_selftest_check(void);
+void FIPS_corrupt_sha1(void);
+int FIPS_selftest_sha1(void);
+void FIPS_corrupt_aes(void);
+int FIPS_selftest_aes(void);
+void FIPS_corrupt_des(void);
+int FIPS_selftest_des(void);
+void FIPS_corrupt_rsa(void);
+void FIPS_corrupt_rsa_keygen(void);
+int FIPS_selftest_rsa(void);
+void FIPS_corrupt_dsa(void);
+void FIPS_corrupt_dsa_keygen(void);
+int FIPS_selftest_dsa(void);
+void FIPS_corrupt_rng(void);
+void FIPS_rng_stick(void);
+int FIPS_selftest_rng(void);
+int FIPS_selftest_hmac(void);
+
+int fips_pkey_signature_test(struct evp_pkey_st *pkey,
+ const unsigned char *tbs, int tbslen,
+ const unsigned char *kat, unsigned int katlen,
+ const struct env_md_st *digest, unsigned int md_flags,
+ const char *fail_str);
+
+int fips_cipher_test(struct evp_cipher_ctx_st *ctx,
+ const struct evp_cipher_st *cipher,
+ const unsigned char *key,
+ const unsigned char *iv,
+ const unsigned char *plaintext,
+ const unsigned char *ciphertext,
+ int len);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_FIPS_strings(void);
+
+/* Error codes for the FIPS functions. */
+
+/* Function codes. */
+#define FIPS_F_DH_BUILTIN_GENPARAMS 100
+#define FIPS_F_DSA_BUILTIN_PARAMGEN 101
+#define FIPS_F_DSA_DO_SIGN 102
+#define FIPS_F_DSA_DO_VERIFY 103
+#define FIPS_F_EVP_CIPHERINIT_EX 124
+#define FIPS_F_EVP_DIGESTINIT_EX 125
+#define FIPS_F_FIPS_CHECK_DSA 104
+#define FIPS_F_FIPS_CHECK_INCORE_FINGERPRINT 105
+#define FIPS_F_FIPS_CHECK_RSA 106
+#define FIPS_F_FIPS_DSA_CHECK 107
+#define FIPS_F_FIPS_MODE_SET 108
+#define FIPS_F_FIPS_PKEY_SIGNATURE_TEST 109
+#define FIPS_F_FIPS_SELFTEST_AES 110
+#define FIPS_F_FIPS_SELFTEST_DES 111
+#define FIPS_F_FIPS_SELFTEST_DSA 112
+#define FIPS_F_FIPS_SELFTEST_HMAC 113
+#define FIPS_F_FIPS_SELFTEST_RNG 114
+#define FIPS_F_FIPS_SELFTEST_SHA1 115
+#define FIPS_F_HASH_FINAL 123
+#define FIPS_F_RSA_BUILTIN_KEYGEN 116
+#define FIPS_F_RSA_EAY_PRIVATE_DECRYPT 117
+#define FIPS_F_RSA_EAY_PRIVATE_ENCRYPT 118
+#define FIPS_F_RSA_EAY_PUBLIC_DECRYPT 119
+#define FIPS_F_RSA_EAY_PUBLIC_ENCRYPT 120
+#define FIPS_F_RSA_X931_GENERATE_KEY_EX 121
+#define FIPS_F_SSLEAY_RAND_BYTES 122
+
+/* Reason codes. */
+#define FIPS_R_CANNOT_READ_EXE 103
+#define FIPS_R_CANNOT_READ_EXE_DIGEST 104
+#define FIPS_R_CONTRADICTING_EVIDENCE 114
+#define FIPS_R_EXE_DIGEST_DOES_NOT_MATCH 105
+#define FIPS_R_FINGERPRINT_DOES_NOT_MATCH 110
+#define FIPS_R_FINGERPRINT_DOES_NOT_MATCH_NONPIC_RELOCATED 111
+#define FIPS_R_FINGERPRINT_DOES_NOT_MATCH_SEGMENT_ALIASING 112
+#define FIPS_R_FIPS_MODE_ALREADY_SET 102
+#define FIPS_R_FIPS_SELFTEST_FAILED 106
+#define FIPS_R_INVALID_KEY_LENGTH 109
+#define FIPS_R_KEY_TOO_SHORT 108
+#define FIPS_R_NON_FIPS_METHOD 100
+#define FIPS_R_PAIRWISE_TEST_FAILED 107
+#define FIPS_R_RSA_DECRYPT_ERROR 115
+#define FIPS_R_RSA_ENCRYPT_ERROR 116
+#define FIPS_R_SELFTEST_FAILED 101
+#define FIPS_R_TEST_FAILURE 117
+#define FIPS_R_UNSUPPORTED_PLATFORM 113
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/fips_rand.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/fips_rand.h
new file mode 100644
index 000000000..a175aaf6c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/fips_rand.h
@@ -0,0 +1,77 @@
+/* ====================================================================
+ * Copyright (c) 2003 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ *
+ */
+
+#ifndef HEADER_FIPS_RAND_H
+#define HEADER_FIPS_RAND_H
+
+#include "des.h"
+
+#ifdef OPENSSL_FIPS
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int FIPS_rand_set_key(const unsigned char *key, FIPS_RAND_SIZE_T keylen);
+int FIPS_rand_seed(const void *buf, FIPS_RAND_SIZE_T num);
+int FIPS_rand_bytes(unsigned char *out, FIPS_RAND_SIZE_T outlen);
+
+int FIPS_rand_test_mode(void);
+void FIPS_rand_reset(void);
+int FIPS_rand_set_dt(unsigned char *dt);
+
+int FIPS_rand_status(void);
+
+const RAND_METHOD *FIPS_rand_method(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/hmac.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/hmac.h
new file mode 100644
index 000000000..fc38ffb52
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/hmac.h
@@ -0,0 +1,109 @@
+/* crypto/hmac/hmac.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+#ifndef HEADER_HMAC_H
+#define HEADER_HMAC_H
+
+#include <openssl/opensslconf.h>
+
+#ifdef OPENSSL_NO_HMAC
+#error HMAC is disabled.
+#endif
+
+#include <openssl/evp.h>
+
+#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct hmac_ctx_st
+ {
+ const EVP_MD *md;
+ EVP_MD_CTX md_ctx;
+ EVP_MD_CTX i_ctx;
+ EVP_MD_CTX o_ctx;
+ unsigned int key_length;
+ unsigned char key[HMAC_MAX_MD_CBLOCK];
+ } HMAC_CTX;
+
+#define HMAC_size(e) (EVP_MD_size((e)->md))
+
+
+void HMAC_CTX_init(HMAC_CTX *ctx);
+void HMAC_CTX_cleanup(HMAC_CTX *ctx);
+
+#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */
+
+void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
+ const EVP_MD *md); /* deprecated */
+void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
+ const EVP_MD *md, ENGINE *impl);
+void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len);
+void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
+unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
+ const unsigned char *d, size_t n, unsigned char *md,
+ unsigned int *md_len);
+
+void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/idea.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/idea.h
new file mode 100644
index 000000000..a137d4cbc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/idea.h
@@ -0,0 +1,103 @@
+/* crypto/idea/idea.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_IDEA_H
+#define HEADER_IDEA_H
+
+#include <openssl/opensslconf.h> /* IDEA_INT, OPENSSL_NO_IDEA */
+
+#ifdef OPENSSL_NO_IDEA
+#error IDEA is disabled.
+#endif
+
+#define IDEA_ENCRYPT 1
+#define IDEA_DECRYPT 0
+
+#define IDEA_BLOCK 8
+#define IDEA_KEY_LENGTH 16
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct idea_key_st
+ {
+ IDEA_INT data[9][6];
+ } IDEA_KEY_SCHEDULE;
+
+const char *idea_options(void);
+void idea_ecb_encrypt(const unsigned char *in, unsigned char *out,
+ IDEA_KEY_SCHEDULE *ks);
+#ifdef OPENSSL_FIPS
+void private_idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
+#endif
+void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
+void idea_set_decrypt_key(const IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);
+void idea_cbc_encrypt(const unsigned char *in, unsigned char *out,
+ long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc);
+void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,
+ long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
+ int *num,int enc);
+void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out,
+ long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num);
+void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/krb5_asn.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/krb5_asn.h
new file mode 100644
index 000000000..41725d0dc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/krb5_asn.h
@@ -0,0 +1,256 @@
+/* krb5_asn.h */
+/* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project,
+** using ocsp/{*.h,*asn*.c} as a starting point
+*/
+
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_KRB5_ASN_H
+#define HEADER_KRB5_ASN_H
+
+/*
+#include <krb5.h>
+*/
+#include <openssl/safestack.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* ASN.1 from Kerberos RFC 1510
+*/
+
+/* EncryptedData ::= SEQUENCE {
+** etype[0] INTEGER, -- EncryptionType
+** kvno[1] INTEGER OPTIONAL,
+** cipher[2] OCTET STRING -- ciphertext
+** }
+*/
+typedef struct krb5_encdata_st
+ {
+ ASN1_INTEGER *etype;
+ ASN1_INTEGER *kvno;
+ ASN1_OCTET_STRING *cipher;
+ } KRB5_ENCDATA;
+
+DECLARE_STACK_OF(KRB5_ENCDATA)
+
+/* PrincipalName ::= SEQUENCE {
+** name-type[0] INTEGER,
+** name-string[1] SEQUENCE OF GeneralString
+** }
+*/
+typedef struct krb5_princname_st
+ {
+ ASN1_INTEGER *nametype;
+ STACK_OF(ASN1_GENERALSTRING) *namestring;
+ } KRB5_PRINCNAME;
+
+DECLARE_STACK_OF(KRB5_PRINCNAME)
+
+
+/* Ticket ::= [APPLICATION 1] SEQUENCE {
+** tkt-vno[0] INTEGER,
+** realm[1] Realm,
+** sname[2] PrincipalName,
+** enc-part[3] EncryptedData
+** }
+*/
+typedef struct krb5_tktbody_st
+ {
+ ASN1_INTEGER *tktvno;
+ ASN1_GENERALSTRING *realm;
+ KRB5_PRINCNAME *sname;
+ KRB5_ENCDATA *encdata;
+ } KRB5_TKTBODY;
+
+typedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET;
+DECLARE_STACK_OF(KRB5_TKTBODY)
+
+
+/* AP-REQ ::= [APPLICATION 14] SEQUENCE {
+** pvno[0] INTEGER,
+** msg-type[1] INTEGER,
+** ap-options[2] APOptions,
+** ticket[3] Ticket,
+** authenticator[4] EncryptedData
+** }
+**
+** APOptions ::= BIT STRING {
+** reserved(0), use-session-key(1), mutual-required(2) }
+*/
+typedef struct krb5_ap_req_st
+ {
+ ASN1_INTEGER *pvno;
+ ASN1_INTEGER *msgtype;
+ ASN1_BIT_STRING *apoptions;
+ KRB5_TICKET *ticket;
+ KRB5_ENCDATA *authenticator;
+ } KRB5_APREQBODY;
+
+typedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ;
+DECLARE_STACK_OF(KRB5_APREQBODY)
+
+
+/* Authenticator Stuff */
+
+
+/* Checksum ::= SEQUENCE {
+** cksumtype[0] INTEGER,
+** checksum[1] OCTET STRING
+** }
+*/
+typedef struct krb5_checksum_st
+ {
+ ASN1_INTEGER *ctype;
+ ASN1_OCTET_STRING *checksum;
+ } KRB5_CHECKSUM;
+
+DECLARE_STACK_OF(KRB5_CHECKSUM)
+
+
+/* EncryptionKey ::= SEQUENCE {
+** keytype[0] INTEGER,
+** keyvalue[1] OCTET STRING
+** }
+*/
+typedef struct krb5_encryptionkey_st
+ {
+ ASN1_INTEGER *ktype;
+ ASN1_OCTET_STRING *keyvalue;
+ } KRB5_ENCKEY;
+
+DECLARE_STACK_OF(KRB5_ENCKEY)
+
+
+/* AuthorizationData ::= SEQUENCE OF SEQUENCE {
+** ad-type[0] INTEGER,
+** ad-data[1] OCTET STRING
+** }
+*/
+typedef struct krb5_authorization_st
+ {
+ ASN1_INTEGER *adtype;
+ ASN1_OCTET_STRING *addata;
+ } KRB5_AUTHDATA;
+
+DECLARE_STACK_OF(KRB5_AUTHDATA)
+
+
+/* -- Unencrypted authenticator
+** Authenticator ::= [APPLICATION 2] SEQUENCE {
+** authenticator-vno[0] INTEGER,
+** crealm[1] Realm,
+** cname[2] PrincipalName,
+** cksum[3] Checksum OPTIONAL,
+** cusec[4] INTEGER,
+** ctime[5] KerberosTime,
+** subkey[6] EncryptionKey OPTIONAL,
+** seq-number[7] INTEGER OPTIONAL,
+** authorization-data[8] AuthorizationData OPTIONAL
+** }
+*/
+typedef struct krb5_authenticator_st
+ {
+ ASN1_INTEGER *avno;
+ ASN1_GENERALSTRING *crealm;
+ KRB5_PRINCNAME *cname;
+ KRB5_CHECKSUM *cksum;
+ ASN1_INTEGER *cusec;
+ ASN1_GENERALIZEDTIME *ctime;
+ KRB5_ENCKEY *subkey;
+ ASN1_INTEGER *seqnum;
+ KRB5_AUTHDATA *authorization;
+ } KRB5_AUTHENTBODY;
+
+typedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT;
+DECLARE_STACK_OF(KRB5_AUTHENTBODY)
+
+
+/* DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) =
+** type *name##_new(void);
+** void name##_free(type *a);
+** DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) =
+** DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) =
+** type *d2i_##name(type **a, const unsigned char **in, long len);
+** int i2d_##name(type *a, unsigned char **out);
+** DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it
+*/
+
+DECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA)
+DECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME)
+DECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY)
+DECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY)
+DECLARE_ASN1_FUNCTIONS(KRB5_TICKET)
+DECLARE_ASN1_FUNCTIONS(KRB5_APREQ)
+
+DECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM)
+DECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY)
+DECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA)
+DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY)
+DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT)
+
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/kssl.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/kssl.h
new file mode 100644
index 000000000..a3d20e1cc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/kssl.h
@@ -0,0 +1,179 @@
+/* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */
+/* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project 2000.
+ * project 2000.
+ */
+/* ====================================================================
+ * Copyright (c) 2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+/*
+** 19990701 VRS Started.
+*/
+
+#ifndef KSSL_H
+#define KSSL_H
+
+#include <openssl/opensslconf.h>
+
+#ifndef OPENSSL_NO_KRB5
+
+#include <stdio.h>
+#include <ctype.h>
+#include <krb5.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Depending on which KRB5 implementation used, some types from
+** the other may be missing. Resolve that here and now
+*/
+#ifdef KRB5_HEIMDAL
+typedef unsigned char krb5_octet;
+#define FAR
+#else
+
+#ifndef FAR
+#define FAR
+#endif
+
+#endif
+
+/* Uncomment this to debug kssl problems or
+** to trace usage of the Kerberos session key
+**
+** #define KSSL_DEBUG
+*/
+
+#ifndef KRB5SVC
+#define KRB5SVC "host"
+#endif
+
+#ifndef KRB5KEYTAB
+#define KRB5KEYTAB "/etc/krb5.keytab"
+#endif
+
+#ifndef KRB5SENDAUTH
+#define KRB5SENDAUTH 1
+#endif
+
+#ifndef KRB5CHECKAUTH
+#define KRB5CHECKAUTH 1
+#endif
+
+#ifndef KSSL_CLOCKSKEW
+#define KSSL_CLOCKSKEW 300;
+#endif
+
+#define KSSL_ERR_MAX 255
+typedef struct kssl_err_st {
+ int reason;
+ char text[KSSL_ERR_MAX+1];
+ } KSSL_ERR;
+
+
+/* Context for passing
+** (1) Kerberos session key to SSL, and
+** (2) Config data between application and SSL lib
+*/
+typedef struct kssl_ctx_st
+ {
+ /* used by: disposition: */
+ char *service_name; /* C,S default ok (kssl) */
+ char *service_host; /* C input, REQUIRED */
+ char *client_princ; /* S output from krb5 ticket */
+ char *keytab_file; /* S NULL (/etc/krb5.keytab) */
+ char *cred_cache; /* C NULL (default) */
+ krb5_enctype enctype;
+ int length;
+ krb5_octet FAR *key;
+ } KSSL_CTX;
+
+#define KSSL_CLIENT 1
+#define KSSL_SERVER 2
+#define KSSL_SERVICE 3
+#define KSSL_KEYTAB 4
+
+#define KSSL_CTX_OK 0
+#define KSSL_CTX_ERR 1
+#define KSSL_NOMEM 2
+
+/* Public (for use by applications that use OpenSSL with Kerberos 5 support */
+krb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text);
+KSSL_CTX *kssl_ctx_new(void);
+KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx);
+void kssl_ctx_show(KSSL_CTX *kssl_ctx);
+krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,
+ krb5_data *realm, krb5_data *entity, int nentities);
+krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp,
+ krb5_data *authenp, KSSL_ERR *kssl_err);
+krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata,
+ krb5_ticket_times *ttimes, KSSL_ERR *kssl_err);
+krb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session);
+void kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text);
+void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data);
+krb5_error_code kssl_build_principal_2(krb5_context context,
+ krb5_principal *princ, int rlen, const char *realm,
+ int slen, const char *svc, int hlen, const char *host);
+krb5_error_code kssl_validate_times(krb5_timestamp atime,
+ krb5_ticket_times *ttimes);
+krb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp,
+ krb5_timestamp *atimep, KSSL_ERR *kssl_err);
+unsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* OPENSSL_NO_KRB5 */
+#endif /* KSSL_H */
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/lhash.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/lhash.h
new file mode 100644
index 000000000..d392d0cd8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/lhash.h
@@ -0,0 +1,200 @@
+/* crypto/lhash/lhash.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+/* Header for dynamic hash table routines
+ * Author - Eric Young
+ */
+
+#ifndef HEADER_LHASH_H
+#define HEADER_LHASH_H
+
+#include <openssl/e_os2.h>
+#ifndef OPENSSL_NO_FP_API
+#include <stdio.h>
+#endif
+
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct lhash_node_st
+ {
+ void *data;
+ struct lhash_node_st *next;
+#ifndef OPENSSL_NO_HASH_COMP
+ unsigned long hash;
+#endif
+ } LHASH_NODE;
+
+typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
+typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
+typedef void (*LHASH_DOALL_FN_TYPE)(void *);
+typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *);
+
+/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks.
+ * This way, callbacks can be provided to LHASH structures without function
+ * pointer casting and the macro-defined callbacks provide per-variable casting
+ * before deferring to the underlying type-specific callbacks. NB: It is
+ * possible to place a "static" in front of both the DECLARE and IMPLEMENT
+ * macros if the functions are strictly internal. */
+
+/* First: "hash" functions */
+#define DECLARE_LHASH_HASH_FN(f_name,o_type) \
+ unsigned long f_name##_LHASH_HASH(const void *);
+#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
+ unsigned long f_name##_LHASH_HASH(const void *arg) { \
+ o_type a = (o_type)arg; \
+ return f_name(a); }
+#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
+
+/* Second: "compare" functions */
+#define DECLARE_LHASH_COMP_FN(f_name,o_type) \
+ int f_name##_LHASH_COMP(const void *, const void *);
+#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
+ int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
+ o_type a = (o_type)arg1; \
+ o_type b = (o_type)arg2; \
+ return f_name(a,b); }
+#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP
+
+/* Third: "doall" functions */
+#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \
+ void f_name##_LHASH_DOALL(void *);
+#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \
+ void f_name##_LHASH_DOALL(void *arg) { \
+ o_type a = (o_type)arg; \
+ f_name(a); }
+#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL
+
+/* Fourth: "doall_arg" functions */
+#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
+ void f_name##_LHASH_DOALL_ARG(void *, void *);
+#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
+ void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
+ o_type a = (o_type)arg1; \
+ a_type b = (a_type)arg2; \
+ f_name(a,b); }
+#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG
+
+typedef struct lhash_st
+ {
+ LHASH_NODE **b;
+ LHASH_COMP_FN_TYPE comp;
+ LHASH_HASH_FN_TYPE hash;
+ unsigned int num_nodes;
+ unsigned int num_alloc_nodes;
+ unsigned int p;
+ unsigned int pmax;
+ unsigned long up_load; /* load times 256 */
+ unsigned long down_load; /* load times 256 */
+ unsigned long num_items;
+
+ unsigned long num_expands;
+ unsigned long num_expand_reallocs;
+ unsigned long num_contracts;
+ unsigned long num_contract_reallocs;
+ unsigned long num_hash_calls;
+ unsigned long num_comp_calls;
+ unsigned long num_insert;
+ unsigned long num_replace;
+ unsigned long num_delete;
+ unsigned long num_no_delete;
+ unsigned long num_retrieve;
+ unsigned long num_retrieve_miss;
+ unsigned long num_hash_comps;
+
+ int error;
+ } LHASH;
+
+#define LH_LOAD_MULT 256
+
+/* Indicates a malloc() error in the last call, this is only bad
+ * in lh_insert(). */
+#define lh_error(lh) ((lh)->error)
+
+LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
+void lh_free(LHASH *lh);
+void *lh_insert(LHASH *lh, void *data);
+void *lh_delete(LHASH *lh, const void *data);
+void *lh_retrieve(LHASH *lh, const void *data);
+void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func);
+void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
+unsigned long lh_strhash(const char *c);
+unsigned long lh_num_items(const LHASH *lh);
+
+#ifndef OPENSSL_NO_FP_API
+void lh_stats(const LHASH *lh, FILE *out);
+void lh_node_stats(const LHASH *lh, FILE *out);
+void lh_node_usage_stats(const LHASH *lh, FILE *out);
+#endif
+
+#ifndef OPENSSL_NO_BIO
+void lh_stats_bio(const LHASH *lh, BIO *out);
+void lh_node_stats_bio(const LHASH *lh, BIO *out);
+void lh_node_usage_stats_bio(const LHASH *lh, BIO *out);
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md2.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md2.h
new file mode 100644
index 000000000..d59c9f259
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md2.h
@@ -0,0 +1,95 @@
+/* crypto/md/md2.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_MD2_H
+#define HEADER_MD2_H
+
+#include <openssl/opensslconf.h> /* OPENSSL_NO_MD2, MD2_INT */
+#ifdef OPENSSL_NO_MD2
+#error MD2 is disabled.
+#endif
+#include <stddef.h>
+
+#define MD2_DIGEST_LENGTH 16
+#define MD2_BLOCK 16
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct MD2state_st
+ {
+ unsigned int num;
+ unsigned char data[MD2_BLOCK];
+ MD2_INT cksm[MD2_BLOCK];
+ MD2_INT state[MD2_BLOCK];
+ } MD2_CTX;
+
+const char *MD2_options(void);
+#ifdef OPENSSL_FIPS
+int private_MD2_Init(MD2_CTX *c);
+#endif
+int MD2_Init(MD2_CTX *c);
+int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len);
+int MD2_Final(unsigned char *md, MD2_CTX *c);
+unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md4.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md4.h
new file mode 100644
index 000000000..ba1fe4a6e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md4.h
@@ -0,0 +1,120 @@
+/* crypto/md4/md4.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_MD4_H
+#define HEADER_MD4_H
+
+#include <openssl/e_os2.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef OPENSSL_NO_MD4
+#error MD4 is disabled.
+#endif
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then !
+ * ! MD4_LONG_LOG2 has to be defined along. !
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ */
+
+#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
+#define MD4_LONG unsigned long
+#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
+#define MD4_LONG unsigned long
+#define MD4_LONG_LOG2 3
+/*
+ * _CRAY note. I could declare short, but I have no idea what impact
+ * does it have on performance on none-T3E machines. I could declare
+ * int, but at least on C90 sizeof(int) can be chosen at compile time.
+ * So I've chosen long...
+ * <appro@fy.chalmers.se>
+ */
+#else
+#define MD4_LONG unsigned int
+#endif
+
+#define MD4_CBLOCK 64
+#define MD4_LBLOCK (MD4_CBLOCK/4)
+#define MD4_DIGEST_LENGTH 16
+
+typedef struct MD4state_st
+ {
+ MD4_LONG A,B,C,D;
+ MD4_LONG Nl,Nh;
+ MD4_LONG data[MD4_LBLOCK];
+ unsigned int num;
+ } MD4_CTX;
+
+#ifdef OPENSSL_FIPS
+int private_MD4_Init(MD4_CTX *c);
+#endif
+int MD4_Init(MD4_CTX *c);
+int MD4_Update(MD4_CTX *c, const void *data, size_t len);
+int MD4_Final(unsigned char *md, MD4_CTX *c);
+unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md);
+void MD4_Transform(MD4_CTX *c, const unsigned char *b);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md5.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md5.h
new file mode 100644
index 000000000..0761f84a2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/md5.h
@@ -0,0 +1,120 @@
+/* crypto/md5/md5.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_MD5_H
+#define HEADER_MD5_H
+
+#include <openssl/e_os2.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef OPENSSL_NO_MD5
+#error MD5 is disabled.
+#endif
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !
+ * ! MD5_LONG_LOG2 has to be defined along. !
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ */
+
+#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
+#define MD5_LONG unsigned long
+#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
+#define MD5_LONG unsigned long
+#define MD5_LONG_LOG2 3
+/*
+ * _CRAY note. I could declare short, but I have no idea what impact
+ * does it have on performance on none-T3E machines. I could declare
+ * int, but at least on C90 sizeof(int) can be chosen at compile time.
+ * So I've chosen long...
+ * <appro@fy.chalmers.se>
+ */
+#else
+#define MD5_LONG unsigned int
+#endif
+
+#define MD5_CBLOCK 64
+#define MD5_LBLOCK (MD5_CBLOCK/4)
+#define MD5_DIGEST_LENGTH 16
+
+typedef struct MD5state_st
+ {
+ MD5_LONG A,B,C,D;
+ MD5_LONG Nl,Nh;
+ MD5_LONG data[MD5_LBLOCK];
+ unsigned int num;
+ } MD5_CTX;
+
+#ifdef OPENSSL_FIPS
+int private_MD5_Init(MD5_CTX *c);
+#endif
+int MD5_Init(MD5_CTX *c);
+int MD5_Update(MD5_CTX *c, const void *data, size_t len);
+int MD5_Final(unsigned char *md, MD5_CTX *c);
+unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
+void MD5_Transform(MD5_CTX *c, const unsigned char *b);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/obj_mac.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/obj_mac.h
new file mode 100644
index 000000000..ad5f7cfc1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/obj_mac.h
@@ -0,0 +1,3775 @@
+/* crypto/objects/obj_mac.h */
+
+/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the
+ * following command:
+ * perl objects.pl objects.txt obj_mac.num obj_mac.h
+ */
+
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#define SN_undef "UNDEF"
+#define LN_undef "undefined"
+#define NID_undef 0
+#define OBJ_undef 0L
+
+#define SN_itu_t "ITU-T"
+#define LN_itu_t "itu-t"
+#define NID_itu_t 645
+#define OBJ_itu_t 0L
+
+#define NID_ccitt 404
+#define OBJ_ccitt OBJ_itu_t
+
+#define SN_iso "ISO"
+#define LN_iso "iso"
+#define NID_iso 181
+#define OBJ_iso 1L
+
+#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T"
+#define LN_joint_iso_itu_t "joint-iso-itu-t"
+#define NID_joint_iso_itu_t 646
+#define OBJ_joint_iso_itu_t 2L
+
+#define NID_joint_iso_ccitt 393
+#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t
+
+#define SN_member_body "member-body"
+#define LN_member_body "ISO Member Body"
+#define NID_member_body 182
+#define OBJ_member_body OBJ_iso,2L
+
+#define SN_identified_organization "identified-organization"
+#define NID_identified_organization 676
+#define OBJ_identified_organization OBJ_iso,3L
+
+#define SN_hmac_md5 "HMAC-MD5"
+#define LN_hmac_md5 "hmac-md5"
+#define NID_hmac_md5 780
+#define OBJ_hmac_md5 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L
+
+#define SN_hmac_sha1 "HMAC-SHA1"
+#define LN_hmac_sha1 "hmac-sha1"
+#define NID_hmac_sha1 781
+#define OBJ_hmac_sha1 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L
+
+#define SN_certicom_arc "certicom-arc"
+#define NID_certicom_arc 677
+#define OBJ_certicom_arc OBJ_identified_organization,132L
+
+#define SN_international_organizations "international-organizations"
+#define LN_international_organizations "International Organizations"
+#define NID_international_organizations 647
+#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L
+
+#define SN_wap "wap"
+#define NID_wap 678
+#define OBJ_wap OBJ_international_organizations,43L
+
+#define SN_wap_wsg "wap-wsg"
+#define NID_wap_wsg 679
+#define OBJ_wap_wsg OBJ_wap,13L
+
+#define SN_selected_attribute_types "selected-attribute-types"
+#define LN_selected_attribute_types "Selected Attribute Types"
+#define NID_selected_attribute_types 394
+#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L
+
+#define SN_clearance "clearance"
+#define NID_clearance 395
+#define OBJ_clearance OBJ_selected_attribute_types,55L
+
+#define SN_ISO_US "ISO-US"
+#define LN_ISO_US "ISO US Member Body"
+#define NID_ISO_US 183
+#define OBJ_ISO_US OBJ_member_body,840L
+
+#define SN_X9_57 "X9-57"
+#define LN_X9_57 "X9.57"
+#define NID_X9_57 184
+#define OBJ_X9_57 OBJ_ISO_US,10040L
+
+#define SN_X9cm "X9cm"
+#define LN_X9cm "X9.57 CM ?"
+#define NID_X9cm 185
+#define OBJ_X9cm OBJ_X9_57,4L
+
+#define SN_dsa "DSA"
+#define LN_dsa "dsaEncryption"
+#define NID_dsa 116
+#define OBJ_dsa OBJ_X9cm,1L
+
+#define SN_dsaWithSHA1 "DSA-SHA1"
+#define LN_dsaWithSHA1 "dsaWithSHA1"
+#define NID_dsaWithSHA1 113
+#define OBJ_dsaWithSHA1 OBJ_X9cm,3L
+
+#define SN_ansi_X9_62 "ansi-X9-62"
+#define LN_ansi_X9_62 "ANSI X9.62"
+#define NID_ansi_X9_62 405
+#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L
+
+#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L
+
+#define SN_X9_62_prime_field "prime-field"
+#define NID_X9_62_prime_field 406
+#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L
+
+#define SN_X9_62_characteristic_two_field "characteristic-two-field"
+#define NID_X9_62_characteristic_two_field 407
+#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L
+
+#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis"
+#define NID_X9_62_id_characteristic_two_basis 680
+#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L
+
+#define SN_X9_62_onBasis "onBasis"
+#define NID_X9_62_onBasis 681
+#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L
+
+#define SN_X9_62_tpBasis "tpBasis"
+#define NID_X9_62_tpBasis 682
+#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L
+
+#define SN_X9_62_ppBasis "ppBasis"
+#define NID_X9_62_ppBasis 683
+#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L
+
+#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L
+
+#define SN_X9_62_id_ecPublicKey "id-ecPublicKey"
+#define NID_X9_62_id_ecPublicKey 408
+#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L
+
+#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L
+
+#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L
+
+#define SN_X9_62_c2pnb163v1 "c2pnb163v1"
+#define NID_X9_62_c2pnb163v1 684
+#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L
+
+#define SN_X9_62_c2pnb163v2 "c2pnb163v2"
+#define NID_X9_62_c2pnb163v2 685
+#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L
+
+#define SN_X9_62_c2pnb163v3 "c2pnb163v3"
+#define NID_X9_62_c2pnb163v3 686
+#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L
+
+#define SN_X9_62_c2pnb176v1 "c2pnb176v1"
+#define NID_X9_62_c2pnb176v1 687
+#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L
+
+#define SN_X9_62_c2tnb191v1 "c2tnb191v1"
+#define NID_X9_62_c2tnb191v1 688
+#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L
+
+#define SN_X9_62_c2tnb191v2 "c2tnb191v2"
+#define NID_X9_62_c2tnb191v2 689
+#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L
+
+#define SN_X9_62_c2tnb191v3 "c2tnb191v3"
+#define NID_X9_62_c2tnb191v3 690
+#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L
+
+#define SN_X9_62_c2onb191v4 "c2onb191v4"
+#define NID_X9_62_c2onb191v4 691
+#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L
+
+#define SN_X9_62_c2onb191v5 "c2onb191v5"
+#define NID_X9_62_c2onb191v5 692
+#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L
+
+#define SN_X9_62_c2pnb208w1 "c2pnb208w1"
+#define NID_X9_62_c2pnb208w1 693
+#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L
+
+#define SN_X9_62_c2tnb239v1 "c2tnb239v1"
+#define NID_X9_62_c2tnb239v1 694
+#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L
+
+#define SN_X9_62_c2tnb239v2 "c2tnb239v2"
+#define NID_X9_62_c2tnb239v2 695
+#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L
+
+#define SN_X9_62_c2tnb239v3 "c2tnb239v3"
+#define NID_X9_62_c2tnb239v3 696
+#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L
+
+#define SN_X9_62_c2onb239v4 "c2onb239v4"
+#define NID_X9_62_c2onb239v4 697
+#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L
+
+#define SN_X9_62_c2onb239v5 "c2onb239v5"
+#define NID_X9_62_c2onb239v5 698
+#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L
+
+#define SN_X9_62_c2pnb272w1 "c2pnb272w1"
+#define NID_X9_62_c2pnb272w1 699
+#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L
+
+#define SN_X9_62_c2pnb304w1 "c2pnb304w1"
+#define NID_X9_62_c2pnb304w1 700
+#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L
+
+#define SN_X9_62_c2tnb359v1 "c2tnb359v1"
+#define NID_X9_62_c2tnb359v1 701
+#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L
+
+#define SN_X9_62_c2pnb368w1 "c2pnb368w1"
+#define NID_X9_62_c2pnb368w1 702
+#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L
+
+#define SN_X9_62_c2tnb431r1 "c2tnb431r1"
+#define NID_X9_62_c2tnb431r1 703
+#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L
+
+#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L
+
+#define SN_X9_62_prime192v1 "prime192v1"
+#define NID_X9_62_prime192v1 409
+#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L
+
+#define SN_X9_62_prime192v2 "prime192v2"
+#define NID_X9_62_prime192v2 410
+#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L
+
+#define SN_X9_62_prime192v3 "prime192v3"
+#define NID_X9_62_prime192v3 411
+#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L
+
+#define SN_X9_62_prime239v1 "prime239v1"
+#define NID_X9_62_prime239v1 412
+#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L
+
+#define SN_X9_62_prime239v2 "prime239v2"
+#define NID_X9_62_prime239v2 413
+#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L
+
+#define SN_X9_62_prime239v3 "prime239v3"
+#define NID_X9_62_prime239v3 414
+#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L
+
+#define SN_X9_62_prime256v1 "prime256v1"
+#define NID_X9_62_prime256v1 415
+#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L
+
+#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L
+
+#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1"
+#define NID_ecdsa_with_SHA1 416
+#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L
+
+#define SN_ecdsa_with_Recommended "ecdsa-with-Recommended"
+#define NID_ecdsa_with_Recommended 791
+#define OBJ_ecdsa_with_Recommended OBJ_X9_62_id_ecSigType,2L
+
+#define SN_ecdsa_with_Specified "ecdsa-with-Specified"
+#define NID_ecdsa_with_Specified 792
+#define OBJ_ecdsa_with_Specified OBJ_X9_62_id_ecSigType,3L
+
+#define SN_ecdsa_with_SHA224 "ecdsa-with-SHA224"
+#define NID_ecdsa_with_SHA224 793
+#define OBJ_ecdsa_with_SHA224 OBJ_ecdsa_with_Specified,1L
+
+#define SN_ecdsa_with_SHA256 "ecdsa-with-SHA256"
+#define NID_ecdsa_with_SHA256 794
+#define OBJ_ecdsa_with_SHA256 OBJ_ecdsa_with_Specified,2L
+
+#define SN_ecdsa_with_SHA384 "ecdsa-with-SHA384"
+#define NID_ecdsa_with_SHA384 795
+#define OBJ_ecdsa_with_SHA384 OBJ_ecdsa_with_Specified,3L
+
+#define SN_ecdsa_with_SHA512 "ecdsa-with-SHA512"
+#define NID_ecdsa_with_SHA512 796
+#define OBJ_ecdsa_with_SHA512 OBJ_ecdsa_with_Specified,4L
+
+#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L
+
+#define SN_secp112r1 "secp112r1"
+#define NID_secp112r1 704
+#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L
+
+#define SN_secp112r2 "secp112r2"
+#define NID_secp112r2 705
+#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L
+
+#define SN_secp128r1 "secp128r1"
+#define NID_secp128r1 706
+#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L
+
+#define SN_secp128r2 "secp128r2"
+#define NID_secp128r2 707
+#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L
+
+#define SN_secp160k1 "secp160k1"
+#define NID_secp160k1 708
+#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L
+
+#define SN_secp160r1 "secp160r1"
+#define NID_secp160r1 709
+#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L
+
+#define SN_secp160r2 "secp160r2"
+#define NID_secp160r2 710
+#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L
+
+#define SN_secp192k1 "secp192k1"
+#define NID_secp192k1 711
+#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L
+
+#define SN_secp224k1 "secp224k1"
+#define NID_secp224k1 712
+#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L
+
+#define SN_secp224r1 "secp224r1"
+#define NID_secp224r1 713
+#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L
+
+#define SN_secp256k1 "secp256k1"
+#define NID_secp256k1 714
+#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L
+
+#define SN_secp384r1 "secp384r1"
+#define NID_secp384r1 715
+#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L
+
+#define SN_secp521r1 "secp521r1"
+#define NID_secp521r1 716
+#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L
+
+#define SN_sect113r1 "sect113r1"
+#define NID_sect113r1 717
+#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L
+
+#define SN_sect113r2 "sect113r2"
+#define NID_sect113r2 718
+#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L
+
+#define SN_sect131r1 "sect131r1"
+#define NID_sect131r1 719
+#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L
+
+#define SN_sect131r2 "sect131r2"
+#define NID_sect131r2 720
+#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L
+
+#define SN_sect163k1 "sect163k1"
+#define NID_sect163k1 721
+#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L
+
+#define SN_sect163r1 "sect163r1"
+#define NID_sect163r1 722
+#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L
+
+#define SN_sect163r2 "sect163r2"
+#define NID_sect163r2 723
+#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L
+
+#define SN_sect193r1 "sect193r1"
+#define NID_sect193r1 724
+#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L
+
+#define SN_sect193r2 "sect193r2"
+#define NID_sect193r2 725
+#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L
+
+#define SN_sect233k1 "sect233k1"
+#define NID_sect233k1 726
+#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L
+
+#define SN_sect233r1 "sect233r1"
+#define NID_sect233r1 727
+#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L
+
+#define SN_sect239k1 "sect239k1"
+#define NID_sect239k1 728
+#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L
+
+#define SN_sect283k1 "sect283k1"
+#define NID_sect283k1 729
+#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L
+
+#define SN_sect283r1 "sect283r1"
+#define NID_sect283r1 730
+#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L
+
+#define SN_sect409k1 "sect409k1"
+#define NID_sect409k1 731
+#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L
+
+#define SN_sect409r1 "sect409r1"
+#define NID_sect409r1 732
+#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L
+
+#define SN_sect571k1 "sect571k1"
+#define NID_sect571k1 733
+#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L
+
+#define SN_sect571r1 "sect571r1"
+#define NID_sect571r1 734
+#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L
+
+#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L
+
+#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1"
+#define NID_wap_wsg_idm_ecid_wtls1 735
+#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L
+
+#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3"
+#define NID_wap_wsg_idm_ecid_wtls3 736
+#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L
+
+#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4"
+#define NID_wap_wsg_idm_ecid_wtls4 737
+#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L
+
+#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5"
+#define NID_wap_wsg_idm_ecid_wtls5 738
+#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L
+
+#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6"
+#define NID_wap_wsg_idm_ecid_wtls6 739
+#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L
+
+#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7"
+#define NID_wap_wsg_idm_ecid_wtls7 740
+#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L
+
+#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8"
+#define NID_wap_wsg_idm_ecid_wtls8 741
+#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L
+
+#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9"
+#define NID_wap_wsg_idm_ecid_wtls9 742
+#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L
+
+#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10"
+#define NID_wap_wsg_idm_ecid_wtls10 743
+#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L
+
+#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11"
+#define NID_wap_wsg_idm_ecid_wtls11 744
+#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L
+
+#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12"
+#define NID_wap_wsg_idm_ecid_wtls12 745
+#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L
+
+#define SN_cast5_cbc "CAST5-CBC"
+#define LN_cast5_cbc "cast5-cbc"
+#define NID_cast5_cbc 108
+#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L
+
+#define SN_cast5_ecb "CAST5-ECB"
+#define LN_cast5_ecb "cast5-ecb"
+#define NID_cast5_ecb 109
+
+#define SN_cast5_cfb64 "CAST5-CFB"
+#define LN_cast5_cfb64 "cast5-cfb"
+#define NID_cast5_cfb64 110
+
+#define SN_cast5_ofb64 "CAST5-OFB"
+#define LN_cast5_ofb64 "cast5-ofb"
+#define NID_cast5_ofb64 111
+
+#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC"
+#define NID_pbeWithMD5AndCast5_CBC 112
+#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L
+
+#define SN_id_PasswordBasedMAC "id-PasswordBasedMAC"
+#define LN_id_PasswordBasedMAC "password based MAC"
+#define NID_id_PasswordBasedMAC 782
+#define OBJ_id_PasswordBasedMAC OBJ_ISO_US,113533L,7L,66L,13L
+
+#define SN_id_DHBasedMac "id-DHBasedMac"
+#define LN_id_DHBasedMac "Diffie-Hellman based MAC"
+#define NID_id_DHBasedMac 783
+#define OBJ_id_DHBasedMac OBJ_ISO_US,113533L,7L,66L,30L
+
+#define SN_rsadsi "rsadsi"
+#define LN_rsadsi "RSA Data Security, Inc."
+#define NID_rsadsi 1
+#define OBJ_rsadsi OBJ_ISO_US,113549L
+
+#define SN_pkcs "pkcs"
+#define LN_pkcs "RSA Data Security, Inc. PKCS"
+#define NID_pkcs 2
+#define OBJ_pkcs OBJ_rsadsi,1L
+
+#define SN_pkcs1 "pkcs1"
+#define NID_pkcs1 186
+#define OBJ_pkcs1 OBJ_pkcs,1L
+
+#define LN_rsaEncryption "rsaEncryption"
+#define NID_rsaEncryption 6
+#define OBJ_rsaEncryption OBJ_pkcs1,1L
+
+#define SN_md2WithRSAEncryption "RSA-MD2"
+#define LN_md2WithRSAEncryption "md2WithRSAEncryption"
+#define NID_md2WithRSAEncryption 7
+#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L
+
+#define SN_md4WithRSAEncryption "RSA-MD4"
+#define LN_md4WithRSAEncryption "md4WithRSAEncryption"
+#define NID_md4WithRSAEncryption 396
+#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L
+
+#define SN_md5WithRSAEncryption "RSA-MD5"
+#define LN_md5WithRSAEncryption "md5WithRSAEncryption"
+#define NID_md5WithRSAEncryption 8
+#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L
+
+#define SN_sha1WithRSAEncryption "RSA-SHA1"
+#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption"
+#define NID_sha1WithRSAEncryption 65
+#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L
+
+#define SN_sha256WithRSAEncryption "RSA-SHA256"
+#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption"
+#define NID_sha256WithRSAEncryption 668
+#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L
+
+#define SN_sha384WithRSAEncryption "RSA-SHA384"
+#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption"
+#define NID_sha384WithRSAEncryption 669
+#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L
+
+#define SN_sha512WithRSAEncryption "RSA-SHA512"
+#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption"
+#define NID_sha512WithRSAEncryption 670
+#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L
+
+#define SN_sha224WithRSAEncryption "RSA-SHA224"
+#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption"
+#define NID_sha224WithRSAEncryption 671
+#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L
+
+#define SN_pkcs3 "pkcs3"
+#define NID_pkcs3 27
+#define OBJ_pkcs3 OBJ_pkcs,3L
+
+#define LN_dhKeyAgreement "dhKeyAgreement"
+#define NID_dhKeyAgreement 28
+#define OBJ_dhKeyAgreement OBJ_pkcs3,1L
+
+#define SN_pkcs5 "pkcs5"
+#define NID_pkcs5 187
+#define OBJ_pkcs5 OBJ_pkcs,5L
+
+#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES"
+#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC"
+#define NID_pbeWithMD2AndDES_CBC 9
+#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L
+
+#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES"
+#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC"
+#define NID_pbeWithMD5AndDES_CBC 10
+#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L
+
+#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64"
+#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC"
+#define NID_pbeWithMD2AndRC2_CBC 168
+#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L
+
+#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64"
+#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC"
+#define NID_pbeWithMD5AndRC2_CBC 169
+#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L
+
+#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES"
+#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC"
+#define NID_pbeWithSHA1AndDES_CBC 170
+#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L
+
+#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64"
+#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC"
+#define NID_pbeWithSHA1AndRC2_CBC 68
+#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L
+
+#define LN_id_pbkdf2 "PBKDF2"
+#define NID_id_pbkdf2 69
+#define OBJ_id_pbkdf2 OBJ_pkcs5,12L
+
+#define LN_pbes2 "PBES2"
+#define NID_pbes2 161
+#define OBJ_pbes2 OBJ_pkcs5,13L
+
+#define LN_pbmac1 "PBMAC1"
+#define NID_pbmac1 162
+#define OBJ_pbmac1 OBJ_pkcs5,14L
+
+#define SN_pkcs7 "pkcs7"
+#define NID_pkcs7 20
+#define OBJ_pkcs7 OBJ_pkcs,7L
+
+#define LN_pkcs7_data "pkcs7-data"
+#define NID_pkcs7_data 21
+#define OBJ_pkcs7_data OBJ_pkcs7,1L
+
+#define LN_pkcs7_signed "pkcs7-signedData"
+#define NID_pkcs7_signed 22
+#define OBJ_pkcs7_signed OBJ_pkcs7,2L
+
+#define LN_pkcs7_enveloped "pkcs7-envelopedData"
+#define NID_pkcs7_enveloped 23
+#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L
+
+#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData"
+#define NID_pkcs7_signedAndEnveloped 24
+#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L
+
+#define LN_pkcs7_digest "pkcs7-digestData"
+#define NID_pkcs7_digest 25
+#define OBJ_pkcs7_digest OBJ_pkcs7,5L
+
+#define LN_pkcs7_encrypted "pkcs7-encryptedData"
+#define NID_pkcs7_encrypted 26
+#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L
+
+#define SN_pkcs9 "pkcs9"
+#define NID_pkcs9 47
+#define OBJ_pkcs9 OBJ_pkcs,9L
+
+#define LN_pkcs9_emailAddress "emailAddress"
+#define NID_pkcs9_emailAddress 48
+#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L
+
+#define LN_pkcs9_unstructuredName "unstructuredName"
+#define NID_pkcs9_unstructuredName 49
+#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L
+
+#define LN_pkcs9_contentType "contentType"
+#define NID_pkcs9_contentType 50
+#define OBJ_pkcs9_contentType OBJ_pkcs9,3L
+
+#define LN_pkcs9_messageDigest "messageDigest"
+#define NID_pkcs9_messageDigest 51
+#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L
+
+#define LN_pkcs9_signingTime "signingTime"
+#define NID_pkcs9_signingTime 52
+#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L
+
+#define LN_pkcs9_countersignature "countersignature"
+#define NID_pkcs9_countersignature 53
+#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L
+
+#define LN_pkcs9_challengePassword "challengePassword"
+#define NID_pkcs9_challengePassword 54
+#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L
+
+#define LN_pkcs9_unstructuredAddress "unstructuredAddress"
+#define NID_pkcs9_unstructuredAddress 55
+#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L
+
+#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes"
+#define NID_pkcs9_extCertAttributes 56
+#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L
+
+#define SN_ext_req "extReq"
+#define LN_ext_req "Extension Request"
+#define NID_ext_req 172
+#define OBJ_ext_req OBJ_pkcs9,14L
+
+#define SN_SMIMECapabilities "SMIME-CAPS"
+#define LN_SMIMECapabilities "S/MIME Capabilities"
+#define NID_SMIMECapabilities 167
+#define OBJ_SMIMECapabilities OBJ_pkcs9,15L
+
+#define SN_SMIME "SMIME"
+#define LN_SMIME "S/MIME"
+#define NID_SMIME 188
+#define OBJ_SMIME OBJ_pkcs9,16L
+
+#define SN_id_smime_mod "id-smime-mod"
+#define NID_id_smime_mod 189
+#define OBJ_id_smime_mod OBJ_SMIME,0L
+
+#define SN_id_smime_ct "id-smime-ct"
+#define NID_id_smime_ct 190
+#define OBJ_id_smime_ct OBJ_SMIME,1L
+
+#define SN_id_smime_aa "id-smime-aa"
+#define NID_id_smime_aa 191
+#define OBJ_id_smime_aa OBJ_SMIME,2L
+
+#define SN_id_smime_alg "id-smime-alg"
+#define NID_id_smime_alg 192
+#define OBJ_id_smime_alg OBJ_SMIME,3L
+
+#define SN_id_smime_cd "id-smime-cd"
+#define NID_id_smime_cd 193
+#define OBJ_id_smime_cd OBJ_SMIME,4L
+
+#define SN_id_smime_spq "id-smime-spq"
+#define NID_id_smime_spq 194
+#define OBJ_id_smime_spq OBJ_SMIME,5L
+
+#define SN_id_smime_cti "id-smime-cti"
+#define NID_id_smime_cti 195
+#define OBJ_id_smime_cti OBJ_SMIME,6L
+
+#define SN_id_smime_mod_cms "id-smime-mod-cms"
+#define NID_id_smime_mod_cms 196
+#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L
+
+#define SN_id_smime_mod_ess "id-smime-mod-ess"
+#define NID_id_smime_mod_ess 197
+#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L
+
+#define SN_id_smime_mod_oid "id-smime-mod-oid"
+#define NID_id_smime_mod_oid 198
+#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L
+
+#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3"
+#define NID_id_smime_mod_msg_v3 199
+#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L
+
+#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88"
+#define NID_id_smime_mod_ets_eSignature_88 200
+#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L
+
+#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97"
+#define NID_id_smime_mod_ets_eSignature_97 201
+#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L
+
+#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88"
+#define NID_id_smime_mod_ets_eSigPolicy_88 202
+#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L
+
+#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97"
+#define NID_id_smime_mod_ets_eSigPolicy_97 203
+#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L
+
+#define SN_id_smime_ct_receipt "id-smime-ct-receipt"
+#define NID_id_smime_ct_receipt 204
+#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L
+
+#define SN_id_smime_ct_authData "id-smime-ct-authData"
+#define NID_id_smime_ct_authData 205
+#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L
+
+#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert"
+#define NID_id_smime_ct_publishCert 206
+#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L
+
+#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo"
+#define NID_id_smime_ct_TSTInfo 207
+#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L
+
+#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo"
+#define NID_id_smime_ct_TDTInfo 208
+#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L
+
+#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo"
+#define NID_id_smime_ct_contentInfo 209
+#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L
+
+#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData"
+#define NID_id_smime_ct_DVCSRequestData 210
+#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L
+
+#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData"
+#define NID_id_smime_ct_DVCSResponseData 211
+#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L
+
+#define SN_id_smime_ct_compressedData "id-smime-ct-compressedData"
+#define NID_id_smime_ct_compressedData 786
+#define OBJ_id_smime_ct_compressedData OBJ_id_smime_ct,9L
+
+#define SN_id_ct_asciiTextWithCRLF "id-ct-asciiTextWithCRLF"
+#define NID_id_ct_asciiTextWithCRLF 787
+#define OBJ_id_ct_asciiTextWithCRLF OBJ_id_smime_ct,27L
+
+#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest"
+#define NID_id_smime_aa_receiptRequest 212
+#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L
+
+#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel"
+#define NID_id_smime_aa_securityLabel 213
+#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L
+
+#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory"
+#define NID_id_smime_aa_mlExpandHistory 214
+#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L
+
+#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint"
+#define NID_id_smime_aa_contentHint 215
+#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L
+
+#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest"
+#define NID_id_smime_aa_msgSigDigest 216
+#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L
+
+#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType"
+#define NID_id_smime_aa_encapContentType 217
+#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L
+
+#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier"
+#define NID_id_smime_aa_contentIdentifier 218
+#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L
+
+#define SN_id_smime_aa_macValue "id-smime-aa-macValue"
+#define NID_id_smime_aa_macValue 219
+#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L
+
+#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels"
+#define NID_id_smime_aa_equivalentLabels 220
+#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L
+
+#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference"
+#define NID_id_smime_aa_contentReference 221
+#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L
+
+#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref"
+#define NID_id_smime_aa_encrypKeyPref 222
+#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L
+
+#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate"
+#define NID_id_smime_aa_signingCertificate 223
+#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L
+
+#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts"
+#define NID_id_smime_aa_smimeEncryptCerts 224
+#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L
+
+#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken"
+#define NID_id_smime_aa_timeStampToken 225
+#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L
+
+#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId"
+#define NID_id_smime_aa_ets_sigPolicyId 226
+#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L
+
+#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType"
+#define NID_id_smime_aa_ets_commitmentType 227
+#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L
+
+#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation"
+#define NID_id_smime_aa_ets_signerLocation 228
+#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L
+
+#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr"
+#define NID_id_smime_aa_ets_signerAttr 229
+#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L
+
+#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert"
+#define NID_id_smime_aa_ets_otherSigCert 230
+#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L
+
+#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp"
+#define NID_id_smime_aa_ets_contentTimestamp 231
+#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L
+
+#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs"
+#define NID_id_smime_aa_ets_CertificateRefs 232
+#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L
+
+#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs"
+#define NID_id_smime_aa_ets_RevocationRefs 233
+#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L
+
+#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues"
+#define NID_id_smime_aa_ets_certValues 234
+#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L
+
+#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues"
+#define NID_id_smime_aa_ets_revocationValues 235
+#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L
+
+#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp"
+#define NID_id_smime_aa_ets_escTimeStamp 236
+#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L
+
+#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp"
+#define NID_id_smime_aa_ets_certCRLTimestamp 237
+#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L
+
+#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp"
+#define NID_id_smime_aa_ets_archiveTimeStamp 238
+#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L
+
+#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType"
+#define NID_id_smime_aa_signatureType 239
+#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L
+
+#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc"
+#define NID_id_smime_aa_dvcs_dvc 240
+#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L
+
+#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES"
+#define NID_id_smime_alg_ESDHwith3DES 241
+#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L
+
+#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2"
+#define NID_id_smime_alg_ESDHwithRC2 242
+#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L
+
+#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap"
+#define NID_id_smime_alg_3DESwrap 243
+#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L
+
+#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap"
+#define NID_id_smime_alg_RC2wrap 244
+#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L
+
+#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH"
+#define NID_id_smime_alg_ESDH 245
+#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L
+
+#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap"
+#define NID_id_smime_alg_CMS3DESwrap 246
+#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L
+
+#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap"
+#define NID_id_smime_alg_CMSRC2wrap 247
+#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L
+
+#define SN_id_smime_cd_ldap "id-smime-cd-ldap"
+#define NID_id_smime_cd_ldap 248
+#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L
+
+#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri"
+#define NID_id_smime_spq_ets_sqt_uri 249
+#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L
+
+#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice"
+#define NID_id_smime_spq_ets_sqt_unotice 250
+#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L
+
+#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin"
+#define NID_id_smime_cti_ets_proofOfOrigin 251
+#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L
+
+#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt"
+#define NID_id_smime_cti_ets_proofOfReceipt 252
+#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L
+
+#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery"
+#define NID_id_smime_cti_ets_proofOfDelivery 253
+#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L
+
+#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender"
+#define NID_id_smime_cti_ets_proofOfSender 254
+#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L
+
+#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval"
+#define NID_id_smime_cti_ets_proofOfApproval 255
+#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L
+
+#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation"
+#define NID_id_smime_cti_ets_proofOfCreation 256
+#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L
+
+#define LN_friendlyName "friendlyName"
+#define NID_friendlyName 156
+#define OBJ_friendlyName OBJ_pkcs9,20L
+
+#define LN_localKeyID "localKeyID"
+#define NID_localKeyID 157
+#define OBJ_localKeyID OBJ_pkcs9,21L
+
+#define SN_ms_csp_name "CSPName"
+#define LN_ms_csp_name "Microsoft CSP Name"
+#define NID_ms_csp_name 417
+#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L
+
+#define SN_LocalKeySet "LocalKeySet"
+#define LN_LocalKeySet "Microsoft Local Key set"
+#define NID_LocalKeySet 856
+#define OBJ_LocalKeySet 1L,3L,6L,1L,4L,1L,311L,17L,2L
+
+#define OBJ_certTypes OBJ_pkcs9,22L
+
+#define LN_x509Certificate "x509Certificate"
+#define NID_x509Certificate 158
+#define OBJ_x509Certificate OBJ_certTypes,1L
+
+#define LN_sdsiCertificate "sdsiCertificate"
+#define NID_sdsiCertificate 159
+#define OBJ_sdsiCertificate OBJ_certTypes,2L
+
+#define OBJ_crlTypes OBJ_pkcs9,23L
+
+#define LN_x509Crl "x509Crl"
+#define NID_x509Crl 160
+#define OBJ_x509Crl OBJ_crlTypes,1L
+
+#define OBJ_pkcs12 OBJ_pkcs,12L
+
+#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L
+
+#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128"
+#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4"
+#define NID_pbe_WithSHA1And128BitRC4 144
+#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L
+
+#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40"
+#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4"
+#define NID_pbe_WithSHA1And40BitRC4 145
+#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L
+
+#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES"
+#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC"
+#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146
+#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L
+
+#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES"
+#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC"
+#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147
+#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L
+
+#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128"
+#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC"
+#define NID_pbe_WithSHA1And128BitRC2_CBC 148
+#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L
+
+#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40"
+#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC"
+#define NID_pbe_WithSHA1And40BitRC2_CBC 149
+#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L
+
+#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L
+
+#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L
+
+#define LN_keyBag "keyBag"
+#define NID_keyBag 150
+#define OBJ_keyBag OBJ_pkcs12_BagIds,1L
+
+#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag"
+#define NID_pkcs8ShroudedKeyBag 151
+#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L
+
+#define LN_certBag "certBag"
+#define NID_certBag 152
+#define OBJ_certBag OBJ_pkcs12_BagIds,3L
+
+#define LN_crlBag "crlBag"
+#define NID_crlBag 153
+#define OBJ_crlBag OBJ_pkcs12_BagIds,4L
+
+#define LN_secretBag "secretBag"
+#define NID_secretBag 154
+#define OBJ_secretBag OBJ_pkcs12_BagIds,5L
+
+#define LN_safeContentsBag "safeContentsBag"
+#define NID_safeContentsBag 155
+#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L
+
+#define SN_md2 "MD2"
+#define LN_md2 "md2"
+#define NID_md2 3
+#define OBJ_md2 OBJ_rsadsi,2L,2L
+
+#define SN_md4 "MD4"
+#define LN_md4 "md4"
+#define NID_md4 257
+#define OBJ_md4 OBJ_rsadsi,2L,4L
+
+#define SN_md5 "MD5"
+#define LN_md5 "md5"
+#define NID_md5 4
+#define OBJ_md5 OBJ_rsadsi,2L,5L
+
+#define SN_md5_sha1 "MD5-SHA1"
+#define LN_md5_sha1 "md5-sha1"
+#define NID_md5_sha1 114
+
+#define LN_hmacWithMD5 "hmacWithMD5"
+#define NID_hmacWithMD5 797
+#define OBJ_hmacWithMD5 OBJ_rsadsi,2L,6L
+
+#define LN_hmacWithSHA1 "hmacWithSHA1"
+#define NID_hmacWithSHA1 163
+#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L
+
+#define LN_hmacWithSHA224 "hmacWithSHA224"
+#define NID_hmacWithSHA224 798
+#define OBJ_hmacWithSHA224 OBJ_rsadsi,2L,8L
+
+#define LN_hmacWithSHA256 "hmacWithSHA256"
+#define NID_hmacWithSHA256 799
+#define OBJ_hmacWithSHA256 OBJ_rsadsi,2L,9L
+
+#define LN_hmacWithSHA384 "hmacWithSHA384"
+#define NID_hmacWithSHA384 800
+#define OBJ_hmacWithSHA384 OBJ_rsadsi,2L,10L
+
+#define LN_hmacWithSHA512 "hmacWithSHA512"
+#define NID_hmacWithSHA512 801
+#define OBJ_hmacWithSHA512 OBJ_rsadsi,2L,11L
+
+#define SN_rc2_cbc "RC2-CBC"
+#define LN_rc2_cbc "rc2-cbc"
+#define NID_rc2_cbc 37
+#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L
+
+#define SN_rc2_ecb "RC2-ECB"
+#define LN_rc2_ecb "rc2-ecb"
+#define NID_rc2_ecb 38
+
+#define SN_rc2_cfb64 "RC2-CFB"
+#define LN_rc2_cfb64 "rc2-cfb"
+#define NID_rc2_cfb64 39
+
+#define SN_rc2_ofb64 "RC2-OFB"
+#define LN_rc2_ofb64 "rc2-ofb"
+#define NID_rc2_ofb64 40
+
+#define SN_rc2_40_cbc "RC2-40-CBC"
+#define LN_rc2_40_cbc "rc2-40-cbc"
+#define NID_rc2_40_cbc 98
+
+#define SN_rc2_64_cbc "RC2-64-CBC"
+#define LN_rc2_64_cbc "rc2-64-cbc"
+#define NID_rc2_64_cbc 166
+
+#define SN_rc4 "RC4"
+#define LN_rc4 "rc4"
+#define NID_rc4 5
+#define OBJ_rc4 OBJ_rsadsi,3L,4L
+
+#define SN_rc4_40 "RC4-40"
+#define LN_rc4_40 "rc4-40"
+#define NID_rc4_40 97
+
+#define SN_des_ede3_cbc "DES-EDE3-CBC"
+#define LN_des_ede3_cbc "des-ede3-cbc"
+#define NID_des_ede3_cbc 44
+#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L
+
+#define SN_rc5_cbc "RC5-CBC"
+#define LN_rc5_cbc "rc5-cbc"
+#define NID_rc5_cbc 120
+#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L
+
+#define SN_rc5_ecb "RC5-ECB"
+#define LN_rc5_ecb "rc5-ecb"
+#define NID_rc5_ecb 121
+
+#define SN_rc5_cfb64 "RC5-CFB"
+#define LN_rc5_cfb64 "rc5-cfb"
+#define NID_rc5_cfb64 122
+
+#define SN_rc5_ofb64 "RC5-OFB"
+#define LN_rc5_ofb64 "rc5-ofb"
+#define NID_rc5_ofb64 123
+
+#define SN_ms_ext_req "msExtReq"
+#define LN_ms_ext_req "Microsoft Extension Request"
+#define NID_ms_ext_req 171
+#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L
+
+#define SN_ms_code_ind "msCodeInd"
+#define LN_ms_code_ind "Microsoft Individual Code Signing"
+#define NID_ms_code_ind 134
+#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L
+
+#define SN_ms_code_com "msCodeCom"
+#define LN_ms_code_com "Microsoft Commercial Code Signing"
+#define NID_ms_code_com 135
+#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L
+
+#define SN_ms_ctl_sign "msCTLSign"
+#define LN_ms_ctl_sign "Microsoft Trust List Signing"
+#define NID_ms_ctl_sign 136
+#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L
+
+#define SN_ms_sgc "msSGC"
+#define LN_ms_sgc "Microsoft Server Gated Crypto"
+#define NID_ms_sgc 137
+#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L
+
+#define SN_ms_efs "msEFS"
+#define LN_ms_efs "Microsoft Encrypted File System"
+#define NID_ms_efs 138
+#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L
+
+#define SN_ms_smartcard_login "msSmartcardLogin"
+#define LN_ms_smartcard_login "Microsoft Smartcardlogin"
+#define NID_ms_smartcard_login 648
+#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L
+
+#define SN_ms_upn "msUPN"
+#define LN_ms_upn "Microsoft Universal Principal Name"
+#define NID_ms_upn 649
+#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L
+
+#define SN_idea_cbc "IDEA-CBC"
+#define LN_idea_cbc "idea-cbc"
+#define NID_idea_cbc 34
+#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L
+
+#define SN_idea_ecb "IDEA-ECB"
+#define LN_idea_ecb "idea-ecb"
+#define NID_idea_ecb 36
+
+#define SN_idea_cfb64 "IDEA-CFB"
+#define LN_idea_cfb64 "idea-cfb"
+#define NID_idea_cfb64 35
+
+#define SN_idea_ofb64 "IDEA-OFB"
+#define LN_idea_ofb64 "idea-ofb"
+#define NID_idea_ofb64 46
+
+#define SN_bf_cbc "BF-CBC"
+#define LN_bf_cbc "bf-cbc"
+#define NID_bf_cbc 91
+#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L
+
+#define SN_bf_ecb "BF-ECB"
+#define LN_bf_ecb "bf-ecb"
+#define NID_bf_ecb 92
+
+#define SN_bf_cfb64 "BF-CFB"
+#define LN_bf_cfb64 "bf-cfb"
+#define NID_bf_cfb64 93
+
+#define SN_bf_ofb64 "BF-OFB"
+#define LN_bf_ofb64 "bf-ofb"
+#define NID_bf_ofb64 94
+
+#define SN_id_pkix "PKIX"
+#define NID_id_pkix 127
+#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L
+
+#define SN_id_pkix_mod "id-pkix-mod"
+#define NID_id_pkix_mod 258
+#define OBJ_id_pkix_mod OBJ_id_pkix,0L
+
+#define SN_id_pe "id-pe"
+#define NID_id_pe 175
+#define OBJ_id_pe OBJ_id_pkix,1L
+
+#define SN_id_qt "id-qt"
+#define NID_id_qt 259
+#define OBJ_id_qt OBJ_id_pkix,2L
+
+#define SN_id_kp "id-kp"
+#define NID_id_kp 128
+#define OBJ_id_kp OBJ_id_pkix,3L
+
+#define SN_id_it "id-it"
+#define NID_id_it 260
+#define OBJ_id_it OBJ_id_pkix,4L
+
+#define SN_id_pkip "id-pkip"
+#define NID_id_pkip 261
+#define OBJ_id_pkip OBJ_id_pkix,5L
+
+#define SN_id_alg "id-alg"
+#define NID_id_alg 262
+#define OBJ_id_alg OBJ_id_pkix,6L
+
+#define SN_id_cmc "id-cmc"
+#define NID_id_cmc 263
+#define OBJ_id_cmc OBJ_id_pkix,7L
+
+#define SN_id_on "id-on"
+#define NID_id_on 264
+#define OBJ_id_on OBJ_id_pkix,8L
+
+#define SN_id_pda "id-pda"
+#define NID_id_pda 265
+#define OBJ_id_pda OBJ_id_pkix,9L
+
+#define SN_id_aca "id-aca"
+#define NID_id_aca 266
+#define OBJ_id_aca OBJ_id_pkix,10L
+
+#define SN_id_qcs "id-qcs"
+#define NID_id_qcs 267
+#define OBJ_id_qcs OBJ_id_pkix,11L
+
+#define SN_id_cct "id-cct"
+#define NID_id_cct 268
+#define OBJ_id_cct OBJ_id_pkix,12L
+
+#define SN_id_ppl "id-ppl"
+#define NID_id_ppl 662
+#define OBJ_id_ppl OBJ_id_pkix,21L
+
+#define SN_id_ad "id-ad"
+#define NID_id_ad 176
+#define OBJ_id_ad OBJ_id_pkix,48L
+
+#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88"
+#define NID_id_pkix1_explicit_88 269
+#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L
+
+#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88"
+#define NID_id_pkix1_implicit_88 270
+#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L
+
+#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93"
+#define NID_id_pkix1_explicit_93 271
+#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L
+
+#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93"
+#define NID_id_pkix1_implicit_93 272
+#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L
+
+#define SN_id_mod_crmf "id-mod-crmf"
+#define NID_id_mod_crmf 273
+#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L
+
+#define SN_id_mod_cmc "id-mod-cmc"
+#define NID_id_mod_cmc 274
+#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L
+
+#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88"
+#define NID_id_mod_kea_profile_88 275
+#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L
+
+#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93"
+#define NID_id_mod_kea_profile_93 276
+#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L
+
+#define SN_id_mod_cmp "id-mod-cmp"
+#define NID_id_mod_cmp 277
+#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L
+
+#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88"
+#define NID_id_mod_qualified_cert_88 278
+#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L
+
+#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93"
+#define NID_id_mod_qualified_cert_93 279
+#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L
+
+#define SN_id_mod_attribute_cert "id-mod-attribute-cert"
+#define NID_id_mod_attribute_cert 280
+#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L
+
+#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol"
+#define NID_id_mod_timestamp_protocol 281
+#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L
+
+#define SN_id_mod_ocsp "id-mod-ocsp"
+#define NID_id_mod_ocsp 282
+#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L
+
+#define SN_id_mod_dvcs "id-mod-dvcs"
+#define NID_id_mod_dvcs 283
+#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L
+
+#define SN_id_mod_cmp2000 "id-mod-cmp2000"
+#define NID_id_mod_cmp2000 284
+#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L
+
+#define SN_info_access "authorityInfoAccess"
+#define LN_info_access "Authority Information Access"
+#define NID_info_access 177
+#define OBJ_info_access OBJ_id_pe,1L
+
+#define SN_biometricInfo "biometricInfo"
+#define LN_biometricInfo "Biometric Info"
+#define NID_biometricInfo 285
+#define OBJ_biometricInfo OBJ_id_pe,2L
+
+#define SN_qcStatements "qcStatements"
+#define NID_qcStatements 286
+#define OBJ_qcStatements OBJ_id_pe,3L
+
+#define SN_ac_auditEntity "ac-auditEntity"
+#define NID_ac_auditEntity 287
+#define OBJ_ac_auditEntity OBJ_id_pe,4L
+
+#define SN_ac_targeting "ac-targeting"
+#define NID_ac_targeting 288
+#define OBJ_ac_targeting OBJ_id_pe,5L
+
+#define SN_aaControls "aaControls"
+#define NID_aaControls 289
+#define OBJ_aaControls OBJ_id_pe,6L
+
+#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock"
+#define NID_sbgp_ipAddrBlock 290
+#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L
+
+#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum"
+#define NID_sbgp_autonomousSysNum 291
+#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L
+
+#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier"
+#define NID_sbgp_routerIdentifier 292
+#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L
+
+#define SN_ac_proxying "ac-proxying"
+#define NID_ac_proxying 397
+#define OBJ_ac_proxying OBJ_id_pe,10L
+
+#define SN_sinfo_access "subjectInfoAccess"
+#define LN_sinfo_access "Subject Information Access"
+#define NID_sinfo_access 398
+#define OBJ_sinfo_access OBJ_id_pe,11L
+
+#define SN_proxyCertInfo "proxyCertInfo"
+#define LN_proxyCertInfo "Proxy Certificate Information"
+#define NID_proxyCertInfo 663
+#define OBJ_proxyCertInfo OBJ_id_pe,14L
+
+#define SN_id_qt_cps "id-qt-cps"
+#define LN_id_qt_cps "Policy Qualifier CPS"
+#define NID_id_qt_cps 164
+#define OBJ_id_qt_cps OBJ_id_qt,1L
+
+#define SN_id_qt_unotice "id-qt-unotice"
+#define LN_id_qt_unotice "Policy Qualifier User Notice"
+#define NID_id_qt_unotice 165
+#define OBJ_id_qt_unotice OBJ_id_qt,2L
+
+#define SN_textNotice "textNotice"
+#define NID_textNotice 293
+#define OBJ_textNotice OBJ_id_qt,3L
+
+#define SN_server_auth "serverAuth"
+#define LN_server_auth "TLS Web Server Authentication"
+#define NID_server_auth 129
+#define OBJ_server_auth OBJ_id_kp,1L
+
+#define SN_client_auth "clientAuth"
+#define LN_client_auth "TLS Web Client Authentication"
+#define NID_client_auth 130
+#define OBJ_client_auth OBJ_id_kp,2L
+
+#define SN_code_sign "codeSigning"
+#define LN_code_sign "Code Signing"
+#define NID_code_sign 131
+#define OBJ_code_sign OBJ_id_kp,3L
+
+#define SN_email_protect "emailProtection"
+#define LN_email_protect "E-mail Protection"
+#define NID_email_protect 132
+#define OBJ_email_protect OBJ_id_kp,4L
+
+#define SN_ipsecEndSystem "ipsecEndSystem"
+#define LN_ipsecEndSystem "IPSec End System"
+#define NID_ipsecEndSystem 294
+#define OBJ_ipsecEndSystem OBJ_id_kp,5L
+
+#define SN_ipsecTunnel "ipsecTunnel"
+#define LN_ipsecTunnel "IPSec Tunnel"
+#define NID_ipsecTunnel 295
+#define OBJ_ipsecTunnel OBJ_id_kp,6L
+
+#define SN_ipsecUser "ipsecUser"
+#define LN_ipsecUser "IPSec User"
+#define NID_ipsecUser 296
+#define OBJ_ipsecUser OBJ_id_kp,7L
+
+#define SN_time_stamp "timeStamping"
+#define LN_time_stamp "Time Stamping"
+#define NID_time_stamp 133
+#define OBJ_time_stamp OBJ_id_kp,8L
+
+#define SN_OCSP_sign "OCSPSigning"
+#define LN_OCSP_sign "OCSP Signing"
+#define NID_OCSP_sign 180
+#define OBJ_OCSP_sign OBJ_id_kp,9L
+
+#define SN_dvcs "DVCS"
+#define LN_dvcs "dvcs"
+#define NID_dvcs 297
+#define OBJ_dvcs OBJ_id_kp,10L
+
+#define SN_id_it_caProtEncCert "id-it-caProtEncCert"
+#define NID_id_it_caProtEncCert 298
+#define OBJ_id_it_caProtEncCert OBJ_id_it,1L
+
+#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes"
+#define NID_id_it_signKeyPairTypes 299
+#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L
+
+#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes"
+#define NID_id_it_encKeyPairTypes 300
+#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L
+
+#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg"
+#define NID_id_it_preferredSymmAlg 301
+#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L
+
+#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo"
+#define NID_id_it_caKeyUpdateInfo 302
+#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L
+
+#define SN_id_it_currentCRL "id-it-currentCRL"
+#define NID_id_it_currentCRL 303
+#define OBJ_id_it_currentCRL OBJ_id_it,6L
+
+#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs"
+#define NID_id_it_unsupportedOIDs 304
+#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L
+
+#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest"
+#define NID_id_it_subscriptionRequest 305
+#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L
+
+#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse"
+#define NID_id_it_subscriptionResponse 306
+#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L
+
+#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq"
+#define NID_id_it_keyPairParamReq 307
+#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L
+
+#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep"
+#define NID_id_it_keyPairParamRep 308
+#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L
+
+#define SN_id_it_revPassphrase "id-it-revPassphrase"
+#define NID_id_it_revPassphrase 309
+#define OBJ_id_it_revPassphrase OBJ_id_it,12L
+
+#define SN_id_it_implicitConfirm "id-it-implicitConfirm"
+#define NID_id_it_implicitConfirm 310
+#define OBJ_id_it_implicitConfirm OBJ_id_it,13L
+
+#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime"
+#define NID_id_it_confirmWaitTime 311
+#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L
+
+#define SN_id_it_origPKIMessage "id-it-origPKIMessage"
+#define NID_id_it_origPKIMessage 312
+#define OBJ_id_it_origPKIMessage OBJ_id_it,15L
+
+#define SN_id_it_suppLangTags "id-it-suppLangTags"
+#define NID_id_it_suppLangTags 784
+#define OBJ_id_it_suppLangTags OBJ_id_it,16L
+
+#define SN_id_regCtrl "id-regCtrl"
+#define NID_id_regCtrl 313
+#define OBJ_id_regCtrl OBJ_id_pkip,1L
+
+#define SN_id_regInfo "id-regInfo"
+#define NID_id_regInfo 314
+#define OBJ_id_regInfo OBJ_id_pkip,2L
+
+#define SN_id_regCtrl_regToken "id-regCtrl-regToken"
+#define NID_id_regCtrl_regToken 315
+#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L
+
+#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator"
+#define NID_id_regCtrl_authenticator 316
+#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L
+
+#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo"
+#define NID_id_regCtrl_pkiPublicationInfo 317
+#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L
+
+#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions"
+#define NID_id_regCtrl_pkiArchiveOptions 318
+#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L
+
+#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID"
+#define NID_id_regCtrl_oldCertID 319
+#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L
+
+#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey"
+#define NID_id_regCtrl_protocolEncrKey 320
+#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L
+
+#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs"
+#define NID_id_regInfo_utf8Pairs 321
+#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L
+
+#define SN_id_regInfo_certReq "id-regInfo-certReq"
+#define NID_id_regInfo_certReq 322
+#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L
+
+#define SN_id_alg_des40 "id-alg-des40"
+#define NID_id_alg_des40 323
+#define OBJ_id_alg_des40 OBJ_id_alg,1L
+
+#define SN_id_alg_noSignature "id-alg-noSignature"
+#define NID_id_alg_noSignature 324
+#define OBJ_id_alg_noSignature OBJ_id_alg,2L
+
+#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1"
+#define NID_id_alg_dh_sig_hmac_sha1 325
+#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L
+
+#define SN_id_alg_dh_pop "id-alg-dh-pop"
+#define NID_id_alg_dh_pop 326
+#define OBJ_id_alg_dh_pop OBJ_id_alg,4L
+
+#define SN_id_cmc_statusInfo "id-cmc-statusInfo"
+#define NID_id_cmc_statusInfo 327
+#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L
+
+#define SN_id_cmc_identification "id-cmc-identification"
+#define NID_id_cmc_identification 328
+#define OBJ_id_cmc_identification OBJ_id_cmc,2L
+
+#define SN_id_cmc_identityProof "id-cmc-identityProof"
+#define NID_id_cmc_identityProof 329
+#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L
+
+#define SN_id_cmc_dataReturn "id-cmc-dataReturn"
+#define NID_id_cmc_dataReturn 330
+#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L
+
+#define SN_id_cmc_transactionId "id-cmc-transactionId"
+#define NID_id_cmc_transactionId 331
+#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L
+
+#define SN_id_cmc_senderNonce "id-cmc-senderNonce"
+#define NID_id_cmc_senderNonce 332
+#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L
+
+#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce"
+#define NID_id_cmc_recipientNonce 333
+#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L
+
+#define SN_id_cmc_addExtensions "id-cmc-addExtensions"
+#define NID_id_cmc_addExtensions 334
+#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L
+
+#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP"
+#define NID_id_cmc_encryptedPOP 335
+#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L
+
+#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP"
+#define NID_id_cmc_decryptedPOP 336
+#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L
+
+#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness"
+#define NID_id_cmc_lraPOPWitness 337
+#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L
+
+#define SN_id_cmc_getCert "id-cmc-getCert"
+#define NID_id_cmc_getCert 338
+#define OBJ_id_cmc_getCert OBJ_id_cmc,15L
+
+#define SN_id_cmc_getCRL "id-cmc-getCRL"
+#define NID_id_cmc_getCRL 339
+#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L
+
+#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest"
+#define NID_id_cmc_revokeRequest 340
+#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L
+
+#define SN_id_cmc_regInfo "id-cmc-regInfo"
+#define NID_id_cmc_regInfo 341
+#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L
+
+#define SN_id_cmc_responseInfo "id-cmc-responseInfo"
+#define NID_id_cmc_responseInfo 342
+#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L
+
+#define SN_id_cmc_queryPending "id-cmc-queryPending"
+#define NID_id_cmc_queryPending 343
+#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L
+
+#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom"
+#define NID_id_cmc_popLinkRandom 344
+#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L
+
+#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness"
+#define NID_id_cmc_popLinkWitness 345
+#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L
+
+#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance"
+#define NID_id_cmc_confirmCertAcceptance 346
+#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L
+
+#define SN_id_on_personalData "id-on-personalData"
+#define NID_id_on_personalData 347
+#define OBJ_id_on_personalData OBJ_id_on,1L
+
+#define SN_id_on_permanentIdentifier "id-on-permanentIdentifier"
+#define LN_id_on_permanentIdentifier "Permanent Identifier"
+#define NID_id_on_permanentIdentifier 858
+#define OBJ_id_on_permanentIdentifier OBJ_id_on,3L
+
+#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth"
+#define NID_id_pda_dateOfBirth 348
+#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L
+
+#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth"
+#define NID_id_pda_placeOfBirth 349
+#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L
+
+#define SN_id_pda_gender "id-pda-gender"
+#define NID_id_pda_gender 351
+#define OBJ_id_pda_gender OBJ_id_pda,3L
+
+#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship"
+#define NID_id_pda_countryOfCitizenship 352
+#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L
+
+#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence"
+#define NID_id_pda_countryOfResidence 353
+#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L
+
+#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo"
+#define NID_id_aca_authenticationInfo 354
+#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L
+
+#define SN_id_aca_accessIdentity "id-aca-accessIdentity"
+#define NID_id_aca_accessIdentity 355
+#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L
+
+#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity"
+#define NID_id_aca_chargingIdentity 356
+#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L
+
+#define SN_id_aca_group "id-aca-group"
+#define NID_id_aca_group 357
+#define OBJ_id_aca_group OBJ_id_aca,4L
+
+#define SN_id_aca_role "id-aca-role"
+#define NID_id_aca_role 358
+#define OBJ_id_aca_role OBJ_id_aca,5L
+
+#define SN_id_aca_encAttrs "id-aca-encAttrs"
+#define NID_id_aca_encAttrs 399
+#define OBJ_id_aca_encAttrs OBJ_id_aca,6L
+
+#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1"
+#define NID_id_qcs_pkixQCSyntax_v1 359
+#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L
+
+#define SN_id_cct_crs "id-cct-crs"
+#define NID_id_cct_crs 360
+#define OBJ_id_cct_crs OBJ_id_cct,1L
+
+#define SN_id_cct_PKIData "id-cct-PKIData"
+#define NID_id_cct_PKIData 361
+#define OBJ_id_cct_PKIData OBJ_id_cct,2L
+
+#define SN_id_cct_PKIResponse "id-cct-PKIResponse"
+#define NID_id_cct_PKIResponse 362
+#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L
+
+#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage"
+#define LN_id_ppl_anyLanguage "Any language"
+#define NID_id_ppl_anyLanguage 664
+#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L
+
+#define SN_id_ppl_inheritAll "id-ppl-inheritAll"
+#define LN_id_ppl_inheritAll "Inherit all"
+#define NID_id_ppl_inheritAll 665
+#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L
+
+#define SN_Independent "id-ppl-independent"
+#define LN_Independent "Independent"
+#define NID_Independent 667
+#define OBJ_Independent OBJ_id_ppl,2L
+
+#define SN_ad_OCSP "OCSP"
+#define LN_ad_OCSP "OCSP"
+#define NID_ad_OCSP 178
+#define OBJ_ad_OCSP OBJ_id_ad,1L
+
+#define SN_ad_ca_issuers "caIssuers"
+#define LN_ad_ca_issuers "CA Issuers"
+#define NID_ad_ca_issuers 179
+#define OBJ_ad_ca_issuers OBJ_id_ad,2L
+
+#define SN_ad_timeStamping "ad_timestamping"
+#define LN_ad_timeStamping "AD Time Stamping"
+#define NID_ad_timeStamping 363
+#define OBJ_ad_timeStamping OBJ_id_ad,3L
+
+#define SN_ad_dvcs "AD_DVCS"
+#define LN_ad_dvcs "ad dvcs"
+#define NID_ad_dvcs 364
+#define OBJ_ad_dvcs OBJ_id_ad,4L
+
+#define SN_caRepository "caRepository"
+#define LN_caRepository "CA Repository"
+#define NID_caRepository 785
+#define OBJ_caRepository OBJ_id_ad,5L
+
+#define OBJ_id_pkix_OCSP OBJ_ad_OCSP
+
+#define SN_id_pkix_OCSP_basic "basicOCSPResponse"
+#define LN_id_pkix_OCSP_basic "Basic OCSP Response"
+#define NID_id_pkix_OCSP_basic 365
+#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L
+
+#define SN_id_pkix_OCSP_Nonce "Nonce"
+#define LN_id_pkix_OCSP_Nonce "OCSP Nonce"
+#define NID_id_pkix_OCSP_Nonce 366
+#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L
+
+#define SN_id_pkix_OCSP_CrlID "CrlID"
+#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID"
+#define NID_id_pkix_OCSP_CrlID 367
+#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L
+
+#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses"
+#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses"
+#define NID_id_pkix_OCSP_acceptableResponses 368
+#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L
+
+#define SN_id_pkix_OCSP_noCheck "noCheck"
+#define LN_id_pkix_OCSP_noCheck "OCSP No Check"
+#define NID_id_pkix_OCSP_noCheck 369
+#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L
+
+#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff"
+#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff"
+#define NID_id_pkix_OCSP_archiveCutoff 370
+#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L
+
+#define SN_id_pkix_OCSP_serviceLocator "serviceLocator"
+#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator"
+#define NID_id_pkix_OCSP_serviceLocator 371
+#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L
+
+#define SN_id_pkix_OCSP_extendedStatus "extendedStatus"
+#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status"
+#define NID_id_pkix_OCSP_extendedStatus 372
+#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L
+
+#define SN_id_pkix_OCSP_valid "valid"
+#define NID_id_pkix_OCSP_valid 373
+#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L
+
+#define SN_id_pkix_OCSP_path "path"
+#define NID_id_pkix_OCSP_path 374
+#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L
+
+#define SN_id_pkix_OCSP_trustRoot "trustRoot"
+#define LN_id_pkix_OCSP_trustRoot "Trust Root"
+#define NID_id_pkix_OCSP_trustRoot 375
+#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L
+
+#define SN_algorithm "algorithm"
+#define LN_algorithm "algorithm"
+#define NID_algorithm 376
+#define OBJ_algorithm 1L,3L,14L,3L,2L
+
+#define SN_md5WithRSA "RSA-NP-MD5"
+#define LN_md5WithRSA "md5WithRSA"
+#define NID_md5WithRSA 104
+#define OBJ_md5WithRSA OBJ_algorithm,3L
+
+#define SN_des_ecb "DES-ECB"
+#define LN_des_ecb "des-ecb"
+#define NID_des_ecb 29
+#define OBJ_des_ecb OBJ_algorithm,6L
+
+#define SN_des_cbc "DES-CBC"
+#define LN_des_cbc "des-cbc"
+#define NID_des_cbc 31
+#define OBJ_des_cbc OBJ_algorithm,7L
+
+#define SN_des_ofb64 "DES-OFB"
+#define LN_des_ofb64 "des-ofb"
+#define NID_des_ofb64 45
+#define OBJ_des_ofb64 OBJ_algorithm,8L
+
+#define SN_des_cfb64 "DES-CFB"
+#define LN_des_cfb64 "des-cfb"
+#define NID_des_cfb64 30
+#define OBJ_des_cfb64 OBJ_algorithm,9L
+
+#define SN_rsaSignature "rsaSignature"
+#define NID_rsaSignature 377
+#define OBJ_rsaSignature OBJ_algorithm,11L
+
+#define SN_dsa_2 "DSA-old"
+#define LN_dsa_2 "dsaEncryption-old"
+#define NID_dsa_2 67
+#define OBJ_dsa_2 OBJ_algorithm,12L
+
+#define SN_dsaWithSHA "DSA-SHA"
+#define LN_dsaWithSHA "dsaWithSHA"
+#define NID_dsaWithSHA 66
+#define OBJ_dsaWithSHA OBJ_algorithm,13L
+
+#define SN_shaWithRSAEncryption "RSA-SHA"
+#define LN_shaWithRSAEncryption "shaWithRSAEncryption"
+#define NID_shaWithRSAEncryption 42
+#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L
+
+#define SN_des_ede_ecb "DES-EDE"
+#define LN_des_ede_ecb "des-ede"
+#define NID_des_ede_ecb 32
+#define OBJ_des_ede_ecb OBJ_algorithm,17L
+
+#define SN_des_ede3_ecb "DES-EDE3"
+#define LN_des_ede3_ecb "des-ede3"
+#define NID_des_ede3_ecb 33
+
+#define SN_des_ede_cbc "DES-EDE-CBC"
+#define LN_des_ede_cbc "des-ede-cbc"
+#define NID_des_ede_cbc 43
+
+#define SN_des_ede_cfb64 "DES-EDE-CFB"
+#define LN_des_ede_cfb64 "des-ede-cfb"
+#define NID_des_ede_cfb64 60
+
+#define SN_des_ede3_cfb64 "DES-EDE3-CFB"
+#define LN_des_ede3_cfb64 "des-ede3-cfb"
+#define NID_des_ede3_cfb64 61
+
+#define SN_des_ede_ofb64 "DES-EDE-OFB"
+#define LN_des_ede_ofb64 "des-ede-ofb"
+#define NID_des_ede_ofb64 62
+
+#define SN_des_ede3_ofb64 "DES-EDE3-OFB"
+#define LN_des_ede3_ofb64 "des-ede3-ofb"
+#define NID_des_ede3_ofb64 63
+
+#define SN_desx_cbc "DESX-CBC"
+#define LN_desx_cbc "desx-cbc"
+#define NID_desx_cbc 80
+
+#define SN_sha "SHA"
+#define LN_sha "sha"
+#define NID_sha 41
+#define OBJ_sha OBJ_algorithm,18L
+
+#define SN_sha1 "SHA1"
+#define LN_sha1 "sha1"
+#define NID_sha1 64
+#define OBJ_sha1 OBJ_algorithm,26L
+
+#define SN_dsaWithSHA1_2 "DSA-SHA1-old"
+#define LN_dsaWithSHA1_2 "dsaWithSHA1-old"
+#define NID_dsaWithSHA1_2 70
+#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L
+
+#define SN_sha1WithRSA "RSA-SHA1-2"
+#define LN_sha1WithRSA "sha1WithRSA"
+#define NID_sha1WithRSA 115
+#define OBJ_sha1WithRSA OBJ_algorithm,29L
+
+#define SN_ripemd160 "RIPEMD160"
+#define LN_ripemd160 "ripemd160"
+#define NID_ripemd160 117
+#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L
+
+#define SN_ripemd160WithRSA "RSA-RIPEMD160"
+#define LN_ripemd160WithRSA "ripemd160WithRSA"
+#define NID_ripemd160WithRSA 119
+#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L
+
+#define SN_sxnet "SXNetID"
+#define LN_sxnet "Strong Extranet ID"
+#define NID_sxnet 143
+#define OBJ_sxnet 1L,3L,101L,1L,4L,1L
+
+#define SN_X500 "X500"
+#define LN_X500 "directory services (X.500)"
+#define NID_X500 11
+#define OBJ_X500 2L,5L
+
+#define SN_X509 "X509"
+#define NID_X509 12
+#define OBJ_X509 OBJ_X500,4L
+
+#define SN_commonName "CN"
+#define LN_commonName "commonName"
+#define NID_commonName 13
+#define OBJ_commonName OBJ_X509,3L
+
+#define SN_surname "SN"
+#define LN_surname "surname"
+#define NID_surname 100
+#define OBJ_surname OBJ_X509,4L
+
+#define LN_serialNumber "serialNumber"
+#define NID_serialNumber 105
+#define OBJ_serialNumber OBJ_X509,5L
+
+#define SN_countryName "C"
+#define LN_countryName "countryName"
+#define NID_countryName 14
+#define OBJ_countryName OBJ_X509,6L
+
+#define SN_localityName "L"
+#define LN_localityName "localityName"
+#define NID_localityName 15
+#define OBJ_localityName OBJ_X509,7L
+
+#define SN_stateOrProvinceName "ST"
+#define LN_stateOrProvinceName "stateOrProvinceName"
+#define NID_stateOrProvinceName 16
+#define OBJ_stateOrProvinceName OBJ_X509,8L
+
+#define LN_streetAddress "streetAddress"
+#define NID_streetAddress 660
+#define OBJ_streetAddress OBJ_X509,9L
+
+#define SN_organizationName "O"
+#define LN_organizationName "organizationName"
+#define NID_organizationName 17
+#define OBJ_organizationName OBJ_X509,10L
+
+#define SN_organizationalUnitName "OU"
+#define LN_organizationalUnitName "organizationalUnitName"
+#define NID_organizationalUnitName 18
+#define OBJ_organizationalUnitName OBJ_X509,11L
+
+#define LN_title "title"
+#define NID_title 106
+#define OBJ_title OBJ_X509,12L
+
+#define LN_description "description"
+#define NID_description 107
+#define OBJ_description OBJ_X509,13L
+
+#define LN_postalCode "postalCode"
+#define NID_postalCode 661
+#define OBJ_postalCode OBJ_X509,17L
+
+#define SN_name "name"
+#define LN_name "name"
+#define NID_name 173
+#define OBJ_name OBJ_X509,41L
+
+#define SN_givenName "GN"
+#define LN_givenName "givenName"
+#define NID_givenName 99
+#define OBJ_givenName OBJ_X509,42L
+
+#define LN_initials "initials"
+#define NID_initials 101
+#define OBJ_initials OBJ_X509,43L
+
+#define LN_generationQualifier "generationQualifier"
+#define NID_generationQualifier 509
+#define OBJ_generationQualifier OBJ_X509,44L
+
+#define LN_x500UniqueIdentifier "x500UniqueIdentifier"
+#define NID_x500UniqueIdentifier 503
+#define OBJ_x500UniqueIdentifier OBJ_X509,45L
+
+#define SN_dnQualifier "dnQualifier"
+#define LN_dnQualifier "dnQualifier"
+#define NID_dnQualifier 174
+#define OBJ_dnQualifier OBJ_X509,46L
+
+#define LN_pseudonym "pseudonym"
+#define NID_pseudonym 510
+#define OBJ_pseudonym OBJ_X509,65L
+
+#define SN_role "role"
+#define LN_role "role"
+#define NID_role 400
+#define OBJ_role OBJ_X509,72L
+
+#define SN_X500algorithms "X500algorithms"
+#define LN_X500algorithms "directory services - algorithms"
+#define NID_X500algorithms 378
+#define OBJ_X500algorithms OBJ_X500,8L
+
+#define SN_rsa "RSA"
+#define LN_rsa "rsa"
+#define NID_rsa 19
+#define OBJ_rsa OBJ_X500algorithms,1L,1L
+
+#define SN_mdc2WithRSA "RSA-MDC2"
+#define LN_mdc2WithRSA "mdc2WithRSA"
+#define NID_mdc2WithRSA 96
+#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L
+
+#define SN_mdc2 "MDC2"
+#define LN_mdc2 "mdc2"
+#define NID_mdc2 95
+#define OBJ_mdc2 OBJ_X500algorithms,3L,101L
+
+#define SN_id_ce "id-ce"
+#define NID_id_ce 81
+#define OBJ_id_ce OBJ_X500,29L
+
+#define SN_subject_directory_attributes "subjectDirectoryAttributes"
+#define LN_subject_directory_attributes "X509v3 Subject Directory Attributes"
+#define NID_subject_directory_attributes 769
+#define OBJ_subject_directory_attributes OBJ_id_ce,9L
+
+#define SN_subject_key_identifier "subjectKeyIdentifier"
+#define LN_subject_key_identifier "X509v3 Subject Key Identifier"
+#define NID_subject_key_identifier 82
+#define OBJ_subject_key_identifier OBJ_id_ce,14L
+
+#define SN_key_usage "keyUsage"
+#define LN_key_usage "X509v3 Key Usage"
+#define NID_key_usage 83
+#define OBJ_key_usage OBJ_id_ce,15L
+
+#define SN_private_key_usage_period "privateKeyUsagePeriod"
+#define LN_private_key_usage_period "X509v3 Private Key Usage Period"
+#define NID_private_key_usage_period 84
+#define OBJ_private_key_usage_period OBJ_id_ce,16L
+
+#define SN_subject_alt_name "subjectAltName"
+#define LN_subject_alt_name "X509v3 Subject Alternative Name"
+#define NID_subject_alt_name 85
+#define OBJ_subject_alt_name OBJ_id_ce,17L
+
+#define SN_issuer_alt_name "issuerAltName"
+#define LN_issuer_alt_name "X509v3 Issuer Alternative Name"
+#define NID_issuer_alt_name 86
+#define OBJ_issuer_alt_name OBJ_id_ce,18L
+
+#define SN_basic_constraints "basicConstraints"
+#define LN_basic_constraints "X509v3 Basic Constraints"
+#define NID_basic_constraints 87
+#define OBJ_basic_constraints OBJ_id_ce,19L
+
+#define SN_crl_number "crlNumber"
+#define LN_crl_number "X509v3 CRL Number"
+#define NID_crl_number 88
+#define OBJ_crl_number OBJ_id_ce,20L
+
+#define SN_crl_reason "CRLReason"
+#define LN_crl_reason "X509v3 CRL Reason Code"
+#define NID_crl_reason 141
+#define OBJ_crl_reason OBJ_id_ce,21L
+
+#define SN_invalidity_date "invalidityDate"
+#define LN_invalidity_date "Invalidity Date"
+#define NID_invalidity_date 142
+#define OBJ_invalidity_date OBJ_id_ce,24L
+
+#define SN_delta_crl "deltaCRL"
+#define LN_delta_crl "X509v3 Delta CRL Indicator"
+#define NID_delta_crl 140
+#define OBJ_delta_crl OBJ_id_ce,27L
+
+#define SN_issuing_distribution_point "issuingDistributionPoint"
+#define LN_issuing_distribution_point "X509v3 Issuing Distrubution Point"
+#define NID_issuing_distribution_point 770
+#define OBJ_issuing_distribution_point OBJ_id_ce,28L
+
+#define SN_certificate_issuer "certificateIssuer"
+#define LN_certificate_issuer "X509v3 Certificate Issuer"
+#define NID_certificate_issuer 771
+#define OBJ_certificate_issuer OBJ_id_ce,29L
+
+#define SN_name_constraints "nameConstraints"
+#define LN_name_constraints "X509v3 Name Constraints"
+#define NID_name_constraints 666
+#define OBJ_name_constraints OBJ_id_ce,30L
+
+#define SN_crl_distribution_points "crlDistributionPoints"
+#define LN_crl_distribution_points "X509v3 CRL Distribution Points"
+#define NID_crl_distribution_points 103
+#define OBJ_crl_distribution_points OBJ_id_ce,31L
+
+#define SN_certificate_policies "certificatePolicies"
+#define LN_certificate_policies "X509v3 Certificate Policies"
+#define NID_certificate_policies 89
+#define OBJ_certificate_policies OBJ_id_ce,32L
+
+#define SN_any_policy "anyPolicy"
+#define LN_any_policy "X509v3 Any Policy"
+#define NID_any_policy 746
+#define OBJ_any_policy OBJ_certificate_policies,0L
+
+#define SN_policy_mappings "policyMappings"
+#define LN_policy_mappings "X509v3 Policy Mappings"
+#define NID_policy_mappings 747
+#define OBJ_policy_mappings OBJ_id_ce,33L
+
+#define SN_authority_key_identifier "authorityKeyIdentifier"
+#define LN_authority_key_identifier "X509v3 Authority Key Identifier"
+#define NID_authority_key_identifier 90
+#define OBJ_authority_key_identifier OBJ_id_ce,35L
+
+#define SN_policy_constraints "policyConstraints"
+#define LN_policy_constraints "X509v3 Policy Constraints"
+#define NID_policy_constraints 401
+#define OBJ_policy_constraints OBJ_id_ce,36L
+
+#define SN_ext_key_usage "extendedKeyUsage"
+#define LN_ext_key_usage "X509v3 Extended Key Usage"
+#define NID_ext_key_usage 126
+#define OBJ_ext_key_usage OBJ_id_ce,37L
+
+#define SN_freshest_crl "freshestCRL"
+#define LN_freshest_crl "X509v3 Freshest CRL"
+#define NID_freshest_crl 857
+#define OBJ_freshest_crl OBJ_id_ce,46L
+
+#define SN_inhibit_any_policy "inhibitAnyPolicy"
+#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy"
+#define NID_inhibit_any_policy 748
+#define OBJ_inhibit_any_policy OBJ_id_ce,54L
+
+#define SN_target_information "targetInformation"
+#define LN_target_information "X509v3 AC Targeting"
+#define NID_target_information 402
+#define OBJ_target_information OBJ_id_ce,55L
+
+#define SN_no_rev_avail "noRevAvail"
+#define LN_no_rev_avail "X509v3 No Revocation Available"
+#define NID_no_rev_avail 403
+#define OBJ_no_rev_avail OBJ_id_ce,56L
+
+#define SN_netscape "Netscape"
+#define LN_netscape "Netscape Communications Corp."
+#define NID_netscape 57
+#define OBJ_netscape 2L,16L,840L,1L,113730L
+
+#define SN_netscape_cert_extension "nsCertExt"
+#define LN_netscape_cert_extension "Netscape Certificate Extension"
+#define NID_netscape_cert_extension 58
+#define OBJ_netscape_cert_extension OBJ_netscape,1L
+
+#define SN_netscape_data_type "nsDataType"
+#define LN_netscape_data_type "Netscape Data Type"
+#define NID_netscape_data_type 59
+#define OBJ_netscape_data_type OBJ_netscape,2L
+
+#define SN_netscape_cert_type "nsCertType"
+#define LN_netscape_cert_type "Netscape Cert Type"
+#define NID_netscape_cert_type 71
+#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L
+
+#define SN_netscape_base_url "nsBaseUrl"
+#define LN_netscape_base_url "Netscape Base Url"
+#define NID_netscape_base_url 72
+#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L
+
+#define SN_netscape_revocation_url "nsRevocationUrl"
+#define LN_netscape_revocation_url "Netscape Revocation Url"
+#define NID_netscape_revocation_url 73
+#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L
+
+#define SN_netscape_ca_revocation_url "nsCaRevocationUrl"
+#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url"
+#define NID_netscape_ca_revocation_url 74
+#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L
+
+#define SN_netscape_renewal_url "nsRenewalUrl"
+#define LN_netscape_renewal_url "Netscape Renewal Url"
+#define NID_netscape_renewal_url 75
+#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L
+
+#define SN_netscape_ca_policy_url "nsCaPolicyUrl"
+#define LN_netscape_ca_policy_url "Netscape CA Policy Url"
+#define NID_netscape_ca_policy_url 76
+#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L
+
+#define SN_netscape_ssl_server_name "nsSslServerName"
+#define LN_netscape_ssl_server_name "Netscape SSL Server Name"
+#define NID_netscape_ssl_server_name 77
+#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L
+
+#define SN_netscape_comment "nsComment"
+#define LN_netscape_comment "Netscape Comment"
+#define NID_netscape_comment 78
+#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L
+
+#define SN_netscape_cert_sequence "nsCertSequence"
+#define LN_netscape_cert_sequence "Netscape Certificate Sequence"
+#define NID_netscape_cert_sequence 79
+#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L
+
+#define SN_ns_sgc "nsSGC"
+#define LN_ns_sgc "Netscape Server Gated Crypto"
+#define NID_ns_sgc 139
+#define OBJ_ns_sgc OBJ_netscape,4L,1L
+
+#define SN_org "ORG"
+#define LN_org "org"
+#define NID_org 379
+#define OBJ_org OBJ_iso,3L
+
+#define SN_dod "DOD"
+#define LN_dod "dod"
+#define NID_dod 380
+#define OBJ_dod OBJ_org,6L
+
+#define SN_iana "IANA"
+#define LN_iana "iana"
+#define NID_iana 381
+#define OBJ_iana OBJ_dod,1L
+
+#define OBJ_internet OBJ_iana
+
+#define SN_Directory "directory"
+#define LN_Directory "Directory"
+#define NID_Directory 382
+#define OBJ_Directory OBJ_internet,1L
+
+#define SN_Management "mgmt"
+#define LN_Management "Management"
+#define NID_Management 383
+#define OBJ_Management OBJ_internet,2L
+
+#define SN_Experimental "experimental"
+#define LN_Experimental "Experimental"
+#define NID_Experimental 384
+#define OBJ_Experimental OBJ_internet,3L
+
+#define SN_Private "private"
+#define LN_Private "Private"
+#define NID_Private 385
+#define OBJ_Private OBJ_internet,4L
+
+#define SN_Security "security"
+#define LN_Security "Security"
+#define NID_Security 386
+#define OBJ_Security OBJ_internet,5L
+
+#define SN_SNMPv2 "snmpv2"
+#define LN_SNMPv2 "SNMPv2"
+#define NID_SNMPv2 387
+#define OBJ_SNMPv2 OBJ_internet,6L
+
+#define LN_Mail "Mail"
+#define NID_Mail 388
+#define OBJ_Mail OBJ_internet,7L
+
+#define SN_Enterprises "enterprises"
+#define LN_Enterprises "Enterprises"
+#define NID_Enterprises 389
+#define OBJ_Enterprises OBJ_Private,1L
+
+#define SN_dcObject "dcobject"
+#define LN_dcObject "dcObject"
+#define NID_dcObject 390
+#define OBJ_dcObject OBJ_Enterprises,1466L,344L
+
+#define SN_mime_mhs "mime-mhs"
+#define LN_mime_mhs "MIME MHS"
+#define NID_mime_mhs 504
+#define OBJ_mime_mhs OBJ_Mail,1L
+
+#define SN_mime_mhs_headings "mime-mhs-headings"
+#define LN_mime_mhs_headings "mime-mhs-headings"
+#define NID_mime_mhs_headings 505
+#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L
+
+#define SN_mime_mhs_bodies "mime-mhs-bodies"
+#define LN_mime_mhs_bodies "mime-mhs-bodies"
+#define NID_mime_mhs_bodies 506
+#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L
+
+#define SN_id_hex_partial_message "id-hex-partial-message"
+#define LN_id_hex_partial_message "id-hex-partial-message"
+#define NID_id_hex_partial_message 507
+#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L
+
+#define SN_id_hex_multipart_message "id-hex-multipart-message"
+#define LN_id_hex_multipart_message "id-hex-multipart-message"
+#define NID_id_hex_multipart_message 508
+#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L
+
+#define SN_rle_compression "RLE"
+#define LN_rle_compression "run length compression"
+#define NID_rle_compression 124
+#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L
+
+#define SN_zlib_compression "ZLIB"
+#define LN_zlib_compression "zlib compression"
+#define NID_zlib_compression 125
+#define OBJ_zlib_compression OBJ_id_smime_alg,8L
+
+#define OBJ_csor 2L,16L,840L,1L,101L,3L
+
+#define OBJ_nistAlgorithms OBJ_csor,4L
+
+#define OBJ_aes OBJ_nistAlgorithms,1L
+
+#define SN_aes_128_ecb "AES-128-ECB"
+#define LN_aes_128_ecb "aes-128-ecb"
+#define NID_aes_128_ecb 418
+#define OBJ_aes_128_ecb OBJ_aes,1L
+
+#define SN_aes_128_cbc "AES-128-CBC"
+#define LN_aes_128_cbc "aes-128-cbc"
+#define NID_aes_128_cbc 419
+#define OBJ_aes_128_cbc OBJ_aes,2L
+
+#define SN_aes_128_ofb128 "AES-128-OFB"
+#define LN_aes_128_ofb128 "aes-128-ofb"
+#define NID_aes_128_ofb128 420
+#define OBJ_aes_128_ofb128 OBJ_aes,3L
+
+#define SN_aes_128_cfb128 "AES-128-CFB"
+#define LN_aes_128_cfb128 "aes-128-cfb"
+#define NID_aes_128_cfb128 421
+#define OBJ_aes_128_cfb128 OBJ_aes,4L
+
+#define SN_aes_192_ecb "AES-192-ECB"
+#define LN_aes_192_ecb "aes-192-ecb"
+#define NID_aes_192_ecb 422
+#define OBJ_aes_192_ecb OBJ_aes,21L
+
+#define SN_aes_192_cbc "AES-192-CBC"
+#define LN_aes_192_cbc "aes-192-cbc"
+#define NID_aes_192_cbc 423
+#define OBJ_aes_192_cbc OBJ_aes,22L
+
+#define SN_aes_192_ofb128 "AES-192-OFB"
+#define LN_aes_192_ofb128 "aes-192-ofb"
+#define NID_aes_192_ofb128 424
+#define OBJ_aes_192_ofb128 OBJ_aes,23L
+
+#define SN_aes_192_cfb128 "AES-192-CFB"
+#define LN_aes_192_cfb128 "aes-192-cfb"
+#define NID_aes_192_cfb128 425
+#define OBJ_aes_192_cfb128 OBJ_aes,24L
+
+#define SN_aes_256_ecb "AES-256-ECB"
+#define LN_aes_256_ecb "aes-256-ecb"
+#define NID_aes_256_ecb 426
+#define OBJ_aes_256_ecb OBJ_aes,41L
+
+#define SN_aes_256_cbc "AES-256-CBC"
+#define LN_aes_256_cbc "aes-256-cbc"
+#define NID_aes_256_cbc 427
+#define OBJ_aes_256_cbc OBJ_aes,42L
+
+#define SN_aes_256_ofb128 "AES-256-OFB"
+#define LN_aes_256_ofb128 "aes-256-ofb"
+#define NID_aes_256_ofb128 428
+#define OBJ_aes_256_ofb128 OBJ_aes,43L
+
+#define SN_aes_256_cfb128 "AES-256-CFB"
+#define LN_aes_256_cfb128 "aes-256-cfb"
+#define NID_aes_256_cfb128 429
+#define OBJ_aes_256_cfb128 OBJ_aes,44L
+
+#define SN_aes_128_cfb1 "AES-128-CFB1"
+#define LN_aes_128_cfb1 "aes-128-cfb1"
+#define NID_aes_128_cfb1 650
+
+#define SN_aes_192_cfb1 "AES-192-CFB1"
+#define LN_aes_192_cfb1 "aes-192-cfb1"
+#define NID_aes_192_cfb1 651
+
+#define SN_aes_256_cfb1 "AES-256-CFB1"
+#define LN_aes_256_cfb1 "aes-256-cfb1"
+#define NID_aes_256_cfb1 652
+
+#define SN_aes_128_cfb8 "AES-128-CFB8"
+#define LN_aes_128_cfb8 "aes-128-cfb8"
+#define NID_aes_128_cfb8 653
+
+#define SN_aes_192_cfb8 "AES-192-CFB8"
+#define LN_aes_192_cfb8 "aes-192-cfb8"
+#define NID_aes_192_cfb8 654
+
+#define SN_aes_256_cfb8 "AES-256-CFB8"
+#define LN_aes_256_cfb8 "aes-256-cfb8"
+#define NID_aes_256_cfb8 655
+
+#define SN_des_cfb1 "DES-CFB1"
+#define LN_des_cfb1 "des-cfb1"
+#define NID_des_cfb1 656
+
+#define SN_des_cfb8 "DES-CFB8"
+#define LN_des_cfb8 "des-cfb8"
+#define NID_des_cfb8 657
+
+#define SN_des_ede3_cfb1 "DES-EDE3-CFB1"
+#define LN_des_ede3_cfb1 "des-ede3-cfb1"
+#define NID_des_ede3_cfb1 658
+
+#define SN_des_ede3_cfb8 "DES-EDE3-CFB8"
+#define LN_des_ede3_cfb8 "des-ede3-cfb8"
+#define NID_des_ede3_cfb8 659
+
+#define SN_id_aes128_wrap "id-aes128-wrap"
+#define NID_id_aes128_wrap 788
+#define OBJ_id_aes128_wrap OBJ_aes,5L
+
+#define SN_id_aes192_wrap "id-aes192-wrap"
+#define NID_id_aes192_wrap 789
+#define OBJ_id_aes192_wrap OBJ_aes,25L
+
+#define SN_id_aes256_wrap "id-aes256-wrap"
+#define NID_id_aes256_wrap 790
+#define OBJ_id_aes256_wrap OBJ_aes,45L
+
+#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L
+
+#define SN_sha256 "SHA256"
+#define LN_sha256 "sha256"
+#define NID_sha256 672
+#define OBJ_sha256 OBJ_nist_hashalgs,1L
+
+#define SN_sha384 "SHA384"
+#define LN_sha384 "sha384"
+#define NID_sha384 673
+#define OBJ_sha384 OBJ_nist_hashalgs,2L
+
+#define SN_sha512 "SHA512"
+#define LN_sha512 "sha512"
+#define NID_sha512 674
+#define OBJ_sha512 OBJ_nist_hashalgs,3L
+
+#define SN_sha224 "SHA224"
+#define LN_sha224 "sha224"
+#define NID_sha224 675
+#define OBJ_sha224 OBJ_nist_hashalgs,4L
+
+#define OBJ_dsa_with_sha2 OBJ_nistAlgorithms,3L
+
+#define SN_dsa_with_SHA224 "dsa_with_SHA224"
+#define NID_dsa_with_SHA224 802
+#define OBJ_dsa_with_SHA224 OBJ_dsa_with_sha2,1L
+
+#define SN_dsa_with_SHA256 "dsa_with_SHA256"
+#define NID_dsa_with_SHA256 803
+#define OBJ_dsa_with_SHA256 OBJ_dsa_with_sha2,2L
+
+#define SN_hold_instruction_code "holdInstructionCode"
+#define LN_hold_instruction_code "Hold Instruction Code"
+#define NID_hold_instruction_code 430
+#define OBJ_hold_instruction_code OBJ_id_ce,23L
+
+#define OBJ_holdInstruction OBJ_X9_57,2L
+
+#define SN_hold_instruction_none "holdInstructionNone"
+#define LN_hold_instruction_none "Hold Instruction None"
+#define NID_hold_instruction_none 431
+#define OBJ_hold_instruction_none OBJ_holdInstruction,1L
+
+#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer"
+#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer"
+#define NID_hold_instruction_call_issuer 432
+#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L
+
+#define SN_hold_instruction_reject "holdInstructionReject"
+#define LN_hold_instruction_reject "Hold Instruction Reject"
+#define NID_hold_instruction_reject 433
+#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L
+
+#define SN_data "data"
+#define NID_data 434
+#define OBJ_data OBJ_itu_t,9L
+
+#define SN_pss "pss"
+#define NID_pss 435
+#define OBJ_pss OBJ_data,2342L
+
+#define SN_ucl "ucl"
+#define NID_ucl 436
+#define OBJ_ucl OBJ_pss,19200300L
+
+#define SN_pilot "pilot"
+#define NID_pilot 437
+#define OBJ_pilot OBJ_ucl,100L
+
+#define LN_pilotAttributeType "pilotAttributeType"
+#define NID_pilotAttributeType 438
+#define OBJ_pilotAttributeType OBJ_pilot,1L
+
+#define LN_pilotAttributeSyntax "pilotAttributeSyntax"
+#define NID_pilotAttributeSyntax 439
+#define OBJ_pilotAttributeSyntax OBJ_pilot,3L
+
+#define LN_pilotObjectClass "pilotObjectClass"
+#define NID_pilotObjectClass 440
+#define OBJ_pilotObjectClass OBJ_pilot,4L
+
+#define LN_pilotGroups "pilotGroups"
+#define NID_pilotGroups 441
+#define OBJ_pilotGroups OBJ_pilot,10L
+
+#define LN_iA5StringSyntax "iA5StringSyntax"
+#define NID_iA5StringSyntax 442
+#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L
+
+#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax"
+#define NID_caseIgnoreIA5StringSyntax 443
+#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L
+
+#define LN_pilotObject "pilotObject"
+#define NID_pilotObject 444
+#define OBJ_pilotObject OBJ_pilotObjectClass,3L
+
+#define LN_pilotPerson "pilotPerson"
+#define NID_pilotPerson 445
+#define OBJ_pilotPerson OBJ_pilotObjectClass,4L
+
+#define SN_account "account"
+#define NID_account 446
+#define OBJ_account OBJ_pilotObjectClass,5L
+
+#define SN_document "document"
+#define NID_document 447
+#define OBJ_document OBJ_pilotObjectClass,6L
+
+#define SN_room "room"
+#define NID_room 448
+#define OBJ_room OBJ_pilotObjectClass,7L
+
+#define LN_documentSeries "documentSeries"
+#define NID_documentSeries 449
+#define OBJ_documentSeries OBJ_pilotObjectClass,9L
+
+#define SN_Domain "domain"
+#define LN_Domain "Domain"
+#define NID_Domain 392
+#define OBJ_Domain OBJ_pilotObjectClass,13L
+
+#define LN_rFC822localPart "rFC822localPart"
+#define NID_rFC822localPart 450
+#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L
+
+#define LN_dNSDomain "dNSDomain"
+#define NID_dNSDomain 451
+#define OBJ_dNSDomain OBJ_pilotObjectClass,15L
+
+#define LN_domainRelatedObject "domainRelatedObject"
+#define NID_domainRelatedObject 452
+#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L
+
+#define LN_friendlyCountry "friendlyCountry"
+#define NID_friendlyCountry 453
+#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L
+
+#define LN_simpleSecurityObject "simpleSecurityObject"
+#define NID_simpleSecurityObject 454
+#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L
+
+#define LN_pilotOrganization "pilotOrganization"
+#define NID_pilotOrganization 455
+#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L
+
+#define LN_pilotDSA "pilotDSA"
+#define NID_pilotDSA 456
+#define OBJ_pilotDSA OBJ_pilotObjectClass,21L
+
+#define LN_qualityLabelledData "qualityLabelledData"
+#define NID_qualityLabelledData 457
+#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L
+
+#define SN_userId "UID"
+#define LN_userId "userId"
+#define NID_userId 458
+#define OBJ_userId OBJ_pilotAttributeType,1L
+
+#define LN_textEncodedORAddress "textEncodedORAddress"
+#define NID_textEncodedORAddress 459
+#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L
+
+#define SN_rfc822Mailbox "mail"
+#define LN_rfc822Mailbox "rfc822Mailbox"
+#define NID_rfc822Mailbox 460
+#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L
+
+#define SN_info "info"
+#define NID_info 461
+#define OBJ_info OBJ_pilotAttributeType,4L
+
+#define LN_favouriteDrink "favouriteDrink"
+#define NID_favouriteDrink 462
+#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L
+
+#define LN_roomNumber "roomNumber"
+#define NID_roomNumber 463
+#define OBJ_roomNumber OBJ_pilotAttributeType,6L
+
+#define SN_photo "photo"
+#define NID_photo 464
+#define OBJ_photo OBJ_pilotAttributeType,7L
+
+#define LN_userClass "userClass"
+#define NID_userClass 465
+#define OBJ_userClass OBJ_pilotAttributeType,8L
+
+#define SN_host "host"
+#define NID_host 466
+#define OBJ_host OBJ_pilotAttributeType,9L
+
+#define SN_manager "manager"
+#define NID_manager 467
+#define OBJ_manager OBJ_pilotAttributeType,10L
+
+#define LN_documentIdentifier "documentIdentifier"
+#define NID_documentIdentifier 468
+#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L
+
+#define LN_documentTitle "documentTitle"
+#define NID_documentTitle 469
+#define OBJ_documentTitle OBJ_pilotAttributeType,12L
+
+#define LN_documentVersion "documentVersion"
+#define NID_documentVersion 470
+#define OBJ_documentVersion OBJ_pilotAttributeType,13L
+
+#define LN_documentAuthor "documentAuthor"
+#define NID_documentAuthor 471
+#define OBJ_documentAuthor OBJ_pilotAttributeType,14L
+
+#define LN_documentLocation "documentLocation"
+#define NID_documentLocation 472
+#define OBJ_documentLocation OBJ_pilotAttributeType,15L
+
+#define LN_homeTelephoneNumber "homeTelephoneNumber"
+#define NID_homeTelephoneNumber 473
+#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L
+
+#define SN_secretary "secretary"
+#define NID_secretary 474
+#define OBJ_secretary OBJ_pilotAttributeType,21L
+
+#define LN_otherMailbox "otherMailbox"
+#define NID_otherMailbox 475
+#define OBJ_otherMailbox OBJ_pilotAttributeType,22L
+
+#define LN_lastModifiedTime "lastModifiedTime"
+#define NID_lastModifiedTime 476
+#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L
+
+#define LN_lastModifiedBy "lastModifiedBy"
+#define NID_lastModifiedBy 477
+#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L
+
+#define SN_domainComponent "DC"
+#define LN_domainComponent "domainComponent"
+#define NID_domainComponent 391
+#define OBJ_domainComponent OBJ_pilotAttributeType,25L
+
+#define LN_aRecord "aRecord"
+#define NID_aRecord 478
+#define OBJ_aRecord OBJ_pilotAttributeType,26L
+
+#define LN_pilotAttributeType27 "pilotAttributeType27"
+#define NID_pilotAttributeType27 479
+#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L
+
+#define LN_mXRecord "mXRecord"
+#define NID_mXRecord 480
+#define OBJ_mXRecord OBJ_pilotAttributeType,28L
+
+#define LN_nSRecord "nSRecord"
+#define NID_nSRecord 481
+#define OBJ_nSRecord OBJ_pilotAttributeType,29L
+
+#define LN_sOARecord "sOARecord"
+#define NID_sOARecord 482
+#define OBJ_sOARecord OBJ_pilotAttributeType,30L
+
+#define LN_cNAMERecord "cNAMERecord"
+#define NID_cNAMERecord 483
+#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L
+
+#define LN_associatedDomain "associatedDomain"
+#define NID_associatedDomain 484
+#define OBJ_associatedDomain OBJ_pilotAttributeType,37L
+
+#define LN_associatedName "associatedName"
+#define NID_associatedName 485
+#define OBJ_associatedName OBJ_pilotAttributeType,38L
+
+#define LN_homePostalAddress "homePostalAddress"
+#define NID_homePostalAddress 486
+#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L
+
+#define LN_personalTitle "personalTitle"
+#define NID_personalTitle 487
+#define OBJ_personalTitle OBJ_pilotAttributeType,40L
+
+#define LN_mobileTelephoneNumber "mobileTelephoneNumber"
+#define NID_mobileTelephoneNumber 488
+#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L
+
+#define LN_pagerTelephoneNumber "pagerTelephoneNumber"
+#define NID_pagerTelephoneNumber 489
+#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L
+
+#define LN_friendlyCountryName "friendlyCountryName"
+#define NID_friendlyCountryName 490
+#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L
+
+#define LN_organizationalStatus "organizationalStatus"
+#define NID_organizationalStatus 491
+#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L
+
+#define LN_janetMailbox "janetMailbox"
+#define NID_janetMailbox 492
+#define OBJ_janetMailbox OBJ_pilotAttributeType,46L
+
+#define LN_mailPreferenceOption "mailPreferenceOption"
+#define NID_mailPreferenceOption 493
+#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L
+
+#define LN_buildingName "buildingName"
+#define NID_buildingName 494
+#define OBJ_buildingName OBJ_pilotAttributeType,48L
+
+#define LN_dSAQuality "dSAQuality"
+#define NID_dSAQuality 495
+#define OBJ_dSAQuality OBJ_pilotAttributeType,49L
+
+#define LN_singleLevelQuality "singleLevelQuality"
+#define NID_singleLevelQuality 496
+#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L
+
+#define LN_subtreeMinimumQuality "subtreeMinimumQuality"
+#define NID_subtreeMinimumQuality 497
+#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L
+
+#define LN_subtreeMaximumQuality "subtreeMaximumQuality"
+#define NID_subtreeMaximumQuality 498
+#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L
+
+#define LN_personalSignature "personalSignature"
+#define NID_personalSignature 499
+#define OBJ_personalSignature OBJ_pilotAttributeType,53L
+
+#define LN_dITRedirect "dITRedirect"
+#define NID_dITRedirect 500
+#define OBJ_dITRedirect OBJ_pilotAttributeType,54L
+
+#define SN_audio "audio"
+#define NID_audio 501
+#define OBJ_audio OBJ_pilotAttributeType,55L
+
+#define LN_documentPublisher "documentPublisher"
+#define NID_documentPublisher 502
+#define OBJ_documentPublisher OBJ_pilotAttributeType,56L
+
+#define SN_id_set "id-set"
+#define LN_id_set "Secure Electronic Transactions"
+#define NID_id_set 512
+#define OBJ_id_set OBJ_international_organizations,42L
+
+#define SN_set_ctype "set-ctype"
+#define LN_set_ctype "content types"
+#define NID_set_ctype 513
+#define OBJ_set_ctype OBJ_id_set,0L
+
+#define SN_set_msgExt "set-msgExt"
+#define LN_set_msgExt "message extensions"
+#define NID_set_msgExt 514
+#define OBJ_set_msgExt OBJ_id_set,1L
+
+#define SN_set_attr "set-attr"
+#define NID_set_attr 515
+#define OBJ_set_attr OBJ_id_set,3L
+
+#define SN_set_policy "set-policy"
+#define NID_set_policy 516
+#define OBJ_set_policy OBJ_id_set,5L
+
+#define SN_set_certExt "set-certExt"
+#define LN_set_certExt "certificate extensions"
+#define NID_set_certExt 517
+#define OBJ_set_certExt OBJ_id_set,7L
+
+#define SN_set_brand "set-brand"
+#define NID_set_brand 518
+#define OBJ_set_brand OBJ_id_set,8L
+
+#define SN_setct_PANData "setct-PANData"
+#define NID_setct_PANData 519
+#define OBJ_setct_PANData OBJ_set_ctype,0L
+
+#define SN_setct_PANToken "setct-PANToken"
+#define NID_setct_PANToken 520
+#define OBJ_setct_PANToken OBJ_set_ctype,1L
+
+#define SN_setct_PANOnly "setct-PANOnly"
+#define NID_setct_PANOnly 521
+#define OBJ_setct_PANOnly OBJ_set_ctype,2L
+
+#define SN_setct_OIData "setct-OIData"
+#define NID_setct_OIData 522
+#define OBJ_setct_OIData OBJ_set_ctype,3L
+
+#define SN_setct_PI "setct-PI"
+#define NID_setct_PI 523
+#define OBJ_setct_PI OBJ_set_ctype,4L
+
+#define SN_setct_PIData "setct-PIData"
+#define NID_setct_PIData 524
+#define OBJ_setct_PIData OBJ_set_ctype,5L
+
+#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned"
+#define NID_setct_PIDataUnsigned 525
+#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L
+
+#define SN_setct_HODInput "setct-HODInput"
+#define NID_setct_HODInput 526
+#define OBJ_setct_HODInput OBJ_set_ctype,7L
+
+#define SN_setct_AuthResBaggage "setct-AuthResBaggage"
+#define NID_setct_AuthResBaggage 527
+#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L
+
+#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage"
+#define NID_setct_AuthRevReqBaggage 528
+#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L
+
+#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage"
+#define NID_setct_AuthRevResBaggage 529
+#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L
+
+#define SN_setct_CapTokenSeq "setct-CapTokenSeq"
+#define NID_setct_CapTokenSeq 530
+#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L
+
+#define SN_setct_PInitResData "setct-PInitResData"
+#define NID_setct_PInitResData 531
+#define OBJ_setct_PInitResData OBJ_set_ctype,12L
+
+#define SN_setct_PI_TBS "setct-PI-TBS"
+#define NID_setct_PI_TBS 532
+#define OBJ_setct_PI_TBS OBJ_set_ctype,13L
+
+#define SN_setct_PResData "setct-PResData"
+#define NID_setct_PResData 533
+#define OBJ_setct_PResData OBJ_set_ctype,14L
+
+#define SN_setct_AuthReqTBS "setct-AuthReqTBS"
+#define NID_setct_AuthReqTBS 534
+#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L
+
+#define SN_setct_AuthResTBS "setct-AuthResTBS"
+#define NID_setct_AuthResTBS 535
+#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L
+
+#define SN_setct_AuthResTBSX "setct-AuthResTBSX"
+#define NID_setct_AuthResTBSX 536
+#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L
+
+#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS"
+#define NID_setct_AuthTokenTBS 537
+#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L
+
+#define SN_setct_CapTokenData "setct-CapTokenData"
+#define NID_setct_CapTokenData 538
+#define OBJ_setct_CapTokenData OBJ_set_ctype,20L
+
+#define SN_setct_CapTokenTBS "setct-CapTokenTBS"
+#define NID_setct_CapTokenTBS 539
+#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L
+
+#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg"
+#define NID_setct_AcqCardCodeMsg 540
+#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L
+
+#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS"
+#define NID_setct_AuthRevReqTBS 541
+#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L
+
+#define SN_setct_AuthRevResData "setct-AuthRevResData"
+#define NID_setct_AuthRevResData 542
+#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L
+
+#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS"
+#define NID_setct_AuthRevResTBS 543
+#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L
+
+#define SN_setct_CapReqTBS "setct-CapReqTBS"
+#define NID_setct_CapReqTBS 544
+#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L
+
+#define SN_setct_CapReqTBSX "setct-CapReqTBSX"
+#define NID_setct_CapReqTBSX 545
+#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L
+
+#define SN_setct_CapResData "setct-CapResData"
+#define NID_setct_CapResData 546
+#define OBJ_setct_CapResData OBJ_set_ctype,28L
+
+#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS"
+#define NID_setct_CapRevReqTBS 547
+#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L
+
+#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX"
+#define NID_setct_CapRevReqTBSX 548
+#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L
+
+#define SN_setct_CapRevResData "setct-CapRevResData"
+#define NID_setct_CapRevResData 549
+#define OBJ_setct_CapRevResData OBJ_set_ctype,31L
+
+#define SN_setct_CredReqTBS "setct-CredReqTBS"
+#define NID_setct_CredReqTBS 550
+#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L
+
+#define SN_setct_CredReqTBSX "setct-CredReqTBSX"
+#define NID_setct_CredReqTBSX 551
+#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L
+
+#define SN_setct_CredResData "setct-CredResData"
+#define NID_setct_CredResData 552
+#define OBJ_setct_CredResData OBJ_set_ctype,34L
+
+#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS"
+#define NID_setct_CredRevReqTBS 553
+#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L
+
+#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX"
+#define NID_setct_CredRevReqTBSX 554
+#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L
+
+#define SN_setct_CredRevResData "setct-CredRevResData"
+#define NID_setct_CredRevResData 555
+#define OBJ_setct_CredRevResData OBJ_set_ctype,37L
+
+#define SN_setct_PCertReqData "setct-PCertReqData"
+#define NID_setct_PCertReqData 556
+#define OBJ_setct_PCertReqData OBJ_set_ctype,38L
+
+#define SN_setct_PCertResTBS "setct-PCertResTBS"
+#define NID_setct_PCertResTBS 557
+#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L
+
+#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData"
+#define NID_setct_BatchAdminReqData 558
+#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L
+
+#define SN_setct_BatchAdminResData "setct-BatchAdminResData"
+#define NID_setct_BatchAdminResData 559
+#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L
+
+#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS"
+#define NID_setct_CardCInitResTBS 560
+#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L
+
+#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS"
+#define NID_setct_MeAqCInitResTBS 561
+#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L
+
+#define SN_setct_RegFormResTBS "setct-RegFormResTBS"
+#define NID_setct_RegFormResTBS 562
+#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L
+
+#define SN_setct_CertReqData "setct-CertReqData"
+#define NID_setct_CertReqData 563
+#define OBJ_setct_CertReqData OBJ_set_ctype,45L
+
+#define SN_setct_CertReqTBS "setct-CertReqTBS"
+#define NID_setct_CertReqTBS 564
+#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L
+
+#define SN_setct_CertResData "setct-CertResData"
+#define NID_setct_CertResData 565
+#define OBJ_setct_CertResData OBJ_set_ctype,47L
+
+#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS"
+#define NID_setct_CertInqReqTBS 566
+#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L
+
+#define SN_setct_ErrorTBS "setct-ErrorTBS"
+#define NID_setct_ErrorTBS 567
+#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L
+
+#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE"
+#define NID_setct_PIDualSignedTBE 568
+#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L
+
+#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE"
+#define NID_setct_PIUnsignedTBE 569
+#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L
+
+#define SN_setct_AuthReqTBE "setct-AuthReqTBE"
+#define NID_setct_AuthReqTBE 570
+#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L
+
+#define SN_setct_AuthResTBE "setct-AuthResTBE"
+#define NID_setct_AuthResTBE 571
+#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L
+
+#define SN_setct_AuthResTBEX "setct-AuthResTBEX"
+#define NID_setct_AuthResTBEX 572
+#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L
+
+#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE"
+#define NID_setct_AuthTokenTBE 573
+#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L
+
+#define SN_setct_CapTokenTBE "setct-CapTokenTBE"
+#define NID_setct_CapTokenTBE 574
+#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L
+
+#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX"
+#define NID_setct_CapTokenTBEX 575
+#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L
+
+#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE"
+#define NID_setct_AcqCardCodeMsgTBE 576
+#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L
+
+#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE"
+#define NID_setct_AuthRevReqTBE 577
+#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L
+
+#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE"
+#define NID_setct_AuthRevResTBE 578
+#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L
+
+#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB"
+#define NID_setct_AuthRevResTBEB 579
+#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L
+
+#define SN_setct_CapReqTBE "setct-CapReqTBE"
+#define NID_setct_CapReqTBE 580
+#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L
+
+#define SN_setct_CapReqTBEX "setct-CapReqTBEX"
+#define NID_setct_CapReqTBEX 581
+#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L
+
+#define SN_setct_CapResTBE "setct-CapResTBE"
+#define NID_setct_CapResTBE 582
+#define OBJ_setct_CapResTBE OBJ_set_ctype,64L
+
+#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE"
+#define NID_setct_CapRevReqTBE 583
+#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L
+
+#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX"
+#define NID_setct_CapRevReqTBEX 584
+#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L
+
+#define SN_setct_CapRevResTBE "setct-CapRevResTBE"
+#define NID_setct_CapRevResTBE 585
+#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L
+
+#define SN_setct_CredReqTBE "setct-CredReqTBE"
+#define NID_setct_CredReqTBE 586
+#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L
+
+#define SN_setct_CredReqTBEX "setct-CredReqTBEX"
+#define NID_setct_CredReqTBEX 587
+#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L
+
+#define SN_setct_CredResTBE "setct-CredResTBE"
+#define NID_setct_CredResTBE 588
+#define OBJ_setct_CredResTBE OBJ_set_ctype,70L
+
+#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE"
+#define NID_setct_CredRevReqTBE 589
+#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L
+
+#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX"
+#define NID_setct_CredRevReqTBEX 590
+#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L
+
+#define SN_setct_CredRevResTBE "setct-CredRevResTBE"
+#define NID_setct_CredRevResTBE 591
+#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L
+
+#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE"
+#define NID_setct_BatchAdminReqTBE 592
+#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L
+
+#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE"
+#define NID_setct_BatchAdminResTBE 593
+#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L
+
+#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE"
+#define NID_setct_RegFormReqTBE 594
+#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L
+
+#define SN_setct_CertReqTBE "setct-CertReqTBE"
+#define NID_setct_CertReqTBE 595
+#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L
+
+#define SN_setct_CertReqTBEX "setct-CertReqTBEX"
+#define NID_setct_CertReqTBEX 596
+#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L
+
+#define SN_setct_CertResTBE "setct-CertResTBE"
+#define NID_setct_CertResTBE 597
+#define OBJ_setct_CertResTBE OBJ_set_ctype,79L
+
+#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS"
+#define NID_setct_CRLNotificationTBS 598
+#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L
+
+#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS"
+#define NID_setct_CRLNotificationResTBS 599
+#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L
+
+#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS"
+#define NID_setct_BCIDistributionTBS 600
+#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L
+
+#define SN_setext_genCrypt "setext-genCrypt"
+#define LN_setext_genCrypt "generic cryptogram"
+#define NID_setext_genCrypt 601
+#define OBJ_setext_genCrypt OBJ_set_msgExt,1L
+
+#define SN_setext_miAuth "setext-miAuth"
+#define LN_setext_miAuth "merchant initiated auth"
+#define NID_setext_miAuth 602
+#define OBJ_setext_miAuth OBJ_set_msgExt,3L
+
+#define SN_setext_pinSecure "setext-pinSecure"
+#define NID_setext_pinSecure 603
+#define OBJ_setext_pinSecure OBJ_set_msgExt,4L
+
+#define SN_setext_pinAny "setext-pinAny"
+#define NID_setext_pinAny 604
+#define OBJ_setext_pinAny OBJ_set_msgExt,5L
+
+#define SN_setext_track2 "setext-track2"
+#define NID_setext_track2 605
+#define OBJ_setext_track2 OBJ_set_msgExt,7L
+
+#define SN_setext_cv "setext-cv"
+#define LN_setext_cv "additional verification"
+#define NID_setext_cv 606
+#define OBJ_setext_cv OBJ_set_msgExt,8L
+
+#define SN_set_policy_root "set-policy-root"
+#define NID_set_policy_root 607
+#define OBJ_set_policy_root OBJ_set_policy,0L
+
+#define SN_setCext_hashedRoot "setCext-hashedRoot"
+#define NID_setCext_hashedRoot 608
+#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L
+
+#define SN_setCext_certType "setCext-certType"
+#define NID_setCext_certType 609
+#define OBJ_setCext_certType OBJ_set_certExt,1L
+
+#define SN_setCext_merchData "setCext-merchData"
+#define NID_setCext_merchData 610
+#define OBJ_setCext_merchData OBJ_set_certExt,2L
+
+#define SN_setCext_cCertRequired "setCext-cCertRequired"
+#define NID_setCext_cCertRequired 611
+#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L
+
+#define SN_setCext_tunneling "setCext-tunneling"
+#define NID_setCext_tunneling 612
+#define OBJ_setCext_tunneling OBJ_set_certExt,4L
+
+#define SN_setCext_setExt "setCext-setExt"
+#define NID_setCext_setExt 613
+#define OBJ_setCext_setExt OBJ_set_certExt,5L
+
+#define SN_setCext_setQualf "setCext-setQualf"
+#define NID_setCext_setQualf 614
+#define OBJ_setCext_setQualf OBJ_set_certExt,6L
+
+#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities"
+#define NID_setCext_PGWYcapabilities 615
+#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L
+
+#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier"
+#define NID_setCext_TokenIdentifier 616
+#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L
+
+#define SN_setCext_Track2Data "setCext-Track2Data"
+#define NID_setCext_Track2Data 617
+#define OBJ_setCext_Track2Data OBJ_set_certExt,9L
+
+#define SN_setCext_TokenType "setCext-TokenType"
+#define NID_setCext_TokenType 618
+#define OBJ_setCext_TokenType OBJ_set_certExt,10L
+
+#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities"
+#define NID_setCext_IssuerCapabilities 619
+#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L
+
+#define SN_setAttr_Cert "setAttr-Cert"
+#define NID_setAttr_Cert 620
+#define OBJ_setAttr_Cert OBJ_set_attr,0L
+
+#define SN_setAttr_PGWYcap "setAttr-PGWYcap"
+#define LN_setAttr_PGWYcap "payment gateway capabilities"
+#define NID_setAttr_PGWYcap 621
+#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L
+
+#define SN_setAttr_TokenType "setAttr-TokenType"
+#define NID_setAttr_TokenType 622
+#define OBJ_setAttr_TokenType OBJ_set_attr,2L
+
+#define SN_setAttr_IssCap "setAttr-IssCap"
+#define LN_setAttr_IssCap "issuer capabilities"
+#define NID_setAttr_IssCap 623
+#define OBJ_setAttr_IssCap OBJ_set_attr,3L
+
+#define SN_set_rootKeyThumb "set-rootKeyThumb"
+#define NID_set_rootKeyThumb 624
+#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L
+
+#define SN_set_addPolicy "set-addPolicy"
+#define NID_set_addPolicy 625
+#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L
+
+#define SN_setAttr_Token_EMV "setAttr-Token-EMV"
+#define NID_setAttr_Token_EMV 626
+#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L
+
+#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime"
+#define NID_setAttr_Token_B0Prime 627
+#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L
+
+#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM"
+#define NID_setAttr_IssCap_CVM 628
+#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L
+
+#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2"
+#define NID_setAttr_IssCap_T2 629
+#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L
+
+#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig"
+#define NID_setAttr_IssCap_Sig 630
+#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L
+
+#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm"
+#define LN_setAttr_GenCryptgrm "generate cryptogram"
+#define NID_setAttr_GenCryptgrm 631
+#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L
+
+#define SN_setAttr_T2Enc "setAttr-T2Enc"
+#define LN_setAttr_T2Enc "encrypted track 2"
+#define NID_setAttr_T2Enc 632
+#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L
+
+#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt"
+#define LN_setAttr_T2cleartxt "cleartext track 2"
+#define NID_setAttr_T2cleartxt 633
+#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L
+
+#define SN_setAttr_TokICCsig "setAttr-TokICCsig"
+#define LN_setAttr_TokICCsig "ICC or token signature"
+#define NID_setAttr_TokICCsig 634
+#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L
+
+#define SN_setAttr_SecDevSig "setAttr-SecDevSig"
+#define LN_setAttr_SecDevSig "secure device signature"
+#define NID_setAttr_SecDevSig 635
+#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L
+
+#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA"
+#define NID_set_brand_IATA_ATA 636
+#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L
+
+#define SN_set_brand_Diners "set-brand-Diners"
+#define NID_set_brand_Diners 637
+#define OBJ_set_brand_Diners OBJ_set_brand,30L
+
+#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress"
+#define NID_set_brand_AmericanExpress 638
+#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L
+
+#define SN_set_brand_JCB "set-brand-JCB"
+#define NID_set_brand_JCB 639
+#define OBJ_set_brand_JCB OBJ_set_brand,35L
+
+#define SN_set_brand_Visa "set-brand-Visa"
+#define NID_set_brand_Visa 640
+#define OBJ_set_brand_Visa OBJ_set_brand,4L
+
+#define SN_set_brand_MasterCard "set-brand-MasterCard"
+#define NID_set_brand_MasterCard 641
+#define OBJ_set_brand_MasterCard OBJ_set_brand,5L
+
+#define SN_set_brand_Novus "set-brand-Novus"
+#define NID_set_brand_Novus 642
+#define OBJ_set_brand_Novus OBJ_set_brand,6011L
+
+#define SN_des_cdmf "DES-CDMF"
+#define LN_des_cdmf "des-cdmf"
+#define NID_des_cdmf 643
+#define OBJ_des_cdmf OBJ_rsadsi,3L,10L
+
+#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET"
+#define NID_rsaOAEPEncryptionSET 644
+#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L
+
+#define SN_ipsec3 "Oakley-EC2N-3"
+#define LN_ipsec3 "ipsec3"
+#define NID_ipsec3 749
+
+#define SN_ipsec4 "Oakley-EC2N-4"
+#define LN_ipsec4 "ipsec4"
+#define NID_ipsec4 750
+
+#define SN_whirlpool "whirlpool"
+#define NID_whirlpool 804
+#define OBJ_whirlpool OBJ_iso,0L,10118L,3L,0L,55L
+
+#define SN_cryptopro "cryptopro"
+#define NID_cryptopro 805
+#define OBJ_cryptopro OBJ_member_body,643L,2L,2L
+
+#define SN_cryptocom "cryptocom"
+#define NID_cryptocom 806
+#define OBJ_cryptocom OBJ_member_body,643L,2L,9L
+
+#define SN_id_GostR3411_94_with_GostR3410_2001 "id-GostR3411-94-with-GostR3410-2001"
+#define LN_id_GostR3411_94_with_GostR3410_2001 "GOST R 34.11-94 with GOST R 34.10-2001"
+#define NID_id_GostR3411_94_with_GostR3410_2001 807
+#define OBJ_id_GostR3411_94_with_GostR3410_2001 OBJ_cryptopro,3L
+
+#define SN_id_GostR3411_94_with_GostR3410_94 "id-GostR3411-94-with-GostR3410-94"
+#define LN_id_GostR3411_94_with_GostR3410_94 "GOST R 34.11-94 with GOST R 34.10-94"
+#define NID_id_GostR3411_94_with_GostR3410_94 808
+#define OBJ_id_GostR3411_94_with_GostR3410_94 OBJ_cryptopro,4L
+
+#define SN_id_GostR3411_94 "md_gost94"
+#define LN_id_GostR3411_94 "GOST R 34.11-94"
+#define NID_id_GostR3411_94 809
+#define OBJ_id_GostR3411_94 OBJ_cryptopro,9L
+
+#define SN_id_HMACGostR3411_94 "id-HMACGostR3411-94"
+#define LN_id_HMACGostR3411_94 "HMAC GOST 34.11-94"
+#define NID_id_HMACGostR3411_94 810
+#define OBJ_id_HMACGostR3411_94 OBJ_cryptopro,10L
+
+#define SN_id_GostR3410_2001 "gost2001"
+#define LN_id_GostR3410_2001 "GOST R 34.10-2001"
+#define NID_id_GostR3410_2001 811
+#define OBJ_id_GostR3410_2001 OBJ_cryptopro,19L
+
+#define SN_id_GostR3410_94 "gost94"
+#define LN_id_GostR3410_94 "GOST R 34.10-94"
+#define NID_id_GostR3410_94 812
+#define OBJ_id_GostR3410_94 OBJ_cryptopro,20L
+
+#define SN_id_Gost28147_89 "gost89"
+#define LN_id_Gost28147_89 "GOST 28147-89"
+#define NID_id_Gost28147_89 813
+#define OBJ_id_Gost28147_89 OBJ_cryptopro,21L
+
+#define SN_gost89_cnt "gost89-cnt"
+#define NID_gost89_cnt 814
+
+#define SN_id_Gost28147_89_MAC "gost-mac"
+#define LN_id_Gost28147_89_MAC "GOST 28147-89 MAC"
+#define NID_id_Gost28147_89_MAC 815
+#define OBJ_id_Gost28147_89_MAC OBJ_cryptopro,22L
+
+#define SN_id_GostR3411_94_prf "prf-gostr3411-94"
+#define LN_id_GostR3411_94_prf "GOST R 34.11-94 PRF"
+#define NID_id_GostR3411_94_prf 816
+#define OBJ_id_GostR3411_94_prf OBJ_cryptopro,23L
+
+#define SN_id_GostR3410_2001DH "id-GostR3410-2001DH"
+#define LN_id_GostR3410_2001DH "GOST R 34.10-2001 DH"
+#define NID_id_GostR3410_2001DH 817
+#define OBJ_id_GostR3410_2001DH OBJ_cryptopro,98L
+
+#define SN_id_GostR3410_94DH "id-GostR3410-94DH"
+#define LN_id_GostR3410_94DH "GOST R 34.10-94 DH"
+#define NID_id_GostR3410_94DH 818
+#define OBJ_id_GostR3410_94DH OBJ_cryptopro,99L
+
+#define SN_id_Gost28147_89_CryptoPro_KeyMeshing "id-Gost28147-89-CryptoPro-KeyMeshing"
+#define NID_id_Gost28147_89_CryptoPro_KeyMeshing 819
+#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing OBJ_cryptopro,14L,1L
+
+#define SN_id_Gost28147_89_None_KeyMeshing "id-Gost28147-89-None-KeyMeshing"
+#define NID_id_Gost28147_89_None_KeyMeshing 820
+#define OBJ_id_Gost28147_89_None_KeyMeshing OBJ_cryptopro,14L,0L
+
+#define SN_id_GostR3411_94_TestParamSet "id-GostR3411-94-TestParamSet"
+#define NID_id_GostR3411_94_TestParamSet 821
+#define OBJ_id_GostR3411_94_TestParamSet OBJ_cryptopro,30L,0L
+
+#define SN_id_GostR3411_94_CryptoProParamSet "id-GostR3411-94-CryptoProParamSet"
+#define NID_id_GostR3411_94_CryptoProParamSet 822
+#define OBJ_id_GostR3411_94_CryptoProParamSet OBJ_cryptopro,30L,1L
+
+#define SN_id_Gost28147_89_TestParamSet "id-Gost28147-89-TestParamSet"
+#define NID_id_Gost28147_89_TestParamSet 823
+#define OBJ_id_Gost28147_89_TestParamSet OBJ_cryptopro,31L,0L
+
+#define SN_id_Gost28147_89_CryptoPro_A_ParamSet "id-Gost28147-89-CryptoPro-A-ParamSet"
+#define NID_id_Gost28147_89_CryptoPro_A_ParamSet 824
+#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet OBJ_cryptopro,31L,1L
+
+#define SN_id_Gost28147_89_CryptoPro_B_ParamSet "id-Gost28147-89-CryptoPro-B-ParamSet"
+#define NID_id_Gost28147_89_CryptoPro_B_ParamSet 825
+#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet OBJ_cryptopro,31L,2L
+
+#define SN_id_Gost28147_89_CryptoPro_C_ParamSet "id-Gost28147-89-CryptoPro-C-ParamSet"
+#define NID_id_Gost28147_89_CryptoPro_C_ParamSet 826
+#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet OBJ_cryptopro,31L,3L
+
+#define SN_id_Gost28147_89_CryptoPro_D_ParamSet "id-Gost28147-89-CryptoPro-D-ParamSet"
+#define NID_id_Gost28147_89_CryptoPro_D_ParamSet 827
+#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet OBJ_cryptopro,31L,4L
+
+#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet"
+#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet 828
+#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet OBJ_cryptopro,31L,5L
+
+#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet"
+#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet 829
+#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet OBJ_cryptopro,31L,6L
+
+#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet "id-Gost28147-89-CryptoPro-RIC-1-ParamSet"
+#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet 830
+#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet OBJ_cryptopro,31L,7L
+
+#define SN_id_GostR3410_94_TestParamSet "id-GostR3410-94-TestParamSet"
+#define NID_id_GostR3410_94_TestParamSet 831
+#define OBJ_id_GostR3410_94_TestParamSet OBJ_cryptopro,32L,0L
+
+#define SN_id_GostR3410_94_CryptoPro_A_ParamSet "id-GostR3410-94-CryptoPro-A-ParamSet"
+#define NID_id_GostR3410_94_CryptoPro_A_ParamSet 832
+#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet OBJ_cryptopro,32L,2L
+
+#define SN_id_GostR3410_94_CryptoPro_B_ParamSet "id-GostR3410-94-CryptoPro-B-ParamSet"
+#define NID_id_GostR3410_94_CryptoPro_B_ParamSet 833
+#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet OBJ_cryptopro,32L,3L
+
+#define SN_id_GostR3410_94_CryptoPro_C_ParamSet "id-GostR3410-94-CryptoPro-C-ParamSet"
+#define NID_id_GostR3410_94_CryptoPro_C_ParamSet 834
+#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet OBJ_cryptopro,32L,4L
+
+#define SN_id_GostR3410_94_CryptoPro_D_ParamSet "id-GostR3410-94-CryptoPro-D-ParamSet"
+#define NID_id_GostR3410_94_CryptoPro_D_ParamSet 835
+#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet OBJ_cryptopro,32L,5L
+
+#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet "id-GostR3410-94-CryptoPro-XchA-ParamSet"
+#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet 836
+#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet OBJ_cryptopro,33L,1L
+
+#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet "id-GostR3410-94-CryptoPro-XchB-ParamSet"
+#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet 837
+#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet OBJ_cryptopro,33L,2L
+
+#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet "id-GostR3410-94-CryptoPro-XchC-ParamSet"
+#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet 838
+#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet OBJ_cryptopro,33L,3L
+
+#define SN_id_GostR3410_2001_TestParamSet "id-GostR3410-2001-TestParamSet"
+#define NID_id_GostR3410_2001_TestParamSet 839
+#define OBJ_id_GostR3410_2001_TestParamSet OBJ_cryptopro,35L,0L
+
+#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet "id-GostR3410-2001-CryptoPro-A-ParamSet"
+#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet 840
+#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet OBJ_cryptopro,35L,1L
+
+#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet "id-GostR3410-2001-CryptoPro-B-ParamSet"
+#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet 841
+#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet OBJ_cryptopro,35L,2L
+
+#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet "id-GostR3410-2001-CryptoPro-C-ParamSet"
+#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet 842
+#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet OBJ_cryptopro,35L,3L
+
+#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet "id-GostR3410-2001-CryptoPro-XchA-ParamSet"
+#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet 843
+#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet OBJ_cryptopro,36L,0L
+
+#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet "id-GostR3410-2001-CryptoPro-XchB-ParamSet"
+#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet 844
+#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet OBJ_cryptopro,36L,1L
+
+#define SN_id_GostR3410_94_a "id-GostR3410-94-a"
+#define NID_id_GostR3410_94_a 845
+#define OBJ_id_GostR3410_94_a OBJ_id_GostR3410_94,1L
+
+#define SN_id_GostR3410_94_aBis "id-GostR3410-94-aBis"
+#define NID_id_GostR3410_94_aBis 846
+#define OBJ_id_GostR3410_94_aBis OBJ_id_GostR3410_94,2L
+
+#define SN_id_GostR3410_94_b "id-GostR3410-94-b"
+#define NID_id_GostR3410_94_b 847
+#define OBJ_id_GostR3410_94_b OBJ_id_GostR3410_94,3L
+
+#define SN_id_GostR3410_94_bBis "id-GostR3410-94-bBis"
+#define NID_id_GostR3410_94_bBis 848
+#define OBJ_id_GostR3410_94_bBis OBJ_id_GostR3410_94,4L
+
+#define SN_id_Gost28147_89_cc "id-Gost28147-89-cc"
+#define LN_id_Gost28147_89_cc "GOST 28147-89 Cryptocom ParamSet"
+#define NID_id_Gost28147_89_cc 849
+#define OBJ_id_Gost28147_89_cc OBJ_cryptocom,1L,6L,1L
+
+#define SN_id_GostR3410_94_cc "gost94cc"
+#define LN_id_GostR3410_94_cc "GOST 34.10-94 Cryptocom"
+#define NID_id_GostR3410_94_cc 850
+#define OBJ_id_GostR3410_94_cc OBJ_cryptocom,1L,5L,3L
+
+#define SN_id_GostR3410_2001_cc "gost2001cc"
+#define LN_id_GostR3410_2001_cc "GOST 34.10-2001 Cryptocom"
+#define NID_id_GostR3410_2001_cc 851
+#define OBJ_id_GostR3410_2001_cc OBJ_cryptocom,1L,5L,4L
+
+#define SN_id_GostR3411_94_with_GostR3410_94_cc "id-GostR3411-94-with-GostR3410-94-cc"
+#define LN_id_GostR3411_94_with_GostR3410_94_cc "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom"
+#define NID_id_GostR3411_94_with_GostR3410_94_cc 852
+#define OBJ_id_GostR3411_94_with_GostR3410_94_cc OBJ_cryptocom,1L,3L,3L
+
+#define SN_id_GostR3411_94_with_GostR3410_2001_cc "id-GostR3411-94-with-GostR3410-2001-cc"
+#define LN_id_GostR3411_94_with_GostR3410_2001_cc "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom"
+#define NID_id_GostR3411_94_with_GostR3410_2001_cc 853
+#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc OBJ_cryptocom,1L,3L,4L
+
+#define SN_id_GostR3410_2001_ParamSet_cc "id-GostR3410-2001-ParamSet-cc"
+#define LN_id_GostR3410_2001_ParamSet_cc "GOST R 3410-2001 Parameter Set Cryptocom"
+#define NID_id_GostR3410_2001_ParamSet_cc 854
+#define OBJ_id_GostR3410_2001_ParamSet_cc OBJ_cryptocom,1L,8L,1L
+
+#define SN_camellia_128_cbc "CAMELLIA-128-CBC"
+#define LN_camellia_128_cbc "camellia-128-cbc"
+#define NID_camellia_128_cbc 751
+#define OBJ_camellia_128_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,2L
+
+#define SN_camellia_192_cbc "CAMELLIA-192-CBC"
+#define LN_camellia_192_cbc "camellia-192-cbc"
+#define NID_camellia_192_cbc 752
+#define OBJ_camellia_192_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,3L
+
+#define SN_camellia_256_cbc "CAMELLIA-256-CBC"
+#define LN_camellia_256_cbc "camellia-256-cbc"
+#define NID_camellia_256_cbc 753
+#define OBJ_camellia_256_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,4L
+
+#define OBJ_ntt_ds 0L,3L,4401L,5L
+
+#define OBJ_camellia OBJ_ntt_ds,3L,1L,9L
+
+#define SN_camellia_128_ecb "CAMELLIA-128-ECB"
+#define LN_camellia_128_ecb "camellia-128-ecb"
+#define NID_camellia_128_ecb 754
+#define OBJ_camellia_128_ecb OBJ_camellia,1L
+
+#define SN_camellia_128_ofb128 "CAMELLIA-128-OFB"
+#define LN_camellia_128_ofb128 "camellia-128-ofb"
+#define NID_camellia_128_ofb128 766
+#define OBJ_camellia_128_ofb128 OBJ_camellia,3L
+
+#define SN_camellia_128_cfb128 "CAMELLIA-128-CFB"
+#define LN_camellia_128_cfb128 "camellia-128-cfb"
+#define NID_camellia_128_cfb128 757
+#define OBJ_camellia_128_cfb128 OBJ_camellia,4L
+
+#define SN_camellia_192_ecb "CAMELLIA-192-ECB"
+#define LN_camellia_192_ecb "camellia-192-ecb"
+#define NID_camellia_192_ecb 755
+#define OBJ_camellia_192_ecb OBJ_camellia,21L
+
+#define SN_camellia_192_ofb128 "CAMELLIA-192-OFB"
+#define LN_camellia_192_ofb128 "camellia-192-ofb"
+#define NID_camellia_192_ofb128 767
+#define OBJ_camellia_192_ofb128 OBJ_camellia,23L
+
+#define SN_camellia_192_cfb128 "CAMELLIA-192-CFB"
+#define LN_camellia_192_cfb128 "camellia-192-cfb"
+#define NID_camellia_192_cfb128 758
+#define OBJ_camellia_192_cfb128 OBJ_camellia,24L
+
+#define SN_camellia_256_ecb "CAMELLIA-256-ECB"
+#define LN_camellia_256_ecb "camellia-256-ecb"
+#define NID_camellia_256_ecb 756
+#define OBJ_camellia_256_ecb OBJ_camellia,41L
+
+#define SN_camellia_256_ofb128 "CAMELLIA-256-OFB"
+#define LN_camellia_256_ofb128 "camellia-256-ofb"
+#define NID_camellia_256_ofb128 768
+#define OBJ_camellia_256_ofb128 OBJ_camellia,43L
+
+#define SN_camellia_256_cfb128 "CAMELLIA-256-CFB"
+#define LN_camellia_256_cfb128 "camellia-256-cfb"
+#define NID_camellia_256_cfb128 759
+#define OBJ_camellia_256_cfb128 OBJ_camellia,44L
+
+#define SN_camellia_128_cfb1 "CAMELLIA-128-CFB1"
+#define LN_camellia_128_cfb1 "camellia-128-cfb1"
+#define NID_camellia_128_cfb1 760
+
+#define SN_camellia_192_cfb1 "CAMELLIA-192-CFB1"
+#define LN_camellia_192_cfb1 "camellia-192-cfb1"
+#define NID_camellia_192_cfb1 761
+
+#define SN_camellia_256_cfb1 "CAMELLIA-256-CFB1"
+#define LN_camellia_256_cfb1 "camellia-256-cfb1"
+#define NID_camellia_256_cfb1 762
+
+#define SN_camellia_128_cfb8 "CAMELLIA-128-CFB8"
+#define LN_camellia_128_cfb8 "camellia-128-cfb8"
+#define NID_camellia_128_cfb8 763
+
+#define SN_camellia_192_cfb8 "CAMELLIA-192-CFB8"
+#define LN_camellia_192_cfb8 "camellia-192-cfb8"
+#define NID_camellia_192_cfb8 764
+
+#define SN_camellia_256_cfb8 "CAMELLIA-256-CFB8"
+#define LN_camellia_256_cfb8 "camellia-256-cfb8"
+#define NID_camellia_256_cfb8 765
+
+#define SN_kisa "KISA"
+#define LN_kisa "kisa"
+#define NID_kisa 773
+#define OBJ_kisa OBJ_member_body,410L,200004L
+
+#define SN_seed_ecb "SEED-ECB"
+#define LN_seed_ecb "seed-ecb"
+#define NID_seed_ecb 776
+#define OBJ_seed_ecb OBJ_kisa,1L,3L
+
+#define SN_seed_cbc "SEED-CBC"
+#define LN_seed_cbc "seed-cbc"
+#define NID_seed_cbc 777
+#define OBJ_seed_cbc OBJ_kisa,1L,4L
+
+#define SN_seed_cfb128 "SEED-CFB"
+#define LN_seed_cfb128 "seed-cfb"
+#define NID_seed_cfb128 779
+#define OBJ_seed_cfb128 OBJ_kisa,1L,5L
+
+#define SN_seed_ofb128 "SEED-OFB"
+#define LN_seed_ofb128 "seed-ofb"
+#define NID_seed_ofb128 778
+#define OBJ_seed_ofb128 OBJ_kisa,1L,6L
+
+#define SN_hmac "HMAC"
+#define LN_hmac "hmac"
+#define NID_hmac 855
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/objects.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/objects.h
new file mode 100644
index 000000000..7242f76fb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/objects.h
@@ -0,0 +1,1049 @@
+/* crypto/objects/objects.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_OBJECTS_H
+#define HEADER_OBJECTS_H
+
+#define USE_OBJ_MAC
+
+#ifdef USE_OBJ_MAC
+#include <openssl/obj_mac.h>
+#else
+#define SN_undef "UNDEF"
+#define LN_undef "undefined"
+#define NID_undef 0
+#define OBJ_undef 0L
+
+#define SN_Algorithm "Algorithm"
+#define LN_algorithm "algorithm"
+#define NID_algorithm 38
+#define OBJ_algorithm 1L,3L,14L,3L,2L
+
+#define LN_rsadsi "rsadsi"
+#define NID_rsadsi 1
+#define OBJ_rsadsi 1L,2L,840L,113549L
+
+#define LN_pkcs "pkcs"
+#define NID_pkcs 2
+#define OBJ_pkcs OBJ_rsadsi,1L
+
+#define SN_md2 "MD2"
+#define LN_md2 "md2"
+#define NID_md2 3
+#define OBJ_md2 OBJ_rsadsi,2L,2L
+
+#define SN_md5 "MD5"
+#define LN_md5 "md5"
+#define NID_md5 4
+#define OBJ_md5 OBJ_rsadsi,2L,5L
+
+#define SN_rc4 "RC4"
+#define LN_rc4 "rc4"
+#define NID_rc4 5
+#define OBJ_rc4 OBJ_rsadsi,3L,4L
+
+#define LN_rsaEncryption "rsaEncryption"
+#define NID_rsaEncryption 6
+#define OBJ_rsaEncryption OBJ_pkcs,1L,1L
+
+#define SN_md2WithRSAEncryption "RSA-MD2"
+#define LN_md2WithRSAEncryption "md2WithRSAEncryption"
+#define NID_md2WithRSAEncryption 7
+#define OBJ_md2WithRSAEncryption OBJ_pkcs,1L,2L
+
+#define SN_md5WithRSAEncryption "RSA-MD5"
+#define LN_md5WithRSAEncryption "md5WithRSAEncryption"
+#define NID_md5WithRSAEncryption 8
+#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L
+
+#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES"
+#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC"
+#define NID_pbeWithMD2AndDES_CBC 9
+#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L
+
+#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES"
+#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC"
+#define NID_pbeWithMD5AndDES_CBC 10
+#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L
+
+#define LN_X500 "X500"
+#define NID_X500 11
+#define OBJ_X500 2L,5L
+
+#define LN_X509 "X509"
+#define NID_X509 12
+#define OBJ_X509 OBJ_X500,4L
+
+#define SN_commonName "CN"
+#define LN_commonName "commonName"
+#define NID_commonName 13
+#define OBJ_commonName OBJ_X509,3L
+
+#define SN_countryName "C"
+#define LN_countryName "countryName"
+#define NID_countryName 14
+#define OBJ_countryName OBJ_X509,6L
+
+#define SN_localityName "L"
+#define LN_localityName "localityName"
+#define NID_localityName 15
+#define OBJ_localityName OBJ_X509,7L
+
+/* Postal Address? PA */
+
+/* should be "ST" (rfc1327) but MS uses 'S' */
+#define SN_stateOrProvinceName "ST"
+#define LN_stateOrProvinceName "stateOrProvinceName"
+#define NID_stateOrProvinceName 16
+#define OBJ_stateOrProvinceName OBJ_X509,8L
+
+#define SN_organizationName "O"
+#define LN_organizationName "organizationName"
+#define NID_organizationName 17
+#define OBJ_organizationName OBJ_X509,10L
+
+#define SN_organizationalUnitName "OU"
+#define LN_organizationalUnitName "organizationalUnitName"
+#define NID_organizationalUnitName 18
+#define OBJ_organizationalUnitName OBJ_X509,11L
+
+#define SN_rsa "RSA"
+#define LN_rsa "rsa"
+#define NID_rsa 19
+#define OBJ_rsa OBJ_X500,8L,1L,1L
+
+#define LN_pkcs7 "pkcs7"
+#define NID_pkcs7 20
+#define OBJ_pkcs7 OBJ_pkcs,7L
+
+#define LN_pkcs7_data "pkcs7-data"
+#define NID_pkcs7_data 21
+#define OBJ_pkcs7_data OBJ_pkcs7,1L
+
+#define LN_pkcs7_signed "pkcs7-signedData"
+#define NID_pkcs7_signed 22
+#define OBJ_pkcs7_signed OBJ_pkcs7,2L
+
+#define LN_pkcs7_enveloped "pkcs7-envelopedData"
+#define NID_pkcs7_enveloped 23
+#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L
+
+#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData"
+#define NID_pkcs7_signedAndEnveloped 24
+#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L
+
+#define LN_pkcs7_digest "pkcs7-digestData"
+#define NID_pkcs7_digest 25
+#define OBJ_pkcs7_digest OBJ_pkcs7,5L
+
+#define LN_pkcs7_encrypted "pkcs7-encryptedData"
+#define NID_pkcs7_encrypted 26
+#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L
+
+#define LN_pkcs3 "pkcs3"
+#define NID_pkcs3 27
+#define OBJ_pkcs3 OBJ_pkcs,3L
+
+#define LN_dhKeyAgreement "dhKeyAgreement"
+#define NID_dhKeyAgreement 28
+#define OBJ_dhKeyAgreement OBJ_pkcs3,1L
+
+#define SN_des_ecb "DES-ECB"
+#define LN_des_ecb "des-ecb"
+#define NID_des_ecb 29
+#define OBJ_des_ecb OBJ_algorithm,6L
+
+#define SN_des_cfb64 "DES-CFB"
+#define LN_des_cfb64 "des-cfb"
+#define NID_des_cfb64 30
+/* IV + num */
+#define OBJ_des_cfb64 OBJ_algorithm,9L
+
+#define SN_des_cbc "DES-CBC"
+#define LN_des_cbc "des-cbc"
+#define NID_des_cbc 31
+/* IV */
+#define OBJ_des_cbc OBJ_algorithm,7L
+
+#define SN_des_ede "DES-EDE"
+#define LN_des_ede "des-ede"
+#define NID_des_ede 32
+/* ?? */
+#define OBJ_des_ede OBJ_algorithm,17L
+
+#define SN_des_ede3 "DES-EDE3"
+#define LN_des_ede3 "des-ede3"
+#define NID_des_ede3 33
+
+#define SN_idea_cbc "IDEA-CBC"
+#define LN_idea_cbc "idea-cbc"
+#define NID_idea_cbc 34
+#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L
+
+#define SN_idea_cfb64 "IDEA-CFB"
+#define LN_idea_cfb64 "idea-cfb"
+#define NID_idea_cfb64 35
+
+#define SN_idea_ecb "IDEA-ECB"
+#define LN_idea_ecb "idea-ecb"
+#define NID_idea_ecb 36
+
+#define SN_rc2_cbc "RC2-CBC"
+#define LN_rc2_cbc "rc2-cbc"
+#define NID_rc2_cbc 37
+#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L
+
+#define SN_rc2_ecb "RC2-ECB"
+#define LN_rc2_ecb "rc2-ecb"
+#define NID_rc2_ecb 38
+
+#define SN_rc2_cfb64 "RC2-CFB"
+#define LN_rc2_cfb64 "rc2-cfb"
+#define NID_rc2_cfb64 39
+
+#define SN_rc2_ofb64 "RC2-OFB"
+#define LN_rc2_ofb64 "rc2-ofb"
+#define NID_rc2_ofb64 40
+
+#define SN_sha "SHA"
+#define LN_sha "sha"
+#define NID_sha 41
+#define OBJ_sha OBJ_algorithm,18L
+
+#define SN_shaWithRSAEncryption "RSA-SHA"
+#define LN_shaWithRSAEncryption "shaWithRSAEncryption"
+#define NID_shaWithRSAEncryption 42
+#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L
+
+#define SN_des_ede_cbc "DES-EDE-CBC"
+#define LN_des_ede_cbc "des-ede-cbc"
+#define NID_des_ede_cbc 43
+
+#define SN_des_ede3_cbc "DES-EDE3-CBC"
+#define LN_des_ede3_cbc "des-ede3-cbc"
+#define NID_des_ede3_cbc 44
+#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L
+
+#define SN_des_ofb64 "DES-OFB"
+#define LN_des_ofb64 "des-ofb"
+#define NID_des_ofb64 45
+#define OBJ_des_ofb64 OBJ_algorithm,8L
+
+#define SN_idea_ofb64 "IDEA-OFB"
+#define LN_idea_ofb64 "idea-ofb"
+#define NID_idea_ofb64 46
+
+#define LN_pkcs9 "pkcs9"
+#define NID_pkcs9 47
+#define OBJ_pkcs9 OBJ_pkcs,9L
+
+#define SN_pkcs9_emailAddress "Email"
+#define LN_pkcs9_emailAddress "emailAddress"
+#define NID_pkcs9_emailAddress 48
+#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L
+
+#define LN_pkcs9_unstructuredName "unstructuredName"
+#define NID_pkcs9_unstructuredName 49
+#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L
+
+#define LN_pkcs9_contentType "contentType"
+#define NID_pkcs9_contentType 50
+#define OBJ_pkcs9_contentType OBJ_pkcs9,3L
+
+#define LN_pkcs9_messageDigest "messageDigest"
+#define NID_pkcs9_messageDigest 51
+#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L
+
+#define LN_pkcs9_signingTime "signingTime"
+#define NID_pkcs9_signingTime 52
+#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L
+
+#define LN_pkcs9_countersignature "countersignature"
+#define NID_pkcs9_countersignature 53
+#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L
+
+#define LN_pkcs9_challengePassword "challengePassword"
+#define NID_pkcs9_challengePassword 54
+#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L
+
+#define LN_pkcs9_unstructuredAddress "unstructuredAddress"
+#define NID_pkcs9_unstructuredAddress 55
+#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L
+
+#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes"
+#define NID_pkcs9_extCertAttributes 56
+#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L
+
+#define SN_netscape "Netscape"
+#define LN_netscape "Netscape Communications Corp."
+#define NID_netscape 57
+#define OBJ_netscape 2L,16L,840L,1L,113730L
+
+#define SN_netscape_cert_extension "nsCertExt"
+#define LN_netscape_cert_extension "Netscape Certificate Extension"
+#define NID_netscape_cert_extension 58
+#define OBJ_netscape_cert_extension OBJ_netscape,1L
+
+#define SN_netscape_data_type "nsDataType"
+#define LN_netscape_data_type "Netscape Data Type"
+#define NID_netscape_data_type 59
+#define OBJ_netscape_data_type OBJ_netscape,2L
+
+#define SN_des_ede_cfb64 "DES-EDE-CFB"
+#define LN_des_ede_cfb64 "des-ede-cfb"
+#define NID_des_ede_cfb64 60
+
+#define SN_des_ede3_cfb64 "DES-EDE3-CFB"
+#define LN_des_ede3_cfb64 "des-ede3-cfb"
+#define NID_des_ede3_cfb64 61
+
+#define SN_des_ede_ofb64 "DES-EDE-OFB"
+#define LN_des_ede_ofb64 "des-ede-ofb"
+#define NID_des_ede_ofb64 62
+
+#define SN_des_ede3_ofb64 "DES-EDE3-OFB"
+#define LN_des_ede3_ofb64 "des-ede3-ofb"
+#define NID_des_ede3_ofb64 63
+
+/* I'm not sure about the object ID */
+#define SN_sha1 "SHA1"
+#define LN_sha1 "sha1"
+#define NID_sha1 64
+#define OBJ_sha1 OBJ_algorithm,26L
+/* 28 Jun 1996 - eay */
+/* #define OBJ_sha1 1L,3L,14L,2L,26L,05L <- wrong */
+
+#define SN_sha1WithRSAEncryption "RSA-SHA1"
+#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption"
+#define NID_sha1WithRSAEncryption 65
+#define OBJ_sha1WithRSAEncryption OBJ_pkcs,1L,5L
+
+#define SN_dsaWithSHA "DSA-SHA"
+#define LN_dsaWithSHA "dsaWithSHA"
+#define NID_dsaWithSHA 66
+#define OBJ_dsaWithSHA OBJ_algorithm,13L
+
+#define SN_dsa_2 "DSA-old"
+#define LN_dsa_2 "dsaEncryption-old"
+#define NID_dsa_2 67
+#define OBJ_dsa_2 OBJ_algorithm,12L
+
+/* proposed by microsoft to RSA */
+#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64"
+#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC"
+#define NID_pbeWithSHA1AndRC2_CBC 68
+#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L
+
+/* proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now
+ * defined explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something
+ * completely different.
+ */
+#define LN_id_pbkdf2 "PBKDF2"
+#define NID_id_pbkdf2 69
+#define OBJ_id_pbkdf2 OBJ_pkcs,5L,12L
+
+#define SN_dsaWithSHA1_2 "DSA-SHA1-old"
+#define LN_dsaWithSHA1_2 "dsaWithSHA1-old"
+#define NID_dsaWithSHA1_2 70
+/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */
+#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L
+
+#define SN_netscape_cert_type "nsCertType"
+#define LN_netscape_cert_type "Netscape Cert Type"
+#define NID_netscape_cert_type 71
+#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L
+
+#define SN_netscape_base_url "nsBaseUrl"
+#define LN_netscape_base_url "Netscape Base Url"
+#define NID_netscape_base_url 72
+#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L
+
+#define SN_netscape_revocation_url "nsRevocationUrl"
+#define LN_netscape_revocation_url "Netscape Revocation Url"
+#define NID_netscape_revocation_url 73
+#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L
+
+#define SN_netscape_ca_revocation_url "nsCaRevocationUrl"
+#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url"
+#define NID_netscape_ca_revocation_url 74
+#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L
+
+#define SN_netscape_renewal_url "nsRenewalUrl"
+#define LN_netscape_renewal_url "Netscape Renewal Url"
+#define NID_netscape_renewal_url 75
+#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L
+
+#define SN_netscape_ca_policy_url "nsCaPolicyUrl"
+#define LN_netscape_ca_policy_url "Netscape CA Policy Url"
+#define NID_netscape_ca_policy_url 76
+#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L
+
+#define SN_netscape_ssl_server_name "nsSslServerName"
+#define LN_netscape_ssl_server_name "Netscape SSL Server Name"
+#define NID_netscape_ssl_server_name 77
+#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L
+
+#define SN_netscape_comment "nsComment"
+#define LN_netscape_comment "Netscape Comment"
+#define NID_netscape_comment 78
+#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L
+
+#define SN_netscape_cert_sequence "nsCertSequence"
+#define LN_netscape_cert_sequence "Netscape Certificate Sequence"
+#define NID_netscape_cert_sequence 79
+#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L
+
+#define SN_desx_cbc "DESX-CBC"
+#define LN_desx_cbc "desx-cbc"
+#define NID_desx_cbc 80
+
+#define SN_id_ce "id-ce"
+#define NID_id_ce 81
+#define OBJ_id_ce 2L,5L,29L
+
+#define SN_subject_key_identifier "subjectKeyIdentifier"
+#define LN_subject_key_identifier "X509v3 Subject Key Identifier"
+#define NID_subject_key_identifier 82
+#define OBJ_subject_key_identifier OBJ_id_ce,14L
+
+#define SN_key_usage "keyUsage"
+#define LN_key_usage "X509v3 Key Usage"
+#define NID_key_usage 83
+#define OBJ_key_usage OBJ_id_ce,15L
+
+#define SN_private_key_usage_period "privateKeyUsagePeriod"
+#define LN_private_key_usage_period "X509v3 Private Key Usage Period"
+#define NID_private_key_usage_period 84
+#define OBJ_private_key_usage_period OBJ_id_ce,16L
+
+#define SN_subject_alt_name "subjectAltName"
+#define LN_subject_alt_name "X509v3 Subject Alternative Name"
+#define NID_subject_alt_name 85
+#define OBJ_subject_alt_name OBJ_id_ce,17L
+
+#define SN_issuer_alt_name "issuerAltName"
+#define LN_issuer_alt_name "X509v3 Issuer Alternative Name"
+#define NID_issuer_alt_name 86
+#define OBJ_issuer_alt_name OBJ_id_ce,18L
+
+#define SN_basic_constraints "basicConstraints"
+#define LN_basic_constraints "X509v3 Basic Constraints"
+#define NID_basic_constraints 87
+#define OBJ_basic_constraints OBJ_id_ce,19L
+
+#define SN_crl_number "crlNumber"
+#define LN_crl_number "X509v3 CRL Number"
+#define NID_crl_number 88
+#define OBJ_crl_number OBJ_id_ce,20L
+
+#define SN_certificate_policies "certificatePolicies"
+#define LN_certificate_policies "X509v3 Certificate Policies"
+#define NID_certificate_policies 89
+#define OBJ_certificate_policies OBJ_id_ce,32L
+
+#define SN_authority_key_identifier "authorityKeyIdentifier"
+#define LN_authority_key_identifier "X509v3 Authority Key Identifier"
+#define NID_authority_key_identifier 90
+#define OBJ_authority_key_identifier OBJ_id_ce,35L
+
+#define SN_bf_cbc "BF-CBC"
+#define LN_bf_cbc "bf-cbc"
+#define NID_bf_cbc 91
+#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L
+
+#define SN_bf_ecb "BF-ECB"
+#define LN_bf_ecb "bf-ecb"
+#define NID_bf_ecb 92
+
+#define SN_bf_cfb64 "BF-CFB"
+#define LN_bf_cfb64 "bf-cfb"
+#define NID_bf_cfb64 93
+
+#define SN_bf_ofb64 "BF-OFB"
+#define LN_bf_ofb64 "bf-ofb"
+#define NID_bf_ofb64 94
+
+#define SN_mdc2 "MDC2"
+#define LN_mdc2 "mdc2"
+#define NID_mdc2 95
+#define OBJ_mdc2 2L,5L,8L,3L,101L
+/* An alternative? 1L,3L,14L,3L,2L,19L */
+
+#define SN_mdc2WithRSA "RSA-MDC2"
+#define LN_mdc2WithRSA "mdc2withRSA"
+#define NID_mdc2WithRSA 96
+#define OBJ_mdc2WithRSA 2L,5L,8L,3L,100L
+
+#define SN_rc4_40 "RC4-40"
+#define LN_rc4_40 "rc4-40"
+#define NID_rc4_40 97
+
+#define SN_rc2_40_cbc "RC2-40-CBC"
+#define LN_rc2_40_cbc "rc2-40-cbc"
+#define NID_rc2_40_cbc 98
+
+#define SN_givenName "G"
+#define LN_givenName "givenName"
+#define NID_givenName 99
+#define OBJ_givenName OBJ_X509,42L
+
+#define SN_surname "S"
+#define LN_surname "surname"
+#define NID_surname 100
+#define OBJ_surname OBJ_X509,4L
+
+#define SN_initials "I"
+#define LN_initials "initials"
+#define NID_initials 101
+#define OBJ_initials OBJ_X509,43L
+
+#define SN_uniqueIdentifier "UID"
+#define LN_uniqueIdentifier "uniqueIdentifier"
+#define NID_uniqueIdentifier 102
+#define OBJ_uniqueIdentifier OBJ_X509,45L
+
+#define SN_crl_distribution_points "crlDistributionPoints"
+#define LN_crl_distribution_points "X509v3 CRL Distribution Points"
+#define NID_crl_distribution_points 103
+#define OBJ_crl_distribution_points OBJ_id_ce,31L
+
+#define SN_md5WithRSA "RSA-NP-MD5"
+#define LN_md5WithRSA "md5WithRSA"
+#define NID_md5WithRSA 104
+#define OBJ_md5WithRSA OBJ_algorithm,3L
+
+#define SN_serialNumber "SN"
+#define LN_serialNumber "serialNumber"
+#define NID_serialNumber 105
+#define OBJ_serialNumber OBJ_X509,5L
+
+#define SN_title "T"
+#define LN_title "title"
+#define NID_title 106
+#define OBJ_title OBJ_X509,12L
+
+#define SN_description "D"
+#define LN_description "description"
+#define NID_description 107
+#define OBJ_description OBJ_X509,13L
+
+/* CAST5 is CAST-128, I'm just sticking with the documentation */
+#define SN_cast5_cbc "CAST5-CBC"
+#define LN_cast5_cbc "cast5-cbc"
+#define NID_cast5_cbc 108
+#define OBJ_cast5_cbc 1L,2L,840L,113533L,7L,66L,10L
+
+#define SN_cast5_ecb "CAST5-ECB"
+#define LN_cast5_ecb "cast5-ecb"
+#define NID_cast5_ecb 109
+
+#define SN_cast5_cfb64 "CAST5-CFB"
+#define LN_cast5_cfb64 "cast5-cfb"
+#define NID_cast5_cfb64 110
+
+#define SN_cast5_ofb64 "CAST5-OFB"
+#define LN_cast5_ofb64 "cast5-ofb"
+#define NID_cast5_ofb64 111
+
+#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC"
+#define NID_pbeWithMD5AndCast5_CBC 112
+#define OBJ_pbeWithMD5AndCast5_CBC 1L,2L,840L,113533L,7L,66L,12L
+
+/* This is one sun will soon be using :-(
+ * id-dsa-with-sha1 ID ::= {
+ * iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 }
+ */
+#define SN_dsaWithSHA1 "DSA-SHA1"
+#define LN_dsaWithSHA1 "dsaWithSHA1"
+#define NID_dsaWithSHA1 113
+#define OBJ_dsaWithSHA1 1L,2L,840L,10040L,4L,3L
+
+#define NID_md5_sha1 114
+#define SN_md5_sha1 "MD5-SHA1"
+#define LN_md5_sha1 "md5-sha1"
+
+#define SN_sha1WithRSA "RSA-SHA1-2"
+#define LN_sha1WithRSA "sha1WithRSA"
+#define NID_sha1WithRSA 115
+#define OBJ_sha1WithRSA OBJ_algorithm,29L
+
+#define SN_dsa "DSA"
+#define LN_dsa "dsaEncryption"
+#define NID_dsa 116
+#define OBJ_dsa 1L,2L,840L,10040L,4L,1L
+
+#define SN_ripemd160 "RIPEMD160"
+#define LN_ripemd160 "ripemd160"
+#define NID_ripemd160 117
+#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L
+
+/* The name should actually be rsaSignatureWithripemd160, but I'm going
+ * to continue using the convention I'm using with the other ciphers */
+#define SN_ripemd160WithRSA "RSA-RIPEMD160"
+#define LN_ripemd160WithRSA "ripemd160WithRSA"
+#define NID_ripemd160WithRSA 119
+#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L
+
+/* Taken from rfc2040
+ * RC5_CBC_Parameters ::= SEQUENCE {
+ * version INTEGER (v1_0(16)),
+ * rounds INTEGER (8..127),
+ * blockSizeInBits INTEGER (64, 128),
+ * iv OCTET STRING OPTIONAL
+ * }
+ */
+#define SN_rc5_cbc "RC5-CBC"
+#define LN_rc5_cbc "rc5-cbc"
+#define NID_rc5_cbc 120
+#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L
+
+#define SN_rc5_ecb "RC5-ECB"
+#define LN_rc5_ecb "rc5-ecb"
+#define NID_rc5_ecb 121
+
+#define SN_rc5_cfb64 "RC5-CFB"
+#define LN_rc5_cfb64 "rc5-cfb"
+#define NID_rc5_cfb64 122
+
+#define SN_rc5_ofb64 "RC5-OFB"
+#define LN_rc5_ofb64 "rc5-ofb"
+#define NID_rc5_ofb64 123
+
+#define SN_rle_compression "RLE"
+#define LN_rle_compression "run length compression"
+#define NID_rle_compression 124
+#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L
+
+#define SN_zlib_compression "ZLIB"
+#define LN_zlib_compression "zlib compression"
+#define NID_zlib_compression 125
+#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L
+
+#define SN_ext_key_usage "extendedKeyUsage"
+#define LN_ext_key_usage "X509v3 Extended Key Usage"
+#define NID_ext_key_usage 126
+#define OBJ_ext_key_usage OBJ_id_ce,37
+
+#define SN_id_pkix "PKIX"
+#define NID_id_pkix 127
+#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L
+
+#define SN_id_kp "id-kp"
+#define NID_id_kp 128
+#define OBJ_id_kp OBJ_id_pkix,3L
+
+/* PKIX extended key usage OIDs */
+
+#define SN_server_auth "serverAuth"
+#define LN_server_auth "TLS Web Server Authentication"
+#define NID_server_auth 129
+#define OBJ_server_auth OBJ_id_kp,1L
+
+#define SN_client_auth "clientAuth"
+#define LN_client_auth "TLS Web Client Authentication"
+#define NID_client_auth 130
+#define OBJ_client_auth OBJ_id_kp,2L
+
+#define SN_code_sign "codeSigning"
+#define LN_code_sign "Code Signing"
+#define NID_code_sign 131
+#define OBJ_code_sign OBJ_id_kp,3L
+
+#define SN_email_protect "emailProtection"
+#define LN_email_protect "E-mail Protection"
+#define NID_email_protect 132
+#define OBJ_email_protect OBJ_id_kp,4L
+
+#define SN_time_stamp "timeStamping"
+#define LN_time_stamp "Time Stamping"
+#define NID_time_stamp 133
+#define OBJ_time_stamp OBJ_id_kp,8L
+
+/* Additional extended key usage OIDs: Microsoft */
+
+#define SN_ms_code_ind "msCodeInd"
+#define LN_ms_code_ind "Microsoft Individual Code Signing"
+#define NID_ms_code_ind 134
+#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L
+
+#define SN_ms_code_com "msCodeCom"
+#define LN_ms_code_com "Microsoft Commercial Code Signing"
+#define NID_ms_code_com 135
+#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L
+
+#define SN_ms_ctl_sign "msCTLSign"
+#define LN_ms_ctl_sign "Microsoft Trust List Signing"
+#define NID_ms_ctl_sign 136
+#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L
+
+#define SN_ms_sgc "msSGC"
+#define LN_ms_sgc "Microsoft Server Gated Crypto"
+#define NID_ms_sgc 137
+#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L
+
+#define SN_ms_efs "msEFS"
+#define LN_ms_efs "Microsoft Encrypted File System"
+#define NID_ms_efs 138
+#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L
+
+/* Additional usage: Netscape */
+
+#define SN_ns_sgc "nsSGC"
+#define LN_ns_sgc "Netscape Server Gated Crypto"
+#define NID_ns_sgc 139
+#define OBJ_ns_sgc OBJ_netscape,4L,1L
+
+#define SN_delta_crl "deltaCRL"
+#define LN_delta_crl "X509v3 Delta CRL Indicator"
+#define NID_delta_crl 140
+#define OBJ_delta_crl OBJ_id_ce,27L
+
+#define SN_crl_reason "CRLReason"
+#define LN_crl_reason "CRL Reason Code"
+#define NID_crl_reason 141
+#define OBJ_crl_reason OBJ_id_ce,21L
+
+#define SN_invalidity_date "invalidityDate"
+#define LN_invalidity_date "Invalidity Date"
+#define NID_invalidity_date 142
+#define OBJ_invalidity_date OBJ_id_ce,24L
+
+#define SN_sxnet "SXNetID"
+#define LN_sxnet "Strong Extranet ID"
+#define NID_sxnet 143
+#define OBJ_sxnet 1L,3L,101L,1L,4L,1L
+
+/* PKCS12 and related OBJECT IDENTIFIERS */
+
+#define OBJ_pkcs12 OBJ_pkcs,12L
+#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1
+
+#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128"
+#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4"
+#define NID_pbe_WithSHA1And128BitRC4 144
+#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L
+
+#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40"
+#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4"
+#define NID_pbe_WithSHA1And40BitRC4 145
+#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L
+
+#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES"
+#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC"
+#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146
+#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L
+
+#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES"
+#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC"
+#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147
+#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L
+
+#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128"
+#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC"
+#define NID_pbe_WithSHA1And128BitRC2_CBC 148
+#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L
+
+#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40"
+#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC"
+#define NID_pbe_WithSHA1And40BitRC2_CBC 149
+#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L
+
+#define OBJ_pkcs12_Version1 OBJ_pkcs12, 10L
+
+#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1, 1L
+
+#define LN_keyBag "keyBag"
+#define NID_keyBag 150
+#define OBJ_keyBag OBJ_pkcs12_BagIds, 1L
+
+#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag"
+#define NID_pkcs8ShroudedKeyBag 151
+#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L
+
+#define LN_certBag "certBag"
+#define NID_certBag 152
+#define OBJ_certBag OBJ_pkcs12_BagIds, 3L
+
+#define LN_crlBag "crlBag"
+#define NID_crlBag 153
+#define OBJ_crlBag OBJ_pkcs12_BagIds, 4L
+
+#define LN_secretBag "secretBag"
+#define NID_secretBag 154
+#define OBJ_secretBag OBJ_pkcs12_BagIds, 5L
+
+#define LN_safeContentsBag "safeContentsBag"
+#define NID_safeContentsBag 155
+#define OBJ_safeContentsBag OBJ_pkcs12_BagIds, 6L
+
+#define LN_friendlyName "friendlyName"
+#define NID_friendlyName 156
+#define OBJ_friendlyName OBJ_pkcs9, 20L
+
+#define LN_localKeyID "localKeyID"
+#define NID_localKeyID 157
+#define OBJ_localKeyID OBJ_pkcs9, 21L
+
+#define OBJ_certTypes OBJ_pkcs9, 22L
+
+#define LN_x509Certificate "x509Certificate"
+#define NID_x509Certificate 158
+#define OBJ_x509Certificate OBJ_certTypes, 1L
+
+#define LN_sdsiCertificate "sdsiCertificate"
+#define NID_sdsiCertificate 159
+#define OBJ_sdsiCertificate OBJ_certTypes, 2L
+
+#define OBJ_crlTypes OBJ_pkcs9, 23L
+
+#define LN_x509Crl "x509Crl"
+#define NID_x509Crl 160
+#define OBJ_x509Crl OBJ_crlTypes, 1L
+
+/* PKCS#5 v2 OIDs */
+
+#define LN_pbes2 "PBES2"
+#define NID_pbes2 161
+#define OBJ_pbes2 OBJ_pkcs,5L,13L
+
+#define LN_pbmac1 "PBMAC1"
+#define NID_pbmac1 162
+#define OBJ_pbmac1 OBJ_pkcs,5L,14L
+
+#define LN_hmacWithSHA1 "hmacWithSHA1"
+#define NID_hmacWithSHA1 163
+#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L
+
+/* Policy Qualifier Ids */
+
+#define LN_id_qt_cps "Policy Qualifier CPS"
+#define SN_id_qt_cps "id-qt-cps"
+#define NID_id_qt_cps 164
+#define OBJ_id_qt_cps OBJ_id_pkix,2L,1L
+
+#define LN_id_qt_unotice "Policy Qualifier User Notice"
+#define SN_id_qt_unotice "id-qt-unotice"
+#define NID_id_qt_unotice 165
+#define OBJ_id_qt_unotice OBJ_id_pkix,2L,2L
+
+#define SN_rc2_64_cbc "RC2-64-CBC"
+#define LN_rc2_64_cbc "rc2-64-cbc"
+#define NID_rc2_64_cbc 166
+
+#define SN_SMIMECapabilities "SMIME-CAPS"
+#define LN_SMIMECapabilities "S/MIME Capabilities"
+#define NID_SMIMECapabilities 167
+#define OBJ_SMIMECapabilities OBJ_pkcs9,15L
+
+#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64"
+#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC"
+#define NID_pbeWithMD2AndRC2_CBC 168
+#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L
+
+#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64"
+#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC"
+#define NID_pbeWithMD5AndRC2_CBC 169
+#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L
+
+#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES"
+#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC"
+#define NID_pbeWithSHA1AndDES_CBC 170
+#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L
+
+/* Extension request OIDs */
+
+#define LN_ms_ext_req "Microsoft Extension Request"
+#define SN_ms_ext_req "msExtReq"
+#define NID_ms_ext_req 171
+#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L
+
+#define LN_ext_req "Extension Request"
+#define SN_ext_req "extReq"
+#define NID_ext_req 172
+#define OBJ_ext_req OBJ_pkcs9,14L
+
+#define SN_name "name"
+#define LN_name "name"
+#define NID_name 173
+#define OBJ_name OBJ_X509,41L
+
+#define SN_dnQualifier "dnQualifier"
+#define LN_dnQualifier "dnQualifier"
+#define NID_dnQualifier 174
+#define OBJ_dnQualifier OBJ_X509,46L
+
+#define SN_id_pe "id-pe"
+#define NID_id_pe 175
+#define OBJ_id_pe OBJ_id_pkix,1L
+
+#define SN_id_ad "id-ad"
+#define NID_id_ad 176
+#define OBJ_id_ad OBJ_id_pkix,48L
+
+#define SN_info_access "authorityInfoAccess"
+#define LN_info_access "Authority Information Access"
+#define NID_info_access 177
+#define OBJ_info_access OBJ_id_pe,1L
+
+#define SN_ad_OCSP "OCSP"
+#define LN_ad_OCSP "OCSP"
+#define NID_ad_OCSP 178
+#define OBJ_ad_OCSP OBJ_id_ad,1L
+
+#define SN_ad_ca_issuers "caIssuers"
+#define LN_ad_ca_issuers "CA Issuers"
+#define NID_ad_ca_issuers 179
+#define OBJ_ad_ca_issuers OBJ_id_ad,2L
+
+#define SN_OCSP_sign "OCSPSigning"
+#define LN_OCSP_sign "OCSP Signing"
+#define NID_OCSP_sign 180
+#define OBJ_OCSP_sign OBJ_id_kp,9L
+#endif /* USE_OBJ_MAC */
+
+#include <openssl/bio.h>
+#include <openssl/asn1.h>
+
+#define OBJ_NAME_TYPE_UNDEF 0x00
+#define OBJ_NAME_TYPE_MD_METH 0x01
+#define OBJ_NAME_TYPE_CIPHER_METH 0x02
+#define OBJ_NAME_TYPE_PKEY_METH 0x03
+#define OBJ_NAME_TYPE_COMP_METH 0x04
+#define OBJ_NAME_TYPE_NUM 0x05
+
+#define OBJ_NAME_ALIAS 0x8000
+
+#define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01
+#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct obj_name_st
+ {
+ int type;
+ int alias;
+ const char *name;
+ const char *data;
+ } OBJ_NAME;
+
+#define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)
+
+
+int OBJ_NAME_init(void);
+int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
+ int (*cmp_func)(const char *, const char *),
+ void (*free_func)(const char *, int, const char *));
+const char *OBJ_NAME_get(const char *name,int type);
+int OBJ_NAME_add(const char *name,int type,const char *data);
+int OBJ_NAME_remove(const char *name,int type);
+void OBJ_NAME_cleanup(int type); /* -1 for everything */
+void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),
+ void *arg);
+void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
+ void *arg);
+
+ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
+ASN1_OBJECT * OBJ_nid2obj(int n);
+const char * OBJ_nid2ln(int n);
+const char * OBJ_nid2sn(int n);
+int OBJ_obj2nid(const ASN1_OBJECT *o);
+ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name);
+int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
+int OBJ_txt2nid(const char *s);
+int OBJ_ln2nid(const char *s);
+int OBJ_sn2nid(const char *s);
+int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
+const char * OBJ_bsearch(const char *key,const char *base,int num,int size,
+ int (*cmp)(const void *, const void *));
+const char * OBJ_bsearch_ex(const char *key,const char *base,int num,
+ int size, int (*cmp)(const void *, const void *), int flags);
+
+int OBJ_new_nid(int num);
+int OBJ_add_object(const ASN1_OBJECT *obj);
+int OBJ_create(const char *oid,const char *sn,const char *ln);
+void OBJ_cleanup(void );
+int OBJ_create_objects(BIO *in);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_OBJ_strings(void);
+
+/* Error codes for the OBJ functions. */
+
+/* Function codes. */
+#define OBJ_F_OBJ_ADD_OBJECT 105
+#define OBJ_F_OBJ_CREATE 100
+#define OBJ_F_OBJ_DUP 101
+#define OBJ_F_OBJ_NAME_NEW_INDEX 106
+#define OBJ_F_OBJ_NID2LN 102
+#define OBJ_F_OBJ_NID2OBJ 103
+#define OBJ_F_OBJ_NID2SN 104
+
+/* Reason codes. */
+#define OBJ_R_MALLOC_FAILURE 100
+#define OBJ_R_UNKNOWN_NID 101
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ocsp.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ocsp.h
new file mode 100644
index 000000000..a0577a717
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ocsp.h
@@ -0,0 +1,623 @@
+/* ocsp.h */
+/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
+ * project. */
+
+/* History:
+ This file was transfered to Richard Levitte from CertCo by Kathy
+ Weinhold in mid-spring 2000 to be included in OpenSSL or released
+ as a patch kit. */
+
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_OCSP_H
+#define HEADER_OCSP_H
+
+#include <openssl/x509.h>
+#include <openssl/x509v3.h>
+#include <openssl/safestack.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Various flags and values */
+
+#define OCSP_DEFAULT_NONCE_LENGTH 16
+
+#define OCSP_NOCERTS 0x1
+#define OCSP_NOINTERN 0x2
+#define OCSP_NOSIGS 0x4
+#define OCSP_NOCHAIN 0x8
+#define OCSP_NOVERIFY 0x10
+#define OCSP_NOEXPLICIT 0x20
+#define OCSP_NOCASIGN 0x40
+#define OCSP_NODELEGATED 0x80
+#define OCSP_NOCHECKS 0x100
+#define OCSP_TRUSTOTHER 0x200
+#define OCSP_RESPID_KEY 0x400
+#define OCSP_NOTIME 0x800
+
+/* CertID ::= SEQUENCE {
+ * hashAlgorithm AlgorithmIdentifier,
+ * issuerNameHash OCTET STRING, -- Hash of Issuer's DN
+ * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
+ * serialNumber CertificateSerialNumber }
+ */
+typedef struct ocsp_cert_id_st
+ {
+ X509_ALGOR *hashAlgorithm;
+ ASN1_OCTET_STRING *issuerNameHash;
+ ASN1_OCTET_STRING *issuerKeyHash;
+ ASN1_INTEGER *serialNumber;
+ } OCSP_CERTID;
+
+DECLARE_STACK_OF(OCSP_CERTID)
+
+/* Request ::= SEQUENCE {
+ * reqCert CertID,
+ * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL }
+ */
+typedef struct ocsp_one_request_st
+ {
+ OCSP_CERTID *reqCert;
+ STACK_OF(X509_EXTENSION) *singleRequestExtensions;
+ } OCSP_ONEREQ;
+
+DECLARE_STACK_OF(OCSP_ONEREQ)
+DECLARE_ASN1_SET_OF(OCSP_ONEREQ)
+
+
+/* TBSRequest ::= SEQUENCE {
+ * version [0] EXPLICIT Version DEFAULT v1,
+ * requestorName [1] EXPLICIT GeneralName OPTIONAL,
+ * requestList SEQUENCE OF Request,
+ * requestExtensions [2] EXPLICIT Extensions OPTIONAL }
+ */
+typedef struct ocsp_req_info_st
+ {
+ ASN1_INTEGER *version;
+ GENERAL_NAME *requestorName;
+ STACK_OF(OCSP_ONEREQ) *requestList;
+ STACK_OF(X509_EXTENSION) *requestExtensions;
+ } OCSP_REQINFO;
+
+/* Signature ::= SEQUENCE {
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signature BIT STRING,
+ * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
+ */
+typedef struct ocsp_signature_st
+ {
+ X509_ALGOR *signatureAlgorithm;
+ ASN1_BIT_STRING *signature;
+ STACK_OF(X509) *certs;
+ } OCSP_SIGNATURE;
+
+/* OCSPRequest ::= SEQUENCE {
+ * tbsRequest TBSRequest,
+ * optionalSignature [0] EXPLICIT Signature OPTIONAL }
+ */
+typedef struct ocsp_request_st
+ {
+ OCSP_REQINFO *tbsRequest;
+ OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
+ } OCSP_REQUEST;
+
+/* OCSPResponseStatus ::= ENUMERATED {
+ * successful (0), --Response has valid confirmations
+ * malformedRequest (1), --Illegal confirmation request
+ * internalError (2), --Internal error in issuer
+ * tryLater (3), --Try again later
+ * --(4) is not used
+ * sigRequired (5), --Must sign the request
+ * unauthorized (6) --Request unauthorized
+ * }
+ */
+#define OCSP_RESPONSE_STATUS_SUCCESSFUL 0
+#define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1
+#define OCSP_RESPONSE_STATUS_INTERNALERROR 2
+#define OCSP_RESPONSE_STATUS_TRYLATER 3
+#define OCSP_RESPONSE_STATUS_SIGREQUIRED 5
+#define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6
+
+/* ResponseBytes ::= SEQUENCE {
+ * responseType OBJECT IDENTIFIER,
+ * response OCTET STRING }
+ */
+typedef struct ocsp_resp_bytes_st
+ {
+ ASN1_OBJECT *responseType;
+ ASN1_OCTET_STRING *response;
+ } OCSP_RESPBYTES;
+
+/* OCSPResponse ::= SEQUENCE {
+ * responseStatus OCSPResponseStatus,
+ * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL }
+ */
+struct ocsp_response_st
+ {
+ ASN1_ENUMERATED *responseStatus;
+ OCSP_RESPBYTES *responseBytes;
+ };
+
+/* ResponderID ::= CHOICE {
+ * byName [1] Name,
+ * byKey [2] KeyHash }
+ */
+#define V_OCSP_RESPID_NAME 0
+#define V_OCSP_RESPID_KEY 1
+struct ocsp_responder_id_st
+ {
+ int type;
+ union {
+ X509_NAME* byName;
+ ASN1_OCTET_STRING *byKey;
+ } value;
+ };
+
+DECLARE_STACK_OF(OCSP_RESPID)
+DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
+
+/* KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
+ * --(excluding the tag and length fields)
+ */
+
+/* RevokedInfo ::= SEQUENCE {
+ * revocationTime GeneralizedTime,
+ * revocationReason [0] EXPLICIT CRLReason OPTIONAL }
+ */
+typedef struct ocsp_revoked_info_st
+ {
+ ASN1_GENERALIZEDTIME *revocationTime;
+ ASN1_ENUMERATED *revocationReason;
+ } OCSP_REVOKEDINFO;
+
+/* CertStatus ::= CHOICE {
+ * good [0] IMPLICIT NULL,
+ * revoked [1] IMPLICIT RevokedInfo,
+ * unknown [2] IMPLICIT UnknownInfo }
+ */
+#define V_OCSP_CERTSTATUS_GOOD 0
+#define V_OCSP_CERTSTATUS_REVOKED 1
+#define V_OCSP_CERTSTATUS_UNKNOWN 2
+typedef struct ocsp_cert_status_st
+ {
+ int type;
+ union {
+ ASN1_NULL *good;
+ OCSP_REVOKEDINFO *revoked;
+ ASN1_NULL *unknown;
+ } value;
+ } OCSP_CERTSTATUS;
+
+/* SingleResponse ::= SEQUENCE {
+ * certID CertID,
+ * certStatus CertStatus,
+ * thisUpdate GeneralizedTime,
+ * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL,
+ * singleExtensions [1] EXPLICIT Extensions OPTIONAL }
+ */
+typedef struct ocsp_single_response_st
+ {
+ OCSP_CERTID *certId;
+ OCSP_CERTSTATUS *certStatus;
+ ASN1_GENERALIZEDTIME *thisUpdate;
+ ASN1_GENERALIZEDTIME *nextUpdate;
+ STACK_OF(X509_EXTENSION) *singleExtensions;
+ } OCSP_SINGLERESP;
+
+DECLARE_STACK_OF(OCSP_SINGLERESP)
+DECLARE_ASN1_SET_OF(OCSP_SINGLERESP)
+
+/* ResponseData ::= SEQUENCE {
+ * version [0] EXPLICIT Version DEFAULT v1,
+ * responderID ResponderID,
+ * producedAt GeneralizedTime,
+ * responses SEQUENCE OF SingleResponse,
+ * responseExtensions [1] EXPLICIT Extensions OPTIONAL }
+ */
+typedef struct ocsp_response_data_st
+ {
+ ASN1_INTEGER *version;
+ OCSP_RESPID *responderId;
+ ASN1_GENERALIZEDTIME *producedAt;
+ STACK_OF(OCSP_SINGLERESP) *responses;
+ STACK_OF(X509_EXTENSION) *responseExtensions;
+ } OCSP_RESPDATA;
+
+/* BasicOCSPResponse ::= SEQUENCE {
+ * tbsResponseData ResponseData,
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signature BIT STRING,
+ * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
+ */
+ /* Note 1:
+ The value for "signature" is specified in the OCSP rfc2560 as follows:
+ "The value for the signature SHALL be computed on the hash of the DER
+ encoding ResponseData." This means that you must hash the DER-encoded
+ tbsResponseData, and then run it through a crypto-signing function, which
+ will (at least w/RSA) do a hash-'n'-private-encrypt operation. This seems
+ a bit odd, but that's the spec. Also note that the data structures do not
+ leave anywhere to independently specify the algorithm used for the initial
+ hash. So, we look at the signature-specification algorithm, and try to do
+ something intelligent. -- Kathy Weinhold, CertCo */
+ /* Note 2:
+ It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open
+ for interpretation. I've done tests against another responder, and found
+ that it doesn't do the double hashing that the RFC seems to say one
+ should. Therefore, all relevant functions take a flag saying which
+ variant should be used. -- Richard Levitte, OpenSSL team and CeloCom */
+typedef struct ocsp_basic_response_st
+ {
+ OCSP_RESPDATA *tbsResponseData;
+ X509_ALGOR *signatureAlgorithm;
+ ASN1_BIT_STRING *signature;
+ STACK_OF(X509) *certs;
+ } OCSP_BASICRESP;
+
+/*
+ * CRLReason ::= ENUMERATED {
+ * unspecified (0),
+ * keyCompromise (1),
+ * cACompromise (2),
+ * affiliationChanged (3),
+ * superseded (4),
+ * cessationOfOperation (5),
+ * certificateHold (6),
+ * removeFromCRL (8) }
+ */
+#define OCSP_REVOKED_STATUS_NOSTATUS -1
+#define OCSP_REVOKED_STATUS_UNSPECIFIED 0
+#define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1
+#define OCSP_REVOKED_STATUS_CACOMPROMISE 2
+#define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3
+#define OCSP_REVOKED_STATUS_SUPERSEDED 4
+#define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5
+#define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6
+#define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8
+
+/* CrlID ::= SEQUENCE {
+ * crlUrl [0] EXPLICIT IA5String OPTIONAL,
+ * crlNum [1] EXPLICIT INTEGER OPTIONAL,
+ * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL }
+ */
+typedef struct ocsp_crl_id_st
+ {
+ ASN1_IA5STRING *crlUrl;
+ ASN1_INTEGER *crlNum;
+ ASN1_GENERALIZEDTIME *crlTime;
+ } OCSP_CRLID;
+
+/* ServiceLocator ::= SEQUENCE {
+ * issuer Name,
+ * locator AuthorityInfoAccessSyntax OPTIONAL }
+ */
+typedef struct ocsp_service_locator_st
+ {
+ X509_NAME* issuer;
+ STACK_OF(ACCESS_DESCRIPTION) *locator;
+ } OCSP_SERVICELOC;
+
+#define PEM_STRING_OCSP_REQUEST "OCSP REQUEST"
+#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"
+
+#define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)
+
+#define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)
+
+#define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
+
+#define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\
+ (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)
+
+#define PEM_write_bio_OCSP_REQUEST(bp,o) \
+ PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
+ bp,(char *)o, NULL,NULL,0,NULL,NULL)
+
+#define PEM_write_bio_OCSP_RESPONSE(bp,o) \
+ PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
+ bp,(char *)o, NULL,NULL,0,NULL,NULL)
+
+#define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)
+
+#define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)
+
+#define OCSP_REQUEST_sign(o,pkey,md) \
+ ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\
+ o->optionalSignature->signatureAlgorithm,NULL,\
+ o->optionalSignature->signature,o->tbsRequest,pkey,md)
+
+#define OCSP_BASICRESP_sign(o,pkey,md,d) \
+ ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\
+ o->signature,o->tbsResponseData,pkey,md)
+
+#define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\
+ a->optionalSignature->signatureAlgorithm,\
+ a->optionalSignature->signature,a->tbsRequest,r)
+
+#define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\
+ a->signatureAlgorithm,a->signature,a->tbsResponseData,r)
+
+#define ASN1_BIT_STRING_digest(data,type,md,len) \
+ ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)
+
+#define OCSP_CERTID_dup(cid) ASN1_dup_of(OCSP_CERTID,i2d_OCSP_CERTID,d2i_OCSP_CERTID,cid)
+
+#define OCSP_CERTSTATUS_dup(cs)\
+ (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
+ (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))
+
+OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
+OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
+ int maxline);
+int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
+void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
+
+OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);
+
+OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,
+ X509_NAME *issuerName,
+ ASN1_BIT_STRING* issuerKey,
+ ASN1_INTEGER *serialNumber);
+
+OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
+
+int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
+int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
+int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
+int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
+
+int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
+int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);
+
+int OCSP_request_sign(OCSP_REQUEST *req,
+ X509 *signer,
+ EVP_PKEY *key,
+ const EVP_MD *dgst,
+ STACK_OF(X509) *certs,
+ unsigned long flags);
+
+int OCSP_response_status(OCSP_RESPONSE *resp);
+OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
+
+int OCSP_resp_count(OCSP_BASICRESP *bs);
+OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
+int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
+int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
+ ASN1_GENERALIZEDTIME **revtime,
+ ASN1_GENERALIZEDTIME **thisupd,
+ ASN1_GENERALIZEDTIME **nextupd);
+int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
+ int *reason,
+ ASN1_GENERALIZEDTIME **revtime,
+ ASN1_GENERALIZEDTIME **thisupd,
+ ASN1_GENERALIZEDTIME **nextupd);
+int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
+ ASN1_GENERALIZEDTIME *nextupd,
+ long sec, long maxsec);
+
+int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags);
+
+int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl);
+
+int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
+int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
+
+int OCSP_request_onereq_count(OCSP_REQUEST *req);
+OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
+OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
+int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
+ ASN1_OCTET_STRING **pikeyHash,
+ ASN1_INTEGER **pserial, OCSP_CERTID *cid);
+int OCSP_request_is_signed(OCSP_REQUEST *req);
+OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
+OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,
+ OCSP_CERTID *cid,
+ int status, int reason,
+ ASN1_TIME *revtime,
+ ASN1_TIME *thisupd, ASN1_TIME *nextupd);
+int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
+int OCSP_basic_sign(OCSP_BASICRESP *brsp,
+ X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
+ STACK_OF(X509) *certs, unsigned long flags);
+
+ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d,
+ void *data, STACK_OF(ASN1_OBJECT) *sk);
+#define ASN1_STRING_encode_of(type,s,i2d,data,sk) \
+ ASN1_STRING_encode(s, CHECKED_I2D_OF(type, i2d), data, sk)
+
+X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
+
+X509_EXTENSION *OCSP_accept_responses_new(char **oids);
+
+X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);
+
+X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls);
+
+int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
+int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
+int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos);
+int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);
+X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
+X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
+void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx);
+int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,
+ unsigned long flags);
+int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
+
+int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
+int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
+int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);
+int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
+X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
+X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
+void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
+int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
+ unsigned long flags);
+int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
+
+int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
+int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
+int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos);
+int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos);
+X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
+X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
+void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx);
+int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit,
+ unsigned long flags);
+int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
+
+int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
+int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);
+int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos);
+int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos);
+X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
+X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
+void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx);
+int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit,
+ unsigned long flags);
+int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);
+
+DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
+DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
+DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
+DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
+DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
+DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
+DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
+DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
+DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
+DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
+DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
+DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
+DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
+DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
+DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
+
+char *OCSP_response_status_str(long s);
+char *OCSP_cert_status_str(long s);
+char *OCSP_crl_reason_str(long s);
+
+int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
+int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);
+
+int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
+ X509_STORE *st, unsigned long flags);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_OCSP_strings(void);
+
+/* Error codes for the OCSP functions. */
+
+/* Function codes. */
+#define OCSP_F_ASN1_STRING_ENCODE 100
+#define OCSP_F_D2I_OCSP_NONCE 102
+#define OCSP_F_OCSP_BASIC_ADD1_STATUS 103
+#define OCSP_F_OCSP_BASIC_SIGN 104
+#define OCSP_F_OCSP_BASIC_VERIFY 105
+#define OCSP_F_OCSP_CERT_ID_NEW 101
+#define OCSP_F_OCSP_CHECK_DELEGATED 106
+#define OCSP_F_OCSP_CHECK_IDS 107
+#define OCSP_F_OCSP_CHECK_ISSUER 108
+#define OCSP_F_OCSP_CHECK_VALIDITY 115
+#define OCSP_F_OCSP_MATCH_ISSUERID 109
+#define OCSP_F_OCSP_PARSE_URL 114
+#define OCSP_F_OCSP_REQUEST_SIGN 110
+#define OCSP_F_OCSP_REQUEST_VERIFY 116
+#define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111
+#define OCSP_F_OCSP_SENDREQ_BIO 112
+#define OCSP_F_PARSE_HTTP_LINE1 117
+#define OCSP_F_REQUEST_VERIFY 113
+
+/* Reason codes. */
+#define OCSP_R_BAD_DATA 100
+#define OCSP_R_CERTIFICATE_VERIFY_ERROR 101
+#define OCSP_R_DIGEST_ERR 102
+#define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122
+#define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123
+#define OCSP_R_ERROR_PARSING_URL 121
+#define OCSP_R_MISSING_OCSPSIGNING_USAGE 103
+#define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124
+#define OCSP_R_NOT_BASIC_RESPONSE 104
+#define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105
+#define OCSP_R_NO_CONTENT 106
+#define OCSP_R_NO_PUBLIC_KEY 107
+#define OCSP_R_NO_RESPONSE_DATA 108
+#define OCSP_R_NO_REVOKED_TIME 109
+#define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110
+#define OCSP_R_REQUEST_NOT_SIGNED 128
+#define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111
+#define OCSP_R_ROOT_CA_NOT_TRUSTED 112
+#define OCSP_R_SERVER_READ_ERROR 113
+#define OCSP_R_SERVER_RESPONSE_ERROR 114
+#define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115
+#define OCSP_R_SERVER_WRITE_ERROR 116
+#define OCSP_R_SIGNATURE_FAILURE 117
+#define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118
+#define OCSP_R_STATUS_EXPIRED 125
+#define OCSP_R_STATUS_NOT_YET_VALID 126
+#define OCSP_R_STATUS_TOO_OLD 127
+#define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119
+#define OCSP_R_UNKNOWN_NID 120
+#define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/opensslconf.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/opensslconf.h
new file mode 100644
index 000000000..60505327d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/opensslconf.h
@@ -0,0 +1,255 @@
+/* opensslconf.h */
+/* WARNING: Generated automatically from opensslconf.h.in by Configure. */
+
+/* OpenSSL was configured with the following options: */
+#ifndef OPENSSL_DOING_MAKEDEPEND
+
+
+#ifndef OPENSSL_NO_CAMELLIA
+# define OPENSSL_NO_CAMELLIA
+#endif
+#ifndef OPENSSL_NO_CAPIENG
+# define OPENSSL_NO_CAPIENG
+#endif
+#ifndef OPENSSL_NO_CMS
+# define OPENSSL_NO_CMS
+#endif
+#ifndef OPENSSL_NO_GMP
+# define OPENSSL_NO_GMP
+#endif
+#ifndef OPENSSL_NO_JPAKE
+# define OPENSSL_NO_JPAKE
+#endif
+#ifndef OPENSSL_NO_KRB5
+# define OPENSSL_NO_KRB5
+#endif
+#ifndef OPENSSL_NO_MDC2
+# define OPENSSL_NO_MDC2
+#endif
+#ifndef OPENSSL_NO_RC5
+# define OPENSSL_NO_RC5
+#endif
+#ifndef OPENSSL_NO_RFC3779
+# define OPENSSL_NO_RFC3779
+#endif
+#ifndef OPENSSL_NO_SEED
+# define OPENSSL_NO_SEED
+#endif
+
+#endif /* OPENSSL_DOING_MAKEDEPEND */
+
+#ifndef OPENSSL_NO_DYNAMIC_ENGINE
+# define OPENSSL_NO_DYNAMIC_ENGINE
+#endif
+
+/* The OPENSSL_NO_* macros are also defined as NO_* if the application
+ asks for it. This is a transient feature that is provided for those
+ who haven't had the time to do the appropriate changes in their
+ applications. */
+#ifdef OPENSSL_ALGORITHM_DEFINES
+# if defined(OPENSSL_NO_CAMELLIA) && !defined(NO_CAMELLIA)
+# define NO_CAMELLIA
+# endif
+# if defined(OPENSSL_NO_CAPIENG) && !defined(NO_CAPIENG)
+# define NO_CAPIENG
+# endif
+# if defined(OPENSSL_NO_CMS) && !defined(NO_CMS)
+# define NO_CMS
+# endif
+# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP)
+# define NO_GMP
+# endif
+# if defined(OPENSSL_NO_JPAKE) && !defined(NO_JPAKE)
+# define NO_JPAKE
+# endif
+# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5)
+# define NO_KRB5
+# endif
+# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2)
+# define NO_MDC2
+# endif
+# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5)
+# define NO_RC5
+# endif
+# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779)
+# define NO_RFC3779
+# endif
+# if defined(OPENSSL_NO_SEED) && !defined(NO_SEED)
+# define NO_SEED
+# endif
+#endif
+
+/* crypto/opensslconf.h.in */
+
+#ifdef OPENSSL_DOING_MAKEDEPEND
+
+/* Include any symbols here that have to be explicitly set to enable a feature
+ * that should be visible to makedepend.
+ *
+ * [Our "make depend" doesn't actually look at this, we use actual build settings
+ * instead; we want to make it easy to remove subdirectories with disabled algorithms.]
+ */
+
+#ifndef OPENSSL_FIPS
+#define OPENSSL_FIPS
+#endif
+
+#endif
+
+/* Generate 80386 code? */
+#undef I386_ONLY
+
+#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
+#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
+#define ENGINESDIR "/usr/local/ssl/lib/engines"
+#define OPENSSLDIR "/usr/local/ssl"
+#endif
+#endif
+
+#undef OPENSSL_UNISTD
+#define OPENSSL_UNISTD <unistd.h>
+
+#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
+
+#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
+#define IDEA_INT unsigned int
+#endif
+
+#if defined(HEADER_MD2_H) && !defined(MD2_INT)
+#define MD2_INT unsigned int
+#endif
+
+#if defined(HEADER_RC2_H) && !defined(RC2_INT)
+/* I need to put in a mod for the alpha - eay */
+#define RC2_INT unsigned int
+#endif
+
+#if defined(HEADER_RC4_H)
+#if !defined(RC4_INT)
+/* using int types make the structure larger but make the code faster
+ * on most boxes I have tested - up to %20 faster. */
+/*
+ * I don't know what does "most" mean, but declaring "int" is a must on:
+ * - Intel P6 because partial register stalls are very expensive;
+ * - elder Alpha because it lacks byte load/store instructions;
+ */
+#define RC4_INT unsigned int
+#endif
+#if !defined(RC4_CHUNK)
+/*
+ * This enables code handling data aligned at natural CPU word
+ * boundary. See crypto/rc4/rc4_enc.c for further details.
+ */
+#undef RC4_CHUNK
+#endif
+#endif
+
+#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
+/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
+ * %20 speed up (longs are 8 bytes, int's are 4). */
+#ifndef DES_LONG
+#define DES_LONG unsigned long
+#endif
+#endif
+
+#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
+#define CONFIG_HEADER_BN_H
+#undef BN_LLONG
+
+/* Should we define BN_DIV2W here? */
+
+/* Only one for the following should be defined */
+/* The prime number generation stuff may not work when
+ * EIGHT_BIT but I don't care since I've only used this mode
+ * for debuging the bignum libraries */
+#undef SIXTY_FOUR_BIT_LONG
+#undef SIXTY_FOUR_BIT
+#define THIRTY_TWO_BIT
+#undef SIXTEEN_BIT
+#undef EIGHT_BIT
+#endif
+
+#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
+#define CONFIG_HEADER_RC4_LOCL_H
+/* if this is defined data[i] is used instead of *data, this is a %20
+ * speedup on x86 */
+#undef RC4_INDEX
+#endif
+
+#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
+#define CONFIG_HEADER_BF_LOCL_H
+#undef BF_PTR
+#endif /* HEADER_BF_LOCL_H */
+
+#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
+#define CONFIG_HEADER_DES_LOCL_H
+#ifndef DES_DEFAULT_OPTIONS
+/* the following is tweaked from a config script, that is why it is a
+ * protected undef/define */
+#ifndef DES_PTR
+#undef DES_PTR
+#endif
+
+/* This helps C compiler generate the correct code for multiple functional
+ * units. It reduces register dependancies at the expense of 2 more
+ * registers */
+#ifndef DES_RISC1
+#undef DES_RISC1
+#endif
+
+#ifndef DES_RISC2
+#undef DES_RISC2
+#endif
+
+#if defined(DES_RISC1) && defined(DES_RISC2)
+YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
+#endif
+
+/* Unroll the inner loop, this sometimes helps, sometimes hinders.
+ * Very mucy CPU dependant */
+#ifndef DES_UNROLL
+#undef DES_UNROLL
+#endif
+
+/* These default values were supplied by
+ * Peter Gutman <pgut001@cs.auckland.ac.nz>
+ * They are only used if nothing else has been defined */
+#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
+/* Special defines which change the way the code is built depending on the
+ CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
+ even newer MIPS CPU's, but at the moment one size fits all for
+ optimization options. Older Sparc's work better with only UNROLL, but
+ there's no way to tell at compile time what it is you're running on */
+
+#if defined( sun ) /* Newer Sparc's */
+# define DES_PTR
+# define DES_RISC1
+# define DES_UNROLL
+#elif defined( __ultrix ) /* Older MIPS */
+# define DES_PTR
+# define DES_RISC2
+# define DES_UNROLL
+#elif defined( __osf1__ ) /* Alpha */
+# define DES_PTR
+# define DES_RISC2
+#elif defined ( _AIX ) /* RS6000 */
+ /* Unknown */
+#elif defined( __hpux ) /* HP-PA */
+ /* Unknown */
+#elif defined( __aux ) /* 68K */
+ /* Unknown */
+#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
+# define DES_UNROLL
+#elif defined( __sgi ) /* Newer MIPS */
+# define DES_PTR
+# define DES_RISC2
+# define DES_UNROLL
+#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
+# define DES_PTR
+# define DES_RISC1
+# define DES_UNROLL
+#endif /* Systems-specific speed defines */
+#endif
+
+#endif /* DES_DEFAULT_OPTIONS */
+#endif /* HEADER_DES_LOCL_H */
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/opensslv.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/opensslv.h
new file mode 100644
index 000000000..c6207f76b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/opensslv.h
@@ -0,0 +1,89 @@
+#ifndef HEADER_OPENSSLV_H
+#define HEADER_OPENSSLV_H
+
+/* Numeric release version identifier:
+ * MNNFFPPS: major minor fix patch status
+ * The status nibble has one of the values 0 for development, 1 to e for betas
+ * 1 to 14, and f for release. The patch level is exactly that.
+ * For example:
+ * 0.9.3-dev 0x00903000
+ * 0.9.3-beta1 0x00903001
+ * 0.9.3-beta2-dev 0x00903002
+ * 0.9.3-beta2 0x00903002 (same as ...beta2-dev)
+ * 0.9.3 0x0090300f
+ * 0.9.3a 0x0090301f
+ * 0.9.4 0x0090400f
+ * 1.2.3z 0x102031af
+ *
+ * For continuity reasons (because 0.9.5 is already out, and is coded
+ * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level
+ * part is slightly different, by setting the highest bit. This means
+ * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start
+ * with 0x0090600S...
+ *
+ * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
+ * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
+ * major minor fix final patch/beta)
+ */
+#define OPENSSL_VERSION_NUMBER 0x009080bfL
+#ifdef OPENSSL_FIPS
+#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8k-fips 25 Mar 2009"
+#else
+#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8k 25 Mar 2009"
+#endif
+#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
+
+
+/* The macros below are to be used for shared library (.so, .dll, ...)
+ * versioning. That kind of versioning works a bit differently between
+ * operating systems. The most usual scheme is to set a major and a minor
+ * number, and have the runtime loader check that the major number is equal
+ * to what it was at application link time, while the minor number has to
+ * be greater or equal to what it was at application link time. With this
+ * scheme, the version number is usually part of the file name, like this:
+ *
+ * libcrypto.so.0.9
+ *
+ * Some unixen also make a softlink with the major verson number only:
+ *
+ * libcrypto.so.0
+ *
+ * On Tru64 and IRIX 6.x it works a little bit differently. There, the
+ * shared library version is stored in the file, and is actually a series
+ * of versions, separated by colons. The rightmost version present in the
+ * library when linking an application is stored in the application to be
+ * matched at run time. When the application is run, a check is done to
+ * see if the library version stored in the application matches any of the
+ * versions in the version string of the library itself.
+ * This version string can be constructed in any way, depending on what
+ * kind of matching is desired. However, to implement the same scheme as
+ * the one used in the other unixen, all compatible versions, from lowest
+ * to highest, should be part of the string. Consecutive builds would
+ * give the following versions strings:
+ *
+ * 3.0
+ * 3.0:3.1
+ * 3.0:3.1:3.2
+ * 4.0
+ * 4.0:4.1
+ *
+ * Notice how version 4 is completely incompatible with version, and
+ * therefore give the breach you can see.
+ *
+ * There may be other schemes as well that I haven't yet discovered.
+ *
+ * So, here's the way it works here: first of all, the library version
+ * number doesn't need at all to match the overall OpenSSL version.
+ * However, it's nice and more understandable if it actually does.
+ * The current library version is stored in the macro SHLIB_VERSION_NUMBER,
+ * which is just a piece of text in the format "M.m.e" (Major, minor, edit).
+ * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,
+ * we need to keep a history of version numbers, which is done in the
+ * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and
+ * should only keep the versions that are binary compatible with the current.
+ */
+#define SHLIB_VERSION_HISTORY ""
+#define SHLIB_VERSION_NUMBER "0.9.8"
+
+
+#endif /* HEADER_OPENSSLV_H */
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ossl_typ.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ossl_typ.h
new file mode 100644
index 000000000..0e7a38088
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ossl_typ.h
@@ -0,0 +1,183 @@
+/* ====================================================================
+ * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_OPENSSL_TYPES_H
+#define HEADER_OPENSSL_TYPES_H
+
+#include <openssl/e_os2.h>
+
+#ifdef NO_ASN1_TYPEDEFS
+#define ASN1_INTEGER ASN1_STRING
+#define ASN1_ENUMERATED ASN1_STRING
+#define ASN1_BIT_STRING ASN1_STRING
+#define ASN1_OCTET_STRING ASN1_STRING
+#define ASN1_PRINTABLESTRING ASN1_STRING
+#define ASN1_T61STRING ASN1_STRING
+#define ASN1_IA5STRING ASN1_STRING
+#define ASN1_UTCTIME ASN1_STRING
+#define ASN1_GENERALIZEDTIME ASN1_STRING
+#define ASN1_TIME ASN1_STRING
+#define ASN1_GENERALSTRING ASN1_STRING
+#define ASN1_UNIVERSALSTRING ASN1_STRING
+#define ASN1_BMPSTRING ASN1_STRING
+#define ASN1_VISIBLESTRING ASN1_STRING
+#define ASN1_UTF8STRING ASN1_STRING
+#define ASN1_BOOLEAN int
+#define ASN1_NULL int
+#else
+typedef struct asn1_string_st ASN1_INTEGER;
+typedef struct asn1_string_st ASN1_ENUMERATED;
+typedef struct asn1_string_st ASN1_BIT_STRING;
+typedef struct asn1_string_st ASN1_OCTET_STRING;
+typedef struct asn1_string_st ASN1_PRINTABLESTRING;
+typedef struct asn1_string_st ASN1_T61STRING;
+typedef struct asn1_string_st ASN1_IA5STRING;
+typedef struct asn1_string_st ASN1_GENERALSTRING;
+typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
+typedef struct asn1_string_st ASN1_BMPSTRING;
+typedef struct asn1_string_st ASN1_UTCTIME;
+typedef struct asn1_string_st ASN1_TIME;
+typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
+typedef struct asn1_string_st ASN1_VISIBLESTRING;
+typedef struct asn1_string_st ASN1_UTF8STRING;
+typedef int ASN1_BOOLEAN;
+typedef int ASN1_NULL;
+#endif
+
+#ifdef OPENSSL_SYS_WIN32
+#undef X509_NAME
+#undef X509_EXTENSIONS
+#undef X509_CERT_PAIR
+#undef PKCS7_ISSUER_AND_SERIAL
+#undef OCSP_REQUEST
+#undef OCSP_RESPONSE
+#endif
+
+#ifdef BIGNUM
+#undef BIGNUM
+#endif
+typedef struct bignum_st BIGNUM;
+typedef struct bignum_ctx BN_CTX;
+typedef struct bn_blinding_st BN_BLINDING;
+typedef struct bn_mont_ctx_st BN_MONT_CTX;
+typedef struct bn_recp_ctx_st BN_RECP_CTX;
+typedef struct bn_gencb_st BN_GENCB;
+
+typedef struct buf_mem_st BUF_MEM;
+
+typedef struct evp_cipher_st EVP_CIPHER;
+typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
+typedef struct env_md_st EVP_MD;
+typedef struct env_md_ctx_st EVP_MD_CTX;
+typedef struct evp_pkey_st EVP_PKEY;
+
+typedef struct dh_st DH;
+typedef struct dh_method DH_METHOD;
+
+typedef struct dsa_st DSA;
+typedef struct dsa_method DSA_METHOD;
+
+typedef struct rsa_st RSA;
+typedef struct rsa_meth_st RSA_METHOD;
+
+typedef struct rand_meth_st RAND_METHOD;
+
+typedef struct ecdh_method ECDH_METHOD;
+typedef struct ecdsa_method ECDSA_METHOD;
+
+typedef struct x509_st X509;
+typedef struct X509_algor_st X509_ALGOR;
+typedef struct X509_crl_st X509_CRL;
+typedef struct X509_name_st X509_NAME;
+typedef struct x509_store_st X509_STORE;
+typedef struct x509_store_ctx_st X509_STORE_CTX;
+typedef struct ssl_st SSL;
+typedef struct ssl_ctx_st SSL_CTX;
+
+typedef struct v3_ext_ctx X509V3_CTX;
+typedef struct conf_st CONF;
+
+typedef struct store_st STORE;
+typedef struct store_method_st STORE_METHOD;
+
+typedef struct ui_st UI;
+typedef struct ui_method_st UI_METHOD;
+
+typedef struct st_ERR_FNS ERR_FNS;
+
+typedef struct engine_st ENGINE;
+
+typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
+typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
+typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
+typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;
+
+ /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
+#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
+#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */
+
+typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
+/* Callback types for crypto.h */
+typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
+ int idx, long argl, void *argp);
+typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
+ int idx, long argl, void *argp);
+typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
+ int idx, long argl, void *argp);
+
+typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
+typedef struct ocsp_response_st OCSP_RESPONSE;
+typedef struct ocsp_responder_id_st OCSP_RESPID;
+
+#endif /* def HEADER_OPENSSL_TYPES_H */
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pem.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pem.h
new file mode 100644
index 000000000..6c193f1cb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pem.h
@@ -0,0 +1,782 @@
+/* crypto/pem/pem.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_PEM_H
+#define HEADER_PEM_H
+
+#include <openssl/e_os2.h>
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+#ifndef OPENSSL_NO_STACK
+#include <openssl/stack.h>
+#endif
+#include <openssl/evp.h>
+#include <openssl/x509.h>
+#include <openssl/pem2.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PEM_BUFSIZE 1024
+
+#define PEM_OBJ_UNDEF 0
+#define PEM_OBJ_X509 1
+#define PEM_OBJ_X509_REQ 2
+#define PEM_OBJ_CRL 3
+#define PEM_OBJ_SSL_SESSION 4
+#define PEM_OBJ_PRIV_KEY 10
+#define PEM_OBJ_PRIV_RSA 11
+#define PEM_OBJ_PRIV_DSA 12
+#define PEM_OBJ_PRIV_DH 13
+#define PEM_OBJ_PUB_RSA 14
+#define PEM_OBJ_PUB_DSA 15
+#define PEM_OBJ_PUB_DH 16
+#define PEM_OBJ_DHPARAMS 17
+#define PEM_OBJ_DSAPARAMS 18
+#define PEM_OBJ_PRIV_RSA_PUBLIC 19
+#define PEM_OBJ_PRIV_ECDSA 20
+#define PEM_OBJ_PUB_ECDSA 21
+#define PEM_OBJ_ECPARAMETERS 22
+
+#define PEM_ERROR 30
+#define PEM_DEK_DES_CBC 40
+#define PEM_DEK_IDEA_CBC 45
+#define PEM_DEK_DES_EDE 50
+#define PEM_DEK_DES_ECB 60
+#define PEM_DEK_RSA 70
+#define PEM_DEK_RSA_MD2 80
+#define PEM_DEK_RSA_MD5 90
+
+#define PEM_MD_MD2 NID_md2
+#define PEM_MD_MD5 NID_md5
+#define PEM_MD_SHA NID_sha
+#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption
+#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption
+#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption
+
+#define PEM_STRING_X509_OLD "X509 CERTIFICATE"
+#define PEM_STRING_X509 "CERTIFICATE"
+#define PEM_STRING_X509_PAIR "CERTIFICATE PAIR"
+#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
+#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
+#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
+#define PEM_STRING_X509_CRL "X509 CRL"
+#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
+#define PEM_STRING_PUBLIC "PUBLIC KEY"
+#define PEM_STRING_RSA "RSA PRIVATE KEY"
+#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
+#define PEM_STRING_DSA "DSA PRIVATE KEY"
+#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
+#define PEM_STRING_PKCS7 "PKCS7"
+#define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
+#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
+#define PEM_STRING_PKCS8INF "PRIVATE KEY"
+#define PEM_STRING_DHPARAMS "DH PARAMETERS"
+#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
+#define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
+#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
+#define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
+#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
+#define PEM_STRING_CMS "CMS"
+
+ /* Note that this structure is initialised by PEM_SealInit and cleaned up
+ by PEM_SealFinal (at least for now) */
+typedef struct PEM_Encode_Seal_st
+ {
+ EVP_ENCODE_CTX encode;
+ EVP_MD_CTX md;
+ EVP_CIPHER_CTX cipher;
+ } PEM_ENCODE_SEAL_CTX;
+
+/* enc_type is one off */
+#define PEM_TYPE_ENCRYPTED 10
+#define PEM_TYPE_MIC_ONLY 20
+#define PEM_TYPE_MIC_CLEAR 30
+#define PEM_TYPE_CLEAR 40
+
+typedef struct pem_recip_st
+ {
+ char *name;
+ X509_NAME *dn;
+
+ int cipher;
+ int key_enc;
+ /* char iv[8]; unused and wrong size */
+ } PEM_USER;
+
+typedef struct pem_ctx_st
+ {
+ int type; /* what type of object */
+
+ struct {
+ int version;
+ int mode;
+ } proc_type;
+
+ char *domain;
+
+ struct {
+ int cipher;
+ /* unused, and wrong size
+ unsigned char iv[8]; */
+ } DEK_info;
+
+ PEM_USER *originator;
+
+ int num_recipient;
+ PEM_USER **recipient;
+
+#ifndef OPENSSL_NO_STACK
+ STACK *x509_chain; /* certificate chain */
+#else
+ char *x509_chain; /* certificate chain */
+#endif
+ EVP_MD *md; /* signature type */
+
+ int md_enc; /* is the md encrypted or not? */
+ int md_len; /* length of md_data */
+ char *md_data; /* message digest, could be pkey encrypted */
+
+ EVP_CIPHER *dec; /* date encryption cipher */
+ int key_len; /* key length */
+ unsigned char *key; /* key */
+ /* unused, and wrong size
+ unsigned char iv[8]; */
+
+
+ int data_enc; /* is the data encrypted */
+ int data_len;
+ unsigned char *data;
+ } PEM_CTX;
+
+/* These macros make the PEM_read/PEM_write functions easier to maintain and
+ * write. Now they are all implemented with either:
+ * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...)
+ */
+
+#ifdef OPENSSL_NO_FP_API
+
+#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
+#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
+#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/
+#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/
+#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/
+
+#else
+
+#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
+type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
+{ \
+ return (type*)PEM_ASN1_read(CHECKED_D2I_OF(type, d2i_##asn1), \
+ str, fp, \
+ CHECKED_PPTR_OF(type, x), \
+ cb, u); \
+}
+
+#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
+int PEM_write_##name(FILE *fp, type *x) \
+{ \
+ return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \
+ str, fp, \
+ CHECKED_PTR_OF(type, x), \
+ NULL, NULL, 0, NULL, NULL); \
+}
+
+#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
+int PEM_write_##name(FILE *fp, const type *x) \
+{ \
+ return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \
+ str, fp, \
+ CHECKED_PTR_OF(const type, x), \
+ NULL, NULL, 0, NULL, NULL); \
+}
+
+#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
+int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
+ unsigned char *kstr, int klen, pem_password_cb *cb, \
+ void *u) \
+ { \
+ return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \
+ str, fp, \
+ CHECKED_PTR_OF(type, x), \
+ enc, kstr, klen, cb, u); \
+ }
+
+#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
+int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
+ unsigned char *kstr, int klen, pem_password_cb *cb, \
+ void *u) \
+ { \
+ return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \
+ str, fp, \
+ CHECKED_PTR_OF(const type, x), \
+ enc, kstr, klen, cb, u); \
+ }
+
+#endif
+
+#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
+type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
+{ \
+ return (type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i_##asn1), \
+ str, bp, \
+ CHECKED_PPTR_OF(type, x), \
+ cb, u); \
+}
+
+#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
+int PEM_write_bio_##name(BIO *bp, type *x) \
+{ \
+ return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \
+ str, bp, \
+ CHECKED_PTR_OF(type, x), \
+ NULL, NULL, 0, NULL, NULL); \
+}
+
+#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
+int PEM_write_bio_##name(BIO *bp, const type *x) \
+{ \
+ return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \
+ str, bp, \
+ CHECKED_PTR_OF(const type, x), \
+ NULL, NULL, 0, NULL, NULL); \
+}
+
+#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
+int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
+ unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
+ { \
+ return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \
+ str, bp, \
+ CHECKED_PTR_OF(type, x), \
+ enc, kstr, klen, cb, u); \
+ }
+
+#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
+int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
+ unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
+ { \
+ return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \
+ str, bp, \
+ CHECKED_PTR_OF(const type, x), \
+ enc, kstr, klen, cb, u); \
+ }
+
+#define IMPLEMENT_PEM_write(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_fp(name, type, str, asn1)
+
+#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
+
+#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
+
+#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
+
+#define IMPLEMENT_PEM_read(name, type, str, asn1) \
+ IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
+ IMPLEMENT_PEM_read_fp(name, type, str, asn1)
+
+#define IMPLEMENT_PEM_rw(name, type, str, asn1) \
+ IMPLEMENT_PEM_read(name, type, str, asn1) \
+ IMPLEMENT_PEM_write(name, type, str, asn1)
+
+#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_read(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_const(name, type, str, asn1)
+
+#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
+ IMPLEMENT_PEM_read(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_cb(name, type, str, asn1)
+
+/* These are the same except they are for the declarations */
+
+#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API)
+
+#define DECLARE_PEM_read_fp(name, type) /**/
+#define DECLARE_PEM_write_fp(name, type) /**/
+#define DECLARE_PEM_write_fp_const(name, type) /**/
+#define DECLARE_PEM_write_cb_fp(name, type) /**/
+
+#else
+
+#define DECLARE_PEM_read_fp(name, type) \
+ type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);
+
+#define DECLARE_PEM_write_fp(name, type) \
+ int PEM_write_##name(FILE *fp, type *x);
+
+#define DECLARE_PEM_write_fp_const(name, type) \
+ int PEM_write_##name(FILE *fp, const type *x);
+
+#define DECLARE_PEM_write_cb_fp(name, type) \
+ int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
+ unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
+
+#endif
+
+#ifndef OPENSSL_NO_BIO
+#define DECLARE_PEM_read_bio(name, type) \
+ type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);
+
+#define DECLARE_PEM_write_bio(name, type) \
+ int PEM_write_bio_##name(BIO *bp, type *x);
+
+#define DECLARE_PEM_write_bio_const(name, type) \
+ int PEM_write_bio_##name(BIO *bp, const type *x);
+
+#define DECLARE_PEM_write_cb_bio(name, type) \
+ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
+ unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
+
+#else
+
+#define DECLARE_PEM_read_bio(name, type) /**/
+#define DECLARE_PEM_write_bio(name, type) /**/
+#define DECLARE_PEM_write_bio_const(name, type) /**/
+#define DECLARE_PEM_write_cb_bio(name, type) /**/
+
+#endif
+
+#define DECLARE_PEM_write(name, type) \
+ DECLARE_PEM_write_bio(name, type) \
+ DECLARE_PEM_write_fp(name, type)
+
+#define DECLARE_PEM_write_const(name, type) \
+ DECLARE_PEM_write_bio_const(name, type) \
+ DECLARE_PEM_write_fp_const(name, type)
+
+#define DECLARE_PEM_write_cb(name, type) \
+ DECLARE_PEM_write_cb_bio(name, type) \
+ DECLARE_PEM_write_cb_fp(name, type)
+
+#define DECLARE_PEM_read(name, type) \
+ DECLARE_PEM_read_bio(name, type) \
+ DECLARE_PEM_read_fp(name, type)
+
+#define DECLARE_PEM_rw(name, type) \
+ DECLARE_PEM_read(name, type) \
+ DECLARE_PEM_write(name, type)
+
+#define DECLARE_PEM_rw_const(name, type) \
+ DECLARE_PEM_read(name, type) \
+ DECLARE_PEM_write_const(name, type)
+
+#define DECLARE_PEM_rw_cb(name, type) \
+ DECLARE_PEM_read(name, type) \
+ DECLARE_PEM_write_cb(name, type)
+
+#ifdef SSLEAY_MACROS
+
+#define PEM_write_SSL_SESSION(fp,x) \
+ PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
+ PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL)
+#define PEM_write_X509(fp,x) \
+ PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
+ (char *)x, NULL,NULL,0,NULL,NULL)
+#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
+ (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
+ NULL,NULL,0,NULL,NULL)
+#define PEM_write_X509_CRL(fp,x) \
+ PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
+ fp,(char *)x, NULL,NULL,0,NULL,NULL)
+#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
+ PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
+ (char *)x,enc,kstr,klen,cb,u)
+#define PEM_write_RSAPublicKey(fp,x) \
+ PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
+ PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL)
+#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
+ PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
+ (char *)x,enc,kstr,klen,cb,u)
+#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
+ PEM_ASN1_write((int (*)())i2d_PrivateKey,\
+ (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
+ bp,(char *)x,enc,kstr,klen,cb,u)
+#define PEM_write_PKCS7(fp,x) \
+ PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
+ (char *)x, NULL,NULL,0,NULL,NULL)
+#define PEM_write_DHparams(fp,x) \
+ PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
+ (char *)x,NULL,NULL,0,NULL,NULL)
+
+#define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \
+ PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
+ PEM_STRING_X509,fp, \
+ (char *)x, NULL,NULL,0,NULL,NULL)
+
+#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \
+ (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u)
+#define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \
+ (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u)
+#define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \
+ (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u)
+#define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \
+ (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u)
+#define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
+ (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u)
+#define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
+ (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u)
+#define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \
+ (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u)
+#define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \
+ (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u)
+#define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \
+ (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u)
+#define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \
+ (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u)
+
+#define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \
+ (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \
+ (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\
+ (char **)x,cb,u)
+
+#define PEM_write_bio_X509(bp,x) \
+ PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
+ (char *)x, NULL,NULL,0,NULL,NULL)
+#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
+ (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
+ NULL,NULL,0,NULL,NULL)
+#define PEM_write_bio_X509_CRL(bp,x) \
+ PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
+ bp,(char *)x, NULL,NULL,0,NULL,NULL)
+#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
+ PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
+ bp,(char *)x,enc,kstr,klen,cb,u)
+#define PEM_write_bio_RSAPublicKey(bp,x) \
+ PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
+ PEM_STRING_RSA_PUBLIC,\
+ bp,(char *)x,NULL,NULL,0,NULL,NULL)
+#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
+ PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
+ bp,(char *)x,enc,kstr,klen,cb,u)
+#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
+ PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
+ (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
+ bp,(char *)x,enc,kstr,klen,cb,u)
+#define PEM_write_bio_PKCS7(bp,x) \
+ PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
+ (char *)x, NULL,NULL,0,NULL,NULL)
+#define PEM_write_bio_DHparams(bp,x) \
+ PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
+ bp,(char *)x,NULL,NULL,0,NULL,NULL)
+#define PEM_write_bio_DSAparams(bp,x) \
+ PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
+ PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL)
+
+#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \
+ PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
+ PEM_STRING_X509,bp, \
+ (char *)x, NULL,NULL,0,NULL,NULL)
+
+#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u)
+#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u)
+#define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u)
+#define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u)
+#define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u)
+#define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u)
+#define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u)
+
+#define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u)
+#define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u)
+#define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u)
+
+#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \
+ (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\
+ (char **)x,cb,u)
+
+#endif
+
+#if 1
+/* "userdata": new with OpenSSL 0.9.4 */
+typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
+#else
+/* OpenSSL 0.9.3, 0.9.3a */
+typedef int pem_password_cb(char *buf, int size, int rwflag);
+#endif
+
+int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
+int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
+ pem_password_cb *callback,void *u);
+
+#ifndef OPENSSL_NO_BIO
+int PEM_read_bio(BIO *bp, char **name, char **header,
+ unsigned char **data,long *len);
+int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data,
+ long len);
+int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp,
+ pem_password_cb *cb, void *u);
+void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp,
+ void **x, pem_password_cb *cb, void *u);
+
+#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \
+ ((type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i), \
+ name, bp, \
+ CHECKED_PPTR_OF(type, x), \
+ cb, u))
+
+int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x,
+ const EVP_CIPHER *enc,unsigned char *kstr,int klen,
+ pem_password_cb *cb, void *u);
+
+#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \
+ (PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d), \
+ name, bp, \
+ CHECKED_PTR_OF(type, x), \
+ enc, kstr, klen, cb, u))
+
+STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
+int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
+ unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
+#endif
+
+#ifndef OPENSSL_SYS_WIN16
+int PEM_read(FILE *fp, char **name, char **header,
+ unsigned char **data,long *len);
+int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
+void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
+ pem_password_cb *cb, void *u);
+int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp,
+ char *x,const EVP_CIPHER *enc,unsigned char *kstr,
+ int klen,pem_password_cb *callback, void *u);
+STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
+ pem_password_cb *cb, void *u);
+#endif
+
+int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
+ EVP_MD *md_type, unsigned char **ek, int *ekl,
+ unsigned char *iv, EVP_PKEY **pubk, int npubk);
+void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
+ unsigned char *in, int inl);
+int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
+ unsigned char *out, int *outl, EVP_PKEY *priv);
+
+void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
+void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
+int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
+ unsigned int *siglen, EVP_PKEY *pkey);
+
+int PEM_def_callback(char *buf, int num, int w, void *key);
+void PEM_proc_type(char *buf, int type);
+void PEM_dek_info(char *buf, const char *type, int len, char *str);
+
+#ifndef SSLEAY_MACROS
+
+#include <openssl/symhacks.h>
+
+DECLARE_PEM_rw(X509, X509)
+
+DECLARE_PEM_rw(X509_AUX, X509)
+
+DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)
+
+DECLARE_PEM_rw(X509_REQ, X509_REQ)
+DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
+
+DECLARE_PEM_rw(X509_CRL, X509_CRL)
+
+DECLARE_PEM_rw(PKCS7, PKCS7)
+
+DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
+
+DECLARE_PEM_rw(PKCS8, X509_SIG)
+
+DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
+
+#ifndef OPENSSL_NO_RSA
+
+DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
+
+DECLARE_PEM_rw_const(RSAPublicKey, RSA)
+DECLARE_PEM_rw(RSA_PUBKEY, RSA)
+
+#endif
+
+#ifndef OPENSSL_NO_DSA
+
+DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
+
+DECLARE_PEM_rw(DSA_PUBKEY, DSA)
+
+DECLARE_PEM_rw_const(DSAparams, DSA)
+
+#endif
+
+#ifndef OPENSSL_NO_EC
+DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
+DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
+DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
+#endif
+
+#ifndef OPENSSL_NO_DH
+
+DECLARE_PEM_rw_const(DHparams, DH)
+
+#endif
+
+DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
+
+DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
+
+int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
+ char *kstr, int klen,
+ pem_password_cb *cb, void *u);
+int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
+ char *, int, pem_password_cb *, void *);
+int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
+ char *kstr, int klen,
+ pem_password_cb *cb, void *u);
+int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
+ char *kstr, int klen,
+ pem_password_cb *cb, void *u);
+EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
+
+int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
+ char *kstr, int klen,
+ pem_password_cb *cb, void *u);
+int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
+ char *kstr, int klen,
+ pem_password_cb *cb, void *u);
+int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
+ char *kstr, int klen,
+ pem_password_cb *cb, void *u);
+
+EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
+
+int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
+ char *kstr,int klen, pem_password_cb *cd, void *u);
+
+#endif /* SSLEAY_MACROS */
+
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_PEM_strings(void);
+
+/* Error codes for the PEM functions. */
+
+/* Function codes. */
+#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120
+#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121
+#define PEM_F_DO_PK8PKEY 126
+#define PEM_F_DO_PK8PKEY_FP 125
+#define PEM_F_LOAD_IV 101
+#define PEM_F_PEM_ASN1_READ 102
+#define PEM_F_PEM_ASN1_READ_BIO 103
+#define PEM_F_PEM_ASN1_WRITE 104
+#define PEM_F_PEM_ASN1_WRITE_BIO 105
+#define PEM_F_PEM_DEF_CALLBACK 100
+#define PEM_F_PEM_DO_HEADER 106
+#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118
+#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
+#define PEM_F_PEM_PK8PKEY 119
+#define PEM_F_PEM_READ 108
+#define PEM_F_PEM_READ_BIO 109
+#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123
+#define PEM_F_PEM_READ_PRIVATEKEY 124
+#define PEM_F_PEM_SEALFINAL 110
+#define PEM_F_PEM_SEALINIT 111
+#define PEM_F_PEM_SIGNFINAL 112
+#define PEM_F_PEM_WRITE 113
+#define PEM_F_PEM_WRITE_BIO 114
+#define PEM_F_PEM_X509_INFO_READ 115
+#define PEM_F_PEM_X509_INFO_READ_BIO 116
+#define PEM_F_PEM_X509_INFO_WRITE_BIO 117
+
+/* Reason codes. */
+#define PEM_R_BAD_BASE64_DECODE 100
+#define PEM_R_BAD_DECRYPT 101
+#define PEM_R_BAD_END_LINE 102
+#define PEM_R_BAD_IV_CHARS 103
+#define PEM_R_BAD_PASSWORD_READ 104
+#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115
+#define PEM_R_NOT_DEK_INFO 105
+#define PEM_R_NOT_ENCRYPTED 106
+#define PEM_R_NOT_PROC_TYPE 107
+#define PEM_R_NO_START_LINE 108
+#define PEM_R_PROBLEMS_GETTING_PASSWORD 109
+#define PEM_R_PUBLIC_KEY_NO_RSA 110
+#define PEM_R_READ_KEY 111
+#define PEM_R_SHORT_HEADER 112
+#define PEM_R_UNSUPPORTED_CIPHER 113
+#define PEM_R_UNSUPPORTED_ENCRYPTION 114
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pem2.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pem2.h
new file mode 100644
index 000000000..f31790d69
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pem2.h
@@ -0,0 +1,70 @@
+/* ====================================================================
+ * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+/*
+ * This header only exists to break a circular dependency between pem and err
+ * Ben 30 Jan 1999.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef HEADER_PEM_H
+void ERR_load_PEM_strings(void);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pkcs12.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pkcs12.h
new file mode 100644
index 000000000..4bee605dc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pkcs12.h
@@ -0,0 +1,333 @@
+/* pkcs12.h */
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
+ * project 1999.
+ */
+/* ====================================================================
+ * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_PKCS12_H
+#define HEADER_PKCS12_H
+
+#include <openssl/bio.h>
+#include <openssl/x509.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PKCS12_KEY_ID 1
+#define PKCS12_IV_ID 2
+#define PKCS12_MAC_ID 3
+
+/* Default iteration count */
+#ifndef PKCS12_DEFAULT_ITER
+#define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER
+#endif
+
+#define PKCS12_MAC_KEY_LENGTH 20
+
+#define PKCS12_SALT_LEN 8
+
+/* Uncomment out next line for unicode password and names, otherwise ASCII */
+
+/*#define PBE_UNICODE*/
+
+#ifdef PBE_UNICODE
+#define PKCS12_key_gen PKCS12_key_gen_uni
+#define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni
+#else
+#define PKCS12_key_gen PKCS12_key_gen_asc
+#define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc
+#endif
+
+/* MS key usage constants */
+
+#define KEY_EX 0x10
+#define KEY_SIG 0x80
+
+typedef struct {
+X509_SIG *dinfo;
+ASN1_OCTET_STRING *salt;
+ASN1_INTEGER *iter; /* defaults to 1 */
+} PKCS12_MAC_DATA;
+
+typedef struct {
+ASN1_INTEGER *version;
+PKCS12_MAC_DATA *mac;
+PKCS7 *authsafes;
+} PKCS12;
+
+PREDECLARE_STACK_OF(PKCS12_SAFEBAG)
+
+typedef struct {
+ASN1_OBJECT *type;
+union {
+ struct pkcs12_bag_st *bag; /* secret, crl and certbag */
+ struct pkcs8_priv_key_info_st *keybag; /* keybag */
+ X509_SIG *shkeybag; /* shrouded key bag */
+ STACK_OF(PKCS12_SAFEBAG) *safes;
+ ASN1_TYPE *other;
+}value;
+STACK_OF(X509_ATTRIBUTE) *attrib;
+} PKCS12_SAFEBAG;
+
+DECLARE_STACK_OF(PKCS12_SAFEBAG)
+DECLARE_ASN1_SET_OF(PKCS12_SAFEBAG)
+DECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG)
+
+typedef struct pkcs12_bag_st {
+ASN1_OBJECT *type;
+union {
+ ASN1_OCTET_STRING *x509cert;
+ ASN1_OCTET_STRING *x509crl;
+ ASN1_OCTET_STRING *octet;
+ ASN1_IA5STRING *sdsicert;
+ ASN1_TYPE *other; /* Secret or other bag */
+}value;
+} PKCS12_BAGS;
+
+#define PKCS12_ERROR 0
+#define PKCS12_OK 1
+
+/* Compatibility macros */
+
+#define M_PKCS12_x5092certbag PKCS12_x5092certbag
+#define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag
+
+#define M_PKCS12_certbag2x509 PKCS12_certbag2x509
+#define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl
+
+#define M_PKCS12_unpack_p7data PKCS12_unpack_p7data
+#define M_PKCS12_pack_authsafes PKCS12_pack_authsafes
+#define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes
+#define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata
+
+#define M_PKCS12_decrypt_skey PKCS12_decrypt_skey
+#define M_PKCS8_decrypt PKCS8_decrypt
+
+#define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type)
+#define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type)
+#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type
+
+#define PKCS12_get_attr(bag, attr_nid) \
+ PKCS12_get_attr_gen(bag->attrib, attr_nid)
+
+#define PKCS8_get_attr(p8, attr_nid) \
+ PKCS12_get_attr_gen(p8->attributes, attr_nid)
+
+#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0)
+
+
+PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509);
+PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl);
+X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag);
+X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag);
+
+PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1,
+ int nid2);
+PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8);
+PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen);
+PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass,
+ int passlen);
+X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
+ const char *pass, int passlen,
+ unsigned char *salt, int saltlen, int iter,
+ PKCS8_PRIV_KEY_INFO *p8);
+PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,
+ int passlen, unsigned char *salt,
+ int saltlen, int iter,
+ PKCS8_PRIV_KEY_INFO *p8);
+PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);
+STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);
+PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
+ unsigned char *salt, int saltlen, int iter,
+ STACK_OF(PKCS12_SAFEBAG) *bags);
+STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen);
+
+int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);
+STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12);
+
+int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen);
+int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
+ int namelen);
+int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,
+ int namelen);
+int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name,
+ int namelen);
+int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);
+ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid);
+char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);
+unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,
+ int passlen, unsigned char *in, int inlen,
+ unsigned char **data, int *datalen, int en_de);
+void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,
+ const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf);
+ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it,
+ const char *pass, int passlen,
+ void *obj, int zbuf);
+PKCS12 *PKCS12_init(int mode);
+int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
+ int saltlen, int id, int iter, int n,
+ unsigned char *out, const EVP_MD *md_type);
+int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type);
+int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
+ ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type,
+ int en_de);
+int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
+ unsigned char *mac, unsigned int *maclen);
+int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);
+int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
+ unsigned char *salt, int saltlen, int iter,
+ const EVP_MD *md_type);
+int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,
+ int saltlen, const EVP_MD *md_type);
+unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen);
+char *uni2asc(unsigned char *uni, int unilen);
+
+DECLARE_ASN1_FUNCTIONS(PKCS12)
+DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)
+DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)
+DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)
+
+DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)
+DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)
+
+void PKCS12_PBE_add(void);
+int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
+ STACK_OF(X509) **ca);
+PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
+ STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter,
+ int mac_iter, int keytype);
+
+PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);
+PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key,
+ int key_usage, int iter,
+ int key_nid, char *pass);
+int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
+ int safe_nid, int iter, char *pass);
+PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);
+
+int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);
+int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);
+PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);
+PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
+int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_PKCS12_strings(void);
+
+/* Error codes for the PKCS12 functions. */
+
+/* Function codes. */
+#define PKCS12_F_PARSE_BAG 129
+#define PKCS12_F_PARSE_BAGS 103
+#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME 100
+#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC 127
+#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI 102
+#define PKCS12_F_PKCS12_ADD_LOCALKEYID 104
+#define PKCS12_F_PKCS12_CREATE 105
+#define PKCS12_F_PKCS12_GEN_MAC 107
+#define PKCS12_F_PKCS12_INIT 109
+#define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106
+#define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108
+#define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117
+#define PKCS12_F_PKCS12_KEY_GEN_ASC 110
+#define PKCS12_F_PKCS12_KEY_GEN_UNI 111
+#define PKCS12_F_PKCS12_MAKE_KEYBAG 112
+#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113
+#define PKCS12_F_PKCS12_NEWPASS 128
+#define PKCS12_F_PKCS12_PACK_P7DATA 114
+#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115
+#define PKCS12_F_PKCS12_PARSE 118
+#define PKCS12_F_PKCS12_PBE_CRYPT 119
+#define PKCS12_F_PKCS12_PBE_KEYIVGEN 120
+#define PKCS12_F_PKCS12_SETUP_MAC 122
+#define PKCS12_F_PKCS12_SET_MAC 123
+#define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130
+#define PKCS12_F_PKCS12_UNPACK_P7DATA 131
+#define PKCS12_F_PKCS12_VERIFY_MAC 126
+#define PKCS12_F_PKCS8_ADD_KEYUSAGE 124
+#define PKCS12_F_PKCS8_ENCRYPT 125
+
+/* Reason codes. */
+#define PKCS12_R_CANT_PACK_STRUCTURE 100
+#define PKCS12_R_CONTENT_TYPE_NOT_DATA 121
+#define PKCS12_R_DECODE_ERROR 101
+#define PKCS12_R_ENCODE_ERROR 102
+#define PKCS12_R_ENCRYPT_ERROR 103
+#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120
+#define PKCS12_R_INVALID_NULL_ARGUMENT 104
+#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105
+#define PKCS12_R_IV_GEN_ERROR 106
+#define PKCS12_R_KEY_GEN_ERROR 107
+#define PKCS12_R_MAC_ABSENT 108
+#define PKCS12_R_MAC_GENERATION_ERROR 109
+#define PKCS12_R_MAC_SETUP_ERROR 110
+#define PKCS12_R_MAC_STRING_SET_ERROR 111
+#define PKCS12_R_MAC_VERIFY_ERROR 112
+#define PKCS12_R_MAC_VERIFY_FAILURE 113
+#define PKCS12_R_PARSE_ERROR 114
+#define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115
+#define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116
+#define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117
+#define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118
+#define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pkcs7.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pkcs7.h
new file mode 100644
index 000000000..cc092d262
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pkcs7.h
@@ -0,0 +1,464 @@
+/* crypto/pkcs7/pkcs7.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_PKCS7_H
+#define HEADER_PKCS7_H
+
+#include <openssl/asn1.h>
+#include <openssl/bio.h>
+#include <openssl/e_os2.h>
+
+#include <openssl/symhacks.h>
+#include <openssl/ossl_typ.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef OPENSSL_SYS_WIN32
+/* Under Win32 thes are defined in wincrypt.h */
+#undef PKCS7_ISSUER_AND_SERIAL
+#undef PKCS7_SIGNER_INFO
+#endif
+
+/*
+Encryption_ID DES-CBC
+Digest_ID MD5
+Digest_Encryption_ID rsaEncryption
+Key_Encryption_ID rsaEncryption
+*/
+
+typedef struct pkcs7_issuer_and_serial_st
+ {
+ X509_NAME *issuer;
+ ASN1_INTEGER *serial;
+ } PKCS7_ISSUER_AND_SERIAL;
+
+typedef struct pkcs7_signer_info_st
+ {
+ ASN1_INTEGER *version; /* version 1 */
+ PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
+ X509_ALGOR *digest_alg;
+ STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */
+ X509_ALGOR *digest_enc_alg;
+ ASN1_OCTET_STRING *enc_digest;
+ STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */
+
+ /* The private key to sign with */
+ EVP_PKEY *pkey;
+ } PKCS7_SIGNER_INFO;
+
+DECLARE_STACK_OF(PKCS7_SIGNER_INFO)
+DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO)
+
+typedef struct pkcs7_recip_info_st
+ {
+ ASN1_INTEGER *version; /* version 0 */
+ PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
+ X509_ALGOR *key_enc_algor;
+ ASN1_OCTET_STRING *enc_key;
+ X509 *cert; /* get the pub-key from this */
+ } PKCS7_RECIP_INFO;
+
+DECLARE_STACK_OF(PKCS7_RECIP_INFO)
+DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO)
+
+typedef struct pkcs7_signed_st
+ {
+ ASN1_INTEGER *version; /* version 1 */
+ STACK_OF(X509_ALGOR) *md_algs; /* md used */
+ STACK_OF(X509) *cert; /* [ 0 ] */
+ STACK_OF(X509_CRL) *crl; /* [ 1 ] */
+ STACK_OF(PKCS7_SIGNER_INFO) *signer_info;
+
+ struct pkcs7_st *contents;
+ } PKCS7_SIGNED;
+/* The above structure is very very similar to PKCS7_SIGN_ENVELOPE.
+ * How about merging the two */
+
+typedef struct pkcs7_enc_content_st
+ {
+ ASN1_OBJECT *content_type;
+ X509_ALGOR *algorithm;
+ ASN1_OCTET_STRING *enc_data; /* [ 0 ] */
+ const EVP_CIPHER *cipher;
+ } PKCS7_ENC_CONTENT;
+
+typedef struct pkcs7_enveloped_st
+ {
+ ASN1_INTEGER *version; /* version 0 */
+ STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;
+ PKCS7_ENC_CONTENT *enc_data;
+ } PKCS7_ENVELOPE;
+
+typedef struct pkcs7_signedandenveloped_st
+ {
+ ASN1_INTEGER *version; /* version 1 */
+ STACK_OF(X509_ALGOR) *md_algs; /* md used */
+ STACK_OF(X509) *cert; /* [ 0 ] */
+ STACK_OF(X509_CRL) *crl; /* [ 1 ] */
+ STACK_OF(PKCS7_SIGNER_INFO) *signer_info;
+
+ PKCS7_ENC_CONTENT *enc_data;
+ STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;
+ } PKCS7_SIGN_ENVELOPE;
+
+typedef struct pkcs7_digest_st
+ {
+ ASN1_INTEGER *version; /* version 0 */
+ X509_ALGOR *md; /* md used */
+ struct pkcs7_st *contents;
+ ASN1_OCTET_STRING *digest;
+ } PKCS7_DIGEST;
+
+typedef struct pkcs7_encrypted_st
+ {
+ ASN1_INTEGER *version; /* version 0 */
+ PKCS7_ENC_CONTENT *enc_data;
+ } PKCS7_ENCRYPT;
+
+typedef struct pkcs7_st
+ {
+ /* The following is non NULL if it contains ASN1 encoding of
+ * this structure */
+ unsigned char *asn1;
+ long length;
+
+#define PKCS7_S_HEADER 0
+#define PKCS7_S_BODY 1
+#define PKCS7_S_TAIL 2
+ int state; /* used during processing */
+
+ int detached;
+
+ ASN1_OBJECT *type;
+ /* content as defined by the type */
+ /* all encryption/message digests are applied to the 'contents',
+ * leaving out the 'type' field. */
+ union {
+ char *ptr;
+
+ /* NID_pkcs7_data */
+ ASN1_OCTET_STRING *data;
+
+ /* NID_pkcs7_signed */
+ PKCS7_SIGNED *sign;
+
+ /* NID_pkcs7_enveloped */
+ PKCS7_ENVELOPE *enveloped;
+
+ /* NID_pkcs7_signedAndEnveloped */
+ PKCS7_SIGN_ENVELOPE *signed_and_enveloped;
+
+ /* NID_pkcs7_digest */
+ PKCS7_DIGEST *digest;
+
+ /* NID_pkcs7_encrypted */
+ PKCS7_ENCRYPT *encrypted;
+
+ /* Anything else */
+ ASN1_TYPE *other;
+ } d;
+ } PKCS7;
+
+DECLARE_STACK_OF(PKCS7)
+DECLARE_ASN1_SET_OF(PKCS7)
+DECLARE_PKCS12_STACK_OF(PKCS7)
+
+#define PKCS7_OP_SET_DETACHED_SIGNATURE 1
+#define PKCS7_OP_GET_DETACHED_SIGNATURE 2
+
+#define PKCS7_get_signed_attributes(si) ((si)->auth_attr)
+#define PKCS7_get_attributes(si) ((si)->unauth_attr)
+
+#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)
+#define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
+#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)
+#define PKCS7_type_is_signedAndEnveloped(a) \
+ (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
+#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data)
+
+#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
+
+#define PKCS7_set_detached(p,v) \
+ PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)
+#define PKCS7_get_detached(p) \
+ PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)
+
+#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))
+
+#ifdef SSLEAY_MACROS
+#ifndef PKCS7_ISSUER_AND_SERIAL_digest
+#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \
+ ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\
+ (char *)data,md,len)
+#endif
+#endif
+
+/* S/MIME related flags */
+
+#define PKCS7_TEXT 0x1
+#define PKCS7_NOCERTS 0x2
+#define PKCS7_NOSIGS 0x4
+#define PKCS7_NOCHAIN 0x8
+#define PKCS7_NOINTERN 0x10
+#define PKCS7_NOVERIFY 0x20
+#define PKCS7_DETACHED 0x40
+#define PKCS7_BINARY 0x80
+#define PKCS7_NOATTR 0x100
+#define PKCS7_NOSMIMECAP 0x200
+#define PKCS7_NOOLDMIMETYPE 0x400
+#define PKCS7_CRLFEOL 0x800
+#define PKCS7_STREAM 0x1000
+#define PKCS7_NOCRL 0x2000
+
+/* Flags: for compatibility with older code */
+
+#define SMIME_TEXT PKCS7_TEXT
+#define SMIME_NOCERTS PKCS7_NOCERTS
+#define SMIME_NOSIGS PKCS7_NOSIGS
+#define SMIME_NOCHAIN PKCS7_NOCHAIN
+#define SMIME_NOINTERN PKCS7_NOINTERN
+#define SMIME_NOVERIFY PKCS7_NOVERIFY
+#define SMIME_DETACHED PKCS7_DETACHED
+#define SMIME_BINARY PKCS7_BINARY
+#define SMIME_NOATTR PKCS7_NOATTR
+
+DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)
+
+#ifndef SSLEAY_MACROS
+int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type,
+ unsigned char *md,unsigned int *len);
+#ifndef OPENSSL_NO_FP_API
+PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7);
+int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7);
+#endif
+PKCS7 *PKCS7_dup(PKCS7 *p7);
+PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7);
+int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7);
+#endif
+
+DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)
+DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)
+DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)
+DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)
+DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)
+DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)
+DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)
+DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)
+DECLARE_ASN1_FUNCTIONS(PKCS7)
+
+DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)
+DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)
+
+DECLARE_ASN1_NDEF_FUNCTION(PKCS7)
+
+long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);
+
+int PKCS7_set_type(PKCS7 *p7, int type);
+int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);
+int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);
+int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
+ const EVP_MD *dgst);
+int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
+int PKCS7_add_certificate(PKCS7 *p7, X509 *x509);
+int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
+int PKCS7_content_new(PKCS7 *p7, int nid);
+int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,
+ BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);
+int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
+ X509 *x509);
+
+BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);
+int PKCS7_dataFinal(PKCS7 *p7, BIO *bio);
+BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);
+
+
+PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,
+ EVP_PKEY *pkey, const EVP_MD *dgst);
+X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
+int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);
+STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);
+
+PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);
+int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);
+int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);
+int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);
+
+PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);
+ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);
+int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si,int nid,int type,
+ void *data);
+int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,
+ void *value);
+ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);
+ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);
+int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,
+ STACK_OF(X509_ATTRIBUTE) *sk);
+int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk);
+
+
+PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
+ BIO *data, int flags);
+int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
+ BIO *indata, BIO *out, int flags);
+STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
+PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
+ int flags);
+int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
+
+int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,
+ STACK_OF(X509_ALGOR) *cap);
+STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);
+int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);
+
+int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);
+PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);
+int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
+int SMIME_text(BIO *in, BIO *out);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_PKCS7_strings(void);
+
+/* Error codes for the PKCS7 functions. */
+
+/* Function codes. */
+#define PKCS7_F_B64_READ_PKCS7 120
+#define PKCS7_F_B64_WRITE_PKCS7 121
+#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118
+#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100
+#define PKCS7_F_PKCS7_ADD_CRL 101
+#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102
+#define PKCS7_F_PKCS7_ADD_SIGNER 103
+#define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125
+#define PKCS7_F_PKCS7_CTRL 104
+#define PKCS7_F_PKCS7_DATADECODE 112
+#define PKCS7_F_PKCS7_DATAFINAL 128
+#define PKCS7_F_PKCS7_DATAINIT 105
+#define PKCS7_F_PKCS7_DATASIGN 106
+#define PKCS7_F_PKCS7_DATAVERIFY 107
+#define PKCS7_F_PKCS7_DECRYPT 114
+#define PKCS7_F_PKCS7_ENCRYPT 115
+#define PKCS7_F_PKCS7_FIND_DIGEST 127
+#define PKCS7_F_PKCS7_GET0_SIGNERS 124
+#define PKCS7_F_PKCS7_SET_CIPHER 108
+#define PKCS7_F_PKCS7_SET_CONTENT 109
+#define PKCS7_F_PKCS7_SET_DIGEST 126
+#define PKCS7_F_PKCS7_SET_TYPE 110
+#define PKCS7_F_PKCS7_SIGN 116
+#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113
+#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119
+#define PKCS7_F_PKCS7_VERIFY 117
+#define PKCS7_F_SMIME_READ_PKCS7 122
+#define PKCS7_F_SMIME_TEXT 123
+
+/* Reason codes. */
+#define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117
+#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144
+#define PKCS7_R_CIPHER_NOT_INITIALIZED 116
+#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118
+#define PKCS7_R_DECODE_ERROR 130
+#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100
+#define PKCS7_R_DECRYPT_ERROR 119
+#define PKCS7_R_DIGEST_FAILURE 101
+#define PKCS7_R_ERROR_ADDING_RECIPIENT 120
+#define PKCS7_R_ERROR_SETTING_CIPHER 121
+#define PKCS7_R_INVALID_MIME_TYPE 131
+#define PKCS7_R_INVALID_NULL_POINTER 143
+#define PKCS7_R_MIME_NO_CONTENT_TYPE 132
+#define PKCS7_R_MIME_PARSE_ERROR 133
+#define PKCS7_R_MIME_SIG_PARSE_ERROR 134
+#define PKCS7_R_MISSING_CERIPEND_INFO 103
+#define PKCS7_R_NO_CONTENT 122
+#define PKCS7_R_NO_CONTENT_TYPE 135
+#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136
+#define PKCS7_R_NO_MULTIPART_BOUNDARY 137
+#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115
+#define PKCS7_R_NO_RECIPIENT_MATCHES_KEY 146
+#define PKCS7_R_NO_SIGNATURES_ON_DATA 123
+#define PKCS7_R_NO_SIGNERS 142
+#define PKCS7_R_NO_SIG_CONTENT_TYPE 138
+#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104
+#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124
+#define PKCS7_R_PKCS7_DATAFINAL 126
+#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125
+#define PKCS7_R_PKCS7_DATASIGN 145
+#define PKCS7_R_PKCS7_PARSE_ERROR 139
+#define PKCS7_R_PKCS7_SIG_PARSE_ERROR 140
+#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127
+#define PKCS7_R_SIGNATURE_FAILURE 105
+#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128
+#define PKCS7_R_SIG_INVALID_MIME_TYPE 141
+#define PKCS7_R_SMIME_TEXT_ERROR 129
+#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106
+#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107
+#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108
+#define PKCS7_R_UNKNOWN_DIGEST_TYPE 109
+#define PKCS7_R_UNKNOWN_OPERATION 110
+#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111
+#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112
+#define PKCS7_R_WRONG_CONTENT_TYPE 113
+#define PKCS7_R_WRONG_PKCS7_TYPE 114
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pq_compat.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pq_compat.h
new file mode 100644
index 000000000..7b2c32725
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pq_compat.h
@@ -0,0 +1,152 @@
+/* crypto/pqueue/pqueue_compat.h */
+/*
+ * DTLS implementation written by Nagendra Modadugu
+ * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
+ */
+/* ====================================================================
+ * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_PQ_COMPAT_H
+#define HEADER_PQ_COMPAT_H
+
+#include <openssl/opensslconf.h>
+#include <openssl/bn.h>
+
+/*
+ * The purpose of this header file is for supporting 64-bit integer
+ * manipulation on 32-bit (and lower) machines. Currently the only
+ * such environment is VMS, Utrix and those with smaller default integer
+ * sizes than 32 bits. For all such environment, we fall back to using
+ * BIGNUM. We may need to fine tune the conditions for systems that
+ * are incorrectly configured.
+ *
+ * The only clients of this code are (1) pqueue for priority, and
+ * (2) DTLS, for sequence number manipulation.
+ */
+
+#if (defined(THIRTY_TWO_BIT) && !defined(BN_LLONG)) || defined(SIXTEEN_BIT) || defined(EIGHT_BIT)
+
+#define PQ_64BIT_IS_INTEGER 0
+#define PQ_64BIT_IS_BIGNUM 1
+
+#define PQ_64BIT BIGNUM
+#define PQ_64BIT_CTX BN_CTX
+
+#define pq_64bit_init(x) BN_init(x)
+#define pq_64bit_free(x) BN_free(x)
+
+#define pq_64bit_ctx_new(ctx) BN_CTX_new()
+#define pq_64bit_ctx_free(x) BN_CTX_free(x)
+
+#define pq_64bit_assign(x, y) BN_copy(x, y)
+#define pq_64bit_assign_word(x, y) BN_set_word(x, y)
+#define pq_64bit_gt(x, y) BN_ucmp(x, y) >= 1 ? 1 : 0
+#define pq_64bit_eq(x, y) BN_ucmp(x, y) == 0 ? 1 : 0
+#define pq_64bit_add_word(x, w) BN_add_word(x, w)
+#define pq_64bit_sub(r, x, y) BN_sub(r, x, y)
+#define pq_64bit_sub_word(x, w) BN_sub_word(x, w)
+#define pq_64bit_mod(r, x, n, ctx) BN_mod(r, x, n, ctx)
+
+#define pq_64bit_bin2num(bn, bytes, len) BN_bin2bn(bytes, len, bn)
+#define pq_64bit_num2bin(bn, bytes) BN_bn2bin(bn, bytes)
+#define pq_64bit_get_word(x) BN_get_word(x)
+#define pq_64bit_is_bit_set(x, offset) BN_is_bit_set(x, offset)
+#define pq_64bit_lshift(r, x, shift) BN_lshift(r, x, shift)
+#define pq_64bit_set_bit(x, num) BN_set_bit(x, num)
+#define pq_64bit_get_length(x) BN_num_bits((x))
+
+#else
+
+#define PQ_64BIT_IS_INTEGER 1
+#define PQ_64BIT_IS_BIGNUM 0
+
+#if defined(SIXTY_FOUR_BIT)
+#define PQ_64BIT BN_ULONG
+#define PQ_64BIT_PRINT "%lld"
+#elif defined(SIXTY_FOUR_BIT_LONG)
+#define PQ_64BIT BN_ULONG
+#define PQ_64BIT_PRINT "%ld"
+#elif defined(THIRTY_TWO_BIT)
+#define PQ_64BIT BN_ULLONG
+#define PQ_64BIT_PRINT "%lld"
+#endif
+
+#define PQ_64BIT_CTX void
+
+#define pq_64bit_init(x)
+#define pq_64bit_free(x)
+#define pq_64bit_ctx_new(ctx) (ctx)
+#define pq_64bit_ctx_free(x)
+
+#define pq_64bit_assign(x, y) (*(x) = *(y))
+#define pq_64bit_assign_word(x, y) (*(x) = y)
+#define pq_64bit_gt(x, y) (*(x) > *(y))
+#define pq_64bit_eq(x, y) (*(x) == *(y))
+#define pq_64bit_add_word(x, w) (*(x) = (*(x) + (w)))
+#define pq_64bit_sub(r, x, y) (*(r) = (*(x) - *(y)))
+#define pq_64bit_sub_word(x, w) (*(x) = (*(x) - (w)))
+#define pq_64bit_mod(r, x, n, ctx)
+
+#define pq_64bit_bin2num(num, bytes, len) bytes_to_long_long(bytes, num)
+#define pq_64bit_num2bin(num, bytes) long_long_to_bytes(num, bytes)
+#define pq_64bit_get_word(x) *(x)
+#define pq_64bit_lshift(r, x, shift) (*(r) = (*(x) << (shift)))
+#define pq_64bit_set_bit(x, num) do { \
+ PQ_64BIT mask = 1; \
+ mask = mask << (num); \
+ *(x) |= mask; \
+ } while(0)
+#endif /* OPENSSL_SYS_VMS */
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pqueue.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pqueue.h
new file mode 100644
index 000000000..02386d130
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/pqueue.h
@@ -0,0 +1,95 @@
+/* crypto/pqueue/pqueue.h */
+/*
+ * DTLS implementation written by Nagendra Modadugu
+ * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
+ */
+/* ====================================================================
+ * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_PQUEUE_H
+#define HEADER_PQUEUE_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <openssl/pq_compat.h>
+
+typedef struct _pqueue *pqueue;
+
+typedef struct _pitem
+ {
+ PQ_64BIT priority;
+ void *data;
+ struct _pitem *next;
+ } pitem;
+
+typedef struct _pitem *piterator;
+
+pitem *pitem_new(PQ_64BIT priority, void *data);
+void pitem_free(pitem *item);
+
+pqueue pqueue_new(void);
+void pqueue_free(pqueue pq);
+
+pitem *pqueue_insert(pqueue pq, pitem *item);
+pitem *pqueue_peek(pqueue pq);
+pitem *pqueue_pop(pqueue pq);
+pitem *pqueue_find(pqueue pq, PQ_64BIT priority);
+pitem *pqueue_iterator(pqueue pq);
+pitem *pqueue_next(piterator *iter);
+
+void pqueue_print(pqueue pq);
+
+#endif /* ! HEADER_PQUEUE_H */
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rand.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rand.h
new file mode 100644
index 000000000..ea89153cb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rand.h
@@ -0,0 +1,167 @@
+/* crypto/rand/rand.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_RAND_H
+#define HEADER_RAND_H
+
+#include <stdlib.h>
+#include <openssl/ossl_typ.h>
+#include <openssl/e_os2.h>
+
+#if defined(OPENSSL_SYS_WINDOWS)
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(OPENSSL_FIPS)
+#define FIPS_RAND_SIZE_T int
+#endif
+
+/* Already defined in ossl_typ.h */
+/* typedef struct rand_meth_st RAND_METHOD; */
+
+struct rand_meth_st
+ {
+ void (*seed)(const void *buf, int num);
+ int (*bytes)(unsigned char *buf, int num);
+ void (*cleanup)(void);
+ void (*add)(const void *buf, int num, double entropy);
+ int (*pseudorand)(unsigned char *buf, int num);
+ int (*status)(void);
+ };
+
+#ifdef BN_DEBUG
+extern int rand_predictable;
+#endif
+
+int RAND_set_rand_method(const RAND_METHOD *meth);
+const RAND_METHOD *RAND_get_rand_method(void);
+#ifndef OPENSSL_NO_ENGINE
+int RAND_set_rand_engine(ENGINE *engine);
+#endif
+RAND_METHOD *RAND_SSLeay(void);
+void RAND_cleanup(void );
+int RAND_bytes(unsigned char *buf,int num);
+int RAND_pseudo_bytes(unsigned char *buf,int num);
+void RAND_seed(const void *buf,int num);
+void RAND_add(const void *buf,int num,double entropy);
+int RAND_load_file(const char *file,long max_bytes);
+int RAND_write_file(const char *file);
+const char *RAND_file_name(char *file,size_t num);
+int RAND_status(void);
+int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
+int RAND_egd(const char *path);
+int RAND_egd_bytes(const char *path,int bytes);
+int RAND_poll(void);
+#ifndef OPENSSL_NO_ENGINE
+#ifdef OPENSSL_FIPS
+void int_RAND_init_engine_callbacks(void);
+void int_RAND_set_callbacks(
+ int (*set_rand_func)(const RAND_METHOD *meth,
+ const RAND_METHOD **pmeth),
+ const RAND_METHOD *(*get_rand_func)(const RAND_METHOD **pmeth));
+#endif
+#endif
+
+#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
+
+void RAND_screen(void);
+int RAND_event(UINT, WPARAM, LPARAM);
+
+#endif
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_RAND_strings(void);
+
+/* Error codes for the RAND functions. */
+
+/* Function codes. */
+#define RAND_F_ENG_RAND_GET_RAND_METHOD 108
+#define RAND_F_FIPS_RAND 103
+#define RAND_F_FIPS_RAND_BYTES 102
+#define RAND_F_FIPS_RAND_GET_RAND_METHOD 109
+#define RAND_F_FIPS_RAND_SET_DT 106
+#define RAND_F_FIPS_SET_DT 104
+#define RAND_F_FIPS_SET_PRNG_SEED 107
+#define RAND_F_FIPS_SET_TEST_MODE 105
+#define RAND_F_RAND_GET_RAND_METHOD 101
+#define RAND_F_SSLEAY_RAND_BYTES 100
+
+/* Reason codes. */
+#define RAND_R_NON_FIPS_METHOD 105
+#define RAND_R_NOT_IN_TEST_MODE 106
+#define RAND_R_NO_KEY_SET 107
+#define RAND_R_PRNG_ASKING_FOR_TOO_MUCH 101
+#define RAND_R_PRNG_ERROR 108
+#define RAND_R_PRNG_KEYED 109
+#define RAND_R_PRNG_NOT_REKEYED 102
+#define RAND_R_PRNG_NOT_RESEEDED 103
+#define RAND_R_PRNG_NOT_SEEDED 100
+#define RAND_R_PRNG_SEED_MUST_NOT_MATCH_KEY 110
+#define RAND_R_PRNG_STUCK 104
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rc2.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rc2.h
new file mode 100644
index 000000000..e542ec94f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rc2.h
@@ -0,0 +1,103 @@
+/* crypto/rc2/rc2.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_RC2_H
+#define HEADER_RC2_H
+
+#include <openssl/opensslconf.h> /* OPENSSL_NO_RC2, RC2_INT */
+#ifdef OPENSSL_NO_RC2
+#error RC2 is disabled.
+#endif
+
+#define RC2_ENCRYPT 1
+#define RC2_DECRYPT 0
+
+#define RC2_BLOCK 8
+#define RC2_KEY_LENGTH 16
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct rc2_key_st
+ {
+ RC2_INT data[64];
+ } RC2_KEY;
+
+#ifdef OPENSSL_FIPS
+void private_RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits);
+#endif
+void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits);
+void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key,
+ int enc);
+void RC2_encrypt(unsigned long *data,RC2_KEY *key);
+void RC2_decrypt(unsigned long *data,RC2_KEY *key);
+void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
+ RC2_KEY *ks, unsigned char *iv, int enc);
+void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out,
+ long length, RC2_KEY *schedule, unsigned char *ivec,
+ int *num, int enc);
+void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out,
+ long length, RC2_KEY *schedule, unsigned char *ivec,
+ int *num);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rc4.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rc4.h
new file mode 100644
index 000000000..2d8620d33
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rc4.h
@@ -0,0 +1,90 @@
+/* crypto/rc4/rc4.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_RC4_H
+#define HEADER_RC4_H
+
+#include <openssl/opensslconf.h> /* OPENSSL_NO_RC4, RC4_INT */
+#ifdef OPENSSL_NO_RC4
+#error RC4 is disabled.
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct rc4_key_st
+ {
+ RC4_INT x,y;
+ RC4_INT data[256];
+ } RC4_KEY;
+
+
+const char *RC4_options(void);
+#ifdef OPENSSL_FIPS
+void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
+#endif
+void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
+void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
+ unsigned char *outdata);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ripemd.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ripemd.h
new file mode 100644
index 000000000..3b6d04386
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ripemd.h
@@ -0,0 +1,106 @@
+/* crypto/ripemd/ripemd.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_RIPEMD_H
+#define HEADER_RIPEMD_H
+
+#include <openssl/e_os2.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef OPENSSL_NO_RIPEMD
+#error RIPEMD is disabled.
+#endif
+
+#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
+#define RIPEMD160_LONG unsigned long
+#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
+#define RIPEMD160_LONG unsigned long
+#define RIPEMD160_LONG_LOG2 3
+#else
+#define RIPEMD160_LONG unsigned int
+#endif
+
+#define RIPEMD160_CBLOCK 64
+#define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4)
+#define RIPEMD160_DIGEST_LENGTH 20
+
+typedef struct RIPEMD160state_st
+ {
+ RIPEMD160_LONG A,B,C,D,E;
+ RIPEMD160_LONG Nl,Nh;
+ RIPEMD160_LONG data[RIPEMD160_LBLOCK];
+ unsigned int num;
+ } RIPEMD160_CTX;
+#ifdef OPENSSL_FIPS
+int private_RIPEMD160_Init(RIPEMD160_CTX *c);
+#endif
+int RIPEMD160_Init(RIPEMD160_CTX *c);
+int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);
+int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
+unsigned char *RIPEMD160(const unsigned char *d, size_t n,
+ unsigned char *md);
+void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rsa.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rsa.h
new file mode 100644
index 000000000..5bb932ae1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/rsa.h
@@ -0,0 +1,496 @@
+/* crypto/rsa/rsa.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_RSA_H
+#define HEADER_RSA_H
+
+#include <openssl/asn1.h>
+
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+#include <openssl/crypto.h>
+#include <openssl/ossl_typ.h>
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/bn.h>
+#endif
+
+#ifdef OPENSSL_NO_RSA
+#error RSA is disabled.
+#endif
+
+/* If this flag is set the RSA method is FIPS compliant and can be used
+ * in FIPS mode. This is set in the validated module method. If an
+ * application sets this flag in its own methods it is its reposibility
+ * to ensure the result is compliant.
+ */
+
+#define RSA_FLAG_FIPS_METHOD 0x0400
+
+/* If this flag is set the operations normally disabled in FIPS mode are
+ * permitted it is then the applications responsibility to ensure that the
+ * usage is compliant.
+ */
+
+#define RSA_FLAG_NON_FIPS_ALLOW 0x0400
+
+#ifdef OPENSSL_FIPS
+#define FIPS_RSA_SIZE_T int
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Declared already in ossl_typ.h */
+/* typedef struct rsa_st RSA; */
+/* typedef struct rsa_meth_st RSA_METHOD; */
+
+struct rsa_meth_st
+ {
+ const char *name;
+ int (*rsa_pub_enc)(int flen,const unsigned char *from,
+ unsigned char *to,
+ RSA *rsa,int padding);
+ int (*rsa_pub_dec)(int flen,const unsigned char *from,
+ unsigned char *to,
+ RSA *rsa,int padding);
+ int (*rsa_priv_enc)(int flen,const unsigned char *from,
+ unsigned char *to,
+ RSA *rsa,int padding);
+ int (*rsa_priv_dec)(int flen,const unsigned char *from,
+ unsigned char *to,
+ RSA *rsa,int padding);
+ int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx); /* Can be null */
+ int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx,
+ BN_MONT_CTX *m_ctx); /* Can be null */
+ int (*init)(RSA *rsa); /* called at new */
+ int (*finish)(RSA *rsa); /* called at free */
+ int flags; /* RSA_METHOD_FLAG_* things */
+ char *app_data; /* may be needed! */
+/* New sign and verify functions: some libraries don't allow arbitrary data
+ * to be signed/verified: this allows them to be used. Note: for this to work
+ * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used
+ * RSA_sign(), RSA_verify() should be used instead. Note: for backwards
+ * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER
+ * option is set in 'flags'.
+ */
+ int (*rsa_sign)(int type,
+ const unsigned char *m, unsigned int m_length,
+ unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
+ int (*rsa_verify)(int dtype,
+ const unsigned char *m, unsigned int m_length,
+ unsigned char *sigbuf, unsigned int siglen, const RSA *rsa);
+/* If this callback is NULL, the builtin software RSA key-gen will be used. This
+ * is for behavioural compatibility whilst the code gets rewired, but one day
+ * it would be nice to assume there are no such things as "builtin software"
+ * implementations. */
+ int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
+ };
+
+struct rsa_st
+ {
+ /* The first parameter is used to pickup errors where
+ * this is passed instead of aEVP_PKEY, it is set to 0 */
+ int pad;
+ long version;
+ const RSA_METHOD *meth;
+ /* functional reference if 'meth' is ENGINE-provided */
+ ENGINE *engine;
+ BIGNUM *n;
+ BIGNUM *e;
+ BIGNUM *d;
+ BIGNUM *p;
+ BIGNUM *q;
+ BIGNUM *dmp1;
+ BIGNUM *dmq1;
+ BIGNUM *iqmp;
+ /* be careful using this if the RSA structure is shared */
+ CRYPTO_EX_DATA ex_data;
+ int references;
+ int flags;
+
+ /* Used to cache montgomery values */
+ BN_MONT_CTX *_method_mod_n;
+ BN_MONT_CTX *_method_mod_p;
+ BN_MONT_CTX *_method_mod_q;
+
+ /* all BIGNUM values are actually in the following data, if it is not
+ * NULL */
+ char *bignum_data;
+ BN_BLINDING *blinding;
+ BN_BLINDING *mt_blinding;
+ };
+
+#ifndef OPENSSL_RSA_MAX_MODULUS_BITS
+# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
+#endif
+
+#define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024
+
+#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
+# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
+#endif
+#ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
+# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 /* exponent limit enforced for "large" modulus only */
+#endif
+
+#define RSA_3 0x3L
+#define RSA_F4 0x10001L
+
+#define RSA_METHOD_FLAG_NO_CHECK 0x0001 /* don't check pub/private match */
+
+#define RSA_FLAG_CACHE_PUBLIC 0x0002
+#define RSA_FLAG_CACHE_PRIVATE 0x0004
+#define RSA_FLAG_BLINDING 0x0008
+#define RSA_FLAG_THREAD_SAFE 0x0010
+/* This flag means the private key operations will be handled by rsa_mod_exp
+ * and that they do not depend on the private key components being present:
+ * for example a key stored in external hardware. Without this flag bn_mod_exp
+ * gets called when private key components are absent.
+ */
+#define RSA_FLAG_EXT_PKEY 0x0020
+
+/* This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions.
+ */
+#define RSA_FLAG_SIGN_VER 0x0040
+
+#define RSA_FLAG_NO_BLINDING 0x0080 /* new with 0.9.6j and 0.9.7b; the built-in
+ * RSA implementation now uses blinding by
+ * default (ignoring RSA_FLAG_BLINDING),
+ * but other engines might not need it
+ */
+#define RSA_FLAG_NO_CONSTTIME 0x0100 /* new with 0.9.8f; the built-in RSA
+ * implementation now uses constant time
+ * operations by default in private key operations,
+ * e.g., constant time modular exponentiation,
+ * modular inverse without leaking branches,
+ * division without leaking branches. This
+ * flag disables these constant time
+ * operations and results in faster RSA
+ * private key operations.
+ */
+#ifndef OPENSSL_NO_DEPRECATED
+#define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME /* deprecated name for the flag*/
+ /* new with 0.9.7h; the built-in RSA
+ * implementation now uses constant time
+ * modular exponentiation for secret exponents
+ * by default. This flag causes the
+ * faster variable sliding window method to
+ * be used for all exponents.
+ */
+#endif
+
+
+#define RSA_PKCS1_PADDING 1
+#define RSA_SSLV23_PADDING 2
+#define RSA_NO_PADDING 3
+#define RSA_PKCS1_OAEP_PADDING 4
+#define RSA_X931_PADDING 5
+
+#define RSA_PKCS1_PADDING_SIZE 11
+
+#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg)
+#define RSA_get_app_data(s) RSA_get_ex_data(s,0)
+
+RSA * RSA_new(void);
+RSA * RSA_new_method(ENGINE *engine);
+int RSA_size(const RSA *);
+
+/* Deprecated version */
+#ifndef OPENSSL_NO_DEPRECATED
+RSA * RSA_generate_key(int bits, unsigned long e,void
+ (*callback)(int,int,void *),void *cb_arg);
+#endif /* !defined(OPENSSL_NO_DEPRECATED) */
+
+/* New version */
+int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
+int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, BIGNUM *q2,
+ const BIGNUM *Xp1, const BIGNUM *Xp2, const BIGNUM *Xp,
+ const BIGNUM *Xq1, const BIGNUM *Xq2, const BIGNUM *Xq,
+ const BIGNUM *e, BN_GENCB *cb);
+int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, BN_GENCB *cb);
+
+int RSA_check_key(const RSA *);
+ /* next 4 return -1 on error */
+int RSA_public_encrypt(int flen, const unsigned char *from,
+ unsigned char *to, RSA *rsa,int padding);
+int RSA_private_encrypt(int flen, const unsigned char *from,
+ unsigned char *to, RSA *rsa,int padding);
+int RSA_public_decrypt(int flen, const unsigned char *from,
+ unsigned char *to, RSA *rsa,int padding);
+int RSA_private_decrypt(int flen, const unsigned char *from,
+ unsigned char *to, RSA *rsa,int padding);
+void RSA_free (RSA *r);
+/* "up" the RSA object's reference count */
+int RSA_up_ref(RSA *r);
+
+int RSA_flags(const RSA *r);
+
+#ifdef OPENSSL_FIPS
+RSA *FIPS_rsa_new(void);
+void FIPS_rsa_free(RSA *r);
+#endif
+
+void RSA_set_default_method(const RSA_METHOD *meth);
+const RSA_METHOD *RSA_get_default_method(void);
+const RSA_METHOD *RSA_get_method(const RSA *rsa);
+int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
+
+/* This function needs the memory locking malloc callbacks to be installed */
+int RSA_memory_lock(RSA *r);
+
+/* these are the actual SSLeay RSA functions */
+const RSA_METHOD *RSA_PKCS1_SSLeay(void);
+
+const RSA_METHOD *RSA_null_method(void);
+
+DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)
+DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)
+
+#ifndef OPENSSL_NO_FP_API
+int RSA_print_fp(FILE *fp, const RSA *r,int offset);
+#endif
+
+#ifndef OPENSSL_NO_BIO
+int RSA_print(BIO *bp, const RSA *r,int offset);
+#endif
+
+#ifndef OPENSSL_NO_RC4
+int i2d_RSA_NET(const RSA *a, unsigned char **pp,
+ int (*cb)(char *buf, int len, const char *prompt, int verify),
+ int sgckey);
+RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length,
+ int (*cb)(char *buf, int len, const char *prompt, int verify),
+ int sgckey);
+
+int i2d_Netscape_RSA(const RSA *a, unsigned char **pp,
+ int (*cb)(char *buf, int len, const char *prompt,
+ int verify));
+RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,
+ int (*cb)(char *buf, int len, const char *prompt,
+ int verify));
+#endif
+
+/* The following 2 functions sign and verify a X509_SIG ASN1 object
+ * inside PKCS#1 padded RSA encryption */
+int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
+ unsigned char *sigret, unsigned int *siglen, RSA *rsa);
+int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
+ unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
+
+/* The following 2 function sign and verify a ASN1_OCTET_STRING
+ * object inside PKCS#1 padded RSA encryption */
+int RSA_sign_ASN1_OCTET_STRING(int type,
+ const unsigned char *m, unsigned int m_length,
+ unsigned char *sigret, unsigned int *siglen, RSA *rsa);
+int RSA_verify_ASN1_OCTET_STRING(int type,
+ const unsigned char *m, unsigned int m_length,
+ unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
+
+int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
+void RSA_blinding_off(RSA *rsa);
+BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
+
+int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen,
+ const unsigned char *f,int fl);
+int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen,
+ const unsigned char *f,int fl,int rsa_len);
+int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen,
+ const unsigned char *f,int fl);
+int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen,
+ const unsigned char *f,int fl,int rsa_len);
+int PKCS1_MGF1(unsigned char *mask, long len,
+ const unsigned char *seed, long seedlen, const EVP_MD *dgst);
+int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen,
+ const unsigned char *f,int fl,
+ const unsigned char *p,int pl);
+int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen,
+ const unsigned char *f,int fl,int rsa_len,
+ const unsigned char *p,int pl);
+int RSA_padding_add_SSLv23(unsigned char *to,int tlen,
+ const unsigned char *f,int fl);
+int RSA_padding_check_SSLv23(unsigned char *to,int tlen,
+ const unsigned char *f,int fl,int rsa_len);
+int RSA_padding_add_none(unsigned char *to,int tlen,
+ const unsigned char *f,int fl);
+int RSA_padding_check_none(unsigned char *to,int tlen,
+ const unsigned char *f,int fl,int rsa_len);
+int RSA_padding_add_X931(unsigned char *to,int tlen,
+ const unsigned char *f,int fl);
+int RSA_padding_check_X931(unsigned char *to,int tlen,
+ const unsigned char *f,int fl,int rsa_len);
+int RSA_X931_hash_id(int nid);
+
+int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
+ const EVP_MD *Hash, const unsigned char *EM, int sLen);
+int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
+ const unsigned char *mHash,
+ const EVP_MD *Hash, int sLen);
+
+int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int RSA_set_ex_data(RSA *r,int idx,void *arg);
+void *RSA_get_ex_data(const RSA *r, int idx);
+
+RSA *RSAPublicKey_dup(RSA *rsa);
+RSA *RSAPrivateKey_dup(RSA *rsa);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_RSA_strings(void);
+
+/* Error codes for the RSA functions. */
+
+/* Function codes. */
+#define RSA_F_FIPS_RSA_SIGN 140
+#define RSA_F_FIPS_RSA_VERIFY 141
+#define RSA_F_MEMORY_LOCK 100
+#define RSA_F_RSA_BUILTIN_KEYGEN 129
+#define RSA_F_RSA_CHECK_KEY 123
+#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101
+#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 102
+#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 103
+#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104
+#define RSA_F_RSA_GENERATE_KEY 105
+#define RSA_F_RSA_MEMORY_LOCK 130
+#define RSA_F_RSA_NEW_METHOD 106
+#define RSA_F_RSA_NULL 124
+#define RSA_F_RSA_NULL_MOD_EXP 131
+#define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132
+#define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133
+#define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134
+#define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135
+#define RSA_F_RSA_PADDING_ADD_NONE 107
+#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121
+#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125
+#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108
+#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109
+#define RSA_F_RSA_PADDING_ADD_SSLV23 110
+#define RSA_F_RSA_PADDING_ADD_X931 127
+#define RSA_F_RSA_PADDING_CHECK_NONE 111
+#define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122
+#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112
+#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113
+#define RSA_F_RSA_PADDING_CHECK_SSLV23 114
+#define RSA_F_RSA_PADDING_CHECK_X931 128
+#define RSA_F_RSA_PRINT 115
+#define RSA_F_RSA_PRINT_FP 116
+#define RSA_F_RSA_PRIVATE_ENCRYPT 137
+#define RSA_F_RSA_PUBLIC_DECRYPT 138
+#define RSA_F_RSA_SETUP_BLINDING 136
+#define RSA_F_RSA_SET_DEFAULT_METHOD 139
+#define RSA_F_RSA_SET_METHOD 142
+#define RSA_F_RSA_SIGN 117
+#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118
+#define RSA_F_RSA_VERIFY 119
+#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120
+#define RSA_F_RSA_VERIFY_PKCS1_PSS 126
+
+/* Reason codes. */
+#define RSA_R_ALGORITHM_MISMATCH 100
+#define RSA_R_BAD_E_VALUE 101
+#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102
+#define RSA_R_BAD_PAD_BYTE_COUNT 103
+#define RSA_R_BAD_SIGNATURE 104
+#define RSA_R_BLOCK_TYPE_IS_NOT_01 106
+#define RSA_R_BLOCK_TYPE_IS_NOT_02 107
+#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108
+#define RSA_R_DATA_TOO_LARGE 109
+#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110
+#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132
+#define RSA_R_DATA_TOO_SMALL 111
+#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122
+#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112
+#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124
+#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125
+#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
+#define RSA_R_FIRST_OCTET_INVALID 133
+#define RSA_R_INVALID_HEADER 137
+#define RSA_R_INVALID_MESSAGE_LENGTH 131
+#define RSA_R_INVALID_PADDING 138
+#define RSA_R_INVALID_TRAILER 139
+#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126
+#define RSA_R_KEY_SIZE_TOO_SMALL 120
+#define RSA_R_LAST_OCTET_INVALID 134
+#define RSA_R_MODULUS_TOO_LARGE 105
+#define RSA_R_NON_FIPS_METHOD 141
+#define RSA_R_NO_PUBLIC_EXPONENT 140
+#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
+#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127
+#define RSA_R_OAEP_DECODING_ERROR 121
+#define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 142
+#define RSA_R_PADDING_CHECK_FAILED 114
+#define RSA_R_P_NOT_PRIME 128
+#define RSA_R_Q_NOT_PRIME 129
+#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130
+#define RSA_R_SLEN_CHECK_FAILED 136
+#define RSA_R_SLEN_RECOVERY_FAILED 135
+#define RSA_R_SSLV3_ROLLBACK_ATTACK 115
+#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
+#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
+#define RSA_R_UNKNOWN_PADDING_TYPE 118
+#define RSA_R_WRONG_SIGNATURE_LENGTH 119
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/safestack.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/safestack.h
new file mode 100644
index 000000000..40b17902e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/safestack.h
@@ -0,0 +1,2030 @@
+/* ====================================================================
+ * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_SAFESTACK_H
+#define HEADER_SAFESTACK_H
+
+#include <openssl/stack.h>
+
+#ifdef DEBUG_SAFESTACK
+
+#ifndef CHECKED_PTR_OF
+#define CHECKED_PTR_OF(type, p) \
+ ((void*) (1 ? p : (type*)0))
+#endif
+
+#define CHECKED_SK_FREE_FUNC(type, p) \
+ ((void (*)(void *)) ((1 ? p : (void (*)(type *))0)))
+
+#define CHECKED_SK_CMP_FUNC(type, p) \
+ ((int (*)(const char * const *, const char * const *)) \
+ ((1 ? p : (int (*)(const type * const *, const type * const *))0)))
+
+#define STACK_OF(type) struct stack_st_##type
+#define PREDECLARE_STACK_OF(type) STACK_OF(type);
+
+#define DECLARE_STACK_OF(type) \
+STACK_OF(type) \
+ { \
+ STACK stack; \
+ };
+
+#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/
+
+/* SKM_sk_... stack macros are internal to safestack.h:
+ * never use them directly, use sk_<type>_... instead */
+#define SKM_sk_new(type, cmp) \
+ ((STACK_OF(type) *)sk_new(CHECKED_SK_CMP_FUNC(type, cmp)))
+#define SKM_sk_new_null(type) \
+ ((STACK_OF(type) *)sk_new_null())
+#define SKM_sk_free(type, st) \
+ sk_free(CHECKED_PTR_OF(STACK_OF(type), st))
+#define SKM_sk_num(type, st) \
+ sk_num(CHECKED_PTR_OF(STACK_OF(type), st))
+#define SKM_sk_value(type, st,i) \
+ ((type *)sk_value(CHECKED_PTR_OF(STACK_OF(type), st), i))
+#define SKM_sk_set(type, st,i,val) \
+ sk_set(CHECKED_PTR_OF(STACK_OF(type), st), i, CHECKED_PTR_OF(type, val))
+#define SKM_sk_zero(type, st) \
+ sk_zero(CHECKED_PTR_OF(STACK_OF(type), st))
+#define SKM_sk_push(type, st,val) \
+ sk_push(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val))
+#define SKM_sk_unshift(type, st,val) \
+ sk_unshift(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val))
+#define SKM_sk_find(type, st,val) \
+ sk_find(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val))
+#define SKM_sk_delete(type, st,i) \
+ (type *)sk_delete(CHECKED_PTR_OF(STACK_OF(type), st), i)
+#define SKM_sk_delete_ptr(type, st,ptr) \
+ (type *)sk_delete_ptr(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, ptr))
+#define SKM_sk_insert(type, st,val,i) \
+ sk_insert(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val), i)
+#define SKM_sk_set_cmp_func(type, st,cmp) \
+ ((int (*)(const type * const *,const type * const *)) \
+ sk_set_cmp_func(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_SK_CMP_FUNC(type, cmp)))
+#define SKM_sk_dup(type, st) \
+ (STACK_OF(type) *)sk_dup(CHECKED_PTR_OF(STACK_OF(type), st))
+#define SKM_sk_pop_free(type, st,free_func) \
+ sk_pop_free(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_SK_FREE_FUNC(type, free_func))
+#define SKM_sk_shift(type, st) \
+ (type *)sk_shift(CHECKED_PTR_OF(STACK_OF(type), st))
+#define SKM_sk_pop(type, st) \
+ (type *)sk_pop(CHECKED_PTR_OF(STACK_OF(type), st))
+#define SKM_sk_sort(type, st) \
+ sk_sort(CHECKED_PTR_OF(STACK_OF(type), st))
+#define SKM_sk_is_sorted(type, st) \
+ sk_is_sorted(CHECKED_PTR_OF(STACK_OF(type), st))
+
+#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ (STACK_OF(type) *)d2i_ASN1_SET(CHECKED_PTR_OF(STACK_OF(type), st), \
+ pp, length, \
+ CHECKED_D2I_OF(type, d2i_func), \
+ CHECKED_SK_FREE_FUNC(type, free_func), \
+ ex_tag, ex_class)
+
+#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ i2d_ASN1_SET(CHECKED_PTR_OF(STACK_OF(type), st), pp, \
+ CHECKED_I2D_OF(type, i2d_func), \
+ ex_tag, ex_class, is_set)
+
+#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \
+ ASN1_seq_pack(CHECKED_PTR_OF(STACK_OF(type), st), \
+ CHECKED_I2D_OF(type, i2d_func), buf, len)
+
+#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \
+ (STACK_OF(type) *)ASN1_seq_unpack(buf, len, CHECKED_D2I_OF(type, d2i_func), CHECKED_SK_FREE_FUNC(type, free_func))
+
+#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \
+ (STACK_OF(type) *)PKCS12_decrypt_d2i(algor, \
+ CHECKED_D2I_OF(type, d2i_func), \
+ CHECKED_SK_FREE_FUNC(type, free_func), \
+ pass, passlen, oct, seq)
+
+#else
+
+#define STACK_OF(type) STACK
+#define PREDECLARE_STACK_OF(type) /* nada */
+#define DECLARE_STACK_OF(type) /* nada */
+#define IMPLEMENT_STACK_OF(type) /* nada */
+
+#define SKM_sk_new(type, cmp) \
+ sk_new((int (*)(const char * const *, const char * const *))(cmp))
+#define SKM_sk_new_null(type) \
+ sk_new_null()
+#define SKM_sk_free(type, st) \
+ sk_free(st)
+#define SKM_sk_num(type, st) \
+ sk_num(st)
+#define SKM_sk_value(type, st,i) \
+ ((type *)sk_value(st, i))
+#define SKM_sk_set(type, st,i,val) \
+ ((type *)sk_set(st, i,(char *)val))
+#define SKM_sk_zero(type, st) \
+ sk_zero(st)
+#define SKM_sk_push(type, st,val) \
+ sk_push(st, (char *)val)
+#define SKM_sk_unshift(type, st,val) \
+ sk_unshift(st, (char *)val)
+#define SKM_sk_find(type, st,val) \
+ sk_find(st, (char *)val)
+#define SKM_sk_delete(type, st,i) \
+ ((type *)sk_delete(st, i))
+#define SKM_sk_delete_ptr(type, st,ptr) \
+ ((type *)sk_delete_ptr(st,(char *)ptr))
+#define SKM_sk_insert(type, st,val,i) \
+ sk_insert(st, (char *)val, i)
+#define SKM_sk_set_cmp_func(type, st,cmp) \
+ ((int (*)(const type * const *,const type * const *)) \
+ sk_set_cmp_func(st, (int (*)(const char * const *, const char * const *))(cmp)))
+#define SKM_sk_dup(type, st) \
+ sk_dup(st)
+#define SKM_sk_pop_free(type, st,free_func) \
+ sk_pop_free(st, (void (*)(void *))free_func)
+#define SKM_sk_shift(type, st) \
+ ((type *)sk_shift(st))
+#define SKM_sk_pop(type, st) \
+ ((type *)sk_pop(st))
+#define SKM_sk_sort(type, st) \
+ sk_sort(st)
+#define SKM_sk_is_sorted(type, st) \
+ sk_is_sorted(st)
+
+#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ d2i_ASN1_SET(st,pp,length, (void *(*)(void ** ,const unsigned char ** ,long))d2i_func, (void (*)(void *))free_func, ex_tag,ex_class)
+#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ i2d_ASN1_SET(st,pp,(int (*)(void *, unsigned char **))i2d_func,ex_tag,ex_class,is_set)
+
+#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \
+ ASN1_seq_pack(st, (int (*)(void *, unsigned char **))i2d_func, buf, len)
+#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \
+ ASN1_seq_unpack(buf,len,(void *(*)(void **,const unsigned char **,long))d2i_func, (void(*)(void *))free_func)
+
+#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \
+ ((STACK *)PKCS12_decrypt_d2i(algor,(char *(*)())d2i_func, (void(*)(void *))free_func,pass,passlen,oct,seq))
+
+#endif
+
+/* This block of defines is updated by util/mkstack.pl, please do not touch! */
+#define sk_ACCESS_DESCRIPTION_new(st) SKM_sk_new(ACCESS_DESCRIPTION, (st))
+#define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION)
+#define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st))
+#define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st))
+#define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i))
+#define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val))
+#define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st))
+#define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val))
+#define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val))
+#define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val))
+#define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val))
+#define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i))
+#define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr))
+#define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i))
+#define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp))
+#define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st)
+#define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func))
+#define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st))
+#define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st))
+#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st))
+#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st))
+
+#define sk_ASIdOrRange_new(st) SKM_sk_new(ASIdOrRange, (st))
+#define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange)
+#define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st))
+#define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st))
+#define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i))
+#define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val))
+#define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st))
+#define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val))
+#define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val))
+#define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val))
+#define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val))
+#define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i))
+#define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr))
+#define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i))
+#define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp))
+#define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st)
+#define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func))
+#define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st))
+#define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st))
+#define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st))
+#define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st))
+
+#define sk_ASN1_GENERALSTRING_new(st) SKM_sk_new(ASN1_GENERALSTRING, (st))
+#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING)
+#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st))
+#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st))
+#define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i))
+#define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val))
+#define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st))
+#define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val))
+#define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val))
+#define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val))
+#define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val))
+#define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i))
+#define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr))
+#define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i))
+#define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp))
+#define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st)
+#define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func))
+#define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st))
+#define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st))
+#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st))
+#define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st))
+
+#define sk_ASN1_INTEGER_new(st) SKM_sk_new(ASN1_INTEGER, (st))
+#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER)
+#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st))
+#define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st))
+#define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i))
+#define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val))
+#define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st))
+#define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val))
+#define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val))
+#define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val))
+#define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val))
+#define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i))
+#define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr))
+#define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i))
+#define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp))
+#define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st)
+#define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func))
+#define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st))
+#define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st))
+#define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st))
+#define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st))
+
+#define sk_ASN1_OBJECT_new(st) SKM_sk_new(ASN1_OBJECT, (st))
+#define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT)
+#define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st))
+#define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st))
+#define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i))
+#define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val))
+#define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st))
+#define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val))
+#define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val))
+#define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val))
+#define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val))
+#define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i))
+#define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr))
+#define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i))
+#define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp))
+#define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st)
+#define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func))
+#define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st))
+#define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st))
+#define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st))
+#define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st))
+
+#define sk_ASN1_STRING_TABLE_new(st) SKM_sk_new(ASN1_STRING_TABLE, (st))
+#define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE)
+#define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st))
+#define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st))
+#define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i))
+#define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val))
+#define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st))
+#define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val))
+#define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val))
+#define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val))
+#define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val))
+#define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i))
+#define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr))
+#define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i))
+#define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp))
+#define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st)
+#define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func))
+#define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st))
+#define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st))
+#define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st))
+#define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st))
+
+#define sk_ASN1_TYPE_new(st) SKM_sk_new(ASN1_TYPE, (st))
+#define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE)
+#define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st))
+#define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st))
+#define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i))
+#define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val))
+#define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st))
+#define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val))
+#define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val))
+#define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val))
+#define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val))
+#define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i))
+#define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr))
+#define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i))
+#define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp))
+#define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st)
+#define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func))
+#define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st))
+#define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st))
+#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st))
+#define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st))
+
+#define sk_ASN1_VALUE_new(st) SKM_sk_new(ASN1_VALUE, (st))
+#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE)
+#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st))
+#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st))
+#define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i))
+#define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val))
+#define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st))
+#define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val))
+#define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val))
+#define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val))
+#define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val))
+#define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i))
+#define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr))
+#define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i))
+#define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp))
+#define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st)
+#define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func))
+#define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st))
+#define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st))
+#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st))
+#define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st))
+
+#define sk_BIO_new(st) SKM_sk_new(BIO, (st))
+#define sk_BIO_new_null() SKM_sk_new_null(BIO)
+#define sk_BIO_free(st) SKM_sk_free(BIO, (st))
+#define sk_BIO_num(st) SKM_sk_num(BIO, (st))
+#define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i))
+#define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val))
+#define sk_BIO_zero(st) SKM_sk_zero(BIO, (st))
+#define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val))
+#define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val))
+#define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val))
+#define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val))
+#define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i))
+#define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr))
+#define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i))
+#define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp))
+#define sk_BIO_dup(st) SKM_sk_dup(BIO, st)
+#define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func))
+#define sk_BIO_shift(st) SKM_sk_shift(BIO, (st))
+#define sk_BIO_pop(st) SKM_sk_pop(BIO, (st))
+#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st))
+#define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st))
+
+#define sk_CMS_CertificateChoices_new(st) SKM_sk_new(CMS_CertificateChoices, (st))
+#define sk_CMS_CertificateChoices_new_null() SKM_sk_new_null(CMS_CertificateChoices)
+#define sk_CMS_CertificateChoices_free(st) SKM_sk_free(CMS_CertificateChoices, (st))
+#define sk_CMS_CertificateChoices_num(st) SKM_sk_num(CMS_CertificateChoices, (st))
+#define sk_CMS_CertificateChoices_value(st, i) SKM_sk_value(CMS_CertificateChoices, (st), (i))
+#define sk_CMS_CertificateChoices_set(st, i, val) SKM_sk_set(CMS_CertificateChoices, (st), (i), (val))
+#define sk_CMS_CertificateChoices_zero(st) SKM_sk_zero(CMS_CertificateChoices, (st))
+#define sk_CMS_CertificateChoices_push(st, val) SKM_sk_push(CMS_CertificateChoices, (st), (val))
+#define sk_CMS_CertificateChoices_unshift(st, val) SKM_sk_unshift(CMS_CertificateChoices, (st), (val))
+#define sk_CMS_CertificateChoices_find(st, val) SKM_sk_find(CMS_CertificateChoices, (st), (val))
+#define sk_CMS_CertificateChoices_find_ex(st, val) SKM_sk_find_ex(CMS_CertificateChoices, (st), (val))
+#define sk_CMS_CertificateChoices_delete(st, i) SKM_sk_delete(CMS_CertificateChoices, (st), (i))
+#define sk_CMS_CertificateChoices_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_CertificateChoices, (st), (ptr))
+#define sk_CMS_CertificateChoices_insert(st, val, i) SKM_sk_insert(CMS_CertificateChoices, (st), (val), (i))
+#define sk_CMS_CertificateChoices_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_CertificateChoices, (st), (cmp))
+#define sk_CMS_CertificateChoices_dup(st) SKM_sk_dup(CMS_CertificateChoices, st)
+#define sk_CMS_CertificateChoices_pop_free(st, free_func) SKM_sk_pop_free(CMS_CertificateChoices, (st), (free_func))
+#define sk_CMS_CertificateChoices_shift(st) SKM_sk_shift(CMS_CertificateChoices, (st))
+#define sk_CMS_CertificateChoices_pop(st) SKM_sk_pop(CMS_CertificateChoices, (st))
+#define sk_CMS_CertificateChoices_sort(st) SKM_sk_sort(CMS_CertificateChoices, (st))
+#define sk_CMS_CertificateChoices_is_sorted(st) SKM_sk_is_sorted(CMS_CertificateChoices, (st))
+
+#define sk_CMS_RecipientInfo_new(st) SKM_sk_new(CMS_RecipientInfo, (st))
+#define sk_CMS_RecipientInfo_new_null() SKM_sk_new_null(CMS_RecipientInfo)
+#define sk_CMS_RecipientInfo_free(st) SKM_sk_free(CMS_RecipientInfo, (st))
+#define sk_CMS_RecipientInfo_num(st) SKM_sk_num(CMS_RecipientInfo, (st))
+#define sk_CMS_RecipientInfo_value(st, i) SKM_sk_value(CMS_RecipientInfo, (st), (i))
+#define sk_CMS_RecipientInfo_set(st, i, val) SKM_sk_set(CMS_RecipientInfo, (st), (i), (val))
+#define sk_CMS_RecipientInfo_zero(st) SKM_sk_zero(CMS_RecipientInfo, (st))
+#define sk_CMS_RecipientInfo_push(st, val) SKM_sk_push(CMS_RecipientInfo, (st), (val))
+#define sk_CMS_RecipientInfo_unshift(st, val) SKM_sk_unshift(CMS_RecipientInfo, (st), (val))
+#define sk_CMS_RecipientInfo_find(st, val) SKM_sk_find(CMS_RecipientInfo, (st), (val))
+#define sk_CMS_RecipientInfo_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientInfo, (st), (val))
+#define sk_CMS_RecipientInfo_delete(st, i) SKM_sk_delete(CMS_RecipientInfo, (st), (i))
+#define sk_CMS_RecipientInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientInfo, (st), (ptr))
+#define sk_CMS_RecipientInfo_insert(st, val, i) SKM_sk_insert(CMS_RecipientInfo, (st), (val), (i))
+#define sk_CMS_RecipientInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientInfo, (st), (cmp))
+#define sk_CMS_RecipientInfo_dup(st) SKM_sk_dup(CMS_RecipientInfo, st)
+#define sk_CMS_RecipientInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientInfo, (st), (free_func))
+#define sk_CMS_RecipientInfo_shift(st) SKM_sk_shift(CMS_RecipientInfo, (st))
+#define sk_CMS_RecipientInfo_pop(st) SKM_sk_pop(CMS_RecipientInfo, (st))
+#define sk_CMS_RecipientInfo_sort(st) SKM_sk_sort(CMS_RecipientInfo, (st))
+#define sk_CMS_RecipientInfo_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientInfo, (st))
+
+#define sk_CMS_RevocationInfoChoice_new(st) SKM_sk_new(CMS_RevocationInfoChoice, (st))
+#define sk_CMS_RevocationInfoChoice_new_null() SKM_sk_new_null(CMS_RevocationInfoChoice)
+#define sk_CMS_RevocationInfoChoice_free(st) SKM_sk_free(CMS_RevocationInfoChoice, (st))
+#define sk_CMS_RevocationInfoChoice_num(st) SKM_sk_num(CMS_RevocationInfoChoice, (st))
+#define sk_CMS_RevocationInfoChoice_value(st, i) SKM_sk_value(CMS_RevocationInfoChoice, (st), (i))
+#define sk_CMS_RevocationInfoChoice_set(st, i, val) SKM_sk_set(CMS_RevocationInfoChoice, (st), (i), (val))
+#define sk_CMS_RevocationInfoChoice_zero(st) SKM_sk_zero(CMS_RevocationInfoChoice, (st))
+#define sk_CMS_RevocationInfoChoice_push(st, val) SKM_sk_push(CMS_RevocationInfoChoice, (st), (val))
+#define sk_CMS_RevocationInfoChoice_unshift(st, val) SKM_sk_unshift(CMS_RevocationInfoChoice, (st), (val))
+#define sk_CMS_RevocationInfoChoice_find(st, val) SKM_sk_find(CMS_RevocationInfoChoice, (st), (val))
+#define sk_CMS_RevocationInfoChoice_find_ex(st, val) SKM_sk_find_ex(CMS_RevocationInfoChoice, (st), (val))
+#define sk_CMS_RevocationInfoChoice_delete(st, i) SKM_sk_delete(CMS_RevocationInfoChoice, (st), (i))
+#define sk_CMS_RevocationInfoChoice_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RevocationInfoChoice, (st), (ptr))
+#define sk_CMS_RevocationInfoChoice_insert(st, val, i) SKM_sk_insert(CMS_RevocationInfoChoice, (st), (val), (i))
+#define sk_CMS_RevocationInfoChoice_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RevocationInfoChoice, (st), (cmp))
+#define sk_CMS_RevocationInfoChoice_dup(st) SKM_sk_dup(CMS_RevocationInfoChoice, st)
+#define sk_CMS_RevocationInfoChoice_pop_free(st, free_func) SKM_sk_pop_free(CMS_RevocationInfoChoice, (st), (free_func))
+#define sk_CMS_RevocationInfoChoice_shift(st) SKM_sk_shift(CMS_RevocationInfoChoice, (st))
+#define sk_CMS_RevocationInfoChoice_pop(st) SKM_sk_pop(CMS_RevocationInfoChoice, (st))
+#define sk_CMS_RevocationInfoChoice_sort(st) SKM_sk_sort(CMS_RevocationInfoChoice, (st))
+#define sk_CMS_RevocationInfoChoice_is_sorted(st) SKM_sk_is_sorted(CMS_RevocationInfoChoice, (st))
+
+#define sk_CMS_SignerInfo_new(st) SKM_sk_new(CMS_SignerInfo, (st))
+#define sk_CMS_SignerInfo_new_null() SKM_sk_new_null(CMS_SignerInfo)
+#define sk_CMS_SignerInfo_free(st) SKM_sk_free(CMS_SignerInfo, (st))
+#define sk_CMS_SignerInfo_num(st) SKM_sk_num(CMS_SignerInfo, (st))
+#define sk_CMS_SignerInfo_value(st, i) SKM_sk_value(CMS_SignerInfo, (st), (i))
+#define sk_CMS_SignerInfo_set(st, i, val) SKM_sk_set(CMS_SignerInfo, (st), (i), (val))
+#define sk_CMS_SignerInfo_zero(st) SKM_sk_zero(CMS_SignerInfo, (st))
+#define sk_CMS_SignerInfo_push(st, val) SKM_sk_push(CMS_SignerInfo, (st), (val))
+#define sk_CMS_SignerInfo_unshift(st, val) SKM_sk_unshift(CMS_SignerInfo, (st), (val))
+#define sk_CMS_SignerInfo_find(st, val) SKM_sk_find(CMS_SignerInfo, (st), (val))
+#define sk_CMS_SignerInfo_find_ex(st, val) SKM_sk_find_ex(CMS_SignerInfo, (st), (val))
+#define sk_CMS_SignerInfo_delete(st, i) SKM_sk_delete(CMS_SignerInfo, (st), (i))
+#define sk_CMS_SignerInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_SignerInfo, (st), (ptr))
+#define sk_CMS_SignerInfo_insert(st, val, i) SKM_sk_insert(CMS_SignerInfo, (st), (val), (i))
+#define sk_CMS_SignerInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_SignerInfo, (st), (cmp))
+#define sk_CMS_SignerInfo_dup(st) SKM_sk_dup(CMS_SignerInfo, st)
+#define sk_CMS_SignerInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_SignerInfo, (st), (free_func))
+#define sk_CMS_SignerInfo_shift(st) SKM_sk_shift(CMS_SignerInfo, (st))
+#define sk_CMS_SignerInfo_pop(st) SKM_sk_pop(CMS_SignerInfo, (st))
+#define sk_CMS_SignerInfo_sort(st) SKM_sk_sort(CMS_SignerInfo, (st))
+#define sk_CMS_SignerInfo_is_sorted(st) SKM_sk_is_sorted(CMS_SignerInfo, (st))
+
+#define sk_CONF_IMODULE_new(st) SKM_sk_new(CONF_IMODULE, (st))
+#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE)
+#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st))
+#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st))
+#define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i))
+#define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val))
+#define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st))
+#define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val))
+#define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val))
+#define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val))
+#define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val))
+#define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i))
+#define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr))
+#define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i))
+#define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp))
+#define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st)
+#define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func))
+#define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st))
+#define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st))
+#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st))
+#define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st))
+
+#define sk_CONF_MODULE_new(st) SKM_sk_new(CONF_MODULE, (st))
+#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE)
+#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st))
+#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st))
+#define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i))
+#define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val))
+#define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st))
+#define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val))
+#define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val))
+#define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val))
+#define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val))
+#define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i))
+#define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr))
+#define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i))
+#define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp))
+#define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st)
+#define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func))
+#define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st))
+#define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st))
+#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st))
+#define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st))
+
+#define sk_CONF_VALUE_new(st) SKM_sk_new(CONF_VALUE, (st))
+#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE)
+#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st))
+#define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st))
+#define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i))
+#define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val))
+#define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st))
+#define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val))
+#define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val))
+#define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val))
+#define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val))
+#define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i))
+#define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr))
+#define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i))
+#define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp))
+#define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st)
+#define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func))
+#define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st))
+#define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st))
+#define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st))
+#define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st))
+
+#define sk_CRYPTO_EX_DATA_FUNCS_new(st) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (st))
+#define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS)
+#define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st))
+#define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st))
+#define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i))
+#define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val))
+#define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st))
+#define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val))
+#define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val))
+#define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val))
+#define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val))
+#define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i))
+#define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr))
+#define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i))
+#define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp))
+#define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st)
+#define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func))
+#define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st))
+#define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st))
+#define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st))
+#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st))
+
+#define sk_CRYPTO_dynlock_new(st) SKM_sk_new(CRYPTO_dynlock, (st))
+#define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock)
+#define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st))
+#define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st))
+#define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i))
+#define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val))
+#define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st))
+#define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val))
+#define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val))
+#define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val))
+#define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val))
+#define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i))
+#define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr))
+#define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i))
+#define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp))
+#define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st)
+#define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func))
+#define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st))
+#define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st))
+#define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st))
+#define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st))
+
+#define sk_DIST_POINT_new(st) SKM_sk_new(DIST_POINT, (st))
+#define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT)
+#define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st))
+#define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st))
+#define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i))
+#define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val))
+#define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st))
+#define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val))
+#define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val))
+#define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val))
+#define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val))
+#define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i))
+#define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr))
+#define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i))
+#define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp))
+#define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st)
+#define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func))
+#define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st))
+#define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st))
+#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st))
+#define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st))
+
+#define sk_ENGINE_new(st) SKM_sk_new(ENGINE, (st))
+#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE)
+#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st))
+#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st))
+#define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i))
+#define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val))
+#define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st))
+#define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val))
+#define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val))
+#define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val))
+#define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val))
+#define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i))
+#define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr))
+#define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i))
+#define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp))
+#define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st)
+#define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func))
+#define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st))
+#define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st))
+#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st))
+#define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st))
+
+#define sk_ENGINE_CLEANUP_ITEM_new(st) SKM_sk_new(ENGINE_CLEANUP_ITEM, (st))
+#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM)
+#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st))
+#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st))
+#define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i))
+#define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val))
+#define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st))
+#define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val))
+#define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val))
+#define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val))
+#define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val))
+#define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i))
+#define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr))
+#define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i))
+#define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp))
+#define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st)
+#define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func))
+#define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st))
+#define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st))
+#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st))
+#define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st))
+
+#define sk_GENERAL_NAME_new(st) SKM_sk_new(GENERAL_NAME, (st))
+#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME)
+#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st))
+#define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st))
+#define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i))
+#define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val))
+#define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st))
+#define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val))
+#define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val))
+#define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val))
+#define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val))
+#define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i))
+#define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr))
+#define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i))
+#define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp))
+#define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st)
+#define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func))
+#define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st))
+#define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st))
+#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st))
+#define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st))
+
+#define sk_GENERAL_NAMES_new(st) SKM_sk_new(GENERAL_NAMES, (st))
+#define sk_GENERAL_NAMES_new_null() SKM_sk_new_null(GENERAL_NAMES)
+#define sk_GENERAL_NAMES_free(st) SKM_sk_free(GENERAL_NAMES, (st))
+#define sk_GENERAL_NAMES_num(st) SKM_sk_num(GENERAL_NAMES, (st))
+#define sk_GENERAL_NAMES_value(st, i) SKM_sk_value(GENERAL_NAMES, (st), (i))
+#define sk_GENERAL_NAMES_set(st, i, val) SKM_sk_set(GENERAL_NAMES, (st), (i), (val))
+#define sk_GENERAL_NAMES_zero(st) SKM_sk_zero(GENERAL_NAMES, (st))
+#define sk_GENERAL_NAMES_push(st, val) SKM_sk_push(GENERAL_NAMES, (st), (val))
+#define sk_GENERAL_NAMES_unshift(st, val) SKM_sk_unshift(GENERAL_NAMES, (st), (val))
+#define sk_GENERAL_NAMES_find(st, val) SKM_sk_find(GENERAL_NAMES, (st), (val))
+#define sk_GENERAL_NAMES_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAMES, (st), (val))
+#define sk_GENERAL_NAMES_delete(st, i) SKM_sk_delete(GENERAL_NAMES, (st), (i))
+#define sk_GENERAL_NAMES_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAMES, (st), (ptr))
+#define sk_GENERAL_NAMES_insert(st, val, i) SKM_sk_insert(GENERAL_NAMES, (st), (val), (i))
+#define sk_GENERAL_NAMES_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAMES, (st), (cmp))
+#define sk_GENERAL_NAMES_dup(st) SKM_sk_dup(GENERAL_NAMES, st)
+#define sk_GENERAL_NAMES_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAMES, (st), (free_func))
+#define sk_GENERAL_NAMES_shift(st) SKM_sk_shift(GENERAL_NAMES, (st))
+#define sk_GENERAL_NAMES_pop(st) SKM_sk_pop(GENERAL_NAMES, (st))
+#define sk_GENERAL_NAMES_sort(st) SKM_sk_sort(GENERAL_NAMES, (st))
+#define sk_GENERAL_NAMES_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAMES, (st))
+
+#define sk_GENERAL_SUBTREE_new(st) SKM_sk_new(GENERAL_SUBTREE, (st))
+#define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE)
+#define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st))
+#define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st))
+#define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i))
+#define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val))
+#define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st))
+#define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val))
+#define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val))
+#define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val))
+#define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val))
+#define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i))
+#define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr))
+#define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i))
+#define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp))
+#define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st)
+#define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func))
+#define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st))
+#define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st))
+#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st))
+#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st))
+
+#define sk_IPAddressFamily_new(st) SKM_sk_new(IPAddressFamily, (st))
+#define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily)
+#define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st))
+#define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st))
+#define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i))
+#define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val))
+#define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st))
+#define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val))
+#define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val))
+#define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val))
+#define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val))
+#define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i))
+#define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr))
+#define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i))
+#define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp))
+#define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st)
+#define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func))
+#define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st))
+#define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st))
+#define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st))
+#define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st))
+
+#define sk_IPAddressOrRange_new(st) SKM_sk_new(IPAddressOrRange, (st))
+#define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange)
+#define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st))
+#define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st))
+#define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i))
+#define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val))
+#define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st))
+#define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val))
+#define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val))
+#define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val))
+#define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val))
+#define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i))
+#define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr))
+#define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i))
+#define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp))
+#define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st)
+#define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func))
+#define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st))
+#define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st))
+#define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st))
+#define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st))
+
+#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st))
+#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)
+#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st))
+#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st))
+#define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i))
+#define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val))
+#define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st))
+#define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val))
+#define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val))
+#define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val))
+#define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val))
+#define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i))
+#define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr))
+#define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i))
+#define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp))
+#define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st)
+#define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func))
+#define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st))
+#define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st))
+#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st))
+#define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st))
+
+#define sk_KRB5_AUTHDATA_new(st) SKM_sk_new(KRB5_AUTHDATA, (st))
+#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA)
+#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st))
+#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st))
+#define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i))
+#define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val))
+#define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st))
+#define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val))
+#define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val))
+#define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val))
+#define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val))
+#define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i))
+#define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr))
+#define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i))
+#define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp))
+#define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st)
+#define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func))
+#define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st))
+#define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st))
+#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st))
+#define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st))
+
+#define sk_KRB5_AUTHENTBODY_new(st) SKM_sk_new(KRB5_AUTHENTBODY, (st))
+#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY)
+#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st))
+#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st))
+#define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i))
+#define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val))
+#define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st))
+#define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val))
+#define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val))
+#define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val))
+#define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val))
+#define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i))
+#define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr))
+#define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i))
+#define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp))
+#define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st)
+#define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func))
+#define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st))
+#define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st))
+#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st))
+#define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st))
+
+#define sk_KRB5_CHECKSUM_new(st) SKM_sk_new(KRB5_CHECKSUM, (st))
+#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM)
+#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st))
+#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st))
+#define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i))
+#define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val))
+#define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st))
+#define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val))
+#define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val))
+#define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val))
+#define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val))
+#define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i))
+#define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr))
+#define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i))
+#define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp))
+#define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st)
+#define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func))
+#define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st))
+#define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st))
+#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st))
+#define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st))
+
+#define sk_KRB5_ENCDATA_new(st) SKM_sk_new(KRB5_ENCDATA, (st))
+#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA)
+#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st))
+#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st))
+#define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i))
+#define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val))
+#define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st))
+#define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val))
+#define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val))
+#define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val))
+#define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val))
+#define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i))
+#define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr))
+#define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i))
+#define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp))
+#define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st)
+#define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func))
+#define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st))
+#define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st))
+#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st))
+#define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st))
+
+#define sk_KRB5_ENCKEY_new(st) SKM_sk_new(KRB5_ENCKEY, (st))
+#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY)
+#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st))
+#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st))
+#define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i))
+#define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val))
+#define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st))
+#define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val))
+#define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val))
+#define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val))
+#define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val))
+#define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i))
+#define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr))
+#define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i))
+#define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp))
+#define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st)
+#define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func))
+#define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st))
+#define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st))
+#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st))
+#define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st))
+
+#define sk_KRB5_PRINCNAME_new(st) SKM_sk_new(KRB5_PRINCNAME, (st))
+#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME)
+#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st))
+#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st))
+#define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i))
+#define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val))
+#define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st))
+#define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val))
+#define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val))
+#define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val))
+#define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val))
+#define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i))
+#define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr))
+#define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i))
+#define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp))
+#define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st)
+#define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func))
+#define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st))
+#define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st))
+#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st))
+#define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st))
+
+#define sk_KRB5_TKTBODY_new(st) SKM_sk_new(KRB5_TKTBODY, (st))
+#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY)
+#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st))
+#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st))
+#define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i))
+#define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val))
+#define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st))
+#define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val))
+#define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val))
+#define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val))
+#define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val))
+#define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i))
+#define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr))
+#define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i))
+#define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp))
+#define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st)
+#define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func))
+#define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st))
+#define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st))
+#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st))
+#define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st))
+
+#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st))
+#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)
+#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))
+#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st))
+#define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i))
+#define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val))
+#define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st))
+#define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val))
+#define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val))
+#define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val))
+#define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val))
+#define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i))
+#define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr))
+#define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i))
+#define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp))
+#define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st)
+#define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func))
+#define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st))
+#define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st))
+#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st))
+#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st))
+
+#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st))
+#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)
+#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))
+#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st))
+#define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i))
+#define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val))
+#define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st))
+#define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val))
+#define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val))
+#define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val))
+#define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val))
+#define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i))
+#define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr))
+#define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i))
+#define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp))
+#define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st)
+#define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func))
+#define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st))
+#define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st))
+#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st))
+#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st))
+
+#define sk_MIME_PARAM_new(st) SKM_sk_new(MIME_PARAM, (st))
+#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM)
+#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st))
+#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st))
+#define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i))
+#define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val))
+#define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st))
+#define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val))
+#define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val))
+#define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val))
+#define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val))
+#define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i))
+#define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr))
+#define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i))
+#define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp))
+#define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st)
+#define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func))
+#define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st))
+#define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st))
+#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st))
+#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st))
+
+#define sk_MIME_PARAM_new(st) SKM_sk_new(MIME_PARAM, (st))
+#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM)
+#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st))
+#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st))
+#define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i))
+#define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val))
+#define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st))
+#define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val))
+#define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val))
+#define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val))
+#define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val))
+#define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i))
+#define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr))
+#define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i))
+#define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp))
+#define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st)
+#define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func))
+#define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st))
+#define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st))
+#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st))
+#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st))
+
+#define sk_NAME_FUNCS_new(st) SKM_sk_new(NAME_FUNCS, (st))
+#define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS)
+#define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st))
+#define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st))
+#define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i))
+#define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val))
+#define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st))
+#define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val))
+#define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val))
+#define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val))
+#define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val))
+#define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i))
+#define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr))
+#define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i))
+#define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp))
+#define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st)
+#define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func))
+#define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st))
+#define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st))
+#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st))
+#define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st))
+
+#define sk_OCSP_CERTID_new(st) SKM_sk_new(OCSP_CERTID, (st))
+#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID)
+#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st))
+#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st))
+#define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i))
+#define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val))
+#define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st))
+#define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val))
+#define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val))
+#define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val))
+#define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val))
+#define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i))
+#define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr))
+#define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i))
+#define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp))
+#define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st)
+#define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func))
+#define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st))
+#define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st))
+#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st))
+#define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st))
+
+#define sk_OCSP_ONEREQ_new(st) SKM_sk_new(OCSP_ONEREQ, (st))
+#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ)
+#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st))
+#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st))
+#define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i))
+#define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val))
+#define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st))
+#define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val))
+#define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val))
+#define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val))
+#define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val))
+#define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i))
+#define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr))
+#define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i))
+#define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp))
+#define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st)
+#define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func))
+#define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st))
+#define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st))
+#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st))
+#define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st))
+
+#define sk_OCSP_RESPID_new(st) SKM_sk_new(OCSP_RESPID, (st))
+#define sk_OCSP_RESPID_new_null() SKM_sk_new_null(OCSP_RESPID)
+#define sk_OCSP_RESPID_free(st) SKM_sk_free(OCSP_RESPID, (st))
+#define sk_OCSP_RESPID_num(st) SKM_sk_num(OCSP_RESPID, (st))
+#define sk_OCSP_RESPID_value(st, i) SKM_sk_value(OCSP_RESPID, (st), (i))
+#define sk_OCSP_RESPID_set(st, i, val) SKM_sk_set(OCSP_RESPID, (st), (i), (val))
+#define sk_OCSP_RESPID_zero(st) SKM_sk_zero(OCSP_RESPID, (st))
+#define sk_OCSP_RESPID_push(st, val) SKM_sk_push(OCSP_RESPID, (st), (val))
+#define sk_OCSP_RESPID_unshift(st, val) SKM_sk_unshift(OCSP_RESPID, (st), (val))
+#define sk_OCSP_RESPID_find(st, val) SKM_sk_find(OCSP_RESPID, (st), (val))
+#define sk_OCSP_RESPID_find_ex(st, val) SKM_sk_find_ex(OCSP_RESPID, (st), (val))
+#define sk_OCSP_RESPID_delete(st, i) SKM_sk_delete(OCSP_RESPID, (st), (i))
+#define sk_OCSP_RESPID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_RESPID, (st), (ptr))
+#define sk_OCSP_RESPID_insert(st, val, i) SKM_sk_insert(OCSP_RESPID, (st), (val), (i))
+#define sk_OCSP_RESPID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_RESPID, (st), (cmp))
+#define sk_OCSP_RESPID_dup(st) SKM_sk_dup(OCSP_RESPID, st)
+#define sk_OCSP_RESPID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_RESPID, (st), (free_func))
+#define sk_OCSP_RESPID_shift(st) SKM_sk_shift(OCSP_RESPID, (st))
+#define sk_OCSP_RESPID_pop(st) SKM_sk_pop(OCSP_RESPID, (st))
+#define sk_OCSP_RESPID_sort(st) SKM_sk_sort(OCSP_RESPID, (st))
+#define sk_OCSP_RESPID_is_sorted(st) SKM_sk_is_sorted(OCSP_RESPID, (st))
+
+#define sk_OCSP_SINGLERESP_new(st) SKM_sk_new(OCSP_SINGLERESP, (st))
+#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP)
+#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st))
+#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st))
+#define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i))
+#define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val))
+#define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st))
+#define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val))
+#define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val))
+#define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val))
+#define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val))
+#define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i))
+#define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr))
+#define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i))
+#define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp))
+#define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st)
+#define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func))
+#define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st))
+#define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st))
+#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st))
+#define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st))
+
+#define sk_PKCS12_SAFEBAG_new(st) SKM_sk_new(PKCS12_SAFEBAG, (st))
+#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG)
+#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st))
+#define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st))
+#define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i))
+#define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val))
+#define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st))
+#define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val))
+#define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val))
+#define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val))
+#define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val))
+#define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i))
+#define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr))
+#define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i))
+#define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp))
+#define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st)
+#define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func))
+#define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st))
+#define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st))
+#define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st))
+#define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st))
+
+#define sk_PKCS7_new(st) SKM_sk_new(PKCS7, (st))
+#define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7)
+#define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st))
+#define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st))
+#define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i))
+#define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val))
+#define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st))
+#define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val))
+#define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val))
+#define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val))
+#define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val))
+#define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i))
+#define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr))
+#define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i))
+#define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp))
+#define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st)
+#define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func))
+#define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st))
+#define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st))
+#define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st))
+#define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st))
+
+#define sk_PKCS7_RECIP_INFO_new(st) SKM_sk_new(PKCS7_RECIP_INFO, (st))
+#define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO)
+#define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st))
+#define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st))
+#define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i))
+#define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val))
+#define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st))
+#define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val))
+#define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val))
+#define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val))
+#define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val))
+#define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i))
+#define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr))
+#define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i))
+#define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp))
+#define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st)
+#define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func))
+#define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st))
+#define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st))
+#define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st))
+#define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st))
+
+#define sk_PKCS7_SIGNER_INFO_new(st) SKM_sk_new(PKCS7_SIGNER_INFO, (st))
+#define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO)
+#define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st))
+#define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st))
+#define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i))
+#define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val))
+#define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st))
+#define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val))
+#define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val))
+#define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val))
+#define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val))
+#define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i))
+#define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr))
+#define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i))
+#define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp))
+#define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st)
+#define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func))
+#define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st))
+#define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st))
+#define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st))
+#define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st))
+
+#define sk_POLICYINFO_new(st) SKM_sk_new(POLICYINFO, (st))
+#define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO)
+#define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st))
+#define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st))
+#define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i))
+#define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val))
+#define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st))
+#define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val))
+#define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val))
+#define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val))
+#define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val))
+#define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i))
+#define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr))
+#define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i))
+#define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp))
+#define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st)
+#define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func))
+#define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st))
+#define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st))
+#define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st))
+#define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st))
+
+#define sk_POLICYQUALINFO_new(st) SKM_sk_new(POLICYQUALINFO, (st))
+#define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO)
+#define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st))
+#define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st))
+#define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i))
+#define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val))
+#define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st))
+#define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val))
+#define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val))
+#define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val))
+#define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val))
+#define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i))
+#define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr))
+#define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i))
+#define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp))
+#define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st)
+#define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func))
+#define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st))
+#define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st))
+#define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st))
+#define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st))
+
+#define sk_POLICY_MAPPING_new(st) SKM_sk_new(POLICY_MAPPING, (st))
+#define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING)
+#define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st))
+#define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st))
+#define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i))
+#define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val))
+#define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st))
+#define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val))
+#define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val))
+#define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val))
+#define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val))
+#define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i))
+#define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr))
+#define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i))
+#define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp))
+#define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st)
+#define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func))
+#define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st))
+#define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st))
+#define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st))
+#define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st))
+
+#define sk_SSL_CIPHER_new(st) SKM_sk_new(SSL_CIPHER, (st))
+#define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER)
+#define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st))
+#define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st))
+#define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i))
+#define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val))
+#define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st))
+#define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val))
+#define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val))
+#define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val))
+#define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val))
+#define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i))
+#define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr))
+#define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i))
+#define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp))
+#define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st)
+#define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func))
+#define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st))
+#define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st))
+#define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st))
+#define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st))
+
+#define sk_SSL_COMP_new(st) SKM_sk_new(SSL_COMP, (st))
+#define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP)
+#define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st))
+#define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st))
+#define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i))
+#define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val))
+#define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st))
+#define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val))
+#define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val))
+#define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val))
+#define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val))
+#define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i))
+#define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr))
+#define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i))
+#define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp))
+#define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st)
+#define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func))
+#define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st))
+#define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st))
+#define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st))
+#define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st))
+
+#define sk_STORE_OBJECT_new(st) SKM_sk_new(STORE_OBJECT, (st))
+#define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT)
+#define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st))
+#define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st))
+#define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i))
+#define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val))
+#define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st))
+#define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val))
+#define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val))
+#define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val))
+#define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val))
+#define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i))
+#define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr))
+#define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i))
+#define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp))
+#define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st)
+#define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func))
+#define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st))
+#define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st))
+#define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st))
+#define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st))
+
+#define sk_SXNETID_new(st) SKM_sk_new(SXNETID, (st))
+#define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID)
+#define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st))
+#define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st))
+#define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i))
+#define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val))
+#define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st))
+#define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val))
+#define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val))
+#define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val))
+#define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val))
+#define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i))
+#define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr))
+#define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i))
+#define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp))
+#define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st)
+#define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func))
+#define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st))
+#define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st))
+#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st))
+#define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st))
+
+#define sk_UI_STRING_new(st) SKM_sk_new(UI_STRING, (st))
+#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING)
+#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st))
+#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st))
+#define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i))
+#define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val))
+#define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st))
+#define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val))
+#define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val))
+#define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val))
+#define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val))
+#define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i))
+#define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr))
+#define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i))
+#define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp))
+#define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st)
+#define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func))
+#define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st))
+#define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st))
+#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st))
+#define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st))
+
+#define sk_X509_new(st) SKM_sk_new(X509, (st))
+#define sk_X509_new_null() SKM_sk_new_null(X509)
+#define sk_X509_free(st) SKM_sk_free(X509, (st))
+#define sk_X509_num(st) SKM_sk_num(X509, (st))
+#define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i))
+#define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val))
+#define sk_X509_zero(st) SKM_sk_zero(X509, (st))
+#define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val))
+#define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val))
+#define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val))
+#define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val))
+#define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i))
+#define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr))
+#define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i))
+#define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp))
+#define sk_X509_dup(st) SKM_sk_dup(X509, st)
+#define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func))
+#define sk_X509_shift(st) SKM_sk_shift(X509, (st))
+#define sk_X509_pop(st) SKM_sk_pop(X509, (st))
+#define sk_X509_sort(st) SKM_sk_sort(X509, (st))
+#define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st))
+
+#define sk_X509V3_EXT_METHOD_new(st) SKM_sk_new(X509V3_EXT_METHOD, (st))
+#define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD)
+#define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st))
+#define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st))
+#define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i))
+#define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val))
+#define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st))
+#define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val))
+#define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val))
+#define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val))
+#define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val))
+#define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i))
+#define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr))
+#define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i))
+#define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp))
+#define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st)
+#define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func))
+#define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st))
+#define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st))
+#define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st))
+#define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st))
+
+#define sk_X509_ALGOR_new(st) SKM_sk_new(X509_ALGOR, (st))
+#define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR)
+#define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st))
+#define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st))
+#define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i))
+#define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val))
+#define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st))
+#define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val))
+#define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val))
+#define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val))
+#define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val))
+#define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i))
+#define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr))
+#define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i))
+#define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp))
+#define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st)
+#define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func))
+#define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st))
+#define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st))
+#define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st))
+#define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st))
+
+#define sk_X509_ATTRIBUTE_new(st) SKM_sk_new(X509_ATTRIBUTE, (st))
+#define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE)
+#define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st))
+#define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st))
+#define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i))
+#define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val))
+#define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st))
+#define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val))
+#define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val))
+#define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val))
+#define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val))
+#define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i))
+#define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr))
+#define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i))
+#define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp))
+#define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st)
+#define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func))
+#define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st))
+#define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st))
+#define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st))
+#define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st))
+
+#define sk_X509_CRL_new(st) SKM_sk_new(X509_CRL, (st))
+#define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL)
+#define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st))
+#define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st))
+#define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i))
+#define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val))
+#define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st))
+#define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val))
+#define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val))
+#define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val))
+#define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val))
+#define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i))
+#define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr))
+#define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i))
+#define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp))
+#define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st)
+#define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func))
+#define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st))
+#define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st))
+#define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st))
+#define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st))
+
+#define sk_X509_EXTENSION_new(st) SKM_sk_new(X509_EXTENSION, (st))
+#define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION)
+#define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st))
+#define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st))
+#define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i))
+#define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val))
+#define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st))
+#define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val))
+#define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val))
+#define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val))
+#define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val))
+#define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i))
+#define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr))
+#define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i))
+#define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp))
+#define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st)
+#define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func))
+#define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st))
+#define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st))
+#define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st))
+#define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st))
+
+#define sk_X509_INFO_new(st) SKM_sk_new(X509_INFO, (st))
+#define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO)
+#define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st))
+#define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st))
+#define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i))
+#define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val))
+#define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st))
+#define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val))
+#define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val))
+#define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val))
+#define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val))
+#define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i))
+#define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr))
+#define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i))
+#define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp))
+#define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st)
+#define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func))
+#define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st))
+#define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st))
+#define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st))
+#define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st))
+
+#define sk_X509_LOOKUP_new(st) SKM_sk_new(X509_LOOKUP, (st))
+#define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP)
+#define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st))
+#define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st))
+#define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i))
+#define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val))
+#define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st))
+#define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val))
+#define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val))
+#define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val))
+#define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val))
+#define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i))
+#define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr))
+#define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i))
+#define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp))
+#define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st)
+#define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func))
+#define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st))
+#define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st))
+#define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st))
+#define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st))
+
+#define sk_X509_NAME_new(st) SKM_sk_new(X509_NAME, (st))
+#define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME)
+#define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st))
+#define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st))
+#define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i))
+#define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val))
+#define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st))
+#define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val))
+#define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val))
+#define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val))
+#define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val))
+#define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i))
+#define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr))
+#define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i))
+#define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp))
+#define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st)
+#define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func))
+#define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st))
+#define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st))
+#define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st))
+#define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st))
+
+#define sk_X509_NAME_ENTRY_new(st) SKM_sk_new(X509_NAME_ENTRY, (st))
+#define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY)
+#define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st))
+#define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st))
+#define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i))
+#define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val))
+#define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st))
+#define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val))
+#define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val))
+#define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val))
+#define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val))
+#define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i))
+#define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr))
+#define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i))
+#define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp))
+#define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st)
+#define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func))
+#define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st))
+#define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st))
+#define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st))
+#define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st))
+
+#define sk_X509_OBJECT_new(st) SKM_sk_new(X509_OBJECT, (st))
+#define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT)
+#define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st))
+#define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st))
+#define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i))
+#define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val))
+#define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st))
+#define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val))
+#define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val))
+#define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val))
+#define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val))
+#define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i))
+#define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr))
+#define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i))
+#define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp))
+#define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st)
+#define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func))
+#define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st))
+#define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st))
+#define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st))
+#define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st))
+
+#define sk_X509_POLICY_DATA_new(st) SKM_sk_new(X509_POLICY_DATA, (st))
+#define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA)
+#define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st))
+#define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st))
+#define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i))
+#define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val))
+#define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st))
+#define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val))
+#define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val))
+#define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val))
+#define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val))
+#define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i))
+#define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr))
+#define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i))
+#define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp))
+#define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st)
+#define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func))
+#define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st))
+#define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st))
+#define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st))
+#define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st))
+
+#define sk_X509_POLICY_NODE_new(st) SKM_sk_new(X509_POLICY_NODE, (st))
+#define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE)
+#define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st))
+#define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st))
+#define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i))
+#define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val))
+#define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st))
+#define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val))
+#define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val))
+#define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val))
+#define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val))
+#define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i))
+#define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr))
+#define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i))
+#define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp))
+#define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st)
+#define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func))
+#define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st))
+#define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st))
+#define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st))
+#define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st))
+
+#define sk_X509_POLICY_REF_new(st) SKM_sk_new(X509_POLICY_REF, (st))
+#define sk_X509_POLICY_REF_new_null() SKM_sk_new_null(X509_POLICY_REF)
+#define sk_X509_POLICY_REF_free(st) SKM_sk_free(X509_POLICY_REF, (st))
+#define sk_X509_POLICY_REF_num(st) SKM_sk_num(X509_POLICY_REF, (st))
+#define sk_X509_POLICY_REF_value(st, i) SKM_sk_value(X509_POLICY_REF, (st), (i))
+#define sk_X509_POLICY_REF_set(st, i, val) SKM_sk_set(X509_POLICY_REF, (st), (i), (val))
+#define sk_X509_POLICY_REF_zero(st) SKM_sk_zero(X509_POLICY_REF, (st))
+#define sk_X509_POLICY_REF_push(st, val) SKM_sk_push(X509_POLICY_REF, (st), (val))
+#define sk_X509_POLICY_REF_unshift(st, val) SKM_sk_unshift(X509_POLICY_REF, (st), (val))
+#define sk_X509_POLICY_REF_find(st, val) SKM_sk_find(X509_POLICY_REF, (st), (val))
+#define sk_X509_POLICY_REF_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_REF, (st), (val))
+#define sk_X509_POLICY_REF_delete(st, i) SKM_sk_delete(X509_POLICY_REF, (st), (i))
+#define sk_X509_POLICY_REF_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_REF, (st), (ptr))
+#define sk_X509_POLICY_REF_insert(st, val, i) SKM_sk_insert(X509_POLICY_REF, (st), (val), (i))
+#define sk_X509_POLICY_REF_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_REF, (st), (cmp))
+#define sk_X509_POLICY_REF_dup(st) SKM_sk_dup(X509_POLICY_REF, st)
+#define sk_X509_POLICY_REF_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_REF, (st), (free_func))
+#define sk_X509_POLICY_REF_shift(st) SKM_sk_shift(X509_POLICY_REF, (st))
+#define sk_X509_POLICY_REF_pop(st) SKM_sk_pop(X509_POLICY_REF, (st))
+#define sk_X509_POLICY_REF_sort(st) SKM_sk_sort(X509_POLICY_REF, (st))
+#define sk_X509_POLICY_REF_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_REF, (st))
+
+#define sk_X509_PURPOSE_new(st) SKM_sk_new(X509_PURPOSE, (st))
+#define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE)
+#define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st))
+#define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st))
+#define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i))
+#define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val))
+#define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st))
+#define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val))
+#define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val))
+#define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val))
+#define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val))
+#define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i))
+#define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr))
+#define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i))
+#define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp))
+#define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st)
+#define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func))
+#define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st))
+#define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st))
+#define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st))
+#define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st))
+
+#define sk_X509_REVOKED_new(st) SKM_sk_new(X509_REVOKED, (st))
+#define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED)
+#define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st))
+#define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st))
+#define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i))
+#define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val))
+#define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st))
+#define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val))
+#define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val))
+#define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val))
+#define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val))
+#define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i))
+#define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr))
+#define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i))
+#define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp))
+#define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st)
+#define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func))
+#define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st))
+#define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st))
+#define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st))
+#define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st))
+
+#define sk_X509_TRUST_new(st) SKM_sk_new(X509_TRUST, (st))
+#define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST)
+#define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st))
+#define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st))
+#define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i))
+#define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val))
+#define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st))
+#define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val))
+#define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val))
+#define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val))
+#define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val))
+#define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i))
+#define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr))
+#define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i))
+#define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp))
+#define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st)
+#define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func))
+#define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st))
+#define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st))
+#define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st))
+#define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st))
+
+#define sk_X509_VERIFY_PARAM_new(st) SKM_sk_new(X509_VERIFY_PARAM, (st))
+#define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM)
+#define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st))
+#define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st))
+#define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i))
+#define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val))
+#define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st))
+#define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val))
+#define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val))
+#define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val))
+#define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val))
+#define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i))
+#define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr))
+#define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i))
+#define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp))
+#define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st)
+#define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func))
+#define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st))
+#define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st))
+#define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st))
+#define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st))
+
+#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_X509(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func))
+
+#define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
+ SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
+#define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \
+ SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
+#define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \
+ SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len))
+#define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \
+ SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func))
+
+#define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \
+ SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
+
+#define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \
+ SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
+/* End of util/mkstack.pl block, you may now edit :-) */
+
+#endif /* !defined HEADER_SAFESTACK_H */
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/sha.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/sha.h
new file mode 100644
index 000000000..47a2c29f6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/sha.h
@@ -0,0 +1,203 @@
+/* crypto/sha/sha.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_SHA_H
+#define HEADER_SHA_H
+
+#include <openssl/e_os2.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))
+#error SHA is disabled.
+#endif
+
+#if defined(OPENSSL_FIPS)
+#define FIPS_SHA_SIZE_T size_t
+#endif
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then !
+ * ! SHA_LONG_LOG2 has to be defined along. !
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ */
+
+#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
+#define SHA_LONG unsigned long
+#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
+#define SHA_LONG unsigned long
+#define SHA_LONG_LOG2 3
+#else
+#define SHA_LONG unsigned int
+#endif
+
+#define SHA_LBLOCK 16
+#define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a
+ * contiguous array of 32 bit
+ * wide big-endian values. */
+#define SHA_LAST_BLOCK (SHA_CBLOCK-8)
+#define SHA_DIGEST_LENGTH 20
+
+typedef struct SHAstate_st
+ {
+ SHA_LONG h0,h1,h2,h3,h4;
+ SHA_LONG Nl,Nh;
+ SHA_LONG data[SHA_LBLOCK];
+ unsigned int num;
+ } SHA_CTX;
+
+#ifndef OPENSSL_NO_SHA0
+#ifdef OPENSSL_FIPS
+int private_SHA_Init(SHA_CTX *c);
+#endif
+int SHA_Init(SHA_CTX *c);
+int SHA_Update(SHA_CTX *c, const void *data, size_t len);
+int SHA_Final(unsigned char *md, SHA_CTX *c);
+unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md);
+void SHA_Transform(SHA_CTX *c, const unsigned char *data);
+#endif
+#ifndef OPENSSL_NO_SHA1
+int SHA1_Init(SHA_CTX *c);
+int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
+int SHA1_Final(unsigned char *md, SHA_CTX *c);
+unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
+void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
+#endif
+
+#define SHA256_CBLOCK (SHA_LBLOCK*4) /* SHA-256 treats input data as a
+ * contiguous array of 32 bit
+ * wide big-endian values. */
+#define SHA224_DIGEST_LENGTH 28
+#define SHA256_DIGEST_LENGTH 32
+
+typedef struct SHA256state_st
+ {
+ SHA_LONG h[8];
+ SHA_LONG Nl,Nh;
+ SHA_LONG data[SHA_LBLOCK];
+ unsigned int num,md_len;
+ } SHA256_CTX;
+
+#ifndef OPENSSL_NO_SHA256
+int SHA224_Init(SHA256_CTX *c);
+int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
+int SHA224_Final(unsigned char *md, SHA256_CTX *c);
+unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md);
+int SHA256_Init(SHA256_CTX *c);
+int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
+int SHA256_Final(unsigned char *md, SHA256_CTX *c);
+unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md);
+void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
+#endif
+
+#define SHA384_DIGEST_LENGTH 48
+#define SHA512_DIGEST_LENGTH 64
+
+#ifndef OPENSSL_NO_SHA512
+/*
+ * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64
+ * being exactly 64-bit wide. See Implementation Notes in sha512.c
+ * for further details.
+ */
+#define SHA512_CBLOCK (SHA_LBLOCK*8) /* SHA-512 treats input data as a
+ * contiguous array of 64 bit
+ * wide big-endian values. */
+#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
+#define SHA_LONG64 unsigned __int64
+#define U64(C) C##UI64
+#elif defined(__arch64__)
+#define SHA_LONG64 unsigned long
+#define U64(C) C##UL
+#else
+#define SHA_LONG64 unsigned long long
+#define U64(C) C##ULL
+#endif
+
+typedef struct SHA512state_st
+ {
+ SHA_LONG64 h[8];
+ SHA_LONG64 Nl,Nh;
+ union {
+ SHA_LONG64 d[SHA_LBLOCK];
+ unsigned char p[SHA512_CBLOCK];
+ } u;
+ unsigned int num,md_len;
+ } SHA512_CTX;
+#endif
+
+#ifndef OPENSSL_NO_SHA512
+int SHA384_Init(SHA512_CTX *c);
+int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
+int SHA384_Final(unsigned char *md, SHA512_CTX *c);
+unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md);
+int SHA512_Init(SHA512_CTX *c);
+int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
+int SHA512_Final(unsigned char *md, SHA512_CTX *c);
+unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md);
+void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl.h
new file mode 100644
index 000000000..ff8a128d3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl.h
@@ -0,0 +1,2075 @@
+/* ssl/ssl.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ * ECC cipher suite support in OpenSSL originally developed by
+ * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
+ */
+
+#ifndef HEADER_SSL_H
+#define HEADER_SSL_H
+
+#include <openssl/e_os2.h>
+
+#ifndef OPENSSL_NO_COMP
+#include <openssl/comp.h>
+#endif
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+#ifndef OPENSSL_NO_DEPRECATED
+#ifndef OPENSSL_NO_X509
+#include <openssl/x509.h>
+#endif
+#include <openssl/crypto.h>
+#include <openssl/lhash.h>
+#include <openssl/buffer.h>
+#endif
+#include <openssl/pem.h>
+#include <openssl/hmac.h>
+
+#include <openssl/kssl.h>
+#include <openssl/safestack.h>
+#include <openssl/symhacks.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* SSLeay version number for ASN.1 encoding of the session information */
+/* Version 0 - initial version
+ * Version 1 - added the optional peer certificate
+ */
+#define SSL_SESSION_ASN1_VERSION 0x0001
+
+/* text strings for the ciphers */
+#define SSL_TXT_NULL_WITH_MD5 SSL2_TXT_NULL_WITH_MD5
+#define SSL_TXT_RC4_128_WITH_MD5 SSL2_TXT_RC4_128_WITH_MD5
+#define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5
+#define SSL_TXT_RC2_128_CBC_WITH_MD5 SSL2_TXT_RC2_128_CBC_WITH_MD5
+#define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5
+#define SSL_TXT_IDEA_128_CBC_WITH_MD5 SSL2_TXT_IDEA_128_CBC_WITH_MD5
+#define SSL_TXT_DES_64_CBC_WITH_MD5 SSL2_TXT_DES_64_CBC_WITH_MD5
+#define SSL_TXT_DES_64_CBC_WITH_SHA SSL2_TXT_DES_64_CBC_WITH_SHA
+#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5
+#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA
+
+/* VRS Additional Kerberos5 entries
+ */
+#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA
+#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA
+#define SSL_TXT_KRB5_RC4_128_SHA SSL3_TXT_KRB5_RC4_128_SHA
+#define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA
+#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5
+#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5
+#define SSL_TXT_KRB5_RC4_128_MD5 SSL3_TXT_KRB5_RC4_128_MD5
+#define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5
+
+#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA
+#define SSL_TXT_KRB5_RC2_40_CBC_SHA SSL3_TXT_KRB5_RC2_40_CBC_SHA
+#define SSL_TXT_KRB5_RC4_40_SHA SSL3_TXT_KRB5_RC4_40_SHA
+#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5
+#define SSL_TXT_KRB5_RC2_40_CBC_MD5 SSL3_TXT_KRB5_RC2_40_CBC_MD5
+#define SSL_TXT_KRB5_RC4_40_MD5 SSL3_TXT_KRB5_RC4_40_MD5
+
+#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA
+#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5
+#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA
+#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5
+#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA
+#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5
+#define SSL_MAX_KRB5_PRINCIPAL_LENGTH 256
+
+#define SSL_MAX_SSL_SESSION_ID_LENGTH 32
+#define SSL_MAX_SID_CTX_LENGTH 32
+
+#define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8)
+#define SSL_MAX_KEY_ARG_LENGTH 8
+#define SSL_MAX_MASTER_KEY_LENGTH 48
+
+/* These are used to specify which ciphers to use and not to use */
+#define SSL_TXT_LOW "LOW"
+#define SSL_TXT_MEDIUM "MEDIUM"
+#define SSL_TXT_HIGH "HIGH"
+#define SSL_TXT_FIPS "FIPS"
+#define SSL_TXT_kFZA "kFZA"
+#define SSL_TXT_aFZA "aFZA"
+#define SSL_TXT_eFZA "eFZA"
+#define SSL_TXT_FZA "FZA"
+
+#define SSL_TXT_aNULL "aNULL"
+#define SSL_TXT_eNULL "eNULL"
+#define SSL_TXT_NULL "NULL"
+
+#define SSL_TXT_kKRB5 "kKRB5"
+#define SSL_TXT_aKRB5 "aKRB5"
+#define SSL_TXT_KRB5 "KRB5"
+
+#define SSL_TXT_kRSA "kRSA"
+#define SSL_TXT_kDHr "kDHr"
+#define SSL_TXT_kDHd "kDHd"
+#define SSL_TXT_kEDH "kEDH"
+#define SSL_TXT_aRSA "aRSA"
+#define SSL_TXT_aDSS "aDSS"
+#define SSL_TXT_aDH "aDH"
+#define SSL_TXT_DSS "DSS"
+#define SSL_TXT_DH "DH"
+#define SSL_TXT_EDH "EDH"
+#define SSL_TXT_ADH "ADH"
+#define SSL_TXT_RSA "RSA"
+#define SSL_TXT_DES "DES"
+#define SSL_TXT_3DES "3DES"
+#define SSL_TXT_RC4 "RC4"
+#define SSL_TXT_RC2 "RC2"
+#define SSL_TXT_IDEA "IDEA"
+#define SSL_TXT_SEED "SEED"
+#define SSL_TXT_AES "AES"
+#define SSL_TXT_CAMELLIA "CAMELLIA"
+#define SSL_TXT_MD5 "MD5"
+#define SSL_TXT_SHA1 "SHA1"
+#define SSL_TXT_SHA "SHA"
+#define SSL_TXT_EXP "EXP"
+#define SSL_TXT_EXPORT "EXPORT"
+#define SSL_TXT_EXP40 "EXPORT40"
+#define SSL_TXT_EXP56 "EXPORT56"
+#define SSL_TXT_SSLV2 "SSLv2"
+#define SSL_TXT_SSLV3 "SSLv3"
+#define SSL_TXT_TLSV1 "TLSv1"
+#define SSL_TXT_ALL "ALL"
+#define SSL_TXT_ECC "ECCdraft" /* ECC ciphersuites are not yet official */
+
+/*
+ * COMPLEMENTOF* definitions. These identifiers are used to (de-select)
+ * ciphers normally not being used.
+ * Example: "RC4" will activate all ciphers using RC4 including ciphers
+ * without authentication, which would normally disabled by DEFAULT (due
+ * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT"
+ * will make sure that it is also disabled in the specific selection.
+ * COMPLEMENTOF* identifiers are portable between version, as adjustments
+ * to the default cipher setup will also be included here.
+ *
+ * COMPLEMENTOFDEFAULT does not experience the same special treatment that
+ * DEFAULT gets, as only selection is being done and no sorting as needed
+ * for DEFAULT.
+ */
+#define SSL_TXT_CMPALL "COMPLEMENTOFALL"
+#define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT"
+
+/* The following cipher list is used by default.
+ * It also is substituted when an application-defined cipher list string
+ * starts with 'DEFAULT'. */
+#define SSL_DEFAULT_CIPHER_LIST "AES:ALL:!aNULL:!eNULL:+RC4:@STRENGTH" /* low priority for RC4 */
+
+/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
+#define SSL_SENT_SHUTDOWN 1
+#define SSL_RECEIVED_SHUTDOWN 2
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2)
+#define OPENSSL_NO_SSL2
+#endif
+
+#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1
+#define SSL_FILETYPE_PEM X509_FILETYPE_PEM
+
+/* This is needed to stop compilers complaining about the
+ * 'struct ssl_st *' function parameters used to prototype callbacks
+ * in SSL_CTX. */
+typedef struct ssl_st *ssl_crock_st;
+
+/* used to hold info on the particular ciphers used */
+typedef struct ssl_cipher_st
+ {
+ int valid;
+ const char *name; /* text name */
+ unsigned long id; /* id, 4 bytes, first is version */
+ unsigned long algorithms; /* what ciphers are used */
+ unsigned long algo_strength; /* strength and export flags */
+ unsigned long algorithm2; /* Extra flags */
+ int strength_bits; /* Number of bits really used */
+ int alg_bits; /* Number of bits for algorithm */
+ unsigned long mask; /* used for matching */
+ unsigned long mask_strength; /* also used for matching */
+ } SSL_CIPHER;
+
+DECLARE_STACK_OF(SSL_CIPHER)
+
+/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */
+typedef struct ssl_method_st
+ {
+ int version;
+ int (*ssl_new)(SSL *s);
+ void (*ssl_clear)(SSL *s);
+ void (*ssl_free)(SSL *s);
+ int (*ssl_accept)(SSL *s);
+ int (*ssl_connect)(SSL *s);
+ int (*ssl_read)(SSL *s,void *buf,int len);
+ int (*ssl_peek)(SSL *s,void *buf,int len);
+ int (*ssl_write)(SSL *s,const void *buf,int len);
+ int (*ssl_shutdown)(SSL *s);
+ int (*ssl_renegotiate)(SSL *s);
+ int (*ssl_renegotiate_check)(SSL *s);
+ long (*ssl_get_message)(SSL *s, int st1, int stn, int mt, long
+ max, int *ok);
+ int (*ssl_read_bytes)(SSL *s, int type, unsigned char *buf, int len,
+ int peek);
+ int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len);
+ int (*ssl_dispatch_alert)(SSL *s);
+ long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg);
+ long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg);
+ SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr);
+ int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr);
+ int (*ssl_pending)(const SSL *s);
+ int (*num_ciphers)(void);
+ SSL_CIPHER *(*get_cipher)(unsigned ncipher);
+ struct ssl_method_st *(*get_ssl_method)(int version);
+ long (*get_timeout)(void);
+ struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
+ int (*ssl_version)(void);
+ long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void));
+ long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void));
+ } SSL_METHOD;
+
+/* Lets make this into an ASN.1 type structure as follows
+ * SSL_SESSION_ID ::= SEQUENCE {
+ * version INTEGER, -- structure version number
+ * SSLversion INTEGER, -- SSL version number
+ * Cipher OCTET_STRING, -- the 3 byte cipher ID
+ * Session_ID OCTET_STRING, -- the Session ID
+ * Master_key OCTET_STRING, -- the master key
+ * KRB5_principal OCTET_STRING -- optional Kerberos principal
+ * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument
+ * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time
+ * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds
+ * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate
+ * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context
+ * Verify_result [ 5 ] EXPLICIT INTEGER -- X509_V_... code for `Peer'
+ * Compression [6] IMPLICIT ASN1_OBJECT -- compression OID XXXXX
+ * }
+ * Look in ssl/ssl_asn1.c for more details
+ * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).
+ */
+typedef struct ssl_session_st
+ {
+ int ssl_version; /* what ssl version session info is
+ * being kept in here? */
+
+ /* only really used in SSLv2 */
+ unsigned int key_arg_length;
+ unsigned char key_arg[SSL_MAX_KEY_ARG_LENGTH];
+ int master_key_length;
+ unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];
+ /* session_id - valid? */
+ unsigned int session_id_length;
+ unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
+ /* this is used to determine whether the session is being reused in
+ * the appropriate context. It is up to the application to set this,
+ * via SSL_new */
+ unsigned int sid_ctx_length;
+ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
+
+#ifndef OPENSSL_NO_KRB5
+ unsigned int krb5_client_princ_len;
+ unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH];
+#endif /* OPENSSL_NO_KRB5 */
+
+ int not_resumable;
+
+ /* The cert is the certificate used to establish this connection */
+ struct sess_cert_st /* SESS_CERT */ *sess_cert;
+
+ /* This is the cert for the other end.
+ * On clients, it will be the same as sess_cert->peer_key->x509
+ * (the latter is not enough as sess_cert is not retained
+ * in the external representation of sessions, see ssl_asn1.c). */
+ X509 *peer;
+ /* when app_verify_callback accepts a session where the peer's certificate
+ * is not ok, we must remember the error for session reuse: */
+ long verify_result; /* only for servers */
+
+ int references;
+ long timeout;
+ long time;
+
+ int compress_meth; /* Need to lookup the method */
+
+ SSL_CIPHER *cipher;
+ unsigned long cipher_id; /* when ASN.1 loaded, this
+ * needs to be used to load
+ * the 'cipher' structure */
+
+ STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */
+
+ CRYPTO_EX_DATA ex_data; /* application specific data */
+
+ /* These are used to make removal of session-ids more
+ * efficient and to implement a maximum cache size. */
+ struct ssl_session_st *prev,*next;
+#ifndef OPENSSL_NO_TLSEXT
+ char *tlsext_hostname;
+ /* RFC4507 info */
+ unsigned char *tlsext_tick; /* Session ticket */
+ size_t tlsext_ticklen; /* Session ticket length */
+ long tlsext_tick_lifetime_hint; /* Session lifetime hint in seconds */
+#endif
+ } SSL_SESSION;
+
+
+#define SSL_OP_MICROSOFT_SESS_ID_BUG 0x00000001L
+#define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x00000002L
+#define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x00000008L
+#define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x00000010L
+#define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x00000020L
+#define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x00000040L /* no effect since 0.9.7h and 0.9.8b */
+#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L
+#define SSL_OP_TLS_D5_BUG 0x00000100L
+#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L
+
+/* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added
+ * in OpenSSL 0.9.6d. Usually (depending on the application protocol)
+ * the workaround is not needed. Unfortunately some broken SSL/TLS
+ * implementations cannot handle it at all, which is why we include
+ * it in SSL_OP_ALL. */
+#define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800L /* added in 0.9.6e */
+
+/* SSL_OP_ALL: various bug workarounds that should be rather harmless.
+ * This used to be 0x000FFFFFL before 0.9.7. */
+#define SSL_OP_ALL 0x00000FFFL
+
+/* DTLS options */
+#define SSL_OP_NO_QUERY_MTU 0x00001000L
+/* Turn on Cookie Exchange (on relevant for servers) */
+#define SSL_OP_COOKIE_EXCHANGE 0x00002000L
+/* Don't use RFC4507 ticket extension */
+#define SSL_OP_NO_TICKET 0x00004000L
+
+/* As server, disallow session resumption on renegotiation */
+#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000L
+/* If set, always create a new key when using tmp_ecdh parameters */
+#define SSL_OP_SINGLE_ECDH_USE 0x00080000L
+/* If set, always create a new key when using tmp_dh parameters */
+#define SSL_OP_SINGLE_DH_USE 0x00100000L
+/* Set to always use the tmp_rsa key when doing RSA operations,
+ * even when this violates protocol specs */
+#define SSL_OP_EPHEMERAL_RSA 0x00200000L
+/* Set on servers to choose the cipher according to the server's
+ * preferences */
+#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L
+/* If set, a server will allow a client to issue a SSLv3.0 version number
+ * as latest version supported in the premaster secret, even when TLSv1.0
+ * (version 3.1) was announced in the client hello. Normally this is
+ * forbidden to prevent version rollback attacks. */
+#define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L
+
+#define SSL_OP_NO_SSLv2 0x01000000L
+#define SSL_OP_NO_SSLv3 0x02000000L
+#define SSL_OP_NO_TLSv1 0x04000000L
+
+/* The next flag deliberately changes the ciphertest, this is a check
+ * for the PKCS#1 attack */
+#define SSL_OP_PKCS1_CHECK_1 0x08000000L
+#define SSL_OP_PKCS1_CHECK_2 0x10000000L
+#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L
+#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x40000000L
+
+
+/* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
+ * when just a single record has been written): */
+#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L
+/* Make it possible to retry SSL_write() with changed buffer location
+ * (buffer contents must stay the same!); this is not the default to avoid
+ * the misconception that non-blocking SSL_write() behaves like
+ * non-blocking write(): */
+#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L
+/* Never bother the application with retries if the transport
+ * is blocking: */
+#define SSL_MODE_AUTO_RETRY 0x00000004L
+/* Don't attempt to automatically build certificate chain */
+#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L
+
+
+/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
+ * they cannot be used to clear bits. */
+
+#define SSL_CTX_set_options(ctx,op) \
+ SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)
+#define SSL_CTX_get_options(ctx) \
+ SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL)
+#define SSL_set_options(ssl,op) \
+ SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL)
+#define SSL_get_options(ssl) \
+ SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL)
+
+#define SSL_CTX_set_mode(ctx,op) \
+ SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
+#define SSL_CTX_get_mode(ctx) \
+ SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)
+#define SSL_set_mode(ssl,op) \
+ SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)
+#define SSL_get_mode(ssl) \
+ SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)
+#define SSL_set_mtu(ssl, mtu) \
+ SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL)
+
+
+void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
+void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
+#define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))
+#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))
+
+
+
+#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)
+#define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */
+#else
+#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */
+#endif
+
+#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20)
+
+/* This callback type is used inside SSL_CTX, SSL, and in the functions that set
+ * them. It is used to override the generation of SSL/TLS session IDs in a
+ * server. Return value should be zero on an error, non-zero to proceed. Also,
+ * callbacks should themselves check if the id they generate is unique otherwise
+ * the SSL handshake will fail with an error - callbacks can do this using the
+ * 'ssl' value they're passed by;
+ * SSL_has_matching_session_id(ssl, id, *id_len)
+ * The length value passed in is set at the maximum size the session ID can be.
+ * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback
+ * can alter this length to be less if desired, but under SSLv2 session IDs are
+ * supposed to be fixed at 16 bytes so the id will be padded after the callback
+ * returns in this case. It is also an error for the callback to set the size to
+ * zero. */
+typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id,
+ unsigned int *id_len);
+
+typedef struct ssl_comp_st
+ {
+ int id;
+ const char *name;
+#ifndef OPENSSL_NO_COMP
+ COMP_METHOD *method;
+#else
+ char *method;
+#endif
+ } SSL_COMP;
+
+DECLARE_STACK_OF(SSL_COMP)
+
+struct ssl_ctx_st
+ {
+ SSL_METHOD *method;
+
+ STACK_OF(SSL_CIPHER) *cipher_list;
+ /* same as above but sorted for lookup */
+ STACK_OF(SSL_CIPHER) *cipher_list_by_id;
+
+ struct x509_store_st /* X509_STORE */ *cert_store;
+ struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSIONs */
+ /* Most session-ids that will be cached, default is
+ * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */
+ unsigned long session_cache_size;
+ struct ssl_session_st *session_cache_head;
+ struct ssl_session_st *session_cache_tail;
+
+ /* This can have one of 2 values, ored together,
+ * SSL_SESS_CACHE_CLIENT,
+ * SSL_SESS_CACHE_SERVER,
+ * Default is SSL_SESSION_CACHE_SERVER, which means only
+ * SSL_accept which cache SSL_SESSIONS. */
+ int session_cache_mode;
+
+ /* If timeout is not 0, it is the default timeout value set
+ * when SSL_new() is called. This has been put in to make
+ * life easier to set things up */
+ long session_timeout;
+
+ /* If this callback is not null, it will be called each
+ * time a session id is added to the cache. If this function
+ * returns 1, it means that the callback will do a
+ * SSL_SESSION_free() when it has finished using it. Otherwise,
+ * on 0, it means the callback has finished with it.
+ * If remove_session_cb is not null, it will be called when
+ * a session-id is removed from the cache. After the call,
+ * OpenSSL will SSL_SESSION_free() it. */
+ int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess);
+ void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess);
+ SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl,
+ unsigned char *data,int len,int *copy);
+
+ struct
+ {
+ int sess_connect; /* SSL new conn - started */
+ int sess_connect_renegotiate;/* SSL reneg - requested */
+ int sess_connect_good; /* SSL new conne/reneg - finished */
+ int sess_accept; /* SSL new accept - started */
+ int sess_accept_renegotiate;/* SSL reneg - requested */
+ int sess_accept_good; /* SSL accept/reneg - finished */
+ int sess_miss; /* session lookup misses */
+ int sess_timeout; /* reuse attempt on timeouted session */
+ int sess_cache_full; /* session removed due to full cache */
+ int sess_hit; /* session reuse actually done */
+ int sess_cb_hit; /* session-id that was not
+ * in the cache was
+ * passed back via the callback. This
+ * indicates that the application is
+ * supplying session-id's from other
+ * processes - spooky :-) */
+ } stats;
+
+ int references;
+
+ /* if defined, these override the X509_verify_cert() calls */
+ int (*app_verify_callback)(X509_STORE_CTX *, void *);
+ void *app_verify_arg;
+ /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored
+ * ('app_verify_callback' was called with just one argument) */
+
+ /* Default password callback. */
+ pem_password_cb *default_passwd_callback;
+
+ /* Default password callback user data. */
+ void *default_passwd_callback_userdata;
+
+ /* get client cert callback */
+ int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
+
+ /* cookie generate callback */
+ int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie,
+ unsigned int *cookie_len);
+
+ /* verify cookie callback */
+ int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie,
+ unsigned int cookie_len);
+
+ CRYPTO_EX_DATA ex_data;
+
+ const EVP_MD *rsa_md5;/* For SSLv2 - name is 'ssl2-md5' */
+ const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */
+ const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */
+
+ STACK_OF(X509) *extra_certs;
+ STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */
+
+
+ /* Default values used when no per-SSL value is defined follow */
+
+ void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */
+
+ /* what we put in client cert requests */
+ STACK_OF(X509_NAME) *client_CA;
+
+
+ /* Default values to use in SSL structures follow (these are copied by SSL_new) */
+
+ unsigned long options;
+ unsigned long mode;
+ long max_cert_list;
+
+ struct cert_st /* CERT */ *cert;
+ int read_ahead;
+
+ /* callback that allows applications to peek at protocol messages */
+ void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg);
+ void *msg_callback_arg;
+
+ int verify_mode;
+ unsigned int sid_ctx_length;
+ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
+ int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */
+
+ /* Default generate session ID callback. */
+ GEN_SESSION_CB generate_session_id;
+
+ X509_VERIFY_PARAM *param;
+
+#if 0
+ int purpose; /* Purpose setting */
+ int trust; /* Trust setting */
+#endif
+
+ int quiet_shutdown;
+
+#ifndef OPENSSL_ENGINE
+ /* Engine to pass requests for client certs to
+ */
+ ENGINE *client_cert_engine;
+#endif
+
+#ifndef OPENSSL_NO_TLSEXT
+ /* TLS extensions servername callback */
+ int (*tlsext_servername_callback)(SSL*, int *, void *);
+ void *tlsext_servername_arg;
+ /* RFC 4507 session ticket keys */
+ unsigned char tlsext_tick_key_name[16];
+ unsigned char tlsext_tick_hmac_key[16];
+ unsigned char tlsext_tick_aes_key[16];
+ /* Callback to support customisation of ticket key setting */
+ int (*tlsext_ticket_key_cb)(SSL *ssl,
+ unsigned char *name, unsigned char *iv,
+ EVP_CIPHER_CTX *ectx,
+ HMAC_CTX *hctx, int enc);
+
+ /* certificate status request info */
+ /* Callback for status request */
+ int (*tlsext_status_cb)(SSL *ssl, void *arg);
+ void *tlsext_status_arg;
+#endif
+
+ };
+
+#define SSL_SESS_CACHE_OFF 0x0000
+#define SSL_SESS_CACHE_CLIENT 0x0001
+#define SSL_SESS_CACHE_SERVER 0x0002
+#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)
+#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080
+/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */
+#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100
+#define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200
+#define SSL_SESS_CACHE_NO_INTERNAL \
+ (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)
+
+ struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx);
+#define SSL_CTX_sess_number(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)
+#define SSL_CTX_sess_connect(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL)
+#define SSL_CTX_sess_connect_good(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL)
+#define SSL_CTX_sess_connect_renegotiate(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL)
+#define SSL_CTX_sess_accept(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL)
+#define SSL_CTX_sess_accept_renegotiate(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL)
+#define SSL_CTX_sess_accept_good(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL)
+#define SSL_CTX_sess_hits(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL)
+#define SSL_CTX_sess_cb_hits(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL)
+#define SSL_CTX_sess_misses(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL)
+#define SSL_CTX_sess_timeouts(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL)
+#define SSL_CTX_sess_cache_full(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL)
+
+void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess));
+int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl, SSL_SESSION *sess);
+void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess));
+void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, SSL_SESSION *sess);
+void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, unsigned char *data,int len,int *copy));
+SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, unsigned char *Data, int len, int *copy);
+void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(const SSL *ssl,int type,int val));
+void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl,int type,int val);
+void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
+int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
+#ifndef OPENSSL_NO_ENGINE
+int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e);
+#endif
+void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len));
+void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int cookie_len));
+
+#define SSL_NOTHING 1
+#define SSL_WRITING 2
+#define SSL_READING 3
+#define SSL_X509_LOOKUP 4
+
+/* These will only be used when doing non-blocking IO */
+#define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING)
+#define SSL_want_read(s) (SSL_want(s) == SSL_READING)
+#define SSL_want_write(s) (SSL_want(s) == SSL_WRITING)
+#define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP)
+
+struct ssl_st
+ {
+ /* protocol version
+ * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION)
+ */
+ int version;
+ int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */
+
+ SSL_METHOD *method; /* SSLv3 */
+
+ /* There are 2 BIO's even though they are normally both the
+ * same. This is so data can be read and written to different
+ * handlers */
+
+#ifndef OPENSSL_NO_BIO
+ BIO *rbio; /* used by SSL_read */
+ BIO *wbio; /* used by SSL_write */
+ BIO *bbio; /* used during session-id reuse to concatenate
+ * messages */
+#else
+ char *rbio; /* used by SSL_read */
+ char *wbio; /* used by SSL_write */
+ char *bbio;
+#endif
+ /* This holds a variable that indicates what we were doing
+ * when a 0 or -1 is returned. This is needed for
+ * non-blocking IO so we know what request needs re-doing when
+ * in SSL_accept or SSL_connect */
+ int rwstate;
+
+ /* true when we are actually in SSL_accept() or SSL_connect() */
+ int in_handshake;
+ int (*handshake_func)(SSL *);
+
+ /* Imagine that here's a boolean member "init" that is
+ * switched as soon as SSL_set_{accept/connect}_state
+ * is called for the first time, so that "state" and
+ * "handshake_func" are properly initialized. But as
+ * handshake_func is == 0 until then, we use this
+ * test instead of an "init" member.
+ */
+
+ int server; /* are we the server side? - mostly used by SSL_clear*/
+
+ int new_session;/* 1 if we are to use a new session.
+ * 2 if we are a server and are inside a handshake
+ * (i.e. not just sending a HelloRequest)
+ * NB: For servers, the 'new' session may actually be a previously
+ * cached session or even the previous session unless
+ * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */
+ int quiet_shutdown;/* don't send shutdown packets */
+ int shutdown; /* we have shut things down, 0x01 sent, 0x02
+ * for received */
+ int state; /* where we are */
+ int rstate; /* where we are when reading */
+
+ BUF_MEM *init_buf; /* buffer used during init */
+ void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */
+ int init_num; /* amount read/written */
+ int init_off; /* amount read/written */
+
+ /* used internally to point at a raw packet */
+ unsigned char *packet;
+ unsigned int packet_length;
+
+ struct ssl2_state_st *s2; /* SSLv2 variables */
+ struct ssl3_state_st *s3; /* SSLv3 variables */
+ struct dtls1_state_st *d1; /* DTLSv1 variables */
+
+ int read_ahead; /* Read as many input bytes as possible
+ * (for non-blocking reads) */
+
+ /* callback that allows applications to peek at protocol messages */
+ void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg);
+ void *msg_callback_arg;
+
+ int hit; /* reusing a previous session */
+
+ X509_VERIFY_PARAM *param;
+
+#if 0
+ int purpose; /* Purpose setting */
+ int trust; /* Trust setting */
+#endif
+
+ /* crypto */
+ STACK_OF(SSL_CIPHER) *cipher_list;
+ STACK_OF(SSL_CIPHER) *cipher_list_by_id;
+
+ /* These are the ones being used, the ones in SSL_SESSION are
+ * the ones to be 'copied' into these ones */
+
+ EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */
+ const EVP_MD *read_hash; /* used for mac generation */
+#ifndef OPENSSL_NO_COMP
+ COMP_CTX *expand; /* uncompress */
+#else
+ char *expand;
+#endif
+
+ EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
+ const EVP_MD *write_hash; /* used for mac generation */
+#ifndef OPENSSL_NO_COMP
+ COMP_CTX *compress; /* compression */
+#else
+ char *compress;
+#endif
+
+ /* session info */
+
+ /* client cert? */
+ /* This is used to hold the server certificate used */
+ struct cert_st /* CERT */ *cert;
+
+ /* the session_id_context is used to ensure sessions are only reused
+ * in the appropriate context */
+ unsigned int sid_ctx_length;
+ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
+
+ /* This can also be in the session once a session is established */
+ SSL_SESSION *session;
+
+ /* Default generate session ID callback. */
+ GEN_SESSION_CB generate_session_id;
+
+ /* Used in SSL2 and SSL3 */
+ int verify_mode; /* 0 don't care about verify failure.
+ * 1 fail if verify fails */
+ int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */
+
+ void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */
+
+ int error; /* error bytes to be written */
+ int error_code; /* actual code */
+
+#ifndef OPENSSL_NO_KRB5
+ KSSL_CTX *kssl_ctx; /* Kerberos 5 context */
+#endif /* OPENSSL_NO_KRB5 */
+
+ SSL_CTX *ctx;
+ /* set this flag to 1 and a sleep(1) is put into all SSL_read()
+ * and SSL_write() calls, good for nbio debuging :-) */
+ int debug;
+
+ /* extra application data */
+ long verify_result;
+ CRYPTO_EX_DATA ex_data;
+
+ /* for server side, keep the list of CA_dn we can use */
+ STACK_OF(X509_NAME) *client_CA;
+
+ int references;
+ unsigned long options; /* protocol behaviour */
+ unsigned long mode; /* API behaviour */
+ long max_cert_list;
+ int first_packet;
+ int client_version; /* what was passed, used for
+ * SSLv3/TLS rollback check */
+#ifndef OPENSSL_NO_TLSEXT
+ /* TLS extension debug callback */
+ void (*tlsext_debug_cb)(SSL *s, int client_server, int type,
+ unsigned char *data, int len,
+ void *arg);
+ void *tlsext_debug_arg;
+ char *tlsext_hostname;
+ int servername_done; /* no further mod of servername
+ 0 : call the servername extension callback.
+ 1 : prepare 2, allow last ack just after in server callback.
+ 2 : don't call servername callback, no ack in server hello
+ */
+ /* certificate status request info */
+ /* Status type or -1 if no status type */
+ int tlsext_status_type;
+ /* Expect OCSP CertificateStatus message */
+ int tlsext_status_expected;
+ /* OCSP status request only */
+ STACK_OF(OCSP_RESPID) *tlsext_ocsp_ids;
+ X509_EXTENSIONS *tlsext_ocsp_exts;
+ /* OCSP response received or to be sent */
+ unsigned char *tlsext_ocsp_resp;
+ int tlsext_ocsp_resplen;
+
+ /* RFC4507 session ticket expected to be received or sent */
+ int tlsext_ticket_expected;
+ SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */
+#define session_ctx initial_ctx
+#else
+#define session_ctx ctx
+#endif
+ };
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <openssl/ssl2.h>
+#include <openssl/ssl3.h>
+#include <openssl/tls1.h> /* This is mostly sslv3 with a few tweaks */
+#include <openssl/dtls1.h> /* Datagram TLS */
+#include <openssl/ssl23.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* compatibility */
+#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg))
+#define SSL_get_app_data(s) (SSL_get_ex_data(s,0))
+#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a))
+#define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0))
+#define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0))
+#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg))
+
+/* The following are the possible values for ssl->state are are
+ * used to indicate where we are up to in the SSL connection establishment.
+ * The macros that follow are about the only things you should need to use
+ * and even then, only when using non-blocking IO.
+ * It can also be useful to work out where you were when the connection
+ * failed */
+
+#define SSL_ST_CONNECT 0x1000
+#define SSL_ST_ACCEPT 0x2000
+#define SSL_ST_MASK 0x0FFF
+#define SSL_ST_INIT (SSL_ST_CONNECT|SSL_ST_ACCEPT)
+#define SSL_ST_BEFORE 0x4000
+#define SSL_ST_OK 0x03
+#define SSL_ST_RENEGOTIATE (0x04|SSL_ST_INIT)
+
+#define SSL_CB_LOOP 0x01
+#define SSL_CB_EXIT 0x02
+#define SSL_CB_READ 0x04
+#define SSL_CB_WRITE 0x08
+#define SSL_CB_ALERT 0x4000 /* used in callback */
+#define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)
+#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)
+#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)
+#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)
+#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)
+#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)
+#define SSL_CB_HANDSHAKE_START 0x10
+#define SSL_CB_HANDSHAKE_DONE 0x20
+
+/* Is the SSL_connection established? */
+#define SSL_get_state(a) SSL_state(a)
+#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK)
+#define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT)
+#define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE)
+#define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT)
+#define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT)
+
+/* The following 2 states are kept in ssl->rstate when reads fail,
+ * you should not need these */
+#define SSL_ST_READ_HEADER 0xF0
+#define SSL_ST_READ_BODY 0xF1
+#define SSL_ST_READ_DONE 0xF2
+
+/* Obtain latest Finished message
+ * -- that we sent (SSL_get_finished)
+ * -- that we expected from peer (SSL_get_peer_finished).
+ * Returns length (0 == no Finished so far), copies up to 'count' bytes. */
+size_t SSL_get_finished(const SSL *s, void *buf, size_t count);
+size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);
+
+/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options
+ * are 'ored' with SSL_VERIFY_PEER if they are desired */
+#define SSL_VERIFY_NONE 0x00
+#define SSL_VERIFY_PEER 0x01
+#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
+#define SSL_VERIFY_CLIENT_ONCE 0x04
+
+#define OpenSSL_add_ssl_algorithms() SSL_library_init()
+#define SSLeay_add_ssl_algorithms() SSL_library_init()
+
+/* this is for backward compatibility */
+#if 0 /* NEW_SSLEAY */
+#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c)
+#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n)
+#define SSL_add_session(a,b) SSL_CTX_add_session((a),(b))
+#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b))
+#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b))
+#endif
+/* More backward compatibility */
+#define SSL_get_cipher(s) \
+ SSL_CIPHER_get_name(SSL_get_current_cipher(s))
+#define SSL_get_cipher_bits(s,np) \
+ SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)
+#define SSL_get_cipher_version(s) \
+ SSL_CIPHER_get_version(SSL_get_current_cipher(s))
+#define SSL_get_cipher_name(s) \
+ SSL_CIPHER_get_name(SSL_get_current_cipher(s))
+#define SSL_get_time(a) SSL_SESSION_get_time(a)
+#define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b))
+#define SSL_get_timeout(a) SSL_SESSION_get_timeout(a)
+#define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b))
+
+#if 1 /*SSLEAY_MACROS*/
+#define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)
+#define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)
+#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \
+ (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u)
+#define PEM_read_bio_SSL_SESSION(bp,x,cb,u) PEM_ASN1_read_bio_of(SSL_SESSION,d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,cb,u)
+#define PEM_write_SSL_SESSION(fp,x) \
+ PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
+ PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL)
+#define PEM_write_bio_SSL_SESSION(bp,x) \
+ PEM_ASN1_write_bio_of(SSL_SESSION,i2d_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,NULL,NULL,0,NULL,NULL)
+#endif
+
+#define SSL_AD_REASON_OFFSET 1000
+/* These alert types are for SSLv3 and TLSv1 */
+#define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY
+#define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */
+#define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC /* fatal */
+#define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED
+#define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW
+#define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE/* fatal */
+#define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE/* fatal */
+#define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE /* Not for TLS */
+#define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE
+#define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE
+#define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED
+#define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED
+#define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN
+#define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER /* fatal */
+#define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA /* fatal */
+#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */
+#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */
+#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR
+#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */
+#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */
+#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */
+#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */
+#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED
+#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION
+#define SSL_AD_UNSUPPORTED_EXTENSION TLS1_AD_UNSUPPORTED_EXTENSION
+#define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE
+#define SSL_AD_UNRECOGNIZED_NAME TLS1_AD_UNRECOGNIZED_NAME
+#define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE
+
+#define SSL_ERROR_NONE 0
+#define SSL_ERROR_SSL 1
+#define SSL_ERROR_WANT_READ 2
+#define SSL_ERROR_WANT_WRITE 3
+#define SSL_ERROR_WANT_X509_LOOKUP 4
+#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */
+#define SSL_ERROR_ZERO_RETURN 6
+#define SSL_ERROR_WANT_CONNECT 7
+#define SSL_ERROR_WANT_ACCEPT 8
+
+#define SSL_CTRL_NEED_TMP_RSA 1
+#define SSL_CTRL_SET_TMP_RSA 2
+#define SSL_CTRL_SET_TMP_DH 3
+#define SSL_CTRL_SET_TMP_ECDH 4
+#define SSL_CTRL_SET_TMP_RSA_CB 5
+#define SSL_CTRL_SET_TMP_DH_CB 6
+#define SSL_CTRL_SET_TMP_ECDH_CB 7
+
+#define SSL_CTRL_GET_SESSION_REUSED 8
+#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9
+#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10
+#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11
+#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12
+#define SSL_CTRL_GET_FLAGS 13
+#define SSL_CTRL_EXTRA_CHAIN_CERT 14
+
+#define SSL_CTRL_SET_MSG_CALLBACK 15
+#define SSL_CTRL_SET_MSG_CALLBACK_ARG 16
+
+/* only applies to datagram connections */
+#define SSL_CTRL_SET_MTU 17
+/* Stats */
+#define SSL_CTRL_SESS_NUMBER 20
+#define SSL_CTRL_SESS_CONNECT 21
+#define SSL_CTRL_SESS_CONNECT_GOOD 22
+#define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23
+#define SSL_CTRL_SESS_ACCEPT 24
+#define SSL_CTRL_SESS_ACCEPT_GOOD 25
+#define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26
+#define SSL_CTRL_SESS_HIT 27
+#define SSL_CTRL_SESS_CB_HIT 28
+#define SSL_CTRL_SESS_MISSES 29
+#define SSL_CTRL_SESS_TIMEOUTS 30
+#define SSL_CTRL_SESS_CACHE_FULL 31
+#define SSL_CTRL_OPTIONS 32
+#define SSL_CTRL_MODE 33
+
+#define SSL_CTRL_GET_READ_AHEAD 40
+#define SSL_CTRL_SET_READ_AHEAD 41
+#define SSL_CTRL_SET_SESS_CACHE_SIZE 42
+#define SSL_CTRL_GET_SESS_CACHE_SIZE 43
+#define SSL_CTRL_SET_SESS_CACHE_MODE 44
+#define SSL_CTRL_GET_SESS_CACHE_MODE 45
+
+#define SSL_CTRL_GET_MAX_CERT_LIST 50
+#define SSL_CTRL_SET_MAX_CERT_LIST 51
+
+/* see tls1.h for macros based on these */
+#ifndef OPENSSL_NO_TLSEXT
+#define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB 53
+#define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG 54
+#define SSL_CTRL_SET_TLSEXT_HOSTNAME 55
+#define SSL_CTRL_SET_TLSEXT_DEBUG_CB 56
+#define SSL_CTRL_SET_TLSEXT_DEBUG_ARG 57
+#define SSL_CTRL_GET_TLSEXT_TICKET_KEYS 58
+#define SSL_CTRL_SET_TLSEXT_TICKET_KEYS 59
+
+#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB 63
+#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG 64
+#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE 65
+#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS 66
+#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS 67
+#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS 68
+#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS 69
+#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP 70
+#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP 71
+
+#define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB 72
+#endif
+
+#define SSL_session_reused(ssl) \
+ SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL)
+#define SSL_num_renegotiations(ssl) \
+ SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL)
+#define SSL_clear_num_renegotiations(ssl) \
+ SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL)
+#define SSL_total_renegotiations(ssl) \
+ SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL)
+
+#define SSL_CTX_need_tmp_RSA(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)
+#define SSL_CTX_set_tmp_rsa(ctx,rsa) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)
+#define SSL_CTX_set_tmp_dh(ctx,dh) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh)
+#define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)
+
+#define SSL_need_tmp_RSA(ssl) \
+ SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL)
+#define SSL_set_tmp_rsa(ssl,rsa) \
+ SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)
+#define SSL_set_tmp_dh(ssl,dh) \
+ SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh)
+#define SSL_set_tmp_ecdh(ssl,ecdh) \
+ SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)
+
+#define SSL_CTX_add_extra_chain_cert(ctx,x509) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)
+
+#ifndef OPENSSL_NO_BIO
+BIO_METHOD *BIO_f_ssl(void);
+BIO *BIO_new_ssl(SSL_CTX *ctx,int client);
+BIO *BIO_new_ssl_connect(SSL_CTX *ctx);
+BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);
+int BIO_ssl_copy_session_id(BIO *to,BIO *from);
+void BIO_ssl_shutdown(BIO *ssl_bio);
+
+#endif
+
+int SSL_CTX_set_cipher_list(SSL_CTX *,const char *str);
+SSL_CTX *SSL_CTX_new(SSL_METHOD *meth);
+void SSL_CTX_free(SSL_CTX *);
+long SSL_CTX_set_timeout(SSL_CTX *ctx,long t);
+long SSL_CTX_get_timeout(const SSL_CTX *ctx);
+X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);
+void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *);
+int SSL_want(const SSL *s);
+int SSL_clear(SSL *s);
+
+void SSL_CTX_flush_sessions(SSL_CTX *ctx,long tm);
+
+SSL_CIPHER *SSL_get_current_cipher(const SSL *s);
+int SSL_CIPHER_get_bits(const SSL_CIPHER *c,int *alg_bits);
+char * SSL_CIPHER_get_version(const SSL_CIPHER *c);
+const char * SSL_CIPHER_get_name(const SSL_CIPHER *c);
+
+int SSL_get_fd(const SSL *s);
+int SSL_get_rfd(const SSL *s);
+int SSL_get_wfd(const SSL *s);
+const char * SSL_get_cipher_list(const SSL *s,int n);
+char * SSL_get_shared_ciphers(const SSL *s, char *buf, int len);
+int SSL_get_read_ahead(const SSL * s);
+int SSL_pending(const SSL *s);
+#ifndef OPENSSL_NO_SOCK
+int SSL_set_fd(SSL *s, int fd);
+int SSL_set_rfd(SSL *s, int fd);
+int SSL_set_wfd(SSL *s, int fd);
+#endif
+#ifndef OPENSSL_NO_BIO
+void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio);
+BIO * SSL_get_rbio(const SSL *s);
+BIO * SSL_get_wbio(const SSL *s);
+#endif
+int SSL_set_cipher_list(SSL *s, const char *str);
+void SSL_set_read_ahead(SSL *s, int yes);
+int SSL_get_verify_mode(const SSL *s);
+int SSL_get_verify_depth(const SSL *s);
+int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *);
+void SSL_set_verify(SSL *s, int mode,
+ int (*callback)(int ok,X509_STORE_CTX *ctx));
+void SSL_set_verify_depth(SSL *s, int depth);
+#ifndef OPENSSL_NO_RSA
+int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);
+#endif
+int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);
+int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);
+int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, const unsigned char *d, long len);
+int SSL_use_certificate(SSL *ssl, X509 *x);
+int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);
+
+#ifndef OPENSSL_NO_STDIO
+int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);
+int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);
+int SSL_use_certificate_file(SSL *ssl, const char *file, int type);
+int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type);
+int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);
+int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);
+int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM type */
+STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
+int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
+ const char *file);
+#ifndef OPENSSL_SYS_VMS
+#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */
+int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
+ const char *dir);
+#endif
+#endif
+
+#endif
+
+void SSL_load_error_strings(void );
+const char *SSL_state_string(const SSL *s);
+const char *SSL_rstate_string(const SSL *s);
+const char *SSL_state_string_long(const SSL *s);
+const char *SSL_rstate_string_long(const SSL *s);
+long SSL_SESSION_get_time(const SSL_SESSION *s);
+long SSL_SESSION_set_time(SSL_SESSION *s, long t);
+long SSL_SESSION_get_timeout(const SSL_SESSION *s);
+long SSL_SESSION_set_timeout(SSL_SESSION *s, long t);
+void SSL_copy_session_id(SSL *to,const SSL *from);
+
+SSL_SESSION *SSL_SESSION_new(void);
+unsigned long SSL_SESSION_hash(const SSL_SESSION *a);
+int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b);
+const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len);
+#ifndef OPENSSL_NO_FP_API
+int SSL_SESSION_print_fp(FILE *fp,const SSL_SESSION *ses);
+#endif
+#ifndef OPENSSL_NO_BIO
+int SSL_SESSION_print(BIO *fp,const SSL_SESSION *ses);
+#endif
+void SSL_SESSION_free(SSL_SESSION *ses);
+int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp);
+int SSL_set_session(SSL *to, SSL_SESSION *session);
+int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c);
+int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c);
+int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB);
+int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB);
+int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
+ unsigned int id_len);
+SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,const unsigned char **pp,
+ long length);
+
+#ifdef HEADER_X509_H
+X509 * SSL_get_peer_certificate(const SSL *s);
+#endif
+
+STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s);
+
+int SSL_CTX_get_verify_mode(const SSL_CTX *ctx);
+int SSL_CTX_get_verify_depth(const SSL_CTX *ctx);
+int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int,X509_STORE_CTX *);
+void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,
+ int (*callback)(int, X509_STORE_CTX *));
+void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth);
+void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg);
+#ifndef OPENSSL_NO_RSA
+int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);
+#endif
+int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len);
+int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);
+int SSL_CTX_use_PrivateKey_ASN1(int pk,SSL_CTX *ctx,
+ const unsigned char *d, long len);
+int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);
+int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d);
+
+void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);
+void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);
+
+int SSL_CTX_check_private_key(const SSL_CTX *ctx);
+int SSL_check_private_key(const SSL *ctx);
+
+int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx,
+ unsigned int sid_ctx_len);
+
+SSL * SSL_new(SSL_CTX *ctx);
+int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx,
+ unsigned int sid_ctx_len);
+
+int SSL_CTX_set_purpose(SSL_CTX *s, int purpose);
+int SSL_set_purpose(SSL *s, int purpose);
+int SSL_CTX_set_trust(SSL_CTX *s, int trust);
+int SSL_set_trust(SSL *s, int trust);
+
+void SSL_free(SSL *ssl);
+int SSL_accept(SSL *ssl);
+int SSL_connect(SSL *ssl);
+int SSL_read(SSL *ssl,void *buf,int num);
+int SSL_peek(SSL *ssl,void *buf,int num);
+int SSL_write(SSL *ssl,const void *buf,int num);
+long SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg);
+long SSL_callback_ctrl(SSL *, int, void (*)(void));
+long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg);
+long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void));
+
+int SSL_get_error(const SSL *s,int ret_code);
+const char *SSL_get_version(const SSL *s);
+
+/* This sets the 'default' SSL version that SSL_new() will create */
+int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth);
+
+SSL_METHOD *SSLv2_method(void); /* SSLv2 */
+SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */
+SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */
+
+SSL_METHOD *SSLv3_method(void); /* SSLv3 */
+SSL_METHOD *SSLv3_server_method(void); /* SSLv3 */
+SSL_METHOD *SSLv3_client_method(void); /* SSLv3 */
+
+SSL_METHOD *SSLv23_method(void); /* SSLv3 but can rollback to v2 */
+SSL_METHOD *SSLv23_server_method(void); /* SSLv3 but can rollback to v2 */
+SSL_METHOD *SSLv23_client_method(void); /* SSLv3 but can rollback to v2 */
+
+SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */
+SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */
+SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */
+
+SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */
+SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */
+SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */
+
+STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);
+
+int SSL_do_handshake(SSL *s);
+int SSL_renegotiate(SSL *s);
+int SSL_renegotiate_pending(SSL *s);
+int SSL_shutdown(SSL *s);
+
+SSL_METHOD *SSL_get_ssl_method(SSL *s);
+int SSL_set_ssl_method(SSL *s,SSL_METHOD *method);
+const char *SSL_alert_type_string_long(int value);
+const char *SSL_alert_type_string(int value);
+const char *SSL_alert_desc_string_long(int value);
+const char *SSL_alert_desc_string(int value);
+
+void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);
+void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);
+STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);
+STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s);
+int SSL_add_client_CA(SSL *ssl,X509 *x);
+int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x);
+
+void SSL_set_connect_state(SSL *s);
+void SSL_set_accept_state(SSL *s);
+
+long SSL_get_default_timeout(const SSL *s);
+
+int SSL_library_init(void );
+
+char *SSL_CIPHER_description(SSL_CIPHER *,char *buf,int size);
+STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk);
+
+SSL *SSL_dup(SSL *ssl);
+
+X509 *SSL_get_certificate(const SSL *ssl);
+/* EVP_PKEY */ struct evp_pkey_st *SSL_get_privatekey(SSL *ssl);
+
+void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode);
+int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);
+void SSL_set_quiet_shutdown(SSL *ssl,int mode);
+int SSL_get_quiet_shutdown(const SSL *ssl);
+void SSL_set_shutdown(SSL *ssl,int mode);
+int SSL_get_shutdown(const SSL *ssl);
+int SSL_version(const SSL *ssl);
+int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
+int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
+ const char *CApath);
+#define SSL_get0_session SSL_get_session /* just peek at pointer */
+SSL_SESSION *SSL_get_session(const SSL *ssl);
+SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */
+SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);
+SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx);
+void SSL_set_info_callback(SSL *ssl,
+ void (*cb)(const SSL *ssl,int type,int val));
+void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl,int type,int val);
+int SSL_state(const SSL *ssl);
+
+void SSL_set_verify_result(SSL *ssl,long v);
+long SSL_get_verify_result(const SSL *ssl);
+
+int SSL_set_ex_data(SSL *ssl,int idx,void *data);
+void *SSL_get_ex_data(const SSL *ssl,int idx);
+int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+
+int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data);
+void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss,int idx);
+int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+
+int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data);
+void *SSL_CTX_get_ex_data(const SSL_CTX *ssl,int idx);
+int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+
+int SSL_get_ex_data_X509_STORE_CTX_idx(void );
+
+#define SSL_CTX_sess_set_cache_size(ctx,t) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL)
+#define SSL_CTX_sess_get_cache_size(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL)
+#define SSL_CTX_set_session_cache_mode(ctx,m) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL)
+#define SSL_CTX_get_session_cache_mode(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL)
+
+#define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx)
+#define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m)
+#define SSL_CTX_get_read_ahead(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)
+#define SSL_CTX_set_read_ahead(ctx,m) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)
+#define SSL_CTX_get_max_cert_list(ctx) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
+#define SSL_CTX_set_max_cert_list(ctx,m) \
+ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)
+#define SSL_get_max_cert_list(ssl) \
+ SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
+#define SSL_set_max_cert_list(ssl,m) \
+ SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)
+
+ /* NB: the keylength is only applicable when is_export is true */
+#ifndef OPENSSL_NO_RSA
+void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
+ RSA *(*cb)(SSL *ssl,int is_export,
+ int keylength));
+
+void SSL_set_tmp_rsa_callback(SSL *ssl,
+ RSA *(*cb)(SSL *ssl,int is_export,
+ int keylength));
+#endif
+#ifndef OPENSSL_NO_DH
+void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
+ DH *(*dh)(SSL *ssl,int is_export,
+ int keylength));
+void SSL_set_tmp_dh_callback(SSL *ssl,
+ DH *(*dh)(SSL *ssl,int is_export,
+ int keylength));
+#endif
+#ifndef OPENSSL_NO_ECDH
+void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx,
+ EC_KEY *(*ecdh)(SSL *ssl,int is_export,
+ int keylength));
+void SSL_set_tmp_ecdh_callback(SSL *ssl,
+ EC_KEY *(*ecdh)(SSL *ssl,int is_export,
+ int keylength));
+#endif
+
+#ifndef OPENSSL_NO_COMP
+const COMP_METHOD *SSL_get_current_compression(SSL *s);
+const COMP_METHOD *SSL_get_current_expansion(SSL *s);
+const char *SSL_COMP_get_name(const COMP_METHOD *comp);
+STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);
+int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm);
+#else
+const void *SSL_get_current_compression(SSL *s);
+const void *SSL_get_current_expansion(SSL *s);
+const char *SSL_COMP_get_name(const void *comp);
+void *SSL_COMP_get_compression_methods(void);
+int SSL_COMP_add_compression_method(int id,void *cm);
+#endif
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_SSL_strings(void);
+
+/* Error codes for the SSL functions. */
+
+/* Function codes. */
+#define SSL_F_CLIENT_CERTIFICATE 100
+#define SSL_F_CLIENT_FINISHED 167
+#define SSL_F_CLIENT_HELLO 101
+#define SSL_F_CLIENT_MASTER_KEY 102
+#define SSL_F_D2I_SSL_SESSION 103
+#define SSL_F_DO_DTLS1_WRITE 245
+#define SSL_F_DO_SSL3_WRITE 104
+#define SSL_F_DTLS1_ACCEPT 246
+#define SSL_F_DTLS1_BUFFER_RECORD 247
+#define SSL_F_DTLS1_CLIENT_HELLO 248
+#define SSL_F_DTLS1_CONNECT 249
+#define SSL_F_DTLS1_ENC 250
+#define SSL_F_DTLS1_GET_HELLO_VERIFY 251
+#define SSL_F_DTLS1_GET_MESSAGE 252
+#define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT 253
+#define SSL_F_DTLS1_GET_RECORD 254
+#define SSL_F_DTLS1_OUTPUT_CERT_CHAIN 255
+#define SSL_F_DTLS1_PREPROCESS_FRAGMENT 277
+#define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE 256
+#define SSL_F_DTLS1_PROCESS_RECORD 257
+#define SSL_F_DTLS1_READ_BYTES 258
+#define SSL_F_DTLS1_READ_FAILED 259
+#define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST 260
+#define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE 261
+#define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE 262
+#define SSL_F_DTLS1_SEND_CLIENT_VERIFY 263
+#define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST 264
+#define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE 265
+#define SSL_F_DTLS1_SEND_SERVER_HELLO 266
+#define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE 267
+#define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 268
+#define SSL_F_GET_CLIENT_FINISHED 105
+#define SSL_F_GET_CLIENT_HELLO 106
+#define SSL_F_GET_CLIENT_MASTER_KEY 107
+#define SSL_F_GET_SERVER_FINISHED 108
+#define SSL_F_GET_SERVER_HELLO 109
+#define SSL_F_GET_SERVER_VERIFY 110
+#define SSL_F_I2D_SSL_SESSION 111
+#define SSL_F_READ_N 112
+#define SSL_F_REQUEST_CERTIFICATE 113
+#define SSL_F_SERVER_FINISH 239
+#define SSL_F_SERVER_HELLO 114
+#define SSL_F_SERVER_VERIFY 240
+#define SSL_F_SSL23_ACCEPT 115
+#define SSL_F_SSL23_CLIENT_HELLO 116
+#define SSL_F_SSL23_CONNECT 117
+#define SSL_F_SSL23_GET_CLIENT_HELLO 118
+#define SSL_F_SSL23_GET_SERVER_HELLO 119
+#define SSL_F_SSL23_PEEK 237
+#define SSL_F_SSL23_READ 120
+#define SSL_F_SSL23_WRITE 121
+#define SSL_F_SSL2_ACCEPT 122
+#define SSL_F_SSL2_CONNECT 123
+#define SSL_F_SSL2_ENC_INIT 124
+#define SSL_F_SSL2_GENERATE_KEY_MATERIAL 241
+#define SSL_F_SSL2_PEEK 234
+#define SSL_F_SSL2_READ 125
+#define SSL_F_SSL2_READ_INTERNAL 236
+#define SSL_F_SSL2_SET_CERTIFICATE 126
+#define SSL_F_SSL2_WRITE 127
+#define SSL_F_SSL3_ACCEPT 128
+#define SSL_F_SSL3_CALLBACK_CTRL 233
+#define SSL_F_SSL3_CHANGE_CIPHER_STATE 129
+#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130
+#define SSL_F_SSL3_CLIENT_HELLO 131
+#define SSL_F_SSL3_CONNECT 132
+#define SSL_F_SSL3_CTRL 213
+#define SSL_F_SSL3_CTX_CTRL 133
+#define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC 279
+#define SSL_F_SSL3_ENC 134
+#define SSL_F_SSL3_GENERATE_KEY_BLOCK 238
+#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135
+#define SSL_F_SSL3_GET_CERT_STATUS 288
+#define SSL_F_SSL3_GET_CERT_VERIFY 136
+#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137
+#define SSL_F_SSL3_GET_CLIENT_HELLO 138
+#define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE 139
+#define SSL_F_SSL3_GET_FINISHED 140
+#define SSL_F_SSL3_GET_KEY_EXCHANGE 141
+#define SSL_F_SSL3_GET_MESSAGE 142
+#define SSL_F_SSL3_GET_NEW_SESSION_TICKET 283
+#define SSL_F_SSL3_GET_RECORD 143
+#define SSL_F_SSL3_GET_SERVER_CERTIFICATE 144
+#define SSL_F_SSL3_GET_SERVER_DONE 145
+#define SSL_F_SSL3_GET_SERVER_HELLO 146
+#define SSL_F_SSL3_NEW_SESSION_TICKET 284
+#define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147
+#define SSL_F_SSL3_PEEK 235
+#define SSL_F_SSL3_READ_BYTES 148
+#define SSL_F_SSL3_READ_N 149
+#define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150
+#define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE 151
+#define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE 152
+#define SSL_F_SSL3_SEND_CLIENT_VERIFY 153
+#define SSL_F_SSL3_SEND_SERVER_CERTIFICATE 154
+#define SSL_F_SSL3_SEND_SERVER_HELLO 242
+#define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE 155
+#define SSL_F_SSL3_SETUP_BUFFERS 156
+#define SSL_F_SSL3_SETUP_KEY_BLOCK 157
+#define SSL_F_SSL3_WRITE_BYTES 158
+#define SSL_F_SSL3_WRITE_PENDING 159
+#define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT 272
+#define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 215
+#define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 216
+#define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT 273
+#define SSL_F_SSL_BAD_METHOD 160
+#define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161
+#define SSL_F_SSL_CERT_DUP 221
+#define SSL_F_SSL_CERT_INST 222
+#define SSL_F_SSL_CERT_INSTANTIATE 214
+#define SSL_F_SSL_CERT_NEW 162
+#define SSL_F_SSL_CHECK_PRIVATE_KEY 163
+#define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT 274
+#define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230
+#define SSL_F_SSL_CIPHER_STRENGTH_SORT 231
+#define SSL_F_SSL_CLEAR 164
+#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165
+#define SSL_F_SSL_CREATE_CIPHER_LIST 166
+#define SSL_F_SSL_CTRL 232
+#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168
+#define SSL_F_SSL_CTX_NEW 169
+#define SSL_F_SSL_CTX_SET_CIPHER_LIST 269
+#define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE 278
+#define SSL_F_SSL_CTX_SET_PURPOSE 226
+#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219
+#define SSL_F_SSL_CTX_SET_SSL_VERSION 170
+#define SSL_F_SSL_CTX_SET_TRUST 229
+#define SSL_F_SSL_CTX_USE_CERTIFICATE 171
+#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172
+#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220
+#define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 173
+#define SSL_F_SSL_CTX_USE_PRIVATEKEY 174
+#define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 175
+#define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 176
+#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 177
+#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 178
+#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 179
+#define SSL_F_SSL_DO_HANDSHAKE 180
+#define SSL_F_SSL_GET_NEW_SESSION 181
+#define SSL_F_SSL_GET_PREV_SESSION 217
+#define SSL_F_SSL_GET_SERVER_SEND_CERT 182
+#define SSL_F_SSL_GET_SIGN_PKEY 183
+#define SSL_F_SSL_INIT_WBIO_BUFFER 184
+#define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185
+#define SSL_F_SSL_NEW 186
+#define SSL_F_SSL_PEEK 270
+#define SSL_F_SSL_PREPARE_CLIENTHELLO_TLSEXT 275
+#define SSL_F_SSL_PREPARE_SERVERHELLO_TLSEXT 276
+#define SSL_F_SSL_READ 223
+#define SSL_F_SSL_RSA_PRIVATE_DECRYPT 187
+#define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 188
+#define SSL_F_SSL_SESSION_NEW 189
+#define SSL_F_SSL_SESSION_PRINT_FP 190
+#define SSL_F_SSL_SESS_CERT_NEW 225
+#define SSL_F_SSL_SET_CERT 191
+#define SSL_F_SSL_SET_CIPHER_LIST 271
+#define SSL_F_SSL_SET_FD 192
+#define SSL_F_SSL_SET_PKEY 193
+#define SSL_F_SSL_SET_PURPOSE 227
+#define SSL_F_SSL_SET_RFD 194
+#define SSL_F_SSL_SET_SESSION 195
+#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218
+#define SSL_F_SSL_SET_TRUST 228
+#define SSL_F_SSL_SET_WFD 196
+#define SSL_F_SSL_SHUTDOWN 224
+#define SSL_F_SSL_UNDEFINED_CONST_FUNCTION 243
+#define SSL_F_SSL_UNDEFINED_FUNCTION 197
+#define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 244
+#define SSL_F_SSL_USE_CERTIFICATE 198
+#define SSL_F_SSL_USE_CERTIFICATE_ASN1 199
+#define SSL_F_SSL_USE_CERTIFICATE_FILE 200
+#define SSL_F_SSL_USE_PRIVATEKEY 201
+#define SSL_F_SSL_USE_PRIVATEKEY_ASN1 202
+#define SSL_F_SSL_USE_PRIVATEKEY_FILE 203
+#define SSL_F_SSL_USE_RSAPRIVATEKEY 204
+#define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 205
+#define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206
+#define SSL_F_SSL_VERIFY_CERT_CHAIN 207
+#define SSL_F_SSL_WRITE 208
+#define SSL_F_TLS1_CHANGE_CIPHER_STATE 209
+#define SSL_F_TLS1_ENC 210
+#define SSL_F_TLS1_SETUP_KEY_BLOCK 211
+#define SSL_F_WRITE_PENDING 212
+
+/* Reason codes. */
+#define SSL_R_APP_DATA_IN_HANDSHAKE 100
+#define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272
+#define SSL_R_BAD_ALERT_RECORD 101
+#define SSL_R_BAD_AUTHENTICATION_TYPE 102
+#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103
+#define SSL_R_BAD_CHECKSUM 104
+#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106
+#define SSL_R_BAD_DECOMPRESSION 107
+#define SSL_R_BAD_DH_G_LENGTH 108
+#define SSL_R_BAD_DH_PUB_KEY_LENGTH 109
+#define SSL_R_BAD_DH_P_LENGTH 110
+#define SSL_R_BAD_DIGEST_LENGTH 111
+#define SSL_R_BAD_DSA_SIGNATURE 112
+#define SSL_R_BAD_ECC_CERT 304
+#define SSL_R_BAD_ECDSA_SIGNATURE 305
+#define SSL_R_BAD_ECPOINT 306
+#define SSL_R_BAD_HELLO_REQUEST 105
+#define SSL_R_BAD_LENGTH 271
+#define SSL_R_BAD_MAC_DECODE 113
+#define SSL_R_BAD_MESSAGE_TYPE 114
+#define SSL_R_BAD_PACKET_LENGTH 115
+#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116
+#define SSL_R_BAD_RESPONSE_ARGUMENT 117
+#define SSL_R_BAD_RSA_DECRYPT 118
+#define SSL_R_BAD_RSA_ENCRYPT 119
+#define SSL_R_BAD_RSA_E_LENGTH 120
+#define SSL_R_BAD_RSA_MODULUS_LENGTH 121
+#define SSL_R_BAD_RSA_SIGNATURE 122
+#define SSL_R_BAD_SIGNATURE 123
+#define SSL_R_BAD_SSL_FILETYPE 124
+#define SSL_R_BAD_SSL_SESSION_ID_LENGTH 125
+#define SSL_R_BAD_STATE 126
+#define SSL_R_BAD_WRITE_RETRY 127
+#define SSL_R_BIO_NOT_SET 128
+#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129
+#define SSL_R_BN_LIB 130
+#define SSL_R_CA_DN_LENGTH_MISMATCH 131
+#define SSL_R_CA_DN_TOO_LONG 132
+#define SSL_R_CCS_RECEIVED_EARLY 133
+#define SSL_R_CERTIFICATE_VERIFY_FAILED 134
+#define SSL_R_CERT_LENGTH_MISMATCH 135
+#define SSL_R_CHALLENGE_IS_DIFFERENT 136
+#define SSL_R_CIPHER_CODE_WRONG_LENGTH 137
+#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138
+#define SSL_R_CIPHER_TABLE_SRC_ERROR 139
+#define SSL_R_CLIENTHELLO_TLSEXT 157
+#define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140
+#define SSL_R_COMPRESSION_FAILURE 141
+#define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE 307
+#define SSL_R_COMPRESSION_LIBRARY_ERROR 142
+#define SSL_R_CONNECTION_ID_IS_DIFFERENT 143
+#define SSL_R_CONNECTION_TYPE_NOT_SET 144
+#define SSL_R_COOKIE_MISMATCH 308
+#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145
+#define SSL_R_DATA_LENGTH_TOO_LONG 146
+#define SSL_R_DECRYPTION_FAILED 147
+#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281
+#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148
+#define SSL_R_DIGEST_CHECK_FAILED 149
+#define SSL_R_DUPLICATE_COMPRESSION_ID 309
+#define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER 310
+#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150
+#define SSL_R_ERROR_GENERATING_TMP_RSA_KEY 282
+#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151
+#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152
+#define SSL_R_EXTRA_DATA_IN_MESSAGE 153
+#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154
+#define SSL_R_HTTPS_PROXY_REQUEST 155
+#define SSL_R_HTTP_REQUEST 156
+#define SSL_R_ILLEGAL_PADDING 283
+#define SSL_R_INVALID_CHALLENGE_LENGTH 158
+#define SSL_R_INVALID_COMMAND 280
+#define SSL_R_INVALID_PURPOSE 278
+#define SSL_R_INVALID_STATUS_RESPONSE 316
+#define SSL_R_INVALID_TICKET_KEYS_LENGTH 275
+#define SSL_R_INVALID_TRUST 279
+#define SSL_R_KEY_ARG_TOO_LONG 284
+#define SSL_R_KRB5 285
+#define SSL_R_KRB5_C_CC_PRINC 286
+#define SSL_R_KRB5_C_GET_CRED 287
+#define SSL_R_KRB5_C_INIT 288
+#define SSL_R_KRB5_C_MK_REQ 289
+#define SSL_R_KRB5_S_BAD_TICKET 290
+#define SSL_R_KRB5_S_INIT 291
+#define SSL_R_KRB5_S_RD_REQ 292
+#define SSL_R_KRB5_S_TKT_EXPIRED 293
+#define SSL_R_KRB5_S_TKT_NYV 294
+#define SSL_R_KRB5_S_TKT_SKEW 295
+#define SSL_R_LENGTH_MISMATCH 159
+#define SSL_R_LENGTH_TOO_SHORT 160
+#define SSL_R_LIBRARY_BUG 274
+#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161
+#define SSL_R_MESSAGE_TOO_LONG 296
+#define SSL_R_MISSING_DH_DSA_CERT 162
+#define SSL_R_MISSING_DH_KEY 163
+#define SSL_R_MISSING_DH_RSA_CERT 164
+#define SSL_R_MISSING_DSA_SIGNING_CERT 165
+#define SSL_R_MISSING_EXPORT_TMP_DH_KEY 166
+#define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 167
+#define SSL_R_MISSING_RSA_CERTIFICATE 168
+#define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169
+#define SSL_R_MISSING_RSA_SIGNING_CERT 170
+#define SSL_R_MISSING_TMP_DH_KEY 171
+#define SSL_R_MISSING_TMP_ECDH_KEY 311
+#define SSL_R_MISSING_TMP_RSA_KEY 172
+#define SSL_R_MISSING_TMP_RSA_PKEY 173
+#define SSL_R_MISSING_VERIFY_MESSAGE 174
+#define SSL_R_NON_SSLV2_INITIAL_PACKET 175
+#define SSL_R_NO_CERTIFICATES_RETURNED 176
+#define SSL_R_NO_CERTIFICATE_ASSIGNED 177
+#define SSL_R_NO_CERTIFICATE_RETURNED 178
+#define SSL_R_NO_CERTIFICATE_SET 179
+#define SSL_R_NO_CERTIFICATE_SPECIFIED 180
+#define SSL_R_NO_CIPHERS_AVAILABLE 181
+#define SSL_R_NO_CIPHERS_PASSED 182
+#define SSL_R_NO_CIPHERS_SPECIFIED 183
+#define SSL_R_NO_CIPHER_LIST 184
+#define SSL_R_NO_CIPHER_MATCH 185
+#define SSL_R_NO_CLIENT_CERT_METHOD 317
+#define SSL_R_NO_CLIENT_CERT_RECEIVED 186
+#define SSL_R_NO_COMPRESSION_SPECIFIED 187
+#define SSL_R_NO_METHOD_SPECIFIED 188
+#define SSL_R_NO_PRIVATEKEY 189
+#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190
+#define SSL_R_NO_PROTOCOLS_AVAILABLE 191
+#define SSL_R_NO_PUBLICKEY 192
+#define SSL_R_NO_SHARED_CIPHER 193
+#define SSL_R_NO_VERIFY_CALLBACK 194
+#define SSL_R_NULL_SSL_CTX 195
+#define SSL_R_NULL_SSL_METHOD_PASSED 196
+#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197
+#define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE 297
+#define SSL_R_PACKET_LENGTH_TOO_LONG 198
+#define SSL_R_PARSE_TLSEXT 223
+#define SSL_R_PATH_TOO_LONG 270
+#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199
+#define SSL_R_PEER_ERROR 200
+#define SSL_R_PEER_ERROR_CERTIFICATE 201
+#define SSL_R_PEER_ERROR_NO_CERTIFICATE 202
+#define SSL_R_PEER_ERROR_NO_CIPHER 203
+#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 204
+#define SSL_R_PRE_MAC_LENGTH_TOO_LONG 205
+#define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 206
+#define SSL_R_PROTOCOL_IS_SHUTDOWN 207
+#define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 208
+#define SSL_R_PUBLIC_KEY_IS_NOT_RSA 209
+#define SSL_R_PUBLIC_KEY_NOT_RSA 210
+#define SSL_R_READ_BIO_NOT_SET 211
+#define SSL_R_READ_TIMEOUT_EXPIRED 312
+#define SSL_R_READ_WRONG_PACKET_TYPE 212
+#define SSL_R_RECORD_LENGTH_MISMATCH 213
+#define SSL_R_RECORD_TOO_LARGE 214
+#define SSL_R_RECORD_TOO_SMALL 298
+#define SSL_R_REQUIRED_CIPHER_MISSING 215
+#define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 216
+#define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 217
+#define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 218
+#define SSL_R_SERVERHELLO_TLSEXT 224
+#define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277
+#define SSL_R_SHORT_READ 219
+#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220
+#define SSL_R_SSL23_DOING_SESSION_ID_REUSE 221
+#define SSL_R_SSL2_CONNECTION_ID_TOO_LONG 299
+#define SSL_R_SSL3_EXT_INVALID_SERVERNAME 225
+#define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE 226
+#define SSL_R_SSL3_SESSION_ID_TOO_LONG 300
+#define SSL_R_SSL3_SESSION_ID_TOO_SHORT 222
+#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042
+#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020
+#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045
+#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044
+#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046
+#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030
+#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040
+#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047
+#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041
+#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010
+#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043
+#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228
+#define SSL_R_SSL_HANDSHAKE_FAILURE 229
+#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230
+#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301
+#define SSL_R_SSL_SESSION_ID_CONFLICT 302
+#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273
+#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303
+#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231
+#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049
+#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050
+#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021
+#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051
+#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060
+#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
+#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
+#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
+#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070
+#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022
+#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048
+#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
+#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232
+#define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST 227
+#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233
+#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234
+#define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 235
+#define SSL_R_UNABLE_TO_DECODE_DH_CERTS 236
+#define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS 313
+#define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 237
+#define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 238
+#define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 314
+#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239
+#define SSL_R_UNABLE_TO_FIND_SSL_METHOD 240
+#define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 241
+#define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242
+#define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243
+#define SSL_R_UNEXPECTED_MESSAGE 244
+#define SSL_R_UNEXPECTED_RECORD 245
+#define SSL_R_UNINITIALIZED 276
+#define SSL_R_UNKNOWN_ALERT_TYPE 246
+#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247
+#define SSL_R_UNKNOWN_CIPHER_RETURNED 248
+#define SSL_R_UNKNOWN_CIPHER_TYPE 249
+#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250
+#define SSL_R_UNKNOWN_PKEY_TYPE 251
+#define SSL_R_UNKNOWN_PROTOCOL 252
+#define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 253
+#define SSL_R_UNKNOWN_SSL_VERSION 254
+#define SSL_R_UNKNOWN_STATE 255
+#define SSL_R_UNSUPPORTED_CIPHER 256
+#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257
+#define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 315
+#define SSL_R_UNSUPPORTED_PROTOCOL 258
+#define SSL_R_UNSUPPORTED_SSL_VERSION 259
+#define SSL_R_UNSUPPORTED_STATUS_TYPE 329
+#define SSL_R_WRITE_BIO_NOT_SET 260
+#define SSL_R_WRONG_CIPHER_RETURNED 261
+#define SSL_R_WRONG_MESSAGE_TYPE 262
+#define SSL_R_WRONG_NUMBER_OF_KEY_BITS 263
+#define SSL_R_WRONG_SIGNATURE_LENGTH 264
+#define SSL_R_WRONG_SIGNATURE_SIZE 265
+#define SSL_R_WRONG_SSL_VERSION 266
+#define SSL_R_WRONG_VERSION_NUMBER 267
+#define SSL_R_X509_LIB 268
+#define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl2.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl2.h
new file mode 100644
index 000000000..99a52ea0d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl2.h
@@ -0,0 +1,268 @@
+/* ssl/ssl2.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_SSL2_H
+#define HEADER_SSL2_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Protocol Version Codes */
+#define SSL2_VERSION 0x0002
+#define SSL2_VERSION_MAJOR 0x00
+#define SSL2_VERSION_MINOR 0x02
+/* #define SSL2_CLIENT_VERSION 0x0002 */
+/* #define SSL2_SERVER_VERSION 0x0002 */
+
+/* Protocol Message Codes */
+#define SSL2_MT_ERROR 0
+#define SSL2_MT_CLIENT_HELLO 1
+#define SSL2_MT_CLIENT_MASTER_KEY 2
+#define SSL2_MT_CLIENT_FINISHED 3
+#define SSL2_MT_SERVER_HELLO 4
+#define SSL2_MT_SERVER_VERIFY 5
+#define SSL2_MT_SERVER_FINISHED 6
+#define SSL2_MT_REQUEST_CERTIFICATE 7
+#define SSL2_MT_CLIENT_CERTIFICATE 8
+
+/* Error Message Codes */
+#define SSL2_PE_UNDEFINED_ERROR 0x0000
+#define SSL2_PE_NO_CIPHER 0x0001
+#define SSL2_PE_NO_CERTIFICATE 0x0002
+#define SSL2_PE_BAD_CERTIFICATE 0x0004
+#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006
+
+/* Cipher Kind Values */
+#define SSL2_CK_NULL_WITH_MD5 0x02000000 /* v3 */
+#define SSL2_CK_RC4_128_WITH_MD5 0x02010080
+#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5 0x02020080
+#define SSL2_CK_RC2_128_CBC_WITH_MD5 0x02030080
+#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5 0x02040080
+#define SSL2_CK_IDEA_128_CBC_WITH_MD5 0x02050080
+#define SSL2_CK_DES_64_CBC_WITH_MD5 0x02060040
+#define SSL2_CK_DES_64_CBC_WITH_SHA 0x02060140 /* v3 */
+#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5 0x020700c0
+#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA 0x020701c0 /* v3 */
+#define SSL2_CK_RC4_64_WITH_MD5 0x02080080 /* MS hack */
+
+#define SSL2_CK_DES_64_CFB64_WITH_MD5_1 0x02ff0800 /* SSLeay */
+#define SSL2_CK_NULL 0x02ff0810 /* SSLeay */
+
+#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1 "DES-CFB-M1"
+#define SSL2_TXT_NULL_WITH_MD5 "NULL-MD5"
+#define SSL2_TXT_RC4_128_WITH_MD5 "RC4-MD5"
+#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 "EXP-RC4-MD5"
+#define SSL2_TXT_RC2_128_CBC_WITH_MD5 "RC2-CBC-MD5"
+#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 "EXP-RC2-CBC-MD5"
+#define SSL2_TXT_IDEA_128_CBC_WITH_MD5 "IDEA-CBC-MD5"
+#define SSL2_TXT_DES_64_CBC_WITH_MD5 "DES-CBC-MD5"
+#define SSL2_TXT_DES_64_CBC_WITH_SHA "DES-CBC-SHA"
+#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 "DES-CBC3-MD5"
+#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA "DES-CBC3-SHA"
+#define SSL2_TXT_RC4_64_WITH_MD5 "RC4-64-MD5"
+
+#define SSL2_TXT_NULL "NULL"
+
+/* Flags for the SSL_CIPHER.algorithm2 field */
+#define SSL2_CF_5_BYTE_ENC 0x01
+#define SSL2_CF_8_BYTE_ENC 0x02
+
+/* Certificate Type Codes */
+#define SSL2_CT_X509_CERTIFICATE 0x01
+
+/* Authentication Type Code */
+#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION 0x01
+
+#define SSL2_MAX_SSL_SESSION_ID_LENGTH 32
+
+/* Upper/Lower Bounds */
+#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256
+#ifdef OPENSSL_SYS_MPE
+#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u
+#else
+#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */
+#endif
+#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER 16383 /* 2^14-1 */
+
+#define SSL2_CHALLENGE_LENGTH 16
+/*#define SSL2_CHALLENGE_LENGTH 32 */
+#define SSL2_MIN_CHALLENGE_LENGTH 16
+#define SSL2_MAX_CHALLENGE_LENGTH 32
+#define SSL2_CONNECTION_ID_LENGTH 16
+#define SSL2_MAX_CONNECTION_ID_LENGTH 16
+#define SSL2_SSL_SESSION_ID_LENGTH 16
+#define SSL2_MAX_CERT_CHALLENGE_LENGTH 32
+#define SSL2_MIN_CERT_CHALLENGE_LENGTH 16
+#define SSL2_MAX_KEY_MATERIAL_LENGTH 24
+
+#ifndef HEADER_SSL_LOCL_H
+#define CERT char
+#endif
+
+typedef struct ssl2_state_st
+ {
+ int three_byte_header;
+ int clear_text; /* clear text */
+ int escape; /* not used in SSLv2 */
+ int ssl2_rollback; /* used if SSLv23 rolled back to SSLv2 */
+
+ /* non-blocking io info, used to make sure the same
+ * args were passwd */
+ unsigned int wnum; /* number of bytes sent so far */
+ int wpend_tot;
+ const unsigned char *wpend_buf;
+
+ int wpend_off; /* offset to data to write */
+ int wpend_len; /* number of bytes passwd to write */
+ int wpend_ret; /* number of bytes to return to caller */
+
+ /* buffer raw data */
+ int rbuf_left;
+ int rbuf_offs;
+ unsigned char *rbuf;
+ unsigned char *wbuf;
+
+ unsigned char *write_ptr;/* used to point to the start due to
+ * 2/3 byte header. */
+
+ unsigned int padding;
+ unsigned int rlength; /* passed to ssl2_enc */
+ int ract_data_length; /* Set when things are encrypted. */
+ unsigned int wlength; /* passed to ssl2_enc */
+ int wact_data_length; /* Set when things are decrypted. */
+ unsigned char *ract_data;
+ unsigned char *wact_data;
+ unsigned char *mac_data;
+
+ unsigned char *read_key;
+ unsigned char *write_key;
+
+ /* Stuff specifically to do with this SSL session */
+ unsigned int challenge_length;
+ unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH];
+ unsigned int conn_id_length;
+ unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH];
+ unsigned int key_material_length;
+ unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2];
+
+ unsigned long read_sequence;
+ unsigned long write_sequence;
+
+ struct {
+ unsigned int conn_id_length;
+ unsigned int cert_type;
+ unsigned int cert_length;
+ unsigned int csl;
+ unsigned int clear;
+ unsigned int enc;
+ unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH];
+ unsigned int cipher_spec_length;
+ unsigned int session_id_length;
+ unsigned int clen;
+ unsigned int rlen;
+ } tmp;
+ } SSL2_STATE;
+
+/* SSLv2 */
+/* client */
+#define SSL2_ST_SEND_CLIENT_HELLO_A (0x10|SSL_ST_CONNECT)
+#define SSL2_ST_SEND_CLIENT_HELLO_B (0x11|SSL_ST_CONNECT)
+#define SSL2_ST_GET_SERVER_HELLO_A (0x20|SSL_ST_CONNECT)
+#define SSL2_ST_GET_SERVER_HELLO_B (0x21|SSL_ST_CONNECT)
+#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A (0x30|SSL_ST_CONNECT)
+#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B (0x31|SSL_ST_CONNECT)
+#define SSL2_ST_SEND_CLIENT_FINISHED_A (0x40|SSL_ST_CONNECT)
+#define SSL2_ST_SEND_CLIENT_FINISHED_B (0x41|SSL_ST_CONNECT)
+#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A (0x50|SSL_ST_CONNECT)
+#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B (0x51|SSL_ST_CONNECT)
+#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C (0x52|SSL_ST_CONNECT)
+#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D (0x53|SSL_ST_CONNECT)
+#define SSL2_ST_GET_SERVER_VERIFY_A (0x60|SSL_ST_CONNECT)
+#define SSL2_ST_GET_SERVER_VERIFY_B (0x61|SSL_ST_CONNECT)
+#define SSL2_ST_GET_SERVER_FINISHED_A (0x70|SSL_ST_CONNECT)
+#define SSL2_ST_GET_SERVER_FINISHED_B (0x71|SSL_ST_CONNECT)
+#define SSL2_ST_CLIENT_START_ENCRYPTION (0x80|SSL_ST_CONNECT)
+#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE (0x90|SSL_ST_CONNECT)
+/* server */
+#define SSL2_ST_GET_CLIENT_HELLO_A (0x10|SSL_ST_ACCEPT)
+#define SSL2_ST_GET_CLIENT_HELLO_B (0x11|SSL_ST_ACCEPT)
+#define SSL2_ST_GET_CLIENT_HELLO_C (0x12|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_SERVER_HELLO_A (0x20|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_SERVER_HELLO_B (0x21|SSL_ST_ACCEPT)
+#define SSL2_ST_GET_CLIENT_MASTER_KEY_A (0x30|SSL_ST_ACCEPT)
+#define SSL2_ST_GET_CLIENT_MASTER_KEY_B (0x31|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_SERVER_VERIFY_A (0x40|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_SERVER_VERIFY_B (0x41|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_SERVER_VERIFY_C (0x42|SSL_ST_ACCEPT)
+#define SSL2_ST_GET_CLIENT_FINISHED_A (0x50|SSL_ST_ACCEPT)
+#define SSL2_ST_GET_CLIENT_FINISHED_B (0x51|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_SERVER_FINISHED_A (0x60|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_SERVER_FINISHED_B (0x61|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A (0x70|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B (0x71|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C (0x72|SSL_ST_ACCEPT)
+#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D (0x73|SSL_ST_ACCEPT)
+#define SSL2_ST_SERVER_START_ENCRYPTION (0x80|SSL_ST_ACCEPT)
+#define SSL2_ST_X509_GET_SERVER_CERTIFICATE (0x90|SSL_ST_ACCEPT)
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl23.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl23.h
new file mode 100644
index 000000000..d3228983c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl23.h
@@ -0,0 +1,83 @@
+/* ssl/ssl23.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_SSL23_H
+#define HEADER_SSL23_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*client */
+/* write to server */
+#define SSL23_ST_CW_CLNT_HELLO_A (0x210|SSL_ST_CONNECT)
+#define SSL23_ST_CW_CLNT_HELLO_B (0x211|SSL_ST_CONNECT)
+/* read from server */
+#define SSL23_ST_CR_SRVR_HELLO_A (0x220|SSL_ST_CONNECT)
+#define SSL23_ST_CR_SRVR_HELLO_B (0x221|SSL_ST_CONNECT)
+
+/* server */
+/* read from client */
+#define SSL23_ST_SR_CLNT_HELLO_A (0x210|SSL_ST_ACCEPT)
+#define SSL23_ST_SR_CLNT_HELLO_B (0x211|SSL_ST_ACCEPT)
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl3.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl3.h
new file mode 100644
index 000000000..4b1e2e983
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ssl3.h
@@ -0,0 +1,565 @@
+/* ssl/ssl3.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ * ECC cipher suite support in OpenSSL originally developed by
+ * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
+ */
+
+#ifndef HEADER_SSL3_H
+#define HEADER_SSL3_H
+
+#ifndef OPENSSL_NO_COMP
+#include <openssl/comp.h>
+#endif
+#include <openssl/buffer.h>
+#include <openssl/evp.h>
+#include <openssl/ssl.h>
+#include <openssl/pq_compat.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SSL3_CK_RSA_NULL_MD5 0x03000001
+#define SSL3_CK_RSA_NULL_SHA 0x03000002
+#define SSL3_CK_RSA_RC4_40_MD5 0x03000003
+#define SSL3_CK_RSA_RC4_128_MD5 0x03000004
+#define SSL3_CK_RSA_RC4_128_SHA 0x03000005
+#define SSL3_CK_RSA_RC2_40_MD5 0x03000006
+#define SSL3_CK_RSA_IDEA_128_SHA 0x03000007
+#define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008
+#define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009
+#define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A
+
+#define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B
+#define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C
+#define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D
+#define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E
+#define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F
+#define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010
+
+#define SSL3_CK_EDH_DSS_DES_40_CBC_SHA 0x03000011
+#define SSL3_CK_EDH_DSS_DES_64_CBC_SHA 0x03000012
+#define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA 0x03000013
+#define SSL3_CK_EDH_RSA_DES_40_CBC_SHA 0x03000014
+#define SSL3_CK_EDH_RSA_DES_64_CBC_SHA 0x03000015
+#define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA 0x03000016
+
+#define SSL3_CK_ADH_RC4_40_MD5 0x03000017
+#define SSL3_CK_ADH_RC4_128_MD5 0x03000018
+#define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019
+#define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A
+#define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B
+
+#define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C
+#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D
+#if 0 /* Because it clashes with KRB5, is never used any more, and is safe
+ to remove according to David Hopwood <david.hopwood@zetnet.co.uk>
+ of the ietf-tls list */
+#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E
+#endif
+
+/* VRS Additional Kerberos5 entries
+ */
+#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x0300001E
+#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x0300001F
+#define SSL3_CK_KRB5_RC4_128_SHA 0x03000020
+#define SSL3_CK_KRB5_IDEA_128_CBC_SHA 0x03000021
+#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000022
+#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000023
+#define SSL3_CK_KRB5_RC4_128_MD5 0x03000024
+#define SSL3_CK_KRB5_IDEA_128_CBC_MD5 0x03000025
+
+#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000026
+#define SSL3_CK_KRB5_RC2_40_CBC_SHA 0x03000027
+#define SSL3_CK_KRB5_RC4_40_SHA 0x03000028
+#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000029
+#define SSL3_CK_KRB5_RC2_40_CBC_MD5 0x0300002A
+#define SSL3_CK_KRB5_RC4_40_MD5 0x0300002B
+
+#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5"
+#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA"
+#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5"
+#define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5"
+#define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA"
+#define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5"
+#define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA"
+#define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA"
+#define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA"
+#define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA"
+
+#define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA"
+#define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA"
+#define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA"
+#define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA"
+#define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA"
+#define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA"
+
+#define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA"
+#define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA"
+#define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA"
+#define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA"
+#define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA"
+#define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA"
+
+#define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5"
+#define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5"
+#define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA"
+#define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA"
+#define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA"
+
+#define SSL3_TXT_FZA_DMS_NULL_SHA "FZA-NULL-SHA"
+#define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA"
+#define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA"
+
+#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA"
+#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA"
+#define SSL3_TXT_KRB5_RC4_128_SHA "KRB5-RC4-SHA"
+#define SSL3_TXT_KRB5_IDEA_128_CBC_SHA "KRB5-IDEA-CBC-SHA"
+#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5"
+#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5"
+#define SSL3_TXT_KRB5_RC4_128_MD5 "KRB5-RC4-MD5"
+#define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 "KRB5-IDEA-CBC-MD5"
+
+#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA"
+#define SSL3_TXT_KRB5_RC2_40_CBC_SHA "EXP-KRB5-RC2-CBC-SHA"
+#define SSL3_TXT_KRB5_RC4_40_SHA "EXP-KRB5-RC4-SHA"
+#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5"
+#define SSL3_TXT_KRB5_RC2_40_CBC_MD5 "EXP-KRB5-RC2-CBC-MD5"
+#define SSL3_TXT_KRB5_RC4_40_MD5 "EXP-KRB5-RC4-MD5"
+
+#define SSL3_SSL_SESSION_ID_LENGTH 32
+#define SSL3_MAX_SSL_SESSION_ID_LENGTH 32
+
+#define SSL3_MASTER_SECRET_SIZE 48
+#define SSL3_RANDOM_SIZE 32
+#define SSL3_SESSION_ID_SIZE 32
+#define SSL3_RT_HEADER_LENGTH 5
+
+/* Due to MS stuffing up, this can change.... */
+#if defined(OPENSSL_SYS_WIN16) || \
+ (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32))
+#define SSL3_RT_MAX_EXTRA (14000)
+#else
+#define SSL3_RT_MAX_EXTRA (16384)
+#endif
+
+#define SSL3_RT_MAX_PLAIN_LENGTH 16384
+#ifdef OPENSSL_NO_COMP
+#define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH
+#else
+#define SSL3_RT_MAX_COMPRESSED_LENGTH (1024+SSL3_RT_MAX_PLAIN_LENGTH)
+#endif
+#define SSL3_RT_MAX_ENCRYPTED_LENGTH (1024+SSL3_RT_MAX_COMPRESSED_LENGTH)
+#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)
+#define SSL3_RT_MAX_DATA_SIZE (1024*1024)
+
+#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54"
+#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52"
+
+#define SSL3_VERSION 0x0300
+#define SSL3_VERSION_MAJOR 0x03
+#define SSL3_VERSION_MINOR 0x00
+
+#define SSL3_RT_CHANGE_CIPHER_SPEC 20
+#define SSL3_RT_ALERT 21
+#define SSL3_RT_HANDSHAKE 22
+#define SSL3_RT_APPLICATION_DATA 23
+
+#define SSL3_AL_WARNING 1
+#define SSL3_AL_FATAL 2
+
+#define SSL3_AD_CLOSE_NOTIFY 0
+#define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */
+#define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */
+#define SSL3_AD_DECOMPRESSION_FAILURE 30 /* fatal */
+#define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */
+#define SSL3_AD_NO_CERTIFICATE 41
+#define SSL3_AD_BAD_CERTIFICATE 42
+#define SSL3_AD_UNSUPPORTED_CERTIFICATE 43
+#define SSL3_AD_CERTIFICATE_REVOKED 44
+#define SSL3_AD_CERTIFICATE_EXPIRED 45
+#define SSL3_AD_CERTIFICATE_UNKNOWN 46
+#define SSL3_AD_ILLEGAL_PARAMETER 47 /* fatal */
+
+typedef struct ssl3_record_st
+ {
+/*r */ int type; /* type of record */
+/*rw*/ unsigned int length; /* How many bytes available */
+/*r */ unsigned int off; /* read/write offset into 'buf' */
+/*rw*/ unsigned char *data; /* pointer to the record data */
+/*rw*/ unsigned char *input; /* where the decode bytes are */
+/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */
+/*r */ unsigned long epoch; /* epoch number, needed by DTLS1 */
+/*r */ PQ_64BIT seq_num; /* sequence number, needed by DTLS1 */
+ } SSL3_RECORD;
+
+typedef struct ssl3_buffer_st
+ {
+ unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes,
+ * see ssl3_setup_buffers() */
+ size_t len; /* buffer size */
+ int offset; /* where to 'copy from' */
+ int left; /* how many bytes left */
+ } SSL3_BUFFER;
+
+#define SSL3_CT_RSA_SIGN 1
+#define SSL3_CT_DSS_SIGN 2
+#define SSL3_CT_RSA_FIXED_DH 3
+#define SSL3_CT_DSS_FIXED_DH 4
+#define SSL3_CT_RSA_EPHEMERAL_DH 5
+#define SSL3_CT_DSS_EPHEMERAL_DH 6
+#define SSL3_CT_FORTEZZA_DMS 20
+/* SSL3_CT_NUMBER is used to size arrays and it must be large
+ * enough to contain all of the cert types defined either for
+ * SSLv3 and TLSv1.
+ */
+#define SSL3_CT_NUMBER 7
+
+
+#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001
+#define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002
+#define SSL3_FLAGS_POP_BUFFER 0x0004
+#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008
+
+typedef struct ssl3_state_st
+ {
+ long flags;
+ int delay_buf_pop_ret;
+
+ unsigned char read_sequence[8];
+ unsigned char read_mac_secret[EVP_MAX_MD_SIZE];
+ unsigned char write_sequence[8];
+ unsigned char write_mac_secret[EVP_MAX_MD_SIZE];
+
+ unsigned char server_random[SSL3_RANDOM_SIZE];
+ unsigned char client_random[SSL3_RANDOM_SIZE];
+
+ /* flags for countermeasure against known-IV weakness */
+ int need_empty_fragments;
+ int empty_fragment_done;
+
+ SSL3_BUFFER rbuf; /* read IO goes into here */
+ SSL3_BUFFER wbuf; /* write IO goes into here */
+
+ SSL3_RECORD rrec; /* each decoded record goes in here */
+ SSL3_RECORD wrec; /* goes out from here */
+
+ /* storage for Alert/Handshake protocol data received but not
+ * yet processed by ssl3_read_bytes: */
+ unsigned char alert_fragment[2];
+ unsigned int alert_fragment_len;
+ unsigned char handshake_fragment[4];
+ unsigned int handshake_fragment_len;
+
+ /* partial write - check the numbers match */
+ unsigned int wnum; /* number of bytes sent so far */
+ int wpend_tot; /* number bytes written */
+ int wpend_type;
+ int wpend_ret; /* number of bytes submitted */
+ const unsigned char *wpend_buf;
+
+ /* used during startup, digest all incoming/outgoing packets */
+ EVP_MD_CTX finish_dgst1;
+ EVP_MD_CTX finish_dgst2;
+
+ /* this is set whenerver we see a change_cipher_spec message
+ * come in when we are not looking for one */
+ int change_cipher_spec;
+
+ int warn_alert;
+ int fatal_alert;
+ /* we allow one fatal and one warning alert to be outstanding,
+ * send close alert via the warning alert */
+ int alert_dispatch;
+ unsigned char send_alert[2];
+
+ /* This flag is set when we should renegotiate ASAP, basically when
+ * there is no more data in the read or write buffers */
+ int renegotiate;
+ int total_renegotiations;
+ int num_renegotiations;
+
+ int in_read_app_data;
+
+ struct {
+ /* actually only needs to be 16+20 */
+ unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2];
+
+ /* actually only need to be 16+20 for SSLv3 and 12 for TLS */
+ unsigned char finish_md[EVP_MAX_MD_SIZE*2];
+ int finish_md_len;
+ unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2];
+ int peer_finish_md_len;
+
+ unsigned long message_size;
+ int message_type;
+
+ /* used to hold the new cipher we are going to use */
+ SSL_CIPHER *new_cipher;
+#ifndef OPENSSL_NO_DH
+ DH *dh;
+#endif
+
+#ifndef OPENSSL_NO_ECDH
+ EC_KEY *ecdh; /* holds short lived ECDH key */
+#endif
+
+ /* used when SSL_ST_FLUSH_DATA is entered */
+ int next_state;
+
+ int reuse_message;
+
+ /* used for certificate requests */
+ int cert_req;
+ int ctype_num;
+ char ctype[SSL3_CT_NUMBER];
+ STACK_OF(X509_NAME) *ca_names;
+
+ int use_rsa_tmp;
+
+ int key_block_length;
+ unsigned char *key_block;
+
+ const EVP_CIPHER *new_sym_enc;
+ const EVP_MD *new_hash;
+#ifndef OPENSSL_NO_COMP
+ const SSL_COMP *new_compression;
+#else
+ char *new_compression;
+#endif
+ int cert_request;
+ } tmp;
+
+ } SSL3_STATE;
+
+
+/* SSLv3 */
+/*client */
+/* extra state */
+#define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT)
+/* write to server */
+#define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT)
+#define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT)
+/* read from server */
+#define SSL3_ST_CR_SRVR_HELLO_A (0x120|SSL_ST_CONNECT)
+#define SSL3_ST_CR_SRVR_HELLO_B (0x121|SSL_ST_CONNECT)
+#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT)
+#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT)
+#define SSL3_ST_CR_CERT_A (0x130|SSL_ST_CONNECT)
+#define SSL3_ST_CR_CERT_B (0x131|SSL_ST_CONNECT)
+#define SSL3_ST_CR_KEY_EXCH_A (0x140|SSL_ST_CONNECT)
+#define SSL3_ST_CR_KEY_EXCH_B (0x141|SSL_ST_CONNECT)
+#define SSL3_ST_CR_CERT_REQ_A (0x150|SSL_ST_CONNECT)
+#define SSL3_ST_CR_CERT_REQ_B (0x151|SSL_ST_CONNECT)
+#define SSL3_ST_CR_SRVR_DONE_A (0x160|SSL_ST_CONNECT)
+#define SSL3_ST_CR_SRVR_DONE_B (0x161|SSL_ST_CONNECT)
+/* write to server */
+#define SSL3_ST_CW_CERT_A (0x170|SSL_ST_CONNECT)
+#define SSL3_ST_CW_CERT_B (0x171|SSL_ST_CONNECT)
+#define SSL3_ST_CW_CERT_C (0x172|SSL_ST_CONNECT)
+#define SSL3_ST_CW_CERT_D (0x173|SSL_ST_CONNECT)
+#define SSL3_ST_CW_KEY_EXCH_A (0x180|SSL_ST_CONNECT)
+#define SSL3_ST_CW_KEY_EXCH_B (0x181|SSL_ST_CONNECT)
+#define SSL3_ST_CW_CERT_VRFY_A (0x190|SSL_ST_CONNECT)
+#define SSL3_ST_CW_CERT_VRFY_B (0x191|SSL_ST_CONNECT)
+#define SSL3_ST_CW_CHANGE_A (0x1A0|SSL_ST_CONNECT)
+#define SSL3_ST_CW_CHANGE_B (0x1A1|SSL_ST_CONNECT)
+#define SSL3_ST_CW_FINISHED_A (0x1B0|SSL_ST_CONNECT)
+#define SSL3_ST_CW_FINISHED_B (0x1B1|SSL_ST_CONNECT)
+/* read from server */
+#define SSL3_ST_CR_CHANGE_A (0x1C0|SSL_ST_CONNECT)
+#define SSL3_ST_CR_CHANGE_B (0x1C1|SSL_ST_CONNECT)
+#define SSL3_ST_CR_FINISHED_A (0x1D0|SSL_ST_CONNECT)
+#define SSL3_ST_CR_FINISHED_B (0x1D1|SSL_ST_CONNECT)
+#define SSL3_ST_CR_SESSION_TICKET_A (0x1E0|SSL_ST_CONNECT)
+#define SSL3_ST_CR_SESSION_TICKET_B (0x1E1|SSL_ST_CONNECT)
+#define SSL3_ST_CR_CERT_STATUS_A (0x1F0|SSL_ST_CONNECT)
+#define SSL3_ST_CR_CERT_STATUS_B (0x1F1|SSL_ST_CONNECT)
+
+/* server */
+/* extra state */
+#define SSL3_ST_SW_FLUSH (0x100|SSL_ST_ACCEPT)
+/* read from client */
+/* Do not change the number values, they do matter */
+#define SSL3_ST_SR_CLNT_HELLO_A (0x110|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_CLNT_HELLO_B (0x111|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_CLNT_HELLO_C (0x112|SSL_ST_ACCEPT)
+/* write to client */
+#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT)
+#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_HELLO_REQ_A (0x120|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_HELLO_REQ_B (0x121|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_HELLO_REQ_C (0x122|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_SRVR_HELLO_A (0x130|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_SRVR_HELLO_B (0x131|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_CERT_A (0x140|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_CERT_B (0x141|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_KEY_EXCH_A (0x150|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_KEY_EXCH_B (0x151|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_CERT_REQ_A (0x160|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_CERT_REQ_B (0x161|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_SRVR_DONE_A (0x170|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_SRVR_DONE_B (0x171|SSL_ST_ACCEPT)
+/* read from client */
+#define SSL3_ST_SR_CERT_A (0x180|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_CERT_B (0x181|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_KEY_EXCH_A (0x190|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_KEY_EXCH_B (0x191|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_CERT_VRFY_A (0x1A0|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_CERT_VRFY_B (0x1A1|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_CHANGE_A (0x1B0|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_CHANGE_B (0x1B1|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_FINISHED_A (0x1C0|SSL_ST_ACCEPT)
+#define SSL3_ST_SR_FINISHED_B (0x1C1|SSL_ST_ACCEPT)
+/* write to client */
+#define SSL3_ST_SW_CHANGE_A (0x1D0|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_CHANGE_B (0x1D1|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_SESSION_TICKET_A (0x1F0|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_SESSION_TICKET_B (0x1F1|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_CERT_STATUS_A (0x200|SSL_ST_ACCEPT)
+#define SSL3_ST_SW_CERT_STATUS_B (0x201|SSL_ST_ACCEPT)
+
+#define SSL3_MT_HELLO_REQUEST 0
+#define SSL3_MT_CLIENT_HELLO 1
+#define SSL3_MT_SERVER_HELLO 2
+#define SSL3_MT_NEWSESSION_TICKET 4
+#define SSL3_MT_CERTIFICATE 11
+#define SSL3_MT_SERVER_KEY_EXCHANGE 12
+#define SSL3_MT_CERTIFICATE_REQUEST 13
+#define SSL3_MT_SERVER_DONE 14
+#define SSL3_MT_CERTIFICATE_VERIFY 15
+#define SSL3_MT_CLIENT_KEY_EXCHANGE 16
+#define SSL3_MT_FINISHED 20
+#define SSL3_MT_CERTIFICATE_STATUS 22
+#define DTLS1_MT_HELLO_VERIFY_REQUEST 3
+
+
+#define SSL3_MT_CCS 1
+
+/* These are used when changing over to a new cipher */
+#define SSL3_CC_READ 0x01
+#define SSL3_CC_WRITE 0x02
+#define SSL3_CC_CLIENT 0x10
+#define SSL3_CC_SERVER 0x20
+#define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE)
+#define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ)
+#define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ)
+#define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE)
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/stack.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/stack.h
new file mode 100644
index 000000000..5cbb116a8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/stack.h
@@ -0,0 +1,109 @@
+/* crypto/stack/stack.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_STACK_H
+#define HEADER_STACK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct stack_st
+ {
+ int num;
+ char **data;
+ int sorted;
+
+ int num_alloc;
+ int (*comp)(const char * const *, const char * const *);
+ } STACK;
+
+#define M_sk_num(sk) ((sk) ? (sk)->num:-1)
+#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL)
+
+int sk_num(const STACK *);
+char *sk_value(const STACK *, int);
+
+char *sk_set(STACK *, int, char *);
+
+STACK *sk_new(int (*cmp)(const char * const *, const char * const *));
+STACK *sk_new_null(void);
+void sk_free(STACK *);
+void sk_pop_free(STACK *st, void (*func)(void *));
+int sk_insert(STACK *sk,char *data,int where);
+char *sk_delete(STACK *st,int loc);
+char *sk_delete_ptr(STACK *st, char *p);
+int sk_find(STACK *st,char *data);
+int sk_find_ex(STACK *st,char *data);
+int sk_push(STACK *st,char *data);
+int sk_unshift(STACK *st,char *data);
+char *sk_shift(STACK *st);
+char *sk_pop(STACK *st);
+void sk_zero(STACK *st);
+int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *,
+ const char * const *)))
+ (const char * const *, const char * const *);
+STACK *sk_dup(STACK *st);
+void sk_sort(STACK *st);
+int sk_is_sorted(const STACK *st);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/store.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/store.h
new file mode 100644
index 000000000..64583377a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/store.h
@@ -0,0 +1,554 @@
+/* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */
+/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
+ * project 2003.
+ */
+/* ====================================================================
+ * Copyright (c) 2003 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_STORE_H
+#define HEADER_STORE_H
+
+#include <openssl/ossl_typ.h>
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/evp.h>
+#include <openssl/bn.h>
+#include <openssl/x509.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Already defined in ossl_typ.h */
+/* typedef struct store_st STORE; */
+/* typedef struct store_method_st STORE_METHOD; */
+
+
+/* All the following functions return 0, a negative number or NULL on error.
+ When everything is fine, they return a positive value or a non-NULL
+ pointer, all depending on their purpose. */
+
+/* Creators and destructor. */
+STORE *STORE_new_method(const STORE_METHOD *method);
+STORE *STORE_new_engine(ENGINE *engine);
+void STORE_free(STORE *ui);
+
+
+/* Give a user interface parametrised control commands. This can be used to
+ send down an integer, a data pointer or a function pointer, as well as
+ be used to get information from a STORE. */
+int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void));
+
+/* A control to set the directory with keys and certificates. Used by the
+ built-in directory level method. */
+#define STORE_CTRL_SET_DIRECTORY 0x0001
+/* A control to set a file to load. Used by the built-in file level method. */
+#define STORE_CTRL_SET_FILE 0x0002
+/* A control to set a configuration file to load. Can be used by any method
+ that wishes to load a configuration file. */
+#define STORE_CTRL_SET_CONF_FILE 0x0003
+/* A control to set a the section of the loaded configuration file. Can be
+ used by any method that wishes to load a configuration file. */
+#define STORE_CTRL_SET_CONF_SECTION 0x0004
+
+
+/* Some methods may use extra data */
+#define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg)
+#define STORE_get_app_data(s) STORE_get_ex_data(s,0)
+int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int STORE_set_ex_data(STORE *r,int idx,void *arg);
+void *STORE_get_ex_data(STORE *r, int idx);
+
+/* Use specific methods instead of the built-in one */
+const STORE_METHOD *STORE_get_method(STORE *store);
+const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth);
+
+/* The standard OpenSSL methods. */
+/* This is the in-memory method. It does everything except revoking and updating,
+ and is of course volatile. It's used by other methods that have an in-memory
+ cache. */
+const STORE_METHOD *STORE_Memory(void);
+#if 0 /* Not yet implemented */
+/* This is the directory store. It does everything except revoking and updating,
+ and uses STORE_Memory() to cache things in memory. */
+const STORE_METHOD *STORE_Directory(void);
+/* This is the file store. It does everything except revoking and updating,
+ and uses STORE_Memory() to cache things in memory. Certificates are added
+ to it with the store operation, and it will only get cached certificates. */
+const STORE_METHOD *STORE_File(void);
+#endif
+
+/* Store functions take a type code for the type of data they should store
+ or fetch */
+typedef enum STORE_object_types
+ {
+ STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */
+ STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */
+ STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */
+ STORE_OBJECT_TYPE_PUBLIC_KEY= 0x04, /* EVP_PKEY * */
+ STORE_OBJECT_TYPE_NUMBER= 0x05, /* BIGNUM * */
+ STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */
+ STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known
+ object types */
+ } STORE_OBJECT_TYPES;
+/* List of text strings corresponding to the object types. */
+extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1];
+
+/* Some store functions take a parameter list. Those parameters come with
+ one of the following codes. The comments following the codes below indicate
+ what type the value should be a pointer to. */
+typedef enum STORE_params
+ {
+ STORE_PARAM_EVP_TYPE= 0x01, /* int */
+ STORE_PARAM_BITS= 0x02, /* size_t */
+ STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */
+ STORE_PARAM_KEY_NO_PARAMETERS= 0x04, /* N/A */
+ STORE_PARAM_AUTH_PASSPHRASE= 0x05, /* char * */
+ STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */
+ STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known
+ parameter types */
+ } STORE_PARAM_TYPES;
+/* Parameter value sizes. -1 means unknown, anything else is the required size. */
+extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1];
+
+/* Store functions take attribute lists. Those attributes come with codes.
+ The comments following the codes below indicate what type the value should
+ be a pointer to. */
+typedef enum STORE_attribs
+ {
+ STORE_ATTR_END= 0x00,
+ STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */
+ STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */
+ STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */
+ STORE_ATTR_SUBJECTKEYID= 0x04, /* 160 bit string (SHA1) */
+ STORE_ATTR_ISSUERSERIALHASH= 0x05, /* 160 bit string (SHA1) */
+ STORE_ATTR_ISSUER= 0x06, /* X509_NAME * */
+ STORE_ATTR_SERIAL= 0x07, /* BIGNUM * */
+ STORE_ATTR_SUBJECT= 0x08, /* X509_NAME * */
+ STORE_ATTR_CERTHASH= 0x09, /* 160 bit string (SHA1) */
+ STORE_ATTR_EMAIL= 0x0a, /* C string */
+ STORE_ATTR_FILENAME= 0x0b, /* C string */
+ STORE_ATTR_TYPE_NUM= 0x0b, /* The amount of known
+ attribute types */
+ STORE_ATTR_OR= 0xff /* This is a special
+ separator, which
+ expresses the OR
+ operation. */
+ } STORE_ATTR_TYPES;
+/* Attribute value sizes. -1 means unknown, anything else is the required size. */
+extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1];
+
+typedef enum STORE_certificate_status
+ {
+ STORE_X509_VALID= 0x00,
+ STORE_X509_EXPIRED= 0x01,
+ STORE_X509_SUSPENDED= 0x02,
+ STORE_X509_REVOKED= 0x03
+ } STORE_CERTIFICATE_STATUS;
+
+/* Engine store functions will return a structure that contains all the necessary
+ * information, including revokation status for certificates. This is really not
+ * needed for application authors, as the ENGINE framework functions will extract
+ * the OpenSSL-specific information when at all possible. However, for engine
+ * authors, it's crucial to know this structure. */
+typedef struct STORE_OBJECT_st
+ {
+ STORE_OBJECT_TYPES type;
+ union
+ {
+ struct
+ {
+ STORE_CERTIFICATE_STATUS status;
+ X509 *certificate;
+ } x509;
+ X509_CRL *crl;
+ EVP_PKEY *key;
+ BIGNUM *number;
+ BUF_MEM *arbitrary;
+ } data;
+ } STORE_OBJECT;
+DECLARE_STACK_OF(STORE_OBJECT)
+STORE_OBJECT *STORE_OBJECT_new(void);
+void STORE_OBJECT_free(STORE_OBJECT *data);
+
+
+
+/* The following functions handle the storage. They return 0, a negative number
+ or NULL on error, anything else on success. */
+X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[],
+ OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[],
+ OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
+int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+X509 *STORE_list_certificate_next(STORE *e, void *handle);
+int STORE_list_certificate_end(STORE *e, void *handle);
+int STORE_list_certificate_endp(STORE *e, void *handle);
+EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_store_private_key(STORE *e, EVP_PKEY *data,
+ OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
+int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[],
+ OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
+ OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
+int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle);
+int STORE_list_private_key_end(STORE *e, void *handle);
+int STORE_list_private_key_endp(STORE *e, void *handle);
+EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[],
+ OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
+ OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
+int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle);
+int STORE_list_public_key_end(STORE *e, void *handle);
+int STORE_list_public_key_endp(STORE *e, void *handle);
+X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[],
+ OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
+ OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
+int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+X509_CRL *STORE_list_crl_next(STORE *e, void *handle);
+int STORE_list_crl_end(STORE *e, void *handle);
+int STORE_list_crl_endp(STORE *e, void *handle);
+int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[],
+ OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
+ OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
+BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[],
+ OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
+ OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
+BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[],
+ OPENSSL_ITEM parameters[]);
+
+
+/* Create and manipulate methods */
+STORE_METHOD *STORE_create_method(char *name);
+void STORE_destroy_method(STORE_METHOD *store_method);
+
+/* These callback types are use for store handlers */
+typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *);
+typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *);
+typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
+typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
+typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
+typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle);
+typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle);
+typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
+typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
+typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
+typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
+typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void));
+
+int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f);
+int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f);
+int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f);
+int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f);
+int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f);
+int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f);
+int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f);
+int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f);
+int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f);
+int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f);
+int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f);
+int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR);
+int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR);
+int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR);
+int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f);
+
+STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm);
+STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm);
+STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm);
+STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm);
+STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm);
+STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm);
+STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm);
+STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm);
+STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm);
+STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm);
+STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm);
+STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm);
+STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm);
+STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm);
+STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm);
+
+/* Method helper structures and functions. */
+
+/* This structure is the result of parsing through the information in a list
+ of OPENSSL_ITEMs. It stores all the necessary information in a structured
+ way.*/
+typedef struct STORE_attr_info_st STORE_ATTR_INFO;
+
+/* Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO.
+ Note that we do this in the list form, since the list of OPENSSL_ITEMs can
+ come in blocks separated with STORE_ATTR_OR. Note that the value returned
+ by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). */
+void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes);
+STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle);
+int STORE_parse_attrs_end(void *handle);
+int STORE_parse_attrs_endp(void *handle);
+
+/* Creator and destructor */
+STORE_ATTR_INFO *STORE_ATTR_INFO_new(void);
+int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs);
+
+/* Manipulators */
+char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code);
+unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs,
+ STORE_ATTR_TYPES code);
+X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code);
+BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code);
+int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
+ char *cstr, size_t cstr_size);
+int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
+ unsigned char *sha1str, size_t sha1str_size);
+int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
+ X509_NAME *dn);
+int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
+ BIGNUM *number);
+int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
+ char *cstr, size_t cstr_size);
+int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
+ unsigned char *sha1str, size_t sha1str_size);
+int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
+ X509_NAME *dn);
+int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
+ BIGNUM *number);
+
+/* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values
+ in each contained attribute. */
+int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
+/* Check if the set of attributes in a is within the range of attributes
+ set in b. */
+int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
+/* Check if the set of attributes in a are also set in b. */
+int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
+/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */
+int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
+
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_STORE_strings(void);
+
+/* Error codes for the STORE functions. */
+
+/* Function codes. */
+#define STORE_F_MEM_DELETE 134
+#define STORE_F_MEM_GENERATE 135
+#define STORE_F_MEM_LIST_END 168
+#define STORE_F_MEM_LIST_NEXT 136
+#define STORE_F_MEM_LIST_START 137
+#define STORE_F_MEM_MODIFY 169
+#define STORE_F_MEM_STORE 138
+#define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139
+#define STORE_F_STORE_ATTR_INFO_GET0_DN 140
+#define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141
+#define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142
+#define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143
+#define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144
+#define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145
+#define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146
+#define STORE_F_STORE_ATTR_INFO_SET_CSTR 147
+#define STORE_F_STORE_ATTR_INFO_SET_DN 148
+#define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149
+#define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150
+#define STORE_F_STORE_CERTIFICATE 170
+#define STORE_F_STORE_CTRL 161
+#define STORE_F_STORE_DELETE_ARBITRARY 158
+#define STORE_F_STORE_DELETE_CERTIFICATE 102
+#define STORE_F_STORE_DELETE_CRL 103
+#define STORE_F_STORE_DELETE_NUMBER 104
+#define STORE_F_STORE_DELETE_PRIVATE_KEY 105
+#define STORE_F_STORE_DELETE_PUBLIC_KEY 106
+#define STORE_F_STORE_GENERATE_CRL 107
+#define STORE_F_STORE_GENERATE_KEY 108
+#define STORE_F_STORE_GET_ARBITRARY 159
+#define STORE_F_STORE_GET_CERTIFICATE 109
+#define STORE_F_STORE_GET_CRL 110
+#define STORE_F_STORE_GET_NUMBER 111
+#define STORE_F_STORE_GET_PRIVATE_KEY 112
+#define STORE_F_STORE_GET_PUBLIC_KEY 113
+#define STORE_F_STORE_LIST_CERTIFICATE_END 114
+#define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153
+#define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115
+#define STORE_F_STORE_LIST_CERTIFICATE_START 116
+#define STORE_F_STORE_LIST_CRL_END 117
+#define STORE_F_STORE_LIST_CRL_ENDP 154
+#define STORE_F_STORE_LIST_CRL_NEXT 118
+#define STORE_F_STORE_LIST_CRL_START 119
+#define STORE_F_STORE_LIST_PRIVATE_KEY_END 120
+#define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155
+#define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121
+#define STORE_F_STORE_LIST_PRIVATE_KEY_START 122
+#define STORE_F_STORE_LIST_PUBLIC_KEY_END 123
+#define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156
+#define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124
+#define STORE_F_STORE_LIST_PUBLIC_KEY_START 125
+#define STORE_F_STORE_MODIFY_ARBITRARY 162
+#define STORE_F_STORE_MODIFY_CERTIFICATE 163
+#define STORE_F_STORE_MODIFY_CRL 164
+#define STORE_F_STORE_MODIFY_NUMBER 165
+#define STORE_F_STORE_MODIFY_PRIVATE_KEY 166
+#define STORE_F_STORE_MODIFY_PUBLIC_KEY 167
+#define STORE_F_STORE_NEW_ENGINE 133
+#define STORE_F_STORE_NEW_METHOD 132
+#define STORE_F_STORE_PARSE_ATTRS_END 151
+#define STORE_F_STORE_PARSE_ATTRS_ENDP 172
+#define STORE_F_STORE_PARSE_ATTRS_NEXT 152
+#define STORE_F_STORE_PARSE_ATTRS_START 171
+#define STORE_F_STORE_REVOKE_CERTIFICATE 129
+#define STORE_F_STORE_REVOKE_PRIVATE_KEY 130
+#define STORE_F_STORE_REVOKE_PUBLIC_KEY 131
+#define STORE_F_STORE_STORE_ARBITRARY 157
+#define STORE_F_STORE_STORE_CERTIFICATE 100
+#define STORE_F_STORE_STORE_CRL 101
+#define STORE_F_STORE_STORE_NUMBER 126
+#define STORE_F_STORE_STORE_PRIVATE_KEY 127
+#define STORE_F_STORE_STORE_PUBLIC_KEY 128
+
+/* Reason codes. */
+#define STORE_R_ALREADY_HAS_A_VALUE 127
+#define STORE_R_FAILED_DELETING_ARBITRARY 132
+#define STORE_R_FAILED_DELETING_CERTIFICATE 100
+#define STORE_R_FAILED_DELETING_KEY 101
+#define STORE_R_FAILED_DELETING_NUMBER 102
+#define STORE_R_FAILED_GENERATING_CRL 103
+#define STORE_R_FAILED_GENERATING_KEY 104
+#define STORE_R_FAILED_GETTING_ARBITRARY 133
+#define STORE_R_FAILED_GETTING_CERTIFICATE 105
+#define STORE_R_FAILED_GETTING_KEY 106
+#define STORE_R_FAILED_GETTING_NUMBER 107
+#define STORE_R_FAILED_LISTING_CERTIFICATES 108
+#define STORE_R_FAILED_LISTING_KEYS 109
+#define STORE_R_FAILED_MODIFYING_ARBITRARY 138
+#define STORE_R_FAILED_MODIFYING_CERTIFICATE 139
+#define STORE_R_FAILED_MODIFYING_CRL 140
+#define STORE_R_FAILED_MODIFYING_NUMBER 141
+#define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142
+#define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143
+#define STORE_R_FAILED_REVOKING_CERTIFICATE 110
+#define STORE_R_FAILED_REVOKING_KEY 111
+#define STORE_R_FAILED_STORING_ARBITRARY 134
+#define STORE_R_FAILED_STORING_CERTIFICATE 112
+#define STORE_R_FAILED_STORING_KEY 113
+#define STORE_R_FAILED_STORING_NUMBER 114
+#define STORE_R_NOT_IMPLEMENTED 128
+#define STORE_R_NO_CONTROL_FUNCTION 144
+#define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135
+#define STORE_R_NO_DELETE_NUMBER_FUNCTION 115
+#define STORE_R_NO_DELETE_OBJECT_FUNCTION 116
+#define STORE_R_NO_GENERATE_CRL_FUNCTION 117
+#define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118
+#define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136
+#define STORE_R_NO_GET_OBJECT_FUNCTION 119
+#define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120
+#define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131
+#define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121
+#define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122
+#define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123
+#define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145
+#define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124
+#define STORE_R_NO_STORE 129
+#define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137
+#define STORE_R_NO_STORE_OBJECT_FUNCTION 125
+#define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126
+#define STORE_R_NO_VALUE 130
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/symhacks.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/symhacks.h
new file mode 100644
index 000000000..8728e6124
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/symhacks.h
@@ -0,0 +1,409 @@
+/* ====================================================================
+ * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_SYMHACKS_H
+#define HEADER_SYMHACKS_H
+
+#include <openssl/e_os2.h>
+
+/* Hacks to solve the problem with linkers incapable of handling very long
+ symbol names. In the case of VMS, the limit is 31 characters on VMS for
+ VAX. */
+#ifdef OPENSSL_SYS_VMS
+
+/* Hack a long name in crypto/cryptlib.c */
+#undef int_CRYPTO_set_do_dynlock_callback
+#define int_CRYPTO_set_do_dynlock_callback int_CRYPTO_set_do_dynlock_cb
+
+/* Hack a long name in crypto/ex_data.c */
+#undef CRYPTO_get_ex_data_implementation
+#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl
+#undef CRYPTO_set_ex_data_implementation
+#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl
+
+/* Hack a long name in crypto/asn1/a_mbstr.c */
+#undef ASN1_STRING_set_default_mask_asc
+#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc
+
+#if 0 /* No longer needed, since safestack macro magic does the job */
+/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */
+#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO
+#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF
+#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO
+#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF
+#endif
+
+#if 0 /* No longer needed, since safestack macro magic does the job */
+/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */
+#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO
+#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF
+#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO
+#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF
+#endif
+
+#if 0 /* No longer needed, since safestack macro magic does the job */
+/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */
+#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION
+#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC
+#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION
+#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC
+#endif
+
+/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */
+#undef PEM_read_NETSCAPE_CERT_SEQUENCE
+#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ
+#undef PEM_write_NETSCAPE_CERT_SEQUENCE
+#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ
+#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE
+#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ
+#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE
+#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ
+#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE
+#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ
+
+/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */
+#undef PEM_read_PKCS8_PRIV_KEY_INFO
+#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO
+#undef PEM_write_PKCS8_PRIV_KEY_INFO
+#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO
+#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO
+#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO
+#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO
+#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO
+#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO
+#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO
+
+/* Hack other PEM names */
+#undef PEM_write_bio_PKCS8PrivateKey_nid
+#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid
+
+/* Hack some long X509 names */
+#undef X509_REVOKED_get_ext_by_critical
+#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic
+#undef X509_policy_tree_get0_user_policies
+#define X509_policy_tree_get0_user_policies X509_pcy_tree_get0_usr_policies
+#undef X509_policy_node_get0_qualifiers
+#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers
+#undef X509_STORE_CTX_get_explicit_policy
+#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy
+
+/* Hack some long CRYPTO names */
+#undef CRYPTO_set_dynlock_destroy_callback
+#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb
+#undef CRYPTO_set_dynlock_create_callback
+#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb
+#undef CRYPTO_set_dynlock_lock_callback
+#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb
+#undef CRYPTO_get_dynlock_lock_callback
+#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb
+#undef CRYPTO_get_dynlock_destroy_callback
+#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb
+#undef CRYPTO_get_dynlock_create_callback
+#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb
+#undef CRYPTO_set_locked_mem_ex_functions
+#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs
+#undef CRYPTO_get_locked_mem_ex_functions
+#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs
+
+/* Hack some long SSL names */
+#undef SSL_CTX_set_default_verify_paths
+#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths
+#undef SSL_get_ex_data_X509_STORE_CTX_idx
+#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx
+#undef SSL_add_file_cert_subjects_to_stack
+#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk
+#undef SSL_add_dir_cert_subjects_to_stack
+#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk
+#undef SSL_CTX_use_certificate_chain_file
+#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file
+#undef SSL_CTX_set_cert_verify_callback
+#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb
+#undef SSL_CTX_set_default_passwd_cb_userdata
+#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud
+#undef SSL_COMP_get_compression_methods
+#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods
+
+/* Hack some long ENGINE names */
+#undef ENGINE_get_default_BN_mod_exp_crt
+#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt
+#undef ENGINE_set_default_BN_mod_exp_crt
+#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt
+#undef ENGINE_set_load_privkey_function
+#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn
+#undef ENGINE_get_load_privkey_function
+#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn
+#undef ENGINE_set_load_ssl_client_cert_function
+#define ENGINE_set_load_ssl_client_cert_function \
+ ENGINE_set_ld_ssl_clnt_cert_fn
+#undef ENGINE_get_ssl_client_cert_function
+#define ENGINE_get_ssl_client_cert_function ENGINE_get_ssl_client_cert_fn
+
+/* Hack some long OCSP names */
+#undef OCSP_REQUEST_get_ext_by_critical
+#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit
+#undef OCSP_BASICRESP_get_ext_by_critical
+#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit
+#undef OCSP_SINGLERESP_get_ext_by_critical
+#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit
+
+/* Hack some long DES names */
+#undef _ossl_old_des_ede3_cfb64_encrypt
+#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt
+#undef _ossl_old_des_ede3_ofb64_encrypt
+#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt
+
+/* Hack some long EVP names */
+#undef OPENSSL_add_all_algorithms_noconf
+#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf
+#undef OPENSSL_add_all_algorithms_conf
+#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf
+
+/* Hack some long EC names */
+#undef EC_GROUP_set_point_conversion_form
+#define EC_GROUP_set_point_conversion_form EC_GROUP_set_point_conv_form
+#undef EC_GROUP_get_point_conversion_form
+#define EC_GROUP_get_point_conversion_form EC_GROUP_get_point_conv_form
+#undef EC_GROUP_clear_free_all_extra_data
+#define EC_GROUP_clear_free_all_extra_data EC_GROUP_clr_free_all_xtra_data
+#undef EC_POINT_set_Jprojective_coordinates_GFp
+#define EC_POINT_set_Jprojective_coordinates_GFp \
+ EC_POINT_set_Jproj_coords_GFp
+#undef EC_POINT_get_Jprojective_coordinates_GFp
+#define EC_POINT_get_Jprojective_coordinates_GFp \
+ EC_POINT_get_Jproj_coords_GFp
+#undef EC_POINT_set_affine_coordinates_GFp
+#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp
+#undef EC_POINT_get_affine_coordinates_GFp
+#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp
+#undef EC_POINT_set_compressed_coordinates_GFp
+#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp
+#undef EC_POINT_set_affine_coordinates_GF2m
+#define EC_POINT_set_affine_coordinates_GF2m EC_POINT_set_affine_coords_GF2m
+#undef EC_POINT_get_affine_coordinates_GF2m
+#define EC_POINT_get_affine_coordinates_GF2m EC_POINT_get_affine_coords_GF2m
+#undef EC_POINT_set_compressed_coordinates_GF2m
+#define EC_POINT_set_compressed_coordinates_GF2m \
+ EC_POINT_set_compr_coords_GF2m
+#undef ec_GF2m_simple_group_clear_finish
+#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish
+#undef ec_GF2m_simple_group_check_discriminant
+#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim
+#undef ec_GF2m_simple_point_clear_finish
+#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish
+#undef ec_GF2m_simple_point_set_to_infinity
+#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf
+#undef ec_GF2m_simple_points_make_affine
+#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine
+#undef ec_GF2m_simple_point_set_affine_coordinates
+#define ec_GF2m_simple_point_set_affine_coordinates \
+ ec_GF2m_smp_pt_set_af_coords
+#undef ec_GF2m_simple_point_get_affine_coordinates
+#define ec_GF2m_simple_point_get_affine_coordinates \
+ ec_GF2m_smp_pt_get_af_coords
+#undef ec_GF2m_simple_set_compressed_coordinates
+#define ec_GF2m_simple_set_compressed_coordinates \
+ ec_GF2m_smp_set_compr_coords
+#undef ec_GFp_simple_group_set_curve_GFp
+#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp
+#undef ec_GFp_simple_group_get_curve_GFp
+#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp
+#undef ec_GFp_simple_group_clear_finish
+#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish
+#undef ec_GFp_simple_group_set_generator
+#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator
+#undef ec_GFp_simple_group_get0_generator
+#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator
+#undef ec_GFp_simple_group_get_cofactor
+#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor
+#undef ec_GFp_simple_point_clear_finish
+#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish
+#undef ec_GFp_simple_point_set_to_infinity
+#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf
+#undef ec_GFp_simple_points_make_affine
+#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine
+#undef ec_GFp_simple_group_get_curve_GFp
+#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp
+#undef ec_GFp_simple_set_Jprojective_coordinates_GFp
+#define ec_GFp_simple_set_Jprojective_coordinates_GFp \
+ ec_GFp_smp_set_Jproj_coords_GFp
+#undef ec_GFp_simple_get_Jprojective_coordinates_GFp
+#define ec_GFp_simple_get_Jprojective_coordinates_GFp \
+ ec_GFp_smp_get_Jproj_coords_GFp
+#undef ec_GFp_simple_point_set_affine_coordinates_GFp
+#define ec_GFp_simple_point_set_affine_coordinates_GFp \
+ ec_GFp_smp_pt_set_af_coords_GFp
+#undef ec_GFp_simple_point_get_affine_coordinates_GFp
+#define ec_GFp_simple_point_get_affine_coordinates_GFp \
+ ec_GFp_smp_pt_get_af_coords_GFp
+#undef ec_GFp_simple_set_compressed_coordinates_GFp
+#define ec_GFp_simple_set_compressed_coordinates_GFp \
+ ec_GFp_smp_set_compr_coords_GFp
+#undef ec_GFp_simple_point_set_affine_coordinates
+#define ec_GFp_simple_point_set_affine_coordinates \
+ ec_GFp_smp_pt_set_af_coords
+#undef ec_GFp_simple_point_get_affine_coordinates
+#define ec_GFp_simple_point_get_affine_coordinates \
+ ec_GFp_smp_pt_get_af_coords
+#undef ec_GFp_simple_set_compressed_coordinates
+#define ec_GFp_simple_set_compressed_coordinates \
+ ec_GFp_smp_set_compr_coords
+#undef ec_GFp_simple_group_check_discriminant
+#define ec_GFp_simple_group_check_discriminant ec_GFp_simple_grp_chk_discrim
+
+/* Hack som long STORE names */
+#undef STORE_method_set_initialise_function
+#define STORE_method_set_initialise_function STORE_meth_set_initialise_fn
+#undef STORE_method_set_cleanup_function
+#define STORE_method_set_cleanup_function STORE_meth_set_cleanup_fn
+#undef STORE_method_set_generate_function
+#define STORE_method_set_generate_function STORE_meth_set_generate_fn
+#undef STORE_method_set_modify_function
+#define STORE_method_set_modify_function STORE_meth_set_modify_fn
+#undef STORE_method_set_revoke_function
+#define STORE_method_set_revoke_function STORE_meth_set_revoke_fn
+#undef STORE_method_set_delete_function
+#define STORE_method_set_delete_function STORE_meth_set_delete_fn
+#undef STORE_method_set_list_start_function
+#define STORE_method_set_list_start_function STORE_meth_set_list_start_fn
+#undef STORE_method_set_list_next_function
+#define STORE_method_set_list_next_function STORE_meth_set_list_next_fn
+#undef STORE_method_set_list_end_function
+#define STORE_method_set_list_end_function STORE_meth_set_list_end_fn
+#undef STORE_method_set_update_store_function
+#define STORE_method_set_update_store_function STORE_meth_set_update_store_fn
+#undef STORE_method_set_lock_store_function
+#define STORE_method_set_lock_store_function STORE_meth_set_lock_store_fn
+#undef STORE_method_set_unlock_store_function
+#define STORE_method_set_unlock_store_function STORE_meth_set_unlock_store_fn
+#undef STORE_method_get_initialise_function
+#define STORE_method_get_initialise_function STORE_meth_get_initialise_fn
+#undef STORE_method_get_cleanup_function
+#define STORE_method_get_cleanup_function STORE_meth_get_cleanup_fn
+#undef STORE_method_get_generate_function
+#define STORE_method_get_generate_function STORE_meth_get_generate_fn
+#undef STORE_method_get_modify_function
+#define STORE_method_get_modify_function STORE_meth_get_modify_fn
+#undef STORE_method_get_revoke_function
+#define STORE_method_get_revoke_function STORE_meth_get_revoke_fn
+#undef STORE_method_get_delete_function
+#define STORE_method_get_delete_function STORE_meth_get_delete_fn
+#undef STORE_method_get_list_start_function
+#define STORE_method_get_list_start_function STORE_meth_get_list_start_fn
+#undef STORE_method_get_list_next_function
+#define STORE_method_get_list_next_function STORE_meth_get_list_next_fn
+#undef STORE_method_get_list_end_function
+#define STORE_method_get_list_end_function STORE_meth_get_list_end_fn
+#undef STORE_method_get_update_store_function
+#define STORE_method_get_update_store_function STORE_meth_get_update_store_fn
+#undef STORE_method_get_lock_store_function
+#define STORE_method_get_lock_store_function STORE_meth_get_lock_store_fn
+#undef STORE_method_get_unlock_store_function
+#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn
+
+/* Hack some long CMS names */
+#undef CMS_RecipientInfo_ktri_get0_algs
+#define CMS_RecipientInfo_ktri_get0_algs CMS_RecipInfo_ktri_get0_algs
+#undef CMS_RecipientInfo_ktri_get0_signer_id
+#define CMS_RecipientInfo_ktri_get0_signer_id CMS_RecipInfo_ktri_get0_sigr_id
+#undef CMS_OtherRevocationInfoFormat_it
+#define CMS_OtherRevocationInfoFormat_it CMS_OtherRevocInfoFormat_it
+#undef CMS_KeyAgreeRecipientIdentifier_it
+#define CMS_KeyAgreeRecipientIdentifier_it CMS_KeyAgreeRecipIdentifier_it
+#undef CMS_OriginatorIdentifierOrKey_it
+#define CMS_OriginatorIdentifierOrKey_it CMS_OriginatorIdOrKey_it
+#undef cms_SignerIdentifier_get0_signer_id
+#define cms_SignerIdentifier_get0_signer_id cms_SignerId_get0_signer_id
+
+#endif /* defined OPENSSL_SYS_VMS */
+
+
+/* Case insensiteve linking causes problems.... */
+#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)
+#undef ERR_load_CRYPTO_strings
+#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings
+#undef OCSP_crlID_new
+#define OCSP_crlID_new OCSP_crlID2_new
+
+#undef d2i_ECPARAMETERS
+#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS
+#undef i2d_ECPARAMETERS
+#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS
+#undef d2i_ECPKPARAMETERS
+#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS
+#undef i2d_ECPKPARAMETERS
+#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS
+
+/* These functions do not seem to exist! However, I'm paranoid...
+ Original command in x509v3.h:
+ These functions are being redefined in another directory,
+ and clash when the linker is case-insensitive, so let's
+ hide them a little, by giving them an extra 'o' at the
+ beginning of the name... */
+#undef X509v3_cleanup_extensions
+#define X509v3_cleanup_extensions oX509v3_cleanup_extensions
+#undef X509v3_add_extension
+#define X509v3_add_extension oX509v3_add_extension
+#undef X509v3_add_netscape_extensions
+#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions
+#undef X509v3_add_standard_extensions
+#define X509v3_add_standard_extensions oX509v3_add_standard_extensions
+
+
+#endif
+
+
+#endif /* ! defined HEADER_VMS_IDHACKS_H */
+/* This one clashes with CMS_data_create */
+#undef cms_Data_create
+#define cms_Data_create priv_cms_Data_create
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/tls1.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/tls1.h
new file mode 100644
index 000000000..2d1d293e1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/tls1.h
@@ -0,0 +1,407 @@
+/* ssl/tls1.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ *
+ * Portions of the attached software ("Contribution") are developed by
+ * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
+ *
+ * The Contribution is licensed pursuant to the OpenSSL open source
+ * license provided above.
+ *
+ * ECC cipher suite support in OpenSSL originally written by
+ * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.
+ *
+ */
+
+#ifndef HEADER_TLS1_H
+#define HEADER_TLS1_H
+
+#include <openssl/buffer.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0
+
+#define TLS1_VERSION 0x0301
+#define TLS1_VERSION_MAJOR 0x03
+#define TLS1_VERSION_MINOR 0x01
+
+#define TLS1_AD_DECRYPTION_FAILED 21
+#define TLS1_AD_RECORD_OVERFLOW 22
+#define TLS1_AD_UNKNOWN_CA 48 /* fatal */
+#define TLS1_AD_ACCESS_DENIED 49 /* fatal */
+#define TLS1_AD_DECODE_ERROR 50 /* fatal */
+#define TLS1_AD_DECRYPT_ERROR 51
+#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */
+#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */
+#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */
+#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */
+#define TLS1_AD_USER_CANCELLED 90
+#define TLS1_AD_NO_RENEGOTIATION 100
+/* codes 110-114 are from RFC3546 */
+#define TLS1_AD_UNSUPPORTED_EXTENSION 110
+#define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111
+#define TLS1_AD_UNRECOGNIZED_NAME 112
+#define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113
+#define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114
+#define TLS1_AD_UNKNOWN_PSK_IDENTITY 115 /* fatal */
+
+/* ExtensionType values from RFC 3546 */
+#define TLSEXT_TYPE_server_name 0
+#define TLSEXT_TYPE_max_fragment_length 1
+#define TLSEXT_TYPE_client_certificate_url 2
+#define TLSEXT_TYPE_trusted_ca_keys 3
+#define TLSEXT_TYPE_truncated_hmac 4
+#define TLSEXT_TYPE_status_request 5
+#define TLSEXT_TYPE_elliptic_curves 10
+#define TLSEXT_TYPE_ec_point_formats 11
+#define TLSEXT_TYPE_session_ticket 35
+
+/* NameType value from RFC 3546 */
+#define TLSEXT_NAMETYPE_host_name 0
+/* status request value from RFC 3546 */
+#define TLSEXT_STATUSTYPE_ocsp 1
+
+#ifndef OPENSSL_NO_TLSEXT
+
+#define TLSEXT_MAXLEN_host_name 255
+
+const char *SSL_get_servername(const SSL *s, const int type) ;
+int SSL_get_servername_type(const SSL *s) ;
+
+#define SSL_set_tlsext_host_name(s,name) \
+SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name)
+
+#define SSL_set_tlsext_debug_callback(ssl, cb) \
+SSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,(void (*)(void))cb)
+
+#define SSL_set_tlsext_debug_arg(ssl, arg) \
+SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0, (void *)arg)
+
+#define SSL_set_tlsext_status_type(ssl, type) \
+SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type, NULL)
+
+#define SSL_get_tlsext_status_exts(ssl, arg) \
+SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)
+
+#define SSL_set_tlsext_status_exts(ssl, arg) \
+SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)
+
+#define SSL_get_tlsext_status_ids(ssl, arg) \
+SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)
+
+#define SSL_set_tlsext_status_ids(ssl, arg) \
+SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)
+
+#define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \
+SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0, (void *)arg)
+
+#define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \
+SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen, (void *)arg)
+
+#define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \
+SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,(void (*)(void))cb)
+
+#define SSL_TLSEXT_ERR_OK 0
+#define SSL_TLSEXT_ERR_ALERT_WARNING 1
+#define SSL_TLSEXT_ERR_ALERT_FATAL 2
+#define SSL_TLSEXT_ERR_NOACK 3
+
+#define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \
+SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0, (void *)arg)
+
+#define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \
+ SSL_CTX_ctrl((ctx),SSL_CTRL_GET_TLXEXT_TICKET_KEYS,(keylen),(keys))
+#define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \
+ SSL_CTX_ctrl((ctx),SSL_CTRL_SET_TLXEXT_TICKET_KEYS,(keylen),(keys))
+
+#define SSL_CTX_set_tlsext_status_cb(ssl, cb) \
+SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,(void (*)(void))cb)
+
+#define SSL_CTX_set_tlsext_status_arg(ssl, arg) \
+SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg)
+
+#define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \
+SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb)
+
+#endif
+
+/* Additional TLS ciphersuites from draft-ietf-tls-56-bit-ciphersuites-00.txt
+ * (available if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see
+ * s3_lib.c). We actually treat them like SSL 3.0 ciphers, which we probably
+ * shouldn't. */
+#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060
+#define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 0x03000061
+#define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x03000062
+#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x03000063
+#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA 0x03000064
+#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065
+#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066
+
+/* AES ciphersuites from RFC3268 */
+
+#define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F
+#define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030
+#define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031
+#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032
+#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033
+#define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034
+
+#define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035
+#define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036
+#define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037
+#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038
+#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039
+#define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A
+
+/* Camellia ciphersuites from RFC4132 */
+#define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041
+#define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042
+#define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043
+#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044
+#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045
+#define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046
+
+#define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084
+#define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085
+#define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086
+#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087
+#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088
+#define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089
+
+/* SEED ciphersuites from RFC4162 */
+#define TLS1_CK_RSA_WITH_SEED_SHA 0x03000096
+#define TLS1_CK_DH_DSS_WITH_SEED_SHA 0x03000097
+#define TLS1_CK_DH_RSA_WITH_SEED_SHA 0x03000098
+#define TLS1_CK_DHE_DSS_WITH_SEED_SHA 0x03000099
+#define TLS1_CK_DHE_RSA_WITH_SEED_SHA 0x0300009A
+#define TLS1_CK_ADH_WITH_SEED_SHA 0x0300009B
+
+/* ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in draft 13 */
+#define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001
+#define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002
+#define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003
+#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004
+#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005
+
+#define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006
+#define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007
+#define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008
+#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009
+#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A
+
+#define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B
+#define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C
+#define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D
+#define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E
+#define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F
+
+#define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010
+#define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011
+#define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012
+#define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013
+#define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014
+
+#define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015
+#define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016
+#define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017
+#define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018
+#define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019
+
+/* XXX
+ * Inconsistency alert:
+ * The OpenSSL names of ciphers with ephemeral DH here include the string
+ * "DHE", while elsewhere it has always been "EDH".
+ * (The alias for the list of all such ciphers also is "EDH".)
+ * The specifications speak of "EDH"; maybe we should allow both forms
+ * for everything. */
+#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 "EXP1024-RC4-MD5"
+#define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 "EXP1024-RC2-CBC-MD5"
+#define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DES-CBC-SHA"
+#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DHE-DSS-DES-CBC-SHA"
+#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA"
+#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA"
+#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA"
+
+/* AES ciphersuites from RFC3268 */
+#define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA"
+#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA"
+#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA"
+#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA"
+#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA"
+#define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA"
+
+#define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA"
+#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA"
+#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA"
+#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA"
+#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA"
+#define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA"
+
+/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */
+#define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA"
+#define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA"
+#define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA"
+#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA"
+#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA"
+
+#define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA"
+#define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA"
+#define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA"
+#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA"
+#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA"
+
+#define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA"
+#define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA"
+#define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA"
+#define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA"
+#define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA"
+
+#define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA"
+#define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA"
+#define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA"
+#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA"
+#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA"
+
+#define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA"
+#define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA"
+#define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA"
+#define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA"
+#define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA"
+
+/* Camellia ciphersuites from RFC4132 */
+#define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA"
+#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA"
+#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA"
+#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA"
+#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA"
+#define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA"
+
+#define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA"
+#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA"
+#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA"
+#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA"
+#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA"
+#define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA"
+
+/* SEED ciphersuites from RFC4162 */
+#define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA"
+#define TLS1_TXT_DH_DSS_WITH_SEED_SHA "DH-DSS-SEED-SHA"
+#define TLS1_TXT_DH_RSA_WITH_SEED_SHA "DH-RSA-SEED-SHA"
+#define TLS1_TXT_DHE_DSS_WITH_SEED_SHA "DHE-DSS-SEED-SHA"
+#define TLS1_TXT_DHE_RSA_WITH_SEED_SHA "DHE-RSA-SEED-SHA"
+#define TLS1_TXT_ADH_WITH_SEED_SHA "ADH-SEED-SHA"
+
+#define TLS_CT_RSA_SIGN 1
+#define TLS_CT_DSS_SIGN 2
+#define TLS_CT_RSA_FIXED_DH 3
+#define TLS_CT_DSS_FIXED_DH 4
+#define TLS_CT_ECDSA_SIGN 64
+#define TLS_CT_RSA_FIXED_ECDH 65
+#define TLS_CT_ECDSA_FIXED_ECDH 66
+#define TLS_CT_NUMBER 7
+
+#define TLS1_FINISH_MAC_LENGTH 12
+
+#define TLS_MD_MAX_CONST_SIZE 20
+#define TLS_MD_CLIENT_FINISH_CONST "client finished"
+#define TLS_MD_CLIENT_FINISH_CONST_SIZE 15
+#define TLS_MD_SERVER_FINISH_CONST "server finished"
+#define TLS_MD_SERVER_FINISH_CONST_SIZE 15
+#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key"
+#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16
+#define TLS_MD_KEY_EXPANSION_CONST "key expansion"
+#define TLS_MD_KEY_EXPANSION_CONST_SIZE 13
+#define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key"
+#define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16
+#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key"
+#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16
+#define TLS_MD_IV_BLOCK_CONST "IV block"
+#define TLS_MD_IV_BLOCK_CONST_SIZE 8
+#define TLS_MD_MASTER_SECRET_CONST "master secret"
+#define TLS_MD_MASTER_SECRET_CONST_SIZE 13
+
+#ifdef CHARSET_EBCDIC
+#undef TLS_MD_CLIENT_FINISH_CONST
+#define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*client finished*/
+#undef TLS_MD_SERVER_FINISH_CONST
+#define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*server finished*/
+#undef TLS_MD_SERVER_WRITE_KEY_CONST
+#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/
+#undef TLS_MD_KEY_EXPANSION_CONST
+#define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" /*key expansion*/
+#undef TLS_MD_CLIENT_WRITE_KEY_CONST
+#define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*client write key*/
+#undef TLS_MD_SERVER_WRITE_KEY_CONST
+#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/
+#undef TLS_MD_IV_BLOCK_CONST
+#define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" /*IV block*/
+#undef TLS_MD_MASTER_SECRET_CONST
+#define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/tmdiff.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/tmdiff.h
new file mode 100644
index 000000000..af5c41c64
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/tmdiff.h
@@ -0,0 +1,93 @@
+/* crypto/tmdiff.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+/* Header for dynamic hash table routines
+ * Author - Eric Young
+ */
+/* ... erm yeah, "dynamic hash tables" you say?
+ *
+ * And what would dynamic hash tables have to do with any of this code *now*?
+ * AFAICS, this code is only referenced by crypto/bn/exp.c which is an unused
+ * file that I doubt compiles any more. speed.c is the only thing that could
+ * use this (and it has nothing to do with hash tables), yet it instead has its
+ * own duplication of all this stuff and looks, if anything, more complete. See
+ * the corresponding note in apps/speed.c.
+ * The Bemused - Geoff
+ */
+
+#ifndef HEADER_TMDIFF_H
+#define HEADER_TMDIFF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ms_tm MS_TM;
+
+MS_TM *ms_time_new(void );
+void ms_time_free(MS_TM *a);
+void ms_time_get(MS_TM *a);
+double ms_time_diff(MS_TM *start, MS_TM *end);
+int ms_time_cmp(const MS_TM *ap, const MS_TM *bp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/txt_db.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/txt_db.h
new file mode 100644
index 000000000..307e1ba23
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/txt_db.h
@@ -0,0 +1,109 @@
+/* crypto/txt_db/txt_db.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_TXT_DB_H
+#define HEADER_TXT_DB_H
+
+#include <openssl/opensslconf.h>
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+#include <openssl/stack.h>
+#include <openssl/lhash.h>
+
+#define DB_ERROR_OK 0
+#define DB_ERROR_MALLOC 1
+#define DB_ERROR_INDEX_CLASH 2
+#define DB_ERROR_INDEX_OUT_OF_RANGE 3
+#define DB_ERROR_NO_INDEX 4
+#define DB_ERROR_INSERT_INDEX_CLASH 5
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct txt_db_st
+ {
+ int num_fields;
+ STACK /* char ** */ *data;
+ LHASH **index;
+ int (**qual)(char **);
+ long error;
+ long arg1;
+ long arg2;
+ char **arg_row;
+ } TXT_DB;
+
+#ifndef OPENSSL_NO_BIO
+TXT_DB *TXT_DB_read(BIO *in, int num);
+long TXT_DB_write(BIO *out, TXT_DB *db);
+#else
+TXT_DB *TXT_DB_read(char *in, int num);
+long TXT_DB_write(char *out, TXT_DB *db);
+#endif
+int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(char **),
+ LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);
+void TXT_DB_free(TXT_DB *db);
+char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value);
+int TXT_DB_insert(TXT_DB *db,char **value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ui.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ui.h
new file mode 100644
index 000000000..018296412
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/ui.h
@@ -0,0 +1,381 @@
+/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */
+/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
+ * project 2001.
+ */
+/* ====================================================================
+ * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_UI_H
+#define HEADER_UI_H
+
+#ifndef OPENSSL_NO_DEPRECATED
+#include <openssl/crypto.h>
+#endif
+#include <openssl/safestack.h>
+#include <openssl/ossl_typ.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Declared already in ossl_typ.h */
+/* typedef struct ui_st UI; */
+/* typedef struct ui_method_st UI_METHOD; */
+
+
+/* All the following functions return -1 or NULL on error and in some cases
+ (UI_process()) -2 if interrupted or in some other way cancelled.
+ When everything is fine, they return 0, a positive value or a non-NULL
+ pointer, all depending on their purpose. */
+
+/* Creators and destructor. */
+UI *UI_new(void);
+UI *UI_new_method(const UI_METHOD *method);
+void UI_free(UI *ui);
+
+/* The following functions are used to add strings to be printed and prompt
+ strings to prompt for data. The names are UI_{add,dup}_<function>_string
+ and UI_{add,dup}_input_boolean.
+
+ UI_{add,dup}_<function>_string have the following meanings:
+ add add a text or prompt string. The pointers given to these
+ functions are used verbatim, no copying is done.
+ dup make a copy of the text or prompt string, then add the copy
+ to the collection of strings in the user interface.
+ <function>
+ The function is a name for the functionality that the given
+ string shall be used for. It can be one of:
+ input use the string as data prompt.
+ verify use the string as verification prompt. This
+ is used to verify a previous input.
+ info use the string for informational output.
+ error use the string for error output.
+ Honestly, there's currently no difference between info and error for the
+ moment.
+
+ UI_{add,dup}_input_boolean have the same semantics for "add" and "dup",
+ and are typically used when one wants to prompt for a yes/no response.
+
+
+ All of the functions in this group take a UI and a prompt string.
+ The string input and verify addition functions also take a flag argument,
+ a buffer for the result to end up with, a minimum input size and a maximum
+ input size (the result buffer MUST be large enough to be able to contain
+ the maximum number of characters). Additionally, the verify addition
+ functions takes another buffer to compare the result against.
+ The boolean input functions take an action description string (which should
+ be safe to ignore if the expected user action is obvious, for example with
+ a dialog box with an OK button and a Cancel button), a string of acceptable
+ characters to mean OK and to mean Cancel. The two last strings are checked
+ to make sure they don't have common characters. Additionally, the same
+ flag argument as for the string input is taken, as well as a result buffer.
+ The result buffer is required to be at least one byte long. Depending on
+ the answer, the first character from the OK or the Cancel character strings
+ will be stored in the first byte of the result buffer. No NUL will be
+ added, so the result is *not* a string.
+
+ On success, the all return an index of the added information. That index
+ is usefull when retrieving results with UI_get0_result(). */
+int UI_add_input_string(UI *ui, const char *prompt, int flags,
+ char *result_buf, int minsize, int maxsize);
+int UI_dup_input_string(UI *ui, const char *prompt, int flags,
+ char *result_buf, int minsize, int maxsize);
+int UI_add_verify_string(UI *ui, const char *prompt, int flags,
+ char *result_buf, int minsize, int maxsize, const char *test_buf);
+int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
+ char *result_buf, int minsize, int maxsize, const char *test_buf);
+int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
+ const char *ok_chars, const char *cancel_chars,
+ int flags, char *result_buf);
+int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
+ const char *ok_chars, const char *cancel_chars,
+ int flags, char *result_buf);
+int UI_add_info_string(UI *ui, const char *text);
+int UI_dup_info_string(UI *ui, const char *text);
+int UI_add_error_string(UI *ui, const char *text);
+int UI_dup_error_string(UI *ui, const char *text);
+
+/* These are the possible flags. They can be or'ed together. */
+/* Use to have echoing of input */
+#define UI_INPUT_FLAG_ECHO 0x01
+/* Use a default password. Where that password is found is completely
+ up to the application, it might for example be in the user data set
+ with UI_add_user_data(). It is not recommended to have more than
+ one input in each UI being marked with this flag, or the application
+ might get confused. */
+#define UI_INPUT_FLAG_DEFAULT_PWD 0x02
+
+/* The user of these routines may want to define flags of their own. The core
+ UI won't look at those, but will pass them on to the method routines. They
+ must use higher bits so they don't get confused with the UI bits above.
+ UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good
+ example of use is this:
+
+ #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE)
+
+*/
+#define UI_INPUT_FLAG_USER_BASE 16
+
+
+/* The following function helps construct a prompt. object_desc is a
+ textual short description of the object, for example "pass phrase",
+ and object_name is the name of the object (might be a card name or
+ a file name.
+ The returned string shall always be allocated on the heap with
+ OPENSSL_malloc(), and need to be free'd with OPENSSL_free().
+
+ If the ui_method doesn't contain a pointer to a user-defined prompt
+ constructor, a default string is built, looking like this:
+
+ "Enter {object_desc} for {object_name}:"
+
+ So, if object_desc has the value "pass phrase" and object_name has
+ the value "foo.key", the resulting string is:
+
+ "Enter pass phrase for foo.key:"
+*/
+char *UI_construct_prompt(UI *ui_method,
+ const char *object_desc, const char *object_name);
+
+
+/* The following function is used to store a pointer to user-specific data.
+ Any previous such pointer will be returned and replaced.
+
+ For callback purposes, this function makes a lot more sense than using
+ ex_data, since the latter requires that different parts of OpenSSL or
+ applications share the same ex_data index.
+
+ Note that the UI_OpenSSL() method completely ignores the user data.
+ Other methods may not, however. */
+void *UI_add_user_data(UI *ui, void *user_data);
+/* We need a user data retrieving function as well. */
+void *UI_get0_user_data(UI *ui);
+
+/* Return the result associated with a prompt given with the index i. */
+const char *UI_get0_result(UI *ui, int i);
+
+/* When all strings have been added, process the whole thing. */
+int UI_process(UI *ui);
+
+/* Give a user interface parametrised control commands. This can be used to
+ send down an integer, a data pointer or a function pointer, as well as
+ be used to get information from a UI. */
+int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void));
+
+/* The commands */
+/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the
+ OpenSSL error stack before printing any info or added error messages and
+ before any prompting. */
+#define UI_CTRL_PRINT_ERRORS 1
+/* Check if a UI_process() is possible to do again with the same instance of
+ a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0
+ if not. */
+#define UI_CTRL_IS_REDOABLE 2
+
+
+/* Some methods may use extra data */
+#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg)
+#define UI_get_app_data(s) UI_get_ex_data(s,0)
+int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int UI_set_ex_data(UI *r,int idx,void *arg);
+void *UI_get_ex_data(UI *r, int idx);
+
+/* Use specific methods instead of the built-in one */
+void UI_set_default_method(const UI_METHOD *meth);
+const UI_METHOD *UI_get_default_method(void);
+const UI_METHOD *UI_get_method(UI *ui);
+const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);
+
+/* The method with all the built-in thingies */
+UI_METHOD *UI_OpenSSL(void);
+
+
+/* ---------- For method writers ---------- */
+/* A method contains a number of functions that implement the low level
+ of the User Interface. The functions are:
+
+ an opener This function starts a session, maybe by opening
+ a channel to a tty, or by opening a window.
+ a writer This function is called to write a given string,
+ maybe to the tty, maybe as a field label in a
+ window.
+ a flusher This function is called to flush everything that
+ has been output so far. It can be used to actually
+ display a dialog box after it has been built.
+ a reader This function is called to read a given prompt,
+ maybe from the tty, maybe from a field in a
+ window. Note that it's called wth all string
+ structures, not only the prompt ones, so it must
+ check such things itself.
+ a closer This function closes the session, maybe by closing
+ the channel to the tty, or closing the window.
+
+ All these functions are expected to return:
+
+ 0 on error.
+ 1 on success.
+ -1 on out-of-band events, for example if some prompting has
+ been canceled (by pressing Ctrl-C, for example). This is
+ only checked when returned by the flusher or the reader.
+
+ The way this is used, the opener is first called, then the writer for all
+ strings, then the flusher, then the reader for all strings and finally the
+ closer. Note that if you want to prompt from a terminal or other command
+ line interface, the best is to have the reader also write the prompts
+ instead of having the writer do it. If you want to prompt from a dialog
+ box, the writer can be used to build up the contents of the box, and the
+ flusher to actually display the box and run the event loop until all data
+ has been given, after which the reader only grabs the given data and puts
+ them back into the UI strings.
+
+ All method functions take a UI as argument. Additionally, the writer and
+ the reader take a UI_STRING.
+*/
+
+/* The UI_STRING type is the data structure that contains all the needed info
+ about a string or a prompt, including test data for a verification prompt.
+*/
+DECLARE_STACK_OF(UI_STRING)
+typedef struct ui_string_st UI_STRING;
+
+/* The different types of strings that are currently supported.
+ This is only needed by method authors. */
+enum UI_string_types
+ {
+ UIT_NONE=0,
+ UIT_PROMPT, /* Prompt for a string */
+ UIT_VERIFY, /* Prompt for a string and verify */
+ UIT_BOOLEAN, /* Prompt for a yes/no response */
+ UIT_INFO, /* Send info to the user */
+ UIT_ERROR /* Send an error message to the user */
+ };
+
+/* Create and manipulate methods */
+UI_METHOD *UI_create_method(char *name);
+void UI_destroy_method(UI_METHOD *ui_method);
+int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui));
+int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis));
+int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui));
+int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis));
+int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui));
+int (*UI_method_get_opener(UI_METHOD *method))(UI*);
+int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*);
+int (*UI_method_get_flusher(UI_METHOD *method))(UI*);
+int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*);
+int (*UI_method_get_closer(UI_METHOD *method))(UI*);
+
+/* The following functions are helpers for method writers to access relevant
+ data from a UI_STRING. */
+
+/* Return type of the UI_STRING */
+enum UI_string_types UI_get_string_type(UI_STRING *uis);
+/* Return input flags of the UI_STRING */
+int UI_get_input_flags(UI_STRING *uis);
+/* Return the actual string to output (the prompt, info or error) */
+const char *UI_get0_output_string(UI_STRING *uis);
+/* Return the optional action string to output (the boolean promtp instruction) */
+const char *UI_get0_action_string(UI_STRING *uis);
+/* Return the result of a prompt */
+const char *UI_get0_result_string(UI_STRING *uis);
+/* Return the string to test the result against. Only useful with verifies. */
+const char *UI_get0_test_string(UI_STRING *uis);
+/* Return the required minimum size of the result */
+int UI_get_result_minsize(UI_STRING *uis);
+/* Return the required maximum size of the result */
+int UI_get_result_maxsize(UI_STRING *uis);
+/* Set the result of a UI_STRING. */
+int UI_set_result(UI *ui, UI_STRING *uis, const char *result);
+
+
+/* A couple of popular utility functions */
+int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify);
+int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
+
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_UI_strings(void);
+
+/* Error codes for the UI functions. */
+
+/* Function codes. */
+#define UI_F_GENERAL_ALLOCATE_BOOLEAN 108
+#define UI_F_GENERAL_ALLOCATE_PROMPT 109
+#define UI_F_GENERAL_ALLOCATE_STRING 100
+#define UI_F_UI_CTRL 111
+#define UI_F_UI_DUP_ERROR_STRING 101
+#define UI_F_UI_DUP_INFO_STRING 102
+#define UI_F_UI_DUP_INPUT_BOOLEAN 110
+#define UI_F_UI_DUP_INPUT_STRING 103
+#define UI_F_UI_DUP_VERIFY_STRING 106
+#define UI_F_UI_GET0_RESULT 107
+#define UI_F_UI_NEW_METHOD 104
+#define UI_F_UI_SET_RESULT 105
+
+/* Reason codes. */
+#define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104
+#define UI_R_INDEX_TOO_LARGE 102
+#define UI_R_INDEX_TOO_SMALL 103
+#define UI_R_NO_RESULT_BUFFER 105
+#define UI_R_RESULT_TOO_LARGE 100
+#define UI_R_RESULT_TOO_SMALL 101
+#define UI_R_UNKNOWN_CONTROL_COMMAND 106
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509.h
new file mode 100644
index 000000000..e71b5257e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509.h
@@ -0,0 +1,1355 @@
+/* crypto/x509/x509.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ * ECDH support in OpenSSL originally developed by
+ * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
+ */
+
+#ifndef HEADER_X509_H
+#define HEADER_X509_H
+
+#include <openssl/e_os2.h>
+#include <openssl/symhacks.h>
+#ifndef OPENSSL_NO_BUFFER
+#include <openssl/buffer.h>
+#endif
+#ifndef OPENSSL_NO_EVP
+#include <openssl/evp.h>
+#endif
+#ifndef OPENSSL_NO_BIO
+#include <openssl/bio.h>
+#endif
+#include <openssl/stack.h>
+#include <openssl/asn1.h>
+#include <openssl/safestack.h>
+
+#ifndef OPENSSL_NO_EC
+#include <openssl/ec.h>
+#endif
+
+#ifndef OPENSSL_NO_ECDSA
+#include <openssl/ecdsa.h>
+#endif
+
+#ifndef OPENSSL_NO_ECDH
+#include <openssl/ecdh.h>
+#endif
+
+#ifndef OPENSSL_NO_DEPRECATED
+#ifndef OPENSSL_NO_RSA
+#include <openssl/rsa.h>
+#endif
+#ifndef OPENSSL_NO_DSA
+#include <openssl/dsa.h>
+#endif
+#ifndef OPENSSL_NO_DH
+#include <openssl/dh.h>
+#endif
+#endif
+
+#ifndef OPENSSL_NO_SHA
+#include <openssl/sha.h>
+#endif
+#include <openssl/ossl_typ.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef OPENSSL_SYS_WIN32
+/* Under Win32 these are defined in wincrypt.h */
+#undef X509_NAME
+#undef X509_CERT_PAIR
+#endif
+
+#define X509_FILETYPE_PEM 1
+#define X509_FILETYPE_ASN1 2
+#define X509_FILETYPE_DEFAULT 3
+
+#define X509v3_KU_DIGITAL_SIGNATURE 0x0080
+#define X509v3_KU_NON_REPUDIATION 0x0040
+#define X509v3_KU_KEY_ENCIPHERMENT 0x0020
+#define X509v3_KU_DATA_ENCIPHERMENT 0x0010
+#define X509v3_KU_KEY_AGREEMENT 0x0008
+#define X509v3_KU_KEY_CERT_SIGN 0x0004
+#define X509v3_KU_CRL_SIGN 0x0002
+#define X509v3_KU_ENCIPHER_ONLY 0x0001
+#define X509v3_KU_DECIPHER_ONLY 0x8000
+#define X509v3_KU_UNDEF 0xffff
+
+typedef struct X509_objects_st
+ {
+ int nid;
+ int (*a2i)(void);
+ int (*i2a)(void);
+ } X509_OBJECTS;
+
+struct X509_algor_st
+ {
+ ASN1_OBJECT *algorithm;
+ ASN1_TYPE *parameter;
+ } /* X509_ALGOR */;
+
+DECLARE_ASN1_SET_OF(X509_ALGOR)
+
+typedef STACK_OF(X509_ALGOR) X509_ALGORS;
+
+typedef struct X509_val_st
+ {
+ ASN1_TIME *notBefore;
+ ASN1_TIME *notAfter;
+ } X509_VAL;
+
+typedef struct X509_pubkey_st
+ {
+ X509_ALGOR *algor;
+ ASN1_BIT_STRING *public_key;
+ EVP_PKEY *pkey;
+ } X509_PUBKEY;
+
+typedef struct X509_sig_st
+ {
+ X509_ALGOR *algor;
+ ASN1_OCTET_STRING *digest;
+ } X509_SIG;
+
+typedef struct X509_name_entry_st
+ {
+ ASN1_OBJECT *object;
+ ASN1_STRING *value;
+ int set;
+ int size; /* temp variable */
+ } X509_NAME_ENTRY;
+
+DECLARE_STACK_OF(X509_NAME_ENTRY)
+DECLARE_ASN1_SET_OF(X509_NAME_ENTRY)
+
+/* we always keep X509_NAMEs in 2 forms. */
+struct X509_name_st
+ {
+ STACK_OF(X509_NAME_ENTRY) *entries;
+ int modified; /* true if 'bytes' needs to be built */
+#ifndef OPENSSL_NO_BUFFER
+ BUF_MEM *bytes;
+#else
+ char *bytes;
+#endif
+ unsigned long hash; /* Keep the hash around for lookups */
+ } /* X509_NAME */;
+
+DECLARE_STACK_OF(X509_NAME)
+
+#define X509_EX_V_NETSCAPE_HACK 0x8000
+#define X509_EX_V_INIT 0x0001
+typedef struct X509_extension_st
+ {
+ ASN1_OBJECT *object;
+ ASN1_BOOLEAN critical;
+ ASN1_OCTET_STRING *value;
+ } X509_EXTENSION;
+
+typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
+
+DECLARE_STACK_OF(X509_EXTENSION)
+DECLARE_ASN1_SET_OF(X509_EXTENSION)
+
+/* a sequence of these are used */
+typedef struct x509_attributes_st
+ {
+ ASN1_OBJECT *object;
+ int single; /* 0 for a set, 1 for a single item (which is wrong) */
+ union {
+ char *ptr;
+/* 0 */ STACK_OF(ASN1_TYPE) *set;
+/* 1 */ ASN1_TYPE *single;
+ } value;
+ } X509_ATTRIBUTE;
+
+DECLARE_STACK_OF(X509_ATTRIBUTE)
+DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)
+
+
+typedef struct X509_req_info_st
+ {
+ ASN1_ENCODING enc;
+ ASN1_INTEGER *version;
+ X509_NAME *subject;
+ X509_PUBKEY *pubkey;
+ /* d=2 hl=2 l= 0 cons: cont: 00 */
+ STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
+ } X509_REQ_INFO;
+
+typedef struct X509_req_st
+ {
+ X509_REQ_INFO *req_info;
+ X509_ALGOR *sig_alg;
+ ASN1_BIT_STRING *signature;
+ int references;
+ } X509_REQ;
+
+typedef struct x509_cinf_st
+ {
+ ASN1_INTEGER *version; /* [ 0 ] default of v1 */
+ ASN1_INTEGER *serialNumber;
+ X509_ALGOR *signature;
+ X509_NAME *issuer;
+ X509_VAL *validity;
+ X509_NAME *subject;
+ X509_PUBKEY *key;
+ ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */
+ ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */
+ STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */
+ } X509_CINF;
+
+/* This stuff is certificate "auxiliary info"
+ * it contains details which are useful in certificate
+ * stores and databases. When used this is tagged onto
+ * the end of the certificate itself
+ */
+
+typedef struct x509_cert_aux_st
+ {
+ STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */
+ STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */
+ ASN1_UTF8STRING *alias; /* "friendly name" */
+ ASN1_OCTET_STRING *keyid; /* key id of private key */
+ STACK_OF(X509_ALGOR) *other; /* other unspecified info */
+ } X509_CERT_AUX;
+
+struct x509_st
+ {
+ X509_CINF *cert_info;
+ X509_ALGOR *sig_alg;
+ ASN1_BIT_STRING *signature;
+ int valid;
+ int references;
+ char *name;
+ CRYPTO_EX_DATA ex_data;
+ /* These contain copies of various extension values */
+ long ex_pathlen;
+ long ex_pcpathlen;
+ unsigned long ex_flags;
+ unsigned long ex_kusage;
+ unsigned long ex_xkusage;
+ unsigned long ex_nscert;
+ ASN1_OCTET_STRING *skid;
+ struct AUTHORITY_KEYID_st *akid;
+ X509_POLICY_CACHE *policy_cache;
+#ifndef OPENSSL_NO_RFC3779
+ STACK_OF(IPAddressFamily) *rfc3779_addr;
+ struct ASIdentifiers_st *rfc3779_asid;
+#endif
+#ifndef OPENSSL_NO_SHA
+ unsigned char sha1_hash[SHA_DIGEST_LENGTH];
+#endif
+ X509_CERT_AUX *aux;
+ } /* X509 */;
+
+DECLARE_STACK_OF(X509)
+DECLARE_ASN1_SET_OF(X509)
+
+/* This is used for a table of trust checking functions */
+
+typedef struct x509_trust_st {
+ int trust;
+ int flags;
+ int (*check_trust)(struct x509_trust_st *, X509 *, int);
+ char *name;
+ int arg1;
+ void *arg2;
+} X509_TRUST;
+
+DECLARE_STACK_OF(X509_TRUST)
+
+typedef struct x509_cert_pair_st {
+ X509 *forward;
+ X509 *reverse;
+} X509_CERT_PAIR;
+
+/* standard trust ids */
+
+#define X509_TRUST_DEFAULT -1 /* Only valid in purpose settings */
+
+#define X509_TRUST_COMPAT 1
+#define X509_TRUST_SSL_CLIENT 2
+#define X509_TRUST_SSL_SERVER 3
+#define X509_TRUST_EMAIL 4
+#define X509_TRUST_OBJECT_SIGN 5
+#define X509_TRUST_OCSP_SIGN 6
+#define X509_TRUST_OCSP_REQUEST 7
+
+/* Keep these up to date! */
+#define X509_TRUST_MIN 1
+#define X509_TRUST_MAX 7
+
+
+/* trust_flags values */
+#define X509_TRUST_DYNAMIC 1
+#define X509_TRUST_DYNAMIC_NAME 2
+
+/* check_trust return codes */
+
+#define X509_TRUST_TRUSTED 1
+#define X509_TRUST_REJECTED 2
+#define X509_TRUST_UNTRUSTED 3
+
+/* Flags for X509_print_ex() */
+
+#define X509_FLAG_COMPAT 0
+#define X509_FLAG_NO_HEADER 1L
+#define X509_FLAG_NO_VERSION (1L << 1)
+#define X509_FLAG_NO_SERIAL (1L << 2)
+#define X509_FLAG_NO_SIGNAME (1L << 3)
+#define X509_FLAG_NO_ISSUER (1L << 4)
+#define X509_FLAG_NO_VALIDITY (1L << 5)
+#define X509_FLAG_NO_SUBJECT (1L << 6)
+#define X509_FLAG_NO_PUBKEY (1L << 7)
+#define X509_FLAG_NO_EXTENSIONS (1L << 8)
+#define X509_FLAG_NO_SIGDUMP (1L << 9)
+#define X509_FLAG_NO_AUX (1L << 10)
+#define X509_FLAG_NO_ATTRIBUTES (1L << 11)
+
+/* Flags specific to X509_NAME_print_ex() */
+
+/* The field separator information */
+
+#define XN_FLAG_SEP_MASK (0xf << 16)
+
+#define XN_FLAG_COMPAT 0 /* Traditional SSLeay: use old X509_NAME_print */
+#define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */
+#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */
+#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */
+#define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */
+
+#define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */
+
+/* How the field name is shown */
+
+#define XN_FLAG_FN_MASK (0x3 << 21)
+
+#define XN_FLAG_FN_SN 0 /* Object short name */
+#define XN_FLAG_FN_LN (1 << 21) /* Object long name */
+#define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */
+#define XN_FLAG_FN_NONE (3 << 21) /* No field names */
+
+#define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */
+
+/* This determines if we dump fields we don't recognise:
+ * RFC2253 requires this.
+ */
+
+#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
+
+#define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */
+
+/* Complete set of RFC2253 flags */
+
+#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
+ XN_FLAG_SEP_COMMA_PLUS | \
+ XN_FLAG_DN_REV | \
+ XN_FLAG_FN_SN | \
+ XN_FLAG_DUMP_UNKNOWN_FIELDS)
+
+/* readable oneline form */
+
+#define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
+ ASN1_STRFLGS_ESC_QUOTE | \
+ XN_FLAG_SEP_CPLUS_SPC | \
+ XN_FLAG_SPC_EQ | \
+ XN_FLAG_FN_SN)
+
+/* readable multiline form */
+
+#define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
+ ASN1_STRFLGS_ESC_MSB | \
+ XN_FLAG_SEP_MULTILINE | \
+ XN_FLAG_SPC_EQ | \
+ XN_FLAG_FN_LN | \
+ XN_FLAG_FN_ALIGN)
+
+typedef struct X509_revoked_st
+ {
+ ASN1_INTEGER *serialNumber;
+ ASN1_TIME *revocationDate;
+ STACK_OF(X509_EXTENSION) /* optional */ *extensions;
+ int sequence; /* load sequence */
+ } X509_REVOKED;
+
+DECLARE_STACK_OF(X509_REVOKED)
+DECLARE_ASN1_SET_OF(X509_REVOKED)
+
+typedef struct X509_crl_info_st
+ {
+ ASN1_INTEGER *version;
+ X509_ALGOR *sig_alg;
+ X509_NAME *issuer;
+ ASN1_TIME *lastUpdate;
+ ASN1_TIME *nextUpdate;
+ STACK_OF(X509_REVOKED) *revoked;
+ STACK_OF(X509_EXTENSION) /* [0] */ *extensions;
+ ASN1_ENCODING enc;
+ } X509_CRL_INFO;
+
+struct X509_crl_st
+ {
+ /* actual signature */
+ X509_CRL_INFO *crl;
+ X509_ALGOR *sig_alg;
+ ASN1_BIT_STRING *signature;
+ int references;
+ } /* X509_CRL */;
+
+DECLARE_STACK_OF(X509_CRL)
+DECLARE_ASN1_SET_OF(X509_CRL)
+
+typedef struct private_key_st
+ {
+ int version;
+ /* The PKCS#8 data types */
+ X509_ALGOR *enc_algor;
+ ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */
+
+ /* When decrypted, the following will not be NULL */
+ EVP_PKEY *dec_pkey;
+
+ /* used to encrypt and decrypt */
+ int key_length;
+ char *key_data;
+ int key_free; /* true if we should auto free key_data */
+
+ /* expanded version of 'enc_algor' */
+ EVP_CIPHER_INFO cipher;
+
+ int references;
+ } X509_PKEY;
+
+#ifndef OPENSSL_NO_EVP
+typedef struct X509_info_st
+ {
+ X509 *x509;
+ X509_CRL *crl;
+ X509_PKEY *x_pkey;
+
+ EVP_CIPHER_INFO enc_cipher;
+ int enc_len;
+ char *enc_data;
+
+ int references;
+ } X509_INFO;
+
+DECLARE_STACK_OF(X509_INFO)
+#endif
+
+/* The next 2 structures and their 8 routines were sent to me by
+ * Pat Richard <patr@x509.com> and are used to manipulate
+ * Netscapes spki structures - useful if you are writing a CA web page
+ */
+typedef struct Netscape_spkac_st
+ {
+ X509_PUBKEY *pubkey;
+ ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */
+ } NETSCAPE_SPKAC;
+
+typedef struct Netscape_spki_st
+ {
+ NETSCAPE_SPKAC *spkac; /* signed public key and challenge */
+ X509_ALGOR *sig_algor;
+ ASN1_BIT_STRING *signature;
+ } NETSCAPE_SPKI;
+
+/* Netscape certificate sequence structure */
+typedef struct Netscape_certificate_sequence
+ {
+ ASN1_OBJECT *type;
+ STACK_OF(X509) *certs;
+ } NETSCAPE_CERT_SEQUENCE;
+
+/* Unused (and iv length is wrong)
+typedef struct CBCParameter_st
+ {
+ unsigned char iv[8];
+ } CBC_PARAM;
+*/
+
+/* Password based encryption structure */
+
+typedef struct PBEPARAM_st {
+ASN1_OCTET_STRING *salt;
+ASN1_INTEGER *iter;
+} PBEPARAM;
+
+/* Password based encryption V2 structures */
+
+typedef struct PBE2PARAM_st {
+X509_ALGOR *keyfunc;
+X509_ALGOR *encryption;
+} PBE2PARAM;
+
+typedef struct PBKDF2PARAM_st {
+ASN1_TYPE *salt; /* Usually OCTET STRING but could be anything */
+ASN1_INTEGER *iter;
+ASN1_INTEGER *keylength;
+X509_ALGOR *prf;
+} PBKDF2PARAM;
+
+
+/* PKCS#8 private key info structure */
+
+typedef struct pkcs8_priv_key_info_st
+ {
+ int broken; /* Flag for various broken formats */
+#define PKCS8_OK 0
+#define PKCS8_NO_OCTET 1
+#define PKCS8_EMBEDDED_PARAM 2
+#define PKCS8_NS_DB 3
+ ASN1_INTEGER *version;
+ X509_ALGOR *pkeyalg;
+ ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */
+ STACK_OF(X509_ATTRIBUTE) *attributes;
+ } PKCS8_PRIV_KEY_INFO;
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <openssl/x509_vfy.h>
+#include <openssl/pkcs7.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef SSLEAY_MACROS
+#define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\
+ a->signature,(char *)a->cert_info,r)
+#define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \
+ a->sig_alg,a->signature,(char *)a->req_info,r)
+#define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \
+ a->sig_alg, a->signature,(char *)a->crl,r)
+
+#define X509_sign(x,pkey,md) \
+ ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \
+ x->sig_alg, x->signature, (char *)x->cert_info,pkey,md)
+#define X509_REQ_sign(x,pkey,md) \
+ ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \
+ x->signature, (char *)x->req_info,pkey,md)
+#define X509_CRL_sign(x,pkey,md) \
+ ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \
+ x->signature, (char *)x->crl,pkey,md)
+#define NETSCAPE_SPKI_sign(x,pkey,md) \
+ ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \
+ x->signature, (char *)x->spkac,pkey,md)
+
+#define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \
+ (char *(*)())d2i_X509,(char *)x509)
+#define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\
+ (int (*)())i2d_X509_ATTRIBUTE, \
+ (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa)
+#define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \
+ (int (*)())i2d_X509_EXTENSION, \
+ (char *(*)())d2i_X509_EXTENSION,(char *)ex)
+#define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \
+ (char *(*)())d2i_X509, (fp),(unsigned char **)(x509))
+#define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509)
+#define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \
+ (char *(*)())d2i_X509, (bp),(unsigned char **)(x509))
+#define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509)
+
+#define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \
+ (char *(*)())d2i_X509_CRL,(char *)crl)
+#define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \
+ X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\
+ (unsigned char **)(crl))
+#define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\
+ (unsigned char *)crl)
+#define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \
+ X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\
+ (unsigned char **)(crl))
+#define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\
+ (unsigned char *)crl)
+
+#define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \
+ (char *(*)())d2i_PKCS7,(char *)p7)
+#define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \
+ PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\
+ (unsigned char **)(p7))
+#define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\
+ (unsigned char *)p7)
+#define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \
+ PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\
+ (unsigned char **)(p7))
+#define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\
+ (unsigned char *)p7)
+
+#define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \
+ (char *(*)())d2i_X509_REQ,(char *)req)
+#define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\
+ X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\
+ (unsigned char **)(req))
+#define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\
+ (unsigned char *)req)
+#define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\
+ X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\
+ (unsigned char **)(req))
+#define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\
+ (unsigned char *)req)
+
+#define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \
+ (char *(*)())d2i_RSAPublicKey,(char *)rsa)
+#define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \
+ (char *(*)())d2i_RSAPrivateKey,(char *)rsa)
+
+#define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
+ RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \
+ (unsigned char **)(rsa))
+#define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \
+ (unsigned char *)rsa)
+#define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
+ RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \
+ (unsigned char **)(rsa))
+#define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \
+ (unsigned char *)rsa)
+
+#define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
+ RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \
+ (unsigned char **)(rsa))
+#define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \
+ (unsigned char *)rsa)
+#define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
+ RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \
+ (unsigned char **)(rsa))
+#define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \
+ (unsigned char *)rsa)
+
+#define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\
+ DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \
+ (unsigned char **)(dsa))
+#define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \
+ (unsigned char *)dsa)
+#define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\
+ DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \
+ (unsigned char **)(dsa))
+#define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \
+ (unsigned char *)dsa)
+
+#define d2i_ECPrivateKey_fp(fp,ecdsa) (EC_KEY *)ASN1_d2i_fp((char *(*)())\
+ EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (fp), \
+ (unsigned char **)(ecdsa))
+#define i2d_ECPrivateKey_fp(fp,ecdsa) ASN1_i2d_fp(i2d_ECPrivateKey,fp, \
+ (unsigned char *)ecdsa)
+#define d2i_ECPrivateKey_bio(bp,ecdsa) (EC_KEY *)ASN1_d2i_bio((char *(*)())\
+ EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (bp), \
+ (unsigned char **)(ecdsa))
+#define i2d_ECPrivateKey_bio(bp,ecdsa) ASN1_i2d_bio(i2d_ECPrivateKey,bp, \
+ (unsigned char *)ecdsa)
+
+#define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\
+ (char *(*)())d2i_X509_ALGOR,(char *)xn)
+
+#define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \
+ (char *(*)())d2i_X509_NAME,(char *)xn)
+#define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \
+ (int (*)())i2d_X509_NAME_ENTRY, \
+ (char *(*)())d2i_X509_NAME_ENTRY,\
+ (char *)ne)
+
+#define X509_digest(data,type,md,len) \
+ ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len)
+#define X509_NAME_digest(data,type,md,len) \
+ ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len)
+#ifndef PKCS7_ISSUER_AND_SERIAL_digest
+#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \
+ ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\
+ (char *)data,md,len)
+#endif
+#endif
+
+#define X509_EXT_PACK_UNKNOWN 1
+#define X509_EXT_PACK_STRING 2
+
+#define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version)
+/* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */
+#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)
+#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)
+#define X509_extract_key(x) X509_get_pubkey(x) /*****/
+#define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version)
+#define X509_REQ_get_subject_name(x) ((x)->req_info->subject)
+#define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)
+#define X509_name_cmp(a,b) X509_NAME_cmp((a),(b))
+#define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm))
+
+#define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version)
+#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate)
+#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate)
+#define X509_CRL_get_issuer(x) ((x)->crl->issuer)
+#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked)
+
+/* This one is only used so that a binary form can output, as in
+ * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */
+#define X509_get_X509_PUBKEY(x) ((x)->cert_info->key)
+
+
+const char *X509_verify_cert_error_string(long n);
+
+#ifndef SSLEAY_MACROS
+#ifndef OPENSSL_NO_EVP
+int X509_verify(X509 *a, EVP_PKEY *r);
+
+int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
+int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
+int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
+
+NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
+char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
+EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
+int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
+
+int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
+
+int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig);
+
+int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
+int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
+int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
+int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
+
+int X509_pubkey_digest(const X509 *data,const EVP_MD *type,
+ unsigned char *md, unsigned int *len);
+int X509_digest(const X509 *data,const EVP_MD *type,
+ unsigned char *md, unsigned int *len);
+int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type,
+ unsigned char *md, unsigned int *len);
+int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type,
+ unsigned char *md, unsigned int *len);
+int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type,
+ unsigned char *md, unsigned int *len);
+#endif
+
+#ifndef OPENSSL_NO_FP_API
+X509 *d2i_X509_fp(FILE *fp, X509 **x509);
+int i2d_X509_fp(FILE *fp,X509 *x509);
+X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
+int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
+X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
+int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
+#ifndef OPENSSL_NO_RSA
+RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
+int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
+RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
+int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
+RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
+int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
+#endif
+#ifndef OPENSSL_NO_DSA
+DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
+int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
+DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
+int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
+#endif
+#ifndef OPENSSL_NO_EC
+EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
+int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);
+EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
+int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);
+#endif
+X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
+int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
+PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
+ PKCS8_PRIV_KEY_INFO **p8inf);
+int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
+int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
+int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
+EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
+int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
+EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
+#endif
+
+#ifndef OPENSSL_NO_BIO
+X509 *d2i_X509_bio(BIO *bp,X509 **x509);
+int i2d_X509_bio(BIO *bp,X509 *x509);
+X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
+int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
+X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
+int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
+#ifndef OPENSSL_NO_RSA
+RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
+int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
+RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
+int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
+RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
+int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
+#endif
+#ifndef OPENSSL_NO_DSA
+DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
+int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
+DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
+int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
+#endif
+#ifndef OPENSSL_NO_EC
+EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
+int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);
+EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
+int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);
+#endif
+X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8);
+int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
+PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
+ PKCS8_PRIV_KEY_INFO **p8inf);
+int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
+int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
+int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
+EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
+int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);
+EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
+#endif
+
+X509 *X509_dup(X509 *x509);
+X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
+X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
+X509_CRL *X509_CRL_dup(X509_CRL *crl);
+X509_REQ *X509_REQ_dup(X509_REQ *req);
+X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
+int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
+void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
+ X509_ALGOR *algor);
+
+X509_NAME *X509_NAME_dup(X509_NAME *xn);
+X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
+
+#endif /* !SSLEAY_MACROS */
+
+int X509_cmp_time(ASN1_TIME *s, time_t *t);
+int X509_cmp_current_time(ASN1_TIME *s);
+ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
+ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj);
+
+const char * X509_get_default_cert_area(void );
+const char * X509_get_default_cert_dir(void );
+const char * X509_get_default_cert_file(void );
+const char * X509_get_default_cert_dir_env(void );
+const char * X509_get_default_cert_file_env(void );
+const char * X509_get_default_private_dir(void );
+
+X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
+X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
+
+DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
+DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
+DECLARE_ASN1_FUNCTIONS(X509_VAL)
+
+DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)
+
+int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
+EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key);
+int X509_get_pubkey_parameters(EVP_PKEY *pkey,
+ STACK_OF(X509) *chain);
+int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
+EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp,
+ long length);
+#ifndef OPENSSL_NO_RSA
+int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
+RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp,
+ long length);
+#endif
+#ifndef OPENSSL_NO_DSA
+int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
+DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp,
+ long length);
+#endif
+#ifndef OPENSSL_NO_EC
+int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);
+EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp,
+ long length);
+#endif
+
+DECLARE_ASN1_FUNCTIONS(X509_SIG)
+DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
+DECLARE_ASN1_FUNCTIONS(X509_REQ)
+
+DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
+X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
+
+DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
+DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)
+
+DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)
+
+DECLARE_ASN1_FUNCTIONS(X509_NAME)
+
+int X509_NAME_set(X509_NAME **xn, X509_NAME *name);
+
+DECLARE_ASN1_FUNCTIONS(X509_CINF)
+
+DECLARE_ASN1_FUNCTIONS(X509)
+DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
+
+DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR)
+
+int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int X509_set_ex_data(X509 *r, int idx, void *arg);
+void *X509_get_ex_data(X509 *r, int idx);
+int i2d_X509_AUX(X509 *a,unsigned char **pp);
+X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length);
+
+int X509_alias_set1(X509 *x, unsigned char *name, int len);
+int X509_keyid_set1(X509 *x, unsigned char *id, int len);
+unsigned char * X509_alias_get0(X509 *x, int *len);
+unsigned char * X509_keyid_get0(X509 *x, int *len);
+int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
+int X509_TRUST_set(int *t, int trust);
+int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
+int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
+void X509_trust_clear(X509 *x);
+void X509_reject_clear(X509 *x);
+
+DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
+DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
+DECLARE_ASN1_FUNCTIONS(X509_CRL)
+
+int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
+
+X509_PKEY * X509_PKEY_new(void );
+void X509_PKEY_free(X509_PKEY *a);
+int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp);
+X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length);
+
+DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)
+DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
+DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)
+
+#ifndef OPENSSL_NO_EVP
+X509_INFO * X509_INFO_new(void);
+void X509_INFO_free(X509_INFO *a);
+char * X509_NAME_oneline(X509_NAME *a,char *buf,int size);
+
+int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,
+ ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey);
+
+int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data,
+ unsigned char *md,unsigned int *len);
+
+int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,
+ X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
+ char *data,EVP_PKEY *pkey, const EVP_MD *type);
+
+int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data,
+ unsigned char *md,unsigned int *len);
+
+int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
+ ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey);
+
+int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
+ ASN1_BIT_STRING *signature,
+ void *data, EVP_PKEY *pkey, const EVP_MD *type);
+#endif
+
+int X509_set_version(X509 *x,long version);
+int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
+ASN1_INTEGER * X509_get_serialNumber(X509 *x);
+int X509_set_issuer_name(X509 *x, X509_NAME *name);
+X509_NAME * X509_get_issuer_name(X509 *a);
+int X509_set_subject_name(X509 *x, X509_NAME *name);
+X509_NAME * X509_get_subject_name(X509 *a);
+int X509_set_notBefore(X509 *x, ASN1_TIME *tm);
+int X509_set_notAfter(X509 *x, ASN1_TIME *tm);
+int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
+EVP_PKEY * X509_get_pubkey(X509 *x);
+ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x);
+int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */);
+
+int X509_REQ_set_version(X509_REQ *x,long version);
+int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name);
+int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
+EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req);
+int X509_REQ_extension_nid(int nid);
+int * X509_REQ_get_extension_nids(void);
+void X509_REQ_set_extension_nids(int *nids);
+STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
+int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
+ int nid);
+int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
+int X509_REQ_get_attr_count(const X509_REQ *req);
+int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
+ int lastpos);
+int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
+ int lastpos);
+X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
+X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
+int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
+int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
+ const ASN1_OBJECT *obj, int type,
+ const unsigned char *bytes, int len);
+int X509_REQ_add1_attr_by_NID(X509_REQ *req,
+ int nid, int type,
+ const unsigned char *bytes, int len);
+int X509_REQ_add1_attr_by_txt(X509_REQ *req,
+ const char *attrname, int type,
+ const unsigned char *bytes, int len);
+
+int X509_CRL_set_version(X509_CRL *x, long version);
+int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
+int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm);
+int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm);
+int X509_CRL_sort(X509_CRL *crl);
+
+int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
+int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
+
+int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey);
+
+int X509_check_private_key(X509 *x509,EVP_PKEY *pkey);
+
+int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
+unsigned long X509_issuer_and_serial_hash(X509 *a);
+
+int X509_issuer_name_cmp(const X509 *a, const X509 *b);
+unsigned long X509_issuer_name_hash(X509 *a);
+
+int X509_subject_name_cmp(const X509 *a, const X509 *b);
+unsigned long X509_subject_name_hash(X509 *x);
+
+int X509_cmp(const X509 *a, const X509 *b);
+int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
+unsigned long X509_NAME_hash(X509_NAME *x);
+
+int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
+#ifndef OPENSSL_NO_FP_API
+int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
+int X509_print_fp(FILE *bp,X509 *x);
+int X509_CRL_print_fp(FILE *bp,X509_CRL *x);
+int X509_REQ_print_fp(FILE *bp,X509_REQ *req);
+int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags);
+#endif
+
+#ifndef OPENSSL_NO_BIO
+int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
+int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags);
+int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
+int X509_print(BIO *bp,X509 *x);
+int X509_ocspid_print(BIO *bp,X509 *x);
+int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
+int X509_CRL_print(BIO *bp,X509_CRL *x);
+int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag);
+int X509_REQ_print(BIO *bp,X509_REQ *req);
+#endif
+
+int X509_NAME_entry_count(X509_NAME *name);
+int X509_NAME_get_text_by_NID(X509_NAME *name, int nid,
+ char *buf,int len);
+int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
+ char *buf,int len);
+
+/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use
+ * lastpos, search after that position on. */
+int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
+int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj,
+ int lastpos);
+X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
+X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
+int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,
+ int loc, int set);
+int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
+ unsigned char *bytes, int len, int loc, int set);
+int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
+ unsigned char *bytes, int len, int loc, int set);
+X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
+ const char *field, int type, const unsigned char *bytes, int len);
+X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
+ int type,unsigned char *bytes, int len);
+int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
+ const unsigned char *bytes, int len, int loc, int set);
+X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
+ ASN1_OBJECT *obj, int type,const unsigned char *bytes,
+ int len);
+int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne,
+ ASN1_OBJECT *obj);
+int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
+ const unsigned char *bytes, int len);
+ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
+ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
+
+int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
+int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
+ int nid, int lastpos);
+int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
+ ASN1_OBJECT *obj,int lastpos);
+int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
+ int crit, int lastpos);
+X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
+X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
+STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
+ X509_EXTENSION *ex, int loc);
+
+int X509_get_ext_count(X509 *x);
+int X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
+int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos);
+int X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
+X509_EXTENSION *X509_get_ext(X509 *x, int loc);
+X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
+int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
+void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
+int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
+ unsigned long flags);
+
+int X509_CRL_get_ext_count(X509_CRL *x);
+int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
+int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos);
+int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
+X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
+X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
+int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
+void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
+int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
+ unsigned long flags);
+
+int X509_REVOKED_get_ext_count(X509_REVOKED *x);
+int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
+int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos);
+int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
+X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
+X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
+int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
+void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
+int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
+ unsigned long flags);
+
+X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
+ int nid, int crit, ASN1_OCTET_STRING *data);
+X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
+ ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data);
+int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj);
+int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
+int X509_EXTENSION_set_data(X509_EXTENSION *ex,
+ ASN1_OCTET_STRING *data);
+ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex);
+ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
+int X509_EXTENSION_get_critical(X509_EXTENSION *ex);
+
+int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
+int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
+ int lastpos);
+int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj,
+ int lastpos);
+X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
+X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
+STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
+ X509_ATTRIBUTE *attr);
+STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
+ const ASN1_OBJECT *obj, int type,
+ const unsigned char *bytes, int len);
+STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
+ int nid, int type,
+ const unsigned char *bytes, int len);
+STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
+ const char *attrname, int type,
+ const unsigned char *bytes, int len);
+void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x,
+ ASN1_OBJECT *obj, int lastpos, int type);
+X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
+ int atrtype, const void *data, int len);
+X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
+ const ASN1_OBJECT *obj, int atrtype, const void *data, int len);
+X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
+ const char *atrname, int type, const unsigned char *bytes, int len);
+int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
+int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len);
+void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
+ int atrtype, void *data);
+int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
+ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
+ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
+
+int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
+int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid,
+ int lastpos);
+int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,
+ int lastpos);
+X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
+X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
+int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
+int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
+ const ASN1_OBJECT *obj, int type,
+ const unsigned char *bytes, int len);
+int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
+ int nid, int type,
+ const unsigned char *bytes, int len);
+int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
+ const char *attrname, int type,
+ const unsigned char *bytes, int len);
+
+int X509_verify_cert(X509_STORE_CTX *ctx);
+
+/* lookup a cert from a X509 STACK */
+X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name,
+ ASN1_INTEGER *serial);
+X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name);
+
+DECLARE_ASN1_FUNCTIONS(PBEPARAM)
+DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
+DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)
+
+X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen);
+X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
+ unsigned char *salt, int saltlen);
+
+/* PKCS#8 utilities */
+
+DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
+
+EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
+PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
+PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
+PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
+
+int X509_check_trust(X509 *x, int id, int flags);
+int X509_TRUST_get_count(void);
+X509_TRUST * X509_TRUST_get0(int idx);
+int X509_TRUST_get_by_id(int id);
+int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
+ char *name, int arg1, void *arg2);
+void X509_TRUST_cleanup(void);
+int X509_TRUST_get_flags(X509_TRUST *xp);
+char *X509_TRUST_get0_name(X509_TRUST *xp);
+int X509_TRUST_get_trust(X509_TRUST *xp);
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_X509_strings(void);
+
+/* Error codes for the X509 functions. */
+
+/* Function codes. */
+#define X509_F_ADD_CERT_DIR 100
+#define X509_F_BY_FILE_CTRL 101
+#define X509_F_CHECK_POLICY 145
+#define X509_F_DIR_CTRL 102
+#define X509_F_GET_CERT_BY_SUBJECT 103
+#define X509_F_NETSCAPE_SPKI_B64_DECODE 129
+#define X509_F_NETSCAPE_SPKI_B64_ENCODE 130
+#define X509_F_X509AT_ADD1_ATTR 135
+#define X509_F_X509V3_ADD_EXT 104
+#define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136
+#define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137
+#define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140
+#define X509_F_X509_ATTRIBUTE_GET0_DATA 139
+#define X509_F_X509_ATTRIBUTE_SET1_DATA 138
+#define X509_F_X509_CHECK_PRIVATE_KEY 128
+#define X509_F_X509_CRL_PRINT_FP 147
+#define X509_F_X509_EXTENSION_CREATE_BY_NID 108
+#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109
+#define X509_F_X509_GET_PUBKEY_PARAMETERS 110
+#define X509_F_X509_LOAD_CERT_CRL_FILE 132
+#define X509_F_X509_LOAD_CERT_FILE 111
+#define X509_F_X509_LOAD_CRL_FILE 112
+#define X509_F_X509_NAME_ADD_ENTRY 113
+#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114
+#define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131
+#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115
+#define X509_F_X509_NAME_ONELINE 116
+#define X509_F_X509_NAME_PRINT 117
+#define X509_F_X509_PRINT_EX_FP 118
+#define X509_F_X509_PUBKEY_GET 119
+#define X509_F_X509_PUBKEY_SET 120
+#define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144
+#define X509_F_X509_REQ_PRINT_EX 121
+#define X509_F_X509_REQ_PRINT_FP 122
+#define X509_F_X509_REQ_TO_X509 123
+#define X509_F_X509_STORE_ADD_CERT 124
+#define X509_F_X509_STORE_ADD_CRL 125
+#define X509_F_X509_STORE_CTX_GET1_ISSUER 146
+#define X509_F_X509_STORE_CTX_INIT 143
+#define X509_F_X509_STORE_CTX_NEW 142
+#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134
+#define X509_F_X509_TO_X509_REQ 126
+#define X509_F_X509_TRUST_ADD 133
+#define X509_F_X509_TRUST_SET 141
+#define X509_F_X509_VERIFY_CERT 127
+
+/* Reason codes. */
+#define X509_R_BAD_X509_FILETYPE 100
+#define X509_R_BASE64_DECODE_ERROR 118
+#define X509_R_CANT_CHECK_DH_KEY 114
+#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101
+#define X509_R_ERR_ASN1_LIB 102
+#define X509_R_INVALID_DIRECTORY 113
+#define X509_R_INVALID_FIELD_NAME 119
+#define X509_R_INVALID_TRUST 123
+#define X509_R_KEY_TYPE_MISMATCH 115
+#define X509_R_KEY_VALUES_MISMATCH 116
+#define X509_R_LOADING_CERT_DIR 103
+#define X509_R_LOADING_DEFAULTS 104
+#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105
+#define X509_R_SHOULD_RETRY 106
+#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107
+#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108
+#define X509_R_UNKNOWN_KEY_TYPE 117
+#define X509_R_UNKNOWN_NID 109
+#define X509_R_UNKNOWN_PURPOSE_ID 121
+#define X509_R_UNKNOWN_TRUST_ID 120
+#define X509_R_UNSUPPORTED_ALGORITHM 111
+#define X509_R_WRONG_LOOKUP_TYPE 112
+#define X509_R_WRONG_TYPE 122
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509_vfy.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509_vfy.h
new file mode 100644
index 000000000..76c76e171
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509_vfy.h
@@ -0,0 +1,531 @@
+/* crypto/x509/x509_vfy.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_X509_H
+#include <openssl/x509.h>
+/* openssl/x509.h ends up #include-ing this file at about the only
+ * appropriate moment. */
+#endif
+
+#ifndef HEADER_X509_VFY_H
+#define HEADER_X509_VFY_H
+
+#include <openssl/opensslconf.h>
+#ifndef OPENSSL_NO_LHASH
+#include <openssl/lhash.h>
+#endif
+#include <openssl/bio.h>
+#include <openssl/crypto.h>
+#include <openssl/symhacks.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Outer object */
+typedef struct x509_hash_dir_st
+ {
+ int num_dirs;
+ char **dirs;
+ int *dirs_type;
+ int num_dirs_alloced;
+ } X509_HASH_DIR_CTX;
+
+typedef struct x509_file_st
+ {
+ int num_paths; /* number of paths to files or directories */
+ int num_alloced;
+ char **paths; /* the list of paths or directories */
+ int *path_type;
+ } X509_CERT_FILE_CTX;
+
+/*******************************/
+/*
+SSL_CTX -> X509_STORE
+ -> X509_LOOKUP
+ ->X509_LOOKUP_METHOD
+ -> X509_LOOKUP
+ ->X509_LOOKUP_METHOD
+
+SSL -> X509_STORE_CTX
+ ->X509_STORE
+
+The X509_STORE holds the tables etc for verification stuff.
+A X509_STORE_CTX is used while validating a single certificate.
+The X509_STORE has X509_LOOKUPs for looking up certs.
+The X509_STORE then calls a function to actually verify the
+certificate chain.
+*/
+
+#define X509_LU_RETRY -1
+#define X509_LU_FAIL 0
+#define X509_LU_X509 1
+#define X509_LU_CRL 2
+#define X509_LU_PKEY 3
+
+typedef struct x509_object_st
+ {
+ /* one of the above types */
+ int type;
+ union {
+ char *ptr;
+ X509 *x509;
+ X509_CRL *crl;
+ EVP_PKEY *pkey;
+ } data;
+ } X509_OBJECT;
+
+typedef struct x509_lookup_st X509_LOOKUP;
+
+DECLARE_STACK_OF(X509_LOOKUP)
+DECLARE_STACK_OF(X509_OBJECT)
+
+/* This is a static that defines the function interface */
+typedef struct x509_lookup_method_st
+ {
+ const char *name;
+ int (*new_item)(X509_LOOKUP *ctx);
+ void (*free)(X509_LOOKUP *ctx);
+ int (*init)(X509_LOOKUP *ctx);
+ int (*shutdown)(X509_LOOKUP *ctx);
+ int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl,
+ char **ret);
+ int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name,
+ X509_OBJECT *ret);
+ int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name,
+ ASN1_INTEGER *serial,X509_OBJECT *ret);
+ int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type,
+ unsigned char *bytes,int len,
+ X509_OBJECT *ret);
+ int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len,
+ X509_OBJECT *ret);
+ } X509_LOOKUP_METHOD;
+
+/* This structure hold all parameters associated with a verify operation
+ * by including an X509_VERIFY_PARAM structure in related structures the
+ * parameters used can be customized
+ */
+
+typedef struct X509_VERIFY_PARAM_st
+ {
+ char *name;
+ time_t check_time; /* Time to use */
+ unsigned long inh_flags; /* Inheritance flags */
+ unsigned long flags; /* Various verify flags */
+ int purpose; /* purpose to check untrusted certificates */
+ int trust; /* trust setting to check */
+ int depth; /* Verify depth */
+ STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */
+ } X509_VERIFY_PARAM;
+
+DECLARE_STACK_OF(X509_VERIFY_PARAM)
+
+/* This is used to hold everything. It is used for all certificate
+ * validation. Once we have a certificate chain, the 'verify'
+ * function is then called to actually check the cert chain. */
+struct x509_store_st
+ {
+ /* The following is a cache of trusted certs */
+ int cache; /* if true, stash any hits */
+ STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */
+
+ /* These are external lookup methods */
+ STACK_OF(X509_LOOKUP) *get_cert_methods;
+
+ X509_VERIFY_PARAM *param;
+
+ /* Callbacks for various operations */
+ int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */
+ int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */
+ int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */
+ int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */
+ int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */
+ int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */
+ int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
+ int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
+ int (*cleanup)(X509_STORE_CTX *ctx);
+
+ CRYPTO_EX_DATA ex_data;
+ int references;
+ } /* X509_STORE */;
+
+int X509_STORE_set_depth(X509_STORE *store, int depth);
+
+#define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func))
+#define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func))
+
+/* This is the functions plus an instance of the local variables. */
+struct x509_lookup_st
+ {
+ int init; /* have we been started */
+ int skip; /* don't use us. */
+ X509_LOOKUP_METHOD *method; /* the functions */
+ char *method_data; /* method data */
+
+ X509_STORE *store_ctx; /* who owns us */
+ } /* X509_LOOKUP */;
+
+/* This is a used when verifying cert chains. Since the
+ * gathering of the cert chain can take some time (and have to be
+ * 'retried', this needs to be kept and passed around. */
+struct x509_store_ctx_st /* X509_STORE_CTX */
+ {
+ X509_STORE *ctx;
+ int current_method; /* used when looking up certs */
+
+ /* The following are set by the caller */
+ X509 *cert; /* The cert to check */
+ STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */
+ STACK_OF(X509_CRL) *crls; /* set of CRLs passed in */
+
+ X509_VERIFY_PARAM *param;
+ void *other_ctx; /* Other info for use with get_issuer() */
+
+ /* Callbacks for various operations */
+ int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */
+ int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */
+ int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */
+ int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */
+ int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */
+ int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */
+ int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
+ int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
+ int (*check_policy)(X509_STORE_CTX *ctx);
+ int (*cleanup)(X509_STORE_CTX *ctx);
+
+ /* The following is built up */
+ int valid; /* if 0, rebuild chain */
+ int last_untrusted; /* index of last untrusted cert */
+ STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */
+ X509_POLICY_TREE *tree; /* Valid policy tree */
+
+ int explicit_policy; /* Require explicit policy value */
+
+ /* When something goes wrong, this is why */
+ int error_depth;
+ int error;
+ X509 *current_cert;
+ X509 *current_issuer; /* cert currently being tested as valid issuer */
+ X509_CRL *current_crl; /* current CRL */
+
+ CRYPTO_EX_DATA ex_data;
+ } /* X509_STORE_CTX */;
+
+void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
+
+#define X509_STORE_CTX_set_app_data(ctx,data) \
+ X509_STORE_CTX_set_ex_data(ctx,0,data)
+#define X509_STORE_CTX_get_app_data(ctx) \
+ X509_STORE_CTX_get_ex_data(ctx,0)
+
+#define X509_L_FILE_LOAD 1
+#define X509_L_ADD_DIR 2
+
+#define X509_LOOKUP_load_file(x,name,type) \
+ X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)
+
+#define X509_LOOKUP_add_dir(x,name,type) \
+ X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)
+
+#define X509_V_OK 0
+/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */
+
+#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2
+#define X509_V_ERR_UNABLE_TO_GET_CRL 3
+#define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4
+#define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5
+#define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6
+#define X509_V_ERR_CERT_SIGNATURE_FAILURE 7
+#define X509_V_ERR_CRL_SIGNATURE_FAILURE 8
+#define X509_V_ERR_CERT_NOT_YET_VALID 9
+#define X509_V_ERR_CERT_HAS_EXPIRED 10
+#define X509_V_ERR_CRL_NOT_YET_VALID 11
+#define X509_V_ERR_CRL_HAS_EXPIRED 12
+#define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13
+#define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14
+#define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15
+#define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16
+#define X509_V_ERR_OUT_OF_MEM 17
+#define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18
+#define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19
+#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20
+#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21
+#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22
+#define X509_V_ERR_CERT_REVOKED 23
+#define X509_V_ERR_INVALID_CA 24
+#define X509_V_ERR_PATH_LENGTH_EXCEEDED 25
+#define X509_V_ERR_INVALID_PURPOSE 26
+#define X509_V_ERR_CERT_UNTRUSTED 27
+#define X509_V_ERR_CERT_REJECTED 28
+/* These are 'informational' when looking for issuer cert */
+#define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29
+#define X509_V_ERR_AKID_SKID_MISMATCH 30
+#define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31
+#define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32
+
+#define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33
+#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34
+#define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35
+#define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36
+#define X509_V_ERR_INVALID_NON_CA 37
+#define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38
+#define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39
+#define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40
+
+#define X509_V_ERR_INVALID_EXTENSION 41
+#define X509_V_ERR_INVALID_POLICY_EXTENSION 42
+#define X509_V_ERR_NO_EXPLICIT_POLICY 43
+
+#define X509_V_ERR_UNNESTED_RESOURCE 44
+
+/* The application is not happy */
+#define X509_V_ERR_APPLICATION_VERIFICATION 50
+
+/* Certificate verify flags */
+
+/* Send issuer+subject checks to verify_cb */
+#define X509_V_FLAG_CB_ISSUER_CHECK 0x1
+/* Use check time instead of current time */
+#define X509_V_FLAG_USE_CHECK_TIME 0x2
+/* Lookup CRLs */
+#define X509_V_FLAG_CRL_CHECK 0x4
+/* Lookup CRLs for whole chain */
+#define X509_V_FLAG_CRL_CHECK_ALL 0x8
+/* Ignore unhandled critical extensions */
+#define X509_V_FLAG_IGNORE_CRITICAL 0x10
+/* Disable workarounds for broken certificates */
+#define X509_V_FLAG_X509_STRICT 0x20
+/* Enable proxy certificate validation */
+#define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40
+/* Enable policy checking */
+#define X509_V_FLAG_POLICY_CHECK 0x80
+/* Policy variable require-explicit-policy */
+#define X509_V_FLAG_EXPLICIT_POLICY 0x100
+/* Policy variable inhibit-any-policy */
+#define X509_V_FLAG_INHIBIT_ANY 0x200
+/* Policy variable inhibit-policy-mapping */
+#define X509_V_FLAG_INHIBIT_MAP 0x400
+/* Notify callback that policy is OK */
+#define X509_V_FLAG_NOTIFY_POLICY 0x800
+
+#define X509_VP_FLAG_DEFAULT 0x1
+#define X509_VP_FLAG_OVERWRITE 0x2
+#define X509_VP_FLAG_RESET_FLAGS 0x4
+#define X509_VP_FLAG_LOCKED 0x8
+#define X509_VP_FLAG_ONCE 0x10
+
+/* Internal use: mask of policy related options */
+#define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \
+ | X509_V_FLAG_EXPLICIT_POLICY \
+ | X509_V_FLAG_INHIBIT_ANY \
+ | X509_V_FLAG_INHIBIT_MAP)
+
+int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
+ X509_NAME *name);
+X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name);
+X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x);
+void X509_OBJECT_up_ref_count(X509_OBJECT *a);
+void X509_OBJECT_free_contents(X509_OBJECT *a);
+X509_STORE *X509_STORE_new(void );
+void X509_STORE_free(X509_STORE *v);
+
+int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);
+int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
+int X509_STORE_set_trust(X509_STORE *ctx, int trust);
+int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);
+
+X509_STORE_CTX *X509_STORE_CTX_new(void);
+
+int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
+
+void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
+int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
+ X509 *x509, STACK_OF(X509) *chain);
+void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
+void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
+
+X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
+
+X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
+X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
+
+int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
+int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
+
+int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name,
+ X509_OBJECT *ret);
+
+int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
+ long argl, char **ret);
+
+#ifndef OPENSSL_NO_STDIO
+int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
+int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
+int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
+#endif
+
+
+X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
+void X509_LOOKUP_free(X509_LOOKUP *ctx);
+int X509_LOOKUP_init(X509_LOOKUP *ctx);
+int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,
+ X509_OBJECT *ret);
+int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,
+ ASN1_INTEGER *serial, X509_OBJECT *ret);
+int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,
+ unsigned char *bytes, int len, X509_OBJECT *ret);
+int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str,
+ int len, X509_OBJECT *ret);
+int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
+
+#ifndef OPENSSL_NO_STDIO
+int X509_STORE_load_locations (X509_STORE *ctx,
+ const char *file, const char *dir);
+int X509_STORE_set_default_paths(X509_STORE *ctx);
+#endif
+
+int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data);
+void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx);
+int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
+void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
+int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
+X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
+STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
+STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
+void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x);
+void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk);
+void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk);
+int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
+int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
+int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
+ int purpose, int trust);
+void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);
+void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
+ time_t t);
+void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
+ int (*verify_cb)(int, X509_STORE_CTX *));
+
+X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);
+int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);
+
+X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
+void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
+int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
+
+/* X509_VERIFY_PARAM functions */
+
+X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);
+void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);
+int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,
+ const X509_VERIFY_PARAM *from);
+int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,
+ const X509_VERIFY_PARAM *from);
+int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);
+int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags);
+int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,
+ unsigned long flags);
+unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);
+int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);
+int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);
+void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);
+void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);
+int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,
+ ASN1_OBJECT *policy);
+int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,
+ STACK_OF(ASN1_OBJECT) *policies);
+int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);
+
+int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);
+const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);
+void X509_VERIFY_PARAM_table_cleanup(void);
+
+int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
+ STACK_OF(X509) *certs,
+ STACK_OF(ASN1_OBJECT) *policy_oids,
+ unsigned int flags);
+
+void X509_policy_tree_free(X509_POLICY_TREE *tree);
+
+int X509_policy_tree_level_count(const X509_POLICY_TREE *tree);
+X509_POLICY_LEVEL *
+ X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i);
+
+STACK_OF(X509_POLICY_NODE) *
+ X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree);
+
+STACK_OF(X509_POLICY_NODE) *
+ X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree);
+
+int X509_policy_level_node_count(X509_POLICY_LEVEL *level);
+
+X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i);
+
+const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);
+
+STACK_OF(POLICYQUALINFO) *
+ X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node);
+const X509_POLICY_NODE *
+ X509_policy_node_get0_parent(const X509_POLICY_NODE *node);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509v3.h b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509v3.h
new file mode 100644
index 000000000..9ef83da75
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/openssl-0.9.8k/src/include/openssl/x509v3.h
@@ -0,0 +1,922 @@
+/* x509v3.h */
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
+ * project 1999.
+ */
+/* ====================================================================
+ * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+#ifndef HEADER_X509V3_H
+#define HEADER_X509V3_H
+
+#include <openssl/bio.h>
+#include <openssl/x509.h>
+#include <openssl/conf.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Forward reference */
+struct v3_ext_method;
+struct v3_ext_ctx;
+
+/* Useful typedefs */
+
+typedef void * (*X509V3_EXT_NEW)(void);
+typedef void (*X509V3_EXT_FREE)(void *);
+typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long);
+typedef int (*X509V3_EXT_I2D)(void *, unsigned char **);
+typedef STACK_OF(CONF_VALUE) * (*X509V3_EXT_I2V)(struct v3_ext_method *method, void *ext, STACK_OF(CONF_VALUE) *extlist);
+typedef void * (*X509V3_EXT_V2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) *values);
+typedef char * (*X509V3_EXT_I2S)(struct v3_ext_method *method, void *ext);
+typedef void * (*X509V3_EXT_S2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str);
+typedef int (*X509V3_EXT_I2R)(struct v3_ext_method *method, void *ext, BIO *out, int indent);
+typedef void * (*X509V3_EXT_R2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str);
+
+/* V3 extension structure */
+
+struct v3_ext_method {
+int ext_nid;
+int ext_flags;
+/* If this is set the following four fields are ignored */
+ASN1_ITEM_EXP *it;
+/* Old style ASN1 calls */
+X509V3_EXT_NEW ext_new;
+X509V3_EXT_FREE ext_free;
+X509V3_EXT_D2I d2i;
+X509V3_EXT_I2D i2d;
+
+/* The following pair is used for string extensions */
+X509V3_EXT_I2S i2s;
+X509V3_EXT_S2I s2i;
+
+/* The following pair is used for multi-valued extensions */
+X509V3_EXT_I2V i2v;
+X509V3_EXT_V2I v2i;
+
+/* The following are used for raw extensions */
+X509V3_EXT_I2R i2r;
+X509V3_EXT_R2I r2i;
+
+void *usr_data; /* Any extension specific data */
+};
+
+typedef struct X509V3_CONF_METHOD_st {
+char * (*get_string)(void *db, char *section, char *value);
+STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section);
+void (*free_string)(void *db, char * string);
+void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section);
+} X509V3_CONF_METHOD;
+
+/* Context specific info */
+struct v3_ext_ctx {
+#define CTX_TEST 0x1
+int flags;
+X509 *issuer_cert;
+X509 *subject_cert;
+X509_REQ *subject_req;
+X509_CRL *crl;
+X509V3_CONF_METHOD *db_meth;
+void *db;
+/* Maybe more here */
+};
+
+typedef struct v3_ext_method X509V3_EXT_METHOD;
+
+DECLARE_STACK_OF(X509V3_EXT_METHOD)
+
+/* ext_flags values */
+#define X509V3_EXT_DYNAMIC 0x1
+#define X509V3_EXT_CTX_DEP 0x2
+#define X509V3_EXT_MULTILINE 0x4
+
+typedef BIT_STRING_BITNAME ENUMERATED_NAMES;
+
+typedef struct BASIC_CONSTRAINTS_st {
+int ca;
+ASN1_INTEGER *pathlen;
+} BASIC_CONSTRAINTS;
+
+
+typedef struct PKEY_USAGE_PERIOD_st {
+ASN1_GENERALIZEDTIME *notBefore;
+ASN1_GENERALIZEDTIME *notAfter;
+} PKEY_USAGE_PERIOD;
+
+typedef struct otherName_st {
+ASN1_OBJECT *type_id;
+ASN1_TYPE *value;
+} OTHERNAME;
+
+typedef struct EDIPartyName_st {
+ ASN1_STRING *nameAssigner;
+ ASN1_STRING *partyName;
+} EDIPARTYNAME;
+
+typedef struct GENERAL_NAME_st {
+
+#define GEN_OTHERNAME 0
+#define GEN_EMAIL 1
+#define GEN_DNS 2
+#define GEN_X400 3
+#define GEN_DIRNAME 4
+#define GEN_EDIPARTY 5
+#define GEN_URI 6
+#define GEN_IPADD 7
+#define GEN_RID 8
+
+int type;
+union {
+ char *ptr;
+ OTHERNAME *otherName; /* otherName */
+ ASN1_IA5STRING *rfc822Name;
+ ASN1_IA5STRING *dNSName;
+ ASN1_TYPE *x400Address;
+ X509_NAME *directoryName;
+ EDIPARTYNAME *ediPartyName;
+ ASN1_IA5STRING *uniformResourceIdentifier;
+ ASN1_OCTET_STRING *iPAddress;
+ ASN1_OBJECT *registeredID;
+
+ /* Old names */
+ ASN1_OCTET_STRING *ip; /* iPAddress */
+ X509_NAME *dirn; /* dirn */
+ ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */
+ ASN1_OBJECT *rid; /* registeredID */
+ ASN1_TYPE *other; /* x400Address */
+} d;
+} GENERAL_NAME;
+
+typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
+
+typedef struct ACCESS_DESCRIPTION_st {
+ ASN1_OBJECT *method;
+ GENERAL_NAME *location;
+} ACCESS_DESCRIPTION;
+
+typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
+
+typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;
+
+DECLARE_STACK_OF(GENERAL_NAME)
+DECLARE_ASN1_SET_OF(GENERAL_NAME)
+
+DECLARE_STACK_OF(ACCESS_DESCRIPTION)
+DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)
+
+typedef struct DIST_POINT_NAME_st {
+int type;
+union {
+ GENERAL_NAMES *fullname;
+ STACK_OF(X509_NAME_ENTRY) *relativename;
+} name;
+} DIST_POINT_NAME;
+
+typedef struct DIST_POINT_st {
+DIST_POINT_NAME *distpoint;
+ASN1_BIT_STRING *reasons;
+GENERAL_NAMES *CRLissuer;
+} DIST_POINT;
+
+typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;
+
+DECLARE_STACK_OF(DIST_POINT)
+DECLARE_ASN1_SET_OF(DIST_POINT)
+
+typedef struct AUTHORITY_KEYID_st {
+ASN1_OCTET_STRING *keyid;
+GENERAL_NAMES *issuer;
+ASN1_INTEGER *serial;
+} AUTHORITY_KEYID;
+
+/* Strong extranet structures */
+
+typedef struct SXNET_ID_st {
+ ASN1_INTEGER *zone;
+ ASN1_OCTET_STRING *user;
+} SXNETID;
+
+DECLARE_STACK_OF(SXNETID)
+DECLARE_ASN1_SET_OF(SXNETID)
+
+typedef struct SXNET_st {
+ ASN1_INTEGER *version;
+ STACK_OF(SXNETID) *ids;
+} SXNET;
+
+typedef struct NOTICEREF_st {
+ ASN1_STRING *organization;
+ STACK_OF(ASN1_INTEGER) *noticenos;
+} NOTICEREF;
+
+typedef struct USERNOTICE_st {
+ NOTICEREF *noticeref;
+ ASN1_STRING *exptext;
+} USERNOTICE;
+
+typedef struct POLICYQUALINFO_st {
+ ASN1_OBJECT *pqualid;
+ union {
+ ASN1_IA5STRING *cpsuri;
+ USERNOTICE *usernotice;
+ ASN1_TYPE *other;
+ } d;
+} POLICYQUALINFO;
+
+DECLARE_STACK_OF(POLICYQUALINFO)
+DECLARE_ASN1_SET_OF(POLICYQUALINFO)
+
+typedef struct POLICYINFO_st {
+ ASN1_OBJECT *policyid;
+ STACK_OF(POLICYQUALINFO) *qualifiers;
+} POLICYINFO;
+
+typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;
+
+DECLARE_STACK_OF(POLICYINFO)
+DECLARE_ASN1_SET_OF(POLICYINFO)
+
+typedef struct POLICY_MAPPING_st {
+ ASN1_OBJECT *issuerDomainPolicy;
+ ASN1_OBJECT *subjectDomainPolicy;
+} POLICY_MAPPING;
+
+DECLARE_STACK_OF(POLICY_MAPPING)
+
+typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;
+
+typedef struct GENERAL_SUBTREE_st {
+ GENERAL_NAME *base;
+ ASN1_INTEGER *minimum;
+ ASN1_INTEGER *maximum;
+} GENERAL_SUBTREE;
+
+DECLARE_STACK_OF(GENERAL_SUBTREE)
+
+typedef struct NAME_CONSTRAINTS_st {
+ STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;
+ STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;
+} NAME_CONSTRAINTS;
+
+typedef struct POLICY_CONSTRAINTS_st {
+ ASN1_INTEGER *requireExplicitPolicy;
+ ASN1_INTEGER *inhibitPolicyMapping;
+} POLICY_CONSTRAINTS;
+
+/* Proxy certificate structures, see RFC 3820 */
+typedef struct PROXY_POLICY_st
+ {
+ ASN1_OBJECT *policyLanguage;
+ ASN1_OCTET_STRING *policy;
+ } PROXY_POLICY;
+
+typedef struct PROXY_CERT_INFO_EXTENSION_st
+ {
+ ASN1_INTEGER *pcPathLengthConstraint;
+ PROXY_POLICY *proxyPolicy;
+ } PROXY_CERT_INFO_EXTENSION;
+
+DECLARE_ASN1_FUNCTIONS(PROXY_POLICY)
+DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)
+
+
+#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \
+",name:", val->name, ",value:", val->value);
+
+#define X509V3_set_ctx_test(ctx) \
+ X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)
+#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;
+
+#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \
+ 0,0,0,0, \
+ 0,0, \
+ (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \
+ (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \
+ NULL, NULL, \
+ table}
+
+#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \
+ 0,0,0,0, \
+ (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
+ (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \
+ 0,0,0,0, \
+ NULL}
+
+#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+
+
+/* X509_PURPOSE stuff */
+
+#define EXFLAG_BCONS 0x1
+#define EXFLAG_KUSAGE 0x2
+#define EXFLAG_XKUSAGE 0x4
+#define EXFLAG_NSCERT 0x8
+
+#define EXFLAG_CA 0x10
+/* Really self issued not necessarily self signed */
+#define EXFLAG_SI 0x20
+#define EXFLAG_SS 0x20
+#define EXFLAG_V1 0x40
+#define EXFLAG_INVALID 0x80
+#define EXFLAG_SET 0x100
+#define EXFLAG_CRITICAL 0x200
+#define EXFLAG_PROXY 0x400
+
+#define EXFLAG_INVALID_POLICY 0x800
+
+#define KU_DIGITAL_SIGNATURE 0x0080
+#define KU_NON_REPUDIATION 0x0040
+#define KU_KEY_ENCIPHERMENT 0x0020
+#define KU_DATA_ENCIPHERMENT 0x0010
+#define KU_KEY_AGREEMENT 0x0008
+#define KU_KEY_CERT_SIGN 0x0004
+#define KU_CRL_SIGN 0x0002
+#define KU_ENCIPHER_ONLY 0x0001
+#define KU_DECIPHER_ONLY 0x8000
+
+#define NS_SSL_CLIENT 0x80
+#define NS_SSL_SERVER 0x40
+#define NS_SMIME 0x20
+#define NS_OBJSIGN 0x10
+#define NS_SSL_CA 0x04
+#define NS_SMIME_CA 0x02
+#define NS_OBJSIGN_CA 0x01
+#define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)
+
+#define XKU_SSL_SERVER 0x1
+#define XKU_SSL_CLIENT 0x2
+#define XKU_SMIME 0x4
+#define XKU_CODE_SIGN 0x8
+#define XKU_SGC 0x10
+#define XKU_OCSP_SIGN 0x20
+#define XKU_TIMESTAMP 0x40
+#define XKU_DVCS 0x80
+
+#define X509_PURPOSE_DYNAMIC 0x1
+#define X509_PURPOSE_DYNAMIC_NAME 0x2
+
+typedef struct x509_purpose_st {
+ int purpose;
+ int trust; /* Default trust ID */
+ int flags;
+ int (*check_purpose)(const struct x509_purpose_st *,
+ const X509 *, int);
+ char *name;
+ char *sname;
+ void *usr_data;
+} X509_PURPOSE;
+
+#define X509_PURPOSE_SSL_CLIENT 1
+#define X509_PURPOSE_SSL_SERVER 2
+#define X509_PURPOSE_NS_SSL_SERVER 3
+#define X509_PURPOSE_SMIME_SIGN 4
+#define X509_PURPOSE_SMIME_ENCRYPT 5
+#define X509_PURPOSE_CRL_SIGN 6
+#define X509_PURPOSE_ANY 7
+#define X509_PURPOSE_OCSP_HELPER 8
+
+#define X509_PURPOSE_MIN 1
+#define X509_PURPOSE_MAX 8
+
+/* Flags for X509V3_EXT_print() */
+
+#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16)
+/* Return error for unknown extensions */
+#define X509V3_EXT_DEFAULT 0
+/* Print error for unknown extensions */
+#define X509V3_EXT_ERROR_UNKNOWN (1L << 16)
+/* ASN1 parse unknown extensions */
+#define X509V3_EXT_PARSE_UNKNOWN (2L << 16)
+/* BIO_dump unknown extensions */
+#define X509V3_EXT_DUMP_UNKNOWN (3L << 16)
+
+/* Flags for X509V3_add1_i2d */
+
+#define X509V3_ADD_OP_MASK 0xfL
+#define X509V3_ADD_DEFAULT 0L
+#define X509V3_ADD_APPEND 1L
+#define X509V3_ADD_REPLACE 2L
+#define X509V3_ADD_REPLACE_EXISTING 3L
+#define X509V3_ADD_KEEP_EXISTING 4L
+#define X509V3_ADD_DELETE 5L
+#define X509V3_ADD_SILENT 0x10
+
+DECLARE_STACK_OF(X509_PURPOSE)
+
+DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)
+
+DECLARE_ASN1_FUNCTIONS(SXNET)
+DECLARE_ASN1_FUNCTIONS(SXNETID)
+
+int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen);
+int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen);
+int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen);
+
+ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone);
+ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);
+ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);
+
+DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)
+
+DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
+
+DECLARE_ASN1_FUNCTIONS(GENERAL_NAME)
+
+
+ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
+ X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
+STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
+ ASN1_BIT_STRING *bits,
+ STACK_OF(CONF_VALUE) *extlist);
+
+STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret);
+int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);
+
+DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)
+
+STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
+ GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist);
+GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method,
+ X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
+
+DECLARE_ASN1_FUNCTIONS(OTHERNAME)
+DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)
+
+char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5);
+ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
+
+DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
+int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a);
+
+DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)
+DECLARE_ASN1_FUNCTIONS(POLICYINFO)
+DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)
+DECLARE_ASN1_FUNCTIONS(USERNOTICE)
+DECLARE_ASN1_FUNCTIONS(NOTICEREF)
+
+DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)
+DECLARE_ASN1_FUNCTIONS(DIST_POINT)
+DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)
+
+DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
+DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
+
+DECLARE_ASN1_ITEM(POLICY_MAPPING)
+DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)
+DECLARE_ASN1_ITEM(POLICY_MAPPINGS)
+
+DECLARE_ASN1_ITEM(GENERAL_SUBTREE)
+DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)
+
+DECLARE_ASN1_ITEM(NAME_CONSTRAINTS)
+DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)
+
+DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)
+DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)
+
+#ifdef HEADER_CONF_H
+GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
+ CONF_VALUE *cnf);
+GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, X509V3_EXT_METHOD *method,
+ X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc);
+void X509V3_conf_free(CONF_VALUE *val);
+
+X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value);
+X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value);
+int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk);
+int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert);
+int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
+int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
+
+X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value);
+X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value);
+int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert);
+int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
+int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
+
+int X509V3_add_value_bool_nf(char *name, int asn1_bool,
+ STACK_OF(CONF_VALUE) **extlist);
+int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);
+int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);
+void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
+void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash);
+#endif
+
+char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);
+STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section);
+void X509V3_string_free(X509V3_CTX *ctx, char *str);
+void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);
+void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,
+ X509_REQ *req, X509_CRL *crl, int flags);
+
+int X509V3_add_value(const char *name, const char *value,
+ STACK_OF(CONF_VALUE) **extlist);
+int X509V3_add_value_uchar(const char *name, const unsigned char *value,
+ STACK_OF(CONF_VALUE) **extlist);
+int X509V3_add_value_bool(const char *name, int asn1_bool,
+ STACK_OF(CONF_VALUE) **extlist);
+int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint,
+ STACK_OF(CONF_VALUE) **extlist);
+char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint);
+ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value);
+char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);
+char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);
+int X509V3_EXT_add(X509V3_EXT_METHOD *ext);
+int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);
+int X509V3_EXT_add_alias(int nid_to, int nid_from);
+void X509V3_EXT_cleanup(void);
+
+X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);
+X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
+int X509V3_add_standard_extensions(void);
+STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
+void *X509V3_EXT_d2i(X509_EXTENSION *ext);
+void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx);
+
+
+X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
+int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags);
+
+char *hex_to_string(unsigned char *buffer, long len);
+unsigned char *string_to_hex(char *str, long *len);
+int name_cmp(const char *name, const char *cmp);
+
+void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
+ int ml);
+int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent);
+int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
+
+int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent);
+
+int X509_check_ca(X509 *x);
+int X509_check_purpose(X509 *x, int id, int ca);
+int X509_supported_extension(X509_EXTENSION *ex);
+int X509_PURPOSE_set(int *p, int purpose);
+int X509_check_issued(X509 *issuer, X509 *subject);
+int X509_PURPOSE_get_count(void);
+X509_PURPOSE * X509_PURPOSE_get0(int idx);
+int X509_PURPOSE_get_by_sname(char *sname);
+int X509_PURPOSE_get_by_id(int id);
+int X509_PURPOSE_add(int id, int trust, int flags,
+ int (*ck)(const X509_PURPOSE *, const X509 *, int),
+ char *name, char *sname, void *arg);
+char *X509_PURPOSE_get0_name(X509_PURPOSE *xp);
+char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp);
+int X509_PURPOSE_get_trust(X509_PURPOSE *xp);
+void X509_PURPOSE_cleanup(void);
+int X509_PURPOSE_get_id(X509_PURPOSE *);
+
+STACK *X509_get1_email(X509 *x);
+STACK *X509_REQ_get1_email(X509_REQ *x);
+void X509_email_free(STACK *sk);
+STACK *X509_get1_ocsp(X509 *x);
+
+ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);
+ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);
+int a2i_ipadd(unsigned char *ipout, const char *ipasc);
+int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk,
+ unsigned long chtype);
+
+void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);
+
+#ifndef OPENSSL_NO_RFC3779
+
+typedef struct ASRange_st {
+ ASN1_INTEGER *min, *max;
+} ASRange;
+
+#define ASIdOrRange_id 0
+#define ASIdOrRange_range 1
+
+typedef struct ASIdOrRange_st {
+ int type;
+ union {
+ ASN1_INTEGER *id;
+ ASRange *range;
+ } u;
+} ASIdOrRange;
+
+typedef STACK_OF(ASIdOrRange) ASIdOrRanges;
+DECLARE_STACK_OF(ASIdOrRange)
+
+#define ASIdentifierChoice_inherit 0
+#define ASIdentifierChoice_asIdsOrRanges 1
+
+typedef struct ASIdentifierChoice_st {
+ int type;
+ union {
+ ASN1_NULL *inherit;
+ ASIdOrRanges *asIdsOrRanges;
+ } u;
+} ASIdentifierChoice;
+
+typedef struct ASIdentifiers_st {
+ ASIdentifierChoice *asnum, *rdi;
+} ASIdentifiers;
+
+DECLARE_ASN1_FUNCTIONS(ASRange)
+DECLARE_ASN1_FUNCTIONS(ASIdOrRange)
+DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)
+DECLARE_ASN1_FUNCTIONS(ASIdentifiers)
+
+
+typedef struct IPAddressRange_st {
+ ASN1_BIT_STRING *min, *max;
+} IPAddressRange;
+
+#define IPAddressOrRange_addressPrefix 0
+#define IPAddressOrRange_addressRange 1
+
+typedef struct IPAddressOrRange_st {
+ int type;
+ union {
+ ASN1_BIT_STRING *addressPrefix;
+ IPAddressRange *addressRange;
+ } u;
+} IPAddressOrRange;
+
+typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;
+DECLARE_STACK_OF(IPAddressOrRange)
+
+#define IPAddressChoice_inherit 0
+#define IPAddressChoice_addressesOrRanges 1
+
+typedef struct IPAddressChoice_st {
+ int type;
+ union {
+ ASN1_NULL *inherit;
+ IPAddressOrRanges *addressesOrRanges;
+ } u;
+} IPAddressChoice;
+
+typedef struct IPAddressFamily_st {
+ ASN1_OCTET_STRING *addressFamily;
+ IPAddressChoice *ipAddressChoice;
+} IPAddressFamily;
+
+typedef STACK_OF(IPAddressFamily) IPAddrBlocks;
+DECLARE_STACK_OF(IPAddressFamily)
+
+DECLARE_ASN1_FUNCTIONS(IPAddressRange)
+DECLARE_ASN1_FUNCTIONS(IPAddressOrRange)
+DECLARE_ASN1_FUNCTIONS(IPAddressChoice)
+DECLARE_ASN1_FUNCTIONS(IPAddressFamily)
+
+/*
+ * API tag for elements of the ASIdentifer SEQUENCE.
+ */
+#define V3_ASID_ASNUM 0
+#define V3_ASID_RDI 1
+
+/*
+ * AFI values, assigned by IANA. It'd be nice to make the AFI
+ * handling code totally generic, but there are too many little things
+ * that would need to be defined for other address families for it to
+ * be worth the trouble.
+ */
+#define IANA_AFI_IPV4 1
+#define IANA_AFI_IPV6 2
+
+/*
+ * Utilities to construct and extract values from RFC3779 extensions,
+ * since some of the encodings (particularly for IP address prefixes
+ * and ranges) are a bit tedious to work with directly.
+ */
+int v3_asid_add_inherit(ASIdentifiers *asid, int which);
+int v3_asid_add_id_or_range(ASIdentifiers *asid, int which,
+ ASN1_INTEGER *min, ASN1_INTEGER *max);
+int v3_addr_add_inherit(IPAddrBlocks *addr,
+ const unsigned afi, const unsigned *safi);
+int v3_addr_add_prefix(IPAddrBlocks *addr,
+ const unsigned afi, const unsigned *safi,
+ unsigned char *a, const int prefixlen);
+int v3_addr_add_range(IPAddrBlocks *addr,
+ const unsigned afi, const unsigned *safi,
+ unsigned char *min, unsigned char *max);
+unsigned v3_addr_get_afi(const IPAddressFamily *f);
+int v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,
+ unsigned char *min, unsigned char *max,
+ const int length);
+
+/*
+ * Canonical forms.
+ */
+int v3_asid_is_canonical(ASIdentifiers *asid);
+int v3_addr_is_canonical(IPAddrBlocks *addr);
+int v3_asid_canonize(ASIdentifiers *asid);
+int v3_addr_canonize(IPAddrBlocks *addr);
+
+/*
+ * Tests for inheritance and containment.
+ */
+int v3_asid_inherits(ASIdentifiers *asid);
+int v3_addr_inherits(IPAddrBlocks *addr);
+int v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);
+int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);
+
+/*
+ * Check whether RFC 3779 extensions nest properly in chains.
+ */
+int v3_asid_validate_path(X509_STORE_CTX *);
+int v3_addr_validate_path(X509_STORE_CTX *);
+int v3_asid_validate_resource_set(STACK_OF(X509) *chain,
+ ASIdentifiers *ext,
+ int allow_inheritance);
+int v3_addr_validate_resource_set(STACK_OF(X509) *chain,
+ IPAddrBlocks *ext,
+ int allow_inheritance);
+
+#endif /* OPENSSL_NO_RFC3779 */
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+void ERR_load_X509V3_strings(void);
+
+/* Error codes for the X509V3 functions. */
+
+/* Function codes. */
+#define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 156
+#define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 157
+#define X509V3_F_COPY_EMAIL 122
+#define X509V3_F_COPY_ISSUER 123
+#define X509V3_F_DO_DIRNAME 144
+#define X509V3_F_DO_EXT_CONF 124
+#define X509V3_F_DO_EXT_I2D 135
+#define X509V3_F_DO_EXT_NCONF 151
+#define X509V3_F_DO_I2V_NAME_CONSTRAINTS 148
+#define X509V3_F_HEX_TO_STRING 111
+#define X509V3_F_I2S_ASN1_ENUMERATED 121
+#define X509V3_F_I2S_ASN1_IA5STRING 149
+#define X509V3_F_I2S_ASN1_INTEGER 120
+#define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138
+#define X509V3_F_NOTICE_SECTION 132
+#define X509V3_F_NREF_NOS 133
+#define X509V3_F_POLICY_SECTION 131
+#define X509V3_F_PROCESS_PCI_VALUE 150
+#define X509V3_F_R2I_CERTPOL 130
+#define X509V3_F_R2I_PCI 155
+#define X509V3_F_S2I_ASN1_IA5STRING 100
+#define X509V3_F_S2I_ASN1_INTEGER 108
+#define X509V3_F_S2I_ASN1_OCTET_STRING 112
+#define X509V3_F_S2I_ASN1_SKEY_ID 114
+#define X509V3_F_S2I_SKEY_ID 115
+#define X509V3_F_STRING_TO_HEX 113
+#define X509V3_F_SXNET_ADD_ID_ASC 125
+#define X509V3_F_SXNET_ADD_ID_INTEGER 126
+#define X509V3_F_SXNET_ADD_ID_ULONG 127
+#define X509V3_F_SXNET_GET_ID_ASC 128
+#define X509V3_F_SXNET_GET_ID_ULONG 129
+#define X509V3_F_V2I_ASIDENTIFIERS 158
+#define X509V3_F_V2I_ASN1_BIT_STRING 101
+#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139
+#define X509V3_F_V2I_AUTHORITY_KEYID 119
+#define X509V3_F_V2I_BASIC_CONSTRAINTS 102
+#define X509V3_F_V2I_CRLD 134
+#define X509V3_F_V2I_EXTENDED_KEY_USAGE 103
+#define X509V3_F_V2I_GENERAL_NAMES 118
+#define X509V3_F_V2I_GENERAL_NAME_EX 117
+#define X509V3_F_V2I_IPADDRBLOCKS 159
+#define X509V3_F_V2I_ISSUER_ALT 153
+#define X509V3_F_V2I_NAME_CONSTRAINTS 147
+#define X509V3_F_V2I_POLICY_CONSTRAINTS 146
+#define X509V3_F_V2I_POLICY_MAPPINGS 145
+#define X509V3_F_V2I_SUBJECT_ALT 154
+#define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL 160
+#define X509V3_F_V3_GENERIC_EXTENSION 116
+#define X509V3_F_X509V3_ADD1_I2D 140
+#define X509V3_F_X509V3_ADD_VALUE 105
+#define X509V3_F_X509V3_EXT_ADD 104
+#define X509V3_F_X509V3_EXT_ADD_ALIAS 106
+#define X509V3_F_X509V3_EXT_CONF 107
+#define X509V3_F_X509V3_EXT_I2D 136
+#define X509V3_F_X509V3_EXT_NCONF 152
+#define X509V3_F_X509V3_GET_SECTION 142
+#define X509V3_F_X509V3_GET_STRING 143
+#define X509V3_F_X509V3_GET_VALUE_BOOL 110
+#define X509V3_F_X509V3_PARSE_LIST 109
+#define X509V3_F_X509_PURPOSE_ADD 137
+#define X509V3_F_X509_PURPOSE_SET 141
+
+/* Reason codes. */
+#define X509V3_R_BAD_IP_ADDRESS 118
+#define X509V3_R_BAD_OBJECT 119
+#define X509V3_R_BN_DEC2BN_ERROR 100
+#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101
+#define X509V3_R_DIRNAME_ERROR 149
+#define X509V3_R_DUPLICATE_ZONE_ID 133
+#define X509V3_R_ERROR_CONVERTING_ZONE 131
+#define X509V3_R_ERROR_CREATING_EXTENSION 144
+#define X509V3_R_ERROR_IN_EXTENSION 128
+#define X509V3_R_EXPECTED_A_SECTION_NAME 137
+#define X509V3_R_EXTENSION_EXISTS 145
+#define X509V3_R_EXTENSION_NAME_ERROR 115
+#define X509V3_R_EXTENSION_NOT_FOUND 102
+#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103
+#define X509V3_R_EXTENSION_VALUE_ERROR 116
+#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151
+#define X509V3_R_ILLEGAL_HEX_DIGIT 113
+#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152
+#define X509V3_R_INVALID_ASNUMBER 160
+#define X509V3_R_INVALID_ASRANGE 161
+#define X509V3_R_INVALID_BOOLEAN_STRING 104
+#define X509V3_R_INVALID_EXTENSION_STRING 105
+#define X509V3_R_INVALID_INHERITANCE 162
+#define X509V3_R_INVALID_IPADDRESS 163
+#define X509V3_R_INVALID_NAME 106
+#define X509V3_R_INVALID_NULL_ARGUMENT 107
+#define X509V3_R_INVALID_NULL_NAME 108
+#define X509V3_R_INVALID_NULL_VALUE 109
+#define X509V3_R_INVALID_NUMBER 140
+#define X509V3_R_INVALID_NUMBERS 141
+#define X509V3_R_INVALID_OBJECT_IDENTIFIER 110
+#define X509V3_R_INVALID_OPTION 138
+#define X509V3_R_INVALID_POLICY_IDENTIFIER 134
+#define X509V3_R_INVALID_PROXY_POLICY_SETTING 153
+#define X509V3_R_INVALID_PURPOSE 146
+#define X509V3_R_INVALID_SAFI 164
+#define X509V3_R_INVALID_SECTION 135
+#define X509V3_R_INVALID_SYNTAX 143
+#define X509V3_R_ISSUER_DECODE_ERROR 126
+#define X509V3_R_MISSING_VALUE 124
+#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142
+#define X509V3_R_NO_CONFIG_DATABASE 136
+#define X509V3_R_NO_ISSUER_CERTIFICATE 121
+#define X509V3_R_NO_ISSUER_DETAILS 127
+#define X509V3_R_NO_POLICY_IDENTIFIER 139
+#define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154
+#define X509V3_R_NO_PUBLIC_KEY 114
+#define X509V3_R_NO_SUBJECT_DETAILS 125
+#define X509V3_R_ODD_NUMBER_OF_DIGITS 112
+#define X509V3_R_OPERATION_NOT_DEFINED 148
+#define X509V3_R_OTHERNAME_ERROR 147
+#define X509V3_R_POLICY_LANGUAGE_ALREADTY_DEFINED 155
+#define X509V3_R_POLICY_PATH_LENGTH 156
+#define X509V3_R_POLICY_PATH_LENGTH_ALREADTY_DEFINED 157
+#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 158
+#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159
+#define X509V3_R_SECTION_NOT_FOUND 150
+#define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122
+#define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123
+#define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111
+#define X509V3_R_UNKNOWN_EXTENSION 129
+#define X509V3_R_UNKNOWN_EXTENSION_NAME 130
+#define X509V3_R_UNKNOWN_OPTION 120
+#define X509V3_R_UNSUPPORTED_OPTION 117
+#define X509V3_R_USER_TOO_LONG 132
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp
new file mode 100644
index 000000000..f1dd2e439
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp
@@ -0,0 +1,1253 @@
+#include "lib7z_facade.h"
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+
+#include "Common/CommandLineParser.h"
+#include "Common/IntToString.h"
+#include "Common/MyException.h"
+#include "Common/StdOutStream.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/Defs.h"
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+
+#include "7zip/ICoder.h"
+#include "7zip/IPassword.h"
+
+#include "7zip/UI/Common/ArchiveCommandLine.h"
+#include "7zip/UI/Common/ExitCode.h"
+#include "7zip/UI/Common/Extract.h"
+#include "7zip/UI/Common/Update.h"
+#include "7zip/UI/Common/ArchiveExtractCallback.h"
+
+#include "Windows/Defs.h"
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+
+#include "7zip/UI/Common/LoadCodecs.h"
+#include "7zip/UI/Common/PropIDUtils.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include <common/errors.h>
+#include <common/fileutils.h>
+
+#include <QCoreApplication>
+#include <QDebug>
+#include <QDir>
+#include <QFileInfo>
+#include <QIODevice>
+#include <QPointer>
+#include <QString>
+#include <QStringList>
+#include <QTemporaryFile>
+
+#ifdef Q_WS_WIN
+#include <time.h>
+#define FILE_ATTRIBUTE_UNIX_EXTENSION 0x8000 /* trick for Unix */
+#define S_IFMT 00170000
+#define S_IFLNK 0120000
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+
+typedef BOOL (WINAPI *CREATEHARDLINK)(LPCSTR dst, LPCSTR str, LPSECURITY_ATTRIBUTES sa);
+
+bool CreateHardLinkWrapper( const QString& dest, const QString& file )
+{
+ static HMODULE module = 0;
+ static CREATEHARDLINK proc = 0;
+
+ if( module == 0 )
+ module = LoadLibrary( L"kernel32.dll" );
+ if( module == 0 )
+ return false;
+ if( proc == 0 )
+ proc = (CREATEHARDLINK) GetProcAddress( module, "CreateHardLinkA" );
+ if( proc == 0 )
+ return false;
+ QString target = file;
+ if( !QFileInfo( file ).isAbsolute() )
+ {
+ target = QFileInfo( dest ).dir().absoluteFilePath( file );
+ }
+ const QString link = QDir::toNativeSeparators( dest );
+ const QString existingFile = QDir::toNativeSeparators( target );
+ return proc( link.toLocal8Bit(), existingFile.toLocal8Bit(), 0 );
+}
+
+#else
+#include <sys/stat.h>
+#endif
+
+#include <iostream>
+#include <memory>
+
+#include <cassert>
+
+using namespace Lib7z;
+using namespace NWindows;
+
+namespace {
+ /**
+ * RAII class to create a directory (tryCreate()) and delete it on destruction unless released.
+ */
+ struct DirectoryGuard {
+ explicit DirectoryGuard( const QString& path )
+ : m_path( path ),
+ m_created( false ),
+ m_released( false )
+ {
+ static const QRegExp re( QLatin1String( "\\\\|/" ) );
+ static const QLatin1String sep( "/" );
+ m_path.replace( re, sep );
+ }
+ ~DirectoryGuard() {
+ if ( !m_created || m_released )
+ return;
+ QDir dir( m_path );
+ if ( !dir.rmdir( m_path ) )
+ qWarning() << "Could not delete directory " << m_path;
+ }
+
+ /**
+ * Tries to create the directorie structure.
+ * Returns a list of every directory created.
+ */
+ QStringList tryCreate() {
+ if( m_path.isEmpty() )
+ return QStringList();
+
+ const QFileInfo fi( m_path );
+ if ( fi.exists() && fi.isDir() )
+ return QStringList();
+ if ( fi.exists() && !fi.isDir() )
+ throw SevenZipException( QObject::tr("Path exists but is not a folder: %1").arg( m_path ) );
+
+ QStringList created;
+
+ QDir toCreate( m_path );
+ while( !toCreate.exists() )
+ {
+ QString p = toCreate.absolutePath();
+ created.push_front( p );
+ p = p.section( QLatin1Char( '/' ), 0, -2 );
+ toCreate = QDir( p );
+ }
+
+ QDir dir( m_path );
+ m_created = dir.mkpath( m_path );
+ if ( !m_created )
+ throw SevenZipException( QObject::tr("Could not create folder: %1").arg( m_path ) );
+
+ return created;
+ }
+
+ void release() {
+ m_released = true;
+ }
+
+ QString m_path;
+ bool m_created;
+ bool m_released;
+ };
+}
+
+static void throwIfNotOK( HRESULT result, const QString& msg ) {
+ if ( result != S_OK )
+ throw SevenZipException( msg );
+}
+
+static UString QString2UString( const QString& str ) {
+ return str.toStdWString().c_str();
+}
+
+static QString UString2QString( const UString& str ) {
+ return QString::fromStdWString( static_cast<const wchar_t*>( str ) );
+}
+
+static QString generateTempFileName() {
+ QTemporaryFile tmp;
+ if ( !tmp.open() )
+ throw SevenZipException( QObject::tr("Could not create temporary file") );
+ return QDir::toNativeSeparators( tmp.fileName() );
+}
+
+/*
+static QStringList UStringVector2QStringList( const UStringVector& vec ) {
+ QStringList res;
+ for( int i = 0; i < vec.Size(); ++i )
+ res += UString2QString( vec[i] );
+ return res;
+}
+*/
+
+static NCOM::CPropVariant readProperty( IInArchive* archive, int index, int propId ) {
+ NCOM::CPropVariant prop;
+ throwIfNotOK( archive->GetProperty(index, propId, &prop), QObject::tr("Could not retrieve property %1 for item %2").arg( QString::number( propId ), QString::number( index ) ) );
+ return prop;
+}
+static bool IsFileTimeZero( const FILETIME *lpFileTime )
+{
+ return (lpFileTime->dwLowDateTime == 0) && (lpFileTime->dwHighDateTime == 0);
+}
+
+static bool IsDST( const QDateTime& datetime = QDateTime() )
+{
+ const time_t seconds = static_cast< time_t >( datetime.isValid() ? datetime.toTime_t() : QDateTime::currentDateTime().toTime_t() );
+ const tm* const t = localtime( &seconds );
+ return t->tm_isdst;
+}
+
+static QDateTime getDateTimeProperty( IInArchive* archive, int index, int propId, const QDateTime& defaultValue ) {
+ const NCOM::CPropVariant prop = readProperty( archive, index, propId );
+ if (prop.vt != VT_FILETIME)
+ throw SevenZipException( QObject::tr("Property %1 for item %2 not of type VT_FILETIME but %3").arg( QString::number( propId ), QString::number( index ), QString::number( prop.vt ) ) );
+ if ( IsFileTimeZero( &prop.filetime ) )
+ return defaultValue;
+
+ FILETIME localFileTime;
+ if ( !FileTimeToLocalFileTime( &prop.filetime, &localFileTime ) )
+ throw SevenZipException( QObject::tr("Could not convert file time to local time") );
+
+ SYSTEMTIME st;
+ if ( !BOOLToBool(FileTimeToSystemTime(&localFileTime, &st)) )
+ throw SevenZipException( QObject::tr("Could not convert local file time to system time") );
+
+ const QDate date( st.wYear, st.wMonth, st.wDay );
+ const QTime time( st.wHour, st.wMinute, st.wSecond );
+ QDateTime result( date, time );
+
+ // fix daylight saving time
+ const bool dst = IsDST();
+ if( dst != IsDST( result ) )
+ result = result.addSecs( dst ? -3600 : 3600 );
+
+ return result;
+}
+
+static quint64 getUInt64Property( IInArchive* archive, int index, int propId, quint64 defaultValue=0 ) {
+ const NCOM::CPropVariant prop = readProperty( archive, index, propId );
+ if ( prop.vt == VT_EMPTY )
+ return defaultValue;
+ return static_cast<quint64>( ConvertPropVariantToUInt64( prop ) );
+}
+
+static quint32 getUInt32Property( IInArchive* archive, int index, int propId, quint32 defaultValue=0 ) {
+ const NCOM::CPropVariant prop = readProperty( archive, index, propId );
+ if ( prop.vt == VT_EMPTY )
+ return defaultValue;
+ return static_cast< quint32 >( prop.ulVal );
+}
+
+static QFile::Permissions getPermissions( IInArchive* archive, int index, bool* hasPermissions = 0 )
+{
+ quint32 attributes = getUInt32Property( archive, index, kpidAttrib, 0 );
+ QFile::Permissions permissions = 0;
+ if( attributes & FILE_ATTRIBUTE_UNIX_EXTENSION )
+ {
+ if( hasPermissions != 0 )
+ *hasPermissions = true;
+ // filter the unix permissions
+ attributes = ( attributes >> 16 ) & 0777;
+ permissions |= static_cast< QFile::Permissions >( ( attributes & 0700 ) << 2 ); // owner rights
+ permissions |= static_cast< QFile::Permissions >( ( attributes & 0070 ) << 1 ); // group
+ permissions |= static_cast< QFile::Permissions >( ( attributes & 0007 ) << 0 ); // and world rights
+ }
+ else if( hasPermissions != 0 )
+ *hasPermissions = false;
+ return permissions;
+}
+
+namespace Lib7z {
+
+ class QIODeviceSequentialOutStream : public ISequentialOutStream, public CMyUnknownImp {
+ public:
+ MY_UNKNOWN_IMP
+ explicit QIODeviceSequentialOutStream( QIODevice* device );
+ ~QIODeviceSequentialOutStream();
+
+ /* reimp */ STDMETHOD(Write)( const void* data, UInt32 size, UInt32* processedSize );
+
+ private:
+ QPointer<QIODevice> m_device;
+ const bool closeOnDestroy;
+ };
+
+
+ QIODeviceSequentialOutStream::QIODeviceSequentialOutStream( QIODevice* device )
+ : ISequentialOutStream(),
+ CMyUnknownImp(),
+ m_device( device ),
+ closeOnDestroy( !device->isOpen() )
+ {
+ assert( m_device );
+ if( closeOnDestroy )
+ m_device->open( QIODevice::WriteOnly );
+ }
+
+ QIODeviceSequentialOutStream::~QIODeviceSequentialOutStream()
+ {
+ if( closeOnDestroy )
+ {
+ m_device->close();
+ delete m_device;
+ }
+ }
+
+ HRESULT QIODeviceSequentialOutStream::Write( const void* data, UInt32 size, UInt32* processedSize ) {
+ if ( !m_device ) {
+ if ( processedSize )
+ *processedSize = 0;
+ return E_FAIL;
+ }
+ if( closeOnDestroy && !m_device->isOpen() ) {
+ const bool opened = m_device->open( QIODevice::WriteOnly );
+ if ( !opened ) {
+ if ( processedSize )
+ *processedSize = 0;
+ return E_FAIL;
+ }
+ }
+
+ const qint64 written = m_device->write( reinterpret_cast<const char*>( data ), size );
+ if ( processedSize )
+ *processedSize = written;
+ return written >= 0 ? S_OK : E_FAIL;
+ }
+
+ class QIODeviceInStream : public IInStream, public CMyUnknownImp {
+ public:
+ MY_UNKNOWN_IMP
+
+ explicit QIODeviceInStream( QIODevice* device ) : IInStream(), CMyUnknownImp(), m_device( device ) {
+ assert( m_device );
+ assert( !m_device->isSequential() );
+ }
+
+ /* reimp */ STDMETHOD(Read)( void* data, UInt32 size, UInt32* processedSize ) {
+ assert( m_device );
+ assert( m_device->isReadable() );
+ const qint64 actual = m_device->read( reinterpret_cast<char*>( data ), size );
+ Q_ASSERT( actual != 0 || m_device->atEnd() );
+ if ( processedSize )
+ *processedSize = actual;
+ return actual >= 0 ? S_OK : E_FAIL;
+ }
+
+ /* reimp */ STDMETHOD(Seek)( Int64 offset, UInt32 seekOrigin, UInt64* newPosition ) {
+ assert( m_device );
+ assert( !m_device->isSequential() );
+ assert( m_device->isReadable() );
+ if ( seekOrigin > STREAM_SEEK_END )
+ return STG_E_INVALIDFUNCTION;
+ UInt64 np = 0;
+ switch( seekOrigin ) {
+ case STREAM_SEEK_SET:
+ np = offset;
+ break;
+ case STREAM_SEEK_CUR:
+ np = m_device->pos() + offset;
+ break;
+ case STREAM_SEEK_END:
+ np = m_device->size() + offset;
+ break;
+ default:
+ return STG_E_INVALIDFUNCTION;
+ }
+
+ np = qBound( static_cast<UInt64>( 0 ), np, static_cast<UInt64>( m_device->size() - 1 ) );
+ const bool ok = m_device->seek( np );
+ if ( newPosition )
+ *newPosition = np;
+ return ok ? S_OK : E_FAIL;
+ }
+
+ private:
+ QPointer<QIODevice> m_device;
+ };
+}
+
+File::File() : permissions( 0 ), uncompressedSize( 0 ), compressedSize( 0 ), isDirectory( false ) {
+}
+
+QVector<File> File::subtreeInPreorder() const {
+ QVector<File> res;
+ res += *this;
+ Q_FOREACH( const File& child, children )
+ res += child.subtreeInPreorder();
+ return res;
+}
+
+bool File::operator<( const File& other ) const {
+ if ( path != other.path )
+ return path < other.path;
+ if ( mtime != other.mtime )
+ return mtime < other.mtime;
+ if ( uncompressedSize != other.uncompressedSize )
+ return uncompressedSize < other.uncompressedSize;
+ if ( compressedSize != other.compressedSize )
+ return compressedSize < other.compressedSize;
+ if ( isDirectory != other.isDirectory )
+ return !isDirectory;
+ if( permissions != other.permissions )
+ return permissions < other.permissions;
+ return false;
+}
+
+bool File::operator==( const File& other ) const {
+ return mtime == other.mtime
+ && path == other.path
+ && uncompressedSize == other.uncompressedSize
+ && compressedSize == other.compressedSize
+ && isDirectory == other.isDirectory
+ && children == other.children
+ && (permissions == other.permissions || permissions == static_cast< QFile::Permissions >( -1 ) || other.permissions == static_cast< QFile::Permissions >( -1 ) );
+}
+
+QByteArray Lib7z::formatKeyValuePairs( const QVariantList& l ) {
+ assert( l.size() % 2 == 0 );
+ QByteArray res;
+ for ( QVariantList::ConstIterator it = l.constBegin(); it != l.constEnd(); ++it ) {
+ if ( !res.isEmpty() )
+ res += ", ";
+ res += qPrintable(it->toString()) + QByteArray(" = ");
+ ++it;
+ res += qPrintable(it->toString());
+ }
+ return res;
+}
+
+class Job::Private {
+public:
+ Private() : error(Lib7z::NoError) {}
+ int error;
+ QString errorString;
+};
+
+Job::Job( QObject* parent ) : QObject( parent ), QRunnable(), d( new Private ) {
+}
+
+Job::~Job() {
+ delete d;
+}
+
+void Job::emitResult() {
+ emit finished( this );
+}
+
+void Job::setError( int code ) {
+ d->error = code;
+}
+
+void Job::setErrorString( const QString& str ) {
+ d->errorString = str;
+}
+
+void Job::emitProgress( qint64 completed, qint64 total ) {
+ emit progress( completed, total );
+}
+
+int Job::error() const {
+ return d->error;
+}
+
+bool Job::hasError() const {
+ return d->error != NoError;
+}
+
+void Job::run() {
+ doStart();
+}
+
+QString Job::errorString() const {
+ return d->errorString;
+}
+
+void Job::start() {
+ QMetaObject::invokeMethod( this, "doStart", Qt::QueuedConnection );
+}
+
+class ListArchiveJob::Private {
+public:
+ QPointer<QIODevice> archive;
+ QVector<File> files;
+};
+
+ListArchiveJob::ListArchiveJob( QObject* parent ) : Job( parent ), d( new Private ) {
+}
+
+ListArchiveJob::~ListArchiveJob() {
+ delete d;
+}
+
+QIODevice* ListArchiveJob::archive() const {
+ return d->archive;
+}
+
+void ListArchiveJob::setArchive( QIODevice* device ) {
+ d->archive = device;
+}
+
+QVector<File> ListArchiveJob::index() const {
+ return d->files;
+}
+
+class OpenArchiveInfo
+{
+private:
+ OpenArchiveInfo( QIODevice* device )
+ : codecs( new CCodecs ),
+ stream( new QIODeviceInStream( device ) )
+ {
+ throwIfNotOK( codecs->Load(), QObject::tr( "Could not load codecs" ) );
+
+ if( !codecs->FindFormatForArchiveType( L"", formatIndices ) )
+ throw SevenZipException( QObject::tr( "Could not retrieve default format" ) );
+
+ throwIfNotOK( archiveLink.Open2( codecs.get(), formatIndices, false, stream, UString(), 0 ), QObject::tr( "Could not open archive" ) );
+ if( archiveLink.Arcs.Size() == 0 )
+ throw SevenZipException( QObject::tr( "No CArc found" ) );
+
+ m_cleaner = new OpenArchiveInfoCleaner();
+ m_cleaner->moveToThread( device->thread() );
+ QObject::connect(device, SIGNAL(destroyed(QObject*)), m_cleaner, SLOT(deviceDestroyed(QObject*)));
+ }
+
+public:
+ ~OpenArchiveInfo()
+ {
+ m_cleaner->deleteLater();
+ }
+
+ static QMap< QIODevice*, OpenArchiveInfo* > instances;
+
+ static OpenArchiveInfo* instance( QIODevice* device )
+ {
+ if( instances[ device ] == 0 )
+ instances[ device ] = new OpenArchiveInfo( device );
+ return instances[ device ];
+ }
+
+ std::auto_ptr< CCodecs > codecs;
+ CIntVector formatIndices;
+ CArchiveLink archiveLink;
+ CMyComPtr< IInStream > stream;
+private:
+ OpenArchiveInfoCleaner *m_cleaner;
+};
+
+QMap< QIODevice*, OpenArchiveInfo* > OpenArchiveInfo::instances;
+
+void OpenArchiveInfoCleaner::deviceDestroyed(QObject* dev)
+{
+ QIODevice* device = static_cast<QIODevice*>(dev);
+ Q_ASSERT(device);
+ Q_ASSERT(OpenArchiveInfo::instances.contains(device));
+ delete OpenArchiveInfo::instances.take(device);
+}
+
+QVector<File> Lib7z::listArchive( QIODevice* archive ) {
+ assert( archive );
+ try {
+ const OpenArchiveInfo* const openArchive = OpenArchiveInfo::instance( archive );
+
+ QVector<File> flat;
+
+ for ( int i = 0; i < openArchive->archiveLink.Arcs.Size(); ++i ) {
+ const CArc& arc = openArchive->archiveLink.Arcs[i];
+ IInArchive* const arch = arc.Archive;
+
+ UInt32 numItems = 0;
+ throwIfNotOK( arch->GetNumberOfItems(&numItems), QObject::tr("Could not retrieve number of items in archive") );
+
+ flat.reserve( flat.size() + numItems );
+ for ( uint item = 0; item < numItems; ++item ) {
+ UString s;
+ throwIfNotOK( arc.GetItemPath( item, s ), QObject::tr("Could not retrieve path of archive item %1").arg( item ) );
+ File f;
+ f.archiveIndex.setX( i );
+ f.archiveIndex.setY( item );
+ f.path = UString2QString( s ).replace( QLatin1Char( '\\' ), QLatin1Char( '/' ) );
+ IsArchiveItemFolder( arch, item, f.isDirectory );
+ f.permissions = getPermissions( arch, item );
+ f.mtime = getDateTimeProperty( arch, item, kpidMTime, QDateTime() );
+ f.uncompressedSize = getUInt64Property( arch, item, kpidSize, 0 );
+ f.compressedSize = getUInt64Property( arch, item, kpidPackSize, 0 );
+ flat.push_back( f );
+ qApp->processEvents();
+ }
+ }
+ return flat;
+ } catch ( const SevenZipException& e ) {
+ throw e;
+ }
+ catch(const char *err) {
+ throw SevenZipException( err );
+ }
+ catch ( ... ) {
+ throw SevenZipException( QObject::tr("Unknown exception caught (%1)").arg(QString::fromLatin1(Q_FUNC_INFO)) );
+ }
+ return QVector<File>(); // never reached
+}
+
+void ListArchiveJob::doStart() {
+ try {
+ if ( !d->archive )
+ throw SevenZipException( tr("Could not list archive: QIODevice already destroyed") );
+ d->files = listArchive( d->archive );
+ } catch ( const SevenZipException& e ) {
+ setError( Failed );
+ setErrorString( e.message() );
+ } catch ( ... ) {
+ setError( Failed );
+ setErrorString( QObject::tr("Unknown exception caught (%1)").arg( QObject::tr( "Failed" )) );
+ }
+ emitResult();
+}
+
+class Lib7z::ExtractCallbackImpl : public IArchiveExtractCallback, public CMyUnknownImp {
+public:
+ MY_UNKNOWN_IMP
+ explicit ExtractCallbackImpl( ExtractCallback* qq )
+ : q( qq ),
+ currentIndex( 0 ),
+ arc( 0 ),
+ total( 0 ),
+ completed( 0 ),
+ device( 0 )
+ {
+ }
+
+ void setTarget( QIODevice* dev )
+ {
+ device = dev;
+ }
+
+ void setTarget( const QString& targetDirectory )
+ {
+ targetDir = targetDirectory;
+ }
+
+ // this method will be called by CFolderOutStream::OpenFile to stream via
+ // CDecoder::CodeSpec extracted content to an output stream.
+ /* reimp */ STDMETHOD(GetStream)( UInt32 index, ISequentialOutStream** outStream, Int32 askExtractMode )
+ {
+ Q_UNUSED( askExtractMode )
+ *outStream = 0;
+ if( device != 0 )
+ {
+ CMyComPtr<ISequentialOutStream> stream = new QIODeviceSequentialOutStream( device );
+ *outStream = stream.Detach();
+ return S_OK;
+ }
+ else if( !targetDir.isEmpty() )
+ {
+ assert( arc );
+
+ currentIndex = index;
+
+ UString s;
+ throwIfNotOK( arc->GetItemPath( index, s ), QObject::tr( "Could not retrieve path of archive item %1" ).arg( index ) );
+ const QString path = UString2QString( s ).replace( QLatin1Char( '\\' ), QLatin1Char( '/' ) );
+
+ const QFileInfo fi( QString::fromLatin1( "%1/%2" ).arg( targetDir, path ) );
+ DirectoryGuard guard( fi.absolutePath() );
+ const QStringList directories = guard.tryCreate();
+
+ bool isDir = false;
+ IsArchiveItemFolder( arc->Archive, index, isDir );
+ if( isDir )
+ {
+ QDir( fi.absolutePath() ).mkdir( fi.fileName() );
+ }
+
+ // this makes sure that all directories created get removed as well
+ for( QStringList::const_iterator it = directories.begin(); it != directories.end(); ++it )
+ q->setCurrentFile( *it );
+
+ if( !isDir && !q->prepareForFile( fi.absoluteFilePath() ) )
+ return E_FAIL;
+
+ q->setCurrentFile( fi.absoluteFilePath() );
+
+ if( !isDir )
+ {
+ CMyComPtr< ISequentialOutStream > stream = new QIODeviceSequentialOutStream( new QFile( fi.absoluteFilePath() ) );
+ *outStream = stream;
+ stream.Detach();
+ }
+
+ guard.release();
+ return S_OK;
+ }
+ return E_FAIL;
+ }
+
+ /* reimp */ STDMETHOD(PrepareOperation)( Int32 askExtractMode ) {
+ Q_UNUSED( askExtractMode )
+ return S_OK;
+ }
+
+ /* reimp */ STDMETHOD(SetOperationResult)( Int32 resultEOperationResult ) {
+ Q_UNUSED( resultEOperationResult )
+
+ if( !targetDir.isEmpty() )
+ {
+ bool hasPerm;
+ const QFile::Permissions permissions = getPermissions( arc->Archive, currentIndex, &hasPerm );
+ if( hasPerm )
+ {
+ UString s;
+ throwIfNotOK( arc->GetItemPath( currentIndex, s ), QObject::tr( "Could not retrieve path of archive item %1" ).arg( currentIndex ) );
+ const QString path = UString2QString( s ).replace( QLatin1Char( '\\' ), QLatin1Char( '/' ) );
+ const QFileInfo fi( QString::fromLatin1( "%1/%2" ).arg( targetDir, path ) );
+ QFile::setPermissions( fi.absoluteFilePath(), permissions );
+
+ // do we have a symlink?
+ const quint32 attributes = getUInt32Property( arc->Archive, currentIndex, kpidAttrib, 0 );
+ struct stat stat_info;
+ stat_info.st_mode = attributes >> 16;
+ if( S_ISLNK( stat_info.st_mode ) )
+ {
+ QFile f( fi.absoluteFilePath() );
+ f.open( QIODevice::ReadOnly );
+ const QByteArray path = f.readAll();
+ f.close();
+ f.remove();
+#ifdef Q_WS_WIN
+ if( !CreateHardLinkWrapper( fi.absoluteFilePath(), QLatin1String( path ) ) )
+ throw SevenZipException( QObject::tr( "Could not create file system lik at %1" ).arg( fi.absoluteFilePath() ) );
+#else
+ if( !QFile::link( QString::fromLatin1( path ), fi.absoluteFilePath() ) )
+ throw SevenZipException( QObject::tr( "Could not create softlink at %1" ).arg( fi.absoluteFilePath() ) );
+#endif
+ }
+ }
+ }
+
+ return S_OK;
+ }
+
+ /* reimp */ STDMETHOD(SetTotal)( UInt64 t ) {
+ total = t;
+ return S_OK;
+ }
+
+ /* reimp */ STDMETHOD(SetCompleted)( const UInt64* c ) {
+ completed = *c;
+ if ( total > 0 ) {
+ return q->setCompleted( completed, total );
+ }
+ return S_OK;
+ }
+
+ void setArchive( const CArc* archive )
+ {
+ arc = archive;
+ }
+
+private:
+ ExtractCallback* const q;
+ UInt32 currentIndex;
+ const CArc* arc;
+ UInt64 total;
+ UInt64 completed;
+ QPointer<QIODevice> device;
+ QString targetDir;
+};
+
+
+class Lib7z::ExtractCallbackPrivate {
+public:
+ explicit ExtractCallbackPrivate( ExtractCallback* qq ) {
+ impl = new ExtractCallbackImpl( qq );
+ }
+
+ CMyComPtr<ExtractCallbackImpl> impl;
+};
+
+ExtractCallback::ExtractCallback() : d( new ExtractCallbackPrivate( this ) ) {
+}
+
+ExtractCallback::~ExtractCallback() {
+ delete d;
+}
+
+ExtractCallbackImpl* ExtractCallback::impl() {
+ return d->impl;
+}
+
+const ExtractCallbackImpl* ExtractCallback::impl() const {
+ return d->impl;
+}
+
+void ExtractCallback::setTarget( QIODevice* dev )
+{
+ d->impl->setTarget( dev );
+}
+
+void ExtractCallback::setTarget( const QString& dir )
+{
+ d->impl->setTarget( dir );
+}
+
+HRESULT ExtractCallback::setCompleted( quint64, quint64 )
+{
+ return S_OK;
+}
+
+void ExtractCallback::setCurrentFile( const QString& )
+{
+}
+
+bool ExtractCallback::prepareForFile( const QString& )
+{
+ return true;
+}
+
+class Lib7z::ExtractCallbackJobImpl : public ExtractCallback {
+ public:
+ explicit ExtractCallbackJobImpl( ExtractItemJob* j ) : ExtractCallback(), job( j ) {}
+ private:
+ /* reimp */ HRESULT setCompleted( quint64 c, quint64 t ) {
+ emit job->progress( c, t );
+ return S_OK;
+ }
+
+ ExtractItemJob* const job;
+};
+
+class Lib7z::UpdateCallbackImpl : public IUpdateCallbackUI2, public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+ explicit UpdateCallbackImpl( UpdateCallback* qq )
+ : q( qq )
+ {
+ }
+ virtual ~UpdateCallbackImpl()
+ {
+ }
+ /**
+ * \reimp
+ */
+ HRESULT SetTotal( UInt64 )
+ {
+ return S_OK;
+ }
+ /**
+ * \reimp
+ */
+ HRESULT SetCompleted( const UInt64* )
+ {
+ return S_OK;
+ }
+ HRESULT SetRatioInfo( const UInt64*, const UInt64* )
+ {
+ return S_OK;
+ }
+ HRESULT CheckBreak()
+ {
+ return S_OK;
+ }
+ HRESULT Finilize()
+ {
+ return S_OK;
+ }
+ HRESULT SetNumFiles( UInt64 )
+ {
+ return S_OK;
+ }
+ HRESULT GetStream( const wchar_t*, bool )
+ {
+ return S_OK;
+ }
+ HRESULT OpenFileError( const wchar_t*, DWORD )
+ {
+ return S_OK;
+ }
+ HRESULT CryptoGetTextPassword2( Int32* passwordIsDefined, OLECHAR** password )
+ {
+ *password = 0;
+ *passwordIsDefined = false;
+ return S_OK;
+ }
+ HRESULT CryptoGetTextPassword(OLECHAR**)
+ {
+ return E_NOTIMPL;
+ }
+ HRESULT OpenResult(const wchar_t*, LONG )
+ {
+ return S_OK;
+ }
+ HRESULT StartScanning()
+ {
+ return S_OK;
+ }
+ HRESULT ScanProgress(UInt64, UInt64, const wchar_t*)
+ {
+ return S_OK;
+ }
+ HRESULT CanNotFindError(const wchar_t*, DWORD)
+ {
+ return S_OK;
+ }
+ HRESULT FinishScanning()
+ {
+ return S_OK;
+ }
+ HRESULT StartArchive(const wchar_t*, bool)
+ {
+ return S_OK;
+ }
+ HRESULT FinishArchive()
+ {
+ return S_OK;
+ }
+
+ /**
+ * \reimp
+ */
+ HRESULT SetOperationResult( Int32 )
+ {
+ // TODO!
+ return S_OK;
+ }
+ void setSource( const QString& dir )
+ {
+ sourceDir = dir;
+ }
+ void setTarget( QIODevice* archive )
+ {
+ target = archive;
+ }
+
+private:
+ UpdateCallback* const q;
+
+ QIODevice* target;
+ QString sourceDir;
+};
+
+class Lib7z::UpdateCallbackPrivate
+{
+public:
+ explicit UpdateCallbackPrivate( UpdateCallback* qq )
+ {
+ m_impl = new UpdateCallbackImpl( qq );
+ }
+
+ UpdateCallbackImpl* impl()
+ {
+ return m_impl;
+ }
+
+private:
+ CMyComPtr< UpdateCallbackImpl > m_impl;
+};
+
+UpdateCallback::UpdateCallback()
+ : d( new UpdateCallbackPrivate( this ) )
+{
+}
+
+UpdateCallback::~UpdateCallback()
+{
+ delete d;
+}
+
+UpdateCallbackImpl* UpdateCallback::impl()
+{
+ return d->impl();
+}
+
+
+void UpdateCallback::setSource( const QString& dir )
+{
+ d->impl()->setSource( dir );
+}
+
+void UpdateCallback::setTarget( QIODevice* target )
+{
+ d->impl()->setTarget( target );
+}
+
+class ExtractItemJob::Private {
+public:
+ Private( ExtractItemJob* qq )
+ : q( qq),
+ target( 0 ),
+ callback( new ExtractCallbackJobImpl( q ) )
+ {
+ }
+
+ ~Private() {
+ }
+
+ ExtractItemJob* q;
+ File item;
+ QPointer<QIODevice> archive;
+ QString targetDirectory;
+ QIODevice* target;
+ ExtractCallback* callback;
+};
+
+ExtractItemJob::ExtractItemJob( QObject* parent ) : Job( parent ), d( new Private( this ) ) {
+}
+
+ExtractItemJob::~ExtractItemJob() {
+ delete d;
+}
+
+File ExtractItemJob::item() const {
+ return d->item;
+}
+
+void ExtractItemJob::setItem( const File& item ) {
+ d->item = item;
+}
+
+QIODevice* ExtractItemJob::archive() const {
+ return d->archive;
+}
+
+void ExtractItemJob::setArchive( QIODevice* archive ) {
+ d->archive = archive;
+}
+
+QString ExtractItemJob::targetDirectory() const {
+ return d->targetDirectory;
+}
+
+void ExtractItemJob::setTargetDirectory( const QString& dir ) {
+ d->targetDirectory = dir;
+ d->target = 0;
+}
+
+void ExtractItemJob::setTarget( QIODevice* dev )
+{
+ d->target = dev;
+}
+
+void Lib7z::createArchive( QIODevice* archive, const QString& sourceDirectory, UpdateCallback* callback )
+{
+ assert( archive );
+
+ std::auto_ptr< UpdateCallback > dummyCallback( callback ? 0 : new UpdateCallback );
+ if ( !callback )
+ callback = dummyCallback.get();
+
+ try
+ {
+ std::auto_ptr< CCodecs > codecs( new CCodecs );
+ throwIfNotOK( codecs->Load(), QObject::tr( "Could not load codecs" ) );
+
+ CIntVector formatIndices;
+
+ if( !codecs.get()->FindFormatForArchiveType( L"", formatIndices ) )
+ throw SevenZipException( QObject::tr( "Could not retrieve default format" ) );
+
+ // yes this is crap, but there seems to be no streaming solution to this...
+
+ const QString tempFile = generateTempFileName();
+
+ NWildcard::CCensor censor;
+ const UString sourceDirectoryPath = QString2UString( QDir::toNativeSeparators( sourceDirectory ) );
+ if( UString2QString( sourceDirectoryPath ) != QDir::toNativeSeparators( sourceDirectory ) )
+ throw UString2QString( sourceDirectoryPath ).toLatin1().data();
+ censor.AddItem( true, sourceDirectoryPath, true );
+
+ CUpdateOptions options;
+ CArchivePath archivePath;
+ archivePath.ParseFromPath( QString2UString( tempFile ) );
+ CUpdateArchiveCommand command;
+ command.ArchivePath = archivePath;
+ command.ActionSet = NUpdateArchive::kAddActionSet;
+ options.Commands.Add( command );
+ options.ArchivePath = archivePath;
+ options.MethodMode.FormatIndex = codecs->FindFormatForArchiveType( L"7z" );
+
+ CUpdateErrorInfo errorInfo;
+
+ callback->setTarget( archive );
+ callback->setSource( sourceDirectory );
+ const HRESULT res = UpdateArchive( codecs.get(), censor, options, errorInfo, 0, callback->impl() );
+ if( res != S_OK || !QFile::exists( tempFile ) )
+ throw SevenZipException( QObject::tr( "Could not create archive %1" ).arg( tempFile ) );
+ {
+ //TODO remove temp file even if one the following throws
+ QFile file( tempFile );
+ QInstaller::openForRead( &file, tempFile );
+ QInstaller::blockingCopy( &file, archive, file.size() );
+ }
+ QFile file( tempFile );
+ if ( !file.remove() )
+ qWarning("%s: Could not remove temporary file %s: %s", Q_FUNC_INFO, qPrintable(tempFile), qPrintable(file.errorString()) );
+ }
+ catch(const char *err)
+ {
+ std::cout << err << std::endl;
+ throw SevenZipException( err );
+ }
+ catch (const QInstaller::Error &err )
+ {
+ throw SevenZipException( err.message() );
+ }
+ catch( ... )
+ {
+ throw SevenZipException( QObject::tr("Unknown exception caught (%1)").arg(QString::fromLatin1(Q_FUNC_INFO)) );
+ }
+}
+
+void Lib7z::extractArchive( QIODevice* archive, const File& item, QIODevice* target, ExtractCallback* callback ) {
+ assert( archive );
+ assert( target );
+
+ std::auto_ptr<ExtractCallback> dummyCallback( callback ? 0 : new ExtractCallback );
+ if ( !callback )
+ callback = dummyCallback.get();
+
+ try {
+ const OpenArchiveInfo* const openArchive = OpenArchiveInfo::instance( archive );
+
+ const int arcIdx = item.archiveIndex.x();
+ if ( arcIdx < 0 || arcIdx >= openArchive->archiveLink.Arcs.Size() )
+ throw SevenZipException( QObject::tr("CArc index %1 out of bounds [0, %2]").arg( openArchive->archiveLink.Arcs.Size() - 1 ) );
+ const CArc& arc = openArchive->archiveLink.Arcs[arcIdx];
+ IInArchive* const parchive = arc.Archive;
+
+ const UInt32 itemIdx = item.archiveIndex.y();
+ UInt32 numItems = 0;
+ throwIfNotOK( parchive->GetNumberOfItems(&numItems), QObject::tr("Could not retrieve number of items in archive") );
+ if ( itemIdx >= numItems )
+ throw SevenZipException( QObject::tr("Item index %1 out of bounds [0, %2]").arg( itemIdx ).arg( numItems - 1 ) );
+
+ UString s;
+ throwIfNotOK( arc.GetItemPath( itemIdx, s ), QObject::tr( "Could not retrieve path of archive item %1" ).arg( itemIdx ) );
+ assert( item.path == UString2QString( s ).replace( QLatin1Char( '\\' ), QLatin1Char( '/' ) ) );
+
+ callback->setTarget( target );
+ const LONG extractResult = parchive->Extract( &itemIdx, 1, /*testmode=*/1, callback->impl() );
+ //TODO: how to interpret result?
+ throwIfNotOK( extractResult, QObject::tr("Extracting %1 failed.").arg( item.path ) );
+ } catch(const char *err) {
+ throw SevenZipException( err );
+ } catch ( ... ) {
+ throw SevenZipException( QObject::tr("Unknown exception caught (%1)").arg(QString::fromLatin1(Q_FUNC_INFO)) );
+ }
+}
+
+void Lib7z::extractArchive( QIODevice* archive, const File& item, const QString& targetDirectory, ExtractCallback* callback ) {
+ assert( archive );
+
+ std::auto_ptr<ExtractCallback> dummyCallback( callback ? 0 : new ExtractCallback );
+ if ( !callback )
+ callback = dummyCallback.get();
+
+ QFileInfo fi( targetDirectory + QLatin1String( "/" ) + item.path );
+ DirectoryGuard outDir( fi.absolutePath() );
+ outDir.tryCreate();
+ QFile out( fi.absoluteFilePath() );
+ if ( !out.open( QIODevice::WriteOnly ) ) //TODO use tmp file
+ throw SevenZipException( QObject::tr("Could not create output file for writing: %1").arg( fi.absoluteFilePath() ) );
+ if( item.permissions )
+ out.setPermissions( item.permissions );
+ callback->setTarget( &out );
+ extractArchive( archive, item, &out, callback );
+ outDir.release();
+}
+
+void Lib7z::extractArchive( QIODevice* archive, const QString& targetDirectory, ExtractCallback* callback )
+{
+ assert( archive );
+
+ std::auto_ptr<ExtractCallback> dummyCallback( callback ? 0 : new ExtractCallback );
+ if ( !callback )
+ callback = dummyCallback.get();
+
+ callback->setTarget( targetDirectory );
+
+ const QFileInfo fi( targetDirectory );
+ DirectoryGuard outDir( fi.absolutePath() );
+ outDir.tryCreate();
+
+ const OpenArchiveInfo* const openArchive = OpenArchiveInfo::instance( archive );
+
+ for( int a = 0; a < openArchive->archiveLink.Arcs.Size(); ++a )
+ {
+ const CArc& arc = openArchive->archiveLink.Arcs[ a ];
+ IInArchive* const arch = arc.Archive;
+ callback->impl()->setArchive( &arc );
+ const LONG extractResult = arch->Extract( 0, static_cast< UInt32 >( -1 ), false, callback->impl() );
+ throwIfNotOK( extractResult, QObject::tr("Extraction failed.") ); //TODO is it possible to get a more detailed error?
+ }
+
+ outDir.release();
+}
+
+bool Lib7z::isSupportedArchive( const QString& archive )
+{
+ QFile file( archive );
+ if( !file.open( QIODevice::ReadOnly ) )
+ return false;
+
+ return isSupportedArchive( &file );
+}
+
+bool Lib7z::isSupportedArchive( QIODevice* archive ) {
+ assert( archive );
+ assert( !archive->isSequential() );
+ const qint64 initialPos = archive->pos();
+ try {
+ std::auto_ptr<CCodecs> codecs( new CCodecs );
+ throwIfNotOK( codecs->Load(), QObject::tr("Could not load codecs") );
+
+ CIntVector formatIndices;
+
+ if ( !codecs.get()->FindFormatForArchiveType(L"", formatIndices) )
+ throw SevenZipException( QObject::tr("Could not retrieve default format") );
+
+ CArchiveLink archiveLink;
+ const CMyComPtr<IInStream> stream = new QIODeviceInStream( archive ); //CMyComPtr is needed, otherwise it crashes in OpenStream()
+
+ const HRESULT result = archiveLink.Open2(codecs.get(), formatIndices, /*stdInMode*/false, stream, UString(), 0);
+
+ archive->seek( initialPos );
+ return result == S_OK;
+ } catch ( const SevenZipException& e ) {
+ archive->seek( initialPos );
+ throw e;
+ } catch(const char *err) {
+ archive->seek( initialPos );
+ throw SevenZipException( err );
+ } catch( ... ) {
+ archive->seek( initialPos );
+ throw SevenZipException( QObject::tr("Unknown exception caught (%1)").arg(QString::fromLatin1(Q_FUNC_INFO)) );
+ }
+ return false; // never reached
+}
+
+void ExtractItemJob::doStart() {
+ try {
+ if ( !d->archive )
+ throw SevenZipException( tr("Could not list archive: QIODevice not set or already destroyed") );
+ if ( d->target )
+ extractArchive( d->archive, d->item, d->target, d->callback );
+ else if( !d->item.path.isEmpty() )
+ extractArchive( d->archive, d->item, d->targetDirectory, d->callback );
+ else
+ extractArchive( d->archive, d->targetDirectory, d->callback );
+ } catch ( const SevenZipException& e ) {
+ setError( Failed );
+ setErrorString( e.message() );
+ } catch ( ... ) {
+ setError( Failed );
+ setErrorString( QObject::tr("Unknown exception caught (%1)").arg( QObject::tr( "Failed" )) );
+ }
+ emitResult();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h
new file mode 100644
index 000000000..670071866
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h
@@ -0,0 +1,240 @@
+#ifndef LIB7Z_FACADE_H
+#define LIB7Z_FACADE_H
+
+#include <QCoreApplication>
+#include <QDateTime>
+#include <QFile>
+#include <QString>
+#include <QRunnable>
+#include <QVector>
+#include <QVariant>
+#include <QPoint>
+
+#include <stdexcept>
+#include <string>
+
+#include "Common/MyWindows.h"
+
+#include "../../installerbuilder/libinstaller/installer_global.h"
+
+class QStringList;
+template <typename T> class QVector;
+
+namespace Lib7z {
+
+ class INSTALLER_EXPORT SevenZipException : public std::runtime_error {
+ public:
+ explicit SevenZipException( const QString& msg ) : std::runtime_error( msg.toStdString() ), m_message( msg ) {}
+ explicit SevenZipException( const char* msg ) : std::runtime_error( msg ), m_message( QString::fromLocal8Bit( msg ) ) {}
+ explicit SevenZipException( const std::string& msg ) : std::runtime_error( msg ), m_message( QString::fromLocal8Bit( msg.c_str() ) ) {}
+
+ ~SevenZipException() throw() {}
+ QString message() const { return m_message; }
+ private:
+ QString m_message;
+ };
+
+ class INSTALLER_EXPORT File {
+ public:
+ File();
+ QVector<File> subtreeInPreorder() const;
+
+ bool operator<( const File& other ) const;
+ bool operator==( const File& other ) const;
+
+ QFile::Permissions permissions;
+ QString path;
+ QString name;
+ QDateTime mtime;
+ quint64 uncompressedSize;
+ quint64 compressedSize;
+ bool isDirectory;
+ QVector<File> children;
+ QPoint archiveIndex;
+ };
+
+ class ExtractCallbackPrivate;
+ class ExtractCallbackImpl;
+
+ class ExtractCallback {
+ friend class ::Lib7z::ExtractCallbackImpl;
+ public:
+ ExtractCallback();
+ virtual ~ExtractCallback();
+
+ void setTarget( QIODevice* archive );
+ void setTarget( const QString& dir );
+
+ protected:
+ /**
+ * Reimplement to prepare for file @p filename to be extracted, e.g. by renaming existing files.
+ * @return @p true if the preparation was successful and extraction can be continued.
+ * If @p false is returned, the extraction will be aborted. Default implementation returns @p true.
+ */
+ virtual bool prepareForFile( const QString& filename );
+ virtual void setCurrentFile( const QString& filename );
+ virtual HRESULT setCompleted( quint64 completed, quint64 total );
+
+ public: //for internal use
+ const ExtractCallbackImpl* impl() const;
+ ExtractCallbackImpl* impl();
+
+ private:
+ ExtractCallbackPrivate* const d;
+ };
+
+ class UpdateCallbackPrivate;
+ class UpdateCallbackImpl;
+
+ class UpdateCallback
+ {
+ friend class ::Lib7z::UpdateCallbackImpl;
+ public:
+ UpdateCallback();
+ virtual ~UpdateCallback();
+
+ void setTarget( QIODevice* archive );
+ void setSource( const QString& dir );
+
+ virtual UpdateCallbackImpl* impl();
+
+ private:
+ UpdateCallbackPrivate* const d;
+ };
+
+ class OpenArchiveInfoCleaner : public QObject {
+ Q_OBJECT
+ public:
+ OpenArchiveInfoCleaner() {}
+ private Q_SLOTS:
+ void deviceDestroyed(QObject*);
+ };
+
+ /*
+ * @throws Lib7z::SevenZipException
+ */
+ void INSTALLER_EXPORT extractArchive( QIODevice* archive, const File& item, QIODevice* out, ExtractCallback* callback=0 );
+
+ /*
+ * @throws Lib7z::SevenZipException
+ */
+ void INSTALLER_EXPORT extractArchive( QIODevice* archive, const File& item, const QString& targetDirectory, ExtractCallback* callback=0 );
+
+ /*
+ * @throws Lib7z::SevenZipException
+ */
+ void INSTALLER_EXPORT extractArchive( QIODevice* archive, const QString& targetDirectory, ExtractCallback* callback=0 );
+
+ /*
+ * @thows Lib7z::SevenZipException
+ */
+ void INSTALLER_EXPORT createArchive( QIODevice* archive, const QString& sourceDirectory, UpdateCallback* callback = 0 );
+
+ /*
+ * @throws Lib7z::SevenZipException
+ */
+ QVector<File> INSTALLER_EXPORT listArchive( QIODevice* archive );
+
+ /*
+ * @throws Lib7z::SevenZipException
+ */
+ bool INSTALLER_EXPORT isSupportedArchive( QIODevice* archive );
+
+ /*
+ * @throws Lib7z::SevenZipException
+ */
+ bool INSTALLER_EXPORT isSupportedArchive( const QString& archive );
+
+
+
+ enum Error {
+ NoError=0,
+ Failed=1,
+ UserDefinedError=128
+ };
+
+ class ExtractCallbackJobImpl;
+
+ class INSTALLER_EXPORT Job : public QObject, public QRunnable {
+ friend class ::Lib7z::ExtractCallbackJobImpl;
+ Q_OBJECT
+ public:
+
+ explicit Job( QObject* parent=0 );
+ ~Job();
+ void start();
+ int error() const;
+ bool hasError() const;
+ QString errorString() const;
+
+ /* reimp */ void run();
+
+ protected:
+ void emitResult();
+ void setError( int code );
+ void setErrorString( const QString& err );
+ void emitProgress( qint64 completed, qint64 total );
+
+ Q_SIGNALS:
+ void finished( Lib7z::Job* job );
+ void progress( qint64 completed, qint64 total );
+
+ private Q_SLOTS:
+ virtual void doStart() = 0;
+
+ private:
+ class Private;
+ Private* const d;
+ };
+
+ class INSTALLER_EXPORT ListArchiveJob : public Job {
+ Q_OBJECT
+ public:
+
+ explicit ListArchiveJob( QObject* parent=0 );
+ ~ListArchiveJob();
+
+ QIODevice* archive() const;
+ void setArchive( QIODevice* archive );
+
+ QVector<File> index() const;
+
+ private:
+ /* reimp */ void doStart();
+
+ private:
+ class Private;
+ Private* const d;
+ };
+
+ class INSTALLER_EXPORT ExtractItemJob : public Job {
+ Q_OBJECT
+ friend class ::Lib7z::ExtractCallback;
+ public:
+
+ explicit ExtractItemJob( QObject* parent=0 );
+ ~ExtractItemJob();
+
+ File item() const;
+ void setItem( const File& item );
+
+ QIODevice* archive() const;
+ void setArchive( QIODevice* archive );
+
+ QString targetDirectory() const;
+ void setTargetDirectory( const QString& dir );
+
+ void setTarget( QIODevice* dev );
+
+ private:
+ /* reimp */ void doStart();
+
+ private:
+ class Private;
+ Private* const d;
+ };
+
+ QByteArray INSTALLER_EXPORT formatKeyValuePairs( const QVariantList& l );
+}
+
+#endif // LIB7Z_FACADE_H
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_static_init.pri b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_static_init.pri
new file mode 100644
index 000000000..2cf48f8cd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_static_init.pri
@@ -0,0 +1,15 @@
+P7ZIP_ROOT=$$PWD
+
+unix {
+ INCLUDEPATH += $$P7ZIP_ROOT $$P7ZIP_ROOT/unix/CPP $$P7ZIP_ROOT/unix/CPP/myWindows/ $$P7ZIP_ROOT/unix/CPP/include_windows
+ DEFINES += FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE NDEBUG _REENTRANT ENV_UNIX COMPRESS_MT COMPRESS_BZIP2_MT COMPRESS_MF_MT BREAK_HANDLER BENCH_MT
+# macx:DEFINES += _LZMA_UINT32_IS_ULONG
+ P7ZIP_PLATFORM=unix
+} else {
+ INCLUDEPATH += $$P7ZIP_ROOT $$P7ZIP_ROOT/win32/CPP
+ P7ZIP_PLATFORM=win32
+}
+
+SOURCES += $$P7ZIP_ROOT/$$P7ZIP_PLATFORM/CPP/7zip/Archive/7z/7zRegister.cpp
+SOURCES += $$P7ZIP_ROOT/$$P7ZIP_PLATFORM/CPP/7zip/Compress/LzmaRegister.cpp
+SOURCES += $$P7ZIP_ROOT/$$P7ZIP_PLATFORM/CPP/7zip/Compress/Lzma2Register.cpp
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/p7zip.pri b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/p7zip.pri
new file mode 100644
index 000000000..3738ec04d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/p7zip.pri
@@ -0,0 +1,5 @@
+P7ZIP_BASE=$$PWD
+
+unix:CXXFLAGS += -fvisibility
+
+include($$P7ZIP_BASE/unix/unix.pri)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/p7zip.pro b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/p7zip.pro
new file mode 100644
index 000000000..bae399060
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/p7zip.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+
+SUBDIRS = unix
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zBuf.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zBuf.h
new file mode 100644
index 000000000..e9f2f316d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zBuf.h
@@ -0,0 +1,39 @@
+/* 7zBuf.h -- Byte Buffer
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __7Z_BUF_H
+#define __7Z_BUF_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ Byte *data;
+ size_t size;
+} CBuf;
+
+void Buf_Init(CBuf *p);
+int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc);
+void Buf_Free(CBuf *p, ISzAlloc *alloc);
+
+typedef struct
+{
+ Byte *data;
+ size_t size;
+ size_t pos;
+} CDynBuf;
+
+void DynBuf_Construct(CDynBuf *p);
+void DynBuf_SeekToBeg(CDynBuf *p);
+int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc);
+void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zBuf2.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zBuf2.c
new file mode 100644
index 000000000..8d17e0dcf
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zBuf2.c
@@ -0,0 +1,45 @@
+/* 7zBuf2.c -- Byte Buffer
+2008-10-04 : Igor Pavlov : Public domain */
+
+#include <string.h>
+#include "7zBuf.h"
+
+void DynBuf_Construct(CDynBuf *p)
+{
+ p->data = 0;
+ p->size = 0;
+ p->pos = 0;
+}
+
+void DynBuf_SeekToBeg(CDynBuf *p)
+{
+ p->pos = 0;
+}
+
+int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc)
+{
+ if (size > p->size - p->pos)
+ {
+ size_t newSize = p->pos + size;
+ Byte *data;
+ newSize += newSize / 4;
+ data = (Byte *)alloc->Alloc(alloc, newSize);
+ if (data == 0)
+ return 0;
+ p->size = newSize;
+ memcpy(data, p->data, p->pos);
+ alloc->Free(alloc, p->data);
+ p->data = data;
+ }
+ memcpy(p->data + p->pos, buf, size);
+ p->pos += size;
+ return 1;
+}
+
+void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->data);
+ p->data = 0;
+ p->size = 0;
+ p->pos = 0;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrc.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrc.c
new file mode 100644
index 000000000..1ac290af6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrc.c
@@ -0,0 +1,36 @@
+/* 7zCrc.c -- CRC32 calculation
+2008-08-05
+Igor Pavlov
+Public domain */
+
+#include "7zCrc.h"
+
+#define kCrcPoly 0xEDB88320
+UInt32 g_CrcTable[256];
+
+void MY_FAST_CALL CrcGenerateTable(void)
+{
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ {
+ UInt32 r = i;
+ int j;
+ for (j = 0; j < 8; j++)
+ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
+ g_CrcTable[i] = r;
+ }
+}
+
+UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
+{
+ const Byte *p = (const Byte *)data;
+ for (; size > 0 ; size--, p++)
+ v = CRC_UPDATE_BYTE(v, *p);
+ return v;
+}
+
+UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
+{
+ CrcGenerateTable();
+ return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrc.h
new file mode 100644
index 000000000..e0d59d403
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrc.h
@@ -0,0 +1,30 @@
+/* 7zCrc.h -- CRC32 calculation
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __7Z_CRC_H
+#define __7Z_CRC_H
+
+#include <stddef.h>
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern UInt32 g_CrcTable[];
+
+void MY_FAST_CALL CrcGenerateTable(void);
+
+#define CRC_INIT_VAL 0xFFFFFFFF
+#define CRC_GET_DIGEST(crc) ((crc) ^ 0xFFFFFFFF)
+#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
+
+UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size);
+UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrcT8.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrcT8.c
new file mode 100644
index 000000000..cd80e262b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zCrcT8.c
@@ -0,0 +1,43 @@
+/* 7zCrcT8.c -- CRC32 calculation with 8 tables
+2008-03-19
+Igor Pavlov
+Public domain */
+
+#include "7zCrc.h"
+
+#define kCrcPoly 0xEDB88320
+#define CRC_NUM_TABLES 8
+
+UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
+
+void MY_FAST_CALL CrcGenerateTable()
+{
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ {
+ UInt32 r = i;
+ int j;
+ for (j = 0; j < 8; j++)
+ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
+ g_CrcTable[i] = r;
+ }
+ #if CRC_NUM_TABLES > 1
+ for (; i < 256 * CRC_NUM_TABLES; i++)
+ {
+ UInt32 r = g_CrcTable[i - 256];
+ g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
+ }
+ #endif
+}
+
+UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
+
+UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
+{
+ return CrcUpdateT8(v, data, size, g_CrcTable);
+}
+
+UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
+{
+ return CrcUpdateT8(CRC_INIT_VAL, data, size, g_CrcTable) ^ 0xFFFFFFFF;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zStream.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zStream.c
new file mode 100644
index 000000000..86232aa34
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zStream.c
@@ -0,0 +1,169 @@
+/* 7zStream.c -- 7z Stream functions
+2008-11-23 : Igor Pavlov : Public domain */
+
+#include <string.h>
+
+#include "Types.h"
+
+SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType)
+{
+ while (size != 0)
+ {
+ size_t processed = size;
+ RINOK(stream->Read(stream, buf, &processed));
+ if (processed == 0)
+ return errorType;
+ buf = (void *)((Byte *)buf + processed);
+ size -= processed;
+ }
+ return SZ_OK;
+}
+
+SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size)
+{
+ return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);
+}
+
+SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf)
+{
+ size_t processed = 1;
+ RINOK(stream->Read(stream, buf, &processed));
+ return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF;
+}
+
+SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset)
+{
+ Int64 t = offset;
+ return stream->Seek(stream, &t, SZ_SEEK_SET);
+}
+
+SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size)
+{
+ void *lookBuf;
+ if (*size == 0)
+ return SZ_OK;
+ RINOK(stream->Look(stream, &lookBuf, size));
+ memcpy(buf, lookBuf, *size);
+ return stream->Skip(stream, *size);
+}
+
+SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType)
+{
+ while (size != 0)
+ {
+ size_t processed = size;
+ RINOK(stream->Read(stream, buf, &processed));
+ if (processed == 0)
+ return errorType;
+ buf = (void *)((Byte *)buf + processed);
+ size -= processed;
+ }
+ return SZ_OK;
+}
+
+SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size)
+{
+ return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);
+}
+
+static SRes LookToRead_Look_Lookahead(void *pp, void **buf, size_t *size)
+{
+ SRes res = SZ_OK;
+ CLookToRead *p = (CLookToRead *)pp;
+ size_t size2 = p->size - p->pos;
+ if (size2 == 0 && *size > 0)
+ {
+ p->pos = 0;
+ size2 = LookToRead_BUF_SIZE;
+ res = p->realStream->Read(p->realStream, p->buf, &size2);
+ p->size = size2;
+ }
+ if (size2 < *size)
+ *size = size2;
+ *buf = p->buf + p->pos;
+ return res;
+}
+
+static SRes LookToRead_Look_Exact(void *pp, void **buf, size_t *size)
+{
+ SRes res = SZ_OK;
+ CLookToRead *p = (CLookToRead *)pp;
+ size_t size2 = p->size - p->pos;
+ if (size2 == 0 && *size > 0)
+ {
+ p->pos = 0;
+ if (*size > LookToRead_BUF_SIZE)
+ *size = LookToRead_BUF_SIZE;
+ res = p->realStream->Read(p->realStream, p->buf, size);
+ size2 = p->size = *size;
+ }
+ if (size2 < *size)
+ *size = size2;
+ *buf = p->buf + p->pos;
+ return res;
+}
+
+static SRes LookToRead_Skip(void *pp, size_t offset)
+{
+ CLookToRead *p = (CLookToRead *)pp;
+ p->pos += offset;
+ return SZ_OK;
+}
+
+static SRes LookToRead_Read(void *pp, void *buf, size_t *size)
+{
+ CLookToRead *p = (CLookToRead *)pp;
+ size_t rem = p->size - p->pos;
+ if (rem == 0)
+ return p->realStream->Read(p->realStream, buf, size);
+ if (rem > *size)
+ rem = *size;
+ memcpy(buf, p->buf + p->pos, rem);
+ p->pos += rem;
+ *size = rem;
+ return SZ_OK;
+}
+
+static SRes LookToRead_Seek(void *pp, Int64 *pos, ESzSeek origin)
+{
+ CLookToRead *p = (CLookToRead *)pp;
+ p->pos = p->size = 0;
+ return p->realStream->Seek(p->realStream, pos, origin);
+}
+
+void LookToRead_CreateVTable(CLookToRead *p, int lookahead)
+{
+ p->s.Look = lookahead ?
+ LookToRead_Look_Lookahead :
+ LookToRead_Look_Exact;
+ p->s.Skip = LookToRead_Skip;
+ p->s.Read = LookToRead_Read;
+ p->s.Seek = LookToRead_Seek;
+}
+
+void LookToRead_Init(CLookToRead *p)
+{
+ p->pos = p->size = 0;
+}
+
+static SRes SecToLook_Read(void *pp, void *buf, size_t *size)
+{
+ CSecToLook *p = (CSecToLook *)pp;
+ return LookInStream_LookRead(p->realStream, buf, size);
+}
+
+void SecToLook_CreateVTable(CSecToLook *p)
+{
+ p->s.Read = SecToLook_Read;
+}
+
+static SRes SecToRead_Read(void *pp, void *buf, size_t *size)
+{
+ CSecToRead *p = (CSecToRead *)pp;
+ return p->realStream->Read(p->realStream, buf, size);
+}
+
+void SecToRead_CreateVTable(CSecToRead *p)
+{
+ p->s.Read = SecToRead_Read;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zVersion.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zVersion.h
new file mode 100644
index 000000000..2804bc47c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/7zVersion.h
@@ -0,0 +1,7 @@
+#define MY_VER_MAJOR 9
+#define MY_VER_MINOR 04
+#define MY_VER_BUILD 0
+#define MY_VERSION "9.04 beta"
+#define MY_DATE "2009-05-30"
+#define MY_COPYRIGHT ": Igor Pavlov : Public domain"
+#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Aes.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Aes.c
new file mode 100644
index 000000000..5feb9fc30
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Aes.c
@@ -0,0 +1,262 @@
+/* Aes.c -- AES encryption / decryption
+2008-08-05
+Igor Pavlov
+Public domain */
+
+#include "Aes.h"
+#include "CpuArch.h"
+
+static UInt32 T[256 * 4];
+static Byte Sbox[256] = {
+ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
+ 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
+ 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
+ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
+ 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
+ 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
+ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
+ 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
+ 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
+ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
+ 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
+ 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
+ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
+ 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
+ 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
+ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16};
+
+static UInt32 D[256 * 4];
+static Byte InvS[256];
+
+static Byte Rcon[11] = { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };
+
+#define xtime(x) ((((x) << 1) ^ (((x) & 0x80) != 0 ? 0x1B : 0)) & 0xFF)
+
+#define Ui32(a0, a1, a2, a3) ((UInt32)(a0) | ((UInt32)(a1) << 8) | ((UInt32)(a2) << 16) | ((UInt32)(a3) << 24))
+
+#define gb0(x) ( (x) & 0xFF)
+#define gb1(x) (((x) >> ( 8)) & 0xFF)
+#define gb2(x) (((x) >> (16)) & 0xFF)
+#define gb3(x) (((x) >> (24)) & 0xFF)
+
+void AesGenTables(void)
+{
+ unsigned i;
+ for (i = 0; i < 256; i++)
+ InvS[Sbox[i]] = (Byte)i;
+ for (i = 0; i < 256; i++)
+ {
+ {
+ UInt32 a1 = Sbox[i];
+ UInt32 a2 = xtime(a1);
+ UInt32 a3 = xtime(a1) ^ a1;
+ T[ i] = Ui32(a2, a1, a1, a3);
+ T[0x100 + i] = Ui32(a3, a2, a1, a1);
+ T[0x200 + i] = Ui32(a1, a3, a2, a1);
+ T[0x300 + i] = Ui32(a1, a1, a3, a2);
+ }
+ {
+ UInt32 a1 = InvS[i];
+ UInt32 a2 = xtime(a1);
+ UInt32 a4 = xtime(a2);
+ UInt32 a8 = xtime(a4);
+ UInt32 a9 = a8 ^ a1;
+ UInt32 aB = a8 ^ a2 ^ a1;
+ UInt32 aD = a8 ^ a4 ^ a1;
+ UInt32 aE = a8 ^ a4 ^ a2;
+ D[ i] = Ui32(aE, a9, aD, aB);
+ D[0x100 + i] = Ui32(aB, aE, a9, aD);
+ D[0x200 + i] = Ui32(aD, aB, aE, a9);
+ D[0x300 + i] = Ui32(a9, aD, aB, aE);
+ }
+ }
+}
+
+#define HT(i, x, s) (T + (x << 8))[gb ## x(s[(i + x) & 3])]
+#define HT4(m, i, s, p) m[i] = \
+ HT(i, 0, s) ^ \
+ HT(i, 1, s) ^ \
+ HT(i, 2, s) ^ \
+ HT(i, 3, s) ^ w[p + i]
+/* such order (2031) in HT16 is for VC6/K8 speed optimization) */
+#define HT16(m, s, p) \
+ HT4(m, 2, s, p); \
+ HT4(m, 0, s, p); \
+ HT4(m, 3, s, p); \
+ HT4(m, 1, s, p); \
+
+#define FT(i, x) Sbox[gb ## x(m[(i + x) & 3])]
+#define FT4(i) dest[i] = Ui32(FT(i, 0), FT(i, 1), FT(i, 2), FT(i, 3)) ^ w[i];
+
+#define HD(i, x, s) (D + (x << 8))[gb ## x(s[(i - x) & 3])]
+#define HD4(m, i, s, p) m[i] = \
+ HD(i, 0, s) ^ \
+ HD(i, 1, s) ^ \
+ HD(i, 2, s) ^ \
+ HD(i, 3, s) ^ w[p + i];
+/* such order (0231) in HD16 is for VC6/K8 speed optimization) */
+#define HD16(m, s, p) \
+ HD4(m, 0, s, p); \
+ HD4(m, 2, s, p); \
+ HD4(m, 3, s, p); \
+ HD4(m, 1, s, p); \
+
+#define FD(i, x) InvS[gb ## x(m[(i - x) & 3])]
+#define FD4(i) dest[i] = Ui32(FD(i, 0), FD(i, 1), FD(i, 2), FD(i, 3)) ^ w[i];
+
+void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize)
+{
+ unsigned i, wSize;
+ UInt32 *w;
+ keySize /= 4;
+ p->numRounds2 = keySize / 2 + 3;
+
+ wSize = (p->numRounds2 * 2 + 1) * 4;
+ w = p->rkey;
+
+ for (i = 0; i < keySize; i++, key += 4)
+ w[i] = Ui32(key[0], key[1], key[2], key[3]);
+
+ for (; i < wSize; i++)
+ {
+ UInt32 t = w[i - 1];
+ unsigned rem = i % keySize;
+ if (rem == 0)
+ t = Ui32(Sbox[gb1(t)] ^ Rcon[i / keySize], Sbox[gb2(t)], Sbox[gb3(t)], Sbox[gb0(t)]);
+ else if (keySize > 6 && rem == 4)
+ t = Ui32(Sbox[gb0(t)], Sbox[gb1(t)], Sbox[gb2(t)], Sbox[gb3(t)]);
+ w[i] = w[i - keySize] ^ t;
+ }
+}
+
+void Aes_SetKeyDecode(CAes *p, const Byte *key, unsigned keySize)
+{
+ unsigned i, num;
+ UInt32 *w;
+ Aes_SetKeyEncode(p, key, keySize);
+ num = p->numRounds2 * 8 - 4;
+ w = p->rkey + 4;
+ for (i = 0; i < num; i++)
+ {
+ UInt32 r = w[i];
+ w[i] =
+ D[ Sbox[gb0(r)]] ^
+ D[0x100 + Sbox[gb1(r)]] ^
+ D[0x200 + Sbox[gb2(r)]] ^
+ D[0x300 + Sbox[gb3(r)]];
+ }
+}
+
+static void AesEncode32(UInt32 *dest, const UInt32 *src, const UInt32 *w, unsigned numRounds2)
+{
+ UInt32 s[4];
+ UInt32 m[4];
+ s[0] = src[0] ^ w[0];
+ s[1] = src[1] ^ w[1];
+ s[2] = src[2] ^ w[2];
+ s[3] = src[3] ^ w[3];
+ w += 4;
+ for (;;)
+ {
+ HT16(m, s, 0);
+ if (--numRounds2 == 0)
+ break;
+ HT16(s, m, 4);
+ w += 8;
+ }
+ w += 4;
+ FT4(0); FT4(1); FT4(2); FT4(3);
+}
+
+static void AesDecode32(UInt32 *dest, const UInt32 *src, const UInt32 *w, unsigned numRounds2)
+{
+ UInt32 s[4];
+ UInt32 m[4];
+ w += numRounds2 * 8;
+ s[0] = src[0] ^ w[0];
+ s[1] = src[1] ^ w[1];
+ s[2] = src[2] ^ w[2];
+ s[3] = src[3] ^ w[3];
+ for (;;)
+ {
+ w -= 8;
+ HD16(m, s, 4);
+ if (--numRounds2 == 0)
+ break;
+ HD16(s, m, 0);
+ }
+ FD4(0); FD4(1); FD4(2); FD4(3);
+}
+
+void Aes_Encode32(const CAes *p, UInt32 *dest, const UInt32 *src)
+{
+ AesEncode32(dest, src, p->rkey, p->numRounds2);
+}
+
+void Aes_Decode32(const CAes *p, UInt32 *dest, const UInt32 *src)
+{
+ AesDecode32(dest, src, p->rkey, p->numRounds2);
+}
+
+void AesCbc_Init(CAesCbc *p, const Byte *iv)
+{
+ unsigned i;
+ for (i = 0; i < 4; i++)
+ p->prev[i] = GetUi32(iv + i * 4);
+}
+
+SizeT AesCbc_Encode(CAesCbc *p, Byte *data, SizeT size)
+{
+ SizeT i;
+ if (size == 0)
+ return 0;
+ if (size < AES_BLOCK_SIZE)
+ return AES_BLOCK_SIZE;
+ size -= AES_BLOCK_SIZE;
+ for (i = 0; i <= size; i += AES_BLOCK_SIZE, data += AES_BLOCK_SIZE)
+ {
+ p->prev[0] ^= GetUi32(data);
+ p->prev[1] ^= GetUi32(data + 4);
+ p->prev[2] ^= GetUi32(data + 8);
+ p->prev[3] ^= GetUi32(data + 12);
+
+ AesEncode32(p->prev, p->prev, p->aes.rkey, p->aes.numRounds2);
+
+ SetUi32(data, p->prev[0]);
+ SetUi32(data + 4, p->prev[1]);
+ SetUi32(data + 8, p->prev[2]);
+ SetUi32(data + 12, p->prev[3]);
+ }
+ return i;
+}
+
+SizeT AesCbc_Decode(CAesCbc *p, Byte *data, SizeT size)
+{
+ SizeT i;
+ UInt32 in[4], out[4];
+ if (size == 0)
+ return 0;
+ if (size < AES_BLOCK_SIZE)
+ return AES_BLOCK_SIZE;
+ size -= AES_BLOCK_SIZE;
+ for (i = 0; i <= size; i += AES_BLOCK_SIZE, data += AES_BLOCK_SIZE)
+ {
+ in[0] = GetUi32(data);
+ in[1] = GetUi32(data + 4);
+ in[2] = GetUi32(data + 8);
+ in[3] = GetUi32(data + 12);
+
+ AesDecode32(out, in, p->aes.rkey, p->aes.numRounds2);
+
+ SetUi32(data, p->prev[0] ^ out[0]);
+ SetUi32(data + 4, p->prev[1] ^ out[1]);
+ SetUi32(data + 8, p->prev[2] ^ out[2]);
+ SetUi32(data + 12, p->prev[3] ^ out[3]);
+
+ p->prev[0] = in[0];
+ p->prev[1] = in[1];
+ p->prev[2] = in[2];
+ p->prev[3] = in[3];
+ }
+ return i;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Aes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Aes.h
new file mode 100644
index 000000000..5aa60955d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Aes.h
@@ -0,0 +1,54 @@
+/* Aes.h -- AES encryption / decryption
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __AES_H
+#define __AES_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AES_BLOCK_SIZE 16
+
+typedef struct
+{
+ unsigned numRounds2; /* = numRounds / 2 */
+ UInt32 rkey[(14 + 1) * 4];
+} CAes;
+
+/* Call AesGenTables one time before other AES functions */
+void AesGenTables(void);
+
+/* keySize = 16 or 24 or 32 (bytes) */
+void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize);
+void Aes_SetKeyDecode(CAes *p, const Byte *key, unsigned keySize);
+
+/* Aes_Encode32 and Aes_Decode32 functions work with little-endian words.
+ src and dest are pointers to 4 UInt32 words.
+ arc and dest can point to same block */
+void Aes_Encode32(const CAes *p, UInt32 *dest, const UInt32 *src);
+void Aes_Decode32(const CAes *p, UInt32 *dest, const UInt32 *src);
+
+typedef struct
+{
+ UInt32 prev[4];
+ CAes aes;
+} CAesCbc;
+
+void AesCbc_Init(CAesCbc *p, const Byte *iv); /* iv size is AES_BLOCK_SIZE */
+
+/* AesCbc_Encode and AesCbc_Decode:
+ if (res <= size): Filter have converted res bytes
+ if (res > size): Filter have not converted anything. And it needs at
+ least res = AES_BLOCK_SIZE bytes to convert one block */
+
+SizeT AesCbc_Encode(CAesCbc *p, Byte *data, SizeT size);
+SizeT AesCbc_Decode(CAesCbc *p, Byte *data, SizeT size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Alloc.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Alloc.c
new file mode 100644
index 000000000..358a7b526
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Alloc.c
@@ -0,0 +1,127 @@
+/* Alloc.c -- Memory allocation functions
+2008-09-24
+Igor Pavlov
+Public domain */
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#include <stdlib.h>
+
+#include "Alloc.h"
+
+/* #define _SZ_ALLOC_DEBUG */
+
+/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
+#ifdef _SZ_ALLOC_DEBUG
+#include <stdio.h>
+int g_allocCount = 0;
+int g_allocCountMid = 0;
+int g_allocCountBig = 0;
+#endif
+
+void *MyAlloc(size_t size)
+{
+ if (size == 0)
+ return 0;
+ #ifdef _SZ_ALLOC_DEBUG
+ {
+ void *p = malloc(size);
+ fprintf(stderr, "\nAlloc %10d bytes, count = %10d, addr = %8X", size, g_allocCount++, (unsigned)p);
+ return p;
+ }
+ #else
+ return malloc(size);
+ #endif
+}
+
+void MyFree(void *address)
+{
+ #ifdef _SZ_ALLOC_DEBUG
+ if (address != 0)
+ fprintf(stderr, "\nFree; count = %10d, addr = %8X", --g_allocCount, (unsigned)address);
+ #endif
+ free(address);
+}
+
+#ifdef _WIN32
+
+void *MidAlloc(size_t size)
+{
+ if (size == 0)
+ return 0;
+ #ifdef _SZ_ALLOC_DEBUG
+ fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++);
+ #endif
+ return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
+}
+
+void MidFree(void *address)
+{
+ #ifdef _SZ_ALLOC_DEBUG
+ if (address != 0)
+ fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
+ #endif
+ if (address == 0)
+ return;
+ VirtualFree(address, 0, MEM_RELEASE);
+}
+
+#ifndef MEM_LARGE_PAGES
+#undef _7ZIP_LARGE_PAGES
+#endif
+
+#ifdef _7ZIP_LARGE_PAGES
+SIZE_T g_LargePageSize = 0;
+typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
+#endif
+
+void SetLargePageSize()
+{
+ #ifdef _7ZIP_LARGE_PAGES
+ SIZE_T size = 0;
+ GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
+ GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
+ if (largePageMinimum == 0)
+ return;
+ size = largePageMinimum();
+ if (size == 0 || (size & (size - 1)) != 0)
+ return;
+ g_LargePageSize = size;
+ #endif
+}
+
+
+void *BigAlloc(size_t size)
+{
+ if (size == 0)
+ return 0;
+ #ifdef _SZ_ALLOC_DEBUG
+ fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
+ #endif
+
+ #ifdef _7ZIP_LARGE_PAGES
+ if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
+ {
+ void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
+ MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
+ if (res != 0)
+ return res;
+ }
+ #endif
+ return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
+}
+
+void BigFree(void *address)
+{
+ #ifdef _SZ_ALLOC_DEBUG
+ if (address != 0)
+ fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
+ #endif
+
+ if (address == 0)
+ return;
+ VirtualFree(address, 0, MEM_RELEASE);
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Alloc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Alloc.h
new file mode 100644
index 000000000..94a2186a0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Alloc.h
@@ -0,0 +1,42 @@
+/* Alloc.h -- Memory allocation functions
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __COMMON_ALLOC_H
+#define __COMMON_ALLOC_H
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *MyAlloc(size_t size);
+void MyFree(void *address);
+
+#ifdef _WIN32
+
+void SetLargePageSize();
+
+void *MidAlloc(size_t size);
+void MidFree(void *address);
+void *BigAlloc(size_t size);
+void BigFree(void *address);
+
+#else
+
+#include <stdlib.h> /* malloc */
+
+#define MyAlloc(size) malloc(size)
+#define MyFree(address) free(address)
+#define MidAlloc(size) malloc(size)
+#define MidFree(address) free(address)
+#define BigAlloc(size) malloc(size)
+#define BigFree(address) free(address)
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra.c
new file mode 100644
index 000000000..0f4742802
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra.c
@@ -0,0 +1,133 @@
+/* Bra.c -- Converters for RISC code
+2008-10-04 : Igor Pavlov : Public domain */
+
+#include "Bra.h"
+
+SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+{
+ SizeT i;
+ if (size < 4)
+ return 0;
+ size -= 4;
+ ip += 8;
+ for (i = 0; i <= size; i += 4)
+ {
+ if (data[i + 3] == 0xEB)
+ {
+ UInt32 dest;
+ UInt32 src = ((UInt32)data[i + 2] << 16) | ((UInt32)data[i + 1] << 8) | (data[i + 0]);
+ src <<= 2;
+ if (encoding)
+ dest = ip + (UInt32)i + src;
+ else
+ dest = src - (ip + (UInt32)i);
+ dest >>= 2;
+ data[i + 2] = (Byte)(dest >> 16);
+ data[i + 1] = (Byte)(dest >> 8);
+ data[i + 0] = (Byte)dest;
+ }
+ }
+ return i;
+}
+
+SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+{
+ SizeT i;
+ if (size < 4)
+ return 0;
+ size -= 4;
+ ip += 4;
+ for (i = 0; i <= size; i += 2)
+ {
+ if ((data[i + 1] & 0xF8) == 0xF0 &&
+ (data[i + 3] & 0xF8) == 0xF8)
+ {
+ UInt32 dest;
+ UInt32 src =
+ (((UInt32)data[i + 1] & 0x7) << 19) |
+ ((UInt32)data[i + 0] << 11) |
+ (((UInt32)data[i + 3] & 0x7) << 8) |
+ (data[i + 2]);
+
+ src <<= 1;
+ if (encoding)
+ dest = ip + (UInt32)i + src;
+ else
+ dest = src - (ip + (UInt32)i);
+ dest >>= 1;
+
+ data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7));
+ data[i + 0] = (Byte)(dest >> 11);
+ data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7));
+ data[i + 2] = (Byte)dest;
+ i += 2;
+ }
+ }
+ return i;
+}
+
+SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+{
+ SizeT i;
+ if (size < 4)
+ return 0;
+ size -= 4;
+ for (i = 0; i <= size; i += 4)
+ {
+ if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1)
+ {
+ UInt32 src = ((UInt32)(data[i + 0] & 3) << 24) |
+ ((UInt32)data[i + 1] << 16) |
+ ((UInt32)data[i + 2] << 8) |
+ ((UInt32)data[i + 3] & (~3));
+
+ UInt32 dest;
+ if (encoding)
+ dest = ip + (UInt32)i + src;
+ else
+ dest = src - (ip + (UInt32)i);
+ data[i + 0] = (Byte)(0x48 | ((dest >> 24) & 0x3));
+ data[i + 1] = (Byte)(dest >> 16);
+ data[i + 2] = (Byte)(dest >> 8);
+ data[i + 3] &= 0x3;
+ data[i + 3] |= dest;
+ }
+ }
+ return i;
+}
+
+SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+{
+ UInt32 i;
+ if (size < 4)
+ return 0;
+ size -= 4;
+ for (i = 0; i <= size; i += 4)
+ {
+ if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00 ) ||
+ (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0))
+ {
+ UInt32 src =
+ ((UInt32)data[i + 0] << 24) |
+ ((UInt32)data[i + 1] << 16) |
+ ((UInt32)data[i + 2] << 8) |
+ ((UInt32)data[i + 3]);
+ UInt32 dest;
+
+ src <<= 2;
+ if (encoding)
+ dest = ip + i + src;
+ else
+ dest = src - (ip + i);
+ dest >>= 2;
+
+ dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000;
+
+ data[i + 0] = (Byte)(dest >> 24);
+ data[i + 1] = (Byte)(dest >> 16);
+ data[i + 2] = (Byte)(dest >> 8);
+ data[i + 3] = (Byte)dest;
+ }
+ }
+ return i;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra.h
new file mode 100644
index 000000000..5748c1c05
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra.h
@@ -0,0 +1,68 @@
+/* Bra.h -- Branch converters for executables
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __BRA_H
+#define __BRA_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+These functions convert relative addresses to absolute addresses
+in CALL instructions to increase the compression ratio.
+
+ In:
+ data - data buffer
+ size - size of data
+ ip - current virtual Instruction Pinter (IP) value
+ state - state variable for x86 converter
+ encoding - 0 (for decoding), 1 (for encoding)
+
+ Out:
+ state - state variable for x86 converter
+
+ Returns:
+ The number of processed bytes. If you call these functions with multiple calls,
+ you must start next call with first byte after block of processed bytes.
+
+ Type Endian Alignment LookAhead
+
+ x86 little 1 4
+ ARMT little 2 2
+ ARM little 4 0
+ PPC big 4 0
+ SPARC big 4 0
+ IA64 little 16 0
+
+ size must be >= Alignment + LookAhead, if it's not last block.
+ If (size < Alignment + LookAhead), converter returns 0.
+
+ Example:
+
+ UInt32 ip = 0;
+ for ()
+ {
+ ; size must be >= Alignment + LookAhead, if it's not last block
+ SizeT processed = Convert(data, size, ip, 1);
+ data += processed;
+ size -= processed;
+ ip += processed;
+ }
+*/
+
+#define x86_Convert_Init(state) { state = 0; }
+SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding);
+SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra86.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra86.c
new file mode 100644
index 000000000..1ee0e709b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Bra86.c
@@ -0,0 +1,85 @@
+/* Bra86.c -- Converter for x86 code (BCJ)
+2008-10-04 : Igor Pavlov : Public domain */
+
+#include "Bra.h"
+
+#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
+
+const Byte kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0};
+const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3};
+
+SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)
+{
+ SizeT bufferPos = 0, prevPosT;
+ UInt32 prevMask = *state & 0x7;
+ if (size < 5)
+ return 0;
+ ip += 5;
+ prevPosT = (SizeT)0 - 1;
+
+ for (;;)
+ {
+ Byte *p = data + bufferPos;
+ Byte *limit = data + size - 4;
+ for (; p < limit; p++)
+ if ((*p & 0xFE) == 0xE8)
+ break;
+ bufferPos = (SizeT)(p - data);
+ if (p >= limit)
+ break;
+ prevPosT = bufferPos - prevPosT;
+ if (prevPosT > 3)
+ prevMask = 0;
+ else
+ {
+ prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7;
+ if (prevMask != 0)
+ {
+ Byte b = p[4 - kMaskToBitNumber[prevMask]];
+ if (!kMaskToAllowedStatus[prevMask] || Test86MSByte(b))
+ {
+ prevPosT = bufferPos;
+ prevMask = ((prevMask << 1) & 0x7) | 1;
+ bufferPos++;
+ continue;
+ }
+ }
+ }
+ prevPosT = bufferPos;
+
+ if (Test86MSByte(p[4]))
+ {
+ UInt32 src = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
+ UInt32 dest;
+ for (;;)
+ {
+ Byte b;
+ int index;
+ if (encoding)
+ dest = (ip + (UInt32)bufferPos) + src;
+ else
+ dest = src - (ip + (UInt32)bufferPos);
+ if (prevMask == 0)
+ break;
+ index = kMaskToBitNumber[prevMask] * 8;
+ b = (Byte)(dest >> (24 - index));
+ if (!Test86MSByte(b))
+ break;
+ src = dest ^ ((1 << (32 - index)) - 1);
+ }
+ p[4] = (Byte)(~(((dest >> 24) & 1) - 1));
+ p[3] = (Byte)(dest >> 16);
+ p[2] = (Byte)(dest >> 8);
+ p[1] = (Byte)dest;
+ bufferPos += 5;
+ }
+ else
+ {
+ prevMask = ((prevMask << 1) & 0x7) | 1;
+ bufferPos++;
+ }
+ }
+ prevPosT = bufferPos - prevPosT;
+ *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7));
+ return bufferPos;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BraIA64.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BraIA64.c
new file mode 100644
index 000000000..0b4ee85bc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BraIA64.c
@@ -0,0 +1,67 @@
+/* BraIA64.c -- Converter for IA-64 code
+2008-10-04 : Igor Pavlov : Public domain */
+
+#include "Bra.h"
+
+static const Byte kBranchTable[32] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 4, 4, 6, 6, 0, 0, 7, 7,
+ 4, 4, 0, 0, 4, 4, 0, 0
+};
+
+SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+{
+ SizeT i;
+ if (size < 16)
+ return 0;
+ size -= 16;
+ for (i = 0; i <= size; i += 16)
+ {
+ UInt32 instrTemplate = data[i] & 0x1F;
+ UInt32 mask = kBranchTable[instrTemplate];
+ UInt32 bitPos = 5;
+ int slot;
+ for (slot = 0; slot < 3; slot++, bitPos += 41)
+ {
+ UInt32 bytePos, bitRes;
+ UInt64 instruction, instNorm;
+ int j;
+ if (((mask >> slot) & 1) == 0)
+ continue;
+ bytePos = (bitPos >> 3);
+ bitRes = bitPos & 0x7;
+ instruction = 0;
+ for (j = 0; j < 6; j++)
+ instruction += (UInt64)data[i + j + bytePos] << (8 * j);
+
+ instNorm = instruction >> bitRes;
+ if (((instNorm >> 37) & 0xF) == 0x5 && ((instNorm >> 9) & 0x7) == 0)
+ {
+ UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
+ UInt32 dest;
+ src |= ((UInt32)(instNorm >> 36) & 1) << 20;
+
+ src <<= 4;
+
+ if (encoding)
+ dest = ip + (UInt32)i + src;
+ else
+ dest = src - (ip + (UInt32)i);
+
+ dest >>= 4;
+
+ instNorm &= ~((UInt64)(0x8FFFFF) << 13);
+ instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
+ instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
+
+ instruction &= (1 << bitRes) - 1;
+ instruction |= (instNorm << bitRes);
+ for (j = 0; j < 6; j++)
+ data[i + j + bytePos] = (Byte)(instruction >> (8 * j));
+ }
+ }
+ }
+ return i;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BwtSort.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BwtSort.c
new file mode 100644
index 000000000..207305072
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BwtSort.c
@@ -0,0 +1,516 @@
+/* BwtSort.c -- BWT block sorting
+2008-08-17
+Igor Pavlov
+Public domain */
+
+#include "BwtSort.h"
+#include "Sort.h"
+
+/* #define BLOCK_SORT_USE_HEAP_SORT */
+
+#define NO_INLINE MY_FAST_CALL
+
+/* Don't change it !!! */
+#define kNumHashBytes 2
+#define kNumHashValues (1 << (kNumHashBytes * 8))
+
+/* kNumRefBitsMax must be < (kNumHashBytes * 8) = 16 */
+#define kNumRefBitsMax 12
+
+#define BS_TEMP_SIZE kNumHashValues
+
+#ifdef BLOCK_SORT_EXTERNAL_FLAGS
+
+/* 32 Flags in UInt32 word */
+#define kNumFlagsBits 5
+#define kNumFlagsInWord (1 << kNumFlagsBits)
+#define kFlagsMask (kNumFlagsInWord - 1)
+#define kAllFlags 0xFFFFFFFF
+
+#else
+
+#define kNumBitsMax 20
+#define kIndexMask ((1 << kNumBitsMax) - 1)
+#define kNumExtraBits (32 - kNumBitsMax)
+#define kNumExtra0Bits (kNumExtraBits - 2)
+#define kNumExtra0Mask ((1 << kNumExtra0Bits) - 1)
+
+#define SetFinishedGroupSize(p, size) \
+ { *(p) |= ((((size) - 1) & kNumExtra0Mask) << kNumBitsMax); \
+ if ((size) > (1 << kNumExtra0Bits)) { \
+ *(p) |= 0x40000000; *((p) + 1) |= ((((size) - 1)>> kNumExtra0Bits) << kNumBitsMax); } } \
+
+static void SetGroupSize(UInt32 *p, UInt32 size)
+{
+ if (--size == 0)
+ return;
+ *p |= 0x80000000 | ((size & kNumExtra0Mask) << kNumBitsMax);
+ if (size >= (1 << kNumExtra0Bits))
+ {
+ *p |= 0x40000000;
+ p[1] |= ((size >> kNumExtra0Bits) << kNumBitsMax);
+ }
+}
+
+#endif
+
+/*
+SortGroup - is recursive Range-Sort function with HeapSort optimization for small blocks
+ "range" is not real range. It's only for optimization.
+returns: 1 - if there are groups, 0 - no more groups
+*/
+
+UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 groupOffset, UInt32 groupSize, int NumRefBits, UInt32 *Indices
+ #ifndef BLOCK_SORT_USE_HEAP_SORT
+ , UInt32 left, UInt32 range
+ #endif
+ )
+{
+ UInt32 *ind2 = Indices + groupOffset;
+ UInt32 *Groups;
+ if (groupSize <= 1)
+ {
+ /*
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetFinishedGroupSize(ind2, 1);
+ #endif
+ */
+ return 0;
+ }
+ Groups = Indices + BlockSize + BS_TEMP_SIZE;
+ if (groupSize <= ((UInt32)1 << NumRefBits)
+ #ifndef BLOCK_SORT_USE_HEAP_SORT
+ && groupSize <= range
+ #endif
+ )
+ {
+ UInt32 *temp = Indices + BlockSize;
+ UInt32 j;
+ UInt32 mask, thereAreGroups, group, cg;
+ {
+ UInt32 gPrev;
+ UInt32 gRes = 0;
+ {
+ UInt32 sp = ind2[0] + NumSortedBytes;
+ if (sp >= BlockSize) sp -= BlockSize;
+ gPrev = Groups[sp];
+ temp[0] = (gPrev << NumRefBits);
+ }
+
+ for (j = 1; j < groupSize; j++)
+ {
+ UInt32 sp = ind2[j] + NumSortedBytes;
+ UInt32 g;
+ if (sp >= BlockSize) sp -= BlockSize;
+ g = Groups[sp];
+ temp[j] = (g << NumRefBits) | j;
+ gRes |= (gPrev ^ g);
+ }
+ if (gRes == 0)
+ {
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(ind2, groupSize);
+ #endif
+ return 1;
+ }
+ }
+
+ HeapSort(temp, groupSize);
+ mask = ((1 << NumRefBits) - 1);
+ thereAreGroups = 0;
+
+ group = groupOffset;
+ cg = (temp[0] >> NumRefBits);
+ temp[0] = ind2[temp[0] & mask];
+
+ {
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 *Flags = Groups + BlockSize;
+ #else
+ UInt32 prevGroupStart = 0;
+ #endif
+
+ for (j = 1; j < groupSize; j++)
+ {
+ UInt32 val = temp[j];
+ UInt32 cgCur = (val >> NumRefBits);
+
+ if (cgCur != cg)
+ {
+ cg = cgCur;
+ group = groupOffset + j;
+
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ {
+ UInt32 t = group - 1;
+ Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
+ }
+ #else
+ SetGroupSize(temp + prevGroupStart, j - prevGroupStart);
+ prevGroupStart = j;
+ #endif
+ }
+ else
+ thereAreGroups = 1;
+ {
+ UInt32 ind = ind2[val & mask];
+ temp[j] = ind;
+ Groups[ind] = group;
+ }
+ }
+
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(temp + prevGroupStart, j - prevGroupStart);
+ #endif
+ }
+
+ for (j = 0; j < groupSize; j++)
+ ind2[j] = temp[j];
+ return thereAreGroups;
+ }
+
+ /* Check that all strings are in one group (cannot sort) */
+ {
+ UInt32 group, j;
+ UInt32 sp = ind2[0] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ group = Groups[sp];
+ for (j = 1; j < groupSize; j++)
+ {
+ sp = ind2[j] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ if (Groups[sp] != group)
+ break;
+ }
+ if (j == groupSize)
+ {
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(ind2, groupSize);
+ #endif
+ return 1;
+ }
+ }
+
+ #ifndef BLOCK_SORT_USE_HEAP_SORT
+ {
+ /* ---------- Range Sort ---------- */
+ UInt32 i;
+ UInt32 mid;
+ for (;;)
+ {
+ UInt32 j;
+ if (range <= 1)
+ {
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(ind2, groupSize);
+ #endif
+ return 1;
+ }
+ mid = left + ((range + 1) >> 1);
+ j = groupSize;
+ i = 0;
+ do
+ {
+ UInt32 sp = ind2[i] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ if (Groups[sp] >= mid)
+ {
+ for (j--; j > i; j--)
+ {
+ sp = ind2[j] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ if (Groups[sp] < mid)
+ {
+ UInt32 temp = ind2[i]; ind2[i] = ind2[j]; ind2[j] = temp;
+ break;
+ }
+ }
+ if (i >= j)
+ break;
+ }
+ }
+ while (++i < j);
+ if (i == 0)
+ {
+ range = range - (mid - left);
+ left = mid;
+ }
+ else if (i == groupSize)
+ range = (mid - left);
+ else
+ break;
+ }
+
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ {
+ UInt32 t = (groupOffset + i - 1);
+ UInt32 *Flags = Groups + BlockSize;
+ Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
+ }
+ #endif
+
+ {
+ UInt32 j;
+ for (j = i; j < groupSize; j++)
+ Groups[ind2[j]] = groupOffset + i;
+ }
+
+ {
+ UInt32 res = SortGroup(BlockSize, NumSortedBytes, groupOffset, i, NumRefBits, Indices, left, mid - left);
+ return res | SortGroup(BlockSize, NumSortedBytes, groupOffset + i, groupSize - i, NumRefBits, Indices, mid, range - (mid - left));
+ }
+
+ }
+
+ #else
+
+ /* ---------- Heap Sort ---------- */
+
+ {
+ UInt32 j;
+ for (j = 0; j < groupSize; j++)
+ {
+ UInt32 sp = ind2[j] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ ind2[j] = sp;
+ }
+
+ HeapSortRef(ind2, Groups, groupSize);
+
+ /* Write Flags */
+ {
+ UInt32 sp = ind2[0];
+ UInt32 group = Groups[sp];
+
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 *Flags = Groups + BlockSize;
+ #else
+ UInt32 prevGroupStart = 0;
+ #endif
+
+ for (j = 1; j < groupSize; j++)
+ {
+ sp = ind2[j];
+ if (Groups[sp] != group)
+ {
+ group = Groups[sp];
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ {
+ UInt32 t = groupOffset + j - 1;
+ Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
+ }
+ #else
+ SetGroupSize(ind2 + prevGroupStart, j - prevGroupStart);
+ prevGroupStart = j;
+ #endif
+ }
+ }
+
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(ind2 + prevGroupStart, j - prevGroupStart);
+ #endif
+ }
+ {
+ /* Write new Groups values and Check that there are groups */
+ UInt32 thereAreGroups = 0;
+ for (j = 0; j < groupSize; j++)
+ {
+ UInt32 group = groupOffset + j;
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 subGroupSize = ((ind2[j] & ~0xC0000000) >> kNumBitsMax);
+ if ((ind2[j] & 0x40000000) != 0)
+ subGroupSize += ((ind2[j + 1] >> kNumBitsMax) << kNumExtra0Bits);
+ subGroupSize++;
+ for (;;)
+ {
+ UInt32 original = ind2[j];
+ UInt32 sp = original & kIndexMask;
+ if (sp < NumSortedBytes) sp += BlockSize; sp -= NumSortedBytes;
+ ind2[j] = sp | (original & ~kIndexMask);
+ Groups[sp] = group;
+ if (--subGroupSize == 0)
+ break;
+ j++;
+ thereAreGroups = 1;
+ }
+ #else
+ UInt32 *Flags = Groups + BlockSize;
+ for (;;)
+ {
+ UInt32 sp = ind2[j]; if (sp < NumSortedBytes) sp += BlockSize; sp -= NumSortedBytes;
+ ind2[j] = sp;
+ Groups[sp] = group;
+ if ((Flags[(groupOffset + j) >> kNumFlagsBits] & (1 << ((groupOffset + j) & kFlagsMask))) == 0)
+ break;
+ j++;
+ thereAreGroups = 1;
+ }
+ #endif
+ }
+ return thereAreGroups;
+ }
+ }
+ #endif
+}
+
+/* conditions: blockSize > 0 */
+UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
+{
+ UInt32 *counters = Indices + blockSize;
+ UInt32 i;
+ UInt32 *Groups;
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 *Flags;
+ #endif
+
+ /* Radix-Sort for 2 bytes */
+ for (i = 0; i < kNumHashValues; i++)
+ counters[i] = 0;
+ for (i = 0; i < blockSize - 1; i++)
+ counters[((UInt32)data[i] << 8) | data[i + 1]]++;
+ counters[((UInt32)data[i] << 8) | data[0]]++;
+
+ Groups = counters + BS_TEMP_SIZE;
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ Flags = Groups + blockSize;
+ {
+ UInt32 numWords = (blockSize + kFlagsMask) >> kNumFlagsBits;
+ for (i = 0; i < numWords; i++)
+ Flags[i] = kAllFlags;
+ }
+ #endif
+
+ {
+ UInt32 sum = 0;
+ for (i = 0; i < kNumHashValues; i++)
+ {
+ UInt32 groupSize = counters[i];
+ if (groupSize > 0)
+ {
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 t = sum + groupSize - 1;
+ Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
+ #endif
+ sum += groupSize;
+ }
+ counters[i] = sum - groupSize;
+ }
+
+ for (i = 0; i < blockSize - 1; i++)
+ Groups[i] = counters[((UInt32)data[i] << 8) | data[i + 1]];
+ Groups[i] = counters[((UInt32)data[i] << 8) | data[0]];
+
+ for (i = 0; i < blockSize - 1; i++)
+ Indices[counters[((UInt32)data[i] << 8) | data[i + 1]]++] = i;
+ Indices[counters[((UInt32)data[i] << 8) | data[0]]++] = i;
+
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ {
+ UInt32 prev = 0;
+ for (i = 0; i < kNumHashValues; i++)
+ {
+ UInt32 prevGroupSize = counters[i] - prev;
+ if (prevGroupSize == 0)
+ continue;
+ SetGroupSize(Indices + prev, prevGroupSize);
+ prev = counters[i];
+ }
+ }
+ #endif
+ }
+
+ {
+ int NumRefBits;
+ UInt32 NumSortedBytes;
+ for (NumRefBits = 0; ((blockSize - 1) >> NumRefBits) != 0; NumRefBits++);
+ NumRefBits = 32 - NumRefBits;
+ if (NumRefBits > kNumRefBitsMax)
+ NumRefBits = kNumRefBitsMax;
+
+ for (NumSortedBytes = kNumHashBytes; ; NumSortedBytes <<= 1)
+ {
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 finishedGroupSize = 0;
+ #endif
+ UInt32 newLimit = 0;
+ for (i = 0; i < blockSize;)
+ {
+ UInt32 groupSize;
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+
+ if ((Flags[i >> kNumFlagsBits] & (1 << (i & kFlagsMask))) == 0)
+ {
+ i++;
+ continue;
+ }
+ for (groupSize = 1;
+ (Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0;
+ groupSize++);
+
+ groupSize++;
+
+ #else
+
+ groupSize = ((Indices[i] & ~0xC0000000) >> kNumBitsMax);
+ {
+ Bool finishedGroup = ((Indices[i] & 0x80000000) == 0);
+ if ((Indices[i] & 0x40000000) != 0)
+ {
+ groupSize += ((Indices[i + 1] >> kNumBitsMax) << kNumExtra0Bits);
+ Indices[i + 1] &= kIndexMask;
+ }
+ Indices[i] &= kIndexMask;
+ groupSize++;
+ if (finishedGroup || groupSize == 1)
+ {
+ Indices[i - finishedGroupSize] &= kIndexMask;
+ if (finishedGroupSize > 1)
+ Indices[i - finishedGroupSize + 1] &= kIndexMask;
+ {
+ UInt32 newGroupSize = groupSize + finishedGroupSize;
+ SetFinishedGroupSize(Indices + i - finishedGroupSize, newGroupSize);
+ finishedGroupSize = newGroupSize;
+ }
+ i += groupSize;
+ continue;
+ }
+ finishedGroupSize = 0;
+ }
+
+ #endif
+
+ if (NumSortedBytes >= blockSize)
+ {
+ UInt32 j;
+ for (j = 0; j < groupSize; j++)
+ {
+ UInt32 t = (i + j);
+ /* Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask)); */
+ Groups[Indices[t]] = t;
+ }
+ }
+ else
+ if (SortGroup(blockSize, NumSortedBytes, i, groupSize, NumRefBits, Indices
+ #ifndef BLOCK_SORT_USE_HEAP_SORT
+ , 0, blockSize
+ #endif
+ ) != 0)
+ newLimit = i + groupSize;
+ i += groupSize;
+ }
+ if (newLimit == 0)
+ break;
+ }
+ }
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ for (i = 0; i < blockSize;)
+ {
+ UInt32 groupSize = ((Indices[i] & ~0xC0000000) >> kNumBitsMax);
+ if ((Indices[i] & 0x40000000) != 0)
+ {
+ groupSize += ((Indices[i + 1] >> kNumBitsMax) << kNumExtra0Bits);
+ Indices[i + 1] &= kIndexMask;
+ }
+ Indices[i] &= kIndexMask;
+ groupSize++;
+ i += groupSize;
+ }
+ #endif
+ return Groups[0];
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BwtSort.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BwtSort.h
new file mode 100644
index 000000000..ce5598f0f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/BwtSort.h
@@ -0,0 +1,30 @@
+/* BwtSort.h -- BWT block sorting
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __BWT_SORT_H
+#define __BWT_SORT_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* use BLOCK_SORT_EXTERNAL_FLAGS if blockSize can be > 1M */
+/* #define BLOCK_SORT_EXTERNAL_FLAGS */
+
+#ifdef BLOCK_SORT_EXTERNAL_FLAGS
+#define BLOCK_SORT_EXTERNAL_SIZE(blockSize) ((((blockSize) + 31) >> 5))
+#else
+#define BLOCK_SORT_EXTERNAL_SIZE(blockSize) 0
+#endif
+
+#define BLOCK_SORT_BUF_SIZE(blockSize) ((blockSize) * 2 + BLOCK_SORT_EXTERNAL_SIZE(blockSize) + (1 << 16))
+
+UInt32 BlockSort(UInt32 *indices, const Byte *data, UInt32 blockSize);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/CpuArch.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/CpuArch.h
new file mode 100644
index 000000000..10ec02b37
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/CpuArch.h
@@ -0,0 +1,80 @@
+/* CpuArch.h
+2009-03-22 : Igor Pavlov : Public domain */
+
+#ifndef __CPU_ARCH_H
+#define __CPU_ARCH_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+LITTLE_ENDIAN_UNALIGN means:
+ 1) CPU is LITTLE_ENDIAN
+ 2) it's allowed to make unaligned memory accesses
+if LITTLE_ENDIAN_UNALIGN is not defined, it means that we don't know
+about these properties of platform.
+*/
+
+#if defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(__i386__) || defined(__x86_64__)
+#define LITTLE_ENDIAN_UNALIGN
+#endif
+
+#ifdef LITTLE_ENDIAN_UNALIGN
+
+#define GetUi16(p) (*(const UInt16 *)(p))
+#define GetUi32(p) (*(const UInt32 *)(p))
+#define GetUi64(p) (*(const UInt64 *)(p))
+#define SetUi16(p, d) *(UInt16 *)(p) = (d);
+#define SetUi32(p, d) *(UInt32 *)(p) = (d);
+
+#else
+
+#define GetUi16(p) (((const Byte *)(p))[0] | ((UInt16)((const Byte *)(p))[1] << 8))
+
+#define GetUi32(p) ( \
+ ((const Byte *)(p))[0] | \
+ ((UInt32)((const Byte *)(p))[1] << 8) | \
+ ((UInt32)((const Byte *)(p))[2] << 16) | \
+ ((UInt32)((const Byte *)(p))[3] << 24))
+
+#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))
+
+#define SetUi16(p, d) { UInt32 _x_ = (d); \
+ ((Byte *)(p))[0] = (Byte)_x_; \
+ ((Byte *)(p))[1] = (Byte)(_x_ >> 8); }
+
+#define SetUi32(p, d) { UInt32 _x_ = (d); \
+ ((Byte *)(p))[0] = (Byte)_x_; \
+ ((Byte *)(p))[1] = (Byte)(_x_ >> 8); \
+ ((Byte *)(p))[2] = (Byte)(_x_ >> 16); \
+ ((Byte *)(p))[3] = (Byte)(_x_ >> 24); }
+
+#endif
+
+#if defined(LITTLE_ENDIAN_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300)
+
+#pragma intrinsic(_byteswap_ulong)
+#pragma intrinsic(_byteswap_uint64)
+#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
+#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
+
+#else
+
+#define GetBe32(p) ( \
+ ((UInt32)((const Byte *)(p))[0] << 24) | \
+ ((UInt32)((const Byte *)(p))[1] << 16) | \
+ ((UInt32)((const Byte *)(p))[2] << 8) | \
+ ((const Byte *)(p))[3] )
+
+#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
+
+#endif
+
+#define GetBe16(p) (((UInt16)((const Byte *)(p))[0] << 8) | ((const Byte *)(p))[1])
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Delta.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Delta.c
new file mode 100644
index 000000000..2b327f15f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Delta.c
@@ -0,0 +1,62 @@
+/* Delta.c -- Delta converter
+2009-05-26 : Igor Pavlov : Public domain */
+
+#include "Delta.h"
+
+void Delta_Init(Byte *state)
+{
+ unsigned i;
+ for (i = 0; i < DELTA_STATE_SIZE; i++)
+ state[i] = 0;
+}
+
+static void MyMemCpy(Byte *dest, const Byte *src, unsigned size)
+{
+ unsigned i;
+ for (i = 0; i < size; i++)
+ dest[i] = src[i];
+}
+
+void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size)
+{
+ Byte buf[DELTA_STATE_SIZE];
+ unsigned j = 0;
+ MyMemCpy(buf, state, delta);
+ {
+ SizeT i;
+ for (i = 0; i < size;)
+ {
+ for (j = 0; j < delta && i < size; i++, j++)
+ {
+ Byte b = data[i];
+ data[i] = (Byte)(b - buf[j]);
+ buf[j] = b;
+ }
+ }
+ }
+ if (j == delta)
+ j = 0;
+ MyMemCpy(state, buf + j, delta - j);
+ MyMemCpy(state + delta - j, buf, j);
+}
+
+void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size)
+{
+ Byte buf[DELTA_STATE_SIZE];
+ unsigned j = 0;
+ MyMemCpy(buf, state, delta);
+ {
+ SizeT i;
+ for (i = 0; i < size;)
+ {
+ for (j = 0; j < delta && i < size; i++, j++)
+ {
+ buf[j] = data[i] = (Byte)(buf[j] + data[i]);
+ }
+ }
+ }
+ if (j == delta)
+ j = 0;
+ MyMemCpy(state, buf + j, delta - j);
+ MyMemCpy(state + delta - j, buf, j);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Delta.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Delta.h
new file mode 100644
index 000000000..0d4cd6274
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Delta.h
@@ -0,0 +1,23 @@
+/* Delta.h -- Delta converter
+2009-04-15 : Igor Pavlov : Public domain */
+
+#ifndef __DELTA_H
+#define __DELTA_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DELTA_STATE_SIZE 256
+
+void Delta_Init(Byte *state);
+void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size);
+void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/HuffEnc.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/HuffEnc.c
new file mode 100644
index 000000000..6e58d2cef
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/HuffEnc.c
@@ -0,0 +1,148 @@
+/* HuffEnc.c -- functions for Huffman encoding
+2008-08-05
+Igor Pavlov
+Public domain */
+
+#include "HuffEnc.h"
+#include "Sort.h"
+
+#define kMaxLen 16
+#define NUM_BITS 10
+#define MASK ((1 << NUM_BITS) - 1)
+
+#define NUM_COUNTERS 64
+
+#define HUFFMAN_SPEED_OPT
+
+void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymbols, UInt32 maxLen)
+{
+ UInt32 num = 0;
+ /* if (maxLen > 10) maxLen = 10; */
+ {
+ UInt32 i;
+
+ #ifdef HUFFMAN_SPEED_OPT
+
+ UInt32 counters[NUM_COUNTERS];
+ for (i = 0; i < NUM_COUNTERS; i++)
+ counters[i] = 0;
+ for (i = 0; i < numSymbols; i++)
+ {
+ UInt32 freq = freqs[i];
+ counters[(freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1]++;
+ }
+
+ for (i = 1; i < NUM_COUNTERS; i++)
+ {
+ UInt32 temp = counters[i];
+ counters[i] = num;
+ num += temp;
+ }
+
+ for (i = 0; i < numSymbols; i++)
+ {
+ UInt32 freq = freqs[i];
+ if (freq == 0)
+ lens[i] = 0;
+ else
+ p[counters[((freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1)]++] = i | (freq << NUM_BITS);
+ }
+ counters[0] = 0;
+ HeapSort(p + counters[NUM_COUNTERS - 2], counters[NUM_COUNTERS - 1] - counters[NUM_COUNTERS - 2]);
+
+ #else
+
+ for (i = 0; i < numSymbols; i++)
+ {
+ UInt32 freq = freqs[i];
+ if (freq == 0)
+ lens[i] = 0;
+ else
+ p[num++] = i | (freq << NUM_BITS);
+ }
+ HeapSort(p, num);
+
+ #endif
+ }
+
+ if (num < 2)
+ {
+ int minCode = 0;
+ int maxCode = 1;
+ if (num == 1)
+ {
+ maxCode = (int)(p[0] & MASK);
+ if (maxCode == 0)
+ maxCode++;
+ }
+ p[minCode] = 0;
+ p[maxCode] = 1;
+ lens[minCode] = lens[maxCode] = 1;
+ return;
+ }
+
+ {
+ UInt32 b, e, i;
+
+ i = b = e = 0;
+ do
+ {
+ UInt32 n, m, freq;
+ n = (i != num && (b == e || (p[i] >> NUM_BITS) <= (p[b] >> NUM_BITS))) ? i++ : b++;
+ freq = (p[n] & ~MASK);
+ p[n] = (p[n] & MASK) | (e << NUM_BITS);
+ m = (i != num && (b == e || (p[i] >> NUM_BITS) <= (p[b] >> NUM_BITS))) ? i++ : b++;
+ freq += (p[m] & ~MASK);
+ p[m] = (p[m] & MASK) | (e << NUM_BITS);
+ p[e] = (p[e] & MASK) | freq;
+ e++;
+ }
+ while (num - e > 1);
+
+ {
+ UInt32 lenCounters[kMaxLen + 1];
+ for (i = 0; i <= kMaxLen; i++)
+ lenCounters[i] = 0;
+
+ p[--e] &= MASK;
+ lenCounters[1] = 2;
+ while (e > 0)
+ {
+ UInt32 len = (p[p[--e] >> NUM_BITS] >> NUM_BITS) + 1;
+ p[e] = (p[e] & MASK) | (len << NUM_BITS);
+ if (len >= maxLen)
+ for (len = maxLen - 1; lenCounters[len] == 0; len--);
+ lenCounters[len]--;
+ lenCounters[len + 1] += 2;
+ }
+
+ {
+ UInt32 len;
+ i = 0;
+ for (len = maxLen; len != 0; len--)
+ {
+ UInt32 num;
+ for (num = lenCounters[len]; num != 0; num--)
+ lens[p[i++] & MASK] = (Byte)len;
+ }
+ }
+
+ {
+ UInt32 nextCodes[kMaxLen + 1];
+ {
+ UInt32 code = 0;
+ UInt32 len;
+ for (len = 1; len <= kMaxLen; len++)
+ nextCodes[len] = code = (code + lenCounters[len - 1]) << 1;
+ }
+ /* if (code + lenCounters[kMaxLen] - 1 != (1 << kMaxLen) - 1) throw 1; */
+
+ {
+ UInt32 i;
+ for (i = 0; i < numSymbols; i++)
+ p[i] = nextCodes[lens[i]]++;
+ }
+ }
+ }
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/HuffEnc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/HuffEnc.h
new file mode 100644
index 000000000..9cf4bfde8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/HuffEnc.h
@@ -0,0 +1,27 @@
+/* HuffEnc.h -- Huffman encoding
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __HUFF_ENC_H
+#define __HUFF_ENC_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+Conditions:
+ num <= 1024 = 2 ^ NUM_BITS
+ Sum(freqs) < 4M = 2 ^ (32 - NUM_BITS)
+ maxLen <= 16 = kMaxLen
+ Num_Items(p) >= HUFFMAN_TEMP_SIZE(num)
+*/
+
+void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFind.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFind.c
new file mode 100644
index 000000000..e3ecb0542
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFind.c
@@ -0,0 +1,761 @@
+/* LzFind.c -- Match finder for LZ algorithms
+2009-04-22 : Igor Pavlov : Public domain */
+
+#include <string.h>
+
+#include "LzFind.h"
+#include "LzHash.h"
+
+#define kEmptyHashValue 0
+#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
+#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
+#define kNormalizeMask (~(kNormalizeStepMin - 1))
+#define kMaxHistorySize ((UInt32)3 << 30)
+
+#define kStartMaxLen 3
+
+static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
+{
+ if (!p->directInput)
+ {
+ alloc->Free(alloc, p->bufferBase);
+ p->bufferBase = 0;
+ }
+}
+
+/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
+
+static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
+{
+ UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
+ if (p->directInput)
+ {
+ p->blockSize = blockSize;
+ return 1;
+ }
+ if (p->bufferBase == 0 || p->blockSize != blockSize)
+ {
+ LzInWindow_Free(p, alloc);
+ p->blockSize = blockSize;
+ p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize);
+ }
+ return (p->bufferBase != 0);
+}
+
+Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
+Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
+
+UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
+
+void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
+{
+ p->posLimit -= subValue;
+ p->pos -= subValue;
+ p->streamPos -= subValue;
+}
+
+static void MatchFinder_ReadBlock(CMatchFinder *p)
+{
+ if (p->streamEndWasReached || p->result != SZ_OK)
+ return;
+ if (p->directInput)
+ {
+ UInt32 curSize = 0xFFFFFFFF - p->streamPos;
+ if (curSize > p->directInputRem)
+ curSize = (UInt32)p->directInputRem;
+ p->directInputRem -= curSize;
+ p->streamPos += curSize;
+ if (p->directInputRem == 0)
+ p->streamEndWasReached = 1;
+ return;
+ }
+ for (;;)
+ {
+ Byte *dest = p->buffer + (p->streamPos - p->pos);
+ size_t size = (p->bufferBase + p->blockSize - dest);
+ if (size == 0)
+ return;
+ p->result = p->stream->Read(p->stream, dest, &size);
+ if (p->result != SZ_OK)
+ return;
+ if (size == 0)
+ {
+ p->streamEndWasReached = 1;
+ return;
+ }
+ p->streamPos += (UInt32)size;
+ if (p->streamPos - p->pos > p->keepSizeAfter)
+ return;
+ }
+}
+
+void MatchFinder_MoveBlock(CMatchFinder *p)
+{
+ memmove(p->bufferBase,
+ p->buffer - p->keepSizeBefore,
+ (size_t)(p->streamPos - p->pos + p->keepSizeBefore));
+ p->buffer = p->bufferBase + p->keepSizeBefore;
+}
+
+int MatchFinder_NeedMove(CMatchFinder *p)
+{
+ if (p->directInput)
+ return 0;
+ /* if (p->streamEndWasReached) return 0; */
+ return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
+}
+
+void MatchFinder_ReadIfRequired(CMatchFinder *p)
+{
+ if (p->streamEndWasReached)
+ return;
+ if (p->keepSizeAfter >= p->streamPos - p->pos)
+ MatchFinder_ReadBlock(p);
+}
+
+static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
+{
+ if (MatchFinder_NeedMove(p))
+ MatchFinder_MoveBlock(p);
+ MatchFinder_ReadBlock(p);
+}
+
+static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
+{
+ p->cutValue = 32;
+ p->btMode = 1;
+ p->numHashBytes = 4;
+ p->bigHash = 0;
+}
+
+#define kCrcPoly 0xEDB88320
+
+void MatchFinder_Construct(CMatchFinder *p)
+{
+ UInt32 i;
+ p->bufferBase = 0;
+ p->directInput = 0;
+ p->hash = 0;
+ MatchFinder_SetDefaultSettings(p);
+
+ for (i = 0; i < 256; i++)
+ {
+ UInt32 r = i;
+ int j;
+ for (j = 0; j < 8; j++)
+ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
+ p->crc[i] = r;
+ }
+}
+
+static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->hash);
+ p->hash = 0;
+}
+
+void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)
+{
+ MatchFinder_FreeThisClassMemory(p, alloc);
+ LzInWindow_Free(p, alloc);
+}
+
+static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc)
+{
+ size_t sizeInBytes = (size_t)num * sizeof(CLzRef);
+ if (sizeInBytes / sizeof(CLzRef) != num)
+ return 0;
+ return (CLzRef *)alloc->Alloc(alloc, sizeInBytes);
+}
+
+int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
+ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
+ ISzAlloc *alloc)
+{
+ UInt32 sizeReserv;
+ if (historySize > kMaxHistorySize)
+ {
+ MatchFinder_Free(p, alloc);
+ return 0;
+ }
+ sizeReserv = historySize >> 1;
+ if (historySize > ((UInt32)2 << 30))
+ sizeReserv = historySize >> 2;
+ sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
+
+ p->keepSizeBefore = historySize + keepAddBufferBefore + 1;
+ p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
+ /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */
+ if (LzInWindow_Create(p, sizeReserv, alloc))
+ {
+ UInt32 newCyclicBufferSize = historySize + 1;
+ UInt32 hs;
+ p->matchMaxLen = matchMaxLen;
+ {
+ p->fixedHashSize = 0;
+ if (p->numHashBytes == 2)
+ hs = (1 << 16) - 1;
+ else
+ {
+ hs = historySize - 1;
+ hs |= (hs >> 1);
+ hs |= (hs >> 2);
+ hs |= (hs >> 4);
+ hs |= (hs >> 8);
+ hs >>= 1;
+ hs |= 0xFFFF; /* don't change it! It's required for Deflate */
+ if (hs > (1 << 24))
+ {
+ if (p->numHashBytes == 3)
+ hs = (1 << 24) - 1;
+ else
+ hs >>= 1;
+ }
+ }
+ p->hashMask = hs;
+ hs++;
+ if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size;
+ if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size;
+ if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size;
+ hs += p->fixedHashSize;
+ }
+
+ {
+ UInt32 prevSize = p->hashSizeSum + p->numSons;
+ UInt32 newSize;
+ p->historySize = historySize;
+ p->hashSizeSum = hs;
+ p->cyclicBufferSize = newCyclicBufferSize;
+ p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize);
+ newSize = p->hashSizeSum + p->numSons;
+ if (p->hash != 0 && prevSize == newSize)
+ return 1;
+ MatchFinder_FreeThisClassMemory(p, alloc);
+ p->hash = AllocRefs(newSize, alloc);
+ if (p->hash != 0)
+ {
+ p->son = p->hash + p->hashSizeSum;
+ return 1;
+ }
+ }
+ }
+ MatchFinder_Free(p, alloc);
+ return 0;
+}
+
+static void MatchFinder_SetLimits(CMatchFinder *p)
+{
+ UInt32 limit = kMaxValForNormalize - p->pos;
+ UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
+ if (limit2 < limit)
+ limit = limit2;
+ limit2 = p->streamPos - p->pos;
+ if (limit2 <= p->keepSizeAfter)
+ {
+ if (limit2 > 0)
+ limit2 = 1;
+ }
+ else
+ limit2 -= p->keepSizeAfter;
+ if (limit2 < limit)
+ limit = limit2;
+ {
+ UInt32 lenLimit = p->streamPos - p->pos;
+ if (lenLimit > p->matchMaxLen)
+ lenLimit = p->matchMaxLen;
+ p->lenLimit = lenLimit;
+ }
+ p->posLimit = p->pos + limit;
+}
+
+void MatchFinder_Init(CMatchFinder *p)
+{
+ UInt32 i;
+ for (i = 0; i < p->hashSizeSum; i++)
+ p->hash[i] = kEmptyHashValue;
+ p->cyclicBufferPos = 0;
+ p->buffer = p->bufferBase;
+ p->pos = p->streamPos = p->cyclicBufferSize;
+ p->result = SZ_OK;
+ p->streamEndWasReached = 0;
+ MatchFinder_ReadBlock(p);
+ MatchFinder_SetLimits(p);
+}
+
+static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
+{
+ return (p->pos - p->historySize - 1) & kNormalizeMask;
+}
+
+void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
+{
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ UInt32 value = items[i];
+ if (value <= subValue)
+ value = kEmptyHashValue;
+ else
+ value -= subValue;
+ items[i] = value;
+ }
+}
+
+static void MatchFinder_Normalize(CMatchFinder *p)
+{
+ UInt32 subValue = MatchFinder_GetSubValue(p);
+ MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons);
+ MatchFinder_ReduceOffsets(p, subValue);
+}
+
+static void MatchFinder_CheckLimits(CMatchFinder *p)
+{
+ if (p->pos == kMaxValForNormalize)
+ MatchFinder_Normalize(p);
+ if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos)
+ MatchFinder_CheckAndMoveAndRead(p);
+ if (p->cyclicBufferPos == p->cyclicBufferSize)
+ p->cyclicBufferPos = 0;
+ MatchFinder_SetLimits(p);
+}
+
+static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
+ UInt32 *distances, UInt32 maxLen)
+{
+ son[_cyclicBufferPos] = curMatch;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ return distances;
+ {
+ const Byte *pb = cur - delta;
+ curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
+ if (pb[maxLen] == cur[maxLen] && *pb == *cur)
+ {
+ UInt32 len = 0;
+ while (++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ if (maxLen < len)
+ {
+ *distances++ = maxLen = len;
+ *distances++ = delta - 1;
+ if (len == lenLimit)
+ return distances;
+ }
+ }
+ }
+ }
+}
+
+UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
+ UInt32 *distances, UInt32 maxLen)
+{
+ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
+ UInt32 len0 = 0, len1 = 0;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ {
+ *ptr0 = *ptr1 = kEmptyHashValue;
+ return distances;
+ }
+ {
+ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = cur - delta;
+ UInt32 len = (len0 < len1 ? len0 : len1);
+ if (pb[len] == cur[len])
+ {
+ if (++len != lenLimit && pb[len] == cur[len])
+ while (++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ if (maxLen < len)
+ {
+ *distances++ = maxLen = len;
+ *distances++ = delta - 1;
+ if (len == lenLimit)
+ {
+ *ptr1 = pair[0];
+ *ptr0 = pair[1];
+ return distances;
+ }
+ }
+ }
+ if (pb[len] < cur[len])
+ {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
+ curMatch = *ptr1;
+ len1 = len;
+ }
+ else
+ {
+ *ptr0 = curMatch;
+ ptr0 = pair;
+ curMatch = *ptr0;
+ len0 = len;
+ }
+ }
+ }
+}
+
+static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
+{
+ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
+ UInt32 len0 = 0, len1 = 0;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ {
+ *ptr0 = *ptr1 = kEmptyHashValue;
+ return;
+ }
+ {
+ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = cur - delta;
+ UInt32 len = (len0 < len1 ? len0 : len1);
+ if (pb[len] == cur[len])
+ {
+ while (++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ {
+ if (len == lenLimit)
+ {
+ *ptr1 = pair[0];
+ *ptr0 = pair[1];
+ return;
+ }
+ }
+ }
+ if (pb[len] < cur[len])
+ {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
+ curMatch = *ptr1;
+ len1 = len;
+ }
+ else
+ {
+ *ptr0 = curMatch;
+ ptr0 = pair;
+ curMatch = *ptr0;
+ len0 = len;
+ }
+ }
+ }
+}
+
+#define MOVE_POS \
+ ++p->cyclicBufferPos; \
+ p->buffer++; \
+ if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
+
+#define MOVE_POS_RET MOVE_POS return offset;
+
+static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
+
+#define GET_MATCHES_HEADER2(minLen, ret_op) \
+ UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
+ lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
+ cur = p->buffer;
+
+#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
+#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue)
+
+#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
+
+#define GET_MATCHES_FOOTER(offset, maxLen) \
+ offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
+ distances + offset, maxLen) - distances); MOVE_POS_RET;
+
+#define SKIP_FOOTER \
+ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
+
+static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 offset;
+ GET_MATCHES_HEADER(2)
+ HASH2_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ offset = 0;
+ GET_MATCHES_FOOTER(offset, 1)
+}
+
+UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 offset;
+ GET_MATCHES_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ offset = 0;
+ GET_MATCHES_FOOTER(offset, 2)
+}
+
+static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 hash2Value, delta2, maxLen, offset;
+ GET_MATCHES_HEADER(3)
+
+ HASH3_CALC;
+
+ delta2 = p->pos - p->hash[hash2Value];
+ curMatch = p->hash[kFix3HashSize + hashValue];
+
+ p->hash[hash2Value] =
+ p->hash[kFix3HashSize + hashValue] = p->pos;
+
+
+ maxLen = 2;
+ offset = 0;
+ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
+ {
+ for (; maxLen != lenLimit; maxLen++)
+ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
+ break;
+ distances[0] = maxLen;
+ distances[1] = delta2 - 1;
+ offset = 2;
+ if (maxLen == lenLimit)
+ {
+ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
+ MOVE_POS_RET;
+ }
+ }
+ GET_MATCHES_FOOTER(offset, maxLen)
+}
+
+static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
+ GET_MATCHES_HEADER(4)
+
+ HASH4_CALC;
+
+ delta2 = p->pos - p->hash[ hash2Value];
+ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
+ curMatch = p->hash[kFix4HashSize + hashValue];
+
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] =
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+
+ maxLen = 1;
+ offset = 0;
+ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
+ {
+ distances[0] = maxLen = 2;
+ distances[1] = delta2 - 1;
+ offset = 2;
+ }
+ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
+ {
+ maxLen = 3;
+ distances[offset + 1] = delta3 - 1;
+ offset += 2;
+ delta2 = delta3;
+ }
+ if (offset != 0)
+ {
+ for (; maxLen != lenLimit; maxLen++)
+ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
+ break;
+ distances[offset - 2] = maxLen;
+ if (maxLen == lenLimit)
+ {
+ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
+ MOVE_POS_RET;
+ }
+ }
+ if (maxLen < 3)
+ maxLen = 3;
+ GET_MATCHES_FOOTER(offset, maxLen)
+}
+
+static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
+ GET_MATCHES_HEADER(4)
+
+ HASH4_CALC;
+
+ delta2 = p->pos - p->hash[ hash2Value];
+ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
+ curMatch = p->hash[kFix4HashSize + hashValue];
+
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] =
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+
+ maxLen = 1;
+ offset = 0;
+ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
+ {
+ distances[0] = maxLen = 2;
+ distances[1] = delta2 - 1;
+ offset = 2;
+ }
+ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
+ {
+ maxLen = 3;
+ distances[offset + 1] = delta3 - 1;
+ offset += 2;
+ delta2 = delta3;
+ }
+ if (offset != 0)
+ {
+ for (; maxLen != lenLimit; maxLen++)
+ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
+ break;
+ distances[offset - 2] = maxLen;
+ if (maxLen == lenLimit)
+ {
+ p->son[p->cyclicBufferPos] = curMatch;
+ MOVE_POS_RET;
+ }
+ }
+ if (maxLen < 3)
+ maxLen = 3;
+ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
+ distances + offset, maxLen) - (distances));
+ MOVE_POS_RET
+}
+
+UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 offset;
+ GET_MATCHES_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
+ distances, 2) - (distances));
+ MOVE_POS_RET
+}
+
+static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ SKIP_HEADER(2)
+ HASH2_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ SKIP_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ UInt32 hash2Value;
+ SKIP_HEADER(3)
+ HASH3_CALC;
+ curMatch = p->hash[kFix3HashSize + hashValue];
+ p->hash[hash2Value] =
+ p->hash[kFix3HashSize + hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ UInt32 hash2Value, hash3Value;
+ SKIP_HEADER(4)
+ HASH4_CALC;
+ curMatch = p->hash[kFix4HashSize + hashValue];
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] = p->pos;
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ UInt32 hash2Value, hash3Value;
+ SKIP_HEADER(4)
+ HASH4_CALC;
+ curMatch = p->hash[kFix4HashSize + hashValue];
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] =
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+ p->son[p->cyclicBufferPos] = curMatch;
+ MOVE_POS
+ }
+ while (--num != 0);
+}
+
+void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ SKIP_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ p->son[p->cyclicBufferPos] = curMatch;
+ MOVE_POS
+ }
+ while (--num != 0);
+}
+
+void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
+{
+ vTable->Init = (Mf_Init_Func)MatchFinder_Init;
+ vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
+ vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
+ vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
+ if (!p->btMode)
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
+ }
+ else if (p->numHashBytes == 2)
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
+ }
+ else if (p->numHashBytes == 3)
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
+ }
+ else
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFind.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFind.h
new file mode 100644
index 000000000..010c4b92b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFind.h
@@ -0,0 +1,115 @@
+/* LzFind.h -- Match finder for LZ algorithms
+2009-04-22 : Igor Pavlov : Public domain */
+
+#ifndef __LZ_FIND_H
+#define __LZ_FIND_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef UInt32 CLzRef;
+
+typedef struct _CMatchFinder
+{
+ Byte *buffer;
+ UInt32 pos;
+ UInt32 posLimit;
+ UInt32 streamPos;
+ UInt32 lenLimit;
+
+ UInt32 cyclicBufferPos;
+ UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
+
+ UInt32 matchMaxLen;
+ CLzRef *hash;
+ CLzRef *son;
+ UInt32 hashMask;
+ UInt32 cutValue;
+
+ Byte *bufferBase;
+ ISeqInStream *stream;
+ int streamEndWasReached;
+
+ UInt32 blockSize;
+ UInt32 keepSizeBefore;
+ UInt32 keepSizeAfter;
+
+ UInt32 numHashBytes;
+ int directInput;
+ size_t directInputRem;
+ int btMode;
+ int bigHash;
+ UInt32 historySize;
+ UInt32 fixedHashSize;
+ UInt32 hashSizeSum;
+ UInt32 numSons;
+ SRes result;
+ UInt32 crc[256];
+} CMatchFinder;
+
+#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
+#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
+
+#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
+
+int MatchFinder_NeedMove(CMatchFinder *p);
+Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
+void MatchFinder_MoveBlock(CMatchFinder *p);
+void MatchFinder_ReadIfRequired(CMatchFinder *p);
+
+void MatchFinder_Construct(CMatchFinder *p);
+
+/* Conditions:
+ historySize <= 3 GB
+ keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
+*/
+int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
+ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
+ ISzAlloc *alloc);
+void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
+void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
+void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
+
+UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
+ UInt32 *distances, UInt32 maxLen);
+
+/*
+Conditions:
+ Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
+ Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
+*/
+
+typedef void (*Mf_Init_Func)(void *object);
+typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
+typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
+typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
+typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
+typedef void (*Mf_Skip_Func)(void *object, UInt32);
+
+typedef struct _IMatchFinder
+{
+ Mf_Init_Func Init;
+ Mf_GetIndexByte_Func GetIndexByte;
+ Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
+ Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
+ Mf_GetMatches_Func GetMatches;
+ Mf_Skip_Func Skip;
+} IMatchFinder;
+
+void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
+
+void MatchFinder_Init(CMatchFinder *p);
+UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
+UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
+void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFindMt.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFindMt.c
new file mode 100644
index 000000000..5c23f8ead
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFindMt.c
@@ -0,0 +1,793 @@
+/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
+2009-05-26 : Igor Pavlov : Public domain */
+
+#include "LzHash.h"
+
+#include "LzFindMt.h"
+
+void MtSync_Construct(CMtSync *p)
+{
+ p->wasCreated = False;
+ p->csWasInitialized = False;
+ p->csWasEntered = False;
+ Thread_Construct(&p->thread);
+ Event_Construct(&p->canStart);
+ Event_Construct(&p->wasStarted);
+ Event_Construct(&p->wasStopped);
+ Semaphore_Construct(&p->freeSemaphore);
+ Semaphore_Construct(&p->filledSemaphore);
+}
+
+void MtSync_GetNextBlock(CMtSync *p)
+{
+ if (p->needStart)
+ {
+ p->numProcessedBlocks = 1;
+ p->needStart = False;
+ p->stopWriting = False;
+ p->exit = False;
+ Event_Reset(&p->wasStarted);
+ Event_Reset(&p->wasStopped);
+
+ Event_Set(&p->canStart);
+ Event_Wait(&p->wasStarted);
+ }
+ else
+ {
+ CriticalSection_Leave(&p->cs);
+ p->csWasEntered = False;
+ p->numProcessedBlocks++;
+ Semaphore_Release1(&p->freeSemaphore);
+ }
+ Semaphore_Wait(&p->filledSemaphore);
+ CriticalSection_Enter(&p->cs);
+ p->csWasEntered = True;
+}
+
+/* MtSync_StopWriting must be called if Writing was started */
+
+void MtSync_StopWriting(CMtSync *p)
+{
+ UInt32 myNumBlocks = p->numProcessedBlocks;
+ if (!Thread_WasCreated(&p->thread) || p->needStart)
+ return;
+ p->stopWriting = True;
+ if (p->csWasEntered)
+ {
+ CriticalSection_Leave(&p->cs);
+ p->csWasEntered = False;
+ }
+ Semaphore_Release1(&p->freeSemaphore);
+
+ Event_Wait(&p->wasStopped);
+
+ while (myNumBlocks++ != p->numProcessedBlocks)
+ {
+ Semaphore_Wait(&p->filledSemaphore);
+ Semaphore_Release1(&p->freeSemaphore);
+ }
+ p->needStart = True;
+}
+
+void MtSync_Destruct(CMtSync *p)
+{
+ if (Thread_WasCreated(&p->thread))
+ {
+ MtSync_StopWriting(p);
+ p->exit = True;
+ if (p->needStart)
+ Event_Set(&p->canStart);
+ Thread_Wait(&p->thread);
+ Thread_Close(&p->thread);
+ }
+ if (p->csWasInitialized)
+ {
+ CriticalSection_Delete(&p->cs);
+ p->csWasInitialized = False;
+ }
+
+ Event_Close(&p->canStart);
+ Event_Close(&p->wasStarted);
+ Event_Close(&p->wasStopped);
+ Semaphore_Close(&p->freeSemaphore);
+ Semaphore_Close(&p->filledSemaphore);
+
+ p->wasCreated = False;
+}
+
+#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }
+
+static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
+{
+ if (p->wasCreated)
+ return SZ_OK;
+
+ RINOK_THREAD(CriticalSection_Init(&p->cs));
+ p->csWasInitialized = True;
+
+ RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canStart));
+ RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStarted));
+ RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped));
+
+ RINOK_THREAD(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks));
+ RINOK_THREAD(Semaphore_Create(&p->filledSemaphore, 0, numBlocks));
+
+ p->needStart = True;
+
+ RINOK_THREAD(Thread_Create(&p->thread, startAddress, obj));
+ p->wasCreated = True;
+ return SZ_OK;
+}
+
+static SRes MtSync_Create(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
+{
+ SRes res = MtSync_Create2(p, startAddress, obj, numBlocks);
+ if (res != SZ_OK)
+ MtSync_Destruct(p);
+ return res;
+}
+
+void MtSync_Init(CMtSync *p) { p->needStart = True; }
+
+#define kMtMaxValForNormalize 0xFFFFFFFF
+
+#define DEF_GetHeads2(name, v, action) \
+static void GetHeads ## name(const Byte *p, UInt32 pos, \
+UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc) \
+{ action; for (; numHeads != 0; numHeads--) { \
+const UInt32 value = (v); p++; *heads++ = pos - hash[value]; hash[value] = pos++; } }
+
+#define DEF_GetHeads(name, v) DEF_GetHeads2(name, v, ;)
+
+DEF_GetHeads2(2, (p[0] | ((UInt32)p[1] << 8)), hashMask = hashMask; crc = crc; )
+DEF_GetHeads(3, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8)) & hashMask)
+DEF_GetHeads(4, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (crc[p[3]] << 5)) & hashMask)
+DEF_GetHeads(4b, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ ((UInt32)p[3] << 16)) & hashMask)
+/* DEF_GetHeads(5, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (crc[p[3]] << 5) ^ (crc[p[4]] << 3)) & hashMask) */
+
+void HashThreadFunc(CMatchFinderMt *mt)
+{
+ CMtSync *p = &mt->hashSync;
+ for (;;)
+ {
+ UInt32 numProcessedBlocks = 0;
+ Event_Wait(&p->canStart);
+ Event_Set(&p->wasStarted);
+ for (;;)
+ {
+ if (p->exit)
+ return;
+ if (p->stopWriting)
+ {
+ p->numProcessedBlocks = numProcessedBlocks;
+ Event_Set(&p->wasStopped);
+ break;
+ }
+
+ {
+ CMatchFinder *mf = mt->MatchFinder;
+ if (MatchFinder_NeedMove(mf))
+ {
+ CriticalSection_Enter(&mt->btSync.cs);
+ CriticalSection_Enter(&mt->hashSync.cs);
+ {
+ const Byte *beforePtr = MatchFinder_GetPointerToCurrentPos(mf);
+ const Byte *afterPtr;
+ MatchFinder_MoveBlock(mf);
+ afterPtr = MatchFinder_GetPointerToCurrentPos(mf);
+ mt->pointerToCurPos -= beforePtr - afterPtr;
+ mt->buffer -= beforePtr - afterPtr;
+ }
+ CriticalSection_Leave(&mt->btSync.cs);
+ CriticalSection_Leave(&mt->hashSync.cs);
+ continue;
+ }
+
+ Semaphore_Wait(&p->freeSemaphore);
+
+ MatchFinder_ReadIfRequired(mf);
+ if (mf->pos > (kMtMaxValForNormalize - kMtHashBlockSize))
+ {
+ UInt32 subValue = (mf->pos - mf->historySize - 1);
+ MatchFinder_ReduceOffsets(mf, subValue);
+ MatchFinder_Normalize3(subValue, mf->hash + mf->fixedHashSize, mf->hashMask + 1);
+ }
+ {
+ UInt32 *heads = mt->hashBuf + ((numProcessedBlocks++) & kMtHashNumBlocksMask) * kMtHashBlockSize;
+ UInt32 num = mf->streamPos - mf->pos;
+ heads[0] = 2;
+ heads[1] = num;
+ if (num >= mf->numHashBytes)
+ {
+ num = num - mf->numHashBytes + 1;
+ if (num > kMtHashBlockSize - 2)
+ num = kMtHashBlockSize - 2;
+ mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num, mf->crc);
+ heads[0] += num;
+ }
+ mf->pos += num;
+ mf->buffer += num;
+ }
+ }
+
+ Semaphore_Release1(&p->filledSemaphore);
+ }
+ }
+}
+
+void MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p)
+{
+ MtSync_GetNextBlock(&p->hashSync);
+ p->hashBufPosLimit = p->hashBufPos = ((p->hashSync.numProcessedBlocks - 1) & kMtHashNumBlocksMask) * kMtHashBlockSize;
+ p->hashBufPosLimit += p->hashBuf[p->hashBufPos++];
+ p->hashNumAvail = p->hashBuf[p->hashBufPos++];
+}
+
+#define kEmptyHashValue 0
+
+/* #define MFMT_GM_INLINE */
+
+#ifdef MFMT_GM_INLINE
+
+#define NO_INLINE MY_FAST_CALL
+
+Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
+ UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 limit, UInt32 size, UInt32 *posRes)
+{
+ do
+ {
+ UInt32 *distances = _distances + 1;
+ UInt32 curMatch = pos - *hash++;
+
+ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
+ UInt32 len0 = 0, len1 = 0;
+ UInt32 cutValue = _cutValue;
+ UInt32 maxLen = _maxLen;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ {
+ *ptr0 = *ptr1 = kEmptyHashValue;
+ break;
+ }
+ {
+ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = cur - delta;
+ UInt32 len = (len0 < len1 ? len0 : len1);
+ if (pb[len] == cur[len])
+ {
+ if (++len != lenLimit && pb[len] == cur[len])
+ while (++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ if (maxLen < len)
+ {
+ *distances++ = maxLen = len;
+ *distances++ = delta - 1;
+ if (len == lenLimit)
+ {
+ *ptr1 = pair[0];
+ *ptr0 = pair[1];
+ break;
+ }
+ }
+ }
+ if (pb[len] < cur[len])
+ {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
+ curMatch = *ptr1;
+ len1 = len;
+ }
+ else
+ {
+ *ptr0 = curMatch;
+ ptr0 = pair;
+ curMatch = *ptr0;
+ len0 = len;
+ }
+ }
+ }
+ pos++;
+ _cyclicBufferPos++;
+ cur++;
+ {
+ UInt32 num = (UInt32)(distances - _distances);
+ *_distances = num - 1;
+ _distances += num;
+ limit -= num;
+ }
+ }
+ while (limit > 0 && --size != 0);
+ *posRes = pos;
+ return limit;
+}
+
+#endif
+
+void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
+{
+ UInt32 numProcessed = 0;
+ UInt32 curPos = 2;
+ UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2);
+ distances[1] = p->hashNumAvail;
+ while (curPos < limit)
+ {
+ if (p->hashBufPos == p->hashBufPosLimit)
+ {
+ MatchFinderMt_GetNextBlock_Hash(p);
+ distances[1] = numProcessed + p->hashNumAvail;
+ if (p->hashNumAvail >= p->numHashBytes)
+ continue;
+ for (; p->hashNumAvail != 0; p->hashNumAvail--)
+ distances[curPos++] = 0;
+ break;
+ }
+ {
+ UInt32 size = p->hashBufPosLimit - p->hashBufPos;
+ UInt32 lenLimit = p->matchMaxLen;
+ UInt32 pos = p->pos;
+ UInt32 cyclicBufferPos = p->cyclicBufferPos;
+ if (lenLimit >= p->hashNumAvail)
+ lenLimit = p->hashNumAvail;
+ {
+ UInt32 size2 = p->hashNumAvail - lenLimit + 1;
+ if (size2 < size)
+ size = size2;
+ size2 = p->cyclicBufferSize - cyclicBufferPos;
+ if (size2 < size)
+ size = size2;
+ }
+ #ifndef MFMT_GM_INLINE
+ while (curPos < limit && size-- != 0)
+ {
+ UInt32 *startDistances = distances + curPos;
+ UInt32 num = (UInt32)(GetMatchesSpec1(lenLimit, pos - p->hashBuf[p->hashBufPos++],
+ pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
+ startDistances + 1, p->numHashBytes - 1) - startDistances);
+ *startDistances = num - 1;
+ curPos += num;
+ cyclicBufferPos++;
+ pos++;
+ p->buffer++;
+ }
+ #else
+ {
+ UInt32 posRes;
+ curPos = limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
+ distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos, (Int32)(limit - curPos) , size, &posRes);
+ p->hashBufPos += posRes - pos;
+ cyclicBufferPos += posRes - pos;
+ p->buffer += posRes - pos;
+ pos = posRes;
+ }
+ #endif
+
+ numProcessed += pos - p->pos;
+ p->hashNumAvail -= pos - p->pos;
+ p->pos = pos;
+ if (cyclicBufferPos == p->cyclicBufferSize)
+ cyclicBufferPos = 0;
+ p->cyclicBufferPos = cyclicBufferPos;
+ }
+ }
+ distances[0] = curPos;
+}
+
+void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex)
+{
+ CMtSync *sync = &p->hashSync;
+ if (!sync->needStart)
+ {
+ CriticalSection_Enter(&sync->cs);
+ sync->csWasEntered = True;
+ }
+
+ BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize);
+
+ if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize)
+ {
+ UInt32 subValue = p->pos - p->cyclicBufferSize;
+ MatchFinder_Normalize3(subValue, p->son, p->cyclicBufferSize * 2);
+ p->pos -= subValue;
+ }
+
+ if (!sync->needStart)
+ {
+ CriticalSection_Leave(&sync->cs);
+ sync->csWasEntered = False;
+ }
+}
+
+void BtThreadFunc(CMatchFinderMt *mt)
+{
+ CMtSync *p = &mt->btSync;
+ for (;;)
+ {
+ UInt32 blockIndex = 0;
+ Event_Wait(&p->canStart);
+ Event_Set(&p->wasStarted);
+ for (;;)
+ {
+ if (p->exit)
+ return;
+ if (p->stopWriting)
+ {
+ p->numProcessedBlocks = blockIndex;
+ MtSync_StopWriting(&mt->hashSync);
+ Event_Set(&p->wasStopped);
+ break;
+ }
+ Semaphore_Wait(&p->freeSemaphore);
+ BtFillBlock(mt, blockIndex++);
+ Semaphore_Release1(&p->filledSemaphore);
+ }
+ }
+}
+
+void MatchFinderMt_Construct(CMatchFinderMt *p)
+{
+ p->hashBuf = 0;
+ MtSync_Construct(&p->hashSync);
+ MtSync_Construct(&p->btSync);
+}
+
+void MatchFinderMt_FreeMem(CMatchFinderMt *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->hashBuf);
+ p->hashBuf = 0;
+}
+
+void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc)
+{
+ MtSync_Destruct(&p->hashSync);
+ MtSync_Destruct(&p->btSync);
+ MatchFinderMt_FreeMem(p, alloc);
+}
+
+#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks)
+#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)
+
+static unsigned MY_STD_CALL HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
+static unsigned MY_STD_CALL BtThreadFunc2(void *p)
+{
+ Byte allocaDummy[0x180];
+ int i = 0;
+ for (i = 0; i < 16; i++)
+ allocaDummy[i] = (Byte)i;
+ BtThreadFunc((CMatchFinderMt *)p);
+ return 0;
+}
+
+SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
+ UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc)
+{
+ CMatchFinder *mf = p->MatchFinder;
+ p->historySize = historySize;
+ if (kMtBtBlockSize <= matchMaxLen * 4)
+ return SZ_ERROR_PARAM;
+ if (p->hashBuf == 0)
+ {
+ p->hashBuf = (UInt32 *)alloc->Alloc(alloc, (kHashBufferSize + kBtBufferSize) * sizeof(UInt32));
+ if (p->hashBuf == 0)
+ return SZ_ERROR_MEM;
+ p->btBuf = p->hashBuf + kHashBufferSize;
+ }
+ keepAddBufferBefore += (kHashBufferSize + kBtBufferSize);
+ keepAddBufferAfter += kMtHashBlockSize;
+ if (!MatchFinder_Create(mf, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter, alloc))
+ return SZ_ERROR_MEM;
+
+ RINOK(MtSync_Create(&p->hashSync, HashThreadFunc2, p, kMtHashNumBlocks));
+ RINOK(MtSync_Create(&p->btSync, BtThreadFunc2, p, kMtBtNumBlocks));
+ return SZ_OK;
+}
+
+/* Call it after ReleaseStream / SetStream */
+void MatchFinderMt_Init(CMatchFinderMt *p)
+{
+ CMatchFinder *mf = p->MatchFinder;
+ p->btBufPos = p->btBufPosLimit = 0;
+ p->hashBufPos = p->hashBufPosLimit = 0;
+ MatchFinder_Init(mf);
+ p->pointerToCurPos = MatchFinder_GetPointerToCurrentPos(mf);
+ p->btNumAvailBytes = 0;
+ p->lzPos = p->historySize + 1;
+
+ p->hash = mf->hash;
+ p->fixedHashSize = mf->fixedHashSize;
+ p->crc = mf->crc;
+
+ p->son = mf->son;
+ p->matchMaxLen = mf->matchMaxLen;
+ p->numHashBytes = mf->numHashBytes;
+ p->pos = mf->pos;
+ p->buffer = mf->buffer;
+ p->cyclicBufferPos = mf->cyclicBufferPos;
+ p->cyclicBufferSize = mf->cyclicBufferSize;
+ p->cutValue = mf->cutValue;
+}
+
+/* ReleaseStream is required to finish multithreading */
+void MatchFinderMt_ReleaseStream(CMatchFinderMt *p)
+{
+ MtSync_StopWriting(&p->btSync);
+ /* p->MatchFinder->ReleaseStream(); */
+}
+
+void MatchFinderMt_Normalize(CMatchFinderMt *p)
+{
+ MatchFinder_Normalize3(p->lzPos - p->historySize - 1, p->hash, p->fixedHashSize);
+ p->lzPos = p->historySize + 1;
+}
+
+void MatchFinderMt_GetNextBlock_Bt(CMatchFinderMt *p)
+{
+ UInt32 blockIndex;
+ MtSync_GetNextBlock(&p->btSync);
+ blockIndex = ((p->btSync.numProcessedBlocks - 1) & kMtBtNumBlocksMask);
+ p->btBufPosLimit = p->btBufPos = blockIndex * kMtBtBlockSize;
+ p->btBufPosLimit += p->btBuf[p->btBufPos++];
+ p->btNumAvailBytes = p->btBuf[p->btBufPos++];
+ if (p->lzPos >= kMtMaxValForNormalize - kMtBtBlockSize)
+ MatchFinderMt_Normalize(p);
+}
+
+const Byte * MatchFinderMt_GetPointerToCurrentPos(CMatchFinderMt *p)
+{
+ return p->pointerToCurPos;
+}
+
+#define GET_NEXT_BLOCK_IF_REQUIRED if (p->btBufPos == p->btBufPosLimit) MatchFinderMt_GetNextBlock_Bt(p);
+
+UInt32 MatchFinderMt_GetNumAvailableBytes(CMatchFinderMt *p)
+{
+ GET_NEXT_BLOCK_IF_REQUIRED;
+ return p->btNumAvailBytes;
+}
+
+Byte MatchFinderMt_GetIndexByte(CMatchFinderMt *p, Int32 index)
+{
+ return p->pointerToCurPos[index];
+}
+
+UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
+{
+ UInt32 hash2Value, curMatch2;
+ UInt32 *hash = p->hash;
+ const Byte *cur = p->pointerToCurPos;
+ UInt32 lzPos = p->lzPos;
+ MT_HASH2_CALC
+
+ curMatch2 = hash[hash2Value];
+ hash[hash2Value] = lzPos;
+
+ if (curMatch2 >= matchMinPos)
+ if (cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])
+ {
+ *distances++ = 2;
+ *distances++ = lzPos - curMatch2 - 1;
+ }
+ return distances;
+}
+
+UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, curMatch2, curMatch3;
+ UInt32 *hash = p->hash;
+ const Byte *cur = p->pointerToCurPos;
+ UInt32 lzPos = p->lzPos;
+ MT_HASH3_CALC
+
+ curMatch2 = hash[ hash2Value];
+ curMatch3 = hash[kFix3HashSize + hash3Value];
+
+ hash[ hash2Value] =
+ hash[kFix3HashSize + hash3Value] =
+ lzPos;
+
+ if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])
+ {
+ distances[1] = lzPos - curMatch2 - 1;
+ if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2])
+ {
+ distances[0] = 3;
+ return distances + 2;
+ }
+ distances[0] = 2;
+ distances += 2;
+ }
+ if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0])
+ {
+ *distances++ = 3;
+ *distances++ = lzPos - curMatch3 - 1;
+ }
+ return distances;
+}
+
+/*
+UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, hash4Value, curMatch2, curMatch3, curMatch4;
+ UInt32 *hash = p->hash;
+ const Byte *cur = p->pointerToCurPos;
+ UInt32 lzPos = p->lzPos;
+ MT_HASH4_CALC
+
+ curMatch2 = hash[ hash2Value];
+ curMatch3 = hash[kFix3HashSize + hash3Value];
+ curMatch4 = hash[kFix4HashSize + hash4Value];
+
+ hash[ hash2Value] =
+ hash[kFix3HashSize + hash3Value] =
+ hash[kFix4HashSize + hash4Value] =
+ lzPos;
+
+ if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])
+ {
+ distances[1] = lzPos - curMatch2 - 1;
+ if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2])
+ {
+ distances[0] = (cur[(ptrdiff_t)curMatch2 - lzPos + 3] == cur[3]) ? 4 : 3;
+ return distances + 2;
+ }
+ distances[0] = 2;
+ distances += 2;
+ }
+ if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0])
+ {
+ distances[1] = lzPos - curMatch3 - 1;
+ if (cur[(ptrdiff_t)curMatch3 - lzPos + 3] == cur[3])
+ {
+ distances[0] = 4;
+ return distances + 2;
+ }
+ distances[0] = 3;
+ distances += 2;
+ }
+
+ if (curMatch4 >= matchMinPos)
+ if (
+ cur[(ptrdiff_t)curMatch4 - lzPos] == cur[0] &&
+ cur[(ptrdiff_t)curMatch4 - lzPos + 3] == cur[3]
+ )
+ {
+ *distances++ = 4;
+ *distances++ = lzPos - curMatch4 - 1;
+ }
+ return distances;
+}
+*/
+
+#define INCREASE_LZ_POS p->lzPos++; p->pointerToCurPos++;
+
+UInt32 MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *distances)
+{
+ const UInt32 *btBuf = p->btBuf + p->btBufPos;
+ UInt32 len = *btBuf++;
+ p->btBufPos += 1 + len;
+ p->btNumAvailBytes--;
+ {
+ UInt32 i;
+ for (i = 0; i < len; i += 2)
+ {
+ *distances++ = *btBuf++;
+ *distances++ = *btBuf++;
+ }
+ }
+ INCREASE_LZ_POS
+ return len;
+}
+
+UInt32 MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *distances)
+{
+ const UInt32 *btBuf = p->btBuf + p->btBufPos;
+ UInt32 len = *btBuf++;
+ p->btBufPos += 1 + len;
+
+ if (len == 0)
+ {
+ if (p->btNumAvailBytes-- >= 4)
+ len = (UInt32)(p->MixMatchesFunc(p, p->lzPos - p->historySize, distances) - (distances));
+ }
+ else
+ {
+ /* Condition: there are matches in btBuf with length < p->numHashBytes */
+ UInt32 *distances2;
+ p->btNumAvailBytes--;
+ distances2 = p->MixMatchesFunc(p, p->lzPos - btBuf[1], distances);
+ do
+ {
+ *distances2++ = *btBuf++;
+ *distances2++ = *btBuf++;
+ }
+ while ((len -= 2) != 0);
+ len = (UInt32)(distances2 - (distances));
+ }
+ INCREASE_LZ_POS
+ return len;
+}
+
+#define SKIP_HEADER2 do { GET_NEXT_BLOCK_IF_REQUIRED
+#define SKIP_HEADER(n) SKIP_HEADER2 if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash;
+#define SKIP_FOOTER } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while (--num != 0);
+
+void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num)
+{
+ SKIP_HEADER2 { p->btNumAvailBytes--;
+ SKIP_FOOTER
+}
+
+void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num)
+{
+ SKIP_HEADER(2)
+ UInt32 hash2Value;
+ MT_HASH2_CALC
+ hash[hash2Value] = p->lzPos;
+ SKIP_FOOTER
+}
+
+void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num)
+{
+ SKIP_HEADER(3)
+ UInt32 hash2Value, hash3Value;
+ MT_HASH3_CALC
+ hash[kFix3HashSize + hash3Value] =
+ hash[ hash2Value] =
+ p->lzPos;
+ SKIP_FOOTER
+}
+
+/*
+void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num)
+{
+ SKIP_HEADER(4)
+ UInt32 hash2Value, hash3Value, hash4Value;
+ MT_HASH4_CALC
+ hash[kFix4HashSize + hash4Value] =
+ hash[kFix3HashSize + hash3Value] =
+ hash[ hash2Value] =
+ p->lzPos;
+ SKIP_FOOTER
+}
+*/
+
+void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable)
+{
+ vTable->Init = (Mf_Init_Func)MatchFinderMt_Init;
+ vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinderMt_GetIndexByte;
+ vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinderMt_GetNumAvailableBytes;
+ vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinderMt_GetPointerToCurrentPos;
+ vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches;
+ switch(p->MatchFinder->numHashBytes)
+ {
+ case 2:
+ p->GetHeadsFunc = GetHeads2;
+ p->MixMatchesFunc = (Mf_Mix_Matches)0;
+ vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip;
+ vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches;
+ break;
+ case 3:
+ p->GetHeadsFunc = GetHeads3;
+ p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches2;
+ vTable->Skip = (Mf_Skip_Func)MatchFinderMt2_Skip;
+ break;
+ default:
+ /* case 4: */
+ p->GetHeadsFunc = p->MatchFinder->bigHash ? GetHeads4b : GetHeads4;
+ /* p->GetHeadsFunc = GetHeads4; */
+ p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches3;
+ vTable->Skip = (Mf_Skip_Func)MatchFinderMt3_Skip;
+ break;
+ /*
+ default:
+ p->GetHeadsFunc = GetHeads5;
+ p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches4;
+ vTable->Skip = (Mf_Skip_Func)MatchFinderMt4_Skip;
+ break;
+ */
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFindMt.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFindMt.h
new file mode 100644
index 000000000..b985af5fe
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzFindMt.h
@@ -0,0 +1,105 @@
+/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __LZ_FIND_MT_H
+#define __LZ_FIND_MT_H
+
+#include "LzFind.h"
+#include "Threads.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define kMtHashBlockSize (1 << 13)
+#define kMtHashNumBlocks (1 << 3)
+#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
+
+#define kMtBtBlockSize (1 << 14)
+#define kMtBtNumBlocks (1 << 6)
+#define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)
+
+typedef struct _CMtSync
+{
+ Bool wasCreated;
+ Bool needStart;
+ Bool exit;
+ Bool stopWriting;
+
+ CThread thread;
+ CAutoResetEvent canStart;
+ CAutoResetEvent wasStarted;
+ CAutoResetEvent wasStopped;
+ CSemaphore freeSemaphore;
+ CSemaphore filledSemaphore;
+ Bool csWasInitialized;
+ Bool csWasEntered;
+ CCriticalSection cs;
+ UInt32 numProcessedBlocks;
+} CMtSync;
+
+typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);
+
+/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
+#define kMtCacheLineDummy 128
+
+typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
+ UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc);
+
+typedef struct _CMatchFinderMt
+{
+ /* LZ */
+ const Byte *pointerToCurPos;
+ UInt32 *btBuf;
+ UInt32 btBufPos;
+ UInt32 btBufPosLimit;
+ UInt32 lzPos;
+ UInt32 btNumAvailBytes;
+
+ UInt32 *hash;
+ UInt32 fixedHashSize;
+ UInt32 historySize;
+ const UInt32 *crc;
+
+ Mf_Mix_Matches MixMatchesFunc;
+
+ /* LZ + BT */
+ CMtSync btSync;
+ Byte btDummy[kMtCacheLineDummy];
+
+ /* BT */
+ UInt32 *hashBuf;
+ UInt32 hashBufPos;
+ UInt32 hashBufPosLimit;
+ UInt32 hashNumAvail;
+
+ CLzRef *son;
+ UInt32 matchMaxLen;
+ UInt32 numHashBytes;
+ UInt32 pos;
+ Byte *buffer;
+ UInt32 cyclicBufferPos;
+ UInt32 cyclicBufferSize; /* it must be historySize + 1 */
+ UInt32 cutValue;
+
+ /* BT + Hash */
+ CMtSync hashSync;
+ /* Byte hashDummy[kMtCacheLineDummy]; */
+
+ /* Hash */
+ Mf_GetHeads GetHeadsFunc;
+ CMatchFinder *MatchFinder;
+} CMatchFinderMt;
+
+void MatchFinderMt_Construct(CMatchFinderMt *p);
+void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc);
+SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
+ UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc);
+void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);
+void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzHash.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzHash.h
new file mode 100644
index 000000000..f3e89966c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzHash.h
@@ -0,0 +1,54 @@
+/* LzHash.h -- HASH functions for LZ algorithms
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __LZ_HASH_H
+#define __LZ_HASH_H
+
+#define kHash2Size (1 << 10)
+#define kHash3Size (1 << 16)
+#define kHash4Size (1 << 20)
+
+#define kFix3HashSize (kHash2Size)
+#define kFix4HashSize (kHash2Size + kHash3Size)
+#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
+
+#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
+
+#define HASH3_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
+
+#define HASH4_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
+ hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
+
+#define HASH5_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
+ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \
+ hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \
+ hash4Value &= (kHash4Size - 1); }
+
+/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
+#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
+
+
+#define MT_HASH2_CALC \
+ hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
+
+#define MT_HASH3_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
+
+#define MT_HASH4_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
+ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Dec.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Dec.c
new file mode 100644
index 000000000..7ea1cc953
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Dec.c
@@ -0,0 +1,356 @@
+/* Lzma2Dec.c -- LZMA2 Decoder
+2009-05-03 : Igor Pavlov : Public domain */
+
+/* #define SHOW_DEBUG_INFO */
+
+#ifdef SHOW_DEBUG_INFO
+#include <stdio.h>
+#endif
+
+#include <string.h>
+
+#include "Lzma2Dec.h"
+
+/*
+00000000 - EOS
+00000001 U U - Uncompressed Reset Dic
+00000010 U U - Uncompressed No Reset
+100uuuuu U U P P - LZMA no reset
+101uuuuu U U P P - LZMA reset state
+110uuuuu U U P P S - LZMA reset state + new prop
+111uuuuu U U P P S - LZMA reset state + new prop + reset dic
+
+ u, U - Unpack Size
+ P - Pack Size
+ S - Props
+*/
+
+#define LZMA2_CONTROL_LZMA (1 << 7)
+#define LZMA2_CONTROL_COPY_NO_RESET 2
+#define LZMA2_CONTROL_COPY_RESET_DIC 1
+#define LZMA2_CONTROL_EOF 0
+
+#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & LZMA2_CONTROL_LZMA) == 0)
+
+#define LZMA2_GET_LZMA_MODE(p) (((p)->control >> 5) & 3)
+#define LZMA2_IS_THERE_PROP(mode) ((mode) >= 2)
+
+#define LZMA2_LCLP_MAX 4
+#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11))
+
+#ifdef SHOW_DEBUG_INFO
+#define PRF(x) x
+#else
+#define PRF(x)
+#endif
+
+typedef enum
+{
+ LZMA2_STATE_CONTROL,
+ LZMA2_STATE_UNPACK0,
+ LZMA2_STATE_UNPACK1,
+ LZMA2_STATE_PACK0,
+ LZMA2_STATE_PACK1,
+ LZMA2_STATE_PROP,
+ LZMA2_STATE_DATA,
+ LZMA2_STATE_DATA_CONT,
+ LZMA2_STATE_FINISHED,
+ LZMA2_STATE_ERROR
+} ELzma2State;
+
+static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props)
+{
+ UInt32 dicSize;
+ if (prop > 40)
+ return SZ_ERROR_UNSUPPORTED;
+ dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop);
+ props[0] = (Byte)LZMA2_LCLP_MAX;
+ props[1] = (Byte)(dicSize);
+ props[2] = (Byte)(dicSize >> 8);
+ props[3] = (Byte)(dicSize >> 16);
+ props[4] = (Byte)(dicSize >> 24);
+ return SZ_OK;
+}
+
+SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc)
+{
+ Byte props[LZMA_PROPS_SIZE];
+ RINOK(Lzma2Dec_GetOldProps(prop, props));
+ return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc);
+}
+
+SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc)
+{
+ Byte props[LZMA_PROPS_SIZE];
+ RINOK(Lzma2Dec_GetOldProps(prop, props));
+ return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc);
+}
+
+void Lzma2Dec_Init(CLzma2Dec *p)
+{
+ p->state = LZMA2_STATE_CONTROL;
+ p->needInitDic = True;
+ p->needInitState = True;
+ p->needInitProp = True;
+ LzmaDec_Init(&p->decoder);
+}
+
+static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
+{
+ switch(p->state)
+ {
+ case LZMA2_STATE_CONTROL:
+ p->control = b;
+ PRF(printf("\n %4X ", p->decoder.dicPos));
+ PRF(printf(" %2X", b));
+ if (p->control == 0)
+ return LZMA2_STATE_FINISHED;
+ if (LZMA2_IS_UNCOMPRESSED_STATE(p))
+ {
+ if ((p->control & 0x7F) > 2)
+ return LZMA2_STATE_ERROR;
+ p->unpackSize = 0;
+ }
+ else
+ p->unpackSize = (UInt32)(p->control & 0x1F) << 16;
+ return LZMA2_STATE_UNPACK0;
+
+ case LZMA2_STATE_UNPACK0:
+ p->unpackSize |= (UInt32)b << 8;
+ return LZMA2_STATE_UNPACK1;
+
+ case LZMA2_STATE_UNPACK1:
+ p->unpackSize |= (UInt32)b;
+ p->unpackSize++;
+ PRF(printf(" %8d", p->unpackSize));
+ return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
+
+ case LZMA2_STATE_PACK0:
+ p->packSize = (UInt32)b << 8;
+ return LZMA2_STATE_PACK1;
+
+ case LZMA2_STATE_PACK1:
+ p->packSize |= (UInt32)b;
+ p->packSize++;
+ PRF(printf(" %8d", p->packSize));
+ return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP:
+ (p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA);
+
+ case LZMA2_STATE_PROP:
+ {
+ int lc, lp;
+ if (b >= (9 * 5 * 5))
+ return LZMA2_STATE_ERROR;
+ lc = b % 9;
+ b /= 9;
+ p->decoder.prop.pb = b / 5;
+ lp = b % 5;
+ if (lc + lp > LZMA2_LCLP_MAX)
+ return LZMA2_STATE_ERROR;
+ p->decoder.prop.lc = lc;
+ p->decoder.prop.lp = lp;
+ p->needInitProp = False;
+ return LZMA2_STATE_DATA;
+ }
+ }
+ return LZMA2_STATE_ERROR;
+}
+
+static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT size)
+{
+ memcpy(p->dic + p->dicPos, src, size);
+ p->dicPos += size;
+ if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size)
+ p->checkDicSize = p->prop.dicSize;
+ p->processedPos += (UInt32)size;
+}
+
+void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState);
+
+SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
+ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
+{
+ SizeT inSize = *srcLen;
+ *srcLen = 0;
+ *status = LZMA_STATUS_NOT_SPECIFIED;
+
+ while (p->state != LZMA2_STATE_FINISHED)
+ {
+ SizeT dicPos = p->decoder.dicPos;
+ if (p->state == LZMA2_STATE_ERROR)
+ return SZ_ERROR_DATA;
+ if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY)
+ {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_OK;
+ }
+ if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT)
+ {
+ if (*srcLen == inSize)
+ {
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+ return SZ_OK;
+ }
+ (*srcLen)++;
+ p->state = Lzma2Dec_UpdateState(p, *src++);
+ continue;
+ }
+ {
+ SizeT destSizeCur = dicLimit - dicPos;
+ SizeT srcSizeCur = inSize - *srcLen;
+ ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY;
+
+ if (p->unpackSize <= destSizeCur)
+ {
+ destSizeCur = (SizeT)p->unpackSize;
+ curFinishMode = LZMA_FINISH_END;
+ }
+
+ if (LZMA2_IS_UNCOMPRESSED_STATE(p))
+ {
+ if (*srcLen == inSize)
+ {
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+ return SZ_OK;
+ }
+
+ if (p->state == LZMA2_STATE_DATA)
+ {
+ Bool initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC);
+ if (initDic)
+ p->needInitProp = p->needInitState = True;
+ else if (p->needInitDic)
+ return SZ_ERROR_DATA;
+ p->needInitDic = False;
+ LzmaDec_InitDicAndState(&p->decoder, initDic, False);
+ }
+
+ if (srcSizeCur > destSizeCur)
+ srcSizeCur = destSizeCur;
+
+ if (srcSizeCur == 0)
+ return SZ_ERROR_DATA;
+
+ LzmaDec_UpdateWithUncompressed(&p->decoder, src, srcSizeCur);
+
+ src += srcSizeCur;
+ *srcLen += srcSizeCur;
+ p->unpackSize -= (UInt32)srcSizeCur;
+ p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT;
+ }
+ else
+ {
+ SizeT outSizeProcessed;
+ SRes res;
+
+ if (p->state == LZMA2_STATE_DATA)
+ {
+ int mode = LZMA2_GET_LZMA_MODE(p);
+ Bool initDic = (mode == 3);
+ Bool initState = (mode > 0);
+ if ((!initDic && p->needInitDic) || (!initState && p->needInitState))
+ return SZ_ERROR_DATA;
+
+ LzmaDec_InitDicAndState(&p->decoder, initDic, initState);
+ p->needInitDic = False;
+ p->needInitState = False;
+ p->state = LZMA2_STATE_DATA_CONT;
+ }
+ if (srcSizeCur > p->packSize)
+ srcSizeCur = (SizeT)p->packSize;
+
+ res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status);
+
+ src += srcSizeCur;
+ *srcLen += srcSizeCur;
+ p->packSize -= (UInt32)srcSizeCur;
+
+ outSizeProcessed = p->decoder.dicPos - dicPos;
+ p->unpackSize -= (UInt32)outSizeProcessed;
+
+ RINOK(res);
+ if (*status == LZMA_STATUS_NEEDS_MORE_INPUT)
+ return res;
+
+ if (srcSizeCur == 0 && outSizeProcessed == 0)
+ {
+ if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK ||
+ p->unpackSize != 0 || p->packSize != 0)
+ return SZ_ERROR_DATA;
+ p->state = LZMA2_STATE_CONTROL;
+ }
+ if (*status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)
+ *status = LZMA_STATUS_NOT_FINISHED;
+ }
+ }
+ }
+ *status = LZMA_STATUS_FINISHED_WITH_MARK;
+ return SZ_OK;
+}
+
+SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
+{
+ SizeT outSize = *destLen, inSize = *srcLen;
+ *srcLen = *destLen = 0;
+ for (;;)
+ {
+ SizeT srcSizeCur = inSize, outSizeCur, dicPos;
+ ELzmaFinishMode curFinishMode;
+ SRes res;
+ if (p->decoder.dicPos == p->decoder.dicBufSize)
+ p->decoder.dicPos = 0;
+ dicPos = p->decoder.dicPos;
+ if (outSize > p->decoder.dicBufSize - dicPos)
+ {
+ outSizeCur = p->decoder.dicBufSize;
+ curFinishMode = LZMA_FINISH_ANY;
+ }
+ else
+ {
+ outSizeCur = dicPos + outSize;
+ curFinishMode = finishMode;
+ }
+
+ res = Lzma2Dec_DecodeToDic(p, outSizeCur, src, &srcSizeCur, curFinishMode, status);
+ src += srcSizeCur;
+ inSize -= srcSizeCur;
+ *srcLen += srcSizeCur;
+ outSizeCur = p->decoder.dicPos - dicPos;
+ memcpy(dest, p->decoder.dic + dicPos, outSizeCur);
+ dest += outSizeCur;
+ outSize -= outSizeCur;
+ *destLen += outSizeCur;
+ if (res != 0)
+ return res;
+ if (outSizeCur == 0 || outSize == 0)
+ return SZ_OK;
+ }
+}
+
+SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc)
+{
+ CLzma2Dec decoder;
+ SRes res;
+ SizeT outSize = *destLen, inSize = *srcLen;
+ Byte props[LZMA_PROPS_SIZE];
+
+ Lzma2Dec_Construct(&decoder);
+
+ *destLen = *srcLen = 0;
+ *status = LZMA_STATUS_NOT_SPECIFIED;
+ decoder.decoder.dic = dest;
+ decoder.decoder.dicBufSize = outSize;
+
+ RINOK(Lzma2Dec_GetOldProps(prop, props));
+ RINOK(LzmaDec_AllocateProbs(&decoder.decoder, props, LZMA_PROPS_SIZE, alloc));
+
+ *srcLen = inSize;
+ res = Lzma2Dec_DecodeToDic(&decoder, outSize, src, srcLen, finishMode, status);
+ *destLen = decoder.decoder.dicPos;
+ if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
+ res = SZ_ERROR_INPUT_EOF;
+
+ LzmaDec_FreeProbs(&decoder.decoder, alloc);
+ return res;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Dec.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Dec.h
new file mode 100644
index 000000000..6bc07bbc1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Dec.h
@@ -0,0 +1,84 @@
+/* Lzma2Dec.h -- LZMA2 Decoder
+2009-05-03 : Igor Pavlov : Public domain */
+
+#ifndef __LZMA2_DEC_H
+#define __LZMA2_DEC_H
+
+#include "LzmaDec.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ---------- State Interface ---------- */
+
+typedef struct
+{
+ CLzmaDec decoder;
+ UInt32 packSize;
+ UInt32 unpackSize;
+ int state;
+ Byte control;
+ Bool needInitDic;
+ Bool needInitState;
+ Bool needInitProp;
+} CLzma2Dec;
+
+#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder)
+#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc);
+#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc);
+
+SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc);
+SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc);
+void Lzma2Dec_Init(CLzma2Dec *p);
+
+
+/*
+finishMode:
+ It has meaning only if the decoding reaches output limit (*destLen or dicLimit).
+ LZMA_FINISH_ANY - use smallest number of input bytes
+ LZMA_FINISH_END - read EndOfStream marker after decoding
+
+Returns:
+ SZ_OK
+ status:
+ LZMA_STATUS_FINISHED_WITH_MARK
+ LZMA_STATUS_NOT_FINISHED
+ LZMA_STATUS_NEEDS_MORE_INPUT
+ SZ_ERROR_DATA - Data error
+*/
+
+SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
+ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+
+SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen,
+ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+
+
+/* ---------- One Call Interface ---------- */
+
+/*
+finishMode:
+ It has meaning only if the decoding reaches output limit (*destLen).
+ LZMA_FINISH_ANY - use smallest number of input bytes
+ LZMA_FINISH_END - read EndOfStream marker after decoding
+
+Returns:
+ SZ_OK
+ status:
+ LZMA_STATUS_FINISHED_WITH_MARK
+ LZMA_STATUS_NOT_FINISHED
+ SZ_ERROR_DATA - Data error
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_UNSUPPORTED - Unsupported properties
+ SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
+*/
+
+SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Enc.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Enc.c
new file mode 100644
index 000000000..0e07b5673
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Enc.c
@@ -0,0 +1,484 @@
+/* Lzma2Enc.c -- LZMA2 Encoder
+2009-05-26 : Igor Pavlov : Public domain */
+
+/* #include <stdio.h> */
+#include <string.h>
+
+#include "Lzma2Enc.h"
+
+/* #define COMPRESS_MT */
+
+#ifdef COMPRESS_MT
+#include "MtCoder.h"
+#else
+#define NUM_MT_CODER_THREADS_MAX 1
+#endif
+
+#define LZMA2_CONTROL_LZMA (1 << 7)
+#define LZMA2_CONTROL_COPY_NO_RESET 2
+#define LZMA2_CONTROL_COPY_RESET_DIC 1
+#define LZMA2_CONTROL_EOF 0
+
+#define LZMA2_LCLP_MAX 4
+
+#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11))
+
+#define LZMA2_PACK_SIZE_MAX (1 << 16)
+#define LZMA2_COPY_CHUNK_SIZE LZMA2_PACK_SIZE_MAX
+#define LZMA2_UNPACK_SIZE_MAX (1 << 21)
+#define LZMA2_KEEP_WINDOW_SIZE LZMA2_UNPACK_SIZE_MAX
+
+#define LZMA2_CHUNK_SIZE_COMPRESSED_MAX ((1 << 16) + 16)
+
+
+#define PRF(x) /* x */
+
+/* ---------- CLzma2EncInt ---------- */
+
+typedef struct
+{
+ CLzmaEncHandle enc;
+ UInt64 srcPos;
+ Byte props;
+ Bool needInitState;
+ Bool needInitProp;
+} CLzma2EncInt;
+
+static SRes Lzma2EncInt_Init(CLzma2EncInt *p, const CLzma2EncProps *props)
+{
+ Byte propsEncoded[LZMA_PROPS_SIZE];
+ SizeT propsSize = LZMA_PROPS_SIZE;
+ RINOK(LzmaEnc_SetProps(p->enc, &props->lzmaProps));
+ RINOK(LzmaEnc_WriteProperties(p->enc, propsEncoded, &propsSize));
+ p->srcPos = 0;
+ p->props = propsEncoded[0];
+ p->needInitState = True;
+ p->needInitProp = True;
+ return SZ_OK;
+}
+
+SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ISeqInStream *inStream, UInt32 keepWindowSize,
+ ISzAlloc *alloc, ISzAlloc *allocBig);
+SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
+ UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig);
+SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
+ Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize);
+const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp);
+void LzmaEnc_Finish(CLzmaEncHandle pp);
+void LzmaEnc_SaveState(CLzmaEncHandle pp);
+void LzmaEnc_RestoreState(CLzmaEncHandle pp);
+
+
+static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
+ size_t *packSizeRes, ISeqOutStream *outStream)
+{
+ size_t packSizeLimit = *packSizeRes;
+ size_t packSize = packSizeLimit;
+ UInt32 unpackSize = LZMA2_UNPACK_SIZE_MAX;
+ unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0);
+ Bool useCopyBlock;
+ SRes res;
+
+ *packSizeRes = 0;
+ if (packSize < lzHeaderSize)
+ return SZ_ERROR_OUTPUT_EOF;
+ packSize -= lzHeaderSize;
+
+ LzmaEnc_SaveState(p->enc);
+ res = LzmaEnc_CodeOneMemBlock(p->enc, p->needInitState,
+ outBuf + lzHeaderSize, &packSize, LZMA2_PACK_SIZE_MAX, &unpackSize);
+
+ PRF(printf("\npackSize = %7d unpackSize = %7d ", packSize, unpackSize));
+
+ if (unpackSize == 0)
+ return res;
+
+ if (res == SZ_OK)
+ useCopyBlock = (packSize + 2 >= unpackSize || packSize > (1 << 16));
+ else
+ {
+ if (res != SZ_ERROR_OUTPUT_EOF)
+ return res;
+ res = SZ_OK;
+ useCopyBlock = True;
+ }
+
+ if (useCopyBlock)
+ {
+ size_t destPos = 0;
+ PRF(printf("################# COPY "));
+ while (unpackSize > 0)
+ {
+ UInt32 u = (unpackSize < LZMA2_COPY_CHUNK_SIZE) ? unpackSize : LZMA2_COPY_CHUNK_SIZE;
+ if (packSizeLimit - destPos < u + 3)
+ return SZ_ERROR_OUTPUT_EOF;
+ outBuf[destPos++] = (Byte)(p->srcPos == 0 ? LZMA2_CONTROL_COPY_RESET_DIC : LZMA2_CONTROL_COPY_NO_RESET);
+ outBuf[destPos++] = (Byte)((u - 1) >> 8);
+ outBuf[destPos++] = (Byte)(u - 1);
+ memcpy(outBuf + destPos, LzmaEnc_GetCurBuf(p->enc) - unpackSize, u);
+ unpackSize -= u;
+ destPos += u;
+ p->srcPos += u;
+ if (outStream)
+ {
+ *packSizeRes += destPos;
+ if (outStream->Write(outStream, outBuf, destPos) != destPos)
+ return SZ_ERROR_WRITE;
+ destPos = 0;
+ }
+ else
+ *packSizeRes = destPos;
+ /* needInitState = True; */
+ }
+ LzmaEnc_RestoreState(p->enc);
+ return SZ_OK;
+ }
+ {
+ size_t destPos = 0;
+ UInt32 u = unpackSize - 1;
+ UInt32 pm = (UInt32)(packSize - 1);
+ unsigned mode = (p->srcPos == 0) ? 3 : (p->needInitState ? (p->needInitProp ? 2 : 1) : 0);
+
+ PRF(printf(" "));
+
+ outBuf[destPos++] = (Byte)((LZMA2_CONTROL_LZMA | (mode << 5)) | ((u >> 16) & 0x1F));
+ outBuf[destPos++] = (Byte)(u >> 8);
+ outBuf[destPos++] = (Byte)u;
+ outBuf[destPos++] = (Byte)(pm >> 8);
+ outBuf[destPos++] = (Byte)pm;
+
+ if (p->needInitProp)
+ outBuf[destPos++] = p->props;
+
+ p->needInitProp = False;
+ p->needInitState = False;
+ destPos += packSize;
+ p->srcPos += unpackSize;
+
+ if (outStream)
+ if (outStream->Write(outStream, outBuf, destPos) != destPos)
+ return SZ_ERROR_WRITE;
+ *packSizeRes = destPos;
+ return SZ_OK;
+ }
+}
+
+/* ---------- Lzma2 Props ---------- */
+
+void Lzma2EncProps_Init(CLzma2EncProps *p)
+{
+ LzmaEncProps_Init(&p->lzmaProps);
+ p->numTotalThreads = -1;
+ p->numBlockThreads = -1;
+ p->blockSize = 0;
+}
+
+
+static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)
+{
+ return (p && p->Progress(p, inSize, outSize) != SZ_OK) ? SZ_ERROR_PROGRESS : SZ_OK;
+}
+
+/* ---------- Lzma2 ---------- */
+
+//extern struct _CLzma2Enc;
+
+typedef struct _CLzma2Enc
+{
+ Byte propEncoded;
+ CLzma2EncProps props;
+
+ Byte *outBuf;
+
+ ISzAlloc *alloc;
+ ISzAlloc *allocBig;
+
+ CLzma2EncInt coders[NUM_MT_CODER_THREADS_MAX];
+
+ #ifdef COMPRESS_MT
+ CMtCoder mtCoder;
+ #endif
+
+} CLzma2Enc;
+
+
+/* ---------- Lzma2EncThread ---------- */
+
+static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,
+ ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress)
+{
+ UInt64 packTotal = 0;
+ SRes res = SZ_OK;
+
+ if (mainEncoder->outBuf == 0)
+ {
+ mainEncoder->outBuf = IAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
+ if (mainEncoder->outBuf == 0)
+ return SZ_ERROR_MEM;
+ }
+ RINOK(Lzma2EncInt_Init(p, &mainEncoder->props));
+ RINOK(LzmaEnc_PrepareForLzma2(p->enc, inStream, LZMA2_KEEP_WINDOW_SIZE,
+ mainEncoder->alloc, mainEncoder->allocBig));
+ for (;;)
+ {
+ size_t packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX;
+ res = Lzma2EncInt_EncodeSubblock(p, mainEncoder->outBuf, &packSize, outStream);
+ if (res != SZ_OK)
+ break;
+ packTotal += packSize;
+ res = Progress(progress, p->srcPos, packTotal);
+ if (res != SZ_OK)
+ break;
+ if (packSize == 0)
+ break;
+ }
+ LzmaEnc_Finish(p->enc);
+ if (res == SZ_OK)
+ {
+ Byte b = 0;
+ if (outStream->Write(outStream, &b, 1) != 1)
+ return SZ_ERROR_WRITE;
+ }
+ return res;
+}
+
+#ifdef COMPRESS_MT
+
+typedef struct
+{
+ IMtCoderCallback funcTable;
+ CLzma2Enc *lzma2Enc;
+} CMtCallbackImp;
+
+static SRes MtCallbackImp_Code(void *pp, unsigned index, Byte *dest, size_t *destSize,
+ const Byte *src, size_t srcSize, int finished)
+{
+ CMtCallbackImp *imp = (CMtCallbackImp *)pp;
+ CLzma2Enc *mainEncoder = imp->lzma2Enc;
+ CLzma2EncInt *p = &mainEncoder->coders[index];
+
+ SRes res = SZ_OK;
+ {
+ size_t destLim = *destSize;
+ *destSize = 0;
+
+ if (srcSize != 0)
+ {
+ RINOK(Lzma2EncInt_Init(p, &mainEncoder->props));
+
+ RINOK(LzmaEnc_MemPrepare(p->enc, src, srcSize, LZMA2_KEEP_WINDOW_SIZE,
+ mainEncoder->alloc, mainEncoder->allocBig));
+
+ while (p->srcPos < srcSize)
+ {
+ size_t packSize = destLim - *destSize;
+ res = Lzma2EncInt_EncodeSubblock(p, dest + *destSize, &packSize, NULL);
+ if (res != SZ_OK)
+ break;
+ *destSize += packSize;
+
+ if (packSize == 0)
+ {
+ res = SZ_ERROR_FAIL;
+ break;
+ }
+
+ if (MtProgress_Set(&mainEncoder->mtCoder.mtProgress, index, p->srcPos, *destSize) != SZ_OK)
+ {
+ res = SZ_ERROR_PROGRESS;
+ break;
+ }
+ }
+ LzmaEnc_Finish(p->enc);
+ if (res != SZ_OK)
+ return res;
+ }
+ if (finished)
+ {
+ if (*destSize == destLim)
+ return SZ_ERROR_OUTPUT_EOF;
+ dest[(*destSize)++] = 0;
+ }
+ }
+ return res;
+}
+
+#endif
+
+/* ---------- Lzma2Enc ---------- */
+
+CLzma2EncHandle Lzma2Enc_Create(ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ CLzma2Enc *p = (CLzma2Enc *)alloc->Alloc(alloc, sizeof(CLzma2Enc));
+ if (p == 0)
+ return NULL;
+ Lzma2EncProps_Init(&p->props);
+ Lzma2EncProps_Normalize(&p->props);
+ p->outBuf = 0;
+ p->alloc = alloc;
+ p->allocBig = allocBig;
+ {
+ unsigned i;
+ for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
+ p->coders[i].enc = 0;
+ }
+ #ifdef COMPRESS_MT
+ MtCoder_Construct(&p->mtCoder);
+ #endif
+
+ return p;
+}
+
+void Lzma2Enc_Destroy(CLzma2EncHandle pp)
+{
+ CLzma2Enc *p = (CLzma2Enc *)pp;
+ unsigned i;
+ for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
+ {
+ CLzma2EncInt *t = &p->coders[i];
+ if (t->enc)
+ {
+ LzmaEnc_Destroy(t->enc, p->alloc, p->allocBig);
+ t->enc = 0;
+ }
+ }
+
+ #ifdef COMPRESS_MT
+ MtCoder_Destruct(&p->mtCoder);
+ #endif
+
+ IAlloc_Free(p->alloc, p->outBuf);
+ IAlloc_Free(p->alloc, pp);
+}
+
+void Lzma2EncProps_Normalize(CLzma2EncProps *p)
+{
+ int t1, t1n, t2, t3;
+ CLzmaEncProps lzmaProps = p->lzmaProps;
+
+ LzmaEncProps_Normalize(&lzmaProps);
+
+ t1 = p->lzmaProps.numThreads;
+ t1n = lzmaProps.numThreads;
+ t2 = p->numBlockThreads;
+ t3 = p->numTotalThreads;
+
+ #ifdef COMPRESS_MT
+ if (t2 > NUM_MT_CODER_THREADS_MAX)
+ t2 = NUM_MT_CODER_THREADS_MAX;
+ #else
+ t2 = 1;
+ #endif
+
+ if (t3 <= 0)
+ {
+ if (t2 <= 0)
+ t2 = 1;
+ t3 = t1n * t2;
+ }
+ else
+ {
+ if (t2 <= 0)
+ {
+ t2 = t3 / t1n;
+ if (t2 == 0)
+ {
+ t1 = 1;
+ t2 = t3;
+ }
+ }
+ else if (t1 <= 0)
+ {
+ t1 = t3 / t2;
+ if (t1 == 0)
+ t1 = 1;
+ }
+ else
+ t3 = t1n * t2;
+ }
+
+ p->lzmaProps.numThreads = t1;
+ p->numBlockThreads = t2;
+ p->numTotalThreads = t3;
+ LzmaEncProps_Normalize(&p->lzmaProps);
+
+ if (p->blockSize == 0)
+ {
+ UInt64 blockSize = (UInt64)lzmaProps.dictSize << 2;
+ const UInt32 kMinSize = (UInt32)1 << 20;
+ const UInt32 kMaxSize = (UInt32)1 << 28;
+ if (blockSize < kMinSize) blockSize = kMinSize;
+ if (blockSize > kMaxSize) blockSize = kMaxSize;
+ if (blockSize < lzmaProps.dictSize)
+ blockSize = lzmaProps.dictSize;
+ p->blockSize = (size_t)blockSize;
+ }
+}
+
+SRes Lzma2Enc_SetProps(CLzma2EncHandle pp, const CLzma2EncProps *props)
+{
+ CLzma2Enc *p = (CLzma2Enc *)pp;
+ CLzmaEncProps lzmaProps = props->lzmaProps;
+ LzmaEncProps_Normalize(&lzmaProps);
+ if (lzmaProps.lc + lzmaProps.lp > LZMA2_LCLP_MAX)
+ return SZ_ERROR_PARAM;
+ p->props = *props;
+ Lzma2EncProps_Normalize(&p->props);
+ return SZ_OK;
+}
+
+Byte Lzma2Enc_WriteProperties(CLzma2EncHandle pp)
+{
+ CLzma2Enc *p = (CLzma2Enc *)pp;
+ unsigned i;
+ UInt32 dicSize = LzmaEncProps_GetDictSize(&p->props.lzmaProps);
+ for (i = 0; i < 40; i++)
+ if (dicSize <= LZMA2_DIC_SIZE_FROM_PROP(i))
+ break;
+ return (Byte)i;
+}
+
+SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
+ ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress)
+{
+ CLzma2Enc *p = (CLzma2Enc *)pp;
+ int i;
+
+ for (i = 0; i < p->props.numBlockThreads; i++)
+ {
+ CLzma2EncInt *t = &p->coders[i];
+ if (t->enc == NULL)
+ {
+ t->enc = LzmaEnc_Create(p->alloc);
+ if (t->enc == NULL)
+ return SZ_ERROR_MEM;
+ }
+ }
+
+ #ifdef COMPRESS_MT
+ if (p->props.numBlockThreads <= 1)
+ #endif
+ return Lzma2Enc_EncodeMt1(&p->coders[0], p, outStream, inStream, progress);
+
+ #ifdef COMPRESS_MT
+
+ {
+ CMtCallbackImp mtCallback;
+
+ mtCallback.funcTable.Code = MtCallbackImp_Code;
+ mtCallback.lzma2Enc = p;
+
+ p->mtCoder.progress = progress;
+ p->mtCoder.inStream = inStream;
+ p->mtCoder.outStream = outStream;
+ p->mtCoder.alloc = p->alloc;
+ p->mtCoder.mtCallback = &mtCallback.funcTable;
+
+ p->mtCoder.blockSize = p->props.blockSize;
+ p->mtCoder.destBlockSize = p->props.blockSize + (p->props.blockSize >> 10) + 16;
+ p->mtCoder.numThreads = p->props.numBlockThreads;
+
+ return MtCoder_Code(&p->mtCoder);
+ }
+ #endif
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Enc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Enc.h
new file mode 100644
index 000000000..283525581
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Lzma2Enc.h
@@ -0,0 +1,66 @@
+/* Lzma2Enc.h -- LZMA2 Encoder
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __LZMA2_ENC_H
+#define __LZMA2_ENC_H
+
+#include "LzmaEnc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ CLzmaEncProps lzmaProps;
+ size_t blockSize;
+ int numBlockThreads;
+ int numTotalThreads;
+} CLzma2EncProps;
+
+void Lzma2EncProps_Init(CLzma2EncProps *p);
+void Lzma2EncProps_Normalize(CLzma2EncProps *p);
+
+/* ---------- CLzmaEnc2Handle Interface ---------- */
+
+/* Lzma2Enc_* functions can return the following exit codes:
+Returns:
+ SZ_OK - OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_PARAM - Incorrect paramater in props
+ SZ_ERROR_WRITE - Write callback error
+ SZ_ERROR_PROGRESS - some break from progress callback
+ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
+*/
+
+typedef void * CLzma2EncHandle;
+
+CLzma2EncHandle Lzma2Enc_Create(ISzAlloc *alloc, ISzAlloc *allocBig);
+void Lzma2Enc_Destroy(CLzma2EncHandle p);
+SRes Lzma2Enc_SetProps(CLzma2EncHandle p, const CLzma2EncProps *props);
+Byte Lzma2Enc_WriteProperties(CLzma2EncHandle p);
+SRes Lzma2Enc_Encode(CLzma2EncHandle p,
+ ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress);
+
+/* ---------- One Call Interface ---------- */
+
+/* Lzma2Encode
+Return code:
+ SZ_OK - OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_PARAM - Incorrect paramater
+ SZ_ERROR_OUTPUT_EOF - output buffer overflow
+ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
+*/
+
+/*
+SRes Lzma2Encode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ const CLzmaEncProps *props, Byte *propsEncoded, int writeEndMark,
+ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaDec.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaDec.c
new file mode 100644
index 000000000..d87eb1914
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaDec.c
@@ -0,0 +1,1007 @@
+/* LzmaDec.c -- LZMA Decoder
+2008-11-06 : Igor Pavlov : Public domain */
+
+#include "LzmaDec.h"
+
+#include <string.h>
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+
+#define RC_INIT_SIZE 5
+
+#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
+
+#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
+#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
+#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
+#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
+ { UPDATE_0(p); i = (i + i); A0; } else \
+ { UPDATE_1(p); i = (i + i) + 1; A1; }
+#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;)
+
+#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); }
+#define TREE_DECODE(probs, limit, i) \
+ { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
+
+/* #define _LZMA_SIZE_OPT */
+
+#ifdef _LZMA_SIZE_OPT
+#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)
+#else
+#define TREE_6_DECODE(probs, i) \
+ { i = 1; \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ i -= 0x40; }
+#endif
+
+#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
+
+#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
+#define UPDATE_0_CHECK range = bound;
+#define UPDATE_1_CHECK range -= bound; code -= bound;
+#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
+ { UPDATE_0_CHECK; i = (i + i); A0; } else \
+ { UPDATE_1_CHECK; i = (i + i) + 1; A1; }
+#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)
+#define TREE_DECODE_CHECK(probs, limit, i) \
+ { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
+
+
+#define kNumPosBitsMax 4
+#define kNumPosStatesMax (1 << kNumPosBitsMax)
+
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumMidBits 3
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
+
+#define LenChoice 0
+#define LenChoice2 (LenChoice + 1)
+#define LenLow (LenChoice2 + 1)
+#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
+#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
+#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
+
+
+#define kNumStates 12
+#define kNumLitStates 7
+
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
+
+#define kNumPosSlotBits 6
+#define kNumLenToPosStates 4
+
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
+
+#define kMatchMinLen 2
+#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
+
+#define IsMatch 0
+#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
+#define IsRepG0 (IsRep + kNumStates)
+#define IsRepG1 (IsRepG0 + kNumStates)
+#define IsRepG2 (IsRepG1 + kNumStates)
+#define IsRep0Long (IsRepG2 + kNumStates)
+#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
+#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
+#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
+#define LenCoder (Align + kAlignTableSize)
+#define RepLenCoder (LenCoder + kNumLenProbs)
+#define Literal (RepLenCoder + kNumLenProbs)
+
+#define LZMA_BASE_SIZE 1846
+#define LZMA_LIT_SIZE 768
+
+#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
+
+#if Literal != LZMA_BASE_SIZE
+StopCompilingDueBUG
+#endif
+
+static const Byte kLiteralNextStates[kNumStates * 2] =
+{
+ 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5,
+ 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10
+};
+
+#define LZMA_DIC_MIN (1 << 12)
+
+/* First LZMA-symbol is always decoded.
+And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization
+Out:
+ Result:
+ SZ_OK - OK
+ SZ_ERROR_DATA - Error
+ p->remainLen:
+ < kMatchSpecLenStart : normal remain
+ = kMatchSpecLenStart : finished
+ = kMatchSpecLenStart + 1 : Flush marker
+ = kMatchSpecLenStart + 2 : State Init Marker
+*/
+
+static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
+{
+ CLzmaProb *probs = p->probs;
+
+ unsigned state = p->state;
+ UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
+ unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
+ unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;
+ unsigned lc = p->prop.lc;
+
+ Byte *dic = p->dic;
+ SizeT dicBufSize = p->dicBufSize;
+ SizeT dicPos = p->dicPos;
+
+ UInt32 processedPos = p->processedPos;
+ UInt32 checkDicSize = p->checkDicSize;
+ unsigned len = 0;
+
+ const Byte *buf = p->buf;
+ UInt32 range = p->range;
+ UInt32 code = p->code;
+
+ do
+ {
+ CLzmaProb *prob;
+ UInt32 bound;
+ unsigned ttt;
+ unsigned posState = processedPos & pbMask;
+
+ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
+ IF_BIT_0(prob)
+ {
+ unsigned symbol;
+ UPDATE_0(prob);
+ prob = probs + Literal;
+ if (checkDicSize != 0 || processedPos != 0)
+ prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +
+ (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
+
+ if (state < kNumLitStates)
+ {
+ symbol = 1;
+ do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
+ }
+ else
+ {
+ unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+ unsigned offs = 0x100;
+ symbol = 1;
+ do
+ {
+ unsigned bit;
+ CLzmaProb *probLit;
+ matchByte <<= 1;
+ bit = (matchByte & offs);
+ probLit = prob + offs + bit + symbol;
+ GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
+ }
+ while (symbol < 0x100);
+ }
+ dic[dicPos++] = (Byte)symbol;
+ processedPos++;
+
+ state = kLiteralNextStates[state];
+ /* if (state < 4) state = 0; else if (state < 10) state -= 3; else state -= 6; */
+ continue;
+ }
+ else
+ {
+ UPDATE_1(prob);
+ prob = probs + IsRep + state;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ state += kNumStates;
+ prob = probs + LenCoder;
+ }
+ else
+ {
+ UPDATE_1(prob);
+ if (checkDicSize == 0 && processedPos == 0)
+ return SZ_ERROR_DATA;
+ prob = probs + IsRepG0 + state;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+ dicPos++;
+ processedPos++;
+ state = state < kNumLitStates ? 9 : 11;
+ continue;
+ }
+ UPDATE_1(prob);
+ }
+ else
+ {
+ UInt32 distance;
+ UPDATE_1(prob);
+ prob = probs + IsRepG1 + state;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ distance = rep1;
+ }
+ else
+ {
+ UPDATE_1(prob);
+ prob = probs + IsRepG2 + state;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ distance = rep2;
+ }
+ else
+ {
+ UPDATE_1(prob);
+ distance = rep3;
+ rep3 = rep2;
+ }
+ rep2 = rep1;
+ }
+ rep1 = rep0;
+ rep0 = distance;
+ }
+ state = state < kNumLitStates ? 8 : 11;
+ prob = probs + RepLenCoder;
+ }
+ {
+ unsigned limit, offset;
+ CLzmaProb *probLen = prob + LenChoice;
+ IF_BIT_0(probLen)
+ {
+ UPDATE_0(probLen);
+ probLen = prob + LenLow + (posState << kLenNumLowBits);
+ offset = 0;
+ limit = (1 << kLenNumLowBits);
+ }
+ else
+ {
+ UPDATE_1(probLen);
+ probLen = prob + LenChoice2;
+ IF_BIT_0(probLen)
+ {
+ UPDATE_0(probLen);
+ probLen = prob + LenMid + (posState << kLenNumMidBits);
+ offset = kLenNumLowSymbols;
+ limit = (1 << kLenNumMidBits);
+ }
+ else
+ {
+ UPDATE_1(probLen);
+ probLen = prob + LenHigh;
+ offset = kLenNumLowSymbols + kLenNumMidSymbols;
+ limit = (1 << kLenNumHighBits);
+ }
+ }
+ TREE_DECODE(probLen, limit, len);
+ len += offset;
+ }
+
+ if (state >= kNumStates)
+ {
+ UInt32 distance;
+ prob = probs + PosSlot +
+ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
+ TREE_6_DECODE(prob, distance);
+ if (distance >= kStartPosModelIndex)
+ {
+ unsigned posSlot = (unsigned)distance;
+ int numDirectBits = (int)(((distance >> 1) - 1));
+ distance = (2 | (distance & 1));
+ if (posSlot < kEndPosModelIndex)
+ {
+ distance <<= numDirectBits;
+ prob = probs + SpecPos + distance - posSlot - 1;
+ {
+ UInt32 mask = 1;
+ unsigned i = 1;
+ do
+ {
+ GET_BIT2(prob + i, i, ; , distance |= mask);
+ mask <<= 1;
+ }
+ while (--numDirectBits != 0);
+ }
+ }
+ else
+ {
+ numDirectBits -= kNumAlignBits;
+ do
+ {
+ NORMALIZE
+ range >>= 1;
+
+ {
+ UInt32 t;
+ code -= range;
+ t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
+ distance = (distance << 1) + (t + 1);
+ code += range & t;
+ }
+ /*
+ distance <<= 1;
+ if (code >= range)
+ {
+ code -= range;
+ distance |= 1;
+ }
+ */
+ }
+ while (--numDirectBits != 0);
+ prob = probs + Align;
+ distance <<= kNumAlignBits;
+ {
+ unsigned i = 1;
+ GET_BIT2(prob + i, i, ; , distance |= 1);
+ GET_BIT2(prob + i, i, ; , distance |= 2);
+ GET_BIT2(prob + i, i, ; , distance |= 4);
+ GET_BIT2(prob + i, i, ; , distance |= 8);
+ }
+ if (distance == (UInt32)0xFFFFFFFF)
+ {
+ len += kMatchSpecLenStart;
+ state -= kNumStates;
+ break;
+ }
+ }
+ }
+ rep3 = rep2;
+ rep2 = rep1;
+ rep1 = rep0;
+ rep0 = distance + 1;
+ if (checkDicSize == 0)
+ {
+ if (distance >= processedPos)
+ return SZ_ERROR_DATA;
+ }
+ else if (distance >= checkDicSize)
+ return SZ_ERROR_DATA;
+ state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
+ /* state = kLiteralNextStates[state]; */
+ }
+
+ len += kMatchMinLen;
+
+ if (limit == dicPos)
+ return SZ_ERROR_DATA;
+ {
+ SizeT rem = limit - dicPos;
+ unsigned curLen = ((rem < len) ? (unsigned)rem : len);
+ SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0);
+
+ processedPos += curLen;
+
+ len -= curLen;
+ if (pos + curLen <= dicBufSize)
+ {
+ Byte *dest = dic + dicPos;
+ ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
+ const Byte *lim = dest + curLen;
+ dicPos += curLen;
+ do
+ *(dest) = (Byte)*(dest + src);
+ while (++dest != lim);
+ }
+ else
+ {
+ do
+ {
+ dic[dicPos++] = dic[pos];
+ if (++pos == dicBufSize)
+ pos = 0;
+ }
+ while (--curLen != 0);
+ }
+ }
+ }
+ }
+ while (dicPos < limit && buf < bufLimit);
+ NORMALIZE;
+ p->buf = buf;
+ p->range = range;
+ p->code = code;
+ p->remainLen = len;
+ p->dicPos = dicPos;
+ p->processedPos = processedPos;
+ p->reps[0] = rep0;
+ p->reps[1] = rep1;
+ p->reps[2] = rep2;
+ p->reps[3] = rep3;
+ p->state = state;
+
+ return SZ_OK;
+}
+
+static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
+{
+ if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
+ {
+ Byte *dic = p->dic;
+ SizeT dicPos = p->dicPos;
+ SizeT dicBufSize = p->dicBufSize;
+ unsigned len = p->remainLen;
+ UInt32 rep0 = p->reps[0];
+ if (limit - dicPos < len)
+ len = (unsigned)(limit - dicPos);
+
+ if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
+ p->checkDicSize = p->prop.dicSize;
+
+ p->processedPos += len;
+ p->remainLen -= len;
+ while (len-- != 0)
+ {
+ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+ dicPos++;
+ }
+ p->dicPos = dicPos;
+ }
+}
+
+static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
+{
+ do
+ {
+ SizeT limit2 = limit;
+ if (p->checkDicSize == 0)
+ {
+ UInt32 rem = p->prop.dicSize - p->processedPos;
+ if (limit - p->dicPos > rem)
+ limit2 = p->dicPos + rem;
+ }
+ RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit));
+ if (p->processedPos >= p->prop.dicSize)
+ p->checkDicSize = p->prop.dicSize;
+ LzmaDec_WriteRem(p, limit);
+ }
+ while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
+
+ if (p->remainLen > kMatchSpecLenStart)
+ {
+ p->remainLen = kMatchSpecLenStart;
+ }
+ return 0;
+}
+
+typedef enum
+{
+ DUMMY_ERROR, /* unexpected end of input stream */
+ DUMMY_LIT,
+ DUMMY_MATCH,
+ DUMMY_REP
+} ELzmaDummy;
+
+static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
+{
+ UInt32 range = p->range;
+ UInt32 code = p->code;
+ const Byte *bufLimit = buf + inSize;
+ CLzmaProb *probs = p->probs;
+ unsigned state = p->state;
+ ELzmaDummy res;
+
+ {
+ CLzmaProb *prob;
+ UInt32 bound;
+ unsigned ttt;
+ unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);
+
+ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK
+
+ /* if (bufLimit - buf >= 7) return DUMMY_LIT; */
+
+ prob = probs + Literal;
+ if (p->checkDicSize != 0 || p->processedPos != 0)
+ prob += (LZMA_LIT_SIZE *
+ ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
+ (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
+
+ if (state < kNumLitStates)
+ {
+ unsigned symbol = 1;
+ do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);
+ }
+ else
+ {
+ unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
+ ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)];
+ unsigned offs = 0x100;
+ unsigned symbol = 1;
+ do
+ {
+ unsigned bit;
+ CLzmaProb *probLit;
+ matchByte <<= 1;
+ bit = (matchByte & offs);
+ probLit = prob + offs + bit + symbol;
+ GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
+ }
+ while (symbol < 0x100);
+ }
+ res = DUMMY_LIT;
+ }
+ else
+ {
+ unsigned len;
+ UPDATE_1_CHECK;
+
+ prob = probs + IsRep + state;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ state = 0;
+ prob = probs + LenCoder;
+ res = DUMMY_MATCH;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ res = DUMMY_REP;
+ prob = probs + IsRepG0 + state;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ NORMALIZE_CHECK;
+ return DUMMY_REP;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ }
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ prob = probs + IsRepG1 + state;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ prob = probs + IsRepG2 + state;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ }
+ }
+ }
+ state = kNumStates;
+ prob = probs + RepLenCoder;
+ }
+ {
+ unsigned limit, offset;
+ CLzmaProb *probLen = prob + LenChoice;
+ IF_BIT_0_CHECK(probLen)
+ {
+ UPDATE_0_CHECK;
+ probLen = prob + LenLow + (posState << kLenNumLowBits);
+ offset = 0;
+ limit = 1 << kLenNumLowBits;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ probLen = prob + LenChoice2;
+ IF_BIT_0_CHECK(probLen)
+ {
+ UPDATE_0_CHECK;
+ probLen = prob + LenMid + (posState << kLenNumMidBits);
+ offset = kLenNumLowSymbols;
+ limit = 1 << kLenNumMidBits;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ probLen = prob + LenHigh;
+ offset = kLenNumLowSymbols + kLenNumMidSymbols;
+ limit = 1 << kLenNumHighBits;
+ }
+ }
+ TREE_DECODE_CHECK(probLen, limit, len);
+ len += offset;
+ }
+
+ if (state < 4)
+ {
+ unsigned posSlot;
+ prob = probs + PosSlot +
+ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
+ kNumPosSlotBits);
+ TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
+ if (posSlot >= kStartPosModelIndex)
+ {
+ int numDirectBits = ((posSlot >> 1) - 1);
+
+ /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */
+
+ if (posSlot < kEndPosModelIndex)
+ {
+ prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1;
+ }
+ else
+ {
+ numDirectBits -= kNumAlignBits;
+ do
+ {
+ NORMALIZE_CHECK
+ range >>= 1;
+ code -= range & (((code - range) >> 31) - 1);
+ /* if (code >= range) code -= range; */
+ }
+ while (--numDirectBits != 0);
+ prob = probs + Align;
+ numDirectBits = kNumAlignBits;
+ }
+ {
+ unsigned i = 1;
+ do
+ {
+ GET_BIT_CHECK(prob + i, i);
+ }
+ while (--numDirectBits != 0);
+ }
+ }
+ }
+ }
+ }
+ NORMALIZE_CHECK;
+ return res;
+}
+
+
+static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
+{
+ p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]);
+ p->range = 0xFFFFFFFF;
+ p->needFlush = 0;
+}
+
+void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
+{
+ p->needFlush = 1;
+ p->remainLen = 0;
+ p->tempBufSize = 0;
+
+ if (initDic)
+ {
+ p->processedPos = 0;
+ p->checkDicSize = 0;
+ p->needInitState = 1;
+ }
+ if (initState)
+ p->needInitState = 1;
+}
+
+void LzmaDec_Init(CLzmaDec *p)
+{
+ p->dicPos = 0;
+ LzmaDec_InitDicAndState(p, True, True);
+}
+
+static void LzmaDec_InitStateReal(CLzmaDec *p)
+{
+ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
+ UInt32 i;
+ CLzmaProb *probs = p->probs;
+ for (i = 0; i < numProbs; i++)
+ probs[i] = kBitModelTotal >> 1;
+ p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
+ p->state = 0;
+ p->needInitState = 0;
+}
+
+SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
+ ELzmaFinishMode finishMode, ELzmaStatus *status)
+{
+ SizeT inSize = *srcLen;
+ (*srcLen) = 0;
+ LzmaDec_WriteRem(p, dicLimit);
+
+ *status = LZMA_STATUS_NOT_SPECIFIED;
+
+ while (p->remainLen != kMatchSpecLenStart)
+ {
+ int checkEndMarkNow;
+
+ if (p->needFlush != 0)
+ {
+ for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
+ p->tempBuf[p->tempBufSize++] = *src++;
+ if (p->tempBufSize < RC_INIT_SIZE)
+ {
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+ return SZ_OK;
+ }
+ if (p->tempBuf[0] != 0)
+ return SZ_ERROR_DATA;
+
+ LzmaDec_InitRc(p, p->tempBuf);
+ p->tempBufSize = 0;
+ }
+
+ checkEndMarkNow = 0;
+ if (p->dicPos >= dicLimit)
+ {
+ if (p->remainLen == 0 && p->code == 0)
+ {
+ *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;
+ return SZ_OK;
+ }
+ if (finishMode == LZMA_FINISH_ANY)
+ {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_OK;
+ }
+ if (p->remainLen != 0)
+ {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_ERROR_DATA;
+ }
+ checkEndMarkNow = 1;
+ }
+
+ if (p->needInitState)
+ LzmaDec_InitStateReal(p);
+
+ if (p->tempBufSize == 0)
+ {
+ SizeT processed;
+ const Byte *bufLimit;
+ if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
+ {
+ int dummyRes = LzmaDec_TryDummy(p, src, inSize);
+ if (dummyRes == DUMMY_ERROR)
+ {
+ memcpy(p->tempBuf, src, inSize);
+ p->tempBufSize = (unsigned)inSize;
+ (*srcLen) += inSize;
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+ return SZ_OK;
+ }
+ if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
+ {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_ERROR_DATA;
+ }
+ bufLimit = src;
+ }
+ else
+ bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;
+ p->buf = src;
+ if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)
+ return SZ_ERROR_DATA;
+ processed = (SizeT)(p->buf - src);
+ (*srcLen) += processed;
+ src += processed;
+ inSize -= processed;
+ }
+ else
+ {
+ unsigned rem = p->tempBufSize, lookAhead = 0;
+ while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)
+ p->tempBuf[rem++] = src[lookAhead++];
+ p->tempBufSize = rem;
+ if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
+ {
+ int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);
+ if (dummyRes == DUMMY_ERROR)
+ {
+ (*srcLen) += lookAhead;
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+ return SZ_OK;
+ }
+ if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
+ {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_ERROR_DATA;
+ }
+ }
+ p->buf = p->tempBuf;
+ if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)
+ return SZ_ERROR_DATA;
+ lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf));
+ (*srcLen) += lookAhead;
+ src += lookAhead;
+ inSize -= lookAhead;
+ p->tempBufSize = 0;
+ }
+ }
+ if (p->code == 0)
+ *status = LZMA_STATUS_FINISHED_WITH_MARK;
+ return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
+}
+
+SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
+{
+ SizeT outSize = *destLen;
+ SizeT inSize = *srcLen;
+ *srcLen = *destLen = 0;
+ for (;;)
+ {
+ SizeT inSizeCur = inSize, outSizeCur, dicPos;
+ ELzmaFinishMode curFinishMode;
+ SRes res;
+ if (p->dicPos == p->dicBufSize)
+ p->dicPos = 0;
+ dicPos = p->dicPos;
+ if (outSize > p->dicBufSize - dicPos)
+ {
+ outSizeCur = p->dicBufSize;
+ curFinishMode = LZMA_FINISH_ANY;
+ }
+ else
+ {
+ outSizeCur = dicPos + outSize;
+ curFinishMode = finishMode;
+ }
+
+ res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
+ src += inSizeCur;
+ inSize -= inSizeCur;
+ *srcLen += inSizeCur;
+ outSizeCur = p->dicPos - dicPos;
+ memcpy(dest, p->dic + dicPos, outSizeCur);
+ dest += outSizeCur;
+ outSize -= outSizeCur;
+ *destLen += outSizeCur;
+ if (res != 0)
+ return res;
+ if (outSizeCur == 0 || outSize == 0)
+ return SZ_OK;
+ }
+}
+
+void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->probs);
+ p->probs = 0;
+}
+
+static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->dic);
+ p->dic = 0;
+}
+
+void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
+{
+ LzmaDec_FreeProbs(p, alloc);
+ LzmaDec_FreeDict(p, alloc);
+}
+
+SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
+{
+ UInt32 dicSize;
+ Byte d;
+
+ if (size < LZMA_PROPS_SIZE)
+ return SZ_ERROR_UNSUPPORTED;
+ else
+ dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
+
+ if (dicSize < LZMA_DIC_MIN)
+ dicSize = LZMA_DIC_MIN;
+ p->dicSize = dicSize;
+
+ d = data[0];
+ if (d >= (9 * 5 * 5))
+ return SZ_ERROR_UNSUPPORTED;
+
+ p->lc = d % 9;
+ d /= 9;
+ p->pb = d / 5;
+ p->lp = d % 5;
+
+ return SZ_OK;
+}
+
+static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
+{
+ UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
+ if (p->probs == 0 || numProbs != p->numProbs)
+ {
+ LzmaDec_FreeProbs(p, alloc);
+ p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb));
+ p->numProbs = numProbs;
+ if (p->probs == 0)
+ return SZ_ERROR_MEM;
+ }
+ return SZ_OK;
+}
+
+SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+{
+ CLzmaProps propNew;
+ RINOK(LzmaProps_Decode(&propNew, props, propsSize));
+ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+ p->prop = propNew;
+ return SZ_OK;
+}
+
+SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+{
+ CLzmaProps propNew;
+ SizeT dicBufSize;
+ RINOK(LzmaProps_Decode(&propNew, props, propsSize));
+ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+ dicBufSize = propNew.dicSize;
+ if (p->dic == 0 || dicBufSize != p->dicBufSize)
+ {
+ LzmaDec_FreeDict(p, alloc);
+ p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
+ if (p->dic == 0)
+ {
+ LzmaDec_FreeProbs(p, alloc);
+ return SZ_ERROR_MEM;
+ }
+ }
+ p->dicBufSize = dicBufSize;
+ p->prop = propNew;
+ return SZ_OK;
+}
+
+SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+ ELzmaStatus *status, ISzAlloc *alloc)
+{
+ CLzmaDec p;
+ SRes res;
+ SizeT inSize = *srcLen;
+ SizeT outSize = *destLen;
+ *srcLen = *destLen = 0;
+ if (inSize < RC_INIT_SIZE)
+ return SZ_ERROR_INPUT_EOF;
+
+ LzmaDec_Construct(&p);
+ res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc);
+ if (res != 0)
+ return res;
+ p.dic = dest;
+ p.dicBufSize = outSize;
+
+ LzmaDec_Init(&p);
+
+ *srcLen = inSize;
+ res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
+
+ if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
+ res = SZ_ERROR_INPUT_EOF;
+
+ (*destLen) = p.dicPos;
+ LzmaDec_FreeProbs(&p, alloc);
+ return res;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaDec.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaDec.h
new file mode 100644
index 000000000..bf7f084ba
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaDec.h
@@ -0,0 +1,231 @@
+/* LzmaDec.h -- LZMA Decoder
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __LZMA_DEC_H
+#define __LZMA_DEC_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* #define _LZMA_PROB32 */
+/* _LZMA_PROB32 can increase the speed on some CPUs,
+ but memory usage for CLzmaDec::probs will be doubled in that case */
+
+#ifdef _LZMA_PROB32
+#define CLzmaProb UInt32
+#else
+#define CLzmaProb UInt16
+#endif
+
+
+/* ---------- LZMA Properties ---------- */
+
+#define LZMA_PROPS_SIZE 5
+
+typedef struct _CLzmaProps
+{
+ unsigned lc, lp, pb;
+ UInt32 dicSize;
+} CLzmaProps;
+
+/* LzmaProps_Decode - decodes properties
+Returns:
+ SZ_OK
+ SZ_ERROR_UNSUPPORTED - Unsupported properties
+*/
+
+SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
+
+
+/* ---------- LZMA Decoder state ---------- */
+
+/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
+ Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
+
+#define LZMA_REQUIRED_INPUT_MAX 20
+
+typedef struct
+{
+ CLzmaProps prop;
+ CLzmaProb *probs;
+ Byte *dic;
+ const Byte *buf;
+ UInt32 range, code;
+ SizeT dicPos;
+ SizeT dicBufSize;
+ UInt32 processedPos;
+ UInt32 checkDicSize;
+ unsigned state;
+ UInt32 reps[4];
+ unsigned remainLen;
+ int needFlush;
+ int needInitState;
+ UInt32 numProbs;
+ unsigned tempBufSize;
+ Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
+} CLzmaDec;
+
+#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
+
+void LzmaDec_Init(CLzmaDec *p);
+
+/* There are two types of LZMA streams:
+ 0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
+ 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
+
+typedef enum
+{
+ LZMA_FINISH_ANY, /* finish at any point */
+ LZMA_FINISH_END /* block must be finished at the end */
+} ELzmaFinishMode;
+
+/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
+
+ You must use LZMA_FINISH_END, when you know that current output buffer
+ covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
+
+ If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
+ and output value of destLen will be less than output buffer size limit.
+ You can check status result also.
+
+ You can use multiple checks to test data integrity after full decompression:
+ 1) Check Result and "status" variable.
+ 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
+ 3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
+ You must use correct finish mode in that case. */
+
+typedef enum
+{
+ LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
+ LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
+ LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
+ LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
+ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */
+} ELzmaStatus;
+
+/* ELzmaStatus is used only as output value for function call */
+
+
+/* ---------- Interfaces ---------- */
+
+/* There are 3 levels of interfaces:
+ 1) Dictionary Interface
+ 2) Buffer Interface
+ 3) One Call Interface
+ You can select any of these interfaces, but don't mix functions from different
+ groups for same object. */
+
+
+/* There are two variants to allocate state for Dictionary Interface:
+ 1) LzmaDec_Allocate / LzmaDec_Free
+ 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
+ You can use variant 2, if you set dictionary buffer manually.
+ For Buffer Interface you must always use variant 1.
+
+LzmaDec_Allocate* can return:
+ SZ_OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_UNSUPPORTED - Unsupported properties
+*/
+
+SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
+void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
+
+SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
+void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
+
+/* ---------- Dictionary Interface ---------- */
+
+/* You can use it, if you want to eliminate the overhead for data copying from
+ dictionary to some other external buffer.
+ You must work with CLzmaDec variables directly in this interface.
+
+ STEPS:
+ LzmaDec_Constr()
+ LzmaDec_Allocate()
+ for (each new stream)
+ {
+ LzmaDec_Init()
+ while (it needs more decompression)
+ {
+ LzmaDec_DecodeToDic()
+ use data from CLzmaDec::dic and update CLzmaDec::dicPos
+ }
+ }
+ LzmaDec_Free()
+*/
+
+/* LzmaDec_DecodeToDic
+
+ The decoding to internal dictionary buffer (CLzmaDec::dic).
+ You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
+
+finishMode:
+ It has meaning only if the decoding reaches output limit (dicLimit).
+ LZMA_FINISH_ANY - Decode just dicLimit bytes.
+ LZMA_FINISH_END - Stream must be finished after dicLimit.
+
+Returns:
+ SZ_OK
+ status:
+ LZMA_STATUS_FINISHED_WITH_MARK
+ LZMA_STATUS_NOT_FINISHED
+ LZMA_STATUS_NEEDS_MORE_INPUT
+ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
+ SZ_ERROR_DATA - Data error
+*/
+
+SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
+ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+
+
+/* ---------- Buffer Interface ---------- */
+
+/* It's zlib-like interface.
+ See LzmaDec_DecodeToDic description for information about STEPS and return results,
+ but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
+ to work with CLzmaDec variables manually.
+
+finishMode:
+ It has meaning only if the decoding reaches output limit (*destLen).
+ LZMA_FINISH_ANY - Decode just destLen bytes.
+ LZMA_FINISH_END - Stream must be finished after (*destLen).
+*/
+
+SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
+ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+
+
+/* ---------- One Call Interface ---------- */
+
+/* LzmaDecode
+
+finishMode:
+ It has meaning only if the decoding reaches output limit (*destLen).
+ LZMA_FINISH_ANY - Decode just destLen bytes.
+ LZMA_FINISH_END - Stream must be finished after (*destLen).
+
+Returns:
+ SZ_OK
+ status:
+ LZMA_STATUS_FINISHED_WITH_MARK
+ LZMA_STATUS_NOT_FINISHED
+ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
+ SZ_ERROR_DATA - Data error
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_UNSUPPORTED - Unsupported properties
+ SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
+*/
+
+SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+ ELzmaStatus *status, ISzAlloc *alloc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaEnc.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaEnc.c
new file mode 100644
index 000000000..20ad727f0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaEnc.c
@@ -0,0 +1,2268 @@
+/* LzmaEnc.c -- LZMA Encoder
+2009-04-22 : Igor Pavlov : Public domain */
+
+#include <string.h>
+
+/* #define SHOW_STAT */
+/* #define SHOW_STAT2 */
+
+#if defined(SHOW_STAT) || defined(SHOW_STAT2)
+#include <stdio.h>
+#endif
+
+#include "LzmaEnc.h"
+
+#include "LzFind.h"
+#ifdef COMPRESS_MF_MT
+#include "LzFindMt.h"
+#endif
+
+#ifdef SHOW_STAT
+static int ttt = 0;
+#endif
+
+#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1)
+
+#define kBlockSize (9 << 10)
+#define kUnpackBlockSize (1 << 18)
+#define kMatchArraySize (1 << 21)
+#define kMatchRecordMaxSize ((LZMA_MATCH_LEN_MAX * 2 + 3) * LZMA_MATCH_LEN_MAX)
+
+#define kNumMaxDirectBits (31)
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+#define kProbInitValue (kBitModelTotal >> 1)
+
+#define kNumMoveReducingBits 4
+#define kNumBitPriceShiftBits 4
+#define kBitPrice (1 << kNumBitPriceShiftBits)
+
+void LzmaEncProps_Init(CLzmaEncProps *p)
+{
+ p->level = 5;
+ p->dictSize = p->mc = 0;
+ p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1;
+ p->writeEndMark = 0;
+}
+
+void LzmaEncProps_Normalize(CLzmaEncProps *p)
+{
+ int level = p->level;
+ if (level < 0) level = 5;
+ p->level = level;
+ if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26)));
+ if (p->lc < 0) p->lc = 3;
+ if (p->lp < 0) p->lp = 0;
+ if (p->pb < 0) p->pb = 2;
+ if (p->algo < 0) p->algo = (level < 5 ? 0 : 1);
+ if (p->fb < 0) p->fb = (level < 7 ? 32 : 64);
+ if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1);
+ if (p->numHashBytes < 0) p->numHashBytes = 4;
+ if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1);
+ if (p->numThreads < 0)
+ p->numThreads =
+ #ifdef COMPRESS_MF_MT
+ ((p->btMode && p->algo) ? 2 : 1);
+ #else
+ 1;
+ #endif
+}
+
+UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
+{
+ CLzmaEncProps props = *props2;
+ LzmaEncProps_Normalize(&props);
+ return props.dictSize;
+}
+
+/* #define LZMA_LOG_BSR */
+/* Define it for Intel's CPU */
+
+
+#ifdef LZMA_LOG_BSR
+
+#define kDicLogSizeMaxCompress 30
+
+#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
+
+UInt32 GetPosSlot1(UInt32 pos)
+{
+ UInt32 res;
+ BSR2_RET(pos, res);
+ return res;
+}
+#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }
+#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); }
+
+#else
+
+#define kNumLogBits (9 + (int)sizeof(size_t) / 2)
+#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
+
+void LzmaEnc_FastPosInit(Byte *g_FastPos)
+{
+ int c = 2, slotFast;
+ g_FastPos[0] = 0;
+ g_FastPos[1] = 1;
+
+ for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++)
+ {
+ UInt32 k = (1 << ((slotFast >> 1) - 1));
+ UInt32 j;
+ for (j = 0; j < k; j++, c++)
+ g_FastPos[c] = (Byte)slotFast;
+ }
+}
+
+#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
+ (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \
+ res = p->g_FastPos[pos >> i] + (i * 2); }
+/*
+#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \
+ p->g_FastPos[pos >> 6] + 12 : \
+ p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; }
+*/
+
+#define GetPosSlot1(pos) p->g_FastPos[pos]
+#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }
+#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); }
+
+#endif
+
+
+#define LZMA_NUM_REPS 4
+
+typedef unsigned CState;
+
+typedef struct
+{
+ UInt32 price;
+
+ CState state;
+ int prev1IsChar;
+ int prev2;
+
+ UInt32 posPrev2;
+ UInt32 backPrev2;
+
+ UInt32 posPrev;
+ UInt32 backPrev;
+ UInt32 backs[LZMA_NUM_REPS];
+} COptimal;
+
+#define kNumOpts (1 << 12)
+
+#define kNumLenToPosStates 4
+#define kNumPosSlotBits 6
+#define kDicLogSizeMin 0
+#define kDicLogSizeMax 32
+#define kDistTableSizeMax (kDicLogSizeMax * 2)
+
+
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
+#define kAlignMask (kAlignTableSize - 1)
+
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex)
+
+#define kNumFullDistances (1 << (kEndPosModelIndex / 2))
+
+#ifdef _LZMA_PROB32
+#define CLzmaProb UInt32
+#else
+#define CLzmaProb UInt16
+#endif
+
+#define LZMA_PB_MAX 4
+#define LZMA_LC_MAX 8
+#define LZMA_LP_MAX 4
+
+#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX)
+
+
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumMidBits 3
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
+
+#define kLenNumSymbolsTotal (kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
+
+#define LZMA_MATCH_LEN_MIN 2
+#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1)
+
+#define kNumStates 12
+
+typedef struct
+{
+ CLzmaProb choice;
+ CLzmaProb choice2;
+ CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits];
+ CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits];
+ CLzmaProb high[kLenNumHighSymbols];
+} CLenEnc;
+
+typedef struct
+{
+ CLenEnc p;
+ UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];
+ UInt32 tableSize;
+ UInt32 counters[LZMA_NUM_PB_STATES_MAX];
+} CLenPriceEnc;
+
+typedef struct
+{
+ UInt32 range;
+ Byte cache;
+ UInt64 low;
+ UInt64 cacheSize;
+ Byte *buf;
+ Byte *bufLim;
+ Byte *bufBase;
+ ISeqOutStream *outStream;
+ UInt64 processed;
+ SRes res;
+} CRangeEnc;
+
+typedef struct
+{
+ CLzmaProb *litProbs;
+
+ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];
+ CLzmaProb isRep[kNumStates];
+ CLzmaProb isRepG0[kNumStates];
+ CLzmaProb isRepG1[kNumStates];
+ CLzmaProb isRepG2[kNumStates];
+ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];
+
+ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
+ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
+ CLzmaProb posAlignEncoder[1 << kNumAlignBits];
+
+ CLenPriceEnc lenEnc;
+ CLenPriceEnc repLenEnc;
+
+ UInt32 reps[LZMA_NUM_REPS];
+ UInt32 state;
+} CSaveState;
+
+typedef struct
+{
+ IMatchFinder matchFinder;
+ void *matchFinderObj;
+
+ #ifdef COMPRESS_MF_MT
+ Bool mtMode;
+ CMatchFinderMt matchFinderMt;
+ #endif
+
+ CMatchFinder matchFinderBase;
+
+ #ifdef COMPRESS_MF_MT
+ Byte pad[128];
+ #endif
+
+ UInt32 optimumEndIndex;
+ UInt32 optimumCurrentIndex;
+
+ UInt32 longestMatchLength;
+ UInt32 numPairs;
+ UInt32 numAvail;
+ COptimal opt[kNumOpts];
+
+ #ifndef LZMA_LOG_BSR
+ Byte g_FastPos[1 << kNumLogBits];
+ #endif
+
+ UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
+ UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1];
+ UInt32 numFastBytes;
+ UInt32 additionalOffset;
+ UInt32 reps[LZMA_NUM_REPS];
+ UInt32 state;
+
+ UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
+ UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances];
+ UInt32 alignPrices[kAlignTableSize];
+ UInt32 alignPriceCount;
+
+ UInt32 distTableSize;
+
+ unsigned lc, lp, pb;
+ unsigned lpMask, pbMask;
+
+ CLzmaProb *litProbs;
+
+ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];
+ CLzmaProb isRep[kNumStates];
+ CLzmaProb isRepG0[kNumStates];
+ CLzmaProb isRepG1[kNumStates];
+ CLzmaProb isRepG2[kNumStates];
+ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];
+
+ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
+ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
+ CLzmaProb posAlignEncoder[1 << kNumAlignBits];
+
+ CLenPriceEnc lenEnc;
+ CLenPriceEnc repLenEnc;
+
+ unsigned lclp;
+
+ Bool fastMode;
+
+ CRangeEnc rc;
+
+ Bool writeEndMark;
+ UInt64 nowPos64;
+ UInt32 matchPriceCount;
+ Bool finished;
+ Bool multiThread;
+
+ SRes result;
+ UInt32 dictSize;
+ UInt32 matchFinderCycles;
+
+ int needInit;
+
+ CSaveState saveState;
+} CLzmaEnc;
+
+void LzmaEnc_SaveState(CLzmaEncHandle pp)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ CSaveState *dest = &p->saveState;
+ int i;
+ dest->lenEnc = p->lenEnc;
+ dest->repLenEnc = p->repLenEnc;
+ dest->state = p->state;
+
+ for (i = 0; i < kNumStates; i++)
+ {
+ memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
+ memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
+ }
+ for (i = 0; i < kNumLenToPosStates; i++)
+ memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
+ memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
+ memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
+ memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
+ memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
+ memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
+ memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
+ memcpy(dest->reps, p->reps, sizeof(p->reps));
+ memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
+}
+
+void LzmaEnc_RestoreState(CLzmaEncHandle pp)
+{
+ CLzmaEnc *dest = (CLzmaEnc *)pp;
+ const CSaveState *p = &dest->saveState;
+ int i;
+ dest->lenEnc = p->lenEnc;
+ dest->repLenEnc = p->repLenEnc;
+ dest->state = p->state;
+
+ for (i = 0; i < kNumStates; i++)
+ {
+ memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
+ memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
+ }
+ for (i = 0; i < kNumLenToPosStates; i++)
+ memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
+ memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
+ memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
+ memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
+ memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
+ memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
+ memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
+ memcpy(dest->reps, p->reps, sizeof(p->reps));
+ memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb));
+}
+
+SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ CLzmaEncProps props = *props2;
+ LzmaEncProps_Normalize(&props);
+
+ if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX ||
+ props.dictSize > (1 << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30))
+ return SZ_ERROR_PARAM;
+ p->dictSize = props.dictSize;
+ p->matchFinderCycles = props.mc;
+ {
+ unsigned fb = props.fb;
+ if (fb < 5)
+ fb = 5;
+ if (fb > LZMA_MATCH_LEN_MAX)
+ fb = LZMA_MATCH_LEN_MAX;
+ p->numFastBytes = fb;
+ }
+ p->lc = props.lc;
+ p->lp = props.lp;
+ p->pb = props.pb;
+ p->fastMode = (props.algo == 0);
+ p->matchFinderBase.btMode = props.btMode;
+ {
+ UInt32 numHashBytes = 4;
+ if (props.btMode)
+ {
+ if (props.numHashBytes < 2)
+ numHashBytes = 2;
+ else if (props.numHashBytes < 4)
+ numHashBytes = props.numHashBytes;
+ }
+ p->matchFinderBase.numHashBytes = numHashBytes;
+ }
+
+ p->matchFinderBase.cutValue = props.mc;
+
+ p->writeEndMark = props.writeEndMark;
+
+ #ifdef COMPRESS_MF_MT
+ /*
+ if (newMultiThread != _multiThread)
+ {
+ ReleaseMatchFinder();
+ _multiThread = newMultiThread;
+ }
+ */
+ p->multiThread = (props.numThreads > 1);
+ #endif
+
+ return SZ_OK;
+}
+
+static const int kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5};
+static const int kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
+static const int kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
+static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
+
+#define IsCharState(s) ((s) < 7)
+
+#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1)
+
+#define kInfinityPrice (1 << 30)
+
+static void RangeEnc_Construct(CRangeEnc *p)
+{
+ p->outStream = 0;
+ p->bufBase = 0;
+}
+
+#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize)
+
+#define RC_BUF_SIZE (1 << 16)
+static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
+{
+ if (p->bufBase == 0)
+ {
+ p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE);
+ if (p->bufBase == 0)
+ return 0;
+ p->bufLim = p->bufBase + RC_BUF_SIZE;
+ }
+ return 1;
+}
+
+static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->bufBase);
+ p->bufBase = 0;
+}
+
+static void RangeEnc_Init(CRangeEnc *p)
+{
+ /* Stream.Init(); */
+ p->low = 0;
+ p->range = 0xFFFFFFFF;
+ p->cacheSize = 1;
+ p->cache = 0;
+
+ p->buf = p->bufBase;
+
+ p->processed = 0;
+ p->res = SZ_OK;
+}
+
+static void RangeEnc_FlushStream(CRangeEnc *p)
+{
+ size_t num;
+ if (p->res != SZ_OK)
+ return;
+ num = p->buf - p->bufBase;
+ if (num != p->outStream->Write(p->outStream, p->bufBase, num))
+ p->res = SZ_ERROR_WRITE;
+ p->processed += num;
+ p->buf = p->bufBase;
+}
+
+static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p)
+{
+ if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0)
+ {
+ Byte temp = p->cache;
+ do
+ {
+ Byte *buf = p->buf;
+ *buf++ = (Byte)(temp + (Byte)(p->low >> 32));
+ p->buf = buf;
+ if (buf == p->bufLim)
+ RangeEnc_FlushStream(p);
+ temp = 0xFF;
+ }
+ while (--p->cacheSize != 0);
+ p->cache = (Byte)((UInt32)p->low >> 24);
+ }
+ p->cacheSize++;
+ p->low = (UInt32)p->low << 8;
+}
+
+static void RangeEnc_FlushData(CRangeEnc *p)
+{
+ int i;
+ for (i = 0; i < 5; i++)
+ RangeEnc_ShiftLow(p);
+}
+
+static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits)
+{
+ do
+ {
+ p->range >>= 1;
+ p->low += p->range & (0 - ((value >> --numBits) & 1));
+ if (p->range < kTopValue)
+ {
+ p->range <<= 8;
+ RangeEnc_ShiftLow(p);
+ }
+ }
+ while (numBits != 0);
+}
+
+static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol)
+{
+ UInt32 ttt = *prob;
+ UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt;
+ if (symbol == 0)
+ {
+ p->range = newBound;
+ ttt += (kBitModelTotal - ttt) >> kNumMoveBits;
+ }
+ else
+ {
+ p->low += newBound;
+ p->range -= newBound;
+ ttt -= ttt >> kNumMoveBits;
+ }
+ *prob = (CLzmaProb)ttt;
+ if (p->range < kTopValue)
+ {
+ p->range <<= 8;
+ RangeEnc_ShiftLow(p);
+ }
+}
+
+static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)
+{
+ symbol |= 0x100;
+ do
+ {
+ RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1);
+ symbol <<= 1;
+ }
+ while (symbol < 0x10000);
+}
+
+static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte)
+{
+ UInt32 offs = 0x100;
+ symbol |= 0x100;
+ do
+ {
+ matchByte <<= 1;
+ RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1);
+ symbol <<= 1;
+ offs &= ~(matchByte ^ symbol);
+ }
+ while (symbol < 0x10000);
+}
+
+void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
+{
+ UInt32 i;
+ for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
+ {
+ const int kCyclesBits = kNumBitPriceShiftBits;
+ UInt32 w = i;
+ UInt32 bitCount = 0;
+ int j;
+ for (j = 0; j < kCyclesBits; j++)
+ {
+ w = w * w;
+ bitCount <<= 1;
+ while (w >= ((UInt32)1 << 16))
+ {
+ w >>= 1;
+ bitCount++;
+ }
+ }
+ ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount);
+ }
+}
+
+
+#define GET_PRICE(prob, symbol) \
+ p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];
+
+#define GET_PRICEa(prob, symbol) \
+ ProbPrices[((prob) ^ ((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];
+
+#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits]
+#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]
+
+#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits]
+#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]
+
+static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *ProbPrices)
+{
+ UInt32 price = 0;
+ symbol |= 0x100;
+ do
+ {
+ price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1);
+ symbol <<= 1;
+ }
+ while (symbol < 0x10000);
+ return price;
+}
+
+static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, UInt32 *ProbPrices)
+{
+ UInt32 price = 0;
+ UInt32 offs = 0x100;
+ symbol |= 0x100;
+ do
+ {
+ matchByte <<= 1;
+ price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1);
+ symbol <<= 1;
+ offs &= ~(matchByte ^ symbol);
+ }
+ while (symbol < 0x10000);
+ return price;
+}
+
+
+static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
+{
+ UInt32 m = 1;
+ int i;
+ for (i = numBitLevels; i != 0;)
+ {
+ UInt32 bit;
+ i--;
+ bit = (symbol >> i) & 1;
+ RangeEnc_EncodeBit(rc, probs + m, bit);
+ m = (m << 1) | bit;
+ }
+}
+
+static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
+{
+ UInt32 m = 1;
+ int i;
+ for (i = 0; i < numBitLevels; i++)
+ {
+ UInt32 bit = symbol & 1;
+ RangeEnc_EncodeBit(rc, probs + m, bit);
+ m = (m << 1) | bit;
+ symbol >>= 1;
+ }
+}
+
+static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
+{
+ UInt32 price = 0;
+ symbol |= (1 << numBitLevels);
+ while (symbol != 1)
+ {
+ price += GET_PRICEa(probs[symbol >> 1], symbol & 1);
+ symbol >>= 1;
+ }
+ return price;
+}
+
+static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
+{
+ UInt32 price = 0;
+ UInt32 m = 1;
+ int i;
+ for (i = numBitLevels; i != 0; i--)
+ {
+ UInt32 bit = symbol & 1;
+ symbol >>= 1;
+ price += GET_PRICEa(probs[m], bit);
+ m = (m << 1) | bit;
+ }
+ return price;
+}
+
+
+static void LenEnc_Init(CLenEnc *p)
+{
+ unsigned i;
+ p->choice = p->choice2 = kProbInitValue;
+ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumLowBits); i++)
+ p->low[i] = kProbInitValue;
+ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumMidBits); i++)
+ p->mid[i] = kProbInitValue;
+ for (i = 0; i < kLenNumHighSymbols; i++)
+ p->high[i] = kProbInitValue;
+}
+
+static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState)
+{
+ if (symbol < kLenNumLowSymbols)
+ {
+ RangeEnc_EncodeBit(rc, &p->choice, 0);
+ RcTree_Encode(rc, p->low + (posState << kLenNumLowBits), kLenNumLowBits, symbol);
+ }
+ else
+ {
+ RangeEnc_EncodeBit(rc, &p->choice, 1);
+ if (symbol < kLenNumLowSymbols + kLenNumMidSymbols)
+ {
+ RangeEnc_EncodeBit(rc, &p->choice2, 0);
+ RcTree_Encode(rc, p->mid + (posState << kLenNumMidBits), kLenNumMidBits, symbol - kLenNumLowSymbols);
+ }
+ else
+ {
+ RangeEnc_EncodeBit(rc, &p->choice2, 1);
+ RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols - kLenNumMidSymbols);
+ }
+ }
+}
+
+static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, UInt32 *ProbPrices)
+{
+ UInt32 a0 = GET_PRICE_0a(p->choice);
+ UInt32 a1 = GET_PRICE_1a(p->choice);
+ UInt32 b0 = a1 + GET_PRICE_0a(p->choice2);
+ UInt32 b1 = a1 + GET_PRICE_1a(p->choice2);
+ UInt32 i = 0;
+ for (i = 0; i < kLenNumLowSymbols; i++)
+ {
+ if (i >= numSymbols)
+ return;
+ prices[i] = a0 + RcTree_GetPrice(p->low + (posState << kLenNumLowBits), kLenNumLowBits, i, ProbPrices);
+ }
+ for (; i < kLenNumLowSymbols + kLenNumMidSymbols; i++)
+ {
+ if (i >= numSymbols)
+ return;
+ prices[i] = b0 + RcTree_GetPrice(p->mid + (posState << kLenNumMidBits), kLenNumMidBits, i - kLenNumLowSymbols, ProbPrices);
+ }
+ for (; i < numSymbols; i++)
+ prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices);
+}
+
+static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, UInt32 *ProbPrices)
+{
+ LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices);
+ p->counters[posState] = p->tableSize;
+}
+
+static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt32 *ProbPrices)
+{
+ UInt32 posState;
+ for (posState = 0; posState < numPosStates; posState++)
+ LenPriceEnc_UpdateTable(p, posState, ProbPrices);
+}
+
+static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices)
+{
+ LenEnc_Encode(&p->p, rc, symbol, posState);
+ if (updatePrice)
+ if (--p->counters[posState] == 0)
+ LenPriceEnc_UpdateTable(p, posState, ProbPrices);
+}
+
+
+
+
+static void MovePos(CLzmaEnc *p, UInt32 num)
+{
+ #ifdef SHOW_STAT
+ ttt += num;
+ printf("\n MovePos %d", num);
+ #endif
+ if (num != 0)
+ {
+ p->additionalOffset += num;
+ p->matchFinder.Skip(p->matchFinderObj, num);
+ }
+}
+
+static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
+{
+ UInt32 lenRes = 0, numPairs;
+ p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
+ numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);
+ #ifdef SHOW_STAT
+ printf("\n i = %d numPairs = %d ", ttt, numPairs / 2);
+ ttt++;
+ {
+ UInt32 i;
+ for (i = 0; i < numPairs; i += 2)
+ printf("%2d %6d | ", p->matches[i], p->matches[i + 1]);
+ }
+ #endif
+ if (numPairs > 0)
+ {
+ lenRes = p->matches[numPairs - 2];
+ if (lenRes == p->numFastBytes)
+ {
+ const Byte *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ UInt32 distance = p->matches[numPairs - 1] + 1;
+ UInt32 numAvail = p->numAvail;
+ if (numAvail > LZMA_MATCH_LEN_MAX)
+ numAvail = LZMA_MATCH_LEN_MAX;
+ {
+ const Byte *pby2 = pby - distance;
+ for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++);
+ }
+ }
+ }
+ p->additionalOffset++;
+ *numDistancePairsRes = numPairs;
+ return lenRes;
+}
+
+
+#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False;
+#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False;
+#define IsShortRep(p) ((p)->backPrev == 0)
+
+static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState)
+{
+ return
+ GET_PRICE_0(p->isRepG0[state]) +
+ GET_PRICE_0(p->isRep0Long[state][posState]);
+}
+
+static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState)
+{
+ UInt32 price;
+ if (repIndex == 0)
+ {
+ price = GET_PRICE_0(p->isRepG0[state]);
+ price += GET_PRICE_1(p->isRep0Long[state][posState]);
+ }
+ else
+ {
+ price = GET_PRICE_1(p->isRepG0[state]);
+ if (repIndex == 1)
+ price += GET_PRICE_0(p->isRepG1[state]);
+ else
+ {
+ price += GET_PRICE_1(p->isRepG1[state]);
+ price += GET_PRICE(p->isRepG2[state], repIndex - 2);
+ }
+ }
+ return price;
+}
+
+static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState)
+{
+ return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] +
+ GetPureRepPrice(p, repIndex, state, posState);
+}
+
+static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
+{
+ UInt32 posMem = p->opt[cur].posPrev;
+ UInt32 backMem = p->opt[cur].backPrev;
+ p->optimumEndIndex = cur;
+ do
+ {
+ if (p->opt[cur].prev1IsChar)
+ {
+ MakeAsChar(&p->opt[posMem])
+ p->opt[posMem].posPrev = posMem - 1;
+ if (p->opt[cur].prev2)
+ {
+ p->opt[posMem - 1].prev1IsChar = False;
+ p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2;
+ p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2;
+ }
+ }
+ {
+ UInt32 posPrev = posMem;
+ UInt32 backCur = backMem;
+
+ backMem = p->opt[posPrev].backPrev;
+ posMem = p->opt[posPrev].posPrev;
+
+ p->opt[posPrev].backPrev = backCur;
+ p->opt[posPrev].posPrev = cur;
+ cur = posPrev;
+ }
+ }
+ while (cur != 0);
+ *backRes = p->opt[0].backPrev;
+ p->optimumCurrentIndex = p->opt[0].posPrev;
+ return p->optimumCurrentIndex;
+}
+
+#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300)
+
+static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
+{
+ UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur;
+ UInt32 matchPrice, repMatchPrice, normalMatchPrice;
+ UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS];
+ UInt32 *matches;
+ const Byte *data;
+ Byte curByte, matchByte;
+ if (p->optimumEndIndex != p->optimumCurrentIndex)
+ {
+ const COptimal *opt = &p->opt[p->optimumCurrentIndex];
+ UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex;
+ *backRes = opt->backPrev;
+ p->optimumCurrentIndex = opt->posPrev;
+ return lenRes;
+ }
+ p->optimumCurrentIndex = p->optimumEndIndex = 0;
+
+ if (p->additionalOffset == 0)
+ mainLen = ReadMatchDistances(p, &numPairs);
+ else
+ {
+ mainLen = p->longestMatchLength;
+ numPairs = p->numPairs;
+ }
+
+ numAvail = p->numAvail;
+ if (numAvail < 2)
+ {
+ *backRes = (UInt32)(-1);
+ return 1;
+ }
+ if (numAvail > LZMA_MATCH_LEN_MAX)
+ numAvail = LZMA_MATCH_LEN_MAX;
+
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ repMaxIndex = 0;
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ {
+ UInt32 lenTest;
+ const Byte *data2;
+ reps[i] = p->reps[i];
+ data2 = data - (reps[i] + 1);
+ if (data[0] != data2[0] || data[1] != data2[1])
+ {
+ repLens[i] = 0;
+ continue;
+ }
+ for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++);
+ repLens[i] = lenTest;
+ if (lenTest > repLens[repMaxIndex])
+ repMaxIndex = i;
+ }
+ if (repLens[repMaxIndex] >= p->numFastBytes)
+ {
+ UInt32 lenRes;
+ *backRes = repMaxIndex;
+ lenRes = repLens[repMaxIndex];
+ MovePos(p, lenRes - 1);
+ return lenRes;
+ }
+
+ matches = p->matches;
+ if (mainLen >= p->numFastBytes)
+ {
+ *backRes = matches[numPairs - 1] + LZMA_NUM_REPS;
+ MovePos(p, mainLen - 1);
+ return mainLen;
+ }
+ curByte = *data;
+ matchByte = *(data - (reps[0] + 1));
+
+ if (mainLen < 2 && curByte != matchByte && repLens[repMaxIndex] < 2)
+ {
+ *backRes = (UInt32)-1;
+ return 1;
+ }
+
+ p->opt[0].state = (CState)p->state;
+
+ posState = (position & p->pbMask);
+
+ {
+ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
+ p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) +
+ (!IsCharState(p->state) ?
+ LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :
+ LitEnc_GetPrice(probs, curByte, p->ProbPrices));
+ }
+
+ MakeAsChar(&p->opt[1]);
+
+ matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]);
+ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]);
+
+ if (matchByte == curByte)
+ {
+ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState);
+ if (shortRepPrice < p->opt[1].price)
+ {
+ p->opt[1].price = shortRepPrice;
+ MakeAsShortRep(&p->opt[1]);
+ }
+ }
+ lenEnd = ((mainLen >= repLens[repMaxIndex]) ? mainLen : repLens[repMaxIndex]);
+
+ if (lenEnd < 2)
+ {
+ *backRes = p->opt[1].backPrev;
+ return 1;
+ }
+
+ p->opt[1].posPrev = 0;
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ p->opt[0].backs[i] = reps[i];
+
+ len = lenEnd;
+ do
+ p->opt[len--].price = kInfinityPrice;
+ while (len >= 2);
+
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ {
+ UInt32 repLen = repLens[i];
+ UInt32 price;
+ if (repLen < 2)
+ continue;
+ price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState);
+ do
+ {
+ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2];
+ COptimal *opt = &p->opt[repLen];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = 0;
+ opt->backPrev = i;
+ opt->prev1IsChar = False;
+ }
+ }
+ while (--repLen >= 2);
+ }
+
+ normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]);
+
+ len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);
+ if (len <= mainLen)
+ {
+ UInt32 offs = 0;
+ while (len > matches[offs])
+ offs += 2;
+ for (; ; len++)
+ {
+ COptimal *opt;
+ UInt32 distance = matches[offs + 1];
+
+ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN];
+ UInt32 lenToPosState = GetLenToPosState(len);
+ if (distance < kNumFullDistances)
+ curAndLenPrice += p->distancesPrices[lenToPosState][distance];
+ else
+ {
+ UInt32 slot;
+ GetPosSlot2(distance, slot);
+ curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot];
+ }
+ opt = &p->opt[len];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = 0;
+ opt->backPrev = distance + LZMA_NUM_REPS;
+ opt->prev1IsChar = False;
+ }
+ if (len == matches[offs])
+ {
+ offs += 2;
+ if (offs == numPairs)
+ break;
+ }
+ }
+ }
+
+ cur = 0;
+
+ #ifdef SHOW_STAT2
+ if (position >= 0)
+ {
+ unsigned i;
+ printf("\n pos = %4X", position);
+ for (i = cur; i <= lenEnd; i++)
+ printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price);
+ }
+ #endif
+
+ for (;;)
+ {
+ UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;
+ UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice;
+ Bool nextIsChar;
+ Byte curByte, matchByte;
+ const Byte *data;
+ COptimal *curOpt;
+ COptimal *nextOpt;
+
+ cur++;
+ if (cur == lenEnd)
+ return Backward(p, backRes, cur);
+
+ newLen = ReadMatchDistances(p, &numPairs);
+ if (newLen >= p->numFastBytes)
+ {
+ p->numPairs = numPairs;
+ p->longestMatchLength = newLen;
+ return Backward(p, backRes, cur);
+ }
+ position++;
+ curOpt = &p->opt[cur];
+ posPrev = curOpt->posPrev;
+ if (curOpt->prev1IsChar)
+ {
+ posPrev--;
+ if (curOpt->prev2)
+ {
+ state = p->opt[curOpt->posPrev2].state;
+ if (curOpt->backPrev2 < LZMA_NUM_REPS)
+ state = kRepNextStates[state];
+ else
+ state = kMatchNextStates[state];
+ }
+ else
+ state = p->opt[posPrev].state;
+ state = kLiteralNextStates[state];
+ }
+ else
+ state = p->opt[posPrev].state;
+ if (posPrev == cur - 1)
+ {
+ if (IsShortRep(curOpt))
+ state = kShortRepNextStates[state];
+ else
+ state = kLiteralNextStates[state];
+ }
+ else
+ {
+ UInt32 pos;
+ const COptimal *prevOpt;
+ if (curOpt->prev1IsChar && curOpt->prev2)
+ {
+ posPrev = curOpt->posPrev2;
+ pos = curOpt->backPrev2;
+ state = kRepNextStates[state];
+ }
+ else
+ {
+ pos = curOpt->backPrev;
+ if (pos < LZMA_NUM_REPS)
+ state = kRepNextStates[state];
+ else
+ state = kMatchNextStates[state];
+ }
+ prevOpt = &p->opt[posPrev];
+ if (pos < LZMA_NUM_REPS)
+ {
+ UInt32 i;
+ reps[0] = prevOpt->backs[pos];
+ for (i = 1; i <= pos; i++)
+ reps[i] = prevOpt->backs[i - 1];
+ for (; i < LZMA_NUM_REPS; i++)
+ reps[i] = prevOpt->backs[i];
+ }
+ else
+ {
+ UInt32 i;
+ reps[0] = (pos - LZMA_NUM_REPS);
+ for (i = 1; i < LZMA_NUM_REPS; i++)
+ reps[i] = prevOpt->backs[i - 1];
+ }
+ }
+ curOpt->state = (CState)state;
+
+ curOpt->backs[0] = reps[0];
+ curOpt->backs[1] = reps[1];
+ curOpt->backs[2] = reps[2];
+ curOpt->backs[3] = reps[3];
+
+ curPrice = curOpt->price;
+ nextIsChar = False;
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ curByte = *data;
+ matchByte = *(data - (reps[0] + 1));
+
+ posState = (position & p->pbMask);
+
+ curAnd1Price = curPrice + GET_PRICE_0(p->isMatch[state][posState]);
+ {
+ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
+ curAnd1Price +=
+ (!IsCharState(state) ?
+ LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :
+ LitEnc_GetPrice(probs, curByte, p->ProbPrices));
+ }
+
+ nextOpt = &p->opt[cur + 1];
+
+ if (curAnd1Price < nextOpt->price)
+ {
+ nextOpt->price = curAnd1Price;
+ nextOpt->posPrev = cur;
+ MakeAsChar(nextOpt);
+ nextIsChar = True;
+ }
+
+ matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]);
+ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]);
+
+ if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0))
+ {
+ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState);
+ if (shortRepPrice <= nextOpt->price)
+ {
+ nextOpt->price = shortRepPrice;
+ nextOpt->posPrev = cur;
+ MakeAsShortRep(nextOpt);
+ nextIsChar = True;
+ }
+ }
+ numAvailFull = p->numAvail;
+ {
+ UInt32 temp = kNumOpts - 1 - cur;
+ if (temp < numAvailFull)
+ numAvailFull = temp;
+ }
+
+ if (numAvailFull < 2)
+ continue;
+ numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes);
+
+ if (!nextIsChar && matchByte != curByte) /* speed optimization */
+ {
+ /* try Literal + rep0 */
+ UInt32 temp;
+ UInt32 lenTest2;
+ const Byte *data2 = data - (reps[0] + 1);
+ UInt32 limit = p->numFastBytes + 1;
+ if (limit > numAvailFull)
+ limit = numAvailFull;
+
+ for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++);
+ lenTest2 = temp - 1;
+ if (lenTest2 >= 2)
+ {
+ UInt32 state2 = kLiteralNextStates[state];
+ UInt32 posStateNext = (position + 1) & p->pbMask;
+ UInt32 nextRepMatchPrice = curAnd1Price +
+ GET_PRICE_1(p->isMatch[state2][posStateNext]) +
+ GET_PRICE_1(p->isRep[state2]);
+ /* for (; lenTest2 >= 2; lenTest2--) */
+ {
+ UInt32 curAndLenPrice;
+ COptimal *opt;
+ UInt32 offset = cur + 1 + lenTest2;
+ while (lenEnd < offset)
+ p->opt[++lenEnd].price = kInfinityPrice;
+ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
+ opt = &p->opt[offset];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur + 1;
+ opt->backPrev = 0;
+ opt->prev1IsChar = True;
+ opt->prev2 = False;
+ }
+ }
+ }
+ }
+
+ startLen = 2; /* speed optimization */
+ {
+ UInt32 repIndex;
+ for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++)
+ {
+ UInt32 lenTest;
+ UInt32 lenTestTemp;
+ UInt32 price;
+ const Byte *data2 = data - (reps[repIndex] + 1);
+ if (data[0] != data2[0] || data[1] != data2[1])
+ continue;
+ for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++);
+ while (lenEnd < cur + lenTest)
+ p->opt[++lenEnd].price = kInfinityPrice;
+ lenTestTemp = lenTest;
+ price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState);
+ do
+ {
+ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2];
+ COptimal *opt = &p->opt[cur + lenTest];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur;
+ opt->backPrev = repIndex;
+ opt->prev1IsChar = False;
+ }
+ }
+ while (--lenTest >= 2);
+ lenTest = lenTestTemp;
+
+ if (repIndex == 0)
+ startLen = lenTest + 1;
+
+ /* if (_maxMode) */
+ {
+ UInt32 lenTest2 = lenTest + 1;
+ UInt32 limit = lenTest2 + p->numFastBytes;
+ UInt32 nextRepMatchPrice;
+ if (limit > numAvailFull)
+ limit = numAvailFull;
+ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
+ lenTest2 -= lenTest + 1;
+ if (lenTest2 >= 2)
+ {
+ UInt32 state2 = kRepNextStates[state];
+ UInt32 posStateNext = (position + lenTest) & p->pbMask;
+ UInt32 curAndLenCharPrice =
+ price + p->repLenEnc.prices[posState][lenTest - 2] +
+ GET_PRICE_0(p->isMatch[state2][posStateNext]) +
+ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
+ data[lenTest], data2[lenTest], p->ProbPrices);
+ state2 = kLiteralNextStates[state2];
+ posStateNext = (position + lenTest + 1) & p->pbMask;
+ nextRepMatchPrice = curAndLenCharPrice +
+ GET_PRICE_1(p->isMatch[state2][posStateNext]) +
+ GET_PRICE_1(p->isRep[state2]);
+
+ /* for (; lenTest2 >= 2; lenTest2--) */
+ {
+ UInt32 curAndLenPrice;
+ COptimal *opt;
+ UInt32 offset = cur + lenTest + 1 + lenTest2;
+ while (lenEnd < offset)
+ p->opt[++lenEnd].price = kInfinityPrice;
+ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
+ opt = &p->opt[offset];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur + lenTest + 1;
+ opt->backPrev = 0;
+ opt->prev1IsChar = True;
+ opt->prev2 = True;
+ opt->posPrev2 = cur;
+ opt->backPrev2 = repIndex;
+ }
+ }
+ }
+ }
+ }
+ }
+ /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */
+ if (newLen > numAvail)
+ {
+ newLen = numAvail;
+ for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2);
+ matches[numPairs] = newLen;
+ numPairs += 2;
+ }
+ if (newLen >= startLen)
+ {
+ UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]);
+ UInt32 offs, curBack, posSlot;
+ UInt32 lenTest;
+ while (lenEnd < cur + newLen)
+ p->opt[++lenEnd].price = kInfinityPrice;
+
+ offs = 0;
+ while (startLen > matches[offs])
+ offs += 2;
+ curBack = matches[offs + 1];
+ GetPosSlot2(curBack, posSlot);
+ for (lenTest = /*2*/ startLen; ; lenTest++)
+ {
+ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
+ UInt32 lenToPosState = GetLenToPosState(lenTest);
+ COptimal *opt;
+ if (curBack < kNumFullDistances)
+ curAndLenPrice += p->distancesPrices[lenToPosState][curBack];
+ else
+ curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask];
+
+ opt = &p->opt[cur + lenTest];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur;
+ opt->backPrev = curBack + LZMA_NUM_REPS;
+ opt->prev1IsChar = False;
+ }
+
+ if (/*_maxMode && */lenTest == matches[offs])
+ {
+ /* Try Match + Literal + Rep0 */
+ const Byte *data2 = data - (curBack + 1);
+ UInt32 lenTest2 = lenTest + 1;
+ UInt32 limit = lenTest2 + p->numFastBytes;
+ UInt32 nextRepMatchPrice;
+ if (limit > numAvailFull)
+ limit = numAvailFull;
+ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
+ lenTest2 -= lenTest + 1;
+ if (lenTest2 >= 2)
+ {
+ UInt32 state2 = kMatchNextStates[state];
+ UInt32 posStateNext = (position + lenTest) & p->pbMask;
+ UInt32 curAndLenCharPrice = curAndLenPrice +
+ GET_PRICE_0(p->isMatch[state2][posStateNext]) +
+ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
+ data[lenTest], data2[lenTest], p->ProbPrices);
+ state2 = kLiteralNextStates[state2];
+ posStateNext = (posStateNext + 1) & p->pbMask;
+ nextRepMatchPrice = curAndLenCharPrice +
+ GET_PRICE_1(p->isMatch[state2][posStateNext]) +
+ GET_PRICE_1(p->isRep[state2]);
+
+ /* for (; lenTest2 >= 2; lenTest2--) */
+ {
+ UInt32 offset = cur + lenTest + 1 + lenTest2;
+ UInt32 curAndLenPrice;
+ COptimal *opt;
+ while (lenEnd < offset)
+ p->opt[++lenEnd].price = kInfinityPrice;
+ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
+ opt = &p->opt[offset];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur + lenTest + 1;
+ opt->backPrev = 0;
+ opt->prev1IsChar = True;
+ opt->prev2 = True;
+ opt->posPrev2 = cur;
+ opt->backPrev2 = curBack + LZMA_NUM_REPS;
+ }
+ }
+ }
+ offs += 2;
+ if (offs == numPairs)
+ break;
+ curBack = matches[offs + 1];
+ if (curBack >= kNumFullDistances)
+ GetPosSlot2(curBack, posSlot);
+ }
+ }
+ }
+ }
+}
+
+#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist))
+
+static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
+{
+ UInt32 numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i;
+ const Byte *data;
+ const UInt32 *matches;
+
+ if (p->additionalOffset == 0)
+ mainLen = ReadMatchDistances(p, &numPairs);
+ else
+ {
+ mainLen = p->longestMatchLength;
+ numPairs = p->numPairs;
+ }
+
+ numAvail = p->numAvail;
+ *backRes = (UInt32)-1;
+ if (numAvail < 2)
+ return 1;
+ if (numAvail > LZMA_MATCH_LEN_MAX)
+ numAvail = LZMA_MATCH_LEN_MAX;
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+
+ repLen = repIndex = 0;
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ {
+ UInt32 len;
+ const Byte *data2 = data - (p->reps[i] + 1);
+ if (data[0] != data2[0] || data[1] != data2[1])
+ continue;
+ for (len = 2; len < numAvail && data[len] == data2[len]; len++);
+ if (len >= p->numFastBytes)
+ {
+ *backRes = i;
+ MovePos(p, len - 1);
+ return len;
+ }
+ if (len > repLen)
+ {
+ repIndex = i;
+ repLen = len;
+ }
+ }
+
+ matches = p->matches;
+ if (mainLen >= p->numFastBytes)
+ {
+ *backRes = matches[numPairs - 1] + LZMA_NUM_REPS;
+ MovePos(p, mainLen - 1);
+ return mainLen;
+ }
+
+ mainDist = 0; /* for GCC */
+ if (mainLen >= 2)
+ {
+ mainDist = matches[numPairs - 1];
+ while (numPairs > 2 && mainLen == matches[numPairs - 4] + 1)
+ {
+ if (!ChangePair(matches[numPairs - 3], mainDist))
+ break;
+ numPairs -= 2;
+ mainLen = matches[numPairs - 2];
+ mainDist = matches[numPairs - 1];
+ }
+ if (mainLen == 2 && mainDist >= 0x80)
+ mainLen = 1;
+ }
+
+ if (repLen >= 2 && (
+ (repLen + 1 >= mainLen) ||
+ (repLen + 2 >= mainLen && mainDist >= (1 << 9)) ||
+ (repLen + 3 >= mainLen && mainDist >= (1 << 15))))
+ {
+ *backRes = repIndex;
+ MovePos(p, repLen - 1);
+ return repLen;
+ }
+
+ if (mainLen < 2 || numAvail <= 2)
+ return 1;
+
+ p->longestMatchLength = ReadMatchDistances(p, &p->numPairs);
+ if (p->longestMatchLength >= 2)
+ {
+ UInt32 newDistance = matches[p->numPairs - 1];
+ if ((p->longestMatchLength >= mainLen && newDistance < mainDist) ||
+ (p->longestMatchLength == mainLen + 1 && !ChangePair(mainDist, newDistance)) ||
+ (p->longestMatchLength > mainLen + 1) ||
+ (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist)))
+ return 1;
+ }
+
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ {
+ UInt32 len, limit;
+ const Byte *data2 = data - (p->reps[i] + 1);
+ if (data[0] != data2[0] || data[1] != data2[1])
+ continue;
+ limit = mainLen - 1;
+ for (len = 2; len < limit && data[len] == data2[len]; len++);
+ if (len >= limit)
+ return 1;
+ }
+ *backRes = mainDist + LZMA_NUM_REPS;
+ MovePos(p, mainLen - 2);
+ return mainLen;
+}
+
+static void WriteEndMarker(CLzmaEnc *p, UInt32 posState)
+{
+ UInt32 len;
+ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
+ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
+ p->state = kMatchNextStates[p->state];
+ len = LZMA_MATCH_LEN_MIN;
+ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
+ RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1);
+ RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits);
+ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);
+}
+
+static SRes CheckErrors(CLzmaEnc *p)
+{
+ if (p->result != SZ_OK)
+ return p->result;
+ if (p->rc.res != SZ_OK)
+ p->result = SZ_ERROR_WRITE;
+ if (p->matchFinderBase.result != SZ_OK)
+ p->result = SZ_ERROR_READ;
+ if (p->result != SZ_OK)
+ p->finished = True;
+ return p->result;
+}
+
+static SRes Flush(CLzmaEnc *p, UInt32 nowPos)
+{
+ /* ReleaseMFStream(); */
+ p->finished = True;
+ if (p->writeEndMark)
+ WriteEndMarker(p, nowPos & p->pbMask);
+ RangeEnc_FlushData(&p->rc);
+ RangeEnc_FlushStream(&p->rc);
+ return CheckErrors(p);
+}
+
+static void FillAlignPrices(CLzmaEnc *p)
+{
+ UInt32 i;
+ for (i = 0; i < kAlignTableSize; i++)
+ p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices);
+ p->alignPriceCount = 0;
+}
+
+static void FillDistancesPrices(CLzmaEnc *p)
+{
+ UInt32 tempPrices[kNumFullDistances];
+ UInt32 i, lenToPosState;
+ for (i = kStartPosModelIndex; i < kNumFullDistances; i++)
+ {
+ UInt32 posSlot = GetPosSlot1(i);
+ UInt32 footerBits = ((posSlot >> 1) - 1);
+ UInt32 base = ((2 | (posSlot & 1)) << footerBits);
+ tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices);
+ }
+
+ for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
+ {
+ UInt32 posSlot;
+ const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState];
+ UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState];
+ for (posSlot = 0; posSlot < p->distTableSize; posSlot++)
+ posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices);
+ for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++)
+ posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits);
+
+ {
+ UInt32 *distancesPrices = p->distancesPrices[lenToPosState];
+ UInt32 i;
+ for (i = 0; i < kStartPosModelIndex; i++)
+ distancesPrices[i] = posSlotPrices[i];
+ for (; i < kNumFullDistances; i++)
+ distancesPrices[i] = posSlotPrices[GetPosSlot1(i)] + tempPrices[i];
+ }
+ }
+ p->matchPriceCount = 0;
+}
+
+void LzmaEnc_Construct(CLzmaEnc *p)
+{
+ RangeEnc_Construct(&p->rc);
+ MatchFinder_Construct(&p->matchFinderBase);
+ #ifdef COMPRESS_MF_MT
+ MatchFinderMt_Construct(&p->matchFinderMt);
+ p->matchFinderMt.MatchFinder = &p->matchFinderBase;
+ #endif
+
+ {
+ CLzmaEncProps props;
+ LzmaEncProps_Init(&props);
+ LzmaEnc_SetProps(p, &props);
+ }
+
+ #ifndef LZMA_LOG_BSR
+ LzmaEnc_FastPosInit(p->g_FastPos);
+ #endif
+
+ LzmaEnc_InitPriceTables(p->ProbPrices);
+ p->litProbs = 0;
+ p->saveState.litProbs = 0;
+}
+
+CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)
+{
+ void *p;
+ p = alloc->Alloc(alloc, sizeof(CLzmaEnc));
+ if (p != 0)
+ LzmaEnc_Construct((CLzmaEnc *)p);
+ return p;
+}
+
+void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->litProbs);
+ alloc->Free(alloc, p->saveState.litProbs);
+ p->litProbs = 0;
+ p->saveState.litProbs = 0;
+}
+
+void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ #ifdef COMPRESS_MF_MT
+ MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
+ #endif
+ MatchFinder_Free(&p->matchFinderBase, allocBig);
+ LzmaEnc_FreeLits(p, alloc);
+ RangeEnc_Free(&p->rc, alloc);
+}
+
+void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig);
+ alloc->Free(alloc, p);
+}
+
+static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize)
+{
+ UInt32 nowPos32, startPos32;
+ if (p->needInit)
+ {
+ p->matchFinder.Init(p->matchFinderObj);
+ p->needInit = 0;
+ }
+
+ if (p->finished)
+ return p->result;
+ RINOK(CheckErrors(p));
+
+ nowPos32 = (UInt32)p->nowPos64;
+ startPos32 = nowPos32;
+
+ if (p->nowPos64 == 0)
+ {
+ UInt32 numPairs;
+ Byte curByte;
+ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)
+ return Flush(p, nowPos32);
+ ReadMatchDistances(p, &numPairs);
+ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0);
+ p->state = kLiteralNextStates[p->state];
+ curByte = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset);
+ LitEnc_Encode(&p->rc, p->litProbs, curByte);
+ p->additionalOffset--;
+ nowPos32++;
+ }
+
+ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0)
+ for (;;)
+ {
+ UInt32 pos, len, posState;
+
+ if (p->fastMode)
+ len = GetOptimumFast(p, &pos);
+ else
+ len = GetOptimum(p, nowPos32, &pos);
+
+ #ifdef SHOW_STAT2
+ printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos);
+ #endif
+
+ posState = nowPos32 & p->pbMask;
+ if (len == 1 && pos == (UInt32)-1)
+ {
+ Byte curByte;
+ CLzmaProb *probs;
+ const Byte *data;
+
+ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0);
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
+ curByte = *data;
+ probs = LIT_PROBS(nowPos32, *(data - 1));
+ if (IsCharState(p->state))
+ LitEnc_Encode(&p->rc, probs, curByte);
+ else
+ LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1));
+ p->state = kLiteralNextStates[p->state];
+ }
+ else
+ {
+ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
+ if (pos < LZMA_NUM_REPS)
+ {
+ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 1);
+ if (pos == 0)
+ {
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 0);
+ RangeEnc_EncodeBit(&p->rc, &p->isRep0Long[p->state][posState], ((len == 1) ? 0 : 1));
+ }
+ else
+ {
+ UInt32 distance = p->reps[pos];
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1);
+ if (pos == 1)
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0);
+ else
+ {
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 1);
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG2[p->state], pos - 2);
+ if (pos == 3)
+ p->reps[3] = p->reps[2];
+ p->reps[2] = p->reps[1];
+ }
+ p->reps[1] = p->reps[0];
+ p->reps[0] = distance;
+ }
+ if (len == 1)
+ p->state = kShortRepNextStates[p->state];
+ else
+ {
+ LenEnc_Encode2(&p->repLenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
+ p->state = kRepNextStates[p->state];
+ }
+ }
+ else
+ {
+ UInt32 posSlot;
+ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
+ p->state = kMatchNextStates[p->state];
+ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
+ pos -= LZMA_NUM_REPS;
+ GetPosSlot(pos, posSlot);
+ RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot);
+
+ if (posSlot >= kStartPosModelIndex)
+ {
+ UInt32 footerBits = ((posSlot >> 1) - 1);
+ UInt32 base = ((2 | (posSlot & 1)) << footerBits);
+ UInt32 posReduced = pos - base;
+
+ if (posSlot < kEndPosModelIndex)
+ RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced);
+ else
+ {
+ RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
+ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask);
+ p->alignPriceCount++;
+ }
+ }
+ p->reps[3] = p->reps[2];
+ p->reps[2] = p->reps[1];
+ p->reps[1] = p->reps[0];
+ p->reps[0] = pos;
+ p->matchPriceCount++;
+ }
+ }
+ p->additionalOffset -= len;
+ nowPos32 += len;
+ if (p->additionalOffset == 0)
+ {
+ UInt32 processed;
+ if (!p->fastMode)
+ {
+ if (p->matchPriceCount >= (1 << 7))
+ FillDistancesPrices(p);
+ if (p->alignPriceCount >= kAlignTableSize)
+ FillAlignPrices(p);
+ }
+ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)
+ break;
+ processed = nowPos32 - startPos32;
+ if (useLimits)
+ {
+ if (processed + kNumOpts + 300 >= maxUnpackSize ||
+ RangeEnc_GetProcessed(&p->rc) + kNumOpts * 2 >= maxPackSize)
+ break;
+ }
+ else if (processed >= (1 << 15))
+ {
+ p->nowPos64 += nowPos32 - startPos32;
+ return CheckErrors(p);
+ }
+ }
+ }
+ p->nowPos64 += nowPos32 - startPos32;
+ return Flush(p, nowPos32);
+}
+
+#define kBigHashDicLimit ((UInt32)1 << 24)
+
+static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ UInt32 beforeSize = kNumOpts;
+ Bool btMode;
+ if (!RangeEnc_Alloc(&p->rc, alloc))
+ return SZ_ERROR_MEM;
+ btMode = (p->matchFinderBase.btMode != 0);
+ #ifdef COMPRESS_MF_MT
+ p->mtMode = (p->multiThread && !p->fastMode && btMode);
+ #endif
+
+ {
+ unsigned lclp = p->lc + p->lp;
+ if (p->litProbs == 0 || p->saveState.litProbs == 0 || p->lclp != lclp)
+ {
+ LzmaEnc_FreeLits(p, alloc);
+ p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb));
+ p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb));
+ if (p->litProbs == 0 || p->saveState.litProbs == 0)
+ {
+ LzmaEnc_FreeLits(p, alloc);
+ return SZ_ERROR_MEM;
+ }
+ p->lclp = lclp;
+ }
+ }
+
+ p->matchFinderBase.bigHash = (p->dictSize > kBigHashDicLimit);
+
+ if (beforeSize + p->dictSize < keepWindowSize)
+ beforeSize = keepWindowSize - p->dictSize;
+
+ #ifdef COMPRESS_MF_MT
+ if (p->mtMode)
+ {
+ RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig));
+ p->matchFinderObj = &p->matchFinderMt;
+ MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder);
+ }
+ else
+ #endif
+ {
+ if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig))
+ return SZ_ERROR_MEM;
+ p->matchFinderObj = &p->matchFinderBase;
+ MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder);
+ }
+ return SZ_OK;
+}
+
+void LzmaEnc_Init(CLzmaEnc *p)
+{
+ UInt32 i;
+ p->state = 0;
+ for (i = 0 ; i < LZMA_NUM_REPS; i++)
+ p->reps[i] = 0;
+
+ RangeEnc_Init(&p->rc);
+
+
+ for (i = 0; i < kNumStates; i++)
+ {
+ UInt32 j;
+ for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++)
+ {
+ p->isMatch[i][j] = kProbInitValue;
+ p->isRep0Long[i][j] = kProbInitValue;
+ }
+ p->isRep[i] = kProbInitValue;
+ p->isRepG0[i] = kProbInitValue;
+ p->isRepG1[i] = kProbInitValue;
+ p->isRepG2[i] = kProbInitValue;
+ }
+
+ {
+ UInt32 num = 0x300 << (p->lp + p->lc);
+ for (i = 0; i < num; i++)
+ p->litProbs[i] = kProbInitValue;
+ }
+
+ {
+ for (i = 0; i < kNumLenToPosStates; i++)
+ {
+ CLzmaProb *probs = p->posSlotEncoder[i];
+ UInt32 j;
+ for (j = 0; j < (1 << kNumPosSlotBits); j++)
+ probs[j] = kProbInitValue;
+ }
+ }
+ {
+ for (i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
+ p->posEncoders[i] = kProbInitValue;
+ }
+
+ LenEnc_Init(&p->lenEnc.p);
+ LenEnc_Init(&p->repLenEnc.p);
+
+ for (i = 0; i < (1 << kNumAlignBits); i++)
+ p->posAlignEncoder[i] = kProbInitValue;
+
+ p->optimumEndIndex = 0;
+ p->optimumCurrentIndex = 0;
+ p->additionalOffset = 0;
+
+ p->pbMask = (1 << p->pb) - 1;
+ p->lpMask = (1 << p->lp) - 1;
+}
+
+void LzmaEnc_InitPrices(CLzmaEnc *p)
+{
+ if (!p->fastMode)
+ {
+ FillDistancesPrices(p);
+ FillAlignPrices(p);
+ }
+
+ p->lenEnc.tableSize =
+ p->repLenEnc.tableSize =
+ p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN;
+ LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices);
+ LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices);
+}
+
+static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ UInt32 i;
+ for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++)
+ if (p->dictSize <= ((UInt32)1 << i))
+ break;
+ p->distTableSize = i * 2;
+
+ p->finished = False;
+ p->result = SZ_OK;
+ RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig));
+ LzmaEnc_Init(p);
+ LzmaEnc_InitPrices(p);
+ p->nowPos64 = 0;
+ return SZ_OK;
+}
+
+static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream,
+ ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ p->matchFinderBase.stream = inStream;
+ p->needInit = 1;
+ p->rc.outStream = outStream;
+ return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
+}
+
+SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp,
+ ISeqInStream *inStream, UInt32 keepWindowSize,
+ ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ p->matchFinderBase.stream = inStream;
+ p->needInit = 1;
+ return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
+}
+
+static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
+{
+ p->matchFinderBase.directInput = 1;
+ p->matchFinderBase.bufferBase = (Byte *)src;
+ p->matchFinderBase.directInputRem = srcLen;
+}
+
+SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
+ UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ LzmaEnc_SetInputBuf(p, src, srcLen);
+ p->needInit = 1;
+
+ return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
+}
+
+void LzmaEnc_Finish(CLzmaEncHandle pp)
+{
+ #ifdef COMPRESS_MF_MT
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ if (p->mtMode)
+ MatchFinderMt_ReleaseStream(&p->matchFinderMt);
+ #else
+ pp = pp;
+ #endif
+}
+
+typedef struct
+{
+ ISeqOutStream funcTable;
+ Byte *data;
+ SizeT rem;
+ Bool overflow;
+} CSeqOutStreamBuf;
+
+static size_t MyWrite(void *pp, const void *data, size_t size)
+{
+ CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp;
+ if (p->rem < size)
+ {
+ size = p->rem;
+ p->overflow = True;
+ }
+ memcpy(p->data, data, size);
+ p->rem -= size;
+ p->data += size;
+ return size;
+}
+
+
+UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
+{
+ const CLzmaEnc *p = (CLzmaEnc *)pp;
+ return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
+}
+
+const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
+{
+ const CLzmaEnc *p = (CLzmaEnc *)pp;
+ return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
+}
+
+SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
+ Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ UInt64 nowPos64;
+ SRes res;
+ CSeqOutStreamBuf outStream;
+
+ outStream.funcTable.Write = MyWrite;
+ outStream.data = dest;
+ outStream.rem = *destLen;
+ outStream.overflow = False;
+
+ p->writeEndMark = False;
+ p->finished = False;
+ p->result = SZ_OK;
+
+ if (reInit)
+ LzmaEnc_Init(p);
+ LzmaEnc_InitPrices(p);
+ nowPos64 = p->nowPos64;
+ RangeEnc_Init(&p->rc);
+ p->rc.outStream = &outStream.funcTable;
+
+ res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
+
+ *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
+ *destLen -= outStream.rem;
+ if (outStream.overflow)
+ return SZ_ERROR_OUTPUT_EOF;
+
+ return res;
+}
+
+static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
+{
+ SRes res = SZ_OK;
+
+ #ifdef COMPRESS_MF_MT
+ Byte allocaDummy[0x300];
+ int i = 0;
+ for (i = 0; i < 16; i++)
+ allocaDummy[i] = (Byte)i;
+ #endif
+
+ for (;;)
+ {
+ res = LzmaEnc_CodeOneBlock(p, False, 0, 0);
+ if (res != SZ_OK || p->finished != 0)
+ break;
+ if (progress != 0)
+ {
+ res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc));
+ if (res != SZ_OK)
+ {
+ res = SZ_ERROR_PROGRESS;
+ break;
+ }
+ }
+ }
+ LzmaEnc_Finish(p);
+ return res;
+}
+
+SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
+ ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig));
+ return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
+}
+
+SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ int i;
+ UInt32 dictSize = p->dictSize;
+ if (*size < LZMA_PROPS_SIZE)
+ return SZ_ERROR_PARAM;
+ *size = LZMA_PROPS_SIZE;
+ props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc);
+
+ for (i = 11; i <= 30; i++)
+ {
+ if (dictSize <= ((UInt32)2 << i))
+ {
+ dictSize = (2 << i);
+ break;
+ }
+ if (dictSize <= ((UInt32)3 << i))
+ {
+ dictSize = (3 << i);
+ break;
+ }
+ }
+
+ for (i = 0; i < 4; i++)
+ props[1 + i] = (Byte)(dictSize >> (8 * i));
+ return SZ_OK;
+}
+
+SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ SRes res;
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+
+ CSeqOutStreamBuf outStream;
+
+ LzmaEnc_SetInputBuf(p, src, srcLen);
+
+ outStream.funcTable.Write = MyWrite;
+ outStream.data = dest;
+ outStream.rem = *destLen;
+ outStream.overflow = False;
+
+ p->writeEndMark = writeEndMark;
+
+ p->rc.outStream = &outStream.funcTable;
+ res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig);
+ if (res == SZ_OK)
+ res = LzmaEnc_Encode2(p, progress);
+
+ *destLen -= outStream.rem;
+ if (outStream.overflow)
+ return SZ_ERROR_OUTPUT_EOF;
+ return res;
+}
+
+SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
+ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
+ SRes res;
+ if (p == 0)
+ return SZ_ERROR_MEM;
+
+ res = LzmaEnc_SetProps(p, props);
+ if (res == SZ_OK)
+ {
+ res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize);
+ if (res == SZ_OK)
+ res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen,
+ writeEndMark, progress, alloc, allocBig);
+ }
+
+ LzmaEnc_Destroy(p, alloc, allocBig);
+ return res;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaEnc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaEnc.h
new file mode 100644
index 000000000..200d60eb8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaEnc.h
@@ -0,0 +1,80 @@
+/* LzmaEnc.h -- LZMA Encoder
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __LZMA_ENC_H
+#define __LZMA_ENC_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LZMA_PROPS_SIZE 5
+
+typedef struct _CLzmaEncProps
+{
+ int level; /* 0 <= level <= 9 */
+ UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
+ (1 << 12) <= dictSize <= (1 << 30) for 64-bit version
+ default = (1 << 24) */
+ int lc; /* 0 <= lc <= 8, default = 3 */
+ int lp; /* 0 <= lp <= 4, default = 0 */
+ int pb; /* 0 <= pb <= 4, default = 2 */
+ int algo; /* 0 - fast, 1 - normal, default = 1 */
+ int fb; /* 5 <= fb <= 273, default = 32 */
+ int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
+ int numHashBytes; /* 2, 3 or 4, default = 4 */
+ UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
+ unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
+ int numThreads; /* 1 or 2, default = 2 */
+} CLzmaEncProps;
+
+void LzmaEncProps_Init(CLzmaEncProps *p);
+void LzmaEncProps_Normalize(CLzmaEncProps *p);
+UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
+
+
+/* ---------- CLzmaEncHandle Interface ---------- */
+
+/* LzmaEnc_* functions can return the following exit codes:
+Returns:
+ SZ_OK - OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_PARAM - Incorrect paramater in props
+ SZ_ERROR_WRITE - Write callback error.
+ SZ_ERROR_PROGRESS - some break from progress callback
+ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
+*/
+
+typedef void * CLzmaEncHandle;
+
+CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
+void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
+SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
+SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
+SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
+ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+
+/* ---------- One Call Interface ---------- */
+
+/* LzmaEncode
+Return code:
+ SZ_OK - OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_PARAM - Incorrect paramater
+ SZ_ERROR_OUTPUT_EOF - output buffer overflow
+ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
+*/
+
+SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
+ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Dec.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Dec.c
new file mode 100644
index 000000000..b801dd1ca
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Dec.c
@@ -0,0 +1,61 @@
+/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
+2008-04-07
+Igor Pavlov
+Public domain */
+
+#include "Lzma86Dec.h"
+
+#include "../Alloc.h"
+#include "../Bra.h"
+#include "../LzmaDec.h"
+
+#define LZMA86_SIZE_OFFSET (1 + LZMA_PROPS_SIZE)
+#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
+
+static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
+static void SzFree(void *p, void *address) { p = p; MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
+{
+ unsigned i;
+ if (srcLen < LZMA86_HEADER_SIZE)
+ return SZ_ERROR_INPUT_EOF;
+ *unpackSize = 0;
+ for (i = 0; i < sizeof(UInt64); i++)
+ *unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i);
+ return SZ_OK;
+}
+
+SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
+{
+ SRes res;
+ int useFilter;
+ SizeT inSizePure;
+ ELzmaStatus status;
+
+ if (*srcLen < LZMA86_HEADER_SIZE)
+ return SZ_ERROR_INPUT_EOF;
+
+ useFilter = src[0];
+
+ if (useFilter > 1)
+ {
+ *destLen = 0;
+ return SZ_ERROR_UNSUPPORTED;
+ }
+
+ inSizePure = *srcLen - LZMA86_HEADER_SIZE;
+ res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure,
+ src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc);
+ *srcLen = inSizePure + LZMA86_HEADER_SIZE;
+ if (res != SZ_OK)
+ return res;
+ if (useFilter == 1)
+ {
+ UInt32 x86State;
+ x86_Convert_Init(x86State);
+ x86_Convert(dest, *destLen, 0, &x86State, 0);
+ }
+ return SZ_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Dec.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Dec.h
new file mode 100644
index 000000000..138ce1ff7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Dec.h
@@ -0,0 +1,51 @@
+/* Lzma86Dec.h -- LZMA + x86 (BCJ) Filter Decoder
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __LZMA86_DEC_H
+#define __LZMA86_DEC_H
+
+#include "../Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+Lzma86_GetUnpackSize:
+ In:
+ src - input data
+ srcLen - input data size
+ Out:
+ unpackSize - size of uncompressed stream
+ Return code:
+ SZ_OK - OK
+ SZ_ERROR_INPUT_EOF - Error in headers
+*/
+
+SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize);
+
+/*
+Lzma86_Decode:
+ In:
+ dest - output data
+ destLen - output data size
+ src - input data
+ srcLen - input data size
+ Out:
+ destLen - processed output size
+ srcLen - processed input size
+ Return code:
+ SZ_OK - OK
+ SZ_ERROR_DATA - Data error
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_UNSUPPORTED - unsupported file
+ SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer
+*/
+
+SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Enc.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Enc.c
new file mode 100644
index 000000000..efc81ea35
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Enc.c
@@ -0,0 +1,113 @@
+/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
+2008-08-05
+Igor Pavlov
+Public domain */
+
+#include <string.h>
+
+#include "Lzma86Enc.h"
+
+#include "../Alloc.h"
+#include "../Bra.h"
+#include "../LzmaEnc.h"
+
+#define SZE_OUT_OVERFLOW SZE_DATA_ERROR
+
+static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
+static void SzFree(void *p, void *address) { p = p; MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+#define LZMA86_SIZE_OFFSET (1 + LZMA_PROPS_SIZE)
+#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
+
+int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
+ int level, UInt32 dictSize, int filterMode)
+{
+ size_t outSize2 = *destLen;
+ Byte *filteredStream;
+ Bool useFilter;
+ int mainResult = SZ_ERROR_OUTPUT_EOF;
+ CLzmaEncProps props;
+ LzmaEncProps_Init(&props);
+ props.level = level;
+ props.dictSize = dictSize;
+
+ *destLen = 0;
+ if (outSize2 < LZMA86_HEADER_SIZE)
+ return SZ_ERROR_OUTPUT_EOF;
+
+ {
+ int i;
+ UInt64 t = srcLen;
+ for (i = 0; i < 8; i++, t >>= 8)
+ dest[LZMA86_SIZE_OFFSET + i] = (Byte)t;
+ }
+
+ filteredStream = 0;
+ useFilter = (filterMode != SZ_FILTER_NO);
+ if (useFilter)
+ {
+ if (srcLen != 0)
+ {
+ filteredStream = (Byte *)MyAlloc(srcLen);
+ if (filteredStream == 0)
+ return SZ_ERROR_MEM;
+ memcpy(filteredStream, src, srcLen);
+ }
+ {
+ UInt32 x86State;
+ x86_Convert_Init(x86State);
+ x86_Convert(filteredStream, srcLen, 0, &x86State, 1);
+ }
+ }
+
+ {
+ size_t minSize = 0;
+ Bool bestIsFiltered = False;
+
+ /* passes for SZ_FILTER_AUTO:
+ 0 - BCJ + LZMA
+ 1 - LZMA
+ 2 - BCJ + LZMA agaian, if pass 0 (BCJ + LZMA) is better.
+ */
+ int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1;
+
+ int i;
+ for (i = 0; i < numPasses; i++)
+ {
+ size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE;
+ size_t outPropsSize = 5;
+ SRes curRes;
+ Bool curModeIsFiltered = (numPasses > 1 && i == numPasses - 1);
+ if (curModeIsFiltered && !bestIsFiltered)
+ break;
+ if (useFilter && i == 0)
+ curModeIsFiltered = True;
+
+ curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed,
+ curModeIsFiltered ? filteredStream : src, srcLen,
+ &props, dest + 1, &outPropsSize, 0,
+ NULL, &g_Alloc, &g_Alloc);
+
+ if (curRes != SZ_ERROR_OUTPUT_EOF)
+ {
+ if (curRes != SZ_OK)
+ {
+ mainResult = curRes;
+ break;
+ }
+ if (outSizeProcessed <= minSize || mainResult != SZ_OK)
+ {
+ minSize = outSizeProcessed;
+ bestIsFiltered = curModeIsFiltered;
+ mainResult = SZ_OK;
+ }
+ }
+ }
+ dest[0] = (bestIsFiltered ? 1 : 0);
+ *destLen = LZMA86_HEADER_SIZE + minSize;
+ }
+ if (useFilter)
+ MyFree(filteredStream);
+ return mainResult;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Enc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Enc.h
new file mode 100644
index 000000000..355bf343c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/LzmaUtil/Lzma86Enc.h
@@ -0,0 +1,78 @@
+/* Lzma86Enc.h -- LZMA + x86 (BCJ) Filter Encoder
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __LZMA86_ENC_H
+#define __LZMA86_ENC_H
+
+#include "../Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+It's an example for LZMA + x86 Filter use.
+You can use .lzma86 extension, if you write that stream to file.
+.lzma86 header adds one additional byte to standard .lzma header.
+.lzma86 header (14 bytes):
+ Offset Size Description
+ 0 1 = 0 - no filter,
+ = 1 - x86 filter
+ 1 1 lc, lp and pb in encoded form
+ 2 4 dictSize (little endian)
+ 6 8 uncompressed size (little endian)
+
+
+Lzma86_Encode
+-------------
+level - compression level: 0 <= level <= 9, the default value for "level" is 5.
+
+
+dictSize - The dictionary size in bytes. The maximum value is
+ 128 MB = (1 << 27) bytes for 32-bit version
+ 1 GB = (1 << 30) bytes for 64-bit version
+ The default value is 16 MB = (1 << 24) bytes, for level = 5.
+ It's recommended to use the dictionary that is larger than 4 KB and
+ that can be calculated as (1 << N) or (3 << N) sizes.
+ For better compression ratio dictSize must be >= inSize.
+
+filterMode:
+ SZ_FILTER_NO - no Filter
+ SZ_FILTER_YES - x86 Filter
+ SZ_FILTER_AUTO - it tries both alternatives to select best.
+ Encoder will use 2 or 3 passes:
+ 2 passes when FILTER_NO provides better compression.
+ 3 passes when FILTER_YES provides better compression.
+
+Lzma86Encode allocates Data with MyAlloc functions.
+RAM Requirements for compressing:
+ RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize
+ filterMode FilterBlockSize
+ SZ_FILTER_NO 0
+ SZ_FILTER_YES inSize
+ SZ_FILTER_AUTO inSize
+
+
+Return code:
+ SZ_OK - OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_PARAM - Incorrect paramater
+ SZ_ERROR_OUTPUT_EOF - output buffer overflow
+ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
+*/
+
+enum ESzFilterMode
+{
+ SZ_FILTER_NO,
+ SZ_FILTER_YES,
+ SZ_FILTER_AUTO
+};
+
+SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
+ int level, UInt32 dictSize, int filterMode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/MtCoder.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/MtCoder.c
new file mode 100644
index 000000000..57cfe3535
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/MtCoder.c
@@ -0,0 +1,327 @@
+/* MtCoder.c -- Multi-thread Coder
+2009-03-26 : Igor Pavlov : Public domain */
+
+#include <stdio.h>
+
+#include "MtCoder.h"
+
+void LoopThread_Construct(CLoopThread *p)
+{
+ Thread_Construct(&p->thread);
+ Event_Construct(&p->startEvent);
+ Event_Construct(&p->finishedEvent);
+}
+
+void LoopThread_Close(CLoopThread *p)
+{
+ Thread_Close(&p->thread);
+ Event_Close(&p->startEvent);
+ Event_Close(&p->finishedEvent);
+}
+
+static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE LoopThreadFunc(void *pp)
+{
+ CLoopThread *p = (CLoopThread *)pp;
+ for (;;)
+ {
+ if (Event_Wait(&p->startEvent) != 0)
+ return SZ_ERROR_THREAD;
+ if (p->stop)
+ return 0;
+ p->res = p->func(p->param);
+ if (Event_Set(&p->finishedEvent) != 0)
+ return SZ_ERROR_THREAD;
+ }
+}
+
+WRes LoopThread_Create(CLoopThread *p)
+{
+ p->stop = 0;
+ RINOK(AutoResetEvent_CreateNotSignaled(&p->startEvent));
+ RINOK(AutoResetEvent_CreateNotSignaled(&p->finishedEvent));
+ return Thread_Create(&p->thread, LoopThreadFunc, p);
+}
+
+WRes LoopThread_StopAndWait(CLoopThread *p)
+{
+ p->stop = 1;
+ if (Event_Set(&p->startEvent) != 0)
+ return SZ_ERROR_THREAD;
+ return Thread_Wait(&p->thread);
+}
+
+WRes LoopThread_StartSubThread(CLoopThread *p) { return Event_Set(&p->startEvent); }
+WRes LoopThread_WaitSubThread(CLoopThread *p) { return Event_Wait(&p->finishedEvent); }
+
+static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)
+{
+ return (p && p->Progress(p, inSize, outSize) != SZ_OK) ? SZ_ERROR_PROGRESS : SZ_OK;
+}
+
+static void MtProgress_Init(CMtProgress *p, ICompressProgress *progress)
+{
+ unsigned i;
+ for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
+ p->inSizes[i] = p->outSizes[i] = 0;
+ p->totalInSize = p->totalOutSize = 0;
+ p->progress = progress;
+ p->res = SZ_OK;
+}
+
+static void MtProgress_Reinit(CMtProgress *p, unsigned index)
+{
+ p->inSizes[index] = 0;
+ p->outSizes[index] = 0;
+}
+
+#define UPDATE_PROGRESS(size, prev, total) \
+ if (size != (UInt64)(Int64)-1) { total += size - prev; prev = size; }
+
+SRes MtProgress_Set(CMtProgress *p, unsigned index, UInt64 inSize, UInt64 outSize)
+{
+ SRes res;
+ CriticalSection_Enter(&p->cs);
+ UPDATE_PROGRESS(inSize, p->inSizes[index], p->totalInSize)
+ UPDATE_PROGRESS(outSize, p->outSizes[index], p->totalOutSize)
+ if (p->res == SZ_OK)
+ p->res = Progress(p->progress, p->totalInSize, p->totalOutSize);
+ res = p->res;
+ CriticalSection_Leave(&p->cs);
+ return res;
+}
+
+static void MtProgress_SetError(CMtProgress *p, SRes res)
+{
+ CriticalSection_Enter(&p->cs);
+ if (p->res == SZ_OK)
+ p->res = res;
+ CriticalSection_Leave(&p->cs);
+}
+
+static void MtCoder_SetError(CMtCoder* p, SRes res)
+{
+ CriticalSection_Enter(&p->cs);
+ if (p->res == SZ_OK)
+ p->res = res;
+ CriticalSection_Leave(&p->cs);
+}
+
+/* ---------- MtThread ---------- */
+
+void CMtThread_Construct(CMtThread *p, CMtCoder *mtCoder)
+{
+ p->mtCoder = mtCoder;
+ p->outBuf = 0;
+ p->inBuf = 0;
+ Event_Construct(&p->canRead);
+ Event_Construct(&p->canWrite);
+ LoopThread_Construct(&p->thread);
+}
+
+#define RINOK_THREAD(x) { if((x) != 0) return SZ_ERROR_THREAD; }
+
+static void CMtThread_CloseEvents(CMtThread *p)
+{
+ Event_Close(&p->canRead);
+ Event_Close(&p->canWrite);
+}
+
+static void CMtThread_Destruct(CMtThread *p)
+{
+ CMtThread_CloseEvents(p);
+
+ if (Thread_WasCreated(&p->thread.thread))
+ {
+ LoopThread_StopAndWait(&p->thread);
+ LoopThread_Close(&p->thread);
+ }
+
+ if (p->mtCoder->alloc)
+ IAlloc_Free(p->mtCoder->alloc, p->outBuf);
+ p->outBuf = 0;
+
+ if (p->mtCoder->alloc)
+ IAlloc_Free(p->mtCoder->alloc, p->inBuf);
+ p->inBuf = 0;
+}
+
+#define MY_BUF_ALLOC(buf, size, newSize) \
+ if (buf == 0 || size != newSize) \
+ { IAlloc_Free(p->mtCoder->alloc, buf); \
+ size = newSize; buf = IAlloc_Alloc(p->mtCoder->alloc, size); \
+ if (buf == 0) return SZ_ERROR_MEM; }
+
+static SRes CMtThread_Prepare(CMtThread *p)
+{
+ MY_BUF_ALLOC(p->inBuf, p->inBufSize, p->mtCoder->blockSize)
+ MY_BUF_ALLOC(p->outBuf, p->outBufSize, p->mtCoder->destBlockSize)
+
+ p->stopReading = False;
+ p->stopWriting = False;
+ RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canRead));
+ RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canWrite));
+
+ return SZ_OK;
+}
+
+static SRes FullRead(ISeqInStream *stream, Byte *data, size_t *processedSize)
+{
+ size_t size = *processedSize;
+ *processedSize = 0;
+ while (size != 0)
+ {
+ size_t curSize = size;
+ SRes res = stream->Read(stream, data, &curSize);
+ *processedSize += curSize;
+ data += curSize;
+ size -= curSize;
+ RINOK(res);
+ if (curSize == 0)
+ return SZ_OK;
+ }
+ return SZ_OK;
+}
+
+#define GET_NEXT_THREAD(p) &p->mtCoder->threads[p->index == p->mtCoder->numThreads - 1 ? 0 : p->index + 1]
+
+static SRes MtThread_Process(CMtThread *p, Bool *stop)
+{
+ CMtThread *next;
+ *stop = True;
+ if (Event_Wait(&p->canRead) != 0)
+ return SZ_ERROR_THREAD;
+
+ next = GET_NEXT_THREAD(p);
+
+ if (p->stopReading)
+ {
+ next->stopReading = True;
+ return Event_Set(&next->canRead) == 0 ? SZ_OK : SZ_ERROR_THREAD;
+ }
+
+ {
+ size_t size = p->mtCoder->blockSize;
+ size_t destSize = p->outBufSize;
+
+ RINOK(FullRead(p->mtCoder->inStream, p->inBuf, &size));
+ next->stopReading = *stop = (size != p->mtCoder->blockSize);
+ if (Event_Set(&next->canRead) != 0)
+ return SZ_ERROR_THREAD;
+
+ RINOK(p->mtCoder->mtCallback->Code(p->mtCoder->mtCallback, p->index,
+ p->outBuf, &destSize, p->inBuf, size, *stop));
+
+ MtProgress_Reinit(&p->mtCoder->mtProgress, p->index);
+
+ if (Event_Wait(&p->canWrite) != 0)
+ return SZ_ERROR_THREAD;
+ if (p->stopWriting)
+ return SZ_ERROR_FAIL;
+ if (p->mtCoder->outStream->Write(p->mtCoder->outStream, p->outBuf, destSize) != destSize)
+ return SZ_ERROR_WRITE;
+ return Event_Set(&next->canWrite) == 0 ? SZ_OK : SZ_ERROR_THREAD;
+ }
+}
+
+static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp)
+{
+ CMtThread *p = (CMtThread *)pp;
+ for (;;)
+ {
+ Bool stop;
+ CMtThread *next = GET_NEXT_THREAD(p);
+ SRes res = MtThread_Process(p, &stop);
+ if (res != SZ_OK)
+ {
+ MtCoder_SetError(p->mtCoder, res);
+ MtProgress_SetError(&p->mtCoder->mtProgress, res);
+ next->stopReading = True;
+ next->stopWriting = True;
+ Event_Set(&next->canRead);
+ Event_Set(&next->canWrite);
+ return res;
+ }
+ if (stop)
+ return 0;
+ }
+}
+
+void MtCoder_Construct(CMtCoder* p)
+{
+ unsigned i;
+ p->alloc = 0;
+ for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
+ {
+ CMtThread *t = &p->threads[i];
+ t->index = i;
+ CMtThread_Construct(t, p);
+ }
+ CriticalSection_Init(&p->cs);
+ CriticalSection_Init(&p->mtProgress.cs);
+}
+
+void MtCoder_Destruct(CMtCoder* p)
+{
+ unsigned i;
+ for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
+ CMtThread_Destruct(&p->threads[i]);
+ CriticalSection_Delete(&p->cs);
+ CriticalSection_Delete(&p->mtProgress.cs);
+}
+
+SRes MtCoder_Code(CMtCoder *p)
+{
+ unsigned i, numThreads = p->numThreads;
+ SRes res = SZ_OK;
+ p->res = SZ_OK;
+
+ MtProgress_Init(&p->mtProgress, p->progress);
+
+ for (i = 0; i < numThreads; i++)
+ {
+ RINOK(CMtThread_Prepare(&p->threads[i]));
+ }
+
+ for (i = 0; i < numThreads; i++)
+ {
+ CMtThread *t = &p->threads[i];
+ CLoopThread *lt = &t->thread;
+
+ if (!Thread_WasCreated(&lt->thread))
+ {
+ lt->func = ThreadFunc;
+ lt->param = t;
+
+ if (LoopThread_Create(lt) != SZ_OK)
+ {
+ res = SZ_ERROR_THREAD;
+ break;
+ }
+ }
+ }
+
+ if (res == SZ_OK)
+ {
+ unsigned j;
+ for (i = 0; i < numThreads; i++)
+ {
+ CMtThread *t = &p->threads[i];
+ if (LoopThread_StartSubThread(&t->thread) != SZ_OK || i == 10)
+ {
+ res = SZ_ERROR_THREAD;
+ p->threads[0].stopReading = True;
+ break;
+ }
+ }
+
+ Event_Set(&p->threads[0].canWrite);
+ Event_Set(&p->threads[0].canRead);
+
+ for (j = 0; j < i; j++)
+ LoopThread_WaitSubThread(&p->threads[j].thread);
+ }
+
+ for (i = 0; i < numThreads; i++)
+ CMtThread_CloseEvents(&p->threads[i]);
+ return (res == SZ_OK) ? p->res : res;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/MtCoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/MtCoder.h
new file mode 100644
index 000000000..fb813d4de
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/MtCoder.h
@@ -0,0 +1,102 @@
+/* MtCoder.h -- Multi-thread Coder
+2009-03-26 : Igor Pavlov : Public domain */
+
+#ifndef __MT_CODER_H
+#define __MT_CODER_H
+
+#include "Threads.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ CThread thread;
+ CAutoResetEvent startEvent;
+ CAutoResetEvent finishedEvent;
+ int stop;
+
+ THREAD_FUNC_TYPE func;
+ LPVOID param;
+ THREAD_FUNC_RET_TYPE res;
+} CLoopThread;
+
+void LoopThread_Construct(CLoopThread *p);
+void LoopThread_Close(CLoopThread *p);
+WRes LoopThread_Create(CLoopThread *p);
+WRes LoopThread_StopAndWait(CLoopThread *p);
+WRes LoopThread_StartSubThread(CLoopThread *p);
+WRes LoopThread_WaitSubThread(CLoopThread *p);
+
+#ifdef COMPRESS_MT
+#define NUM_MT_CODER_THREADS_MAX 32
+#else
+#define NUM_MT_CODER_THREADS_MAX 1
+#endif
+
+typedef struct
+{
+ UInt64 totalInSize;
+ UInt64 totalOutSize;
+ ICompressProgress *progress;
+ SRes res;
+ CCriticalSection cs;
+ UInt64 inSizes[NUM_MT_CODER_THREADS_MAX];
+ UInt64 outSizes[NUM_MT_CODER_THREADS_MAX];
+} CMtProgress;
+
+SRes MtProgress_Set(CMtProgress *p, unsigned index, UInt64 inSize, UInt64 outSize);
+
+struct _CMtCoder;
+
+typedef struct
+{
+ struct _CMtCoder *mtCoder;
+ Byte *outBuf;
+ size_t outBufSize;
+ Byte *inBuf;
+ size_t inBufSize;
+ unsigned index;
+ CLoopThread thread;
+
+ Bool stopReading;
+ Bool stopWriting;
+ CAutoResetEvent canRead;
+ CAutoResetEvent canWrite;
+} CMtThread;
+
+typedef struct
+{
+ SRes (*Code)(void *p, unsigned index, Byte *dest, size_t *destSize,
+ const Byte *src, size_t srcSize, int finished);
+} IMtCoderCallback;
+
+typedef struct _CMtCoder
+{
+ size_t blockSize;
+ size_t destBlockSize;
+ unsigned numThreads;
+
+ ISeqInStream *inStream;
+ ISeqOutStream *outStream;
+ ICompressProgress *progress;
+ ISzAlloc *alloc;
+
+ IMtCoderCallback *mtCallback;
+ CCriticalSection cs;
+ SRes res;
+
+ CMtProgress mtProgress;
+ CMtThread threads[NUM_MT_CODER_THREADS_MAX];
+} CMtCoder;
+
+void MtCoder_Construct(CMtCoder* p);
+void MtCoder_Destruct(CMtCoder* p);
+SRes MtCoder_Code(CMtCoder *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/RotateDefs.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/RotateDefs.h
new file mode 100644
index 000000000..c3a1385ce
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/RotateDefs.h
@@ -0,0 +1,20 @@
+/* RotateDefs.h -- Rotate functions
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __ROTATE_DEFS_H
+#define __ROTATE_DEFS_H
+
+#ifdef _MSC_VER
+
+#include <stdlib.h>
+#define rotlFixed(x, n) _rotl((x), (n))
+#define rotrFixed(x, n) _rotr((x), (n))
+
+#else
+
+#define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+#define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
+
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sha256.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sha256.c
new file mode 100644
index 000000000..7cd99e093
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sha256.c
@@ -0,0 +1,204 @@
+/* Crypto/Sha256.c -- SHA-256 Hash function
+2008-11-06 : Igor Pavlov : Public domain
+This code is based on public domain code from Wei Dai's Crypto++ library. */
+
+#include "Sha256.h"
+#include "RotateDefs.h"
+
+/* define it for speed optimization */
+/* #define _SHA256_UNROLL */
+/* #define _SHA256_UNROLL2 */
+
+void Sha256_Init(CSha256 *p)
+{
+ p->state[0] = 0x6a09e667;
+ p->state[1] = 0xbb67ae85;
+ p->state[2] = 0x3c6ef372;
+ p->state[3] = 0xa54ff53a;
+ p->state[4] = 0x510e527f;
+ p->state[5] = 0x9b05688c;
+ p->state[6] = 0x1f83d9ab;
+ p->state[7] = 0x5be0cd19;
+ p->count = 0;
+}
+
+#define S0(x) (rotrFixed(x, 2) ^ rotrFixed(x,13) ^ rotrFixed(x, 22))
+#define S1(x) (rotrFixed(x, 6) ^ rotrFixed(x,11) ^ rotrFixed(x, 25))
+#define s0(x) (rotrFixed(x, 7) ^ rotrFixed(x,18) ^ (x >> 3))
+#define s1(x) (rotrFixed(x,17) ^ rotrFixed(x,19) ^ (x >> 10))
+
+#define blk0(i) (W[i] = data[i])
+#define blk2(i) (W[i&15] += s1(W[(i-2)&15]) + W[(i-7)&15] + s0(W[(i-15)&15]))
+
+#define Ch(x,y,z) (z^(x&(y^z)))
+#define Maj(x,y,z) ((x&y)|(z&(x|y)))
+
+#define a(i) T[(0-(i))&7]
+#define b(i) T[(1-(i))&7]
+#define c(i) T[(2-(i))&7]
+#define d(i) T[(3-(i))&7]
+#define e(i) T[(4-(i))&7]
+#define f(i) T[(5-(i))&7]
+#define g(i) T[(6-(i))&7]
+#define h(i) T[(7-(i))&7]
+
+
+#ifdef _SHA256_UNROLL2
+
+#define R(a,b,c,d,e,f,g,h, i) h += S1(e) + Ch(e,f,g) + K[i+j] + (j?blk2(i):blk0(i));\
+ d += h; h += S0(a) + Maj(a, b, c)
+
+#define RX_8(i) \
+ R(a,b,c,d,e,f,g,h, i); \
+ R(h,a,b,c,d,e,f,g, i+1); \
+ R(g,h,a,b,c,d,e,f, i+2); \
+ R(f,g,h,a,b,c,d,e, i+3); \
+ R(e,f,g,h,a,b,c,d, i+4); \
+ R(d,e,f,g,h,a,b,c, i+5); \
+ R(c,d,e,f,g,h,a,b, i+6); \
+ R(b,c,d,e,f,g,h,a, i+7)
+
+#else
+
+#define R(i) h(i) += S1(e(i)) + Ch(e(i),f(i),g(i)) + K[i+j] + (j?blk2(i):blk0(i));\
+ d(i) += h(i); h(i) += S0(a(i)) + Maj(a(i), b(i), c(i))
+
+#ifdef _SHA256_UNROLL
+
+#define RX_8(i) R(i+0); R(i+1); R(i+2); R(i+3); R(i+4); R(i+5); R(i+6); R(i+7);
+
+#endif
+
+#endif
+
+const UInt32 K[64] = {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+};
+
+static void Sha256_Transform(UInt32 *state, const UInt32 *data)
+{
+ UInt32 W[16];
+ unsigned j;
+ #ifdef _SHA256_UNROLL2
+ UInt32 a,b,c,d,e,f,g,h;
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+ f = state[5];
+ g = state[6];
+ h = state[7];
+ #else
+ UInt32 T[8];
+ for (j = 0; j < 8; j++)
+ T[j] = state[j];
+ #endif
+
+ for (j = 0; j < 64; j += 16)
+ {
+ #if defined(_SHA256_UNROLL) || defined(_SHA256_UNROLL2)
+ RX_8(0); RX_8(8);
+ #else
+ unsigned i;
+ for (i = 0; i < 16; i++) { R(i); }
+ #endif
+ }
+
+ #ifdef _SHA256_UNROLL2
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+ state[5] += f;
+ state[6] += g;
+ state[7] += h;
+ #else
+ for (j = 0; j < 8; j++)
+ state[j] += T[j];
+ #endif
+
+ /* Wipe variables */
+ /* memset(W, 0, sizeof(W)); */
+ /* memset(T, 0, sizeof(T)); */
+}
+
+#undef S0
+#undef S1
+#undef s0
+#undef s1
+
+static void Sha256_WriteByteBlock(CSha256 *p)
+{
+ UInt32 data32[16];
+ unsigned i;
+ for (i = 0; i < 16; i++)
+ data32[i] =
+ ((UInt32)(p->buffer[i * 4 ]) << 24) +
+ ((UInt32)(p->buffer[i * 4 + 1]) << 16) +
+ ((UInt32)(p->buffer[i * 4 + 2]) << 8) +
+ ((UInt32)(p->buffer[i * 4 + 3]));
+ Sha256_Transform(p->state, data32);
+}
+
+void Sha256_Update(CSha256 *p, const Byte *data, size_t size)
+{
+ UInt32 curBufferPos = (UInt32)p->count & 0x3F;
+ while (size > 0)
+ {
+ p->buffer[curBufferPos++] = *data++;
+ p->count++;
+ size--;
+ if (curBufferPos == 64)
+ {
+ curBufferPos = 0;
+ Sha256_WriteByteBlock(p);
+ }
+ }
+}
+
+void Sha256_Final(CSha256 *p, Byte *digest)
+{
+ UInt64 lenInBits = (p->count << 3);
+ UInt32 curBufferPos = (UInt32)p->count & 0x3F;
+ unsigned i;
+ p->buffer[curBufferPos++] = 0x80;
+ while (curBufferPos != (64 - 8))
+ {
+ curBufferPos &= 0x3F;
+ if (curBufferPos == 0)
+ Sha256_WriteByteBlock(p);
+ p->buffer[curBufferPos++] = 0;
+ }
+ for (i = 0; i < 8; i++)
+ {
+ p->buffer[curBufferPos++] = (Byte)(lenInBits >> 56);
+ lenInBits <<= 8;
+ }
+ Sha256_WriteByteBlock(p);
+
+ for (i = 0; i < 8; i++)
+ {
+ *digest++ = (Byte)(p->state[i] >> 24);
+ *digest++ = (Byte)(p->state[i] >> 16);
+ *digest++ = (Byte)(p->state[i] >> 8);
+ *digest++ = (Byte)(p->state[i]);
+ }
+ Sha256_Init(p);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sha256.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sha256.h
new file mode 100644
index 000000000..0224105d3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sha256.h
@@ -0,0 +1,30 @@
+/* Sha256.h -- SHA-256 Hash
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __CRYPTO_SHA256_H
+#define __CRYPTO_SHA256_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SHA256_DIGEST_SIZE 32
+
+typedef struct
+{
+ UInt32 state[8];
+ UInt64 count;
+ Byte buffer[64];
+} CSha256;
+
+void Sha256_Init(CSha256 *p);
+void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
+void Sha256_Final(CSha256 *p, Byte *digest);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sort.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sort.c
new file mode 100644
index 000000000..ac772f6f3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sort.c
@@ -0,0 +1,95 @@
+/* Sort.c -- Sort functions
+2008-08-17
+Igor Pavlov
+Public domain */
+
+#include "Sort.h"
+
+#define HeapSortDown(p, k, size, temp) \
+ { for (;;) { \
+ UInt32 s = (k << 1); \
+ if (s > size) break; \
+ if (s < size && p[s + 1] > p[s]) s++; \
+ if (temp >= p[s]) break; \
+ p[k] = p[s]; k = s; \
+ } p[k] = temp; }
+
+void HeapSort(UInt32 *p, UInt32 size)
+{
+ if (size <= 1)
+ return;
+ p--;
+ {
+ UInt32 i = size / 2;
+ do
+ {
+ UInt32 temp = p[i];
+ UInt32 k = i;
+ HeapSortDown(p, k, size, temp)
+ }
+ while (--i != 0);
+ }
+ /*
+ do
+ {
+ UInt32 k = 1;
+ UInt32 temp = p[size];
+ p[size--] = p[1];
+ HeapSortDown(p, k, size, temp)
+ }
+ while (size > 1);
+ */
+ while (size > 3)
+ {
+ UInt32 temp = p[size];
+ UInt32 k = (p[3] > p[2]) ? 3 : 2;
+ p[size--] = p[1];
+ p[1] = p[k];
+ HeapSortDown(p, k, size, temp)
+ }
+ {
+ UInt32 temp = p[size];
+ p[size] = p[1];
+ if (size > 2 && p[2] < temp)
+ {
+ p[1] = p[2];
+ p[2] = temp;
+ }
+ else
+ p[1] = temp;
+ }
+}
+
+/*
+#define HeapSortRefDown(p, vals, n, size, temp) \
+ { UInt32 k = n; UInt32 val = vals[temp]; for (;;) { \
+ UInt32 s = (k << 1); \
+ if (s > size) break; \
+ if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \
+ if (val >= vals[p[s]]) break; \
+ p[k] = p[s]; k = s; \
+ } p[k] = temp; }
+
+void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size)
+{
+ if (size <= 1)
+ return;
+ p--;
+ {
+ UInt32 i = size / 2;
+ do
+ {
+ UInt32 temp = p[i];
+ HeapSortRefDown(p, vals, i, size, temp);
+ }
+ while (--i != 0);
+ }
+ do
+ {
+ UInt32 temp = p[size];
+ p[size--] = p[1];
+ HeapSortRefDown(p, vals, 1, size, temp);
+ }
+ while (size > 1);
+}
+*/ \ No newline at end of file
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sort.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sort.h
new file mode 100644
index 000000000..65dfc6f6a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Sort.h
@@ -0,0 +1,20 @@
+/* Sort.h -- Sort functions
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __7Z_SORT_H
+#define __7Z_SORT_H
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void HeapSort(UInt32 *p, UInt32 size);
+/* void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size); */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Threads.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Threads.c
new file mode 100644
index 000000000..2501f8ed7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Threads.c
@@ -0,0 +1,690 @@
+/* Threads.c */
+
+#include "Threads.h"
+
+#ifdef ENV_UNIX
+#ifdef ENV_BEOS
+#include <kernel/OS.h>
+#else
+#include <pthread.h>
+#include <stdlib.h>
+#endif
+
+#include <errno.h>
+
+#if defined(__linux__)
+#define PTHREAD_MUTEX_ERRORCHECK PTHREAD_MUTEX_ERRORCHECK_NP
+#endif
+
+#ifdef ENV_BEOS
+
+/* TODO : optimize the code and verify the returned values */
+
+WRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
+{
+ thread->_tid = spawn_thread((int32 (*)(void *))startAddress, "CThread", B_LOW_PRIORITY, parameter);
+ if (thread->_tid >= B_OK) {
+ resume_thread(thread->_tid);
+ } else {
+ thread->_tid = B_BAD_THREAD_ID;
+ }
+ thread->_created = 1;
+ return 0; // SZ_OK;
+}
+
+WRes Thread_Wait(CThread *thread)
+{
+ int ret;
+
+ if (thread->_created == 0)
+ return EINVAL;
+
+ if (thread->_tid >= B_OK)
+ {
+ status_t exit_value;
+ wait_for_thread(thread->_tid, &exit_value);
+ thread->_tid = B_BAD_THREAD_ID;
+ } else {
+ return EINVAL;
+ }
+
+ thread->_created = 0;
+
+ return 0;
+}
+
+WRes Thread_Close(CThread *thread)
+{
+ if (!thread->_created) return SZ_OK;
+
+ thread->_tid = B_BAD_THREAD_ID;
+ thread->_created = 0;
+ return SZ_OK;
+}
+
+
+WRes Event_Create(CEvent *p, BOOL manualReset, int initialSignaled)
+{
+ p->_index_waiting = 0;
+ p->_manual_reset = manualReset;
+ p->_state = (initialSignaled ? TRUE : FALSE);
+ p->_created = 1;
+ p->_sem = create_sem(1,"event");
+ return 0;
+}
+
+WRes Event_Set(CEvent *p) {
+ int index;
+ acquire_sem(p->_sem);
+ p->_state = TRUE;
+ for(index = 0 ; index < p->_index_waiting ; index++)
+ {
+ send_data(p->_waiting[index], '7zCN', NULL, 0);
+ }
+ p->_index_waiting = 0;
+ release_sem(p->_sem);
+ return 0;
+}
+
+WRes Event_Reset(CEvent *p) {
+ acquire_sem(p->_sem);
+ p->_state = FALSE;
+ release_sem(p->_sem);
+ return 0;
+}
+
+WRes Event_Wait(CEvent *p) {
+ acquire_sem(p->_sem);
+ while (p->_state == FALSE)
+ {
+ thread_id sender;
+ p->_waiting[p->_index_waiting++] = find_thread(NULL);
+ release_sem(p->_sem);
+ /* int msg = */ receive_data(&sender, NULL, 0);
+ acquire_sem(p->_sem);
+ }
+ if (p->_manual_reset == FALSE)
+ {
+ p->_state = FALSE;
+ }
+ release_sem(p->_sem);
+ return 0;
+}
+
+WRes Event_Close(CEvent *p) {
+ if (p->_created)
+ {
+ p->_created = 0;
+ delete_sem(p->_sem);
+ }
+ return 0;
+}
+
+WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount)
+{
+ p->_index_waiting = 0;
+ p->_count = initiallyCount;
+ p->_maxCount = maxCount;
+ p->_created = 1;
+ p->_sem = create_sem(1,"sem");
+ return 0;
+}
+
+WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount)
+{
+ UInt32 newCount;
+ int index;
+
+ if (releaseCount < 1) return EINVAL;
+
+ acquire_sem(p->_sem);
+ newCount = p->_count + releaseCount;
+ if (newCount > p->_maxCount)
+ {
+ release_sem(p->_sem);
+ return EINVAL;
+ }
+ p->_count = newCount;
+ for(index = 0 ; index < p->_index_waiting ; index++)
+ {
+ send_data(p->_waiting[index], '7zCN', NULL, 0);
+ }
+ p->_index_waiting = 0;
+ release_sem(p->_sem);
+ return 0;
+}
+
+WRes Semaphore_Wait(CSemaphore *p) {
+ acquire_sem(p->_sem);
+ while (p->_count < 1)
+ {
+ thread_id sender;
+ p->_waiting[p->_index_waiting++] = find_thread(NULL);
+ release_sem(p->_sem);
+ /* int msg = */ receive_data(&sender, NULL, 0);
+ acquire_sem(p->_sem);
+ }
+ p->_count--;
+ release_sem(p->_sem);
+ return 0;
+}
+
+WRes Semaphore_Close(CSemaphore *p) {
+ if (p->_created)
+ {
+ p->_created = 0;
+ delete_sem(p->_sem);
+ }
+ return 0;
+}
+
+WRes CriticalSection_Init(CCriticalSection * lpCriticalSection)
+{
+ lpCriticalSection->_sem = create_sem(1,"cc");
+ return 0;
+}
+
+#else /* !ENV_BEOS */
+
+WRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
+{
+ pthread_attr_t attr;
+ int ret;
+
+ thread->_created = 0;
+
+ ret = pthread_attr_init(&attr);
+ if (ret) return ret;
+
+ ret = pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE);
+ if (ret) return ret;
+
+ ret = pthread_create(&thread->_tid, &attr, (void * (*)(void *))startAddress, parameter);
+
+ /* ret2 = */ pthread_attr_destroy(&attr);
+
+ if (ret) return ret;
+
+ thread->_created = 1;
+
+ return 0; // SZ_OK;
+}
+
+WRes Thread_Wait(CThread *thread)
+{
+ void *thread_return;
+ int ret;
+
+ if (thread->_created == 0)
+ return EINVAL;
+
+ ret = pthread_join(thread->_tid,&thread_return);
+ thread->_created = 0;
+
+ return ret;
+}
+
+WRes Thread_Close(CThread *thread)
+{
+ if (!thread->_created) return SZ_OK;
+
+ pthread_detach(thread->_tid);
+ thread->_tid = 0;
+ thread->_created = 0;
+ return SZ_OK;
+}
+
+#ifdef DEBUG_SYNCHRO
+
+#include <stdio.h>
+
+static void dump_error(int ligne,int ret,const char *text,void *param)
+{
+ printf("\n##T%d#ERROR2 (l=%d) %s : param=%p ret = %d (%s)##\n",(int)pthread_self(),ligne,text,param,ret,strerror(ret));
+ // abort();
+}
+
+WRes Event_Create(CEvent *p, BOOL manualReset, int initialSignaled)
+{
+ int ret;
+ pthread_mutexattr_t mutexattr;
+ memset(&mutexattr,0,sizeof(mutexattr));
+ ret = pthread_mutexattr_init(&mutexattr);
+ if (ret != 0) dump_error(__LINE__,ret,"Event_Create::pthread_mutexattr_init",&mutexattr);
+ ret = pthread_mutexattr_settype(&mutexattr,PTHREAD_MUTEX_ERRORCHECK);
+ if (ret != 0) dump_error(__LINE__,ret,"Event_Create::pthread_mutexattr_settype",&mutexattr);
+ ret = pthread_mutex_init(&p->_mutex,&mutexattr);
+ if (ret != 0) dump_error(__LINE__,ret,"Event_Create::pthread_mutexattr_init",&p->_mutex);
+ if (ret == 0)
+ {
+ ret = pthread_cond_init(&p->_cond,0);
+ if (ret != 0) dump_error(__LINE__,ret,"Event_Create::pthread_cond_init",&p->_cond);
+ p->_manual_reset = manualReset;
+ p->_state = (initialSignaled ? TRUE : FALSE);
+ p->_created = 1;
+ }
+ return ret;
+}
+
+WRes Event_Set(CEvent *p) {
+ int ret = pthread_mutex_lock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"ES::pthread_mutex_lock",&p->_mutex);
+ if (ret == 0)
+ {
+ p->_state = TRUE;
+ ret = pthread_cond_broadcast(&p->_cond);
+ if (ret != 0) dump_error(__LINE__,ret,"ES::pthread_cond_broadcast",&p->_cond);
+ if (ret == 0)
+ {
+ ret = pthread_mutex_unlock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"ES::pthread_mutex_unlock",&p->_mutex);
+ }
+ }
+ return ret;
+}
+
+WRes Event_Reset(CEvent *p) {
+ int ret = pthread_mutex_lock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"ER::pthread_mutex_lock",&p->_mutex);
+ if (ret == 0)
+ {
+ p->_state = FALSE;
+ ret = pthread_mutex_unlock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"ER::pthread_mutex_unlock",&p->_mutex);
+ }
+ return ret;
+}
+
+WRes Event_Wait(CEvent *p) {
+ int ret = pthread_mutex_lock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"EW::pthread_mutex_lock",&p->_mutex);
+ if (ret == 0)
+ {
+ while ((p->_state == FALSE) && (ret == 0))
+ {
+ ret = pthread_cond_wait(&p->_cond, &p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"EW::pthread_cond_wait",&p->_mutex);
+ }
+ if (ret == 0)
+ {
+ if (p->_manual_reset == FALSE)
+ {
+ p->_state = FALSE;
+ }
+ ret = pthread_mutex_unlock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"EW::pthread_mutex_unlock",&p->_mutex);
+ }
+ }
+ return ret;
+}
+
+WRes Event_Close(CEvent *p) {
+ if (p->_created)
+ {
+ int ret;
+ p->_created = 0;
+ ret = pthread_mutex_destroy(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"EC::pthread_mutex_destroy",&p->_mutex);
+ ret = pthread_cond_destroy(&p->_cond);
+ if (ret != 0) dump_error(__LINE__,ret,"EC::pthread_cond_destroy",&p->_cond);
+ }
+ return 0;
+}
+
+WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount)
+{
+ int ret;
+ pthread_mutexattr_t mutexattr;
+ memset(&mutexattr,0,sizeof(mutexattr));
+ ret = pthread_mutexattr_init(&mutexattr);
+ if (ret != 0) dump_error(__LINE__,ret,"SemC::pthread_mutexattr_init",&mutexattr);
+ ret = pthread_mutexattr_settype(&mutexattr,PTHREAD_MUTEX_ERRORCHECK);
+ if (ret != 0) dump_error(__LINE__,ret,"SemC::pthread_mutexattr_settype",&mutexattr);
+ ret = pthread_mutex_init(&p->_mutex,&mutexattr);
+ if (ret != 0) dump_error(__LINE__,ret,"SemC::pthread_mutexattr_init",&p->_mutex);
+ if (ret == 0)
+ {
+ ret = pthread_cond_init(&p->_cond,0);
+ if (ret != 0) dump_error(__LINE__,ret,"SemC::pthread_cond_init",&p->_mutex);
+ p->_count = initiallyCount;
+ p->_maxCount = maxCount;
+ p->_created = 1;
+ }
+ return ret;
+}
+
+WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount)
+{
+ int ret;
+ if (releaseCount < 1) return EINVAL;
+
+ ret = pthread_mutex_lock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"SemR::pthread_mutex_lock",&p->_mutex);
+ if (ret == 0)
+ {
+ UInt32 newCount = p->_count + releaseCount;
+ if (newCount > p->_maxCount)
+ {
+ ret = pthread_mutex_unlock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"SemR::pthread_mutex_unlock",&p->_mutex);
+ return EINVAL;
+ }
+ p->_count = newCount;
+ ret = pthread_cond_broadcast(&p->_cond);
+ if (ret != 0) dump_error(__LINE__,ret,"SemR::pthread_cond_broadcast",&p->_cond);
+ if (ret == 0)
+ {
+ ret = pthread_mutex_unlock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"SemR::pthread_mutex_unlock",&p->_mutex);
+ }
+ }
+ return ret;
+}
+
+WRes Semaphore_Wait(CSemaphore *p) {
+ int ret = pthread_mutex_lock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"SemW::pthread_mutex_lock",&p->_mutex);
+ if (ret == 0)
+ {
+ while ((p->_count < 1) && (ret == 0))
+ {
+ ret = pthread_cond_wait(&p->_cond, &p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"SemW::pthread_cond_wait",&p->_mutex);
+ }
+ if (ret == 0)
+ {
+ p->_count--;
+ ret = pthread_mutex_unlock(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"SemW::pthread_mutex_unlock",&p->_mutex);
+ }
+ }
+ return ret;
+}
+
+WRes Semaphore_Close(CSemaphore *p) {
+ if (p->_created)
+ {
+ int ret;
+ p->_created = 0;
+ ret = pthread_mutex_destroy(&p->_mutex);
+ if (ret != 0) dump_error(__LINE__,ret,"Semc::pthread_mutex_destroy",&p->_mutex);
+ ret = pthread_cond_destroy(&p->_cond);
+ if (ret != 0) dump_error(__LINE__,ret,"Semc::pthread_cond_destroy",&p->_cond);
+ }
+ return 0;
+}
+
+WRes CriticalSection_Init(CCriticalSection * lpCriticalSection)
+{
+ if (lpCriticalSection)
+ {
+ int ret;
+ pthread_mutexattr_t mutexattr;
+ memset(&mutexattr,0,sizeof(mutexattr));
+ ret = pthread_mutexattr_init(&mutexattr);
+ if (ret != 0) dump_error(__LINE__,ret,"CS I::pthread_mutexattr_init",&mutexattr);
+ ret = pthread_mutexattr_settype(&mutexattr,PTHREAD_MUTEX_ERRORCHECK);
+ if (ret != 0) dump_error(__LINE__,ret,"CS I::pthread_mutexattr_settype",&mutexattr);
+ ret = pthread_mutex_init(&lpCriticalSection->_mutex,&mutexattr);
+ if (ret != 0) dump_error(__LINE__,ret,"CS I::pthread_mutexattr_init",&lpCriticalSection->_mutex);
+ return ret;
+ }
+ return EINTR;
+}
+
+void CriticalSection_Enter(CCriticalSection * lpCriticalSection)
+{
+ if (lpCriticalSection)
+ {
+ int ret = pthread_mutex_lock(&(lpCriticalSection->_mutex));
+ if (ret != 0) dump_error(__LINE__,ret,"CS::pthread_mutex_lock",&(lpCriticalSection->_mutex));
+ }
+}
+
+void CriticalSection_Leave(CCriticalSection * lpCriticalSection)
+{
+ if (lpCriticalSection)
+ {
+ int ret = pthread_mutex_unlock(&(lpCriticalSection->_mutex));
+ if (ret != 0) dump_error(__LINE__,ret,"CS::pthread_mutex_unlock",&(lpCriticalSection->_mutex));
+ }
+}
+
+void CriticalSection_Delete(CCriticalSection * lpCriticalSection)
+{
+ if (lpCriticalSection)
+ {
+ int ret = pthread_mutex_destroy(&(lpCriticalSection->_mutex));
+ if (ret != 0) dump_error(__LINE__,ret,"CS::pthread_mutex_destroy",&(lpCriticalSection->_mutex));
+ }
+}
+
+#else
+
+WRes Event_Create(CEvent *p, BOOL manualReset, int initialSignaled)
+{
+ pthread_mutex_init(&p->_mutex,0);
+ pthread_cond_init(&p->_cond,0);
+ p->_manual_reset = manualReset;
+ p->_state = (initialSignaled ? TRUE : FALSE);
+ p->_created = 1;
+ return 0;
+}
+
+WRes Event_Set(CEvent *p) {
+ pthread_mutex_lock(&p->_mutex);
+ p->_state = TRUE;
+ pthread_cond_broadcast(&p->_cond);
+ pthread_mutex_unlock(&p->_mutex);
+ return 0;
+}
+
+WRes Event_Reset(CEvent *p) {
+ pthread_mutex_lock(&p->_mutex);
+ p->_state = FALSE;
+ pthread_mutex_unlock(&p->_mutex);
+ return 0;
+}
+
+WRes Event_Wait(CEvent *p) {
+ pthread_mutex_lock(&p->_mutex);
+ while (p->_state == FALSE)
+ {
+ pthread_cond_wait(&p->_cond, &p->_mutex);
+ }
+ if (p->_manual_reset == FALSE)
+ {
+ p->_state = FALSE;
+ }
+ pthread_mutex_unlock(&p->_mutex);
+ return 0;
+}
+
+WRes Event_Close(CEvent *p) {
+ if (p->_created)
+ {
+ p->_created = 0;
+ pthread_mutex_destroy(&p->_mutex);
+ pthread_cond_destroy(&p->_cond);
+ }
+ return 0;
+}
+
+WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount)
+{
+ pthread_mutex_init(&p->_mutex,0);
+ pthread_cond_init(&p->_cond,0);
+ p->_count = initiallyCount;
+ p->_maxCount = maxCount;
+ p->_created = 1;
+ return 0;
+}
+
+WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount)
+{
+ UInt32 newCount;
+
+ if (releaseCount < 1) return EINVAL;
+
+ pthread_mutex_lock(&p->_mutex);
+
+ newCount = p->_count + releaseCount;
+ if (newCount > p->_maxCount)
+ {
+ pthread_mutex_unlock(&p->_mutex);
+ return EINVAL;
+ }
+ p->_count = newCount;
+ pthread_cond_broadcast(&p->_cond);
+ pthread_mutex_unlock(&p->_mutex);
+ return 0;
+}
+
+WRes Semaphore_Wait(CSemaphore *p) {
+ pthread_mutex_lock(&p->_mutex);
+ while (p->_count < 1)
+ {
+ pthread_cond_wait(&p->_cond, &p->_mutex);
+ }
+ p->_count--;
+ pthread_mutex_unlock(&p->_mutex);
+ return 0;
+}
+
+WRes Semaphore_Close(CSemaphore *p) {
+ if (p->_created)
+ {
+ p->_created = 0;
+ pthread_mutex_destroy(&p->_mutex);
+ pthread_cond_destroy(&p->_cond);
+ }
+ return 0;
+}
+
+WRes CriticalSection_Init(CCriticalSection * lpCriticalSection)
+{
+ return pthread_mutex_init(&(lpCriticalSection->_mutex),0);
+}
+
+#endif /* DEBUG_SYNCHRO */
+
+#endif /* ENV_BEOS */
+
+WRes ManualResetEvent_Create(CManualResetEvent *p, int initialSignaled)
+ { return Event_Create(p, TRUE, initialSignaled); }
+
+WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p)
+ { return ManualResetEvent_Create(p, 0); }
+
+WRes AutoResetEvent_Create(CAutoResetEvent *p, int initialSignaled)
+ { return Event_Create(p, FALSE, initialSignaled); }
+WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p)
+ { return AutoResetEvent_Create(p, 0); }
+
+#else
+
+#include <process.h>
+
+static WRes GetError()
+{
+ DWORD res = GetLastError();
+ return (res) ? (WRes)(res) : 1;
+}
+
+WRes HandleToWRes(HANDLE h) { return (h != 0) ? 0 : GetError(); }
+WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); }
+
+static WRes MyCloseHandle(HANDLE *h)
+{
+ if (*h != NULL)
+ if (!CloseHandle(*h))
+ return GetError();
+ *h = NULL;
+ return 0;
+}
+
+WRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
+{
+ unsigned threadId; /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */
+ thread->handle =
+ /* CreateThread(0, 0, startAddress, parameter, 0, &threadId); */
+ (HANDLE)_beginthreadex(NULL, 0, startAddress, parameter, 0, &threadId);
+ /* maybe we must use errno here, but probably GetLastError() is also OK. */
+ return HandleToWRes(thread->handle);
+}
+
+WRes WaitObject(HANDLE h)
+{
+ return (WRes)WaitForSingleObject(h, INFINITE);
+}
+
+WRes Thread_Wait(CThread *thread)
+{
+ if (thread->handle == NULL)
+ return 1;
+ return WaitObject(thread->handle);
+}
+
+WRes Thread_Close(CThread *thread)
+{
+ return MyCloseHandle(&thread->handle);
+}
+
+WRes Event_Create(CEvent *p, BOOL manualReset, int initialSignaled)
+{
+ p->handle = CreateEvent(NULL, manualReset, (initialSignaled ? TRUE : FALSE), NULL);
+ return HandleToWRes(p->handle);
+}
+
+WRes ManualResetEvent_Create(CManualResetEvent *p, int initialSignaled)
+ { return Event_Create(p, TRUE, initialSignaled); }
+WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p)
+ { return ManualResetEvent_Create(p, 0); }
+
+WRes AutoResetEvent_Create(CAutoResetEvent *p, int initialSignaled)
+ { return Event_Create(p, FALSE, initialSignaled); }
+WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p)
+ { return AutoResetEvent_Create(p, 0); }
+
+WRes Event_Set(CEvent *p) { return BOOLToWRes(SetEvent(p->handle)); }
+WRes Event_Reset(CEvent *p) { return BOOLToWRes(ResetEvent(p->handle)); }
+WRes Event_Wait(CEvent *p) { return WaitObject(p->handle); }
+WRes Event_Close(CEvent *p) { return MyCloseHandle(&p->handle); }
+
+
+WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount)
+{
+ p->handle = CreateSemaphore(NULL, (LONG)initiallyCount, (LONG)maxCount, NULL);
+ return HandleToWRes(p->handle);
+}
+
+WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount)
+{
+ return BOOLToWRes(ReleaseSemaphore(p->handle, releaseCount, previousCount));
+}
+WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount)
+{
+ return Semaphore_Release(p, (LONG)releaseCount, NULL);
+}
+WRes Semaphore_Release1(CSemaphore *p)
+{
+ return Semaphore_ReleaseN(p, 1);
+}
+
+WRes Semaphore_Wait(CSemaphore *p) { return WaitObject(p->handle); }
+WRes Semaphore_Close(CSemaphore *p) { return MyCloseHandle(&p->handle); }
+
+WRes CriticalSection_Init(CCriticalSection *p)
+{
+ /* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */
+ __try
+ {
+ InitializeCriticalSection(p);
+ /* InitializeCriticalSectionAndSpinCount(p, 0); */
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER) { return 1; }
+ return 0;
+}
+
+
+#endif \ No newline at end of file
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Threads.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Threads.h
new file mode 100644
index 000000000..4215e403c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Threads.h
@@ -0,0 +1,196 @@
+/* Threads.h -- multithreading library
+2008-11-22 : Igor Pavlov : Public domain */
+
+#ifndef __7Z_THRESDS_H
+#define __7Z_THRESDS_H
+
+#ifdef ENV_UNIX
+
+#include "Types.h"
+#include "windows.h"
+
+#ifdef ENV_BEOS
+#include <kernel/OS.h>
+#define MAX_THREAD 256
+#else
+#include <pthread.h>
+#endif
+
+/* #define DEBUG_SYNCHRO 1 */
+
+typedef struct _CThread
+{
+#ifdef ENV_BEOS
+ thread_id _tid;
+#else
+ pthread_t _tid;
+#endif
+ int _created;
+
+} CThread;
+
+#define Thread_Construct(thread) (thread)->_created = 0
+#define Thread_WasCreated(thread) ((thread)->_created != 0)
+
+typedef unsigned THREAD_FUNC_RET_TYPE;
+#define THREAD_FUNC_CALL_TYPE MY_STD_CALL
+#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE
+
+typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *);
+
+WRes Thread_Create(CThread *thread, THREAD_FUNC_TYPE startAddress, LPVOID parameter);
+WRes Thread_Wait(CThread *thread);
+WRes Thread_Close(CThread *thread);
+
+typedef struct _CEvent
+{
+ int _created;
+ int _manual_reset;
+ int _state;
+#ifdef ENV_BEOS
+ thread_id _waiting[MAX_THREAD];
+ int _index_waiting;
+ sem_id _sem;
+#else
+ pthread_mutex_t _mutex;
+ pthread_cond_t _cond;
+#endif
+} CEvent;
+
+typedef CEvent CAutoResetEvent;
+typedef CEvent CManualResetEvent;
+
+#define Event_Construct(event) (event)->_created = 0
+#define Event_IsCreated(event) ((event)->_created)
+
+WRes ManualResetEvent_Create(CManualResetEvent *event, int initialSignaled);
+WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *event);
+WRes AutoResetEvent_Create(CAutoResetEvent *event, int initialSignaled);
+WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *event);
+WRes Event_Set(CEvent *event);
+WRes Event_Reset(CEvent *event);
+WRes Event_Wait(CEvent *event);
+WRes Event_Close(CEvent *event);
+
+
+typedef struct _CSemaphore
+{
+ int _created;
+ UInt32 _count;
+ UInt32 _maxCount;
+#ifdef ENV_BEOS
+ thread_id _waiting[MAX_THREAD];
+ int _index_waiting;
+ sem_id _sem;
+#else
+ pthread_mutex_t _mutex;
+ pthread_cond_t _cond;
+#endif
+} CSemaphore;
+
+#define Semaphore_Construct(p) (p)->_created = 0
+
+WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount);
+WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num);
+#define Semaphore_Release1(p) Semaphore_ReleaseN(p, 1)
+WRes Semaphore_Wait(CSemaphore *p);
+WRes Semaphore_Close(CSemaphore *p);
+
+typedef struct {
+#ifdef ENV_BEOS
+ sem_id _sem;
+#else
+ pthread_mutex_t _mutex;
+#endif
+} CCriticalSection;
+
+WRes CriticalSection_Init(CCriticalSection *p);
+#ifdef ENV_BEOS
+#define CriticalSection_Delete(p) delete_sem((p)->_sem)
+#define CriticalSection_Enter(p) acquire_sem((p)->_sem)
+#define CriticalSection_Leave(p) release_sem((p)->_sem)
+#else
+#ifdef DEBUG_SYNCHRO
+void CriticalSection_Delete(CCriticalSection *);
+void CriticalSection_Enter(CCriticalSection *);
+void CriticalSection_Leave(CCriticalSection *);
+#else
+#define CriticalSection_Delete(p) pthread_mutex_destroy(&((p)->_mutex))
+#define CriticalSection_Enter(p) pthread_mutex_lock(&((p)->_mutex))
+#define CriticalSection_Leave(p) pthread_mutex_unlock(&((p)->_mutex))
+#endif
+#endif
+
+#else
+
+#include "Types.h"
+
+typedef unsigned THREAD_FUNC_RET_TYPE;
+#define THREAD_FUNC_CALL_TYPE MY_STD_CALL
+#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE
+
+typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *);
+
+typedef struct _CThread
+{
+ HANDLE handle;
+} CThread;
+
+#define Thread_Construct(thread) (thread)->handle = NULL
+#define Thread_WasCreated(thread) ((thread)->handle != NULL)
+
+typedef unsigned THREAD_FUNC_RET_TYPE;
+#define THREAD_FUNC_CALL_TYPE MY_STD_CALL
+#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE
+
+WRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter);
+WRes Thread_Wait(CThread *thread);
+WRes Thread_Close(CThread *thread);
+
+typedef struct _CEvent
+{
+ HANDLE handle;
+} CEvent;
+
+typedef CEvent CAutoResetEvent;
+typedef CEvent CManualResetEvent;
+
+#define Event_Construct(event) (event)->handle = NULL
+#define Event_IsCreated(event) ((event)->handle != NULL)
+
+WRes ManualResetEvent_Create(CManualResetEvent *event, int initialSignaled);
+WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *event);
+WRes AutoResetEvent_Create(CAutoResetEvent *event, int initialSignaled);
+WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *event);
+WRes Event_Set(CEvent *event);
+WRes Event_Reset(CEvent *event);
+WRes Event_Wait(CEvent *event);
+WRes Event_Close(CEvent *event);
+
+
+typedef struct _CSemaphore
+{
+ HANDLE handle;
+} CSemaphore;
+
+#define Semaphore_Construct(p) (p)->handle = NULL
+
+WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount);
+WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num);
+WRes Semaphore_Release1(CSemaphore *p);
+WRes Semaphore_Wait(CSemaphore *p);
+WRes Semaphore_Close(CSemaphore *p);
+
+
+typedef CRITICAL_SECTION CCriticalSection;
+
+WRes CriticalSection_Init(CCriticalSection *p);
+#define CriticalSection_Delete(p) DeleteCriticalSection(p)
+#define CriticalSection_Enter(p) EnterCriticalSection(p)
+#define CriticalSection_Leave(p) LeaveCriticalSection(p)
+
+
+#endif
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Types.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Types.h
new file mode 100644
index 000000000..9af877ff8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Types.h
@@ -0,0 +1,216 @@
+/* Types.h -- Basic types
+2009-02-07 : Igor Pavlov : Public domain */
+
+#ifndef __7Z_TYPES_H
+#define __7Z_TYPES_H
+
+#include <stddef.h>
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SZ_OK 0
+
+#define SZ_ERROR_DATA 1
+#define SZ_ERROR_MEM 2
+#define SZ_ERROR_CRC 3
+#define SZ_ERROR_UNSUPPORTED 4
+#define SZ_ERROR_PARAM 5
+#define SZ_ERROR_INPUT_EOF 6
+#define SZ_ERROR_OUTPUT_EOF 7
+#define SZ_ERROR_READ 8
+#define SZ_ERROR_WRITE 9
+#define SZ_ERROR_PROGRESS 10
+#define SZ_ERROR_FAIL 11
+#define SZ_ERROR_THREAD 12
+
+#define SZ_ERROR_ARCHIVE 16
+#define SZ_ERROR_NO_ARCHIVE 17
+
+typedef int SRes;
+
+#ifdef _WIN32
+typedef DWORD WRes;
+#else
+typedef int WRes;
+#endif
+
+#ifndef RINOK
+#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
+#endif
+
+typedef unsigned char Byte;
+typedef short Int16;
+typedef unsigned short UInt16;
+
+#ifdef _LZMA_UINT32_IS_ULONG
+typedef long Int32;
+typedef unsigned long UInt32;
+#else
+typedef int Int32;
+typedef unsigned int UInt32;
+#endif
+
+#ifdef _SZ_NO_INT_64
+
+/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
+ NOTES: Some code will work incorrectly in that case! */
+
+typedef long Int64;
+typedef unsigned long UInt64;
+
+#else
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+typedef __int64 Int64;
+typedef unsigned __int64 UInt64;
+#else
+typedef long long int Int64;
+typedef unsigned long long int UInt64;
+#endif
+
+#endif
+
+#ifdef _LZMA_NO_SYSTEM_SIZE_T
+typedef UInt32 SizeT;
+#else
+typedef size_t SizeT;
+#endif
+
+typedef int Bool;
+#define True 1
+#define False 0
+
+
+#ifdef _MSC_VER
+
+#if _MSC_VER >= 1300
+#define MY_NO_INLINE __declspec(noinline)
+#else
+#define MY_NO_INLINE
+#endif
+
+#define MY_CDECL __cdecl
+#define MY_STD_CALL __stdcall
+#define MY_FAST_CALL MY_NO_INLINE __fastcall
+
+#else
+
+#define MY_CDECL
+#define MY_STD_CALL
+#define MY_FAST_CALL
+
+#endif
+
+
+/* The following interfaces use first parameter as pointer to structure */
+
+typedef struct
+{
+ SRes (*Read)(void *p, void *buf, size_t *size);
+ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
+ (output(*size) < input(*size)) is allowed */
+} ISeqInStream;
+
+/* it can return SZ_ERROR_INPUT_EOF */
+SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
+SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
+SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
+
+typedef struct
+{
+ size_t (*Write)(void *p, const void *buf, size_t size);
+ /* Returns: result - the number of actually written bytes.
+ (result < size) means error */
+} ISeqOutStream;
+
+typedef enum
+{
+ SZ_SEEK_SET = 0,
+ SZ_SEEK_CUR = 1,
+ SZ_SEEK_END = 2
+} ESzSeek;
+
+typedef struct
+{
+ SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
+ SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
+} ISeekInStream;
+
+typedef struct
+{
+ SRes (*Look)(void *p, void **buf, size_t *size);
+ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
+ (output(*size) > input(*size)) is not allowed
+ (output(*size) < input(*size)) is allowed */
+ SRes (*Skip)(void *p, size_t offset);
+ /* offset must be <= output(*size) of Look */
+
+ SRes (*Read)(void *p, void *buf, size_t *size);
+ /* reads directly (without buffer). It's same as ISeqInStream::Read */
+ SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
+} ILookInStream;
+
+SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
+SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
+
+/* reads via ILookInStream::Read */
+SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
+SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
+
+#define LookToRead_BUF_SIZE (1 << 14)
+
+typedef struct
+{
+ ILookInStream s;
+ ISeekInStream *realStream;
+ size_t pos;
+ size_t size;
+ Byte buf[LookToRead_BUF_SIZE];
+} CLookToRead;
+
+void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
+void LookToRead_Init(CLookToRead *p);
+
+typedef struct
+{
+ ISeqInStream s;
+ ILookInStream *realStream;
+} CSecToLook;
+
+void SecToLook_CreateVTable(CSecToLook *p);
+
+typedef struct
+{
+ ISeqInStream s;
+ ILookInStream *realStream;
+} CSecToRead;
+
+void SecToRead_CreateVTable(CSecToRead *p);
+
+typedef struct
+{
+ SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
+ /* Returns: result. (result != SZ_OK) means break.
+ Value (UInt64)(Int64)-1 for size means unknown value. */
+} ICompressProgress;
+
+typedef struct
+{
+ void *(*Alloc)(void *p, size_t size);
+ void (*Free)(void *p, void *address); /* address can be 0 */
+} ISzAlloc;
+
+#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
+#define IAlloc_Free(p, a) (p)->Free((p), a)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Xz.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Xz.c
new file mode 100644
index 000000000..18caba2c1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Xz.c
@@ -0,0 +1,88 @@
+/* Xz.c - Xz
+2009-04-15 : Igor Pavlov : Public domain */
+
+#include "7zCrc.h"
+#include "CpuArch.h"
+#include "Xz.h"
+#include "XzCrc64.h"
+
+Byte XZ_SIG[XZ_SIG_SIZE] = { 0xFD, '7', 'z', 'X', 'Z', 0 };
+Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE] = { 'Y', 'Z' };
+
+unsigned Xz_WriteVarInt(Byte *buf, UInt64 v)
+{
+ unsigned i = 0;
+ do
+ {
+ buf[i++] = (Byte)((v & 0x7F) | 0x80);
+ v >>= 7;
+ }
+ while (v != 0);
+ buf[i - 1] &= 0x7F;
+ return i;
+}
+
+void Xz_Construct(CXzStream *p)
+{
+ p->numBlocks = p->numBlocksAllocated = 0;
+ p->blocks = 0;
+ p->flags = 0;
+}
+
+void Xz_Free(CXzStream *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->blocks);
+ p->numBlocks = p->numBlocksAllocated = 0;
+ p->blocks = 0;
+}
+
+unsigned XzFlags_GetCheckSize(CXzStreamFlags f)
+{
+ int t = XzFlags_GetCheckType(f);
+ return (t == 0) ? 0 : (4 << ((t - 1) / 3));
+}
+
+void XzCheck_Init(CXzCheck *p, int mode)
+{
+ p->mode = mode;
+ switch (mode)
+ {
+ case XZ_CHECK_CRC32: p->crc = CRC_INIT_VAL; break;
+ case XZ_CHECK_CRC64: p->crc64 = CRC64_INIT_VAL; break;
+ case XZ_CHECK_SHA256: Sha256_Init(&p->sha); break;
+ }
+}
+
+void XzCheck_Update(CXzCheck *p, const void *data, size_t size)
+{
+ switch (p->mode)
+ {
+ case XZ_CHECK_CRC32: p->crc = CrcUpdate(p->crc, data, size); break;
+ case XZ_CHECK_CRC64: p->crc64 = Crc64Update(p->crc64, data, size); break;
+ case XZ_CHECK_SHA256: Sha256_Update(&p->sha, (const Byte *)data, size); break;
+ }
+}
+
+int XzCheck_Final(CXzCheck *p, Byte *digest)
+{
+ switch (p->mode)
+ {
+ case XZ_CHECK_CRC32:
+ SetUi32(digest, CRC_GET_DIGEST(p->crc));
+ break;
+ case XZ_CHECK_CRC64:
+ {
+ int i;
+ UInt64 v = CRC64_GET_DIGEST(p->crc64);
+ for (i = 0; i < 8; i++, v >>= 8)
+ digest[i] = (Byte)(v & 0xFF);
+ break;
+ }
+ case XZ_CHECK_SHA256:
+ Sha256_Final(&p->sha, digest);
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Xz.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Xz.h
new file mode 100644
index 000000000..65c44d265
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/Xz.h
@@ -0,0 +1,256 @@
+/* Xz.h - Xz interface
+2009-04-15 : Igor Pavlov : Public domain */
+
+#ifndef __XZ_H
+#define __XZ_H
+
+#include "Sha256.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define XZ_ID_Subblock 1
+#define XZ_ID_Delta 3
+#define XZ_ID_X86 4
+#define XZ_ID_PPC 5
+#define XZ_ID_IA64 6
+#define XZ_ID_ARM 7
+#define XZ_ID_ARMT 8
+#define XZ_ID_SPARC 9
+#define XZ_ID_LZMA2 0x21
+
+unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value);
+unsigned Xz_WriteVarInt(Byte *buf, UInt64 v);
+
+/* ---------- xz block ---------- */
+
+#define XZ_BLOCK_HEADER_SIZE_MAX 1024
+
+#define XZ_NUM_FILTERS_MAX 4
+#define XZ_BF_NUM_FILTERS_MASK 3
+#define XZ_BF_PACK_SIZE (1 << 6)
+#define XZ_BF_UNPACK_SIZE (1 << 7)
+
+#define XZ_FILTER_PROPS_SIZE_MAX 20
+
+typedef struct
+{
+ UInt64 id;
+ UInt32 propsSize;
+ Byte props[XZ_FILTER_PROPS_SIZE_MAX];
+} CXzFilter;
+
+typedef struct
+{
+ UInt64 packSize;
+ UInt64 unpackSize;
+ Byte flags;
+ CXzFilter filters[XZ_NUM_FILTERS_MAX];
+} CXzBlock;
+
+#define XzBlock_GetNumFilters(p) (((p)->flags & XZ_BF_NUM_FILTERS_MASK) + 1)
+#define XzBlock_HasPackSize(p) (((p)->flags & XZ_BF_PACK_SIZE) != 0)
+#define XzBlock_HasUnpackSize(p) (((p)->flags & XZ_BF_UNPACK_SIZE) != 0)
+
+SRes XzBlock_Parse(CXzBlock *p, const Byte *header);
+SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, Bool *isIndex, UInt32 *headerSizeRes);
+
+/* ---------- xz stream ---------- */
+
+#define XZ_SIG_SIZE 6
+#define XZ_FOOTER_SIG_SIZE 2
+
+extern Byte XZ_SIG[XZ_SIG_SIZE];
+extern Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE];
+
+#define XZ_STREAM_FLAGS_SIZE 2
+#define XZ_STREAM_CRC_SIZE 4
+
+#define XZ_STREAM_HEADER_SIZE (XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE + XZ_STREAM_CRC_SIZE)
+#define XZ_STREAM_FOOTER_SIZE (XZ_FOOTER_SIG_SIZE + XZ_STREAM_FLAGS_SIZE + XZ_STREAM_CRC_SIZE + 4)
+
+#define XZ_CHECK_MASK 0xF
+#define XZ_CHECK_NO 0
+#define XZ_CHECK_CRC32 1
+#define XZ_CHECK_CRC64 4
+#define XZ_CHECK_SHA256 10
+
+typedef struct
+{
+ int mode;
+ UInt32 crc;
+ UInt64 crc64;
+ CSha256 sha;
+} CXzCheck;
+
+void XzCheck_Init(CXzCheck *p, int mode);
+void XzCheck_Update(CXzCheck *p, const void *data, size_t size);
+int XzCheck_Final(CXzCheck *p, Byte *digest);
+
+typedef UInt16 CXzStreamFlags;
+
+#define XzFlags_IsSupported(f) ((f) <= XZ_CHECK_MASK)
+#define XzFlags_GetCheckType(f) ((f) & XZ_CHECK_MASK)
+#define XzFlags_HasDataCrc32(f) (Xz_GetCheckType(f) == XZ_CHECK_CRC32)
+unsigned XzFlags_GetCheckSize(CXzStreamFlags f);
+
+SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf);
+SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream);
+
+typedef struct
+{
+ UInt64 unpackSize;
+ UInt64 totalSize;
+} CXzBlockSizes;
+
+typedef struct
+{
+ CXzStreamFlags flags;
+ size_t numBlocks;
+ size_t numBlocksAllocated;
+ CXzBlockSizes *blocks;
+ UInt64 startOffset;
+} CXzStream;
+
+void Xz_Construct(CXzStream *p);
+void Xz_Free(CXzStream *p, ISzAlloc *alloc);
+
+#define XZ_SIZE_OVERFLOW ((UInt64)(Int64)-1)
+
+UInt64 Xz_GetUnpackSize(const CXzStream *p);
+UInt64 Xz_GetPackSize(const CXzStream *p);
+
+typedef struct
+{
+ size_t num;
+ size_t numAllocated;
+ CXzStream *streams;
+} CXzs;
+
+void Xzs_Construct(CXzs *p);
+void Xzs_Free(CXzs *p, ISzAlloc *alloc);
+SRes Xzs_ReadBackward(CXzs *p, ILookInStream *inStream, Int64 *startOffset, ICompressProgress *progress, ISzAlloc *alloc);
+
+UInt64 Xzs_GetNumBlocks(const CXzs *p);
+UInt64 Xzs_GetUnpackSize(const CXzs *p);
+
+typedef enum
+{
+ CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */
+ CODER_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
+ CODER_STATUS_NOT_FINISHED, /* stream was not finished */
+ CODER_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
+} ECoderStatus;
+
+typedef enum
+{
+ CODER_FINISH_ANY, /* finish at any point */
+ CODER_FINISH_END /* block must be finished at the end */
+} ECoderFinishMode;
+
+typedef struct _IStateCoder
+{
+ void *p;
+ void (*Free)(void *p, ISzAlloc *alloc);
+ SRes (*SetProps)(void *p, const Byte *props, size_t propSize, ISzAlloc *alloc);
+ void (*Init)(void *p);
+ SRes (*Code)(void *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished);
+} IStateCoder;
+
+#define MIXCODER_NUM_FILTERS_MAX 4
+
+typedef struct
+{
+ ISzAlloc *alloc;
+ Byte *buf;
+ int numCoders;
+ int finished[MIXCODER_NUM_FILTERS_MAX - 1];
+ size_t pos[MIXCODER_NUM_FILTERS_MAX - 1];
+ size_t size[MIXCODER_NUM_FILTERS_MAX - 1];
+ UInt64 ids[MIXCODER_NUM_FILTERS_MAX];
+ IStateCoder coders[MIXCODER_NUM_FILTERS_MAX];
+} CMixCoder;
+
+void MixCoder_Construct(CMixCoder *p, ISzAlloc *alloc);
+void MixCoder_Free(CMixCoder *p);
+void MixCoder_Init(CMixCoder *p);
+SRes MixCoder_SetFromMethod(CMixCoder *p, int coderIndex, UInt64 methodId);
+SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
+ const Byte *src, SizeT *srcLen, int srcWasFinished,
+ ECoderFinishMode finishMode, ECoderStatus *status);
+
+typedef enum
+{
+ XZ_STATE_STREAM_HEADER,
+ XZ_STATE_STREAM_INDEX,
+ XZ_STATE_STREAM_INDEX_CRC,
+ XZ_STATE_STREAM_FOOTER,
+ XZ_STATE_STREAM_PADDING,
+ XZ_STATE_BLOCK_HEADER,
+ XZ_STATE_BLOCK,
+ XZ_STATE_BLOCK_FOOTER
+} EXzState;
+
+typedef struct
+{
+ EXzState state;
+ UInt32 pos;
+ unsigned alignPos;
+ unsigned indexPreSize;
+
+ CXzStreamFlags streamFlags;
+
+ UInt32 blockHeaderSize;
+ UInt64 packSize;
+ UInt64 unpackSize;
+
+ UInt64 numBlocks;
+ UInt64 indexSize;
+ UInt64 indexPos;
+ UInt64 padSize;
+
+ UInt64 numStreams;
+
+ UInt32 crc;
+ CMixCoder decoder;
+ CXzBlock block;
+ CXzCheck check;
+ CSha256 sha;
+ Byte shaDigest[SHA256_DIGEST_SIZE];
+ Byte buf[XZ_BLOCK_HEADER_SIZE_MAX];
+} CXzUnpacker;
+
+SRes XzUnpacker_Create(CXzUnpacker *p, ISzAlloc *alloc);
+void XzUnpacker_Free(CXzUnpacker *p);
+
+/*
+finishMode:
+ It has meaning only if the decoding reaches output limit (*destLen).
+ LZMA_FINISH_ANY - use smallest number of input bytes
+ LZMA_FINISH_END - read EndOfStream marker after decoding
+
+Returns:
+ SZ_OK
+ status:
+ LZMA_STATUS_FINISHED_WITH_MARK
+ LZMA_STATUS_NOT_FINISHED
+ SZ_ERROR_DATA - Data error
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_UNSUPPORTED - Unsupported properties
+ SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
+*/
+
+
+SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
+ const Byte *src, SizeT *srcLen, /* int srcWasFinished, */ int finishMode,
+ ECoderStatus *status);
+
+Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzCrc64.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzCrc64.c
new file mode 100644
index 000000000..fcd3d8156
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzCrc64.c
@@ -0,0 +1,33 @@
+/* XzCrc64.c -- CRC64 calculation
+2009-04-15 : Igor Pavlov : Public domain */
+
+#include "XzCrc64.h"
+
+#define kCrc64Poly 0xC96C5795D7870F42ULL
+UInt64 g_Crc64Table[256];
+
+void MY_FAST_CALL Crc64GenerateTable(void)
+{
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ {
+ UInt64 r = i;
+ int j;
+ for (j = 0; j < 8; j++)
+ r = (r >> 1) ^ ((UInt64)kCrc64Poly & ~((r & 1) - 1));
+ g_Crc64Table[i] = r;
+ }
+}
+
+UInt64 MY_FAST_CALL Crc64Update(UInt64 v, const void *data, size_t size)
+{
+ const Byte *p = (const Byte *)data;
+ for (; size > 0 ; size--, p++)
+ v = CRC64_UPDATE_BYTE(v, *p);
+ return v;
+}
+
+UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size)
+{
+ return CRC64_GET_DIGEST(Crc64Update(CRC64_INIT_VAL, data, size));
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzCrc64.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzCrc64.h
new file mode 100644
index 000000000..a30af4407
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzCrc64.h
@@ -0,0 +1,30 @@
+/* XzCrc64.c -- CRC64 calculation
+2009-04-15 : Igor Pavlov : Public domain */
+
+#ifndef __XZ_CRC64_H
+#define __XZ_CRC64_H
+
+#include <stddef.h>
+
+#include "Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern UInt64 g_Crc64Table[];
+
+void MY_FAST_CALL Crc64GenerateTable(void);
+
+#define CRC64_INIT_VAL 0xFFFFFFFFFFFFFFFFLL
+#define CRC64_GET_DIGEST(crc) ((crc) ^ 0xFFFFFFFFFFFFFFFFLL)
+#define CRC64_UPDATE_BYTE(crc, b) (g_Crc64Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
+
+UInt64 MY_FAST_CALL Crc64Update(UInt64 crc, const void *data, size_t size);
+UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzDec.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzDec.c
new file mode 100644
index 000000000..2f2d58d76
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzDec.c
@@ -0,0 +1,875 @@
+/* XzDec.c -- Xz Decode
+2009-05-29 : Igor Pavlov : Public domain */
+
+/* #define XZ_DUMP */
+
+#ifdef XZ_DUMP
+#include <stdio.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "7zCrc.h"
+#include "Alloc.h"
+#include "Bra.h"
+#include "CpuArch.h"
+#include "Delta.h"
+#include "Lzma2Dec.h"
+
+#ifdef USE_SUBBLOCK
+#include "SbDec.h"
+#endif
+
+#include "Xz.h"
+
+#define XZ_CHECK_SIZE_MAX 64
+
+#define CODER_BUF_SIZE (1 << 17)
+
+unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value)
+{
+ int i, limit;
+ *value = 0;
+ limit = (maxSize > 9) ? 9 : (int)maxSize;
+
+ for (i = 0; i < limit;)
+ {
+ Byte b = p[i];
+ *value |= (UInt64)(b & 0x7F) << (7 * i++);
+ if ((b & 0x80) == 0)
+ return (b == 0 && i != 1) ? 0 : i;
+ }
+ return 0;
+}
+
+/* ---------- BraState ---------- */
+
+#define BRA_BUF_SIZE (1 << 14)
+
+typedef struct
+{
+ size_t bufPos;
+ size_t bufConv;
+ size_t bufTotal;
+
+ UInt32 methodId;
+ int encodeMode;
+ UInt32 delta;
+ UInt32 ip;
+ UInt32 x86State;
+ Byte deltaState[DELTA_STATE_SIZE];
+
+ Byte buf[BRA_BUF_SIZE];
+} CBraState;
+
+void BraState_Free(void *pp, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, pp);
+}
+
+SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
+{
+ CBraState *p = ((CBraState *)pp);
+ alloc = alloc;
+ p->encodeMode = 0;
+ p->ip = 0;
+ if (p->methodId == XZ_ID_Delta)
+ {
+ if (propSize != 1)
+ return SZ_ERROR_UNSUPPORTED;
+ p->delta = (unsigned)props[0] + 1;
+ }
+ else
+ {
+ if (propSize == 4)
+ {
+ UInt32 v = GetUi32(props);
+ switch(p->methodId)
+ {
+ case XZ_ID_PPC:
+ case XZ_ID_ARM:
+ case XZ_ID_SPARC:
+ if ((v & 3) != 0)
+ return SZ_ERROR_UNSUPPORTED;
+ break;
+ case XZ_ID_ARMT:
+ if ((v & 1) != 0)
+ return SZ_ERROR_UNSUPPORTED;
+ break;
+ case XZ_ID_IA64:
+ if ((v & 0xF) != 0)
+ return SZ_ERROR_UNSUPPORTED;
+ break;
+ }
+ p->ip = v;
+ }
+ else if (propSize != 0)
+ return SZ_ERROR_UNSUPPORTED;
+ }
+ return SZ_OK;
+}
+
+void BraState_Init(void *pp)
+{
+ CBraState *p = ((CBraState *)pp);
+ p->bufPos = p->bufConv = p->bufTotal = 0;
+ x86_Convert_Init(p->x86State);
+ if (p->methodId == XZ_ID_Delta)
+ Delta_Init(p->deltaState);
+}
+
+#define CASE_BRA_CONV(isa) case XZ_ID_ ## isa: p->bufConv = isa ## _Convert(p->buf, p->bufTotal, p->ip, p->encodeMode); break;
+
+static SRes BraState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)
+{
+ CBraState *p = ((CBraState *)pp);
+ SizeT destLenOrig = *destLen;
+ SizeT srcLenOrig = *srcLen;
+ *destLen = 0;
+ *srcLen = 0;
+ finishMode = finishMode;
+ *wasFinished = 0;
+ while (destLenOrig > 0)
+ {
+ if (p->bufPos != p->bufConv)
+ {
+ size_t curSize = p->bufConv - p->bufPos;
+ if (curSize > destLenOrig)
+ curSize = destLenOrig;
+ memcpy(dest, p->buf + p->bufPos, curSize);
+ p->bufPos += curSize;
+ *destLen += curSize;
+ dest += curSize;
+ destLenOrig -= curSize;
+ continue;
+ }
+ p->bufTotal -= p->bufPos;
+ memmove(p->buf, p->buf + p->bufPos, p->bufTotal);
+ p->bufPos = 0;
+ p->bufConv = 0;
+ {
+ size_t curSize = BRA_BUF_SIZE - p->bufTotal;
+ if (curSize > srcLenOrig)
+ curSize = srcLenOrig;
+ memcpy(p->buf + p->bufTotal, src, curSize);
+ *srcLen += curSize;
+ src += curSize;
+ srcLenOrig -= curSize;
+ p->bufTotal += curSize;
+ }
+ if (p->bufTotal == 0)
+ break;
+ switch(p->methodId)
+ {
+ case XZ_ID_Delta:
+ if (p->encodeMode)
+ Delta_Encode(p->deltaState, p->delta, p->buf, p->bufTotal);
+ else
+ Delta_Decode(p->deltaState, p->delta, p->buf, p->bufTotal);
+ p->bufConv = p->bufTotal;
+ break;
+ case XZ_ID_X86:
+ p->bufConv = x86_Convert(p->buf, p->bufTotal, p->ip, &p->x86State, p->encodeMode);
+ break;
+ CASE_BRA_CONV(PPC)
+ CASE_BRA_CONV(IA64)
+ CASE_BRA_CONV(ARM)
+ CASE_BRA_CONV(ARMT)
+ CASE_BRA_CONV(SPARC)
+ default:
+ return SZ_ERROR_UNSUPPORTED;
+ }
+ p->ip += (UInt32)p->bufConv;
+
+ if (p->bufConv == 0)
+ {
+ if (!srcWasFinished)
+ break;
+ p->bufConv = p->bufTotal;
+ }
+ }
+ if (p->bufTotal == p->bufPos && srcLenOrig == 0 && srcWasFinished)
+ *wasFinished = 1;
+ return SZ_OK;
+}
+
+SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, ISzAlloc *alloc)
+{
+ CBraState *decoder;
+ if (id != XZ_ID_Delta &&
+ id != XZ_ID_X86 &&
+ id != XZ_ID_PPC &&
+ id != XZ_ID_IA64 &&
+ id != XZ_ID_ARM &&
+ id != XZ_ID_ARMT &&
+ id != XZ_ID_SPARC)
+ return SZ_ERROR_UNSUPPORTED;
+ p->p = 0;
+ decoder = alloc->Alloc(alloc, sizeof(CBraState));
+ if (decoder == 0)
+ return SZ_ERROR_MEM;
+ decoder->methodId = (UInt32)id;
+ p->p = decoder;
+ p->Free = BraState_Free;
+ p->SetProps = BraState_SetProps;
+ p->Init = BraState_Init;
+ p->Code = BraState_Code;
+ return SZ_OK;
+}
+
+/* ---------- SbState ---------- */
+
+#ifdef USE_SUBBLOCK
+
+static void SbState_Free(void *pp, ISzAlloc *alloc)
+{
+ CSubblockDec *p = (CSubblockDec *)pp;
+ SubblockDec_Free(p, alloc);
+ alloc->Free(alloc, pp);
+}
+
+static SRes SbState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
+{
+ pp = pp;
+ props = props;
+ alloc = alloc;
+ return (propSize == 0) ? SZ_OK : SZ_ERROR_UNSUPPORTED;
+}
+
+static void SbState_Init(void *pp)
+{
+ SubblockDec_Init((CSubblockDec *)pp);
+}
+
+static SRes SbState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)
+{
+ ECoderStatus status;
+ SRes res = SubblockDec_Decode((CSubblockDec *)pp, dest, destLen, src, srcLen, finishMode, &status);
+ srcWasFinished = srcWasFinished;
+ *wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
+ return res;
+}
+
+SRes SbState_SetFromMethod(IStateCoder *p, ISzAlloc *alloc)
+{
+ CSubblockDec *decoder;
+ p->p = 0;
+ decoder = alloc->Alloc(alloc, sizeof(CSubblockDec));
+ if (decoder == 0)
+ return SZ_ERROR_MEM;
+ p->p = decoder;
+ p->Free = SbState_Free;
+ p->SetProps = SbState_SetProps;
+ p->Init = SbState_Init;
+ p->Code = SbState_Code;
+ SubblockDec_Construct(decoder);
+ return SZ_OK;
+}
+#endif
+
+/* ---------- Lzma2State ---------- */
+
+static void Lzma2State_Free(void *pp, ISzAlloc *alloc)
+{
+ Lzma2Dec_Free((CLzma2Dec *)pp, alloc);
+ alloc->Free(alloc, pp);
+}
+
+static SRes Lzma2State_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
+{
+ if (propSize != 1)
+ return SZ_ERROR_UNSUPPORTED;
+ return Lzma2Dec_Allocate((CLzma2Dec *)pp, props[0], alloc);
+}
+
+static void Lzma2State_Init(void *pp)
+{
+ Lzma2Dec_Init((CLzma2Dec *)pp);
+}
+
+static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ //int srcWasFinished, ELzmaFinishMode finishMode, int *wasFinished)
+ int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)
+{
+ ELzmaStatus status;
+ SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, finishMode, &status);
+ srcWasFinished = srcWasFinished;
+ *wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
+ return res;
+}
+
+static SRes Lzma2State_SetFromMethod(IStateCoder *p, ISzAlloc *alloc)
+{
+ CLzma2Dec *decoder = alloc->Alloc(alloc, sizeof(CLzma2Dec));
+ p->p = decoder;
+ if (decoder == 0)
+ return SZ_ERROR_MEM;
+ p->Free = Lzma2State_Free;
+ p->SetProps = Lzma2State_SetProps;
+ p->Init = Lzma2State_Init;
+ p->Code = Lzma2State_Code;
+ Lzma2Dec_Construct(decoder);
+ return SZ_OK;
+}
+
+
+void MixCoder_Construct(CMixCoder *p, ISzAlloc *alloc)
+{
+ int i;
+ p->alloc = alloc;
+ p->buf = 0;
+ p->numCoders = 0;
+ for (i = 0; i < MIXCODER_NUM_FILTERS_MAX; i++)
+ p->coders[i].p = NULL;
+}
+
+void MixCoder_Free(CMixCoder *p)
+{
+ int i;
+ for (i = 0; i < p->numCoders; i++)
+ {
+ IStateCoder *sc = &p->coders[i];
+ if (p->alloc && sc->p)
+ sc->Free(sc->p, p->alloc);
+ }
+ p->numCoders = 0;
+ if (p->buf)
+ p->alloc->Free(p->alloc, p->buf);
+}
+
+void MixCoder_Init(CMixCoder *p)
+{
+ int i;
+ for (i = 0; i < p->numCoders - 1; i++)
+ {
+ p->size[i] = 0;
+ p->pos[i] = 0;
+ p->finished[i] = 0;
+ }
+ for (i = 0; i < p->numCoders; i++)
+ {
+ IStateCoder *coder = &p->coders[i];
+ coder->Init(coder->p);
+ }
+}
+
+SRes MixCoder_SetFromMethod(CMixCoder *p, int coderIndex, UInt64 methodId)
+{
+ IStateCoder *sc = &p->coders[coderIndex];
+ p->ids[coderIndex] = methodId;
+ switch(methodId)
+ {
+ case XZ_ID_LZMA2: return Lzma2State_SetFromMethod(sc, p->alloc);
+ #ifdef USE_SUBBLOCK
+ case XZ_ID_Subblock: return SbState_SetFromMethod(sc, p->alloc);
+ #endif
+ }
+ if (coderIndex == 0)
+ return SZ_ERROR_UNSUPPORTED;
+ return BraState_SetFromMethod(sc, methodId, p->alloc);
+}
+
+SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
+ const Byte *src, SizeT *srcLen, int srcWasFinished,
+ ECoderFinishMode finishMode, ECoderStatus *status) /* FIXME ELzmaFinishMode <-> ECoderFinishMode */
+{
+ SizeT destLenOrig = *destLen;
+ SizeT srcLenOrig = *srcLen;
+ Bool allFinished = True;
+ *destLen = 0;
+ *srcLen = 0;
+ *status = CODER_STATUS_NOT_FINISHED;
+
+ if (p->buf == 0)
+ {
+ p->buf = p->alloc->Alloc(p->alloc, CODER_BUF_SIZE * (MIXCODER_NUM_FILTERS_MAX - 1));
+ if (p->buf == 0)
+ return SZ_ERROR_MEM;
+ }
+
+ if (p->numCoders != 1)
+ finishMode = CODER_FINISH_ANY;
+
+ for (;;)
+ {
+ Bool processed = False;
+ int i;
+ /*
+ if (p->numCoders == 1 && *destLen == destLenOrig && finishMode == LZMA_FINISH_ANY)
+ break;
+ */
+
+ for (i = 0; i < p->numCoders; i++)
+ {
+ SRes res;
+ IStateCoder *coder = &p->coders[i];
+ Byte *destCur;
+ SizeT destLenCur, srcLenCur;
+ const Byte *srcCur;
+ int srcFinishedCur;
+ int encodingWasFinished;
+
+ if (i == 0)
+ {
+ srcCur = src;
+ srcLenCur = srcLenOrig - *srcLen;
+ srcFinishedCur = srcWasFinished;
+ }
+ else
+ {
+ srcCur = p->buf + (CODER_BUF_SIZE * (i - 1)) + p->pos[i - 1];
+ srcLenCur = p->size[i - 1] - p->pos[i - 1];
+ srcFinishedCur = p->finished[i - 1];
+ }
+
+ if (i == p->numCoders - 1)
+ {
+ destCur = dest;
+ destLenCur = destLenOrig - *destLen;
+ }
+ else
+ {
+ if (p->pos[i] != p->size[i])
+ continue;
+ destCur = p->buf + (CODER_BUF_SIZE * i);
+ destLenCur = CODER_BUF_SIZE;
+ }
+
+ res = coder->Code(coder->p, destCur, &destLenCur, srcCur, &srcLenCur, srcFinishedCur, finishMode, &encodingWasFinished);
+
+ if (!encodingWasFinished)
+ allFinished = False;
+
+ if (i == 0)
+ {
+ *srcLen += srcLenCur;
+ src += srcLenCur;
+ }
+ else
+ {
+ p->pos[i - 1] += srcLenCur;
+ }
+
+ if (i == p->numCoders - 1)
+ {
+ *destLen += destLenCur;
+ dest += destLenCur;
+ }
+ else
+ {
+ p->size[i] = destLenCur;
+ p->pos[i] = 0;
+ p->finished[i] = encodingWasFinished;
+ }
+
+ if (res != SZ_OK)
+ return res;
+
+ if (destLenCur != 0 || srcLenCur != 0)
+ processed = True;
+ }
+ if (!processed)
+ break;
+ }
+ if (allFinished)
+ *status = CODER_STATUS_FINISHED_WITH_MARK;
+ return SZ_OK;
+}
+
+SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf)
+{
+ *p = (CXzStreamFlags)GetBe16(buf + XZ_SIG_SIZE);
+ if (CrcCalc(buf + XZ_SIG_SIZE, XZ_STREAM_FLAGS_SIZE) !=
+ GetUi32(buf + XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE))
+ return SZ_ERROR_NO_ARCHIVE;
+ return XzFlags_IsSupported(*p) ? SZ_OK : SZ_ERROR_UNSUPPORTED;
+}
+
+static Bool Xz_CheckFooter(CXzStreamFlags flags, UInt64 indexSize, const Byte *buf)
+{
+ return
+ indexSize == (((UInt64)GetUi32(buf + 4) + 1) << 2) &&
+ (GetUi32(buf) == CrcCalc(buf + 4, 6) &&
+ flags == GetBe16(buf + 8) &&
+ memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) == 0);
+}
+
+#define READ_VARINT_AND_CHECK(buf, pos, size, res) \
+ { unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \
+ if (s == 0) return SZ_ERROR_ARCHIVE; pos += s; }
+
+
+SRes XzBlock_Parse(CXzBlock *p, const Byte *header)
+{
+ unsigned pos;
+ int numFilters, i;
+ UInt32 headerSize = (UInt32)header[0] << 2;
+
+ if (CrcCalc(header, headerSize) != GetUi32(header + headerSize))
+ return SZ_ERROR_ARCHIVE;
+
+ pos = 1;
+ if (pos == headerSize)
+ return SZ_ERROR_ARCHIVE;
+ p->flags = header[pos++];
+
+ if (XzBlock_HasPackSize(p))
+ {
+ READ_VARINT_AND_CHECK(header, pos, headerSize, &p->packSize);
+ if (p->packSize == 0 || p->packSize + headerSize >= (UInt64)1 << 63)
+ return SZ_ERROR_ARCHIVE;
+ }
+
+ if (XzBlock_HasUnpackSize(p))
+ READ_VARINT_AND_CHECK(header, pos, headerSize, &p->unpackSize);
+
+ numFilters = XzBlock_GetNumFilters(p);
+ for (i = 0; i < numFilters; i++)
+ {
+ CXzFilter *filter = p->filters + i;
+ UInt64 size;
+ READ_VARINT_AND_CHECK(header, pos, headerSize, &filter->id);
+ READ_VARINT_AND_CHECK(header, pos, headerSize, &size);
+ if (size > headerSize - pos || size > XZ_FILTER_PROPS_SIZE_MAX)
+ return SZ_ERROR_ARCHIVE;
+ filter->propsSize = (UInt32)size;
+ memcpy(filter->props, header + pos, (size_t)size);
+ pos += (unsigned)size;
+
+ #ifdef XZ_DUMP
+ printf("\nf[%d] = %2X: ", i, filter->id);
+ {
+ int i;
+ for (i = 0; i < size; i++)
+ printf(" %2X", filter->props[i]);
+ }
+ #endif
+ }
+
+ while (pos < headerSize)
+ if (header[pos++] != 0)
+ return SZ_ERROR_ARCHIVE;
+ return SZ_OK;
+}
+
+SRes XzDec_Init(CMixCoder *p, const CXzBlock *block)
+{
+ int i;
+ Bool needReInit = True;
+ int numFilters = XzBlock_GetNumFilters(block);
+ if (numFilters == p->numCoders)
+ {
+ for (i = 0; i < numFilters; i++)
+ if (p->ids[i] != block->filters[numFilters - 1 - i].id)
+ break;
+ needReInit = (i != numFilters);
+ }
+ if (needReInit)
+ {
+ MixCoder_Free(p);
+ p->numCoders = numFilters;
+ for (i = 0; i < numFilters; i++)
+ {
+ const CXzFilter *f = &block->filters[numFilters - 1 - i];
+ RINOK(MixCoder_SetFromMethod(p, i, f->id));
+ }
+ }
+ for (i = 0; i < numFilters; i++)
+ {
+ const CXzFilter *f = &block->filters[numFilters - 1 - i];
+ IStateCoder *sc = &p->coders[i];
+ RINOK(sc->SetProps(sc->p, f->props, f->propsSize, p->alloc));
+ }
+ MixCoder_Init(p);
+ return SZ_OK;
+}
+
+SRes XzUnpacker_Create(CXzUnpacker *p, ISzAlloc *alloc)
+{
+ MixCoder_Construct(&p->decoder, alloc);
+ p->state = XZ_STATE_STREAM_HEADER;
+ p->pos = 0;
+ p->numStreams = 0;
+ return SZ_OK;
+}
+
+void XzUnpacker_Free(CXzUnpacker *p)
+{
+ MixCoder_Free(&p->decoder);
+}
+
+SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
+ const Byte *src, SizeT *srcLen, int finishMode, ECoderStatus *status)
+{
+ SizeT destLenOrig = *destLen;
+ SizeT srcLenOrig = *srcLen;
+ *destLen = 0;
+ *srcLen = 0;
+ *status = CODER_STATUS_NOT_SPECIFIED;
+ for (;;)
+ {
+ SizeT srcRem = srcLenOrig - *srcLen;
+
+ if (p->state == XZ_STATE_BLOCK)
+ {
+ SizeT destLen2 = destLenOrig - *destLen;
+ SizeT srcLen2 = srcLenOrig - *srcLen;
+ SRes res;
+ if (srcLen2 == 0 && destLen2 == 0)
+ {
+ *status = CODER_STATUS_NOT_FINISHED;
+ return SZ_OK;
+ }
+
+ res = MixCoder_Code(&p->decoder, dest, &destLen2, src, &srcLen2, False, finishMode, status);
+ XzCheck_Update(&p->check, dest, destLen2);
+
+ (*srcLen) += srcLen2;
+ src += srcLen2;
+ p->packSize += srcLen2;
+
+ (*destLen) += destLen2;
+ dest += destLen2;
+ p->unpackSize += destLen2;
+
+ RINOK(res);
+
+ if (*status == CODER_STATUS_FINISHED_WITH_MARK)
+ {
+ Byte temp[32];
+ unsigned num = Xz_WriteVarInt(temp, p->packSize + p->blockHeaderSize + XzFlags_GetCheckSize(p->streamFlags));
+ num += Xz_WriteVarInt(temp + num, p->unpackSize);
+ Sha256_Update(&p->sha, temp, num);
+ p->indexSize += num;
+ p->numBlocks++;
+
+ p->state = XZ_STATE_BLOCK_FOOTER;
+ p->pos = 0;
+ p->alignPos = 0;
+ }
+ else if (srcLen2 == 0 && destLen2 == 0)
+ return SZ_OK;
+
+ continue;
+ }
+
+ if (srcRem == 0)
+ {
+ *status = CODER_STATUS_NEEDS_MORE_INPUT;
+ return SZ_OK;
+ }
+
+ switch(p->state)
+ {
+ case XZ_STATE_STREAM_HEADER:
+ {
+ if (p->pos < XZ_STREAM_HEADER_SIZE)
+ {
+ if (p->pos < XZ_SIG_SIZE && *src != XZ_SIG[p->pos])
+ return SZ_ERROR_NO_ARCHIVE;
+ p->buf[p->pos++] = *src++;
+ (*srcLen)++;
+ }
+ else
+ {
+ RINOK(Xz_ParseHeader(&p->streamFlags, p->buf));
+ p->state = XZ_STATE_BLOCK_HEADER;
+ Sha256_Init(&p->sha);
+ p->indexSize = 0;
+ p->numBlocks = 0;
+ p->pos = 0;
+ }
+ break;
+ }
+
+ case XZ_STATE_BLOCK_HEADER:
+ {
+ if (p->pos == 0)
+ {
+ p->buf[p->pos++] = *src++;
+ (*srcLen)++;
+ if (p->buf[0] == 0)
+ {
+ p->indexPreSize = 1 + Xz_WriteVarInt(p->buf + 1, p->numBlocks);
+ p->indexPos = p->indexPreSize;
+ p->indexSize += p->indexPreSize;
+ Sha256_Final(&p->sha, p->shaDigest);
+ Sha256_Init(&p->sha);
+ p->crc = CrcUpdate(CRC_INIT_VAL, p->buf, p->indexPreSize);
+ p->state = XZ_STATE_STREAM_INDEX;
+ }
+ p->blockHeaderSize = ((UInt32)p->buf[0] << 2) + 4;
+ }
+ else if (p->pos != p->blockHeaderSize)
+ {
+ UInt32 cur = p->blockHeaderSize - p->pos;
+ if (cur > srcRem)
+ cur = (UInt32)srcRem;
+ memcpy(p->buf + p->pos, src, cur);
+ p->pos += cur;
+ (*srcLen) += cur;
+ src += cur;
+ }
+ else
+ {
+ RINOK(XzBlock_Parse(&p->block, p->buf));
+ p->state = XZ_STATE_BLOCK;
+ p->packSize = 0;
+ p->unpackSize = 0;
+ XzCheck_Init(&p->check, XzFlags_GetCheckType(p->streamFlags));
+ RINOK(XzDec_Init(&p->decoder, &p->block));
+ }
+ break;
+ }
+
+ case XZ_STATE_BLOCK_FOOTER:
+ {
+ if (((p->packSize + p->alignPos) & 3) != 0)
+ {
+ (*srcLen)++;
+ p->alignPos++;
+ if (*src++ != 0)
+ return SZ_ERROR_CRC;
+ }
+ else
+ {
+ UInt32 checkSize = XzFlags_GetCheckSize(p->streamFlags);
+ UInt32 cur = checkSize - p->pos;
+ if (cur != 0)
+ {
+ if (cur > srcRem)
+ cur = (UInt32)srcRem;
+ memcpy(p->buf + p->pos, src, cur);
+ p->pos += cur;
+ (*srcLen) += cur;
+ src += cur;
+ }
+ else
+ {
+ Byte digest[XZ_CHECK_SIZE_MAX];
+ p->state = XZ_STATE_BLOCK_HEADER;
+ p->pos = 0;
+ if (XzCheck_Final(&p->check, digest) && memcmp(digest, p->buf, checkSize) != 0)
+ return SZ_ERROR_CRC;
+ }
+ }
+ break;
+ }
+
+ case XZ_STATE_STREAM_INDEX:
+ {
+ if (p->pos < p->indexPreSize)
+ {
+ (*srcLen)++;
+ if (*src++ != p->buf[p->pos++])
+ return SZ_ERROR_CRC;
+ }
+ else
+ {
+ if (p->indexPos < p->indexSize)
+ {
+ UInt64 cur = p->indexSize - p->indexPos;
+ if (srcRem > cur)
+ srcRem = (SizeT)cur;
+ p->crc = CrcUpdate(p->crc, src, srcRem);
+ Sha256_Update(&p->sha, src, srcRem);
+ (*srcLen) += srcRem;
+ src += srcRem;
+ p->indexPos += srcRem;
+ }
+ else if ((p->indexPos & 3) != 0)
+ {
+ Byte b = *src++;
+ p->crc = CRC_UPDATE_BYTE(p->crc, b);
+ (*srcLen)++;
+ p->indexPos++;
+ p->indexSize++;
+ if (b != 0)
+ return SZ_ERROR_CRC;
+ }
+ else
+ {
+ Byte digest[SHA256_DIGEST_SIZE];
+ p->state = XZ_STATE_STREAM_INDEX_CRC;
+ p->indexSize += 4;
+ p->pos = 0;
+ Sha256_Final(&p->sha, digest);
+ if (memcmp(digest, p->shaDigest, SHA256_DIGEST_SIZE) != 0)
+ return SZ_ERROR_CRC;
+ }
+ }
+ break;
+ }
+
+ case XZ_STATE_STREAM_INDEX_CRC:
+ {
+ if (p->pos < 4)
+ {
+ (*srcLen)++;
+ p->buf[p->pos++] = *src++;
+ }
+ else
+ {
+ p->state = XZ_STATE_STREAM_FOOTER;
+ p->pos = 0;
+ if (CRC_GET_DIGEST(p->crc) != GetUi32(p->buf))
+ return SZ_ERROR_CRC;
+ }
+ break;
+ }
+
+ case XZ_STATE_STREAM_FOOTER:
+ {
+ UInt32 cur = XZ_STREAM_FOOTER_SIZE - p->pos;
+ if (cur > srcRem)
+ cur = (UInt32)srcRem;
+ memcpy(p->buf + p->pos, src, cur);
+ p->pos += cur;
+ (*srcLen) += cur;
+ src += cur;
+ if (p->pos == XZ_STREAM_FOOTER_SIZE)
+ {
+ p->state = XZ_STATE_STREAM_PADDING;
+ p->numStreams++;
+ p->padSize = 0;
+ if (!Xz_CheckFooter(p->streamFlags, p->indexSize, p->buf))
+ return SZ_ERROR_CRC;
+ }
+ break;
+ }
+
+ case XZ_STATE_STREAM_PADDING:
+ {
+ if (*src != 0)
+ {
+ if (((UInt32)p->padSize & 3) != 0)
+ return SZ_ERROR_NO_ARCHIVE;
+ p->pos = 0;
+ p->state = XZ_STATE_STREAM_HEADER;
+ }
+ else
+ {
+ (*srcLen)++;
+ src++;
+ p->padSize++;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ /*
+ if (p->state == XZ_STATE_FINISHED)
+ *status = CODER_STATUS_FINISHED_WITH_MARK;
+ return SZ_OK;
+ */
+}
+
+Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p)
+{
+ return (p->state == XZ_STATE_STREAM_PADDING) && (((UInt32)p->padSize & 3) == 0);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzEnc.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzEnc.c
new file mode 100644
index 000000000..e98856f4b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzEnc.c
@@ -0,0 +1,497 @@
+/* XzEnc.c -- Xz Encode
+2009-05-26 : Igor Pavlov : Public domain */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "7zCrc.h"
+#include "Alloc.h"
+#include "Bra.h"
+#include "CpuArch.h"
+#ifdef USE_SUBBLOCK
+#include "SbEnc.h"
+#endif
+
+#include "XzEnc.h"
+
+static void *SzBigAlloc(void *p, size_t size) { p = p; return BigAlloc(size); }
+static void SzBigFree(void *p, void *address) { p = p; BigFree(address); }
+static ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree };
+
+static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
+static void SzFree(void *p, void *address) { p = p; MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+#define XzBlock_ClearFlags(p) (p)->flags = 0;
+#define XzBlock_SetNumFilters(p, n) (p)->flags |= ((n) - 1);
+#define XzBlock_SetHasPackSize(p) (p)->flags |= XZ_BF_PACK_SIZE;
+#define XzBlock_SetHasUnpackSize(p) (p)->flags |= XZ_BF_UNPACK_SIZE;
+
+static SRes WriteBytes(ISeqOutStream *s, const void *buf, UInt32 size)
+{
+ return (s->Write(s, buf, size) == size) ? SZ_OK : SZ_ERROR_WRITE;
+}
+
+static SRes WriteBytesAndCrc(ISeqOutStream *s, const void *buf, UInt32 size, UInt32 *crc)
+{
+ *crc = CrcUpdate(*crc, buf, size);
+ return WriteBytes(s, buf, size);
+}
+
+SRes Xz_WriteHeader(CXzStreamFlags f, ISeqOutStream *s)
+{
+ UInt32 crc;
+ Byte header[XZ_STREAM_HEADER_SIZE];
+ memcpy(header, XZ_SIG, XZ_SIG_SIZE);
+ header[XZ_SIG_SIZE] = (Byte)(f >> 8);
+ header[XZ_SIG_SIZE + 1] = (Byte)(f & 0xFF);
+ crc = CrcCalc(header + XZ_SIG_SIZE, XZ_STREAM_FLAGS_SIZE);
+ SetUi32(header + XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE, crc);
+ return WriteBytes(s, header, XZ_STREAM_HEADER_SIZE);
+}
+
+SRes XzBlock_WriteHeader(const CXzBlock *p, ISeqOutStream *s)
+{
+ Byte header[XZ_BLOCK_HEADER_SIZE_MAX];
+
+ unsigned pos = 1;
+ int numFilters, i;
+ header[pos++] = p->flags;
+
+ if (XzBlock_HasPackSize(p)) pos += Xz_WriteVarInt(header + pos, p->packSize);
+ if (XzBlock_HasUnpackSize(p)) pos += Xz_WriteVarInt(header + pos, p->unpackSize);
+ numFilters = XzBlock_GetNumFilters(p);
+ for (i = 0; i < numFilters; i++)
+ {
+ const CXzFilter *f = &p->filters[i];
+ pos += Xz_WriteVarInt(header + pos, f->id);
+ pos += Xz_WriteVarInt(header + pos, f->propsSize);
+ memcpy(header + pos, f->props, f->propsSize);
+ pos += f->propsSize;
+ }
+ while((pos & 3) != 0)
+ header[pos++] = 0;
+ header[0] = (Byte)(pos >> 2);
+ SetUi32(header + pos, CrcCalc(header, pos));
+ return WriteBytes(s, header, pos + 4);
+}
+
+SRes Xz_WriteFooter(CXzStream *p, ISeqOutStream *s)
+{
+ Byte buf[32];
+ UInt64 globalPos;
+ {
+ UInt32 crc = CRC_INIT_VAL;
+ unsigned pos = 1 + Xz_WriteVarInt(buf + 1, p->numBlocks);
+ size_t i;
+
+ globalPos = pos;
+ buf[0] = 0;
+ RINOK(WriteBytesAndCrc(s, buf, pos, &crc));
+ for (i = 0; i < p->numBlocks; i++)
+ {
+ const CXzBlockSizes *block = &p->blocks[i];
+ pos = Xz_WriteVarInt(buf, block->totalSize);
+ pos += Xz_WriteVarInt(buf + pos, block->unpackSize);
+ globalPos += pos;
+ RINOK(WriteBytesAndCrc(s, buf, pos, &crc));
+ }
+ pos = ((unsigned)globalPos & 3);
+ if (pos != 0)
+ {
+ buf[0] = buf[1] = buf[2] = 0;
+ RINOK(WriteBytesAndCrc(s, buf, 4 - pos, &crc));
+ globalPos += 4 - pos;
+ }
+ {
+ SetUi32(buf, CRC_GET_DIGEST(crc));
+ RINOK(WriteBytes(s, buf, 4));
+ globalPos += 4;
+ }
+ }
+
+ {
+ UInt32 indexSize = (UInt32)((globalPos >> 2) - 1);
+ SetUi32(buf + 4, indexSize);
+ buf[8] = (Byte)(p->flags >> 8);
+ buf[9] = (Byte)(p->flags & 0xFF);
+ SetUi32(buf, CrcCalc(buf + 4, 6));
+ memcpy(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE);
+ return WriteBytes(s, buf, 12);
+ }
+}
+
+SRes Xz_AddIndexRecord(CXzStream *p, UInt64 unpackSize, UInt64 totalSize, ISzAlloc *alloc)
+{
+ if (p->blocks == 0 || p->numBlocksAllocated == p->numBlocks)
+ {
+ size_t num = (p->numBlocks + 1) * 2;
+ size_t newSize = sizeof(CXzBlockSizes) * num;
+ CXzBlockSizes *blocks;
+ if (newSize / sizeof(CXzBlockSizes) != num)
+ return SZ_ERROR_MEM;
+ blocks = alloc->Alloc(alloc, newSize);
+ if (blocks == 0)
+ return SZ_ERROR_MEM;
+ if (p->numBlocks != 0)
+ {
+ memcpy(blocks, p->blocks, p->numBlocks * sizeof(CXzBlockSizes));
+ Xz_Free(p, alloc);
+ }
+ p->blocks = blocks;
+ p->numBlocksAllocated = num;
+ }
+ {
+ CXzBlockSizes *block = &p->blocks[p->numBlocks++];
+ block->totalSize = totalSize;
+ block->unpackSize = unpackSize;
+ }
+ return SZ_OK;
+}
+
+/* ---------- CSeqCheckInStream ---------- */
+
+typedef struct
+{
+ ISeqInStream p;
+ ISeqInStream *realStream;
+ UInt64 processed;
+ CXzCheck check;
+} CSeqCheckInStream;
+
+void SeqCheckInStream_Init(CSeqCheckInStream *p, int mode)
+{
+ p->processed = 0;
+ XzCheck_Init(&p->check, mode);
+}
+
+void SeqCheckInStream_GetDigest(CSeqCheckInStream *p, Byte *digest)
+{
+ XzCheck_Final(&p->check, digest);
+}
+
+static SRes SeqCheckInStream_Read(void *pp, void *data, size_t *size)
+{
+ CSeqCheckInStream *p = (CSeqCheckInStream *)pp;
+ SRes res = p->realStream->Read(p->realStream, data, size);
+ XzCheck_Update(&p->check, data, *size);
+ p->processed += *size;
+ return res;
+}
+
+/* ---------- CSeqSizeOutStream ---------- */
+
+typedef struct
+{
+ ISeqOutStream p;
+ ISeqOutStream *realStream;
+ UInt64 processed;
+} CSeqSizeOutStream;
+
+static size_t MyWrite(void *pp, const void *data, size_t size)
+{
+ CSeqSizeOutStream *p = (CSeqSizeOutStream *)pp;
+ size = p->realStream->Write(p->realStream, data, size);
+ p->processed += size;
+ return size;
+}
+
+/* ---------- CSeqInFilter ---------- */
+
+/*
+typedef struct _IFilter
+{
+ void *p;
+ void (*Free)(void *p, ISzAlloc *alloc);
+ SRes (*SetProps)(void *p, const Byte *props, size_t propSize, ISzAlloc *alloc);
+ void (*Init)(void *p);
+ size_t (*Filter)(void *p, Byte *data, SizeT destLen);
+} IFilter;
+
+#define FILT_BUF_SIZE (1 << 19)
+
+typedef struct
+{
+ ISeqInStream p;
+ ISeqInStream *realStream;
+ UInt32 x86State;
+ UInt32 ip;
+ UInt64 processed;
+ CXzCheck check;
+ Byte buf[FILT_BUF_SIZE];
+ UInt32 bufferPos;
+ UInt32 convertedPosBegin;
+ UInt32 convertedPosEnd;
+ IFilter *filter;
+} CSeqInFilter;
+
+static SRes SeqInFilter_Read(void *pp, void *data, size_t *size)
+{
+ CSeqInFilter *p = (CSeqInFilter *)pp;
+ size_t remSize = *size;
+ *size = 0;
+
+ while (remSize > 0)
+ {
+ int i;
+ if (p->convertedPosBegin != p->convertedPosEnd)
+ {
+ UInt32 sizeTemp = p->convertedPosEnd - p->convertedPosBegin;
+ if (remSize < sizeTemp)
+ sizeTemp = (UInt32)remSize;
+ memmove(data, p->buf + p->convertedPosBegin, sizeTemp);
+ p->convertedPosBegin += sizeTemp;
+ data = (void *)((Byte *)data + sizeTemp);
+ remSize -= sizeTemp;
+ *size += sizeTemp;
+ break;
+ }
+ for (i = 0; p->convertedPosEnd + i < p->bufferPos; i++)
+ p->buf[i] = p->buf[i + p->convertedPosEnd];
+ p->bufferPos = i;
+ p->convertedPosBegin = p->convertedPosEnd = 0;
+ {
+ size_t processedSizeTemp = FILT_BUF_SIZE - p->bufferPos;
+ RINOK(p->realStream->Read(p->realStream, p->buf + p->bufferPos, &processedSizeTemp));
+ p->bufferPos = p->bufferPos + (UInt32)processedSizeTemp;
+ }
+ p->convertedPosEnd = (UInt32)p->filter->Filter(p->filter->p, p->buf, p->bufferPos);
+ if (p->convertedPosEnd == 0)
+ {
+ if (p->bufferPos == 0)
+ break;
+ else
+ {
+ p->convertedPosEnd = p->bufferPos;
+ continue;
+ }
+ }
+ if (p->convertedPosEnd > p->bufferPos)
+ {
+ for (; p->bufferPos < p->convertedPosEnd; p->bufferPos++)
+ p->buf[p->bufferPos] = 0;
+ p->convertedPosEnd = (UInt32)p->filter->Filter(p->filter->p, p->buf, p->bufferPos);
+ }
+ }
+ return SZ_OK;
+}
+*/
+
+/*
+typedef struct
+{
+ ISeqInStream p;
+ ISeqInStream *realStream;
+ CMixCoder mixCoder;
+ Byte buf[FILT_BUF_SIZE];
+ UInt32 bufPos;
+ UInt32 bufSize;
+} CMixCoderSeqInStream;
+
+static SRes CMixCoderSeqInStream_Read(void *pp, void *data, size_t *size)
+{
+ CMixCoderSeqInStream *p = (CMixCoderSeqInStream *)pp;
+ SRes res = SZ_OK;
+ size_t remSize = *size;
+ *size = 0;
+ while (remSize > 0)
+ {
+ if (p->bufPos == p->bufSize)
+ {
+ size_t curSize;
+ p->bufPos = p->bufSize = 0;
+ if (*size != 0)
+ break;
+ curSize = FILT_BUF_SIZE;
+ RINOK(p->realStream->Read(p->realStream, p->buf, &curSize));
+ p->bufSize = (UInt32)curSize;
+ }
+ {
+ SizeT destLen = remSize;
+ SizeT srcLen = p->bufSize - p->bufPos;
+ res = MixCoder_Code(&p->mixCoder, data, &destLen, p->buf + p->bufPos, &srcLen, 0);
+ data = (void *)((Byte *)data + destLen);
+ remSize -= destLen;
+ *size += destLen;
+ p->bufPos += srcLen;
+ }
+ }
+ return res;
+}
+*/
+
+#ifdef USE_SUBBLOCK
+typedef struct
+{
+ ISeqInStream p;
+ CSubblockEnc sb;
+ UInt64 processed;
+} CSbEncInStream;
+
+void SbEncInStream_Init(CSbEncInStream *p)
+{
+ p->processed = 0;
+ SubblockEnc_Init(&p->sb);
+}
+
+static SRes SbEncInStream_Read(void *pp, void *data, size_t *size)
+{
+ CSbEncInStream *p = (CSbEncInStream *)pp;
+ SRes res = SubblockEnc_Read(&p->sb, data, size);
+ p->processed += *size;
+ return res;
+}
+#endif
+
+typedef struct
+{
+ /* CMixCoderSeqInStream inStream; */
+ CLzma2EncHandle lzma2;
+ #ifdef USE_SUBBLOCK
+ CSbEncInStream sb;
+ #endif
+ ISzAlloc *alloc;
+ ISzAlloc *bigAlloc;
+} CLzma2WithFilters;
+
+
+static void Lzma2WithFilters_Construct(CLzma2WithFilters *p, ISzAlloc *alloc, ISzAlloc *bigAlloc)
+{
+ p->alloc = alloc;
+ p->bigAlloc = bigAlloc;
+ p->lzma2 = NULL;
+ #ifdef USE_SUBBLOCK
+ p->sb.p.Read = SbEncInStream_Read;
+ SubblockEnc_Construct(&p->sb.sb, p->alloc);
+ #endif
+}
+
+static SRes Lzma2WithFilters_Create(CLzma2WithFilters *p)
+{
+ p->lzma2 = Lzma2Enc_Create(p->alloc, p->bigAlloc);
+ if (p->lzma2 == 0)
+ return SZ_ERROR_MEM;
+ return SZ_OK;
+}
+
+static void Lzma2WithFilters_Free(CLzma2WithFilters *p)
+{
+ #ifdef USE_SUBBLOCK
+ SubblockEnc_Free(&p->sb.sb);
+ #endif
+ if (p->lzma2)
+ {
+ Lzma2Enc_Destroy(p->lzma2);
+ p->lzma2 = NULL;
+ }
+}
+
+static SRes Xz_Compress(CXzStream *xz,
+ CLzma2WithFilters *lzmaf,
+ ISeqOutStream *outStream,
+ ISeqInStream *inStream,
+ const CLzma2EncProps *lzma2Props,
+ Bool useSubblock,
+ ICompressProgress *progress)
+{
+ xz->flags = XZ_CHECK_CRC32;
+
+ RINOK(Lzma2Enc_SetProps(lzmaf->lzma2, lzma2Props));
+ RINOK(Xz_WriteHeader(xz->flags, outStream));
+
+ {
+ CSeqCheckInStream checkInStream;
+ CSeqSizeOutStream seqSizeOutStream;
+ CXzBlock block;
+ int filterIndex = 0;
+
+ XzBlock_ClearFlags(&block);
+ XzBlock_SetNumFilters(&block, 1 + (useSubblock ? 1 : 0));
+
+ if (useSubblock)
+ {
+ CXzFilter *f = &block.filters[filterIndex++];
+ f->id = XZ_ID_Subblock;
+ f->propsSize = 0;
+ }
+
+ {
+ CXzFilter *f = &block.filters[filterIndex++];
+ f->id = XZ_ID_LZMA2;
+ f->propsSize = 1;
+ f->props[0] = Lzma2Enc_WriteProperties(lzmaf->lzma2);
+ }
+
+ seqSizeOutStream.p.Write = MyWrite;
+ seqSizeOutStream.realStream = outStream;
+ seqSizeOutStream.processed = 0;
+
+ RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.p));
+
+ checkInStream.p.Read = SeqCheckInStream_Read;
+ checkInStream.realStream = inStream;
+ SeqCheckInStream_Init(&checkInStream, XzFlags_GetCheckType(xz->flags));
+
+ #ifdef USE_SUBBLOCK
+ if (useSubblock)
+ {
+ lzmaf->sb.sb.inStream = &checkInStream.p;
+ SubblockEnc_Init(&lzmaf->sb.sb);
+ }
+ #endif
+
+ {
+ UInt64 packPos = seqSizeOutStream.processed;
+ SRes res = Lzma2Enc_Encode(lzmaf->lzma2, &seqSizeOutStream.p, /* FIXME HRESULT -> SRes */
+ #ifdef USE_SUBBLOCK
+ useSubblock ? &lzmaf->sb.p:
+ #endif
+ &checkInStream.p,
+ progress);
+ RINOK(res);
+ block.unpackSize = checkInStream.processed;
+ block.packSize = seqSizeOutStream.processed - packPos;
+ }
+
+ {
+ unsigned padSize = 0;
+ Byte buf[128];
+ while((((unsigned)block.packSize + padSize) & 3) != 0)
+ buf[padSize++] = 0;
+ SeqCheckInStream_GetDigest(&checkInStream, buf + padSize);
+ RINOK(WriteBytes(&seqSizeOutStream.p, buf, padSize + XzFlags_GetCheckSize(xz->flags)));
+ RINOK(Xz_AddIndexRecord(xz, block.unpackSize, seqSizeOutStream.processed - padSize, &g_Alloc));
+ }
+ }
+ return Xz_WriteFooter(xz, outStream);
+}
+
+SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
+ const CLzma2EncProps *lzma2Props, Bool useSubblock,
+ ICompressProgress *progress)
+{
+ SRes res;
+ CXzStream xz;
+ CLzma2WithFilters lzmaf;
+ Xz_Construct(&xz);
+ Lzma2WithFilters_Construct(&lzmaf, &g_Alloc, &g_BigAlloc);
+ res = Lzma2WithFilters_Create(&lzmaf);
+ if (res == SZ_OK)
+ res = Xz_Compress(&xz, &lzmaf, outStream, inStream,
+ lzma2Props, useSubblock, progress);
+ Lzma2WithFilters_Free(&lzmaf);
+ Xz_Free(&xz, &g_Alloc);
+ return res;
+}
+
+SRes Xz_EncodeEmpty(ISeqOutStream *outStream)
+{
+ SRes res;
+ CXzStream xz;
+ Xz_Construct(&xz);
+ res = Xz_WriteHeader(xz.flags, outStream);
+ if (res == SZ_OK)
+ res = Xz_WriteFooter(&xz, outStream);
+ Xz_Free(&xz, &g_Alloc);
+ return res;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzEnc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzEnc.h
new file mode 100644
index 000000000..13390df8b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzEnc.h
@@ -0,0 +1,25 @@
+/* XzEnc.h -- Xz Encode
+2009-04-15 : Igor Pavlov : Public domain */
+
+#ifndef __XZ_ENC_H
+#define __XZ_ENC_H
+
+#include "Lzma2Enc.h"
+
+#include "Xz.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
+ const CLzma2EncProps *lzma2Props, Bool useSubblock,
+ ICompressProgress *progress);
+
+SRes Xz_EncodeEmpty(ISeqOutStream *outStream);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzIn.c b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzIn.c
new file mode 100644
index 000000000..9e62efa2e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/C/XzIn.c
@@ -0,0 +1,307 @@
+/* XzIn.c - Xz input
+2009-04-15 : Igor Pavlov : Public domain */
+
+#include "Xz.h"
+
+#include "7zCrc.h"
+#include "CpuArch.h"
+
+#include <string.h>
+
+SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream)
+{
+ Byte sig[XZ_STREAM_HEADER_SIZE];
+ RINOK(SeqInStream_Read2(inStream, sig, XZ_STREAM_HEADER_SIZE, SZ_ERROR_NO_ARCHIVE));
+ if (memcmp(sig, XZ_SIG, XZ_SIG_SIZE) != 0)
+ return SZ_ERROR_NO_ARCHIVE;
+ return Xz_ParseHeader(p, sig);
+}
+
+#define READ_VARINT_AND_CHECK(buf, pos, size, res) \
+ { unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \
+ if (s == 0) return SZ_ERROR_ARCHIVE; pos += s; }
+
+SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, Bool *isIndex, UInt32 *headerSizeRes)
+{
+ Byte header[XZ_BLOCK_HEADER_SIZE_MAX];
+ unsigned headerSize;
+ *headerSizeRes = 0;
+ RINOK(SeqInStream_ReadByte(inStream, &header[0]));
+ headerSize = ((unsigned)header[0] << 2) + 4;
+ if (headerSize == 0)
+ {
+ *headerSizeRes = 1;
+ *isIndex = True;
+ return SZ_OK;
+ }
+
+ *isIndex = False;
+ *headerSizeRes = headerSize;
+ RINOK(SeqInStream_Read(inStream, header + 1, headerSize - 1));
+ return XzBlock_Parse(p, header);
+}
+
+#define ADD_SIZE_CHECH(size, val) \
+ { UInt64 newSize = size + (val); if (newSize < size) return XZ_SIZE_OVERFLOW; size = newSize; }
+
+UInt64 Xz_GetUnpackSize(const CXzStream *p)
+{
+ UInt64 size = 0;
+ size_t i;
+ for (i = 0; i < p->numBlocks; i++)
+ ADD_SIZE_CHECH(size, p->blocks[i].unpackSize);
+ return size;
+}
+
+UInt64 Xz_GetPackSize(const CXzStream *p)
+{
+ UInt64 size = 0;
+ size_t i;
+ for (i = 0; i < p->numBlocks; i++)
+ ADD_SIZE_CHECH(size, (p->blocks[i].totalSize + 3) & ~(UInt64)3);
+ return size;
+}
+
+/*
+SRes XzBlock_ReadFooter(CXzBlock *p, CXzStreamFlags f, ISeqInStream *inStream)
+{
+ return SeqInStream_Read(inStream, p->check, XzFlags_GetCheckSize(f));
+}
+*/
+
+static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *alloc)
+{
+ size_t i, numBlocks, crcStartPos, pos = 1;
+ UInt32 crc;
+
+ if (size < 5 || buf[0] != 0)
+ return SZ_ERROR_ARCHIVE;
+
+ size -= 4;
+ crc = CrcCalc(buf, size);
+ if (crc != GetUi32(buf + size))
+ return SZ_ERROR_ARCHIVE;
+
+ {
+ UInt64 numBlocks64;
+ READ_VARINT_AND_CHECK(buf, pos, size, &numBlocks64);
+ numBlocks = (size_t)numBlocks64;
+ if (numBlocks != numBlocks64 || numBlocks * 2 > size)
+ return SZ_ERROR_ARCHIVE;
+ }
+
+ crcStartPos = pos;
+ Xz_Free(p, alloc);
+ if (numBlocks != 0)
+ {
+ p->numBlocks = numBlocks;
+ p->numBlocksAllocated = numBlocks;
+ p->blocks = alloc->Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks);
+ if (p->blocks == 0)
+ return SZ_ERROR_MEM;
+ for (i = 0; i < numBlocks; i++)
+ {
+ CXzBlockSizes *block = &p->blocks[i];
+ READ_VARINT_AND_CHECK(buf, pos, size, &block->totalSize);
+ READ_VARINT_AND_CHECK(buf, pos, size, &block->unpackSize);
+ if (block->totalSize == 0)
+ return SZ_ERROR_ARCHIVE;
+ }
+ }
+ while ((pos & 3) != 0)
+ if (buf[pos++] != 0)
+ return SZ_ERROR_ARCHIVE;
+ return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE;
+}
+
+static SRes Xz_ReadIndex(CXzStream *p, ILookInStream *stream, UInt64 indexSize, ISzAlloc *alloc)
+{
+ SRes res;
+ size_t size;
+ Byte *buf;
+ if (indexSize > ((UInt32)1 << 31))
+ return SZ_ERROR_UNSUPPORTED;
+ size = (size_t)indexSize;
+ if (size != indexSize)
+ return SZ_ERROR_UNSUPPORTED;
+ buf = alloc->Alloc(alloc, size);
+ if (buf == 0)
+ return SZ_ERROR_MEM;
+ res = LookInStream_Read2(stream, buf, size, SZ_ERROR_UNSUPPORTED);
+ if (res == SZ_OK)
+ res = Xz_ReadIndex2(p, buf, size, alloc);
+ alloc->Free(alloc, buf);
+ return res;
+}
+
+static SRes SeekFromCur(ILookInStream *inStream, Int64 *res)
+{
+ return inStream->Seek(inStream, res, SZ_SEEK_CUR);
+}
+
+static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOffset, ISzAlloc *alloc)
+{
+ UInt64 indexSize;
+ Byte buf[XZ_STREAM_FOOTER_SIZE];
+
+ if ((*startOffset & 3) != 0 || *startOffset < XZ_STREAM_FOOTER_SIZE)
+ return SZ_ERROR_NO_ARCHIVE;
+ *startOffset = -XZ_STREAM_FOOTER_SIZE;
+ RINOK(SeekFromCur(stream, startOffset));
+
+ RINOK(LookInStream_Read2(stream, buf, XZ_STREAM_FOOTER_SIZE, SZ_ERROR_NO_ARCHIVE));
+
+ if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
+ {
+ Int64 i = 0;
+ *startOffset += XZ_STREAM_FOOTER_SIZE;
+ for (;;)
+ {
+ int j;
+ size_t processedSize;
+ #define TEMP_BUF_SIZE (1 << 10)
+ Byte tempBuf[TEMP_BUF_SIZE];
+ if (*startOffset < XZ_STREAM_FOOTER_SIZE || i > (1 << 16))
+ return SZ_ERROR_NO_ARCHIVE;
+ processedSize = (*startOffset > TEMP_BUF_SIZE) ? TEMP_BUF_SIZE : (size_t)*startOffset;
+ i += processedSize;
+ *startOffset = -(Int64)processedSize;
+ RINOK(SeekFromCur(stream, startOffset));
+ RINOK(LookInStream_Read2(stream, tempBuf, processedSize, SZ_ERROR_NO_ARCHIVE));
+ for (j = (int)processedSize; j >= 0; j--)
+ if (tempBuf[j -1] != 0)
+ break;
+ if (j != 0)
+ {
+ if ((j & 3) != 0)
+ return SZ_ERROR_NO_ARCHIVE;
+ *startOffset += j;
+ if (*startOffset < XZ_STREAM_FOOTER_SIZE)
+ return SZ_ERROR_NO_ARCHIVE;
+ *startOffset -= XZ_STREAM_FOOTER_SIZE;
+ RINOK(stream->Seek(stream, startOffset, SZ_SEEK_SET));
+ RINOK(LookInStream_Read2(stream, buf, XZ_STREAM_FOOTER_SIZE, SZ_ERROR_NO_ARCHIVE));
+ if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
+ return SZ_ERROR_NO_ARCHIVE;
+ break;
+ }
+ }
+ }
+
+ p->flags = (CXzStreamFlags)GetBe16(buf + 8);
+
+ if (!XzFlags_IsSupported(p->flags))
+ return SZ_ERROR_UNSUPPORTED;
+
+ if (GetUi32(buf) != CrcCalc(buf + 4, 6))
+ return SZ_ERROR_ARCHIVE;
+
+ indexSize = ((UInt64)GetUi32(buf + 4) + 1) << 2;
+
+ *startOffset = -(Int64)(indexSize + XZ_STREAM_FOOTER_SIZE);
+ RINOK(SeekFromCur(stream, startOffset));
+
+ RINOK(Xz_ReadIndex(p, stream, indexSize, alloc));
+
+ {
+ UInt64 totalSize = Xz_GetPackSize(p);
+ UInt64 sum = XZ_STREAM_HEADER_SIZE + totalSize + indexSize;
+ if (totalSize == XZ_SIZE_OVERFLOW ||
+ sum >= ((UInt64)1 << 63) ||
+ totalSize >= ((UInt64)1 << 63))
+ return SZ_ERROR_ARCHIVE;
+ *startOffset = -(Int64)sum;
+ RINOK(SeekFromCur(stream, startOffset));
+ }
+ {
+ CXzStreamFlags headerFlags;
+ CSecToRead secToRead;
+ SecToRead_CreateVTable(&secToRead);
+ secToRead.realStream = stream;
+
+ RINOK(Xz_ReadHeader(&headerFlags, &secToRead.s));
+ return (p->flags == headerFlags) ? SZ_OK : SZ_ERROR_ARCHIVE;
+ }
+}
+
+
+/* ---------- Xz Streams ---------- */
+
+void Xzs_Construct(CXzs *p)
+{
+ p->num = p->numAllocated = 0;
+ p->streams = 0;
+}
+
+void Xzs_Free(CXzs *p, ISzAlloc *alloc)
+{
+ size_t i;
+ for (i = 0; i < p->num; i++)
+ Xz_Free(&p->streams[i], alloc);
+ alloc->Free(alloc, p->streams);
+ p->num = p->numAllocated = 0;
+ p->streams = 0;
+}
+
+UInt64 Xzs_GetNumBlocks(const CXzs *p)
+{
+ UInt64 num = 0;
+ size_t i;
+ for (i = 0; i < p->num; i++)
+ num += p->streams[i].numBlocks;
+ return num;
+}
+
+UInt64 Xzs_GetUnpackSize(const CXzs *p)
+{
+ UInt64 size = 0;
+ size_t i;
+ for (i = 0; i < p->num; i++)
+ ADD_SIZE_CHECH(size, Xz_GetUnpackSize(&p->streams[i]));
+ return size;
+}
+
+/*
+UInt64 Xzs_GetPackSize(const CXzs *p)
+{
+ UInt64 size = 0;
+ size_t i;
+ for (i = 0; i < p->num; i++)
+ ADD_SIZE_CHECH(size, Xz_GetTotalSize(&p->streams[i]));
+ return size;
+}
+*/
+
+SRes Xzs_ReadBackward(CXzs *p, ILookInStream *stream, Int64 *startOffset, ICompressProgress *progress, ISzAlloc *alloc)
+{
+ Int64 endOffset = 0;
+ RINOK(stream->Seek(stream, &endOffset, SZ_SEEK_END));
+ *startOffset = endOffset;
+ for (;;)
+ {
+ CXzStream st;
+ SRes res;
+ Xz_Construct(&st);
+ res = Xz_ReadBackward(&st, stream, startOffset, alloc);
+ st.startOffset = *startOffset;
+ RINOK(res);
+ if (p->num == p->numAllocated)
+ {
+ size_t newNum = p->num + p->num / 4 + 1;
+ Byte *data = (Byte *)alloc->Alloc(alloc, newNum * sizeof(CXzStream));
+ if (data == 0)
+ return SZ_ERROR_MEM;
+ p->numAllocated = newNum;
+ memcpy(data, p->streams, p->num * sizeof(CXzStream));
+ alloc->Free(alloc, p->streams);
+ p->streams = (CXzStream *)data;
+ }
+ p->streams[p->num++] = st;
+ if (*startOffset == 0)
+ break;
+ RINOK(stream->Seek(stream, startOffset, SZ_SEEK_SET));
+ if (progress && progress->Progress(progress, endOffset - *startOffset, (UInt64)(Int64)-1) != SZ_OK)
+ return SZ_ERROR_PROGRESS;
+ }
+ return SZ_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zCompressionMode.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zCompressionMode.cpp
new file mode 100644
index 000000000..6774fc482
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zCompressionMode.cpp
@@ -0,0 +1,3 @@
+// CompressionMethod.cpp
+
+#include "StdAfx.h"
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zCompressionMode.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zCompressionMode.h
new file mode 100644
index 000000000..174b9ebf3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zCompressionMode.h
@@ -0,0 +1,51 @@
+// 7zCompressionMode.h
+
+#ifndef __7Z_COMPRESSION_MODE_H
+#define __7Z_COMPRESSION_MODE_H
+
+#include "../../../Common/MyString.h"
+
+#include "../../../Windows/PropVariant.h"
+
+#include "../../Common/MethodProps.h"
+
+namespace NArchive {
+namespace N7z {
+
+struct CMethodFull: public CMethod
+{
+ UInt32 NumInStreams;
+ UInt32 NumOutStreams;
+ bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
+};
+
+struct CBind
+{
+ UInt32 InCoder;
+ UInt32 InStream;
+ UInt32 OutCoder;
+ UInt32 OutStream;
+};
+
+struct CCompressionMethodMode
+{
+ CObjectVector<CMethodFull> Methods;
+ CRecordVector<CBind> Binds;
+ #ifdef COMPRESS_MT
+ UInt32 NumThreads;
+ #endif
+ bool PasswordIsDefined;
+ UString Password;
+
+ bool IsEmpty() const { return (Methods.IsEmpty() && !PasswordIsDefined); }
+ CCompressionMethodMode():
+ #ifdef COMPRESS_MT
+ NumThreads(1),
+ #endif
+ PasswordIsDefined(false)
+ {}
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zDecode.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zDecode.cpp
new file mode 100644
index 000000000..2d25ff2ec
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zDecode.cpp
@@ -0,0 +1,332 @@
+// 7zDecode.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/LockedStream.h"
+#include "../../Common/ProgressUtils.h"
+#include "../../Common/StreamObjects.h"
+
+#include "7zDecode.h"
+
+namespace NArchive {
+namespace N7z {
+
+static void ConvertFolderItemInfoToBindInfo(const CFolder &folder,
+ CBindInfoEx &bindInfo)
+{
+ bindInfo.Clear();
+ int i;
+ for (i = 0; i < folder.BindPairs.Size(); i++)
+ {
+ NCoderMixer::CBindPair bindPair;
+ bindPair.InIndex = (UInt32)folder.BindPairs[i].InIndex;
+ bindPair.OutIndex = (UInt32)folder.BindPairs[i].OutIndex;
+ bindInfo.BindPairs.Add(bindPair);
+ }
+ UInt32 outStreamIndex = 0;
+ for (i = 0; i < folder.Coders.Size(); i++)
+ {
+ NCoderMixer::CCoderStreamsInfo coderStreamsInfo;
+ const CCoderInfo &coderInfo = folder.Coders[i];
+ coderStreamsInfo.NumInStreams = (UInt32)coderInfo.NumInStreams;
+ coderStreamsInfo.NumOutStreams = (UInt32)coderInfo.NumOutStreams;
+ bindInfo.Coders.Add(coderStreamsInfo);
+ bindInfo.CoderMethodIDs.Add(coderInfo.MethodID);
+ for (UInt32 j = 0; j < coderStreamsInfo.NumOutStreams; j++, outStreamIndex++)
+ if (folder.FindBindPairForOutStream(outStreamIndex) < 0)
+ bindInfo.OutStreams.Add(outStreamIndex);
+ }
+ for (i = 0; i < folder.PackStreams.Size(); i++)
+ bindInfo.InStreams.Add((UInt32)folder.PackStreams[i]);
+}
+
+static bool AreCodersEqual(const NCoderMixer::CCoderStreamsInfo &a1,
+ const NCoderMixer::CCoderStreamsInfo &a2)
+{
+ return (a1.NumInStreams == a2.NumInStreams) &&
+ (a1.NumOutStreams == a2.NumOutStreams);
+}
+
+static bool AreBindPairsEqual(const NCoderMixer::CBindPair &a1, const NCoderMixer::CBindPair &a2)
+{
+ return (a1.InIndex == a2.InIndex) &&
+ (a1.OutIndex == a2.OutIndex);
+}
+
+static bool AreBindInfoExEqual(const CBindInfoEx &a1, const CBindInfoEx &a2)
+{
+ if (a1.Coders.Size() != a2.Coders.Size())
+ return false;
+ int i;
+ for (i = 0; i < a1.Coders.Size(); i++)
+ if (!AreCodersEqual(a1.Coders[i], a2.Coders[i]))
+ return false;
+ if (a1.BindPairs.Size() != a2.BindPairs.Size())
+ return false;
+ for (i = 0; i < a1.BindPairs.Size(); i++)
+ if (!AreBindPairsEqual(a1.BindPairs[i], a2.BindPairs[i]))
+ return false;
+ for (i = 0; i < a1.CoderMethodIDs.Size(); i++)
+ if (a1.CoderMethodIDs[i] != a2.CoderMethodIDs[i])
+ return false;
+ if (a1.InStreams.Size() != a2.InStreams.Size())
+ return false;
+ if (a1.OutStreams.Size() != a2.OutStreams.Size())
+ return false;
+ return true;
+}
+
+CDecoder::CDecoder(bool multiThread)
+{
+ #ifndef _ST_MODE
+ multiThread = true;
+ #endif
+ _multiThread = multiThread;
+ _bindInfoExPrevIsDefined = false;
+}
+
+HRESULT CDecoder::Decode(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IInStream *inStream,
+ UInt64 startPos,
+ const UInt64 *packSizes,
+ const CFolder &folderInfo,
+ ISequentialOutStream *outStream,
+ ICompressProgressInfo *compressProgress
+ #ifndef _NO_CRYPTO
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
+ #endif
+ #ifdef COMPRESS_MT
+ , bool mtMode, UInt32 numThreads
+ #endif
+ )
+{
+ if (!folderInfo.CheckStructure())
+ return E_NOTIMPL;
+ #ifndef _NO_CRYPTO
+ passwordIsDefined = false;
+ #endif
+ CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;
+
+ CLockedInStream lockedInStream;
+ lockedInStream.Init(inStream);
+
+ for (int j = 0; j < folderInfo.PackStreams.Size(); j++)
+ {
+ CLockedSequentialInStreamImp *lockedStreamImpSpec = new
+ CLockedSequentialInStreamImp;
+ CMyComPtr<ISequentialInStream> lockedStreamImp = lockedStreamImpSpec;
+ lockedStreamImpSpec->Init(&lockedInStream, startPos);
+ startPos += packSizes[j];
+
+ CLimitedSequentialInStream *streamSpec = new
+ CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream = streamSpec;
+ streamSpec->SetStream(lockedStreamImp);
+ streamSpec->Init(packSizes[j]);
+ inStreams.Add(inStream);
+ }
+
+ int numCoders = folderInfo.Coders.Size();
+
+ CBindInfoEx bindInfo;
+ ConvertFolderItemInfoToBindInfo(folderInfo, bindInfo);
+ bool createNewCoders;
+ if (!_bindInfoExPrevIsDefined)
+ createNewCoders = true;
+ else
+ createNewCoders = !AreBindInfoExEqual(bindInfo, _bindInfoExPrev);
+ if (createNewCoders)
+ {
+ int i;
+ _decoders.Clear();
+ // _decoders2.Clear();
+
+ _mixerCoder.Release();
+
+ if (_multiThread)
+ {
+ _mixerCoderMTSpec = new NCoderMixer::CCoderMixer2MT;
+ _mixerCoder = _mixerCoderMTSpec;
+ _mixerCoderCommon = _mixerCoderMTSpec;
+ }
+ else
+ {
+ #ifdef _ST_MODE
+ _mixerCoderSTSpec = new NCoderMixer::CCoderMixer2ST;
+ _mixerCoder = _mixerCoderSTSpec;
+ _mixerCoderCommon = _mixerCoderSTSpec;
+ #endif
+ }
+ RINOK(_mixerCoderCommon->SetBindInfo(bindInfo));
+
+ for (i = 0; i < numCoders; i++)
+ {
+ const CCoderInfo &coderInfo = folderInfo.Coders[i];
+
+
+ CMyComPtr<ICompressCoder> decoder;
+ CMyComPtr<ICompressCoder2> decoder2;
+ RINOK(CreateCoder(
+ EXTERNAL_CODECS_LOC_VARS
+ coderInfo.MethodID, decoder, decoder2, false));
+ CMyComPtr<IUnknown> decoderUnknown;
+ if (coderInfo.IsSimpleCoder())
+ {
+ if (decoder == 0)
+ return E_NOTIMPL;
+
+ decoderUnknown = (IUnknown *)decoder;
+
+ if (_multiThread)
+ _mixerCoderMTSpec->AddCoder(decoder);
+ #ifdef _ST_MODE
+ else
+ _mixerCoderSTSpec->AddCoder(decoder, false);
+ #endif
+ }
+ else
+ {
+ if (decoder2 == 0)
+ return E_NOTIMPL;
+ decoderUnknown = (IUnknown *)decoder2;
+ if (_multiThread)
+ _mixerCoderMTSpec->AddCoder2(decoder2);
+ #ifdef _ST_MODE
+ else
+ _mixerCoderSTSpec->AddCoder2(decoder2, false);
+ #endif
+ }
+ _decoders.Add(decoderUnknown);
+ #ifdef EXTERNAL_CODECS
+ CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
+ decoderUnknown.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
+ if (setCompressCodecsInfo)
+ {
+ RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecsInfo));
+ }
+ #endif
+ }
+ _bindInfoExPrev = bindInfo;
+ _bindInfoExPrevIsDefined = true;
+ }
+ int i;
+ _mixerCoderCommon->ReInit();
+
+ UInt32 packStreamIndex = 0, unpackStreamIndex = 0;
+ UInt32 coderIndex = 0;
+ // UInt32 coder2Index = 0;
+
+ for (i = 0; i < numCoders; i++)
+ {
+ const CCoderInfo &coderInfo = folderInfo.Coders[i];
+ CMyComPtr<IUnknown> &decoder = _decoders[coderIndex];
+
+ {
+ CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
+ decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
+ if (setDecoderProperties)
+ {
+ const CByteBuffer &props = coderInfo.Props;
+ size_t size = props.GetCapacity();
+ if (size > 0xFFFFFFFF)
+ return E_NOTIMPL;
+ if (size > 0)
+ {
+ RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)props, (UInt32)size));
+ }
+ }
+ }
+
+ #ifdef COMPRESS_MT
+ if (mtMode)
+ {
+ CMyComPtr<ICompressSetCoderMt> setCoderMt;
+ decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
+ if (setCoderMt)
+ {
+ RINOK(setCoderMt->SetNumberOfThreads(numThreads));
+ }
+ }
+ #endif
+
+ #ifndef _NO_CRYPTO
+ {
+ CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
+ decoder.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
+ if (cryptoSetPassword)
+ {
+ if (getTextPassword == 0)
+ return E_FAIL;
+ CMyComBSTR passwordBSTR;
+ RINOK(getTextPassword->CryptoGetTextPassword(&passwordBSTR));
+ CByteBuffer buffer;
+ passwordIsDefined = true;
+ const UString password(passwordBSTR);
+ const UInt32 sizeInBytes = password.Length() * 2;
+ buffer.SetCapacity(sizeInBytes);
+ for (int i = 0; i < password.Length(); i++)
+ {
+ wchar_t c = password[i];
+ ((Byte *)buffer)[i * 2] = (Byte)c;
+ ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
+ }
+ RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, sizeInBytes));
+ }
+ }
+ #endif
+
+ coderIndex++;
+
+ UInt32 numInStreams = (UInt32)coderInfo.NumInStreams;
+ UInt32 numOutStreams = (UInt32)coderInfo.NumOutStreams;
+ CRecordVector<const UInt64 *> packSizesPointers;
+ CRecordVector<const UInt64 *> unpackSizesPointers;
+ packSizesPointers.Reserve(numInStreams);
+ unpackSizesPointers.Reserve(numOutStreams);
+ UInt32 j;
+ for (j = 0; j < numOutStreams; j++, unpackStreamIndex++)
+ unpackSizesPointers.Add(&folderInfo.UnpackSizes[unpackStreamIndex]);
+
+ for (j = 0; j < numInStreams; j++, packStreamIndex++)
+ {
+ int bindPairIndex = folderInfo.FindBindPairForInStream(packStreamIndex);
+ if (bindPairIndex >= 0)
+ packSizesPointers.Add(
+ &folderInfo.UnpackSizes[(UInt32)folderInfo.BindPairs[bindPairIndex].OutIndex]);
+ else
+ {
+ int index = folderInfo.FindPackStreamArrayIndex(packStreamIndex);
+ if (index < 0)
+ return E_FAIL;
+ packSizesPointers.Add(&packSizes[index]);
+ }
+ }
+
+ _mixerCoderCommon->SetCoderInfo(i,
+ &packSizesPointers.Front(),
+ &unpackSizesPointers.Front());
+ }
+ UInt32 mainCoder, temp;
+ bindInfo.FindOutStream(bindInfo.OutStreams[0], mainCoder, temp);
+
+ if (_multiThread)
+ _mixerCoderMTSpec->SetProgressCoderIndex(mainCoder);
+ /*
+ else
+ _mixerCoderSTSpec->SetProgressCoderIndex(mainCoder);;
+ */
+
+ if (numCoders == 0)
+ return 0;
+ CRecordVector<ISequentialInStream *> inStreamPointers;
+ inStreamPointers.Reserve(inStreams.Size());
+ for (i = 0; i < inStreams.Size(); i++)
+ inStreamPointers.Add(inStreams[i]);
+ ISequentialOutStream *outStreamPointer = outStream;
+ return _mixerCoder->Code(&inStreamPointers.Front(), NULL,
+ inStreams.Size(), &outStreamPointer, NULL, 1, compressProgress);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zDecode.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zDecode.h
new file mode 100644
index 000000000..1057a5258
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zDecode.h
@@ -0,0 +1,68 @@
+// 7zDecode.h
+
+#ifndef __7Z_DECODE_H
+#define __7Z_DECODE_H
+
+#include "../../IStream.h"
+#include "../../IPassword.h"
+
+#include "../Common/CoderMixer2.h"
+#include "../Common/CoderMixer2MT.h"
+#ifdef _ST_MODE
+#include "../Common/CoderMixer2ST.h"
+#endif
+
+#include "../../Common/CreateCoder.h"
+
+#include "7zItem.h"
+
+namespace NArchive {
+namespace N7z {
+
+struct CBindInfoEx: public NCoderMixer::CBindInfo
+{
+ CRecordVector<CMethodId> CoderMethodIDs;
+ void Clear()
+ {
+ CBindInfo::Clear();
+ CoderMethodIDs.Clear();
+ }
+};
+
+class CDecoder
+{
+ bool _bindInfoExPrevIsDefined;
+ CBindInfoEx _bindInfoExPrev;
+
+ bool _multiThread;
+ #ifdef _ST_MODE
+ NCoderMixer::CCoderMixer2ST *_mixerCoderSTSpec;
+ #endif
+ NCoderMixer::CCoderMixer2MT *_mixerCoderMTSpec;
+ NCoderMixer::CCoderMixer2 *_mixerCoderCommon;
+
+ CMyComPtr<ICompressCoder2> _mixerCoder;
+ CObjectVector<CMyComPtr<IUnknown> > _decoders;
+ // CObjectVector<CMyComPtr<ICompressCoder2> > _decoders2;
+public:
+ CDecoder(bool multiThread);
+ HRESULT Decode(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IInStream *inStream,
+ UInt64 startPos,
+ const UInt64 *packSizes,
+ const CFolder &folder,
+ ISequentialOutStream *outStream,
+ ICompressProgressInfo *compressProgress
+ #ifndef _NO_CRYPTO
+ , ICryptoGetTextPassword *getTextPasswordSpec, bool &passwordIsDefined
+ #endif
+ #ifdef COMPRESS_MT
+ , bool mtMode, UInt32 numThreads
+ #endif
+ );
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zEncode.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zEncode.cpp
new file mode 100644
index 000000000..c97f893be
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zEncode.cpp
@@ -0,0 +1,453 @@
+// 7zEncode.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/CreateCoder.h"
+#include "../../Common/FilterCoder.h"
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/InOutTempBuffer.h"
+#include "../../Common/ProgressUtils.h"
+#include "../../Common/StreamObjects.h"
+
+#include "7zEncode.h"
+#include "7zSpecStream.h"
+
+static const UInt64 k_Delta = 0x03;
+static const UInt64 k_BCJ = 0x03030103;
+static const UInt64 k_BCJ2 = 0x0303011B;
+static const UInt64 k_AES = 0x06F10701;
+
+namespace NArchive {
+namespace N7z {
+
+static void ConvertBindInfoToFolderItemInfo(const NCoderMixer::CBindInfo &bindInfo,
+ const CRecordVector<CMethodId> decompressionMethods,
+ CFolder &folder)
+{
+ folder.Coders.Clear();
+ // bindInfo.CoderMethodIDs.Clear();
+ // folder.OutStreams.Clear();
+ folder.PackStreams.Clear();
+ folder.BindPairs.Clear();
+ int i;
+ for (i = 0; i < bindInfo.BindPairs.Size(); i++)
+ {
+ CBindPair bindPair;
+ bindPair.InIndex = bindInfo.BindPairs[i].InIndex;
+ bindPair.OutIndex = bindInfo.BindPairs[i].OutIndex;
+ folder.BindPairs.Add(bindPair);
+ }
+ for (i = 0; i < bindInfo.Coders.Size(); i++)
+ {
+ CCoderInfo coderInfo;
+ const NCoderMixer::CCoderStreamsInfo &coderStreamsInfo = bindInfo.Coders[i];
+ coderInfo.NumInStreams = coderStreamsInfo.NumInStreams;
+ coderInfo.NumOutStreams = coderStreamsInfo.NumOutStreams;
+ coderInfo.MethodID = decompressionMethods[i];
+ folder.Coders.Add(coderInfo);
+ }
+ for (i = 0; i < bindInfo.InStreams.Size(); i++)
+ folder.PackStreams.Add(bindInfo.InStreams[i]);
+}
+
+HRESULT CEncoder::CreateMixerCoder(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ const UInt64 *inSizeForReduce)
+{
+ _mixerCoderSpec = new NCoderMixer::CCoderMixer2MT;
+ _mixerCoder = _mixerCoderSpec;
+ RINOK(_mixerCoderSpec->SetBindInfo(_bindInfo));
+ for (int i = 0; i < _options.Methods.Size(); i++)
+ {
+ const CMethodFull &methodFull = _options.Methods[i];
+ _codersInfo.Add(CCoderInfo());
+ CCoderInfo &encodingInfo = _codersInfo.Back();
+ encodingInfo.MethodID = methodFull.Id;
+ CMyComPtr<ICompressCoder> encoder;
+ CMyComPtr<ICompressCoder2> encoder2;
+
+
+ RINOK(CreateCoder(
+ EXTERNAL_CODECS_LOC_VARS
+ methodFull.Id, encoder, encoder2, true));
+
+ if (!encoder && !encoder2)
+ return E_FAIL;
+
+ CMyComPtr<IUnknown> encoderCommon = encoder ? (IUnknown *)encoder : (IUnknown *)encoder2;
+
+ #ifdef COMPRESS_MT
+ {
+ CMyComPtr<ICompressSetCoderMt> setCoderMt;
+ encoderCommon.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
+ if (setCoderMt)
+ {
+ RINOK(setCoderMt->SetNumberOfThreads(_options.NumThreads));
+ }
+ }
+ #endif
+
+
+ RINOK(SetMethodProperties(methodFull, inSizeForReduce, encoderCommon));
+
+ /*
+ CMyComPtr<ICryptoResetSalt> resetSalt;
+ encoderCommon.QueryInterface(IID_ICryptoResetSalt, (void **)&resetSalt);
+ if (resetSalt != NULL)
+ {
+ resetSalt->ResetSalt();
+ }
+ */
+
+ #ifdef EXTERNAL_CODECS
+ CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
+ encoderCommon.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
+ if (setCompressCodecsInfo)
+ {
+ RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecsInfo));
+ }
+ #endif
+
+ CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
+ encoderCommon.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
+
+ if (cryptoSetPassword)
+ {
+ CByteBuffer buffer;
+ const UInt32 sizeInBytes = _options.Password.Length() * 2;
+ buffer.SetCapacity(sizeInBytes);
+ for (int i = 0; i < _options.Password.Length(); i++)
+ {
+ wchar_t c = _options.Password[i];
+ ((Byte *)buffer)[i * 2] = (Byte)c;
+ ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
+ }
+ RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, sizeInBytes));
+ }
+
+ if (encoder)
+ _mixerCoderSpec->AddCoder(encoder);
+ else
+ _mixerCoderSpec->AddCoder2(encoder2);
+ }
+ return S_OK;
+}
+
+HRESULT CEncoder::Encode(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ ISequentialInStream *inStream,
+ const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
+ CFolder &folderItem,
+ ISequentialOutStream *outStream,
+ CRecordVector<UInt64> &packSizes,
+ ICompressProgressInfo *compressProgress)
+{
+ RINOK(EncoderConstr());
+
+ if (_mixerCoderSpec == NULL)
+ {
+ RINOK(CreateMixerCoder(EXTERNAL_CODECS_LOC_VARS inSizeForReduce));
+ }
+ _mixerCoderSpec->ReInit();
+ // _mixerCoderSpec->SetCoderInfo(0, NULL, NULL, progress);
+
+ CObjectVector<CInOutTempBuffer> inOutTempBuffers;
+ CObjectVector<CSequentialOutTempBufferImp *> tempBufferSpecs;
+ CObjectVector<CMyComPtr<ISequentialOutStream> > tempBuffers;
+ int numMethods = _bindInfo.Coders.Size();
+ int i;
+ for (i = 1; i < _bindInfo.OutStreams.Size(); i++)
+ {
+ inOutTempBuffers.Add(CInOutTempBuffer());
+ inOutTempBuffers.Back().Create();
+ inOutTempBuffers.Back().InitWriting();
+ }
+ for (i = 1; i < _bindInfo.OutStreams.Size(); i++)
+ {
+ CSequentialOutTempBufferImp *tempBufferSpec =
+ new CSequentialOutTempBufferImp;
+ CMyComPtr<ISequentialOutStream> tempBuffer = tempBufferSpec;
+ tempBufferSpec->Init(&inOutTempBuffers[i - 1]);
+ tempBuffers.Add(tempBuffer);
+ tempBufferSpecs.Add(tempBufferSpec);
+ }
+
+ for (i = 0; i < numMethods; i++)
+ _mixerCoderSpec->SetCoderInfo(i, NULL, NULL);
+
+ if (_bindInfo.InStreams.IsEmpty())
+ return E_FAIL;
+ UInt32 mainCoderIndex, mainStreamIndex;
+ _bindInfo.FindInStream(_bindInfo.InStreams[0], mainCoderIndex, mainStreamIndex);
+
+ if (inStreamSize != NULL)
+ {
+ CRecordVector<const UInt64 *> sizePointers;
+ for (UInt32 i = 0; i < _bindInfo.Coders[mainCoderIndex].NumInStreams; i++)
+ if (i == mainStreamIndex)
+ sizePointers.Add(inStreamSize);
+ else
+ sizePointers.Add(NULL);
+ _mixerCoderSpec->SetCoderInfo(mainCoderIndex, &sizePointers.Front(), NULL);
+ }
+
+
+ // UInt64 outStreamStartPos;
+ // RINOK(stream->Seek(0, STREAM_SEEK_CUR, &outStreamStartPos));
+
+ CSequentialInStreamSizeCount2 *inStreamSizeCountSpec =
+ new CSequentialInStreamSizeCount2;
+ CMyComPtr<ISequentialInStream> inStreamSizeCount = inStreamSizeCountSpec;
+ CSequentialOutStreamSizeCount *outStreamSizeCountSpec =
+ new CSequentialOutStreamSizeCount;
+ CMyComPtr<ISequentialOutStream> outStreamSizeCount = outStreamSizeCountSpec;
+
+ inStreamSizeCountSpec->Init(inStream);
+ outStreamSizeCountSpec->SetStream(outStream);
+ outStreamSizeCountSpec->Init();
+
+ CRecordVector<ISequentialInStream *> inStreamPointers;
+ CRecordVector<ISequentialOutStream *> outStreamPointers;
+ inStreamPointers.Add(inStreamSizeCount);
+ outStreamPointers.Add(outStreamSizeCount);
+ for (i = 1; i < _bindInfo.OutStreams.Size(); i++)
+ outStreamPointers.Add(tempBuffers[i - 1]);
+
+ for (i = 0; i < _codersInfo.Size(); i++)
+ {
+ CCoderInfo &encodingInfo = _codersInfo[i];
+
+ CMyComPtr<ICryptoResetInitVector> resetInitVector;
+ _mixerCoderSpec->_coders[i].QueryInterface(IID_ICryptoResetInitVector, (void **)&resetInitVector);
+ if (resetInitVector != NULL)
+ {
+ resetInitVector->ResetInitVector();
+ }
+
+ CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
+ _mixerCoderSpec->_coders[i].QueryInterface(IID_ICompressWriteCoderProperties, (void **)&writeCoderProperties);
+ if (writeCoderProperties != NULL)
+ {
+ CSequentialOutStreamImp *outStreamSpec = new CSequentialOutStreamImp;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->Init();
+ writeCoderProperties->WriteCoderProperties(outStream);
+ size_t size = outStreamSpec->GetSize();
+ encodingInfo.Props.SetCapacity(size);
+ memmove(encodingInfo.Props, outStreamSpec->GetBuffer(), size);
+ }
+ }
+
+ UInt32 progressIndex = mainCoderIndex;
+
+ for (i = 0; i + 1 < _codersInfo.Size(); i++)
+ {
+ UInt64 m = _codersInfo[i].MethodID;
+ if (m == k_Delta || m == k_BCJ || m == k_BCJ2)
+ progressIndex = i + 1;
+ }
+
+ _mixerCoderSpec->SetProgressCoderIndex(progressIndex);
+
+ RINOK(_mixerCoder->Code(&inStreamPointers.Front(), NULL, 1,
+ &outStreamPointers.Front(), NULL, outStreamPointers.Size(), compressProgress));
+
+ ConvertBindInfoToFolderItemInfo(_decompressBindInfo, _decompressionMethods,
+ folderItem);
+
+ packSizes.Add(outStreamSizeCountSpec->GetSize());
+
+ for (i = 1; i < _bindInfo.OutStreams.Size(); i++)
+ {
+ CInOutTempBuffer &inOutTempBuffer = inOutTempBuffers[i - 1];
+ inOutTempBuffer.FlushWrite();
+ inOutTempBuffer.InitReading();
+ inOutTempBuffer.WriteToStream(outStream);
+ packSizes.Add(inOutTempBuffer.GetDataSize());
+ }
+
+ for (i = 0; i < (int)_bindReverseConverter->NumSrcInStreams; i++)
+ {
+ int binder = _bindInfo.FindBinderForInStream(
+ _bindReverseConverter->DestOutToSrcInMap[i]);
+ UInt64 streamSize;
+ if (binder < 0)
+ streamSize = inStreamSizeCountSpec->GetSize();
+ else
+ streamSize = _mixerCoderSpec->GetWriteProcessedSize(binder);
+ folderItem.UnpackSizes.Add(streamSize);
+ }
+ for (i = numMethods - 1; i >= 0; i--)
+ folderItem.Coders[numMethods - 1 - i].Props = _codersInfo[i].Props;
+ return S_OK;
+}
+
+
+CEncoder::CEncoder(const CCompressionMethodMode &options):
+ _bindReverseConverter(0),
+ _constructed(false)
+{
+ if (options.IsEmpty())
+ throw 1;
+
+ _options = options;
+ _mixerCoderSpec = NULL;
+}
+
+HRESULT CEncoder::EncoderConstr()
+{
+ if (_constructed)
+ return S_OK;
+ if (_options.Methods.IsEmpty())
+ {
+ // it has only password method;
+ if (!_options.PasswordIsDefined)
+ throw 1;
+ if (!_options.Binds.IsEmpty())
+ throw 1;
+ NCoderMixer::CCoderStreamsInfo coderStreamsInfo;
+ CMethodFull method;
+
+ method.NumInStreams = 1;
+ method.NumOutStreams = 1;
+ coderStreamsInfo.NumInStreams = 1;
+ coderStreamsInfo.NumOutStreams = 1;
+ method.Id = k_AES;
+
+ _options.Methods.Add(method);
+ _bindInfo.Coders.Add(coderStreamsInfo);
+
+ _bindInfo.InStreams.Add(0);
+ _bindInfo.OutStreams.Add(0);
+ }
+ else
+ {
+
+ UInt32 numInStreams = 0, numOutStreams = 0;
+ int i;
+ for (i = 0; i < _options.Methods.Size(); i++)
+ {
+ const CMethodFull &methodFull = _options.Methods[i];
+ NCoderMixer::CCoderStreamsInfo coderStreamsInfo;
+ coderStreamsInfo.NumInStreams = methodFull.NumOutStreams;
+ coderStreamsInfo.NumOutStreams = methodFull.NumInStreams;
+ if (_options.Binds.IsEmpty())
+ {
+ if (i < _options.Methods.Size() - 1)
+ {
+ NCoderMixer::CBindPair bindPair;
+ bindPair.InIndex = numInStreams + coderStreamsInfo.NumInStreams;
+ bindPair.OutIndex = numOutStreams;
+ _bindInfo.BindPairs.Add(bindPair);
+ }
+ else
+ _bindInfo.OutStreams.Insert(0, numOutStreams);
+ for (UInt32 j = 1; j < coderStreamsInfo.NumOutStreams; j++)
+ _bindInfo.OutStreams.Add(numOutStreams + j);
+ }
+
+ numInStreams += coderStreamsInfo.NumInStreams;
+ numOutStreams += coderStreamsInfo.NumOutStreams;
+
+ _bindInfo.Coders.Add(coderStreamsInfo);
+ }
+
+ if (!_options.Binds.IsEmpty())
+ {
+ for (i = 0; i < _options.Binds.Size(); i++)
+ {
+ NCoderMixer::CBindPair bindPair;
+ const CBind &bind = _options.Binds[i];
+ bindPair.InIndex = _bindInfo.GetCoderInStreamIndex(bind.InCoder) + bind.InStream;
+ bindPair.OutIndex = _bindInfo.GetCoderOutStreamIndex(bind.OutCoder) + bind.OutStream;
+ _bindInfo.BindPairs.Add(bindPair);
+ }
+ for (i = 0; i < (int)numOutStreams; i++)
+ if (_bindInfo.FindBinderForOutStream(i) == -1)
+ _bindInfo.OutStreams.Add(i);
+ }
+
+ for (i = 0; i < (int)numInStreams; i++)
+ if (_bindInfo.FindBinderForInStream(i) == -1)
+ _bindInfo.InStreams.Add(i);
+
+ if (_bindInfo.InStreams.IsEmpty())
+ throw 1; // this is error
+
+ // Make main stream first in list
+ int inIndex = _bindInfo.InStreams[0];
+ for (;;)
+ {
+ UInt32 coderIndex, coderStreamIndex;
+ _bindInfo.FindInStream(inIndex, coderIndex, coderStreamIndex);
+ UInt32 outIndex = _bindInfo.GetCoderOutStreamIndex(coderIndex);
+ int binder = _bindInfo.FindBinderForOutStream(outIndex);
+ if (binder >= 0)
+ {
+ inIndex = _bindInfo.BindPairs[binder].InIndex;
+ continue;
+ }
+ for (i = 0; i < _bindInfo.OutStreams.Size(); i++)
+ if (_bindInfo.OutStreams[i] == outIndex)
+ {
+ _bindInfo.OutStreams.Delete(i);
+ _bindInfo.OutStreams.Insert(0, outIndex);
+ break;
+ }
+ break;
+ }
+
+ if (_options.PasswordIsDefined)
+ {
+ int numCryptoStreams = _bindInfo.OutStreams.Size();
+
+ for (i = 0; i < numCryptoStreams; i++)
+ {
+ NCoderMixer::CBindPair bindPair;
+ bindPair.InIndex = numInStreams + i;
+ bindPair.OutIndex = _bindInfo.OutStreams[i];
+ _bindInfo.BindPairs.Add(bindPair);
+ }
+ _bindInfo.OutStreams.Clear();
+
+ /*
+ if (numCryptoStreams == 0)
+ numCryptoStreams = 1;
+ */
+
+ for (i = 0; i < numCryptoStreams; i++)
+ {
+ NCoderMixer::CCoderStreamsInfo coderStreamsInfo;
+ CMethodFull method;
+ method.NumInStreams = 1;
+ method.NumOutStreams = 1;
+ coderStreamsInfo.NumInStreams = method.NumOutStreams;
+ coderStreamsInfo.NumOutStreams = method.NumInStreams;
+ method.Id = k_AES;
+
+ _options.Methods.Add(method);
+ _bindInfo.Coders.Add(coderStreamsInfo);
+ _bindInfo.OutStreams.Add(numOutStreams + i);
+ }
+ }
+
+ }
+
+ for (int i = _options.Methods.Size() - 1; i >= 0; i--)
+ {
+ const CMethodFull &methodFull = _options.Methods[i];
+ _decompressionMethods.Add(methodFull.Id);
+ }
+
+ _bindReverseConverter = new NCoderMixer::CBindReverseConverter(_bindInfo);
+ _bindReverseConverter->CreateReverseBindInfo(_decompressBindInfo);
+ _constructed = true;
+ return S_OK;
+}
+
+CEncoder::~CEncoder()
+{
+ delete _bindReverseConverter;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zEncode.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zEncode.h
new file mode 100644
index 000000000..4909a6e89
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zEncode.h
@@ -0,0 +1,55 @@
+// 7zEncode.h
+
+#ifndef __7Z_ENCODE_H
+#define __7Z_ENCODE_H
+
+// #include "../../Common/StreamObjects.h"
+
+#include "7zCompressionMode.h"
+
+#include "../Common/CoderMixer2.h"
+#include "../Common/CoderMixer2MT.h"
+#ifdef _ST_MODE
+#include "../Common/CoderMixer2ST.h"
+#endif
+#include "7zItem.h"
+
+#include "../../Common/CreateCoder.h"
+
+namespace NArchive {
+namespace N7z {
+
+class CEncoder
+{
+ NCoderMixer::CCoderMixer2MT *_mixerCoderSpec;
+ CMyComPtr<ICompressCoder2> _mixerCoder;
+
+ CObjectVector<CCoderInfo> _codersInfo;
+
+ CCompressionMethodMode _options;
+ NCoderMixer::CBindInfo _bindInfo;
+ NCoderMixer::CBindInfo _decompressBindInfo;
+ NCoderMixer::CBindReverseConverter *_bindReverseConverter;
+ CRecordVector<CMethodId> _decompressionMethods;
+
+ HRESULT CreateMixerCoder(DECL_EXTERNAL_CODECS_LOC_VARS
+ const UInt64 *inSizeForReduce);
+
+ bool _constructed;
+public:
+ CEncoder(const CCompressionMethodMode &options);
+ ~CEncoder();
+ HRESULT EncoderConstr();
+ HRESULT Encode(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ ISequentialInStream *inStream,
+ const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
+ CFolder &folderItem,
+ ISequentialOutStream *outStream,
+ CRecordVector<UInt64> &packSizes,
+ ICompressProgressInfo *compressProgress);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zExtract.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zExtract.cpp
new file mode 100644
index 000000000..06e9ef979
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zExtract.cpp
@@ -0,0 +1,273 @@
+// 7zExtract.cpp
+
+#include "StdAfx.h"
+
+#include "7zHandler.h"
+#include "7zFolderOutStream.h"
+#include "7zDecode.h"
+// #include "7z1Decode.h"
+
+#include "../../../Common/ComTry.h"
+#include "../../Common/StreamObjects.h"
+#include "../../Common/ProgressUtils.h"
+#include "../../Common/LimitedStreams.h"
+
+namespace NArchive {
+namespace N7z {
+
+struct CExtractFolderInfo
+{
+ #ifdef _7Z_VOL
+ int VolumeIndex;
+ #endif
+ CNum FileIndex;
+ CNum FolderIndex;
+ CBoolVector ExtractStatuses;
+ UInt64 UnpackSize;
+ CExtractFolderInfo(
+ #ifdef _7Z_VOL
+ int volumeIndex,
+ #endif
+ CNum fileIndex, CNum folderIndex):
+ #ifdef _7Z_VOL
+ VolumeIndex(volumeIndex),
+ #endif
+ FileIndex(fileIndex),
+ FolderIndex(folderIndex),
+ UnpackSize(0)
+ {
+ if (fileIndex != kNumNoIndex)
+ {
+ ExtractStatuses.Reserve(1);
+ ExtractStatuses.Add(true);
+ }
+ };
+};
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 testModeSpec, IArchiveExtractCallback *extractCallbackSpec)
+{
+ COM_TRY_BEGIN
+ bool testMode = (testModeSpec != 0);
+ CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
+ UInt64 importantTotalUnpacked = 0;
+
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems =
+ #ifdef _7Z_VOL
+ _refs.Size();
+ #else
+ _db.Files.Size();
+ #endif
+
+ if(numItems == 0)
+ return S_OK;
+
+ /*
+ if(_volumes.Size() != 1)
+ return E_FAIL;
+ const CVolume &volume = _volumes.Front();
+ const CArchiveDatabaseEx &_db = volume.Database;
+ IInStream *_inStream = volume.Stream;
+ */
+
+ CObjectVector<CExtractFolderInfo> extractFolderInfoVector;
+ for(UInt32 ii = 0; ii < numItems; ii++)
+ {
+ // UInt32 fileIndex = allFilesMode ? indexIndex : indices[indexIndex];
+ UInt32 ref2Index = allFilesMode ? ii : indices[ii];
+ // const CRef2 &ref2 = _refs[ref2Index];
+
+ // for(UInt32 ri = 0; ri < ref2.Refs.Size(); ri++)
+ {
+ #ifdef _7Z_VOL
+ // const CRef &ref = ref2.Refs[ri];
+ const CRef &ref = _refs[ref2Index];
+
+ int volumeIndex = ref.VolumeIndex;
+ const CVolume &volume = _volumes[volumeIndex];
+ const CArchiveDatabaseEx &db = volume.Database;
+ UInt32 fileIndex = ref.ItemIndex;
+ #else
+ const CArchiveDatabaseEx &db = _db;
+ UInt32 fileIndex = ref2Index;
+ #endif
+
+ CNum folderIndex = db.FileIndexToFolderIndexMap[fileIndex];
+ if (folderIndex == kNumNoIndex)
+ {
+ extractFolderInfoVector.Add(CExtractFolderInfo(
+ #ifdef _7Z_VOL
+ volumeIndex,
+ #endif
+ fileIndex, kNumNoIndex));
+ continue;
+ }
+ if (extractFolderInfoVector.IsEmpty() ||
+ folderIndex != extractFolderInfoVector.Back().FolderIndex
+ #ifdef _7Z_VOL
+ || volumeIndex != extractFolderInfoVector.Back().VolumeIndex
+ #endif
+ )
+ {
+ extractFolderInfoVector.Add(CExtractFolderInfo(
+ #ifdef _7Z_VOL
+ volumeIndex,
+ #endif
+ kNumNoIndex, folderIndex));
+ const CFolder &folderInfo = db.Folders[folderIndex];
+ UInt64 unpackSize = folderInfo.GetUnpackSize();
+ importantTotalUnpacked += unpackSize;
+ extractFolderInfoVector.Back().UnpackSize = unpackSize;
+ }
+
+ CExtractFolderInfo &efi = extractFolderInfoVector.Back();
+
+ // const CFolderInfo &folderInfo = m_dam_Folders[folderIndex];
+ CNum startIndex = db.FolderStartFileIndex[folderIndex];
+ for (CNum index = efi.ExtractStatuses.Size();
+ index <= fileIndex - startIndex; index++)
+ {
+ // UInt64 unpackSize = _db.Files[startIndex + index].UnpackSize;
+ // Count partial_folder_size
+ // efi.UnpackSize += unpackSize;
+ // importantTotalUnpacked += unpackSize;
+ efi.ExtractStatuses.Add(index == fileIndex - startIndex);
+ }
+ }
+ }
+
+ extractCallback->SetTotal(importantTotalUnpacked);
+
+ CDecoder decoder(
+ #ifdef _ST_MODE
+ false
+ #else
+ true
+ #endif
+ );
+ // CDecoder1 decoder;
+
+ UInt64 currentTotalPacked = 0;
+ UInt64 currentTotalUnpacked = 0;
+ UInt64 totalFolderUnpacked;
+ UInt64 totalFolderPacked;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ for(int i = 0; i < extractFolderInfoVector.Size(); i++,
+ currentTotalUnpacked += totalFolderUnpacked,
+ currentTotalPacked += totalFolderPacked)
+ {
+ lps->OutSize = currentTotalUnpacked;
+ lps->InSize = currentTotalPacked;
+ RINOK(lps->SetCur());
+
+ const CExtractFolderInfo &efi = extractFolderInfoVector[i];
+ totalFolderUnpacked = efi.UnpackSize;
+
+ totalFolderPacked = 0;
+
+ CFolderOutStream *folderOutStream = new CFolderOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(folderOutStream);
+
+ #ifdef _7Z_VOL
+ const CVolume &volume = _volumes[efi.VolumeIndex];
+ const CArchiveDatabaseEx &db = volume.Database;
+ #else
+ const CArchiveDatabaseEx &db = _db;
+ #endif
+
+ CNum startIndex;
+ if (efi.FileIndex != kNumNoIndex)
+ startIndex = efi.FileIndex;
+ else
+ startIndex = db.FolderStartFileIndex[efi.FolderIndex];
+
+
+ HRESULT result = folderOutStream->Init(&db,
+ #ifdef _7Z_VOL
+ volume.StartRef2Index,
+ #else
+ 0,
+ #endif
+ startIndex,
+ &efi.ExtractStatuses, extractCallback, testMode, _crcSize != 0);
+
+ RINOK(result);
+
+ if (efi.FileIndex != kNumNoIndex)
+ continue;
+
+ CNum folderIndex = efi.FolderIndex;
+ const CFolder &folderInfo = db.Folders[folderIndex];
+
+ totalFolderPacked = _db.GetFolderFullPackSize(folderIndex);
+
+ CNum packStreamIndex = db.FolderStartPackStreamIndex[folderIndex];
+ UInt64 folderStartPackPos = db.GetFolderStreamPos(folderIndex, 0);
+
+ #ifndef _NO_CRYPTO
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
+ if (extractCallback)
+ extractCallback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
+ #endif
+
+ try
+ {
+ #ifndef _NO_CRYPTO
+ bool passwordIsDefined;
+ #endif
+
+ HRESULT result = decoder.Decode(
+ EXTERNAL_CODECS_VARS
+ #ifdef _7Z_VOL
+ volume.Stream,
+ #else
+ _inStream,
+ #endif
+ folderStartPackPos,
+ &db.PackSizes[packStreamIndex],
+ folderInfo,
+ outStream,
+ progress
+ #ifndef _NO_CRYPTO
+ , getTextPassword, passwordIsDefined
+ #endif
+ #ifdef COMPRESS_MT
+ , true, _numThreads
+ #endif
+ );
+
+ if (result == S_FALSE)
+ {
+ RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError));
+ continue;
+ }
+ if (result == E_NOTIMPL)
+ {
+ RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ continue;
+ }
+ if (result != S_OK)
+ return result;
+ if (folderOutStream->WasWritingFinished() != S_OK)
+ {
+ RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError));
+ continue;
+ }
+ }
+ catch(...)
+ {
+ RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError));
+ continue;
+ }
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderInStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderInStream.cpp
new file mode 100644
index 000000000..6dcce665b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderInStream.cpp
@@ -0,0 +1,130 @@
+// 7zFolderInStream.cpp
+
+#include "StdAfx.h"
+
+#include "7zFolderInStream.h"
+
+namespace NArchive {
+namespace N7z {
+
+CFolderInStream::CFolderInStream()
+{
+ _inStreamWithHashSpec = new CSequentialInStreamWithCRC;
+ _inStreamWithHash = _inStreamWithHashSpec;
+}
+
+void CFolderInStream::Init(IArchiveUpdateCallback *updateCallback,
+ const UInt32 *fileIndices, UInt32 numFiles)
+{
+ _updateCallback = updateCallback;
+ _numFiles = numFiles;
+ _fileIndex = 0;
+ _fileIndices = fileIndices;
+ Processed.Clear();
+ CRCs.Clear();
+ Sizes.Clear();
+ _fileIsOpen = false;
+ _currentSizeIsDefined = false;
+}
+
+HRESULT CFolderInStream::OpenStream()
+{
+ _filePos = 0;
+ while (_fileIndex < _numFiles)
+ {
+ _currentSizeIsDefined = false;
+ CMyComPtr<ISequentialInStream> stream;
+ HRESULT result = _updateCallback->GetStream(_fileIndices[_fileIndex], &stream);
+ if (result != S_OK && result != S_FALSE)
+ return result;
+ _fileIndex++;
+ _inStreamWithHashSpec->SetStream(stream);
+ _inStreamWithHashSpec->Init();
+ if (!stream)
+ {
+ RINOK(_updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ Sizes.Add(0);
+ Processed.Add(result == S_OK);
+ AddDigest();
+ continue;
+ }
+ CMyComPtr<IStreamGetSize> streamGetSize;
+ if (stream.QueryInterface(IID_IStreamGetSize, &streamGetSize) == S_OK)
+ {
+ if(streamGetSize)
+ {
+ _currentSizeIsDefined = true;
+ RINOK(streamGetSize->GetSize(&_currentSize));
+ }
+ }
+
+ _fileIsOpen = true;
+ return S_OK;
+ }
+ return S_OK;
+}
+
+void CFolderInStream::AddDigest()
+{
+ CRCs.Add(_inStreamWithHashSpec->GetCRC());
+}
+
+HRESULT CFolderInStream::CloseStream()
+{
+ RINOK(_updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ _inStreamWithHashSpec->ReleaseStream();
+ _fileIsOpen = false;
+ Processed.Add(true);
+ Sizes.Add(_filePos);
+ AddDigest();
+ return S_OK;
+}
+
+STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize = 0;
+ while ((_fileIndex < _numFiles || _fileIsOpen) && size > 0)
+ {
+ if (_fileIsOpen)
+ {
+ UInt32 localProcessedSize;
+ RINOK(_inStreamWithHash->Read(
+ ((Byte *)data) + realProcessedSize, size, &localProcessedSize));
+ if (localProcessedSize == 0)
+ {
+ RINOK(CloseStream());
+ continue;
+ }
+ realProcessedSize += localProcessedSize;
+ _filePos += localProcessedSize;
+ size -= localProcessedSize;
+ break;
+ }
+ else
+ {
+ RINOK(OpenStream());
+ }
+ }
+ if (processedSize != 0)
+ *processedSize = realProcessedSize;
+ return S_OK;
+}
+
+STDMETHODIMP CFolderInStream::GetSubStreamSize(UInt64 subStream, UInt64 *value)
+{
+ *value = 0;
+ int subStreamIndex = (int)subStream;
+ if (subStreamIndex < 0 || static_cast< Int64 >( subStream ) > Sizes.Size())
+ return E_FAIL;
+ if (subStreamIndex < Sizes.Size())
+ {
+ *value= Sizes[subStreamIndex];
+ return S_OK;
+ }
+ if (!_currentSizeIsDefined)
+ return S_FALSE;
+ *value = _currentSize;
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderInStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderInStream.h
new file mode 100644
index 000000000..68e2b27ba
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderInStream.h
@@ -0,0 +1,66 @@
+// 7z/FolderInStream.h
+
+#ifndef __7Z_FOLDERINSTREAM_H
+#define __7Z_FOLDERINSTREAM_H
+
+#include "7zItem.h"
+#include "7zHeader.h"
+
+#include "../IArchive.h"
+#include "../Common/InStreamWithCRC.h"
+#include "../../IStream.h"
+#include "../../ICoder.h"
+
+namespace NArchive {
+namespace N7z {
+
+class CFolderInStream:
+ public ISequentialInStream,
+ public ICompressGetSubStreamSize,
+ public CMyUnknownImp
+{
+public:
+
+ MY_UNKNOWN_IMP1(ICompressGetSubStreamSize)
+
+ CFolderInStream();
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+
+ STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value);
+private:
+ CSequentialInStreamWithCRC *_inStreamWithHashSpec;
+ CMyComPtr<ISequentialInStream> _inStreamWithHash;
+ CMyComPtr<IArchiveUpdateCallback> _updateCallback;
+
+ bool _currentSizeIsDefined;
+ UInt64 _currentSize;
+
+ bool _fileIsOpen;
+ UInt64 _filePos;
+
+ const UInt32 *_fileIndices;
+ UInt32 _numFiles;
+ UInt32 _fileIndex;
+
+ HRESULT OpenStream();
+ HRESULT CloseStream();
+ void AddDigest();
+public:
+ void Init(IArchiveUpdateCallback *updateCallback,
+ const UInt32 *fileIndices, UInt32 numFiles);
+ CRecordVector<bool> Processed;
+ CRecordVector<UInt32> CRCs;
+ CRecordVector<UInt64> Sizes;
+ UInt64 GetFullSize() const
+ {
+ UInt64 size = 0;
+ for (int i = 0; i < Sizes.Size(); i++)
+ size += Sizes[i];
+ return size;
+ }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderOutStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
new file mode 100644
index 000000000..755058638
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
@@ -0,0 +1,140 @@
+// 7zFolderOutStream.cpp
+
+#include "StdAfx.h"
+
+#include "7zFolderOutStream.h"
+
+namespace NArchive {
+namespace N7z {
+
+CFolderOutStream::CFolderOutStream()
+{
+ _crcStreamSpec = new COutStreamWithCRC;
+ _crcStream = _crcStreamSpec;
+}
+
+HRESULT CFolderOutStream::Init(
+ const CArchiveDatabaseEx *archiveDatabase,
+ UInt32 ref2Offset, UInt32 startIndex,
+ const CBoolVector *extractStatuses,
+ IArchiveExtractCallback *extractCallback,
+ bool testMode, bool checkCrc)
+{
+ _db = archiveDatabase;
+ _ref2Offset = ref2Offset;
+ _startIndex = startIndex;
+
+ _extractStatuses = extractStatuses;
+ _extractCallback = extractCallback;
+ _testMode = testMode;
+ _checkCrc = checkCrc;
+
+ _currentIndex = 0;
+ _fileIsOpen = false;
+ return ProcessEmptyFiles();
+}
+
+HRESULT CFolderOutStream::OpenFile()
+{
+ Int32 askMode = ((*_extractStatuses)[_currentIndex]) ? (_testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract):
+ NArchive::NExtract::NAskMode::kSkip;
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ UInt32 index = _startIndex + _currentIndex;
+ RINOK(_extractCallback->GetStream(_ref2Offset + index, &realOutStream, askMode));
+ _crcStreamSpec->SetStream(realOutStream);
+ _crcStreamSpec->Init(_checkCrc);
+ _fileIsOpen = true;
+ const CFileItem &fi = _db->Files[index];
+ _rem = fi.Size;
+ if (askMode == NArchive::NExtract::NAskMode::kExtract && !realOutStream &&
+ !_db->IsItemAnti(index) && !fi.IsDir)
+ askMode = NArchive::NExtract::NAskMode::kSkip;
+ return _extractCallback->PrepareOperation(askMode);
+}
+
+HRESULT CFolderOutStream::CloseFileAndSetResult(Int32 res)
+{
+ _crcStreamSpec->ReleaseStream();
+ _fileIsOpen = false;
+ _currentIndex++;
+ return _extractCallback->SetOperationResult(res);
+}
+
+HRESULT CFolderOutStream::CloseFileAndSetResult()
+{
+ const CFileItem &fi = _db->Files[_startIndex + _currentIndex];
+ return CloseFileAndSetResult(
+ (fi.IsDir || !fi.CrcDefined || !_checkCrc || fi.Crc == _crcStreamSpec->GetCRC()) ?
+ NArchive::NExtract::NOperationResult::kOK :
+ NArchive::NExtract::NOperationResult::kCRCError);
+}
+
+HRESULT CFolderOutStream::ProcessEmptyFiles()
+{
+ while (_currentIndex < _extractStatuses->Size() && _db->Files[_startIndex + _currentIndex].Size == 0)
+ {
+ RINOK(OpenFile());
+ RINOK(CloseFileAndSetResult());
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ while (size != 0)
+ {
+ if (_fileIsOpen)
+ {
+ UInt32 cur = size < _rem ? size : (UInt32)_rem;
+ RINOK(_crcStream->Write(data, cur, &cur));
+ if (cur == 0)
+ break;
+ data = (const Byte *)data + cur;
+ size -= cur;
+ _rem -= cur;
+ if (processedSize != NULL)
+ *processedSize += cur;
+ if (_rem == 0)
+ {
+ RINOK(CloseFileAndSetResult());
+ RINOK(ProcessEmptyFiles());
+ continue;
+ }
+ }
+ else
+ {
+ RINOK(ProcessEmptyFiles());
+ if (_currentIndex == _extractStatuses->Size())
+ {
+ // we support partial extracting
+ if (processedSize != NULL)
+ *processedSize += size;
+ break;
+ }
+ RINOK(OpenFile());
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CFolderOutStream::FlushCorrupted(Int32 resultEOperationResult)
+{
+ while (_currentIndex < _extractStatuses->Size())
+ {
+ if (_fileIsOpen)
+ {
+ RINOK(CloseFileAndSetResult(resultEOperationResult));
+ }
+ else
+ {
+ RINOK(OpenFile());
+ }
+ }
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderOutStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderOutStream.h
new file mode 100644
index 000000000..e6e05b85c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zFolderOutStream.h
@@ -0,0 +1,56 @@
+// 7zFolderOutStream.h
+
+#ifndef __7Z_FOLDER_OUT_STREAM_H
+#define __7Z_FOLDER_OUT_STREAM_H
+
+#include "7zIn.h"
+
+#include "../../IStream.h"
+#include "../IArchive.h"
+#include "../Common/OutStreamWithCRC.h"
+
+namespace NArchive {
+namespace N7z {
+
+class CFolderOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ COutStreamWithCRC *_crcStreamSpec;
+ CMyComPtr<ISequentialOutStream> _crcStream;
+ const CArchiveDatabaseEx *_db;
+ const CBoolVector *_extractStatuses;
+ CMyComPtr<IArchiveExtractCallback> _extractCallback;
+ UInt32 _ref2Offset;
+ UInt32 _startIndex;
+ int _currentIndex;
+ bool _testMode;
+ bool _checkCrc;
+ bool _fileIsOpen;
+ UInt64 _rem;
+
+ HRESULT OpenFile();
+ HRESULT CloseFileAndSetResult(Int32 res);
+ HRESULT CloseFileAndSetResult();
+ HRESULT ProcessEmptyFiles();
+public:
+ MY_UNKNOWN_IMP
+
+ CFolderOutStream();
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+
+ HRESULT Init(
+ const CArchiveDatabaseEx *archiveDatabase,
+ UInt32 ref2Offset, UInt32 startIndex,
+ const CBoolVector *extractStatuses,
+ IArchiveExtractCallback *extractCallback,
+ bool testMode, bool checkCrc);
+ HRESULT FlushCorrupted(Int32 resultEOperationResult);
+ HRESULT WasWritingFinished() const
+ { return (_currentIndex == _extractStatuses->Size()) ? S_OK: E_FAIL; }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandler.cpp
new file mode 100644
index 000000000..6f0cf6b2d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandler.cpp
@@ -0,0 +1,493 @@
+// 7zHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/CpuArch.h"
+
+#include "../../../Common/ComTry.h"
+#include "../../../Common/IntToString.h"
+
+#ifdef COMPRESS_MT
+#include "../../../Windows/System.h"
+#endif
+
+#include "../Common/ItemNameUtils.h"
+
+#include "7zHandler.h"
+#include "7zProperties.h"
+
+#ifdef __7Z_SET_PROPERTIES
+#ifdef EXTRACT_ONLY
+#include "../Common/ParseProperties.h"
+#endif
+#endif
+
+using namespace NWindows;
+
+extern UString ConvertMethodIdToString(UInt64 id);
+
+namespace NArchive {
+namespace N7z {
+
+CHandler::CHandler()
+{
+ _crcSize = 4;
+
+ #ifndef _NO_CRYPTO
+ _passwordIsDefined = false;
+ #endif
+
+ #ifdef EXTRACT_ONLY
+ #ifdef COMPRESS_MT
+ _numThreads = NSystem::GetNumberOfProcessors();
+ #endif
+ #else
+ Init();
+ #endif
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _db.Files.Size();
+ return S_OK;
+}
+
+#ifdef _SFX
+
+IMP_IInArchive_ArcProps_NO
+
+STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 * /* numProperties */)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CHandler::GetPropertyInfo(UInt32 /* index */,
+ BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */)
+{
+ return E_NOTIMPL;
+}
+
+
+#else
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidSolid, VT_BOOL},
+ { NULL, kpidNumBlocks, VT_UI4},
+ { NULL, kpidPhySize, VT_UI8},
+ { NULL, kpidHeadersSize, VT_UI8},
+ { NULL, kpidOffset, VT_UI8}
+};
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ UString resString;
+ CRecordVector<UInt64> ids;
+ int i;
+ for (i = 0; i < _db.Folders.Size(); i++)
+ {
+ const CFolder &f = _db.Folders[i];
+ for (int j = f.Coders.Size() - 1; j >= 0; j--)
+ ids.AddToUniqueSorted(f.Coders[j].MethodID);
+ }
+
+ for (i = 0; i < ids.Size(); i++)
+ {
+ UInt64 id = ids[i];
+ UString methodName;
+ /* bool methodIsKnown = */ FindMethod(EXTERNAL_CODECS_VARS id, methodName);
+ if (methodName.IsEmpty())
+ methodName = ConvertMethodIdToString(id);
+ if (!resString.IsEmpty())
+ resString += L' ';
+ resString += methodName;
+ }
+ prop = resString;
+ break;
+ }
+ case kpidSolid: prop = _db.IsSolid(); break;
+ case kpidNumBlocks: prop = (UInt32)_db.Folders.Size(); break;
+ case kpidHeadersSize: prop = _db.HeadersSize; break;
+ case kpidPhySize: prop = _db.PhySize; break;
+ case kpidOffset: if (_db.ArchiveInfo.StartPosition != 0) prop = _db.ArchiveInfo.StartPosition; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+IMP_IInArchive_ArcProps
+
+#endif
+
+static void SetPropFromUInt64Def(CUInt64DefVector &v, int index, NCOM::CPropVariant &prop)
+{
+ UInt64 value;
+ if (v.GetItem(index, value))
+ {
+ FILETIME ft;
+ ft.dwLowDateTime = (DWORD)value;
+ ft.dwHighDateTime = (DWORD)(value >> 32);
+ prop = ft;
+ }
+}
+
+#ifndef _SFX
+
+static UString ConvertUInt32ToString(UInt32 value)
+{
+ wchar_t buffer[32];
+ ConvertUInt64ToString(value, buffer);
+ return buffer;
+}
+
+static UString GetStringForSizeValue(UInt32 value)
+{
+ for (int i = 31; i >= 0; i--)
+ if ((UInt32(1) << i) == value)
+ return ConvertUInt32ToString(i);
+ UString result;
+ if (value % (1 << 20) == 0)
+ {
+ result += ConvertUInt32ToString(value >> 20);
+ result += L"m";
+ }
+ else if (value % (1 << 10) == 0)
+ {
+ result += ConvertUInt32ToString(value >> 10);
+ result += L"k";
+ }
+ else
+ {
+ result += ConvertUInt32ToString(value);
+ result += L"b";
+ }
+ return result;
+}
+
+static const UInt64 k_Copy = 0x0;
+static const UInt64 k_Delta = 3;
+static const UInt64 k_LZMA2 = 0x21;
+static const UInt64 k_LZMA = 0x030101;
+static const UInt64 k_PPMD = 0x030401;
+
+static wchar_t GetHex(Byte value)
+{
+ return (wchar_t)((value < 10) ? (L'0' + value) : (L'A' + (value - 10)));
+}
+static inline void AddHexToString(UString &res, Byte value)
+{
+ res += GetHex((Byte)(value >> 4));
+ res += GetHex((Byte)(value & 0xF));
+}
+
+#endif
+
+static const UInt64 k_AES = 0x06F10701;
+
+bool CHandler::IsEncrypted(UInt32 index2) const
+{
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
+ if (folderIndex != kNumNoIndex)
+ {
+ const CFolder &folderInfo = _db.Folders[folderIndex];
+ for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
+ if (folderInfo.Coders[i].MethodID == k_AES)
+ return true;
+ }
+ return false;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+
+ /*
+ const CRef2 &ref2 = _refs[index];
+ if (ref2.Refs.IsEmpty())
+ return E_FAIL;
+ const CRef &ref = ref2.Refs.Front();
+ */
+
+ const CFileItem &item = _db.Files[index];
+ UInt32 index2 = index;
+
+ switch(propID)
+ {
+ case kpidPath:
+ if (!item.Name.IsEmpty())
+ prop = NItemName::GetOSName(item.Name);
+ break;
+ case kpidIsDir: prop = item.IsDir; break;
+ case kpidSize:
+ {
+ prop = item.Size;
+ // prop = ref2.Size;
+ break;
+ }
+ case kpidPackSize:
+ {
+ // prop = ref2.PackSize;
+ {
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
+ if (folderIndex != kNumNoIndex)
+ {
+ if (_db.FolderStartFileIndex[folderIndex] == (CNum)index2)
+ prop = _db.GetFolderFullPackSize(folderIndex);
+ /*
+ else
+ prop = (UInt64)0;
+ */
+ }
+ else
+ prop = (UInt64)0;
+ }
+ break;
+ }
+ case kpidPosition: { UInt64 v; if (_db.StartPos.GetItem(index2, v)) prop = v; break; }
+ case kpidCTime: SetPropFromUInt64Def(_db.CTime, index2, prop); break;
+ case kpidATime: SetPropFromUInt64Def(_db.ATime, index2, prop); break;
+ case kpidMTime: SetPropFromUInt64Def(_db.MTime, index2, prop); break;
+ case kpidAttrib: if (item.AttribDefined) prop = item.Attrib; break;
+ case kpidCRC: if (item.CrcDefined) prop = item.Crc; break;
+ case kpidEncrypted: prop = IsEncrypted(index2); break;
+ case kpidIsAnti: prop = _db.IsItemAnti(index2); break;
+ #ifndef _SFX
+ case kpidMethod:
+ {
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
+ if (folderIndex != kNumNoIndex)
+ {
+ const CFolder &folderInfo = _db.Folders[folderIndex];
+ UString methodsString;
+ for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
+ {
+ const CCoderInfo &coder = folderInfo.Coders[i];
+ if (!methodsString.IsEmpty())
+ methodsString += L' ';
+
+ UString methodName, propsString;
+ bool methodIsKnown = FindMethod(
+ EXTERNAL_CODECS_VARS
+ coder.MethodID, methodName);
+
+ if (!methodIsKnown)
+ methodsString += ConvertMethodIdToString(coder.MethodID);
+ else
+ {
+ methodsString += methodName;
+ if (coder.MethodID == k_Delta && coder.Props.GetCapacity() == 1)
+ propsString = ConvertUInt32ToString((UInt32)coder.Props[0] + 1);
+ else if (coder.MethodID == k_LZMA && coder.Props.GetCapacity() == 5)
+ {
+ UInt32 dicSize = GetUi32((const Byte *)coder.Props + 1);
+ propsString = GetStringForSizeValue(dicSize);
+ }
+ else if (coder.MethodID == k_LZMA2 && coder.Props.GetCapacity() == 1)
+ {
+ Byte p = coder.Props[0];
+ UInt32 dicSize = (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11));
+ propsString = GetStringForSizeValue(dicSize);
+ }
+ else if (coder.MethodID == k_PPMD && coder.Props.GetCapacity() == 5)
+ {
+ Byte order = *(const Byte *)coder.Props;
+ methodsString += L'o';
+ methodsString += ConvertUInt32ToString(order);
+ methodsString += L":mem";
+ UInt32 dicSize = GetUi32((const Byte *)coder.Props + 1);
+ propsString = GetStringForSizeValue(dicSize);
+ }
+ else if (coder.MethodID == k_AES && coder.Props.GetCapacity() >= 1)
+ {
+ const Byte *data = (const Byte *)coder.Props;
+ Byte firstByte = *data++;
+ UInt32 numCyclesPower = firstByte & 0x3F;
+ propsString = ConvertUInt32ToString(numCyclesPower);
+ /*
+ if ((firstByte & 0xC0) != 0)
+ {
+ UInt32 saltSize = (firstByte >> 7) & 1;
+ UInt32 ivSize = (firstByte >> 6) & 1;
+ if (coder.Props.GetCapacity() >= 2)
+ {
+ Byte secondByte = *data++;
+ saltSize += (secondByte >> 4);
+ ivSize += (secondByte & 0x0F);
+ }
+ }
+ */
+ }
+ }
+ if (!propsString.IsEmpty())
+ {
+ methodsString += L':';
+ methodsString += propsString;
+ }
+ else if (coder.Props.GetCapacity() > 0)
+ {
+ methodsString += L":[";
+ for (size_t bi = 0; bi < coder.Props.GetCapacity(); bi++)
+ {
+ if (bi > 5 && bi + 1 < coder.Props.GetCapacity())
+ {
+ methodsString += L"..";
+ break;
+ }
+ else
+ AddHexToString(methodsString, coder.Props[bi]);
+ }
+ methodsString += L']';
+ }
+ }
+ prop = methodsString;
+ }
+ }
+ break;
+ case kpidBlock:
+ {
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
+ if (folderIndex != kNumNoIndex)
+ prop = (UInt32)folderIndex;
+ }
+ break;
+ case kpidPackedSize0:
+ case kpidPackedSize1:
+ case kpidPackedSize2:
+ case kpidPackedSize3:
+ case kpidPackedSize4:
+ {
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
+ if (folderIndex != kNumNoIndex)
+ {
+ const CFolder &folderInfo = _db.Folders[folderIndex];
+ if (_db.FolderStartFileIndex[folderIndex] == (CNum)index2 &&
+ folderInfo.PackStreams.Size() > (int)(propID - kpidPackedSize0))
+ {
+ prop = _db.GetFolderPackStreamSize(folderIndex, propID - kpidPackedSize0);
+ }
+ else
+ prop = (UInt64)0;
+ }
+ else
+ prop = (UInt64)0;
+ }
+ break;
+ #endif
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ Close();
+ #ifndef _SFX
+ _fileInfoPopIDs.Clear();
+ #endif
+ try
+ {
+ CMyComPtr<IArchiveOpenCallback> openArchiveCallbackTemp = openArchiveCallback;
+
+ #ifndef _NO_CRYPTO
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
+ if (openArchiveCallback)
+ {
+ openArchiveCallbackTemp.QueryInterface(
+ IID_ICryptoGetTextPassword, &getTextPassword);
+ }
+ #endif
+ CInArchive archive;
+ RINOK(archive.Open(stream, maxCheckStartPosition));
+ #ifndef _NO_CRYPTO
+ _passwordIsDefined = false;
+ UString password;
+ #endif
+ HRESULT result = archive.ReadDatabase(
+ EXTERNAL_CODECS_VARS
+ _db
+ #ifndef _NO_CRYPTO
+ , getTextPassword, _passwordIsDefined
+ #endif
+ );
+ RINOK(result);
+ _db.Fill();
+ _inStream = stream;
+ }
+ catch(...)
+ {
+ Close();
+ return S_FALSE;
+ }
+ // _inStream = stream;
+ #ifndef _SFX
+ FillPopIDs();
+ #endif
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ COM_TRY_BEGIN
+ _inStream.Release();
+ _db.Clear();
+ return S_OK;
+ COM_TRY_END
+}
+
+#ifdef __7Z_SET_PROPERTIES
+#ifdef EXTRACT_ONLY
+
+STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
+{
+ COM_TRY_BEGIN
+ #ifdef COMPRESS_MT
+ const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
+ _numThreads = numProcessors;
+ #endif
+
+ for (int i = 0; i < numProperties; i++)
+ {
+ UString name = names[i];
+ name.MakeUpper();
+ if (name.IsEmpty())
+ return E_INVALIDARG;
+ const PROPVARIANT &value = values[i];
+ UInt32 number;
+ int index = ParseStringToUInt32(name, number);
+ if (index == 0)
+ {
+ if(name.Left(2).CompareNoCase(L"MT") == 0)
+ {
+ #ifdef COMPRESS_MT
+ RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
+ #endif
+ continue;
+ }
+ else
+ return E_INVALIDARG;
+ }
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+#endif
+#endif
+
+IMPL_ISetCompressCodecsInfo
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandler.h
new file mode 100644
index 000000000..68fb034f4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandler.h
@@ -0,0 +1,119 @@
+// 7z/Handler.h
+
+#ifndef __7Z_HANDLER_H
+#define __7Z_HANDLER_H
+
+#include "../../ICoder.h"
+#include "../IArchive.h"
+
+#include "../../Common/CreateCoder.h"
+
+#ifndef EXTRACT_ONLY
+#include "../Common/HandlerOut.h"
+#endif
+
+#include "7zCompressionMode.h"
+#include "7zIn.h"
+
+namespace NArchive {
+namespace N7z {
+
+#ifndef __7Z_SET_PROPERTIES
+
+#ifdef EXTRACT_ONLY
+#ifdef COMPRESS_MT
+#define __7Z_SET_PROPERTIES
+#endif
+#else
+#define __7Z_SET_PROPERTIES
+#endif
+
+#endif
+
+
+class CHandler:
+ #ifndef EXTRACT_ONLY
+ public NArchive::COutHandler,
+ #endif
+ public IInArchive,
+ #ifdef __7Z_SET_PROPERTIES
+ public ISetProperties,
+ #endif
+ #ifndef EXTRACT_ONLY
+ public IOutArchive,
+ #endif
+ PUBLIC_ISetCompressCodecsInfo
+ public CMyUnknownImp
+{
+public:
+ MY_QUERYINTERFACE_BEGIN2(IInArchive)
+ #ifdef __7Z_SET_PROPERTIES
+ MY_QUERYINTERFACE_ENTRY(ISetProperties)
+ #endif
+ #ifndef EXTRACT_ONLY
+ MY_QUERYINTERFACE_ENTRY(IOutArchive)
+ #endif
+ QUERY_ENTRY_ISetCompressCodecsInfo
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ INTERFACE_IInArchive(;)
+
+ #ifdef __7Z_SET_PROPERTIES
+ STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
+ #endif
+
+ #ifndef EXTRACT_ONLY
+ INTERFACE_IOutArchive(;)
+ #endif
+
+ DECL_ISetCompressCodecsInfo
+
+ CHandler();
+
+private:
+ CMyComPtr<IInStream> _inStream;
+ NArchive::N7z::CArchiveDatabaseEx _db;
+ #ifndef _NO_CRYPTO
+ bool _passwordIsDefined;
+ #endif
+
+ #ifdef EXTRACT_ONLY
+
+ #ifdef COMPRESS_MT
+ UInt32 _numThreads;
+ #endif
+
+ UInt32 _crcSize;
+
+ #else
+
+ CRecordVector<CBind> _binds;
+
+ HRESULT SetCompressionMethod(CCompressionMethodMode &method,
+ CObjectVector<COneMethodInfo> &methodsInfo
+ #ifdef COMPRESS_MT
+ , UInt32 numThreads
+ #endif
+ );
+
+ HRESULT SetCompressionMethod(
+ CCompressionMethodMode &method,
+ CCompressionMethodMode &headerMethod);
+
+ #endif
+
+ bool IsEncrypted(UInt32 index2) const;
+ #ifndef _SFX
+
+ CRecordVector<UInt64> _fileInfoPopIDs;
+ void FillPopIDs();
+
+ #endif
+
+ DECL_EXTERNAL_CODECS_VARS
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandlerOut.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandlerOut.cpp
new file mode 100644
index 000000000..e2c250ab6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHandlerOut.cpp
@@ -0,0 +1,477 @@
+// 7zHandlerOut.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Windows/PropVariant.h"
+
+#include "../../../Common/ComTry.h"
+#include "../../../Common/StringToInt.h"
+
+#include "../../ICoder.h"
+
+#include "../Common/ItemNameUtils.h"
+#include "../Common/ParseProperties.h"
+
+#include "7zHandler.h"
+#include "7zOut.h"
+#include "7zUpdate.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace N7z {
+
+static const wchar_t *kLZMAMethodName = L"LZMA";
+static const wchar_t *kCopyMethod = L"Copy";
+static const wchar_t *kDefaultMethodName = kLZMAMethodName;
+
+static const UInt32 kLzmaAlgorithmX5 = 1;
+static const wchar_t *kLzmaMatchFinderForHeaders = L"BT2";
+static const UInt32 kDictionaryForHeaders = 1 << 20;
+static const UInt32 kNumFastBytesForHeaders = 273;
+static const UInt32 kAlgorithmForHeaders = kLzmaAlgorithmX5;
+
+static inline bool IsCopyMethod(const UString &methodName)
+ { return (methodName.CompareNoCase(kCopyMethod) == 0); }
+
+STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
+{
+ *type = NFileTimeType::kWindows;
+ return S_OK;
+}
+
+HRESULT CHandler::SetCompressionMethod(
+ CCompressionMethodMode &methodMode,
+ CCompressionMethodMode &headerMethod)
+{
+ HRESULT res = SetCompressionMethod(methodMode, _methods
+ #ifdef COMPRESS_MT
+ , _numThreads
+ #endif
+ );
+ RINOK(res);
+ methodMode.Binds = _binds;
+
+ if (_compressHeaders)
+ {
+ // headerMethod.Methods.Add(methodMode.Methods.Back());
+
+ CObjectVector<COneMethodInfo> headerMethodInfoVector;
+ COneMethodInfo oneMethodInfo;
+ oneMethodInfo.MethodName = kLZMAMethodName;
+ {
+ CProp prop;
+ prop.Id = NCoderPropID::kMatchFinder;
+ prop.Value = kLzmaMatchFinderForHeaders;
+ oneMethodInfo.Props.Add(prop);
+ }
+ {
+ CProp prop;
+ prop.Id = NCoderPropID::kAlgorithm;
+ prop.Value = kAlgorithmForHeaders;
+ oneMethodInfo.Props.Add(prop);
+ }
+ {
+ CProp prop;
+ prop.Id = NCoderPropID::kNumFastBytes;
+ prop.Value = (UInt32)kNumFastBytesForHeaders;
+ oneMethodInfo.Props.Add(prop);
+ }
+ {
+ CProp prop;
+ prop.Id = NCoderPropID::kDictionarySize;
+ prop.Value = (UInt32)kDictionaryForHeaders;
+ oneMethodInfo.Props.Add(prop);
+ }
+ headerMethodInfoVector.Add(oneMethodInfo);
+ HRESULT res = SetCompressionMethod(headerMethod, headerMethodInfoVector
+ #ifdef COMPRESS_MT
+ ,1
+ #endif
+ );
+ RINOK(res);
+ }
+ return S_OK;
+}
+
+HRESULT CHandler::SetCompressionMethod(
+ CCompressionMethodMode &methodMode,
+ CObjectVector<COneMethodInfo> &methodsInfo
+ #ifdef COMPRESS_MT
+ , UInt32 numThreads
+ #endif
+ )
+{
+ UInt32 level = _level;
+
+ if (methodsInfo.IsEmpty())
+ {
+ COneMethodInfo oneMethodInfo;
+ oneMethodInfo.MethodName = ((level == 0) ? kCopyMethod : kDefaultMethodName);
+ methodsInfo.Add(oneMethodInfo);
+ }
+
+ bool needSolid = false;
+ for(int i = 0; i < methodsInfo.Size(); i++)
+ {
+ COneMethodInfo &oneMethodInfo = methodsInfo[i];
+ SetCompressionMethod2(oneMethodInfo
+ #ifdef COMPRESS_MT
+ , numThreads
+ #endif
+ );
+
+ if (!IsCopyMethod(oneMethodInfo.MethodName))
+ needSolid = true;
+
+ CMethodFull methodFull;
+
+ if (!FindMethod(
+ EXTERNAL_CODECS_VARS
+ oneMethodInfo.MethodName, methodFull.Id, methodFull.NumInStreams, methodFull.NumOutStreams))
+ return E_INVALIDARG;
+ methodFull.Props = oneMethodInfo.Props;
+ methodMode.Methods.Add(methodFull);
+
+ if (!_numSolidBytesDefined)
+ {
+ for (int j = 0; j < methodFull.Props.Size(); j++)
+ {
+ const CProp &prop = methodFull.Props[j];
+ if ((prop.Id == NCoderPropID::kDictionarySize ||
+ prop.Id == NCoderPropID::kUsedMemorySize) && prop.Value.vt == VT_UI4)
+ {
+ _numSolidBytes = ((UInt64)prop.Value.ulVal) << 7;
+ const UInt64 kMinSize = (1 << 24);
+ if (_numSolidBytes < kMinSize)
+ _numSolidBytes = kMinSize;
+ _numSolidBytesDefined = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!needSolid && !_numSolidBytesDefined)
+ {
+ _numSolidBytesDefined = true;
+ _numSolidBytes = 0;
+ }
+ return S_OK;
+}
+
+static HRESULT GetTime(IArchiveUpdateCallback *updateCallback, int index, bool writeTime, PROPID propID, UInt64 &ft, bool &ftDefined)
+{
+ ft = 0;
+ ftDefined = false;
+ if (!writeTime)
+ return S_OK;
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(index, propID, &prop));
+ if (prop.vt == VT_FILETIME)
+ {
+ ft = prop.filetime.dwLowDateTime | ((UInt64)prop.filetime.dwHighDateTime << 32);
+ ftDefined = true;
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
+ IArchiveUpdateCallback *updateCallback)
+{
+ COM_TRY_BEGIN
+
+ const CArchiveDatabaseEx *db = 0;
+ #ifdef _7Z_VOL
+ if (_volumes.Size() > 1)
+ return E_FAIL;
+ const CVolume *volume = 0;
+ if (_volumes.Size() == 1)
+ {
+ volume = &_volumes.Front();
+ db = &volume->Database;
+ }
+ #else
+ if (_inStream != 0)
+ db = &_db;
+ #endif
+
+ CObjectVector<CUpdateItem> updateItems;
+
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ Int32 newData, newProps;
+ UInt32 indexInArchive;
+ if (!updateCallback)
+ return E_FAIL;
+ RINOK(updateCallback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArchive));
+ CUpdateItem ui;
+ ui.NewProps = IntToBool(newProps);
+ ui.NewData = IntToBool(newData);
+ ui.IndexInArchive = indexInArchive;
+ ui.IndexInClient = i;
+ ui.IsAnti = false;
+ ui.Size = 0;
+
+ if (ui.IndexInArchive != -1)
+ {
+ if (db == 0 || ui.IndexInArchive >= db->Files.Size())
+ return E_INVALIDARG;
+ const CFileItem &fi = db->Files[ui.IndexInArchive];
+ ui.Name = fi.Name;
+ ui.IsDir = fi.IsDir;
+ ui.Size = fi.Size;
+ ui.IsAnti = db->IsItemAnti(ui.IndexInArchive);
+
+ ui.CTimeDefined = db->CTime.GetItem(ui.IndexInArchive, ui.CTime);
+ ui.ATimeDefined = db->ATime.GetItem(ui.IndexInArchive, ui.ATime);
+ ui.MTimeDefined = db->MTime.GetItem(ui.IndexInArchive, ui.MTime);
+ }
+
+ if (ui.NewProps)
+ {
+ bool nameIsDefined;
+ bool folderStatusIsDefined;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidAttrib, &prop));
+ if (prop.vt == VT_EMPTY)
+ ui.AttribDefined = false;
+ else if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ else
+ {
+ ui.Attrib = prop.ulVal;
+ ui.AttribDefined = true;
+ }
+ }
+
+ // we need MTime to sort files.
+ RINOK(GetTime(updateCallback, i, WriteCTime, kpidCTime, ui.CTime, ui.CTimeDefined));
+ RINOK(GetTime(updateCallback, i, WriteATime, kpidATime, ui.ATime, ui.ATimeDefined));
+ RINOK(GetTime(updateCallback, i, true, kpidMTime, ui.MTime, ui.MTimeDefined));
+
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidPath, &prop));
+ if (prop.vt == VT_EMPTY)
+ nameIsDefined = false;
+ else if (prop.vt != VT_BSTR)
+ return E_INVALIDARG;
+ else
+ {
+ ui.Name = NItemName::MakeLegalName(prop.bstrVal);
+ nameIsDefined = true;
+ }
+ }
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidIsDir, &prop));
+ if (prop.vt == VT_EMPTY)
+ folderStatusIsDefined = false;
+ else if (prop.vt != VT_BOOL)
+ return E_INVALIDARG;
+ else
+ {
+ ui.IsDir = (prop.boolVal != VARIANT_FALSE);
+ folderStatusIsDefined = true;
+ }
+ }
+
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidIsAnti, &prop));
+ if (prop.vt == VT_EMPTY)
+ ui.IsAnti = false;
+ else if (prop.vt != VT_BOOL)
+ return E_INVALIDARG;
+ else
+ ui.IsAnti = (prop.boolVal != VARIANT_FALSE);
+ }
+
+ if (ui.IsAnti)
+ {
+ ui.AttribDefined = false;
+
+ ui.CTimeDefined = false;
+ ui.ATimeDefined = false;
+ ui.MTimeDefined = false;
+
+ ui.Size = 0;
+ }
+
+ if (!folderStatusIsDefined && ui.AttribDefined)
+ ui.SetDirStatusFromAttrib();
+ }
+
+ if (ui.NewData)
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidSize, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ ui.Size = (UInt64)prop.uhVal.QuadPart;
+ if (ui.Size != 0 && ui.IsAnti)
+ return E_INVALIDARG;
+ }
+ updateItems.Add(ui);
+ }
+
+ CCompressionMethodMode methodMode, headerMethod;
+ RINOK(SetCompressionMethod(methodMode, headerMethod));
+ #ifdef COMPRESS_MT
+ methodMode.NumThreads = _numThreads;
+ headerMethod.NumThreads = 1;
+ #endif
+
+ CMyComPtr<ICryptoGetTextPassword2> getPassword2;
+ updateCallback->QueryInterface(IID_ICryptoGetTextPassword2, (void **)&getPassword2);
+
+ if (getPassword2)
+ {
+ CMyComBSTR password;
+ Int32 passwordIsDefined;
+ RINOK(getPassword2->CryptoGetTextPassword2(&passwordIsDefined, &password));
+ methodMode.PasswordIsDefined = IntToBool(passwordIsDefined);
+ if (methodMode.PasswordIsDefined)
+ methodMode.Password = password;
+ }
+ else
+ methodMode.PasswordIsDefined = false;
+
+ bool compressMainHeader = _compressHeaders; // check it
+
+ bool encryptHeaders = false;
+
+ if (methodMode.PasswordIsDefined)
+ {
+ if (_encryptHeadersSpecified)
+ encryptHeaders = _encryptHeaders;
+ #ifndef _NO_CRYPTO
+ else
+ encryptHeaders = _passwordIsDefined;
+ #endif
+ compressMainHeader = true;
+ if (encryptHeaders)
+ {
+ headerMethod.PasswordIsDefined = methodMode.PasswordIsDefined;
+ headerMethod.Password = methodMode.Password;
+ }
+ }
+
+ if (numItems < 2)
+ compressMainHeader = false;
+
+ CUpdateOptions options;
+ options.Method = &methodMode;
+ options.HeaderMethod = (_compressHeaders || encryptHeaders) ? &headerMethod : 0;
+ options.UseFilters = _level != 0 && _autoFilter;
+ options.MaxFilter = _level >= 8;
+
+ options.HeaderOptions.CompressMainHeader = compressMainHeader;
+ options.HeaderOptions.WriteCTime = WriteCTime;
+ options.HeaderOptions.WriteATime = WriteATime;
+ options.HeaderOptions.WriteMTime = WriteMTime;
+
+ options.NumSolidFiles = _numSolidFiles;
+ options.NumSolidBytes = _numSolidBytes;
+ options.SolidExtension = _solidExtension;
+ options.RemoveSfxBlock = _removeSfxBlock;
+ options.VolumeMode = _volumeMode;
+
+ COutArchive archive;
+ CArchiveDatabase newDatabase;
+
+ CMyComPtr<ICryptoGetTextPassword> getPassword;
+ updateCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getPassword);
+
+ HRESULT res = Update(
+ EXTERNAL_CODECS_VARS
+ #ifdef _7Z_VOL
+ volume ? volume->Stream: 0,
+ volume ? db : 0,
+ #else
+ _inStream,
+ db,
+ #endif
+ updateItems,
+ archive, newDatabase, outStream, updateCallback, options
+ #ifndef _NO_CRYPTO
+ , getPassword
+ #endif
+ );
+
+ RINOK(res);
+
+ updateItems.ClearAndFree();
+
+ return archive.WriteDatabase(EXTERNAL_CODECS_VARS
+ newDatabase, options.HeaderMethod, options.HeaderOptions);
+
+ COM_TRY_END
+}
+
+static HRESULT GetBindInfoPart(UString &srcString, UInt32 &coder, UInt32 &stream)
+{
+ stream = 0;
+ int index = ParseStringToUInt32(srcString, coder);
+ if (index == 0)
+ return E_INVALIDARG;
+ srcString.Delete(0, index);
+ if (srcString[0] == 'S')
+ {
+ srcString.Delete(0);
+ int index = ParseStringToUInt32(srcString, stream);
+ if (index == 0)
+ return E_INVALIDARG;
+ srcString.Delete(0, index);
+ }
+ return S_OK;
+}
+
+static HRESULT GetBindInfo(UString &srcString, CBind &bind)
+{
+ RINOK(GetBindInfoPart(srcString, bind.OutCoder, bind.OutStream));
+ if (srcString[0] != ':')
+ return E_INVALIDARG;
+ srcString.Delete(0);
+ RINOK(GetBindInfoPart(srcString, bind.InCoder, bind.InStream));
+ if (!srcString.IsEmpty())
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
+{
+ COM_TRY_BEGIN
+ _binds.Clear();
+ BeforeSetProperty();
+
+ for (int i = 0; i < numProperties; i++)
+ {
+ UString name = names[i];
+ name.MakeUpper();
+ if (name.IsEmpty())
+ return E_INVALIDARG;
+
+ const PROPVARIANT &value = values[i];
+
+ if (name[0] == 'B')
+ {
+ name.Delete(0);
+ CBind bind;
+ RINOK(GetBindInfo(name, bind));
+ _binds.Add(bind);
+ continue;
+ }
+
+ RINOK(SetProperty(name, value));
+ }
+
+ return S_OK;
+ COM_TRY_END
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHeader.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHeader.cpp
new file mode 100644
index 000000000..f232a23ee
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHeader.cpp
@@ -0,0 +1,27 @@
+// 7z/Header.cpp
+
+#include "StdAfx.h"
+#include "7zHeader.h"
+
+namespace NArchive {
+namespace N7z {
+
+Byte kSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C};
+#ifdef _7Z_VOL
+Byte kFinishSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C + 1};
+#endif
+
+class SignatureInitializer
+{
+public:
+ SignatureInitializer()
+ {
+ kSignature[0]--;
+ #ifdef _7Z_VOL
+ kFinishSignature[0]--;
+ #endif
+ };
+} g_SignatureInitializer;
+
+}}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHeader.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHeader.h
new file mode 100644
index 000000000..30622b90e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zHeader.h
@@ -0,0 +1,97 @@
+// 7z/7zHeader.h
+
+#ifndef __7Z_HEADER_H
+#define __7Z_HEADER_H
+
+#include "../../../Common/Types.h"
+
+namespace NArchive {
+namespace N7z {
+
+const int kSignatureSize = 6;
+extern Byte kSignature[kSignatureSize];
+
+// #define _7Z_VOL
+// 7z-MultiVolume is not finished yet.
+// It can work already, but I still do not like some
+// things of that new multivolume format.
+// So please keep it commented.
+
+#ifdef _7Z_VOL
+extern Byte kFinishSignature[kSignatureSize];
+#endif
+
+struct CArchiveVersion
+{
+ Byte Major;
+ Byte Minor;
+};
+
+const Byte kMajorVersion = 0;
+
+struct CStartHeader
+{
+ UInt64 NextHeaderOffset;
+ UInt64 NextHeaderSize;
+ UInt32 NextHeaderCRC;
+};
+
+const UInt32 kStartHeaderSize = 20;
+
+#ifdef _7Z_VOL
+struct CFinishHeader: public CStartHeader
+{
+ UInt64 ArchiveStartOffset; // data offset from end if that struct
+ UInt64 AdditionalStartBlockSize; // start signature & start header size
+};
+
+const UInt32 kFinishHeaderSize = kStartHeaderSize + 16;
+#endif
+
+namespace NID
+{
+ enum EEnum
+ {
+ kEnd,
+
+ kHeader,
+
+ kArchiveProperties,
+
+ kAdditionalStreamsInfo,
+ kMainStreamsInfo,
+ kFilesInfo,
+
+ kPackInfo,
+ kUnpackInfo,
+ kSubStreamsInfo,
+
+ kSize,
+ kCRC,
+
+ kFolder,
+
+ kCodersUnpackSize,
+ kNumUnpackStream,
+
+ kEmptyStream,
+ kEmptyFile,
+ kAnti,
+
+ kName,
+ kCTime,
+ kATime,
+ kMTime,
+ kWinAttributes,
+ kComment,
+
+ kEncodedHeader,
+
+ kStartPos,
+ kDummy
+ };
+}
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zIn.cpp
new file mode 100644
index 000000000..f1ededdc7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zIn.cpp
@@ -0,0 +1,1257 @@
+// 7zIn.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/7zCrc.h"
+#include "../../../../C/CpuArch.h"
+
+#include "../../Common/StreamObjects.h"
+#include "../../Common/StreamUtils.h"
+
+#include "7zDecode.h"
+#include "7zIn.h"
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+// define FORMAT_7Z_RECOVERY if you want to recover multivolume archives with empty StartHeader
+#ifndef _SFX
+#define FORMAT_7Z_RECOVERY
+#endif
+
+namespace NArchive {
+namespace N7z {
+
+static void BoolVector_Fill_False(CBoolVector &v, int size)
+{
+ v.Clear();
+ v.Reserve(size);
+ for (int i = 0; i < size; i++)
+ v.Add(false);
+}
+
+static bool BoolVector_GetAndSet(CBoolVector &v, UInt32 index)
+{
+ if (index >= (UInt32)v.Size())
+ return true;
+ bool res = v[index];
+ v[index] = true;
+ return res;
+}
+
+bool CFolder::CheckStructure() const
+{
+ const int kNumCodersMax = sizeof(UInt32) * 8; // don't change it
+ const int kMaskSize = sizeof(UInt32) * 8; // it must be >= kNumCodersMax
+ const int kNumBindsMax = 32;
+
+ if (Coders.Size() > kNumCodersMax || BindPairs.Size() > kNumBindsMax)
+ return false;
+
+ {
+ CBoolVector v;
+ BoolVector_Fill_False(v, BindPairs.Size() + PackStreams.Size());
+
+ int i;
+ for (i = 0; i < BindPairs.Size(); i++)
+ if (BoolVector_GetAndSet(v, BindPairs[i].InIndex))
+ return false;
+ for (i = 0; i < PackStreams.Size(); i++)
+ if (BoolVector_GetAndSet(v, PackStreams[i]))
+ return false;
+
+ BoolVector_Fill_False(v, UnpackSizes.Size());
+ for (i = 0; i < BindPairs.Size(); i++)
+ if (BoolVector_GetAndSet(v, BindPairs[i].OutIndex))
+ return false;
+ }
+
+ UInt32 mask[kMaskSize];
+ int i;
+ for (i = 0; i < kMaskSize; i++)
+ mask[i] = 0;
+
+ {
+ CIntVector inStreamToCoder, outStreamToCoder;
+ for (i = 0; i < Coders.Size(); i++)
+ {
+ CNum j;
+ const CCoderInfo &coder = Coders[i];
+ for (j = 0; j < coder.NumInStreams; j++)
+ inStreamToCoder.Add(i);
+ for (j = 0; j < coder.NumOutStreams; j++)
+ outStreamToCoder.Add(i);
+ }
+
+ for (i = 0; i < BindPairs.Size(); i++)
+ {
+ const CBindPair &bp = BindPairs[i];
+ mask[inStreamToCoder[bp.InIndex]] |= (1 << outStreamToCoder[bp.OutIndex]);
+ }
+ }
+
+ for (i = 0; i < kMaskSize; i++)
+ for (int j = 0; j < kMaskSize; j++)
+ if (((1 << j) & mask[i]) != 0)
+ mask[i] |= mask[j];
+
+ for (i = 0; i < kMaskSize; i++)
+ if (((1 << i) & mask[i]) != 0)
+ return false;
+
+ return true;
+}
+
+class CInArchiveException {};
+
+static void ThrowException() { throw CInArchiveException(); }
+static inline void ThrowEndOfData() { ThrowException(); }
+static inline void ThrowUnsupported() { ThrowException(); }
+static inline void ThrowIncorrect() { ThrowException(); }
+static inline void ThrowUnsupportedVersion() { ThrowException(); }
+
+/*
+class CInArchiveException
+{
+public:
+ enum CCauseType
+ {
+ kUnsupportedVersion = 0,
+ kUnsupported,
+ kIncorrect,
+ kEndOfData,
+ } Cause;
+ CInArchiveException(CCauseType cause): Cause(cause) {};
+};
+
+static void ThrowException(CInArchiveException::CCauseType c) { throw CInArchiveException(c); }
+static void ThrowEndOfData() { ThrowException(CInArchiveException::kEndOfData); }
+static void ThrowUnsupported() { ThrowException(CInArchiveException::kUnsupported); }
+static void ThrowIncorrect() { ThrowException(CInArchiveException::kIncorrect); }
+static void ThrowUnsupportedVersion() { ThrowException(CInArchiveException::kUnsupportedVersion); }
+*/
+
+class CStreamSwitch
+{
+ CInArchive *_archive;
+ bool _needRemove;
+public:
+ CStreamSwitch(): _needRemove(false) {}
+ ~CStreamSwitch() { Remove(); }
+ void Remove();
+ void Set(CInArchive *archive, const Byte *data, size_t size);
+ void Set(CInArchive *archive, const CByteBuffer &byteBuffer);
+ void Set(CInArchive *archive, const CObjectVector<CByteBuffer> *dataVector);
+};
+
+void CStreamSwitch::Remove()
+{
+ if (_needRemove)
+ {
+ _archive->DeleteByteStream();
+ _needRemove = false;
+ }
+}
+
+void CStreamSwitch::Set(CInArchive *archive, const Byte *data, size_t size)
+{
+ Remove();
+ _archive = archive;
+ _archive->AddByteStream(data, size);
+ _needRemove = true;
+}
+
+void CStreamSwitch::Set(CInArchive *archive, const CByteBuffer &byteBuffer)
+{
+ Set(archive, byteBuffer, byteBuffer.GetCapacity());
+}
+
+void CStreamSwitch::Set(CInArchive *archive, const CObjectVector<CByteBuffer> *dataVector)
+{
+ Remove();
+ Byte external = archive->ReadByte();
+ if (external != 0)
+ {
+ int dataIndex = (int)archive->ReadNum();
+ if (dataIndex < 0 || dataIndex >= dataVector->Size())
+ ThrowIncorrect();
+ Set(archive, (*dataVector)[dataIndex]);
+ }
+}
+
+Byte CInByte2::ReadByte()
+{
+ if (_pos >= _size)
+ ThrowEndOfData();
+ return _buffer[_pos++];
+}
+
+void CInByte2::ReadBytes(Byte *data, size_t size)
+{
+ if (size > _size - _pos)
+ ThrowEndOfData();
+ for (size_t i = 0; i < size; i++)
+ data[i] = _buffer[_pos++];
+}
+
+void CInByte2::SkipData(UInt64 size)
+{
+ if (size > _size - _pos)
+ ThrowEndOfData();
+ _pos += (size_t)size;
+}
+
+void CInByte2::SkipData()
+{
+ SkipData(ReadNumber());
+}
+
+UInt64 CInByte2::ReadNumber()
+{
+ if (_pos >= _size)
+ ThrowEndOfData();
+ Byte firstByte = _buffer[_pos++];
+ Byte mask = 0x80;
+ UInt64 value = 0;
+ for (int i = 0; i < 8; i++)
+ {
+ if ((firstByte & mask) == 0)
+ {
+ UInt64 highPart = firstByte & (mask - 1);
+ value += (highPart << (i * 8));
+ return value;
+ }
+ if (_pos >= _size)
+ ThrowEndOfData();
+ value |= ((UInt64)_buffer[_pos++] << (8 * i));
+ mask >>= 1;
+ }
+ return value;
+}
+
+CNum CInByte2::ReadNum()
+{
+ UInt64 value = ReadNumber();
+ if (value > kNumMax)
+ ThrowUnsupported();
+ return (CNum)value;
+}
+
+UInt32 CInByte2::ReadUInt32()
+{
+ if (_pos + 4 > _size)
+ ThrowEndOfData();
+ UInt32 res = Get32(_buffer + _pos);
+ _pos += 4;
+ return res;
+}
+
+UInt64 CInByte2::ReadUInt64()
+{
+ if (_pos + 8 > _size)
+ ThrowEndOfData();
+ UInt64 res = Get64(_buffer + _pos);
+ _pos += 8;
+ return res;
+}
+
+void CInByte2::ReadString(UString &s)
+{
+ const Byte *buf = _buffer + _pos;
+ size_t rem = (_size - _pos) / 2 * 2;
+ {
+ size_t i;
+ for (i = 0; i < rem; i += 2)
+ if (buf[i] == 0 && buf[i + 1] == 0)
+ break;
+ if (i == rem)
+ ThrowEndOfData();
+ rem = i;
+ }
+ int len = (int)(rem / 2);
+ if (len < 0 || (size_t)len * 2 != rem)
+ ThrowUnsupported();
+ wchar_t *p = s.GetBuffer(len);
+ int i;
+ for (i = 0; i < len; i++, buf += 2)
+ p[i] = (wchar_t)Get16(buf);
+ s.ReleaseBuffer(len);
+ _pos += rem + 2;
+}
+
+static inline bool TestSignatureCandidate(const Byte *p)
+{
+ for (int i = 0; i < kSignatureSize; i++)
+ if (p[i] != kSignature[i])
+ return false;
+ return (p[0x1A] == 0 && p[0x1B] == 0);
+}
+
+HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
+{
+ RINOK(ReadStream_FALSE(stream, _header, kHeaderSize));
+
+ if (TestSignatureCandidate(_header))
+ return S_OK;
+
+ CByteBuffer byteBuffer;
+ const UInt32 kBufferSize = (1 << 16);
+ byteBuffer.SetCapacity(kBufferSize);
+ Byte *buffer = byteBuffer;
+ UInt32 numPrevBytes = kHeaderSize - 1;
+ memcpy(buffer, _header + 1, numPrevBytes);
+ UInt64 curTestPos = _arhiveBeginStreamPosition + 1;
+ for (;;)
+ {
+ if (searchHeaderSizeLimit != NULL)
+ if (curTestPos - _arhiveBeginStreamPosition > *searchHeaderSizeLimit)
+ break;
+ do
+ {
+ UInt32 numReadBytes = kBufferSize - numPrevBytes;
+ UInt32 processedSize;
+ RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize));
+ numPrevBytes += processedSize;
+ if (processedSize == 0)
+ return S_FALSE;
+ }
+ while (numPrevBytes < kHeaderSize);
+ UInt32 numTests = numPrevBytes - kHeaderSize + 1;
+ for (UInt32 pos = 0; pos < numTests; pos++)
+ {
+ for (; buffer[pos] != '7' && pos < numTests; pos++);
+ if (pos == numTests)
+ break;
+ if (TestSignatureCandidate(buffer + pos))
+ {
+ memcpy(_header, buffer + pos, kHeaderSize);
+ curTestPos += pos;
+ _arhiveBeginStreamPosition = curTestPos;
+ return stream->Seek(curTestPos + kHeaderSize, STREAM_SEEK_SET, NULL);
+ }
+ }
+ curTestPos += numTests;
+ numPrevBytes -= numTests;
+ memmove(buffer, buffer + numTests, numPrevBytes);
+ }
+ return S_FALSE;
+}
+
+// S_FALSE means that file is not archive
+HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
+{
+ HeadersSize = 0;
+ Close();
+ RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_arhiveBeginStreamPosition))
+ RINOK(FindAndReadSignature(stream, searchHeaderSizeLimit));
+ _stream = stream;
+ return S_OK;
+}
+
+void CInArchive::Close()
+{
+ _stream.Release();
+}
+
+void CInArchive::ReadArchiveProperties(CInArchiveInfo & /* archiveInfo */)
+{
+ for (;;)
+ {
+ if (ReadID() == NID::kEnd)
+ break;
+ SkipData();
+ }
+}
+
+void CInArchive::GetNextFolderItem(CFolder &folder)
+{
+ CNum numCoders = ReadNum();
+
+ folder.Coders.Clear();
+ folder.Coders.Reserve((int)numCoders);
+ CNum numInStreams = 0;
+ CNum numOutStreams = 0;
+ CNum i;
+ for (i = 0; i < numCoders; i++)
+ {
+ folder.Coders.Add(CCoderInfo());
+ CCoderInfo &coder = folder.Coders.Back();
+
+ {
+ Byte mainByte = ReadByte();
+ int idSize = (mainByte & 0xF);
+ Byte longID[15];
+ ReadBytes(longID, idSize);
+ if (idSize > 8)
+ ThrowUnsupported();
+ UInt64 id = 0;
+ for (int j = 0; j < idSize; j++)
+ id |= (UInt64)longID[idSize - 1 - j] << (8 * j);
+ coder.MethodID = id;
+
+ if ((mainByte & 0x10) != 0)
+ {
+ coder.NumInStreams = ReadNum();
+ coder.NumOutStreams = ReadNum();
+ }
+ else
+ {
+ coder.NumInStreams = 1;
+ coder.NumOutStreams = 1;
+ }
+ if ((mainByte & 0x20) != 0)
+ {
+ CNum propsSize = ReadNum();
+ coder.Props.SetCapacity((size_t)propsSize);
+ ReadBytes((Byte *)coder.Props, (size_t)propsSize);
+ }
+ if ((mainByte & 0x80) != 0)
+ ThrowUnsupported();
+ }
+ numInStreams += coder.NumInStreams;
+ numOutStreams += coder.NumOutStreams;
+ }
+
+ CNum numBindPairs = numOutStreams - 1;
+ folder.BindPairs.Clear();
+ folder.BindPairs.Reserve(numBindPairs);
+ for (i = 0; i < numBindPairs; i++)
+ {
+ CBindPair bp;
+ bp.InIndex = ReadNum();
+ bp.OutIndex = ReadNum();
+ folder.BindPairs.Add(bp);
+ }
+
+ if (numInStreams < numBindPairs)
+ ThrowUnsupported();
+ CNum numPackStreams = numInStreams - numBindPairs;
+ folder.PackStreams.Reserve(numPackStreams);
+ if (numPackStreams == 1)
+ {
+ for (i = 0; i < numInStreams; i++)
+ if (folder.FindBindPairForInStream(i) < 0)
+ {
+ folder.PackStreams.Add(i);
+ break;
+ }
+ if (folder.PackStreams.Size() != 1)
+ ThrowUnsupported();
+ }
+ else
+ for (i = 0; i < numPackStreams; i++)
+ folder.PackStreams.Add(ReadNum());
+}
+
+void CInArchive::WaitAttribute(UInt64 attribute)
+{
+ for (;;)
+ {
+ UInt64 type = ReadID();
+ if (type == attribute)
+ return;
+ if (type == NID::kEnd)
+ ThrowIncorrect();
+ SkipData();
+ }
+}
+
+void CInArchive::ReadHashDigests(int numItems,
+ CBoolVector &digestsDefined,
+ CRecordVector<UInt32> &digests)
+{
+ ReadBoolVector2(numItems, digestsDefined);
+ digests.Clear();
+ digests.Reserve(numItems);
+ for (int i = 0; i < numItems; i++)
+ {
+ UInt32 crc = 0;
+ if (digestsDefined[i])
+ crc = ReadUInt32();
+ digests.Add(crc);
+ }
+}
+
+void CInArchive::ReadPackInfo(
+ UInt64 &dataOffset,
+ CRecordVector<UInt64> &packSizes,
+ CBoolVector &packCRCsDefined,
+ CRecordVector<UInt32> &packCRCs)
+{
+ dataOffset = ReadNumber();
+ CNum numPackStreams = ReadNum();
+
+ WaitAttribute(NID::kSize);
+ packSizes.Clear();
+ packSizes.Reserve(numPackStreams);
+ for (CNum i = 0; i < numPackStreams; i++)
+ packSizes.Add(ReadNumber());
+
+ UInt64 type;
+ for (;;)
+ {
+ type = ReadID();
+ if (type == NID::kEnd)
+ break;
+ if (type == NID::kCRC)
+ {
+ ReadHashDigests(numPackStreams, packCRCsDefined, packCRCs);
+ continue;
+ }
+ SkipData();
+ }
+ if (packCRCsDefined.IsEmpty())
+ {
+ BoolVector_Fill_False(packCRCsDefined, numPackStreams);
+ packCRCs.Reserve(numPackStreams);
+ packCRCs.Clear();
+ for (CNum i = 0; i < numPackStreams; i++)
+ packCRCs.Add(0);
+ }
+}
+
+void CInArchive::ReadUnpackInfo(
+ const CObjectVector<CByteBuffer> *dataVector,
+ CObjectVector<CFolder> &folders)
+{
+ WaitAttribute(NID::kFolder);
+ CNum numFolders = ReadNum();
+
+ {
+ CStreamSwitch streamSwitch;
+ streamSwitch.Set(this, dataVector);
+ folders.Clear();
+ folders.Reserve(numFolders);
+ for (CNum i = 0; i < numFolders; i++)
+ {
+ folders.Add(CFolder());
+ GetNextFolderItem(folders.Back());
+ }
+ }
+
+ WaitAttribute(NID::kCodersUnpackSize);
+
+ CNum i;
+ for (i = 0; i < numFolders; i++)
+ {
+ CFolder &folder = folders[i];
+ CNum numOutStreams = folder.GetNumOutStreams();
+ folder.UnpackSizes.Reserve(numOutStreams);
+ for (CNum j = 0; j < numOutStreams; j++)
+ folder.UnpackSizes.Add(ReadNumber());
+ }
+
+ for (;;)
+ {
+ UInt64 type = ReadID();
+ if (type == NID::kEnd)
+ return;
+ if (type == NID::kCRC)
+ {
+ CBoolVector crcsDefined;
+ CRecordVector<UInt32> crcs;
+ ReadHashDigests(numFolders, crcsDefined, crcs);
+ for (i = 0; i < numFolders; i++)
+ {
+ CFolder &folder = folders[i];
+ folder.UnpackCRCDefined = crcsDefined[i];
+ folder.UnpackCRC = crcs[i];
+ }
+ continue;
+ }
+ SkipData();
+ }
+}
+
+void CInArchive::ReadSubStreamsInfo(
+ const CObjectVector<CFolder> &folders,
+ CRecordVector<CNum> &numUnpackStreamsInFolders,
+ CRecordVector<UInt64> &unpackSizes,
+ CBoolVector &digestsDefined,
+ CRecordVector<UInt32> &digests)
+{
+ numUnpackStreamsInFolders.Clear();
+ numUnpackStreamsInFolders.Reserve(folders.Size());
+ UInt64 type;
+ for (;;)
+ {
+ type = ReadID();
+ if (type == NID::kNumUnpackStream)
+ {
+ for (int i = 0; i < folders.Size(); i++)
+ numUnpackStreamsInFolders.Add(ReadNum());
+ continue;
+ }
+ if (type == NID::kCRC || type == NID::kSize)
+ break;
+ if (type == NID::kEnd)
+ break;
+ SkipData();
+ }
+
+ if (numUnpackStreamsInFolders.IsEmpty())
+ for (int i = 0; i < folders.Size(); i++)
+ numUnpackStreamsInFolders.Add(1);
+
+ int i;
+ for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
+ {
+ // v3.13 incorrectly worked with empty folders
+ // v4.07: we check that folder is empty
+ CNum numSubstreams = numUnpackStreamsInFolders[i];
+ if (numSubstreams == 0)
+ continue;
+ UInt64 sum = 0;
+ for (CNum j = 1; j < numSubstreams; j++)
+ if (type == NID::kSize)
+ {
+ UInt64 size = ReadNumber();
+ unpackSizes.Add(size);
+ sum += size;
+ }
+ unpackSizes.Add(folders[i].GetUnpackSize() - sum);
+ }
+ if (type == NID::kSize)
+ type = ReadID();
+
+ int numDigests = 0;
+ int numDigestsTotal = 0;
+ for (i = 0; i < folders.Size(); i++)
+ {
+ CNum numSubstreams = numUnpackStreamsInFolders[i];
+ if (numSubstreams != 1 || !folders[i].UnpackCRCDefined)
+ numDigests += numSubstreams;
+ numDigestsTotal += numSubstreams;
+ }
+
+ for (;;)
+ {
+ if (type == NID::kCRC)
+ {
+ CBoolVector digestsDefined2;
+ CRecordVector<UInt32> digests2;
+ ReadHashDigests(numDigests, digestsDefined2, digests2);
+ int digestIndex = 0;
+ for (i = 0; i < folders.Size(); i++)
+ {
+ CNum numSubstreams = numUnpackStreamsInFolders[i];
+ const CFolder &folder = folders[i];
+ if (numSubstreams == 1 && folder.UnpackCRCDefined)
+ {
+ digestsDefined.Add(true);
+ digests.Add(folder.UnpackCRC);
+ }
+ else
+ for (CNum j = 0; j < numSubstreams; j++, digestIndex++)
+ {
+ digestsDefined.Add(digestsDefined2[digestIndex]);
+ digests.Add(digests2[digestIndex]);
+ }
+ }
+ }
+ else if (type == NID::kEnd)
+ {
+ if (digestsDefined.IsEmpty())
+ {
+ BoolVector_Fill_False(digestsDefined, numDigestsTotal);
+ digests.Clear();
+ for (int i = 0; i < numDigestsTotal; i++)
+ digests.Add(0);
+ }
+ return;
+ }
+ else
+ SkipData();
+ type = ReadID();
+ }
+}
+
+void CInArchive::ReadStreamsInfo(
+ const CObjectVector<CByteBuffer> *dataVector,
+ UInt64 &dataOffset,
+ CRecordVector<UInt64> &packSizes,
+ CBoolVector &packCRCsDefined,
+ CRecordVector<UInt32> &packCRCs,
+ CObjectVector<CFolder> &folders,
+ CRecordVector<CNum> &numUnpackStreamsInFolders,
+ CRecordVector<UInt64> &unpackSizes,
+ CBoolVector &digestsDefined,
+ CRecordVector<UInt32> &digests)
+{
+ for (;;)
+ {
+ UInt64 type = ReadID();
+ if (type > ((UInt32)1 << 30))
+ ThrowIncorrect();
+ switch((UInt32)type)
+ {
+ case NID::kEnd:
+ return;
+ case NID::kPackInfo:
+ {
+ ReadPackInfo(dataOffset, packSizes, packCRCsDefined, packCRCs);
+ break;
+ }
+ case NID::kUnpackInfo:
+ {
+ ReadUnpackInfo(dataVector, folders);
+ break;
+ }
+ case NID::kSubStreamsInfo:
+ {
+ ReadSubStreamsInfo(folders, numUnpackStreamsInFolders,
+ unpackSizes, digestsDefined, digests);
+ break;
+ }
+ default:
+ ThrowIncorrect();
+ }
+ }
+}
+
+void CInArchive::ReadBoolVector(int numItems, CBoolVector &v)
+{
+ v.Clear();
+ v.Reserve(numItems);
+ Byte b = 0;
+ Byte mask = 0;
+ for (int i = 0; i < numItems; i++)
+ {
+ if (mask == 0)
+ {
+ b = ReadByte();
+ mask = 0x80;
+ }
+ v.Add((b & mask) != 0);
+ mask >>= 1;
+ }
+}
+
+void CInArchive::ReadBoolVector2(int numItems, CBoolVector &v)
+{
+ Byte allAreDefined = ReadByte();
+ if (allAreDefined == 0)
+ {
+ ReadBoolVector(numItems, v);
+ return;
+ }
+ v.Clear();
+ v.Reserve(numItems);
+ for (int i = 0; i < numItems; i++)
+ v.Add(true);
+}
+
+void CInArchive::ReadUInt64DefVector(const CObjectVector<CByteBuffer> &dataVector,
+ CUInt64DefVector &v, int numFiles)
+{
+ ReadBoolVector2(numFiles, v.Defined);
+
+ CStreamSwitch streamSwitch;
+ streamSwitch.Set(this, &dataVector);
+ v.Values.Reserve(numFiles);
+
+ for (int i = 0; i < numFiles; i++)
+ {
+ UInt64 t = 0;
+ if (v.Defined[i])
+ t = ReadUInt64();
+ v.Values.Add(t);
+ }
+}
+
+HRESULT CInArchive::ReadAndDecodePackedStreams(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ UInt64 baseOffset,
+ UInt64 &dataOffset, CObjectVector<CByteBuffer> &dataVector
+ #ifndef _NO_CRYPTO
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
+ #endif
+ )
+{
+ CRecordVector<UInt64> packSizes;
+ CBoolVector packCRCsDefined;
+ CRecordVector<UInt32> packCRCs;
+ CObjectVector<CFolder> folders;
+
+ CRecordVector<CNum> numUnpackStreamsInFolders;
+ CRecordVector<UInt64> unpackSizes;
+ CBoolVector digestsDefined;
+ CRecordVector<UInt32> digests;
+
+ ReadStreamsInfo(NULL,
+ dataOffset,
+ packSizes,
+ packCRCsDefined,
+ packCRCs,
+ folders,
+ numUnpackStreamsInFolders,
+ unpackSizes,
+ digestsDefined,
+ digests);
+
+ // db.ArchiveInfo.DataStartPosition2 += db.ArchiveInfo.StartPositionAfterHeader;
+
+ CNum packIndex = 0;
+ CDecoder decoder(
+ #ifdef _ST_MODE
+ false
+ #else
+ true
+ #endif
+ );
+ UInt64 dataStartPos = baseOffset + dataOffset;
+ for (int i = 0; i < folders.Size(); i++)
+ {
+ const CFolder &folder = folders[i];
+ dataVector.Add(CByteBuffer());
+ CByteBuffer &data = dataVector.Back();
+ UInt64 unpackSize64 = folder.GetUnpackSize();
+ size_t unpackSize = (size_t)unpackSize64;
+ if (unpackSize != unpackSize64)
+ ThrowUnsupported();
+ data.SetCapacity(unpackSize);
+
+ CSequentialOutStreamImp2 *outStreamSpec = new CSequentialOutStreamImp2;
+ CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
+ outStreamSpec->Init(data, unpackSize);
+
+ HRESULT result = decoder.Decode(
+ EXTERNAL_CODECS_LOC_VARS
+ _stream, dataStartPos,
+ &packSizes[packIndex], folder, outStream, NULL
+ #ifndef _NO_CRYPTO
+ , getTextPassword, passwordIsDefined
+ #endif
+ #ifdef COMPRESS_MT
+ , false, 1
+ #endif
+ );
+ RINOK(result);
+
+ if (folder.UnpackCRCDefined)
+ if (CrcCalc(data, unpackSize) != folder.UnpackCRC)
+ ThrowIncorrect();
+ for (int j = 0; j < folder.PackStreams.Size(); j++)
+ {
+ UInt64 packSize = packSizes[packIndex++];
+ dataStartPos += packSize;
+ HeadersSize += packSize;
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadHeader(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CArchiveDatabaseEx &db
+ #ifndef _NO_CRYPTO
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
+ #endif
+ )
+{
+ UInt64 type = ReadID();
+
+ if (type == NID::kArchiveProperties)
+ {
+ ReadArchiveProperties(db.ArchiveInfo);
+ type = ReadID();
+ }
+
+ CObjectVector<CByteBuffer> dataVector;
+
+ if (type == NID::kAdditionalStreamsInfo)
+ {
+ HRESULT result = ReadAndDecodePackedStreams(
+ EXTERNAL_CODECS_LOC_VARS
+ db.ArchiveInfo.StartPositionAfterHeader,
+ db.ArchiveInfo.DataStartPosition2,
+ dataVector
+ #ifndef _NO_CRYPTO
+ , getTextPassword, passwordIsDefined
+ #endif
+ );
+ RINOK(result);
+ db.ArchiveInfo.DataStartPosition2 += db.ArchiveInfo.StartPositionAfterHeader;
+ type = ReadID();
+ }
+
+ CRecordVector<UInt64> unpackSizes;
+ CBoolVector digestsDefined;
+ CRecordVector<UInt32> digests;
+
+ if (type == NID::kMainStreamsInfo)
+ {
+ ReadStreamsInfo(&dataVector,
+ db.ArchiveInfo.DataStartPosition,
+ db.PackSizes,
+ db.PackCRCsDefined,
+ db.PackCRCs,
+ db.Folders,
+ db.NumUnpackStreamsVector,
+ unpackSizes,
+ digestsDefined,
+ digests);
+ db.ArchiveInfo.DataStartPosition += db.ArchiveInfo.StartPositionAfterHeader;
+ type = ReadID();
+ }
+ else
+ {
+ for (int i = 0; i < db.Folders.Size(); i++)
+ {
+ db.NumUnpackStreamsVector.Add(1);
+ CFolder &folder = db.Folders[i];
+ unpackSizes.Add(folder.GetUnpackSize());
+ digestsDefined.Add(folder.UnpackCRCDefined);
+ digests.Add(folder.UnpackCRC);
+ }
+ }
+
+ db.Files.Clear();
+
+ if (type == NID::kEnd)
+ return S_OK;
+ if (type != NID::kFilesInfo)
+ ThrowIncorrect();
+
+ CNum numFiles = ReadNum();
+ db.Files.Reserve(numFiles);
+ CNum i;
+ for (i = 0; i < numFiles; i++)
+ db.Files.Add(CFileItem());
+
+ db.ArchiveInfo.FileInfoPopIDs.Add(NID::kSize);
+ if (!db.PackSizes.IsEmpty())
+ db.ArchiveInfo.FileInfoPopIDs.Add(NID::kPackInfo);
+ if (numFiles > 0 && !digests.IsEmpty())
+ db.ArchiveInfo.FileInfoPopIDs.Add(NID::kCRC);
+
+ CBoolVector emptyStreamVector;
+ BoolVector_Fill_False(emptyStreamVector, (int)numFiles);
+ CBoolVector emptyFileVector;
+ CBoolVector antiFileVector;
+ CNum numEmptyStreams = 0;
+
+ for (;;)
+ {
+ UInt64 type = ReadID();
+ if (type == NID::kEnd)
+ break;
+ UInt64 size = ReadNumber();
+ size_t ppp = _inByteBack->_pos;
+ bool addPropIdToList = true;
+ bool isKnownType = true;
+ if (type > ((UInt32)1 << 30))
+ isKnownType = false;
+ else switch((UInt32)type)
+ {
+ case NID::kName:
+ {
+ CStreamSwitch streamSwitch;
+ streamSwitch.Set(this, &dataVector);
+ for (int i = 0; i < db.Files.Size(); i++)
+ _inByteBack->ReadString(db.Files[i].Name);
+ break;
+ }
+ case NID::kWinAttributes:
+ {
+ CBoolVector boolVector;
+ ReadBoolVector2(db.Files.Size(), boolVector);
+ CStreamSwitch streamSwitch;
+ streamSwitch.Set(this, &dataVector);
+ for (i = 0; i < numFiles; i++)
+ {
+ CFileItem &file = db.Files[i];
+ file.AttribDefined = boolVector[i];
+ if (file.AttribDefined)
+ file.Attrib = ReadUInt32();
+ }
+ break;
+ }
+ case NID::kEmptyStream:
+ {
+ ReadBoolVector(numFiles, emptyStreamVector);
+ for (i = 0; i < (CNum)emptyStreamVector.Size(); i++)
+ if (emptyStreamVector[i])
+ numEmptyStreams++;
+
+ BoolVector_Fill_False(emptyFileVector, numEmptyStreams);
+ BoolVector_Fill_False(antiFileVector, numEmptyStreams);
+
+ break;
+ }
+ case NID::kEmptyFile: ReadBoolVector(numEmptyStreams, emptyFileVector); break;
+ case NID::kAnti: ReadBoolVector(numEmptyStreams, antiFileVector); break;
+ case NID::kStartPos: ReadUInt64DefVector(dataVector, db.StartPos, (int)numFiles); break;
+ case NID::kCTime: ReadUInt64DefVector(dataVector, db.CTime, (int)numFiles); break;
+ case NID::kATime: ReadUInt64DefVector(dataVector, db.ATime, (int)numFiles); break;
+ case NID::kMTime: ReadUInt64DefVector(dataVector, db.MTime, (int)numFiles); break;
+ case NID::kDummy:
+ {
+ for (UInt64 j = 0; j < size; j++)
+ if (ReadByte() != 0)
+ ThrowIncorrect();
+ addPropIdToList = false;
+ break;
+ }
+ default:
+ addPropIdToList = isKnownType = false;
+ }
+ if (isKnownType)
+ {
+ if(addPropIdToList)
+ db.ArchiveInfo.FileInfoPopIDs.Add(type);
+ }
+ else
+ SkipData(size);
+ bool checkRecordsSize = (db.ArchiveInfo.Version.Major > 0 ||
+ db.ArchiveInfo.Version.Minor > 2);
+ if (checkRecordsSize && _inByteBack->_pos - ppp != size)
+ ThrowIncorrect();
+ }
+
+ CNum emptyFileIndex = 0;
+ CNum sizeIndex = 0;
+
+ CNum numAntiItems = 0;
+ for (i = 0; i < numEmptyStreams; i++)
+ if (antiFileVector[i])
+ numAntiItems++;
+
+ for (i = 0; i < numFiles; i++)
+ {
+ CFileItem &file = db.Files[i];
+ bool isAnti;
+ file.HasStream = !emptyStreamVector[i];
+ if (file.HasStream)
+ {
+ file.IsDir = false;
+ isAnti = false;
+ file.Size = unpackSizes[sizeIndex];
+ file.Crc = digests[sizeIndex];
+ file.CrcDefined = digestsDefined[sizeIndex];
+ sizeIndex++;
+ }
+ else
+ {
+ file.IsDir = !emptyFileVector[emptyFileIndex];
+ isAnti = antiFileVector[emptyFileIndex];
+ emptyFileIndex++;
+ file.Size = 0;
+ file.CrcDefined = false;
+ }
+ if (numAntiItems != 0)
+ db.IsAnti.Add(isAnti);
+ }
+ return S_OK;
+}
+
+
+void CArchiveDatabaseEx::FillFolderStartPackStream()
+{
+ FolderStartPackStreamIndex.Clear();
+ FolderStartPackStreamIndex.Reserve(Folders.Size());
+ CNum startPos = 0;
+ for (int i = 0; i < Folders.Size(); i++)
+ {
+ FolderStartPackStreamIndex.Add(startPos);
+ startPos += (CNum)Folders[i].PackStreams.Size();
+ }
+}
+
+void CArchiveDatabaseEx::FillStartPos()
+{
+ PackStreamStartPositions.Clear();
+ PackStreamStartPositions.Reserve(PackSizes.Size());
+ UInt64 startPos = 0;
+ for (int i = 0; i < PackSizes.Size(); i++)
+ {
+ PackStreamStartPositions.Add(startPos);
+ startPos += PackSizes[i];
+ }
+}
+
+void CArchiveDatabaseEx::FillFolderStartFileIndex()
+{
+ FolderStartFileIndex.Clear();
+ FolderStartFileIndex.Reserve(Folders.Size());
+ FileIndexToFolderIndexMap.Clear();
+ FileIndexToFolderIndexMap.Reserve(Files.Size());
+
+ int folderIndex = 0;
+ CNum indexInFolder = 0;
+ for (int i = 0; i < Files.Size(); i++)
+ {
+ const CFileItem &file = Files[i];
+ bool emptyStream = !file.HasStream;
+ if (emptyStream && indexInFolder == 0)
+ {
+ FileIndexToFolderIndexMap.Add(kNumNoIndex);
+ continue;
+ }
+ if (indexInFolder == 0)
+ {
+ // v3.13 incorrectly worked with empty folders
+ // v4.07: Loop for skipping empty folders
+ for (;;)
+ {
+ if (folderIndex >= Folders.Size())
+ ThrowIncorrect();
+ FolderStartFileIndex.Add(i); // check it
+ if (NumUnpackStreamsVector[folderIndex] != 0)
+ break;
+ folderIndex++;
+ }
+ }
+ FileIndexToFolderIndexMap.Add(folderIndex);
+ if (emptyStream)
+ continue;
+ indexInFolder++;
+ if (indexInFolder >= NumUnpackStreamsVector[folderIndex])
+ {
+ folderIndex++;
+ indexInFolder = 0;
+ }
+ }
+}
+
+HRESULT CInArchive::ReadDatabase2(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CArchiveDatabaseEx &db
+ #ifndef _NO_CRYPTO
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
+ #endif
+ )
+{
+ db.Clear();
+ db.ArchiveInfo.StartPosition = _arhiveBeginStreamPosition;
+
+ db.ArchiveInfo.Version.Major = _header[6];
+ db.ArchiveInfo.Version.Minor = _header[7];
+
+ if (db.ArchiveInfo.Version.Major != kMajorVersion)
+ ThrowUnsupportedVersion();
+
+ UInt32 crcFromArchive = Get32(_header + 8);
+ UInt64 nextHeaderOffset = Get64(_header + 0xC);
+ UInt64 nextHeaderSize = Get64(_header + 0x14);
+ UInt32 nextHeaderCRC = Get32(_header + 0x1C);
+ UInt32 crc = CrcCalc(_header + 0xC, 20);
+
+ #ifdef FORMAT_7Z_RECOVERY
+ if (crcFromArchive == 0 && nextHeaderOffset == 0 && nextHeaderSize == 0 && nextHeaderCRC == 0)
+ {
+ UInt64 cur, cur2;
+ RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &cur));
+ const int kCheckSize = 500;
+ Byte buf[kCheckSize];
+ RINOK(_stream->Seek(0, STREAM_SEEK_END, &cur2));
+ int checkSize = kCheckSize;
+ if (cur2 - cur < static_cast< UInt64 >( kCheckSize ) )
+ checkSize = (int)(cur2 - cur);
+ RINOK(_stream->Seek(-checkSize, STREAM_SEEK_END, &cur2));
+
+ RINOK(ReadStream_FALSE(_stream, buf, (size_t)checkSize));
+
+ int i;
+ for (i = (int)checkSize - 2; i >= 0; i--)
+ if ((buf[i] == 0x17 && buf[i + 1] == 0x6) || (buf[i] == 0x01 && buf[i + 1] == 0x04))
+ break;
+ if (i < 0)
+ return S_FALSE;
+ nextHeaderSize = checkSize - i;
+ nextHeaderOffset = cur2 - cur + i;
+ nextHeaderCRC = CrcCalc(buf + i, (size_t)nextHeaderSize);
+ RINOK(_stream->Seek(cur, STREAM_SEEK_SET, NULL));
+ }
+ #endif
+
+ #ifdef FORMAT_7Z_RECOVERY
+ crcFromArchive = crc;
+ #endif
+
+ db.ArchiveInfo.StartPositionAfterHeader = _arhiveBeginStreamPosition + kHeaderSize;
+
+ if (crc != crcFromArchive)
+ ThrowIncorrect();
+
+ if (nextHeaderSize == 0)
+ return S_OK;
+
+ if (nextHeaderSize > (UInt64)0xFFFFFFFF)
+ return S_FALSE;
+
+ RINOK(_stream->Seek(nextHeaderOffset, STREAM_SEEK_CUR, NULL));
+
+ CByteBuffer buffer2;
+ buffer2.SetCapacity((size_t)nextHeaderSize);
+
+ RINOK(ReadStream_FALSE(_stream, buffer2, (size_t)nextHeaderSize));
+ HeadersSize += kHeaderSize + nextHeaderSize;
+ db.PhySize = kHeaderSize + nextHeaderOffset + nextHeaderSize;
+
+ if (CrcCalc(buffer2, (UInt32)nextHeaderSize) != nextHeaderCRC)
+ ThrowIncorrect();
+
+ CStreamSwitch streamSwitch;
+ streamSwitch.Set(this, buffer2);
+
+ CObjectVector<CByteBuffer> dataVector;
+
+ UInt64 type = ReadID();
+ if (type != NID::kHeader)
+ {
+ if (type != NID::kEncodedHeader)
+ ThrowIncorrect();
+ HRESULT result = ReadAndDecodePackedStreams(
+ EXTERNAL_CODECS_LOC_VARS
+ db.ArchiveInfo.StartPositionAfterHeader,
+ db.ArchiveInfo.DataStartPosition2,
+ dataVector
+ #ifndef _NO_CRYPTO
+ , getTextPassword, passwordIsDefined
+ #endif
+ );
+ RINOK(result);
+ if (dataVector.Size() == 0)
+ return S_OK;
+ if (dataVector.Size() > 1)
+ ThrowIncorrect();
+ streamSwitch.Remove();
+ streamSwitch.Set(this, dataVector.Front());
+ if (ReadID() != NID::kHeader)
+ ThrowIncorrect();
+ }
+
+ db.HeadersSize = HeadersSize;
+
+ return ReadHeader(
+ EXTERNAL_CODECS_LOC_VARS
+ db
+ #ifndef _NO_CRYPTO
+ , getTextPassword, passwordIsDefined
+ #endif
+ );
+}
+
+HRESULT CInArchive::ReadDatabase(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CArchiveDatabaseEx &db
+ #ifndef _NO_CRYPTO
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
+ #endif
+ )
+{
+ try
+ {
+ return ReadDatabase2(
+ EXTERNAL_CODECS_LOC_VARS db
+ #ifndef _NO_CRYPTO
+ , getTextPassword, passwordIsDefined
+ #endif
+ );
+ }
+ catch(CInArchiveException &) { return S_FALSE; }
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zIn.h
new file mode 100644
index 000000000..971f27b2a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zIn.h
@@ -0,0 +1,245 @@
+// 7zIn.h
+
+#ifndef __7Z_IN_H
+#define __7Z_IN_H
+
+#include "../../../Common/MyCom.h"
+
+#include "../../IPassword.h"
+#include "../../IStream.h"
+
+#include "../../Common/CreateCoder.h"
+#include "../../Common/InBuffer.h"
+
+#include "7zItem.h"
+
+namespace NArchive {
+namespace N7z {
+
+struct CInArchiveInfo
+{
+ CArchiveVersion Version;
+ UInt64 StartPosition;
+ UInt64 StartPositionAfterHeader;
+ UInt64 DataStartPosition;
+ UInt64 DataStartPosition2;
+ CRecordVector<UInt64> FileInfoPopIDs;
+ void Clear()
+ {
+ FileInfoPopIDs.Clear();
+ }
+};
+
+struct CArchiveDatabaseEx: public CArchiveDatabase
+{
+ CInArchiveInfo ArchiveInfo;
+ CRecordVector<UInt64> PackStreamStartPositions;
+ CRecordVector<CNum> FolderStartPackStreamIndex;
+ CRecordVector<CNum> FolderStartFileIndex;
+ CRecordVector<CNum> FileIndexToFolderIndexMap;
+
+ UInt64 HeadersSize;
+ UInt64 PhySize;
+
+ void Clear()
+ {
+ CArchiveDatabase::Clear();
+ ArchiveInfo.Clear();
+ PackStreamStartPositions.Clear();
+ FolderStartPackStreamIndex.Clear();
+ FolderStartFileIndex.Clear();
+ FileIndexToFolderIndexMap.Clear();
+
+ HeadersSize = 0;
+ PhySize = 0;
+ }
+
+ void FillFolderStartPackStream();
+ void FillStartPos();
+ void FillFolderStartFileIndex();
+
+ void Fill()
+ {
+ FillFolderStartPackStream();
+ FillStartPos();
+ FillFolderStartFileIndex();
+ }
+
+ UInt64 GetFolderStreamPos(int folderIndex, int indexInFolder) const
+ {
+ return ArchiveInfo.DataStartPosition +
+ PackStreamStartPositions[FolderStartPackStreamIndex[folderIndex] + indexInFolder];
+ }
+
+ UInt64 GetFolderFullPackSize(int folderIndex) const
+ {
+ CNum packStreamIndex = FolderStartPackStreamIndex[folderIndex];
+ const CFolder &folder = Folders[folderIndex];
+ UInt64 size = 0;
+ for (int i = 0; i < folder.PackStreams.Size(); i++)
+ size += PackSizes[packStreamIndex + i];
+ return size;
+ }
+
+ UInt64 GetFolderPackStreamSize(int folderIndex, int streamIndex) const
+ {
+ return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex];
+ }
+
+ UInt64 GetFilePackSize(CNum fileIndex) const
+ {
+ CNum folderIndex = FileIndexToFolderIndexMap[fileIndex];
+ if (folderIndex != kNumNoIndex)
+ if (FolderStartFileIndex[folderIndex] == fileIndex)
+ return GetFolderFullPackSize(folderIndex);
+ return 0;
+ }
+};
+
+class CInByte2
+{
+ const Byte *_buffer;
+ size_t _size;
+public:
+ size_t _pos;
+ void Init(const Byte *buffer, size_t size)
+ {
+ _buffer = buffer;
+ _size = size;
+ _pos = 0;
+ }
+ Byte ReadByte();
+ void ReadBytes(Byte *data, size_t size);
+ void SkipData(UInt64 size);
+ void SkipData();
+ UInt64 ReadNumber();
+ CNum ReadNum();
+ UInt32 ReadUInt32();
+ UInt64 ReadUInt64();
+ void ReadString(UString &s);
+};
+
+class CStreamSwitch;
+
+const UInt32 kHeaderSize = 32;
+
+class CInArchive
+{
+ friend class CStreamSwitch;
+
+ CMyComPtr<IInStream> _stream;
+
+ CObjectVector<CInByte2> _inByteVector;
+ CInByte2 *_inByteBack;
+
+ UInt64 _arhiveBeginStreamPosition;
+
+ Byte _header[kHeaderSize];
+
+ UInt64 HeadersSize;
+
+ void AddByteStream(const Byte *buffer, size_t size)
+ {
+ _inByteVector.Add(CInByte2());
+ _inByteBack = &_inByteVector.Back();
+ _inByteBack->Init(buffer, size);
+ }
+
+ void DeleteByteStream()
+ {
+ _inByteVector.DeleteBack();
+ if (!_inByteVector.IsEmpty())
+ _inByteBack = &_inByteVector.Back();
+ }
+
+private:
+ HRESULT FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
+
+ void ReadBytes(Byte *data, size_t size) { _inByteBack->ReadBytes(data, size); }
+ Byte ReadByte() { return _inByteBack->ReadByte(); }
+ UInt64 ReadNumber() { return _inByteBack->ReadNumber(); }
+ CNum ReadNum() { return _inByteBack->ReadNum(); }
+ UInt64 ReadID() { return _inByteBack->ReadNumber(); }
+ UInt32 ReadUInt32() { return _inByteBack->ReadUInt32(); }
+ UInt64 ReadUInt64() { return _inByteBack->ReadUInt64(); }
+ void SkipData(UInt64 size) { _inByteBack->SkipData(size); }
+ void SkipData() { _inByteBack->SkipData(); }
+ void WaitAttribute(UInt64 attribute);
+
+ void ReadArchiveProperties(CInArchiveInfo &archiveInfo);
+ void GetNextFolderItem(CFolder &itemInfo);
+ void ReadHashDigests(int numItems,
+ CBoolVector &digestsDefined, CRecordVector<UInt32> &digests);
+
+ void ReadPackInfo(
+ UInt64 &dataOffset,
+ CRecordVector<UInt64> &packSizes,
+ CBoolVector &packCRCsDefined,
+ CRecordVector<UInt32> &packCRCs);
+
+ void ReadUnpackInfo(
+ const CObjectVector<CByteBuffer> *dataVector,
+ CObjectVector<CFolder> &folders);
+
+ void ReadSubStreamsInfo(
+ const CObjectVector<CFolder> &folders,
+ CRecordVector<CNum> &numUnpackStreamsInFolders,
+ CRecordVector<UInt64> &unpackSizes,
+ CBoolVector &digestsDefined,
+ CRecordVector<UInt32> &digests);
+
+ void ReadStreamsInfo(
+ const CObjectVector<CByteBuffer> *dataVector,
+ UInt64 &dataOffset,
+ CRecordVector<UInt64> &packSizes,
+ CBoolVector &packCRCsDefined,
+ CRecordVector<UInt32> &packCRCs,
+ CObjectVector<CFolder> &folders,
+ CRecordVector<CNum> &numUnpackStreamsInFolders,
+ CRecordVector<UInt64> &unpackSizes,
+ CBoolVector &digestsDefined,
+ CRecordVector<UInt32> &digests);
+
+
+ void ReadBoolVector(int numItems, CBoolVector &v);
+ void ReadBoolVector2(int numItems, CBoolVector &v);
+ void ReadUInt64DefVector(const CObjectVector<CByteBuffer> &dataVector,
+ CUInt64DefVector &v, int numFiles);
+ HRESULT ReadAndDecodePackedStreams(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ UInt64 baseOffset, UInt64 &dataOffset,
+ CObjectVector<CByteBuffer> &dataVector
+ #ifndef _NO_CRYPTO
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
+ #endif
+ );
+ HRESULT ReadHeader(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CArchiveDatabaseEx &db
+ #ifndef _NO_CRYPTO
+ ,ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
+ #endif
+ );
+ HRESULT ReadDatabase2(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CArchiveDatabaseEx &db
+ #ifndef _NO_CRYPTO
+ ,ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
+ #endif
+ );
+public:
+ HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
+ void Close();
+
+ HRESULT ReadDatabase(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CArchiveDatabaseEx &db
+ #ifndef _NO_CRYPTO
+ ,ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
+ #endif
+ );
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zItem.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zItem.h
new file mode 100644
index 000000000..1c3068bb2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zItem.h
@@ -0,0 +1,258 @@
+// 7zItem.h
+
+#ifndef __7Z_ITEM_H
+#define __7Z_ITEM_H
+
+#include "../../../Common/Buffer.h"
+#include "../../../Common/MyString.h"
+
+#include "../../Common/MethodId.h"
+
+#include "7zHeader.h"
+
+namespace NArchive {
+namespace N7z {
+
+typedef UInt32 CNum;
+const CNum kNumMax = 0x7FFFFFFF;
+const CNum kNumNoIndex = 0xFFFFFFFF;
+
+struct CCoderInfo
+{
+ CMethodId MethodID;
+ CByteBuffer Props;
+ CNum NumInStreams;
+ CNum NumOutStreams;
+ bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
+};
+
+struct CBindPair
+{
+ CNum InIndex;
+ CNum OutIndex;
+};
+
+struct CFolder
+{
+ CObjectVector<CCoderInfo> Coders;
+ CRecordVector<CBindPair> BindPairs;
+ CRecordVector<CNum> PackStreams;
+ CRecordVector<UInt64> UnpackSizes;
+ UInt32 UnpackCRC;
+ bool UnpackCRCDefined;
+
+ CFolder(): UnpackCRCDefined(false) {}
+
+ UInt64 GetUnpackSize() const // test it
+ {
+ if (UnpackSizes.IsEmpty())
+ return 0;
+ for (int i = UnpackSizes.Size() - 1; i >= 0; i--)
+ if (FindBindPairForOutStream(i) < 0)
+ return UnpackSizes[i];
+ throw 1;
+ }
+
+ CNum GetNumOutStreams() const
+ {
+ CNum result = 0;
+ for (int i = 0; i < Coders.Size(); i++)
+ result += Coders[i].NumOutStreams;
+ return result;
+ }
+
+ int FindBindPairForInStream(CNum inStreamIndex) const
+ {
+ for(int i = 0; i < BindPairs.Size(); i++)
+ if (BindPairs[i].InIndex == inStreamIndex)
+ return i;
+ return -1;
+ }
+ int FindBindPairForOutStream(CNum outStreamIndex) const
+ {
+ for(int i = 0; i < BindPairs.Size(); i++)
+ if (BindPairs[i].OutIndex == outStreamIndex)
+ return i;
+ return -1;
+ }
+ int FindPackStreamArrayIndex(CNum inStreamIndex) const
+ {
+ for(int i = 0; i < PackStreams.Size(); i++)
+ if (PackStreams[i] == inStreamIndex)
+ return i;
+ return -1;
+ }
+
+ bool CheckStructure() const;
+};
+
+struct CUInt64DefVector
+{
+ CRecordVector<UInt64> Values;
+ CRecordVector<bool> Defined;
+
+ void Clear()
+ {
+ Values.Clear();
+ Defined.Clear();
+ }
+
+ void ReserveDown()
+ {
+ Values.ReserveDown();
+ Values.ReserveDown();
+ }
+
+ bool GetItem(int index, UInt64 &value) const
+ {
+ if (index < Defined.Size() && Defined[index])
+ {
+ value = Values[index];
+ return true;
+ }
+ value = 0;
+ return false;
+ }
+
+ void SetItem(int index, bool defined, UInt64 value)
+ {
+ while (index >= Defined.Size())
+ Defined.Add(false);
+ Defined[index] = defined;
+ if (!defined)
+ return;
+ while (index >= Values.Size())
+ Values.Add(0);
+ Values[index] = value;
+ }
+
+ bool CheckSize(int size) const { return Defined.Size() == size || Defined.Size() == 0; }
+};
+
+struct CFileItem
+{
+ UInt64 Size;
+ UInt32 Attrib;
+ UInt32 Crc;
+ UString Name;
+
+ bool HasStream; // Test it !!! it means that there is
+ // stream in some folder. It can be empty stream
+ bool IsDir;
+ bool CrcDefined;
+ bool AttribDefined;
+
+ CFileItem():
+ HasStream(true),
+ IsDir(false),
+ CrcDefined(false),
+ AttribDefined(false)
+ {}
+ void SetAttrib(UInt32 attrib)
+ {
+ AttribDefined = true;
+ Attrib = attrib;
+ }
+};
+
+struct CFileItem2
+{
+ UInt64 CTime;
+ UInt64 ATime;
+ UInt64 MTime;
+ UInt64 StartPos;
+ bool CTimeDefined;
+ bool ATimeDefined;
+ bool MTimeDefined;
+ bool StartPosDefined;
+ bool IsAnti;
+};
+
+struct CArchiveDatabase
+{
+ CRecordVector<UInt64> PackSizes;
+ CRecordVector<bool> PackCRCsDefined;
+ CRecordVector<UInt32> PackCRCs;
+ CObjectVector<CFolder> Folders;
+ CRecordVector<CNum> NumUnpackStreamsVector;
+ CObjectVector<CFileItem> Files;
+
+ CUInt64DefVector CTime;
+ CUInt64DefVector ATime;
+ CUInt64DefVector MTime;
+ CUInt64DefVector StartPos;
+ CRecordVector<bool> IsAnti;
+
+ void Clear()
+ {
+ PackSizes.Clear();
+ PackCRCsDefined.Clear();
+ PackCRCs.Clear();
+ Folders.Clear();
+ NumUnpackStreamsVector.Clear();
+ Files.Clear();
+ CTime.Clear();
+ ATime.Clear();
+ MTime.Clear();
+ StartPos.Clear();
+ IsAnti.Clear();
+ }
+
+ void ReserveDown()
+ {
+ PackSizes.ReserveDown();
+ PackCRCsDefined.ReserveDown();
+ PackCRCs.ReserveDown();
+ Folders.ReserveDown();
+ NumUnpackStreamsVector.ReserveDown();
+ Files.ReserveDown();
+ CTime.ReserveDown();
+ ATime.ReserveDown();
+ MTime.ReserveDown();
+ StartPos.ReserveDown();
+ IsAnti.ReserveDown();
+ }
+
+ bool IsEmpty() const
+ {
+ return (PackSizes.IsEmpty() &&
+ PackCRCsDefined.IsEmpty() &&
+ PackCRCs.IsEmpty() &&
+ Folders.IsEmpty() &&
+ NumUnpackStreamsVector.IsEmpty() &&
+ Files.IsEmpty());
+ }
+
+ bool CheckNumFiles() const
+ {
+ int size = Files.Size();
+ return (
+ CTime.CheckSize(size) &&
+ ATime.CheckSize(size) &&
+ MTime.CheckSize(size) &&
+ StartPos.CheckSize(size) &&
+ (size == IsAnti.Size() || IsAnti.Size() == 0));
+ }
+
+ bool IsSolid() const
+ {
+ for (int i = 0; i < NumUnpackStreamsVector.Size(); i++)
+ if (NumUnpackStreamsVector[i] > 1)
+ return true;
+ return false;
+ }
+ bool IsItemAnti(int index) const { return (index < IsAnti.Size() && IsAnti[index]); }
+ void SetItemAnti(int index, bool isAnti)
+ {
+ while (index >= IsAnti.Size())
+ IsAnti.Add(false);
+ IsAnti[index] = isAnti;
+ }
+
+ void GetFile(int index, CFileItem &file, CFileItem2 &file2) const;
+ void AddFile(const CFileItem &file, const CFileItem2 &file2);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zOut.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zOut.cpp
new file mode 100644
index 000000000..1bd8c4c36
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zOut.cpp
@@ -0,0 +1,874 @@
+// 7zOut.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/7zCrc.h"
+
+#include "../../../Common/AutoPtr.h"
+
+#include "../../Common/StreamObjects.h"
+
+#include "7zOut.h"
+
+static HRESULT WriteBytes(ISequentialOutStream *stream, const void *data, size_t size)
+{
+ while (size > 0)
+ {
+ UInt32 curSize = (UInt32)MyMin(size, (size_t)0xFFFFFFFF);
+ UInt32 processedSize;
+ RINOK(stream->Write(data, curSize, &processedSize));
+ if (processedSize == 0)
+ return E_FAIL;
+ data = (const void *)((const Byte *)data + processedSize);
+ size -= processedSize;
+ }
+ return S_OK;
+}
+
+namespace NArchive {
+namespace N7z {
+
+HRESULT COutArchive::WriteDirect(const void *data, UInt32 size)
+{
+ return ::WriteBytes(SeqStream, data, size);
+}
+
+HRESULT COutArchive::WriteSignature()
+{
+ Byte buf[8];
+ memcpy(buf, kSignature, kSignatureSize);
+ buf[kSignatureSize] = kMajorVersion;
+ buf[kSignatureSize + 1] = 3;
+ return WriteDirect(buf, 8);
+}
+
+#ifdef _7Z_VOL
+HRESULT COutArchive::WriteFinishSignature()
+{
+ RINOK(WriteDirect(kFinishSignature, kSignatureSize));
+ CArchiveVersion av;
+ av.Major = kMajorVersion;
+ av.Minor = 2;
+ RINOK(WriteDirectByte(av.Major));
+ return WriteDirectByte(av.Minor);
+}
+#endif
+
+static void SetUInt32(Byte *p, UInt32 d)
+{
+ for (int i = 0; i < 4; i++, d >>= 8)
+ p[i] = (Byte)d;
+}
+
+static void SetUInt64(Byte *p, UInt64 d)
+{
+ for (int i = 0; i < 8; i++, d >>= 8)
+ p[i] = (Byte)d;
+}
+
+HRESULT COutArchive::WriteStartHeader(const CStartHeader &h)
+{
+ Byte buf[24];
+ SetUInt64(buf + 4, h.NextHeaderOffset);
+ SetUInt64(buf + 12, h.NextHeaderSize);
+ SetUInt32(buf + 20, h.NextHeaderCRC);
+ SetUInt32(buf, CrcCalc(buf + 4, 20));
+ return WriteDirect(buf, 24);
+}
+
+#ifdef _7Z_VOL
+HRESULT COutArchive::WriteFinishHeader(const CFinishHeader &h)
+{
+ CCRC crc;
+ crc.UpdateUInt64(h.NextHeaderOffset);
+ crc.UpdateUInt64(h.NextHeaderSize);
+ crc.UpdateUInt32(h.NextHeaderCRC);
+ crc.UpdateUInt64(h.ArchiveStartOffset);
+ crc.UpdateUInt64(h.AdditionalStartBlockSize);
+ RINOK(WriteDirectUInt32(crc.GetDigest()));
+ RINOK(WriteDirectUInt64(h.NextHeaderOffset));
+ RINOK(WriteDirectUInt64(h.NextHeaderSize));
+ RINOK(WriteDirectUInt32(h.NextHeaderCRC));
+ RINOK(WriteDirectUInt64(h.ArchiveStartOffset));
+ return WriteDirectUInt64(h.AdditionalStartBlockSize);
+}
+#endif
+
+HRESULT COutArchive::Create(ISequentialOutStream *stream, bool endMarker)
+{
+ Close();
+ #ifdef _7Z_VOL
+ // endMarker = false;
+ _endMarker = endMarker;
+ #endif
+ SeqStream = stream;
+ if (!endMarker)
+ {
+ SeqStream.QueryInterface(IID_IOutStream, &Stream);
+ if (!Stream)
+ {
+ return E_NOTIMPL;
+ // endMarker = true;
+ }
+ }
+ #ifdef _7Z_VOL
+ if (endMarker)
+ {
+ /*
+ CStartHeader sh;
+ sh.NextHeaderOffset = (UInt32)(Int32)-1;
+ sh.NextHeaderSize = (UInt32)(Int32)-1;
+ sh.NextHeaderCRC = 0;
+ WriteStartHeader(sh);
+ */
+ }
+ else
+ #endif
+ {
+ if (!Stream)
+ return E_FAIL;
+ RINOK(WriteSignature());
+ RINOK(Stream->Seek(0, STREAM_SEEK_CUR, &_prefixHeaderPos));
+ }
+ return S_OK;
+}
+
+void COutArchive::Close()
+{
+ SeqStream.Release();
+ Stream.Release();
+}
+
+HRESULT COutArchive::SkipPrefixArchiveHeader()
+{
+ #ifdef _7Z_VOL
+ if (_endMarker)
+ return S_OK;
+ #endif
+ return Stream->Seek(24, STREAM_SEEK_CUR, NULL);
+}
+
+UInt64 COutArchive::GetPos() const
+{
+ if (_countMode)
+ return _countSize;
+ if (_writeToStream)
+ return _outByte.GetProcessedSize();
+ return _outByte2.GetPos();
+}
+
+void COutArchive::WriteBytes(const void *data, size_t size)
+{
+ if (_countMode)
+ _countSize += size;
+ else if (_writeToStream)
+ {
+ _outByte.WriteBytes(data, size);
+ _crc = CrcUpdate(_crc, data, size);
+ }
+ else
+ _outByte2.WriteBytes(data, size);
+}
+
+void COutArchive::WriteByte(Byte b)
+{
+ if (_countMode)
+ _countSize++;
+ else if (_writeToStream)
+ {
+ _outByte.WriteByte(b);
+ _crc = CRC_UPDATE_BYTE(_crc, b);
+ }
+ else
+ _outByte2.WriteByte(b);
+}
+
+void COutArchive::WriteUInt32(UInt32 value)
+{
+ for (int i = 0; i < 4; i++)
+ {
+ WriteByte((Byte)value);
+ value >>= 8;
+ }
+}
+
+void COutArchive::WriteUInt64(UInt64 value)
+{
+ for (int i = 0; i < 8; i++)
+ {
+ WriteByte((Byte)value);
+ value >>= 8;
+ }
+}
+
+void COutArchive::WriteNumber(UInt64 value)
+{
+ Byte firstByte = 0;
+ Byte mask = 0x80;
+ int i;
+ for (i = 0; i < 8; i++)
+ {
+ if (value < ((UInt64(1) << ( 7 * (i + 1)))))
+ {
+ firstByte |= Byte(value >> (8 * i));
+ break;
+ }
+ firstByte |= mask;
+ mask >>= 1;
+ }
+ WriteByte(firstByte);
+ for (;i > 0; i--)
+ {
+ WriteByte((Byte)value);
+ value >>= 8;
+ }
+}
+
+static UInt32 GetBigNumberSize(UInt64 value)
+{
+ int i;
+ for (i = 1; i < 9; i++)
+ if (value < (((UInt64)1 << (i * 7))))
+ break;
+ return i;
+}
+
+#ifdef _7Z_VOL
+UInt32 COutArchive::GetVolHeadersSize(UInt64 dataSize, int nameLength, bool props)
+{
+ UInt32 result = GetBigNumberSize(dataSize) * 2 + 41;
+ if (nameLength != 0)
+ {
+ nameLength = (nameLength + 1) * 2;
+ result += nameLength + GetBigNumberSize(nameLength) + 2;
+ }
+ if (props)
+ {
+ result += 20;
+ }
+ if (result >= 128)
+ result++;
+ result += kSignatureSize + 2 + kFinishHeaderSize;
+ return result;
+}
+
+UInt64 COutArchive::GetVolPureSize(UInt64 volSize, int nameLength, bool props)
+{
+ UInt32 headersSizeBase = COutArchive::GetVolHeadersSize(1, nameLength, props);
+ int testSize;
+ if (volSize > headersSizeBase)
+ testSize = volSize - headersSizeBase;
+ else
+ testSize = 1;
+ UInt32 headersSize = COutArchive::GetVolHeadersSize(testSize, nameLength, props);
+ UInt64 pureSize = 1;
+ if (volSize > headersSize)
+ pureSize = volSize - headersSize;
+ return pureSize;
+}
+#endif
+
+void COutArchive::WriteFolder(const CFolder &folder)
+{
+ WriteNumber(folder.Coders.Size());
+ int i;
+ for (i = 0; i < folder.Coders.Size(); i++)
+ {
+ const CCoderInfo &coder = folder.Coders[i];
+ {
+ size_t propsSize = coder.Props.GetCapacity();
+
+ UInt64 id = coder.MethodID;
+ unsigned int idSize;
+ for (idSize = 1; idSize < sizeof(id); idSize++)
+ if ((id >> (8 * idSize)) == 0)
+ break;
+ BYTE longID[15];
+ for (int t = idSize - 1; t >= 0 ; t--, id >>= 8)
+ longID[t] = (Byte)(id & 0xFF);
+ Byte b;
+ b = (Byte)(idSize & 0xF);
+ bool isComplex = !coder.IsSimpleCoder();
+ b |= (isComplex ? 0x10 : 0);
+ b |= ((propsSize != 0) ? 0x20 : 0 );
+ WriteByte(b);
+ WriteBytes(longID, idSize);
+ if (isComplex)
+ {
+ WriteNumber(coder.NumInStreams);
+ WriteNumber(coder.NumOutStreams);
+ }
+ if (propsSize == 0)
+ continue;
+ WriteNumber(propsSize);
+ WriteBytes(coder.Props, propsSize);
+ }
+ }
+ for (i = 0; i < folder.BindPairs.Size(); i++)
+ {
+ const CBindPair &bindPair = folder.BindPairs[i];
+ WriteNumber(bindPair.InIndex);
+ WriteNumber(bindPair.OutIndex);
+ }
+ if (folder.PackStreams.Size() > 1)
+ for (i = 0; i < folder.PackStreams.Size(); i++)
+ {
+ WriteNumber(folder.PackStreams[i]);
+ }
+}
+
+void COutArchive::WriteBoolVector(const CBoolVector &boolVector)
+{
+ Byte b = 0;
+ Byte mask = 0x80;
+ for (int i = 0; i < boolVector.Size(); i++)
+ {
+ if (boolVector[i])
+ b |= mask;
+ mask >>= 1;
+ if (mask == 0)
+ {
+ WriteByte(b);
+ mask = 0x80;
+ b = 0;
+ }
+ }
+ if (mask != 0x80)
+ WriteByte(b);
+}
+
+
+void COutArchive::WriteHashDigests(
+ const CRecordVector<bool> &digestsDefined,
+ const CRecordVector<UInt32> &digests)
+{
+ int numDefined = 0;
+ int i;
+ for (i = 0; i < digestsDefined.Size(); i++)
+ if (digestsDefined[i])
+ numDefined++;
+ if (numDefined == 0)
+ return;
+
+ WriteByte(NID::kCRC);
+ if (numDefined == digestsDefined.Size())
+ WriteByte(1);
+ else
+ {
+ WriteByte(0);
+ WriteBoolVector(digestsDefined);
+ }
+ for (i = 0; i < digests.Size(); i++)
+ if (digestsDefined[i])
+ WriteUInt32(digests[i]);
+}
+
+void COutArchive::WritePackInfo(
+ UInt64 dataOffset,
+ const CRecordVector<UInt64> &packSizes,
+ const CRecordVector<bool> &packCRCsDefined,
+ const CRecordVector<UInt32> &packCRCs)
+{
+ if (packSizes.IsEmpty())
+ return;
+ WriteByte(NID::kPackInfo);
+ WriteNumber(dataOffset);
+ WriteNumber(packSizes.Size());
+ WriteByte(NID::kSize);
+ for (int i = 0; i < packSizes.Size(); i++)
+ WriteNumber(packSizes[i]);
+
+ WriteHashDigests(packCRCsDefined, packCRCs);
+
+ WriteByte(NID::kEnd);
+}
+
+void COutArchive::WriteUnpackInfo(const CObjectVector<CFolder> &folders)
+{
+ if (folders.IsEmpty())
+ return;
+
+ WriteByte(NID::kUnpackInfo);
+
+ WriteByte(NID::kFolder);
+ WriteNumber(folders.Size());
+ {
+ WriteByte(0);
+ for (int i = 0; i < folders.Size(); i++)
+ WriteFolder(folders[i]);
+ }
+
+ WriteByte(NID::kCodersUnpackSize);
+ int i;
+ for (i = 0; i < folders.Size(); i++)
+ {
+ const CFolder &folder = folders[i];
+ for (int j = 0; j < folder.UnpackSizes.Size(); j++)
+ WriteNumber(folder.UnpackSizes[j]);
+ }
+
+ CRecordVector<bool> unpackCRCsDefined;
+ CRecordVector<UInt32> unpackCRCs;
+ for (i = 0; i < folders.Size(); i++)
+ {
+ const CFolder &folder = folders[i];
+ unpackCRCsDefined.Add(folder.UnpackCRCDefined);
+ unpackCRCs.Add(folder.UnpackCRC);
+ }
+ WriteHashDigests(unpackCRCsDefined, unpackCRCs);
+
+ WriteByte(NID::kEnd);
+}
+
+void COutArchive::WriteSubStreamsInfo(
+ const CObjectVector<CFolder> &folders,
+ const CRecordVector<CNum> &numUnpackStreamsInFolders,
+ const CRecordVector<UInt64> &unpackSizes,
+ const CRecordVector<bool> &digestsDefined,
+ const CRecordVector<UInt32> &digests)
+{
+ WriteByte(NID::kSubStreamsInfo);
+
+ int i;
+ for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
+ {
+ if (numUnpackStreamsInFolders[i] != 1)
+ {
+ WriteByte(NID::kNumUnpackStream);
+ for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
+ WriteNumber(numUnpackStreamsInFolders[i]);
+ break;
+ }
+ }
+
+
+ bool needFlag = true;
+ CNum index = 0;
+ for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
+ for (CNum j = 0; j < numUnpackStreamsInFolders[i]; j++)
+ {
+ if (j + 1 != numUnpackStreamsInFolders[i])
+ {
+ if (needFlag)
+ WriteByte(NID::kSize);
+ needFlag = false;
+ WriteNumber(unpackSizes[index]);
+ }
+ index++;
+ }
+
+ CRecordVector<bool> digestsDefined2;
+ CRecordVector<UInt32> digests2;
+
+ int digestIndex = 0;
+ for (i = 0; i < folders.Size(); i++)
+ {
+ int numSubStreams = (int)numUnpackStreamsInFolders[i];
+ if (numSubStreams == 1 && folders[i].UnpackCRCDefined)
+ digestIndex++;
+ else
+ for (int j = 0; j < numSubStreams; j++, digestIndex++)
+ {
+ digestsDefined2.Add(digestsDefined[digestIndex]);
+ digests2.Add(digests[digestIndex]);
+ }
+ }
+ WriteHashDigests(digestsDefined2, digests2);
+ WriteByte(NID::kEnd);
+}
+
+void COutArchive::SkipAlign(unsigned /* pos */, unsigned /* alignSize */)
+{
+ return;
+}
+
+/*
+7-Zip 4.50 - 4.58 contain BUG, so they do not support .7z archives with Unknown field.
+
+void COutArchive::SkipAlign(unsigned pos, unsigned alignSize)
+{
+ pos += (unsigned)GetPos();
+ pos &= (alignSize - 1);
+ if (pos == 0)
+ return;
+ unsigned skip = alignSize - pos;
+ if (skip < 2)
+ skip += alignSize;
+ skip -= 2;
+ WriteByte(NID::kDummy);
+ WriteByte((Byte)skip);
+ for (unsigned i = 0; i < skip; i++)
+ WriteByte(0);
+}
+*/
+
+void COutArchive::WriteAlignedBoolHeader(const CBoolVector &v, int numDefined, Byte type, unsigned itemSize)
+{
+ const UInt64 bvSize = (numDefined == v.Size()) ? 0 : (v.Size() + 7) / 8;
+ const UInt64 dataSize = (UInt64)numDefined * itemSize + bvSize + 2;
+ SkipAlign(3 + (unsigned)bvSize + (unsigned)GetBigNumberSize(dataSize), itemSize);
+
+ WriteByte(type);
+ WriteNumber(dataSize);
+ if (numDefined == v.Size())
+ WriteByte(1);
+ else
+ {
+ WriteByte(0);
+ WriteBoolVector(v);
+ }
+ WriteByte(0);
+}
+
+void COutArchive::WriteUInt64DefVector(const CUInt64DefVector &v, Byte type)
+{
+ int numDefined = 0;
+
+ int i;
+ for (i = 0; i < v.Defined.Size(); i++)
+ if (v.Defined[i])
+ numDefined++;
+
+ if (numDefined == 0)
+ return;
+
+ WriteAlignedBoolHeader(v.Defined, numDefined, type, 8);
+
+ for (i = 0; i < v.Defined.Size(); i++)
+ if (v.Defined[i])
+ WriteUInt64(v.Values[i]);
+}
+
+HRESULT COutArchive::EncodeStream(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CEncoder &encoder, const Byte *data, size_t dataSize,
+ CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders)
+{
+ CSequentialInStreamImp *streamSpec = new CSequentialInStreamImp;
+ CMyComPtr<ISequentialInStream> stream = streamSpec;
+ streamSpec->Init(data, dataSize);
+ CFolder folderItem;
+ folderItem.UnpackCRCDefined = true;
+ folderItem.UnpackCRC = CrcCalc(data, dataSize);
+ UInt64 dataSize64 = dataSize;
+ RINOK(encoder.Encode(
+ EXTERNAL_CODECS_LOC_VARS
+ stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL))
+ folders.Add(folderItem);
+ return S_OK;
+}
+
+HRESULT COutArchive::EncodeStream(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CEncoder &encoder, const CByteBuffer &data,
+ CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders)
+{
+ return EncodeStream(
+ EXTERNAL_CODECS_LOC_VARS
+ encoder, data, data.GetCapacity(), packSizes, folders);
+}
+
+void COutArchive::WriteHeader(
+ const CArchiveDatabase &db,
+ const CHeaderOptions &headerOptions,
+ UInt64 &headerOffset)
+{
+ int i;
+
+ UInt64 packedSize = 0;
+ for (i = 0; i < db.PackSizes.Size(); i++)
+ packedSize += db.PackSizes[i];
+
+ headerOffset = packedSize;
+
+ WriteByte(NID::kHeader);
+
+ // Archive Properties
+
+ if (db.Folders.Size() > 0)
+ {
+ WriteByte(NID::kMainStreamsInfo);
+ WritePackInfo(0, db.PackSizes,
+ db.PackCRCsDefined,
+ db.PackCRCs);
+
+ WriteUnpackInfo(db.Folders);
+
+ CRecordVector<UInt64> unpackSizes;
+ CRecordVector<bool> digestsDefined;
+ CRecordVector<UInt32> digests;
+ for (i = 0; i < db.Files.Size(); i++)
+ {
+ const CFileItem &file = db.Files[i];
+ if (!file.HasStream)
+ continue;
+ unpackSizes.Add(file.Size);
+ digestsDefined.Add(file.CrcDefined);
+ digests.Add(file.Crc);
+ }
+
+ WriteSubStreamsInfo(
+ db.Folders,
+ db.NumUnpackStreamsVector,
+ unpackSizes,
+ digestsDefined,
+ digests);
+ WriteByte(NID::kEnd);
+ }
+
+ if (db.Files.IsEmpty())
+ {
+ WriteByte(NID::kEnd);
+ return;
+ }
+
+ WriteByte(NID::kFilesInfo);
+ WriteNumber(db.Files.Size());
+
+ {
+ /* ---------- Empty Streams ---------- */
+ CBoolVector emptyStreamVector;
+ emptyStreamVector.Reserve(db.Files.Size());
+ int numEmptyStreams = 0;
+ for (i = 0; i < db.Files.Size(); i++)
+ if (db.Files[i].HasStream)
+ emptyStreamVector.Add(false);
+ else
+ {
+ emptyStreamVector.Add(true);
+ numEmptyStreams++;
+ }
+ if (numEmptyStreams > 0)
+ {
+ WriteByte(NID::kEmptyStream);
+ WriteNumber((emptyStreamVector.Size() + 7) / 8);
+ WriteBoolVector(emptyStreamVector);
+
+ CBoolVector emptyFileVector, antiVector;
+ emptyFileVector.Reserve(numEmptyStreams);
+ antiVector.Reserve(numEmptyStreams);
+ CNum numEmptyFiles = 0, numAntiItems = 0;
+ for (i = 0; i < db.Files.Size(); i++)
+ {
+ const CFileItem &file = db.Files[i];
+ if (!file.HasStream)
+ {
+ emptyFileVector.Add(!file.IsDir);
+ if (!file.IsDir)
+ numEmptyFiles++;
+ bool isAnti = db.IsItemAnti(i);
+ antiVector.Add(isAnti);
+ if (isAnti)
+ numAntiItems++;
+ }
+ }
+
+ if (numEmptyFiles > 0)
+ {
+ WriteByte(NID::kEmptyFile);
+ WriteNumber((emptyFileVector.Size() + 7) / 8);
+ WriteBoolVector(emptyFileVector);
+ }
+
+ if (numAntiItems > 0)
+ {
+ WriteByte(NID::kAnti);
+ WriteNumber((antiVector.Size() + 7) / 8);
+ WriteBoolVector(antiVector);
+ }
+ }
+ }
+
+
+ {
+ /* ---------- Names ---------- */
+
+ int numDefined = 0;
+ size_t namesDataSize = 0;
+ for (int i = 0; i < db.Files.Size(); i++)
+ {
+ const UString &name = db.Files[i].Name;
+ if (!name.IsEmpty())
+ numDefined++;
+ namesDataSize += (name.Length() + 1) * 2;
+ }
+
+ if (numDefined > 0)
+ {
+ namesDataSize++;
+ SkipAlign(2 + GetBigNumberSize(namesDataSize), 2);
+
+ WriteByte(NID::kName);
+ WriteNumber(namesDataSize);
+ WriteByte(0);
+ for (int i = 0; i < db.Files.Size(); i++)
+ {
+ const UString &name = db.Files[i].Name;
+ for (int t = 0; t <= name.Length(); t++)
+ {
+ wchar_t c = name[t];
+ WriteByte((Byte)c);
+ WriteByte((Byte)(c >> 8));
+ }
+ }
+ }
+ }
+
+ if (headerOptions.WriteCTime) WriteUInt64DefVector(db.CTime, NID::kCTime);
+ if (headerOptions.WriteATime) WriteUInt64DefVector(db.ATime, NID::kATime);
+ if (headerOptions.WriteMTime) WriteUInt64DefVector(db.MTime, NID::kMTime);
+ WriteUInt64DefVector(db.StartPos, NID::kStartPos);
+
+ {
+ /* ---------- Write Attrib ---------- */
+ CBoolVector boolVector;
+ boolVector.Reserve(db.Files.Size());
+ int numDefined = 0;
+ for (i = 0; i < db.Files.Size(); i++)
+ {
+ bool defined = db.Files[i].AttribDefined;
+ boolVector.Add(defined);
+ if (defined)
+ numDefined++;
+ }
+ if (numDefined > 0)
+ {
+ WriteAlignedBoolHeader(boolVector, numDefined, NID::kWinAttributes, 4);
+ for (i = 0; i < db.Files.Size(); i++)
+ {
+ const CFileItem &file = db.Files[i];
+ if (file.AttribDefined)
+ WriteUInt32(file.Attrib);
+ }
+ }
+ }
+
+ WriteByte(NID::kEnd); // for files
+ WriteByte(NID::kEnd); // for headers
+}
+
+HRESULT COutArchive::WriteDatabase(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ const CArchiveDatabase &db,
+ const CCompressionMethodMode *options,
+ const CHeaderOptions &headerOptions)
+{
+ if (!db.CheckNumFiles())
+ return E_FAIL;
+
+ UInt64 headerOffset;
+ UInt32 headerCRC;
+ UInt64 headerSize;
+ if (db.IsEmpty())
+ {
+ headerSize = 0;
+ headerOffset = 0;
+ headerCRC = CrcCalc(0, 0);
+ }
+ else
+ {
+ bool encodeHeaders = false;
+ if (options != 0)
+ if (options->IsEmpty())
+ options = 0;
+ if (options != 0)
+ if (options->PasswordIsDefined || headerOptions.CompressMainHeader)
+ encodeHeaders = true;
+
+ _outByte.SetStream(SeqStream);
+ _outByte.Init();
+ _crc = CRC_INIT_VAL;
+ _countMode = encodeHeaders;
+ _writeToStream = true;
+ _countSize = 0;
+ WriteHeader(db, headerOptions, headerOffset);
+
+ if (encodeHeaders)
+ {
+ CByteBuffer buf;
+ buf.SetCapacity(_countSize);
+ _outByte2.Init((Byte *)buf, _countSize);
+
+ _countMode = false;
+ _writeToStream = false;
+ WriteHeader(db, headerOptions, headerOffset);
+
+ if (_countSize != _outByte2.GetPos())
+ return E_FAIL;
+
+ CCompressionMethodMode encryptOptions;
+ encryptOptions.PasswordIsDefined = options->PasswordIsDefined;
+ encryptOptions.Password = options->Password;
+ CEncoder encoder(headerOptions.CompressMainHeader ? *options : encryptOptions);
+ CRecordVector<UInt64> packSizes;
+ CObjectVector<CFolder> folders;
+ RINOK(EncodeStream(
+ EXTERNAL_CODECS_LOC_VARS
+ encoder, (const Byte *)buf,
+ _countSize, packSizes, folders));
+
+ _writeToStream = true;
+
+ if (folders.Size() == 0)
+ throw 1;
+
+ WriteID(NID::kEncodedHeader);
+ WritePackInfo(headerOffset, packSizes,
+ CRecordVector<bool>(), CRecordVector<UInt32>());
+ WriteUnpackInfo(folders);
+ WriteByte(NID::kEnd);
+ for (int i = 0; i < packSizes.Size(); i++)
+ headerOffset += packSizes[i];
+ }
+ RINOK(_outByte.Flush());
+ headerCRC = CRC_GET_DIGEST(_crc);
+ headerSize = _outByte.GetProcessedSize();
+ }
+ #ifdef _7Z_VOL
+ if (_endMarker)
+ {
+ CFinishHeader h;
+ h.NextHeaderSize = headerSize;
+ h.NextHeaderCRC = headerCRC;
+ h.NextHeaderOffset =
+ UInt64(0) - (headerSize +
+ 4 + kFinishHeaderSize);
+ h.ArchiveStartOffset = h.NextHeaderOffset - headerOffset;
+ h.AdditionalStartBlockSize = 0;
+ RINOK(WriteFinishHeader(h));
+ return WriteFinishSignature();
+ }
+ else
+ #endif
+ {
+ CStartHeader h;
+ h.NextHeaderSize = headerSize;
+ h.NextHeaderCRC = headerCRC;
+ h.NextHeaderOffset = headerOffset;
+ RINOK(Stream->Seek(_prefixHeaderPos, STREAM_SEEK_SET, NULL));
+ return WriteStartHeader(h);
+ }
+}
+
+void CArchiveDatabase::GetFile(int index, CFileItem &file, CFileItem2 &file2) const
+{
+ file = Files[index];
+ file2.CTimeDefined = CTime.GetItem(index, file2.CTime);
+ file2.ATimeDefined = ATime.GetItem(index, file2.ATime);
+ file2.MTimeDefined = MTime.GetItem(index, file2.MTime);
+ file2.StartPosDefined = StartPos.GetItem(index, file2.StartPos);
+ file2.IsAnti = IsItemAnti(index);
+}
+
+void CArchiveDatabase::AddFile(const CFileItem &file, const CFileItem2 &file2)
+{
+ int index = Files.Size();
+ CTime.SetItem(index, file2.CTimeDefined, file2.CTime);
+ ATime.SetItem(index, file2.ATimeDefined, file2.ATime);
+ MTime.SetItem(index, file2.MTimeDefined, file2.MTime);
+ StartPos.SetItem(index, file2.StartPosDefined, file2.StartPos);
+ SetItemAnti(index, file2.IsAnti);
+ Files.Add(file);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zOut.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zOut.h
new file mode 100644
index 000000000..9d8ef3083
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zOut.h
@@ -0,0 +1,156 @@
+// 7zOut.h
+
+#ifndef __7Z_OUT_H
+#define __7Z_OUT_H
+
+#include "7zCompressionMode.h"
+#include "7zEncode.h"
+#include "7zHeader.h"
+#include "7zItem.h"
+
+#include "../../Common/OutBuffer.h"
+
+namespace NArchive {
+namespace N7z {
+
+class CWriteBufferLoc
+{
+ Byte *_data;
+ size_t _size;
+ size_t _pos;
+public:
+ CWriteBufferLoc(): _size(0), _pos(0) {}
+ void Init(Byte *data, size_t size)
+ {
+ _data = data;
+ _size = size;
+ _pos = 0;
+ }
+ void WriteBytes(const void *data, size_t size)
+ {
+ if (size > _size - _pos)
+ throw 1;
+ memcpy(_data + _pos, data, size);
+ _pos += size;
+ }
+ void WriteByte(Byte b)
+ {
+ if (_size == _pos)
+ throw 1;
+ _data[_pos++] = b;
+ }
+ size_t GetPos() const { return _pos; }
+};
+
+struct CHeaderOptions
+{
+ bool CompressMainHeader;
+ bool WriteCTime;
+ bool WriteATime;
+ bool WriteMTime;
+
+ CHeaderOptions():
+ CompressMainHeader(true),
+ WriteCTime(false),
+ WriteATime(false),
+ WriteMTime(true)
+ {}
+};
+
+class COutArchive
+{
+ UInt64 _prefixHeaderPos;
+
+ HRESULT WriteDirect(const void *data, UInt32 size);
+
+ UInt64 GetPos() const;
+ void WriteBytes(const void *data, size_t size);
+ void WriteBytes(const CByteBuffer &data) { WriteBytes(data, data.GetCapacity()); }
+ void WriteByte(Byte b);
+ void WriteUInt32(UInt32 value);
+ void WriteUInt64(UInt64 value);
+ void WriteNumber(UInt64 value);
+ void WriteID(UInt64 value) { WriteNumber(value); }
+
+ void WriteFolder(const CFolder &folder);
+ HRESULT WriteFileHeader(const CFileItem &itemInfo);
+ void WriteBoolVector(const CBoolVector &boolVector);
+ void WriteHashDigests(
+ const CRecordVector<bool> &digestsDefined,
+ const CRecordVector<UInt32> &hashDigests);
+
+ void WritePackInfo(
+ UInt64 dataOffset,
+ const CRecordVector<UInt64> &packSizes,
+ const CRecordVector<bool> &packCRCsDefined,
+ const CRecordVector<UInt32> &packCRCs);
+
+ void WriteUnpackInfo(const CObjectVector<CFolder> &folders);
+
+ void WriteSubStreamsInfo(
+ const CObjectVector<CFolder> &folders,
+ const CRecordVector<CNum> &numUnpackStreamsInFolders,
+ const CRecordVector<UInt64> &unpackSizes,
+ const CRecordVector<bool> &digestsDefined,
+ const CRecordVector<UInt32> &hashDigests);
+
+ void SkipAlign(unsigned pos, unsigned alignSize);
+ void WriteAlignedBoolHeader(const CBoolVector &v, int numDefined, Byte type, unsigned itemSize);
+ void WriteUInt64DefVector(const CUInt64DefVector &v, Byte type);
+
+ HRESULT EncodeStream(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CEncoder &encoder, const Byte *data, size_t dataSize,
+ CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders);
+ HRESULT EncodeStream(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CEncoder &encoder, const CByteBuffer &data,
+ CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders);
+ void WriteHeader(
+ const CArchiveDatabase &db,
+ const CHeaderOptions &headerOptions,
+ UInt64 &headerOffset);
+
+ bool _countMode;
+ bool _writeToStream;
+ size_t _countSize;
+ UInt32 _crc;
+ COutBuffer _outByte;
+ CWriteBufferLoc _outByte2;
+
+ #ifdef _7Z_VOL
+ bool _endMarker;
+ #endif
+
+ HRESULT WriteSignature();
+ #ifdef _7Z_VOL
+ HRESULT WriteFinishSignature();
+ #endif
+ HRESULT WriteStartHeader(const CStartHeader &h);
+ #ifdef _7Z_VOL
+ HRESULT WriteFinishHeader(const CFinishHeader &h);
+ #endif
+ CMyComPtr<IOutStream> Stream;
+public:
+
+ COutArchive() { _outByte.Create(1 << 16); }
+ CMyComPtr<ISequentialOutStream> SeqStream;
+ HRESULT Create(ISequentialOutStream *stream, bool endMarker);
+ void Close();
+ HRESULT SkipPrefixArchiveHeader();
+ HRESULT WriteDatabase(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ const CArchiveDatabase &db,
+ const CCompressionMethodMode *options,
+ const CHeaderOptions &headerOptions);
+
+ #ifdef _7Z_VOL
+ static UInt32 GetVolHeadersSize(UInt64 dataSize, int nameLength = 0, bool props = false);
+ static UInt64 GetVolPureSize(UInt64 volSize, int nameLength = 0, bool props = false);
+ #endif
+
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zProperties.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zProperties.cpp
new file mode 100644
index 000000000..66d90785a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zProperties.cpp
@@ -0,0 +1,163 @@
+// 7zProperties.cpp
+
+#include "StdAfx.h"
+
+#include "7zProperties.h"
+#include "7zHeader.h"
+#include "7zHandler.h"
+
+// #define _MULTI_PACK
+
+namespace NArchive {
+namespace N7z {
+
+struct CPropMap
+{
+ UInt64 FilePropID;
+ STATPROPSTG StatPROPSTG;
+};
+
+CPropMap kPropMap[] =
+{
+ { NID::kName, NULL, kpidPath, VT_BSTR},
+ { NID::kSize, NULL, kpidSize, VT_UI8},
+ { NID::kPackInfo, NULL, kpidPackSize, VT_UI8},
+
+ #ifdef _MULTI_PACK
+ { 100, L"Pack0", kpidPackedSize0, VT_UI8},
+ { 101, L"Pack1", kpidPackedSize1, VT_UI8},
+ { 102, L"Pack2", kpidPackedSize2, VT_UI8},
+ { 103, L"Pack3", kpidPackedSize3, VT_UI8},
+ { 104, L"Pack4", kpidPackedSize4, VT_UI8},
+ #endif
+
+ { NID::kCTime, NULL, kpidCTime, VT_FILETIME},
+ { NID::kMTime, NULL, kpidMTime, VT_FILETIME},
+ { NID::kATime, NULL, kpidATime, VT_FILETIME},
+ { NID::kWinAttributes, NULL, kpidAttrib, VT_UI4},
+ { NID::kStartPos, NULL, kpidPosition, VT_UI4},
+
+ { NID::kCRC, NULL, kpidCRC, VT_UI4},
+
+ { NID::kAnti, NULL, kpidIsAnti, VT_BOOL},
+
+ #ifndef _SFX
+ { 97, NULL, kpidEncrypted, VT_BOOL},
+ { 98, NULL, kpidMethod, VT_BSTR},
+ { 99, NULL, kpidBlock, VT_UI4}
+ #endif
+};
+
+static const int kPropMapSize = sizeof(kPropMap) / sizeof(kPropMap[0]);
+
+static int FindPropInMap(UInt64 filePropID)
+{
+ for (int i = 0; i < kPropMapSize; i++)
+ if (kPropMap[i].FilePropID == filePropID)
+ return i;
+ return -1;
+}
+
+static void CopyOneItem(CRecordVector<UInt64> &src,
+ CRecordVector<UInt64> &dest, UInt32 item)
+{
+ for (int i = 0; i < src.Size(); i++)
+ if (src[i] == item)
+ {
+ dest.Add(item);
+ src.Delete(i);
+ return;
+ }
+}
+
+static void RemoveOneItem(CRecordVector<UInt64> &src, UInt32 item)
+{
+ for (int i = 0; i < src.Size(); i++)
+ if (src[i] == item)
+ {
+ src.Delete(i);
+ return;
+ }
+}
+
+static void InsertToHead(CRecordVector<UInt64> &dest, UInt32 item)
+{
+ for (int i = 0; i < dest.Size(); i++)
+ if (dest[i] == item)
+ {
+ dest.Delete(i);
+ break;
+ }
+ dest.Insert(0, item);
+}
+
+void CHandler::FillPopIDs()
+{
+ _fileInfoPopIDs.Clear();
+
+ #ifdef _7Z_VOL
+ if(_volumes.Size() < 1)
+ return;
+ const CVolume &volume = _volumes.Front();
+ const CArchiveDatabaseEx &_db = volume.Database;
+ #endif
+
+ CRecordVector<UInt64> fileInfoPopIDs = _db.ArchiveInfo.FileInfoPopIDs;
+
+ RemoveOneItem(fileInfoPopIDs, NID::kEmptyStream);
+ RemoveOneItem(fileInfoPopIDs, NID::kEmptyFile);
+
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kName);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kAnti);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kSize);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kPackInfo);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kCTime);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kMTime);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kATime);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kWinAttributes);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kCRC);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kComment);
+ _fileInfoPopIDs += fileInfoPopIDs;
+
+ #ifndef _SFX
+ _fileInfoPopIDs.Add(97);
+ _fileInfoPopIDs.Add(98);
+ _fileInfoPopIDs.Add(99);
+ #endif
+ #ifdef _MULTI_PACK
+ _fileInfoPopIDs.Add(100);
+ _fileInfoPopIDs.Add(101);
+ _fileInfoPopIDs.Add(102);
+ _fileInfoPopIDs.Add(103);
+ _fileInfoPopIDs.Add(104);
+ #endif
+
+ #ifndef _SFX
+ InsertToHead(_fileInfoPopIDs, NID::kMTime);
+ InsertToHead(_fileInfoPopIDs, NID::kPackInfo);
+ InsertToHead(_fileInfoPopIDs, NID::kSize);
+ InsertToHead(_fileInfoPopIDs, NID::kName);
+ #endif
+}
+
+STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
+{
+ *numProperties = _fileInfoPopIDs.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ if ((int)index >= _fileInfoPopIDs.Size())
+ return E_INVALIDARG;
+ int indexInMap = FindPropInMap(_fileInfoPopIDs[index]);
+ if (indexInMap == -1)
+ return E_INVALIDARG;
+ const STATPROPSTG &srcItem = kPropMap[indexInMap].StatPROPSTG;
+ *propID = srcItem.propid;
+ *varType = srcItem.vt;
+ *name = 0;
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zProperties.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zProperties.h
new file mode 100644
index 000000000..661817954
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zProperties.h
@@ -0,0 +1,22 @@
+// 7zProperties.h
+
+#ifndef __7Z_PROPERTIES_H
+#define __7Z_PROPERTIES_H
+
+#include "../../PropID.h"
+
+namespace NArchive {
+namespace N7z {
+
+enum
+{
+ kpidPackedSize0 = kpidUserDefined,
+ kpidPackedSize1,
+ kpidPackedSize2,
+ kpidPackedSize3,
+ kpidPackedSize4
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zRegister.cpp
new file mode 100644
index 000000000..5da289081
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zRegister.cpp
@@ -0,0 +1,18 @@
+// 7zRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "7zHandler.h"
+static IInArchive *CreateArc() { return new NArchive::N7z::CHandler; }
+#ifndef EXTRACT_ONLY
+static IOutArchive *CreateArcOut() { return new NArchive::N7z::CHandler; }
+#else
+#define CreateArcOut 0
+#endif
+
+static CArcInfo g_ArcInfo =
+ { L"7z", L"7z", 0, 7, {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}, 6, false, CreateArc, CreateArcOut };
+
+REGISTER_ARC(7z)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zSpecStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zSpecStream.cpp
new file mode 100644
index 000000000..06969636d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zSpecStream.cpp
@@ -0,0 +1,24 @@
+// 7zSpecStream.cpp
+
+#include "StdAfx.h"
+
+#include "7zSpecStream.h"
+
+STDMETHODIMP CSequentialInStreamSizeCount2::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize;
+ HRESULT result = _stream->Read(data, size, &realProcessedSize);
+ _size += realProcessedSize;
+ if (processedSize != 0)
+ *processedSize = realProcessedSize;
+ return result;
+}
+
+STDMETHODIMP CSequentialInStreamSizeCount2::GetSubStreamSize(
+ UInt64 subStream, UInt64 *value)
+{
+ if (_getSubStreamSize == NULL)
+ return E_NOTIMPL;
+ return _getSubStreamSize->GetSubStreamSize(subStream, value);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zSpecStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zSpecStream.h
new file mode 100644
index 000000000..2e26efd5c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zSpecStream.h
@@ -0,0 +1,35 @@
+// 7zSpecStream.h
+
+#ifndef __7Z_SPEC_STREAM_H
+#define __7Z_SPEC_STREAM_H
+
+#include "../../IStream.h"
+#include "../../ICoder.h"
+#include "../../../Common/MyCom.h"
+
+class CSequentialInStreamSizeCount2:
+ public ISequentialInStream,
+ public ICompressGetSubStreamSize,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialInStream> _stream;
+ CMyComPtr<ICompressGetSubStreamSize> _getSubStreamSize;
+ UInt64 _size;
+public:
+ void Init(ISequentialInStream *stream)
+ {
+ _stream = stream;
+ _getSubStreamSize = 0;
+ _stream.QueryInterface(IID_ICompressGetSubStreamSize, &_getSubStreamSize);
+ _size = 0;
+ }
+ UInt64 GetSize() const { return _size; }
+
+ MY_UNKNOWN_IMP1(ICompressGetSubStreamSize)
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+
+ STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zUpdate.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zUpdate.cpp
new file mode 100644
index 000000000..141654d8e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zUpdate.cpp
@@ -0,0 +1,1208 @@
+// 7zUpdate.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Common/CreateCoder.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../Common/ItemNameUtils.h"
+#include "../Common/OutStreamWithCRC.h"
+
+#include "7zDecode.h"
+#include "7zEncode.h"
+#include "7zFolderInStream.h"
+#include "7zHandler.h"
+#include "7zOut.h"
+#include "7zUpdate.h"
+
+#ifndef WIN32
+#include "Windows/FileIO.h"
+#endif
+
+namespace NArchive {
+namespace N7z {
+
+static const UInt64 k_LZMA = 0x030101;
+static const UInt64 k_BCJ = 0x03030103;
+static const UInt64 k_BCJ2 = 0x0303011B;
+static const UInt64 k_AES = 0x06F10701;
+
+static const wchar_t *kMatchFinderForBCJ2_LZMA = L"BT2";
+static const UInt32 kDictionaryForBCJ2_LZMA = 1 << 20;
+static const UInt32 kAlgorithmForBCJ2_LZMA = 1;
+static const UInt32 kNumFastBytesForBCJ2_LZMA = 64;
+
+static HRESULT WriteRange(IInStream *inStream, ISequentialOutStream *outStream,
+ UInt64 position, UInt64 size, ICompressProgressInfo *progress)
+{
+ RINOK(inStream->Seek(position, STREAM_SEEK_SET, 0));
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
+ streamSpec->SetStream(inStream);
+ streamSpec->Init(size);
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+ RINOK(copyCoder->Code(inStreamLimited, outStream, NULL, NULL, progress));
+ return (copyCoderSpec->TotalSize == size ? S_OK : E_FAIL);
+}
+
+static int GetReverseSlashPos(const UString &name)
+{
+ int slashPos = name.ReverseFind(L'/');
+ #ifdef _WIN32
+ int slash1Pos = name.ReverseFind(L'\\');
+ slashPos = MyMax(slashPos, slash1Pos);
+ #endif
+ return slashPos;
+}
+
+int CUpdateItem::GetExtensionPos() const
+{
+ int slashPos = GetReverseSlashPos(Name);
+ int dotPos = Name.ReverseFind(L'.');
+ if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
+ return Name.Length();
+ return dotPos + 1;
+}
+
+UString CUpdateItem::GetExtension() const
+{
+ return Name.Mid(GetExtensionPos());
+}
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+#define RINOZ_COMP(a, b) RINOZ(MyCompare(a, b))
+
+static int CompareBuffers(const CByteBuffer &a1, const CByteBuffer &a2)
+{
+ size_t c1 = a1.GetCapacity();
+ size_t c2 = a2.GetCapacity();
+ RINOZ_COMP(c1, c2);
+ for (size_t i = 0; i < c1; i++)
+ RINOZ_COMP(a1[i], a2[i]);
+ return 0;
+}
+
+static int CompareCoders(const CCoderInfo &c1, const CCoderInfo &c2)
+{
+ RINOZ_COMP(c1.NumInStreams, c2.NumInStreams);
+ RINOZ_COMP(c1.NumOutStreams, c2.NumOutStreams);
+ RINOZ_COMP(c1.MethodID, c2.MethodID);
+ return CompareBuffers(c1.Props, c2.Props);
+}
+
+static int CompareBindPairs(const CBindPair &b1, const CBindPair &b2)
+{
+ RINOZ_COMP(b1.InIndex, b2.InIndex);
+ return MyCompare(b1.OutIndex, b2.OutIndex);
+}
+
+static int CompareFolders(const CFolder &f1, const CFolder &f2)
+{
+ int s1 = f1.Coders.Size();
+ int s2 = f2.Coders.Size();
+ RINOZ_COMP(s1, s2);
+ int i;
+ for (i = 0; i < s1; i++)
+ RINOZ(CompareCoders(f1.Coders[i], f2.Coders[i]));
+ s1 = f1.BindPairs.Size();
+ s2 = f2.BindPairs.Size();
+ RINOZ_COMP(s1, s2);
+ for (i = 0; i < s1; i++)
+ RINOZ(CompareBindPairs(f1.BindPairs[i], f2.BindPairs[i]));
+ return 0;
+}
+
+/*
+static int CompareFiles(const CFileItem &f1, const CFileItem &f2)
+{
+ return MyStringCompareNoCase(f1.Name, f2.Name);
+}
+*/
+
+struct CFolderRepack
+{
+ int FolderIndex;
+ int Group;
+ CNum NumCopyFiles;
+};
+
+static int CompareFolderRepacks(const CFolderRepack *p1, const CFolderRepack *p2, void *param)
+{
+ RINOZ_COMP(p1->Group, p2->Group);
+ int i1 = p1->FolderIndex;
+ int i2 = p2->FolderIndex;
+ const CArchiveDatabaseEx &db = *(const CArchiveDatabaseEx *)param;
+ RINOZ(CompareFolders(
+ db.Folders[i1],
+ db.Folders[i2]));
+ return MyCompare(i1, i2);
+ /*
+ RINOZ_COMP(
+ db.NumUnpackStreamsVector[i1],
+ db.NumUnpackStreamsVector[i2]);
+ if (db.NumUnpackStreamsVector[i1] == 0)
+ return 0;
+ return CompareFiles(
+ db.Files[db.FolderStartFileIndex[i1]],
+ db.Files[db.FolderStartFileIndex[i2]]);
+ */
+}
+
+////////////////////////////////////////////////////////////
+
+static int CompareEmptyItems(const int *p1, const int *p2, void *param)
+{
+ const CObjectVector<CUpdateItem> &updateItems = *(const CObjectVector<CUpdateItem> *)param;
+ const CUpdateItem &u1 = updateItems[*p1];
+ const CUpdateItem &u2 = updateItems[*p2];
+ if (u1.IsDir != u2.IsDir)
+ return (u1.IsDir) ? 1 : -1;
+ if (u1.IsDir)
+ {
+ if (u1.IsAnti != u2.IsAnti)
+ return (u1.IsAnti ? 1 : -1);
+ int n = MyStringCompareNoCase(u1.Name, u2.Name);
+ return -n;
+ }
+ if (u1.IsAnti != u2.IsAnti)
+ return (u1.IsAnti ? 1 : -1);
+ return MyStringCompareNoCase(u1.Name, u2.Name);
+}
+
+static const char *g_Exts =
+ " lzma 7z ace arc arj bz bz2 deb lzo lzx gz pak rpm sit tgz tbz tbz2 tgz cab ha lha lzh rar zoo"
+ " zip jar ear war msi"
+ " 3gp avi mov mpeg mpg mpe wmv"
+ " aac ape fla flac la mp3 m4a mp4 ofr ogg pac ra rm rka shn swa tta wv wma wav"
+ " swf "
+ " chm hxi hxs"
+ " gif jpeg jpg jp2 png tiff bmp ico psd psp"
+ " awg ps eps cgm dxf svg vrml wmf emf ai md"
+ " cad dwg pps key sxi"
+ " max 3ds"
+ " iso bin nrg mdf img pdi tar cpio xpi"
+ " vfd vhd vud vmc vsv"
+ " vmdk dsk nvram vmem vmsd vmsn vmss vmtm"
+ " inl inc idl acf asa h hpp hxx c cpp cxx rc java cs pas bas vb cls ctl frm dlg def"
+ " f77 f f90 f95"
+ " asm sql manifest dep "
+ " mak clw csproj vcproj sln dsp dsw "
+ " class "
+ " bat cmd"
+ " xml xsd xsl xslt hxk hxc htm html xhtml xht mht mhtml htw asp aspx css cgi jsp shtml"
+ " awk sed hta js php php3 php4 php5 phptml pl pm py pyo rb sh tcl vbs"
+ " text txt tex ans asc srt reg ini doc docx mcw dot rtf hlp xls xlr xlt xlw ppt pdf"
+ " sxc sxd sxi sxg sxw stc sti stw stm odt ott odg otg odp otp ods ots odf"
+ " abw afp cwk lwp wpd wps wpt wrf wri"
+ " abf afm bdf fon mgf otf pcf pfa snf ttf"
+ " dbf mdb nsf ntf wdb db fdb gdb"
+ " exe dll ocx vbx sfx sys tlb awx com obj lib out o so "
+ " pdb pch idb ncb opt";
+
+int GetExtIndex(const char *ext)
+{
+ int extIndex = 1;
+ const char *p = g_Exts;
+ for (;;)
+ {
+ char c = *p++;
+ if (c == 0)
+ return extIndex;
+ if (c == ' ')
+ continue;
+ int pos = 0;
+ for (;;)
+ {
+ char c2 = ext[pos++];
+ if (c2 == 0 && (c == 0 || c == ' '))
+ return extIndex;
+ if (c != c2)
+ break;
+ c = *p++;
+ }
+ extIndex++;
+ for (;;)
+ {
+ if (c == 0)
+ return extIndex;
+ if (c == ' ')
+ break;
+ c = *p++;
+ }
+ }
+}
+
+struct CRefItem
+{
+ const CUpdateItem *UpdateItem;
+ UInt32 Index;
+ UInt32 ExtensionPos;
+ UInt32 NamePos;
+ int ExtensionIndex;
+ CRefItem(UInt32 index, const CUpdateItem &ui, bool sortByType):
+ UpdateItem(&ui),
+ Index(index),
+ ExtensionPos(0),
+ NamePos(0),
+ ExtensionIndex(0)
+ {
+ if (sortByType)
+ {
+ int slashPos = GetReverseSlashPos(ui.Name);
+ NamePos = ((slashPos >= 0) ? (slashPos + 1) : 0);
+ int dotPos = ui.Name.ReverseFind(L'.');
+ if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
+ ExtensionPos = ui.Name.Length();
+ else
+ {
+ ExtensionPos = dotPos + 1;
+ UString us = ui.Name.Mid(ExtensionPos);
+ if (!us.IsEmpty())
+ {
+ us.MakeLower();
+ int i;
+ AString s;
+ for (i = 0; i < us.Length(); i++)
+ {
+ wchar_t c = us[i];
+ if (c >= 0x80)
+ break;
+ s += (char)c;
+ }
+ if (i == us.Length())
+ ExtensionIndex = GetExtIndex(s);
+ else
+ ExtensionIndex = 0;
+ }
+ }
+ }
+ }
+};
+
+static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *param)
+{
+ const CRefItem &a1 = *p1;
+ const CRefItem &a2 = *p2;
+ const CUpdateItem &u1 = *a1.UpdateItem;
+ const CUpdateItem &u2 = *a2.UpdateItem;
+ int n;
+ if (u1.IsDir != u2.IsDir)
+ return (u1.IsDir) ? 1 : -1;
+ if (u1.IsDir)
+ {
+ if (u1.IsAnti != u2.IsAnti)
+ return (u1.IsAnti ? 1 : -1);
+ n = MyStringCompareNoCase(u1.Name, u2.Name);
+ return -n;
+ }
+ bool sortByType = *(bool *)param;
+ if (sortByType)
+ {
+ RINOZ_COMP(a1.ExtensionIndex, a2.ExtensionIndex);
+ RINOZ(MyStringCompareNoCase(u1.Name + a1.ExtensionPos, u2.Name + a2.ExtensionPos));
+ RINOZ(MyStringCompareNoCase(u1.Name + a1.NamePos, u2.Name + a2.NamePos));
+ if (!u1.MTimeDefined && u2.MTimeDefined) return 1;
+ if (u1.MTimeDefined && !u2.MTimeDefined) return -1;
+ if (u1.MTimeDefined && u2.MTimeDefined) RINOZ_COMP(u1.MTime, u2.MTime);
+ RINOZ_COMP(u1.Size, u2.Size);
+ }
+ return MyStringCompareNoCase(u1.Name, u2.Name);
+}
+
+struct CSolidGroup
+{
+ CRecordVector<UInt32> Indices;
+};
+
+#ifdef _WIN32
+static wchar_t *g_ExeExts[] =
+{
+ L"dll",
+ L"exe",
+ L"ocx",
+ L"sfx",
+ L"sys"
+};
+
+static bool IsExeExt(const UString &ext)
+{
+ for (int i = 0; i < sizeof(g_ExeExts) / sizeof(g_ExeExts[0]); i++)
+ if (ext.CompareNoCase(g_ExeExts[i]) == 0)
+ return true;
+ return false;
+}
+#else
+static bool IsExeFile(const CUpdateItem &ui)
+{
+ if (ui.Attrib & FILE_ATTRIBUTE_UNIX_EXTENSION) {
+ unsigned short st_mode = ui.Attrib >> 16;
+ if ((st_mode & 00111) && (ui.Size >= 2048))
+ {
+ // file has the execution flag and it's big enought
+ // try to find if the file is a script
+ NWindows::NFile::NIO::CInFile file;
+ if (file.Open(ui.Name))
+ {
+ char buffer[512];
+ UINT32 processedSize;
+ if (file.Read(buffer,sizeof(buffer),processedSize))
+ {
+ for(UInt32 i = 0; i < processedSize ; i++)
+ {
+ if (buffer[i] == 0)
+ {
+ return true; // this file is not a text (ascii, utf8, ...) !
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+#endif
+
+static void GetMethodFull(UInt64 methodID, UInt32 numInStreams, CMethodFull &methodResult)
+{
+ methodResult.Id = methodID;
+ methodResult.NumInStreams = numInStreams;
+ methodResult.NumOutStreams = 1;
+}
+
+static void MakeExeMethod(const CCompressionMethodMode &method,
+ bool bcj2Filter, CCompressionMethodMode &exeMethod)
+{
+ exeMethod = method;
+ if (bcj2Filter)
+ {
+ CMethodFull methodFull;
+ GetMethodFull(k_BCJ2, 4, methodFull);
+ exeMethod.Methods.Insert(0, methodFull);
+ GetMethodFull(k_LZMA, 1, methodFull);
+ {
+ CProp prop;
+ prop.Id = NCoderPropID::kAlgorithm;
+ prop.Value = kAlgorithmForBCJ2_LZMA;
+ methodFull.Props.Add(prop);
+ }
+ {
+ CProp prop;
+ prop.Id = NCoderPropID::kMatchFinder;
+ prop.Value = kMatchFinderForBCJ2_LZMA;
+ methodFull.Props.Add(prop);
+ }
+ {
+ CProp prop;
+ prop.Id = NCoderPropID::kDictionarySize;
+ prop.Value = kDictionaryForBCJ2_LZMA;
+ methodFull.Props.Add(prop);
+ }
+ {
+ CProp prop;
+ prop.Id = NCoderPropID::kNumFastBytes;
+ prop.Value = kNumFastBytesForBCJ2_LZMA;
+ methodFull.Props.Add(prop);
+ }
+
+ exeMethod.Methods.Add(methodFull);
+ exeMethod.Methods.Add(methodFull);
+ CBind bind;
+
+ bind.OutCoder = 0;
+ bind.InStream = 0;
+
+ bind.InCoder = 1;
+ bind.OutStream = 0;
+ exeMethod.Binds.Add(bind);
+
+ bind.InCoder = 2;
+ bind.OutStream = 1;
+ exeMethod.Binds.Add(bind);
+
+ bind.InCoder = 3;
+ bind.OutStream = 2;
+ exeMethod.Binds.Add(bind);
+ }
+ else
+ {
+ CMethodFull methodFull;
+ GetMethodFull(k_BCJ, 1, methodFull);
+ exeMethod.Methods.Insert(0, methodFull);
+ CBind bind;
+ bind.OutCoder = 0;
+ bind.InStream = 0;
+ bind.InCoder = 1;
+ bind.OutStream = 0;
+ exeMethod.Binds.Add(bind);
+ }
+}
+
+static void FromUpdateItemToFileItem(const CUpdateItem &ui,
+ CFileItem &file, CFileItem2 &file2)
+{
+ file.Name = NItemName::MakeLegalName(ui.Name);
+ if (ui.AttribDefined)
+ file.SetAttrib(ui.Attrib);
+
+ file2.CTime = ui.CTime; file2.CTimeDefined = ui.CTimeDefined;
+ file2.ATime = ui.ATime; file2.ATimeDefined = ui.ATimeDefined;
+ file2.MTime = ui.MTime; file2.MTimeDefined = ui.MTimeDefined;
+ file2.IsAnti = ui.IsAnti;
+ file2.StartPosDefined = false;
+
+ file.Size = ui.Size;
+ file.IsDir = ui.IsDir;
+ file.HasStream = ui.HasStream();
+}
+
+class CFolderOutStream2:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ COutStreamWithCRC *_crcStreamSpec;
+ CMyComPtr<ISequentialOutStream> _crcStream;
+ const CArchiveDatabaseEx *_db;
+ const CBoolVector *_extractStatuses;
+ CMyComPtr<ISequentialOutStream> _outStream;
+ UInt32 _startIndex;
+ int _currentIndex;
+ bool _fileIsOpen;
+ UInt64 _rem;
+
+ void OpenFile();
+ void CloseFile();
+ HRESULT CloseFileAndSetResult();
+ HRESULT ProcessEmptyFiles();
+public:
+ MY_UNKNOWN_IMP
+
+ CFolderOutStream2()
+ {
+ _crcStreamSpec = new COutStreamWithCRC;
+ _crcStream = _crcStreamSpec;
+ }
+
+ HRESULT Init(const CArchiveDatabaseEx *db, UInt32 startIndex,
+ const CBoolVector *extractStatuses, ISequentialOutStream *outStream);
+ void ReleaseOutStream();
+ HRESULT CheckFinishedState() const { return (_currentIndex == _extractStatuses->Size()) ? S_OK: E_FAIL; }
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+HRESULT CFolderOutStream2::Init(const CArchiveDatabaseEx *db, UInt32 startIndex,
+ const CBoolVector *extractStatuses, ISequentialOutStream *outStream)
+{
+ _db = db;
+ _startIndex = startIndex;
+ _extractStatuses = extractStatuses;
+ _outStream = outStream;
+
+ _currentIndex = 0;
+ _fileIsOpen = false;
+ return ProcessEmptyFiles();
+}
+
+void CFolderOutStream2::ReleaseOutStream()
+{
+ _outStream.Release();
+ _crcStreamSpec->ReleaseStream();
+}
+
+void CFolderOutStream2::OpenFile()
+{
+ _crcStreamSpec->SetStream((*_extractStatuses)[_currentIndex] ? (ISequentialOutStream *)_outStream : NULL); // FIXED for gcc 2.95
+ _crcStreamSpec->Init(true);
+ _fileIsOpen = true;
+ _rem = _db->Files[_startIndex + _currentIndex].Size;
+}
+
+void CFolderOutStream2::CloseFile()
+{
+ _crcStreamSpec->ReleaseStream();
+ _fileIsOpen = false;
+ _currentIndex++;
+}
+
+HRESULT CFolderOutStream2::CloseFileAndSetResult()
+{
+ const CFileItem &file = _db->Files[_startIndex + _currentIndex];
+ CloseFile();
+ return (file.IsDir || !file.CrcDefined || file.Crc == _crcStreamSpec->GetCRC()) ? S_OK: S_FALSE;
+}
+
+HRESULT CFolderOutStream2::ProcessEmptyFiles()
+{
+ while (_currentIndex < _extractStatuses->Size() && _db->Files[_startIndex + _currentIndex].Size == 0)
+ {
+ OpenFile();
+ RINOK(CloseFileAndSetResult());
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFolderOutStream2::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ while (size != 0)
+ {
+ if (_fileIsOpen)
+ {
+ UInt32 cur = size < _rem ? size : (UInt32)_rem;
+ RINOK(_crcStream->Write(data, cur, &cur));
+ if (cur == 0)
+ break;
+ data = (const Byte *)data + cur;
+ size -= cur;
+ _rem -= cur;
+ if (processedSize != NULL)
+ *processedSize += cur;
+ if (_rem == 0)
+ {
+ RINOK(CloseFileAndSetResult());
+ RINOK(ProcessEmptyFiles());
+ continue;
+ }
+ }
+ else
+ {
+ RINOK(ProcessEmptyFiles());
+ if (_currentIndex == _extractStatuses->Size())
+ {
+ // we don't support partial extracting
+ return E_FAIL;
+ }
+ OpenFile();
+ }
+ }
+ return S_OK;
+}
+
+class CThreadDecoder: public CVirtThread
+{
+public:
+ HRESULT Result;
+ CMyComPtr<IInStream> InStream;
+
+ CFolderOutStream2 *FosSpec;
+ CMyComPtr<ISequentialOutStream> Fos;
+
+ UInt64 StartPos;
+ const UInt64 *PackSizes;
+ const CFolder *Folder;
+ #ifndef _NO_CRYPTO
+ CMyComPtr<ICryptoGetTextPassword> GetTextPassword;
+ #endif
+
+ DECL_EXTERNAL_CODECS_VARS
+ CDecoder Decoder;
+
+ #ifdef COMPRESS_MT
+ bool MtMode;
+ UInt32 NumThreads;
+ #endif
+
+ CThreadDecoder():
+ Decoder(true)
+ {
+ #ifdef COMPRESS_MT
+ MtMode = false;
+ NumThreads = 1;
+ #endif
+ FosSpec = new CFolderOutStream2;
+ Fos = FosSpec;
+ Result = E_FAIL;
+ }
+ virtual void Execute();
+};
+
+void CThreadDecoder::Execute()
+{
+ try
+ {
+ #ifndef _NO_CRYPTO
+ bool passwordIsDefined;
+ #endif
+ Result = Decoder.Decode(
+ EXTERNAL_CODECS_VARS
+ InStream,
+ StartPos,
+ PackSizes,
+ *Folder,
+ Fos,
+ NULL
+ #ifndef _NO_CRYPTO
+ , GetTextPassword, passwordIsDefined
+ #endif
+ #ifdef COMPRESS_MT
+ , MtMode, NumThreads
+ #endif
+ );
+ }
+ catch(...)
+ {
+ Result = E_FAIL;
+ }
+ if (Result == S_OK)
+ Result = FosSpec->CheckFinishedState();
+ FosSpec->ReleaseOutStream();
+}
+
+bool static Is86FilteredFolder(const CFolder &f)
+{
+ for (int i = 0; i < f.Coders.Size(); i++)
+ {
+ CMethodId m = f.Coders[i].MethodID;
+ if (m == k_BCJ || m == k_BCJ2)
+ return true;
+ }
+ return false;
+}
+
+bool static IsEncryptedFolder(const CFolder &f)
+{
+ for (int i = 0; i < f.Coders.Size(); i++)
+ {
+ CMethodId m = f.Coders[i].MethodID;
+ if (m == k_AES)
+ return true;
+ }
+ return false;
+}
+
+#ifndef _NO_CRYPTO
+
+class CCryptoGetTextPassword:
+ public ICryptoGetTextPassword,
+ public CMyUnknownImp
+{
+public:
+ UString Password;
+
+ MY_UNKNOWN_IMP
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+};
+
+STDMETHODIMP CCryptoGetTextPassword::CryptoGetTextPassword(BSTR *password)
+{
+ return StringToBstr(Password, password);
+}
+
+#endif
+
+static const int kNumGroupsMax = 4;
+
+static bool Is86Group(int group) { return (group & 1) != 0; }
+static bool IsEncryptedGroup(int group) { return (group & 2) != 0; }
+static int GetGroupIndex(bool encrypted, int bcjFiltered)
+ { return (encrypted ? 2 : 0) + (bcjFiltered ? 1 : 0); }
+
+HRESULT Update(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IInStream *inStream,
+ const CArchiveDatabaseEx *db,
+ const CObjectVector<CUpdateItem> &updateItems,
+ COutArchive &archive,
+ CArchiveDatabase &newDatabase,
+ ISequentialOutStream *seqOutStream,
+ IArchiveUpdateCallback *updateCallback,
+ const CUpdateOptions &options
+ #ifndef _NO_CRYPTO
+ , ICryptoGetTextPassword *getDecoderPassword
+ #endif
+ )
+{
+ UInt64 numSolidFiles = options.NumSolidFiles;
+ if (numSolidFiles == 0)
+ numSolidFiles = 1;
+ /*
+ CMyComPtr<IOutStream> outStream;
+ RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream));
+ if (!outStream)
+ return E_NOTIMPL;
+ */
+
+ UInt64 startBlockSize = db != 0 ? db->ArchiveInfo.StartPosition: 0;
+ if (startBlockSize > 0 && !options.RemoveSfxBlock)
+ {
+ RINOK(WriteRange(inStream, seqOutStream, 0, startBlockSize, NULL));
+ }
+
+ CRecordVector<int> fileIndexToUpdateIndexMap;
+ CRecordVector<CFolderRepack> folderRefs;
+ UInt64 complexity = 0;
+ UInt64 inSizeForReduce2 = 0;
+ bool needEncryptedRepack = false;
+ if (db != 0)
+ {
+ fileIndexToUpdateIndexMap.Reserve(db->Files.Size());
+ int i;
+ for (i = 0; i < db->Files.Size(); i++)
+ fileIndexToUpdateIndexMap.Add(-1);
+
+ for (i = 0; i < updateItems.Size(); i++)
+ {
+ int index = updateItems[i].IndexInArchive;
+ if (index != -1)
+ fileIndexToUpdateIndexMap[index] = i;
+ }
+
+ for (i = 0; i < db->Folders.Size(); i++)
+ {
+ CNum indexInFolder = 0;
+ CNum numCopyItems = 0;
+ CNum numUnpackStreams = db->NumUnpackStreamsVector[i];
+ UInt64 repackSize = 0;
+ for (CNum fi = db->FolderStartFileIndex[i]; indexInFolder < numUnpackStreams; fi++)
+ {
+ const CFileItem &file = db->Files[fi];
+ if (file.HasStream)
+ {
+ indexInFolder++;
+ int updateIndex = fileIndexToUpdateIndexMap[fi];
+ if (updateIndex >= 0 && !updateItems[updateIndex].NewData)
+ {
+ numCopyItems++;
+ repackSize += file.Size;
+ }
+ }
+ }
+
+ if (numCopyItems == 0)
+ continue;
+
+ CFolderRepack rep;
+ rep.FolderIndex = i;
+ rep.NumCopyFiles = numCopyItems;
+ const CFolder &f = db->Folders[i];
+ bool isEncrypted = IsEncryptedFolder(f);
+ rep.Group = GetGroupIndex(isEncrypted, Is86FilteredFolder(f));
+ folderRefs.Add(rep);
+ if (numCopyItems == numUnpackStreams)
+ complexity += db->GetFolderFullPackSize(i);
+ else
+ {
+ complexity += repackSize;
+ if (repackSize > inSizeForReduce2)
+ inSizeForReduce2 = repackSize;
+ if (isEncrypted)
+ needEncryptedRepack = true;
+ }
+ }
+ folderRefs.Sort(CompareFolderRepacks, (void *)db);
+ }
+
+ UInt64 inSizeForReduce = 0;
+ int i;
+ for (i = 0; i < updateItems.Size(); i++)
+ {
+ const CUpdateItem &ui = updateItems[i];
+ if (ui.NewData)
+ {
+ complexity += ui.Size;
+ if (numSolidFiles != 1)
+ inSizeForReduce += ui.Size;
+ else if (ui.Size > inSizeForReduce)
+ inSizeForReduce = ui.Size;
+ }
+ }
+
+ if (inSizeForReduce2 > inSizeForReduce)
+ inSizeForReduce = inSizeForReduce2;
+
+ const UInt32 kMinReduceSize = (1 << 16);
+ if (inSizeForReduce < kMinReduceSize)
+ inSizeForReduce = kMinReduceSize;
+
+ RINOK(updateCallback->SetTotal(complexity));
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(updateCallback, true);
+
+ CThreadDecoder threadDecoder;
+ if (!folderRefs.IsEmpty())
+ {
+ #ifdef EXTERNAL_CODECS
+ threadDecoder._codecsInfo = codecsInfo;
+ threadDecoder._externalCodecs = *externalCodecs;
+ #endif
+ RINOK(threadDecoder.Create());
+ }
+
+ CObjectVector<CSolidGroup> groups;
+ for (i = 0; i < kNumGroupsMax; i++)
+ groups.Add(CSolidGroup());
+
+ {
+ // ---------- Split files to 2 groups ----------
+
+ bool useFilters = options.UseFilters;
+ const CCompressionMethodMode &method = *options.Method;
+ if (method.Methods.Size() != 1 || method.Binds.Size() != 0)
+ useFilters = false;
+ for (i = 0; i < updateItems.Size(); i++)
+ {
+ const CUpdateItem &ui = updateItems[i];
+ if (!ui.NewData || !ui.HasStream())
+ continue;
+ bool filteredGroup = false;
+ if (useFilters)
+ {
+#ifdef _WIN32
+ int dotPos = ui.Name.ReverseFind(L'.');
+ if (dotPos >= 0)
+ filteredGroup = IsExeExt(ui.Name.Mid(dotPos + 1));
+#else
+ filteredGroup = IsExeFile(ui);
+#endif
+ }
+ groups[GetGroupIndex(method.PasswordIsDefined, filteredGroup)].Indices.Add(i);
+ }
+ }
+
+ #ifndef _NO_CRYPTO
+
+ CCryptoGetTextPassword *getPasswordSpec = NULL;
+ if (needEncryptedRepack)
+ {
+ getPasswordSpec = new CCryptoGetTextPassword;
+ threadDecoder.GetTextPassword = getPasswordSpec;
+
+ if (options.Method->PasswordIsDefined)
+ getPasswordSpec->Password = options.Method->Password;
+ else
+ {
+ if (!getDecoderPassword)
+ return E_NOTIMPL;
+ CMyComBSTR password;
+ RINOK(getDecoderPassword->CryptoGetTextPassword(&password));
+ getPasswordSpec->Password = password;
+ }
+ }
+
+ #endif
+
+ // ---------- Compress ----------
+
+ RINOK(archive.Create(seqOutStream, false));
+ RINOK(archive.SkipPrefixArchiveHeader());
+
+ int folderRefIndex = 0;
+ lps->ProgressOffset = 0;
+
+ for (int groupIndex = 0; groupIndex < kNumGroupsMax; groupIndex++)
+ {
+ const CSolidGroup &group = groups[groupIndex];
+
+ CCompressionMethodMode method;
+ if (Is86Group(groupIndex))
+ MakeExeMethod(*options.Method, options.MaxFilter, method);
+ else
+ method = *options.Method;
+
+ if (IsEncryptedGroup(groupIndex))
+ {
+ if (!method.PasswordIsDefined)
+ {
+ #ifndef _NO_CRYPTO
+ if (getPasswordSpec)
+ method.Password = getPasswordSpec->Password;
+ #endif
+ method.PasswordIsDefined = true;
+ }
+ }
+ else
+ {
+ method.PasswordIsDefined = false;
+ method.Password.Empty();
+ }
+
+ CEncoder encoder(method);
+
+ for (; folderRefIndex < folderRefs.Size(); folderRefIndex++)
+ {
+ const CFolderRepack &rep = folderRefs[folderRefIndex];
+ if (rep.Group != groupIndex)
+ break;
+ int folderIndex = rep.FolderIndex;
+
+ if (rep.NumCopyFiles == db->NumUnpackStreamsVector[folderIndex])
+ {
+ UInt64 packSize = db->GetFolderFullPackSize(folderIndex);
+ RINOK(WriteRange(inStream, archive.SeqStream,
+ db->GetFolderStreamPos(folderIndex, 0), packSize, progress));
+ lps->ProgressOffset += packSize;
+
+ const CFolder &folder = db->Folders[folderIndex];
+ CNum startIndex = db->FolderStartPackStreamIndex[folderIndex];
+ for (int j = 0; j < folder.PackStreams.Size(); j++)
+ {
+ newDatabase.PackSizes.Add(db->PackSizes[startIndex + j]);
+ // newDatabase.PackCRCsDefined.Add(db.PackCRCsDefined[startIndex + j]);
+ // newDatabase.PackCRCs.Add(db.PackCRCs[startIndex + j]);
+ }
+ newDatabase.Folders.Add(folder);
+ }
+ else
+ {
+ CStreamBinder sb;
+ RINOK(sb.CreateEvents());
+ CMyComPtr<ISequentialOutStream> sbOutStream;
+ CMyComPtr<ISequentialInStream> sbInStream;
+ sb.CreateStreams(&sbInStream, &sbOutStream);
+ CBoolVector extractStatuses;
+
+ CNum numUnpackStreams = db->NumUnpackStreamsVector[folderIndex];
+ CNum indexInFolder = 0;
+
+ for (CNum fi = db->FolderStartFileIndex[folderIndex]; indexInFolder < numUnpackStreams; fi++)
+ {
+ bool needExtract = false;
+ if (db->Files[fi].HasStream)
+ {
+ indexInFolder++;
+ int updateIndex = fileIndexToUpdateIndexMap[fi];
+ if (updateIndex >= 0 && !updateItems[updateIndex].NewData)
+ needExtract = true;
+ }
+ extractStatuses.Add(needExtract);
+ }
+
+ RINOK(threadDecoder.FosSpec->Init(db, db->FolderStartFileIndex[folderIndex], &extractStatuses, sbOutStream));
+ sbOutStream.Release();
+
+ threadDecoder.InStream = inStream;
+ threadDecoder.Folder = &db->Folders[folderIndex];
+ threadDecoder.StartPos = db->GetFolderStreamPos(folderIndex, 0);
+ threadDecoder.PackSizes = &db->PackSizes[db->FolderStartPackStreamIndex[folderIndex]];
+
+ threadDecoder.Start();
+
+ int startPackIndex = newDatabase.PackSizes.Size();
+ CFolder newFolder;
+ RINOK(encoder.Encode(
+ EXTERNAL_CODECS_LOC_VARS
+ sbInStream, NULL, &inSizeForReduce, newFolder,
+ archive.SeqStream, newDatabase.PackSizes, progress));
+
+ threadDecoder.WaitFinish();
+
+ RINOK(threadDecoder.Result);
+
+ for (; startPackIndex < newDatabase.PackSizes.Size(); startPackIndex++)
+ lps->OutSize += newDatabase.PackSizes[startPackIndex];
+ lps->InSize += newFolder.GetUnpackSize();
+
+ newDatabase.Folders.Add(newFolder);
+ }
+
+ newDatabase.NumUnpackStreamsVector.Add(rep.NumCopyFiles);
+
+ CNum numUnpackStreams = db->NumUnpackStreamsVector[folderIndex];
+
+ CNum indexInFolder = 0;
+ for (CNum fi = db->FolderStartFileIndex[folderIndex]; indexInFolder < numUnpackStreams; fi++)
+ {
+ CFileItem file;
+ CFileItem2 file2;
+ db->GetFile(fi, file, file2);
+ if (file.HasStream)
+ {
+ indexInFolder++;
+ int updateIndex = fileIndexToUpdateIndexMap[fi];
+ if (updateIndex >= 0)
+ {
+ const CUpdateItem &ui = updateItems[updateIndex];
+ if (ui.NewData)
+ continue;
+ if (ui.NewProps)
+ {
+ CFileItem uf;
+ FromUpdateItemToFileItem(ui, uf, file2);
+ uf.Size = file.Size;
+ uf.Crc = file.Crc;
+ uf.CrcDefined = file.CrcDefined;
+ uf.HasStream = file.HasStream;
+ file = uf;
+ }
+ newDatabase.AddFile(file, file2);
+ }
+ }
+ }
+ }
+
+ int numFiles = group.Indices.Size();
+ if (numFiles == 0)
+ continue;
+ CRecordVector<CRefItem> refItems;
+ refItems.Reserve(numFiles);
+ bool sortByType = (numSolidFiles > 1);
+ for (i = 0; i < numFiles; i++)
+ refItems.Add(CRefItem(group.Indices[i], updateItems[group.Indices[i]], sortByType));
+ refItems.Sort(CompareUpdateItems, (void *)&sortByType);
+
+ CRecordVector<UInt32> indices;
+ indices.Reserve(numFiles);
+
+ for (i = 0; i < numFiles; i++)
+ {
+ UInt32 index = refItems[i].Index;
+ indices.Add(index);
+ /*
+ const CUpdateItem &ui = updateItems[index];
+ CFileItem file;
+ if (ui.NewProps)
+ FromUpdateItemToFileItem(ui, file);
+ else
+ file = db.Files[ui.IndexInArchive];
+ if (file.IsAnti || file.IsDir)
+ return E_FAIL;
+ newDatabase.Files.Add(file);
+ */
+ }
+
+ for (i = 0; i < numFiles;)
+ {
+ UInt64 totalSize = 0;
+ int numSubFiles;
+ UString prevExtension;
+ for (numSubFiles = 0; i + numSubFiles < numFiles &&
+ static_cast< unsigned int >( numSubFiles ) < numSolidFiles; numSubFiles++)
+ {
+ const CUpdateItem &ui = updateItems[indices[i + numSubFiles]];
+ totalSize += ui.Size;
+ if (totalSize > options.NumSolidBytes)
+ break;
+ if (options.SolidExtension)
+ {
+ UString ext = ui.GetExtension();
+ if (numSubFiles == 0)
+ prevExtension = ext;
+ else
+ if (ext.CompareNoCase(prevExtension) != 0)
+ break;
+ }
+ }
+ if (numSubFiles < 1)
+ numSubFiles = 1;
+
+ CFolderInStream *inStreamSpec = new CFolderInStream;
+ CMyComPtr<ISequentialInStream> solidInStream(inStreamSpec);
+ inStreamSpec->Init(updateCallback, &indices[i], numSubFiles);
+
+ CFolder folderItem;
+
+ int startPackIndex = newDatabase.PackSizes.Size();
+ RINOK(encoder.Encode(
+ EXTERNAL_CODECS_LOC_VARS
+ solidInStream, NULL, &inSizeForReduce, folderItem,
+ archive.SeqStream, newDatabase.PackSizes, progress));
+
+ for (; startPackIndex < newDatabase.PackSizes.Size(); startPackIndex++)
+ lps->OutSize += newDatabase.PackSizes[startPackIndex];
+
+ lps->InSize += folderItem.GetUnpackSize();
+ // for ()
+ // newDatabase.PackCRCsDefined.Add(false);
+ // newDatabase.PackCRCs.Add(0);
+
+ newDatabase.Folders.Add(folderItem);
+
+ CNum numUnpackStreams = 0;
+ for (int subIndex = 0; subIndex < numSubFiles; subIndex++)
+ {
+ const CUpdateItem &ui = updateItems[indices[i + subIndex]];
+ CFileItem file;
+ CFileItem2 file2;
+ if (ui.NewProps)
+ FromUpdateItemToFileItem(ui, file, file2);
+ else
+ db->GetFile(ui.IndexInArchive, file, file2);
+ if (file2.IsAnti || file.IsDir)
+ return E_FAIL;
+
+ /*
+ CFileItem &file = newDatabase.Files[
+ startFileIndexInDatabase + i + subIndex];
+ */
+ if (!inStreamSpec->Processed[subIndex])
+ {
+ continue;
+ // file.Name += L".locked";
+ }
+
+ file.Crc = inStreamSpec->CRCs[subIndex];
+ file.Size = inStreamSpec->Sizes[subIndex];
+ if (file.Size != 0)
+ {
+ file.CrcDefined = true;
+ file.HasStream = true;
+ numUnpackStreams++;
+ }
+ else
+ {
+ file.CrcDefined = false;
+ file.HasStream = false;
+ }
+ newDatabase.AddFile(file, file2);
+ }
+ // numUnpackStreams = 0 is very bad case for locked files
+ // v3.13 doesn't understand it.
+ newDatabase.NumUnpackStreamsVector.Add(numUnpackStreams);
+ i += numSubFiles;
+ }
+ }
+
+ if (folderRefIndex != folderRefs.Size())
+ return E_FAIL;
+
+ /*
+ folderRefs.ClearAndFree();
+ fileIndexToUpdateIndexMap.ClearAndFree();
+ groups.ClearAndFree();
+ */
+
+ {
+ // ---------- Write Folders & Empty Files ----------
+
+ CRecordVector<int> emptyRefs;
+ for (i = 0; i < updateItems.Size(); i++)
+ {
+ const CUpdateItem &ui = updateItems[i];
+ if (ui.NewData)
+ {
+ if (ui.HasStream())
+ continue;
+ }
+ else if (ui.IndexInArchive != -1 && db->Files[ui.IndexInArchive].HasStream)
+ continue;
+ emptyRefs.Add(i);
+ }
+ emptyRefs.Sort(CompareEmptyItems, (void *)&updateItems);
+ for (i = 0; i < emptyRefs.Size(); i++)
+ {
+ const CUpdateItem &ui = updateItems[emptyRefs[i]];
+ CFileItem file;
+ CFileItem2 file2;
+ if (ui.NewProps)
+ FromUpdateItemToFileItem(ui, file, file2);
+ else
+ db->GetFile(ui.IndexInArchive, file, file2);
+ newDatabase.AddFile(file, file2);
+ }
+ }
+
+ newDatabase.ReserveDown();
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zUpdate.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zUpdate.h
new file mode 100644
index 000000000..31e362246
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/7z/7zUpdate.h
@@ -0,0 +1,88 @@
+// 7zUpdate.h
+
+#ifndef __7Z_UPDATE_H
+#define __7Z_UPDATE_H
+
+#include "7zCompressionMode.h"
+#include "7zIn.h"
+#include "7zOut.h"
+
+#include "../IArchive.h"
+
+namespace NArchive {
+namespace N7z {
+
+struct CUpdateItem
+{
+ int IndexInArchive;
+ int IndexInClient;
+
+ UInt64 CTime;
+ UInt64 ATime;
+ UInt64 MTime;
+
+ UInt64 Size;
+ UString Name;
+
+ UInt32 Attrib;
+
+ bool NewData;
+ bool NewProps;
+
+ bool IsAnti;
+ bool IsDir;
+
+ bool AttribDefined;
+ bool CTimeDefined;
+ bool ATimeDefined;
+ bool MTimeDefined;
+
+ bool HasStream() const { return !IsDir && !IsAnti && Size != 0; }
+
+ CUpdateItem():
+ IsAnti(false),
+ IsDir(false),
+ AttribDefined(false),
+ CTimeDefined(false),
+ ATimeDefined(false),
+ MTimeDefined(false)
+ {}
+ void SetDirStatusFromAttrib() { IsDir = ((Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0); };
+
+ int GetExtensionPos() const;
+ UString GetExtension() const;
+};
+
+struct CUpdateOptions
+{
+ const CCompressionMethodMode *Method;
+ const CCompressionMethodMode *HeaderMethod;
+ bool UseFilters;
+ bool MaxFilter;
+
+ CHeaderOptions HeaderOptions;
+
+ UInt64 NumSolidFiles;
+ UInt64 NumSolidBytes;
+ bool SolidExtension;
+ bool RemoveSfxBlock;
+ bool VolumeMode;
+};
+
+HRESULT Update(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IInStream *inStream,
+ const CArchiveDatabaseEx *db,
+ const CObjectVector<CUpdateItem> &updateItems,
+ COutArchive &archive,
+ CArchiveDatabase &newDatabase,
+ ISequentialOutStream *seqOutStream,
+ IArchiveUpdateCallback *updateCallback,
+ const CUpdateOptions &options
+ #ifndef _NO_CRYPTO
+ , ICryptoGetTextPassword *getDecoderPassword
+ #endif
+ );
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ArchiveExports.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ArchiveExports.cpp
new file mode 100644
index 000000000..f7bc9c694
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ArchiveExports.cpp
@@ -0,0 +1,127 @@
+// ArchiveExports.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/ComTry.h"
+
+#include "../../Windows/PropVariant.h"
+
+#include "../Common/RegisterArc.h"
+
+static const unsigned int kNumArcsMax = 48;
+static unsigned int g_NumArcs = 0;
+static const CArcInfo *g_Arcs[kNumArcsMax];
+void RegisterArc(const CArcInfo *arcInfo)
+{
+ if (g_NumArcs < kNumArcsMax)
+ g_Arcs[g_NumArcs++] = arcInfo;
+}
+
+DEFINE_GUID(CLSID_CArchiveHandler,
+0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
+
+#define CLS_ARC_ID_ITEM(cls) ((cls).Data4[5])
+
+static inline HRESULT SetPropString(const char *s, unsigned int size, PROPVARIANT *value)
+{
+ if ((value->bstrVal = ::SysAllocStringByteLen(s, size)) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+}
+
+static inline HRESULT SetPropGUID(const GUID &guid, PROPVARIANT *value)
+{
+ return SetPropString((const char *)&guid, sizeof(GUID), value);
+}
+
+int FindFormatCalssId(const GUID *clsID)
+{
+ GUID cls = *clsID;
+ CLS_ARC_ID_ITEM(cls) = 0;
+ if (cls != CLSID_CArchiveHandler)
+ return -1;
+ Byte id = CLS_ARC_ID_ITEM(*clsID);
+ for (unsigned i = 0; i < g_NumArcs; i++)
+ if (g_Arcs[i]->ClassId == id)
+ return (int)i;
+ return -1;
+}
+
+STDAPI CreateArchiver(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ COM_TRY_BEGIN
+ {
+ int needIn = (*iid == IID_IInArchive);
+ int needOut = (*iid == IID_IOutArchive);
+ if (!needIn && !needOut)
+ return E_NOINTERFACE;
+ int formatIndex = FindFormatCalssId(clsid);
+ if (formatIndex < 0)
+ return CLASS_E_CLASSNOTAVAILABLE;
+
+ const CArcInfo &arc = *g_Arcs[formatIndex];
+ if (needIn)
+ {
+ *outObject = arc.CreateInArchive();
+ ((IInArchive *)*outObject)->AddRef();
+ }
+ else
+ {
+ if (!arc.CreateOutArchive)
+ return CLASS_E_CLASSNOTAVAILABLE;
+ *outObject = arc.CreateOutArchive();
+ ((IOutArchive *)*outObject)->AddRef();
+ }
+ }
+ COM_TRY_END
+ return S_OK;
+}
+
+STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value)
+{
+ if (formatIndex >= g_NumArcs)
+ return E_INVALIDARG;
+ const CArcInfo &arc = *g_Arcs[formatIndex];
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case NArchive::kName:
+ prop = arc.Name;
+ break;
+ case NArchive::kClassID:
+ {
+ GUID clsId = CLSID_CArchiveHandler;
+ CLS_ARC_ID_ITEM(clsId) = arc.ClassId;
+ return SetPropGUID(clsId, value);
+ }
+ case NArchive::kExtension:
+ if (arc.Ext != 0)
+ prop = arc.Ext;
+ break;
+ case NArchive::kAddExtension:
+ if (arc.AddExt != 0)
+ prop = arc.AddExt;
+ break;
+ case NArchive::kUpdate:
+ prop = (bool)(arc.CreateOutArchive != 0);
+ break;
+ case NArchive::kKeepName:
+ prop = arc.KeepName;
+ break;
+ case NArchive::kStartSignature:
+ return SetPropString((const char *)arc.Signature, arc.SignatureSize, value);
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
+{
+ return GetHandlerProperty2(0, propID, value);
+}
+
+STDAPI GetNumberOfFormats(UINT32 *numFormats)
+{
+ *numFormats = g_NumArcs;
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ArjHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ArjHandler.cpp
new file mode 100644
index 000000000..66ad16776
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ArjHandler.cpp
@@ -0,0 +1,799 @@
+// ArjHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamObjects.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/ArjDecoder1.h"
+#include "../Compress/ArjDecoder2.h"
+#include "../Compress/CopyCoder.h"
+
+#include "Common/ItemNameUtils.h"
+#include "Common/OutStreamWithCRC.h"
+
+using namespace NWindows;
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+
+namespace NArchive {
+namespace NArj {
+
+const int kBlockSizeMin = 30;
+const int kBlockSizeMax = 2600;
+
+namespace NSignature
+{
+ const Byte kSig0 = 0x60;
+ const Byte kSig1 = 0xEA;
+}
+
+namespace NFileHeader
+{
+ namespace NCompressionMethod
+ {
+ enum
+ {
+ kStored = 0,
+ kCompressed1a = 1,
+ kCompressed1b = 2,
+ kCompressed1c = 3,
+ kCompressed2 = 4,
+ kNoDataNoCRC = 8,
+ kNoData = 9
+ };
+ }
+
+ namespace NFileType
+ {
+ enum
+ {
+ kBinary = 0,
+ k7BitText = 1,
+ kArchiveHeader = 2,
+ kDirectory = 3,
+ kVolumeLablel = 4,
+ kChapterLabel = 5
+ };
+ }
+
+ namespace NFlags
+ {
+ const Byte kGarbled = 1;
+ const Byte kVolume = 4;
+ const Byte kExtFile = 8;
+ const Byte kPathSym = 0x10;
+ const Byte kBackup = 0x20;
+ }
+
+ namespace NHostOS
+ {
+ enum EEnum
+ {
+ kMSDOS = 0, // filesystem used by MS-DOS, OS/2, Win32
+ // pkarj 2.50 (FAT / VFAT / FAT32 file systems)
+ kPRIMOS,
+ kUnix,
+ kAMIGA,
+ kMac,
+ kOS_2,
+ kAPPLE_GS,
+ kAtari_ST,
+ kNext,
+ kVAX_VMS,
+ kWIN95
+ };
+ }
+}
+
+struct CArchiveHeader
+{
+ // Byte ArchiverVersion;
+ // Byte ExtractVersion;
+ Byte HostOS;
+ // Byte Flags;
+ // Byte SecuryVersion;
+ // Byte FileType;
+ // Byte Reserved;
+ UInt32 CTime;
+ UInt32 MTime;
+ UInt32 ArchiveSize;
+ // UInt32 SecurityEnvelopeFilePosition;
+ // UInt16 FilespecPositionInFilename;
+ // UInt16 LengthOfSecurityEnvelopeSata;
+ // Byte EncryptionVersion;
+ // Byte LastChapter;
+ AString Name;
+ AString Comment;
+
+ HRESULT Parse(const Byte *p, unsigned size);
+};
+
+static HRESULT ReadString(const Byte *p, unsigned &size, AString &res)
+{
+ AString s;
+ for (unsigned i = 0; i < size;)
+ {
+ char c = (char)p[i++];
+ if (c == 0)
+ {
+ size = i;
+ res = s;
+ return S_OK;
+ }
+ s += c;
+ }
+ return S_FALSE;
+}
+
+HRESULT CArchiveHeader::Parse(const Byte *p, unsigned size)
+{
+ if (size < kBlockSizeMin)
+ return S_FALSE;
+ Byte firstHeaderSize = p[0];
+ if (firstHeaderSize > size)
+ return S_FALSE;
+ // ArchiverVersion = p[1];
+ // ExtractVersion = p[2];
+ HostOS = p[3];
+ // Flags = p[4];
+ // SecuryVersion = p[5];
+ if (p[6] != NFileHeader::NFileType::kArchiveHeader)
+ return S_FALSE;
+ // Reserved = p[7];
+ CTime = Get32(p + 8);
+ MTime = Get32(p + 12);
+ ArchiveSize = Get32(p + 16);
+ // SecurityEnvelopeFilePosition = Get32(p + 20);
+ // UInt16 filespecPositionInFilename = Get16(p + 24);
+ // LengthOfSecurityEnvelopeSata = Get16(p + 26);
+ // EncryptionVersion = p[28];
+ // LastChapter = p[29];
+ unsigned pos = firstHeaderSize;
+ unsigned size1 = size - pos;
+ RINOK(ReadString(p + pos, size1, Name));
+ pos += size1;
+ size1 = size - pos;
+ RINOK(ReadString(p + pos, size1, Comment));
+ pos += size1;
+ return S_OK;
+}
+
+struct CItem
+{
+ AString Name;
+ AString Comment;
+
+ UInt32 MTime;
+ UInt32 PackSize;
+ UInt32 Size;
+ UInt32 FileCRC;
+ UInt32 SplitPos;
+
+ Byte Version;
+ Byte ExtractVersion;
+ Byte HostOS;
+ Byte Flags;
+ Byte Method;
+ Byte FileType;
+
+ // UInt16 FilespecPositionInFilename;
+ UInt16 FileAccessMode;
+ // Byte FirstChapter;
+ // Byte LastChapter;
+
+ UInt64 DataPosition;
+
+ bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kGarbled) != 0; }
+ bool IsDir() const { return (FileType == NFileHeader::NFileType::kDirectory); }
+ bool IsSplitAfter() const { return (Flags & NFileHeader::NFlags::kVolume) != 0; }
+ bool IsSplitBefore() const { return (Flags & NFileHeader::NFlags::kExtFile) != 0; }
+ UInt32 GetWinAttributes() const
+ {
+ UInt32 winAtrributes;
+ switch(HostOS)
+ {
+ case NFileHeader::NHostOS::kMSDOS:
+ case NFileHeader::NHostOS::kWIN95:
+ winAtrributes = FileAccessMode;
+ break;
+ default:
+ winAtrributes = 0;
+ }
+ if (IsDir())
+ winAtrributes |= FILE_ATTRIBUTE_DIRECTORY;
+ return winAtrributes;
+ }
+
+ HRESULT Parse(const Byte *p, unsigned size);
+};
+
+HRESULT CItem::Parse(const Byte *p, unsigned size)
+{
+ if (size < kBlockSizeMin)
+ return S_FALSE;
+
+ Byte firstHeaderSize = p[0];
+
+ Version = p[1];
+ ExtractVersion = p[2];
+ HostOS = p[3];
+ Flags = p[4];
+ Method = p[5];
+ FileType = p[6];
+ // Reserved = p[7];
+ MTime = Get32(p + 8);
+ PackSize = Get32(p + 12);
+ Size = Get32(p + 16);
+ FileCRC = Get32(p + 20);
+ // FilespecPositionInFilename = Get16(p + 24);
+ FileAccessMode = Get16(p + 26);
+ // FirstChapter = p[28];
+ // FirstChapter = p[29];
+
+ SplitPos = 0;
+ if (IsSplitBefore() && firstHeaderSize >= 34)
+ SplitPos = Get32(p + 30);
+
+ unsigned pos = firstHeaderSize;
+ unsigned size1 = size - pos;
+ RINOK(ReadString(p + pos, size1, Name));
+ pos += size1;
+ size1 = size - pos;
+ RINOK(ReadString(p + pos, size1, Comment));
+ pos += size1;
+
+ return S_OK;
+}
+
+struct CInArchiveException
+{
+ enum CCauseType
+ {
+ kUnexpectedEndOfArchive = 0,
+ kCRCError,
+ kIncorrectArchive,
+ }
+ Cause;
+ CInArchiveException(CCauseType cause): Cause(cause) {};
+};
+
+class CInArchive
+{
+ UInt32 _blockSize;
+ Byte _block[kBlockSizeMax + 4];
+
+ HRESULT ReadBlock(bool &filled);
+ HRESULT ReadSignatureAndBlock(bool &filled);
+ HRESULT SkipExtendedHeaders();
+
+ HRESULT SafeReadBytes(void *data, UInt32 size);
+
+public:
+ CArchiveHeader Header;
+
+ IInStream *Stream;
+ IArchiveOpenCallback *Callback;
+ UInt64 NumFiles;
+ UInt64 NumBytes;
+
+ HRESULT Open(const UInt64 *searchHeaderSizeLimit);
+ HRESULT GetNextItem(bool &filled, CItem &item);
+};
+
+static inline bool TestMarkerCandidate(const Byte *p, unsigned maxSize)
+{
+ if (p[0] != NSignature::kSig0 || p[1] != NSignature::kSig1)
+ return false;
+ UInt32 blockSize = Get16(p + 2);
+ p += 4;
+ if (p[6] != NFileHeader::NFileType::kArchiveHeader ||
+ p[0] > blockSize ||
+ maxSize < 2 + 2 + blockSize + 4 ||
+ blockSize < kBlockSizeMin || blockSize > kBlockSizeMax ||
+ p[28] > 8) // EncryptionVersion
+ return false;
+ // return (Get32(p + blockSize) == CrcCalc(p, blockSize));
+ return true;
+}
+
+static HRESULT FindAndReadMarker(ISequentialInStream *stream, const UInt64 *searchHeaderSizeLimit, UInt64 &position)
+{
+ position = 0;
+
+ const int kMarkerSizeMin = 2 + 2 + kBlockSizeMin + 4;
+ const int kMarkerSizeMax = 2 + 2 + kBlockSizeMax + 4;
+
+ CByteBuffer byteBuffer;
+ const UInt32 kBufSize = 1 << 16;
+ byteBuffer.SetCapacity(kBufSize);
+ Byte *buf = byteBuffer;
+
+ size_t processedSize = kMarkerSizeMax;
+ RINOK(ReadStream(stream, buf, &processedSize));
+ if (processedSize < kMarkerSizeMin)
+ return S_FALSE;
+ if (TestMarkerCandidate(buf, (unsigned)processedSize))
+ return S_OK;
+
+ UInt32 numBytesPrev = (UInt32)processedSize - 1;
+ memmove(buf, buf + 1, numBytesPrev);
+ UInt64 curTestPos = 1;
+ for (;;)
+ {
+ if (searchHeaderSizeLimit != NULL)
+ if (curTestPos > *searchHeaderSizeLimit)
+ return S_FALSE;
+ processedSize = kBufSize - numBytesPrev;
+ RINOK(ReadStream(stream, buf + numBytesPrev, &processedSize));
+ UInt32 numBytesInBuffer = numBytesPrev + (UInt32)processedSize;
+ if (numBytesInBuffer < kMarkerSizeMin)
+ return S_FALSE;
+ UInt32 numTests = numBytesInBuffer - kMarkerSizeMin + 1;
+ UInt32 pos;
+ for (pos = 0; pos < numTests; pos++)
+ {
+ for (; buf[pos] != NSignature::kSig0 && pos < numTests; pos++);
+ if (pos == numTests)
+ break;
+ if (TestMarkerCandidate(buf + pos, numBytesInBuffer - pos))
+ {
+ position = curTestPos + pos;
+ return S_OK;
+ }
+ }
+ curTestPos += pos;
+ numBytesPrev = numBytesInBuffer - numTests;
+ memmove(buf, buf + numTests, numBytesPrev);
+ }
+}
+
+HRESULT CInArchive::SafeReadBytes(void *data, UInt32 size)
+{
+ size_t processed = size;
+ RINOK(ReadStream(Stream, data, &processed));
+ if (processed != size)
+ throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadBlock(bool &filled)
+{
+ filled = false;
+ Byte buf[2];
+ RINOK(SafeReadBytes(buf, 2));
+ _blockSize = Get16(buf);
+ if (_blockSize == 0)
+ return S_OK;
+ if (_blockSize > kBlockSizeMax)
+ throw CInArchiveException(CInArchiveException::kIncorrectArchive);
+ RINOK(SafeReadBytes(_block, _blockSize + 4));
+ NumBytes += _blockSize + 6;
+ if (Get32(_block + _blockSize) != CrcCalc(_block, _blockSize))
+ throw CInArchiveException(CInArchiveException::kCRCError);
+ filled = true;
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadSignatureAndBlock(bool &filled)
+{
+ Byte id[2];
+ RINOK(SafeReadBytes(id, 2));
+ if (id[0] != NSignature::kSig0 || id[1] != NSignature::kSig1)
+ throw CInArchiveException(CInArchiveException::kIncorrectArchive);
+ return ReadBlock(filled);
+}
+
+HRESULT CInArchive::SkipExtendedHeaders()
+{
+ for (UInt32 i = 0;; i++)
+ {
+ bool filled;
+ RINOK(ReadBlock(filled));
+ if (!filled)
+ return S_OK;
+ if (Callback && (i & 0xFF) == 0)
+ RINOK(Callback->SetCompleted(&NumFiles, &NumBytes));
+ }
+}
+
+HRESULT CInArchive::Open(const UInt64 *searchHeaderSizeLimit)
+{
+ UInt64 position = 0;
+ RINOK(FindAndReadMarker(Stream, searchHeaderSizeLimit, position));
+ RINOK(Stream->Seek(position, STREAM_SEEK_SET, NULL));
+ bool filled;
+ RINOK(ReadSignatureAndBlock(filled));
+ if (!filled)
+ return S_FALSE;
+ RINOK(Header.Parse(_block, _blockSize));
+ return SkipExtendedHeaders();
+}
+
+HRESULT CInArchive::GetNextItem(bool &filled, CItem &item)
+{
+ RINOK(ReadSignatureAndBlock(filled));
+ if (!filled)
+ return S_OK;
+ filled = false;
+ RINOK(item.Parse(_block, _blockSize));
+ /*
+ UInt32 extraData;
+ if ((header.Flags & NFileHeader::NFlags::kExtFile) != 0)
+ extraData = GetUi32(_block + pos);
+ */
+
+ RINOK(SkipExtendedHeaders());
+ filled = true;
+ return S_OK;
+}
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+
+ INTERFACE_IInArchive(;)
+
+ HRESULT Open2(IInStream *inStream, const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *callback);
+private:
+ CInArchive _archive;
+ CObjectVector<CItem> _items;
+ CMyComPtr<IInStream> _stream;
+};
+
+const wchar_t *kHostOS[] =
+{
+ L"MSDOS",
+ L"PRIMOS",
+ L"UNIX",
+ L"AMIGA",
+ L"MAC",
+ L"OS/2",
+ L"APPLE GS",
+ L"ATARI ST",
+ L"NEXT",
+ L"VAX VMS",
+ L"WIN95"
+};
+
+const wchar_t *kUnknownOS = L"Unknown";
+
+const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidName, VT_BSTR},
+ { NULL, kpidCTime, VT_BSTR},
+ { NULL, kpidMTime, VT_BSTR},
+ { NULL, kpidHostOS, VT_BSTR},
+ { NULL, kpidComment, VT_BSTR}
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI4},
+ { NULL, kpidPosition, VT_UI8},
+ { NULL, kpidPackSize, VT_UI4},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidEncrypted, VT_BOOL},
+ { NULL, kpidCRC, VT_UI4},
+ { NULL, kpidMethod, VT_UI1},
+ { NULL, kpidHostOS, VT_BSTR},
+ { NULL, kpidComment, VT_BSTR}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+static void SetTime(UInt32 dosTime, NWindows::NCOM::CPropVariant &prop)
+{
+ if (dosTime == 0)
+ return;
+ FILETIME localFileTime, utc;
+ if (NTime::DosTimeToFileTime(dosTime, localFileTime))
+ {
+ if (!LocalFileTimeToFileTime(&localFileTime, &utc))
+ utc.dwHighDateTime = utc.dwLowDateTime = 0;
+ }
+ else
+ utc.dwHighDateTime = utc.dwLowDateTime = 0;
+ prop = utc;
+}
+
+static void SetHostOS(Byte hostOS, NWindows::NCOM::CPropVariant &prop)
+{
+ prop = hostOS < kNumHostOSes ? kHostOS[hostOS] : kUnknownOS;
+}
+
+static void SetUnicodeString(const AString &s, NWindows::NCOM::CPropVariant &prop)
+{
+ if (!s.IsEmpty())
+ prop = MultiByteToUnicodeString(s, CP_OEMCP);
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidName: SetUnicodeString(_archive.Header.Name, prop); break;
+ case kpidCTime: SetTime(_archive.Header.CTime, prop); break;
+ case kpidMTime: SetTime(_archive.Header.MTime, prop); break;
+ case kpidHostOS: SetHostOS(_archive.Header.HostOS, prop); break;
+ case kpidComment: SetUnicodeString(_archive.Header.Comment, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _items.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItem &item = _items[index];
+ switch(propID)
+ {
+ case kpidPath: prop = NItemName::GetOSName(MultiByteToUnicodeString(item.Name, CP_OEMCP)); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidPackSize: prop = item.PackSize; break;
+ case kpidPosition: if (item.IsSplitBefore() || item.IsSplitAfter()) prop = (UInt64)item.SplitPos; break;
+ case kpidAttrib: prop = item.GetWinAttributes(); break;
+ case kpidEncrypted: prop = item.IsEncrypted(); break;
+ case kpidCRC: prop = item.FileCRC; break;
+ case kpidMethod: prop = item.Method; break;
+ case kpidHostOS: SetHostOS(item.HostOS, prop); break;
+ case kpidMTime: SetTime(item.MTime, prop); break;
+ case kpidComment: SetUnicodeString(item.Comment, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::Open2(IInStream *inStream, const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *callback)
+{
+ Close();
+
+ UInt64 endPos = 0;
+ if (callback != NULL)
+ {
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ }
+
+ _archive.Stream = inStream;
+ _archive.Callback = callback;
+ _archive.NumFiles = _archive.NumBytes = 0;
+
+ RINOK(_archive.Open(maxCheckStartPosition));
+ if (callback != NULL)
+ RINOK(callback->SetTotal(NULL, &endPos));
+ for (;;)
+ {
+ CItem item;
+ bool filled;
+
+
+ RINOK(_archive.GetNextItem(filled, item));
+
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &item.DataPosition));
+
+ if (!filled)
+ break;
+ _items.Add(item);
+
+ if (inStream->Seek(item.PackSize, STREAM_SEEK_CUR, NULL) != S_OK)
+ throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
+
+ _archive.NumFiles = _items.Size();
+ _archive.NumBytes = item.DataPosition;
+
+ if (callback != NULL && _items.Size() % 100 == 0)
+ {
+ RINOK(callback->SetCompleted(&_archive.NumFiles, &_archive.NumBytes));
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ HRESULT res;
+ try
+ {
+ res = Open2(inStream, maxCheckStartPosition, callback);
+ if (res == S_OK)
+ {
+ _stream = inStream;
+ return S_OK;
+ }
+ }
+ catch(const CInArchiveException &) { res = S_FALSE; }
+ Close();
+ return res;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _items.Clear();
+ _stream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (testModeSpec != 0);
+ UInt64 totalUnpacked = 0, totalPacked = 0;
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ const CItem &item = _items[allFilesMode ? i : indices[i]];
+ totalUnpacked += item.Size;
+ totalPacked += item.PackSize;
+ }
+ extractCallback->SetTotal(totalUnpacked);
+
+ totalUnpacked = totalPacked = 0;
+ UInt64 curUnpacked, curPacked;
+
+ CMyComPtr<ICompressCoder> arj1Decoder;
+ CMyComPtr<ICompressCoder> arj2Decoder;
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *inStreamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(inStreamSpec);
+ inStreamSpec->SetStream(_stream);
+
+ for (i = 0; i < numItems; i++, totalUnpacked += curUnpacked, totalPacked += curPacked)
+ {
+ lps->InSize = totalPacked;
+ lps->OutSize = totalUnpacked;
+ RINOK(lps->SetCur());
+
+ curUnpacked = curPacked = 0;
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NExtract::NAskMode::kTest :
+ NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _items[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (item.IsDir())
+ {
+ // if (!testMode)
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
+ }
+ continue;
+ }
+
+ if (!testMode && (!realOutStream))
+ continue;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ curUnpacked = item.Size;
+ curPacked = item.PackSize;
+
+ {
+ COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->SetStream(realOutStream);
+ realOutStream.Release();
+ outStreamSpec->Init();
+
+ inStreamSpec->Init(item.PackSize);
+
+ UInt64 pos;
+ _stream->Seek(item.DataPosition, STREAM_SEEK_SET, &pos);
+
+ HRESULT result = S_OK;
+ Int32 opRes = NExtract::NOperationResult::kOK;
+
+ if (item.IsEncrypted())
+ opRes = NExtract::NOperationResult::kUnSupportedMethod;
+ else
+ {
+ switch(item.Method)
+ {
+ case NFileHeader::NCompressionMethod::kStored:
+ {
+ result = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+ if (result == S_OK && copyCoderSpec->TotalSize != item.PackSize)
+ result = S_FALSE;
+ break;
+ }
+ case NFileHeader::NCompressionMethod::kCompressed1a:
+ case NFileHeader::NCompressionMethod::kCompressed1b:
+ case NFileHeader::NCompressionMethod::kCompressed1c:
+ {
+ if (!arj1Decoder)
+ arj1Decoder = new NCompress::NArj::NDecoder1::CCoder;
+ result = arj1Decoder->Code(inStream, outStream, NULL, &curUnpacked, progress);
+ break;
+ }
+ case NFileHeader::NCompressionMethod::kCompressed2:
+ {
+ if (!arj2Decoder)
+ arj2Decoder = new NCompress::NArj::NDecoder2::CCoder;
+ result = arj2Decoder->Code(inStream, outStream, NULL, &curUnpacked, progress);
+ break;
+ }
+ default:
+ opRes = NExtract::NOperationResult::kUnSupportedMethod;
+ }
+ }
+ if (opRes == NExtract::NOperationResult::kOK)
+ {
+ if (result == S_FALSE)
+ opRes = NExtract::NOperationResult::kDataError;
+ else
+ {
+ RINOK(result);
+ opRes = (outStreamSpec->GetCRC() == item.FileCRC) ?
+ NExtract::NOperationResult::kOK:
+ NExtract::NOperationResult::kCRCError;
+ }
+ }
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Arj", L"arj", 0, 4, { 0x60, 0xEA }, 2, false, CreateArc, 0 };
+
+REGISTER_ARC(Arj)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Bz2Handler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Bz2Handler.cpp
new file mode 100644
index 000000000..9b2c40482
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Bz2Handler.cpp
@@ -0,0 +1,428 @@
+// Bz2Handler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+
+#include "Windows/PropVariant.h"
+
+#ifdef COMPRESS_MT
+#include "../../Windows/System.h"
+#endif
+
+#include "../Common/CreateCoder.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/BZip2Decoder.h"
+#include "../Compress/BZip2Encoder.h"
+#include "../Compress/CopyCoder.h"
+
+#include "Common/DummyOutStream.h"
+#include "Common/ParseProperties.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NBz2 {
+
+static const UInt32 kNumPassesX1 = 1;
+static const UInt32 kNumPassesX7 = 2;
+static const UInt32 kNumPassesX9 = 7;
+
+static const UInt32 kDicSizeX1 = 100000;
+static const UInt32 kDicSizeX3 = 500000;
+static const UInt32 kDicSizeX5 = 900000;
+
+class CHandler:
+ public IInArchive,
+ public IArchiveOpenSeq,
+ public IOutArchive,
+ public ISetProperties,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _stream;
+ CMyComPtr<ISequentialInStream> _seqStream;
+ UInt64 _packSize;
+ UInt64 _startPosition;
+ bool _packSizeDefined;
+
+ UInt32 _level;
+ UInt32 _dicSize;
+ UInt32 _numPasses;
+ #ifdef COMPRESS_MT
+ UInt32 _numThreads;
+ #endif
+
+ void InitMethodProperties()
+ {
+ _level = 5;
+ _dicSize =
+ _numPasses = 0xFFFFFFFF;
+ #ifdef COMPRESS_MT
+ _numThreads = NWindows::NSystem::GetNumberOfProcessors();;
+ #endif
+ }
+
+public:
+ MY_UNKNOWN_IMP4(IInArchive, IArchiveOpenSeq, IOutArchive, ISetProperties)
+
+ INTERFACE_IInArchive(;)
+ INTERFACE_IOutArchive(;)
+ STDMETHOD(OpenSeq)(ISequentialInStream *stream);
+ STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProps);
+
+ CHandler() { InitMethodProperties(); }
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPackSize, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO_Table
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPhySize: if (_packSizeDefined) prop = _packSize; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPackSize: if (_packSizeDefined) prop = _packSize; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ try
+ {
+ Close();
+ RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_startPosition));
+ const int kSignatureSize = 3;
+ Byte buf[kSignatureSize];
+ RINOK(ReadStream_FALSE(stream, buf, kSignatureSize));
+ if (buf[0] != 'B' || buf[1] != 'Z' || buf[2] != 'h')
+ return S_FALSE;
+
+ UInt64 endPosition;
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPosition));
+ _packSize = endPosition - _startPosition;
+ _packSizeDefined = true;
+ _stream = stream;
+ _seqStream = stream;
+ }
+ catch(...) { return S_FALSE; }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
+{
+ Close();
+ _seqStream = stream;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _packSizeDefined = false;
+ _seqStream.Release();
+ _stream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == (UInt32)-1);
+ if (!allFilesMode)
+ {
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1 || indices[0] != 0)
+ return E_INVALIDARG;
+ }
+
+ bool testMode = (_aTestMode != 0);
+ if (_stream)
+ extractCallback->SetTotal(_packSize);
+ UInt64 currentTotalPacked = 0;
+ RINOK(extractCallback->SetCompleted(&currentTotalPacked));
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
+ if (!testMode && !realOutStream)
+ return S_OK;
+
+ extractCallback->PrepareOperation(askMode);
+
+ NCompress::NBZip2::CDecoder *decoderSpec = new NCompress::NBZip2::CDecoder;
+ CMyComPtr<ICompressCoder> decoder = decoderSpec;
+
+ if (_stream)
+ {
+ RINOK(_stream->Seek(_startPosition, STREAM_SEEK_SET, NULL));
+ }
+
+ decoderSpec->SetInStream(_seqStream);
+
+ #if defined( COMPRESS_MT) && defined( COMPRESS_BZIP2_MT)
+ RINOK(decoderSpec->SetNumberOfThreads(_numThreads));
+ #endif
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->SetStream(realOutStream);
+ outStreamSpec->Init();
+
+ realOutStream.Release();
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, true);
+
+ HRESULT result = S_OK;
+
+ bool firstItem = true;
+ for (;;)
+ {
+ lps->InSize = currentTotalPacked;
+ lps->OutSize = outStreamSpec->GetSize();
+
+ RINOK(lps->SetCur());
+
+ bool isBz2;
+ result = decoderSpec->CodeResume(outStream, isBz2, progress);
+
+ if (result != S_OK)
+ break;
+ if (!isBz2)
+ {
+ if (firstItem)
+ result = S_FALSE;
+ break;
+ }
+ firstItem = false;
+
+ _packSize = currentTotalPacked = decoderSpec->GetInputProcessedSize();
+ _packSizeDefined = true;
+ }
+ decoderSpec->ReleaseInStream();
+ outStream.Release();
+
+ Int32 retResult;
+ if (result == S_OK)
+ retResult = NExtract::NOperationResult::kOK;
+ else if (result == S_FALSE)
+ retResult = NExtract::NOperationResult::kDataError;
+ else
+ return result;
+ return extractCallback->SetOperationResult(retResult);
+
+ COM_TRY_END
+}
+
+static HRESULT UpdateArchive(
+ UInt64 unpackSize,
+ ISequentialOutStream *outStream,
+ int indexInClient,
+ UInt32 dictionary,
+ UInt32 numPasses,
+ #ifdef COMPRESS_MT
+ UInt32 numThreads,
+ #endif
+ IArchiveUpdateCallback *updateCallback)
+{
+ RINOK(updateCallback->SetTotal(unpackSize));
+ UInt64 complexity = 0;
+ RINOK(updateCallback->SetCompleted(&complexity));
+
+ CMyComPtr<ISequentialInStream> fileInStream;
+
+ RINOK(updateCallback->GetStream(indexInClient, &fileInStream));
+
+ CLocalProgress *localProgressSpec = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
+ localProgressSpec->Init(updateCallback, true);
+
+ NCompress::NBZip2::CEncoder *encoderSpec = new NCompress::NBZip2::CEncoder;
+ CMyComPtr<ICompressCoder> encoder = encoderSpec;
+ {
+ NWindows::NCOM::CPropVariant properties[] =
+ {
+ dictionary,
+ numPasses
+ #ifdef COMPRESS_MT
+ , numThreads
+ #endif
+ };
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kDictionarySize,
+ NCoderPropID::kNumPasses
+ #ifdef COMPRESS_MT
+ , NCoderPropID::kNumThreads
+ #endif
+ };
+ RINOK(encoderSpec->SetCoderProperties(propIDs, properties, sizeof(propIDs) / sizeof(propIDs[0])));
+ }
+
+ RINOK(encoder->Code(fileInStream, outStream, NULL, NULL, localProgress));
+
+ return updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK);
+}
+
+STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
+{
+ *type = NFileTimeType::kUnix;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
+ IArchiveUpdateCallback *updateCallback)
+{
+ if (numItems != 1)
+ return E_INVALIDARG;
+
+ Int32 newData, newProps;
+ UInt32 indexInArchive;
+ if (!updateCallback)
+ return E_FAIL;
+ RINOK(updateCallback->GetUpdateItemInfo(0, &newData, &newProps, &indexInArchive));
+
+ if (IntToBool(newProps))
+ {
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(0, kpidIsDir, &prop));
+ if (prop.vt == VT_BOOL)
+ {
+ if (prop.boolVal != VARIANT_FALSE)
+ return E_INVALIDARG;
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_INVALIDARG;
+ }
+ }
+
+ if (IntToBool(newData))
+ {
+ UInt64 size;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(0, kpidSize, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ size = prop.uhVal.QuadPart;
+ }
+
+ UInt32 dicSize = _dicSize;
+ if (dicSize == 0xFFFFFFFF)
+ dicSize = (_level >= 5 ? kDicSizeX5 :
+ (_level >= 3 ? kDicSizeX3 :
+ kDicSizeX1));
+
+ UInt32 numPasses = _numPasses;
+ if (numPasses == 0xFFFFFFFF)
+ numPasses = (_level >= 9 ? kNumPassesX9 :
+ (_level >= 7 ? kNumPassesX7 :
+ kNumPassesX1));
+
+ return UpdateArchive(
+ size, outStream, 0, dicSize, numPasses,
+ #ifdef COMPRESS_MT
+ _numThreads,
+ #endif
+ updateCallback);
+ }
+ if (indexInArchive != 0)
+ return E_INVALIDARG;
+ if (_stream)
+ RINOK(_stream->Seek(_startPosition, STREAM_SEEK_SET, NULL));
+ return NCompress::CopyStream(_stream, outStream, NULL);
+}
+
+STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProps)
+{
+ InitMethodProperties();
+ #ifdef COMPRESS_MT
+ const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
+ _numThreads = numProcessors;
+ #endif
+
+ for (int i = 0; i < numProps; i++)
+ {
+ UString name = names[i];
+ name.MakeUpper();
+ if (name.IsEmpty())
+ return E_INVALIDARG;
+ const PROPVARIANT &prop = values[i];
+ if (name[0] == L'X')
+ {
+ UInt32 level = 9;
+ RINOK(ParsePropValue(name.Mid(1), prop, level));
+ _level = level;
+ }
+ else if (name[0] == L'D')
+ {
+ UInt32 dicSize = kDicSizeX5;
+ RINOK(ParsePropDictionaryValue(name.Mid(1), prop, dicSize));
+ _dicSize = dicSize;
+ }
+ else if (name.Left(4) == L"PASS")
+ {
+ UInt32 num = kNumPassesX9;
+ RINOK(ParsePropValue(name.Mid(4), prop, num));
+ _numPasses = num;
+ }
+ else if (name.Left(2) == L"MT")
+ {
+ #ifdef COMPRESS_MT
+ RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
+ #endif
+ }
+ else
+ return E_INVALIDARG;
+ }
+ return S_OK;
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+#ifndef EXTRACT_ONLY
+static IOutArchive *CreateArcOut() { return new CHandler; }
+#else
+#define CreateArcOut 0
+#endif
+
+static CArcInfo g_ArcInfo =
+ { L"BZip2", L"bz2 bzip2 tbz2 tbz", L"* * .tar .tar", 2, { 'B', 'Z', 'h' }, 3, true, CreateArc, CreateArcOut };
+
+REGISTER_ARC(BZip2)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabBlockInStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabBlockInStream.cpp
new file mode 100644
index 000000000..12c73eb5f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabBlockInStream.cpp
@@ -0,0 +1,189 @@
+// CabBlockInStream.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/Alloc.h"
+
+#include "Common/Defs.h"
+
+#include "../../Common/StreamUtils.h"
+
+#include "CabBlockInStream.h"
+
+namespace NArchive {
+namespace NCab {
+
+static const UInt32 kBlockSize = (1 << 16);
+
+bool CCabBlockInStream::Create()
+{
+ if (!_buffer)
+ _buffer = (Byte *)::MyAlloc(kBlockSize);
+ return (_buffer != 0);
+}
+
+CCabBlockInStream::~CCabBlockInStream()
+{
+ MyFree(_buffer);
+}
+
+class CCheckSum2
+{
+ UInt32 m_Value;
+ int m_Pos;
+ Byte m_Hist[4];
+public:
+ CCheckSum2(): m_Value(0){};
+ void Init() { m_Value = 0; m_Pos = 0; }
+ void Update(const void *data, UInt32 size);
+ void FinishDataUpdate()
+ {
+ for (int i = 0; i < m_Pos; i++)
+ m_Value ^= ((UInt32)(m_Hist[i])) << (8 * (m_Pos - i - 1));
+ }
+ void UpdateUInt32(UInt32 v) { m_Value ^= v; }
+ UInt32 GetResult() const { return m_Value; }
+};
+
+void CCheckSum2::Update(const void *data, UInt32 size)
+{
+ UInt32 checkSum = m_Value;
+ const Byte *dataPointer = (const Byte *)data;
+
+ while (size != 0 && m_Pos != 0)
+ {
+ m_Hist[m_Pos] = *dataPointer++;
+ m_Pos = (m_Pos + 1) & 3;
+ size--;
+ if (m_Pos == 0)
+ for (int i = 0; i < 4; i++)
+ checkSum ^= ((UInt32)m_Hist[i]) << (8 * i);
+ }
+
+ int numWords = size / 4;
+
+ while (numWords-- != 0)
+ {
+ UInt32 temp = *dataPointer++;
+ temp |= ((UInt32)(*dataPointer++)) << 8;
+ temp |= ((UInt32)(*dataPointer++)) << 16;
+ temp |= ((UInt32)(*dataPointer++)) << 24;
+ checkSum ^= temp;
+ }
+ m_Value = checkSum;
+
+ size &= 3;
+
+ while (size != 0)
+ {
+ m_Hist[m_Pos] = *dataPointer++;
+ m_Pos = (m_Pos + 1) & 3;
+ size--;
+ }
+}
+
+static const UInt32 kDataBlockHeaderSize = 8;
+
+class CTempCabInBuffer2
+{
+public:
+ Byte Buffer[kDataBlockHeaderSize];
+ UInt32 Pos;
+ Byte ReadByte()
+ {
+ return Buffer[Pos++];
+ }
+ UInt32 ReadUInt32()
+ {
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ value |= (((UInt32)ReadByte()) << (8 * i));
+ return value;
+ }
+ UInt16 ReadUInt16()
+ {
+ UInt16 value = 0;
+ for (int i = 0; i < 2; i++)
+ value |= (((UInt16)ReadByte()) << (8 * i));
+ return value;
+ }
+};
+
+HRESULT CCabBlockInStream::PreRead(UInt32 &packSize, UInt32 &unpackSize)
+{
+ CTempCabInBuffer2 inBuffer;
+ inBuffer.Pos = 0;
+ RINOK(ReadStream_FALSE(_stream, inBuffer.Buffer, kDataBlockHeaderSize))
+
+ UInt32 checkSum = inBuffer.ReadUInt32();
+ packSize = inBuffer.ReadUInt16();
+ unpackSize = inBuffer.ReadUInt16();
+ if (ReservedSize != 0)
+ {
+ RINOK(ReadStream_FALSE(_stream, _buffer, ReservedSize));
+ }
+ _pos = 0;
+ CCheckSum2 checkSumCalc;
+ checkSumCalc.Init();
+ UInt32 packSize2 = packSize;
+ if (MsZip && _size == 0)
+ {
+ if (packSize < 2)
+ return S_FALSE; // bad block;
+ Byte sig[2];
+ RINOK(ReadStream_FALSE(_stream, sig, 2));
+ if (sig[0] != 0x43 || sig[1] != 0x4B)
+ return S_FALSE;
+ packSize2 -= 2;
+ checkSumCalc.Update(sig, 2);
+ }
+
+ if (kBlockSize - _size < packSize2)
+ return S_FALSE;
+
+ UInt32 curSize = packSize2;
+ if (curSize != 0)
+ {
+ size_t processedSizeLoc = curSize;
+ RINOK(ReadStream(_stream, _buffer + _size, &processedSizeLoc));
+ checkSumCalc.Update(_buffer + _size, (UInt32)processedSizeLoc);
+ _size += (UInt32)processedSizeLoc;
+ if (processedSizeLoc != curSize)
+ return S_FALSE;
+ }
+ TotalPackSize = _size;
+
+ checkSumCalc.FinishDataUpdate();
+
+ bool dataError;
+ if (checkSum == 0)
+ dataError = false;
+ else
+ {
+ checkSumCalc.UpdateUInt32(packSize | (((UInt32)unpackSize) << 16));
+ dataError = (checkSumCalc.GetResult() != checkSum);
+ }
+ DataError |= dataError;
+ return dataError ? S_FALSE : S_OK;
+}
+
+STDMETHODIMP CCabBlockInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != 0)
+ *processedSize = 0;
+ if (size == 0)
+ return S_OK;
+ if (_size != 0)
+ {
+ size = MyMin(_size, size);
+ memmove(data, _buffer + _pos, size);
+ _pos += size;
+ _size -= size;
+ if (processedSize != 0)
+ *processedSize = size;
+ return S_OK;
+ }
+ return S_OK; // no blocks data
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabBlockInStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabBlockInStream.h
new file mode 100644
index 000000000..a70dfdab4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabBlockInStream.h
@@ -0,0 +1,44 @@
+// CabBlockInStream.cpp
+
+#ifndef __CABBLOCKINSTREAM_H
+#define __CABBLOCKINSTREAM_H
+
+#include "Common/MyCom.h"
+#include "../../IStream.h"
+
+namespace NArchive {
+namespace NCab {
+
+class CCabBlockInStream:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialInStream> _stream;
+ Byte *_buffer;
+ UInt32 _pos;
+ UInt32 _size;
+
+public:
+ UInt32 TotalPackSize;
+ UInt32 ReservedSize;
+ bool DataError;
+ bool MsZip;
+
+ CCabBlockInStream(): _buffer(0), TotalPackSize(0), ReservedSize(0), DataError(false), MsZip(false) {}
+ ~CCabBlockInStream();
+ bool Create();
+ void SetStream(ISequentialInStream *stream) { _stream = stream; }
+
+ void InitForNewFolder() { TotalPackSize = 0; }
+ void InitForNewBlock() { _size = 0; }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+
+ HRESULT PreRead(UInt32 &packSize, UInt32 &unpackSize);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHandler.cpp
new file mode 100644
index 000000000..c4681183c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHandler.cpp
@@ -0,0 +1,822 @@
+// CabHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/Defs.h"
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+#include "Common/UTFConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+#include "../../Compress/DeflateDecoder.h"
+#include "../../Compress/LzxDecoder.h"
+#include "../../Compress/QuantumDecoder.h"
+
+#include "../Common/ItemNameUtils.h"
+
+#include "CabBlockInStream.h"
+#include "CabHandler.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NCab {
+
+// #define _CAB_DETAILS
+
+#ifdef _CAB_DETAILS
+enum
+{
+ kpidBlockReal = kpidUserDefined
+};
+#endif
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidBlock, VT_I4}
+ #ifdef _CAB_DETAILS
+ ,
+ { L"BlockReal", kpidBlockReal, VT_UI4},
+ { NULL, kpidOffset, VT_UI4},
+ { NULL, kpidVolume, VT_UI4}
+ #endif
+};
+
+static const wchar_t *kMethods[] =
+{
+ L"None",
+ L"MSZip",
+ L"Quantum",
+ L"LZX"
+};
+
+static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
+static const wchar_t *kUnknownMethod = L"Unknown";
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidMethod, VT_BSTR},
+ // { NULL, kpidSolid, VT_BOOL},
+ { NULL, kpidNumBlocks, VT_UI4},
+ { NULL, kpidNumVolumes, VT_UI4}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ UString resString;
+ CRecordVector<Byte> ids;
+ int i;
+ for (int v = 0; v < m_Database.Volumes.Size(); v++)
+ {
+ const CDatabaseEx &de = m_Database.Volumes[v];
+ for (i = 0; i < de.Folders.Size(); i++)
+ ids.AddToUniqueSorted(de.Folders[i].GetCompressionMethod());
+ }
+ for (i = 0; i < ids.Size(); i++)
+ {
+ Byte id = ids[i];
+ UString method = (id < kNumMethods) ? kMethods[id] : kUnknownMethod;
+ if (!resString.IsEmpty())
+ resString += L' ';
+ resString += method;
+ }
+ prop = resString;
+ break;
+ }
+ // case kpidSolid: prop = _database.IsSolid(); break;
+ case kpidNumBlocks:
+ {
+ UInt32 numFolders = 0;
+ for (int v = 0; v < m_Database.Volumes.Size(); v++)
+ numFolders += m_Database.Volumes[v].Folders.Size();
+ prop = numFolders;
+ break;
+ }
+ case kpidNumVolumes:
+ {
+ prop = (UInt32)m_Database.Volumes.Size();
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+
+ const CMvItem &mvItem = m_Database.Items[index];
+ const CDatabaseEx &db = m_Database.Volumes[mvItem.VolumeIndex];
+ int itemIndex = mvItem.ItemIndex;
+ const CItem &item = db.Items[itemIndex];
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ UString unicodeName;
+ if (item.IsNameUTF())
+ ConvertUTF8ToUnicode(item.Name, unicodeName);
+ else
+ unicodeName = MultiByteToUnicodeString(item.Name, CP_ACP);
+ prop = (const wchar_t *)NItemName::WinNameToOSName(unicodeName);
+ break;
+ }
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidAttrib: prop = item.GetWinAttributes(); break;
+
+ case kpidMTime:
+ {
+ FILETIME localFileTime, utcFileTime;
+ if (NTime::DosTimeToFileTime(item.Time, localFileTime))
+ {
+ if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
+ utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
+ }
+ else
+ utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
+ prop = utcFileTime;
+ break;
+ }
+
+ case kpidMethod:
+ {
+ UInt32 realFolderIndex = item.GetFolderIndex(db.Folders.Size());
+ const CFolder &folder = db.Folders[realFolderIndex];
+ int methodIndex = folder.GetCompressionMethod();
+ UString method = (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
+ if (methodIndex == NHeader::NCompressionMethodMajor::kLZX ||
+ methodIndex == NHeader::NCompressionMethodMajor::kQuantum)
+ {
+ method += L":";
+ wchar_t temp[32];
+ ConvertUInt64ToString(folder.CompressionTypeMinor, temp);
+ method += temp;
+ }
+ prop = method;
+ break;
+ }
+ case kpidBlock: prop = (Int32)m_Database.GetFolderIndex(&mvItem); break;
+
+ #ifdef _CAB_DETAILS
+
+ case kpidBlockReal: prop = (UInt32)item.FolderIndex; break;
+ case kpidOffset: prop = (UInt32)item.Offset; break;
+ case kpidVolume: prop = (UInt32)mvItem.VolumeIndex; break;
+
+ #endif
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+/*
+class CProgressImp: public CProgressVirt
+{
+ CMyComPtr<IArchiveOpenCallback> m_OpenArchiveCallback;
+public:
+ STDMETHOD(SetTotal)(const UInt64 *numFiles);
+ STDMETHOD(SetCompleted)(const UInt64 *numFiles);
+ void Init(IArchiveOpenCallback *openArchiveCallback)
+ { m_OpenArchiveCallback = openArchiveCallback; }
+};
+
+STDMETHODIMP CProgressImp::SetTotal(const UInt64 *numFiles)
+{
+ if (m_OpenArchiveCallback)
+ return m_OpenArchiveCallback->SetCompleted(numFiles, NULL);
+ return S_OK;
+}
+
+STDMETHODIMP CProgressImp::SetCompleted(const UInt64 *numFiles)
+{
+ if (m_OpenArchiveCallback)
+ return m_OpenArchiveCallback->SetCompleted(numFiles, NULL);
+ return S_OK;
+}
+*/
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ Close();
+ HRESULT res = S_FALSE;
+ CInArchive archive;
+ CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
+ {
+ CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = callback;
+ openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback, &openVolumeCallback);
+ }
+
+ CMyComPtr<IInStream> nextStream = inStream;
+ bool prevChecked = false;
+ UInt64 numItems = 0;
+ try
+ {
+ while(nextStream != 0)
+ {
+ CDatabaseEx db;
+ db.Stream = nextStream;
+ res = archive.Open(maxCheckStartPosition, db);
+ if (res == S_OK)
+ {
+ if (!m_Database.Volumes.IsEmpty())
+ {
+ const CDatabaseEx &dbPrev = m_Database.Volumes[prevChecked ? m_Database.Volumes.Size() - 1 : 0];
+ if (dbPrev.ArchiveInfo.SetID != db.ArchiveInfo.SetID ||
+ dbPrev.ArchiveInfo.CabinetNumber + (prevChecked ? 1: - 1) !=
+ db.ArchiveInfo.CabinetNumber)
+ res = S_FALSE;
+ }
+ }
+ if (res == S_OK)
+ m_Database.Volumes.Insert(prevChecked ? m_Database.Volumes.Size() : 0, db);
+ else if (res != S_FALSE)
+ return res;
+ else
+ {
+ if (m_Database.Volumes.IsEmpty())
+ return S_FALSE;
+ if (prevChecked)
+ break;
+ prevChecked = true;
+ }
+
+ numItems += db.Items.Size();
+ RINOK(callback->SetCompleted(&numItems, NULL));
+
+ nextStream = 0;
+ for (;;)
+ {
+ const COtherArchive *otherArchive = 0;
+ if (!prevChecked)
+ {
+ const CInArchiveInfo &ai = m_Database.Volumes.Front().ArchiveInfo;
+ if (ai.IsTherePrev())
+ otherArchive = &ai.PreviousArchive;
+ else
+ prevChecked = true;
+ }
+ if (otherArchive == 0)
+ {
+ const CInArchiveInfo &ai = m_Database.Volumes.Back().ArchiveInfo;
+ if (ai.IsThereNext())
+ otherArchive = &ai.NextArchive;
+ }
+ if (!otherArchive)
+ break;
+ const UString fullName = MultiByteToUnicodeString(otherArchive->FileName, CP_ACP);
+ HRESULT result = openVolumeCallback->GetStream(fullName, &nextStream);
+ if (result == S_OK)
+ break;
+ if (result != S_FALSE)
+ return result;
+ if (prevChecked)
+ break;
+ prevChecked = true;
+ }
+ }
+ if (res == S_OK)
+ {
+ m_Database.FillSortAndShrink();
+ if (!m_Database.Check())
+ res = S_FALSE;
+ }
+ }
+ catch(...)
+ {
+ res = S_FALSE;
+ }
+ if (res != S_OK)
+ {
+ Close();
+ return res;
+ }
+ COM_TRY_END
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ m_Database.Clear();
+ return S_OK;
+}
+
+class CCabFolderOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+private:
+ const CMvDatabaseEx *m_Database;
+ const CRecordVector<bool> *m_ExtractStatuses;
+ int m_StartIndex;
+ int m_CurrentIndex;
+ CMyComPtr<IArchiveExtractCallback> m_ExtractCallback;
+ bool m_TestMode;
+
+ CMyComPtr<ISequentialOutStream> m_RealOutStream;
+
+ bool m_IsOk;
+ bool m_FileIsOpen;
+ UInt64 m_RemainFileSize;
+ UInt64 m_FolderSize;
+ UInt64 m_PosInFolder;
+
+ HRESULT OpenFile();
+ HRESULT Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK);
+public:
+ HRESULT WriteEmptyFiles();
+
+ void Init(
+ const CMvDatabaseEx *database,
+ const CRecordVector<bool> *extractStatuses,
+ int startIndex,
+ UInt64 folderSize,
+ IArchiveExtractCallback *extractCallback,
+ bool testMode);
+ HRESULT FlushCorrupted();
+ HRESULT Unsupported();
+
+ UInt64 GetRemain() const { return m_FolderSize - m_PosInFolder; }
+ UInt64 GetPosInFolder() const { return m_PosInFolder; }
+};
+
+void CCabFolderOutStream::Init(
+ const CMvDatabaseEx *database,
+ const CRecordVector<bool> *extractStatuses,
+ int startIndex,
+ UInt64 folderSize,
+ IArchiveExtractCallback *extractCallback,
+ bool testMode)
+{
+ m_Database = database;
+ m_ExtractStatuses = extractStatuses;
+ m_StartIndex = startIndex;
+ m_FolderSize = folderSize;
+
+ m_ExtractCallback = extractCallback;
+ m_TestMode = testMode;
+
+ m_CurrentIndex = 0;
+ m_PosInFolder = 0;
+ m_FileIsOpen = false;
+ m_IsOk = true;
+}
+
+HRESULT CCabFolderOutStream::OpenFile()
+{
+ Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ?
+ NExtract::NAskMode::kTest :
+ NExtract::NAskMode::kExtract) :
+ NExtract::NAskMode::kSkip;
+ RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &m_RealOutStream, askMode));
+ if (!m_RealOutStream && !m_TestMode)
+ askMode = NArchive::NExtract::NAskMode::kSkip;
+ return m_ExtractCallback->PrepareOperation(askMode);
+}
+
+HRESULT CCabFolderOutStream::WriteEmptyFiles()
+{
+ if (m_FileIsOpen)
+ return S_OK;
+ for(;m_CurrentIndex < m_ExtractStatuses->Size(); m_CurrentIndex++)
+ {
+ const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex];
+ const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
+ UInt64 fileSize = item.Size;
+ if (fileSize != 0)
+ return S_OK;
+ HRESULT result = OpenFile();
+ m_RealOutStream.Release();
+ RINOK(result);
+ RINOK(m_ExtractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ }
+ return S_OK;
+}
+
+// This is Write function
+HRESULT CCabFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK)
+{
+ UInt32 realProcessed = 0;
+ if (processedSize != NULL)
+ *processedSize = 0;
+ while(size != 0)
+ {
+ if (m_FileIsOpen)
+ {
+ UInt32 numBytesToWrite = (UInt32)MyMin(m_RemainFileSize, (UInt64)(size));
+ HRESULT res = S_OK;
+ if (numBytesToWrite > 0)
+ {
+ if (!isOK)
+ m_IsOk = false;
+ if (m_RealOutStream)
+ {
+ UInt32 processedSizeLocal = 0;
+ res = m_RealOutStream->Write((const Byte *)data, numBytesToWrite, &processedSizeLocal);
+ numBytesToWrite = processedSizeLocal;
+ }
+ }
+ realProcessed += numBytesToWrite;
+ if (processedSize != NULL)
+ *processedSize = realProcessed;
+ data = (const void *)((const Byte *)data + numBytesToWrite);
+ size -= numBytesToWrite;
+ m_RemainFileSize -= numBytesToWrite;
+ m_PosInFolder += numBytesToWrite;
+ if (res != S_OK)
+ return res;
+ if (m_RemainFileSize == 0)
+ {
+ m_RealOutStream.Release();
+ RINOK(m_ExtractCallback->SetOperationResult(
+ m_IsOk ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ m_FileIsOpen = false;
+ }
+ if (realProcessed > 0)
+ break; // with this break this function works as Write-Part
+ }
+ else
+ {
+ if (m_CurrentIndex >= m_ExtractStatuses->Size())
+ return E_FAIL;
+
+ const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex];
+ const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
+
+ m_RemainFileSize = item.Size;
+
+ UInt32 fileOffset = item.Offset;
+ if (fileOffset < m_PosInFolder)
+ return E_FAIL;
+ if (fileOffset > m_PosInFolder)
+ {
+ UInt32 numBytesToWrite = (UInt32)MyMin((UInt64)fileOffset - m_PosInFolder, UInt64(size));
+ realProcessed += numBytesToWrite;
+ if (processedSize != NULL)
+ *processedSize = realProcessed;
+ data = (const void *)((const Byte *)data + numBytesToWrite);
+ size -= numBytesToWrite;
+ m_PosInFolder += numBytesToWrite;
+ }
+ if (fileOffset == m_PosInFolder)
+ {
+ RINOK(OpenFile());
+ m_FileIsOpen = true;
+ m_CurrentIndex++;
+ m_IsOk = true;
+ }
+ }
+ }
+ return WriteEmptyFiles();
+}
+
+STDMETHODIMP CCabFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ return Write2(data, size, processedSize, true);
+}
+
+HRESULT CCabFolderOutStream::FlushCorrupted()
+{
+ const UInt32 kBufferSize = (1 << 10);
+ Byte buffer[kBufferSize];
+ for (unsigned int i = 0; i < kBufferSize; i++)
+ buffer[i] = 0;
+ for (;;)
+ {
+ UInt64 remain = GetRemain();
+ if (remain == 0)
+ return S_OK;
+ UInt32 size = (UInt32)MyMin(remain, (UInt64)kBufferSize);
+ UInt32 processedSizeLocal = 0;
+ RINOK(Write2(buffer, size, &processedSizeLocal, false));
+ }
+}
+
+HRESULT CCabFolderOutStream::Unsupported()
+{
+ while(m_CurrentIndex < m_ExtractStatuses->Size())
+ {
+ HRESULT result = OpenFile();
+ if (result != S_FALSE && result != S_OK)
+ return result;
+ m_RealOutStream.Release();
+ RINOK(m_ExtractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ m_CurrentIndex++;
+ }
+ return S_OK;
+}
+
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == (UInt32)(-1));
+ if (allFilesMode)
+ numItems = m_Database.Items.Size();
+ if(numItems == 0)
+ return S_OK;
+ bool testMode = (_aTestMode != 0);
+ UInt64 totalUnPacked = 0;
+
+ UInt32 i;
+ int lastFolder = -2;
+ UInt64 lastFolderSize = 0;
+ for(i = 0; i < numItems; i++)
+ {
+ int index = allFilesMode ? i : indices[i];
+ const CMvItem &mvItem = m_Database.Items[index];
+ const CItem &item = m_Database.Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
+ if (item.IsDir())
+ continue;
+ int folderIndex = m_Database.GetFolderIndex(&mvItem);
+ if (folderIndex != lastFolder)
+ totalUnPacked += lastFolderSize;
+ lastFolder = folderIndex;
+ lastFolderSize = item.GetEndOffset();
+ }
+ totalUnPacked += lastFolderSize;
+
+ extractCallback->SetTotal(totalUnPacked);
+
+ totalUnPacked = 0;
+
+ UInt64 totalPacked = 0;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ NCompress::NDeflate::NDecoder::CCOMCoder *deflateDecoderSpec = NULL;
+ CMyComPtr<ICompressCoder> deflateDecoder;
+
+ NCompress::NLzx::CDecoder *lzxDecoderSpec = NULL;
+ CMyComPtr<ICompressCoder> lzxDecoder;
+
+ NCompress::NQuantum::CDecoder *quantumDecoderSpec = NULL;
+ CMyComPtr<ICompressCoder> quantumDecoder;
+
+ CCabBlockInStream *cabBlockInStreamSpec = new CCabBlockInStream();
+ CMyComPtr<ISequentialInStream> cabBlockInStream = cabBlockInStreamSpec;
+ if (!cabBlockInStreamSpec->Create())
+ return E_OUTOFMEMORY;
+
+ CRecordVector<bool> extractStatuses;
+ for(i = 0; i < numItems;)
+ {
+ int index = allFilesMode ? i : indices[i];
+
+ const CMvItem &mvItem = m_Database.Items[index];
+ const CDatabaseEx &db = m_Database.Volumes[mvItem.VolumeIndex];
+ int itemIndex = mvItem.ItemIndex;
+ const CItem &item = db.Items[itemIndex];
+
+ i++;
+ if (item.IsDir())
+ {
+ Int32 askMode= testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ RINOK(extractCallback->PrepareOperation(askMode));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ int folderIndex = m_Database.GetFolderIndex(&mvItem);
+ if (folderIndex < 0)
+ {
+ // If we need previous archive
+ Int32 askMode= testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ RINOK(extractCallback->PrepareOperation(askMode));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kDataError));
+ continue;
+ }
+ int startIndex2 = m_Database.FolderStartFileIndex[folderIndex];
+ int startIndex = startIndex2;
+ extractStatuses.Clear();
+ for (; startIndex < index; startIndex++)
+ extractStatuses.Add(false);
+ extractStatuses.Add(true);
+ startIndex++;
+ UInt64 curUnpack = item.GetEndOffset();
+ for(;i < numItems; i++)
+ {
+ int indexNext = allFilesMode ? i : indices[i];
+ const CMvItem &mvItem = m_Database.Items[indexNext];
+ const CItem &item = m_Database.Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
+ if (item.IsDir())
+ continue;
+ int newFolderIndex = m_Database.GetFolderIndex(&mvItem);
+
+ if (newFolderIndex != folderIndex)
+ break;
+ for (; startIndex < indexNext; startIndex++)
+ extractStatuses.Add(false);
+ extractStatuses.Add(true);
+ startIndex++;
+ curUnpack = item.GetEndOffset();
+ }
+
+ lps->OutSize = totalUnPacked;
+ lps->InSize = totalPacked;
+ RINOK(lps->SetCur());
+
+ CCabFolderOutStream *cabFolderOutStream = new CCabFolderOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(cabFolderOutStream);
+
+ const CFolder &folder = db.Folders[item.GetFolderIndex(db.Folders.Size())];
+
+ cabFolderOutStream->Init(&m_Database, &extractStatuses, startIndex2,
+ curUnpack, extractCallback, testMode);
+
+ cabBlockInStreamSpec->MsZip = false;
+ switch(folder.GetCompressionMethod())
+ {
+ case NHeader::NCompressionMethodMajor::kNone:
+ break;
+ case NHeader::NCompressionMethodMajor::kMSZip:
+ if(deflateDecoderSpec == NULL)
+ {
+ deflateDecoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder;
+ deflateDecoder = deflateDecoderSpec;
+ }
+ cabBlockInStreamSpec->MsZip = true;
+ break;
+ case NHeader::NCompressionMethodMajor::kLZX:
+ if(lzxDecoderSpec == NULL)
+ {
+ lzxDecoderSpec = new NCompress::NLzx::CDecoder;
+ lzxDecoder = lzxDecoderSpec;
+ }
+ RINOK(lzxDecoderSpec->SetParams(folder.CompressionTypeMinor));
+ break;
+ case NHeader::NCompressionMethodMajor::kQuantum:
+ if(quantumDecoderSpec == NULL)
+ {
+ quantumDecoderSpec = new NCompress::NQuantum::CDecoder;
+ quantumDecoder = quantumDecoderSpec;
+ }
+ quantumDecoderSpec->SetParams(folder.CompressionTypeMinor);
+ break;
+ default:
+ {
+ RINOK(cabFolderOutStream->Unsupported());
+ totalUnPacked += curUnpack;
+ continue;
+ }
+ }
+
+ cabBlockInStreamSpec->InitForNewFolder();
+
+ HRESULT res = S_OK;
+
+ {
+ int volIndex = mvItem.VolumeIndex;
+ int locFolderIndex = item.GetFolderIndex(db.Folders.Size());
+ bool keepHistory = false;
+ bool keepInputBuffer = false;
+ for (UInt32 f = 0; cabFolderOutStream->GetRemain() != 0;)
+ {
+ if (volIndex >= m_Database.Volumes.Size())
+ {
+ res = S_FALSE;
+ break;
+ }
+
+ const CDatabaseEx &db = m_Database.Volumes[volIndex];
+ const CFolder &folder = db.Folders[locFolderIndex];
+ if (f == 0)
+ {
+ cabBlockInStreamSpec->SetStream(db.Stream);
+ cabBlockInStreamSpec->ReservedSize = db.ArchiveInfo.GetDataBlockReserveSize();
+ RINOK(db.Stream->Seek(db.StartPosition + folder.DataStart, STREAM_SEEK_SET, NULL));
+ }
+ if (f == folder.NumDataBlocks)
+ {
+ volIndex++;
+ locFolderIndex = 0;
+ f = 0;
+ continue;
+ }
+ f++;
+
+ cabBlockInStreamSpec->DataError = false;
+
+ if (!keepInputBuffer)
+ cabBlockInStreamSpec->InitForNewBlock();
+
+ UInt32 packSize, unpackSize;
+ res = cabBlockInStreamSpec->PreRead(packSize, unpackSize);
+ if (res == S_FALSE)
+ break;
+ RINOK(res);
+ keepInputBuffer = (unpackSize == 0);
+ if (keepInputBuffer)
+ continue;
+
+ UInt64 totalUnPacked2 = totalUnPacked + cabFolderOutStream->GetPosInFolder();
+ totalPacked += packSize;
+
+ lps->OutSize = totalUnPacked2;
+ lps->InSize = totalPacked;
+ RINOK(lps->SetCur());
+
+ UInt64 unpackRemain = cabFolderOutStream->GetRemain();
+
+ const UInt32 kBlockSizeMax = (1 << 15);
+ if (unpackRemain > kBlockSizeMax)
+ unpackRemain = kBlockSizeMax;
+ if (unpackRemain > unpackSize)
+ unpackRemain = unpackSize;
+
+ switch(folder.GetCompressionMethod())
+ {
+ case NHeader::NCompressionMethodMajor::kNone:
+ res = copyCoder->Code(cabBlockInStream, outStream, NULL, &unpackRemain, NULL);
+ break;
+ case NHeader::NCompressionMethodMajor::kMSZip:
+ deflateDecoderSpec->SetKeepHistory(keepHistory);
+ res = deflateDecoder->Code(cabBlockInStream, outStream, NULL, &unpackRemain, NULL);
+ break;
+ case NHeader::NCompressionMethodMajor::kLZX:
+ lzxDecoderSpec->SetKeepHistory(keepHistory);
+ res = lzxDecoder->Code(cabBlockInStream, outStream, NULL, &unpackRemain, NULL);
+ break;
+ case NHeader::NCompressionMethodMajor::kQuantum:
+ quantumDecoderSpec->SetKeepHistory(keepHistory);
+ res = quantumDecoder->Code(cabBlockInStream, outStream, NULL, &unpackRemain, NULL);
+ break;
+ }
+ if (res != S_OK)
+ {
+ if (res != S_FALSE)
+ RINOK(res);
+ break;
+ }
+ keepHistory = true;
+ }
+ if (res == S_OK)
+ {
+ RINOK(cabFolderOutStream->WriteEmptyFiles());
+ }
+ }
+ if (res != S_OK || cabFolderOutStream->GetRemain() != 0)
+ {
+ RINOK(cabFolderOutStream->FlushCorrupted());
+ }
+ totalUnPacked += curUnpack;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = m_Database.Items.Size();
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHandler.h
new file mode 100644
index 000000000..1edcd11e2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHandler.h
@@ -0,0 +1,28 @@
+// CabHandler.h
+
+#ifndef __CAB_HANDLER_H
+#define __CAB_HANDLER_H
+
+#include "Common/MyCom.h"
+#include "../IArchive.h"
+#include "CabIn.h"
+
+namespace NArchive {
+namespace NCab {
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+
+ INTERFACE_IInArchive(;)
+
+private:
+ CMvDatabaseEx m_Database;
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHeader.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHeader.cpp
new file mode 100644
index 000000000..d1f71df30
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHeader.cpp
@@ -0,0 +1,15 @@
+// Archive/Cab/Header.h
+
+#include "StdAfx.h"
+
+#include "CabHeader.h"
+
+namespace NArchive{
+namespace NCab{
+namespace NHeader{
+
+Byte kMarker[kMarkerSize] = {'M' + 1, 'S', 'C', 'F', 0, 0, 0, 0 };
+
+struct SignatureInitializer { SignatureInitializer() { kMarker[0]--; }; } g_SignatureInitializer;
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHeader.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHeader.h
new file mode 100644
index 000000000..0f0d2af35
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabHeader.h
@@ -0,0 +1,44 @@
+// Archive/Cab/Header.h
+
+#ifndef __ARCHIVE_CAB_HEADER_H
+#define __ARCHIVE_CAB_HEADER_H
+
+#include "Common/Types.h"
+
+namespace NArchive {
+namespace NCab {
+namespace NHeader {
+
+const unsigned kMarkerSize = 8;
+extern Byte kMarker[kMarkerSize];
+
+namespace NArchive
+{
+ namespace NFlags
+ {
+ const int kPrevCabinet = 0x0001;
+ const int kNextCabinet = 0x0002;
+ const int kReservePresent = 0x0004;
+ }
+}
+
+namespace NCompressionMethodMajor
+{
+ const Byte kNone = 0;
+ const Byte kMSZip = 1;
+ const Byte kQuantum = 2;
+ const Byte kLZX = 3;
+}
+
+const int kFileNameIsUTFAttributeMask = 0x80;
+
+namespace NFolderIndex
+{
+ const int kContinuedFromPrev = 0xFFFD;
+ const int kContinuedToNext = 0xFFFE;
+ const int kContinuedPrevAndNext = 0xFFFF;
+}
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabIn.cpp
new file mode 100644
index 000000000..afc0faed4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabIn.cpp
@@ -0,0 +1,290 @@
+// Archive/CabIn.cpp
+
+#include "StdAfx.h"
+
+#include "CabIn.h"
+
+#include "../Common/FindSignature.h"
+
+namespace NArchive {
+namespace NCab {
+
+Byte CInArchive::ReadByte()
+{
+ Byte b;
+ if (!inBuffer.ReadByte(b))
+ throw CInArchiveException(CInArchiveException::kUnsupported);
+ return b;
+}
+
+UInt16 CInArchive::ReadUInt16()
+{
+ UInt16 value = 0;
+ for (int i = 0; i < 2; i++)
+ {
+ Byte b = ReadByte();
+ value |= (UInt16(b) << (8 * i));
+ }
+ return value;
+}
+
+UInt32 CInArchive::ReadUInt32()
+{
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ Byte b = ReadByte();
+ value |= (UInt32(b) << (8 * i));
+ }
+ return value;
+}
+
+AString CInArchive::SafeReadName()
+{
+ AString name;
+ for (;;)
+ {
+ Byte b = ReadByte();
+ if (b == 0)
+ return name;
+ name += (char)b;
+ }
+}
+
+void CInArchive::ReadOtherArchive(COtherArchive &oa)
+{
+ oa.FileName = SafeReadName();
+ oa.DiskName = SafeReadName();
+}
+
+void CInArchive::Skip(size_t size)
+{
+ while (size-- != 0)
+ ReadByte();
+}
+
+HRESULT CInArchive::Open2(IInStream *stream,
+ const UInt64 *searchHeaderSizeLimit,
+ CDatabase &database)
+{
+ database.Clear();
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, &database.StartPosition));
+
+ RINOK(FindSignatureInStream(stream, NHeader::kMarker, NHeader::kMarkerSize,
+ searchHeaderSizeLimit, database.StartPosition));
+
+ RINOK(stream->Seek(database.StartPosition + NHeader::kMarkerSize, STREAM_SEEK_SET, NULL));
+ if (!inBuffer.Create(1 << 17))
+ return E_OUTOFMEMORY;
+ inBuffer.SetStream(stream);
+ inBuffer.Init();
+
+ CInArchiveInfo &ai = database.ArchiveInfo;
+
+ ai.Size = ReadUInt32();
+ if (ReadUInt32() != 0)
+ return S_FALSE;
+ ai.FileHeadersOffset = ReadUInt32();
+ if (ReadUInt32() != 0)
+ return S_FALSE;
+
+ ai.VersionMinor = ReadByte();
+ ai.VersionMajor = ReadByte();
+ ai.NumFolders = ReadUInt16();
+ ai.NumFiles = ReadUInt16();
+ ai.Flags = ReadUInt16();
+ if (ai.Flags > 7)
+ return S_FALSE;
+ ai.SetID = ReadUInt16();
+ ai.CabinetNumber = ReadUInt16();
+
+ if (ai.ReserveBlockPresent())
+ {
+ ai.PerCabinetAreaSize = ReadUInt16();
+ ai.PerFolderAreaSize = ReadByte();
+ ai.PerDataBlockAreaSize = ReadByte();
+
+ Skip(ai.PerCabinetAreaSize);
+ }
+
+ {
+ if (ai.IsTherePrev())
+ ReadOtherArchive(ai.PreviousArchive);
+ if (ai.IsThereNext())
+ ReadOtherArchive(ai.NextArchive);
+ }
+
+ int i;
+ for (i = 0; i < ai.NumFolders; i++)
+ {
+ CFolder folder;
+
+ folder.DataStart = ReadUInt32();
+ folder.NumDataBlocks = ReadUInt16();
+ folder.CompressionTypeMajor = ReadByte();
+ folder.CompressionTypeMinor = ReadByte();
+
+ Skip(ai.PerFolderAreaSize);
+ database.Folders.Add(folder);
+ }
+
+ RINOK(stream->Seek(database.StartPosition + ai.FileHeadersOffset, STREAM_SEEK_SET, NULL));
+
+ inBuffer.SetStream(stream);
+ inBuffer.Init();
+ for (i = 0; i < ai.NumFiles; i++)
+ {
+ CItem item;
+ item.Size = ReadUInt32();
+ item.Offset = ReadUInt32();
+ item.FolderIndex = ReadUInt16();
+ UInt16 pureDate = ReadUInt16();
+ UInt16 pureTime = ReadUInt16();
+ item.Time = ((UInt32(pureDate) << 16)) | pureTime;
+ item.Attributes = ReadUInt16();
+ item.Name = SafeReadName();
+ int folderIndex = item.GetFolderIndex(database.Folders.Size());
+ if (folderIndex >= database.Folders.Size())
+ return S_FALSE;
+ database.Items.Add(item);
+ }
+ return S_OK;
+}
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+HRESULT CInArchive::Open(
+ const UInt64 *searchHeaderSizeLimit,
+ CDatabaseEx &database)
+{
+ return Open2(database.Stream, searchHeaderSizeLimit, database);
+}
+
+
+static int CompareMvItems2(const CMvItem *p1, const CMvItem *p2)
+{
+ RINOZ(MyCompare(p1->VolumeIndex, p2->VolumeIndex));
+ return MyCompare(p1->ItemIndex, p2->ItemIndex);
+}
+
+static int CompareMvItems(const CMvItem *p1, const CMvItem *p2, void *param)
+{
+ const CMvDatabaseEx &mvDb = *(const CMvDatabaseEx *)param;
+ const CDatabaseEx &db1 = mvDb.Volumes[p1->VolumeIndex];
+ const CDatabaseEx &db2 = mvDb.Volumes[p2->VolumeIndex];
+ const CItem &item1 = db1.Items[p1->ItemIndex];
+ const CItem &item2 = db2.Items[p2->ItemIndex];;
+ bool isDir1 = item1.IsDir();
+ bool isDir2 = item2.IsDir();
+ if (isDir1 && !isDir2)
+ return -1;
+ if (isDir2 && !isDir1)
+ return 1;
+ int f1 = mvDb.GetFolderIndex(p1);
+ int f2 = mvDb.GetFolderIndex(p2);
+ RINOZ(MyCompare(f1, f2));
+ RINOZ(MyCompare(item1.Offset, item2.Offset));
+ RINOZ(MyCompare(item1.Size, item2.Size));
+ return CompareMvItems2(p1, p2);
+}
+
+bool CMvDatabaseEx::AreItemsEqual(int i1, int i2)
+{
+ const CMvItem *p1 = &Items[i1];
+ const CMvItem *p2 = &Items[i2];
+ const CDatabaseEx &db1 = Volumes[p1->VolumeIndex];
+ const CDatabaseEx &db2 = Volumes[p2->VolumeIndex];
+ const CItem &item1 = db1.Items[p1->ItemIndex];
+ const CItem &item2 = db2.Items[p2->ItemIndex];;
+ return GetFolderIndex(p1) == GetFolderIndex(p2) &&
+ item1.Offset == item2.Offset &&
+ item1.Size == item2.Size &&
+ item1.Name == item2.Name;
+}
+
+void CMvDatabaseEx::FillSortAndShrink()
+{
+ Items.Clear();
+ StartFolderOfVol.Clear();
+ FolderStartFileIndex.Clear();
+ int offset = 0;
+ for (int v = 0; v < Volumes.Size(); v++)
+ {
+ const CDatabaseEx &db = Volumes[v];
+ int curOffset = offset;
+ if (db.IsTherePrevFolder())
+ curOffset--;
+ StartFolderOfVol.Add(curOffset);
+ offset += db.GetNumberOfNewFolders();
+
+ CMvItem mvItem;
+ mvItem.VolumeIndex = v;
+ for (int i = 0 ; i < db.Items.Size(); i++)
+ {
+ mvItem.ItemIndex = i;
+ Items.Add(mvItem);
+ }
+ }
+
+ Items.Sort(CompareMvItems, (void *)this);
+ int j = 1;
+ int i;
+ for (i = 1; i < Items.Size(); i++)
+ if (!AreItemsEqual(i, i -1))
+ Items[j++] = Items[i];
+ Items.DeleteFrom(j);
+
+ for (i = 0; i < Items.Size(); i++)
+ {
+ const CMvItem &mvItem = Items[i];
+ int folderIndex = GetFolderIndex(&mvItem);
+ if (folderIndex >= FolderStartFileIndex.Size())
+ FolderStartFileIndex.Add(i);
+ }
+}
+
+bool CMvDatabaseEx::Check()
+{
+ for (int v = 1; v < Volumes.Size(); v++)
+ {
+ const CDatabaseEx &db1 = Volumes[v];
+ if (db1.IsTherePrevFolder())
+ {
+ const CDatabaseEx &db0 = Volumes[v - 1];
+ if (db0.Folders.IsEmpty() || db1.Folders.IsEmpty())
+ return false;
+ const CFolder &f0 = db0.Folders.Back();
+ const CFolder &f1 = db1.Folders.Front();
+ if (f0.CompressionTypeMajor != f1.CompressionTypeMajor ||
+ f0.CompressionTypeMinor != f1.CompressionTypeMinor)
+ return false;
+ }
+ }
+ UInt64 maxPos = 0;
+ int prevFolder = -2;
+ for (int i = 0; i < Items.Size(); i++)
+ {
+ const CMvItem &mvItem = Items[i];
+ int fIndex = GetFolderIndex(&mvItem);
+ if (fIndex >= FolderStartFileIndex.Size())
+ return false;
+ const CItem &item = Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
+ if (item.IsDir())
+ continue;
+ int folderIndex = GetFolderIndex(&mvItem);
+ if (folderIndex != prevFolder)
+ {
+ prevFolder = folderIndex;
+ maxPos = 0;
+ continue;
+ }
+ if (item.Offset < maxPos)
+ return false;
+ maxPos = item.GetEndOffset();
+ if (maxPos < item.Offset)
+ return false;
+ }
+ return true;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabIn.h
new file mode 100644
index 000000000..c9cfcbdda
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabIn.h
@@ -0,0 +1,166 @@
+// Archive/CabIn.h
+
+#ifndef __ARCHIVE_CAB_IN_H
+#define __ARCHIVE_CAB_IN_H
+
+#include "../../IStream.h"
+#include "../../Common/InBuffer.h"
+#include "CabHeader.h"
+#include "CabItem.h"
+
+namespace NArchive {
+namespace NCab {
+
+class CInArchiveException
+{
+public:
+ enum CCauseType
+ {
+ kUnexpectedEndOfArchive = 0,
+ kIncorrectArchive,
+ kUnsupported
+ } Cause;
+ CInArchiveException(CCauseType cause) : Cause(cause) {}
+};
+
+struct COtherArchive
+{
+ AString FileName;
+ AString DiskName;
+};
+
+struct CArchiveInfo
+{
+ Byte VersionMinor; /* cabinet file format version, minor */
+ Byte VersionMajor; /* cabinet file format version, major */
+ UInt16 NumFolders; /* number of CFFOLDER entries in this cabinet */
+ UInt16 NumFiles; /* number of CFFILE entries in this cabinet */
+ UInt16 Flags; /* cabinet file option indicators */
+ UInt16 SetID; /* must be the same for all cabinets in a set */
+ UInt16 CabinetNumber; /* number of this cabinet file in a set */
+
+ bool ReserveBlockPresent() const { return (Flags & NHeader::NArchive::NFlags::kReservePresent) != 0; }
+
+ bool IsTherePrev() const { return (Flags & NHeader::NArchive::NFlags::kPrevCabinet) != 0; }
+ bool IsThereNext() const { return (Flags & NHeader::NArchive::NFlags::kNextCabinet) != 0; }
+
+ UInt16 PerCabinetAreaSize; // (optional) size of per-cabinet reserved area
+ Byte PerFolderAreaSize; // (optional) size of per-folder reserved area
+ Byte PerDataBlockAreaSize; // (optional) size of per-datablock reserved area
+
+ Byte GetDataBlockReserveSize() const { return (Byte)(ReserveBlockPresent() ? PerDataBlockAreaSize : 0); }
+
+ COtherArchive PreviousArchive;
+ COtherArchive NextArchive;
+
+ CArchiveInfo()
+ {
+ Clear();
+ }
+
+ void Clear()
+ {
+ PerCabinetAreaSize = 0;
+ PerFolderAreaSize = 0;
+ PerDataBlockAreaSize = 0;
+ }
+};
+
+struct CInArchiveInfo: public CArchiveInfo
+{
+ UInt32 Size; /* size of this cabinet file in bytes */
+ UInt32 FileHeadersOffset; // offset of the first CFFILE entry
+};
+
+
+class CDatabase
+{
+public:
+ UInt64 StartPosition;
+ CInArchiveInfo ArchiveInfo;
+ CObjectVector<CFolder> Folders;
+ CObjectVector<CItem> Items;
+ void Clear()
+ {
+ ArchiveInfo.Clear();
+ Folders.Clear();
+ Items.Clear();
+ }
+ bool IsTherePrevFolder() const
+ {
+ for (int i = 0; i < Items.Size(); i++)
+ if (Items[i].ContinuedFromPrev())
+ return true;
+ return false;
+ }
+ int GetNumberOfNewFolders() const
+ {
+ int res = Folders.Size();
+ if (IsTherePrevFolder())
+ res--;
+ return res;
+ }
+ UInt32 GetFileOffset(int index) const { return Items[index].Offset; }
+ UInt32 GetFileSize(int index) const { return Items[index].Size; }
+};
+
+class CDatabaseEx: public CDatabase
+{
+public:
+ CMyComPtr<IInStream> Stream;
+};
+
+struct CMvItem
+{
+ int VolumeIndex;
+ int ItemIndex;
+};
+
+class CMvDatabaseEx
+{
+ bool AreItemsEqual(int i1, int i2);
+public:
+ CObjectVector<CDatabaseEx> Volumes;
+ CRecordVector<CMvItem> Items;
+ CRecordVector<int> StartFolderOfVol;
+ CRecordVector<int> FolderStartFileIndex;
+ int GetFolderIndex(const CMvItem *mvi) const
+ {
+ const CDatabaseEx &db = Volumes[mvi->VolumeIndex];
+ return StartFolderOfVol[mvi->VolumeIndex] +
+ db.Items[mvi->ItemIndex].GetFolderIndex(db.Folders.Size());
+ }
+ void Clear()
+ {
+ Volumes.Clear();
+ Items.Clear();
+ StartFolderOfVol.Clear();
+ FolderStartFileIndex.Clear();
+ }
+ void FillSortAndShrink();
+ bool Check();
+};
+
+class CInArchive
+{
+ CInBuffer inBuffer;
+
+ Byte ReadByte();
+ UInt16 ReadUInt16();
+ UInt32 ReadUInt32();
+ AString SafeReadName();
+ void Skip(size_t size);
+ void ReadOtherArchive(COtherArchive &oa);
+
+ HRESULT Open2(IInStream *inStream,
+ const UInt64 *searchHeaderSizeLimit,
+ CDatabase &database);
+public:
+ HRESULT Open(
+ const UInt64 *searchHeaderSizeLimit,
+ CDatabaseEx &database);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabItem.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabItem.h
new file mode 100644
index 000000000..63a1e856c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabItem.h
@@ -0,0 +1,63 @@
+// Archive/CabItem.h
+
+#ifndef __ARCHIVE_CAB_ITEM_H
+#define __ARCHIVE_CAB_ITEM_H
+
+#include "Common/Types.h"
+#include "Common/MyString.h"
+#include "CabHeader.h"
+
+namespace NArchive {
+namespace NCab {
+
+struct CFolder
+{
+ UInt32 DataStart; // offset of the first CFDATA block in this folder
+ UInt16 NumDataBlocks; // number of CFDATA blocks in this folder
+ Byte CompressionTypeMajor;
+ Byte CompressionTypeMinor;
+ Byte GetCompressionMethod() const { return (Byte)(CompressionTypeMajor & 0xF); }
+};
+
+struct CItem
+{
+ AString Name;
+ UInt32 Offset;
+ UInt32 Size;
+ UInt32 Time;
+ UInt16 FolderIndex;
+ UInt16 Flags;
+ UInt16 Attributes;
+
+ UInt64 GetEndOffset() const { return (UInt64)Offset + Size; }
+ UInt32 GetWinAttributes() const { return (Attributes & ~NHeader::kFileNameIsUTFAttributeMask); }
+ bool IsNameUTF() const { return (Attributes & NHeader::kFileNameIsUTFAttributeMask) != 0; }
+ bool IsDir() const { return (Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }
+
+ bool ContinuedFromPrev() const
+ {
+ return
+ (FolderIndex == NHeader::NFolderIndex::kContinuedFromPrev) ||
+ (FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext);
+ }
+
+ bool ContinuedToNext() const
+ {
+ return
+ (FolderIndex == NHeader::NFolderIndex::kContinuedToNext) ||
+ (FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext);
+ }
+
+ int GetFolderIndex(int numFolders) const
+ {
+ if (ContinuedFromPrev())
+ return 0;
+ if (ContinuedToNext())
+ return (numFolders - 1);
+ return FolderIndex;
+ }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabRegister.cpp
new file mode 100644
index 000000000..0ce8a87fb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Cab/CabRegister.cpp
@@ -0,0 +1,13 @@
+// CabRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "CabHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NCab::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Cab", L"cab", 0, 8, { 0x4D, 0x53, 0x43, 0x46 }, 4, false, CreateArc, 0 };
+
+REGISTER_ARC(Cab)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHandler.cpp
new file mode 100644
index 000000000..03bff8218
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHandler.cpp
@@ -0,0 +1,721 @@
+// ChmHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/Defs.h"
+#include "Common/StringConvert.h"
+#include "Common/UTFConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
+#include "../../Common/StreamUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+#include "../../Compress/LzxDecoder.h"
+
+#include "../Common/ItemNameUtils.h"
+
+#include "ChmHandler.h"
+
+using namespace NWindows;
+using namespace NTime;
+
+namespace NArchive {
+namespace NChm {
+
+// #define _CHM_DETAILS
+
+#ifdef _CHM_DETAILS
+
+enum
+{
+ kpidSection = kpidUserDefined
+};
+
+#endif
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidBlock, VT_UI4}
+
+ #ifdef _CHM_DETAILS
+ ,
+ { L"Section", kpidSection, VT_UI4},
+ { NULL, kpidOffset, VT_UI4}
+ #endif
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidNumBlocks, VT_UI8}
+};
+
+IMP_IInArchive_Props
+
+IMP_IInArchive_ArcProps_NO
+/*
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidNumBlocks:
+ {
+ UInt64 numBlocks = 0;
+ for (int i = 0; i < m_Database.Sections.Size(); i++)
+ {
+ const CSectionInfo &s = m_Database.Sections[i];
+ for (int j = 0; j < s.Methods.Size(); j++)
+ {
+ const CMethodInfo &m = s.Methods[j];
+ if (m.IsLzx())
+ numBlocks += m.LzxInfo.ResetTable.GetNumBlocks();
+ }
+ }
+ prop = numBlocks;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+*/
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ if (m_Database.NewFormat)
+ {
+ switch(propID)
+ {
+ case kpidSize:
+ prop = (UInt64)m_Database.NewFormatString.Length();
+ break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ }
+ int entryIndex;
+ if (m_Database.LowLevel)
+ entryIndex = index;
+ else
+ entryIndex = m_Database.Indices[index];
+ const CItem &item = m_Database.Items[entryIndex];
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ UString us;
+ if (ConvertUTF8ToUnicode(item.Name, us))
+ {
+ if (!m_Database.LowLevel)
+ {
+ if (us.Length() > 1)
+ if (us[0] == L'/')
+ us.Delete(0);
+ }
+ prop = NItemName::GetOSName2(us);
+ }
+ break;
+ }
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidMethod:
+ {
+ if (!item.IsDir())
+ if (item.Section == 0)
+ prop = L"Copy";
+ else if (item.Section < m_Database.Sections.Size())
+ prop = m_Database.Sections[(int)item.Section].GetMethodName();
+ break;
+ }
+ case kpidBlock:
+ if (m_Database.LowLevel)
+ prop = item.Section;
+ else if (item.Section != 0)
+ prop = m_Database.GetFolder(index);
+ break;
+
+ #ifdef _CHM_DETAILS
+
+ case kpidSection: prop = (UInt32)item.Section; break;
+ case kpidOffset: prop = (UInt32)item.Offset; break;
+
+ #endif
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CProgressImp: public CProgressVirt
+{
+ CMyComPtr<IArchiveOpenCallback> _callback;
+public:
+ STDMETHOD(SetTotal)(const UInt64 *numFiles);
+ STDMETHOD(SetCompleted)(const UInt64 *numFiles);
+ CProgressImp(IArchiveOpenCallback *callback): _callback(callback) {};
+};
+
+STDMETHODIMP CProgressImp::SetTotal(const UInt64 *numFiles)
+{
+ if (_callback)
+ return _callback->SetCompleted(numFiles, NULL);
+ return S_OK;
+}
+
+STDMETHODIMP CProgressImp::SetCompleted(const UInt64 *numFiles)
+{
+ if (_callback)
+ return _callback->SetCompleted(numFiles, NULL);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ m_Stream.Release();
+ try
+ {
+ CInArchive archive;
+ // CProgressImp progressImp(openArchiveCallback);
+ RINOK(archive.Open(inStream, maxCheckStartPosition, m_Database));
+ /*
+ if (m_Database.LowLevel)
+ return S_FALSE;
+ */
+ m_Stream = inStream;
+ }
+ catch(...)
+ {
+ return S_FALSE;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ m_Database.Clear();
+ m_Stream.Release();
+ return S_OK;
+}
+
+class CChmFolderOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+
+ HRESULT Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK);
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+
+ UInt64 m_FolderSize;
+ UInt64 m_PosInFolder;
+ UInt64 m_PosInSection;
+ const CRecordVector<bool> *m_ExtractStatuses;
+ int m_StartIndex;
+ int m_CurrentIndex;
+ int m_NumFiles;
+
+private:
+ const CFilesDatabase *m_Database;
+ CMyComPtr<IArchiveExtractCallback> m_ExtractCallback;
+ bool m_TestMode;
+
+ bool m_IsOk;
+ bool m_FileIsOpen;
+ UInt64 m_RemainFileSize;
+ CMyComPtr<ISequentialOutStream> m_RealOutStream;
+
+ HRESULT OpenFile();
+ HRESULT WriteEmptyFiles();
+public:
+ void Init(
+ const CFilesDatabase *database,
+ IArchiveExtractCallback *extractCallback,
+ bool testMode);
+ HRESULT FlushCorrupted(UInt64 maxSize);
+};
+
+void CChmFolderOutStream::Init(
+ const CFilesDatabase *database,
+ IArchiveExtractCallback *extractCallback,
+ bool testMode)
+{
+ m_Database = database;
+ m_ExtractCallback = extractCallback;
+ m_TestMode = testMode;
+
+ m_CurrentIndex = 0;
+ m_FileIsOpen = false;
+}
+
+HRESULT CChmFolderOutStream::OpenFile()
+{
+ Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ?
+ NExtract::NAskMode::kTest :
+ NExtract::NAskMode::kExtract) :
+ NExtract::NAskMode::kSkip;
+ m_RealOutStream.Release();
+ RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &m_RealOutStream, askMode));
+ if (!m_RealOutStream && !m_TestMode)
+ askMode = NArchive::NExtract::NAskMode::kSkip;
+ return m_ExtractCallback->PrepareOperation(askMode);
+}
+
+HRESULT CChmFolderOutStream::WriteEmptyFiles()
+{
+ if (m_FileIsOpen)
+ return S_OK;
+ for (;m_CurrentIndex < m_NumFiles; m_CurrentIndex++)
+ {
+ UInt64 fileSize = m_Database->GetFileSize(m_StartIndex + m_CurrentIndex);
+ if (fileSize != 0)
+ return S_OK;
+ HRESULT result = OpenFile();
+ m_RealOutStream.Release();
+ RINOK(result);
+ RINOK(m_ExtractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ }
+ return S_OK;
+}
+
+// This is WritePart function
+HRESULT CChmFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK)
+{
+ UInt32 realProcessed = 0;
+ if (processedSize != NULL)
+ *processedSize = 0;
+ while(size != 0)
+ {
+ if (m_FileIsOpen)
+ {
+ UInt32 numBytesToWrite = (UInt32)MyMin(m_RemainFileSize, (UInt64)(size));
+ HRESULT res = S_OK;
+ if (numBytesToWrite > 0)
+ {
+ if (!isOK)
+ m_IsOk = false;
+ if (m_RealOutStream)
+ {
+ UInt32 processedSizeLocal = 0;
+ res = m_RealOutStream->Write((const Byte *)data, numBytesToWrite, &processedSizeLocal);
+ numBytesToWrite = processedSizeLocal;
+ }
+ }
+ realProcessed += numBytesToWrite;
+ if (processedSize != NULL)
+ *processedSize = realProcessed;
+ data = (const void *)((const Byte *)data + numBytesToWrite);
+ size -= numBytesToWrite;
+ m_RemainFileSize -= numBytesToWrite;
+ m_PosInSection += numBytesToWrite;
+ m_PosInFolder += numBytesToWrite;
+ if (res != S_OK)
+ return res;
+ if (m_RemainFileSize == 0)
+ {
+ m_RealOutStream.Release();
+ RINOK(m_ExtractCallback->SetOperationResult(
+ m_IsOk ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ m_FileIsOpen = false;
+ }
+ if (realProcessed > 0)
+ break; // with this break this function works as write part
+ }
+ else
+ {
+ if (m_CurrentIndex >= m_NumFiles)
+ return E_FAIL;
+ int fullIndex = m_StartIndex + m_CurrentIndex;
+ m_RemainFileSize = m_Database->GetFileSize(fullIndex);
+ UInt64 fileOffset = m_Database->GetFileOffset(fullIndex);
+ if (fileOffset < m_PosInSection)
+ return E_FAIL;
+ if (fileOffset > m_PosInSection)
+ {
+ UInt32 numBytesToWrite = (UInt32)MyMin(fileOffset - m_PosInSection, UInt64(size));
+ realProcessed += numBytesToWrite;
+ if (processedSize != NULL)
+ *processedSize = realProcessed;
+ data = (const void *)((const Byte *)data + numBytesToWrite);
+ size -= numBytesToWrite;
+ m_PosInSection += numBytesToWrite;
+ m_PosInFolder += numBytesToWrite;
+ }
+ if (fileOffset == m_PosInSection)
+ {
+ RINOK(OpenFile());
+ m_FileIsOpen = true;
+ m_CurrentIndex++;
+ m_IsOk = true;
+ }
+ }
+ }
+ return WriteEmptyFiles();
+}
+
+STDMETHODIMP CChmFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ return Write2(data, size, processedSize, true);
+}
+
+HRESULT CChmFolderOutStream::FlushCorrupted(UInt64 maxSize)
+{
+ const UInt32 kBufferSize = (1 << 10);
+ Byte buffer[kBufferSize];
+ for (int i = 0; i < kBufferSize; i++)
+ buffer[i] = 0;
+ if (maxSize > m_FolderSize)
+ maxSize = m_FolderSize;
+ while (m_PosInFolder < maxSize)
+ {
+ UInt32 size = (UInt32)MyMin(maxSize - m_PosInFolder, (UInt64)kBufferSize);
+ UInt32 processedSizeLocal = 0;
+ RINOK(Write2(buffer, size, &processedSizeLocal, false));
+ if (processedSizeLocal == 0)
+ return S_OK;
+ }
+ return S_OK;
+}
+
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == UInt32(-1));
+
+ if (allFilesMode)
+ numItems = m_Database.NewFormat ? 1:
+ (m_Database.LowLevel ?
+ m_Database.Items.Size():
+ m_Database.Indices.Size());
+ if (numItems == 0)
+ return S_OK;
+ bool testMode = (_aTestMode != 0);
+
+ UInt64 currentTotalSize = 0;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+ UInt32 i;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(m_Stream);
+
+ if (m_Database.LowLevel)
+ {
+ UInt64 currentItemSize = 0;
+ UInt64 totalSize = 0;
+ if (m_Database.NewFormat)
+ totalSize = m_Database.NewFormatString.Length();
+ else
+ for (i = 0; i < numItems; i++)
+ totalSize += m_Database.Items[allFilesMode ? i : indices[i]].Size;
+ extractCallback->SetTotal(totalSize);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ currentItemSize = 0;
+ lps->InSize = currentTotalSize; // Change it
+ lps->OutSize = currentTotalSize;
+
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode= testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (m_Database.NewFormat)
+ {
+ if (index != 0)
+ return E_FAIL;
+ if (!testMode && (!realOutStream))
+ continue;
+ if (!testMode)
+ {
+ UInt32 size = m_Database.NewFormatString.Length();
+ RINOK(WriteStream(realOutStream, (const char *)m_Database.NewFormatString, size));
+ }
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ const CItem &item = m_Database.Items[index];
+
+ currentItemSize = item.Size;
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ if (item.Section != 0)
+ {
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ continue;
+ }
+
+ if (testMode)
+ {
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+
+ RINOK(m_Stream->Seek(m_Database.ContentOffset + item.Offset, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(item.Size);
+
+ RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ }
+
+ UInt64 lastFolderIndex = ((UInt64)0 - 1);
+ for (i = 0; i < numItems; i++)
+ {
+ UInt32 index = allFilesMode ? i : indices[i];
+ int entryIndex = m_Database.Indices[index];
+ const CItem &item = m_Database.Items[entryIndex];
+ UInt64 sectionIndex = item.Section;
+ if (item.IsDir() || item.Size == 0)
+ continue;
+ if (sectionIndex == 0)
+ {
+ currentTotalSize += item.Size;
+ continue;
+ }
+ const CSectionInfo &section = m_Database.Sections[(int)item.Section];
+ if (section.IsLzx())
+ {
+ const CLzxInfo &lzxInfo = section.Methods[0].LzxInfo;
+ UInt64 folderIndex = m_Database.GetFolder(index);
+ if (lastFolderIndex == folderIndex)
+ folderIndex++;
+ lastFolderIndex = m_Database.GetLastFolder(index);
+ for (; folderIndex <= lastFolderIndex; folderIndex++)
+ currentTotalSize += lzxInfo.GetFolderSize();
+ }
+ }
+
+ RINOK(extractCallback->SetTotal(currentTotalSize));
+
+ NCompress::NLzx::CDecoder *lzxDecoderSpec = 0;
+ CMyComPtr<ICompressCoder> lzxDecoder;
+ CChmFolderOutStream *chmFolderOutStream = 0;
+ CMyComPtr<ISequentialOutStream> outStream;
+
+ currentTotalSize = 0;
+
+ CRecordVector<bool> extractStatuses;
+ for (i = 0; i < numItems;)
+ {
+ RINOK(extractCallback->SetCompleted(&currentTotalSize));
+ UInt32 index = allFilesMode ? i : indices[i];
+ i++;
+ int entryIndex = m_Database.Indices[index];
+ const CItem &item = m_Database.Items[entryIndex];
+ UInt64 sectionIndex = item.Section;
+ Int32 askMode= testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ if (item.IsDir())
+ {
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ RINOK(extractCallback->PrepareOperation(askMode));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+
+ lps->InSize = currentTotalSize; // Change it
+ lps->OutSize = currentTotalSize;
+
+ if (item.Size == 0 || sectionIndex == 0)
+ {
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ Int32 opRes = NArchive::NExtract::NOperationResult::kOK;
+ if (!testMode && item.Size != 0)
+ {
+ RINOK(m_Stream->Seek(m_Database.ContentOffset + item.Offset, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(item.Size);
+ RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
+ if (copyCoderSpec->TotalSize != item.Size)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ }
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ currentTotalSize += item.Size;
+ continue;
+ }
+
+ const CSectionInfo &section = m_Database.Sections[(int)sectionIndex];
+
+ if (!section.IsLzx())
+ {
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ if(!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ continue;
+ }
+
+ const CLzxInfo &lzxInfo = section.Methods[0].LzxInfo;
+
+ if (chmFolderOutStream == 0)
+ {
+ chmFolderOutStream = new CChmFolderOutStream;
+ outStream = chmFolderOutStream;
+ }
+
+ chmFolderOutStream->Init(&m_Database, extractCallback, testMode);
+
+ if(lzxDecoderSpec == NULL)
+ {
+ lzxDecoderSpec = new NCompress::NLzx::CDecoder;
+ lzxDecoder = lzxDecoderSpec;
+ }
+
+ UInt64 folderIndex = m_Database.GetFolder(index);
+
+ UInt64 compressedPos = m_Database.ContentOffset + section.Offset;
+ UInt32 numDictBits = lzxInfo.GetNumDictBits();
+ RINOK(lzxDecoderSpec->SetParams(numDictBits));
+
+ const CItem *lastItem = &item;
+ extractStatuses.Clear();
+ extractStatuses.Add(true);
+
+ for (;; folderIndex++)
+ {
+ RINOK(extractCallback->SetCompleted(&currentTotalSize));
+
+ UInt64 startPos = lzxInfo.GetFolderPos(folderIndex);
+ UInt64 finishPos = lastItem->Offset + lastItem->Size;
+ UInt64 limitFolderIndex = lzxInfo.GetFolder(finishPos);
+
+ lastFolderIndex = m_Database.GetLastFolder(index);
+ UInt64 folderSize = lzxInfo.GetFolderSize();
+ UInt64 unPackSize = folderSize;
+ if (extractStatuses.IsEmpty())
+ chmFolderOutStream->m_StartIndex = index + 1;
+ else
+ chmFolderOutStream->m_StartIndex = index;
+ if (limitFolderIndex == folderIndex)
+ {
+ for (; i < numItems; i++)
+ {
+ UInt32 nextIndex = allFilesMode ? i : indices[i];
+ int entryIndex = m_Database.Indices[nextIndex];
+ const CItem &nextItem = m_Database.Items[entryIndex];
+ if (nextItem.Section != sectionIndex)
+ break;
+ UInt64 nextFolderIndex = m_Database.GetFolder(nextIndex);
+ if (nextFolderIndex != folderIndex)
+ break;
+ for (index++; index < nextIndex; index++)
+ extractStatuses.Add(false);
+ extractStatuses.Add(true);
+ index = nextIndex;
+ lastItem = &nextItem;
+ if (nextItem.Size != 0)
+ finishPos = nextItem.Offset + nextItem.Size;
+ lastFolderIndex = m_Database.GetLastFolder(index);
+ }
+ }
+ unPackSize = MyMin(finishPos - startPos, unPackSize);
+
+ chmFolderOutStream->m_FolderSize = folderSize;
+ chmFolderOutStream->m_PosInFolder = 0;
+ chmFolderOutStream->m_PosInSection = startPos;
+ chmFolderOutStream->m_ExtractStatuses = &extractStatuses;
+ chmFolderOutStream->m_NumFiles = extractStatuses.Size();
+ chmFolderOutStream->m_CurrentIndex = 0;
+ try
+ {
+ UInt64 startBlock = lzxInfo.GetBlockIndexFromFolderIndex(folderIndex);
+ const CResetTable &rt = lzxInfo.ResetTable;
+ UInt32 numBlocks = (UInt32)rt.GetNumBlocks(unPackSize);
+ for (UInt32 b = 0; b < numBlocks; b++)
+ {
+ UInt64 completedSize = currentTotalSize + chmFolderOutStream->m_PosInSection - startPos;
+ RINOK(extractCallback->SetCompleted(&completedSize));
+ UInt64 bCur = startBlock + b;
+ if (bCur >= rt.ResetOffsets.Size())
+ return E_FAIL;
+ UInt64 offset = rt.ResetOffsets[(int)bCur];
+ UInt64 compressedSize;
+ rt.GetCompressedSizeOfBlock(bCur, compressedSize);
+ UInt64 rem = finishPos - chmFolderOutStream->m_PosInSection;
+ if (rem > rt.BlockSize)
+ rem = rt.BlockSize;
+ RINOK(m_Stream->Seek(compressedPos + offset, STREAM_SEEK_SET, NULL));
+ streamSpec->SetStream(m_Stream);
+ streamSpec->Init(compressedSize);
+ lzxDecoderSpec->SetKeepHistory(b > 0);
+ HRESULT res = lzxDecoder->Code(inStream, outStream, NULL, &rem, NULL);
+ if (res != S_OK)
+ {
+ if (res != S_FALSE)
+ return res;
+ throw 1;
+ }
+ }
+ }
+ catch(...)
+ {
+ RINOK(chmFolderOutStream->FlushCorrupted(unPackSize));
+ }
+ currentTotalSize += folderSize;
+ if (folderIndex == lastFolderIndex)
+ break;
+ extractStatuses.Clear();
+ }
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = m_Database.NewFormat ? 1:
+ (m_Database.LowLevel ?
+ m_Database.Items.Size():
+ m_Database.Indices.Size());
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHandler.h
new file mode 100644
index 000000000..440c50f11
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHandler.h
@@ -0,0 +1,29 @@
+// ChmHandler.h
+
+#ifndef __ARCHIVE_CHM_HANDLER_H
+#define __ARCHIVE_CHM_HANDLER_H
+
+#include "Common/MyCom.h"
+#include "../IArchive.h"
+#include "ChmIn.h"
+
+namespace NArchive {
+namespace NChm {
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+
+ INTERFACE_IInArchive(;)
+
+private:
+ CFilesDatabase m_Database;
+ CMyComPtr<IInStream> m_Stream;
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHeader.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHeader.cpp
new file mode 100644
index 000000000..e8dc9f3e8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHeader.cpp
@@ -0,0 +1,24 @@
+// Archive/Chm/Header.h
+
+#include "StdAfx.h"
+
+#include "ChmHeader.h"
+
+namespace NArchive{
+namespace NChm{
+namespace NHeader{
+
+UInt32 kItsfSignature = 0x46535449 + 1;
+UInt32 kItolSignature = 0x4C4F5449 + 1;
+static class CSignatureInitializer
+{
+public:
+ CSignatureInitializer()
+ {
+ kItsfSignature--;
+ kItolSignature--;
+ }
+}g_SignatureInitializer;
+
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHeader.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHeader.h
new file mode 100644
index 000000000..9f1bd42b6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmHeader.h
@@ -0,0 +1,28 @@
+// Archive/Chm/Header.h
+
+#ifndef __ARCHIVE_CHM_HEADER_H
+#define __ARCHIVE_CHM_HEADER_H
+
+#include "Common/Types.h"
+
+namespace NArchive {
+namespace NChm {
+namespace NHeader{
+
+const UInt32 kItspSignature = 0x50535449;
+const UInt32 kPmglSignature = 0x4C474D50;
+const UInt32 kLzxcSignature = 0x43585A4C;
+
+const UInt32 kIfcmSignature = 0x4D434649;
+const UInt32 kAollSignature = 0x4C4C4F41;
+const UInt32 kCaolSignature = 0x4C4F4143;
+
+extern UInt32 kItsfSignature;
+
+extern UInt32 kItolSignature;
+const UInt32 kItlsSignature = 0x534C5449;
+UInt64 inline GetHxsSignature() { return ((UInt64)kItlsSignature << 32) | kItolSignature; }
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmIn.cpp
new file mode 100644
index 000000000..cc571937e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmIn.cpp
@@ -0,0 +1,940 @@
+// Archive/ChmIn.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/UTFConvert.h"
+
+#include "../../Common/LimitedStreams.h"
+
+#include "ChmIn.h"
+
+namespace NArchive{
+namespace NChm{
+
+// define CHM_LOW, if you want to see low level items
+// #define CHM_LOW
+
+static const GUID kChmLzxGuid =
+ { 0x7FC28940, 0x9D31, 0x11D0, 0x9B, 0x27, 0x00, 0xA0, 0xC9, 0x1E, 0x9C, 0x7C };
+static const GUID kHelp2LzxGuid =
+ { 0x0A9007C6, 0x4076, 0x11D3, 0x87, 0x89, 0x00, 0x00, 0xF8, 0x10, 0x57, 0x54 };
+static const GUID kDesGuid =
+ { 0x67F6E4A2, 0x60BF, 0x11D3, 0x85, 0x40, 0x00, 0xC0, 0x4F, 0x58, 0xC3, 0xCF };
+
+static bool AreGuidsEqual(REFGUID g1, REFGUID g2)
+{
+ if (g1.Data1 != g2.Data1 ||
+ g1.Data2 != g2.Data2 ||
+ g1.Data3 != g2.Data3)
+ return false;
+ for (int i = 0; i < 8; i++)
+ if (g1.Data4[i] != g2.Data4[i])
+ return false;
+ return true;
+}
+
+static char GetHex(Byte value)
+{
+ return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
+}
+
+static void PrintByte(Byte b, AString &s)
+{
+ s += GetHex(b >> 4);
+ s += GetHex(b & 0xF);
+}
+
+static void PrintUInt16(UInt16 v, AString &s)
+{
+ PrintByte((Byte)(v >> 8), s);
+ PrintByte((Byte)v, s);
+}
+
+static void PrintUInt32(UInt32 v, AString &s)
+{
+ PrintUInt16((UInt16)(v >> 16), s);
+ PrintUInt16((UInt16)v, s);
+}
+
+AString CMethodInfo::GetGuidString() const
+{
+ AString s;
+ s += '{';
+ PrintUInt32(Guid.Data1, s);
+ s += '-';
+ PrintUInt16(Guid.Data2, s);
+ s += '-';
+ PrintUInt16(Guid.Data3, s);
+ s += '-';
+ PrintByte(Guid.Data4[0], s);
+ PrintByte(Guid.Data4[1], s);
+ s += '-';
+ for (int i = 2; i < 8; i++)
+ PrintByte(Guid.Data4[i], s);
+ s += '}';
+ return s;
+}
+
+bool CMethodInfo::IsLzx() const
+{
+ if (AreGuidsEqual(Guid, kChmLzxGuid))
+ return true;
+ return AreGuidsEqual(Guid, kHelp2LzxGuid);
+}
+
+bool CMethodInfo::IsDes() const
+{
+ return AreGuidsEqual(Guid, kDesGuid);
+}
+
+UString CMethodInfo::GetName() const
+{
+ UString s;
+ if (IsLzx())
+ {
+ s = L"LZX:";
+ wchar_t temp[16];
+ ConvertUInt32ToString(LzxInfo.GetNumDictBits(), temp);
+ s += temp;
+ }
+ else
+ {
+ AString s2;
+ if (IsDes())
+ s2 = "DES";
+ else
+ {
+ s2 = GetGuidString();
+ if (ControlData.GetCapacity() > 0)
+ {
+ s2 += ':';
+ for (size_t i = 0; i < ControlData.GetCapacity(); i++)
+ PrintByte(ControlData[i], s2);
+ }
+ }
+ ConvertUTF8ToUnicode(s2, s);
+ }
+ return s;
+}
+
+bool CSectionInfo::IsLzx() const
+{
+ if (Methods.Size() != 1)
+ return false;
+ return Methods[0].IsLzx();
+}
+
+UString CSectionInfo::GetMethodName() const
+{
+ UString s;
+ if (!IsLzx())
+ {
+ UString temp;
+ if (ConvertUTF8ToUnicode(Name, temp))
+ s += temp;
+ s += L": ";
+ }
+ for (int i = 0; i < Methods.Size(); i++)
+ {
+ if (i != 0)
+ s += L' ';
+ s += Methods[i].GetName();
+ }
+ return s;
+}
+
+Byte CInArchive::ReadByte()
+{
+ Byte b;
+ if (!_inBuffer.ReadByte(b))
+ throw 1;
+ return b;
+}
+
+void CInArchive::Skip(size_t size)
+{
+ while (size-- != 0)
+ ReadByte();
+}
+
+void CInArchive::ReadBytes(Byte *data, UInt32 size)
+{
+ for (UInt32 i = 0; i < size; i++)
+ data[i] = ReadByte();
+}
+
+UInt16 CInArchive::ReadUInt16()
+{
+ UInt16 value = 0;
+ for (int i = 0; i < 2; i++)
+ value |= ((UInt16)(ReadByte()) << (8 * i));
+ return value;
+}
+
+UInt32 CInArchive::ReadUInt32()
+{
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ value |= ((UInt32)(ReadByte()) << (8 * i));
+ return value;
+}
+
+UInt64 CInArchive::ReadUInt64()
+{
+ UInt64 value = 0;
+ for (int i = 0; i < 8; i++)
+ value |= ((UInt64)(ReadByte()) << (8 * i));
+ return value;
+}
+
+UInt64 CInArchive::ReadEncInt()
+{
+ UInt64 val = 0;;
+ for (int i = 0; i < 10; i++)
+ {
+ Byte b = ReadByte();
+ val |= (b & 0x7F);
+ if (b < 0x80)
+ return val;
+ val <<= 7;
+ }
+ throw 1;
+}
+
+void CInArchive::ReadGUID(GUID &g)
+{
+ g.Data1 = ReadUInt32();
+ g.Data2 = ReadUInt16();
+ g.Data3 = ReadUInt16();
+ ReadBytes(g.Data4, 8);
+}
+
+void CInArchive::ReadString(int size, AString &s)
+{
+ s.Empty();
+ while(size-- != 0)
+ {
+ char c = (char)ReadByte();
+ if (c == 0)
+ {
+ Skip(size);
+ return;
+ }
+ s += c;
+ }
+}
+
+void CInArchive::ReadUString(int size, UString &s)
+{
+ s.Empty();
+ while(size-- != 0)
+ {
+ wchar_t c = ReadUInt16();
+ if (c == 0)
+ {
+ Skip(2 * size);
+ return;
+ }
+ s += c;
+ }
+}
+
+HRESULT CInArchive::ReadChunk(IInStream *inStream, UInt64 pos, UInt64 size)
+{
+ RINOK(inStream->Seek(pos, STREAM_SEEK_SET, NULL));
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> limitedStream(streamSpec);
+ streamSpec->SetStream(inStream);
+ streamSpec->Init(size);
+ _inBuffer.SetStream(limitedStream);
+ _inBuffer.Init();
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadDirEntry(CDatabase &database)
+{
+ CItem item;
+ UInt64 nameLength = ReadEncInt();
+ if (nameLength == 0 || nameLength >= 0x10000000)
+ return S_FALSE;
+ ReadString((int)nameLength, item.Name);
+ item.Section = ReadEncInt();
+ item.Offset = ReadEncInt();
+ item.Size = ReadEncInt();
+ database.Items.Add(item);
+ return S_OK;
+}
+
+HRESULT CInArchive::OpenChm(IInStream *inStream, CDatabase &database)
+{
+ UInt32 headerSize = ReadUInt32();
+ if (headerSize != 0x60)
+ return S_FALSE;
+ UInt32 unknown1 = ReadUInt32();
+ if (unknown1 != 0 && unknown1 != 1) // it's 0 in one .sll file
+ return S_FALSE;
+ /* UInt32 timeStamp = */ ReadUInt32();
+ // Considered as a big-endian DWORD, it appears to contain seconds (MSB) and
+ // fractional seconds (second byte).
+ // The third and fourth bytes may contain even more fractional bits.
+ // The 4 least significant bits in the last byte are constant.
+ /* UInt32 lang = */ ReadUInt32();
+ GUID g;
+ ReadGUID(g); // {7C01FD10-7BAA-11D0-9E0C-00A0-C922-E6EC}
+ ReadGUID(g); // {7C01FD11-7BAA-11D0-9E0C-00A0-C922-E6EC}
+ const int kNumSections = 2;
+ UInt64 sectionOffsets[kNumSections];
+ UInt64 sectionSizes[kNumSections];
+ int i;
+ for (i = 0; i < kNumSections; i++)
+ {
+ sectionOffsets[i] = ReadUInt64();
+ sectionSizes[i] = ReadUInt64();
+ }
+ // if (chmVersion == 3)
+ database.ContentOffset = ReadUInt64();
+ /*
+ else
+ database.ContentOffset = _startPosition + 0x58
+ */
+
+ /*
+ // Section 0
+ ReadChunk(inStream, sectionOffsets[0], sectionSizes[0]);
+ if (sectionSizes[0] != 0x18)
+ return S_FALSE;
+ ReadUInt32(); // unknown: 01FE
+ ReadUInt32(); // unknown: 0
+ UInt64 fileSize = ReadUInt64();
+ ReadUInt32(); // unknown: 0
+ ReadUInt32(); // unknown: 0
+ */
+
+ // Section 1: The Directory Listing
+ ReadChunk(inStream, sectionOffsets[1], sectionSizes[1]);
+ if (ReadUInt32() != NHeader::kItspSignature)
+ return S_FALSE;
+ if (ReadUInt32() != 1) // version
+ return S_FALSE;
+ /* UInt32 dirHeaderSize = */ ReadUInt32();
+ ReadUInt32(); // 0x0A (unknown)
+ UInt32 dirChunkSize = ReadUInt32(); // $1000
+ if (dirChunkSize < 32)
+ return S_FALSE;
+ /* UInt32 density = */ ReadUInt32(); // "Density" of quickref section, usually 2.
+ /* UInt32 depth = */ ReadUInt32(); // Depth of the index tree: 1 there is no index,
+ // 2 if there is one level of PMGI chunks.
+
+ /* UInt32 chunkNumber = */ ReadUInt32(); // Chunk number of root index chunk, -1 if there is none
+ // (though at least one file has 0 despite there being no
+ // index chunk, probably a bug.)
+ /* UInt32 firstPmglChunkNumber = */ ReadUInt32(); // Chunk number of first PMGL (listing) chunk
+ /* UInt32 lastPmglChunkNumber = */ ReadUInt32(); // Chunk number of last PMGL (listing) chunk
+ ReadUInt32(); // -1 (unknown)
+ UInt32 numDirChunks = ReadUInt32(); // Number of directory chunks (total)
+ /* UInt32 windowsLangId = */ ReadUInt32();
+ ReadGUID(g); // {5D02926A-212E-11D0-9DF9-00A0C922E6EC}
+ ReadUInt32(); // 0x54 (This is the length again)
+ ReadUInt32(); // -1 (unknown)
+ ReadUInt32(); // -1 (unknown)
+ ReadUInt32(); // -1 (unknown)
+
+ for (UInt32 ci = 0; ci < numDirChunks; ci++)
+ {
+ UInt64 chunkPos = _inBuffer.GetProcessedSize();
+ if (ReadUInt32() == NHeader::kPmglSignature)
+ {
+ // The quickref area is written backwards from the end of the chunk.
+ // One quickref entry exists for every n entries in the file, where n
+ // is calculated as 1 + (1 << quickref density). So for density = 2, n = 5.
+
+ UInt32 quickrefLength = ReadUInt32(); // Length of free space and/or quickref area at end of directory chunk
+ if (quickrefLength > dirChunkSize || quickrefLength < 2)
+ return S_FALSE;
+ ReadUInt32(); // Always 0
+ ReadUInt32(); // Chunk number of previous listing chunk when reading
+ // directory in sequence (-1 if this is the first listing chunk)
+ ReadUInt32(); // Chunk number of next listing chunk when reading
+ // directory in sequence (-1 if this is the last listing chunk)
+ int numItems = 0;
+ for (;;)
+ {
+ UInt64 offset = _inBuffer.GetProcessedSize() - chunkPos;
+ UInt32 offsetLimit = dirChunkSize - quickrefLength;
+ if (offset > offsetLimit)
+ return S_FALSE;
+ if (offset == offsetLimit)
+ break;
+ RINOK(ReadDirEntry(database));
+ numItems++;
+ }
+ Skip(quickrefLength - 2);
+ if (ReadUInt16() != numItems)
+ return S_FALSE;
+ }
+ else
+ Skip(dirChunkSize - 4);
+ }
+ return S_OK;
+}
+
+HRESULT CInArchive::OpenHelp2(IInStream *inStream, CDatabase &database)
+{
+ if (ReadUInt32() != 1) // version
+ return S_FALSE;
+ if (ReadUInt32() != 0x28) // Location of header section table
+ return S_FALSE;
+ UInt32 numHeaderSections = ReadUInt32();
+ const int kNumHeaderSectionsMax = 5;
+ if (numHeaderSections != kNumHeaderSectionsMax)
+ return S_FALSE;
+ ReadUInt32(); // Length of post-header table
+ GUID g;
+ ReadGUID(g); // {0A9007C1-4076-11D3-8789-0000F8105754}
+
+ // header section table
+ UInt64 sectionOffsets[kNumHeaderSectionsMax];
+ UInt64 sectionSizes[kNumHeaderSectionsMax];
+ UInt32 i;
+ for (i = 0; i < numHeaderSections; i++)
+ {
+ sectionOffsets[i] = ReadUInt64();
+ sectionSizes[i] = ReadUInt64();
+ }
+
+ // Post-Header
+ ReadUInt32(); // 2
+ ReadUInt32(); // 0x98: offset to CAOL from beginning of post-header)
+ // ----- Directory information
+ ReadUInt64(); // Chunk number of top-level AOLI chunk in directory, or -1
+ ReadUInt64(); // Chunk number of first AOLL chunk in directory
+ ReadUInt64(); // Chunk number of last AOLL chunk in directory
+ ReadUInt64(); // 0 (unknown)
+ ReadUInt32(); // $2000 (Directory chunk size of directory)
+ ReadUInt32(); // Quickref density for main directory, usually 2
+ ReadUInt32(); // 0 (unknown)
+ ReadUInt32(); // Depth of main directory index tree
+ // 1 there is no index, 2 if there is one level of AOLI chunks.
+ ReadUInt64(); // 0 (unknown)
+ UInt64 numDirEntries = ReadUInt64(); // Number of directory entries
+ // ----- Directory Index Information
+ ReadUInt64(); // -1 (unknown, probably chunk number of top-level AOLI in directory index)
+ ReadUInt64(); // Chunk number of first AOLL chunk in directory index
+ ReadUInt64(); // Chunk number of last AOLL chunk in directory index
+ ReadUInt64(); // 0 (unknown)
+ ReadUInt32(); // $200 (Directory chunk size of directory index)
+ ReadUInt32(); // Quickref density for directory index, usually 2
+ ReadUInt32(); // 0 (unknown)
+ ReadUInt32(); // Depth of directory index index tree.
+ ReadUInt64(); // Possibly flags -- sometimes 1, sometimes 0.
+ ReadUInt64(); // Number of directory index entries (same as number of AOLL
+ // chunks in main directory)
+
+ // (The obvious guess for the following two fields, which recur in a number
+ // of places, is they are maximum sizes for the directory and directory index.
+ // However, I have seen no direct evidence that this is the case.)
+
+ ReadUInt32(); // $100000 (Same as field following chunk size in directory)
+ ReadUInt32(); // $20000 (Same as field following chunk size in directory index)
+
+ ReadUInt64(); // 0 (unknown)
+ if (ReadUInt32() != NHeader::kCaolSignature)
+ return S_FALSE;
+ if (ReadUInt32() != 2) // (Most likely a version number)
+ return S_FALSE;
+ UInt32 caolLength = ReadUInt32(); // $50 (Length of the CAOL section, which includes the ITSF section)
+ if (caolLength >= 0x2C)
+ {
+ /* UInt32 c7 = */ ReadUInt16(); // Unknown. Remains the same when identical files are built.
+ // Does not appear to be a checksum. Many files have
+ // 'HH' (HTML Help?) here, indicating this may be a compiler ID
+ // field. But at least one ITOL/ITLS compiler does not set this
+ // field to a constant value.
+ ReadUInt16(); // 0 (Unknown. Possibly part of 00A4 field)
+ ReadUInt32(); // Unknown. Two values have been seen -- $43ED, and 0.
+ ReadUInt32(); // $2000 (Directory chunk size of directory)
+ ReadUInt32(); // $200 (Directory chunk size of directory index)
+ ReadUInt32(); // $100000 (Same as field following chunk size in directory)
+ ReadUInt32(); // $20000 (Same as field following chunk size in directory index)
+ ReadUInt32(); // 0 (unknown)
+ ReadUInt32(); // 0 (Unknown)
+ if (caolLength == 0x2C)
+ {
+ database.ContentOffset = 0;
+ database.NewFormat = true;
+ }
+ else if (caolLength == 0x50)
+ {
+ ReadUInt32(); // 0 (Unknown)
+ if (ReadUInt32() != NHeader::kItsfSignature)
+ return S_FALSE;
+ if (ReadUInt32() != 4) // $4 (Version number -- CHM uses 3)
+ return S_FALSE;
+ if (ReadUInt32() != 0x20) // $20 (length of ITSF)
+ return S_FALSE;
+ UInt32 unknown = ReadUInt32();
+ if (unknown != 0 && unknown != 1) // = 0 for some HxW files, 1 in other cases;
+ return S_FALSE;
+ database.ContentOffset = _startPosition + ReadUInt64();
+ /* UInt32 timeStamp = */ ReadUInt32();
+ // A timestamp of some sort.
+ // Considered as a big-endian DWORD, it appears to contain
+ // seconds (MSB) and fractional seconds (second byte).
+ // The third and fourth bytes may contain even more fractional
+ // bits. The 4 least significant bits in the last byte are constant.
+ /* UInt32 lang = */ ReadUInt32(); // BE?
+ }
+ else
+ return S_FALSE;
+ }
+
+ /*
+ // Section 0
+ ReadChunk(inStream, _startPosition + sectionOffsets[0], sectionSizes[0]);
+ if (sectionSizes[0] != 0x18)
+ return S_FALSE;
+ ReadUInt32(); // unknown: 01FE
+ ReadUInt32(); // unknown: 0
+ UInt64 fileSize = ReadUInt64();
+ ReadUInt32(); // unknown: 0
+ ReadUInt32(); // unknown: 0
+ */
+
+ // Section 1: The Directory Listing
+ ReadChunk(inStream, _startPosition + sectionOffsets[1], sectionSizes[1]);
+ if (ReadUInt32() != NHeader::kIfcmSignature)
+ return S_FALSE;
+ if (ReadUInt32() != 1) // (probably a version number)
+ return S_FALSE;
+ UInt32 dirChunkSize = ReadUInt32(); // $2000
+ if (dirChunkSize < 64)
+ return S_FALSE;
+ ReadUInt32(); // $100000 (unknown)
+ ReadUInt32(); // -1 (unknown)
+ ReadUInt32(); // -1 (unknown)
+ UInt32 numDirChunks = ReadUInt32();
+ ReadUInt32(); // 0 (unknown, probably high word of above)
+
+ for (UInt32 ci = 0; ci < numDirChunks; ci++)
+ {
+ UInt64 chunkPos = _inBuffer.GetProcessedSize();
+ if (ReadUInt32() == NHeader::kAollSignature)
+ {
+ UInt32 quickrefLength = ReadUInt32(); // Length of quickref area at end of directory chunk
+ if (quickrefLength > dirChunkSize || quickrefLength < 2)
+ return S_FALSE;
+ ReadUInt64(); // Directory chunk number
+ // This must match physical position in file, that is
+ // the chunk size times the chunk number must be the
+ // offset from the end of the directory header.
+ ReadUInt64(); // Chunk number of previous listing chunk when reading
+ // directory in sequence (-1 if first listing chunk)
+ ReadUInt64(); // Chunk number of next listing chunk when reading
+ // directory in sequence (-1 if last listing chunk)
+ ReadUInt64(); // Number of first listing entry in this chunk
+ ReadUInt32(); // 1 (unknown -- other values have also been seen here)
+ ReadUInt32(); // 0 (unknown)
+
+ int numItems = 0;
+ for (;;)
+ {
+ UInt64 offset = _inBuffer.GetProcessedSize() - chunkPos;
+ UInt32 offsetLimit = dirChunkSize - quickrefLength;
+ if (offset > offsetLimit)
+ return S_FALSE;
+ if (offset == offsetLimit)
+ break;
+ if (database.NewFormat)
+ {
+ UInt16 nameLength = ReadUInt16();
+ if (nameLength == 0)
+ return S_FALSE;
+ UString name;
+ ReadUString((int)nameLength, name);
+ AString s;
+ ConvertUnicodeToUTF8(name, s);
+ Byte b = ReadByte();
+ s += ' ';
+ PrintByte(b, s);
+ s += ' ';
+ UInt64 len = ReadEncInt();
+ // then number of items ?
+ // then length ?
+ // then some data (binary encoding?)
+ while (len-- != 0)
+ {
+ b = ReadByte();
+ PrintByte(b, s);
+ }
+ database.NewFormatString += s;
+ database.NewFormatString += "\r\n";
+ }
+ else
+ {
+ RINOK(ReadDirEntry(database));
+ }
+ numItems++;
+ }
+ Skip(quickrefLength - 2);
+ if (ReadUInt16() != numItems)
+ return S_FALSE;
+ if (numItems > numDirEntries)
+ return S_FALSE;
+ numDirEntries -= numItems;
+ }
+ else
+ Skip(dirChunkSize - 4);
+ }
+ return numDirEntries == 0 ? S_OK : S_FALSE;
+}
+
+HRESULT CInArchive::DecompressStream(IInStream *inStream, const CDatabase &database, const AString &name)
+{
+ int index = database.FindItem(name);
+ if (index < 0)
+ return S_FALSE;
+ const CItem &item = database.Items[index];
+ _chunkSize = item.Size;
+ return ReadChunk(inStream, database.ContentOffset + item.Offset, item.Size);
+}
+
+
+#define DATA_SPACE "::DataSpace/"
+static const char *kNameList = DATA_SPACE "NameList";
+static const char *kStorage = DATA_SPACE "Storage/";
+static const char *kContent = "Content";
+static const char *kControlData = "ControlData";
+static const char *kSpanInfo = "SpanInfo";
+static const char *kTransform = "Transform/";
+static const char *kResetTable = "/InstanceData/ResetTable";
+static const char *kTransformList = "List";
+
+static AString GetSectionPrefix(const AString &name)
+{
+ return AString(kStorage) + name + AString("/");
+}
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+static int CompareFiles(const int *p1, const int *p2, void *param)
+{
+ const CObjectVector<CItem> &items = *(const CObjectVector<CItem> *)param;
+ const CItem &item1 = items[*p1];
+ const CItem &item2 = items[*p2];
+ bool isDir1 = item1.IsDir();
+ bool isDir2 = item2.IsDir();
+ if (isDir1 && !isDir2)
+ return -1;
+ if (isDir2)
+ {
+ if (isDir1)
+ return MyCompare(*p1, *p2);
+ return 1;
+ }
+ RINOZ(MyCompare(item1.Section, item2.Section));
+ RINOZ(MyCompare(item1.Offset, item2.Offset));
+ RINOZ(MyCompare(item1.Size, item2.Size));
+ return MyCompare(*p1, *p2);
+}
+
+void CFilesDatabase::SetIndices()
+{
+ for (int i = 0; i < Items.Size(); i++)
+ {
+ const CItem &item = Items[i];
+ if (item.IsUserItem() && item.Name.Length() != 1)
+ Indices.Add(i);
+ }
+}
+
+void CFilesDatabase::Sort()
+{
+ Indices.Sort(CompareFiles, (void *)&Items);
+}
+
+bool CFilesDatabase::Check()
+{
+ UInt64 maxPos = 0;
+ UInt64 prevSection = 0;
+ for(int i = 0; i < Indices.Size(); i++)
+ {
+ const CItem &item = Items[Indices[i]];
+ if (item.Section == 0 || item.IsDir())
+ continue;
+ if (item.Section != prevSection)
+ {
+ prevSection = item.Section;
+ maxPos = 0;
+ continue;
+ }
+ if (item.Offset < maxPos)
+ return false;
+ maxPos = item.Offset + item.Size;
+ if (maxPos < item.Offset)
+ return false;
+ }
+ return true;
+}
+
+HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
+{
+ {
+ // The NameList file
+ RINOK(DecompressStream(inStream, database, kNameList));
+ /* UInt16 length = */ ReadUInt16();
+ UInt16 numSections = ReadUInt16();
+ for (int i = 0; i < numSections; i++)
+ {
+ CSectionInfo section;
+ UInt16 nameLength = ReadUInt16();
+ UString name;
+ ReadUString(nameLength, name);
+ if (ReadUInt16() != 0)
+ return S_FALSE;
+ if (!ConvertUnicodeToUTF8(name, section.Name))
+ return S_FALSE;
+ database.Sections.Add(section);
+ }
+ }
+
+ int i;
+ for (i = 1; i < database.Sections.Size(); i++)
+ {
+ CSectionInfo &section = database.Sections[i];
+ AString sectionPrefix = GetSectionPrefix(section.Name);
+ {
+ // Content
+ int index = database.FindItem(sectionPrefix + kContent);
+ if (index < 0)
+ return S_FALSE;
+ const CItem &item = database.Items[index];
+ section.Offset = item.Offset;
+ section.CompressedSize = item.Size;
+ }
+ AString transformPrefix = sectionPrefix + kTransform;
+ if (database.Help2Format)
+ {
+ // Transform List
+ RINOK(DecompressStream(inStream, database, transformPrefix + kTransformList));
+ if ((_chunkSize & 0xF) != 0)
+ return S_FALSE;
+ int numGuids = (int)(_chunkSize / 0x10);
+ if (numGuids < 1)
+ return S_FALSE;
+ for (int i = 0; i < numGuids; i++)
+ {
+ CMethodInfo method;
+ ReadGUID(method.Guid);
+ section.Methods.Add(method);
+ }
+ }
+ else
+ {
+ CMethodInfo method;
+ method.Guid = kChmLzxGuid;
+ section.Methods.Add(method);
+ }
+
+ {
+ // Control Data
+ RINOK(DecompressStream(inStream, database, sectionPrefix + kControlData));
+ for (int mi = 0; mi < section.Methods.Size(); mi++)
+ {
+ CMethodInfo &method = section.Methods[mi];
+ UInt32 numDWORDS = ReadUInt32();
+ if (method.IsLzx())
+ {
+ if (numDWORDS < 5)
+ return S_FALSE;
+ if (ReadUInt32() != NHeader::kLzxcSignature)
+ return S_FALSE;
+ CLzxInfo &li = method.LzxInfo;
+ li.Version = ReadUInt32();
+ if (li.Version != 2 && li.Version != 3)
+ return S_FALSE;
+ li.ResetInterval = ReadUInt32();
+ li.WindowSize = ReadUInt32();
+ li.CacheSize = ReadUInt32();
+ if (
+ li.ResetInterval != 1 &&
+ li.ResetInterval != 2 &&
+ li.ResetInterval != 4 &&
+ li.ResetInterval != 8 &&
+ li.ResetInterval != 16 &&
+ li.ResetInterval != 32 &&
+ li.ResetInterval != 64)
+ return S_FALSE;
+ if (
+ li.WindowSize != 1 &&
+ li.WindowSize != 2 &&
+ li.WindowSize != 4 &&
+ li.WindowSize != 8 &&
+ li.WindowSize != 16 &&
+ li.WindowSize != 32 &&
+ li.WindowSize != 64)
+ return S_FALSE;
+ numDWORDS -= 5;
+ while (numDWORDS-- != 0)
+ ReadUInt32();
+ }
+ else
+ {
+ UInt32 numBytes = numDWORDS * 4;
+ method.ControlData.SetCapacity(numBytes);
+ ReadBytes(method.ControlData, numBytes);
+ }
+ }
+ }
+
+ {
+ // SpanInfo
+ RINOK(DecompressStream(inStream, database, sectionPrefix + kSpanInfo));
+ section.UncompressedSize = ReadUInt64();
+ }
+
+ // read ResetTable for LZX
+ for (int mi = 0; mi < section.Methods.Size(); mi++)
+ {
+ CMethodInfo &method = section.Methods[mi];
+ if (method.IsLzx())
+ {
+ // ResetTable;
+ RINOK(DecompressStream(inStream, database, transformPrefix +
+ method.GetGuidString() + kResetTable));
+ CResetTable &rt = method.LzxInfo.ResetTable;
+ if (_chunkSize < 4)
+ {
+ if (_chunkSize != 0)
+ return S_FALSE;
+ // ResetTable is empty in .chw files
+ if (section.UncompressedSize != 0)
+ return S_FALSE;
+ rt.UncompressedSize = 0;
+ rt.CompressedSize = 0;
+ rt.BlockSize = 0;
+ }
+ else
+ {
+ UInt32 ver = ReadUInt32(); // 2 unknown (possibly a version number)
+ if (ver != 2 && ver != 3)
+ return S_FALSE;
+ UInt32 numEntries = ReadUInt32();
+ if (ReadUInt32() != 8) // Size of table entry (bytes)
+ return S_FALSE;
+ if (ReadUInt32() != 0x28) // Length of table header
+ return S_FALSE;
+ rt.UncompressedSize = ReadUInt64();
+ rt.CompressedSize = ReadUInt64();
+ rt.BlockSize = ReadUInt64(); // 0x8000 block size for locations below
+ if (rt.BlockSize != 0x8000)
+ return S_FALSE;
+ rt.ResetOffsets.Reserve(numEntries);
+ for (UInt32 i = 0; i < numEntries; i++)
+ rt.ResetOffsets.Add(ReadUInt64());
+ }
+ }
+ }
+ }
+
+ database.SetIndices();
+ database.Sort();
+ return database.Check() ? S_OK : S_FALSE;
+}
+
+HRESULT CInArchive::Open2(IInStream *inStream,
+ const UInt64 *searchHeaderSizeLimit,
+ CFilesDatabase &database)
+{
+ database.Clear();
+
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &_startPosition));
+
+ database.Help2Format = false;
+ const UInt32 chmVersion = 3;
+ {
+ if (!_inBuffer.Create(1 << 14))
+ return E_OUTOFMEMORY;
+ _inBuffer.SetStream(inStream);
+ _inBuffer.Init();
+ UInt64 value = 0;
+ const int kSignatureSize = 8;
+ UInt64 hxsSignature = NHeader::GetHxsSignature();
+ UInt64 chmSignature = ((UInt64)chmVersion << 32)| NHeader::kItsfSignature;
+ UInt64 limit = 1 << 18;
+ if (searchHeaderSizeLimit)
+ if (limit > *searchHeaderSizeLimit)
+ limit = *searchHeaderSizeLimit;
+
+ for (;;)
+ {
+ Byte b;
+ if (!_inBuffer.ReadByte(b))
+ return S_FALSE;
+ value >>= 8;
+ value |= ((UInt64)b) << ((kSignatureSize - 1) * 8);
+ if (_inBuffer.GetProcessedSize() >= kSignatureSize)
+ {
+ if (value == chmSignature)
+ break;
+ if (value == hxsSignature)
+ {
+ database.Help2Format = true;
+ break;
+ }
+ if (_inBuffer.GetProcessedSize() > limit)
+ return S_FALSE;
+ }
+ }
+ _startPosition += _inBuffer.GetProcessedSize() - kSignatureSize;
+ }
+
+ if (database.Help2Format)
+ {
+ RINOK(OpenHelp2(inStream, database));
+ if (database.NewFormat)
+ return S_OK;
+ }
+ else
+ {
+ RINOK(OpenChm(inStream, database));
+ }
+
+ #ifndef CHM_LOW
+ try
+ {
+ HRESULT res = OpenHighLevel(inStream, database);
+ if (res == S_FALSE)
+ {
+ database.HighLevelClear();
+ return S_OK;
+ }
+ RINOK(res);
+ database.LowLevel = false;
+ }
+ catch(...)
+ {
+ return S_OK;
+ }
+ #endif
+ return S_OK;
+}
+
+HRESULT CInArchive::Open(IInStream *inStream,
+ const UInt64 *searchHeaderSizeLimit,
+ CFilesDatabase &database)
+{
+ try
+ {
+ HRESULT res = Open2(inStream, searchHeaderSizeLimit, database);
+ _inBuffer.ReleaseStream();
+ return res;
+ }
+ catch(...)
+ {
+ _inBuffer.ReleaseStream();
+ throw;
+ }
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmIn.h
new file mode 100644
index 000000000..4719a484d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmIn.h
@@ -0,0 +1,244 @@
+// Archive/ChmIn.h
+
+#ifndef __ARCHIVE_CHM_IN_H
+#define __ARCHIVE_CHM_IN_H
+
+#include "Common/Buffer.h"
+#include "Common/MyString.h"
+
+#include "../../IStream.h"
+#include "../../Common/InBuffer.h"
+
+#include "ChmHeader.h"
+
+namespace NArchive {
+namespace NChm {
+
+struct CItem
+{
+ UInt64 Section;
+ UInt64 Offset;
+ UInt64 Size;
+ AString Name;
+
+ bool IsFormatRelatedItem() const
+ {
+ if (Name.Length() < 2)
+ return false;
+ return Name[0] == ':' && Name[1] == ':';
+ }
+
+ bool IsUserItem() const
+ {
+ if (Name.Length() < 2)
+ return false;
+ return Name[0] == '/';
+ }
+
+ bool IsDir() const
+ {
+ if (Name.Length() == 0)
+ return false;
+ return (Name[Name.Length() - 1] == '/');
+ }
+};
+
+struct CDatabase
+{
+ UInt64 ContentOffset;
+ CObjectVector<CItem> Items;
+ AString NewFormatString;
+ bool Help2Format;
+ bool NewFormat;
+
+ int FindItem(const AString &name) const
+ {
+ for (int i = 0; i < Items.Size(); i++)
+ if (Items[i].Name == name)
+ return i;
+ return -1;
+ }
+
+ void Clear()
+ {
+ NewFormat = false;
+ NewFormatString.Empty();
+ Help2Format = false;
+ Items.Clear();
+ }
+};
+
+struct CResetTable
+{
+ UInt64 UncompressedSize;
+ UInt64 CompressedSize;
+ UInt64 BlockSize;
+ CRecordVector<UInt64> ResetOffsets;
+ bool GetCompressedSizeOfBlocks(UInt64 blockIndex, UInt32 numBlocks, UInt64 &size) const
+ {
+ if (blockIndex >= ResetOffsets.Size())
+ return false;
+ UInt64 startPos = ResetOffsets[(int)blockIndex];
+ if (blockIndex + numBlocks >= ResetOffsets.Size())
+ size = CompressedSize - startPos;
+ else
+ size = ResetOffsets[(int)(blockIndex + numBlocks)] - startPos;
+ return true;
+ }
+ bool GetCompressedSizeOfBlock(UInt64 blockIndex, UInt64 &size) const
+ {
+ return GetCompressedSizeOfBlocks(blockIndex, 1, size);
+ }
+ UInt64 GetNumBlocks(UInt64 size) const
+ {
+ return (size + BlockSize - 1) / BlockSize;
+ }
+};
+
+struct CLzxInfo
+{
+ UInt32 Version;
+ UInt32 ResetInterval;
+ UInt32 WindowSize;
+ UInt32 CacheSize;
+ CResetTable ResetTable;
+
+ UInt32 GetNumDictBits() const
+ {
+ if (Version == 2 || Version == 3)
+ {
+ for (int i = 0; i <= 31; i++)
+ if (((UInt32)1 << i) >= WindowSize)
+ return 15 + i;
+ }
+ return 0;
+ }
+
+ UInt64 GetFolderSize() const { return ResetTable.BlockSize * ResetInterval; };
+ UInt64 GetFolder(UInt64 offset) const { return offset / GetFolderSize(); };
+ UInt64 GetFolderPos(UInt64 folderIndex) const { return folderIndex * GetFolderSize(); };
+ UInt64 GetBlockIndexFromFolderIndex(UInt64 folderIndex) const { return folderIndex * ResetInterval; };
+ bool GetOffsetOfFolder(UInt64 folderIndex, UInt64 &offset) const
+ {
+ UInt64 blockIndex = GetBlockIndexFromFolderIndex(folderIndex);
+ if (blockIndex >= ResetTable.ResetOffsets.Size())
+ return false;
+ offset = ResetTable.ResetOffsets[(int)blockIndex];
+ return true;
+ }
+ bool GetCompressedSizeOfFolder(UInt64 folderIndex, UInt64 &size) const
+ {
+ UInt64 blockIndex = GetBlockIndexFromFolderIndex(folderIndex);
+ return ResetTable.GetCompressedSizeOfBlocks(blockIndex, ResetInterval, size);
+ }
+};
+
+struct CMethodInfo
+{
+ GUID Guid;
+ CByteBuffer ControlData;
+ CLzxInfo LzxInfo;
+ bool IsLzx() const;
+ bool IsDes() const;
+ AString GetGuidString() const;
+ UString GetName() const;
+};
+
+struct CSectionInfo
+{
+ UInt64 Offset;
+ UInt64 CompressedSize;
+ UInt64 UncompressedSize;
+
+ AString Name;
+ CObjectVector<CMethodInfo> Methods;
+
+ bool IsLzx() const;
+ UString GetMethodName() const;
+};
+
+class CFilesDatabase: public CDatabase
+{
+public:
+ bool LowLevel;
+ CRecordVector<int> Indices;
+ CObjectVector<CSectionInfo> Sections;
+
+ UInt64 GetFileSize(int fileIndex) const { return Items[Indices[fileIndex]].Size; }
+ UInt64 GetFileOffset(int fileIndex) const { return Items[Indices[fileIndex]].Offset; }
+
+ UInt64 GetFolder(int fileIndex) const
+ {
+ const CItem &item = Items[Indices[fileIndex]];
+ const CSectionInfo &section = Sections[(int)item.Section];
+ if (section.IsLzx())
+ return section.Methods[0].LzxInfo.GetFolder(item.Offset);
+ return 0;
+ }
+
+ UInt64 GetLastFolder(int fileIndex) const
+ {
+ const CItem &item = Items[Indices[fileIndex]];
+ const CSectionInfo &section = Sections[(int)item.Section];
+ if (section.IsLzx())
+ return section.Methods[0].LzxInfo.GetFolder(item.Offset + item.Size - 1);
+ return 0;
+ }
+
+ void HighLevelClear()
+ {
+ LowLevel = true;
+ Indices.Clear();
+ Sections.Clear();
+ }
+
+ void Clear()
+ {
+ CDatabase::Clear();
+ HighLevelClear();
+ }
+ void SetIndices();
+ void Sort();
+ bool Check();
+};
+
+class CProgressVirt
+{
+public:
+ STDMETHOD(SetTotal)(const UInt64 *numFiles) PURE;
+ STDMETHOD(SetCompleted)(const UInt64 *numFiles) PURE;
+};
+
+class CInArchive
+{
+ UInt64 _startPosition;
+ ::CInBuffer _inBuffer;
+ UInt64 _chunkSize;
+
+ Byte ReadByte();
+ void ReadBytes(Byte *data, UInt32 size);
+ void Skip(size_t size);
+ UInt16 ReadUInt16();
+ UInt32 ReadUInt32();
+ UInt64 ReadUInt64();
+ UInt64 ReadEncInt();
+ void ReadString(int size, AString &s);
+ void ReadUString(int size, UString &s);
+ void ReadGUID(GUID &g);
+
+ HRESULT ReadChunk(IInStream *inStream, UInt64 pos, UInt64 size);
+
+ HRESULT ReadDirEntry(CDatabase &database);
+ HRESULT DecompressStream(IInStream *inStream, const CDatabase &database, const AString &name);
+
+public:
+ HRESULT OpenChm(IInStream *inStream, CDatabase &database);
+ HRESULT OpenHelp2(IInStream *inStream, CDatabase &database);
+ HRESULT OpenHighLevel(IInStream *inStream, CFilesDatabase &database);
+ HRESULT Open2(IInStream *inStream, const UInt64 *searchHeaderSizeLimit, CFilesDatabase &database);
+ HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit, CFilesDatabase &database);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmRegister.cpp
new file mode 100644
index 000000000..abebe6c67
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Chm/ChmRegister.cpp
@@ -0,0 +1,13 @@
+// ChmRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "ChmHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NChm::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Chm", L"chm chi chq chw hxs hxi hxr hxq hxw lit", 0, 0xE9, { 'I', 'T', 'S', 'F' }, 4, false, CreateArc, 0 };
+
+REGISTER_ARC(Chm)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComHandler.cpp
new file mode 100644
index 000000000..287f61565
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComHandler.cpp
@@ -0,0 +1,239 @@
+// ComHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
+#include "../../Common/StreamUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "ComHandler.h"
+
+namespace NArchive {
+namespace NCom {
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidClusterSize, VT_UI4},
+ { NULL, kpidSectorSize, VT_UI4}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidClusterSize: prop = (UInt32)1 << _db.SectorSizeBits; break;
+ case kpidSectorSize: prop = (UInt32)1 << _db.MiniSectorSizeBits; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CRef &ref = _db.Refs[index];
+ const CItem &item = _db.Items[ref.Did];
+
+ switch(propID)
+ {
+ case kpidPath: prop = _db.GetItemPath(index); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidCTime: prop = item.CTime; break;
+ case kpidMTime: prop = item.MTime; break;
+ case kpidPackSize: if (!item.IsDir()) prop = _db.GetItemPackSize(item.Size); break;
+ case kpidSize: if (!item.IsDir()) prop = item.Size; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ try
+ {
+ if (_db.Open(inStream) != S_OK)
+ return S_FALSE;
+ _stream = inStream;
+ }
+ catch(...) { return S_FALSE; }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _db.Clear();
+ _stream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _db.Refs.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt32 i;
+ UInt64 totalSize = 0;
+ for(i = 0; i < numItems; i++)
+ {
+ const CItem &item = _db.Items[_db.Refs[allFilesMode ? i : indices[i]].Did];
+ if (!item.IsDir())
+ totalSize += item.Size;
+ }
+ RINOK(extractCallback->SetTotal(totalSize));
+
+ UInt64 totalPackSize;
+ totalSize = totalPackSize = 0;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ for (i = 0; i < numItems; i++)
+ {
+ lps->InSize = totalPackSize;
+ lps->OutSize = totalSize;
+ RINOK(lps->SetCur());
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _db.Items[_db.Refs[index].Did];
+
+ CMyComPtr<ISequentialOutStream> outStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ RINOK(extractCallback->GetStream(index, &outStream, askMode));
+
+ if (item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+
+ totalPackSize += _db.GetItemPackSize(item.Size);
+ totalSize += item.Size;
+
+ if (!testMode && (!outStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ Int32 res = NArchive::NExtract::NOperationResult::kDataError;
+ CMyComPtr<ISequentialInStream> inStream;
+ HRESULT hres = GetStream(index, &inStream);
+ if (hres == S_FALSE)
+ res = NArchive::NExtract::NOperationResult::kDataError;
+ else if (hres == E_NOTIMPL)
+ res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ else
+ {
+ RINOK(hres);
+ if (inStream)
+ {
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ if (copyCoderSpec->TotalSize == item.Size)
+ res = NArchive::NExtract::NOperationResult::kOK;
+ }
+ }
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(res));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _db.Refs.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ *stream = 0;
+ const CItem &item = _db.Items[_db.Refs[index].Did];
+ CClusterInStream *streamSpec = new CClusterInStream;
+ CMyComPtr<ISequentialInStream> streamTemp = streamSpec;
+ streamSpec->Stream = _stream;
+ streamSpec->StartOffset = 0;
+
+ bool isLargeStream = _db.IsLargeStream(item.Size);
+ int bsLog = isLargeStream ? _db.SectorSizeBits : _db.MiniSectorSizeBits;
+ streamSpec->BlockSizeLog = bsLog;
+ streamSpec->Size = item.Size;
+
+ UInt32 clusterSize = (UInt32)1 << bsLog;
+ UInt64 numClusters64 = (item.Size + clusterSize - 1) >> bsLog;
+ if (numClusters64 >= ((UInt32)1 << 31))
+ return E_NOTIMPL;
+ streamSpec->Vector.Reserve((int)numClusters64);
+ UInt32 sid = item.Sid;
+ UInt64 size = item.Size;
+
+ if (size != 0)
+ {
+ for (;; size -= clusterSize)
+ {
+ if (isLargeStream)
+ {
+ if (sid >= _db.FatSize)
+ return S_FALSE;
+ streamSpec->Vector.Add(sid + 1);
+ sid = _db.Fat[sid];
+ }
+ else
+ {
+ UInt64 val;
+ if (sid >= _db.MatSize || !_db.GetMiniCluster(sid, val) || val >= (UInt64)1 << 32)
+ return S_FALSE;
+ streamSpec->Vector.Add((UInt32)val);
+ sid = _db.Mat[sid];
+ }
+ if (size <= clusterSize)
+ break;
+ }
+ }
+ if (sid != NFatID::kEndOfChain)
+ return S_FALSE;
+ RINOK(streamSpec->InitAndSeek());
+ *stream = streamTemp.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComHandler.h
new file mode 100644
index 000000000..f2b7de96d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComHandler.h
@@ -0,0 +1,28 @@
+// ComHandler.h
+
+#ifndef __ARCHIVE_COM_HANDLER_H
+#define __ARCHIVE_COM_HANDLER_H
+
+#include "Common/MyCom.h"
+#include "../IArchive.h"
+#include "ComIn.h"
+
+namespace NArchive {
+namespace NCom {
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _stream;
+ CDatabase _db;
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComIn.cpp
new file mode 100644
index 000000000..8f6221221
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComIn.cpp
@@ -0,0 +1,359 @@
+// Archive/ComIn.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/Alloc.h"
+#include "../../../../C/CpuArch.h"
+
+#include "Common/IntToString.h"
+#include "Common/MyCom.h"
+
+#include "../../Common/StreamUtils.h"
+
+#include "ComIn.h"
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+
+namespace NArchive{
+namespace NCom{
+
+static const UInt32 kSignatureSize = 8;
+static const Byte kSignature[kSignatureSize] = { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 };
+
+void CUInt32Buf::Free()
+{
+ MyFree(_buf);
+ _buf = 0;
+}
+
+bool CUInt32Buf::Allocate(UInt32 numItems)
+{
+ Free();
+ if (numItems == 0)
+ return true;
+ size_t newSize = (size_t)numItems * sizeof(UInt32);
+ if (newSize / sizeof(UInt32) != numItems)
+ return false;
+ _buf = (UInt32 *)MyAlloc(newSize);
+ return (_buf != 0);
+}
+
+static HRESULT ReadSector(IInStream *inStream, Byte *buf, int sectorSizeBits, UInt32 sid)
+{
+ RINOK(inStream->Seek((((UInt64)sid + 1) << sectorSizeBits), STREAM_SEEK_SET, NULL));
+ return ReadStream_FALSE(inStream, buf, (UInt32)1 << sectorSizeBits);
+}
+
+static HRESULT ReadIDs(IInStream *inStream, Byte *buf, int sectorSizeBits, UInt32 sid, UInt32 *dest)
+{
+ RINOK(ReadSector(inStream, buf, sectorSizeBits, sid));
+ UInt32 sectorSize = (UInt32)1 << sectorSizeBits;
+ for (UInt32 t = 0; t < sectorSize; t += 4)
+ *dest++ = Get32(buf + t);
+ return S_OK;
+}
+
+static void GetFileTimeFromMem(const Byte *p, FILETIME *ft)
+{
+ ft->dwLowDateTime = Get32(p);
+ ft->dwHighDateTime = Get32(p + 4);
+}
+
+void CItem::Parse(const Byte *p, bool mode64bit)
+{
+ memcpy(Name, p, kNameSizeMax);
+ // NameSize = Get16(p + 64);
+ Type = p[66];
+ LeftDid = Get32(p + 68);
+ RightDid = Get32(p + 72);
+ SonDid = Get32(p + 76);
+ // Flags = Get32(p + 96);
+ GetFileTimeFromMem(p + 100, &CTime);
+ GetFileTimeFromMem(p + 108, &MTime);
+ Sid = Get32(p + 116);
+ Size = Get32(p + 120);
+ if (mode64bit)
+ Size |= ((UInt64)Get32(p + 124) << 32);
+}
+
+void CDatabase::Clear()
+{
+ Fat.Free();
+ MiniSids.Free();
+ Mat.Free();
+ Items.Clear();
+ Refs.Clear();
+}
+
+static const UInt32 kNoDid = 0xFFFFFFFF;
+
+HRESULT CDatabase::AddNode(int parent, UInt32 did)
+{
+ if (did == kNoDid)
+ return S_OK;
+ if (did >= (UInt32)Items.Size())
+ return S_FALSE;
+ const CItem &item = Items[did];
+ if (item.IsEmpty())
+ return S_FALSE;
+ CRef ref;
+ ref.Parent = parent;
+ ref.Did = did;
+ int index = Refs.Add(ref);
+ if (Refs.Size() > Items.Size())
+ return S_FALSE;
+ RINOK(AddNode(parent, item.LeftDid));
+ RINOK(AddNode(parent, item.RightDid));
+ if (item.IsDir())
+ {
+ RINOK(AddNode(index, item.SonDid));
+ }
+ return S_OK;
+}
+
+static const char kCharOpenBracket = '[';
+static const char kCharCloseBracket = ']';
+
+static UString CompoundNameToFileName(const UString &s)
+{
+ UString res;
+ for (int i = 0; i < s.Length(); i++)
+ {
+ wchar_t c = s[i];
+ if (c < 0x20)
+ {
+ res += kCharOpenBracket;
+ wchar_t buf[32];
+ ConvertUInt32ToString(c, buf);
+ res += buf;
+ res += kCharCloseBracket;
+ }
+ else
+ res += c;
+ }
+ return res;
+}
+
+static char g_MsiChars[] =
+"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._";
+
+static const wchar_t *kMsi_ID = L""; // L"{msi}";
+
+static const int kMsiNumBits = 6;
+static const UInt32 kMsiNumChars = 1 << kMsiNumBits;
+static const UInt32 kMsiCharMask = kMsiNumChars - 1;
+static const UInt32 kMsiStartUnicodeChar = 0x3800;
+static const UInt32 kMsiUnicodeRange = kMsiNumChars * (kMsiNumChars + 1);
+
+bool CompoundMsiNameToFileName(const UString &name, UString &resultName)
+{
+ resultName.Empty();
+ for (int i = 0; i < name.Length(); i++)
+ {
+ wchar_t c = name[i];
+ if (c < kMsiStartUnicodeChar || c > kMsiStartUnicodeChar + kMsiUnicodeRange)
+ return false;
+ if (i == 0)
+ resultName += kMsi_ID;
+ c -= kMsiStartUnicodeChar;
+
+ UInt32 c0 = c & kMsiCharMask;
+ UInt32 c1 = c >> kMsiNumBits;
+
+ if (c1 <= kMsiNumChars)
+ {
+ resultName += (wchar_t)g_MsiChars[c0];
+ if (c1 == kMsiNumChars)
+ break;
+ resultName += (wchar_t)g_MsiChars[c1];
+ }
+ else
+ resultName += L'!';
+ }
+ return true;
+}
+
+static UString ConvertName(const Byte *p)
+{
+ UString s;
+ for (int i = 0; i < kNameSizeMax; i += 2)
+ {
+ wchar_t c = (p[i] | (wchar_t)p[i + 1] << 8);
+ if (c == 0)
+ break;
+ s += c;
+ }
+ UString msiName;
+ if (CompoundMsiNameToFileName(s, msiName))
+ return msiName;
+ return CompoundNameToFileName(s);
+}
+
+UString CDatabase::GetItemPath(UInt32 index) const
+{
+ UString s;
+ while (index != kNoDid)
+ {
+ const CRef &ref = Refs[index];
+ const CItem &item = Items[ref.Did];
+ if (!s.IsEmpty())
+ s = (UString)WCHAR_PATH_SEPARATOR + s;
+ s = ConvertName(item.Name) + s;
+ index = ref.Parent;
+ }
+ return s;
+}
+
+HRESULT CDatabase::Open(IInStream *inStream)
+{
+ static const UInt32 kHeaderSize = 512;
+ Byte p[kHeaderSize];
+ RINOK(ReadStream_FALSE(inStream, p, kHeaderSize));
+ if (memcmp(p, kSignature, kSignatureSize) != 0)
+ return S_FALSE;
+ if (Get16(p + 0x1A) > 4) // majorVer
+ return S_FALSE;
+ if (Get16(p + 0x1C) != 0xFFFE)
+ return S_FALSE;
+ int sectorSizeBits = Get16(p + 0x1E);
+ bool mode64bit = (sectorSizeBits >= 12);
+ int miniSectorSizeBits = Get16(p + 0x20);
+ SectorSizeBits = sectorSizeBits;
+ MiniSectorSizeBits = miniSectorSizeBits;
+
+ if (sectorSizeBits > 28 || miniSectorSizeBits > 28 ||
+ sectorSizeBits < 7 || miniSectorSizeBits < 2 || miniSectorSizeBits > sectorSizeBits)
+ return S_FALSE;
+ UInt32 numSectorsForFAT = Get32(p + 0x2C);
+ LongStreamMinSize = Get32(p + 0x38);
+
+ UInt32 sectSize = (UInt32)1 << (int)sectorSizeBits;
+
+ CByteBuffer sect;
+ sect.SetCapacity(sectSize);
+
+ int ssb2 = (int)(sectorSizeBits - 2);
+ UInt32 numSidsInSec = (UInt32)1 << ssb2;
+ UInt32 numFatItems = numSectorsForFAT << ssb2;
+ if ((numFatItems >> ssb2) != numSectorsForFAT)
+ return S_FALSE;
+ FatSize = numFatItems;
+
+ {
+ CUInt32Buf bat;
+ UInt32 numSectorsForBat = Get32(p + 0x48);
+ const UInt32 kNumHeaderBatItems = 109;
+ UInt32 numBatItems = kNumHeaderBatItems + (numSectorsForBat << ssb2);
+ if (numBatItems < kNumHeaderBatItems || ((numBatItems - kNumHeaderBatItems) >> ssb2) != numSectorsForBat)
+ return S_FALSE;
+ if (!bat.Allocate(numBatItems))
+ return S_FALSE;
+ UInt32 i;
+ for (i = 0; i < kNumHeaderBatItems; i++)
+ bat[i] = Get32(p + 0x4c + i * 4);
+ UInt32 sid = Get32(p + 0x44);
+ for (UInt32 s = 0; s < numSectorsForBat; s++)
+ {
+ RINOK(ReadIDs(inStream, sect, sectorSizeBits, sid, bat + i));
+ i += numSidsInSec - 1;
+ sid = bat[i];
+ }
+ numBatItems = i;
+
+ if (!Fat.Allocate(numFatItems))
+ return S_FALSE;
+ UInt32 j = 0;
+
+ for (i = 0; i < numFatItems; j++, i += numSidsInSec)
+ {
+ if (j >= numBatItems)
+ return S_FALSE;
+ RINOK(ReadIDs(inStream, sect, sectorSizeBits, bat[j], Fat + i));
+ }
+ }
+
+ UInt32 numMatItems;
+ {
+ UInt32 numSectorsForMat = Get32(p + 0x40);
+ numMatItems = (UInt32)numSectorsForMat << ssb2;
+ if ((numMatItems >> ssb2) != numSectorsForMat)
+ return S_FALSE;
+ if (!Mat.Allocate(numMatItems))
+ return S_FALSE;
+ UInt32 i;
+ UInt32 sid = Get32(p + 0x3C);
+ for (i = 0; i < numMatItems; i += numSidsInSec)
+ {
+ RINOK(ReadIDs(inStream, sect, sectorSizeBits, sid, Mat + i));
+ if (sid >= numFatItems)
+ return S_FALSE;
+ sid = Fat[sid];
+ }
+ if (sid != NFatID::kEndOfChain)
+ return S_FALSE;
+ }
+
+ {
+ UInt32 sid = Get32(p + 0x30);
+ for (;;)
+ {
+ if (sid >= numFatItems)
+ return S_FALSE;
+ RINOK(ReadSector(inStream, sect, sectorSizeBits, sid));
+ for (UInt32 i = 0; i < sectSize; i += 128)
+ {
+ CItem item;
+ item.Parse(sect + i, mode64bit);
+ Items.Add(item);
+ }
+ sid = Fat[sid];
+ if (sid == NFatID::kEndOfChain)
+ break;
+ }
+ }
+
+ CItem root = Items[0];
+
+ {
+ UInt32 numSectorsInMiniStream;
+ {
+ UInt64 numSatSects64 = (root.Size + sectSize - 1) >> sectorSizeBits;
+ if (numSatSects64 > NFatID::kMaxValue)
+ return S_FALSE;
+ numSectorsInMiniStream = (UInt32)numSatSects64;
+ }
+ NumSectorsInMiniStream = numSectorsInMiniStream;
+ if (!MiniSids.Allocate(numSectorsInMiniStream))
+ return S_FALSE;
+ {
+ UInt64 matSize64 = (root.Size + ((UInt64)1 << miniSectorSizeBits) - 1) >> miniSectorSizeBits;
+ if (matSize64 > NFatID::kMaxValue)
+ return S_FALSE;
+ MatSize = (UInt32)matSize64;
+ if (numMatItems < MatSize)
+ return S_FALSE;
+ }
+
+ UInt32 sid = root.Sid;
+ for (UInt32 i = 0; ; i++)
+ {
+ if (sid == NFatID::kEndOfChain)
+ {
+ if (i != numSectorsInMiniStream)
+ return S_FALSE;
+ break;
+ }
+ if (i >= numSectorsInMiniStream)
+ return S_FALSE;
+ MiniSids[i] = sid;
+ if (sid >= numFatItems)
+ return S_FALSE;
+ sid = Fat[sid];
+ }
+ }
+
+ return AddNode(-1, root.SonDid);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComIn.h
new file mode 100644
index 000000000..05fc73870
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComIn.h
@@ -0,0 +1,117 @@
+// Archive/ComIn.h
+
+#ifndef __ARCHIVE_COM_IN_H
+#define __ARCHIVE_COM_IN_H
+
+#include "Common/MyString.h"
+#include "Common/Buffer.h"
+
+namespace NArchive {
+namespace NCom {
+
+struct CUInt32Buf
+{
+ UInt32 *_buf;
+public:
+ CUInt32Buf(): _buf(0) {}
+ ~CUInt32Buf() { Free(); }
+ void Free();
+ bool Allocate(UInt32 numItems);
+ operator UInt32 *() const { return _buf; };
+};
+
+namespace NFatID
+{
+ const UInt32 kFree = 0xFFFFFFFF;
+ const UInt32 kEndOfChain = 0xFFFFFFFE;
+ const UInt32 kFatSector = 0xFFFFFFFD;
+ const UInt32 kMatSector = 0xFFFFFFFC;
+ const UInt32 kMaxValue = 0xFFFFFFFA;
+}
+
+namespace NItemType
+{
+ const Byte kEmpty = 0;
+ const Byte kStorage = 1;
+ const Byte kStream = 2;
+ const Byte kLockBytes = 3;
+ const Byte kProperty = 4;
+ const Byte kRootStorage = 5;
+}
+
+const UInt32 kNameSizeMax = 64;
+
+struct CItem
+{
+ Byte Name[kNameSizeMax];
+ // UInt16 NameSize;
+ // UInt32 Flags;
+ FILETIME CTime;
+ FILETIME MTime;
+ UInt64 Size;
+ UInt32 LeftDid;
+ UInt32 RightDid;
+ UInt32 SonDid;
+ UInt32 Sid;
+ Byte Type;
+
+ bool IsEmpty() const { return Type == NItemType::kEmpty; }
+ bool IsDir() const { return Type == NItemType::kStorage || Type == NItemType::kRootStorage; }
+
+ void Parse(const Byte *p, bool mode64bit);
+};
+
+struct CRef
+{
+ int Parent;
+ UInt32 Did;
+};
+
+class CDatabase
+{
+ UInt32 NumSectorsInMiniStream;
+ CUInt32Buf MiniSids;
+
+ HRESULT AddNode(int parent, UInt32 did);
+public:
+
+ CUInt32Buf Fat;
+ UInt32 FatSize;
+
+ CUInt32Buf Mat;
+ UInt32 MatSize;
+
+ CObjectVector<CItem> Items;
+ CRecordVector<CRef> Refs;
+
+ UInt32 LongStreamMinSize;
+ int SectorSizeBits;
+ int MiniSectorSizeBits;
+
+ void Clear();
+ bool IsLargeStream(UInt64 size) const { return size >= LongStreamMinSize; }
+ UString GetItemPath(UInt32 index) const;
+
+ UInt64 GetItemPackSize(UInt64 size) const
+ {
+ UInt64 mask = ((UInt64)1 << (IsLargeStream(size) ? SectorSizeBits : MiniSectorSizeBits)) - 1;
+ return (size + mask) & ~mask;
+ }
+
+ bool GetMiniCluster(UInt32 sid, UInt64 &res) const
+ {
+ int subBits = SectorSizeBits - MiniSectorSizeBits;
+ UInt32 fid = sid >> subBits;
+ if (fid >= NumSectorsInMiniStream)
+ return false;
+ res = (((UInt64)MiniSids[fid] + 1) << subBits) + (sid & ((1 << subBits) - 1));
+ return true;
+ }
+
+ HRESULT Open(IInStream *inStream);
+};
+
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComRegister.cpp
new file mode 100644
index 000000000..c744b04fb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Com/ComRegister.cpp
@@ -0,0 +1,13 @@
+// ComRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "ComHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NCom::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Compound", L"msi doc xls ppt", 0, 0xE5, { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 }, 8, false, CreateArc, 0 };
+
+REGISTER_ARC(Com)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2.cpp
new file mode 100644
index 000000000..aed94f9cf
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2.cpp
@@ -0,0 +1,121 @@
+// CoderMixer2.cpp
+
+#include "StdAfx.h"
+
+#include "CoderMixer2.h"
+
+namespace NCoderMixer {
+
+CBindReverseConverter::CBindReverseConverter(const CBindInfo &srcBindInfo):
+ _srcBindInfo(srcBindInfo)
+{
+ srcBindInfo.GetNumStreams(NumSrcInStreams, _numSrcOutStreams);
+
+ UInt32 j;
+ for (j = 0; j < NumSrcInStreams; j++)
+ {
+ _srcInToDestOutMap.Add(0);
+ DestOutToSrcInMap.Add(0);
+ }
+ for (j = 0; j < _numSrcOutStreams; j++)
+ {
+ _srcOutToDestInMap.Add(0);
+ _destInToSrcOutMap.Add(0);
+ }
+
+ UInt32 destInOffset = 0;
+ UInt32 destOutOffset = 0;
+ UInt32 srcInOffset = NumSrcInStreams;
+ UInt32 srcOutOffset = _numSrcOutStreams;
+
+ for (int i = srcBindInfo.Coders.Size() - 1; i >= 0; i--)
+ {
+ const CCoderStreamsInfo &srcCoderInfo = srcBindInfo.Coders[i];
+
+ srcInOffset -= srcCoderInfo.NumInStreams;
+ srcOutOffset -= srcCoderInfo.NumOutStreams;
+
+ UInt32 j;
+ for (j = 0; j < srcCoderInfo.NumInStreams; j++, destOutOffset++)
+ {
+ UInt32 index = srcInOffset + j;
+ _srcInToDestOutMap[index] = destOutOffset;
+ DestOutToSrcInMap[destOutOffset] = index;
+ }
+ for (j = 0; j < srcCoderInfo.NumOutStreams; j++, destInOffset++)
+ {
+ UInt32 index = srcOutOffset + j;
+ _srcOutToDestInMap[index] = destInOffset;
+ _destInToSrcOutMap[destInOffset] = index;
+ }
+ }
+}
+
+void CBindReverseConverter::CreateReverseBindInfo(CBindInfo &destBindInfo)
+{
+ destBindInfo.Coders.Clear();
+ destBindInfo.BindPairs.Clear();
+ destBindInfo.InStreams.Clear();
+ destBindInfo.OutStreams.Clear();
+
+ int i;
+ for (i = _srcBindInfo.Coders.Size() - 1; i >= 0; i--)
+ {
+ const CCoderStreamsInfo &srcCoderInfo = _srcBindInfo.Coders[i];
+ CCoderStreamsInfo destCoderInfo;
+ destCoderInfo.NumInStreams = srcCoderInfo.NumOutStreams;
+ destCoderInfo.NumOutStreams = srcCoderInfo.NumInStreams;
+ destBindInfo.Coders.Add(destCoderInfo);
+ }
+ for (i = _srcBindInfo.BindPairs.Size() - 1; i >= 0; i--)
+ {
+ const CBindPair &srcBindPair = _srcBindInfo.BindPairs[i];
+ CBindPair destBindPair;
+ destBindPair.InIndex = _srcOutToDestInMap[srcBindPair.OutIndex];
+ destBindPair.OutIndex = _srcInToDestOutMap[srcBindPair.InIndex];
+ destBindInfo.BindPairs.Add(destBindPair);
+ }
+ for (i = 0; i < _srcBindInfo.InStreams.Size(); i++)
+ destBindInfo.OutStreams.Add(_srcInToDestOutMap[_srcBindInfo.InStreams[i]]);
+ for (i = 0; i < _srcBindInfo.OutStreams.Size(); i++)
+ destBindInfo.InStreams.Add(_srcOutToDestInMap[_srcBindInfo.OutStreams[i]]);
+}
+
+CCoderInfo2::CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams):
+ NumInStreams(numInStreams),
+ NumOutStreams(numOutStreams)
+{
+ InSizes.Reserve(NumInStreams);
+ InSizePointers.Reserve(NumInStreams);
+ OutSizePointers.Reserve(NumOutStreams);
+ OutSizePointers.Reserve(NumOutStreams);
+}
+
+static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
+ CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems)
+{
+ sizes.Clear();
+ sizePointers.Clear();
+ for(UInt32 i = 0; i < numItems; i++)
+ {
+ if (srcSizes == 0 || srcSizes[i] == NULL)
+ {
+ sizes.Add(0);
+ sizePointers.Add(NULL);
+ }
+ else
+ {
+ sizes.Add(*srcSizes[i]);
+ sizePointers.Add(&sizes.Back());
+ }
+ }
+}
+
+void CCoderInfo2::SetCoderInfo(const UInt64 **inSizes,
+ const UInt64 **outSizes)
+{
+ SetSizes(inSizes, InSizes, InSizePointers, NumInStreams);
+ SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2.h
new file mode 100644
index 000000000..386e83932
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2.h
@@ -0,0 +1,175 @@
+// CoderMixer2.h
+
+#ifndef __CODER_MIXER2_H
+#define __CODER_MIXER2_H
+
+#include "../../../Common/MyVector.h"
+#include "../../../Common/Types.h"
+#include "../../../Common/MyCom.h"
+#include "../../ICoder.h"
+
+namespace NCoderMixer {
+
+struct CBindPair
+{
+ UInt32 InIndex;
+ UInt32 OutIndex;
+};
+
+struct CCoderStreamsInfo
+{
+ UInt32 NumInStreams;
+ UInt32 NumOutStreams;
+};
+
+struct CBindInfo
+{
+ CRecordVector<CCoderStreamsInfo> Coders;
+ CRecordVector<CBindPair> BindPairs;
+ CRecordVector<UInt32> InStreams;
+ CRecordVector<UInt32> OutStreams;
+
+ void Clear()
+ {
+ Coders.Clear();
+ BindPairs.Clear();
+ InStreams.Clear();
+ OutStreams.Clear();
+ }
+
+ /*
+ UInt32 GetCoderStartOutStream(UInt32 coderIndex) const
+ {
+ UInt32 numOutStreams = 0;
+ for (UInt32 i = 0; i < coderIndex; i++)
+ numOutStreams += Coders[i].NumOutStreams;
+ return numOutStreams;
+ }
+ */
+
+
+ void GetNumStreams(UInt32 &numInStreams, UInt32 &numOutStreams) const
+ {
+ numInStreams = 0;
+ numOutStreams = 0;
+ for (int i = 0; i < Coders.Size(); i++)
+ {
+ const CCoderStreamsInfo &coderStreamsInfo = Coders[i];
+ numInStreams += coderStreamsInfo.NumInStreams;
+ numOutStreams += coderStreamsInfo.NumOutStreams;
+ }
+ }
+
+ int FindBinderForInStream(UInt32 inStream) const
+ {
+ for (int i = 0; i < BindPairs.Size(); i++)
+ if (BindPairs[i].InIndex == inStream)
+ return i;
+ return -1;
+ }
+ int FindBinderForOutStream(UInt32 outStream) const
+ {
+ for (int i = 0; i < BindPairs.Size(); i++)
+ if (BindPairs[i].OutIndex == outStream)
+ return i;
+ return -1;
+ }
+
+ UInt32 GetCoderInStreamIndex(UInt32 coderIndex) const
+ {
+ UInt32 streamIndex = 0;
+ for (UInt32 i = 0; i < coderIndex; i++)
+ streamIndex += Coders[i].NumInStreams;
+ return streamIndex;
+ }
+
+ UInt32 GetCoderOutStreamIndex(UInt32 coderIndex) const
+ {
+ UInt32 streamIndex = 0;
+ for (UInt32 i = 0; i < coderIndex; i++)
+ streamIndex += Coders[i].NumOutStreams;
+ return streamIndex;
+ }
+
+
+ void FindInStream(UInt32 streamIndex, UInt32 &coderIndex,
+ UInt32 &coderStreamIndex) const
+ {
+ for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
+ {
+ UInt32 curSize = Coders[coderIndex].NumInStreams;
+ if (streamIndex < curSize)
+ {
+ coderStreamIndex = streamIndex;
+ return;
+ }
+ streamIndex -= curSize;
+ }
+ throw 1;
+ }
+ void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex,
+ UInt32 &coderStreamIndex) const
+ {
+ for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
+ {
+ UInt32 curSize = Coders[coderIndex].NumOutStreams;
+ if (streamIndex < curSize)
+ {
+ coderStreamIndex = streamIndex;
+ return;
+ }
+ streamIndex -= curSize;
+ }
+ throw 1;
+ }
+};
+
+class CBindReverseConverter
+{
+ UInt32 _numSrcOutStreams;
+ NCoderMixer::CBindInfo _srcBindInfo;
+ CRecordVector<UInt32> _srcInToDestOutMap;
+ CRecordVector<UInt32> _srcOutToDestInMap;
+ CRecordVector<UInt32> _destInToSrcOutMap;
+public:
+ UInt32 NumSrcInStreams;
+ CRecordVector<UInt32> DestOutToSrcInMap;
+
+ CBindReverseConverter(const NCoderMixer::CBindInfo &srcBindInfo);
+ void CreateReverseBindInfo(NCoderMixer::CBindInfo &destBindInfo);
+};
+
+struct CCoderInfo2
+{
+ CMyComPtr<ICompressCoder> Coder;
+ CMyComPtr<ICompressCoder2> Coder2;
+ UInt32 NumInStreams;
+ UInt32 NumOutStreams;
+
+ CRecordVector<UInt64> InSizes;
+ CRecordVector<UInt64> OutSizes;
+ CRecordVector<const UInt64 *> InSizePointers;
+ CRecordVector<const UInt64 *> OutSizePointers;
+
+ CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams);
+ void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes);
+
+ HRESULT QueryInterface(REFGUID iid, void** pp) const
+ {
+ IUnknown *p = Coder ? (IUnknown *)Coder : (IUnknown *)Coder2;
+ return p->QueryInterface(iid, pp);
+ }
+};
+
+class CCoderMixer2
+{
+public:
+ virtual ~CCoderMixer2() {}
+ virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) = 0;
+ virtual void ReInit() = 0;
+ virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0;
+};
+
+}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2MT.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
new file mode 100644
index 000000000..1265dfcde
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
@@ -0,0 +1,230 @@
+// CoderMixer2MT.cpp
+
+#include "StdAfx.h"
+
+#include "CoderMixer2MT.h"
+
+namespace NCoderMixer {
+
+CCoder2::CCoder2(UInt32 numInStreams, UInt32 numOutStreams):
+ CCoderInfo2(numInStreams, numOutStreams)
+{
+ InStreams.Reserve(NumInStreams);
+ InStreamPointers.Reserve(NumInStreams);
+ OutStreams.Reserve(NumOutStreams);
+ OutStreamPointers.Reserve(NumOutStreams);
+}
+
+void CCoder2::Execute() { Code(NULL); }
+
+void CCoder2::Code(ICompressProgressInfo *progress)
+{
+ InStreamPointers.Clear();
+ OutStreamPointers.Clear();
+ UInt32 i;
+ for (i = 0; i < NumInStreams; i++)
+ {
+ if (InSizePointers[i] != NULL)
+ InSizePointers[i] = &InSizes[i];
+ InStreamPointers.Add((ISequentialInStream *)InStreams[i]);
+ }
+ for (i = 0; i < NumOutStreams; i++)
+ {
+ if (OutSizePointers[i] != NULL)
+ OutSizePointers[i] = &OutSizes[i];
+ OutStreamPointers.Add((ISequentialOutStream *)OutStreams[i]);
+ }
+ if (Coder)
+ Result = Coder->Code(InStreamPointers[0], OutStreamPointers[0],
+ InSizePointers[0], OutSizePointers[0], progress);
+ else
+ Result = Coder2->Code(&InStreamPointers.Front(), &InSizePointers.Front(), NumInStreams,
+ &OutStreamPointers.Front(), &OutSizePointers.Front(), NumOutStreams, progress);
+ {
+ int i;
+ for (i = 0; i < InStreams.Size(); i++)
+ InStreams[i].Release();
+ for (i = 0; i < OutStreams.Size(); i++)
+ OutStreams[i].Release();
+ }
+}
+
+static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
+ CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems)
+{
+ sizes.Clear();
+ sizePointers.Clear();
+ for(UInt32 i = 0; i < numItems; i++)
+ {
+ if (srcSizes == 0 || srcSizes[i] == NULL)
+ {
+ sizes.Add(0);
+ sizePointers.Add(NULL);
+ }
+ else
+ {
+ sizes.Add(*srcSizes[i]);
+ sizePointers.Add(&sizes.Back());
+ }
+ }
+}
+
+
+void CCoder2::SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes)
+{
+ SetSizes(inSizes, InSizes, InSizePointers, NumInStreams);
+ SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
+}
+
+//////////////////////////////////////
+// CCoderMixer2MT
+
+HRESULT CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
+{
+ _bindInfo = bindInfo;
+ _streamBinders.Clear();
+ for(int i = 0; i < _bindInfo.BindPairs.Size(); i++)
+ {
+ _streamBinders.Add(CStreamBinder());
+ RINOK(_streamBinders.Back().CreateEvents());
+ }
+ return S_OK;
+}
+
+void CCoderMixer2MT::AddCoderCommon()
+{
+ const CCoderStreamsInfo &c = _bindInfo.Coders[_coders.Size()];
+ CCoder2 threadCoderInfo(c.NumInStreams, c.NumOutStreams);
+ _coders.Add(threadCoderInfo);
+}
+
+void CCoderMixer2MT::AddCoder(ICompressCoder *coder)
+{
+ AddCoderCommon();
+ _coders.Back().Coder = coder;
+}
+
+void CCoderMixer2MT::AddCoder2(ICompressCoder2 *coder)
+{
+ AddCoderCommon();
+ _coders.Back().Coder2 = coder;
+}
+
+
+void CCoderMixer2MT::ReInit()
+{
+ for(int i = 0; i < _streamBinders.Size(); i++)
+ _streamBinders[i].ReInit();
+}
+
+
+HRESULT CCoderMixer2MT::Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams)
+{
+ /*
+ if (_coders.Size() != _bindInfo.Coders.Size())
+ throw 0;
+ */
+ int i;
+ for(i = 0; i < _coders.Size(); i++)
+ {
+ CCoder2 &coderInfo = _coders[i];
+ const CCoderStreamsInfo &coderStreamsInfo = _bindInfo.Coders[i];
+ coderInfo.InStreams.Clear();
+ UInt32 j;
+ for(j = 0; j < coderStreamsInfo.NumInStreams; j++)
+ coderInfo.InStreams.Add(NULL);
+ coderInfo.OutStreams.Clear();
+ for(j = 0; j < coderStreamsInfo.NumOutStreams; j++)
+ coderInfo.OutStreams.Add(NULL);
+ }
+
+ for(i = 0; i < _bindInfo.BindPairs.Size(); i++)
+ {
+ const CBindPair &bindPair = _bindInfo.BindPairs[i];
+ UInt32 inCoderIndex, inCoderStreamIndex;
+ UInt32 outCoderIndex, outCoderStreamIndex;
+ _bindInfo.FindInStream(bindPair.InIndex, inCoderIndex, inCoderStreamIndex);
+ _bindInfo.FindOutStream(bindPair.OutIndex, outCoderIndex, outCoderStreamIndex);
+
+ _streamBinders[i].CreateStreams(
+ &_coders[inCoderIndex].InStreams[inCoderStreamIndex],
+ &_coders[outCoderIndex].OutStreams[outCoderStreamIndex]);
+ }
+
+ for(i = 0; i < _bindInfo.InStreams.Size(); i++)
+ {
+ UInt32 inCoderIndex, inCoderStreamIndex;
+ _bindInfo.FindInStream(_bindInfo.InStreams[i], inCoderIndex, inCoderStreamIndex);
+ _coders[inCoderIndex].InStreams[inCoderStreamIndex] = inStreams[i];
+ }
+
+ for(i = 0; i < _bindInfo.OutStreams.Size(); i++)
+ {
+ UInt32 outCoderIndex, outCoderStreamIndex;
+ _bindInfo.FindOutStream(_bindInfo.OutStreams[i], outCoderIndex, outCoderStreamIndex);
+ _coders[outCoderIndex].OutStreams[outCoderStreamIndex] = outStreams[i];
+ }
+ return S_OK;
+}
+
+HRESULT CCoderMixer2MT::ReturnIfError(HRESULT code)
+{
+ for (int i = 0; i < _coders.Size(); i++)
+ if (_coders[i].Result == code)
+ return code;
+ return S_OK;
+}
+
+STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams,
+ const UInt64 ** /* inSizes */,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 ** /* outSizes */,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress)
+{
+ if (numInStreams != (UInt32)_bindInfo.InStreams.Size() ||
+ numOutStreams != (UInt32)_bindInfo.OutStreams.Size())
+ return E_INVALIDARG;
+
+ Init(inStreams, outStreams);
+
+ int i;
+ for (i = 0; i < _coders.Size(); i++)
+ if (i != _progressCoderIndex)
+ {
+ RINOK(_coders[i].Create());
+ }
+
+ for (i = 0; i < _coders.Size(); i++)
+ if (i != _progressCoderIndex)
+ _coders[i].Start();
+
+ _coders[_progressCoderIndex].Code(progress);
+
+ for (i = 0; i < _coders.Size(); i++)
+ if (i != _progressCoderIndex)
+ _coders[i].WaitFinish();
+
+ RINOK(ReturnIfError(E_ABORT));
+ RINOK(ReturnIfError(E_OUTOFMEMORY));
+
+ for (i = 0; i < _coders.Size(); i++)
+ {
+ HRESULT result = _coders[i].Result;
+ if (result != S_OK && result != E_FAIL && result != S_FALSE)
+ return result;
+ }
+
+ RINOK(ReturnIfError(S_FALSE));
+
+ for (i = 0; i < _coders.Size(); i++)
+ {
+ HRESULT result = _coders[i].Result;
+ if (result != S_OK)
+ return result;
+ }
+ return S_OK;
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2MT.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2MT.h
new file mode 100644
index 000000000..d1c7f4d07
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2MT.h
@@ -0,0 +1,80 @@
+// CoderMixer2MT.h
+
+#ifndef __CODER_MIXER2_MT_H
+#define __CODER_MIXER2_MT_H
+
+#include "CoderMixer2.h"
+#include "../../../Common/MyCom.h"
+#include "../../Common/StreamBinder.h"
+#include "../../Common/VirtThread.h"
+
+namespace NCoderMixer {
+
+struct CCoder2: public CCoderInfo2, public CVirtThread
+{
+ HRESULT Result;
+ CObjectVector< CMyComPtr<ISequentialInStream> > InStreams;
+ CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams;
+ CRecordVector<ISequentialInStream*> InStreamPointers;
+ CRecordVector<ISequentialOutStream*> OutStreamPointers;
+
+ CCoder2(UInt32 numInStreams, UInt32 numOutStreams);
+ void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes);
+ virtual void Execute();
+ void Code(ICompressProgressInfo *progress);
+};
+
+
+/*
+ SetBindInfo()
+ for each coder
+ AddCoder[2]()
+ SetProgressIndex(UInt32 coderIndex);
+
+ for each file
+ {
+ ReInit()
+ for each coder
+ SetCoderInfo
+ Code
+ }
+*/
+
+class CCoderMixer2MT:
+ public ICompressCoder2,
+ public CCoderMixer2,
+ public CMyUnknownImp
+{
+ CBindInfo _bindInfo;
+ CObjectVector<CStreamBinder> _streamBinders;
+ int _progressCoderIndex;
+
+ void AddCoderCommon();
+ HRESULT Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams);
+ HRESULT ReturnIfError(HRESULT code);
+public:
+ CObjectVector<CCoder2> _coders;
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Code)(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 **outSizes,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress);
+
+ HRESULT SetBindInfo(const CBindInfo &bindInfo);
+ void AddCoder(ICompressCoder *coder);
+ void AddCoder2(ICompressCoder2 *coder);
+ void SetProgressCoderIndex(int coderIndex) { _progressCoderIndex = coderIndex; }
+
+ void ReInit();
+ void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes)
+ { _coders[coderIndex].SetCoderInfo(inSizes, outSizes); }
+ UInt64 GetWriteProcessedSize(UInt32 binderIndex) const
+ { return _streamBinders[binderIndex].ProcessedSize; }
+};
+
+}
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2ST.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
new file mode 100644
index 000000000..a59ce5fc0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
@@ -0,0 +1,239 @@
+// CoderMixer2ST.cpp
+
+#include "StdAfx.h"
+
+#include "CoderMixer2ST.h"
+
+namespace NCoderMixer2 {
+
+CCoderMixer2ST::CCoderMixer2ST() {}
+
+CCoderMixer2ST::~CCoderMixer2ST(){ }
+
+HRESULT CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo)
+{
+ _bindInfo = bindInfo;
+ return S_OK;
+}
+
+void CCoderMixer2ST::AddCoderCommon(bool isMain)
+{
+ const CCoderStreamsInfo &csi = _bindInfo.Coders[_coders.Size()];
+ _coders.Add(CSTCoderInfo(csi.NumInStreams, csi.NumOutStreams, isMain));
+}
+
+void CCoderMixer2ST::AddCoder(ICompressCoder *coder, bool isMain)
+{
+ AddCoderCommon(isMain);
+ _coders.Back().Coder = coder;
+}
+
+void CCoderMixer2ST::AddCoder2(ICompressCoder2 *coder, bool isMain)
+{
+ AddCoderCommon(isMain);
+ _coders.Back().Coder2 = coder;
+}
+
+void CCoderMixer2ST::ReInit() { }
+
+HRESULT CCoderMixer2ST::GetInStream(
+ ISequentialInStream **inStreams, const UInt64 **inSizes,
+ UInt32 streamIndex, ISequentialInStream **inStreamRes)
+{
+ CMyComPtr<ISequentialInStream> seqInStream;
+ int i;
+ for(i = 0; i < _bindInfo.InStreams.Size(); i++)
+ if (_bindInfo.InStreams[i] == streamIndex)
+ {
+ seqInStream = inStreams[i];
+ *inStreamRes = seqInStream.Detach();
+ return S_OK;
+ }
+ int binderIndex = _bindInfo.FindBinderForInStream(streamIndex);
+ if (binderIndex < 0)
+ return E_INVALIDARG;
+
+ UInt32 coderIndex, coderStreamIndex;
+ _bindInfo.FindOutStream(_bindInfo.BindPairs[binderIndex].OutIndex,
+ coderIndex, coderStreamIndex);
+
+ CCoderInfo &coder = _coders[coderIndex];
+ if (!coder.Coder)
+ return E_NOTIMPL;
+ coder.Coder.QueryInterface(IID_ISequentialInStream, &seqInStream);
+ if (!seqInStream)
+ return E_NOTIMPL;
+
+ UInt32 startIndex = _bindInfo.GetCoderInStreamIndex(coderIndex);
+
+ CMyComPtr<ICompressSetInStream> setInStream;
+ if (!coder.Coder)
+ return E_NOTIMPL;
+ coder.Coder.QueryInterface(IID_ICompressSetInStream, &setInStream);
+ if (!setInStream)
+ return E_NOTIMPL;
+
+ if (coder.NumInStreams > 1)
+ return E_NOTIMPL;
+ for (i = 0; i < (int)coder.NumInStreams; i++)
+ {
+ CMyComPtr<ISequentialInStream> seqInStream2;
+ RINOK(GetInStream(inStreams, inSizes, startIndex + i, &seqInStream2));
+ RINOK(setInStream->SetInStream(seqInStream2));
+ }
+ *inStreamRes = seqInStream.Detach();
+ return S_OK;
+}
+
+HRESULT CCoderMixer2ST::GetOutStream(
+ ISequentialOutStream **outStreams, const UInt64 **outSizes,
+ UInt32 streamIndex, ISequentialOutStream **outStreamRes)
+{
+ CMyComPtr<ISequentialOutStream> seqOutStream;
+ int i;
+ for(i = 0; i < _bindInfo.OutStreams.Size(); i++)
+ if (_bindInfo.OutStreams[i] == streamIndex)
+ {
+ seqOutStream = outStreams[i];
+ *outStreamRes = seqOutStream.Detach();
+ return S_OK;
+ }
+ int binderIndex = _bindInfo.FindBinderForOutStream(streamIndex);
+ if (binderIndex < 0)
+ return E_INVALIDARG;
+
+ UInt32 coderIndex, coderStreamIndex;
+ _bindInfo.FindInStream(_bindInfo.BindPairs[binderIndex].InIndex,
+ coderIndex, coderStreamIndex);
+
+ CCoderInfo &coder = _coders[coderIndex];
+ if (!coder.Coder)
+ return E_NOTIMPL;
+ coder.Coder.QueryInterface(IID_ISequentialOutStream, &seqOutStream);
+ if (!seqOutStream)
+ return E_NOTIMPL;
+
+ UInt32 startIndex = _bindInfo.GetCoderOutStreamIndex(coderIndex);
+
+ CMyComPtr<ICompressSetOutStream> setOutStream;
+ if (!coder.Coder)
+ return E_NOTIMPL;
+ coder.Coder.QueryInterface(IID_ICompressSetOutStream, &setOutStream);
+ if (!setOutStream)
+ return E_NOTIMPL;
+
+ if (coder.NumOutStreams > 1)
+ return E_NOTIMPL;
+ for (i = 0; i < (int)coder.NumOutStreams; i++)
+ {
+ CMyComPtr<ISequentialOutStream> seqOutStream2;
+ RINOK(GetOutStream(outStreams, outSizes, startIndex + i, &seqOutStream2));
+ RINOK(setOutStream->SetOutStream(seqOutStream2));
+ }
+ *outStreamRes = seqOutStream.Detach();
+ return S_OK;
+}
+
+
+STDMETHODIMP CCoderMixer2ST::Code(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 **outSizes,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress)
+{
+ if (numInStreams != (UInt32)_bindInfo.InStreams.Size() ||
+ numOutStreams != (UInt32)_bindInfo.OutStreams.Size())
+ return E_INVALIDARG;
+
+ // Find main coder
+ int _mainCoderIndex = -1;
+ int i;
+ for (i = 0; i < _coders.Size(); i++)
+ if (_coders[i].IsMain)
+ {
+ _mainCoderIndex = i;
+ break;
+ }
+ if (_mainCoderIndex < 0)
+ for (i = 0; i < _coders.Size(); i++)
+ if (_coders[i].NumInStreams > 1)
+ {
+ if (_mainCoderIndex >= 0)
+ return E_NOTIMPL;
+ _mainCoderIndex = i;
+ }
+ if (_mainCoderIndex < 0)
+ _mainCoderIndex = 0;
+
+ // _mainCoderIndex = 0;
+ // _mainCoderIndex = _coders.Size() - 1;
+ CCoderInfo &mainCoder = _coders[_mainCoderIndex];
+
+ CObjectVector< CMyComPtr<ISequentialInStream> > seqInStreams;
+ CObjectVector< CMyComPtr<ISequentialOutStream> > seqOutStreams;
+ UInt32 startInIndex = _bindInfo.GetCoderInStreamIndex(_mainCoderIndex);
+ UInt32 startOutIndex = _bindInfo.GetCoderOutStreamIndex(_mainCoderIndex);
+ for (i = 0; i < (int)mainCoder.NumInStreams; i++)
+ {
+ CMyComPtr<ISequentialInStream> seqInStream;
+ RINOK(GetInStream(inStreams, inSizes, startInIndex + i, &seqInStream));
+ seqInStreams.Add(seqInStream);
+ }
+ for (i = 0; i < (int)mainCoder.NumOutStreams; i++)
+ {
+ CMyComPtr<ISequentialOutStream> seqOutStream;
+ RINOK(GetOutStream(outStreams, outSizes, startOutIndex + i, &seqOutStream));
+ seqOutStreams.Add(seqOutStream);
+ }
+ CRecordVector< ISequentialInStream * > seqInStreamsSpec;
+ CRecordVector< ISequentialOutStream * > seqOutStreamsSpec;
+ for (i = 0; i < (int)mainCoder.NumInStreams; i++)
+ seqInStreamsSpec.Add(seqInStreams[i]);
+ for (i = 0; i < (int)mainCoder.NumOutStreams; i++)
+ seqOutStreamsSpec.Add(seqOutStreams[i]);
+
+ for (i = 0; i < _coders.Size(); i++)
+ {
+ if (i == _mainCoderIndex)
+ continue;
+ CCoderInfo &coder = _coders[i];
+ CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
+ coder.Coder.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize);
+ if (setOutStreamSize)
+ {
+ RINOK(setOutStreamSize->SetOutStreamSize(coder.OutSizePointers[0]));
+ }
+ }
+ if (mainCoder.Coder)
+ {
+ RINOK(mainCoder.Coder->Code(
+ seqInStreamsSpec[0], seqOutStreamsSpec[0],
+ mainCoder.InSizePointers[0], mainCoder.OutSizePointers[0],
+ progress));
+ }
+ else
+ {
+ RINOK(mainCoder.Coder2->Code(
+ &seqInStreamsSpec.Front(),
+ &mainCoder.InSizePointers.Front(), mainCoder.NumInStreams,
+ &seqOutStreamsSpec.Front(),
+ &mainCoder.OutSizePointers.Front(), mainCoder.NumOutStreams,
+ progress));
+ }
+ CMyComPtr<IOutStreamFlush> flush;
+ seqOutStreams.Front().QueryInterface(IID_IOutStreamFlush, &flush);
+ if (flush)
+ return flush->Flush();
+ return S_OK;
+}
+
+/*
+UInt64 CCoderMixer2ST::GetWriteProcessedSize(UInt32 binderIndex) const
+{
+ return _streamBinders[binderIndex].ProcessedSize;
+}
+*/
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2ST.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2ST.h
new file mode 100644
index 000000000..a4ea7e80d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CoderMixer2ST.h
@@ -0,0 +1,88 @@
+// CoderMixer2ST.h
+
+#ifndef __CODER_MIXER2_ST_H
+#define __CODER_MIXER2_ST_H
+
+#include "CoderMixer2.h"
+#include "../../../Common/MyCom.h"
+#include "../../ICoder.h"
+
+namespace NCoderMixer2 {
+
+// SetBindInfo()
+// for each coder
+// {
+// AddCoder[2]()
+// }
+//
+// for each file
+// {
+// ReInit()
+// for each coder
+// {
+// SetCoderInfo
+// }
+// SetProgressIndex(UInt32 coderIndex);
+// Code
+// }
+
+struct CSTCoderInfo: public CCoderInfo
+{
+ bool IsMain;
+ CSTCoderInfo(UInt32 numInStreams, UInt32 numOutStreams, bool isMain):
+ CCoderInfo(numInStreams, numOutStreams),IsMain(isMain) {}
+};
+
+class CCoderMixer2ST:
+ public ICompressCoder2,
+ public CCoderMixer2,
+ public CMyUnknownImp
+{
+ MY_UNKNOWN_IMP
+
+ HRESULT GetInStream(
+ ISequentialInStream **inStreams, const UInt64 **inSizes,
+ UInt32 streamIndex, ISequentialInStream **inStreamRes);
+ HRESULT GetOutStream(
+ ISequentialOutStream **outStreams, const UInt64 **outSizes,
+ UInt32 streamIndex, ISequentialOutStream **outStreamRes);
+public:
+ STDMETHOD(Code)(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 **outSizes,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress);
+
+ CCoderMixer2ST();
+ ~CCoderMixer2ST();
+ void AddCoderCommon(bool isMain);
+ void AddCoder(ICompressCoder *coder, bool isMain);
+ void AddCoder2(ICompressCoder2 *coder, bool isMain);
+
+ void ReInit();
+ void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes)
+ {
+ { _coders[coderIndex].SetCoderInfo(inSizes, outSizes); }
+ }
+
+ void SetProgressCoderIndex(UInt32 /*coderIndex*/)
+ {
+ // _progressCoderIndex = coderIndex;
+ }
+
+ // UInt64 GetWriteProcessedSize(UInt32 binderIndex) const;
+
+private:
+ CBindInfo _bindInfo;
+ CObjectVector<CSTCoderInfo> _coders;
+ int _mainCoderIndex;
+public:
+ HRESULT SetBindInfo(const CBindInfo &bindInfo);
+
+};
+
+}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CrossThreadProgress.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CrossThreadProgress.cpp
new file mode 100644
index 000000000..a974b54c7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CrossThreadProgress.cpp
@@ -0,0 +1,15 @@
+// CrossThreadProgress.cpp
+
+#include "StdAfx.h"
+
+#include "CrossThreadProgress.h"
+
+STDMETHODIMP CCrossThreadProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ InSize = inSize;
+ OutSize = outSize;
+ ProgressEvent.Set();
+ WaitEvent.Lock();
+ return Result;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CrossThreadProgress.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CrossThreadProgress.h
new file mode 100644
index 000000000..7e0b10538
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/CrossThreadProgress.h
@@ -0,0 +1,37 @@
+// CrossThreadProgress.h
+
+#ifndef __CROSSTHREADPROGRESS_H
+#define __CROSSTHREADPROGRESS_H
+
+#include "../../ICoder.h"
+#include "../../../Windows/Synchronization.h"
+#include "../../../Common/MyCom.h"
+
+class CCrossThreadProgress:
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+public:
+ const UInt64 *InSize;
+ const UInt64 *OutSize;
+ HRESULT Result;
+ NWindows::NSynchronization::CAutoResetEvent ProgressEvent;
+ NWindows::NSynchronization::CAutoResetEvent WaitEvent;
+
+ HRes Create()
+ {
+ RINOK(ProgressEvent.CreateIfNotCreated());
+ return WaitEvent.CreateIfNotCreated();
+ }
+ void Init()
+ {
+ ProgressEvent.Reset();
+ WaitEvent.Reset();
+ }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/DummyOutStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/DummyOutStream.cpp
new file mode 100644
index 000000000..54bcfec11
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/DummyOutStream.cpp
@@ -0,0 +1,22 @@
+// DummyOutStream.cpp
+
+#include "StdAfx.h"
+
+#include "DummyOutStream.h"
+
+STDMETHODIMP CDummyOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize;
+ HRESULT result;
+ if(!_stream)
+ {
+ realProcessedSize = size;
+ result = S_OK;
+ }
+ else
+ result = _stream->Write(data, size, &realProcessedSize);
+ _size += realProcessedSize;
+ if(processedSize != NULL)
+ *processedSize = realProcessedSize;
+ return result;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/DummyOutStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/DummyOutStream.h
new file mode 100644
index 000000000..13d5b62ca
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/DummyOutStream.h
@@ -0,0 +1,24 @@
+// DummyOutStream.h
+
+#ifndef __DUMMYOUTSTREAM_H
+#define __DUMMYOUTSTREAM_H
+
+#include "../../IStream.h"
+#include "Common/MyCom.h"
+
+class CDummyOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialOutStream> _stream;
+ UInt64 _size;
+public:
+ void SetStream(ISequentialOutStream *outStream) { _stream = outStream; }
+ void ReleaseStream() { _stream.Release(); }
+ void Init() { _size = 0; }
+ MY_UNKNOWN_IMP
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ UInt64 GetSize() const { return _size; }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/FindSignature.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/FindSignature.cpp
new file mode 100644
index 000000000..15aa6ceae
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/FindSignature.cpp
@@ -0,0 +1,62 @@
+// FindSignature.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Buffer.h"
+
+#include "FindSignature.h"
+
+#include "../../Common/StreamUtils.h"
+
+HRESULT FindSignatureInStream(ISequentialInStream *stream,
+ const Byte *signature, unsigned signatureSize,
+ const UInt64 *limit, UInt64 &resPos)
+{
+ resPos = 0;
+ CByteBuffer byteBuffer2;
+ byteBuffer2.SetCapacity(signatureSize);
+ RINOK(ReadStream_FALSE(stream, byteBuffer2, signatureSize));
+
+ if (memcmp(byteBuffer2, signature, signatureSize) == 0)
+ return S_OK;
+
+ const UInt32 kBufferSize = (1 << 16);
+ CByteBuffer byteBuffer;
+ byteBuffer.SetCapacity(kBufferSize);
+ Byte *buffer = byteBuffer;
+ UInt32 numPrevBytes = signatureSize - 1;
+ memcpy(buffer, (const Byte *)byteBuffer2 + 1, numPrevBytes);
+ resPos = 1;
+ for (;;)
+ {
+ if (limit != NULL)
+ if (resPos > *limit)
+ return S_FALSE;
+ do
+ {
+ UInt32 numReadBytes = kBufferSize - numPrevBytes;
+ UInt32 processedSize;
+ RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize));
+ numPrevBytes += processedSize;
+ if (processedSize == 0)
+ return S_FALSE;
+ }
+ while (numPrevBytes < signatureSize);
+ UInt32 numTests = numPrevBytes - signatureSize + 1;
+ for (UInt32 pos = 0; pos < numTests; pos++)
+ {
+ Byte b = signature[0];
+ for (; buffer[pos] != b && pos < numTests; pos++);
+ if (pos == numTests)
+ break;
+ if (memcmp(buffer + pos, signature, signatureSize) == 0)
+ {
+ resPos += pos;
+ return S_OK;
+ }
+ }
+ resPos += numTests;
+ numPrevBytes -= numTests;
+ memmove(buffer, buffer + numTests, numPrevBytes);
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/FindSignature.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/FindSignature.h
new file mode 100644
index 000000000..e15af5732
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/FindSignature.h
@@ -0,0 +1,12 @@
+// FindSignature.h
+
+#ifndef __FINDSIGNATURE_H
+#define __FINDSIGNATURE_H
+
+#include "../../IStream.h"
+
+HRESULT FindSignatureInStream(ISequentialInStream *stream,
+ const Byte *signature, unsigned signatureSize,
+ const UInt64 *limit, UInt64 &resPos);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/HandlerOut.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/HandlerOut.cpp
new file mode 100644
index 000000000..1af239b51
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/HandlerOut.cpp
@@ -0,0 +1,623 @@
+// HandlerOut.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Common/StringToInt.h"
+
+#include "../../../Windows/PropVariant.h"
+
+#ifdef COMPRESS_MT
+#include "../../../Windows/System.h"
+#endif
+
+#include "../../ICoder.h"
+
+#include "../Common/ParseProperties.h"
+
+#include "HandlerOut.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+
+//static const wchar_t *kCopyMethod = L"Copy";
+static const wchar_t *kLZMAMethodName = L"LZMA";
+static const wchar_t *kLZMA2MethodName = L"LZMA2";
+static const wchar_t *kBZip2MethodName = L"BZip2";
+static const wchar_t *kPpmdMethodName = L"PPMd";
+static const wchar_t *kDeflateMethodName = L"Deflate";
+static const wchar_t *kDeflate64MethodName = L"Deflate64";
+
+static const wchar_t *kLzmaMatchFinderX1 = L"HC4";
+static const wchar_t *kLzmaMatchFinderX5 = L"BT4";
+
+static const UInt32 kLzmaAlgoX1 = 0;
+static const UInt32 kLzmaAlgoX5 = 1;
+
+static const UInt32 kLzmaDicSizeX1 = 1 << 16;
+static const UInt32 kLzmaDicSizeX3 = 1 << 20;
+static const UInt32 kLzmaDicSizeX5 = 1 << 24;
+static const UInt32 kLzmaDicSizeX7 = 1 << 25;
+static const UInt32 kLzmaDicSizeX9 = 1 << 26;
+
+static const UInt32 kLzmaFastBytesX1 = 32;
+static const UInt32 kLzmaFastBytesX7 = 64;
+
+static const UInt32 kPpmdMemSizeX1 = (1 << 22);
+static const UInt32 kPpmdMemSizeX5 = (1 << 24);
+static const UInt32 kPpmdMemSizeX7 = (1 << 26);
+static const UInt32 kPpmdMemSizeX9 = (192 << 20);
+
+static const UInt32 kPpmdOrderX1 = 4;
+static const UInt32 kPpmdOrderX5 = 6;
+static const UInt32 kPpmdOrderX7 = 16;
+static const UInt32 kPpmdOrderX9 = 32;
+
+static const UInt32 kDeflateAlgoX1 = 0;
+static const UInt32 kDeflateAlgoX5 = 1;
+
+static const UInt32 kDeflateFastBytesX1 = 32;
+static const UInt32 kDeflateFastBytesX7 = 64;
+static const UInt32 kDeflateFastBytesX9 = 128;
+
+static const UInt32 kDeflatePassesX1 = 1;
+static const UInt32 kDeflatePassesX7 = 3;
+static const UInt32 kDeflatePassesX9 = 10;
+
+static const UInt32 kBZip2NumPassesX1 = 1;
+static const UInt32 kBZip2NumPassesX7 = 2;
+static const UInt32 kBZip2NumPassesX9 = 7;
+
+static const UInt32 kBZip2DicSizeX1 = 100000;
+static const UInt32 kBZip2DicSizeX3 = 500000;
+static const UInt32 kBZip2DicSizeX5 = 900000;
+
+static const wchar_t *kDefaultMethodName = kLZMAMethodName;
+
+//static const wchar_t *kLzmaMatchFinderForHeaders = L"BT2";
+static const UInt32 kDictionaryForHeaders = 1 << 20;
+static const UInt32 kNumFastBytesForHeaders = 273;
+static const UInt32 kAlgorithmForHeaders = kLzmaAlgoX5;
+
+static bool AreEqual(const UString &methodName, const wchar_t *s)
+ { return (methodName.CompareNoCase(s) == 0); }
+
+bool COneMethodInfo::IsLzma() const
+{
+ return
+ AreEqual(MethodName, kLZMAMethodName) ||
+ AreEqual(MethodName, kLZMA2MethodName);
+}
+
+static inline bool IsBZip2Method(const UString &methodName)
+ { return AreEqual(methodName, kBZip2MethodName); }
+
+static inline bool IsPpmdMethod(const UString &methodName)
+ { return AreEqual(methodName, kPpmdMethodName); }
+
+static inline bool IsDeflateMethod(const UString &methodName)
+{
+ return
+ AreEqual(methodName, kDeflateMethodName) ||
+ AreEqual(methodName, kDeflate64MethodName);
+}
+
+struct CNameToPropID
+{
+ PROPID PropID;
+ VARTYPE VarType;
+ const wchar_t *Name;
+};
+
+static CNameToPropID g_NameToPropID[] =
+{
+ { NCoderPropID::kBlockSize, VT_UI4, L"C" },
+ { NCoderPropID::kDictionarySize, VT_UI4, L"D" },
+ { NCoderPropID::kUsedMemorySize, VT_UI4, L"MEM" },
+
+ { NCoderPropID::kOrder, VT_UI4, L"O" },
+ { NCoderPropID::kPosStateBits, VT_UI4, L"PB" },
+ { NCoderPropID::kLitContextBits, VT_UI4, L"LC" },
+ { NCoderPropID::kLitPosBits, VT_UI4, L"LP" },
+ { NCoderPropID::kEndMarker, VT_BOOL, L"eos" },
+
+ { NCoderPropID::kNumPasses, VT_UI4, L"Pass" },
+ { NCoderPropID::kNumFastBytes, VT_UI4, L"fb" },
+ { NCoderPropID::kMatchFinderCycles, VT_UI4, L"mc" },
+ { NCoderPropID::kAlgorithm, VT_UI4, L"a" },
+ { NCoderPropID::kMatchFinder, VT_BSTR, L"mf" },
+ { NCoderPropID::kNumThreads, VT_UI4, L"mt" },
+ { NCoderPropID::kDefaultProp, VT_UI4, L"" }
+};
+
+static bool ConvertProperty(PROPVARIANT srcProp, VARTYPE varType, NCOM::CPropVariant &destProp)
+{
+ if (varType == srcProp.vt)
+ {
+ destProp = srcProp;
+ return true;
+ }
+ if (varType == VT_UI1)
+ {
+ if (srcProp.vt == VT_UI4)
+ {
+ UInt32 value = srcProp.ulVal;
+ if (value > 0xFF)
+ return false;
+ destProp = (Byte)value;
+ return true;
+ }
+ }
+ else if (varType == VT_BOOL)
+ {
+ bool res;
+ if (SetBoolProperty(res, srcProp) != S_OK)
+ return false;
+ destProp = res;
+ return true;
+ }
+ return false;
+}
+
+static int FindPropIdExact(const UString &name)
+{
+ for (unsigned int i = 0; i < sizeof(g_NameToPropID) / sizeof(g_NameToPropID[0]); i++)
+ if (name.CompareNoCase(g_NameToPropID[i].Name) == 0)
+ return i;
+ return -1;
+}
+
+static int FindPropIdStart(const UString &name)
+{
+ for (unsigned int i = 0; i < sizeof(g_NameToPropID) / sizeof(g_NameToPropID[0]); i++)
+ {
+ UString t = g_NameToPropID[i].Name;
+ if (t.CompareNoCase(name.Left(t.Length())) == 0)
+ return i;
+ }
+ return -1;
+}
+
+static void SetMethodProp(COneMethodInfo &m, PROPID propID, const NCOM::CPropVariant &value)
+{
+ for (int j = 0; j < m.Props.Size(); j++)
+ if (m.Props[j].Id == propID)
+ return;
+ CProp prop;
+ prop.Id = propID;
+ prop.Value = value;
+ m.Props.Add(prop);
+}
+
+void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo
+ #ifdef COMPRESS_MT
+ , UInt32 numThreads
+ #endif
+ )
+{
+ UInt32 level = _level;
+ if (oneMethodInfo.MethodName.IsEmpty())
+ oneMethodInfo.MethodName = kDefaultMethodName;
+
+ if (oneMethodInfo.IsLzma())
+ {
+ UInt32 dicSize =
+ (level >= 9 ? kLzmaDicSizeX9 :
+ (level >= 7 ? kLzmaDicSizeX7 :
+ (level >= 5 ? kLzmaDicSizeX5 :
+ (level >= 3 ? kLzmaDicSizeX3 :
+ kLzmaDicSizeX1))));
+
+ UInt32 algo =
+ (level >= 5 ? kLzmaAlgoX5 :
+ kLzmaAlgoX1);
+
+ UInt32 fastBytes =
+ (level >= 7 ? kLzmaFastBytesX7 :
+ kLzmaFastBytesX1);
+
+ const wchar_t *matchFinder =
+ (level >= 5 ? kLzmaMatchFinderX5 :
+ kLzmaMatchFinderX1);
+
+ SetMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
+ SetMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo);
+ SetMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
+ SetMethodProp(oneMethodInfo, NCoderPropID::kMatchFinder, matchFinder);
+ #ifdef COMPRESS_MT
+ SetMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
+ #endif
+ }
+ else if (IsDeflateMethod(oneMethodInfo.MethodName))
+ {
+ UInt32 fastBytes =
+ (level >= 9 ? kDeflateFastBytesX9 :
+ (level >= 7 ? kDeflateFastBytesX7 :
+ kDeflateFastBytesX1));
+
+ UInt32 numPasses =
+ (level >= 9 ? kDeflatePassesX9 :
+ (level >= 7 ? kDeflatePassesX7 :
+ kDeflatePassesX1));
+
+ UInt32 algo =
+ (level >= 5 ? kDeflateAlgoX5 :
+ kDeflateAlgoX1);
+
+ SetMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo);
+ SetMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
+ SetMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
+ }
+ else if (IsBZip2Method(oneMethodInfo.MethodName))
+ {
+ UInt32 numPasses =
+ (level >= 9 ? kBZip2NumPassesX9 :
+ (level >= 7 ? kBZip2NumPassesX7 :
+ kBZip2NumPassesX1));
+
+ UInt32 dicSize =
+ (level >= 5 ? kBZip2DicSizeX5 :
+ (level >= 3 ? kBZip2DicSizeX3 :
+ kBZip2DicSizeX1));
+
+ SetMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
+ SetMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
+ #ifdef COMPRESS_MT
+ SetMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
+ #endif
+ }
+ else if (IsPpmdMethod(oneMethodInfo.MethodName))
+ {
+ UInt32 useMemSize =
+ (level >= 9 ? kPpmdMemSizeX9 :
+ (level >= 7 ? kPpmdMemSizeX7 :
+ (level >= 5 ? kPpmdMemSizeX5 :
+ kPpmdMemSizeX1)));
+
+ UInt32 order =
+ (level >= 9 ? kPpmdOrderX9 :
+ (level >= 7 ? kPpmdOrderX7 :
+ (level >= 5 ? kPpmdOrderX5 :
+ kPpmdOrderX1)));
+
+ SetMethodProp(oneMethodInfo, NCoderPropID::kUsedMemorySize, useMemSize);
+ SetMethodProp(oneMethodInfo, NCoderPropID::kOrder, order);
+ }
+}
+
+static void SplitParams(const UString &srcString, UStringVector &subStrings)
+{
+ subStrings.Clear();
+ UString name;
+ int len = srcString.Length();
+ if (len == 0)
+ return;
+ for (int i = 0; i < len; i++)
+ {
+ wchar_t c = srcString[i];
+ if (c == L':')
+ {
+ subStrings.Add(name);
+ name.Empty();
+ }
+ else
+ name += c;
+ }
+ subStrings.Add(name);
+}
+
+static void SplitParam(const UString &param, UString &name, UString &value)
+{
+ int eqPos = param.Find(L'=');
+ if (eqPos >= 0)
+ {
+ name = param.Left(eqPos);
+ value = param.Mid(eqPos + 1);
+ return;
+ }
+ for(int i = 0; i < param.Length(); i++)
+ {
+ wchar_t c = param[i];
+ if (c >= L'0' && c <= L'9')
+ {
+ name = param.Left(i);
+ value = param.Mid(i);
+ return;
+ }
+ }
+ name = param;
+}
+
+HRESULT COutHandler::SetParam(COneMethodInfo &oneMethodInfo, const UString &name, const UString &value)
+{
+ CProp prop;
+ int index = FindPropIdExact(name);
+ if (index < 0)
+ return E_INVALIDARG;
+ const CNameToPropID &nameToPropID = g_NameToPropID[index];
+ prop.Id = nameToPropID.PropID;
+
+ if (prop.Id == NCoderPropID::kBlockSize ||
+ prop.Id == NCoderPropID::kDictionarySize ||
+ prop.Id == NCoderPropID::kUsedMemorySize)
+ {
+ UInt32 dicSize;
+ RINOK(ParsePropDictionaryValue(value, dicSize));
+ prop.Value = dicSize;
+ }
+ else
+ {
+ NCOM::CPropVariant propValue;
+
+ if (nameToPropID.VarType == VT_BSTR)
+ propValue = value;
+ else if (nameToPropID.VarType == VT_BOOL)
+ {
+ bool res;
+ if (!StringToBool(value, res))
+ return E_INVALIDARG;
+ propValue = res;
+ }
+ else
+ {
+ UInt32 number;
+ if (ParseStringToUInt32(value, number) == value.Length())
+ propValue = number;
+ else
+ propValue = value;
+ }
+
+ if (!ConvertProperty(propValue, nameToPropID.VarType, prop.Value))
+ return E_INVALIDARG;
+ }
+ oneMethodInfo.Props.Add(prop);
+ return S_OK;
+}
+
+HRESULT COutHandler::SetParams(COneMethodInfo &oneMethodInfo, const UString &srcString)
+{
+ UStringVector params;
+ SplitParams(srcString, params);
+ if (params.Size() > 0)
+ oneMethodInfo.MethodName = params[0];
+ for (int i = 1; i < params.Size(); i++)
+ {
+ const UString &param = params[i];
+ UString name, value;
+ SplitParam(param, name, value);
+ RINOK(SetParam(oneMethodInfo, name, value));
+ }
+ return S_OK;
+}
+
+HRESULT COutHandler::SetSolidSettings(const UString &s)
+{
+ UString s2 = s;
+ s2.MakeUpper();
+ for (int i = 0; i < s2.Length();)
+ {
+ const wchar_t *start = ((const wchar_t *)s2) + i;
+ const wchar_t *end;
+ UInt64 v = ConvertStringToUInt64(start, &end);
+ if (start == end)
+ {
+ if (s2[i++] != 'E')
+ return E_INVALIDARG;
+ _solidExtension = true;
+ continue;
+ }
+ i += (int)(end - start);
+ if (i == s2.Length())
+ return E_INVALIDARG;
+ wchar_t c = s2[i++];
+ switch(c)
+ {
+ case 'F':
+ if (v < 1)
+ v = 1;
+ _numSolidFiles = v;
+ break;
+ case 'B':
+ _numSolidBytes = v;
+ _numSolidBytesDefined = true;
+ break;
+ case 'K':
+ _numSolidBytes = (v << 10);
+ _numSolidBytesDefined = true;
+ break;
+ case 'M':
+ _numSolidBytes = (v << 20);
+ _numSolidBytesDefined = true;
+ break;
+ case 'G':
+ _numSolidBytes = (v << 30);
+ _numSolidBytesDefined = true;
+ break;
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ return S_OK;
+}
+
+HRESULT COutHandler::SetSolidSettings(const PROPVARIANT &value)
+{
+ bool isSolid;
+ switch(value.vt)
+ {
+ case VT_EMPTY:
+ isSolid = true;
+ break;
+ case VT_BOOL:
+ isSolid = (value.boolVal != VARIANT_FALSE);
+ break;
+ case VT_BSTR:
+ if (StringToBool(value.bstrVal, isSolid))
+ break;
+ return SetSolidSettings(value.bstrVal);
+ default:
+ return E_INVALIDARG;
+ }
+ if (isSolid)
+ InitSolid();
+ else
+ _numSolidFiles = 1;
+ return S_OK;
+}
+
+void COutHandler::Init()
+{
+ _removeSfxBlock = false;
+ _compressHeaders = true;
+ _encryptHeadersSpecified = false;
+ _encryptHeaders = false;
+
+ WriteCTime = false;
+ WriteATime = false;
+ WriteMTime = true;
+
+ #ifdef COMPRESS_MT
+ _numThreads = NSystem::GetNumberOfProcessors();
+ #endif
+
+ _level = 5;
+ _autoFilter = true;
+ _volumeMode = false;
+ _crcSize = 4;
+ InitSolid();
+}
+
+void COutHandler::BeforeSetProperty()
+{
+ Init();
+ #ifdef COMPRESS_MT
+ numProcessors = NSystem::GetNumberOfProcessors();
+ #endif
+
+ mainDicSize = 0xFFFFFFFF;
+ mainDicMethodIndex = 0xFFFFFFFF;
+ minNumber = 0;
+ _crcSize = 4;
+}
+
+HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
+{
+ UString name = nameSpec;
+ name.MakeUpper();
+ if (name.IsEmpty())
+ return E_INVALIDARG;
+
+ if (name[0] == 'X')
+ {
+ name.Delete(0);
+ _level = 9;
+ return ParsePropValue(name, value, _level);
+ }
+
+ if (name[0] == L'S')
+ {
+ name.Delete(0);
+ if (name.IsEmpty())
+ return SetSolidSettings(value);
+ if (value.vt != VT_EMPTY)
+ return E_INVALIDARG;
+ return SetSolidSettings(name);
+ }
+
+ if (name == L"CRC")
+ {
+ _crcSize = 4;
+ name.Delete(0, 3);
+ return ParsePropValue(name, value, _crcSize);
+ }
+
+ UInt32 number;
+ int index = ParseStringToUInt32(name, number);
+ UString realName = name.Mid(index);
+ if (index == 0)
+ {
+ if(name.Left(2).CompareNoCase(L"MT") == 0)
+ {
+ #ifdef COMPRESS_MT
+ RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
+ #endif
+ return S_OK;
+ }
+ if (name.CompareNoCase(L"RSFX") == 0) return SetBoolProperty(_removeSfxBlock, value);
+ if (name.CompareNoCase(L"F") == 0) return SetBoolProperty(_autoFilter, value);
+ if (name.CompareNoCase(L"HC") == 0) return SetBoolProperty(_compressHeaders, value);
+ if (name.CompareNoCase(L"HCF") == 0)
+ {
+ bool compressHeadersFull = true;
+ RINOK(SetBoolProperty(compressHeadersFull, value));
+ if (!compressHeadersFull)
+ return E_INVALIDARG;
+ return S_OK;
+ }
+ if (name.CompareNoCase(L"HE") == 0)
+ {
+ RINOK(SetBoolProperty(_encryptHeaders, value));
+ _encryptHeadersSpecified = true;
+ return S_OK;
+ }
+ if (name.CompareNoCase(L"TC") == 0) return SetBoolProperty(WriteCTime, value);
+ if (name.CompareNoCase(L"TA") == 0) return SetBoolProperty(WriteATime, value);
+ if (name.CompareNoCase(L"TM") == 0) return SetBoolProperty(WriteMTime, value);
+ if (name.CompareNoCase(L"V") == 0) return SetBoolProperty(_volumeMode, value);
+ number = 0;
+ }
+ if (number > 10000)
+ return E_FAIL;
+ if (number < minNumber)
+ return E_INVALIDARG;
+ number -= minNumber;
+ for(int j = _methods.Size(); j <= (int)number; j++)
+ {
+ COneMethodInfo oneMethodInfo;
+ _methods.Add(oneMethodInfo);
+ }
+
+ COneMethodInfo &oneMethodInfo = _methods[number];
+
+ if (realName.Length() == 0)
+ {
+ if (value.vt != VT_BSTR)
+ return E_INVALIDARG;
+
+ RINOK(SetParams(oneMethodInfo, value.bstrVal));
+ }
+ else
+ {
+ int index = FindPropIdStart(realName);
+ if (index < 0)
+ return E_INVALIDARG;
+ const CNameToPropID &nameToPropID = g_NameToPropID[index];
+ CProp prop;
+ prop.Id = nameToPropID.PropID;
+
+ if (prop.Id == NCoderPropID::kBlockSize ||
+ prop.Id == NCoderPropID::kDictionarySize ||
+ prop.Id == NCoderPropID::kUsedMemorySize)
+ {
+ UInt32 dicSize;
+ RINOK(ParsePropDictionaryValue(realName.Mid(MyStringLen(nameToPropID.Name)), value, dicSize));
+ prop.Value = dicSize;
+ if (number <= mainDicMethodIndex)
+ mainDicSize = dicSize;
+ }
+ else
+ {
+ int index = FindPropIdExact(realName);
+ if (index < 0)
+ return E_INVALIDARG;
+ const CNameToPropID &nameToPropID = g_NameToPropID[index];
+ prop.Id = nameToPropID.PropID;
+ if (!ConvertProperty(value, nameToPropID.VarType, prop.Value))
+ return E_INVALIDARG;
+ }
+ oneMethodInfo.Props.Add(prop);
+ }
+ return S_OK;
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/HandlerOut.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/HandlerOut.h
new file mode 100644
index 000000000..7ba22b242
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/HandlerOut.h
@@ -0,0 +1,87 @@
+// HandlerOut.h
+
+#ifndef __HANDLER_OUT_H
+#define __HANDLER_OUT_H
+
+#include "../../../Common/MyString.h"
+#include "../../Common/MethodProps.h"
+
+namespace NArchive {
+
+struct COneMethodInfo
+{
+ CObjectVector<CProp> Props;
+ UString MethodName;
+
+ bool IsLzma() const;
+};
+
+class COutHandler
+{
+public:
+ HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
+
+ HRESULT SetSolidSettings(const UString &s);
+ HRESULT SetSolidSettings(const PROPVARIANT &value);
+
+ #ifdef COMPRESS_MT
+ UInt32 _numThreads;
+ #endif
+
+ UInt32 _crcSize;
+
+ CObjectVector<COneMethodInfo> _methods;
+ bool _removeSfxBlock;
+
+ UInt64 _numSolidFiles;
+ UInt64 _numSolidBytes;
+ bool _numSolidBytesDefined;
+ bool _solidExtension;
+
+ bool _compressHeaders;
+ bool _encryptHeadersSpecified;
+ bool _encryptHeaders;
+
+ bool WriteCTime;
+ bool WriteATime;
+ bool WriteMTime;
+
+ bool _autoFilter;
+ UInt32 _level;
+
+ bool _volumeMode;
+
+ HRESULT SetParam(COneMethodInfo &oneMethodInfo, const UString &name, const UString &value);
+ HRESULT SetParams(COneMethodInfo &oneMethodInfo, const UString &srcString);
+
+ void SetCompressionMethod2(COneMethodInfo &oneMethodInfo
+ #ifdef COMPRESS_MT
+ , UInt32 numThreads
+ #endif
+ );
+
+ void InitSolidFiles() { _numSolidFiles = (UInt64)(Int64)(-1); }
+ void InitSolidSize() { _numSolidBytes = (UInt64)(Int64)(-1); }
+ void InitSolid()
+ {
+ InitSolidFiles();
+ InitSolidSize();
+ _solidExtension = false;
+ _numSolidBytesDefined = false;
+ }
+
+ void Init();
+
+ COutHandler() { Init(); }
+
+ void BeforeSetProperty();
+
+ UInt32 minNumber;
+ UInt32 numProcessors;
+ UInt32 mainDicSize;
+ UInt32 mainDicMethodIndex;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/InStreamWithCRC.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
new file mode 100644
index 000000000..1d9e55562
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
@@ -0,0 +1,40 @@
+// InStreamWithCRC.cpp
+
+#include "StdAfx.h"
+
+#include "InStreamWithCRC.h"
+
+STDMETHODIMP CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize;
+ HRESULT result = _stream->Read(data, size, &realProcessedSize);
+ _size += realProcessedSize;
+ if (size > 0 && realProcessedSize == 0)
+ _wasFinished = true;
+ _crc = CrcUpdate(_crc, data, realProcessedSize);
+ if(processedSize != NULL)
+ *processedSize = realProcessedSize;
+ return result;
+}
+
+STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize;
+ HRESULT result = _stream->Read(data, size, &realProcessedSize);
+ if (size > 0 && realProcessedSize == 0)
+ _wasFinished = true;
+ _size += realProcessedSize;
+ _crc = CrcUpdate(_crc, data, realProcessedSize);
+ if(processedSize != NULL)
+ *processedSize = realProcessedSize;
+ return result;
+}
+
+STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ if (seekOrigin != STREAM_SEEK_SET || offset != 0)
+ return E_FAIL;
+ _size = 0;
+ _crc = CRC_INIT_VAL;
+ return _stream->Seek(offset, seekOrigin, newPosition);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/InStreamWithCRC.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/InStreamWithCRC.h
new file mode 100644
index 000000000..0492a5f8a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/InStreamWithCRC.h
@@ -0,0 +1,67 @@
+// InStreamWithCRC.h
+
+#ifndef __IN_STREAM_WITH_CRC_H
+#define __IN_STREAM_WITH_CRC_H
+
+#include "../../../../C/7zCrc.h"
+
+#include "../../../Common/MyCom.h"
+
+#include "../../IStream.h"
+
+class CSequentialInStreamWithCRC:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+private:
+ CMyComPtr<ISequentialInStream> _stream;
+ UInt64 _size;
+ UInt32 _crc;
+ bool _wasFinished;
+public:
+ void SetStream(ISequentialInStream *stream) { _stream = stream; }
+ void Init()
+ {
+ _size = 0;
+ _wasFinished = false;
+ _crc = CRC_INIT_VAL;
+ }
+ void ReleaseStream() { _stream.Release(); }
+ UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
+ UInt64 GetSize() const { return _size; }
+ bool WasFinished() const { return _wasFinished; }
+};
+
+class CInStreamWithCRC:
+ public IInStream,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInStream)
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+private:
+ CMyComPtr<IInStream> _stream;
+ UInt64 _size;
+ UInt32 _crc;
+ bool _wasFinished;
+public:
+ void SetStream(IInStream *stream) { _stream = stream; }
+ void Init()
+ {
+ _size = 0;
+ _wasFinished = false;
+ _crc = CRC_INIT_VAL;
+ }
+ void ReleaseStream() { _stream.Release(); }
+ UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
+ UInt64 GetSize() const { return _size; }
+ bool WasFinished() const { return _wasFinished; }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ItemNameUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ItemNameUtils.cpp
new file mode 100644
index 000000000..57d2e4e57
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ItemNameUtils.cpp
@@ -0,0 +1,61 @@
+// Archive/Common/ItemNameUtils.cpp
+
+#include "StdAfx.h"
+
+#include "ItemNameUtils.h"
+#include "Common/MyWindows.h"
+
+namespace NArchive {
+namespace NItemName {
+
+static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR;
+static const wchar_t kDirDelimiter = L'/';
+
+UString MakeLegalName(const UString &name)
+{
+ UString zipName = name;
+ zipName.Replace(kOSDirDelimiter, kDirDelimiter);
+ return zipName;
+}
+
+UString GetOSName(const UString &name)
+{
+ UString newName = name;
+ newName.Replace(kDirDelimiter, kOSDirDelimiter);
+ return newName;
+}
+
+UString GetOSName2(const UString &name)
+{
+ if (name.IsEmpty())
+ return UString();
+ UString newName = GetOSName(name);
+ if (newName[newName.Length() - 1] == kOSDirDelimiter)
+ newName.Delete(newName.Length() - 1);
+ return newName;
+}
+
+bool HasTailSlash(const AString &name, UINT codePage)
+{
+ if (name.IsEmpty())
+ return false;
+ LPCSTR prev =
+ #ifdef _WIN32
+ CharPrevExA((WORD)codePage, name, &name[name.Length()], 0);
+ #else
+ (LPCSTR)(name) + (name.Length() - 1);
+ (void)codePage;
+ #endif
+ return (*prev == '/');
+}
+
+#ifndef _WIN32
+UString WinNameToOSName(const UString &name)
+{
+ UString newName = name;
+ newName.Replace(L'\\', kOSDirDelimiter);
+ return newName;
+}
+#endif
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ItemNameUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ItemNameUtils.h
new file mode 100644
index 000000000..5eafacb12
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ItemNameUtils.h
@@ -0,0 +1,24 @@
+// Archive/Common/ItemNameUtils.h
+
+#ifndef __ARCHIVE_ITEMNAMEUTILS_H
+#define __ARCHIVE_ITEMNAMEUTILS_H
+
+#include "../../../Common/MyString.h"
+
+namespace NArchive {
+namespace NItemName {
+
+ UString MakeLegalName(const UString &name);
+ UString GetOSName(const UString &name);
+ UString GetOSName2(const UString &name);
+ bool HasTailSlash(const AString &name, UINT codePage);
+
+ #ifdef _WIN32
+ inline UString WinNameToOSName(const UString &name) { return name; }
+ #else
+ UString WinNameToOSName(const UString &name);
+ #endif
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/MultiStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/MultiStream.cpp
new file mode 100644
index 000000000..cf7dc0501
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/MultiStream.cpp
@@ -0,0 +1,201 @@
+// MultiStream.cpp
+
+#include "StdAfx.h"
+
+#include "MultiStream.h"
+
+STDMETHODIMP CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if(processedSize != NULL)
+ *processedSize = 0;
+ while(_streamIndex < Streams.Size() && size > 0)
+ {
+ CSubStreamInfo &s = Streams[_streamIndex];
+ if (_pos == s.Size)
+ {
+ _streamIndex++;
+ _pos = 0;
+ continue;
+ }
+ RINOK(s.Stream->Seek(s.Pos + _pos, STREAM_SEEK_SET, 0));
+ UInt32 sizeToRead = UInt32(MyMin((UInt64)size, s.Size - _pos));
+ UInt32 realProcessed;
+ HRESULT result = s.Stream->Read(data, sizeToRead, &realProcessed);
+ data = (void *)((Byte *)data + realProcessed);
+ size -= realProcessed;
+ if(processedSize != NULL)
+ *processedSize += realProcessed;
+ _pos += realProcessed;
+ _seekPos += realProcessed;
+ RINOK(result);
+ break;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin,
+ UInt64 *newPosition)
+{
+ UInt64 newPos;
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET:
+ newPos = offset;
+ break;
+ case STREAM_SEEK_CUR:
+ newPos = _seekPos + offset;
+ break;
+ case STREAM_SEEK_END:
+ newPos = _totalLength + offset;
+ break;
+ default:
+ return STG_E_INVALIDFUNCTION;
+ }
+ _seekPos = 0;
+ for (_streamIndex = 0; _streamIndex < Streams.Size(); _streamIndex++)
+ {
+ UInt64 size = Streams[_streamIndex].Size;
+ if (newPos < _seekPos + size)
+ {
+ _pos = newPos - _seekPos;
+ _seekPos += _pos;
+ if (newPosition != 0)
+ *newPosition = newPos;
+ return S_OK;
+ }
+ _seekPos += size;
+ }
+ if (newPos == _seekPos)
+ {
+ if (newPosition != 0)
+ *newPosition = newPos;
+ return S_OK;
+ }
+ return E_FAIL;
+}
+
+
+/*
+class COutVolumeStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ int _volIndex;
+ UInt64 _volSize;
+ UInt64 _curPos;
+ CMyComPtr<ISequentialOutStream> _volumeStream;
+ COutArchive _archive;
+ CCRC _crc;
+
+public:
+ MY_UNKNOWN_IMP
+
+ CFileItem _file;
+ CUpdateOptions _options;
+ CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
+ void Init(IArchiveUpdateCallback2 *volumeCallback,
+ const UString &name)
+ {
+ _file.Name = name;
+ _file.IsStartPosDefined = true;
+ _file.StartPos = 0;
+
+ VolumeCallback = volumeCallback;
+ _volIndex = 0;
+ _volSize = 0;
+ }
+
+ HRESULT Flush();
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+HRESULT COutVolumeStream::Flush()
+{
+ if (_volumeStream)
+ {
+ _file.UnPackSize = _curPos;
+ _file.FileCRC = _crc.GetDigest();
+ RINOK(WriteVolumeHeader(_archive, _file, _options));
+ _archive.Close();
+ _volumeStream.Release();
+ _file.StartPos += _file.UnPackSize;
+ }
+ return S_OK;
+}
+*/
+
+/*
+STDMETHODIMP COutMultiStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if(processedSize != NULL)
+ *processedSize = 0;
+ while(size > 0)
+ {
+ if (_streamIndex >= Streams.Size())
+ {
+ CSubStreamInfo subStream;
+ RINOK(VolumeCallback->GetVolumeSize(Streams.Size(), &subStream.Size));
+ RINOK(VolumeCallback->GetVolumeStream(Streams.Size(), &subStream.Stream));
+ subStream.Pos = 0;
+ Streams.Add(subStream);
+ continue;
+ }
+ CSubStreamInfo &subStream = Streams[_streamIndex];
+ if (_offsetPos >= subStream.Size)
+ {
+ _offsetPos -= subStream.Size;
+ _streamIndex++;
+ continue;
+ }
+ if (_offsetPos != subStream.Pos)
+ {
+ CMyComPtr<IOutStream> outStream;
+ RINOK(subStream.Stream.QueryInterface(IID_IOutStream, &outStream));
+ RINOK(outStream->Seek(_offsetPos, STREAM_SEEK_SET, NULL));
+ subStream.Pos = _offsetPos;
+ }
+
+ UInt32 curSize = (UInt32)MyMin((UInt64)size, subStream.Size - subStream.Pos);
+ UInt32 realProcessed;
+ RINOK(subStream.Stream->Write(data, curSize, &realProcessed));
+ data = (void *)((Byte *)data + realProcessed);
+ size -= realProcessed;
+ subStream.Pos += realProcessed;
+ _offsetPos += realProcessed;
+ _absPos += realProcessed;
+ if (_absPos > _length)
+ _length = _absPos;
+ if(processedSize != NULL)
+ *processedSize += realProcessed;
+ if (subStream.Pos == subStream.Size)
+ {
+ _streamIndex++;
+ _offsetPos = 0;
+ }
+ if (realProcessed != curSize && realProcessed == 0)
+ return E_FAIL;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP COutMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ if(seekOrigin >= 3)
+ return STG_E_INVALIDFUNCTION;
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET:
+ _absPos = offset;
+ break;
+ case STREAM_SEEK_CUR:
+ _absPos += offset;
+ break;
+ case STREAM_SEEK_END:
+ _absPos = _length + offset;
+ break;
+ }
+ _offsetPos = _absPos;
+ _streamIndex = 0;
+ return S_OK;
+}
+*/
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/MultiStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/MultiStream.h
new file mode 100644
index 000000000..137c9400d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/MultiStream.h
@@ -0,0 +1,76 @@
+// MultiStream.h
+
+#ifndef __MULTISTREAM_H
+#define __MULTISTREAM_H
+
+#include "../../../Common/MyCom.h"
+#include "../../../Common/MyVector.h"
+#include "../../Archive/IArchive.h"
+
+class CMultiStream:
+ public IInStream,
+ public CMyUnknownImp
+{
+ int _streamIndex;
+ UInt64 _pos;
+ UInt64 _seekPos;
+ UInt64 _totalLength;
+public:
+ struct CSubStreamInfo
+ {
+ CMyComPtr<IInStream> Stream;
+ UInt64 Pos;
+ UInt64 Size;
+ };
+ CObjectVector<CSubStreamInfo> Streams;
+ void Init()
+ {
+ _streamIndex = 0;
+ _pos = 0;
+ _seekPos = 0;
+ _totalLength = 0;
+ for (int i = 0; i < Streams.Size(); i++)
+ _totalLength += Streams[i].Size;
+ }
+
+ MY_UNKNOWN_IMP1(IInStream)
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+};
+
+/*
+class COutMultiStream:
+ public IOutStream,
+ public CMyUnknownImp
+{
+ int _streamIndex; // required stream
+ UInt64 _offsetPos; // offset from start of _streamIndex index
+ UInt64 _absPos;
+ UInt64 _length;
+
+ struct CSubStreamInfo
+ {
+ CMyComPtr<ISequentialOutStream> Stream;
+ UInt64 Size;
+ UInt64 Pos;
+ };
+ CObjectVector<CSubStreamInfo> Streams;
+public:
+ CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
+ void Init()
+ {
+ _streamIndex = 0;
+ _offsetPos = 0;
+ _absPos = 0;
+ _length = 0;
+ }
+
+ MY_UNKNOWN_IMP1(IOutStream)
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+};
+*/
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp
new file mode 100644
index 000000000..f955c2254
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp
@@ -0,0 +1,18 @@
+// OutStreamWithCRC.cpp
+
+#include "StdAfx.h"
+
+#include "OutStreamWithCRC.h"
+
+STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ HRESULT result = S_OK;
+ if (_stream)
+ result = _stream->Write(data, size, &size);
+ if (_calculate)
+ _crc = CrcUpdate(_crc, data, size);
+ _size += size;
+ if (processedSize != NULL)
+ *processedSize = size;
+ return result;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithCRC.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithCRC.h
new file mode 100644
index 000000000..115b442aa
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithCRC.h
@@ -0,0 +1,36 @@
+// OutStreamWithCRC.h
+
+#ifndef __OUT_STREAM_WITH_CRC_H
+#define __OUT_STREAM_WITH_CRC_H
+
+#include "../../../../C/7zCrc.h"
+
+#include "../../../Common/MyCom.h"
+
+#include "../../IStream.h"
+
+class COutStreamWithCRC:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialOutStream> _stream;
+ UInt64 _size;
+ UInt32 _crc;
+ bool _calculate;
+public:
+ MY_UNKNOWN_IMP
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ void SetStream(ISequentialOutStream *stream) { _stream = stream; }
+ void ReleaseStream() { _stream.Release(); }
+ void Init(bool calculate = true)
+ {
+ _size = 0;
+ _calculate = calculate;
+ _crc = CRC_INIT_VAL;
+ }
+ void InitCRC() { _crc = CRC_INIT_VAL; }
+ UInt64 GetSize() const { return _size; }
+ UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp
new file mode 100644
index 000000000..0526c1b1d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp
@@ -0,0 +1,18 @@
+// OutStreamWithSha1.cpp
+
+#include "StdAfx.h"
+
+#include "OutStreamWithSha1.h"
+
+STDMETHODIMP COutStreamWithSha1::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ HRESULT result = S_OK;
+ if (_stream)
+ result = _stream->Write(data, size, &size);
+ if (_calculate)
+ _sha.Update((const Byte *)data, size);
+ _size += size;
+ if (processedSize != NULL)
+ *processedSize = size;
+ return result;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithSha1.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithSha1.h
new file mode 100644
index 000000000..3bbfbbe19
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/OutStreamWithSha1.h
@@ -0,0 +1,36 @@
+// OutStreamWithSha1.h
+
+#ifndef __OUT_STREAM_WITH_SHA1_H
+#define __OUT_STREAM_WITH_SHA1_H
+
+#include "../../Crypto/Sha1.h"
+
+#include "../../../Common/MyCom.h"
+
+#include "../../IStream.h"
+
+class COutStreamWithSha1:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialOutStream> _stream;
+ UInt64 _size;
+ NCrypto::NSha1::CContext _sha;
+ bool _calculate;
+public:
+ MY_UNKNOWN_IMP
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ void SetStream(ISequentialOutStream *stream) { _stream = stream; }
+ void ReleaseStream() { _stream.Release(); }
+ void Init(bool calculate = true)
+ {
+ _size = 0;
+ _calculate = calculate;
+ _sha.Init();
+ }
+ void InitSha1() { _sha.Init(); }
+ UInt64 GetSize() const { return _size; }
+ void Final(Byte *digest) { _sha.Final(digest); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ParseProperties.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ParseProperties.cpp
new file mode 100644
index 000000000..498f4ee5d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ParseProperties.cpp
@@ -0,0 +1,177 @@
+// ParseProperties.cpp
+
+#include "StdAfx.h"
+
+#include "ParseProperties.h"
+
+#include "Common/StringToInt.h"
+#include "Common/MyCom.h"
+
+HRESULT ParsePropValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue)
+{
+ if (prop.vt == VT_UI4)
+ {
+ if (!name.IsEmpty())
+ return E_INVALIDARG;
+ resValue = prop.ulVal;
+ }
+ else if (prop.vt == VT_EMPTY)
+ {
+ if(!name.IsEmpty())
+ {
+ const wchar_t *start = name;
+ const wchar_t *end;
+ UInt64 v = ConvertStringToUInt64(start, &end);
+ if (end - start != name.Length())
+ return E_INVALIDARG;
+ resValue = (UInt32)v;
+ }
+ }
+ else
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+static const int kLogarithmicSizeLimit = 32;
+static const wchar_t kByteSymbol = L'B';
+static const wchar_t kKiloByteSymbol = L'K';
+static const wchar_t kMegaByteSymbol = L'M';
+
+HRESULT ParsePropDictionaryValue(const UString &srcStringSpec, UInt32 &dicSize)
+{
+ UString srcString = srcStringSpec;
+ srcString.MakeUpper();
+
+ const wchar_t *start = srcString;
+ const wchar_t *end;
+ UInt64 number = ConvertStringToUInt64(start, &end);
+ int numDigits = (int)(end - start);
+ if (numDigits == 0 || srcString.Length() > numDigits + 1)
+ return E_INVALIDARG;
+ if (srcString.Length() == numDigits)
+ {
+ if (number >= static_cast< UInt64 >( kLogarithmicSizeLimit ) )
+ return E_INVALIDARG;
+ dicSize = (UInt32)1 << (int)number;
+ return S_OK;
+ }
+ switch (srcString[numDigits])
+ {
+ case kByteSymbol:
+ if (number >= ((UInt64)1 << kLogarithmicSizeLimit))
+ return E_INVALIDARG;
+ dicSize = (UInt32)number;
+ break;
+ case kKiloByteSymbol:
+ if (number >= ((UInt64)1 << (kLogarithmicSizeLimit - 10)))
+ return E_INVALIDARG;
+ dicSize = (UInt32)(number << 10);
+ break;
+ case kMegaByteSymbol:
+ if (number >= ((UInt64)1 << (kLogarithmicSizeLimit - 20)))
+ return E_INVALIDARG;
+ dicSize = (UInt32)(number << 20);
+ break;
+ default:
+ return E_INVALIDARG;
+ }
+ return S_OK;
+}
+
+HRESULT ParsePropDictionaryValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue)
+{
+ if (name.IsEmpty())
+ {
+ if (prop.vt == VT_UI4)
+ {
+ UInt32 logDicSize = prop.ulVal;
+ if (logDicSize >= 32)
+ return E_INVALIDARG;
+ resValue = (UInt32)1 << logDicSize;
+ return S_OK;
+ }
+ if (prop.vt == VT_BSTR)
+ return ParsePropDictionaryValue(prop.bstrVal, resValue);
+ return E_INVALIDARG;
+ }
+ return ParsePropDictionaryValue(name, resValue);
+}
+
+bool StringToBool(const UString &s, bool &res)
+{
+ if (s.IsEmpty() || s.CompareNoCase(L"ON") == 0 || s.Compare(L"+") == 0)
+ {
+ res = true;
+ return true;
+ }
+ if (s.CompareNoCase(L"OFF") == 0 || s.Compare(L"-") == 0)
+ {
+ res = false;
+ return true;
+ }
+ return false;
+}
+
+HRESULT SetBoolProperty(bool &dest, const PROPVARIANT &value)
+{
+ switch(value.vt)
+ {
+ case VT_EMPTY:
+ dest = true;
+ return S_OK;
+ case VT_BOOL:
+ dest = (value.boolVal != VARIANT_FALSE);
+ return S_OK;
+ /*
+ case VT_UI4:
+ dest = (value.ulVal != 0);
+ break;
+ */
+ case VT_BSTR:
+ return StringToBool(value.bstrVal, dest) ? S_OK : E_INVALIDARG;
+ }
+ return E_INVALIDARG;
+}
+
+int ParseStringToUInt32(const UString &srcString, UInt32 &number)
+{
+ const wchar_t *start = srcString;
+ const wchar_t *end;
+ UInt64 number64 = ConvertStringToUInt64(start, &end);
+ if (number64 > 0xFFFFFFFF)
+ {
+ number = 0;
+ return 0;
+ }
+ number = (UInt32)number64;
+ return (int)(end - start);
+}
+
+HRESULT ParseMtProp(const UString &name, const PROPVARIANT &prop, UInt32 defaultNumThreads, UInt32 &numThreads)
+{
+ if (name.IsEmpty())
+ {
+ switch(prop.vt)
+ {
+ case VT_UI4:
+ numThreads = prop.ulVal;
+ break;
+ default:
+ {
+ bool val;
+ RINOK(SetBoolProperty(val, prop));
+ numThreads = (val ? defaultNumThreads : 1);
+ break;
+ }
+ }
+ }
+ else
+ {
+ UInt32 number;
+ int index = ParseStringToUInt32(name, number);
+ if (index != name.Length())
+ return E_INVALIDARG;
+ numThreads = number;
+ }
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ParseProperties.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ParseProperties.h
new file mode 100644
index 000000000..6f80f6344
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Common/ParseProperties.h
@@ -0,0 +1,18 @@
+// ParseProperties.h
+
+#ifndef __PARSEPROPERTIES_H
+#define __PARSEPROPERTIES_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+
+HRESULT ParsePropValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue);
+HRESULT ParsePropDictionaryValue(const UString &srcStringSpec, UInt32 &dicSize);
+HRESULT ParsePropDictionaryValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue);
+
+bool StringToBool(const UString &s, bool &res);
+HRESULT SetBoolProperty(bool &dest, const PROPVARIANT &value);
+int ParseStringToUInt32(const UString &srcString, UInt32 &number);
+HRESULT ParseMtProp(const UString &name, const PROPVARIANT &prop, UInt32 defaultNumThreads, UInt32 &numThreads);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/CpioHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/CpioHandler.cpp
new file mode 100644
index 000000000..e5a32936c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/CpioHandler.cpp
@@ -0,0 +1,625 @@
+// CpioHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/StringToInt.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#include "Common/ItemNameUtils.h"
+
+namespace NArchive {
+namespace NCpio {
+
+namespace NFileHeader
+{
+ namespace NMagic
+ {
+ extern const char *kMagic1 = "070701";
+ extern const char *kMagic2 = "070702";
+ extern const char *kMagic3 = "070707";
+ extern const char *kEndName = "TRAILER!!!";
+
+ const Byte kMagicForRecord2[2] = { 0xC7, 0x71 };
+ }
+
+ const UInt32 kRecord2Size = 26;
+ /*
+ struct CRecord2
+ {
+ unsigned short c_magic;
+ short c_dev;
+ unsigned short c_ino;
+ unsigned short c_mode;
+ unsigned short c_uid;
+ unsigned short c_gid;
+ unsigned short c_nlink;
+ short c_rdev;
+ unsigned short c_mtimes[2];
+ unsigned short c_namesize;
+ unsigned short c_filesizes[2];
+ };
+ */
+
+ const UInt32 kRecordSize = 110;
+ /*
+ struct CRecord
+ {
+ char Magic[6]; // "070701" for "new" portable format, "070702" for CRC format
+ char inode[8];
+ char Mode[8];
+ char UID[8];
+ char GID[8];
+ char nlink[8];
+ char mtime[8];
+ char Size[8]; // must be 0 for FIFOs and directories
+ char DevMajor[8];
+ char DevMinor[8];
+ char RDevMajor[8]; //only valid for chr and blk special files
+ char RDevMinor[8]; //only valid for chr and blk special files
+ char NameSize[8]; // count includes terminating NUL in pathname
+ char ChkSum[8]; // 0 for "new" portable format; for CRC format the sum of all the bytes in the file
+ bool CheckMagic() const
+ { return memcmp(Magic, NMagic::kMagic1, 6) == 0 ||
+ memcmp(Magic, NMagic::kMagic2, 6) == 0; };
+ };
+ */
+
+ const UInt32 kOctRecordSize = 76;
+
+}
+
+struct CItem
+{
+ AString Name;
+ UInt32 inode;
+ UInt32 Mode;
+ UInt32 UID;
+ UInt32 GID;
+ UInt32 Size;
+ UInt32 MTime;
+
+ // char LinkFlag;
+ // AString LinkName; ?????
+ char Magic[8];
+ UInt32 NumLinks;
+ UInt32 DevMajor;
+ UInt32 DevMinor;
+ UInt32 RDevMajor;
+ UInt32 RDevMinor;
+ UInt32 ChkSum;
+
+ UInt32 Align;
+
+ bool IsDir() const { return (Mode & 0170000) == 0040000; }
+};
+
+class CItemEx: public CItem
+{
+public:
+ UInt64 HeaderPosition;
+ UInt32 HeaderSize;
+ UInt64 GetDataPosition() const { return HeaderPosition + HeaderSize; };
+};
+
+const UInt32 kMaxBlockSize = NFileHeader::kRecordSize;
+
+class CInArchive
+{
+ CMyComPtr<IInStream> m_Stream;
+ UInt64 m_Position;
+
+ UInt16 _blockSize;
+ Byte _block[kMaxBlockSize];
+ UInt32 _blockPos;
+ Byte ReadByte();
+ UInt16 ReadUInt16();
+ UInt32 ReadUInt32();
+
+ bool ReadNumber(UInt32 &resultValue);
+ bool ReadOctNumber(int size, UInt32 &resultValue);
+
+ HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize);
+public:
+ HRESULT Open(IInStream *inStream);
+ HRESULT GetNextItem(bool &filled, CItemEx &itemInfo);
+ HRESULT Skip(UInt64 numBytes);
+ HRESULT SkipDataRecords(UInt64 dataSize, UInt32 align);
+};
+
+HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
+{
+ size_t realProcessedSize = size;
+ RINOK(ReadStream(m_Stream, data, &realProcessedSize));
+ processedSize = (UInt32)realProcessedSize;
+ m_Position += processedSize;
+ return S_OK;
+}
+
+Byte CInArchive::ReadByte()
+{
+ if (_blockPos >= _blockSize)
+ throw "Incorrect cpio archive";
+ return _block[_blockPos++];
+}
+
+UInt16 CInArchive::ReadUInt16()
+{
+ UInt16 value = 0;
+ for (int i = 0; i < 2; i++)
+ {
+ Byte b = ReadByte();
+ value |= (UInt16(b) << (8 * i));
+ }
+ return value;
+}
+
+UInt32 CInArchive::ReadUInt32()
+{
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ Byte b = ReadByte();
+ value |= (UInt32(b) << (8 * i));
+ }
+ return value;
+}
+
+HRESULT CInArchive::Open(IInStream *inStream)
+{
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
+ m_Stream = inStream;
+ return S_OK;
+}
+
+bool CInArchive::ReadNumber(UInt32 &resultValue)
+{
+ resultValue = 0;
+ for (int i = 0; i < 8; i++)
+ {
+ char c = char(ReadByte());
+ int d;
+ if (c >= '0' && c <= '9')
+ d = c - '0';
+ else if (c >= 'A' && c <= 'F')
+ d = 10 + c - 'A';
+ else if (c >= 'a' && c <= 'f')
+ d = 10 + c - 'a';
+ else
+ return false;
+ resultValue *= 0x10;
+ resultValue += d;
+ }
+ return true;
+}
+
+static bool OctalToNumber(const char *s, UInt64 &res)
+{
+ const char *end;
+ res = ConvertOctStringToUInt64(s, &end);
+ return (*end == ' ' || *end == 0);
+}
+
+static bool OctalToNumber32(const char *s, UInt32 &res)
+{
+ UInt64 res64;
+ if (!OctalToNumber(s, res64))
+ return false;
+ res = (UInt32)res64;
+ return (res64 <= 0xFFFFFFFF);
+}
+
+bool CInArchive::ReadOctNumber(int size, UInt32 &resultValue)
+{
+ char sz[32 + 4];
+ int i;
+ for (i = 0; i < size && i < 32; i++)
+ sz[i] = (char)ReadByte();
+ sz[i] = 0;
+ return OctalToNumber32(sz, resultValue);
+}
+
+#define GetFromHex(y) { if (!ReadNumber(y)) return S_FALSE; }
+#define GetFromOct6(y) { if (!ReadOctNumber(6, y)) return S_FALSE; }
+#define GetFromOct11(y) { if (!ReadOctNumber(11, y)) return S_FALSE; }
+
+static unsigned short ConvertValue(unsigned short value, bool convert)
+{
+ if (!convert)
+ return value;
+ return (unsigned short)((((unsigned short)(value & 0xFF)) << 8) | (value >> 8));
+}
+
+static UInt32 GetAlignedSize(UInt32 size, UInt32 align)
+{
+ while ((size & (align - 1)) != 0)
+ size++;
+ return size;
+}
+
+
+HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
+{
+ filled = false;
+
+ UInt32 processedSize;
+ item.HeaderPosition = m_Position;
+
+ _blockSize = kMaxBlockSize;
+ RINOK(ReadBytes(_block, 2, processedSize));
+ if (processedSize != 2)
+ return S_FALSE;
+ _blockPos = 0;
+
+ UInt32 nameSize;
+
+ bool oldBE =
+ _block[0] == NFileHeader::NMagic::kMagicForRecord2[1] &&
+ _block[1] == NFileHeader::NMagic::kMagicForRecord2[0];
+
+ bool binMode = (_block[0] == NFileHeader::NMagic::kMagicForRecord2[0] &&
+ _block[1] == NFileHeader::NMagic::kMagicForRecord2[1]) ||
+ oldBE;
+
+ if (binMode)
+ {
+ RINOK(ReadBytes(_block + 2, NFileHeader::kRecord2Size - 2, processedSize));
+ if (processedSize != NFileHeader::kRecord2Size - 2)
+ return S_FALSE;
+ item.Align = 2;
+ _blockPos = 2;
+ item.DevMajor = 0;
+ item.DevMinor = ConvertValue(ReadUInt16(), oldBE);
+ item.inode = ConvertValue(ReadUInt16(), oldBE);
+ item.Mode = ConvertValue(ReadUInt16(), oldBE);
+ item.UID = ConvertValue(ReadUInt16(), oldBE);
+ item.GID = ConvertValue(ReadUInt16(), oldBE);
+ item.NumLinks = ConvertValue(ReadUInt16(), oldBE);
+ item.RDevMajor =0;
+ item.RDevMinor = ConvertValue(ReadUInt16(), oldBE);
+ UInt16 timeHigh = ConvertValue(ReadUInt16(), oldBE);
+ UInt16 timeLow = ConvertValue(ReadUInt16(), oldBE);
+ item.MTime = (UInt32(timeHigh) << 16) + timeLow;
+ nameSize = ConvertValue(ReadUInt16(), oldBE);
+ UInt16 sizeHigh = ConvertValue(ReadUInt16(), oldBE);
+ UInt16 sizeLow = ConvertValue(ReadUInt16(), oldBE);
+ item.Size = (UInt32(sizeHigh) << 16) + sizeLow;
+
+ item.ChkSum = 0;
+ item.HeaderSize = GetAlignedSize(
+ nameSize + NFileHeader::kRecord2Size, item.Align);
+ nameSize = item.HeaderSize - NFileHeader::kRecord2Size;
+ }
+ else
+ {
+ RINOK(ReadBytes(_block + 2, 4, processedSize));
+ if (processedSize != 4)
+ return S_FALSE;
+
+ bool magicOK =
+ memcmp(_block, NFileHeader::NMagic::kMagic1, 6) == 0 ||
+ memcmp(_block, NFileHeader::NMagic::kMagic2, 6) == 0;
+ _blockPos = 6;
+ if (magicOK)
+ {
+ RINOK(ReadBytes(_block + 6, NFileHeader::kRecordSize - 6, processedSize));
+ if (processedSize != NFileHeader::kRecordSize - 6)
+ return S_FALSE;
+ item.Align = 4;
+
+ GetFromHex(item.inode);
+ GetFromHex(item.Mode);
+ GetFromHex(item.UID);
+ GetFromHex(item.GID);
+ GetFromHex(item.NumLinks);
+ UInt32 mTime;
+ GetFromHex(mTime);
+ item.MTime = mTime;
+ GetFromHex(item.Size);
+ GetFromHex(item.DevMajor);
+ GetFromHex(item.DevMinor);
+ GetFromHex(item.RDevMajor);
+ GetFromHex(item.RDevMinor);
+ GetFromHex(nameSize);
+ GetFromHex(item.ChkSum);
+ item.HeaderSize = GetAlignedSize(
+ nameSize + NFileHeader::kRecordSize, item.Align);
+ nameSize = item.HeaderSize - NFileHeader::kRecordSize;
+ }
+ else
+ {
+ if (!memcmp(_block, NFileHeader::NMagic::kMagic3, 6) == 0)
+ return S_FALSE;
+ RINOK(ReadBytes(_block + 6, NFileHeader::kOctRecordSize - 6, processedSize));
+ if (processedSize != NFileHeader::kOctRecordSize - 6)
+ return S_FALSE;
+ item.Align = 1;
+ item.DevMajor = 0;
+ GetFromOct6(item.DevMinor);
+ GetFromOct6(item.inode);
+ GetFromOct6(item.Mode);
+ GetFromOct6(item.UID);
+ GetFromOct6(item.GID);
+ GetFromOct6(item.NumLinks);
+ item.RDevMajor = 0;
+ GetFromOct6(item.RDevMinor);
+ UInt32 mTime;
+ GetFromOct11(mTime);
+ item.MTime = mTime;
+ GetFromOct6(nameSize);
+ GetFromOct11(item.Size); // ?????
+ item.HeaderSize = GetAlignedSize(
+ nameSize + NFileHeader::kOctRecordSize, item.Align);
+ nameSize = item.HeaderSize - NFileHeader::kOctRecordSize;
+ }
+ }
+ if (nameSize == 0 || nameSize >= (1 << 27))
+ return E_FAIL;
+ RINOK(ReadBytes(item.Name.GetBuffer(nameSize), nameSize, processedSize));
+ if (processedSize != nameSize)
+ return E_FAIL;
+ item.Name.ReleaseBuffer();
+ if (strcmp(item.Name, NFileHeader::NMagic::kEndName) == 0)
+ return S_OK;
+ filled = true;
+ return S_OK;
+}
+
+HRESULT CInArchive::Skip(UInt64 numBytes)
+{
+ UInt64 newPostion;
+ RINOK(m_Stream->Seek(numBytes, STREAM_SEEK_CUR, &newPostion));
+ m_Position += numBytes;
+ if (m_Position != newPostion)
+ return E_FAIL;
+ return S_OK;
+}
+
+HRESULT CInArchive::SkipDataRecords(UInt64 dataSize, UInt32 align)
+{
+ while ((dataSize & (align - 1)) != 0)
+ dataSize++;
+ return Skip(dataSize);
+}
+
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ CObjectVector<CItemEx> _items;
+ CMyComPtr<IInStream> _stream;
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+/*
+enum
+{
+ kpidinode = kpidUserDefined,
+ kpidiChkSum
+};
+*/
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidPosixAttrib, VT_UI4},
+ // { L"inode", kpidinode, VT_UI4}
+ // { L"CheckSum", kpidiChkSum, VT_UI4}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ // try
+ {
+ CInArchive archive;
+
+ UInt64 endPos = 0;
+ bool needSetTotal = true;
+
+ if (callback != NULL)
+ {
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
+ }
+
+ RINOK(archive.Open(stream));
+
+ _items.Clear();
+
+ for (;;)
+ {
+ CItemEx item;
+ bool filled;
+ HRESULT result = archive.GetNextItem(filled, item);
+ if (result == S_FALSE)
+ return S_FALSE;
+ if (result != S_OK)
+ return S_FALSE;
+ if (!filled)
+ break;
+ _items.Add(item);
+ archive.SkipDataRecords(item.Size, item.Align);
+ if (callback != NULL)
+ {
+ if (needSetTotal)
+ {
+ RINOK(callback->SetTotal(NULL, &endPos));
+ needSetTotal = false;
+ }
+ if (_items.Size() % 100 == 0)
+ {
+ UInt64 numFiles = _items.Size();
+ UInt64 numBytes = item.HeaderPosition;
+ RINOK(callback->SetCompleted(&numFiles, &numBytes));
+ }
+ }
+ }
+ if (_items.Size() == 0)
+ return S_FALSE;
+
+ _stream = stream;
+ }
+ /*
+ catch(...)
+ {
+ return S_FALSE;
+ }
+ */
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _items.Clear();
+ _stream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _items.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItemEx &item = _items[index];
+
+ switch(propID)
+ {
+ case kpidPath: prop = NItemName::GetOSName(MultiByteToUnicodeString(item.Name, CP_OEMCP)); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize:
+ case kpidPackSize:
+ prop = (UInt64)item.Size;
+ break;
+ case kpidMTime:
+ {
+ if (item.MTime != 0)
+ {
+ FILETIME utc;
+ NWindows::NTime::UnixTimeToFileTime(item.MTime, utc);
+ prop = utc;
+ }
+ break;
+ }
+ case kpidPosixAttrib: prop = item.Mode; break;
+ /*
+ case kpidinode: prop = item.inode; break;
+ case kpidiChkSum: prop = item.ChkSum; break;
+ */
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _items[allFilesMode ? i : indices[i]].Size;
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_stream);
+
+ for (i = 0; i < numItems; i++)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> outStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItemEx &item = _items[index];
+ RINOK(extractCallback->GetStream(index, &outStream, askMode));
+ currentTotalSize += item.Size;
+ if (item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ if (!testMode && !outStream)
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ if (testMode)
+ {
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ RINOK(_stream->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
+ streamSpec->Init(item.Size);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ const CItemEx &item = _items[index];
+ return CreateLimitedInStream(_stream, item.GetDataPosition(), item.Size, stream);
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new NArchive::NCpio::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Cpio", L"cpio", 0, 0xED, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Cpio)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DebHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DebHandler.cpp
new file mode 100644
index 000000000..0381e0fd1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DebHandler.cpp
@@ -0,0 +1,394 @@
+// DebHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/Defs.h"
+#include "Common/NewHandler.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#include "Common/ItemNameUtils.h"
+
+using namespace NWindows;
+using namespace NTime;
+
+namespace NArchive {
+namespace NDeb {
+
+namespace NHeader
+{
+ const int kSignatureLen = 8;
+
+ const char *kSignature = "!<arch>\n";
+
+ const int kNameSize = 16;
+ const int kTimeSize = 12;
+ const int kModeSize = 8;
+ const int kSizeSize = 10;
+
+ /*
+ struct CHeader
+ {
+ char Name[kNameSize];
+ char MTime[kTimeSize];
+ char Number0[6];
+ char Number1[6];
+ char Mode[kModeSize];
+ char Size[kSizeSize];
+ char Quote;
+ char NewLine;
+ };
+ */
+ const int kHeaderSize = kNameSize + kTimeSize + 6 + 6 + kModeSize + kSizeSize + 1 + 1;
+}
+
+struct CItem
+{
+ AString Name;
+ UInt64 Size;
+ UInt32 MTime;
+ UInt32 Mode;
+
+ UInt64 HeaderPos;
+ UInt64 GetDataPos() const { return HeaderPos + NHeader::kHeaderSize; };
+ // UInt64 GetFullSize() const { return NFileHeader::kRecordSize + Size; };
+};
+
+class CInArchive
+{
+ CMyComPtr<IInStream> m_Stream;
+ UInt64 m_Position;
+
+ HRESULT GetNextItemReal(bool &filled, CItem &itemInfo);
+public:
+ HRESULT Open(IInStream *inStream);
+ HRESULT GetNextItem(bool &filled, CItem &itemInfo);
+ HRESULT SkipData(UInt64 dataSize);
+};
+
+HRESULT CInArchive::Open(IInStream *inStream)
+{
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
+ char signature[NHeader::kSignatureLen];
+ RINOK(ReadStream_FALSE(inStream, signature, NHeader::kSignatureLen));
+ m_Position += NHeader::kSignatureLen;
+ if (memcmp(signature, NHeader::kSignature, NHeader::kSignatureLen) != 0)
+ return S_FALSE;
+ m_Stream = inStream;
+ return S_OK;
+}
+
+static void MyStrNCpy(char *dest, const char *src, int size)
+{
+ for (int i = 0; i < size; i++)
+ {
+ char c = src[i];
+ dest[i] = c;
+ if (c == 0)
+ break;
+ }
+}
+
+static bool OctalToNumber(const char *s, int size, UInt64 &res)
+{
+ char sz[32];
+ MyStrNCpy(sz, s, size);
+ sz[size] = 0;
+ const char *end;
+ int i;
+ for (i = 0; sz[i] == ' '; i++);
+ res = ConvertOctStringToUInt64(sz + i, &end);
+ return (*end == ' ' || *end == 0);
+}
+
+static bool OctalToNumber32(const char *s, int size, UInt32 &res)
+{
+ UInt64 res64;
+ if (!OctalToNumber(s, size, res64))
+ return false;
+ res = (UInt32)res64;
+ return (res64 <= 0xFFFFFFFF);
+}
+
+static bool DecimalToNumber(const char *s, int size, UInt64 &res)
+{
+ char sz[32];
+ MyStrNCpy(sz, s, size);
+ sz[size] = 0;
+ const char *end;
+ int i;
+ for (i = 0; sz[i] == ' '; i++);
+ res = ConvertStringToUInt64(sz + i, &end);
+ return (*end == ' ' || *end == 0);
+}
+
+static bool DecimalToNumber32(const char *s, int size, UInt32 &res)
+{
+ UInt64 res64;
+ if (!DecimalToNumber(s, size, res64))
+ return false;
+ res = (UInt32)res64;
+ return (res64 <= 0xFFFFFFFF);
+}
+
+#define RIF(x) { if (!(x)) return S_FALSE; }
+
+
+HRESULT CInArchive::GetNextItemReal(bool &filled, CItem &item)
+{
+ filled = false;
+
+ char header[NHeader::kHeaderSize];
+ const char *cur = header;
+
+ size_t processedSize = sizeof(header);
+ item.HeaderPos = m_Position;
+ RINOK(ReadStream(m_Stream, header, &processedSize));
+ m_Position += processedSize;
+ if (processedSize != sizeof(header))
+ return S_OK;
+
+ char tempString[NHeader::kNameSize + 1];
+ MyStrNCpy(tempString, cur, NHeader::kNameSize);
+ cur += NHeader::kNameSize;
+ tempString[NHeader::kNameSize] = '\0';
+ item.Name = tempString;
+ item.Name.Trim();
+
+ for (int i = 0; i < item.Name.Length(); i++)
+ if (((Byte)item.Name[i]) < 0x20)
+ return S_FALSE;
+
+ RIF(DecimalToNumber32(cur, NHeader::kTimeSize, item.MTime));
+ cur += NHeader::kTimeSize;
+
+ cur += 6 + 6;
+
+ RIF(OctalToNumber32(cur, NHeader::kModeSize, item.Mode));
+ cur += NHeader::kModeSize;
+
+ RIF(DecimalToNumber(cur, NHeader::kSizeSize, item.Size));
+ cur += NHeader::kSizeSize;
+
+ filled = true;
+ return S_OK;
+}
+
+HRESULT CInArchive::GetNextItem(bool &filled, CItem &item)
+{
+ for (;;)
+ {
+ RINOK(GetNextItemReal(filled, item));
+ if (!filled)
+ return S_OK;
+ if (item.Name.Compare("debian-binary") != 0)
+ return S_OK;
+ if (item.Size != 4)
+ return S_OK;
+ SkipData(item.Size);
+ }
+}
+
+HRESULT CInArchive::SkipData(UInt64 dataSize)
+{
+ return m_Stream->Seek((dataSize + 1) & (~((UInt64)0x1)), STREAM_SEEK_CUR, &m_Position);
+}
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ CObjectVector<CItem> _items;
+ CMyComPtr<IInStream> _stream;
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ {
+ CInArchive archive;
+ if(archive.Open(stream) != S_OK)
+ return S_FALSE;
+ _items.Clear();
+
+ if (openArchiveCallback != NULL)
+ {
+ RINOK(openArchiveCallback->SetTotal(NULL, NULL));
+ UInt64 numFiles = _items.Size();
+ RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ }
+
+ for (;;)
+ {
+ CItem item;
+ bool filled;
+ HRESULT result = archive.GetNextItem(filled, item);
+ if (result == S_FALSE)
+ return S_FALSE;
+ if (result != S_OK)
+ return S_FALSE;
+ if (!filled)
+ break;
+ _items.Add(item);
+ archive.SkipData(item.Size);
+ if (openArchiveCallback != NULL)
+ {
+ UInt64 numFiles = _items.Size();
+ RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ }
+ }
+ _stream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _stream.Release();
+ _items.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _items.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItem &item = _items[index];
+
+ switch(propID)
+ {
+ case kpidPath: prop = (const wchar_t *)NItemName::GetOSName2(MultiByteToUnicodeString(item.Name, CP_OEMCP)); break;
+ case kpidSize:
+ case kpidPackSize:
+ prop = item.Size;
+ break;
+ case kpidMTime:
+ {
+ if (item.MTime != 0)
+ {
+ FILETIME fileTime;
+ NTime::UnixTimeToFileTime(item.MTime, fileTime);
+ prop = fileTime;
+ }
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _items[allFilesMode ? i : indices[i]].Size;
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_stream);
+
+ for (i = 0; i < numItems; i++)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _items[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ currentTotalSize += item.Size;
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ if (testMode)
+ {
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ RINOK(_stream->Seek(item.GetDataPos(), STREAM_SEEK_SET, NULL));
+ streamSpec->Init(item.Size);
+ RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ const CItem &item = _items[index];
+ return CreateLimitedInStream(_stream, item.GetDataPos(), item.Size, stream);
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new NArchive::NDeb::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Deb", L"deb", 0, 0xEC, { '!', '<', 'a', 'r', 'c', 'h', '>', '\n' }, 8, false, CreateArc, 0 };
+
+REGISTER_ARC(Deb)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DllExports2.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DllExports2.cpp
new file mode 100644
index 000000000..a21173ade
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DllExports2.cpp
@@ -0,0 +1,74 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/MyInitGuid.h"
+#include "../../Common/ComTry.h"
+#include "../../Common/Types.h"
+#include "../../Windows/PropVariant.h"
+#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
+#include "../../../C/Alloc.h"
+#endif
+
+#include "IArchive.h"
+#include "../ICoder.h"
+#include "../IPassword.h"
+
+#ifndef _UNICODE
+#ifdef _WIN32
+bool g_IsNT = false;
+HINSTANCE g_hInstance;
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+#endif
+
+#ifdef _WIN32
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ g_hInstance = hInstance;
+ #ifndef _UNICODE
+ #ifdef _WIN32
+ g_IsNT = IsItWindowsNT();
+ #endif
+ #endif
+ }
+ return TRUE;
+}
+#endif
+
+DEFINE_GUID(CLSID_CArchiveHandler,
+0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
+
+static const UInt16 kDecodeId = 0x2790;
+
+DEFINE_GUID(CLSID_CCodec,
+0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
+STDAPI CreateArchiver(const GUID *classID, const GUID *iid, void **outObject);
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ // COM_TRY_BEGIN
+ *outObject = 0;
+ if (*iid == IID_ICompressCoder || *iid == IID_ICompressCoder2 || *iid == IID_ICompressFilter)
+ {
+ return CreateCoder(clsid, iid, outObject);
+ }
+ else
+ {
+ return CreateArchiver(clsid, iid, outObject);
+ }
+ // COM_TRY_END
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DmgHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DmgHandler.cpp
new file mode 100644
index 000000000..dd1e95ecc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/DmgHandler.cpp
@@ -0,0 +1,778 @@
+// DmgHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+#include "Common/MyXml.h"
+#include "Common/UTFConvert.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/BZip2Decoder.h"
+#include "../Compress/CopyCoder.h"
+#include "../Compress/ZlibDecoder.h"
+
+// #define DMG_SHOW_RAW
+
+// #include <stdio.h>
+#define PRF(x) // x
+
+#define Get32(p) GetBe32(p)
+#define Get64(p) GetBe64(p)
+
+static int Base64ToByte(char c)
+{
+ if (c >= 'A' && c <= 'Z') return c - 'A';
+ if (c >= 'a' && c <= 'z') return c - 'a' + 26;
+ if (c >= '0' && c <= '9') return c - '0' + 52;
+ if (c == '+') return 62;
+ if (c == '/') return 63;
+ if (c == '=') return 0;
+ return -1;
+}
+
+static int Base64ToBin(Byte *dest, const char *src, int srcLen)
+{
+ int srcPos = 0;
+ int destPos = 0;
+ while (srcPos < srcLen)
+ {
+ Byte buf[4];
+ int filled = 0;
+ while (srcPos < srcLen)
+ {
+ int n = Base64ToByte(src[srcPos++]);
+ if (n >= 0)
+ {
+ buf[filled++] = (Byte)n;
+ if (filled == 4)
+ break;
+ }
+ }
+ if (filled >= 2) { if (dest) dest[destPos] = (buf[0] << 2) | (buf[1] >> 4); destPos++; }
+ if (filled >= 3) { if (dest) dest[destPos] = (buf[1] << 4) | (buf[2] >> 2); destPos++; }
+ if (filled >= 4) { if (dest) dest[destPos] = (buf[2] << 6) | (buf[3] ); destPos++; }
+ }
+ return destPos;
+}
+
+static UString GetSizeString(UInt64 value)
+{
+ wchar_t s[32];
+ wchar_t c;
+ if (value < (UInt64)20000) c = 0;
+ else if (value < ((UInt64)20000 << 10)) { value >>= 10; c = L'K'; }
+ else if (value < ((UInt64)20000 << 20)) { value >>= 20; c = L'M'; }
+ else { value >>= 30; c = L'G'; }
+ ConvertUInt64ToString(value, s);
+ int p = MyStringLen(s);
+ s[p++] = c;
+ s[p++] = L'\0';
+ return s;
+}
+
+namespace NArchive {
+namespace NDmg {
+
+struct CBlock
+{
+ UInt32 Type;
+ UInt64 UnpPos;
+ UInt64 UnpSize;
+ UInt64 PackPos;
+ UInt64 PackSize;
+};
+
+struct CFile
+{
+ CByteBuffer Raw;
+ // UInt64 StartPos;
+ CRecordVector<CBlock> Blocks;
+ UInt64 GetUnpackSize() const
+ {
+ UInt64 size = 0;
+ for (int i = 0; i < Blocks.Size(); i++)
+ size += Blocks[i].UnpSize;
+ return size;
+ };
+ UInt64 GetPackSize() const
+ {
+ UInt64 size = 0;
+ for (int i = 0; i < Blocks.Size(); i++)
+ size += Blocks[i].PackSize;
+ return size;
+ };
+
+ AString Name;
+};
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+
+ AString _xml;
+ CObjectVector<CFile> _files;
+ CRecordVector<int> _fileIndices;
+
+ HRESULT Open2(IInStream *stream);
+ HRESULT Extract(IInStream *stream);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+const UInt32 kXmlSizeMax = ((UInt32)1 << 31) - (1 << 14);
+
+enum
+{
+ METHOD_ZERO_0 = 0,
+ METHOD_COPY = 1,
+ METHOD_ZERO_2 = 2,
+ METHOD_ZLIB = 0x80000005,
+ METHOD_BZIP2 = 0x80000006,
+ METHOD_DUMMY = 0x7FFFFFFE,
+ METHOD_END = 0xFFFFFFFF
+};
+
+struct CMethodStat
+{
+ UInt32 NumBlocks;
+ UInt64 PackSize;
+ UInt64 UnpSize;
+ CMethodStat(): NumBlocks(0), PackSize(0), UnpSize(0) {}
+};
+
+struct CMethods
+{
+ CRecordVector<CMethodStat> Stats;
+ CRecordVector<UInt32> Types;
+ void Update(const CFile &file);
+ UString GetString() const;
+};
+
+void CMethods::Update(const CFile &file)
+{
+ for (int i = 0; i < file.Blocks.Size(); i++)
+ {
+ const CBlock &b = file.Blocks[i];
+ int index = Types.FindInSorted(b.Type);
+ if (index < 0)
+ {
+ index = Types.AddToUniqueSorted(b.Type);
+ Stats.Insert(index, CMethodStat());
+ }
+ CMethodStat &m = Stats[index];
+ m.PackSize += b.PackSize;
+ m.UnpSize += b.UnpSize;
+ m.NumBlocks++;
+ }
+}
+
+UString CMethods::GetString() const
+{
+ UString res;
+ for (int i = 0; i < Types.Size(); i++)
+ {
+ if (i != 0)
+ res += L' ';
+ wchar_t buf[32];
+ const wchar_t *s;
+ const CMethodStat &m = Stats[i];
+ bool showPack = true;
+ UInt32 type = Types[i];
+ switch(type)
+ {
+ case METHOD_ZERO_0: s = L"zero0"; showPack = (m.PackSize != 0); break;
+ case METHOD_ZERO_2: s = L"zero2"; showPack = (m.PackSize != 0); break;
+ case METHOD_COPY: s = L"copy"; showPack = (m.UnpSize != m.PackSize); break;
+ case METHOD_ZLIB: s = L"zlib"; break;
+ case METHOD_BZIP2: s = L"bzip2"; break;
+ default: ConvertUInt64ToString(type, buf); s = buf;
+ }
+ res += s;
+ if (m.NumBlocks != 1)
+ {
+ res += L'[';
+ ConvertUInt64ToString(m.NumBlocks, buf);
+ res += buf;
+ res += L']';
+ }
+ res += L'-';
+ res += GetSizeString(m.UnpSize);
+ if (showPack)
+ {
+ res += L'-';
+ res += GetSizeString(m.PackSize);
+ }
+ }
+ return res;
+}
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidComment, VT_BSTR},
+ { NULL, kpidMethod, VT_BSTR}
+};
+
+IMP_IInArchive_Props
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidNumBlocks, VT_UI4}
+};
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ CMethods m;
+ for (int i = 0; i < _files.Size(); i++)
+ m.Update(_files[i]);
+ prop = m.GetString();
+ break;
+ }
+ case kpidNumBlocks:
+ {
+ UInt64 numBlocks = 0;
+ for (int i = 0; i < _files.Size(); i++)
+ numBlocks += _files[i].Blocks.Size();
+ prop = numBlocks;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+IMP_IInArchive_ArcProps
+
+static int FindKeyPair(const CXmlItem &item, const AString &key, const AString &nextTag)
+{
+ for (int i = 0; i + 1 < item.SubItems.Size(); i++)
+ {
+ const CXmlItem &si = item.SubItems[i];
+ if (si.IsTagged("key") && si.GetSubString() == key && item.SubItems[i + 1].IsTagged(nextTag))
+ return i + 1;
+ }
+ return -1;
+}
+
+static AString GetStringFromKeyPair(const CXmlItem &item, const AString &key, const AString &nextTag)
+{
+ int index = FindKeyPair(item, key, nextTag);
+ if (index >= 0)
+ return item.SubItems[index].GetSubString();
+ return AString();
+}
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ const int HEADER_SIZE = 0x1E0;
+
+ UInt64 headerPos;
+ RINOK(stream->Seek(-HEADER_SIZE, STREAM_SEEK_END, &headerPos));
+ Byte buf[HEADER_SIZE];
+ RINOK(ReadStream_FALSE(stream, buf, HEADER_SIZE));
+ UInt64 address1 = Get64(buf + 0);
+ UInt64 address2 = Get64(buf + 0xB8);
+ UInt64 size64 = Get64(buf + 0xC0);
+ if (address1 != address2 || size64 >= kXmlSizeMax || size64 == 0 ||
+ address1 >= headerPos || address1 + size64 > headerPos)
+ return S_FALSE;
+ RINOK(stream->Seek(address1, STREAM_SEEK_SET, NULL));
+ size_t size = (size_t)size64;
+
+ char *ss = _xml.GetBuffer((int)size + 1);
+ RINOK(ReadStream_FALSE(stream, ss, size));
+ ss[size] = 0;
+ _xml.ReleaseBuffer();
+
+ CXml xml;
+ if (!xml.Parse(_xml))
+ return S_FALSE;
+ if (xml.Root.Name != "plist")
+ return S_FALSE;
+
+ int dictIndex = xml.Root.FindSubTag("dict");
+ if (dictIndex < 0)
+ return S_FALSE;
+
+ const CXmlItem &dictItem = xml.Root.SubItems[dictIndex];
+ int rfDictIndex = FindKeyPair(dictItem, "resource-fork", "dict");
+ if (rfDictIndex < 0)
+ return S_FALSE;
+
+ const CXmlItem &rfDictItem = dictItem.SubItems[rfDictIndex];
+ int arrIndex = FindKeyPair(rfDictItem, "blkx", "array");
+ if (arrIndex < 0)
+ return S_FALSE;
+
+ const CXmlItem &arrItem = rfDictItem.SubItems[arrIndex];
+
+ /* some DMG file has BUG:
+ PackPos for each new file is 0.
+ So we use additional "StartPos" to fix that BUG */
+
+ /*
+ UInt64 startPos = 0;
+ bool startPosIsDefined = false;
+ */
+
+
+ for (int i = 0; i < arrItem.SubItems.Size(); i++)
+ {
+ const CXmlItem &item = arrItem.SubItems[i];
+ if (!item.IsTagged("dict"))
+ continue;
+
+ CFile file;
+ // file.StartPos = startPos;
+
+ int destLen;
+ {
+ AString dataString;
+ AString name = GetStringFromKeyPair(item, "Name", "string");
+ if (name.IsEmpty())
+ name = GetStringFromKeyPair(item, "CFName", "string");
+ file.Name = name;
+ dataString = GetStringFromKeyPair(item, "Data", "data");
+
+ destLen = Base64ToBin(NULL, dataString, dataString.Length());
+ file.Raw.SetCapacity(destLen);
+ Base64ToBin(file.Raw, dataString, dataString.Length());
+ }
+
+ if (destLen > 0xCC && Get32(file.Raw) == 0x6D697368)
+ {
+ PRF(printf("\n\n index = %d", _files.Size()));
+ const int kRecordSize = 40;
+ for (int offset = 0xCC; offset + kRecordSize <= destLen; offset += kRecordSize)
+ {
+ const Byte *p = (const Byte *)file.Raw + offset;
+ CBlock b;
+ b.Type = Get32(p);
+ if (b.Type == METHOD_END)
+ break;
+ if (b.Type == METHOD_DUMMY)
+ continue;
+
+ b.UnpPos = Get64(p + 0x08) << 9;
+ b.UnpSize = Get64(p + 0x10) << 9;
+ b.PackPos = Get64(p + 0x18);
+ b.PackSize = Get64(p + 0x20);
+
+ /*
+ if (startPosIsdefined)
+ {
+ }
+ else
+ {
+ startPosIsdefined = true;
+ startPos = b.PackPos;
+ }
+ startPos += b.PackSize;
+ */
+
+ file.Blocks.Add(b);
+
+ PRF(printf("\nType=%8x m[1]=%8x uPos=%8x uSize=%7x pPos=%8x pSize=%7x",
+ b.Type, Get32(p + 4), (UInt32)b.UnpPos, (UInt32)b.UnpSize, (UInt32)b.PackPos, (UInt32)b.PackSize));
+ }
+ }
+ int itemIndex = _files.Add(file);
+ if (file.Blocks.Size() > 0)
+ {
+ // if (file.Name.Find("HFS") >= 0)
+ _fileIndices.Add(itemIndex);
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ {
+ Close();
+ if (Open2(stream) != S_OK)
+ return S_FALSE;
+ _inStream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _fileIndices.Clear();
+ _files.Clear();
+ _xml.Empty();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _fileIndices.Size()
+ #ifdef DMG_SHOW_RAW
+ + _files.Size() + 1;
+ #endif
+ ;
+ return S_OK;
+}
+
+#define RAW_PREFIX L"raw" WSTRING_PATH_SEPARATOR
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+
+ #ifdef DMG_SHOW_RAW
+ if ((int)index == _fileIndices.Size())
+ {
+ switch(propID)
+ {
+ case kpidPath:
+ prop = RAW_PREFIX L"a.xml";
+ break;
+ case kpidSize:
+ case kpidPackedSize:
+ prop = (UInt64)_xml.Length();
+ break;
+ }
+ }
+ else if ((int)index > _fileIndices.Size())
+ {
+ int rawIndex = (int)index - (_fileIndices.Size() + 1);
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ wchar_t s[32] = RAW_PREFIX;
+ ConvertUInt64ToString(rawIndex, s + MyStringLen(s));
+ prop = s;
+ break;
+ }
+ case kpidSize:
+ case kpidPackedSize:
+ prop = (UInt64)_files[rawIndex].Raw.GetCapacity();
+ break;
+ }
+ }
+ else
+ #endif
+ {
+ int itemIndex = _fileIndices[index];
+ const CFile &item = _files[itemIndex];
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ CMethods m;
+ m.Update(item);
+ UString resString = m.GetString();
+ if (!resString.IsEmpty())
+ prop = resString;
+ break;
+ }
+
+ // case kpidExtension: prop = L"hfs"; break;
+
+ case kpidPath:
+ {
+ // break;
+ UString name;
+ wchar_t s[32];
+ ConvertUInt64ToString(index, s);
+ name = s;
+ int num = 10;
+ int numDigits;
+ for (numDigits = 1; num < _fileIndices.Size(); numDigits++)
+ num *= 10;
+ while (name.Length() < numDigits)
+ name = L'0' + name;
+
+ AString subName;
+ int pos1 = item.Name.Find('(');
+ if (pos1 >= 0)
+ {
+ pos1++;
+ int pos2 = item.Name.Find(')', pos1);
+ if (pos2 >= 0)
+ {
+ subName = item.Name.Mid(pos1, pos2 - pos1);
+ pos1 = subName.Find(':');
+ if (pos1 >= 0)
+ subName = subName.Left(pos1);
+ }
+ }
+ subName.Trim();
+ if (!subName.IsEmpty())
+ {
+ if (subName == "Apple_HFS")
+ subName = "hfs";
+ else if (subName == "Apple_HFSX")
+ subName = "hfsx";
+ else if (subName == "Apple_Free")
+ subName = "free";
+ else if (subName == "DDM")
+ subName = "ddm";
+ UString name2;
+ ConvertUTF8ToUnicode(subName, name2);
+ name += L'.';
+ name += name2;
+ }
+ else
+ {
+ UString name2;
+ ConvertUTF8ToUnicode(item.Name, name2);
+ if (!name2.IsEmpty())
+ name += L" - ";
+ name += name2;
+ }
+ prop = name;
+ break;
+ }
+ case kpidComment:
+ {
+ UString name;
+ ConvertUTF8ToUnicode(item.Name, name);
+ prop = name;
+ break;
+ }
+
+ case kpidSize: prop = item.GetUnpackSize(); break;
+ case kpidPackSize: prop = item.GetPackSize(); break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _files.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ int index = (int)(allFilesMode ? i : indices[i]);
+ #ifdef DMG_SHOW_RAW
+ if (index == _fileIndices.Size())
+ totalSize += _xml.Length();
+ else if (index > _fileIndices.Size())
+ totalSize += _files[index - (_fileIndices.Size() + 1)].Raw.GetCapacity();
+ else
+ #endif
+ totalSize += _files[_fileIndices[index]].GetUnpackSize();
+ }
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentPackTotal = 0;
+ UInt64 currentUnpTotal = 0;
+ UInt64 currentPackSize = 0;
+ UInt64 currentUnpSize = 0;
+
+ const UInt32 kZeroBufSize = (1 << 14);
+ CByteBuffer zeroBuf;
+ zeroBuf.SetCapacity(kZeroBufSize);
+ memset(zeroBuf, 0, kZeroBufSize);
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ NCompress::NBZip2::CDecoder *bzip2CoderSpec = new NCompress::NBZip2::CDecoder();
+ CMyComPtr<ICompressCoder> bzip2Coder = bzip2CoderSpec;
+
+ NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
+ CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ for (i = 0; i < numItems; i++, currentPackTotal += currentPackSize, currentUnpTotal += currentUnpSize)
+ {
+ lps->InSize = currentPackTotal;
+ lps->OutSize = currentUnpTotal;
+ currentPackSize = 0;
+ currentUnpSize = 0;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ // const CItemEx &item = _files[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ CLimitedSequentialOutStream *outStreamSpec = new CLimitedSequentialOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->SetStream(realOutStream);
+
+ realOutStream.Release();
+
+ Int32 opRes = NArchive::NExtract::NOperationResult::kOK;
+ #ifdef DMG_SHOW_RAW
+ if (index > _fileIndices.Size())
+ {
+ const CByteBuffer &buf = _files[index - (_fileIndices.Size() + 1)].Raw;
+ outStreamSpec->Init(buf.GetCapacity());
+ RINOK(WriteStream(outStream, buf, buf.GetCapacity()));
+ currentPackSize = currentUnpSize = buf.GetCapacity();
+ }
+ else if (index == _fileIndices.Size())
+ {
+ outStreamSpec->Init(_xml.Length());
+ RINOK(WriteStream(outStream, (const char *)_xml, _xml.Length()));
+ currentPackSize = currentUnpSize = _xml.Length();
+ }
+ else
+ #endif
+ {
+ const CFile &item = _files[_fileIndices[index]];
+ currentPackSize = item.GetPackSize();
+ currentUnpSize = item.GetUnpackSize();
+
+ UInt64 unpPos = 0;
+ UInt64 packPos = 0;
+ {
+ for (int j = 0; j < item.Blocks.Size(); j++)
+ {
+ lps->InSize = currentPackTotal + packPos;
+ lps->OutSize = currentUnpTotal + unpPos;
+ RINOK(lps->SetCur());
+
+ const CBlock &block = item.Blocks[j];
+
+ packPos += block.PackSize;
+ if (block.UnpPos != unpPos)
+ {
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ break;
+ }
+
+ RINOK(_inStream->Seek(block.PackPos, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(block.PackSize);
+ // UInt64 startSize = outStreamSpec->GetSize();
+ bool realMethod = true;
+ outStreamSpec->Init(block.UnpSize);
+ HRESULT res = S_OK;
+
+ switch(block.Type)
+ {
+ case METHOD_ZERO_0:
+ case METHOD_ZERO_2:
+ realMethod = false;
+ if (block.PackSize != 0)
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ break;
+
+ case METHOD_COPY:
+ if (block.UnpSize != block.PackSize)
+ {
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ break;
+ }
+ res = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+ break;
+
+ case METHOD_ZLIB:
+ {
+ res = zlibCoder->Code(inStream, outStream, NULL, NULL, progress);
+ if (res != S_OK)
+ break;
+ break;
+ }
+
+ case METHOD_BZIP2:
+ {
+ res = bzip2Coder->Code(inStream, outStream, NULL, NULL, progress);
+ if (res == S_OK)
+ if (streamSpec->GetSize() != block.PackSize)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ break;
+ }
+
+ default:
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ break;
+ }
+ if (res != S_OK)
+ {
+ if (res != S_FALSE)
+ return res;
+ if (opRes == NArchive::NExtract::NOperationResult::kOK)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ }
+ unpPos += block.UnpSize;
+ if (!outStreamSpec->IsFinishedOK())
+ {
+ if (realMethod && opRes == NArchive::NExtract::NOperationResult::kOK)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+
+ while (outStreamSpec->GetRem() != 0)
+ {
+ UInt64 rem = outStreamSpec->GetRem();
+ UInt32 size = (UInt32)MyMin(rem, (UInt64)kZeroBufSize);
+ RINOK(WriteStream(outStream, zeroBuf, size));
+ }
+ }
+ }
+ }
+ }
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Dmg", L"dmg", 0, 0xE4, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Dmg)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ElfHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ElfHandler.cpp
new file mode 100644
index 000000000..66b18e7a7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ElfHandler.cpp
@@ -0,0 +1,535 @@
+// ElfHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+
+#include "Windows/PropVariantUtils.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+static UInt16 Get16(const Byte *p, int be) { if (be) return GetBe16(p); return GetUi16(p); }
+static UInt32 Get32(const Byte *p, int be) { if (be) return GetBe32(p); return GetUi32(p); }
+static UInt64 Get64(const Byte *p, int be) { if (be) return GetBe64(p); return GetUi64(p); }
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NElf {
+
+#define ELF_CLASS_32 1
+#define ELF_CLASS_64 2
+
+#define ELF_DATA_2LSB 1
+#define ELF_DATA_2MSB 2
+
+#define NUM_SCAN_SECTIONS_MAX (1 << 6)
+
+struct CHeader
+{
+ bool Mode64;
+ bool Be;
+ Byte Os;
+ Byte AbiVer;
+
+ UInt16 Type;
+ UInt16 Machine;
+ // UInt32 Version;
+
+ // UInt64 EntryVa;
+ UInt64 ProgOffset;
+ UInt64 SectOffset;
+ UInt32 Flags;
+ UInt16 ElfHeaderSize;
+ UInt16 SegmentEntrySize;
+ UInt16 NumSegments;
+ UInt16 SectEntrySize;
+ UInt16 NumSections;
+ // UInt16 SectNameStringTableIndex;
+
+ bool Parse(const Byte *buf);
+
+ bool CheckSegmentEntrySize() const
+ {
+ return (Mode64 && SegmentEntrySize == 0x38) || (!Mode64 && SegmentEntrySize == 0x20);
+ };
+
+ UInt64 GetHeadersSize() const
+ { return ElfHeaderSize +
+ (UInt64)SegmentEntrySize * NumSegments +
+ (UInt64)SectEntrySize * NumSections; }
+
+};
+
+bool CHeader::Parse(const Byte *p)
+{
+ switch(p[4])
+ {
+ case ELF_CLASS_32: Mode64 = false; break;
+ case ELF_CLASS_64: Mode64 = true; break;
+ default: return false;
+ }
+ bool be;
+ switch(p[5])
+ {
+ case ELF_DATA_2LSB: be = false; break;
+ case ELF_DATA_2MSB: be = true; break;
+ default: return false;
+ }
+ Be = be;
+ if (p[6] != 1) // Version
+ return false;
+ Os = p[7];
+ AbiVer = p[8];
+ for (int i = 9; i < 16; i++)
+ if (p[i] != 0)
+ return false;
+
+ Type = Get16(p + 0x10, be);
+ Machine = Get16(p + 0x12, be);
+ if (Get32(p + 0x14, be) != 1) // Version
+ return false;
+
+ if (Mode64)
+ {
+ // EntryVa = Get64(p + 0x18, be);
+ ProgOffset = Get64(p + 0x20, be);
+ SectOffset = Get64(p + 0x28, be);
+ p += 0x30;
+ }
+ else
+ {
+ // EntryVa = Get32(p + 0x18, be);
+ ProgOffset = Get32(p + 0x1C, be);
+ SectOffset = Get32(p + 0x20, be);
+ p += 0x24;
+ }
+
+ Flags = Get32(p + 0, be);
+ ElfHeaderSize = Get16(p + 4, be);
+ SegmentEntrySize = Get16(p + 6, be);
+ NumSegments = Get16(p + 8, be);
+ SectEntrySize = Get16(p + 10, be);
+ NumSections = Get16(p + 12, be);
+ // SectNameStringTableIndex = Get16(p + 14, be);
+ return CheckSegmentEntrySize();
+}
+
+struct CSegment
+{
+ UInt32 Type;
+ UInt32 Flags;
+ UInt64 Offset;
+ UInt64 Va;
+ // UInt64 Pa;
+ UInt64 PSize;
+ UInt64 VSize;
+ // UInt64 Align;
+
+ void UpdateTotalSize(UInt64 &totalSize)
+ {
+ UInt64 t = Offset + PSize;
+ if (t > totalSize)
+ totalSize = t;
+ }
+ void Parse(const Byte *p, bool mode64, bool be);
+};
+
+void CSegment::Parse(const Byte *p, bool mode64, bool be)
+{
+ Type = Get32(p, be);
+ if (mode64)
+ {
+ Flags = Get32(p + 4, be);
+ Offset = Get64(p + 8, be);
+ Va = Get64(p + 0x10, be);
+ // Pa = Get64(p + 0x18, be);
+ PSize = Get64(p + 0x20, be);
+ VSize = Get64(p + 0x28, be);
+ // Align = Get64(p + 0x30, be);
+ }
+ else
+ {
+ Offset = Get32(p + 4, be);
+ Va = Get32(p + 8, be);
+ // Pa = Get32(p + 12, be);
+ PSize = Get32(p + 16, be);
+ VSize = Get32(p + 20, be);
+ Flags = Get32(p + 24, be);
+ // Align = Get32(p + 28, be);
+ }
+}
+
+static const CUInt32PCharPair g_MachinePairs[] =
+{
+ { 0, "None" },
+ { 1, "AT&T WE 32100" },
+ { 2, "SPARC" },
+ { 3, "Intel 386" },
+ { 4, "Motorola 68000" },
+ { 5, "Motorola 88000" },
+ { 6, "Intel 486" },
+ { 7, "Intel i860" },
+ { 8, "MIPS" },
+ { 9, "IBM S/370" },
+ { 10, "MIPS RS3000 LE" },
+ { 11, "RS6000" },
+
+ { 15, "PA-RISC" },
+ { 16, "nCUBE" },
+ { 17, "Fujitsu VPP500" },
+ { 18, "SPARC 32+" },
+ { 19, "Intel i960" },
+ { 20, "PowerPC" },
+ { 21, "PowerPC 64-bit" },
+ { 22, "IBM S/390" },
+
+ { 36, "NEX v800" },
+ { 37, "Fujitsu FR20" },
+ { 38, "TRW RH-32" },
+ { 39, "Motorola RCE" },
+ { 40, "ARM" },
+ { 41, "Alpha" },
+ { 42, "Hitachi SH" },
+ { 43, "SPARC-V9" },
+ { 44, "Siemens Tricore" },
+ { 45, "ARC" },
+ { 46, "H8/300" },
+ { 47, "H8/300H" },
+ { 48, "H8S" },
+ { 49, "H8/500" },
+ { 50, "IA-64" },
+ { 51, "Stanford MIPS-X" },
+ { 52, "Motorola ColdFire" },
+ { 53, "M68HC12" },
+ { 54, "Fujitsu MMA" },
+ { 55, "Siemens PCP" },
+ { 56, "Sony nCPU" },
+ { 57, "Denso NDR1" },
+ { 58, "Motorola StarCore" },
+ { 59, "Toyota ME16" },
+ { 60, "ST100" },
+ { 61, "Advanced Logic TinyJ" },
+ { 62, "AMD64" },
+ { 63, "Sony DSP" },
+
+ { 66, "Siemens FX66" },
+ { 67, "ST9+" },
+ { 68, "ST7" },
+ { 69, "MC68HC16" },
+ { 70, "MC68HC11" },
+ { 71, "MC68HC08" },
+ { 72, "MC68HC05" },
+ { 73, "Silicon Graphics SVx" },
+ { 74, "ST19" },
+ { 75, "Digital VAX" },
+ { 76, "Axis CRIS" },
+ { 77, "Infineon JAVELIN" },
+ { 78, "Element 14 FirePath" },
+ { 79, "LSI ZSP" },
+ { 80, "MMIX" },
+ { 81, "HUANY" },
+ { 82, "SiTera Prism" },
+ { 83, "Atmel AVR" },
+ { 84, "Fujitsu FR30" },
+ { 85, "Mitsubishi D10V" },
+ { 86, "Mitsubishi D30V" },
+ { 87, "NEC v850" },
+ { 88, "Mitsubishi M32R" },
+ { 89, "Matsushita MN10300" },
+ { 90, "Matsushita MN10200" },
+ { 91, "picoJava" },
+ { 92, "OpenRISC" },
+ { 93, "ARC Tangent-A5" },
+ { 94, "Tensilica Xtensa" },
+ { 0x9026, "Alpha" }
+};
+
+static const CUInt32PCharPair g_AbiOS[] =
+{
+ { 0, "None" },
+ { 1, "HP-UX" },
+ { 2, "NetBSD" },
+ { 3, "Linux" },
+
+ { 6, "Solaris" },
+ { 7, "AIX" },
+ { 8, "IRIX" },
+ { 9, "FreeBSD" },
+ { 10, "TRU64" },
+ { 11, "Novell Modesto" },
+ { 12, "OpenBSD" },
+ { 13, "OpenVMS" },
+ { 14, "HP NSK" },
+ { 15, "AROS" },
+ { 97, "ARM" },
+ { 255, "Standalone" }
+};
+
+static const CUInt32PCharPair g_SegmentFlags[] =
+{
+ { 1 << 0, "Execute" },
+ { 1 << 1, "Write" },
+ { 1 << 2, "Read" }
+};
+
+static const char *g_Types[] =
+{
+ "None",
+ "Relocatable file",
+ "Executable file",
+ "Shared object file",
+ "Core file"
+};
+
+static const char *g_SegnmentTypes[] =
+{
+ "Unused",
+ "Loadable segment",
+ "Dynamic linking tables",
+ "Program interpreter path name",
+ "Note section",
+ "SHLIB",
+ "Program header table",
+ "TLS"
+};
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+ CObjectVector<CSegment> _sections;
+ UInt32 _peOffset;
+ CHeader _header;
+ UInt64 _totalSize;
+ HRESULT Open2(IInStream *stream);
+ bool Parse(const Byte *buf, UInt32 size);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+#define ELF_PT_PHDR 6
+
+bool CHandler::Parse(const Byte *buf, UInt32 size)
+{
+ if (size < 64)
+ return false;
+ if (!_header.Parse(buf))
+ return false;
+ if (_header.ProgOffset > size ||
+ _header.ProgOffset + (UInt64)_header.SegmentEntrySize * _header.NumSegments > size ||
+ _header.NumSegments > NUM_SCAN_SECTIONS_MAX)
+ return false;
+ const Byte *p = buf + _header.ProgOffset;
+ _totalSize = _header.ProgOffset;
+
+ for (int i = 0; i < _header.NumSegments; i++, p += _header.SegmentEntrySize)
+ {
+ CSegment sect;
+ sect.Parse(p, _header.Mode64, _header.Be);
+ sect.UpdateTotalSize(_totalSize);
+ if (sect.Type != ELF_PT_PHDR)
+ _sections.Add(sect);
+ }
+ UInt64 total2 = _header.SectOffset + (UInt64)_header.SectEntrySize * _header.NumSections;
+ if (total2 > _totalSize)
+ _totalSize = total2;
+ return true;
+}
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidCpu, VT_BSTR},
+ { NULL, kpidBit64, VT_BOOL},
+ { NULL, kpidBigEndian, VT_BOOL},
+ { NULL, kpidHostOS, VT_BSTR},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidPhySize, VT_UI8},
+ { NULL, kpidHeadersSize, VT_UI8}
+ };
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidType, VT_BSTR},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidOffset, VT_UI8},
+ { NULL, kpidVa, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPhySize: prop = _totalSize; break;
+ case kpidHeadersSize: prop = _header.GetHeadersSize(); break;
+ case kpidBit64: if (_header.Mode64) prop = _header.Mode64; break;
+ case kpidBigEndian: if (_header.Be) prop = _header.Be; break;
+ case kpidCpu: PAIR_TO_PROP(g_MachinePairs, _header.Machine, prop); break;
+ case kpidHostOS: PAIR_TO_PROP(g_AbiOS, _header.Os, prop); break;
+ case kpidCharacts: TYPE_TO_PROP(g_Types, _header.Type, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ const CSegment &item = _sections[index];
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ wchar_t sz[32];
+ ConvertUInt64ToString(index, sz);
+ prop = sz;
+ break;
+ }
+ case kpidSize: prop = (UInt64)item.VSize; break;
+ case kpidPackSize: prop = (UInt64)item.PSize; break;
+ case kpidOffset: prop = item.Offset; break;
+ case kpidVa: prop = item.Va; break;
+ case kpidType: TYPE_TO_PROP(g_SegnmentTypes, item.Type, prop); break;
+ case kpidCharacts: FLAGS_TO_PROP(g_SegmentFlags, item.Flags, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ const UInt32 kBufSize = 1 << 18;
+ const UInt32 kSigSize = 4;
+
+ CByteBuffer buffer;
+ buffer.SetCapacity(kBufSize);
+ Byte *buf = buffer;
+
+ size_t processed = kSigSize;
+ RINOK(ReadStream_FALSE(stream, buf, processed));
+ if (buf[0] != 0x7F || buf[1] != 'E' || buf[2] != 'L' || buf[3] != 'F')
+ return S_FALSE;
+ processed = kBufSize - kSigSize;
+ RINOK(ReadStream(stream, buf + kSigSize, &processed));
+ processed += kSigSize;
+ if (!Parse(buf, (UInt32)processed))
+ return S_FALSE;
+ UInt64 fileSize;
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
+ return (fileSize == _totalSize) ? S_OK : S_FALSE;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ RINOK(Open2(inStream));
+ _inStream = inStream;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _sections.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _sections.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _sections.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _sections[allFilesMode ? i : indices[i]].PSize;
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+ const CSegment &item = _sections[index];
+ currentItemSize = item.PSize;
+
+ CMyComPtr<ISequentialOutStream> outStream;
+ RINOK(extractCallback->GetStream(index, &outStream, askMode));
+ if (!testMode && !outStream)
+ continue;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(_inStream->Seek(item.Offset, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(currentItemSize);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == currentItemSize ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"ELF", L"", 0, 0xDE, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Elf)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/FatHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/FatHandler.cpp
new file mode 100644
index 000000000..f07d4ccb7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/FatHandler.cpp
@@ -0,0 +1,983 @@
+// FatHandler.cpp
+
+#include "StdAfx.h"
+
+// #include <stdio.h>
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+#include "Common/MyCom.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#include "Common/DummyOutStream.h"
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+
+#define PRF(x) /* x */
+
+namespace NArchive {
+namespace NFat {
+
+static const UInt32 kFatItemUsedByDirMask = (UInt32)1 << 31;
+
+struct CHeader
+{
+ UInt32 NumSectors;
+ UInt16 NumReservedSectors;
+ Byte NumFats;
+ UInt32 NumFatSectors;
+ UInt32 RootDirSector;
+ UInt32 NumRootDirSectors;
+ UInt32 DataSector;
+
+ UInt32 FatSize;
+ UInt32 BadCluster;
+
+ Byte NumFatBits;
+ Byte SectorSizeLog;
+ Byte SectorsPerClusterLog;
+ Byte ClusterSizeLog;
+
+ UInt16 SectorsPerTrack;
+ UInt16 NumHeads;
+ UInt32 NumHiddenSectors;
+
+ bool VolFieldsDefined;
+
+ UInt32 VolId;
+ // Byte VolName[11];
+ // Byte FileSys[8];
+
+ // Byte OemName[5];
+ Byte MediaType;
+
+ // 32-bit FAT
+ UInt16 Flags;
+ UInt16 FsInfoSector;
+ UInt32 RootCluster;
+
+ bool IsFat32() const { return NumFatBits == 32; }
+ UInt64 GetPhySize() const { return (UInt64)NumSectors << SectorSizeLog; }
+ UInt32 SectorSize() const { return (UInt32)1 << SectorSizeLog; }
+ UInt32 ClusterSize() const { return (UInt32)1 << ClusterSizeLog; }
+ UInt32 ClusterToSector(UInt32 c) const { return DataSector + ((c - 2) << SectorsPerClusterLog); }
+ UInt32 IsEoc(UInt32 c) const { return c > BadCluster; }
+ UInt32 IsEocAndUnused(UInt32 c) const { return c > BadCluster && (c & kFatItemUsedByDirMask) == 0; }
+ UInt32 IsValidCluster(UInt32 c) const { return c >= 2 && c < FatSize; }
+ UInt32 SizeToSectors(UInt32 size) const { return (size + SectorSize() - 1) >> SectorSizeLog; }
+ UInt32 CalcFatSizeInSectors() const { return SizeToSectors((FatSize * (NumFatBits / 4) + 1) / 2); }
+
+ UInt32 GetFatSector() const
+ {
+ UInt32 index = (IsFat32() && (Flags & 0x80) != 0) ? (Flags & 0xF) : 0;
+ if (index > NumFats)
+ index = 0;
+ return NumReservedSectors + index * NumFatSectors;
+ }
+
+ UInt64 GetFilePackSize(UInt32 unpackSize) const
+ {
+ UInt64 mask = ClusterSize() - 1;
+ return (unpackSize + mask) & ~mask;
+ }
+
+ UInt32 GetNumClusters(UInt32 size) const
+ { return (UInt32)(((UInt64)size + ClusterSize() - 1) >> ClusterSizeLog); }
+
+ bool Parse(const Byte *p);
+};
+
+static int GetLog(UInt32 num)
+{
+ for (int i = 0; i < 31; i++)
+ if (((UInt32)1 << i) == num)
+ return i;
+ return -1;
+}
+
+bool CHeader::Parse(const Byte *p)
+{
+ if (p[0x1FE] != 0x55 || p[0x1FF] != 0xAA)
+ return false;
+
+ int codeOffset = 0;
+ switch (p[0])
+ {
+ case 0xE9: codeOffset = 3 + (Int16)Get16(p + 1); break;
+ case 0xEB: if (p[2] != 0x90) return false; codeOffset = 2 + (signed char)p[1]; break;
+ default: return false;
+ }
+ {
+ int s = GetLog(Get16(p + 11));
+ if (s < 9 || s > 12)
+ return false;
+ SectorSizeLog = (Byte)s;
+ s = GetLog(p[13]);
+ if (s < 0)
+ return false;
+ SectorsPerClusterLog = (Byte)s;
+ ClusterSizeLog = SectorSizeLog + SectorsPerClusterLog;
+ }
+
+ NumReservedSectors = Get16(p + 14);
+ if (NumReservedSectors == 0)
+ return false;
+
+ NumFats = p[16];
+ if (NumFats < 1 || NumFats > 4)
+ return false;
+
+ UInt16 numRootDirEntries = Get16(p + 17);
+ if (numRootDirEntries == 0)
+ {
+ if (codeOffset < 90)
+ return false;
+ NumFatBits = 32;
+ NumRootDirSectors = 0;
+ }
+ else
+ {
+ if (codeOffset < 62)
+ return false;
+ NumFatBits = 0;
+ UInt32 mask = (1 << (SectorSizeLog - 5)) - 1;
+ if ((numRootDirEntries & mask) != 0)
+ return false;
+ NumRootDirSectors = (numRootDirEntries + mask) >> (SectorSizeLog - 5);
+ }
+
+ NumSectors = Get16(p + 19);
+ if (NumSectors == 0)
+ NumSectors = Get32(p + 32);
+ else if (IsFat32())
+ return false;
+
+ MediaType = p[21];
+ NumFatSectors = Get16(p + 22);
+ SectorsPerTrack = Get16(p + 24);
+ NumHeads = Get16(p + 26);
+ NumHiddenSectors = Get32(p + 28);
+
+ // memcpy(OemName, p + 3, 5);
+
+ p += 36;
+ if (IsFat32())
+ {
+ if (NumFatSectors != 0)
+ return false;
+ NumFatSectors = Get32(p);
+ if (NumFatSectors >= (1 << 24))
+ return false;
+
+ Flags = Get16(p + 4);
+ if (Get16(p + 6) != 0)
+ return false;
+ RootCluster = Get32(p + 8);
+ FsInfoSector = Get16(p + 12);
+ for (int i = 16; i < 28; i++)
+ if (p[i] != 0)
+ return false;
+ p += 28;
+ }
+
+ // DriveNumber = p[0];
+ VolFieldsDefined = (p[2] == 0x29); // ExtendedBootSig
+ VolId = Get32(p + 3);
+ // memcpy(VolName, p + 7, 11);
+ // memcpy(FileSys, p + 18, 8);
+
+ if (NumFatSectors == 0)
+ return false;
+ RootDirSector = NumReservedSectors + NumFatSectors * NumFats;
+ DataSector = RootDirSector + NumRootDirSectors;
+ if (NumSectors < DataSector)
+ return false;
+ UInt32 numDataSectors = NumSectors - DataSector;
+ UInt32 numClusters = numDataSectors >> SectorsPerClusterLog;
+
+ BadCluster = 0x0FFFFFF7;
+ if (numClusters < 0xFFF5)
+ {
+ if (NumFatBits == 32)
+ return false;
+ NumFatBits = (numClusters < 0xFF5) ? 12: 16;
+ BadCluster &= ((1 << NumFatBits) - 1);
+ }
+ else if (NumFatBits != 32)
+ return false;
+
+ FatSize = numClusters + 2;
+ if (FatSize > BadCluster || CalcFatSizeInSectors() > NumFatSectors)
+ return false;
+ return true;
+}
+
+struct CItem
+{
+ UString UName;
+ char DosName[11];
+ Byte CTime2;
+ UInt32 CTime;
+ UInt32 MTime;
+ UInt16 ADate;
+ Byte Attrib;
+ Byte Flags;
+ UInt32 Size;
+ UInt32 Cluster;
+ Int32 Parent;
+
+ // NT uses Flags to store Low Case status
+ bool NameIsLow() const { return (Flags & 0x8) != 0; }
+ bool ExtIsLow() const { return (Flags & 0x10) != 0; }
+ bool IsDir() const { return (Attrib & 0x10) != 0; }
+ UString GetShortName() const;
+ UString GetName() const;
+ UString GetVolName() const;
+};
+
+static int CopyAndTrim(char *dest, const char *src, int size, bool toLower)
+{
+ int i;
+ memcpy(dest, src, size);
+ if (toLower)
+ for (i = 0; i < size; i++)
+ {
+ char c = dest[i];
+ if (c >= 'A' && c <= 'Z')
+ dest[i] = c + 0x20;
+ }
+ for (i = size - 1; i >= 0 && dest[i] == ' '; i--);
+ return i + 1;
+}
+
+static UString FatStringToUnicode(const char *s)
+{
+ return MultiByteToUnicodeString(s, CP_OEMCP);
+}
+
+UString CItem::GetShortName() const
+{
+ char s[16];
+ int i = CopyAndTrim(s, DosName, 8, NameIsLow());
+ s[i++] = '.';
+ int j = CopyAndTrim(s + i, DosName + 8, 3, ExtIsLow());
+ if (j == 0)
+ j--;
+ s[i + j] = 0;
+ return FatStringToUnicode(s);
+}
+
+UString CItem::GetName() const
+{
+ if (!UName.IsEmpty())
+ return UName;
+ return GetShortName();
+}
+
+UString CItem::GetVolName() const
+{
+ if (!UName.IsEmpty())
+ return UName;
+ char s[12];
+ int i = CopyAndTrim(s, DosName, 11, false);
+ s[i] = 0;
+ return FatStringToUnicode(s);
+}
+
+struct CDatabase
+{
+ CHeader Header;
+ CObjectVector<CItem> Items;
+ UInt32 *Fat;
+ CMyComPtr<IInStream> InStream;
+ IArchiveOpenCallback *OpenCallback;
+
+ UInt32 NumFreeClusters;
+ bool VolItemDefined;
+ CItem VolItem;
+ UInt32 NumDirClusters;
+ CByteBuffer ByteBuf;
+ UInt64 NumCurUsedBytes;
+
+ CDatabase(): Fat(0) {}
+ ~CDatabase() { ClearAndClose(); }
+
+ void Clear();
+ void ClearAndClose();
+ HRESULT OpenProgressFat(bool changeTotal = true);
+ HRESULT OpenProgress();
+
+ UString GetItemPath(Int32 index) const;
+ HRESULT Open();
+ HRESULT ReadDir(Int32 parent, UInt32 cluster, int level);
+
+ UInt64 GetHeadersSize() const
+ {
+ return (UInt64)(Header.DataSector + (NumDirClusters << Header.SectorsPerClusterLog)) << Header.SectorSizeLog;
+ }
+ HRESULT SeekToSector(UInt32 sector);
+ HRESULT SeekToCluster(UInt32 cluster) { return SeekToSector(Header.ClusterToSector(cluster)); }
+};
+
+HRESULT CDatabase::SeekToSector(UInt32 sector)
+{
+ return InStream->Seek((UInt64)sector << Header.SectorSizeLog, STREAM_SEEK_SET, NULL);
+}
+
+void CDatabase::Clear()
+{
+ VolItemDefined = false;
+ NumDirClusters = 0;
+ NumCurUsedBytes = 0;
+
+ Items.Clear();
+ delete []Fat;
+ Fat = 0;
+}
+
+void CDatabase::ClearAndClose()
+{
+ Clear();
+ InStream.Release();
+}
+
+HRESULT CDatabase::OpenProgressFat(bool changeTotal)
+{
+ if (!OpenCallback)
+ return S_OK;
+ if (changeTotal)
+ {
+ UInt64 numTotalBytes = (Header.CalcFatSizeInSectors() << Header.SectorSizeLog) +
+ ((UInt64)(Header.FatSize - NumFreeClusters) << Header.ClusterSizeLog);
+ RINOK(OpenCallback->SetTotal(NULL, &numTotalBytes));
+ }
+ return OpenCallback->SetCompleted(NULL, &NumCurUsedBytes);
+}
+
+HRESULT CDatabase::OpenProgress()
+{
+ if (!OpenCallback)
+ return S_OK;
+ UInt64 numItems = Items.Size();
+ return OpenCallback->SetCompleted(&numItems, &NumCurUsedBytes);
+}
+
+UString CDatabase::GetItemPath(Int32 index) const
+{
+ const CItem *item = &Items[index];
+ UString name = item->GetName();
+ for (;;)
+ {
+ index = item->Parent;
+ if (index < 0)
+ return name;
+ item = &Items[index];
+ name = item->GetName() + WCHAR_PATH_SEPARATOR + name;
+ }
+}
+
+static wchar_t *AddSubStringToName(wchar_t *dest, const Byte *p, int numChars)
+{
+ for (int i = 0; i < numChars; i++)
+ {
+ wchar_t c = Get16(p + i * 2);
+ if (c != 0 && c != 0xFFFF)
+ *dest++ = c;
+ }
+ *dest = 0;
+ return dest;
+}
+
+HRESULT CDatabase::ReadDir(Int32 parent, UInt32 cluster, int level)
+{
+ int startIndex = Items.Size();
+ if (startIndex >= (1 << 30) || level > 256)
+ return S_FALSE;
+
+ UInt32 sectorIndex = 0;
+ UInt32 blockSize = Header.ClusterSize();
+ bool clusterMode = (Header.IsFat32() || parent >= 0);
+ if (!clusterMode)
+ {
+ blockSize = Header.SectorSize();
+ RINOK(SeekToSector(Header.RootDirSector));
+ }
+
+ ByteBuf.SetCapacity(blockSize);
+ UString curName;
+ int checkSum = -1;
+ int numLongRecords = -1;
+ for (UInt32 pos = blockSize;; pos += 32)
+ {
+ if (pos == blockSize)
+ {
+ pos = 0;
+
+ if ((NumDirClusters & 0xFF) == 0)
+ {
+ RINOK(OpenProgress());
+ }
+
+ if (clusterMode)
+ {
+ if (Header.IsEoc(cluster))
+ break;
+ if (!Header.IsValidCluster(cluster))
+ return S_FALSE;
+ PRF(printf("\nCluster = %4X", cluster));
+ RINOK(SeekToCluster(cluster));
+ UInt32 newCluster = Fat[cluster];
+ if ((newCluster & kFatItemUsedByDirMask) != 0)
+ return S_FALSE;
+ Fat[cluster] |= kFatItemUsedByDirMask;
+ cluster = newCluster;
+ NumDirClusters++;
+ NumCurUsedBytes += Header.ClusterSize();
+ }
+ else if (sectorIndex++ >= Header.NumRootDirSectors)
+ break;
+
+ RINOK(ReadStream_FALSE(InStream, ByteBuf, blockSize));
+ }
+ const Byte *p = ByteBuf + pos;
+ if (p[0] == 0)
+ {
+ if (clusterMode && !Header.IsEoc(cluster))
+ return S_FALSE;
+ break;
+ }
+ if (p[0] == 0xE5)
+ {
+ if (numLongRecords > 0)
+ return S_FALSE;
+ continue;
+ }
+
+ Byte attrib = p[11];
+ if ((attrib & 0x3F) == 0xF)
+ {
+ if (p[0] > 0x7F || Get16(p + 26) != 0)
+ return S_FALSE;
+ int longIndex = p[0] & 0x3F;
+ if (longIndex == 0)
+ return S_FALSE;
+ bool isLast = (p[0] & 0x40) != 0;
+ if (numLongRecords < 0)
+ {
+ if (!isLast)
+ return S_FALSE;
+ numLongRecords = longIndex;
+ }
+ else if (isLast || numLongRecords != longIndex)
+ return S_FALSE;
+
+ numLongRecords--;
+
+ if (p[12] == 0)
+ {
+ wchar_t nameBuf[14];
+ wchar_t *dest;
+
+ dest = AddSubStringToName(nameBuf, p + 1, 5);
+ dest = AddSubStringToName(dest, p + 14, 6);
+ AddSubStringToName(dest, p + 28, 2);
+ curName = nameBuf + curName;
+ if (isLast)
+ checkSum = p[13];
+ if (checkSum != p[13])
+ return S_FALSE;
+ }
+ }
+ else
+ {
+ if (numLongRecords > 0)
+ return S_FALSE;
+ CItem item;
+ memcpy(item.DosName, p, 11);
+
+ if (checkSum >= 0)
+ {
+ Byte sum = 0;
+ for (int i = 0; i < 11; i++)
+ sum = ((sum & 1) ? 0x80 : 0) + (sum >> 1) + (Byte)item.DosName[i];
+ if (sum == checkSum)
+ item.UName = curName;
+ }
+
+ if (item.DosName[0] == 5)
+ item.DosName[0] = (char)(Byte)0xE5;
+ item.Attrib = attrib;
+ item.Flags = p[12];
+ item.Size = Get32(p + 28);
+ item.Cluster = Get16(p + 26) | ((UInt32)Get16(p + 20) << 16);
+ item.CTime = Get32(p + 14);
+ item.CTime2 = p[13];
+ item.ADate = Get16(p + 18);
+ item.MTime = Get32(p + 22);
+ item.Parent = parent;
+
+ if (attrib == 8)
+ {
+ VolItem = item;
+ VolItemDefined = true;
+ }
+ else
+ if (memcmp(item.DosName, ". ", 11) != 0 &&
+ memcmp(item.DosName, ".. ", 11) != 0)
+ {
+ if (!item.IsDir())
+ NumCurUsedBytes += Header.GetFilePackSize(item.Size);
+ Items.Add(item);
+ PRF(printf("\n%7d: %S", Items.Size(), GetItemPath(Items.Size() - 1)));
+ }
+ numLongRecords = -1;
+ curName.Empty();
+ checkSum = -1;
+ }
+ }
+
+ int finishIndex = Items.Size();
+ for (int i = startIndex; i < finishIndex; i++)
+ {
+ const CItem &item = Items[i];
+ if (item.IsDir())
+ {
+ PRF(printf("\n%S", GetItemPath(i)));
+ RINOK(CDatabase::ReadDir(i, item.Cluster, level + 1));
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CDatabase::Open()
+{
+ Clear();
+ bool numFreeClustersDefined = false;
+ {
+ static const UInt32 kHeaderSize = 512;
+ Byte buf[kHeaderSize];
+ RINOK(ReadStream_FALSE(InStream, buf, kHeaderSize));
+ if (!Header.Parse(buf))
+ return S_FALSE;
+ UInt64 fileSize;
+ RINOK(InStream->Seek(0, STREAM_SEEK_END, &fileSize));
+ if (fileSize < Header.GetPhySize())
+ return S_FALSE;
+
+ if (Header.IsFat32())
+ {
+ SeekToSector(Header.FsInfoSector);
+ RINOK(ReadStream_FALSE(InStream, buf, kHeaderSize));
+ if (buf[0x1FE] != 0x55 || buf[0x1FF] != 0xAA)
+ return S_FALSE;
+ if (Get32(buf) == 0x41615252 && Get32(buf + 484) == 0x61417272)
+ {
+ NumFreeClusters = Get32(buf + 488);
+ numFreeClustersDefined = (NumFreeClusters <= Header.FatSize);
+ }
+ }
+ }
+
+ // numFreeClustersDefined = false; // to recalculate NumFreeClusters
+ if (!numFreeClustersDefined)
+ NumFreeClusters = 0;
+
+ CByteBuffer byteBuf;
+ Fat = new UInt32[Header.FatSize];
+
+ RINOK(OpenProgressFat());
+ RINOK(SeekToSector(Header.GetFatSector()));
+ if (Header.NumFatBits == 32)
+ {
+ const UInt32 kBufSize = (1 << 15);
+ byteBuf.SetCapacity(kBufSize);
+ for (UInt32 i = 0; i < Header.FatSize;)
+ {
+ UInt32 size = Header.FatSize - i;
+ const UInt32 kBufSize32 = kBufSize / 4;
+ if (size > kBufSize32)
+ size = kBufSize32;
+ UInt32 readSize = Header.SizeToSectors(size * 4) << Header.SectorSizeLog;
+ RINOK(ReadStream_FALSE(InStream, byteBuf, readSize));
+ NumCurUsedBytes += readSize;
+
+ const UInt32 *src = (const UInt32 *)(const Byte *)byteBuf;
+ UInt32 *dest = Fat + i;
+ if (numFreeClustersDefined)
+ for (UInt32 j = 0; j < size; j++)
+ dest[j] = Get32(src + j) & 0x0FFFFFFF;
+ else
+ {
+ UInt32 numFreeClusters = 0;
+ for (UInt32 j = 0; j < size; j++)
+ {
+ UInt32 v = Get32(src + j) & 0x0FFFFFFF;
+ numFreeClusters += (UInt32)(v - 1) >> 31;
+ dest[j] = v;
+ }
+ NumFreeClusters += numFreeClusters;
+ }
+ i += size;
+ if ((i & 0xFFFFF) == 0)
+ {
+ RINOK(OpenProgressFat(!numFreeClustersDefined));
+ }
+ }
+ }
+ else
+ {
+ const UInt32 kBufSize = (UInt32)Header.CalcFatSizeInSectors() << Header.SectorSizeLog;
+ NumCurUsedBytes += kBufSize;
+ byteBuf.SetCapacity(kBufSize);
+ Byte *p = byteBuf;
+ RINOK(ReadStream_FALSE(InStream, p, kBufSize));
+ UInt32 fatSize = Header.FatSize;
+ UInt32 *fat = &Fat[0];
+ if (Header.NumFatBits == 16)
+ for (UInt32 j = 0; j < fatSize; j++)
+ fat[j] = Get16(p + j * 2);
+ else
+ for (UInt32 j = 0; j < fatSize; j++)
+ fat[j] = (Get16(p + j * 3 / 2) >> ((j & 1) << 2)) & 0xFFF;
+
+ if (!numFreeClustersDefined)
+ {
+ UInt32 numFreeClusters = 0;
+ for (UInt32 i = 0; i < fatSize; i++)
+ numFreeClusters += (UInt32)(fat[i] - 1) >> 31;
+ NumFreeClusters = numFreeClusters;
+ }
+ }
+
+ RINOK(OpenProgressFat());
+
+ if ((Fat[0] & 0xFF) != Header.MediaType)
+ return S_FALSE;
+
+ return ReadDir(-1, Header.RootCluster, 0);
+}
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp,
+ CDatabase
+{
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ *stream = 0;
+ const CItem &item = Items[index];
+ CClusterInStream *streamSpec = new CClusterInStream;
+ CMyComPtr<ISequentialInStream> streamTemp = streamSpec;
+ streamSpec->Stream = InStream;
+ streamSpec->StartOffset = Header.DataSector << Header.SectorSizeLog;
+ streamSpec->BlockSizeLog = Header.ClusterSizeLog;
+ streamSpec->Size = item.Size;
+
+ UInt32 numClusters = Header.GetNumClusters(item.Size);
+ streamSpec->Vector.Reserve(numClusters);
+ UInt32 cluster = item.Cluster;
+ UInt32 size = item.Size;
+
+ if (size == 0)
+ {
+ if (cluster != 0)
+ return S_FALSE;
+ }
+ else
+ {
+ UInt32 clusterSize = Header.ClusterSize();
+ for (;; size -= clusterSize)
+ {
+ if (!Header.IsValidCluster(cluster))
+ return S_FALSE;
+ streamSpec->Vector.Add(cluster - 2);
+ cluster = Fat[cluster];
+ if (size <= clusterSize)
+ break;
+ }
+ if (!Header.IsEocAndUnused(cluster))
+ return S_FALSE;
+ }
+ RINOK(streamSpec->InitAndSeek());
+ *stream = streamTemp.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI8},
+ { NULL, kpidShortName, VT_BSTR}
+};
+
+enum
+{
+ kpidNumFats = kpidUserDefined
+ // kpidOemName,
+ // kpidVolName,
+ // kpidFileSysType
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidFileSystem, VT_BSTR},
+ { NULL, kpidClusterSize, VT_UI4},
+ { NULL, kpidPhySize, VT_UI8},
+ { NULL, kpidFreeSpace, VT_UI8},
+ { NULL, kpidHeadersSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidVolumeName, VT_BSTR},
+
+ { L"FATs", kpidNumFats, VT_UI4},
+ { NULL, kpidSectorSize, VT_UI4},
+ { NULL, kpidId, VT_UI4},
+ // { L"OEM Name", kpidOemName, VT_BSTR},
+ // { L"Volume Name", kpidVolName, VT_BSTR},
+ // { L"File System Type", kpidFileSysType, VT_BSTR}
+ // { NULL, kpidSectorsPerTrack, VT_UI4},
+ // { NULL, kpidNumHeads, VT_UI4},
+ // { NULL, kpidHiddenSectors, VT_UI4}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_WITH_NAME
+
+static void FatTimeToProp(UInt32 dosTime, UInt32 ms10, NWindows::NCOM::CPropVariant &prop)
+{
+ FILETIME localFileTime, utc;
+ if (NWindows::NTime::DosTimeToFileTime(dosTime, localFileTime))
+ if (LocalFileTimeToFileTime(&localFileTime, &utc))
+ {
+ UInt64 t64 = (((UInt64)utc.dwHighDateTime) << 32) + utc.dwLowDateTime;
+ t64 += ms10 * 100000;
+ utc.dwLowDateTime = (DWORD)t64;
+ utc.dwHighDateTime = (DWORD)(t64 >> 32);
+ prop = utc;
+ }
+}
+
+/*
+static void StringToProp(const Byte *src, int size, NWindows::NCOM::CPropVariant &prop)
+{
+ char dest[32];
+ memcpy(dest, src, size);
+ dest[size] = 0;
+ prop = FatStringToUnicode(dest);
+}
+
+#define STRING_TO_PROP(s, p) StringToProp(s, sizeof(s), prop)
+*/
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidFileSystem:
+ {
+ wchar_t s[32] = { L'F', L'A', L'T' };
+ ConvertUInt32ToString(Header.NumFatBits, s + 3);
+ prop = s;
+ break;
+ }
+ case kpidClusterSize: prop = Header.ClusterSize(); break;
+ case kpidPhySize: prop = Header.GetPhySize(); break;
+ case kpidFreeSpace: prop = (UInt64)NumFreeClusters << Header.ClusterSizeLog; break;
+ case kpidHeadersSize: prop = GetHeadersSize(); break;
+ case kpidMTime: if (VolItemDefined) FatTimeToProp(VolItem.MTime, 0, prop); break;
+ case kpidVolumeName: if (VolItemDefined) prop = VolItem.GetVolName(); break;
+ case kpidNumFats: if (Header.NumFats != 2) prop = Header.NumFats; break;
+ case kpidSectorSize: prop = (UInt32)1 << Header.SectorSizeLog; break;
+ // case kpidSectorsPerTrack: prop = Header.SectorsPerTrack; break;
+ // case kpidNumHeads: prop = Header.NumHeads; break;
+ // case kpidOemName: STRING_TO_PROP(Header.OemName, prop); break;
+ case kpidId: if (Header.VolFieldsDefined) prop = Header.VolId; break;
+ // case kpidVolName: if (Header.VolFieldsDefined) STRING_TO_PROP(Header.VolName, prop); break;
+ // case kpidFileSysType: if (Header.VolFieldsDefined) STRING_TO_PROP(Header.FileSys, prop); break;
+ // case kpidHiddenSectors: prop = Header.NumHiddenSectors; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItem &item = Items[index];
+ switch(propID)
+ {
+ case kpidPath: prop = GetItemPath(index); break;
+ case kpidShortName: prop = item.GetShortName(); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidMTime: FatTimeToProp(item.MTime, 0, prop); break;
+ case kpidCTime: FatTimeToProp(item.CTime, item.CTime2, prop); break;
+ case kpidATime: FatTimeToProp(((UInt32)item.ADate << 16), 0, prop); break;
+ case kpidAttrib: prop = (UInt32)item.Attrib; break;
+ case kpidSize: if (!item.IsDir()) prop = item.Size; break;
+ case kpidPackSize: if (!item.IsDir()) prop = Header.GetFilePackSize(item.Size); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ {
+ OpenCallback = callback;
+ InStream = stream;
+ HRESULT res;
+ try
+ {
+ res = CDatabase::Open();
+ if (res == S_OK)
+ return S_OK;
+ }
+ catch(...)
+ {
+ Close();
+ throw;
+ }
+ Close();
+ return res;
+ }
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ ClearAndClose();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = Items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt32 i;
+ UInt64 totalSize = 0;
+ for (i = 0; i < numItems; i++)
+ {
+ const CItem &item = Items[allFilesMode ? i : indices[i]];
+ if (!item.IsDir())
+ totalSize += item.Size;
+ }
+ RINOK(extractCallback->SetTotal(totalSize));
+
+ UInt64 totalPackSize;
+ totalSize = totalPackSize = 0;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems; i++)
+ {
+ lps->InSize = totalPackSize;
+ lps->OutSize = totalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItem &item = Items[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+
+ totalPackSize += Header.GetFilePackSize(item.Size);
+ totalSize += item.Size;
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ outStreamSpec->SetStream(realOutStream);
+ realOutStream.Release();
+ outStreamSpec->Init();
+
+ int res = NArchive::NExtract::NOperationResult::kDataError;
+ CMyComPtr<ISequentialInStream> inStream;
+ HRESULT hres = GetStream(index, &inStream);
+ if (hres != S_FALSE)
+ {
+ RINOK(hres);
+ if (inStream)
+ {
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ if (copyCoderSpec->TotalSize == item.Size)
+ res = NArchive::NExtract::NOperationResult::kOK;
+ }
+ }
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(res));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = Items.Size();
+ return S_OK;
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"FAT", L"fat img", 0, 0xDA, { 0x55, 0xAA }, 2, false, CreateArc, 0 };
+
+REGISTER_ARC(Fat)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/GzHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/GzHandler.cpp
new file mode 100644
index 000000000..0d7f94b19
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/GzHandler.cpp
@@ -0,0 +1,820 @@
+// GzHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+#include "../Compress/DeflateDecoder.h"
+#include "../Compress/DeflateEncoder.h"
+
+#include "Common/InStreamWithCRC.h"
+#include "Common/OutStreamWithCRC.h"
+#include "Common/ParseProperties.h"
+
+#define Get32(p) GetUi32(p)
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NGz {
+
+static const UInt16 kSignature = 0x8B1F;
+
+namespace NHeader
+{
+ namespace NFlags
+ {
+ const Byte kIsText = 1 << 0;
+ const Byte kCrc = 1 << 1;
+ const Byte kExtra = 1 << 2;
+ const Byte kName = 1 << 3;
+ const Byte kComment = 1 << 4;
+ }
+
+ namespace NExtraFlags
+ {
+ const Byte kMaximum = 2;
+ const Byte kFastest = 4;
+ }
+
+ namespace NCompressionMethod
+ {
+ const Byte kDeflate = 8;
+ }
+
+ namespace NHostOS
+ {
+ enum EEnum
+ {
+ kFAT = 0,
+ kAMIGA,
+ kVMS,
+ kUnix,
+ kVM_CMS,
+ kAtari,
+ kHPFS,
+ kMac,
+ kZ_System,
+ kCPM,
+ kTOPS20,
+ kNTFS,
+ kQDOS,
+ kAcorn,
+ kVFAT,
+ kMVS,
+ kBeOS,
+ kTandem,
+
+ kUnknown = 255
+ };
+ }
+}
+
+static const char *kHostOSes[] =
+{
+ "FAT",
+ "AMIGA",
+ "VMS",
+ "Unix",
+ "VM/CMS",
+ "Atari",
+ "HPFS",
+ "Macintosh",
+ "Z-System",
+ "CP/M",
+ "TOPS-20",
+ "NTFS",
+ "SMS/QDOS",
+ "Acorn",
+ "VFAT",
+ "MVS",
+ "BeOS",
+ "Tandem",
+ "OS/400",
+ "OS/X"
+};
+
+static const char *kUnknownOS = "Unknown";
+
+class CItem
+{
+ bool TestFlag(Byte flag) const { return (Flags & flag) != 0; }
+public:
+ Byte Method;
+ Byte Flags;
+ Byte ExtraFlags;
+ Byte HostOS;
+ UInt32 Time;
+ UInt32 Crc;
+ UInt32 Size32;
+
+ AString Name;
+ AString Comment;
+ // CByteBuffer Extra;
+
+ // bool IsText() const { return TestFlag(NHeader::NFlags::kIsText); }
+ bool HeaderCrcIsPresent() const { return TestFlag(NHeader::NFlags::kCrc); }
+ bool ExtraFieldIsPresent() const { return TestFlag(NHeader::NFlags::kExtra); }
+ bool NameIsPresent() const { return TestFlag(NHeader::NFlags::kName); }
+ bool CommentIsPresent() const { return TestFlag(NHeader::NFlags::kComment); }
+
+ void Clear()
+ {
+ Name.Empty();
+ Comment.Empty();
+ // Extra.SetCapacity(0);
+ }
+
+ HRESULT ReadHeader(NCompress::NDeflate::NDecoder::CCOMCoder *stream);
+ HRESULT ReadFooter1(NCompress::NDeflate::NDecoder::CCOMCoder *stream);
+ HRESULT ReadFooter2(ISequentialInStream *stream);
+
+ HRESULT WriteHeader(ISequentialOutStream *stream);
+ HRESULT WriteFooter(ISequentialOutStream *stream);
+};
+
+static HRESULT ReadBytes(NCompress::NDeflate::NDecoder::CCOMCoder *stream, Byte *data, UInt32 size)
+{
+ for (UInt32 i = 0; i < size; i++)
+ data[i] = stream->ReadByte();
+ return stream->InputEofError() ? S_FALSE : S_OK;
+}
+
+static HRESULT SkipBytes(NCompress::NDeflate::NDecoder::CCOMCoder *stream, UInt32 size)
+{
+ for (UInt32 i = 0; i < size; i++)
+ stream->ReadByte();
+ return stream->InputEofError() ? S_FALSE : S_OK;
+}
+
+static HRESULT ReadUInt16(NCompress::NDeflate::NDecoder::CCOMCoder *stream, UInt16 &value /* , UInt32 &crc */)
+{
+ value = 0;
+ for (int i = 0; i < 2; i++)
+ {
+ Byte b = stream->ReadByte();
+ if (stream->InputEofError())
+ return S_FALSE;
+ // crc = CRC_UPDATE_BYTE(crc, b);
+ value |= (UInt16(b) << (8 * i));
+ }
+ return S_OK;
+}
+
+static HRESULT ReadString(NCompress::NDeflate::NDecoder::CCOMCoder *stream, AString &s, UInt32 limit /* , UInt32 &crc */)
+{
+ s.Empty();
+ for (UInt32 i = 0; i < limit; i++)
+ {
+ Byte b = stream->ReadByte();
+ if (stream->InputEofError())
+ return S_FALSE;
+ // crc = CRC_UPDATE_BYTE(crc, b);
+ if (b == 0)
+ return S_OK;
+ s += (char)b;
+ }
+ return S_FALSE;
+}
+
+HRESULT CItem::ReadHeader(NCompress::NDeflate::NDecoder::CCOMCoder *stream)
+{
+ Clear();
+
+ // Header-CRC field had another meaning in old version of gzip!
+ // UInt32 crc = CRC_INIT_VAL;
+ Byte buf[10];
+
+ RINOK(ReadBytes(stream, buf, 10));
+
+ if (GetUi16(buf) != kSignature)
+ return S_FALSE;
+
+ Method = buf[2];
+
+ if (Method != NHeader::NCompressionMethod::kDeflate)
+ return S_FALSE;
+
+ Flags = buf[3];
+ Time = Get32(buf + 4);
+ ExtraFlags = buf[8];
+ HostOS = buf[9];
+
+ // crc = CrcUpdate(crc, buf, 10);
+
+ if (ExtraFieldIsPresent())
+ {
+ UInt16 extraSize;
+ RINOK(ReadUInt16(stream, extraSize /* , crc */));
+ RINOK(SkipBytes(stream, extraSize));
+ // Extra.SetCapacity(extraSize);
+ // RINOK(ReadStream_FALSE(stream, Extra, extraSize));
+ // crc = CrcUpdate(crc, Extra, extraSize);
+ }
+ if (NameIsPresent())
+ RINOK(ReadString(stream, Name, (1 << 10) /* , crc */));
+ if (CommentIsPresent())
+ RINOK(ReadString(stream, Comment, (1 << 16) /* , crc */));
+
+ if (HeaderCrcIsPresent())
+ {
+ UInt16 headerCRC;
+ // UInt32 dummy = 0;
+ RINOK(ReadUInt16(stream, headerCRC /* , dummy */));
+ /*
+ if ((UInt16)CRC_GET_DIGEST(crc) != headerCRC)
+ return S_FALSE;
+ */
+ }
+ return stream->InputEofError() ? S_FALSE : S_OK;
+}
+
+HRESULT CItem::ReadFooter1(NCompress::NDeflate::NDecoder::CCOMCoder *stream)
+{
+ Byte buf[8];
+ RINOK(ReadBytes(stream, buf, 8));
+ Crc = Get32(buf);
+ Size32 = Get32(buf + 4);
+ return stream->InputEofError() ? S_FALSE : S_OK;
+}
+
+HRESULT CItem::ReadFooter2(ISequentialInStream *stream)
+{
+ Byte buf[8];
+ RINOK(ReadStream_FALSE(stream, buf, 8));
+ Crc = Get32(buf);
+ Size32 = Get32(buf + 4);
+ return S_OK;
+}
+
+HRESULT CItem::WriteHeader(ISequentialOutStream *stream)
+{
+ Byte buf[10];
+ SetUi16(buf, kSignature);
+ buf[2] = Method;
+ buf[3] = Flags & NHeader::NFlags::kName;
+ // buf[3] |= NHeader::NFlags::kCrc;
+ SetUi32(buf + 4, Time);
+ buf[8] = ExtraFlags;
+ buf[9] = HostOS;
+ RINOK(WriteStream(stream, buf, 10));
+ // crc = CrcUpdate(CRC_INIT_VAL, buf, 10);
+ if (NameIsPresent())
+ {
+ // crc = CrcUpdate(crc, (const char *)Name, Name.Length() + 1);
+ RINOK(WriteStream(stream, (const char *)Name, Name.Length() + 1));
+ }
+ // SetUi16(buf, (UInt16)CRC_GET_DIGEST(crc));
+ // RINOK(WriteStream(stream, buf, 2));
+ return S_OK;
+}
+
+HRESULT CItem::WriteFooter(ISequentialOutStream *stream)
+{
+ Byte buf[8];
+ SetUi32(buf, Crc);
+ SetUi32(buf + 4, Size32);
+ return WriteStream(stream, buf, 8);
+}
+
+static const UInt32 kAlgoX1 = 0;
+static const UInt32 kAlgoX5 = 1;
+
+static const UInt32 kNumPassesX1 = 1;
+static const UInt32 kNumPassesX7 = 3;
+static const UInt32 kNumPassesX9 = 10;
+
+static const UInt32 kNumFastBytesX1 = 32;
+static const UInt32 kNumFastBytesX7 = 64;
+static const UInt32 kNumFastBytesX9 = 128;
+
+struct CCompressMode
+{
+ UInt32 NumPasses;
+ UInt32 NumFastBytes;
+ UInt32 Algo;
+ UInt32 Mc;
+ bool McDefined;
+
+ bool IsMaximum() const { return Algo > 0; }
+
+ void Init()
+ {
+ NumPasses = NumFastBytes = Mc = Algo = 0xFFFFFFFF;
+ McDefined = false;
+ }
+
+ void Normalize(UInt32 level)
+ {
+ if (level == 0xFFFFFFFF)
+ level = 5;
+ if (NumPasses == 0xFFFFFFFF)
+ NumPasses =
+ (level >= 9 ? kNumPassesX9 :
+ (level >= 7 ? kNumPassesX7 :
+ kNumPassesX1));
+ if (NumFastBytes == 0xFFFFFFFF)
+ NumFastBytes =
+ (level >= 9 ? kNumFastBytesX9 :
+ (level >= 7 ? kNumFastBytesX7 :
+ kNumFastBytesX1));
+ if (Algo == 0xFFFFFFFF)
+ Algo = (level >= 5 ?
+ kAlgoX5 :
+ kAlgoX1);
+ }
+};
+
+class CHandler:
+ public IInArchive,
+ public IArchiveOpenSeq,
+ public IOutArchive,
+ public ISetProperties,
+ public CMyUnknownImp
+{
+ CItem _item;
+ UInt64 _startPosition;
+ UInt64 _headerSize;
+ UInt64 _packSize;
+ bool _packSizeDefined;
+ CMyComPtr<IInStream> _stream;
+ CMyComPtr<ICompressCoder> _decoder;
+ NCompress::NDeflate::NDecoder::CCOMCoder *_decoderSpec;
+
+ CCompressMode _method;
+ UInt32 _level;
+
+ void InitMethodProperties()
+ {
+ _level = 0xFFFFFFFF;
+ _method.Init();
+ }
+
+public:
+ MY_UNKNOWN_IMP4(IInArchive, IArchiveOpenSeq, IOutArchive, ISetProperties)
+ INTERFACE_IInArchive(;)
+ INTERFACE_IOutArchive(;)
+ STDMETHOD(OpenSeq)(ISequentialInStream *stream);
+ STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProps);
+
+ CHandler()
+ {
+ InitMethodProperties();
+ _decoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder;
+ _decoder = _decoderSpec;
+ }
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidHostOS, VT_BSTR},
+ { NULL, kpidCRC, VT_UI4}
+ // { NULL, kpidComment, VT_BSTR}
+}
+;
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO_Table
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPhySize: if (_packSizeDefined) prop = _packSize; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPath:
+ if (_item.NameIsPresent())
+ prop = MultiByteToUnicodeString(_item.Name, CP_ACP);
+ break;
+ // case kpidComment: if (_item.CommentIsPresent()) prop = MultiByteToUnicodeString(_item.Comment, CP_ACP); break;
+ case kpidMTime:
+ {
+ if (_item.Time != 0)
+ {
+ FILETIME utc;
+ NTime::UnixTimeToFileTime(_item.Time, utc);
+ prop = utc;
+ }
+ break;
+ }
+ case kpidSize: if (_stream) prop = (UInt64)_item.Size32; break;
+ case kpidPackSize: if (_packSizeDefined) prop = _packSize; break;
+ case kpidHostOS: prop = (_item.HostOS < sizeof(kHostOSes) / sizeof(kHostOSes[0])) ?
+ kHostOSes[_item.HostOS] : kUnknownOS; break;
+ case kpidCRC: if (_stream) prop = _item.Crc; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *)
+{
+ COM_TRY_BEGIN
+ HRESULT res;
+ try
+ {
+ RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_startPosition));
+ res = OpenSeq(stream);
+ if (res == S_OK)
+ {
+ UInt64 endPos;
+ res = stream->Seek(-8, STREAM_SEEK_END, &endPos);
+ _packSize = endPos + 8 - _startPosition;
+ _packSizeDefined = true;
+ if (res == S_OK)
+ {
+ res = _item.ReadFooter2(stream);
+ _stream = stream;
+ }
+ }
+ }
+ catch(...) { res = S_FALSE; }
+ if (res != S_OK)
+ Close();
+ return res;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
+{
+ COM_TRY_BEGIN
+ HRESULT res;
+ try
+ {
+ Close();
+ _decoderSpec->SetInStream(stream);
+ _decoderSpec->InitInStream(true);
+ res = _item.ReadHeader(_decoderSpec);
+ _headerSize = _decoderSpec->GetInputProcessedSize();
+ }
+ catch(...) { res = S_FALSE; }
+ if (res != S_OK)
+ Close();
+ return res;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _packSizeDefined = false;
+ _stream.Release();
+ _decoderSpec->ReleaseInStream();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == (UInt32)-1);
+ if (!allFilesMode)
+ {
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1 || indices[0] != 0)
+ return E_INVALIDARG;
+ }
+
+ bool testMode = (_aTestMode != 0);
+ if (_stream)
+ extractCallback->SetTotal(_packSize);
+ UInt64 currentTotalPacked = 0;
+ RINOK(extractCallback->SetCompleted(&currentTotalPacked));
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
+ if (!testMode && !realOutStream)
+ return S_OK;
+
+ extractCallback->PrepareOperation(askMode);
+
+ COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->SetStream(realOutStream);
+ outStreamSpec->Init();
+ realOutStream.Release();
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, true);
+
+ if (_stream)
+ {
+ RINOK(_stream->Seek(_startPosition, STREAM_SEEK_SET, NULL));
+ _decoderSpec->InitInStream(true);
+ }
+ bool firstItem = true;
+ Int32 opRes = 0;
+ for (;;)
+ {
+ lps->InSize = _packSize = _decoderSpec->GetInputProcessedSize();
+ _packSizeDefined = true;
+ lps->OutSize = outStreamSpec->GetSize();
+ RINOK(lps->SetCur());
+
+ CItem item;
+ if (!firstItem || _stream)
+ {
+ HRESULT result = item.ReadHeader(_decoderSpec);
+ if (result != S_OK)
+ {
+ if (result != S_FALSE)
+ return result;
+ opRes = firstItem ?
+ NArchive::NExtract::NOperationResult::kDataError :
+ NArchive::NExtract::NOperationResult::kOK;
+ break;
+ }
+ }
+ firstItem = false;
+
+ UInt64 startOffset = outStreamSpec->GetSize();
+ outStreamSpec->InitCRC();
+
+ HRESULT result = _decoderSpec->CodeResume(outStream, NULL, progress);
+ if (result != S_OK)
+ {
+ if (result != S_FALSE)
+ return result;
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ break;
+ }
+
+ _decoderSpec->AlignToByte();
+ if (item.ReadFooter1(_decoderSpec) != S_OK)
+ {
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ break;
+ }
+ if (item.Crc != outStreamSpec->GetCRC() ||
+ item.Size32 != (UInt32)(outStreamSpec->GetSize() - startOffset))
+ {
+ opRes = NArchive::NExtract::NOperationResult::kCRCError;
+ break;
+ }
+ }
+ outStream.Release();
+ return extractCallback->SetOperationResult(opRes);
+ COM_TRY_END
+}
+
+static const Byte kHostOS =
+ #ifdef _WIN32
+ NHeader::NHostOS::kFAT;
+ #else
+ NHeader::NHostOS::kUnix;
+ #endif
+
+static HRESULT UpdateArchive(
+ ISequentialOutStream *outStream,
+ UInt64 unpackSize,
+ const CItem &newItem,
+ const CCompressMode &compressionMode,
+ IArchiveUpdateCallback *updateCallback)
+{
+ UInt64 complexity = 0;
+ RINOK(updateCallback->SetTotal(unpackSize));
+ RINOK(updateCallback->SetCompleted(&complexity));
+
+ CMyComPtr<ISequentialInStream> fileInStream;
+
+ RINOK(updateCallback->GetStream(0, &fileInStream));
+
+ CSequentialInStreamWithCRC *inStreamSpec = new CSequentialInStreamWithCRC;
+ CMyComPtr<ISequentialInStream> crcStream(inStreamSpec);
+ inStreamSpec->SetStream(fileInStream);
+ inStreamSpec->Init();
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(updateCallback, true);
+
+ CItem item = newItem;
+ item.Method = NHeader::NCompressionMethod::kDeflate;
+ item.ExtraFlags = compressionMode.IsMaximum() ?
+ NHeader::NExtraFlags::kMaximum :
+ NHeader::NExtraFlags::kFastest;
+
+ item.HostOS = kHostOS;
+
+ RINOK(item.WriteHeader(outStream));
+
+ NCompress::NDeflate::NEncoder::CCOMCoder *deflateEncoderSpec = new NCompress::NDeflate::NEncoder::CCOMCoder;
+ CMyComPtr<ICompressCoder> deflateEncoder = deflateEncoderSpec;
+ {
+ NWindows::NCOM::CPropVariant props[] =
+ {
+ compressionMode.Algo,
+ compressionMode.NumPasses,
+ compressionMode.NumFastBytes,
+ compressionMode.Mc
+ };
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kAlgorithm,
+ NCoderPropID::kNumPasses,
+ NCoderPropID::kNumFastBytes,
+ NCoderPropID::kMatchFinderCycles
+ };
+ int numProps = sizeof(propIDs) / sizeof(propIDs[0]);
+ if (!compressionMode.McDefined)
+ numProps--;
+ RINOK(deflateEncoderSpec->SetCoderProperties(propIDs, props, numProps));
+ }
+ RINOK(deflateEncoder->Code(crcStream, outStream, NULL, NULL, progress));
+
+ item.Crc = inStreamSpec->GetCRC();
+ item.Size32 = (UInt32)inStreamSpec->GetSize();
+ RINOK(item.WriteFooter(outStream));
+ return updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK);
+}
+
+STDMETHODIMP CHandler::GetFileTimeType(UInt32 *timeType)
+{
+ *timeType = NFileTimeType::kUnix;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
+ IArchiveUpdateCallback *updateCallback)
+{
+ if (numItems != 1)
+ return E_INVALIDARG;
+
+ Int32 newData, newProps;
+ UInt32 indexInArchive;
+ if (!updateCallback)
+ return E_FAIL;
+ RINOK(updateCallback->GetUpdateItemInfo(0, &newData, &newProps, &indexInArchive));
+
+ CItem newItem = _item;
+ newItem.ExtraFlags = 0;
+ newItem.Flags = 0;
+ if (IntToBool(newProps))
+ {
+ {
+ FILETIME utcTime;
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(0, kpidMTime, &prop));
+ if (prop.vt != VT_FILETIME)
+ return E_INVALIDARG;
+ utcTime = prop.filetime;
+ if (!NTime::FileTimeToUnixTime(utcTime, newItem.Time))
+ return E_INVALIDARG;
+ }
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(0, kpidPath, &prop));
+ if (prop.vt == VT_BSTR)
+ {
+ UString name = prop.bstrVal;
+ int dirDelimiterPos = name.ReverseFind(CHAR_PATH_SEPARATOR);
+ if (dirDelimiterPos >= 0)
+ name = name.Mid(dirDelimiterPos + 1);
+ newItem.Name = UnicodeStringToMultiByte(name, CP_ACP);
+ if (!newItem.Name.IsEmpty())
+ newItem.Flags |= NHeader::NFlags::kName;
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_INVALIDARG;
+ }
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(0, kpidIsDir, &prop));
+ if (prop.vt == VT_BOOL)
+ {
+ if (prop.boolVal != VARIANT_FALSE)
+ return E_INVALIDARG;
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_INVALIDARG;
+ }
+ }
+
+ if (IntToBool(newData))
+ {
+ UInt64 size;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(0, kpidSize, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ size = prop.uhVal.QuadPart;
+ }
+
+ _method.Normalize(_level);
+ return UpdateArchive(outStream, size, newItem, _method, updateCallback);
+ }
+
+ if (indexInArchive != 0)
+ return E_INVALIDARG;
+
+ if (!_stream)
+ return E_NOTIMPL;
+
+ UInt64 offset = _startPosition;
+ if (IntToBool(newProps))
+ {
+ newItem.WriteHeader(outStream);
+ offset += _headerSize;
+ }
+ RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL));
+ return NCompress::CopyStream(_stream, outStream, NULL);
+}
+
+STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProps)
+{
+ InitMethodProperties();
+ for (int i = 0; i < numProps; i++)
+ {
+ UString name = names[i];
+ name.MakeUpper();
+ if (name.IsEmpty())
+ return E_INVALIDARG;
+ const PROPVARIANT &prop = values[i];
+ if (name[0] == L'X')
+ {
+ UInt32 level = 9;
+ RINOK(ParsePropValue(name.Mid(1), prop, level));
+ _level = level;
+ }
+ else if (name.Left(4) == L"PASS")
+ {
+ UInt32 num = kNumPassesX9;
+ RINOK(ParsePropValue(name.Mid(4), prop, num));
+ _method.NumPasses = num;
+ }
+ else if (name.Left(2) == L"FB")
+ {
+ UInt32 num = kNumFastBytesX9;
+ RINOK(ParsePropValue(name.Mid(2), prop, num));
+ _method.NumFastBytes = num;
+ }
+ else if (name.Left(2) == L"MC")
+ {
+ UInt32 num = 0xFFFFFFFF;
+ RINOK(ParsePropValue(name.Mid(2), prop, num));
+ _method.Mc = num;
+ _method.McDefined = true;
+ }
+ else if (name.Left(1) == L"A")
+ {
+ UInt32 num = kAlgoX5;
+ RINOK(ParsePropValue(name.Mid(1), prop, num));
+ _method.Algo = num;
+ }
+ else
+ return E_INVALIDARG;
+ }
+ return S_OK;
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+#ifndef EXTRACT_ONLY
+static IOutArchive *CreateArcOut() { return new CHandler; }
+#else
+#define CreateArcOut 0
+#endif
+
+static CArcInfo g_ArcInfo =
+ { L"GZip", L"gz gzip tgz tpz", L"* * .tar .tar", 0xEF, { 0x1F, 0x8B, 8 }, 3, true, CreateArc, CreateArcOut };
+
+REGISTER_ARC(GZip)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsHandler.cpp
new file mode 100644
index 000000000..ade538770
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsHandler.cpp
@@ -0,0 +1,244 @@
+// HfsHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Windows/PropVariant.h"
+#include "../../Common/StreamUtils.h"
+#include "HfsHandler.h"
+
+namespace NArchive {
+namespace NHfs {
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidClusterSize, VT_UI4},
+ { NULL, kpidFreeSpace, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+static void HfsTimeToProp(UInt32 hfsTime, NWindows::NCOM::CPropVariant &prop)
+{
+ FILETIME ft;
+ HfsTimeToFileTime(hfsTime, ft);
+ prop = ft;
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMethod: prop = _db.Header.IsHfsX() ? L"HFSX" : L"HFS+"; break;
+ case kpidClusterSize: prop = (UInt32)1 << _db.Header.BlockSizeLog; break;
+ case kpidFreeSpace: prop = (UInt64)_db.Header.NumFreeBlocks << _db.Header.BlockSizeLog; break;
+ case kpidMTime: HfsTimeToProp(_db.Header.MTime, prop); break;
+ case kpidCTime:
+ {
+ FILETIME localFt, ft;
+ HfsTimeToFileTime(_db.Header.CTime, localFt);
+ if (LocalFileTimeToFileTime(&localFt, &ft))
+ prop = ft;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItem &item = _db.Items[index];
+ switch(propID)
+ {
+ case kpidPath: prop = _db.GetItemPath(index); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+
+ case kpidCTime: HfsTimeToProp(item.CTime, prop); break;
+ case kpidMTime: HfsTimeToProp(item.MTime, prop); break;
+ case kpidATime: HfsTimeToProp(item.ATime, prop); break;
+
+ case kpidPackSize: if (!item.IsDir()) prop = (UInt64)item.NumBlocks << _db.Header.BlockSizeLog; break;
+ case kpidSize: if (!item.IsDir()) prop = item.Size; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CProgressImp: public CProgressVirt
+{
+ CMyComPtr<IArchiveOpenCallback> _callback;
+public:
+ HRESULT SetTotal(UInt64 numFiles);
+ HRESULT SetCompleted(UInt64 numFiles);
+ CProgressImp(IArchiveOpenCallback *callback): _callback(callback) {}
+};
+
+HRESULT CProgressImp::SetTotal(UInt64 numFiles)
+{
+ if (_callback)
+ return _callback->SetTotal(&numFiles, NULL);
+ return S_OK;
+}
+
+HRESULT CProgressImp::SetCompleted(UInt64 numFiles)
+{
+ if (_callback)
+ return _callback->SetCompleted(&numFiles, NULL);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ Close();
+ try
+ {
+ CProgressImp progressImp(callback);
+ HRESULT res = _db.Open(inStream, &progressImp);
+ if (res == E_ABORT)
+ return res;
+ if (res != S_OK)
+ return S_FALSE;
+ _stream = inStream;
+ }
+ catch(...) { return S_FALSE; }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _stream.Release();
+ _db.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _db.Items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt32 i;
+ UInt64 totalSize = 0;
+ for (i = 0; i < numItems; i++)
+ {
+ const CItem &item = _db.Items[allFilesMode ? i : indices[i]];
+ if (!item.IsDir())
+ totalSize += item.Size;
+ }
+ RINOK(extractCallback->SetTotal(totalSize));
+
+ UInt64 currentTotalSize = 0, currentItemSize = 0;
+
+ CByteBuffer buf;
+ const UInt32 kBufSize = (1 << 16);
+ buf.SetCapacity(kBufSize);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ RINOK(extractCallback->SetCompleted(&currentTotalSize));
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _db.Items[index];
+ currentItemSize = 0;
+ if (!item.IsDir())
+ currentItemSize = item.Size;
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ UInt64 pos = 0;
+ int res = NArchive::NExtract::NOperationResult::kOK;
+ int i;
+ for (i = 0; i < item.Extents.Size(); i++)
+ {
+ if (item.Size == pos)
+ break;
+ if (res != NArchive::NExtract::NOperationResult::kOK)
+ break;
+ const CExtent &e = item.Extents[i];
+ RINOK(_stream->Seek((UInt64)e.Pos << _db.Header.BlockSizeLog, STREAM_SEEK_SET, NULL));
+ UInt64 extentSize = (UInt64)e.NumBlocks << _db.Header.BlockSizeLog;
+ for (;;)
+ {
+ if (extentSize == 0)
+ break;
+ UInt64 rem = item.Size - pos;
+ if (rem == 0)
+ {
+ if (extentSize >= (UInt64)((UInt32)1 << _db.Header.BlockSizeLog))
+ res = NArchive::NExtract::NOperationResult::kDataError;
+ break;
+ }
+ UInt32 curSize = kBufSize;
+ if (curSize > rem)
+ curSize = (UInt32)rem;
+ if (curSize > extentSize)
+ curSize = (UInt32)extentSize;
+ RINOK(ReadStream_FALSE(_stream, buf, curSize));
+ if (realOutStream)
+ {
+ RINOK(WriteStream(realOutStream, buf, curSize));
+ }
+ pos += curSize;
+ extentSize -= curSize;
+ UInt64 processed = currentTotalSize + pos;
+ RINOK(extractCallback->SetCompleted(&processed));
+ }
+ }
+ if (i != item.Extents.Size() || item.Size != pos)
+ res = NArchive::NExtract::NOperationResult::kDataError;
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(res));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _db.Items.Size();
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsHandler.h
new file mode 100644
index 000000000..269af218e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsHandler.h
@@ -0,0 +1,26 @@
+// HfsHandler.h
+
+#ifndef __ARCHIVE_HFS_HANDLER_H
+#define __ARCHIVE_HFS_HANDLER_H
+
+#include "Common/MyCom.h"
+#include "../IArchive.h"
+#include "HfsIn.h"
+
+namespace NArchive {
+namespace NHfs {
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _stream;
+ CDatabase _db;
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsIn.cpp
new file mode 100644
index 000000000..8391dd936
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsIn.cpp
@@ -0,0 +1,480 @@
+// HfsIn.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/StreamUtils.h"
+#include "Common/IntToString.h"
+
+#include "HfsIn.h"
+
+#include "../../../../C/CpuArch.h"
+
+#define Get16(p) GetBe16(p)
+#define Get32(p) GetBe32(p)
+#define Get64(p) GetBe64(p)
+
+namespace NArchive {
+namespace NHfs {
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+static int CompareIdToIndex(const CIdIndexPair *p1, const CIdIndexPair *p2, void * /* param */)
+{
+ RINOZ(MyCompare(p1->ID, p2->ID));
+ return MyCompare(p1->Index, p2->Index);
+}
+
+bool operator< (const CIdIndexPair &a1, const CIdIndexPair &a2) { return (a1.ID < a2.ID); }
+bool operator> (const CIdIndexPair &a1, const CIdIndexPair &a2) { return (a1.ID > a2.ID); }
+bool operator==(const CIdIndexPair &a1, const CIdIndexPair &a2) { return (a1.ID == a2.ID); }
+bool operator!=(const CIdIndexPair &a1, const CIdIndexPair &a2) { return (a1.ID != a2.ID); }
+
+static UString GetSpecName(const UString &name, UInt32 /* id */)
+{
+ UString name2 = name;
+ name2.Trim();
+ if (name2.IsEmpty())
+ {
+ /*
+ wchar_t s[32];
+ ConvertUInt64ToString(id, s);
+ return L"[" + (UString)s + L"]";
+ */
+ return L"[]";
+ }
+ return name;
+}
+
+UString CDatabase::GetItemPath(int index) const
+{
+ const CItem *item = &Items[index];
+ UString name = GetSpecName(item->Name, item->ID);
+
+ for (int i = 0; i < 1000; i++)
+ {
+ if (item->ParentID < 16 && item->ParentID != 2)
+ {
+ if (item->ParentID != 1)
+ break;
+ return name;
+ }
+ CIdIndexPair pair;
+ pair.ID = item->ParentID;
+ pair.Index = 0;
+ int indexInMap = IdToIndexMap.FindInSorted(pair);
+ if (indexInMap < 0)
+ break;
+ item = &Items[IdToIndexMap[indexInMap].Index];
+ name = GetSpecName(item->Name, item->ID) + WCHAR_PATH_SEPARATOR + name;
+ }
+ return (UString)L"Unknown" + WCHAR_PATH_SEPARATOR + name;
+}
+
+void CFork::Parse(const Byte *p)
+{
+ Size = Get64(p);
+ // ClumpSize = Get32(p + 8);
+ NumBlocks = Get32(p + 0xC);
+ for (int i = 0; i < 8; i++)
+ {
+ CExtent &e = Extents[i];
+ e.Pos = Get32(p + 0x10 + i * 8);
+ e.NumBlocks = Get32(p + 0x10 + i * 8 + 4);
+ }
+}
+
+static HRESULT ReadExtent(int blockSizeLog, IInStream *inStream, Byte *buf, const CExtent &e)
+{
+ RINOK(inStream->Seek((UInt64)e.Pos << blockSizeLog, STREAM_SEEK_SET, NULL));
+ return ReadStream_FALSE(inStream, buf, (size_t)e.NumBlocks << blockSizeLog);
+}
+
+HRESULT CDatabase::ReadFile(const CFork &fork, CByteBuffer &buf, IInStream *inStream)
+{
+ if (fork.NumBlocks >= Header.NumBlocks)
+ return S_FALSE;
+ size_t totalSize = (size_t)fork.NumBlocks << Header.BlockSizeLog;
+ if ((totalSize >> Header.BlockSizeLog) != fork.NumBlocks)
+ return S_FALSE;
+ buf.SetCapacity(totalSize);
+ UInt32 curBlock = 0;
+ for (int i = 0; i < 8; i++)
+ {
+ if (curBlock >= fork.NumBlocks)
+ break;
+ const CExtent &e = fork.Extents[i];
+ if (fork.NumBlocks - curBlock < e.NumBlocks || e.Pos >= Header.NumBlocks)
+ return S_FALSE;
+ RINOK(ReadExtent(Header.BlockSizeLog, inStream,
+ (Byte *)buf + ((size_t)curBlock << Header.BlockSizeLog), e));
+ curBlock += e.NumBlocks;
+ }
+ return S_OK;
+}
+
+struct CNodeDescriptor
+{
+ UInt32 fLink;
+ UInt32 bLink;
+ Byte Kind;
+ Byte Height;
+ UInt16 NumRecords;
+ // UInt16 Reserved;
+ void Parse(const Byte *p);
+};
+
+void CNodeDescriptor::Parse(const Byte *p)
+{
+ fLink = Get32(p);
+ bLink = Get32(p + 4);
+ Kind = p[8];
+ Height = p[9];
+ NumRecords = Get16(p + 10);
+}
+
+struct CHeaderRec
+{
+ // UInt16 TreeDepth;
+ // UInt32 RootNode;
+ // UInt32 LeafRecords;
+ UInt32 FirstLeafNode;
+ // UInt32 LastLeafNode;
+ int NodeSizeLog;
+ // UInt16 MaxKeyLength;
+ UInt32 TotalNodes;
+ // UInt32 FreeNodes;
+ // UInt16 Reserved1;
+ // UInt32 ClumpSize;
+ // Byte BtreeType;
+ // Byte KeyCompareType;
+ // UInt32 Attributes;
+ // UInt32 Reserved3[16];
+
+ HRESULT Parse(const Byte *p);
+};
+
+HRESULT CHeaderRec::Parse(const Byte *p)
+{
+ // TreeDepth = Get16(p);
+ // RootNode = Get32(p + 2);
+ // LeafRecords = Get32(p + 6);
+ FirstLeafNode = Get32(p + 0xA);
+ // LastLeafNode = Get32(p + 0xE);
+ UInt32 nodeSize = Get16(p + 0x12);
+
+ int i;
+ for (i = 9; ((UInt32)1 << i) != nodeSize; i++)
+ if (i == 16)
+ return S_FALSE;
+ NodeSizeLog = i;
+
+ // MaxKeyLength = Get16(p + 0x14);
+ TotalNodes = Get32(p + 0x16);
+ // FreeNodes = Get32(p + 0x1A);
+ // Reserved1 = Get16(p + 0x1E);
+ // ClumpSize = Get32(p + 0x20);
+ // BtreeType = p[0x24];
+ // KeyCompareType = p[0x25];
+ // Attributes = Get32(p + 0x26);
+ /*
+ for (int i = 0; i < 16; i++)
+ Reserved3[i] = Get32(p + 0x2A + i * 4);
+ */
+ return S_OK;
+}
+
+
+enum ENodeType
+{
+ NODE_TYPE_LEAF = 0xFF,
+ NODE_TYPE_INDEX = 0,
+ NODE_TYPE_HEADER = 1,
+ NODE_TYPE_MODE = 2
+};
+
+HRESULT CDatabase::LoadExtentFile(IInStream *inStream)
+{
+ // FileExtents.Clear();
+ // ResExtents.Clear();
+
+ CByteBuffer extents;
+ RINOK(ReadFile(Header.ExtentsFile, extents, inStream));
+
+ const Byte *p = (const Byte *)extents;
+
+ // CNodeDescriptor nodeDesc;
+ // nodeDesc.Parse(p);
+ CHeaderRec hr;
+ RINOK(hr.Parse(p + 14));
+
+ UInt32 node = hr.FirstLeafNode;
+ if (node != 0)
+ return S_FALSE;
+ /*
+ while (node != 0)
+ {
+ size_t nodeOffset = node * hr.NodeSize;
+ if ((node + 1)* hr.NodeSize > CatalogBuf.GetCapacity())
+ return S_FALSE;
+ CNodeDescriptor desc;
+ desc.Parse(p + nodeOffset);
+ if (desc.Kind != NODE_TYPE_LEAF)
+ return S_FALSE;
+ UInt32 ptr = hr.NodeSize;
+ for (int i = 0; i < desc.NumRecords; i++)
+ {
+ UInt32 offs = Get16(p + nodeOffset + hr.NodeSize - (i + 1) * 2);
+ UInt32 offsNext = Get16(p + nodeOffset + hr.NodeSize - (i + 2) * 2);
+
+ const Byte *r = p + nodeOffset + offs;
+ int keyLength = Get16(r);
+ Byte forkType = r[2];
+ UInt32 id = Get16(r + 4);
+ UInt32 startBlock = Get16(r + 4);
+ CObjectVector<CIdExtents> *extents = (forkType == 0) ? &FileExtents : &ResExtents;
+ if (extents->Size() == 0)
+ extents->Add(CIdExtents());
+ else
+ {
+ CIdExtents &e = extents->Back();
+ if (e.ID != id)
+ {
+ if (e.ID > id)
+ return S_FALSE;
+ extents->Add(CIdExtents());
+ }
+ }
+ CIdExtents &e = extents->Back();
+ for (UInt32 k = offs + 10 + 2; k + 8 <= offsNext; k += 8)
+ {
+ CExtent ee;
+ ee.Pos = Get32(p + nodeOffset + k);
+ ee.NumBlocks = Get32(p + nodeOffset + k * 4);
+ e.Extents.Add(ee);
+ }
+ }
+ node = desc.fLink;
+ }
+ */
+ return S_OK;
+}
+
+
+HRESULT CDatabase::LoadCatalog(IInStream *inStream, CProgressVirt *progress)
+{
+ Items.Clear();
+ IdToIndexMap.ClearAndFree();
+
+ CByteBuffer catalogBuf;
+ RINOK(ReadFile(Header.CatalogFile, catalogBuf, inStream));
+ const Byte *p = (const Byte *)catalogBuf;
+
+ // CNodeDescriptor nodeDesc;
+ // nodeDesc.Parse(p);
+ CHeaderRec hr;
+ hr.Parse(p + 14);
+
+ // CaseSensetive = (Header.IsHfsX() && hr.KeyCompareType == 0xBC);
+
+ if ((catalogBuf.GetCapacity() >> hr.NodeSizeLog) < hr.TotalNodes)
+ return S_FALSE;
+
+ CByteBuffer usedBuf;
+ usedBuf.SetCapacity(hr.TotalNodes);
+ for (UInt32 i = 0; i < hr.TotalNodes; i++)
+ usedBuf[i] = 0;
+
+ UInt32 node = hr.FirstLeafNode;
+ while (node != 0)
+ {
+ if (node >= hr.TotalNodes)
+ return S_FALSE;
+ if (usedBuf[node])
+ return S_FALSE;
+ usedBuf[node] = 1;
+ size_t nodeOffset = (size_t)node << hr.NodeSizeLog;
+ CNodeDescriptor desc;
+ desc.Parse(p + nodeOffset);
+ if (desc.Kind != NODE_TYPE_LEAF)
+ return S_FALSE;
+ for (int i = 0; i < desc.NumRecords; i++)
+ {
+ UInt32 nodeSize = (1 << hr.NodeSizeLog);
+ UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
+ UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
+ UInt32 recSize = offsNext - offs;
+ if (offsNext >= nodeSize || offsNext < offs || recSize < 6)
+ return S_FALSE;
+
+ CItem item;
+
+ const Byte *r = p + nodeOffset + offs;
+ UInt32 keyLength = Get16(r);
+ item.ParentID = Get32(r + 2);
+ UString name;
+ if (keyLength < 6 || (keyLength & 1) != 0 || keyLength + 2 > recSize)
+ return S_FALSE;
+ r += 6;
+ recSize -= 6;
+ keyLength -= 6;
+
+ int nameLength = Get16(r);
+ if (nameLength * 2 != (int)keyLength)
+ return S_FALSE;
+ r += 2;
+ recSize -= 2;
+
+ wchar_t *pp = name.GetBuffer(nameLength + 1);
+
+ int j;
+ for (j = 0; j < nameLength; j++)
+ pp[j] = ((wchar_t)r[j * 2] << 8) | r[j * 2 + 1];
+ pp[j] = 0;
+ name.ReleaseBuffer();
+ r += j * 2;
+ recSize -= j * 2;
+
+ if (recSize < 2)
+ return S_FALSE;
+ item.Type = Get16(r);
+
+ if (item.Type != RECORD_TYPE_FOLDER && item.Type != RECORD_TYPE_FILE)
+ continue;
+ if (recSize < 0x58)
+ return S_FALSE;
+
+ // item.Flags = Get16(r + 2);
+ // item.Valence = Get32(r + 4);
+ item.ID = Get32(r + 8);
+ item.CTime = Get32(r + 0xC);
+ item.MTime = Get32(r + 0x10);
+ // item.AttrMTime = Get32(r + 0x14);
+ item.ATime = Get32(r + 0x18);
+ // item.BackupDate = Get32(r + 0x1C);
+
+ /*
+ item.OwnerID = Get32(r + 0x20);
+ item.GroupID = Get32(r + 0x24);
+ item.AdminFlags = r[0x28];
+ item.OwnerFlags = r[0x29];
+ item.FileMode = Get16(r + 0x2A);
+ item.special.iNodeNum = Get16(r + 0x2C);
+ */
+
+ item.Name = name;
+
+ if (item.IsDir())
+ {
+ CIdIndexPair pair;
+ pair.ID = item.ID;
+ pair.Index = Items.Size();
+ IdToIndexMap.Add(pair);
+ }
+ else
+ {
+ CFork fd;
+ recSize -= 0x58;
+ r += 0x58;
+ if (recSize < 0x50 * 2)
+ return S_FALSE;
+ fd.Parse(r);
+ item.Size = fd.Size;
+ item.NumBlocks = fd.NumBlocks;
+ UInt32 curBlock = 0;
+ for (int j = 0; j < 8; j++)
+ {
+ if (curBlock >= fd.NumBlocks)
+ break;
+ const CExtent &e = fd.Extents[j];
+ item.Extents.Add(e);
+ curBlock += e.NumBlocks;
+ }
+ }
+ Items.Add(item);
+ if (progress && Items.Size() % 100 == 0)
+ {
+ RINOK(progress->SetCompleted(Items.Size()));
+ }
+ }
+ node = desc.fLink;
+ }
+ IdToIndexMap.Sort(CompareIdToIndex, NULL);
+ return S_OK;
+}
+
+HRESULT CDatabase::Open(IInStream *inStream, CProgressVirt *progress)
+{
+ static const UInt32 kHeaderSize = 1024 + 512;
+ Byte buf[kHeaderSize];
+ RINOK(ReadStream_FALSE(inStream, buf, kHeaderSize));
+ int i;
+ for (i = 0; i < 1024; i++)
+ if (buf[i] != 0)
+ return S_FALSE;
+ const Byte *p = buf + 1024;
+ CVolHeader &h = Header;
+
+ h.Header[0] = p[0];
+ h.Header[1] = p[1];
+ if (p[0] != 'H' || (p[1] != '+' && p[1] != 'X'))
+ return S_FALSE;
+ h.Version = Get16(p + 2);
+ if (h.Version < 4 || h.Version > 5)
+ return S_FALSE;
+
+ // h.Attr = Get32(p + 4);
+ // h.LastMountedVersion = Get32(p + 8);
+ // h.JournalInfoBlock = Get32(p + 0xC);
+
+ h.CTime = Get32(p + 0x10);
+ h.MTime = Get32(p + 0x14);
+ // h.BackupTime = Get32(p + 0x18);
+ // h.CheckedTime = Get32(p + 0x1C);
+
+ // h.NumFiles = Get32(p + 0x20);
+ // h.NumFolders = Get32(p + 0x24);
+
+ UInt32 numFiles = Get32(p + 0x20);
+ UInt32 numFolders = Get32(p + 0x24);;
+ if (progress)
+ {
+ RINOK(progress->SetTotal(numFolders + numFiles));
+ }
+
+ UInt32 blockSize = Get32(p + 0x28);
+
+ for (i = 9; ((UInt32)1 << i) != blockSize; i++)
+ if (i == 31)
+ return S_FALSE;
+ h.BlockSizeLog = i;
+
+ h.NumBlocks = Get32(p + 0x2C);
+ h.NumFreeBlocks = Get32(p + 0x30);
+
+ /*
+ h.WriteCount = Get32(p + 0x44);
+ for (i = 0; i < 6; i++)
+ h.FinderInfo[i] = Get32(p + 0x50 + i * 4);
+ h.VolID = Get64(p + 0x68);
+ */
+
+ UInt64 endPos;
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos));
+ if ((endPos >> h.BlockSizeLog) < h.NumBlocks)
+ return S_FALSE;
+
+ // h.AllocationFile.Parse(p + 0x70 + 0x50 * 0);
+ h.ExtentsFile.Parse( p + 0x70 + 0x50 * 1);
+ h.CatalogFile.Parse( p + 0x70 + 0x50 * 2);
+ // h.AttributesFile.Parse(p + 0x70 + 0x50 * 3);
+ // h.StartupFile.Parse( p + 0x70 + 0x50 * 4);
+
+ RINOK(LoadExtentFile(inStream));
+ RINOK(LoadCatalog(inStream, progress));
+
+ // if (Header.NumFiles + Header.NumFolders != (UInt32)Items.Size()) return S_OK;
+
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsIn.h
new file mode 100644
index 000000000..c19539057
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsIn.h
@@ -0,0 +1,154 @@
+// HfsIn.h
+
+#ifndef __ARCHIVE_HFS_IN_H
+#define __ARCHIVE_HFS_IN_H
+
+#include "Common/MyString.h"
+#include "Common/Buffer.h"
+
+namespace NArchive {
+namespace NHfs {
+
+struct CExtent
+{
+ UInt32 Pos;
+ UInt32 NumBlocks;
+};
+
+struct CFork
+{
+ UInt64 Size;
+ // UInt32 ClumpSize;
+ UInt32 NumBlocks;
+ CExtent Extents[8];
+ void Parse(const Byte *p);
+};
+
+struct CVolHeader
+{
+ Byte Header[2];
+ UInt16 Version;
+ // UInt32 Attr;
+ // UInt32 LastMountedVersion;
+ // UInt32 JournalInfoBlock;
+
+ UInt32 CTime;
+ UInt32 MTime;
+ // UInt32 BackupTime;
+ // UInt32 CheckedTime;
+
+ // UInt32 NumFiles;
+ // UInt32 NumFolders;
+ int BlockSizeLog;
+ UInt32 NumBlocks;
+ UInt32 NumFreeBlocks;
+
+ // UInt32 WriteCount;
+ // UInt32 FinderInfo[8];
+ // UInt64 VolID;
+
+ // CFork AllocationFile;
+ CFork ExtentsFile;
+ CFork CatalogFile;
+ // CFork AttributesFile;
+ // CFork StartupFile;
+
+ bool IsHfsX() const { return Version > 4; }
+};
+
+inline void HfsTimeToFileTime(UInt32 hfsTime, FILETIME &ft)
+{
+ UInt64 v = ((UInt64)3600 * 24 * (365 * 303 + 24 * 3) + hfsTime) * 10000000;
+ ft.dwLowDateTime = (DWORD)v;
+ ft.dwHighDateTime = (DWORD)(v >> 32);
+}
+
+enum ERecordType
+{
+ RECORD_TYPE_FOLDER = 1,
+ RECORD_TYPE_FILE = 2,
+ RECORD_TYPE_FOLDER_THREAD = 3,
+ RECORD_TYPE_FILE_THREAD = 4
+};
+
+struct CItem
+{
+ UString Name;
+
+ UInt32 ParentID;
+
+ UInt16 Type;
+ // UInt16 Flags;
+ // UInt32 Valence;
+ UInt32 ID;
+ UInt32 CTime;
+ UInt32 MTime;
+ // UInt32 AttrMTime;
+ UInt32 ATime;
+ // UInt32 BackupDate;
+
+ /*
+ UInt32 OwnerID;
+ UInt32 GroupID;
+ Byte AdminFlags;
+ Byte OwnerFlags;
+ UInt16 FileMode;
+ union
+ {
+ UInt32 iNodeNum;
+ UInt32 LinkCount;
+ UInt32 RawDevice;
+ } special;
+ */
+
+ UInt64 Size;
+ UInt32 NumBlocks;
+ CRecordVector<CExtent> Extents;
+
+ bool IsDir() const { return Type == RECORD_TYPE_FOLDER; }
+ CItem(): Size(0), NumBlocks(0) {}
+};
+
+struct CIdIndexPair
+{
+ UInt32 ID;
+ int Index;
+};
+
+struct CProgressVirt
+{
+ virtual HRESULT SetTotal(UInt64 numFiles) PURE;
+ virtual HRESULT SetCompleted(UInt64 numFiles) PURE;
+};
+
+class CDatabase
+{
+ // CObjectVector<CIdExtents> FileExtents;
+ // CObjectVector<CIdExtents> ResExtents;
+ CRecordVector<CIdIndexPair> IdToIndexMap;
+
+ HRESULT LoadExtentFile(IInStream *inStream);
+ HRESULT LoadCatalog(IInStream *inStream, CProgressVirt *progress);
+
+ HRESULT ReadFile(const CFork &fork, CByteBuffer &buf, IInStream *inStream);
+public:
+ CVolHeader Header;
+ CObjectVector<CItem> Items;
+ // bool CaseSensetive;
+
+ void Clear()
+ {
+ // CaseSensetive = false;
+ Items.Clear();
+ // FileExtents.Clear();
+ // ResExtents.Clear();
+ IdToIndexMap.Clear();
+ }
+
+ UString GetItemPath(int index) const;
+ HRESULT Open(IInStream *inStream, CProgressVirt *progress);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsRegister.cpp
new file mode 100644
index 000000000..2d7069005
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Hfs/HfsRegister.cpp
@@ -0,0 +1,13 @@
+// HfsRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "HfsHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NHfs::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"HFS", L"hfs", 0, 0xE3, { 'H', '+', 0, 4 }, 4, false, CreateArc, 0 };
+
+REGISTER_ARC(Hfs)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/IArchive.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/IArchive.h
new file mode 100644
index 000000000..853202767
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/IArchive.h
@@ -0,0 +1,234 @@
+// IArchive.h
+
+#ifndef __IARCHIVE_H
+#define __IARCHIVE_H
+
+#include "../IProgress.h"
+#include "../IStream.h"
+#include "../PropID.h"
+
+#define ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 6, x)
+#define ARCHIVE_INTERFACE(i, x) ARCHIVE_INTERFACE_SUB(i, IUnknown, x)
+
+namespace NFileTimeType
+{
+ enum EEnum
+ {
+ kWindows,
+ kUnix,
+ kDOS
+ };
+}
+
+namespace NArchive
+{
+ enum
+ {
+ kName = 0,
+ kClassID,
+ kExtension,
+ kAddExtension,
+ kUpdate,
+ kKeepName,
+ kStartSignature,
+ kFinishSignature,
+ kAssociate
+ };
+
+ namespace NExtract
+ {
+ namespace NAskMode
+ {
+ enum
+ {
+ kExtract = 0,
+ kTest,
+ kSkip
+ };
+ }
+ namespace NOperationResult
+ {
+ enum
+ {
+ kOK = 0,
+ kUnSupportedMethod,
+ kDataError,
+ kCRCError
+ };
+ }
+ }
+ namespace NUpdate
+ {
+ namespace NOperationResult
+ {
+ enum
+ {
+ kOK = 0,
+ kError
+ };
+ }
+ }
+}
+
+#define INTERFACE_IArchiveOpenCallback(x) \
+ STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes) x; \
+ STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes) x; \
+
+ARCHIVE_INTERFACE(IArchiveOpenCallback, 0x10)
+{
+ INTERFACE_IArchiveOpenCallback(PURE);
+};
+
+
+#define INTERFACE_IArchiveExtractCallback(x) \
+ INTERFACE_IProgress(x) \
+ STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode) x; \
+ STDMETHOD(PrepareOperation)(Int32 askExtractMode) x; \
+ STDMETHOD(SetOperationResult)(Int32 resultEOperationResult) x; \
+
+ARCHIVE_INTERFACE_SUB(IArchiveExtractCallback, IProgress, 0x20)
+{
+ INTERFACE_IArchiveExtractCallback(PURE)
+};
+
+
+#define INTERFACE_IArchiveOpenVolumeCallback(x) \
+ STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream) x; \
+
+ARCHIVE_INTERFACE(IArchiveOpenVolumeCallback, 0x30)
+{
+ INTERFACE_IArchiveOpenVolumeCallback(PURE);
+};
+
+
+ARCHIVE_INTERFACE(IInArchiveGetStream, 0x40)
+{
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream) PURE;
+};
+
+
+ARCHIVE_INTERFACE(IArchiveOpenSetSubArchiveName, 0x50)
+{
+ STDMETHOD(SetSubArchiveName)(const wchar_t *name) PURE;
+};
+
+
+/*
+IInArchive::Extract:
+ indices must be sorted
+ numItems = 0xFFFFFFFF means "all files"
+ testMode != 0 means "test files without writing to outStream"
+*/
+
+#define INTERFACE_IInArchive(x) \
+ STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback) x; \
+ STDMETHOD(Close)() x; \
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems) x; \
+ STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) x; \
+ STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
+ STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
+ STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) x; \
+ STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x;
+
+ARCHIVE_INTERFACE(IInArchive, 0x60)
+{
+ INTERFACE_IInArchive(PURE)
+};
+
+ARCHIVE_INTERFACE(IArchiveOpenSeq, 0x61)
+{
+ STDMETHOD(OpenSeq)(ISequentialInStream *stream) PURE;
+};
+
+#define INTERFACE_IArchiveUpdateCallback(x) \
+ INTERFACE_IProgress(x); \
+ STDMETHOD(GetUpdateItemInfo)(UInt32 index, \
+ Int32 *newData, /*1 - new data, 0 - old data */ \
+ Int32 *newProperties, /* 1 - new properties, 0 - old properties */ \
+ UInt32 *indexInArchive /* -1 if there is no in archive, or if doesn't matter */ \
+ ) x; \
+ STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream) x; \
+ STDMETHOD(SetOperationResult)(Int32 operationResult) x; \
+
+ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback, IProgress, 0x80)
+{
+ INTERFACE_IArchiveUpdateCallback(PURE);
+};
+
+#define INTERFACE_IArchiveUpdateCallback2(x) \
+ INTERFACE_IArchiveUpdateCallback(x) \
+ STDMETHOD(GetVolumeSize)(UInt32 index, UInt64 *size) x; \
+ STDMETHOD(GetVolumeStream)(UInt32 index, ISequentialOutStream **volumeStream) x; \
+
+ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback2, IArchiveUpdateCallback, 0x82)
+{
+ INTERFACE_IArchiveUpdateCallback2(PURE);
+};
+
+
+#define INTERFACE_IOutArchive(x) \
+ STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems, IArchiveUpdateCallback *updateCallback) x; \
+ STDMETHOD(GetFileTimeType)(UInt32 *type) x;
+
+ARCHIVE_INTERFACE(IOutArchive, 0xA0)
+{
+ INTERFACE_IOutArchive(PURE)
+};
+
+
+ARCHIVE_INTERFACE(ISetProperties, 0x03)
+{
+ STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties) PURE;
+};
+
+
+#define IMP_IInArchive_GetProp(k) \
+ (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
+ { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \
+ const STATPROPSTG &srcItem = k[index]; \
+ *propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \
+
+#define IMP_IInArchive_GetProp_WITH_NAME(k) \
+ (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
+ { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \
+ const STATPROPSTG &srcItem = k[index]; \
+ *propID = srcItem.propid; *varType = srcItem.vt; \
+ if (srcItem.lpwstrName == 0) *name = 0; else *name = ::SysAllocString(srcItem.lpwstrName); return S_OK; } \
+
+#define IMP_IInArchive_Props \
+ STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties) \
+ { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \
+ STDMETHODIMP CHandler::GetPropertyInfo IMP_IInArchive_GetProp(kProps)
+
+#define IMP_IInArchive_Props_WITH_NAME \
+ STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties) \
+ { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \
+ STDMETHODIMP CHandler::GetPropertyInfo IMP_IInArchive_GetProp_WITH_NAME(kProps)
+
+
+#define IMP_IInArchive_ArcProps \
+ STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
+ { *numProperties = sizeof(kArcProps) / sizeof(kArcProps[0]); return S_OK; } \
+ STDMETHODIMP CHandler::GetArchivePropertyInfo IMP_IInArchive_GetProp(kArcProps)
+
+#define IMP_IInArchive_ArcProps_WITH_NAME \
+ STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
+ { *numProperties = sizeof(kArcProps) / sizeof(kArcProps[0]); return S_OK; } \
+ STDMETHODIMP CHandler::GetArchivePropertyInfo IMP_IInArchive_GetProp_WITH_NAME(kArcProps)
+
+#define IMP_IInArchive_ArcProps_NO_Table \
+ STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
+ { *numProperties = 0; return S_OK; } \
+ STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32, BSTR *, PROPID *, VARTYPE *) \
+ { return E_NOTIMPL; } \
+
+#define IMP_IInArchive_ArcProps_NO \
+ IMP_IInArchive_ArcProps_NO_Table \
+ STDMETHODIMP CHandler::GetArchiveProperty(PROPID, PROPVARIANT *value) \
+ { value->vt = VT_EMPTY; return S_OK; }
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHandler.cpp
new file mode 100644
index 000000000..ed8da189a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHandler.cpp
@@ -0,0 +1,278 @@
+// IsoHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/Defs.h"
+#include "Common/IntToString.h"
+#include "Common/NewHandler.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../Common/ItemNameUtils.h"
+
+#include "IsoHandler.h"
+
+using namespace NWindows;
+using namespace NTime;
+
+namespace NArchive {
+namespace NIso {
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ // try
+ {
+ if (_archive.Open(stream) != S_OK)
+ return S_FALSE;
+ _stream = stream;
+ }
+ // catch(...) { return S_FALSE; }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _archive.Clear();
+ _stream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _archive.Refs.Size() + _archive.BootEntries.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ if (index >= (UInt32)_archive.Refs.Size())
+ {
+ index -= _archive.Refs.Size();
+ const CBootInitialEntry &be = _archive.BootEntries[index];
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ // wchar_t name[32];
+ // ConvertUInt64ToString(index + 1, name);
+ UString s = L"[BOOT]" WSTRING_PATH_SEPARATOR;
+ // s += name;
+ // s += L"-";
+ s += be.GetName();
+ prop = (const wchar_t *)s;
+ break;
+ }
+ case kpidIsDir:
+ prop = false;
+ break;
+ case kpidSize:
+ case kpidPackSize:
+ prop = (UInt64)_archive.GetBootItemSize(index);
+ break;
+ }
+ }
+ else
+ {
+ const CRef &ref = _archive.Refs[index];
+ const CDir &item = ref.Dir->_subItems[ref.Index];
+ switch(propID)
+ {
+ case kpidPath:
+ // if (item.FileId.GetCapacity() >= 0)
+ {
+ UString s;
+ if (_archive.IsJoliet())
+ s = item.GetPathU();
+ else
+ s = MultiByteToUnicodeString(item.GetPath(_archive.IsSusp, _archive.SuspSkipSize), CP_OEMCP);
+
+ int pos = s.ReverseFind(L';');
+ if (pos >= 0 && pos == s.Length() - 2)
+ if (s[s.Length() - 1] == L'1')
+ s = s.Left(pos);
+ if (!s.IsEmpty())
+ if (s[s.Length() - 1] == L'.')
+ s = s.Left(s.Length() - 1);
+ prop = (const wchar_t *)NItemName::GetOSName2(s);
+ }
+ break;
+ case kpidIsDir:
+ prop = item.IsDir();
+ break;
+ case kpidSize:
+ case kpidPackSize:
+ if (!item.IsDir())
+ prop = (UInt64)item.DataLength;
+ break;
+ case kpidMTime:
+ {
+ FILETIME utcFileTime;
+ if (item.DateTime.GetFileTime(utcFileTime))
+ prop = utcFileTime;
+ /*
+ else
+ {
+ utcFileTime.dwLowDateTime = 0;
+ utcFileTime.dwHighDateTime = 0;
+ }
+ */
+ break;
+ }
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _archive.Refs.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for(i = 0; i < numItems; i++)
+ {
+ UInt32 index = (allFilesMode ? i : indices[i]);
+ if (index < (UInt32)_archive.Refs.Size())
+ {
+ const CRef &ref = _archive.Refs[index];
+ const CDir &item = ref.Dir->_subItems[ref.Index];
+ totalSize += item.DataLength;
+ }
+ else
+ {
+ totalSize += _archive.GetBootItemSize(index - _archive.Refs.Size());
+ }
+ }
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_stream);
+
+ CLimitedSequentialOutStream *outStreamSpec = new CLimitedSequentialOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ currentItemSize = 0;
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode;
+ askMode = testMode ? NArchive::NExtract::NAskMode::kTest : NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ UInt64 blockIndex;
+ if (index < (UInt32)_archive.Refs.Size())
+ {
+ const CRef &ref = _archive.Refs[index];
+ const CDir &item = ref.Dir->_subItems[ref.Index];
+ if (item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ currentItemSize = item.DataLength;
+ blockIndex = item.ExtentLocation;
+ }
+ else
+ {
+ int bootIndex = index - _archive.Refs.Size();
+ const CBootInitialEntry &be = _archive.BootEntries[bootIndex];
+ currentItemSize = _archive.GetBootItemSize(bootIndex);
+ blockIndex = be.LoadRBA;
+ }
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ outStreamSpec->SetStream(realOutStream);
+ realOutStream.Release();
+ outStreamSpec->Init(currentItemSize);
+ RINOK(_stream->Seek(blockIndex * _archive.BlockSize, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(currentItemSize);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(outStreamSpec->IsFinishedOK() ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ *stream = 0;
+ UInt64 blockIndex;
+ UInt64 currentItemSize;
+ if (index < (UInt32)_archive.Refs.Size())
+ {
+ const CRef &ref = _archive.Refs[index];
+ const CDir &item = ref.Dir->_subItems[ref.Index];
+ if (item.IsDir())
+ return S_FALSE;
+ currentItemSize = item.DataLength;
+ blockIndex = item.ExtentLocation;
+ }
+ else
+ {
+ int bootIndex = index - _archive.Refs.Size();
+ const CBootInitialEntry &be = _archive.BootEntries[bootIndex];
+ currentItemSize = _archive.GetBootItemSize(bootIndex);
+ blockIndex = be.LoadRBA;
+ }
+ return CreateLimitedInStream(_stream, blockIndex * _archive.BlockSize, currentItemSize, stream);
+ COM_TRY_END
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHandler.h
new file mode 100644
index 000000000..1dcade8f9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHandler.h
@@ -0,0 +1,30 @@
+// IsoHandler.h
+
+#ifndef __ISO_HANDLER_H
+#define __ISO_HANDLER_H
+
+#include "Common/MyCom.h"
+#include "../IArchive.h"
+
+#include "IsoIn.h"
+#include "IsoItem.h"
+
+namespace NArchive {
+namespace NIso {
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _stream;
+ CInArchive _archive;
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHeader.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHeader.cpp
new file mode 100644
index 000000000..b3e418bbc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHeader.cpp
@@ -0,0 +1,21 @@
+// Archive/Iso/Header.h
+
+#include "StdAfx.h"
+
+#include "IsoHeader.h"
+
+namespace NArchive {
+namespace NIso {
+
+const char *kElToritoSpec = "EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0";
+
+const wchar_t *kMediaTypes[5] =
+{
+ L"NoEmulation",
+ L"1.2M",
+ L"1.44M",
+ L"2.88M",
+ L"HardDisk"
+};
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHeader.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHeader.h
new file mode 100644
index 000000000..9702d70ae
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoHeader.h
@@ -0,0 +1,61 @@
+// Archive/IsoHeader.h
+
+#ifndef __ARCHIVE_ISO_HEADER_H
+#define __ARCHIVE_ISO_HEADER_H
+
+#include "Common/Types.h"
+
+namespace NArchive {
+namespace NIso {
+
+namespace NVolDescType
+{
+ const Byte kBootRecord = 0;
+ const Byte kPrimaryVol = 1;
+ const Byte kSupplementaryVol = 2;
+ const Byte kVolParttition = 3;
+ const Byte kTerminator = 255;
+}
+
+const Byte kVersion = 1;
+
+namespace NFileFlags
+{
+ const Byte kDirectory = 1 << 1;
+}
+
+extern const char *kElToritoSpec;
+
+const UInt32 kStartPos = 0x8000;
+
+namespace NBootEntryId
+{
+ const Byte kValidationEntry = 1;
+ const Byte kInitialEntryNotBootable = 0;
+ const Byte kInitialEntryBootable = 0x88;
+}
+
+namespace NBootPlatformId
+{
+ const Byte kX86 = 0;
+ const Byte kPowerPC = 1;
+ const Byte kMac = 2;
+}
+
+const BYTE kBootMediaTypeMask = 0xF;
+
+namespace NBootMediaType
+{
+ const Byte kNoEmulation = 0;
+ const Byte k1d2Floppy = 1;
+ const Byte k1d44Floppy = 2;
+ const Byte k2d88Floppy = 3;
+ const Byte kHardDisk = 4;
+}
+
+const int kNumBootMediaTypes = 5;
+extern const wchar_t *kMediaTypes[];
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoIn.cpp
new file mode 100644
index 000000000..84143348b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoIn.cpp
@@ -0,0 +1,452 @@
+// Archive/IsoIn.cpp
+
+#include "StdAfx.h"
+
+#include "IsoIn.h"
+
+#include "../../Common/StreamUtils.h"
+
+namespace NArchive {
+namespace NIso {
+
+Byte CInArchive::ReadByte()
+{
+ if (m_BufferPos >= BlockSize)
+ m_BufferPos = 0;
+ if (m_BufferPos == 0)
+ {
+ size_t processedSize = BlockSize;
+ if (ReadStream(_stream, m_Buffer, &processedSize) != S_OK)
+ throw 1;
+ if (processedSize != BlockSize)
+ throw 1;
+ }
+ Byte b = m_Buffer[m_BufferPos++];
+ _position++;
+ return b;
+}
+
+void CInArchive::ReadBytes(Byte *data, UInt32 size)
+{
+ for (UInt32 i = 0; i < size; i++)
+ data[i] = ReadByte();
+}
+
+void CInArchive::Skip(size_t size)
+{
+ while (size-- != 0)
+ ReadByte();
+}
+
+void CInArchive::SkipZeros(size_t size)
+{
+ while (size-- != 0)
+ {
+ Byte b = ReadByte();
+ if (b != 0)
+ throw 1;
+ }
+}
+
+UInt16 CInArchive::ReadUInt16Spec()
+{
+ UInt16 value = 0;
+ for (int i = 0; i < 2; i++)
+ value |= ((UInt16)(ReadByte()) << (8 * i));
+ return value;
+}
+
+
+UInt16 CInArchive::ReadUInt16()
+{
+ Byte b[4];
+ ReadBytes(b, 4);
+ UInt32 value = 0;
+ for (int i = 0; i < 2; i++)
+ {
+ if (b[i] != b[3 - i])
+ throw 1;
+ value |= ((UInt16)(b[i]) << (8 * i));
+ }
+ return (UInt16)value;
+}
+
+UInt32 CInArchive::ReadUInt32Le()
+{
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ value |= ((UInt32)(ReadByte()) << (8 * i));
+ return value;
+}
+
+UInt32 CInArchive::ReadUInt32Be()
+{
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ value <<= 8;
+ value |= ReadByte();
+ }
+ return value;
+}
+
+UInt32 CInArchive::ReadUInt32()
+{
+ Byte b[8];
+ ReadBytes(b, 8);
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ if (b[i] != b[7 - i])
+ throw 1;
+ value |= ((UInt32)(b[i]) << (8 * i));
+ }
+ return value;
+}
+
+UInt32 CInArchive::ReadDigits(int numDigits)
+{
+ UInt32 res = 0;
+ for (int i = 0; i < numDigits; i++)
+ {
+ Byte b = ReadByte();
+ if (b < '0' || b > '9')
+ {
+ if (b == 0) // it's bug in some CD's
+ b = '0';
+ else
+ throw 1;
+ }
+ UInt32 d = (UInt32)(b - '0');
+ res *= 10;
+ res += d;
+ }
+ return res;
+}
+
+void CInArchive::ReadDateTime(CDateTime &d)
+{
+ d.Year = (UInt16)ReadDigits(4);
+ d.Month = (Byte)ReadDigits(2);
+ d.Day = (Byte)ReadDigits(2);
+ d.Hour = (Byte)ReadDigits(2);
+ d.Minute = (Byte)ReadDigits(2);
+ d.Second = (Byte)ReadDigits(2);
+ d.Hundredths = (Byte)ReadDigits(2);
+ d.GmtOffset = (signed char)ReadByte();
+}
+
+void CInArchive::ReadBootRecordDescriptor(CBootRecordDescriptor &d)
+{
+ ReadBytes(d.BootSystemId, sizeof(d.BootSystemId));
+ ReadBytes(d.BootId, sizeof(d.BootId));
+ ReadBytes(d.BootSystemUse, sizeof(d.BootSystemUse));
+}
+
+void CInArchive::ReadRecordingDateTime(CRecordingDateTime &t)
+{
+ t.Year = ReadByte();
+ t.Month = ReadByte();
+ t.Day = ReadByte();
+ t.Hour = ReadByte();
+ t.Minute = ReadByte();
+ t.Second = ReadByte();
+ t.GmtOffset = (signed char)ReadByte();
+}
+
+void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
+{
+ r.ExtendedAttributeRecordLen = ReadByte();
+ if (r.ExtendedAttributeRecordLen != 0)
+ throw 1;
+ r.ExtentLocation = ReadUInt32();
+ r.DataLength = ReadUInt32();
+ ReadRecordingDateTime(r.DateTime);
+ r.FileFlags = ReadByte();
+ r.FileUnitSize = ReadByte();
+ r.InterleaveGapSize = ReadByte();
+ r.VolSequenceNumber = ReadUInt16();
+ Byte idLen = ReadByte();
+ r.FileId.SetCapacity(idLen);
+ ReadBytes((Byte *)r.FileId, idLen);
+ int padSize = 1 - (idLen & 1);
+
+ // SkipZeros(1 - (idLen & 1));
+ Skip(1 - (idLen & 1)); // it's bug in some cd's. Must be zeros
+
+ int curPos = 33 + idLen + padSize;
+ if (curPos > len)
+ throw 1;
+ int rem = len - curPos;
+ r.SystemUse.SetCapacity(rem);
+ ReadBytes((Byte *)r.SystemUse, rem);
+}
+
+void CInArchive::ReadDirRecord(CDirRecord &r)
+{
+ Byte len = ReadByte();
+ // Some CDs can have incorrect value len = 48 ('0') in VolumeDescriptor.
+ // But maybe we must use real "len" for other records.
+ len = 34;
+ ReadDirRecord2(r, len);
+}
+
+void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
+{
+ d.VolFlags = ReadByte();
+ ReadBytes(d.SystemId, sizeof(d.SystemId));
+ ReadBytes(d.VolumeId, sizeof(d.VolumeId));
+ SkipZeros(8);
+ d.VolumeSpaceSize = ReadUInt32();
+ ReadBytes(d.EscapeSequence, sizeof(d.EscapeSequence));
+ d.VolumeSetSize = ReadUInt16();
+ d.VolumeSequenceNumber = ReadUInt16();
+ d.LogicalBlockSize = ReadUInt16();
+ d.PathTableSize = ReadUInt32();
+ d.LPathTableLocation = ReadUInt32Le();
+ d.LOptionalPathTableLocation = ReadUInt32Le();
+ d.MPathTableLocation = ReadUInt32Be();
+ d.MOptionalPathTableLocation = ReadUInt32Be();
+ ReadDirRecord(d.RootDirRecord);
+ ReadBytes(d.VolumeSetId, sizeof(d.VolumeSetId));
+ ReadBytes(d.PublisherId, sizeof(d.PublisherId));
+ ReadBytes(d.DataPreparerId, sizeof(d.DataPreparerId));
+ ReadBytes(d.ApplicationId, sizeof(d.ApplicationId));
+ ReadBytes(d.CopyrightFileId, sizeof(d.CopyrightFileId));
+ ReadBytes(d.AbstractFileId, sizeof(d.AbstractFileId));
+ ReadBytes(d.BibFileId, sizeof(d.BibFileId));
+ ReadDateTime(d.CTime);
+ ReadDateTime(d.MTime);
+ ReadDateTime(d.ExpirationTime);
+ ReadDateTime(d.EffectiveTime);
+ d.FileStructureVersion = ReadByte(); // = 1
+ SkipZeros(1);
+ ReadBytes(d.ApplicationUse, sizeof(d.ApplicationUse));
+ SkipZeros(653);
+}
+
+static const Byte kSig_CD001[5] = { 'C', 'D', '0', '0', '1' };
+
+static const Byte kSig_NSR02[5] = { 'N', 'S', 'R', '0', '2' };
+static const Byte kSig_NSR03[5] = { 'N', 'S', 'R', '0', '3' };
+static const Byte kSig_BEA01[5] = { 'B', 'E', 'A', '0', '1' };
+static const Byte kSig_TEA01[5] = { 'T', 'E', 'A', '0', '1' };
+
+static inline bool CheckSignature(const Byte *sig, const Byte *data)
+{
+ for (int i = 0; i < 5; i++)
+ if (sig[i] != data[i])
+ return false;
+ return true;
+}
+
+void CInArchive::SeekToBlock(UInt32 blockIndex)
+{
+ if (_stream->Seek((UInt64)blockIndex * VolDescs[MainVolDescIndex].LogicalBlockSize, STREAM_SEEK_SET, &_position) != S_OK)
+ throw 1;
+ m_BufferPos = 0;
+}
+
+void CInArchive::ReadDir(CDir &d, int level)
+{
+ if (!d.IsDir())
+ return;
+ SeekToBlock(d.ExtentLocation);
+ UInt64 startPos = _position;
+
+ bool firstItem = true;
+ for (;;)
+ {
+ UInt64 offset = _position - startPos;
+ if (offset >= d.DataLength)
+ break;
+ Byte len = ReadByte();
+ if (len == 0)
+ continue;
+ CDir subItem;
+ ReadDirRecord2(subItem, len);
+ if (firstItem && level == 0)
+ IsSusp = subItem.CheckSusp(SuspSkipSize);
+
+ if (!subItem.IsSystemItem())
+ d._subItems.Add(subItem);
+
+ firstItem = false;
+ }
+ for (int i = 0; i < d._subItems.Size(); i++)
+ ReadDir(d._subItems[i], level + 1);
+}
+
+void CInArchive::CreateRefs(CDir &d)
+{
+ if (!d.IsDir())
+ return;
+ for (int i = 0; i < d._subItems.Size(); i++)
+ {
+ CRef ref;
+ CDir &subItem = d._subItems[i];
+ subItem.Parent = &d;
+ ref.Dir = &d;
+ ref.Index = i;
+ Refs.Add(ref);
+ CreateRefs(subItem);
+ }
+}
+
+void CInArchive::ReadBootInfo()
+{
+ if (!_bootIsDefined)
+ return;
+ if (memcmp(_bootDesc.BootSystemId, kElToritoSpec, sizeof(_bootDesc.BootSystemId)) != 0)
+ return;
+
+ const Byte *p = (const Byte *)_bootDesc.BootSystemUse;
+ UInt32 blockIndex = p[0] | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16) | ((UInt32)p[3] << 24);
+ SeekToBlock(blockIndex);
+ Byte b = ReadByte();
+ if (b != NBootEntryId::kValidationEntry)
+ return;
+ {
+ CBootValidationEntry e;
+ e.PlatformId = ReadByte();
+ if (ReadUInt16Spec() != 0)
+ throw 1;
+ ReadBytes(e.Id, sizeof(e.Id));
+ /* UInt16 checkSum = */ ReadUInt16Spec();
+ if (ReadByte() != 0x55)
+ throw 1;
+ if (ReadByte() != 0xAA)
+ throw 1;
+ }
+ b = ReadByte();
+ if (b == NBootEntryId::kInitialEntryBootable || b == NBootEntryId::kInitialEntryNotBootable)
+ {
+ CBootInitialEntry e;
+ e.Bootable = (b == NBootEntryId::kInitialEntryBootable);
+ e.BootMediaType = ReadByte();
+ e.LoadSegment = ReadUInt16Spec();
+ e.SystemType = ReadByte();
+ if (ReadByte() != 0)
+ throw 1;
+ e.SectorCount = ReadUInt16Spec();
+ e.LoadRBA = ReadUInt32Le();
+ if (ReadByte() != 0)
+ throw 1;
+ BootEntries.Add(e);
+ }
+ else
+ return;
+}
+
+HRESULT CInArchive::Open2()
+{
+ Clear();
+ RINOK(_stream->Seek(kStartPos, STREAM_SEEK_CUR, &_position));
+
+ m_BufferPos = 0;
+ BlockSize = kBlockSize;
+ for (;;)
+ {
+ Byte sig[7];
+ ReadBytes(sig, 7);
+ Byte ver = sig[6];
+ if (!CheckSignature(kSig_CD001, sig + 1))
+ {
+ return S_FALSE;
+ /*
+ if (sig[0] != 0 || ver != 1)
+ break;
+ if (CheckSignature(kSig_BEA01, sig + 1))
+ {
+ }
+ else if (CheckSignature(kSig_TEA01, sig + 1))
+ {
+ break;
+ }
+ else if (CheckSignature(kSig_NSR02, sig + 1))
+ {
+ }
+ else
+ break;
+ SkipZeros(0x800 - 7);
+ continue;
+ */
+ }
+ // version = 2 for ISO 9660:1999?
+ if (ver > 2)
+ throw S_FALSE;
+
+ if (sig[0] == NVolDescType::kTerminator)
+ {
+ break;
+ // Skip(0x800 - 7);
+ // continue;
+ }
+ switch(sig[0])
+ {
+ case NVolDescType::kBootRecord:
+ {
+ _bootIsDefined = true;
+ ReadBootRecordDescriptor(_bootDesc);
+ break;
+ }
+ case NVolDescType::kPrimaryVol:
+ case NVolDescType::kSupplementaryVol:
+ {
+ // some ISOs have two PrimaryVols.
+ CVolumeDescriptor vd;
+ ReadVolumeDescriptor(vd);
+ if (sig[0] == NVolDescType::kPrimaryVol)
+ {
+ // some burners write "Joliet" Escape Sequence to primary volume
+ memset(vd.EscapeSequence, 0, sizeof(vd.EscapeSequence));
+ }
+ VolDescs.Add(vd);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ if (VolDescs.IsEmpty())
+ return S_FALSE;
+ for (MainVolDescIndex = VolDescs.Size() - 1; MainVolDescIndex > 0; MainVolDescIndex--)
+ if (VolDescs[MainVolDescIndex].IsJoliet())
+ break;
+ // MainVolDescIndex = 0; // to read primary volume
+ const CVolumeDescriptor &vd = VolDescs[MainVolDescIndex];
+ if (vd.LogicalBlockSize != kBlockSize)
+ return S_FALSE;
+ (CDirRecord &)_rootDir = vd.RootDirRecord;
+ ReadDir(_rootDir, 0);
+ CreateRefs(_rootDir);
+ ReadBootInfo();
+ return S_OK;
+}
+
+HRESULT CInArchive::Open(IInStream *inStream)
+{
+ _stream = inStream;
+ UInt64 pos;
+ RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &pos));
+ RINOK(_stream->Seek(0, STREAM_SEEK_END, &_archiveSize));
+ RINOK(_stream->Seek(pos, STREAM_SEEK_SET, &_position));
+ HRESULT res = S_FALSE;
+ try { res = Open2(); }
+ catch(...) { Clear(); res = S_FALSE; }
+ _stream.Release();
+ return res;
+}
+
+void CInArchive::Clear()
+{
+ Refs.Clear();
+ _rootDir.Clear();
+ VolDescs.Clear();
+ _bootIsDefined = false;
+ BootEntries.Clear();
+ SuspSkipSize = 0;
+ IsSusp = false;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoIn.h
new file mode 100644
index 000000000..49687e27a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoIn.h
@@ -0,0 +1,300 @@
+// Archive/IsoIn.h
+
+#ifndef __ARCHIVE_ISO_IN_H
+#define __ARCHIVE_ISO_IN_H
+
+#include "Common/IntToString.h"
+#include "Common/MyCom.h"
+
+#include "../../IStream.h"
+
+#include "IsoHeader.h"
+#include "IsoItem.h"
+
+namespace NArchive {
+namespace NIso {
+
+struct CDir: public CDirRecord
+{
+ CDir *Parent;
+ CObjectVector<CDir> _subItems;
+
+ void Clear()
+ {
+ Parent = 0;
+ _subItems.Clear();
+ }
+
+ int GetLength(bool checkSusp, int skipSize) const
+ {
+ int len = GetLengthCur(checkSusp, skipSize);
+ if (Parent != 0)
+ if (Parent->Parent != 0)
+ len += 1 + Parent->GetLength(checkSusp, skipSize);
+ return len;
+ }
+
+ int GetLengthU() const
+ {
+ int len = (int)(FileId.GetCapacity() / 2);
+ if (Parent != 0)
+ if (Parent->Parent != 0)
+ len += 1 + Parent->GetLengthU();
+ return len;
+ }
+
+ AString GetPath(bool checkSusp, int skipSize) const
+ {
+ AString s;
+ int len = GetLength(checkSusp, skipSize);
+ char *p = s.GetBuffer(len + 1);
+ p += len;
+ *p = 0;
+ const CDir *cur = this;
+ for (;;)
+ {
+ int curLen = cur->GetLengthCur(checkSusp, skipSize);
+ p -= curLen;
+ memmove(p, (const char *)(const Byte *)cur->GetNameCur(checkSusp, skipSize), curLen);
+ cur = cur->Parent;
+ if (cur == 0)
+ break;
+ if (cur->Parent == 0)
+ break;
+ p--;
+ *p = CHAR_PATH_SEPARATOR;
+ }
+ s.ReleaseBuffer();
+ return s;
+ }
+
+ UString GetPathU() const
+ {
+ UString s;
+ int len = GetLengthU();
+ wchar_t *p = s.GetBuffer(len + 1);
+ p += len;
+ *p = 0;
+ const CDir *cur = this;
+ for (;;)
+ {
+ int curLen = (int)(cur->FileId.GetCapacity() / 2);
+ p -= curLen;
+ for (int i = 0; i < curLen; i++)
+ {
+ Byte b0 = ((const Byte *)cur->FileId)[i * 2];
+ Byte b1 = ((const Byte *)cur->FileId)[i * 2 + 1];
+ p[i] = (wchar_t)(((wchar_t)b0 << 8) | b1);
+ }
+ cur = cur->Parent;
+ if (cur == 0)
+ break;
+ if (cur->Parent == 0)
+ break;
+ p--;
+ *p = WCHAR_PATH_SEPARATOR;
+ }
+ s.ReleaseBuffer();
+ return s;
+ }
+};
+
+struct CDateTime
+{
+ UInt16 Year;
+ Byte Month;
+ Byte Day;
+ Byte Hour;
+ Byte Minute;
+ Byte Second;
+ Byte Hundredths;
+ signed char GmtOffset; // min intervals from -48 (West) to +52 (East) recorded.
+ bool NotSpecified() const { return Year == 0 && Month == 0 && Day == 0 &&
+ Hour == 0 && Minute == 0 && Second == 0 && GmtOffset == 0; }
+};
+
+struct CBootRecordDescriptor
+{
+ Byte BootSystemId[32]; // a-characters
+ Byte BootId[32]; // a-characters
+ Byte BootSystemUse[1977];
+};
+
+struct CBootValidationEntry
+{
+ Byte PlatformId;
+ Byte Id[24]; // to identify the manufacturer/developer of the CD-ROM.
+};
+
+struct CBootInitialEntry
+{
+ bool Bootable;
+ Byte BootMediaType;
+ UInt16 LoadSegment;
+ /* This is the load segment for the initial boot image. If this
+ value is 0 the system will use the traditional segment of 7C0. If this value
+ is non-zero the system will use the specified segment. This applies to x86
+ architectures only. For "flat" model architectures (such as Motorola) this
+ is the address divided by 10. */
+ Byte SystemType; // This must be a copy of byte 5 (System Type) from the
+ // Partition Table found in the boot image.
+ UInt16 SectorCount; // This is the number of virtual/emulated sectors the system
+ // will store at Load Segment during the initial boot procedure.
+ UInt32 LoadRBA; // This is the start address of the virtual disk. CD’s use
+ // Relative/Logical block addressing.
+
+ UInt64 GetSize() const
+ {
+ // if (BootMediaType == NBootMediaType::k1d44Floppy) (1440 << 10);
+ return SectorCount * 512;
+ }
+
+ UString GetName() const
+ {
+ UString s;
+ if (Bootable)
+ s += L"Bootable";
+ else
+ s += L"NotBootable";
+ s += L"_";
+ if (BootMediaType >= kNumBootMediaTypes)
+ {
+ wchar_t name[16];
+ ConvertUInt32ToString(BootMediaType, name);
+ s += name;
+ }
+ else
+ s += kMediaTypes[BootMediaType];
+ s += L".img";
+ return s;
+ }
+};
+
+struct CVolumeDescriptor
+{
+ Byte VolFlags;
+ Byte SystemId[32]; // a-characters. An identification of a system
+ // which can recognize and act upon the content of the Logical
+ // Sectors with logical Sector Numbers 0 to 15 of the volume.
+ Byte VolumeId[32]; // d-characters. An identification of the volume.
+ UInt32 VolumeSpaceSize; // the number of Logical Blocks in which the Volume Space of the volume is recorded
+ Byte EscapeSequence[32];
+ UInt16 VolumeSetSize;
+ UInt16 VolumeSequenceNumber; // the ordinal number of the volume in the Volume Set of which the volume is a member.
+ UInt16 LogicalBlockSize;
+ UInt32 PathTableSize;
+ UInt32 LPathTableLocation;
+ UInt32 LOptionalPathTableLocation;
+ UInt32 MPathTableLocation;
+ UInt32 MOptionalPathTableLocation;
+ CDirRecord RootDirRecord;
+ Byte VolumeSetId[128];
+ Byte PublisherId[128];
+ Byte DataPreparerId[128];
+ Byte ApplicationId[128];
+ Byte CopyrightFileId[37];
+ Byte AbstractFileId[37];
+ Byte BibFileId[37];
+ CDateTime CTime;
+ CDateTime MTime;
+ CDateTime ExpirationTime;
+ CDateTime EffectiveTime;
+ Byte FileStructureVersion; // = 1;
+ Byte ApplicationUse[512];
+
+ bool IsJoliet() const
+ {
+ if ((VolFlags & 1) != 0)
+ return false;
+ Byte b = EscapeSequence[2];
+ return (EscapeSequence[0] == 0x25 && EscapeSequence[1] == 0x2F &&
+ (b == 0x40 || b == 0x43 || b == 0x45));
+ }
+};
+
+struct CRef
+{
+ CDir *Dir;
+ UInt32 Index;
+};
+
+const UInt32 kBlockSize = 1 << 11;
+
+class CInArchive
+{
+ CMyComPtr<IInStream> _stream;
+ UInt64 _position;
+
+ Byte m_Buffer[kBlockSize];
+ UInt32 m_BufferPos;
+
+ CDir _rootDir;
+ bool _bootIsDefined;
+ CBootRecordDescriptor _bootDesc;
+
+ void Skip(size_t size);
+ void SkipZeros(size_t size);
+ Byte ReadByte();
+ void ReadBytes(Byte *data, UInt32 size);
+ UInt16 ReadUInt16Spec();
+ UInt16 ReadUInt16();
+ UInt32 ReadUInt32Le();
+ UInt32 ReadUInt32Be();
+ UInt32 ReadUInt32();
+ UInt64 ReadUInt64();
+ UInt32 ReadDigits(int numDigits);
+ void ReadDateTime(CDateTime &d);
+ void ReadRecordingDateTime(CRecordingDateTime &t);
+ void ReadDirRecord2(CDirRecord &r, Byte len);
+ void ReadDirRecord(CDirRecord &r);
+
+ void ReadBootRecordDescriptor(CBootRecordDescriptor &d);
+ void ReadVolumeDescriptor(CVolumeDescriptor &d);
+
+ void SeekToBlock(UInt32 blockIndex);
+ void ReadDir(CDir &d, int level);
+ void CreateRefs(CDir &d);
+
+ void ReadBootInfo();
+ HRESULT Open2();
+public:
+ HRESULT Open(IInStream *inStream);
+ void Clear();
+
+ UInt64 _archiveSize;
+
+ CRecordVector<CRef> Refs;
+ CObjectVector<CVolumeDescriptor> VolDescs;
+ int MainVolDescIndex;
+ UInt32 BlockSize;
+ CObjectVector<CBootInitialEntry> BootEntries;
+
+
+ bool IsJoliet() const { return VolDescs[MainVolDescIndex].IsJoliet(); }
+
+ UInt64 GetBootItemSize(int index) const
+ {
+ const CBootInitialEntry &be = BootEntries[index];
+ UInt64 size = be.GetSize();
+ if (be.BootMediaType == NBootMediaType::k1d2Floppy)
+ size = (1200 << 10);
+ else if (be.BootMediaType == NBootMediaType::k1d44Floppy)
+ size = (1440 << 10);
+ else if (be.BootMediaType == NBootMediaType::k2d88Floppy)
+ size = (2880 << 10);
+ UInt64 startPos = be.LoadRBA * BlockSize;
+ if (startPos < _archiveSize)
+ {
+ if (_archiveSize - startPos < size)
+ size = _archiveSize - startPos;
+ }
+ return size;
+ }
+
+ bool IsSusp;
+ int SuspSkipSize;
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoItem.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoItem.h
new file mode 100644
index 000000000..f39c2f5d2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoItem.h
@@ -0,0 +1,141 @@
+// Archive/IsoItem.h
+
+#ifndef __ARCHIVE_ISO_ITEM_H
+#define __ARCHIVE_ISO_ITEM_H
+
+#include "Common/Types.h"
+#include "Common/MyString.h"
+#include "Common/Buffer.h"
+
+#include "Windows/Time.h"
+
+#include "IsoHeader.h"
+
+namespace NArchive {
+namespace NIso {
+
+struct CRecordingDateTime
+{
+ Byte Year;
+ Byte Month;
+ Byte Day;
+ Byte Hour;
+ Byte Minute;
+ Byte Second;
+ signed char GmtOffset; // min intervals from -48 (West) to +52 (East) recorded.
+
+ bool GetFileTime(FILETIME &ft) const
+ {
+ UInt64 value;
+ bool res = NWindows::NTime::GetSecondsSince1601(Year + 1900, Month, Day, Hour, Minute, Second, value);
+ if (res)
+ {
+ value -= (UInt64)((Int64)GmtOffset * 15 * 60);
+ value *= 10000000;
+ }
+ ft.dwLowDateTime = (DWORD)value;
+ ft.dwHighDateTime = (DWORD)(value >> 32);
+ return res;
+ }
+};
+
+struct CDirRecord
+{
+ Byte ExtendedAttributeRecordLen;
+ UInt32 ExtentLocation;
+ UInt32 DataLength;
+ CRecordingDateTime DateTime;
+ Byte FileFlags;
+ Byte FileUnitSize;
+ Byte InterleaveGapSize;
+ UInt16 VolSequenceNumber;
+ CByteBuffer FileId;
+ CByteBuffer SystemUse;
+
+ bool IsDir() const { return (FileFlags & NFileFlags::kDirectory) != 0; }
+ bool IsSystemItem() const
+ {
+ if (FileId.GetCapacity() != 1)
+ return false;
+ Byte b = *(const Byte *)FileId;
+ return (b == 0 || b == 1);
+ }
+
+ const Byte* FindSuspName(int skipSize, int &lenRes) const
+ {
+ lenRes = 0;
+ const Byte *p = (const Byte *)SystemUse + skipSize;
+ int length = (int)(SystemUse.GetCapacity() - skipSize);
+ while (length >= 5)
+ {
+ int len = p[2];
+ if (p[0] == 'N' && p[1] == 'M' && p[3] == 1)
+ {
+ lenRes = len - 5;
+ return p + 5;
+ }
+ p += len;
+ length -= len;
+ }
+ return 0;
+ }
+
+ int GetLengthCur(bool checkSusp, int skipSize) const
+ {
+ if (checkSusp)
+ {
+ int len;
+ const Byte *res = FindSuspName(skipSize, len);
+ if (res != 0)
+ return len;
+ }
+ return (int)FileId.GetCapacity();
+ }
+
+ const Byte* GetNameCur(bool checkSusp, int skipSize) const
+ {
+ if (checkSusp)
+ {
+ int len;
+ const Byte *res = FindSuspName(skipSize, len);
+ if (res != 0)
+ return res;
+ }
+ return (const Byte *)FileId;
+ }
+
+
+ bool CheckSusp(const Byte *p, int &startPos) const
+ {
+ if (p[0] == 'S' &&
+ p[1] == 'P' &&
+ p[2] == 0x7 &&
+ p[3] == 0x1 &&
+ p[4] == 0xBE &&
+ p[5] == 0xEF)
+ {
+ startPos = p[6];
+ return true;
+ }
+ return false;
+ }
+
+ bool CheckSusp(int &startPos) const
+ {
+ const Byte *p = (const Byte *)SystemUse;
+ int length = (int)SystemUse.GetCapacity();
+ const int kMinLen = 7;
+ if (length < kMinLen)
+ return false;
+ if (CheckSusp(p, startPos))
+ return true;
+ const int kOffset2 = 14;
+ if (length < kOffset2 + kMinLen)
+ return false;
+ return CheckSusp(p + kOffset2, startPos);
+ }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoRegister.cpp
new file mode 100644
index 000000000..b43caba37
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Iso/IsoRegister.cpp
@@ -0,0 +1,13 @@
+// IsoRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "IsoHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NIso::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Iso", L"iso", 0, 0xE7, { 'C', 'D', '0', '0', '1', 0x1 }, 7, false, CreateArc, 0 };
+
+REGISTER_ARC(Iso)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/LzhHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/LzhHandler.cpp
new file mode 100644
index 000000000..983d90ec6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/LzhHandler.cpp
@@ -0,0 +1,783 @@
+// LzhHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../ICoder.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+#include "../Compress/LzhDecoder.h"
+
+#include "IArchive.h"
+
+#include "Common/ItemNameUtils.h"
+
+using namespace NWindows;
+using namespace NTime;
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+
+namespace NArchive {
+namespace NLzh{
+
+const int kMethodIdSize = 5;
+
+const Byte kExtIdFileName = 0x01;
+const Byte kExtIdDirName = 0x02;
+const Byte kExtIdUnixTime = 0x54;
+
+struct CExtension
+{
+ Byte Type;
+ CByteBuffer Data;
+ AString GetString() const
+ {
+ AString s;
+ for (size_t i = 0; i < Data.GetCapacity(); i++)
+ {
+ char c = (char)Data[i];
+ if (c == 0)
+ break;
+ s += c;
+ }
+ return s;
+ }
+};
+
+struct CItem
+{
+ AString Name;
+ Byte Method[kMethodIdSize];
+ Byte Attributes;
+ Byte Level;
+ Byte OsId;
+ UInt32 PackSize;
+ UInt32 Size;
+ UInt32 ModifiedTime;
+ UInt16 CRC;
+ CObjectVector<CExtension> Extensions;
+
+ bool IsValidMethod() const { return (Method[0] == '-' && Method[1] == 'l' && Method[4] == '-'); }
+ bool IsLhMethod() const {return (IsValidMethod() && Method[2] == 'h'); }
+ bool IsDir() const {return (IsLhMethod() && Method[3] == 'd'); }
+
+ bool IsCopyMethod() const
+ {
+ return (IsLhMethod() && Method[3] == '0') ||
+ (IsValidMethod() && Method[2] == 'z' && Method[3] == '4');
+ }
+
+ bool IsLh1GroupMethod() const
+ {
+ if (!IsLhMethod())
+ return false;
+ switch(Method[3])
+ {
+ case '1':
+ return true;
+ }
+ return false;
+ }
+
+ bool IsLh4GroupMethod() const
+ {
+ if (!IsLhMethod())
+ return false;
+ switch(Method[3])
+ {
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ return true;
+ }
+ return false;
+ }
+
+ int GetNumDictBits() const
+ {
+ if (!IsLhMethod())
+ return 0;
+ switch(Method[3])
+ {
+ case '1': return 12;
+ case '2': return 13;
+ case '3': return 13;
+ case '4': return 12;
+ case '5': return 13;
+ case '6': return 15;
+ case '7': return 16;
+ }
+ return 0;
+ }
+
+ int FindExt(Byte type) const
+ {
+ for (int i = 0; i < Extensions.Size(); i++)
+ if (Extensions[i].Type == type)
+ return i;
+ return -1;
+ }
+ bool GetUnixTime(UInt32 &value) const
+ {
+ int index = FindExt(kExtIdUnixTime);
+ if (index < 0)
+ {
+ if (Level == 2)
+ {
+ value = ModifiedTime;
+ return true;
+ }
+ return false;
+ }
+ const Byte *data = (const Byte *)(Extensions[index].Data);
+ value = GetUi32(data);
+ return true;
+ }
+
+ AString GetDirName() const
+ {
+ int index = FindExt(kExtIdDirName);
+ if (index < 0)
+ return AString();
+ return Extensions[index].GetString();
+ }
+
+ AString GetFileName() const
+ {
+ int index = FindExt(kExtIdFileName);
+ if (index < 0)
+ return Name;
+ return Extensions[index].GetString();
+ }
+
+ AString GetName() const
+ {
+ AString dirName = GetDirName();
+ dirName.Replace((char)(unsigned char)0xFF, CHAR_PATH_SEPARATOR);
+ if (!dirName.IsEmpty())
+ {
+ char c = dirName[dirName.Length() - 1];
+ if (c != CHAR_PATH_SEPARATOR)
+ dirName += CHAR_PATH_SEPARATOR;
+ }
+ return dirName + GetFileName();
+ }
+};
+
+struct CItemEx: public CItem
+{
+ UInt64 DataPosition;
+};
+
+class CInArchive
+{
+ CMyComPtr<IInStream> m_Stream;
+ UInt64 m_Position;
+
+ HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize);
+ HRESULT CheckReadBytes(void *data, UInt32 size);
+public:
+ HRESULT Open(IInStream *inStream);
+ HRESULT GetNextItem(bool &filled, CItemEx &itemInfo);
+ HRESULT Skip(UInt64 numBytes);
+};
+
+HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
+{
+ size_t realProcessedSize = size;
+ RINOK(ReadStream(m_Stream, data, &realProcessedSize));
+ processedSize = (UInt32)realProcessedSize;
+ m_Position += processedSize;
+ return S_OK;
+}
+
+HRESULT CInArchive::CheckReadBytes(void *data, UInt32 size)
+{
+ UInt32 processedSize;
+ RINOK(ReadBytes(data, size, processedSize));
+ return (processedSize == size) ? S_OK: S_FALSE;
+}
+
+HRESULT CInArchive::Open(IInStream *inStream)
+{
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
+ m_Stream = inStream;
+ return S_OK;
+}
+
+static const Byte *ReadUInt16(const Byte *p, UInt16 &v)
+{
+ v = Get16(p);
+ return p + 2;
+}
+
+static const Byte *ReadString(const Byte *p, size_t size, AString &s)
+{
+ s.Empty();
+ for (size_t i = 0; i < size; i++)
+ {
+ char c = p[i];
+ if (c == 0)
+ break;
+ s += c;
+ }
+ return p + size;
+}
+
+static Byte CalcSum(const Byte *data, size_t size)
+{
+ Byte sum = 0;
+ for (size_t i = 0; i < size; i++)
+ sum = (Byte)(sum + data[i]);
+ return sum;
+}
+
+HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
+{
+ filled = false;
+
+ UInt32 processedSize;
+ Byte startHeader[2];
+ RINOK(ReadBytes(startHeader, 2, processedSize))
+ if (processedSize == 0)
+ return S_OK;
+ if (processedSize == 1)
+ return (startHeader[0] == 0) ? S_OK: S_FALSE;
+ if (startHeader[0] == 0 && startHeader[1] == 0)
+ return S_OK;
+
+ Byte header[256];
+ const UInt32 kBasicPartSize = 22;
+ RINOK(ReadBytes(header, kBasicPartSize, processedSize));
+ if (processedSize != kBasicPartSize)
+ return (startHeader[0] == 0) ? S_OK: S_FALSE;
+
+ const Byte *p = header;
+ memmove(item.Method, p, kMethodIdSize);
+ if (!item.IsValidMethod())
+ return S_OK;
+ p += kMethodIdSize;
+ item.PackSize = Get32(p);
+ item.Size = Get32(p + 4);
+ item.ModifiedTime = Get32(p + 8);
+ item.Attributes = p[12];
+ item.Level = p[13];
+ p += 14;
+ if (item.Level > 2)
+ return S_FALSE;
+ UInt32 headerSize;
+ if (item.Level < 2)
+ {
+ headerSize = startHeader[0];
+ if (headerSize < kBasicPartSize)
+ return S_FALSE;
+ UInt32 remain = headerSize - kBasicPartSize;
+ RINOK(CheckReadBytes(header + kBasicPartSize, remain));
+ if (startHeader[1] != CalcSum(header, headerSize))
+ return S_FALSE;
+ size_t nameLength = *p++;
+ if ((p - header) + nameLength + 2 > headerSize)
+ return S_FALSE;
+ p = ReadString(p, nameLength, item.Name);
+ }
+ else
+ headerSize = startHeader[0] | ((UInt32)startHeader[1] << 8);
+ p = ReadUInt16(p, item.CRC);
+ if (item.Level != 0)
+ {
+ if (item.Level == 2)
+ {
+ RINOK(CheckReadBytes(header + kBasicPartSize, 2));
+ }
+ if ((size_t)(p - header) + 3 > headerSize)
+ return S_FALSE;
+ item.OsId = *p++;
+ UInt16 nextSize;
+ p = ReadUInt16(p, nextSize);
+ while (nextSize != 0)
+ {
+ if (nextSize < 3)
+ return S_FALSE;
+ if (item.Level == 1)
+ {
+ if (item.PackSize < nextSize)
+ return S_FALSE;
+ item.PackSize -= nextSize;
+ }
+ CExtension ext;
+ RINOK(CheckReadBytes(&ext.Type, 1))
+ nextSize -= 3;
+ ext.Data.SetCapacity(nextSize);
+ RINOK(CheckReadBytes((Byte *)ext.Data, nextSize))
+ item.Extensions.Add(ext);
+ Byte hdr2[2];
+ RINOK(CheckReadBytes(hdr2, 2));
+ ReadUInt16(hdr2, nextSize);
+ }
+ }
+ item.DataPosition = m_Position;
+ filled = true;
+ return S_OK;
+}
+
+HRESULT CInArchive::Skip(UInt64 numBytes)
+{
+ UInt64 newPostion;
+ RINOK(m_Stream->Seek(numBytes, STREAM_SEEK_CUR, &newPostion));
+ m_Position += numBytes;
+ if (m_Position != newPostion)
+ return E_FAIL;
+ return S_OK;
+}
+
+struct COsPair
+{
+ Byte Id;
+ const char *Name;
+};
+
+static COsPair g_OsPairs[] =
+{
+ { 0, "MS-DOS" },
+ { 'M', "MS-DOS" },
+ { '2', "OS/2" },
+ { '9', "OS9" },
+ { 'K', "OS/68K" },
+ { '3', "OS/386" },
+ { 'H', "HUMAN" },
+ { 'U', "UNIX" },
+ { 'C', "CP/M" },
+ { 'F', "FLEX" },
+ { 'm', "Mac" },
+ { 'R', "Runser" },
+ { 'T', "TownsOS" },
+ { 'X', "XOSK" },
+ { 'w', "Windows 95" },
+ { 'W', "Windows NT" },
+ { 'J', "Java VM" }
+};
+
+static const char *kUnknownOS = "Unknown";
+
+static const char *GetOS(Byte osId)
+{
+ for (int i = 0; i < sizeof(g_OsPairs) / sizeof(g_OsPairs[0]); i++)
+ if (g_OsPairs[i].Id == osId)
+ return g_OsPairs[i].Name;
+ return kUnknownOS;
+};
+
+static STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ // { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidCRC, VT_UI4},
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidHostOS, VT_BSTR}
+};
+
+class CCRC
+{
+ UInt16 _value;
+public:
+ static UInt16 Table[256];
+ static void InitTable();
+
+ CCRC(): _value(0){};
+ void Init() { _value = 0; }
+ void Update(const void *data, size_t size);
+ UInt16 GetDigest() const { return _value; }
+};
+
+static const UInt16 kCRCPoly = 0xA001;
+
+UInt16 CCRC::Table[256];
+
+void CCRC::InitTable()
+{
+ for (UInt32 i = 0; i < 256; i++)
+ {
+ UInt32 r = i;
+ for (int j = 0; j < 8; j++)
+ if (r & 1)
+ r = (r >> 1) ^ kCRCPoly;
+ else
+ r >>= 1;
+ CCRC::Table[i] = (UInt16)r;
+ }
+}
+
+class CCRCTableInit
+{
+public:
+ CCRCTableInit() { CCRC::InitTable(); }
+} g_CRCTableInit;
+
+void CCRC::Update(const void *data, size_t size)
+{
+ UInt16 v = _value;
+ const Byte *p = (const Byte *)data;
+ for (; size > 0; size--, p++)
+ v = (UInt16)(Table[((Byte)(v)) ^ *p] ^ (v >> 8));
+ _value = v;
+}
+
+
+class COutStreamWithCRC:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+private:
+ CCRC _crc;
+ CMyComPtr<ISequentialOutStream> _stream;
+public:
+ void Init(ISequentialOutStream *stream)
+ {
+ _stream = stream;
+ _crc.Init();
+ }
+ void ReleaseStream() { _stream.Release(); }
+ UInt32 GetCRC() const { return _crc.GetDigest(); }
+ void InitCRC() { _crc.Init(); }
+
+};
+
+STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize;
+ HRESULT result;
+ if(!_stream)
+ {
+ realProcessedSize = size;
+ result = S_OK;
+ }
+ else
+ result = _stream->Write(data, size, &realProcessedSize);
+ _crc.Update(data, realProcessedSize);
+ if(processedSize != NULL)
+ *processedSize = realProcessedSize;
+ return result;
+}
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CObjectVector<CItemEx> _items;
+ CMyComPtr<IInStream> _stream;
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+ CHandler();
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+CHandler::CHandler() {}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _items.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItemEx &item = _items[index];
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetName(), CP_OEMCP));
+ if (!s.IsEmpty())
+ {
+ if (s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
+ s.Delete(s.Length() - 1);
+ prop = s;
+ }
+ break;
+ }
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidPackSize: prop = item.PackSize; break;
+ case kpidCRC: prop = (UInt32)item.CRC; break;
+ case kpidHostOS: prop = GetOS(item.OsId); break;
+ case kpidMTime:
+ {
+ FILETIME utc;
+ UInt32 unixTime;
+ if (item.GetUnixTime(unixTime))
+ NTime::UnixTimeToFileTime(unixTime, utc);
+ else
+ {
+ FILETIME localFileTime;
+ if (DosTimeToFileTime(item.ModifiedTime, localFileTime))
+ {
+ if (!LocalFileTimeToFileTime(&localFileTime, &utc))
+ utc.dwHighDateTime = utc.dwLowDateTime = 0;
+ }
+ else
+ utc.dwHighDateTime = utc.dwLowDateTime = 0;
+ }
+ prop = utc;
+ break;
+ }
+ // case kpidAttrib: prop = (UInt32)item.Attributes; break;
+ case kpidMethod:
+ {
+ char method2[kMethodIdSize + 1];
+ method2[kMethodIdSize] = 0;
+ memcpy(method2, item.Method, kMethodIdSize);
+ prop = method2;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */, IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ try
+ {
+ _items.Clear();
+ CInArchive archive;
+
+ UInt64 endPos = 0;
+ bool needSetTotal = true;
+
+ if (callback != NULL)
+ {
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
+ }
+
+ RINOK(archive.Open(stream));
+ for (;;)
+ {
+ CItemEx item;
+ bool filled;
+ HRESULT result = archive.GetNextItem(filled, item);
+ if (result == S_FALSE)
+ return S_FALSE;
+ if (result != S_OK)
+ return S_FALSE;
+ if (!filled)
+ break;
+ _items.Add(item);
+ archive.Skip(item.PackSize);
+ if (callback != NULL)
+ {
+ if (needSetTotal)
+ {
+ RINOK(callback->SetTotal(NULL, &endPos));
+ needSetTotal = false;
+ }
+ if (_items.Size() % 100 == 0)
+ {
+ UInt64 numFiles = _items.Size();
+ UInt64 numBytes = item.DataPosition;
+ RINOK(callback->SetCompleted(&numFiles, &numBytes));
+ }
+ }
+ }
+ if (_items.IsEmpty())
+ return S_FALSE;
+
+ _stream = stream;
+ }
+ catch(...)
+ {
+ return S_FALSE;
+ }
+ COM_TRY_END
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _items.Clear();
+ _stream.Release();
+ return S_OK;
+}
+
+
+
+//////////////////////////////////////
+// CHandler::DecompressItems
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (testModeSpec != 0);
+ UInt64 totalUnPacked = 0, totalPacked = 0;
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _items.Size();
+ if(numItems == 0)
+ return S_OK;
+ UInt32 i;
+ for(i = 0; i < numItems; i++)
+ {
+ const CItemEx &item = _items[allFilesMode ? i : indices[i]];
+ totalUnPacked += item.Size;
+ totalPacked += item.PackSize;
+ }
+ extractCallback->SetTotal(totalUnPacked);
+
+ UInt64 currentTotalUnPacked = 0, currentTotalPacked = 0;
+ UInt64 currentItemUnPacked, currentItemPacked;
+
+ NCompress::NLzh::NDecoder::CCoder *lzhDecoderSpec = 0;
+ CMyComPtr<ICompressCoder> lzhDecoder;
+ CMyComPtr<ICompressCoder> lzh1Decoder;
+ CMyComPtr<ICompressCoder> arj2Decoder;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_stream);
+
+ for(i = 0; i < numItems; i++, currentTotalUnPacked += currentItemUnPacked,
+ currentTotalPacked += currentItemPacked)
+ {
+ currentItemUnPacked = 0;
+ currentItemPacked = 0;
+
+ lps->InSize = currentTotalPacked;
+ lps->OutSize = currentTotalUnPacked;
+ RINOK(lps->SetCur());
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode;
+ askMode = testMode ? NExtract::NAskMode::kTest :
+ NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItemEx &item = _items[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (item.IsDir())
+ {
+ // if (!testMode)
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
+ }
+ continue;
+ }
+
+ if (!testMode && (!realOutStream))
+ continue;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ currentItemUnPacked = item.Size;
+ currentItemPacked = item.PackSize;
+
+ {
+ COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->Init(realOutStream);
+ realOutStream.Release();
+
+ UInt64 pos;
+ _stream->Seek(item.DataPosition, STREAM_SEEK_SET, &pos);
+
+ streamSpec->Init(item.PackSize);
+
+ HRESULT result = S_OK;
+ Int32 opRes = NExtract::NOperationResult::kOK;
+
+ if (item.IsCopyMethod())
+ {
+ result = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+ if (result == S_OK && copyCoderSpec->TotalSize != item.PackSize)
+ result = S_FALSE;
+ }
+ else if (item.IsLh4GroupMethod())
+ {
+ if (!lzhDecoder)
+ {
+ lzhDecoderSpec = new NCompress::NLzh::NDecoder::CCoder;
+ lzhDecoder = lzhDecoderSpec;
+ }
+ lzhDecoderSpec->SetDictionary(item.GetNumDictBits());
+ result = lzhDecoder->Code(inStream, outStream, NULL, &currentItemUnPacked, progress);
+ }
+ /*
+ else if (item.IsLh1GroupMethod())
+ {
+ if (!lzh1Decoder)
+ {
+ lzh1DecoderSpec = new NCompress::NLzh1::NDecoder::CCoder;
+ lzh1Decoder = lzh1DecoderSpec;
+ }
+ lzh1DecoderSpec->SetDictionary(item.GetNumDictBits());
+ result = lzh1Decoder->Code(inStream, outStream, NULL, &currentItemUnPacked, progress);
+ }
+ */
+ else
+ opRes = NExtract::NOperationResult::kUnSupportedMethod;
+
+ if (opRes == NExtract::NOperationResult::kOK)
+ {
+ if (result == S_FALSE)
+ opRes = NExtract::NOperationResult::kDataError;
+ else
+ {
+ RINOK(result);
+ if (outStreamSpec->GetCRC() != item.CRC)
+ opRes = NExtract::NOperationResult::kCRCError;
+ }
+ }
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Lzh", L"lzh lha", 0, 6, { '-', 'l' }, 2, false, CreateArc, 0 };
+
+REGISTER_ARC(Lzh)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/LzmaHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/LzmaHandler.cpp
new file mode 100644
index 000000000..5dd0aac7e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/LzmaHandler.cpp
@@ -0,0 +1,436 @@
+// LzmaHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/CreateCoder.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/LzmaDecoder.h"
+
+#include "Common/DummyOutStream.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NLzma {
+
+static bool CheckDicSize(const Byte *p)
+{
+ UInt32 dicSize = GetUi32(p);
+ for (int i = 1; i <= 30; i++)
+ if (dicSize == ((UInt32)2 << i) || dicSize == ((UInt32)3 << i))
+ return true;
+ return (dicSize == 0xFFFFFFFF);
+}
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMethod, VT_BSTR}
+};
+
+struct CHeader
+{
+ UInt64 Size;
+ Byte FilterID;
+ Byte LzmaProps[5];
+
+ UInt32 GetDicSize() const { return GetUi32(LzmaProps + 1); }
+ bool HasSize() const { return (Size != (UInt64)(Int64)-1); }
+ bool Parse(const Byte *buf, bool isThereFilter);
+};
+
+bool CHeader::Parse(const Byte *buf, bool isThereFilter)
+{
+ FilterID = 0;
+ if (isThereFilter)
+ FilterID = buf[0];
+ const Byte *sig = buf + (isThereFilter ? 1 : 0);
+ for (int i = 0; i < 5; i++)
+ LzmaProps[i] = sig[i];
+ Size = GetUi64(sig + 5);
+ return
+ LzmaProps[0] < 5 * 5 * 9 &&
+ FilterID < 2 &&
+ (!HasSize() || Size < ((UInt64)1 << 56)) &&
+ CheckDicSize(LzmaProps + 1);
+}
+
+class CDecoder
+{
+ NCompress::NLzma::CDecoder *_lzmaDecoderSpec;
+ CMyComPtr<ICompressCoder> _lzmaDecoder;
+ CMyComPtr<ISequentialOutStream> _bcjStream;
+public:
+ ~CDecoder();
+ HRESULT Create(DECL_EXTERNAL_CODECS_LOC_VARS
+ bool filtered, ISequentialInStream *inStream);
+
+ HRESULT Code(const CHeader &header, ISequentialOutStream *outStream, ICompressProgressInfo *progress);
+
+ UInt64 GetInputProcessedSize() const { return _lzmaDecoderSpec->GetInputProcessedSize(); }
+
+ void ReleaseInStream() { if (_lzmaDecoder) _lzmaDecoderSpec->ReleaseInStream(); }
+
+ HRESULT ReadInput(Byte *data, UInt32 size, UInt32 *processedSize)
+ { return _lzmaDecoderSpec->ReadFromInputStream(data, size, processedSize); }
+};
+
+static const UInt64 k_BCJ = 0x03030103;
+
+HRESULT CDecoder::Create(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ bool filteredMode, ISequentialInStream *inStream)
+{
+ if (!_lzmaDecoder)
+ {
+ _lzmaDecoderSpec = new NCompress::NLzma::CDecoder;
+ _lzmaDecoder = _lzmaDecoderSpec;
+ }
+
+ if (filteredMode)
+ {
+ if (!_bcjStream)
+ {
+ CMyComPtr<ICompressCoder> coder;
+ RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS k_BCJ, coder, false));
+ if (!coder)
+ return E_NOTIMPL;
+ coder.QueryInterface(IID_ISequentialOutStream, &_bcjStream);
+ if (!_bcjStream)
+ return E_NOTIMPL;
+ }
+ }
+
+ return _lzmaDecoderSpec->SetInStream(inStream);
+}
+
+CDecoder::~CDecoder()
+{
+ ReleaseInStream();
+}
+
+HRESULT CDecoder::Code(const CHeader &header, ISequentialOutStream *outStream,
+ ICompressProgressInfo *progress)
+{
+ if (header.FilterID > 1)
+ return E_NOTIMPL;
+
+ {
+ CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
+ _lzmaDecoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
+ if (!setDecoderProperties)
+ return E_NOTIMPL;
+ RINOK(setDecoderProperties->SetDecoderProperties2(header.LzmaProps, 5));
+ }
+
+ CMyComPtr<ICompressSetOutStream> setOutStream;
+
+ bool filteredMode = (header.FilterID == 1);
+
+ if (filteredMode)
+ {
+ _bcjStream.QueryInterface(IID_ICompressSetOutStream, &setOutStream);
+ if (!setOutStream)
+ return E_NOTIMPL;
+ RINOK(setOutStream->SetOutStream(outStream));
+ outStream = _bcjStream;
+ }
+
+ const UInt64 *Size = header.HasSize() ? &header.Size : NULL;
+ HRESULT res = _lzmaDecoderSpec->CodeResume(outStream, Size, progress);
+
+ if (filteredMode)
+ {
+ CMyComPtr<IOutStreamFlush> flush;
+ _bcjStream.QueryInterface(IID_IOutStreamFlush, &flush);
+ if (flush)
+ {
+ HRESULT res2 = flush->Flush();
+ if (res == S_OK)
+ res = res2;
+ }
+ HRESULT res2 = setOutStream->ReleaseOutStream();
+ if (res == S_OK)
+ res = res2;
+ }
+ RINOK(res);
+
+ return S_OK;
+}
+
+
+class CHandler:
+ public IInArchive,
+ public IArchiveOpenSeq,
+ PUBLIC_ISetCompressCodecsInfo
+ public CMyUnknownImp
+{
+ CHeader _header;
+ bool _lzma86;
+ UInt64 _startPosition;
+ UInt64 _packSize;
+ bool _packSizeDefined;
+ CMyComPtr<IInStream> _stream;
+ CMyComPtr<ISequentialInStream> _seqStream;
+
+ DECL_EXTERNAL_CODECS_VARS
+ DECL_ISetCompressCodecsInfo
+
+public:
+ MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_ENTRY(IInArchive)
+ MY_QUERYINTERFACE_ENTRY(IArchiveOpenSeq)
+ QUERY_ENTRY_ISetCompressCodecsInfo
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ INTERFACE_IInArchive(;)
+ STDMETHOD(OpenSeq)(ISequentialInStream *stream);
+
+ CHandler(bool lzma86) { _lzma86 = lzma86; }
+
+ unsigned GetHeaderSize() const { return 5 + 8 + (_lzma86 ? 1 : 0); }
+
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO_Table
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPhySize: if (_packSizeDefined) prop = _packSize; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+static void DictSizeToString(UInt32 value, char *s)
+{
+ for (int i = 0; i <= 31; i++)
+ if ((UInt32(1) << i) == value)
+ {
+ ::ConvertUInt32ToString(i, s);
+ return;
+ }
+ char c = 'b';
+ if ((value & ((1 << 20) - 1)) == 0)
+ {
+ value >>= 20;
+ c = 'm';
+ }
+ else if ((value & ((1 << 10) - 1)) == 0)
+ {
+ value >>= 10;
+ c = 'k';
+ }
+ ::ConvertUInt32ToString(value, s);
+ int p = MyStringLen(s);
+ s[p++] = c;
+ s[p++] = '\0';
+}
+
+static void MyStrCat(char *d, const char *s)
+{
+ MyStringCopy(d + MyStringLen(d), s);
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidSize: if (_stream && _header.HasSize()) prop = _header.Size; break;
+ case kpidPackSize: if (_packSizeDefined) prop = _packSize; break;
+ case kpidMethod:
+ if (_stream)
+ {
+ char s[64];
+ s[0] = '\0';
+ if (_header.FilterID != 0)
+ MyStrCat(s, "BCJ ");
+ MyStrCat(s, "LZMA:");
+ DictSizeToString(_header.GetDicSize(), s + MyStringLen(s));
+ prop = s;
+ }
+ break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCallback *)
+{
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &_startPosition));
+
+ const UInt32 kBufSize = 1 + 5 + 8 + 1;
+ Byte buf[kBufSize];
+
+ RINOK(ReadStream_FALSE(inStream, buf, kBufSize));
+
+ if (!_header.Parse(buf, _lzma86))
+ return S_FALSE;
+ const Byte *start = buf + GetHeaderSize();
+ if (start[0] != 0)
+ return S_FALSE;
+
+ UInt64 endPos;
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos));
+ _packSize = endPos - _startPosition;
+ _packSizeDefined = true;
+
+ _stream = inStream;
+ _seqStream = inStream;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
+{
+ Close();
+ _seqStream = stream;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _packSizeDefined = false;
+ _stream.Release();
+ _seqStream.Release();
+ return S_OK;
+}
+
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == (UInt32)-1);
+ if (!allFilesMode)
+ {
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1 || indices[0] != 0)
+ return E_INVALIDARG;
+ }
+
+ bool testMode = (_aTestMode != 0);
+ if (_stream)
+ extractCallback->SetTotal(_packSize);
+
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
+ if (!testMode && !realOutStream)
+ return S_OK;
+
+ extractCallback->PrepareOperation(askMode);
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->SetStream(realOutStream);
+ outStreamSpec->Init();
+ realOutStream.Release();
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, true);
+
+ if (_stream)
+ {
+ RINOK(_stream->Seek(_startPosition, STREAM_SEEK_SET, NULL));
+ }
+
+ CDecoder decoder;
+ HRESULT result = decoder.Create(
+ EXTERNAL_CODECS_VARS
+ _lzma86, _seqStream);
+ RINOK(result);
+
+ Int32 opRes = NArchive::NExtract::NOperationResult::kOK;
+ bool firstItem = true;
+
+ for (;;)
+ {
+ lps->OutSize = outStreamSpec->GetSize();
+ lps->InSize = _packSize = decoder.GetInputProcessedSize();
+ _packSizeDefined = true;
+ RINOK(lps->SetCur());
+
+ CHeader st;
+
+ const UInt32 kBufSize = 1 + 5 + 8;
+ Byte buf[kBufSize];
+ const UInt32 headerSize = GetHeaderSize();
+ UInt32 processed;
+ RINOK(decoder.ReadInput(buf, headerSize, &processed));
+ if (processed != headerSize)
+ break;
+
+ if (!st.Parse(buf, _lzma86))
+ break;
+ firstItem = false;
+
+ result = decoder.Code(st, outStream, progress);
+ if (result == E_NOTIMPL)
+ {
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ break;
+ }
+ if (result == S_FALSE)
+ {
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ break;
+ }
+ RINOK(result);
+ }
+ if (firstItem)
+ return E_FAIL;
+ outStream.Release();
+ return extractCallback->SetOperationResult(opRes);
+ COM_TRY_END
+}
+
+IMPL_ISetCompressCodecsInfo
+
+static IInArchive *CreateArc() { return new CHandler(false); }
+static IInArchive *CreateArc86() { return new CHandler(true); }
+
+namespace NLzmaAr {
+
+static CArcInfo g_ArcInfo =
+ { L"lzma", L"lzma", 0, 0xA, { 0 }, 0, true, CreateArc, NULL };
+REGISTER_ARC(Lzma)
+
+}
+
+namespace NLzma86Ar {
+
+static CArcInfo g_ArcInfo =
+ { L"lzma86", L"lzma86", 0, 0xB, { 0 }, 0, true, CreateArc86, NULL };
+REGISTER_ARC(Lzma86)
+
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MachoHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MachoHandler.cpp
new file mode 100644
index 000000000..342a8e761
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MachoHandler.cpp
@@ -0,0 +1,468 @@
+// MachoHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+
+#include "Windows/PropVariantUtils.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+static UInt32 Get32(const Byte *p, int be) { if (be) return GetBe32(p); return GetUi32(p); }
+static UInt64 Get64(const Byte *p, int be) { if (be) return GetBe64(p); return GetUi64(p); }
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NMacho {
+
+#define MACH_ARCH_ABI64 (1 << 24)
+#define MACH_MACHINE_386 7
+#define MACH_MACHINE_ARM 12
+#define MACH_MACHINE_SPARC 14
+#define MACH_MACHINE_PPC 18
+
+#define MACH_MACHINE_PPC64 (MACH_ARCH_ABI64 | MACH_MACHINE_PPC)
+#define MACH_MACHINE_AMD64 (MACH_ARCH_ABI64 | MACH_MACHINE_386)
+
+#define MACH_CMD_SEGMENT_32 1
+#define MACH_CMD_SEGMENT_64 0x19
+
+#define MACH_SECT_TYPE_MASK 0x000000FF
+#define MACH_SECT_ATTR_MASK 0xFFFFFF00
+
+#define MACH_SECT_ATTR_ZEROFILL 1
+
+const char *g_SectTypes[] =
+{
+ "REGULAR",
+ "ZEROFILL",
+ "CSTRINGS",
+ "4BYTE_LITERALS",
+ "8BYTE_LITERALS",
+ "LITERAL_POINTERS",
+ "NON_LAZY_SYMBOL_POINTERS",
+ "LAZY_SYMBOL_POINTERS",
+ "SYMBOL_STUBS",
+ "MOD_INIT_FUNC_POINTERS",
+ "MOD_TERM_FUNC_POINTERS",
+ "COALESCED",
+ "GB_ZEROFILL",
+ "INTERPOSING",
+ "16BYTE_LITERALS"
+};
+
+const char *g_FileTypes[] =
+{
+ "0",
+ "OBJECT",
+ "EXECUTE",
+ "FVMLIB",
+ "CORE",
+ "PRELOAD",
+ "DYLIB",
+ "DYLINKER",
+ "BUNDLE",
+ "DYLIB_STUB",
+ "DSYM"
+};
+
+static const CUInt32PCharPair g_Flags[] =
+{
+ { (UInt32)1 << 31, "PURE_INSTRUCTIONS" },
+ { 1 << 30, "NO_TOC" },
+ { 1 << 29, "STRIP_STATIC_SYMS" },
+ { 1 << 28, "NO_DEAD_STRIP" },
+ { 1 << 27, "LIVE_SUPPORT" },
+ { 1 << 26, "SELF_MODIFYING_CODE" },
+ { 1 << 25, "DEBUG" },
+ { 1 << 10, "SOME_INSTRUCTIONS" },
+ { 1 << 9, "EXT_RELOC" },
+ { 1 << 8, "LOC_RELOC" }
+};
+
+static const CUInt32PCharPair g_MachinePairs[] =
+{
+ { MACH_MACHINE_386, "x86" },
+ { MACH_MACHINE_ARM, "ARM" },
+ { MACH_MACHINE_SPARC, "SPARC" },
+ { MACH_MACHINE_PPC, "PowerPC" },
+ { MACH_MACHINE_PPC64, "PowerPC 64-bit" },
+ { MACH_MACHINE_AMD64, "x64" }
+};
+
+static const int kNameSize = 16;
+
+struct CSegment
+{
+ char Name[kNameSize];
+};
+
+struct CSection
+{
+ char Name[kNameSize];
+ char SegName[kNameSize];
+ UInt64 Va;
+ UInt64 Size;
+ UInt32 Pa;
+ UInt32 Flags;
+ int SegmentIndex;
+ UInt64 GetPackSize() const { return Flags == MACH_SECT_ATTR_ZEROFILL ? 0 : Size; }
+};
+
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+ CObjectVector<CSegment> _segments;
+ CObjectVector<CSection> _sections;
+ bool _mode64;
+ bool _be;
+ UInt32 _machine;
+ UInt32 _type;
+ UInt32 _headersSize;
+ UInt64 _totalSize;
+ HRESULT Open2(ISequentialInStream *stream);
+ bool Parse(const Byte *buf, UInt32 size);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+bool CHandler::Parse(const Byte *buf, UInt32 size)
+{
+ bool mode64 = _mode64;
+ bool be = _be;
+
+ const Byte *bufStart = buf;
+ bool reduceCommands = false;
+ if (size < 512)
+ return false;
+
+ _machine = Get32(buf + 4, be);
+ _type = Get32(buf + 0xC, be);
+
+ UInt32 numCommands = Get32(buf + 0x10, be);
+ UInt32 commandsSize = Get32(buf + 0x14, be);
+ if (commandsSize > size)
+ return false;
+
+ if (commandsSize > (1 << 24) || numCommands > (1 << 18))
+ return false;
+
+ if (numCommands > 16)
+ {
+ reduceCommands = true;
+ numCommands = 16;
+ }
+
+ _headersSize = 0;
+
+ buf += 0x1C;
+ size -= 0x1C;
+
+ if (mode64)
+ {
+ buf += 4;
+ size -= 4;
+ }
+
+ _totalSize = (UInt32)(buf - bufStart);
+ if (commandsSize < size)
+ size = commandsSize;
+
+ for (UInt32 cmdIndex = 0; cmdIndex < numCommands; cmdIndex++)
+ {
+ if (size < 8)
+ return false;
+ UInt32 cmd = Get32(buf, be);
+ UInt32 cmdSize = Get32(buf + 4, be);
+ if (size < cmdSize)
+ return false;
+ if (cmd == MACH_CMD_SEGMENT_32 || cmd == MACH_CMD_SEGMENT_64)
+ {
+ UInt32 offs = (cmd == MACH_CMD_SEGMENT_64) ? 0x48 : 0x38;
+ if (cmdSize < offs)
+ break;
+
+ {
+ UInt64 vmAddr, vmSize, phAddr, phSize;
+ if (cmd == MACH_CMD_SEGMENT_64)
+ {
+ vmAddr = Get64(buf + 0x18, be);
+ vmSize = Get64(buf + 0x20, be);
+ phAddr = Get64(buf + 0x28, be);
+ phSize = Get64(buf + 0x30, be);
+ }
+ else
+ {
+ vmAddr = Get32(buf + 0x18, be);
+ vmSize = Get32(buf + 0x1C, be);
+ phAddr = Get32(buf + 0x20, be);
+ phSize = Get32(buf + 0x24, be);
+ }
+ {
+ UInt64 totalSize = phAddr + phSize;
+ if (totalSize > _totalSize)
+ _totalSize = totalSize;
+ }
+ }
+
+ CSegment seg;
+ memcpy(seg.Name, buf + 8, kNameSize);
+ _segments.Add(seg);
+
+ UInt32 numSections = Get32(buf + offs - 8, be);
+ if (numSections > (1 << 8))
+ return false;
+
+ while (numSections-- != 0)
+ {
+ CSection section;
+ UInt32 headerSize = (cmd == MACH_CMD_SEGMENT_64) ? 0x50 : 0x44;
+ const Byte *p = buf + offs;
+ if (cmdSize - offs < headerSize)
+ break;
+ if (cmd == MACH_CMD_SEGMENT_64)
+ {
+ section.Va = Get64(p + 0x20, be);
+ section.Size = Get64(p + 0x28, be);
+ section.Pa = Get32(p + 0x30, be);
+ section.Flags = Get32(p + 0x40, be);
+ }
+ else
+ {
+ section.Va = Get32(p + 0x20, be);
+ section.Size = Get32(p + 0x24, be);
+ section.Pa = Get32(p + 0x28, be);
+ section.Flags = Get32(p + 0x38, be);
+ }
+ memcpy(section.Name, p, kNameSize);
+ memcpy(section.SegName, p + kNameSize, kNameSize);
+ section.SegmentIndex = _segments.Size() - 1;
+ _sections.Add(section);
+ offs += headerSize;
+ }
+ if (offs != cmdSize)
+ return false;
+ }
+ buf += cmdSize;
+ size -= cmdSize;
+ }
+ _headersSize = (UInt32)(buf - bufStart);
+ return reduceCommands || (size == 0);
+}
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidCpu, VT_BSTR},
+ { NULL, kpidBit64, VT_BOOL},
+ { NULL, kpidBigEndian, VT_BOOL},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidPhySize, VT_UI8},
+ { NULL, kpidHeadersSize, VT_UI4}
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidOffset, VT_UI8},
+ { NULL, kpidVa, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidCpu: PAIR_TO_PROP(g_MachinePairs, _machine, prop); break;
+ case kpidCharacts: TYPE_TO_PROP(g_FileTypes, _type, prop); break;
+ case kpidPhySize: prop = _totalSize; break;
+ case kpidHeadersSize: prop = _headersSize; break;
+ case kpidBit64: if (_mode64) prop = _mode64; break;
+ case kpidBigEndian: if (_be) prop = _be; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+static AString GetName(const char *name)
+{
+ char res[kNameSize + 1];
+ memcpy(res, name, kNameSize);
+ res[kNameSize] = 0;
+ return res;
+}
+
+static AString SectFlagsToString(UInt32 flags)
+{
+ AString res = TypeToString(g_SectTypes, sizeof(g_SectTypes) / sizeof(g_SectTypes[0]),
+ flags & MACH_SECT_TYPE_MASK);
+ AString s = FlagsToString(g_Flags, sizeof(g_Flags) / sizeof(g_Flags[0]),
+ flags & MACH_SECT_ATTR_MASK);
+ if (!s.IsEmpty())
+ {
+ res += ' ';
+ res += s;
+ }
+ return res;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ const CSection &item = _sections[index];
+ switch(propID)
+ {
+ case kpidPath: StringToProp(GetName(_segments[item.SegmentIndex].Name) + GetName(item.Name), prop); break;
+ case kpidSize: prop = (UInt64)item.Size; break;
+ case kpidPackSize: prop = (UInt64)item.GetPackSize(); break;
+ case kpidCharacts: StringToProp(SectFlagsToString(item.Flags), prop); break;
+ case kpidOffset: prop = item.Pa; break;
+ case kpidVa: prop = item.Va; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::Open2(ISequentialInStream *stream)
+{
+ const UInt32 kBufSize = 1 << 18;
+ const UInt32 kSigSize = 4;
+
+ CByteBuffer buffer;
+ buffer.SetCapacity(kBufSize);
+ Byte *buf = buffer;
+
+ size_t processed = kSigSize;
+ RINOK(ReadStream_FALSE(stream, buf, processed));
+ UInt32 sig = GetUi32(buf);
+ bool be, mode64;
+ switch(sig)
+ {
+ case 0xCEFAEDFE: be = true; mode64 = false; break;
+ case 0xCFFAEDFE: be = true; mode64 = true; break;
+ case 0xFEEDFACE: be = false; mode64 = false; break;
+ case 0xFEEDFACF: be = false; mode64 = true; break;
+ default: return S_FALSE;
+ }
+ processed = kBufSize - kSigSize;
+ RINOK(ReadStream(stream, buf + kSigSize, &processed));
+ _mode64 = mode64;
+ _be = be;
+ return Parse(buf, (UInt32)processed + kSigSize) ? S_OK : S_FALSE;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ RINOK(Open2(inStream));
+ _inStream = inStream;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _sections.Clear();
+ _segments.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _sections.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _sections.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _sections[allFilesMode ? i : indices[i]].GetPackSize();
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+ const CSection &item = _sections[index];
+ currentItemSize = item.GetPackSize();
+
+ CMyComPtr<ISequentialOutStream> outStream;
+ RINOK(extractCallback->GetStream(index, &outStream, askMode));
+ if (!testMode && !outStream)
+ continue;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(_inStream->Seek(item.Pa, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(currentItemSize);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == currentItemSize ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"MachO", L"", 0, 0xDF, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Macho)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MbrHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MbrHandler.cpp
new file mode 100644
index 000000000..47b18f15e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MbrHandler.cpp
@@ -0,0 +1,508 @@
+// MbrHandler.cpp
+
+#include "StdAfx.h"
+
+// #define SHOW_DEBUG_INFO
+
+#ifdef SHOW_DEBUG_INFO
+#include <stdio.h>
+#endif
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+#include "Common/MyString.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#ifdef SHOW_DEBUG_INFO
+#define PRF(x) x
+#else
+#define PRF(x)
+#endif
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NMbr {
+
+struct CChs
+{
+ Byte Head;
+ Byte SectCyl;
+ Byte Cyl8;
+
+ UInt32 GetSector() const { return SectCyl & 0x3F; }
+ UInt32 GetCyl() const { return ((UInt32)SectCyl >> 6 << 8) | Cyl8; }
+ void ToString(NCOM::CPropVariant &prop) const;
+
+ void Parse(const Byte *p)
+ {
+ Head = p[0];
+ SectCyl = p[1];
+ Cyl8 = p[2];
+ }
+ bool Check() const { return GetSector() > 0; }
+};
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+static int CompareChs(const CChs &c1, const CChs &c2)
+{
+ RINOZ(MyCompare(c1.GetCyl(), c2.GetCyl()));
+ RINOZ(MyCompare(c1.Head, c2.Head));
+ return MyCompare(c1.GetSector(), c2.GetSector());
+}
+
+static void AddUIntToString(UInt32 val, AString &res)
+{
+ char s[16];
+ ConvertUInt32ToString(val, s);
+ res += s;
+}
+
+void CChs::ToString(NCOM::CPropVariant &prop) const
+{
+ AString s;
+ AddUIntToString(GetCyl(), s);
+ s += '-';
+ AddUIntToString(Head, s);
+ s += '-';
+ AddUIntToString(GetSector(), s);
+ prop = s;
+}
+
+struct CPartition
+{
+ Byte Status;
+ CChs BeginChs;
+ Byte Type;
+ CChs EndChs;
+ UInt32 Lba;
+ UInt32 NumBlocks;
+
+ CPartition() { memset (this, 0, sizeof(*this)); }
+
+ bool IsEmpty() const { return Type == 0; }
+ bool IsExtended() const { return Type == 5 || Type == 0xF; }
+ UInt32 GetLimit() const { return Lba + NumBlocks; }
+ // bool IsActive() const { return Status == 0x80; }
+ UInt64 GetPos() const { return (UInt64)Lba * 512; }
+ UInt64 GetSize() const { return (UInt64)NumBlocks * 512; }
+
+ bool CheckLbaLimits() const { return (UInt32)0xFFFFFFFF - Lba >= NumBlocks; }
+ bool Parse(const Byte *p)
+ {
+ Status = p[0];
+ BeginChs.Parse(p + 1);
+ Type = p[4];
+ EndChs.Parse(p + 5);
+ Lba = GetUi32(p + 8);
+ NumBlocks = GetUi32(p + 12);
+ if (Type == 0)
+ return true;
+ if (Status != 0 && Status != 0x80)
+ return false;
+ return
+ BeginChs.Check() &&
+ EndChs.Check() &&
+ CompareChs(BeginChs, EndChs) <= 0 &&
+ NumBlocks > 0 &&
+ CheckLbaLimits();
+ }
+
+ #ifdef SHOW_DEBUG_INFO
+ void Print() const
+ {
+ NCOM::CPropVariant prop, prop2;
+ BeginChs.ToString(prop);
+ EndChs.ToString(prop2);
+ printf(" %2x %2x %8X %8X %12S %12S", (int)Status, (int)Type, Lba, NumBlocks, prop.bstrVal, prop2.bstrVal);
+ }
+ #endif
+};
+
+struct CPartType
+{
+ UInt32 Id;
+ const char *Ext;
+ const char *Name;
+};
+
+static const char *kFat = "fat";
+
+static const CPartType kPartTypes[] =
+{
+ { 0x01, kFat, "FAT12" },
+ { 0x04, kFat, "FAT16 DOS 3.0+" },
+ { 0x05, 0, "Extended" },
+ { 0x06, kFat, "FAT16 DOS 3.31+" },
+ { 0x07, "ntfs", "NTFS" },
+ { 0x0B, kFat, "FAT32" },
+ { 0x0C, kFat, "FAT32-LBA" },
+ { 0x0E, kFat, "FAT16-LBA" },
+ { 0x0F, 0, "Extended-LBA" },
+ { 0x11, kFat, "FAT12-Hidden" },
+ { 0x14, kFat, "FAT16-Hidden < 32 MB" },
+ { 0x16, kFat, "FAT16-Hidden >= 32 MB" },
+ { 0x1B, kFat, "FAT32-Hidden" },
+ { 0x1C, kFat, "FAT32-LBA-Hidden" },
+ { 0x1E, kFat, "FAT16-LBA-WIN95-Hidden" },
+ { 0x82, 0, "Solaris x86 / Linux swap" },
+ { 0x83, 0, "Linux" },
+ { 0xBE, 0, "Solaris 8 boot" },
+ { 0xBF, 0, "New Solaris x86" },
+ { 0xC2, 0, "Linux-Hidden" },
+ { 0xC3, 0, "Linux swap-Hidden" },
+ { 0xEE, 0, "EFI-MBR" },
+ { 0xEE, 0, "EFI" }
+};
+
+static int FindPartType(UInt32 type)
+{
+ for (int i = 0; i < sizeof(kPartTypes) / sizeof(kPartTypes[0]); i++)
+ if (kPartTypes[i].Id == type)
+ return i;
+ return -1;
+}
+
+struct CItem
+{
+ bool IsReal;
+ bool IsPrim;
+ UInt64 Size;
+ CPartition Part;
+};
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _stream;
+ CObjectVector<CItem> _items;
+ UInt64 _totalSize;
+ CByteBuffer _buffer;
+
+ HRESULT ReadTables(IInStream *stream, UInt32 baseLba, UInt32 lba, int level);
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+HRESULT CHandler::ReadTables(IInStream *stream, UInt32 baseLba, UInt32 lba, int level)
+{
+ if (level >= 128 || _items.Size() >= 128)
+ return S_FALSE;
+
+ const int kNumHeaderParts = 4;
+ CPartition parts[kNumHeaderParts];
+
+ {
+ const UInt32 kSectorSize = 512;
+ _buffer.SetCapacity(kSectorSize);
+ Byte *buf = _buffer;
+ UInt64 newPos = (UInt64)lba << 9;
+ if (newPos + 512 > _totalSize)
+ return S_FALSE;
+ RINOK(stream->Seek(newPos, STREAM_SEEK_SET, NULL));
+ RINOK(ReadStream_FALSE(stream, buf, kSectorSize));
+
+ if (buf[0x1FE] != 0x55 || buf[0x1FF] != 0xAA)
+ return S_FALSE;
+
+ for (int i = 0; i < kNumHeaderParts; i++)
+ if (!parts[i].Parse(buf + 0x1BE + 16 * i))
+ return S_FALSE;
+ }
+
+ PRF(printf("\n# %8X", lba));
+
+ UInt32 limLba = lba + 1;
+ if (limLba == 0)
+ return S_FALSE;
+
+ for (int i = 0; i < kNumHeaderParts; i++)
+ {
+ CPartition &part = parts[i];
+
+ if (part.IsEmpty())
+ continue;
+ PRF(printf("\n %2d ", (int)level));
+ #ifdef SHOW_DEBUG_INFO
+ part.Print();
+ #endif
+
+ int numItems = _items.Size();
+ UInt32 newLba = lba + part.Lba;
+
+ if (part.IsExtended())
+ {
+ // if (part.Type == 5) // Check it!
+ newLba = baseLba + part.Lba;
+ if (newLba < limLba)
+ return S_FALSE;
+ HRESULT res = ReadTables(stream, level < 1 ? newLba : baseLba, newLba, level + 1);
+ if (res != S_FALSE && res != S_OK)
+ return res;
+ }
+ if (newLba < limLba)
+ return S_FALSE;
+ part.Lba = newLba;
+ if (!part.CheckLbaLimits())
+ return S_FALSE;
+
+ CItem n;
+ n.Part = part;
+ bool addItem = false;
+ if (numItems == _items.Size())
+ {
+ n.IsPrim = (level == 0);
+ n.IsReal = true;
+ addItem = true;
+ }
+ else
+ {
+ const CItem &back = _items.Back();
+ UInt32 backLimit = back.Part.GetLimit();
+ UInt32 partLimit = part.GetLimit();
+ if (backLimit < partLimit)
+ {
+ n.IsReal = false;
+ n.Part.Lba = backLimit;
+ n.Part.NumBlocks = partLimit - backLimit;
+ addItem = true;
+ }
+ }
+ if (addItem)
+ {
+ if (n.Part.GetLimit() < limLba)
+ return S_FALSE;
+ limLba = n.Part.GetLimit();
+ n.Size = n.Part.GetSize();
+ _items.Add(n);
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &_totalSize));
+ RINOK(ReadTables(stream, 0, 0, 0));
+ if (_items.IsEmpty())
+ return S_FALSE;
+ UInt32 lbaLimit = _items.Back().Part.GetLimit();
+ UInt64 lim = (UInt64)lbaLimit << 9;
+ if (lim < _totalSize)
+ {
+ CItem n;
+ n.Part.Lba = lbaLimit;
+ n.Size = _totalSize - lim;
+ n.IsReal = false;
+ _items.Add(n);
+ }
+ _stream = stream;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _items.Clear();
+ _stream.Release();
+ return S_OK;
+}
+
+enum
+{
+ kpidPrimary = kpidUserDefined,
+ kpidBegChs,
+ kpidEndChs,
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidFileSystem, VT_BSTR},
+ { NULL, kpidOffset, VT_UI8},
+ { L"Primary", kpidPrimary, VT_BOOL},
+ { L"Begin CHS", kpidBegChs, VT_BSTR},
+ { L"End CHS", kpidEndChs, VT_BSTR}
+};
+
+IMP_IInArchive_Props_WITH_NAME
+IMP_IInArchive_ArcProps_NO_Table
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMainSubfile:
+ {
+ int mainIndex = -1;
+ for (int i = 0; i < _items.Size(); i++)
+ if (_items[i].IsReal)
+ {
+ if (mainIndex >= 0)
+ {
+ mainIndex = -1;
+ break;
+ }
+ mainIndex = i;
+ }
+ if (mainIndex >= 0)
+ prop = (UInt32)mainIndex;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _items.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+
+ const CItem &item = _items[index];
+ const CPartition &part = item.Part;
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ AString s;
+ AddUIntToString(index, s);
+ if (item.IsReal)
+ {
+ int typeIndex = FindPartType(part.Type);
+ s += '.';
+ const char *ext = "img";
+ if (typeIndex >= 0 && kPartTypes[typeIndex].Ext != 0)
+ ext = kPartTypes[typeIndex].Ext;
+ s += ext;
+ }
+ prop = s;
+ break;
+ }
+ case kpidFileSystem:
+ if (item.IsReal)
+ {
+ char s[32];
+ ConvertUInt32ToString(part.Type, s);
+ const char *res = s;
+ int typeIndex = FindPartType(part.Type);
+ if (typeIndex >= 0 && kPartTypes[typeIndex].Name)
+ res = kPartTypes[typeIndex].Name;
+ prop = res;
+ }
+ break;
+ case kpidSize: prop = item.Size; break;;
+ case kpidPackSize: prop = item.Size; break;
+ case kpidOffset: prop = part.GetPos(); break;
+ case kpidPrimary: if (item.IsReal) prop = item.IsPrim; break;
+ case kpidBegChs: if (item.IsReal) part.BeginChs.ToString(prop); break;
+ case kpidEndChs: if (item.IsReal) part.EndChs.ToString(prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _items[allFilesMode ? i : indices[i]].Size;
+ extractCallback->SetTotal(totalSize);
+
+ totalSize = 0;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_stream);
+
+ for (i = 0; i < numItems; i++)
+ {
+ lps->InSize = totalSize;
+ lps->OutSize = totalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> outStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _items[index];
+ const CPartition &part = item.Part;
+ RINOK(extractCallback->GetStream(index, &outStream, askMode));
+ totalSize += item.Size;
+ if (!testMode && (!outStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ RINOK(_stream->Seek(part.GetPos(), STREAM_SEEK_SET, NULL));
+ streamSpec->Init(item.Size);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == item.Size ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ const CItem &item = _items[index];
+ return CreateLimitedInStream(_stream, item.Part.GetPos(), item.Size, stream);
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"MBR", L"mbr", 0, 0xDB, { 1, 1, 0 }, 3, false, CreateArc, 0 };
+
+REGISTER_ARC(Mbr)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MubHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MubHandler.cpp
new file mode 100644
index 000000000..f099aad26
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/MubHandler.cpp
@@ -0,0 +1,267 @@
+// MubHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#define Get32(p) GetBe32(p)
+
+namespace NArchive {
+namespace NMub {
+
+struct CItem
+{
+ UInt32 Type;
+ UInt32 SubType;
+ UInt64 Offset;
+ UInt64 Size;
+ UInt32 Align;
+ bool IsTail;
+};
+
+const UInt32 kNumFilesMax = 10;
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ UInt64 _startPos;
+ CMyComPtr<IInStream> _stream;
+ UInt32 _numItems;
+ CItem _items[kNumFilesMax + 1];
+ HRESULT Open2(IInStream *stream);
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidSize, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+#define MACH_ARCH_ABI64 0x1000000
+#define MACH_MACHINE_386 7
+#define MACH_MACHINE_ARM 12
+#define MACH_MACHINE_SPARC 14
+#define MACH_MACHINE_PPC 18
+
+#define MACH_MACHINE_PPC64 (MACH_MACHINE_PPC | MACH_ARCH_ABI64)
+#define MACH_MACHINE_AMD64 (MACH_MACHINE_386 | MACH_ARCH_ABI64)
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+ const CItem &item = _items[index];
+ switch(propID)
+ {
+ case kpidExtension:
+ {
+ const wchar_t *ext;
+ if (item.IsTail)
+ ext = L"tail";
+ else
+ {
+ switch(item.Type)
+ {
+ case MACH_MACHINE_386: ext = L"86"; break;
+ case MACH_MACHINE_ARM: ext = L"arm"; break;
+ case MACH_MACHINE_SPARC: ext = L"sparc"; break;
+ case MACH_MACHINE_PPC: ext = L"ppc"; break;
+ case MACH_MACHINE_PPC64: ext = L"ppc64"; break;
+ case MACH_MACHINE_AMD64: ext = L"x64"; break;
+ default: ext = L"unknown"; break;
+ }
+ }
+ prop = ext;
+ break;
+ }
+ case kpidSize:
+ case kpidPackSize:
+ prop = (UInt64)item.Size;
+ break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+#define MACH_TYPE_ABI64 (1 << 24)
+#define MACH_SUBTYPE_ABI64 (1 << 31)
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, &_startPos));
+
+ const UInt32 kHeaderSize = 8;
+ const UInt32 kRecordSize = 5 * 4;
+ const UInt32 kBufSize = kHeaderSize + kNumFilesMax * kRecordSize;
+ Byte buf[kBufSize];
+ size_t processed = kBufSize;
+ RINOK(ReadStream(stream, buf, &processed));
+ if (processed < kHeaderSize)
+ return S_FALSE;
+ UInt32 num = Get32(buf + 4);
+ if (Get32(buf) != 0xCAFEBABE || num > kNumFilesMax || processed < kHeaderSize + num * kRecordSize)
+ return S_FALSE;
+ UInt64 endPosMax = kHeaderSize;
+ for (UInt32 i = 0; i < num; i++)
+ {
+ const Byte *p = buf + kHeaderSize + i * kRecordSize;
+ CItem &sb = _items[i];
+ sb.IsTail = false;
+ sb.Type = Get32(p);
+ sb.SubType = Get32(p + 4);
+ sb.Offset = Get32(p + 8);
+ sb.Size = Get32(p + 12);
+ sb.Align = Get32(p + 16);
+
+ if ((sb.Type & ~MACH_TYPE_ABI64) >= 0x100 ||
+ (sb.SubType & ~MACH_SUBTYPE_ABI64) >= 0x100 ||
+ sb.Align > 31)
+ return S_FALSE;
+
+ UInt64 endPos = (UInt64)sb.Offset + sb.Size;
+ if (endPos > endPosMax)
+ endPosMax = endPos;
+ }
+ UInt64 fileSize;
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
+ fileSize -= _startPos;
+ _numItems = num;
+ if (fileSize > endPosMax)
+ {
+ CItem &sb = _items[_numItems++];
+ sb.IsTail = true;
+ sb.Type = 0;
+ sb.SubType = 0;
+ sb.Offset = endPosMax;
+ sb.Size = fileSize - endPosMax;
+ sb.Align = 0;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ try
+ {
+ if (Open2(inStream) != S_OK)
+ return S_FALSE;
+ _stream = inStream;
+ }
+ catch(...) { return S_FALSE; }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _stream.Release();
+ _numItems = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _numItems;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _numItems;
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _items[allFilesMode ? i : indices[i]].Size;
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_stream);
+
+ for (i = 0; i < numItems; i++)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _items[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ currentTotalSize += item.Size;
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ if (testMode)
+ {
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ RINOK(_stream->Seek(_startPos + item.Offset, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(item.Size);
+ RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ const CItem &item = _items[index];
+ return CreateLimitedInStream(_stream, _startPos + item.Offset, item.Size, stream);
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Mub", L"", 0, 0xE2, { 0xCA, 0xFE, 0xBA, 0xBE, 0, 0, 0 }, 7, false, CreateArc, 0 };
+
+REGISTER_ARC(Mub)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisDecode.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisDecode.cpp
new file mode 100644
index 000000000..7e126bd44
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisDecode.cpp
@@ -0,0 +1,141 @@
+// NsisDecode.cpp
+
+#include "StdAfx.h"
+
+#include "NsisDecode.h"
+
+#include "../../Common/StreamUtils.h"
+
+#include "../../Common/MethodId.h"
+#include "../../Common/CreateCoder.h"
+
+namespace NArchive {
+namespace NNsis {
+
+static const CMethodId k_Copy = 0x0;
+static const CMethodId k_Deflate = 0x040901;
+static const CMethodId k_BZip2 = 0x040902;
+static const CMethodId k_LZMA = 0x030101;
+static const CMethodId k_BCJ_X86 = 0x03030103;
+
+HRESULT CDecoder::Init(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IInStream *inStream, NMethodType::EEnum method, bool thereIsFilterFlag, bool &useFilter)
+{
+ useFilter = false;
+ CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;
+
+ if (_decoderInStream)
+ if (method != _method)
+ Release();
+ _method = method;
+ if (!_codecInStream)
+ {
+ CMethodId methodID;
+ switch (method)
+ {
+ case NMethodType::kCopy: methodID = k_Copy; break;
+ case NMethodType::kDeflate: methodID = k_Deflate; break;
+ case NMethodType::kBZip2: methodID = k_BZip2; break;
+ case NMethodType::kLZMA: methodID = k_LZMA; break;
+ default: return E_NOTIMPL;
+ }
+ CMyComPtr<ICompressCoder> coder;
+ RINOK(CreateCoder(
+ EXTERNAL_CODECS_LOC_VARS
+ methodID, coder, false));
+ if (!coder)
+ return E_NOTIMPL;
+ coder.QueryInterface(IID_ISequentialInStream, &_codecInStream);
+ if (!_codecInStream)
+ return E_NOTIMPL;
+ }
+
+ if (thereIsFilterFlag)
+ {
+ UInt32 processedSize;
+ BYTE flag;
+ RINOK(inStream->Read(&flag, 1, &processedSize));
+ if (processedSize != 1)
+ return E_FAIL;
+ if (flag > 1)
+ return E_NOTIMPL;
+ useFilter = (flag != 0);
+ }
+
+ if (useFilter)
+ {
+ if (!_filterInStream)
+ {
+ CMyComPtr<ICompressCoder> coder;
+ RINOK(CreateCoder(
+ EXTERNAL_CODECS_LOC_VARS
+ k_BCJ_X86, coder, false));
+ if (!coder)
+ return E_NOTIMPL;
+ coder.QueryInterface(IID_ISequentialInStream, &_filterInStream);
+ if (!_filterInStream)
+ return E_NOTIMPL;
+ }
+ CMyComPtr<ICompressSetInStream> setInStream;
+ _filterInStream.QueryInterface(IID_ICompressSetInStream, &setInStream);
+ if (!setInStream)
+ return E_NOTIMPL;
+ RINOK(setInStream->SetInStream(_codecInStream));
+ _decoderInStream = _filterInStream;
+ }
+ else
+ _decoderInStream = _codecInStream;
+
+ if (method == NMethodType::kLZMA)
+ {
+ CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
+ _codecInStream.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
+ if (setDecoderProperties)
+ {
+ static const UInt32 kPropertiesSize = 5;
+ BYTE properties[kPropertiesSize];
+ UInt32 processedSize;
+ RINOK(inStream->Read(properties, kPropertiesSize, &processedSize));
+ if (processedSize != kPropertiesSize)
+ return E_FAIL;
+ RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)properties, kPropertiesSize));
+ }
+ }
+
+ {
+ CMyComPtr<ICompressSetInStream> setInStream;
+ _codecInStream.QueryInterface(IID_ICompressSetInStream, &setInStream);
+ if (!setInStream)
+ return E_NOTIMPL;
+ RINOK(setInStream->SetInStream(inStream));
+ }
+
+ {
+ CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
+ _codecInStream.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize);
+ if (!setOutStreamSize)
+ return E_NOTIMPL;
+ RINOK(setOutStreamSize->SetOutStreamSize(NULL));
+ }
+
+ if (useFilter)
+ {
+ /*
+ CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
+ _filterInStream.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize);
+ if (!setOutStreamSize)
+ return E_NOTIMPL;
+ RINOK(setOutStreamSize->SetOutStreamSize(NULL));
+ */
+ }
+
+ return S_OK;
+}
+
+HRESULT CDecoder::Read(void *data, size_t *processedSize)
+{
+ return ReadStream(_decoderInStream, data, processedSize);;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisDecode.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisDecode.h
new file mode 100644
index 000000000..36aeb2b14
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisDecode.h
@@ -0,0 +1,47 @@
+// NsisDecode.h
+
+#ifndef __NSIS_DECODE_H
+#define __NSIS_DECODE_H
+
+#include "../../IStream.h"
+
+#include "../../Common/CreateCoder.h"
+
+namespace NArchive {
+namespace NNsis {
+
+namespace NMethodType
+{
+ enum EEnum
+ {
+ kCopy,
+ kDeflate,
+ kBZip2,
+ kLZMA
+ };
+}
+
+class CDecoder
+{
+ NMethodType::EEnum _method;
+
+ CMyComPtr<ISequentialInStream> _filterInStream;
+ CMyComPtr<ISequentialInStream> _codecInStream;
+ CMyComPtr<ISequentialInStream> _decoderInStream;
+
+public:
+ void Release()
+ {
+ _filterInStream.Release();
+ _codecInStream.Release();
+ _decoderInStream.Release();
+ }
+ HRESULT Init(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IInStream *inStream, NMethodType::EEnum method, bool thereIsFilterFlag, bool &useFilter);
+ HRESULT Read(void *data, size_t *processedSize);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisHandler.cpp
new file mode 100644
index 000000000..f2e3aab62
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisHandler.cpp
@@ -0,0 +1,489 @@
+// NSisHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+#include "Common/NewHandler.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../Common/StreamUtils.h"
+
+#include "../Common/ItemNameUtils.h"
+
+#include "NsisHandler.h"
+
+#define Get32(p) GetUi32(p)
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NNsis {
+
+static const wchar_t *kBcjMethod = L"BCJ";
+static const wchar_t *kUnknownMethod = L"Unknown";
+
+static const wchar_t *kMethods[] =
+{
+ L"Copy",
+ L"Deflate",
+ L"BZip2",
+ L"LZMA"
+};
+
+static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidSolid, VT_BOOL}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidSolid, VT_BOOL}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ UInt32 dict = 1;
+ bool filter = false;
+ for (int i = 0; i < _archive.Items.Size(); i++)
+ {
+ const CItem &item = _archive.Items[i];
+ filter |= item.UseFilter;
+ if (item.DictionarySize > dict)
+ dict = item.DictionarySize;
+ }
+ prop = GetMethod(filter, dict);
+ break;
+ }
+ case kpidSolid: prop = _archive.IsSolid; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+
+STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 * maxCheckStartPosition, IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ {
+ if(_archive.Open(
+ EXTERNAL_CODECS_VARS
+ stream, maxCheckStartPosition) != S_OK)
+ return S_FALSE;
+ _inStream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _archive.Clear();
+ _archive.Release();
+ _inStream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _archive.Items.Size()
+ #ifdef NSIS_SCRIPT
+ + 1
+ #endif
+ ;
+ return S_OK;
+}
+
+static UString ConvertUInt32ToString(UInt32 value)
+{
+ wchar_t buffer[32];
+ ConvertUInt64ToString(value, buffer);
+ return buffer;
+}
+
+static UString GetStringForSizeValue(UInt32 value)
+{
+ for (int i = 31; i >= 0; i--)
+ if ((UInt32(1) << i) == value)
+ return ConvertUInt32ToString(i);
+ UString result;
+ if (value % (1 << 20) == 0)
+ {
+ result += ConvertUInt32ToString(value >> 20);
+ result += L"m";
+ }
+ else if (value % (1 << 10) == 0)
+ {
+ result += ConvertUInt32ToString(value >> 10);
+ result += L"k";
+ }
+ else
+ {
+ result += ConvertUInt32ToString(value);
+ result += L"b";
+ }
+ return result;
+}
+
+UString CHandler::GetMethod(bool useItemFilter, UInt32 dictionary) const
+{
+ NMethodType::EEnum methodIndex = _archive.Method;
+ UString method;
+ if (_archive.IsSolid && _archive.UseFilter || !_archive.IsSolid && useItemFilter)
+ {
+ method += kBcjMethod;
+ method += L" ";
+ }
+ method += (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
+ if (methodIndex == NMethodType::kLZMA)
+ {
+ method += L":";
+ method += GetStringForSizeValue(_archive.IsSolid ? _archive.DictionarySize: dictionary);
+ }
+ return method;
+}
+
+bool CHandler::GetUncompressedSize(int index, UInt32 &size)
+{
+ size = 0;
+ const CItem &item = _archive.Items[index];
+ if (item.SizeIsDefined)
+ size = item.Size;
+ else if (_archive.IsSolid && item.EstimatedSizeIsDefined)
+ size = item.EstimatedSize;
+ else
+ return false;
+ return true;
+}
+
+bool CHandler::GetCompressedSize(int index, UInt32 &size)
+{
+ size = 0;
+ const CItem &item = _archive.Items[index];
+ if (item.CompressedSizeIsDefined)
+ size = item.CompressedSize;
+ else
+ {
+ if (_archive.IsSolid)
+ {
+ if (index == 0)
+ size = _archive.FirstHeader.GetDataSize();
+ else
+ return false;
+ }
+ else
+ {
+ if (!item.IsCompressed)
+ size = item.Size;
+ else
+ return false;
+ }
+ }
+ return true;
+}
+
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ #ifdef NSIS_SCRIPT
+ if (index >= (UInt32)_archive.Items.Size())
+ {
+ switch(propID)
+ {
+ case kpidPath: prop = L"[NSIS].nsi"; break;
+ case kpidSize:
+ case kpidPackSize: prop = (UInt64)_archive.Script.Length(); break;
+ case kpidSolid: prop = false; break;
+ }
+ }
+ else
+ #endif
+ {
+ const CItem &item = _archive.Items[index];
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ UString s = NItemName::WinNameToOSName(item.GetReducedName(_archive.IsUnicode));
+ if (!s.IsEmpty())
+ prop = (const wchar_t *)s;
+ break;
+ }
+ case kpidSize:
+ {
+ UInt32 size;
+ if (GetUncompressedSize(index, size))
+ prop = (UInt64)size;
+ break;
+ }
+ case kpidPackSize:
+ {
+ UInt32 size;
+ if (GetCompressedSize(index, size))
+ prop = (UInt64)size;
+ break;
+ }
+ case kpidMTime:
+ {
+ if (item.MTime.dwHighDateTime > 0x01000000 &&
+ item.MTime.dwHighDateTime < 0xFF000000)
+ prop = item.MTime;
+ break;
+ }
+ case kpidMethod: prop = GetMethod(item.UseFilter, item.DictionarySize); break;
+ case kpidSolid: prop = _archive.IsSolid; break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ GetNumberOfItems(&numItems);
+ if(numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+
+ UInt32 i;
+ for(i = 0; i < numItems; i++)
+ {
+ UInt32 index = (allFilesMode ? i : indices[i]);
+ #ifdef NSIS_SCRIPT
+ if (index >= (UInt32)_archive.Items.Size())
+ totalSize += _archive.Script.Length();
+ else
+ #endif
+ {
+ UInt32 size;
+ if (_archive.IsSolid)
+ {
+ GetUncompressedSize(index, size);
+ UInt64 pos = _archive.GetPosOfSolidItem(index);
+ if (pos > totalSize)
+ totalSize = pos + size;
+ }
+ else
+ {
+ GetCompressedSize(index, size);
+ totalSize += size;
+ }
+ }
+ }
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt32 currentItemSize = 0;
+
+ UInt64 streamPos = 0;
+ if (_archive.IsSolid)
+ {
+ RINOK(_inStream->Seek(_archive.StreamOffset, STREAM_SEEK_SET, NULL));
+ bool useFilter;
+ RINOK(_archive.Decoder.Init(
+ EXTERNAL_CODECS_VARS
+ _inStream, _archive.Method, _archive.FilterFlag, useFilter));
+ }
+
+ CByteBuffer byteBuf;
+ const UInt32 kBufferLength = 1 << 16;
+ byteBuf.SetCapacity(kBufferLength);
+ Byte *buffer = byteBuf;
+
+ bool dataError = false;
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ currentItemSize = 0;
+ RINOK(extractCallback->SetCompleted(&currentTotalSize));
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode;
+ askMode = testMode ? NArchive::NExtract::NAskMode::kTest : NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ #ifdef NSIS_SCRIPT
+ if (index >= (UInt32)_archive.Items.Size())
+ {
+ currentItemSize = _archive.Script.Length();
+ if(!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ if (!testMode)
+ RINOK(WriteStream(realOutStream, (const char *)_archive.Script, (UInt32)_archive.Script.Length()));
+ }
+ else
+ #endif
+ {
+ const CItem &item = _archive.Items[index];
+
+ if (_archive.IsSolid)
+ GetUncompressedSize(index, currentItemSize);
+ else
+ GetCompressedSize(index, currentItemSize);
+
+ if(!testMode && (!realOutStream))
+ continue;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ if (!dataError)
+ {
+ bool needDecompress = false;
+ bool sizeIsKnown = false;
+ UInt32 fullSize = 0;
+
+ if (_archive.IsSolid)
+ {
+ UInt64 pos = _archive.GetPosOfSolidItem(index);
+ while(streamPos < pos)
+ {
+ size_t processedSize = (UInt32)MyMin(pos - streamPos, (UInt64)kBufferLength);
+ HRESULT res = _archive.Decoder.Read(buffer, &processedSize);
+ if (res != S_OK)
+ {
+ if (res != S_FALSE)
+ return res;
+ dataError = true;
+ break;
+ }
+ if (processedSize == 0)
+ {
+ dataError = true;
+ break;
+ }
+ streamPos += processedSize;
+ }
+ if (streamPos == pos)
+ {
+ Byte buffer2[4];
+ size_t processedSize = 4;
+ RINOK(_archive.Decoder.Read(buffer2, &processedSize));
+ if (processedSize != 4)
+ return E_FAIL;
+ streamPos += processedSize;
+ fullSize = Get32(buffer2);
+ sizeIsKnown = true;
+ needDecompress = true;
+ }
+ }
+ else
+ {
+ RINOK(_inStream->Seek(_archive.GetPosOfNonSolidItem(index) + 4, STREAM_SEEK_SET, NULL));
+ if (item.IsCompressed)
+ {
+ needDecompress = true;
+ bool useFilter;
+ RINOK(_archive.Decoder.Init(
+ EXTERNAL_CODECS_VARS
+ _inStream, _archive.Method, _archive.FilterFlag, useFilter));
+ // fullSize = Get32(buffer); // It's bug !!!
+ // Test it: what is exact fullSize?
+ fullSize = 0xFFFFFFFF;
+ }
+ else
+ fullSize = item.Size;
+ }
+ if (!dataError)
+ {
+ if (needDecompress)
+ {
+ UInt64 offset = 0;
+ while(!sizeIsKnown || fullSize > 0)
+ {
+ UInt32 curSize = kBufferLength;
+ if (sizeIsKnown && curSize > fullSize)
+ curSize = fullSize;
+ size_t processedSize = curSize;
+ HRESULT res = _archive.Decoder.Read(buffer, &processedSize);
+ if (res != S_OK)
+ {
+ if (res != S_FALSE)
+ return res;
+ dataError = true;
+ break;
+ }
+ if (processedSize == 0)
+ {
+ if (sizeIsKnown)
+ dataError = true;
+ break;
+ }
+
+ fullSize -= (UInt32)processedSize;
+ streamPos += processedSize;
+ offset += processedSize;
+
+ UInt64 completed;
+ if (_archive.IsSolid)
+ completed = currentTotalSize + offset;
+ else
+ completed = streamPos;
+ RINOK(extractCallback->SetCompleted(&completed));
+ if (!testMode)
+ RINOK(WriteStream(realOutStream, buffer, processedSize));
+ }
+ }
+ else
+ {
+ while(fullSize > 0)
+ {
+ UInt32 curSize = MyMin(fullSize, kBufferLength);
+ UInt32 processedSize;
+ RINOK(_inStream->Read(buffer, curSize, &processedSize));
+ if (processedSize == 0)
+ {
+ dataError = true;
+ break;
+ }
+ fullSize -= processedSize;
+ streamPos += processedSize;
+ if (!testMode)
+ RINOK(WriteStream(realOutStream, buffer, processedSize));
+ }
+ }
+ }
+ }
+ }
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(dataError ?
+ NArchive::NExtract::NOperationResult::kDataError :
+ NArchive::NExtract::NOperationResult::kOK));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+IMPL_ISetCompressCodecsInfo
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisHandler.h
new file mode 100644
index 000000000..95fea5d0d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisHandler.h
@@ -0,0 +1,43 @@
+// NSisHandler.h
+
+#ifndef __NSIS_HANDLER_H
+#define __NSIS_HANDLER_H
+
+#include "Common/MyCom.h"
+#include "../IArchive.h"
+
+#include "NsisIn.h"
+
+#include "../../Common/CreateCoder.h"
+
+namespace NArchive {
+namespace NNsis {
+
+class CHandler:
+ public IInArchive,
+ PUBLIC_ISetCompressCodecsInfo
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+ CInArchive _archive;
+
+ DECL_EXTERNAL_CODECS_VARS
+
+ bool GetUncompressedSize(int index, UInt32 &size);
+ bool GetCompressedSize(int index, UInt32 &size);
+
+ UString GetMethod(bool useItemFilter, UInt32 dictionary) const;
+public:
+ MY_QUERYINTERFACE_BEGIN2(IInArchive)
+ QUERY_ENTRY_ISetCompressCodecsInfo
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ INTERFACE_IInArchive(;)
+
+ DECL_ISetCompressCodecsInfo
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisIn.cpp
new file mode 100644
index 000000000..9e7e89bb9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisIn.cpp
@@ -0,0 +1,1448 @@
+// Archive/NsisIn.cpp
+
+#include "StdAfx.h"
+
+// #include <stdio.h>
+
+#include "NsisIn.h"
+#include "NsisDecode.h"
+
+#include "Windows/Defs.h"
+
+#include "../../Common/StreamUtils.h"
+
+#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
+
+#include "../../../../C/CpuArch.h"
+
+#define Get32(p) GetUi32(p)
+
+namespace NArchive {
+namespace NNsis {
+
+Byte kSignature[kSignatureSize] = { 0xEF + 1, 0xBE, 0xAD, 0xDE,
+0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74};
+
+struct CSignatureInit { CSignatureInit() { kSignature[0]--; } } g_SignatureInit;
+
+#ifdef NSIS_SCRIPT
+static const char *kCrLf = "\x0D\x0A";
+#endif
+
+#define NS_UN_SKIP_CODE 0xE000
+#define NS_UN_VAR_CODE 0xE001
+#define NS_UN_SHELL_CODE 0xE002
+#define NS_UN_LANG_CODE 0xE003
+#define NS_UN_CODES_START NS_UN_SKIP_CODE
+#define NS_UN_CODES_END NS_UN_LANG_CODE
+
+Byte CInArchive::ReadByte()
+{
+ if (_posInData >= _size)
+ throw 1;
+ return _data[_posInData++];
+}
+
+UInt32 CInArchive::ReadUInt32()
+{
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ value |= ((UInt32)(ReadByte()) << (8 * i));
+ return value;
+}
+
+void CInArchive::ReadBlockHeader(CBlockHeader &bh)
+{
+ bh.Offset = ReadUInt32();
+ bh.Num = ReadUInt32();
+}
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+static int CompareItems(void *const *p1, void *const *p2, void * /* param */)
+{
+ const CItem &i1 = **(CItem **)p1;
+ const CItem &i2 = **(CItem **)p2;
+ RINOZ(MyCompare(i1.Pos, i2.Pos));
+ if (i1.IsUnicode)
+ {
+ RINOZ(i1.PrefixU.Compare(i2.PrefixU));
+ RINOZ(i1.NameU.Compare(i2.NameU));
+ }
+ else
+ {
+ RINOZ(i1.PrefixA.Compare(i2.PrefixA));
+ RINOZ(i1.NameA.Compare(i2.NameA));
+ }
+ return 0;
+}
+
+static AString UIntToString(UInt32 v)
+{
+ char sz[32];
+ ConvertUInt64ToString(v, sz);
+ return sz;
+}
+
+static AString IntToString(Int32 v)
+{
+ char sz[32];
+ ConvertInt64ToString(v, sz);
+ return sz;
+}
+
+AString CInArchive::ReadStringA(UInt32 pos) const
+{
+ AString s;
+ if (pos >= _size)
+ return IntToString((Int32)pos);
+ UInt32 offset = GetOffset() + _stringsPos + pos;
+ for (;;)
+ {
+ if (offset >= _size)
+ break; // throw 1;
+ char c = _data[offset++];
+ if (c == 0)
+ break;
+ s += c;
+ }
+ return s;
+}
+
+UString CInArchive::ReadStringU(UInt32 pos) const
+{
+ UString s;
+ UInt32 offset = GetOffset() + _stringsPos + (pos * 2);
+ for (;;)
+ {
+ if (offset >= _size || offset + 1 >= _size)
+ return s; // throw 1;
+ char c0 = _data[offset++];
+ char c1 = _data[offset++];
+ wchar_t c = (c0 | ((wchar_t)c1 << 8));
+ if (c == 0)
+ break;
+ s += c;
+ }
+ return s;
+}
+
+/*
+static AString ParsePrefix(const AString &prefix)
+{
+ AString res = prefix;
+ if (prefix.Length() >= 3)
+ {
+ if ((Byte)prefix[0] == 0xFD && (Byte)prefix[1] == 0x95 && (Byte)prefix[2] == 0x80)
+ res = "$INSTDIR" + prefix.Mid(3);
+ else if ((Byte)prefix[0] == 0xFD && (Byte)prefix[1] == 0x96 && (Byte)prefix[2] == 0x80)
+ res = "$OUTDIR" + prefix.Mid(3);
+ }
+ return res;
+}
+*/
+
+#define SYSREGKEY "Software\\Microsoft\\Windows\\CurrentVersion"
+
+/*
+# define CSIDL_PROGRAMS 0x2
+# define CSIDL_PRINTERS 0x4
+# define CSIDL_PERSONAL 0x5
+# define CSIDL_FAVORITES 0x6
+# define CSIDL_STARTUP 0x7
+# define CSIDL_RECENT 0x8
+# define CSIDL_SENDTO 0x9
+# define CSIDL_STARTMENU 0xB
+# define CSIDL_MYMUSIC 0xD
+# define CSIDL_MYVIDEO 0xE
+
+# define CSIDL_DESKTOPDIRECTORY 0x10
+# define CSIDL_NETHOOD 0x13
+# define CSIDL_FONTS 0x14
+# define CSIDL_TEMPLATES 0x15
+# define CSIDL_COMMON_STARTMENU 0x16
+# define CSIDL_COMMON_PROGRAMS 0x17
+# define CSIDL_COMMON_STARTUP 0x18
+# define CSIDL_COMMON_DESKTOPDIRECTORY 0x19
+# define CSIDL_APPDATA 0x1A
+# define CSIDL_PRINTHOOD 0x1B
+# define CSIDL_LOCAL_APPDATA 0x1C
+# define CSIDL_ALTSTARTUP 0x1D
+# define CSIDL_COMMON_ALTSTARTUP 0x1E
+# define CSIDL_COMMON_FAVORITES 0x1F
+
+# define CSIDL_INTERNET_CACHE 0x20
+# define CSIDL_COOKIES 0x21
+# define CSIDL_HISTORY 0x22
+# define CSIDL_COMMON_APPDATA 0x23
+# define CSIDL_WINDOWS 0x24
+# define CSIDL_SYSTEM 0x25
+# define CSIDL_PROGRAM_FILES 0x26
+# define CSIDL_MYPICTURES 0x27
+# define CSIDL_PROFILE 0x28
+# define CSIDL_PROGRAM_FILES_COMMON 0x2B
+# define CSIDL_COMMON_TEMPLATES 0x2D
+# define CSIDL_COMMON_DOCUMENTS 0x2E
+# define CSIDL_COMMON_ADMINTOOLS 0x2F
+
+# define CSIDL_ADMINTOOLS 0x30
+# define CSIDL_COMMON_MUSIC 0x35
+# define CSIDL_COMMON_PICTURES 0x36
+# define CSIDL_COMMON_VIDEO 0x37
+# define CSIDL_RESOURCES 0x38
+# define CSIDL_RESOURCES_LOCALIZED 0x39
+# define CSIDL_CDBURN_AREA 0x3B
+*/
+
+struct CCommandPair
+{
+ int NumParams;
+ const char *Name;
+};
+
+enum
+{
+ // 0
+ EW_INVALID_OPCODE, // zero is invalid. useful for catching errors. (otherwise an all zeroes instruction
+ // does nothing, which is easily ignored but means something is wrong.
+ EW_RET, // return from function call
+ EW_NOP, // Nop/Jump, do nothing: 1, [?new address+1:advance one]
+ EW_ABORT, // Abort: 1 [status]
+ EW_QUIT, // Quit: 0
+ EW_CALL, // Call: 1 [new address+1]
+ EW_UPDATETEXT, // Update status text: 2 [update str, ui_st_updateflag=?ui_st_updateflag:this]
+ EW_SLEEP, // Sleep: 1 [sleep time in milliseconds]
+ EW_BRINGTOFRONT, // BringToFront: 0
+ EW_CHDETAILSVIEW, // SetDetailsView: 2 [listaction,buttonaction]
+
+ // 10
+ EW_SETFILEATTRIBUTES, // SetFileAttributes: 2 [filename, attributes]
+ EW_CREATEDIR, // Create directory: 2, [path, ?update$INSTDIR]
+ EW_IFFILEEXISTS, // IfFileExists: 3, [file name, jump amount if exists, jump amount if not exists]
+ EW_SETFLAG, // Sets a flag: 2 [id, data]
+ EW_IFFLAG, // If a flag: 4 [on, off, id, new value mask]
+ EW_GETFLAG, // Gets a flag: 2 [output, id]
+ EW_RENAME, // Rename: 3 [old, new, rebootok]
+ EW_GETFULLPATHNAME, // GetFullPathName: 2 [output, input, ?lfn:sfn]
+ EW_SEARCHPATH, // SearchPath: 2 [output, filename]
+ EW_GETTEMPFILENAME, // GetTempFileName: 2 [output, base_dir]
+
+ // 20
+ EW_EXTRACTFILE, // File to extract: 6 [overwriteflag, output filename, compressed filedata, filedatetimelow, filedatetimehigh, allow ignore]
+ // overwriteflag: 0x1 = no. 0x0=force, 0x2=try, 0x3=if date is newer
+ EW_DELETEFILE, // Delete File: 2, [filename, rebootok]
+ EW_MESSAGEBOX, // MessageBox: 5,[MB_flags,text,retv1:retv2,moveonretv1:moveonretv2]
+ EW_RMDIR, // RMDir: 2 [path, recursiveflag]
+ EW_STRLEN, // StrLen: 2 [output, input]
+ EW_ASSIGNVAR, // Assign: 4 [variable (0-9) to assign, string to assign, maxlen, startpos]
+ EW_STRCMP, // StrCmp: 5 [str1, str2, jump_if_equal, jump_if_not_equal, case-sensitive?]
+ EW_READENVSTR, // ReadEnvStr/ExpandEnvStrings: 3 [output, string_with_env_variables, IsRead]
+ EW_INTCMP, // IntCmp: 6 [val1, val2, equal, val1<val2, val1>val2, unsigned?]
+ EW_INTOP, // IntOp: 4 [output, input1, input2, op] where op: 0=add, 1=sub, 2=mul, 3=div, 4=bor, 5=band, 6=bxor, 7=bnot input1, 8=lnot input1, 9=lor, 10=land], 11=1%2
+
+ // 30
+ EW_INTFMT, // IntFmt: [output, format, input]
+ EW_PUSHPOP, // Push/Pop/Exchange: 3 [variable/string, ?pop:push, ?exch]
+ EW_FINDWINDOW, // FindWindow: 5, [outputvar, window class,window name, window_parent, window_after]
+ EW_SENDMESSAGE, // SendMessage: 6 [output, hwnd, msg, wparam, lparam, [wparamstring?1:0 | lparamstring?2:0 | timeout<<2]
+ EW_ISWINDOW, // IsWindow: 3 [hwnd, jump_if_window, jump_if_notwindow]
+ EW_GETDLGITEM, // GetDlgItem: 3: [outputvar, dialog, item_id]
+ EW_SETCTLCOLORS, // SerCtlColors: 3: [hwnd, pointer to struct colors]
+ EW_SETBRANDINGIMAGE, // SetBrandingImage: 1: [Bitmap file]
+ EW_CREATEFONT, // CreateFont: 5: [handle output, face name, height, weight, flags]
+ EW_SHOWWINDOW, // ShowWindow: 2: [hwnd, show state]
+
+ // 40
+ EW_SHELLEXEC, // ShellExecute program: 4, [shell action, complete commandline, parameters, showwindow]
+ EW_EXECUTE, // Execute program: 3,[complete command line,waitflag,>=0?output errorcode]
+ EW_GETFILETIME, // GetFileTime; 3 [file highout lowout]
+ EW_GETDLLVERSION, // GetDLLVersion: 3 [file highout lowout]
+ EW_REGISTERDLL, // Register DLL: 3,[DLL file name, string ptr of function to call, text to put in display (<0 if none/pass parms), 1 - no unload, 0 - unload]
+ EW_CREATESHORTCUT, // Make Shortcut: 5, [link file, target file, parameters, icon file, iconindex|show mode<<8|hotkey<<16]
+ EW_COPYFILES, // CopyFiles: 3 [source mask, destination location, flags]
+ EW_REBOOT, // Reboot: 0
+ EW_WRITEINI, // Write INI String: 4, [Section, Name, Value, INI File]
+ EW_READINISTR, // ReadINIStr: 4 [output, section, name, ini_file]
+
+ // 50
+ EW_DELREG, // DeleteRegValue/DeleteRegKey: 4, [root key(int), KeyName, ValueName, delkeyonlyifempty]. ValueName is -1 if delete key
+ EW_WRITEREG, // Write Registry value: 5, [RootKey(int),KeyName,ItemName,ItemData,typelen]
+ // typelen=1 for str, 2 for dword, 3 for binary, 0 for expanded str
+ EW_READREGSTR, // ReadRegStr: 5 [output, rootkey(int), keyname, itemname, ==1?int::str]
+ EW_REGENUM, // RegEnum: 5 [output, rootkey, keyname, index, ?key:value]
+ EW_FCLOSE, // FileClose: 1 [handle]
+ EW_FOPEN, // FileOpen: 4 [name, openmode, createmode, outputhandle]
+ EW_FPUTS, // FileWrite: 3 [handle, string, ?int:string]
+ EW_FGETS, // FileRead: 4 [handle, output, maxlen, ?getchar:gets]
+ EW_FSEEK, // FileSeek: 4 [handle, offset, mode, >=0?positionoutput]
+ EW_FINDCLOSE, // FindClose: 1 [handle]
+
+ // 60
+ EW_FINDNEXT, // FindNext: 2 [output, handle]
+ EW_FINDFIRST, // FindFirst: 2 [filespec, output, handleoutput]
+ EW_WRITEUNINSTALLER, // WriteUninstaller: 3 [name, offset, icon_size]
+ EW_LOG, // LogText: 2 [0, text] / LogSet: [1, logstate]
+ EW_SECTIONSET, // SectionSetText: 3: [idx, 0, text]
+ // SectionGetText: 3: [idx, 1, output]
+ // SectionSetFlags: 3: [idx, 2, flags]
+ // SectionGetFlags: 3: [idx, 3, output]
+ EW_INSTTYPESET, // InstTypeSetFlags: 3: [idx, 0, flags]
+ // InstTypeGetFlags: 3: [idx, 1, output]
+ // instructions not actually implemented in exehead, but used in compiler.
+ EW_GETLABELADDR, // both of these get converted to EW_ASSIGNVAR
+ EW_GETFUNCTIONADDR,
+
+ EW_LOCKWINDOW
+};
+
+#ifdef NSIS_SCRIPT
+static CCommandPair kCommandPairs[] =
+{
+ { 0, "Invalid" },
+ { 0, "Return" },
+ { 1, "Goto" },
+ { 0, "Abort" },
+ { 0, "Quit" },
+ { 1, "Call" },
+ { 2, "UpdateSatusText" },
+ { 1, "Sleep" },
+ { 0, "BringToFront" },
+ { 2, "SetDetailsView" },
+
+ { 2, "SetFileAttributes" },
+ { 2, "SetOutPath" },
+ { 3, "IfFileExists" },
+ { 2, "SetFlag" },
+ { 4, "IfFlag" },
+ { 2, "GetFlag" },
+ { 3, "Rename" },
+ { 2, "GetFullPathName" },
+ { 2, "SearchPath" },
+ { 2, "GetTempFileName" },
+
+ { 6, "File" },
+ { 2, "Delete" },
+ { 5, "MessageBox" },
+ { 2, "RMDir" },
+ { 2, "StrLen" },
+ { 4, "StrCpy" },
+ { 5, "StrCmp" },
+ { 3, "ReadEnvStr" },
+ { 6, "IntCmp" },
+ { 4, "IntOp" },
+
+ { 3, "IntFmt" },
+ { 3, "PushPop" },
+ { 5, "FindWindow" },
+ { 6, "SendMessage" },
+ { 3, "IsWindow" },
+ { 3, "GetDlgItem" },
+ { 3, "SerCtlColors" },
+ { 1, "SetBrandingImage" },
+ { 5, "CreateFont" },
+ { 2, "ShowWindow" },
+
+ { 4, "ShellExecute" },
+ { 3, "Execute" },
+ { 3, "GetFileTime" },
+ { 3, "GetDLLVersion" },
+ { 3, "RegisterDLL" },
+ { 5, "CreateShortCut" },
+ { 3, "CopyFiles" },
+ { 0, "Reboot" },
+ { 4, "WriteINIStr" },
+ { 4, "ReadINIStr" },
+
+ { 4, "DelReg" },
+ { 5, "WriteReg" },
+ { 5, "ReadRegStr" },
+ { 5, "RegEnum" },
+ { 1, "FileClose" },
+ { 4, "FileOpen" },
+ { 3, "FileWrite" },
+ { 4, "FileRead" },
+ { 4, "FileSeek" },
+ { 1, "FindClose" },
+
+ { 2, "FindNext" },
+ { 2, "FindFirst" },
+ { 3, "WriteUninstaller" },
+ { 2, "LogText" },
+ { 3, "Section?etText" },
+ { 3, "InstType?etFlags" },
+ { 6, "GetLabelAddr" },
+ { 2, "GetFunctionAddress" },
+ { 6, "LockWindow" }
+};
+
+#endif
+
+static const char *kShellStrings[] =
+{
+ "",
+ "",
+
+ "SMPROGRAMS",
+ "",
+ "PRINTERS",
+ "DOCUMENTS",
+ "FAVORITES",
+ "SMSTARTUP",
+ "RECENT",
+ "SENDTO",
+ "",
+ "STARTMENU",
+ "",
+ "MUSIC",
+ "VIDEO",
+ "",
+
+ "DESKTOP",
+ "",
+ "",
+ "NETHOOD",
+ "FONTS",
+ "TEMPLATES",
+ "COMMONSTARTMENU",
+ "COMMONFILES",
+ "COMMON_STARTUP",
+ "COMMON_DESKTOPDIRECTORY",
+ "QUICKLAUNCH",
+ "PRINTHOOD",
+ "LOCALAPPDATA",
+ "ALTSTARTUP",
+ "ALTSTARTUP",
+ "FAVORITES",
+
+ "INTERNET_CACHE",
+ "COOKIES",
+ "HISTORY",
+ "APPDATA",
+ "WINDIR",
+ "SYSDIR",
+ "PROGRAMFILES",
+ "PICTURES",
+ "PROFILE",
+ "",
+ "",
+ "COMMONFILES",
+ "",
+ "TEMPLATES",
+ "DOCUMENTS",
+ "ADMINTOOLS",
+
+ "ADMINTOOLS",
+ "",
+ "",
+ "",
+ "",
+ "MUSIC",
+ "PICTURES",
+ "VIDEO",
+ "RESOURCES",
+ "RESOURCES_LOCALIZED",
+ "",
+ "CDBURN_AREA"
+};
+
+static const int kNumShellStrings = sizeof(kShellStrings) / sizeof(kShellStrings[0]);
+
+/*
+# define CMDLINE 20 // everything before here doesn't have trailing slash removal
+# define INSTDIR 21
+# define OUTDIR 22
+# define EXEDIR 23
+# define LANGUAGE 24
+# define TEMP 25
+# define PLUGINSDIR 26
+# define HWNDPARENT 27
+# define _CLICK 28
+# define _OUTDIR 29
+*/
+
+static const char *kVarStrings[] =
+{
+ "CMDLINE",
+ "INSTDIR",
+ "OUTDIR",
+ "EXEDIR",
+ "LANGUAGE",
+ "TEMP",
+ "PLUGINSDIR",
+ "EXEPATH", // test it
+ "EXEFILE", // test it
+ "HWNDPARENT",
+ "_CLICK",
+ "_OUTDIR"
+};
+
+static const int kNumVarStrings = sizeof(kVarStrings) / sizeof(kVarStrings[0]);
+
+
+static AString GetVar(UInt32 index)
+{
+ AString res = "$";
+ if (index < 10)
+ res += UIntToString(index);
+ else if (index < 20)
+ {
+ res += "R";
+ res += UIntToString(index - 10);
+ }
+ else if (index < 20 + kNumVarStrings)
+ res += kVarStrings[index - 20];
+ else
+ {
+ res += "[";
+ res += UIntToString(index);
+ res += "]";
+ }
+ return res;
+}
+
+#define NS_SKIP_CODE 252
+#define NS_VAR_CODE 253
+#define NS_SHELL_CODE 254
+#define NS_LANG_CODE 255
+#define NS_CODES_START NS_SKIP_CODE
+
+static AString GetShellString(int index)
+{
+ AString res = "$";
+ if (index < kNumShellStrings)
+ {
+ const char *sz = kShellStrings[index];
+ if (sz[0] != 0)
+ return res + sz;
+ }
+ res += "SHELL[";
+ res += UIntToString(index);
+ res += "]";
+ return res;
+}
+
+// Based on Dave Laundon's simplified process_string
+AString GetNsisString(const AString &s)
+{
+ AString res;
+ for (int i = 0; i < s.Length();)
+ {
+ unsigned char nVarIdx = s[i++];
+ if (nVarIdx > NS_CODES_START && i + 2 <= s.Length())
+ {
+ int nData = s[i++] & 0x7F;
+ unsigned char c1 = s[i++];
+ nData |= (((int)(c1 & 0x7F)) << 7);
+
+ if (nVarIdx == NS_SHELL_CODE)
+ res += GetShellString(c1);
+ else if (nVarIdx == NS_VAR_CODE)
+ res += GetVar(nData);
+ else if (nVarIdx == NS_LANG_CODE)
+ res += "NS_LANG_CODE";
+ }
+ else if (nVarIdx == NS_SKIP_CODE)
+ {
+ if (i < s.Length())
+ res += s[i++];
+ }
+ else // Normal char
+ res += (char)nVarIdx;
+ }
+ return res;
+}
+
+UString GetNsisString(const UString &s)
+{
+ UString res;
+ for (int i = 0; i < s.Length();)
+ {
+ wchar_t nVarIdx = s[i++];
+ if (nVarIdx > NS_UN_CODES_START && nVarIdx <= NS_UN_CODES_END)
+ {
+ if (i == s.Length())
+ break;
+ int nData = s[i++] & 0x7FFF;
+
+ if (nVarIdx == NS_UN_SHELL_CODE)
+ res += GetUnicodeString(GetShellString(nData >> 8));
+ else if (nVarIdx == NS_UN_VAR_CODE)
+ res += GetUnicodeString(GetVar(nData));
+ else if (nVarIdx == NS_UN_LANG_CODE)
+ res += L"NS_LANG_CODE";
+ }
+ else if (nVarIdx == NS_UN_SKIP_CODE)
+ {
+ if (i == s.Length())
+ break;
+ res += s[i++];
+ }
+ else // Normal char
+ res += (char)nVarIdx;
+ }
+ return res;
+}
+
+AString CInArchive::ReadString2A(UInt32 pos) const
+{
+ return GetNsisString(ReadStringA(pos));
+}
+
+UString CInArchive::ReadString2U(UInt32 pos) const
+{
+ return GetNsisString(ReadStringU(pos));
+}
+
+AString CInArchive::ReadString2(UInt32 pos) const
+{
+ if (IsUnicode)
+ return UnicodeStringToMultiByte(ReadString2U(pos));
+ else
+ return ReadString2A(pos);
+}
+
+AString CInArchive::ReadString2Qw(UInt32 pos) const
+{
+ return "\"" + ReadString2(pos) + "\"";
+}
+
+#define DEL_DIR 1
+#define DEL_RECURSE 2
+#define DEL_REBOOT 4
+// #define DEL_SIMPLE 8
+
+static const int kNumEntryParams = 6;
+
+struct CEntry
+{
+ UInt32 Which;
+ UInt32 Params[kNumEntryParams];
+ AString GetParamsString(int numParams);
+ CEntry()
+ {
+ Which = 0;
+ for (UInt32 j = 0; j < kNumEntryParams; j++)
+ Params[j] = 0;
+ }
+};
+
+AString CEntry::GetParamsString(int numParams)
+{
+ AString s;
+ for (int i = 0; i < numParams; i++)
+ {
+ s += " ";
+ UInt32 v = Params[i];
+ if (v > 0xFFF00000)
+ s += IntToString((Int32)Params[i]);
+ else
+ s += UIntToString(Params[i]);
+ }
+ return s;
+}
+
+#ifdef NSIS_SCRIPT
+
+static AString GetRegRootID(UInt32 val)
+{
+ const char *s;
+ switch(val)
+ {
+ case 0: s = "SHCTX"; break;
+ case 0x80000000: s = "HKCR"; break;
+ case 0x80000001: s = "HKCU"; break;
+ case 0x80000002: s = "HKLM"; break;
+ case 0x80000003: s = "HKU"; break;
+ case 0x80000004: s = "HKPD"; break;
+ case 0x80000005: s = "HKCC"; break;
+ case 0x80000006: s = "HKDD"; break;
+ case 0x80000050: s = "HKPT"; break;
+ case 0x80000060: s = "HKPN"; break;
+ default:
+ return UIntToString(val); break;
+ }
+ return s;
+}
+
+#endif
+
+HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
+{
+ _posInData = bh.Offset + GetOffset();
+ AString prefixA;
+ UString prefixU;
+ for (UInt32 i = 0; i < bh.Num; i++)
+ {
+ CEntry e;
+ e.Which = ReadUInt32();
+ for (UInt32 j = 0; j < kNumEntryParams; j++)
+ e.Params[j] = ReadUInt32();
+ #ifdef NSIS_SCRIPT
+ if (e.Which != EW_PUSHPOP && e.Which < sizeof(kCommandPairs) / sizeof(kCommandPairs[0]))
+ {
+ const CCommandPair &pair = kCommandPairs[e.Which];
+ Script += pair.Name;
+ }
+ #endif
+
+ switch (e.Which)
+ {
+ case EW_CREATEDIR:
+ {
+ if (IsUnicode)
+ {
+ prefixU.Empty();
+ prefixU = ReadString2U(e.Params[0]);
+ }
+ else
+ {
+ prefixA.Empty();
+ prefixA = ReadString2A(e.Params[0]);
+ }
+ #ifdef NSIS_SCRIPT
+ Script += " ";
+ if (IsUnicode)
+ Script += UnicodeStringToMultiByte(prefixU);
+ else
+ Script += prefixA;
+ #endif
+ break;
+ }
+
+ case EW_EXTRACTFILE:
+ {
+ CItem item;
+ item.IsUnicode = IsUnicode;
+ if (IsUnicode)
+ {
+ item.PrefixU = prefixU;
+ item.NameU = ReadString2U(e.Params[1]);
+ }
+ else
+ {
+ item.PrefixA = prefixA;
+ item.NameA = ReadString2A(e.Params[1]);
+ }
+ /* UInt32 overwriteFlag = e.Params[0]; */
+ item.Pos = e.Params[2];
+ item.MTime.dwLowDateTime = e.Params[3];
+ item.MTime.dwHighDateTime = e.Params[4];
+ /* UInt32 allowIgnore = e.Params[5]; */
+ if (Items.Size() > 0)
+ {
+ /*
+ if (item.Pos == Items.Back().Pos)
+ continue;
+ */
+ }
+ Items.Add(item);
+ #ifdef NSIS_SCRIPT
+ Script += " ";
+
+ if (IsUnicode)
+ Script += UnicodeStringToMultiByte(item.NameU);
+ else
+ Script += item.NameA;
+ #endif
+ break;
+ }
+
+
+ #ifdef NSIS_SCRIPT
+ case EW_UPDATETEXT:
+ {
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += UIntToString(e.Params[1]);
+ break;
+ }
+ case EW_SETFILEATTRIBUTES:
+ {
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += UIntToString(e.Params[1]);
+ break;
+ }
+ case EW_IFFILEEXISTS:
+ {
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += UIntToString(e.Params[1]);
+ Script += " ";
+ Script += UIntToString(e.Params[2]);
+ break;
+ }
+ case EW_RENAME:
+ {
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += ReadString2(e.Params[1]);
+ Script += " ";
+ Script += UIntToString(e.Params[2]);
+ break;
+ }
+ case EW_GETFULLPATHNAME:
+ {
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += ReadString2(e.Params[1]);
+ Script += " ";
+ Script += UIntToString(e.Params[2]);
+ break;
+ }
+ case EW_SEARCHPATH:
+ {
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += ReadString2(e.Params[1]);
+ break;
+ }
+ case EW_GETTEMPFILENAME:
+ {
+ AString s;
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += ReadString2(e.Params[1]);
+ break;
+ }
+
+ case EW_DELETEFILE:
+ {
+ UInt64 flag = e.Params[1];
+ if (flag != 0)
+ {
+ Script += " ";
+ if (flag == DEL_REBOOT)
+ Script += "/REBOOTOK";
+ else
+ Script += UIntToString(e.Params[1]);
+ }
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ break;
+ }
+ case EW_RMDIR:
+ {
+ UInt64 flag = e.Params[1];
+ if (flag != 0)
+ {
+ if ((flag & DEL_REBOOT) != 0)
+ Script += " /REBOOTOK";
+ if ((flag & DEL_RECURSE) != 0)
+ Script += " /r";
+ }
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ break;
+ }
+ case EW_STRLEN:
+ {
+ Script += " ";
+ Script += GetVar(e.Params[0]);;
+ Script += " ";
+ Script += ReadString2Qw(e.Params[1]);
+ break;
+ }
+ case EW_ASSIGNVAR:
+ {
+ Script += " ";
+ Script += GetVar(e.Params[0]);;
+ Script += " ";
+ Script += ReadString2Qw(e.Params[1]);
+ AString maxLen, startOffset;
+ if (e.Params[2] != 0)
+ maxLen = ReadString2(e.Params[2]);
+ if (e.Params[3] != 0)
+ startOffset = ReadString2(e.Params[3]);
+ if (!maxLen.IsEmpty() || !startOffset.IsEmpty())
+ {
+ Script += " ";
+ if (maxLen.IsEmpty())
+ Script += "\"\"";
+ else
+ Script += maxLen;
+ if (!startOffset.IsEmpty())
+ {
+ Script += " ";
+ Script += startOffset;
+ }
+ }
+ break;
+ }
+ case EW_STRCMP:
+ {
+ Script += " ";
+
+ Script += " ";
+ Script += ReadString2Qw(e.Params[0]);
+
+ Script += " ";
+ Script += ReadString2Qw(e.Params[1]);
+
+ for (int j = 2; j < 5; j++)
+ {
+ Script += " ";
+ Script += UIntToString(e.Params[j]);
+ }
+ break;
+ }
+ case EW_INTCMP:
+ {
+ if (e.Params[5] != 0)
+ Script += "U";
+
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += ReadString2(e.Params[1]);
+
+ for (int i = 2; i < 5; i++)
+ {
+ Script += " ";
+ Script += UIntToString(e.Params[i]);
+ }
+ break;
+ }
+ case EW_INTOP:
+ {
+ Script += " ";
+ Script += GetVar(e.Params[0]);
+ Script += " ";
+ int numOps = 2;
+ AString op;
+ switch (e.Params[3])
+ {
+ case 0: op = '+'; break;
+ case 1: op = '-'; break;
+ case 2: op = '*'; break;
+ case 3: op = '/'; break;
+ case 4: op = '|'; break;
+ case 5: op = '&'; break;
+ case 6: op = '^'; break;
+ case 7: op = '~'; numOps = 1; break;
+ case 8: op = '!'; numOps = 1; break;
+ case 9: op = "||"; break;
+ case 10: op = "&&"; break;
+ case 11: op = '%'; break;
+ default: op = UIntToString(e.Params[3]);
+ }
+ AString p1 = ReadString2(e.Params[1]);
+ if (numOps == 1)
+ {
+ Script += op;
+ Script += p1;
+ }
+ else
+ {
+ Script += p1;
+ Script += " ";
+ Script += op;
+ Script += " ";
+ Script += ReadString2(e.Params[2]);
+ }
+ break;
+ }
+
+ case EW_PUSHPOP:
+ {
+ int isPop = (e.Params[1] != 0);
+ if (isPop)
+ {
+ Script += "Pop";
+ Script += " ";
+ Script += GetVar(e.Params[0]);;
+ }
+ else
+ {
+ int isExch = (e.Params[2] != 0);
+ if (isExch)
+ {
+ Script += "Exch";
+ }
+ else
+ {
+ Script += "Push";
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ }
+ }
+ break;
+ }
+
+ case EW_SENDMESSAGE:
+ {
+ // SendMessage: 6 [output, hwnd, msg, wparam, lparam, [wparamstring?1:0 | lparamstring?2:0 | timeout<<2]
+ Script += " ";
+ // Script += ReadString2(e.Params[0]);
+ // Script += " ";
+ Script += ReadString2(e.Params[1]);
+ Script += " ";
+ Script += ReadString2(e.Params[2]);
+
+ Script += " ";
+ UInt32 spec = e.Params[5];
+ // if (spec & 1)
+ Script += IntToString(e.Params[3]);
+ // else
+ // Script += ReadString2(e.Params[3]);
+
+ Script += " ";
+ // if (spec & 2)
+ Script += IntToString(e.Params[4]);
+ // else
+ // Script += ReadString2(e.Params[4]);
+
+ if ((Int32)e.Params[0] >= 0)
+ {
+ Script += " ";
+ Script += GetVar(e.Params[1]);
+ }
+
+ spec >>= 2;
+ if (spec != 0)
+ {
+ Script += " /TIMEOUT=";
+ Script += IntToString(spec);
+ }
+ break;
+ }
+
+ case EW_GETDLGITEM:
+ {
+ Script += " ";
+ Script += GetVar(e.Params[0]);;
+ Script += " ";
+ Script += ReadString2(e.Params[1]);
+ Script += " ";
+ Script += ReadString2(e.Params[2]);
+ break;
+ }
+
+
+ case EW_REGISTERDLL:
+ {
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += ReadString2(e.Params[1]);
+ Script += " ";
+ Script += UIntToString(e.Params[2]);
+ break;
+ }
+
+ case EW_CREATESHORTCUT:
+ {
+ AString s;
+
+ Script += " ";
+ Script += ReadString2Qw(e.Params[0]);
+
+ Script += " ";
+ Script += ReadString2Qw(e.Params[1]);
+
+ for (int j = 2; j < 5; j++)
+ {
+ Script += " ";
+ Script += UIntToString(e.Params[j]);
+ }
+ break;
+ }
+
+ /*
+ case EW_DELREG:
+ {
+ AString keyName, valueName;
+ keyName = ReadString2(e.Params[1]);
+ bool isValue = (e.Params[2] != -1);
+ if (isValue)
+ {
+ valueName = ReadString2(e.Params[2]);
+ Script += "Key";
+ }
+ else
+ Script += "Value";
+ Script += " ";
+ Script += UIntToString(e.Params[0]);
+ Script += " ";
+ Script += keyName;
+ if (isValue)
+ {
+ Script += " ";
+ Script += valueName;
+ }
+ Script += " ";
+ Script += UIntToString(e.Params[3]);
+ break;
+ }
+ */
+
+ case EW_WRITEREG:
+ {
+ AString s;
+ switch(e.Params[4])
+ {
+ case 1: s = "Str"; break;
+ case 2: s = "ExpandStr"; break;
+ case 3: s = "Bin"; break;
+ case 4: s = "DWORD"; break;
+ default: s = "?" + UIntToString(e.Params[4]); break;
+ }
+ Script += s;
+ Script += " ";
+ Script += GetRegRootID(e.Params[0]);
+ Script += " ";
+
+ AString keyName, valueName;
+ keyName = ReadString2Qw(e.Params[1]);
+ Script += keyName;
+ Script += " ";
+
+ valueName = ReadString2Qw(e.Params[2]);
+ Script += valueName;
+ Script += " ";
+
+ valueName = ReadString2Qw(e.Params[3]);
+ Script += valueName;
+ Script += " ";
+
+ break;
+ }
+
+ case EW_WRITEUNINSTALLER:
+ {
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ for (int j = 1; j < 3; j++)
+ {
+ Script += " ";
+ Script += UIntToString(e.Params[j]);
+ }
+ break;
+ }
+
+ default:
+ {
+ int numParams = kNumEntryParams;
+ if (e.Which < sizeof(kCommandPairs) / sizeof(kCommandPairs[0]))
+ {
+ const CCommandPair &pair = kCommandPairs[e.Which];
+ // Script += pair.Name;
+ numParams = pair.NumParams;
+ }
+ else
+ {
+ Script += "Unknown";
+ Script += UIntToString(e.Which);
+ }
+ Script += e.GetParamsString(numParams);
+ }
+ #endif
+ }
+ #ifdef NSIS_SCRIPT
+ Script += kCrLf;
+ #endif
+ }
+
+ {
+ Items.Sort(CompareItems, 0);
+ int i;
+ // if (IsSolid)
+ for (i = 0; i + 1 < Items.Size();)
+ {
+ bool sameName = IsUnicode ?
+ (Items[i].NameU == Items[i + 1].NameU) :
+ (Items[i].NameA == Items[i + 1].NameA);
+ if (Items[i].Pos == Items[i + 1].Pos && (IsSolid || sameName))
+ Items.Delete(i + 1);
+ else
+ i++;
+ }
+ for (i = 0; i + 1 < Items.Size(); i++)
+ {
+ CItem &item = Items[i];
+ item.EstimatedSizeIsDefined = true;
+ item.EstimatedSize = Items[i + 1].Pos - item.Pos - 4;
+ }
+ if (!IsSolid)
+ {
+ for (i = 0; i < Items.Size(); i++)
+ {
+ CItem &item = Items[i];
+ RINOK(_stream->Seek(GetPosOfNonSolidItem(i), STREAM_SEEK_SET, NULL));
+ const UInt32 kSigSize = 4 + 1 + 5;
+ BYTE sig[kSigSize];
+ size_t processedSize = kSigSize;
+ RINOK(ReadStream(_stream, sig, &processedSize));
+ if (processedSize < 4)
+ return S_FALSE;
+ UInt32 size = Get32(sig);
+ if ((size & 0x80000000) != 0)
+ {
+ item.IsCompressed = true;
+ // is compressed;
+ size &= ~0x80000000;
+ if (Method == NMethodType::kLZMA)
+ {
+ if (processedSize < 9)
+ return S_FALSE;
+ if (FilterFlag)
+ item.UseFilter = (sig[4] != 0);
+ item.DictionarySize = Get32(sig + 5 + (FilterFlag ? 1 : 0));
+ }
+ }
+ else
+ {
+ item.IsCompressed = false;
+ item.Size = size;
+ item.SizeIsDefined = true;
+ }
+ item.CompressedSize = size;
+ item.CompressedSizeIsDefined = true;
+ }
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CInArchive::Parse()
+{
+ // UInt32 offset = ReadUInt32();
+ // ???? offset == FirstHeader.HeaderLength
+ /* UInt32 ehFlags = */ ReadUInt32();
+ CBlockHeader bhPages, bhSections, bhEntries, bhStrings, bhLangTables, bhCtlColors, bhData;
+ // CBlockHeader bgFont;
+ ReadBlockHeader(bhPages);
+ ReadBlockHeader(bhSections);
+ ReadBlockHeader(bhEntries);
+ ReadBlockHeader(bhStrings);
+ ReadBlockHeader(bhLangTables);
+ ReadBlockHeader(bhCtlColors);
+ // ReadBlockHeader(bgFont);
+ ReadBlockHeader(bhData);
+
+ _stringsPos = bhStrings.Offset;
+ UInt32 pos = GetOffset() + _stringsPos;
+ int numZeros0 = 0;
+ int numZeros1 = 0;
+ int i;
+ const int kBlockSize = 256;
+ for (i = 0; i < kBlockSize; i++)
+ {
+ if (pos >= _size || pos + 1 >= _size)
+ break;
+ char c0 = _data[pos++];
+ char c1 = _data[pos++];
+ wchar_t c = (c0 | ((wchar_t)c1 << 8));
+
+ if (c >= NS_UN_CODES_START && c < NS_UN_CODES_END)
+ {
+ if (pos >= _size || pos + 1 >= _size)
+ break;
+ pos += 2;
+ numZeros1++;
+ }
+ else
+ {
+ if (c0 == 0 && c1 != 0)
+ numZeros0++;
+ if (c1 == 0)
+ numZeros1++;
+ }
+ // printf("\nnumZeros0 = %2x %2x", _data[pos + 0], _data[pos + 1]);
+ }
+ IsUnicode = (numZeros1 > numZeros0 * 3 + kBlockSize / 16);
+ // printf("\nnumZeros0 = %3d numZeros1 = %3d", numZeros0, numZeros1);
+ return ReadEntries(bhEntries);
+}
+
+static bool IsLZMA(const Byte *p, UInt32 &dictionary)
+{
+ dictionary = Get32(p + 1);
+ return (p[0] == 0x5D && p[1] == 0x00 && p[2] == 0x00 && p[5] == 0x00);
+}
+
+static bool IsLZMA(const Byte *p, UInt32 &dictionary, bool &thereIsFlag)
+{
+ if (IsLZMA(p, dictionary))
+ {
+ thereIsFlag = false;
+ return true;
+ }
+ if (IsLZMA(p + 1, dictionary))
+ {
+ thereIsFlag = true;
+ return true;
+ }
+ return false;
+}
+
+HRESULT CInArchive::Open2(
+ DECL_EXTERNAL_CODECS_LOC_VARS2
+ )
+{
+ RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &StreamOffset));
+
+ const UInt32 kSigSize = 4 + 1 + 5 + 1; // size, flag, lzma props, lzma first byte
+ BYTE sig[kSigSize];
+ RINOK(ReadStream_FALSE(_stream, sig, kSigSize));
+ UInt64 position;
+ RINOK(_stream->Seek(StreamOffset, STREAM_SEEK_SET, &position));
+
+ _headerIsCompressed = true;
+ IsSolid = true;
+ FilterFlag = false;
+
+ UInt32 compressedHeaderSize = Get32(sig);
+
+ if (compressedHeaderSize == FirstHeader.HeaderLength)
+ {
+ _headerIsCompressed = false;
+ IsSolid = false;
+ Method = NMethodType::kCopy;
+ }
+ else if (IsLZMA(sig, DictionarySize, FilterFlag))
+ {
+ Method = NMethodType::kLZMA;
+ }
+ else if (IsLZMA(sig + 4, DictionarySize, FilterFlag))
+ {
+ IsSolid = false;
+ Method = NMethodType::kLZMA;
+ }
+ else if (sig[3] == 0x80)
+ {
+ IsSolid = false;
+ Method = NMethodType::kDeflate;
+ }
+ else
+ {
+ Method = NMethodType::kDeflate;
+ }
+
+ _posInData = 0;
+ if (!IsSolid)
+ {
+ _headerIsCompressed = ((compressedHeaderSize & 0x80000000) != 0);
+ if (_headerIsCompressed)
+ compressedHeaderSize &= ~0x80000000;
+ _nonSolidStartOffset = compressedHeaderSize;
+ RINOK(_stream->Seek(StreamOffset + 4, STREAM_SEEK_SET, NULL));
+ }
+ UInt32 unpackSize = FirstHeader.HeaderLength;
+ if (_headerIsCompressed)
+ {
+ // unpackSize = (1 << 23);
+ _data.SetCapacity(unpackSize);
+ RINOK(Decoder.Init(
+ EXTERNAL_CODECS_LOC_VARS
+ _stream, Method, FilterFlag, UseFilter));
+ size_t processedSize = unpackSize;
+ RINOK(Decoder.Read(_data, &processedSize));
+ if (processedSize != unpackSize)
+ return S_FALSE;
+ _size = processedSize;
+ if (IsSolid)
+ {
+ UInt32 size2 = ReadUInt32();
+ if (size2 < _size)
+ _size = size2;
+ }
+ }
+ else
+ {
+ _data.SetCapacity(unpackSize);
+ _size = (size_t)unpackSize;
+ RINOK(ReadStream_FALSE(_stream, (Byte *)_data, unpackSize));
+ }
+ return Parse();
+}
+
+/*
+NsisExe =
+{
+ ExeStub
+ Archive // must start from 512 * N
+ #ifndef NSIS_CONFIG_CRC_ANAL
+ {
+ Some additional data
+ }
+}
+
+Archive
+{
+ FirstHeader
+ Data
+ #ifdef NSIS_CONFIG_CRC_SUPPORT && FirstHeader.ThereIsCrc()
+ {
+ CRC
+ }
+}
+
+FirstHeader
+{
+ UInt32 Flags;
+ Byte Signature[16];
+ // points to the header+sections+entries+stringtable in the datablock
+ UInt32 HeaderLength;
+ UInt32 ArchiveSize;
+}
+*/
+
+HRESULT CInArchive::Open(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IInStream *inStream, const UInt64 *maxCheckStartPosition)
+{
+ Clear();
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ UInt64 maxSize = ((maxCheckStartPosition != 0) ? *maxCheckStartPosition : 0);
+ const UInt32 kStep = 512;
+ Byte buffer[kStep];
+
+ UInt64 position = 0;
+ for (; position <= maxSize; position += kStep)
+ {
+ RINOK(ReadStream_FALSE(inStream, buffer, kStep));
+ if (memcmp(buffer + 4, kSignature, kSignatureSize) == 0)
+ break;
+ }
+ if (position > maxSize)
+ return S_FALSE;
+ const UInt32 kStartHeaderSize = 4 * 7;
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &_archiveSize));
+ RINOK(inStream->Seek(position + kStartHeaderSize, STREAM_SEEK_SET, 0));
+ FirstHeader.Flags = Get32(buffer);
+ FirstHeader.HeaderLength = Get32(buffer + kSignatureSize + 4);
+ FirstHeader.ArchiveSize = Get32(buffer + kSignatureSize + 8);
+ if (_archiveSize - position < FirstHeader.ArchiveSize)
+ return S_FALSE;
+
+ try
+ {
+ _stream = inStream;
+ HRESULT res = Open2(EXTERNAL_CODECS_LOC_VARS2);
+ if (res != S_OK)
+ Clear();
+ _stream.Release();
+ return res;
+ }
+ catch(...) { Clear(); return S_FALSE; }
+}
+
+void CInArchive::Clear()
+{
+ #ifdef NSIS_SCRIPT
+ Script.Empty();
+ #endif
+ Items.Clear();
+ _stream.Release();
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisIn.h
new file mode 100644
index 000000000..1fa6b4a6d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisIn.h
@@ -0,0 +1,184 @@
+// Archive/NsisIn.h
+
+#ifndef __ARCHIVE_NSIS_IN_H
+#define __ARCHIVE_NSIS_IN_H
+
+#include "Common/Buffer.h"
+#include "Common/IntToString.h"
+#include "Common/MyCom.h"
+#include "Common/StringConvert.h"
+
+#include "../../Common/CreateCoder.h"
+
+#include "../../IStream.h"
+
+#include "NsisDecode.h"
+
+// #define NSIS_SCRIPT
+
+namespace NArchive {
+namespace NNsis {
+
+const int kSignatureSize = 16;
+extern Byte kSignature[kSignatureSize];
+
+const UInt32 kFlagsMask = 0xF;
+namespace NFlags
+{
+ const UInt32 kUninstall = 1;
+ const UInt32 kSilent = 2;
+ const UInt32 kNoCrc = 4;
+ const UInt32 kForceCrc = 8;
+}
+
+struct CFirstHeader
+{
+ UInt32 Flags;
+ UInt32 HeaderLength;
+
+ UInt32 ArchiveSize;
+
+ bool ThereIsCrc() const
+ {
+ if ((Flags & NFlags::kForceCrc ) != 0)
+ return true;
+ return ((Flags & NFlags::kNoCrc) == 0);
+ }
+
+ UInt32 GetDataSize() const { return ArchiveSize - (ThereIsCrc() ? 4 : 0); }
+};
+
+
+struct CBlockHeader
+{
+ UInt32 Offset;
+ UInt32 Num;
+};
+
+struct CItem
+{
+ AString PrefixA;
+ UString PrefixU;
+ AString NameA;
+ UString NameU;
+ FILETIME MTime;
+ bool IsUnicode;
+ bool UseFilter;
+ bool IsCompressed;
+ bool SizeIsDefined;
+ bool CompressedSizeIsDefined;
+ bool EstimatedSizeIsDefined;
+ UInt32 Pos;
+ UInt32 Size;
+ UInt32 CompressedSize;
+ UInt32 EstimatedSize;
+ UInt32 DictionarySize;
+
+ CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false),
+ CompressedSizeIsDefined(false), EstimatedSizeIsDefined(false), Size(0) {}
+
+ bool IsINSTDIR() const
+ {
+ return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3);
+ }
+
+ UString GetReducedName(bool unicode) const
+ {
+ UString s;
+ if (unicode)
+ s = PrefixU;
+ else
+ s = MultiByteToUnicodeString(PrefixA);
+ if (s.Length() > 0)
+ if (s[s.Length() - 1] != L'\\')
+ s += L'\\';
+ if (unicode)
+ s += NameU;
+ else
+ s += MultiByteToUnicodeString(NameA);
+ const int len = 9;
+ if (s.Left(len).CompareNoCase(L"$INSTDIR\\") == 0)
+ s = s.Mid(len);
+ return s;
+ }
+};
+
+class CInArchive
+{
+ UInt64 _archiveSize;
+ CMyComPtr<IInStream> _stream;
+
+ Byte ReadByte();
+ UInt32 ReadUInt32();
+ HRESULT Open2(
+ DECL_EXTERNAL_CODECS_LOC_VARS2
+ );
+ void ReadBlockHeader(CBlockHeader &bh);
+ AString ReadStringA(UInt32 pos) const;
+ UString ReadStringU(UInt32 pos) const;
+ AString ReadString2A(UInt32 pos) const;
+ UString ReadString2U(UInt32 pos) const;
+ AString ReadString2(UInt32 pos) const;
+ AString ReadString2Qw(UInt32 pos) const;
+ HRESULT ReadEntries(const CBlockHeader &bh);
+ HRESULT Parse();
+
+ CByteBuffer _data;
+ UInt64 _size;
+
+ size_t _posInData;
+
+ UInt32 _stringsPos;
+
+
+ bool _headerIsCompressed;
+ UInt32 _nonSolidStartOffset;
+public:
+ HRESULT Open(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IInStream *inStream, const UInt64 *maxCheckStartPosition);
+ void Clear();
+
+ UInt64 StreamOffset;
+ CDecoder Decoder;
+ CObjectVector<CItem> Items;
+ CFirstHeader FirstHeader;
+ NMethodType::EEnum Method;
+ UInt32 DictionarySize;
+ bool IsSolid;
+ bool UseFilter;
+ bool FilterFlag;
+ bool IsUnicode;
+
+ #ifdef NSIS_SCRIPT
+ AString Script;
+ #endif
+ UInt32 GetOffset() const { return IsSolid ? 4 : 0; }
+ UInt64 GetDataPos(int index)
+ {
+ const CItem &item = Items[index];
+ return GetOffset() + FirstHeader.HeaderLength + item.Pos;
+ }
+
+ UInt64 GetPosOfSolidItem(int index) const
+ {
+ const CItem &item = Items[index];
+ return 4 + FirstHeader.HeaderLength + item.Pos;
+ }
+
+ UInt64 GetPosOfNonSolidItem(int index) const
+ {
+ const CItem &item = Items[index];
+ return StreamOffset + _nonSolidStartOffset + 4 + item.Pos;
+ }
+
+ void Release()
+ {
+ Decoder.Release();
+ }
+
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisRegister.cpp
new file mode 100644
index 000000000..7e6f7acbb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Nsis/NsisRegister.cpp
@@ -0,0 +1,14 @@
+// NsisRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "NsisHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NNsis::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Nsis", 0, 0, 0x9, { 0xEF, 0xBE, 0xAD, 0xDE,
+0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74}, 16, false, CreateArc, 0 };
+
+REGISTER_ARC(Nsis)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/NtfsHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/NtfsHandler.cpp
new file mode 100644
index 000000000..37847a245
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/NtfsHandler.cpp
@@ -0,0 +1,1725 @@
+// NtfsHandler.cpp
+
+#include "StdAfx.h"
+
+// #define SHOW_DEBUG_INFO
+// #define SHOW_DEBUG_INFO2
+
+#if defined(SHOW_DEBUG_INFO) || defined(SHOW_DEBUG_INFO2)
+#include <stdio.h>
+#endif
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+#include "Common/MyCom.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#include "Common/DummyOutStream.h"
+
+#ifdef SHOW_DEBUG_INFO
+#define PRF(x) x
+#else
+#define PRF(x)
+#endif
+
+#ifdef SHOW_DEBUG_INFO2
+#define PRF2(x) x
+#else
+#define PRF2(x)
+#endif
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+#define G16(p, dest) dest = Get16(p);
+#define G32(p, dest) dest = Get32(p);
+#define G64(p, dest) dest = Get64(p);
+
+namespace NArchive {
+namespace Ntfs {
+
+static const UInt32 kNumSysRecs = 16;
+static const UInt32 kRecIndex_Volume = 3;
+static const UInt32 kRecIndex_BadClus = 8;
+
+struct CHeader
+{
+ Byte SectorSizeLog;
+ Byte ClusterSizeLog;
+ // Byte MediaType;
+ UInt32 NumHiddenSectors;
+ UInt64 NumClusters;
+ UInt64 MftCluster;
+ UInt64 SerialNumber;
+ UInt16 SectorsPerTrack;
+ UInt16 NumHeads;
+
+ UInt64 GetPhySize() const { return NumClusters << ClusterSizeLog; }
+ UInt32 ClusterSize() const { return (UInt32)1 << ClusterSizeLog; }
+ bool Parse(const Byte *p);
+};
+
+static int GetLog(UInt32 num)
+{
+ for (int i = 0; i < 31; i++)
+ if (((UInt32)1 << i) == num)
+ return i;
+ return -1;
+}
+
+bool CHeader::Parse(const Byte *p)
+{
+ if (p[0x1FE] != 0x55 || p[0x1FF] != 0xAA)
+ return false;
+
+ int codeOffset = 0;
+ switch (p[0])
+ {
+ case 0xE9: codeOffset = 3 + (Int16)Get16(p + 1); break;
+ case 0xEB: if (p[2] != 0x90) return false; codeOffset = 2 + (signed char)p[1]; break;
+ default: return false;
+ }
+ Byte sectorsPerClusterLog;
+
+ if (memcmp(p + 3, "NTFS ", 8) != 0)
+ return false;
+ {
+ int s = GetLog(Get16(p + 11));
+ if (s < 9 || s > 12)
+ return false;
+ SectorSizeLog = (Byte)s;
+ s = GetLog(p[13]);
+ if (s < 0)
+ return false;
+ sectorsPerClusterLog = (Byte)s;
+ ClusterSizeLog = SectorSizeLog + sectorsPerClusterLog;
+ }
+
+ for (int i = 14; i < 21; i++)
+ if (p[i] != 0)
+ return false;
+
+ // MediaType = p[21];
+ if (Get16(p + 22) != 0) // NumFatSectors
+ return false;
+ G16(p + 24, SectorsPerTrack);
+ G16(p + 26, NumHeads);
+ G32(p + 28, NumHiddenSectors);
+ if (Get32(p + 32) != 0) // NumSectors32
+ return false;
+
+ // DriveNumber = p[0x24];
+ if (p[0x25] != 0) // CurrentHead
+ return false;
+ if (p[0x26] != 0x80) // ExtendedBootSig
+ return false;
+ if (p[0x27] != 0) // reserved
+ return false;
+ UInt64 numSectors = Get64(p + 0x28);
+ NumClusters = numSectors >> sectorsPerClusterLog;
+
+ G64(p + 0x30, MftCluster);
+ // G64(p + 0x38, Mft2Cluster);
+ G64(p + 0x48, SerialNumber);
+ UInt32 numClustersInMftRec;
+ UInt32 numClustersInIndexBlock;
+ G32(p + 0x40, numClustersInMftRec);
+ G32(p + 0x44, numClustersInIndexBlock);
+ return (numClustersInMftRec < 256 && numClustersInIndexBlock < 256);
+}
+
+struct CMftRef
+{
+ UInt64 Val;
+ UInt64 GetIndex() const { return Val & (((UInt64)1 << 48) - 1); }
+ UInt16 GetNumber() const { return (UInt16)(Val >> 48); }
+ bool IsBaseItself() const { return Val == 0; }
+};
+
+#define ATNAME(n) ATTR_TYPE_ ## n
+#define DEF_ATTR_TYPE(v, n) ATNAME(n) = v
+
+typedef enum
+{
+ DEF_ATTR_TYPE(0x00, UNUSED),
+ DEF_ATTR_TYPE(0x10, STANDARD_INFO),
+ DEF_ATTR_TYPE(0x20, ATTRIBUTE_LIST),
+ DEF_ATTR_TYPE(0x30, FILE_NAME),
+ DEF_ATTR_TYPE(0x40, OBJECT_ID),
+ DEF_ATTR_TYPE(0x50, SECURITY_DESCRIPTOR),
+ DEF_ATTR_TYPE(0x60, VOLUME_NAME),
+ DEF_ATTR_TYPE(0x70, VOLUME_INFO),
+ DEF_ATTR_TYPE(0x80, DATA),
+ DEF_ATTR_TYPE(0x90, INDEX_ROOT),
+ DEF_ATTR_TYPE(0xA0, INDEX_ALLOCATION),
+ DEF_ATTR_TYPE(0xB0, BITMAP),
+ DEF_ATTR_TYPE(0xC0, REPARSE_POINT),
+ DEF_ATTR_TYPE(0xD0, EA_INFO),
+ DEF_ATTR_TYPE(0xE0, EA),
+ DEF_ATTR_TYPE(0xF0, PROPERTY_SET),
+ DEF_ATTR_TYPE(0x100, LOGGED_UTILITY_STREAM),
+ DEF_ATTR_TYPE(0x1000, FIRST_USER_DEFINED_ATTRIBUTE)
+};
+
+static const Byte kFileNameType_Posix = 0;
+static const Byte kFileNameType_Win32 = 1;
+static const Byte kFileNameType_Dos = 2;
+static const Byte kFileNameType_Win32Dos = 3;
+
+struct CFileNameAttr
+{
+ CMftRef ParentDirRef;
+ // UInt64 CTime;
+ // UInt64 MTime;
+ // UInt64 ThisRecMTime;
+ // UInt64 ATime;
+ // UInt64 AllocatedSize;
+ // UInt64 DataSize;
+ // UInt16 PackedEaSize;
+ UString Name;
+ UInt32 Attrib;
+ Byte NameType;
+
+ bool IsDos() const { return NameType == kFileNameType_Dos; }
+ bool Parse(const Byte *p, unsigned size);
+};
+
+static void GetString(const Byte *p, unsigned length, UString &res)
+{
+ wchar_t *s = res.GetBuffer(length);
+ for (unsigned i = 0; i < length; i++)
+ s[i] = Get16(p + i * 2);
+ s[length] = 0;
+ res.ReleaseBuffer();
+}
+
+bool CFileNameAttr::Parse(const Byte *p, unsigned size)
+{
+ if (size < 0x42)
+ return false;
+ G64(p + 0x00, ParentDirRef.Val);
+ // G64(p + 0x08, CTime);
+ // G64(p + 0x10, MTime);
+ // G64(p + 0x18, ThisRecMTime);
+ // G64(p + 0x20, ATime);
+ // G64(p + 0x28, AllocatedSize);
+ // G64(p + 0x30, DataSize);
+ G32(p + 0x38, Attrib);
+ // G16(p + 0x3C, PackedEaSize);
+ NameType = p[0x41];
+ unsigned length = p[0x40];
+ if (0x42 + length > size)
+ return false;
+ GetString(p + 0x42, length, Name);
+ return true;
+}
+
+struct CSiAttr
+{
+ UInt64 CTime;
+ UInt64 MTime;
+ // UInt64 ThisRecMTime;
+ UInt64 ATime;
+ UInt32 Attrib;
+
+ /*
+ UInt32 MaxVersions;
+ UInt32 Version;
+ UInt32 ClassId;
+ UInt32 OwnerId;
+ UInt32 SecurityId;
+ UInt64 QuotaCharged;
+ */
+
+ bool Parse(const Byte *p, unsigned size);
+};
+
+bool CSiAttr::Parse(const Byte *p, unsigned size)
+{
+ if (size < 0x24)
+ return false;
+ G64(p + 0x00, CTime);
+ G64(p + 0x08, MTime);
+ // G64(p + 0x10, ThisRecMTime);
+ G64(p + 0x18, ATime);
+ G32(p + 0x20, Attrib);
+ return true;
+}
+
+static const UInt64 kEmptyExtent = (UInt64)(Int64)-1;
+
+struct CExtent
+{
+ UInt64 Virt;
+ UInt64 Phy;
+
+ bool IsEmpty() const { return Phy == kEmptyExtent; }
+};
+
+struct CVolInfo
+{
+ Byte MajorVer;
+ Byte MinorVer;
+ // UInt16 Flags;
+
+ bool Parse(const Byte *p, unsigned size);
+};
+
+bool CVolInfo::Parse(const Byte *p, unsigned size)
+{
+ if (size < 12)
+ return false;
+ MajorVer = p[8];
+ MinorVer = p[9];
+ // Flags = Get16(p + 10);
+ return true;
+}
+
+struct CAttr
+{
+ UInt32 Type;
+ // UInt32 Length;
+ UString Name;
+ // UInt16 Flags;
+ // UInt16 Instance;
+ CByteBuffer Data;
+ Byte NonResident;
+
+ // Non-Resident
+ Byte CompressionUnit;
+ UInt64 LowVcn;
+ UInt64 HighVcn;
+ UInt64 AllocatedSize;
+ UInt64 Size;
+ UInt64 PackSize;
+ UInt64 InitializedSize;
+
+ // Resident
+ // UInt16 ResidentFlags;
+
+ bool IsCompressionUnitSupported() const { return CompressionUnit == 0 || CompressionUnit == 4; }
+
+ UInt32 Parse(const Byte *p, unsigned size);
+ bool ParseFileName(CFileNameAttr &a) const { return a.Parse(Data, (unsigned)Data.GetCapacity()); }
+ bool ParseSi(CSiAttr &a) const { return a.Parse(Data, (unsigned)Data.GetCapacity()); }
+ bool ParseVolInfo(CVolInfo &a) const { return a.Parse(Data, (unsigned)Data.GetCapacity()); }
+ bool ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax, int compressionUnit) const;
+ UInt64 GetSize() const { return NonResident ? Size : Data.GetCapacity(); }
+ UInt64 GetPackSize() const
+ {
+ if (!NonResident)
+ return Data.GetCapacity();
+ if (CompressionUnit != 0)
+ return PackSize;
+ return AllocatedSize;
+ }
+};
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+static int CompareAttr(void *const *elem1, void *const *elem2, void *)
+{
+ const CAttr &a1 = *(*((const CAttr **)elem1));
+ const CAttr &a2 = *(*((const CAttr **)elem2));
+ RINOZ(MyCompare(a1.Type, a2.Type));
+ RINOZ(MyCompare(a1.Name, a2.Name));
+ return MyCompare(a1.LowVcn, a2.LowVcn);
+}
+
+UInt32 CAttr::Parse(const Byte *p, unsigned size)
+{
+ if (size < 4)
+ return 0;
+ G32(p, Type);
+ if (Type == 0xFFFFFFFF)
+ return 4;
+ if (size < 0x18)
+ return 0;
+ PRF(printf(" T=%2X", Type));
+
+ UInt32 length = Get32(p + 0x04);
+ PRF(printf(" L=%3d", length));
+ if (length > size)
+ return 0;
+ NonResident = p[0x08];
+ {
+ int nameLength = p[9];
+ UInt32 nameOffset = Get16(p + 0x0A);
+ if (nameLength != 0)
+ {
+ if (nameOffset + nameLength * 2 > length)
+ return 0;
+ GetString(p + nameOffset, nameLength, Name);
+ PRF(printf(" N=%S", Name));
+ }
+ }
+
+ // G16(p + 0x0C, Flags);
+ // G16(p + 0x0E, Instance);
+ // PRF(printf(" F=%4X", Flags));
+ // PRF(printf(" Inst=%d", Instance));
+
+ UInt32 dataSize;
+ UInt32 offs;
+ if (NonResident)
+ {
+ if (length < 0x40)
+ return 0;
+ PRF(printf(" NR"));
+ G64(p + 0x10, LowVcn);
+ G64(p + 0x18, HighVcn);
+ G64(p + 0x28, AllocatedSize);
+ G64(p + 0x30, Size);
+ G64(p + 0x38, InitializedSize);
+ G16(p + 0x20, offs);
+ CompressionUnit = p[0x22];
+
+ PackSize = Size;
+ if (CompressionUnit != 0)
+ {
+ if (length < 0x48)
+ return 0;
+ G64(p + 0x40, PackSize);
+ PRF(printf(" PS=%I64x", PackSize));
+ }
+
+ // PRF(printf("\n"));
+ PRF(printf(" ASize=%4I64d", AllocatedSize));
+ PRF(printf(" Size=%I64d", Size));
+ PRF(printf(" IS=%I64d", InitializedSize));
+ PRF(printf(" Low=%I64d", LowVcn));
+ PRF(printf(" High=%I64d", HighVcn));
+ PRF(printf(" CU=%d", (int)CompressionUnit));
+ dataSize = length - offs;
+ }
+ else
+ {
+ if (length < 0x18)
+ return 0;
+ PRF(printf(" RES"));
+ dataSize = Get32(p + 0x10);
+ PRF(printf(" dataSize=%3d", dataSize));
+ offs = Get16(p + 0x14);
+ // G16(p + 0x16, ResidentFlags);
+ // PRF(printf(" ResFlags=%4X", ResidentFlags));
+ }
+ if (offs > length || dataSize > length || length - dataSize < offs)
+ return 0;
+ Data.SetCapacity(dataSize);
+ memcpy(Data, p + offs, dataSize);
+ #ifdef SHOW_DEBUG_INFO
+ PRF(printf(" : "));
+ for (unsigned i = 0; i < Data.GetCapacity(); i++)
+ {
+ PRF(printf(" %02X", (int)Data[i]));
+ }
+ #endif
+ return length;
+}
+
+bool CAttr::ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax, int compressionUnit) const
+{
+ const Byte *p = Data;
+ unsigned size = (unsigned)Data.GetCapacity();
+ UInt64 vcn = LowVcn;
+ UInt64 lcn = 0;
+ UInt64 highVcn1 = HighVcn + 1;
+ if (LowVcn != extents.Back().Virt || highVcn1 > (UInt64)1 << 63)
+ return false;
+
+ extents.DeleteBack();
+
+ PRF2(printf("\n# ParseExtents # LowVcn = %4I64X # HighVcn = %4I64X", LowVcn, HighVcn));
+
+ while (size > 0)
+ {
+ Byte b = *p++;
+ size--;
+ if (b == 0)
+ break;
+ UInt32 num = b & 0xF;
+ if (num == 0 || num > 8 || num > size)
+ return false;
+
+ int i;
+ UInt64 vSize = p[num - 1];
+ for (i = (int)num - 2; i >= 0; i--)
+ vSize = (vSize << 8) | p[i];
+ if (vSize == 0)
+ return false;
+ p += num;
+ size -= num;
+ if ((highVcn1 - vcn) < vSize)
+ return false;
+
+ num = (b >> 4) & 0xF;
+ if (num > 8 || num > size)
+ return false;
+ CExtent e;
+ e.Virt = vcn;
+ if (num == 0)
+ {
+ if (compressionUnit == 0)
+ return false;
+ e.Phy = kEmptyExtent;
+ }
+ else
+ {
+ Int64 v = (signed char)p[num - 1];
+ for (i = (int)num - 2; i >= 0; i--)
+ v = (v << 8) | p[i];
+ p += num;
+ size -= num;
+ lcn += v;
+ if (lcn > numClustersMax)
+ return false;
+ e.Phy = lcn;
+ }
+ extents.Add(e);
+ vcn += vSize;
+ }
+ CExtent e;
+ e.Phy = kEmptyExtent;
+ e.Virt = vcn;
+ extents.Add(e);
+ return (highVcn1 == vcn);
+}
+
+static const UInt64 kEmptyTag = (UInt64)(Int64)-1;
+
+static const int kNumCacheChunksLog = 1;
+static const UInt32 kNumCacheChunks = (1 << kNumCacheChunksLog);
+
+class CInStream:
+ public IInStream,
+ public CMyUnknownImp
+{
+ UInt64 _virtPos;
+ UInt64 _physPos;
+ UInt64 _curRem;
+ bool _sparseMode;
+ size_t _compressedPos;
+
+ UInt64 _tags[kNumCacheChunks];
+ int _chunkSizeLog;
+ CByteBuffer _inBuf;
+ CByteBuffer _outBuf;
+public:
+ CMyComPtr<IInStream> Stream;
+ UInt64 Size;
+ UInt64 InitializedSize;
+ int BlockSizeLog;
+ int CompressionUnit;
+ bool InUse;
+ CRecordVector<CExtent> Extents;
+
+ HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
+
+ UInt32 GetCuSize() const { return (UInt32)1 << (BlockSizeLog + CompressionUnit); }
+ HRESULT InitAndSeek(int compressionUnit)
+ {
+ CompressionUnit = compressionUnit;
+ if (compressionUnit != 0)
+ {
+ UInt32 cuSize = GetCuSize();
+ _inBuf.SetCapacity(cuSize);
+ _chunkSizeLog = BlockSizeLog + CompressionUnit;
+ _outBuf.SetCapacity(kNumCacheChunks << _chunkSizeLog);
+ }
+ for (int i = 0; i < kNumCacheChunks; i++)
+ _tags[i] = kEmptyTag;
+
+ _sparseMode = false;
+ _curRem = 0;
+ _virtPos = 0;
+ _physPos = 0;
+ const CExtent &e = Extents[0];
+ if (!e.IsEmpty())
+ _physPos = e.Phy << BlockSizeLog;
+ return SeekToPhys();
+ }
+
+ MY_UNKNOWN_IMP1(IInStream)
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+};
+
+static size_t Lznt1Dec(Byte *dest, size_t outBufLim, size_t destLen, const Byte *src, size_t srcLen)
+{
+ size_t destSize = 0;
+ while (destSize < destLen)
+ {
+ if (srcLen < 2 || (destSize & 0xFFF) != 0)
+ break;
+ UInt32 v = Get16(src);
+ if (v == 0)
+ break;
+ src += 2;
+ srcLen -= 2;
+ UInt32 comprSize = (v & 0xFFF) + 1;
+ if (comprSize > srcLen)
+ break;
+ srcLen -= comprSize;
+ if ((v & 0x8000) == 0)
+ {
+ if (comprSize != (1 << 12))
+ break;
+ memcpy(dest + destSize, src, comprSize);
+ src += comprSize;
+ destSize += comprSize;
+ }
+ else
+ {
+ if (destSize + (1 << 12) > outBufLim || (src[0] & 1) != 0)
+ return 0;
+ int numDistBits = 4;
+ UInt32 sbOffset = 0;
+ UInt32 pos = 0;
+
+ do
+ {
+ comprSize--;
+ for (UInt32 mask = src[pos++] | 0x100; mask > 1 && comprSize > 0; mask >>= 1)
+ {
+ if ((mask & 1) == 0)
+ {
+ if (sbOffset >= (1 << 12))
+ return 0;
+ dest[destSize++] = src[pos++];
+ sbOffset++;
+ comprSize--;
+ }
+ else
+ {
+ if (comprSize < 2)
+ return 0;
+ UInt32 v = Get16(src + pos);
+ pos += 2;
+ comprSize -= 2;
+
+ while (((sbOffset - 1) >> numDistBits) != 0)
+ numDistBits++;
+
+ UInt32 len = (v & (0xFFFF >> numDistBits)) + 3;
+ if (sbOffset + len > (1 << 12))
+ return 0;
+ UInt32 dist = (v >> (16 - numDistBits));
+ if (dist >= sbOffset)
+ return 0;
+ Int32 offs = -1 - dist;
+ Byte *p = dest + destSize;
+ for (UInt32 t = 0; t < len; t++)
+ p[t] = p[t + offs];
+ destSize += len;
+ sbOffset += len;
+ }
+ }
+ }
+ while (comprSize > 0);
+ src += pos;
+ }
+ }
+ return destSize;
+}
+
+STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ if (_virtPos >= Size)
+ return (Size == _virtPos) ? S_OK: E_FAIL;
+ if (size == 0)
+ return S_OK;
+ UInt64 rem = Size - _virtPos;
+ if (size > rem)
+ size = (UInt32)rem;
+ if (_virtPos >= InitializedSize)
+ {
+ memset((Byte *)data, 0, size);
+ _virtPos += size;
+ *processedSize = size;
+ return S_OK;
+ }
+ rem = InitializedSize - _virtPos;
+ if (size > rem)
+ size = (UInt32)rem;
+
+ while (_curRem == 0)
+ {
+ UInt64 cacheTag = _virtPos >> _chunkSizeLog;
+ UInt32 cacheIndex = (UInt32)cacheTag & (kNumCacheChunks - 1);
+ if (_tags[cacheIndex] == cacheTag)
+ {
+ UInt32 chunkSize = (UInt32)1 << _chunkSizeLog;
+ UInt32 offset = (UInt32)_virtPos & (chunkSize - 1);
+ UInt32 cur = MyMin(chunkSize - offset, size);
+ memcpy(data, _outBuf + (cacheIndex << _chunkSizeLog) + offset, cur);
+ *processedSize = cur;
+ _virtPos += cur;
+ return S_OK;
+ }
+
+ PRF2(printf("\nVirtPos = %6d", _virtPos));
+
+ UInt32 comprUnitSize = (UInt32)1 << CompressionUnit;
+ UInt64 virtBlock = _virtPos >> BlockSizeLog;
+ UInt64 virtBlock2 = virtBlock & ~((UInt64)comprUnitSize - 1);
+
+ int left = 0, right = Extents.Size();
+ for (;;)
+ {
+ int mid = (left + right) / 2;
+ if (mid == left)
+ break;
+ if (virtBlock2 < Extents[mid].Virt)
+ right = mid;
+ else
+ left = mid;
+ }
+
+ bool isCompressed = false;
+ UInt64 virtBlock2End = virtBlock2 + comprUnitSize;
+ if (CompressionUnit != 0)
+ for (int i = left; i < Extents.Size(); i++)
+ {
+ const CExtent &e = Extents[i];
+ if (e.Virt >= virtBlock2End)
+ break;
+ if (e.IsEmpty())
+ {
+ isCompressed = true;
+ break;
+ }
+ }
+
+ int i;
+ for (i = left; Extents[i + 1].Virt <= virtBlock; i++);
+
+ _sparseMode = false;
+ if (!isCompressed)
+ {
+ const CExtent &e = Extents[i];
+ UInt64 newPos = (e.Phy << BlockSizeLog) + _virtPos - (e.Virt << BlockSizeLog);
+ if (newPos != _physPos)
+ {
+ _physPos = newPos;
+ RINOK(SeekToPhys());
+ }
+ UInt64 next = Extents[i + 1].Virt;
+ if (next > virtBlock2End)
+ next &= ~((UInt64)comprUnitSize - 1);
+ next <<= BlockSizeLog;
+ if (next > Size)
+ next = Size;
+ _curRem = next - _virtPos;
+ break;
+ }
+ bool thereArePhy = false;
+ for (int i2 = left; i2 < Extents.Size(); i2++)
+ {
+ const CExtent &e = Extents[i2];
+ if (e.Virt >= virtBlock2End)
+ break;
+ if (!e.IsEmpty())
+ {
+ thereArePhy = true;
+ break;
+ }
+ }
+ if (!thereArePhy)
+ {
+ _curRem = (Extents[i + 1].Virt << BlockSizeLog) - _virtPos;
+ _sparseMode = true;
+ break;
+ }
+
+ size_t offs = 0;
+ UInt64 curVirt = virtBlock2;
+ for (i = left; i < Extents.Size(); i++)
+ {
+ const CExtent &e = Extents[i];
+ if (e.IsEmpty())
+ break;
+ if (e.Virt >= virtBlock2End)
+ return S_FALSE;
+ UInt64 newPos = (e.Phy + (curVirt - e.Virt)) << BlockSizeLog;
+ if (newPos != _physPos)
+ {
+ _physPos = newPos;
+ RINOK(SeekToPhys());
+ }
+ UInt64 numChunks = Extents[i + 1].Virt - curVirt;
+ if (curVirt + numChunks > virtBlock2End)
+ numChunks = virtBlock2End - curVirt;
+ size_t compressed = (size_t)numChunks << BlockSizeLog;
+ RINOK(ReadStream_FALSE(Stream, _inBuf + offs, compressed));
+ curVirt += numChunks;
+ _physPos += compressed;
+ offs += compressed;
+ }
+ size_t destLenMax = GetCuSize();
+ size_t destLen = destLenMax;
+ UInt64 rem = Size - (virtBlock2 << BlockSizeLog);
+ if (destLen > rem)
+ destLen = (size_t)rem;
+
+ Byte *dest = _outBuf + (cacheIndex << _chunkSizeLog);
+ size_t destSizeRes = Lznt1Dec(dest, destLenMax, destLen, _inBuf, offs);
+ _tags[cacheIndex] = cacheTag;
+
+ // some files in Vista have destSize > destLen
+ if (destSizeRes < destLen)
+ {
+ memset(dest, 0, destLenMax);
+ if (InUse)
+ return S_FALSE;
+ }
+ }
+ if (size > _curRem)
+ size = (UInt32)_curRem;
+ HRESULT res = S_OK;
+ if (_sparseMode)
+ memset(data, 0, size);
+ else
+ {
+ res = Stream->Read(data, size, &size);
+ _physPos += size;
+ }
+ if (processedSize != NULL)
+ *processedSize = size;
+ _virtPos += size;
+ _curRem -= size;
+ return res;
+}
+
+STDMETHODIMP CInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ UInt64 newVirtPos = offset;
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET: break;
+ case STREAM_SEEK_CUR: newVirtPos += _virtPos; break;
+ case STREAM_SEEK_END: newVirtPos += Size; break;
+ default: return STG_E_INVALIDFUNCTION;
+ }
+ if (_virtPos != newVirtPos)
+ _curRem = 0;
+ _virtPos = newVirtPos;
+ if (newPosition)
+ *newPosition = newVirtPos;
+ return S_OK;
+}
+
+class CByteBufStream:
+ public IInStream,
+ public CMyUnknownImp
+{
+ UInt64 _virtPos;
+public:
+ CByteBuffer Buf;
+ void Init() { _virtPos = 0; }
+
+ MY_UNKNOWN_IMP1(IInStream)
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+};
+
+STDMETHODIMP CByteBufStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ if (_virtPos >= Buf.GetCapacity())
+ return (_virtPos == Buf.GetCapacity()) ? S_OK: E_FAIL;
+ UInt64 rem = Buf.GetCapacity() - _virtPos;
+ if (rem < size)
+ size = (UInt32)rem;
+ memcpy(data, Buf + (size_t)_virtPos, size);
+ if (processedSize != NULL)
+ *processedSize = size;
+ _virtPos += size;
+ return S_OK;
+}
+
+STDMETHODIMP CByteBufStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET: _virtPos = offset; break;
+ case STREAM_SEEK_CUR: _virtPos += offset; break;
+ case STREAM_SEEK_END: _virtPos = Buf.GetCapacity() + offset; break;
+ default: return STG_E_INVALIDFUNCTION;
+ }
+ if (newPosition)
+ *newPosition = _virtPos;
+ return S_OK;
+}
+
+HRESULT DataParseExtents(int clusterSizeLog, const CObjectVector<CAttr> attrs,
+ int attrIndex, int attrIndexLim, UInt64 numPhysClusters, CRecordVector<CExtent> &Extents)
+{
+ CExtent e;
+ e.Virt = 0;
+ e.Phy = kEmptyExtent;
+ Extents.Add(e);
+ const CAttr &attr0 = attrs[attrIndex];
+
+ if (attr0.AllocatedSize < attr0.Size ||
+ (attrs[attrIndexLim - 1].HighVcn + 1) != (attr0.AllocatedSize >> clusterSizeLog) ||
+ (attr0.AllocatedSize & ((1 << clusterSizeLog) - 1)) != 0)
+ return S_FALSE;
+
+ for (int i = attrIndex; i < attrIndexLim; i++)
+ if (!attrs[i].ParseExtents(Extents, numPhysClusters, attr0.CompressionUnit))
+ return S_FALSE;
+
+ UInt64 packSizeCalc = 0;
+ for (int k = 0; k < Extents.Size(); k++)
+ {
+ CExtent &e = Extents[k];
+ if (!e.IsEmpty())
+ packSizeCalc += (Extents[k + 1].Virt - e.Virt) << clusterSizeLog;
+ PRF2(printf("\nSize = %4I64X", Extents[k + 1].Virt - e.Virt));
+ PRF2(printf(" Pos = %4I64X", e.Phy));
+ }
+
+ if (attr0.CompressionUnit != 0)
+ {
+ if (packSizeCalc != attr0.PackSize)
+ return S_FALSE;
+ }
+ else
+ {
+ if (packSizeCalc != attr0.AllocatedSize)
+ return S_FALSE;
+ }
+ return S_OK;
+}
+
+struct CDataRef
+{
+ int Start;
+ int Num;
+};
+
+struct CMftRec
+{
+ UInt32 Magic;
+ // UInt64 Lsn;
+ UInt16 SeqNumber;
+ UInt16 Flags;
+ // UInt16 LinkCount;
+ // UInt16 NextAttrInstance;
+ CMftRef BaseMftRef;
+ // UInt32 ThisRecNumber;
+ UInt32 MyNumNameLinks;
+
+ CObjectVector<CAttr> DataAttrs;
+ CObjectVector<CFileNameAttr> FileNames;
+ CRecordVector<CDataRef> DataRefs;
+
+ CSiAttr SiAttr;
+
+
+ void MoveAttrsFrom(CMftRec &src)
+ {
+ DataAttrs += src.DataAttrs;
+ FileNames += src.FileNames;
+ src.DataAttrs.ClearAndFree();
+ src.FileNames.ClearAndFree();
+ }
+
+ UInt64 GetPackSize() const
+ {
+ UInt64 res = 0;
+ for (int i = 0; i < DataRefs.Size(); i++)
+ res += DataAttrs[DataRefs[i].Start].GetPackSize();
+ return res;
+ }
+
+ bool Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber, CObjectVector<CAttr> *attrs);
+
+ bool IsEmpty() const { return (Magic <= 2); }
+
+ bool InUse() const { return (Flags & 1) != 0; }
+ bool IsDir() const { return (Flags & 2) != 0; }
+
+ void ParseDataNames();
+ HRESULT GetStream(IInStream *mainStream, int dataIndex,
+ int clusterSizeLog, UInt64 numPhysClusters, IInStream **stream) const;
+
+ UInt64 GetSize(int dataIndex) const { return DataAttrs[DataRefs[dataIndex].Start].GetSize(); }
+
+ CMftRec(): MyNumNameLinks(0) {}
+};
+
+void CMftRec::ParseDataNames()
+{
+ DataRefs.Clear();
+ DataAttrs.Sort(CompareAttr, 0);
+
+ for (int i = 0; i < DataAttrs.Size();)
+ {
+ CDataRef ref;
+ ref.Start = i;
+ for (i++; i < DataAttrs.Size(); i++)
+ if (DataAttrs[ref.Start].Name != DataAttrs[i].Name)
+ break;
+ ref.Num = i - ref.Start;
+ DataRefs.Add(ref);
+ }
+}
+
+HRESULT CMftRec::GetStream(IInStream *mainStream, int dataIndex,
+ int clusterSizeLog, UInt64 numPhysClusters, IInStream **destStream) const
+{
+ *destStream = 0;
+ CByteBufStream *streamSpec = new CByteBufStream;
+ CMyComPtr<IInStream> streamTemp = streamSpec;
+
+ if (dataIndex < 0)
+ return E_FAIL;
+
+ if (dataIndex < DataRefs.Size())
+ {
+ const CDataRef &ref = DataRefs[dataIndex];
+ int numNonResident = 0;
+ int i;
+ for (i = ref.Start; i < ref.Start + ref.Num; i++)
+ if (DataAttrs[i].NonResident)
+ numNonResident++;
+
+ const CAttr &attr0 = DataAttrs[ref.Start];
+
+ if (numNonResident != 0 || ref.Num != 1)
+ {
+ if (numNonResident != ref.Num || !attr0.IsCompressionUnitSupported())
+ return S_FALSE;
+ CInStream *streamSpec = new CInStream;
+ CMyComPtr<IInStream> streamTemp = streamSpec;
+ RINOK(DataParseExtents(clusterSizeLog, DataAttrs, ref.Start, ref.Start + ref.Num, numPhysClusters, streamSpec->Extents));
+ streamSpec->Size = attr0.Size;
+ streamSpec->InitializedSize = attr0.InitializedSize;
+ streamSpec->Stream = mainStream;
+ streamSpec->BlockSizeLog = clusterSizeLog;
+ streamSpec->InUse = InUse();
+ RINOK(streamSpec->InitAndSeek(attr0.CompressionUnit));
+ *destStream = streamTemp.Detach();
+ return S_OK;
+ }
+ streamSpec->Buf = attr0.Data;
+ }
+ streamSpec->Init();
+ *destStream = streamTemp.Detach();
+ return S_OK;
+}
+
+bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber,
+ CObjectVector<CAttr> *attrs)
+{
+ G32(p, Magic);
+ if (IsEmpty())
+ return true;
+ if (Magic != 0x454c4946)
+ return false;
+
+ UInt32 usaOffset;
+ UInt32 numUsaItems;
+ G16(p + 0x04, usaOffset);
+ G16(p + 0x06, numUsaItems);
+
+ if ((usaOffset & 1) != 0 || usaOffset + numUsaItems * 2 > ((UInt32)1 << sectorSizeLog) - 2 ||
+ numUsaItems == 0 || numUsaItems - 1 != numSectors)
+ return false;
+
+ UInt16 usn = Get16(p + usaOffset);
+ // PRF(printf("\nusn = %d", usn));
+ for (UInt32 i = 1; i < numUsaItems; i++)
+ {
+ void *pp = p + (i << sectorSizeLog) - 2;
+ if (Get16(pp) != usn)
+ return false;
+ SetUi16(pp, Get16(p + usaOffset + i * 2));
+ }
+
+ // G64(p + 0x08, Lsn);
+ G16(p + 0x10, SeqNumber);
+ // G16(p + 0x12, LinkCount);
+ // PRF(printf(" L=%d", LinkCount));
+ UInt32 attrOffs = Get16(p + 0x14);
+ G16(p + 0x16, Flags);
+ PRF(printf(" F=%4X", Flags));
+
+ UInt32 bytesInUse = Get32(p + 0x18);
+ UInt32 bytesAlloc = Get32(p + 0x1C);
+ G64(p + 0x20, BaseMftRef.Val);
+ if (BaseMftRef.Val != 0)
+ {
+ PRF(printf(" BaseRef=%d", (int)BaseMftRef.Val));
+ // return false; // Check it;
+ }
+ // G16(p + 0x28, NextAttrInstance);
+ if (usaOffset >= 0x30)
+ if (Get32(p + 0x2C) != recNumber) // NTFS 3.1+
+ return false;
+
+ UInt32 limit = numSectors << sectorSizeLog;
+ if (attrOffs >= limit || (attrOffs & 7) != 0 || bytesInUse > limit
+ || bytesAlloc != limit)
+ return false;
+
+
+ for (UInt32 t = attrOffs; t < limit;)
+ {
+ CAttr attr;
+ // PRF(printf("\n %2d:", Attrs.Size()));
+ PRF(printf("\n"));
+ UInt32 length = attr.Parse(p + t, limit - t);
+ if (length == 0 || limit - t < length)
+ return false;
+ t += length;
+ if (attr.Type == 0xFFFFFFFF)
+ break;
+ switch(attr.Type)
+ {
+ case ATTR_TYPE_FILE_NAME:
+ {
+ CFileNameAttr fna;
+ if (!attr.ParseFileName(fna))
+ return false;
+ FileNames.Add(fna);
+ PRF(printf(" flags = %4x", (int)fna.NameType));
+ PRF(printf("\n %S", fna.Name));
+ break;
+ }
+ case ATTR_TYPE_STANDARD_INFO:
+ if (!attr.ParseSi(SiAttr))
+ return false;
+ break;
+ case ATTR_TYPE_DATA:
+ DataAttrs.Add(attr);
+ break;
+ default:
+ if (attrs)
+ attrs->Add(attr);
+ break;
+ }
+ }
+
+ return true;
+}
+
+struct CItem
+{
+ int RecIndex;
+ int DataIndex;
+ CMftRef ParentRef;
+ UString Name;
+ UInt32 Attrib;
+
+ bool IsDir() const { return (DataIndex < 0); }
+};
+
+struct CDatabase
+{
+ CHeader Header;
+ CObjectVector<CItem> Items;
+ CObjectVector<CMftRec> Recs;
+ CMyComPtr<IInStream> InStream;
+ IArchiveOpenCallback *OpenCallback;
+
+ CByteBuffer ByteBuf;
+
+ CObjectVector<CAttr> VolAttrs;
+
+ ~CDatabase() { ClearAndClose(); }
+
+ void Clear();
+ void ClearAndClose();
+
+ UString GetItemPath(Int32 index) const;
+ HRESULT Open();
+ HRESULT ReadDir(Int32 parent, UInt32 cluster, int level);
+
+ HRESULT SeekToCluster(UInt64 cluster);
+
+ int FindMtfRec(const CMftRef &ref) const
+ {
+ UInt64 val = ref.GetIndex();
+ int left = 0, right = Items.Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ UInt64 midValue = Items[mid].RecIndex;
+ if (val == midValue)
+ return mid;
+ if (val < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ return -1;
+ }
+
+};
+
+HRESULT CDatabase::SeekToCluster(UInt64 cluster)
+{
+ return InStream->Seek(cluster << Header.ClusterSizeLog, STREAM_SEEK_SET, NULL);
+}
+
+void CDatabase::Clear()
+{
+ Items.Clear();
+ Recs.Clear();
+}
+
+void CDatabase::ClearAndClose()
+{
+ Clear();
+ InStream.Release();
+}
+
+#define MY_DIR_PREFIX(x) L"[" x L"]" WSTRING_PATH_SEPARATOR
+
+UString CDatabase::GetItemPath(Int32 index) const
+{
+ const CItem *item = &Items[index];
+ UString name = item->Name;
+ for (int j = 0; j < 256; j++)
+ {
+ CMftRef ref = item->ParentRef;
+ index = FindMtfRec(ref);
+ if (ref.GetIndex() == 5)
+ return name;
+ if (index < 0 || Recs[Items[index].RecIndex].SeqNumber != ref.GetNumber())
+ return MY_DIR_PREFIX(L"UNKNOWN") + name;
+ item = &Items[index];
+ name = item->Name + WCHAR_PATH_SEPARATOR + name;
+ }
+ return MY_DIR_PREFIX(L"BAD") + name;
+}
+
+HRESULT CDatabase::Open()
+{
+ Clear();
+
+ static const UInt32 kHeaderSize = 512;
+ Byte buf[kHeaderSize];
+ RINOK(ReadStream_FALSE(InStream, buf, kHeaderSize));
+ if (!Header.Parse(buf))
+ return S_FALSE;
+ UInt64 fileSize;
+ RINOK(InStream->Seek(0, STREAM_SEEK_END, &fileSize));
+ if (fileSize < Header.GetPhySize())
+ return S_FALSE;
+
+ SeekToCluster(Header.MftCluster);
+
+ CMftRec mftRec;
+ UInt32 numSectorsInRec;
+ int recSizeLog;
+ CMyComPtr<IInStream> mftStream;
+ {
+ UInt32 blockSize = 1 << 12;
+ ByteBuf.SetCapacity(blockSize);
+ RINOK(ReadStream_FALSE(InStream, ByteBuf, blockSize));
+
+ UInt32 allocSize = Get32(ByteBuf + 0x1C);
+ recSizeLog = GetLog(allocSize);
+ if (recSizeLog < Header.SectorSizeLog)
+ return false;
+ numSectorsInRec = 1 << (recSizeLog - Header.SectorSizeLog);
+ if (!mftRec.Parse(ByteBuf, Header.SectorSizeLog, numSectorsInRec, NULL, 0))
+ return S_FALSE;
+ if (mftRec.IsEmpty())
+ return S_FALSE;
+ mftRec.ParseDataNames();
+ if (mftRec.DataRefs.IsEmpty())
+ return S_FALSE;
+ RINOK(mftRec.GetStream(InStream, 0, Header.ClusterSizeLog, Header.NumClusters, &mftStream));
+ if (!mftStream)
+ return S_FALSE;
+ }
+
+ UInt64 mftSize = mftRec.DataAttrs[0].Size;
+ if ((mftSize >> 4) > Header.GetPhySize())
+ return S_FALSE;
+
+ UInt64 numFiles = mftSize >> recSizeLog;
+ if (numFiles > (1 << 30))
+ return S_FALSE;
+ if (OpenCallback)
+ {
+ RINOK(OpenCallback->SetTotal(&numFiles, &mftSize));
+ }
+ const UInt32 kBufSize = (1 << 15);
+ if (kBufSize < (1 << recSizeLog))
+ return S_FALSE;
+
+ ByteBuf.SetCapacity((size_t)kBufSize);
+ Recs.Reserve((int)numFiles);
+ for (UInt64 pos64 = 0;;)
+ {
+ if (OpenCallback)
+ {
+ // Sleep(0);
+ UInt64 numFiles = Recs.Size();
+ RINOK(OpenCallback->SetCompleted(&numFiles, &pos64));
+ }
+ UInt32 readSize = kBufSize;
+ UInt64 rem = mftSize - pos64;
+ if (readSize > rem)
+ readSize = (UInt32)rem;
+ if (readSize < ((UInt32)1 << recSizeLog))
+ break;
+ RINOK(ReadStream_FALSE(mftStream, ByteBuf, (size_t)readSize));
+ pos64 += readSize;
+ for (int i = 0; ((UInt32)(i + 1) << recSizeLog) <= readSize; i++)
+ {
+ PRF(printf("\n---------------------"));
+ PRF(printf("\n%5d:", Recs.Size()));
+ Byte *p = ByteBuf + ((UInt32)i << recSizeLog);
+ CMftRec rec;
+ if (!rec.Parse(p, Header.SectorSizeLog, numSectorsInRec, (UInt32)Recs.Size(),
+ (Recs.Size() == kRecIndex_Volume) ? &VolAttrs: NULL))
+ return S_FALSE;
+ Recs.Add(rec);
+ }
+ }
+
+ int i;
+ for (i = 0; i < Recs.Size(); i++)
+ {
+ CMftRec &rec = Recs[i];
+ if (!rec.BaseMftRef.IsBaseItself())
+ {
+ UInt64 refIndex = rec.BaseMftRef.GetIndex();
+ if (refIndex > (UInt32)Recs.Size())
+ return S_FALSE;
+ CMftRec &refRec = Recs[(int)refIndex];
+ bool moveAttrs = (refRec.SeqNumber == rec.BaseMftRef.GetNumber() && refRec.BaseMftRef.IsBaseItself());
+ if (rec.InUse() && refRec.InUse())
+ {
+ if (!moveAttrs)
+ return S_FALSE;
+ }
+ else if (rec.InUse() || refRec.InUse())
+ moveAttrs = false;
+ if (moveAttrs)
+ refRec.MoveAttrsFrom(rec);
+ }
+ }
+
+ for (i = 0; i < Recs.Size(); i++)
+ Recs[i].ParseDataNames();
+
+ for (i = 0; i < Recs.Size(); i++)
+ {
+ CMftRec &rec = Recs[i];
+ if (rec.IsEmpty() || !rec.BaseMftRef.IsBaseItself())
+ continue;
+ int numNames = 0;
+ // printf("\n%4d: ", i);
+ for (int t = 0; t < rec.FileNames.Size(); t++)
+ {
+ const CFileNameAttr &fna = rec.FileNames[t];
+ // printf("%4d %S | ", (int)fna.NameType, fna.Name);
+ if (fna.IsDos())
+ continue;
+ int numDatas = rec.DataRefs.Size();
+
+ // For hard linked files we show substreams only for first Name.
+ if (numDatas > 1 && numNames > 0)
+ numDatas = 1;
+ numNames++;
+
+ if (rec.IsDir())
+ {
+ CItem item;
+ item.Name = fna.Name;
+ item.RecIndex = i;
+ item.DataIndex = -1;
+ item.ParentRef = fna.ParentDirRef;
+ item.Attrib = rec.SiAttr.Attrib | 0x10;
+ // item.Attrib = fna.Attrib;
+ Items.Add(item);
+ }
+ for (int di = 0; di < numDatas; di++)
+ {
+ CItem item;
+ item.Name = fna.Name;
+ item.Attrib = rec.SiAttr.Attrib;
+ const UString &subName = rec.DataAttrs[rec.DataRefs[di].Start].Name;
+ if (!subName.IsEmpty())
+ {
+ // $BadClus:$Bad is sparse file for all clusters. So we skip it.
+ if (i == kRecIndex_BadClus && subName == L"$Bad")
+ continue;
+ item.Name += L":";
+ item.Name += subName;
+ item.Attrib = fna.Attrib;
+ }
+
+ PRF(printf("\n%3d", i));
+ PRF(printf(" attrib=%2x", rec.SiAttr.Attrib));
+ PRF(printf(" %S", item.Name));
+
+ item.RecIndex = i;
+ item.DataIndex = di;
+ item.ParentRef = fna.ParentDirRef;
+
+ Items.Add(item);
+ rec.MyNumNameLinks++;
+ }
+ }
+ rec.FileNames.ClearAndFree();
+ }
+
+ return S_OK;
+}
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp,
+ CDatabase
+{
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ IInStream *stream2;
+ const CItem &item = Items[index];
+ const CMftRec &rec = Recs[item.RecIndex];
+ HRESULT res = rec.GetStream(InStream, item.DataIndex, Header.ClusterSizeLog, Header.NumClusters, &stream2);
+ *stream = (ISequentialInStream *)stream2;
+ return res;
+ COM_TRY_END
+}
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidLinks, VT_UI4}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidVolumeName, VT_BSTR},
+ { NULL, kpidFileSystem, VT_BSTR},
+ { NULL, kpidClusterSize, VT_UI4},
+ { NULL, kpidPhySize, VT_UI8},
+ { NULL, kpidHeadersSize, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+
+ { NULL, kpidSectorSize, VT_UI4},
+ { NULL, kpidId, VT_UI8}
+ // { NULL, kpidSectorsPerTrack, VT_UI4},
+ // { NULL, kpidNumHeads, VT_UI4},
+ // { NULL, kpidHiddenSectors, VT_UI4}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+static void NtfsTimeToProp(UInt64 t, NWindows::NCOM::CPropVariant &prop)
+{
+ FILETIME ft;
+ ft.dwLowDateTime = (DWORD)t;
+ ft.dwHighDateTime = (DWORD)(t >> 32);
+ prop = ft;
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+
+ const CMftRec *volRec = (Recs.Size() > kRecIndex_Volume ? &Recs[kRecIndex_Volume] : NULL);
+
+ switch(propID)
+ {
+ case kpidClusterSize: prop = Header.ClusterSize(); break;
+ case kpidPhySize: prop = Header.GetPhySize(); break;
+ /*
+ case kpidHeadersSize:
+ {
+ UInt64 val = 0;
+ for (int i = 0; i < kNumSysRecs; i++)
+ {
+ printf("\n%2d: %8I64d ", i, Recs[i].GetPackSize());
+ if (i == 8)
+ i = i
+ val += Recs[i].GetPackSize();
+ }
+ prop = val;
+ break;
+ }
+ */
+ case kpidCTime: if (volRec) NtfsTimeToProp(volRec->SiAttr.CTime, prop); break;break;
+ case kpidVolumeName:
+ {
+ for (int i = 0; i < VolAttrs.Size(); i++)
+ {
+ const CAttr &attr = VolAttrs[i];
+ if (attr.Type == ATTR_TYPE_VOLUME_NAME)
+ {
+ UString name;
+ GetString(attr.Data, (int)attr.Data.GetCapacity() / 2, name);
+ prop = name;
+ break;
+ }
+ }
+ break;
+ }
+ case kpidFileSystem:
+ {
+ AString s = "NTFS";
+ for (int i = 0; i < VolAttrs.Size(); i++)
+ {
+ const CAttr &attr = VolAttrs[i];
+ if (attr.Type == ATTR_TYPE_VOLUME_INFO)
+ {
+ CVolInfo vi;
+ if (attr.ParseVolInfo(vi))
+ {
+ s += ' ';
+ char temp[16];
+ ConvertUInt32ToString(vi.MajorVer, temp);
+ s += temp;
+ s += '.';
+ ConvertUInt32ToString(vi.MinorVer, temp);
+ s += temp;
+ }
+ break;
+ }
+ }
+ prop = s;
+ break;
+ }
+ case kpidSectorSize: prop = (UInt32)1 << Header.SectorSizeLog; break;
+ case kpidId: prop = Header.SerialNumber; break;
+ // case kpidMediaType: prop = Header.MediaType; break;
+ // case kpidSectorsPerTrack: prop = Header.SectorsPerTrack; break;
+ // case kpidNumHeads: prop = Header.NumHeads; break;
+ // case kpidHiddenSectors: prop = Header.NumHiddenSectors; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItem &item = Items[index];
+ const CMftRec &rec = Recs[item.RecIndex];
+
+ const CAttr *data= NULL;
+ if (item.DataIndex >= 0)
+ data = &rec.DataAttrs[rec.DataRefs[item.DataIndex].Start];
+
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ UString name = GetItemPath(index);
+ const wchar_t *prefix = NULL;
+ if (!rec.InUse())
+ prefix = MY_DIR_PREFIX(L"DELETED");
+ else if (item.RecIndex < kNumSysRecs)
+ prefix = MY_DIR_PREFIX(L"SYSTEM");
+ if (prefix)
+ name = prefix + name;
+ prop = name;
+ break;
+ }
+
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidMTime: NtfsTimeToProp(rec.SiAttr.MTime, prop); break;
+
+ case kpidCTime: NtfsTimeToProp(rec.SiAttr.CTime, prop); break;
+ case kpidATime: NtfsTimeToProp(rec.SiAttr.ATime, prop); break;
+ case kpidAttrib:
+ prop = item.Attrib;
+ break;
+ case kpidLinks: prop = rec.MyNumNameLinks; break;
+ case kpidSize: if (data) prop = data->GetSize(); break;
+ case kpidPackSize: if (data) prop = data->GetPackSize(); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ {
+ OpenCallback = callback;
+ InStream = stream;
+ HRESULT res;
+ try
+ {
+ res = CDatabase::Open();
+ if (res == S_OK)
+ return S_OK;
+ }
+ catch(...)
+ {
+ Close();
+ throw;
+ }
+ Close();
+ return res;
+ }
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ ClearAndClose();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = Items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt32 i;
+ UInt64 totalSize = 0;
+ for (i = 0; i < numItems; i++)
+ {
+ const CItem &item = Items[allFilesMode ? i : indices[i]];
+ const CMftRec &rec = Recs[item.RecIndex];
+ if (!rec.IsDir())
+ totalSize += rec.GetSize(item.DataIndex);
+ }
+ RINOK(extractCallback->SetTotal(totalSize));
+
+ UInt64 totalPackSize;
+ totalSize = totalPackSize = 0;
+
+ CByteBuffer buf;
+ UInt32 clusterSize = Header.ClusterSize();
+ buf.SetCapacity(clusterSize);
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems; i++)
+ {
+ lps->InSize = totalPackSize;
+ lps->OutSize = totalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ const CItem &item = Items[index];
+ if (item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ outStreamSpec->SetStream(realOutStream);
+ realOutStream.Release();
+ outStreamSpec->Init();
+
+ const CMftRec &rec = Recs[item.RecIndex];
+ const CAttr &data = rec.DataAttrs[rec.DataRefs[item.DataIndex].Start];
+
+ int res = NArchive::NExtract::NOperationResult::kDataError;
+ {
+ CMyComPtr<IInStream> inStream;
+ HRESULT hres = rec.GetStream(InStream, item.DataIndex, Header.ClusterSizeLog, Header.NumClusters, &inStream);
+ if (hres == S_FALSE)
+ res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ else
+ {
+ RINOK(hres);
+ if (inStream)
+ {
+ HRESULT hres = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+ if (hres != S_OK && hres != S_FALSE)
+ {
+ RINOK(hres);
+ }
+ if (/* copyCoderSpec->TotalSize == item.GetSize() && */ hres == S_OK)
+ res = NArchive::NExtract::NOperationResult::kOK;
+ }
+ }
+ }
+ totalPackSize += data.GetPackSize();
+ totalSize += data.GetSize();
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(res));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = Items.Size();
+ return S_OK;
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"NTFS", L"ntfs img", 0, 0xD9, { 'N', 'T', 'F', 'S', ' ', ' ', ' ', ' ', 0 }, 9, false, CreateArc, 0 };
+
+REGISTER_ARC(Fat)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/PeHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/PeHandler.cpp
new file mode 100644
index 000000000..a1304ae45
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/PeHandler.cpp
@@ -0,0 +1,912 @@
+// PeHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+
+#include "Windows/PropVariantUtils.h"
+#include "Windows/Time.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NPe {
+
+#define NUM_SCAN_SECTIONS_MAX (1 << 6)
+
+#define PE_SIG 0x00004550
+#define PE_OptHeader_Magic_32 0x10B
+#define PE_OptHeader_Magic_64 0x20B
+
+static AString GetDecString(UInt32 v)
+{
+ char sz[32];
+ ConvertUInt64ToString(v, sz);
+ return sz;
+}
+
+struct CVersion
+{
+ UInt16 Major;
+ UInt16 Minor;
+
+ void Parse(const Byte *buf);
+ AString GetString() const { return GetDecString(Major) + '.' + GetDecString(Minor); }
+};
+
+void CVersion::Parse(const Byte *p)
+{
+ Major = Get16(p);
+ Minor = Get16(p + 2);
+}
+
+static const UInt32 kHeaderSize = 4 + 20;
+
+struct CHeader
+{
+ UInt16 NumSections;
+ UInt32 Time;
+ UInt32 PointerToSymbolTable;
+ UInt32 NumSymbols;
+ UInt16 OptHeaderSize;
+ UInt16 Flags;
+ UInt16 Machine;
+
+ bool Parse(const Byte *buf);
+};
+
+bool CHeader::Parse(const Byte *p)
+{
+ if (Get32(p) != PE_SIG)
+ return false;
+ p += 4;
+ Machine = Get16(p + 0);
+ NumSections = Get16(p + 2);
+ Time = Get32(p + 4);
+ PointerToSymbolTable = Get32(p + 8);
+ NumSymbols = Get32(p + 12);
+ OptHeaderSize = Get16(p + 16);
+ Flags = Get16(p + 18);
+ return true;
+}
+
+struct CDirLink
+{
+ UInt32 Va;
+ UInt32 Size;
+ void Parse(const Byte *p);
+};
+
+void CDirLink::Parse(const Byte *p)
+{
+ Va = Get32(p);
+ Size = Get32(p + 4);
+};
+
+enum
+{
+ kDirLink_Certificate = 4,
+ kDirLink_Debug = 6
+};
+
+struct CDebugEntry
+{
+ UInt32 Flags;
+ UInt32 Time;
+ CVersion Ver;
+ UInt32 Type;
+ UInt32 Size;
+ UInt32 Va;
+ UInt32 Pa;
+
+ void Parse(const Byte *p);
+};
+
+void CDebugEntry::Parse(const Byte *p)
+{
+ Flags = Get32(p);
+ Time = Get32(p + 4);
+ Ver.Parse(p + 8);
+ Type = Get32(p + 12);
+ Size = Get32(p + 16);
+ Va = Get32(p + 20);
+ Pa = Get32(p + 24);
+}
+
+static const UInt32 kNumDirItemsMax = 16;
+
+struct COptHeader
+{
+ UInt16 Magic;
+ Byte LinkerVerMajor;
+ Byte LinkerVerMinor;
+
+ UInt32 CodeSize;
+ UInt32 InitDataSize;
+ UInt32 UninitDataSize;
+
+ // UInt32 AddressOfEntryPoint;
+ // UInt32 BaseOfCode;
+ // UInt32 BaseOfData32;
+ // UInt64 ImageBase;
+
+ UInt32 SectAlign;
+ UInt32 FileAlign;
+
+ CVersion OsVer;
+ CVersion ImageVer;
+ CVersion SubsysVer;
+
+ UInt32 ImageSize;
+ UInt32 HeadersSize;
+ UInt32 CheckSum;
+ UInt16 SubSystem;
+ UInt16 DllCharacts;
+
+ UInt64 StackReserve;
+ UInt64 StackCommit;
+ UInt64 HeapReserve;
+ UInt64 HeapCommit;
+
+ UInt32 NumDirItems;
+ CDirLink DirItems[kNumDirItemsMax];
+
+ bool Is64Bit() const { return Magic == PE_OptHeader_Magic_64; }
+ bool Parse(const Byte *p, UInt32 size);
+};
+
+bool COptHeader::Parse(const Byte *p, UInt32 size)
+{
+ Magic = Get16(p);
+ switch (Magic)
+ {
+ case PE_OptHeader_Magic_32:
+ case PE_OptHeader_Magic_64:
+ break;
+ default:
+ return false;
+ }
+ LinkerVerMajor = p[2];
+ LinkerVerMinor = p[3];
+
+ bool hdr64 = Is64Bit();
+
+ CodeSize = Get32(p + 4);
+ InitDataSize = Get32(p + 8);
+ UninitDataSize = Get32(p + 12);
+
+ // AddressOfEntryPoint = Get32(p + 16);
+ // BaseOfCode = Get32(p + 20);
+ // BaseOfData32 = Get32(p + 24);
+ // ImageBase = hdr64 ? GetUi64(p + 24) :Get32(p + 28);
+
+ SectAlign = Get32(p + 32);
+ FileAlign = Get32(p + 36);
+
+ OsVer.Parse(p + 40);
+ ImageVer.Parse(p + 44);
+ SubsysVer.Parse(p + 48);
+
+ // reserved = Get32(p + 52);
+
+ ImageSize = Get32(p + 56);
+ HeadersSize = Get32(p + 60);
+ CheckSum = Get32(p + 64);
+ SubSystem = Get16(p + 68);
+ DllCharacts = Get16(p + 70);
+
+ if (hdr64)
+ {
+ StackReserve = Get64(p + 72);
+ StackCommit = Get64(p + 80);
+ HeapReserve = Get64(p + 88);
+ HeapCommit = Get64(p + 96);
+ }
+ else
+ {
+ StackReserve = Get32(p + 72);
+ StackCommit = Get32(p + 76);
+ HeapReserve = Get32(p + 80);
+ HeapCommit = Get32(p + 84);
+ }
+ UInt32 pos = (hdr64 ? 108 : 92);
+ NumDirItems = Get32(p + pos);
+ pos += 4;
+ if (pos + 8 * NumDirItems != size)
+ return false;
+ for (UInt32 i = 0; i < NumDirItems && i < kNumDirItemsMax; i++)
+ DirItems[i].Parse(p + pos + i * 8);
+ return true;
+}
+
+static const UInt32 kSectionSize = 40;
+
+struct CSection
+{
+ AString Name;
+
+ UInt32 VSize;
+ UInt32 Va;
+ UInt32 PSize;
+ UInt32 Pa;
+ UInt32 Flags;
+ UInt32 Time;
+ // UInt16 NumRelocs;
+ bool IsDebug;
+ bool IsRealSect;
+
+ CSection(): IsRealSect(false), IsDebug(false) {}
+ UInt64 GetPackSize() const { return PSize; }
+
+ void UpdateTotalSize(UInt32 &totalSize)
+ {
+ UInt32 t = Pa + PSize;
+ if (t > totalSize)
+ totalSize = t;
+ }
+ void Parse(const Byte *p);
+};
+
+static bool operator <(const CSection &a1, const CSection &a2) { return (a1.Pa < a2.Pa); }
+static bool operator ==(const CSection &a1, const CSection &a2) { return (a1.Pa == a2.Pa); }
+
+static AString GetName(const Byte *name)
+{
+ const int kNameSize = 8;
+ AString res;
+ char *p = res.GetBuffer(kNameSize);
+ memcpy(p, name, kNameSize);
+ p[kNameSize] = 0;
+ res.ReleaseBuffer();
+ return res;
+}
+
+void CSection::Parse(const Byte *p)
+{
+ Name = GetName(p);
+ VSize = Get32(p + 8);
+ Va = Get32(p + 12);
+ PSize = Get32(p + 16);
+ Pa = Get32(p + 20);
+ // NumRelocs = Get16(p + 32);
+ Flags = Get32(p + 36);
+}
+
+static const CUInt32PCharPair g_HeaderCharacts[] =
+{
+ { 1 << 1, "Executable" },
+ { 1 << 13, "DLL" },
+ { 1 << 8, "32-bit" },
+ { 1 << 5, "LargeAddress" },
+ { 1 << 0, "NoRelocs" },
+ { 1 << 2, "NoLineNums" },
+ { 1 << 3, "NoLocalSyms" },
+ { 1 << 4, "AggressiveWsTrim" },
+ { 1 << 9, "NoDebugInfo" },
+ { 1 << 10, "RemovableRun" },
+ { 1 << 11, "NetRun" },
+ { 1 << 12, "System" },
+ { 1 << 14, "UniCPU" },
+ { 1 << 7, "Little-Endian" },
+ { 1 << 15, "Big-Endian" }
+};
+
+static const CUInt32PCharPair g_DllCharacts[] =
+{
+ { 1 << 6, "Relocated" },
+ { 1 << 7, "Integrity" },
+ { 1 << 8, "NX-Compatible" },
+ { 1 << 9, "NoIsolation" },
+ { 1 << 10, "NoSEH" },
+ { 1 << 11, "NoBind" },
+ { 1 << 13, "WDM" },
+ { 1 << 15, "TerminalServerAware" }
+};
+
+static const CUInt32PCharPair g_SectFlags[] =
+{
+ { 1 << 3, "NoPad" },
+ { 1 << 5, "Code" },
+ { 1 << 6, "InitializedData" },
+ { 1 << 7, "UninitializedData" },
+ { 1 << 9, "Comments" },
+ { 1 << 11, "Remove" },
+ { 1 << 12, "COMDAT" },
+ { 1 << 15, "GP" },
+ { 1 << 24, "ExtendedRelocations" },
+ { 1 << 25, "Discardable" },
+ { 1 << 26, "NotCached" },
+ { 1 << 27, "NotPaged" },
+ { 1 << 28, "Shared" },
+ { 1 << 29, "Execute" },
+ { 1 << 30, "Read" },
+ { (UInt32)1 << 31, "Write" }
+};
+
+static const CUInt32PCharPair g_MachinePairs[] =
+{
+ { 0x014C, "x86" },
+ { 0x0162, "MIPS-R3000" },
+ { 0x0166, "MIPS-R4000" },
+ { 0x0168, "MIPS-R10000" },
+ { 0x0169, "MIPS-V2" },
+ { 0x0184, "Alpha" },
+ { 0x01A2, "SH3" },
+ { 0x01A3, "SH3-DSP" },
+ { 0x01A4, "SH3E" },
+ { 0x01A6, "SH4" },
+ { 0x01A8, "SH5" },
+ { 0x01C0, "ARM" },
+ { 0x01C2, "ARM-Thumb" },
+ { 0x01F0, "PPC" },
+ { 0x01F1, "PPC-FP" },
+ { 0x0200, "IA-64" },
+ { 0x0284, "Alpha-64" },
+ { 0x0200, "IA-64" },
+ { 0x0366, "MIPSFPU" },
+ { 0x8664, "x64" },
+ { 0x0EBC, "EFI" }
+};
+
+static const CUInt32PCharPair g_SubSystems[] =
+{
+ { 0, "Unknown" },
+ { 1, "Native" },
+ { 2, "Windows GUI" },
+ { 3, "Windows CUI" },
+ { 7, "Posix" },
+ { 9, "Windows CE" },
+ { 10, "EFI" },
+ { 11, "EFI Boot" },
+ { 12, "EFI Runtime" },
+ { 13, "EFI ROM" },
+ { 14, "XBOX" }
+};
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+ CObjectVector<CSection> _sections;
+ UInt32 _peOffset;
+ CHeader _header;
+ COptHeader _optHeader;
+ UInt32 _totalSize;
+ UInt32 _totalSizeLimited;
+ HRESULT LoadDebugSections(IInStream *stream, bool &thereIsSection);
+ HRESULT Open2(IInStream *stream);
+ bool Parse(const Byte *buf, UInt32 size);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+bool CHandler::Parse(const Byte *buf, UInt32 size)
+{
+ UInt32 i;
+ if (size < 512)
+ return false;
+ _peOffset = Get32(buf + 0x3C);
+ if (_peOffset >= 0x1000 || _peOffset + 512 > size || (_peOffset & 7) != 0)
+ return false;
+
+ UInt32 pos = _peOffset;
+ if (!_header.Parse(buf + pos))
+ return false;
+ if (_header.OptHeaderSize > 512 || _header.NumSections > NUM_SCAN_SECTIONS_MAX)
+ return false;
+ pos += kHeaderSize;
+
+ if (!_optHeader.Parse(buf + pos, _header.OptHeaderSize))
+ return false;
+
+ pos += _header.OptHeaderSize;
+ _totalSize = pos;
+
+ for (i = 0; i < _header.NumSections; i++, pos += kSectionSize)
+ {
+ CSection sect;
+ if (pos + kSectionSize > size)
+ return false;
+ sect.Parse(buf + pos);
+ sect.IsRealSect = true;
+ sect.UpdateTotalSize(_totalSize);
+ _sections.Add(sect);
+ }
+
+ return true;
+}
+
+enum
+{
+ kpidSectAlign = kpidUserDefined,
+ kpidFileAlign,
+ kpidLinkerVer,
+ kpidOsVer,
+ kpidImageVer,
+ kpidSubsysVer,
+ kpidCodeSize,
+ kpidImageSize,
+ kpidInitDataSize,
+ kpidUnInitDataSize,
+ kpidHeadersSizeUnInitDataSize,
+ kpidSubSystem,
+ kpidDllCharacts,
+ kpidStackReserve,
+ kpidStackCommit,
+ kpidHeapReserve,
+ kpidHeapCommit,
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidCpu, VT_BSTR},
+ { NULL, kpidBit64, VT_BOOL},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidPhySize, VT_UI4},
+ { NULL, kpidHeadersSize, VT_UI4},
+ { NULL, kpidChecksum, VT_UI4},
+ { L"Image Size", kpidImageSize, VT_UI4},
+ { L"Section Alignment", kpidSectAlign, VT_UI4},
+ { L"File Alignment", kpidFileAlign, VT_UI4},
+ { L"Code Size", kpidCodeSize, VT_UI4},
+ { L"Initialized Data Size", kpidInitDataSize, VT_UI4},
+ { L"Uninitialized Data Size", kpidUnInitDataSize, VT_UI4},
+ { L"Linker Version", kpidLinkerVer, VT_BSTR},
+ { L"OS Version", kpidOsVer, VT_BSTR},
+ { L"Image Version", kpidImageVer, VT_BSTR},
+ { L"Subsystem Version", kpidSubsysVer, VT_BSTR},
+ { L"Subsystem", kpidSubSystem, VT_BSTR},
+ { L"DLL Characteristics", kpidDllCharacts, VT_BSTR},
+ { L"Stack Reserve", kpidStackReserve, VT_UI8},
+ { L"Stack Commit", kpidStackCommit, VT_UI8},
+ { L"Heap Reserve", kpidHeapReserve, VT_UI8},
+ { L"Heap Commit", kpidHeapCommit, VT_UI8},
+ };
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidOffset, VT_UI8},
+ { NULL, kpidVa, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_WITH_NAME
+
+static void VerToProp(const CVersion &v, NCOM::CPropVariant &prop)
+{
+ StringToProp(v.GetString(), prop);
+}
+
+void TimeToProp(UInt32 unixTime, NCOM::CPropVariant &prop)
+{
+ if (unixTime != 0)
+ {
+ FILETIME ft;
+ NTime::UnixTimeToFileTime(unixTime, ft);
+ prop = ft;
+ }
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidSectAlign: prop = _optHeader.SectAlign; break;
+ case kpidFileAlign: prop = _optHeader.FileAlign; break;
+ case kpidLinkerVer:
+ {
+ CVersion v = { _optHeader.LinkerVerMajor, _optHeader.LinkerVerMinor };
+ VerToProp(v, prop); break;
+ break;
+ }
+
+ case kpidOsVer: VerToProp(_optHeader.OsVer, prop); break;
+ case kpidImageVer: VerToProp(_optHeader.ImageVer, prop); break;
+ case kpidSubsysVer: VerToProp(_optHeader.SubsysVer, prop); break;
+ case kpidCodeSize: prop = _optHeader.CodeSize; break;
+ case kpidInitDataSize: prop = _optHeader.InitDataSize; break;
+ case kpidUnInitDataSize: prop = _optHeader.UninitDataSize; break;
+ case kpidImageSize: prop = _optHeader.ImageSize; break;
+ case kpidPhySize: prop = _totalSize; break;
+ case kpidHeadersSize: prop = _optHeader.HeadersSize; break;
+ case kpidChecksum: prop = _optHeader.CheckSum; break;
+
+ case kpidCpu: PAIR_TO_PROP(g_MachinePairs, _header.Machine, prop); break;
+ case kpidBit64: if (_optHeader.Is64Bit()) prop = true; break;
+ case kpidSubSystem: PAIR_TO_PROP(g_SubSystems, _optHeader.SubSystem, prop); break;
+
+ case kpidMTime:
+ case kpidCTime: TimeToProp(_header.Time, prop); break;
+ case kpidCharacts: FLAGS_TO_PROP(g_HeaderCharacts, _header.Flags, prop); break;
+ case kpidDllCharacts: FLAGS_TO_PROP(g_DllCharacts, _optHeader.DllCharacts, prop); break;
+ case kpidStackReserve: prop = _optHeader.StackReserve; break;
+ case kpidStackCommit: prop = _optHeader.StackCommit; break;
+ case kpidHeapReserve: prop = _optHeader.HeapReserve; break;
+ case kpidHeapCommit: prop = _optHeader.HeapCommit; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ const CSection &item = _sections[index];
+ switch(propID)
+ {
+ case kpidPath: StringToProp(item.Name, prop); break;
+ case kpidSize: prop = (UInt64)item.VSize; break;
+ case kpidPackSize: prop = (UInt64)item.GetPackSize(); break;
+ case kpidOffset: prop = item.Pa; break;
+ case kpidVa: if (item.IsRealSect) prop = item.Va; break;
+ case kpidMTime:
+ case kpidCTime:
+ TimeToProp(item.IsDebug ? item.Time : _header.Time, prop); break;
+ case kpidCharacts: if (item.IsRealSect) FLAGS_TO_PROP(g_SectFlags, item.Flags, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::LoadDebugSections(IInStream *stream, bool &thereIsSection)
+{
+ thereIsSection = false;
+ const CDirLink &debugLink = _optHeader.DirItems[kDirLink_Debug];
+ if (debugLink.Size == 0)
+ return S_OK;
+ const unsigned kEntrySize = 28;
+ UInt32 numItems = debugLink.Size / kEntrySize;
+ if (numItems * kEntrySize != debugLink.Size || numItems > 16)
+ return S_FALSE;
+
+ UInt64 pa = 0;
+ int i;
+ for (i = 0; i < _sections.Size(); i++)
+ {
+ const CSection &sect = _sections[i];
+ if (sect.Va < debugLink.Va && debugLink.Va + debugLink.Size <= sect.Va + sect.PSize)
+ {
+ pa = sect.Pa + (debugLink.Va - sect.Va);
+ break;
+ }
+ }
+ if (i == _sections.Size())
+ {
+ return S_OK;
+ // Exe for ARM requires S_OK
+ // return S_FALSE;
+ }
+
+ CByteBuffer buffer;
+ buffer.SetCapacity(debugLink.Size);
+ Byte *buf = buffer;
+
+ RINOK(stream->Seek(pa, STREAM_SEEK_SET, NULL));
+ RINOK(ReadStream_FALSE(stream, buf, debugLink.Size));
+
+ for (i = 0; i < (int)numItems; i++)
+ {
+ CDebugEntry de;
+ de.Parse(buf);
+
+ if (de.Size == 0)
+ continue;
+
+ CSection sect;
+ sect.Name = ".debug" + GetDecString(i);
+
+ sect.IsDebug = true;
+ sect.Time = de.Time;
+ sect.Va = de.Va;
+ sect.Pa = de.Pa;
+ sect.PSize = sect.VSize = de.Size;
+ UInt32 totalSize = sect.Pa + sect.PSize;
+ if (totalSize > _totalSize)
+ {
+ _totalSize = totalSize;
+ _sections.Add(sect);
+ thereIsSection = true;
+ }
+ buf += kEntrySize;
+ }
+
+ return S_OK;
+}
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ const UInt32 kBufSize = 1 << 18;
+ const UInt32 kSigSize = 2;
+
+ CByteBuffer buffer;
+ buffer.SetCapacity(kBufSize);
+ Byte *buf = buffer;
+
+ size_t processed = kSigSize;
+ RINOK(ReadStream_FALSE(stream, buf, processed));
+ if (buf[0] != 'M' || buf[1] != 'Z')
+ return S_FALSE;
+ processed = kBufSize - kSigSize;
+ RINOK(ReadStream(stream, buf + kSigSize, &processed));
+ processed += kSigSize;
+ if (!Parse(buf, (UInt32)processed))
+ return S_FALSE;
+ bool thereISDebug;
+ RINOK(LoadDebugSections(stream, thereISDebug));
+
+ const CDirLink &certLink = _optHeader.DirItems[kDirLink_Certificate];
+ if (certLink.Size != 0)
+ {
+ CSection sect;
+ sect.Name = "CERTIFICATE";
+ sect.Va = 0;
+ sect.Pa = certLink.Va;
+ sect.PSize = sect.VSize = certLink.Size;
+ sect.UpdateTotalSize(_totalSize);
+ _sections.Add(sect);
+ }
+
+ if (thereISDebug)
+ {
+ const UInt32 kAlign = 1 << 12;
+ UInt32 alignPos = _totalSize & (kAlign - 1);
+ if (alignPos != 0)
+ {
+ UInt32 size = kAlign - alignPos;
+ RINOK(stream->Seek(_totalSize, STREAM_SEEK_SET, NULL));
+ buffer.Free();
+ buffer.SetCapacity(kAlign);
+ Byte *buf = buffer;
+ size_t processed = size;
+ RINOK(ReadStream(stream, buf, &processed));
+ size_t i;
+ for (i = 0; i < processed; i++)
+ {
+ if (buf[i] != 0)
+ break;
+ }
+ if (processed < size && processed < 100)
+ _totalSize += (UInt32)processed;
+ else if (((_totalSize + i) & 0x1FF) == 0 || processed < size)
+ _totalSize += (UInt32)i;
+ }
+ }
+
+ if (_header.NumSymbols > 0 && _header.PointerToSymbolTable >= 512)
+ {
+ if (_header.NumSymbols >= (1 << 24))
+ return S_FALSE;
+ CSection sect;
+ sect.Name = "COFF_SYMBOLS";
+ UInt32 size = _header.NumSymbols * 18;
+ RINOK(stream->Seek((UInt64)_header.PointerToSymbolTable + size, STREAM_SEEK_SET, NULL));
+ Byte buf[4];
+ RINOK(ReadStream_FALSE(stream, buf, 4));
+ UInt32 size2 = Get32(buf);
+ if (size2 >= (1 << 28))
+ return S_FALSE;
+ size += size2;
+
+ sect.Va = 0;
+ sect.Pa = _header.PointerToSymbolTable;
+ sect.PSize = sect.VSize = size;
+ sect.UpdateTotalSize(_totalSize);
+ _sections.Add(sect);
+ }
+
+ UInt64 fileSize;
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
+ if (fileSize > _totalSize)
+ return S_FALSE;
+ _totalSizeLimited = (_totalSize < fileSize) ? _totalSize : (UInt32)fileSize;
+
+ {
+ CObjectVector<CSection> sections = _sections;
+ sections.Sort();
+ UInt32 limit = (1 << 12);
+ int num = 0;
+ for (int i = 0; i < sections.Size(); i++)
+ {
+ const CSection &s = sections[i];
+ if (s.Pa > limit)
+ {
+ CSection s2;
+ s2.Pa = s2.Va = limit;
+ s2.PSize = s2.VSize = s.Pa - limit;
+ char sz[32];
+ ConvertUInt64ToString(++num, sz);
+ s2.Name = "[data-";
+ s2.Name += sz;
+ s2.Name += "]";
+ _sections.Add(s2);
+ }
+ UInt32 next = s.Pa + s.PSize;
+ if (next < limit)
+ break;
+ limit = next;
+ }
+ }
+
+ return S_OK;
+}
+
+HRESULT CalcCheckSum(ISequentialInStream *stream, UInt32 size, UInt32 excludePos, UInt32 &res)
+{
+ // size &= ~1;
+ const UInt32 kBufSize = 1 << 23;
+ CByteBuffer buffer;
+ buffer.SetCapacity(kBufSize);
+ Byte *buf = buffer;
+
+ UInt32 sum = 0;
+ UInt32 pos;
+ for(pos = 0;;)
+ {
+ UInt32 rem = size - pos;
+ if (rem > kBufSize)
+ rem = kBufSize;
+ if (rem == 0)
+ break;
+ size_t processed = rem;
+ RINOK(ReadStream(stream, buf, &processed));
+
+ /*
+ for (; processed < rem; processed++)
+ buf[processed] = 0;
+ */
+
+ if ((processed & 1) != 0)
+ buf[processed] = 0;
+
+ for (int j = 0; j < 4; j++)
+ {
+ UInt32 p = excludePos + j;
+ if (pos <= p && p < pos + processed)
+ buf[p - pos] = 0;
+ }
+
+ for (size_t i = 0; i < processed; i += 2)
+ {
+ sum += Get16(buf + i);
+ sum = (sum + (sum >> 16)) & 0xFFFF;
+ }
+ pos += (UInt32)processed;
+ if (rem != processed)
+ break;
+ }
+ sum += pos;
+ res = sum;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ RINOK(Open2(inStream));
+ _inStream = inStream;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _sections.Clear();
+
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _sections.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _sections.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _sections[allFilesMode ? i : indices[i]].GetPackSize();
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ bool checkSumOK = true;
+ if (_optHeader.CheckSum != 0 && (int)numItems == _sections.Size())
+ {
+ UInt32 checkSum = 0;
+ RINOK(_inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ CalcCheckSum(_inStream, _totalSizeLimited, _peOffset + kHeaderSize + 64, checkSum);
+ checkSumOK = (checkSum == _optHeader.CheckSum);
+ }
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+ const CSection &item = _sections[index];
+ currentItemSize = item.GetPackSize();
+
+ CMyComPtr<ISequentialOutStream> outStream;
+ RINOK(extractCallback->GetStream(index, &outStream, askMode));
+ if (!testMode && !outStream)
+ continue;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(_inStream->Seek(item.Pa, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(currentItemSize);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == currentItemSize) ?
+ checkSumOK ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kCRCError:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"PE", L"", 0, 0xDD, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Pe)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHandler.cpp
new file mode 100644
index 000000000..93c192659
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHandler.cpp
@@ -0,0 +1,838 @@
+// RarHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../IPassword.h"
+
+#include "../../Common/CreateCoder.h"
+#include "../../Common/FilterCoder.h"
+#include "../../Common/MethodId.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../../Crypto/Rar20Crypto.h"
+#include "../../Crypto/RarAes.h"
+
+#include "../Common/ItemNameUtils.h"
+#include "../Common/OutStreamWithCRC.h"
+
+#include "RarHandler.h"
+
+using namespace NWindows;
+using namespace NTime;
+
+namespace NArchive {
+namespace NRar {
+
+static const wchar_t *kHostOS[] =
+{
+ L"MS DOS",
+ L"OS/2",
+ L"Win32",
+ L"Unix",
+ L"Mac OS",
+ L"BeOS"
+};
+
+static const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
+
+static const wchar_t *kUnknownOS = L"Unknown";
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+
+ { NULL, kpidEncrypted, VT_BOOL},
+ { NULL, kpidSolid, VT_BOOL},
+ { NULL, kpidCommented, VT_BOOL},
+ { NULL, kpidSplitBefore, VT_BOOL},
+ { NULL, kpidSplitAfter, VT_BOOL},
+ { NULL, kpidCRC, VT_UI4},
+ { NULL, kpidHostOS, VT_BSTR},
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidUnpackVer, VT_UI1}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidSolid, VT_BOOL},
+ { NULL, kpidNumBlocks, VT_UI4},
+ // { NULL, kpidEncrypted, VT_BOOL},
+ { NULL, kpidIsVolume, VT_BOOL},
+ { NULL, kpidNumVolumes, VT_UI4},
+ { NULL, kpidPhySize, VT_UI8}
+ // { NULL, kpidCommented, VT_BOOL}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+UInt64 CHandler::GetPackSize(int refIndex) const
+{
+ const CRefItem &refItem = _refItems[refIndex];
+ UInt64 totalPackSize = 0;
+ for (int i = 0; i < refItem.NumItems; i++)
+ totalPackSize += _items[refItem.ItemIndex + i].PackSize;
+ return totalPackSize;
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ // COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidSolid: prop = _archiveInfo.IsSolid(); break;
+ // case kpidEncrypted: prop = _archiveInfo.IsEncrypted(); break; // it's for encrypted names.
+ case kpidIsVolume: prop = _archiveInfo.IsVolume(); break;
+ case kpidNumVolumes: prop = (UInt32)_archives.Size(); break;
+ case kpidOffset: if (_archiveInfo.StartPosition != 0) prop = _archiveInfo.StartPosition; break;
+ // case kpidCommented: prop = _archiveInfo.IsCommented(); break;
+ case kpidNumBlocks:
+ {
+ UInt32 numBlocks = 0;
+ for (int i = 0; i < _refItems.Size(); i++)
+ if (!IsSolid(i))
+ numBlocks++;
+ prop = (UInt32)numBlocks;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ // COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _refItems.Size();
+ return S_OK;
+}
+
+static bool RarTimeToFileTime(const CRarTime &rarTime, FILETIME &result)
+{
+ if (!DosTimeToFileTime(rarTime.DosTime, result))
+ return false;
+ UInt64 value = (((UInt64)result.dwHighDateTime) << 32) + result.dwLowDateTime;
+ value += (UInt64)rarTime.LowSecond * 10000000;
+ value += ((UInt64)rarTime.SubTime[2] << 16) +
+ ((UInt64)rarTime.SubTime[1] << 8) +
+ ((UInt64)rarTime.SubTime[0]);
+ result.dwLowDateTime = (DWORD)value;
+ result.dwHighDateTime = DWORD(value >> 32);
+ return true;
+}
+
+static void RarTimeToProp(const CRarTime &rarTime, NWindows::NCOM::CPropVariant &prop)
+{
+ FILETIME localFileTime, utcFileTime;
+ if (RarTimeToFileTime(rarTime, localFileTime))
+ {
+ if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
+ utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
+ }
+ else
+ utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
+ prop = utcFileTime;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CRefItem &refItem = _refItems[index];
+ const CItemEx &item = _items[refItem.ItemIndex];
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ UString u;
+ if (item.HasUnicodeName() && !item.UnicodeName.IsEmpty())
+ u = item.UnicodeName;
+ else
+ u = MultiByteToUnicodeString(item.Name, CP_OEMCP);
+ prop = (const wchar_t *)NItemName::WinNameToOSName(u);
+ break;
+ }
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidPackSize: prop = GetPackSize(index); break;
+ case kpidMTime: RarTimeToProp(item.MTime, prop); break;
+ case kpidCTime: if (item.CTimeDefined) RarTimeToProp(item.CTime, prop); break;
+ case kpidATime: if (item.ATimeDefined) RarTimeToProp(item.ATime, prop); break;
+ case kpidAttrib: prop = item.GetWinAttributes(); break;
+ case kpidEncrypted: prop = item.IsEncrypted(); break;
+ case kpidSolid: prop = IsSolid(index); break;
+ case kpidCommented: prop = item.IsCommented(); break;
+ case kpidSplitBefore: prop = item.IsSplitBefore(); break;
+ case kpidSplitAfter: prop = _items[refItem.ItemIndex + refItem.NumItems - 1].IsSplitAfter(); break;
+ case kpidCRC:
+ {
+ const CItemEx &lastItem = _items[refItem.ItemIndex + refItem.NumItems - 1];
+ prop = ((lastItem.IsSplitAfter()) ? item.FileCRC : lastItem.FileCRC);
+ break;
+ }
+ case kpidUnpackVer: prop = item.UnPackVersion; break;
+ case kpidMethod:
+ {
+ UString method;
+ if (item.Method >= Byte('0') && item.Method <= Byte('5'))
+ {
+ method = L"m";
+ wchar_t temp[32];
+ ConvertUInt64ToString(item.Method - Byte('0'), temp);
+ method += temp;
+ if (!item.IsDir())
+ {
+ method += L":";
+ ConvertUInt64ToString(16 + item.GetDictSize(), temp);
+ method += temp;
+ }
+ }
+ else
+ {
+ wchar_t temp[32];
+ ConvertUInt64ToString(item.Method, temp);
+ method += temp;
+ }
+ prop = method;
+ break;
+ }
+ case kpidHostOS: prop = (item.HostOS < kNumHostOSes) ? (kHostOS[item.HostOS]) : kUnknownOS; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CVolumeName
+{
+ bool _first;
+ bool _newStyle;
+ UString _unchangedPart;
+ UString _changedPart;
+ UString _afterPart;
+public:
+ CVolumeName(): _newStyle(true) {};
+
+ bool InitName(const UString &name, bool newStyle)
+ {
+ _first = true;
+ _newStyle = newStyle;
+ int dotPos = name.ReverseFind('.');
+ UString basePart = name;
+ if (dotPos >= 0)
+ {
+ UString ext = name.Mid(dotPos + 1);
+ if (ext.CompareNoCase(L"rar") == 0)
+ {
+ _afterPart = name.Mid(dotPos);
+ basePart = name.Left(dotPos);
+ }
+ else if (ext.CompareNoCase(L"exe") == 0)
+ {
+ _afterPart = L".rar";
+ basePart = name.Left(dotPos);
+ }
+ else if (!_newStyle)
+ {
+ if (ext.CompareNoCase(L"000") == 0 ||
+ ext.CompareNoCase(L"001") == 0 ||
+ ext.CompareNoCase(L"r00") == 0 ||
+ ext.CompareNoCase(L"r01") == 0)
+ {
+ _afterPart.Empty();
+ _first = false;
+ _changedPart = ext;
+ _unchangedPart = name.Left(dotPos + 1);
+ return true;
+ }
+ }
+ }
+
+ if (!_newStyle)
+ {
+ _afterPart.Empty();
+ _unchangedPart = basePart + UString(L".");
+ _changedPart = L"r00";
+ return true;
+ }
+
+ int numLetters = 1;
+ if (basePart.Right(numLetters) == L"1" || basePart.Right(numLetters) == L"0")
+ {
+ while (numLetters < basePart.Length())
+ {
+ if (basePart[basePart.Length() - numLetters - 1] != '0')
+ break;
+ numLetters++;
+ }
+ }
+ else
+ return false;
+ _unchangedPart = basePart.Left(basePart.Length() - numLetters);
+ _changedPart = basePart.Right(numLetters);
+ return true;
+ }
+
+ UString GetNextName()
+ {
+ UString newName;
+ if (_newStyle || !_first)
+ {
+ int i;
+ int numLetters = _changedPart.Length();
+ for (i = numLetters - 1; i >= 0; i--)
+ {
+ wchar_t c = _changedPart[i];
+ if (c == L'9')
+ {
+ c = L'0';
+ newName = c + newName;
+ if (i == 0)
+ newName = UString(L'1') + newName;
+ continue;
+ }
+ c++;
+ newName = UString(c) + newName;
+ i--;
+ for (; i >= 0; i--)
+ newName = _changedPart[i] + newName;
+ break;
+ }
+ _changedPart = newName;
+ }
+ _first = false;
+ return _unchangedPart + _changedPart + _afterPart;
+ }
+};
+
+HRESULT CHandler::Open2(IInStream *stream,
+ const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ {
+ CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
+ CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = openArchiveCallback;
+
+ CVolumeName seqName;
+
+ UInt64 totalBytes = 0;
+ UInt64 curBytes = 0;
+
+ if (openArchiveCallback != NULL)
+ {
+ openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback, &openVolumeCallback);
+ openArchiveCallbackWrap.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
+ }
+
+ for (;;)
+ {
+ CMyComPtr<IInStream> inStream;
+ if (!_archives.IsEmpty())
+ {
+ if (!openVolumeCallback)
+ break;
+
+ if(_archives.Size() == 1)
+ {
+ if (!_archiveInfo.IsVolume())
+ break;
+ UString baseName;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
+ if (prop.vt != VT_BSTR)
+ break;
+ baseName = prop.bstrVal;
+ }
+ seqName.InitName(baseName, _archiveInfo.HaveNewVolumeName());
+ }
+
+ UString fullName = seqName.GetNextName();
+ HRESULT result = openVolumeCallback->GetStream(fullName, &inStream);
+ if (result == S_FALSE)
+ break;
+ if (result != S_OK)
+ return result;
+ if (!stream)
+ break;
+ }
+ else
+ inStream = stream;
+
+ UInt64 endPos = 0;
+ if (openArchiveCallback != NULL)
+ {
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
+ totalBytes += endPos;
+ RINOK(openArchiveCallback->SetTotal(NULL, &totalBytes));
+ }
+
+ NArchive::NRar::CInArchive archive;
+ RINOK(archive.Open(inStream, maxCheckStartPosition));
+
+ if (_archives.IsEmpty())
+ archive.GetArchiveInfo(_archiveInfo);
+
+ CItemEx item;
+ for (;;)
+ {
+ HRESULT result = archive.GetNextItem(item, getTextPassword);
+ if (result == S_FALSE)
+ break;
+ RINOK(result);
+ if (item.IgnoreItem())
+ continue;
+
+ bool needAdd = true;
+ if (item.IsSplitBefore())
+ {
+ if (!_refItems.IsEmpty())
+ {
+ CRefItem &refItem = _refItems.Back();
+ refItem.NumItems++;
+ needAdd = false;
+ }
+ }
+ if (needAdd)
+ {
+ CRefItem refItem;
+ refItem.ItemIndex = _items.Size();
+ refItem.NumItems = 1;
+ refItem.VolumeIndex = _archives.Size();
+ _refItems.Add(refItem);
+ }
+ _items.Add(item);
+ if (openArchiveCallback != NULL && _items.Size() % 100 == 0)
+ {
+ UInt64 numFiles = _items.Size();
+ UInt64 numBytes = curBytes + item.Position;
+ RINOK(openArchiveCallback->SetCompleted(&numFiles, &numBytes));
+ }
+ }
+ curBytes += endPos;
+ _archives.Add(archive);
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ Close();
+ try
+ {
+ HRESULT res = Open2(stream, maxCheckStartPosition, openArchiveCallback);
+ if (res != S_OK)
+ Close();
+ return res;
+ }
+ catch(const CInArchiveException &) { Close(); return S_FALSE; }
+ catch(...) { Close(); throw; }
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ COM_TRY_BEGIN
+ _refItems.Clear();
+ _items.Clear();
+ _archives.Clear();
+ return S_OK;
+ COM_TRY_END
+}
+
+struct CMethodItem
+{
+ Byte RarUnPackVersion;
+ CMyComPtr<ICompressCoder> Coder;
+};
+
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *_anExtractCallback)
+{
+ COM_TRY_BEGIN
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
+ bool testMode = (_aTestMode != 0);
+ CMyComPtr<IArchiveExtractCallback> extractCallback = _anExtractCallback;
+ UInt64 censoredTotalUnPacked = 0,
+ // censoredTotalPacked = 0,
+ importantTotalUnPacked = 0;
+ // importantTotalPacked = 0;
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _refItems.Size();
+ if(numItems == 0)
+ return S_OK;
+ int lastIndex = 0;
+ CRecordVector<int> importantIndexes;
+ CRecordVector<bool> extractStatuses;
+
+ for(UInt32 t = 0; t < numItems; t++)
+ {
+ int index = allFilesMode ? t : indices[t];
+ const CRefItem &refItem = _refItems[index];
+ const CItemEx &item = _items[refItem.ItemIndex];
+ censoredTotalUnPacked += item.Size;
+ // censoredTotalPacked += item.PackSize;
+ int j;
+ for(j = lastIndex; j <= index; j++)
+ // if(!_items[_refItems[j].ItemIndex].IsSolid())
+ if(!IsSolid(j))
+ lastIndex = j;
+ for(j = lastIndex; j <= index; j++)
+ {
+ const CRefItem &refItem = _refItems[j];
+ const CItemEx &item = _items[refItem.ItemIndex];
+
+ // const CItemEx &item = _items[j];
+
+ importantTotalUnPacked += item.Size;
+ // importantTotalPacked += item.PackSize;
+ importantIndexes.Add(j);
+ extractStatuses.Add(j == index);
+ }
+ lastIndex = index + 1;
+ }
+
+ extractCallback->SetTotal(importantTotalUnPacked);
+ UInt64 currentImportantTotalUnPacked = 0;
+ UInt64 currentImportantTotalPacked = 0;
+ UInt64 currentUnPackSize, currentPackSize;
+
+ CObjectVector<CMethodItem> methodItems;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CFilterCoder *filterStreamSpec = new CFilterCoder;
+ CMyComPtr<ISequentialInStream> filterStream = filterStreamSpec;
+
+ NCrypto::NRar20::CDecoder *rar20CryptoDecoderSpec = NULL;
+ CMyComPtr<ICompressFilter> rar20CryptoDecoder;
+ NCrypto::NRar29::CDecoder *rar29CryptoDecoderSpec = NULL;
+ CMyComPtr<ICompressFilter> rar29CryptoDecoder;
+
+ CFolderInStream *folderInStreamSpec = NULL;
+ CMyComPtr<ISequentialInStream> folderInStream;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ bool solidStart = true;
+ for(int i = 0; i < importantIndexes.Size(); i++,
+ currentImportantTotalUnPacked += currentUnPackSize,
+ currentImportantTotalPacked += currentPackSize)
+ {
+ lps->InSize = currentImportantTotalPacked;
+ lps->OutSize = currentImportantTotalUnPacked;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+
+ Int32 askMode;
+ if(extractStatuses[i])
+ askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ else
+ askMode = NArchive::NExtract::NAskMode::kSkip;
+
+ UInt32 index = importantIndexes[i];
+
+ const CRefItem &refItem = _refItems[index];
+ const CItemEx &item = _items[refItem.ItemIndex];
+
+ currentUnPackSize = item.Size;
+
+ currentPackSize = GetPackSize(index);
+
+ if(item.IgnoreItem())
+ continue;
+
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (!IsSolid(index))
+ solidStart = true;
+ if(item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+
+ bool mustBeProcessedAnywhere = false;
+ if(i < importantIndexes.Size() - 1)
+ {
+ // const CRefItem &nextRefItem = _refItems[importantIndexes[i + 1]];
+ // const CItemEx &nextItemInfo = _items[nextRefItem.ItemIndex];
+ // mustBeProcessedAnywhere = nextItemInfo.IsSolid();
+ mustBeProcessedAnywhere = IsSolid(importantIndexes[i + 1]);
+ }
+
+ if (!mustBeProcessedAnywhere && !testMode && !realOutStream)
+ continue;
+
+ if (!realOutStream && !testMode)
+ askMode = NArchive::NExtract::NAskMode::kSkip;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->SetStream(realOutStream);
+ outStreamSpec->Init();
+ realOutStream.Release();
+
+ /*
+ for (int partIndex = 0; partIndex < 1; partIndex++)
+ {
+ CMyComPtr<ISequentialInStream> inStream;
+
+ // item redefinition
+ const CItemEx &item = _items[refItem.ItemIndex + partIndex];
+
+ NArchive::NRar::CInArchive &archive = _archives[refItem.VolumeIndex + partIndex];
+
+ inStream.Attach(archive.CreateLimitedStream(item.GetDataPosition(),
+ item.PackSize));
+ */
+ if (!folderInStream)
+ {
+ folderInStreamSpec = new CFolderInStream;
+ folderInStream = folderInStreamSpec;
+ }
+
+ folderInStreamSpec->Init(&_archives, &_items, refItem);
+
+ UInt64 packSize = currentPackSize;
+
+ // packedPos += item.PackSize;
+ // unpackedPos += 0;
+
+ CMyComPtr<ISequentialInStream> inStream;
+ if (item.IsEncrypted())
+ {
+ CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
+ if (item.UnPackVersion >= 29)
+ {
+ if (!rar29CryptoDecoder)
+ {
+ rar29CryptoDecoderSpec = new NCrypto::NRar29::CDecoder;
+ rar29CryptoDecoder = rar29CryptoDecoderSpec;
+ // RINOK(rar29CryptoDecoder.CoCreateInstance(CLSID_CCryptoRar29Decoder));
+ }
+ rar29CryptoDecoderSpec->SetRar350Mode(item.UnPackVersion < 36);
+ CMyComPtr<ICompressSetDecoderProperties2> cryptoProperties;
+ RINOK(rar29CryptoDecoder.QueryInterface(IID_ICompressSetDecoderProperties2,
+ &cryptoProperties));
+ RINOK(cryptoProperties->SetDecoderProperties2(item.Salt, item.HasSalt() ? sizeof(item.Salt) : 0));
+ filterStreamSpec->Filter = rar29CryptoDecoder;
+ }
+ else if (item.UnPackVersion >= 20)
+ {
+ if (!rar20CryptoDecoder)
+ {
+ rar20CryptoDecoderSpec = new NCrypto::NRar20::CDecoder;
+ rar20CryptoDecoder = rar20CryptoDecoderSpec;
+ // RINOK(rar20CryptoDecoder.CoCreateInstance(CLSID_CCryptoRar20Decoder));
+ }
+ filterStreamSpec->Filter = rar20CryptoDecoder;
+ }
+ else
+ {
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ continue;
+ }
+ RINOK(filterStreamSpec->Filter.QueryInterface(IID_ICryptoSetPassword,
+ &cryptoSetPassword));
+
+ if (!getTextPassword)
+ extractCallback.QueryInterface(IID_ICryptoGetTextPassword,
+ &getTextPassword);
+ if (getTextPassword)
+ {
+ CMyComBSTR password;
+ RINOK(getTextPassword->CryptoGetTextPassword(&password));
+ if (item.UnPackVersion >= 29)
+ {
+ CByteBuffer buffer;
+ UString unicodePassword(password);
+ const UInt32 sizeInBytes = unicodePassword.Length() * 2;
+ buffer.SetCapacity(sizeInBytes);
+ for (int i = 0; i < unicodePassword.Length(); i++)
+ {
+ wchar_t c = unicodePassword[i];
+ ((Byte *)buffer)[i * 2] = (Byte)c;
+ ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
+ }
+ RINOK(cryptoSetPassword->CryptoSetPassword(
+ (const Byte *)buffer, sizeInBytes));
+ }
+ else
+ {
+ AString oemPassword = UnicodeStringToMultiByte(
+ (const wchar_t *)password, CP_OEMCP);
+ RINOK(cryptoSetPassword->CryptoSetPassword(
+ (const Byte *)(const char *)oemPassword, oemPassword.Length()));
+ }
+ }
+ else
+ {
+ RINOK(cryptoSetPassword->CryptoSetPassword(0, 0));
+ }
+ filterStreamSpec->SetInStream(folderInStream);
+ inStream = filterStream;
+ }
+ else
+ {
+ inStream = folderInStream;
+ }
+ CMyComPtr<ICompressCoder> commonCoder;
+ switch(item.Method)
+ {
+ case '0':
+ {
+ commonCoder = copyCoder;
+ break;
+ }
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ {
+ /*
+ if (item.UnPackVersion >= 29)
+ {
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ continue;
+ }
+ */
+ int m;
+ for (m = 0; m < methodItems.Size(); m++)
+ if (methodItems[m].RarUnPackVersion == item.UnPackVersion)
+ break;
+ if (m == methodItems.Size())
+ {
+ CMethodItem mi;
+ mi.RarUnPackVersion = item.UnPackVersion;
+
+ mi.Coder.Release();
+ if (item.UnPackVersion <= 30)
+ {
+ UInt32 methodID = 0x040300;
+ if (item.UnPackVersion < 20)
+ methodID += 1;
+ else if (item.UnPackVersion < 29)
+ methodID += 2;
+ else
+ methodID += 3;
+ RINOK(CreateCoder(EXTERNAL_CODECS_VARS methodID, mi.Coder, false));
+ }
+
+ if (mi.Coder == 0)
+ {
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ continue;
+ }
+
+ m = methodItems.Add(mi);
+ }
+ CMyComPtr<ICompressCoder> decoder = methodItems[m].Coder;
+
+ CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
+ RINOK(decoder.QueryInterface(IID_ICompressSetDecoderProperties2,
+ &compressSetDecoderProperties));
+
+ Byte isSolid = (Byte)((IsSolid(index) || item.IsSplitBefore()) ? 1: 0);
+ if (solidStart)
+ {
+ isSolid = false;
+ solidStart = false;
+ }
+
+
+ RINOK(compressSetDecoderProperties->SetDecoderProperties2(&isSolid, 1));
+
+ commonCoder = decoder;
+ break;
+ }
+ default:
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ continue;
+ }
+ HRESULT result = commonCoder->Code(inStream, outStream, &packSize, &item.Size, progress);
+ if (item.IsEncrypted())
+ filterStreamSpec->ReleaseInStream();
+ if (result == S_FALSE)
+ {
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kDataError));
+ continue;
+ }
+ if (result != S_OK)
+ return result;
+
+ /*
+ if (refItem.NumItems == 1 &&
+ !item.IsSplitBefore() && !item.IsSplitAfter())
+ */
+ {
+ const CItemEx &lastItem = _items[refItem.ItemIndex + refItem.NumItems - 1];
+ bool crcOK = outStreamSpec->GetCRC() == lastItem.FileCRC;
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(crcOK ? NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kCRCError));
+ }
+ /*
+ else
+ {
+ bool crcOK = true;
+ for (int partIndex = 0; partIndex < refItem.NumItems; partIndex++)
+ {
+ const CItemEx &item = _items[refItem.ItemIndex + partIndex];
+ if (item.FileCRC != folderInStreamSpec->CRCs[partIndex])
+ {
+ crcOK = false;
+ break;
+ }
+ }
+ RINOK(extractCallback->SetOperationResult(crcOK ? NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kCRCError));
+ }
+ */
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+IMPL_ISetCompressCodecsInfo
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHandler.h
new file mode 100644
index 000000000..58e3fefcf
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHandler.h
@@ -0,0 +1,60 @@
+// Rar/Handler.h
+
+#ifndef __RAR_HANDLER_H
+#define __RAR_HANDLER_H
+
+#include "../IArchive.h"
+#include "RarIn.h"
+#include "RarVolumeInStream.h"
+
+#include "../../Common/CreateCoder.h"
+
+namespace NArchive {
+namespace NRar {
+
+class CHandler:
+ public IInArchive,
+ PUBLIC_ISetCompressCodecsInfo
+ public CMyUnknownImp
+{
+public:
+ MY_QUERYINTERFACE_BEGIN2(IInArchive)
+ QUERY_ENTRY_ISetCompressCodecsInfo
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ INTERFACE_IInArchive(;)
+
+ DECL_ISetCompressCodecsInfo
+
+private:
+ CRecordVector<CRefItem> _refItems;
+ CObjectVector<CItemEx> _items;
+ CObjectVector<CInArchive> _archives;
+ NArchive::NRar::CInArchiveInfo _archiveInfo;
+
+ DECL_EXTERNAL_CODECS_VARS
+
+ UInt64 GetPackSize(int refIndex) const;
+ // NArchive::NRar::CInArchive _archive;
+
+ bool IsSolid(int refIndex)
+ {
+ const CItemEx &item = _items[_refItems[refIndex].ItemIndex];
+ if (item.UnPackVersion < 20)
+ {
+ if (_archiveInfo.IsSolid())
+ return (refIndex > 0);
+ return false;
+ }
+ return item.IsSolid();
+ }
+
+ HRESULT Open2(IInStream *stream,
+ const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *openArchiveCallback);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHeader.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHeader.cpp
new file mode 100644
index 000000000..94481e025
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHeader.cpp
@@ -0,0 +1,21 @@
+// Archive/Rar/Headers.cpp
+
+#include "StdAfx.h"
+
+#include "RarHeader.h"
+
+namespace NArchive{
+namespace NRar{
+namespace NHeader{
+
+Byte kMarker[kMarkerSize] = {0x52 + 1, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00};
+
+class CMarkerInitializer
+{
+public:
+ CMarkerInitializer() { kMarker[0]--; };
+};
+
+static CMarkerInitializer markerInitializer;
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHeader.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHeader.h
new file mode 100644
index 000000000..4df42e628
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarHeader.h
@@ -0,0 +1,224 @@
+// Archive/RarHeader.h
+
+#ifndef __ARCHIVE_RAR_HEADER_H
+#define __ARCHIVE_RAR_HEADER_H
+
+#include "Common/Types.h"
+
+namespace NArchive{
+namespace NRar{
+namespace NHeader{
+
+const int kMarkerSize = 7;
+extern Byte kMarker[kMarkerSize];
+
+const int kArchiveSolid = 0x1;
+
+namespace NBlockType
+{
+ enum EBlockType
+ {
+ kMarker = 0x72,
+ kArchiveHeader = 0x73,
+ kFileHeader = 0x74,
+ kCommentHeader = 0x75,
+ kOldAuthenticity = 0x76,
+ kSubBlock = 0x77,
+ kRecoveryRecord = 0x78,
+ kAuthenticity = 0x79,
+
+ kEndOfArchive = 0x7B // Is not safe
+ };
+}
+
+namespace NArchive
+{
+ const UInt16 kVolume = 1;
+ const UInt16 kComment = 2;
+ const UInt16 kLock = 4;
+ const UInt16 kSolid = 8;
+ const UInt16 kNewVolName = 0x10; // ('volname.partN.rar')
+ const UInt16 kAuthenticity = 0x20;
+ const UInt16 kRecovery = 0x40;
+ const UInt16 kBlockEncryption = 0x80;
+ const UInt16 kFirstVolume = 0x100; // (set only by RAR 3.0 and later)
+ const UInt16 kEncryptVer = 0x200; // RAR 3.6 there is EncryptVer Byte in End of MainHeader
+
+ const int kHeaderSizeMin = 7;
+
+ struct CBlock
+ {
+ UInt16 CRC;
+ Byte Type;
+ UInt16 Flags;
+ UInt16 Size;
+ UInt16 Reserved1;
+ UInt32 Reserved2;
+ // UInt16 GetRealCRC() const;
+ };
+
+ const int kArchiveHeaderSize = 13;
+
+ const int kBlockHeadersAreEncrypted = 0x80;
+
+ struct CHeader360: public CBlock
+ {
+ Byte EncryptVersion;
+ bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; }
+ bool IsThereEncryptVer() const { return (Flags & NHeader::NArchive::kEncryptVer) != 0; }
+ bool IsEncryptOld() const { return (!IsThereEncryptVer() || EncryptVersion < 36); }
+ UInt32 GetBaseSize() const { return kArchiveHeaderSize + (IsEncryptOld() ? 0 : 1); }
+ };
+}
+
+namespace NFile
+{
+ const int kSplitBefore = 1 << 0;
+ const int kSplitAfter = 1 << 1;
+ const int kEncrypted = 1 << 2;
+ const int kComment = 1 << 3;
+ const int kSolid = 1 << 4;
+
+ const int kDictBitStart = 5;
+ const int kNumDictBits = 3;
+ const int kDictMask = (1 << kNumDictBits) - 1;
+ const int kDictDirectoryValue = 0x7;
+
+ const int kSize64Bits = 1 << 8;
+ const int kUnicodeName = 1 << 9;
+ const int kSalt = 1 << 10;
+ const int kOldVersion = 1 << 11;
+ const int kExtTime = 1 << 12;
+ // const int kExtFlags = 1 << 13;
+ // const int kSkipIfUnknown = 1 << 14;
+
+ const int kLongBlock = 1 << 15;
+
+ /*
+ struct CBlock
+ {
+ // UInt16 HeadCRC;
+ // Byte Type;
+ // UInt16 Flags;
+ // UInt16 HeadSize;
+ UInt32 PackSize;
+ UInt32 UnPackSize;
+ Byte HostOS;
+ UInt32 FileCRC;
+ UInt32 Time;
+ Byte UnPackVersion;
+ Byte Method;
+ UInt16 NameSize;
+ UInt32 Attributes;
+ };
+ */
+
+ /*
+ struct CBlock32
+ {
+ UInt16 HeadCRC;
+ Byte Type;
+ UInt16 Flags;
+ UInt16 HeadSize;
+ UInt32 PackSize;
+ UInt32 UnPackSize;
+ Byte HostOS;
+ UInt32 FileCRC;
+ UInt32 Time;
+ Byte UnPackVersion;
+ Byte Method;
+ UInt16 NameSize;
+ UInt32 Attributes;
+ UInt16 GetRealCRC(const void *aName, UInt32 aNameSize,
+ bool anExtraDataDefined = false, Byte *anExtraData = 0) const;
+ };
+ struct CBlock64
+ {
+ UInt16 HeadCRC;
+ Byte Type;
+ UInt16 Flags;
+ UInt16 HeadSize;
+ UInt32 PackSizeLow;
+ UInt32 UnPackSizeLow;
+ Byte HostOS;
+ UInt32 FileCRC;
+ UInt32 Time;
+ Byte UnPackVersion;
+ Byte Method;
+ UInt16 NameSize;
+ UInt32 Attributes;
+ UInt32 PackSizeHigh;
+ UInt32 UnPackSizeHigh;
+ UInt16 GetRealCRC(const void *aName, UInt32 aNameSize) const;
+ };
+ */
+
+ const int kLabelFileAttribute = 0x08;
+ const int kWinFileDirectoryAttributeMask = 0x10;
+
+ enum CHostOS
+ {
+ kHostMSDOS = 0,
+ kHostOS2 = 1,
+ kHostWin32 = 2,
+ kHostUnix = 3,
+ kHostMacOS = 4,
+ kHostBeOS = 5
+ };
+}
+
+namespace NBlock
+{
+ const UInt16 kLongBlock = 1 << 15;
+ struct CBlock
+ {
+ UInt16 CRC;
+ Byte Type;
+ UInt16 Flags;
+ UInt16 HeadSize;
+ // UInt32 DataSize;
+ };
+}
+
+/*
+struct CSubBlock
+{
+ UInt16 HeadCRC;
+ Byte HeadType;
+ UInt16 Flags;
+ UInt16 HeadSize;
+ UInt32 DataSize;
+ UInt16 SubType;
+ Byte Level; // Reserved : Must be 0
+};
+
+struct CCommentBlock
+{
+ UInt16 HeadCRC;
+ Byte HeadType;
+ UInt16 Flags;
+ UInt16 HeadSize;
+ UInt16 UnpSize;
+ Byte UnpVer;
+ Byte Method;
+ UInt16 CommCRC;
+};
+
+
+struct CProtectHeader
+{
+ UInt16 HeadCRC;
+ Byte HeadType;
+ UInt16 Flags;
+ UInt16 HeadSize;
+ UInt32 DataSize;
+ Byte Version;
+ UInt16 RecSectors;
+ UInt32 TotalBlocks;
+ Byte Mark[8];
+};
+*/
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarIn.cpp
new file mode 100644
index 000000000..4810649ba
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarIn.cpp
@@ -0,0 +1,511 @@
+// Archive/RarIn.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/7zCrc.h"
+
+#include "Common/StringConvert.h"
+#include "Common/UTFConvert.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/StreamUtils.h"
+
+#include "../Common/FindSignature.h"
+
+#include "RarIn.h"
+
+namespace NArchive {
+namespace NRar {
+
+void CInArchive::ThrowExceptionWithCode(
+ CInArchiveException::CCauseType cause)
+{
+ throw CInArchiveException(cause);
+}
+
+HRESULT CInArchive::Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit)
+{
+ try
+ {
+ Close();
+ HRESULT res = Open2(inStream, searchHeaderSizeLimit);
+ if (res == S_OK)
+ return res;
+ Close();
+ return res;
+ }
+ catch(...) { Close(); throw; }
+}
+
+void CInArchive::Close()
+{
+ m_Stream.Release();
+}
+
+
+static inline bool TestMarkerCandidate(const void *aTestBytes)
+{
+ for (UInt32 i = 0; i < NHeader::kMarkerSize; i++)
+ if (((const Byte *)aTestBytes)[i] != NHeader::kMarker[i])
+ return false;
+ return true;
+}
+
+HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
+{
+ RINOK(FindSignatureInStream(stream,
+ NHeader::kMarker, NHeader::kMarkerSize,
+ searchHeaderSizeLimit, m_ArchiveStartPosition));
+ m_Stream = stream;
+ m_Position = m_ArchiveStartPosition + NHeader::kMarkerSize;
+ return m_Stream->Seek(m_Position, STREAM_SEEK_SET, NULL);
+}
+
+void CInArchive::ThrowUnexpectedEndOfArchiveException()
+{
+ ThrowExceptionWithCode(CInArchiveException::kUnexpectedEndOfArchive);
+}
+
+bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
+{
+ if (m_CryptoMode)
+ {
+ const Byte *bufData = (const Byte *)m_DecryptedData;
+ UInt32 bufSize = m_DecryptedDataSize;
+ UInt32 i;
+ for (i = 0; i < size && m_CryptoPos < bufSize; i++)
+ ((Byte *)data)[i] = bufData[m_CryptoPos++];
+ return (i == size);
+ }
+ return (ReadStream_FALSE(m_Stream, data, size) == S_OK);
+}
+
+void CInArchive::ReadBytesAndTestResult(void *data, UInt32 size)
+{
+ if(!ReadBytesAndTestSize(data,size))
+ ThrowUnexpectedEndOfArchiveException();
+}
+
+HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
+{
+ size_t realProcessedSize = size;
+ HRESULT result = ReadStream(m_Stream, data, &realProcessedSize);
+ if (processedSize != NULL)
+ *processedSize = (UInt32)realProcessedSize;
+ AddToSeekValue(realProcessedSize);
+ return result;
+}
+
+static UInt32 CrcUpdateUInt16(UInt32 crc, UInt16 v)
+{
+ crc = CRC_UPDATE_BYTE(crc, (Byte)(v & 0xFF));
+ crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 8) & 0xFF));
+ return crc;
+}
+
+static UInt32 CrcUpdateUInt32(UInt32 crc, UInt32 v)
+{
+ crc = CRC_UPDATE_BYTE(crc, (Byte)(v & 0xFF));
+ crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 8) & 0xFF));
+ crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 16) & 0xFF));
+ crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 24) & 0xFF));
+ return crc;
+}
+
+
+HRESULT CInArchive::Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
+{
+ m_CryptoMode = false;
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, &m_StreamStartPosition));
+ m_Position = m_StreamStartPosition;
+
+ RINOK(FindAndReadMarker(stream, searchHeaderSizeLimit));
+
+ Byte buf[NHeader::NArchive::kArchiveHeaderSize];
+ UInt32 processedSize;
+ ReadBytes(buf, sizeof(buf), &processedSize);
+ if (processedSize != sizeof(buf))
+ return S_FALSE;
+ m_CurData = buf;
+ m_CurPos = 0;
+ m_PosLimit = sizeof(buf);
+
+ m_ArchiveHeader.CRC = ReadUInt16();
+ m_ArchiveHeader.Type = ReadByte();
+ m_ArchiveHeader.Flags = ReadUInt16();
+ m_ArchiveHeader.Size = ReadUInt16();
+ m_ArchiveHeader.Reserved1 = ReadUInt16();
+ m_ArchiveHeader.Reserved2 = ReadUInt32();
+ m_ArchiveHeader.EncryptVersion = 0;
+
+ UInt32 crc = CRC_INIT_VAL;
+ crc = CRC_UPDATE_BYTE(crc, m_ArchiveHeader.Type);
+ crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Flags);
+ crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Size);
+ crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Reserved1);
+ crc = CrcUpdateUInt32(crc, m_ArchiveHeader.Reserved2);
+
+ if (m_ArchiveHeader.IsThereEncryptVer() && m_ArchiveHeader.Size > NHeader::NArchive::kArchiveHeaderSize)
+ {
+ ReadBytes(&m_ArchiveHeader.EncryptVersion, 1, &processedSize);
+ if (processedSize != 1)
+ return S_FALSE;
+ crc = CRC_UPDATE_BYTE(crc, m_ArchiveHeader.EncryptVersion);
+ }
+
+ if(m_ArchiveHeader.CRC != (CRC_GET_DIGEST(crc) & 0xFFFF))
+ ThrowExceptionWithCode(CInArchiveException::kArchiveHeaderCRCError);
+ if (m_ArchiveHeader.Type != NHeader::NBlockType::kArchiveHeader)
+ return S_FALSE;
+ m_ArchiveCommentPosition = m_Position;
+ m_SeekOnArchiveComment = true;
+ return S_OK;
+}
+
+void CInArchive::SkipArchiveComment()
+{
+ if (!m_SeekOnArchiveComment)
+ return;
+ AddToSeekValue(m_ArchiveHeader.Size - m_ArchiveHeader.GetBaseSize());
+ m_SeekOnArchiveComment = false;
+}
+
+void CInArchive::GetArchiveInfo(CInArchiveInfo &archiveInfo) const
+{
+ archiveInfo.StartPosition = m_ArchiveStartPosition;
+ archiveInfo.Flags = m_ArchiveHeader.Flags;
+ archiveInfo.CommentPosition = m_ArchiveCommentPosition;
+ archiveInfo.CommentSize = (UInt16)(m_ArchiveHeader.Size - NHeader::NArchive::kArchiveHeaderSize);
+}
+
+static void DecodeUnicodeFileName(const char *name, const Byte *encName,
+ int encSize, wchar_t *unicodeName, int maxDecSize)
+{
+ int encPos = 0;
+ int decPos = 0;
+ int flagBits = 0;
+ Byte flags = 0;
+ Byte highByte = encName[encPos++];
+ while (encPos < encSize && decPos < maxDecSize)
+ {
+ if (flagBits == 0)
+ {
+ flags = encName[encPos++];
+ flagBits = 8;
+ }
+ switch(flags >> 6)
+ {
+ case 0:
+ unicodeName[decPos++] = encName[encPos++];
+ break;
+ case 1:
+ unicodeName[decPos++] = (wchar_t)(encName[encPos++] + (highByte << 8));
+ break;
+ case 2:
+ unicodeName[decPos++] = (wchar_t)(encName[encPos] + (encName[encPos + 1] << 8));
+ encPos += 2;
+ break;
+ case 3:
+ {
+ int length = encName[encPos++];
+ if (length & 0x80)
+ {
+ Byte correction = encName[encPos++];
+ for (length = (length & 0x7f) + 2;
+ length > 0 && decPos < maxDecSize; length--, decPos++)
+ unicodeName[decPos] = (wchar_t)(((name[decPos] + correction) & 0xff) + (highByte << 8));
+ }
+ else
+ for (length += 2; length > 0 && decPos < maxDecSize; length--, decPos++)
+ unicodeName[decPos] = name[decPos];
+ }
+ break;
+ }
+ flags <<= 2;
+ flagBits -= 2;
+ }
+ unicodeName[decPos < maxDecSize ? decPos : maxDecSize - 1] = 0;
+}
+
+void CInArchive::ReadName(CItemEx &item, int nameSize)
+{
+ item.UnicodeName.Empty();
+ if (nameSize > 0)
+ {
+ m_NameBuffer.EnsureCapacity(nameSize + 1);
+ char *buffer = (char *)m_NameBuffer;
+
+ for (int i = 0; i < nameSize; i++)
+ buffer[i] = ReadByte();
+
+ int mainLen;
+ for (mainLen = 0; mainLen < nameSize; mainLen++)
+ if (buffer[mainLen] == '\0')
+ break;
+ buffer[mainLen] = '\0';
+ item.Name = buffer;
+
+ if(item.HasUnicodeName())
+ {
+ if(mainLen < nameSize)
+ {
+ int unicodeNameSizeMax = MyMin(nameSize, (0x400));
+ _unicodeNameBuffer.EnsureCapacity(unicodeNameSizeMax + 1);
+ DecodeUnicodeFileName(buffer, (const Byte *)buffer + mainLen + 1,
+ nameSize - (mainLen + 1), _unicodeNameBuffer, unicodeNameSizeMax);
+ item.UnicodeName = _unicodeNameBuffer;
+ }
+ else if (!ConvertUTF8ToUnicode(item.Name, item.UnicodeName))
+ item.UnicodeName.Empty();
+ }
+ }
+ else
+ item.Name.Empty();
+}
+
+Byte CInArchive::ReadByte()
+{
+ if (m_CurPos >= m_PosLimit)
+ throw CInArchiveException(CInArchiveException::kIncorrectArchive);
+ return m_CurData[m_CurPos++];
+}
+
+UInt16 CInArchive::ReadUInt16()
+{
+ UInt16 value = 0;
+ for (int i = 0; i < 2; i++)
+ {
+ Byte b = ReadByte();
+ value |= (UInt16(b) << (8 * i));
+ }
+ return value;
+}
+
+UInt32 CInArchive::ReadUInt32()
+{
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ Byte b = ReadByte();
+ value |= (UInt32(b) << (8 * i));
+ }
+ return value;
+}
+
+void CInArchive::ReadTime(Byte mask, CRarTime &rarTime)
+{
+ rarTime.LowSecond = (Byte)(((mask & 4) != 0) ? 1 : 0);
+ int numDigits = (mask & 3);
+ rarTime.SubTime[0] = rarTime.SubTime[1] = rarTime.SubTime[2] = 0;
+ for (int i = 0; i < numDigits; i++)
+ rarTime.SubTime[3 - numDigits + i] = ReadByte();
+}
+
+void CInArchive::ReadHeaderReal(CItemEx &item)
+{
+ item.Flags = m_BlockHeader.Flags;
+ item.PackSize = ReadUInt32();
+ item.Size = ReadUInt32();
+ item.HostOS = ReadByte();
+ item.FileCRC = ReadUInt32();
+ item.MTime.DosTime = ReadUInt32();
+ item.UnPackVersion = ReadByte();
+ item.Method = ReadByte();
+ int nameSize = ReadUInt16();
+ item.Attrib = ReadUInt32();
+
+ item.MTime.LowSecond = 0;
+ item.MTime.SubTime[0] =
+ item.MTime.SubTime[1] =
+ item.MTime.SubTime[2] = 0;
+
+ if((item.Flags & NHeader::NFile::kSize64Bits) != 0)
+ {
+ item.PackSize |= ((UInt64)ReadUInt32() << 32);
+ item.Size |= ((UInt64)ReadUInt32() << 32);
+ }
+
+ ReadName(item, nameSize);
+
+ if (item.HasSalt())
+ for (int i = 0; i < sizeof(item.Salt); i++)
+ item.Salt[i] = ReadByte();
+
+ // some rar archives have HasExtTime flag without field.
+ if (m_CurPos < m_PosLimit && item.HasExtTime())
+ {
+ Byte accessMask = (Byte)(ReadByte() >> 4);
+ Byte b = ReadByte();
+ Byte modifMask = (Byte)(b >> 4);
+ Byte createMask = (Byte)(b & 0xF);
+ if ((modifMask & 8) != 0)
+ ReadTime(modifMask, item.MTime);
+ item.CTimeDefined = ((createMask & 8) != 0);
+ if (item.CTimeDefined)
+ {
+ item.CTime.DosTime = ReadUInt32();
+ ReadTime(createMask, item.CTime);
+ }
+ item.ATimeDefined = ((accessMask & 8) != 0);
+ if (item.ATimeDefined)
+ {
+ item.ATime.DosTime = ReadUInt32();
+ ReadTime(accessMask, item.ATime);
+ }
+ }
+
+ UInt16 fileHeaderWithNameSize = (UInt16)m_CurPos;
+
+ item.Position = m_Position;
+ item.MainPartSize = fileHeaderWithNameSize;
+ item.CommentSize = (UInt16)(m_BlockHeader.HeadSize - fileHeaderWithNameSize);
+
+ if (m_CryptoMode)
+ item.AlignSize = (UInt16)((16 - ((m_BlockHeader.HeadSize) & 0xF)) & 0xF);
+ else
+ item.AlignSize = 0;
+ AddToSeekValue(m_BlockHeader.HeadSize);
+}
+
+void CInArchive::AddToSeekValue(UInt64 addValue)
+{
+ m_Position += addValue;
+}
+
+HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword)
+{
+ if (m_SeekOnArchiveComment)
+ SkipArchiveComment();
+ for (;;)
+ {
+ if(!SeekInArchive(m_Position))
+ return S_FALSE;
+ if (!m_CryptoMode && (m_ArchiveHeader.Flags &
+ NHeader::NArchive::kBlockHeadersAreEncrypted) != 0)
+ {
+ m_CryptoMode = false;
+ if (getTextPassword == 0)
+ return S_FALSE;
+ if(!SeekInArchive(m_Position))
+ return S_FALSE;
+ if (!m_RarAES)
+ {
+ m_RarAESSpec = new NCrypto::NRar29::CDecoder;
+ m_RarAES = m_RarAESSpec;
+ }
+ m_RarAESSpec->SetRar350Mode(m_ArchiveHeader.IsEncryptOld());
+
+ // Salt
+ const UInt32 kSaltSize = 8;
+ Byte salt[kSaltSize];
+ if(!ReadBytesAndTestSize(salt, kSaltSize))
+ return S_FALSE;
+ m_Position += kSaltSize;
+ RINOK(m_RarAESSpec->SetDecoderProperties2(salt, kSaltSize))
+ // Password
+ CMyComBSTR password;
+ RINOK(getTextPassword->CryptoGetTextPassword(&password))
+ UString unicodePassword(password);
+
+ CByteBuffer buffer;
+ const UInt32 sizeInBytes = unicodePassword.Length() * 2;
+ buffer.SetCapacity(sizeInBytes);
+ for (int i = 0; i < unicodePassword.Length(); i++)
+ {
+ wchar_t c = unicodePassword[i];
+ ((Byte *)buffer)[i * 2] = (Byte)c;
+ ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
+ }
+
+ RINOK(m_RarAESSpec->CryptoSetPassword((const Byte *)buffer, sizeInBytes));
+
+ const UInt32 kDecryptedBufferSize = (1 << 12);
+ if (m_DecryptedData.GetCapacity() == 0)
+ {
+ m_DecryptedData.SetCapacity(kDecryptedBufferSize);
+ }
+ RINOK(m_RarAES->Init());
+ size_t decryptedDataSizeT = kDecryptedBufferSize;
+ RINOK(ReadStream(m_Stream, (Byte *)m_DecryptedData, &decryptedDataSizeT));
+ m_DecryptedDataSize = (UInt32)decryptedDataSizeT;
+ m_DecryptedDataSize = m_RarAES->Filter((Byte *)m_DecryptedData, m_DecryptedDataSize);
+
+ m_CryptoMode = true;
+ m_CryptoPos = 0;
+ }
+
+ m_FileHeaderData.EnsureCapacity(7);
+ if(!ReadBytesAndTestSize((Byte *)m_FileHeaderData, 7))
+ return S_FALSE;
+
+ m_CurData = (Byte *)m_FileHeaderData;
+ m_CurPos = 0;
+ m_PosLimit = 7;
+ m_BlockHeader.CRC = ReadUInt16();
+ m_BlockHeader.Type = ReadByte();
+ m_BlockHeader.Flags = ReadUInt16();
+ m_BlockHeader.HeadSize = ReadUInt16();
+
+ if (m_BlockHeader.HeadSize < 7)
+ ThrowExceptionWithCode(CInArchiveException::kIncorrectArchive);
+
+ if (m_BlockHeader.Type == NHeader::NBlockType::kEndOfArchive)
+ return S_FALSE;
+
+ if (m_BlockHeader.Type == NHeader::NBlockType::kFileHeader)
+ {
+ m_FileHeaderData.EnsureCapacity(m_BlockHeader.HeadSize);
+ m_CurData = (Byte *)m_FileHeaderData;
+ m_PosLimit = m_BlockHeader.HeadSize;
+ ReadBytesAndTestResult(m_CurData + m_CurPos, m_BlockHeader.HeadSize - 7);
+ ReadHeaderReal(item);
+ if ((CrcCalc(m_CurData + 2,
+ m_BlockHeader.HeadSize - item.CommentSize - 2) & 0xFFFF) != m_BlockHeader.CRC)
+ ThrowExceptionWithCode(CInArchiveException::kFileHeaderCRCError);
+
+ FinishCryptoBlock();
+ m_CryptoMode = false;
+ SeekInArchive(m_Position); // Move Position to compressed Data;
+ AddToSeekValue(item.PackSize); // m_Position points to next header;
+ return S_OK;
+ }
+ if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 12))
+ return E_FAIL; // it's for bad passwords
+ if ((m_BlockHeader.Flags & NHeader::NBlock::kLongBlock) != 0)
+ {
+ m_FileHeaderData.EnsureCapacity(7 + 4);
+ m_CurData = (Byte *)m_FileHeaderData;
+ ReadBytesAndTestResult(m_CurData + m_CurPos, 4); // test it
+ m_PosLimit = 7 + 4;
+ UInt32 dataSize = ReadUInt32();
+ AddToSeekValue(dataSize);
+ if (m_CryptoMode && dataSize > (1 << 27))
+ return E_FAIL; // it's for bad passwords
+ m_CryptoPos = m_BlockHeader.HeadSize;
+ }
+ else
+ m_CryptoPos = 0;
+ AddToSeekValue(m_BlockHeader.HeadSize);
+ FinishCryptoBlock();
+ m_CryptoMode = false;
+ }
+}
+
+bool CInArchive::SeekInArchive(UInt64 position)
+{
+ UInt64 newPosition;
+ m_Stream->Seek(position, STREAM_SEEK_SET, &newPosition);
+ return newPosition == position;
+}
+
+ISequentialInStream* CInArchive::CreateLimitedStream(UInt64 position, UInt64 size)
+{
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ SeekInArchive(position);
+ streamSpec->SetStream(m_Stream);
+ streamSpec->Init(size);
+ return inStream.Detach();
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarIn.h
new file mode 100644
index 000000000..ff97a1090
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarIn.h
@@ -0,0 +1,126 @@
+// RarIn.h
+
+#ifndef __ARCHIVE_RAR_IN_H
+#define __ARCHIVE_RAR_IN_H
+
+#include "Common/DynamicBuffer.h"
+#include "Common/MyCom.h"
+
+#include "../../ICoder.h"
+#include "../../IStream.h"
+
+#include "../../Common/StreamObjects.h"
+
+#include "../../Crypto/RarAes.h"
+
+#include "RarHeader.h"
+#include "RarItem.h"
+
+namespace NArchive {
+namespace NRar {
+
+class CInArchiveException
+{
+public:
+ enum CCauseType
+ {
+ kUnexpectedEndOfArchive = 0,
+ kArchiveHeaderCRCError,
+ kFileHeaderCRCError,
+ kIncorrectArchive
+ }
+ Cause;
+ CInArchiveException(CCauseType cause) : Cause(cause) {}
+};
+
+class CInArchiveInfo
+{
+public:
+ UInt64 StartPosition;
+ UInt16 Flags;
+ UInt64 CommentPosition;
+ UInt16 CommentSize;
+ bool IsSolid() const { return (Flags & NHeader::NArchive::kSolid) != 0; }
+ bool IsCommented() const { return (Flags & NHeader::NArchive::kComment) != 0; }
+ bool IsVolume() const { return (Flags & NHeader::NArchive::kVolume) != 0; }
+ bool HaveNewVolumeName() const { return (Flags & NHeader::NArchive::kNewVolName) != 0; }
+ bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; }
+};
+
+class CInArchive
+{
+ CMyComPtr<IInStream> m_Stream;
+
+ UInt64 m_StreamStartPosition;
+ UInt64 m_Position;
+ UInt64 m_ArchiveStartPosition;
+
+ NHeader::NArchive::CHeader360 m_ArchiveHeader;
+ CDynamicBuffer<char> m_NameBuffer;
+ CDynamicBuffer<wchar_t> _unicodeNameBuffer;
+ bool m_SeekOnArchiveComment;
+ UInt64 m_ArchiveCommentPosition;
+
+ void ReadName(CItemEx &item, int nameSize);
+ void ReadHeaderReal(CItemEx &item);
+
+ HRESULT ReadBytes(void *data, UInt32 size, UInt32 *aProcessedSize);
+ bool ReadBytesAndTestSize(void *data, UInt32 size);
+ void ReadBytesAndTestResult(void *data, UInt32 size);
+
+ HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
+ HRESULT Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
+
+ void ThrowExceptionWithCode(CInArchiveException::CCauseType cause);
+ void ThrowUnexpectedEndOfArchiveException();
+
+ void AddToSeekValue(UInt64 addValue);
+
+protected:
+
+ CDynamicBuffer<Byte> m_FileHeaderData;
+
+ NHeader::NBlock::CBlock m_BlockHeader;
+
+ NCrypto::NRar29::CDecoder *m_RarAESSpec;
+ CMyComPtr<ICompressFilter> m_RarAES;
+
+ Byte *m_CurData; // it must point to start of Rar::Block
+ UInt32 m_CurPos;
+ UInt32 m_PosLimit;
+ Byte ReadByte();
+ UInt16 ReadUInt16();
+ UInt32 ReadUInt32();
+ void ReadTime(Byte mask, CRarTime &rarTime);
+
+ CBuffer<Byte> m_DecryptedData;
+ UInt32 m_DecryptedDataSize;
+
+ bool m_CryptoMode;
+ UInt32 m_CryptoPos;
+ void FinishCryptoBlock()
+ {
+ if (m_CryptoMode)
+ while ((m_CryptoPos & 0xF) != 0)
+ {
+ m_CryptoPos++;
+ m_Position++;
+ }
+ }
+
+public:
+ HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
+ void Close();
+ HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword);
+
+ void SkipArchiveComment();
+
+ void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
+
+ bool SeekInArchive(UInt64 position);
+ ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarItem.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarItem.cpp
new file mode 100644
index 000000000..9216ae57b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarItem.cpp
@@ -0,0 +1,55 @@
+// RarItem.cpp
+
+#include "StdAfx.h"
+
+#include "RarItem.h"
+
+namespace NArchive{
+namespace NRar{
+
+bool CItem::IgnoreItem() const
+{
+ switch(HostOS)
+ {
+ case NHeader::NFile::kHostMSDOS:
+ case NHeader::NFile::kHostOS2:
+ case NHeader::NFile::kHostWin32:
+ return ((Attrib & NHeader::NFile::kLabelFileAttribute) != 0);
+ }
+ return false;
+}
+
+bool CItem::IsDir() const
+{
+ if (GetDictSize() == NHeader::NFile::kDictDirectoryValue)
+ return true;
+ switch(HostOS)
+ {
+ case NHeader::NFile::kHostMSDOS:
+ case NHeader::NFile::kHostOS2:
+ case NHeader::NFile::kHostWin32:
+ if ((Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
+ return true;
+ }
+ return false;
+}
+
+UInt32 CItem::GetWinAttributes() const
+{
+ UInt32 winAttributes;
+ switch(HostOS)
+ {
+ case NHeader::NFile::kHostMSDOS:
+ case NHeader::NFile::kHostOS2:
+ case NHeader::NFile::kHostWin32:
+ winAttributes = Attrib;
+ break;
+ default:
+ winAttributes = 0; // must be converted from unix value;
+ }
+ if (IsDir())
+ winAttributes |= NHeader::NFile::kWinFileDirectoryAttributeMask;
+ return winAttributes;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarItem.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarItem.h
new file mode 100644
index 000000000..4aa4d8667
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarItem.h
@@ -0,0 +1,79 @@
+// RarItem.h
+
+#ifndef __ARCHIVE_RAR_ITEM_H
+#define __ARCHIVE_RAR_ITEM_H
+
+#include "Common/Types.h"
+#include "Common/MyString.h"
+
+#include "RarHeader.h"
+
+namespace NArchive{
+namespace NRar{
+
+struct CRarTime
+{
+ UInt32 DosTime;
+ Byte LowSecond;
+ Byte SubTime[3];
+};
+
+struct CItem
+{
+ UInt64 Size;
+ UInt64 PackSize;
+
+ CRarTime CTime;
+ CRarTime ATime;
+ CRarTime MTime;
+
+ UInt32 FileCRC;
+ UInt32 Attrib;
+
+ UInt16 Flags;
+ Byte HostOS;
+ Byte UnPackVersion;
+ Byte Method;
+
+ bool CTimeDefined;
+ bool ATimeDefined;
+
+ AString Name;
+ UString UnicodeName;
+
+ Byte Salt[8];
+
+ bool IsEncrypted() const { return (Flags & NHeader::NFile::kEncrypted) != 0; }
+ bool IsSolid() const { return (Flags & NHeader::NFile::kSolid) != 0; }
+ bool IsCommented() const { return (Flags & NHeader::NFile::kComment) != 0; }
+ bool IsSplitBefore() const { return (Flags & NHeader::NFile::kSplitBefore) != 0; }
+ bool IsSplitAfter() const { return (Flags & NHeader::NFile::kSplitAfter) != 0; }
+ bool HasSalt() const { return (Flags & NHeader::NFile::kSalt) != 0; }
+ bool HasExtTime() const { return (Flags & NHeader::NFile::kExtTime) != 0; }
+ bool HasUnicodeName()const { return (Flags & NHeader::NFile::kUnicodeName) != 0; }
+ bool IsOldVersion() const { return (Flags & NHeader::NFile::kOldVersion) != 0; }
+
+ UInt32 GetDictSize() const { return (Flags >> NHeader::NFile::kDictBitStart) & NHeader::NFile::kDictMask; }
+ bool IsDir() const;
+ bool IgnoreItem() const;
+ UInt32 GetWinAttributes() const;
+
+ CItem(): CTimeDefined(false), ATimeDefined(false) {}
+};
+
+class CItemEx: public CItem
+{
+public:
+ UInt64 Position;
+ UInt16 MainPartSize;
+ UInt16 CommentSize;
+ UInt16 AlignSize;
+ UInt64 GetFullSize() const { return MainPartSize + CommentSize + AlignSize + PackSize; };
+ // DWORD GetHeaderWithCommentSize() const { return MainPartSize + CommentSize; };
+ UInt64 GetCommentPosition() const { return Position + MainPartSize; };
+ UInt64 GetDataPosition() const { return GetCommentPosition() + CommentSize + AlignSize; };
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarRegister.cpp
new file mode 100644
index 000000000..a79fd0264
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarRegister.cpp
@@ -0,0 +1,13 @@
+// RarRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "RarHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NRar::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Rar", L"rar r00", 0, 3, {0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}, 7, false, CreateArc, 0, };
+
+REGISTER_ARC(Rar)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp
new file mode 100644
index 000000000..25194f915
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp
@@ -0,0 +1,78 @@
+// RarVolumeInStream.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/7zCrc.h"
+
+#include "RarVolumeInStream.h"
+
+namespace NArchive {
+namespace NRar {
+
+void CFolderInStream::Init(
+ CObjectVector<CInArchive> *archives,
+ const CObjectVector<CItemEx> *items,
+ const CRefItem &refItem)
+{
+ _archives = archives;
+ _items = items;
+ _refItem = refItem;
+ _curIndex = 0;
+ CRCs.Clear();
+ _fileIsOpen = false;
+}
+
+HRESULT CFolderInStream::OpenStream()
+{
+ while (_curIndex < _refItem.NumItems)
+ {
+ const CItemEx &item = (*_items)[_refItem.ItemIndex + _curIndex];
+ _stream.Attach((*_archives)[_refItem.VolumeIndex + _curIndex].
+ CreateLimitedStream(item.GetDataPosition(), item.PackSize));
+ _curIndex++;
+ _fileIsOpen = true;
+ _crc = CRC_INIT_VAL;
+ return S_OK;
+ }
+ return S_OK;
+}
+
+HRESULT CFolderInStream::CloseStream()
+{
+ CRCs.Add(CRC_GET_DIGEST(_crc));
+ _stream.Release();
+ _fileIsOpen = false;
+ return S_OK;
+}
+
+STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize = 0;
+ while ((_curIndex < _refItem.NumItems || _fileIsOpen) && size > 0)
+ {
+ if (_fileIsOpen)
+ {
+ UInt32 localProcessedSize;
+ RINOK(_stream->Read(
+ ((Byte *)data) + realProcessedSize, size, &localProcessedSize));
+ _crc = CrcUpdate(_crc, ((Byte *)data) + realProcessedSize, localProcessedSize);
+ if (localProcessedSize == 0)
+ {
+ RINOK(CloseStream());
+ continue;
+ }
+ realProcessedSize += localProcessedSize;
+ size -= localProcessedSize;
+ break;
+ }
+ else
+ {
+ RINOK(OpenStream());
+ }
+ }
+ if (processedSize != 0)
+ *processedSize = realProcessedSize;
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarVolumeInStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarVolumeInStream.h
new file mode 100644
index 000000000..78d95b10f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Rar/RarVolumeInStream.h
@@ -0,0 +1,49 @@
+// RarVolumeInStream.h
+
+#ifndef __RAR_VOLUME_IN_STREAM_H
+#define __RAR_VOLUME_IN_STREAM_H
+
+#include "../../IStream.h"
+#include "RarIn.h"
+
+namespace NArchive {
+namespace NRar {
+
+struct CRefItem
+{
+ int VolumeIndex;
+ int ItemIndex;
+ int NumItems;
+};
+
+class CFolderInStream:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+
+private:
+ CObjectVector<CInArchive> *_archives;
+ const CObjectVector<CItemEx> *_items;
+ CRefItem _refItem;
+ int _curIndex;
+ UInt32 _crc;
+ bool _fileIsOpen;
+ CMyComPtr<ISequentialInStream> _stream;
+
+ HRESULT OpenStream();
+ HRESULT CloseStream();
+public:
+ void Init(CObjectVector<CInArchive> *archives,
+ const CObjectVector<CItemEx> *items,
+ const CRefItem &refItem);
+
+ CRecordVector<UInt32> CRCs;
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/RpmHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/RpmHandler.cpp
new file mode 100644
index 000000000..13b67390c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/RpmHandler.cpp
@@ -0,0 +1,297 @@
+// RpmHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+#include "Common/MyString.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+using namespace NWindows;
+
+#define Get16(p) GetBe16(p)
+#define Get32(p) GetBe32(p)
+
+namespace NArchive {
+namespace NRpm {
+
+/* Reference: lib/signature.h of rpm package */
+#define RPMSIG_NONE 0 /* Do not change! */
+/* The following types are no longer generated */
+#define RPMSIG_PGP262_1024 1 /* No longer generated */ /* 256 byte */
+/* These are the new-style signatures. They are Header structures. */
+/* Inside them we can put any number of any type of signature we like. */
+
+#define RPMSIG_HEADERSIG 5 /* New Header style signature */
+
+const UInt32 kLeadSize = 96;
+struct CLead
+{
+ unsigned char Magic[4];
+ unsigned char Major; // not supported ver1, only support 2,3 and lator
+ unsigned char Minor;
+ UInt16 Type;
+ UInt16 ArchNum;
+ char Name[66];
+ UInt16 OSNum;
+ UInt16 SignatureType;
+ char Reserved[16]; // pad to 96 bytes -- 8 byte aligned
+ bool MagicCheck() const
+ { return Magic[0] == 0xed && Magic[1] == 0xab && Magic[2] == 0xee && Magic[3] == 0xdb; };
+};
+
+const UInt32 kEntryInfoSize = 16;
+/*
+struct CEntryInfo
+{
+ int Tag;
+ int Type;
+ int Offset; // Offset from beginning of data segment, only defined on disk
+ int Count;
+};
+*/
+
+// case: SignatureType == RPMSIG_HEADERSIG
+const UInt32 kCSigHeaderSigSize = 16;
+struct CSigHeaderSig
+{
+ unsigned char Magic[4];
+ UInt32 Reserved;
+ UInt32 IndexLen; // count of index entries
+ UInt32 DataLen; // number of bytes
+ bool MagicCheck()
+ { return Magic[0] == 0x8e && Magic[1] == 0xad && Magic[2] == 0xe8 && Magic[3] == 0x01; };
+ UInt32 GetLostHeaderLen()
+ { return IndexLen * kEntryInfoSize + DataLen; };
+};
+
+static HRESULT RedSigHeaderSig(IInStream *inStream, CSigHeaderSig &h)
+{
+ char dat[kCSigHeaderSigSize];
+ char *cur = dat;
+ RINOK(ReadStream_FALSE(inStream, dat, kCSigHeaderSigSize));
+ memmove(h.Magic, cur, 4);
+ cur += 4;
+ cur += 4;
+ h.IndexLen = Get32(cur);
+ cur += 4;
+ h.DataLen = Get32(cur);
+ return S_OK;
+}
+
+HRESULT OpenArchive(IInStream *inStream)
+{
+ UInt64 pos;
+ char leadData[kLeadSize];
+ char *cur = leadData;
+ CLead lead;
+ RINOK(ReadStream_FALSE(inStream, leadData, kLeadSize));
+ memmove(lead.Magic, cur, 4);
+ cur += 4;
+ lead.Major = *cur++;
+ lead.Minor = *cur++;
+ lead.Type = Get16(cur);
+ cur += 2;
+ lead.ArchNum = Get16(cur);
+ cur += 2;
+ memmove(lead.Name, cur, sizeof(lead.Name));
+ cur += sizeof(lead.Name);
+ lead.OSNum = Get16(cur);
+ cur += 2;
+ lead.SignatureType = Get16(cur);
+ cur += 2;
+
+ if (!lead.MagicCheck() || lead.Major < 3)
+ return S_FALSE;
+
+ CSigHeaderSig sigHeader, header;
+ if (lead.SignatureType == RPMSIG_NONE)
+ {
+ ;
+ }
+ else if (lead.SignatureType == RPMSIG_PGP262_1024)
+ {
+ UInt64 pos;
+ RINOK(inStream->Seek(256, STREAM_SEEK_CUR, &pos));
+ }
+ else if (lead.SignatureType == RPMSIG_HEADERSIG)
+ {
+ RINOK(RedSigHeaderSig(inStream, sigHeader));
+ if (!sigHeader.MagicCheck())
+ return S_FALSE;
+ UInt32 len = sigHeader.GetLostHeaderLen();
+ RINOK(inStream->Seek(len, STREAM_SEEK_CUR, &pos));
+ if ((pos % 8) != 0)
+ {
+ RINOK(inStream->Seek((pos / 8 + 1) * 8 - pos,
+ STREAM_SEEK_CUR, &pos));
+ }
+ }
+ else
+ return S_FALSE;
+
+ RINOK(RedSigHeaderSig(inStream, header));
+ if (!header.MagicCheck())
+ return S_FALSE;
+ int headerLen = header.GetLostHeaderLen();
+ if (headerLen == -1)
+ return S_FALSE;
+ RINOK(inStream->Seek(headerLen, STREAM_SEEK_CUR, &pos));
+ return S_OK;
+}
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _stream;
+ UInt64 _pos;
+ UInt64 _size;
+ Byte _sig[4];
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidSize, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO_Table
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID) { case kpidMainSubfile: prop = (UInt32)0; break; }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ try
+ {
+ Close();
+ if (OpenArchive(inStream) != S_OK)
+ return S_FALSE;
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &_pos));
+ RINOK(ReadStream_FALSE(inStream, _sig, sizeof(_sig) / sizeof(_sig[0])));
+ UInt64 endPosition;
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPosition));
+ _size = endPosition - _pos;
+ _stream = inStream;
+ return S_OK;
+ }
+ catch(...) { return S_FALSE; }
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _stream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidSize:
+ case kpidPackSize:
+ prop = _size;
+ break;
+ case kpidExtension:
+ {
+ char s[32];
+ MyStringCopy(s, "cpio.");
+ const char *ext;
+ if (_sig[0] == 0x1F && _sig[1] == 0x8B)
+ ext = "gz";
+ else if (_sig[0] == 'B' && _sig[1] == 'Z' && _sig[2] == 'h')
+ ext = "bz2";
+ else
+ ext = "lzma";
+ MyStringCopy(s + MyStringLen(s), ext);
+ prop = s;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ if (numItems == UInt32(-1))
+ numItems = 1;
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1 || indices[0] != 0)
+ return E_INVALIDARG;
+
+ bool testMode = (_aTestMode != 0);
+
+ RINOK(extractCallback->SetTotal(_size));
+ CMyComPtr<ISequentialOutStream> outStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ RINOK(extractCallback->GetStream(0, &outStream, askMode));
+ if (!testMode && !outStream)
+ return S_OK;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+
+ CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ RINOK(_stream->Seek(_pos, STREAM_SEEK_SET, NULL));
+ RINOK(copyCoder->Code(_stream, outStream, NULL, NULL, progress));
+ outStream.Release();
+ return extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK);
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 /* index */, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ return CreateLimitedInStream(_stream, _pos, _size, stream);
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new NArchive::NRpm::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Rpm", L"rpm", 0, 0xEB, { 0xED, 0xAB, 0xEE, 0xDB}, 4, false, CreateArc, 0 };
+
+REGISTER_ARC(Rpm)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/SplitHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/SplitHandler.cpp
new file mode 100644
index 000000000..892e12afa
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/SplitHandler.cpp
@@ -0,0 +1,370 @@
+// SplitHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/MyString.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+
+#include "../Compress/CopyCoder.h"
+
+#include "Common/MultiStream.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NSplit {
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidNumVolumes, VT_UI4}
+};
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ UString _subName;
+ CObjectVector<CMyComPtr<IInStream> > _streams;
+ CRecordVector<UInt64> _sizes;
+ UInt64 _totalSize;
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMainSubfile: prop = (UInt32)0; break;
+ case kpidNumVolumes: prop = (UInt32)_streams.Size(); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+struct CSeqName
+{
+ UString _unchangedPart;
+ UString _changedPart;
+ bool _splitStyle;
+
+ UString GetNextName()
+ {
+ UString newName;
+ if (_splitStyle)
+ {
+ int i;
+ int numLetters = _changedPart.Length();
+ for (i = numLetters - 1; i >= 0; i--)
+ {
+ wchar_t c = _changedPart[i];
+ if (c == 'z')
+ {
+ c = 'a';
+ newName = c + newName;
+ continue;
+ }
+ else if (c == 'Z')
+ {
+ c = 'A';
+ newName = c + newName;
+ continue;
+ }
+ c++;
+ if ((c == 'z' || c == 'Z') && i == 0)
+ {
+ _unchangedPart += c;
+ wchar_t newChar = (c == 'z') ? L'a' : L'A';
+ newName.Empty();
+ numLetters++;
+ for (int k = 0; k < numLetters; k++)
+ newName += newChar;
+ break;
+ }
+ newName = c + newName;
+ i--;
+ for (; i >= 0; i--)
+ newName = _changedPart[i] + newName;
+ break;
+ }
+ }
+ else
+ {
+ int i;
+ int numLetters = _changedPart.Length();
+ for (i = numLetters - 1; i >= 0; i--)
+ {
+ wchar_t c = _changedPart[i];
+ if (c == L'9')
+ {
+ c = L'0';
+ newName = c + newName;
+ if (i == 0)
+ newName = UString(L'1') + newName;
+ continue;
+ }
+ c++;
+ newName = c + newName;
+ i--;
+ for (; i >= 0; i--)
+ newName = _changedPart[i] + newName;
+ break;
+ }
+ }
+ _changedPart = newName;
+ return _unchangedPart + _changedPart;
+ }
+};
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ Close();
+ if (openArchiveCallback == 0)
+ return S_FALSE;
+ // try
+ {
+ CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
+ CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = openArchiveCallback;
+ if (openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback,
+ &openVolumeCallback) != S_OK)
+ return S_FALSE;
+
+ UString name;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
+ if (prop.vt != VT_BSTR)
+ return S_FALSE;
+ name = prop.bstrVal;
+ }
+
+ int dotPos = name.ReverseFind('.');
+ UString prefix, ext;
+ if (dotPos >= 0)
+ {
+ prefix = name.Left(dotPos + 1);
+ ext = name.Mid(dotPos + 1);
+ }
+ else
+ ext = name;
+ UString extBig = ext;
+ extBig.MakeUpper();
+
+ CSeqName seqName;
+
+ int numLetters = 2;
+ bool splitStyle = false;
+ if (extBig.Right(2) == L"AA")
+ {
+ splitStyle = true;
+ while (numLetters < extBig.Length())
+ {
+ if (extBig[extBig.Length() - numLetters - 1] != 'A')
+ break;
+ numLetters++;
+ }
+ }
+ else if (ext.Right(2) == L"01")
+ {
+ while (numLetters < extBig.Length())
+ {
+ if (extBig[extBig.Length() - numLetters - 1] != '0')
+ break;
+ numLetters++;
+ }
+ if (numLetters != ext.Length())
+ return S_FALSE;
+ }
+ else
+ return S_FALSE;
+
+ _streams.Add(stream);
+
+ seqName._unchangedPart = prefix + ext.Left(extBig.Length() - numLetters);
+ seqName._changedPart = ext.Right(numLetters);
+ seqName._splitStyle = splitStyle;
+
+ if (prefix.Length() < 1)
+ _subName = L"file";
+ else
+ _subName = prefix.Left(prefix.Length() - 1);
+
+ _totalSize = 0;
+ UInt64 size;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(openVolumeCallback->GetProperty(kpidSize, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ size = prop.uhVal.QuadPart;
+ }
+ _totalSize += size;
+ _sizes.Add(size);
+
+ if (openArchiveCallback != NULL)
+ {
+ UInt64 numFiles = _streams.Size();
+ RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ }
+
+ for (;;)
+ {
+ UString fullName = seqName.GetNextName();
+ CMyComPtr<IInStream> nextStream;
+ HRESULT result = openVolumeCallback->GetStream(fullName, &nextStream);
+ if (result == S_FALSE)
+ break;
+ if (result != S_OK)
+ return result;
+ if (!stream)
+ break;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(openVolumeCallback->GetProperty(kpidSize, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ size = prop.uhVal.QuadPart;
+ }
+ _totalSize += size;
+ _sizes.Add(size);
+ _streams.Add(nextStream);
+ if (openArchiveCallback != NULL)
+ {
+ UInt64 numFiles = _streams.Size();
+ RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ }
+ }
+ }
+ /*
+ catch(...)
+ {
+ return S_FALSE;
+ }
+ */
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _sizes.Clear();
+ _streams.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _streams.IsEmpty() ? 0 : 1;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPath: prop = _subName; break;
+ case kpidSize:
+ case kpidPackSize:
+ prop = _totalSize;
+ break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ if (numItems == UInt32(-1))
+ numItems = 1;
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1 || indices[0] != 0)
+ return E_INVALIDARG;
+
+ bool testMode = (_aTestMode != 0);
+ UInt64 currentTotalSize = 0;
+ RINOK(extractCallback->SetTotal(_totalSize));
+ CMyComPtr<ISequentialOutStream> outStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ RINOK(extractCallback->GetStream(0, &outStream, askMode));
+ if (!testMode && !outStream)
+ return S_OK;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ for (int i = 0; i < _streams.Size(); i++)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ IInStream *inStream = _streams[i];
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ currentTotalSize += copyCoderSpec->TotalSize;
+ }
+ outStream.Release();
+ return extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK);
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ if (index != 0)
+ return E_INVALIDARG;
+ *stream = 0;
+ CMultiStream *streamSpec = new CMultiStream;
+ CMyComPtr<ISequentialInStream> streamTemp = streamSpec;
+ for (int i = 0; i < _streams.Size(); i++)
+ {
+ CMultiStream::CSubStreamInfo subStreamInfo;
+ subStreamInfo.Stream = _streams[i];
+ subStreamInfo.Pos = 0;
+ subStreamInfo.Size = _sizes[i];
+ streamSpec->Streams.Add(subStreamInfo);
+ }
+ streamSpec->Init();
+ *stream = streamTemp.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+{ L"Split", L"001", 0, 0xEA, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Split)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandler.cpp
new file mode 100644
index 000000000..aa4b2aeca
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandler.cpp
@@ -0,0 +1,338 @@
+// TarHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/Defs.h"
+#include "Common/NewHandler.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../Common/ItemNameUtils.h"
+
+#include "TarHandler.h"
+#include "TarIn.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NTar {
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidPosixAttrib, VT_UI4},
+ { NULL, kpidUser, VT_BSTR},
+ { NULL, kpidGroup, VT_BSTR},
+ { NULL, kpidLink, VT_BSTR}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO_Table
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPhySize: if (_phySizeDefined) prop = _phySize; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
+{
+ UInt64 endPos = 0;
+ {
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
+ }
+
+ _isGood = true;
+ UInt64 pos = 0;
+ for (;;)
+ {
+ CItemEx item;
+ bool filled;
+ item.HeaderPosition = pos;
+ RINOK(ReadItem(stream, filled, item));
+ if (!filled)
+ break;
+ _items.Add(item);
+
+ RINOK(stream->Seek(item.GetPackSize(), STREAM_SEEK_CUR, &pos));
+ if (pos > endPos)
+ return S_FALSE;
+ if (pos == endPos)
+ {
+ _isGood = false;
+ break;
+ }
+ if (callback != NULL)
+ {
+ if (_items.Size() == 1)
+ {
+ RINOK(callback->SetTotal(NULL, &endPos));
+ }
+ if (_items.Size() % 100 == 0)
+ {
+ UInt64 numFiles = _items.Size();
+ RINOK(callback->SetCompleted(&numFiles, &pos));
+ }
+ }
+ }
+
+ if (_items.Size() == 0)
+ {
+ CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
+ if (!callback)
+ return S_FALSE;
+ callback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
+ if (!openVolumeCallback)
+ return S_FALSE;
+ NCOM::CPropVariant prop;
+ if (openVolumeCallback->GetProperty(kpidName, &prop) != S_OK)
+ return S_FALSE;
+ if (prop.vt != VT_BSTR)
+ return S_FALSE;
+ UString baseName = prop.bstrVal;
+ baseName = baseName.Right(4);
+ if (baseName.CompareNoCase(L".tar") != 0)
+ return S_FALSE;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ {
+ Close();
+ RINOK(Open2(stream, openArchiveCallback));
+ _stream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
+{
+ Close();
+ _seqStream = stream;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _phySizeDefined = false;
+ _curIndex = 0;
+ _latestIsRead = false;
+ _items.Clear();
+ _seqStream.Release();
+ _stream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = (_stream ? _items.Size() : (UInt32)(Int32)-1);
+ return S_OK;
+}
+
+CHandler::CHandler()
+{
+ copyCoderSpec = new NCompress::CCopyCoder();
+ copyCoder = copyCoderSpec;
+}
+
+HRESULT CHandler::SkipTo(UInt32 index)
+{
+ while (_curIndex < index || !_latestIsRead)
+ {
+ if (_latestIsRead)
+ {
+ UInt64 packSize = _latestItem.GetPackSize();
+ RINOK(copyCoderSpec->Code(_seqStream, NULL, &packSize, &packSize, NULL));
+ _latestIsRead = false;
+ _curIndex++;
+ }
+ else
+ {
+ bool filled;
+ // item.HeaderPosition = pos;
+ RINOK(ReadItem(_seqStream, filled, _latestItem));
+ if (!filled)
+ return E_INVALIDARG;
+ _latestIsRead = true;
+ }
+ }
+ return S_OK;
+}
+
+static UString TarStringToUnicode(const AString &s)
+{
+ return MultiByteToUnicodeString(s, CP_OEMCP);
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+
+ const CItemEx *item;
+ if (_stream)
+ item = &_items[index];
+ else
+ {
+ if (index < _curIndex)
+ return E_INVALIDARG;
+ else
+ {
+ RINOK(SkipTo(index));
+ item = &_latestItem;
+ }
+ }
+
+ switch(propID)
+ {
+ case kpidPath: prop = NItemName::GetOSName2(TarStringToUnicode(item->Name)); break;
+ case kpidIsDir: prop = item->IsDir(); break;
+ case kpidSize: prop = item->Size; break;
+ case kpidPackSize: prop = item->GetPackSize(); break;
+ case kpidMTime:
+ if (item->MTime != 0)
+ {
+ FILETIME ft;
+ NTime::UnixTimeToFileTime(item->MTime, ft);
+ prop = ft;
+ }
+ break;
+ case kpidPosixAttrib: prop = item->Mode; break;
+ case kpidUser: prop = TarStringToUnicode(item->User); break;
+ case kpidGroup: prop = TarStringToUnicode(item->Group); break;
+ case kpidLink: prop = TarStringToUnicode(item->LinkName); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ ISequentialInStream *stream = _seqStream;
+ bool seqMode = (_stream == NULL);
+ if (!seqMode)
+ stream = _stream;
+
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == (UInt32)-1);
+ if (allFilesMode)
+ numItems = _items.Size();
+ if (_stream && numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _items[allFilesMode ? i : indices[i]].Size;
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 totalPackSize;
+ totalSize = totalPackSize = 0;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(stream);
+
+ CLimitedSequentialOutStream *outStreamSpec = new CLimitedSequentialOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems || seqMode; i++)
+ {
+ lps->InSize = totalPackSize;
+ lps->OutSize = totalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItemEx *item;
+ if (seqMode)
+ {
+ HRESULT res = SkipTo(index);
+ if (res == E_INVALIDARG)
+ break;
+ RINOK(res);
+ item = &_latestItem;
+ }
+ else
+ item = &_items[index];
+
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ totalSize += item->Size;
+ totalPackSize += item->GetPackSize();
+ if (item->IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ bool skipMode = false;
+ if (!testMode && !realOutStream)
+ {
+ if (!seqMode)
+ continue;
+ skipMode = true;
+ askMode = NArchive::NExtract::NAskMode::kSkip;
+ }
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ outStreamSpec->SetStream(realOutStream);
+ realOutStream.Release();
+ outStreamSpec->Init(skipMode ? 0 : item->Size, true);
+
+ if (!seqMode)
+ {
+ RINOK(_stream->Seek(item->GetDataPosition(), STREAM_SEEK_SET, NULL));
+ }
+ streamSpec->Init(item->GetPackSize());
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ if (seqMode)
+ {
+ _latestIsRead = false;
+ _curIndex++;
+ }
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(outStreamSpec->GetRem() == 0 ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ const CItemEx &item = _items[index];
+ return CreateLimitedInStream(_stream, item.GetDataPosition(), item.Size, stream);
+ COM_TRY_END
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandler.h
new file mode 100644
index 000000000..d2def9a1c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandler.h
@@ -0,0 +1,59 @@
+// TarHandler.h
+
+#ifndef __TAR_HANDLER_H
+#define __TAR_HANDLER_H
+
+#include "Common/MyCom.h"
+#include "../IArchive.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "TarItem.h"
+
+namespace NArchive {
+namespace NTar {
+
+class CHandler:
+ public IInArchive,
+ public IArchiveOpenSeq,
+ public IInArchiveGetStream,
+ public IOutArchive,
+ public CMyUnknownImp
+{
+ CObjectVector<CItemEx> _items;
+ CMyComPtr<IInStream> _stream;
+ CMyComPtr<ISequentialInStream> _seqStream;
+ bool _isGood;
+
+ UInt32 _curIndex;
+ bool _latestIsRead;
+ CItemEx _latestItem;
+
+ UInt64 _phySize;
+ bool _phySizeDefined;
+
+ NCompress::CCopyCoder *copyCoderSpec;
+ CMyComPtr<ICompressCoder> copyCoder;
+
+ HRESULT Open2(IInStream *stream, IArchiveOpenCallback *callback);
+ HRESULT SkipTo(UInt32 index);
+
+public:
+ MY_UNKNOWN_IMP4(
+ IInArchive,
+ IArchiveOpenSeq,
+ IInArchiveGetStream,
+ IOutArchive
+ )
+
+ INTERFACE_IInArchive(;)
+ INTERFACE_IOutArchive(;)
+ STDMETHOD(OpenSeq)(ISequentialInStream *stream);
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+
+ CHandler();
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandlerOut.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
new file mode 100644
index 000000000..4c0cb5f83
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
@@ -0,0 +1,117 @@
+// TarHandlerOut.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "TarHandler.h"
+#include "TarUpdate.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NTar {
+
+STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
+{
+ *type = NFileTimeType::kUnix;
+ return S_OK;
+}
+
+static HRESULT GetPropString(IArchiveUpdateCallback *callback, UInt32 index, PROPID propId, AString &res)
+{
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(index, propId, &prop));
+ if (prop.vt == VT_BSTR)
+ res = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
+ else if (prop.vt != VT_EMPTY)
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
+ IArchiveUpdateCallback *callback)
+{
+ COM_TRY_BEGIN
+ if ((_stream && !_isGood) || _seqStream)
+ return E_NOTIMPL;
+ CObjectVector<CUpdateItem> updateItems;
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ CUpdateItem ui;
+ Int32 newData;
+ Int32 newProps;
+ UInt32 indexInArchive;
+ if (!callback)
+ return E_FAIL;
+ RINOK(callback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArchive));
+ ui.NewProps = IntToBool(newProps);
+ ui.NewData = IntToBool(newData);
+ ui.IndexInArchive = indexInArchive;
+ ui.IndexInClient = i;
+
+ if (IntToBool(newProps))
+ {
+ {
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidIsDir, &prop));
+ if (prop.vt == VT_EMPTY)
+ ui.IsDir = false;
+ else if (prop.vt != VT_BOOL)
+ return E_INVALIDARG;
+ else
+ ui.IsDir = (prop.boolVal != VARIANT_FALSE);
+ }
+
+ {
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidPosixAttrib, &prop));
+ if (prop.vt == VT_EMPTY)
+ ui.Mode = 0777 | (ui.IsDir ? 0040000 : 0100000);
+ else if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ else
+ ui.Mode = prop.ulVal;
+ }
+ {
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidMTime, &prop));
+ if (prop.vt == VT_EMPTY)
+ ui.Time = 0;
+ else if (prop.vt != VT_FILETIME)
+ return E_INVALIDARG;
+ else if (!NTime::FileTimeToUnixTime(prop.filetime, ui.Time))
+ ui.Time = 0;
+ }
+ {
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidPath, &prop));
+ if (prop.vt == VT_BSTR)
+ ui.Name = UnicodeStringToMultiByte(NItemName::MakeLegalName(prop.bstrVal), CP_OEMCP);
+ else if (prop.vt != VT_EMPTY)
+ return E_INVALIDARG;
+ if (ui.IsDir)
+ ui.Name += '/';
+ }
+ RINOK(GetPropString(callback, i, kpidUser, ui.User));
+ RINOK(GetPropString(callback, i, kpidGroup, ui.Group));
+ }
+ if (IntToBool(newData))
+ {
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidSize, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ ui.Size = prop.uhVal.QuadPart;
+ }
+ updateItems.Add(ui);
+ }
+ return UpdateArchive(_stream, outStream, _items, updateItems, callback);
+ COM_TRY_END
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHeader.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHeader.cpp
new file mode 100644
index 000000000..3275b284c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHeader.cpp
@@ -0,0 +1,25 @@
+// Archive/Tar/Header.h
+
+#include "StdAfx.h"
+
+#include "TarHeader.h"
+
+namespace NArchive {
+namespace NTar {
+namespace NFileHeader {
+
+ // The checksum field is filled with this while the checksum is computed.
+ const char *kCheckSumBlanks = " "; // 8 blanks, no null
+
+ const char *kLongLink = "././@LongLink";
+ const char *kLongLink2 = "@LongLink";
+
+ // The magic field is filled with this if uname and gname are valid.
+ namespace NMagic
+ {
+ const char *kUsTar = "ustar"; // 5 chars
+ const char *kGNUTar = "GNUtar "; // 7 chars and a null
+ const char *kEmpty = "\0\0\0\0\0\0\0\0"; // 7 chars and a null
+ }
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHeader.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHeader.h
new file mode 100644
index 000000000..0b78bdc26
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarHeader.h
@@ -0,0 +1,108 @@
+// Archive/Tar/Header.h
+
+#ifndef __ARCHIVE_TAR_HEADER_H
+#define __ARCHIVE_TAR_HEADER_H
+
+#include "Common/Types.h"
+
+namespace NArchive {
+namespace NTar {
+
+namespace NFileHeader
+{
+ const int kRecordSize = 512;
+ const int kNameSize = 100;
+ const int kUserNameSize = 32;
+ const int kGroupNameSize = 32;
+ const int kPrefixSize = 155;
+
+ /*
+ struct CHeader
+ {
+ char Name[kNameSize];
+ char Mode[8];
+ char UID[8];
+ char GID[8];
+ char Size[12];
+ char ModificationTime[12];
+ char CheckSum[8];
+ char LinkFlag;
+ char LinkName[kNameSize];
+ char Magic[8];
+ char UserName[kUserNameSize];
+ char GroupName[kGroupNameSize];
+ char DeviceMajor[8];
+ char DeviceMinor[8];
+ char Prefix[155];
+ };
+ union CRecord
+ {
+ CHeader Header;
+ Byte Padding[kRecordSize];
+ };
+ */
+
+ namespace NMode
+ {
+ const int kSetUID = 04000; // Set UID on execution
+ const int kSetGID = 02000; // Set GID on execution
+ const int kSaveText = 01000; // Save text (sticky bit)
+ }
+
+ namespace NFilePermissions
+ {
+ const int kUserRead = 00400; // read by owner
+ const int kUserWrite = 00200; // write by owner
+ const int kUserExecute = 00100; // execute/search by owner
+ const int kGroupRead = 00040; // read by group
+ const int kGroupWrite = 00020; // write by group
+ const int kGroupExecute = 00010; // execute/search by group
+ const int kOtherRead = 00004; // read by other
+ const int kOtherWrite = 00002; // write by other
+ const int kOtherExecute = 00001; // execute/search by other
+ }
+
+
+ // The linkflag defines the type of file
+ namespace NLinkFlag
+ {
+ const char kOldNormal = '\0'; // Normal disk file, Unix compatible
+ const char kNormal = '0'; // Normal disk file
+ const char kLink = '1'; // Link to previously dumped file
+ const char kSymbolicLink = '2'; // Symbolic link
+ const char kCharacter = '3'; // Character special file
+ const char kBlock = '4'; // Block special file
+ const char kDirectory = '5'; // Directory
+ const char kFIFO = '6'; // FIFO special file
+ const char kContiguous = '7'; // Contiguous file
+
+ const char kDumpDir = 'D'; /* GNUTYPE_DUMPDIR.
+ data: list of files created by the --incremental (-G) option
+ Each file name is preceded by either
+ - 'Y' (file should be in this archive)
+ - 'N' (file is a directory, or is not stored in the archive.)
+ Each file name is terminated by a null + an additional null after
+ the last file name. */
+
+ }
+ // Further link types may be defined later.
+
+ // The checksum field is filled with this while the checksum is computed.
+ extern const char *kCheckSumBlanks;// = " "; // 8 blanks, no null
+
+ extern const char *kLongLink; // = "././@LongLink";
+ extern const char *kLongLink2; // = "@LongLink";
+
+ // The magic field is filled with this if uname and gname are valid.
+ namespace NMagic
+ {
+ extern const char *kUsTar; // = "ustar"; // 5 chars
+ extern const char *kGNUTar; // = "GNUtar "; // 7 chars and a null
+ extern const char *kEmpty; // = "GNUtar "; // 7 chars and a null
+ }
+
+}
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarIn.cpp
new file mode 100644
index 000000000..376b3e7c8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarIn.cpp
@@ -0,0 +1,181 @@
+// TarIn.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringToInt.h"
+
+#include "../../Common/StreamUtils.h"
+
+#include "TarIn.h"
+
+namespace NArchive {
+namespace NTar {
+
+static void MyStrNCpy(char *dest, const char *src, int size)
+{
+ for (int i = 0; i < size; i++)
+ {
+ char c = src[i];
+ dest[i] = c;
+ if (c == 0)
+ break;
+ }
+}
+
+static bool OctalToNumber(const char *srcString, int size, UInt64 &res)
+{
+ char sz[32];
+ MyStrNCpy(sz, srcString, size);
+ sz[size] = 0;
+ const char *end;
+ int i;
+ for (i = 0; sz[i] == ' '; i++);
+ res = ConvertOctStringToUInt64(sz + i, &end);
+ return (*end == ' ' || *end == 0);
+}
+
+static bool OctalToNumber32(const char *srcString, int size, UInt32 &res)
+{
+ UInt64 res64;
+ if (!OctalToNumber(srcString, size, res64))
+ return false;
+ res = (UInt32)res64;
+ return (res64 <= 0xFFFFFFFF);
+}
+
+#define RIF(x) { if (!(x)) return S_FALSE; }
+
+static bool IsRecordLast(const char *buf)
+{
+ for (int i = 0; i < NFileHeader::kRecordSize; i++)
+ if (buf[i] != 0)
+ return false;
+ return true;
+}
+
+static void ReadString(const char *s, int size, AString &result)
+{
+ char temp[NFileHeader::kRecordSize + 1];
+ MyStrNCpy(temp, s, size);
+ temp[size] = '\0';
+ result = temp;
+}
+
+static HRESULT GetNextItemReal(ISequentialInStream *stream, bool &filled, CItemEx &item, size_t &processedSize)
+{
+ item.LongLinkSize = 0;
+ char buf[NFileHeader::kRecordSize];
+ char *p = buf;
+
+ filled = false;
+
+ processedSize = NFileHeader::kRecordSize;
+ RINOK(ReadStream(stream, buf, &processedSize));
+ if (processedSize == 0 || (static_cast< int >( processedSize ) == NFileHeader::kRecordSize && IsRecordLast(buf)))
+ return S_OK;
+ if (static_cast< int >( processedSize ) < NFileHeader::kRecordSize)
+ return S_FALSE;
+
+ ReadString(p, NFileHeader::kNameSize, item.Name); p += NFileHeader::kNameSize;
+
+ RIF(OctalToNumber32(p, 8, item.Mode)); p += 8;
+
+ if (!OctalToNumber32(p, 8, item.UID)) item.UID = 0; p += 8;
+ if (!OctalToNumber32(p, 8, item.GID)) item.GID = 0; p += 8;
+
+ RIF(OctalToNumber(p, 12, item.Size)); p += 12;
+ RIF(OctalToNumber32(p, 12, item.MTime)); p += 12;
+
+ UInt32 checkSum;
+ RIF(OctalToNumber32(p, 8, checkSum));
+ memcpy(p, NFileHeader::kCheckSumBlanks, 8); p += 8;
+
+ item.LinkFlag = *p++;
+
+ ReadString(p, NFileHeader::kNameSize, item.LinkName); p += NFileHeader::kNameSize;
+
+ memcpy(item.Magic, p, 8); p += 8;
+
+ ReadString(p, NFileHeader::kUserNameSize, item.User); p += NFileHeader::kUserNameSize;
+ ReadString(p, NFileHeader::kGroupNameSize, item.Group); p += NFileHeader::kGroupNameSize;
+
+ item.DeviceMajorDefined = (p[0] != 0); RIF(OctalToNumber32(p, 8, item.DeviceMajor)); p += 8;
+ item.DeviceMinorDefined = (p[0] != 0); RIF(OctalToNumber32(p, 8, item.DeviceMinor)); p += 8;
+
+ AString prefix;
+ ReadString(p, NFileHeader::kPrefixSize, prefix);
+ p += NFileHeader::kPrefixSize;
+ if (!prefix.IsEmpty() && item.IsMagic() &&
+ (item.LinkFlag != 'L' /* || prefix != "00000000000" */ ))
+ item.Name = prefix + AString('/') + item.Name;
+
+ if (item.LinkFlag == NFileHeader::NLinkFlag::kLink)
+ item.Size = 0;
+
+ UInt32 checkSumReal = 0;
+ for (int i = 0; i < NFileHeader::kRecordSize; i++)
+ checkSumReal += (Byte)buf[i];
+
+ if (checkSumReal != checkSum)
+ return S_FALSE;
+
+ filled = true;
+ return S_OK;
+}
+
+HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &item)
+{
+ size_t processedSize;
+ RINOK(GetNextItemReal(stream, filled, item, processedSize));
+ if (!filled)
+ return S_OK;
+ // GNUtar extension
+ if (item.LinkFlag == 'L' || // NEXT file has a long name
+ item.LinkFlag == 'K') // NEXT file has a long linkname
+ {
+ if (item.Name.Compare(NFileHeader::kLongLink) != 0)
+ if (item.Name.Compare(NFileHeader::kLongLink2) != 0)
+ return S_FALSE;
+
+ AString fullName;
+ if (item.Size > (1 << 15))
+ return S_FALSE;
+ int packSize = (int)item.GetPackSize();
+ char *buffer = fullName.GetBuffer(packSize + 1);
+
+ RINOK(ReadStream_FALSE(stream, buffer, packSize));
+ processedSize += packSize;
+ buffer[item.Size] = '\0';
+ fullName.ReleaseBuffer();
+
+ UInt64 headerPosition = item.HeaderPosition;
+ if (item.LinkFlag == 'L')
+ {
+ size_t processedSize2;
+ RINOK(GetNextItemReal(stream, filled, item, processedSize2));
+ item.LongLinkSize = (unsigned)processedSize;
+ }
+ else
+ {
+ item.LongLinkSize = (unsigned)processedSize - NFileHeader::kRecordSize;
+ item.Size = 0;
+ }
+ item.Name = fullName;
+ item.HeaderPosition = headerPosition;
+ }
+ else if (item.LinkFlag == 'g' || item.LinkFlag == 'x' || item.LinkFlag == 'X')
+ {
+ // pax Extended Header
+ return S_OK;
+ }
+ else if (item.LinkFlag == NFileHeader::NLinkFlag::kDumpDir)
+ {
+ // GNU Extensions to the Archive Format
+ return S_OK;
+ }
+ else if (item.LinkFlag > '7' || (item.LinkFlag < '0' && item.LinkFlag != 0))
+ return S_FALSE;
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarIn.h
new file mode 100644
index 000000000..cc6e3f5b5
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarIn.h
@@ -0,0 +1,18 @@
+// Archive/TarIn.h
+
+#ifndef __ARCHIVE_TAR_IN_H
+#define __ARCHIVE_TAR_IN_H
+
+#include "Common/MyCom.h"
+#include "../../IStream.h"
+
+#include "TarItem.h"
+
+namespace NArchive {
+namespace NTar {
+
+HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &itemInfo);
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarItem.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarItem.h
new file mode 100644
index 000000000..afe8997db
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarItem.h
@@ -0,0 +1,69 @@
+// TarItem.h
+
+#ifndef __ARCHIVE_TAR_ITEM_H
+#define __ARCHIVE_TAR_ITEM_H
+
+#include "../Common/ItemNameUtils.h"
+
+#include "TarHeader.h"
+
+namespace NArchive {
+namespace NTar {
+
+struct CItem
+{
+ AString Name;
+ UInt64 Size;
+
+ UInt32 Mode;
+ UInt32 UID;
+ UInt32 GID;
+ UInt32 MTime;
+ UInt32 DeviceMajor;
+ UInt32 DeviceMinor;
+
+ AString LinkName;
+ AString User;
+ AString Group;
+
+ char Magic[8];
+ char LinkFlag;
+ bool DeviceMajorDefined;
+ bool DeviceMinorDefined;
+
+ bool IsDir() const
+ {
+ switch(LinkFlag)
+ {
+ case NFileHeader::NLinkFlag::kDirectory:
+ case NFileHeader::NLinkFlag::kDumpDir:
+ return true;
+ case NFileHeader::NLinkFlag::kOldNormal:
+ case NFileHeader::NLinkFlag::kNormal:
+ return NItemName::HasTailSlash(Name, CP_OEMCP);
+ }
+ return false;
+ }
+
+ bool IsMagic() const
+ {
+ for (int i = 0; i < 5; i++)
+ if (Magic[i] != NFileHeader::NMagic::kUsTar[i])
+ return false;
+ return true;
+ }
+
+ UInt64 GetPackSize() const { return (Size + 0x1FF) & (~((UInt64)0x1FF)); }
+};
+
+struct CItemEx: public CItem
+{
+ UInt64 HeaderPosition;
+ unsigned LongLinkSize;
+ UInt64 GetDataPosition() const { return HeaderPosition + LongLinkSize + NFileHeader::kRecordSize; }
+ UInt64 GetFullSize() const { return LongLinkSize + NFileHeader::kRecordSize + Size; }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarOut.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarOut.cpp
new file mode 100644
index 000000000..1ec314c73
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarOut.cpp
@@ -0,0 +1,186 @@
+// TarOut.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+
+#include "../../Common/StreamUtils.h"
+
+#include "TarOut.h"
+
+namespace NArchive {
+namespace NTar {
+
+HRESULT COutArchive::WriteBytes(const void *buffer, UInt32 size)
+{
+ return WriteStream(m_Stream, buffer, size);
+}
+
+void COutArchive::Create(ISequentialOutStream *outStream)
+{
+ m_Stream = outStream;
+}
+
+static AString MakeOctalString(UInt64 value)
+{
+ char s[32];
+ ConvertUInt64ToString(value, s, 8);
+ return AString(s) + ' ';
+}
+
+static void MyStrNCpy(char *dest, const char *src, int size)
+{
+ for (int i = 0; i < size; i++)
+ {
+ char c = src[i];
+ dest[i] = c;
+ if (c == 0)
+ break;
+ }
+}
+
+static bool MakeOctalString8(char *s, UInt32 value)
+{
+ AString tempString = MakeOctalString(value);
+
+ const int kMaxSize = 8;
+ if (tempString.Length() >= kMaxSize)
+ return false;
+ int numSpaces = kMaxSize - (tempString.Length() + 1);
+ for(int i = 0; i < numSpaces; i++)
+ s[i] = ' ';
+ MyStringCopy(s + numSpaces, (const char *)tempString);
+ return true;
+}
+
+static bool MakeOctalString12(char *s, UInt64 value)
+{
+ AString tempString = MakeOctalString(value);
+ const int kMaxSize = 12;
+ if (tempString.Length() > kMaxSize)
+ return false;
+ int numSpaces = kMaxSize - tempString.Length();
+ for(int i = 0; i < numSpaces; i++)
+ s[i] = ' ';
+ memmove(s + numSpaces, (const char *)tempString, tempString.Length());
+ return true;
+}
+
+static bool CopyString(char *dest, const AString &src, int maxSize)
+{
+ if (src.Length() >= maxSize)
+ return false;
+ MyStringCopy(dest, (const char *)src);
+ return true;
+}
+
+#define RETURN_IF_NOT_TRUE(x) { if (!(x)) return E_FAIL; }
+
+HRESULT COutArchive::WriteHeaderReal(const CItem &item)
+{
+ char record[NFileHeader::kRecordSize];
+ char *cur = record;
+ int i;
+ for (i = 0; i < NFileHeader::kRecordSize; i++)
+ record[i] = 0;
+
+ // RETURN_IF_NOT_TRUE(CopyString(header.Name, item.Name, NFileHeader::kNameSize));
+ if (item.Name.Length() > NFileHeader::kNameSize)
+ return E_FAIL;
+ MyStrNCpy(cur, item.Name, NFileHeader::kNameSize);
+ cur += NFileHeader::kNameSize;
+
+ RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.Mode));
+ cur += 8;
+ RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.UID));
+ cur += 8;
+ RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.GID));
+ cur += 8;
+
+ RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.Size));
+ cur += 12;
+ RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.MTime));
+ cur += 12;
+
+ memmove(cur, NFileHeader::kCheckSumBlanks, 8);
+ cur += 8;
+
+ *cur++ = item.LinkFlag;
+
+ RETURN_IF_NOT_TRUE(CopyString(cur, item.LinkName, NFileHeader::kNameSize));
+ cur += NFileHeader::kNameSize;
+
+ memmove(cur, item.Magic, 8);
+ cur += 8;
+
+ RETURN_IF_NOT_TRUE(CopyString(cur, item.User, NFileHeader::kUserNameSize));
+ cur += NFileHeader::kUserNameSize;
+ RETURN_IF_NOT_TRUE(CopyString(cur, item.Group, NFileHeader::kGroupNameSize));
+ cur += NFileHeader::kGroupNameSize;
+
+
+ if (item.DeviceMajorDefined)
+ RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.DeviceMajor));
+ cur += 8;
+
+ if (item.DeviceMinorDefined)
+ RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.DeviceMinor));
+ cur += 8;
+
+
+ UInt32 checkSumReal = 0;
+ for(i = 0; i < NFileHeader::kRecordSize; i++)
+ checkSumReal += Byte(record[i]);
+
+ RETURN_IF_NOT_TRUE(MakeOctalString8(record + 148, checkSumReal));
+
+ return WriteBytes(record, NFileHeader::kRecordSize);
+}
+
+HRESULT COutArchive::WriteHeader(const CItem &item)
+{
+ int nameSize = item.Name.Length();
+ if (nameSize < NFileHeader::kNameSize)
+ return WriteHeaderReal(item);
+
+ CItem modifiedItem = item;
+ int nameStreamSize = nameSize + 1;
+ modifiedItem.Size = nameStreamSize;
+ modifiedItem.LinkFlag = 'L';
+ modifiedItem.Name = NFileHeader::kLongLink;
+ modifiedItem.LinkName.Empty();
+ RINOK(WriteHeaderReal(modifiedItem));
+ RINOK(WriteBytes(item.Name, nameStreamSize));
+ RINOK(FillDataResidual(nameStreamSize));
+
+ modifiedItem = item;
+ modifiedItem.Name = item.Name.Left(NFileHeader::kNameSize - 1);
+ return WriteHeaderReal(modifiedItem);
+}
+
+HRESULT COutArchive::FillDataResidual(UInt64 dataSize)
+{
+ UInt32 lastRecordSize = UInt32(dataSize & (NFileHeader::kRecordSize - 1));
+ if (lastRecordSize == 0)
+ return S_OK;
+ UInt32 residualSize = NFileHeader::kRecordSize - lastRecordSize;
+ Byte residualBytes[NFileHeader::kRecordSize];
+ for (UInt32 i = 0; i < residualSize; i++)
+ residualBytes[i] = 0;
+ return WriteBytes(residualBytes, residualSize);
+}
+
+HRESULT COutArchive::WriteFinishHeader()
+{
+ Byte record[NFileHeader::kRecordSize];
+ int i;
+ for (i = 0; i < NFileHeader::kRecordSize; i++)
+ record[i] = 0;
+ for (i = 0; i < 2; i++)
+ {
+ RINOK(WriteBytes(record, NFileHeader::kRecordSize));
+ }
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarOut.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarOut.h
new file mode 100644
index 000000000..ef837869b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarOut.h
@@ -0,0 +1,28 @@
+// Archive/TarOut.h
+
+#ifndef __ARCHIVE_TAR_OUT_H
+#define __ARCHIVE_TAR_OUT_H
+
+#include "TarItem.h"
+
+#include "Common/MyCom.h"
+#include "../../IStream.h"
+
+namespace NArchive {
+namespace NTar {
+
+class COutArchive
+{
+ CMyComPtr<ISequentialOutStream> m_Stream;
+ HRESULT WriteBytes(const void *buffer, UInt32 size);
+public:
+ void Create(ISequentialOutStream *outStream);
+ HRESULT WriteHeaderReal(const CItem &item);
+ HRESULT WriteHeader(const CItem &item);
+ HRESULT FillDataResidual(UInt64 dataSize);
+ HRESULT WriteFinishHeader();
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarRegister.cpp
new file mode 100644
index 000000000..3cc0d6052
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarRegister.cpp
@@ -0,0 +1,18 @@
+// TarRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "TarHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NTar::CHandler; }
+#ifndef EXTRACT_ONLY
+static IOutArchive *CreateArcOut() { return new NArchive::NTar::CHandler; }
+#else
+#define CreateArcOut 0
+#endif
+
+static CArcInfo g_ArcInfo =
+{ L"Tar", L"tar", 0, 0xEE, { 'u', 's', 't', 'a', 'r' }, 5, false, CreateArc, CreateArcOut };
+
+REGISTER_ARC(Tar)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarUpdate.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarUpdate.cpp
new file mode 100644
index 000000000..0577848f6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarUpdate.cpp
@@ -0,0 +1,139 @@
+// TarUpdate.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "TarOut.h"
+#include "TarUpdate.h"
+
+namespace NArchive {
+namespace NTar {
+
+HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
+ const CObjectVector<NArchive::NTar::CItemEx> &inputItems,
+ const CObjectVector<CUpdateItem> &updateItems,
+ IArchiveUpdateCallback *updateCallback)
+{
+ COutArchive outArchive;
+ outArchive.Create(outStream);
+
+ UInt64 complexity = 0;
+
+ int i;
+ for(i = 0; i < updateItems.Size(); i++)
+ {
+ const CUpdateItem &ui = updateItems[i];
+ if (ui.NewData)
+ complexity += ui.Size;
+ else
+ complexity += inputItems[ui.IndexInArchive].GetFullSize();
+ }
+
+ RINOK(updateCallback->SetTotal(complexity));
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(updateCallback, true);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
+ streamSpec->SetStream(inStream);
+
+ complexity = 0;
+
+ for(i = 0; i < updateItems.Size(); i++)
+ {
+ lps->InSize = lps->OutSize = complexity;
+ RINOK(lps->SetCur());
+
+ const CUpdateItem &ui = updateItems[i];
+ CItem item;
+ if (ui.NewProps)
+ {
+ item.Mode = ui.Mode;
+ item.Name = ui.Name;
+ item.User = ui.User;
+ item.Group = ui.Group;
+ if (ui.IsDir)
+ {
+ item.LinkFlag = NFileHeader::NLinkFlag::kDirectory;
+ item.Size = 0;
+ }
+ else
+ {
+ item.LinkFlag = NFileHeader::NLinkFlag::kNormal;
+ item.Size = ui.Size;
+ }
+ item.MTime = ui.Time;
+ item.DeviceMajorDefined = false;
+ item.DeviceMinorDefined = false;
+ item.UID = 0;
+ item.GID = 0;
+ memmove(item.Magic, NFileHeader::NMagic::kEmpty, 8);
+ }
+ else
+ item = inputItems[ui.IndexInArchive];
+
+ if (ui.NewData)
+ {
+ item.Size = ui.Size;
+ if (item.Size == (UInt64)(Int64)-1)
+ return E_INVALIDARG;
+ }
+ else
+ item.Size = inputItems[ui.IndexInArchive].Size;
+
+ if (ui.NewData)
+ {
+ CMyComPtr<ISequentialInStream> fileInStream;
+ HRESULT res = updateCallback->GetStream(ui.IndexInClient, &fileInStream);
+ if (res != S_FALSE)
+ {
+ RINOK(res);
+ RINOK(outArchive.WriteHeader(item));
+ if (!ui.IsDir)
+ {
+ RINOK(copyCoder->Code(fileInStream, outStream, NULL, NULL, progress));
+ if (copyCoderSpec->TotalSize != item.Size)
+ return E_FAIL;
+ RINOK(outArchive.FillDataResidual(item.Size));
+ }
+ }
+ complexity += ui.Size;
+ RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ }
+ else
+ {
+ const CItemEx &existItemInfo = inputItems[ui.IndexInArchive];
+ UInt64 size;
+ if (ui.NewProps)
+ {
+ RINOK(outArchive.WriteHeader(item));
+ RINOK(inStream->Seek(existItemInfo.GetDataPosition(), STREAM_SEEK_SET, NULL));
+ size = existItemInfo.Size;
+ }
+ else
+ {
+ RINOK(inStream->Seek(existItemInfo.HeaderPosition, STREAM_SEEK_SET, NULL));
+ size = existItemInfo.GetFullSize();
+ }
+ streamSpec->Init(size);
+
+ RINOK(copyCoder->Code(inStreamLimited, outStream, NULL, NULL, progress));
+ if (copyCoderSpec->TotalSize != size)
+ return E_FAIL;
+ RINOK(outArchive.FillDataResidual(existItemInfo.Size));
+ complexity += size;
+ }
+ }
+ return outArchive.WriteFinishHeader();
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarUpdate.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarUpdate.h
new file mode 100644
index 000000000..fb217d196
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Tar/TarUpdate.h
@@ -0,0 +1,34 @@
+// TarUpdate.h
+
+#ifndef __TAR_UPDATE_H
+#define __TAR_UPDATE_H
+
+#include "../IArchive.h"
+#include "TarItem.h"
+
+namespace NArchive {
+namespace NTar {
+
+struct CUpdateItem
+{
+ int IndexInArchive;
+ int IndexInClient;
+ UInt32 Time;
+ UInt32 Mode;
+ UInt64 Size;
+ AString Name;
+ AString User;
+ AString Group;
+ bool NewData;
+ bool NewProps;
+ bool IsDir;
+};
+
+HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
+ const CObjectVector<CItemEx> &inputItems,
+ const CObjectVector<CUpdateItem> &updateItems,
+ IArchiveUpdateCallback *updateCallback);
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfHandler.cpp
new file mode 100644
index 000000000..07b61c515
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfHandler.cpp
@@ -0,0 +1,500 @@
+// UdfHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/NewHandler.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "UdfHandler.h"
+
+namespace NArchive {
+namespace NUdf {
+
+void UdfTimeToFileTime(const CTime &t, NWindows::NCOM::CPropVariant &prop)
+{
+ UInt64 numSecs;
+ const Byte *d = t.Data;
+ if (!NWindows::NTime::GetSecondsSince1601(t.GetYear(), d[4], d[5], d[6], d[7], d[8], numSecs))
+ return;
+ if (t.IsLocal())
+ numSecs -= t.GetMinutesOffset() * 60;
+ FILETIME ft;
+ UInt64 v = (((numSecs * 100 + d[9]) * 100 + d[10]) * 100 + d[11]) * 10;
+ ft.dwLowDateTime = (UInt32)v;
+ ft.dwHighDateTime = (UInt32)(v >> 32);
+ prop = ft;
+}
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidComment, VT_BSTR},
+ { NULL, kpidClusterSize, VT_UI4},
+ { NULL, kpidCTime, VT_FILETIME}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidComment:
+ {
+ UString comment = _archive.GetComment();
+ if (!comment.IsEmpty())
+ prop = comment;
+ break;
+ }
+
+ case kpidClusterSize:
+ if (_archive.LogVols.Size() > 0)
+ {
+ UInt32 blockSize = _archive.LogVols[0].BlockSize;
+ int i;
+ for (i = 1; i < _archive.LogVols.Size(); i++)
+ if (_archive.LogVols[i].BlockSize != blockSize)
+ break;
+ if (i == _archive.LogVols.Size())
+ prop = blockSize;
+ }
+ break;
+
+ case kpidCTime:
+ if (_archive.LogVols.Size() == 1)
+ {
+ const CLogVol &vol = _archive.LogVols[0];
+ if (vol.FileSets.Size() >= 1)
+ UdfTimeToFileTime(vol.FileSets[0].RecodringTime, prop);
+ }
+ break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CProgressImp: public CProgressVirt
+{
+ CMyComPtr<IArchiveOpenCallback> _callback;
+ UInt64 _numFiles;
+ UInt64 _numBytes;
+public:
+ HRESULT SetTotal(UInt64 numBytes);
+ HRESULT SetCompleted(UInt64 numFiles, UInt64 numBytes);
+ HRESULT SetCompleted();
+ CProgressImp(IArchiveOpenCallback *callback): _callback(callback), _numFiles(0), _numBytes(0) {}
+};
+
+HRESULT CProgressImp::SetTotal(UInt64 numBytes)
+{
+ if (_callback)
+ return _callback->SetTotal(NULL, &numBytes);
+ return S_OK;
+}
+
+HRESULT CProgressImp::SetCompleted(UInt64 numFiles, UInt64 numBytes)
+{
+ _numFiles = numFiles;
+ _numBytes = numBytes;
+ return SetCompleted();
+}
+
+HRESULT CProgressImp::SetCompleted()
+{
+ if (_callback)
+ return _callback->SetCompleted(&_numFiles, &_numBytes);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ {
+ Close();
+ CProgressImp progressImp(callback);
+ RINOK(_archive.Open(stream, &progressImp));
+ bool showVolName = (_archive.LogVols.Size() > 1);
+ for (int volIndex = 0; volIndex < _archive.LogVols.Size(); volIndex++)
+ {
+ const CLogVol &vol = _archive.LogVols[volIndex];
+ bool showFileSetName = (vol.FileSets.Size() > 1);
+ for (int fsIndex = 0; fsIndex < vol.FileSets.Size(); fsIndex++)
+ {
+ const CFileSet &fs = vol.FileSets[fsIndex];
+ for (int i = ((showVolName || showFileSetName) ? 0 : 1); i < fs.Refs.Size(); i++)
+ {
+ CRef2 ref2;
+ ref2.Vol = volIndex;
+ ref2.Fs = fsIndex;
+ ref2.Ref = i;
+ _refs2.Add(ref2);
+ }
+ }
+ }
+ _inStream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _archive.Clear();
+ _refs2.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _refs2.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ {
+ const CRef2 &ref2 = _refs2[index];
+ const CLogVol &vol = _archive.LogVols[ref2.Vol];
+ const CRef &ref = vol.FileSets[ref2.Fs].Refs[ref2.Ref];
+ const CFile &file = _archive.Files[ref.FileIndex];
+ const CItem &item = _archive.Items[file.ItemIndex];
+ switch(propID)
+ {
+ case kpidPath: prop = _archive.GetItemPath(ref2.Vol, ref2.Fs, ref2.Ref,
+ _archive.LogVols.Size() > 1, vol.FileSets.Size() > 1); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: if (!item.IsDir()) prop = (UInt64)item.Size; break;
+ case kpidPackSize: if (!item.IsDir()) prop = (UInt64)item.NumLogBlockRecorded * vol.BlockSize; break;
+ case kpidMTime: UdfTimeToFileTime(item.MTime, prop); break;
+ case kpidATime: UdfTimeToFileTime(item.ATime, prop); break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CBufInStream:
+ public IInStream,
+ public CMyUnknownImp
+{
+ CByteBuffer _data;
+ UInt64 _pos;
+
+public:
+ void Init(const CByteBuffer &data)
+ {
+ _data = data;
+ _pos = 0;
+ }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+};
+
+
+STDMETHODIMP CBufInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ if (_pos > _data.GetCapacity())
+ return E_FAIL;
+ size_t rem = _data.GetCapacity() - (size_t)_pos;
+ if (size < rem)
+ rem = (size_t)size;
+ memcpy(data, (const Byte *)_data + _pos, rem);
+ _pos += rem;
+ if (processedSize != NULL)
+ *processedSize = (UInt32)rem;
+ return S_OK;
+}
+
+STDMETHODIMP CBufInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET: _pos = offset; break;
+ case STREAM_SEEK_CUR: _pos += offset; break;
+ case STREAM_SEEK_END: _pos = _data.GetCapacity() + offset; break;
+ default: return STG_E_INVALIDFUNCTION;
+ }
+ if (newPosition)
+ *newPosition = _pos;
+ return S_OK;
+}
+
+struct CSeekExtent
+{
+ UInt64 Phy;
+ UInt64 Virt;
+};
+
+class CExtentsStream:
+ public IInStream,
+ public CMyUnknownImp
+{
+ UInt64 _phyPos;
+ UInt64 _virtPos;
+ bool _needStartSeek;
+
+ HRESULT SeekToPhys() { return Stream->Seek(_phyPos, STREAM_SEEK_SET, NULL); }
+
+public:
+ CMyComPtr<IInStream> Stream;
+ CRecordVector<CSeekExtent> Extents;
+
+ MY_UNKNOWN_IMP1(IInStream)
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+ void ReleaseStream() { Stream.Release(); }
+
+ void Init()
+ {
+ _virtPos = 0;
+ _phyPos = 0;
+ _needStartSeek = true;
+ }
+
+};
+
+
+STDMETHODIMP CExtentsStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize)
+ *processedSize = 0;
+ if (size > 0)
+ {
+ UInt64 totalSize = Extents.Back().Virt;
+ if (_virtPos >= totalSize)
+ return (_virtPos == totalSize) ? S_OK : E_FAIL;
+ int left = 0, right = Extents.Size() - 1;
+ for (;;)
+ {
+ int mid = (left + right) / 2;
+ if (mid == left)
+ break;
+ if (_virtPos < Extents[mid].Virt)
+ right = mid;
+ else
+ left = mid;
+ }
+
+ const CSeekExtent &extent = Extents[left];
+ UInt64 phyPos = extent.Phy + (_virtPos - extent.Virt);
+ if (_needStartSeek || _phyPos != phyPos)
+ {
+ _needStartSeek = false;
+ _phyPos = phyPos;
+ RINOK(SeekToPhys());
+ }
+
+ UInt64 rem = Extents[left + 1].Virt - _virtPos;
+ if (size > rem)
+ size = (UInt32)rem;
+
+ HRESULT res = Stream->Read(data, size, &size);
+ _phyPos += size;
+ _virtPos += size;
+ if (processedSize)
+ *processedSize = size;
+ return res;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CExtentsStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET: _virtPos = offset; break;
+ case STREAM_SEEK_CUR: _virtPos += offset; break;
+ case STREAM_SEEK_END: _virtPos = Extents.Back().Virt + offset; break;
+ default: return STG_E_INVALIDFUNCTION;
+ }
+ if (newPosition)
+ *newPosition = _virtPos;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ *stream = 0;
+
+ const CRef2 &ref2 = _refs2[index];
+ const CLogVol &vol = _archive.LogVols[ref2.Vol];
+ const CRef &ref = vol.FileSets[ref2.Fs].Refs[ref2.Ref];
+ const CFile &file = _archive.Files[ref.FileIndex];
+ const CItem &item = _archive.Items[file.ItemIndex];
+ UInt64 size = item.Size;
+
+ if (!item.IsRecAndAlloc() || !item.CheckChunkSizes() || ! _archive.CheckItemExtents(ref2.Vol, item))
+ return E_NOTIMPL;
+
+ if (item.IsInline)
+ {
+ CBufInStream *inStreamSpec = new CBufInStream;
+ CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
+ inStreamSpec->Init(item.InlineData);
+ *stream = inStream .Detach();
+ return S_OK;
+ }
+
+ CExtentsStream *extentStreamSpec = new CExtentsStream();
+ CMyComPtr<ISequentialInStream> extentStream = extentStreamSpec;
+
+ extentStreamSpec->Stream = _inStream;
+
+ UInt64 virtOffset = 0;
+ for (int extentIndex = 0; extentIndex < item.Extents.Size(); extentIndex++)
+ {
+ const CMyExtent &extent = item.Extents[extentIndex];
+ UInt32 len = extent.GetLen();
+ if (len == 0)
+ continue;
+ if (size < len)
+ return S_FALSE;
+
+ int partitionIndex = vol.PartitionMaps[extent.PartitionRef].PartitionIndex;
+ UInt32 logBlockNumber = extent.Pos;
+ const CPartition &partition = _archive.Partitions[partitionIndex];
+ UInt64 offset = ((UInt64)partition.Pos << _archive.SecLogSize) +
+ (UInt64)logBlockNumber * vol.BlockSize;
+
+ CSeekExtent se;
+ se.Phy = offset;
+ se.Virt = virtOffset;
+ virtOffset += len;
+ extentStreamSpec->Extents.Add(se);
+
+ size -= len;
+ }
+ if (size != 0)
+ return S_FALSE;
+ CSeekExtent se;
+ se.Phy = 0;
+ se.Virt = virtOffset;
+ extentStreamSpec->Extents.Add(se);
+ extentStreamSpec->Init();
+ *stream = extentStream.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _refs2.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+
+ for (i = 0; i < numItems; i++)
+ {
+ UInt32 index = (allFilesMode ? i : indices[i]);
+ const CRef2 &ref2 = _refs2[index];
+ const CRef &ref = _archive.LogVols[ref2.Vol].FileSets[ref2.Fs].Refs[ref2.Ref];
+ const CFile &file = _archive.Files[ref.FileIndex];
+ const CItem &item = _archive.Items[file.ItemIndex];
+ if (!item.IsDir())
+ totalSize += item.Size;
+ }
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialOutStream *outStreamSpec = new CLimitedSequentialOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems; i++)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ const CRef2 &ref2 = _refs2[index];
+ const CRef &ref = _archive.LogVols[ref2.Vol].FileSets[ref2.Fs].Refs[ref2.Ref];
+ const CFile &file = _archive.Files[ref.FileIndex];
+ const CItem &item = _archive.Items[file.ItemIndex];
+
+ if (item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ currentTotalSize += item.Size;
+
+ if (!testMode && !realOutStream)
+ continue;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ outStreamSpec->SetStream(realOutStream);
+ realOutStream.Release();
+ outStreamSpec->Init(item.Size);
+ Int32 opRes;
+ CMyComPtr<ISequentialInStream> udfInStream;
+ HRESULT res = GetStream(index, &udfInStream);
+ if (res == E_NOTIMPL)
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ else if (res != S_OK)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ else
+ {
+ RINOK(copyCoder->Code(udfInStream, outStream, NULL, NULL, progress));
+ opRes = outStreamSpec->IsFinishedOK() ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError;
+ }
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfHandler.h
new file mode 100644
index 000000000..63f859af3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfHandler.h
@@ -0,0 +1,38 @@
+// Udf/Handler.h
+
+#ifndef __UDF_HANDLER_H
+#define __UDF_HANDLER_H
+
+#include "Common/MyCom.h"
+#include "../IArchive.h"
+
+#include "UdfIn.h"
+
+namespace NArchive {
+namespace NUdf {
+
+struct CRef2
+{
+ int Vol;
+ int Fs;
+ int Ref;
+};
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+ CInArchive _archive;
+ CRecordVector<CRef2> _refs2;
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+}}
+
+#endif
+ \ No newline at end of file
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfIn.cpp
new file mode 100644
index 000000000..d2f9e7319
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfIn.cpp
@@ -0,0 +1,876 @@
+// Archive/UdfIn.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/CpuArch.h"
+
+#include "../../Common/StreamUtils.h"
+
+#include "UdfIn.h"
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+namespace NArchive {
+namespace NUdf {
+
+const int kNumPartitionsMax = 64;
+const int kNumLogVolumesMax = 64;
+const int kNumRecureseLevelsMax = 1 << 10;
+const int kNumItemsMax = 1 << 27;
+const int kNumFilesMax = 1 << 28;
+const int kNumRefsMax = 1 << 28;
+const UInt32 kNumExtentsMax = (UInt32)1 << 30;
+const UInt64 kFileNameLengthTotalMax = (UInt64)1 << 33;
+const UInt64 kInlineExtentsSizeMax = (UInt64)1 << 33;
+
+void MY_FAST_CALL Crc16GenerateTable(void);
+
+#define CRC16_INIT_VAL 0
+#define CRC16_GET_DIGEST(crc) (crc)
+#define CRC16_UPDATE_BYTE(crc, b) (g_Crc16Table[(((crc) >> 8) ^ (b)) & 0xFF] ^ ((crc) << 8))
+
+#define kCrc16Poly 0x1021
+UInt16 g_Crc16Table[256];
+
+void MY_FAST_CALL Crc16GenerateTable(void)
+{
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ {
+ UInt32 r = (i << 8);
+ for (int j = 8; j > 0; j--)
+ r = ((r & 0x8000) ? ((r << 1) ^ kCrc16Poly) : (r << 1)) & 0xFFFF;
+ g_Crc16Table[i] = (UInt16)r;
+ }
+}
+
+UInt16 MY_FAST_CALL Crc16_Update(UInt16 v, const void *data, size_t size)
+{
+ const Byte *p = (const Byte *)data;
+ for (; size > 0 ; size--, p++)
+ v = CRC16_UPDATE_BYTE(v, *p);
+ return v;
+}
+
+UInt16 MY_FAST_CALL Crc16Calc(const void *data, size_t size)
+{
+ return Crc16_Update(CRC16_INIT_VAL, data, size);
+}
+
+struct CCrc16TableInit { CCrc16TableInit() { Crc16GenerateTable(); } } g_Crc16TableInit;
+
+void CDString128::Parse(const Byte *buf) { memcpy(Data, buf, sizeof(Data)); }
+
+void CDString::Parse(const Byte *p, unsigned size)
+{
+ Data.SetCapacity(size);
+ memcpy(Data, p, size);
+}
+
+static UString ParseDString(const Byte *data, int size)
+{
+ UString res;
+ wchar_t *p;
+ if (size > 0)
+ {
+ Byte type = data[0];
+ if (type == 8)
+ {
+ p = res.GetBuffer((int)size + 1);
+ for (int i = 1; i < size; i++)
+ {
+ wchar_t c = data[i];
+ if (c == 0)
+ break;
+ *p++ = c;
+ }
+ }
+ else if (type == 16)
+ {
+ p = res.GetBuffer((int)size / 2 + 1);
+ for (int i = 1; i + 2 <= size; i += 2)
+ {
+ wchar_t c = ((wchar_t)data[i] << 8) | data[i + 1];
+ if (c == 0)
+ break;
+ *p++ = c;
+ }
+ }
+ else
+ return L"[unknow]";
+ *p++ = 0;
+ res.ReleaseBuffer();
+ }
+ return res;
+}
+
+UString CDString:: GetString() const { return ParseDString(Data, (int)Data.GetCapacity()); }
+UString CDString128::GetString() const
+{
+ int size = Data[sizeof(Data) - 1];
+ return ParseDString(Data, MyMin(size, (int)(sizeof(Data) - 1)));
+}
+
+void CTime::Parse(const Byte *buf) { memcpy(Data, buf, sizeof(Data)); }
+
+/*
+void CRegId::Parse(const Byte *buf)
+{
+ Flags = buf[0];
+ memcpy(Id, buf + 1, sizeof(Id));
+ memcpy(Suffix, buf + 24, sizeof(Suffix));
+}
+*/
+
+// ECMA 3/7.1
+
+struct CExtent
+{
+ UInt32 Len;
+ UInt32 Pos;
+
+ void Parse(const Byte *buf);
+};
+
+void CExtent::Parse(const Byte *buf)
+{
+ Len = Get32(buf);
+ Pos = Get32(buf + 4);
+}
+
+// ECMA 3/7.2
+
+struct CTag
+{
+ UInt16 Id;
+ UInt16 Version;
+ // Byte Checksum;
+ // UInt16 SerialNumber;
+ // UInt16 Crc;
+ // UInt16 CrcLen;
+ // UInt32 TagLocation;
+
+ HRESULT Parse(const Byte *buf, size_t size);
+};
+
+HRESULT CTag::Parse(const Byte *buf, size_t size)
+{
+ if (size < 16)
+ return S_FALSE;
+ Byte sum = 0;
+ int i;
+ for (i = 0; i < 4; i++) sum = sum + buf[i];
+ for (i = 5; i < 16; i++) sum = sum + buf[i];
+ if (sum != buf[4] || buf[5] != 0) return S_FALSE;
+
+ Id = Get16(buf);
+ Version = Get16(buf + 2);
+ // SerialNumber = Get16(buf + 6);
+ UInt16 crc = Get16(buf + 8);
+ UInt16 crcLen = Get16(buf + 10);
+ // TagLocation = Get32(buf + 12);
+
+ if (size >= 16 + (size_t)crcLen)
+ if (crc == Crc16Calc(buf + 16, crcLen))
+ return S_OK;
+ return S_FALSE;
+}
+
+// ECMA 3/7.2.1
+
+enum EDescriptorType
+{
+ DESC_TYPE_SpoaringTable = 0, // UDF
+ DESC_TYPE_PrimVol = 1,
+ DESC_TYPE_AnchorVolPtr = 2,
+ DESC_TYPE_VolPtr = 3,
+ DESC_TYPE_ImplUseVol = 4,
+ DESC_TYPE_Partition = 5,
+ DESC_TYPE_LogicalVol = 6,
+ DESC_TYPE_UnallocSpace = 7,
+ DESC_TYPE_Terminating = 8,
+ DESC_TYPE_LogicalVolIntegrity = 9,
+ DESC_TYPE_FileSet = 256,
+ DESC_TYPE_FileId = 257,
+ DESC_TYPE_AllocationExtent = 258,
+ DESC_TYPE_Indirect = 259,
+ DESC_TYPE_Terminal = 260,
+ DESC_TYPE_File = 261,
+ DESC_TYPE_ExtendedAttrHeader = 262,
+ DESC_TYPE_UnallocatedSpace = 263,
+ DESC_TYPE_SpaceBitmap = 264,
+ DESC_TYPE_PartitionIntegrity = 265,
+ DESC_TYPE_ExtendedFile = 266,
+};
+
+
+void CLogBlockAddr::Parse(const Byte *buf)
+{
+ Pos = Get32(buf);
+ PartitionRef = Get16(buf + 4);
+}
+
+void CShortAllocDesc::Parse(const Byte *buf)
+{
+ Len = Get32(buf);
+ Pos = Get32(buf + 4);
+}
+
+/*
+void CADImpUse::Parse(const Byte *buf)
+{
+ Flags = Get16(buf);
+ UdfUniqueId = Get32(buf + 2);
+}
+*/
+
+void CLongAllocDesc::Parse(const Byte *buf)
+{
+ Len = Get32(buf);
+ Location.Parse(buf + 4);
+ // memcpy(ImplUse, buf + 10, sizeof(ImplUse));
+ // adImpUse.Parse(ImplUse);
+}
+
+bool CInArchive::CheckExtent(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len) const
+{
+ const CLogVol &vol = LogVols[volIndex];
+ const CPartition &partition = Partitions[vol.PartitionMaps[partitionRef].PartitionIndex];
+ UInt64 offset = ((UInt64)partition.Pos << SecLogSize) + (UInt64)blockPos * vol.BlockSize;
+ return (offset + len) <= (((UInt64)partition.Pos + partition.Len) << SecLogSize);
+}
+
+bool CInArchive::CheckItemExtents(int volIndex, const CItem &item) const
+{
+ for (int i = 0; i < item.Extents.Size(); i++)
+ {
+ const CMyExtent &e = item.Extents[i];
+ if (!CheckExtent(volIndex, e.PartitionRef, e.Pos, e.GetLen()))
+ return false;
+ }
+ return true;
+}
+
+HRESULT CInArchive::Read(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len, Byte *buf)
+{
+ if (!CheckExtent(volIndex, partitionRef, blockPos, len))
+ return S_FALSE;
+ const CLogVol &vol = LogVols[volIndex];
+ const CPartition &partition = Partitions[vol.PartitionMaps[partitionRef].PartitionIndex];
+ RINOK(_stream->Seek(((UInt64)partition.Pos << SecLogSize) +
+ (UInt64)blockPos * vol.BlockSize, STREAM_SEEK_SET, NULL));
+ return ReadStream_FALSE(_stream, buf, len);
+}
+
+HRESULT CInArchive::Read(int volIndex, const CLongAllocDesc &lad, Byte *buf)
+{
+ return Read(volIndex, lad.Location.PartitionRef, lad.Location.Pos, lad.GetLen(), (Byte *)buf);
+}
+
+HRESULT CInArchive::ReadFromFile(int volIndex, const CItem &item, CByteBuffer &buf)
+{
+ if (item.Size >= (UInt32)1 << 30)
+ return S_FALSE;
+ if (item.IsInline)
+ {
+ buf = item.InlineData;
+ return S_OK;
+ }
+ buf.SetCapacity((size_t)item.Size);
+ size_t pos = 0;
+ for (int i = 0; i < item.Extents.Size(); i++)
+ {
+ const CMyExtent &e = item.Extents[i];
+ UInt32 len = e.GetLen();
+ RINOK(Read(volIndex, e.PartitionRef, e.Pos, len, (Byte *)buf + pos));
+ pos += len;
+ }
+ return S_OK;
+}
+
+
+void CIcbTag::Parse(const Byte *p)
+{
+ // PriorDirectNum = Get32(p);
+ // StrategyType = Get16(p + 4);
+ // StrategyParam = Get16(p + 6);
+ // MaxNumOfEntries = Get16(p + 8);
+ FileType = p[11];
+ // ParentIcb.Parse(p + 12);
+ Flags = Get16(p + 18);
+}
+
+void CItem::Parse(const Byte *p)
+{
+ // Uid = Get32(p + 36);
+ // Gid = Get32(p + 40);
+ // Permissions = Get32(p + 44);
+ // FileLinkCount = Get16(p + 48);
+ // RecordFormat = p[50];
+ // RecordDisplayAttr = p[51];
+ // RecordLen = Get32(p + 52);
+ Size = Get64(p + 56);
+ NumLogBlockRecorded = Get64(p + 64);
+ ATime.Parse(p + 72);
+ MTime.Parse(p + 84);
+ // AttrtTime.Parse(p + 96);
+ // CheckPoint = Get32(p + 108);
+ // ExtendedAttrIcb.Parse(p + 112);
+ // ImplId.Parse(p + 128);
+ // UniqueId = Get64(p + 160);
+}
+
+// 4/14.4
+struct CFileId
+{
+ // UInt16 FileVersion;
+ Byte FileCharacteristics;
+ // CByteBuffer ImplUse;
+ CDString Id;
+ CLongAllocDesc Icb;
+
+ bool IsItLinkParent() const { return (FileCharacteristics & FILEID_CHARACS_Parent) != 0; }
+ HRESULT Parse(const Byte *p, size_t size, size_t &processed);
+};
+
+HRESULT CFileId::Parse(const Byte *p, size_t size, size_t &processed)
+{
+ processed = 0;
+ if (size < 38)
+ return S_FALSE;
+ CTag tag;
+ RINOK(tag.Parse(p, size));
+ if (tag.Id != DESC_TYPE_FileId)
+ return S_FALSE;
+ // FileVersion = Get16(p + 16);
+ FileCharacteristics = p[18];
+ unsigned idLen = p[19];
+ Icb.Parse(p + 20);
+ unsigned impLen = Get16(p + 36);
+ if (size < 38 + idLen + impLen)
+ return S_FALSE;
+ // ImplUse.SetCapacity(impLen);
+ processed = 38;
+ // memcpy(ImplUse, p + processed, impLen);
+ processed += impLen;
+ Id.Parse(p + processed, idLen);
+ processed += idLen;
+ for (;(processed & 3) != 0; processed++)
+ if (p[processed] != 0)
+ return S_FALSE;
+ return (processed <= size) ? S_OK : S_FALSE;
+}
+
+HRESULT CInArchive::ReadFileItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed)
+{
+ if (Files.Size() % 100 == 0)
+ RINOK(_progress->SetCompleted(Files.Size(), _processedProgressBytes));
+ if (numRecurseAllowed-- == 0)
+ return S_FALSE;
+ CFile &file = Files.Back();
+ const CLogVol &vol = LogVols[volIndex];
+ CPartition &partition = Partitions[vol.PartitionMaps[lad.Location.PartitionRef].PartitionIndex];
+
+ UInt32 key = lad.Location.Pos;
+ UInt32 value;
+ const UInt32 kRecursedErrorValue = (UInt32)(Int32)-1;
+ if (partition.Map.Find(key, value))
+ {
+ if (value == kRecursedErrorValue)
+ return S_FALSE;
+ file.ItemIndex = value;
+ }
+ else
+ {
+ value = Items.Size();
+ file.ItemIndex = (int)value;
+ if (partition.Map.Set(key, kRecursedErrorValue))
+ return S_FALSE;
+ RINOK(ReadItem(volIndex, fsIndex, lad, numRecurseAllowed));
+ if (!partition.Map.Set(key, value))
+ return S_FALSE;
+ }
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed)
+{
+ if (Items.Size() > kNumItemsMax)
+ return S_FALSE;
+ Items.Add(CItem());
+ CItem &item = Items.Back();
+
+ const CLogVol &vol = LogVols[volIndex];
+
+ if (lad.GetLen() != vol.BlockSize)
+ return S_FALSE;
+
+ CByteBuffer buf;
+ size_t size = lad.GetLen();
+ buf.SetCapacity(size);
+ RINOK(Read(volIndex, lad, buf));
+
+ CTag tag;
+ const Byte *p = buf;
+ RINOK(tag.Parse(p, size));
+ if (tag.Id != DESC_TYPE_File)
+ return S_FALSE;
+
+ item.IcbTag.Parse(p + 16);
+ if (item.IcbTag.FileType != ICB_FILE_TYPE_DIR &&
+ item.IcbTag.FileType != ICB_FILE_TYPE_FILE)
+ return S_FALSE;
+
+ item.Parse(p);
+
+ _processedProgressBytes += (UInt64)item.NumLogBlockRecorded * vol.BlockSize + size;
+
+ UInt32 extendedAttrLen = Get32(p + 168);
+ UInt32 allocDescriptorsLen = Get32(p + 172);
+
+ if ((extendedAttrLen & 3) != 0)
+ return S_FALSE;
+ int pos = 176;
+ if (extendedAttrLen > size - pos)
+ return S_FALSE;
+ /*
+ if (extendedAttrLen != 16)
+ {
+ if (extendedAttrLen < 24)
+ return S_FALSE;
+ CTag attrTag;
+ RINOK(attrTag.Parse(p + pos, size));
+ if (attrTag.Id != DESC_TYPE_ExtendedAttrHeader)
+ return S_FALSE;
+ // UInt32 implAttrLocation = Get32(p + pos + 16);
+ // UInt32 applicationlAttrLocation = Get32(p + pos + 20);
+ }
+ */
+ pos += extendedAttrLen;
+
+ int desctType = item.IcbTag.GetDescriptorType();
+ if (allocDescriptorsLen > size - pos)
+ return S_FALSE;
+ if (desctType == ICB_DESC_TYPE_INLINE)
+ {
+ item.IsInline = true;
+ item.InlineData.SetCapacity(allocDescriptorsLen);
+ memcpy(item.InlineData, p + pos, allocDescriptorsLen);
+ }
+ else
+ {
+ item.IsInline = false;
+ if (desctType != ICB_DESC_TYPE_SHORT && desctType != ICB_DESC_TYPE_LONG)
+ return S_FALSE;
+ for (UInt32 i = 0; i < allocDescriptorsLen;)
+ {
+ CMyExtent e;
+ if (desctType == ICB_DESC_TYPE_SHORT)
+ {
+ if (i + 8 > allocDescriptorsLen)
+ return S_FALSE;
+ CShortAllocDesc sad;
+ sad.Parse(p + pos + i);
+ e.Pos = sad.Pos;
+ e.Len = sad.Len;
+ e.PartitionRef = lad.Location.PartitionRef;
+ i += 8;
+ }
+ else
+ {
+ if (i + 16 > allocDescriptorsLen)
+ return S_FALSE;
+ CLongAllocDesc ladNew;
+ ladNew.Parse(p + pos + i);
+ e.Pos = ladNew.Location.Pos;
+ e.PartitionRef = ladNew.Location.PartitionRef;
+ e.Len = ladNew.Len;
+ i += 16;
+ }
+ item.Extents.Add(e);
+ }
+ }
+
+ if (item.IcbTag.IsDir())
+ {
+ if (!item.CheckChunkSizes() || !CheckItemExtents(volIndex, item))
+ return S_FALSE;
+ CByteBuffer buf;
+ RINOK(ReadFromFile(volIndex, item, buf));
+ item.Size = 0;
+ item.Extents.ClearAndFree();
+ item.InlineData.Free();
+
+ const Byte *p = buf;
+ size = buf.GetCapacity();
+ size_t processedTotal = 0;
+ for (; processedTotal < size;)
+ {
+ size_t processedCur;
+ CFileId fileId;
+ RINOK(fileId.Parse(p + processedTotal, size - processedTotal, processedCur));
+ if (!fileId.IsItLinkParent())
+ {
+ CFile file;
+ // file.FileVersion = fileId.FileVersion;
+ // file.FileCharacteristics = fileId.FileCharacteristics;
+ // file.ImplUse = fileId.ImplUse;
+ file.Id = fileId.Id;
+
+ _fileNameLengthTotal += file.Id.Data.GetCapacity();
+ if (_fileNameLengthTotal > kFileNameLengthTotalMax)
+ return S_FALSE;
+
+ item.SubFiles.Add(Files.Size());
+ if (Files.Size() > kNumFilesMax)
+ return S_FALSE;
+ Files.Add(file);
+ RINOK(ReadFileItem(volIndex, fsIndex, fileId.Icb, numRecurseAllowed));
+ }
+ processedTotal += processedCur;
+ }
+ }
+ else
+ {
+ if ((UInt32)item.Extents.Size() > kNumExtentsMax - _numExtents)
+ return S_FALSE;
+ _numExtents += item.Extents.Size();
+
+ if (item.InlineData.GetCapacity() > kInlineExtentsSizeMax - _inlineExtentsSize)
+ return S_FALSE;
+ _inlineExtentsSize += item.InlineData.GetCapacity();
+ }
+
+ return S_OK;
+}
+
+HRESULT CInArchive::FillRefs(CFileSet &fs, int fileIndex, int parent, int numRecurseAllowed)
+{
+ if (_numRefs % 10000 == 0)
+ {
+ RINOK(_progress->SetCompleted());
+ }
+ if (numRecurseAllowed-- == 0)
+ return S_FALSE;
+ if (_numRefs >= kNumRefsMax)
+ return S_FALSE;
+ _numRefs++;
+ CRef ref;
+ ref.FileIndex = fileIndex;
+ ref.Parent = parent;
+ parent = fs.Refs.Size();
+ fs.Refs.Add(ref);
+ const CItem &item = Items[Files[fileIndex].ItemIndex];
+ for (int i = 0; i < item.SubFiles.Size(); i++)
+ {
+ RINOK(FillRefs(fs, item.SubFiles[i], parent, numRecurseAllowed));
+ }
+ return S_OK;
+}
+
+HRESULT CInArchive::Open2()
+{
+ Clear();
+
+ UInt64 fileSize;
+ RINOK(_stream->Seek(0, STREAM_SEEK_END, &fileSize));
+
+ // Some UDFs contain additional 2 KB of zeros, so we also check 12, corrected to 11.
+ const int kSecLogSizeMax = 12;
+ Byte buf[1 << kSecLogSizeMax];
+ Byte kSizesLog[] = { 11, 8, 12 };
+
+ for (int i = 0;; i++)
+ {
+ if (i == sizeof(kSizesLog) / sizeof(kSizesLog[0]))
+ return S_FALSE;
+ SecLogSize = kSizesLog[i];
+ Int32 bufSize = 1 << SecLogSize;
+ if (bufSize > fileSize)
+ return S_FALSE;
+ RINOK(_stream->Seek(-bufSize, STREAM_SEEK_END, NULL));
+ RINOK(ReadStream_FALSE(_stream, buf, bufSize));
+ CTag tag;
+ if (tag.Parse(buf, bufSize) == S_OK)
+ if (tag.Id == DESC_TYPE_AnchorVolPtr)
+ break;
+ }
+ if (SecLogSize == 12)
+ SecLogSize = 11;
+
+ CExtent extentVDS;
+ extentVDS.Parse(buf + 16);
+
+ for (UInt32 location = extentVDS.Pos; ; location++)
+ {
+ size_t bufSize = 1 << SecLogSize;
+ size_t pos = 0;
+ RINOK(_stream->Seek((UInt64)location << SecLogSize, STREAM_SEEK_SET, NULL));
+ RINOK(ReadStream_FALSE(_stream, buf, bufSize));
+ CTag tag;
+ RINOK(tag.Parse(buf + pos, bufSize - pos));
+ if (tag.Id == DESC_TYPE_Terminating)
+ break;
+ if (tag.Id == DESC_TYPE_Partition)
+ {
+ if (Partitions.Size() >= kNumPartitionsMax)
+ return S_FALSE;
+ CPartition partition;
+ // UInt32 volDescSeqNumer = Get32(buf + 16);
+ // partition.Flags = Get16(buf + 20);
+ partition.Number = Get16(buf + 22);
+ // partition.ContentsId.Parse(buf + 24);
+
+ // memcpy(partition.ContentsUse, buf + 56, sizeof(partition.ContentsUse));
+ // ContentsUse is Partition Header Description.
+
+ // partition.AccessType = Get32(buf + 184);
+ partition.Pos = Get32(buf + 188);
+ partition.Len = Get32(buf + 192);
+ // partition.ImplId.Parse(buf + 196);
+ // memcpy(partition.ImplUse, buf + 228, sizeof(partition.ImplUse));
+
+ Partitions.Add(partition);
+ }
+ else if (tag.Id == DESC_TYPE_LogicalVol)
+ {
+ if (LogVols.Size() >= kNumLogVolumesMax)
+ return S_FALSE;
+ CLogVol vol;
+ vol.Id.Parse(buf + 84);
+ vol.BlockSize = Get32(buf + 212);
+ // vol.DomainId.Parse(buf + 216);
+
+ if (vol.BlockSize < 512 || vol.BlockSize > ((UInt32)1 << 30))
+ return S_FALSE;
+
+ // memcpy(vol.ContentsUse, buf + 248, sizeof(vol.ContentsUse));
+ vol.FileSetLocation.Parse(buf + 248);
+
+ // UInt32 mapTableLength = Get32(buf + 264);
+ UInt32 numPartitionMaps = Get32(buf + 268);
+ if (numPartitionMaps > kNumPartitionsMax)
+ return S_FALSE;
+ // vol.ImplId.Parse(buf + 272);
+ // memcpy(vol.ImplUse, buf + 128, sizeof(vol.ImplUse));
+ size_t pos = 440;
+ for (UInt32 i = 0; i < numPartitionMaps; i++)
+ {
+ if (pos + 2 > bufSize)
+ return S_FALSE;
+ CPartitionMap pm;
+ pm.Type = buf[pos];
+ // pm.Length = buf[pos + 1];
+ Byte len = buf[pos + 1];
+
+ if (pos + len > bufSize)
+ return S_FALSE;
+
+ // memcpy(pm.Data, buf + pos + 2, pm.Length - 2);
+ if (pm.Type == 1)
+ {
+ if (pos + 6 > bufSize)
+ return S_FALSE;
+ // pm.VolSeqNumber = Get16(buf + pos + 2);
+ pm.PartitionNumber = Get16(buf + pos + 4);
+ }
+ else
+ return S_FALSE;
+ pos += len;
+ vol.PartitionMaps.Add(pm);
+ }
+ LogVols.Add(vol);
+ }
+ }
+
+ UInt64 totalSize = 0;
+
+ int volIndex;
+ for (volIndex = 0; volIndex < LogVols.Size(); volIndex++)
+ {
+ CLogVol &vol = LogVols[volIndex];
+ for (int pmIndex = 0; pmIndex < vol.PartitionMaps.Size(); pmIndex++)
+ {
+ CPartitionMap &pm = vol.PartitionMaps[pmIndex];
+ int i;
+ for (i = 0; i < Partitions.Size(); i++)
+ {
+ CPartition &part = Partitions[i];
+ if (part.Number == pm.PartitionNumber)
+ {
+ if (part.VolIndex >= 0)
+ return S_FALSE;
+ pm.PartitionIndex = i;
+ part.VolIndex = volIndex;
+
+ totalSize += (UInt64)part.Len << SecLogSize;
+ break;
+ }
+ }
+ if (i == Partitions.Size())
+ return S_FALSE;
+ }
+ }
+
+ RINOK(_progress->SetTotal(totalSize));
+
+ for (volIndex = 0; volIndex < LogVols.Size(); volIndex++)
+ {
+ CLogVol &vol = LogVols[volIndex];
+
+ CLongAllocDesc nextExtent = vol.FileSetLocation;
+ // while (nextExtent.ExtentLen != 0)
+ // for (int i = 0; i < 1; i++)
+ {
+ if (nextExtent.GetLen() < 512)
+ return S_FALSE;
+ CByteBuffer buf;
+ buf.SetCapacity(nextExtent.GetLen());
+ RINOK(Read(volIndex, nextExtent, buf));
+ const Byte *p = buf;
+ size_t size = nextExtent.GetLen();
+
+ CTag tag;
+ RINOK(tag.Parse(p, size));
+ if (tag.Id != DESC_TYPE_FileSet)
+ return S_FALSE;
+
+ CFileSet fs;
+ fs.RecodringTime.Parse(p + 16);
+ // fs.InterchangeLevel = Get16(p + 18);
+ // fs.MaxInterchangeLevel = Get16(p + 20);
+ // fs.FileSetNumber = Get32(p + 40);
+ // fs.FileSetDescNumber = Get32(p + 44);
+
+ // fs.Id.Parse(p + 304);
+ // fs.CopyrightId.Parse(p + 336);
+ // fs.AbstractId.Parse(p + 368);
+
+ fs.RootDirICB.Parse(p + 400);
+ // fs.DomainId.Parse(p + 416);
+
+ // fs.SystemStreamDirICB.Parse(p + 464);
+
+ vol.FileSets.Add(fs);
+
+ // nextExtent.Parse(p + 448);
+ }
+
+ for (int fsIndex = 0; fsIndex < vol.FileSets.Size(); fsIndex++)
+ {
+ CFileSet &fs = vol.FileSets[fsIndex];
+ int fileIndex = Files.Size();
+ Files.Add(CFile());
+ RINOK(ReadFileItem(volIndex, fsIndex, fs.RootDirICB, kNumRecureseLevelsMax));
+ RINOK(FillRefs(fs, fileIndex, -1, kNumRecureseLevelsMax));
+ }
+ }
+
+ return S_OK;
+}
+
+HRESULT CInArchive::Open(IInStream *inStream, CProgressVirt *progress)
+{
+ _progress = progress;
+ _stream = inStream;
+ HRESULT res;
+ try { res = Open2(); }
+ catch(...) { Clear(); res = S_FALSE; }
+ _stream.Release();
+ return res;
+}
+
+void CInArchive::Clear()
+{
+ Partitions.Clear();
+ LogVols.Clear();
+ Items.Clear();
+ Files.Clear();
+ _fileNameLengthTotal = 0;
+ _numRefs = 0;
+ _numExtents = 0;
+ _inlineExtentsSize = 0;
+ _processedProgressBytes = 0;
+}
+
+UString CInArchive::GetComment() const
+{
+ UString res;
+ for (int i = 0; i < LogVols.Size(); i++)
+ {
+ if (i > 0)
+ res += L" ";
+ res += LogVols[i].GetName();
+ }
+ return res;
+}
+
+static UString GetSpecName(const UString &name)
+{
+ UString name2 = name;
+ name2.Trim();
+ if (name2.IsEmpty())
+ {
+ /*
+ wchar_t s[32];
+ ConvertUInt64ToString(id, s);
+ return L"[" + (UString)s + L"]";
+ */
+ return L"[]";
+ }
+ return name;
+}
+
+static void UpdateWithName(UString &res, const UString &addString)
+{
+ if (res.IsEmpty())
+ res = addString;
+ else
+ res = addString + WCHAR_PATH_SEPARATOR + res;
+}
+
+UString CInArchive::GetItemPath(int volIndex, int fsIndex, int refIndex,
+ bool showVolName, bool showFsName) const
+{
+ // showVolName = true;
+ const CLogVol &vol = LogVols[volIndex];
+ const CFileSet &fs = vol.FileSets[fsIndex];
+
+ UString name;
+
+ for (;;)
+ {
+ const CRef &ref = fs.Refs[refIndex];
+ refIndex = ref.Parent;
+ if (refIndex < 0)
+ break;
+ UpdateWithName(name, GetSpecName(Files[ref.FileIndex].GetName()));
+ }
+
+ if (showFsName)
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString(fsIndex, s);
+ UString newName = L"File Set ";
+ newName += s;
+ UpdateWithName(name, newName);
+ }
+
+ if (showVolName)
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString(volIndex, s);
+ UString newName = s;
+ UString newName2 = vol.GetName();
+ if (newName2.IsEmpty())
+ newName2 = L"Volume";
+ newName += L'-';
+ newName += newName2;
+ UpdateWithName(name, newName);
+ }
+ return name;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfIn.h
new file mode 100644
index 000000000..46b9a7e85
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfIn.h
@@ -0,0 +1,375 @@
+// Archive/UdfIn.h -- UDF / ECMA-167
+
+#ifndef __ARCHIVE_UDF_IN_H
+#define __ARCHIVE_UDF_IN_H
+
+#include "Common/MyCom.h"
+#include "Common/IntToString.h"
+#include "Common/Buffer.h"
+#include "Common/MyString.h"
+#include "Common/MyMap.h"
+
+#include "../../IStream.h"
+
+namespace NArchive {
+namespace NUdf {
+
+// ---------- ECMA Part 1 ----------
+
+// ECMA 1/7.2.12
+
+/*
+struct CDString32
+{
+ Byte Data[32];
+ void Parse(const Byte *buf);
+ // UString GetString() const;
+};
+*/
+
+struct CDString128
+{
+ Byte Data[128];
+ void Parse(const Byte *buf);
+ UString GetString() const;
+};
+
+struct CDString
+{
+ CByteBuffer Data;
+ void Parse(const Byte *p, unsigned size);
+ UString GetString() const;
+};
+
+
+// ECMA 1/7.3
+
+struct CTime
+{
+ Byte Data[12];
+
+ unsigned GetType() const { return Data[1] >> 4; }
+ bool IsLocal() const { return GetType() == 1; }
+ int GetMinutesOffset() const
+ {
+ int t = (Data[0] | ((UInt16)Data[1] << 8)) & 0xFFF;
+ if ((t >> 11) != 0)
+ t -= (1 << 12);
+ return (t > (60 * 24) || t < -(60 * 24)) ? 0 : t;
+ }
+ unsigned GetYear() const { return (Data[2] | ((UInt16)Data[3] << 8)); }
+ void Parse(const Byte *buf);
+};
+
+
+// ECMA 1/7.4
+
+/*
+struct CRegId
+{
+ Byte Flags;
+ char Id[23];
+ char Suffix[8];
+
+ void Parse(const Byte *buf);
+};
+*/
+
+// ---------- ECMA Part 3: Volume Structure ----------
+
+// ECMA 3/10.5
+
+struct CPartition
+{
+ // UInt16 Flags;
+ UInt16 Number;
+ // CRegId ContentsId;
+ // Byte ContentsUse[128];
+ // UInt32 AccessType;
+
+ UInt32 Pos;
+ UInt32 Len;
+
+ // CRegId ImplId;
+ // Byte ImplUse[128];
+
+ int VolIndex;
+ CMap32 Map;
+
+ CPartition(): VolIndex(-1) {}
+
+ // bool IsNsr() const { return (strncmp(ContentsId.Id, "+NSR0", 5) == 0); }
+ // bool IsAllocated() const { return ((Flags & 1) != 0); }
+};
+
+struct CLogBlockAddr
+{
+ UInt32 Pos;
+ UInt16 PartitionRef;
+
+ void Parse(const Byte *buf);
+};
+
+enum EShortAllocDescType
+{
+ SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated = 0,
+ SHORT_ALLOC_DESC_TYPE_NotRecordedButAllocated = 1,
+ SHORT_ALLOC_DESC_TYPE_NotRecordedAndNotAllocated = 2,
+ SHORT_ALLOC_DESC_TYPE_NextExtent = 3
+};
+
+struct CShortAllocDesc
+{
+ UInt32 Len;
+ UInt32 Pos;
+
+ // 4/14.14.1
+ // UInt32 GetLen() const { return Len & 0x3FFFFFFF; }
+ // UInt32 GetType() const { return Len >> 30; }
+ // bool IsRecAndAlloc() const { return GetType() == SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated; }
+ void Parse(const Byte *buf);
+};
+
+/*
+struct CADImpUse
+{
+ UInt16 Flags;
+ UInt32 UdfUniqueId;
+ void Parse(const Byte *buf);
+};
+*/
+
+struct CLongAllocDesc
+{
+ UInt32 Len;
+ CLogBlockAddr Location;
+
+ // Byte ImplUse[6];
+ // CADImpUse adImpUse; // UDF
+
+ UInt32 GetLen() const { return Len & 0x3FFFFFFF; }
+ UInt32 GetType() const { return Len >> 30; }
+ bool IsRecAndAlloc() const { return GetType() == SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated; }
+ void Parse(const Byte *buf);
+};
+
+struct CPartitionMap
+{
+ Byte Type;
+ // Byte Len;
+
+ // Type - 1
+ // UInt16 VolSeqNumber;
+ UInt16 PartitionNumber;
+
+ // Byte Data[256];
+
+ int PartitionIndex;
+};
+
+// ECMA 4/14.6
+
+enum EIcbFileType
+{
+ ICB_FILE_TYPE_DIR = 4,
+ ICB_FILE_TYPE_FILE = 5
+};
+
+enum EIcbDescriptorType
+{
+ ICB_DESC_TYPE_SHORT = 0,
+ ICB_DESC_TYPE_LONG = 1,
+ ICB_DESC_TYPE_EXTENDED = 2,
+ ICB_DESC_TYPE_INLINE = 3
+};
+
+struct CIcbTag
+{
+ // UInt32 PriorDirectNum;
+ // UInt16 StrategyType;
+ // UInt16 StrategyParam;
+ // UInt16 MaxNumOfEntries;
+ Byte FileType;
+ // CLogBlockAddr ParentIcb;
+ UInt16 Flags;
+
+ bool IsDir() const { return FileType == ICB_FILE_TYPE_DIR; }
+ int GetDescriptorType() const { return Flags & 3; }
+ void Parse(const Byte *p);
+};
+
+// const Byte FILEID_CHARACS_Existance = (1 << 0);
+const Byte FILEID_CHARACS_Parent = (1 << 3);
+
+struct CFile
+{
+ // UInt16 FileVersion;
+ // Byte FileCharacteristics;
+ // CByteBuffer ImplUse;
+ CDString Id;
+
+ CFile(): /* FileVersion(0), FileCharacteristics(0), */ ItemIndex(-1) {}
+ int ItemIndex;
+ UString GetName() const { return Id.GetString(); }
+};
+
+struct CMyExtent
+{
+ UInt32 Pos;
+ UInt32 Len;
+ int PartitionRef;
+
+ UInt32 GetLen() const { return Len & 0x3FFFFFFF; }
+ UInt32 GetType() const { return Len >> 30; }
+ bool IsRecAndAlloc() const { return GetType() == SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated; }
+};
+
+struct CItem
+{
+ CIcbTag IcbTag;
+
+ // UInt32 Uid;
+ // UInt32 Gid;
+ // UInt32 Permissions;
+ // UInt16 FileLinkCount;
+ // Byte RecordFormat;
+ // Byte RecordDisplayAttr;
+ // UInt32 RecordLen;
+ UInt64 Size;
+ UInt64 NumLogBlockRecorded;
+ CTime ATime;
+ CTime MTime;
+ // CTime AttrtTime;
+ // UInt32 CheckPoint;
+ // CLongAllocDesc ExtendedAttrIcb;
+ // CRegId ImplId;
+ // UInt64 UniqueId;
+
+ bool IsInline;
+ CByteBuffer InlineData;
+ CRecordVector<CMyExtent> Extents;
+ CRecordVector<int> SubFiles;
+
+ void Parse(const Byte *buf);
+
+ bool IsRecAndAlloc() const
+ {
+ for (int i = 0; i < Extents.Size(); i++)
+ if (!Extents[i].IsRecAndAlloc())
+ return false;
+ return true;
+ }
+
+ UInt64 GetChunksSumSize() const
+ {
+ if (IsInline)
+ return InlineData.GetCapacity();
+ UInt64 size = 0;
+ for (int i = 0; i < Extents.Size(); i++)
+ size += Extents[i].GetLen();
+ return size;
+ }
+
+ bool CheckChunkSizes() const { return GetChunksSumSize() == Size; }
+
+ bool IsDir() const { return IcbTag.IsDir(); }
+};
+
+struct CRef
+{
+ int Parent;
+ int FileIndex;
+};
+
+
+// ECMA 4 / 14.1
+struct CFileSet
+{
+ CTime RecodringTime;
+ // UInt16 InterchangeLevel;
+ // UInt16 MaxInterchangeLevel;
+ // UInt32 FileSetNumber;
+ // UInt32 FileSetDescNumber;
+ // CDString32 Id;
+ // CDString32 CopyrightId;
+ // CDString32 AbstractId;
+
+ CLongAllocDesc RootDirICB;
+ // CRegId DomainId;
+ // CLongAllocDesc SystemStreamDirICB;
+
+ CRecordVector<CRef> Refs;
+};
+
+
+// ECMA 3/10.6
+
+struct CLogVol
+{
+ CDString128 Id;
+ UInt32 BlockSize;
+ // CRegId DomainId;
+
+ // Byte ContentsUse[16];
+ CLongAllocDesc FileSetLocation; // UDF
+
+ // CRegId ImplId;
+ // Byte ImplUse[128];
+
+ CObjectVector<CPartitionMap> PartitionMaps;
+ CObjectVector<CFileSet> FileSets;
+
+ UString GetName() const { return Id.GetString(); }
+};
+
+struct CProgressVirt
+{
+ virtual HRESULT SetTotal(UInt64 numBytes) PURE;
+ virtual HRESULT SetCompleted(UInt64 numFiles, UInt64 numBytes) PURE;
+ virtual HRESULT SetCompleted() PURE;
+};
+
+class CInArchive
+{
+ CMyComPtr<IInStream> _stream;
+ CProgressVirt *_progress;
+
+ HRESULT Read(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len, Byte *buf);
+ HRESULT Read(int volIndex, const CLongAllocDesc &lad, Byte *buf);
+ HRESULT ReadFromFile(int volIndex, const CItem &item, CByteBuffer &buf);
+
+ HRESULT ReadFileItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed);
+ HRESULT ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed);
+
+ HRESULT Open2();
+ HRESULT FillRefs(CFileSet &fs, int fileIndex, int parent, int numRecurseAllowed);
+
+ UInt64 _processedProgressBytes;
+
+ UInt64 _fileNameLengthTotal;
+ int _numRefs;
+ UInt32 _numExtents;
+ UInt64 _inlineExtentsSize;
+ bool CheckExtent(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len) const;
+public:
+ HRESULT Open(IInStream *inStream, CProgressVirt *progress);
+ void Clear();
+
+ CObjectVector<CPartition> Partitions;
+ CObjectVector<CLogVol> LogVols;
+
+ CObjectVector<CItem> Items;
+ CObjectVector<CFile> Files;
+
+ int SecLogSize;
+
+ UString GetComment() const;
+ UString GetItemPath(int volIndex, int fsIndex, int refIndex,
+ bool showVolName, bool showFsName) const;
+
+ bool CheckItemExtents(int volIndex, const CItem &item) const;
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfRegister.cpp
new file mode 100644
index 000000000..b3a6c152e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Udf/UdfRegister.cpp
@@ -0,0 +1,13 @@
+// UdfRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "UdfHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NUdf::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Udf", L"iso", 0, 0xE0, { 0, 'N', 'S', 'R', '0' }, 5, false, CreateArc, 0 };
+
+REGISTER_ARC(Udf)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/VhdHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/VhdHandler.cpp
new file mode 100644
index 000000000..5fc2c9189
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/VhdHandler.cpp
@@ -0,0 +1,731 @@
+// VhdHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+#include "Common/MyString.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#define Get16(p) GetBe16(p)
+#define Get32(p) GetBe32(p)
+#define Get64(p) GetBe64(p)
+
+#define G32(p, dest) dest = Get32(p);
+#define G64(p, dest) dest = Get64(p);
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NVhd {
+
+static const UInt32 kUnusedBlock = 0xFFFFFFFF;
+
+static const UInt32 kDiskType_Fixed = 2;
+static const UInt32 kDiskType_Dynamic = 3;
+static const UInt32 kDiskType_Diff = 4;
+
+static const char *kDiskTypes[] =
+{
+ "0",
+ "1",
+ "Fixed",
+ "Dynamic",
+ "Differencing"
+};
+
+struct CFooter
+{
+ // UInt32 Features;
+ // UInt32 FormatVersion;
+ UInt64 DataOffset;
+ UInt32 CTime;
+ UInt32 CreatorApp;
+ UInt32 CreatorVersion;
+ UInt32 CreatorHostOS;
+ // UInt64 OriginalSize;
+ UInt64 CurrentSize;
+ UInt32 DiskGeometry;
+ UInt32 Type;
+ Byte Id[16];
+ Byte SavedState;
+
+ bool IsFixed() const { return Type == kDiskType_Fixed; }
+ bool ThereIsDynamic() const { return Type == kDiskType_Dynamic || Type == kDiskType_Diff; }
+ // bool IsSupported() const { return Type == kDiskType_Fixed || Type == kDiskType_Dynamic || Type == kDiskType_Diff; }
+ UInt32 NumCyls() const { return DiskGeometry >> 16; }
+ UInt32 NumHeads() const { return (DiskGeometry >> 8) & 0xFF; }
+ UInt32 NumSectorsPerTrack() const { return DiskGeometry & 0xFF; }
+ AString GetTypeString() const;
+ bool Parse(const Byte *p);
+};
+
+AString CFooter::GetTypeString() const
+{
+ if (Type < sizeof(kDiskTypes) / sizeof(kDiskTypes[0]))
+ return kDiskTypes[Type];
+ char s[16];
+ ConvertUInt32ToString(Type, s);
+ return s;
+}
+
+static bool CheckBlock(const Byte *p, unsigned size, unsigned checkSumOffset, unsigned zeroOffset)
+{
+ UInt32 sum = 0;
+ unsigned i;
+ for (i = 0; i < checkSumOffset; i++)
+ sum += p[i];
+ for (i = checkSumOffset + 4; i < size; i++)
+ sum += p[i];
+ if (~sum != Get32(p + checkSumOffset))
+ return false;
+ for (i = zeroOffset; i < size; i++)
+ if (p[i] != 0)
+ return false;
+ return true;
+}
+
+bool CFooter::Parse(const Byte *p)
+{
+ if (memcmp(p, "conectix", 8) != 0)
+ return false;
+ // G32(p + 0x08, Features);
+ // G32(p + 0x0C, FormatVersion);
+ G64(p + 0x10, DataOffset);
+ G32(p + 0x18, CTime);
+ G32(p + 0x1C, CreatorApp);
+ G32(p + 0x20, CreatorVersion);
+ G32(p + 0x24, CreatorHostOS);
+ // G64(p + 0x28, OriginalSize);
+ G64(p + 0x30, CurrentSize);
+ G32(p + 0x38, DiskGeometry);
+ G32(p + 0x3C, Type);
+ memcpy(Id, p + 0x44, 16);
+ SavedState = p[0x54];
+ return CheckBlock(p, 512, 0x40, 0x55);
+}
+
+/*
+struct CParentLocatorEntry
+{
+ UInt32 Code;
+ UInt32 DataSpace;
+ UInt32 DataLen;
+ UInt64 DataOffset;
+
+ bool Parse(const Byte *p);
+};
+bool CParentLocatorEntry::Parse(const Byte *p)
+{
+ G32(p + 0x00, Code);
+ G32(p + 0x04, DataSpace);
+ G32(p + 0x08, DataLen);
+ G32(p + 0x10, DataOffset);
+ return (Get32(p + 0x0C) == 0); // Resrved
+}
+*/
+
+struct CDynHeader
+{
+ // UInt64 DataOffset;
+ UInt64 TableOffset;
+ // UInt32 HeaderVersion;
+ UInt32 NumBlocks;
+ int BlockSizeLog;
+ UInt32 ParentTime;
+ Byte ParentId[16];
+ UString ParentName;
+ // CParentLocatorEntry ParentLocators[8];
+
+ bool Parse(const Byte *p);
+ UInt32 NumBitMapSectors() const
+ {
+ UInt32 numSectorsInBlock = (1 << (BlockSizeLog - 9));
+ return (numSectorsInBlock + 512 * 8 - 1) / (512 * 8);
+ }
+};
+
+static int GetLog(UInt32 num)
+{
+ for (int i = 0; i < 31; i++)
+ if (((UInt32)1 << i) == num)
+ return i;
+ return -1;
+}
+
+bool CDynHeader::Parse(const Byte *p)
+{
+ if (memcmp(p, "cxsparse", 8) != 0)
+ return false;
+ // G64(p + 0x08, DataOffset);
+ G64(p + 0x10, TableOffset);
+ // G32(p + 0x18, HeaderVersion);
+ G32(p + 0x1C, NumBlocks);
+ BlockSizeLog = GetLog(Get32(p + 0x20));
+ if (BlockSizeLog < 9 || BlockSizeLog > 30)
+ return false;
+ G32(p + 0x38, ParentTime);
+ if (Get32(p + 0x3C) != 0) // reserved
+ return false;
+ memcpy(ParentId, p + 0x28, 16);
+ {
+ const int kNameLength = 256;
+ wchar_t *s = ParentName.GetBuffer(kNameLength);
+ for (unsigned i = 0; i < kNameLength; i++)
+ s[i] = Get16(p + 0x40 + i * 2);
+ s[kNameLength] = 0;
+ ParentName.ReleaseBuffer();
+ }
+ /*
+ for (int i = 0; i < 8; i++)
+ if (!ParentLocators[i].Parse(p + 0x240 + i * 24))
+ return false;
+ */
+ return CheckBlock(p, 1024, 0x24, 0x240 + 8 * 24);
+}
+
+class CHandler:
+ public IInStream,
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ UInt64 _virtPos;
+ UInt64 _phyPos;
+ UInt64 _phyLimit;
+
+ CFooter Footer;
+ CDynHeader Dyn;
+ CRecordVector<UInt32> Bat;
+ CByteBuffer BitMap;
+ UInt32 BitMapTag;
+ UInt32 NumUsedBlocks;
+ CMyComPtr<IInStream> Stream;
+ CMyComPtr<IInStream> ParentStream;
+ CHandler *Parent;
+
+ HRESULT Seek(UInt64 offset);
+ HRESULT InitAndSeek();
+ HRESULT ReadPhy(UInt64 offset, void *data, UInt32 size);
+
+ bool NeedParent() const { return Footer.Type == kDiskType_Diff; }
+ UInt64 GetSize() const { return Footer.CurrentSize; }
+ UInt64 GetPackSize() const
+ { return Footer.ThereIsDynamic() ? ((UInt64)NumUsedBlocks << Dyn.BlockSizeLog) : Footer.CurrentSize; }
+
+ UString GetParentName() const
+ {
+ const CHandler *p = this;
+ UString res;
+ while (p && p->NeedParent())
+ {
+ if (!res.IsEmpty())
+ res += L" -> ";
+ res += p->Dyn.ParentName;
+ p = p->Parent;
+ }
+ return res;
+ }
+
+ bool IsOK() const
+ {
+ const CHandler *p = this;
+ while (p->NeedParent())
+ {
+ p = p->Parent;
+ if (p == 0)
+ return false;
+ }
+ return true;
+ }
+
+ HRESULT Open3();
+ HRESULT Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback *openArchiveCallback, int level);
+
+public:
+ MY_UNKNOWN_IMP3(IInArchive, IInArchiveGetStream, IInStream)
+
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+};
+
+HRESULT CHandler::Seek(UInt64 offset) { return Stream->Seek(offset, STREAM_SEEK_SET, NULL); }
+
+HRESULT CHandler::InitAndSeek()
+{
+ if (ParentStream)
+ {
+ RINOK(Parent->InitAndSeek());
+ }
+ _virtPos = _phyPos = 0;
+ BitMapTag = kUnusedBlock;
+ BitMap.SetCapacity(Dyn.NumBitMapSectors() << 9);
+ return Seek(0);
+}
+
+HRESULT CHandler::ReadPhy(UInt64 offset, void *data, UInt32 size)
+{
+ if (offset + size > _phyLimit)
+ return S_FALSE;
+ if (offset != _phyPos)
+ {
+ _phyPos = offset;
+ RINOK(Seek(offset));
+ }
+ HRESULT res = ReadStream_FALSE(Stream, data, size);
+ _phyPos += size;
+ return res;
+}
+
+HRESULT CHandler::Open3()
+{
+ RINOK(Stream->Seek(0, STREAM_SEEK_END, &_phyPos));
+ if (_phyPos < 512)
+ return S_FALSE;
+ const UInt32 kDynSize = 1024;
+ Byte buf[kDynSize];
+
+ _phyLimit = _phyPos;
+ RINOK(ReadPhy(_phyLimit - 512, buf, 512));
+ if (!Footer.Parse(buf))
+ return S_FALSE;
+ _phyLimit -= 512;
+
+ if (!Footer.ThereIsDynamic())
+ return S_OK;
+
+ RINOK(ReadPhy(0, buf + 512, 512));
+ if (memcmp(buf, buf + 512, 512) != 0)
+ return S_FALSE;
+
+ RINOK(ReadPhy(Footer.DataOffset, buf, kDynSize));
+ if (!Dyn.Parse(buf))
+ return S_FALSE;
+
+ if (Dyn.NumBlocks >= (UInt32)1 << 31)
+ return S_FALSE;
+ if (GetSize() != ((UInt64)Dyn.NumBlocks << Dyn.BlockSizeLog))
+ return S_FALSE;
+
+ Bat.Reserve(Dyn.NumBlocks);
+ while ((UInt32)Bat.Size() < Dyn.NumBlocks)
+ {
+ RINOK(ReadPhy(Dyn.TableOffset + (UInt64)Bat.Size() * 4, buf, 512));
+ for (UInt32 j = 0; j < 512; j += 4)
+ {
+ UInt32 v = Get32(buf + j);
+ if (v != kUnusedBlock)
+ NumUsedBlocks++;
+ Bat.Add(v);
+ if ((UInt32)Bat.Size() >= Dyn.NumBlocks)
+ break;
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ if (_virtPos >= GetSize())
+ return (GetSize() == _virtPos) ? S_OK: E_FAIL;
+ if (size == 0)
+ return S_OK;
+ UInt32 blockIndex = (UInt32)(_virtPos >> Dyn.BlockSizeLog);
+ UInt32 blockSectIndex = Bat[blockIndex];
+ UInt32 blockSize = (UInt32)1 << Dyn.BlockSizeLog;
+ UInt32 offsetInBlock = (UInt32)_virtPos & (blockSize - 1);
+ size = MyMin(blockSize - offsetInBlock, size);
+
+ HRESULT res = S_OK;
+ if (blockSectIndex == kUnusedBlock)
+ {
+ if (ParentStream)
+ {
+ RINOK(ParentStream->Seek(_virtPos, STREAM_SEEK_SET, NULL));
+ res = ParentStream->Read(data, size, &size);
+ }
+ else
+ memset(data, 0, size);
+ }
+ else
+ {
+ UInt64 newPos = (UInt64)blockSectIndex << 9;
+ if (BitMapTag != blockIndex)
+ {
+ RINOK(ReadPhy(newPos, BitMap, (UInt32)BitMap.GetCapacity()));
+ BitMapTag = blockIndex;
+ }
+ RINOK(ReadPhy(newPos + BitMap.GetCapacity() + offsetInBlock, data, size));
+ for (UInt32 cur = 0; cur < size;)
+ {
+ UInt32 rem = MyMin(0x200 - (offsetInBlock & 0x1FF), size - cur);
+ UInt32 bmi = offsetInBlock >> 9;
+ if (((BitMap[bmi >> 3] >> (7 - (bmi & 7))) & 1) == 0)
+ {
+ if (ParentStream)
+ {
+ RINOK(ParentStream->Seek(_virtPos + cur, STREAM_SEEK_SET, NULL));
+ RINOK(ReadStream_FALSE(ParentStream, (Byte *)data + cur, rem));
+ }
+ else
+ {
+ const Byte *p = (const Byte *)data + cur;
+ for (UInt32 i = 0; i < rem; i++)
+ if (p[i] != 0)
+ return S_FALSE;
+ }
+ }
+ offsetInBlock += rem;
+ cur += rem;
+ }
+ }
+ if (processedSize != NULL)
+ *processedSize = size;
+ _virtPos += size;
+ return res;
+}
+
+STDMETHODIMP CHandler::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET: _virtPos = offset; break;
+ case STREAM_SEEK_CUR: _virtPos += offset; break;
+ case STREAM_SEEK_END: _virtPos = GetSize() + offset; break;
+ default: return STG_E_INVALIDFUNCTION;
+ }
+ if (newPosition)
+ *newPosition = _virtPos;
+ return S_OK;
+}
+
+enum
+{
+ kpidParent = kpidUserDefined,
+ kpidSavedState
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidClusterSize, VT_UI8},
+ { NULL, kpidMethod, VT_BSTR},
+ { L"Parent", kpidParent, VT_BSTR},
+ { NULL, kpidCreatorApp, VT_BSTR},
+ { NULL, kpidHostOS, VT_BSTR},
+ { L"Saved State", kpidSavedState, VT_BOOL},
+ { NULL, kpidId, VT_BSTR}
+ };
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME}
+
+ /*
+ { NULL, kpidNumCyls, VT_UI4},
+ { NULL, kpidNumHeads, VT_UI4},
+ { NULL, kpidSectorsPerTrack, VT_UI4}
+ */
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_WITH_NAME
+
+// VHD start time: 2000-01-01
+static const UInt64 kVhdTimeStartValue = (UInt64)3600 * 24 * (399 * 365 + 24 * 4);
+
+static void VhdTimeToFileTime(UInt32 vhdTime, NCOM::CPropVariant &prop)
+{
+ FILETIME ft, utc;
+ UInt64 v = (kVhdTimeStartValue + vhdTime) * 10000000;
+ ft.dwLowDateTime = (DWORD)v;
+ ft.dwHighDateTime = (DWORD)(v >> 32);
+ // specification says that it's UTC time, but Virtual PC 6 writes local time. Why?
+ LocalFileTimeToFileTime(&ft, &utc);
+ prop = utc;
+}
+
+static void StringToAString(char *dest, UInt32 s)
+{
+ for (int i = 24; i >= 0; i -= 8)
+ {
+ Byte b = (Byte)((s >> i) & 0xFF);
+ if (b < 0x20 || b > 0x7F)
+ break;
+ *dest++ = b;
+ }
+ *dest = 0;
+}
+
+static void ConvertByteToHex(unsigned value, char *s)
+{
+ for (int i = 0; i < 2; i++)
+ {
+ unsigned t = value & 0xF;
+ value >>= 4;
+ s[1 - i] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
+ }
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMainSubfile: prop = (UInt32)0; break;
+ case kpidCTime: VhdTimeToFileTime(Footer.CTime, prop); break;
+ case kpidClusterSize: if (Footer.ThereIsDynamic()) prop = (UInt32)1 << Dyn.BlockSizeLog; break;
+ case kpidMethod:
+ {
+ AString s = Footer.GetTypeString();
+ if (NeedParent())
+ {
+ s += " -> ";
+ const CHandler *p = this;
+ while (p != 0 && p->NeedParent())
+ p = p->Parent;
+ if (p == 0)
+ s += '?';
+ else
+ s += p->Footer.GetTypeString();
+ }
+ prop = s;
+ break;
+ }
+ case kpidCreatorApp:
+ {
+ char s[16];
+ StringToAString(s, Footer.CreatorApp);
+ AString res = s;
+ res.Trim();
+ ConvertUInt32ToString(Footer.CreatorVersion >> 16, s);
+ res += ' ';
+ res += s;
+ res += '.';
+ ConvertUInt32ToString(Footer.CreatorVersion & 0xFFFF, s);
+ res += s;
+ prop = res;
+ break;
+ }
+ case kpidHostOS:
+ {
+ if (Footer.CreatorHostOS == 0x5769326b)
+ prop = "Windows";
+ else
+ {
+ char s[16];
+ StringToAString(s, Footer.CreatorHostOS);
+ prop = s;
+ }
+ break;
+ }
+ case kpidId:
+ {
+ char s[32 + 4];
+ for (int i = 0; i < 16; i++)
+ ConvertByteToHex(Footer.Id[i], s + i * 2);
+ s[32] = 0;
+ prop = s;
+ break;
+ }
+ case kpidSavedState: prop = Footer.SavedState ? true : false; break;
+ case kpidParent: if (NeedParent()) prop = GetParentName(); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback *openArchiveCallback, int level)
+{
+ Close();
+ Stream = stream;
+ if (level > 32)
+ return S_FALSE;
+ RINOK(Open3());
+ if (child && memcmp(child->Dyn.ParentId, Footer.Id, 16) != 0)
+ return S_FALSE;
+ if (Footer.Type != kDiskType_Diff)
+ return S_OK;
+ CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
+ if (openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback) != S_OK)
+ return S_FALSE;
+ CMyComPtr<IInStream> nextStream;
+ HRESULT res = openVolumeCallback->GetStream(Dyn.ParentName, &nextStream);
+ if (res == S_FALSE)
+ return S_OK;
+ RINOK(res);
+
+ Parent = new CHandler;
+ ParentStream = Parent;
+ return Parent->Open2(nextStream, this, openArchiveCallback, level + 1);
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ {
+ HRESULT res;
+ try
+ {
+ res = Open2(stream, NULL, openArchiveCallback, 0);
+ if (res == S_OK)
+ return S_OK;
+ }
+ catch(...)
+ {
+ Close();
+ throw;
+ }
+ Close();
+ return res;
+ }
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ Bat.Clear();
+ NumUsedBlocks = 0;
+ Parent = 0;
+ Stream.Release();
+ ParentStream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+
+ switch(propID)
+ {
+ case kpidSize: prop = GetSize(); break;
+ case kpidPackSize: prop = GetPackSize(); break;
+ case kpidCTime: VhdTimeToFileTime(Footer.CTime, prop); break;
+ /*
+ case kpidNumCyls: prop = Footer.NumCyls(); break;
+ case kpidNumHeads: prop = Footer.NumHeads(); break;
+ case kpidSectorsPerTrack: prop = Footer.NumSectorsPerTrack(); break;
+ */
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ if (numItems == UInt32(-1))
+ numItems = 1;
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1 || indices[0] != 0)
+ return E_INVALIDARG;
+
+ bool testMode = (_aTestMode != 0);
+
+ RINOK(extractCallback->SetTotal(GetSize()));
+ CMyComPtr<ISequentialOutStream> outStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ RINOK(extractCallback->GetStream(0, &outStream, askMode));
+ if (!testMode && !outStream)
+ return S_OK;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ int res = NArchive::NExtract::NOperationResult::kDataError;
+ CMyComPtr<ISequentialInStream> inStream;
+ HRESULT hres = GetStream(0, &inStream);
+ if (hres == S_FALSE)
+ res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ else
+ {
+ RINOK(hres);
+ HRESULT hres = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+ if (hres == S_OK)
+ {
+ if (copyCoderSpec->TotalSize == GetSize())
+ res = NArchive::NExtract::NOperationResult::kOK;
+ }
+ else
+ {
+ if (hres != S_FALSE)
+ {
+ RINOK(hres);
+ }
+ }
+ }
+ outStream.Release();
+ return extractCallback->SetOperationResult(res);
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 /* index */, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ *stream = 0;
+ if (Footer.IsFixed())
+ {
+ CLimitedInStream *streamSpec = new CLimitedInStream;
+ CMyComPtr<ISequentialInStream> streamTemp = streamSpec;
+ streamSpec->SetStream(Stream);
+ streamSpec->InitAndSeek(0, GetSize());
+ RINOK(streamSpec->SeekToStart());
+ *stream = streamTemp.Detach();
+ return S_OK;
+ }
+ if (!Footer.ThereIsDynamic() || !IsOK())
+ return S_FALSE;
+ CMyComPtr<ISequentialInStream> streamTemp = this;
+ RINOK(InitAndSeek());
+ *stream = streamTemp.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"VHD", L"vhd", L".mbr", 0xDC, { 'c', 'o', 'n', 'e', 'c', 't', 'i', 'x', 0, 0 }, 10, false, CreateArc, 0 };
+
+REGISTER_ARC(Vhd)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimHandler.cpp
new file mode 100644
index 000000000..1b8661c9f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimHandler.cpp
@@ -0,0 +1,619 @@
+// WimHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/Defs.h"
+#include "Common/ComTry.h"
+#include "Common/StringToInt.h"
+#include "Common/UTFConvert.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../Common/StreamUtils.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../../../C/CpuArch.h"
+
+#include "WimHandler.h"
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NWim {
+
+#define WIM_DETAILS
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME}
+
+ #ifdef WIM_DETAILS
+ , { NULL, kpidVolume, VT_UI4}
+ , { NULL, kpidOffset, VT_UI8}
+ , { NULL, kpidLinks, VT_UI4}
+ #endif
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidComment, VT_FILETIME},
+ { NULL, kpidIsVolume, VT_BOOL},
+ { NULL, kpidVolume, VT_UI4},
+ { NULL, kpidNumVolumes, VT_UI4}
+};
+
+static bool ParseNumber64(const AString &s, UInt64 &res)
+{
+ const char *end;
+ if (s.Left(2) == "0x")
+ {
+ if (s.Length() == 2)
+ return false;
+ res = ConvertHexStringToUInt64((const char *)s + 2, &end);
+ }
+ else
+ {
+ if (s.IsEmpty())
+ return false;
+ res = ConvertStringToUInt64(s, &end);
+ }
+ return *end == 0;
+}
+
+static bool ParseNumber32(const AString &s, UInt32 &res)
+{
+ UInt64 res64;
+ if (!ParseNumber64(s, res64) || res64 >= ((UInt64)1 << 32))
+ return false;
+ res = (UInt32)res64;
+ return true;
+}
+
+void ParseTime(const CXmlItem &item, bool &defined, FILETIME &ft, const AString &s)
+{
+ defined = false;
+ int cTimeIndex = item.FindSubTag(s);
+ if (cTimeIndex >= 0)
+ {
+ const CXmlItem &timeItem = item.SubItems[cTimeIndex];
+ UInt32 high = 0, low = 0;
+ if (ParseNumber32(timeItem.GetSubStringForTag("HIGHPART"), high) &&
+ ParseNumber32(timeItem.GetSubStringForTag("LOWPART"), low))
+ {
+ defined = true;
+ ft.dwHighDateTime = high;
+ ft.dwLowDateTime = low;
+ }
+ }
+}
+
+void CImageInfo::Parse(const CXmlItem &item)
+{
+ ParseTime(item, CTimeDefined, CTime, "CREATIONTIME");
+ ParseTime(item, MTimeDefined, MTime, "LASTMODIFICATIONTIME");
+ NameDefined = ConvertUTF8ToUnicode(item.GetSubStringForTag("NAME"), Name);
+ // IndexDefined = ParseNumber32(item.GetPropertyValue("INDEX"), Index);
+}
+
+void CXml::Parse()
+{
+ size_t size = Data.GetCapacity();
+ if (size < 2 || (size & 1) != 0 || (size > 1 << 24))
+ return;
+ const Byte *p = Data;
+ if (Get16(p) != 0xFEFF)
+ return;
+ UString s;
+ {
+ wchar_t *chars = s.GetBuffer((int)size / 2 + 1);
+ for (size_t i = 2; i < size; i += 2)
+ *chars++ = (wchar_t)Get16(p + i);
+ *chars = 0;
+ s.ReleaseBuffer();
+ }
+
+ AString utf;
+ if (!ConvertUnicodeToUTF8(s, utf))
+ return;
+ ::CXml xml;
+ if (!xml.Parse(utf))
+ return;
+ if (xml.Root.Name != "WIM")
+ return;
+
+ for (int i = 0; i < xml.Root.SubItems.Size(); i++)
+ {
+ const CXmlItem &item = xml.Root.SubItems[i];
+ if (item.IsTagged("IMAGE"))
+ {
+ CImageInfo imageInfo;
+ imageInfo.Parse(item);
+ Images.Add(imageInfo);
+ }
+ }
+}
+
+static const wchar_t *kStreamsNamePrefix = L"Files" WSTRING_PATH_SEPARATOR;
+static const wchar_t *kMethodLZX = L"LZX";
+static const wchar_t *kMethodXpress = L"XPress";
+static const wchar_t *kMethodCopy = L"Copy";
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+
+ const CImageInfo *image = NULL;
+ if (m_Xmls.Size() == 1)
+ {
+ const CXml &xml = m_Xmls[0];
+ if (xml.Images.Size() == 1)
+ image = &xml.Images[0];
+ }
+
+ switch(propID)
+ {
+ case kpidSize: prop = m_Database.GetUnpackSize(); break;
+ case kpidPackSize: prop = m_Database.GetPackSize(); break;
+
+ case kpidCTime:
+ if (m_Xmls.Size() == 1)
+ {
+ const CXml &xml = m_Xmls[0];
+ int index = -1;
+ for (int i = 0; i < xml.Images.Size(); i++)
+ {
+ const CImageInfo &image = xml.Images[i];
+ if (image.CTimeDefined)
+ if (index < 0 || ::CompareFileTime(&image.CTime, &xml.Images[index].CTime) < 0)
+ index = i;
+ }
+ if (index >= 0)
+ prop = xml.Images[index].CTime;
+ }
+ break;
+
+ case kpidMTime:
+ if (m_Xmls.Size() == 1)
+ {
+ const CXml &xml = m_Xmls[0];
+ int index = -1;
+ for (int i = 0; i < xml.Images.Size(); i++)
+ {
+ const CImageInfo &image = xml.Images[i];
+ if (image.MTimeDefined)
+ if (index < 0 || ::CompareFileTime(&image.MTime, &xml.Images[index].MTime) > 0)
+ index = i;
+ }
+ if (index >= 0)
+ prop = xml.Images[index].MTime;
+ }
+ break;
+
+ case kpidComment: if (image != NULL && image->NameDefined) prop = image->Name; break;
+
+ case kpidIsVolume:
+ if (m_Xmls.Size() > 0)
+ {
+ UInt16 volIndex = m_Xmls[0].VolIndex;
+ if (volIndex < m_Volumes.Size())
+ prop = (m_Volumes[volIndex].Header.NumParts > 1);
+ }
+ break;
+ case kpidVolume:
+ if (m_Xmls.Size() > 0)
+ {
+ UInt16 volIndex = m_Xmls[0].VolIndex;
+ if (volIndex < m_Volumes.Size())
+ prop = (UInt32)m_Volumes[volIndex].Header.PartNumber;
+ }
+ break;
+ case kpidNumVolumes: if (m_Volumes.Size() > 0) prop = (UInt32)(m_Volumes.Size() - 1); break;
+ case kpidMethod:
+ {
+ bool lzx = false, xpress = false, copy = false;
+ for (int i = 0; i < m_Xmls.Size(); i++)
+ {
+ const CVolume &vol = m_Volumes[m_Xmls[i].VolIndex];
+ const CHeader &header = vol.Header;
+ if (header.IsCompressed())
+ if (header.IsLzxMode())
+ lzx = true;
+ else
+ xpress = true;
+ else
+ copy = true;
+ }
+ UString res;
+ if (lzx)
+ res = kMethodLZX;
+ if (xpress)
+ {
+ if (!res.IsEmpty())
+ res += L' ';
+ res += kMethodXpress;
+ }
+ if (copy)
+ {
+ if (!res.IsEmpty())
+ res += L' ';
+ res += kMethodCopy;
+ }
+ prop = res;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ if (index < (UInt32)m_Database.Items.Size())
+ {
+ const CItem &item = m_Database.Items[index];
+ const CStreamInfo *si = NULL;
+ const CVolume *vol = NULL;
+ if (item.StreamIndex >= 0)
+ {
+ si = &m_Database.Streams[item.StreamIndex];
+ vol = &m_Volumes[si->PartNumber];
+ }
+
+ switch(propID)
+ {
+ case kpidPath:
+ if (item.HasMetadata)
+ prop = item.Name;
+ else
+ {
+ wchar_t sz[32];
+ ConvertUInt64ToString(item.StreamIndex, sz);
+ UString s = sz;
+ while (s.Length() < m_NameLenForStreams)
+ s = L'0' + s;
+ s = UString(kStreamsNamePrefix) + s;
+ prop = s;
+ break;
+ }
+ break;
+ case kpidIsDir: prop = item.isDir(); break;
+ case kpidAttrib: if (item.HasMetadata) prop = item.Attrib; break;
+ case kpidCTime: if (item.HasMetadata) prop = item.CTime; break;
+ case kpidATime: if (item.HasMetadata) prop = item.ATime; break;
+ case kpidMTime: if (item.HasMetadata) prop = item.MTime; break;
+ case kpidPackSize: prop = si ? si->Resource.PackSize : (UInt64)0; break;
+ case kpidSize: prop = si ? si->Resource.UnpackSize : (UInt64)0; break;
+ case kpidMethod: if (si) prop = si->Resource.IsCompressed() ?
+ (vol->Header.IsLzxMode() ? kMethodLZX : kMethodXpress) : kMethodCopy; break;
+ #ifdef WIM_DETAILS
+ case kpidVolume: if (si) prop = (UInt32)si->PartNumber; break;
+ case kpidOffset: if (si) prop = (UInt64)si->Resource.Offset; break;
+ case kpidLinks: prop = si ? (UInt32)si->RefCount : (UInt32)0; break;
+ #endif
+ }
+ }
+ else
+ {
+ index -= m_Database.Items.Size();
+ {
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ wchar_t sz[32];
+ ConvertUInt64ToString(m_Xmls[index].VolIndex, sz);
+ UString s = (UString)sz + L".xml";
+ prop = s;
+ break;
+ }
+ case kpidIsDir: prop = false; break;
+ case kpidPackSize:
+ case kpidSize: prop = (UInt64)m_Xmls[index].Data.GetCapacity(); break;
+ case kpidMethod: prop = L"Copy"; break;
+ }
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CVolumeName
+{
+ // UInt32 _volIndex;
+ UString _before;
+ UString _after;
+public:
+ CVolumeName() {};
+
+ void InitName(const UString &name)
+ {
+ // _volIndex = 1;
+ int dotPos = name.ReverseFind('.');
+ if (dotPos < 0)
+ dotPos = name.Length();
+ _before = name.Left(dotPos);
+ _after = name.Mid(dotPos);
+ }
+
+ UString GetNextName(UInt32 index)
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString((index), s);
+ return _before + (UString)s + _after;
+ }
+};
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ Close();
+ try
+ {
+ CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
+
+ CVolumeName seqName;
+ if (openArchiveCallback != NULL)
+ openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
+
+ UInt32 numVolumes = 1;
+ int firstVolumeIndex = -1;
+ for (UInt32 i = 1; i <= numVolumes; i++)
+ {
+ CMyComPtr<IInStream> curStream;
+ if (i != 1)
+ {
+ UString fullName = seqName.GetNextName(i);
+ HRESULT result = openVolumeCallback->GetStream(fullName, &curStream);
+ if (result == S_FALSE)
+ continue;
+ if (result != S_OK)
+ return result;
+ if (!curStream)
+ break;
+ }
+ else
+ curStream = inStream;
+ CHeader header;
+ HRESULT res = NWim::ReadHeader(curStream, header);
+ if (res != S_OK)
+ {
+ if (i == 1)
+ return res;
+ if (res == S_FALSE)
+ continue;
+ return res;
+ }
+ if (firstVolumeIndex >= 0)
+ if (!header.AreFromOnArchive(m_Volumes[firstVolumeIndex].Header))
+ break;
+ if (m_Volumes.Size() > header.PartNumber && m_Volumes[header.PartNumber].Stream)
+ break;
+ CXml xml;
+ xml.VolIndex = header.PartNumber;
+ res = OpenArchive(curStream, header, xml.Data, m_Database);
+ if (res != S_OK)
+ {
+ if (i == 1)
+ return res;
+ if (res == S_FALSE)
+ continue;
+ return res;
+ }
+
+ while (m_Volumes.Size() <= header.PartNumber)
+ m_Volumes.Add(CVolume());
+ CVolume &volume = m_Volumes[header.PartNumber];
+ volume.Header = header;
+ volume.Stream = curStream;
+
+ firstVolumeIndex = header.PartNumber;
+
+ bool needAddXml = true;
+ if (m_Xmls.Size() != 0)
+ if (xml.Data == m_Xmls[0].Data)
+ needAddXml = false;
+ if (needAddXml)
+ {
+ xml.Parse();
+ m_Xmls.Add(xml);
+ }
+
+ if (i == 1)
+ {
+ if (header.PartNumber != 1)
+ break;
+ if (!openVolumeCallback)
+ break;
+ numVolumes = header.NumParts;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
+ if (prop.vt != VT_BSTR)
+ break;
+ seqName.InitName(prop.bstrVal);
+ }
+ }
+ }
+
+ RINOK(SortDatabase(m_Database));
+
+ wchar_t sz[32];
+ ConvertUInt64ToString(m_Database.Streams.Size(), sz);
+ m_NameLenForStreams = MyStringLen(sz);
+ }
+ catch(...)
+ {
+ return S_FALSE;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ m_Database.Clear();
+ m_Volumes.Clear();
+ m_Xmls.Clear();
+ m_NameLenForStreams = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == UInt32(-1));
+
+ if (allFilesMode)
+ numItems = m_Database.Items.Size() + m_Xmls.Size();
+ if (numItems == 0)
+ return S_OK;
+ bool testMode = (_aTestMode != 0);
+
+ UInt32 i;
+ UInt64 totalSize = 0;
+ for (i = 0; i < numItems; i++)
+ {
+ UInt32 index = allFilesMode ? i : indices[i];
+ if (index < (UInt32)m_Database.Items.Size())
+ {
+ int streamIndex = m_Database.Items[index].StreamIndex;
+ if (streamIndex >= 0)
+ {
+ const CStreamInfo &si = m_Database.Streams[streamIndex];
+ totalSize += si.Resource.UnpackSize;
+ }
+ }
+ else
+ totalSize += m_Xmls[index - (UInt32)m_Database.Items.Size()].Data.GetCapacity();
+ }
+
+ RINOK(extractCallback->SetTotal(totalSize));
+
+ UInt64 currentTotalPacked = 0;
+ UInt64 currentTotalUnPacked = 0;
+ UInt64 currentItemUnPacked, currentItemPacked;
+
+ int prevSuccessStreamIndex = -1;
+
+ CUnpacker unpacker;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ for (i = 0; i < numItems; currentTotalUnPacked += currentItemUnPacked,
+ currentTotalPacked += currentItemPacked)
+ {
+ currentItemUnPacked = 0;
+ currentItemPacked = 0;
+
+ lps->InSize = currentTotalPacked;
+ lps->OutSize = currentTotalUnPacked;
+
+ RINOK(lps->SetCur());
+ UInt32 index = allFilesMode ? i : indices[i];
+ i++;
+ Int32 askMode = testMode ?
+ NExtract::NAskMode::kTest :
+ NExtract::NAskMode::kExtract;
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ if (index >= (UInt32)m_Database.Items.Size())
+ {
+ if(!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ const CByteBuffer &data = m_Xmls[index - (UInt32)m_Database.Items.Size()].Data;
+ currentItemUnPacked = data.GetCapacity();
+ if (realOutStream)
+ {
+ RINOK(WriteStream(realOutStream, (const Byte *)data, data.GetCapacity()));
+ realOutStream.Release();
+ }
+ RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
+ continue;
+ }
+
+ const CItem &item = m_Database.Items[index];
+ int streamIndex = item.StreamIndex;
+ if (streamIndex < 0)
+ {
+ if(!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(item.HasStream() ?
+ NExtract::NOperationResult::kDataError :
+ NExtract::NOperationResult::kOK));
+ continue;
+ }
+
+ const CStreamInfo &si = m_Database.Streams[streamIndex];
+ currentItemUnPacked = si.Resource.UnpackSize;
+ currentItemPacked = si.Resource.PackSize;
+
+ if(!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ Int32 opRes = NExtract::NOperationResult::kOK;
+ if (streamIndex != prevSuccessStreamIndex || realOutStream)
+ {
+ Byte digest[20];
+ const CVolume &vol = m_Volumes[si.PartNumber];
+ HRESULT res = unpacker.Unpack(vol.Stream, si.Resource, vol.Header.IsLzxMode(),
+ realOutStream, progress, digest);
+ if (res == S_OK)
+ {
+ if (memcmp(digest, si.Hash, kHashSize) == 0)
+ prevSuccessStreamIndex = streamIndex;
+ else
+ opRes = NExtract::NOperationResult::kCRCError;
+ }
+ else if (res == S_FALSE)
+ opRes = NExtract::NOperationResult::kDataError;
+ else
+ return res;
+ }
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = m_Database.Items.Size() + m_Xmls.Size();
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimHandler.h
new file mode 100644
index 000000000..b7df36067
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimHandler.h
@@ -0,0 +1,66 @@
+// WimHandler.h
+
+#ifndef __ARCHIVE_WIM_HANDLER_H
+#define __ARCHIVE_WIM_HANDLER_H
+
+#include "Common/MyCom.h"
+#include "Common/MyXml.h"
+
+#include "../IArchive.h"
+#include "WimIn.h"
+
+namespace NArchive {
+namespace NWim {
+
+struct CVolume
+{
+ CHeader Header;
+ CMyComPtr<IInStream> Stream;
+};
+
+struct CImageInfo
+{
+ bool CTimeDefined;
+ bool MTimeDefined;
+ bool NameDefined;
+ // bool IndexDefined;
+
+ FILETIME CTime;
+ FILETIME MTime;
+ UString Name;
+ // UInt32 Index;
+
+ CImageInfo(): CTimeDefined(false), MTimeDefined(false), NameDefined(false)
+ // , IndexDefined(false)
+ {}
+ void Parse(const CXmlItem &item);
+};
+
+struct CXml
+{
+ CByteBuffer Data;
+ UInt16 VolIndex;
+
+ CObjectVector<CImageInfo> Images;
+
+ void Parse();
+};
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+
+private:
+ CDatabase m_Database;
+ CObjectVector<CVolume> m_Volumes;
+ CObjectVector<CXml> m_Xmls;
+ int m_NameLenForStreams;
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimIn.cpp
new file mode 100644
index 000000000..90c3c2c2f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimIn.cpp
@@ -0,0 +1,570 @@
+// Archive/WimIn.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/CpuArch.h"
+
+#include "Common/IntToString.h"
+
+#include "../../Common/StreamUtils.h"
+#include "../../Common/StreamObjects.h"
+#include "../../Common/LimitedStreams.h"
+
+#include "../Common/OutStreamWithSha1.h"
+
+#include "WimIn.h"
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+namespace NArchive{
+namespace NWim{
+
+static const int kChunkSizeBits = 15;
+static const UInt32 kChunkSize = (1 << kChunkSizeBits);
+
+namespace NXpress {
+
+class CDecoderFlusher
+{
+ CDecoder *m_Decoder;
+public:
+ bool NeedFlush;
+ CDecoderFlusher(CDecoder *decoder): m_Decoder(decoder), NeedFlush(true) {}
+ ~CDecoderFlusher()
+ {
+ if (NeedFlush)
+ m_Decoder->Flush();
+ m_Decoder->ReleaseStreams();
+ }
+};
+
+HRESULT CDecoder::CodeSpec(UInt32 outSize)
+{
+ {
+ Byte levels[kMainTableSize];
+ for (int i = 0; i < kMainTableSize; i += 2)
+ {
+ Byte b = m_InBitStream.DirectReadByte();
+ levels[i] = b & 0xF;
+ levels[i + 1] = b >> 4;
+ }
+ if (!m_MainDecoder.SetCodeLengths(levels))
+ return S_FALSE;
+ }
+
+ while (outSize > 0)
+ {
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < 256)
+ {
+ m_OutWindowStream.PutByte((Byte)number);
+ outSize--;
+ }
+ else
+ {
+ if (number >= kMainTableSize)
+ return S_FALSE;
+ UInt32 posLenSlot = number - 256;
+ UInt32 posSlot = posLenSlot / kNumLenSlots;
+ UInt32 len = posLenSlot % kNumLenSlots;
+ UInt32 distance = (1 << posSlot) - 1 + m_InBitStream.ReadBits(posSlot);
+
+ if (len == kNumLenSlots - 1)
+ {
+ len = m_InBitStream.DirectReadByte();
+ if (len == 0xFF)
+ {
+ len = m_InBitStream.DirectReadByte();
+ len |= (UInt32)m_InBitStream.DirectReadByte() << 8;
+ }
+ else
+ len += kNumLenSlots - 1;
+ }
+
+ len += kMatchMinLen;
+ UInt32 locLen = (len <= outSize ? len : outSize);
+
+ if (!m_OutWindowStream.CopyBlock(distance, locLen))
+ return S_FALSE;
+
+ len -= locLen;
+ outSize -= locLen;
+ if (len != 0)
+ return S_FALSE;
+ }
+ }
+ return S_OK;
+}
+
+const UInt32 kDictSize = (1 << kNumPosSlots);
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize)
+{
+ if (!m_OutWindowStream.Create(kDictSize) || !m_InBitStream.Create(1 << 16))
+ return E_OUTOFMEMORY;
+
+ CDecoderFlusher flusher(this);
+
+ m_InBitStream.SetStream(inStream);
+ m_OutWindowStream.SetStream(outStream);
+ m_InBitStream.Init();
+ m_OutWindowStream.Init(false);
+
+ RINOK(CodeSpec(outSize));
+
+ flusher.NeedFlush = false;
+ return Flush();
+}
+
+HRESULT CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize)
+{
+ try { return CodeReal(inStream, outStream, outSize); }
+ catch(const CInBufferException &e) { return e.ErrorCode; } \
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+}
+
+static void GetFileTimeFromMem(const Byte *p, FILETIME *ft)
+{
+ ft->dwLowDateTime = Get32(p);
+ ft->dwHighDateTime = Get32(p + 4);
+}
+
+HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, bool lzxMode,
+ ISequentialOutStream *outStream, ICompressProgressInfo *progress)
+{
+ RINOK(inStream->Seek(resource.Offset, STREAM_SEEK_SET, NULL));
+
+ CLimitedSequentialInStream *limitedStreamSpec = new CLimitedSequentialInStream();
+ CMyComPtr<ISequentialInStream> limitedStream = limitedStreamSpec;
+ limitedStreamSpec->SetStream(inStream);
+
+ if (!copyCoder)
+ {
+ copyCoderSpec = new NCompress::CCopyCoder;
+ copyCoder = copyCoderSpec;
+ }
+ if (!resource.IsCompressed())
+ {
+ if (resource.PackSize != resource.UnpackSize)
+ return S_FALSE;
+ limitedStreamSpec->Init(resource.PackSize);
+ return copyCoder->Code(limitedStreamSpec, outStream, NULL, NULL, progress);
+ }
+ if (resource.UnpackSize == 0)
+ return S_OK;
+ UInt64 numChunks = (resource.UnpackSize + kChunkSize - 1) >> kChunkSizeBits;
+ unsigned entrySize = ((resource.UnpackSize > (UInt64)1 << 32) ? 8 : 4);
+ UInt64 sizesBufSize64 = entrySize * (numChunks - 1);
+ size_t sizesBufSize = (size_t)sizesBufSize64;
+ if (sizesBufSize != sizesBufSize64)
+ return E_OUTOFMEMORY;
+ if (sizesBufSize > sizesBuf.GetCapacity())
+ {
+ sizesBuf.Free();
+ sizesBuf.SetCapacity(sizesBufSize);
+ }
+ RINOK(ReadStream_FALSE(inStream, (Byte *)sizesBuf, sizesBufSize));
+ const Byte *p = (const Byte *)sizesBuf;
+
+ if (lzxMode && !lzxDecoder)
+ {
+ lzxDecoderSpec = new NCompress::NLzx::CDecoder(true);
+ lzxDecoder = lzxDecoderSpec;
+ RINOK(lzxDecoderSpec->SetParams(kChunkSizeBits));
+ }
+
+ UInt64 baseOffset = resource.Offset + sizesBufSize64;
+ UInt64 outProcessed = 0;
+ for (UInt32 i = 0; i < (UInt32)numChunks; i++)
+ {
+ UInt64 offset = 0;
+ if (i > 0)
+ {
+ offset = (entrySize == 4) ? Get32(p): Get64(p);
+ p += entrySize;
+ }
+ UInt64 nextOffset = resource.PackSize - sizesBufSize64;
+ if (i + 1 < (UInt32)numChunks)
+ nextOffset = (entrySize == 4) ? Get32(p): Get64(p);
+ if (nextOffset < offset)
+ return S_FALSE;
+
+ RINOK(inStream->Seek(baseOffset + offset, STREAM_SEEK_SET, NULL));
+ UInt64 inSize = nextOffset - offset;
+ limitedStreamSpec->Init(inSize);
+
+ if (progress)
+ {
+ RINOK(progress->SetRatioInfo(&offset, &outProcessed));
+ }
+
+ UInt32 outSize = kChunkSize;
+ if (outProcessed + outSize > resource.UnpackSize)
+ outSize = (UInt32)(resource.UnpackSize - outProcessed);
+ UInt64 outSize64 = outSize;
+ if (inSize == outSize)
+ {
+ RINOK(copyCoder->Code(limitedStreamSpec, outStream, NULL, &outSize64, NULL));
+ }
+ else
+ {
+ if (lzxMode)
+ {
+ lzxDecoderSpec->SetKeepHistory(false);
+ RINOK(lzxDecoder->Code(limitedStreamSpec, outStream, NULL, &outSize64, NULL));
+ }
+ else
+ {
+ RINOK(xpressDecoder.Code(limitedStreamSpec, outStream, outSize));
+ }
+ }
+ outProcessed += outSize;
+ }
+ return S_OK;
+}
+
+HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, bool lzxMode,
+ ISequentialOutStream *outStream, ICompressProgressInfo *progress, Byte *digest)
+{
+ COutStreamWithSha1 *shaStreamSpec = new COutStreamWithSha1();
+ CMyComPtr<ISequentialOutStream> shaStream = shaStreamSpec;
+ shaStreamSpec->SetStream(outStream);
+ shaStreamSpec->Init(digest != NULL);
+ HRESULT result = Unpack(inStream, resource, lzxMode, shaStream, progress);
+ if (digest)
+ shaStreamSpec->Final(digest);
+ return result;
+}
+
+static HRESULT UnpackData(IInStream *inStream, const CResource &resource, bool lzxMode, CByteBuffer &buf, Byte *digest)
+{
+ size_t size = (size_t)resource.UnpackSize;
+ if (size != resource.UnpackSize)
+ return E_OUTOFMEMORY;
+ buf.Free();
+ buf.SetCapacity(size);
+
+ CSequentialOutStreamImp2 *outStreamSpec = new CSequentialOutStreamImp2();
+ CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
+ outStreamSpec->Init((Byte *)buf, size);
+
+ CUnpacker unpacker;
+ return unpacker.Unpack(inStream, resource, lzxMode, outStream, NULL, digest);
+}
+
+static const UInt32 kSignatureSize = 8;
+static const Byte kSignature[kSignatureSize] = { 'M', 'S', 'W', 'I', 'M', 0, 0, 0 };
+
+void CResource::Parse(const Byte *p)
+{
+ Flags = p[7];
+ PackSize = Get64(p) & (((UInt64)1 << 56) - 1);
+ Offset = Get64(p + 8);
+ UnpackSize = Get64(p + 16);
+}
+
+#define GetResource(p, res) res.Parse(p)
+
+static void GetStream(const Byte *p, CStreamInfo &s)
+{
+ s.Resource.Parse(p);
+ s.PartNumber = Get16(p + 24);
+ s.RefCount = Get32(p + 26);
+ memcpy(s.Hash, p + 30, kHashSize);
+}
+
+static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size,
+ const UString &prefix, CObjectVector<CItem> &items)
+{
+ for (;;)
+ {
+ if (pos + 8 > size)
+ return S_FALSE;
+ const Byte *p = base + pos;
+ UInt64 length = Get64(p);
+ if (length == 0)
+ return S_OK;
+ if (pos + 102 > size || pos + length + 8 > size || length > ((UInt64)1 << 62))
+ return S_FALSE;
+ CItem item;
+ item.Attrib = Get32(p + 8);
+ // item.SecurityId = Get32(p + 0xC);
+ UInt64 subdirOffset = Get64(p + 0x10);
+ GetFileTimeFromMem(p + 0x28, &item.CTime);
+ GetFileTimeFromMem(p + 0x30, &item.ATime);
+ GetFileTimeFromMem(p + 0x38, &item.MTime);
+ memcpy(item.Hash, p + 0x40, kHashSize);
+
+ // UInt16 shortNameLen = Get16(p + 98);
+ UInt16 fileNameLen = Get16(p + 100);
+
+ size_t tempPos = pos + 102;
+ if (tempPos + fileNameLen > size)
+ return S_FALSE;
+
+ wchar_t *sz = item.Name.GetBuffer(prefix.Length() + fileNameLen / 2 + 1);
+ MyStringCopy(sz, (const wchar_t *)prefix);
+ sz += prefix.Length();
+ for (UInt16 i = 0; i + 2 <= fileNameLen; i += 2)
+ *sz++ = Get16(base + tempPos + i);
+ *sz++ = '\0';
+ item.Name.ReleaseBuffer();
+ if (fileNameLen == 0 && item.isDir() && !item.HasStream())
+ {
+ item.Attrib = 0x10; // some swm archives have system/hidden attributes for root
+ item.Name.Delete(item.Name.Length() - 1);
+ }
+ items.Add(item);
+ pos += (size_t)length;
+ if (item.isDir() && (subdirOffset != 0))
+ {
+ if (subdirOffset >= size)
+ return S_FALSE;
+ RINOK(ParseDirItem(base, (size_t)subdirOffset, size, item.Name + WCHAR_PATH_SEPARATOR, items));
+ }
+ }
+}
+
+static HRESULT ParseDir(const Byte *base, size_t size,
+ const UString &prefix, CObjectVector<CItem> &items)
+{
+ size_t pos = 0;
+ if (pos + 8 > size)
+ return S_FALSE;
+ const Byte *p = base + pos;
+ UInt32 totalLength = Get32(p);
+ // UInt32 numEntries = Get32(p + 4);
+ pos += 8;
+ {
+ /*
+ CRecordVector<UInt64> entryLens;
+ UInt64 sum = 0;
+ for (UInt32 i = 0; i < numEntries; i++)
+ {
+ if (pos + 8 > size)
+ return S_FALSE;
+ UInt64 len = Get64(p + pos);
+ entryLens.Add(len);
+ sum += len;
+ pos += 8;
+ }
+ pos += sum; // skip security descriptors
+ while ((pos & 7) != 0)
+ pos++;
+ if (pos != totalLength)
+ return S_FALSE;
+ */
+ pos = totalLength;
+ }
+ return ParseDirItem(base, pos, size, prefix, items);
+}
+
+static int CompareHashRefs(const int *p1, const int *p2, void *param)
+{
+ const CRecordVector<CStreamInfo> &streams = *(const CRecordVector<CStreamInfo> *)param;
+ return memcmp(streams[*p1].Hash, streams[*p2].Hash, kHashSize);
+}
+
+static int CompareStreamsByPos(const CStreamInfo *p1, const CStreamInfo *p2, void * /* param */)
+{
+ int res = MyCompare(p1->PartNumber, p2->PartNumber);
+ if (res != 0)
+ return res;
+ return MyCompare(p1->Resource.Offset, p2->Resource.Offset);
+}
+
+int CompareItems(void *const *a1, void *const *a2, void * /* param */)
+{
+ const CItem &i1 = **((const CItem **)a1);
+ const CItem &i2 = **((const CItem **)a2);
+
+ if (i1.isDir() != i2.isDir())
+ return (i1.isDir()) ? 1 : -1;
+ if (i1.isDir())
+ return -MyStringCompareNoCase(i1.Name, i2.Name);
+
+ int res = MyCompare(i1.StreamIndex, i2.StreamIndex);
+ if (res != 0)
+ return res;
+ return MyStringCompareNoCase(i1.Name, i2.Name);
+}
+
+static int FindHash(const CRecordVector<CStreamInfo> &streams,
+ const CRecordVector<int> &sortedByHash, const Byte *hash)
+{
+ int left = 0, right = streams.Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ int streamIndex = sortedByHash[mid];
+ UInt32 i;
+ const Byte *hash2 = streams[streamIndex].Hash;
+ for (i = 0; i < kHashSize; i++)
+ if (hash[i] != hash2[i])
+ break;
+ if (i == kHashSize)
+ return streamIndex;
+ if (hash[i] < hash2[i])
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ return -1;
+}
+
+HRESULT CHeader::Parse(const Byte *p)
+{
+ UInt32 haderSize = Get32(p + 8);
+ if (haderSize < 0x74)
+ return S_FALSE;
+ Version = Get32(p + 0x0C);
+ Flags = Get32(p + 0x10);
+ if (!IsSupported())
+ return S_FALSE;
+ UInt32 chunkSize = Get32(p + 0x14);
+ if (chunkSize != kChunkSize && chunkSize != 0)
+ return S_FALSE;
+ memcpy(Guid, p + 0x18, 16);
+ PartNumber = Get16(p + 0x28);
+ NumParts = Get16(p + 0x2A);
+ int offset = 0x2C;
+ if (IsNewVersion())
+ {
+ NumImages = Get32(p + offset);
+ offset += 4;
+ }
+ GetResource(p + offset, OffsetResource);
+ GetResource(p + offset + 0x18, XmlResource);
+ GetResource(p + offset + 0x30, MetadataResource);
+ /*
+ if (IsNewVersion())
+ {
+ if (haderSize < 0xD0)
+ return S_FALSE;
+ IntegrityResource.Parse(p + offset + 0x4C);
+ BootIndex = Get32(p + 0x48);
+ }
+ */
+ return S_OK;
+}
+
+HRESULT ReadHeader(IInStream *inStream, CHeader &h)
+{
+ const UInt32 kHeaderSizeMax = 0xD0;
+ Byte p[kHeaderSizeMax];
+ RINOK(ReadStream_FALSE(inStream, p, kHeaderSizeMax));
+ if (memcmp(p, kSignature, kSignatureSize) != 0)
+ return S_FALSE;
+ return h.Parse(p);
+}
+
+HRESULT ReadStreams(IInStream *inStream, const CHeader &h, CDatabase &db)
+{
+ CByteBuffer offsetBuf;
+ RINOK(UnpackData(inStream, h.OffsetResource, h.IsLzxMode(), offsetBuf, NULL));
+ for (size_t i = 0; i + kStreamInfoSize <= offsetBuf.GetCapacity(); i += kStreamInfoSize)
+ {
+ CStreamInfo s;
+ GetStream((const Byte *)offsetBuf + i, s);
+ if (s.PartNumber == h.PartNumber)
+ db.Streams.Add(s);
+ }
+ return S_OK;
+}
+
+HRESULT OpenArchive(IInStream *inStream, const CHeader &h, CByteBuffer &xml, CDatabase &db)
+{
+ RINOK(UnpackData(inStream, h.XmlResource, h.IsLzxMode(), xml, NULL));
+
+ RINOK(ReadStreams(inStream, h, db));
+ bool needBootMetadata = !h.MetadataResource.IsEmpty();
+ if (h.PartNumber == 1)
+ {
+ int imageIndex = 1;
+ for (int j = 0; j < db.Streams.Size(); j++)
+ {
+ // if (imageIndex > 1) break;
+ const CStreamInfo &si = db.Streams[j];
+ if (!si.Resource.IsMetadata() || si.PartNumber != h.PartNumber)
+ continue;
+ Byte hash[kHashSize];
+ CByteBuffer metadata;
+ RINOK(UnpackData(inStream, si.Resource, h.IsLzxMode(), metadata, hash));
+ if (memcmp(hash, si.Hash, kHashSize) != 0)
+ return S_FALSE;
+ wchar_t sz[16];
+ ConvertUInt32ToString(imageIndex++, sz);
+ UString s = sz;
+ s += WCHAR_PATH_SEPARATOR;
+ RINOK(ParseDir(metadata, metadata.GetCapacity(), s, db.Items));
+ if (needBootMetadata)
+ if (h.MetadataResource.Offset == si.Resource.Offset)
+ needBootMetadata = false;
+ }
+ }
+
+ if (needBootMetadata)
+ {
+ CByteBuffer metadata;
+ RINOK(UnpackData(inStream, h.MetadataResource, h.IsLzxMode(), metadata, NULL));
+ RINOK(ParseDir(metadata, metadata.GetCapacity(), L"0" WSTRING_PATH_SEPARATOR, db.Items));
+ }
+ return S_OK;
+}
+
+
+HRESULT SortDatabase(CDatabase &db)
+{
+ db.Streams.Sort(CompareStreamsByPos, NULL);
+
+ {
+ CRecordVector<int> sortedByHash;
+ {
+ for (int j = 0; j < db.Streams.Size(); j++)
+ sortedByHash.Add(j);
+ sortedByHash.Sort(CompareHashRefs, &db.Streams);
+ }
+
+ for (int i = 0; i < db.Items.Size(); i++)
+ {
+ CItem &item = db.Items[i];
+ item.StreamIndex = -1;
+ if (item.HasStream())
+ item.StreamIndex = FindHash(db.Streams, sortedByHash, item.Hash);
+ }
+ }
+
+ {
+ CRecordVector<bool> used;
+ int j;
+ for (j = 0; j < db.Streams.Size(); j++)
+ {
+ const CStreamInfo &s = db.Streams[j];
+ used.Add(s.Resource.IsMetadata() && s.PartNumber == 1);
+ }
+ for (int i = 0; i < db.Items.Size(); i++)
+ {
+ CItem &item = db.Items[i];
+ if (item.StreamIndex >= 0)
+ used[item.StreamIndex] = true;
+ }
+ for (j = 0; j < db.Streams.Size(); j++)
+ if (!used[j])
+ {
+ CItem item;
+ item.StreamIndex = j;
+ item.HasMetadata = false;
+ db.Items.Add(item);
+ }
+ }
+
+ db.Items.Sort(CompareItems, NULL);
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimIn.h
new file mode 100644
index 000000000..e51a301aa
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimIn.h
@@ -0,0 +1,235 @@
+// Archive/WimIn.h
+
+#ifndef __ARCHIVE_WIM_IN_H
+#define __ARCHIVE_WIM_IN_H
+
+#include "Common/Buffer.h"
+#include "Common/MyString.h"
+
+#include "../../Compress/CopyCoder.h"
+#include "../../Compress/LzxDecoder.h"
+
+namespace NArchive {
+namespace NWim {
+
+namespace NXpress {
+
+class CBitStream
+{
+ CInBuffer m_Stream;
+ UInt32 m_Value;
+ unsigned m_BitPos;
+public:
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+ void SetStream(ISequentialInStream *s) { m_Stream.SetStream(s); }
+ void ReleaseStream() { m_Stream.ReleaseStream(); }
+
+ void Init() { m_Stream.Init(); m_BitPos = 0; }
+ // UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() - m_BitPos / 8; }
+ Byte DirectReadByte() { return m_Stream.ReadByte(); }
+
+ void Normalize()
+ {
+ if (m_BitPos < 16)
+ {
+ Byte b0 = m_Stream.ReadByte();
+ Byte b1 = m_Stream.ReadByte();
+ m_Value = (m_Value << 8) | b1;
+ m_Value = (m_Value << 8) | b0;
+ m_BitPos += 16;
+ }
+ }
+
+ UInt32 GetValue(unsigned numBits)
+ {
+ Normalize();
+ return (m_Value >> (m_BitPos - numBits)) & ((1 << numBits) - 1);
+ }
+
+ void MovePos(unsigned numBits) { m_BitPos -= numBits; }
+
+ UInt32 ReadBits(unsigned numBits)
+ {
+ UInt32 res = GetValue(numBits);
+ m_BitPos -= numBits;
+ return res;
+ }
+};
+
+const int kNumHuffmanBits = 16;
+const UInt32 kMatchMinLen = 3;
+const UInt32 kNumLenSlots = 16;
+const UInt32 kNumPosSlots = 16;
+const UInt32 kNumPosLenSlots = kNumPosSlots * kNumLenSlots;
+const UInt32 kMainTableSize = 256 + kNumPosLenSlots;
+
+class CDecoder
+{
+ CBitStream m_InBitStream;
+ CLzOutWindow m_OutWindowStream;
+ NCompress::NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
+
+ HRESULT CodeSpec(UInt32 size);
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize);
+public:
+ void ReleaseStreams()
+ {
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ }
+ HRESULT Flush() { return m_OutWindowStream.Flush(); }
+ HRESULT Code(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize);
+};
+
+}
+
+namespace NResourceFlags
+{
+ const Byte Compressed = 4;
+ const Byte kMetadata = 2;
+}
+
+struct CResource
+{
+ UInt64 PackSize;
+ UInt64 Offset;
+ UInt64 UnpackSize;
+ Byte Flags;
+
+ void Parse(const Byte *p);
+ bool IsCompressed() const { return (Flags & NResourceFlags::Compressed) != 0; }
+ bool IsMetadata() const { return (Flags & NResourceFlags::kMetadata) != 0; }
+ bool IsEmpty() const { return (UnpackSize == 0); }
+};
+
+namespace NHeaderFlags
+{
+ const UInt32 kCompression = 2;
+ const UInt32 kSpanned = 8;
+ const UInt32 kRpFix = 0x80;
+ const UInt32 kXPRESS = 0x20000;
+ const UInt32 kLZX = 0x40000;
+}
+
+struct CHeader
+{
+ UInt32 Flags;
+ UInt32 Version;
+ // UInt32 ChunkSize;
+ UInt16 PartNumber;
+ UInt16 NumParts;
+ UInt32 NumImages;
+ Byte Guid[16];
+
+ CResource OffsetResource;
+ CResource XmlResource;
+ CResource MetadataResource;
+ /*
+ CResource IntegrityResource;
+ UInt32 BootIndex;
+ */
+
+ HRESULT Parse(const Byte *p);
+ bool IsCompressed() const { return (Flags & NHeaderFlags::kCompression) != 0; }
+ bool IsSupported() const { return (!IsCompressed() || (Flags & NHeaderFlags::kLZX) != 0 || (Flags & NHeaderFlags::kXPRESS) != 0 ) ; }
+ bool IsLzxMode() const { return (Flags & NHeaderFlags::kLZX) != 0; }
+ bool IsSpanned() const { return (!IsCompressed() || (Flags & NHeaderFlags::kSpanned) != 0); }
+
+ bool IsNewVersion()const { return (Version > 0x010C00); }
+
+ bool AreFromOnArchive(const CHeader &h)
+ {
+ return (memcmp(Guid, h.Guid, sizeof(Guid)) == 0) && (h.NumParts == NumParts);
+ }
+};
+
+const UInt32 kHashSize = 20;
+const UInt32 kStreamInfoSize = 24 + 2 + 4 + kHashSize;
+
+struct CStreamInfo
+{
+ CResource Resource;
+ UInt16 PartNumber;
+ UInt32 RefCount;
+ BYTE Hash[kHashSize];
+};
+
+struct CItem
+{
+ UString Name;
+ UInt32 Attrib;
+ // UInt32 SecurityId;
+ BYTE Hash[kHashSize];
+ FILETIME CTime;
+ FILETIME ATime;
+ FILETIME MTime;
+ // UInt32 ReparseTag;
+ // UInt64 HardLink;
+ // UInt16 NumStreams;
+ // UInt16 ShortNameLen;
+ int StreamIndex;
+ bool HasMetadata;
+ CItem(): HasMetadata(true), StreamIndex(-1) {}
+ bool isDir() const { return HasMetadata && ((Attrib & 0x10) != 0); }
+ bool HasStream() const
+ {
+ for (int i = 0; i < kHashSize; i++)
+ if (Hash[i] != 0)
+ return true;
+ return false;
+ }
+};
+
+struct CDatabase
+{
+ CRecordVector<CStreamInfo> Streams;
+ CObjectVector<CItem> Items;
+
+ UInt64 GetUnpackSize() const
+ {
+ UInt64 res = 0;
+ for (int i = 0; i < Streams.Size(); i++)
+ res += Streams[i].Resource.UnpackSize;
+ return res;
+ }
+
+ UInt64 GetPackSize() const
+ {
+ UInt64 res = 0;
+ for (int i = 0; i < Streams.Size(); i++)
+ res += Streams[i].Resource.PackSize;
+ return res;
+ }
+
+ void Clear()
+ {
+ Streams.Clear();
+ Items.Clear();
+ }
+};
+
+HRESULT ReadHeader(IInStream *inStream, CHeader &header);
+HRESULT OpenArchive(IInStream *inStream, const CHeader &header, CByteBuffer &xml, CDatabase &database);
+HRESULT SortDatabase(CDatabase &database);
+
+class CUnpacker
+{
+ NCompress::CCopyCoder *copyCoderSpec;
+ CMyComPtr<ICompressCoder> copyCoder;
+
+ NCompress::NLzx::CDecoder *lzxDecoderSpec;
+ CMyComPtr<ICompressCoder> lzxDecoder;
+
+ NXpress::CDecoder xpressDecoder;
+
+ CByteBuffer sizesBuf;
+ HRESULT Unpack(IInStream *inStream, const CResource &res, bool lzxMode,
+ ISequentialOutStream *outStream, ICompressProgressInfo *progress);
+public:
+ HRESULT Unpack(IInStream *inStream, const CResource &res, bool lzxMode,
+ ISequentialOutStream *outStream, ICompressProgressInfo *progress, Byte *digest);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimRegister.cpp
new file mode 100644
index 000000000..22344b3a2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Wim/WimRegister.cpp
@@ -0,0 +1,13 @@
+// WimRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "WimHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NWim::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Wim", L"wim swm", 0, 0xE6, { 'M', 'S', 'W', 'I', 'M', 0, 0, 0 }, 8, false, CreateArc, 0 };
+
+REGISTER_ARC(Wim)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/XarHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/XarHandler.cpp
new file mode 100644
index 000000000..2dddad9fb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/XarHandler.cpp
@@ -0,0 +1,586 @@
+// XarHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+#include "Common/MyXml.h"
+#include "Common/StringToInt.h"
+#include "Common/UTFConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamObjects.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/BZip2Decoder.h"
+#include "../Compress/CopyCoder.h"
+#include "../Compress/ZlibDecoder.h"
+
+#include "Common/OutStreamWithSha1.h"
+
+#define XAR_SHOW_RAW
+
+#define Get16(p) GetBe16(p)
+#define Get32(p) GetBe32(p)
+#define Get64(p) GetBe64(p)
+
+namespace NArchive {
+namespace NXar {
+
+struct CFile
+{
+ AString Name;
+ AString Method;
+ UInt64 Size;
+ UInt64 PackSize;
+ UInt64 Offset;
+
+ // UInt32 mode;
+ UInt64 CTime;
+ UInt64 MTime;
+ UInt64 ATime;
+
+ bool IsDir;
+ bool HasData;
+
+ bool Sha1IsDefined;
+ Byte Sha1[20];
+ // bool packSha1IsDefined;
+ // Byte packSha1[20];
+
+ int Parent;
+
+ CFile(): IsDir(false), HasData(false), Sha1IsDefined(false),
+ /* packSha1IsDefined(false), */
+ Parent(-1), Size(0), PackSize(0), CTime(0), MTime(0), ATime(0) {}
+};
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ UInt64 _dataStartPos;
+ CMyComPtr<IInStream> _inStream;
+ AString _xml;
+ CObjectVector<CFile> _files;
+
+ HRESULT Open2(IInStream *stream);
+ HRESULT Extract(IInStream *stream);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+const UInt32 kXmlSizeMax = ((UInt32)1 << 30) - (1 << 14);
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidMethod, VT_BSTR}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+static bool ParseNumber(const char *s, int size, UInt32 &res)
+{
+ const char *end;
+ res = (UInt32)ConvertStringToUInt64(s, &end);
+ return (end - s == size);
+}
+
+static bool ParseUInt64(const CXmlItem &item, const char *name, UInt64 &res)
+{
+ AString s = item.GetSubStringForTag(name);
+ const char *end;
+ res = ConvertStringToUInt64(s, &end);
+ return (end - (const char *)s == s.Length());
+}
+
+static UInt64 ParseTime(const CXmlItem &item, const char *name)
+{
+ AString s = item.GetSubStringForTag(name);
+ if (s.Length() < 20)
+ return 0;
+ const char *p = s;
+ if (p[ 4] != '-' || p[ 7] != '-' || p[10] != 'T' ||
+ p[13] != ':' || p[16] != ':' || p[19] != 'Z')
+ return 0;
+ UInt32 year, month, day, hour, min, sec;
+ if (!ParseNumber(p, 4, year )) return 0;
+ if (!ParseNumber(p + 5, 2, month)) return 0;
+ if (!ParseNumber(p + 8, 2, day )) return 0;
+ if (!ParseNumber(p + 11, 2, hour )) return 0;
+ if (!ParseNumber(p + 14, 2, min )) return 0;
+ if (!ParseNumber(p + 17, 2, sec )) return 0;
+
+ UInt64 numSecs;
+ if (!NWindows::NTime::GetSecondsSince1601(year, month, day, hour, min, sec, numSecs))
+ return 0;
+ return numSecs * 10000000;
+}
+
+static bool HexToByte(char c, Byte &res)
+{
+ if (c >= '0' && c <= '9') res = c - '0';
+ else if (c >= 'A' && c <= 'F') res = c - 'A' + 10;
+ else if (c >= 'a' && c <= 'f') res = c - 'a' + 10;
+ else return false;
+ return true;
+}
+
+#define METHOD_NAME_ZLIB "zlib"
+
+static bool ParseSha1(const CXmlItem &item, const char *name, Byte *digest)
+{
+ int index = item.FindSubTag(name);
+ if (index < 0)
+ return false;
+ const CXmlItem &checkItem = item.SubItems[index];
+ AString style = checkItem.GetPropertyValue("style");
+ if (style == "SHA1")
+ {
+ AString s = checkItem.GetSubString();
+ if (s.Length() != 40)
+ return false;
+ for (int i = 0; i < s.Length(); i += 2)
+ {
+ Byte b0, b1;
+ if (!HexToByte(s[i], b0) || !HexToByte(s[i + 1], b1))
+ return false;
+ digest[i / 2] = (b0 << 4) | b1;
+ }
+ return true;
+ }
+ return false;
+}
+
+static bool AddItem(const CXmlItem &item, CObjectVector<CFile> &files, int parent)
+{
+ if (!item.IsTag)
+ return true;
+ if (item.Name == "file")
+ {
+ CFile file;
+ file.Parent = parent;
+ parent = files.Size();
+ file.Name = item.GetSubStringForTag("name");
+ AString type = item.GetSubStringForTag("type");
+ if (type == "directory")
+ file.IsDir = true;
+ else if (type == "file")
+ file.IsDir = false;
+ else
+ return false;
+
+ int dataIndex = item.FindSubTag("data");
+ if (dataIndex >= 0 && !file.IsDir)
+ {
+ file.HasData = true;
+ const CXmlItem &dataItem = item.SubItems[dataIndex];
+ if (!ParseUInt64(dataItem, "size", file.Size))
+ return false;
+ if (!ParseUInt64(dataItem, "length", file.PackSize))
+ return false;
+ if (!ParseUInt64(dataItem, "offset", file.Offset))
+ return false;
+ file.Sha1IsDefined = ParseSha1(dataItem, "extracted-checksum", file.Sha1);
+ // file.packSha1IsDefined = ParseSha1(dataItem, "archived-checksum", file.packSha1);
+ int encodingIndex = dataItem.FindSubTag("encoding");
+ const CXmlItem &encodingItem = dataItem.SubItems[encodingIndex];
+ if (encodingItem.IsTag)
+ {
+ AString s = encodingItem.GetPropertyValue("style");
+ if (s.Length() >= 0)
+ {
+ AString appl = "application/";
+ if (s.Left(appl.Length()) == appl)
+ {
+ s = s.Mid(appl.Length());
+ AString xx = "x-";
+ if (s.Left(xx.Length()) == xx)
+ {
+ s = s.Mid(xx.Length());
+ if (s == "gzip")
+ s = METHOD_NAME_ZLIB;
+ }
+ }
+ file.Method = s;
+ }
+ }
+ }
+
+ file.CTime = ParseTime(item, "ctime");
+ file.MTime = ParseTime(item, "mtime");
+ file.ATime = ParseTime(item, "atime");
+ files.Add(file);
+ }
+ for (int i = 0; i < item.SubItems.Size(); i++)
+ if (!AddItem(item.SubItems[i], files, parent))
+ return false;
+ return true;
+}
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ UInt64 archiveStartPos;
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, &archiveStartPos));
+
+ const UInt32 kHeaderSize = 0x1C;
+ Byte buf[kHeaderSize];
+ RINOK(ReadStream_FALSE(stream, buf, kHeaderSize));
+
+ UInt32 size = Get16(buf + 4);
+ // UInt32 ver = Get16(buf + 6); // == 0
+ if (Get32(buf) != 0x78617221 || size != kHeaderSize)
+ return S_FALSE;
+
+ UInt64 packSize = Get64(buf + 8);
+ UInt64 unpackSize = Get64(buf + 0x10);
+ // UInt32 checkSumAlogo = Get32(buf + 0x18);
+
+ if (unpackSize >= kXmlSizeMax)
+ return S_FALSE;
+
+ _dataStartPos = archiveStartPos + kHeaderSize + packSize;
+
+ char *ss = _xml.GetBuffer((int)unpackSize + 1);
+
+ NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
+ CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;
+
+ CLimitedSequentialInStream *inStreamLimSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStreamLim(inStreamLimSpec);
+ inStreamLimSpec->SetStream(stream);
+ inStreamLimSpec->Init(packSize);
+
+ CSequentialOutStreamImp2 *outStreamLimSpec = new CSequentialOutStreamImp2;
+ CMyComPtr<ISequentialOutStream> outStreamLim(outStreamLimSpec);
+ outStreamLimSpec->Init((Byte *)ss, (size_t)unpackSize);
+
+ RINOK(zlibCoder->Code(inStreamLim, outStreamLim, NULL, NULL, NULL));
+
+ if (outStreamLimSpec->GetPos() != (size_t)unpackSize)
+ return S_FALSE;
+
+ ss[(size_t)unpackSize] = 0;
+ _xml.ReleaseBuffer();
+
+ CXml xml;
+ if (!xml.Parse(_xml))
+ return S_FALSE;
+
+ if (!xml.Root.IsTagged("xar") || xml.Root.SubItems.Size() != 1)
+ return S_FALSE;
+ const CXmlItem &toc = xml.Root.SubItems[0];
+ if (!toc.IsTagged("toc"))
+ return S_FALSE;
+ if (!AddItem(toc, _files, -1))
+ return S_FALSE;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ {
+ Close();
+ if (Open2(stream) != S_OK)
+ return S_FALSE;
+ _inStream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _files.Clear();
+ _xml.Empty();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _files.Size()
+ #ifdef XAR_SHOW_RAW
+ + 1
+ #endif
+ ;
+ return S_OK;
+}
+
+static void TimeToProp(UInt64 t, NWindows::NCOM::CPropVariant &prop)
+{
+ if (t != 0)
+ {
+ FILETIME ft;
+ ft.dwLowDateTime = (UInt32)(t);
+ ft.dwHighDateTime = (UInt32)(t >> 32);
+ prop = ft;
+ }
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+
+ #ifdef XAR_SHOW_RAW
+ if ((int)index == _files.Size())
+ {
+ switch(propID)
+ {
+ case kpidPath: prop = L"[TOC].xml"; break;
+ case kpidSize:
+ case kpidPackSize: prop = (UInt64)_xml.Length(); break;
+ }
+ }
+ else
+ #endif
+ {
+ const CFile &item = _files[index];
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ UString name;
+ if (ConvertUTF8ToUnicode(item.Method, name))
+ prop = name;
+ break;
+ }
+ case kpidPath:
+ {
+ AString path;
+ int cur = index;
+ do
+ {
+ const CFile &item = _files[cur];
+ AString s = item.Name;
+ if (s.IsEmpty())
+ s = "unknown";
+ if (path.IsEmpty())
+ path = s;
+ else
+ path = s + CHAR_PATH_SEPARATOR + path;
+ cur = item.Parent;
+ }
+ while (cur >= 0);
+
+ UString name;
+ if (ConvertUTF8ToUnicode(path, name))
+ prop = name;
+ break;
+ }
+
+ case kpidIsDir: prop = item.IsDir; break;
+ case kpidSize: if (!item.IsDir) prop = item.Size; break;
+ case kpidPackSize: if (!item.IsDir) prop = item.PackSize; break;
+
+ case kpidMTime: TimeToProp(item.MTime, prop); break;
+ case kpidCTime: TimeToProp(item.CTime, prop); break;
+ case kpidATime: TimeToProp(item.ATime, prop); break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _files.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ int index = (int)(allFilesMode ? i : indices[i]);
+ #ifdef XAR_SHOW_RAW
+ if (index == _files.Size())
+ totalSize += _xml.Length();
+ else
+ #endif
+ totalSize += _files[index].Size;
+ }
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentPackTotal = 0;
+ UInt64 currentUnpTotal = 0;
+ UInt64 currentPackSize = 0;
+ UInt64 currentUnpSize = 0;
+
+ const UInt32 kZeroBufSize = (1 << 14);
+ CByteBuffer zeroBuf;
+ zeroBuf.SetCapacity(kZeroBufSize);
+ memset(zeroBuf, 0, kZeroBufSize);
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
+ CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;
+
+ NCompress::NBZip2::CDecoder *bzip2CoderSpec = new NCompress::NBZip2::CDecoder();
+ CMyComPtr<ICompressCoder> bzip2Coder = bzip2CoderSpec;
+
+ NCompress::NDeflate::NDecoder::CCOMCoder *deflateCoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder();
+ CMyComPtr<ICompressCoder> deflateCoder = deflateCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *inStreamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(inStreamSpec);
+ inStreamSpec->SetStream(_inStream);
+
+
+ CLimitedSequentialOutStream *outStreamLimSpec = new CLimitedSequentialOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamLimSpec);
+
+ COutStreamWithSha1 *outStreamSha1Spec = new COutStreamWithSha1;
+ {
+ CMyComPtr<ISequentialOutStream> outStreamSha1(outStreamSha1Spec);
+ outStreamLimSpec->SetStream(outStreamSha1);
+ }
+
+ for (i = 0; i < numItems; i++, currentPackTotal += currentPackSize, currentUnpTotal += currentUnpSize)
+ {
+ lps->InSize = currentPackTotal;
+ lps->OutSize = currentUnpTotal;
+ currentPackSize = 0;
+ currentUnpSize = 0;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (index < _files.Size())
+ {
+ const CFile &item = _files[index];
+ if (item.IsDir)
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ }
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ outStreamSha1Spec->SetStream(realOutStream);
+ realOutStream.Release();
+
+ Int32 opRes = NArchive::NExtract::NOperationResult::kOK;
+ #ifdef XAR_SHOW_RAW
+ if (index == _files.Size())
+ {
+ outStreamSha1Spec->Init(false);
+ outStreamLimSpec->Init(_xml.Length());
+ RINOK(WriteStream(outStream, (const char *)_xml, _xml.Length()));
+ currentPackSize = currentUnpSize = _xml.Length();
+ }
+ else
+ #endif
+ {
+ const CFile &item = _files[index];
+ if (item.HasData)
+ {
+ currentPackSize = item.PackSize;
+ currentUnpSize = item.Size;
+
+ RINOK(_inStream->Seek(_dataStartPos + item.Offset, STREAM_SEEK_SET, NULL));
+ inStreamSpec->Init(item.PackSize);
+ outStreamSha1Spec->Init(item.Sha1IsDefined);
+ outStreamLimSpec->Init(item.Size);
+ HRESULT res = S_OK;
+
+ ICompressCoder *coder = NULL;
+ if (item.Method == "octet-stream")
+ if (item.PackSize == item.Size)
+ coder = copyCoder;
+ else
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ else if (item.Method == METHOD_NAME_ZLIB)
+ coder = zlibCoder;
+ else if (item.Method == "bzip2")
+ coder = bzip2Coder;
+ else
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+
+ if (coder)
+ res = coder->Code(inStream, outStream, NULL, NULL, progress);
+
+ if (res != S_OK)
+ {
+ if (!outStreamLimSpec->IsFinishedOK())
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ else if (res != S_FALSE)
+ return res;
+ if (opRes == NArchive::NExtract::NOperationResult::kOK)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ }
+
+ if (opRes == NArchive::NExtract::NOperationResult::kOK)
+ {
+ if (outStreamLimSpec->IsFinishedOK() &&
+ outStreamSha1Spec->GetSize() == item.Size)
+ {
+ if (!outStreamLimSpec->IsFinishedOK())
+ {
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ }
+ else if (item.Sha1IsDefined)
+ {
+ Byte digest[NCrypto::NSha1::kDigestSize];
+ outStreamSha1Spec->Final(digest);
+ if (memcmp(digest, item.Sha1, NCrypto::NSha1::kDigestSize) != 0)
+ opRes = NArchive::NExtract::NOperationResult::kCRCError;
+ }
+ }
+ else
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ }
+ }
+ }
+ outStreamSha1Spec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new NArchive::NXar::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Xar", L"xar", 0, 0xE1, { 'x', 'a', 'r', '!', 0, 0x1C }, 6, false, CreateArc, 0 };
+
+REGISTER_ARC(Xar)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/XzHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/XzHandler.cpp
new file mode 100644
index 000000000..1ceec2009
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/XzHandler.cpp
@@ -0,0 +1,714 @@
+// XzHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+#include "../../../C/XzCrc64.h"
+#include "../../../C/XzEnc.h"
+
+#include "../../Common/ComTry.h"
+#include "../../Common/IntToString.h"
+
+#include "../ICoder.h"
+
+#include "../Common/CWrappers.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#include "IArchive.h"
+
+#include "Common/HandlerOut.h"
+
+using namespace NWindows;
+
+namespace NCompress {
+namespace NLzma2 {
+
+HRESULT SetLzma2Prop(PROPID propID, const PROPVARIANT &prop, CLzma2EncProps &lzma2Props);
+
+}}
+
+static void *SzAlloc(void *, size_t size) { return MyAlloc(size); }
+static void SzFree(void *, void *address) { MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+namespace NArchive {
+namespace NXz {
+
+struct CCrc64Gen { CCrc64Gen() { Crc64GenerateTable(); } } g_Crc64TableInit;
+
+class CHandler:
+ public IInArchive,
+ public IArchiveOpenSeq,
+ #ifndef EXTRACT_ONLY
+ public IOutArchive,
+ public ISetProperties,
+ public COutHandler,
+ #endif
+ public CMyUnknownImp
+{
+ Int64 _startPosition;
+ UInt64 _packSize;
+ UInt64 _unpackSize;
+ UInt64 _numBlocks;
+ AString _methodsString;
+ bool _useSeq;
+ UInt64 _unpackSizeDefined;
+ UInt64 _packSizeDefined;
+
+ CMyComPtr<IInStream> _stream;
+ CMyComPtr<ISequentialInStream> _seqStream;
+
+ UInt32 _crcSize;
+
+ void Init()
+ {
+ _crcSize = 4;
+ COutHandler::Init();
+ }
+
+ HRESULT Open2(IInStream *inStream, IArchiveOpenCallback *callback);
+
+public:
+ MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_ENTRY(IInArchive)
+ MY_QUERYINTERFACE_ENTRY(IArchiveOpenSeq)
+ #ifndef EXTRACT_ONLY
+ MY_QUERYINTERFACE_ENTRY(IOutArchive)
+ MY_QUERYINTERFACE_ENTRY(ISetProperties)
+ #endif
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ INTERFACE_IInArchive(;)
+ STDMETHOD(OpenSeq)(ISequentialInStream *stream);
+
+ #ifndef EXTRACT_ONLY
+ INTERFACE_IOutArchive(;)
+ STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProps);
+ #endif
+
+ CHandler();
+};
+
+CHandler::CHandler()
+{
+ Init();
+}
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMethod, VT_BSTR}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidNumBlocks, VT_UI4}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+static char GetHex(Byte value)
+{
+ return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
+}
+
+static inline void AddHexToString(AString &res, Byte value)
+{
+ res += GetHex((Byte)(value >> 4));
+ res += GetHex((Byte)(value & 0xF));
+}
+
+static AString ConvertUInt32ToString(UInt32 value)
+{
+ char temp[32];
+ ::ConvertUInt32ToString(value, temp);
+ return temp;
+}
+
+static AString Lzma2PropToString(int prop)
+{
+ if ((prop & 1) == 0)
+ return ConvertUInt32ToString(prop / 2 + 12);
+ AString res;
+ char c;
+
+ UInt32 size = (2 | ((prop) & 1)) << ((prop) / 2 + 1);
+
+ if (prop > 17)
+ {
+ res = ConvertUInt32ToString(size >> 10);
+ c = 'm';
+ }
+ else
+ {
+ res = ConvertUInt32ToString(size);
+ c = 'k';
+ }
+ return res + c;
+}
+
+struct CMethodNamePair
+{
+ UInt32 Id;
+ const char *Name;
+};
+
+static CMethodNamePair g_NamePairs[] =
+{
+ { XZ_ID_Subblock, "SB" },
+ { XZ_ID_Delta, "Delta" },
+ { XZ_ID_X86, "x86" },
+ { XZ_ID_PPC, "PPC" },
+ { XZ_ID_IA64, "IA64" },
+ { XZ_ID_ARM, "ARM" },
+ { XZ_ID_ARMT, "ARMT" },
+ { XZ_ID_SPARC, "SPARC" },
+ { XZ_ID_LZMA2, "LZMA2" }
+};
+
+static AString GetMethodString(const CXzFilter &f)
+{
+ AString s;
+
+ for (unsigned int i = 0; i < sizeof(g_NamePairs) / sizeof(g_NamePairs[i]); i++)
+ if (g_NamePairs[i].Id == f.id)
+ s = g_NamePairs[i].Name;
+ if (s.IsEmpty())
+ {
+ char temp[32];
+ ::ConvertUInt64ToString(f.id, temp);
+ s = temp;
+ }
+
+ if (f.propsSize > 0)
+ {
+ s += ':';
+ if (f.id == XZ_ID_LZMA2 && f.propsSize == 1)
+ s += Lzma2PropToString(f.props[0]);
+ else if (f.id == XZ_ID_Delta && f.propsSize == 1)
+ s += ConvertUInt32ToString((UInt32)f.props[0] + 1);
+ else
+ {
+ s += '[';
+ for (UInt32 bi = 0; bi < f.propsSize; bi++)
+ AddHexToString(s, f.props[bi]);
+ s += ']';
+ }
+ }
+ return s;
+}
+
+static void AddString(AString &dest, const AString &src)
+{
+ if (!dest.IsEmpty())
+ dest += ' ';
+ dest += src;
+}
+
+static const char *kChecks[] =
+{
+ "NoCheck",
+ "CRC32",
+ NULL,
+ NULL,
+ "CRC64",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "SHA256",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+static AString GetCheckString(const CXzs &xzs)
+{
+ size_t i;
+ UInt32 mask = 0;
+ for (i = 0; i < xzs.num; i++)
+ mask |= ((UInt32)1 << XzFlags_GetCheckType(xzs.streams[i].flags));
+ AString s;
+ for (i = 0; i <= XZ_CHECK_MASK; i++)
+ if (((mask >> i) & 1) != 0)
+ {
+ AString s2;
+ if (kChecks[i])
+ s2 = kChecks[i];
+ else
+ s2 = "Check-" + ConvertUInt32ToString((UInt32)i);
+ AddString(s, s2);
+ }
+ return s;
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidNumBlocks: if (!_useSeq) prop = _numBlocks; break;
+ case kpidPhySize: if (_packSizeDefined) prop = _packSize; break;
+ case kpidMethod: if (!_methodsString.IsEmpty()) prop = _methodsString; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidSize: if (_unpackSizeDefined) prop = _unpackSize; break;
+ case kpidPackSize: if (_packSizeDefined) prop = _packSize; break;
+ case kpidMethod: if (!_methodsString.IsEmpty()) prop = _methodsString; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+
+struct COpenCallbackWrap
+{
+ ICompressProgress p;
+ IArchiveOpenCallback *OpenCallback;
+ HRESULT Res;
+ COpenCallbackWrap(IArchiveOpenCallback *progress);
+};
+
+static SRes OpenCallbackProgress(void *pp, UInt64 inSize, UInt64 /* outSize */)
+{
+ COpenCallbackWrap *p = (COpenCallbackWrap *)pp;
+ p->Res = p->OpenCallback->SetCompleted(NULL, &inSize);
+ return (SRes)p->Res;
+}
+
+COpenCallbackWrap::COpenCallbackWrap(IArchiveOpenCallback *callback)
+{
+ p.Progress = OpenCallbackProgress;
+ OpenCallback = callback;
+ Res = SZ_OK;
+}
+
+struct CXzsCPP
+{
+ CXzs p;
+ CXzsCPP() { Xzs_Construct(&p); }
+ ~CXzsCPP() { Xzs_Free(&p, &g_Alloc); }
+};
+
+HRESULT CHandler::Open2(IInStream *inStream, IArchiveOpenCallback *callback)
+{
+ CSeekInStreamWrap inStreamImp(inStream);
+
+ CLookToRead lookStream;
+ LookToRead_CreateVTable(&lookStream, True);
+ lookStream.realStream = &inStreamImp.p;
+ LookToRead_Init(&lookStream);
+
+ COpenCallbackWrap openWrap(callback);
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &_packSize));
+ RINOK(callback->SetTotal(NULL, &_packSize));
+
+ CXzsCPP xzs;
+ SRes res = Xzs_ReadBackward(&xzs.p, &lookStream.s, &_startPosition, &openWrap.p, &g_Alloc);
+ if (res == SZ_ERROR_NO_ARCHIVE && xzs.p.num > 0)
+ res = SZ_OK;
+ if (res == SZ_OK)
+ {
+ _packSize -= _startPosition;
+ _unpackSize = Xzs_GetUnpackSize(&xzs.p);
+ _unpackSizeDefined = _packSizeDefined = true;
+ _numBlocks = (UInt64)Xzs_GetNumBlocks(&xzs.p);
+
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ CXzStreamFlags st;
+ CSeqInStreamWrap inStreamWrap(inStream);
+ SRes res2 = Xz_ReadHeader(&st, &inStreamWrap.p);
+
+ if (res2 == SZ_OK)
+ {
+ CXzBlock block;
+ Bool isIndex;
+ UInt32 headerSizeRes;
+ res2 = XzBlock_ReadHeader(&block, &inStreamWrap.p, &isIndex, &headerSizeRes);
+ if (res2 == SZ_OK && !isIndex)
+ {
+ int numFilters = XzBlock_GetNumFilters(&block);
+ for (int i = 0; i < numFilters; i++)
+ AddString(_methodsString, GetMethodString(block.filters[i]));
+ }
+ }
+ AddString(_methodsString, GetCheckString(xzs.p));
+ }
+
+ if (res != SZ_OK || _startPosition != 0)
+ {
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ CXzStreamFlags st;
+ CSeqInStreamWrap inStreamWrap(inStream);
+ SRes res2 = Xz_ReadHeader(&st, &inStreamWrap.p);
+ if (res2 == SZ_OK)
+ {
+ res = res2;
+ _startPosition = 0;
+ _useSeq = True;
+ _unpackSizeDefined = _packSizeDefined = false;
+ }
+ }
+ if (res == SZ_ERROR_NO_ARCHIVE)
+ return S_FALSE;
+ RINOK(SResToHRESULT(res));
+ _stream = inStream;
+ _seqStream = inStream;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ try
+ {
+ Close();
+ return Open2(inStream, callback);
+ }
+ catch(...) { return S_FALSE; }
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
+{
+ Close();
+ _seqStream = stream;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _numBlocks = 0;
+ _useSeq = true;
+ _unpackSizeDefined = _packSizeDefined = false;
+ _methodsString.Empty();
+ _stream.Release();
+ _seqStream.Release();
+ return S_OK;
+}
+
+class CSeekToSeqStream:
+ public IInStream,
+ public CMyUnknownImp
+{
+public:
+ CMyComPtr<ISequentialInStream> Stream;
+ MY_UNKNOWN_IMP1(IInStream)
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+};
+
+STDMETHODIMP CSeekToSeqStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ return Stream->Read(data, size, processedSize);
+}
+
+STDMETHODIMP CSeekToSeqStream::Seek(Int64, UInt32, UInt64 *) { return E_NOTIMPL; }
+
+struct CXzUnpackerCPP
+{
+ Byte *InBuf;
+ Byte *OutBuf;
+ CXzUnpacker p;
+ CXzUnpackerCPP(): InBuf(0), OutBuf(0) {}
+ ~CXzUnpackerCPP()
+ {
+ XzUnpacker_Free(&p);
+ MyFree(InBuf);
+ MyFree(OutBuf);
+ }
+};
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (!allFilesMode)
+ {
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1 || indices[0] != 0)
+ return E_INVALIDARG;
+ }
+
+ bool testMode = (_aTestMode != 0);
+
+ extractCallback->SetTotal(_packSize);
+ UInt64 currentTotalPacked = 0;
+ RINOK(extractCallback->SetCompleted(&currentTotalPacked));
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+
+ RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
+
+ if (!testMode && !realOutStream)
+ return S_OK;
+
+ extractCallback->PrepareOperation(askMode);
+
+ if (_stream)
+ {
+ RINOK(_stream->Seek(_startPosition, STREAM_SEEK_SET, NULL));
+ }
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, true);
+
+ CCompressProgressWrap progressWrap(progress);
+
+ SRes res;
+
+ const UInt32 kInBufSize = 1 << 15;
+ const UInt32 kOutBufSize = 1 << 21;
+
+ UInt32 inPos = 0;
+ UInt32 inSize = 0;
+ UInt32 outPos = 0;
+ CXzUnpackerCPP xzu;
+ res = XzUnpacker_Create(&xzu.p, &g_Alloc);
+ if (res == SZ_OK)
+ {
+ xzu.InBuf = (Byte *)MyAlloc(kInBufSize);
+ xzu.OutBuf = (Byte *)MyAlloc(kOutBufSize);
+ if (xzu.InBuf == 0 || xzu.OutBuf == 0)
+ res = SZ_ERROR_MEM;
+ }
+ if (res == SZ_OK)
+ for (;;)
+ {
+ if (inPos == inSize)
+ {
+ inPos = inSize = 0;
+ RINOK(_seqStream->Read(xzu.InBuf, kInBufSize, &inSize));
+ }
+
+ SizeT inLen = inSize - inPos;
+ SizeT outLen = kOutBufSize - outPos;
+ ECoderStatus status;
+ res = XzUnpacker_Code(&xzu.p,
+ xzu.OutBuf + outPos, &outLen,
+ xzu.InBuf + inPos, &inLen,
+ (inSize == 0 ? CODER_FINISH_END : CODER_FINISH_ANY), &status);
+
+ // printf("\n_inPos = %6d inLen = %5d, outLen = %5d", inPos, inLen, outLen);
+
+ inPos += (UInt32)inLen;
+ outPos += (UInt32)outLen;
+ lps->InSize += inLen;
+ lps->OutSize += outLen;
+
+ bool finished = (((inLen == 0) && (outLen == 0)) || res != SZ_OK);
+
+ if (outPos == kOutBufSize || finished)
+ {
+ if (realOutStream && outPos > 0)
+ {
+ RINOK(WriteStream(realOutStream, xzu.OutBuf, outPos));
+ }
+ outPos = 0;
+ }
+ if (finished)
+ {
+ _packSize = lps->InSize;
+ _unpackSize = lps->OutSize;
+ _packSizeDefined = _unpackSizeDefined = true;
+ if (res == SZ_OK)
+ {
+ if (status == CODER_STATUS_NEEDS_MORE_INPUT)
+ {
+ if (XzUnpacker_IsStreamWasFinished(&xzu.p))
+ _packSize -= xzu.p.padSize;
+ else
+ res = SZ_ERROR_DATA;
+ }
+ else
+ res = SZ_ERROR_DATA;
+ }
+ break;
+ }
+ RINOK(lps->SetCur());
+ }
+
+ Int32 opRes;
+ switch(res)
+ {
+ case SZ_OK:
+ opRes = NArchive::NExtract::NOperationResult::kOK; break;
+ case SZ_ERROR_UNSUPPORTED:
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; break;
+ case SZ_ERROR_CRC:
+ opRes = NArchive::NExtract::NOperationResult::kCRCError; break;
+ case SZ_ERROR_DATA:
+ case SZ_ERROR_ARCHIVE:
+ case SZ_ERROR_NO_ARCHIVE:
+ opRes = NArchive::NExtract::NOperationResult::kDataError; break;
+ default:
+ return SResToHRESULT(res);
+ }
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ return S_OK;
+ COM_TRY_END
+}
+
+#ifndef EXTRACT_ONLY
+
+STDMETHODIMP CHandler::GetFileTimeType(UInt32 *timeType)
+{
+ *timeType = NFileTimeType::kUnix;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
+ IArchiveUpdateCallback *updateCallback)
+{
+ CSeqOutStreamWrap seqOutStream(outStream);
+
+ if (numItems == 0)
+ {
+ SRes res = Xz_EncodeEmpty(&seqOutStream.p);
+ return SResToHRESULT(res);
+ }
+
+ if (numItems != 1)
+ return E_INVALIDARG;
+
+ Int32 newData, newProps;
+ UInt32 indexInArchive;
+ if (!updateCallback)
+ return E_FAIL;
+ RINOK(updateCallback->GetUpdateItemInfo(0, &newData, &newProps, &indexInArchive));
+
+ if (IntToBool(newProps))
+ {
+ {
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(0, kpidIsDir, &prop));
+ if (prop.vt != VT_EMPTY)
+ if (prop.vt != VT_BOOL || prop.boolVal != VARIANT_FALSE)
+ return E_INVALIDARG;
+ }
+ }
+
+ if (IntToBool(newData))
+ {
+ {
+ UInt64 size;
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(0, kpidSize, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ size = prop.uhVal.QuadPart;
+ RINOK(updateCallback->SetTotal(size));
+ }
+
+ CLzma2EncProps lzma2Props;
+ Lzma2EncProps_Init(&lzma2Props);
+
+ lzma2Props.lzmaProps.level = _level;
+
+ CMyComPtr<ISequentialInStream> fileInStream;
+ RINOK(updateCallback->GetStream(0, &fileInStream));
+
+ CSeqInStreamWrap seqInStream(fileInStream);
+
+ for (int i = 0; i < _methods.Size(); i++)
+ {
+ COneMethodInfo &m = _methods[i];
+ SetCompressionMethod2(m
+ #ifdef COMPRESS_MT
+ , _numThreads
+ #endif
+ );
+ if (m.IsLzma())
+ {
+ for (int j = 0; j < m.Props.Size(); j++)
+ {
+ const CProp &prop = m.Props[j];
+ RINOK(NCompress::NLzma2::SetLzma2Prop(prop.Id, prop.Value, lzma2Props));
+ }
+ }
+ }
+
+ #ifdef COMPRESS_MT
+ lzma2Props.numTotalThreads = _numThreads;
+ #endif
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(updateCallback, true);
+
+ CCompressProgressWrap progressWrap(progress);
+ SRes res = Xz_Encode(&seqOutStream.p, &seqInStream.p, &lzma2Props, False, &progressWrap.p);
+ if (res == SZ_OK)
+ return updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK);
+ return SResToHRESULT(res);
+ }
+ if (indexInArchive != 0)
+ return E_INVALIDARG;
+ if (_stream)
+ RINOK(_stream->Seek(_startPosition, STREAM_SEEK_SET, NULL));
+ return NCompress::CopyStream(_stream, outStream, 0);
+}
+
+STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProps)
+{
+ COM_TRY_BEGIN
+ BeforeSetProperty();
+ for (int i = 0; i < numProps; i++)
+ {
+ RINOK(SetProperty(names[i], values[i]));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+#endif
+
+static IInArchive *CreateArc() { return new NArchive::NXz::CHandler; }
+#ifndef EXTRACT_ONLY
+static IOutArchive *CreateArcOut() { return new NArchive::NXz::CHandler; }
+#else
+#define CreateArcOut 0
+#endif
+
+static CArcInfo g_ArcInfo =
+ { L"xz", L"xz txz", L"* .tar", 0xC, {0xFD, '7' , 'z', 'X', 'Z', '\0'}, 6, true, CreateArc, CreateArcOut };
+
+REGISTER_ARC(xz)
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ZHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ZHandler.cpp
new file mode 100644
index 000000000..21432b226
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/ZHandler.cpp
@@ -0,0 +1,171 @@
+// ZHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/ZDecoder.h"
+
+#include "Common/DummyOutStream.h"
+
+namespace NArchive {
+namespace NZ {
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+
+private:
+ CMyComPtr<IInStream> _stream;
+ UInt64 _streamStartPosition;
+ UInt64 _packSize;
+ Byte _properties;
+};
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Z", L"z taz", L"* .tar", 5, { 0x1F, 0x9D }, 2, false, CreateArc, 0 };
+
+REGISTER_ARC(Z)
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPackSize, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPackSize: prop = _packSize; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+static const int kSignatureSize = 3;
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ {
+ RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_streamStartPosition));
+ Byte buffer[kSignatureSize];
+ RINOK(ReadStream_FALSE(stream, buffer, kSignatureSize));
+ if (buffer[0] != 0x1F || buffer[1] != 0x9D)
+ return S_FALSE;
+ _properties = buffer[2];
+
+ UInt64 endPosition;
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPosition));
+ _packSize = endPosition - _streamStartPosition - kSignatureSize;
+
+ _stream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _stream.Release();
+ return S_OK;
+}
+
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == (UInt32)(-1));
+ if (!allFilesMode)
+ {
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1)
+ return E_INVALIDARG;
+ if (indices[0] != 0)
+ return E_INVALIDARG;
+ }
+
+ bool testMode = (testModeSpec != 0);
+
+ extractCallback->SetTotal(_packSize);
+
+ UInt64 currentTotalPacked = 0;
+
+ RINOK(extractCallback->SetCompleted(&currentTotalPacked));
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NExtract::NAskMode::kTest :
+ NExtract::NAskMode::kExtract;
+
+ RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
+
+ if (!testMode && !realOutStream)
+ return S_OK;
+
+ extractCallback->PrepareOperation(askMode);
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->SetStream(realOutStream);
+ outStreamSpec->Init();
+ realOutStream.Release();
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, true);
+
+ RINOK(_stream->Seek(_streamStartPosition + kSignatureSize, STREAM_SEEK_SET, NULL));
+
+ CMyComPtr<ICompressCoder> decoder;
+ NCompress::NZ::CDecoder *decoderSpec = new NCompress::NZ::CDecoder;
+ decoder = decoderSpec;
+
+ HRESULT result = decoderSpec->SetDecoderProperties2(&_properties, 1);
+
+ int opResult;
+ if (result != S_OK)
+ opResult = NExtract::NOperationResult::kUnSupportedMethod;
+ else
+ {
+ result = decoder->Code(_stream, outStream, NULL, NULL, progress);
+ if (result == S_FALSE)
+ opResult = NExtract::NOperationResult::kDataError;
+ else
+ {
+ RINOK(result);
+ opResult = NExtract::NOperationResult::kOK;
+ }
+ }
+ outStream.Release();
+ return extractCallback->SetOperationResult(opResult);
+ COM_TRY_END
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
new file mode 100644
index 000000000..9157deeb4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
@@ -0,0 +1,345 @@
+// ZipAddCommon.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/7zCrc.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../ICoder.h"
+#include "../../IPassword.h"
+#include "../../MyVersion.h"
+
+#include "../../Common/CreateCoder.h"
+#include "../../Common/StreamObjects.h"
+#include "../../Common/StreamUtils.h"
+
+#include "../../Compress/LzmaEncoder.h"
+
+#include "../Common/InStreamWithCRC.h"
+
+#include "ZipAddCommon.h"
+#include "ZipHeader.h"
+
+namespace NArchive {
+namespace NZip {
+
+static const CMethodId kMethodId_ZipBase = 0x040100;
+static const CMethodId kMethodId_BZip2 = 0x040202;
+
+static const UInt32 kLzmaPropsSize = 5;
+static const UInt32 kLzmaHeaderSize = 4 + kLzmaPropsSize;
+
+class CLzmaEncoder:
+ public ICompressCoder,
+ public CMyUnknownImp
+{
+ NCompress::NLzma::CEncoder *EncoderSpec;
+ CMyComPtr<ICompressCoder> Encoder;
+ Byte Header[kLzmaHeaderSize];
+public:
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+ HRESULT SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
+
+ MY_UNKNOWN_IMP
+};
+
+HRESULT CLzmaEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
+{
+ if (!Encoder)
+ {
+ EncoderSpec = new NCompress::NLzma::CEncoder;
+ Encoder = EncoderSpec;
+ }
+ CSequentialOutStreamImp *outStreamSpec = new CSequentialOutStreamImp;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->Init();
+ RINOK(EncoderSpec->SetCoderProperties(propIDs, props, numProps));
+ RINOK(EncoderSpec->WriteCoderProperties(outStream));
+ if (outStreamSpec->GetSize() != kLzmaPropsSize)
+ return E_FAIL;
+ Header[0] = MY_VER_MAJOR;
+ Header[1] = MY_VER_MINOR;
+ Header[2] = kLzmaPropsSize;
+ Header[3] = 0;
+ memcpy(Header + 4, outStreamSpec->GetBuffer(), kLzmaPropsSize);
+ return S_OK;
+}
+
+HRESULT CLzmaEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ RINOK(WriteStream(outStream, Header, kLzmaHeaderSize));
+ return Encoder->Code(inStream, outStream, inSize, outSize, progress);
+}
+
+
+CAddCommon::CAddCommon(const CCompressionMethodMode &options):
+ _options(options),
+ _copyCoderSpec(NULL),
+ _cryptoStreamSpec(0)
+ {}
+
+static HRESULT GetStreamCRC(ISequentialInStream *inStream, UInt32 &resultCRC)
+{
+ UInt32 crc = CRC_INIT_VAL;
+ const UInt32 kBufferSize = (1 << 14);
+ Byte buffer[kBufferSize];
+ for (;;)
+ {
+ UInt32 realProcessedSize;
+ RINOK(inStream->Read(buffer, kBufferSize, &realProcessedSize));
+ if (realProcessedSize == 0)
+ {
+ resultCRC = CRC_GET_DIGEST(crc);
+ return S_OK;
+ }
+ crc = CrcUpdate(crc, buffer, (size_t)realProcessedSize);
+ }
+}
+
+HRESULT CAddCommon::Compress(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ ISequentialInStream *inStream, IOutStream *outStream,
+ ICompressProgressInfo *progress, CCompressingResult &operationResult)
+{
+ CSequentialInStreamWithCRC *inSecCrcStreamSpec = 0;
+ CInStreamWithCRC *inCrcStreamSpec = 0;
+ CMyComPtr<ISequentialInStream> inCrcStream;
+ {
+ CMyComPtr<IInStream> inStream2;
+ // we don't support stdin, since stream from stdin can require 64-bit size header
+ RINOK(inStream->QueryInterface(IID_IInStream, (void **)&inStream2));
+ if (inStream2)
+ {
+ inCrcStreamSpec = new CInStreamWithCRC;
+ inCrcStream = inCrcStreamSpec;
+ inCrcStreamSpec->SetStream(inStream2);
+ inCrcStreamSpec->Init();
+ }
+ else
+ {
+ inSecCrcStreamSpec = new CSequentialInStreamWithCRC;
+ inCrcStream = inSecCrcStreamSpec;
+ inSecCrcStreamSpec->SetStream(inStream);
+ inSecCrcStreamSpec->Init();
+ }
+ }
+
+ int numTestMethods = _options.MethodSequence.Size();
+ if (numTestMethods > 1 || _options.PasswordIsDefined)
+ {
+ if (inCrcStreamSpec == 0)
+ {
+ if (_options.PasswordIsDefined)
+ return E_NOTIMPL;
+ numTestMethods = 1;
+ }
+ }
+ Byte method = 0;
+ COutStreamReleaser outStreamReleaser;
+ for (int i = 0; i < numTestMethods; i++)
+ {
+ if (inCrcStreamSpec != 0)
+ RINOK(inCrcStreamSpec->Seek(0, STREAM_SEEK_SET, NULL));
+ RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL));
+ if (_options.PasswordIsDefined)
+ {
+ if (!_cryptoStream)
+ {
+ _cryptoStreamSpec = new CFilterCoder;
+ _cryptoStream = _cryptoStreamSpec;
+ }
+ if (_options.IsAesMode)
+ {
+ _cryptoStreamSpec->Filter = _aesFilter = _filterAesSpec = new NCrypto::NWzAes::CEncoder;
+ _filterAesSpec->SetKeyMode(_options.AesKeyMode);
+ RINOK(_filterAesSpec->CryptoSetPassword(
+ (const Byte *)(const char *)_options.Password, _options.Password.Length()));
+ RINOK(_filterAesSpec->WriteHeader(outStream));
+ }
+ else
+ {
+ _cryptoStreamSpec->Filter = _zipCryptoFilter = _filterSpec = new NCrypto::NZip::CEncoder;
+ RINOK(_filterSpec->CryptoSetPassword(
+ (const Byte *)(const char *)_options.Password, _options.Password.Length()));
+ UInt32 crc = 0;
+ RINOK(GetStreamCRC(inStream, crc));
+ RINOK(inCrcStreamSpec->Seek(0, STREAM_SEEK_SET, NULL));
+ RINOK(_filterSpec->CryptoSetCRC(crc));
+ RINOK(_filterSpec->WriteHeader(outStream));
+ }
+ RINOK(_cryptoStreamSpec->SetOutStream(outStream));
+ outStreamReleaser.FilterCoder = _cryptoStreamSpec;
+ }
+
+ method = _options.MethodSequence[i];
+ switch(method)
+ {
+ case NFileHeader::NCompressionMethod::kStored:
+ {
+ if (_copyCoderSpec == NULL)
+ {
+ _copyCoderSpec = new NCompress::CCopyCoder;
+ _copyCoder = _copyCoderSpec;
+ }
+ CMyComPtr<ISequentialOutStream> outStreamNew;
+ if (_options.PasswordIsDefined)
+ outStreamNew = _cryptoStream;
+ else
+ outStreamNew = outStream;
+ RINOK(_copyCoder->Code(inCrcStream, outStreamNew, NULL, NULL, progress));
+ operationResult.ExtractVersion = NFileHeader::NCompressionMethod::kStoreExtractVersion;
+ break;
+ }
+ default:
+ {
+ if (!_compressEncoder)
+ {
+ if (method == NFileHeader::NCompressionMethod::kLZMA)
+ {
+ CLzmaEncoder *_lzmaEncoder = new CLzmaEncoder();
+ _compressEncoder = _lzmaEncoder;
+ NWindows::NCOM::CPropVariant props[] =
+ {
+ #ifdef COMPRESS_MT
+ _options.NumThreads,
+ #endif
+ _options.Algo,
+ _options.DicSize,
+ _options.NumFastBytes,
+ (BSTR)(const wchar_t *)_options.MatchFinder,
+ _options.NumMatchFinderCycles
+ };
+ PROPID propIDs[] =
+ {
+ #ifdef COMPRESS_MT
+ NCoderPropID::kNumThreads,
+ #endif
+ NCoderPropID::kAlgorithm,
+ NCoderPropID::kDictionarySize,
+ NCoderPropID::kNumFastBytes,
+ NCoderPropID::kMatchFinder,
+ NCoderPropID::kMatchFinderCycles
+ };
+ int numProps = sizeof(propIDs) / sizeof(propIDs[0]);
+ if (!_options.NumMatchFinderCyclesDefined)
+ numProps--;
+ RINOK(_lzmaEncoder->SetCoderProperties(propIDs, props, numProps));
+ }
+ else
+ {
+ CMethodId methodId;
+ switch(method)
+ {
+ case NFileHeader::NCompressionMethod::kBZip2:
+ methodId = kMethodId_BZip2;
+ break;
+ default:
+ methodId = kMethodId_ZipBase + method;
+ break;
+ }
+ RINOK(CreateCoder(
+ EXTERNAL_CODECS_LOC_VARS
+ methodId, _compressEncoder, true));
+ if (!_compressEncoder)
+ return E_NOTIMPL;
+
+ if (method == NFileHeader::NCompressionMethod::kDeflated ||
+ method == NFileHeader::NCompressionMethod::kDeflated64)
+ {
+ NWindows::NCOM::CPropVariant props[] =
+ {
+ _options.Algo,
+ _options.NumPasses,
+ _options.NumFastBytes,
+ _options.NumMatchFinderCycles
+ };
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kAlgorithm,
+ NCoderPropID::kNumPasses,
+ NCoderPropID::kNumFastBytes,
+ NCoderPropID::kMatchFinderCycles
+ };
+ int numProps = sizeof(propIDs) / sizeof(propIDs[0]);
+ if (!_options.NumMatchFinderCyclesDefined)
+ numProps--;
+ CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
+ _compressEncoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
+ if (setCoderProperties)
+ {
+ RINOK(setCoderProperties->SetCoderProperties(propIDs, props, numProps));
+ }
+ }
+ else if (method == NFileHeader::NCompressionMethod::kBZip2)
+ {
+ NWindows::NCOM::CPropVariant props[] =
+ {
+ _options.DicSize,
+ _options.NumPasses
+ #ifdef COMPRESS_MT
+ , _options.NumThreads
+ #endif
+ };
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kDictionarySize,
+ NCoderPropID::kNumPasses
+ #ifdef COMPRESS_MT
+ , NCoderPropID::kNumThreads
+ #endif
+ };
+ CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
+ _compressEncoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
+ if (setCoderProperties)
+ {
+ RINOK(setCoderProperties->SetCoderProperties(propIDs, props, sizeof(propIDs) / sizeof(propIDs[0])));
+ }
+ }
+ }
+ }
+ CMyComPtr<ISequentialOutStream> outStreamNew;
+ if (_options.PasswordIsDefined)
+ outStreamNew = _cryptoStream;
+ else
+ outStreamNew = outStream;
+ RINOK(_compressEncoder->Code(inCrcStream, outStreamNew, NULL, NULL, progress));
+ operationResult.ExtractVersion = NFileHeader::NCompressionMethod::kDeflateExtractVersion;
+ break;
+ }
+ }
+
+ RINOK(outStream->Seek(0, STREAM_SEEK_CUR, &operationResult.PackSize));
+
+ if (inCrcStreamSpec != 0)
+ {
+ operationResult.CRC = inCrcStreamSpec->GetCRC();
+ operationResult.UnpackSize = inCrcStreamSpec->GetSize();
+ }
+ else
+ {
+ operationResult.CRC = inSecCrcStreamSpec->GetCRC();
+ operationResult.UnpackSize = inSecCrcStreamSpec->GetSize();
+ }
+
+ if (_options.PasswordIsDefined)
+ {
+ if (operationResult.PackSize < operationResult.UnpackSize +
+ (_options.IsAesMode ? _filterAesSpec->GetHeaderSize() : NCrypto::NZip::kHeaderSize))
+ break;
+ }
+ else if (operationResult.PackSize < operationResult.UnpackSize)
+ break;
+ }
+ if (_options.IsAesMode)
+ {
+ RINOK(_filterAesSpec->WriteFooter(outStream));
+ RINOK(outStream->Seek(0, STREAM_SEEK_CUR, &operationResult.PackSize));
+ }
+ operationResult.Method = method;
+ return outStream->SetSize(operationResult.PackSize);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipAddCommon.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipAddCommon.h
new file mode 100644
index 000000000..8f5b568d6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipAddCommon.h
@@ -0,0 +1,59 @@
+// ZipAddCommon.h
+
+#ifndef __ZIP_ADD_COMMON_H
+#define __ZIP_ADD_COMMON_H
+
+#include "../../ICoder.h"
+#include "../../IProgress.h"
+
+#include "../../Common/CreateCoder.h"
+#include "../../Common/FilterCoder.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../../Crypto/ZipCrypto.h"
+#include "../../Crypto/WzAes.h"
+
+#include "ZipCompressionMode.h"
+
+namespace NArchive {
+namespace NZip {
+
+struct CCompressingResult
+{
+ UInt64 UnpackSize;
+ UInt64 PackSize;
+ UInt32 CRC;
+ UInt16 Method;
+ Byte ExtractVersion;
+};
+
+class CAddCommon
+{
+ CCompressionMethodMode _options;
+ NCompress::CCopyCoder *_copyCoderSpec;
+ CMyComPtr<ICompressCoder> _copyCoder;
+
+ CMyComPtr<ICompressCoder> _compressEncoder;
+
+ CFilterCoder *_cryptoStreamSpec;
+ CMyComPtr<ISequentialOutStream> _cryptoStream;
+
+ NCrypto::NZip::CEncoder *_filterSpec;
+ NCrypto::NWzAes::CEncoder *_filterAesSpec;
+
+ CMyComPtr<ICompressFilter> _zipCryptoFilter;
+ CMyComPtr<ICompressFilter> _aesFilter;
+
+
+public:
+ CAddCommon(const CCompressionMethodMode &options);
+ HRESULT Compress(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ ISequentialInStream *inStream, IOutStream *outStream,
+ ICompressProgressInfo *progress, CCompressingResult &operationResult);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipCompressionMode.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipCompressionMode.h
new file mode 100644
index 000000000..de5f5ccd8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipCompressionMode.h
@@ -0,0 +1,39 @@
+// CompressionMode.h
+
+#ifndef __ZIP_COMPRESSIONMETHOD_H
+#define __ZIP_COMPRESSIONMETHOD_H
+
+#include "Common/MyString.h"
+
+namespace NArchive {
+namespace NZip {
+
+struct CCompressionMethodMode
+{
+ CRecordVector<Byte> MethodSequence;
+ UString MatchFinder;
+ UInt32 Algo;
+ UInt32 NumPasses;
+ UInt32 NumFastBytes;
+ bool NumMatchFinderCyclesDefined;
+ UInt32 NumMatchFinderCycles;
+ UInt32 DicSize;
+ #ifdef COMPRESS_MT
+ UInt32 NumThreads;
+ #endif
+ bool PasswordIsDefined;
+ AString Password;
+ bool IsAesMode;
+ Byte AesKeyMode;
+
+ CCompressionMethodMode():
+ NumMatchFinderCyclesDefined(false),
+ PasswordIsDefined(false),
+ IsAesMode(false),
+ AesKeyMode(3)
+ {}
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandler.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandler.cpp
new file mode 100644
index 000000000..a8b8bee47
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandler.cpp
@@ -0,0 +1,823 @@
+// ZipHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../IPassword.h"
+
+#include "../../Common/FilterCoder.h"
+#include "../../Common/ProgressUtils.h"
+#include "../../Common/StreamObjects.h"
+#include "../../Common/StreamUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+#include "../../Compress/LzmaDecoder.h"
+#include "../../Compress/ImplodeDecoder.h"
+#include "../../Compress/ShrinkDecoder.h"
+
+#include "../../Crypto/WzAes.h"
+#include "../../Crypto/ZipCrypto.h"
+#include "../../Crypto/ZipStrong.h"
+
+#include "../Common/ItemNameUtils.h"
+#include "../Common/OutStreamWithCRC.h"
+
+#include "ZipHandler.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NZip {
+
+static const CMethodId kMethodId_ZipBase = 0x040100;
+static const CMethodId kMethodId_BZip2 = 0x040202;
+
+static const char *kHostOS[] =
+{
+ "FAT",
+ "AMIGA",
+ "VMS",
+ "Unix",
+ "VM/CMS",
+ "Atari",
+ "HPFS",
+ "Macintosh",
+ "Z-System",
+ "CP/M",
+ "TOPS-20",
+ "NTFS",
+ "SMS/QDOS",
+ "Acorn",
+ "VFAT",
+ "MVS",
+ "BeOS",
+ "Tandem",
+ "OS/400",
+ "OS/X"
+};
+
+static const char *kUnknownOS = "Unknown";
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+
+ { NULL, kpidAttrib, VT_UI4},
+
+ { NULL, kpidEncrypted, VT_BOOL},
+ { NULL, kpidComment, VT_BSTR},
+
+ { NULL, kpidCRC, VT_UI4},
+
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidHostOS, VT_BSTR}
+
+ // { NULL, kpidUnpackVer, VT_UI1},
+};
+
+const char *kMethods[] =
+{
+ "Store",
+ "Shrink",
+ "Reduced1",
+ "Reduced2",
+ "Reduced2",
+ "Reduced3",
+ "Implode",
+ "Tokenizing",
+ "Deflate",
+ "Deflate64",
+ "PKImploding"
+};
+
+const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
+const char *kBZip2Method = "BZip2";
+const char *kLZMAMethod = "LZMA";
+const char *kJpegMethod = "Jpeg";
+const char *kWavPackMethod = "WavPack";
+const char *kPPMdMethod = "PPMd";
+const char *kAESMethod = "AES";
+const char *kZipCryptoMethod = "ZipCrypto";
+const char *kStrongCryptoMethod = "StrongCrypto";
+
+struct CStrongCryptoPair
+{
+ UInt16 Id;
+ const char *Name;
+};
+
+CStrongCryptoPair g_StrongCryptoPairs[] =
+{
+ { NStrongCryptoFlags::kDES, "DES" },
+ { NStrongCryptoFlags::kRC2old, "RC2a" },
+ { NStrongCryptoFlags::k3DES168, "3DES-168" },
+ { NStrongCryptoFlags::k3DES112, "3DES-112" },
+ { NStrongCryptoFlags::kAES128, "pkAES-128" },
+ { NStrongCryptoFlags::kAES192, "pkAES-192" },
+ { NStrongCryptoFlags::kAES256, "pkAES-256" },
+ { NStrongCryptoFlags::kRC2, "RC2" },
+ { NStrongCryptoFlags::kBlowfish, "Blowfish" },
+ { NStrongCryptoFlags::kTwofish, "Twofish" },
+ { NStrongCryptoFlags::kRC4, "RC4" }
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidBit64, VT_BOOL},
+ { NULL, kpidComment, VT_BSTR}
+};
+
+CHandler::CHandler()
+{
+ InitMethodProperties();
+}
+
+static AString BytesToString(const CByteBuffer &data)
+{
+ AString s;
+ int size = (int)data.GetCapacity();
+ if (size > 0)
+ {
+ char *p = s.GetBuffer(size + 1);
+ memcpy(p, (const Byte *)data, size);
+ p[size] = '\0';
+ s.ReleaseBuffer();
+ }
+ return s;
+}
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidBit64: if (m_Archive.IsZip64) prop = m_Archive.IsZip64; break;
+ case kpidComment:
+ prop = MultiByteToUnicodeString(BytesToString(m_Archive.m_ArchiveInfo.Comment), CP_ACP);
+ break;
+ }
+ prop.Detach(value);
+ COM_TRY_END
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = m_Items.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItemEx &item = m_Items[index];
+ switch(propID)
+ {
+ case kpidPath: prop = NItemName::GetOSName2(item.GetUnicodeString(item.Name)); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.UnPackSize; break;
+ case kpidPackSize: prop = item.PackSize; break;
+ case kpidTimeType:
+ {
+ FILETIME ft;
+ UInt32 unixTime;
+ if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kMTime, ft))
+ prop = (UInt32)NFileTimeType::kWindows;
+ else if (item.CentralExtra.GetUnixTime(NFileHeader::NUnixTime::kMTime, unixTime))
+ prop = (UInt32)NFileTimeType::kUnix;
+ else
+ prop = (UInt32)NFileTimeType::kDOS;
+ break;
+ }
+ case kpidCTime:
+ {
+ FILETIME ft;
+ if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kCTime, ft))
+ prop = ft;
+ break;
+ }
+ case kpidATime:
+ {
+ FILETIME ft;
+ if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kATime, ft))
+ prop = ft;
+ break;
+ }
+ case kpidMTime:
+ {
+ FILETIME utc;
+ if (!item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kMTime, utc))
+ {
+ UInt32 unixTime;
+ if (item.CentralExtra.GetUnixTime(NFileHeader::NUnixTime::kMTime, unixTime))
+ NTime::UnixTimeToFileTime(unixTime, utc);
+ else
+ {
+ FILETIME localFileTime;
+ if (!NTime::DosTimeToFileTime(item.Time, localFileTime) ||
+ !LocalFileTimeToFileTime(&localFileTime, &utc))
+ utc.dwHighDateTime = utc.dwLowDateTime = 0;
+ }
+ }
+ prop = utc;
+ break;
+ }
+ case kpidAttrib: prop = item.GetWinAttributes(); break;
+ case kpidEncrypted: prop = item.IsEncrypted(); break;
+ case kpidComment: prop = item.GetUnicodeString(BytesToString(item.Comment)); break;
+ case kpidCRC: if (item.IsThereCrc()) prop = item.FileCRC; break;
+ case kpidMethod:
+ {
+ UInt16 methodId = item.CompressionMethod;
+ AString method;
+ if (item.IsEncrypted())
+ {
+ if (methodId == NFileHeader::NCompressionMethod::kWzAES)
+ {
+ method = kAESMethod;
+ CWzAesExtraField aesField;
+ if (item.CentralExtra.GetWzAesField(aesField))
+ {
+ method += '-';
+ char s[32];
+ ConvertUInt64ToString((aesField.Strength + 1) * 64 , s);
+ method += s;
+ method += ' ';
+ methodId = aesField.Method;
+ }
+ }
+ else
+ {
+ if (item.IsStrongEncrypted())
+ {
+ CStrongCryptoField f;
+ bool finded = false;
+ if (item.CentralExtra.GetStrongCryptoField(f))
+ {
+ for (unsigned int i = 0; i < sizeof(g_StrongCryptoPairs) / sizeof(g_StrongCryptoPairs[0]); i++)
+ {
+ const CStrongCryptoPair &pair = g_StrongCryptoPairs[i];
+ if (f.AlgId == pair.Id)
+ {
+ method += pair.Name;
+ finded = true;
+ break;
+ }
+ }
+ }
+ if (!finded)
+ method += kStrongCryptoMethod;
+ }
+ else
+ method += kZipCryptoMethod;
+ method += ' ';
+ }
+ }
+ if (methodId < kNumMethods)
+ method += kMethods[methodId];
+ else switch (methodId)
+ {
+ case NFileHeader::NCompressionMethod::kLZMA:
+ method += kLZMAMethod;
+ if (item.IsLzmaEOS())
+ method += ":EOS";
+ break;
+ case NFileHeader::NCompressionMethod::kBZip2: method += kBZip2Method; break;
+ case NFileHeader::NCompressionMethod::kJpeg: method += kJpegMethod; break;
+ case NFileHeader::NCompressionMethod::kWavPack: method += kWavPackMethod; break;
+ case NFileHeader::NCompressionMethod::kPPMd: method += kPPMdMethod; break;
+ default:
+ {
+ char s[32];
+ ConvertUInt64ToString(methodId, s);
+ method += s;
+ }
+ }
+ prop = method;
+ break;
+ }
+ case kpidHostOS:
+ prop = (item.MadeByVersion.HostOS < sizeof(kHostOS) / sizeof(kHostOS[0])) ?
+ (kHostOS[item.MadeByVersion.HostOS]) : kUnknownOS;
+ break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CProgressImp: public CProgressVirt
+{
+ CMyComPtr<IArchiveOpenCallback> _callback;
+public:
+ STDMETHOD(SetTotal)(UInt64 numFiles);
+ STDMETHOD(SetCompleted)(UInt64 numFiles);
+ CProgressImp(IArchiveOpenCallback *callback): _callback(callback) {}
+};
+
+STDMETHODIMP CProgressImp::SetTotal(UInt64 numFiles)
+{
+ if (_callback)
+ return _callback->SetTotal(&numFiles, NULL);
+ return S_OK;
+}
+
+STDMETHODIMP CProgressImp::SetCompleted(UInt64 numFiles)
+{
+ if (_callback)
+ return _callback->SetCompleted(&numFiles, NULL);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ try
+ {
+ Close();
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ RINOK(m_Archive.Open(inStream, maxCheckStartPosition));
+ CProgressImp progressImp(callback);
+ return m_Archive.ReadHeaders(m_Items, &progressImp);
+ }
+ catch(const CInArchiveException &) { Close(); return S_FALSE; }
+ catch(...) { Close(); throw; }
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ m_Items.Clear();
+ m_Archive.Close();
+ return S_OK;
+}
+
+//////////////////////////////////////
+// CHandler::DecompressItems
+
+class CLzmaDecoder:
+ public ICompressCoder,
+ public CMyUnknownImp
+{
+ NCompress::NLzma::CDecoder *DecoderSpec;
+ CMyComPtr<ICompressCoder> Decoder;
+public:
+ CLzmaDecoder();
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ MY_UNKNOWN_IMP
+};
+
+CLzmaDecoder::CLzmaDecoder()
+{
+ DecoderSpec = new NCompress::NLzma::CDecoder;
+ Decoder = DecoderSpec;
+}
+
+HRESULT CLzmaDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ Byte buf[9];
+ RINOK(ReadStream_FALSE(inStream, buf, 9));
+ if (buf[2] != 5 || buf[3] != 0)
+ return E_NOTIMPL;
+ RINOK(DecoderSpec->SetDecoderProperties2(buf + 4, 5));
+ return Decoder->Code(inStream, outStream, NULL, outSize, progress);
+}
+
+struct CMethodItem
+{
+ UInt16 ZipMethod;
+ CMyComPtr<ICompressCoder> Coder;
+};
+
+class CZipDecoder
+{
+ NCrypto::NZip::CDecoder *_zipCryptoDecoderSpec;
+ NCrypto::NZipStrong::CDecoder *_pkAesDecoderSpec;
+ NCrypto::NWzAes::CDecoder *_wzAesDecoderSpec;
+
+ CMyComPtr<ICompressFilter> _zipCryptoDecoder;
+ CMyComPtr<ICompressFilter> _pkAesDecoder;
+ CMyComPtr<ICompressFilter> _wzAesDecoder;
+
+ CFilterCoder *filterStreamSpec;
+ CMyComPtr<ISequentialInStream> filterStream;
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
+ CObjectVector<CMethodItem> methodItems;
+
+public:
+ CZipDecoder():
+ _zipCryptoDecoderSpec(0),
+ _pkAesDecoderSpec(0),
+ _wzAesDecoderSpec(0),
+ filterStreamSpec(0) {}
+
+ HRESULT Decode(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CInArchive &archive, const CItemEx &item,
+ ISequentialOutStream *realOutStream,
+ IArchiveExtractCallback *extractCallback,
+ ICompressProgressInfo *compressProgress,
+ UInt32 numThreads, Int32 &res);
+};
+
+HRESULT CZipDecoder::Decode(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CInArchive &archive, const CItemEx &item,
+ ISequentialOutStream *realOutStream,
+ IArchiveExtractCallback *extractCallback,
+ ICompressProgressInfo *compressProgress,
+ UInt32 numThreads, Int32 &res)
+{
+ res = NArchive::NExtract::NOperationResult::kDataError;
+ CInStreamReleaser inStreamReleaser;
+
+ bool needCRC = true;
+ bool wzAesMode = false;
+ bool pkAesMode = false;
+ UInt16 methodId = item.CompressionMethod;
+ if (item.IsEncrypted())
+ {
+ if (item.IsStrongEncrypted())
+ {
+ CStrongCryptoField f;
+ if (item.CentralExtra.GetStrongCryptoField(f))
+ {
+ pkAesMode = true;
+ }
+ if (!pkAesMode)
+ {
+ res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ return S_OK;
+ }
+ }
+ if (methodId == NFileHeader::NCompressionMethod::kWzAES)
+ {
+ CWzAesExtraField aesField;
+ if (item.CentralExtra.GetWzAesField(aesField))
+ {
+ wzAesMode = true;
+ needCRC = aesField.NeedCrc();
+ }
+ }
+ }
+
+ COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
+ CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
+ outStreamSpec->SetStream(realOutStream);
+ outStreamSpec->Init(needCRC);
+
+ UInt64 authenticationPos;
+
+ CMyComPtr<ISequentialInStream> inStream;
+ {
+ UInt64 packSize = item.PackSize;
+ if (wzAesMode)
+ {
+ if (packSize < NCrypto::NWzAes::kMacSize)
+ return S_OK;
+ packSize -= NCrypto::NWzAes::kMacSize;
+ }
+ UInt64 dataPos = item.GetDataPosition();
+ inStream.Attach(archive.CreateLimitedStream(dataPos, packSize));
+ authenticationPos = dataPos + packSize;
+ }
+
+ CMyComPtr<ICompressFilter> cryptoFilter;
+ if (item.IsEncrypted())
+ {
+ if (wzAesMode)
+ {
+ CWzAesExtraField aesField;
+ if (!item.CentralExtra.GetWzAesField(aesField))
+ return S_OK;
+ methodId = aesField.Method;
+ if (!_wzAesDecoder)
+ {
+ _wzAesDecoderSpec = new NCrypto::NWzAes::CDecoder;
+ _wzAesDecoder = _wzAesDecoderSpec;
+ }
+ cryptoFilter = _wzAesDecoder;
+ Byte properties = aesField.Strength;
+ RINOK(_wzAesDecoderSpec->SetDecoderProperties2(&properties, 1));
+ }
+ else if (pkAesMode)
+ {
+ if (!_pkAesDecoder)
+ {
+ _pkAesDecoderSpec = new NCrypto::NZipStrong::CDecoder;
+ _pkAesDecoder = _pkAesDecoderSpec;
+ }
+ cryptoFilter = _pkAesDecoder;
+ }
+ else
+ {
+ if (!_zipCryptoDecoder)
+ {
+ _zipCryptoDecoderSpec = new NCrypto::NZip::CDecoder;
+ _zipCryptoDecoder = _zipCryptoDecoderSpec;
+ }
+ cryptoFilter = _zipCryptoDecoder;
+ }
+ CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
+ RINOK(cryptoFilter.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword));
+
+ if (!getTextPassword)
+ extractCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getTextPassword);
+
+ if (getTextPassword)
+ {
+ CMyComBSTR password;
+ RINOK(getTextPassword->CryptoGetTextPassword(&password));
+ AString charPassword;
+ if (wzAesMode || pkAesMode)
+ {
+ charPassword = UnicodeStringToMultiByte((const wchar_t *)password, CP_ACP);
+ /*
+ for (int i = 0;; i++)
+ {
+ wchar_t c = password[i];
+ if (c == 0)
+ break;
+ if (c >= 0x80)
+ {
+ res = NArchive::NExtract::NOperationResult::kDataError;
+ return S_OK;
+ }
+ charPassword += (char)c;
+ }
+ */
+ }
+ else
+ {
+ // we use OEM. WinZip/Windows probably use ANSI for some files
+ charPassword = UnicodeStringToMultiByte((const wchar_t *)password, CP_OEMCP);
+ }
+ HRESULT result = cryptoSetPassword->CryptoSetPassword(
+ (const Byte *)(const char *)charPassword, charPassword.Length());
+ if (result != S_OK)
+ return S_OK;
+ }
+ else
+ {
+ RINOK(cryptoSetPassword->CryptoSetPassword(0, 0));
+ }
+ }
+
+ int m;
+ for (m = 0; m < methodItems.Size(); m++)
+ if (methodItems[m].ZipMethod == methodId)
+ break;
+
+ if (m == methodItems.Size())
+ {
+ CMethodItem mi;
+ mi.ZipMethod = methodId;
+ if (methodId == NFileHeader::NCompressionMethod::kStored)
+ mi.Coder = new NCompress::CCopyCoder;
+ else if (methodId == NFileHeader::NCompressionMethod::kShrunk)
+ mi.Coder = new NCompress::NShrink::CDecoder;
+ else if (methodId == NFileHeader::NCompressionMethod::kImploded)
+ mi.Coder = new NCompress::NImplode::NDecoder::CCoder;
+ else if (methodId == NFileHeader::NCompressionMethod::kLZMA)
+ mi.Coder = new CLzmaDecoder;
+ else
+ {
+ CMethodId szMethodID;
+ if (methodId == NFileHeader::NCompressionMethod::kBZip2)
+ szMethodID = kMethodId_BZip2;
+ else
+ {
+ if (methodId > 0xFF)
+ {
+ res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ return S_OK;
+ }
+ szMethodID = kMethodId_ZipBase + (Byte)methodId;
+ }
+
+ RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS szMethodID, mi.Coder, false));
+
+ if (mi.Coder == 0)
+ {
+ res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ return S_OK;
+ }
+ }
+ m = methodItems.Add(mi);
+ }
+ ICompressCoder *coder = methodItems[m].Coder;
+
+ {
+ CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
+ coder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
+ if (setDecoderProperties)
+ {
+ Byte properties = (Byte)item.Flags;
+ RINOK(setDecoderProperties->SetDecoderProperties2(&properties, 1));
+ }
+ }
+
+ #ifdef COMPRESS_MT
+ {
+ CMyComPtr<ICompressSetCoderMt> setCoderMt;
+ coder->QueryInterface(IID_ICompressSetCoderMt, (void **)&setCoderMt);
+ if (setCoderMt)
+ {
+ RINOK(setCoderMt->SetNumberOfThreads(numThreads));
+ }
+ }
+ #endif
+
+ {
+ HRESULT result = S_OK;
+ CMyComPtr<ISequentialInStream> inStreamNew;
+ if (item.IsEncrypted())
+ {
+ if (!filterStream)
+ {
+ filterStreamSpec = new CFilterCoder;
+ filterStream = filterStreamSpec;
+ }
+ filterStreamSpec->Filter = cryptoFilter;
+ if (wzAesMode)
+ {
+ result = _wzAesDecoderSpec->ReadHeader(inStream);
+ }
+ else if (pkAesMode)
+ {
+ result =_pkAesDecoderSpec->ReadHeader(inStream, item.FileCRC, item.UnPackSize);
+ if (result == S_OK)
+ {
+ bool passwOK;
+ result = _pkAesDecoderSpec->CheckPassword(passwOK);
+ if (result == S_OK && !passwOK)
+ result = S_FALSE;
+ }
+ }
+ else
+ {
+ result = _zipCryptoDecoderSpec->ReadHeader(inStream);
+ }
+
+ if (result == S_OK)
+ {
+ RINOK(filterStreamSpec->SetInStream(inStream));
+ inStreamReleaser.FilterCoder = filterStreamSpec;
+ inStreamNew = filterStream;
+ if (wzAesMode)
+ {
+ if (!_wzAesDecoderSpec->CheckPasswordVerifyCode())
+ result = S_FALSE;
+ }
+ }
+ }
+ else
+ inStreamNew = inStream;
+ if (result == S_OK)
+ result = coder->Code(inStreamNew, outStream, NULL, &item.UnPackSize, compressProgress);
+ if (result == S_FALSE)
+ return S_OK;
+ if (result == E_NOTIMPL)
+ {
+ res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ return S_OK;
+ }
+
+ RINOK(result);
+ }
+ bool crcOK = true;
+ bool authOk = true;
+ if (needCRC)
+ crcOK = (outStreamSpec->GetCRC() == item.FileCRC);
+ if (wzAesMode)
+ {
+ inStream.Attach(archive.CreateLimitedStream(authenticationPos, NCrypto::NWzAes::kMacSize));
+ if (_wzAesDecoderSpec->CheckMac(inStream, authOk) != S_OK)
+ authOk = false;
+ }
+
+ res = ((crcOK && authOk) ?
+ NArchive::NExtract::NOperationResult::kOK :
+ NArchive::NExtract::NOperationResult::kCRCError);
+ return S_OK;
+}
+
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ CZipDecoder myDecoder;
+ bool testMode = (_aTestMode != 0);
+ UInt64 totalUnPacked = 0, totalPacked = 0;
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = m_Items.Size();
+ if(numItems == 0)
+ return S_OK;
+ UInt32 i;
+ for(i = 0; i < numItems; i++)
+ {
+ const CItemEx &item = m_Items[allFilesMode ? i : indices[i]];
+ totalUnPacked += item.UnPackSize;
+ totalPacked += item.PackSize;
+ }
+ RINOK(extractCallback->SetTotal(totalUnPacked));
+
+ UInt64 currentTotalUnPacked = 0, currentTotalPacked = 0;
+ UInt64 currentItemUnPacked, currentItemPacked;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ for (i = 0; i < numItems; i++, currentTotalUnPacked += currentItemUnPacked,
+ currentTotalPacked += currentItemPacked)
+ {
+ currentItemUnPacked = 0;
+ currentItemPacked = 0;
+
+ lps->InSize = currentTotalPacked;
+ lps->OutSize = currentTotalUnPacked;
+ RINOK(lps->SetCur());
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ CItemEx item = m_Items[index];
+ if (!item.FromLocal)
+ {
+ HRESULT res = m_Archive.ReadLocalItemAfterCdItem(item);
+ if (res == S_FALSE)
+ {
+ if (item.IsDir() || realOutStream || testMode)
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ }
+ continue;
+ }
+ RINOK(res);
+ }
+
+ if (item.IsDir() || item.IgnoreItem())
+ {
+ // if (!testMode)
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ }
+ continue;
+ }
+
+ currentItemUnPacked = item.UnPackSize;
+ currentItemPacked = item.PackSize;
+
+ if (!testMode && (!realOutStream))
+ continue;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ Int32 res;
+ RINOK(myDecoder.Decode(
+ EXTERNAL_CODECS_VARS
+ m_Archive, item, realOutStream, extractCallback,
+ progress, _numThreads, res));
+ realOutStream.Release();
+
+ RINOK(extractCallback->SetOperationResult(res))
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+IMPL_ISetCompressCodecsInfo
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandler.h
new file mode 100644
index 000000000..1a3a441a8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandler.h
@@ -0,0 +1,96 @@
+// Zip/Handler.h
+
+#ifndef __ZIP_HANDLER_H
+#define __ZIP_HANDLER_H
+
+#include "Common/DynamicBuffer.h"
+#include "../../ICoder.h"
+#include "../IArchive.h"
+
+#include "../../Common/CreateCoder.h"
+
+#include "ZipIn.h"
+#include "ZipCompressionMode.h"
+
+#ifdef COMPRESS_MT
+#include "../../../Windows/System.h"
+#endif
+
+namespace NArchive {
+namespace NZip {
+
+class CHandler:
+ public IInArchive,
+ public IOutArchive,
+ public ISetProperties,
+ PUBLIC_ISetCompressCodecsInfo
+ public CMyUnknownImp
+{
+public:
+ MY_QUERYINTERFACE_BEGIN2(IInArchive)
+ MY_QUERYINTERFACE_ENTRY(IOutArchive)
+ MY_QUERYINTERFACE_ENTRY(ISetProperties)
+ QUERY_ENTRY_ISetCompressCodecsInfo
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ INTERFACE_IInArchive(;)
+ INTERFACE_IOutArchive(;)
+
+ STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
+
+ DECL_ISetCompressCodecsInfo
+
+ CHandler();
+private:
+ CObjectVector<CItemEx> m_Items;
+ CInArchive m_Archive;
+
+ int m_Level;
+ int m_MainMethod;
+ UInt32 m_DicSize;
+ UInt32 m_Algo;
+ UInt32 m_NumPasses;
+ UInt32 m_NumFastBytes;
+ UInt32 m_NumMatchFinderCycles;
+ bool m_NumMatchFinderCyclesDefined;
+
+ bool m_ForceAesMode;
+ bool m_IsAesMode;
+ Byte m_AesKeyMode;
+
+ bool m_WriteNtfsTimeExtra;
+ bool m_ForseLocal;
+ bool m_ForseUtf8;
+
+ #ifdef COMPRESS_MT
+ UInt32 _numThreads;
+ #endif
+
+ DECL_EXTERNAL_CODECS_VARS
+
+ void InitMethodProperties()
+ {
+ m_Level = -1;
+ m_MainMethod = -1;
+ m_Algo =
+ m_DicSize =
+ m_NumPasses =
+ m_NumFastBytes =
+ m_NumMatchFinderCycles = 0xFFFFFFFF;
+ m_NumMatchFinderCyclesDefined = false;
+ m_ForceAesMode = false;
+ m_IsAesMode = false;
+ m_AesKeyMode = 3; // aes-256
+ m_WriteNtfsTimeExtra = false;
+ m_ForseLocal = false;
+ m_ForseUtf8 = false;
+ #ifdef COMPRESS_MT
+ _numThreads = NWindows::NSystem::GetNumberOfProcessors();;
+ #endif
+ }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
new file mode 100644
index 000000000..80d3572d0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -0,0 +1,508 @@
+// ZipHandlerOut.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../IPassword.h"
+
+#include "../../Common/OutBuffer.h"
+
+#include "../../Crypto/WzAes.h"
+
+#include "../Common/ItemNameUtils.h"
+#include "../Common/ParseProperties.h"
+
+#include "ZipHandler.h"
+#include "ZipUpdate.h"
+
+using namespace NWindows;
+using namespace NCOM;
+using namespace NTime;
+
+namespace NArchive {
+namespace NZip {
+
+static const UInt32 kLzAlgoX1 = 0;
+static const UInt32 kLzAlgoX5 = 1;
+
+static const UInt32 kDeflateNumPassesX1 = 1;
+static const UInt32 kDeflateNumPassesX7 = 3;
+static const UInt32 kDeflateNumPassesX9 = 10;
+
+static const UInt32 kDeflateNumFastBytesX1 = 32;
+static const UInt32 kDeflateNumFastBytesX7 = 64;
+static const UInt32 kDeflateNumFastBytesX9 = 128;
+
+static const wchar_t *kLzmaMatchFinderX1 = L"HC4";
+static const wchar_t *kLzmaMatchFinderX5 = L"BT4";
+
+static const UInt32 kLzmaNumFastBytesX1 = 32;
+static const UInt32 kLzmaNumFastBytesX7 = 64;
+
+static const UInt32 kLzmaDicSizeX1 = 1 << 16;
+static const UInt32 kLzmaDicSizeX3 = 1 << 20;
+static const UInt32 kLzmaDicSizeX5 = 1 << 24;
+static const UInt32 kLzmaDicSizeX7 = 1 << 25;
+static const UInt32 kLzmaDicSizeX9 = 1 << 26;
+
+static const UInt32 kBZip2NumPassesX1 = 1;
+static const UInt32 kBZip2NumPassesX7 = 2;
+static const UInt32 kBZip2NumPassesX9 = 7;
+
+static const UInt32 kBZip2DicSizeX1 = 100000;
+static const UInt32 kBZip2DicSizeX3 = 500000;
+static const UInt32 kBZip2DicSizeX5 = 900000;
+
+STDMETHODIMP CHandler::GetFileTimeType(UInt32 *timeType)
+{
+ *timeType = NFileTimeType::kDOS;
+ return S_OK;
+}
+
+static bool IsAsciiString(const UString &s)
+{
+ for (int i = 0; i < s.Length(); i++)
+ {
+ wchar_t c = s[i];
+ if (c < 0x20 || c > 0x7F)
+ return false;
+ }
+ return true;
+}
+
+#define COM_TRY_BEGIN2 try {
+#define COM_TRY_END2 } \
+catch(const CSystemException &e) { return e.ErrorCode; } \
+catch(...) { return E_OUTOFMEMORY; }
+
+static HRESULT GetTime(IArchiveUpdateCallback *callback, int index, PROPID propID, FILETIME &filetime)
+{
+ filetime.dwHighDateTime = filetime.dwLowDateTime = 0;
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(index, propID, &prop));
+ if (prop.vt == VT_FILETIME)
+ filetime = prop.filetime;
+ else if (prop.vt != VT_EMPTY)
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
+ IArchiveUpdateCallback *callback)
+{
+ COM_TRY_BEGIN2
+ CObjectVector<CUpdateItem> updateItems;
+ bool thereAreAesUpdates = false;
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ CUpdateItem ui;
+ Int32 newData;
+ Int32 newProperties;
+ UInt32 indexInArchive;
+ if (!callback)
+ return E_FAIL;
+ RINOK(callback->GetUpdateItemInfo(i, &newData, &newProperties, &indexInArchive));
+ ui.NewProperties = IntToBool(newProperties);
+ ui.NewData = IntToBool(newData);
+ ui.IndexInArchive = indexInArchive;
+ ui.IndexInClient = i;
+ bool existInArchive = (indexInArchive != UInt32(-1));
+ if (existInArchive && newData)
+ if (m_Items[indexInArchive].IsAesEncrypted())
+ thereAreAesUpdates = true;
+
+ if (IntToBool(newProperties))
+ {
+ UString name;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidAttrib, &prop));
+ if (prop.vt == VT_EMPTY)
+ ui.Attributes = 0;
+ else if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ else
+ ui.Attributes = prop.ulVal;
+ }
+
+ {
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidPath, &prop));
+ if (prop.vt == VT_EMPTY)
+ name.Empty();
+ else if (prop.vt != VT_BSTR)
+ return E_INVALIDARG;
+ else
+ name = prop.bstrVal;
+ }
+ {
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidIsDir, &prop));
+ if (prop.vt == VT_EMPTY)
+ ui.IsDir = false;
+ else if (prop.vt != VT_BOOL)
+ return E_INVALIDARG;
+ else
+ ui.IsDir = (prop.boolVal != VARIANT_FALSE);
+ }
+
+ {
+ CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidTimeType, &prop));
+ if (prop.vt == VT_UI4)
+ ui.NtfsTimeIsDefined = (prop.ulVal == NFileTimeType::kWindows);
+ else
+ ui.NtfsTimeIsDefined = m_WriteNtfsTimeExtra;
+ }
+ RINOK(GetTime(callback, i, kpidMTime, ui.NtfsMTime));
+ RINOK(GetTime(callback, i, kpidATime, ui.NtfsATime));
+ RINOK(GetTime(callback, i, kpidCTime, ui.NtfsCTime));
+
+ {
+ FILETIME localFileTime = { 0, 0 };
+ if (ui.NtfsMTime.dwHighDateTime != 0 ||
+ ui.NtfsMTime.dwLowDateTime != 0)
+ if (!FileTimeToLocalFileTime(&ui.NtfsMTime, &localFileTime))
+ return E_INVALIDARG;
+ FileTimeToDosTime(localFileTime, ui.Time);
+ }
+
+ name = NItemName::MakeLegalName(name);
+ bool needSlash = ui.IsDir;
+ const wchar_t kSlash = L'/';
+ if (!name.IsEmpty())
+ {
+ if (name[name.Length() - 1] == kSlash)
+ {
+ if (!ui.IsDir)
+ return E_INVALIDARG;
+ needSlash = false;
+ }
+ }
+ if (needSlash)
+ name += kSlash;
+
+ bool tryUtf8 = true;
+ if (m_ForseLocal || !m_ForseUtf8)
+ {
+//#ifdef _WIN32
+// bool defaultCharWasUsed;
+// ui.Name = UnicodeStringToMultiByte(name, CP_OEMCP, '_', defaultCharWasUsed);
+// tryUtf8 = (!m_ForseLocal && (defaultCharWasUsed ||
+// MultiByteToUnicodeString(ui.Name, CP_OEMCP) != name));
+//#else
+ // FIXME
+ ui.Name = UnicodeStringToMultiByte(name, CP_OEMCP);
+ tryUtf8 = (!m_ForseLocal);
+//#endif
+ }
+
+ if (tryUtf8)
+ {
+ int i;
+ for (i = 0; i < name.Length() && (unsigned)name[i] < 0x80; i++);
+ ui.IsUtf8 = (i != name.Length());
+ if (!ConvertUnicodeToUTF8(name, ui.Name))
+ return E_INVALIDARG;
+ }
+
+ if (ui.Name.Length() >= (1 << 16))
+ return E_INVALIDARG;
+
+ ui.IndexInClient = i;
+ /*
+ if (existInArchive)
+ {
+ const CItemEx &itemInfo = m_Items[indexInArchive];
+ // ui.Commented = itemInfo.IsCommented();
+ ui.Commented = false;
+ if (ui.Commented)
+ {
+ ui.CommentRange.Position = itemInfo.GetCommentPosition();
+ ui.CommentRange.Size = itemInfo.CommentSize;
+ }
+ }
+ else
+ ui.Commented = false;
+ */
+ }
+ if (IntToBool(newData))
+ {
+ UInt64 size;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(callback->GetProperty(i, kpidSize, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ size = prop.uhVal.QuadPart;
+ }
+ ui.Size = size;
+ }
+ updateItems.Add(ui);
+ }
+
+ CMyComPtr<ICryptoGetTextPassword2> getTextPassword;
+ {
+ CMyComPtr<IArchiveUpdateCallback> udateCallBack2(callback);
+ udateCallBack2.QueryInterface(IID_ICryptoGetTextPassword2, &getTextPassword);
+ }
+ CCompressionMethodMode options;
+
+ if (getTextPassword)
+ {
+ CMyComBSTR password;
+ Int32 passwordIsDefined;
+ RINOK(getTextPassword->CryptoGetTextPassword2(&passwordIsDefined, &password));
+ options.PasswordIsDefined = IntToBool(passwordIsDefined);
+ if (options.PasswordIsDefined)
+ {
+ options.IsAesMode = (m_ForceAesMode ? m_IsAesMode : thereAreAesUpdates);
+ options.AesKeyMode = m_AesKeyMode;
+
+ if (!IsAsciiString((const wchar_t *)password))
+ return E_INVALIDARG;
+ if (options.IsAesMode)
+ {
+ if (static_cast< unsigned int >( options.Password.Length() ) > NCrypto::NWzAes::kPasswordSizeMax)
+ return E_INVALIDARG;
+ }
+ options.Password = UnicodeStringToMultiByte((const wchar_t *)password, CP_OEMCP);
+ }
+ }
+ else
+ options.PasswordIsDefined = false;
+
+ int level = m_Level;
+ if (level < 0)
+ level = 5;
+
+ Byte mainMethod;
+ if (m_MainMethod < 0)
+ mainMethod = (Byte)(((level == 0) ?
+ NFileHeader::NCompressionMethod::kStored :
+ NFileHeader::NCompressionMethod::kDeflated));
+ else
+ mainMethod = (Byte)m_MainMethod;
+ options.MethodSequence.Add(mainMethod);
+ if (mainMethod != NFileHeader::NCompressionMethod::kStored)
+ options.MethodSequence.Add(NFileHeader::NCompressionMethod::kStored);
+ bool isDeflate = (mainMethod == NFileHeader::NCompressionMethod::kDeflated) ||
+ (mainMethod == NFileHeader::NCompressionMethod::kDeflated64);
+ bool isLZMA = (mainMethod == NFileHeader::NCompressionMethod::kLZMA);
+ bool isLz = (isLZMA || isDeflate);
+ bool isBZip2 = (mainMethod == NFileHeader::NCompressionMethod::kBZip2);
+ options.NumPasses = m_NumPasses;
+ options.DicSize = m_DicSize;
+ options.NumFastBytes = m_NumFastBytes;
+ options.NumMatchFinderCycles = m_NumMatchFinderCycles;
+ options.NumMatchFinderCyclesDefined = m_NumMatchFinderCyclesDefined;
+ options.Algo = m_Algo;
+ #ifdef COMPRESS_MT
+ options.NumThreads = _numThreads;
+ #endif
+ if (isLz)
+ {
+ if (isDeflate)
+ {
+ if (options.NumPasses == 0xFFFFFFFF)
+ options.NumPasses = (level >= 9 ? kDeflateNumPassesX9 :
+ (level >= 7 ? kDeflateNumPassesX7 :
+ kDeflateNumPassesX1));
+ if (options.NumFastBytes == 0xFFFFFFFF)
+ options.NumFastBytes = (level >= 9 ? kDeflateNumFastBytesX9 :
+ (level >= 7 ? kDeflateNumFastBytesX7 :
+ kDeflateNumFastBytesX1));
+ }
+ else if (isLZMA)
+ {
+ if (options.DicSize == 0xFFFFFFFF)
+ options.DicSize =
+ (level >= 9 ? kLzmaDicSizeX9 :
+ (level >= 7 ? kLzmaDicSizeX7 :
+ (level >= 5 ? kLzmaDicSizeX5 :
+ (level >= 3 ? kLzmaDicSizeX3 :
+ kLzmaDicSizeX1))));
+
+ if (options.NumFastBytes == 0xFFFFFFFF)
+ options.NumFastBytes = (level >= 7 ? kLzmaNumFastBytesX7 :
+ kLzmaNumFastBytesX1);
+
+ options.MatchFinder =
+ (level >= 5 ? kLzmaMatchFinderX5 :
+ kLzmaMatchFinderX1);
+ }
+
+ if (options.Algo == 0xFFFFFFFF)
+ options.Algo = (level >= 5 ? kLzAlgoX5 :
+ kLzAlgoX1);
+ }
+ if (isBZip2)
+ {
+ if (options.NumPasses == 0xFFFFFFFF)
+ options.NumPasses = (level >= 9 ? kBZip2NumPassesX9 :
+ (level >= 7 ? kBZip2NumPassesX7 :
+ kBZip2NumPassesX1));
+ if (options.DicSize == 0xFFFFFFFF)
+ options.DicSize = (level >= 5 ? kBZip2DicSizeX5 :
+ (level >= 3 ? kBZip2DicSizeX3 :
+ kBZip2DicSizeX1));
+ }
+
+ return Update(
+ EXTERNAL_CODECS_VARS
+ m_Items, updateItems, outStream,
+ m_Archive.IsOpen() ? &m_Archive : NULL, &options, callback);
+ COM_TRY_END2
+}
+
+STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
+{
+ #ifdef COMPRESS_MT
+ const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
+ _numThreads = numProcessors;
+ #endif
+ InitMethodProperties();
+ for (int i = 0; i < numProperties; i++)
+ {
+ UString name = UString(names[i]);
+ name.MakeUpper();
+ if (name.IsEmpty())
+ return E_INVALIDARG;
+
+ const PROPVARIANT &prop = values[i];
+
+ if (name[0] == L'X')
+ {
+ UInt32 level = 9;
+ RINOK(ParsePropValue(name.Mid(1), prop, level));
+ m_Level = level;
+ continue;
+ }
+ else if (name == L"M")
+ {
+ if (prop.vt == VT_BSTR)
+ {
+ UString m = prop.bstrVal;
+ m.MakeUpper();
+ if (m == L"COPY") m_MainMethod = NFileHeader::NCompressionMethod::kStored;
+ else if (m == L"DEFLATE") m_MainMethod = NFileHeader::NCompressionMethod::kDeflated;
+ else if (m == L"DEFLATE64") m_MainMethod = NFileHeader::NCompressionMethod::kDeflated64;
+ else if (m == L"BZIP2") m_MainMethod = NFileHeader::NCompressionMethod::kBZip2;
+ else if (m == L"LZMA") m_MainMethod = NFileHeader::NCompressionMethod::kLZMA;
+ else return E_INVALIDARG;
+ }
+ else if (prop.vt == VT_UI4)
+ {
+ switch(prop.ulVal)
+ {
+ case NFileHeader::NCompressionMethod::kStored:
+ case NFileHeader::NCompressionMethod::kDeflated:
+ case NFileHeader::NCompressionMethod::kDeflated64:
+ case NFileHeader::NCompressionMethod::kBZip2:
+ case NFileHeader::NCompressionMethod::kLZMA:
+ m_MainMethod = (Byte)prop.ulVal;
+ break;
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ else
+ return E_INVALIDARG;
+ }
+ else if (name.Left(2) == L"EM")
+ {
+ if (prop.vt == VT_BSTR)
+ {
+ UString valueString = prop.bstrVal;
+ valueString.MakeUpper();
+ if (valueString.Left(3) == L"AES")
+ {
+ valueString = valueString.Mid(3);
+ if (valueString == L"128")
+ m_AesKeyMode = 1;
+ else if (valueString == L"192")
+ m_AesKeyMode = 2;
+ else if (valueString == L"256" || valueString.IsEmpty())
+ m_AesKeyMode = 3;
+ else
+ return E_INVALIDARG;
+ m_IsAesMode = true;
+ m_ForceAesMode = true;
+ }
+ else if (valueString == L"ZIPCRYPTO")
+ {
+ m_IsAesMode = false;
+ m_ForceAesMode = true;
+ }
+ else
+ return E_INVALIDARG;
+ }
+ else
+ return E_INVALIDARG;
+ }
+ else if (name[0] == L'D')
+ {
+ UInt32 dicSize = kBZip2DicSizeX5;
+ RINOK(ParsePropDictionaryValue(name.Mid(1), prop, dicSize));
+ m_DicSize = dicSize;
+ }
+ else if (name.Left(4) == L"PASS")
+ {
+ UInt32 num = kDeflateNumPassesX9;
+ RINOK(ParsePropValue(name.Mid(4), prop, num));
+ m_NumPasses = num;
+ }
+ else if (name.Left(2) == L"FB")
+ {
+ UInt32 num = kDeflateNumFastBytesX9;
+ RINOK(ParsePropValue(name.Mid(2), prop, num));
+ m_NumFastBytes = num;
+ }
+ else if (name.Left(2) == L"MC")
+ {
+ UInt32 num = 0xFFFFFFFF;
+ RINOK(ParsePropValue(name.Mid(2), prop, num));
+ m_NumMatchFinderCycles = num;
+ m_NumMatchFinderCyclesDefined = true;
+ }
+ else if (name.Left(2) == L"MT")
+ {
+ #ifdef COMPRESS_MT
+ RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
+ #endif
+ }
+ else if (name.Left(1) == L"A")
+ {
+ UInt32 num = kLzAlgoX5;
+ RINOK(ParsePropValue(name.Mid(1), prop, num));
+ m_Algo = num;
+ }
+ else if (name.CompareNoCase(L"TC") == 0)
+ {
+ RINOK(SetBoolProperty(m_WriteNtfsTimeExtra, prop));
+ }
+ else if (name.CompareNoCase(L"CL") == 0)
+ {
+ RINOK(SetBoolProperty(m_ForseLocal, prop));
+ if (m_ForseLocal)
+ m_ForseUtf8 = false;
+ }
+ else if (name.CompareNoCase(L"CU") == 0)
+ {
+ RINOK(SetBoolProperty(m_ForseUtf8, prop));
+ if (m_ForseUtf8)
+ m_ForseLocal = false;
+ }
+ else
+ return E_INVALIDARG;
+ }
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHeader.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHeader.cpp
new file mode 100644
index 000000000..582187b51
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHeader.cpp
@@ -0,0 +1,36 @@
+// Archive/Zip/Header.h
+
+#include "StdAfx.h"
+
+#include "ZipHeader.h"
+
+namespace NArchive {
+namespace NZip {
+
+namespace NSignature
+{
+ UInt32 kLocalFileHeader = 0x04034B50 + 1;
+ UInt32 kDataDescriptor = 0x08074B50 + 1;
+ UInt32 kCentralFileHeader = 0x02014B50 + 1;
+ UInt32 kEndOfCentralDir = 0x06054B50 + 1;
+ UInt32 kZip64EndOfCentralDir = 0x06064B50 + 1;
+ UInt32 kZip64EndOfCentralDirLocator = 0x07064B50 + 1;
+
+ class CMarkersInitializer
+ {
+ public:
+ CMarkersInitializer()
+ {
+ kLocalFileHeader--;
+ kDataDescriptor--;
+ kCentralFileHeader--;
+ kEndOfCentralDir--;
+ kZip64EndOfCentralDir--;
+ kZip64EndOfCentralDirLocator--;
+ }
+ };
+ static CMarkersInitializer g_MarkerInitializer;
+}
+
+}}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHeader.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHeader.h
new file mode 100644
index 000000000..4839f554d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipHeader.h
@@ -0,0 +1,276 @@
+// Archive/Zip/Header.h
+
+#ifndef __ARCHIVE_ZIP_HEADER_H
+#define __ARCHIVE_ZIP_HEADER_H
+
+#include "Common/Types.h"
+
+namespace NArchive {
+namespace NZip {
+
+namespace NSignature
+{
+ extern UInt32 kLocalFileHeader;
+ extern UInt32 kDataDescriptor;
+ extern UInt32 kCentralFileHeader;
+ extern UInt32 kEndOfCentralDir;
+ extern UInt32 kZip64EndOfCentralDir;
+ extern UInt32 kZip64EndOfCentralDirLocator;
+
+ static const UInt32 kMarkerSize = 4;
+}
+
+const UInt32 kEcdSize = 22;
+const UInt32 kZip64EcdSize = 44;
+const UInt32 kZip64EcdLocatorSize = 20;
+/*
+struct CEndOfCentralDirectoryRecord
+{
+ UInt16 ThisDiskNumber;
+ UInt16 StartCentralDirectoryDiskNumber;
+ UInt16 NumEntriesInCentaralDirectoryOnThisDisk;
+ UInt16 NumEntriesInCentaralDirectory;
+ UInt32 CentralDirectorySize;
+ UInt32 CentralDirectoryStartOffset;
+ UInt16 CommentSize;
+};
+
+struct CEndOfCentralDirectoryRecordFull
+{
+ UInt32 Signature;
+ CEndOfCentralDirectoryRecord Header;
+};
+*/
+
+namespace NFileHeader
+{
+ /*
+ struct CVersion
+ {
+ Byte Version;
+ Byte HostOS;
+ };
+ */
+
+ namespace NCompressionMethod
+ {
+ enum EType
+ {
+ kStored = 0,
+ kShrunk = 1,
+ kReduced1 = 2,
+ kReduced2 = 3,
+ kReduced3 = 4,
+ kReduced4 = 5,
+ kImploded = 6,
+ kReservedTokenizing = 7, // reserved for tokenizing
+ kDeflated = 8,
+ kDeflated64 = 9,
+ kPKImploding = 10,
+
+ kBZip2 = 12,
+ kLZMA = 14,
+ kTerse = 18,
+ kLz77 = 19,
+ kJpeg = 0x60,
+ kWavPack = 0x61,
+ kPPMd = 0x62,
+ kWzAES = 0x63
+ };
+ const int kNumCompressionMethods = 11;
+ const Byte kMadeByProgramVersion = 20;
+
+ const Byte kDeflateExtractVersion = 20;
+ const Byte kStoreExtractVersion = 10;
+
+ const Byte kSupportedVersion = 20;
+ }
+
+ namespace NExtraID
+ {
+ enum
+ {
+ kZip64 = 0x01,
+ kNTFS = 0x0A,
+ kStrongEncrypt = 0x17,
+ kUnixTime = 0x5455,
+ kWzAES = 0x9901
+ };
+ }
+
+ namespace NNtfsExtra
+ {
+ const UInt16 kTagTime = 1;
+ enum
+ {
+ kMTime = 0,
+ kATime,
+ kCTime
+ };
+ }
+
+ namespace NUnixTime
+ {
+ enum
+ {
+ kMTime = 0,
+ kATime,
+ kCTime
+ };
+ }
+
+ const UInt32 kLocalBlockSize = 26;
+ /*
+ struct CLocalBlock
+ {
+ CVersion ExtractVersion;
+
+ UInt16 Flags;
+ UInt16 CompressionMethod;
+ UInt32 Time;
+ UInt32 FileCRC;
+ UInt32 PackSize;
+ UInt32 UnPackSize;
+ UInt16 NameSize;
+ UInt16 ExtraSize;
+ };
+ */
+
+ const UInt32 kDataDescriptorSize = 16;
+ // const UInt32 kDataDescriptor64Size = 16 + 8;
+ /*
+ struct CDataDescriptor
+ {
+ UInt32 Signature;
+ UInt32 FileCRC;
+ UInt32 PackSize;
+ UInt32 UnPackSize;
+ };
+
+ struct CLocalBlockFull
+ {
+ UInt32 Signature;
+ CLocalBlock Header;
+ };
+ */
+
+ const UInt32 kCentralBlockSize = 42;
+ /*
+ struct CBlock
+ {
+ CVersion MadeByVersion;
+ CVersion ExtractVersion;
+ UInt16 Flags;
+ UInt16 CompressionMethod;
+ UInt32 Time;
+ UInt32 FileCRC;
+ UInt32 PackSize;
+ UInt32 UnPackSize;
+ UInt16 NameSize;
+ UInt16 ExtraSize;
+ UInt16 CommentSize;
+ UInt16 DiskNumberStart;
+ UInt16 InternalAttributes;
+ UInt32 ExternalAttributes;
+ UInt32 LocalHeaderOffset;
+ };
+
+ struct CBlockFull
+ {
+ UInt32 Signature;
+ CBlock Header;
+ };
+ */
+
+ namespace NFlags
+ {
+ const int kEncrypted = 1 << 0;
+ const int kLzmaEOS = 1 << 1;
+ const int kDescriptorUsedMask = 1 << 3;
+ const int kStrongEncrypted = 1 << 6;
+ const int kUtf8 = 1 << 11;
+
+ const int kImplodeDictionarySizeMask = 1 << 1;
+ const int kImplodeLiteralsOnMask = 1 << 2;
+
+ const int kDeflateTypeBitStart = 1;
+ const int kNumDeflateTypeBits = 2;
+ const int kNumDeflateTypes = (1 << kNumDeflateTypeBits);
+ const int kDeflateTypeMask = (1 << kNumDeflateTypeBits) - 1;
+ }
+
+ namespace NHostOS
+ {
+ enum EEnum
+ {
+ kFAT = 0,
+ kAMIGA = 1,
+ kVMS = 2, // VAX/VMS
+ kUnix = 3,
+ kVM_CMS = 4,
+ kAtari = 5, // what if it's a minix filesystem? [cjh]
+ kHPFS = 6, // filesystem used by OS/2 (and NT 3.x)
+ kMac = 7,
+ kZ_System = 8,
+ kCPM = 9,
+ kTOPS20 = 10, // pkzip 2.50 NTFS
+ kNTFS = 11, // filesystem used by Windows NT
+ kQDOS = 12, // SMS/QDOS
+ kAcorn = 13, // Archimedes Acorn RISC OS
+ kVFAT = 14, // filesystem used by Windows 95, NT
+ kMVS = 15,
+ kBeOS = 16, // hybrid POSIX/database filesystem
+ kTandem = 17,
+ kOS400 = 18,
+ kOSX = 19
+ };
+ }
+ namespace NUnixAttribute
+ {
+ const UInt32 kIFMT = 0170000; /* Unix file type mask */
+
+ const UInt32 kIFDIR = 0040000; /* Unix directory */
+ const UInt32 kIFREG = 0100000; /* Unix regular file */
+ const UInt32 kIFSOCK = 0140000; /* Unix socket (BSD, not SysV or Amiga) */
+ const UInt32 kIFLNK = 0120000; /* Unix symbolic link (not SysV, Amiga) */
+ const UInt32 kIFBLK = 0060000; /* Unix block special (not Amiga) */
+ const UInt32 kIFCHR = 0020000; /* Unix character special (not Amiga) */
+ const UInt32 kIFIFO = 0010000; /* Unix fifo (BCC, not MSC or Amiga) */
+
+ const UInt32 kISUID = 04000; /* Unix set user id on execution */
+ const UInt32 kISGID = 02000; /* Unix set group id on execution */
+ const UInt32 kISVTX = 01000; /* Unix directory permissions control */
+ const UInt32 kENFMT = kISGID; /* Unix record locking enforcement flag */
+ const UInt32 kIRWXU = 00700; /* Unix read, write, execute: owner */
+ const UInt32 kIRUSR = 00400; /* Unix read permission: owner */
+ const UInt32 kIWUSR = 00200; /* Unix write permission: owner */
+ const UInt32 kIXUSR = 00100; /* Unix execute permission: owner */
+ const UInt32 kIRWXG = 00070; /* Unix read, write, execute: group */
+ const UInt32 kIRGRP = 00040; /* Unix read permission: group */
+ const UInt32 kIWGRP = 00020; /* Unix write permission: group */
+ const UInt32 kIXGRP = 00010; /* Unix execute permission: group */
+ const UInt32 kIRWXO = 00007; /* Unix read, write, execute: other */
+ const UInt32 kIROTH = 00004; /* Unix read permission: other */
+ const UInt32 kIWOTH = 00002; /* Unix write permission: other */
+ const UInt32 kIXOTH = 00001; /* Unix execute permission: other */
+ }
+
+ namespace NAmigaAttribute
+ {
+ const UInt32 kIFMT = 06000; /* Amiga file type mask */
+ const UInt32 kIFDIR = 04000; /* Amiga directory */
+ const UInt32 kIFREG = 02000; /* Amiga regular file */
+ const UInt32 kIHIDDEN = 00200; /* to be supported in AmigaDOS 3.x */
+ const UInt32 kISCRIPT = 00100; /* executable script (text command file) */
+ const UInt32 kIPURE = 00040; /* allow loading into resident memory */
+ const UInt32 kIARCHIVE = 00020; /* not modified since bit was last set */
+ const UInt32 kIREAD = 00010; /* can be opened for reading */
+ const UInt32 kIWRITE = 00004; /* can be opened for writing */
+ const UInt32 kIEXECUTE = 00002; /* executable image, a loadable runfile */
+ const UInt32 kIDELETE = 00001; /* can be deleted */
+ }
+}
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipIn.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipIn.cpp
new file mode 100644
index 000000000..f6749b972
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipIn.cpp
@@ -0,0 +1,851 @@
+// Archive/ZipIn.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/CpuArch.h"
+
+#include "Common/DynamicBuffer.h"
+
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/StreamUtils.h"
+
+#include "ZipIn.h"
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+namespace NArchive {
+namespace NZip {
+
+HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
+{
+ _inBufMode = false;
+ Close();
+ RINOK(stream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition));
+ m_Position = m_StreamStartPosition;
+ RINOK(FindAndReadMarker(stream, searchHeaderSizeLimit));
+ RINOK(stream->Seek(m_Position, STREAM_SEEK_SET, NULL));
+ m_Stream = stream;
+ return S_OK;
+}
+
+void CInArchive::Close()
+{
+ _inBuffer.ReleaseStream();
+ m_Stream.Release();
+}
+
+HRESULT CInArchive::Seek(UInt64 offset)
+{
+ return m_Stream->Seek(offset, STREAM_SEEK_SET, NULL);
+}
+
+//////////////////////////////////////
+// Markers
+
+static inline bool TestMarkerCandidate(const Byte *p, UInt32 &value)
+{
+ value = Get32(p);
+ return
+ (value == NSignature::kLocalFileHeader) ||
+ (value == NSignature::kEndOfCentralDir);
+}
+
+static const UInt32 kNumMarkerAddtionalBytes = 2;
+static inline bool TestMarkerCandidate2(const Byte *p, UInt32 &value)
+{
+ value = Get32(p);
+ if (value == NSignature::kEndOfCentralDir)
+ return (Get16(p + 4) == 0);
+ return (value == NSignature::kLocalFileHeader && p[4] < 128);
+}
+
+HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
+{
+ m_ArchiveInfo.Clear();
+ m_Position = m_StreamStartPosition;
+
+ Byte marker[NSignature::kMarkerSize];
+ RINOK(ReadStream_FALSE(stream, marker, NSignature::kMarkerSize));
+ m_Position += NSignature::kMarkerSize;
+ if (TestMarkerCandidate(marker, m_Signature))
+ return S_OK;
+
+ CByteDynamicBuffer dynamicBuffer;
+ const UInt32 kSearchMarkerBufferSize = 0x10000;
+ dynamicBuffer.EnsureCapacity(kSearchMarkerBufferSize);
+ Byte *buffer = dynamicBuffer;
+ UInt32 numBytesPrev = NSignature::kMarkerSize - 1;
+ memcpy(buffer, marker + 1, numBytesPrev);
+ UInt64 curTestPos = m_StreamStartPosition + 1;
+ for (;;)
+ {
+ if (searchHeaderSizeLimit != NULL)
+ if (curTestPos - m_StreamStartPosition > *searchHeaderSizeLimit)
+ break;
+ size_t numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
+ RINOK(ReadStream(stream, buffer + numBytesPrev, &numReadBytes));
+ m_Position += numReadBytes;
+ UInt32 numBytesInBuffer = numBytesPrev + (UInt32)numReadBytes;
+ const UInt32 kMarker2Size = NSignature::kMarkerSize + kNumMarkerAddtionalBytes;
+ if (numBytesInBuffer < kMarker2Size)
+ break;
+ UInt32 numTests = numBytesInBuffer - kMarker2Size + 1;
+ for (UInt32 pos = 0; pos < numTests; pos++)
+ {
+ if (buffer[pos] != 0x50)
+ continue;
+ if (TestMarkerCandidate2(buffer + pos, m_Signature))
+ {
+ curTestPos += pos;
+ m_ArchiveInfo.StartPosition = curTestPos;
+ m_Position = curTestPos + NSignature::kMarkerSize;
+ return S_OK;
+ }
+ }
+ curTestPos += numTests;
+ numBytesPrev = numBytesInBuffer - numTests;
+ memmove(buffer, buffer + numTests, numBytesPrev);
+ }
+ return S_FALSE;
+}
+
+HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
+{
+ size_t realProcessedSize = size;
+ HRESULT result = S_OK;
+ if (_inBufMode)
+ {
+ try { realProcessedSize = _inBuffer.ReadBytes((Byte *)data, size); }
+ catch (const CInBufferException &e) { return e.ErrorCode; }
+ }
+ else
+ result = ReadStream(m_Stream, data, &realProcessedSize);
+ if (processedSize != NULL)
+ *processedSize = (UInt32)realProcessedSize;
+ m_Position += realProcessedSize;
+ return result;
+}
+
+void CInArchive::Skip(UInt64 num)
+{
+ for (UInt64 i = 0; i < num; i++)
+ ReadByte();
+}
+
+void CInArchive::IncreaseRealPosition(UInt64 addValue)
+{
+ if (m_Stream->Seek(addValue, STREAM_SEEK_CUR, &m_Position) != S_OK)
+ throw CInArchiveException(CInArchiveException::kSeekStreamError);
+}
+
+bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
+{
+ UInt32 realProcessedSize;
+ if (ReadBytes(data, size, &realProcessedSize) != S_OK)
+ throw CInArchiveException(CInArchiveException::kReadStreamError);
+ return (realProcessedSize == size);
+}
+
+void CInArchive::SafeReadBytes(void *data, UInt32 size)
+{
+ if (!ReadBytesAndTestSize(data, size))
+ throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
+}
+
+void CInArchive::ReadBuffer(CByteBuffer &buffer, UInt32 size)
+{
+ buffer.SetCapacity(size);
+ if (size > 0)
+ SafeReadBytes(buffer, size);
+}
+
+Byte CInArchive::ReadByte()
+{
+ Byte b;
+ SafeReadBytes(&b, 1);
+ return b;
+}
+
+UInt16 CInArchive::ReadUInt16()
+{
+ Byte buf[2];
+ SafeReadBytes(buf, 2);
+ return Get16(buf);
+}
+
+UInt32 CInArchive::ReadUInt32()
+{
+ Byte buf[4];
+ SafeReadBytes(buf, 4);
+ return Get32(buf);
+}
+
+UInt64 CInArchive::ReadUInt64()
+{
+ Byte buf[8];
+ SafeReadBytes(buf, 8);
+ return Get64(buf);
+}
+
+bool CInArchive::ReadUInt32(UInt32 &value)
+{
+ Byte buf[4];
+ if (!ReadBytesAndTestSize(buf, 4))
+ return false;
+ value = Get32(buf);
+ return true;
+}
+
+void CInArchive::ReadFileName(UInt32 nameSize, AString &dest)
+{
+ if (nameSize == 0)
+ dest.Empty();
+ char *p = dest.GetBuffer((int)nameSize);
+ SafeReadBytes(p, nameSize);
+ p[nameSize] = 0;
+ dest.ReleaseBuffer();
+}
+
+void CInArchive::GetArchiveInfo(CInArchiveInfo &archiveInfo) const
+{
+ archiveInfo = m_ArchiveInfo;
+}
+
+void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
+ UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber)
+{
+ extraBlock.Clear();
+ UInt32 remain = extraSize;
+ while(remain >= 4)
+ {
+ CExtraSubBlock subBlock;
+ subBlock.ID = ReadUInt16();
+ UInt32 dataSize = ReadUInt16();
+ remain -= 4;
+ if (dataSize > remain) // it's bug
+ dataSize = remain;
+ if (subBlock.ID == NFileHeader::NExtraID::kZip64)
+ {
+ if (unpackSize == 0xFFFFFFFF)
+ {
+ if (dataSize < 8)
+ break;
+ unpackSize = ReadUInt64();
+ remain -= 8;
+ dataSize -= 8;
+ }
+ if (packSize == 0xFFFFFFFF)
+ {
+ if (dataSize < 8)
+ break;
+ packSize = ReadUInt64();
+ remain -= 8;
+ dataSize -= 8;
+ }
+ if (localHeaderOffset == 0xFFFFFFFF)
+ {
+ if (dataSize < 8)
+ break;
+ localHeaderOffset = ReadUInt64();
+ remain -= 8;
+ dataSize -= 8;
+ }
+ if (diskStartNumber == 0xFFFF)
+ {
+ if (dataSize < 4)
+ break;
+ diskStartNumber = ReadUInt32();
+ remain -= 4;
+ dataSize -= 4;
+ }
+ for (UInt32 i = 0; i < dataSize; i++)
+ ReadByte();
+ }
+ else
+ {
+ ReadBuffer(subBlock.Data, dataSize);
+ extraBlock.SubBlocks.Add(subBlock);
+ }
+ remain -= dataSize;
+ }
+ Skip(remain);
+}
+
+HRESULT CInArchive::ReadLocalItem(CItemEx &item)
+{
+ const int kBufSize = 26;
+ Byte p[kBufSize];
+ SafeReadBytes(p, kBufSize);
+
+ item.ExtractVersion.Version = p[0];
+ item.ExtractVersion.HostOS = p[1];
+ item.Flags = Get16(p + 2);
+ item.CompressionMethod = Get16(p + 4);
+ item.Time = Get32(p + 6);
+ item.FileCRC = Get32(p + 10);
+ item.PackSize = Get32(p + 14);
+ item.UnPackSize = Get32(p + 18);
+ UInt32 fileNameSize = Get16(p + 22);
+ item.LocalExtraSize = Get16(p + 24);
+ ReadFileName(fileNameSize, item.Name);
+ item.FileHeaderWithNameSize = 4 + NFileHeader::kLocalBlockSize + fileNameSize;
+ if (item.LocalExtraSize > 0)
+ {
+ UInt64 localHeaderOffset = 0;
+ UInt32 diskStartNumber = 0;
+ ReadExtra(item.LocalExtraSize, item.LocalExtra, item.UnPackSize, item.PackSize,
+ localHeaderOffset, diskStartNumber);
+ }
+ /*
+ if (item.IsDir())
+ item.UnPackSize = 0; // check It
+ */
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadLocalItemAfterCdItem(CItemEx &item)
+{
+ if (item.FromLocal)
+ return S_OK;
+ try
+ {
+ RINOK(Seek(m_ArchiveInfo.Base + item.LocalHeaderPosition));
+ CItemEx localItem;
+ if (ReadUInt32() != NSignature::kLocalFileHeader)
+ return S_FALSE;
+ RINOK(ReadLocalItem(localItem));
+ if (item.Flags != localItem.Flags)
+ {
+ if (
+ (item.CompressionMethod != NFileHeader::NCompressionMethod::kDeflated ||
+ (item.Flags & 0x7FF9) != (localItem.Flags & 0x7FF9)) &&
+ (item.CompressionMethod != NFileHeader::NCompressionMethod::kStored ||
+ (item.Flags & 0x7FFF) != (localItem.Flags & 0x7FFF)) &&
+ (item.CompressionMethod != NFileHeader::NCompressionMethod::kImploded ||
+ (item.Flags & 0x7FFF) != (localItem.Flags & 0x7FFF))
+ )
+ return S_FALSE;
+ }
+
+ if (item.CompressionMethod != localItem.CompressionMethod ||
+ // item.Time != localItem.Time ||
+ (!localItem.HasDescriptor() &&
+ (
+ item.FileCRC != localItem.FileCRC ||
+ item.PackSize != localItem.PackSize ||
+ item.UnPackSize != localItem.UnPackSize
+ )
+ ) ||
+ item.Name.Length() != localItem.Name.Length()
+ )
+ return S_FALSE;
+ item.FileHeaderWithNameSize = localItem.FileHeaderWithNameSize;
+ item.LocalExtraSize = localItem.LocalExtraSize;
+ item.LocalExtra = localItem.LocalExtra;
+ item.FromLocal = true;
+ }
+ catch(...) { return S_FALSE; }
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadLocalItemDescriptor(CItemEx &item)
+{
+ if (item.HasDescriptor())
+ {
+ const int kBufferSize = (1 << 12);
+ Byte buffer[kBufferSize];
+
+ UInt32 numBytesInBuffer = 0;
+ UInt32 packedSize = 0;
+
+ bool descriptorWasFound = false;
+ for (;;)
+ {
+ UInt32 processedSize;
+ RINOK(ReadBytes(buffer + numBytesInBuffer, kBufferSize - numBytesInBuffer, &processedSize));
+ numBytesInBuffer += processedSize;
+ if (numBytesInBuffer < NFileHeader::kDataDescriptorSize)
+ return S_FALSE;
+ UInt32 i;
+ for (i = 0; i <= numBytesInBuffer - NFileHeader::kDataDescriptorSize; i++)
+ {
+ // descriptorSignature field is Info-ZIP's extension
+ // to Zip specification.
+ UInt32 descriptorSignature = Get32(buffer + i);
+
+ // !!!! It must be fixed for Zip64 archives
+ UInt32 descriptorPackSize = Get32(buffer + i + 8);
+ if (descriptorSignature== NSignature::kDataDescriptor && descriptorPackSize == packedSize + i)
+ {
+ descriptorWasFound = true;
+ item.FileCRC = Get32(buffer + i + 4);
+ item.PackSize = descriptorPackSize;
+ item.UnPackSize = Get32(buffer + i + 12);
+ IncreaseRealPosition(Int64(Int32(0 - (numBytesInBuffer - i - NFileHeader::kDataDescriptorSize))));
+ break;
+ }
+ }
+ if (descriptorWasFound)
+ break;
+ packedSize += i;
+ int j;
+ for (j = 0; i < numBytesInBuffer; i++, j++)
+ buffer[j] = buffer[i];
+ numBytesInBuffer = j;
+ }
+ }
+ else
+ IncreaseRealPosition(item.PackSize);
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
+{
+ if (item.FromLocal)
+ return S_OK;
+ try
+ {
+ RINOK(ReadLocalItemAfterCdItem(item));
+ if (item.HasDescriptor())
+ {
+ RINOK(Seek(m_ArchiveInfo.Base + item.GetDataPosition() + item.PackSize));
+ if (ReadUInt32() != NSignature::kDataDescriptor)
+ return S_FALSE;
+ UInt32 crc = ReadUInt32();
+ UInt64 packSize, unpackSize;
+
+ /*
+ if (IsZip64)
+ {
+ packSize = ReadUInt64();
+ unpackSize = ReadUInt64();
+ }
+ else
+ */
+ {
+ packSize = ReadUInt32();
+ unpackSize = ReadUInt32();
+ }
+
+ if (crc != item.FileCRC || item.PackSize != packSize || item.UnPackSize != unpackSize)
+ return S_FALSE;
+ }
+ }
+ catch(...) { return S_FALSE; }
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadCdItem(CItemEx &item)
+{
+ item.FromCentral = true;
+ const int kBufSize = 42;
+ Byte p[kBufSize];
+ SafeReadBytes(p, kBufSize);
+ item.MadeByVersion.Version = p[0];
+ item.MadeByVersion.HostOS = p[1];
+ item.ExtractVersion.Version = p[2];
+ item.ExtractVersion.HostOS = p[3];
+ item.Flags = Get16(p + 4);
+ item.CompressionMethod = Get16(p + 6);
+ item.Time = Get32(p + 8);
+ item.FileCRC = Get32(p + 12);
+ item.PackSize = Get32(p + 16);
+ item.UnPackSize = Get32(p + 20);
+ UInt16 headerNameSize = Get16(p + 24);
+ UInt16 headerExtraSize = Get16(p + 26);
+ UInt16 headerCommentSize = Get16(p + 28);
+ UInt32 headerDiskNumberStart = Get16(p + 30);
+ item.InternalAttributes = Get16(p + 32);
+ item.ExternalAttributes = Get32(p + 34);
+ item.LocalHeaderPosition = Get32(p + 38);
+ ReadFileName(headerNameSize, item.Name);
+
+ if (headerExtraSize > 0)
+ {
+ ReadExtra(headerExtraSize, item.CentralExtra, item.UnPackSize, item.PackSize,
+ item.LocalHeaderPosition, headerDiskNumberStart);
+ }
+
+ if (headerDiskNumberStart != 0)
+ throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
+
+ // May be these strings must be deleted
+ /*
+ if (item.IsDir())
+ item.UnPackSize = 0;
+ */
+
+ ReadBuffer(item.Comment, headerCommentSize);
+ return S_OK;
+}
+
+HRESULT CInArchive::TryEcd64(UInt64 offset, CCdInfo &cdInfo)
+{
+ RINOK(Seek(offset));
+ const UInt32 kEcd64Size = 56;
+ Byte buf[kEcd64Size];
+ if (!ReadBytesAndTestSize(buf, kEcd64Size))
+ return S_FALSE;
+ if (Get32(buf) != NSignature::kZip64EndOfCentralDir)
+ return S_FALSE;
+ // cdInfo.NumEntries = Get64(buf + 24);
+ cdInfo.Size = Get64(buf + 40);
+ cdInfo.Offset = Get64(buf + 48);
+ return S_OK;
+}
+
+HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
+{
+ UInt64 endPosition;
+ RINOK(m_Stream->Seek(0, STREAM_SEEK_END, &endPosition));
+ const UInt32 kBufSizeMax = (1 << 16) + kEcdSize + kZip64EcdLocatorSize;
+ Byte buf[kBufSizeMax];
+ UInt32 bufSize = (endPosition < kBufSizeMax) ? (UInt32)endPosition : kBufSizeMax;
+ if (bufSize < kEcdSize)
+ return S_FALSE;
+ UInt64 startPosition = endPosition - bufSize;
+ RINOK(m_Stream->Seek(startPosition, STREAM_SEEK_SET, &m_Position));
+ if (m_Position != startPosition)
+ return S_FALSE;
+ if (!ReadBytesAndTestSize(buf, bufSize))
+ return S_FALSE;
+ for (int i = (int)(bufSize - kEcdSize); i >= 0; i--)
+ {
+ if (Get32(buf + i) == NSignature::kEndOfCentralDir)
+ {
+ if (i >= static_cast< int >( kZip64EcdLocatorSize ) )
+ {
+ const Byte *locator = buf + i - kZip64EcdLocatorSize;
+ if (Get32(locator) == NSignature::kZip64EndOfCentralDirLocator)
+ {
+ UInt64 ecd64Offset = Get64(locator + 8);
+ if (TryEcd64(ecd64Offset, cdInfo) == S_OK)
+ return S_OK;
+ if (TryEcd64(m_ArchiveInfo.StartPosition + ecd64Offset, cdInfo) == S_OK)
+ {
+ m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
+ return S_OK;
+ }
+ }
+ }
+ if (Get32(buf + i + 4) == 0)
+ {
+ // cdInfo.NumEntries = GetUInt16(buf + i + 10);
+ cdInfo.Size = Get32(buf + i + 12);
+ cdInfo.Offset = Get32(buf + i + 16);
+ UInt64 curPos = endPosition - bufSize + i;
+ UInt64 cdEnd = cdInfo.Size + cdInfo.Offset;
+ if (curPos > cdEnd)
+ m_ArchiveInfo.Base = curPos - cdEnd;
+ return S_OK;
+ }
+ }
+ }
+ return S_FALSE;
+}
+
+HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize, CProgressVirt *progress)
+{
+ items.Clear();
+ RINOK(m_Stream->Seek(cdOffset, STREAM_SEEK_SET, &m_Position));
+ if (m_Position != cdOffset)
+ return S_FALSE;
+
+ if (!_inBuffer.Create(1 << 15))
+ return E_OUTOFMEMORY;
+ _inBuffer.SetStream(m_Stream);
+ _inBuffer.Init();
+ _inBufMode = true;
+
+ while(m_Position - cdOffset < cdSize)
+ {
+ if (ReadUInt32() != NSignature::kCentralFileHeader)
+ return S_FALSE;
+ CItemEx cdItem;
+ RINOK(ReadCdItem(cdItem));
+ items.Add(cdItem);
+ if (progress && items.Size() % 1000 == 0)
+ RINOK(progress->SetCompleted(items.Size()));
+ }
+ return (m_Position - cdOffset == cdSize) ? S_OK : S_FALSE;
+}
+
+HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress)
+{
+ m_ArchiveInfo.Base = 0;
+ CCdInfo cdInfo;
+ RINOK(FindCd(cdInfo));
+ HRESULT res = S_FALSE;
+ cdSize = cdInfo.Size;
+ cdOffset = cdInfo.Offset;
+ res = TryReadCd(items, m_ArchiveInfo.Base + cdOffset, cdSize, progress);
+ if (res == S_FALSE && m_ArchiveInfo.Base == 0)
+ {
+ res = TryReadCd(items, cdInfo.Offset + m_ArchiveInfo.StartPosition, cdSize, progress);
+ if (res == S_OK)
+ m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
+ }
+ if (!ReadUInt32(m_Signature))
+ return S_FALSE;
+ return res;
+}
+
+HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset)
+{
+ items.Clear();
+ while (m_Signature == NSignature::kLocalFileHeader)
+ {
+ // FSeek points to next byte after signature
+ // NFileHeader::CLocalBlock localHeader;
+ CItemEx item;
+ item.LocalHeaderPosition = m_Position - m_StreamStartPosition - 4; // points to signature;
+ RINOK(ReadLocalItem(item));
+ item.FromLocal = true;
+ ReadLocalItemDescriptor(item);
+ items.Add(item);
+ if (progress && items.Size() % 100 == 0)
+ RINOK(progress->SetCompleted(items.Size()));
+ if (!ReadUInt32(m_Signature))
+ break;
+ }
+ cdOffset = m_Position - 4;
+ for (int i = 0; i < items.Size(); i++)
+ {
+ if (progress && i % 1000 == 0)
+ RINOK(progress->SetCompleted(items.Size()));
+ if (m_Signature != NSignature::kCentralFileHeader)
+ return S_FALSE;
+
+ CItemEx cdItem;
+ RINOK(ReadCdItem(cdItem));
+
+ if (i == 0)
+ {
+ if (cdItem.LocalHeaderPosition == 0)
+ m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
+ }
+
+ int index;
+ int left = 0, right = items.Size();
+ for (;;)
+ {
+ if (left >= right)
+ return S_FALSE;
+ index = (left + right) / 2;
+ UInt64 position = items[index].LocalHeaderPosition - m_ArchiveInfo.Base;
+ if (cdItem.LocalHeaderPosition == position)
+ break;
+ if (cdItem.LocalHeaderPosition < position)
+ right = index;
+ else
+ left = index + 1;
+ }
+ CItemEx &item = items[index];
+ item.LocalHeaderPosition = cdItem.LocalHeaderPosition;
+ item.MadeByVersion = cdItem.MadeByVersion;
+ item.CentralExtra = cdItem.CentralExtra;
+
+ if (
+ // item.ExtractVersion != cdItem.ExtractVersion ||
+ item.Flags != cdItem.Flags ||
+ item.CompressionMethod != cdItem.CompressionMethod ||
+ // item.Time != cdItem.Time ||
+ item.FileCRC != cdItem.FileCRC)
+ return S_FALSE;
+
+ if (item.Name.Length() != cdItem.Name.Length() ||
+ item.PackSize != cdItem.PackSize ||
+ item.UnPackSize != cdItem.UnPackSize
+ )
+ return S_FALSE;
+ item.Name = cdItem.Name;
+ item.InternalAttributes = cdItem.InternalAttributes;
+ item.ExternalAttributes = cdItem.ExternalAttributes;
+ item.Comment = cdItem.Comment;
+ item.FromCentral = cdItem.FromCentral;
+ if (!ReadUInt32(m_Signature))
+ return S_FALSE;
+ }
+ return S_OK;
+}
+
+struct CEcd
+{
+ UInt16 thisDiskNumber;
+ UInt16 startCDDiskNumber;
+ UInt16 numEntriesInCDOnThisDisk;
+ UInt16 numEntriesInCD;
+ UInt32 cdSize;
+ UInt32 cdStartOffset;
+ UInt16 commentSize;
+ void Parse(const Byte *p);
+};
+
+void CEcd::Parse(const Byte *p)
+{
+ thisDiskNumber = Get16(p);
+ startCDDiskNumber = Get16(p + 2);
+ numEntriesInCDOnThisDisk = Get16(p + 4);
+ numEntriesInCD = Get16(p + 6);
+ cdSize = Get32(p + 8);
+ cdStartOffset = Get32(p + 12);
+ commentSize = Get16(p + 16);
+}
+
+struct CEcd64
+{
+ UInt16 versionMade;
+ UInt16 versionNeedExtract;
+ UInt32 thisDiskNumber;
+ UInt32 startCDDiskNumber;
+ UInt64 numEntriesInCDOnThisDisk;
+ UInt64 numEntriesInCD;
+ UInt64 cdSize;
+ UInt64 cdStartOffset;
+ void Parse(const Byte *p);
+ CEcd64() { memset(this, 0, sizeof(*this)); }
+};
+
+void CEcd64::Parse(const Byte *p)
+{
+ versionMade = Get16(p);
+ versionNeedExtract = Get16(p + 2);
+ thisDiskNumber = Get32(p + 4);
+ startCDDiskNumber = Get32(p + 8);
+ numEntriesInCDOnThisDisk = Get64(p + 12);
+ numEntriesInCD = Get64(p + 20);
+ cdSize = Get64(p + 28);
+ cdStartOffset = Get64(p + 36);
+}
+
+#define COPY_ECD_ITEM_16(n) if (!isZip64 || ecd. n != 0xFFFF) ecd64. n = ecd. n;
+#define COPY_ECD_ITEM_32(n) if (!isZip64 || ecd. n != 0xFFFFFFFF) ecd64. n = ecd. n;
+
+HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress)
+{
+ // m_Signature must be kLocalFileHeaderSignature or
+ // kEndOfCentralDirSignature
+ // m_Position points to next byte after signature
+
+ IsZip64 = false;
+ items.Clear();
+
+ UInt64 cdSize, cdStartOffset;
+ HRESULT res = ReadCd(items, cdStartOffset, cdSize, progress);
+ if (res != S_FALSE && res != S_OK)
+ return res;
+
+ /*
+ if (res != S_OK)
+ return res;
+ res = S_FALSE;
+ */
+
+ if (res == S_FALSE)
+ {
+ _inBufMode = false;
+ m_ArchiveInfo.Base = 0;
+ RINOK(m_Stream->Seek(m_ArchiveInfo.StartPosition, STREAM_SEEK_SET, &m_Position));
+ if (m_Position != m_ArchiveInfo.StartPosition)
+ return S_FALSE;
+ if (!ReadUInt32(m_Signature))
+ return S_FALSE;
+ RINOK(ReadLocalsAndCd(items, progress, cdStartOffset));
+ cdSize = (m_Position - 4) - cdStartOffset;
+ cdStartOffset -= m_ArchiveInfo.Base;
+ }
+
+ CEcd64 ecd64;
+ bool isZip64 = false;
+ UInt64 zip64EcdStartOffset = m_Position - 4 - m_ArchiveInfo.Base;
+ if (m_Signature == NSignature::kZip64EndOfCentralDir)
+ {
+ IsZip64 = isZip64 = true;
+ UInt64 recordSize = ReadUInt64();
+
+ const int kBufSize = kZip64EcdSize;
+ Byte buf[kBufSize];
+ SafeReadBytes(buf, kBufSize);
+ ecd64.Parse(buf);
+
+ Skip(recordSize - kZip64EcdSize);
+ if (!ReadUInt32(m_Signature))
+ return S_FALSE;
+ if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
+ throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
+ if (ecd64.numEntriesInCDOnThisDisk != static_cast< UInt64 >( items.Size() ) ||
+ ecd64.numEntriesInCD != static_cast< UInt64 >( items.Size() ) ||
+ ecd64.cdSize != cdSize ||
+ (ecd64.cdStartOffset != cdStartOffset &&
+ (!items.IsEmpty())))
+ return S_FALSE;
+ }
+ if (m_Signature == NSignature::kZip64EndOfCentralDirLocator)
+ {
+ /* UInt32 startEndCDDiskNumber = */ ReadUInt32();
+ UInt64 endCDStartOffset = ReadUInt64();
+ /* UInt32 numberOfDisks = */ ReadUInt32();
+ if (zip64EcdStartOffset != endCDStartOffset)
+ return S_FALSE;
+ if (!ReadUInt32(m_Signature))
+ return S_FALSE;
+ }
+ if (m_Signature != NSignature::kEndOfCentralDir)
+ return S_FALSE;
+
+ const int kBufSize = kEcdSize - 4;
+ Byte buf[kBufSize];
+ SafeReadBytes(buf, kBufSize);
+ CEcd ecd;
+ ecd.Parse(buf);
+
+ COPY_ECD_ITEM_16(thisDiskNumber);
+ COPY_ECD_ITEM_16(startCDDiskNumber);
+ COPY_ECD_ITEM_16(numEntriesInCDOnThisDisk);
+ COPY_ECD_ITEM_16(numEntriesInCD);
+ COPY_ECD_ITEM_32(cdSize);
+ COPY_ECD_ITEM_32(cdStartOffset);
+
+ ReadBuffer(m_ArchiveInfo.Comment, ecd.commentSize);
+
+ if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
+ throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
+ if ((UInt16)ecd64.numEntriesInCDOnThisDisk != ((UInt16)items.Size()) ||
+ (UInt16)ecd64.numEntriesInCD != ((UInt16)items.Size()) ||
+ (UInt32)ecd64.cdSize != (UInt32)cdSize ||
+ ((UInt32)(ecd64.cdStartOffset) != (UInt32)cdStartOffset &&
+ (!items.IsEmpty())))
+ return S_FALSE;
+
+ _inBufMode = false;
+ _inBuffer.Free();
+ return S_OK;
+}
+
+ISequentialInStream* CInArchive::CreateLimitedStream(UInt64 position, UInt64 size)
+{
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> stream(streamSpec);
+ SeekInArchive(m_ArchiveInfo.Base + position);
+ streamSpec->SetStream(m_Stream);
+ streamSpec->Init(size);
+ return stream.Detach();
+}
+
+IInStream* CInArchive::CreateStream()
+{
+ CMyComPtr<IInStream> stream = m_Stream;
+ return stream.Detach();
+}
+
+bool CInArchive::SeekInArchive(UInt64 position)
+{
+ UInt64 newPosition;
+ if (m_Stream->Seek(position, STREAM_SEEK_SET, &newPosition) != S_OK)
+ return false;
+ return (newPosition == position);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipIn.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipIn.h
new file mode 100644
index 000000000..51597898d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipIn.h
@@ -0,0 +1,123 @@
+// Archive/ZipIn.h
+
+#ifndef __ZIP_IN_H
+#define __ZIP_IN_H
+
+#include "Common/MyCom.h"
+
+#include "../../IStream.h"
+
+#include "../../Common/InBuffer.h"
+
+#include "ZipHeader.h"
+#include "ZipItemEx.h"
+
+namespace NArchive {
+namespace NZip {
+
+class CInArchiveException
+{
+public:
+ enum ECauseType
+ {
+ kUnexpectedEndOfArchive = 0,
+ kArchiceHeaderCRCError,
+ kFileHeaderCRCError,
+ kIncorrectArchive,
+ kDataDescroptorsAreNotSupported,
+ kMultiVolumeArchiveAreNotSupported,
+ kReadStreamError,
+ kSeekStreamError
+ }
+ Cause;
+ CInArchiveException(ECauseType cause): Cause(cause) {}
+};
+
+class CInArchiveInfo
+{
+public:
+ UInt64 Base;
+ UInt64 StartPosition;
+ CByteBuffer Comment;
+ CInArchiveInfo(): Base(0), StartPosition(0) {}
+ void Clear()
+ {
+ Base = 0;
+ StartPosition = 0;
+ Comment.SetCapacity(0);
+ }
+};
+
+class CProgressVirt
+{
+public:
+ virtual ~CProgressVirt() {}
+ STDMETHOD(SetTotal)(UInt64 numFiles) PURE;
+ STDMETHOD(SetCompleted)(UInt64 numFiles) PURE;
+};
+
+struct CCdInfo
+{
+ // UInt64 NumEntries;
+ UInt64 Size;
+ UInt64 Offset;
+};
+
+class CInArchive
+{
+ CMyComPtr<IInStream> m_Stream;
+ UInt32 m_Signature;
+ UInt64 m_StreamStartPosition;
+ UInt64 m_Position;
+
+ bool _inBufMode;
+ CInBuffer _inBuffer;
+
+ HRESULT Seek(UInt64 offset);
+
+ HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
+ void ReadFileName(UInt32 nameSize, AString &dest);
+
+ HRESULT ReadBytes(void *data, UInt32 size, UInt32 *processedSize);
+ bool ReadBytesAndTestSize(void *data, UInt32 size);
+ void SafeReadBytes(void *data, UInt32 size);
+ void ReadBuffer(CByteBuffer &buffer, UInt32 size);
+ Byte ReadByte();
+ UInt16 ReadUInt16();
+ UInt32 ReadUInt32();
+ UInt64 ReadUInt64();
+ bool ReadUInt32(UInt32 &signature);
+
+ void Skip(UInt64 num);
+ void IncreaseRealPosition(UInt64 addValue);
+
+ void ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
+ UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber);
+ HRESULT ReadLocalItem(CItemEx &item);
+ HRESULT ReadLocalItemDescriptor(CItemEx &item);
+ HRESULT ReadCdItem(CItemEx &item);
+ HRESULT TryEcd64(UInt64 offset, CCdInfo &cdInfo);
+ HRESULT FindCd(CCdInfo &cdInfo);
+ HRESULT TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize, CProgressVirt *progress);
+ HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress);
+ HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset);
+public:
+ CInArchiveInfo m_ArchiveInfo;
+ bool IsZip64;
+
+ HRESULT ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress);
+ HRESULT ReadLocalItemAfterCdItem(CItemEx &item);
+ HRESULT ReadLocalItemAfterCdItemFull(CItemEx &item);
+ HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
+ void Close();
+ void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
+ bool SeekInArchive(UInt64 position);
+ ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
+ IInStream* CreateStream();
+
+ bool IsOpen() const { return m_Stream != NULL; }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItem.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItem.cpp
new file mode 100644
index 000000000..4dd58f7d6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItem.cpp
@@ -0,0 +1,181 @@
+// Archive/ZipItem.cpp
+
+#include "StdAfx.h"
+
+#include "ZipHeader.h"
+#include "ZipItem.h"
+#include "../Common/ItemNameUtils.h"
+#include "../../../../C/CpuArch.h"
+
+namespace NArchive {
+namespace NZip {
+
+bool operator==(const CVersion &v1, const CVersion &v2)
+{
+ return (v1.Version == v2.Version) && (v1.HostOS == v2.HostOS);
+}
+
+bool operator!=(const CVersion &v1, const CVersion &v2)
+{
+ return !(v1 == v2);
+}
+
+bool CExtraSubBlock::ExtractNtfsTime(int index, FILETIME &ft) const
+{
+ ft.dwHighDateTime = ft.dwLowDateTime = 0;
+ UInt32 size = (UInt32)Data.GetCapacity();
+ if (ID != NFileHeader::NExtraID::kNTFS || size < 32)
+ return false;
+ const Byte *p = (const Byte *)Data;
+ p += 4; // for reserved
+ size -= 4;
+ while (size > 4)
+ {
+ UInt16 tag = GetUi16(p);
+ UInt32 attrSize = GetUi16(p + 2);
+ p += 4;
+ size -= 4;
+ if (attrSize > size)
+ attrSize = size;
+
+ if (tag == NFileHeader::NNtfsExtra::kTagTime && attrSize >= 24)
+ {
+ p += 8 * index;
+ ft.dwLowDateTime = GetUi32(p);
+ ft.dwHighDateTime = GetUi32(p + 4);
+ return true;
+ }
+ p += attrSize;
+ size -= attrSize;
+ }
+ return false;
+}
+
+bool CExtraSubBlock::ExtractUnixTime(int index, UInt32 &res) const
+{
+ res = 0;
+ UInt32 size = (UInt32)Data.GetCapacity();
+ if (ID != NFileHeader::NExtraID::kUnixTime || size < 5)
+ return false;
+ const Byte *p = (const Byte *)Data;
+ Byte flags = *p++;
+ size--;
+ for (int i = 0; i < 3; i++)
+ if ((flags & (1 << i)) != 0)
+ {
+ if (size < 4)
+ return false;
+ if (index == i)
+ {
+ res = GetUi32(p);
+ return true;
+ }
+ p += 4;
+ size -= 4;
+ }
+ return false;
+}
+
+bool CLocalItem::IsDir() const
+{
+ return NItemName::HasTailSlash(Name, GetCodePage());
+}
+
+bool CItem::IsDir() const
+{
+ if (NItemName::HasTailSlash(Name, GetCodePage()))
+ return true;
+ if (!FromCentral)
+ return false;
+ WORD highAttributes = WORD((ExternalAttributes >> 16 ) & 0xFFFF);
+ switch(MadeByVersion.HostOS)
+ {
+ case NFileHeader::NHostOS::kAMIGA:
+ switch (highAttributes & NFileHeader::NAmigaAttribute::kIFMT)
+ {
+ case NFileHeader::NAmigaAttribute::kIFDIR: return true;
+ case NFileHeader::NAmigaAttribute::kIFREG: return false;
+ default: return false; // change it throw kUnknownAttributes;
+ }
+ case NFileHeader::NHostOS::kFAT:
+ case NFileHeader::NHostOS::kNTFS:
+ case NFileHeader::NHostOS::kHPFS:
+ case NFileHeader::NHostOS::kVFAT:
+ return ((ExternalAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
+ case NFileHeader::NHostOS::kAtari:
+ case NFileHeader::NHostOS::kMac:
+ case NFileHeader::NHostOS::kVMS:
+ case NFileHeader::NHostOS::kVM_CMS:
+ case NFileHeader::NHostOS::kAcorn:
+ case NFileHeader::NHostOS::kMVS:
+ return false; // change it throw kUnknownAttributes;
+ default:
+ /*
+ switch (highAttributes & NFileHeader::NUnixAttribute::kIFMT)
+ {
+ case NFileHeader::NUnixAttribute::kIFDIR:
+ return true;
+ default:
+ return false;
+ }
+ */
+ return false;
+ }
+}
+
+#ifndef FILE_ATTRIBUTE_UNIX_EXTENSION
+UInt32 CLocalItem::GetWinAttributes() const
+{
+ DWORD winAttributes = 0;
+ if (IsDir())
+ winAttributes |= FILE_ATTRIBUTE_DIRECTORY;
+ return winAttributes;
+}
+#endif
+
+UInt32 CItem::GetWinAttributes() const
+{
+ DWORD winAttributes = 0;
+ switch(MadeByVersion.HostOS)
+ {
+ case NFileHeader::NHostOS::kFAT:
+ case NFileHeader::NHostOS::kNTFS:
+ if (FromCentral)
+ winAttributes = ExternalAttributes;
+ break;
+#ifdef FILE_ATTRIBUTE_UNIX_EXTENSION
+ case NFileHeader::NHostOS::kUnix:
+ winAttributes = (ExternalAttributes & 0xFFFF0000) | FILE_ATTRIBUTE_UNIX_EXTENSION;
+ if (winAttributes & (NFileHeader::NUnixAttribute::kIFDIR << 16))
+ winAttributes |= FILE_ATTRIBUTE_DIRECTORY;
+ return winAttributes;
+#endif
+ default:
+ winAttributes = 0; // must be converted from unix value;
+ }
+ if (IsDir()) // test it;
+ winAttributes |= FILE_ATTRIBUTE_DIRECTORY;
+ return winAttributes;
+}
+
+void CLocalItem::SetFlagBits(int startBitNumber, int numBits, int value)
+{
+ UInt16 mask = (UInt16)(((1 << numBits) - 1) << startBitNumber);
+ Flags &= ~mask;
+ Flags |= value << startBitNumber;
+}
+
+void CLocalItem::SetBitMask(int bitMask, bool enable)
+{
+ if(enable)
+ Flags |= bitMask;
+ else
+ Flags &= ~bitMask;
+}
+
+void CLocalItem::SetEncrypted(bool encrypted)
+ { SetBitMask(NFileHeader::NFlags::kEncrypted, encrypted); }
+void CLocalItem::SetUtf8(bool isUtf8)
+ { SetBitMask(NFileHeader::NFlags::kUtf8, isUtf8); }
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItem.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItem.h
new file mode 100644
index 000000000..31f2de732
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItem.h
@@ -0,0 +1,281 @@
+// Archive/ZipItem.h
+
+#ifndef __ARCHIVE_ZIP_ITEM_H
+#define __ARCHIVE_ZIP_ITEM_H
+
+#include "Common/Types.h"
+#include "Common/MyString.h"
+#include "Common/Buffer.h"
+#include "Common/UTFConvert.h"
+#include "Common/StringConvert.h"
+
+#include "ZipHeader.h"
+
+namespace NArchive {
+namespace NZip {
+
+struct CVersion
+{
+ Byte Version;
+ Byte HostOS;
+};
+
+bool operator==(const CVersion &v1, const CVersion &v2);
+bool operator!=(const CVersion &v1, const CVersion &v2);
+
+struct CExtraSubBlock
+{
+ UInt16 ID;
+ CByteBuffer Data;
+ bool ExtractNtfsTime(int index, FILETIME &ft) const;
+ bool ExtractUnixTime(int index, UInt32 &res) const;
+};
+
+struct CWzAesExtraField
+{
+ UInt16 VendorVersion; // 0x0001 - AE-1, 0x0002 - AE-2,
+ // UInt16 VendorId; // "AE"
+ Byte Strength; // 1 - 128-bit , 2 - 192-bit , 3 - 256-bit
+ UInt16 Method;
+
+ CWzAesExtraField(): VendorVersion(2), Strength(3), Method(0) {}
+
+ bool NeedCrc() const { return (VendorVersion == 1); }
+
+ bool ParseFromSubBlock(const CExtraSubBlock &sb)
+ {
+ if (sb.ID != NFileHeader::NExtraID::kWzAES)
+ return false;
+ if (sb.Data.GetCapacity() < 7)
+ return false;
+ const Byte *p = (const Byte *)sb.Data;
+ VendorVersion = (((UInt16)p[1]) << 8) | p[0];
+ if (p[2] != 'A' || p[3] != 'E')
+ return false;
+ Strength = p[4];
+ Method = (((UInt16)p[6]) << 16) | p[5];
+ return true;
+ }
+ void SetSubBlock(CExtraSubBlock &sb) const
+ {
+ sb.Data.SetCapacity(7);
+ sb.ID = NFileHeader::NExtraID::kWzAES;
+ Byte *p = (Byte *)sb.Data;
+ p[0] = (Byte)VendorVersion;
+ p[1] = (Byte)(VendorVersion >> 8);
+ p[2] = 'A';
+ p[3] = 'E';
+ p[4] = Strength;
+ p[5] = (Byte)Method;
+ p[6] = (Byte)(Method >> 8);
+ }
+};
+
+namespace NStrongCryptoFlags
+{
+ const UInt16 kDES = 0x6601;
+ const UInt16 kRC2old = 0x6602;
+ const UInt16 k3DES168 = 0x6603;
+ const UInt16 k3DES112 = 0x6609;
+ const UInt16 kAES128 = 0x660E;
+ const UInt16 kAES192 = 0x660F;
+ const UInt16 kAES256 = 0x6610;
+ const UInt16 kRC2 = 0x6702;
+ const UInt16 kBlowfish = 0x6720;
+ const UInt16 kTwofish = 0x6721;
+ const UInt16 kRC4 = 0x6801;
+}
+
+struct CStrongCryptoField
+{
+ UInt16 Format;
+ UInt16 AlgId;
+ UInt16 BitLen;
+ UInt16 Flags;
+
+ bool ParseFromSubBlock(const CExtraSubBlock &sb)
+ {
+ if (sb.ID != NFileHeader::NExtraID::kStrongEncrypt)
+ return false;
+ const Byte *p = (const Byte *)sb.Data;
+ if (sb.Data.GetCapacity() < 8)
+ return false;
+ Format = (((UInt16)p[1]) << 8) | p[0];
+ AlgId = (((UInt16)p[3]) << 8) | p[2];
+ BitLen = (((UInt16)p[5]) << 8) | p[4];
+ Flags = (((UInt16)p[7]) << 8) | p[6];
+ return (Format == 2);
+ }
+};
+
+struct CExtraBlock
+{
+ CObjectVector<CExtraSubBlock> SubBlocks;
+ void Clear() { SubBlocks.Clear(); }
+ size_t GetSize() const
+ {
+ size_t res = 0;
+ for (int i = 0; i < SubBlocks.Size(); i++)
+ res += SubBlocks[i].Data.GetCapacity() + 2 + 2;
+ return res;
+ }
+ bool GetWzAesField(CWzAesExtraField &aesField) const
+ {
+ for (int i = 0; i < SubBlocks.Size(); i++)
+ if (aesField.ParseFromSubBlock(SubBlocks[i]))
+ return true;
+ return false;
+ }
+
+ bool GetStrongCryptoField(CStrongCryptoField &f) const
+ {
+ for (int i = 0; i < SubBlocks.Size(); i++)
+ if (f.ParseFromSubBlock(SubBlocks[i]))
+ return true;
+ return false;
+ }
+
+ bool HasWzAesField() const
+ {
+ CWzAesExtraField aesField;
+ return GetWzAesField(aesField);
+ }
+
+ bool GetNtfsTime(int index, FILETIME &ft) const
+ {
+ for (int i = 0; i < SubBlocks.Size(); i++)
+ {
+ const CExtraSubBlock &sb = SubBlocks[i];
+ if (sb.ID == NFileHeader::NExtraID::kNTFS)
+ return sb.ExtractNtfsTime(index, ft);
+ }
+ return false;
+ }
+
+ bool GetUnixTime(int index, UInt32 &res) const
+ {
+ for (int i = 0; i < SubBlocks.Size(); i++)
+ {
+ const CExtraSubBlock &sb = SubBlocks[i];
+ if (sb.ID == NFileHeader::NExtraID::kUnixTime)
+ return sb.ExtractUnixTime(index, res);
+ }
+ return false;
+ }
+
+ /*
+ bool HasStrongCryptoField() const
+ {
+ CStrongCryptoField f;
+ return GetStrongCryptoField(f);
+ }
+ */
+
+ void RemoveUnknownSubBlocks()
+ {
+ for (int i = SubBlocks.Size() - 1; i >= 0; i--)
+ if (SubBlocks[i].ID != NFileHeader::NExtraID::kWzAES)
+ SubBlocks.Delete(i);
+ }
+};
+
+
+class CLocalItem
+{
+public:
+ CVersion ExtractVersion;
+ UInt16 Flags;
+ UInt16 CompressionMethod;
+ UInt32 Time;
+ UInt32 FileCRC;
+ UInt64 PackSize;
+ UInt64 UnPackSize;
+
+ AString Name;
+
+ CExtraBlock LocalExtra;
+
+ bool IsUtf8() const { return (Flags & NFileHeader::NFlags::kUtf8) != 0; }
+
+ bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kEncrypted) != 0; }
+ bool IsStrongEncrypted() const { return IsEncrypted() && (Flags & NFileHeader::NFlags::kStrongEncrypted) != 0; };
+ bool IsAesEncrypted() const { return IsEncrypted() && (IsStrongEncrypted() || CompressionMethod == NFileHeader::NCompressionMethod::kWzAES); };
+
+ bool IsLzmaEOS() const { return (Flags & NFileHeader::NFlags::kLzmaEOS) != 0; }
+
+ bool IsDir() const;
+ bool IgnoreItem() const { return false; }
+ UInt32 GetWinAttributes() const;
+
+ bool HasDescriptor() const { return (Flags & NFileHeader::NFlags::kDescriptorUsedMask) != 0; }
+
+ UString GetUnicodeString(const AString &s) const
+ {
+ UString res;
+ if (IsUtf8())
+ if (!ConvertUTF8ToUnicode(s, res))
+ res.Empty();
+ if (res.IsEmpty())
+ res = MultiByteToUnicodeString(s, GetCodePage());
+ return res;
+ }
+
+private:
+ void SetFlagBits(int startBitNumber, int numBits, int value);
+ void SetBitMask(int bitMask, bool enable);
+public:
+ void ClearFlags() { Flags = 0; }
+ void SetEncrypted(bool encrypted);
+ void SetUtf8(bool isUtf8);
+
+ WORD GetCodePage() const { return CP_OEMCP; }
+};
+
+class CItem: public CLocalItem
+{
+public:
+ CVersion MadeByVersion;
+ UInt16 InternalAttributes;
+ UInt32 ExternalAttributes;
+
+ UInt64 LocalHeaderPosition;
+
+ FILETIME NtfsMTime;
+ FILETIME NtfsATime;
+ FILETIME NtfsCTime;
+
+ CExtraBlock CentralExtra;
+ CByteBuffer Comment;
+
+ bool FromLocal;
+ bool FromCentral;
+ bool NtfsTimeIsDefined;
+
+ bool IsDir() const;
+ UInt32 GetWinAttributes() const;
+
+ bool IsThereCrc() const
+ {
+ if (CompressionMethod == NFileHeader::NCompressionMethod::kWzAES)
+ {
+ CWzAesExtraField aesField;
+ if (CentralExtra.GetWzAesField(aesField))
+ return aesField.NeedCrc();
+ }
+ return (FileCRC != 0 || !IsDir());
+ }
+
+ WORD GetCodePage() const
+ {
+ return (WORD)((MadeByVersion.HostOS == NFileHeader::NHostOS::kFAT
+ || MadeByVersion.HostOS == NFileHeader::NHostOS::kNTFS
+ ) ? CP_OEMCP : CP_ACP);
+ }
+ CItem() : FromLocal(false), FromCentral(false), NtfsTimeIsDefined(false) {}
+};
+
+}}
+
+#endif
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItemEx.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItemEx.h
new file mode 100644
index 000000000..ab62cdbb4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipItemEx.h
@@ -0,0 +1,34 @@
+// Archive/ZipItemEx.h
+
+#ifndef __ARCHIVE_ZIP_ITEMEX_H
+#define __ARCHIVE_ZIP_ITEMEX_H
+
+#include "ZipHeader.h"
+#include "ZipItem.h"
+
+namespace NArchive {
+namespace NZip {
+
+class CItemEx: public CItem
+{
+public:
+ UInt32 FileHeaderWithNameSize;
+ UInt16 LocalExtraSize;
+
+ UInt64 GetLocalFullSize() const
+ { return FileHeaderWithNameSize + LocalExtraSize + PackSize +
+ (HasDescriptor() ? NFileHeader::kDataDescriptorSize : 0); };
+ /*
+ UInt64 GetLocalFullSize(bool isZip64) const
+ { return FileHeaderWithNameSize + LocalExtraSize + PackSize +
+ (HasDescriptor() ? (isZip64 ? NFileHeader::kDataDescriptor64Size : NFileHeader::kDataDescriptorSize) : 0); };
+ */
+ UInt64 GetLocalExtraPosition() const
+ { return LocalHeaderPosition + FileHeaderWithNameSize; };
+ UInt64 GetDataPosition() const
+ { return GetLocalExtraPosition() + LocalExtraSize; };
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipOut.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipOut.cpp
new file mode 100644
index 000000000..5b1bdeee2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipOut.cpp
@@ -0,0 +1,280 @@
+// ZipOut.cpp
+
+#include "StdAfx.h"
+
+#include "ZipOut.h"
+#include "Common/StringConvert.h"
+#include "../../Common/OffsetStream.h"
+#include "../../Common/StreamUtils.h"
+
+namespace NArchive {
+namespace NZip {
+
+void COutArchive::Create(IOutStream *outStream)
+{
+ if (!m_OutBuffer.Create(1 << 16))
+ throw CSystemException(E_OUTOFMEMORY);
+ m_Stream = outStream;
+ m_OutBuffer.SetStream(outStream);
+ m_OutBuffer.Init();
+ m_BasePosition = 0;
+}
+
+void COutArchive::MoveBasePosition(UInt64 distanceToMove)
+{
+ m_BasePosition += distanceToMove; // test overflow
+}
+
+void COutArchive::PrepareWriteCompressedDataZip64(UInt16 fileNameLength, bool isZip64, bool aesEncryption)
+{
+ m_IsZip64 = isZip64;
+ m_ExtraSize = isZip64 ? (4 + 8 + 8) : 0;
+ if (aesEncryption)
+ m_ExtraSize += 4 + 7;
+ m_LocalFileHeaderSize = 4 + NFileHeader::kLocalBlockSize + fileNameLength + m_ExtraSize;
+}
+
+void COutArchive::PrepareWriteCompressedData(UInt16 fileNameLength, UInt64 unPackSize, bool aesEncryption)
+{
+ // We test it to 0xF8000000 to support case when compressed size
+ // can be larger than uncompressed size.
+ PrepareWriteCompressedDataZip64(fileNameLength, unPackSize >= 0xF8000000, aesEncryption);
+}
+
+void COutArchive::PrepareWriteCompressedData2(UInt16 fileNameLength, UInt64 unPackSize, UInt64 packSize, bool aesEncryption)
+{
+ bool isUnPack64 = unPackSize >= 0xFFFFFFFF;
+ bool isPack64 = packSize >= 0xFFFFFFFF;
+ bool isZip64 = isPack64 || isUnPack64;
+ PrepareWriteCompressedDataZip64(fileNameLength, isZip64, aesEncryption);
+}
+
+void COutArchive::WriteBytes(const void *buffer, UInt32 size)
+{
+ m_OutBuffer.WriteBytes(buffer, size);
+ m_BasePosition += size;
+}
+
+void COutArchive::WriteByte(Byte b)
+{
+ WriteBytes(&b, 1);
+}
+
+void COutArchive::WriteUInt16(UInt16 value)
+{
+ for (int i = 0; i < 2; i++)
+ {
+ WriteByte((Byte)value);
+ value >>= 8;
+ }
+}
+
+void COutArchive::WriteUInt32(UInt32 value)
+{
+ for (int i = 0; i < 4; i++)
+ {
+ WriteByte((Byte)value);
+ value >>= 8;
+ }
+}
+
+void COutArchive::WriteUInt64(UInt64 value)
+{
+ for (int i = 0; i < 8; i++)
+ {
+ WriteByte((Byte)value);
+ value >>= 8;
+ }
+}
+
+void COutArchive::WriteExtra(const CExtraBlock &extra)
+{
+ if (extra.SubBlocks.Size() != 0)
+ {
+ for (int i = 0; i < extra.SubBlocks.Size(); i++)
+ {
+ const CExtraSubBlock &subBlock = extra.SubBlocks[i];
+ WriteUInt16(subBlock.ID);
+ WriteUInt16((UInt16)subBlock.Data.GetCapacity());
+ WriteBytes(subBlock.Data, (UInt32)subBlock.Data.GetCapacity());
+ }
+ }
+}
+
+void COutArchive::SeekTo(UInt64 offset)
+{
+ HRESULT res = m_Stream->Seek(offset, STREAM_SEEK_SET, NULL);
+ if (res != S_OK)
+ throw CSystemException(res);
+}
+
+void COutArchive::WriteLocalHeader(const CLocalItem &item)
+{
+ SeekTo(m_BasePosition);
+
+ bool isZip64 = m_IsZip64 || item.PackSize >= 0xFFFFFFFF || item.UnPackSize >= 0xFFFFFFFF;
+
+ WriteUInt32(NSignature::kLocalFileHeader);
+ WriteByte(item.ExtractVersion.Version);
+ WriteByte(item.ExtractVersion.HostOS);
+ WriteUInt16(item.Flags);
+ WriteUInt16(item.CompressionMethod);
+ WriteUInt32(item.Time);
+ WriteUInt32(item.FileCRC);
+ WriteUInt32(isZip64 ? 0xFFFFFFFF: (UInt32)item.PackSize);
+ WriteUInt32(isZip64 ? 0xFFFFFFFF: (UInt32)item.UnPackSize);
+ WriteUInt16((UInt16)item.Name.Length());
+ {
+ UInt16 localExtraSize = (UInt16)((isZip64 ? (4 + 16): 0) + item.LocalExtra.GetSize());
+ if (localExtraSize > m_ExtraSize)
+ throw CSystemException(E_FAIL);
+ }
+ WriteUInt16((UInt16)m_ExtraSize); // test it;
+ WriteBytes((const char *)item.Name, item.Name.Length());
+
+ UInt32 extraPos = 0;
+ if (isZip64)
+ {
+ extraPos += 4 + 16;
+ WriteUInt16(NFileHeader::NExtraID::kZip64);
+ WriteUInt16(16);
+ WriteUInt64(item.UnPackSize);
+ WriteUInt64(item.PackSize);
+ }
+
+ WriteExtra(item.LocalExtra);
+ extraPos += (UInt32)item.LocalExtra.GetSize();
+ for (; extraPos < m_ExtraSize; extraPos++)
+ WriteByte(0);
+
+ m_OutBuffer.FlushWithCheck();
+ MoveBasePosition(item.PackSize);
+ SeekTo(m_BasePosition);
+}
+
+void COutArchive::WriteCentralHeader(const CItem &item)
+{
+ bool isUnPack64 = item.UnPackSize >= 0xFFFFFFFF;
+ bool isPack64 = item.PackSize >= 0xFFFFFFFF;
+ bool isPosition64 = item.LocalHeaderPosition >= 0xFFFFFFFF;
+ bool isZip64 = isPack64 || isUnPack64 || isPosition64;
+
+ WriteUInt32(NSignature::kCentralFileHeader);
+ WriteByte(item.MadeByVersion.Version);
+ WriteByte(item.MadeByVersion.HostOS);
+ WriteByte(item.ExtractVersion.Version);
+ WriteByte(item.ExtractVersion.HostOS);
+ WriteUInt16(item.Flags);
+ WriteUInt16(item.CompressionMethod);
+ WriteUInt32(item.Time);
+ WriteUInt32(item.FileCRC);
+ WriteUInt32(isPack64 ? 0xFFFFFFFF: (UInt32)item.PackSize);
+ WriteUInt32(isUnPack64 ? 0xFFFFFFFF: (UInt32)item.UnPackSize);
+ WriteUInt16((UInt16)item.Name.Length());
+ UInt16 zip64ExtraSize = (UInt16)((isUnPack64 ? 8: 0) + (isPack64 ? 8: 0) + (isPosition64 ? 8: 0));
+ const UInt16 kNtfsExtraSize = 4 + 2 + 2 + (3 * 8);
+ UInt16 centralExtraSize = (UInt16)(isZip64 ? (4 + zip64ExtraSize) : 0) + (item.NtfsTimeIsDefined ? (4 + kNtfsExtraSize) : 0);
+ centralExtraSize = (UInt16)(centralExtraSize + item.CentralExtra.GetSize());
+ WriteUInt16(centralExtraSize); // test it;
+ WriteUInt16((UInt16)item.Comment.GetCapacity());
+ WriteUInt16(0); // DiskNumberStart;
+ WriteUInt16(item.InternalAttributes);
+ WriteUInt32(item.ExternalAttributes);
+ WriteUInt32(isPosition64 ? 0xFFFFFFFF: (UInt32)item.LocalHeaderPosition);
+ WriteBytes((const char *)item.Name, item.Name.Length());
+ if (isZip64)
+ {
+ WriteUInt16(NFileHeader::NExtraID::kZip64);
+ WriteUInt16(zip64ExtraSize);
+ if(isUnPack64)
+ WriteUInt64(item.UnPackSize);
+ if(isPack64)
+ WriteUInt64(item.PackSize);
+ if(isPosition64)
+ WriteUInt64(item.LocalHeaderPosition);
+ }
+ if (item.NtfsTimeIsDefined)
+ {
+ WriteUInt16(NFileHeader::NExtraID::kNTFS);
+ WriteUInt16(kNtfsExtraSize);
+ WriteUInt32(0); // reserved
+ WriteUInt16(NFileHeader::NNtfsExtra::kTagTime);
+ WriteUInt16(8 * 3);
+ WriteUInt32(item.NtfsMTime.dwLowDateTime);
+ WriteUInt32(item.NtfsMTime.dwHighDateTime);
+ WriteUInt32(item.NtfsATime.dwLowDateTime);
+ WriteUInt32(item.NtfsATime.dwHighDateTime);
+ WriteUInt32(item.NtfsCTime.dwLowDateTime);
+ WriteUInt32(item.NtfsCTime.dwHighDateTime);
+ }
+ WriteExtra(item.CentralExtra);
+ if (item.Comment.GetCapacity() > 0)
+ WriteBytes(item.Comment, (UInt32)item.Comment.GetCapacity());
+}
+
+void COutArchive::WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer &comment)
+{
+ SeekTo(m_BasePosition);
+
+ UInt64 cdOffset = GetCurrentPosition();
+ for(int i = 0; i < items.Size(); i++)
+ WriteCentralHeader(items[i]);
+ UInt64 cd64EndOffset = GetCurrentPosition();
+ UInt64 cdSize = cd64EndOffset - cdOffset;
+ bool cdOffset64 = cdOffset >= 0xFFFFFFFF;
+ bool cdSize64 = cdSize >= 0xFFFFFFFF;
+ bool items64 = items.Size() >= 0xFFFF;
+ bool isZip64 = (cdOffset64 || cdSize64 || items64);
+
+ if (isZip64)
+ {
+ WriteUInt32(NSignature::kZip64EndOfCentralDir);
+ WriteUInt64(kZip64EcdSize); // ThisDiskNumber = 0;
+ WriteUInt16(45); // version
+ WriteUInt16(45); // version
+ WriteUInt32(0); // ThisDiskNumber = 0;
+ WriteUInt32(0); // StartCentralDirectoryDiskNumber;;
+ WriteUInt64((UInt64)items.Size());
+ WriteUInt64((UInt64)items.Size());
+ WriteUInt64((UInt64)cdSize);
+ WriteUInt64((UInt64)cdOffset);
+
+ WriteUInt32(NSignature::kZip64EndOfCentralDirLocator);
+ WriteUInt32(0); // number of the disk with the start of the zip64 end of central directory
+ WriteUInt64(cd64EndOffset);
+ WriteUInt32(1); // total number of disks
+ }
+ WriteUInt32(NSignature::kEndOfCentralDir);
+ WriteUInt16(0); // ThisDiskNumber = 0;
+ WriteUInt16(0); // StartCentralDirectoryDiskNumber;
+ WriteUInt16((UInt16)(items64 ? 0xFFFF: items.Size()));
+ WriteUInt16((UInt16)(items64 ? 0xFFFF: items.Size()));
+ WriteUInt32(cdSize64 ? 0xFFFFFFFF: (UInt32)cdSize);
+ WriteUInt32(cdOffset64 ? 0xFFFFFFFF: (UInt32)cdOffset);
+ UInt16 commentSize = (UInt16)comment.GetCapacity();
+ WriteUInt16(commentSize);
+ if (commentSize > 0)
+ WriteBytes((const Byte *)comment, commentSize);
+ m_OutBuffer.FlushWithCheck();
+}
+
+void COutArchive::CreateStreamForCompressing(IOutStream **outStream)
+{
+ COffsetOutStream *streamSpec = new COffsetOutStream;
+ CMyComPtr<IOutStream> tempStream(streamSpec);
+ streamSpec->Init(m_Stream, m_BasePosition + m_LocalFileHeaderSize);
+ *outStream = tempStream.Detach();
+}
+
+void COutArchive::SeekToPackedDataPosition()
+{
+ SeekTo(m_BasePosition + m_LocalFileHeaderSize);
+}
+
+void COutArchive::CreateStreamForCopying(ISequentialOutStream **outStream)
+{
+ CMyComPtr<ISequentialOutStream> tempStream(m_Stream);
+ *outStream = tempStream.Detach();
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipOut.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipOut.h
new file mode 100644
index 000000000..24bc83a1f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipOut.h
@@ -0,0 +1,56 @@
+// ZipOut.h
+
+#ifndef __ZIP_OUT_H
+#define __ZIP_OUT_H
+
+#include "Common/MyCom.h"
+
+#include "../../IStream.h"
+#include "../../Common/OutBuffer.h"
+
+#include "ZipItem.h"
+
+namespace NArchive {
+namespace NZip {
+
+// can throw CSystemException and COutBufferException
+
+class COutArchive
+{
+ CMyComPtr<IOutStream> m_Stream;
+ COutBuffer m_OutBuffer;
+
+ UInt64 m_BasePosition;
+ UInt32 m_LocalFileHeaderSize;
+ UInt32 m_ExtraSize;
+ bool m_IsZip64;
+
+ void WriteBytes(const void *buffer, UInt32 size);
+ void WriteByte(Byte b);
+ void WriteUInt16(UInt16 value);
+ void WriteUInt32(UInt32 value);
+ void WriteUInt64(UInt64 value);
+
+ void WriteExtraHeader(const CItem &item);
+ void WriteCentralHeader(const CItem &item);
+ void WriteExtra(const CExtraBlock &extra);
+ void SeekTo(UInt64 offset);
+public:
+ void Create(IOutStream *outStream);
+ void MoveBasePosition(UInt64 distanceToMove);
+ UInt64 GetCurrentPosition() const { return m_BasePosition; };
+ void PrepareWriteCompressedDataZip64(UInt16 fileNameLength, bool isZip64, bool aesEncryption);
+ void PrepareWriteCompressedData(UInt16 fileNameLength, UInt64 unPackSize, bool aesEncryption);
+ void PrepareWriteCompressedData2(UInt16 fileNameLength, UInt64 unPackSize, UInt64 packSize, bool aesEncryption);
+ void WriteLocalHeader(const CLocalItem &item);
+
+ void WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer &comment);
+
+ void CreateStreamForCompressing(IOutStream **outStream);
+ void CreateStreamForCopying(ISequentialOutStream **outStream);
+ void SeekToPackedDataPosition();
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipRegister.cpp
new file mode 100644
index 000000000..2fd369508
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipRegister.cpp
@@ -0,0 +1,18 @@
+// ZipRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "ZipHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NZip::CHandler; }
+#ifndef EXTRACT_ONLY
+static IOutArchive *CreateArcOut() { return new NArchive::NZip::CHandler; }
+#else
+#define CreateArcOut 0
+#endif
+
+static CArcInfo g_ArcInfo =
+ { L"Zip", L"zip jar xpi odt ods docx xlsx", 0, 1, { 0x50, 0x4B, 0x03, 0x04 }, 4, false, CreateArc, CreateArcOut };
+
+REGISTER_ARC(Zip)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipUpdate.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipUpdate.cpp
new file mode 100644
index 000000000..0f67f16c3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipUpdate.cpp
@@ -0,0 +1,855 @@
+// ZipUpdate.cpp
+
+#include "StdAfx.h"
+
+#include "Common/AutoPtr.h"
+#include "Common/Defs.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Defs.h"
+#include "Windows/Thread.h"
+
+#include "../../Common/CreateCoder.h"
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/OutMemStream.h"
+#include "../../Common/ProgressUtils.h"
+#ifdef COMPRESS_MT
+#include "../../Common/ProgressMt.h"
+#endif
+
+#include "../../Compress/CopyCoder.h"
+
+#include "ZipAddCommon.h"
+#include "ZipOut.h"
+#include "ZipUpdate.h"
+
+using namespace NWindows;
+using namespace NSynchronization;
+
+namespace NArchive {
+namespace NZip {
+
+static const Byte kHostOS =
+ #ifdef _WIN32
+ NFileHeader::NHostOS::kFAT;
+ #else
+ NFileHeader::NHostOS::kUnix;
+ #endif
+
+static const Byte kMadeByHostOS = kHostOS;
+static const Byte kExtractHostOS = kHostOS;
+
+static const Byte kMethodForDirectory = NFileHeader::NCompressionMethod::kStored;
+static const Byte kExtractVersionForDirectory = NFileHeader::NCompressionMethod::kStoreExtractVersion;
+
+static HRESULT CopyBlockToArchive(ISequentialInStream *inStream,
+ COutArchive &outArchive, ICompressProgressInfo *progress)
+{
+ CMyComPtr<ISequentialOutStream> outStream;
+ outArchive.CreateStreamForCopying(&outStream);
+ return NCompress::CopyStream(inStream, outStream, progress);
+}
+
+static HRESULT WriteRange(IInStream *inStream, COutArchive &outArchive,
+ const CUpdateRange &range, ICompressProgressInfo *progress)
+{
+ UInt64 position;
+ RINOK(inStream->Seek(range.Position, STREAM_SEEK_SET, &position));
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
+ streamSpec->SetStream(inStream);
+ streamSpec->Init(range.Size);
+
+ RINOK(CopyBlockToArchive(inStreamLimited, outArchive, progress));
+ return progress->SetRatioInfo(&range.Size, &range.Size);
+}
+
+static void SetFileHeader(
+ COutArchive &archive,
+ const CCompressionMethodMode &options,
+ const CUpdateItem &ui,
+ CItem &item)
+{
+ item.UnPackSize = ui.Size;
+ bool isDir;
+
+ item.ClearFlags();
+
+ if (ui.NewProperties)
+ {
+ isDir = ui.IsDir;
+ item.Name = ui.Name;
+ item.SetUtf8(ui.IsUtf8);
+ item.ExternalAttributes = ui.Attributes;
+ item.Time = ui.Time;
+ item.NtfsMTime = ui.NtfsMTime;
+ item.NtfsATime = ui.NtfsATime;
+ item.NtfsCTime = ui.NtfsCTime;
+ item.NtfsTimeIsDefined = ui.NtfsTimeIsDefined;
+ }
+ else
+ isDir = item.IsDir();
+
+ item.LocalHeaderPosition = archive.GetCurrentPosition();
+ item.MadeByVersion.HostOS = kMadeByHostOS;
+ item.MadeByVersion.Version = NFileHeader::NCompressionMethod::kMadeByProgramVersion;
+
+ item.ExtractVersion.HostOS = kExtractHostOS;
+
+ item.InternalAttributes = 0; // test it
+ item.SetEncrypted(!isDir && options.PasswordIsDefined);
+ if (isDir)
+ {
+ item.ExtractVersion.Version = kExtractVersionForDirectory;
+ item.CompressionMethod = kMethodForDirectory;
+ item.PackSize = 0;
+ item.FileCRC = 0; // test it
+ }
+}
+
+static void SetItemInfoFromCompressingResult(const CCompressingResult &compressingResult,
+ bool isAesMode, Byte aesKeyMode, CItem &item)
+{
+ item.ExtractVersion.Version = compressingResult.ExtractVersion;
+ item.CompressionMethod = compressingResult.Method;
+ item.FileCRC = compressingResult.CRC;
+ item.UnPackSize = compressingResult.UnpackSize;
+ item.PackSize = compressingResult.PackSize;
+
+ item.LocalExtra.Clear();
+ item.CentralExtra.Clear();
+
+ if (isAesMode)
+ {
+ CWzAesExtraField wzAesField;
+ wzAesField.Strength = aesKeyMode;
+ wzAesField.Method = compressingResult.Method;
+ item.CompressionMethod = NFileHeader::NCompressionMethod::kWzAES;
+ item.FileCRC = 0;
+ CExtraSubBlock sb;
+ wzAesField.SetSubBlock(sb);
+ item.LocalExtra.SubBlocks.Add(sb);
+ item.CentralExtra.SubBlocks.Add(sb);
+ }
+}
+
+#ifdef COMPRESS_MT
+
+static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo);
+
+struct CThreadInfo
+{
+ #ifdef EXTERNAL_CODECS
+ CMyComPtr<ICompressCodecsInfo> _codecsInfo;
+ const CObjectVector<CCodecInfoEx> *_externalCodecs;
+ #endif
+
+ NWindows::CThread Thread;
+ NWindows::NSynchronization::CAutoResetEvent CompressEvent;
+ NWindows::NSynchronization::CAutoResetEventWFMO CompressionCompletedEvent;
+ bool ExitThread;
+
+ CMtCompressProgress *ProgressSpec;
+ CMyComPtr<ICompressProgressInfo> Progress;
+
+ COutMemStream *OutStreamSpec;
+ CMyComPtr<IOutStream> OutStream;
+ CMyComPtr<ISequentialInStream> InStream;
+
+ CAddCommon Coder;
+ HRESULT Result;
+ CCompressingResult CompressingResult;
+
+ bool IsFree;
+ UInt32 UpdateIndex;
+
+ CThreadInfo(const CCompressionMethodMode &options):
+ ExitThread(false),
+ ProgressSpec(0),
+ OutStreamSpec(0),
+ Coder(options)
+ {}
+
+ HRESULT CreateEvents(CSynchro *sync)
+ {
+ RINOK(CompressEvent.CreateIfNotCreated());
+ return CompressionCompletedEvent.CreateIfNotCreated(sync);
+ }
+ HRes CreateThread() { return Thread.Create(CoderThread, this); }
+
+ void WaitAndCode();
+ void StopWaitClose()
+ {
+ ExitThread = true;
+ if (OutStreamSpec != 0)
+ OutStreamSpec->StopWriting(E_ABORT);
+ if (CompressEvent.IsCreated())
+ CompressEvent.Set();
+ Thread.Wait();
+ Thread.Close();
+ }
+
+};
+
+void CThreadInfo::WaitAndCode()
+{
+ for (;;)
+ {
+ CompressEvent.Lock();
+ if (ExitThread)
+ return;
+ Result = Coder.Compress(
+ #ifdef EXTERNAL_CODECS
+ _codecsInfo, _externalCodecs,
+ #endif
+ InStream, OutStream, Progress, CompressingResult);
+ if (Result == S_OK && Progress)
+ Result = Progress->SetRatioInfo(&CompressingResult.UnpackSize, &CompressingResult.PackSize);
+ CompressionCompletedEvent.Set();
+ }
+}
+
+static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
+{
+ ((CThreadInfo *)threadCoderInfo)->WaitAndCode();
+ return 0;
+}
+
+class CThreads
+{
+public:
+ CObjectVector<CThreadInfo> Threads;
+ ~CThreads()
+ {
+ for (int i = 0; i < Threads.Size(); i++)
+ Threads[i].StopWaitClose();
+ }
+};
+
+struct CMemBlocks2: public CMemLockBlocks
+{
+ CCompressingResult CompressingResult;
+ bool Defined;
+ bool Skip;
+ CMemBlocks2(): Defined(false), Skip(false) {}
+};
+
+class CMemRefs
+{
+public:
+ CMemBlockManagerMt *Manager;
+ CObjectVector<CMemBlocks2> Refs;
+ CMemRefs(CMemBlockManagerMt *manager): Manager(manager) {} ;
+ ~CMemRefs()
+ {
+ for (int i = 0; i < Refs.Size(); i++)
+ Refs[i].FreeOpt(Manager);
+ }
+};
+
+class CMtProgressMixer2:
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+ UInt64 ProgressOffset;
+ UInt64 InSizes[2];
+ UInt64 OutSizes[2];
+ CMyComPtr<IProgress> Progress;
+ CMyComPtr<ICompressProgressInfo> RatioProgress;
+ bool _inSizeIsMain;
+public:
+ NWindows::NSynchronization::CCriticalSection CriticalSection;
+ MY_UNKNOWN_IMP
+ void Create(IProgress *progress, bool inSizeIsMain);
+ void SetProgressOffset(UInt64 progressOffset);
+ HRESULT SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize);
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+};
+
+void CMtProgressMixer2::Create(IProgress *progress, bool inSizeIsMain)
+{
+ Progress = progress;
+ Progress.QueryInterface(IID_ICompressProgressInfo, &RatioProgress);
+ _inSizeIsMain = inSizeIsMain;
+ ProgressOffset = InSizes[0] = InSizes[1] = OutSizes[0] = OutSizes[1] = 0;
+}
+
+void CMtProgressMixer2::SetProgressOffset(UInt64 progressOffset)
+{
+ CriticalSection.Enter();
+ InSizes[1] = OutSizes[1] = 0;
+ ProgressOffset = progressOffset;
+ CriticalSection.Leave();
+}
+
+HRESULT CMtProgressMixer2::SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize)
+{
+ NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
+ if (index == 0 && RatioProgress)
+ {
+ RINOK(RatioProgress->SetRatioInfo(inSize, outSize));
+ }
+ if (inSize != 0)
+ InSizes[index] = *inSize;
+ if (outSize != 0)
+ OutSizes[index] = *outSize;
+ UInt64 v = ProgressOffset + (_inSizeIsMain ?
+ (InSizes[0] + InSizes[1]) :
+ (OutSizes[0] + OutSizes[1]));
+ return Progress->SetCompleted(&v);
+}
+
+STDMETHODIMP CMtProgressMixer2::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ return SetRatioInfo(0, inSize, outSize);
+}
+
+class CMtProgressMixer:
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+public:
+ CMtProgressMixer2 *Mixer2;
+ CMyComPtr<ICompressProgressInfo> RatioProgress;
+ void Create(IProgress *progress, bool inSizeIsMain);
+ MY_UNKNOWN_IMP
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+};
+
+void CMtProgressMixer::Create(IProgress *progress, bool inSizeIsMain)
+{
+ Mixer2 = new CMtProgressMixer2;
+ RatioProgress = Mixer2;
+ Mixer2->Create(progress, inSizeIsMain);
+}
+
+STDMETHODIMP CMtProgressMixer::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ return Mixer2->SetRatioInfo(1, inSize, outSize);
+}
+
+
+#endif
+
+
+static HRESULT UpdateItemOldData(COutArchive &archive,
+ IInStream *inStream,
+ const CUpdateItem &ui, CItemEx &item,
+ /* bool izZip64, */
+ ICompressProgressInfo *progress,
+ UInt64 &complexity)
+{
+ if (ui.NewProperties)
+ {
+ if (item.HasDescriptor())
+ return E_NOTIMPL;
+
+ // use old name size.
+ // CUpdateRange range(item.GetLocalExtraPosition(), item.LocalExtraSize + item.PackSize);
+ CUpdateRange range(item.GetDataPosition(), item.PackSize);
+
+ // item.ExternalAttributes = ui.Attributes;
+ // Test it
+ item.Name = ui.Name;
+ item.SetUtf8(ui.IsUtf8);
+ item.Time = ui.Time;
+ item.NtfsMTime = ui.NtfsMTime;
+ item.NtfsATime = ui.NtfsATime;
+ item.NtfsCTime = ui.NtfsCTime;
+ item.NtfsTimeIsDefined = ui.NtfsTimeIsDefined;
+
+ item.CentralExtra.RemoveUnknownSubBlocks();
+ item.LocalExtra.RemoveUnknownSubBlocks();
+
+ archive.PrepareWriteCompressedData2((UInt16)item.Name.Length(), item.UnPackSize, item.PackSize, item.LocalExtra.HasWzAesField());
+ item.LocalHeaderPosition = archive.GetCurrentPosition();
+ archive.SeekToPackedDataPosition();
+ RINOK(WriteRange(inStream, archive, range, progress));
+ complexity += range.Size;
+ archive.WriteLocalHeader(item);
+ }
+ else
+ {
+ CUpdateRange range(item.LocalHeaderPosition, item.GetLocalFullSize());
+
+ // set new header position
+ item.LocalHeaderPosition = archive.GetCurrentPosition();
+
+ RINOK(WriteRange(inStream, archive, range, progress));
+ complexity += range.Size;
+ archive.MoveBasePosition(range.Size);
+ }
+ return S_OK;
+}
+
+static void WriteDirHeader(COutArchive &archive, const CCompressionMethodMode *options,
+ const CUpdateItem &ui, CItemEx &item)
+{
+ SetFileHeader(archive, *options, ui, item);
+ archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), ui.Size, options->IsAesMode);
+ archive.WriteLocalHeader(item);
+}
+
+static HRESULT Update2St(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ COutArchive &archive,
+ CInArchive *inArchive,
+ IInStream *inStream,
+ const CObjectVector<CItemEx> &inputItems,
+ const CObjectVector<CUpdateItem> &updateItems,
+ const CCompressionMethodMode *options,
+ const CByteBuffer &comment,
+ IArchiveUpdateCallback *updateCallback)
+{
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(updateCallback, true);
+
+ CAddCommon compressor(*options);
+
+ CObjectVector<CItem> items;
+ UInt64 unpackSizeTotal = 0, packSizeTotal = 0;
+
+ for (int itemIndex = 0; itemIndex < updateItems.Size(); itemIndex++)
+ {
+ lps->InSize = unpackSizeTotal;
+ lps->OutSize = packSizeTotal;
+ RINOK(lps->SetCur());
+ const CUpdateItem &ui = updateItems[itemIndex];
+ CItemEx item;
+ if (!ui.NewProperties || !ui.NewData)
+ {
+ item = inputItems[ui.IndexInArchive];
+ if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
+ return E_NOTIMPL;
+ }
+
+ if (ui.NewData)
+ {
+ bool isDir = ((ui.NewProperties) ? ui.IsDir : item.IsDir());
+ if (isDir)
+ {
+ WriteDirHeader(archive, options, ui, item);
+ }
+ else
+ {
+ CMyComPtr<ISequentialInStream> fileInStream;
+ HRESULT res = updateCallback->GetStream(ui.IndexInClient, &fileInStream);
+ if (res == S_FALSE)
+ {
+ lps->ProgressOffset += ui.Size;
+ RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ continue;
+ }
+ RINOK(res);
+
+ // file Size can be 64-bit !!!
+ SetFileHeader(archive, *options, ui, item);
+ archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), ui.Size, options->IsAesMode);
+ CCompressingResult compressingResult;
+ CMyComPtr<IOutStream> outStream;
+ archive.CreateStreamForCompressing(&outStream);
+ RINOK(compressor.Compress(
+ EXTERNAL_CODECS_LOC_VARS
+ fileInStream, outStream, progress, compressingResult));
+ SetItemInfoFromCompressingResult(compressingResult, options->IsAesMode, options->AesKeyMode, item);
+ archive.WriteLocalHeader(item);
+ RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ unpackSizeTotal += item.UnPackSize;
+ packSizeTotal += item.PackSize;
+ }
+ }
+ else
+ {
+ UInt64 complexity = 0;
+ lps->SendRatio = false;
+ RINOK(UpdateItemOldData(archive, inStream, ui, item, progress, complexity));
+ lps->SendRatio = true;
+ lps->ProgressOffset += complexity;
+ }
+ items.Add(item);
+ lps->ProgressOffset += NFileHeader::kLocalBlockSize;
+ }
+ archive.WriteCentralDir(items, comment);
+ return S_OK;
+}
+
+static HRESULT Update2(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ COutArchive &archive,
+ CInArchive *inArchive,
+ IInStream *inStream,
+ const CObjectVector<CItemEx> &inputItems,
+ const CObjectVector<CUpdateItem> &updateItems,
+ const CCompressionMethodMode *options,
+ const CByteBuffer &comment,
+ IArchiveUpdateCallback *updateCallback)
+{
+ UInt64 complexity = 0;
+ UInt64 numFilesToCompress = 0;
+ UInt64 numBytesToCompress = 0;
+
+ int i;
+ for(i = 0; i < updateItems.Size(); i++)
+ {
+ const CUpdateItem &ui = updateItems[i];
+ if (ui.NewData)
+ {
+ complexity += ui.Size;
+ numBytesToCompress += ui.Size;
+ numFilesToCompress++;
+ /*
+ if (ui.Commented)
+ complexity += ui.CommentRange.Size;
+ */
+ }
+ else
+ {
+ CItemEx inputItem = inputItems[ui.IndexInArchive];
+ if (inArchive->ReadLocalItemAfterCdItemFull(inputItem) != S_OK)
+ return E_NOTIMPL;
+ complexity += inputItem.GetLocalFullSize();
+ // complexity += inputItem.GetCentralExtraPlusCommentSize();
+ }
+ complexity += NFileHeader::kLocalBlockSize;
+ complexity += NFileHeader::kCentralBlockSize;
+ }
+
+ if (comment != 0)
+ complexity += comment.GetCapacity();
+ complexity++; // end of central
+ updateCallback->SetTotal(complexity);
+
+ CAddCommon compressor(*options);
+
+ complexity = 0;
+
+ #ifdef COMPRESS_MT
+
+ const size_t kNumMaxThreads = (1 << 10);
+ UInt32 numThreads = options->NumThreads;
+ if (numThreads > kNumMaxThreads)
+ numThreads = kNumMaxThreads;
+
+ const size_t kMemPerThread = (1 << 25);
+ const size_t kBlockSize = 1 << 16;
+
+ CCompressionMethodMode options2;
+ if (options != 0)
+ options2 = *options;
+
+ bool mtMode = ((options != 0) && (numThreads > 1));
+
+ if (numFilesToCompress <= 1)
+ mtMode = false;
+
+ if (mtMode)
+ {
+ Byte method = options->MethodSequence.Front();
+ if (method == NFileHeader::NCompressionMethod::kStored && !options->PasswordIsDefined)
+ mtMode = false;
+ if (method == NFileHeader::NCompressionMethod::kBZip2)
+ {
+ UInt64 averageSize = numBytesToCompress / numFilesToCompress;
+ UInt32 blockSize = options->DicSize;
+ if (blockSize == 0)
+ blockSize = 1;
+ UInt64 averageNumberOfBlocks = averageSize / blockSize;
+ UInt32 numBZip2Threads = 32;
+ if (averageNumberOfBlocks < numBZip2Threads)
+ numBZip2Threads = (UInt32)averageNumberOfBlocks;
+ if (numBZip2Threads < 1)
+ numBZip2Threads = 1;
+ numThreads = numThreads / numBZip2Threads;
+ options2.NumThreads = numBZip2Threads;
+ if (numThreads <= 1)
+ mtMode = false;
+ }
+ if (method == NFileHeader::NCompressionMethod::kLZMA)
+ {
+ UInt32 numLZMAThreads = (options->Algo > 0 ? 2 : 1);
+ numThreads /= numLZMAThreads;
+ options2.NumThreads = numLZMAThreads;
+ if (numThreads <= 1)
+ mtMode = false;
+ }
+ }
+
+ if (!mtMode)
+ #endif
+ return Update2St(
+ EXTERNAL_CODECS_LOC_VARS
+ archive, inArchive,inStream,
+ inputItems, updateItems, options, comment, updateCallback);
+
+
+ #ifdef COMPRESS_MT
+
+ // Warning : before memManager, threads and compressingCompletedEvents
+ // in order to have a "good" order for the destructor
+ NWindows::NSynchronization::CSynchro synchroForCompressingCompletedEvents;
+ synchroForCompressingCompletedEvents.Create();
+ NWindows::NSynchronization::CSynchro synchroForOutStreamSpec;
+ synchroForOutStreamSpec.Create();
+
+
+ CObjectVector<CItem> items;
+
+ CMtProgressMixer *mtProgressMixerSpec = new CMtProgressMixer;
+ CMyComPtr<ICompressProgressInfo> progress = mtProgressMixerSpec;
+ mtProgressMixerSpec->Create(updateCallback, true);
+
+ CMtCompressProgressMixer mtCompressProgressMixer;
+ mtCompressProgressMixer.Init(numThreads, mtProgressMixerSpec->RatioProgress);
+
+ CMemBlockManagerMt memManager(kBlockSize);
+ CMemRefs refs(&memManager);
+
+ CThreads threads;
+ CRecordVector<HANDLE> compressingCompletedEvents;
+ CRecordVector<int> threadIndices; // list threads in order of updateItems
+
+ {
+ RINOK(memManager.AllocateSpaceAlways(&synchroForOutStreamSpec,(size_t)numThreads * (kMemPerThread / kBlockSize)));
+ for(i = 0; i < updateItems.Size(); i++)
+ refs.Refs.Add(CMemBlocks2());
+
+ UInt32 i;
+ for (i = 0; i < numThreads; i++)
+ threads.Threads.Add(CThreadInfo(options2));
+
+ for (i = 0; i < numThreads; i++)
+ {
+ CThreadInfo &threadInfo = threads.Threads[i];
+ #ifdef EXTERNAL_CODECS
+ threadInfo._codecsInfo = codecsInfo;
+ threadInfo._externalCodecs = externalCodecs;
+ #endif
+ RINOK(threadInfo.CreateEvents(&synchroForCompressingCompletedEvents));
+ threadInfo.OutStreamSpec = new COutMemStream(&memManager);
+ RINOK(threadInfo.OutStreamSpec->CreateEvents(&synchroForOutStreamSpec));
+ threadInfo.OutStream = threadInfo.OutStreamSpec;
+ threadInfo.IsFree = true;
+ threadInfo.ProgressSpec = new CMtCompressProgress();
+ threadInfo.Progress = threadInfo.ProgressSpec;
+ threadInfo.ProgressSpec->Init(&mtCompressProgressMixer, (int)i);
+ RINOK(threadInfo.CreateThread());
+ }
+ }
+ int mtItemIndex = 0;
+
+ int itemIndex = 0;
+ int lastRealStreamItemIndex = -1;
+
+ while (itemIndex < updateItems.Size())
+ {
+ if ((UInt32)threadIndices.Size() < numThreads && mtItemIndex < updateItems.Size())
+ {
+ const CUpdateItem &ui = updateItems[mtItemIndex++];
+ if (!ui.NewData)
+ continue;
+ CItemEx item;
+ if (ui.NewProperties)
+ {
+ if (ui.IsDir)
+ continue;
+ }
+ else
+ {
+ item = inputItems[ui.IndexInArchive];
+ if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
+ return E_NOTIMPL;
+ if (item.IsDir())
+ continue;
+ }
+ CMyComPtr<ISequentialInStream> fileInStream;
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(mtProgressMixerSpec->Mixer2->CriticalSection);
+ HRESULT res = updateCallback->GetStream(ui.IndexInClient, &fileInStream);
+ if (res == S_FALSE)
+ {
+ complexity += ui.Size;
+ complexity += NFileHeader::kLocalBlockSize;
+ mtProgressMixerSpec->Mixer2->SetProgressOffset(complexity);
+ RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ refs.Refs[mtItemIndex - 1].Skip = true;
+ continue;
+ }
+ RINOK(res);
+ RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ }
+
+ for (UInt32 i = 0; i < numThreads; i++)
+ {
+ CThreadInfo &threadInfo = threads.Threads[i];
+ if (threadInfo.IsFree)
+ {
+ threadInfo.IsFree = false;
+ threadInfo.InStream = fileInStream;
+
+ // !!!!! we must release ref before sending event
+ // BUG was here in v4.43 and v4.44. It could change ref counter in two threads in same time
+ fileInStream.Release();
+
+ threadInfo.OutStreamSpec->Init();
+ threadInfo.ProgressSpec->Reinit();
+ threadInfo.CompressEvent.Set();
+ threadInfo.UpdateIndex = mtItemIndex - 1;
+
+ compressingCompletedEvents.Add(threadInfo.CompressionCompletedEvent);
+ threadIndices.Add(i);
+ break;
+ }
+ }
+ continue;
+ }
+
+ if (refs.Refs[itemIndex].Skip)
+ {
+ itemIndex++;
+ continue;
+ }
+
+ const CUpdateItem &ui = updateItems[itemIndex];
+
+ CItemEx item;
+ if (!ui.NewProperties || !ui.NewData)
+ {
+ item = inputItems[ui.IndexInArchive];
+ if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
+ return E_NOTIMPL;
+ }
+
+ if (ui.NewData)
+ {
+ bool isDir = ((ui.NewProperties) ? ui.IsDir : item.IsDir());
+ if (isDir)
+ {
+ WriteDirHeader(archive, options, ui, item);
+ }
+ else
+ {
+ if (lastRealStreamItemIndex < itemIndex)
+ {
+ lastRealStreamItemIndex = itemIndex;
+ SetFileHeader(archive, *options, ui, item);
+ // file Size can be 64-bit !!!
+ archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), ui.Size, options->IsAesMode);
+ }
+
+ CMemBlocks2 &memRef = refs.Refs[itemIndex];
+ if (memRef.Defined)
+ {
+ CMyComPtr<IOutStream> outStream;
+ archive.CreateStreamForCompressing(&outStream);
+ memRef.WriteToStream(memManager.GetBlockSize(), outStream);
+ SetItemInfoFromCompressingResult(memRef.CompressingResult,
+ options->IsAesMode, options->AesKeyMode, item);
+ SetFileHeader(archive, *options, ui, item);
+ archive.WriteLocalHeader(item);
+ // RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ memRef.FreeOpt(&memManager);
+ }
+ else
+ {
+ {
+ CThreadInfo &thread = threads.Threads[threadIndices.Front()];
+ if (!thread.OutStreamSpec->WasUnlockEventSent())
+ {
+ CMyComPtr<IOutStream> outStream;
+ archive.CreateStreamForCompressing(&outStream);
+ thread.OutStreamSpec->SetOutStream(outStream);
+ thread.OutStreamSpec->SetRealStreamMode();
+ }
+ }
+
+ DWORD result = ::WaitForMultipleObjects(compressingCompletedEvents.Size(),
+ &compressingCompletedEvents.Front(), FALSE, INFINITE);
+ int t = (int)(result - WAIT_OBJECT_0);
+ CThreadInfo &threadInfo = threads.Threads[threadIndices[t]];
+ threadInfo.InStream.Release();
+ threadInfo.IsFree = true;
+ RINOK(threadInfo.Result);
+ threadIndices.Delete(t);
+ compressingCompletedEvents.Delete(t);
+ if (t == 0)
+ {
+ RINOK(threadInfo.OutStreamSpec->WriteToRealStream());
+ threadInfo.OutStreamSpec->ReleaseOutStream();
+ SetItemInfoFromCompressingResult(threadInfo.CompressingResult,
+ options->IsAesMode, options->AesKeyMode, item);
+ SetFileHeader(archive, *options, ui, item);
+ archive.WriteLocalHeader(item);
+ }
+ else
+ {
+ CMemBlocks2 &memRef = refs.Refs[threadInfo.UpdateIndex];
+ threadInfo.OutStreamSpec->DetachData(memRef);
+ memRef.CompressingResult = threadInfo.CompressingResult;
+ memRef.Defined = true;
+ continue;
+ }
+ }
+ }
+ }
+ else
+ {
+ RINOK(UpdateItemOldData(archive, inStream, ui, item, progress, complexity));
+ }
+ items.Add(item);
+ complexity += NFileHeader::kLocalBlockSize;
+ mtProgressMixerSpec->Mixer2->SetProgressOffset(complexity);
+ itemIndex++;
+ }
+ archive.WriteCentralDir(items, comment);
+ return S_OK;
+ #endif
+}
+
+HRESULT Update(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ const CObjectVector<CItemEx> &inputItems,
+ const CObjectVector<CUpdateItem> &updateItems,
+ ISequentialOutStream *seqOutStream,
+ CInArchive *inArchive,
+ CCompressionMethodMode *compressionMethodMode,
+ IArchiveUpdateCallback *updateCallback)
+{
+ CMyComPtr<IOutStream> outStream;
+ RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream));
+ if (!outStream)
+ return E_NOTIMPL;
+
+ CInArchiveInfo archiveInfo;
+ if(inArchive != 0)
+ {
+ inArchive->GetArchiveInfo(archiveInfo);
+ if (archiveInfo.Base != 0)
+ return E_NOTIMPL;
+ }
+ else
+ archiveInfo.StartPosition = 0;
+
+ COutArchive outArchive;
+ outArchive.Create(outStream);
+ if (archiveInfo.StartPosition > 0)
+ {
+ CMyComPtr<ISequentialInStream> inStream;
+ inStream.Attach(inArchive->CreateLimitedStream(0, archiveInfo.StartPosition));
+ RINOK(CopyBlockToArchive(inStream, outArchive, NULL));
+ outArchive.MoveBasePosition(archiveInfo.StartPosition);
+ }
+ CMyComPtr<IInStream> inStream;
+ if(inArchive != 0)
+ inStream.Attach(inArchive->CreateStream());
+
+ return Update2(
+ EXTERNAL_CODECS_LOC_VARS
+ outArchive, inArchive, inStream,
+ inputItems, updateItems,
+ compressionMethodMode,
+ archiveInfo.Comment, updateCallback);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipUpdate.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipUpdate.h
new file mode 100644
index 000000000..eee16738c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Archive/Zip/ZipUpdate.h
@@ -0,0 +1,58 @@
+// Zip/Update.h
+
+#ifndef __ZIP_UPDATE_H
+#define __ZIP_UPDATE_H
+
+#include "../../ICoder.h"
+#include "../IArchive.h"
+
+#include "../../Common/CreateCoder.h"
+
+#include "ZipCompressionMode.h"
+#include "ZipIn.h"
+
+namespace NArchive {
+namespace NZip {
+
+struct CUpdateRange
+{
+ UInt64 Position;
+ UInt64 Size;
+ CUpdateRange() {};
+ CUpdateRange(UInt64 position, UInt64 size): Position(position), Size(size) {};
+};
+
+struct CUpdateItem
+{
+ bool NewData;
+ bool NewProperties;
+ bool IsDir;
+ bool NtfsTimeIsDefined;
+ bool IsUtf8;
+ int IndexInArchive;
+ int IndexInClient;
+ UInt32 Attributes;
+ UInt32 Time;
+ UInt64 Size;
+ AString Name;
+ // bool Commented;
+ // CUpdateRange CommentRange;
+ FILETIME NtfsMTime;
+ FILETIME NtfsATime;
+ FILETIME NtfsCTime;
+
+ CUpdateItem(): NtfsTimeIsDefined(false), IsUtf8(false), Size(0) {}
+};
+
+HRESULT Update(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ const CObjectVector<CItemEx> &inputItems,
+ const CObjectVector<CUpdateItem> &updateItems,
+ ISequentialOutStream *seqOutStream,
+ CInArchive *inArchive,
+ CCompressionMethodMode *compressionMethodMode,
+ IArchiveUpdateCallback *updateCallback);
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Bundles/SFXCon/Main.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Bundles/SFXCon/Main.cpp
new file mode 100644
index 000000000..95866fcf8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Bundles/SFXCon/Main.cpp
@@ -0,0 +1,441 @@
+// Main.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+
+#include "Common/CommandLineParser.h"
+#include "Common/MyException.h"
+
+#ifdef _WIN32
+#include "Windows/DLL.h"
+#include "Windows/FileDir.h"
+#else
+#include "Common/StringConvert.h"
+#include "Windows/System.h"
+#endif
+
+#include "../../UI/Common/ExitCode.h"
+#include "../../UI/Common/Extract.h"
+
+#include "../../UI/Console/ExtractCallbackConsole.h"
+#include "../../UI/Console/List.h"
+#include "../../UI/Console/OpenCallbackConsole.h"
+
+#include "../../MyVersion.h"
+
+#include "myPrivate.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NCommandLineParser;
+
+extern CStdOutStream *g_StdStream;
+
+static const char *kCopyrightString =
+"\n7-Zip SFX " MY_VERSION_COPYRIGHT_DATE "\n"
+"p7zip Version " P7ZIP_VERSION ;
+
+static const int kNumSwitches = 6;
+
+namespace NKey {
+enum Enum
+{
+ kHelp1 = 0,
+ kHelp2,
+ kDisablePercents,
+ kYes,
+ kPassword,
+ kOutputDir
+};
+
+}
+
+namespace NRecursedType {
+enum EEnum
+{
+ kRecursed,
+ kWildCardOnlyRecursed,
+ kNonRecursed
+};
+}
+/*
+static const char kRecursedIDChar = 'R';
+static const wchar_t *kRecursedPostCharSet = L"0-";
+
+namespace NRecursedPostCharIndex {
+ enum EEnum
+ {
+ kWildCardRecursionOnly = 0,
+ kNoRecursion = 1
+ };
+}
+
+static const char kFileListID = '@';
+static const char kImmediateNameID = '!';
+
+static const char kSomeCludePostStringMinSize = 2; // at least <@|!><N>ame must be
+static const char kSomeCludeAfterRecursedPostStringMinSize = 2; // at least <@|!><N>ame must be
+*/
+static const CSwitchForm kSwitchForms[kNumSwitches] =
+ {
+ { L"?", NSwitchType::kSimple, false },
+ { L"H", NSwitchType::kSimple, false },
+ { L"BD", NSwitchType::kSimple, false },
+ { L"Y", NSwitchType::kSimple, false },
+ { L"P", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"O", NSwitchType::kUnLimitedPostString, false, 1 },
+ };
+
+static const int kNumCommandForms = 3;
+
+namespace NCommandType {
+enum EEnum
+{
+ kTest = 0,
+ // kExtract,
+ kFullExtract,
+ kList
+};
+
+}
+
+static const CCommandForm commandForms[kNumCommandForms] =
+{
+ { L"T", false },
+ // { "E", false },
+ { L"X", false },
+ { L"L", false }
+};
+
+static const NRecursedType::EEnum kCommandRecursedDefault[kNumCommandForms] =
+{
+ NRecursedType::kRecursed
+};
+
+// static const bool kTestExtractRecursedDefault = true;
+// static const bool kAddRecursedDefault = false;
+
+static const wchar_t *kUniversalWildcard = L"*";
+static const int kCommandIndex = 0;
+
+static const char *kHelpString =
+ "\nUsage: 7zSFX [<command>] [<switches>...]\n"
+ "\n"
+ "<Commands>\n"
+ " l: List contents of archive\n"
+ " t: Test integrity of archive\n"
+ " x: eXtract files with full pathname (default)\n"
+ "<Switches>\n"
+ // " -bd Disable percentage indicator\n"
+ " -o{Directory}: set Output directory\n"
+ " -p{Password}: set Password\n"
+ " -y: assume Yes on all queries\n";
+
+
+// ---------------------------
+// exception messages
+
+static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode::kUserError
+// static const char *kIncorrectListFile = "Incorrect wildcard in listfile";
+static const char *kIncorrectWildCardInCommandLine = "Incorrect wildcard in command line";
+
+// static const CSysString kFileIsNotArchiveMessageBefore = "File \"";
+// static const CSysString kFileIsNotArchiveMessageAfter = "\" is not archive";
+
+// static const char *kProcessArchiveMessage = " archive: ";
+
+static const char *kCantFindSFX = " cannot find sfx";
+
+
+struct CArchiveCommand
+{
+ NCommandType::EEnum CommandType;
+ NRecursedType::EEnum DefaultRecursedType() const;
+};
+
+NRecursedType::EEnum CArchiveCommand::DefaultRecursedType() const
+{
+ return kCommandRecursedDefault[CommandType];
+}
+
+void PrintHelp(void)
+{
+ g_StdOut << kHelpString;
+}
+
+static void ShowMessageAndThrowException(const char *message, NExitCode::EEnum code)
+{
+ g_StdOut << message << endl;
+ throw code;
+}
+
+static void PrintHelpAndExit() // yyy
+{
+ PrintHelp();
+ ShowMessageAndThrowException(kUserErrorMessage, NExitCode::kUserError);
+}
+
+bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &command)
+{
+ UString commandStringUpper = commandString;
+ commandStringUpper.MakeUpper();
+ UString postString;
+ int commandIndex = ParseCommand(kNumCommandForms, commandForms, commandStringUpper,
+ postString) ;
+ if (commandIndex < 0)
+ return false;
+ command.CommandType = (NCommandType::EEnum)commandIndex;
+ return true;
+}
+
+// ------------------------------------------------------------------
+// filenames functions
+
+static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
+ const UString &name, bool include, NRecursedType::EEnum type)
+{
+ /*
+ if(!IsWildCardFilePathLegal(name))
+ return false;
+ */
+ bool isWildCard = DoesNameContainWildCard(name);
+ bool recursed = false;
+
+ switch (type)
+ {
+ case NRecursedType::kWildCardOnlyRecursed:
+ recursed = isWildCard;
+ break;
+ case NRecursedType::kRecursed:
+ recursed = true;
+ break;
+ case NRecursedType::kNonRecursed:
+ recursed = false;
+ break;
+ }
+ wildcardCensor.AddItem(include, name, recursed);
+ return true;
+}
+
+void AddCommandLineWildCardToCensor(NWildcard::CCensor &wildcardCensor,
+ const UString &name, bool include, NRecursedType::EEnum type)
+{
+ if (!AddNameToCensor(wildcardCensor, name, include, type))
+ ShowMessageAndThrowException(kIncorrectWildCardInCommandLine, NExitCode::kUserError);
+}
+
+void AddToCensorFromNonSwitchesStrings(NWildcard::CCensor &wildcardCensor,
+ const UStringVector & /* nonSwitchStrings */, NRecursedType::EEnum type,
+ bool /* thereAreSwitchIncludeWildCards */)
+{
+ AddCommandLineWildCardToCensor(wildcardCensor, kUniversalWildcard, true, type);
+}
+
+
+#ifndef _WIN32
+static void GetArguments(int numArguments, const char *arguments[], UStringVector &parts)
+{
+ parts.Clear();
+ for(int i = 0; i < numArguments; i++)
+ {
+ UString s = MultiByteToUnicodeString(arguments[i]);
+ parts.Add(s);
+ }
+}
+#endif
+
+int Main2(
+ #ifndef _WIN32
+ int numArguments, const char *arguments[]
+ #endif
+)
+{
+ #ifdef _WIN32
+ SetFileApisToOEM();
+ #endif
+
+ UStringVector commandStrings;
+ #ifdef _WIN32
+ NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
+ #else
+ extern void mySplitCommandLine(int numArguments,const char *arguments[],UStringVector &parts);
+ mySplitCommandLine(numArguments,arguments,commandStrings);
+ #endif
+
+ // After mySplitCommandLine
+ g_StdOut << kCopyrightString << " (locale=" << my_getlocale() <<",Utf16=";
+ if (global_use_utf16_conversion) g_StdOut << "on";
+ else g_StdOut << "off";
+ g_StdOut << ",HugeFiles=";
+ if (sizeof(off_t) >= 8) g_StdOut << "on,";
+ else g_StdOut << "off,";
+ int nbcpu = NWindows::NSystem::GetNumberOfProcessors();
+ if (nbcpu > 1) g_StdOut << nbcpu << " CPUs)\n";
+ else g_StdOut << nbcpu << " CPU)\n";
+
+ UString arcPath = commandStrings.Front();
+
+ commandStrings.Delete(0);
+
+ NCommandLineParser::CParser parser(kNumSwitches);
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
+ }
+ catch(...)
+ {
+ PrintHelpAndExit();
+ }
+
+ if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
+ {
+ PrintHelp();
+ return 0;
+ }
+ const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
+
+ int numNonSwitchStrings = nonSwitchStrings.Size();
+
+ CArchiveCommand command;
+ if (numNonSwitchStrings == 0)
+ command.CommandType = NCommandType::kFullExtract;
+ else
+ {
+ if (numNonSwitchStrings > 1)
+ PrintHelpAndExit();
+ if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], command))
+ PrintHelpAndExit();
+ }
+
+
+ NRecursedType::EEnum recursedType;
+ recursedType = command.DefaultRecursedType();
+
+ NWildcard::CCensor wildcardCensor;
+
+ bool thereAreSwitchIncludeWildCards;
+ thereAreSwitchIncludeWildCards = false;
+ AddToCensorFromNonSwitchesStrings(wildcardCensor, nonSwitchStrings, recursedType,
+ thereAreSwitchIncludeWildCards);
+
+ bool yesToAll = parser[NKey::kYes].ThereIs;
+
+ // NExtractMode::EEnum extractMode;
+ // bool isExtractGroupCommand = command.IsFromExtractGroup(extractMode);
+
+ bool passwordEnabled = parser[NKey::kPassword].ThereIs;
+
+ UString password;
+ if(passwordEnabled)
+ password = parser[NKey::kPassword].PostStrings[0];
+
+ if (!NFind::DoesFileExist(arcPath))
+ throw kCantFindSFX;
+
+ UString outputDir;
+ if (parser[NKey::kOutputDir].ThereIs)
+ {
+ outputDir = parser[NKey::kOutputDir].PostStrings[0];
+ NName::NormalizeDirPathPrefix(outputDir);
+ }
+
+ {
+ UStringVector v1, v2;
+ v1.Add(arcPath);
+ v2.Add(arcPath);
+ const NWildcard::CCensorNode &wildcardCensorHead =
+ wildcardCensor.Pairs.Front().Head;
+
+ CCodecs *codecs = new CCodecs;
+ CMyComPtr<
+ #ifdef EXTERNAL_CODECS
+ ICompressCodecsInfo
+ #else
+ IUnknown
+ #endif
+ > compressCodecsInfo = codecs;
+ HRESULT result = codecs->Load();
+ if (result != S_OK)
+ throw CSystemException(result);
+
+ if(command.CommandType != NCommandType::kList)
+ {
+ CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
+ CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
+ ecs->OutStream = g_StdStream;
+
+ #ifndef _NO_CRYPTO
+ ecs->PasswordIsDefined = passwordEnabled;
+ ecs->Password = password;
+ #endif
+
+ ecs->Init();
+
+ COpenCallbackConsole openCallback;
+ openCallback.OutStream = g_StdStream;
+
+ #ifndef _NO_CRYPTO
+ openCallback.PasswordIsDefined = passwordEnabled;
+ openCallback.Password = password;
+ #endif
+
+ CExtractOptions eo;
+ eo.StdOutMode = false;
+ eo.PathMode = NExtract::NPathMode::kFullPathnames;
+ eo.TestMode = command.CommandType == NCommandType::kTest;
+ eo.OverwriteMode = yesToAll ?
+ NExtract::NOverwriteMode::kWithoutPrompt :
+ NExtract::NOverwriteMode::kAskBefore;
+ eo.OutputDir = outputDir;
+ eo.YesToAll = yesToAll;
+
+ UString errorMessage;
+ CDecompressStat stat;
+ HRESULT result = DecompressArchives(
+ codecs, CIntVector(),
+ v1, v2,
+ wildcardCensorHead,
+ eo, &openCallback, ecs, errorMessage, stat);
+ if (!errorMessage.IsEmpty())
+ {
+ (*g_StdStream) << endl << "Error: " << errorMessage;;
+ if (result == S_OK)
+ result = E_FAIL;
+ }
+
+ if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
+ {
+ if (ecs->NumArchiveErrors != 0)
+ (*g_StdStream) << endl << "Archive Errors: " << ecs->NumArchiveErrors << endl;
+ if (ecs->NumFileErrors != 0)
+ (*g_StdStream) << endl << "Sub items Errors: " << ecs->NumFileErrors << endl;
+ return NExitCode::kFatalError;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ }
+ else
+ {
+ UInt64 numErrors = 0;
+ HRESULT result = ListArchives(
+ codecs, CIntVector(),
+ false,
+ v1, v2,
+ wildcardCensorHead,
+ true, false,
+ #ifndef _NO_CRYPTO
+ passwordEnabled, password,
+ #endif
+ numErrors);
+ if (numErrors > 0)
+ {
+ g_StdOut << endl << "Errors: " << numErrors;
+ return NExitCode::kFatalError;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ }
+ }
+ return 0;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/CMAKE/CMakeLists_Alone.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/CMAKE/CMakeLists_Alone.txt
new file mode 100644
index 000000000..a9e0438cd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/CMAKE/CMakeLists_Alone.txt
@@ -0,0 +1,251 @@
+cmake_minimum_required(VERSION 2.6)
+
+project(p7zip)
+
+IF(HAVE_WCHAR_H)
+ OPTION(HAVE_UNICODE_WCHAR "Enable Unicode Support" YES)
+ MARK_AS_ADVANCED(HAVE_UNICODE_WCHAR)
+ELSE(HAVE_WCHAR_H)
+ SET(HAVE_UNICODE_WCHAR 0)
+ENDIF(HAVE_WCHAR_H)
+
+SET(HAVE_PTHREADS 0)
+FIND_PACKAGE(Threads)
+IF(WIN32 OR CMAKE_USE_PTHREADS_INIT)
+ SET(HAVE_PTHREADS 1)
+ENDIF(WIN32 OR CMAKE_USE_PTHREADS_INIT)
+
+include_directories(
+ ../../../myWindows
+ ../../../
+ ../../../include_windows
+)
+
+add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DNDEBUG -D_REENTRANT -DENV_UNIX -DCOMPRESS_MT -DCOMPRESS_BZIP2_MT -DCOMPRESS_MF_MT -DBREAK_HANDLER -DBENCH_MT)
+
+add_executable(7za
+
+ ../../../myWindows/myGetTickCount.cpp
+ ../../../myWindows/wine_date_and_time.cpp
+ ../../../myWindows/myAddExeFlag.cpp
+ ../../../myWindows/mySplitCommandLine.cpp
+
+ ../../UI/Console/ConsoleClose.cpp
+ ../../UI/Console/ExtractCallbackConsole.cpp
+ ../../UI/Console/List.cpp
+ ../../UI/Console/Main.cpp
+ ../../UI/Console/MainAr.cpp
+ ../../UI/Console/OpenCallbackConsole.cpp
+ ../../UI/Console/PercentPrinter.cpp
+ ../../UI/Console/UpdateCallbackConsole.cpp
+ ../../UI/Console/UserInputUtils.cpp
+
+ ../../../Common/CommandLineParser.cpp
+ ../../../Common/CRC.cpp
+ ../../../Common/IntToString.cpp
+ ../../../Common/ListFileUtils.cpp
+ ../../../Common/StdInStream.cpp
+ ../../../Common/StdOutStream.cpp
+ ../../../Common/MyString.cpp
+ ../../../Common/MyWindows.cpp
+ ../../../Common/StringConvert.cpp
+ ../../../Common/StringToInt.cpp
+ ../../../Common/UTFConvert.cpp
+ ../../../Common/MyVector.cpp
+ ../../../Common/Wildcard.cpp
+
+ ../../../Windows/Error.cpp
+ ../../../Windows/FileDir.cpp
+ ../../../Windows/FileFind.cpp
+ ../../../Windows/FileIO.cpp
+ ../../../Windows/FileName.cpp
+ ../../../Windows/PropVariant.cpp
+ ../../../Windows/PropVariantConversions.cpp
+ ../../../Windows/Synchronization.cpp
+ ../../../Windows/System.cpp
+ ../../../Windows/Time.cpp
+
+ ../../Common/CreateCoder.cpp
+ ../../Common/CWrappers.cpp
+ ../../Common/FilePathAutoRename.cpp
+ ../../Common/FileStreams.cpp
+ ../../Common/FilterCoder.cpp
+ ../../Common/InBuffer.cpp
+ ../../Common/InOutTempBuffer.cpp
+ ../../Common/LimitedStreams.cpp
+ ../../Common/LockedStream.cpp
+ ../../Common/MemBlocks.cpp
+ ../../Common/MethodId.cpp
+ ../../Common/MethodProps.cpp
+ ../../Common/OffsetStream.cpp
+ ../../Common/OutBuffer.cpp
+ ../../Common/OutMemStream.cpp
+ ../../Common/ProgressMt.cpp
+ ../../Common/ProgressUtils.cpp
+ ../../Common/StreamBinder.cpp
+ ../../Common/StreamObjects.cpp
+ ../../Common/StreamUtils.cpp
+ ../../Common/VirtThread.cpp
+
+ ../../UI/Common/ArchiveCommandLine.cpp
+ ../../UI/Common/ArchiveExtractCallback.cpp
+ ../../UI/Common/ArchiveOpenCallback.cpp
+ ../../UI/Common/DefaultName.cpp
+ ../../UI/Common/EnumDirItems.cpp
+ ../../UI/Common/Extract.cpp
+ ../../UI/Common/ExtractingFilePath.cpp
+ ../../UI/Common/LoadCodecs.cpp
+ ../../UI/Common/OpenArchive.cpp
+ ../../UI/Common/PropIDUtils.cpp
+ ../../UI/Common/SetProperties.cpp
+ ../../UI/Common/SortUtils.cpp
+ ../../UI/Common/TempFiles.cpp
+ ../../UI/Common/Update.cpp
+ ../../UI/Common/UpdateAction.cpp
+ ../../UI/Common/UpdateCallback.cpp
+ ../../UI/Common/UpdatePair.cpp
+ ../../UI/Common/UpdateProduce.cpp
+
+ ../../Archive/Bz2Handler.cpp
+ ../../Archive/GzHandler.cpp
+ ../../Archive/LzmaHandler.cpp
+ ../../Archive/SplitHandler.cpp
+ ../../Archive/XzHandler.cpp
+ ../../Archive/ZHandler.cpp
+
+ ../../Archive/Common/CoderMixer2.cpp
+ ../../Archive/Common/CoderMixer2MT.cpp
+ ../../Archive/Common/CrossThreadProgress.cpp
+ ../../Archive/Common/DummyOutStream.cpp
+ ../../Archive/Common/FindSignature.cpp
+ ../../Archive/Common/HandlerOut.cpp
+ ../../Archive/Common/InStreamWithCRC.cpp
+ ../../Archive/Common/ItemNameUtils.cpp
+ ../../Archive/Common/MultiStream.cpp
+ ../../Archive/Common/OutStreamWithCRC.cpp
+ ../../Archive/Common/ParseProperties.cpp
+
+ ../../Archive/7z/7zCompressionMode.cpp
+ ../../Archive/7z/7zDecode.cpp
+ ../../Archive/7z/7zEncode.cpp
+ ../../Archive/7z/7zExtract.cpp
+ ../../Archive/7z/7zFolderInStream.cpp
+ ../../Archive/7z/7zFolderOutStream.cpp
+ ../../Archive/7z/7zHandler.cpp
+ ../../Archive/7z/7zHandlerOut.cpp
+ ../../Archive/7z/7zHeader.cpp
+ ../../Archive/7z/7zIn.cpp
+ ../../Archive/7z/7zOut.cpp
+ ../../Archive/7z/7zProperties.cpp
+ ../../Archive/7z/7zSpecStream.cpp
+ ../../Archive/7z/7zUpdate.cpp
+ ../../Archive/7z/7zRegister.cpp
+
+ ../../Archive/Cab/CabBlockInStream.cpp
+ ../../Archive/Cab/CabHandler.cpp
+ ../../Archive/Cab/CabHeader.cpp
+ ../../Archive/Cab/CabIn.cpp
+ ../../Archive/Cab/CabRegister.cpp
+
+ ../../Archive/Tar/TarHandler.cpp
+ ../../Archive/Tar/TarHandlerOut.cpp
+ ../../Archive/Tar/TarHeader.cpp
+ ../../Archive/Tar/TarIn.cpp
+ ../../Archive/Tar/TarOut.cpp
+ ../../Archive/Tar/TarRegister.cpp
+ ../../Archive/Tar/TarUpdate.cpp
+
+ ../../Archive/Zip/ZipAddCommon.cpp
+ ../../Archive/Zip/ZipHandler.cpp
+ ../../Archive/Zip/ZipHandlerOut.cpp
+ ../../Archive/Zip/ZipHeader.cpp
+ ../../Archive/Zip/ZipIn.cpp
+ ../../Archive/Zip/ZipItem.cpp
+ ../../Archive/Zip/ZipOut.cpp
+ ../../Archive/Zip/ZipUpdate.cpp
+ ../../Archive/Zip/ZipRegister.cpp
+
+ ../../Compress/Bcj2Coder.cpp
+ ../../Compress/Bcj2Register.cpp
+ ../../Compress/BcjCoder.cpp
+ ../../Compress/BcjRegister.cpp
+ ../../Compress/BitlDecoder.cpp
+ ../../Compress/BranchCoder.cpp
+ ../../Compress/BranchMisc.cpp
+ ../../Compress/BranchRegister.cpp
+ ../../Compress/ByteSwap.cpp
+ ../../Compress/BZip2Crc.cpp
+ ../../Compress/BZip2Decoder.cpp
+ ../../Compress/BZip2Encoder.cpp
+ ../../Compress/BZip2Register.cpp
+ ../../Compress/CopyCoder.cpp
+ ../../Compress/CopyRegister.cpp
+ ../../Compress/Deflate64Register.cpp
+ ../../Compress/DeflateDecoder.cpp
+ ../../Compress/DeflateEncoder.cpp
+ ../../Compress/DeflateRegister.cpp
+ ../../Compress/DeltaFilter.cpp
+ ../../Compress/ImplodeDecoder.cpp
+ ../../Compress/ImplodeHuffmanDecoder.cpp
+ ../../Compress/Lzma2Decoder.cpp
+ ../../Compress/Lzma2Encoder.cpp
+ ../../Compress/Lzma2Register.cpp
+ ../../Compress/LzmaDecoder.cpp
+ ../../Compress/LzmaEncoder.cpp
+ ../../Compress/LzmaRegister.cpp
+ ../../Compress/LzOutWindow.cpp
+ ../../Compress/Lzx86Converter.cpp
+ ../../Compress/LzxDecoder.cpp
+ ../../Compress/PpmdDecoder.cpp
+ ../../Compress/PpmdEncoder.cpp
+ ../../Compress/PpmdRegister.cpp
+ ../../Compress/QuantumDecoder.cpp
+ ../../Compress/ShrinkDecoder.cpp
+ ../../Compress/ZDecoder.cpp
+
+ ../../Compress/LZMA_Alone/LzmaBench.cpp
+ ../../Compress/LZMA_Alone/LzmaBenchCon.cpp
+
+ ../../Crypto/7zAes.cpp
+ ../../Crypto/7zAesRegister.cpp
+ ../../Crypto/HmacSha1.cpp
+ ../../Crypto/MyAes.cpp
+ ../../Crypto/Pbkdf2HmacSha1.cpp
+ ../../Crypto/RandGen.cpp
+ ../../Crypto/Sha1.cpp
+ ../../Crypto/WzAes.cpp
+ ../../Crypto/ZipCrypto.cpp
+ ../../Crypto/ZipStrong.cpp
+
+ ../../../../C/Aes.c
+ ../../../../C/7zStream.c
+ ../../../../C/Bra.c
+ ../../../../C/Bra86.c
+ ../../../../C/BraIA64.c
+ ../../../../C/BwtSort.c
+ ../../../../C/Delta.c
+ ../../../../C/HuffEnc.c
+ ../../../../C/LzFind.c
+ ../../../../C/LzFindMt.c
+ ../../../../C/Lzma2Dec.c
+ ../../../../C/Lzma2Enc.c
+ ../../../../C/LzmaDec.c
+ ../../../../C/LzmaEnc.c
+ ../../../../C/MtCoder.c
+ ../../../../C/Sha256.c
+ ../../../../C/Sort.c
+ ../../../../C/Threads.c
+ ../../../../C/Xz.c
+ ../../../../C/XzCrc64.c
+ ../../../../C/XzDec.c
+ ../../../../C/XzEnc.c
+ ../../../../C/XzIn.c
+
+ ../../../../C/7zCrc.c
+
+ )
+
+IF(HAVE_PTHREADS)
+ TARGET_LINK_LIBRARIES(7za ${CMAKE_THREAD_LIBS_INIT})
+ENDIF(HAVE_PTHREADS)
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/CMAKE/generate.sh b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/CMAKE/generate.sh
new file mode 100644
index 000000000..4c39a1c53
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/CMAKE/generate.sh
@@ -0,0 +1,14 @@
+
+#TARGET="Unix Makefiles"
+TARGET="CodeBlocks - Unix Makefiles"
+#TARGET="KDevelop3"
+#TARGET="Eclipse CDT4 - Unix Makefiles"
+
+rm -fr Alone
+mkdir Alone
+cd Alone
+cp ../CMakeLists_Alone.txt CMakeLists.txt
+
+cmake -G "${TARGET}" -DCMAKE_BUILD_TYPE=Debug
+#cmake -G "${TARGET}" -DCMAKE_BUILD_TYPE=Release
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CWrappers.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CWrappers.cpp
new file mode 100644
index 000000000..d440027d9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CWrappers.cpp
@@ -0,0 +1,127 @@
+// CWrappers.h
+
+#include "StdAfx.h"
+
+#include "CWrappers.h"
+
+#include "StreamUtils.h"
+
+#define PROGRESS_UNKNOWN_VALUE ((UInt64)(Int64)-1)
+
+#define CONVERT_PR_VAL(x) (x == PROGRESS_UNKNOWN_VALUE ? NULL : &x)
+
+static SRes CompressProgress(void *pp, UInt64 inSize, UInt64 outSize)
+{
+ CCompressProgressWrap *p = (CCompressProgressWrap *)pp;
+ p->Res = p->Progress->SetRatioInfo(CONVERT_PR_VAL(inSize), CONVERT_PR_VAL(outSize));
+ return (SRes)p->Res;
+}
+
+CCompressProgressWrap::CCompressProgressWrap(ICompressProgressInfo *progress)
+{
+ p.Progress = CompressProgress;
+ Progress = progress;
+ Res = SZ_OK;
+}
+
+static const UInt32 kStreamStepSize = (UInt32)1 << 31;
+
+SRes HRESULT_To_SRes(HRESULT res, SRes defaultRes)
+{
+ switch(res)
+ {
+ case S_OK: return SZ_OK;
+ case E_OUTOFMEMORY: return SZ_ERROR_MEM;
+ case E_INVALIDARG: return SZ_ERROR_PARAM;
+ case E_ABORT: return SZ_ERROR_PROGRESS;
+ case S_FALSE: return SZ_ERROR_DATA;
+ }
+ return defaultRes;
+}
+
+static SRes MyRead(void *object, void *data, size_t *size)
+{
+ CSeqInStreamWrap *p = (CSeqInStreamWrap *)object;
+ UInt32 curSize = ((*size < kStreamStepSize) ? (UInt32)*size : kStreamStepSize);
+ p->Res = (p->Stream->Read(data, curSize, &curSize));
+ *size = curSize;
+ if (p->Res == S_OK)
+ return SZ_OK;
+ return HRESULT_To_SRes(p->Res, SZ_ERROR_READ);
+}
+
+static size_t MyWrite(void *object, const void *data, size_t size)
+{
+ CSeqOutStreamWrap *p = (CSeqOutStreamWrap *)object;
+ if (p->Stream)
+ {
+ p->Res = WriteStream(p->Stream, data, size);
+ if (p->Res != 0)
+ return 0;
+ }
+ else
+ p->Res = S_OK;
+ p->Processed += size;
+ return size;
+}
+
+CSeqInStreamWrap::CSeqInStreamWrap(ISequentialInStream *stream)
+{
+ p.Read = MyRead;
+ Stream = stream;
+}
+
+CSeqOutStreamWrap::CSeqOutStreamWrap(ISequentialOutStream *stream)
+{
+ p.Write = MyWrite;
+ Stream = stream;
+ Res = SZ_OK;
+ Processed = 0;
+}
+
+HRESULT SResToHRESULT(SRes res)
+{
+ switch(res)
+ {
+ case SZ_OK: return S_OK;
+ case SZ_ERROR_MEM: return E_OUTOFMEMORY;
+ case SZ_ERROR_PARAM: return E_INVALIDARG;
+ case SZ_ERROR_PROGRESS: return E_ABORT;
+ case SZ_ERROR_DATA: return S_FALSE;
+ }
+ return E_FAIL;
+}
+
+static SRes InStreamWrap_Read(void *pp, void *data, size_t *size)
+{
+ CSeekInStreamWrap *p = (CSeekInStreamWrap *)pp;
+ UInt32 curSize = ((*size < kStreamStepSize) ? (UInt32)*size : kStreamStepSize);
+ p->Res = p->Stream->Read(data, curSize, &curSize);
+ *size = curSize;
+ return (p->Res == S_OK) ? SZ_OK : SZ_ERROR_READ;
+}
+
+static SRes InStreamWrap_Seek(void *pp, Int64 *offset, ESzSeek origin)
+{
+ CSeekInStreamWrap *p = (CSeekInStreamWrap *)pp;
+ UInt32 moveMethod;
+ switch(origin)
+ {
+ case SZ_SEEK_SET: moveMethod = STREAM_SEEK_SET; break;
+ case SZ_SEEK_CUR: moveMethod = STREAM_SEEK_CUR; break;
+ case SZ_SEEK_END: moveMethod = STREAM_SEEK_END; break;
+ default: return SZ_ERROR_PARAM;
+ }
+ UInt64 newPosition;
+ p->Res = p->Stream->Seek(*offset, moveMethod, &newPosition);
+ *offset = (Int64)newPosition;
+ return (p->Res == S_OK) ? SZ_OK : SZ_ERROR_READ;
+}
+
+CSeekInStreamWrap::CSeekInStreamWrap(IInStream *stream)
+{
+ Stream = stream;
+ p.Read = InStreamWrap_Read;
+ p.Seek = InStreamWrap_Seek;
+ Res = S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CWrappers.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CWrappers.h
new file mode 100644
index 000000000..f7ac96cb9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CWrappers.h
@@ -0,0 +1,46 @@
+// CWrappers.h
+
+#ifndef __C_WRAPPERS_H
+#define __C_WRAPPERS_H
+
+#include "../../../C/Types.h"
+
+#include "../ICoder.h"
+#include "../../Common/MyCom.h"
+
+struct CCompressProgressWrap
+{
+ ICompressProgress p;
+ ICompressProgressInfo *Progress;
+ HRESULT Res;
+ CCompressProgressWrap(ICompressProgressInfo *progress);
+};
+
+struct CSeqInStreamWrap
+{
+ ISeqInStream p;
+ ISequentialInStream *Stream;
+ HRESULT Res;
+ CSeqInStreamWrap(ISequentialInStream *stream);
+};
+
+struct CSeekInStreamWrap
+{
+ ISeekInStream p;
+ IInStream *Stream;
+ HRESULT Res;
+ CSeekInStreamWrap(IInStream *stream);
+};
+
+struct CSeqOutStreamWrap
+{
+ ISeqOutStream p;
+ ISequentialOutStream *Stream;
+ HRESULT Res;
+ UInt64 Processed;
+ CSeqOutStreamWrap(ISequentialOutStream *stream);
+};
+
+HRESULT SResToHRESULT(SRes res);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CreateCoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CreateCoder.cpp
new file mode 100644
index 000000000..2742495da
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CreateCoder.cpp
@@ -0,0 +1,292 @@
+// CreateCoder.cpp
+
+#include "StdAfx.h"
+
+#include "CreateCoder.h"
+
+#include "../../Windows/PropVariant.h"
+#include "../../Windows/Defs.h"
+#include "FilterCoder.h"
+#include "RegisterCodec.h"
+
+static const unsigned int kNumCodecsMax = 64;
+unsigned int g_NumCodecs = 0;
+const CCodecInfo *g_Codecs[kNumCodecsMax];
+void RegisterCodec(const CCodecInfo *codecInfo)
+{
+ if (g_NumCodecs < kNumCodecsMax)
+ g_Codecs[g_NumCodecs++] = codecInfo;
+}
+
+#ifdef EXTERNAL_CODECS
+static HRESULT ReadNumberOfStreams(ICompressCodecsInfo *codecsInfo, UInt32 index, PROPID propID, UInt32 &res)
+{
+ NWindows::NCOM::CPropVariant prop;
+ RINOK(codecsInfo->GetProperty(index, propID, &prop));
+ if (prop.vt == VT_EMPTY)
+ res = 1;
+ else if (prop.vt == VT_UI4)
+ res = prop.ulVal;
+ else
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+static HRESULT ReadIsAssignedProp(ICompressCodecsInfo *codecsInfo, UInt32 index, PROPID propID, bool &res)
+{
+ NWindows::NCOM::CPropVariant prop;
+ RINOK(codecsInfo->GetProperty(index, propID, &prop));
+ if (prop.vt == VT_EMPTY)
+ res = true;
+ else if (prop.vt == VT_BOOL)
+ res = VARIANT_BOOLToBool(prop.boolVal);
+ else
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+HRESULT LoadExternalCodecs(ICompressCodecsInfo *codecsInfo, CObjectVector<CCodecInfoEx> &externalCodecs)
+{
+ UInt32 num;
+ RINOK(codecsInfo->GetNumberOfMethods(&num));
+ for (UInt32 i = 0; i < num; i++)
+ {
+ CCodecInfoEx info;
+ NWindows::NCOM::CPropVariant prop;
+ RINOK(codecsInfo->GetProperty(i, NMethodPropID::kID, &prop));
+ // if (prop.vt != VT_BSTR)
+ // info.Id.IDSize = (Byte)SysStringByteLen(prop.bstrVal);
+ // memmove(info.Id.ID, prop.bstrVal, info.Id.IDSize);
+ if (prop.vt != VT_UI8)
+ {
+ continue; // old Interface
+ // return E_INVALIDARG;
+ }
+ info.Id = prop.uhVal.QuadPart;
+ prop.Clear();
+
+ RINOK(codecsInfo->GetProperty(i, NMethodPropID::kName, &prop));
+ if (prop.vt == VT_BSTR)
+ info.Name = prop.bstrVal;
+ else if (prop.vt != VT_EMPTY)
+ return E_INVALIDARG;;
+
+ RINOK(ReadNumberOfStreams(codecsInfo, i, NMethodPropID::kInStreams, info.NumInStreams));
+ RINOK(ReadNumberOfStreams(codecsInfo, i, NMethodPropID::kOutStreams, info.NumOutStreams));
+ RINOK(ReadIsAssignedProp(codecsInfo, i, NMethodPropID::kEncoderIsAssigned, info.EncoderIsAssigned));
+ RINOK(ReadIsAssignedProp(codecsInfo, i, NMethodPropID::kDecoderIsAssigned, info.DecoderIsAssigned));
+
+ externalCodecs.Add(info);
+ }
+ return S_OK;
+}
+
+#endif
+
+bool FindMethod(
+ #ifdef EXTERNAL_CODECS
+ ICompressCodecsInfo * /* codecsInfo */, const CObjectVector<CCodecInfoEx> *externalCodecs,
+ #endif
+ const UString &name,
+ CMethodId &methodId, UInt32 &numInStreams, UInt32 &numOutStreams)
+{
+ UInt32 i;
+ for (i = 0; i < g_NumCodecs; i++)
+ {
+ const CCodecInfo &codec = *g_Codecs[i];
+ if (name.CompareNoCase(codec.Name) == 0)
+ {
+ methodId = codec.Id;
+ numInStreams = codec.NumInStreams;
+ numOutStreams = 1;
+ return true;
+ }
+ }
+ #ifdef EXTERNAL_CODECS
+ if (externalCodecs)
+ for (i = 0; i < (UInt32)externalCodecs->Size(); i++)
+ {
+ const CCodecInfoEx &codec = (*externalCodecs)[i];
+ if (codec.Name.CompareNoCase(name) == 0)
+ {
+ methodId = codec.Id;
+ numInStreams = codec.NumInStreams;
+ numOutStreams = codec.NumOutStreams;
+ return true;
+ }
+ }
+ #endif
+ return false;
+}
+
+bool FindMethod(
+ #ifdef EXTERNAL_CODECS
+ ICompressCodecsInfo * /* codecsInfo */, const CObjectVector<CCodecInfoEx> *externalCodecs,
+ #endif
+ CMethodId methodId, UString &name)
+{
+ UInt32 i;
+ for (i = 0; i < g_NumCodecs; i++)
+ {
+ const CCodecInfo &codec = *g_Codecs[i];
+ if (methodId == codec.Id)
+ {
+ name = codec.Name;
+ return true;
+ }
+ }
+ #ifdef EXTERNAL_CODECS
+ if (externalCodecs)
+ for (i = 0; i < (UInt32)externalCodecs->Size(); i++)
+ {
+ const CCodecInfoEx &codec = (*externalCodecs)[i];
+ if (methodId == codec.Id)
+ {
+ name = codec.Name;
+ return true;
+ }
+ }
+ #endif
+ return false;
+}
+
+HRESULT CreateCoder(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CMethodId methodId,
+ CMyComPtr<ICompressFilter> &filter,
+ CMyComPtr<ICompressCoder> &coder,
+ CMyComPtr<ICompressCoder2> &coder2,
+ bool encode, bool onlyCoder)
+{
+ bool created = false;
+ UInt32 i;
+ for (i = 0; i < g_NumCodecs; i++)
+ {
+ const CCodecInfo &codec = *g_Codecs[i];
+ if (codec.Id == methodId)
+ {
+ if (encode)
+ {
+ if (codec.CreateEncoder)
+ {
+ void *p = codec.CreateEncoder();
+ if (codec.IsFilter) filter = (ICompressFilter *)p;
+ else if (codec.NumInStreams == 1) coder = (ICompressCoder *)p;
+ else coder2 = (ICompressCoder2 *)p;
+ created = (p != 0);
+ break;
+ }
+ }
+ else
+ if (codec.CreateDecoder)
+ {
+ void *p = codec.CreateDecoder();
+ if (codec.IsFilter) filter = (ICompressFilter *)p;
+ else if (codec.NumInStreams == 1) coder = (ICompressCoder *)p;
+ else coder2 = (ICompressCoder2 *)p;
+ created = (p != 0);
+ break;
+ }
+ }
+ }
+
+ #ifdef EXTERNAL_CODECS
+ if (!created && externalCodecs)
+ for (i = 0; i < (UInt32)externalCodecs->Size(); i++)
+ {
+ const CCodecInfoEx &codec = (*externalCodecs)[i];
+ if (codec.Id == methodId)
+ {
+ if (encode)
+ {
+ if (codec.EncoderIsAssigned)
+ {
+ if (codec.IsSimpleCodec())
+ {
+ HRESULT result = codecsInfo->CreateEncoder(i, &IID_ICompressCoder, (void **)&coder);
+ if (result != S_OK && result != E_NOINTERFACE && result != CLASS_E_CLASSNOTAVAILABLE)
+ return result;
+ if (!coder)
+ {
+ RINOK(codecsInfo->CreateEncoder(i, &IID_ICompressFilter, (void **)&filter));
+ }
+ }
+ else
+ {
+ RINOK(codecsInfo->CreateEncoder(i, &IID_ICompressCoder2, (void **)&coder2));
+ }
+ break;
+ }
+ }
+ else
+ if (codec.DecoderIsAssigned)
+ {
+ if (codec.IsSimpleCodec())
+ {
+ HRESULT result = codecsInfo->CreateDecoder(i, &IID_ICompressCoder, (void **)&coder);
+ if (result != S_OK && result != E_NOINTERFACE && result != CLASS_E_CLASSNOTAVAILABLE)
+ return result;
+ if (!coder)
+ {
+ RINOK(codecsInfo->CreateDecoder(i, &IID_ICompressFilter, (void **)&filter));
+ }
+ }
+ else
+ {
+ RINOK(codecsInfo->CreateDecoder(i, &IID_ICompressCoder2, (void **)&coder2));
+ }
+ break;
+ }
+ }
+ }
+ #endif
+
+ if (onlyCoder && filter)
+ {
+ CFilterCoder *coderSpec = new CFilterCoder;
+ coder = coderSpec;
+ coderSpec->Filter = filter;
+ }
+ return S_OK;
+}
+
+HRESULT CreateCoder(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CMethodId methodId,
+ CMyComPtr<ICompressCoder> &coder,
+ CMyComPtr<ICompressCoder2> &coder2,
+ bool encode)
+{
+ CMyComPtr<ICompressFilter> filter;
+ return CreateCoder(
+ EXTERNAL_CODECS_LOC_VARS
+ methodId,
+ filter, coder, coder2, encode, true);
+}
+
+HRESULT CreateCoder(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CMethodId methodId,
+ CMyComPtr<ICompressCoder> &coder, bool encode)
+{
+ CMyComPtr<ICompressFilter> filter;
+ CMyComPtr<ICompressCoder2> coder2;
+ return CreateCoder(
+ EXTERNAL_CODECS_LOC_VARS
+ methodId,
+ coder, coder2, encode);
+}
+
+HRESULT CreateFilter(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CMethodId methodId,
+ CMyComPtr<ICompressFilter> &filter,
+ bool encode)
+{
+ CMyComPtr<ICompressCoder> coder;
+ CMyComPtr<ICompressCoder2> coder2;
+ return CreateCoder(
+ EXTERNAL_CODECS_LOC_VARS
+ methodId,
+ filter, coder, coder2, encode, false);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CreateCoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CreateCoder.h
new file mode 100644
index 000000000..1fcc13431
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/CreateCoder.h
@@ -0,0 +1,98 @@
+// CreateCoder.h
+
+#ifndef __CREATECODER_H
+#define __CREATECODER_H
+
+#include "Common/MyCom.h"
+#include "Common/MyString.h"
+#include "../ICoder.h"
+
+#include "MethodId.h"
+
+#ifdef EXTERNAL_CODECS
+
+struct CCodecInfoEx
+{
+ UString Name;
+ CMethodId Id;
+ UInt32 NumInStreams;
+ UInt32 NumOutStreams;
+ bool EncoderIsAssigned;
+ bool DecoderIsAssigned;
+ bool IsSimpleCodec() const { return NumOutStreams == 1 && NumInStreams == 1; }
+ CCodecInfoEx(): EncoderIsAssigned(false), DecoderIsAssigned(false) {}
+};
+
+HRESULT LoadExternalCodecs(ICompressCodecsInfo *codecsInfo, CObjectVector<CCodecInfoEx> &externalCodecs);
+
+#define PUBLIC_ISetCompressCodecsInfo public ISetCompressCodecsInfo,
+#define QUERY_ENTRY_ISetCompressCodecsInfo MY_QUERYINTERFACE_ENTRY(ISetCompressCodecsInfo)
+#define DECL_ISetCompressCodecsInfo STDMETHOD(SetCompressCodecsInfo)(ICompressCodecsInfo *compressCodecsInfo);
+#define IMPL_ISetCompressCodecsInfo2(x) \
+STDMETHODIMP x::SetCompressCodecsInfo(ICompressCodecsInfo *compressCodecsInfo) { \
+ COM_TRY_BEGIN _codecsInfo = compressCodecsInfo; return LoadExternalCodecs(_codecsInfo, _externalCodecs); COM_TRY_END }
+#define IMPL_ISetCompressCodecsInfo IMPL_ISetCompressCodecsInfo2(CHandler)
+
+#define EXTERNAL_CODECS_VARS2 _codecsInfo, &_externalCodecs
+
+#define DECL_EXTERNAL_CODECS_VARS CMyComPtr<ICompressCodecsInfo> _codecsInfo; CObjectVector<CCodecInfoEx> _externalCodecs;
+#define EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS2,
+
+#define DECL_EXTERNAL_CODECS_LOC_VARS2 ICompressCodecsInfo *codecsInfo, const CObjectVector<CCodecInfoEx> *externalCodecs
+#define EXTERNAL_CODECS_LOC_VARS2 codecsInfo, externalCodecs
+
+#define DECL_EXTERNAL_CODECS_LOC_VARS DECL_EXTERNAL_CODECS_LOC_VARS2,
+#define EXTERNAL_CODECS_LOC_VARS EXTERNAL_CODECS_LOC_VARS2,
+
+#else
+
+#define PUBLIC_ISetCompressCodecsInfo
+#define QUERY_ENTRY_ISetCompressCodecsInfo
+#define DECL_ISetCompressCodecsInfo
+#define IMPL_ISetCompressCodecsInfo
+#define EXTERNAL_CODECS_VARS2
+#define DECL_EXTERNAL_CODECS_VARS
+#define EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS2
+#define DECL_EXTERNAL_CODECS_LOC_VARS2
+#define EXTERNAL_CODECS_LOC_VARS2
+#define DECL_EXTERNAL_CODECS_LOC_VARS
+#define EXTERNAL_CODECS_LOC_VARS
+
+#endif
+
+bool FindMethod(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ const UString &name, CMethodId &methodId, UInt32 &numInStreams, UInt32 &numOutStreams);
+
+bool FindMethod(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CMethodId methodId, UString &name);
+
+
+HRESULT CreateCoder(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CMethodId methodId,
+ CMyComPtr<ICompressFilter> &filter,
+ CMyComPtr<ICompressCoder> &coder,
+ CMyComPtr<ICompressCoder2> &coder2,
+ bool encode, bool onlyCoder);
+
+HRESULT CreateCoder(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CMethodId methodId,
+ CMyComPtr<ICompressCoder> &coder,
+ CMyComPtr<ICompressCoder2> &coder2,
+ bool encode);
+
+HRESULT CreateCoder(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CMethodId methodId,
+ CMyComPtr<ICompressCoder> &coder, bool encode);
+
+HRESULT CreateFilter(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ CMethodId methodId,
+ CMyComPtr<ICompressFilter> &filter,
+ bool encode);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilePathAutoRename.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilePathAutoRename.cpp
new file mode 100644
index 000000000..7d6e36f14
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilePathAutoRename.cpp
@@ -0,0 +1,55 @@
+// FilePathAutoRename.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Defs.h"
+#include "Common/IntToString.h"
+
+#include "Windows/FileFind.h"
+
+#include "FilePathAutoRename.h"
+
+using namespace NWindows;
+
+static bool MakeAutoName(const UString &name,
+ const UString &extension, unsigned value, UString &path)
+{
+ wchar_t number[16];
+ ConvertUInt32ToString(value, number);
+ path = name;
+ path += number;
+ path += extension;
+ return NFile::NFind::DoesFileOrDirExist(path);
+}
+
+bool AutoRenamePath(UString &fullProcessedPath)
+{
+ UString path;
+ int dotPos = fullProcessedPath.ReverseFind(L'.');
+
+ int slashPos = fullProcessedPath.ReverseFind(L'/');
+ #ifdef _WIN32
+ int slash1Pos = fullProcessedPath.ReverseFind(L'\\');
+ slashPos = MyMax(slashPos, slash1Pos);
+ #endif
+
+ UString name, extension;
+ if (dotPos > slashPos && dotPos > 0)
+ {
+ name = fullProcessedPath.Left(dotPos);
+ extension = fullProcessedPath.Mid(dotPos);
+ }
+ else
+ name = fullProcessedPath;
+ name += L'_';
+ unsigned left = 1, right = (1 << 30);
+ while (left != right)
+ {
+ unsigned mid = (left + right) / 2;
+ if (MakeAutoName(name, extension, mid, path))
+ left = mid + 1;
+ else
+ right = mid;
+ }
+ return !MakeAutoName(name, extension, right, fullProcessedPath);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilePathAutoRename.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilePathAutoRename.h
new file mode 100644
index 000000000..3ef87f482
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilePathAutoRename.h
@@ -0,0 +1,10 @@
+// Util/FilePathAutoRename.h
+
+#ifndef __FILEPATHAUTORENAME_H
+#define __FILEPATHAUTORENAME_H
+
+#include "Common/MyString.h"
+
+bool AutoRenamePath(UString &fullProcessedPath);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FileStreams.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FileStreams.cpp
new file mode 100644
index 000000000..d913f51f1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FileStreams.cpp
@@ -0,0 +1,274 @@
+// FileStreams.cpp
+
+#include "StdAfx.h"
+
+#ifndef _WIN32
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#endif
+
+#include "FileStreams.h"
+
+static inline HRESULT ConvertBoolToHRESULT(bool result)
+{
+ #ifdef _WIN32
+ if (result)
+ return S_OK;
+ DWORD lastError = ::GetLastError();
+ if (lastError == 0)
+ return E_FAIL;
+ return HRESULT_FROM_WIN32(lastError);
+ #else
+ return result ? S_OK: E_FAIL;
+ #endif
+}
+
+bool CInFileStream::Open(LPCTSTR fileName)
+{
+#ifdef ENV_UNIX
+ return File.Open(fileName,_ignoreSymbolicLink);
+#else
+ return File.Open(fileName);
+#endif
+}
+
+#ifdef USE_WIN_FILE
+#ifndef _UNICODE
+bool CInFileStream::Open(LPCWSTR fileName)
+{
+#ifdef ENV_UNIX
+ return File.Open(fileName,_ignoreSymbolicLink);
+#else
+ return File.Open(fileName);
+#endif
+}
+#endif
+#endif
+
+bool CInFileStream::OpenShared(LPCTSTR fileName, bool shareForWrite)
+{
+#ifdef ENV_UNIX
+ (void)shareForWrite;
+ return File.Open(fileName,_ignoreSymbolicLink);
+#else
+ return File.OpenShared(fileName, shareForWrite);
+#endif
+}
+
+#ifdef USE_WIN_FILE
+#ifndef _UNICODE
+bool CInFileStream::OpenShared(LPCWSTR fileName, bool shareForWrite)
+{
+ return File.OpenShared(fileName, shareForWrite);
+}
+#endif
+#endif
+
+STDMETHODIMP CInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ #ifdef USE_WIN_FILE
+
+ UInt32 realProcessedSize;
+ bool result = File.ReadPart(data, size, realProcessedSize);
+ if(processedSize != NULL)
+ *processedSize = realProcessedSize;
+ return ConvertBoolToHRESULT(result);
+
+ #else
+
+ if(processedSize != NULL)
+ *processedSize = 0;
+ ssize_t res = File.Read(data, (size_t)size);
+ if (res == -1)
+ return E_FAIL;
+ if(processedSize != NULL)
+ *processedSize = (UInt32)res;
+ return S_OK;
+
+ #endif
+}
+
+#ifndef _WIN32_WCE
+STDMETHODIMP CStdInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ #ifdef _WIN32
+ UInt32 realProcessedSize;
+ BOOL res = ::ReadFile(GetStdHandle(STD_INPUT_HANDLE),
+ data, size, (DWORD *)&realProcessedSize, NULL);
+ if(processedSize != NULL)
+ *processedSize = realProcessedSize;
+ if (res == FALSE && GetLastError() == ERROR_BROKEN_PIPE)
+ return S_OK;
+ return ConvertBoolToHRESULT(res != FALSE);
+
+ #else
+
+ if(processedSize != NULL)
+ *processedSize = 0;
+ ssize_t res;
+ do
+ {
+ res = read(0, data, (size_t)size);
+ }
+ while (res < 0 && (errno == EINTR));
+ if (res == -1)
+ return E_FAIL;
+ if(processedSize != NULL)
+ *processedSize = (UInt32)res;
+ return S_OK;
+
+ #endif
+}
+
+#endif
+
+STDMETHODIMP CInFileStream::Seek(Int64 offset, UInt32 seekOrigin,
+ UInt64 *newPosition)
+{
+ if(seekOrigin >= 3)
+ return STG_E_INVALIDFUNCTION;
+
+ #ifdef USE_WIN_FILE
+
+ UInt64 realNewPosition;
+ bool result = File.Seek(offset, seekOrigin, realNewPosition);
+ if(newPosition != NULL)
+ *newPosition = realNewPosition;
+ return ConvertBoolToHRESULT(result);
+
+ #else
+
+ off_t res = File.Seek(offset, seekOrigin);
+ if (res == -1)
+ return E_FAIL;
+ if(newPosition != NULL)
+ *newPosition = (UInt64)res;
+ return S_OK;
+
+ #endif
+}
+
+STDMETHODIMP CInFileStream::GetSize(UInt64 *size)
+{
+ return ConvertBoolToHRESULT(File.GetLength(*size));
+}
+
+
+//////////////////////////
+// COutFileStream
+
+HRESULT COutFileStream::Close()
+{
+ return ConvertBoolToHRESULT(File.Close());
+}
+
+STDMETHODIMP COutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ #ifdef USE_WIN_FILE
+
+ UInt32 realProcessedSize;
+ bool result = File.WritePart(data, size, realProcessedSize);
+ ProcessedSize += realProcessedSize;
+ if(processedSize != NULL)
+ *processedSize = realProcessedSize;
+ return ConvertBoolToHRESULT(result);
+
+ #else
+
+ if(processedSize != NULL)
+ *processedSize = 0;
+ ssize_t res = File.Write(data, (size_t)size);
+ if (res == -1)
+ return E_FAIL;
+ if(processedSize != NULL)
+ *processedSize = (UInt32)res;
+ ProcessedSize += res;
+ return S_OK;
+
+ #endif
+}
+
+STDMETHODIMP COutFileStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ if(seekOrigin >= 3)
+ return STG_E_INVALIDFUNCTION;
+ #ifdef USE_WIN_FILE
+
+ UInt64 realNewPosition;
+ bool result = File.Seek(offset, seekOrigin, realNewPosition);
+ if(newPosition != NULL)
+ *newPosition = realNewPosition;
+ return ConvertBoolToHRESULT(result);
+
+ #else
+
+ off_t res = File.Seek(offset, seekOrigin);
+ if (res == -1)
+ return E_FAIL;
+ if(newPosition != NULL)
+ *newPosition = (UInt64)res;
+ return S_OK;
+
+ #endif
+}
+
+STDMETHODIMP COutFileStream::SetSize(Int64 newSize)
+{
+ #ifdef USE_WIN_FILE
+ UInt64 currentPos;
+ if(!File.Seek(0, FILE_CURRENT, currentPos))
+ return E_FAIL;
+ bool result = File.SetLength(newSize);
+ UInt64 currentPos2;
+ result = result && File.Seek(currentPos, currentPos2);
+ return result ? S_OK : E_FAIL;
+ #else
+ return E_FAIL;
+ #endif
+}
+
+#ifndef _WIN32_WCE
+STDMETHODIMP CStdOutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if(processedSize != NULL)
+ *processedSize = 0;
+
+ #ifdef _WIN32
+ UInt32 realProcessedSize;
+ BOOL res = TRUE;
+ if (size > 0)
+ {
+ // Seems that Windows doesn't like big amounts writing to stdout.
+ // So we limit portions by 32KB.
+ UInt32 sizeTemp = (1 << 15);
+ if (sizeTemp > size)
+ sizeTemp = size;
+ res = ::WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
+ data, sizeTemp, (DWORD *)&realProcessedSize, NULL);
+ size -= realProcessedSize;
+ data = (const void *)((const Byte *)data + realProcessedSize);
+ if(processedSize != NULL)
+ *processedSize += realProcessedSize;
+ }
+ return ConvertBoolToHRESULT(res != FALSE);
+
+ #else
+
+ ssize_t res;
+ do
+ {
+ res = write(1, data, (size_t)size);
+ }
+ while (res < 0 && (errno == EINTR));
+ if (res == -1)
+ return E_FAIL;
+ if(processedSize != NULL)
+ *processedSize = (UInt32)res;
+ return S_OK;
+
+ return S_OK;
+ #endif
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FileStreams.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FileStreams.h
new file mode 100644
index 000000000..5c7f65e11
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FileStreams.h
@@ -0,0 +1,141 @@
+// FileStreams.h
+
+#ifndef __FILESTREAMS_H
+#define __FILESTREAMS_H
+
+#if defined(_WIN32) || defined(ENV_UNIX)
+#define USE_WIN_FILE
+#endif
+
+#ifdef USE_WIN_FILE
+#include "../../Windows/FileIO.h"
+#else
+#include "../../Common/C_FileIO.h"
+#endif
+
+#include "../IStream.h"
+#include "../../Common/MyCom.h"
+
+class CInFileStream:
+ public IInStream,
+ public IStreamGetSize,
+ public CMyUnknownImp
+{
+ bool _ignoreSymbolicLink;
+public:
+ #ifdef USE_WIN_FILE
+ NWindows::NFile::NIO::CInFile File;
+ #else
+ NC::NFile::NIO::CInFile File;
+ #endif
+ CInFileStream(bool b=false) { _ignoreSymbolicLink = b; }
+ virtual ~CInFileStream() {}
+
+ bool Open(LPCTSTR fileName);
+ #ifdef USE_WIN_FILE
+ #ifndef _UNICODE
+ bool Open(LPCWSTR fileName);
+ #endif
+ #endif
+
+ bool OpenShared(LPCTSTR fileName, bool shareForWrite);
+ #ifdef USE_WIN_FILE
+ #ifndef _UNICODE
+ bool OpenShared(LPCWSTR fileName, bool shareForWrite);
+ #endif
+ #endif
+
+ MY_UNKNOWN_IMP2(IInStream, IStreamGetSize)
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+
+ STDMETHOD(GetSize)(UInt64 *size);
+};
+
+#ifndef _WIN32_WCE
+class CStdInFileStream:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+public:
+ // HANDLE File;
+ // CStdInFileStream() File(INVALID_HANDLE_VALUE): {}
+ // void Open() { File = GetStdHandle(STD_INPUT_HANDLE); };
+ MY_UNKNOWN_IMP
+
+ virtual ~CStdInFileStream() {}
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+};
+#endif
+
+class COutFileStream:
+ public IOutStream,
+ public CMyUnknownImp
+{
+ #ifdef USE_WIN_FILE
+ NWindows::NFile::NIO::COutFile File;
+ #else
+ NC::NFile::NIO::COutFile File;
+ #endif
+public:
+ virtual ~COutFileStream() {}
+ bool Create(LPCTSTR fileName, bool createAlways)
+ {
+ ProcessedSize = 0;
+ return File.Create(fileName, createAlways);
+ }
+ bool Open(LPCTSTR fileName, DWORD creationDisposition)
+ {
+ ProcessedSize = 0;
+ return File.Open(fileName, creationDisposition);
+ }
+ #ifdef USE_WIN_FILE
+ #ifndef _UNICODE
+ bool Create(LPCWSTR fileName, bool createAlways)
+ {
+ ProcessedSize = 0;
+ return File.Create(fileName, createAlways);
+ }
+ bool Open(LPCWSTR fileName, DWORD creationDisposition)
+ {
+ ProcessedSize = 0;
+ return File.Open(fileName, creationDisposition);
+ }
+ #endif
+ #endif
+
+ HRESULT Close();
+
+ UInt64 ProcessedSize;
+
+ #ifdef USE_WIN_FILE
+ bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime)
+ {
+ return File.SetTime(cTime, aTime, mTime);
+ }
+ bool SetMTime(const FILETIME *mTime) { return File.SetMTime(mTime); }
+ #endif
+
+
+ MY_UNKNOWN_IMP1(IOutStream)
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+ STDMETHOD(SetSize)(Int64 newSize);
+};
+
+#ifndef _WIN32_WCE
+class CStdOutFileStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+
+ virtual ~CStdOutFileStream() {}
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilterCoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilterCoder.cpp
new file mode 100644
index 000000000..d99110856
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilterCoder.cpp
@@ -0,0 +1,255 @@
+// FilterCoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "../../Common/Defs.h"
+
+#include "FilterCoder.h"
+#include "StreamUtils.h"
+
+static const UInt32 kBufferSize = 1 << 17;
+
+CFilterCoder::CFilterCoder()
+{
+ _buffer = (Byte *)::MidAlloc(kBufferSize);
+}
+
+CFilterCoder::~CFilterCoder()
+{
+ ::MidFree(_buffer);
+}
+
+HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 size)
+{
+ if (_outSizeIsDefined)
+ {
+ UInt64 remSize = _outSize - _nowPos64;
+ if (size > remSize)
+ size = (UInt32)remSize;
+ }
+ RINOK(WriteStream(outStream, _buffer, size));
+ _nowPos64 += size;
+ return S_OK;
+}
+
+
+STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ RINOK(Init());
+ UInt32 bufferPos = 0;
+ _outSizeIsDefined = (outSize != 0);
+ if (_outSizeIsDefined)
+ _outSize = *outSize;
+
+ while(NeedMore())
+ {
+ size_t processedSize = kBufferSize - bufferPos;
+
+ // Change it: It can be optimized using ReadPart
+ RINOK(ReadStream(inStream, _buffer + bufferPos, &processedSize));
+
+ UInt32 endPos = bufferPos + (UInt32)processedSize;
+
+ bufferPos = Filter->Filter(_buffer, endPos);
+ if (bufferPos > endPos)
+ {
+ for (; endPos< bufferPos; endPos++)
+ _buffer[endPos] = 0;
+ bufferPos = Filter->Filter(_buffer, endPos);
+ }
+
+ if (bufferPos == 0)
+ {
+ if (endPos > 0)
+ return WriteWithLimit(outStream, endPos);
+ return S_OK;
+ }
+ RINOK(WriteWithLimit(outStream, bufferPos));
+ if (progress != NULL)
+ {
+ RINOK(progress->SetRatioInfo(&_nowPos64, &_nowPos64));
+ }
+ UInt32 i = 0;
+ while(bufferPos < endPos)
+ _buffer[i++] = _buffer[bufferPos++];
+ bufferPos = i;
+ }
+ return S_OK;
+}
+
+// #ifdef _ST_MODE
+STDMETHODIMP CFilterCoder::SetOutStream(ISequentialOutStream *outStream)
+{
+ _bufferPos = 0;
+ _outStream = outStream;
+ return Init();
+}
+
+STDMETHODIMP CFilterCoder::ReleaseOutStream()
+{
+ _outStream.Release();
+ return S_OK;
+};
+
+
+STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 processedSizeTotal = 0;
+ while(size > 0)
+ {
+ UInt32 sizeMax = kBufferSize - _bufferPos;
+ UInt32 sizeTemp = size;
+ if (sizeTemp > sizeMax)
+ sizeTemp = sizeMax;
+ memmove(_buffer + _bufferPos, data, sizeTemp);
+ size -= sizeTemp;
+ processedSizeTotal += sizeTemp;
+ data = (const Byte *)data + sizeTemp;
+ UInt32 endPos = _bufferPos + sizeTemp;
+ _bufferPos = Filter->Filter(_buffer, endPos);
+ if (_bufferPos == 0)
+ {
+ _bufferPos = endPos;
+ break;
+ }
+ if (_bufferPos > endPos)
+ {
+ if (size != 0)
+ return E_FAIL;
+ break;
+ }
+ RINOK(WriteWithLimit(_outStream, _bufferPos));
+ UInt32 i = 0;
+ while(_bufferPos < endPos)
+ _buffer[i++] = _buffer[_bufferPos++];
+ _bufferPos = i;
+ }
+ if (processedSize != NULL)
+ *processedSize = processedSizeTotal;
+ return S_OK;
+}
+
+STDMETHODIMP CFilterCoder::Flush()
+{
+ if (_bufferPos != 0)
+ {
+ UInt32 endPos = Filter->Filter(_buffer, _bufferPos);
+ if (endPos > _bufferPos)
+ {
+ for (; _bufferPos < endPos; _bufferPos++)
+ _buffer[_bufferPos] = 0;
+ if (Filter->Filter(_buffer, endPos) != endPos)
+ return E_FAIL;
+ }
+ RINOK(WriteStream(_outStream, _buffer, _bufferPos));
+ _bufferPos = 0;
+ }
+ CMyComPtr<IOutStreamFlush> flush;
+ _outStream.QueryInterface(IID_IOutStreamFlush, &flush);
+ if (flush)
+ return flush->Flush();
+ return S_OK;
+}
+
+
+STDMETHODIMP CFilterCoder::SetInStream(ISequentialInStream *inStream)
+{
+ _convertedPosBegin = _convertedPosEnd = _bufferPos = 0;
+ _inStream = inStream;
+ return Init();
+}
+
+STDMETHODIMP CFilterCoder::ReleaseInStream()
+{
+ _inStream.Release();
+ return S_OK;
+};
+
+STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 processedSizeTotal = 0;
+ while(size > 0)
+ {
+ if (_convertedPosBegin != _convertedPosEnd)
+ {
+ UInt32 sizeTemp = MyMin(size, _convertedPosEnd - _convertedPosBegin);
+ memmove(data, _buffer + _convertedPosBegin, sizeTemp);
+ _convertedPosBegin += sizeTemp;
+ data = (void *)((Byte *)data + sizeTemp);
+ size -= sizeTemp;
+ processedSizeTotal += sizeTemp;
+ break;
+ }
+ int i;
+ for (i = 0; _convertedPosEnd + i < _bufferPos; i++)
+ _buffer[i] = _buffer[i + _convertedPosEnd];
+ _bufferPos = i;
+ _convertedPosBegin = _convertedPosEnd = 0;
+ size_t processedSizeTemp = kBufferSize - _bufferPos;
+ RINOK(ReadStream(_inStream, _buffer + _bufferPos, &processedSizeTemp));
+ _bufferPos = _bufferPos + (UInt32)processedSizeTemp;
+ _convertedPosEnd = Filter->Filter(_buffer, _bufferPos);
+ if (_convertedPosEnd == 0)
+ {
+ if (_bufferPos == 0)
+ break;
+ else
+ {
+ _convertedPosEnd = _bufferPos; // check it
+ continue;
+ }
+ }
+ if (_convertedPosEnd > _bufferPos)
+ {
+ for (; _bufferPos < _convertedPosEnd; _bufferPos++)
+ _buffer[_bufferPos] = 0;
+ _convertedPosEnd = Filter->Filter(_buffer, _bufferPos);
+ }
+ }
+ if (processedSize != NULL)
+ *processedSize = processedSizeTotal;
+ return S_OK;
+}
+
+// #endif // _ST_MODE
+
+#ifndef _NO_CRYPTO
+STDMETHODIMP CFilterCoder::CryptoSetPassword(const Byte *data, UInt32 size)
+{
+ return _setPassword->CryptoSetPassword(data, size);
+}
+#endif
+
+#ifndef EXTRACT_ONLY
+STDMETHODIMP CFilterCoder::SetCoderProperties(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties)
+{
+ return _SetCoderProperties->SetCoderProperties(propIDs, properties, numProperties);
+}
+
+STDMETHODIMP CFilterCoder::WriteCoderProperties(ISequentialOutStream *outStream)
+{
+ return _writeCoderProperties->WriteCoderProperties(outStream);
+}
+
+/*
+STDMETHODIMP CFilterCoder::ResetSalt()
+{
+ return _CryptoResetSalt->ResetSalt();
+}
+*/
+
+STDMETHODIMP CFilterCoder::ResetInitVector()
+{
+ return _CryptoResetInitVector->ResetInitVector();
+}
+#endif
+
+STDMETHODIMP CFilterCoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ return _setDecoderProperties->SetDecoderProperties2(data, size);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilterCoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilterCoder.h
new file mode 100644
index 000000000..a0ec08ca6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/FilterCoder.h
@@ -0,0 +1,143 @@
+// FilterCoder.h
+
+#ifndef __FILTERCODER_H
+#define __FILTERCODER_H
+
+#include "../../Common/MyCom.h"
+#include "../ICoder.h"
+#include "../IPassword.h"
+
+#define MY_QUERYINTERFACE_ENTRY_AG(i, sub0, sub) if (iid == IID_ ## i) \
+{ if (!sub) RINOK(sub0->QueryInterface(IID_ ## i, (void **)&sub)) \
+*outObject = (void *)(i *)this; AddRef(); return S_OK; }
+
+class CFilterCoder:
+ public ICompressCoder,
+ // #ifdef _ST_MODE
+ public ICompressSetInStream,
+ public ISequentialInStream,
+ public ICompressSetOutStream,
+ public ISequentialOutStream,
+ public IOutStreamFlush,
+ // #endif
+
+ #ifndef _NO_CRYPTO
+ public ICryptoSetPassword,
+ #endif
+ #ifndef EXTRACT_ONLY
+ public ICompressSetCoderProperties,
+ public ICompressWriteCoderProperties,
+ // public ICryptoResetSalt,
+ public ICryptoResetInitVector,
+ #endif
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+protected:
+ Byte *_buffer;
+ // #ifdef _ST_MODE
+ CMyComPtr<ISequentialInStream> _inStream;
+ CMyComPtr<ISequentialOutStream> _outStream;
+ UInt32 _bufferPos;
+ UInt32 _convertedPosBegin;
+ UInt32 _convertedPosEnd;
+ // #endif
+ bool _outSizeIsDefined;
+ UInt64 _outSize;
+ UInt64 _nowPos64;
+
+ HRESULT Init()
+ {
+ _nowPos64 = 0;
+ _outSizeIsDefined = false;
+ return Filter->Init();
+ }
+
+ CMyComPtr<ICryptoSetPassword> _setPassword;
+ #ifndef EXTRACT_ONLY
+ CMyComPtr<ICompressSetCoderProperties> _SetCoderProperties;
+ CMyComPtr<ICompressWriteCoderProperties> _writeCoderProperties;
+ // CMyComPtr<ICryptoResetSalt> _CryptoResetSalt;
+ CMyComPtr<ICryptoResetInitVector> _CryptoResetInitVector;
+ #endif
+ CMyComPtr<ICompressSetDecoderProperties2> _setDecoderProperties;
+public:
+ CMyComPtr<ICompressFilter> Filter;
+
+ CFilterCoder();
+ ~CFilterCoder();
+ HRESULT WriteWithLimit(ISequentialOutStream *outStream, UInt32 size);
+ bool NeedMore() const
+ { return (!_outSizeIsDefined || (_nowPos64 < _outSize)); }
+
+public:
+ MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_ENTRY(ICompressCoder)
+ // #ifdef _ST_MODE
+ MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
+ MY_QUERYINTERFACE_ENTRY(ISequentialInStream)
+
+ MY_QUERYINTERFACE_ENTRY(ICompressSetOutStream)
+ MY_QUERYINTERFACE_ENTRY(ISequentialOutStream)
+ MY_QUERYINTERFACE_ENTRY(IOutStreamFlush)
+ // #endif
+
+ #ifndef _NO_CRYPTO
+ MY_QUERYINTERFACE_ENTRY_AG(ICryptoSetPassword, Filter, _setPassword)
+ #endif
+
+ #ifndef EXTRACT_ONLY
+ MY_QUERYINTERFACE_ENTRY_AG(ICompressSetCoderProperties, Filter, _SetCoderProperties)
+ MY_QUERYINTERFACE_ENTRY_AG(ICompressWriteCoderProperties, Filter, _writeCoderProperties)
+ // MY_QUERYINTERFACE_ENTRY_AG(ICryptoResetSalt, Filter, _CryptoResetSalt)
+ MY_QUERYINTERFACE_ENTRY_AG(ICryptoResetInitVector, Filter, _CryptoResetInitVector)
+ #endif
+
+ MY_QUERYINTERFACE_ENTRY_AG(ICompressSetDecoderProperties2, Filter, _setDecoderProperties)
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+ // #ifdef _ST_MODE
+ STDMETHOD(ReleaseInStream)();
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream);
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); \
+ STDMETHOD(SetOutStream)(ISequentialOutStream *outStream);
+ STDMETHOD(ReleaseOutStream)();
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Flush)();
+ // #endif
+
+ #ifndef _NO_CRYPTO
+ STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
+ #endif
+ #ifndef EXTRACT_ONLY
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties);
+ STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+ // STDMETHOD(ResetSalt)();
+ STDMETHOD(ResetInitVector)();
+ #endif
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+};
+
+// #ifdef _ST_MODE
+class CInStreamReleaser
+{
+public:
+ CFilterCoder *FilterCoder;
+ CInStreamReleaser(): FilterCoder(0) {}
+ ~CInStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseInStream(); }
+};
+
+class COutStreamReleaser
+{
+public:
+ CFilterCoder *FilterCoder;
+ COutStreamReleaser(): FilterCoder(0) {}
+ ~COutStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseOutStream(); }
+};
+// #endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InBuffer.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InBuffer.cpp
new file mode 100644
index 000000000..03924d2a8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InBuffer.cpp
@@ -0,0 +1,80 @@
+// InBuffer.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "InBuffer.h"
+
+CInBuffer::CInBuffer():
+ _buffer(0),
+ _bufferLimit(0),
+ _bufferBase(0),
+ _stream(0),
+ _bufferSize(0)
+{}
+
+bool CInBuffer::Create(UInt32 bufferSize)
+{
+ const UInt32 kMinBlockSize = 1;
+ if (bufferSize < kMinBlockSize)
+ bufferSize = kMinBlockSize;
+ if (_bufferBase != 0 && _bufferSize == bufferSize)
+ return true;
+ Free();
+ _bufferSize = bufferSize;
+ _bufferBase = (Byte *)::MidAlloc(bufferSize);
+ return (_bufferBase != 0);
+}
+
+void CInBuffer::Free()
+{
+ ::MidFree(_bufferBase);
+ _bufferBase = 0;
+}
+
+void CInBuffer::SetStream(ISequentialInStream *stream)
+{
+ _stream = stream;
+}
+
+void CInBuffer::Init()
+{
+ _processedSize = 0;
+ _buffer = _bufferBase;
+ _bufferLimit = _buffer;
+ _wasFinished = false;
+ #ifdef _NO_EXCEPTIONS
+ ErrorCode = S_OK;
+ #endif
+}
+
+bool CInBuffer::ReadBlock()
+{
+ #ifdef _NO_EXCEPTIONS
+ if (ErrorCode != S_OK)
+ return false;
+ #endif
+ if (_wasFinished)
+ return false;
+ _processedSize += (_buffer - _bufferBase);
+ UInt32 numProcessedBytes;
+ HRESULT result = _stream->Read(_bufferBase, _bufferSize, &numProcessedBytes);
+ #ifdef _NO_EXCEPTIONS
+ ErrorCode = result;
+ #else
+ if (result != S_OK)
+ throw CInBufferException(result);
+ #endif
+ _buffer = _bufferBase;
+ _bufferLimit = _buffer + numProcessedBytes;
+ _wasFinished = (numProcessedBytes == 0);
+ return (!_wasFinished);
+}
+
+Byte CInBuffer::ReadBlock2()
+{
+ if(!ReadBlock())
+ return 0xFF;
+ return *_buffer++;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InBuffer.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InBuffer.h
new file mode 100644
index 000000000..75625bfd9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InBuffer.h
@@ -0,0 +1,81 @@
+// InBuffer.h
+
+#ifndef __INBUFFER_H
+#define __INBUFFER_H
+
+#include "../IStream.h"
+#include "../../Common/MyCom.h"
+#include "../../Common/MyException.h"
+
+#ifndef _NO_EXCEPTIONS
+struct CInBufferException: public CSystemException
+{
+ CInBufferException(HRESULT errorCode): CSystemException(errorCode) {}
+};
+#endif
+
+class CInBuffer
+{
+ Byte *_buffer;
+ Byte *_bufferLimit;
+ Byte *_bufferBase;
+ CMyComPtr<ISequentialInStream> _stream;
+ UInt64 _processedSize;
+ UInt32 _bufferSize;
+ bool _wasFinished;
+
+ bool ReadBlock();
+ Byte ReadBlock2();
+
+public:
+ #ifdef _NO_EXCEPTIONS
+ HRESULT ErrorCode;
+ #endif
+
+ CInBuffer();
+ ~CInBuffer() { Free(); }
+
+ bool Create(UInt32 bufferSize);
+ void Free();
+
+ void SetStream(ISequentialInStream *stream);
+ void Init();
+ void ReleaseStream() { _stream.Release(); }
+
+ bool ReadByte(Byte &b)
+ {
+ if (_buffer >= _bufferLimit)
+ if (!ReadBlock())
+ return false;
+ b = *_buffer++;
+ return true;
+ }
+ Byte ReadByte()
+ {
+ if (_buffer >= _bufferLimit)
+ return ReadBlock2();
+ return *_buffer++;
+ }
+ UInt32 ReadBytes(Byte *buf, UInt32 size)
+ {
+ if ((UInt32)(_bufferLimit - _buffer) >= size)
+ {
+ for (UInt32 i = 0; i < size; i++)
+ buf[i] = _buffer[i];
+ _buffer += size;
+ return size;
+ }
+ for (UInt32 i = 0; i < size; i++)
+ {
+ if (_buffer >= _bufferLimit)
+ if (!ReadBlock())
+ return i;
+ buf[i] = *_buffer++;
+ }
+ return size;
+ }
+ UInt64 GetProcessedSize() const { return _processedSize + (_buffer - _bufferBase); }
+ bool WasFinished() const { return _wasFinished; }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InOutTempBuffer.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InOutTempBuffer.cpp
new file mode 100644
index 000000000..4cc0b2f24
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InOutTempBuffer.cpp
@@ -0,0 +1,122 @@
+// InOutTempBuffer.cpp
+
+#include "StdAfx.h"
+
+#include "InOutTempBuffer.h"
+#include "../../Common/Defs.h"
+// #include "Windows/Defs.h"
+
+#include "StreamUtils.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NDirectory;
+
+static UInt32 kTmpBufferMemorySize = (1 << 20);
+
+static LPCTSTR kTempFilePrefixString = TEXT("iot");
+
+CInOutTempBuffer::CInOutTempBuffer():
+ _buffer(NULL)
+{
+}
+
+void CInOutTempBuffer::Create()
+{
+ _buffer = new Byte[kTmpBufferMemorySize];
+}
+
+CInOutTempBuffer::~CInOutTempBuffer()
+{
+ delete []_buffer;
+}
+void CInOutTempBuffer::InitWriting()
+{
+ _bufferPosition = 0;
+ _tmpFileCreated = false;
+ _fileSize = 0;
+}
+
+bool CInOutTempBuffer::WriteToFile(const void *data, UInt32 size)
+{
+ if (size == 0)
+ return true;
+ if(!_tmpFileCreated)
+ {
+ CSysString tempDirPath;
+ if(!MyGetTempPath(tempDirPath))
+ return false;
+ if (_tempFile.Create(tempDirPath, kTempFilePrefixString, _tmpFileName) == 0)
+ return false;
+ // _outFile.SetOpenCreationDispositionCreateAlways();
+ if(!_outFile.Create(_tmpFileName, true))
+ return false;
+ _tmpFileCreated = true;
+ }
+ UInt32 processedSize;
+ if(!_outFile.Write(data, size, processedSize))
+ return false;
+ _fileSize += processedSize;
+ return (processedSize == size);
+}
+
+bool CInOutTempBuffer::FlushWrite()
+{
+ return _outFile.Close();
+}
+
+bool CInOutTempBuffer::Write(const void *data, UInt32 size)
+{
+ if(_bufferPosition < kTmpBufferMemorySize)
+ {
+ UInt32 curSize = MyMin(kTmpBufferMemorySize - _bufferPosition, size);
+ memmove(_buffer + _bufferPosition, (const Byte *)data, curSize);
+ _bufferPosition += curSize;
+ size -= curSize;
+ data = ((const Byte *)data) + curSize;
+ _fileSize += curSize;
+ }
+ return WriteToFile(data, size);
+}
+
+bool CInOutTempBuffer::InitReading()
+{
+ _currentPositionInBuffer = 0;
+ if(_tmpFileCreated)
+ return _inFile.Open(_tmpFileName);
+ return true;
+}
+
+HRESULT CInOutTempBuffer::WriteToStream(ISequentialOutStream *stream)
+{
+ if (_currentPositionInBuffer < _bufferPosition)
+ {
+ UInt32 sizeToWrite = _bufferPosition - _currentPositionInBuffer;
+ RINOK(WriteStream(stream, _buffer + _currentPositionInBuffer, sizeToWrite));
+ _currentPositionInBuffer += sizeToWrite;
+ }
+ if (!_tmpFileCreated)
+ return true;
+ for (;;)
+ {
+ UInt32 localProcessedSize;
+ if (!_inFile.ReadPart(_buffer, kTmpBufferMemorySize, localProcessedSize))
+ return E_FAIL;
+ if (localProcessedSize == 0)
+ return S_OK;
+ RINOK(WriteStream(stream, _buffer, localProcessedSize));
+ }
+}
+
+STDMETHODIMP CSequentialOutTempBufferImp::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (!_buffer->Write(data, size))
+ {
+ if (processedSize != NULL)
+ *processedSize = 0;
+ return E_FAIL;
+ }
+ if (processedSize != NULL)
+ *processedSize = size;
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InOutTempBuffer.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InOutTempBuffer.h
new file mode 100644
index 000000000..e1e0e9711
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/InOutTempBuffer.h
@@ -0,0 +1,55 @@
+// Util/InOutTempBuffer.h
+
+#ifndef __IN_OUT_TEMP_BUFFER_H
+#define __IN_OUT_TEMP_BUFFER_H
+
+#include "../../Windows/FileIO.h"
+#include "../../Windows/FileDir.h"
+#include "../../Common/MyCom.h"
+
+#include "../IStream.h"
+
+class CInOutTempBuffer
+{
+ NWindows::NFile::NDirectory::CTempFile _tempFile;
+ NWindows::NFile::NIO::COutFile _outFile;
+ NWindows::NFile::NIO::CInFile _inFile;
+ Byte *_buffer;
+ UInt32 _bufferPosition;
+ UInt32 _currentPositionInBuffer;
+ CSysString _tmpFileName;
+ bool _tmpFileCreated;
+
+ UInt64 _fileSize;
+
+ bool WriteToFile(const void *data, UInt32 size);
+public:
+ CInOutTempBuffer();
+ ~CInOutTempBuffer();
+ void Create();
+
+ void InitWriting();
+ bool Write(const void *data, UInt32 size);
+ UInt64 GetDataSize() const { return _fileSize; }
+ bool FlushWrite();
+ bool InitReading();
+ HRESULT WriteToStream(ISequentialOutStream *stream);
+};
+
+class CSequentialOutTempBufferImp:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CInOutTempBuffer *_buffer;
+public:
+ // CSequentialOutStreamImp(): _size(0) {}
+ // UInt32 _size;
+ void Init(CInOutTempBuffer *buffer) { _buffer = buffer; }
+ // UInt32 GetSize() const { return _size; }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LimitedStreams.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LimitedStreams.cpp
new file mode 100644
index 000000000..1837e3201
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LimitedStreams.cpp
@@ -0,0 +1,154 @@
+// LimitedStreams.cpp
+
+#include "StdAfx.h"
+
+#include "LimitedStreams.h"
+#include "../../Common/Defs.h"
+
+STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize = 0;
+ UInt32 sizeToRead = (UInt32)MyMin((_size - _pos), (UInt64)size);
+ HRESULT result = S_OK;
+ if (sizeToRead > 0)
+ {
+ result = _stream->Read(data, sizeToRead, &realProcessedSize);
+ _pos += realProcessedSize;
+ if (realProcessedSize == 0)
+ _wasFinished = true;
+ }
+ if (processedSize != NULL)
+ *processedSize = realProcessedSize;
+ return result;
+}
+
+STDMETHODIMP CLimitedInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ if (_virtPos >= _size)
+ return (_virtPos == _size) ? S_OK: E_FAIL;
+ UInt64 rem = _size - _virtPos;
+ if (rem < size)
+ size = (UInt32)rem;
+ UInt64 newPos = _startOffset + _virtPos;
+ if (newPos != _physPos)
+ {
+ _physPos = newPos;
+ RINOK(SeekToPhys());
+ }
+ HRESULT res = _stream->Read(data, size, &size);
+ if (processedSize != NULL)
+ *processedSize = size;
+ _physPos += size;
+ _virtPos += size;
+ return res;
+}
+
+STDMETHODIMP CLimitedInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET: _virtPos = offset; break;
+ case STREAM_SEEK_CUR: _virtPos += offset; break;
+ case STREAM_SEEK_END: _virtPos = _size + offset; break;
+ default: return STG_E_INVALIDFUNCTION;
+ }
+ if (newPosition)
+ *newPosition = _virtPos;
+ return S_OK;
+}
+
+STDMETHODIMP CClusterInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ if (_virtPos >= Size)
+ return (_virtPos == Size) ? S_OK: E_FAIL;
+
+ if (_curRem == 0)
+ {
+ UInt32 blockSize = (UInt32)1 << BlockSizeLog;
+ UInt32 virtBlock = (UInt32)(_virtPos >> BlockSizeLog);
+ UInt32 offsetInBlock = (UInt32)_virtPos & (blockSize - 1);
+ UInt32 phyBlock = Vector[virtBlock];
+ UInt64 newPos = StartOffset + ((UInt64)phyBlock << BlockSizeLog) + offsetInBlock;
+ if (newPos != _physPos)
+ {
+ _physPos = newPos;
+ RINOK(SeekToPhys());
+ }
+ _curRem = blockSize - offsetInBlock;
+ for (int i = 1; i < 64 && (virtBlock + i) < (UInt32)Vector.Size() && phyBlock + i == Vector[virtBlock + i]; i++)
+ _curRem += (UInt32)1 << BlockSizeLog;
+ UInt64 rem = Size - _virtPos;
+ if (_curRem > rem)
+ _curRem = (UInt32)rem;
+ }
+ if (size > _curRem)
+ size = _curRem;
+ HRESULT res = Stream->Read(data, size, &size);
+ if (processedSize != NULL)
+ *processedSize = size;
+ _physPos += size;
+ _virtPos += size;
+ _curRem -= size;
+ return res;
+}
+
+STDMETHODIMP CClusterInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ UInt64 newVirtPos = offset;
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET: break;
+ case STREAM_SEEK_CUR: newVirtPos += _virtPos; break;
+ case STREAM_SEEK_END: newVirtPos += Size; break;
+ default: return STG_E_INVALIDFUNCTION;
+ }
+ if (_virtPos != newVirtPos)
+ _curRem = 0;
+ _virtPos = newVirtPos;
+ if (newPosition)
+ *newPosition = newVirtPos;
+ return S_OK;
+}
+
+
+HRESULT CreateLimitedInStream(IInStream *inStream, UInt64 pos, UInt64 size, ISequentialInStream **resStream)
+{
+ *resStream = 0;
+ CLimitedInStream *streamSpec = new CLimitedInStream;
+ CMyComPtr<ISequentialInStream> streamTemp = streamSpec;
+ streamSpec->SetStream(inStream);
+ RINOK(streamSpec->InitAndSeek(pos, size));
+ streamSpec->SeekToStart();
+ *resStream = streamTemp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CLimitedSequentialOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ HRESULT result = S_OK;
+ if (processedSize != NULL)
+ *processedSize = 0;
+ if (size > _size)
+ {
+ if (_size == 0)
+ {
+ _overflow = true;
+ if (!_overflowIsAllowed)
+ return E_FAIL;
+ if (processedSize != NULL)
+ *processedSize = size;
+ return S_OK;
+ }
+ size = (UInt32)_size;
+ }
+ if (_stream)
+ result = _stream->Write(data, size, &size);
+ _size -= size;
+ if (processedSize != NULL)
+ *processedSize = size;
+ return result;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LimitedStreams.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LimitedStreams.h
new file mode 100644
index 000000000..f6900d510
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LimitedStreams.h
@@ -0,0 +1,124 @@
+// LimitedStreams.h
+
+#ifndef __LIMITED_STREAMS_H
+#define __LIMITED_STREAMS_H
+
+#include "../../Common/MyCom.h"
+#include "../../Common/MyVector.h"
+#include "../IStream.h"
+
+class CLimitedSequentialInStream:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialInStream> _stream;
+ UInt64 _size;
+ UInt64 _pos;
+ bool _wasFinished;
+public:
+ void SetStream(ISequentialInStream *stream) { _stream = stream; }
+ void Init(UInt64 streamSize)
+ {
+ _size = streamSize;
+ _pos = 0;
+ _wasFinished = false;
+ }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ UInt64 GetSize() const { return _pos; }
+ bool WasFinished() const { return _wasFinished; }
+};
+
+class CLimitedInStream:
+ public IInStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _stream;
+ UInt64 _virtPos;
+ UInt64 _physPos;
+ UInt64 _size;
+ UInt64 _startOffset;
+
+ HRESULT SeekToPhys() { return _stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
+public:
+ void SetStream(IInStream *stream) { _stream = stream; }
+ HRESULT InitAndSeek(UInt64 startOffset, UInt64 size)
+ {
+ _startOffset = startOffset;
+ _physPos = startOffset;
+ _virtPos = 0;
+ _size = size;
+ return SeekToPhys();
+ }
+
+ MY_UNKNOWN_IMP1(IInStream)
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+
+ HRESULT SeekToStart() { return Seek(0, STREAM_SEEK_SET, NULL); }
+};
+
+class CClusterInStream:
+ public IInStream,
+ public CMyUnknownImp
+{
+ UInt64 _virtPos;
+ UInt64 _physPos;
+ UInt32 _curRem;
+public:
+ CMyComPtr<IInStream> Stream;
+ UInt64 StartOffset;
+ UInt64 Size;
+ int BlockSizeLog;
+ CRecordVector<UInt32> Vector;
+
+ HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
+
+ HRESULT InitAndSeek()
+ {
+ _curRem = 0;
+ _virtPos = 0;
+ _physPos = StartOffset;
+ if (Vector.Size() > 0)
+ {
+ _physPos = StartOffset + (Vector[0] << BlockSizeLog);
+ return SeekToPhys();
+ }
+ return S_OK;
+ }
+
+ MY_UNKNOWN_IMP1(IInStream)
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+};
+
+HRESULT CreateLimitedInStream(IInStream *inStream, UInt64 pos, UInt64 size, ISequentialInStream **resStream);
+
+class CLimitedSequentialOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialOutStream> _stream;
+ UInt64 _size;
+ bool _overflow;
+ bool _overflowIsAllowed;
+public:
+ MY_UNKNOWN_IMP
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ void SetStream(ISequentialOutStream *stream) { _stream = stream; }
+ void ReleaseStream() { _stream.Release(); }
+ void Init(UInt64 size, bool overflowIsAllowed = false)
+ {
+ _size = size;
+ _overflow = false;
+ _overflowIsAllowed = overflowIsAllowed;
+ }
+ bool IsFinishedOK() const { return (_size == 0 && !_overflow); }
+ UInt64 GetRem() const { return _size; }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LockedStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LockedStream.cpp
new file mode 100644
index 000000000..f05601cb6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LockedStream.cpp
@@ -0,0 +1,23 @@
+// LockedStream.cpp
+
+#include "StdAfx.h"
+
+#include "LockedStream.h"
+
+HRESULT CLockedInStream::Read(UInt64 startPos, void *data, UInt32 size,
+ UInt32 *processedSize)
+{
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ RINOK(_stream->Seek(startPos, STREAM_SEEK_SET, NULL));
+ return _stream->Read(data, size, processedSize);
+}
+
+STDMETHODIMP CLockedSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize = 0;
+ HRESULT result = _lockedInStream->Read(_pos, data, size, &realProcessedSize);
+ _pos += realProcessedSize;
+ if (processedSize != NULL)
+ *processedSize = realProcessedSize;
+ return result;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LockedStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LockedStream.h
new file mode 100644
index 000000000..486e4220b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/LockedStream.h
@@ -0,0 +1,38 @@
+// LockedStream.h
+
+#ifndef __LOCKEDSTREAM_H
+#define __LOCKEDSTREAM_H
+
+#include "../../Windows/Synchronization.h"
+#include "../../Common/MyCom.h"
+#include "../IStream.h"
+
+class CLockedInStream
+{
+ CMyComPtr<IInStream> _stream;
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+public:
+ void Init(IInStream *stream)
+ { _stream = stream; }
+ HRESULT Read(UInt64 startPos, void *data, UInt32 size, UInt32 *processedSize);
+};
+
+class CLockedSequentialInStreamImp:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+ CLockedInStream *_lockedInStream;
+ UInt64 _pos;
+public:
+ void Init(CLockedInStream *lockedInStream, UInt64 startPos)
+ {
+ _lockedInStream = lockedInStream;
+ _pos = startPos;
+ }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MemBlocks.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MemBlocks.cpp
new file mode 100644
index 000000000..67192b402
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MemBlocks.cpp
@@ -0,0 +1,183 @@
+// MemBlocks.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "MemBlocks.h"
+#include "StreamUtils.h"
+
+bool CMemBlockManager::AllocateSpace(size_t numBlocks)
+{
+ FreeSpace();
+ if (_blockSize < sizeof(void *) || numBlocks < 1)
+ return false;
+ size_t totalSize = numBlocks * _blockSize;
+ if (totalSize / _blockSize != numBlocks)
+ return false;
+ _data = ::MidAlloc(totalSize);
+ if (_data == 0)
+ return false;
+ Byte *p = (Byte *)_data;
+ for (size_t i = 0; i + 1 < numBlocks; i++, p += _blockSize)
+ *(Byte **)p = (p + _blockSize);
+ *(Byte **)p = 0;
+ _headFree = _data;
+ return true;
+}
+
+void CMemBlockManager::FreeSpace()
+{
+ ::MidFree(_data);
+ _data = 0;
+ _headFree= 0;
+}
+
+void *CMemBlockManager::AllocateBlock()
+{
+ if (_headFree == 0)
+ return 0;
+ void *p = _headFree;
+ _headFree = *(void **)_headFree;
+ return p;
+}
+
+void CMemBlockManager::FreeBlock(void *p)
+{
+ if (p == 0)
+ return;
+ *(void **)p = _headFree;
+ _headFree = p;
+}
+
+
+HRes CMemBlockManagerMt::AllocateSpace(NWindows::NSynchronization::CSynchro *sync,size_t numBlocks, size_t numNoLockBlocks)
+{
+ if (numNoLockBlocks > numBlocks)
+ return E_INVALIDARG;
+ if (!CMemBlockManager::AllocateSpace(numBlocks))
+ return E_OUTOFMEMORY;
+ size_t numLockBlocks = numBlocks - numNoLockBlocks;
+ Semaphore.Close();
+ return Semaphore.Create(sync,(LONG)numLockBlocks, (LONG)numLockBlocks);
+}
+
+HRes CMemBlockManagerMt::AllocateSpaceAlways(NWindows::NSynchronization::CSynchro *sync,size_t desiredNumberOfBlocks, size_t numNoLockBlocks)
+{
+ if (numNoLockBlocks > desiredNumberOfBlocks)
+ return E_INVALIDARG;
+ for (;;)
+ {
+ if (AllocateSpace(sync,desiredNumberOfBlocks, numNoLockBlocks) == 0)
+ return 0;
+ if (desiredNumberOfBlocks == numNoLockBlocks)
+ return E_OUTOFMEMORY;
+ desiredNumberOfBlocks = numNoLockBlocks + ((desiredNumberOfBlocks - numNoLockBlocks) >> 1);
+ }
+}
+
+void CMemBlockManagerMt::FreeSpace()
+{
+ Semaphore.Close();
+ CMemBlockManager::FreeSpace();
+}
+
+void *CMemBlockManagerMt::AllocateBlock()
+{
+ // Semaphore.Lock();
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ return CMemBlockManager::AllocateBlock();
+}
+
+void CMemBlockManagerMt::FreeBlock(void *p, bool lockMode)
+{
+ if (p == 0)
+ return;
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ CMemBlockManager::FreeBlock(p);
+ }
+ if (lockMode)
+ Semaphore.Release();
+}
+
+void CMemBlocks::Free(CMemBlockManagerMt *manager)
+{
+ while(Blocks.Size() > 0)
+ {
+ manager->FreeBlock(Blocks.Back());
+ Blocks.DeleteBack();
+ }
+ TotalSize = 0;
+}
+
+void CMemBlocks::FreeOpt(CMemBlockManagerMt *manager)
+{
+ Free(manager);
+ Blocks.ClearAndFree();
+}
+
+HRESULT CMemBlocks::WriteToStream(size_t blockSize, ISequentialOutStream *outStream) const
+{
+ UInt64 totalSize = TotalSize;
+ for (int blockIndex = 0; totalSize > 0; blockIndex++)
+ {
+ UInt32 curSize = (UInt32)blockSize;
+ if (totalSize < curSize)
+ curSize = (UInt32)totalSize;
+ if (blockIndex >= Blocks.Size())
+ return E_FAIL;
+ RINOK(WriteStream(outStream, Blocks[blockIndex], curSize));
+ totalSize -= curSize;
+ }
+ return S_OK;
+}
+
+
+void CMemLockBlocks::FreeBlock(int index, CMemBlockManagerMt *memManager)
+{
+ memManager->FreeBlock(Blocks[index], LockMode);
+ Blocks[index] = 0;
+}
+
+void CMemLockBlocks::Free(CMemBlockManagerMt *memManager)
+{
+ while (Blocks.Size() > 0)
+ {
+ FreeBlock(Blocks.Size() - 1, memManager);
+ Blocks.DeleteBack();
+ }
+ TotalSize = 0;
+}
+
+HRes CMemLockBlocks::SwitchToNoLockMode(CMemBlockManagerMt *memManager)
+{
+ if (LockMode)
+ {
+ if (Blocks.Size() > 0)
+ {
+ RINOK(memManager->ReleaseLockedBlocks(Blocks.Size()));
+ }
+ LockMode = false;
+ }
+ return 0;
+}
+
+void CMemLockBlocks::Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager)
+{
+ blocks.Free(memManager);
+ blocks.LockMode = LockMode;
+ UInt64 totalSize = 0;
+ size_t blockSize = memManager->GetBlockSize();
+ for (int i = 0; i < Blocks.Size(); i++)
+ {
+ if (totalSize < TotalSize)
+ blocks.Blocks.Add(Blocks[i]);
+ else
+ FreeBlock(i, memManager);
+ Blocks[i] = 0;
+ totalSize += blockSize;
+ }
+ blocks.TotalSize = TotalSize;
+ Free(memManager);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MemBlocks.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MemBlocks.h
new file mode 100644
index 000000000..f23852fbd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MemBlocks.h
@@ -0,0 +1,71 @@
+// MemBlocks.h
+
+#ifndef __MEM_BLOCKS_H
+#define __MEM_BLOCKS_H
+
+#include "Common/MyVector.h"
+
+#include "Windows/Synchronization.h"
+
+#include "../IStream.h"
+
+class CMemBlockManager
+{
+ void *_data;
+ size_t _blockSize;
+ void *_headFree;
+public:
+ CMemBlockManager(size_t blockSize = (1 << 20)): _data(0), _blockSize(blockSize), _headFree(0) {}
+ ~CMemBlockManager() { FreeSpace(); }
+
+ bool AllocateSpace(size_t numBlocks);
+ void FreeSpace();
+ size_t GetBlockSize() const { return _blockSize; }
+ void *AllocateBlock();
+ void FreeBlock(void *p);
+};
+
+
+class CMemBlockManagerMt: public CMemBlockManager
+{
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+public:
+ NWindows::NSynchronization::CSemaphoreWFMO Semaphore;
+
+ CMemBlockManagerMt(size_t blockSize = (1 << 20)): CMemBlockManager(blockSize) {}
+ ~CMemBlockManagerMt() { FreeSpace(); }
+
+ HRes AllocateSpace(NWindows::NSynchronization::CSynchro *sync, size_t numBlocks, size_t numNoLockBlocks = 0);
+ HRes AllocateSpaceAlways(NWindows::NSynchronization::CSynchro *sync, size_t desiredNumberOfBlocks, size_t numNoLockBlocks = 0);
+ void FreeSpace();
+ void *AllocateBlock();
+ void FreeBlock(void *p, bool lockMode = true);
+ HRes ReleaseLockedBlocks(int number) { return Semaphore.Release(number); }
+};
+
+
+class CMemBlocks
+{
+ void Free(CMemBlockManagerMt *manager);
+public:
+ CRecordVector<void *> Blocks;
+ UInt64 TotalSize;
+
+ CMemBlocks(): TotalSize(0) {}
+
+ void FreeOpt(CMemBlockManagerMt *manager);
+ HRESULT WriteToStream(size_t blockSize, ISequentialOutStream *outStream) const;
+};
+
+struct CMemLockBlocks: public CMemBlocks
+{
+ bool LockMode;
+
+ CMemLockBlocks(): LockMode(true) {};
+ void Free(CMemBlockManagerMt *memManager);
+ void FreeBlock(int index, CMemBlockManagerMt *memManager);
+ HRes SwitchToNoLockMode(CMemBlockManagerMt *memManager);
+ void Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodId.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodId.cpp
new file mode 100644
index 000000000..b797b6857
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodId.cpp
@@ -0,0 +1,27 @@
+// MethodId.cpp
+
+#include "StdAfx.h"
+
+#include "MethodId.h"
+#include "../../Common/MyString.h"
+
+static inline wchar_t GetHex(Byte value)
+{
+ return (wchar_t)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
+}
+
+UString ConvertMethodIdToString(UInt64 id)
+{
+ wchar_t s[32];
+ int len = 32;
+ s[--len] = 0;
+ do
+ {
+ s[--len] = GetHex((Byte)id & 0xF);
+ id >>= 4;
+ s[--len] = GetHex((Byte)id & 0xF);
+ id >>= 4;
+ }
+ while (id != 0);
+ return s + len;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodId.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodId.h
new file mode 100644
index 000000000..54ebc9f7d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodId.h
@@ -0,0 +1,10 @@
+// MethodId.h
+
+#ifndef __7Z_METHOD_ID_H
+#define __7Z_METHOD_ID_H
+
+#include "../../Common/Types.h"
+
+typedef UInt64 CMethodId;
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodProps.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodProps.cpp
new file mode 100644
index 000000000..5836d0f84
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodProps.cpp
@@ -0,0 +1,99 @@
+// MethodProps.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "MethodProps.h"
+
+static const UInt64 k_LZMA = 0x030101;
+static const UInt64 k_LZMA2 = 0x21;
+
+HRESULT SetMethodProperties(const CMethod &method, const UInt64 *inSizeForReduce, IUnknown *coder)
+{
+ bool tryReduce = false;
+ UInt32 reducedDictionarySize = 1 << 10;
+ if (inSizeForReduce != 0 && (method.Id == k_LZMA || method.Id == k_LZMA2))
+ {
+ for (;;)
+ {
+ const UInt32 step = (reducedDictionarySize >> 1);
+ if (reducedDictionarySize >= *inSizeForReduce)
+ {
+ tryReduce = true;
+ break;
+ }
+ reducedDictionarySize += step;
+ if (reducedDictionarySize >= *inSizeForReduce)
+ {
+ tryReduce = true;
+ break;
+ }
+ if (reducedDictionarySize >= ((UInt32)3 << 30))
+ break;
+ reducedDictionarySize += step;
+ }
+ }
+
+ {
+ int numProps = method.Props.Size();
+ CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
+ coder->QueryInterface(IID_ICompressSetCoderProperties, (void **)&setCoderProperties);
+ if (setCoderProperties == NULL)
+ {
+ if (numProps != 0)
+ return E_INVALIDARG;
+ }
+ else
+ {
+ CRecordVector<PROPID> propIDs;
+ NWindows::NCOM::CPropVariant *values = new NWindows::NCOM::CPropVariant[numProps];
+ HRESULT res = S_OK;
+ try
+ {
+ for (int i = 0; i < numProps; i++)
+ {
+ const CProp &prop = method.Props[i];
+ propIDs.Add(prop.Id);
+ NWindows::NCOM::CPropVariant &value = values[i];
+ value = prop.Value;
+ // if (tryReduce && prop.Id == NCoderPropID::kDictionarySize && value.vt == VT_UI4 && reducedDictionarySize < value.ulVal)
+ if (tryReduce)
+ if (prop.Id == NCoderPropID::kDictionarySize)
+ if (value.vt == VT_UI4)
+ if (reducedDictionarySize < value.ulVal)
+ value.ulVal = reducedDictionarySize;
+ }
+ CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
+ coder->QueryInterface(IID_ICompressSetCoderProperties, (void **)&setCoderProperties);
+ res = setCoderProperties->SetCoderProperties(&propIDs.Front(), values, numProps);
+ }
+ catch(...)
+ {
+ delete []values;
+ throw;
+ }
+ delete []values;
+ RINOK(res);
+ }
+ }
+
+ /*
+ CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
+ coder->QueryInterface(IID_ICompressWriteCoderProperties, (void **)&writeCoderProperties);
+ if (writeCoderProperties != NULL)
+ {
+ CSequentialOutStreamImp *outStreamSpec = new CSequentialOutStreamImp;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->Init();
+ RINOK(writeCoderProperties->WriteCoderProperties(outStream));
+ size_t size = outStreamSpec->GetSize();
+ filterProps.SetCapacity(size);
+ memmove(filterProps, outStreamSpec->GetBuffer(), size);
+ }
+ */
+ return S_OK;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodProps.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodProps.h
new file mode 100644
index 000000000..c0761c519
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/MethodProps.h
@@ -0,0 +1,41 @@
+// MethodProps.h
+
+#ifndef __7Z_METHOD_PROPS_H
+#define __7Z_METHOD_PROPS_H
+
+#include "../../Common/MyVector.h"
+
+#include "../../Windows/PropVariant.h"
+
+#include "MethodId.h"
+
+struct CProp
+{
+ PROPID Id;
+ NWindows::NCOM::CPropVariant Value;
+};
+
+struct CMethod
+{
+ CMethodId Id;
+ CObjectVector<CProp> Props;
+};
+
+struct CMethodsMode
+{
+ CObjectVector<CMethod> Methods;
+ #ifdef COMPRESS_MT
+ UInt32 NumThreads;
+ #endif
+
+ CMethodsMode()
+ #ifdef COMPRESS_MT
+ : NumThreads(1)
+ #endif
+ {}
+ bool IsEmpty() const { return Methods.IsEmpty() ; }
+};
+
+HRESULT SetMethodProperties(const CMethod &method, const UInt64 *inSizeForReduce, IUnknown *coder);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OffsetStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OffsetStream.cpp
new file mode 100644
index 000000000..24fcf1619
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OffsetStream.cpp
@@ -0,0 +1,35 @@
+// OffsetStream.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Defs.h"
+#include "OffsetStream.h"
+
+HRESULT COffsetOutStream::Init(IOutStream *stream, UInt64 offset)
+{
+ _offset = offset;
+ _stream = stream;
+ return _stream->Seek(offset, STREAM_SEEK_SET, NULL);
+}
+
+STDMETHODIMP COffsetOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ return _stream->Write(data, size, processedSize);
+}
+
+STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin,
+ UInt64 *newPosition)
+{
+ UInt64 absoluteNewPosition;
+ if (seekOrigin == STREAM_SEEK_SET)
+ offset += _offset;
+ HRESULT result = _stream->Seek(offset, seekOrigin, &absoluteNewPosition);
+ if (newPosition != NULL)
+ *newPosition = absoluteNewPosition - _offset;
+ return result;
+}
+
+STDMETHODIMP COffsetOutStream::SetSize(Int64 newSize)
+{
+ return _stream->SetSize(_offset + newSize);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OffsetStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OffsetStream.h
new file mode 100644
index 000000000..5a69404f6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OffsetStream.h
@@ -0,0 +1,25 @@
+// OffsetStream.h
+
+#ifndef __OFFSETSTREAM_H
+#define __OFFSETSTREAM_H
+
+#include "Common/MyCom.h"
+#include "../IStream.h"
+
+class COffsetOutStream:
+ public IOutStream,
+ public CMyUnknownImp
+{
+ UInt64 _offset;
+ CMyComPtr<IOutStream> _stream;
+public:
+ HRESULT Init(IOutStream *stream, UInt64 offset);
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+ STDMETHOD(SetSize)(Int64 newSize);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutBuffer.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutBuffer.cpp
new file mode 100644
index 000000000..2e5debd83
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutBuffer.cpp
@@ -0,0 +1,116 @@
+// OutBuffer.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "OutBuffer.h"
+
+bool COutBuffer::Create(UInt32 bufferSize)
+{
+ const UInt32 kMinBlockSize = 1;
+ if (bufferSize < kMinBlockSize)
+ bufferSize = kMinBlockSize;
+ if (_buffer != 0 && _bufferSize == bufferSize)
+ return true;
+ Free();
+ _bufferSize = bufferSize;
+ _buffer = (Byte *)::MidAlloc(bufferSize);
+ return (_buffer != 0);
+}
+
+void COutBuffer::Free()
+{
+ ::MidFree(_buffer);
+ _buffer = 0;
+}
+
+void COutBuffer::SetStream(ISequentialOutStream *stream)
+{
+ _stream = stream;
+}
+
+void COutBuffer::Init()
+{
+ _streamPos = 0;
+ _limitPos = _bufferSize;
+ _pos = 0;
+ _processedSize = 0;
+ _overDict = false;
+ #ifdef _NO_EXCEPTIONS
+ ErrorCode = S_OK;
+ #endif
+}
+
+UInt64 COutBuffer::GetProcessedSize() const
+{
+ UInt64 res = _processedSize + _pos - _streamPos;
+ if (_streamPos > _pos)
+ res += _bufferSize;
+ return res;
+}
+
+
+HRESULT COutBuffer::FlushPart()
+{
+ // _streamPos < _bufferSize
+ UInt32 size = (_streamPos >= _pos) ? (_bufferSize - _streamPos) : (_pos - _streamPos);
+ HRESULT result = S_OK;
+ #ifdef _NO_EXCEPTIONS
+ result = ErrorCode;
+ #endif
+ if (_buffer2 != 0)
+ {
+ memmove(_buffer2, _buffer + _streamPos, size);
+ _buffer2 += size;
+ }
+
+ if (_stream != 0
+ #ifdef _NO_EXCEPTIONS
+ && (ErrorCode == S_OK)
+ #endif
+ )
+ {
+ UInt32 processedSize = 0;
+ result = _stream->Write(_buffer + _streamPos, size, &processedSize);
+ size = processedSize;
+ }
+ _streamPos += size;
+ if (_streamPos == _bufferSize)
+ _streamPos = 0;
+ if (_pos == _bufferSize)
+ {
+ _overDict = true;
+ _pos = 0;
+ }
+ _limitPos = (_streamPos > _pos) ? _streamPos : _bufferSize;
+ _processedSize += size;
+ return result;
+}
+
+HRESULT COutBuffer::Flush()
+{
+ #ifdef _NO_EXCEPTIONS
+ if (ErrorCode != S_OK)
+ return ErrorCode;
+ #endif
+
+ while(_streamPos != _pos)
+ {
+ HRESULT result = FlushPart();
+ if (result != S_OK)
+ return result;
+ }
+ return S_OK;
+}
+
+void COutBuffer::FlushWithCheck()
+{
+ HRESULT result = Flush();
+ #ifdef _NO_EXCEPTIONS
+ ErrorCode = result;
+ #else
+ if (result != S_OK)
+ throw COutBufferException(result);
+ #endif
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutBuffer.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutBuffer.h
new file mode 100644
index 000000000..62e77caae
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutBuffer.h
@@ -0,0 +1,64 @@
+// OutBuffer.h
+
+#ifndef __OUTBUFFER_H
+#define __OUTBUFFER_H
+
+#include "../IStream.h"
+#include "../../Common/MyCom.h"
+#include "../../Common/MyException.h"
+
+#ifndef _NO_EXCEPTIONS
+struct COutBufferException: public CSystemException
+{
+ COutBufferException(HRESULT errorCode): CSystemException(errorCode) {}
+};
+#endif
+
+class COutBuffer
+{
+protected:
+ Byte *_buffer;
+ UInt32 _pos;
+ UInt32 _limitPos;
+ UInt32 _streamPos;
+ UInt32 _bufferSize;
+ CMyComPtr<ISequentialOutStream> _stream;
+ UInt64 _processedSize;
+ Byte *_buffer2;
+ bool _overDict;
+
+ HRESULT FlushPart();
+public:
+ #ifdef _NO_EXCEPTIONS
+ HRESULT ErrorCode;
+ #endif
+
+ COutBuffer(): _buffer(0), _pos(0), _stream(0), _buffer2(0) {}
+ ~COutBuffer() { Free(); }
+
+ bool Create(UInt32 bufferSize);
+ void Free();
+
+ void SetMemStream(Byte *buffer) { _buffer2 = buffer; }
+ void SetStream(ISequentialOutStream *stream);
+ void Init();
+ HRESULT Flush();
+ void FlushWithCheck();
+ void ReleaseStream() { _stream.Release(); }
+
+ void WriteByte(Byte b)
+ {
+ _buffer[_pos++] = b;
+ if(_pos == _limitPos)
+ FlushWithCheck();
+ }
+ void WriteBytes(const void *data, size_t size)
+ {
+ for (size_t i = 0; i < size; i++)
+ WriteByte(((const Byte *)data)[i]);
+ }
+
+ UInt64 GetProcessedSize() const;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutMemStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutMemStream.cpp
new file mode 100644
index 000000000..ddc314864
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutMemStream.cpp
@@ -0,0 +1,142 @@
+// OutMemStream.cpp
+
+#include "StdAfx.h"
+
+#include "OutMemStream.h"
+
+void COutMemStream::Free()
+{
+ Blocks.Free(_memManager);
+ Blocks.LockMode = true;
+}
+
+void COutMemStream::Init()
+{
+ WriteToRealStreamEvent.Reset();
+ _unlockEventWasSent = false;
+ _realStreamMode = false;
+ Free();
+ _curBlockPos = 0;
+ _curBlockIndex = 0;
+}
+
+void COutMemStream::DetachData(CMemLockBlocks &blocks)
+{
+ Blocks.Detach(blocks, _memManager);
+ Free();
+}
+
+
+HRESULT COutMemStream::WriteToRealStream()
+{
+ RINOK(Blocks.WriteToStream(_memManager->GetBlockSize(), OutSeqStream));
+ Blocks.Free(_memManager);
+ return S_OK;
+}
+
+STDMETHODIMP COutMemStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (_realStreamMode)
+ return OutSeqStream->Write(data, size, processedSize);
+ if (processedSize != 0)
+ *processedSize = 0;
+ while(size != 0)
+ {
+ if ((int)_curBlockIndex < Blocks.Blocks.Size())
+ {
+ Byte *p = (Byte *)Blocks.Blocks[(int)_curBlockIndex] + _curBlockPos;
+ size_t curSize = _memManager->GetBlockSize() - _curBlockPos;
+ if (size < curSize)
+ curSize = size;
+ memmove(p, data, curSize);
+ if (processedSize != 0)
+ *processedSize += (UInt32)curSize;
+ data = (const void *)((const Byte *)data + curSize);
+ size -= (UInt32)curSize;
+ _curBlockPos += curSize;
+
+ UInt64 pos64 = GetPos();
+ if (pos64 > Blocks.TotalSize)
+ Blocks.TotalSize = pos64;
+ if (_curBlockPos == _memManager->GetBlockSize())
+ {
+ _curBlockIndex++;
+ _curBlockPos = 0;
+ }
+ continue;
+ }
+ HANDLE events[3] = { StopWritingEvent, WriteToRealStreamEvent, /* NoLockEvent, */ _memManager->Semaphore };
+ DWORD waitResult = ::WaitForMultipleObjects((Blocks.LockMode ? 3 : 2), events, FALSE, INFINITE);
+ switch (waitResult)
+ {
+ case (WAIT_OBJECT_0 + 0):
+ return StopWriteResult;
+ case (WAIT_OBJECT_0 + 1):
+ {
+ _realStreamMode = true;
+ RINOK(WriteToRealStream());
+ UInt32 processedSize2;
+ HRESULT res = OutSeqStream->Write(data, size, &processedSize2);
+ if (processedSize != 0)
+ *processedSize += processedSize2;
+ return res;
+ }
+ /*
+ case (WAIT_OBJECT_0 + 2):
+ {
+ // it has bug: no write.
+ if (!Blocks.SwitchToNoLockMode(_memManager))
+ return E_FAIL;
+ break;
+ }
+ */
+ case (WAIT_OBJECT_0 + 2):
+ break;
+ default:
+ return E_FAIL;
+ }
+ Blocks.Blocks.Add(_memManager->AllocateBlock());
+ if (Blocks.Blocks.Back() == 0)
+ return E_FAIL;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP COutMemStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ if (_realStreamMode)
+ {
+ if (!OutStream)
+ return E_FAIL;
+ return OutStream->Seek(offset, seekOrigin, newPosition);
+ }
+ if (seekOrigin == STREAM_SEEK_CUR)
+ {
+ if (offset != 0)
+ return E_NOTIMPL;
+ }
+ else if (seekOrigin == STREAM_SEEK_SET)
+ {
+ if (offset != 0)
+ return E_NOTIMPL;
+ _curBlockIndex = 0;
+ _curBlockPos = 0;
+ }
+ else
+ return E_NOTIMPL;
+ if (newPosition != 0)
+ *newPosition = GetPos();
+ return S_OK;
+}
+
+STDMETHODIMP COutMemStream::SetSize(Int64 newSize)
+{
+ if (_realStreamMode)
+ {
+ if (!OutStream)
+ return E_FAIL;
+ return OutStream->SetSize(newSize);
+ }
+ Blocks.TotalSize = newSize;
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutMemStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutMemStream.h
new file mode 100644
index 000000000..4f917976e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/OutMemStream.h
@@ -0,0 +1,96 @@
+// OutMemStream.h
+
+#ifndef __OUTMEMSTREAM_H
+#define __OUTMEMSTREAM_H
+
+#include "Common/MyCom.h"
+#include "MemBlocks.h"
+
+class COutMemStream:
+ public IOutStream,
+ public CMyUnknownImp
+{
+ CMemBlockManagerMt *_memManager;
+ size_t _curBlockIndex;
+ size_t _curBlockPos;
+ bool _realStreamMode;
+
+ bool _unlockEventWasSent;
+ NWindows::NSynchronization::CAutoResetEventWFMO StopWritingEvent;
+ NWindows::NSynchronization::CAutoResetEventWFMO WriteToRealStreamEvent;
+ // NWindows::NSynchronization::CAutoResetEvent NoLockEvent;
+
+ HRESULT StopWriteResult;
+ CMemLockBlocks Blocks;
+
+ UInt64 GetPos() const { return (UInt64)_curBlockIndex * _memManager->GetBlockSize() + _curBlockPos; }
+
+ CMyComPtr<ISequentialOutStream> OutSeqStream;
+ CMyComPtr<IOutStream> OutStream;
+
+public:
+
+ HRes CreateEvents(NWindows::NSynchronization::CSynchro *sync)
+ {
+ RINOK(StopWritingEvent.CreateIfNotCreated(sync));
+ return WriteToRealStreamEvent.CreateIfNotCreated(sync);
+ }
+
+ void SetOutStream(IOutStream *outStream)
+ {
+ OutStream = outStream;
+ OutSeqStream = outStream;
+ }
+
+ void SetSeqOutStream(ISequentialOutStream *outStream)
+ {
+ OutStream = NULL;
+ OutSeqStream = outStream;
+ }
+
+ void ReleaseOutStream()
+ {
+ OutStream.Release();
+ OutSeqStream.Release();
+ }
+
+ COutMemStream(CMemBlockManagerMt *memManager): _memManager(memManager) { }
+
+ ~COutMemStream() { Free(); }
+ void Free();
+
+ void Init();
+ HRESULT WriteToRealStream();
+
+ void DetachData(CMemLockBlocks &blocks);
+
+ bool WasUnlockEventSent() const { return _unlockEventWasSent; }
+
+ void SetRealStreamMode()
+ {
+ _unlockEventWasSent = true;
+ WriteToRealStreamEvent.Set();
+ }
+
+ /*
+ void SetNoLockMode()
+ {
+ _unlockEventWasSent = true;
+ NoLockEvent.Set();
+ }
+ */
+
+ void StopWriting(HRESULT res)
+ {
+ StopWriteResult = res;
+ StopWritingEvent.Set();
+ }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+ STDMETHOD(SetSize)(Int64 newSize);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressMt.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressMt.cpp
new file mode 100644
index 000000000..319bd241b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressMt.cpp
@@ -0,0 +1,53 @@
+// ProgressMt.h
+
+#include "StdAfx.h"
+
+#include "ProgressMt.h"
+
+void CMtCompressProgressMixer::Init(int numItems, ICompressProgressInfo *progress)
+{
+ NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
+ InSizes.Clear();
+ OutSizes.Clear();
+ for (int i = 0; i < numItems; i++)
+ {
+ InSizes.Add(0);
+ OutSizes.Add(0);
+ }
+ TotalInSize = 0;
+ TotalOutSize = 0;
+ _progress = progress;
+}
+
+void CMtCompressProgressMixer::Reinit(int index)
+{
+ NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
+ InSizes[index] = 0;
+ OutSizes[index] = 0;
+}
+
+HRESULT CMtCompressProgressMixer::SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize)
+{
+ NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
+ if (inSize != 0)
+ {
+ UInt64 diff = *inSize - InSizes[index];
+ InSizes[index] = *inSize;
+ TotalInSize += diff;
+ }
+ if (outSize != 0)
+ {
+ UInt64 diff = *outSize - OutSizes[index];
+ OutSizes[index] = *outSize;
+ TotalOutSize += diff;
+ }
+ if (_progress)
+ return _progress->SetRatioInfo(&TotalInSize, &TotalOutSize);
+ return S_OK;
+}
+
+
+STDMETHODIMP CMtCompressProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ return _progress->SetRatioInfo(_index, inSize, outSize);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressMt.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressMt.h
new file mode 100644
index 000000000..26079d4e9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressMt.h
@@ -0,0 +1,46 @@
+// ProgressMt.h
+
+#ifndef __PROGRESSMT_H
+#define __PROGRESSMT_H
+
+#include "../../Common/MyCom.h"
+#include "../../Common/MyVector.h"
+#include "../../Windows/Synchronization.h"
+
+#include "../ICoder.h"
+#include "../IProgress.h"
+
+class CMtCompressProgressMixer
+{
+ CMyComPtr<ICompressProgressInfo> _progress;
+ CRecordVector<UInt64> InSizes;
+ CRecordVector<UInt64> OutSizes;
+ UInt64 TotalInSize;
+ UInt64 TotalOutSize;
+public:
+ NWindows::NSynchronization::CCriticalSection CriticalSection;
+ void Init(int numItems, ICompressProgressInfo *progress);
+ void Reinit(int index);
+ HRESULT SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize);
+};
+
+class CMtCompressProgress:
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+ CMtCompressProgressMixer *_progress;
+ int _index;
+public:
+ void Init(CMtCompressProgressMixer *progress, int index)
+ {
+ _progress = progress;
+ _index = index;
+ }
+ void Reinit() { _progress->Reinit(_index); }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressUtils.cpp
new file mode 100644
index 000000000..f24ff6b6f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressUtils.cpp
@@ -0,0 +1,42 @@
+// ProgressUtils.h
+
+#include "StdAfx.h"
+
+#include "ProgressUtils.h"
+
+CLocalProgress::CLocalProgress()
+{
+ ProgressOffset = InSize = OutSize = 0;
+ SendRatio = SendProgress = true;
+}
+
+void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain)
+{
+ _ratioProgress.Release();
+ _progress = progress;
+ _progress.QueryInterface(IID_ICompressProgressInfo, &_ratioProgress);
+ _inSizeIsMain = inSizeIsMain;
+}
+
+STDMETHODIMP CLocalProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ UInt64 inSizeNew = InSize, outSizeNew = OutSize;
+ if (inSize)
+ inSizeNew += (*inSize);
+ if (outSize)
+ outSizeNew += (*outSize);
+ if (SendRatio && _ratioProgress)
+ {
+ RINOK(_ratioProgress->SetRatioInfo(&inSizeNew, &outSizeNew));
+ }
+ inSizeNew += ProgressOffset;
+ outSizeNew += ProgressOffset;
+ if (SendProgress)
+ return _progress->SetCompleted(_inSizeIsMain ? &inSizeNew : &outSizeNew);
+ return S_OK;
+}
+
+HRESULT CLocalProgress::SetCur()
+{
+ return SetRatioInfo(NULL, NULL);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressUtils.h
new file mode 100644
index 000000000..bae5395c1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/ProgressUtils.h
@@ -0,0 +1,34 @@
+// ProgressUtils.h
+
+#ifndef __PROGRESSUTILS_H
+#define __PROGRESSUTILS_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+#include "../IProgress.h"
+
+class CLocalProgress:
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+ CMyComPtr<IProgress> _progress;
+ CMyComPtr<ICompressProgressInfo> _ratioProgress;
+ bool _inSizeIsMain;
+public:
+ UInt64 ProgressOffset;
+ UInt64 InSize;
+ UInt64 OutSize;
+ bool SendRatio;
+ bool SendProgress;
+
+ CLocalProgress();
+ void Init(IProgress *progress, bool inSizeIsMain);
+ HRESULT SetCur();
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/RegisterArc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/RegisterArc.h
new file mode 100644
index 000000000..cd84e469c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/RegisterArc.h
@@ -0,0 +1,38 @@
+// RegisterArc.h
+
+#ifndef __REGISTERARC_H
+#define __REGISTERARC_H
+
+#include "../Archive/IArchive.h"
+
+typedef IInArchive * (*CreateInArchiveP)();
+typedef IOutArchive * (*CreateOutArchiveP)();
+
+struct CArcInfo
+{
+ const wchar_t *Name;
+ const wchar_t *Ext;
+ const wchar_t *AddExt;
+ Byte ClassId;
+ Byte Signature[16];
+ int SignatureSize;
+ bool KeepName;
+ CreateInArchiveP CreateInArchive;
+ CreateOutArchiveP CreateOutArchive;
+};
+
+void RegisterArc(const CArcInfo *arcInfo);
+
+#define REGISTER_ARC_NAME(x) CRegister ## x
+
+#define REGISTER_ARC_DEC_SIG(x) struct REGISTER_ARC_NAME(x) { \
+ REGISTER_ARC_NAME(x)() { g_ArcInfo.Signature[0]--; RegisterArc(&g_ArcInfo); }}; \
+ static REGISTER_ARC_NAME(x) g_RegisterArc; \
+ void registerArc ## x() { static REGISTER_ARC_NAME(x) g_RegisterArc; }
+
+#define REGISTER_ARC(x) struct REGISTER_ARC_NAME(x) { \
+ REGISTER_ARC_NAME(x)() { RegisterArc(&g_ArcInfo); }}; \
+ static REGISTER_ARC_NAME(x) g_RegisterArc; \
+ void registerArc##x() { static REGISTER_ARC_NAME(x) g_RegisterArc; }
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/RegisterCodec.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/RegisterCodec.h
new file mode 100644
index 000000000..6d300749c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/RegisterCodec.h
@@ -0,0 +1,35 @@
+// RegisterCodec.h
+
+#ifndef __REGISTERCODEC_H
+#define __REGISTERCODEC_H
+
+#include "../Common/MethodId.h"
+
+typedef void * (*CreateCodecP)();
+struct CCodecInfo
+{
+ CreateCodecP CreateDecoder;
+ CreateCodecP CreateEncoder;
+ CMethodId Id;
+ const wchar_t *Name;
+ UInt32 NumInStreams;
+ bool IsFilter;
+};
+
+void RegisterCodec(const CCodecInfo *codecInfo);
+
+#define REGISTER_CODEC_NAME(x) CRegisterCodec ## x
+
+#define REGISTER_CODEC(x) struct REGISTER_CODEC_NAME(x) { \
+ REGISTER_CODEC_NAME(x)() { RegisterCodec(&g_CodecInfo); }}; \
+ static REGISTER_CODEC_NAME(x) g_RegisterCodec; \
+ void registerCodec##x() { static REGISTER_CODEC_NAME(x) g_RegisterCodecs; }
+
+#define REGISTER_CODECS_NAME(x) CRegisterCodecs ## x
+#define REGISTER_CODECS(x) struct REGISTER_CODECS_NAME(x) { \
+ REGISTER_CODECS_NAME(x)() { for (size_t i = 0; i < sizeof(g_CodecsInfo) / sizeof(g_CodecsInfo[0]); i++) \
+ RegisterCodec(&g_CodecsInfo[i]); }}; \
+ static REGISTER_CODECS_NAME(x) g_RegisterCodecs; \
+ void registerCodec##x() { static REGISTER_CODECS_NAME(x) g_RegisterCodecs; }
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamBinder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamBinder.cpp
new file mode 100644
index 000000000..4ad3011e3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamBinder.cpp
@@ -0,0 +1,161 @@
+// StreamBinder.cpp
+
+#include "StdAfx.h"
+
+#include "StreamBinder.h"
+#include "../../Common/Defs.h"
+#include "../../Common/MyCom.h"
+
+#include <cstdio>
+
+using namespace NWindows;
+using namespace NSynchronization;
+
+class CSequentialInStreamForBinder:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+private:
+ CStreamBinder *m_StreamBinder;
+public:
+ ~CSequentialInStreamForBinder() { m_StreamBinder->CloseRead(); }
+ void SetBinder(CStreamBinder *streamBinder) { m_StreamBinder = streamBinder; }
+};
+
+STDMETHODIMP CSequentialInStreamForBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
+ { return m_StreamBinder->Read(data, size, processedSize); }
+
+class CSequentialOutStreamForBinder:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+
+private:
+ CStreamBinder *m_StreamBinder;
+public:
+ ~CSequentialOutStreamForBinder() { m_StreamBinder->CloseWrite(); }
+ void SetBinder(CStreamBinder *streamBinder) { m_StreamBinder = streamBinder; }
+};
+
+STDMETHODIMP CSequentialOutStreamForBinder::Write(const void *data, UInt32 size, UInt32 *processedSize)
+ { return m_StreamBinder->Write(data, size, processedSize); }
+
+
+//////////////////////////
+// CStreamBinder
+// (_thereAreBytesToReadEvent && _bufferSize == 0) means that stream is finished.
+
+HRes CStreamBinder::CreateEvents()
+{
+#ifdef _WIN32
+ RINOK(_allBytesAreWritenEvent.Create(true));
+ RINOK(_thereAreBytesToReadEvent.Create());
+ return _readStreamIsClosedEvent.Create();
+#else
+ _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent = new NWindows::NSynchronization::CSynchro();
+ _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent->Create();
+ RINOK(_allBytesAreWritenEvent.Create(_synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent,true));
+ RINOK(_thereAreBytesToReadEvent.Create());
+ return _readStreamIsClosedEvent.Create(_synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent);
+#endif
+}
+
+void CStreamBinder::ReInit()
+{
+ _thereAreBytesToReadEvent.Reset();
+ _readStreamIsClosedEvent.Reset();
+ ProcessedSize = 0;
+}
+
+
+
+void CStreamBinder::CreateStreams(ISequentialInStream **inStream,
+ ISequentialOutStream **outStream)
+{
+ CSequentialInStreamForBinder *inStreamSpec = new
+ CSequentialInStreamForBinder;
+ CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
+ inStreamSpec->SetBinder(this);
+ *inStream = inStreamLoc.Detach();
+
+ CSequentialOutStreamForBinder *outStreamSpec = new
+ CSequentialOutStreamForBinder;
+ CMyComPtr<ISequentialOutStream> outStreamLoc(outStreamSpec);
+ outStreamSpec->SetBinder(this);
+ *outStream = outStreamLoc.Detach();
+
+ _buffer = NULL;
+ _bufferSize= 0;
+ ProcessedSize = 0;
+}
+
+HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 sizeToRead = size;
+ if (size > 0)
+ {
+ RINOK(_thereAreBytesToReadEvent.Lock());
+ sizeToRead = MyMin(_bufferSize, size);
+ if (_bufferSize > 0)
+ {
+ memcpy(data, _buffer, sizeToRead);
+ _buffer = ((const Byte *)_buffer) + sizeToRead;
+ _bufferSize -= sizeToRead;
+ if (_bufferSize == 0)
+ {
+ _thereAreBytesToReadEvent.Reset();
+ _allBytesAreWritenEvent.Set();
+ }
+ }
+ }
+ if (processedSize != NULL)
+ *processedSize = sizeToRead;
+ ProcessedSize += sizeToRead;
+ return S_OK;
+}
+
+void CStreamBinder::CloseRead()
+{
+ _readStreamIsClosedEvent.Set();
+}
+
+HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (size > 0)
+ {
+ _buffer = data;
+ _bufferSize = size;
+ _allBytesAreWritenEvent.Reset();
+ _thereAreBytesToReadEvent.Set();
+
+ HANDLE events[2];
+ events[0] = _allBytesAreWritenEvent;
+ events[1] = _readStreamIsClosedEvent;
+ DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
+ if (waitResult != WAIT_OBJECT_0 + 0)
+ {
+ // ReadingWasClosed = true;
+ printf("Error: WaitForMultipleObjects in CStreamBinder::Write failed\n");
+ return S_FALSE;
+ }
+ // if(!_allBytesAreWritenEvent.Lock())
+ // return E_FAIL;
+ }
+ if (processedSize != NULL)
+ *processedSize = size;
+ return S_OK;
+}
+
+void CStreamBinder::CloseWrite()
+{
+ // _bufferSize must be = 0
+ _thereAreBytesToReadEvent.Set();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamBinder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamBinder.h
new file mode 100644
index 000000000..1cd45a451
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamBinder.h
@@ -0,0 +1,48 @@
+// StreamBinder.h
+
+#ifndef __STREAMBINDER_H
+#define __STREAMBINDER_H
+
+#include "../IStream.h"
+#include "../../Windows/Synchronization.h"
+
+class CStreamBinder
+{
+#ifdef _WIN32
+ NWindows::NSynchronization::CManualResetEvent _allBytesAreWritenEvent;
+ NWindows::NSynchronization::CManualResetEvent _thereAreBytesToReadEvent;
+ NWindows::NSynchronization::CManualResetEvent _readStreamIsClosedEvent;
+#else
+ NWindows::NSynchronization::CManualResetEventWFMO _allBytesAreWritenEvent;
+ NWindows::NSynchronization::CManualResetEvent _thereAreBytesToReadEvent;
+ NWindows::NSynchronization::CManualResetEventWFMO _readStreamIsClosedEvent;
+ NWindows::NSynchronization::CSynchro * _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent;
+#endif
+ UInt32 _bufferSize;
+ const void *_buffer;
+public:
+ // bool ReadingWasClosed;
+ UInt64 ProcessedSize;
+
+#ifndef _WIN32
+ CStreamBinder() { _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent = 0; }
+ ~CStreamBinder() {
+ if (_synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent)
+ delete _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent;
+ _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent = 0;
+ }
+#endif
+
+ HRes CreateEvents();
+
+ void CreateStreams(ISequentialInStream **inStream,
+ ISequentialOutStream **outStream);
+ HRESULT Read(void *data, UInt32 size, UInt32 *processedSize);
+ void CloseRead();
+
+ HRESULT Write(const void *data, UInt32 size, UInt32 *processedSize);
+ void CloseWrite();
+ void ReInit();
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamObjects.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamObjects.cpp
new file mode 100644
index 000000000..e043e5652
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamObjects.cpp
@@ -0,0 +1,68 @@
+// StreamObjects.cpp
+
+#include "StdAfx.h"
+
+#include "StreamObjects.h"
+#include "../../Common/Defs.h"
+
+
+STDMETHODIMP CSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ size_t rem = _size - _pos;
+ if (size < rem)
+ rem = (size_t)size;
+ memcpy(data, _dataPointer + _pos, rem);
+ _pos += rem;
+ if (processedSize != NULL)
+ *processedSize = (UInt32)rem;
+ return S_OK;
+}
+
+
+void CWriteBuffer::Write(const void *data, size_t size)
+{
+ size_t newCapacity = _size + size;
+ _buffer.EnsureCapacity(newCapacity);
+ memcpy(_buffer + _size, data, size);
+ _size += size;
+}
+
+STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ _writeBuffer.Write(data, (size_t)size);
+ if(processedSize != NULL)
+ *processedSize = size;
+ return S_OK;
+}
+
+STDMETHODIMP CSequentialOutStreamImp2::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ size_t rem = _size - _pos;
+ if (size < rem)
+ rem = (size_t)size;
+ memcpy(_buffer + _pos, data, rem);
+ _pos += rem;
+ if (processedSize != NULL)
+ *processedSize = (UInt32)rem;
+ return (rem == size ? S_OK : E_FAIL);
+}
+
+STDMETHODIMP CSequentialInStreamSizeCount::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize;
+ HRESULT result = _stream->Read(data, size, &realProcessedSize);
+ _size += realProcessedSize;
+ if (processedSize != 0)
+ *processedSize = realProcessedSize;
+ return result;
+}
+
+STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 realProcessedSize;
+ HRESULT result = _stream->Write(data, size, &realProcessedSize);
+ _size += realProcessedSize;
+ if (processedSize != 0)
+ *processedSize = realProcessedSize;
+ return result;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamObjects.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamObjects.h
new file mode 100644
index 000000000..a21089cbb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamObjects.h
@@ -0,0 +1,117 @@
+// StreamObjects.h
+
+#ifndef __STREAMOBJECTS_H
+#define __STREAMOBJECTS_H
+
+#include "../../Common/DynamicBuffer.h"
+#include "../../Common/MyCom.h"
+#include "../IStream.h"
+
+class CSequentialInStreamImp:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+ const Byte *_dataPointer;
+ size_t _size;
+ size_t _pos;
+
+public:
+ void Init(const Byte *dataPointer, size_t size)
+ {
+ _dataPointer = dataPointer;
+ _size = size;
+ _pos = 0;
+ }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+};
+
+
+class CWriteBuffer
+{
+ CByteDynamicBuffer _buffer;
+ size_t _size;
+public:
+ CWriteBuffer(): _size(0) {}
+ void Init() { _size = 0; }
+ void Write(const void *data, size_t size);
+ size_t GetSize() const { return _size; }
+ const CByteDynamicBuffer& GetBuffer() const { return _buffer; }
+};
+
+class CSequentialOutStreamImp:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CWriteBuffer _writeBuffer;
+public:
+ void Init() { _writeBuffer.Init(); }
+ size_t GetSize() const { return _writeBuffer.GetSize(); }
+ const CByteDynamicBuffer& GetBuffer() const { return _writeBuffer.GetBuffer(); }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+class CSequentialOutStreamImp2:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ Byte *_buffer;
+ size_t _size;
+ size_t _pos;
+public:
+
+ void Init(Byte *buffer, size_t size)
+ {
+ _buffer = buffer;
+ _pos = 0;
+ _size = size;
+ }
+
+ size_t GetPos() const { return _pos; }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+class CSequentialInStreamSizeCount:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialInStream> _stream;
+ UInt64 _size;
+public:
+ void Init(ISequentialInStream *stream)
+ {
+ _stream = stream;
+ _size = 0;
+ }
+ UInt64 GetSize() const { return _size; }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+};
+
+class CSequentialOutStreamSizeCount:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialOutStream> _stream;
+ UInt64 _size;
+public:
+ void SetStream(ISequentialOutStream *stream) { _stream = stream; }
+ void Init() { _size = 0; }
+ UInt64 GetSize() const { return _size; }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamUtils.cpp
new file mode 100644
index 000000000..049e4aa17
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamUtils.cpp
@@ -0,0 +1,56 @@
+// StreamUtils.cpp
+
+#include "StdAfx.h"
+
+#include "StreamUtils.h"
+
+static const UInt32 kBlockSize = ((UInt32)1 << 31);
+
+HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSize)
+{
+ size_t size = *processedSize;
+ *processedSize = 0;
+ while (size != 0)
+ {
+ UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize;
+ UInt32 processedSizeLoc;
+ HRESULT res = stream->Read(data, curSize, &processedSizeLoc);
+ *processedSize += processedSizeLoc;
+ data = (void *)((Byte *)data + processedSizeLoc);
+ size -= processedSizeLoc;
+ RINOK(res);
+ if (processedSizeLoc == 0)
+ return S_OK;
+ }
+ return S_OK;
+}
+
+HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size)
+{
+ size_t processedSize = size;
+ RINOK(ReadStream(stream, data, &processedSize));
+ return (size == processedSize) ? S_OK : S_FALSE;
+}
+
+HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size)
+{
+ size_t processedSize = size;
+ RINOK(ReadStream(stream, data, &processedSize));
+ return (size == processedSize) ? S_OK : E_FAIL;
+}
+
+HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size)
+{
+ while (size != 0)
+ {
+ UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize;
+ UInt32 processedSizeLoc;
+ HRESULT res = stream->Write(data, curSize, &processedSizeLoc);
+ data = (const void *)((const Byte *)data + processedSizeLoc);
+ size -= processedSizeLoc;
+ RINOK(res);
+ if (processedSizeLoc == 0)
+ return E_FAIL;
+ }
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamUtils.h
new file mode 100644
index 000000000..f1cfd1848
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/StreamUtils.h
@@ -0,0 +1,13 @@
+// StreamUtils.h
+
+#ifndef __STREAMUTILS_H
+#define __STREAMUTILS_H
+
+#include "../IStream.h"
+
+HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *size);
+HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size);
+HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size);
+HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/VirtThread.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/VirtThread.cpp
new file mode 100644
index 000000000..cf39bd023
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/VirtThread.cpp
@@ -0,0 +1,46 @@
+// VirtThread.cpp
+
+#include "StdAfx.h"
+
+#include "VirtThread.h"
+
+static THREAD_FUNC_DECL CoderThread(void *p)
+{
+ for (;;)
+ {
+ CVirtThread *t = (CVirtThread *)p;
+ t->StartEvent.Lock();
+ if (t->ExitEvent)
+ return 0;
+ t->Execute();
+ t->FinishedEvent.Set();
+ }
+}
+
+WRes CVirtThread::Create()
+{
+ RINOK(StartEvent.CreateIfNotCreated());
+ RINOK(FinishedEvent.CreateIfNotCreated());
+ StartEvent.Reset();
+ FinishedEvent.Reset();
+ ExitEvent = false;
+ if (Thread.IsCreated())
+ return S_OK;
+ return Thread.Create(CoderThread, this);
+}
+
+void CVirtThread::Start()
+{
+ ExitEvent = false;
+ StartEvent.Set();
+}
+
+CVirtThread::~CVirtThread()
+{
+ ExitEvent = true;
+ if (StartEvent.IsCreated())
+ StartEvent.Set();
+ if (Thread.IsCreated())
+ Thread.Wait();
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/VirtThread.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/VirtThread.h
new file mode 100644
index 000000000..3830975e1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Common/VirtThread.h
@@ -0,0 +1,23 @@
+// VirtThread.h
+
+#ifndef __VIRTTHREAD_H
+#define __VIRTTHREAD_H
+
+#include "../../Windows/Synchronization.h"
+#include "../../Windows/Thread.h"
+
+struct CVirtThread
+{
+ NWindows::NSynchronization::CAutoResetEvent StartEvent;
+ NWindows::NSynchronization::CAutoResetEvent FinishedEvent;
+ NWindows::CThread Thread;
+ bool ExitEvent;
+
+ virtual ~CVirtThread();
+ WRes Create();
+ void Start();
+ void WaitFinish() { FinishedEvent.Lock(); }
+ virtual void Execute() = 0;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder1.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder1.cpp
new file mode 100644
index 000000000..3e66feeb6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder1.cpp
@@ -0,0 +1,315 @@
+// ArjDecoder1.cpp
+
+#include "StdAfx.h"
+
+#include "ArjDecoder1.h"
+
+namespace NCompress{
+namespace NArj {
+namespace NDecoder1 {
+
+static const UInt32 kHistorySize = 26624;
+static const UInt32 kMatchMinLen = 3;
+static const UInt32 kMatchMaxLen = 256;
+
+// static const UInt32 kNC = 255 + kMatchMaxLen + 2 - kMatchMinLen;
+
+void CCoder::MakeTable(int nchar, Byte *bitlen, int tablebits,
+ UInt32 *table, int tablesize)
+{
+ UInt32 count[17], weight[17], start[18], *p;
+ UInt32 i, k, len, ch, jutbits, avail, nextcode, mask;
+
+ for (i = 1; i <= 16; i++)
+ count[i] = 0;
+ for (i = 0; (int)i < nchar; i++)
+ count[bitlen[i]]++;
+
+ start[1] = 0;
+ for (i = 1; i <= 16; i++)
+ start[i + 1] = start[i] + (count[i] << (16 - i));
+ if (start[17] != (UInt32) (1 << 16))
+ throw "Data error";
+
+ jutbits = 16 - tablebits;
+ for (i = 1; (int)i <= tablebits; i++)
+ {
+ start[i] >>= jutbits;
+ weight[i] = 1 << (tablebits - i);
+ }
+ while (i <= 16)
+ {
+ weight[i] = 1 << (16 - i);
+ i++;
+ }
+
+ i = start[tablebits + 1] >> jutbits;
+ if (i != (UInt32) (1 << 16))
+ {
+ k = 1 << tablebits;
+ while (i != k)
+ table[i++] = 0;
+ }
+
+ avail = nchar;
+ mask = 1 << (15 - tablebits);
+ for (ch = 0; (int)ch < nchar; ch++)
+ {
+ if ((len = bitlen[ch]) == 0)
+ continue;
+ k = start[len];
+ nextcode = k + weight[len];
+ if ((int)len <= tablebits)
+ {
+ if (nextcode > (UInt32)tablesize)
+ throw "Data error";
+ for (i = start[len]; i < nextcode; i++)
+ table[i] = ch;
+ }
+ else
+ {
+ p = &table[k >> jutbits];
+ i = len - tablebits;
+ while (i != 0)
+ {
+ if (*p == 0)
+ {
+ right[avail] = left[avail] = 0;
+ *p = avail++;
+ }
+ if (k & mask)
+ p = &right[*p];
+ else
+ p = &left[*p];
+ k <<= 1;
+ i--;
+ }
+ *p = ch;
+ }
+ start[len] = nextcode;
+ }
+}
+
+void CCoder::read_pt_len(int nn, int nbit, int i_special)
+{
+ UInt32 n = m_InBitStream.ReadBits(nbit);
+ if (n == 0)
+ {
+ UInt32 c = m_InBitStream.ReadBits(nbit);
+ int i;
+ for (i = 0; i < nn; i++)
+ pt_len[i] = 0;
+ for (i = 0; i < 256; i++)
+ pt_table[i] = c;
+ }
+ else
+ {
+ UInt32 i = 0;
+ while (i < n)
+ {
+ UInt32 bitBuf = m_InBitStream.GetValue(16);
+ int c = bitBuf >> 13;
+ if (c == 7)
+ {
+ UInt32 mask = 1 << (12);
+ while (mask & bitBuf)
+ {
+ mask >>= 1;
+ c++;
+ }
+ }
+ m_InBitStream.MovePos((c < 7) ? 3 : (int)(c - 3));
+ pt_len[i++] = (Byte)c;
+ if (i == (UInt32)i_special)
+ {
+ c = m_InBitStream.ReadBits(2);
+ while (--c >= 0)
+ pt_len[i++] = 0;
+ }
+ }
+ while (i < (UInt32)nn)
+ pt_len[i++] = 0;
+ MakeTable(nn, pt_len, 8, pt_table, PTABLESIZE);
+ }
+}
+
+void CCoder::read_c_len()
+{
+ int i, c, n;
+ UInt32 mask;
+
+ n = m_InBitStream.ReadBits(CBIT);
+ if (n == 0)
+ {
+ c = m_InBitStream.ReadBits(CBIT);
+ for (i = 0; i < NC; i++)
+ c_len[i] = 0;
+ for (i = 0; i < CTABLESIZE; i++)
+ c_table[i] = c;
+ }
+ else
+ {
+ i = 0;
+ while (i < n)
+ {
+ UInt32 bitBuf = m_InBitStream.GetValue(16);
+ c = pt_table[bitBuf >> (8)];
+ if (c >= NT)
+ {
+ mask = 1 << (7);
+ do
+ {
+ if (bitBuf & mask)
+ c = right[c];
+ else
+ c = left[c];
+ mask >>= 1;
+ } while (c >= NT);
+ }
+ m_InBitStream.MovePos((int)(pt_len[c]));
+ if (c <= 2)
+ {
+ if (c == 0)
+ c = 1;
+ else if (c == 1)
+ c = m_InBitStream.ReadBits(4) + 3;
+ else
+ c = m_InBitStream.ReadBits(CBIT) + 20;
+ while (--c >= 0)
+ c_len[i++] = 0;
+ }
+ else
+ c_len[i++] = (Byte)(c - 2);
+ }
+ while (i < NC)
+ c_len[i++] = 0;
+ MakeTable(NC, c_len, 12, c_table, CTABLESIZE);
+ }
+}
+
+UInt32 CCoder::decode_c()
+{
+ UInt32 j, mask;
+ UInt32 bitbuf = m_InBitStream.GetValue(16);
+ j = c_table[bitbuf >> 4];
+ if (j >= NC)
+ {
+ mask = 1 << (3);
+ do
+ {
+ if (bitbuf & mask)
+ j = right[j];
+ else
+ j = left[j];
+ mask >>= 1;
+ } while (j >= NC);
+ }
+ m_InBitStream.MovePos((int)(c_len[j]));
+ return j;
+}
+
+UInt32 CCoder::decode_p()
+{
+ UInt32 j, mask;
+ UInt32 bitbuf = m_InBitStream.GetValue(16);
+ j = pt_table[bitbuf >> (8)];
+ if (j >= NP)
+ {
+ mask = 1 << (7);
+ do
+ {
+ if (bitbuf & mask)
+ j = right[j];
+ else
+ j = left[j];
+ mask >>= 1;
+ } while (j >= NP);
+ }
+ m_InBitStream.MovePos((int)(pt_len[j]));
+ if (j != 0)
+ {
+ j--;
+ j = (1 << j) + m_InBitStream.ReadBits((int)j);
+ }
+ return j;
+}
+
+
+HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ if (outSize == NULL)
+ return E_INVALIDARG;
+
+ if (!m_OutWindowStream.Create(kHistorySize))
+ return E_OUTOFMEMORY;
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ int size1 = sizeof(c_table) / sizeof(c_table[0]);
+ for (int i = 0; i < size1; i++)
+ {
+ if (i % 100 == 0)
+ c_table[i] = 0;
+
+ c_table[i] = 0;
+ }
+
+
+ UInt64 pos = 0;
+ m_OutWindowStream.SetStream(outStream);
+ m_OutWindowStream.Init(false);
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+
+ CCoderReleaser coderReleaser(this);
+
+ UInt32 blockSize = 0;
+
+ while(pos < *outSize)
+ {
+ if (blockSize == 0)
+ {
+ if (progress != NULL)
+ {
+ UInt64 packSize = m_InBitStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &pos));
+ }
+ blockSize = m_InBitStream.ReadBits(16);
+ read_pt_len(NT, TBIT, 3);
+ read_c_len();
+ read_pt_len(NP, PBIT, -1);
+ }
+ blockSize--;
+
+ UInt32 number = decode_c();
+ if (number < 256)
+ {
+ m_OutWindowStream.PutByte((Byte)number);
+ pos++;
+ continue;
+ }
+ else
+ {
+ UInt32 len = number - 256 + kMatchMinLen;
+ UInt32 distance = decode_p();
+ if (distance >= pos)
+ return S_FALSE;
+ m_OutWindowStream.CopyBlock(distance, len);
+ pos += len;
+ }
+ }
+ coderReleaser.NeedFlush = false;
+ return m_OutWindowStream.Flush();
+}
+
+STDMETHODIMP CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress);}
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder1.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder1.h
new file mode 100644
index 000000000..17939dafb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder1.h
@@ -0,0 +1,98 @@
+// ArjDecoder1.h
+
+#ifndef __COMPRESS_ARJ_DECODER1_H
+#define __COMPRESS_ARJ_DECODER1_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "BitmDecoder.h"
+#include "LzOutWindow.h"
+
+namespace NCompress {
+namespace NArj {
+namespace NDecoder1 {
+
+#define CODE_BIT 16
+
+#define THRESHOLD 3
+#define DDICSIZ 26624
+#define MAXDICBIT 16
+#define MATCHBIT 8
+#define MAXMATCH 256
+#define NC (0xFF + MAXMATCH + 2 - THRESHOLD)
+#define NP (MAXDICBIT + 1)
+#define CBIT 9
+#define NT (CODE_BIT + 3)
+#define PBIT 5
+#define TBIT 5
+
+#if NT > NP
+#define NPT NT
+#else
+#define NPT NP
+#endif
+
+#define CTABLESIZE 4096
+#define PTABLESIZE 256
+
+
+class CCoder :
+ public ICompressCoder,
+ public CMyUnknownImp
+{
+ CLzOutWindow m_OutWindowStream;
+ NBitm::CDecoder<CInBuffer> m_InBitStream;
+
+ UInt32 left[2 * NC - 1];
+ UInt32 right[2 * NC - 1];
+ Byte c_len[NC];
+ Byte pt_len[NPT];
+
+ UInt32 c_table[CTABLESIZE];
+ UInt32 pt_table[PTABLESIZE];
+
+ void ReleaseStreams()
+ {
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ }
+
+ class CCoderReleaser
+ {
+ CCoder *m_Coder;
+ public:
+ bool NeedFlush;
+ CCoderReleaser(CCoder *coder): m_Coder(coder), NeedFlush(true) {}
+ ~CCoderReleaser()
+ {
+ if (NeedFlush)
+ m_Coder->m_OutWindowStream.Flush();
+ m_Coder->ReleaseStreams();
+ }
+ };
+ friend class CCoderReleaser;
+
+ void MakeTable(int nchar, Byte *bitlen, int tablebits, UInt32 *table, int tablesize);
+
+ void read_c_len();
+ void read_pt_len(int nn, int nbit, int i_special);
+ UInt32 decode_c();
+ UInt32 decode_p();
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+public:
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+};
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder2.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder2.cpp
new file mode 100644
index 000000000..365993bc5
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder2.cpp
@@ -0,0 +1,90 @@
+// ArjDecoder2.cpp
+
+#include "StdAfx.h"
+
+#include "ArjDecoder2.h"
+
+namespace NCompress{
+namespace NArj {
+namespace NDecoder2 {
+
+static const UInt32 kHistorySize = 26624;
+static const UInt32 kMatchMinLen = 3;
+
+HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo * /* progress */)
+{
+ if (outSize == NULL)
+ return E_INVALIDARG;
+
+ if (!m_OutWindowStream.Create(kHistorySize))
+ return E_OUTOFMEMORY;
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ UInt64 pos = 0;
+ m_OutWindowStream.SetStream(outStream);
+ m_OutWindowStream.Init(false);
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+ CCoderReleaser coderReleaser(this);
+
+ while(pos < *outSize)
+ {
+ const UInt32 kStartWidth = 0;
+ const UInt32 kStopWidth = 7;
+ UInt32 power = 1 << kStartWidth;
+ UInt32 width;
+ UInt32 len = 0;
+ for (width = kStartWidth; width < kStopWidth; width++)
+ {
+ if (m_InBitStream.ReadBits(1) == 0)
+ break;
+ len += power;
+ power <<= 1;
+ }
+ if (width != 0)
+ len += m_InBitStream.ReadBits(width);
+ if (len == 0)
+ {
+ m_OutWindowStream.PutByte((Byte)m_InBitStream.ReadBits(8));
+ pos++;
+ continue;
+ }
+ else
+ {
+ len = len - 1 + kMatchMinLen;
+ const UInt32 kStartWidth = 9;
+ const UInt32 kStopWidth = 13;
+ UInt32 power = 1 << kStartWidth;
+ UInt32 width;
+ UInt32 distance = 0;
+ for (width = kStartWidth; width < kStopWidth; width++)
+ {
+ if (m_InBitStream.ReadBits(1) == 0)
+ break;
+ distance += power;
+ power <<= 1;
+ }
+ if (width != 0)
+ distance += m_InBitStream.ReadBits(width);
+ if (distance >= pos)
+ return S_FALSE;
+ m_OutWindowStream.CopyBlock(distance, len);
+ pos += len;
+ }
+ }
+ coderReleaser.NeedFlush = false;
+ return m_OutWindowStream.Flush();
+}
+
+STDMETHODIMP CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress);}
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder2.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder2.h
new file mode 100644
index 000000000..cf00975da
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ArjDecoder2.h
@@ -0,0 +1,59 @@
+// ArjDecoder2.h
+
+#ifndef __COMPRESS_ARJ_DECODER2_H
+#define __COMPRESS_ARJ_DECODER2_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "BitmDecoder.h"
+#include "LzOutWindow.h"
+
+namespace NCompress {
+namespace NArj {
+namespace NDecoder2 {
+
+class CCoder :
+ public ICompressCoder,
+ public CMyUnknownImp
+{
+ CLzOutWindow m_OutWindowStream;
+ NBitm::CDecoder<CInBuffer> m_InBitStream;
+
+ void ReleaseStreams()
+ {
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ }
+
+ class CCoderReleaser
+ {
+ CCoder *m_Coder;
+ public:
+ bool NeedFlush;
+ CCoderReleaser(CCoder *coder): m_Coder(coder), NeedFlush(true) {}
+ ~CCoderReleaser()
+ {
+ if (NeedFlush)
+ m_Coder->m_OutWindowStream.Flush();
+ m_Coder->ReleaseStreams();
+ }
+ };
+ friend class CCoderReleaser;
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+public:
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+};
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Const.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Const.h
new file mode 100644
index 000000000..62427aa68
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Const.h
@@ -0,0 +1,54 @@
+// Compress/BZip2Const.h
+
+#ifndef __COMPRESS_BZIP2_CONST_H
+#define __COMPRESS_BZIP2_CONST_H
+
+namespace NCompress {
+namespace NBZip2 {
+
+const Byte kArSig0 = 'B';
+const Byte kArSig1 = 'Z';
+const Byte kArSig2 = 'h';
+const Byte kArSig3 = '0';
+
+const Byte kFinSig0 = 0x17;
+const Byte kFinSig1 = 0x72;
+const Byte kFinSig2 = 0x45;
+const Byte kFinSig3 = 0x38;
+const Byte kFinSig4 = 0x50;
+const Byte kFinSig5 = 0x90;
+
+const Byte kBlockSig0 = 0x31;
+const Byte kBlockSig1 = 0x41;
+const Byte kBlockSig2 = 0x59;
+const Byte kBlockSig3 = 0x26;
+const Byte kBlockSig4 = 0x53;
+const Byte kBlockSig5 = 0x59;
+
+const int kNumOrigBits = 24;
+
+const int kNumTablesBits = 3;
+const int kNumTablesMin = 2;
+const int kNumTablesMax = 6;
+
+const int kNumLevelsBits = 5;
+
+const int kMaxHuffmanLen = 20; // Check it
+
+const int kMaxAlphaSize = 258;
+
+const int kGroupSize = 50;
+
+const int kBlockSizeMultMin = 1;
+const int kBlockSizeMultMax = 9;
+const UInt32 kBlockSizeStep = 100000;
+const UInt32 kBlockSizeMax = kBlockSizeMultMax * kBlockSizeStep;
+
+const int kNumSelectorsBits = 15;
+const UInt32 kNumSelectorsMax = (2 + (kBlockSizeMax / kGroupSize));
+
+const int kRleModeRepSize = 4;
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Crc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Crc.cpp
new file mode 100644
index 000000000..4e4741f40
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Crc.cpp
@@ -0,0 +1,26 @@
+// BZip2Crc.cpp
+
+#include "StdAfx.h"
+
+#include "BZip2Crc.h"
+
+UInt32 CBZip2Crc::Table[256];
+
+static const UInt32 kBZip2CrcPoly = 0x04c11db7; /* AUTODIN II, Ethernet, & FDDI */
+
+void CBZip2Crc::InitTable()
+{
+ for (UInt32 i = 0; i < 256; i++)
+ {
+ UInt32 r = (i << 24);
+ for (int j = 8; j > 0; j--)
+ r = (r & 0x80000000) ? ((r << 1) ^ kBZip2CrcPoly) : (r << 1);
+ Table[i] = r;
+ }
+}
+
+class CBZip2CrcTableInit
+{
+public:
+ CBZip2CrcTableInit() { CBZip2Crc::InitTable(); }
+} g_BZip2CrcTableInit;
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Crc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Crc.h
new file mode 100644
index 000000000..876945b5f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Crc.h
@@ -0,0 +1,31 @@
+// BZip2Crc.h
+
+#ifndef __BZIP2_CRC_H
+#define __BZIP2_CRC_H
+
+#include "Common/Types.h"
+
+class CBZip2Crc
+{
+ UInt32 _value;
+ static UInt32 Table[256];
+public:
+ static void InitTable();
+ CBZip2Crc(): _value(0xFFFFFFFF) {};
+ void Init() { _value = 0xFFFFFFFF; }
+ void UpdateByte(Byte b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
+ void UpdateByte(unsigned int b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
+ UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
+};
+
+class CBZip2CombinedCrc
+{
+ UInt32 _value;
+public:
+ CBZip2CombinedCrc(): _value(0){};
+ void Init() { _value = 0; }
+ void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; }
+ UInt32 GetDigest() const { return _value ; }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Decoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Decoder.cpp
new file mode 100644
index 000000000..7b97b93e0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Decoder.cpp
@@ -0,0 +1,813 @@
+// BZip2Decoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "../../Common/Defs.h"
+
+#include "BZip2Crc.h"
+#include "BZip2Decoder.h"
+#include "Mtf8.h"
+
+namespace NCompress {
+namespace NBZip2 {
+
+#ifndef NO_INLINE
+#define NO_INLINE MY_FAST_CALL
+#endif
+
+const UInt32 kNumThreadsMax = 4;
+
+static const UInt32 kBufferSize = (1 << 17);
+
+static Int16 kRandNums[512] = {
+ 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
+ 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
+ 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
+ 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
+ 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
+ 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
+ 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
+ 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
+ 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
+ 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
+ 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
+ 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
+ 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
+ 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
+ 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
+ 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
+ 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
+ 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
+ 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
+ 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
+ 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
+ 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
+ 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
+ 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
+ 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
+ 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
+ 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
+ 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
+ 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
+ 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
+ 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
+ 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
+ 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
+ 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
+ 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
+ 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
+ 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
+ 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
+ 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
+ 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
+ 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
+ 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
+ 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
+ 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
+ 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
+ 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
+ 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
+ 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
+ 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
+ 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
+ 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
+ 936, 638
+};
+
+bool CState::Alloc()
+{
+ if (Counters == 0)
+ Counters = (UInt32 *)BigAlloc((256 + kBlockSizeMax) * sizeof(UInt32));
+ return (Counters != 0);
+}
+
+void CState::Free()
+{
+ ::BigFree(Counters);
+ Counters = 0;
+}
+
+UInt32 CDecoder::ReadBits(int numBits) { return m_InStream.ReadBits(numBits); }
+Byte CDecoder::ReadByte() {return (Byte)ReadBits(8); }
+bool CDecoder::ReadBit() { return ReadBits(1) != 0; }
+
+UInt32 CDecoder::ReadCrc()
+{
+ UInt32 crc = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ crc <<= 8;
+ crc |= ReadByte();
+ }
+ return crc;
+}
+
+UInt32 NO_INLINE ReadBits(NBitm::CDecoder<CInBuffer> *m_InStream, int num)
+{
+ return m_InStream->ReadBits(num);
+}
+
+UInt32 NO_INLINE ReadBit(NBitm::CDecoder<CInBuffer> *m_InStream)
+{
+ return m_InStream->ReadBits(1);
+}
+
+static HRESULT NO_INLINE ReadBlock(NBitm::CDecoder<CInBuffer> *m_InStream,
+ UInt32 *CharCounters, UInt32 blockSizeMax, Byte *m_Selectors, CHuffmanDecoder *m_HuffmanDecoders,
+ UInt32 *blockSizeRes, UInt32 *origPtrRes, bool *randRes)
+{
+ *randRes = ReadBit(m_InStream) ? true : false;
+ *origPtrRes = ReadBits(m_InStream, kNumOrigBits);
+
+ // in original code it compares OrigPtr to (UInt32)(10 + blockSizeMax)) : why ?
+ if (*origPtrRes >= blockSizeMax)
+ return S_FALSE;
+
+ CMtf8Decoder mtf;
+ mtf.StartInit();
+
+ int numInUse = 0;
+ {
+ Byte inUse16[16];
+ int i;
+ for (i = 0; i < 16; i++)
+ inUse16[i] = (Byte)ReadBit(m_InStream);
+ for (i = 0; i < 256; i++)
+ if (inUse16[i >> 4])
+ {
+ if (ReadBit(m_InStream))
+ mtf.Add(numInUse++, (Byte)i);
+ }
+ if (numInUse == 0)
+ return S_FALSE;
+ // mtf.Init(numInUse);
+ }
+ int alphaSize = numInUse + 2;
+
+ int numTables = ReadBits(m_InStream, kNumTablesBits);
+ if (numTables < kNumTablesMin || numTables > kNumTablesMax)
+ return S_FALSE;
+
+ UInt32 numSelectors = ReadBits(m_InStream, kNumSelectorsBits);
+ if (numSelectors < 1 || numSelectors > kNumSelectorsMax)
+ return S_FALSE;
+
+ {
+ Byte mtfPos[kNumTablesMax];
+ int t = 0;
+ do
+ mtfPos[t] = (Byte)t;
+ while(++t < numTables);
+ UInt32 i = 0;
+ do
+ {
+ int j = 0;
+ while (ReadBit(m_InStream))
+ if (++j >= numTables)
+ return S_FALSE;
+ Byte tmp = mtfPos[j];
+ for (;j > 0; j--)
+ mtfPos[j] = mtfPos[j - 1];
+ m_Selectors[i] = mtfPos[0] = tmp;
+ }
+ while(++i < numSelectors);
+ }
+
+ int t = 0;
+ do
+ {
+ Byte lens[kMaxAlphaSize];
+ int len = (int)ReadBits(m_InStream, kNumLevelsBits);
+ int i;
+ for (i = 0; i < alphaSize; i++)
+ {
+ for (;;)
+ {
+ if (len < 1 || len > kMaxHuffmanLen)
+ return S_FALSE;
+ if (!ReadBit(m_InStream))
+ break;
+ len += 1 - (int)(ReadBit(m_InStream) << 1);
+ }
+ lens[i] = (Byte)len;
+ }
+ for (; i < kMaxAlphaSize; i++)
+ lens[i] = 0;
+ if(!m_HuffmanDecoders[t].SetCodeLengths(lens))
+ return S_FALSE;
+ }
+ while(++t < numTables);
+
+ {
+ for (int i = 0; i < 256; i++)
+ CharCounters[i] = 0;
+ }
+
+ UInt32 blockSize = 0;
+ {
+ UInt32 groupIndex = 0;
+ UInt32 groupSize = 0;
+ CHuffmanDecoder *huffmanDecoder = 0;
+ int runPower = 0;
+ UInt32 runCounter = 0;
+
+ for (;;)
+ {
+ if (groupSize == 0)
+ {
+ if (groupIndex >= numSelectors)
+ return S_FALSE;
+ groupSize = kGroupSize;
+ huffmanDecoder = &m_HuffmanDecoders[m_Selectors[groupIndex++]];
+ }
+ groupSize--;
+
+ UInt32 nextSym = huffmanDecoder->DecodeSymbol(m_InStream);
+
+ if (nextSym < 2)
+ {
+ runCounter += ((UInt32)(nextSym + 1) << runPower++);
+ if (blockSizeMax - blockSize < runCounter)
+ return S_FALSE;
+ continue;
+ }
+ if (runCounter != 0)
+ {
+ UInt32 b = (UInt32)mtf.GetHead();
+ CharCounters[b] += runCounter;
+ do
+ CharCounters[256 + blockSize++] = b;
+ while(--runCounter != 0);
+ runPower = 0;
+ }
+ if (nextSym <= (UInt32)numInUse)
+ {
+ UInt32 b = (UInt32)mtf.GetAndMove((int)nextSym - 1);
+ if (blockSize >= blockSizeMax)
+ return S_FALSE;
+ CharCounters[b]++;
+ CharCounters[256 + blockSize++] = b;
+ }
+ else if (nextSym == (UInt32)numInUse + 1)
+ break;
+ else
+ return S_FALSE;
+ }
+ }
+ *blockSizeRes = blockSize;
+ return (*origPtrRes < blockSize) ? S_OK : S_FALSE;
+}
+
+void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize)
+{
+ {
+ UInt32 sum = 0;
+ for (UInt32 i = 0; i < 256; i++)
+ {
+ sum += charCounters[i];
+ charCounters[i] = sum - charCounters[i];
+ }
+ }
+
+ UInt32 *tt = charCounters + 256;
+ // Compute the T^(-1) vector
+ UInt32 i = 0;
+ do
+ tt[charCounters[tt[i] & 0xFF]++] |= (i << 8);
+ while(++i < blockSize);
+}
+
+static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32 OrigPtr, COutBuffer &m_OutStream)
+{
+ CBZip2Crc crc;
+
+ // it's for speed optimization: prefetch & prevByte_init;
+ UInt32 tPos = tt[tt[OrigPtr] >> 8];
+ unsigned int prevByte = (unsigned int)(tPos & 0xFF);
+
+ int numReps = 0;
+
+ do
+ {
+ unsigned int b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+
+ if (numReps == kRleModeRepSize)
+ {
+ for (; b > 0; b--)
+ {
+ crc.UpdateByte(prevByte);
+ m_OutStream.WriteByte((Byte)prevByte);
+ }
+ numReps = 0;
+ continue;
+ }
+ if (b != prevByte)
+ numReps = 0;
+ numReps++;
+ prevByte = b;
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+
+ /*
+ prevByte = b;
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ for (; --blockSize != 0;)
+ {
+ b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ if (b != prevByte)
+ {
+ prevByte = b;
+ continue;
+ }
+ if (--blockSize == 0)
+ break;
+
+ b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ if (b != prevByte)
+ {
+ prevByte = b;
+ continue;
+ }
+ if (--blockSize == 0)
+ break;
+
+ b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ if (b != prevByte)
+ {
+ prevByte = b;
+ continue;
+ }
+ --blockSize;
+ break;
+ }
+ if (blockSize == 0)
+ break;
+
+ b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+
+ for (; b > 0; b--)
+ {
+ crc.UpdateByte(prevByte);
+ m_OutStream.WriteByte((Byte)prevByte);
+ }
+ */
+ }
+ while(--blockSize != 0);
+ return crc.GetDigest();
+}
+
+static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UInt32 OrigPtr, COutBuffer &m_OutStream)
+{
+ CBZip2Crc crc;
+
+ UInt32 randIndex = 1;
+ UInt32 randToGo = kRandNums[0] - 2;
+
+ int numReps = 0;
+
+ // it's for speed optimization: prefetch & prevByte_init;
+ UInt32 tPos = tt[tt[OrigPtr] >> 8];
+ unsigned int prevByte = (unsigned int)(tPos & 0xFF);
+
+ do
+ {
+ unsigned int b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+
+ {
+ if (randToGo == 0)
+ {
+ b ^= 1;
+ randToGo = kRandNums[randIndex++];
+ randIndex &= 0x1FF;
+ }
+ randToGo--;
+ }
+
+ if (numReps == kRleModeRepSize)
+ {
+ for (; b > 0; b--)
+ {
+ crc.UpdateByte(prevByte);
+ m_OutStream.WriteByte((Byte)prevByte);
+ }
+ numReps = 0;
+ continue;
+ }
+ if (b != prevByte)
+ numReps = 0;
+ numReps++;
+ prevByte = b;
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ }
+ while(--blockSize != 0);
+ return crc.GetDigest();
+}
+
+
+CDecoder::CDecoder()
+{
+ #ifdef COMPRESS_BZIP2_MT
+ m_States = 0;
+ m_NumThreadsPrev = 0;
+ NumThreads = 1;
+ #endif;
+ _needInStreamInit = true;
+}
+
+#ifdef COMPRESS_BZIP2_MT
+
+CDecoder::~CDecoder()
+{
+ Free();
+}
+
+#define RINOK_THREAD(x) { WRes __result_ = (x); if(__result_ != 0) return __result_; }
+
+HRESULT CDecoder::Create()
+{
+ RINOK_THREAD(CanProcessEvent.CreateIfNotCreated());
+ RINOK_THREAD(CanStartWaitingEvent.CreateIfNotCreated());
+ if (m_States != 0 && m_NumThreadsPrev == NumThreads)
+ return S_OK;
+ Free();
+ MtMode = (NumThreads > 1);
+ m_NumThreadsPrev = NumThreads;
+ try
+ {
+ m_States = new CState[NumThreads];
+ if (m_States == 0)
+ return E_OUTOFMEMORY;
+ }
+ catch(...) { return E_OUTOFMEMORY; }
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CState &ti = m_States[t];
+ ti.Decoder = this;
+ if (MtMode)
+ {
+ HRESULT res = ti.Create();
+ if (res != S_OK)
+ {
+ NumThreads = t;
+ Free();
+ return res;
+ }
+ }
+ }
+ return S_OK;
+}
+
+void CDecoder::Free()
+{
+ if (!m_States)
+ return;
+ CloseThreads = true;
+ CanProcessEvent.Set();
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CState &s = m_States[t];
+ if (MtMode)
+ s.Thread.Wait();
+ s.Free();
+ }
+ delete []m_States;
+ m_States = 0;
+}
+#endif
+
+HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
+{
+ wasFinished = false;
+ Byte s[6];
+ for (int i = 0; i < 6; i++)
+ s[i] = ReadByte();
+ crc = ReadCrc();
+ if (s[0] == kFinSig0)
+ {
+ if (s[1] != kFinSig1 ||
+ s[2] != kFinSig2 ||
+ s[3] != kFinSig3 ||
+ s[4] != kFinSig4 ||
+ s[5] != kFinSig5)
+ return S_FALSE;
+
+ wasFinished = true;
+ return (crc == CombinedCrc.GetDigest()) ? S_OK : S_FALSE;
+ }
+ if (s[0] != kBlockSig0 ||
+ s[1] != kBlockSig1 ||
+ s[2] != kBlockSig2 ||
+ s[3] != kBlockSig3 ||
+ s[4] != kBlockSig4 ||
+ s[5] != kBlockSig5)
+ return S_FALSE;
+ CombinedCrc.Update(crc);
+ return S_OK;
+}
+
+HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
+{
+ #ifdef COMPRESS_BZIP2_MT
+ Progress = progress;
+ RINOK(Create());
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CState &s = m_States[t];
+ if (!s.Alloc())
+ return E_OUTOFMEMORY;
+ if (MtMode)
+ {
+ RINOK(s.StreamWasFinishedEvent.Reset());
+ RINOK(s.WaitingWasStartedEvent.Reset());
+ RINOK(s.CanWriteEvent.Reset());
+ }
+ }
+ #else
+ if (!m_States[0].Alloc())
+ return E_OUTOFMEMORY;
+ #endif
+
+ isBZ = false;
+ Byte s[6];
+ int i;
+ for (i = 0; i < 4; i++)
+ s[i] = ReadByte();
+ if (s[0] != kArSig0 ||
+ s[1] != kArSig1 ||
+ s[2] != kArSig2 ||
+ s[3] <= kArSig3 ||
+ s[3] > kArSig3 + kBlockSizeMultMax)
+ return S_OK;
+ isBZ = true;
+ UInt32 dicSize = (UInt32)(s[3] - kArSig3) * kBlockSizeStep;
+
+ CombinedCrc.Init();
+ #ifdef COMPRESS_BZIP2_MT
+ if (MtMode)
+ {
+ NextBlockIndex = 0;
+ StreamWasFinished1 = StreamWasFinished2 = false;
+ CloseThreads = false;
+ CanStartWaitingEvent.Reset();
+ m_States[0].CanWriteEvent.Set();
+ BlockSizeMax = dicSize;
+ Result1 = Result2 = S_OK;
+ CanProcessEvent.Set();
+ UInt32 t;
+ for (t = 0; t < NumThreads; t++)
+ m_States[t].StreamWasFinishedEvent.Lock();
+ CanProcessEvent.Reset();
+ CanStartWaitingEvent.Set();
+ for (t = 0; t < NumThreads; t++)
+ m_States[t].WaitingWasStartedEvent.Lock();
+ CanStartWaitingEvent.Reset();
+ RINOK(Result2);
+ RINOK(Result1);
+ }
+ else
+ #endif
+ {
+ CState &state = m_States[0];
+ for (;;)
+ {
+ if (progress)
+ {
+ UInt64 packSize = m_InStream.GetProcessedSize();
+ UInt64 unpackSize = m_OutStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &unpackSize));
+ }
+ bool wasFinished;
+ UInt32 crc;
+ RINOK(ReadSignatures(wasFinished, crc));
+ if (wasFinished)
+ return S_OK;
+
+ UInt32 blockSize, origPtr;
+ bool randMode;
+ RINOK(ReadBlock(&m_InStream, state.Counters, dicSize,
+ m_Selectors, m_HuffmanDecoders,
+ &blockSize, &origPtr, &randMode));
+ DecodeBlock1(state.Counters, blockSize);
+ if ((randMode ?
+ DecodeBlock2Rand(state.Counters + 256, blockSize, origPtr, m_OutStream) :
+ DecodeBlock2(state.Counters + 256, blockSize, origPtr, m_OutStream)) != crc)
+ return S_FALSE;
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ bool &isBZ, ICompressProgressInfo *progress)
+{
+ isBZ = false;
+ try
+ {
+
+ if (!m_InStream.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ if (!m_OutStream.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+
+ if (inStream)
+ m_InStream.SetStream(inStream);
+
+ CDecoderFlusher flusher(this, inStream != NULL);
+
+ if (_needInStreamInit)
+ {
+ m_InStream.Init();
+ _needInStreamInit = false;
+ }
+ _inStart = m_InStream.GetProcessedSize();
+
+ m_InStream.AlignToByte();
+
+ m_OutStream.SetStream(outStream);
+ m_OutStream.Init();
+
+ RINOK(DecodeFile(isBZ, progress));
+ flusher.NeedFlush = false;
+ return Flush();
+
+ }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return E_FAIL; }
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
+{
+ _needInStreamInit = true;
+ bool isBZ;
+ RINOK(CodeReal(inStream, outStream, isBZ, progress));
+ return isBZ ? S_OK : S_FALSE;
+}
+
+HRESULT CDecoder::CodeResume(ISequentialOutStream *outStream, bool &isBZ, ICompressProgressInfo *progress)
+{
+ return CodeReal(NULL, outStream, isBZ, progress);
+}
+
+STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { m_InStream.SetStream(inStream); return S_OK; }
+STDMETHODIMP CDecoder::ReleaseInStream() { m_InStream.ReleaseStream(); return S_OK; }
+
+#ifdef COMPRESS_BZIP2_MT
+
+static THREAD_FUNC_DECL MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; }
+
+HRESULT CState::Create()
+{
+ RINOK_THREAD(StreamWasFinishedEvent.CreateIfNotCreated());
+ RINOK_THREAD(WaitingWasStartedEvent.CreateIfNotCreated());
+ RINOK_THREAD(CanWriteEvent.CreateIfNotCreated());
+ RINOK_THREAD(Thread.Create(MFThread, this));
+ return S_OK;
+}
+
+void CState::FinishStream()
+{
+ Decoder->StreamWasFinished1 = true;
+ StreamWasFinishedEvent.Set();
+ Decoder->CS.Leave();
+ Decoder->CanStartWaitingEvent.Lock();
+ WaitingWasStartedEvent.Set();
+}
+
+void CState::ThreadFunc()
+{
+ for (;;)
+ {
+ Decoder->CanProcessEvent.Lock();
+ Decoder->CS.Enter();
+ if (Decoder->CloseThreads)
+ {
+ Decoder->CS.Leave();
+ return;
+ }
+ if (Decoder->StreamWasFinished1)
+ {
+ FinishStream();
+ continue;
+ }
+ HRESULT res = S_OK;
+
+ UInt32 blockIndex = Decoder->NextBlockIndex;
+ UInt32 nextBlockIndex = blockIndex + 1;
+ if (nextBlockIndex == Decoder->NumThreads)
+ nextBlockIndex = 0;
+ Decoder->NextBlockIndex = nextBlockIndex;
+ UInt32 crc;
+ UInt64 packSize = 0;
+ UInt32 blockSize = 0, origPtr = 0;
+ bool randMode = false;
+
+ try
+ {
+ bool wasFinished;
+ res = Decoder->ReadSignatures(wasFinished, crc);
+ if (res != S_OK)
+ {
+ Decoder->Result1 = res;
+ FinishStream();
+ continue;
+ }
+ if (wasFinished)
+ {
+ Decoder->Result1 = res;
+ FinishStream();
+ continue;
+ }
+
+ res = ReadBlock(&Decoder->m_InStream, Counters, Decoder->BlockSizeMax,
+ Decoder->m_Selectors, Decoder->m_HuffmanDecoders,
+ &blockSize, &origPtr, &randMode);
+ if (res != S_OK)
+ {
+ Decoder->Result1 = res;
+ FinishStream();
+ continue;
+ }
+ packSize = Decoder->m_InStream.GetProcessedSize();
+ }
+ catch(const CInBufferException &e) { res = e.ErrorCode; if (res != S_OK) res = E_FAIL; }
+ catch(...) { res = E_FAIL; }
+ if (res != S_OK)
+ {
+ Decoder->Result1 = res;
+ FinishStream();
+ continue;
+ }
+
+ Decoder->CS.Leave();
+
+ DecodeBlock1(Counters, blockSize);
+
+ bool needFinish = true;
+ try
+ {
+ Decoder->m_States[blockIndex].CanWriteEvent.Lock();
+ needFinish = Decoder->StreamWasFinished2;
+ if (!needFinish)
+ {
+ if ((randMode ?
+ DecodeBlock2Rand(Counters + 256, blockSize, origPtr, Decoder->m_OutStream) :
+ DecodeBlock2(Counters + 256, blockSize, origPtr, Decoder->m_OutStream)) == crc)
+ {
+ if (Decoder->Progress)
+ {
+ UInt64 inSize = packSize - Decoder->_inStart;
+ UInt64 unpackSize = Decoder->m_OutStream.GetProcessedSize();
+ res = Decoder->Progress->SetRatioInfo(&inSize, &unpackSize);
+ }
+ }
+ else
+ res = S_FALSE;
+ }
+ }
+ catch(const COutBufferException &e) { res = e.ErrorCode; if (res != S_OK) res = E_FAIL; }
+ catch(...) { res = E_FAIL; }
+ if (res != S_OK)
+ {
+ Decoder->Result2 = res;
+ Decoder->StreamWasFinished2 = true;
+ }
+ Decoder->m_States[nextBlockIndex].CanWriteEvent.Set();
+ if (res != S_OK || needFinish)
+ {
+ StreamWasFinishedEvent.Set();
+ Decoder->CanStartWaitingEvent.Lock();
+ WaitingWasStartedEvent.Set();
+ }
+ }
+}
+
+STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
+{
+ NumThreads = numThreads;
+ if (NumThreads < 1)
+ NumThreads = 1;
+ if (NumThreads > kNumThreadsMax)
+ NumThreads = kNumThreadsMax;
+ return S_OK;
+}
+#endif
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Decoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Decoder.h
new file mode 100644
index 000000000..ca267a1d8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Decoder.h
@@ -0,0 +1,173 @@
+// Compress/BZip2Decoder.h
+
+#ifndef __COMPRESS_BZIP2_DECODER_H
+#define __COMPRESS_BZIP2_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#ifdef COMPRESS_BZIP2_MT
+#include "../../Windows/Synchronization.h"
+#include "../../Windows/Thread.h"
+#endif
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+#include "../Common/OutBuffer.h"
+
+#include "BitmDecoder.h"
+#include "BZip2Const.h"
+#include "BZip2Crc.h"
+#include "HuffmanDecoder.h"
+
+namespace NCompress {
+namespace NBZip2 {
+
+typedef NCompress::NHuffman::CDecoder<kMaxHuffmanLen, kMaxAlphaSize> CHuffmanDecoder;
+
+class CDecoder;
+
+struct CState
+{
+ UInt32 *Counters;
+
+ #ifdef COMPRESS_BZIP2_MT
+
+ CDecoder *Decoder;
+ NWindows::CThread Thread;
+ bool m_OptimizeNumTables;
+
+ NWindows::NSynchronization::CAutoResetEvent StreamWasFinishedEvent;
+ NWindows::NSynchronization::CAutoResetEvent WaitingWasStartedEvent;
+
+ // it's not member of this thread. We just need one event per thread
+ NWindows::NSynchronization::CAutoResetEvent CanWriteEvent;
+
+ Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
+
+ HRESULT Create();
+ void FinishStream();
+ void ThreadFunc();
+
+ #endif
+
+ CState(): Counters(0) {}
+ ~CState() { Free(); }
+ bool Alloc();
+ void Free();
+};
+
+class CDecoder :
+ public ICompressCoder,
+ #ifdef COMPRESS_BZIP2_MT
+ public ICompressSetCoderMt,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ COutBuffer m_OutStream;
+ Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
+ NBitm::CDecoder<CInBuffer> m_InStream;
+ Byte m_Selectors[kNumSelectorsMax];
+ CHuffmanDecoder m_HuffmanDecoders[kNumTablesMax];
+ UInt64 _inStart;
+
+private:
+
+ bool _needInStreamInit;
+
+ UInt32 ReadBits(int numBits);
+ Byte ReadByte();
+ bool ReadBit();
+ UInt32 ReadCrc();
+ HRESULT PrepareBlock(CState &state);
+ HRESULT DecodeFile(bool &isBZ, ICompressProgressInfo *progress);
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ bool &isBZ, ICompressProgressInfo *progress);
+ class CDecoderFlusher
+ {
+ CDecoder *_decoder;
+ public:
+ bool NeedFlush;
+ bool ReleaseInStream;
+ CDecoderFlusher(CDecoder *decoder, bool releaseInStream):
+ _decoder(decoder),
+ NeedFlush( true ),
+ ReleaseInStream(releaseInStream){}
+ ~CDecoderFlusher()
+ {
+ if (NeedFlush)
+ _decoder->Flush();
+ _decoder->ReleaseStreams(ReleaseInStream);
+ }
+ };
+
+public:
+ CBZip2CombinedCrc CombinedCrc;
+
+ #ifdef COMPRESS_BZIP2_MT
+ ICompressProgressInfo *Progress;
+ CState *m_States;
+ UInt32 m_NumThreadsPrev;
+
+ NWindows::NSynchronization::CManualResetEvent CanProcessEvent;
+ NWindows::NSynchronization::CCriticalSection CS;
+ UInt32 NumThreads;
+ bool MtMode;
+ UInt32 NextBlockIndex;
+ bool CloseThreads;
+ bool StreamWasFinished1;
+ bool StreamWasFinished2;
+ NWindows::NSynchronization::CManualResetEvent CanStartWaitingEvent;
+
+ HRESULT Result1;
+ HRESULT Result2;
+
+ UInt32 BlockSizeMax;
+ ~CDecoder();
+ HRESULT Create();
+ void Free();
+
+ #else
+ CState m_States[1];
+ #endif
+
+ CDecoder();
+
+ HRESULT ReadSignatures(bool &wasFinished, UInt32 &crc);
+
+
+ HRESULT Flush() { return m_OutStream.Flush(); }
+ void ReleaseStreams(bool releaseInStream)
+ {
+ if (releaseInStream)
+ m_InStream.ReleaseStream();
+ m_OutStream.ReleaseStream();
+ }
+
+ MY_QUERYINTERFACE_BEGIN
+ #ifdef COMPRESS_BZIP2_MT
+ MY_QUERYINTERFACE_ENTRY(ICompressSetCoderMt)
+ #endif
+
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream);
+ STDMETHOD(ReleaseInStream)();
+
+ HRESULT CodeResume(ISequentialOutStream *outStream, bool &isBZ, ICompressProgressInfo *progress);
+ UInt64 GetInputProcessedSize() const { return m_InStream.GetProcessedSize(); }
+
+ #ifdef COMPRESS_BZIP2_MT
+ STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
+ #endif
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Encoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Encoder.cpp
new file mode 100644
index 000000000..5fd78b955
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Encoder.cpp
@@ -0,0 +1,895 @@
+// BZip2Encoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+#include "../../../C/BwtSort.h"
+#include "../../../C/HuffEnc.h"
+
+#include "BZip2Crc.h"
+#include "BZip2Encoder.h"
+#include "Mtf8.h"
+
+namespace NCompress {
+namespace NBZip2 {
+
+const int kMaxHuffmanLenForEncoding = 16; // it must be < kMaxHuffmanLen = 20
+
+static const UInt32 kBufferSize = (1 << 17);
+static const int kNumHuffPasses = 4;
+
+bool CThreadInfo::Alloc()
+{
+ if (m_BlockSorterIndex == 0)
+ {
+ m_BlockSorterIndex = (UInt32 *)::BigAlloc(BLOCK_SORT_BUF_SIZE(kBlockSizeMax) * sizeof(UInt32));
+ if (m_BlockSorterIndex == 0)
+ return false;
+ }
+
+ if (m_Block == 0)
+ {
+ m_Block = (Byte *)::MidAlloc(kBlockSizeMax * 5 + kBlockSizeMax / 10 + (20 << 10));
+ if (m_Block == 0)
+ return false;
+ m_MtfArray = m_Block + kBlockSizeMax;
+ m_TempArray = m_MtfArray + kBlockSizeMax * 2 + 2;
+ }
+ return true;
+}
+
+void CThreadInfo::Free()
+{
+ ::BigFree(m_BlockSorterIndex);
+ m_BlockSorterIndex = 0;
+ ::MidFree(m_Block);
+ m_Block = 0;
+}
+
+#ifdef COMPRESS_BZIP2_MT
+
+static THREAD_FUNC_DECL MFThread(void *threadCoderInfo)
+{
+ return ((CThreadInfo *)threadCoderInfo)->ThreadFunc();
+}
+
+#define RINOK_THREAD(x) { WRes __result_ = (x); if(__result_ != 0) return __result_; }
+
+HRESULT CThreadInfo::Create()
+{
+ RINOK_THREAD(StreamWasFinishedEvent.Create());
+ RINOK_THREAD(WaitingWasStartedEvent.Create());
+ RINOK_THREAD(CanWriteEvent.Create());
+ RINOK_THREAD(Thread.Create(MFThread, this));
+ return S_OK;
+}
+
+void CThreadInfo::FinishStream(bool needLeave)
+{
+ Encoder->StreamWasFinished = true;
+ StreamWasFinishedEvent.Set();
+ if (needLeave)
+ Encoder->CS.Leave();
+ Encoder->CanStartWaitingEvent.Lock();
+ WaitingWasStartedEvent.Set();
+}
+
+DWORD CThreadInfo::ThreadFunc()
+{
+ for (;;)
+ {
+ Encoder->CanProcessEvent.Lock();
+ Encoder->CS.Enter();
+ if (Encoder->CloseThreads)
+ {
+ Encoder->CS.Leave();
+ return 0;
+ }
+ if (Encoder->StreamWasFinished)
+ {
+ FinishStream(true);
+ continue;
+ }
+ HRESULT res = S_OK;
+ bool needLeave = true;
+ try
+ {
+ UInt32 blockSize = Encoder->ReadRleBlock(m_Block);
+ m_PackSize = Encoder->m_InStream.GetProcessedSize();
+ m_BlockIndex = Encoder->NextBlockIndex;
+ if (++Encoder->NextBlockIndex == Encoder->NumThreads)
+ Encoder->NextBlockIndex = 0;
+ if (blockSize == 0)
+ {
+ FinishStream(true);
+ continue;
+ }
+ Encoder->CS.Leave();
+ needLeave = false;
+ res = EncodeBlock3(blockSize);
+ }
+ catch(const CInBufferException &e) { res = e.ErrorCode; }
+ catch(const COutBufferException &e) { res = e.ErrorCode; }
+ catch(...) { res = E_FAIL; }
+ if (res != S_OK)
+ {
+ Encoder->Result = res;
+ FinishStream(needLeave);
+ continue;
+ }
+ }
+}
+
+#endif
+
+CEncoder::CEncoder():
+ m_BlockSizeMult(kBlockSizeMultMax),
+ m_OptimizeNumTables(false),
+ NumPasses(1)
+{
+ #ifdef COMPRESS_BZIP2_MT
+ ThreadsInfo = 0;
+ m_NumThreadsPrev = 0;
+ NumThreads = 1;
+ #endif
+}
+
+#ifdef COMPRESS_BZIP2_MT
+CEncoder::~CEncoder()
+{
+ Free();
+}
+
+HRESULT CEncoder::Create()
+{
+ RINOK_THREAD(CanProcessEvent.CreateIfNotCreated());
+ RINOK_THREAD(CanStartWaitingEvent.CreateIfNotCreated());
+ if (ThreadsInfo != 0 && m_NumThreadsPrev == NumThreads)
+ return S_OK;
+ try
+ {
+ Free();
+ MtMode = (NumThreads > 1);
+ m_NumThreadsPrev = NumThreads;
+ ThreadsInfo = new CThreadInfo[NumThreads];
+ if (ThreadsInfo == 0)
+ return E_OUTOFMEMORY;
+ }
+ catch(...) { return E_OUTOFMEMORY; }
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CThreadInfo &ti = ThreadsInfo[t];
+ ti.Encoder = this;
+ if (MtMode)
+ {
+ HRESULT res = ti.Create();
+ if (res != S_OK)
+ {
+ NumThreads = t;
+ Free();
+ return res;
+ }
+ }
+ }
+ return S_OK;
+}
+
+void CEncoder::Free()
+{
+ if (!ThreadsInfo)
+ return;
+ CloseThreads = true;
+ CanProcessEvent.Set();
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CThreadInfo &ti = ThreadsInfo[t];
+ if (MtMode)
+ ti.Thread.Wait();
+ ti.Free();
+ }
+ delete []ThreadsInfo;
+ ThreadsInfo = 0;
+}
+#endif
+
+UInt32 CEncoder::ReadRleBlock(Byte *buffer)
+{
+ UInt32 i = 0;
+ Byte prevByte;
+ if (m_InStream.ReadByte(prevByte))
+ {
+ UInt32 blockSize = m_BlockSizeMult * kBlockSizeStep - 1;
+ int numReps = 1;
+ buffer[i++] = prevByte;
+ while (i < blockSize) // "- 1" to support RLE
+ {
+ Byte b;
+ if (!m_InStream.ReadByte(b))
+ break;
+ if (b != prevByte)
+ {
+ if (numReps >= kRleModeRepSize)
+ buffer[i++] = (Byte)(numReps - kRleModeRepSize);
+ buffer[i++] = b;
+ numReps = 1;
+ prevByte = b;
+ continue;
+ }
+ numReps++;
+ if (numReps <= kRleModeRepSize)
+ buffer[i++] = b;
+ else if (numReps == kRleModeRepSize + 255)
+ {
+ buffer[i++] = (Byte)(numReps - kRleModeRepSize);
+ numReps = 0;
+ }
+ }
+ // it's to support original BZip2 decoder
+ if (numReps >= kRleModeRepSize)
+ buffer[i++] = (Byte)(numReps - kRleModeRepSize);
+ }
+ return i;
+}
+
+void CThreadInfo::WriteBits2(UInt32 value, UInt32 numBits)
+ { m_OutStreamCurrent->WriteBits(value, numBits); }
+void CThreadInfo::WriteByte2(Byte b) { WriteBits2(b , 8); }
+void CThreadInfo::WriteBit2(bool v) { WriteBits2((v ? 1 : 0), 1); }
+void CThreadInfo::WriteCrc2(UInt32 v)
+{
+ for (int i = 0; i < 4; i++)
+ WriteByte2(((Byte)(v >> (24 - i * 8))));
+}
+
+void CEncoder::WriteBits(UInt32 value, UInt32 numBits)
+ { m_OutStream.WriteBits(value, numBits); }
+void CEncoder::WriteByte(Byte b) { WriteBits(b , 8); }
+void CEncoder::WriteBit(bool v) { WriteBits((v ? 1 : 0), 1); }
+void CEncoder::WriteCrc(UInt32 v)
+{
+ for (int i = 0; i < 4; i++)
+ WriteByte(((Byte)(v >> (24 - i * 8))));
+}
+
+
+// blockSize > 0
+void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
+{
+ WriteBit2(false); // Randomised = false
+
+ {
+ UInt32 origPtr = BlockSort(m_BlockSorterIndex, block, blockSize);
+ // if (m_BlockSorterIndex[origPtr] != 0) throw 1;
+ m_BlockSorterIndex[origPtr] = blockSize;
+ WriteBits2(origPtr, kNumOrigBits);
+ }
+
+ CMtf8Encoder mtf;
+ int numInUse = 0;
+ {
+ bool inUse[256];
+ bool inUse16[16];
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ inUse[i] = false;
+ for (i = 0; i < 16; i++)
+ inUse16[i] = false;
+ for (i = 0; i < blockSize; i++)
+ inUse[block[i]] = true;
+ for (i = 0; i < 256; i++)
+ if (inUse[i])
+ {
+ inUse16[i >> 4] = true;
+ mtf.Buf[numInUse++] = (Byte)i;
+ }
+ for (i = 0; i < 16; i++)
+ WriteBit2(inUse16[i]);
+ for (i = 0; i < 256; i++)
+ if (inUse16[i >> 4])
+ WriteBit2(inUse[i]);
+ }
+ int alphaSize = numInUse + 2;
+
+ Byte *mtfs = m_MtfArray;
+ UInt32 mtfArraySize = 0;
+ UInt32 symbolCounts[kMaxAlphaSize];
+ {
+ for (int i = 0; i < kMaxAlphaSize; i++)
+ symbolCounts[i] = 0;
+ }
+
+ {
+ UInt32 rleSize = 0;
+ UInt32 i = 0;
+ const UInt32 *bsIndex = m_BlockSorterIndex;
+ block--;
+ do
+ {
+ int pos = mtf.FindAndMove(block[bsIndex[i]]);
+ if (pos == 0)
+ rleSize++;
+ else
+ {
+ while (rleSize != 0)
+ {
+ rleSize--;
+ mtfs[mtfArraySize++] = (Byte)(rleSize & 1);
+ symbolCounts[rleSize & 1]++;
+ rleSize >>= 1;
+ }
+ if (pos >= 0xFE)
+ {
+ mtfs[mtfArraySize++] = 0xFF;
+ mtfs[mtfArraySize++] = (Byte)(pos - 0xFE);
+ }
+ else
+ mtfs[mtfArraySize++] = (Byte)(pos + 1);
+ symbolCounts[pos + 1]++;
+ }
+ }
+ while (++i < blockSize);
+
+ while (rleSize != 0)
+ {
+ rleSize--;
+ mtfs[mtfArraySize++] = (Byte)(rleSize & 1);
+ symbolCounts[rleSize & 1]++;
+ rleSize >>= 1;
+ }
+
+ if (alphaSize < 256)
+ mtfs[mtfArraySize++] = (Byte)(alphaSize - 1);
+ else
+ {
+ mtfs[mtfArraySize++] = 0xFF;
+ mtfs[mtfArraySize++] = (Byte)(alphaSize - 256);
+ }
+ symbolCounts[alphaSize - 1]++;
+ }
+
+ UInt32 numSymbols = 0;
+ {
+ for (int i = 0; i < kMaxAlphaSize; i++)
+ numSymbols += symbolCounts[i];
+ }
+
+ int bestNumTables = kNumTablesMin;
+ UInt32 bestPrice = 0xFFFFFFFF;
+ UInt32 startPos = m_OutStreamCurrent->GetPos();
+ Byte startCurByte = m_OutStreamCurrent->GetCurByte();
+ for (int nt = kNumTablesMin; nt <= kNumTablesMax + 1; nt++)
+ {
+ int numTables;
+
+ if(m_OptimizeNumTables)
+ {
+ m_OutStreamCurrent->SetPos(startPos);
+ m_OutStreamCurrent->SetCurState((startPos & 7), startCurByte);
+ if (nt <= kNumTablesMax)
+ numTables = nt;
+ else
+ numTables = bestNumTables;
+ }
+ else
+ {
+ if (numSymbols < 200) numTables = 2;
+ else if (numSymbols < 600) numTables = 3;
+ else if (numSymbols < 1200) numTables = 4;
+ else if (numSymbols < 2400) numTables = 5;
+ else numTables = 6;
+ }
+
+ WriteBits2(numTables, kNumTablesBits);
+
+ UInt32 numSelectors = (numSymbols + kGroupSize - 1) / kGroupSize;
+ WriteBits2(numSelectors, kNumSelectorsBits);
+
+ {
+ UInt32 remFreq = numSymbols;
+ int gs = 0;
+ int t = numTables;
+ do
+ {
+ UInt32 tFreq = remFreq / t;
+ int ge = gs;
+ UInt32 aFreq = 0;
+ while (aFreq < tFreq) // && ge < alphaSize)
+ aFreq += symbolCounts[ge++];
+
+ if (ge - 1 > gs && t != numTables && t != 1 && (((numTables - t) & 1) == 1))
+ aFreq -= symbolCounts[--ge];
+
+ Byte *lens = Lens[t - 1];
+ int i = 0;
+ do
+ lens[i] = (i >= gs && i < ge) ? 0 : 1;
+ while (++i < alphaSize);
+ gs = ge;
+ remFreq -= aFreq;
+ }
+ while(--t != 0);
+ }
+
+
+ for (int pass = 0; pass < kNumHuffPasses; pass++)
+ {
+ {
+ int t = 0;
+ do
+ memset(Freqs[t], 0, sizeof(Freqs[t]));
+ while(++t < numTables);
+ }
+
+ {
+ UInt32 mtfPos = 0;
+ UInt32 g = 0;
+ do
+ {
+ UInt32 symbols[kGroupSize];
+ int i = 0;
+ do
+ {
+ UInt32 symbol = mtfs[mtfPos++];
+ if (symbol >= 0xFF)
+ symbol += mtfs[mtfPos++];
+ symbols[i] = symbol;
+ }
+ while (++i < kGroupSize && mtfPos < mtfArraySize);
+
+ UInt32 bestPrice = 0xFFFFFFFF;
+ int t = 0;
+ do
+ {
+ const Byte *lens = Lens[t];
+ UInt32 price = 0;
+ int j = 0;
+ do
+ price += lens[symbols[j]];
+ while (++j < i);
+ if (price < bestPrice)
+ {
+ m_Selectors[g] = (Byte)t;
+ bestPrice = price;
+ }
+ }
+ while(++t < numTables);
+ UInt32 *freqs = Freqs[m_Selectors[g++]];
+ int j = 0;
+ do
+ freqs[symbols[j]]++;
+ while (++j < i);
+ }
+ while (mtfPos < mtfArraySize);
+ }
+
+ int t = 0;
+ do
+ {
+ UInt32 *freqs = Freqs[t];
+ int i = 0;
+ do
+ if (freqs[i] == 0)
+ freqs[i] = 1;
+ while(++i < alphaSize);
+ Huffman_Generate(freqs, Codes[t], Lens[t], kMaxAlphaSize, kMaxHuffmanLenForEncoding);
+ }
+ while(++t < numTables);
+ }
+
+ {
+ Byte mtfSel[kNumTablesMax];
+ {
+ int t = 0;
+ do
+ mtfSel[t] = (Byte)t;
+ while(++t < numTables);
+ }
+
+ UInt32 i = 0;
+ do
+ {
+ Byte sel = m_Selectors[i];
+ int pos;
+ for (pos = 0; mtfSel[pos] != sel; pos++)
+ WriteBit2(true);
+ WriteBit2(false);
+ for (; pos > 0; pos--)
+ mtfSel[pos] = mtfSel[pos - 1];
+ mtfSel[0] = sel;
+ }
+ while(++i < numSelectors);
+ }
+
+ {
+ int t = 0;
+ do
+ {
+ const Byte *lens = Lens[t];
+ UInt32 len = lens[0];
+ WriteBits2(len, kNumLevelsBits);
+ int i = 0;
+ do
+ {
+ UInt32 level = lens[i];
+ while (len != level)
+ {
+ WriteBit2(true);
+ if (len < level)
+ {
+ WriteBit2(false);
+ len++;
+ }
+ else
+ {
+ WriteBit2(true);
+ len--;
+ }
+ }
+ WriteBit2(false);
+ }
+ while (++i < alphaSize);
+ }
+ while(++t < numTables);
+ }
+
+ {
+ UInt32 groupSize = 0;
+ UInt32 groupIndex = 0;
+ const Byte *lens = 0;
+ const UInt32 *codes = 0;
+ UInt32 mtfPos = 0;
+ do
+ {
+ UInt32 symbol = mtfs[mtfPos++];
+ if (symbol >= 0xFF)
+ symbol += mtfs[mtfPos++];
+ if (groupSize == 0)
+ {
+ groupSize = kGroupSize;
+ int t = m_Selectors[groupIndex++];
+ lens = Lens[t];
+ codes = Codes[t];
+ }
+ groupSize--;
+ m_OutStreamCurrent->WriteBits(codes[symbol], lens[symbol]);
+ }
+ while (mtfPos < mtfArraySize);
+ }
+
+ if (!m_OptimizeNumTables)
+ break;
+ UInt32 price = m_OutStreamCurrent->GetPos() - startPos;
+ if (price <= bestPrice)
+ {
+ if (nt == kNumTablesMax)
+ break;
+ bestPrice = price;
+ bestNumTables = nt;
+ }
+ }
+}
+
+// blockSize > 0
+UInt32 CThreadInfo::EncodeBlockWithHeaders(const Byte *block, UInt32 blockSize)
+{
+ WriteByte2(kBlockSig0);
+ WriteByte2(kBlockSig1);
+ WriteByte2(kBlockSig2);
+ WriteByte2(kBlockSig3);
+ WriteByte2(kBlockSig4);
+ WriteByte2(kBlockSig5);
+
+ CBZip2Crc crc;
+ int numReps = 0;
+ Byte prevByte = block[0];
+ UInt32 i = 0;
+ do
+ {
+ Byte b = block[i];
+ if (numReps == kRleModeRepSize)
+ {
+ for (; b > 0; b--)
+ crc.UpdateByte(prevByte);
+ numReps = 0;
+ continue;
+ }
+ if (prevByte == b)
+ numReps++;
+ else
+ {
+ numReps = 1;
+ prevByte = b;
+ }
+ crc.UpdateByte(b);
+ }
+ while (++i < blockSize);
+ UInt32 crcRes = crc.GetDigest();
+ WriteCrc2(crcRes);
+ EncodeBlock(block, blockSize);
+ return crcRes;
+}
+
+void CThreadInfo::EncodeBlock2(const Byte *block, UInt32 blockSize, UInt32 numPasses)
+{
+ UInt32 numCrcs = m_NumCrcs;
+ bool needCompare = false;
+
+ UInt32 startBytePos = m_OutStreamCurrent->GetBytePos();
+ UInt32 startPos = m_OutStreamCurrent->GetPos();
+ Byte startCurByte = m_OutStreamCurrent->GetCurByte();
+ Byte endCurByte = 0;
+ UInt32 endPos = 0;
+ if (numPasses > 1 && blockSize >= (1 << 10))
+ {
+ UInt32 blockSize0 = blockSize / 2;
+ for (;(block[blockSize0] == block[blockSize0 - 1] ||
+ block[blockSize0 - 1] == block[blockSize0 - 2]) &&
+ blockSize0 < blockSize; blockSize0++);
+ if (blockSize0 < blockSize)
+ {
+ EncodeBlock2(block, blockSize0, numPasses - 1);
+ EncodeBlock2(block + blockSize0, blockSize - blockSize0, numPasses - 1);
+ endPos = m_OutStreamCurrent->GetPos();
+ endCurByte = m_OutStreamCurrent->GetCurByte();
+ if ((endPos & 7) > 0)
+ WriteBits2(0, 8 - (endPos & 7));
+ m_OutStreamCurrent->SetCurState((startPos & 7), startCurByte);
+ needCompare = true;
+ }
+ }
+
+ UInt32 startBytePos2 = m_OutStreamCurrent->GetBytePos();
+ UInt32 startPos2 = m_OutStreamCurrent->GetPos();
+ UInt32 crcVal = EncodeBlockWithHeaders(block, blockSize);
+ UInt32 endPos2 = m_OutStreamCurrent->GetPos();
+
+ if (needCompare)
+ {
+ UInt32 size2 = endPos2 - startPos2;
+ if (size2 < endPos - startPos)
+ {
+ UInt32 numBytes = m_OutStreamCurrent->GetBytePos() - startBytePos2;
+ Byte *buffer = m_OutStreamCurrent->GetStream();
+ for (UInt32 i = 0; i < numBytes; i++)
+ buffer[startBytePos + i] = buffer[startBytePos2 + i];
+ m_OutStreamCurrent->SetPos(startPos + endPos2 - startPos2);
+ m_NumCrcs = numCrcs;
+ m_CRCs[m_NumCrcs++] = crcVal;
+ }
+ else
+ {
+ m_OutStreamCurrent->SetPos(endPos);
+ m_OutStreamCurrent->SetCurState((endPos & 7), endCurByte);
+ }
+ }
+ else
+ {
+ m_NumCrcs = numCrcs;
+ m_CRCs[m_NumCrcs++] = crcVal;
+ }
+}
+
+HRESULT CThreadInfo::EncodeBlock3(UInt32 blockSize)
+{
+ CMsbfEncoderTemp outStreamTemp;
+ outStreamTemp.SetStream(m_TempArray);
+ outStreamTemp.Init();
+ m_OutStreamCurrent = &outStreamTemp;
+
+ m_NumCrcs = 0;
+
+ EncodeBlock2(m_Block, blockSize, Encoder->NumPasses);
+
+ #ifdef COMPRESS_BZIP2_MT
+ if (Encoder->MtMode)
+ Encoder->ThreadsInfo[m_BlockIndex].CanWriteEvent.Lock();
+ #endif
+ for (UInt32 i = 0; i < m_NumCrcs; i++)
+ Encoder->CombinedCrc.Update(m_CRCs[i]);
+ Encoder->WriteBytes(m_TempArray, outStreamTemp.GetPos(), outStreamTemp.GetCurByte());
+ HRESULT res = S_OK;
+ #ifdef COMPRESS_BZIP2_MT
+ if (Encoder->MtMode)
+ {
+ UInt32 blockIndex = m_BlockIndex + 1;
+ if (blockIndex == Encoder->NumThreads)
+ blockIndex = 0;
+
+ if (Encoder->Progress)
+ {
+ UInt64 unpackSize = Encoder->m_OutStream.GetProcessedSize();
+ res = Encoder->Progress->SetRatioInfo(&m_PackSize, &unpackSize);
+ }
+
+ Encoder->ThreadsInfo[blockIndex].CanWriteEvent.Set();
+ }
+ #endif
+ return res;
+}
+
+void CEncoder::WriteBytes(const Byte *data, UInt32 sizeInBits, Byte lastByte)
+{
+ UInt32 bytesSize = (sizeInBits / 8);
+ for (UInt32 i = 0; i < bytesSize; i++)
+ m_OutStream.WriteBits(data[i], 8);
+ WriteBits(lastByte, (sizeInBits & 7));
+}
+
+
+HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
+{
+ #ifdef COMPRESS_BZIP2_MT
+ Progress = progress;
+ RINOK(Create());
+ for (UInt32 t = 0; t < NumThreads; t++)
+ #endif
+ {
+ #ifdef COMPRESS_BZIP2_MT
+ CThreadInfo &ti = ThreadsInfo[t];
+ if (MtMode)
+ {
+ RINOK(ti.StreamWasFinishedEvent.Reset());
+ RINOK(ti.WaitingWasStartedEvent.Reset());
+ RINOK(ti.CanWriteEvent.Reset());
+ }
+ #else
+ CThreadInfo &ti = ThreadsInfo;
+ ti.Encoder = this;
+ #endif
+
+ ti.m_OptimizeNumTables = m_OptimizeNumTables;
+
+ if (!ti.Alloc())
+ return E_OUTOFMEMORY;
+ }
+
+
+ if (!m_InStream.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ if (!m_OutStream.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+
+
+ m_InStream.SetStream(inStream);
+ m_InStream.Init();
+
+ m_OutStream.SetStream(outStream);
+ m_OutStream.Init();
+
+ CFlusher flusher(this);
+
+ CombinedCrc.Init();
+ #ifdef COMPRESS_BZIP2_MT
+ NextBlockIndex = 0;
+ StreamWasFinished = false;
+ CloseThreads = false;
+ CanStartWaitingEvent.Reset();
+ #endif
+
+ WriteByte(kArSig0);
+ WriteByte(kArSig1);
+ WriteByte(kArSig2);
+ WriteByte((Byte)(kArSig3 + m_BlockSizeMult));
+
+ #ifdef COMPRESS_BZIP2_MT
+
+ if (MtMode)
+ {
+ ThreadsInfo[0].CanWriteEvent.Set();
+ Result = S_OK;
+ CanProcessEvent.Set();
+ UInt32 t;
+ for (t = 0; t < NumThreads; t++)
+ ThreadsInfo[t].StreamWasFinishedEvent.Lock();
+ CanProcessEvent.Reset();
+ CanStartWaitingEvent.Set();
+ for (t = 0; t < NumThreads; t++)
+ ThreadsInfo[t].WaitingWasStartedEvent.Lock();
+ CanStartWaitingEvent.Reset();
+ RINOK(Result);
+ }
+ else
+ #endif
+ {
+ for (;;)
+ {
+ CThreadInfo &ti =
+ #ifdef COMPRESS_BZIP2_MT
+ ThreadsInfo[0];
+ #else
+ ThreadsInfo;
+ #endif
+ UInt32 blockSize = ReadRleBlock(ti.m_Block);
+ if (blockSize == 0)
+ break;
+ RINOK(ti.EncodeBlock3(blockSize));
+ if (progress)
+ {
+ UInt64 packSize = m_InStream.GetProcessedSize();
+ UInt64 unpackSize = m_OutStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &unpackSize));
+ }
+ }
+ }
+ WriteByte(kFinSig0);
+ WriteByte(kFinSig1);
+ WriteByte(kFinSig2);
+ WriteByte(kFinSig3);
+ WriteByte(kFinSig4);
+ WriteByte(kFinSig5);
+
+ WriteCrc(CombinedCrc.GetDigest());
+ return Flush();
+}
+
+STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
+{
+ for(UInt32 i = 0; i < numProps; i++)
+ {
+ const PROPVARIANT &prop = props[i];
+ switch(propIDs[i])
+ {
+ case NCoderPropID::kNumPasses:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 numPasses = prop.ulVal;
+ if (numPasses == 0)
+ numPasses = 1;
+ if (numPasses > static_cast< UInt32 >( kNumPassesMax) )
+ numPasses = kNumPassesMax;
+ NumPasses = numPasses;
+ m_OptimizeNumTables = (NumPasses > 1);
+ break;
+ }
+ case NCoderPropID::kDictionarySize:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 dictionary = prop.ulVal / kBlockSizeStep;
+ if (dictionary < static_cast< UInt32 >( kBlockSizeMultMin) )
+ dictionary = kBlockSizeMultMin;
+ else if (dictionary > static_cast< UInt32 >( kBlockSizeMultMax) )
+ dictionary = kBlockSizeMultMax;
+ m_BlockSizeMult = dictionary;
+ break;
+ }
+ case NCoderPropID::kNumThreads:
+ {
+ #ifdef COMPRESS_BZIP2_MT
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ NumThreads = prop.ulVal;
+ if (NumThreads < 1)
+ NumThreads = 1;
+ #endif
+ break;
+ }
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ return S_OK;
+}
+
+#ifdef COMPRESS_BZIP2_MT
+STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads)
+{
+ NumThreads = numThreads;
+ if (NumThreads < 1)
+ NumThreads = 1;
+ return S_OK;
+}
+#endif
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Encoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Encoder.h
new file mode 100644
index 000000000..8a1061443
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Encoder.h
@@ -0,0 +1,245 @@
+// BZip2Encoder.h
+
+#ifndef __COMPRESS_BZIP2_ENCODER_H
+#define __COMPRESS_BZIP2_ENCODER_H
+
+#include "../../Common/Defs.h"
+#include "../../Common/MyCom.h"
+
+#ifdef COMPRESS_BZIP2_MT
+#include "../../Windows/Synchronization.h"
+#include "../../Windows/Thread.h"
+#endif
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+#include "../Common/OutBuffer.h"
+
+#include "BitmEncoder.h"
+#include "BZip2Const.h"
+#include "BZip2Crc.h"
+
+namespace NCompress {
+namespace NBZip2 {
+
+class CMsbfEncoderTemp
+{
+ UInt32 m_Pos;
+ int m_BitPos;
+ Byte m_CurByte;
+ Byte *Buffer;
+public:
+ void SetStream(Byte *buffer) { Buffer = buffer; }
+ Byte *GetStream() const { return Buffer; }
+
+ void Init()
+ {
+ m_Pos = 0;
+ m_BitPos = 8;
+ m_CurByte = 0;
+ }
+
+ void Flush()
+ {
+ if (m_BitPos < 8)
+ WriteBits(0, m_BitPos);
+ }
+
+ void WriteBits(UInt32 value, int numBits)
+ {
+ while (numBits > 0)
+ {
+ int numNewBits = MyMin(numBits, m_BitPos);
+ numBits -= numNewBits;
+
+ m_CurByte <<= numNewBits;
+ UInt32 newBits = value >> numBits;
+ m_CurByte |= Byte(newBits);
+ value -= (newBits << numBits);
+
+ m_BitPos -= numNewBits;
+
+ if (m_BitPos == 0)
+ {
+ Buffer[m_Pos++] = m_CurByte;
+ m_BitPos = 8;
+ }
+ }
+ }
+
+ UInt32 GetBytePos() const { return m_Pos ; }
+ UInt32 GetPos() const { return m_Pos * 8 + (8 - m_BitPos); }
+ Byte GetCurByte() const { return m_CurByte; }
+ void SetPos(UInt32 bitPos)
+ {
+ m_Pos = bitPos / 8;
+ m_BitPos = 8 - ((int)bitPos & 7);
+ }
+ void SetCurState(int bitPos, Byte curByte)
+ {
+ m_BitPos = 8 - bitPos;
+ m_CurByte = curByte;
+ }
+};
+
+class CEncoder;
+
+const int kNumPassesMax = 10;
+
+class CThreadInfo
+{
+public:
+ Byte *m_Block;
+private:
+ Byte *m_MtfArray;
+ Byte *m_TempArray;
+ UInt32 *m_BlockSorterIndex;
+
+ CMsbfEncoderTemp *m_OutStreamCurrent;
+
+ Byte Lens[kNumTablesMax][kMaxAlphaSize];
+ UInt32 Freqs[kNumTablesMax][kMaxAlphaSize];
+ UInt32 Codes[kNumTablesMax][kMaxAlphaSize];
+
+ Byte m_Selectors[kNumSelectorsMax];
+
+ UInt32 m_CRCs[1 << kNumPassesMax];
+ UInt32 m_NumCrcs;
+
+ UInt32 m_BlockIndex;
+
+ void WriteBits2(UInt32 value, UInt32 numBits);
+ void WriteByte2(Byte b);
+ void WriteBit2(bool v);
+ void WriteCrc2(UInt32 v);
+
+ void EncodeBlock(const Byte *block, UInt32 blockSize);
+ UInt32 EncodeBlockWithHeaders(const Byte *block, UInt32 blockSize);
+ void EncodeBlock2(const Byte *block, UInt32 blockSize, UInt32 numPasses);
+public:
+ bool m_OptimizeNumTables;
+ CEncoder *Encoder;
+ #ifdef COMPRESS_BZIP2_MT
+ NWindows::CThread Thread;
+
+ NWindows::NSynchronization::CAutoResetEvent StreamWasFinishedEvent;
+ NWindows::NSynchronization::CAutoResetEvent WaitingWasStartedEvent;
+
+ // it's not member of this thread. We just need one event per thread
+ NWindows::NSynchronization::CAutoResetEvent CanWriteEvent;
+
+ UInt64 m_PackSize;
+
+ Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
+ HRESULT Create();
+ void FinishStream(bool needLeave);
+ DWORD ThreadFunc();
+ #endif
+
+ CThreadInfo(): m_Block(0), m_BlockSorterIndex(0) {}
+ ~CThreadInfo() { Free(); }
+ bool Alloc();
+ void Free();
+
+ HRESULT EncodeBlock3(UInt32 blockSize);
+};
+
+class CEncoder :
+ public ICompressCoder,
+ public ICompressSetCoderProperties,
+ #ifdef COMPRESS_BZIP2_MT
+ public ICompressSetCoderMt,
+ #endif
+ public CMyUnknownImp
+{
+ UInt32 m_BlockSizeMult;
+ bool m_OptimizeNumTables;
+
+ UInt32 m_NumPassesPrev;
+
+ UInt32 m_NumThreadsPrev;
+public:
+ CInBuffer m_InStream;
+ Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
+ CBitmEncoder<COutBuffer> m_OutStream;
+ UInt32 NumPasses;
+ CBZip2CombinedCrc CombinedCrc;
+
+ #ifdef COMPRESS_BZIP2_MT
+ CThreadInfo *ThreadsInfo;
+ NWindows::NSynchronization::CManualResetEvent CanProcessEvent;
+ NWindows::NSynchronization::CCriticalSection CS;
+ UInt32 NumThreads;
+ bool MtMode;
+ UInt32 NextBlockIndex;
+
+ bool CloseThreads;
+ bool StreamWasFinished;
+ NWindows::NSynchronization::CManualResetEvent CanStartWaitingEvent;
+
+ HRESULT Result;
+ ICompressProgressInfo *Progress;
+ #else
+ CThreadInfo ThreadsInfo;
+ #endif
+
+ UInt32 ReadRleBlock(Byte *buffer);
+ void WriteBytes(const Byte *data, UInt32 sizeInBits, Byte lastByte);
+
+ void WriteBits(UInt32 value, UInt32 numBits);
+ void WriteByte(Byte b);
+ void WriteBit(bool v);
+ void WriteCrc(UInt32 v);
+
+ #ifdef COMPRESS_BZIP2_MT
+ HRESULT Create();
+ void Free();
+ #endif
+
+public:
+ CEncoder();
+ #ifdef COMPRESS_BZIP2_MT
+ ~CEncoder();
+ #endif
+
+ HRESULT Flush() { return m_OutStream.Flush(); }
+
+ void ReleaseStreams()
+ {
+ m_InStream.ReleaseStream();
+ m_OutStream.ReleaseStream();
+ }
+
+ class CFlusher
+ {
+ CEncoder *_coder;
+ public:
+ CFlusher(CEncoder *coder): _coder(coder) {}
+ ~CFlusher()
+ {
+ _coder->ReleaseStreams();
+ }
+ };
+
+ #ifdef COMPRESS_BZIP2_MT
+ MY_UNKNOWN_IMP2(ICompressSetCoderMt, ICompressSetCoderProperties)
+ #else
+ MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
+ #endif
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
+
+ #ifdef COMPRESS_BZIP2_MT
+ STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
+ #endif
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Register.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Register.cpp
new file mode 100644
index 000000000..ef14204b0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BZip2Register.cpp
@@ -0,0 +1,20 @@
+// BZip2Register.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "BZip2Decoder.h"
+
+static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NBZip2::CDecoder); }
+#if !defined(EXTRACT_ONLY) && !defined(BZIP2_EXTRACT_ONLY)
+#include "BZip2Encoder.h"
+static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NBZip2::CEncoder); }
+#else
+#define CreateCodecOut 0
+#endif
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodec, CreateCodecOut, 0x040202, L"BZip2", 1, false };
+
+REGISTER_CODEC(BZip2)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Coder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Coder.cpp
new file mode 100644
index 000000000..13ce51600
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Coder.cpp
@@ -0,0 +1,390 @@
+// Bcj2Coder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "Bcj2Coder.h"
+
+namespace NCompress {
+namespace NBcj2 {
+
+inline bool IsJcc(Byte b0, Byte b1) { return (b0 == 0x0F && (b1 & 0xF0) == 0x80); }
+inline bool IsJ(Byte b0, Byte b1) { return ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1)); }
+inline unsigned GetIndex(Byte b0, Byte b1) { return ((b1 == 0xE8) ? b0 : ((b1 == 0xE9) ? 256 : 257)); }
+
+#ifndef EXTRACT_ONLY
+
+static const int kBufferSize = 1 << 17;
+
+static bool inline Test86MSByte(Byte b)
+{
+ return (b == 0 || b == 0xFF);
+}
+
+bool CEncoder::Create()
+{
+ if (!_mainStream.Create(1 << 16))
+ return false;
+ if (!_callStream.Create(1 << 20))
+ return false;
+ if (!_jumpStream.Create(1 << 20))
+ return false;
+ if (!_rangeEncoder.Create(1 << 20))
+ return false;
+ if (_buffer == 0)
+ {
+ _buffer = (Byte *)MidAlloc(kBufferSize);
+ if (_buffer == 0)
+ return false;
+ }
+ return true;
+}
+
+CEncoder::~CEncoder()
+{
+ ::MidFree(_buffer);
+}
+
+HRESULT CEncoder::Flush()
+{
+ RINOK(_mainStream.Flush());
+ RINOK(_callStream.Flush());
+ RINOK(_jumpStream.Flush());
+ _rangeEncoder.FlushData();
+ return _rangeEncoder.FlushStream();
+}
+
+const UInt32 kDefaultLimit = (1 << 24);
+
+HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 ** /* outSizes */,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress)
+{
+ if (numInStreams != 1 || numOutStreams != 4)
+ return E_INVALIDARG;
+
+ if (!Create())
+ return E_OUTOFMEMORY;
+
+ bool sizeIsDefined = false;
+ UInt64 inSize = 0;
+ if (inSizes != NULL)
+ if (inSizes[0] != NULL)
+ {
+ inSize = *inSizes[0];
+ if (inSize <= kDefaultLimit)
+ sizeIsDefined = true;
+ }
+
+ ISequentialInStream *inStream = inStreams[0];
+
+ _mainStream.SetStream(outStreams[0]);
+ _mainStream.Init();
+ _callStream.SetStream(outStreams[1]);
+ _callStream.Init();
+ _jumpStream.SetStream(outStreams[2]);
+ _jumpStream.Init();
+ _rangeEncoder.SetStream(outStreams[3]);
+ _rangeEncoder.Init();
+ for (int i = 0; i < 256 + 2; i++)
+ _statusEncoder[i].Init();
+ CCoderReleaser releaser(this);
+
+ CMyComPtr<ICompressGetSubStreamSize> getSubStreamSize;
+ {
+ inStream->QueryInterface(IID_ICompressGetSubStreamSize, (void **)&getSubStreamSize);
+ }
+
+ UInt32 nowPos = 0;
+ UInt64 nowPos64 = 0;
+ UInt32 bufferPos = 0;
+
+ Byte prevByte = 0;
+
+ UInt64 subStreamIndex = 0;
+ UInt64 subStreamStartPos = 0;
+ UInt64 subStreamEndPos = 0;
+
+ for (;;)
+ {
+ UInt32 processedSize = 0;
+ for (;;)
+ {
+ UInt32 size = kBufferSize - (bufferPos + processedSize);
+ UInt32 processedSizeLoc;
+ if (size == 0)
+ break;
+ RINOK(inStream->Read(_buffer + bufferPos + processedSize, size, &processedSizeLoc));
+ if (processedSizeLoc == 0)
+ break;
+ processedSize += processedSizeLoc;
+ }
+ UInt32 endPos = bufferPos + processedSize;
+
+ if (endPos < 5)
+ {
+ // change it
+ for (bufferPos = 0; bufferPos < endPos; bufferPos++)
+ {
+ Byte b = _buffer[bufferPos];
+ _mainStream.WriteByte(b);
+ UInt32 index;
+ if (b == 0xE8)
+ index = prevByte;
+ else if (b == 0xE9)
+ index = 256;
+ else if (IsJcc(prevByte, b))
+ index = 257;
+ else
+ {
+ prevByte = b;
+ continue;
+ }
+ _statusEncoder[index].Encode(&_rangeEncoder, 0);
+ prevByte = b;
+ }
+ return Flush();
+ }
+
+ bufferPos = 0;
+
+ UInt32 limit = endPos - 5;
+ while(bufferPos <= limit)
+ {
+ Byte b = _buffer[bufferPos];
+ _mainStream.WriteByte(b);
+ if (!IsJ(prevByte, b))
+ {
+ bufferPos++;
+ prevByte = b;
+ continue;
+ }
+ Byte nextByte = _buffer[bufferPos + 4];
+ UInt32 src =
+ (UInt32(nextByte) << 24) |
+ (UInt32(_buffer[bufferPos + 3]) << 16) |
+ (UInt32(_buffer[bufferPos + 2]) << 8) |
+ (_buffer[bufferPos + 1]);
+ UInt32 dest = (nowPos + bufferPos + 5) + src;
+ // if (Test86MSByte(nextByte))
+ bool convert;
+ if (getSubStreamSize != NULL)
+ {
+ UInt64 currentPos = (nowPos64 + bufferPos);
+ while (subStreamEndPos < currentPos)
+ {
+ UInt64 subStreamSize;
+ HRESULT result = getSubStreamSize->GetSubStreamSize(subStreamIndex, &subStreamSize);
+ if (result == S_OK)
+ {
+ subStreamStartPos = subStreamEndPos;
+ subStreamEndPos += subStreamSize;
+ subStreamIndex++;
+ }
+ else if (result == S_FALSE || result == E_NOTIMPL)
+ {
+ getSubStreamSize.Release();
+ subStreamStartPos = 0;
+ subStreamEndPos = subStreamStartPos - 1;
+ }
+ else
+ return result;
+ }
+ if (getSubStreamSize == NULL)
+ {
+ if (sizeIsDefined)
+ convert = (dest < inSize);
+ else
+ convert = Test86MSByte(nextByte);
+ }
+ else if (subStreamEndPos - subStreamStartPos > kDefaultLimit)
+ convert = Test86MSByte(nextByte);
+ else
+ {
+ UInt64 dest64 = (currentPos + 5) + Int64(Int32(src));
+ convert = (dest64 >= subStreamStartPos && dest64 < subStreamEndPos);
+ }
+ }
+ else if (sizeIsDefined)
+ convert = (dest < inSize);
+ else
+ convert = Test86MSByte(nextByte);
+ unsigned index = GetIndex(prevByte, b);
+ if (convert)
+ {
+ _statusEncoder[index].Encode(&_rangeEncoder, 1);
+ bufferPos += 5;
+ COutBuffer &s = (b == 0xE8) ? _callStream : _jumpStream;
+ for (int i = 24; i >= 0; i -= 8)
+ s.WriteByte((Byte)(dest >> i));
+ prevByte = nextByte;
+ }
+ else
+ {
+ _statusEncoder[index].Encode(&_rangeEncoder, 0);
+ bufferPos++;
+ prevByte = b;
+ }
+ }
+ nowPos += bufferPos;
+ nowPos64 += bufferPos;
+
+ if (progress != NULL)
+ {
+ /*
+ const UInt64 compressedSize =
+ _mainStream.GetProcessedSize() +
+ _callStream.GetProcessedSize() +
+ _jumpStream.GetProcessedSize() +
+ _rangeEncoder.GetProcessedSize();
+ */
+ RINOK(progress->SetRatioInfo(&nowPos64, NULL));
+ }
+
+ UInt32 i = 0;
+ while(bufferPos < endPos)
+ _buffer[i++] = _buffer[bufferPos++];
+ bufferPos = i;
+ }
+}
+
+STDMETHODIMP CEncoder::Code(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 **outSizes,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress)
+{
+ try
+ {
+ return CodeReal(inStreams, inSizes, numInStreams,
+ outStreams, outSizes,numOutStreams, progress);
+ }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+#endif
+
+HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams,
+ const UInt64 ** /* inSizes */,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 ** /* outSizes */,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress)
+{
+ if (numInStreams != 4 || numOutStreams != 1)
+ return E_INVALIDARG;
+
+ if (!_mainInStream.Create(1 << 16))
+ return E_OUTOFMEMORY;
+ if (!_callStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ if (!_jumpStream.Create(1 << 16))
+ return E_OUTOFMEMORY;
+ if (!_rangeDecoder.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ if (!_outStream.Create(1 << 16))
+ return E_OUTOFMEMORY;
+
+ _mainInStream.SetStream(inStreams[0]);
+ _callStream.SetStream(inStreams[1]);
+ _jumpStream.SetStream(inStreams[2]);
+ _rangeDecoder.SetStream(inStreams[3]);
+ _outStream.SetStream(outStreams[0]);
+
+ _mainInStream.Init();
+ _callStream.Init();
+ _jumpStream.Init();
+ _rangeDecoder.Init();
+ _outStream.Init();
+
+ for (int i = 0; i < 256 + 2; i++)
+ _statusDecoder[i].Init();
+
+ CCoderReleaser releaser(this);
+
+ Byte prevByte = 0;
+ UInt32 processedBytes = 0;
+ for (;;)
+ {
+ if (processedBytes >= (1 << 20) && progress != NULL)
+ {
+ /*
+ const UInt64 compressedSize =
+ _mainInStream.GetProcessedSize() +
+ _callStream.GetProcessedSize() +
+ _jumpStream.GetProcessedSize() +
+ _rangeDecoder.GetProcessedSize();
+ */
+ const UInt64 nowPos64 = _outStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(NULL, &nowPos64));
+ processedBytes = 0;
+ }
+ UInt32 i;
+ Byte b = 0;
+ const UInt32 kBurstSize = (1 << 18);
+ for (i = 0; i < kBurstSize; i++)
+ {
+ if (!_mainInStream.ReadByte(b))
+ return Flush();
+ _outStream.WriteByte(b);
+ if (IsJ(prevByte, b))
+ break;
+ prevByte = b;
+ }
+ processedBytes += i;
+ if (i == kBurstSize)
+ continue;
+ unsigned index = GetIndex(prevByte, b);
+ if (_statusDecoder[index].Decode(&_rangeDecoder) == 1)
+ {
+ UInt32 src = 0;
+ CInBuffer &s = (b == 0xE8) ? _callStream : _jumpStream;
+ for (int i = 0; i < 4; i++)
+ {
+ Byte b0;
+ if(!s.ReadByte(b0))
+ return S_FALSE;
+ src <<= 8;
+ src |= ((UInt32)b0);
+ }
+ UInt32 dest = src - (UInt32(_outStream.GetProcessedSize()) + 4) ;
+ _outStream.WriteByte((Byte)(dest));
+ _outStream.WriteByte((Byte)(dest >> 8));
+ _outStream.WriteByte((Byte)(dest >> 16));
+ _outStream.WriteByte((Byte)(dest >> 24));
+ prevByte = (Byte)(dest >> 24);
+ processedBytes += 4;
+ }
+ else
+ prevByte = b;
+ }
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 **outSizes,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress)
+{
+ try
+ {
+ return CodeReal(inStreams, inSizes, numInStreams,
+ outStreams, outSizes,numOutStreams, progress);
+ }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Coder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Coder.h
new file mode 100644
index 000000000..b8b1e7a99
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Coder.h
@@ -0,0 +1,125 @@
+// Bcj2Coder.h
+
+#ifndef __COMPRESS_BCJ2_CODER_H
+#define __COMPRESS_BCJ2_CODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "RangeCoderBit.h"
+
+namespace NCompress {
+namespace NBcj2 {
+
+const int kNumMoveBits = 5;
+
+#ifndef EXTRACT_ONLY
+
+class CEncoder:
+ public ICompressCoder2,
+ public CMyUnknownImp
+{
+ Byte *_buffer;
+public:
+ CEncoder(): _buffer(0) {};
+ ~CEncoder();
+ bool Create();
+
+ COutBuffer _mainStream;
+ COutBuffer _callStream;
+ COutBuffer _jumpStream;
+ NCompress::NRangeCoder::CEncoder _rangeEncoder;
+ NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2];
+
+ HRESULT Flush();
+ void ReleaseStreams()
+ {
+ _mainStream.ReleaseStream();
+ _callStream.ReleaseStream();
+ _jumpStream.ReleaseStream();
+ _rangeEncoder.ReleaseStream();
+ }
+
+ class CCoderReleaser
+ {
+ CEncoder *_coder;
+ public:
+ CCoderReleaser(CEncoder *coder): _coder(coder) {}
+ ~CCoderReleaser() { _coder->ReleaseStreams(); }
+ };
+
+public:
+
+ MY_UNKNOWN_IMP
+
+ HRESULT CodeReal(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 **outSizes,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress);
+ STDMETHOD(Code)(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 **outSizes,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress);
+};
+
+#endif
+
+class CDecoder:
+ public ICompressCoder2,
+ public CMyUnknownImp
+{
+public:
+ CInBuffer _mainInStream;
+ CInBuffer _callStream;
+ CInBuffer _jumpStream;
+ NCompress::NRangeCoder::CDecoder _rangeDecoder;
+ NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2];
+
+ COutBuffer _outStream;
+
+ void ReleaseStreams()
+ {
+ _mainInStream.ReleaseStream();
+ _callStream.ReleaseStream();
+ _jumpStream.ReleaseStream();
+ _rangeDecoder.ReleaseStream();
+ _outStream.ReleaseStream();
+ }
+
+ HRESULT Flush() { return _outStream.Flush(); }
+ class CCoderReleaser
+ {
+ CDecoder *_coder;
+ public:
+ CCoderReleaser(CDecoder *coder): _coder(coder) {}
+ ~CCoderReleaser() { _coder->ReleaseStreams(); }
+ };
+
+public:
+ MY_UNKNOWN_IMP
+ HRESULT CodeReal(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 **outSizes,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress);
+ STDMETHOD(Code)(ISequentialInStream **inStreams,
+ const UInt64 **inSizes,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 **outSizes,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Register.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Register.cpp
new file mode 100644
index 000000000..8eb1e7360
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Bcj2Register.cpp
@@ -0,0 +1,19 @@
+// Bcj2Register.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "Bcj2Coder.h"
+
+static void *CreateCodec() { return (void *)(ICompressCoder2 *)(new NCompress::NBcj2::CDecoder()); }
+#ifndef EXTRACT_ONLY
+static void *CreateCodecOut() { return (void *)(ICompressCoder2 *)(new NCompress::NBcj2::CEncoder()); }
+#else
+#define CreateCodecOut 0
+#endif
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodec, CreateCodecOut, 0x0303011B, L"BCJ2", 4, false };
+
+REGISTER_CODEC(BCJ2)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjCoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjCoder.cpp
new file mode 100644
index 000000000..0e34ef488
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjCoder.cpp
@@ -0,0 +1,15 @@
+// BcjCoder.cpp
+
+#include "StdAfx.h"
+
+#include "BcjCoder.h"
+
+UInt32 CBCJ_x86_Encoder::SubFilter(Byte *data, UInt32 size)
+{
+ return (UInt32)::x86_Convert(data, size, _bufferPos, &_prevMask, 1);
+}
+
+UInt32 CBCJ_x86_Decoder::SubFilter(Byte *data, UInt32 size)
+{
+ return (UInt32)::x86_Convert(data, size, _bufferPos, &_prevMask, 0);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjCoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjCoder.h
new file mode 100644
index 000000000..0754bcd23
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjCoder.h
@@ -0,0 +1,19 @@
+// BcjCoder.h
+
+#ifndef __COMPRESS_BCJ_CODER_H
+#define __COMPRESS_BCJ_CODER_H
+
+#include "../../../C/Bra.h"
+
+#include "BranchCoder.h"
+
+struct CBranch86
+{
+ UInt32 _prevMask;
+ void x86Init() { x86_Convert_Init(_prevMask); }
+};
+
+MyClassB(BCJ_x86, 0x01, 3, CBranch86 ,
+ virtual void SubInit() { x86Init(); })
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjRegister.cpp
new file mode 100644
index 000000000..648ad8e03
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BcjRegister.cpp
@@ -0,0 +1,19 @@
+// BcjRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "BcjCoder.h"
+
+static void *CreateCodec() { return (void *)(ICompressFilter *)(new CBCJ_x86_Decoder()); }
+#ifndef EXTRACT_ONLY
+static void *CreateCodecOut() { return (void *)(ICompressFilter *)(new CBCJ_x86_Encoder()); }
+#else
+#define CreateCodecOut 0
+#endif
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodec, CreateCodecOut, 0x03030103, L"BCJ", 1, true };
+
+REGISTER_CODEC(BCJ)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlDecoder.cpp
new file mode 100644
index 000000000..78665be8f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlDecoder.cpp
@@ -0,0 +1,24 @@
+// BitlDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "BitlDecoder.h"
+
+namespace NBitl {
+
+Byte kInvertTable[256];
+
+struct CInverterTableInitializer
+{
+ CInverterTableInitializer()
+ {
+ for (int i = 0; i < 256; i++)
+ {
+ int x = ((i & 0x55) << 1) | ((i & 0xAA) >> 1);
+ x = ((x & 0x33) << 2) | ((x & 0xCC) >> 2);
+ kInvertTable[i] = (Byte)(((x & 0x0F) << 4) | ((x & 0xF0) >> 4));
+ }
+ }
+} g_InverterTableInitializer;
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlDecoder.h
new file mode 100644
index 000000000..3bee413ae
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlDecoder.h
@@ -0,0 +1,142 @@
+// BitlDecoder.h -- the Least Significant Bit of byte is First
+
+#ifndef __BITL_DECODER_H
+#define __BITL_DECODER_H
+
+#include "../IStream.h"
+
+namespace NBitl {
+
+const int kNumBigValueBits = 8 * 4;
+
+const int kNumValueBytes = 3;
+const int kNumValueBits = 8 * kNumValueBytes;
+
+const UInt32 kMask = (1 << kNumValueBits) - 1;
+
+extern Byte kInvertTable[256];
+
+template<class TInByte>
+class CBaseDecoder
+{
+protected:
+ int m_BitPos;
+ UInt32 m_Value;
+ TInByte m_Stream;
+public:
+ UInt32 NumExtraBytes;
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+ void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream); }
+ void ReleaseStream() { m_Stream.ReleaseStream(); }
+ void Init()
+ {
+ m_Stream.Init();
+ m_BitPos = kNumBigValueBits;
+ m_Value = 0;
+ NumExtraBytes = 0;
+ }
+ UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() + NumExtraBytes - (kNumBigValueBits - m_BitPos) / 8; }
+
+ void Normalize()
+ {
+ for (; m_BitPos >= 8; m_BitPos -= 8)
+ {
+ Byte b = 0;
+ if (!m_Stream.ReadByte(b))
+ {
+ b = 0xFF; // check it
+ NumExtraBytes++;
+ }
+ m_Value = (b << (kNumBigValueBits - m_BitPos)) | m_Value;
+ }
+ }
+
+ UInt32 ReadBits(int numBits)
+ {
+ Normalize();
+ UInt32 res = m_Value & ((1 << numBits) - 1);
+ m_BitPos += numBits;
+ m_Value >>= numBits;
+ return res;
+ }
+
+ bool ExtraBitsWereRead() const
+ {
+ if (NumExtraBytes == 0)
+ return false;
+ return ((UInt32)(kNumBigValueBits - m_BitPos) < (NumExtraBytes << 3));
+ }
+};
+
+template<class TInByte>
+class CDecoder: public CBaseDecoder<TInByte>
+{
+ UInt32 m_NormalValue;
+
+public:
+ void Init()
+ {
+ CBaseDecoder<TInByte>::Init();
+ m_NormalValue = 0;
+ }
+
+ void Normalize()
+ {
+ for (; this->m_BitPos >= 8; this->m_BitPos -= 8)
+ {
+ Byte b = 0;
+ if (!this->m_Stream.ReadByte(b))
+ {
+ b = 0xFF; // check it
+ this->NumExtraBytes++;
+ }
+ m_NormalValue = (b << (kNumBigValueBits - this->m_BitPos)) | m_NormalValue;
+ this->m_Value = (this->m_Value << 8) | kInvertTable[b];
+ }
+ }
+
+ UInt32 GetValue(int numBits)
+ {
+ Normalize();
+ return ((this->m_Value >> (8 - this->m_BitPos)) & kMask) >> (kNumValueBits - numBits);
+ }
+
+ void MovePos(int numBits)
+ {
+ this->m_BitPos += numBits;
+ m_NormalValue >>= numBits;
+ }
+
+ UInt32 ReadBits(int numBits)
+ {
+ Normalize();
+ UInt32 res = m_NormalValue & ((1 << numBits) - 1);
+ MovePos(numBits);
+ return res;
+ }
+
+ void AlignToByte() { MovePos((32 - this->m_BitPos) & 7); }
+
+ Byte ReadByte()
+ {
+ if (this->m_BitPos == kNumBigValueBits)
+ {
+ Byte b = 0;
+ if (!this->m_Stream.ReadByte(b))
+ {
+ b = 0xFF;
+ this->NumExtraBytes++;
+ }
+ return b;
+ }
+ {
+ Byte b = (Byte)(m_NormalValue & 0xFF);
+ MovePos(8);
+ return b;
+ }
+ }
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlEncoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlEncoder.h
new file mode 100644
index 000000000..02f5a9c65
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitlEncoder.h
@@ -0,0 +1,60 @@
+// BitlEncoder.h -- the Least Significant Bit of byte is First
+
+#ifndef __BITL_ENCODER_H
+#define __BITL_ENCODER_H
+
+#include "../Common/OutBuffer.h"
+
+class CBitlEncoder
+{
+ COutBuffer m_Stream;
+ int m_BitPos;
+ Byte m_CurByte;
+public:
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+ void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream); }
+ void ReleaseStream() { m_Stream.ReleaseStream(); }
+ void Init()
+ {
+ m_Stream.Init();
+ m_BitPos = 8;
+ m_CurByte = 0;
+ }
+ HRESULT Flush()
+ {
+ FlushByte();
+ return m_Stream.Flush();
+ }
+
+ void FlushByte()
+ {
+ if(m_BitPos < 8)
+ m_Stream.WriteByte(m_CurByte);
+ m_BitPos = 8;
+ m_CurByte = 0;
+ }
+
+ void WriteBits(UInt32 value, int numBits)
+ {
+ while(numBits > 0)
+ {
+ if (numBits < m_BitPos)
+ {
+ m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos);
+ m_BitPos -= numBits;
+ return;
+ }
+ numBits -= m_BitPos;
+ m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos))));
+ value >>= m_BitPos;
+ m_BitPos = 8;
+ m_CurByte = 0;
+ }
+ }
+ UInt32 GetBitPosition() const { return (8 - m_BitPos); }
+ UInt64 GetProcessedSize() const {
+ return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
+ void WriteByte(Byte b) { m_Stream.WriteByte(b);}
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitmDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitmDecoder.h
new file mode 100644
index 000000000..2885ed781
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitmDecoder.h
@@ -0,0 +1,66 @@
+// BitmDecoder.h -- the Most Significant Bit of byte is First
+
+#ifndef __BITM_DECODER_H
+#define __BITM_DECODER_H
+
+#include "../IStream.h"
+
+namespace NBitm {
+
+const int kNumBigValueBits = 8 * 4;
+const int kNumValueBytes = 3;
+const int kNumValueBits = 8 * kNumValueBytes;
+
+const UInt32 kMask = (1 << kNumValueBits) - 1;
+
+template<class TInByte>
+class CDecoder
+{
+ UInt32 m_BitPos;
+ UInt32 m_Value;
+public:
+ TInByte m_Stream;
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+ void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
+ void ReleaseStream() { m_Stream.ReleaseStream();}
+
+ void Init()
+ {
+ m_Stream.Init();
+ m_BitPos = kNumBigValueBits;
+ Normalize();
+ }
+
+ UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
+
+ void Normalize()
+ {
+ for (;m_BitPos >= 8; m_BitPos -= 8)
+ m_Value = (m_Value << 8) | m_Stream.ReadByte();
+ }
+
+ UInt32 GetValue(UInt32 numBits) const
+ {
+ // return (m_Value << m_BitPos) >> (kNumBigValueBits - numBits);
+ return ((m_Value >> (8 - m_BitPos)) & kMask) >> (kNumValueBits - numBits);
+ }
+
+ void MovePos(UInt32 numBits)
+ {
+ m_BitPos += numBits;
+ Normalize();
+ }
+
+ UInt32 ReadBits(UInt32 numBits)
+ {
+ UInt32 res = GetValue(numBits);
+ MovePos(numBits);
+ return res;
+ }
+
+ void AlignToByte() { MovePos((32 - m_BitPos) & 7); }
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitmEncoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitmEncoder.h
new file mode 100644
index 000000000..25976ef61
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BitmEncoder.h
@@ -0,0 +1,52 @@
+// BitmEncoder.h -- the Most Significant Bit of byte is First
+
+#ifndef __BITM_ENCODER_H
+#define __BITM_ENCODER_H
+
+#include "../IStream.h"
+
+template<class TOutByte>
+class CBitmEncoder
+{
+ TOutByte m_Stream;
+ int m_BitPos;
+ Byte m_CurByte;
+public:
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+ void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream);}
+ void ReleaseStream() { m_Stream.ReleaseStream(); }
+ void Init()
+ {
+ m_Stream.Init();
+ m_BitPos = 8;
+ m_CurByte = 0;
+ }
+ HRESULT Flush()
+ {
+ if(m_BitPos < 8)
+ WriteBits(0, m_BitPos);
+ return m_Stream.Flush();
+ }
+
+ void WriteBits(UInt32 value, int numBits)
+ {
+ while(numBits > 0)
+ {
+ if (numBits < m_BitPos)
+ {
+ m_CurByte |= ((Byte)value << (m_BitPos -= numBits));
+ return;
+ }
+ numBits -= m_BitPos;
+ UInt32 newBits = (value >> numBits);
+ value -= (newBits << numBits);
+ m_Stream.WriteByte((Byte)(m_CurByte | newBits));
+ m_BitPos = 8;
+ m_CurByte = 0;
+ }
+ }
+ UInt64 GetProcessedSize() const {
+ return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) / 8; }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchCoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchCoder.cpp
new file mode 100644
index 000000000..431709526
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchCoder.cpp
@@ -0,0 +1,19 @@
+// BranchCoder.cpp
+
+#include "StdAfx.h"
+
+#include "BranchCoder.h"
+
+STDMETHODIMP CBranchConverter::Init()
+{
+ _bufferPos = 0;
+ SubInit();
+ return S_OK;
+}
+
+STDMETHODIMP_(UInt32) CBranchConverter::Filter(Byte *data, UInt32 size)
+{
+ UInt32 processedSize = SubFilter(data, size);
+ _bufferPos += processedSize;
+ return processedSize;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchCoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchCoder.h
new file mode 100644
index 000000000..0e3a5c4e1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchCoder.h
@@ -0,0 +1,44 @@
+// BranchCoder.h
+
+#ifndef __COMPRESS_BRANCH_CODER_H
+#define __COMPRESS_BRANCH_CODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+class CBranchConverter:
+ public ICompressFilter,
+ public CMyUnknownImp
+{
+protected:
+ UInt32 _bufferPos;
+ virtual void SubInit() {}
+ virtual UInt32 SubFilter(Byte *data, UInt32 size) = 0;
+public:
+ MY_UNKNOWN_IMP;
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+};
+
+#define MyClassEncoderA(Name) class C ## Name: public CBranchConverter \
+ { public: UInt32 SubFilter(Byte *data, UInt32 size); };
+
+#define MyClassDecoderA(Name) class C ## Name: public CBranchConverter \
+ { public: UInt32 SubFilter(Byte *data, UInt32 size); };
+
+#define MyClassEncoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
+ { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
+
+#define MyClassDecoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
+ { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
+
+#define MyClassA(Name, id, subId) \
+MyClassEncoderA(Name ## _Encoder) \
+MyClassDecoderA(Name ## _Decoder)
+
+#define MyClassB(Name, id, subId, ADD_ITEMS, ADD_INIT) \
+MyClassEncoderB(Name ## _Encoder, ADD_ITEMS, ADD_INIT) \
+MyClassDecoderB(Name ## _Decoder, ADD_ITEMS, ADD_INIT)
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchMisc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchMisc.cpp
new file mode 100644
index 000000000..423b723ab
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchMisc.cpp
@@ -0,0 +1,37 @@
+// BranchMisc.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Bra.h"
+
+#include "BranchMisc.h"
+
+UInt32 CBC_ARM_Encoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::ARM_Convert(data, size, _bufferPos, 1); }
+
+UInt32 CBC_ARM_Decoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::ARM_Convert(data, size, _bufferPos, 0); }
+
+UInt32 CBC_ARMT_Encoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::ARMT_Convert(data, size, _bufferPos, 1); }
+
+UInt32 CBC_ARMT_Decoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::ARMT_Convert(data, size, _bufferPos, 0); }
+
+UInt32 CBC_PPC_Encoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::PPC_Convert(data, size, _bufferPos, 1); }
+
+UInt32 CBC_PPC_Decoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::PPC_Convert(data, size, _bufferPos, 0); }
+
+UInt32 CBC_SPARC_Encoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::SPARC_Convert(data, size, _bufferPos, 1); }
+
+UInt32 CBC_SPARC_Decoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::SPARC_Convert(data, size, _bufferPos, 0); }
+
+UInt32 CBC_IA64_Encoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::IA64_Convert(data, size, _bufferPos, 1); }
+
+UInt32 CBC_IA64_Decoder::SubFilter(Byte *data, UInt32 size)
+ { return (UInt32)::IA64_Convert(data, size, _bufferPos, 0); }
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchMisc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchMisc.h
new file mode 100644
index 000000000..81198b21c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchMisc.h
@@ -0,0 +1,14 @@
+// BranchMisc.h
+
+#ifndef __COMPRESS_BRANCH_MISC_H
+#define __COMPRESS_BRANCH_MISC_H
+
+#include "BranchCoder.h"
+
+MyClassA(BC_ARM, 0x05, 1)
+MyClassA(BC_ARMT, 0x07, 1)
+MyClassA(BC_PPC, 0x02, 5)
+MyClassA(BC_SPARC, 0x08, 5)
+MyClassA(BC_IA64, 0x04, 1)
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchRegister.cpp
new file mode 100644
index 000000000..380828c6d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/BranchRegister.cpp
@@ -0,0 +1,30 @@
+// BranchRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "BranchMisc.h"
+
+#define CREATE_CODEC(x) \
+ static void *CreateCodec ## x() { return (void *)(ICompressFilter *)(new C ## x ## _Decoder); } \
+ static void *CreateCodec ## x ## Out() { return (void *)(ICompressFilter *)(new C ## x ## _Encoder); }
+
+CREATE_CODEC(BC_PPC)
+CREATE_CODEC(BC_IA64)
+CREATE_CODEC(BC_ARM)
+CREATE_CODEC(BC_ARMT)
+CREATE_CODEC(BC_SPARC)
+
+#define METHOD_ITEM(x, id1, id2, name) { CreateCodec ## x, CreateCodec ## x ## Out, 0x03030000 + (id1 * 256) + id2, name, 1, true }
+
+static CCodecInfo g_CodecsInfo[] =
+{
+ METHOD_ITEM(BC_PPC, 0x02, 0x05, L"PPC"),
+ METHOD_ITEM(BC_IA64, 0x04, 1, L"IA64"),
+ METHOD_ITEM(BC_ARM, 0x05, 1, L"ARM"),
+ METHOD_ITEM(BC_ARMT, 0x07, 1, L"ARMT"),
+ METHOD_ITEM(BC_SPARC, 0x08, 0x05, L"SPARC")
+};
+
+REGISTER_CODECS(Branch)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ByteSwap.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ByteSwap.cpp
new file mode 100644
index 000000000..645b6ffcd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ByteSwap.cpp
@@ -0,0 +1,73 @@
+// ByteSwap.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/RegisterCodec.h"
+
+class CByteSwap2:
+ public ICompressFilter,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+};
+
+class CByteSwap4:
+ public ICompressFilter,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+};
+
+STDMETHODIMP CByteSwap2::Init() { return S_OK; }
+
+STDMETHODIMP_(UInt32) CByteSwap2::Filter(Byte *data, UInt32 size)
+{
+ const UInt32 kStep = 2;
+ UInt32 i;
+ for (i = 0; i + kStep <= size; i += kStep)
+ {
+ Byte b = data[i];
+ data[i] = data[i + 1];
+ data[i + 1] = b;
+ }
+ return i;
+}
+
+STDMETHODIMP CByteSwap4::Init() { return S_OK; }
+
+STDMETHODIMP_(UInt32) CByteSwap4::Filter(Byte *data, UInt32 size)
+{
+ const UInt32 kStep = 4;
+ UInt32 i;
+ for (i = 0; i + kStep <= size; i += kStep)
+ {
+ Byte b0 = data[i];
+ Byte b1 = data[i + 1];
+ data[i] = data[i + 3];
+ data[i + 1] = data[i + 2];
+ data[i + 2] = b1;
+ data[i + 3] = b0;
+ }
+ return i;
+}
+
+static void *CreateCodec2() { return (void *)(ICompressFilter *)(new CByteSwap2); }
+static void *CreateCodec4() { return (void *)(ICompressFilter *)(new CByteSwap4); }
+
+static CCodecInfo g_CodecsInfo[] =
+{
+ { CreateCodec2, CreateCodec2, 0x020302, L"Swap2", 1, true },
+ { CreateCodec4, CreateCodec4, 0x020304, L"Swap4", 1, true }
+};
+
+REGISTER_CODECS(ByteSwap)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CodecExports.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CodecExports.cpp
new file mode 100644
index 000000000..4ff1c0fcb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CodecExports.cpp
@@ -0,0 +1,160 @@
+// CodecExports.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/ComTry.h"
+
+#include "../../Windows/PropVariant.h"
+
+#include "../ICoder.h"
+
+#include "../Common/RegisterCodec.h"
+
+extern unsigned int g_NumCodecs;
+extern const CCodecInfo *g_Codecs[];
+
+static const UInt16 kDecodeId = 0x2790;
+
+DEFINE_GUID(CLSID_CCodec,
+0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+static inline HRESULT SetPropString(const char *s, unsigned int size, PROPVARIANT *value)
+{
+ if ((value->bstrVal = ::SysAllocStringByteLen(s, size)) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+}
+
+static inline HRESULT SetPropGUID(const GUID &guid, PROPVARIANT *value)
+{
+ return SetPropString((const char *)&guid, sizeof(GUID), value);
+}
+
+static HRESULT SetClassID(CMethodId id, bool encode, PROPVARIANT *value)
+{
+ GUID clsId = CLSID_CCodec;
+ for (int i = 0; i < sizeof(id); i++, id >>= 8)
+ clsId.Data4[i] = (Byte)(id & 0xFF);
+ if (encode)
+ clsId.Data3++;
+ return SetPropGUID(clsId, value);
+}
+
+static HRESULT FindCodecClassId(const GUID *clsID, UInt32 isCoder2, bool isFilter, bool &encode, int &index)
+{
+ index = -1;
+ if (clsID->Data1 != CLSID_CCodec.Data1 ||
+ clsID->Data2 != CLSID_CCodec.Data2 ||
+ (clsID->Data3 & ~1) != kDecodeId)
+ return S_OK;
+ encode = (clsID->Data3 != kDecodeId);
+ UInt64 id = 0;
+ for (int j = 0; j < 8; j++)
+ id |= ((UInt64)clsID->Data4[j]) << (8 * j);
+ for (unsigned i = 0; i < g_NumCodecs; i++)
+ {
+ const CCodecInfo &codec = *g_Codecs[i];
+ if (id != codec.Id || encode && !codec.CreateEncoder || !encode && !codec.CreateDecoder)
+ continue;
+ if (!isFilter && codec.IsFilter || isFilter && !codec.IsFilter ||
+ codec.NumInStreams != 1 && !isCoder2 || codec.NumInStreams == 1 && isCoder2)
+ return E_NOINTERFACE;
+ index = i;
+ return S_OK;
+ }
+ return S_OK;
+}
+
+STDAPI CreateCoder2(bool encode, UInt32 index, const GUID *iid, void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ bool isCoder = (*iid == IID_ICompressCoder) != 0;
+ bool isCoder2 = (*iid == IID_ICompressCoder2) != 0;
+ bool isFilter = (*iid == IID_ICompressFilter) != 0;
+ const CCodecInfo &codec = *g_Codecs[index];
+ if (!isFilter && codec.IsFilter || isFilter && !codec.IsFilter ||
+ codec.NumInStreams != 1 && !isCoder2 || codec.NumInStreams == 1 && isCoder2)
+ return E_NOINTERFACE;
+ if (encode)
+ {
+ if (!codec.CreateEncoder)
+ return CLASS_E_CLASSNOTAVAILABLE;
+ *outObject = codec.CreateEncoder();
+ }
+ else
+ {
+ if (!codec.CreateDecoder)
+ return CLASS_E_CLASSNOTAVAILABLE;
+ *outObject = codec.CreateDecoder();
+ }
+ if (isCoder)
+ ((ICompressCoder *)*outObject)->AddRef();
+ else if (isCoder2)
+ ((ICompressCoder2 *)*outObject)->AddRef();
+ else
+ ((ICompressFilter *)*outObject)->AddRef();
+ return S_OK;
+ COM_TRY_END
+}
+
+STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ *outObject = 0;
+ bool isCoder = (*iid == IID_ICompressCoder) != 0;
+ bool isCoder2 = (*iid == IID_ICompressCoder2) != 0;
+ bool isFilter = (*iid == IID_ICompressFilter) != 0;
+ if (!isCoder && !isCoder2 && !isFilter)
+ return E_NOINTERFACE;
+ bool encode;
+ int codecIndex;
+ HRESULT res = FindCodecClassId(clsid, isCoder2, isFilter, encode, codecIndex);
+ if (res != S_OK)
+ return res;
+ if (codecIndex < 0)
+ return CLASS_E_CLASSNOTAVAILABLE;
+ return CreateCoder2(encode, codecIndex, iid, outObject);
+}
+
+STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
+{
+ ::VariantClear((VARIANTARG *)value);
+ const CCodecInfo &codec = *g_Codecs[codecIndex];
+ switch(propID)
+ {
+ case NMethodPropID::kID:
+ {
+ value->uhVal.QuadPart = (UInt64)codec.Id;
+ value->vt = VT_UI8;
+ break;
+ }
+ case NMethodPropID::kName:
+ if ((value->bstrVal = ::SysAllocString(codec.Name)) != 0)
+ value->vt = VT_BSTR;
+ break;
+ case NMethodPropID::kDecoder:
+ if (codec.CreateDecoder)
+ return SetClassID(codec.Id, false, value);
+ break;
+ case NMethodPropID::kEncoder:
+ if (codec.CreateEncoder)
+ return SetClassID(codec.Id, true, value);
+ break;
+ case NMethodPropID::kInStreams:
+ {
+ if (codec.NumInStreams != 1)
+ {
+ value->vt = VT_UI4;
+ value->ulVal = (ULONG)codec.NumInStreams;
+ }
+ break;
+ }
+ }
+ return S_OK;
+}
+
+STDAPI GetNumberOfMethods(UINT32 *numCodecs)
+{
+ *numCodecs = g_NumCodecs;
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyCoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyCoder.cpp
new file mode 100644
index 000000000..f71692a77
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyCoder.cpp
@@ -0,0 +1,67 @@
+// Compress/CopyCoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "../Common/StreamUtils.h"
+
+#include "CopyCoder.h"
+
+namespace NCompress {
+
+static const UInt32 kBufferSize = 1 << 17;
+
+CCopyCoder::~CCopyCoder()
+{
+ ::MidFree(_buffer);
+}
+
+STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ if (_buffer == 0)
+ {
+ _buffer = (Byte *)::MidAlloc(kBufferSize);
+ if (_buffer == 0)
+ return E_OUTOFMEMORY;
+ }
+
+ TotalSize = 0;
+ for (;;)
+ {
+ UInt32 size = kBufferSize;
+ if (outSize != 0)
+ if (size > *outSize - TotalSize)
+ size = (UInt32)(*outSize - TotalSize);
+ RINOK(inStream->Read(_buffer, size, &size));
+ if (size == 0)
+ break;
+ if (outStream)
+ {
+ RINOK(WriteStream(outStream, _buffer, size));
+ }
+ TotalSize += size;
+ if (progress != NULL)
+ {
+ RINOK(progress->SetRatioInfo(&TotalSize, &TotalSize));
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CCopyCoder::GetInStreamProcessedSize(UInt64 *value)
+{
+ *value = TotalSize;
+ return S_OK;
+}
+
+HRESULT CopyStream(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress)
+{
+ CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
+ return copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyCoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyCoder.h
new file mode 100644
index 000000000..751c7d711
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyCoder.h
@@ -0,0 +1,34 @@
+// Compress/CopyCoder.h
+
+#ifndef __COMPRESS_COPY_CODER_H
+#define __COMPRESS_COPY_CODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+namespace NCompress {
+
+class CCopyCoder:
+ public ICompressCoder,
+ public ICompressGetInStreamProcessedSize,
+ public CMyUnknownImp
+{
+ Byte *_buffer;
+public:
+ UInt64 TotalSize;
+ CCopyCoder(): _buffer(0), TotalSize(0) {}
+ ~CCopyCoder();
+
+ MY_UNKNOWN_IMP1(ICompressGetInStreamProcessedSize)
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+ STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
+};
+
+HRESULT CopyStream(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress);
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyRegister.cpp
new file mode 100644
index 000000000..efb9b9e95
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/CopyRegister.cpp
@@ -0,0 +1,14 @@
+// CopyRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "CopyCoder.h"
+
+static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::CCopyCoder); }
+
+static CCodecInfo g_CodecInfo =
+{ CreateCodec, CreateCodec, 0x00, L"Copy", 1, false };
+
+REGISTER_CODEC(Copy)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Deflate64Register.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Deflate64Register.cpp
new file mode 100644
index 000000000..509e675a5
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Deflate64Register.cpp
@@ -0,0 +1,20 @@
+// Deflate64Register.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "DeflateDecoder.h"
+
+static void *CreateCodecDeflate64() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CCOMCoder64); }
+#if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY)
+#include "DeflateEncoder.h"
+static void *CreateCodecOutDeflate64() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NEncoder::CCOMCoder64); }
+#else
+#define CreateCodecOutDeflate64 0
+#endif
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodecDeflate64, CreateCodecOutDeflate64, 0x040109, L"Deflate64", 1, false };
+
+REGISTER_CODEC(Deflate64)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateConst.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateConst.h
new file mode 100644
index 000000000..9ca9c869b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateConst.h
@@ -0,0 +1,134 @@
+// DeflateConst.h
+
+#ifndef __DEFLATE_CONST_H
+#define __DEFLATE_CONST_H
+
+namespace NCompress {
+namespace NDeflate {
+
+const int kNumHuffmanBits = 15;
+
+const UInt32 kHistorySize32 = (1 << 15);
+const UInt32 kHistorySize64 = (1 << 16);
+
+const UInt32 kDistTableSize32 = 30;
+const UInt32 kDistTableSize64 = 32;
+
+const UInt32 kNumLenSymbols32 = 256;
+const UInt32 kNumLenSymbols64 = 255; // don't change it. It must be <= 255.
+const UInt32 kNumLenSymbolsMax = kNumLenSymbols32;
+
+const UInt32 kNumLenSlots = 29;
+
+const UInt32 kFixedDistTableSize = 32;
+const UInt32 kFixedLenTableSize = 31;
+
+const UInt32 kSymbolEndOfBlock = 0x100;
+const UInt32 kSymbolMatch = kSymbolEndOfBlock + 1;
+
+const UInt32 kMainTableSize = kSymbolMatch + kNumLenSlots;
+const UInt32 kFixedMainTableSize = kSymbolMatch + kFixedLenTableSize;
+
+const UInt32 kLevelTableSize = 19;
+
+const UInt32 kTableDirectLevels = 16;
+const UInt32 kTableLevelRepNumber = kTableDirectLevels;
+const UInt32 kTableLevel0Number = kTableLevelRepNumber + 1;
+const UInt32 kTableLevel0Number2 = kTableLevel0Number + 1;
+
+const UInt32 kLevelMask = 0xF;
+
+const Byte kLenStart32[kFixedLenTableSize] =
+ {0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224, 255, 0, 0};
+const Byte kLenStart64[kFixedLenTableSize] =
+ {0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224, 0, 0, 0};
+
+const Byte kLenDirectBits32[kFixedLenTableSize] =
+ {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};
+const Byte kLenDirectBits64[kFixedLenTableSize] =
+ {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, 16, 0, 0};
+
+const UInt32 kDistStart[kDistTableSize64] =
+ {0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,
+ 1024,1536,2048,3072,4096,6144,8192,12288,16384,24576,32768,49152};
+const Byte kDistDirectBits[kDistTableSize64] =
+ {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,14,14};
+
+const Byte kLevelDirectBits[3] = {2, 3, 7};
+
+const Byte kCodeLengthAlphabetOrder[kLevelTableSize] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
+
+const UInt32 kMatchMinLen = 3;
+const UInt32 kMatchMaxLen32 = kNumLenSymbols32 + kMatchMinLen - 1; //256 + 2
+const UInt32 kMatchMaxLen64 = kNumLenSymbols64 + kMatchMinLen - 1; //255 + 2
+const UInt32 kMatchMaxLen = kMatchMaxLen32;
+
+const int kFinalBlockFieldSize = 1;
+
+namespace NFinalBlockField
+{
+ enum
+ {
+ kNotFinalBlock = 0,
+ kFinalBlock = 1
+ };
+}
+
+const int kBlockTypeFieldSize = 2;
+
+namespace NBlockType
+{
+ enum
+ {
+ kStored = 0,
+ kFixedHuffman = 1,
+ kDynamicHuffman = 2
+ };
+}
+
+const int kNumLenCodesFieldSize = 5;
+const int kNumDistCodesFieldSize = 5;
+const int kNumLevelCodesFieldSize = 4;
+
+const UInt32 kNumLitLenCodesMin = 257;
+const UInt32 kNumDistCodesMin = 1;
+const UInt32 kNumLevelCodesMin = 4;
+
+const int kLevelFieldSize = 3;
+
+const int kStoredBlockLengthFieldSize = 16;
+
+struct CLevels
+{
+ Byte litLenLevels[kFixedMainTableSize];
+ Byte distLevels[kFixedDistTableSize];
+
+ void SubClear()
+ {
+ UInt32 i;
+ for(i = kNumLitLenCodesMin; i < kFixedMainTableSize; i++)
+ litLenLevels[i] = 0;
+ for(i = 0; i < kFixedDistTableSize; i++)
+ distLevels[i] = 0;
+ }
+
+ void SetFixedLevels()
+ {
+ unsigned int i;
+
+ for (i = 0; i < 144; i++)
+ litLenLevels[i] = 8;
+ for (; i < 256; i++)
+ litLenLevels[i] = 9;
+ for (; i < 280; i++)
+ litLenLevels[i] = 7;
+ for (; i < 288; i++)
+ litLenLevels[i] = 8;
+ for (i = 0; i < kFixedDistTableSize; i++) // test it: InfoZip only uses kDistTableSize
+ distLevels[i] = 5;
+ }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateDecoder.cpp
new file mode 100644
index 000000000..92d113b26
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateDecoder.cpp
@@ -0,0 +1,353 @@
+// DeflateDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "DeflateDecoder.h"
+
+namespace NCompress {
+namespace NDeflate {
+namespace NDecoder {
+
+static const int kLenIdFinished = -1;
+static const int kLenIdNeedInit = -2;
+
+CCoder::CCoder(bool deflate64Mode, bool deflateNSIS):
+ _deflateNSIS(deflateNSIS),
+ _deflate64Mode(deflate64Mode),
+ _keepHistory(false),
+ _needInitInStream(true),
+ ZlibMode(false) {}
+
+UInt32 CCoder::ReadBits(int numBits)
+{
+ return m_InBitStream.ReadBits(numBits);
+}
+
+bool CCoder::DeCodeLevelTable(Byte *values, int numSymbols)
+{
+ int i = 0;
+ do
+ {
+ UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < kTableDirectLevels)
+ values[i++] = (Byte)number;
+ else if (number < kLevelTableSize)
+ {
+ if (number == kTableLevelRepNumber)
+ {
+ if (i == 0)
+ return false;
+ int num = ReadBits(2) + 3;
+ for (; num > 0 && i < numSymbols; num--, i++)
+ values[i] = values[i - 1];
+ }
+ else
+ {
+ int num;
+ if (number == kTableLevel0Number)
+ num = ReadBits(3) + 3;
+ else
+ num = ReadBits(7) + 11;
+ for (;num > 0 && i < numSymbols; num--)
+ values[i++] = 0;
+ }
+ }
+ else
+ return false;
+ }
+ while(i < numSymbols);
+ return true;
+}
+
+#define RIF(x) { if (!(x)) return false; }
+
+bool CCoder::ReadTables(void)
+{
+ m_FinalBlock = (ReadBits(kFinalBlockFieldSize) == NFinalBlockField::kFinalBlock);
+ UInt32 blockType = ReadBits(kBlockTypeFieldSize);
+ if (blockType > NBlockType::kDynamicHuffman)
+ return false;
+
+ if (blockType == NBlockType::kStored)
+ {
+ m_StoredMode = true;
+ m_InBitStream.AlignToByte();
+ m_StoredBlockSize = ReadBits(kStoredBlockLengthFieldSize);
+ if (_deflateNSIS)
+ return true;
+ return (m_StoredBlockSize == (UInt16)~ReadBits(kStoredBlockLengthFieldSize));
+ }
+
+ m_StoredMode = false;
+
+ CLevels levels;
+ if (blockType == NBlockType::kFixedHuffman)
+ {
+ levels.SetFixedLevels();
+ _numDistLevels = _deflate64Mode ? kDistTableSize64 : kDistTableSize32;
+ }
+ else
+ {
+ int numLitLenLevels = ReadBits(kNumLenCodesFieldSize) + kNumLitLenCodesMin;
+ _numDistLevels = ReadBits(kNumDistCodesFieldSize) + kNumDistCodesMin;
+ int numLevelCodes = ReadBits(kNumLevelCodesFieldSize) + kNumLevelCodesMin;
+
+ if (!_deflate64Mode)
+ if (_numDistLevels > kDistTableSize32)
+ return false;
+
+ Byte levelLevels[kLevelTableSize];
+ for (int i = 0; i < static_cast< int >( kLevelTableSize ); i++)
+ {
+ int position = kCodeLengthAlphabetOrder[i];
+ if(i < numLevelCodes)
+ levelLevels[position] = (Byte)ReadBits(kLevelFieldSize);
+ else
+ levelLevels[position] = 0;
+ }
+
+ RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
+
+ Byte tmpLevels[kFixedMainTableSize + kFixedDistTableSize];
+ if (!DeCodeLevelTable(tmpLevels, numLitLenLevels + _numDistLevels))
+ return false;
+
+ levels.SubClear();
+ memcpy(levels.litLenLevels, tmpLevels, numLitLenLevels);
+ memcpy(levels.distLevels, tmpLevels + numLitLenLevels, _numDistLevels);
+ }
+ RIF(m_MainDecoder.SetCodeLengths(levels.litLenLevels));
+ return m_DistDecoder.SetCodeLengths(levels.distLevels);
+}
+
+HRESULT CCoder::CodeSpec(UInt32 curSize)
+{
+ if (_remainLen == kLenIdFinished)
+ return S_OK;
+ if (_remainLen == kLenIdNeedInit)
+ {
+ if (!_keepHistory)
+ if (!m_OutWindowStream.Create(_deflate64Mode ? kHistorySize64: kHistorySize32))
+ return E_OUTOFMEMORY;
+ RINOK(InitInStream(_needInitInStream));
+ m_OutWindowStream.Init(_keepHistory);
+ m_FinalBlock = false;
+ _remainLen = 0;
+ _needReadTable = true;
+ }
+
+ if (curSize == 0)
+ return S_OK;
+
+ while(_remainLen > 0 && curSize > 0)
+ {
+ _remainLen--;
+ Byte b = m_OutWindowStream.GetByte(_rep0);
+ m_OutWindowStream.PutByte(b);
+ curSize--;
+ }
+
+ while(curSize > 0)
+ {
+ if (_needReadTable)
+ {
+ if (m_FinalBlock)
+ {
+ _remainLen = kLenIdFinished;
+ break;
+ }
+ if (!ReadTables())
+ return S_FALSE;
+ _needReadTable = false;
+ }
+
+ if(m_StoredMode)
+ {
+ for (; m_StoredBlockSize > 0 && curSize > 0; m_StoredBlockSize--, curSize--)
+ m_OutWindowStream.PutByte(m_InBitStream.ReadByte());
+ _needReadTable = (m_StoredBlockSize == 0);
+ continue;
+ }
+ while(curSize > 0)
+ {
+ if (m_InBitStream.NumExtraBytes > 4)
+ return S_FALSE;
+
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < 0x100)
+ {
+ m_OutWindowStream.PutByte((Byte)number);
+ curSize--;
+ continue;
+ }
+ else if (number == kSymbolEndOfBlock)
+ {
+ _needReadTable = true;
+ break;
+ }
+ else if (number < kMainTableSize)
+ {
+ number -= kSymbolMatch;
+ UInt32 len;
+ {
+ int numBits;
+ if (_deflate64Mode)
+ {
+ len = kLenStart64[number];
+ numBits = kLenDirectBits64[number];
+ }
+ else
+ {
+ len = kLenStart32[number];
+ numBits = kLenDirectBits32[number];
+ }
+ len += kMatchMinLen + m_InBitStream.ReadBits(numBits);
+ }
+ UInt32 locLen = len;
+ if (locLen > curSize)
+ locLen = (UInt32)curSize;
+ number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
+ if (number >= _numDistLevels)
+ return S_FALSE;
+ UInt32 distance = kDistStart[number] + m_InBitStream.ReadBits(kDistDirectBits[number]);
+ if (!m_OutWindowStream.CopyBlock(distance, locLen))
+ return S_FALSE;
+ curSize -= locLen;
+ len -= locLen;
+ if (len != 0)
+ {
+ _remainLen = (Int32)len;
+ _rep0 = distance;
+ break;
+ }
+ }
+ else
+ return S_FALSE;
+ }
+ }
+ return S_OK;
+}
+
+#ifdef _NO_EXCEPTIONS
+
+#define DEFLATE_TRY_BEGIN
+#define DEFLATE_TRY_END
+
+#else
+
+#define DEFLATE_TRY_BEGIN try {
+#define DEFLATE_TRY_END } \
+ catch(const CInBufferException &e) { return e.ErrorCode; } \
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; } \
+ catch(...) { return S_FALSE; }
+
+#endif
+
+HRESULT CCoder::CodeReal(ISequentialOutStream *outStream,
+ const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ DEFLATE_TRY_BEGIN
+ m_OutWindowStream.SetStream(outStream);
+ CCoderReleaser flusher(this);
+
+ const UInt64 inStart = m_InBitStream.GetProcessedSize();
+ const UInt64 start = m_OutWindowStream.GetProcessedSize();
+ for (;;)
+ {
+ UInt32 curSize = 1 << 18;
+ if (outSize != 0)
+ {
+ const UInt64 rem = *outSize - (m_OutWindowStream.GetProcessedSize() - start);
+ if (curSize > rem)
+ curSize = (UInt32)rem;
+ }
+ if (curSize == 0)
+ break;
+ RINOK(CodeSpec(curSize));
+ if (_remainLen == kLenIdFinished)
+ break;
+ if (progress != NULL)
+ {
+ const UInt64 inSize = m_InBitStream.GetProcessedSize() - inStart;
+ const UInt64 nowPos64 = m_OutWindowStream.GetProcessedSize() - start;
+ RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
+ }
+ }
+ if (_remainLen == kLenIdFinished && ZlibMode)
+ {
+ m_InBitStream.AlignToByte();
+ for (int i = 0; i < 4; i++)
+ ZlibFooter[i] = m_InBitStream.ReadByte();
+ }
+ flusher.NeedFlush = false;
+ HRESULT res = Flush();
+ if (res == S_OK && InputEofError())
+ return S_FALSE;
+ return res;
+ DEFLATE_TRY_END
+}
+
+HRESULT CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ SetInStream(inStream);
+ SetOutStreamSize(outSize);
+ HRESULT res = CodeReal(outStream, outSize, progress);
+ ReleaseInStream();
+ return res;
+}
+
+STDMETHODIMP CCoder::GetInStreamProcessedSize(UInt64 *value)
+{
+ if (value == NULL)
+ return E_INVALIDARG;
+ *value = m_InBitStream.GetProcessedSize();
+ return S_OK;
+}
+
+STDMETHODIMP CCoder::SetInStream(ISequentialInStream *inStream)
+{
+ m_InBitStream.SetStream(inStream);
+ return S_OK;
+}
+
+STDMETHODIMP CCoder::ReleaseInStream()
+{
+ m_InBitStream.ReleaseStream();
+ return S_OK;
+}
+
+STDMETHODIMP CCoder::SetOutStreamSize(const UInt64 * /* outSize */)
+{
+ _remainLen = kLenIdNeedInit;
+ _needInitInStream = true;
+ m_OutWindowStream.Init(_keepHistory);
+ return S_OK;
+}
+
+#ifndef NO_READ_FROM_CODER
+
+STDMETHODIMP CCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ DEFLATE_TRY_BEGIN
+ if (processedSize)
+ *processedSize = 0;
+ const UInt64 startPos = m_OutWindowStream.GetProcessedSize();
+ m_OutWindowStream.SetMemStream((Byte *)data);
+ RINOK(CodeSpec(size));
+ if (processedSize)
+ *processedSize = (UInt32)(m_OutWindowStream.GetProcessedSize() - startPos);
+ return Flush();
+ DEFLATE_TRY_END
+}
+
+#endif
+
+STDMETHODIMP CCoder::CodeResume(ISequentialOutStream *outStream, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ _remainLen = kLenIdNeedInit;
+ m_OutWindowStream.Init(_keepHistory);
+ return CodeReal(outStream, outSize, progress);
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateDecoder.h
new file mode 100644
index 000000000..56ab2bea2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateDecoder.h
@@ -0,0 +1,157 @@
+// DeflateDecoder.h
+
+#ifndef __DEFLATE_DECODER_H
+#define __DEFLATE_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "BitlDecoder.h"
+#include "DeflateConst.h"
+#include "HuffmanDecoder.h"
+#include "LzOutWindow.h"
+
+namespace NCompress {
+namespace NDeflate {
+namespace NDecoder {
+
+class CCoder:
+ public ICompressCoder,
+ public ICompressGetInStreamProcessedSize,
+ #ifndef NO_READ_FROM_CODER
+ public ICompressSetInStream,
+ public ICompressSetOutStreamSize,
+ public ISequentialInStream,
+ #endif
+ public CMyUnknownImp
+{
+ CLzOutWindow m_OutWindowStream;
+ NBitl::CDecoder<CInBuffer> m_InBitStream;
+ NCompress::NHuffman::CDecoder<kNumHuffmanBits, kFixedMainTableSize> m_MainDecoder;
+ NCompress::NHuffman::CDecoder<kNumHuffmanBits, kFixedDistTableSize> m_DistDecoder;
+ NCompress::NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
+
+ UInt32 m_StoredBlockSize;
+
+ bool m_FinalBlock;
+ bool m_StoredMode;
+ UInt32 _numDistLevels;
+
+
+ bool _deflateNSIS;
+ bool _deflate64Mode;
+ bool _keepHistory;
+ bool _needInitInStream;
+ Int32 _remainLen;
+ UInt32 _rep0;
+ bool _needReadTable;
+
+ UInt32 ReadBits(int numBits);
+
+ bool DeCodeLevelTable(Byte *values, int numSymbols);
+ bool ReadTables();
+
+ HRESULT Flush() { return m_OutWindowStream.Flush(); }
+ class CCoderReleaser
+ {
+ CCoder *_coder;
+ public:
+ bool NeedFlush;
+ CCoderReleaser(CCoder *coder): _coder(coder), NeedFlush(true) {}
+ ~CCoderReleaser()
+ {
+ if (NeedFlush)
+ _coder->Flush();
+ _coder->ReleaseOutStream();
+ }
+ };
+ friend class CCoderReleaser;
+
+ HRESULT CodeSpec(UInt32 curSize);
+public:
+ bool ZlibMode;
+ Byte ZlibFooter[4];
+
+ CCoder(bool deflate64Mode, bool deflateNSIS = false);
+ virtual ~CCoder() {};
+
+ void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
+
+ void ReleaseOutStream()
+ {
+ m_OutWindowStream.ReleaseStream();
+ }
+
+ HRESULT CodeReal(ISequentialOutStream *outStream,
+ const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ #ifndef NO_READ_FROM_CODER
+ MY_UNKNOWN_IMP4(
+ ICompressGetInStreamProcessedSize,
+ ICompressSetInStream,
+ ICompressSetOutStreamSize,
+ ISequentialInStream
+ )
+ #else
+ MY_UNKNOWN_IMP1(
+ ICompressGetInStreamProcessedSize)
+ #endif
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream);
+ STDMETHOD(ReleaseInStream)();
+ STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
+
+ #ifndef NO_READ_FROM_CODER
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ #endif
+
+ STDMETHOD(CodeResume)(ISequentialOutStream *outStream, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ HRESULT InitInStream(bool needInit)
+ {
+ if (!m_InBitStream.Create(1 << 17))
+ return E_OUTOFMEMORY;
+ if (needInit)
+ {
+ m_InBitStream.Init();
+ _needInitInStream = false;
+ }
+ return S_OK;
+ }
+
+ void AlignToByte() { m_InBitStream.AlignToByte(); }
+ Byte ReadByte() { return (Byte)m_InBitStream.ReadBits(8); }
+ bool InputEofError() const { return m_InBitStream.ExtraBitsWereRead(); }
+ UInt64 GetInputProcessedSize() const { return m_InBitStream.GetProcessedSize(); }
+
+ // IGetInStreamProcessedSize
+ STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
+};
+
+class CCOMCoder : public CCoder
+{
+public:
+ CCOMCoder(): CCoder(false) {}
+};
+
+class CNsisCOMCoder : public CCoder
+{
+public:
+ CNsisCOMCoder(): CCoder(false, true) {}
+};
+
+class CCOMCoder64 : public CCoder
+{
+public:
+ CCOMCoder64(): CCoder(true) {}
+};
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateEncoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateEncoder.cpp
new file mode 100644
index 000000000..4d040259d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateEncoder.cpp
@@ -0,0 +1,984 @@
+// DeflateEncoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+#include "../../../C/HuffEnc.h"
+
+#include "Common/ComTry.h"
+
+#include "DeflateEncoder.h"
+
+#if _MSC_VER >= 1300
+#define NO_INLINE __declspec(noinline)
+#else
+#define NO_INLINE
+#endif
+
+namespace NCompress {
+namespace NDeflate {
+namespace NEncoder {
+
+const int kNumDivPassesMax = 10; // [0, 16); ratio/speed/ram tradeoff; use big value for better compression ratio.
+const UInt32 kNumTables = (1 << kNumDivPassesMax);
+
+static UInt32 kFixedHuffmanCodeBlockSizeMax = (1 << 8); // [0, (1 << 32)); ratio/speed tradeoff; use big value for better compression ratio.
+static UInt32 kDivideCodeBlockSizeMin = (1 << 7); // [1, (1 << 32)); ratio/speed tradeoff; use small value for better compression ratio.
+static UInt32 kDivideBlockSizeMin = (1 << 6); // [1, (1 << 32)); ratio/speed tradeoff; use small value for better compression ratio.
+
+static const UInt32 kMaxUncompressedBlockSize = ((1 << 16) - 1) * 1; // [1, (1 << 32))
+static const UInt32 kMatchArraySize = kMaxUncompressedBlockSize * 10; // [kMatchMaxLen * 2, (1 << 32))
+static const UInt32 kMatchArrayLimit = kMatchArraySize - kMatchMaxLen * 4 * sizeof(UInt16);
+static const UInt32 kBlockUncompressedSizeThreshold = kMaxUncompressedBlockSize -
+ kMatchMaxLen - kNumOpts;
+
+static const int kMaxCodeBitLength = 11;
+static const int kMaxLevelBitLength = 7;
+
+static Byte kNoLiteralStatPrice = 11;
+static Byte kNoLenStatPrice = 11;
+static Byte kNoPosStatPrice = 6;
+
+static Byte g_LenSlots[kNumLenSymbolsMax];
+static Byte g_FastPos[1 << 9];
+
+class CFastPosInit
+{
+public:
+ CFastPosInit()
+ {
+ unsigned int i;
+ for(i = 0; i < kNumLenSlots; i++)
+ {
+ int c = kLenStart32[i];
+ int j = 1 << kLenDirectBits32[i];
+ for(int k = 0; k < j; k++, c++)
+ g_LenSlots[c] = (Byte)i;
+ }
+
+ const int kFastSlots = 18;
+ int c = 0;
+ for (Byte slotFast = 0; slotFast < kFastSlots; slotFast++)
+ {
+ UInt32 k = (1 << kDistDirectBits[slotFast]);
+ for (UInt32 j = 0; j < k; j++, c++)
+ g_FastPos[c] = slotFast;
+ }
+ }
+};
+
+static CFastPosInit g_FastPosInit;
+
+
+inline UInt32 GetPosSlot(UInt32 pos)
+{
+ if (pos < 0x200)
+ return g_FastPos[pos];
+ return g_FastPos[pos >> 8] + 16;
+}
+
+static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
+static void SzFree(void *p, void *address) { p = p; MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+CCoder::CCoder(bool deflate64Mode):
+ m_Values(0),
+ m_NumFastBytes(32),
+ _fastMode(false),
+ _btMode(true),
+ m_OnePosMatchesMemory(0),
+ m_DistanceMemory(0),
+ m_NumPasses(1),
+ m_NumDivPasses(1),
+ m_Created(false),
+ m_Deflate64Mode(deflate64Mode),
+ m_Tables(0),
+ m_MatchFinderCycles(0)
+ // m_SetMfPasses(0)
+{
+ m_MatchMaxLen = deflate64Mode ? kMatchMaxLen64 : kMatchMaxLen32;
+ m_NumLenCombinations = deflate64Mode ? kNumLenSymbols64 : kNumLenSymbols32;
+ m_LenStart = deflate64Mode ? kLenStart64 : kLenStart32;
+ m_LenDirectBits = deflate64Mode ? kLenDirectBits64 : kLenDirectBits32;
+ MatchFinder_Construct(&_lzInWindow);
+}
+
+HRESULT CCoder::Create()
+{
+ COM_TRY_BEGIN
+ if (m_Values == 0)
+ {
+ m_Values = (CCodeValue *)MyAlloc((kMaxUncompressedBlockSize) * sizeof(CCodeValue));
+ if (m_Values == 0)
+ return E_OUTOFMEMORY;
+ }
+ if (m_Tables == 0)
+ {
+ m_Tables = (CTables *)MyAlloc((kNumTables) * sizeof(CTables));
+ if (m_Tables == 0)
+ return E_OUTOFMEMORY;
+ }
+
+ if (m_IsMultiPass)
+ {
+ if (m_OnePosMatchesMemory == 0)
+ {
+ m_OnePosMatchesMemory = (UInt16 *)::MidAlloc(kMatchArraySize * sizeof(UInt16));
+ if (m_OnePosMatchesMemory == 0)
+ return E_OUTOFMEMORY;
+ }
+ }
+ else
+ {
+ if (m_DistanceMemory == 0)
+ {
+ m_DistanceMemory = (UInt16 *)MyAlloc((kMatchMaxLen + 2) * 2 * sizeof(UInt16));
+ if (m_DistanceMemory == 0)
+ return E_OUTOFMEMORY;
+ m_MatchDistances = m_DistanceMemory;
+ }
+ }
+
+ if (!m_Created)
+ {
+ _lzInWindow.btMode = _btMode ? 1 : 0;
+ _lzInWindow.numHashBytes = 3;
+ if (!MatchFinder_Create(&_lzInWindow,
+ m_Deflate64Mode ? kHistorySize64 : kHistorySize32,
+ kNumOpts + kMaxUncompressedBlockSize,
+ m_NumFastBytes, m_MatchMaxLen - m_NumFastBytes, &g_Alloc))
+ return E_OUTOFMEMORY;
+ if (!m_OutStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ }
+ if (m_MatchFinderCycles != 0)
+ _lzInWindow.cutValue = m_MatchFinderCycles;
+ m_Created = true;
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
+{
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ const PROPVARIANT &prop = props[i];
+ switch(propIDs[i])
+ {
+ case NCoderPropID::kNumPasses:
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ m_NumDivPasses = prop.ulVal;
+ if (m_NumDivPasses == 0)
+ m_NumDivPasses = 1;
+ if (m_NumDivPasses == 1)
+ m_NumPasses = 1;
+ else if (m_NumDivPasses <= kNumDivPassesMax)
+ m_NumPasses = 2;
+ else
+ {
+ m_NumPasses = 2 + (m_NumDivPasses - kNumDivPassesMax);
+ m_NumDivPasses = kNumDivPassesMax;
+ }
+ break;
+ case NCoderPropID::kNumFastBytes:
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ m_NumFastBytes = prop.ulVal;
+ if(m_NumFastBytes < kMatchMinLen || m_NumFastBytes > m_MatchMaxLen)
+ return E_INVALIDARG;
+ break;
+ case NCoderPropID::kMatchFinderCycles:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ m_MatchFinderCycles = prop.ulVal;
+ break;
+ }
+ case NCoderPropID::kAlgorithm:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 maximize = prop.ulVal;
+ _fastMode = (maximize == 0);
+ _btMode = !_fastMode;
+ break;
+ }
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ return S_OK;
+}
+
+void CCoder::Free()
+{
+ ::MidFree(m_OnePosMatchesMemory); m_OnePosMatchesMemory = 0;
+ ::MyFree(m_DistanceMemory); m_DistanceMemory = 0;
+ ::MyFree(m_Values); m_Values = 0;
+ ::MyFree(m_Tables); m_Tables = 0;
+}
+
+CCoder::~CCoder()
+{
+ Free();
+ MatchFinder_Free(&_lzInWindow, &g_Alloc);
+}
+
+NO_INLINE void CCoder::GetMatches()
+{
+ if (m_IsMultiPass)
+ {
+ m_MatchDistances = m_OnePosMatchesMemory + m_Pos;
+ if (m_SecondPass)
+ {
+ m_Pos += *m_MatchDistances + 1;
+ return;
+ }
+ }
+
+ UInt32 distanceTmp[kMatchMaxLen * 2 + 3];
+
+ UInt32 numPairs = (_btMode) ?
+ Bt3Zip_MatchFinder_GetMatches(&_lzInWindow, distanceTmp):
+ Hc3Zip_MatchFinder_GetMatches(&_lzInWindow, distanceTmp);
+
+ *m_MatchDistances = (UInt16)numPairs;
+
+ if (numPairs > 0)
+ {
+ UInt32 i;
+ for(i = 0; i < numPairs; i += 2)
+ {
+ m_MatchDistances[i + 1] = (UInt16)distanceTmp[i];
+ m_MatchDistances[i + 2] = (UInt16)distanceTmp[i + 1];
+ }
+ UInt32 len = distanceTmp[numPairs - 2];
+ if (len == m_NumFastBytes && m_NumFastBytes != m_MatchMaxLen)
+ {
+ UInt32 numAvail = Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) + 1;
+ const Byte *pby = Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow) - 1;
+ const Byte *pby2 = pby - (distanceTmp[numPairs - 1] + 1);
+ if (numAvail > m_MatchMaxLen)
+ numAvail = m_MatchMaxLen;
+ for (; len < numAvail && pby[len] == pby2[len]; len++);
+ m_MatchDistances[i - 1] = (UInt16)len;
+ }
+ }
+ if (m_IsMultiPass)
+ m_Pos += numPairs + 1;
+ if (!m_SecondPass)
+ m_AdditionalOffset++;
+}
+
+void CCoder::MovePos(UInt32 num)
+{
+ if (!m_SecondPass && num > 0)
+ {
+ if (_btMode)
+ Bt3Zip_MatchFinder_Skip(&_lzInWindow, num);
+ else
+ Hc3Zip_MatchFinder_Skip(&_lzInWindow, num);
+ m_AdditionalOffset += num;
+ }
+}
+
+static const UInt32 kIfinityPrice = 0xFFFFFFF;
+
+NO_INLINE UInt32 CCoder::Backward(UInt32 &backRes, UInt32 cur)
+{
+ m_OptimumEndIndex = cur;
+ UInt32 posMem = m_Optimum[cur].PosPrev;
+ UInt16 backMem = m_Optimum[cur].BackPrev;
+ do
+ {
+ UInt32 posPrev = posMem;
+ UInt16 backCur = backMem;
+ backMem = m_Optimum[posPrev].BackPrev;
+ posMem = m_Optimum[posPrev].PosPrev;
+ m_Optimum[posPrev].BackPrev = backCur;
+ m_Optimum[posPrev].PosPrev = (UInt16)cur;
+ cur = posPrev;
+ }
+ while(cur > 0);
+ backRes = m_Optimum[0].BackPrev;
+ m_OptimumCurrentIndex = m_Optimum[0].PosPrev;
+ return m_OptimumCurrentIndex;
+}
+
+NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
+{
+ if(m_OptimumEndIndex != m_OptimumCurrentIndex)
+ {
+ UInt32 len = m_Optimum[m_OptimumCurrentIndex].PosPrev - m_OptimumCurrentIndex;
+ backRes = m_Optimum[m_OptimumCurrentIndex].BackPrev;
+ m_OptimumCurrentIndex = m_Optimum[m_OptimumCurrentIndex].PosPrev;
+ return len;
+ }
+ m_OptimumCurrentIndex = m_OptimumEndIndex = 0;
+
+ GetMatches();
+
+ UInt32 numDistancePairs = m_MatchDistances[0];
+ if(numDistancePairs == 0)
+ return 1;
+
+ const UInt16 *matchDistances = m_MatchDistances + 1;
+ UInt32 lenMain = matchDistances[numDistancePairs - 2];
+
+ if(lenMain > m_NumFastBytes)
+ {
+ backRes = matchDistances[numDistancePairs - 1];
+ MovePos(lenMain - 1);
+ return lenMain;
+ }
+ m_Optimum[1].Price = m_LiteralPrices[Inline_MatchFinder_GetIndexByte(&_lzInWindow, 0 - m_AdditionalOffset)];
+ m_Optimum[1].PosPrev = 0;
+
+ m_Optimum[2].Price = kIfinityPrice;
+ m_Optimum[2].PosPrev = 1;
+
+
+ UInt32 offs = 0;
+ for(UInt32 i = kMatchMinLen; i <= lenMain; i++)
+ {
+ UInt32 distance = matchDistances[offs + 1];
+ m_Optimum[i].PosPrev = 0;
+ m_Optimum[i].BackPrev = (UInt16)distance;
+ m_Optimum[i].Price = m_LenPrices[i - kMatchMinLen] + m_PosPrices[GetPosSlot(distance)];
+ if (i == matchDistances[offs])
+ offs += 2;
+ }
+
+ UInt32 cur = 0;
+ UInt32 lenEnd = lenMain;
+ for (;;)
+ {
+ ++cur;
+ if(cur == lenEnd || cur == kNumOptsBase || m_Pos >= kMatchArrayLimit)
+ return Backward(backRes, cur);
+ GetMatches();
+ matchDistances = m_MatchDistances + 1;
+
+ UInt32 numDistancePairs = m_MatchDistances[0];
+ UInt32 newLen = 0;
+ if(numDistancePairs != 0)
+ {
+ newLen = matchDistances[numDistancePairs - 2];
+ if(newLen > m_NumFastBytes)
+ {
+ UInt32 len = Backward(backRes, cur);
+ m_Optimum[cur].BackPrev = matchDistances[numDistancePairs - 1];
+ m_OptimumEndIndex = cur + newLen;
+ m_Optimum[cur].PosPrev = (UInt16)m_OptimumEndIndex;
+ MovePos(newLen - 1);
+ return len;
+ }
+ }
+ UInt32 curPrice = m_Optimum[cur].Price;
+ UInt32 curAnd1Price = curPrice + m_LiteralPrices[Inline_MatchFinder_GetIndexByte(&_lzInWindow, cur - m_AdditionalOffset)];
+ COptimal &optimum = m_Optimum[cur + 1];
+ if (curAnd1Price < optimum.Price)
+ {
+ optimum.Price = curAnd1Price;
+ optimum.PosPrev = (UInt16)cur;
+ }
+ if(numDistancePairs == 0)
+ continue;
+ while(lenEnd < cur + newLen)
+ m_Optimum[++lenEnd].Price = kIfinityPrice;
+ offs = 0;
+ UInt32 distance = matchDistances[offs + 1];
+ curPrice += m_PosPrices[GetPosSlot(distance)];
+ for(UInt32 lenTest = kMatchMinLen; ; lenTest++)
+ {
+ UInt32 curAndLenPrice = curPrice + m_LenPrices[lenTest - kMatchMinLen];
+ COptimal &optimum = m_Optimum[cur + lenTest];
+ if (curAndLenPrice < optimum.Price)
+ {
+ optimum.Price = curAndLenPrice;
+ optimum.PosPrev = (UInt16)cur;
+ optimum.BackPrev = (UInt16)distance;
+ }
+ if (lenTest == matchDistances[offs])
+ {
+ offs += 2;
+ if (offs == numDistancePairs)
+ break;
+ curPrice -= m_PosPrices[GetPosSlot(distance)];
+ distance = matchDistances[offs + 1];
+ curPrice += m_PosPrices[GetPosSlot(distance)];
+ }
+ }
+ }
+}
+
+UInt32 CCoder::GetOptimalFast(UInt32 &backRes)
+{
+ GetMatches();
+ UInt32 numDistancePairs = m_MatchDistances[0];
+ if (numDistancePairs == 0)
+ return 1;
+ UInt32 lenMain = m_MatchDistances[numDistancePairs - 1];
+ backRes = m_MatchDistances[numDistancePairs];
+ MovePos(lenMain - 1);
+ return lenMain;
+}
+
+void CTables::InitStructures()
+{
+ UInt32 i;
+ for(i = 0; i < 256; i++)
+ litLenLevels[i] = 8;
+ litLenLevels[i++] = 13;
+ for(;i < kFixedMainTableSize; i++)
+ litLenLevels[i] = 5;
+ for(i = 0; i < kFixedDistTableSize; i++)
+ distLevels[i] = 5;
+}
+
+NO_INLINE void CCoder::LevelTableDummy(const Byte *levels, int numLevels, UInt32 *freqs)
+{
+ int prevLen = 0xFF;
+ int nextLen = levels[0];
+ int count = 0;
+ int maxCount = 7;
+ int minCount = 4;
+ if (nextLen == 0)
+ {
+ maxCount = 138;
+ minCount = 3;
+ }
+ for (int n = 0; n < numLevels; n++)
+ {
+ int curLen = nextLen;
+ nextLen = (n < numLevels - 1) ? levels[n + 1] : 0xFF;
+ count++;
+ if (count < maxCount && curLen == nextLen)
+ continue;
+
+ if (count < minCount)
+ freqs[curLen] += (UInt32)count;
+ else if (curLen != 0)
+ {
+ if (curLen != prevLen)
+ {
+ freqs[curLen]++;
+ count--;
+ }
+ freqs[kTableLevelRepNumber]++;
+ }
+ else if (count <= 10)
+ freqs[kTableLevel0Number]++;
+ else
+ freqs[kTableLevel0Number2]++;
+
+ count = 0;
+ prevLen = curLen;
+
+ if (nextLen == 0)
+ {
+ maxCount = 138;
+ minCount = 3;
+ }
+ else if (curLen == nextLen)
+ {
+ maxCount = 6;
+ minCount = 3;
+ }
+ else
+ {
+ maxCount = 7;
+ minCount = 4;
+ }
+ }
+}
+
+NO_INLINE void CCoder::WriteBits(UInt32 value, int numBits)
+{
+ m_OutStream.WriteBits(value, numBits);
+}
+
+#define WRITE_HF2(codes, lens, i) m_OutStream.WriteBits(codes[i], lens[i])
+#define WRITE_HF(i) WriteBits(codes[i], lens[i])
+
+NO_INLINE void CCoder::LevelTableCode(const Byte *levels, int numLevels, const Byte *lens, const UInt32 *codes)
+{
+ int prevLen = 0xFF;
+ int nextLen = levels[0];
+ int count = 0;
+ int maxCount = 7;
+ int minCount = 4;
+ if (nextLen == 0)
+ {
+ maxCount = 138;
+ minCount = 3;
+ }
+ for (int n = 0; n < numLevels; n++)
+ {
+ int curLen = nextLen;
+ nextLen = (n < numLevels - 1) ? levels[n + 1] : 0xFF;
+ count++;
+ if (count < maxCount && curLen == nextLen)
+ continue;
+
+ if (count < minCount)
+ for(int i = 0; i < count; i++)
+ WRITE_HF(curLen);
+ else if (curLen != 0)
+ {
+ if (curLen != prevLen)
+ {
+ WRITE_HF(curLen);
+ count--;
+ }
+ WRITE_HF(kTableLevelRepNumber);
+ WriteBits(count - 3, 2);
+ }
+ else if (count <= 10)
+ {
+ WRITE_HF(kTableLevel0Number);
+ WriteBits(count - 3, 3);
+ }
+ else
+ {
+ WRITE_HF(kTableLevel0Number2);
+ WriteBits(count - 11, 7);
+ }
+
+ count = 0;
+ prevLen = curLen;
+
+ if (nextLen == 0)
+ {
+ maxCount = 138;
+ minCount = 3;
+ }
+ else if (curLen == nextLen)
+ {
+ maxCount = 6;
+ minCount = 3;
+ }
+ else
+ {
+ maxCount = 7;
+ minCount = 4;
+ }
+ }
+}
+
+NO_INLINE void CCoder::MakeTables(unsigned maxHuffLen)
+{
+ Huffman_Generate(mainFreqs, mainCodes, m_NewLevels.litLenLevels, kFixedMainTableSize, maxHuffLen);
+ Huffman_Generate(distFreqs, distCodes, m_NewLevels.distLevels, kDistTableSize64, maxHuffLen);
+}
+
+NO_INLINE UInt32 Huffman_GetPrice(const UInt32 *freqs, const Byte *lens, UInt32 num)
+{
+ UInt32 price = 0;
+ UInt32 i;
+ for (i = 0; i < num; i++)
+ price += lens[i] * freqs[i];
+ return price;
+};
+
+NO_INLINE UInt32 Huffman_GetPrice_Spec(const UInt32 *freqs, const Byte *lens, UInt32 num, const Byte *extraBits, UInt32 extraBase)
+{
+ return Huffman_GetPrice(freqs, lens, num) +
+ Huffman_GetPrice(freqs + extraBase, extraBits, num - extraBase);
+}
+
+NO_INLINE UInt32 CCoder::GetLzBlockPrice() const
+{
+ return
+ Huffman_GetPrice_Spec(mainFreqs, m_NewLevels.litLenLevels, kFixedMainTableSize, m_LenDirectBits, kSymbolMatch) +
+ Huffman_GetPrice_Spec(distFreqs, m_NewLevels.distLevels, kDistTableSize64, kDistDirectBits, 0);
+}
+
+NO_INLINE void CCoder::TryBlock()
+{
+ memset(mainFreqs, 0, sizeof(mainFreqs));
+ memset(distFreqs, 0, sizeof(distFreqs));
+
+ m_ValueIndex = 0;
+ UInt32 blockSize = BlockSizeRes;
+ BlockSizeRes = 0;
+ for (;;)
+ {
+ if (m_OptimumCurrentIndex == m_OptimumEndIndex)
+ {
+ if (m_Pos >= kMatchArrayLimit || BlockSizeRes >= blockSize || (!m_SecondPass &&
+ ((Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) == 0) || m_ValueIndex >= m_ValueBlockSize)))
+ break;
+ }
+ UInt32 pos;
+ UInt32 len;
+ if (_fastMode)
+ len = GetOptimalFast(pos);
+ else
+ len = GetOptimal(pos);
+ CCodeValue &codeValue = m_Values[m_ValueIndex++];
+ if (len >= kMatchMinLen)
+ {
+ UInt32 newLen = len - kMatchMinLen;
+ codeValue.Len = (UInt16)newLen;
+ mainFreqs[kSymbolMatch + g_LenSlots[newLen]]++;
+ codeValue.Pos = (UInt16)pos;
+ distFreqs[GetPosSlot(pos)]++;
+ }
+ else
+ {
+ Byte b = Inline_MatchFinder_GetIndexByte(&_lzInWindow, 0 - m_AdditionalOffset);
+ mainFreqs[b]++;
+ codeValue.SetAsLiteral();
+ codeValue.Pos = b;
+ }
+ m_AdditionalOffset -= len;
+ BlockSizeRes += len;
+ }
+ mainFreqs[kSymbolEndOfBlock]++;
+ m_AdditionalOffset += BlockSizeRes;
+ m_SecondPass = true;
+}
+
+NO_INLINE void CCoder::SetPrices(const CLevels &levels)
+{
+ if (_fastMode)
+ return;
+ UInt32 i;
+ for(i = 0; i < 256; i++)
+ {
+ Byte price = levels.litLenLevels[i];
+ m_LiteralPrices[i] = ((price != 0) ? price : kNoLiteralStatPrice);
+ }
+
+ for(i = 0; i < m_NumLenCombinations; i++)
+ {
+ UInt32 slot = g_LenSlots[i];
+ Byte price = levels.litLenLevels[kSymbolMatch + slot];
+ m_LenPrices[i] = (Byte)(((price != 0) ? price : kNoLenStatPrice) + m_LenDirectBits[slot]);
+ }
+
+ for(i = 0; i < kDistTableSize64; i++)
+ {
+ Byte price = levels.distLevels[i];
+ m_PosPrices[i] = (Byte)(((price != 0) ? price: kNoPosStatPrice) + kDistDirectBits[i]);
+ }
+}
+
+NO_INLINE void Huffman_ReverseBits(UInt32 *codes, const Byte *lens, UInt32 num)
+{
+ for (UInt32 i = 0; i < num; i++)
+ {
+ UInt32 x = codes[i];
+ x = ((x & 0x5555) << 1) | ((x & 0xAAAA) >> 1);
+ x = ((x & 0x3333) << 2) | ((x & 0xCCCC) >> 2);
+ x = ((x & 0x0F0F) << 4) | ((x & 0xF0F0) >> 4);
+ codes[i] = (((x & 0x00FF) << 8) | ((x & 0xFF00) >> 8)) >> (16 - lens[i]);
+ }
+}
+
+NO_INLINE void CCoder::WriteBlock()
+{
+ Huffman_ReverseBits(mainCodes, m_NewLevels.litLenLevels, kFixedMainTableSize);
+ Huffman_ReverseBits(distCodes, m_NewLevels.distLevels, kDistTableSize64);
+
+ for (UInt32 i = 0; i < m_ValueIndex; i++)
+ {
+ const CCodeValue &codeValue = m_Values[i];
+ if (codeValue.IsLiteral())
+ WRITE_HF2(mainCodes, m_NewLevels.litLenLevels, codeValue.Pos);
+ else
+ {
+ UInt32 len = codeValue.Len;
+ UInt32 lenSlot = g_LenSlots[len];
+ WRITE_HF2(mainCodes, m_NewLevels.litLenLevels, kSymbolMatch + lenSlot);
+ m_OutStream.WriteBits(len - m_LenStart[lenSlot], m_LenDirectBits[lenSlot]);
+ UInt32 dist = codeValue.Pos;
+ UInt32 posSlot = GetPosSlot(dist);
+ WRITE_HF2(distCodes, m_NewLevels.distLevels, posSlot);
+ m_OutStream.WriteBits(dist - kDistStart[posSlot], kDistDirectBits[posSlot]);
+ }
+ }
+ WRITE_HF2(mainCodes, m_NewLevels.litLenLevels, kSymbolEndOfBlock);
+}
+
+static UInt32 GetStorePrice(UInt32 blockSize, int bitPosition)
+{
+ UInt32 price = 0;
+ do
+ {
+ UInt32 nextBitPosition = (bitPosition + kFinalBlockFieldSize + kBlockTypeFieldSize) & 7;
+ int numBitsForAlign = nextBitPosition > 0 ? (8 - nextBitPosition): 0;
+ UInt32 curBlockSize = (blockSize < (1 << 16)) ? blockSize : (1 << 16) - 1;
+ price += kFinalBlockFieldSize + kBlockTypeFieldSize + numBitsForAlign + (2 + 2) * 8 + curBlockSize * 8;
+ bitPosition = 0;
+ blockSize -= curBlockSize;
+ }
+ while(blockSize != 0);
+ return price;
+}
+
+void CCoder::WriteStoreBlock(UInt32 blockSize, UInt32 additionalOffset, bool finalBlock)
+{
+ do
+ {
+ UInt32 curBlockSize = (blockSize < (1 << 16)) ? blockSize : (1 << 16) - 1;
+ blockSize -= curBlockSize;
+ WriteBits((finalBlock && (blockSize == 0) ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
+ WriteBits(NBlockType::kStored, kBlockTypeFieldSize);
+ m_OutStream.FlushByte();
+ WriteBits((UInt16)curBlockSize, kStoredBlockLengthFieldSize);
+ WriteBits((UInt16)~curBlockSize, kStoredBlockLengthFieldSize);
+ const Byte *data = Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow)- additionalOffset;
+ for(UInt32 i = 0; i < curBlockSize; i++)
+ m_OutStream.WriteByte(data[i]);
+ additionalOffset -= curBlockSize;
+ }
+ while(blockSize != 0);
+}
+
+NO_INLINE UInt32 CCoder::TryDynBlock(int tableIndex, UInt32 numPasses)
+{
+ CTables &t = m_Tables[tableIndex];
+ BlockSizeRes = t.BlockSizeRes;
+ UInt32 posTemp = t.m_Pos;
+ SetPrices(t);
+
+ for (UInt32 p = 0; p < numPasses; p++)
+ {
+ m_Pos = posTemp;
+ TryBlock();
+ unsigned numHuffBits =
+ (m_ValueIndex > 18000 ? 12 :
+ (m_ValueIndex > 7000 ? 11 :
+ (m_ValueIndex > 2000 ? 10 : 9)));
+ MakeTables(numHuffBits);
+ SetPrices(m_NewLevels);
+ }
+
+ (CLevels &)t = m_NewLevels;
+
+ m_NumLitLenLevels = kMainTableSize;
+ while(m_NumLitLenLevels > static_cast< int >( kNumLitLenCodesMin ) && m_NewLevels.litLenLevels[m_NumLitLenLevels - 1] == 0)
+ m_NumLitLenLevels--;
+
+ m_NumDistLevels = kDistTableSize64;
+ while(m_NumDistLevels > static_cast< int >( kNumDistCodesMin ) && m_NewLevels.distLevels[m_NumDistLevels - 1] == 0)
+ m_NumDistLevels--;
+
+ UInt32 levelFreqs[kLevelTableSize];
+ memset(levelFreqs, 0, sizeof(levelFreqs));
+
+ LevelTableDummy(m_NewLevels.litLenLevels, m_NumLitLenLevels, levelFreqs);
+ LevelTableDummy(m_NewLevels.distLevels, m_NumDistLevels, levelFreqs);
+
+ Huffman_Generate(levelFreqs, levelCodes, levelLens, kLevelTableSize, kMaxLevelBitLength);
+
+ m_NumLevelCodes = kNumLevelCodesMin;
+ for (UInt32 i = 0; i < kLevelTableSize; i++)
+ {
+ Byte level = levelLens[kCodeLengthAlphabetOrder[i]];
+ if (level > 0 && i >= m_NumLevelCodes)
+ m_NumLevelCodes = i + 1;
+ m_LevelLevels[i] = level;
+ }
+
+ return GetLzBlockPrice() +
+ Huffman_GetPrice_Spec(levelFreqs, levelLens, kLevelTableSize, kLevelDirectBits, kTableDirectLevels) +
+ kNumLenCodesFieldSize + kNumDistCodesFieldSize + kNumLevelCodesFieldSize +
+ m_NumLevelCodes * kLevelFieldSize + kFinalBlockFieldSize + kBlockTypeFieldSize;
+}
+
+NO_INLINE UInt32 CCoder::TryFixedBlock(int tableIndex)
+{
+ CTables &t = m_Tables[tableIndex];
+ BlockSizeRes = t.BlockSizeRes;
+ m_Pos = t.m_Pos;
+ m_NewLevels.SetFixedLevels();
+ SetPrices(m_NewLevels);
+ TryBlock();
+ return kFinalBlockFieldSize + kBlockTypeFieldSize + GetLzBlockPrice();
+}
+
+NO_INLINE UInt32 CCoder::GetBlockPrice(int tableIndex, int numDivPasses)
+{
+ CTables &t = m_Tables[tableIndex];
+ t.StaticMode = false;
+ UInt32 price = TryDynBlock(tableIndex, m_NumPasses);
+ t.BlockSizeRes = BlockSizeRes;
+ UInt32 numValues = m_ValueIndex;
+ UInt32 posTemp = m_Pos;
+ UInt32 additionalOffsetEnd = m_AdditionalOffset;
+
+ if (m_CheckStatic && m_ValueIndex <= kFixedHuffmanCodeBlockSizeMax)
+ {
+ const UInt32 fixedPrice = TryFixedBlock(tableIndex);
+ t.StaticMode = (fixedPrice < price);
+ if (t.StaticMode)
+ price = fixedPrice;
+ }
+
+ const UInt32 storePrice = GetStorePrice(BlockSizeRes, 0); // bitPosition
+ t.StoreMode = (storePrice <= price);
+ if (t.StoreMode)
+ price = storePrice;
+
+ t.UseSubBlocks = false;
+
+ if (numDivPasses > 1 && numValues >= kDivideCodeBlockSizeMin)
+ {
+ CTables &t0 = m_Tables[(tableIndex << 1)];
+ (CLevels &)t0 = t;
+ t0.BlockSizeRes = t.BlockSizeRes >> 1;
+ t0.m_Pos = t.m_Pos;
+ UInt32 subPrice = GetBlockPrice((tableIndex << 1), numDivPasses - 1);
+
+ UInt32 blockSize2 = t.BlockSizeRes - t0.BlockSizeRes;
+ if (t0.BlockSizeRes >= kDivideBlockSizeMin && blockSize2 >= kDivideBlockSizeMin)
+ {
+ CTables &t1 = m_Tables[(tableIndex << 1) + 1];
+ (CLevels &)t1 = t;
+ t1.BlockSizeRes = blockSize2;
+ t1.m_Pos = m_Pos;
+ m_AdditionalOffset -= t0.BlockSizeRes;
+ subPrice += GetBlockPrice((tableIndex << 1) + 1, numDivPasses - 1);
+ t.UseSubBlocks = (subPrice < price);
+ if (t.UseSubBlocks)
+ price = subPrice;
+ }
+ }
+ m_AdditionalOffset = additionalOffsetEnd;
+ m_Pos = posTemp;
+ return price;
+}
+
+void CCoder::CodeBlock(int tableIndex, bool finalBlock)
+{
+ CTables &t = m_Tables[tableIndex];
+ if (t.UseSubBlocks)
+ {
+ CodeBlock((tableIndex << 1), false);
+ CodeBlock((tableIndex << 1) + 1, finalBlock);
+ }
+ else
+ {
+ if (t.StoreMode)
+ WriteStoreBlock(t.BlockSizeRes, m_AdditionalOffset, finalBlock);
+ else
+ {
+ WriteBits((finalBlock ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
+ if (t.StaticMode)
+ {
+ WriteBits(NBlockType::kFixedHuffman, kBlockTypeFieldSize);
+ TryFixedBlock(tableIndex);
+ unsigned int i;
+ const int kMaxStaticHuffLen = 9;
+ for (i = 0; i < kFixedMainTableSize; i++)
+ mainFreqs[i] = (UInt32)1 << (kMaxStaticHuffLen - m_NewLevels.litLenLevels[i]);
+ for (i = 0; i < kFixedDistTableSize; i++)
+ distFreqs[i] = (UInt32)1 << (kMaxStaticHuffLen - m_NewLevels.distLevels[i]);
+ MakeTables(kMaxStaticHuffLen);
+ }
+ else
+ {
+ if (m_NumDivPasses > 1 || m_CheckStatic)
+ TryDynBlock(tableIndex, 1);
+ WriteBits(NBlockType::kDynamicHuffman, kBlockTypeFieldSize);
+ WriteBits(m_NumLitLenLevels - kNumLitLenCodesMin, kNumLenCodesFieldSize);
+ WriteBits(m_NumDistLevels - kNumDistCodesMin, kNumDistCodesFieldSize);
+ WriteBits(m_NumLevelCodes - kNumLevelCodesMin, kNumLevelCodesFieldSize);
+
+ for (UInt32 i = 0; i < m_NumLevelCodes; i++)
+ WriteBits(m_LevelLevels[i], kLevelFieldSize);
+
+ Huffman_ReverseBits(levelCodes, levelLens, kLevelTableSize);
+ LevelTableCode(m_NewLevels.litLenLevels, m_NumLitLenLevels, levelLens, levelCodes);
+ LevelTableCode(m_NewLevels.distLevels, m_NumDistLevels, levelLens, levelCodes);
+ }
+ WriteBlock();
+ }
+ m_AdditionalOffset -= t.BlockSizeRes;
+ }
+}
+
+SRes Read(void *object, void *data, size_t *size)
+{
+ const UInt32 kStepSize = (UInt32)1 << 31;
+ UInt32 curSize = ((*size < kStepSize) ? (UInt32)*size : kStepSize);
+ HRESULT res = ((CSeqInStream *)object)->RealStream->Read(data, curSize, &curSize);
+ *size = curSize;
+ return (SRes)res;
+}
+
+HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */ , const UInt64 * /* outSize */ , ICompressProgressInfo *progress)
+{
+ m_CheckStatic = (m_NumPasses != 1 || m_NumDivPasses != 1);
+ m_IsMultiPass = (m_CheckStatic || (m_NumPasses != 1 || m_NumDivPasses != 1));
+
+ RINOK(Create());
+
+ m_ValueBlockSize = (7 << 10) + (1 << 12) * m_NumDivPasses;
+
+ UInt64 nowPos = 0;
+
+ _seqInStream.RealStream = inStream;
+ _seqInStream.SeqInStream.Read = Read;
+ _lzInWindow.stream = &_seqInStream.SeqInStream;
+
+ MatchFinder_Init(&_lzInWindow);
+ m_OutStream.SetStream(outStream);
+ m_OutStream.Init();
+
+ CCoderReleaser coderReleaser(this);
+
+ m_OptimumEndIndex = m_OptimumCurrentIndex = 0;
+
+ CTables &t = m_Tables[1];
+ t.m_Pos = 0;
+ t.InitStructures();
+
+ m_AdditionalOffset = 0;
+ do
+ {
+ t.BlockSizeRes = kBlockUncompressedSizeThreshold;
+ m_SecondPass = false;
+ GetBlockPrice(1, m_NumDivPasses);
+ CodeBlock(1, Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) == 0);
+ nowPos += m_Tables[1].BlockSizeRes;
+ if (progress != NULL)
+ {
+ UInt64 packSize = m_OutStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&nowPos, &packSize));
+ }
+ }
+ while (Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) != 0);
+ if (_lzInWindow.result != SZ_OK)
+ return _lzInWindow.result;
+ return m_OutStream.Flush();
+}
+
+HRESULT CCoder::BaseCode(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return E_FAIL; }
+}
+
+STDMETHODIMP CCOMCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+ { return BaseCode(inStream, outStream, inSize, outSize, progress); }
+
+STDMETHODIMP CCOMCoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
+ { return BaseSetEncoderProperties2(propIDs, props, numProps); }
+
+STDMETHODIMP CCOMCoder64::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+ { return BaseCode(inStream, outStream, inSize, outSize, progress); }
+
+STDMETHODIMP CCOMCoder64::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
+ { return BaseSetEncoderProperties2(propIDs, props, numProps); }
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateEncoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateEncoder.h
new file mode 100644
index 000000000..71c39e4e5
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateEncoder.h
@@ -0,0 +1,211 @@
+// DeflateEncoder.h
+
+#ifndef __DEFLATE_ENCODER_H
+#define __DEFLATE_ENCODER_H
+
+#include "../../../C/LzFind.h"
+
+#include "Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "BitlEncoder.h"
+#include "DeflateConst.h"
+
+namespace NCompress {
+namespace NDeflate {
+namespace NEncoder {
+
+struct CCodeValue
+{
+ UInt16 Len;
+ UInt16 Pos;
+ void SetAsLiteral() { Len = (1 << 15); }
+ bool IsLiteral() const { return (Len >= (1 << 15)); }
+};
+
+struct COptimal
+{
+ UInt32 Price;
+ UInt16 PosPrev;
+ UInt16 BackPrev;
+};
+
+const UInt32 kNumOptsBase = 1 << 12;
+const UInt32 kNumOpts = kNumOptsBase + kMatchMaxLen;
+
+class CCoder;
+
+struct CTables: public CLevels
+{
+ bool UseSubBlocks;
+ bool StoreMode;
+ bool StaticMode;
+ UInt32 BlockSizeRes;
+ UInt32 m_Pos;
+ void InitStructures();
+};
+
+typedef struct _CSeqInStream
+{
+ ISeqInStream SeqInStream;
+ CMyComPtr<ISequentialInStream> RealStream;
+} CSeqInStream;
+
+class CCoder
+{
+ CMatchFinder _lzInWindow;
+ CBitlEncoder m_OutStream;
+
+ CSeqInStream _seqInStream;
+
+public:
+ CCodeValue *m_Values;
+
+ UInt16 *m_MatchDistances;
+ UInt32 m_NumFastBytes;
+ bool _fastMode;
+ bool _btMode;
+
+ UInt16 *m_OnePosMatchesMemory;
+ UInt16 *m_DistanceMemory;
+
+ UInt32 m_Pos;
+
+ int m_NumPasses;
+ int m_NumDivPasses;
+ bool m_CheckStatic;
+ bool m_IsMultiPass;
+ UInt32 m_ValueBlockSize;
+
+ UInt32 m_NumLenCombinations;
+ UInt32 m_MatchMaxLen;
+ const Byte *m_LenStart;
+ const Byte *m_LenDirectBits;
+
+ bool m_Created;
+ bool m_Deflate64Mode;
+
+ Byte m_LevelLevels[kLevelTableSize];
+ int m_NumLitLenLevels;
+ int m_NumDistLevels;
+ UInt32 m_NumLevelCodes;
+ UInt32 m_ValueIndex;
+
+ bool m_SecondPass;
+ UInt32 m_AdditionalOffset;
+
+ UInt32 m_OptimumEndIndex;
+ UInt32 m_OptimumCurrentIndex;
+
+ Byte m_LiteralPrices[256];
+ Byte m_LenPrices[kNumLenSymbolsMax];
+ Byte m_PosPrices[kDistTableSize64];
+
+ CLevels m_NewLevels;
+ UInt32 mainFreqs[kFixedMainTableSize];
+ UInt32 distFreqs[kDistTableSize64];
+ UInt32 mainCodes[kFixedMainTableSize];
+ UInt32 distCodes[kDistTableSize64];
+ UInt32 levelCodes[kLevelTableSize];
+ Byte levelLens[kLevelTableSize];
+
+ UInt32 BlockSizeRes;
+
+ CTables *m_Tables;
+ COptimal m_Optimum[kNumOpts];
+
+ UInt32 m_MatchFinderCycles;
+ // IMatchFinderSetNumPasses *m_SetMfPasses;
+
+ void GetMatches();
+ void MovePos(UInt32 num);
+ UInt32 Backward(UInt32 &backRes, UInt32 cur);
+ UInt32 GetOptimal(UInt32 &backRes);
+ UInt32 GetOptimalFast(UInt32 &backRes);
+
+ void LevelTableDummy(const Byte *levels, int numLevels, UInt32 *freqs);
+
+ void WriteBits(UInt32 value, int numBits);
+ void LevelTableCode(const Byte *levels, int numLevels, const Byte *lens, const UInt32 *codes);
+
+ void MakeTables(unsigned maxHuffLen);
+ UInt32 GetLzBlockPrice() const;
+ void TryBlock();
+ UInt32 TryDynBlock(int tableIndex, UInt32 numPasses);
+
+ UInt32 TryFixedBlock(int tableIndex);
+
+ void SetPrices(const CLevels &levels);
+ void WriteBlock();
+
+ HRESULT Create();
+ void Free();
+
+ void WriteStoreBlock(UInt32 blockSize, UInt32 additionalOffset, bool finalBlock);
+ void WriteTables(bool writeMode, bool finalBlock);
+
+ void WriteBlockData(bool writeMode, bool finalBlock);
+
+ void ReleaseStreams()
+ {
+ _seqInStream.RealStream.Release();
+ m_OutStream.ReleaseStream();
+ }
+ class CCoderReleaser
+ {
+ CCoder *m_Coder;
+ public:
+ CCoderReleaser(CCoder *coder): m_Coder(coder) {}
+ ~CCoderReleaser() { m_Coder->ReleaseStreams(); }
+ };
+ friend class CCoderReleaser;
+
+ UInt32 GetBlockPrice(int tableIndex, int numDivPasses);
+ void CodeBlock(int tableIndex, bool finalBlock);
+
+public:
+ CCoder(bool deflate64Mode = false);
+ ~CCoder();
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ HRESULT BaseCode(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ HRESULT BaseSetEncoderProperties2(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
+};
+
+
+class CCOMCoder :
+ public ICompressCoder,
+ public ICompressSetCoderProperties,
+ public CMyUnknownImp,
+ public CCoder
+{
+public:
+ MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
+ CCOMCoder(): CCoder(false) {};
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
+};
+
+class CCOMCoder64 :
+ public ICompressCoder,
+ public ICompressSetCoderProperties,
+ public CMyUnknownImp,
+ public CCoder
+{
+public:
+ MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
+ CCOMCoder64(): CCoder(true) {};
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
+};
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateNsisRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateNsisRegister.cpp
new file mode 100644
index 000000000..ffad96c21
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateNsisRegister.cpp
@@ -0,0 +1,14 @@
+// DeflateNsisRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "DeflateDecoder.h"
+
+static void *CreateCodecDeflateNsis() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CNsisCOMCoder); }
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodecDeflateNsis, 0, 0x040901, L"DeflateNSIS", 1, false };
+
+REGISTER_CODEC(DeflateNsis)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateRegister.cpp
new file mode 100644
index 000000000..45f55219e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeflateRegister.cpp
@@ -0,0 +1,21 @@
+// DeflateRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "DeflateDecoder.h"
+
+static void *CreateCodecDeflate() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CCOMCoder); }
+
+#if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY)
+#include "DeflateEncoder.h"
+static void *CreateCodecOutDeflate() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NEncoder::CCOMCoder); }
+#else
+#define CreateCodecOutDeflate 0
+#endif
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodecDeflate, CreateCodecOutDeflate, 0x040108, L"Deflate", 1, false };
+
+REGISTER_CODEC(Deflate)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeltaFilter.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeltaFilter.cpp
new file mode 100644
index 000000000..2e421acf4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DeltaFilter.cpp
@@ -0,0 +1,112 @@
+// DeltaFilter.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Delta.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "BranchCoder.h"
+
+struct CDelta
+{
+ unsigned _delta;
+ Byte _state[DELTA_STATE_SIZE];
+ CDelta(): _delta(1) {}
+ void DeltaInit() { Delta_Init(_state); }
+};
+
+class CDeltaEncoder:
+ public ICompressFilter,
+ public ICompressSetCoderProperties,
+ public ICompressWriteCoderProperties,
+ CDelta,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP2(ICompressSetCoderProperties, ICompressWriteCoderProperties)
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
+ STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+};
+
+class CDeltaDecoder:
+ public ICompressFilter,
+ public ICompressSetDecoderProperties2,
+ CDelta,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+};
+
+STDMETHODIMP CDeltaEncoder::Init()
+{
+ DeltaInit();
+ return S_OK;
+}
+
+STDMETHODIMP_(UInt32) CDeltaEncoder::Filter(Byte *data, UInt32 size)
+{
+ Delta_Encode(_state, _delta, data, size);
+ return size;
+}
+
+STDMETHODIMP CDeltaEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
+{
+ UInt32 delta = _delta;
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ const PROPVARIANT &prop = props[i];
+ if (propIDs[i] != NCoderPropID::kDefaultProp || prop.vt != VT_UI4 || prop.ulVal < 1 || prop.ulVal > 256)
+ return E_INVALIDARG;
+ delta = prop.ulVal;
+ }
+ _delta = delta;
+ return S_OK;
+}
+
+STDMETHODIMP CDeltaEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
+{
+ Byte prop = (Byte)(_delta - 1);
+ return outStream->Write(&prop, 1, NULL);
+}
+
+STDMETHODIMP CDeltaDecoder::Init()
+{
+ DeltaInit();
+ return S_OK;
+}
+
+STDMETHODIMP_(UInt32) CDeltaDecoder::Filter(Byte *data, UInt32 size)
+{
+ Delta_Decode(_state, _delta, data, size);
+ return size;
+}
+
+STDMETHODIMP CDeltaDecoder::SetDecoderProperties2(const Byte *props, UInt32 size)
+{
+ if (size != 1)
+ return E_INVALIDARG;
+ _delta = (unsigned)props[0] + 1;
+ return S_OK;
+}
+
+#define CREATE_CODEC(x) \
+ static void *CreateCodec ## x() { return (void *)(ICompressFilter *)(new C ## x ## Decoder); } \
+ static void *CreateCodec ## x ## Out() { return (void *)(ICompressFilter *)(new C ## x ## Encoder); }
+
+CREATE_CODEC(Delta)
+
+#define METHOD_ITEM(x, id, name) { CreateCodec ## x, CreateCodec ## x ## Out, id, name, 1, true }
+
+static CCodecInfo g_CodecsInfo[] =
+{
+ METHOD_ITEM(Delta, 3, L"Delta")
+};
+
+REGISTER_CODECS(Delta)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DllExports.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DllExports.cpp
new file mode 100644
index 000000000..a7ec90270
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DllExports.cpp
@@ -0,0 +1,39 @@
+// DllExports.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/MyInitGuid.h"
+
+#include "../ICoder.h"
+
+#include "../Common/RegisterCodec.h"
+
+static const unsigned int kNumCodecsMax = 32;
+unsigned int g_NumCodecs = 0;
+const CCodecInfo *g_Codecs[kNumCodecsMax];
+void RegisterCodec(const CCodecInfo *codecInfo)
+{
+ if (g_NumCodecs < kNumCodecsMax)
+ g_Codecs[g_NumCodecs++] = codecInfo;
+}
+
+#ifdef _WIN32
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
+{
+ return TRUE;
+}
+#endif
+
+static const UInt16 kDecodeId = 0x2790;
+
+DEFINE_GUID(CLSID_CCodec,
+0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ return CreateCoder(clsid, iid, outObject);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DllExports2.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DllExports2.cpp
new file mode 100644
index 000000000..836f3fa42
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/DllExports2.cpp
@@ -0,0 +1,28 @@
+// DllExports.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/MyInitGuid.h"
+
+#include "../ICoder.h"
+
+#include "../Common/RegisterCodec.h"
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
+{
+ return TRUE;
+}
+
+static const UInt16 kDecodeId = 0x2790;
+
+DEFINE_GUID(CLSID_CCodec,
+0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ return CreateCoder(clsid, iid, outObject);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/HuffmanDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/HuffmanDecoder.h
new file mode 100644
index 000000000..74a389a16
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/HuffmanDecoder.h
@@ -0,0 +1,89 @@
+// Compress/HuffmanDecoder.h
+
+#ifndef __COMPRESS_HUFFMAN_DECODER_H
+#define __COMPRESS_HUFFMAN_DECODER_H
+
+#include "../../Common/Types.h"
+
+namespace NCompress {
+namespace NHuffman {
+
+const int kNumTableBits = 9;
+
+template <int kNumBitsMax, UInt32 m_NumSymbols>
+class CDecoder
+{
+ UInt32 m_Limits[kNumBitsMax + 1]; // m_Limits[i] = value limit for symbols with length = i
+ UInt32 m_Positions[kNumBitsMax + 1]; // m_Positions[i] = index in m_Symbols[] of first symbol with length = i
+ UInt32 m_Symbols[m_NumSymbols];
+ Byte m_Lengths[1 << kNumTableBits]; // Table oh length for short codes.
+
+public:
+
+ bool SetCodeLengths(const Byte *codeLengths)
+ {
+ int lenCounts[kNumBitsMax + 1];
+ UInt32 tmpPositions[kNumBitsMax + 1];
+ int i;
+ for(i = 1; i <= kNumBitsMax; i++)
+ lenCounts[i] = 0;
+ UInt32 symbol;
+ for (symbol = 0; symbol < m_NumSymbols; symbol++)
+ {
+ int len = codeLengths[symbol];
+ if (len > kNumBitsMax)
+ return false;
+ lenCounts[len]++;
+ m_Symbols[symbol] = 0xFFFFFFFF;
+ }
+ lenCounts[0] = 0;
+ m_Positions[0] = m_Limits[0] = 0;
+ UInt32 startPos = 0;
+ UInt32 index = 0;
+ const UInt32 kMaxValue = (1 << kNumBitsMax);
+ for (i = 1; i <= kNumBitsMax; i++)
+ {
+ startPos += lenCounts[i] << (kNumBitsMax - i);
+ if (startPos > kMaxValue)
+ return false;
+ m_Limits[i] = (i == kNumBitsMax) ? kMaxValue : startPos;
+ m_Positions[i] = m_Positions[i - 1] + lenCounts[i - 1];
+ tmpPositions[i] = m_Positions[i];
+ if(i <= kNumTableBits)
+ {
+ UInt32 limit = (m_Limits[i] >> (kNumBitsMax - kNumTableBits));
+ for (; index < limit; index++)
+ m_Lengths[index] = (Byte)i;
+ }
+ }
+ for (symbol = 0; symbol < m_NumSymbols; symbol++)
+ {
+ int len = codeLengths[symbol];
+ if (len != 0)
+ m_Symbols[tmpPositions[len]++] = symbol;
+ }
+ return true;
+ }
+
+ template <class TBitDecoder>
+ UInt32 DecodeSymbol(TBitDecoder *bitStream)
+ {
+ int numBits;
+ UInt32 value = bitStream->GetValue(kNumBitsMax);
+ if (value < m_Limits[kNumTableBits])
+ numBits = m_Lengths[value >> (kNumBitsMax - kNumTableBits)];
+ else
+ for (numBits = kNumTableBits + 1; value >= m_Limits[numBits]; numBits++) {}
+ bitStream->MovePos(numBits);
+ UInt32 index = m_Positions[numBits] +
+ ((value - m_Limits[numBits - 1]) >> (kNumBitsMax - numBits));
+ if (index >= m_NumSymbols)
+ // throw CDecoderException(); // test it
+ return 0xFFFFFFFF;
+ return m_Symbols[index];
+ }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeDecoder.cpp
new file mode 100644
index 000000000..ec29bfe93
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeDecoder.cpp
@@ -0,0 +1,219 @@
+// Implode/Decoder.cpp
+
+#include "StdAfx.h"
+
+#include "ImplodeDecoder.h"
+#include "Common/Defs.h"
+
+namespace NCompress {
+namespace NImplode {
+namespace NDecoder {
+
+class CException
+{
+public:
+ enum ECauseType
+ {
+ kData
+ } m_Cause;
+ CException(ECauseType cause): m_Cause(cause) {}
+};
+
+static const int kNumDistanceLowDirectBitsForBigDict = 7;
+static const int kNumDistanceLowDirectBitsForSmallDict = 6;
+
+static const int kNumBitsInByte = 8;
+
+// static const int kLevelStructuresNumberFieldSize = kNumBitsInByte;
+static const int kLevelStructuresNumberAdditionalValue = 1;
+
+static const int kNumLevelStructureLevelBits = 4;
+static const int kLevelStructureLevelAdditionalValue = 1;
+
+static const int kNumLevelStructureRepNumberBits = 4;
+static const int kLevelStructureRepNumberAdditionalValue = 1;
+
+
+static const int kLiteralTableSize = (1 << kNumBitsInByte);
+static const int kDistanceTableSize = 64;
+static const int kLengthTableSize = 64;
+
+static const UInt32 kHistorySize =
+ (1 << MyMax(kNumDistanceLowDirectBitsForBigDict,
+ kNumDistanceLowDirectBitsForSmallDict)) *
+ kDistanceTableSize; // = 8 KB;
+
+static const int kNumAdditionalLengthBits = 8;
+
+static const UInt32 kMatchMinLenWhenLiteralsOn = 3;
+static const UInt32 kMatchMinLenWhenLiteralsOff = 2;
+
+static const UInt32 kMatchMinLenMax = MyMax(kMatchMinLenWhenLiteralsOn,
+ kMatchMinLenWhenLiteralsOff); // 3
+
+// static const UInt32 kMatchMaxLenMax = kMatchMinLenMax + (kLengthTableSize - 1) + (1 << kNumAdditionalLengthBits) - 1; // or 2
+
+enum
+{
+ kMatchId = 0,
+ kLiteralId = 1
+};
+
+
+CCoder::CCoder():
+ m_LiteralDecoder(kLiteralTableSize),
+ m_LengthDecoder(kLengthTableSize),
+ m_DistanceDecoder(kDistanceTableSize)
+{
+}
+
+void CCoder::ReleaseStreams()
+{
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+}
+
+bool CCoder::ReadLevelItems(NImplode::NHuffman::CDecoder &decoder,
+ Byte *levels, int numLevelItems)
+{
+ int numCodedStructures = m_InBitStream.ReadBits(kNumBitsInByte) +
+ kLevelStructuresNumberAdditionalValue;
+ int currentIndex = 0;
+ for(int i = 0; i < numCodedStructures; i++)
+ {
+ int level = m_InBitStream.ReadBits(kNumLevelStructureLevelBits) +
+ kLevelStructureLevelAdditionalValue;
+ int rep = m_InBitStream.ReadBits(kNumLevelStructureRepNumberBits) +
+ kLevelStructureRepNumberAdditionalValue;
+ if (currentIndex + rep > numLevelItems)
+ throw CException(CException::kData);
+ for(int j = 0; j < rep; j++)
+ levels[currentIndex++] = (Byte)level;
+ }
+ if (currentIndex != numLevelItems)
+ return false;
+ return decoder.SetCodeLengths(levels);
+}
+
+
+bool CCoder::ReadTables(void)
+{
+ if (m_LiteralsOn)
+ {
+ Byte literalLevels[kLiteralTableSize];
+ if (!ReadLevelItems(m_LiteralDecoder, literalLevels, kLiteralTableSize))
+ return false;
+ }
+
+ Byte lengthLevels[kLengthTableSize];
+ if (!ReadLevelItems(m_LengthDecoder, lengthLevels, kLengthTableSize))
+ return false;
+
+ Byte distanceLevels[kDistanceTableSize];
+ return ReadLevelItems(m_DistanceDecoder, distanceLevels, kDistanceTableSize);
+}
+
+class CCoderReleaser
+{
+ CCoder *m_Coder;
+public:
+ CCoderReleaser(CCoder *coder): m_Coder(coder) {}
+ ~CCoderReleaser() { m_Coder->ReleaseStreams(); }
+};
+
+HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ if (!m_OutWindowStream.Create(kHistorySize))
+ return E_OUTOFMEMORY;
+ if (outSize == NULL)
+ return E_INVALIDARG;
+ UInt64 pos = 0, unPackSize = *outSize;
+
+ m_OutWindowStream.SetStream(outStream);
+ m_OutWindowStream.Init(false);
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+ CCoderReleaser coderReleaser(this);
+
+ if (!ReadTables())
+ return S_FALSE;
+
+ while(pos < unPackSize)
+ {
+ if (progress != NULL && pos % (1 << 16) == 0)
+ {
+ UInt64 packSize = m_InBitStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &pos));
+ }
+ if(m_InBitStream.ReadBits(1) == kMatchId) // match
+ {
+ UInt32 lowDistBits = m_InBitStream.ReadBits(m_NumDistanceLowDirectBits);
+ UInt32 distance = m_DistanceDecoder.DecodeSymbol(&m_InBitStream);
+ if (distance >= static_cast< UInt32 >( kDistanceTableSize) )
+ return S_FALSE;
+ distance = (distance << m_NumDistanceLowDirectBits) + lowDistBits;
+ UInt32 lengthSymbol = m_LengthDecoder.DecodeSymbol(&m_InBitStream);
+ if (lengthSymbol >= static_cast< UInt32 >( kLengthTableSize) )
+ return S_FALSE;
+ UInt32 length = lengthSymbol + m_MinMatchLength;
+ if (lengthSymbol == kLengthTableSize - 1) // special symbol = 63
+ length += m_InBitStream.ReadBits(kNumAdditionalLengthBits);
+ while(distance >= pos && length > 0)
+ {
+ m_OutWindowStream.PutByte(0);
+ pos++;
+ length--;
+ }
+ if (length > 0)
+ m_OutWindowStream.CopyBlock(distance, length);
+ pos += length;
+ }
+ else
+ {
+ Byte b;
+ if (m_LiteralsOn)
+ {
+ UInt32 temp = m_LiteralDecoder.DecodeSymbol(&m_InBitStream);
+ if (temp >= static_cast< UInt32 >( kLiteralTableSize) )
+ return S_FALSE;
+ b = (Byte)temp;
+ }
+ else
+ b = (Byte)m_InBitStream.ReadBits(kNumBitsInByte);
+ m_OutWindowStream.PutByte(b);
+ pos++;
+ }
+ }
+ if (pos > unPackSize)
+ return S_FALSE;
+ return m_OutWindowStream.Flush();
+}
+
+STDMETHODIMP CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+STDMETHODIMP CCoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size < 1)
+ return E_INVALIDARG;
+ Byte flag = data[0];
+ m_BigDictionaryOn = ((flag & 2) != 0);
+ m_NumDistanceLowDirectBits = m_BigDictionaryOn ?
+ kNumDistanceLowDirectBitsForBigDict:
+ kNumDistanceLowDirectBitsForSmallDict;
+ m_LiteralsOn = ((flag & 4) != 0);
+ m_MinMatchLength = m_LiteralsOn ?
+ kMatchMinLenWhenLiteralsOn :
+ kMatchMinLenWhenLiteralsOff;
+ return S_OK;
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeDecoder.h
new file mode 100644
index 000000000..7ea1553ee
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeDecoder.h
@@ -0,0 +1,57 @@
+// ImplodeDecoder.h
+
+#ifndef __COMPRESS_IMPLODE_DECODER_H
+#define __COMPRESS_IMPLODE_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "ImplodeHuffmanDecoder.h"
+#include "LzOutWindow.h"
+
+namespace NCompress {
+namespace NImplode {
+namespace NDecoder {
+
+class CCoder:
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+ CLzOutWindow m_OutWindowStream;
+ NBitl::CDecoder<CInBuffer> m_InBitStream;
+
+ NImplode::NHuffman::CDecoder m_LiteralDecoder;
+ NImplode::NHuffman::CDecoder m_LengthDecoder;
+ NImplode::NHuffman::CDecoder m_DistanceDecoder;
+
+ bool m_BigDictionaryOn;
+ bool m_LiteralsOn;
+
+ int m_NumDistanceLowDirectBits;
+ UInt32 m_MinMatchLength;
+
+ bool ReadLevelItems(NImplode::NHuffman::CDecoder &table, Byte *levels, int numLevelItems);
+ bool ReadTables();
+ void DeCodeLevelTable(Byte *newLevels, int numLevels);
+public:
+ CCoder();
+
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+
+ void ReleaseStreams();
+ HRESULT Flush() { return m_OutWindowStream.Flush(); }
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+};
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp
new file mode 100644
index 000000000..64345e08b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp
@@ -0,0 +1,89 @@
+// ImplodeHuffmanDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "ImplodeHuffmanDecoder.h"
+
+namespace NCompress {
+namespace NImplode {
+namespace NHuffman {
+
+CDecoder::CDecoder(UInt32 numSymbols):
+ m_NumSymbols(numSymbols)
+{
+ m_Symbols = new UInt32[m_NumSymbols];
+}
+
+CDecoder::~CDecoder()
+{
+ delete []m_Symbols;
+}
+
+bool CDecoder::SetCodeLengths(const Byte *codeLengths)
+{
+ // int lenCounts[kNumBitsInLongestCode + 1], tmpPositions[kNumBitsInLongestCode + 1];
+ int lenCounts[kNumBitsInLongestCode + 2], tmpPositions[kNumBitsInLongestCode + 1];
+ int i;
+ for(i = 0; i <= kNumBitsInLongestCode; i++)
+ lenCounts[i] = 0;
+ UInt32 symbolIndex;
+ for (symbolIndex = 0; symbolIndex < m_NumSymbols; symbolIndex++)
+ lenCounts[codeLengths[symbolIndex]]++;
+ // lenCounts[0] = 0;
+
+ // tmpPositions[0] = m_Positions[0] = m_Limitits[0] = 0;
+ m_Limitits[kNumBitsInLongestCode + 1] = 0;
+ m_Positions[kNumBitsInLongestCode + 1] = 0;
+ lenCounts[kNumBitsInLongestCode + 1] = 0;
+
+
+ UInt32 startPos = 0;
+ static const UInt32 kMaxValue = (1 << kNumBitsInLongestCode);
+
+ for (i = kNumBitsInLongestCode; i > 0; i--)
+ {
+ startPos += lenCounts[i] << (kNumBitsInLongestCode - i);
+ if (startPos > kMaxValue)
+ return false;
+ m_Limitits[i] = startPos;
+ m_Positions[i] = m_Positions[i + 1] + lenCounts[i + 1];
+ tmpPositions[i] = m_Positions[i] + lenCounts[i];
+
+ }
+
+ // if _ZIP_MODE do not throw exception for trees containing only one node
+ // #ifndef _ZIP_MODE
+ if (startPos != kMaxValue)
+ return false;
+ // #endif
+
+ for (symbolIndex = 0; symbolIndex < m_NumSymbols; symbolIndex++)
+ if (codeLengths[symbolIndex] != 0)
+ m_Symbols[--tmpPositions[codeLengths[symbolIndex]]] = symbolIndex;
+ return true;
+}
+
+UInt32 CDecoder::DecodeSymbol(CInBit *inStream)
+{
+ UInt32 numBits = 0;
+ UInt32 value = inStream->GetValue(kNumBitsInLongestCode);
+ int i;
+ for(i = kNumBitsInLongestCode; i > 0; i--)
+ {
+ if (value < m_Limitits[i])
+ {
+ numBits = i;
+ break;
+ }
+ }
+ if (i == 0)
+ return 0xFFFFFFFF;
+ inStream->MovePos(numBits);
+ UInt32 index = m_Positions[numBits] +
+ ((value - m_Limitits[numBits + 1]) >> (kNumBitsInLongestCode - numBits));
+ if (index >= m_NumSymbols)
+ return 0xFFFFFFFF;
+ return m_Symbols[index];
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeHuffmanDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeHuffmanDecoder.h
new file mode 100644
index 000000000..6120a35ab
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ImplodeHuffmanDecoder.h
@@ -0,0 +1,34 @@
+// ImplodeHuffmanDecoder.h
+
+#ifndef __IMPLODE_HUFFMAN_DECODER_H
+#define __IMPLODE_HUFFMAN_DECODER_H
+
+#include "../Common/InBuffer.h"
+
+#include "BitlDecoder.h"
+
+namespace NCompress {
+namespace NImplode {
+namespace NHuffman {
+
+const int kNumBitsInLongestCode = 16;
+
+typedef NBitl::CDecoder<CInBuffer> CInBit;
+
+class CDecoder
+{
+ UInt32 m_Limitits[kNumBitsInLongestCode + 2]; // m_Limitits[i] = value limit for symbols with length = i
+ UInt32 m_Positions[kNumBitsInLongestCode + 2]; // m_Positions[i] = index in m_Symbols[] of first symbol with length = i
+ UInt32 m_NumSymbols; // number of symbols in m_Symbols
+ UInt32 *m_Symbols; // symbols: at first with len=1 then 2, ... 15.
+public:
+ CDecoder(UInt32 numSymbols);
+ ~CDecoder();
+
+ bool SetCodeLengths(const Byte *codeLengths);
+ UInt32 DecodeSymbol(CInBit *inStream);
+};
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
new file mode 100644
index 000000000..3d8e475ff
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
@@ -0,0 +1,531 @@
+// LzmaAlone.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Common/MyWindows.h"
+#include "../../../Common/MyInitGuid.h"
+
+#include <stdio.h>
+
+#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
+#include <fcntl.h>
+#include <io.h>
+#define MY_SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY)
+#else
+#define MY_SET_BINARY_MODE(file)
+#endif
+
+#include "../../../Common/CommandLineParser.h"
+#include "../../../Common/StringConvert.h"
+#include "../../../Common/StringToInt.h"
+
+#include "../../Common/FileStreams.h"
+#include "../../Common/StreamUtils.h"
+
+#include "../LzmaDecoder.h"
+#include "../LzmaEncoder.h"
+
+#include "LzmaBenchCon.h"
+
+#ifdef COMPRESS_MF_MT
+#include "../../../Windows/System.h"
+#endif
+
+#include "../../../../C/7zVersion.h"
+#include "../../../../C/Alloc.h"
+#include "../../../../C/LzmaUtil/Lzma86Dec.h"
+#include "../../../../C/LzmaUtil/Lzma86Enc.h"
+
+using namespace NCommandLineParser;
+
+#ifdef _WIN32
+bool g_IsNT = false;
+static inline bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+
+static const char *kCantAllocate = "Can not allocate memory";
+static const char *kReadError = "Read error";
+static const char *kWriteError = "Write error";
+
+namespace NKey {
+enum Enum
+{
+ kHelp1 = 0,
+ kHelp2,
+ kAlgo,
+ kDict,
+ kFb,
+ kMc,
+ kLc,
+ kLp,
+ kPb,
+ kMatchFinder,
+ kMultiThread,
+ kEOS,
+ kStdIn,
+ kStdOut,
+ kFilter86
+};
+}
+
+static const CSwitchForm kSwitchForms[] =
+{
+ { L"?", NSwitchType::kSimple, false },
+ { L"H", NSwitchType::kSimple, false },
+ { L"A", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"D", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"FB", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"MC", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"LC", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"LP", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"PB", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"MF", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"MT", NSwitchType::kUnLimitedPostString, false, 0 },
+ { L"EOS", NSwitchType::kSimple, false },
+ { L"SI", NSwitchType::kSimple, false },
+ { L"SO", NSwitchType::kSimple, false },
+ { L"F86", NSwitchType::kPostChar, false, 0, 0, L"+" }
+};
+
+static const int kNumSwitches = sizeof(kSwitchForms) / sizeof(kSwitchForms[0]);
+
+static void PrintHelp()
+{
+ fprintf(stderr, "\nUsage: LZMA <e|d> inputFile outputFile [<switches>...]\n"
+ " e: encode file\n"
+ " d: decode file\n"
+ " b: Benchmark\n"
+ "<Switches>\n"
+ " -a{N}: set compression mode - [0, 1], default: 1 (max)\n"
+ " -d{N}: set dictionary size - [12, 30], default: 23 (8MB)\n"
+ " -fb{N}: set number of fast bytes - [5, 273], default: 128\n"
+ " -mc{N}: set number of cycles for match finder\n"
+ " -lc{N}: set number of literal context bits - [0, 8], default: 3\n"
+ " -lp{N}: set number of literal pos bits - [0, 4], default: 0\n"
+ " -pb{N}: set number of pos bits - [0, 4], default: 2\n"
+ " -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, hc4], default: bt4\n"
+ " -mt{N}: set number of CPU threads\n"
+ " -eos: write End Of Stream marker\n"
+ " -si: read data from stdin\n"
+ " -so: write data to stdout\n"
+ );
+}
+
+static void PrintHelpAndExit(const char *s)
+{
+ fprintf(stderr, "\nError: %s\n\n", s);
+ PrintHelp();
+ throw -1;
+}
+
+static void IncorrectCommand()
+{
+ PrintHelpAndExit("Incorrect command");
+}
+
+static void WriteArgumentsToStringList(int numArguments, const char *arguments[],
+ UStringVector &strings)
+{
+ for(int i = 1; i < numArguments; i++)
+ strings.Add(MultiByteToUnicodeString(arguments[i]));
+}
+
+static bool GetNumber(const wchar_t *s, UInt32 &value)
+{
+ value = 0;
+ if (MyStringLen(s) == 0)
+ return false;
+ const wchar_t *end;
+ UInt64 res = ConvertStringToUInt64(s, &end);
+ if (*end != L'\0')
+ return false;
+ if (res > 0xFFFFFFFF)
+ return false;
+ value = UInt32(res);
+ return true;
+}
+
+static void ParseUInt32(const CParser &parser, int index, UInt32 &res)
+{
+ if (parser[index].ThereIs)
+ if (!GetNumber(parser[index].PostStrings[0], res))
+ IncorrectCommand();
+}
+
+int main2(int n, const char *args[])
+{
+ #ifdef _WIN32
+ g_IsNT = IsItWindowsNT();
+ #endif
+
+ fprintf(stderr, "\nLZMA " MY_VERSION_COPYRIGHT_DATE "\n");
+
+ if (n == 1)
+ {
+ PrintHelp();
+ return 0;
+ }
+
+ bool unsupportedTypes = (sizeof(Byte) != 1 || sizeof(UInt32) < 4 || sizeof(UInt64) < 4);
+ if (unsupportedTypes)
+ {
+ fprintf(stderr, "Unsupported base types. Edit Common/Types.h and recompile");
+ return 1;
+ }
+
+ UStringVector commandStrings;
+ WriteArgumentsToStringList(n, args, commandStrings);
+ CParser parser(kNumSwitches);
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
+ }
+ catch(...)
+ {
+ IncorrectCommand();
+ }
+
+ if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
+ {
+ PrintHelp();
+ return 0;
+ }
+ const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
+
+ int paramIndex = 0;
+ if (paramIndex >= nonSwitchStrings.Size())
+ IncorrectCommand();
+ const UString &command = nonSwitchStrings[paramIndex++];
+
+ bool dictDefined = false;
+ UInt32 dict = (UInt32)-1;
+ if(parser[NKey::kDict].ThereIs)
+ {
+ UInt32 dicLog;
+ if (!GetNumber(parser[NKey::kDict].PostStrings[0], dicLog))
+ IncorrectCommand();
+ dict = 1 << dicLog;
+ dictDefined = true;
+ }
+ UString mf = L"BT4";
+ if (parser[NKey::kMatchFinder].ThereIs)
+ mf = parser[NKey::kMatchFinder].PostStrings[0];
+
+ UInt32 numThreads = (UInt32)-1;
+
+ #ifdef COMPRESS_MF_MT
+ if (parser[NKey::kMultiThread].ThereIs)
+ {
+ UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
+ const UString &s = parser[NKey::kMultiThread].PostStrings[0];
+ if (s.IsEmpty())
+ numThreads = numCPUs;
+ else
+ if (!GetNumber(s, numThreads))
+ IncorrectCommand();
+ }
+ #endif
+
+ if (command.CompareNoCase(L"b") == 0)
+ {
+ const UInt32 kNumDefaultItereations = 1;
+ UInt32 numIterations = kNumDefaultItereations;
+ {
+ if (paramIndex < nonSwitchStrings.Size())
+ if (!GetNumber(nonSwitchStrings[paramIndex++], numIterations))
+ numIterations = kNumDefaultItereations;
+ }
+ return LzmaBenchCon(stderr, numIterations, numThreads, dict);
+ }
+
+ if (numThreads == (UInt32)-1)
+ numThreads = 1;
+
+ bool encodeMode = false;
+ if (command.CompareNoCase(L"e") == 0)
+ encodeMode = true;
+ else if (command.CompareNoCase(L"d") == 0)
+ encodeMode = false;
+ else
+ IncorrectCommand();
+
+ bool stdInMode = parser[NKey::kStdIn].ThereIs;
+ bool stdOutMode = parser[NKey::kStdOut].ThereIs;
+
+ CMyComPtr<ISequentialInStream> inStream;
+ CInFileStream *inStreamSpec = 0;
+ if (stdInMode)
+ {
+ inStream = new CStdInFileStream;
+ MY_SET_BINARY_MODE(stdin);
+ }
+ else
+ {
+ if (paramIndex >= nonSwitchStrings.Size())
+ IncorrectCommand();
+ const UString &inputName = nonSwitchStrings[paramIndex++];
+ inStreamSpec = new CInFileStream;
+ inStream = inStreamSpec;
+ if (!inStreamSpec->Open(GetSystemString(inputName)))
+ {
+ fprintf(stderr, "\nError: can not open input file %s\n",
+ (const char *)GetOemString(inputName));
+ return 1;
+ }
+ }
+
+ CMyComPtr<ISequentialOutStream> outStream;
+ COutFileStream *outStreamSpec = NULL;
+ if (stdOutMode)
+ {
+ outStream = new CStdOutFileStream;
+ MY_SET_BINARY_MODE(stdout);
+ }
+ else
+ {
+ if (paramIndex >= nonSwitchStrings.Size())
+ IncorrectCommand();
+ const UString &outputName = nonSwitchStrings[paramIndex++];
+ outStreamSpec = new COutFileStream;
+ outStream = outStreamSpec;
+ if (!outStreamSpec->Create(GetSystemString(outputName), true))
+ {
+ fprintf(stderr, "\nError: can not open output file %s\n",
+ (const char *)GetOemString(outputName));
+ return 1;
+ }
+ }
+
+ if (parser[NKey::kFilter86].ThereIs)
+ {
+ // -f86 switch is for x86 filtered mode: BCJ + LZMA.
+ if (parser[NKey::kEOS].ThereIs || stdInMode)
+ throw "Can not use stdin in this mode";
+ UInt64 fileSize;
+ inStreamSpec->File.GetLength(fileSize);
+ if (fileSize > 0xF0000000)
+ throw "File is too big";
+ size_t inSize = (size_t)fileSize;
+ Byte *inBuffer = 0;
+ if (inSize != 0)
+ {
+ inBuffer = (Byte *)MyAlloc((size_t)inSize);
+ if (inBuffer == 0)
+ throw kCantAllocate;
+ }
+
+ if (ReadStream_FAIL(inStream, inBuffer, inSize) != S_OK)
+ throw "Can not read";
+
+ Byte *outBuffer = 0;
+ size_t outSize;
+ if (encodeMode)
+ {
+ // we allocate 105% of original size for output buffer
+ outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
+ if (outSize != 0)
+ {
+ outBuffer = (Byte *)MyAlloc((size_t)outSize);
+ if (outBuffer == 0)
+ throw kCantAllocate;
+ }
+ if (!dictDefined)
+ dict = 1 << 23;
+ int res = Lzma86_Encode(outBuffer, &outSize, inBuffer, inSize,
+ 5, dict, parser[NKey::kFilter86].PostCharIndex == 0 ? SZ_FILTER_YES : SZ_FILTER_AUTO);
+ if (res != 0)
+ {
+ fprintf(stderr, "\nEncoder error = %d\n", (int)res);
+ return 1;
+ }
+ }
+ else
+ {
+ UInt64 outSize64;
+ if (Lzma86_GetUnpackSize(inBuffer, inSize, &outSize64) != 0)
+ throw "data error";
+ outSize = (size_t)outSize64;
+ if (outSize != outSize64)
+ throw "too big";
+ if (outSize != 0)
+ {
+ outBuffer = (Byte *)MyAlloc(outSize);
+ if (outBuffer == 0)
+ throw kCantAllocate;
+ }
+ int res = Lzma86_Decode(outBuffer, &outSize, inBuffer, &inSize);
+ if (inSize != (size_t)fileSize)
+ throw "incorrect processed size";
+ if (res != 0)
+ throw "LzmaDecoder error";
+ }
+ if (WriteStream(outStream, outBuffer, outSize) != S_OK)
+ throw kWriteError;
+ MyFree(outBuffer);
+ MyFree(inBuffer);
+ return 0;
+ }
+
+
+ UInt64 fileSize;
+ if (encodeMode)
+ {
+ NCompress::NLzma::CEncoder *encoderSpec = new NCompress::NLzma::CEncoder;
+ CMyComPtr<ICompressCoder> encoder = encoderSpec;
+
+ if (!dictDefined)
+ dict = 1 << 23;
+
+ UInt32 pb = 2;
+ UInt32 lc = 3; // = 0; for 32-bit data
+ UInt32 lp = 0; // = 2; for 32-bit data
+ UInt32 algo = 1;
+ UInt32 fb = 128;
+ UInt32 mc = 16 + fb / 2;
+ bool mcDefined = false;
+
+ bool eos = parser[NKey::kEOS].ThereIs || stdInMode;
+
+ ParseUInt32(parser, NKey::kAlgo, algo);
+ ParseUInt32(parser, NKey::kFb, fb);
+ ParseUInt32(parser, NKey::kLc, lc);
+ ParseUInt32(parser, NKey::kLp, lp);
+ ParseUInt32(parser, NKey::kPb, pb);
+
+ mcDefined = parser[NKey::kMc].ThereIs;
+ if (mcDefined)
+ if (!GetNumber(parser[NKey::kMc].PostStrings[0], mc))
+ IncorrectCommand();
+
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kDictionarySize,
+ NCoderPropID::kPosStateBits,
+ NCoderPropID::kLitContextBits,
+ NCoderPropID::kLitPosBits,
+ NCoderPropID::kAlgorithm,
+ NCoderPropID::kNumFastBytes,
+ NCoderPropID::kMatchFinder,
+ NCoderPropID::kEndMarker,
+ NCoderPropID::kNumThreads,
+ NCoderPropID::kMatchFinderCycles,
+ };
+ const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]);
+
+ PROPVARIANT props[kNumPropsMax];
+ for (int p = 0; p < 6; p++)
+ props[p].vt = VT_UI4;
+
+ props[0].ulVal = (UInt32)dict;
+ props[1].ulVal = (UInt32)pb;
+ props[2].ulVal = (UInt32)lc;
+ props[3].ulVal = (UInt32)lp;
+ props[4].ulVal = (UInt32)algo;
+ props[5].ulVal = (UInt32)fb;
+
+ props[6].vt = VT_BSTR;
+ props[6].bstrVal = (BSTR)(const wchar_t *)mf;
+
+ props[7].vt = VT_BOOL;
+ props[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;
+
+ props[8].vt = VT_UI4;
+ props[8].ulVal = (UInt32)numThreads;
+
+ // it must be last in property list
+ props[9].vt = VT_UI4;
+ props[9].ulVal = (UInt32)mc;
+
+ int numProps = kNumPropsMax;
+ if (!mcDefined)
+ numProps--;
+
+ if (encoderSpec->SetCoderProperties(propIDs, props, numProps) != S_OK)
+ IncorrectCommand();
+ encoderSpec->WriteCoderProperties(outStream);
+
+ if (eos || stdInMode)
+ fileSize = (UInt64)(Int64)-1;
+ else
+ inStreamSpec->File.GetLength(fileSize);
+
+ for (int i = 0; i < 8; i++)
+ {
+ Byte b = Byte(fileSize >> (8 * i));
+ if (outStream->Write(&b, 1, 0) != S_OK)
+ {
+ fprintf(stderr, kWriteError);
+ return 1;
+ }
+ }
+ HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
+ if (result == E_OUTOFMEMORY)
+ {
+ fprintf(stderr, "\nError: Can not allocate memory\n");
+ return 1;
+ }
+ else if (result != S_OK)
+ {
+ fprintf(stderr, "\nEncoder error = %X\n", (unsigned int)result);
+ return 1;
+ }
+ }
+ else
+ {
+ NCompress::NLzma::CDecoder *decoderSpec = new NCompress::NLzma::CDecoder;
+ CMyComPtr<ICompressCoder> decoder = decoderSpec;
+ decoderSpec->FinishStream = true;
+ const UInt32 kPropertiesSize = 5;
+ Byte header[kPropertiesSize + 8];
+ if (ReadStream_FALSE(inStream, header, kPropertiesSize + 8) != S_OK)
+ {
+ fprintf(stderr, kReadError);
+ return 1;
+ }
+ if (decoderSpec->SetDecoderProperties2(header, kPropertiesSize) != S_OK)
+ {
+ fprintf(stderr, "SetDecoderProperties error");
+ return 1;
+ }
+ fileSize = 0;
+ for (int i = 0; i < 8; i++)
+ fileSize |= ((UInt64)header[kPropertiesSize + i]) << (8 * i);
+
+ if (decoder->Code(inStream, outStream, 0, (fileSize == (UInt64)(Int64)-1) ? 0 : &fileSize, 0) != S_OK)
+ {
+ fprintf(stderr, "Decoder error");
+ return 1;
+ }
+ }
+ if (outStreamSpec != NULL)
+ {
+ if (outStreamSpec->Close() != S_OK)
+ {
+ fprintf(stderr, "File closing error");
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int MY_CDECL main(int n, const char *args[])
+{
+ try { return main2(n, args); }
+ catch(const char *s)
+ {
+ fprintf(stderr, "\nError: %s\n", s);
+ return 1;
+ }
+ catch(...)
+ {
+ fprintf(stderr, "\nError\n");
+ return 1;
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
new file mode 100644
index 000000000..f9cc0f87d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
@@ -0,0 +1,1018 @@
+// LzmaBench.cpp
+
+#include "StdAfx.h"
+
+#include "LzmaBench.h"
+
+#ifndef _WIN32
+#define USE_POSIX_TIME
+#define USE_POSIX_TIME2
+#endif
+
+#ifdef USE_POSIX_TIME
+#include <time.h>
+#ifdef USE_POSIX_TIME2
+#include <sys/time.h>
+#endif
+#endif
+
+#ifdef _WIN32
+#define USE_ALLOCA
+#endif
+
+#ifdef USE_ALLOCA
+#ifdef _WIN32
+#include <malloc.h>
+#else
+#include <stdlib.h>
+#endif
+#endif
+
+#include "../../../../C/7zCrc.h"
+#include "../../../../C/Alloc.h"
+
+#include "../../../Common/MyCom.h"
+
+#ifdef BENCH_MT
+#include "../../../Windows/Synchronization.h"
+#include "../../../Windows/Thread.h"
+#endif
+
+#ifdef EXTERNAL_LZMA
+#include "../../../Windows/PropVariant.h"
+#include "../../ICoder.h"
+#else
+#include "../LzmaDecoder.h"
+#include "../LzmaEncoder.h"
+#endif
+
+static const UInt32 kUncompressMinBlockSize = 1 << 26;
+static const UInt32 kAdditionalSize = (1 << 16);
+static const UInt32 kCompressedAdditionalSize = (1 << 10);
+static const UInt32 kMaxLzmaPropSize = 5;
+
+class CBaseRandomGenerator
+{
+ UInt32 A1;
+ UInt32 A2;
+public:
+ CBaseRandomGenerator() { Init(); }
+ void Init() { A1 = 362436069; A2 = 521288629;}
+ UInt32 GetRnd()
+ {
+ return
+ ((A1 = 36969 * (A1 & 0xffff) + (A1 >> 16)) << 16) +
+ ((A2 = 18000 * (A2 & 0xffff) + (A2 >> 16)) );
+ }
+};
+
+class CBenchBuffer
+{
+public:
+ size_t BufferSize;
+ Byte *Buffer;
+ CBenchBuffer(): Buffer(0) {}
+ virtual ~CBenchBuffer() { Free(); }
+ void Free()
+ {
+ ::MidFree(Buffer);
+ Buffer = 0;
+ }
+ bool Alloc(size_t bufferSize)
+ {
+ if (Buffer != 0 && BufferSize == bufferSize)
+ return true;
+ Free();
+ Buffer = (Byte *)::MidAlloc(bufferSize);
+ BufferSize = bufferSize;
+ return (Buffer != 0);
+ }
+};
+
+class CBenchRandomGenerator: public CBenchBuffer
+{
+ CBaseRandomGenerator *RG;
+public:
+ void Set(CBaseRandomGenerator *rg) { RG = rg; }
+ UInt32 GetVal(UInt32 &res, int numBits)
+ {
+ UInt32 val = res & (((UInt32)1 << numBits) - 1);
+ res >>= numBits;
+ return val;
+ }
+ UInt32 GetLen(UInt32 &res)
+ {
+ UInt32 len = GetVal(res, 2);
+ return GetVal(res, 1 + len);
+ }
+ void Generate()
+ {
+ UInt32 pos = 0;
+ UInt32 rep0 = 1;
+ while (pos < BufferSize)
+ {
+ UInt32 res = RG->GetRnd();
+ res >>= 1;
+ if (GetVal(res, 1) == 0 || pos < 1024)
+ Buffer[pos++] = (Byte)(res & 0xFF);
+ else
+ {
+ UInt32 len;
+ len = 1 + GetLen(res);
+ if (GetVal(res, 3) != 0)
+ {
+ len += GetLen(res);
+ do
+ {
+ UInt32 ppp = GetVal(res, 5) + 6;
+ res = RG->GetRnd();
+ if (ppp > 30)
+ continue;
+ rep0 = /* (1 << ppp) +*/ GetVal(res, ppp);
+ res = RG->GetRnd();
+ }
+ while (rep0 >= pos);
+ rep0++;
+ }
+
+ for (UInt32 i = 0; i < len && pos < BufferSize; i++, pos++)
+ Buffer[pos] = Buffer[pos - rep0];
+ }
+ }
+ }
+};
+
+
+class CBenchmarkInStream:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+ const Byte *Data;
+ size_t Pos;
+ size_t Size;
+public:
+ MY_UNKNOWN_IMP
+ void Init(const Byte *data, size_t size)
+ {
+ Data = data;
+ Size = size;
+ Pos = 0;
+ }
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+};
+
+STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ size_t remain = Size - Pos;
+ UInt32 kMaxBlockSize = (1 << 20);
+ if (size > kMaxBlockSize)
+ size = kMaxBlockSize;
+ if (size > remain)
+ size = (UInt32)remain;
+ for (UInt32 i = 0; i < size; i++)
+ ((Byte *)data)[i] = Data[Pos + i];
+ Pos += size;
+ if(processedSize != NULL)
+ *processedSize = size;
+ return S_OK;
+}
+
+class CBenchmarkOutStream:
+ public ISequentialOutStream,
+ public CBenchBuffer,
+ public CMyUnknownImp
+{
+ // bool _overflow;
+public:
+ UInt32 Pos;
+ // CBenchmarkOutStream(): _overflow(false) {}
+ void Init()
+ {
+ // _overflow = false;
+ Pos = 0;
+ }
+ MY_UNKNOWN_IMP
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ size_t curSize = BufferSize - Pos;
+ if (curSize > size)
+ curSize = size;
+ memcpy(Buffer + Pos, data, curSize);
+ Pos += (UInt32)curSize;
+ if(processedSize != NULL)
+ *processedSize = (UInt32)curSize;
+ if (curSize != size)
+ {
+ // _overflow = true;
+ return E_FAIL;
+ }
+ return S_OK;
+}
+
+class CCrcOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+public:
+ UInt32 Crc;
+ MY_UNKNOWN_IMP
+ void Init() { Crc = CRC_INIT_VAL; }
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+STDMETHODIMP CCrcOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ Crc = CrcUpdate(Crc, data, size);
+ if (processedSize != NULL)
+ *processedSize = size;
+ return S_OK;
+}
+
+static UInt64 GetTimeCount()
+{
+ #ifdef USE_POSIX_TIME
+ #ifdef USE_POSIX_TIME2
+ timeval v;
+ if (gettimeofday(&v, 0) == 0)
+ return (UInt64)(v.tv_sec) * 1000000 + v.tv_usec;
+ return (UInt64)time(NULL) * 1000000;
+ #else
+ return time(NULL);
+ #endif
+ #else
+ /*
+ LARGE_INTEGER value;
+ if (::QueryPerformanceCounter(&value))
+ return value.QuadPart;
+ */
+ return GetTickCount();
+ #endif
+}
+
+static UInt64 GetFreq()
+{
+ #ifdef USE_POSIX_TIME
+ #ifdef USE_POSIX_TIME2
+ return 1000000;
+ #else
+ return 1;
+ #endif
+ #else
+ /*
+ LARGE_INTEGER value;
+ if (::QueryPerformanceFrequency(&value))
+ return value.QuadPart;
+ */
+ return 1000;
+ #endif
+}
+
+#ifndef USE_POSIX_TIME
+static inline UInt64 GetTime64(const FILETIME &t) { return ((UInt64)t.dwHighDateTime << 32) | t.dwLowDateTime; }
+#endif
+static UInt64 GetUserTime()
+{
+ #ifdef USE_POSIX_TIME
+ return clock();
+ #else
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ if (::GetProcessTimes(::GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime) != 0)
+ return GetTime64(userTime) + GetTime64(kernelTime);
+ return (UInt64)GetTickCount() * 10000;
+ #endif
+}
+
+static UInt64 GetUserFreq()
+{
+ #ifdef USE_POSIX_TIME
+ return CLOCKS_PER_SEC;
+ #else
+ return 10000000;
+ #endif
+}
+
+class CBenchProgressStatus
+{
+ #ifdef BENCH_MT
+ NWindows::NSynchronization::CCriticalSection CS;
+ #endif
+public:
+ HRESULT Res;
+ bool EncodeMode;
+ void SetResult(HRESULT res)
+ {
+ #ifdef BENCH_MT
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ #endif
+ Res = res;
+ }
+ HRESULT GetResult()
+ {
+ #ifdef BENCH_MT
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ #endif
+ return Res;
+ }
+};
+
+class CBenchProgressInfo:
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+public:
+ CBenchProgressStatus *Status;
+ CBenchInfo BenchInfo;
+ HRESULT Res;
+ IBenchCallback *callback;
+ CBenchProgressInfo(): callback(0) {}
+ MY_UNKNOWN_IMP
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+};
+
+void SetStartTime(CBenchInfo &bi)
+{
+ bi.GlobalFreq = GetFreq();
+ bi.UserFreq = GetUserFreq();
+ bi.GlobalTime = ::GetTimeCount();
+ bi.UserTime = ::GetUserTime();
+}
+
+void SetFinishTime(const CBenchInfo &biStart, CBenchInfo &dest)
+{
+ dest.GlobalFreq = GetFreq();
+ dest.UserFreq = GetUserFreq();
+ dest.GlobalTime = ::GetTimeCount() - biStart.GlobalTime;
+ dest.UserTime = ::GetUserTime() - biStart.UserTime;
+}
+
+STDMETHODIMP CBenchProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ HRESULT res = Status->GetResult();
+ if (res != S_OK)
+ return res;
+ if (!callback)
+ return res;
+ CBenchInfo info = BenchInfo;
+ SetFinishTime(BenchInfo, info);
+ if (Status->EncodeMode)
+ {
+ info.UnpackSize = *inSize;
+ info.PackSize = *outSize;
+ res = callback->SetEncodeResult(info, false);
+ }
+ else
+ {
+ info.PackSize = BenchInfo.PackSize + *inSize;
+ info.UnpackSize = BenchInfo.UnpackSize + *outSize;
+ res = callback->SetDecodeResult(info, false);
+ }
+ if (res != S_OK)
+ Status->SetResult(res);
+ return res;
+}
+
+static const int kSubBits = 8;
+
+static UInt32 GetLogSize(UInt32 size)
+{
+ for (int i = kSubBits; i < 32; i++)
+ for (UInt32 j = 0; j < (1 << kSubBits); j++)
+ if (size <= (((UInt32)1) << i) + (j << (i - kSubBits)))
+ return (i << kSubBits) + j;
+ return (32 << kSubBits);
+}
+
+static void NormalizeVals(UInt64 &v1, UInt64 &v2)
+{
+ while (v1 > 1000000)
+ {
+ v1 >>= 1;
+ v2 >>= 1;
+ }
+}
+
+UInt64 GetUsage(const CBenchInfo &info)
+{
+ UInt64 userTime = info.UserTime;
+ UInt64 userFreq = info.UserFreq;
+ UInt64 globalTime = info.GlobalTime;
+ UInt64 globalFreq = info.GlobalFreq;
+ NormalizeVals(userTime, userFreq);
+ NormalizeVals(globalFreq, globalTime);
+ if (userFreq == 0)
+ userFreq = 1;
+ if (globalTime == 0)
+ globalTime = 1;
+ return userTime * globalFreq * 1000000 / userFreq / globalTime;
+}
+
+UInt64 GetRatingPerUsage(const CBenchInfo &info, UInt64 rating)
+{
+ UInt64 userTime = info.UserTime;
+ UInt64 userFreq = info.UserFreq;
+ UInt64 globalTime = info.GlobalTime;
+ UInt64 globalFreq = info.GlobalFreq;
+ NormalizeVals(userFreq, userTime);
+ NormalizeVals(globalTime, globalFreq);
+ if (globalFreq == 0)
+ globalFreq = 1;
+ if (userTime == 0)
+ userTime = 1;
+ return userFreq * globalTime / globalFreq * rating / userTime;
+}
+
+static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
+{
+ UInt64 elTime = elapsedTime;
+ NormalizeVals(freq, elTime);
+ if (elTime == 0)
+ elTime = 1;
+ return value * freq / elTime;
+}
+
+UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 size)
+{
+ UInt64 t = GetLogSize(dictionarySize) - (kBenchMinDicLogSize << kSubBits);
+ UInt64 numCommandsForOne = 870 + ((t * t * 5) >> (2 * kSubBits));
+ UInt64 numCommands = (UInt64)(size) * numCommandsForOne;
+ return MyMultDiv64(numCommands, elapsedTime, freq);
+}
+
+UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations)
+{
+ UInt64 numCommands = (inSize * 200 + outSize * 4) * numIterations;
+ return MyMultDiv64(numCommands, elapsedTime, freq);
+}
+
+#ifdef EXTERNAL_LZMA
+typedef UInt32 (WINAPI * CreateObjectPointer)(const GUID *clsID,
+ const GUID *interfaceID, void **outObject);
+#endif
+
+struct CEncoderInfo;
+
+struct CEncoderInfo
+{
+ #ifdef BENCH_MT
+ NWindows::CThread thread[2];
+ #endif
+ CMyComPtr<ICompressCoder> encoder;
+ CBenchProgressInfo *progressInfoSpec[2];
+ CMyComPtr<ICompressProgressInfo> progressInfo[2];
+ UInt32 NumIterations;
+ #ifdef USE_ALLOCA
+ size_t AllocaSize;
+ #endif
+
+ struct CDecoderInfo
+ {
+ CEncoderInfo *Encoder;
+ UInt32 DecoderIndex;
+ #ifdef USE_ALLOCA
+ size_t AllocaSize;
+ #endif
+ bool CallbackMode;
+ };
+ CDecoderInfo decodersInfo[2];
+
+ CMyComPtr<ICompressCoder> decoders[2];
+ HRESULT Results[2];
+ CBenchmarkOutStream *outStreamSpec;
+ CMyComPtr<ISequentialOutStream> outStream;
+ IBenchCallback *callback;
+ UInt32 crc;
+ UInt32 kBufferSize;
+ UInt32 compressedSize;
+ CBenchRandomGenerator rg;
+ CBenchmarkOutStream *propStreamSpec;
+ CMyComPtr<ISequentialOutStream> propStream;
+ HRESULT Init(UInt32 dictionarySize, UInt32 numThreads, CBaseRandomGenerator *rg);
+ HRESULT Encode();
+ HRESULT Decode(UInt32 decoderIndex);
+
+ CEncoderInfo(): outStreamSpec(0), callback(0), propStreamSpec(0) {}
+
+ #ifdef BENCH_MT
+ static THREAD_FUNC_DECL EncodeThreadFunction(void *param)
+ {
+ CEncoderInfo *encoder = (CEncoderInfo *)param;
+ #ifdef USE_ALLOCA
+ alloca(encoder->AllocaSize);
+ #endif
+ HRESULT res = encoder->Encode();
+ encoder->Results[0] = res;
+ if (res != S_OK)
+ encoder->progressInfoSpec[0]->Status->SetResult(res);
+
+ return 0;
+ }
+ static THREAD_FUNC_DECL DecodeThreadFunction(void *param)
+ {
+ CDecoderInfo *decoder = (CDecoderInfo *)param;
+ #ifdef USE_ALLOCA
+ alloca(decoder->AllocaSize);
+ #endif
+ CEncoderInfo *encoder = decoder->Encoder;
+ encoder->Results[decoder->DecoderIndex] = encoder->Decode(decoder->DecoderIndex);
+ return 0;
+ }
+
+ HRESULT CreateEncoderThread()
+ {
+ return thread[0].Create(EncodeThreadFunction, this);
+ }
+
+ HRESULT CreateDecoderThread(int index, bool callbackMode
+ #ifdef USE_ALLOCA
+ , size_t allocaSize
+ #endif
+ )
+ {
+ CDecoderInfo &decoder = decodersInfo[index];
+ decoder.DecoderIndex = index;
+ decoder.Encoder = this;
+ #ifdef USE_ALLOCA
+ decoder.AllocaSize = allocaSize;
+ #endif
+ decoder.CallbackMode = callbackMode;
+ return thread[index].Create(DecodeThreadFunction, &decoder);
+ }
+ #endif
+};
+
+HRESULT CEncoderInfo::Init(UInt32 dictionarySize, UInt32 numThreads, CBaseRandomGenerator *rgLoc)
+{
+ rg.Set(rgLoc);
+ kBufferSize = dictionarySize + kAdditionalSize;
+ UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
+ if (!rg.Alloc(kBufferSize))
+ return E_OUTOFMEMORY;
+ rg.Generate();
+ crc = CrcCalc(rg.Buffer, rg.BufferSize);
+
+ outStreamSpec = new CBenchmarkOutStream;
+ if (!outStreamSpec->Alloc(kCompressedBufferSize))
+ return E_OUTOFMEMORY;
+
+ outStream = outStreamSpec;
+
+ propStreamSpec = 0;
+ if (!propStream)
+ {
+ propStreamSpec = new CBenchmarkOutStream;
+ propStream = propStreamSpec;
+ }
+ if (!propStreamSpec->Alloc(kMaxLzmaPropSize))
+ return E_OUTOFMEMORY;
+ propStreamSpec->Init();
+
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kDictionarySize,
+ NCoderPropID::kNumThreads
+ };
+ const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
+ PROPVARIANT props[kNumProps];
+ props[0].vt = VT_UI4;
+ props[0].ulVal = dictionarySize;
+
+ props[1].vt = VT_UI4;
+ props[1].ulVal = numThreads;
+
+ {
+ CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
+ RINOK(encoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties));
+ if (!setCoderProperties)
+ return E_FAIL;
+ RINOK(setCoderProperties->SetCoderProperties(propIDs, props, kNumProps));
+
+ CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
+ encoder.QueryInterface(IID_ICompressWriteCoderProperties, &writeCoderProperties);
+ if (writeCoderProperties)
+ {
+ RINOK(writeCoderProperties->WriteCoderProperties(propStream));
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CEncoderInfo::Encode()
+{
+ CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
+ CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
+ inStreamSpec->Init(rg.Buffer, rg.BufferSize);
+ outStreamSpec->Init();
+
+ RINOK(encoder->Code(inStream, outStream, 0, 0, progressInfo[0]));
+ compressedSize = outStreamSpec->Pos;
+ encoder.Release();
+ return S_OK;
+}
+
+HRESULT CEncoderInfo::Decode(UInt32 decoderIndex)
+{
+ CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
+ CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
+ CMyComPtr<ICompressCoder> &decoder = decoders[decoderIndex];
+
+ CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
+ decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &compressSetDecoderProperties);
+ if (!compressSetDecoderProperties)
+ return E_FAIL;
+
+ CCrcOutStream *crcOutStreamSpec = new CCrcOutStream;
+ CMyComPtr<ISequentialOutStream> crcOutStream = crcOutStreamSpec;
+
+ CBenchProgressInfo *pi = progressInfoSpec[decoderIndex];
+ pi->BenchInfo.UnpackSize = 0;
+ pi->BenchInfo.PackSize = 0;
+
+ for (UInt32 j = 0; j < NumIterations; j++)
+ {
+ inStreamSpec->Init(outStreamSpec->Buffer, compressedSize);
+ crcOutStreamSpec->Init();
+
+ RINOK(compressSetDecoderProperties->SetDecoderProperties2(propStreamSpec->Buffer, propStreamSpec->Pos));
+ UInt64 outSize = kBufferSize;
+ RINOK(decoder->Code(inStream, crcOutStream, 0, &outSize, progressInfo[decoderIndex]));
+ if (CRC_GET_DIGEST(crcOutStreamSpec->Crc) != crc)
+ return S_FALSE;
+ pi->BenchInfo.UnpackSize += kBufferSize;
+ pi->BenchInfo.PackSize += compressedSize;
+ }
+ decoder.Release();
+ return S_OK;
+}
+
+static const UInt32 kNumThreadsMax = (1 << 16);
+
+struct CBenchEncoders
+{
+ CEncoderInfo *encoders;
+ CBenchEncoders(UInt32 num): encoders(0) { encoders = new CEncoderInfo[num]; }
+ ~CBenchEncoders() { delete []encoders; }
+};
+
+HRESULT LzmaBench(
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs,
+ #endif
+ UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback)
+{
+ UInt32 numEncoderThreads =
+ #ifdef BENCH_MT
+ (numThreads > 1 ? numThreads / 2 : 1);
+ #else
+ 1;
+ #endif
+ UInt32 numSubDecoderThreads =
+ #ifdef BENCH_MT
+ (numThreads > 1 ? 2 : 1);
+ #else
+ 1;
+ #endif
+ if (dictionarySize < (1 << kBenchMinDicLogSize) || numThreads < 1 || numEncoderThreads > kNumThreadsMax)
+ {
+ return E_INVALIDARG;
+ }
+
+ CBenchEncoders encodersSpec(numEncoderThreads);
+ CEncoderInfo *encoders = encodersSpec.encoders;
+
+ #ifdef EXTERNAL_LZMA
+ UString name = L"LZMA";
+ #endif
+
+ UInt32 i;
+ for (i = 0; i < numEncoderThreads; i++)
+ {
+ CEncoderInfo &encoder = encoders[i];
+ encoder.callback = (i == 0) ? callback : 0;
+
+ #ifdef EXTERNAL_LZMA
+ RINOK(codecs->CreateCoder(name, true, encoder.encoder));
+ #else
+ encoder.encoder = new NCompress::NLzma::CEncoder;
+ #endif
+ for (UInt32 j = 0; j < numSubDecoderThreads; j++)
+ {
+ #ifdef EXTERNAL_LZMA
+ RINOK(codecs->CreateCoder(name, false, encoder.decoders[j]));
+ #else
+ encoder.decoders[j] = new NCompress::NLzma::CDecoder;
+ #endif
+ }
+ }
+
+ CBaseRandomGenerator rg;
+ rg.Init();
+ for (i = 0; i < numEncoderThreads; i++)
+ {
+ RINOK(encoders[i].Init(dictionarySize, numThreads, &rg));
+ }
+
+ CBenchProgressStatus status;
+ status.Res = S_OK;
+ status.EncodeMode = true;
+
+ for (i = 0; i < numEncoderThreads; i++)
+ {
+ CEncoderInfo &encoder = encoders[i];
+ for (int j = 0; j < 2; j++)
+ {
+ encoder.progressInfo[j] = encoder.progressInfoSpec[j] = new CBenchProgressInfo;
+ encoder.progressInfoSpec[j]->Status = &status;
+ }
+ if (i == 0)
+ {
+ encoder.progressInfoSpec[0]->callback = callback;
+ encoder.progressInfoSpec[0]->BenchInfo.NumIterations = numEncoderThreads;
+ SetStartTime(encoder.progressInfoSpec[0]->BenchInfo);
+ }
+
+ #ifdef BENCH_MT
+ if (numEncoderThreads > 1)
+ {
+ #ifdef USE_ALLOCA
+ encoder.AllocaSize = (i * 16 * 21) & 0x7FF;
+ #endif
+ RINOK(encoder.CreateEncoderThread())
+ }
+ else
+ #endif
+ {
+ RINOK(encoder.Encode());
+ }
+ }
+ #ifdef BENCH_MT
+ if (numEncoderThreads > 1)
+ for (i = 0; i < numEncoderThreads; i++)
+ encoders[i].thread[0].Wait();
+ #endif
+
+ RINOK(status.Res);
+
+ CBenchInfo info;
+
+ SetFinishTime(encoders[0].progressInfoSpec[0]->BenchInfo, info);
+ info.UnpackSize = 0;
+ info.PackSize = 0;
+ info.NumIterations = 1; // progressInfoSpec->NumIterations;
+ for (i = 0; i < numEncoderThreads; i++)
+ {
+ CEncoderInfo &encoder = encoders[i];
+ info.UnpackSize += encoder.kBufferSize;
+ info.PackSize += encoder.compressedSize;
+ }
+ RINOK(callback->SetEncodeResult(info, true));
+
+
+ status.Res = S_OK;
+ status.EncodeMode = false;
+
+ UInt32 numDecoderThreads = numEncoderThreads * numSubDecoderThreads;
+ for (i = 0; i < numEncoderThreads; i++)
+ {
+ CEncoderInfo &encoder = encoders[i];
+ encoder.NumIterations = 2 + kUncompressMinBlockSize / encoder.kBufferSize;
+
+ if (i == 0)
+ {
+ encoder.progressInfoSpec[0]->callback = callback;
+ encoder.progressInfoSpec[0]->BenchInfo.NumIterations = numDecoderThreads;
+ SetStartTime(encoder.progressInfoSpec[0]->BenchInfo);
+ }
+
+ #ifdef BENCH_MT
+ if (numDecoderThreads > 1)
+ {
+ for (UInt32 j = 0; j < numSubDecoderThreads; j++)
+ {
+ HRESULT res = encoder.CreateDecoderThread(j, (i == 0 && j == 0)
+ #ifdef USE_ALLOCA
+ , ((i * numSubDecoderThreads + j) * 16 * 21) & 0x7FF
+ #endif
+ );
+ RINOK(res);
+ }
+ }
+ else
+ #endif
+ {
+ RINOK(encoder.Decode(0));
+ }
+ }
+ #ifdef BENCH_MT
+ HRESULT res = S_OK;
+ if (numDecoderThreads > 1)
+ for (i = 0; i < numEncoderThreads; i++)
+ for (UInt32 j = 0; j < numSubDecoderThreads; j++)
+ {
+ CEncoderInfo &encoder = encoders[i];
+ encoder.thread[j].Wait();
+ if (encoder.Results[j] != S_OK)
+ res = encoder.Results[j];
+ }
+ RINOK(res);
+ #endif
+ RINOK(status.Res);
+ SetFinishTime(encoders[0].progressInfoSpec[0]->BenchInfo, info);
+ info.UnpackSize = 0;
+ info.PackSize = 0;
+ info.NumIterations = numSubDecoderThreads * encoders[0].NumIterations;
+ for (i = 0; i < numEncoderThreads; i++)
+ {
+ CEncoderInfo &encoder = encoders[i];
+ info.UnpackSize += encoder.kBufferSize;
+ info.PackSize += encoder.compressedSize;
+ }
+ RINOK(callback->SetDecodeResult(info, false));
+ RINOK(callback->SetDecodeResult(info, true));
+ return S_OK;
+}
+
+
+inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary)
+{
+ UInt32 hs = dictionary - 1;
+ hs |= (hs >> 1);
+ hs |= (hs >> 2);
+ hs |= (hs >> 4);
+ hs |= (hs >> 8);
+ hs >>= 1;
+ hs |= 0xFFFF;
+ if (hs > (1 << 24))
+ hs >>= 1;
+ hs++;
+ return ((hs + (1 << 16)) + (UInt64)dictionary * 2) * 4 + (UInt64)dictionary * 3 / 2 +
+ (1 << 20) + (multiThread ? (6 << 20) : 0);
+}
+
+UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary)
+{
+ const UInt32 kBufferSize = dictionary;
+ const UInt32 kCompressedBufferSize = (kBufferSize / 2);
+ UInt32 numSubThreads = (numThreads > 1) ? 2 : 1;
+ UInt32 numBigThreads = numThreads / numSubThreads;
+ return (kBufferSize + kCompressedBufferSize +
+ GetLZMAUsage((numThreads > 1), dictionary) + (2 << 20)) * numBigThreads;
+}
+
+static bool CrcBig(const void *data, UInt32 size, UInt32 numCycles, UInt32 crcBase)
+{
+ for (UInt32 i = 0; i < numCycles; i++)
+ if (CrcCalc(data, size) != crcBase)
+ return false;
+ return true;
+}
+
+#ifdef BENCH_MT
+struct CCrcInfo
+{
+ NWindows::CThread Thread;
+ const Byte *Data;
+ UInt32 Size;
+ UInt32 NumCycles;
+ UInt32 Crc;
+ bool Res;
+ void Wait()
+ {
+ Thread.Wait();
+ Thread.Close();
+ }
+};
+
+static THREAD_FUNC_DECL CrcThreadFunction(void *param)
+{
+ CCrcInfo *p = (CCrcInfo *)param;
+ p->Res = CrcBig(p->Data, p->Size, p->NumCycles, p->Crc);
+ return 0;
+}
+
+struct CCrcThreads
+{
+ UInt32 NumThreads;
+ CCrcInfo *Items;
+ CCrcThreads(): NumThreads(0), Items(0) {}
+ void WaitAll()
+ {
+ for (UInt32 i = 0; i < NumThreads; i++)
+ Items[i].Wait();
+ NumThreads = 0;
+ }
+ ~CCrcThreads()
+ {
+ WaitAll();
+ delete []Items;
+ }
+};
+#endif
+
+static UInt32 CrcCalc1(const Byte *buf, UInt32 size)
+{
+ UInt32 crc = CRC_INIT_VAL;;
+ for (UInt32 i = 0; i < size; i++)
+ crc = CRC_UPDATE_BYTE(crc, buf[i]);
+ return CRC_GET_DIGEST(crc);
+}
+
+static void RandGen(Byte *buf, UInt32 size, CBaseRandomGenerator &RG)
+{
+ for (UInt32 i = 0; i < size; i++)
+ buf[i] = (Byte)RG.GetRnd();
+}
+
+static UInt32 RandGenCrc(Byte *buf, UInt32 size, CBaseRandomGenerator &RG)
+{
+ RandGen(buf, size, RG);
+ return CrcCalc1(buf, size);
+}
+
+bool CrcInternalTest()
+{
+ CBenchBuffer buffer;
+ const UInt32 kBufferSize0 = (1 << 8);
+ const UInt32 kBufferSize1 = (1 << 10);
+ const UInt32 kCheckSize = (1 << 5);
+ if (!buffer.Alloc(kBufferSize0 + kBufferSize1))
+ return false;
+ Byte *buf = buffer.Buffer;
+ UInt32 i;
+ for (i = 0; i < kBufferSize0; i++)
+ buf[i] = (Byte)i;
+ UInt32 crc1 = CrcCalc1(buf, kBufferSize0);
+ if (crc1 != 0x29058C73)
+ return false;
+ CBaseRandomGenerator RG;
+ RandGen(buf + kBufferSize0, kBufferSize1, RG);
+ for (i = 0; i < kBufferSize0 + kBufferSize1 - kCheckSize; i++)
+ for (UInt32 j = 0; j < kCheckSize; j++)
+ if (CrcCalc1(buf + i, j) != CrcCalc(buf + i, j))
+ return false;
+ return true;
+}
+
+HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed)
+{
+ if (numThreads == 0)
+ numThreads = 1;
+
+ CBenchBuffer buffer;
+ size_t totalSize = (size_t)bufferSize * numThreads;
+ if (totalSize / numThreads != bufferSize)
+ return E_OUTOFMEMORY;
+ if (!buffer.Alloc(totalSize))
+ return E_OUTOFMEMORY;
+
+ Byte *buf = buffer.Buffer;
+ CBaseRandomGenerator RG;
+ UInt32 numCycles = ((UInt32)1 << 30) / ((bufferSize >> 2) + 1) + 1;
+
+ UInt64 timeVal;
+ #ifdef BENCH_MT
+ CCrcThreads threads;
+ if (numThreads > 1)
+ {
+ threads.Items = new CCrcInfo[numThreads];
+ UInt32 i;
+ for (i = 0; i < numThreads; i++)
+ {
+ CCrcInfo &info = threads.Items[i];
+ Byte *data = buf + (size_t)bufferSize * i;
+ info.Data = data;
+ info.NumCycles = numCycles;
+ info.Size = bufferSize;
+ info.Crc = RandGenCrc(data, bufferSize, RG);
+ }
+ timeVal = GetTimeCount();
+ for (i = 0; i < numThreads; i++)
+ {
+ CCrcInfo &info = threads.Items[i];
+ RINOK(info.Thread.Create(CrcThreadFunction, &info));
+ threads.NumThreads++;
+ }
+ threads.WaitAll();
+ for (i = 0; i < numThreads; i++)
+ if (!threads.Items[i].Res)
+ return S_FALSE;
+ }
+ else
+ #endif
+ {
+ UInt32 crc = RandGenCrc(buf, bufferSize, RG);
+ timeVal = GetTimeCount();
+ if (!CrcBig(buf, bufferSize, numCycles, crc))
+ return S_FALSE;
+ }
+ timeVal = GetTimeCount() - timeVal;
+ if (timeVal == 0)
+ timeVal = 1;
+
+ UInt64 size = (UInt64)numCycles * totalSize;
+ speed = MyMultDiv64(size, timeVal, GetFreq());
+ return S_OK;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h
new file mode 100644
index 000000000..d3cc68678
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h
@@ -0,0 +1,49 @@
+// LzmaBench.h
+
+#ifndef __LZMABENCH_H
+#define __LZMABENCH_H
+
+#include <stdio.h>
+#include "../../../Common/Types.h"
+#ifdef EXTERNAL_LZMA
+#include "../../UI/Common/LoadCodecs.h"
+#endif
+
+struct CBenchInfo
+{
+ UInt64 GlobalTime;
+ UInt64 GlobalFreq;
+ UInt64 UserTime;
+ UInt64 UserFreq;
+ UInt64 UnpackSize;
+ UInt64 PackSize;
+ UInt32 NumIterations;
+ CBenchInfo(): NumIterations(0) {}
+};
+
+struct IBenchCallback
+{
+ virtual ~IBenchCallback() {}
+ virtual HRESULT SetEncodeResult(const CBenchInfo &info, bool final) = 0;
+ virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0;
+};
+
+UInt64 GetUsage(const CBenchInfo &benchOnfo);
+UInt64 GetRatingPerUsage(const CBenchInfo &info, UInt64 rating);
+UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
+UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations);
+
+HRESULT LzmaBench(
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs,
+ #endif
+ UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback);
+
+const int kBenchMinDicLogSize = 18;
+
+UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary);
+
+bool CrcInternalTest();
+HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
new file mode 100644
index 000000000..10eca48bb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
@@ -0,0 +1,311 @@
+// LzmaBenchCon.cpp
+
+#include "StdAfx.h"
+
+#include <stdio.h>
+
+#include "LzmaBench.h"
+#include "LzmaBenchCon.h"
+#include "../../../Common/IntToString.h"
+
+#if defined(BENCH_MT) || defined(_WIN32)
+#include "../../../Windows/System.h"
+#endif
+
+#ifdef BREAK_HANDLER
+#include "../../UI/Console/ConsoleClose.h"
+#endif
+#include "../../../Common/MyCom.h"
+
+struct CTotalBenchRes
+{
+ UInt64 NumIterations;
+ UInt64 Rating;
+ UInt64 Usage;
+ UInt64 RPU;
+ void Init() { NumIterations = 0; Rating = 0; Usage = 0; RPU = 0; }
+ void Normalize()
+ {
+ if (NumIterations == 0)
+ return;
+ Rating /= NumIterations;
+ Usage /= NumIterations;
+ RPU /= NumIterations;
+ NumIterations = 1;
+ }
+ void SetMid(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
+ {
+ Rating = (r1.Rating + r2.Rating) / 2;
+ Usage = (r1.Usage + r2.Usage) / 2;
+ RPU = (r1.RPU + r2.RPU) / 2;
+ NumIterations = (r1.NumIterations + r2.NumIterations) / 2;
+ }
+};
+
+struct CBenchCallback: public IBenchCallback
+{
+ CTotalBenchRes EncodeRes;
+ CTotalBenchRes DecodeRes;
+ FILE *f;
+ void Init() { EncodeRes.Init(); DecodeRes.Init(); }
+ void Normalize() { EncodeRes.Normalize(); DecodeRes.Normalize(); }
+ UInt32 dictionarySize;
+ HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
+ HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
+};
+
+static void NormalizeVals(UInt64 &v1, UInt64 &v2)
+{
+ while (v1 > 1000000)
+ {
+ v1 >>= 1;
+ v2 >>= 1;
+ }
+}
+
+static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
+{
+ UInt64 elTime = elapsedTime;
+ NormalizeVals(freq, elTime);
+ if (elTime == 0)
+ elTime = 1;
+ return value * freq / elTime;
+}
+
+static void PrintNumber(FILE *f, UInt64 value, int size)
+{
+ char s[32];
+ ConvertUInt64ToString(value, s);
+ fprintf(f, " ");
+ for (int len = (int)strlen(s); len < size; len++)
+ fprintf(f, " ");
+ fprintf(f, "%s", s);
+}
+
+static void PrintRating(FILE *f, UInt64 rating)
+{
+ PrintNumber(f, rating / 1000000, 6);
+}
+
+static void PrintResults(FILE *f, UInt64 usage, UInt64 rpu, UInt64 rating)
+{
+ PrintNumber(f, (usage + 5000) / 10000, 5);
+ PrintRating(f, rpu);
+ PrintRating(f, rating);
+}
+
+
+static void PrintResults(FILE *f, const CBenchInfo &info, UInt64 rating, CTotalBenchRes &res)
+{
+ UInt64 speed = MyMultDiv64(info.UnpackSize, info.GlobalTime, info.GlobalFreq);
+ PrintNumber(f, speed / 1024, 7);
+ UInt64 usage = GetUsage(info);
+ UInt64 rpu = GetRatingPerUsage(info, rating);
+ PrintResults(f, usage, rpu, rating);
+ res.NumIterations++;
+ res.RPU += rpu;
+ res.Rating += rating;
+ res.Usage += usage;
+}
+
+static void PrintTotals(FILE *f, const CTotalBenchRes &res)
+{
+ fprintf(f, " ");
+ PrintResults(f, res.Usage, res.RPU, res.Rating);
+}
+
+
+HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
+{
+ #ifdef BREAK_HANDLER
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ #endif
+
+ if (final)
+ {
+ UInt64 rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, info.UnpackSize);
+ PrintResults(f, info, rating, EncodeRes);
+ }
+ return S_OK;
+}
+
+static const char *kSep = " | ";
+
+
+HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
+{
+ #ifdef BREAK_HANDLER
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ #endif
+ if (final)
+ {
+ UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
+ fprintf(f, kSep);
+ CBenchInfo info2 = info;
+ info2.UnpackSize *= info2.NumIterations;
+ info2.PackSize *= info2.NumIterations;
+ info2.NumIterations = 1;
+ PrintResults(f, info2, rating, DecodeRes);
+ }
+ return S_OK;
+}
+
+static void PrintRequirements(FILE *f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
+{
+ fprintf(f, "\nRAM %s ", sizeString);
+ PrintNumber(f, (size >> 20), 5);
+ fprintf(f, " MB, # %s %3d", threadsString, (unsigned int)numThreads);
+}
+
+HRESULT LzmaBenchCon(
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs,
+ #endif
+ FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
+{
+ if (!CrcInternalTest())
+ return S_FALSE;
+ #ifdef BENCH_MT
+ UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
+ UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
+ PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
+ if (numThreads == (UInt32)-1)
+ numThreads = numCPUs;
+ if (numThreads > 1)
+ numThreads &= ~1;
+ if (dictionary == (UInt32)-1)
+ {
+ int dicSizeLog;
+ for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
+ if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
+ break;
+ dictionary = (1 << dicSizeLog);
+ }
+ #else
+ if (dictionary == (UInt32)-1)
+ dictionary = (1 << 22);
+ numThreads = 1;
+ #endif
+
+ PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dictionary), "Benchmark threads: ", numThreads);
+
+ CBenchCallback callback;
+ callback.Init();
+ callback.f = f;
+
+ fprintf(f, "\n\nDict Compressing | Decompressing\n ");
+ int j;
+ for (j = 0; j < 2; j++)
+ {
+ fprintf(f, " Speed Usage R/U Rating");
+ if (j == 0)
+ fprintf(f, kSep);
+ }
+ fprintf(f, "\n ");
+ for (j = 0; j < 2; j++)
+ {
+ fprintf(f, " KB/s %% MIPS MIPS");
+ if (j == 0)
+ fprintf(f, kSep);
+ }
+ fprintf(f, "\n\n");
+ for (UInt32 i = 0; i < numIterations; i++)
+ {
+ const int kStartDicLog = 22;
+ int pow = (dictionary < ((UInt32)1 << kStartDicLog)) ? kBenchMinDicLogSize : kStartDicLog;
+ while (((UInt32)1 << pow) > dictionary)
+ pow--;
+ for (; ((UInt32)1 << pow) <= dictionary; pow++)
+ {
+ fprintf(f, "%2d:", pow);
+ callback.dictionarySize = (UInt32)1 << pow;
+ HRESULT res = LzmaBench(
+ #ifdef EXTERNAL_LZMA
+ codecs,
+ #endif
+ numThreads, callback.dictionarySize, &callback);
+ fprintf(f, "\n");
+ RINOK(res);
+ }
+ }
+ callback.Normalize();
+ fprintf(f, "----------------------------------------------------------------\nAvr:");
+ PrintTotals(f, callback.EncodeRes);
+ fprintf(f, " ");
+ PrintTotals(f, callback.DecodeRes);
+ fprintf(f, "\nTot:");
+ CTotalBenchRes midRes;
+ midRes.SetMid(callback.EncodeRes, callback.DecodeRes);
+ PrintTotals(f, midRes);
+ fprintf(f, "\n");
+ return S_OK;
+}
+
+struct CTempValues
+{
+ UInt64 *Values;
+ CTempValues(UInt32 num) { Values = new UInt64[num]; }
+ ~CTempValues() { delete []Values; }
+};
+
+HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
+{
+ if (!CrcInternalTest())
+ return S_FALSE;
+
+ #ifdef BENCH_MT
+ UInt64 ramSize = NWindows::NSystem::GetRamSize();
+ UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
+ PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
+ if (numThreads == (UInt32)-1)
+ numThreads = numCPUs;
+ #else
+ numThreads = 1;
+ #endif
+ if (dictionary == (UInt32)-1)
+ dictionary = (1 << 24);
+
+ CTempValues speedTotals(numThreads);
+ fprintf(f, "\n\nSize");
+ for (UInt32 ti = 0; ti < numThreads; ti++)
+ {
+ fprintf(f, " %5d", static_cast< int >( ti + 1 ) );
+ speedTotals.Values[ti] = 0;
+ }
+ fprintf(f, "\n\n");
+
+ UInt64 numSteps = 0;
+ for (UInt32 i = 0; i < numIterations; i++)
+ {
+ for (int pow = 10; pow < 32; pow++)
+ {
+ UInt32 bufSize = (UInt32)1 << pow;
+ if (bufSize > dictionary)
+ break;
+ fprintf(f, "%2d: ", pow);
+ UInt64 speed;
+ for (UInt32 ti = 0; ti < numThreads; ti++)
+ {
+ #ifdef BREAK_HANDLER
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ #endif
+ RINOK(CrcBench(ti + 1, bufSize, speed));
+ PrintNumber(f, (speed >> 20), 5);
+ speedTotals.Values[ti] += speed;
+ }
+ fprintf(f, "\n");
+ numSteps++;
+ }
+ }
+ if (numSteps != 0)
+ {
+ fprintf(f, "\nAvg:");
+ for (UInt32 ti = 0; ti < numThreads; ti++)
+ PrintNumber(f, ((speedTotals.Values[ti] / numSteps) >> 20), 5);
+ fprintf(f, "\n");
+ }
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h
new file mode 100644
index 000000000..ea8539d19
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h
@@ -0,0 +1,20 @@
+// LzmaBenchCon.h
+
+#ifndef __LZMABENCHCON_H
+#define __LZMABENCHCON_H
+
+#include <stdio.h>
+#include "../../../Common/Types.h"
+#ifdef EXTERNAL_LZMA
+#include "../../UI/Common/LoadCodecs.h"
+#endif
+HRESULT LzmaBenchCon(
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs,
+ #endif
+ FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
+
+HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzOutWindow.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzOutWindow.cpp
new file mode 100644
index 000000000..df46295bd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzOutWindow.cpp
@@ -0,0 +1,14 @@
+// LzOutWindow.cpp
+
+#include "StdAfx.h"
+
+#include "LzOutWindow.h"
+
+void CLzOutWindow::Init(bool solid)
+{
+ if (!solid)
+ COutBuffer::Init();
+ #ifdef _NO_EXCEPTIONS
+ ErrorCode = S_OK;
+ #endif
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzOutWindow.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzOutWindow.h
new file mode 100644
index 000000000..d8d13c225
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzOutWindow.h
@@ -0,0 +1,66 @@
+// LzOutWindow.h
+
+#ifndef __LZ_OUT_WINDOW_H
+#define __LZ_OUT_WINDOW_H
+
+#include "../IStream.h"
+
+#include "../Common/OutBuffer.h"
+
+#ifndef _NO_EXCEPTIONS
+typedef COutBufferException CLzOutWindowException;
+#endif
+
+class CLzOutWindow: public COutBuffer
+{
+public:
+ void Init(bool solid = false);
+
+ // distance >= 0, len > 0,
+ bool CopyBlock(UInt32 distance, UInt32 len)
+ {
+ UInt32 pos = _pos - distance - 1;
+ if (distance >= _pos)
+ {
+ if (!_overDict || distance >= _bufferSize)
+ return false;
+ pos += _bufferSize;
+ }
+ if (_limitPos - _pos > len && _bufferSize - pos > len)
+ {
+ const Byte *src = _buffer + pos;
+ Byte *dest = _buffer + _pos;
+ _pos += len;
+ do
+ *dest++ = *src++;
+ while(--len != 0);
+ }
+ else do
+ {
+ if (pos == _bufferSize)
+ pos = 0;
+ _buffer[_pos++] = _buffer[pos++];
+ if (_pos == _limitPos)
+ FlushWithCheck();
+ }
+ while(--len != 0);
+ return true;
+ }
+
+ void PutByte(Byte b)
+ {
+ _buffer[_pos++] = b;
+ if (_pos == _limitPos)
+ FlushWithCheck();
+ }
+
+ Byte GetByte(UInt32 distance) const
+ {
+ UInt32 pos = _pos - distance - 1;
+ if (pos >= _bufferSize)
+ pos += _bufferSize;
+ return _buffer[pos];
+ }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzhDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzhDecoder.cpp
new file mode 100644
index 000000000..6f9b5065e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzhDecoder.cpp
@@ -0,0 +1,220 @@
+// LzhDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "LzhDecoder.h"
+
+#include "Windows/Defs.h"
+
+namespace NCompress{
+namespace NLzh {
+namespace NDecoder {
+
+static const UInt32 kHistorySize = (1 << 16);
+
+static const int kBlockSizeBits = 16;
+static const int kNumCBits = 9;
+static const int kNumLevelBits = 5; // smallest integer such that (1 << kNumLevelBits) > kNumLevelSymbols/
+
+UInt32 CCoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+
+HRESULT CCoder::ReadLevelTable()
+{
+ int n = ReadBits(kNumLevelBits);
+ if (n == 0)
+ {
+ m_LevelHuffman.Symbol = ReadBits(kNumLevelBits);
+ if (m_LevelHuffman.Symbol >= kNumLevelSymbols)
+ return S_FALSE;
+ }
+ else
+ {
+ if (n > kNumLevelSymbols)
+ return S_FALSE;
+ m_LevelHuffman.Symbol = -1;
+ Byte lens[kNumLevelSymbols];
+ int i = 0;
+ while (i < n)
+ {
+ int c = m_InBitStream.ReadBits(3);
+ if (c == 7)
+ while (ReadBits(1))
+ if (c++ > kMaxHuffmanLen)
+ return S_FALSE;
+ lens[i++] = (Byte)c;
+ if (i == kNumSpecLevelSymbols)
+ {
+ c = ReadBits(2);
+ while (--c >= 0)
+ lens[i++] = 0;
+ }
+ }
+ while (i < kNumLevelSymbols)
+ lens[i++] = 0;
+ m_LevelHuffman.SetCodeLengths(lens);
+ }
+ return S_OK;
+}
+
+HRESULT CCoder::ReadPTable(int numBits)
+{
+ int n = ReadBits(numBits);
+ if (n == 0)
+ {
+ m_PHuffmanDecoder.Symbol = ReadBits(numBits);
+ if (m_PHuffmanDecoder.Symbol >= kNumDistanceSymbols)
+ return S_FALSE;
+ }
+ else
+ {
+ if (n > kNumDistanceSymbols)
+ return S_FALSE;
+ m_PHuffmanDecoder.Symbol = -1;
+ Byte lens[kNumDistanceSymbols];
+ int i = 0;
+ while (i < n)
+ {
+ int c = m_InBitStream.ReadBits(3);
+ if (c == 7)
+ while (ReadBits(1))
+ {
+ if (c > kMaxHuffmanLen)
+ return S_FALSE;
+ c++;
+ }
+ lens[i++] = (Byte)c;
+ }
+ while (i < kNumDistanceSymbols)
+ lens[i++] = 0;
+ m_PHuffmanDecoder.SetCodeLengths(lens);
+ }
+ return S_OK;
+}
+
+HRESULT CCoder::ReadCTable()
+{
+ int n = ReadBits(kNumCBits);
+ if (n == 0)
+ {
+ m_CHuffmanDecoder.Symbol = ReadBits(kNumCBits);
+ if (m_CHuffmanDecoder.Symbol >= kNumCSymbols)
+ return S_FALSE;
+ }
+ else
+ {
+ if (n > kNumCSymbols)
+ return S_FALSE;
+ m_CHuffmanDecoder.Symbol = -1;
+ Byte lens[kNumCSymbols];
+ int i = 0;
+ while (i < n)
+ {
+ int c = m_LevelHuffman.Decode(&m_InBitStream);
+ if (c < kNumSpecLevelSymbols)
+ {
+ if (c == 0)
+ c = 1;
+ else if (c == 1)
+ c = ReadBits(4) + 3;
+ else
+ c = ReadBits(kNumCBits) + 20;
+ while (--c >= 0)
+ {
+ if (i > kNumCSymbols)
+ return S_FALSE;
+ lens[i++] = 0;
+ }
+ }
+ else
+ lens[i++] = (Byte)(c - 2);
+ }
+ while (i < kNumCSymbols)
+ lens[i++] = 0;
+ m_CHuffmanDecoder.SetCodeLengths(lens);
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ if (outSize == NULL)
+ return E_INVALIDARG;
+
+ if (!m_OutWindowStream.Create(kHistorySize))
+ return E_OUTOFMEMORY;
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ UInt64 pos = 0;
+ m_OutWindowStream.SetStream(outStream);
+ m_OutWindowStream.Init(false);
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+
+ CCoderReleaser coderReleaser(this);
+
+ int pbit;
+ if (m_NumDictBits <= 13)
+ pbit = 4;
+ else
+ pbit = 5;
+
+ UInt32 blockSize = 0;
+
+ while(pos < *outSize)
+ {
+ // for (i = 0; i < dictSize; i++) dtext[i] = 0x20;
+
+ if (blockSize == 0)
+ {
+ if (progress != NULL)
+ {
+ UInt64 packSize = m_InBitStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &pos));
+ }
+ blockSize = ReadBits(kBlockSizeBits);
+ ReadLevelTable();
+ ReadCTable();
+ RINOK(ReadPTable(pbit));
+ }
+ blockSize--;
+ UInt32 c = m_CHuffmanDecoder.Decode(&m_InBitStream);
+ if (c < 256)
+ {
+ m_OutWindowStream.PutByte((Byte)c);
+ pos++;
+ }
+ else if (c >= kNumCSymbols)
+ return S_FALSE;
+ else
+ {
+ // offset = (interface->method == LARC_METHOD_NUM) ? 0x100 - 2 : 0x100 - 3;
+ UInt32 len = c - 256 + kMinMatch;
+ UInt32 distance = m_PHuffmanDecoder.Decode(&m_InBitStream);
+ if (distance != 0)
+ distance = (1 << (distance - 1)) + ReadBits(distance - 1);
+ if (distance >= pos)
+ return S_FALSE;
+ if (pos + len > *outSize)
+ len = (UInt32)(*outSize - pos);
+ pos += len;
+ m_OutWindowStream.CopyBlock(distance, len);
+ }
+ }
+ coderReleaser.NeedFlush = false;
+ return m_OutWindowStream.Flush();
+}
+
+STDMETHODIMP CCoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress);}
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzhDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzhDecoder.h
new file mode 100644
index 000000000..ed631e20d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzhDecoder.h
@@ -0,0 +1,106 @@
+// LzhDecoder.h
+
+#ifndef __COMPRESS_LZH_DECODER_H
+#define __COMPRESS_LZH_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "BitmDecoder.h"
+#include "HuffmanDecoder.h"
+#include "LzOutWindow.h"
+
+namespace NCompress {
+namespace NLzh {
+namespace NDecoder {
+
+const int kMaxHuffmanLen = 16; // Check it
+
+const int kNumSpecLevelSymbols = 3;
+const int kNumLevelSymbols = kNumSpecLevelSymbols + kMaxHuffmanLen;
+
+const int kDictBitsMax = 16;
+const int kNumDistanceSymbols = kDictBitsMax + 1;
+
+const int kMaxMatch = 256;
+const int kMinMatch = 3;
+const int kNumCSymbols = 256 + kMaxMatch + 2 - kMinMatch;
+
+template <UInt32 m_NumSymbols>
+class CHuffmanDecoder:public NCompress::NHuffman::CDecoder<kMaxHuffmanLen, m_NumSymbols>
+{
+public:
+ int Symbol;
+ template <class TBitDecoder>
+ UInt32 Decode(TBitDecoder *bitStream)
+ {
+ if (Symbol >= 0)
+ return (UInt32)Symbol;
+ return DecodeSymbol(bitStream);
+ }
+};
+
+class CCoder :
+ public ICompressCoder,
+ public CMyUnknownImp
+{
+ CLzOutWindow m_OutWindowStream;
+ NBitm::CDecoder<CInBuffer> m_InBitStream;
+
+ int m_NumDictBits;
+
+ CHuffmanDecoder<kNumLevelSymbols> m_LevelHuffman;
+ CHuffmanDecoder<kNumDistanceSymbols> m_PHuffmanDecoder;
+ CHuffmanDecoder<kNumCSymbols> m_CHuffmanDecoder;
+
+ void ReleaseStreams()
+ {
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ }
+
+ class CCoderReleaser
+ {
+ CCoder *m_Coder;
+ public:
+ bool NeedFlush;
+ CCoderReleaser(CCoder *coder): m_Coder(coder), NeedFlush(true) {}
+ ~CCoderReleaser()
+ {
+ if (NeedFlush)
+ m_Coder->m_OutWindowStream.Flush();
+ m_Coder->ReleaseStreams();
+ }
+ };
+ friend class CCoderReleaser;
+
+ void MakeTable(int nchar, Byte *bitlen, int tablebits,
+ UInt32 *table, int tablesize);
+
+ UInt32 ReadBits(int numBits);
+ HRESULT ReadLevelTable();
+ HRESULT ReadPTable(int numBits);
+ HRESULT ReadCTable();
+
+public:
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(CodeReal)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ void SetDictionary(int numDictBits) { m_NumDictBits = numDictBits; }
+ CCoder(): m_NumDictBits(0) {}
+};
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Decoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Decoder.cpp
new file mode 100644
index 000000000..322015e29
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Decoder.cpp
@@ -0,0 +1,189 @@
+// Lzma2Decoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "../Common/StreamUtils.h"
+
+#include "Lzma2Decoder.h"
+
+static HRESULT SResToHRESULT(SRes res)
+{
+ switch(res)
+ {
+ case SZ_OK: return S_OK;
+ case SZ_ERROR_MEM: return E_OUTOFMEMORY;
+ case SZ_ERROR_PARAM: return E_INVALIDARG;
+ // case SZ_ERROR_PROGRESS: return E_ABORT;
+ case SZ_ERROR_DATA: return S_FALSE;
+ }
+ return E_FAIL;
+}
+
+namespace NCompress {
+namespace NLzma2 {
+
+static const UInt32 kInBufSize = 1 << 20;
+
+CDecoder::CDecoder(): _inBuf(0), _outSizeDefined(false)
+{
+ Lzma2Dec_Construct(&_state);
+}
+
+static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
+static void SzFree(void *p, void *address) { p = p; MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+CDecoder::~CDecoder()
+{
+ Lzma2Dec_Free(&_state, &g_Alloc);
+ MyFree(_inBuf);
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *prop, UInt32 size)
+{
+ if (size != 1) return SZ_ERROR_UNSUPPORTED;
+ RINOK(SResToHRESULT(Lzma2Dec_Allocate(&_state, prop[0], &g_Alloc)));
+ if (_inBuf == 0)
+ {
+ _inBuf = (Byte *)MyAlloc(kInBufSize);
+ if (_inBuf == 0)
+ return E_OUTOFMEMORY;
+ }
+
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value) { *value = _inSizeProcessed; return S_OK; }
+STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { _inStream = inStream; return S_OK; }
+STDMETHODIMP CDecoder::ReleaseInStream() { _inStream.Release(); return S_OK; }
+
+STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
+{
+ _outSizeDefined = (outSize != NULL);
+ if (_outSizeDefined)
+ _outSize = *outSize;
+
+ Lzma2Dec_Init(&_state);
+
+ _inPos = _inSize = 0;
+ _inSizeProcessed = _outSizeProcessed = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */,
+ const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ if (_inBuf == 0)
+ return S_FALSE;
+ SetOutStreamSize(outSize);
+
+ for (;;)
+ {
+ if (_inPos == _inSize)
+ {
+ _inPos = _inSize = 0;
+ RINOK(inStream->Read(_inBuf, kInBufSize, &_inSize));
+ }
+
+ SizeT dicPos = _state.decoder.dicPos;
+ SizeT curSize = _state.decoder.dicBufSize - dicPos;
+ const UInt32 kStepSize = ((UInt32)1 << 22);
+ if (curSize > kStepSize)
+ curSize = (SizeT)kStepSize;
+
+ ELzmaFinishMode finishMode = LZMA_FINISH_ANY;
+ if (_outSizeDefined)
+ {
+ const UInt64 rem = _outSize - _outSizeProcessed;
+ if (rem < curSize)
+ {
+ curSize = (SizeT)rem;
+ /*
+ // finishMode = LZMA_FINISH_END;
+ we can't use LZMA_FINISH_END here to allow partial decoding
+ */
+ }
+ }
+
+ SizeT inSizeProcessed = _inSize - _inPos;
+ ELzmaStatus status;
+ SRes res = Lzma2Dec_DecodeToDic(&_state, dicPos + curSize, _inBuf + _inPos, &inSizeProcessed, finishMode, &status);
+
+ _inPos += (UInt32)inSizeProcessed;
+ _inSizeProcessed += inSizeProcessed;
+ SizeT outSizeProcessed = _state.decoder.dicPos - dicPos;
+ _outSizeProcessed += outSizeProcessed;
+
+ bool finished = (inSizeProcessed == 0 && outSizeProcessed == 0);
+ bool stopDecoding = (_outSizeDefined && _outSizeProcessed >= _outSize);
+
+ if (res != 0 || _state.decoder.dicPos == _state.decoder.dicBufSize || finished || stopDecoding)
+ {
+ HRESULT res2 = WriteStream(outStream, _state.decoder.dic, _state.decoder.dicPos);
+ if (res != 0)
+ return S_FALSE;
+ RINOK(res2);
+ if (stopDecoding)
+ return S_OK;
+ if (finished)
+ return (status == LZMA_STATUS_FINISHED_WITH_MARK ? S_OK : S_FALSE);
+ }
+ if (_state.decoder.dicPos == _state.decoder.dicBufSize)
+ _state.decoder.dicPos = 0;
+
+ if (progress != NULL)
+ {
+ RINOK(progress->SetRatioInfo(&_inSizeProcessed, &_outSizeProcessed));
+ }
+ }
+}
+
+#ifndef NO_READ_FROM_CODER
+
+STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize)
+ *processedSize = 0;
+ do
+ {
+ if (_inPos == _inSize)
+ {
+ _inPos = _inSize = 0;
+ RINOK(_inStream->Read(_inBuf, kInBufSize, &_inSize));
+ }
+ {
+ SizeT inProcessed = _inSize - _inPos;
+
+ if (_outSizeDefined)
+ {
+ const UInt64 rem = _outSize - _outSizeProcessed;
+ if (rem < size)
+ size = (UInt32)rem;
+ }
+
+ SizeT outProcessed = size;
+ ELzmaStatus status;
+ SRes res = Lzma2Dec_DecodeToBuf(&_state, (Byte *)data, &outProcessed,
+ _inBuf + _inPos, &inProcessed, LZMA_FINISH_ANY, &status);
+ _inPos += (UInt32)inProcessed;
+ _inSizeProcessed += inProcessed;
+ _outSizeProcessed += outProcessed;
+ size -= (UInt32)outProcessed;
+ data = (Byte *)data + outProcessed;
+ if (processedSize)
+ *processedSize += (UInt32)outProcessed;
+ RINOK(SResToHRESULT(res));
+ if (inProcessed == 0 && outProcessed == 0)
+ return S_OK;
+ }
+ }
+ while (size != 0);
+ return S_OK;
+}
+
+#endif
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Decoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Decoder.h
new file mode 100644
index 000000000..fd7ca2f39
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Decoder.h
@@ -0,0 +1,73 @@
+// Lzma2Decoder.h
+
+#ifndef __LZMA2_DECODER_H
+#define __LZMA2_DECODER_H
+
+#include "../../../C/Lzma2Dec.h"
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+namespace NCompress {
+namespace NLzma2 {
+
+class CDecoder:
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public ICompressGetInStreamProcessedSize,
+ #ifndef NO_READ_FROM_CODER
+ public ICompressSetInStream,
+ public ICompressSetOutStreamSize,
+ public ISequentialInStream,
+ #endif
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialInStream> _inStream;
+ Byte *_inBuf;
+ UInt32 _inPos;
+ UInt32 _inSize;
+ CLzma2Dec _state;
+ bool _outSizeDefined;
+ UInt64 _outSize;
+ UInt64 _inSizeProcessed;
+ UInt64 _outSizeProcessed;
+public:
+
+ #ifndef NO_READ_FROM_CODER
+ MY_UNKNOWN_IMP5(
+ ICompressSetDecoderProperties2,
+ ICompressGetInStreamProcessedSize,
+ ICompressSetInStream,
+ ICompressSetOutStreamSize,
+ ISequentialInStream)
+ #else
+ MY_UNKNOWN_IMP2(
+ ICompressSetDecoderProperties2,
+ ICompressGetInStreamProcessedSize)
+ #endif
+
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *_inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+ STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
+
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream);
+ STDMETHOD(ReleaseInStream)();
+ STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
+
+ #ifndef NO_READ_FROM_CODER
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ #endif
+
+ CDecoder();
+ virtual ~CDecoder();
+
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Encoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Encoder.cpp
new file mode 100644
index 000000000..5e4c71bea
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Encoder.cpp
@@ -0,0 +1,94 @@
+// Lzma2Encoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "../Common/CWrappers.h"
+#include "../Common/StreamUtils.h"
+
+#include "Lzma2Encoder.h"
+
+namespace NCompress {
+
+namespace NLzma {
+
+HRESULT SetLzmaProp(PROPID propID, const PROPVARIANT &prop, CLzmaEncProps &ep);
+
+}
+
+namespace NLzma2 {
+
+static void *SzBigAlloc(void *, size_t size) { return BigAlloc(size); }
+static void SzBigFree(void *, void *address) { BigFree(address); }
+static ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree };
+
+static void *SzAlloc(void *, size_t size) { return MyAlloc(size); }
+static void SzFree(void *, void *address) { MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+CEncoder::CEncoder()
+{
+ _encoder = 0;
+ _encoder = Lzma2Enc_Create(&g_Alloc, &g_BigAlloc);
+ if (_encoder == 0)
+ throw 1;
+}
+
+CEncoder::~CEncoder()
+{
+ if (_encoder != 0)
+ Lzma2Enc_Destroy(_encoder);
+}
+
+HRESULT SetLzma2Prop(PROPID propID, const PROPVARIANT &prop, CLzma2EncProps &lzma2Props)
+{
+ switch (propID)
+ {
+ case NCoderPropID::kBlockSize:
+ if (prop.vt != VT_UI4) return E_INVALIDARG; lzma2Props.blockSize = prop.ulVal; break;
+ case NCoderPropID::kNumThreads:
+ if (prop.vt != VT_UI4) return E_INVALIDARG; lzma2Props.numTotalThreads = (int)(prop.ulVal); break;
+ default:
+ RINOK(NLzma::SetLzmaProp(propID, prop, lzma2Props.lzmaProps));
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
+ const PROPVARIANT *coderProps, UInt32 numProps)
+{
+ CLzma2EncProps lzma2Props;
+ Lzma2EncProps_Init(&lzma2Props);
+
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ RINOK(SetLzma2Prop(propIDs[i], coderProps[i], lzma2Props));
+ }
+ return SResToHRESULT(Lzma2Enc_SetProps(_encoder, &lzma2Props));
+}
+
+STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
+{
+ Byte prop = Lzma2Enc_WriteProperties(_encoder);
+ return WriteStream(outStream, &prop, 1);
+}
+
+STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
+{
+ CSeqInStreamWrap inWrap(inStream);
+ CSeqOutStreamWrap outWrap(outStream);
+ CCompressProgressWrap progressWrap(progress);
+
+ SRes res = Lzma2Enc_Encode(_encoder, &outWrap.p, &inWrap.p, progress ? &progressWrap.p : NULL);
+ if (res == SZ_ERROR_READ && inWrap.Res != S_OK)
+ return inWrap.Res;
+ if (res == SZ_ERROR_WRITE && outWrap.Res != S_OK)
+ return outWrap.Res;
+ if (res == SZ_ERROR_PROGRESS && progressWrap.Res != S_OK)
+ return progressWrap.Res;
+ return SResToHRESULT(res);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Encoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Encoder.h
new file mode 100644
index 000000000..f0fb74d33
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Encoder.h
@@ -0,0 +1,36 @@
+// Lzma2Encoder.h
+
+#ifndef __LZMA2_ENCODER_H
+#define __LZMA2_ENCODER_H
+
+#include "../../../C/Lzma2Enc.h"
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+namespace NCompress {
+namespace NLzma2 {
+
+class CEncoder:
+ public ICompressCoder,
+ public ICompressSetCoderProperties,
+ public ICompressWriteCoderProperties,
+ public CMyUnknownImp
+{
+ CLzma2EncHandle _encoder;
+public:
+ MY_UNKNOWN_IMP2(ICompressSetCoderProperties, ICompressWriteCoderProperties)
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
+ STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+
+ CEncoder();
+ virtual ~CEncoder();
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Register.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Register.cpp
new file mode 100644
index 000000000..cace871ef
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzma2Register.cpp
@@ -0,0 +1,20 @@
+// Lzma2Register.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "Lzma2Decoder.h"
+
+static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NLzma2::CDecoder); }
+#ifndef EXTRACT_ONLY
+#include "Lzma2Encoder.h"
+static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NLzma2::CEncoder); }
+#else
+#define CreateCodecOut 0
+#endif
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodec, CreateCodecOut, 0x21, L"LZMA2", 1, false };
+
+REGISTER_CODEC(LZMA2)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaDecoder.cpp
new file mode 100644
index 000000000..c74d5ade3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaDecoder.cpp
@@ -0,0 +1,239 @@
+// LzmaDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "../Common/StreamUtils.h"
+
+#include "LzmaDecoder.h"
+
+static HRESULT SResToHRESULT(SRes res)
+{
+ switch(res)
+ {
+ case SZ_OK: return S_OK;
+ case SZ_ERROR_MEM: return E_OUTOFMEMORY;
+ case SZ_ERROR_PARAM: return E_INVALIDARG;
+ case SZ_ERROR_UNSUPPORTED: return E_NOTIMPL;
+ case SZ_ERROR_DATA: return S_FALSE;
+ }
+ return E_FAIL;
+}
+
+namespace NCompress {
+namespace NLzma {
+
+static const UInt32 kInBufSize = 1 << 20;
+
+CDecoder::CDecoder(): _inBuf(0), _propsWereSet(false), _outSizeDefined(false), FinishStream(false)
+{
+ _inSizeProcessed = 0;
+ _inPos = _inSize = 0;
+ LzmaDec_Construct(&_state);
+}
+
+static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
+static void SzFree(void *p, void *address) { p = p; MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+CDecoder::~CDecoder()
+{
+ LzmaDec_Free(&_state, &g_Alloc);
+ MyFree(_inBuf);
+}
+
+HRESULT CDecoder::CreateInputBuffer()
+{
+ if (_inBuf == 0)
+ {
+ _inBuf = (Byte *)MyAlloc(kInBufSize);
+ if (_inBuf == 0)
+ return E_OUTOFMEMORY;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *prop, UInt32 size)
+{
+ RINOK(SResToHRESULT(LzmaDec_Allocate(&_state, prop, size, &g_Alloc)));
+ _propsWereSet = true;
+ return CreateInputBuffer();
+}
+
+void CDecoder::SetOutStreamSizeResume(const UInt64 *outSize)
+{
+ _outSizeDefined = (outSize != NULL);
+ if (_outSizeDefined)
+ _outSize = *outSize;
+ _outSizeProcessed = 0;
+ LzmaDec_Init(&_state);
+}
+
+STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
+{
+ _inSizeProcessed = 0;
+ _inPos = _inSize = 0;
+ SetOutStreamSizeResume(outSize);
+ return S_OK;
+}
+
+HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress)
+{
+ if (_inBuf == 0 || !_propsWereSet)
+ return S_FALSE;
+
+ UInt64 startInProgress = _inSizeProcessed;
+
+ for (;;)
+ {
+ if (_inPos == _inSize)
+ {
+ _inPos = _inSize = 0;
+ RINOK(inStream->Read(_inBuf, kInBufSize, &_inSize));
+ }
+
+ SizeT dicPos = _state.dicPos;
+ SizeT curSize = _state.dicBufSize - dicPos;
+ const UInt32 kStepSize = ((UInt32)1 << 22);
+ if (curSize > kStepSize)
+ curSize = (SizeT)kStepSize;
+
+ ELzmaFinishMode finishMode = LZMA_FINISH_ANY;
+ if (_outSizeDefined)
+ {
+ const UInt64 rem = _outSize - _outSizeProcessed;
+ if (rem < curSize)
+ {
+ curSize = (SizeT)rem;
+ if (FinishStream)
+ finishMode = LZMA_FINISH_END;
+ }
+ }
+
+ SizeT inSizeProcessed = _inSize - _inPos;
+ ELzmaStatus status;
+ SRes res = LzmaDec_DecodeToDic(&_state, dicPos + curSize, _inBuf + _inPos, &inSizeProcessed, finishMode, &status);
+
+ _inPos += (UInt32)inSizeProcessed;
+ _inSizeProcessed += inSizeProcessed;
+ SizeT outSizeProcessed = _state.dicPos - dicPos;
+ _outSizeProcessed += outSizeProcessed;
+
+ bool finished = (inSizeProcessed == 0 && outSizeProcessed == 0);
+ bool stopDecoding = (_outSizeDefined && _outSizeProcessed >= _outSize);
+
+ if (res != 0 || _state.dicPos == _state.dicBufSize || finished || stopDecoding)
+ {
+ HRESULT res2 = WriteStream(outStream, _state.dic, _state.dicPos);
+ if (res != 0)
+ return S_FALSE;
+ RINOK(res2);
+ if (stopDecoding)
+ return S_OK;
+ if (finished)
+ return (status == LZMA_STATUS_FINISHED_WITH_MARK ? S_OK : S_FALSE);
+ }
+ if (_state.dicPos == _state.dicBufSize)
+ _state.dicPos = 0;
+
+ if (progress)
+ {
+ UInt64 inSize = _inSizeProcessed - startInProgress;
+ RINOK(progress->SetRatioInfo(&inSize, &_outSizeProcessed));
+ }
+ }
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ SetOutStreamSize(outSize);
+ return CodeSpec(inStream, outStream, progress);
+}
+
+#ifndef NO_READ_FROM_CODER
+
+STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { _inStream = inStream; return S_OK; }
+STDMETHODIMP CDecoder::ReleaseInStream() { _inStream.Release(); return S_OK; }
+
+STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize)
+ *processedSize = 0;
+ do
+ {
+ if (_inPos == _inSize)
+ {
+ _inPos = _inSize = 0;
+ RINOK(_inStream->Read(_inBuf, kInBufSize, &_inSize));
+ }
+ {
+ SizeT inProcessed = _inSize - _inPos;
+
+ if (_outSizeDefined)
+ {
+ const UInt64 rem = _outSize - _outSizeProcessed;
+ if (rem < size)
+ size = (UInt32)rem;
+ }
+
+ SizeT outProcessed = size;
+ ELzmaStatus status;
+ SRes res = LzmaDec_DecodeToBuf(&_state, (Byte *)data, &outProcessed,
+ _inBuf + _inPos, &inProcessed, LZMA_FINISH_ANY, &status);
+ _inPos += (UInt32)inProcessed;
+ _inSizeProcessed += inProcessed;
+ _outSizeProcessed += outProcessed;
+ size -= (UInt32)outProcessed;
+ data = (Byte *)data + outProcessed;
+ if (processedSize)
+ *processedSize += (UInt32)outProcessed;
+ RINOK(SResToHRESULT(res));
+ if (inProcessed == 0 && outProcessed == 0)
+ return S_OK;
+ }
+ }
+ while (size != 0);
+ return S_OK;
+}
+
+HRESULT CDecoder::CodeResume(ISequentialOutStream *outStream, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ SetOutStreamSizeResume(outSize);
+ return CodeSpec(_inStream, outStream, progress);
+}
+
+HRESULT CDecoder::ReadFromInputStream(void *data, UInt32 size, UInt32 *processedSize)
+{
+ RINOK(CreateInputBuffer());
+ if (processedSize)
+ *processedSize = 0;
+ while (size > 0)
+ {
+ if (_inPos == _inSize)
+ {
+ _inPos = _inSize = 0;
+ RINOK(_inStream->Read(_inBuf, kInBufSize, &_inSize));
+ if (_inSize == 0)
+ break;
+ }
+ {
+ UInt32 curSize = _inSize - _inPos;
+ if (curSize > size)
+ curSize = size;
+ memcpy(data, _inBuf + _inPos, curSize);
+ _inPos += curSize;
+ _inSizeProcessed += curSize;
+ size -= curSize;
+ data = (Byte *)data + curSize;
+ if (processedSize)
+ *processedSize += curSize;
+ }
+ }
+ return S_OK;
+}
+
+#endif
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaDecoder.h
new file mode 100644
index 000000000..d4bc9d3b6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaDecoder.h
@@ -0,0 +1,76 @@
+// LzmaDecoder.h
+
+#ifndef __LZMA_DECODER_H
+#define __LZMA_DECODER_H
+
+#include "../../../C/LzmaDec.h"
+
+#include "../../Common/MyCom.h"
+#include "../ICoder.h"
+
+namespace NCompress {
+namespace NLzma {
+
+class CDecoder:
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ #ifndef NO_READ_FROM_CODER
+ public ICompressSetInStream,
+ public ICompressSetOutStreamSize,
+ public ISequentialInStream,
+ #endif
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialInStream> _inStream;
+ Byte *_inBuf;
+ UInt32 _inPos;
+ UInt32 _inSize;
+ CLzmaDec _state;
+ bool _propsWereSet;
+ bool _outSizeDefined;
+ UInt64 _outSize;
+ UInt64 _inSizeProcessed;
+ UInt64 _outSizeProcessed;
+
+ HRESULT CreateInputBuffer();
+ HRESULT CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress);
+ void SetOutStreamSizeResume(const UInt64 *outSize);
+
+public:
+ MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_ENTRY(ICompressSetDecoderProperties2)
+ #ifndef NO_READ_FROM_CODER
+ MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
+ MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize)
+ MY_QUERYINTERFACE_ENTRY(ISequentialInStream)
+ #endif
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+ STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
+
+ #ifndef NO_READ_FROM_CODER
+
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream);
+ STDMETHOD(ReleaseInStream)();
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+
+ HRESULT CodeResume(ISequentialOutStream *outStream, const UInt64 *outSize, ICompressProgressInfo *progress);
+ HRESULT ReadFromInputStream(void *data, UInt32 size, UInt32 *processedSize);
+ UInt64 GetInputProcessedSize() const { return _inSizeProcessed; }
+
+ #endif
+
+ bool FinishStream;
+
+ CDecoder();
+ virtual ~CDecoder();
+
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaEncoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaEncoder.cpp
new file mode 100644
index 000000000..9bdedaeb6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaEncoder.cpp
@@ -0,0 +1,149 @@
+// LzmaEncoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "../Common/CWrappers.h"
+#include "../Common/StreamUtils.h"
+
+#include "LzmaEncoder.h"
+
+namespace NCompress {
+namespace NLzma {
+
+static void *SzBigAlloc(void *, size_t size) { return BigAlloc(size); }
+static void SzBigFree(void *, void *address) { BigFree(address); }
+static ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree };
+
+static void *SzAlloc(void *, size_t size) { return MyAlloc(size); }
+static void SzFree(void *, void *address) { MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+CEncoder::CEncoder()
+{
+ _encoder = 0;
+ _encoder = LzmaEnc_Create(&g_Alloc);
+ if (_encoder == 0)
+ throw 1;
+}
+
+CEncoder::~CEncoder()
+{
+ if (_encoder != 0)
+ LzmaEnc_Destroy(_encoder, &g_Alloc, &g_BigAlloc);
+}
+
+inline wchar_t GetUpperChar(wchar_t c)
+{
+ if (c >= 'a' && c <= 'z')
+ c -= 0x20;
+ return c;
+}
+
+static int ParseMatchFinder(const wchar_t *s, int *btMode, int *numHashBytes)
+{
+ wchar_t c = GetUpperChar(*s++);
+ if (c == L'H')
+ {
+ if (GetUpperChar(*s++) != L'C')
+ return 0;
+ int numHashBytesLoc = (int)(*s++ - L'0');
+ if (numHashBytesLoc < 4 || numHashBytesLoc > 4)
+ return 0;
+ if (*s++ != 0)
+ return 0;
+ *btMode = 0;
+ *numHashBytes = numHashBytesLoc;
+ return 1;
+ }
+ if (c != L'B')
+ return 0;
+
+ if (GetUpperChar(*s++) != L'T')
+ return 0;
+ int numHashBytesLoc = (int)(*s++ - L'0');
+ if (numHashBytesLoc < 2 || numHashBytesLoc > 4)
+ return 0;
+ c = GetUpperChar(*s++);
+ if (c != L'\0')
+ return 0;
+ *btMode = 1;
+ *numHashBytes = numHashBytesLoc;
+ return 1;
+}
+
+HRESULT SetLzmaProp(PROPID propID, const PROPVARIANT &prop, CLzmaEncProps &ep)
+{
+ if (propID == NCoderPropID::kMatchFinder)
+ {
+ if (prop.vt != VT_BSTR)
+ return E_INVALIDARG;
+ return ParseMatchFinder(prop.bstrVal, &ep.btMode, &ep.numHashBytes) ? S_OK : E_INVALIDARG;
+ }
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 v = prop.ulVal;
+ switch (propID)
+ {
+ case NCoderPropID::kNumFastBytes: ep.fb = v; break;
+ case NCoderPropID::kMatchFinderCycles: ep.mc = v; break;
+ case NCoderPropID::kAlgorithm: ep.algo = v; break;
+ case NCoderPropID::kDictionarySize: ep.dictSize = v; break;
+ case NCoderPropID::kPosStateBits: ep.pb = v; break;
+ case NCoderPropID::kLitPosBits: ep.lp = v; break;
+ case NCoderPropID::kLitContextBits: ep.lc = v; break;
+ default: return E_INVALIDARG;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
+ const PROPVARIANT *coderProps, UInt32 numProps)
+{
+ CLzmaEncProps props;
+ LzmaEncProps_Init(&props);
+
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ const PROPVARIANT &prop = coderProps[i];
+ PROPID propID = propIDs[i];
+ switch (propID)
+ {
+ case NCoderPropID::kEndMarker:
+ if (prop.vt != VT_BOOL) return E_INVALIDARG; props.writeEndMark = (prop.boolVal == VARIANT_TRUE); break;
+ case NCoderPropID::kNumThreads:
+ if (prop.vt != VT_UI4) return E_INVALIDARG; props.numThreads = prop.ulVal; break;
+ default:
+ RINOK(SetLzmaProp(propID, prop, props));
+ }
+ }
+ return SResToHRESULT(LzmaEnc_SetProps(_encoder, &props));
+}
+
+STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
+{
+ Byte props[LZMA_PROPS_SIZE];
+ size_t size = LZMA_PROPS_SIZE;
+ RINOK(LzmaEnc_WriteProperties(_encoder, props, &size));
+ return WriteStream(outStream, props, size);
+}
+
+STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
+{
+ CSeqInStreamWrap inWrap(inStream);
+ CSeqOutStreamWrap outWrap(outStream);
+ CCompressProgressWrap progressWrap(progress);
+
+ SRes res = LzmaEnc_Encode(_encoder, &outWrap.p, &inWrap.p, progress ? &progressWrap.p : NULL, &g_Alloc, &g_BigAlloc);
+ if (res == SZ_ERROR_READ && inWrap.Res != S_OK)
+ return inWrap.Res;
+ if (res == SZ_ERROR_WRITE && outWrap.Res != S_OK)
+ return outWrap.Res;
+ if (res == SZ_ERROR_PROGRESS && progressWrap.Res != S_OK)
+ return progressWrap.Res;
+ return SResToHRESULT(res);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaEncoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaEncoder.h
new file mode 100644
index 000000000..904c0002c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaEncoder.h
@@ -0,0 +1,36 @@
+// LzmaEncoder.h
+
+#ifndef __LZMA_ENCODER_H
+#define __LZMA_ENCODER_H
+
+#include "../../../C/LzmaEnc.h"
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+namespace NCompress {
+namespace NLzma {
+
+class CEncoder:
+ public ICompressCoder,
+ public ICompressSetCoderProperties,
+ public ICompressWriteCoderProperties,
+ public CMyUnknownImp
+{
+ CLzmaEncHandle _encoder;
+public:
+ MY_UNKNOWN_IMP2(ICompressSetCoderProperties, ICompressWriteCoderProperties)
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
+ STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+
+ CEncoder();
+ virtual ~CEncoder();
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaRegister.cpp
new file mode 100644
index 000000000..96ed0baed
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzmaRegister.cpp
@@ -0,0 +1,20 @@
+// LzmaRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "LzmaDecoder.h"
+
+static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NLzma::CDecoder); }
+#ifndef EXTRACT_ONLY
+#include "LzmaEncoder.h"
+static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NLzma::CEncoder); }
+#else
+#define CreateCodecOut 0
+#endif
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodec, CreateCodecOut, 0x030101, L"LZMA", 1, false };
+
+REGISTER_CODEC(LZMA)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx.h
new file mode 100644
index 000000000..249cbe51b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx.h
@@ -0,0 +1,61 @@
+// Lzx.h
+
+#ifndef __COMPRESS_LZX_H
+#define __COMPRESS_LZX_H
+
+namespace NCompress {
+namespace NLzx {
+
+const int kNumHuffmanBits = 16;
+const UInt32 kNumRepDistances = 3;
+
+const UInt32 kNumLenSlots = 8;
+const UInt32 kMatchMinLen = 2;
+const UInt32 kNumLenSymbols = 249;
+const UInt32 kMatchMaxLen = kMatchMinLen + (kNumLenSlots - 1) + kNumLenSymbols - 1;
+
+const int kNumAlignBits = 3;
+const UInt32 kAlignTableSize = 1 << kNumAlignBits;
+
+const UInt32 kNumPosSlots = 50;
+const UInt32 kNumPosLenSlots = kNumPosSlots * kNumLenSlots;
+
+const UInt32 kMainTableSize = 256 + kNumPosLenSlots;
+const UInt32 kLevelTableSize = 20;
+const UInt32 kMaxTableSize = kMainTableSize;
+
+const int kNumBlockTypeBits = 3;
+const int kBlockTypeVerbatim = 1;
+const int kBlockTypeAligned = 2;
+const int kBlockTypeUncompressed = 3;
+
+const int kUncompressedBlockSizeNumBits = 24;
+
+const int kNumBitsForPreTreeLevel = 4;
+
+const int kLevelSymbolZeros = 17;
+const int kLevelSymbolZerosBig = 18;
+const int kLevelSymbolSame = 19;
+
+const int kLevelSymbolZerosStartValue = 4;
+const int kLevelSymbolZerosNumBits = 4;
+
+const int kLevelSymbolZerosBigStartValue = kLevelSymbolZerosStartValue +
+ (1 << kLevelSymbolZerosNumBits);
+const int kLevelSymbolZerosBigNumBits = 5;
+
+const int kLevelSymbolSameNumBits = 1;
+const int kLevelSymbolSameStartValue = 4;
+
+const int kNumBitsForAlignLevel = 3;
+
+const int kNumDictionaryBitsMin = 15;
+const int kNumDictionaryBitsMax = 21;
+const UInt32 kDictionarySizeMax = (1 << kNumDictionaryBitsMax);
+
+const int kNumLinearPosSlotBits = 17;
+const UInt32 kNumPowerPosSlots = 0x26;
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx86Converter.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx86Converter.cpp
new file mode 100644
index 000000000..06638fe78
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx86Converter.cpp
@@ -0,0 +1,90 @@
+// Lzx86Converter.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/Defs.h"
+
+#include "Lzx86Converter.h"
+
+namespace NCompress {
+namespace NLzx {
+
+static const int kResidue = 6 + 4;
+
+void Cx86ConvertOutStream::MakeTranslation()
+{
+ if (m_Pos <= static_cast< unsigned int >( kResidue ) )
+ return;
+ UInt32 numBytes = m_Pos - kResidue;
+ Byte *buffer = m_Buffer;
+ for (UInt32 i = 0; i < numBytes;)
+ {
+ if (buffer[i++] == 0xE8)
+ {
+ Int32 absValue = 0;
+ int j;
+ for(j = 0; j < 4; j++)
+ absValue += (UInt32)buffer[i + j] << (j * 8);
+ Int32 pos = (Int32)(m_ProcessedSize + i - 1);
+ if (absValue >= -pos && absValue < (Int32)m_TranslationSize)
+ {
+ UInt32 offset = (absValue >= 0) ?
+ absValue - pos :
+ absValue + m_TranslationSize;
+ for(j = 0; j < 4; j++)
+ {
+ buffer[i + j] = (Byte)(offset & 0xFF);
+ offset >>= 8;
+ }
+ }
+ i += 4;
+ }
+ }
+}
+
+STDMETHODIMP Cx86ConvertOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ if (!m_TranslationMode)
+ return m_Stream->Write(data, size, processedSize);
+ UInt32 realProcessedSize = 0;
+ while (realProcessedSize < size)
+ {
+ UInt32 writeSize = MyMin(size - realProcessedSize, kUncompressedBlockSize - m_Pos);
+ memmove(m_Buffer + m_Pos, (const Byte *)data + realProcessedSize, writeSize);
+ m_Pos += writeSize;
+ realProcessedSize += writeSize;
+ if (m_Pos == static_cast< unsigned int >( kUncompressedBlockSize) )
+ {
+ RINOK(Flush());
+ }
+ }
+ if (processedSize != NULL)
+ *processedSize = realProcessedSize;
+ return S_OK;
+}
+
+HRESULT Cx86ConvertOutStream::Flush()
+{
+ if (m_Pos == 0)
+ return S_OK;
+ if (m_TranslationMode)
+ MakeTranslation();
+ UInt32 pos = 0;
+ do
+ {
+ UInt32 processed;
+ RINOK(m_Stream->Write(m_Buffer + pos, m_Pos - pos, &processed));
+ if (processed == 0)
+ return E_FAIL;
+ pos += processed;
+ }
+ while(pos < m_Pos);
+ m_ProcessedSize += m_Pos;
+ m_Pos = 0;
+ m_TranslationMode = (m_TranslationMode && (m_ProcessedSize < (1 << 30)));
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx86Converter.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx86Converter.h
new file mode 100644
index 000000000..9f110c29b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Lzx86Converter.h
@@ -0,0 +1,46 @@
+// Lzx86Converter.h
+
+#ifndef __LZX_86_CONVERTER_H
+#define __LZX_86_CONVERTER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../IStream.h"
+
+namespace NCompress {
+namespace NLzx {
+
+const int kUncompressedBlockSize = 1 << 15;
+
+class Cx86ConvertOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialOutStream> m_Stream;
+ UInt32 m_ProcessedSize;
+ UInt32 m_Pos;
+ UInt32 m_TranslationSize;
+ bool m_TranslationMode;
+ Byte m_Buffer[kUncompressedBlockSize];
+
+ void MakeTranslation();
+public:
+ void SetStream(ISequentialOutStream *outStream) { m_Stream = outStream; }
+ void ReleaseStream() { m_Stream.Release(); }
+ void Init(bool translationMode, UInt32 translationSize)
+ {
+ m_TranslationMode = translationMode;
+ m_TranslationSize = translationSize;
+ m_ProcessedSize = 0;
+ m_Pos = 0;
+ }
+ HRESULT Flush();
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzxDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzxDecoder.cpp
new file mode 100644
index 000000000..a2eceb4c2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzxDecoder.cpp
@@ -0,0 +1,387 @@
+// LzxDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/Defs.h"
+
+#include "LzxDecoder.h"
+
+namespace NCompress {
+namespace NLzx {
+
+const int kLenIdNeedInit = -2;
+
+CDecoder::CDecoder(bool wimMode):
+ _keepHistory(false),
+ _skipByte(false),
+ _wimMode(wimMode)
+{
+ m_x86ConvertOutStreamSpec = new Cx86ConvertOutStream;
+ m_x86ConvertOutStream = m_x86ConvertOutStreamSpec;
+}
+
+void CDecoder::ReleaseStreams()
+{
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ m_x86ConvertOutStreamSpec->ReleaseStream();
+}
+
+STDMETHODIMP CDecoder::Flush()
+{
+ RINOK(m_OutWindowStream.Flush());
+ return m_x86ConvertOutStreamSpec->Flush();
+}
+
+UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+
+#define RIF(x) { if (!(x)) return false; }
+
+bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols)
+{
+ Byte levelLevels[kLevelTableSize];
+ UInt32 i;
+ for (i = 0; i < kLevelTableSize; i++)
+ levelLevels[i] = (Byte)ReadBits(kNumBitsForPreTreeLevel);
+ RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
+ int num = 0;
+ Byte symbol = 0;
+ for (i = 0; i < numSymbols;)
+ {
+ if (num != 0)
+ {
+ lastLevels[i] = newLevels[i] = symbol;
+ i++;
+ num--;
+ continue;
+ }
+ UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
+ if (number == static_cast< UInt32 >( kLevelSymbolZeros) )
+ {
+ num = kLevelSymbolZerosStartValue + (int)ReadBits(kLevelSymbolZerosNumBits);
+ symbol = 0;
+ }
+ else if (number == static_cast< UInt32 >( kLevelSymbolZerosBig) )
+ {
+ num = kLevelSymbolZerosBigStartValue + (int)ReadBits(kLevelSymbolZerosBigNumBits);
+ symbol = 0;
+ }
+ else if (number == static_cast< UInt32 >( kLevelSymbolSame ) || number <= static_cast< UInt32 >( kNumHuffmanBits) )
+ {
+ if (number <= static_cast< UInt32 >( kNumHuffmanBits) )
+ num = 1;
+ else
+ {
+ num = kLevelSymbolSameStartValue + (int)ReadBits(kLevelSymbolSameNumBits);
+ number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
+ if (number > static_cast< UInt32 >( kNumHuffmanBits) )
+ return false;
+ }
+ symbol = Byte((17 + lastLevels[i] - number) % (kNumHuffmanBits + 1));
+ }
+ else
+ return false;
+ }
+ return true;
+}
+
+bool CDecoder::ReadTables(void)
+{
+ Byte newLevels[kMaxTableSize];
+ {
+ if (_skipByte)
+ m_InBitStream.DirectReadByte();
+ m_InBitStream.Normalize();
+
+ int blockType = (int)ReadBits(kNumBlockTypeBits);
+ if (blockType > kBlockTypeUncompressed)
+ return false;
+ if (_wimMode)
+ if (ReadBits(1) == 1)
+ m_UnCompressedBlockSize = (1 << 15);
+ else
+ m_UnCompressedBlockSize = ReadBits(16);
+ else
+ m_UnCompressedBlockSize = m_InBitStream.ReadBitsBig(kUncompressedBlockSizeNumBits);
+
+ m_IsUncompressedBlock = (blockType == kBlockTypeUncompressed);
+
+ _skipByte = (m_IsUncompressedBlock && ((m_UnCompressedBlockSize & 1) != 0));
+
+ if (m_IsUncompressedBlock)
+ {
+ ReadBits(16 - m_InBitStream.GetBitPosition());
+ if (!m_InBitStream.ReadUInt32(m_RepDistances[0]))
+ return false;
+ m_RepDistances[0]--;
+ for (unsigned int i = 1; i < kNumRepDistances; i++)
+ {
+ UInt32 rep = 0;
+ for (int j = 0; j < 4; j++)
+ rep |= (UInt32)m_InBitStream.DirectReadByte() << (8 * j);
+ m_RepDistances[i] = rep - 1;
+ }
+ return true;
+ }
+ m_AlignIsUsed = (blockType == kBlockTypeAligned);
+ if (m_AlignIsUsed)
+ {
+ for(unsigned int i = 0; i < kAlignTableSize; i++)
+ newLevels[i] = (Byte)ReadBits(kNumBitsForAlignLevel);
+ RIF(m_AlignDecoder.SetCodeLengths(newLevels));
+ }
+ }
+
+ RIF(ReadTable(m_LastMainLevels, newLevels, 256));
+ RIF(ReadTable(m_LastMainLevels + 256, newLevels + 256, m_NumPosLenSlots));
+ for (UInt32 i = 256 + m_NumPosLenSlots; i < kMainTableSize; i++)
+ newLevels[i] = 0;
+ RIF(m_MainDecoder.SetCodeLengths(newLevels));
+
+ RIF(ReadTable(m_LastLenLevels, newLevels, kNumLenSymbols));
+ return m_LenDecoder.SetCodeLengths(newLevels);
+}
+
+class CDecoderFlusher
+{
+ CDecoder *m_Decoder;
+public:
+ bool NeedFlush;
+ CDecoderFlusher(CDecoder *decoder): m_Decoder(decoder), NeedFlush(true) {}
+ ~CDecoderFlusher()
+ {
+ if (NeedFlush)
+ m_Decoder->Flush();
+ m_Decoder->ReleaseStreams();
+ }
+};
+
+
+void CDecoder::ClearPrevLevels()
+{
+ unsigned int i;
+ for (i = 0; i < kMainTableSize; i++)
+ m_LastMainLevels[i] = 0;
+ for (i = 0; i < kNumLenSymbols; i++)
+ m_LastLenLevels[i] = 0;
+};
+
+
+HRESULT CDecoder::CodeSpec(UInt32 curSize)
+{
+ if (_remainLen == kLenIdNeedInit)
+ {
+ _remainLen = 0;
+ m_InBitStream.Init();
+ if (!_keepHistory || !m_IsUncompressedBlock)
+ m_InBitStream.Normalize();
+ if (!_keepHistory)
+ {
+ _skipByte = false;
+ m_UnCompressedBlockSize = 0;
+ ClearPrevLevels();
+ UInt32 i86TranslationSize = 12000000;
+ bool translationMode = true;
+ if (!_wimMode)
+ {
+ translationMode = (ReadBits(1) != 0);
+ if (translationMode)
+ {
+ i86TranslationSize = ReadBits(16) << 16;
+ i86TranslationSize |= ReadBits(16);
+ }
+ }
+ m_x86ConvertOutStreamSpec->Init(translationMode, i86TranslationSize);
+
+ for(unsigned int i = 0 ; i < kNumRepDistances; i++)
+ m_RepDistances[i] = 0;
+ }
+ }
+
+ while(_remainLen > 0 && curSize > 0)
+ {
+ m_OutWindowStream.PutByte(m_OutWindowStream.GetByte(m_RepDistances[0]));
+ _remainLen--;
+ curSize--;
+ }
+
+ while(curSize > 0)
+ {
+ if (m_UnCompressedBlockSize == 0)
+ if (!ReadTables())
+ return S_FALSE;
+ UInt32 next = (Int32)MyMin(m_UnCompressedBlockSize, curSize);
+ curSize -= next;
+ m_UnCompressedBlockSize -= next;
+ if (m_IsUncompressedBlock)
+ {
+ while(next > 0)
+ {
+ m_OutWindowStream.PutByte(m_InBitStream.DirectReadByte());
+ next--;
+ }
+ }
+ else while(next > 0)
+ {
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < 256)
+ {
+ m_OutWindowStream.PutByte((Byte)number);
+ next--;
+ }
+ else
+ {
+ UInt32 posLenSlot = number - 256;
+ if (posLenSlot >= m_NumPosLenSlots)
+ return S_FALSE;
+ UInt32 posSlot = posLenSlot / kNumLenSlots;
+ UInt32 lenSlot = posLenSlot % kNumLenSlots;
+ UInt32 len = kMatchMinLen + lenSlot;
+ if (lenSlot == kNumLenSlots - 1)
+ {
+ UInt32 lenTemp = m_LenDecoder.DecodeSymbol(&m_InBitStream);
+ if (lenTemp >= kNumLenSymbols)
+ return S_FALSE;
+ len += lenTemp;
+ }
+
+ if (posSlot < kNumRepDistances)
+ {
+ UInt32 distance = m_RepDistances[posSlot];
+ m_RepDistances[posSlot] = m_RepDistances[0];
+ m_RepDistances[0] = distance;
+ }
+ else
+ {
+ UInt32 distance;
+ int numDirectBits;
+ if (posSlot < kNumPowerPosSlots)
+ {
+ numDirectBits = (int)(posSlot >> 1) - 1;
+ distance = ((2 | (posSlot & 1)) << numDirectBits);
+ }
+ else
+ {
+ numDirectBits = kNumLinearPosSlotBits;
+ distance = ((posSlot - 0x22) << kNumLinearPosSlotBits);
+ }
+
+ if (m_AlignIsUsed && numDirectBits >= kNumAlignBits)
+ {
+ distance += (m_InBitStream.ReadBits(numDirectBits - kNumAlignBits) << kNumAlignBits);
+ UInt32 alignTemp = m_AlignDecoder.DecodeSymbol(&m_InBitStream);
+ if (alignTemp >= kAlignTableSize)
+ return S_FALSE;
+ distance += alignTemp;
+ }
+ else
+ distance += m_InBitStream.ReadBits(numDirectBits);
+ m_RepDistances[2] = m_RepDistances[1];
+ m_RepDistances[1] = m_RepDistances[0];
+ m_RepDistances[0] = distance - kNumRepDistances;
+ }
+
+ UInt32 locLen = len;
+ if (locLen > next)
+ locLen = next;
+
+ if (!m_OutWindowStream.CopyBlock(m_RepDistances[0], locLen))
+ return S_FALSE;
+
+ len -= locLen;
+ next -= locLen;
+ if (len != 0)
+ {
+ _remainLen = (int)len;
+ return S_OK;
+ }
+ }
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ if (outSize == NULL)
+ return E_INVALIDARG;
+ UInt64 size = *outSize;
+
+ RINOK(SetInStream(inStream));
+ m_x86ConvertOutStreamSpec->SetStream(outStream);
+ m_OutWindowStream.SetStream(m_x86ConvertOutStream);
+ RINOK(SetOutStreamSize(outSize));
+
+ CDecoderFlusher flusher(this);
+
+ const UInt64 start = m_OutWindowStream.GetProcessedSize();
+ for (;;)
+ {
+ UInt32 curSize = 1 << 18;
+ UInt64 rem = size - (m_OutWindowStream.GetProcessedSize() - start);
+ if (curSize > rem)
+ curSize = (UInt32)rem;
+ if (curSize == 0)
+ break;
+ RINOK(CodeSpec(curSize));
+ if (progress != NULL)
+ {
+ UInt64 inSize = m_InBitStream.GetProcessedSize();
+ UInt64 nowPos64 = m_OutWindowStream.GetProcessedSize() - start;
+ RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
+ }
+ }
+ flusher.NeedFlush = false;
+ return Flush();
+}
+
+HRESULT CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
+{
+ m_InBitStream.SetStream(inStream);
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::ReleaseInStream()
+{
+ m_InBitStream.ReleaseStream();
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
+{
+ if (outSize == NULL)
+ return E_FAIL;
+ _remainLen = kLenIdNeedInit;
+ m_OutWindowStream.Init(_keepHistory);
+ return S_OK;
+}
+
+HRESULT CDecoder::SetParams(int numDictBits)
+{
+ if (numDictBits < kNumDictionaryBitsMin || numDictBits > kNumDictionaryBitsMax)
+ return E_INVALIDARG;
+ UInt32 numPosSlots;
+ if (numDictBits < 20)
+ numPosSlots = 30 + (numDictBits - 15) * 2;
+ else if (numDictBits == 20)
+ numPosSlots = 42;
+ else
+ numPosSlots = 50;
+ m_NumPosLenSlots = numPosSlots * kNumLenSlots;
+ if (!m_OutWindowStream.Create(kDictionarySizeMax))
+ return E_OUTOFMEMORY;
+ if (!m_InBitStream.Create(1 << 16))
+ return E_OUTOFMEMORY;
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzxDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzxDecoder.h
new file mode 100644
index 000000000..d7979231c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/LzxDecoder.h
@@ -0,0 +1,161 @@
+// LzxDecoder.h
+
+#ifndef __LZX_DECODER_H
+#define __LZX_DECODER_H
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "HuffmanDecoder.h"
+#include "LzOutWindow.h"
+#include "Lzx.h"
+#include "Lzx86Converter.h"
+
+namespace NCompress {
+namespace NLzx {
+
+namespace NBitStream {
+
+const int kNumBigValueBits = 8 * 4;
+const int kNumValueBits = 17;
+const UInt32 kBitDecoderValueMask = (1 << kNumValueBits) - 1;
+
+class CDecoder
+{
+ CInBuffer m_Stream;
+ UInt32 m_Value;
+ int m_BitPos;
+public:
+ CDecoder() {}
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+
+ void SetStream(ISequentialInStream *s) { m_Stream.SetStream(s); }
+ void ReleaseStream() { m_Stream.ReleaseStream(); }
+
+ void Init()
+ {
+ m_Stream.Init();
+ m_BitPos = kNumBigValueBits;
+ }
+
+ UInt64 GetProcessedSize() const
+ { return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
+
+ int GetBitPosition() const { return m_BitPos & 0xF; }
+
+ void Normalize()
+ {
+ for (;m_BitPos >= 16; m_BitPos -= 16)
+ {
+ Byte b0 = m_Stream.ReadByte();
+ Byte b1 = m_Stream.ReadByte();
+ m_Value = (m_Value << 8) | b1;
+ m_Value = (m_Value << 8) | b0;
+ }
+ }
+
+ UInt32 GetValue(int numBits) const
+ {
+ return ((m_Value >> ((32 - kNumValueBits) - m_BitPos)) & kBitDecoderValueMask) >>
+ (kNumValueBits - numBits);
+ }
+
+ void MovePos(UInt32 numBits)
+ {
+ m_BitPos += (int)numBits;
+ Normalize();
+ }
+
+ UInt32 ReadBits(int numBits)
+ {
+ UInt32 res = GetValue(numBits);
+ MovePos(numBits);
+ return res;
+ }
+
+ UInt32 ReadBitsBig(int numBits)
+ {
+ int numBits0 = numBits / 2;
+ int numBits1 = numBits - numBits0;
+ UInt32 res = ReadBits(numBits0) << numBits1;
+ return res + ReadBits(numBits1);
+ }
+
+ bool ReadUInt32(UInt32 &v)
+ {
+ if (m_BitPos != 0)
+ return false;
+ v = ((m_Value >> 16) & 0xFFFF) | ((m_Value << 16) & 0xFFFF0000);
+ m_BitPos = kNumBigValueBits;
+ return true;
+ }
+
+ Byte DirectReadByte() { return m_Stream.ReadByte(); }
+
+};
+}
+
+class CDecoder :
+ public ICompressCoder,
+ public CMyUnknownImp
+{
+ NBitStream::CDecoder m_InBitStream;
+ CLzOutWindow m_OutWindowStream;
+
+ UInt32 m_RepDistances[kNumRepDistances];
+ UInt32 m_NumPosLenSlots;
+
+ bool m_IsUncompressedBlock;
+ bool m_AlignIsUsed;
+
+ NCompress::NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
+ NCompress::NHuffman::CDecoder<kNumHuffmanBits, kNumLenSymbols> m_LenDecoder;
+ NCompress::NHuffman::CDecoder<kNumHuffmanBits, kAlignTableSize> m_AlignDecoder;
+ NCompress::NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
+
+ Byte m_LastMainLevels[kMainTableSize];
+ Byte m_LastLenLevels[kNumLenSymbols];
+
+ Cx86ConvertOutStream *m_x86ConvertOutStreamSpec;
+ CMyComPtr<ISequentialOutStream> m_x86ConvertOutStream;
+
+ UInt32 m_UnCompressedBlockSize;
+
+ bool _keepHistory;
+ int _remainLen;
+ bool _skipByte;
+
+ bool _wimMode;
+
+ UInt32 ReadBits(int numBits);
+ bool ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols);
+ bool ReadTables();
+ void ClearPrevLevels();
+
+ HRESULT CodeSpec(UInt32 size);
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+public:
+ CDecoder(bool wimMode = false);
+
+ MY_UNKNOWN_IMP
+
+ void ReleaseStreams();
+ STDMETHOD(Flush)();
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream);
+ STDMETHOD(ReleaseInStream)();
+ STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
+
+ HRESULT SetParams(int numDictBits);
+ void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Mtf8.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Mtf8.h
new file mode 100644
index 000000000..7a6b7fe67
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Mtf8.h
@@ -0,0 +1,196 @@
+// Mtf8.h
+
+#ifndef __COMPRESS_MTF8_H
+#define __COMPRESS_MTF8_H
+
+#include "../../Common/Types.h"
+
+namespace NCompress {
+
+struct CMtf8Encoder
+{
+ Byte Buf[256];
+
+ int FindAndMove(Byte v)
+ {
+ int pos;
+ for (pos = 0; Buf[pos] != v; pos++);
+ int resPos = pos;
+ for (; pos >= 8; pos -= 8)
+ {
+ Buf[pos] = Buf[pos - 1];
+ Buf[pos - 1] = Buf[pos - 2];
+ Buf[pos - 2] = Buf[pos - 3];
+ Buf[pos - 3] = Buf[pos - 4];
+ Buf[pos - 4] = Buf[pos - 5];
+ Buf[pos - 5] = Buf[pos - 6];
+ Buf[pos - 6] = Buf[pos - 7];
+ Buf[pos - 7] = Buf[pos - 8];
+ }
+ for (; pos > 0; pos--)
+ Buf[pos] = Buf[pos - 1];
+ Buf[0] = v;
+ return resPos;
+ }
+};
+
+/*
+struct CMtf8Decoder
+{
+ Byte Buf[256];
+
+ void Init(int) {};
+ Byte GetHead() const { return Buf[0]; }
+ Byte GetAndMove(int pos)
+ {
+ Byte res = Buf[pos];
+ for (; pos >= 8; pos -= 8)
+ {
+ Buf[pos] = Buf[pos - 1];
+ Buf[pos - 1] = Buf[pos - 2];
+ Buf[pos - 2] = Buf[pos - 3];
+ Buf[pos - 3] = Buf[pos - 4];
+ Buf[pos - 4] = Buf[pos - 5];
+ Buf[pos - 5] = Buf[pos - 6];
+ Buf[pos - 6] = Buf[pos - 7];
+ Buf[pos - 7] = Buf[pos - 8];
+ }
+ for (; pos > 0; pos--)
+ Buf[pos] = Buf[pos - 1];
+ Buf[0] = res;
+ return res;
+ }
+};
+*/
+
+#ifdef _WIN64
+#define MODE_64BIT
+#endif
+
+#ifdef MODE_64BIT
+typedef UInt64 CMtfVar;
+#define MTF_MOVS 3
+#else
+typedef UInt32 CMtfVar;
+#define MTF_MOVS 2
+#endif
+
+#define MTF_MASK ((1 << MTF_MOVS) - 1)
+
+
+struct CMtf8Decoder
+{
+ CMtfVar Buf[256 >> MTF_MOVS];
+
+ void StartInit() { memset(Buf, 0, sizeof(Buf)); }
+ void Add(unsigned int pos, Byte val) { Buf[pos >> MTF_MOVS] |= ((CMtfVar)val << ((pos & MTF_MASK) << 3)); }
+ Byte GetHead() const { return (Byte)Buf[0]; }
+ Byte GetAndMove(unsigned int pos)
+ {
+ UInt32 lim = ((UInt32)pos >> MTF_MOVS);
+ pos = (pos & MTF_MASK) << 3;
+ CMtfVar prev = (Buf[lim] >> pos) & 0xFF;
+
+ UInt32 i = 0;
+ if ((lim & 1) != 0)
+ {
+ CMtfVar next = Buf[0];
+ Buf[0] = (next << 8) | prev;
+ prev = (next >> (MTF_MASK << 3));
+ i = 1;
+ lim -= 1;
+ }
+ for (; i < lim; i += 2)
+ {
+ CMtfVar next = Buf[i];
+ Buf[i] = (next << 8) | prev;
+ prev = (next >> (MTF_MASK << 3));
+ next = Buf[i + 1];
+ Buf[i + 1] = (next << 8) | prev;
+ prev = (next >> (MTF_MASK << 3));
+ }
+ CMtfVar next = Buf[i];
+ CMtfVar mask = (((CMtfVar)0x100 << pos) - 1);
+ Buf[i] = (next & ~mask) | (((next << 8) | prev) & mask);
+ return (Byte)Buf[0];
+ }
+};
+
+/*
+const int kSmallSize = 64;
+class CMtf8Decoder
+{
+ Byte SmallBuffer[kSmallSize];
+ int SmallSize;
+ Byte Counts[16];
+ int Size;
+public:
+ Byte Buf[256];
+
+ Byte GetHead() const
+ {
+ if (SmallSize > 0)
+ return SmallBuffer[kSmallSize - SmallSize];
+ return Buf[0];
+ }
+
+ void Init(int size)
+ {
+ Size = size;
+ SmallSize = 0;
+ for (int i = 0; i < 16; i++)
+ {
+ Counts[i] = ((size >= 16) ? 16 : size);
+ size -= Counts[i];
+ }
+ }
+
+ Byte GetAndMove(int pos)
+ {
+ if (pos < SmallSize)
+ {
+ Byte *p = SmallBuffer + kSmallSize - SmallSize;
+ Byte res = p[pos];
+ for (; pos > 0; pos--)
+ p[pos] = p[pos - 1];
+ SmallBuffer[kSmallSize - SmallSize] = res;
+ return res;
+ }
+ if (SmallSize == kSmallSize)
+ {
+ int i = Size - 1;
+ int g = 16;
+ do
+ {
+ g--;
+ int offset = (g << 4);
+ for (int t = Counts[g] - 1; t >= 0; t--, i--)
+ Buf[i] = Buf[offset + t];
+ }
+ while(g != 0);
+
+ for (i = kSmallSize - 1; i >= 0; i--)
+ Buf[i] = SmallBuffer[i];
+ Init(Size);
+ }
+ pos -= SmallSize;
+ int g;
+ for (g = 0; pos >= Counts[g]; g++)
+ pos -= Counts[g];
+ int offset = (g << 4);
+ Byte res = Buf[offset + pos];
+ for (pos; pos < 16 - 1; pos++)
+ Buf[offset + pos] = Buf[offset + pos + 1];
+
+ SmallSize++;
+ SmallBuffer[kSmallSize - SmallSize] = res;
+
+ Counts[g]--;
+ return res;
+ }
+};
+*/
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PPMD_Alone/PpmdAlone.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PPMD_Alone/PpmdAlone.cpp
new file mode 100644
index 000000000..25df0a0d0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PPMD_Alone/PpmdAlone.cpp
@@ -0,0 +1,348 @@
+// PpmdAlone.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Common/MyWindows.h"
+#include "../../../Common/MyInitGuid.h"
+
+#include <stdio.h>
+
+#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
+#include <fcntl.h>
+#include <io.h>
+#define MY_SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY)
+#else
+#define MY_SET_BINARY_MODE(file)
+#endif
+
+#include "../../../Common/CommandLineParser.h"
+#include "../../../Common/StringConvert.h"
+#include "../../../Common/StringToInt.h"
+
+#include "../../Common/FileStreams.h"
+#include "../../Common/StreamUtils.h"
+
+#include "../PpmdDecoder.h"
+#include "../PpmdEncoder.h"
+
+using namespace NCommandLineParser;
+
+#ifdef _WIN32
+bool g_IsNT = false;
+static inline bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+
+static const char *kCantAllocate = "Can not allocate memory";
+static const char *kReadError = "Read error";
+static const char *kWriteError = "Write error";
+
+namespace NKey {
+enum Enum
+{
+ kHelp1 = 0,
+ kHelp2,
+ kOrder,
+ kUsedMemorySize,
+ kStdIn,
+ kStdOut
+};
+}
+
+static const CSwitchForm kSwitchForms[] =
+{
+ { L"?", NSwitchType::kSimple, false },
+ { L"H", NSwitchType::kSimple, false },
+ { L"O", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"M", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"SI", NSwitchType::kSimple, false },
+ { L"SO", NSwitchType::kSimple, false }
+};
+
+static const int kNumSwitches = sizeof(kSwitchForms) / sizeof(kSwitchForms[0]);
+
+static void PrintHelp()
+{
+ fprintf(stderr, "\nUsage: PPMD <e|d> inputFile outputFile [<switches>...]\n"
+ " e: encode file\n"
+ " d: decode file\n"
+/*
+ " b: Benchmark\n"
+*/
+ "<Switches>\n"
+ " -o{N}: set order - [4, 32], default: 4\n"
+ " -m{N}: set memory size - [4,512], default: 4 (4 MB)\n"
+ " -si: read data from stdin (only with d)\n"
+ " -so: write data to stdout\n"
+ );
+}
+
+static void PrintHelpAndExit(const char *s)
+{
+ fprintf(stderr, "\nError: %s\n\n", s);
+ PrintHelp();
+ throw -1;
+}
+
+static void IncorrectCommand()
+{
+ PrintHelpAndExit("Incorrect command");
+}
+
+static void WriteArgumentsToStringList(int numArguments, const char *arguments[],
+ UStringVector &strings)
+{
+ for(int i = 1; i < numArguments; i++)
+ strings.Add(MultiByteToUnicodeString(arguments[i]));
+}
+
+static bool GetNumber(const wchar_t *s, UInt32 &value)
+{
+ value = 0;
+ if (MyStringLen(s) == 0)
+ return false;
+ const wchar_t *end;
+ UInt64 res = ConvertStringToUInt64(s, &end);
+ if (*end != L'\0')
+ return false;
+ if (res > 0xFFFFFFFF)
+ return false;
+ value = UInt32(res);
+ return true;
+}
+
+int main2(int n, const char *args[])
+{
+ #ifdef _WIN32
+ g_IsNT = IsItWindowsNT();
+ #endif
+
+ fprintf(stderr, "\nPPMD 4.49 Copyright (c) 1999-2007 Igor Pavlov 2007-07-05\n");
+
+ if (n == 1)
+ {
+ PrintHelp();
+ return 0;
+ }
+
+ bool unsupportedTypes = (sizeof(Byte) != 1 || sizeof(UInt32) < 4 || sizeof(UInt64) < 4);
+ if (unsupportedTypes)
+ {
+ fprintf(stderr, "Unsupported base types. Edit Common/Types.h and recompile");
+ return 1;
+ }
+
+ UStringVector commandStrings;
+ WriteArgumentsToStringList(n, args, commandStrings);
+ CParser parser(kNumSwitches);
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
+ }
+ catch(...)
+ {
+ IncorrectCommand();
+ }
+
+ if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
+ {
+ PrintHelp();
+ return 0;
+ }
+ const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
+
+ int paramIndex = 0;
+ if (paramIndex >= nonSwitchStrings.Size())
+ IncorrectCommand();
+ const UString &command = nonSwitchStrings[paramIndex++];
+
+/* FIXME
+ if (command.CompareNoCase(L"b") == 0)
+ {
+ const UInt32 kNumDefaultItereations = 1;
+ UInt32 numIterations = kNumDefaultItereations;
+ {
+ if (paramIndex < nonSwitchStrings.Size())
+ if (!GetNumber(nonSwitchStrings[paramIndex++], numIterations))
+ numIterations = kNumDefaultItereations;
+ }
+ return LzmaBenchCon(stderr, numIterations, numThreads, dictionary);
+ }
+*/
+
+ bool encodeMode = false;
+ if (command.CompareNoCase(L"e") == 0)
+ encodeMode = true;
+ else if (command.CompareNoCase(L"d") == 0)
+ encodeMode = false;
+ else
+ IncorrectCommand();
+
+ bool stdInMode = parser[NKey::kStdIn].ThereIs;
+ bool stdOutMode = parser[NKey::kStdOut].ThereIs;
+
+ CMyComPtr<ISequentialInStream> inStream;
+ CInFileStream *inStreamSpec = 0;
+ if (stdInMode)
+ {
+ inStream = new CStdInFileStream;
+ MY_SET_BINARY_MODE(stdin);
+ }
+ else
+ {
+ if (paramIndex >= nonSwitchStrings.Size())
+ IncorrectCommand();
+ const UString &inputName = nonSwitchStrings[paramIndex++];
+ inStreamSpec = new CInFileStream;
+ inStream = inStreamSpec;
+ if (!inStreamSpec->Open(GetSystemString(inputName)))
+ {
+ fprintf(stderr, "\nError: can not open input file %s\n",
+ (const char *)GetOemString(inputName));
+ return 1;
+ }
+ }
+
+ CMyComPtr<ISequentialOutStream> outStream;
+ if (stdOutMode)
+ {
+ outStream = new CStdOutFileStream;
+ MY_SET_BINARY_MODE(stdout);
+ }
+ else
+ {
+ if (paramIndex >= nonSwitchStrings.Size())
+ IncorrectCommand();
+ const UString &outputName = nonSwitchStrings[paramIndex++];
+ COutFileStream *outStreamSpec = new COutFileStream;
+ outStream = outStreamSpec;
+ if (!outStreamSpec->Create(GetSystemString(outputName), true))
+ {
+ fprintf(stderr, "\nError: can not open output file %s\n",
+ (const char *)GetOemString(outputName));
+ return 1;
+ }
+ }
+
+ UInt64 fileSize;
+ if (encodeMode)
+ {
+ // NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
+ NCompress::NPpmd::CEncoder *encoderSpec = new NCompress::NPpmd::CEncoder;
+ CMyComPtr<ICompressCoder> encoder = encoderSpec;
+
+ if (stdInMode)
+ IncorrectCommand();
+
+ UInt32 order = 4;
+ if(parser[NKey::kOrder].ThereIs)
+ if (!GetNumber(parser[NKey::kOrder].PostStrings[0], order))
+ IncorrectCommand();
+ if (order < 4) order = 4;
+
+ UInt32 memSize = 4;
+ if(parser[NKey::kUsedMemorySize].ThereIs)
+ if (!GetNumber(parser[NKey::kUsedMemorySize].PostStrings[0], memSize))
+ IncorrectCommand();
+ if (memSize < 4 ) memSize = 4;
+
+
+ PROPID propIDs[] =
+
+ {
+ NCoderPropID::kUsedMemorySize,
+ NCoderPropID::kOrder
+ };
+ const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]);
+
+ PROPVARIANT properties[kNumPropsMax];
+ for (int p = 0; p < kNumPropsMax; p++)
+ properties[p].vt = VT_UI4;
+
+ properties[0].ulVal = memSize * 1024 * 1024; // memory
+ properties[1].ulVal = order;
+
+ int numProps = kNumPropsMax;
+
+ if (encoderSpec->SetCoderProperties(propIDs, properties, numProps) != S_OK)
+ IncorrectCommand();
+ encoderSpec->WriteCoderProperties(outStream);
+
+/*
+ if (eos || stdInMode)
+ fileSize = (UInt64)(Int64)-1;
+ else
+*/
+ inStreamSpec->File.GetLength(fileSize);
+
+ for (int i = 0; i < 8; i++)
+ {
+ Byte b = Byte(fileSize >> (8 * i));
+ if (outStream->Write(&b, 1, 0) != S_OK)
+ {
+ fprintf(stderr, kWriteError);
+ return 1;
+ }
+ }
+ HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
+ if (result == E_OUTOFMEMORY)
+ {
+ fprintf(stderr, "\nError: Can not allocate memory\n");
+ return 1;
+ }
+ else if (result != S_OK)
+ {
+ fprintf(stderr, "\nEncoder error = %X\n", (unsigned int)result);
+ return 1;
+ }
+ }
+ else
+ {
+ // NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder;
+ NCompress::NPpmd::CDecoder *decoderSpec = new NCompress::NPpmd::CDecoder;
+ CMyComPtr<ICompressCoder> decoder = decoderSpec;
+ const UInt32 kPropertiesSize = 5;
+ Byte header[kPropertiesSize + 8];
+ if (ReadStream_FALSE(inStream, header, kPropertiesSize + 8) != S_OK)
+ {
+ fprintf(stderr, kReadError);
+ return 1;
+ }
+ if (decoderSpec->SetDecoderProperties2(header, kPropertiesSize) != S_OK)
+ {
+ fprintf(stderr, "SetDecoderProperties error");
+ return 1;
+ }
+ fileSize = 0;
+ for (int i = 0; i < 8; i++)
+ fileSize |= ((UInt64)header[kPropertiesSize + i]) << (8 * i);
+
+ if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
+ {
+ fprintf(stderr, "Decoder error");
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int main(int n, const char *args[])
+{
+ try { return main2(n, args); }
+ catch(const char *s)
+ {
+ fprintf(stderr, "\nError: %s\n", s);
+ return 1;
+ }
+ catch(...)
+ {
+ fprintf(stderr, "\nError\n");
+ return 1;
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdContext.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdContext.h
new file mode 100644
index 000000000..cfff53eda
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdContext.h
@@ -0,0 +1,490 @@
+// PpmdContext.h
+// 2009-05-30 : Igor Pavlov : Public domain
+// This code is based on Dmitry Shkarin's PPMdH code (public domain)
+
+#ifndef __COMPRESS_PPMD_CONTEXT_H
+#define __COMPRESS_PPMD_CONTEXT_H
+
+#include "../../Common/Types.h"
+
+#include "PpmdSubAlloc.h"
+#include "RangeCoder.h"
+
+namespace NCompress {
+namespace NPpmd {
+
+const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
+ INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124;
+
+struct SEE2_CONTEXT
+{
+ // SEE-contexts for PPM-contexts with masked symbols
+ UInt16 Summ;
+ Byte Shift, Count;
+ void init(int InitVal) { Summ = (UInt16)(InitVal << (Shift=PERIOD_BITS-4)); Count=4; }
+ unsigned int getMean()
+ {
+ unsigned int RetVal=(Summ >> Shift);
+ Summ = (UInt16)(Summ - RetVal);
+ return RetVal+(RetVal == 0);
+ }
+ void update()
+ {
+ if (Shift < PERIOD_BITS && --Count == 0)
+ {
+ Summ <<= 1;
+ Count = (Byte)(3 << Shift++);
+ }
+ }
+};
+
+struct PPM_CONTEXT
+{
+ UInt16 NumStats; // sizeof(UInt16) > sizeof(Byte)
+ UInt16 SummFreq;
+
+ struct STATE
+ {
+ Byte Symbol, Freq;
+ UInt16 SuccessorLow;
+ UInt16 SuccessorHigh;
+
+ UInt32 GetSuccessor() const { return SuccessorLow | ((UInt32)SuccessorHigh << 16); }
+ void SetSuccessor(UInt32 v)
+ {
+ SuccessorLow = (UInt16)(v & 0xFFFF);
+ SuccessorHigh = (UInt16)((v >> 16) & 0xFFFF);
+ }
+ };
+
+ UInt32 Stats;
+ UInt32 Suffix;
+
+ PPM_CONTEXT* createChild(CSubAllocator &subAllocator, STATE* pStats, STATE& FirstState)
+ {
+ PPM_CONTEXT* pc = (PPM_CONTEXT*) subAllocator.AllocContext();
+ if (pc)
+ {
+ pc->NumStats = 1;
+ pc->oneState() = FirstState;
+ pc->Suffix = subAllocator.GetOffset(this);
+ pStats->SetSuccessor(subAllocator.GetOffsetNoCheck(pc));
+ }
+ return pc;
+ }
+
+ STATE& oneState() const { return (STATE&) SummFreq; }
+};
+
+/////////////////////////////////
+
+const UInt16 InitBinEsc[] =
+ {0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051};
+
+struct CInfo
+{
+ CSubAllocator SubAllocator;
+ SEE2_CONTEXT SEE2Cont[25][16], DummySEE2Cont;
+ PPM_CONTEXT * MinContext, * MaxContext;
+
+ PPM_CONTEXT::STATE* FoundState; // found next state transition
+ int NumMasked, InitEsc, OrderFall, RunLength, InitRL, MaxOrder;
+ Byte CharMask[256], NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
+ Byte EscCount, PrintCount, PrevSuccess, HiBitsFlag;
+ UInt16 BinSumm[128][64]; // binary SEE-contexts
+
+ UInt16 &GetBinSumm(const PPM_CONTEXT::STATE &rs, int numStates)
+ {
+ HiBitsFlag = HB2Flag[FoundState->Symbol];
+ return BinSumm[rs.Freq - 1][
+ PrevSuccess + NS2BSIndx[numStates - 1] +
+ HiBitsFlag + 2 * HB2Flag[rs.Symbol] +
+ ((RunLength >> 26) & 0x20)];
+ }
+
+ PPM_CONTEXT *GetContext(UInt32 offset) const { return (PPM_CONTEXT *)SubAllocator.GetPtr(offset); }
+ PPM_CONTEXT *GetContextNoCheck(UInt32 offset) const { return (PPM_CONTEXT *)SubAllocator.GetPtrNoCheck(offset); }
+ PPM_CONTEXT::STATE *GetState(UInt32 offset) const { return (PPM_CONTEXT::STATE *)SubAllocator.GetPtr(offset); }
+ PPM_CONTEXT::STATE *GetStateNoCheck(UInt32 offset) const { return (PPM_CONTEXT::STATE *)SubAllocator.GetPtr(offset); }
+
+ void RestartModelRare()
+ {
+ int i, k, m;
+ memset(CharMask,0,sizeof(CharMask));
+ SubAllocator.InitSubAllocator();
+ InitRL = -((MaxOrder < 12) ? MaxOrder : 12) - 1;
+ MinContext = MaxContext = (PPM_CONTEXT*) SubAllocator.AllocContext();
+ MinContext->Suffix = 0;
+ OrderFall = MaxOrder;
+ MinContext->SummFreq = (UInt16)((MinContext->NumStats = 256) + 1);
+ FoundState = (PPM_CONTEXT::STATE*)SubAllocator.AllocUnits(256 / 2);
+ MinContext->Stats = SubAllocator.GetOffsetNoCheck(FoundState);
+ PrevSuccess = 0;
+ for (RunLength = InitRL, i = 0; i < 256; i++)
+ {
+ PPM_CONTEXT::STATE &state = FoundState[i];
+ state.Symbol = (Byte)i;
+ state.Freq = 1;
+ state.SetSuccessor(0);
+ }
+ for (i = 0; i < 128; i++)
+ for (k = 0; k < 8; k++)
+ for ( m=0; m < 64; m += 8)
+ BinSumm[i][k + m] = (UInt16)(BIN_SCALE - InitBinEsc[k] / (i + 2));
+ for (i = 0; i < 25; i++)
+ for (k = 0; k < 16; k++)
+ SEE2Cont[i][k].init(5*i+10);
+ }
+
+ void StartModelRare(int maxOrder)
+ {
+ int i, k, m ,Step;
+ EscCount=PrintCount=1;
+ if (maxOrder < 2)
+ {
+ memset(CharMask,0,sizeof(CharMask));
+ OrderFall = MaxOrder;
+ MinContext = MaxContext;
+ while (MinContext->Suffix != 0)
+ {
+ MinContext = GetContextNoCheck(MinContext->Suffix);
+ OrderFall--;
+ }
+ FoundState = GetState(MinContext->Stats);
+ MinContext = MaxContext;
+ }
+ else
+ {
+ MaxOrder = maxOrder;
+ RestartModelRare();
+ NS2BSIndx[0] = 2 * 0;
+ NS2BSIndx[1] = 2 * 1;
+ memset(NS2BSIndx + 2, 2 * 2, 9);
+ memset(NS2BSIndx + 11, 2 * 3, 256 - 11);
+ for (i = 0; i < 3; i++)
+ NS2Indx[i] = (Byte)i;
+ for (m = i, k = Step = 1; i < 256; i++)
+ {
+ NS2Indx[i] = (Byte)m;
+ if ( !--k )
+ {
+ k = ++Step;
+ m++;
+ }
+ }
+ memset(HB2Flag, 0, 0x40);
+ memset(HB2Flag + 0x40, 0x08, 0x100 - 0x40);
+ DummySEE2Cont.Shift = PERIOD_BITS;
+ }
+ }
+
+ PPM_CONTEXT* CreateSuccessors(bool skip, PPM_CONTEXT::STATE* p1)
+ {
+ // static UpState declaration bypasses IntelC bug
+ // static PPM_CONTEXT::STATE UpState;
+ PPM_CONTEXT::STATE UpState;
+
+ PPM_CONTEXT *pc = MinContext;
+ PPM_CONTEXT *UpBranch = GetContext(FoundState->GetSuccessor());
+ PPM_CONTEXT::STATE * p, * ps[MAX_O], ** pps = ps;
+ if ( !skip )
+ {
+ *pps++ = FoundState;
+ if ( !pc->Suffix )
+ goto NO_LOOP;
+ }
+ if ( p1 )
+ {
+ p = p1;
+ pc = GetContext(pc->Suffix);
+ goto LOOP_ENTRY;
+ }
+ do
+ {
+ pc = GetContext(pc->Suffix);
+ if (pc->NumStats != 1)
+ {
+ if ((p = GetStateNoCheck(pc->Stats))->Symbol != FoundState->Symbol)
+ do { p++; } while (p->Symbol != FoundState->Symbol);
+ }
+ else
+ p = &(pc->oneState());
+LOOP_ENTRY:
+ if (GetContext(p->GetSuccessor()) != UpBranch)
+ {
+ pc = GetContext(p->GetSuccessor());
+ break;
+ }
+ *pps++ = p;
+ }
+ while ( pc->Suffix );
+NO_LOOP:
+ if (pps == ps)
+ return pc;
+ UpState.Symbol = *(Byte*) UpBranch;
+ UpState.SetSuccessor(SubAllocator.GetOffset(UpBranch) + 1);
+ if (pc->NumStats != 1)
+ {
+ if ((p = GetStateNoCheck(pc->Stats))->Symbol != UpState.Symbol)
+ do { p++; } while (p->Symbol != UpState.Symbol);
+ unsigned int cf = p->Freq-1;
+ unsigned int s0 = pc->SummFreq - pc->NumStats - cf;
+ UpState.Freq = (Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) :
+ ((2 * cf + 3 * s0 - 1) / (2 * s0))));
+ }
+ else
+ UpState.Freq = pc->oneState().Freq;
+ do
+ {
+ pc = pc->createChild(SubAllocator, *--pps, UpState);
+ if ( !pc )
+ return NULL;
+ }
+ while (pps != ps);
+ return pc;
+ }
+
+ void UpdateModel()
+ {
+ PPM_CONTEXT::STATE fs = *FoundState, * p = NULL;
+ PPM_CONTEXT* pc, * Successor;
+ unsigned int ns1, ns, cf, sf, s0;
+ if (fs.Freq < MAX_FREQ / 4 && MinContext->Suffix != 0)
+ {
+ pc = GetContextNoCheck(MinContext->Suffix);
+
+ if (pc->NumStats != 1)
+ {
+ if ((p = GetStateNoCheck(pc->Stats))->Symbol != fs.Symbol)
+ {
+ do { p++; } while (p->Symbol != fs.Symbol);
+ if (p[0].Freq >= p[-1].Freq)
+ {
+ _PPMD_SWAP(p[0],p[-1]);
+ p--;
+ }
+ }
+ if (p->Freq < MAX_FREQ-9)
+ {
+ p->Freq += 2;
+ pc->SummFreq += 2;
+ }
+ }
+ else
+ {
+ p = &(pc->oneState());
+ p->Freq = (Byte)(p->Freq + ((p->Freq < 32) ? 1 : 0));
+ }
+ }
+ if ( !OrderFall )
+ {
+ MinContext = MaxContext = CreateSuccessors(true, p);
+ FoundState->SetSuccessor(SubAllocator.GetOffset(MinContext));
+ if (MinContext == 0)
+ goto RESTART_MODEL;
+ return;
+ }
+ *SubAllocator.pText++ = fs.Symbol;
+ Successor = (PPM_CONTEXT*) SubAllocator.pText;
+ if (SubAllocator.pText >= SubAllocator.UnitsStart)
+ goto RESTART_MODEL;
+ if (fs.GetSuccessor() != 0)
+ {
+ if ((Byte *)GetContext(fs.GetSuccessor()) <= SubAllocator.pText)
+ {
+ PPM_CONTEXT* cs = CreateSuccessors(false, p);
+ fs.SetSuccessor(SubAllocator.GetOffset(cs));
+ if (cs == NULL)
+ goto RESTART_MODEL;
+ }
+ if ( !--OrderFall )
+ {
+ Successor = GetContext(fs.GetSuccessor());
+ SubAllocator.pText -= (MaxContext != MinContext);
+ }
+ }
+ else
+ {
+ FoundState->SetSuccessor(SubAllocator.GetOffsetNoCheck(Successor));
+ fs.SetSuccessor(SubAllocator.GetOffsetNoCheck(MinContext));
+ }
+ s0 = MinContext->SummFreq - (ns = MinContext->NumStats) - (fs.Freq - 1);
+ for (pc = MaxContext; pc != MinContext; pc = GetContext(pc->Suffix))
+ {
+ if ((ns1 = pc->NumStats) != 1)
+ {
+ if ((ns1 & 1) == 0)
+ {
+ void *ppp = SubAllocator.ExpandUnits(GetState(pc->Stats), ns1 >> 1);
+ pc->Stats = SubAllocator.GetOffset(ppp);
+ if (!ppp)
+ goto RESTART_MODEL;
+ }
+ pc->SummFreq = (UInt16)(pc->SummFreq + (2 * ns1 < ns) + 2 * ((4 * ns1 <= ns) &
+ (pc->SummFreq <= 8 * ns1)));
+ }
+ else
+ {
+ p = (PPM_CONTEXT::STATE*) SubAllocator.AllocUnits(1);
+ if ( !p )
+ goto RESTART_MODEL;
+ *p = pc->oneState();
+ pc->Stats = SubAllocator.GetOffsetNoCheck(p);
+ if (p->Freq < MAX_FREQ / 4 - 1)
+ p->Freq <<= 1;
+ else
+ p->Freq = MAX_FREQ - 4;
+ pc->SummFreq = (UInt16)(p->Freq + InitEsc + (ns > 3));
+ }
+ cf = 2 * fs.Freq * (pc->SummFreq+6);
+ sf = s0 + pc->SummFreq;
+ if (cf < 6 * sf)
+ {
+ cf = 1 + (cf > sf)+(cf >= 4 * sf);
+ pc->SummFreq += 3;
+ }
+ else
+ {
+ cf = 4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf);
+ pc->SummFreq = (UInt16)(pc->SummFreq + cf);
+ }
+ p = GetState(pc->Stats) + ns1;
+ p->SetSuccessor(SubAllocator.GetOffset(Successor));
+ p->Symbol = fs.Symbol;
+ p->Freq = (Byte)cf;
+ pc->NumStats = (UInt16)++ns1;
+ }
+ MaxContext = MinContext = GetContext(fs.GetSuccessor());
+ return;
+RESTART_MODEL:
+ RestartModelRare();
+ EscCount = 0;
+ PrintCount = 0xFF;
+ }
+
+ void ClearMask()
+ {
+ EscCount = 1;
+ memset(CharMask, 0, sizeof(CharMask));
+ // if (++PrintCount == 0)
+ // PrintInfo(DecodedFile,EncodedFile);
+ }
+
+ void update1(PPM_CONTEXT::STATE* p)
+ {
+ (FoundState = p)->Freq += 4;
+ MinContext->SummFreq += 4;
+ if (p[0].Freq > p[-1].Freq)
+ {
+ _PPMD_SWAP(p[0],p[-1]);
+ FoundState = --p;
+ if (p->Freq > MAX_FREQ)
+ rescale();
+ }
+ }
+
+
+ void update2(PPM_CONTEXT::STATE* p)
+ {
+ (FoundState = p)->Freq += 4;
+ MinContext->SummFreq += 4;
+ if (p->Freq > MAX_FREQ)
+ rescale();
+ EscCount++;
+ RunLength = InitRL;
+ }
+
+ SEE2_CONTEXT* makeEscFreq2(int Diff, UInt32 &scale)
+ {
+ SEE2_CONTEXT* psee2c;
+ if (MinContext->NumStats != 256)
+ {
+ psee2c = SEE2Cont[NS2Indx[Diff-1]] +
+ (Diff < (GetContext(MinContext->Suffix))->NumStats - MinContext->NumStats) +
+ 2 * (MinContext->SummFreq < 11 * MinContext->NumStats) +
+ 4 * (NumMasked > Diff) +
+ HiBitsFlag;
+ scale = psee2c->getMean();
+ }
+ else
+ {
+ psee2c = &DummySEE2Cont;
+ scale = 1;
+ }
+ return psee2c;
+ }
+
+
+
+ void rescale()
+ {
+ int OldNS = MinContext->NumStats, i = MinContext->NumStats - 1, Adder, EscFreq;
+ PPM_CONTEXT::STATE* p1, * p;
+ PPM_CONTEXT::STATE *stats = GetStateNoCheck(MinContext->Stats);
+ for (p = FoundState; p != stats; p--)
+ _PPMD_SWAP(p[0], p[-1]);
+ stats->Freq += 4;
+ MinContext->SummFreq += 4;
+ EscFreq = MinContext->SummFreq - p->Freq;
+ Adder = (OrderFall != 0);
+ p->Freq = (Byte)((p->Freq + Adder) >> 1);
+ MinContext->SummFreq = p->Freq;
+ do
+ {
+ EscFreq -= (++p)->Freq;
+ p->Freq = (Byte)((p->Freq + Adder) >> 1);
+ MinContext->SummFreq = (UInt16)(MinContext->SummFreq + p->Freq);
+ if (p[0].Freq > p[-1].Freq)
+ {
+ PPM_CONTEXT::STATE tmp = *(p1 = p);
+ do
+ {
+ p1[0] = p1[-1];
+ }
+ while (--p1 != stats && tmp.Freq > p1[-1].Freq);
+ *p1 = tmp;
+ }
+ }
+ while ( --i );
+ if (p->Freq == 0)
+ {
+ do { i++; } while ((--p)->Freq == 0);
+ EscFreq += i;
+ MinContext->NumStats = (UInt16)(MinContext->NumStats - i);
+ if (MinContext->NumStats == 1)
+ {
+ PPM_CONTEXT::STATE tmp = *stats;
+ do { tmp.Freq = (Byte)(tmp.Freq - (tmp.Freq >> 1)); EscFreq >>= 1; } while (EscFreq > 1);
+ SubAllocator.FreeUnits(stats, (OldNS+1) >> 1);
+ *(FoundState = &MinContext->oneState()) = tmp; return;
+ }
+ }
+ EscFreq -= (EscFreq >> 1);
+ MinContext->SummFreq = (UInt16)(MinContext->SummFreq + EscFreq);
+ int n0 = (OldNS+1) >> 1, n1 = (MinContext->NumStats + 1) >> 1;
+ if (n0 != n1)
+ MinContext->Stats = SubAllocator.GetOffset(SubAllocator.ShrinkUnits(stats, n0, n1));
+ FoundState = GetState(MinContext->Stats);
+ }
+
+ void NextContext()
+ {
+ PPM_CONTEXT *c = GetContext(FoundState->GetSuccessor());
+ if (!OrderFall && (Byte *)c > SubAllocator.pText)
+ MinContext = MaxContext = c;
+ else
+ {
+ UpdateModel();
+ if (EscCount == 0)
+ ClearMask();
+ }
+ }
+};
+
+// Tabulated escapes for exponential symbol distribution
+const Byte ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
+#define GET_MEAN(SUMM,SHIFT,ROUND) ((SUMM+(1 << (SHIFT-ROUND))) >> (SHIFT))
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecode.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecode.h
new file mode 100644
index 000000000..fe6927bf8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecode.h
@@ -0,0 +1,156 @@
+// PpmdDecode.h
+// 2009-05-30 : Igor Pavlov : Public domain
+// This code is based on Dmitry Shkarin's PPMdH code (public domain)
+
+#ifndef __COMPRESS_PPMD_DECODE_H
+#define __COMPRESS_PPMD_DECODE_H
+
+#include "PpmdContext.h"
+
+namespace NCompress {
+namespace NPpmd {
+
+class CRangeDecoderVirt
+{
+public:
+ virtual ~CRangeDecoderVirt() {}
+ virtual UInt32 GetThreshold(UInt32 total) = 0;
+ virtual void Decode(UInt32 start, UInt32 size) = 0;
+ virtual UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits) = 0;
+};
+
+typedef NRangeCoder::CDecoder CRangeDecoderMy;
+
+class CRangeDecoder:public CRangeDecoderVirt, public CRangeDecoderMy
+{
+ UInt32 GetThreshold(UInt32 total) { return CRangeDecoderMy::GetThreshold(total); }
+ void Decode(UInt32 start, UInt32 size) { CRangeDecoderMy::Decode(start, size); }
+ UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits) { return CRangeDecoderMy::DecodeBit(size0, numTotalBits); }
+};
+
+struct CDecodeInfo: public CInfo
+{
+ void DecodeBinSymbol(CRangeDecoderVirt *rangeDecoder)
+ {
+ PPM_CONTEXT::STATE& rs = MinContext->oneState();
+ UInt16& bs = GetBinSumm(rs, GetContextNoCheck(MinContext->Suffix)->NumStats);
+ if (rangeDecoder->DecodeBit(bs, TOT_BITS) == 0)
+ {
+ FoundState = &rs;
+ rs.Freq = (Byte)(rs.Freq + (rs.Freq < 128 ? 1: 0));
+ bs = (UInt16)(bs + INTERVAL - GET_MEAN(bs, PERIOD_BITS, 2));
+ PrevSuccess = 1;
+ RunLength++;
+ }
+ else
+ {
+ bs = (UInt16)(bs - GET_MEAN(bs, PERIOD_BITS, 2));
+ InitEsc = ExpEscape[bs >> 10];
+ NumMasked = 1;
+ CharMask[rs.Symbol] = EscCount;
+ PrevSuccess = 0;
+ FoundState = NULL;
+ }
+ }
+
+ void DecodeSymbol1(CRangeDecoderVirt *rangeDecoder)
+ {
+ PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats);
+ int i, count, hiCnt;
+ if ((count = rangeDecoder->GetThreshold(MinContext->SummFreq)) < (hiCnt = p->Freq))
+ {
+ PrevSuccess = (2 * hiCnt > MinContext->SummFreq);
+ RunLength += PrevSuccess;
+ rangeDecoder->Decode(0, p->Freq); // MinContext->SummFreq);
+ (FoundState = p)->Freq = (Byte)(hiCnt += 4);
+ MinContext->SummFreq += 4;
+ if (hiCnt > MAX_FREQ)
+ rescale();
+ return;
+ }
+ PrevSuccess = 0;
+ i = MinContext->NumStats - 1;
+ while ((hiCnt += (++p)->Freq) <= count)
+ if (--i == 0)
+ {
+ HiBitsFlag = HB2Flag[FoundState->Symbol];
+ rangeDecoder->Decode(hiCnt, MinContext->SummFreq - hiCnt); // , MinContext->SummFreq);
+ CharMask[p->Symbol] = EscCount;
+ i = (NumMasked = MinContext->NumStats)-1;
+ FoundState = NULL;
+ do { CharMask[(--p)->Symbol] = EscCount; } while ( --i );
+ return;
+ }
+ rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , MinContext->SummFreq);
+ update1(p);
+ }
+
+
+ void DecodeSymbol2(CRangeDecoderVirt *rangeDecoder)
+ {
+ int count, hiCnt, i = MinContext->NumStats - NumMasked;
+ UInt32 freqSum;
+ SEE2_CONTEXT* psee2c = makeEscFreq2(i, freqSum);
+ PPM_CONTEXT::STATE* ps[256], ** pps = ps, * p = GetStateNoCheck(MinContext->Stats)-1;
+ hiCnt = 0;
+ do
+ {
+ do { p++; } while (CharMask[p->Symbol] == EscCount);
+ hiCnt += p->Freq;
+ *pps++ = p;
+ }
+ while ( --i );
+
+ freqSum += hiCnt;
+ count = rangeDecoder->GetThreshold(freqSum);
+
+ p = *(pps = ps);
+ if (count < hiCnt)
+ {
+ hiCnt = 0;
+ while ((hiCnt += p->Freq) <= count)
+ p=*++pps;
+ rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , freqSum);
+
+ psee2c->update();
+ update2(p);
+ }
+ else
+ {
+ rangeDecoder->Decode(hiCnt, freqSum - hiCnt); // , freqSum);
+
+ i = MinContext->NumStats - NumMasked;
+ pps--;
+ do { CharMask[(*++pps)->Symbol] = EscCount; } while ( --i );
+ psee2c->Summ = (UInt16)(psee2c->Summ + freqSum);
+ NumMasked = MinContext->NumStats;
+ }
+ }
+
+ int DecodeSymbol(CRangeDecoderVirt *rangeDecoder)
+ {
+ if (MinContext->NumStats != 1)
+ DecodeSymbol1(rangeDecoder);
+ else
+ DecodeBinSymbol(rangeDecoder);
+ while ( !FoundState )
+ {
+ do
+ {
+ OrderFall++;
+ MinContext = GetContext(MinContext->Suffix);
+ if (MinContext == 0)
+ return -1;
+ }
+ while (MinContext->NumStats == NumMasked);
+ DecodeSymbol2(rangeDecoder);
+ }
+ Byte symbol = FoundState->Symbol;
+ NextContext();
+ return symbol;
+ }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecoder.cpp
new file mode 100644
index 000000000..0ac98c8b1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecoder.cpp
@@ -0,0 +1,183 @@
+// PpmdDecoder.cpp
+// 2009-05-30 : Igor Pavlov : Public domain
+
+#include "StdAfx.h"
+
+#include "Common/Defs.h"
+#include "Windows/Defs.h"
+
+#include "PpmdDecoder.h"
+
+namespace NCompress {
+namespace NPpmd {
+
+const int kLenIdFinished = -1;
+const int kLenIdNeedInit = -2;
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *properties, UInt32 size)
+{
+ if (size < 5)
+ return E_INVALIDARG;
+ _order = properties[0];
+ _usedMemorySize = 0;
+ for (int i = 0; i < 4; i++)
+ _usedMemorySize += ((UInt32)(properties[1 + i])) << (i * 8);
+
+ if (_usedMemorySize > kMaxMemBlockSize)
+ return E_NOTIMPL;
+
+ if (!_rangeDecoder.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
+ return E_OUTOFMEMORY;
+
+ return S_OK;
+}
+
+class CDecoderFlusher
+{
+ CDecoder *_coder;
+public:
+ bool NeedFlush;
+ CDecoderFlusher(CDecoder *coder): _coder(coder), NeedFlush(true) {}
+ ~CDecoderFlusher()
+ {
+ if (NeedFlush)
+ _coder->Flush();
+ _coder->ReleaseStreams();
+ }
+};
+
+HRESULT CDecoder::CodeSpec(UInt32 size, Byte *memStream)
+{
+ if (_outSizeDefined)
+ {
+ const UInt64 rem = _outSize - _processedSize;
+ if (size > rem)
+ size = (UInt32)rem;
+ }
+ const UInt32 startSize = size;
+
+ if (_remainLen == kLenIdFinished)
+ return S_OK;
+ if (_remainLen == kLenIdNeedInit)
+ {
+ _rangeDecoder.Init();
+ _remainLen = 0;
+ _info.MaxOrder = 0;
+ _info.StartModelRare(_order);
+ }
+ while (size != 0)
+ {
+ int symbol = _info.DecodeSymbol(&_rangeDecoder);
+ if (symbol < 0)
+ {
+ _remainLen = kLenIdFinished;
+ break;
+ }
+ if (memStream != 0)
+ *memStream++ = (Byte)symbol;
+ else
+ _outStream.WriteByte((Byte)symbol);
+ size--;
+ }
+ _processedSize += startSize - size;
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ if (!_outStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ SetInStream(inStream);
+ _outStream.SetStream(outStream);
+ SetOutStreamSize(outSize);
+ CDecoderFlusher flusher(this);
+
+ for (;;)
+ {
+ _processedSize = _outStream.GetProcessedSize();
+ UInt32 curSize = (1 << 18);
+ RINOK(CodeSpec(curSize, NULL));
+ if (_remainLen == kLenIdFinished)
+ break;
+ if (progress != NULL)
+ {
+ UInt64 inSize = _rangeDecoder.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&inSize, &_processedSize));
+ }
+ if (_outSizeDefined)
+ if (_outStream.GetProcessedSize() >= _outSize)
+ break;
+ }
+ flusher.NeedFlush = false;
+ return Flush();
+}
+
+#ifdef _NO_EXCEPTIONS
+
+#define PPMD_TRY_BEGIN
+#define PPMD_TRY_END
+
+#else
+
+#define PPMD_TRY_BEGIN try {
+#define PPMD_TRY_END } \
+ catch(const CInBufferException &e) { return e.ErrorCode; } \
+ catch(const COutBufferException &e) { return e.ErrorCode; } \
+ catch(...) { return S_FALSE; }
+
+#endif
+
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ PPMD_TRY_BEGIN
+ return CodeReal(inStream, outStream, inSize, outSize, progress);
+ PPMD_TRY_END
+}
+
+STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
+{
+ _rangeDecoder.SetStream(inStream);
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::ReleaseInStream()
+{
+ _rangeDecoder.ReleaseStream();
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
+{
+ _outSizeDefined = (outSize != NULL);
+ if (_outSizeDefined)
+ _outSize = *outSize;
+ _processedSize = 0;
+ _remainLen = kLenIdNeedInit;
+ _outStream.Init();
+ return S_OK;
+}
+
+#ifndef NO_READ_FROM_CODER
+
+STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ PPMD_TRY_BEGIN
+ if (processedSize)
+ *processedSize = 0;
+ const UInt64 startPos = _processedSize;
+ RINOK(CodeSpec(size, (Byte *)data));
+ if (processedSize)
+ *processedSize = (UInt32)(_processedSize - startPos);
+ return Flush();
+ PPMD_TRY_END
+}
+
+#endif
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecoder.h
new file mode 100644
index 000000000..31ab8f82a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdDecoder.h
@@ -0,0 +1,87 @@
+// PpmdDecoder.h
+// 2009-05-30 : Igor Pavlov : Public domain
+
+#ifndef __COMPRESS_PPMD_DECODER_H
+#define __COMPRESS_PPMD_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/OutBuffer.h"
+
+#include "PpmdDecode.h"
+#include "RangeCoder.h"
+
+namespace NCompress {
+namespace NPpmd {
+
+class CDecoder :
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ #ifndef NO_READ_FROM_CODER
+ public ICompressSetInStream,
+ public ICompressSetOutStreamSize,
+ public ISequentialInStream,
+ #endif
+ public CMyUnknownImp
+{
+ CRangeDecoder _rangeDecoder;
+
+ COutBuffer _outStream;
+
+ CDecodeInfo _info;
+
+ Byte _order;
+ UInt32 _usedMemorySize;
+
+ int _remainLen;
+ UInt64 _outSize;
+ bool _outSizeDefined;
+ UInt64 _processedSize;
+
+ HRESULT CodeSpec(UInt32 num, Byte *memStream);
+
+public:
+
+ #ifndef NO_READ_FROM_CODER
+ MY_UNKNOWN_IMP4(
+ ICompressSetDecoderProperties2,
+ ICompressSetInStream,
+ ICompressSetOutStreamSize,
+ ISequentialInStream)
+ #else
+ MY_UNKNOWN_IMP1(
+ ICompressSetDecoderProperties2)
+ #endif
+
+ void ReleaseStreams()
+ {
+ ReleaseInStream();
+ _outStream.ReleaseStream();
+ }
+
+ HRESULT Flush() { return _outStream.Flush(); }
+
+ STDMETHOD(CodeReal)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream);
+ STDMETHOD(ReleaseInStream)();
+ STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
+
+ #ifndef NO_READ_FROM_CODER
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ #endif
+
+ CDecoder(): _outSizeDefined(false) {}
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncode.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncode.h
new file mode 100644
index 000000000..012f859c8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncode.h
@@ -0,0 +1,142 @@
+// PpmdEncode.h
+// 2009-05-30 : Igor Pavlov : Public domain
+// This code is based on Dmitry Shkarin's PPMdH code (public domain)
+
+#ifndef __COMPRESS_PPMD_ENCODE_H
+#define __COMPRESS_PPMD_ENCODE_H
+
+#include "PpmdContext.h"
+
+namespace NCompress {
+namespace NPpmd {
+
+struct CEncodeInfo: public CInfo
+{
+ void EncodeBinSymbol(int symbol, NRangeCoder::CEncoder *rangeEncoder)
+ {
+ PPM_CONTEXT::STATE& rs = MinContext->oneState();
+ UInt16 &bs = GetBinSumm(rs, GetContextNoCheck(MinContext->Suffix)->NumStats);
+ if (rs.Symbol == symbol)
+ {
+ FoundState = &rs;
+ rs.Freq = (Byte)(rs.Freq + (rs.Freq < 128 ? 1: 0));
+ rangeEncoder->EncodeBit(bs, TOT_BITS, 0);
+ bs = (UInt16)(bs + INTERVAL - GET_MEAN(bs, PERIOD_BITS, 2));
+ PrevSuccess = 1;
+ RunLength++;
+ }
+ else
+ {
+ rangeEncoder->EncodeBit(bs, TOT_BITS, 1);
+ bs = (UInt16)(bs - GET_MEAN(bs, PERIOD_BITS, 2));
+ InitEsc = ExpEscape[bs >> 10];
+ NumMasked = 1;
+ CharMask[rs.Symbol] = EscCount;
+ PrevSuccess = 0;
+ FoundState = NULL;
+ }
+ }
+
+ void EncodeSymbol1(int symbol, NRangeCoder::CEncoder *rangeEncoder)
+ {
+ PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats);
+ if (p->Symbol == symbol)
+ {
+ PrevSuccess = (2 * (p->Freq) > MinContext->SummFreq);
+ RunLength += PrevSuccess;
+ rangeEncoder->Encode(0, p->Freq, MinContext->SummFreq);
+ (FoundState = p)->Freq += 4;
+ MinContext->SummFreq += 4;
+ if (p->Freq > MAX_FREQ)
+ rescale();
+ return;
+ }
+ PrevSuccess = 0;
+ int LoCnt = p->Freq, i = MinContext->NumStats - 1;
+ while ((++p)->Symbol != symbol)
+ {
+ LoCnt += p->Freq;
+ if (--i == 0)
+ {
+ HiBitsFlag = HB2Flag[FoundState->Symbol];
+ CharMask[p->Symbol] = EscCount;
+ i=(NumMasked = MinContext->NumStats)-1;
+ FoundState = NULL;
+ do { CharMask[(--p)->Symbol] = EscCount; } while ( --i );
+ rangeEncoder->Encode(LoCnt, MinContext->SummFreq - LoCnt, MinContext->SummFreq);
+ return;
+ }
+ }
+ rangeEncoder->Encode(LoCnt, p->Freq, MinContext->SummFreq);
+ update1(p);
+ }
+
+ void EncodeSymbol2(int symbol, NRangeCoder::CEncoder *rangeEncoder)
+ {
+ int hiCnt, i = MinContext->NumStats - NumMasked;
+ UInt32 scale;
+ SEE2_CONTEXT* psee2c = makeEscFreq2(i, scale);
+ PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats) - 1;
+ hiCnt = 0;
+ do
+ {
+ do { p++; } while (CharMask[p->Symbol] == EscCount);
+ hiCnt += p->Freq;
+ if (p->Symbol == symbol)
+ goto SYMBOL_FOUND;
+ CharMask[p->Symbol] = EscCount;
+ }
+ while ( --i );
+
+ rangeEncoder->Encode(hiCnt, scale, hiCnt + scale);
+ scale += hiCnt;
+
+ psee2c->Summ = (UInt16)(psee2c->Summ + scale);
+ NumMasked = MinContext->NumStats;
+ return;
+SYMBOL_FOUND:
+
+ UInt32 highCount = hiCnt;
+ UInt32 lowCount = highCount - p->Freq;
+ if ( --i )
+ {
+ PPM_CONTEXT::STATE* p1 = p;
+ do
+ {
+ do { p1++; } while (CharMask[p1->Symbol] == EscCount);
+ hiCnt += p1->Freq;
+ }
+ while ( --i );
+ }
+ // SubRange.scale += hiCnt;
+ scale += hiCnt;
+ rangeEncoder->Encode(lowCount, highCount - lowCount, scale);
+ psee2c->update();
+ update2(p);
+ }
+
+ void EncodeSymbol(int c, NRangeCoder::CEncoder *rangeEncoder)
+ {
+ if (MinContext->NumStats != 1)
+ EncodeSymbol1(c, rangeEncoder);
+ else
+ EncodeBinSymbol(c, rangeEncoder);
+ while ( !FoundState )
+ {
+ do
+ {
+ OrderFall++;
+ MinContext = GetContext(MinContext->Suffix);
+ if (MinContext == 0)
+ return; // S_OK;
+ }
+ while (MinContext->NumStats == NumMasked);
+ EncodeSymbol2(c, rangeEncoder);
+ }
+ NextContext();
+ }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncoder.cpp
new file mode 100644
index 000000000..ce1b7af02
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncoder.cpp
@@ -0,0 +1,148 @@
+// PpmdEncoder.cpp
+// 2009-05-30 : Igor Pavlov : Public domain
+
+#include "StdAfx.h"
+
+// #include <fstream.h>
+// #include <iomanip.h>
+
+#include "../Common/StreamUtils.h"
+
+#include "PpmdEncoder.h"
+
+namespace NCompress {
+namespace NPpmd {
+
+const UInt32 kMinMemSize = (1 << 11);
+const UInt32 kMinOrder = 2;
+
+/*
+UInt32 g_NumInner = 0;
+UInt32 g_InnerCycles = 0;
+
+UInt32 g_Encode2 = 0;
+UInt32 g_Encode2Cycles = 0;
+UInt32 g_Encode2Cycles2 = 0;
+
+class CCounter
+{
+public:
+ CCounter() {}
+ ~CCounter()
+ {
+ ofstream ofs("Res.dat");
+ ofs << "innerEncode1 = " << setw(10) << g_NumInner << endl;
+ ofs << "g_InnerCycles = " << setw(10) << g_InnerCycles << endl;
+ ofs << "g_Encode2 = " << setw(10) << g_Encode2 << endl;
+ ofs << "g_Encode2Cycles = " << setw(10) << g_Encode2Cycles << endl;
+ ofs << "g_Encode2Cycles2= " << setw(10) << g_Encode2Cycles2 << endl;
+
+ }
+};
+CCounter g_Counter;
+*/
+
+STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
+{
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ const PROPVARIANT &prop = props[i];
+ switch(propIDs[i])
+ {
+ case NCoderPropID::kUsedMemorySize:
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ if (prop.ulVal < kMinMemSize || prop.ulVal > kMaxMemBlockSize)
+ return E_INVALIDARG;
+ _usedMemorySize = (UInt32)prop.ulVal;
+ break;
+ case NCoderPropID::kOrder:
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ if (prop.ulVal < static_cast< Int32 >( kMinOrder ) || prop.ulVal > static_cast< Int32 >( kMaxOrderCompress) )
+ return E_INVALIDARG;
+ _order = (Byte)prop.ulVal;
+ break;
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
+{
+ const UInt32 kPropSize = 5;
+ Byte props[kPropSize];
+ props[0] = _order;
+ for (int i = 0; i < 4; i++)
+ props[1 + i] = Byte(_usedMemorySize >> (8 * i));
+ return WriteStream(outStream, props, kPropSize);
+}
+
+const UInt32 kUsedMemorySizeDefault = (1 << 24);
+const int kOrderDefault = 6;
+
+CEncoder::CEncoder():
+ _usedMemorySize(kUsedMemorySizeDefault),
+ _order(kOrderDefault)
+{
+}
+
+
+HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
+{
+ if (!_inStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ if (!_rangeEncoder.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
+ return E_OUTOFMEMORY;
+
+ _inStream.SetStream(inStream);
+ _inStream.Init();
+
+ _rangeEncoder.SetStream(outStream);
+ _rangeEncoder.Init();
+
+ CEncoderFlusher flusher(this);
+
+ _info.MaxOrder = 0;
+ _info.StartModelRare(_order);
+
+ for (;;)
+ {
+ UInt32 size = (1 << 18);
+ do
+ {
+ Byte symbol;
+ if (!_inStream.ReadByte(symbol))
+ {
+ // here we can write End Mark for stream version.
+ // In current version this feature is not used.
+ // _info.EncodeSymbol(-1, &_rangeEncoder);
+ return S_OK;
+ }
+ _info.EncodeSymbol(symbol, &_rangeEncoder);
+ }
+ while (--size != 0);
+ if (progress != NULL)
+ {
+ UInt64 inSize = _inStream.GetProcessedSize();
+ UInt64 outSize = _rangeEncoder.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&inSize, &outSize));
+ }
+ }
+}
+
+STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(...) { return E_FAIL; }
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncoder.h
new file mode 100644
index 000000000..07b368a7e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdEncoder.h
@@ -0,0 +1,79 @@
+// PpmdEncoder.h
+// 2009-05-30 : Igor Pavlov : Public domain
+
+#ifndef __COMPRESS_PPMD_ENCODER_H
+#define __COMPRESS_PPMD_ENCODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "PpmdEncode.h"
+#include "RangeCoder.h"
+
+namespace NCompress {
+namespace NPpmd {
+
+class CEncoder :
+ public ICompressCoder,
+ public ICompressSetCoderProperties,
+ public ICompressWriteCoderProperties,
+ public CMyUnknownImp
+{
+public:
+ CInBuffer _inStream;
+
+ NRangeCoder::CEncoder _rangeEncoder;
+
+ CEncodeInfo _info;
+ UInt32 _usedMemorySize;
+ Byte _order;
+
+ HRESULT Flush()
+ {
+ _rangeEncoder.FlushData();
+ return _rangeEncoder.FlushStream();
+ }
+
+ void ReleaseStreams()
+ {
+ _inStream.ReleaseStream();
+ _rangeEncoder.ReleaseStream();
+ }
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ class CEncoderFlusher
+ {
+ CEncoder *_encoder;
+ public:
+ CEncoderFlusher(CEncoder *encoder): _encoder(encoder) {}
+ ~CEncoderFlusher()
+ {
+ _encoder->Flush();
+ _encoder->ReleaseStreams();
+ }
+ };
+
+public:
+
+ MY_UNKNOWN_IMP2(
+ ICompressSetCoderProperties,
+ ICompressWriteCoderProperties)
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
+
+ STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+
+ CEncoder();
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdRegister.cpp
new file mode 100644
index 000000000..9f59fcdd3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdRegister.cpp
@@ -0,0 +1,21 @@
+// PpmdRegister.cpp
+// 2009-05-30 : Igor Pavlov : Public domain
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "PpmdDecoder.h"
+
+static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NPpmd::CDecoder); }
+#ifndef EXTRACT_ONLY
+#include "PpmdEncoder.h"
+static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NPpmd::CEncoder); }
+#else
+#define CreateCodecOut 0
+#endif
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodec, CreateCodecOut, 0x030401, L"PPMD", 1, false };
+
+REGISTER_CODEC(PPMD)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdSubAlloc.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdSubAlloc.h
new file mode 100644
index 000000000..f264f6376
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdSubAlloc.h
@@ -0,0 +1,293 @@
+// PpmdSubAlloc.h
+// 2009-05-30 : Igor Pavlov : Public domain
+// This code is based on Dmitry Shkarin's PPMdH code (public domain)
+
+#ifndef __COMPRESS_PPMD_SUB_ALLOC_H
+#define __COMPRESS_PPMD_SUB_ALLOC_H
+
+#include "../../../C/Alloc.h"
+
+#include "PpmdType.h"
+
+const UINT N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
+const UINT UNIT_SIZE=12, N_INDEXES=N1+N2+N3+N4;
+
+// Extra 1 * UNIT_SIZE for NULL support
+// Extra 2 * UNIT_SIZE for s0 in GlueFreeBlocks()
+const UInt32 kExtraSize = (UNIT_SIZE * 3);
+const UInt32 kMaxMemBlockSize = 0xFFFFFFFF - kExtraSize;
+
+struct MEM_BLK
+{
+ UInt16 Stamp, NU;
+ UInt32 Next, Prev;
+ void InsertAt(Byte *Base, UInt32 p)
+ {
+ Prev = p;
+ MEM_BLK *pp = (MEM_BLK *)(Base + p);
+ Next = pp->Next;
+ pp->Next = ((MEM_BLK *)(Base + Next))->Prev = (UInt32)((Byte *)this - Base);
+ }
+ void Remove(Byte *Base)
+ {
+ ((MEM_BLK *)(Base + Prev))->Next = Next;
+ ((MEM_BLK *)(Base + Next))->Prev = Prev;
+ }
+};
+
+
+class CSubAllocator
+{
+ UInt32 SubAllocatorSize;
+ Byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;
+ UInt32 FreeList[N_INDEXES];
+
+ Byte *Base;
+ Byte *HeapStart, *LoUnit, *HiUnit;
+public:
+ Byte *pText, *UnitsStart;
+ CSubAllocator():
+ SubAllocatorSize(0),
+ GlueCount(0),
+ LoUnit(0),
+ HiUnit(0),
+ pText(0),
+ UnitsStart(0)
+ {
+ memset(Indx2Units, 0, sizeof(Indx2Units));
+ memset(FreeList, 0, sizeof(FreeList));
+ }
+ ~CSubAllocator()
+ {
+ StopSubAllocator();
+ };
+
+ void *GetPtr(UInt32 offset) const { return (offset == 0) ? 0 : (void *)(Base + offset); }
+ void *GetPtrNoCheck(UInt32 offset) const { return (void *)(Base + offset); }
+ UInt32 GetOffset(void *ptr) const { return (ptr == 0) ? 0 : (UInt32)((Byte *)ptr - Base); }
+ UInt32 GetOffsetNoCheck(void *ptr) const { return (UInt32)((Byte *)ptr - Base); }
+ MEM_BLK *GetBlk(UInt32 offset) const { return (MEM_BLK *)(Base + offset); }
+ UInt32 *GetNode(UInt32 offset) const { return (UInt32 *)(Base + offset); }
+
+ void InsertNode(void* p, int indx)
+ {
+ *(UInt32 *)p = FreeList[indx];
+ FreeList[indx] = GetOffsetNoCheck(p);
+ }
+
+ void* RemoveNode(int indx)
+ {
+ UInt32 offset = FreeList[indx];
+ UInt32 *p = GetNode(offset);
+ FreeList[indx] = *p;
+ return (void *)p;
+ }
+
+ UINT U2B(int NU) const { return (UINT)(NU) * UNIT_SIZE; }
+
+ void SplitBlock(void* pv, int oldIndx, int newIndx)
+ {
+ int i, UDiff = Indx2Units[oldIndx] - Indx2Units[newIndx];
+ Byte* p = ((Byte*)pv) + U2B(Indx2Units[newIndx]);
+ if (Indx2Units[i = Units2Indx[UDiff-1]] != UDiff)
+ {
+ InsertNode(p, --i);
+ p += U2B(i = Indx2Units[i]);
+ UDiff -= i;
+ }
+ InsertNode(p, Units2Indx[UDiff - 1]);
+ }
+
+ UInt32 GetUsedMemory() const
+ {
+ UInt32 RetVal = SubAllocatorSize - (UInt32)(HiUnit - LoUnit) - (UInt32)(UnitsStart - pText);
+ for (UInt32 i = 0; i < N_INDEXES; i++)
+ for (UInt32 pn = FreeList[i]; pn != 0; RetVal -= (UInt32)Indx2Units[i] * UNIT_SIZE)
+ pn = *GetNode(pn);
+ return (RetVal >> 2);
+ }
+
+ UInt32 GetSubAllocatorSize() const { return SubAllocatorSize; }
+
+ void StopSubAllocator()
+ {
+ if (SubAllocatorSize != 0)
+ {
+ BigFree(Base);
+ SubAllocatorSize = 0;
+ Base = 0;
+ }
+ }
+
+ bool StartSubAllocator(UInt32 size)
+ {
+ if (SubAllocatorSize == size)
+ return true;
+ StopSubAllocator();
+ if (size == 0)
+ Base = 0;
+ else
+ {
+ if ((Base = (Byte *)::BigAlloc(size + kExtraSize)) == 0)
+ return false;
+ HeapStart = Base + UNIT_SIZE; // we need such code to support NULL;
+ }
+ SubAllocatorSize = size;
+ return true;
+ }
+
+ void InitSubAllocator()
+ {
+ unsigned int i, k;
+ memset(FreeList, 0, sizeof(FreeList));
+ HiUnit = (pText = HeapStart) + SubAllocatorSize;
+ UINT Diff = UNIT_SIZE * (SubAllocatorSize / 8 / UNIT_SIZE * 7);
+ LoUnit = UnitsStart = HiUnit - Diff;
+ for (i = 0, k=1; i < N1 ; i++, k += 1) Indx2Units[i] = (Byte)k;
+ for (k++; i < N1 + N2 ;i++, k += 2) Indx2Units[i] = (Byte)k;
+ for (k++; i < N1 + N2 + N3 ;i++,k += 3) Indx2Units[i] = (Byte)k;
+ for (k++; i < N1 + N2 + N3 + N4; i++, k += 4) Indx2Units[i] = (Byte)k;
+ GlueCount = 0;
+ for (k = i = 0; k < 128; k++)
+ {
+ i += (Indx2Units[i] < k+1);
+ Units2Indx[k] = (Byte)i;
+ }
+ }
+
+ void GlueFreeBlocks()
+ {
+ UInt32 s0 = (UInt32)(HeapStart + SubAllocatorSize - Base);
+
+ // We need add exta MEM_BLK with Stamp=0
+ GetBlk(s0)->Stamp = 0;
+ s0 += UNIT_SIZE;
+ MEM_BLK *ps0 = GetBlk(s0);
+
+ UInt32 p;
+ unsigned int i;
+ if (LoUnit != HiUnit)
+ *LoUnit=0;
+ ps0->Next = ps0->Prev = s0;
+
+ for (i = 0; i < N_INDEXES; i++)
+ while (FreeList[i] != 0)
+ {
+ MEM_BLK *pp = (MEM_BLK *)RemoveNode(i);
+ pp->InsertAt(Base, s0);
+ pp->Stamp = 0xFFFF;
+ pp->NU = Indx2Units[i];
+ }
+ for (p = ps0->Next; p != s0; p = GetBlk(p)->Next)
+ {
+ for (;;)
+ {
+ MEM_BLK *pp = GetBlk(p);
+ MEM_BLK *pp1 = GetBlk(p + pp->NU * UNIT_SIZE);
+ if (pp1->Stamp != 0xFFFF || int(pp->NU) + pp1->NU >= 0x10000)
+ break;
+ pp1->Remove(Base);
+ pp->NU = (UInt16)(pp->NU + pp1->NU);
+ }
+ }
+ while ((p = ps0->Next) != s0)
+ {
+ MEM_BLK *pp = GetBlk(p);
+ pp->Remove(Base);
+ int sz;
+ for (sz = pp->NU; sz > 128; sz -= 128, p += 128 * UNIT_SIZE)
+ InsertNode(Base + p, N_INDEXES - 1);
+ if (Indx2Units[i = Units2Indx[sz-1]] != sz)
+ {
+ int k = sz - Indx2Units[--i];
+ InsertNode(Base + p + (sz - k) * UNIT_SIZE, k - 1);
+ }
+ InsertNode(Base + p, i);
+ }
+ }
+ void* AllocUnitsRare(int indx)
+ {
+ if ( !GlueCount )
+ {
+ GlueCount = 255;
+ GlueFreeBlocks();
+ if (FreeList[indx] != 0)
+ return RemoveNode(indx);
+ }
+ int i = indx;
+ do
+ {
+ if (++i == static_cast< int >( N_INDEXES) )
+ {
+ GlueCount--;
+ i = U2B(Indx2Units[indx]);
+ return (UnitsStart - pText > i) ? (UnitsStart -= i) : (NULL);
+ }
+ } while (FreeList[i] == 0);
+ void* RetVal = RemoveNode(i);
+ SplitBlock(RetVal, i, indx);
+ return RetVal;
+ }
+
+ void* AllocUnits(int NU)
+ {
+ int indx = Units2Indx[NU - 1];
+ if (FreeList[indx] != 0)
+ return RemoveNode(indx);
+ void* RetVal = LoUnit;
+ LoUnit += U2B(Indx2Units[indx]);
+ if (LoUnit <= HiUnit)
+ return RetVal;
+ LoUnit -= U2B(Indx2Units[indx]);
+ return AllocUnitsRare(indx);
+ }
+
+ void* AllocContext()
+ {
+ if (HiUnit != LoUnit)
+ return (HiUnit -= UNIT_SIZE);
+ if (FreeList[0] != 0)
+ return RemoveNode(0);
+ return AllocUnitsRare(0);
+ }
+
+ void* ExpandUnits(void* oldPtr, int oldNU)
+ {
+ int i0=Units2Indx[oldNU - 1], i1=Units2Indx[oldNU - 1 + 1];
+ if (i0 == i1)
+ return oldPtr;
+ void* ptr = AllocUnits(oldNU + 1);
+ if (ptr)
+ {
+ memcpy(ptr, oldPtr, U2B(oldNU));
+ InsertNode(oldPtr, i0);
+ }
+ return ptr;
+ }
+
+ void* ShrinkUnits(void* oldPtr, int oldNU, int newNU)
+ {
+ int i0 = Units2Indx[oldNU - 1], i1 = Units2Indx[newNU - 1];
+ if (i0 == i1)
+ return oldPtr;
+ if (FreeList[i1] != 0)
+ {
+ void* ptr = RemoveNode(i1);
+ memcpy(ptr, oldPtr, U2B(newNU));
+ InsertNode(oldPtr,i0);
+ return ptr;
+ }
+ else
+ {
+ SplitBlock(oldPtr, i0, i1);
+ return oldPtr;
+ }
+ }
+
+ void FreeUnits(void* ptr, int oldNU)
+ {
+ InsertNode(ptr, Units2Indx[oldNU - 1]);
+ }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdType.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdType.h
new file mode 100644
index 000000000..e4b0203c0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/PpmdType.h
@@ -0,0 +1,14 @@
+// PpmdType.h
+// 2009-05-30 : Igor Pavlov : Public domain
+// This code is based on Dmitry Shkarin's PPMdH code (public domain)
+
+#ifndef __COMPRESS_PPMD_TYPE_H
+#define __COMPRESS_PPMD_TYPE_H
+
+const int kMaxOrderCompress = 32;
+const int MAX_O = 255; /* maximum allowed model order */
+
+template <class T>
+inline void _PPMD_SWAP(T& t1,T& t2) { T tmp = t1; t1 = t2; t2 = tmp; }
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/QuantumDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/QuantumDecoder.cpp
new file mode 100644
index 000000000..b4c1c2563
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/QuantumDecoder.cpp
@@ -0,0 +1,171 @@
+// QuantumDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/Defs.h"
+
+#include "QuantumDecoder.h"
+
+namespace NCompress {
+namespace NQuantum {
+
+// const UInt32 kDictionarySizeMax = (1 << 21);
+
+const int kLenIdNeedInit = -2;
+
+void CDecoder::Init()
+{
+ m_Selector.Init(kNumSelectors);
+ for (unsigned int i = 0; i < kNumLitSelectors; i++)
+ m_Literals[i].Init(kNumLitSymbols);
+ unsigned int numItems = _numDictBits << 1;
+ m_PosSlot[0].Init(MyMin(numItems, kNumLen3PosSymbolsMax));
+ m_PosSlot[1].Init(MyMin(numItems, kNumLen4PosSymbolsMax));
+ m_PosSlot[2].Init(MyMin(numItems, kNumLen5PosSymbolsMax));
+ m_LenSlot.Init(kNumLenSymbols);
+}
+
+HRESULT CDecoder::CodeSpec(UInt32 curSize)
+{
+ if (_remainLen == kLenIdNeedInit)
+ {
+ if (!_keepHistory)
+ {
+ if (!_outWindowStream.Create(_dictionarySize))
+ return E_OUTOFMEMORY;
+ Init();
+ }
+ if (!_rangeDecoder.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ _rangeDecoder.Init();
+ _remainLen = 0;
+ }
+ if (curSize == 0)
+ return S_OK;
+
+ while(_remainLen > 0 && curSize > 0)
+ {
+ _remainLen--;
+ Byte b = _outWindowStream.GetByte(_rep0);
+ _outWindowStream.PutByte(b);
+ curSize--;
+ }
+
+ while(curSize > 0)
+ {
+ if (_rangeDecoder.Stream.WasFinished())
+ return S_FALSE;
+
+ unsigned int selector = m_Selector.Decode(&_rangeDecoder);
+ if (selector < kNumLitSelectors)
+ {
+ Byte b = (Byte)((selector << (8 - kNumLitSelectorBits)) + m_Literals[selector].Decode(&_rangeDecoder));
+ _outWindowStream.PutByte(b);
+ curSize--;
+ }
+ else
+ {
+ selector -= kNumLitSelectors;
+ unsigned int len = selector + kMatchMinLen;
+ if (selector == 2)
+ {
+ unsigned int lenSlot = m_LenSlot.Decode(&_rangeDecoder);;
+ if (lenSlot >= kNumSimpleLenSlots)
+ {
+ lenSlot -= 2;
+ int numDirectBits = (int)(lenSlot >> 2);
+ len += ((4 | (lenSlot & 3)) << numDirectBits) - 2;
+ if (numDirectBits < 6)
+ len += _rangeDecoder.Stream.ReadBits(numDirectBits);
+ }
+ else
+ len += lenSlot;
+ }
+ UInt32 rep0 = m_PosSlot[selector].Decode(&_rangeDecoder);;
+ if (rep0 >= kNumSimplePosSlots)
+ {
+ int numDirectBits = (int)((rep0 >> 1) - 1);
+ rep0 = ((2 | (rep0 & 1)) << numDirectBits) + _rangeDecoder.Stream.ReadBits(numDirectBits);
+ }
+ unsigned int locLen = len;
+ if (len > curSize)
+ locLen = (unsigned int)curSize;
+ if (!_outWindowStream.CopyBlock(rep0, locLen))
+ return S_FALSE;
+ curSize -= locLen;
+ len -= locLen;
+ if (len != 0)
+ {
+ _remainLen = (int)len;
+ _rep0 = rep0;
+ break;
+ }
+ }
+ }
+ return _rangeDecoder.Stream.WasFinished() ? S_FALSE : S_OK;
+}
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ if (outSize == NULL)
+ return E_INVALIDARG;
+ UInt64 size = *outSize;
+
+ SetInStream(inStream);
+ _outWindowStream.SetStream(outStream);
+ SetOutStreamSize(outSize);
+ CDecoderFlusher flusher(this);
+
+ const UInt64 start = _outWindowStream.GetProcessedSize();
+ for (;;)
+ {
+ UInt32 curSize = 1 << 18;
+ UInt64 rem = size - (_outWindowStream.GetProcessedSize() - start);
+ if (curSize > rem)
+ curSize = (UInt32)rem;
+ if (curSize == 0)
+ break;
+ RINOK(CodeSpec(curSize));
+ if (progress != NULL)
+ {
+ UInt64 inSize = _rangeDecoder.GetProcessedSize();
+ UInt64 nowPos64 = _outWindowStream.GetProcessedSize() - start;
+ RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
+ }
+ }
+ flusher.NeedFlush = false;
+ return Flush();
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
+{
+ _rangeDecoder.SetStream(inStream);
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::ReleaseInStream()
+{
+ _rangeDecoder.ReleaseStream();
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
+{
+ if (outSize == NULL)
+ return E_FAIL;
+ _remainLen = kLenIdNeedInit;
+ _outWindowStream.Init(_keepHistory);
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/QuantumDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/QuantumDecoder.h
new file mode 100644
index 000000000..383514468
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/QuantumDecoder.h
@@ -0,0 +1,287 @@
+// QuantumDecoder.h
+
+#ifndef __COMPRESS_QUANTUM_DECODER_H
+#define __COMPRESS_QUANTUM_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "LzOutWindow.h"
+
+namespace NCompress {
+namespace NQuantum {
+
+class CStreamBitDecoder
+{
+ UInt32 m_Value;
+ CInBuffer m_Stream;
+public:
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+ void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
+ void ReleaseStream() { m_Stream.ReleaseStream();}
+
+ void Finish() { m_Value = 0x10000; }
+
+ void Init()
+ {
+ m_Stream.Init();
+ m_Value = 0x10000;
+ }
+
+ UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize(); }
+ bool WasFinished() const { return m_Stream.WasFinished(); };
+
+ UInt32 ReadBit()
+ {
+ if (m_Value >= 0x10000)
+ m_Value = 0x100 | m_Stream.ReadByte();
+ UInt32 res = (m_Value >> 7) & 1;
+ m_Value <<= 1;
+ return res;
+ }
+
+ UInt32 ReadBits(int numBits) // numBits > 0
+ {
+ UInt32 res = 0;
+ do
+ res = (res << 1) | ReadBit();
+ while(--numBits != 0);
+ return res;
+ }
+};
+
+const int kNumLitSelectorBits = 2;
+const unsigned int kNumLitSelectors = (1 << kNumLitSelectorBits);
+const unsigned int kNumLitSymbols = 1 << (8 - kNumLitSelectorBits);
+const unsigned int kNumMatchSelectors = 3;
+const unsigned int kNumSelectors = kNumLitSelectors + kNumMatchSelectors;
+const unsigned int kNumLen3PosSymbolsMax = 24;
+const unsigned int kNumLen4PosSymbolsMax = 36;
+const unsigned int kNumLen5PosSymbolsMax = 42;
+const unsigned int kNumLenSymbols = 27;
+
+const unsigned int kNumSymbolsMax = kNumLitSymbols; // 64
+
+const unsigned int kMatchMinLen = 3;
+const unsigned int kNumSimplePosSlots = 4;
+const unsigned int kNumSimpleLenSlots = 6;
+
+namespace NRangeCoder {
+
+class CDecoder
+{
+ UInt32 Low;
+ UInt32 Range;
+ UInt32 Code;
+public:
+ CStreamBitDecoder Stream;
+ bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
+ void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }
+ void ReleaseStream() { Stream.ReleaseStream(); }
+
+ void Init()
+ {
+ Stream.Init();
+ Low = 0;
+ Range = 0x10000;
+ Code = Stream.ReadBits(16);
+ }
+
+ void Finish()
+ {
+ // we need these extra two Bit_reads
+ Stream.ReadBit();
+ Stream.ReadBit();
+ Stream.Finish();
+ }
+
+ UInt64 GetProcessedSize() const { return Stream.GetProcessedSize(); }
+
+ UInt32 GetThreshold(UInt32 total) const
+ {
+ return ((Code + 1) * total - 1) / Range; // & 0xFFFF is not required;
+ }
+
+ void Decode(UInt32 start, UInt32 end, UInt32 total)
+ {
+ UInt32 high = Low + end * Range / total - 1;
+ UInt32 offset = start * Range / total;
+ Code -= offset;
+ Low += offset;
+ for (;;)
+ {
+ if ((Low & 0x8000) != (high & 0x8000))
+ {
+ if ((Low & 0x4000) == 0 || (high & 0x4000) != 0)
+ break;
+ Low &= 0x3FFF;
+ high |= 0x4000;
+ }
+ Low = (Low << 1) & 0xFFFF;
+ high = ((high << 1) | 1) & 0xFFFF;
+ Code = ((Code << 1) | Stream.ReadBit());
+ }
+ Range = high - Low + 1;
+ }
+};
+
+const UInt16 kUpdateStep = 8;
+const UInt16 kFreqSumMax = 3800;
+const UInt16 kReorderCountStart = 4;
+const UInt16 kReorderCount = 50;
+
+class CModelDecoder
+{
+ unsigned int NumItems;
+ unsigned int ReorderCount;
+ UInt16 Freqs[kNumSymbolsMax + 1];
+ Byte Values[kNumSymbolsMax];
+public:
+ void Init(unsigned int numItems)
+ {
+ NumItems = numItems;
+ ReorderCount = kReorderCountStart;
+ for(unsigned int i = 0; i < numItems; i++)
+ {
+ Freqs[i] = (UInt16)(numItems - i);
+ Values[i] = (Byte)i;
+ }
+ Freqs[numItems] = 0;
+ }
+
+ unsigned int Decode(CDecoder *rangeDecoder)
+ {
+ UInt32 threshold = rangeDecoder->GetThreshold(Freqs[0]);
+ unsigned int i;
+ for (i = 1; Freqs[i] > threshold; i++) {}
+ rangeDecoder->Decode(Freqs[i], Freqs[i - 1], Freqs[0]);
+ unsigned int res = Values[--i];
+ do
+ Freqs[i] += kUpdateStep;
+ while(i-- != 0);
+
+ if (Freqs[0] > kFreqSumMax)
+ {
+ if (--ReorderCount == 0)
+ {
+ ReorderCount = kReorderCount;
+ for(i = 0; i < NumItems; i++)
+ Freqs[i] = (UInt16)(((Freqs[i] - Freqs[i + 1]) + 1) >> 1);
+ for(i = 0; i < NumItems - 1; i++)
+ for(unsigned int j = i + 1; j < NumItems; j++)
+ if (Freqs[i] < Freqs[j])
+ {
+ UInt16 tmpFreq = Freqs[i];
+ Byte tmpVal = Values[i];
+ Freqs[i] = Freqs[j];
+ Values[i] = Values[j];
+ Freqs[j] = tmpFreq;
+ Values[j] = tmpVal;
+ }
+ do
+ Freqs[i] = (UInt16)(Freqs[i] + Freqs[i + 1]);
+ while(i-- != 0);
+ }
+ else
+ {
+ i = NumItems - 1;
+ do
+ {
+ Freqs[i] >>= 1;
+ if (Freqs[i] <= Freqs[i + 1])
+ Freqs[i] = (UInt16)(Freqs[i + 1] + 1);
+ }
+ while(i-- != 0);
+ }
+ }
+ return res;
+ };
+};
+
+}
+
+class CDecoder:
+ public ICompressCoder,
+ public ICompressSetInStream,
+ public ICompressSetOutStreamSize,
+ public CMyUnknownImp
+{
+ CLzOutWindow _outWindowStream;
+ NRangeCoder::CDecoder _rangeDecoder;
+
+ ///////////////////
+ // State
+ UInt64 _outSize;
+ // UInt64 _nowPos64;
+ int _remainLen; // -1 means end of stream. // -2 means need Init
+ UInt32 _rep0;
+
+ int _numDictBits;
+ UInt32 _dictionarySize;
+
+ NRangeCoder::CModelDecoder m_Selector;
+ NRangeCoder::CModelDecoder m_Literals[kNumLitSelectors];
+ NRangeCoder::CModelDecoder m_PosSlot[kNumMatchSelectors];
+ NRangeCoder::CModelDecoder m_LenSlot;
+
+ bool _keepHistory;
+
+ void Init();
+ HRESULT CodeSpec(UInt32 size);
+public:
+ MY_UNKNOWN_IMP2(
+ ICompressSetInStream,
+ ICompressSetOutStreamSize)
+
+ void ReleaseStreams()
+ {
+ _outWindowStream.ReleaseStream();
+ ReleaseInStream();
+ }
+
+ class CDecoderFlusher
+ {
+ CDecoder *_decoder;
+ public:
+ bool NeedFlush;
+ CDecoderFlusher(CDecoder *decoder): _decoder(decoder), NeedFlush(true) {}
+ ~CDecoderFlusher()
+ {
+ if (NeedFlush)
+ _decoder->Flush();
+ _decoder->ReleaseStreams();
+ }
+ };
+
+ HRESULT Flush() { return _outWindowStream.Flush(); }
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream);
+ STDMETHOD(ReleaseInStream)();
+ STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
+
+ void SetParams(int numDictBits)
+ {
+ _numDictBits = numDictBits;
+ _dictionarySize = (UInt32)1 << numDictBits;
+ }
+ void SetKeepHistory(bool keepHistory)
+ {
+ _keepHistory = keepHistory;
+ }
+
+ CDecoder(): _keepHistory(false) {}
+ virtual ~CDecoder() {}
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RangeCoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RangeCoder.h
new file mode 100644
index 000000000..1eb2a6d47
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RangeCoder.h
@@ -0,0 +1,205 @@
+// Compress/RangeCoder.h
+// 2009-05-30 : Igor Pavlov : Public domain
+
+#ifndef __COMPRESS_RANGE_CODER_H
+#define __COMPRESS_RANGE_CODER_H
+
+#include "../Common/InBuffer.h"
+#include "../Common/OutBuffer.h"
+
+namespace NCompress {
+namespace NRangeCoder {
+
+const int kNumTopBits = 24;
+const UInt32 kTopValue = (1 << kNumTopBits);
+
+class CEncoder
+{
+ UInt32 _cacheSize;
+ Byte _cache;
+public:
+ UInt64 Low;
+ UInt32 Range;
+ COutBuffer Stream;
+ bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
+
+ void SetStream(ISequentialOutStream *stream) { Stream.SetStream(stream); }
+ void Init()
+ {
+ Stream.Init();
+ Low = 0;
+ Range = 0xFFFFFFFF;
+ _cacheSize = 1;
+ _cache = 0;
+ }
+
+ void FlushData()
+ {
+ // Low += 1;
+ for(int i = 0; i < 5; i++)
+ ShiftLow();
+ }
+
+ HRESULT FlushStream() { return Stream.Flush(); }
+
+ void ReleaseStream() { Stream.ReleaseStream(); }
+
+ void Encode(UInt32 start, UInt32 size, UInt32 total)
+ {
+ Low += start * (Range /= total);
+ Range *= size;
+ while (Range < kTopValue)
+ {
+ Range <<= 8;
+ ShiftLow();
+ }
+ }
+
+ void ShiftLow()
+ {
+ if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0)
+ {
+ Byte temp = _cache;
+ do
+ {
+ Stream.WriteByte((Byte)(temp + (Byte)(Low >> 32)));
+ temp = 0xFF;
+ }
+ while(--_cacheSize != 0);
+ _cache = (Byte)((UInt32)Low >> 24);
+ }
+ _cacheSize++;
+ Low = (UInt32)Low << 8;
+ }
+
+ void EncodeDirectBits(UInt32 value, int numBits)
+ {
+ for (numBits--; numBits >= 0; numBits--)
+ {
+ Range >>= 1;
+ Low += Range & (0 - ((value >> numBits) & 1));
+ if (Range < kTopValue)
+ {
+ Range <<= 8;
+ ShiftLow();
+ }
+ }
+ }
+
+ void EncodeBit(UInt32 size0, UInt32 numTotalBits, UInt32 symbol)
+ {
+ UInt32 newBound = (Range >> numTotalBits) * size0;
+ if (symbol == 0)
+ Range = newBound;
+ else
+ {
+ Low += newBound;
+ Range -= newBound;
+ }
+ while (Range < kTopValue)
+ {
+ Range <<= 8;
+ ShiftLow();
+ }
+ }
+
+ UInt64 GetProcessedSize() { return Stream.GetProcessedSize() + _cacheSize + 4; }
+};
+
+class CDecoder
+{
+public:
+ CInBuffer Stream;
+ UInt32 Range;
+ UInt32 Code;
+ bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
+
+ void Normalize()
+ {
+ while (Range < kTopValue)
+ {
+ Code = (Code << 8) | Stream.ReadByte();
+ Range <<= 8;
+ }
+ }
+
+ void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }
+ void Init()
+ {
+ Stream.Init();
+ Code = 0;
+ Range = 0xFFFFFFFF;
+ for(int i = 0; i < 5; i++)
+ Code = (Code << 8) | Stream.ReadByte();
+ }
+
+ void ReleaseStream() { Stream.ReleaseStream(); }
+
+ UInt32 GetThreshold(UInt32 total)
+ {
+ return (Code) / ( Range /= total);
+ }
+
+ void Decode(UInt32 start, UInt32 size)
+ {
+ Code -= start * Range;
+ Range *= size;
+ Normalize();
+ }
+
+ UInt32 DecodeDirectBits(int numTotalBits)
+ {
+ UInt32 range = Range;
+ UInt32 code = Code;
+ UInt32 result = 0;
+ for (int i = numTotalBits; i != 0; i--)
+ {
+ range >>= 1;
+ /*
+ result <<= 1;
+ if (code >= range)
+ {
+ code -= range;
+ result |= 1;
+ }
+ */
+ UInt32 t = (code - range) >> 31;
+ code -= range & (t - 1);
+ result = (result << 1) | (1 - t);
+
+ if (range < kTopValue)
+ {
+ code = (code << 8) | Stream.ReadByte();
+ range <<= 8;
+ }
+ }
+ Range = range;
+ Code = code;
+ return result;
+ }
+
+ UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits)
+ {
+ UInt32 newBound = (Range >> numTotalBits) * size0;
+ UInt32 symbol;
+ if (Code < newBound)
+ {
+ symbol = 0;
+ Range = newBound;
+ }
+ else
+ {
+ symbol = 1;
+ Code -= newBound;
+ Range -= newBound;
+ }
+ Normalize();
+ return symbol;
+ }
+
+ UInt64 GetProcessedSize() {return Stream.GetProcessedSize(); }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RangeCoderBit.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RangeCoderBit.h
new file mode 100644
index 000000000..b5a1830d6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RangeCoderBit.h
@@ -0,0 +1,114 @@
+// Compress/RangeCoderBit.h
+// 2009-05-30 : Igor Pavlov : Public domain
+
+#ifndef __COMPRESS_RANGE_CODER_BIT_H
+#define __COMPRESS_RANGE_CODER_BIT_H
+
+#include "RangeCoder.h"
+
+namespace NCompress {
+namespace NRangeCoder {
+
+const int kNumBitModelTotalBits = 11;
+const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits);
+
+const int kNumMoveReducingBits = 4;
+
+const int kNumBitPriceShiftBits = 4;
+const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits;
+
+extern UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
+
+template <int numMoveBits>
+class CBitModel
+{
+public:
+ UInt32 Prob;
+ void UpdateModel(UInt32 symbol)
+ {
+ /*
+ Prob -= (Prob + ((symbol - 1) & ((1 << numMoveBits) - 1))) >> numMoveBits;
+ Prob += (1 - symbol) << (kNumBitModelTotalBits - numMoveBits);
+ */
+ if (symbol == 0)
+ Prob += (kBitModelTotal - Prob) >> numMoveBits;
+ else
+ Prob -= (Prob) >> numMoveBits;
+ }
+public:
+ void Init() { Prob = kBitModelTotal / 2; }
+};
+
+template <int numMoveBits>
+class CBitEncoder: public CBitModel<numMoveBits>
+{
+public:
+ void Encode(CEncoder *encoder, UInt32 symbol)
+ {
+ /*
+ encoder->EncodeBit(this->Prob, kNumBitModelTotalBits, symbol);
+ this->UpdateModel(symbol);
+ */
+ UInt32 newBound = (encoder->Range >> kNumBitModelTotalBits) * this->Prob;
+ if (symbol == 0)
+ {
+ encoder->Range = newBound;
+ this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
+ }
+ else
+ {
+ encoder->Low += newBound;
+ encoder->Range -= newBound;
+ this->Prob -= (this->Prob) >> numMoveBits;
+ }
+ if (encoder->Range < kTopValue)
+ {
+ encoder->Range <<= 8;
+ encoder->ShiftLow();
+ }
+ }
+ UInt32 GetPrice(UInt32 symbol) const
+ {
+ return ProbPrices[(this->Prob ^ ((-(int)symbol)) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
+ }
+ UInt32 GetPrice0() const { return ProbPrices[this->Prob >> kNumMoveReducingBits]; }
+ UInt32 GetPrice1() const { return ProbPrices[(this->Prob ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]; }
+};
+
+
+template <int numMoveBits>
+class CBitDecoder: public CBitModel<numMoveBits>
+{
+public:
+ UInt32 Decode(CDecoder *decoder)
+ {
+ UInt32 newBound = (decoder->Range >> kNumBitModelTotalBits) * this->Prob;
+ if (decoder->Code < newBound)
+ {
+ decoder->Range = newBound;
+ this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
+ if (decoder->Range < kTopValue)
+ {
+ decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
+ decoder->Range <<= 8;
+ }
+ return 0;
+ }
+ else
+ {
+ decoder->Range -= newBound;
+ decoder->Code -= newBound;
+ this->Prob -= (this->Prob) >> numMoveBits;
+ if (decoder->Range < kTopValue)
+ {
+ decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
+ decoder->Range <<= 8;
+ }
+ return 1;
+ }
+ }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar1Decoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar1Decoder.cpp
new file mode 100644
index 000000000..c7540b922
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar1Decoder.cpp
@@ -0,0 +1,478 @@
+// Rar1Decoder.cpp
+// According to unRAR license, this code may not be used to develop
+// a program that creates RAR archives
+
+#include "StdAfx.h"
+
+#include "Rar1Decoder.h"
+
+namespace NCompress {
+namespace NRar1 {
+
+static UInt32 PosL1[]={0,0,0,2,3,5,7,11,16,20,24,32,32, 256};
+static UInt32 PosL2[]={0,0,0,0,5,7,9,13,18,22,26,34,36, 256};
+static UInt32 PosHf0[]={0,0,0,0,0,8,16,24,33,33,33,33,33, 257};
+static UInt32 PosHf1[]={0,0,0,0,0,0,4,44,60,76,80,80,127, 257};
+static UInt32 PosHf2[]={0,0,0,0,0,0,2,7,53,117,233, 257,0};
+static UInt32 PosHf3[]={0,0,0,0,0,0,0,2,16,218,251, 257,0};
+static UInt32 PosHf4[]={0,0,0,0,0,0,0,0,0,255, 257,0,0};
+
+static const UInt32 kHistorySize = (1 << 16);
+
+class CCoderReleaser
+{
+ CDecoder *m_Coder;
+public:
+ CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
+ ~CCoderReleaser() { m_Coder->ReleaseStreams(); }
+};
+
+CDecoder::CDecoder(): m_IsSolid(false) { }
+
+void CDecoder::InitStructures()
+{
+ for(int i = 0; i < kNumRepDists; i++)
+ m_RepDists[i] = 0;
+ m_RepDistPtr = 0;
+ LastLength = 0;
+ LastDist = 0;
+}
+
+UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+
+HRESULT CDecoder::CopyBlock(UInt32 distance, UInt32 len)
+{
+ m_UnpackSize -= len;
+ return m_OutWindowStream.CopyBlock(distance, len) ? S_OK : S_FALSE;
+}
+
+
+UInt32 CDecoder::DecodeNum(const UInt32 *posTab)
+{
+ UInt32 startPos = 2;
+ UInt32 num = m_InBitStream.GetValue(12);
+ for (;;)
+ {
+ UInt32 cur = (posTab[startPos + 1] - posTab[startPos]) << (12 - startPos);
+ if (num < cur)
+ break;
+ startPos++;
+ num -= cur;
+ }
+ m_InBitStream.MovePos(startPos);
+ return((num >> (12 - startPos)) + posTab[startPos]);
+}
+
+static Byte kShortLen1[] = {1,3,4,4,5,6,7,8,8,4,4,5,6,6 };
+static Byte kShortLen1a[] = {1,4,4,4,5,6,7,8,8,4,4,5,6,6,4 };
+static Byte kShortLen2[] = {2,3,3,3,4,4,5,6,6,4,4,5,6,6 };
+static Byte kShortLen2a[] = {2,3,3,4,4,4,5,6,6,4,4,5,6,6,4 };
+static UInt32 kShortXor1[] = {0,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xc0,0x80,0x90,0x98,0x9c,0xb0};
+static UInt32 kShortXor2[] = {0,0x40,0x60,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xc0,0x80,0x90,0x98,0x9c,0xb0};
+
+HRESULT CDecoder::ShortLZ()
+{
+ UInt32 len, saveLen, dist;
+ int distancePlace;
+ Byte *kShortLen;
+ const UInt32 *kShortXor;
+ NumHuf = 0;
+
+ if (LCount == 2)
+ {
+ if (ReadBits(1))
+ return CopyBlock(LastDist, LastLength);
+ LCount = 0;
+ }
+
+ UInt32 bitField = m_InBitStream.GetValue(8);
+
+ if (AvrLn1 < 37)
+ {
+ kShortLen = Buf60 ? kShortLen1a : kShortLen1;
+ kShortXor = kShortXor1;
+ }
+ else
+ {
+ kShortLen = Buf60 ? kShortLen2a : kShortLen2;
+ kShortXor = kShortXor2;
+ }
+
+ for (len = 0; ((bitField ^ kShortXor[len]) & (~(0xff >> kShortLen[len]))) != 0; len++);
+ m_InBitStream.MovePos(kShortLen[len]);
+
+ if (len >= 9)
+ {
+ if (len == 9)
+ {
+ LCount++;
+ return CopyBlock(LastDist, LastLength);
+ }
+ if (len == 14)
+ {
+ LCount = 0;
+ len = DecodeNum(PosL2) + 5;
+ dist = 0x8000 + ReadBits(15) - 1;
+ LastLength = len;
+ LastDist = dist;
+ return CopyBlock(dist, len);
+ }
+
+ LCount = 0;
+ saveLen = len;
+ dist = m_RepDists[(m_RepDistPtr - (len - 9)) & 3];
+ len = DecodeNum(PosL1) + 2;
+ if (len == 0x101 && saveLen == 10)
+ {
+ Buf60 ^= 1;
+ return S_OK;
+ }
+ if (dist >= 256)
+ len++;
+ if (dist >= MaxDist3 - 1)
+ len++;
+ }
+ else
+ {
+ LCount = 0;
+ AvrLn1 += len;
+ AvrLn1 -= AvrLn1 >> 4;
+
+ distancePlace = DecodeNum(PosHf2) & 0xff;
+ dist = ChSetA[distancePlace];
+ if (--distancePlace != -1)
+ {
+ PlaceA[dist]--;
+ UInt32 lastDistance = ChSetA[distancePlace];
+ PlaceA[lastDistance]++;
+ ChSetA[distancePlace + 1] = lastDistance;
+ ChSetA[distancePlace] = dist;
+ }
+ len += 2;
+ }
+ m_RepDists[m_RepDistPtr++] = dist;
+ m_RepDistPtr &= 3;
+ LastLength = len;
+ LastDist = dist;
+ return CopyBlock(dist, len);
+}
+
+
+HRESULT CDecoder::LongLZ()
+{
+ UInt32 len;
+ UInt32 dist;
+ UInt32 distancePlace, newDistancePlace;
+ UInt32 oldAvr2, oldAvr3;
+
+ NumHuf = 0;
+ Nlzb += 16;
+ if (Nlzb > 0xff)
+ {
+ Nlzb = 0x90;
+ Nhfb >>= 1;
+ }
+ oldAvr2=AvrLn2;
+
+ if (AvrLn2 >= 122)
+ len = DecodeNum(PosL2);
+ else if (AvrLn2 >= 64)
+ len = DecodeNum(PosL1);
+ else
+ {
+ UInt32 bitField = m_InBitStream.GetValue(16);
+ if (bitField < 0x100)
+ {
+ len = bitField;
+ m_InBitStream.MovePos(16);
+ }
+ else
+ {
+ for (len = 0; ((bitField << len) & 0x8000) == 0; len++)
+ ;
+ m_InBitStream.MovePos(len + 1);
+ }
+ }
+
+ AvrLn2 += len;
+ AvrLn2 -= AvrLn2 >> 5;
+
+ if (AvrPlcB > 0x28ff)
+ distancePlace = DecodeNum(PosHf2);
+ else if (AvrPlcB > 0x6ff)
+ distancePlace = DecodeNum(PosHf1);
+ else
+ distancePlace = DecodeNum(PosHf0);
+
+ AvrPlcB += distancePlace;
+ AvrPlcB -= AvrPlcB >> 8;
+ for (;;)
+ {
+ dist = ChSetB[distancePlace & 0xff];
+ newDistancePlace = NToPlB[dist++ & 0xff]++;
+ if (!(dist & 0xff))
+ CorrHuff(ChSetB,NToPlB);
+ else
+ break;
+ }
+
+ ChSetB[distancePlace] = ChSetB[newDistancePlace];
+ ChSetB[newDistancePlace] = dist;
+
+ dist = ((dist & 0xff00) >> 1) | ReadBits(7);
+
+ oldAvr3 = AvrLn3;
+ if (len != 1 && len != 4)
+ if (len == 0 && dist <= MaxDist3)
+ {
+ AvrLn3++;
+ AvrLn3 -= AvrLn3 >> 8;
+ }
+ else
+ if (AvrLn3 > 0)
+ AvrLn3--;
+ len += 3;
+ if (dist >= MaxDist3)
+ len++;
+ if (dist <= 256)
+ len += 8;
+ if (oldAvr3 > 0xb0 || AvrPlc >= 0x2a00 && oldAvr2 < 0x40)
+ MaxDist3 = 0x7f00;
+ else
+ MaxDist3 = 0x2001;
+ m_RepDists[m_RepDistPtr++] = --dist;
+ m_RepDistPtr &= 3;
+ LastLength = len;
+ LastDist = dist;
+ return CopyBlock(dist, len);
+}
+
+
+HRESULT CDecoder::HuffDecode()
+{
+ UInt32 curByte, newBytePlace;
+ UInt32 len;
+ UInt32 dist;
+ int bytePlace;
+
+ if (AvrPlc > 0x75ff) bytePlace = DecodeNum(PosHf4);
+ else if (AvrPlc > 0x5dff) bytePlace = DecodeNum(PosHf3);
+ else if (AvrPlc > 0x35ff) bytePlace = DecodeNum(PosHf2);
+ else if (AvrPlc > 0x0dff) bytePlace = DecodeNum(PosHf1);
+ else bytePlace = DecodeNum(PosHf0);
+ if (StMode)
+ {
+ if (--bytePlace == -1)
+ {
+ if (ReadBits(1))
+ {
+ NumHuf = StMode = 0;
+ return S_OK;
+ }
+ else
+ {
+ len = (ReadBits(1)) ? 4 : 3;
+ dist = DecodeNum(PosHf2);
+ dist = (dist << 5) | ReadBits(5);
+ return CopyBlock(dist - 1, len);
+ }
+ }
+ }
+ else if (NumHuf++ >= 16 && FlagsCnt == 0)
+ StMode = 1;
+ bytePlace &= 0xff;
+ AvrPlc += bytePlace;
+ AvrPlc -= AvrPlc >> 8;
+ Nhfb+=16;
+ if (Nhfb > 0xff)
+ {
+ Nhfb=0x90;
+ Nlzb >>= 1;
+ }
+
+ m_UnpackSize --;
+ m_OutWindowStream.PutByte((Byte)(ChSet[bytePlace] >> 8));
+
+ for (;;)
+ {
+ curByte = ChSet[bytePlace];
+ newBytePlace = NToPl[curByte++ & 0xff]++;
+ if ((curByte & 0xff) > 0xa1)
+ CorrHuff(ChSet, NToPl);
+ else
+ break;
+ }
+
+ ChSet[bytePlace] = ChSet[newBytePlace];
+ ChSet[newBytePlace] = curByte;
+ return S_OK;
+}
+
+
+void CDecoder::GetFlagsBuf()
+{
+ UInt32 flags, newFlagsPlace;
+ UInt32 flagsPlace = DecodeNum(PosHf2);
+
+ for (;;)
+ {
+ flags = ChSetC[flagsPlace];
+ FlagBuf = flags >> 8;
+ newFlagsPlace = NToPlC[flags++ & 0xff]++;
+ if ((flags & 0xff) != 0)
+ break;
+ CorrHuff(ChSetC, NToPlC);
+ }
+
+ ChSetC[flagsPlace] = ChSetC[newFlagsPlace];
+ ChSetC[newFlagsPlace] = flags;
+}
+
+void CDecoder::InitData()
+{
+ if (!m_IsSolid)
+ {
+ AvrPlcB = AvrLn1 = AvrLn2 = AvrLn3 = NumHuf = Buf60 = 0;
+ AvrPlc = 0x3500;
+ MaxDist3 = 0x2001;
+ Nhfb = Nlzb = 0x80;
+ }
+ FlagsCnt = 0;
+ FlagBuf = 0;
+ StMode = 0;
+ LCount = 0;
+}
+
+void CDecoder::CorrHuff(UInt32 *CharSet,UInt32 *NumToPlace)
+{
+ int i;
+ for (i = 7; i >= 0; i--)
+ for (int j = 0; j < 32; j++, CharSet++)
+ *CharSet = (*CharSet & ~0xff) | i;
+ memset(NumToPlace, 0, sizeof(NToPl));
+ for (i = 6; i >= 0; i--)
+ NumToPlace[i] = (7 - i) * 32;
+}
+
+void CDecoder::InitHuff()
+{
+ for (UInt32 i = 0; i < 256; i++)
+ {
+ Place[i] = PlaceA[i] = PlaceB[i] = i;
+ PlaceC[i] = (~i + 1) & 0xff;
+ ChSet[i] = ChSetB[i] = i << 8;
+ ChSetA[i] = i;
+ ChSetC[i] = ((~i + 1) & 0xff) << 8;
+ }
+ memset(NToPl, 0, sizeof(NToPl));
+ memset(NToPlB, 0, sizeof(NToPlB));
+ memset(NToPlC, 0, sizeof(NToPlC));
+ CorrHuff(ChSetB, NToPlB);
+}
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo * /* progress */)
+{
+ if (inSize == NULL || outSize == NULL)
+ return E_INVALIDARG;
+
+ if (!m_OutWindowStream.Create(kHistorySize))
+ return E_OUTOFMEMORY;
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ m_UnpackSize = (Int64)*outSize;
+ m_OutWindowStream.SetStream(outStream);
+ m_OutWindowStream.Init(m_IsSolid);
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+
+ CCoderReleaser coderReleaser(this);
+ InitData();
+ if (!m_IsSolid)
+ {
+ InitStructures();
+ InitHuff();
+ }
+ if (m_UnpackSize > 0)
+ {
+ GetFlagsBuf();
+ FlagsCnt = 8;
+ }
+
+ while (m_UnpackSize > 0)
+ {
+ if (StMode)
+ {
+ RINOK(HuffDecode());
+ continue;
+ }
+
+ if (--FlagsCnt < 0)
+ {
+ GetFlagsBuf();
+ FlagsCnt=7;
+ }
+
+ if (FlagBuf & 0x80)
+ {
+ FlagBuf <<= 1;
+ if (Nlzb > Nhfb)
+ {
+ RINOK(LongLZ());
+ }
+ else
+ {
+ RINOK(HuffDecode());
+ }
+ }
+ else
+ {
+ FlagBuf <<= 1;
+ if (--FlagsCnt < 0)
+ {
+ GetFlagsBuf();
+ FlagsCnt = 7;
+ }
+ if (FlagBuf & 0x80)
+ {
+ FlagBuf <<= 1;
+ if (Nlzb > Nhfb)
+ {
+ RINOK(HuffDecode());
+ }
+ else
+ {
+ RINOK(LongLZ());
+ }
+ }
+ else
+ {
+ FlagBuf <<= 1;
+ RINOK(ShortLZ());
+ }
+ }
+ }
+ if (m_UnpackSize < 0)
+ return S_FALSE;
+ return m_OutWindowStream.Flush();
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size < 1)
+ return E_INVALIDARG;
+ m_IsSolid = (data[0] != 0);
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar1Decoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar1Decoder.h
new file mode 100644
index 000000000..f7c08b386
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar1Decoder.h
@@ -0,0 +1,88 @@
+// Rar1Decoder.h
+// According to unRAR license, this code may not be used to develop
+// a program that creates RAR archives
+
+#ifndef __COMPRESS_RAR1_DECODER_H
+#define __COMPRESS_RAR1_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "BitmDecoder.h"
+#include "HuffmanDecoder.h"
+#include "LzOutWindow.h"
+
+namespace NCompress {
+namespace NRar1 {
+
+const UInt32 kNumRepDists = 4;
+
+typedef NBitm::CDecoder<CInBuffer> CBitDecoder;
+
+class CDecoder :
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+public:
+ CLzOutWindow m_OutWindowStream;
+ CBitDecoder m_InBitStream;
+
+ UInt32 m_RepDists[kNumRepDists];
+ UInt32 m_RepDistPtr;
+
+ UInt32 LastDist;
+ UInt32 LastLength;
+
+ Int64 m_UnpackSize;
+ bool m_IsSolid;
+
+ UInt32 ReadBits(int numBits);
+ HRESULT CopyBlock(UInt32 distance, UInt32 len);
+
+ UInt32 DecodeNum(const UInt32 *posTab);
+ HRESULT ShortLZ();
+ HRESULT LongLZ();
+ HRESULT HuffDecode();
+ void GetFlagsBuf();
+ void InitData();
+ void InitHuff();
+ void CorrHuff(UInt32 *CharSet, UInt32 *NumToPlace);
+ void OldUnpWriteBuf();
+
+ UInt32 ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
+ UInt32 Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
+ UInt32 NToPl[256],NToPlB[256],NToPlC[256];
+ UInt32 FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
+ int Buf60,NumHuf,StMode,LCount,FlagsCnt;
+ UInt32 Nhfb,Nlzb,MaxDist3;
+
+ void InitStructures();
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+public:
+ CDecoder();
+
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+
+ void ReleaseStreams()
+ {
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ }
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar2Decoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar2Decoder.cpp
new file mode 100644
index 000000000..16d6b30cb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar2Decoder.cpp
@@ -0,0 +1,389 @@
+// Rar2Decoder.cpp
+// According to unRAR license, this code may not be used to develop
+// a program that creates RAR archives
+
+#include "StdAfx.h"
+
+#include "Rar2Decoder.h"
+
+namespace NCompress {
+namespace NRar2 {
+
+namespace NMultimedia {
+
+Byte CFilter::Decode(int &channelDelta, Byte deltaByte)
+{
+ D4 = D3;
+ D3 = D2;
+ D2 = LastDelta - D1;
+ D1 = LastDelta;
+ int predictedValue = ((8 * LastChar + K1 * D1 + K2 * D2 + K3 * D3 + K4 * D4 + K5 * channelDelta) >> 3);
+
+ Byte realValue = (Byte)(predictedValue - deltaByte);
+ int i = ((int)(signed char)deltaByte) << 3;
+
+ Dif[0] += abs(i);
+ Dif[1] += abs(i - D1);
+ Dif[2] += abs(i + D1);
+ Dif[3] += abs(i - D2);
+ Dif[4] += abs(i + D2);
+ Dif[5] += abs(i - D3);
+ Dif[6] += abs(i + D3);
+ Dif[7] += abs(i - D4);
+ Dif[8] += abs(i + D4);
+ Dif[9] += abs(i - channelDelta);
+ Dif[10] += abs(i + channelDelta);
+
+ channelDelta = LastDelta = (signed char)(realValue - LastChar);
+ LastChar = realValue;
+
+ if (((++ByteCount) & 0x1F) == 0)
+ {
+ UInt32 minDif = Dif[0];
+ UInt32 numMinDif = 0;
+ Dif[0] = 0;
+ for (i = 1; i < sizeof(Dif) / sizeof(Dif[0]); i++)
+ {
+ if (Dif[i] < minDif)
+ {
+ minDif = Dif[i];
+ numMinDif = i;
+ }
+ Dif[i] = 0;
+ }
+ switch(numMinDif)
+ {
+ case 1: if (K1 >= -16) K1--; break;
+ case 2: if (K1 < 16) K1++; break;
+ case 3: if (K2 >= -16) K2--; break;
+ case 4: if (K2 < 16) K2++; break;
+ case 5: if (K3 >= -16) K3--; break;
+ case 6: if (K3 < 16) K3++; break;
+ case 7: if (K4 >= -16) K4--; break;
+ case 8: if (K4 < 16) K4++; break;
+ case 9: if (K5 >= -16) K5--; break;
+ case 10:if (K5 < 16) K5++; break;
+ }
+ }
+ return realValue;
+}
+}
+
+static const char *kNumberErrorMessage = "Number error";
+
+static const UInt32 kHistorySize = 1 << 20;
+
+static const int kNumStats = 11;
+
+static const UInt32 kWindowReservSize = (1 << 22) + 256;
+
+CDecoder::CDecoder():
+ m_IsSolid(false)
+{
+}
+
+void CDecoder::InitStructures()
+{
+ m_MmFilter.Init();
+ for(int i = 0; i < kNumRepDists; i++)
+ m_RepDists[i] = 0;
+ m_RepDistPtr = 0;
+ m_LastLength = 0;
+ memset(m_LastLevels, 0, kMaxTableSize);
+}
+
+UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+
+#define RIF(x) { if (!(x)) return false; }
+
+bool CDecoder::ReadTables(void)
+{
+ Byte levelLevels[kLevelTableSize];
+ Byte newLevels[kMaxTableSize];
+ m_AudioMode = (ReadBits(1) == 1);
+
+ if (ReadBits(1) == 0)
+ memset(m_LastLevels, 0, kMaxTableSize);
+ int numLevels;
+ if (m_AudioMode)
+ {
+ m_NumChannels = ReadBits(2) + 1;
+ if (m_MmFilter.CurrentChannel >= m_NumChannels)
+ m_MmFilter.CurrentChannel = 0;
+ numLevels = m_NumChannels * kMMTableSize;
+ }
+ else
+ numLevels = kHeapTablesSizesSum;
+
+ int i;
+ for (i = 0; i < kLevelTableSize; i++)
+ levelLevels[i] = (Byte)ReadBits(4);
+ RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
+ i = 0;
+ while (i < numLevels)
+ {
+ UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < kTableDirectLevels)
+ {
+ newLevels[i] = (Byte)((number + m_LastLevels[i]) & kLevelMask);
+ i++;
+ }
+ else
+ {
+ if (number == kTableLevelRepNumber)
+ {
+ int t = ReadBits(2) + 3;
+ for (int reps = t; reps > 0 && i < numLevels ; reps--, i++)
+ newLevels[i] = newLevels[i - 1];
+ }
+ else
+ {
+ int num;
+ if (number == kTableLevel0Number)
+ num = ReadBits(3) + 3;
+ else if (number == kTableLevel0Number2)
+ num = ReadBits(7) + 11;
+ else
+ return false;
+ for (;num > 0 && i < numLevels; num--)
+ newLevels[i++] = 0;
+ }
+ }
+ }
+ if (m_AudioMode)
+ for (i = 0; i < m_NumChannels; i++)
+ {
+ RIF(m_MMDecoders[i].SetCodeLengths(&newLevels[i * kMMTableSize]));
+ }
+ else
+ {
+ RIF(m_MainDecoder.SetCodeLengths(&newLevels[0]));
+ RIF(m_DistDecoder.SetCodeLengths(&newLevels[kMainTableSize]));
+ RIF(m_LenDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize]));
+ }
+ memcpy(m_LastLevels, newLevels, kMaxTableSize);
+ return true;
+}
+
+bool CDecoder::ReadLastTables()
+{
+ // it differs a little from pure RAR sources;
+ // UInt64 ttt = m_InBitStream.GetProcessedSize() + 2;
+ // + 2 works for: return 0xFF; in CInBuffer::ReadByte.
+ if (m_InBitStream.GetProcessedSize() + 7 <= m_PackSize) // test it: probably incorrect;
+ // if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
+ if (m_AudioMode)
+ {
+ UInt32 symbol = m_MMDecoders[m_MmFilter.CurrentChannel].DecodeSymbol(&m_InBitStream);
+ if (symbol == 256)
+ return ReadTables();
+ if (symbol >= kMMTableSize)
+ return false;
+ }
+ else
+ {
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ if (number == kReadTableNumber)
+ return ReadTables();
+ if (number >= kMainTableSize)
+ return false;
+ }
+ return true;
+}
+
+class CCoderReleaser
+{
+ CDecoder *m_Coder;
+public:
+ CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
+ ~CCoderReleaser()
+ {
+ m_Coder->ReleaseStreams();
+ }
+};
+
+bool CDecoder::DecodeMm(UInt32 pos)
+{
+ while (pos-- > 0)
+ {
+ UInt32 symbol = m_MMDecoders[m_MmFilter.CurrentChannel].DecodeSymbol(&m_InBitStream);
+ if (symbol == 256)
+ return true;
+ if (symbol >= kMMTableSize)
+ return false;
+ /*
+ Byte byPredict = m_Predictor.Predict();
+ Byte byReal = (Byte)(byPredict - (Byte)symbol);
+ m_Predictor.Update(byReal, byPredict);
+ */
+ Byte byReal = m_MmFilter.Decode((Byte)symbol);
+ m_OutWindowStream.PutByte(byReal);
+ if (++m_MmFilter.CurrentChannel == m_NumChannels)
+ m_MmFilter.CurrentChannel = 0;
+ }
+ return true;
+}
+
+bool CDecoder::DecodeLz(Int32 pos)
+{
+ while (pos > 0)
+ {
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ UInt32 length, distance;
+ if (number < 256)
+ {
+ m_OutWindowStream.PutByte(Byte(number));
+ pos--;
+ continue;
+ }
+ else if (number >= kMatchNumber)
+ {
+ number -= kMatchNumber;
+ length = kNormalMatchMinLen + UInt32(kLenStart[number]) +
+ m_InBitStream.ReadBits(kLenDirectBits[number]);
+ number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
+ if (number >= kDistTableSize)
+ return false;
+ distance = kDistStart[number] + m_InBitStream.ReadBits(kDistDirectBits[number]);
+ if (distance >= kDistLimit3)
+ {
+ length += 2 - ((distance - kDistLimit4) >> 31);
+ // length++;
+ // if (distance >= kDistLimit4)
+ // length++;
+ }
+ }
+ else if (number == kRepBothNumber)
+ {
+ length = m_LastLength;
+ distance = m_RepDists[(m_RepDistPtr + 4 - 1) & 3];
+ }
+ else if (number < kLen2Number)
+ {
+ distance = m_RepDists[(m_RepDistPtr - (number - kRepNumber + 1)) & 3];
+ number = m_LenDecoder.DecodeSymbol(&m_InBitStream);
+ if (number >= kLenTableSize)
+ return false;
+ length = 2 + kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
+ if (distance >= kDistLimit2)
+ {
+ length++;
+ if (distance >= kDistLimit3)
+ {
+ length += 2 - ((distance - kDistLimit4) >> 31);
+ // length++;
+ // if (distance >= kDistLimit4)
+ // length++;
+ }
+ }
+ }
+ else if (number < kReadTableNumber)
+ {
+ number -= kLen2Number;
+ distance = kLen2DistStarts[number] +
+ m_InBitStream.ReadBits(kLen2DistDirectBits[number]);
+ length = 2;
+ }
+ else if (number == kReadTableNumber)
+ return true;
+ else
+ return false;
+ m_RepDists[m_RepDistPtr++ & 3] = distance;
+ m_LastLength = length;
+ if (!m_OutWindowStream.CopyBlock(distance, length))
+ return false;
+ pos -= length;
+ }
+ return true;
+}
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ if (inSize == NULL || outSize == NULL)
+ return E_INVALIDARG;
+
+ if (!m_OutWindowStream.Create(kHistorySize))
+ return E_OUTOFMEMORY;
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ m_PackSize = *inSize;
+
+ UInt64 pos = 0, unPackSize = *outSize;
+
+ m_OutWindowStream.SetStream(outStream);
+ m_OutWindowStream.Init(m_IsSolid);
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+
+ CCoderReleaser coderReleaser(this);
+ if (!m_IsSolid)
+ {
+ InitStructures();
+ if (unPackSize == 0)
+ {
+ if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
+ if (!ReadTables())
+ return S_FALSE;
+ return S_OK;
+ }
+ if (!ReadTables())
+ return S_FALSE;
+ }
+
+ UInt64 startPos = m_OutWindowStream.GetProcessedSize();
+ while(pos < unPackSize)
+ {
+ UInt32 blockSize = 1 << 20;
+ if (blockSize > unPackSize - pos)
+ blockSize = (UInt32)(unPackSize - pos);
+ UInt64 blockStartPos = m_OutWindowStream.GetProcessedSize();
+ if (m_AudioMode)
+ {
+ if (!DecodeMm(blockSize))
+ return S_FALSE;
+ }
+ else
+ {
+ if (!DecodeLz((Int32)blockSize))
+ return S_FALSE;
+ }
+ UInt64 globalPos = m_OutWindowStream.GetProcessedSize();
+ pos = globalPos - blockStartPos;
+ if (pos < blockSize)
+ if (!ReadTables())
+ return S_FALSE;
+ pos = globalPos - startPos;
+ if (progress != 0)
+ {
+ UInt64 packSize = m_InBitStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &pos));
+ }
+ }
+ if (pos > unPackSize)
+ return S_FALSE;
+
+ if (!ReadLastTables())
+ return S_FALSE;
+ return m_OutWindowStream.Flush();
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size < 1)
+ return E_INVALIDARG;
+ m_IsSolid = (data[0] != 0);
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar2Decoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar2Decoder.h
new file mode 100644
index 000000000..61a8b4dab
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar2Decoder.h
@@ -0,0 +1,174 @@
+// Rar2Decoder.h
+// According to unRAR license, this code may not be used to develop
+// a program that creates RAR archives
+
+#ifndef __COMPRESS_RAR2_DECODER_H
+#define __COMPRESS_RAR2_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "BitmDecoder.h"
+#include "HuffmanDecoder.h"
+#include "LzOutWindow.h"
+
+namespace NCompress {
+namespace NRar2 {
+
+const UInt32 kNumRepDists = 4;
+const UInt32 kDistTableSize = 48;
+
+const int kMMTableSize = 256 + 1;
+
+const UInt32 kMainTableSize = 298;
+const UInt32 kLenTableSize = 28;
+
+const UInt32 kDistTableStart = kMainTableSize;
+const UInt32 kLenTableStart = kDistTableStart + kDistTableSize;
+
+const UInt32 kHeapTablesSizesSum = kMainTableSize + kDistTableSize + kLenTableSize;
+
+const UInt32 kLevelTableSize = 19;
+
+const UInt32 kMMTablesSizesSum = kMMTableSize * 4;
+
+const UInt32 kMaxTableSize = kMMTablesSizesSum;
+
+const UInt32 kTableDirectLevels = 16;
+const UInt32 kTableLevelRepNumber = kTableDirectLevels;
+const UInt32 kTableLevel0Number = kTableLevelRepNumber + 1;
+const UInt32 kTableLevel0Number2 = kTableLevel0Number + 1;
+
+const UInt32 kLevelMask = 0xF;
+
+
+const UInt32 kRepBothNumber = 256;
+const UInt32 kRepNumber = kRepBothNumber + 1;
+const UInt32 kLen2Number = kRepNumber + 4;
+
+const UInt32 kLen2NumNumbers = 8;
+const UInt32 kReadTableNumber = kLen2Number + kLen2NumNumbers;
+const UInt32 kMatchNumber = kReadTableNumber + 1;
+
+const Byte kLenStart[kLenTableSize] = {0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224};
+const Byte kLenDirectBits[kLenTableSize] = {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};
+
+const UInt32 kDistStart[kDistTableSize] = {0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576,32768U,49152U,65536,98304,131072,196608,262144,327680,393216,458752,524288,589824,655360,720896,786432,851968,917504,983040};
+const Byte kDistDirectBits[kDistTableSize] = {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, 14, 14, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
+
+const Byte kLevelDirectBits[kLevelTableSize] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7};
+
+const Byte kLen2DistStarts[kLen2NumNumbers]={0,4,8,16,32,64,128,192};
+const Byte kLen2DistDirectBits[kLen2NumNumbers]={2,2,3, 4, 5, 6, 6, 6};
+
+const UInt32 kDistLimit2 = 0x101 - 1;
+const UInt32 kDistLimit3 = 0x2000 - 1;
+const UInt32 kDistLimit4 = 0x40000 - 1;
+
+const UInt32 kMatchMaxLen = 255 + 2;
+const UInt32 kMatchMaxLenMax = 255 + 5;
+const UInt32 kNormalMatchMinLen = 3;
+
+namespace NMultimedia {
+
+struct CFilter
+{
+ int K1,K2,K3,K4,K5;
+ int D1,D2,D3,D4;
+ int LastDelta;
+ UInt32 Dif[11];
+ UInt32 ByteCount;
+ int LastChar;
+
+ Byte Decode(int &channelDelta, Byte delta);
+
+ void Init() { memset(this, 0, sizeof(*this)); }
+
+};
+
+const int kNumChanelsMax = 4;
+
+class CFilter2
+{
+public:
+ CFilter m_Filters[kNumChanelsMax];
+ int m_ChannelDelta;
+ int CurrentChannel;
+
+ void Init() { memset(this, 0, sizeof(*this)); }
+ Byte Decode(Byte delta)
+ {
+ return m_Filters[CurrentChannel].Decode(m_ChannelDelta, delta);
+ }
+
+};
+
+}
+
+typedef NBitm::CDecoder<CInBuffer> CBitDecoder;
+
+const int kNumHuffmanBits = 15;
+
+class CDecoder :
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+ CLzOutWindow m_OutWindowStream;
+ CBitDecoder m_InBitStream;
+ NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kDistTableSize> m_DistDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kLenTableSize> m_LenDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kMMTableSize> m_MMDecoders[NMultimedia::kNumChanelsMax];
+ NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
+
+ bool m_AudioMode;
+
+ NMultimedia::CFilter2 m_MmFilter;
+ int m_NumChannels;
+
+ UInt32 m_RepDists[kNumRepDists];
+ UInt32 m_RepDistPtr;
+
+ UInt32 m_LastLength;
+
+ Byte m_LastLevels[kMaxTableSize];
+
+ UInt64 m_PackSize;
+ bool m_IsSolid;
+
+ void InitStructures();
+ UInt32 ReadBits(int numBits);
+ bool ReadTables();
+ bool ReadLastTables();
+
+ bool DecodeMm(UInt32 pos);
+ bool DecodeLz(Int32 pos);
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+public:
+ CDecoder();
+
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+
+ void ReleaseStreams()
+ {
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ }
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Decoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Decoder.cpp
new file mode 100644
index 000000000..b7345eb07
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Decoder.cpp
@@ -0,0 +1,834 @@
+// Rar3Decoder.cpp
+// According to unRAR license, this code may not be used to develop
+// a program that creates RAR archives
+
+#include "StdAfx.h"
+
+#include "../Common/StreamUtils.h"
+
+#include "Rar3Decoder.h"
+
+namespace NCompress {
+namespace NRar3 {
+
+static const UInt32 kNumAlignReps = 15;
+
+static const UInt32 kSymbolReadTable = 256;
+static const UInt32 kSymbolRep = 259;
+static const UInt32 kSymbolLen2 = kSymbolRep + kNumReps;
+
+static const Byte kLenStart[kLenTableSize] = {0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224};
+static const Byte kLenDirectBits[kLenTableSize] = {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};
+
+static const Byte kDistDirectBits[kDistTableSize] =
+ {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,14,14,15,15,
+ 16,16,16,16,16,16,16,16,16,16,16,16,16,16,
+ 18,18,18,18,18,18,18,18,18,18,18,18};
+
+static const Byte kLevelDirectBits[kLevelTableSize] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
+
+static const Byte kLen2DistStarts[kNumLen2Symbols]={0,4,8,16,32,64,128,192};
+static const Byte kLen2DistDirectBits[kNumLen2Symbols]={2,2,3, 4, 5, 6, 6, 6};
+
+static const UInt32 kDistLimit3 = 0x2000 - 2;
+static const UInt32 kDistLimit4 = 0x40000 - 2;
+
+static const UInt32 kNormalMatchMinLen = 3;
+
+static const UInt32 kVmDataSizeMax = 1 << 16;
+static const UInt32 kVmCodeSizeMax = 1 << 16;
+
+CDecoder::CDecoder():
+ _window(0),
+ _winPos(0),
+ _wrPtr(0),
+ _lzSize(0),
+ _writtenFileSize(0),
+ _vmData(0),
+ _vmCode(0),
+ m_IsSolid(false)
+{
+}
+
+CDecoder::~CDecoder()
+{
+ InitFilters();
+ ::MidFree(_vmData);
+ ::MidFree(_window);
+}
+
+HRESULT CDecoder::WriteDataToStream(const Byte *data, UInt32 size)
+{
+ return WriteStream(_outStream, data, size);
+}
+
+HRESULT CDecoder::WriteData(const Byte *data, UInt32 size)
+{
+ HRESULT res = S_OK;
+ if (_writtenFileSize < _unpackSize)
+ {
+ UInt32 curSize = size;
+ UInt64 remain = _unpackSize - _writtenFileSize;
+ if (remain < curSize)
+ curSize = (UInt32)remain;
+ res = WriteDataToStream(data, curSize);
+ }
+ _writtenFileSize += size;
+ return res;
+}
+
+HRESULT CDecoder::WriteArea(UInt32 startPtr, UInt32 endPtr)
+{
+ if (startPtr <= endPtr)
+ return WriteData(_window + startPtr, endPtr - startPtr);
+ RINOK(WriteData(_window + startPtr, kWindowSize - startPtr));
+ return WriteData(_window, endPtr);
+}
+
+void CDecoder::ExecuteFilter(int tempFilterIndex, NVm::CBlockRef &outBlockRef)
+{
+ CTempFilter *tempFilter = _tempFilters[tempFilterIndex];
+ tempFilter->InitR[6] = (UInt32)_writtenFileSize;
+ NVm::SetValue32(&tempFilter->GlobalData[0x24], (UInt32)_writtenFileSize);
+ NVm::SetValue32(&tempFilter->GlobalData[0x28], (UInt32)(_writtenFileSize >> 32));
+ CFilter *filter = _filters[tempFilter->FilterIndex];
+ _vm.Execute(filter, tempFilter, outBlockRef, filter->GlobalData);
+ delete tempFilter;
+ _tempFilters[tempFilterIndex] = 0;
+}
+
+HRESULT CDecoder::WriteBuf()
+{
+ UInt32 writtenBorder = _wrPtr;
+ UInt32 writeSize = (_winPos - writtenBorder) & kWindowMask;
+ for (int i = 0; i < _tempFilters.Size(); i++)
+ {
+ CTempFilter *filter = _tempFilters[i];
+ if (filter == NULL)
+ continue;
+ if (filter->NextWindow)
+ {
+ filter->NextWindow = false;
+ continue;
+ }
+ UInt32 blockStart = filter->BlockStart;
+ UInt32 blockSize = filter->BlockSize;
+ if (((blockStart - writtenBorder) & kWindowMask) < writeSize)
+ {
+ if (writtenBorder != blockStart)
+ {
+ RINOK(WriteArea(writtenBorder, blockStart));
+ writtenBorder = blockStart;
+ writeSize = (_winPos - writtenBorder) & kWindowMask;
+ }
+ if (blockSize <= writeSize)
+ {
+ UInt32 blockEnd = (blockStart + blockSize) & kWindowMask;
+ if (blockStart < blockEnd || blockEnd == 0)
+ _vm.SetMemory(0, _window + blockStart, blockSize);
+ else
+ {
+ UInt32 tailSize = kWindowSize - blockStart;
+ _vm.SetMemory(0, _window + blockStart, tailSize);
+ _vm.SetMemory(tailSize, _window, blockEnd);
+ }
+ NVm::CBlockRef outBlockRef;
+ ExecuteFilter(i, outBlockRef);
+ while (i + 1 < _tempFilters.Size())
+ {
+ CTempFilter *nextFilter = _tempFilters[i + 1];
+ if (nextFilter == NULL || nextFilter->BlockStart != blockStart ||
+ nextFilter->BlockSize != outBlockRef.Size || nextFilter->NextWindow)
+ break;
+ _vm.SetMemory(0, _vm.GetDataPointer(outBlockRef.Offset), outBlockRef.Size);
+ ExecuteFilter(++i, outBlockRef);
+ }
+ WriteDataToStream(_vm.GetDataPointer(outBlockRef.Offset), outBlockRef.Size);
+ _writtenFileSize += outBlockRef.Size;
+ writtenBorder = blockEnd;
+ writeSize = (_winPos - writtenBorder) & kWindowMask;
+ }
+ else
+ {
+ for (int j = i; j < _tempFilters.Size(); j++)
+ {
+ CTempFilter *filter = _tempFilters[j];
+ if (filter != NULL && filter->NextWindow)
+ filter->NextWindow = false;
+ }
+ _wrPtr = writtenBorder;
+ return S_OK; // check it
+ }
+ }
+ }
+
+ _wrPtr = _winPos;
+ return WriteArea(writtenBorder, _winPos);
+}
+
+void CDecoder::InitFilters()
+{
+ _lastFilter = 0;
+ int i;
+ for (i = 0; i < _tempFilters.Size(); i++)
+ delete _tempFilters[i];
+ _tempFilters.Clear();
+ for (i = 0; i < _filters.Size(); i++)
+ delete _filters[i];
+ _filters.Clear();
+}
+
+bool CDecoder::AddVmCode(UInt32 firstByte, UInt32 codeSize)
+{
+ CMemBitDecoder inp;
+ inp.Init(_vmData, codeSize);
+
+ UInt32 filterIndex;
+ if (firstByte & 0x80)
+ {
+ filterIndex = NVm::ReadEncodedUInt32(inp);
+ if (filterIndex == 0)
+ InitFilters();
+ else
+ filterIndex--;
+ }
+ else
+ filterIndex = _lastFilter;
+ if (filterIndex > (UInt32)_filters.Size())
+ return false;
+ _lastFilter = filterIndex;
+ bool newFilter = (filterIndex == (UInt32)_filters.Size());
+
+ CFilter *filter;
+ if (newFilter)
+ {
+ // check if too many filters
+ if (filterIndex > 1024)
+ return false;
+ filter = new CFilter;
+ _filters.Add(filter);
+ }
+ else
+ {
+ filter = _filters[filterIndex];
+ filter->ExecCount++;
+ }
+
+ int numEmptyItems = 0;
+ int i;
+ for (i = 0; i < _tempFilters.Size(); i++)
+ {
+ _tempFilters[i - numEmptyItems] = _tempFilters[i];
+ if (_tempFilters[i] == NULL)
+ numEmptyItems++;
+ if (numEmptyItems > 0)
+ _tempFilters[i] = NULL;
+ }
+ if (numEmptyItems == 0)
+ {
+ _tempFilters.Add(NULL);
+ numEmptyItems = 1;
+ }
+ CTempFilter *tempFilter = new CTempFilter;
+ _tempFilters[_tempFilters.Size() - numEmptyItems] = tempFilter;
+ tempFilter->FilterIndex = filterIndex;
+ tempFilter->ExecCount = filter->ExecCount;
+
+ UInt32 blockStart = NVm::ReadEncodedUInt32(inp);
+ if (firstByte & 0x40)
+ blockStart += 258;
+ tempFilter->BlockStart = (blockStart + _winPos) & kWindowMask;
+ if (firstByte & 0x20)
+ filter->BlockSize = NVm::ReadEncodedUInt32(inp);
+ tempFilter->BlockSize = filter->BlockSize;
+ tempFilter->NextWindow = _wrPtr != _winPos && ((_wrPtr - _winPos) & kWindowMask) <= blockStart;
+
+ memset(tempFilter->InitR, 0, sizeof(tempFilter->InitR));
+ tempFilter->InitR[3] = NVm::kGlobalOffset;
+ tempFilter->InitR[4] = tempFilter->BlockSize;
+ tempFilter->InitR[5] = tempFilter->ExecCount;
+ if (firstByte & 0x10)
+ {
+ UInt32 initMask = inp.ReadBits(NVm::kNumGpRegs);
+ for (int i = 0; i < NVm::kNumGpRegs; i++)
+ if (initMask & (1 << i))
+ tempFilter->InitR[i] = NVm::ReadEncodedUInt32(inp);
+ }
+ if (newFilter)
+ {
+ UInt32 vmCodeSize = NVm::ReadEncodedUInt32(inp);
+ if (vmCodeSize >= kVmCodeSizeMax || vmCodeSize == 0)
+ return false;
+ for (UInt32 i = 0; i < vmCodeSize; i++)
+ _vmCode[i] = (Byte)inp.ReadBits(8);
+ _vm.PrepareProgram(_vmCode, vmCodeSize, filter);
+ }
+
+ tempFilter->AllocateEmptyFixedGlobal();
+
+ Byte *globalData = &tempFilter->GlobalData[0];
+ for (i = 0; i < NVm::kNumGpRegs; i++)
+ NVm::SetValue32(&globalData[i * 4], tempFilter->InitR[i]);
+ NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockSize], tempFilter->BlockSize);
+ NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockPos], 0); // It was commented. why?
+ NVm::SetValue32(&globalData[NVm::NGlobalOffset::kExecCount], tempFilter->ExecCount);
+
+ if (firstByte & 8)
+ {
+ UInt32 dataSize = NVm::ReadEncodedUInt32(inp);
+ if (dataSize > NVm::kGlobalSize - NVm::kFixedGlobalSize)
+ return false;
+ CRecordVector<Byte> &globalData = tempFilter->GlobalData;
+ int requredSize = (int)(dataSize + NVm::kFixedGlobalSize);
+ if (globalData.Size() < requredSize)
+ {
+ globalData.Reserve(requredSize);
+ for (; globalData.Size() < requredSize; i++)
+ globalData.Add(0);
+ }
+ for (UInt32 i = 0; i < dataSize; i++)
+ globalData[NVm::kFixedGlobalSize + i] = (Byte)inp.ReadBits(8);
+ }
+ return true;
+}
+
+bool CDecoder::ReadVmCodeLZ()
+{
+ UInt32 firstByte = m_InBitStream.ReadBits(8);
+ UInt32 length = (firstByte & 7) + 1;
+ if (length == 7)
+ length = m_InBitStream.ReadBits(8) + 7;
+ else if (length == 8)
+ length = m_InBitStream.ReadBits(16);
+ if (length > kVmDataSizeMax)
+ return false;
+ for (UInt32 i = 0; i < length; i++)
+ _vmData[i] = (Byte)m_InBitStream.ReadBits(8);
+ return AddVmCode(firstByte, length);
+}
+
+bool CDecoder::ReadVmCodePPM()
+{
+ int firstByte = DecodePpmSymbol();
+ if (firstByte == -1)
+ return false;
+ UInt32 length = (firstByte & 7) + 1;
+ if (length == 7)
+ {
+ int b1 = DecodePpmSymbol();
+ if (b1 == -1)
+ return false;
+ length = b1 + 7;
+ }
+ else if (length == 8)
+ {
+ int b1 = DecodePpmSymbol();
+ if (b1 == -1)
+ return false;
+ int b2 = DecodePpmSymbol();
+ if (b2 == -1)
+ return false;
+ length = b1 * 256 + b2;
+ }
+ if (length > kVmDataSizeMax)
+ return false;
+ for (UInt32 i = 0; i < length; i++)
+ {
+ int b = DecodePpmSymbol();
+ if (b == -1)
+ return false;
+ _vmData[i] = (Byte)b;
+ }
+ return AddVmCode(firstByte, length);
+}
+
+#define RIF(x) { if (!(x)) return S_FALSE; }
+
+UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+
+/////////////////////////////////////////////////
+// PPM
+
+HRESULT CDecoder::InitPPM()
+{
+ Byte maxOrder = (Byte)ReadBits(7);
+
+ bool reset = ((maxOrder & 0x20) != 0);
+ int maxMB = 0;
+ if (reset)
+ maxMB = (Byte)ReadBits(8);
+ else
+ {
+ if (_ppm.SubAllocator.GetSubAllocatorSize()== 0)
+ return S_FALSE;
+ }
+ if (maxOrder & 0x40)
+ PpmEscChar = (Byte)ReadBits(8);
+ m_InBitStream.InitRangeCoder();
+ /*
+ if (m_InBitStream.m_BitPos != 0)
+ return S_FALSE;
+ */
+ if (reset)
+ {
+ maxOrder = (maxOrder & 0x1F) + 1;
+ if (maxOrder > 16)
+ maxOrder = 16 + (maxOrder - 16) * 3;
+ if (maxOrder == 1)
+ {
+ // SubAlloc.StopSubAllocator();
+ _ppm.SubAllocator.StopSubAllocator();
+ return S_FALSE;
+ }
+ // SubAlloc.StartSubAllocator(MaxMB+1);
+ // StartModelRare(maxOrder);
+
+ if (!_ppm.SubAllocator.StartSubAllocator((maxMB + 1) << 20))
+ return E_OUTOFMEMORY;
+ _ppm.MaxOrder = 0;
+ _ppm.StartModelRare(maxOrder);
+
+ }
+ // return (minContext != NULL);
+
+ return S_OK;
+}
+
+int CDecoder::DecodePpmSymbol() { return _ppm.DecodeSymbol(&m_InBitStream); }
+
+HRESULT CDecoder::DecodePPM(Int32 num, bool &keepDecompressing)
+{
+ keepDecompressing = false;
+ do
+ {
+ if (((_wrPtr - _winPos) & kWindowMask) < 260 && _wrPtr != _winPos)
+ {
+ RINOK(WriteBuf());
+ if (_writtenFileSize > _unpackSize)
+ {
+ keepDecompressing = false;
+ return S_OK;
+ }
+ }
+ int c = DecodePpmSymbol();
+ if (c == -1)
+ {
+ // Original code sets PPMError=true here and then it returns S_OK. Why ???
+ // return S_OK;
+ return S_FALSE;
+ }
+ if (c == PpmEscChar)
+ {
+ int nextCh = DecodePpmSymbol();
+ if (nextCh == 0)
+ return ReadTables(keepDecompressing);
+ if (nextCh == 2 || nextCh == -1)
+ return S_OK;
+ if (nextCh == 3)
+ {
+ if (!ReadVmCodePPM())
+ return S_FALSE;
+ continue;
+ }
+ if (nextCh == 4 || nextCh == 5)
+ {
+ UInt32 distance = 0;
+ UInt32 length = 4;
+ if (nextCh == 4)
+ {
+ for (int i = 0; i < 3; i++)
+ {
+ int c = DecodePpmSymbol();
+ if (c == -1)
+ return S_OK;
+ distance = (distance << 8) + (Byte)c;
+ }
+ distance++;
+ length += 28;
+ }
+ int c = DecodePpmSymbol();
+ if (c == -1)
+ return S_OK;
+ length += c;
+ if (distance >= _lzSize)
+ return S_FALSE;
+ CopyBlock(distance, length);
+ num -= (Int32)length;
+ continue;
+ }
+ }
+ PutByte((Byte)c);
+ num--;
+ }
+ while (num >= 0);
+ keepDecompressing = true;
+ return S_OK;
+}
+
+/////////////////////////////////////////////////
+// LZ
+
+HRESULT CDecoder::ReadTables(bool &keepDecompressing)
+{
+ keepDecompressing = true;
+ ReadBits((8 - m_InBitStream.GetBitPosition()) & 7);
+ if (ReadBits(1) != 0)
+ {
+ _lzMode = false;
+ return InitPPM();
+ }
+
+ _lzMode = true;
+ PrevAlignBits = 0;
+ PrevAlignCount = 0;
+
+ Byte levelLevels[kLevelTableSize];
+ Byte newLevels[kTablesSizesSum];
+
+ if (ReadBits(1) == 0)
+ memset(m_LastLevels, 0, kTablesSizesSum);
+
+ int i;
+ for (i = 0; i < kLevelTableSize; i++)
+ {
+ UInt32 length = ReadBits(4);
+ if (length == 15)
+ {
+ UInt32 zeroCount = ReadBits(4);
+ if (zeroCount != 0)
+ {
+ zeroCount += 2;
+ while (zeroCount-- > 0 && i < kLevelTableSize)
+ levelLevels[i++]=0;
+ i--;
+ continue;
+ }
+ }
+ levelLevels[i] = (Byte)length;
+ }
+ RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
+ i = 0;
+ while (i < kTablesSizesSum)
+ {
+ UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < 16)
+ {
+ newLevels[i] = Byte((number + m_LastLevels[i]) & 15);
+ i++;
+ }
+ else if (number > kLevelTableSize)
+ return S_FALSE;
+ else
+ {
+ int num;
+ if (((number - 16) & 1) == 0)
+ num = ReadBits(3) + 3;
+ else
+ num = ReadBits(7) + 11;
+ if (number < 18)
+ {
+ if (i == 0)
+ return S_FALSE;
+ for (; num > 0 && i < kTablesSizesSum; num--, i++)
+ newLevels[i] = newLevels[i - 1];
+ }
+ else
+ {
+ for (; num > 0 && i < kTablesSizesSum; num--)
+ newLevels[i++] = 0;
+ }
+ }
+ }
+ TablesRead = true;
+
+ // original code has check here:
+ /*
+ if (InAddr > ReadTop)
+ {
+ keepDecompressing = false;
+ return true;
+ }
+ */
+
+ RIF(m_MainDecoder.SetCodeLengths(&newLevels[0]));
+ RIF(m_DistDecoder.SetCodeLengths(&newLevels[kMainTableSize]));
+ RIF(m_AlignDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize]));
+ RIF(m_LenDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize + kAlignTableSize]));
+
+ memcpy(m_LastLevels, newLevels, kTablesSizesSum);
+ return S_OK;
+}
+
+class CCoderReleaser
+{
+ CDecoder *m_Coder;
+public:
+ CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
+ ~CCoderReleaser()
+ {
+ // m_Coder->m_OutWindowStream.Flush();
+ m_Coder->ReleaseStreams();
+ }
+};
+
+HRESULT CDecoder::ReadEndOfBlock(bool &keepDecompressing)
+{
+ if (ReadBits(1) != 0)
+ {
+ // old file
+ TablesRead = false;
+ return ReadTables(keepDecompressing);
+ }
+ // new file
+ keepDecompressing = false;
+ TablesRead = (ReadBits(1) == 0);
+ return S_OK;
+}
+
+UInt32 kDistStart[kDistTableSize];
+
+class CDistInit
+{
+public:
+ CDistInit() { Init(); }
+ void Init()
+ {
+ UInt32 start = 0;
+ for (UInt32 i = 0; i < kDistTableSize; i++)
+ {
+ kDistStart[i] = start;
+ start += (1 << kDistDirectBits[i]);
+ }
+ }
+} g_DistInit;
+
+HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
+{
+ UInt32 rep0 = _reps[0];
+ UInt32 rep1 = _reps[1];
+ UInt32 rep2 = _reps[2];
+ UInt32 rep3 = _reps[3];
+ UInt32 length = _lastLength;
+ for (;;)
+ {
+ if (((_wrPtr - _winPos) & kWindowMask) < 260 && _wrPtr != _winPos)
+ {
+ RINOK(WriteBuf());
+ if (_writtenFileSize > _unpackSize)
+ {
+ keepDecompressing = false;
+ return S_OK;
+ }
+ }
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < 256)
+ {
+ PutByte(Byte(number));
+
+ continue;
+ }
+ else if (number == kSymbolReadTable)
+ {
+ RINOK(ReadEndOfBlock(keepDecompressing));
+ break;
+ }
+ else if (number == 257)
+ {
+ if (!ReadVmCodeLZ())
+ return S_FALSE;
+ continue;
+ }
+ else if (number == 258)
+ {
+ }
+ else if (number < kSymbolRep + 4)
+ {
+ if (number != kSymbolRep)
+ {
+ UInt32 distance;
+ if (number == kSymbolRep + 1)
+ distance = rep1;
+ else
+ {
+ if (number == kSymbolRep + 2)
+ distance = rep2;
+ else
+ {
+ distance = rep3;
+ rep3 = rep2;
+ }
+ rep2 = rep1;
+ }
+ rep1 = rep0;
+ rep0 = distance;
+ }
+
+ UInt32 number = m_LenDecoder.DecodeSymbol(&m_InBitStream);
+ if (number >= kLenTableSize)
+ return S_FALSE;
+ length = 2 + kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
+ }
+ else
+ {
+ rep3 = rep2;
+ rep2 = rep1;
+ rep1 = rep0;
+ if (number < 271)
+ {
+ number -= 263;
+ rep0 = kLen2DistStarts[number] + m_InBitStream.ReadBits(kLen2DistDirectBits[number]);
+ length = 2;
+ }
+ else if (number < 299)
+ {
+ number -= 271;
+ length = kNormalMatchMinLen + (UInt32)kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
+ UInt32 number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
+ if (number >= kDistTableSize)
+ return S_FALSE;
+ rep0 = kDistStart[number];
+ int numBits = kDistDirectBits[number];
+ if (number >= (kNumAlignBits * 2) + 2)
+ {
+ if (numBits > kNumAlignBits)
+ rep0 += (m_InBitStream.ReadBits(numBits - kNumAlignBits) << kNumAlignBits);
+ if (PrevAlignCount > 0)
+ {
+ PrevAlignCount--;
+ rep0 += PrevAlignBits;
+ }
+ else
+ {
+ UInt32 number = m_AlignDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < (1 << kNumAlignBits))
+ {
+ rep0 += number;
+ PrevAlignBits = number;
+ }
+ else if (number == (1 << kNumAlignBits))
+ {
+ PrevAlignCount = kNumAlignReps;
+ rep0 += PrevAlignBits;
+ }
+ else
+ return S_FALSE;
+ }
+ }
+ else
+ rep0 += m_InBitStream.ReadBits(numBits);
+ length += ((kDistLimit4 - rep0) >> 31) + ((kDistLimit3 - rep0) >> 31);
+ }
+ else
+ return S_FALSE;
+ }
+ if (rep0 >= _lzSize)
+ return S_FALSE;
+ CopyBlock(rep0, length);
+ }
+ _reps[0] = rep0;
+ _reps[1] = rep1;
+ _reps[2] = rep2;
+ _reps[3] = rep3;
+ _lastLength = length;
+
+ return S_OK;
+}
+
+HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress)
+{
+ _writtenFileSize = 0;
+ if (!m_IsSolid)
+ {
+ _lzSize = 0;
+ _winPos = 0;
+ _wrPtr = 0;
+ for (int i = 0; i < kNumReps; i++)
+ _reps[i] = 0;
+ _lastLength = 0;
+ memset(m_LastLevels, 0, kTablesSizesSum);
+ TablesRead = false;
+ PpmEscChar = 2;
+ InitFilters();
+ }
+ if (!m_IsSolid || !TablesRead)
+ {
+ bool keepDecompressing;
+ RINOK(ReadTables(keepDecompressing));
+ if (!keepDecompressing)
+ return S_OK;
+ }
+
+ for(;;)
+ {
+ bool keepDecompressing;
+ if (_lzMode)
+ {
+ RINOK(DecodeLZ(keepDecompressing))
+ }
+ else
+ {
+ RINOK(DecodePPM(1 << 18, keepDecompressing))
+ }
+ UInt64 packSize = m_InBitStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &_writtenFileSize));
+ if (!keepDecompressing)
+ break;
+ }
+ RINOK(WriteBuf());
+ if (_writtenFileSize < _unpackSize)
+ return S_FALSE;
+ // return m_OutWindowStream.Flush();
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try
+ {
+ if (inSize == NULL || outSize == NULL)
+ return E_INVALIDARG;
+
+ if (_vmData == 0)
+ {
+ _vmData = (Byte *)::MidAlloc(kVmDataSizeMax + kVmCodeSizeMax);
+ if (_vmData == 0)
+ return E_OUTOFMEMORY;
+ _vmCode = _vmData + kVmDataSizeMax;
+ }
+
+ if (_window == 0)
+ {
+ _window = (Byte *)::MidAlloc(kWindowSize);
+ if (_window == 0)
+ return E_OUTOFMEMORY;
+ }
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ if (!_vm.Create())
+ return E_OUTOFMEMORY;
+
+
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+ _outStream = outStream;
+
+ CCoderReleaser coderReleaser(this);
+ _unpackSize = *outSize;
+ return CodeReal(progress);
+ }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+ // CNewException is possible here. But probably CNewException is caused
+ // by error in data stream.
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size < 1)
+ return E_INVALIDARG;
+ m_IsSolid = (data[0] != 0);
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Decoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Decoder.h
new file mode 100644
index 000000000..73d4c224d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Decoder.h
@@ -0,0 +1,301 @@
+// Rar3Decoder.h
+// According to unRAR license, this code may not be used to develop
+// a program that creates RAR archives
+
+#ifndef __COMPRESS_RAR3_DECODER_H
+#define __COMPRESS_RAR3_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+#include "../Common/InBuffer.h"
+
+#include "BitmDecoder.h"
+#include "HuffmanDecoder.h"
+#include "PpmdDecode.h"
+#include "Rar3Vm.h"
+
+namespace NCompress {
+namespace NRar3 {
+
+const UInt32 kWindowSize = 1 << 22;
+const UInt32 kWindowMask = (kWindowSize - 1);
+
+const UInt32 kNumReps = 4;
+const UInt32 kNumLen2Symbols = 8;
+const UInt32 kLenTableSize = 28;
+const UInt32 kMainTableSize = 256 + 1 + 1 + 1 + kNumReps + kNumLen2Symbols + kLenTableSize;
+const UInt32 kDistTableSize = 60;
+
+const int kNumAlignBits = 4;
+const UInt32 kAlignTableSize = (1 << kNumAlignBits) + 1;
+
+const UInt32 kLevelTableSize = 20;
+
+const UInt32 kTablesSizesSum = kMainTableSize + kDistTableSize + kAlignTableSize + kLenTableSize;
+
+class CBitDecoder
+{
+ UInt32 m_Value;
+public:
+ UInt32 m_BitPos;
+ CInBuffer m_Stream;
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+ void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
+ void ReleaseStream() { m_Stream.ReleaseStream();}
+
+ void Init()
+ {
+ m_Stream.Init();
+ m_BitPos = 0;
+ m_Value = 0;
+ // m_BitPos = kNumBigValueBits;
+ // Normalize();
+ }
+
+ UInt64 GetProcessedSize() const
+ { return m_Stream.GetProcessedSize() - (m_BitPos) / 8; }
+ UInt32 GetBitPosition() const { return ((8 - m_BitPos) & 7); }
+
+ /*
+ void Normalize()
+ {
+ for (;m_BitPos >= 8; m_BitPos -= 8)
+ m_Value = (m_Value << 8) | m_Stream.ReadByte();
+ }
+ */
+
+ UInt32 GetValue(UInt32 numBits)
+ {
+ // return (m_Value << m_BitPos) >> (kNumBigValueBits - numBits);
+ // return ((m_Value >> (8 - m_BitPos)) & kMask) >> (kNumValueBits - numBits);
+ if (m_BitPos < numBits)
+ {
+ m_BitPos += 8;
+ m_Value = (m_Value << 8) | m_Stream.ReadByte();
+ if (m_BitPos < numBits)
+ {
+ m_BitPos += 8;
+ m_Value = (m_Value << 8) | m_Stream.ReadByte();
+ }
+ }
+ return m_Value >> (m_BitPos - numBits);
+ }
+
+ void MovePos(UInt32 numBits)
+ {
+ m_BitPos -= numBits;
+ m_Value = m_Value & ((1 << m_BitPos) - 1);
+ }
+
+ UInt32 ReadBits(UInt32 numBits)
+ {
+ UInt32 res = GetValue(numBits);
+ MovePos(numBits);
+ return res;
+ }
+};
+
+const int kNumTopBits = 24;
+const UInt32 kTopValue = (1 << kNumTopBits);
+const UInt32 kBot = (1 << 15);
+
+class CRangeDecoder:public NPpmd::CRangeDecoderVirt, public CBitDecoder
+{
+public:
+ UInt32 Range;
+ UInt32 Low;
+ UInt32 Code;
+
+ void Normalize()
+ {
+ while ((Low ^ (Low + Range)) < kTopValue ||
+ Range < kBot && ((Range = (0 - Low) & (kBot - 1)), 1))
+ {
+ Code = (Code << 8) | m_Stream.ReadByte();
+ Range <<= 8;
+ Low <<= 8;
+ }
+ }
+
+ void InitRangeCoder()
+ {
+ Code = 0;
+ Low = 0;
+ Range = 0xFFFFFFFF;
+ for(int i = 0; i < 4; i++)
+ Code = (Code << 8) | ReadBits(8);
+ }
+
+ virtual UInt32 GetThreshold(UInt32 total)
+ {
+ return (Code - Low) / ( Range /= total);
+ }
+
+ virtual void Decode(UInt32 start, UInt32 size)
+ {
+ Low += start * Range;
+ Range *= size;
+ Normalize();
+ }
+
+ virtual UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits)
+ {
+ if (((Code - Low) / (Range >>= numTotalBits)) < size0)
+ {
+ Decode(0, size0);
+ return 0;
+ }
+ else
+ {
+ Decode(size0, (1 << numTotalBits) - size0);
+ return 1;
+ }
+ }
+
+ // UInt64 GetProcessedSizeRangeCoder() {return Stream.GetProcessedSize(); }
+};
+
+
+struct CFilter: public NVm::CProgram
+{
+ CRecordVector<Byte> GlobalData;
+ UInt32 BlockStart;
+ UInt32 BlockSize;
+ UInt32 ExecCount;
+ CFilter(): BlockStart(0), BlockSize(0), ExecCount(0) {}
+};
+
+struct CTempFilter: public NVm::CProgramInitState
+{
+ UInt32 BlockStart;
+ UInt32 BlockSize;
+ UInt32 ExecCount;
+ bool NextWindow;
+
+ UInt32 FilterIndex;
+};
+
+const int kNumHuffmanBits = 15;
+
+class CDecoder:
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+ CRangeDecoder m_InBitStream;
+ Byte *_window;
+ UInt32 _winPos;
+ UInt32 _wrPtr;
+ UInt64 _lzSize;
+ UInt64 _unpackSize;
+ UInt64 _writtenFileSize; // if it's > _unpackSize, then _unpackSize only written
+ CMyComPtr<ISequentialOutStream> _outStream;
+ NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kDistTableSize> m_DistDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kAlignTableSize> m_AlignDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kLenTableSize> m_LenDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
+
+ UInt32 _reps[kNumReps];
+ UInt32 _lastLength;
+
+ Byte m_LastLevels[kTablesSizesSum];
+
+ Byte *_vmData;
+ Byte *_vmCode;
+ NVm::CVm _vm;
+ CRecordVector<CFilter *> _filters;
+ CRecordVector<CTempFilter *> _tempFilters;
+ UInt32 _lastFilter;
+
+ bool m_IsSolid;
+
+ bool _lzMode;
+
+ UInt32 PrevAlignBits;
+ UInt32 PrevAlignCount;
+
+ bool TablesRead;
+
+ NPpmd::CDecodeInfo _ppm;
+ int PpmEscChar;
+
+ HRESULT WriteDataToStream(const Byte *data, UInt32 size);
+ HRESULT WriteData(const Byte *data, UInt32 size);
+ HRESULT WriteArea(UInt32 startPtr, UInt32 endPtr);
+ void ExecuteFilter(int tempFilterIndex, NVm::CBlockRef &outBlockRef);
+ HRESULT WriteBuf();
+
+ void InitFilters();
+ bool AddVmCode(UInt32 firstByte, UInt32 codeSize);
+ bool ReadVmCodeLZ();
+ bool ReadVmCodePPM();
+
+ UInt32 ReadBits(int numBits);
+
+ HRESULT InitPPM();
+ int DecodePpmSymbol();
+ HRESULT DecodePPM(Int32 num, bool &keepDecompressing);
+
+ HRESULT ReadTables(bool &keepDecompressing);
+ HRESULT ReadEndOfBlock(bool &keepDecompressing);
+ HRESULT DecodeLZ(bool &keepDecompressing);
+ HRESULT CodeReal(ICompressProgressInfo *progress);
+public:
+ CDecoder();
+ ~CDecoder();
+
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+
+ void ReleaseStreams()
+ {
+ _outStream.Release();
+ m_InBitStream.ReleaseStream();
+ }
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+ void CopyBlock(UInt32 distance, UInt32 len)
+ {
+ _lzSize += len;
+ UInt32 pos = (_winPos - distance - 1) & kWindowMask;
+ Byte *window = _window;
+ UInt32 winPos = _winPos;
+ if (kWindowSize - winPos > len && kWindowSize - pos > len)
+ {
+ const Byte *src = window + pos;
+ Byte *dest = window + winPos;
+ _winPos += len;
+ do
+ *dest++ = *src++;
+ while(--len != 0);
+ return;
+ }
+ do
+ {
+ window[winPos] = window[pos];
+ winPos = (winPos + 1) & kWindowMask;
+ pos = (pos + 1) & kWindowMask;
+ }
+ while(--len != 0);
+ _winPos = winPos;
+ }
+
+ void PutByte(Byte b)
+ {
+ _window[_winPos] = b;
+ _winPos = (_winPos + 1) & kWindowMask;
+ _lzSize++;
+ }
+
+
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Vm.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Vm.cpp
new file mode 100644
index 000000000..759dfbdb0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Vm.cpp
@@ -0,0 +1,1091 @@
+// Rar3Vm.cpp
+// According to unRAR license, this code may not be used to develop
+// a program that creates RAR archives
+
+/*
+Note:
+ Due to performance considerations Rar VM may set Flags C incorrectly
+ for some operands (SHL x, 0, ... ).
+ Check implementation of concrete VM command
+ to see if it sets flags right.
+*/
+
+#include "StdAfx.h"
+
+#include "../../../C/7zCrc.h"
+#include "../../../C/Alloc.h"
+
+#include "Rar3Vm.h"
+
+namespace NCompress {
+namespace NRar3 {
+
+UInt32 CMemBitDecoder::ReadBits(int numBits)
+{
+ UInt32 res = 0;
+ for (;;)
+ {
+ Byte b = _bitPos < _bitSize ? _data[_bitPos >> 3] : 0;
+ int avail = (int)(8 - (_bitPos & 7));
+ if (numBits <= avail)
+ {
+ _bitPos += numBits;
+ return res | (b >> (avail - numBits)) & ((1 << numBits) - 1);
+ }
+ numBits -= avail;
+ res |= (UInt32)(b & ((1 << avail) - 1)) << numBits;
+ _bitPos += avail;
+ }
+}
+
+UInt32 CMemBitDecoder::ReadBit() { return ReadBits(1); }
+
+namespace NVm {
+
+static const UInt32 kStackRegIndex = kNumRegs - 1;
+
+static const UInt32 FLAG_C = 1;
+static const UInt32 FLAG_Z = 2;
+static const UInt32 FLAG_S = 0x80000000;
+
+static const Byte CF_OP0 = 0;
+static const Byte CF_OP1 = 1;
+static const Byte CF_OP2 = 2;
+static const Byte CF_OPMASK = 3;
+static const Byte CF_BYTEMODE = 4;
+static const Byte CF_JUMP = 8;
+static const Byte CF_PROC = 16;
+static const Byte CF_USEFLAGS = 32;
+static const Byte CF_CHFLAGS = 64;
+
+static Byte kCmdFlags[]=
+{
+ /* CMD_MOV */ CF_OP2 | CF_BYTEMODE,
+ /* CMD_CMP */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_ADD */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_SUB */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_JZ */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JNZ */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_INC */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_DEC */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_JMP */ CF_OP1 | CF_JUMP,
+ /* CMD_XOR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_AND */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_OR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_TEST */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_JS */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JNS */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JB */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JBE */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JA */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JAE */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_PUSH */ CF_OP1,
+ /* CMD_POP */ CF_OP1,
+ /* CMD_CALL */ CF_OP1 | CF_PROC,
+ /* CMD_RET */ CF_OP0 | CF_PROC,
+ /* CMD_NOT */ CF_OP1 | CF_BYTEMODE,
+ /* CMD_SHL */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_SHR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_SAR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_NEG */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_PUSHA */ CF_OP0,
+ /* CMD_POPA */ CF_OP0,
+ /* CMD_PUSHF */ CF_OP0 | CF_USEFLAGS,
+ /* CMD_POPF */ CF_OP0 | CF_CHFLAGS,
+ /* CMD_MOVZX */ CF_OP2,
+ /* CMD_MOVSX */ CF_OP2,
+ /* CMD_XCHG */ CF_OP2 | CF_BYTEMODE,
+ /* CMD_MUL */ CF_OP2 | CF_BYTEMODE,
+ /* CMD_DIV */ CF_OP2 | CF_BYTEMODE,
+ /* CMD_ADC */ CF_OP2 | CF_BYTEMODE | CF_USEFLAGS | CF_CHFLAGS ,
+ /* CMD_SBB */ CF_OP2 | CF_BYTEMODE | CF_USEFLAGS | CF_CHFLAGS ,
+ /* CMD_PRINT */ CF_OP0
+};
+
+CVm::CVm(): Mem(NULL) {}
+
+bool CVm::Create()
+{
+ if (Mem == NULL)
+ Mem = (Byte *)::MyAlloc(kSpaceSize + 4);
+ return (Mem != NULL);
+}
+
+CVm::~CVm()
+{
+ ::MyFree(Mem);
+}
+
+// CVm::Execute can change CProgram object: it clears progarm if VM returns error.
+
+bool CVm::Execute(CProgram *prg, const CProgramInitState *initState,
+ CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData)
+{
+ memcpy(R, initState->InitR, sizeof(initState->InitR));
+ R[kStackRegIndex] = kSpaceSize;
+ R[kNumRegs] = 0;
+ Flags = 0;
+
+ UInt32 globalSize = MyMin((UInt32)initState->GlobalData.Size(), kGlobalSize);
+ if (globalSize != 0)
+ memcpy(Mem + kGlobalOffset, &initState->GlobalData[0], globalSize);
+ UInt32 staticSize = MyMin((UInt32)prg->StaticData.Size(), kGlobalSize - globalSize);
+ if (staticSize != 0)
+ memcpy(Mem + kGlobalOffset + globalSize, &prg->StaticData[0], staticSize);
+
+ bool res = true;
+ #ifdef RARVM_STANDARD_FILTERS
+ if (prg->StandardFilterIndex >= 0)
+ ExecuteStandardFilter(prg->StandardFilterIndex);
+ else
+ #endif
+ {
+ res = ExecuteCode(prg);
+ if (!res)
+ prg->Commands[0].OpCode = CMD_RET;
+ }
+ UInt32 newBlockPos = GetFixedGlobalValue32(NGlobalOffset::kBlockPos) & kSpaceMask;
+ UInt32 newBlockSize = GetFixedGlobalValue32(NGlobalOffset::kBlockSize) & kSpaceMask;
+ if (newBlockPos + newBlockSize >= kSpaceSize)
+ newBlockPos = newBlockSize = 0;
+ outBlockRef.Offset = newBlockPos;
+ outBlockRef.Size = newBlockSize;
+
+ outGlobalData.Clear();
+ UInt32 dataSize = GetFixedGlobalValue32(NGlobalOffset::kGlobalMemOutSize);
+ dataSize = MyMin(dataSize, kGlobalSize - kFixedGlobalSize);
+ if (dataSize != 0)
+ {
+ dataSize += kFixedGlobalSize;
+ outGlobalData.Reserve(dataSize);
+ for (UInt32 i = 0; i < dataSize; i++)
+ outGlobalData.Add(Mem[kGlobalOffset + i]);
+ }
+ return res;
+}
+
+
+#define SET_IP(IP) \
+ if ((IP) >= numCommands) return true; \
+ if (--maxOpCount <= 0) return false; \
+ cmd = commands + (IP);
+
+#define GET_FLAG_S_B(res) (((res) & 0x80) ? FLAG_S : 0)
+#define SET_IP_OP1 { UInt32 val = GetOperand32(&cmd->Op1); SET_IP(val); }
+#define FLAGS_UPDATE_SZ Flags = res == 0 ? FLAG_Z : res & FLAG_S
+#define FLAGS_UPDATE_SZ_B Flags = (res & 0xFF) == 0 ? FLAG_Z : GET_FLAG_S_B(res)
+
+UInt32 CVm::GetOperand32(const COperand *op) const
+{
+ switch(op->Type)
+ {
+ case OP_TYPE_REG: return R[op->Data];
+ case OP_TYPE_REGMEM: return GetValue32(&Mem[(op->Base + R[op->Data]) & kSpaceMask]);
+ default: return op->Data;
+ }
+}
+
+void CVm::SetOperand32(const COperand *op, UInt32 val)
+{
+ switch(op->Type)
+ {
+ case OP_TYPE_REG: R[op->Data] = val; return;
+ case OP_TYPE_REGMEM: SetValue32(&Mem[(op->Base + R[op->Data]) & kSpaceMask], val); return;
+ }
+}
+
+Byte CVm::GetOperand8(const COperand *op) const
+{
+ switch(op->Type)
+ {
+ case OP_TYPE_REG: return (Byte)R[op->Data];
+ case OP_TYPE_REGMEM: return Mem[(op->Base + R[op->Data]) & kSpaceMask];;
+ default: return (Byte)op->Data;
+ }
+}
+
+void CVm::SetOperand8(const COperand *op, Byte val)
+{
+ switch(op->Type)
+ {
+ case OP_TYPE_REG: R[op->Data] = (R[op->Data] & 0xFFFFFF00) | val; return;
+ case OP_TYPE_REGMEM: Mem[(op->Base + R[op->Data]) & kSpaceMask] = val; return;
+ }
+}
+
+UInt32 CVm::GetOperand(bool byteMode, const COperand *op) const
+{
+ if (byteMode)
+ return GetOperand8(op);
+ return GetOperand32(op);
+}
+
+void CVm::SetOperand(bool byteMode, const COperand *op, UInt32 val)
+{
+ if (byteMode)
+ SetOperand8(op, (Byte)(val & 0xFF));
+ else
+ SetOperand32(op, val);
+}
+
+bool CVm::ExecuteCode(const CProgram *prg)
+{
+ Int32 maxOpCount = 25000000;
+ const CCommand *commands = &prg->Commands[0];
+ const CCommand *cmd = commands;
+ UInt32 numCommands = prg->Commands.Size();
+ for (;;)
+ {
+ switch(cmd->OpCode)
+ {
+ #ifndef RARVM_NO_VM
+
+ case CMD_MOV:
+ SetOperand32(&cmd->Op1, GetOperand32(&cmd->Op2));
+ break;
+ case CMD_MOVB:
+ SetOperand8(&cmd->Op1, GetOperand8(&cmd->Op2));
+ break;
+ case CMD_CMP:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ UInt32 res = v1 - GetOperand32(&cmd->Op2);
+ Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
+ }
+ break;
+ case CMD_CMPB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ Byte res = v1 - GetOperand8(&cmd->Op2);
+ res &= 0xFF;
+ Flags = res == 0 ? FLAG_Z : (res > v1) | GET_FLAG_S_B(res);
+ }
+ break;
+ case CMD_ADD:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ UInt32 res = v1 + GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ Flags = (res < v1) | (res == 0 ? FLAG_Z : (res & FLAG_S));
+ }
+ break;
+ case CMD_ADDB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ Byte res = v1 + GetOperand8(&cmd->Op2);
+ res &= 0xFF;
+ SetOperand8(&cmd->Op1, (Byte)res);
+ Flags = (res < v1) | (res == 0 ? FLAG_Z : GET_FLAG_S_B(res));
+ }
+ break;
+ case CMD_ADC:
+ {
+ UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
+ UInt32 FC = (Flags & FLAG_C);
+ UInt32 res = v1 + GetOperand(cmd->ByteMode, &cmd->Op2) + FC;
+ if (cmd->ByteMode)
+ res &= 0xFF;
+ SetOperand(cmd->ByteMode, &cmd->Op1, res);
+ Flags = (res < v1 || res == v1 && FC) | (res == 0 ? FLAG_Z : (res & FLAG_S));
+ }
+ break;
+ case CMD_SUB:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ UInt32 res = v1 - GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
+ }
+ break;
+ case CMD_SUBB:
+ {
+ UInt32 v1 = GetOperand8(&cmd->Op1);
+ UInt32 res = v1 - GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, (Byte)res);
+ Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
+ }
+ break;
+ case CMD_SBB:
+ {
+ UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
+ UInt32 FC = (Flags & FLAG_C);
+ UInt32 res = v1 - GetOperand(cmd->ByteMode, &cmd->Op2) - FC;
+ // Flags = res == 0 ? FLAG_Z : (res > v1 || res == v1 && FC) | (res & FLAG_S);
+ if (cmd->ByteMode)
+ res &= 0xFF;
+ SetOperand(cmd->ByteMode, &cmd->Op1, res);
+ Flags = (res > v1 || res == v1 && FC) | (res == 0 ? FLAG_Z : (res & FLAG_S));
+ }
+ break;
+ case CMD_INC:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) + 1;
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_INCB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) + 1;
+ SetOperand8(&cmd->Op1, res);;
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_DEC:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) - 1;
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_DECB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) - 1;
+ SetOperand8(&cmd->Op1, res);;
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_XOR:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) ^ GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_XORB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) ^ GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_AND:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) & GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_ANDB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) & GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_OR:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) | GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_ORB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) | GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_TEST:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) & GetOperand32(&cmd->Op2);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_TESTB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) & GetOperand8(&cmd->Op2);
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_NOT:
+ SetOperand(cmd->ByteMode, &cmd->Op1, ~GetOperand(cmd->ByteMode, &cmd->Op1));
+ break;
+ case CMD_NEG:
+ {
+ UInt32 res = 0 - GetOperand32(&cmd->Op1);
+ SetOperand32(&cmd->Op1, res);
+ Flags = res == 0 ? FLAG_Z : FLAG_C | (res & FLAG_S);
+ }
+ break;
+ case CMD_NEGB:
+ {
+ Byte res = (Byte)(0 - GetOperand8(&cmd->Op1));
+ SetOperand8(&cmd->Op1, res);
+ Flags = res == 0 ? FLAG_Z : FLAG_C | GET_FLAG_S_B(res);
+ }
+ break;
+
+ case CMD_SHL:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ int v2 = (int)GetOperand32(&cmd->Op2);
+ UInt32 res = v1 << v2;
+ SetOperand32(&cmd->Op1, res);
+ Flags = (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 << (v2 - 1)) & 0x80000000 ? FLAG_C : 0);
+ }
+ break;
+ case CMD_SHLB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ int v2 = (int)GetOperand8(&cmd->Op2);
+ Byte res = (Byte)(v1 << v2);
+ SetOperand8(&cmd->Op1, res);
+ Flags = (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 << (v2 - 1)) & 0x80 ? FLAG_C : 0);
+ }
+ break;
+ case CMD_SHR:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ int v2 = (int)GetOperand32(&cmd->Op2);
+ UInt32 res = v1 >> v2;
+ SetOperand32(&cmd->Op1, res);
+ Flags = (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 >> (v2 - 1)) & FLAG_C);
+ }
+ break;
+ case CMD_SHRB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ int v2 = (int)GetOperand8(&cmd->Op2);
+ Byte res = (Byte)(v1 >> v2);
+ SetOperand8(&cmd->Op1, res);
+ Flags = (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 >> (v2 - 1)) & FLAG_C);
+ }
+ break;
+ case CMD_SAR:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ int v2 = (int)GetOperand32(&cmd->Op2);
+ UInt32 res = UInt32(((Int32)v1) >> v2);
+ SetOperand32(&cmd->Op1, res);
+ Flags= (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 >> (v2 - 1)) & FLAG_C);
+ }
+ break;
+ case CMD_SARB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ int v2 = (int)GetOperand8(&cmd->Op2);
+ Byte res = (Byte)(((signed char)v1) >> v2);
+ SetOperand8(&cmd->Op1, res);
+ Flags= (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 >> (v2 - 1)) & FLAG_C);
+ }
+ break;
+
+ case CMD_JMP:
+ SET_IP_OP1;
+ continue;
+ case CMD_JZ:
+ if ((Flags & FLAG_Z) != 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JNZ:
+ if ((Flags & FLAG_Z) == 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JS:
+ if ((Flags & FLAG_S) != 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JNS:
+ if ((Flags & FLAG_S) == 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JB:
+ if ((Flags & FLAG_C) != 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JBE:
+ if ((Flags & (FLAG_C | FLAG_Z)) != 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JA:
+ if ((Flags & (FLAG_C | FLAG_Z)) == 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JAE:
+ if ((Flags & FLAG_C) == 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+
+ case CMD_PUSH:
+ R[kStackRegIndex] -= 4;
+ SetValue32(&Mem[R[kStackRegIndex] & kSpaceMask], GetOperand32(&cmd->Op1));
+ break;
+ case CMD_POP:
+ SetOperand32(&cmd->Op1, GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]));
+ R[kStackRegIndex] += 4;
+ break;
+ case CMD_CALL:
+ R[kStackRegIndex] -= 4;
+ SetValue32(&Mem[R[kStackRegIndex] & kSpaceMask], (UInt32)(cmd - commands + 1));
+ SET_IP_OP1;
+ continue;
+
+ case CMD_PUSHA:
+ {
+ for (UInt32 i = 0, SP = R[kStackRegIndex] - 4; i < kNumRegs; i++, SP -= 4)
+ SetValue32(&Mem[SP & kSpaceMask], R[i]);
+ R[kStackRegIndex] -= kNumRegs * 4;
+ }
+ break;
+ case CMD_POPA:
+ {
+ for (UInt32 i = 0, SP = R[kStackRegIndex]; i < kNumRegs; i++, SP += 4)
+ R[kStackRegIndex - i] = GetValue32(&Mem[SP & kSpaceMask]);
+ }
+ break;
+ case CMD_PUSHF:
+ R[kStackRegIndex] -= 4;
+ SetValue32(&Mem[R[kStackRegIndex]&kSpaceMask], Flags);
+ break;
+ case CMD_POPF:
+ Flags = GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]);
+ R[kStackRegIndex] += 4;
+ break;
+
+ case CMD_MOVZX:
+ SetOperand32(&cmd->Op1, GetOperand8(&cmd->Op2));
+ break;
+ case CMD_MOVSX:
+ SetOperand32(&cmd->Op1, (UInt32)(Int32)(signed char)GetOperand8(&cmd->Op2));
+ break;
+ case CMD_XCHG:
+ {
+ UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
+ SetOperand(cmd->ByteMode, &cmd->Op1, GetOperand(cmd->ByteMode, &cmd->Op2));
+ SetOperand(cmd->ByteMode, &cmd->Op2, v1);
+ }
+ break;
+ case CMD_MUL:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) * GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ }
+ break;
+ case CMD_MULB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) * GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, res);
+ }
+ break;
+ case CMD_DIV:
+ {
+ UInt32 divider = GetOperand(cmd->ByteMode, &cmd->Op2);
+ if (divider != 0)
+ {
+ UInt32 res = GetOperand(cmd->ByteMode, &cmd->Op1) / divider;
+ SetOperand(cmd->ByteMode, &cmd->Op1, res);
+ }
+ }
+ break;
+
+ #endif
+
+ case CMD_RET:
+ {
+ if (R[kStackRegIndex] >= kSpaceSize)
+ return true;
+ UInt32 ip = GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]);
+ SET_IP(ip);
+ R[kStackRegIndex] += 4;
+ continue;
+ }
+ case CMD_PRINT:
+ break;
+ }
+ cmd++;
+ --maxOpCount;
+ }
+}
+
+
+//////////////////////////////////////////////////////
+// Read program
+
+UInt32 ReadEncodedUInt32(CMemBitDecoder &inp)
+{
+ switch(inp.ReadBits(2))
+ {
+ case 0:
+ return inp.ReadBits(4);
+ case 1:
+ {
+ UInt32 v = inp.ReadBits(4);
+ if (v == 0)
+ return 0xFFFFFF00 | inp.ReadBits(8);
+ else
+ return (v << 4) | inp.ReadBits(4);
+ }
+ case 2:
+ return inp.ReadBits(16);
+ default:
+ return inp.ReadBits(32);
+ }
+}
+
+void CVm::DecodeArg(CMemBitDecoder &inp, COperand &op, bool byteMode)
+{
+ if (inp.ReadBit())
+ {
+ op.Type = OP_TYPE_REG;
+ op.Data = inp.ReadBits(kNumRegBits);
+ }
+ else if (inp.ReadBit() == 0)
+ {
+ op.Type = OP_TYPE_INT;
+ if (byteMode)
+ op.Data = inp.ReadBits(8);
+ else
+ op.Data = ReadEncodedUInt32(inp);
+ }
+ else
+ {
+ op.Type = OP_TYPE_REGMEM;
+ if (inp.ReadBit() == 0)
+ {
+ op.Data = inp.ReadBits(kNumRegBits);
+ op.Base = 0;
+ }
+ else
+ {
+ if (inp.ReadBit() == 0)
+ op.Data = inp.ReadBits(kNumRegBits);
+ else
+ op.Data = kNumRegs;
+ op.Base = ReadEncodedUInt32(inp);
+ }
+ }
+}
+
+void CVm::ReadVmProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
+{
+ CMemBitDecoder inp;
+ inp.Init(code, codeSize);
+
+ prg->StaticData.Clear();
+ if (inp.ReadBit())
+ {
+ UInt32 dataSize = ReadEncodedUInt32(inp) + 1;
+ for (UInt32 i = 0; inp.Avail() && i < dataSize; i++)
+ prg->StaticData.Add((Byte)inp.ReadBits(8));
+ }
+ while (inp.Avail())
+ {
+ prg->Commands.Add(CCommand());
+ CCommand *cmd = &prg->Commands.Back();
+ if (inp.ReadBit() == 0)
+ cmd->OpCode = (ECommand)inp.ReadBits(3);
+ else
+ cmd->OpCode = (ECommand)(8 + inp.ReadBits(5));
+ if (kCmdFlags[cmd->OpCode] & CF_BYTEMODE)
+ cmd->ByteMode = (inp.ReadBit()) ? true : false;
+ else
+ cmd->ByteMode = 0;
+ int opNum = (kCmdFlags[cmd->OpCode] & CF_OPMASK);
+ if (opNum > 0)
+ {
+ DecodeArg(inp, cmd->Op1, cmd->ByteMode);
+ if (opNum == 2)
+ DecodeArg(inp, cmd->Op2, cmd->ByteMode);
+ else
+ {
+ if (cmd->Op1.Type == OP_TYPE_INT && (kCmdFlags[cmd->OpCode] & (CF_JUMP | CF_PROC)))
+ {
+ int Distance = cmd->Op1.Data;
+ if (Distance >= 256)
+ Distance -= 256;
+ else
+ {
+ if (Distance >= 136)
+ Distance -= 264;
+ else if (Distance >= 16)
+ Distance -= 8;
+ else if (Distance >= 8)
+ Distance -= 16;
+ Distance += prg->Commands.Size() - 1;
+ }
+ cmd->Op1.Data = Distance;
+ }
+ }
+ }
+ if (cmd->ByteMode)
+ {
+ switch (cmd->OpCode)
+ {
+ case CMD_MOV: cmd->OpCode = CMD_MOVB; break;
+ case CMD_CMP: cmd->OpCode = CMD_CMPB; break;
+ case CMD_ADD: cmd->OpCode = CMD_ADDB; break;
+ case CMD_SUB: cmd->OpCode = CMD_SUBB; break;
+ case CMD_INC: cmd->OpCode = CMD_INCB; break;
+ case CMD_DEC: cmd->OpCode = CMD_DECB; break;
+ case CMD_XOR: cmd->OpCode = CMD_XORB; break;
+ case CMD_AND: cmd->OpCode = CMD_ANDB; break;
+ case CMD_OR: cmd->OpCode = CMD_ORB; break;
+ case CMD_TEST: cmd->OpCode = CMD_TESTB; break;
+ case CMD_NEG: cmd->OpCode = CMD_NEGB; break;
+ case CMD_SHL: cmd->OpCode = CMD_SHLB; break;
+ case CMD_SHR: cmd->OpCode = CMD_SHRB; break;
+ case CMD_SAR: cmd->OpCode = CMD_SARB; break;
+ case CMD_MUL: cmd->OpCode = CMD_MULB; break;
+ }
+ }
+ }
+}
+
+#ifdef RARVM_STANDARD_FILTERS
+
+enum EStandardFilter
+{
+ SF_E8,
+ SF_E8E9,
+ SF_ITANIUM,
+ SF_RGB,
+ SF_AUDIO,
+ SF_DELTA,
+ SF_UPCASE
+};
+
+struct StandardFilterSignature
+{
+ UInt32 Length;
+ UInt32 CRC;
+ EStandardFilter Type;
+}
+kStdFilters[]=
+{
+ 53, 0xad576887, SF_E8,
+ 57, 0x3cd7e57e, SF_E8E9,
+ 120, 0x3769893f, SF_ITANIUM,
+ 29, 0x0e06077d, SF_DELTA,
+ 149, 0x1c2c5dc8, SF_RGB,
+ 216, 0xbc85e701, SF_AUDIO,
+ 40, 0x46b9c560, SF_UPCASE
+};
+
+static int FindStandardFilter(const Byte *code, UInt32 codeSize)
+{
+ UInt32 crc = CrcCalc(code, codeSize);
+ for (int i = 0; i < sizeof(kStdFilters) / sizeof(kStdFilters[0]); i++)
+ {
+ StandardFilterSignature &sfs = kStdFilters[i];
+ if (sfs.CRC == crc && sfs.Length == codeSize)
+ return i;
+ }
+ return -1;
+}
+
+#endif
+
+void CVm::PrepareProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
+{
+ Byte xorSum = 0;
+ for (UInt32 i = 1; i < codeSize; i++)
+ xorSum ^= code[i];
+
+ prg->Commands.Clear();
+ #ifdef RARVM_STANDARD_FILTERS
+ prg->StandardFilterIndex = -1;
+ #endif
+
+ if (xorSum == code[0] && codeSize > 0)
+ {
+ #ifdef RARVM_STANDARD_FILTERS
+ prg->StandardFilterIndex = FindStandardFilter(code, codeSize);
+ if (prg->StandardFilterIndex >= 0)
+ return;
+ #endif
+ // 1 byte for checksum
+ ReadVmProgram(code + 1, codeSize - 1, prg);
+ }
+ prg->Commands.Add(CCommand());
+ CCommand *cmd = &prg->Commands.Back();
+ cmd->OpCode = CMD_RET;
+}
+
+void CVm::SetMemory(UInt32 pos, const Byte *data, UInt32 dataSize)
+{
+ if (pos < kSpaceSize && data != Mem + pos)
+ memmove(Mem + pos, data, MyMin(dataSize, kSpaceSize - pos));
+}
+
+#ifdef RARVM_STANDARD_FILTERS
+
+static void E8E9Decode(Byte *data, UInt32 dataSize, UInt32 fileOffset, bool e9)
+{
+ if (dataSize <= 4)
+ return;
+ dataSize -= 4;
+ const UInt32 kFileSize = 0x1000000;
+ Byte cmpByte2 = (e9 ? 0xE9 : 0xE8);
+ for (UInt32 curPos = 0; curPos < dataSize;)
+ {
+ Byte curByte = *(data++);
+ curPos++;
+ if (curByte == 0xE8 || curByte == cmpByte2)
+ {
+ UInt32 offset = curPos + fileOffset;
+ UInt32 addr = (Int32)GetValue32(data);
+ if (addr < kFileSize)
+ SetValue32(data, addr - offset);
+ else if ((Int32)addr < 0 && (Int32)(addr + offset) >= 0)
+ SetValue32(data, addr + kFileSize);
+ data += 4;
+ curPos += 4;
+ }
+ }
+}
+
+static inline UInt32 ItaniumGetOpType(const Byte *data, int bitPos)
+{
+ return (data[(unsigned int)bitPos >> 3] >> (bitPos & 7)) & 0xF;
+}
+
+
+static void ItaniumDecode(Byte *data, UInt32 dataSize, UInt32 fileOffset)
+{
+ UInt32 curPos = 0;
+ fileOffset >>= 4;
+ while (curPos < dataSize - 21)
+ {
+ int b = (data[0] & 0x1F) - 0x10;
+ if (b >= 0)
+ {
+ static Byte kCmdMasks[16] = {4,4,6,6,0,0,7,7,4,4,0,0,4,4,0,0};
+ Byte cmdMask = kCmdMasks[b];
+ if (cmdMask != 0)
+ for (int i = 0; i < 3; i++)
+ if (cmdMask & (1 << i))
+ {
+ int startPos = i * 41 + 18;
+ if (ItaniumGetOpType(data, startPos + 24) == 5)
+ {
+ const UInt32 kMask = 0xFFFFF;
+ Byte *p = data + ((unsigned int)startPos >> 3);
+ UInt32 bitField = ((UInt32)p[0]) | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16);
+ int inBit = (startPos & 7);
+ UInt32 offset = (bitField >> inBit) & kMask;
+ UInt32 andMask = ~(kMask << inBit);
+ bitField = ((offset - fileOffset) & kMask) << inBit;
+ for (int j = 0; j < 3; j++)
+ {
+ p[j] &= andMask;
+ p[j] |= bitField;
+ andMask >>= 8;
+ bitField >>= 8;
+ }
+ }
+ }
+ }
+ data += 16;
+ curPos += 16;
+ fileOffset++;
+ }
+}
+
+static void DeltaDecode(Byte *data, UInt32 dataSize, UInt32 numChannels)
+{
+ UInt32 srcPos = 0;
+ UInt32 border = dataSize * 2;
+ for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
+ {
+ Byte prevByte = 0;
+ for (UInt32 destPos = dataSize + curChannel; destPos < border; destPos += numChannels)
+ data[destPos] = (prevByte = prevByte - data[srcPos++]);
+ }
+}
+
+static void RgbDecode(Byte *srcData, UInt32 dataSize, UInt32 width, UInt32 posR)
+{
+ Byte *destData = srcData + dataSize;
+ const UInt32 numChannels = 3;
+ for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
+ {
+ Byte prevByte = 0;
+
+ for (UInt32 i = curChannel; i < dataSize; i+= numChannels)
+ {
+ unsigned int predicted;
+ if (i < width)
+ predicted = prevByte;
+ else
+ {
+ unsigned int upperLeftByte = destData[i - width];
+ unsigned int upperByte = destData[i - width + 3];
+ predicted = prevByte + upperByte - upperLeftByte;
+ int pa = abs((int)(predicted - prevByte));
+ int pb = abs((int)(predicted - upperByte));
+ int pc = abs((int)(predicted - upperLeftByte));
+ if (pa <= pb && pa <= pc)
+ predicted = prevByte;
+ else
+ if (pb <= pc)
+ predicted = upperByte;
+ else
+ predicted = upperLeftByte;
+ }
+ destData[i] = prevByte = (Byte)(predicted - *(srcData++));
+ }
+ }
+ if (dataSize < 3)
+ return;
+ for (UInt32 i = posR, border = dataSize - 2; i < border; i += 3)
+ {
+ Byte g = destData[i + 1];
+ destData[i] = destData[i] + g;
+ destData[i + 2] = destData[i + 2] + g;
+ }
+}
+
+static void AudioDecode(Byte *srcData, UInt32 dataSize, UInt32 numChannels)
+{
+ Byte *destData = srcData + dataSize;
+ for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
+ {
+ UInt32 prevByte = 0, prevDelta = 0, dif[7];
+ Int32 D1 = 0, D2 = 0, D3;
+ Int32 K1 = 0, K2 = 0, K3 = 0;
+ memset(dif, 0, sizeof(dif));
+
+ for (UInt32 i = curChannel, byteCount = 0; i < dataSize; i += numChannels, byteCount++)
+ {
+ D3 = D2;
+ D2 = prevDelta - D1;
+ D1 = prevDelta;
+
+ UInt32 predicted = 8 * prevByte + K1 * D1 + K2 * D2 + K3 * D3;
+ predicted = (predicted >> 3) & 0xFF;
+
+ UInt32 curByte = *(srcData++);
+
+ predicted -= curByte;
+ destData[i] = (Byte)predicted;
+ prevDelta = (UInt32)(Int32)(signed char)(predicted - prevByte);
+ prevByte = predicted;
+
+ Int32 D = ((Int32)(signed char)curByte) << 3;
+
+ dif[0] += abs(D);
+ dif[1] += abs(D - D1);
+ dif[2] += abs(D + D1);
+ dif[3] += abs(D - D2);
+ dif[4] += abs(D + D2);
+ dif[5] += abs(D - D3);
+ dif[6] += abs(D + D3);
+
+ if ((byteCount & 0x1F) == 0)
+ {
+ UInt32 minDif = dif[0], numMinDif = 0;
+ dif[0] = 0;
+ for (int j = 1; j < sizeof(dif) / sizeof(dif[0]); j++)
+ {
+ if (dif[j] < minDif)
+ {
+ minDif = dif[j];
+ numMinDif = j;
+ }
+ dif[j] = 0;
+ }
+ switch (numMinDif)
+ {
+ case 1: if (K1 >= -16) K1--; break;
+ case 2: if (K1 < 16) K1++; break;
+ case 3: if (K2 >= -16) K2--; break;
+ case 4: if (K2 < 16) K2++; break;
+ case 5: if (K3 >= -16) K3--; break;
+ case 6: if (K3 < 16) K3++; break;
+ }
+ }
+ }
+ }
+}
+
+static UInt32 UpCaseDecode(Byte *data, UInt32 dataSize)
+{
+ UInt32 srcPos = 0, destPos = dataSize;
+ while (srcPos < dataSize)
+ {
+ Byte curByte = data[srcPos++];
+ if (curByte == 2 && (curByte = data[srcPos++]) != 2)
+ curByte -= 32;
+ data[destPos++] = curByte;
+ }
+ return destPos - dataSize;
+}
+
+void CVm::ExecuteStandardFilter(int filterIndex)
+{
+ UInt32 dataSize = R[4];
+ if (dataSize >= kGlobalOffset)
+ return;
+ EStandardFilter filterType = kStdFilters[filterIndex].Type;
+
+ switch (filterType)
+ {
+ case SF_E8:
+ case SF_E8E9:
+ E8E9Decode(Mem, dataSize, R[6], (filterType == SF_E8E9));
+ break;
+ case SF_ITANIUM:
+ ItaniumDecode(Mem, dataSize, R[6]);
+ break;
+ case SF_DELTA:
+ if (dataSize >= kGlobalOffset / 2)
+ break;
+ SetBlockPos(dataSize);
+ DeltaDecode(Mem, dataSize, R[0]);
+ break;
+ case SF_RGB:
+ if (dataSize >= kGlobalOffset / 2)
+ break;
+ {
+ UInt32 width = R[0];
+ if (width <= 3)
+ break;
+ SetBlockPos(dataSize);
+ RgbDecode(Mem, dataSize, width, R[1]);
+ }
+ break;
+ case SF_AUDIO:
+ if (dataSize >= kGlobalOffset / 2)
+ break;
+ SetBlockPos(dataSize);
+ AudioDecode(Mem, dataSize, R[0]);
+ break;
+ case SF_UPCASE:
+ if (dataSize >= kGlobalOffset / 2)
+ break;
+ UInt32 destSize = UpCaseDecode(Mem, dataSize);
+ SetBlockSize(destSize);
+ SetBlockPos(dataSize);
+ break;
+ }
+}
+
+#endif
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Vm.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Vm.h
new file mode 100644
index 000000000..c02534c61
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/Rar3Vm.h
@@ -0,0 +1,179 @@
+// Rar3Vm.h
+// According to unRAR license, this code may not be used to develop
+// a program that creates RAR archives
+
+#ifndef __COMPRESS_RAR3_VM_H
+#define __COMPRESS_RAR3_VM_H
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/MyVector.h"
+#include "Common/Types.h"
+
+#define RARVM_STANDARD_FILTERS
+
+namespace NCompress {
+namespace NRar3 {
+
+class CMemBitDecoder
+{
+ const Byte *_data;
+ UInt32 _bitSize;
+ UInt32 _bitPos;
+public:
+ void Init(const Byte *data, UInt32 byteSize)
+ {
+ _data = data;
+ _bitSize = (byteSize << 3);
+ _bitPos = 0;
+ }
+ UInt32 ReadBits(int numBits);
+ UInt32 ReadBit();
+ bool Avail() const { return (_bitPos < _bitSize); }
+};
+
+namespace NVm {
+
+inline UInt32 GetValue32(const void *addr) { return GetUi32(addr); }
+inline void SetValue32(void *addr, UInt32 value) { SetUi32(addr, value); }
+
+UInt32 ReadEncodedUInt32(CMemBitDecoder &inp);
+
+const int kNumRegBits = 3;
+const UInt32 kNumRegs = 1 << kNumRegBits;
+const UInt32 kNumGpRegs = kNumRegs - 1;
+
+const UInt32 kSpaceSize = 0x40000;
+const UInt32 kSpaceMask = kSpaceSize -1;
+const UInt32 kGlobalOffset = 0x3C000;
+const UInt32 kGlobalSize = 0x2000;
+const UInt32 kFixedGlobalSize = 64;
+
+namespace NGlobalOffset
+{
+ const UInt32 kBlockSize = 0x1C;
+ const UInt32 kBlockPos = 0x20;
+ const UInt32 kExecCount = 0x2C;
+ const UInt32 kGlobalMemOutSize = 0x30;
+}
+
+enum ECommand
+{
+ CMD_MOV, CMD_CMP, CMD_ADD, CMD_SUB, CMD_JZ, CMD_JNZ, CMD_INC, CMD_DEC,
+ CMD_JMP, CMD_XOR, CMD_AND, CMD_OR, CMD_TEST, CMD_JS, CMD_JNS, CMD_JB,
+ CMD_JBE, CMD_JA, CMD_JAE, CMD_PUSH, CMD_POP, CMD_CALL, CMD_RET, CMD_NOT,
+ CMD_SHL, CMD_SHR, CMD_SAR, CMD_NEG, CMD_PUSHA,CMD_POPA, CMD_PUSHF,CMD_POPF,
+ CMD_MOVZX,CMD_MOVSX,CMD_XCHG, CMD_MUL, CMD_DIV, CMD_ADC, CMD_SBB, CMD_PRINT,
+
+ CMD_MOVB, CMD_CMPB, CMD_ADDB, CMD_SUBB, CMD_INCB, CMD_DECB,
+ CMD_XORB, CMD_ANDB, CMD_ORB, CMD_TESTB,CMD_NEGB,
+ CMD_SHLB, CMD_SHRB, CMD_SARB, CMD_MULB
+};
+
+enum EOpType {OP_TYPE_REG, OP_TYPE_INT, OP_TYPE_REGMEM, OP_TYPE_NONE};
+
+// Addr in COperand object can link (point) to CVm object!!!
+
+struct COperand
+{
+ EOpType Type;
+ UInt32 Data;
+ UInt32 Base;
+ COperand(): Type(OP_TYPE_NONE), Data(0), Base(0) {}
+};
+
+struct CCommand
+{
+ ECommand OpCode;
+ bool ByteMode;
+ COperand Op1, Op2;
+};
+
+struct CBlockRef
+{
+ UInt32 Offset;
+ UInt32 Size;
+};
+
+struct CProgram
+{
+ CRecordVector<CCommand> Commands;
+ #ifdef RARVM_STANDARD_FILTERS
+ int StandardFilterIndex;
+ #endif
+ CRecordVector<Byte> StaticData;
+};
+
+struct CProgramInitState
+{
+ UInt32 InitR[kNumGpRegs];
+ CRecordVector<Byte> GlobalData;
+
+ void AllocateEmptyFixedGlobal()
+ {
+ GlobalData.Clear();
+ GlobalData.Reserve(NVm::kFixedGlobalSize);
+ for (UInt32 i = 0; i < NVm::kFixedGlobalSize; i++)
+ GlobalData.Add(0);
+ }
+};
+
+class CVm
+{
+ static UInt32 GetValue(bool byteMode, const void *addr)
+ {
+ if (byteMode)
+ return(*(const Byte *)addr);
+ else
+ return GetUi32(addr);
+ }
+
+ static void SetValue(bool byteMode, void *addr, UInt32 value)
+ {
+ if (byteMode)
+ *(Byte *)addr = (Byte)value;
+ else
+ SetUi32(addr, value);
+ }
+
+ UInt32 GetFixedGlobalValue32(UInt32 globalOffset) { return GetValue(false, &Mem[kGlobalOffset + globalOffset]); }
+
+ void SetBlockSize(UInt32 v) { SetValue(&Mem[kGlobalOffset + NGlobalOffset::kBlockSize], v); }
+ void SetBlockPos(UInt32 v) { SetValue(&Mem[kGlobalOffset + NGlobalOffset::kBlockPos], v); }
+public:
+ static void SetValue(void *addr, UInt32 value) { SetValue(false, addr, value); }
+private:
+ UInt32 GetOperand32(const COperand *op) const;
+ void SetOperand32(const COperand *op, UInt32 val);
+ Byte GetOperand8(const COperand *op) const;
+ void SetOperand8(const COperand *op, Byte val);
+ UInt32 GetOperand(bool byteMode, const COperand *op) const;
+ void SetOperand(bool byteMode, const COperand *op, UInt32 val);
+
+ void DecodeArg(CMemBitDecoder &inp, COperand &op, bool byteMode);
+
+ bool ExecuteCode(const CProgram *prg);
+
+ #ifdef RARVM_STANDARD_FILTERS
+ void ExecuteStandardFilter(int filterIndex);
+ #endif
+
+ Byte *Mem;
+ UInt32 R[kNumRegs + 1]; // R[kNumRegs] = 0 always (speed optimization)
+ UInt32 Flags;
+ void ReadVmProgram(const Byte *code, UInt32 codeSize, CProgram *prg);
+public:
+ CVm();
+ ~CVm();
+ bool Create();
+ void PrepareProgram(const Byte *code, UInt32 codeSize, CProgram *prg);
+ void SetMemory(UInt32 pos, const Byte *data, UInt32 dataSize);
+ bool Execute(CProgram *prg, const CProgramInitState *initState,
+ CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData);
+ const Byte *GetDataPointer(UInt32 offset) const { return Mem + offset; }
+
+};
+
+#endif
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RarCodecsRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RarCodecsRegister.cpp
new file mode 100644
index 000000000..e3f6a05c4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/RarCodecsRegister.cpp
@@ -0,0 +1,26 @@
+// RarCodecsRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+
+#include "Rar1Decoder.h"
+#include "Rar2Decoder.h"
+#include "Rar3Decoder.h"
+
+#define CREATE_CODEC(x) static void *CreateCodec ## x() { return (void *)(ICompressCoder *)(new NCompress::NRar ## x::CDecoder); }
+
+CREATE_CODEC(1)
+CREATE_CODEC(2)
+CREATE_CODEC(3)
+
+#define RAR_CODEC(x, name) { CreateCodec ## x, 0, 0x040300 + x, L"Rar" name, 1, false }
+
+static CCodecInfo g_CodecsInfo[] =
+{
+ RAR_CODEC(1, L"1"),
+ RAR_CODEC(2, L"2"),
+ RAR_CODEC(3, L"3"),
+};
+
+REGISTER_CODECS(Rar)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ShrinkDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ShrinkDecoder.cpp
new file mode 100644
index 000000000..1105220e8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ShrinkDecoder.cpp
@@ -0,0 +1,145 @@
+// ShrinkDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "../Common/InBuffer.h"
+#include "../Common/OutBuffer.h"
+
+#include "BitlDecoder.h"
+#include "ShrinkDecoder.h"
+
+namespace NCompress {
+namespace NShrink {
+
+static const UInt32 kBufferSize = (1 << 20);
+static const int kNumMinBits = 9;
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
+{
+ NBitl::CBaseDecoder<CInBuffer> inBuffer;
+ COutBuffer outBuffer;
+
+ if (!inBuffer.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ inBuffer.SetStream(inStream);
+ inBuffer.Init();
+
+ if (!outBuffer.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ outBuffer.SetStream(outStream);
+ outBuffer.Init();
+
+ UInt64 prevPos = 0;
+ int numBits = kNumMinBits;
+ UInt32 head = 257;
+ bool needPrev = false;
+ UInt32 lastSymbol = 0;
+
+ unsigned int i;
+ for (i = 0; i < kNumItems; i++)
+ _parents[i] = 0;
+ for (i = 0; i < kNumItems; i++)
+ _suffixes[i] = 0;
+ for (i = 0; i < 257; i++)
+ _isFree[i] = false;
+ for (; i < kNumItems; i++)
+ _isFree[i] = true;
+
+ for (;;)
+ {
+ UInt32 symbol = inBuffer.ReadBits(numBits);
+ if (inBuffer.ExtraBitsWereRead())
+ break;
+ if (_isFree[symbol])
+ return S_FALSE;
+ if (symbol == 256)
+ {
+ UInt32 symbol = inBuffer.ReadBits(numBits);
+ if (symbol == 1)
+ {
+ if (numBits < kNumMaxBits)
+ numBits++;
+ }
+ else if (symbol == 2)
+ {
+ if (needPrev)
+ _isFree[head - 1] = true;
+ for (i = 257; i < kNumItems; i++)
+ _isParent[i] = false;
+ for (i = 257; i < kNumItems; i++)
+ if (!_isFree[i])
+ _isParent[_parents[i]] = true;
+ for (i = 257; i < kNumItems; i++)
+ if (!_isParent[i])
+ _isFree[i] = true;
+ head = 257;
+ while (head < kNumItems && !_isFree[head])
+ head++;
+ if (head < kNumItems)
+ {
+ needPrev = true;
+ _isFree[head] = false;
+ _parents[head] = (UInt16)lastSymbol;
+ head++;
+ }
+ }
+ else
+ return S_FALSE;
+ continue;
+ }
+ UInt32 cur = symbol;
+ i = 0;
+ int corectionIndex = -1;
+ while (cur >= 256)
+ {
+ if (cur == head - 1)
+ corectionIndex = i;
+ _stack[i++] = _suffixes[cur];
+ cur = _parents[cur];
+ }
+ _stack[i++] = (Byte)cur;
+ if (needPrev)
+ {
+ _suffixes[head - 1] = (Byte)cur;
+ if (corectionIndex >= 0)
+ _stack[corectionIndex] = (Byte)cur;
+ }
+ while (i > 0)
+ outBuffer.WriteByte((_stack[--i]));
+ while (head < kNumItems && !_isFree[head])
+ head++;
+ if (head < kNumItems)
+ {
+ needPrev = true;
+ _isFree[head] = false;
+ _parents[head] = (UInt16)symbol;
+ head++;
+ }
+ else
+ needPrev = false;
+ lastSymbol = symbol;
+
+ UInt64 nowPos = outBuffer.GetProcessedSize();
+ if (progress != NULL && nowPos - prevPos > (1 << 18))
+ {
+ prevPos = nowPos;
+ UInt64 packSize = inBuffer.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &nowPos));
+ }
+ }
+ return outBuffer.Flush();
+}
+
+STDMETHODIMP CDecoder ::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ShrinkDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ShrinkDecoder.h
new file mode 100644
index 000000000..9bbecd41b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ShrinkDecoder.h
@@ -0,0 +1,38 @@
+// ShrinkDecoder.h
+
+#ifndef __COMPRESS_SHRINK_DECODER_H
+#define __COMPRESS_SHRINK_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+namespace NCompress {
+namespace NShrink {
+
+const int kNumMaxBits = 13;
+const UInt32 kNumItems = 1 << kNumMaxBits;
+
+class CDecoder :
+ public ICompressCoder,
+ public CMyUnknownImp
+{
+ UInt16 _parents[kNumItems];
+ Byte _suffixes[kNumItems];
+ Byte _stack[kNumItems];
+ bool _isFree[kNumItems];
+ bool _isParent[kNumItems];
+
+public:
+ MY_UNKNOWN_IMP
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZDecoder.cpp
new file mode 100644
index 000000000..e28c64518
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZDecoder.cpp
@@ -0,0 +1,159 @@
+// ZDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Alloc.h"
+
+#include "../Common/InBuffer.h"
+#include "../Common/OutBuffer.h"
+
+#include "ZDecoder.h"
+
+namespace NCompress {
+namespace NZ {
+
+static const UInt32 kBufferSize = (1 << 20);
+static const Byte kNumBitsMask = 0x1F;
+static const Byte kBlockModeMask = 0x80;
+static const int kNumMinBits = 9;
+static const int kNumMaxBits = 16;
+
+void CDecoder::Free()
+{
+ MyFree(_parents); _parents = 0;
+ MyFree(_suffixes); _suffixes = 0;
+ MyFree(_stack); _stack = 0;
+}
+
+CDecoder::~CDecoder() { Free(); }
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
+{
+ CInBuffer inBuffer;
+ COutBuffer outBuffer;
+
+ if (!inBuffer.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ inBuffer.SetStream(inStream);
+ inBuffer.Init();
+
+ if (!outBuffer.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ outBuffer.SetStream(outStream);
+ outBuffer.Init();
+
+ int maxbits = _properties & kNumBitsMask;
+ if (maxbits < kNumMinBits || maxbits > kNumMaxBits)
+ return S_FALSE;
+ UInt32 numItems = 1 << maxbits;
+ bool blockMode = ((_properties & kBlockModeMask) != 0);
+
+ if (maxbits != _numMaxBits || _parents == 0 || _suffixes == 0 || _stack == 0)
+ {
+ Free();
+ _parents = (UInt16 *)MyAlloc(numItems * sizeof(UInt16)); if (_parents == 0) return E_OUTOFMEMORY;
+ _suffixes = (Byte *)MyAlloc(numItems * sizeof(Byte)); if (_suffixes == 0) return E_OUTOFMEMORY;
+ _stack = (Byte *)MyAlloc(numItems * sizeof(Byte)); if (_stack == 0) return E_OUTOFMEMORY;
+ _numMaxBits = maxbits;
+ }
+
+ UInt64 prevPos = 0;
+ int numBits = kNumMinBits;
+ UInt32 head = blockMode ? 257 : 256;
+
+ bool needPrev = false;
+
+ unsigned bitPos = 0;
+ unsigned numBufBits = 0;
+
+ Byte buf[kNumMaxBits + 4];
+
+ _parents[256] = 0; // virus protection
+ _suffixes[256] = 0;
+
+ for (;;)
+ {
+ if (numBufBits == bitPos)
+ {
+ numBufBits = (unsigned)inBuffer.ReadBytes(buf, numBits) * 8;
+ bitPos = 0;
+ UInt64 nowPos = outBuffer.GetProcessedSize();
+ if (progress != NULL && nowPos - prevPos >= (1 << 18))
+ {
+ prevPos = nowPos;
+ UInt64 packSize = inBuffer.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &nowPos));
+ }
+ }
+ unsigned bytePos = bitPos >> 3;
+ UInt32 symbol = buf[bytePos] | ((UInt32)buf[bytePos + 1] << 8) | ((UInt32)buf[bytePos + 2] << 16);
+ symbol >>= (bitPos & 7);
+ symbol &= (1 << numBits) - 1;
+ bitPos += numBits;
+ if (bitPos > numBufBits)
+ break;
+ if (symbol >= head)
+ return S_FALSE;
+ if (blockMode && symbol == 256)
+ {
+ numBufBits = bitPos = 0;
+ numBits = kNumMinBits;
+ head = 257;
+ needPrev = false;
+ continue;
+ }
+ UInt32 cur = symbol;
+ int i = 0;
+ while (cur >= 256)
+ {
+ _stack[i++] = _suffixes[cur];
+ cur = _parents[cur];
+ }
+ _stack[i++] = (Byte)cur;
+ if (needPrev)
+ {
+ _suffixes[head - 1] = (Byte)cur;
+ if (symbol == head - 1)
+ _stack[0] = (Byte)cur;
+ }
+ do
+ outBuffer.WriteByte((_stack[--i]));
+ while (i > 0);
+ if (head < numItems)
+ {
+ needPrev = true;
+ _parents[head++] = (UInt16)symbol;
+ if (head > ((UInt32)1 << numBits))
+ {
+ if (numBits < maxbits)
+ {
+ numBufBits = bitPos = 0;
+ numBits++;
+ }
+ }
+ }
+ else
+ needPrev = false;
+ }
+ return outBuffer.Flush();
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size < 1)
+ return E_INVALIDARG;
+ _properties = data[0];
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZDecoder.h
new file mode 100644
index 000000000..2bd83a177
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZDecoder.h
@@ -0,0 +1,42 @@
+// ZDecoder.h
+
+#ifndef __COMPRESS_Z_DECODER_H
+#define __COMPRESS_Z_DECODER_H
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+
+namespace NCompress {
+namespace NZ {
+
+class CDecoder:
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+ UInt16 *_parents;
+ Byte *_suffixes;
+ Byte *_stack;
+ Byte _properties;
+ int _numMaxBits;
+
+public:
+ CDecoder(): _parents(0), _suffixes(0), _stack(0), _properties(0), _numMaxBits(0) {};
+ ~CDecoder();
+ void Free();
+
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZlibDecoder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZlibDecoder.cpp
new file mode 100644
index 000000000..a1bac27b1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZlibDecoder.cpp
@@ -0,0 +1,94 @@
+// ZlibDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/StreamUtils.h"
+
+#include "DeflateDecoder.h"
+#include "ZlibDecoder.h"
+
+namespace NCompress {
+namespace NZlib {
+
+#define DEFLATE_TRY_BEGIN try {
+#define DEFLATE_TRY_END } \
+ catch(...) { return S_FALSE; }
+
+#define ADLER_MOD 65521
+#define ADLER_LOOP_MAX 5550
+
+static UInt32 Adler32_Update(UInt32 adler, const Byte *buf, size_t size)
+{
+ UInt32 a = adler & 0xFFFF;
+ UInt32 b = (adler >> 16) & 0xFFFF;
+ while (size > 0)
+ {
+ unsigned curSize = (size > ADLER_LOOP_MAX) ? ADLER_LOOP_MAX : (unsigned )size;
+ unsigned i;
+ for (i = 0; i < curSize; i++)
+ {
+ a += buf[i];
+ b += a;
+ }
+ buf += curSize;
+ size -= curSize;
+ a %= ADLER_MOD;
+ b %= ADLER_MOD;
+ }
+ return (b << 16) + a;
+}
+
+STDMETHODIMP COutStreamWithAdler::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ HRESULT result = _stream->Write(data, size, &size);
+ _adler = Adler32_Update(_adler, (const Byte *)data, size);
+ if (processedSize != NULL)
+ *processedSize = size;
+ return result;
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
+{
+ DEFLATE_TRY_BEGIN
+ if (!AdlerStream)
+ {
+ AdlerSpec = new COutStreamWithAdler;
+ AdlerStream = AdlerSpec;
+ }
+ if (!DeflateDecoder)
+ {
+ DeflateDecoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder;
+ DeflateDecoderSpec->ZlibMode = true;
+ DeflateDecoder = DeflateDecoderSpec;
+ }
+
+ Byte buf[2];
+ RINOK(ReadStream_FALSE(inStream, buf, 2));
+ int method = buf[0] & 0xF;
+ if (method != 8)
+ return S_FALSE;
+ // int dicSize = buf[0] >> 4;
+ if ((((UInt32)buf[0] << 8) + buf[1]) % 31 != 0)
+ return S_FALSE;
+ if ((buf[1] & 0x20) != 0) // dictPresent
+ return S_FALSE;
+ // int level = (buf[1] >> 6);
+
+ AdlerSpec->SetStream(outStream);
+ AdlerSpec->Init();
+ HRESULT res = DeflateDecoder->Code(inStream, AdlerStream, inSize, outSize, progress);
+ AdlerSpec->ReleaseStream();
+
+ if (res == S_OK)
+ {
+ const Byte *p = DeflateDecoderSpec->ZlibFooter;
+ UInt32 adler = ((UInt32)p[0] << 24) | ((UInt32)p[1] << 16) | ((UInt32)p[2] << 8) | p[3];
+ if (adler != AdlerSpec->GetAdler())
+ return S_FALSE;
+ }
+ return res;
+ DEFLATE_TRY_END
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZlibDecoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZlibDecoder.h
new file mode 100644
index 000000000..906e241b9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Compress/ZlibDecoder.h
@@ -0,0 +1,46 @@
+// ZlibDecoder.h
+
+#ifndef __ZLIB_DECODER_H
+#define __ZLIB_DECODER_H
+
+#include "DeflateDecoder.h"
+
+namespace NCompress {
+namespace NZlib {
+
+const UInt32 ADLER_INIT_VAL = 1;
+
+class COutStreamWithAdler:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialOutStream> _stream;
+ UInt32 _adler;
+public:
+ MY_UNKNOWN_IMP
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ void SetStream(ISequentialOutStream *stream) { _stream = stream; }
+ void ReleaseStream() { _stream.Release(); }
+ void Init() { _adler = ADLER_INIT_VAL; }
+ UInt32 GetAdler() const { return _adler; }
+};
+
+class CDecoder:
+ public ICompressCoder,
+ public CMyUnknownImp
+{
+ COutStreamWithAdler *AdlerSpec;
+ CMyComPtr<ISequentialOutStream> AdlerStream;
+
+ NCompress::NDeflate::NDecoder::CCOMCoder *DeflateDecoderSpec;
+ CMyComPtr<ICompressCoder> DeflateDecoder;
+public:
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
+
+ MY_UNKNOWN_IMP
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.cpp
new file mode 100644
index 000000000..88149eb10
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.cpp
@@ -0,0 +1,244 @@
+// 7zAes.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/Sha256.h"
+
+#include "Windows/Synchronization.h"
+
+#include "../Common/StreamObjects.h"
+#include "../Common/StreamUtils.h"
+
+#include "7zAes.h"
+#include "MyAes.h"
+
+#ifndef EXTRACT_ONLY
+#include "RandGen.h"
+#endif
+
+using namespace NWindows;
+
+namespace NCrypto {
+namespace NSevenZ {
+
+bool CKeyInfo::IsEqualTo(const CKeyInfo &a) const
+{
+ if (SaltSize != a.SaltSize || NumCyclesPower != a.NumCyclesPower)
+ return false;
+ for (UInt32 i = 0; i < SaltSize; i++)
+ if (Salt[i] != a.Salt[i])
+ return false;
+ return (Password == a.Password);
+}
+
+void CKeyInfo::CalculateDigest()
+{
+ if (NumCyclesPower == 0x3F)
+ {
+ UInt32 pos;
+ for (pos = 0; pos < SaltSize; pos++)
+ Key[pos] = Salt[pos];
+ for (UInt32 i = 0; i < Password.GetCapacity() && pos < static_cast< UInt32 >( kKeySize ); i++)
+ Key[pos++] = Password[i];
+ for (; pos < static_cast< UInt32 >( kKeySize ); pos++)
+ Key[pos] = 0;
+ }
+ else
+ {
+ CSha256 sha;
+ Sha256_Init(&sha);
+ const UInt64 numRounds = UInt64(1) << (NumCyclesPower);
+ Byte temp[8] = { 0,0,0,0,0,0,0,0 };
+ for (UInt64 round = 0; round < numRounds; round++)
+ {
+ Sha256_Update(&sha, Salt, (size_t)SaltSize);
+ Sha256_Update(&sha, Password, Password.GetCapacity());
+ Sha256_Update(&sha, temp, 8);
+ for (int i = 0; i < 8; i++)
+ if (++(temp[i]) != 0)
+ break;
+ }
+ Sha256_Final(&sha, Key);
+ }
+}
+
+bool CKeyInfoCache::Find(CKeyInfo &key)
+{
+ for (int i = 0; i < Keys.Size(); i++)
+ {
+ const CKeyInfo &cached = Keys[i];
+ if (key.IsEqualTo(cached))
+ {
+ for (int j = 0; j < kKeySize; j++)
+ key.Key[j] = cached.Key[j];
+ if (i != 0)
+ {
+ Keys.Insert(0, cached);
+ Keys.Delete(i+1);
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+void CKeyInfoCache::Add(CKeyInfo &key)
+{
+ if (Find(key))
+ return;
+ if (Keys.Size() >= Size)
+ Keys.DeleteBack();
+ Keys.Insert(0, key);
+}
+
+static CKeyInfoCache g_GlobalKeyCache(32);
+static NSynchronization::CCriticalSection g_GlobalKeyCacheCriticalSection;
+
+CBase::CBase():
+ _cachedKeys(16),
+ _ivSize(0)
+{
+ for (size_t i = 0; i < sizeof(_iv); i++)
+ _iv[i] = 0;
+}
+
+void CBase::CalculateDigest()
+{
+ NSynchronization::CCriticalSectionLock lock(g_GlobalKeyCacheCriticalSection);
+ if (_cachedKeys.Find(_key))
+ g_GlobalKeyCache.Add(_key);
+ else
+ {
+ if (!g_GlobalKeyCache.Find(_key))
+ {
+ _key.CalculateDigest();
+ g_GlobalKeyCache.Add(_key);
+ }
+ _cachedKeys.Add(_key);
+ }
+}
+
+#ifndef EXTRACT_ONLY
+
+/*
+STDMETHODIMP CEncoder::ResetSalt()
+{
+ _key.SaltSize = 4;
+ g_RandomGenerator.Generate(_key.Salt, _key.SaltSize);
+ return S_OK;
+}
+*/
+
+STDMETHODIMP CEncoder::ResetInitVector()
+{
+ _ivSize = 8;
+ g_RandomGenerator.Generate(_iv, (unsigned)_ivSize);
+ return S_OK;
+}
+
+STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
+{
+ // _key.Init();
+ for (UInt32 i = _ivSize; i < sizeof(_iv); i++)
+ _iv[i] = 0;
+
+ UInt32 ivSize = _ivSize;
+
+ // _key.NumCyclesPower = 0x3F;
+ _key.NumCyclesPower = 19;
+
+ Byte firstByte = (Byte)(_key.NumCyclesPower |
+ (((_key.SaltSize == 0) ? 0 : 1) << 7) |
+ (((ivSize == 0) ? 0 : 1) << 6));
+ RINOK(outStream->Write(&firstByte, 1, NULL));
+ if (_key.SaltSize == 0 && ivSize == 0)
+ return S_OK;
+ Byte saltSizeSpec = (Byte)((_key.SaltSize == 0) ? 0 : (_key.SaltSize - 1));
+ Byte ivSizeSpec = (Byte)((ivSize == 0) ? 0 : (ivSize - 1));
+ Byte secondByte = (Byte)(((saltSizeSpec) << 4) | ivSizeSpec);
+ RINOK(outStream->Write(&secondByte, 1, NULL));
+ if (_key.SaltSize > 0)
+ {
+ RINOK(WriteStream(outStream, _key.Salt, _key.SaltSize));
+ }
+ if (ivSize > 0)
+ {
+ RINOK(WriteStream(outStream, _iv, ivSize));
+ }
+ return S_OK;
+}
+
+HRESULT CEncoder::CreateFilter()
+{
+ _aesFilter = new CAesCbcEncoder;
+ return S_OK;
+}
+
+#endif
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ _key.Init();
+ UInt32 i;
+ for (i = 0; i < sizeof(_iv); i++)
+ _iv[i] = 0;
+ if (size == 0)
+ return S_OK;
+ UInt32 pos = 0;
+ Byte firstByte = data[pos++];
+
+ _key.NumCyclesPower = firstByte & 0x3F;
+ if ((firstByte & 0xC0) == 0)
+ return S_OK;
+ _key.SaltSize = (firstByte >> 7) & 1;
+ UInt32 ivSize = (firstByte >> 6) & 1;
+
+ if (pos >= size)
+ return E_INVALIDARG;
+ Byte secondByte = data[pos++];
+
+ _key.SaltSize += (secondByte >> 4);
+ ivSize += (secondByte & 0x0F);
+
+ if (pos + _key.SaltSize + ivSize > size)
+ return E_INVALIDARG;
+ for (i = 0; i < _key.SaltSize; i++)
+ _key.Salt[i] = data[pos++];
+ for (i = 0; i < ivSize; i++)
+ _iv[i] = data[pos++];
+ return S_OK;
+}
+
+STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
+{
+ _key.Password.SetCapacity((size_t)size);
+ memcpy(_key.Password, data, (size_t)size);
+ return S_OK;
+}
+
+STDMETHODIMP CBaseCoder::Init()
+{
+ CalculateDigest();
+ if (_aesFilter == 0)
+ {
+ RINOK(CreateFilter());
+ }
+ CMyComPtr<ICryptoProperties> cp;
+ RINOK(_aesFilter.QueryInterface(IID_ICryptoProperties, &cp));
+ RINOK(cp->SetKey(_key.Key, sizeof(_key.Key)));
+ RINOK(cp->SetInitVector(_iv, sizeof(_iv)));
+ return S_OK;
+}
+
+STDMETHODIMP_(UInt32) CBaseCoder::Filter(Byte *data, UInt32 size)
+{
+ return _aesFilter->Filter(data, size);
+}
+
+HRESULT CDecoder::CreateFilter()
+{
+ _aesFilter = new CAesCbcDecoder;
+ return S_OK;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.h
new file mode 100644
index 000000000..ea9c585e8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.h
@@ -0,0 +1,117 @@
+// 7zAes.h
+
+#ifndef __CRYPTO_7Z_AES_H
+#define __CRYPTO_7Z_AES_H
+
+#include "Common/Buffer.h"
+#include "Common/MyCom.h"
+#include "Common/MyVector.h"
+
+#include "../ICoder.h"
+#include "../IPassword.h"
+
+namespace NCrypto {
+namespace NSevenZ {
+
+const int kKeySize = 32;
+
+class CKeyInfo
+{
+public:
+ int NumCyclesPower;
+ UInt32 SaltSize;
+ Byte Salt[16];
+ CByteBuffer Password;
+ Byte Key[kKeySize];
+
+ bool IsEqualTo(const CKeyInfo &a) const;
+ void CalculateDigest();
+
+ CKeyInfo() { Init(); }
+ void Init()
+ {
+ NumCyclesPower = 0;
+ SaltSize = 0;
+ for (unsigned int i = 0; i < sizeof(Salt); i++)
+ Salt[i] = 0;
+ }
+};
+
+class CKeyInfoCache
+{
+ int Size;
+ CObjectVector<CKeyInfo> Keys;
+public:
+ CKeyInfoCache(int size): Size(size) {}
+ bool Find(CKeyInfo &key);
+ // HRESULT Calculate(CKeyInfo &key);
+ void Add(CKeyInfo &key);
+};
+
+class CBase
+{
+ CKeyInfoCache _cachedKeys;
+protected:
+ CKeyInfo _key;
+ Byte _iv[16];
+ UInt32 _ivSize;
+ void CalculateDigest();
+ CBase();
+};
+
+class CBaseCoder:
+ public ICompressFilter,
+ public ICryptoSetPassword,
+ public CMyUnknownImp,
+ public CBase
+{
+protected:
+ CMyComPtr<ICompressFilter> _aesFilter;
+
+ virtual HRESULT CreateFilter() = 0;
+ #ifndef CRYPTO_AES
+ HRESULT CreateFilterFromDLL(REFCLSID clsID);
+ #endif
+public:
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+
+ STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
+};
+
+#ifndef EXTRACT_ONLY
+
+class CEncoder:
+ public CBaseCoder,
+ public ICompressWriteCoderProperties,
+ // public ICryptoResetSalt,
+ public ICryptoResetInitVector
+{
+ virtual HRESULT CreateFilter();
+public:
+ MY_UNKNOWN_IMP3(
+ ICryptoSetPassword,
+ ICompressWriteCoderProperties,
+ // ICryptoResetSalt,
+ ICryptoResetInitVector)
+ STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+ // STDMETHOD(ResetSalt)();
+ STDMETHOD(ResetInitVector)();
+};
+#endif
+
+class CDecoder:
+ public CBaseCoder,
+ public ICompressSetDecoderProperties2
+{
+ virtual HRESULT CreateFilter();
+public:
+ MY_UNKNOWN_IMP2(
+ ICryptoSetPassword,
+ ICompressSetDecoderProperties2)
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAesRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAesRegister.cpp
new file mode 100644
index 000000000..5e57748f5
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAesRegister.cpp
@@ -0,0 +1,18 @@
+// 7zAesRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../Common/RegisterCodec.h"
+#include "7zAes.h"
+
+static void *CreateCodec() { return (void *)(ICompressFilter *)(new NCrypto::NSevenZ::CDecoder()); }
+#ifndef EXTRACT_ONLY
+static void *CreateCodecOut() { return (void *)(ICompressFilter *)(new NCrypto::NSevenZ::CEncoder()); }
+#else
+#define CreateCodecOut 0
+#endif
+
+static CCodecInfo g_CodecInfo =
+ { CreateCodec, CreateCodecOut, 0x06F10701, L"7zAES", 1, true };
+
+REGISTER_CODEC(7zAES)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.cpp
new file mode 100644
index 000000000..13a7ff81d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.cpp
@@ -0,0 +1,109 @@
+// HmacSha1.cpp
+
+#include "StdAfx.h"
+
+#include "HmacSha1.h"
+
+namespace NCrypto {
+namespace NSha1 {
+
+void CHmac::SetKey(const Byte *key, size_t keySize)
+{
+ Byte keyTemp[kBlockSize];
+ size_t i;
+ for (i = 0; i < kBlockSize; i++)
+ keyTemp[i] = 0;
+ if(keySize > kBlockSize)
+ {
+ _sha.Init();
+ _sha.Update(key, keySize);
+ _sha.Final(keyTemp);
+ keySize = kDigestSize;
+ }
+ else
+ for (i = 0; i < keySize; i++)
+ keyTemp[i] = key[i];
+ for (i = 0; i < kBlockSize; i++)
+ keyTemp[i] ^= 0x36;
+ _sha.Init();
+ _sha.Update(keyTemp, kBlockSize);
+ for (i = 0; i < kBlockSize; i++)
+ keyTemp[i] ^= 0x36 ^ 0x5C;
+ _sha2.Init();
+ _sha2.Update(keyTemp, kBlockSize);
+}
+
+void CHmac::Final(Byte *mac, size_t macSize)
+{
+ Byte digest[kDigestSize];
+ _sha.Final(digest);
+ _sha2.Update(digest, kDigestSize);
+ _sha2.Final(digest);
+ for(size_t i = 0; i < macSize; i++)
+ mac[i] = digest[i];
+}
+
+
+void CHmac32::SetKey(const Byte *key, size_t keySize)
+{
+ UInt32 keyTemp[kBlockSizeInWords];
+ size_t i;
+ for (i = 0; i < kBlockSizeInWords; i++)
+ keyTemp[i] = 0;
+ if(keySize > kBlockSize)
+ {
+ CContext sha;
+ sha.Init();
+ sha.Update(key, keySize);
+ Byte digest[kDigestSize];
+ sha.Final(digest);
+
+ for (unsigned int i = 0 ; i < kDigestSizeInWords; i++)
+ keyTemp[i] =
+ ((UInt32)(digest[i * 4 + 0]) << 24) |
+ ((UInt32)(digest[i * 4 + 1]) << 16) |
+ ((UInt32)(digest[i * 4 + 2]) << 8) |
+ ((UInt32)(digest[i * 4 + 3]));
+ keySize = kDigestSizeInWords;
+ }
+ else
+ for (size_t i = 0; i < keySize; i++)
+ keyTemp[i / 4] |= (key[i] << (24 - 8 * (i & 3)));
+ for (i = 0; i < kBlockSizeInWords; i++)
+ keyTemp[i] ^= 0x36363636;
+ _sha.Init();
+ _sha.Update(keyTemp, kBlockSizeInWords);
+ for (i = 0; i < kBlockSizeInWords; i++)
+ keyTemp[i] ^= 0x36363636 ^ 0x5C5C5C5C;
+ _sha2.Init();
+ _sha2.Update(keyTemp, kBlockSizeInWords);
+}
+
+void CHmac32::Final(UInt32 *mac, size_t macSize)
+{
+ UInt32 digest[kDigestSizeInWords];
+ _sha.Final(digest);
+ _sha2.Update(digest, kDigestSizeInWords);
+ _sha2.Final(digest);
+ for(size_t i = 0; i < macSize; i++)
+ mac[i] = digest[i];
+}
+
+void CHmac32::GetLoopXorDigest(UInt32 *mac, UInt32 numIteration)
+{
+ UInt32 block[kBlockSizeInWords];
+ UInt32 block2[kBlockSizeInWords];
+ _sha.PrepareBlock(block, kDigestSizeInWords);
+ _sha2.PrepareBlock(block2, kDigestSizeInWords);
+ for(unsigned int s = 0; s < kDigestSizeInWords; s++)
+ block[s] = mac[s];
+ for(UInt32 i = 0; i < numIteration; i++)
+ {
+ _sha.GetBlockDigest(block, block2);
+ _sha2.GetBlockDigest(block2, block);
+ for (unsigned int s = 0; s < kDigestSizeInWords; s++)
+ mac[s] ^= block[s];
+ }
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.h
new file mode 100644
index 000000000..d7181329c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.h
@@ -0,0 +1,39 @@
+// HmacSha1.h
+// Implements HMAC-SHA-1 (RFC2104, FIPS-198)
+
+#ifndef __CRYPTO_HMAC_SHA1_H
+#define __CRYPTO_HMAC_SHA1_H
+
+#include "Sha1.h"
+
+namespace NCrypto {
+namespace NSha1 {
+
+// Use: SetKey(key, keySize); for () Update(data, size); Final(mac, macSize);
+
+class CHmac
+{
+ CContext _sha;
+ CContext _sha2;
+public:
+ void SetKey(const Byte *key, size_t keySize);
+ void Update(const Byte *data, size_t dataSize) { _sha.Update(data, dataSize); }
+ void Final(Byte *mac, size_t macSize = kDigestSize);
+};
+
+class CHmac32
+{
+ CContext32 _sha;
+ CContext32 _sha2;
+public:
+ void SetKey(const Byte *key, size_t keySize);
+ void Update(const UInt32 *data, size_t dataSize) { _sha.Update(data, dataSize); }
+ void Final(UInt32 *mac, size_t macSize = kDigestSizeInWords);
+
+ // It'sa for hmac function. in,out: mac[kDigestSizeInWords].
+ void GetLoopXorDigest(UInt32 *mac, UInt32 numIteration);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.cpp
new file mode 100644
index 000000000..5b0d1e8a4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.cpp
@@ -0,0 +1,57 @@
+// Crypto/MyAes.cpp
+
+#include "StdAfx.h"
+
+#include "MyAes.h"
+
+namespace NCrypto {
+
+struct CAesTabInit { CAesTabInit() { AesGenTables();} } g_AesTabInit;
+
+STDMETHODIMP CAesCbcEncoder::Init() { return S_OK; }
+
+STDMETHODIMP_(UInt32) CAesCbcEncoder::Filter(Byte *data, UInt32 size)
+{
+ return (UInt32)AesCbc_Encode(&Aes, data, size);
+}
+
+STDMETHODIMP CAesCbcEncoder::SetKey(const Byte *data, UInt32 size)
+{
+ if ((size & 0x7) != 0 || size < 16 || size > 32)
+ return E_INVALIDARG;
+ Aes_SetKeyEncode(&Aes.aes, data, size);
+ return S_OK;
+}
+
+STDMETHODIMP CAesCbcEncoder::SetInitVector(const Byte *data, UInt32 size)
+{
+ if (size != AES_BLOCK_SIZE)
+ return E_INVALIDARG;
+ AesCbc_Init(&Aes, data);
+ return S_OK;
+}
+
+STDMETHODIMP CAesCbcDecoder::Init() { return S_OK; }
+
+STDMETHODIMP_(UInt32) CAesCbcDecoder::Filter(Byte *data, UInt32 size)
+{
+ return (UInt32)AesCbc_Decode(&Aes, data, size);
+}
+
+STDMETHODIMP CAesCbcDecoder::SetKey(const Byte *data, UInt32 size)
+{
+ if ((size & 0x7) != 0 || size < 16 || size > 32)
+ return E_INVALIDARG;
+ Aes_SetKeyDecode(&Aes.aes, data, size);
+ return S_OK;
+}
+
+STDMETHODIMP CAesCbcDecoder::SetInitVector(const Byte *data, UInt32 size)
+{
+ if (size != AES_BLOCK_SIZE)
+ return E_INVALIDARG;
+ AesCbc_Init(&Aes, data);
+ return S_OK;
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.h
new file mode 100644
index 000000000..24e90d6f1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.h
@@ -0,0 +1,45 @@
+// Crypto/MyAes.h
+
+#ifndef __CRYPTO_MY_AES_H
+#define __CRYPTO_MY_AES_H
+
+#include "../../../C/Aes.h"
+
+#include "../../Common/MyCom.h"
+#include "../../Common/Types.h"
+
+#include "../ICoder.h"
+
+namespace NCrypto {
+
+class CAesCbcEncoder:
+ public ICompressFilter,
+ public ICryptoProperties,
+ public CMyUnknownImp
+{
+ CAesCbc Aes;
+public:
+ MY_UNKNOWN_IMP1(ICryptoProperties)
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+ STDMETHOD(SetKey)(const Byte *data, UInt32 size);
+ STDMETHOD(SetInitVector)(const Byte *data, UInt32 size);
+};
+
+class CAesCbcDecoder:
+ public ICompressFilter,
+ public ICryptoProperties,
+ public CMyUnknownImp
+{
+ CAesCbc Aes;
+public:
+ MY_UNKNOWN_IMP1(ICryptoProperties)
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+ STDMETHOD(SetKey)(const Byte *data, UInt32 size);
+ STDMETHOD(SetInitVector)(const Byte *data, UInt32 size);
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp
new file mode 100644
index 000000000..cbbdec89d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp
@@ -0,0 +1,83 @@
+// Pbkdf2HmacSha1.cpp
+
+#include "StdAfx.h"
+
+#include "HmacSha1.h"
+
+namespace NCrypto {
+namespace NSha1 {
+
+void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
+ UInt32 numIterations, Byte *key, size_t keySize)
+{
+ CHmac baseCtx;
+ baseCtx.SetKey(pwd, pwdSize);
+ for (UInt32 i = 1; keySize > 0; i++)
+ {
+ CHmac ctx = baseCtx;
+ ctx.Update(salt, saltSize);
+ Byte u[kDigestSize] = { (Byte)(i >> 24), (Byte)(i >> 16), (Byte)(i >> 8), (Byte)(i) };
+ const unsigned int curSize = (keySize < kDigestSize) ? (unsigned int)keySize : kDigestSize;
+ ctx.Update(u, 4);
+ ctx.Final(u, kDigestSize);
+
+ unsigned int s;
+ for (s = 0; s < curSize; s++)
+ key[s] = u[s];
+
+ for (UInt32 j = numIterations; j > 1; j--)
+ {
+ ctx = baseCtx;
+ ctx.Update(u, kDigestSize);
+ ctx.Final(u, kDigestSize);
+ for (s = 0; s < curSize; s++)
+ key[s] ^= u[s];
+ }
+
+ key += curSize;
+ keySize -= curSize;
+ }
+}
+
+void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
+ UInt32 numIterations, UInt32 *key, size_t keySize)
+{
+ CHmac32 baseCtx;
+ baseCtx.SetKey(pwd, pwdSize);
+ for (UInt32 i = 1; keySize > 0; i++)
+ {
+ CHmac32 ctx = baseCtx;
+ ctx.Update(salt, saltSize);
+ UInt32 u[kDigestSizeInWords] = { i };
+ const unsigned int curSize = (keySize < kDigestSizeInWords) ? (unsigned int)keySize : kDigestSizeInWords;
+ ctx.Update(u, 1);
+ ctx.Final(u, kDigestSizeInWords);
+
+ // Speed-optimized code start
+ ctx = baseCtx;
+ ctx.GetLoopXorDigest(u, numIterations - 1);
+ // Speed-optimized code end
+
+ unsigned int s;
+ for (s = 0; s < curSize; s++)
+ key[s] = u[s];
+
+ /*
+ // Default code start
+ for (UInt32 j = numIterations; j > 1; j--)
+ {
+ ctx = baseCtx;
+ ctx.Update(u, kDigestSizeInWords);
+ ctx.Final(u, kDigestSizeInWords);
+ for (s = 0; s < curSize; s++)
+ key[s] ^= u[s];
+ }
+ // Default code end
+ */
+
+ key += curSize;
+ keySize -= curSize;
+ }
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.h
new file mode 100644
index 000000000..bb90e1214
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.h
@@ -0,0 +1,21 @@
+// Pbkdf2HmacSha1.h
+// Password-Based Key Derivation Function (RFC 2898, PKCS #5) based on HMAC-SHA-1
+
+#ifndef __CRYPTO_PBKDF2_HMAC_SHA1_H
+#define __CRYPTO_PBKDF2_HMAC_SHA1_H
+
+#include <stddef.h>
+#include "../../Common/Types.h"
+
+namespace NCrypto {
+namespace NSha1 {
+
+void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
+ UInt32 numIterations, Byte *key, size_t keySize);
+
+void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
+ UInt32 numIterations, UInt32 *key, size_t keySize);
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.cpp
new file mode 100644
index 000000000..e0e2e3abd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.cpp
@@ -0,0 +1,107 @@
+// RandGen.cpp
+
+#include "StdAfx.h"
+
+#include <stdio.h>
+#include "Windows/Synchronization.h"
+#include "RandGen.h"
+
+#ifndef _WIN32
+#include <unistd.h>
+#define USE_POSIX_TIME
+#define USE_POSIX_TIME2
+#endif
+
+#ifdef USE_POSIX_TIME
+#include <time.h>
+#ifdef USE_POSIX_TIME2
+#include <sys/time.h>
+#endif
+#endif
+
+// This is not very good random number generator.
+// Please use it only for salt.
+// First generated data block depends from timer and processID.
+// Other generated data blocks depend from previous state
+// Maybe it's possible to restore original timer value from generated value.
+
+void CRandomGenerator::Init()
+{
+ NCrypto::NSha1::CContext hash;
+ hash.Init();
+
+ #ifdef _WIN32
+ DWORD w = ::GetCurrentProcessId();
+ hash.Update((const Byte *)&w, sizeof(w));
+ w = ::GetCurrentThreadId();
+ hash.Update((const Byte *)&w, sizeof(w));
+ #else
+ pid_t pid = getpid();
+ hash.Update((const Byte *)&pid, sizeof(pid));
+ pid = getppid();
+ hash.Update((const Byte *)&pid, sizeof(pid));
+ #endif
+
+ for (int i = 0; i < 1000; i++)
+ {
+ #ifdef _WIN32
+ LARGE_INTEGER v;
+ if (::QueryPerformanceCounter(&v))
+ hash.Update((const Byte *)&v.QuadPart, sizeof(v.QuadPart));
+ #endif
+
+ #ifdef USE_POSIX_TIME
+ #ifdef USE_POSIX_TIME2
+ timeval v;
+ if (gettimeofday(&v, 0) == 0)
+ {
+ hash.Update((const Byte *)&v.tv_sec, sizeof(v.tv_sec));
+ hash.Update((const Byte *)&v.tv_usec, sizeof(v.tv_usec));
+ }
+ #endif
+ time_t v2 = time(NULL);
+ hash.Update((const Byte *)&v2, sizeof(v2));
+ #endif
+
+ DWORD tickCount = ::GetTickCount();
+ hash.Update((const Byte *)&tickCount, sizeof(tickCount));
+
+ for (int j = 0; j < 100; j++)
+ {
+ hash.Final(_buff);
+ hash.Init();
+ hash.Update(_buff, NCrypto::NSha1::kDigestSize);
+ }
+ }
+ hash.Final(_buff);
+ _needInit = false;
+}
+
+static NWindows::NSynchronization::CCriticalSection g_CriticalSection;
+
+void CRandomGenerator::Generate(Byte *data, unsigned int size)
+{
+ g_CriticalSection.Enter();
+ if (_needInit)
+ Init();
+ while (size > 0)
+ {
+ NCrypto::NSha1::CContext hash;
+
+ hash.Init();
+ hash.Update(_buff, NCrypto::NSha1::kDigestSize);
+ hash.Final(_buff);
+
+ hash.Init();
+ UInt32 salt = 0xF672ABD1;
+ hash.Update((const Byte *)&salt, sizeof(salt));
+ hash.Update(_buff, NCrypto::NSha1::kDigestSize);
+ Byte buff[NCrypto::NSha1::kDigestSize];
+ hash.Final(buff);
+ for (unsigned int i = 0; i < NCrypto::NSha1::kDigestSize && size > 0; i++, size--)
+ *data++ = buff[i];
+ }
+ g_CriticalSection.Leave();
+}
+
+CRandomGenerator g_RandomGenerator;
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.h
new file mode 100644
index 000000000..209445c43
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.h
@@ -0,0 +1,21 @@
+// RandGen.h
+
+#ifndef __CRYPTO_RAND_GEN_H
+#define __CRYPTO_RAND_GEN_H
+
+#include "Sha1.h"
+
+class CRandomGenerator
+{
+ Byte _buff[NCrypto::NSha1::kDigestSize];
+ bool _needInit;
+
+ void Init();
+public:
+ CRandomGenerator(): _needInit(true) {};
+ void Generate(Byte *data, unsigned size);
+};
+
+extern CRandomGenerator g_RandomGenerator;
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.cpp
new file mode 100644
index 000000000..c2df0e527
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.cpp
@@ -0,0 +1,133 @@
+// Crypto/Rar20Crypto.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/7zCrc.h"
+#include "../../../C/CpuArch.h"
+#include "../../../C/RotateDefs.h"
+
+#include "Rar20Crypto.h"
+
+namespace NCrypto {
+namespace NRar20 {
+
+static const int kNumRounds = 32;
+
+static const Byte InitSubstTable[256] = {
+ 215, 19,149, 35, 73,197,192,205,249, 28, 16,119, 48,221, 2, 42,
+ 232, 1,177,233, 14, 88,219, 25,223,195,244, 90, 87,239,153,137,
+ 255,199,147, 70, 92, 66,246, 13,216, 40, 62, 29,217,230, 86, 6,
+ 71, 24,171,196,101,113,218,123, 93, 91,163,178,202, 67, 44,235,
+ 107,250, 75,234, 49,167,125,211, 83,114,157,144, 32,193,143, 36,
+ 158,124,247,187, 89,214,141, 47,121,228, 61,130,213,194,174,251,
+ 97,110, 54,229,115, 57,152, 94,105,243,212, 55,209,245, 63, 11,
+ 164,200, 31,156, 81,176,227, 21, 76, 99,139,188,127, 17,248, 51,
+ 207,120,189,210, 8,226, 41, 72,183,203,135,165,166, 60, 98, 7,
+ 122, 38,155,170, 69,172,252,238, 39,134, 59,128,236, 27,240, 80,
+ 131, 3, 85,206,145, 79,154,142,159,220,201,133, 74, 64, 20,129,
+ 224,185,138,103,173,182, 43, 34,254, 82,198,151,231,180, 58, 10,
+ 118, 26,102, 12, 50,132, 22,191,136,111,162,179, 45, 4,148,108,
+ 161, 56, 78,126,242,222, 15,175,146, 23, 33,241,181,190, 77,225,
+ 0, 46,169,186, 68, 95,237, 65, 53,208,253,168, 9, 18,100, 52,
+ 116,184,160, 96,109, 37, 30,106,140,104,150, 5,204,117,112, 84
+};
+
+void CData::UpdateKeys(const Byte *data)
+{
+ for (int i = 0; i < 16; i += 4)
+ for (int j = 0; j < 4; j++)
+ Keys[j] ^= g_CrcTable[data[i + j]];
+}
+
+static void Swap(Byte *b1, Byte *b2)
+{
+ Byte b = *b1;
+ *b1 = *b2;
+ *b2 = b;
+}
+
+void CData::SetPassword(const Byte *password, UInt32 passwordLen)
+{
+ Keys[0] = 0xD3A3B879L;
+ Keys[1] = 0x3F6D12F7L;
+ Keys[2] = 0x7515A235L;
+ Keys[3] = 0xA4E7F123L;
+
+ Byte psw[256];
+ memset(psw, 0, sizeof(psw));
+ memcpy(psw, password, passwordLen);
+ memcpy(SubstTable, InitSubstTable, sizeof(SubstTable));
+
+ for (UInt32 j = 0; j < 256; j++)
+ for (UInt32 i = 0; i < passwordLen; i += 2)
+ {
+ UInt32 n2 = (Byte)g_CrcTable[(psw[i + 1] + j) & 0xFF];
+ UInt32 n1 = (Byte)g_CrcTable[(psw[i] - j) & 0xFF];
+ for (UInt32 k = 1; (n1 & 0xFF) != n2; n1++, k++)
+ Swap(&SubstTable[n1 & 0xFF], &SubstTable[(n1 + i + k) & 0xFF]);
+ }
+ for (UInt32 i = 0; i < passwordLen; i+= 16)
+ EncryptBlock(&psw[i]);
+}
+
+void CData::CryptBlock(Byte *buf, bool encrypt)
+{
+ Byte inBuf[16];
+ UInt32 A, B, C, D, T, TA, TB;
+
+ A = GetUi32(buf + 0) ^ Keys[0];
+ B = GetUi32(buf + 4) ^ Keys[1];
+ C = GetUi32(buf + 8) ^ Keys[2];
+ D = GetUi32(buf + 12) ^ Keys[3];
+
+ if (!encrypt)
+ memcpy(inBuf, buf, sizeof(inBuf));
+
+ for (int i = 0; i < kNumRounds; i++)
+ {
+ UInt32 key = Keys[(encrypt ? i : (kNumRounds - 1 - i)) & 3];
+ T = ((C + rotlFixed(D, 11)) ^ key);
+ TA = A ^ SubstLong(T);
+ T = ((D ^ rotlFixed(C, 17)) + key);
+ TB = B ^ SubstLong(T);
+ A = C;
+ B = D;
+ C = TA;
+ D = TB;
+ }
+
+ SetUi32(buf + 0, C ^ Keys[0]);
+ SetUi32(buf + 4, D ^ Keys[1]);
+ SetUi32(buf + 8, A ^ Keys[2]);
+ SetUi32(buf + 12, B ^ Keys[3]);
+
+ UpdateKeys(encrypt ? buf : inBuf);
+}
+
+STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
+{
+ _cipher.SetPassword(data, size);
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::Init()
+{
+ return S_OK;
+}
+
+static const UInt32 kBlockSize = 16;
+
+STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
+{
+ if (size == 0)
+ return 0;
+ if (size < kBlockSize)
+ return kBlockSize;
+ UInt32 i;
+ size -= kBlockSize;
+ for (i = 0; i <= size; i += kBlockSize)
+ _cipher.DecryptBlock(data + i);
+ return i;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.h
new file mode 100644
index 000000000..b9648f59d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.h
@@ -0,0 +1,50 @@
+// Crypto/Rar20Crypto.h
+
+#ifndef __CRYPTO_RAR20_CRYPTO_H
+#define __CRYPTO_RAR20_CRYPTO_H
+
+#include "Common/MyCom.h"
+
+#include "../ICoder.h"
+#include "../IPassword.h"
+
+namespace NCrypto {
+namespace NRar20 {
+
+class CData
+{
+ Byte SubstTable[256];
+ UInt32 Keys[4];
+
+ UInt32 SubstLong(UInt32 t)
+ {
+ return (UInt32)SubstTable[(int)t & 255] |
+ ((UInt32)SubstTable[(int)(t >> 8) & 255] << 8) |
+ ((UInt32)SubstTable[(int)(t >> 16) & 255] << 16) |
+ ((UInt32)SubstTable[(int)(t >> 24) & 255] << 24);
+ }
+ void UpdateKeys(const Byte *data);
+ void CryptBlock(Byte *buf, bool encrypt);
+public:
+ void EncryptBlock(Byte *buf) { CryptBlock(buf, true); }
+ void DecryptBlock(Byte *buf) { CryptBlock(buf, false); }
+ void SetPassword(const Byte *password, UInt32 passwordLen);
+};
+
+class CDecoder:
+ public ICompressFilter,
+ public ICryptoSetPassword,
+ public CMyUnknownImp
+{
+ CData _cipher;
+public:
+ MY_UNKNOWN_IMP1(ICryptoSetPassword)
+
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+ STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.cpp
new file mode 100644
index 000000000..bbb4ccefb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.cpp
@@ -0,0 +1,139 @@
+// Crypto/RarAes.cpp
+// Note: you must include MyAes.cpp to project to initialize AES tables
+
+#include "StdAfx.h"
+
+#include "RarAes.h"
+#include "Sha1.h"
+
+namespace NCrypto {
+namespace NRar29 {
+
+CDecoder::CDecoder():
+ _thereIsSalt(false),
+ _needCalculate(true),
+ _rar350Mode(false)
+{
+ for (int i = 0; i < sizeof(_salt); i++)
+ _salt[i] = 0;
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ bool thereIsSaltPrev = _thereIsSalt;
+ _thereIsSalt = false;
+ if (size == 0)
+ return S_OK;
+ if (size < 8)
+ return E_INVALIDARG;
+ _thereIsSalt = true;
+ bool same = false;
+ if (_thereIsSalt == thereIsSaltPrev)
+ {
+ same = true;
+ if (_thereIsSalt)
+ {
+ for (int i = 0; i < sizeof(_salt); i++)
+ if (_salt[i] != data[i])
+ {
+ same = false;
+ break;
+ }
+ }
+ }
+ for (int i = 0; i < sizeof(_salt); i++)
+ _salt[i] = data[i];
+ if (!_needCalculate && !same)
+ _needCalculate = true;
+ return S_OK;
+}
+
+static const int kMaxPasswordLength = 127 * 2;
+
+STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
+{
+ if (size > kMaxPasswordLength)
+ size = kMaxPasswordLength;
+ bool same = false;
+ if (size == buffer.GetCapacity())
+ {
+ same = true;
+ for (UInt32 i = 0; i < size; i++)
+ if (data[i] != buffer[i])
+ {
+ same = false;
+ break;
+ }
+ }
+ if (!_needCalculate && !same)
+ _needCalculate = true;
+ buffer.SetCapacity(size);
+ memcpy(buffer, data, size);
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::Init()
+{
+ Calculate();
+ Aes_SetKeyDecode(&Aes.aes, aesKey, kRarAesKeySize);
+ AesCbc_Init(&Aes, aesInit);
+ return S_OK;
+}
+
+STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
+{
+ return (UInt32)AesCbc_Decode(&Aes, data, size);
+}
+
+void CDecoder::Calculate()
+{
+ if (_needCalculate)
+ {
+ const int kSaltSize = 8;
+
+ Byte rawPassword[kMaxPasswordLength + kSaltSize];
+
+ memcpy(rawPassword, buffer, buffer.GetCapacity());
+
+ size_t rawLength = buffer.GetCapacity();
+
+ if (_thereIsSalt)
+ {
+ memcpy(rawPassword + rawLength, _salt, kSaltSize);
+ rawLength += kSaltSize;
+ }
+
+ NSha1::CContext sha;
+ sha.Init();
+
+ // seems rar reverts hash for sha.
+ const int hashRounds = 0x40000;
+ int i;
+ for (i = 0; i < hashRounds; i++)
+ {
+ sha.Update(rawPassword, rawLength, _rar350Mode);
+ Byte pswNum[3] = { (Byte)i, (Byte)(i >> 8), (Byte)(i >> 16) };
+ sha.Update(pswNum, 3, _rar350Mode);
+ if (i % (hashRounds / 16) == 0)
+ {
+ NSha1::CContext shaTemp = sha;
+ Byte digest[NSha1::kDigestSize];
+ shaTemp.Final(digest);
+ aesInit[i / (hashRounds / 16)] = (Byte)digest[4 * 4 + 3];
+ }
+ }
+ /*
+ // it's test message for sha
+ const char *message = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
+ sha.Update((const Byte *)message, strlen(message));
+ */
+ Byte digest[20];
+ sha.Final(digest);
+ for (i = 0; i < 4; i++)
+ for (int j = 0; j < 4; j++)
+ aesKey[i * 4 + j] = (digest[i * 4 + 3 - j]);
+ }
+ _needCalculate = false;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.h
new file mode 100644
index 000000000..374017b84
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.h
@@ -0,0 +1,59 @@
+// Crypto/RarAes.h
+
+#ifndef __CRYPTO_RAR_AES_H
+#define __CRYPTO_RAR_AES_H
+
+#include "../../../C/Aes.h"
+
+#include "Common/Buffer.h"
+#include "Common/MyCom.h"
+
+#include "../ICoder.h"
+#include "../IPassword.h"
+
+namespace NCrypto {
+namespace NRar29 {
+
+const UInt32 kRarAesKeySize = 16;
+
+class CDecoder:
+ public ICompressFilter,
+ public ICompressSetDecoderProperties2,
+ public ICryptoSetPassword,
+ public CMyUnknownImp
+{
+ Byte _salt[8];
+ bool _thereIsSalt;
+ CByteBuffer buffer;
+ Byte aesKey[kRarAesKeySize];
+ Byte aesInit[AES_BLOCK_SIZE];
+ bool _needCalculate;
+
+ CAesCbc Aes;
+
+ bool _rar350Mode;
+
+ void Calculate();
+
+public:
+
+ MY_UNKNOWN_IMP2(
+ ICryptoSetPassword,
+ ICompressSetDecoderProperties2)
+
+ STDMETHOD(Init)();
+
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+
+ STDMETHOD(CryptoSetPassword)(const Byte *aData, UInt32 aSize);
+
+ // ICompressSetDecoderProperties
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+ CDecoder();
+ void SetRar350Mode(bool rar350Mode) { _rar350Mode = rar350Mode; }
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.cpp
new file mode 100644
index 000000000..92174d18b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.cpp
@@ -0,0 +1,211 @@
+// Crypto/Sha1.cpp
+// This file is based on public domain
+// Steve Reid and Wei Dai's code from Crypto++
+
+#include "StdAfx.h"
+
+#include "../../../C/RotateDefs.h"
+
+#include "Sha1.h"
+
+namespace NCrypto {
+namespace NSha1 {
+
+// define it for speed optimization
+// #define _SHA1_UNROLL
+
+static const unsigned kNumW =
+ #ifdef _SHA1_UNROLL
+ 16;
+ #else
+ 80;
+ #endif
+
+
+#define w0(i) (W[(i)] = data[(i)])
+
+#ifdef _SHA1_UNROLL
+#define w1(i) (W[(i)&15] = rotlFixed(W[((i)-3)&15] ^ W[((i)-8)&15] ^ W[((i)-14)&15] ^ W[((i)-16)&15], 1))
+#else
+#define w1(i) (W[(i)] = rotlFixed(W[(i)-3] ^ W[(i)-8] ^ W[(i)-14] ^ W[(i)-16], 1))
+#endif
+
+#define f1(x,y,z) (z^(x&(y^z)))
+#define f2(x,y,z) (x^y^z)
+#define f3(x,y,z) ((x&y)|(z&(x|y)))
+#define f4(x,y,z) (x^y^z)
+
+#define RK1(a,b,c,d,e,i, f, w, k) e += f(b,c,d) + w(i) + k + rotlFixed(a,5); b = rotlFixed(b,30);
+
+#define R0(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f1, w0, 0x5A827999)
+#define R1(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f1, w1, 0x5A827999)
+#define R2(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f2, w1, 0x6ED9EBA1)
+#define R3(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f3, w1, 0x8F1BBCDC)
+#define R4(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f4, w1, 0xCA62C1D6)
+
+#define RX_1_4(rx1, rx4, i) rx1(a,b,c,d,e,i); rx4(e,a,b,c,d,i+1); rx4(d,e,a,b,c,i+2); rx4(c,d,e,a,b,i+3); rx4(b,c,d,e,a,i+4);
+#define RX_5(rx, i) RX_1_4(rx, rx, i);
+
+void CContextBase::Init()
+{
+ _state[0] = 0x67452301;
+ _state[1] = 0xEFCDAB89;
+ _state[2] = 0x98BADCFE;
+ _state[3] = 0x10325476;
+ _state[4] = 0xC3D2E1F0;
+ _count = 0;
+}
+
+void CContextBase::GetBlockDigest(UInt32 *data, UInt32 *destDigest, bool returnRes)
+{
+ UInt32 a, b, c, d, e;
+ UInt32 W[kNumW];
+
+ a = _state[0];
+ b = _state[1];
+ c = _state[2];
+ d = _state[3];
+ e = _state[4];
+ #ifdef _SHA1_UNROLL
+ RX_5(R0, 0); RX_5(R0, 5); RX_5(R0, 10);
+ #else
+ int i;
+ for (i = 0; i < 15; i += 5) { RX_5(R0, i); }
+ #endif
+
+ RX_1_4(R0, R1, 15);
+
+
+ #ifdef _SHA1_UNROLL
+ RX_5(R2, 20); RX_5(R2, 25); RX_5(R2, 30); RX_5(R2, 35);
+ RX_5(R3, 40); RX_5(R3, 45); RX_5(R3, 50); RX_5(R3, 55);
+ RX_5(R4, 60); RX_5(R4, 65); RX_5(R4, 70); RX_5(R4, 75);
+ #else
+ i = 20;
+ for (; i < 40; i += 5) { RX_5(R2, i); }
+ for (; i < 60; i += 5) { RX_5(R3, i); }
+ for (; i < 80; i += 5) { RX_5(R4, i); }
+ #endif
+
+ destDigest[0] = _state[0] + a;
+ destDigest[1] = _state[1] + b;
+ destDigest[2] = _state[2] + c;
+ destDigest[3] = _state[3] + d;
+ destDigest[4] = _state[4] + e;
+
+ if (returnRes)
+ for (int i = 0 ; i < 16; i++)
+ data[i] = W[kNumW - 16 + i];
+
+ // Wipe variables
+ // a = b = c = d = e = 0;
+}
+
+void CContextBase::PrepareBlock(UInt32 *block, unsigned size) const
+{
+ unsigned curBufferPos = size & 0xF;
+ block[curBufferPos++] = 0x80000000;
+ while (curBufferPos != (16 - 2))
+ block[curBufferPos++] = 0;
+ const UInt64 lenInBits = (_count << 9) + ((UInt64)size << 5);
+ block[curBufferPos++] = (UInt32)(lenInBits >> 32);
+ block[curBufferPos++] = (UInt32)(lenInBits);
+}
+
+void CContext::Update(Byte *data, size_t size, bool rar350Mode)
+{
+ bool returnRes = false;
+ unsigned curBufferPos = _count2;
+ while (size-- > 0)
+ {
+ int pos = (int)(curBufferPos & 3);
+ if (pos == 0)
+ _buffer[curBufferPos >> 2] = 0;
+ _buffer[curBufferPos >> 2] |= ((UInt32)*data++) << (8 * (3 - pos));
+ if (++curBufferPos == kBlockSize)
+ {
+ curBufferPos = 0;
+ CContextBase::UpdateBlock(_buffer, returnRes);
+ if (returnRes)
+ for (unsigned int i = 0; i < kBlockSizeInWords; i++)
+ {
+ UInt32 d = _buffer[i];
+ data[i * 4 + 0 - kBlockSize] = (Byte)(d);
+ data[i * 4 + 1 - kBlockSize] = (Byte)(d >> 8);
+ data[i * 4 + 2 - kBlockSize] = (Byte)(d >> 16);
+ data[i * 4 + 3 - kBlockSize] = (Byte)(d >> 24);
+ }
+ returnRes = rar350Mode;
+ }
+ }
+ _count2 = curBufferPos;
+}
+
+void CContext::Final(Byte *digest)
+{
+ const UInt64 lenInBits = (_count << 9) + ((UInt64)_count2 << 3);
+ unsigned curBufferPos = _count2;
+ int pos = (int)(curBufferPos & 3);
+ curBufferPos >>= 2;
+ if (pos == 0)
+ _buffer[curBufferPos] = 0;
+ _buffer[curBufferPos++] |= ((UInt32)0x80) << (8 * (3 - pos));
+
+ while (curBufferPos != (16 - 2))
+ {
+ curBufferPos &= 0xF;
+ if (curBufferPos == 0)
+ UpdateBlock();
+ _buffer[curBufferPos++] = 0;
+ }
+ _buffer[curBufferPos++] = (UInt32)(lenInBits >> 32);
+ _buffer[curBufferPos++] = (UInt32)(lenInBits);
+ UpdateBlock();
+
+ unsigned int i;
+ for (i = 0; i < kDigestSizeInWords; i++)
+ {
+ UInt32 state = _state[i] & 0xFFFFFFFF;
+ *digest++ = (Byte)(state >> 24);
+ *digest++ = (Byte)(state >> 16);
+ *digest++ = (Byte)(state >> 8);
+ *digest++ = (Byte)(state);
+ }
+ Init();
+}
+
+///////////////////////////
+// Words version
+
+void CContext32::Update(const UInt32 *data, size_t size)
+{
+ while (size-- > 0)
+ {
+ _buffer[_count2++] = *data++;
+ if (_count2 == kBlockSizeInWords)
+ {
+ _count2 = 0;
+ UpdateBlock();
+ }
+ }
+}
+
+void CContext32::Final(UInt32 *digest)
+{
+ const UInt64 lenInBits = (_count << 9) + ((UInt64)_count2 << 5);
+ unsigned curBufferPos = _count2;
+ _buffer[curBufferPos++] = 0x80000000;
+ while (curBufferPos != (16 - 2))
+ {
+ curBufferPos &= 0xF;
+ if (curBufferPos == 0)
+ UpdateBlock();
+ _buffer[curBufferPos++] = 0;
+ }
+ _buffer[curBufferPos++] = (UInt32)(lenInBits >> 32);
+ _buffer[curBufferPos++] = (UInt32)(lenInBits);
+ GetBlockDigest(_buffer, digest);
+ Init();
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.h
new file mode 100644
index 000000000..405be2166
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.h
@@ -0,0 +1,68 @@
+// Crypto/Sha1.h
+// This file is based on public domain
+// Steve Reid and Wei Dai's code from Crypto++
+
+#ifndef __CRYPTO_SHA1_H
+#define __CRYPTO_SHA1_H
+
+#include <stddef.h>
+#include "../../Common/Types.h"
+
+// Sha1 implementation in RAR before version 3.60 has bug:
+// it changes data bytes in some cases.
+// So this class supports both versions: normal_SHA and rar3Mode
+
+namespace NCrypto {
+namespace NSha1 {
+
+const unsigned kBlockSize = 64;
+const unsigned kDigestSize = 20;
+
+const unsigned kBlockSizeInWords = (kBlockSize >> 2);
+const unsigned kDigestSizeInWords = (kDigestSize >> 2);
+
+class CContextBase
+{
+protected:
+ UInt32 _state[5];
+ UInt64 _count;
+ void UpdateBlock(UInt32 *data, bool returnRes = false)
+ {
+ GetBlockDigest(data, _state, returnRes);
+ _count++;
+ }
+public:
+ void Init();
+ void GetBlockDigest(UInt32 *blockData, UInt32 *destDigest, bool returnRes = false);
+ // PrepareBlock can be used only when size <= 13. size in Words
+ void PrepareBlock(UInt32 *block, unsigned int size) const;
+};
+
+class CContextBase2: public CContextBase
+{
+protected:
+ unsigned _count2;
+ UInt32 _buffer[kBlockSizeInWords];
+ void UpdateBlock() { CContextBase::UpdateBlock(_buffer); }
+public:
+ void Init() { CContextBase::Init(); _count2 = 0; }
+};
+
+class CContext: public CContextBase2
+{
+public:
+ void Update(Byte *data, size_t size, bool rar350Mode = false);
+ void Update(const Byte *data, size_t size) { Update((Byte *)data, size, false); }
+ void Final(Byte *digest);
+};
+
+class CContext32: public CContextBase2
+{
+public:
+ void Update(const UInt32 *data, size_t size);
+ void Final(UInt32 *digest);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.cpp
new file mode 100644
index 000000000..beb24217c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.cpp
@@ -0,0 +1,209 @@
+// Crypto/WzAes.cpp
+/*
+This code implements Brian Gladman's scheme
+specified in password Based File Encryption Utility.
+
+Note: you must include MyAes.cpp to project to initialize AES tables
+*/
+
+#include "StdAfx.h"
+
+#include "../Common/StreamObjects.h"
+#include "../Common/StreamUtils.h"
+
+#include "Pbkdf2HmacSha1.h"
+#include "RandGen.h"
+#include "WzAes.h"
+
+// define it if you don't want to use speed-optimized version of Pbkdf2HmacSha1
+// #define _NO_WZAES_OPTIMIZATIONS
+
+namespace NCrypto {
+namespace NWzAes {
+
+const unsigned int kAesKeySizeMax = 32;
+
+static const UInt32 kNumKeyGenIterations = 1000;
+
+STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
+{
+ if(size > kPasswordSizeMax)
+ return E_INVALIDARG;
+ _key.Password.SetCapacity(size);
+ memcpy(_key.Password, data, size);
+ return S_OK;
+}
+
+#define SetUi32(p, d) { UInt32 x = (d); (p)[0] = (Byte)x; (p)[1] = (Byte)(x >> 8); \
+ (p)[2] = (Byte)(x >> 16); (p)[3] = (Byte)(x >> 24); }
+
+void CBaseCoder::EncryptData(Byte *data, UInt32 size)
+{
+ unsigned int pos = _blockPos;
+ for (; size > 0; size--)
+ {
+ if (pos == AES_BLOCK_SIZE)
+ {
+ if (++_counter[0] == 0)
+ _counter[1]++;
+ UInt32 temp[4];
+ Aes_Encode32(&Aes, temp, _counter);
+ SetUi32(_buffer, temp[0]);
+ SetUi32(_buffer + 4, temp[1]);
+ SetUi32(_buffer + 8, temp[2]);
+ SetUi32(_buffer + 12, temp[3]);
+ pos = 0;
+ }
+ *data++ ^= _buffer[pos++];
+ }
+ _blockPos = pos;
+}
+
+#ifndef _NO_WZAES_OPTIMIZATIONS
+
+static void BytesToBeUInt32s(const Byte *src, UInt32 *dest, int destSize)
+{
+ for (int i = 0 ; i < destSize; i++)
+ dest[i] =
+ ((UInt32)(src[i * 4 + 0]) << 24) |
+ ((UInt32)(src[i * 4 + 1]) << 16) |
+ ((UInt32)(src[i * 4 + 2]) << 8) |
+ ((UInt32)(src[i * 4 + 3]));
+}
+
+#endif
+
+STDMETHODIMP CBaseCoder::Init()
+{
+ UInt32 keySize = _key.GetKeySize();
+ UInt32 keysTotalSize = 2 * keySize + kPwdVerifCodeSize;
+ Byte buf[2 * kAesKeySizeMax + kPwdVerifCodeSize];
+
+ // for (int ii = 0; ii < 1000; ii++)
+ {
+ #ifdef _NO_WZAES_OPTIMIZATIONS
+
+ NSha1::Pbkdf2Hmac(
+ _key.Password, _key.Password.GetCapacity(),
+ _key.Salt, _key.GetSaltSize(),
+ kNumKeyGenIterations,
+ buf, keysTotalSize);
+
+ #else
+
+ UInt32 buf32[(2 * kAesKeySizeMax + kPwdVerifCodeSize + 3) / 4];
+ UInt32 key32SizeTotal = (keysTotalSize + 3) / 4;
+ UInt32 salt[kSaltSizeMax * 4];
+ UInt32 saltSizeInWords = _key.GetSaltSize() / 4;
+ BytesToBeUInt32s(_key.Salt, salt, saltSizeInWords);
+ NSha1::Pbkdf2Hmac32(
+ _key.Password, _key.Password.GetCapacity(),
+ salt, saltSizeInWords,
+ kNumKeyGenIterations,
+ buf32, key32SizeTotal);
+ for (UInt32 j = 0; j < keysTotalSize; j++)
+ buf[j] = (Byte)(buf32[j / 4] >> (24 - 8 * (j & 3)));
+
+ #endif
+ }
+
+ _hmac.SetKey(buf + keySize, keySize);
+ memcpy(_key.PwdVerifComputed, buf + 2 * keySize, kPwdVerifCodeSize);
+
+ _blockPos = AES_BLOCK_SIZE;
+ for (int i = 0; i < 4; i++)
+ _counter[i] = 0;
+
+ Aes_SetKeyEncode(&Aes, buf, keySize);
+ return S_OK;
+}
+
+/*
+STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
+{
+ Byte keySizeMode = 3;
+ return outStream->Write(&keySizeMode, 1, NULL);
+}
+*/
+
+HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream)
+{
+ UInt32 saltSize = _key.GetSaltSize();
+ g_RandomGenerator.Generate(_key.Salt, saltSize);
+ Init();
+ RINOK(WriteStream(outStream, _key.Salt, saltSize));
+ return WriteStream(outStream, _key.PwdVerifComputed, kPwdVerifCodeSize);
+}
+
+HRESULT CEncoder::WriteFooter(ISequentialOutStream *outStream)
+{
+ Byte mac[kMacSize];
+ _hmac.Final(mac, kMacSize);
+ return WriteStream(outStream, mac, kMacSize);
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size != 1)
+ return E_INVALIDARG;
+ _key.Init();
+ Byte keySizeMode = data[0];
+ if (keySizeMode < 1 || keySizeMode > 3)
+ return E_INVALIDARG;
+ _key.KeySizeMode = keySizeMode;
+ return S_OK;
+}
+
+HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream)
+{
+ UInt32 saltSize = _key.GetSaltSize();
+ UInt32 extraSize = saltSize + kPwdVerifCodeSize;
+ Byte temp[kSaltSizeMax + kPwdVerifCodeSize];
+ RINOK(ReadStream_FAIL(inStream, temp, extraSize));
+ UInt32 i;
+ for (i = 0; i < saltSize; i++)
+ _key.Salt[i] = temp[i];
+ for (i = 0; i < kPwdVerifCodeSize; i++)
+ _pwdVerifFromArchive[i] = temp[saltSize + i];
+ return S_OK;
+}
+
+static bool CompareArrays(const Byte *p1, const Byte *p2, UInt32 size)
+{
+ for (UInt32 i = 0; i < size; i++)
+ if (p1[i] != p2[i])
+ return false;
+ return true;
+}
+
+bool CDecoder::CheckPasswordVerifyCode()
+{
+ return CompareArrays(_key.PwdVerifComputed, _pwdVerifFromArchive, kPwdVerifCodeSize);
+}
+
+HRESULT CDecoder::CheckMac(ISequentialInStream *inStream, bool &isOK)
+{
+ isOK = false;
+ Byte mac1[kMacSize];
+ RINOK(ReadStream_FAIL(inStream, mac1, kMacSize));
+ Byte mac2[kMacSize];
+ _hmac.Final(mac2, kMacSize);
+ isOK = CompareArrays(mac1, mac2, kMacSize);
+ return S_OK;
+}
+
+STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
+{
+ EncryptData(data, size);
+ _hmac.Update(data, size);
+ return size;
+}
+
+STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
+{
+ _hmac.Update(data, size);
+ EncryptData(data, size);
+ return size;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.h
new file mode 100644
index 000000000..22f4d4dd3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.h
@@ -0,0 +1,116 @@
+// Crypto/WzAes.h
+/*
+This code implements Brian Gladman's scheme
+specified in password Based File Encryption Utility:
+ - AES encryption (128,192,256-bit) in Counter (CTR) mode.
+ - HMAC-SHA1 authentication for encrypted data (10 bytes)
+ - Keys are derived by PPKDF2(RFC2898)-HMAC-SHA1 from ASCII password and
+ Salt (saltSize = aesKeySize / 2).
+ - 2 bytes contain Password Verifier's Code
+*/
+
+#ifndef __CRYPTO_WZ_AES_H
+#define __CRYPTO_WZ_AES_H
+
+#include "../../../C/Aes.h"
+
+#include "Common/Buffer.h"
+#include "Common/MyCom.h"
+#include "Common/MyVector.h"
+
+#include "../ICoder.h"
+#include "../IPassword.h"
+
+#include "HmacSha1.h"
+
+namespace NCrypto {
+namespace NWzAes {
+
+const unsigned int kSaltSizeMax = 16;
+const unsigned int kMacSize = 10;
+
+const UInt32 kPasswordSizeMax = 99; // 128;
+
+// Password Verification Code Size
+const unsigned int kPwdVerifCodeSize = 2;
+
+class CKeyInfo
+{
+public:
+ Byte KeySizeMode; // 1 - 128-bit , 2 - 192-bit , 3 - 256-bit
+ Byte Salt[kSaltSizeMax];
+ Byte PwdVerifComputed[kPwdVerifCodeSize];
+
+ CByteBuffer Password;
+
+ UInt32 GetKeySize() const { return (8 * (KeySizeMode & 3) + 8); }
+ UInt32 GetSaltSize() const { return (4 * (KeySizeMode & 3) + 4); }
+
+ CKeyInfo() { Init(); }
+ void Init() { KeySizeMode = 3; }
+};
+
+class CBaseCoder:
+ public ICompressFilter,
+ public ICryptoSetPassword,
+ public CMyUnknownImp
+{
+protected:
+ CKeyInfo _key;
+ UInt32 _counter[AES_BLOCK_SIZE / 4];
+ Byte _buffer[AES_BLOCK_SIZE];
+ NSha1::CHmac _hmac;
+ unsigned int _blockPos;
+ Byte _pwdVerifFromArchive[kPwdVerifCodeSize];
+
+ void EncryptData(Byte *data, UInt32 size);
+
+ CAes Aes;
+
+public:
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) = 0;
+
+ STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
+
+ UInt32 GetHeaderSize() const { return _key.GetSaltSize() + kPwdVerifCodeSize; }
+};
+
+class CEncoder:
+ public CBaseCoder
+ // public ICompressWriteCoderProperties
+{
+public:
+ MY_UNKNOWN_IMP1(ICryptoSetPassword)
+ // ICompressWriteCoderProperties
+ // STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+ HRESULT WriteHeader(ISequentialOutStream *outStream);
+ HRESULT WriteFooter(ISequentialOutStream *outStream);
+ bool SetKeyMode(Byte mode)
+ {
+ if (mode < 1 || mode > 3)
+ return false;
+ _key.KeySizeMode = mode;
+ return true;
+ }
+};
+
+class CDecoder:
+ public CBaseCoder,
+ public ICompressSetDecoderProperties2
+{
+public:
+ MY_UNKNOWN_IMP2(
+ ICryptoSetPassword,
+ ICompressSetDecoderProperties2)
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+ HRESULT ReadHeader(ISequentialInStream *inStream);
+ bool CheckPasswordVerifyCode();
+ HRESULT CheckMac(ISequentialInStream *inStream, bool &isOK);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.cpp
new file mode 100644
index 000000000..f5972c572
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.cpp
@@ -0,0 +1,128 @@
+// Crypto/ZipCrypto.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/7zCrc.h"
+
+#include "../Common/StreamUtils.h"
+
+#include "RandGen.h"
+#include "ZipCrypto.h"
+
+namespace NCrypto {
+namespace NZip {
+
+void CCipher::UpdateKeys(Byte b)
+{
+ Keys[0] = CRC_UPDATE_BYTE(Keys[0], b);
+ Keys[1] += Keys[0] & 0xff;
+ Keys[1] = Keys[1] * 134775813L + 1;
+ Keys[2] = CRC_UPDATE_BYTE(Keys[2], (Byte)(Keys[1] >> 24));
+}
+
+void CCipher::SetPassword(const Byte *password, UInt32 passwordLen)
+{
+ Keys[0] = 305419896L;
+ Keys[1] = 591751049L;
+ Keys[2] = 878082192L;
+ for (UInt32 i = 0; i < passwordLen; i++)
+ UpdateKeys(password[i]);
+}
+
+Byte CCipher::DecryptByteSpec()
+{
+ UInt32 temp = Keys[2] | 2;
+ return (Byte)((temp * (temp ^ 1)) >> 8);
+}
+
+Byte CCipher::DecryptByte(Byte b)
+{
+ Byte c = (Byte)(b ^ DecryptByteSpec());
+ UpdateKeys(c);
+ return c;
+}
+
+Byte CCipher::EncryptByte(Byte b)
+{
+ Byte c = (Byte)(b ^ DecryptByteSpec());
+ UpdateKeys(b);
+ return c;
+}
+
+void CCipher::DecryptHeader(Byte *buf)
+{
+ for (unsigned i = 0; i < kHeaderSize; i++)
+ buf[i] = DecryptByte(buf[i]);
+}
+
+void CCipher::EncryptHeader(Byte *buf)
+{
+ for (unsigned i = 0; i < kHeaderSize; i++)
+ buf[i] = EncryptByte(buf[i]);
+}
+
+STDMETHODIMP CEncoder::CryptoSetPassword(const Byte *data, UInt32 size)
+{
+ _cipher.SetPassword(data, size);
+ return S_OK;
+}
+
+STDMETHODIMP CEncoder::CryptoSetCRC(UInt32 crc)
+{
+ _crc = crc;
+ return S_OK;
+}
+
+STDMETHODIMP CEncoder::Init()
+{
+ return S_OK;
+}
+
+HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream)
+{
+ Byte header[kHeaderSize];
+ g_RandomGenerator.Generate(header, kHeaderSize - 2);
+
+ header[kHeaderSize - 1] = Byte(_crc >> 24);
+ header[kHeaderSize - 2] = Byte(_crc >> 16);
+
+ _cipher.EncryptHeader(header);
+ return WriteStream(outStream, header, kHeaderSize);
+}
+
+STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
+{
+ UInt32 i;
+ for (i = 0; i < size; i++)
+ data[i] = _cipher.EncryptByte(data[i]);
+ return i;
+}
+
+STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
+{
+ _cipher.SetPassword(data, size);
+ return S_OK;
+}
+
+HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream)
+{
+ Byte header[kHeaderSize];
+ RINOK(ReadStream_FAIL(inStream, header, kHeaderSize));
+ _cipher.DecryptHeader(header);
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::Init()
+{
+ return S_OK;
+}
+
+STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
+{
+ UInt32 i;
+ for (i = 0; i < size; i++)
+ data[i] = _cipher.DecryptByte(data[i]);
+ return i;
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.h
new file mode 100644
index 000000000..040ebb095
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.h
@@ -0,0 +1,71 @@
+// Crypto/ZipCrypto.h
+
+#ifndef __CRYPTO_ZIP_CRYPTO_H
+#define __CRYPTO_ZIP_CRYPTO_H
+
+#include "Common/MyCom.h"
+
+#include "../ICoder.h"
+#include "../IPassword.h"
+
+namespace NCrypto {
+namespace NZip {
+
+const unsigned kHeaderSize = 12;
+
+class CCipher
+{
+ UInt32 Keys[3];
+
+ void UpdateKeys(Byte b);
+ Byte DecryptByteSpec();
+public:
+ void SetPassword(const Byte *password, UInt32 passwordLen);
+ Byte DecryptByte(Byte b);
+ Byte EncryptByte(Byte b);
+ void DecryptHeader(Byte *buf);
+ void EncryptHeader(Byte *buf);
+};
+
+class CEncoder :
+ public ICompressFilter,
+ public ICryptoSetPassword,
+ public ICryptoSetCRC,
+ public CMyUnknownImp
+{
+ CCipher _cipher;
+ UInt32 _crc;
+public:
+ MY_UNKNOWN_IMP2(
+ ICryptoSetPassword,
+ ICryptoSetCRC
+ )
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+
+ STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
+ STDMETHOD(CryptoSetCRC)(UInt32 crc);
+ HRESULT WriteHeader(ISequentialOutStream *outStream);
+};
+
+
+class CDecoder:
+ public ICompressFilter,
+ public ICryptoSetPassword,
+ public CMyUnknownImp
+{
+ CCipher _cipher;
+public:
+ MY_UNKNOWN_IMP1(ICryptoSetPassword)
+
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+ STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
+
+ HRESULT ReadHeader(ISequentialInStream *inStream);
+};
+
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.cpp
new file mode 100644
index 000000000..be5b42754
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.cpp
@@ -0,0 +1,177 @@
+// Crypto/ZipStrong.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/7zCrc.h"
+#include "../../../C/CpuArch.h"
+
+#include "../Common/StreamUtils.h"
+
+#include "MyAes.h"
+#include "Sha1.h"
+#include "ZipStrong.h"
+
+namespace NCrypto {
+namespace NZipStrong {
+
+static const UInt16 kAES128 = 0x660E;
+
+// DeriveKey* function is similar to CryptDeriveKey() from Windows.
+// But MSDN tells that we need such scheme only if
+// "the required key length is longer than the hash value"
+// but ZipStrong uses it always.
+
+static void DeriveKey2(const Byte *digest, Byte c, Byte *dest)
+{
+ Byte buf[64];
+ memset(buf, c, 64);
+ for (unsigned i = 0; i < NSha1::kDigestSize; i++)
+ buf[i] ^= digest[i];
+ NSha1::CContext sha;
+ sha.Init();
+ sha.Update(buf, 64);
+ sha.Final(dest);
+}
+
+static void DeriveKey(NSha1::CContext &sha, Byte *key)
+{
+ Byte digest[NSha1::kDigestSize];
+ sha.Final(digest);
+ Byte temp[NSha1::kDigestSize * 2];
+ DeriveKey2(digest, 0x36, temp);
+ DeriveKey2(digest, 0x5C, temp + NSha1::kDigestSize);
+ memcpy(key, temp, 32);
+}
+
+void CKeyInfo::SetPassword(const Byte *data, UInt32 size)
+{
+ NSha1::CContext sha;
+ sha.Init();
+ sha.Update(data, size);
+ DeriveKey(sha, MasterKey);
+}
+
+STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
+{
+ _key.SetPassword(data, size);
+ return S_OK;
+}
+
+STDMETHODIMP CBaseCoder::Init()
+{
+ return S_OK;
+}
+
+HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream, UInt32 /* crc */, UInt64 /* unpackSize */)
+{
+ Byte temp[4];
+ RINOK(ReadStream_FALSE(inStream, temp, 2));
+ _ivSize = GetUi16(temp);
+ if (_ivSize == 0)
+ {
+ return E_NOTIMPL;
+ /*
+ SetUi32(_iv, crc);
+ for (int i = 0; i < 8; i++)
+ _iv[4 + i] = (Byte)(unpackSize >> (8 * i));
+ SetUi32(_iv + 12, 0);
+ */
+ }
+ else if (_ivSize == 16)
+ {
+ RINOK(ReadStream_FALSE(inStream, _iv, _ivSize));
+ }
+ else
+ return E_NOTIMPL;
+ RINOK(ReadStream_FALSE(inStream, temp, 4));
+ _remSize = GetUi32(temp);
+ if (_remSize > _buf.GetCapacity())
+ {
+ _buf.Free();
+ _buf.SetCapacity(_remSize);
+ }
+ return ReadStream_FALSE(inStream, _buf, _remSize);
+}
+
+HRESULT CDecoder::CheckPassword(bool &passwOK)
+{
+ passwOK = false;
+ if (_remSize < 10)
+ return E_NOTIMPL;
+ Byte *p = _buf;
+ UInt16 format = GetUi16(p);
+ if (format != 3)
+ return E_NOTIMPL;
+ UInt16 algId = GetUi16(p + 2);
+ if (algId < kAES128)
+ return E_NOTIMPL;
+ algId -= kAES128;
+ if (algId > 2)
+ return E_NOTIMPL;
+ UInt16 bitLen = GetUi16(p + 4);
+ UInt16 flags = GetUi16(p + 6);
+ if (algId * 64 + 128 != bitLen)
+ return E_NOTIMPL;
+ _key.KeySize = 16 + algId * 8;
+ if ((flags & 1) == 0)
+ return E_NOTIMPL;
+ UInt32 rdSize = GetUi16(p + 8);
+ UInt32 pos = 10;
+ Byte *rd = p + pos;
+ pos += rdSize;
+ if (pos + 4 > _remSize)
+ return E_NOTIMPL;
+ UInt32 reserved = GetUi32(p + pos);
+ pos += 4;
+ if (reserved != 0)
+ return E_NOTIMPL;
+ if (pos + 2 > _remSize)
+ return E_NOTIMPL;
+ UInt32 validSize = GetUi16(p + pos);
+ pos += 2;
+ Byte *validData = p + pos;
+ if (pos + validSize != _remSize)
+ return E_NOTIMPL;
+
+ if (!_aesFilter)
+ _aesFilter = new CAesCbcDecoder;
+
+ CMyComPtr<ICryptoProperties> cp;
+ RINOK(_aesFilter.QueryInterface(IID_ICryptoProperties, &cp));
+ {
+ RINOK(cp->SetKey(_key.MasterKey, _key.KeySize));
+ RINOK(cp->SetInitVector(_iv, 16));
+ _aesFilter->Init();
+ if (_aesFilter->Filter(rd, rdSize) != rdSize)
+ return E_NOTIMPL;
+ }
+
+ Byte fileKey[32];
+ NSha1::CContext sha;
+ sha.Init();
+ sha.Update(_iv, 16);
+ sha.Update(rd, rdSize - 16); // we don't use last 16 bytes (PAD bytes)
+ DeriveKey(sha, fileKey);
+
+ RINOK(cp->SetKey(fileKey, _key.KeySize));
+ RINOK(cp->SetInitVector(_iv, 16));
+ _aesFilter->Init();
+ if (_aesFilter->Filter(validData, validSize) != validSize)
+ return E_NOTIMPL;
+
+ if (validSize < 4)
+ return E_NOTIMPL;
+ validSize -= 4;
+ if (GetUi32(validData + validSize) != CrcCalc(validData, validSize))
+ return S_OK;
+ passwOK = true;
+ _aesFilter->Init();
+ return S_OK;
+}
+
+STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
+{
+ return _aesFilter->Filter(data, size);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.h
new file mode 100644
index 000000000..6ea00b344
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.h
@@ -0,0 +1,53 @@
+// Crypto/ZipStrong.h
+
+#ifndef __CRYPTO_ZIP_STRONG_H
+#define __CRYPTO_ZIP_STRONG_H
+
+#include "Common/MyCom.h"
+#include "Common/Buffer.h"
+
+#include "../ICoder.h"
+#include "../IPassword.h"
+
+namespace NCrypto {
+namespace NZipStrong {
+
+struct CKeyInfo
+{
+ Byte MasterKey[32];
+ UInt32 KeySize;
+ void SetPassword(const Byte *data, UInt32 size);
+};
+
+class CBaseCoder:
+ public ICompressFilter,
+ public ICryptoSetPassword,
+ public CMyUnknownImp
+{
+protected:
+ CKeyInfo _key;
+ CMyComPtr<ICompressFilter> _aesFilter;
+ CByteBuffer _buf;
+public:
+ STDMETHOD(Init)();
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) = 0;
+
+ STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
+};
+
+class CDecoder:
+ public CBaseCoder
+{
+ UInt32 _ivSize;
+ Byte _iv[16];
+ UInt32 _remSize;
+public:
+ MY_UNKNOWN_IMP1(ICryptoSetPassword)
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
+ HRESULT ReadHeader(ISequentialInStream *inStream, UInt32 crc, UInt64 unpackSize);
+ HRESULT CheckPassword(bool &passwOK);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/ICoder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/ICoder.h
new file mode 100644
index 000000000..b5d4d5567
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/ICoder.h
@@ -0,0 +1,179 @@
+// ICoder.h
+
+#ifndef __ICODER_H
+#define __ICODER_H
+
+#include "IStream.h"
+
+#define CODER_INTERFACE(i, x) DECL_INTERFACE(i, 4, x)
+
+CODER_INTERFACE(ICompressProgressInfo, 0x04)
+{
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize) PURE;
+};
+
+CODER_INTERFACE(ICompressCoder, 0x05)
+{
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress) PURE;
+};
+
+CODER_INTERFACE(ICompressCoder2, 0x18)
+{
+ STDMETHOD(Code)(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
+ ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
+ ICompressProgressInfo *progress) PURE;
+};
+
+namespace NCoderPropID
+{
+ enum EEnum
+ {
+ kDefaultProp = 0,
+ kDictionarySize,
+ kUsedMemorySize,
+ kOrder,
+ kBlockSize,
+ kPosStateBits,
+ kLitContextBits,
+ kLitPosBits,
+ kNumFastBytes,
+ kMatchFinder,
+ kMatchFinderCycles,
+ kNumPasses,
+ kAlgorithm,
+ kNumThreads,
+ kEndMarker
+ };
+}
+
+CODER_INTERFACE(ICompressSetCoderProperties, 0x20)
+{
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps) PURE;
+};
+
+/*
+CODER_INTERFACE(ICompressSetCoderProperties, 0x21)
+{
+ STDMETHOD(SetDecoderProperties)(ISequentialInStream *inStream) PURE;
+};
+*/
+
+CODER_INTERFACE(ICompressSetDecoderProperties2, 0x22)
+{
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size) PURE;
+};
+
+CODER_INTERFACE(ICompressWriteCoderProperties, 0x23)
+{
+ STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream) PURE;
+};
+
+CODER_INTERFACE(ICompressGetInStreamProcessedSize, 0x24)
+{
+ STDMETHOD(GetInStreamProcessedSize)(UInt64 *value) PURE;
+};
+
+CODER_INTERFACE(ICompressSetCoderMt, 0x25)
+{
+ STDMETHOD(SetNumberOfThreads)(UInt32 numThreads) PURE;
+};
+
+CODER_INTERFACE(ICompressGetSubStreamSize, 0x30)
+{
+ STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value) PURE;
+};
+
+CODER_INTERFACE(ICompressSetInStream, 0x31)
+{
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream) PURE;
+ STDMETHOD(ReleaseInStream)() PURE;
+};
+
+CODER_INTERFACE(ICompressSetOutStream, 0x32)
+{
+ STDMETHOD(SetOutStream)(ISequentialOutStream *outStream) PURE;
+ STDMETHOD(ReleaseOutStream)() PURE;
+};
+
+CODER_INTERFACE(ICompressSetInStreamSize, 0x33)
+{
+ STDMETHOD(SetInStreamSize)(const UInt64 *inSize) PURE;
+};
+
+CODER_INTERFACE(ICompressSetOutStreamSize, 0x34)
+{
+ STDMETHOD(SetOutStreamSize)(const UInt64 *outSize) PURE;
+};
+
+CODER_INTERFACE(ICompressFilter, 0x40)
+{
+ STDMETHOD(Init)() PURE;
+ STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) PURE;
+ // Filter return outSize (UInt32)
+ // if (outSize <= size): Filter have converted outSize bytes
+ // if (outSize > size): Filter have not converted anything.
+ // and it needs at least outSize bytes to convert one block
+ // (it's for crypto block algorithms).
+};
+
+CODER_INTERFACE(ICompressCodecsInfo, 0x60)
+{
+ STDMETHOD(GetNumberOfMethods)(UInt32 *numMethods) PURE;
+ STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) PURE;
+ STDMETHOD(CreateDecoder)(UInt32 index, const GUID *iid, void **coder) PURE;
+ STDMETHOD(CreateEncoder)(UInt32 index, const GUID *iid, void **coder) PURE;
+};
+CODER_INTERFACE(ISetCompressCodecsInfo, 0x61)
+{
+ STDMETHOD(SetCompressCodecsInfo)(ICompressCodecsInfo *compressCodecsInfo) PURE;
+};
+
+CODER_INTERFACE(ICryptoProperties, 0x80)
+{
+ STDMETHOD(SetKey)(const Byte *data, UInt32 size) PURE;
+ STDMETHOD(SetInitVector)(const Byte *data, UInt32 size) PURE;
+};
+
+/*
+CODER_INTERFACE(ICryptoResetSalt, 0x88)
+{
+ STDMETHOD(ResetSalt)() PURE;
+};
+*/
+
+CODER_INTERFACE(ICryptoResetInitVector, 0x8C)
+{
+ STDMETHOD(ResetInitVector)() PURE;
+};
+
+CODER_INTERFACE(ICryptoSetPassword, 0x90)
+{
+ STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size) PURE;
+};
+
+CODER_INTERFACE(ICryptoSetCRC, 0xA0)
+{
+ STDMETHOD(CryptoSetCRC)(UInt32 crc) PURE;
+};
+
+//////////////////////
+// It's for DLL file
+namespace NMethodPropID
+{
+ enum EEnum
+ {
+ kID,
+ kName,
+ kDecoder,
+ kEncoder,
+ kInStreams,
+ kOutStreams,
+ kDescription,
+ kDecoderIsAssigned,
+ kEncoderIsAssigned
+ };
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IDecl.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IDecl.h
new file mode 100644
index 000000000..8316eb3ac
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IDecl.h
@@ -0,0 +1,15 @@
+// IDecl.h
+
+#ifndef __IDECL_H
+#define __IDECL_H
+
+#include "../Common/MyUnknown.h"
+
+#define DECL_INTERFACE_SUB(i, base, groupId, subId) \
+DEFINE_GUID(IID_ ## i, \
+0x23170F69, 0x40C1, 0x278A, 0, 0, 0, (groupId), 0, (subId), 0, 0); \
+struct i: public base
+
+#define DECL_INTERFACE(i, groupId, subId) DECL_INTERFACE_SUB(i, IUnknown, groupId, subId)
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IPassword.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IPassword.h
new file mode 100644
index 000000000..3ca7b090e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IPassword.h
@@ -0,0 +1,24 @@
+// IPassword.h
+
+#ifndef __IPASSWORD_H
+#define __IPASSWORD_H
+
+#include "../Common/MyUnknown.h"
+#include "../Common/Types.h"
+
+#include "IDecl.h"
+
+#define PASSWORD_INTERFACE(i, x) DECL_INTERFACE(i, 5, x)
+
+PASSWORD_INTERFACE(ICryptoGetTextPassword, 0x10)
+{
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password) PURE;
+};
+
+PASSWORD_INTERFACE(ICryptoGetTextPassword2, 0x11)
+{
+ STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password) PURE;
+};
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IProgress.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IProgress.h
new file mode 100644
index 000000000..d6093f173
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IProgress.h
@@ -0,0 +1,33 @@
+// Interface/IProgress.h
+
+#ifndef __IPROGRESS_H
+#define __IPROGRESS_H
+
+#include "../Common/MyUnknown.h"
+#include "../Common/Types.h"
+
+#include "IDecl.h"
+
+#define INTERFACE_IProgress(x) \
+ STDMETHOD(SetTotal)(UInt64 total) x; \
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue) x; \
+
+DECL_INTERFACE(IProgress, 0, 5)
+{
+ INTERFACE_IProgress(PURE)
+};
+
+/*
+// {23170F69-40C1-278A-0000-000000050002}
+DEFINE_GUID(IID_IProgress2,
+0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02);
+MIDL_INTERFACE("23170F69-40C1-278A-0000-000000050002")
+IProgress2: public IUnknown
+{
+public:
+ STDMETHOD(SetTotal)(const UInt64 *total) PURE;
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue) PURE;
+};
+*/
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IStream.h
new file mode 100644
index 000000000..a177a9cb4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/IStream.h
@@ -0,0 +1,58 @@
+// IStream.h
+
+#ifndef __ISTREAM_H
+#define __ISTREAM_H
+
+#include "../Common/MyUnknown.h"
+#include "../Common/Types.h"
+
+#include "IDecl.h"
+
+#define STREAM_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 3, x)
+#define STREAM_INTERFACE(i, x) STREAM_INTERFACE_SUB(i, IUnknown, x)
+
+STREAM_INTERFACE(ISequentialInStream, 0x01)
+{
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) PURE;
+ /*
+ Out: if size != 0, return_value = S_OK and (*processedSize == 0),
+ then there are no more bytes in stream.
+ if (size > 0) && there are bytes in stream,
+ this function must read at least 1 byte.
+ This function is allowed to read less than number of remaining bytes in stream.
+ You must call Read function in loop, if you need exact amount of data
+ */
+};
+
+STREAM_INTERFACE(ISequentialOutStream, 0x02)
+{
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) PURE;
+ /*
+ if (size > 0) this function must write at least 1 byte.
+ This function is allowed to write less than "size".
+ You must call Write function in loop, if you need to write exact amount of data
+ */
+};
+
+STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03)
+{
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
+};
+
+STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04)
+{
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
+ STDMETHOD(SetSize)(Int64 newSize) PURE;
+};
+
+STREAM_INTERFACE(IStreamGetSize, 0x06)
+{
+ STDMETHOD(GetSize)(UInt64 *size) PURE;
+};
+
+STREAM_INTERFACE(IOutStreamFlush, 0x07)
+{
+ STDMETHOD(Flush)() PURE;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/MyVersion.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/MyVersion.h
new file mode 100644
index 000000000..9e307bb4b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/MyVersion.h
@@ -0,0 +1,11 @@
+#define MY_VER_MAJOR 9
+#define MY_VER_MINOR 04
+#define MY_VER_BUILD 0
+#define MY_VERSION "9.04 beta"
+#define MY_7ZIP_VERSION "7-Zip 9.04 beta"
+#define MY_DATE "2009-05-30"
+#define MY_COPYRIGHT "Copyright (c) 1999-2009 Igor Pavlov"
+#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE
+
+#define P7ZIP_VERSION "9.04"
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/PropID.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/PropID.h
new file mode 100644
index 000000000..d6f3a7c1b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/PropID.h
@@ -0,0 +1,75 @@
+// PropID.h
+
+#ifndef __7ZIP_PROPID_H
+#define __7ZIP_PROPID_H
+
+enum
+{
+ kpidNoProperty = 0,
+ kpidMainSubfile = 1,
+ kpidHandlerItemIndex = 2,
+ kpidPath,
+ kpidName,
+ kpidExtension,
+ kpidIsDir,
+ kpidSize,
+ kpidPackSize,
+ kpidAttrib,
+ kpidCTime,
+ kpidATime,
+ kpidMTime,
+ kpidSolid,
+ kpidCommented,
+ kpidEncrypted,
+ kpidSplitBefore,
+ kpidSplitAfter,
+ kpidDictionarySize,
+ kpidCRC,
+ kpidType,
+ kpidIsAnti,
+ kpidMethod,
+ kpidHostOS,
+ kpidFileSystem,
+ kpidUser,
+ kpidGroup,
+ kpidBlock,
+ kpidComment,
+ kpidPosition,
+ kpidPrefix,
+ kpidNumSubDirs,
+ kpidNumSubFiles,
+ kpidUnpackVer,
+ kpidVolume,
+ kpidIsVolume,
+ kpidOffset,
+ kpidLinks,
+ kpidNumBlocks,
+ kpidNumVolumes,
+ kpidTimeType,
+ kpidBit64,
+ kpidBigEndian,
+ kpidCpu,
+ kpidPhySize,
+ kpidHeadersSize,
+ kpidChecksum,
+ kpidCharacts,
+ kpidVa,
+ kpidId,
+ kpidShortName,
+ kpidCreatorApp,
+ kpidSectorSize,
+ kpidPosixAttrib,
+ kpidLink,
+
+ kpidTotalSize = 0x1100,
+ kpidFreeSpace,
+ kpidClusterSize,
+ kpidVolumeName,
+
+ kpidLocalName = 0x1200,
+ kpidProvider,
+
+ kpidUserDefined = 0x10000
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/Agent.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/Agent.cpp
new file mode 100644
index 000000000..0b8f7c370
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/Agent.cpp
@@ -0,0 +1,615 @@
+// Agent.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/Sort.h"
+
+#include "Common/ComTry.h"
+
+#include "../Common/ArchiveExtractCallback.h"
+
+#include "Agent.h"
+
+using namespace NWindows;
+
+STDMETHODIMP CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder)
+{
+ *agentFolder = this;
+ return S_OK;
+}
+
+void CAgentFolder::LoadFolder(CProxyFolder *folder)
+{
+ int i;
+ CProxyItem item;
+ item.Folder = folder;
+ for (i = 0; i < folder->Folders.Size(); i++)
+ {
+ item.Index = i;
+ _items.Add(item);
+ LoadFolder(&folder->Folders[i]);
+ }
+ int start = folder->Folders.Size();
+ for (i = 0; i < folder->Files.Size(); i++)
+ {
+ item.Index = start + i;
+ _items.Add(item);
+ }
+}
+
+STDMETHODIMP CAgentFolder::LoadItems()
+{
+ if (!_agentSpec->_archiveLink.IsOpen)
+ return E_FAIL;
+ _items.Clear();
+ if (_flatMode)
+ LoadFolder(_proxyFolderItem);
+ return S_OK;
+}
+
+STDMETHODIMP CAgentFolder::GetNumberOfItems(UInt32 *numItems)
+{
+ if (_flatMode)
+ *numItems = _items.Size();
+ else
+ *numItems = _proxyFolderItem->Folders.Size() +_proxyFolderItem->Files.Size();
+ return S_OK;
+}
+
+UString CAgentFolder::GetName(UInt32 index) const
+{
+ UInt32 realIndex;
+ const CProxyFolder *folder;
+ if (_flatMode)
+ {
+ const CProxyItem &item = _items[index];
+ folder = item.Folder;
+ realIndex = item.Index;
+ }
+ else
+ {
+ folder = _proxyFolderItem;
+ realIndex = index;
+ }
+
+ if (realIndex < (UInt32)folder->Folders.Size())
+ return folder->Folders[realIndex].Name;
+ return folder->Files[realIndex - folder->Folders.Size()].Name;
+}
+
+UString CAgentFolder::GetPrefix(UInt32 index) const
+{
+ if (!_flatMode)
+ return UString();
+ const CProxyItem &item = _items[index];
+ const CProxyFolder *folder = item.Folder;
+ UString path;
+ while (folder != _proxyFolderItem)
+ {
+ path = folder->Name + UString(WCHAR_PATH_SEPARATOR) + path;
+ folder = folder->Parent;
+ }
+ return path;
+}
+
+UString CAgentFolder::GetFullPathPrefixPlusPrefix(UInt32 index) const
+{
+ return _proxyFolderItem->GetFullPathPrefix() + GetPrefix(index);
+}
+
+void CAgentFolder::GetPrefixIfAny(UInt32 index, NCOM::CPropVariant &prop) const
+{
+ if (!_flatMode)
+ return;
+ prop = GetPrefix(index);
+}
+
+
+STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ const CProxyFolder *folder;
+ UInt32 realIndex;
+ if (_flatMode)
+ {
+ const CProxyItem &item = _items[itemIndex];
+ folder = item.Folder;
+ realIndex = item.Index;
+ }
+ else
+ {
+ folder = _proxyFolderItem;
+ realIndex = itemIndex;
+ }
+
+ if (realIndex < (UInt32)folder->Folders.Size())
+ {
+ const CProxyFolder &item = folder->Folders[realIndex];
+ if (!_flatMode && propID == kpidSize)
+ prop = item.Size;
+ else if (!_flatMode && propID == kpidPackSize)
+ prop = item.PackSize;
+ else
+ switch(propID)
+ {
+ case kpidIsDir: prop = true; break;
+ case kpidNumSubDirs: prop = item.NumSubFolders; break;
+ case kpidNumSubFiles: prop = item.NumSubFiles; break;
+ case kpidName: prop = item.Name; break;
+ case kpidCRC:
+ {
+ if (item.IsLeaf)
+ {
+ RINOK(_agentSpec->GetArchive()->GetProperty(item.Index, propID, value));
+ }
+ if (item.CrcIsDefined && value->vt == VT_EMPTY)
+ prop = item.Crc;
+ break;
+ }
+ case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
+
+ default:
+ if (item.IsLeaf)
+ return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
+ }
+ }
+ else
+ {
+ realIndex -= folder->Folders.Size();
+ const CProxyFile &item = folder->Files[realIndex];
+ switch(propID)
+ {
+ case kpidIsDir: prop = false; break;
+ case kpidName: prop = item.Name; break;
+ case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
+ default:
+ return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+HRESULT CAgentFolder::BindToFolder(CProxyFolder *folder, IFolderFolder **resultFolder)
+{
+ CMyComPtr<IFolderFolder> parentFolder;
+ if (folder->Parent != _proxyFolderItem)
+ {
+ RINOK(BindToFolder(folder->Parent, &parentFolder));
+ }
+ else
+ parentFolder = this;
+ CAgentFolder *folderSpec = new CAgentFolder;
+ CMyComPtr<IFolderFolder> agentFolder = folderSpec;
+ folderSpec->Init(_proxyArchive, folder, parentFolder, _agentSpec);
+ *resultFolder = agentFolder.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CAgentFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
+{
+ COM_TRY_BEGIN
+
+ CProxyFolder *folder;
+ UInt32 realIndex;
+ if (_flatMode)
+ {
+ const CProxyItem &item = _items[index];
+ folder = item.Folder;
+ realIndex = item.Index;
+ }
+ else
+ {
+ folder = _proxyFolderItem;
+ realIndex = index;
+ }
+ if (realIndex >= (UInt32)folder->Folders.Size())
+ return E_INVALIDARG;
+ return BindToFolder(&folder->Folders[realIndex], resultFolder);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ COM_TRY_BEGIN
+ int index = _proxyFolderItem->FindDirSubItemIndex(name);
+ if (index < 0)
+ return E_INVALIDARG;
+ return BindToFolder(index, resultFolder);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
+{
+ COM_TRY_BEGIN
+ CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
+ *resultFolder = parentFolder.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ CMyComPtr<IInArchiveGetStream> getStream;
+ _agentSpec->GetArchive()->QueryInterface(IID_IInArchiveGetStream, (void **)&getStream);
+ if (!getStream)
+ return S_OK;
+
+ const CProxyFolder *folder;
+ UInt32 realIndex;
+ if (_flatMode)
+ {
+ const CProxyItem &item = _items[index];
+ folder = item.Folder;
+ realIndex = item.Index;
+ }
+ else
+ {
+ folder = _proxyFolderItem;
+ realIndex = index;
+ }
+
+ UInt32 indexInArchive;
+ if (realIndex < (UInt32)folder->Folders.Size())
+ {
+ const CProxyFolder &item = folder->Folders[realIndex];
+ if (!item.IsLeaf)
+ return S_OK;
+ indexInArchive = item.Index;
+ }
+ else
+ indexInArchive = folder->Files[realIndex - folder->Folders.Size()].Index;
+ return getStream->GetStream(indexInArchive, stream);
+}
+
+STATPROPSTG kProperties[] =
+{
+ { NULL, kpidNumSubDirs, VT_UI4},
+ { NULL, kpidNumSubFiles, VT_UI4},
+ { NULL, kpidPrefix, VT_BSTR}
+};
+
+static const UInt32 kNumProperties = sizeof(kProperties) / sizeof(kProperties[0]);
+
+struct CArchiveItemPropertyTemp
+{
+ UString Name;
+ PROPID ID;
+ VARTYPE Type;
+};
+
+STDMETHODIMP CAgentFolder::GetNumberOfProperties(UInt32 *numProperties)
+{
+ COM_TRY_BEGIN
+ RINOK(_agentSpec->GetArchive()->GetNumberOfProperties(numProperties));
+ *numProperties += kNumProperties;
+ if (!_flatMode)
+ (*numProperties)--;
+ if (!_agentSpec->_proxyArchive->ThereIsPathProp)
+ (*numProperties)++;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ COM_TRY_BEGIN
+ UInt32 numProperties;
+ _agentSpec->GetArchive()->GetNumberOfProperties(&numProperties);
+ if (!_agentSpec->_proxyArchive->ThereIsPathProp)
+ {
+ if (index == 0)
+ {
+ *propID = kpidName;
+ *varType = VT_BSTR;
+ *name = 0;
+ return S_OK;
+ }
+ index--;
+ }
+
+ if (index < numProperties)
+ {
+ RINOK(_agentSpec->GetArchive()->GetPropertyInfo(index, name, propID, varType));
+ if (*propID == kpidPath)
+ *propID = kpidName;
+ }
+ else
+ {
+ const STATPROPSTG &srcItem = kProperties[index - numProperties];
+ *propID = srcItem.propid;
+ *varType = srcItem.vt;
+ *name = 0;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STATPROPSTG kFolderProps[] =
+{
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidNumSubDirs, VT_UI4},
+ { NULL, kpidNumSubFiles, VT_UI4},
+ { NULL, kpidCRC, VT_UI4}
+};
+
+static const UInt32 kNumFolderProps = sizeof(kFolderProps) / sizeof(kFolderProps[0]);
+
+STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidSize: prop = _proxyFolderItem->Size; break;
+ case kpidPackSize: prop = _proxyFolderItem->PackSize; break;
+ case kpidNumSubDirs: prop = _proxyFolderItem->NumSubFolders; break;
+ case kpidNumSubFiles: prop = _proxyFolderItem->NumSubFiles; break;
+ case kpidName: prop = _proxyFolderItem->Name; break;
+ case kpidPath: prop = _proxyFolderItem->GetFullPathPrefix(); break;
+ case kpidType: prop = UString(L"7-Zip.") + _agentSpec->ArchiveType; break;
+ case kpidCRC: if (_proxyFolderItem->CrcIsDefined) prop = _proxyFolderItem->Crc; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::GetNumberOfFolderProperties(UInt32 *numProperties)
+{
+ *numProperties = kNumFolderProps;
+ return S_OK;
+}
+
+STDMETHODIMP CAgentFolder::GetFolderPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ // if (index < kNumFolderProps)
+ {
+ const STATPROPSTG &srcItem = kFolderProps[index];
+ *propID = srcItem.propid;
+ *varType = srcItem.vt;
+ *name = 0;
+ return S_OK;
+ }
+}
+
+STDMETHODIMP CAgentFolder::GetFolderArchiveProperties(IFolderArchiveProperties **object)
+{
+ CMyComPtr<IFolderArchiveProperties> temp = _agentSpec;
+ *object = temp.Detach();
+ return S_OK;
+}
+
+#ifdef NEW_FOLDER_INTERFACE
+
+STDMETHODIMP CAgentFolder::SetFlatMode(Int32 flatMode)
+{
+ _flatMode = IntToBool(flatMode);
+ return S_OK;
+}
+
+#endif
+
+void CAgentFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const
+{
+ if (!_flatMode)
+ {
+ _proxyFolderItem->GetRealIndices(indices, numItems, realIndices);
+ return;
+ }
+ realIndices.Clear();
+ for(UInt32 i = 0; i < numItems; i++)
+ {
+ const CProxyItem &item = _items[indices[i]];
+ const CProxyFolder *folder = item.Folder;
+ UInt32 realIndex = item.Index;
+ if (realIndex < (UInt32)folder->Folders.Size())
+ continue;
+ realIndices.Add(folder->Files[realIndex - folder->Folders.Size()].Index);
+ }
+ HeapSort(&realIndices.Front(), realIndices.Size());
+}
+
+STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
+ UInt32 numItems,
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode,
+ const wchar_t *path,
+ Int32 testMode,
+ IFolderArchiveExtractCallback *extractCallback2)
+{
+ COM_TRY_BEGIN
+ CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
+ CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
+ UStringVector pathParts;
+ CProxyFolder *currentProxyFolder = _proxyFolderItem;
+ while (currentProxyFolder->Parent)
+ {
+ pathParts.Insert(0, currentProxyFolder->Name);
+ currentProxyFolder = currentProxyFolder->Parent;
+ }
+
+ /*
+ if (_flatMode)
+ pathMode = NExtract::NPathMode::kNoPathnames;
+ */
+
+ extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
+
+ extractCallbackSpec->Init(NULL, &_agentSpec->GetArc(),
+ extractCallback2,
+ false, testMode ? true : false, false,
+ (path ? path : L""),
+ pathParts,
+ (UInt64)(Int64)-1);
+ CUIntVector realIndices;
+ GetRealIndices(indices, numItems, realIndices);
+ return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
+ realIndices.Size(), testMode, extractCallback);
+ COM_TRY_END
+}
+
+/////////////////////////////////////////
+// CAgent
+
+CAgent::CAgent():
+ _proxyArchive(NULL),
+ _codecs(0)
+{
+}
+
+CAgent::~CAgent()
+{
+ if (_proxyArchive != NULL)
+ delete _proxyArchive;
+}
+
+STDMETHODIMP CAgent::Open(
+ IInStream *inStream,
+ const wchar_t *filePath,
+ BSTR *archiveType,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ _archiveFilePath = filePath;
+ NFile::NFind::CFileInfoW fi;
+ if (!inStream)
+ {
+ if (!fi.Find(_archiveFilePath))
+ return ::GetLastError();
+ if (fi.IsDir())
+ return E_FAIL;
+ }
+ CArcInfoEx archiverInfo0, archiverInfo1;
+
+ _compressCodecsInfo.Release();
+ _codecs = new CCodecs;
+ _compressCodecsInfo = _codecs;
+ RINOK(_codecs->Load());
+
+ RINOK(_archiveLink.Open(_codecs, CIntVector(), false, inStream, _archiveFilePath, openArchiveCallback));
+
+ CArc &arc = _archiveLink.Arcs.Back();
+ if (!inStream)
+ {
+ arc.MTimeDefined = !fi.IsDevice;
+ arc.MTime = fi.MTime;
+ }
+
+ ArchiveType = _codecs->Formats[arc.FormatIndex].Name;
+ if (archiveType == 0)
+ return S_OK;
+ return StringToBstr(ArchiveType, archiveType);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ if (_proxyArchive != NULL)
+ {
+ delete _proxyArchive;
+ _proxyArchive = NULL;
+ }
+ RINOK(_archiveLink.ReOpen(_codecs, _archiveFilePath, openArchiveCallback));
+ return ReadItems();
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::Close()
+{
+ COM_TRY_BEGIN
+ return _archiveLink.Close();
+ COM_TRY_END
+}
+
+/*
+STDMETHODIMP CAgent::EnumProperties(IEnumSTATPROPSTG **EnumProperties)
+{
+ return _archive->EnumProperties(EnumProperties);
+}
+*/
+
+HRESULT CAgent::ReadItems()
+{
+ if (_proxyArchive != NULL)
+ return S_OK;
+ _proxyArchive = new CProxyArchive();
+ return _proxyArchive->Load(GetArc(), NULL);
+}
+
+STDMETHODIMP CAgent::BindToRootFolder(IFolderFolder **resultFolder)
+{
+ COM_TRY_BEGIN
+ RINOK(ReadItems());
+ CAgentFolder *folderSpec = new CAgentFolder;
+ CMyComPtr<IFolderFolder> rootFolder = folderSpec;
+ folderSpec->Init(_proxyArchive, &_proxyArchive->RootFolder, NULL, this);
+ *resultFolder = rootFolder.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+
+STDMETHODIMP CAgent::Extract(
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode,
+ const wchar_t *path,
+ Int32 testMode,
+ IFolderArchiveExtractCallback *extractCallback2)
+{
+ COM_TRY_BEGIN
+ CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
+ CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
+ extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
+ extractCallbackSpec->Init(NULL, &GetArc(),
+ extractCallback2,
+ false, testMode ? true : false, false,
+ path,
+ UStringVector(),
+ (UInt64)(Int64)-1);
+ return GetArchive()->Extract(0, (UInt32)(Int32)-1, testMode, extractCallback);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetNumberOfProperties(UInt32 *numProperties)
+{
+ COM_TRY_BEGIN
+ return GetArchive()->GetNumberOfProperties(numProperties);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetPropertyInfo(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ COM_TRY_BEGIN
+ RINOK(GetArchive()->GetPropertyInfo(index, name, propID, varType));
+ if (*propID == kpidPath)
+ *propID = kpidName;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ return GetArchive()->GetArchiveProperty(propID, value);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetNumberOfArchiveProperties(UInt32 *numProperties)
+{
+ COM_TRY_BEGIN
+ return GetArchive()->GetNumberOfArchiveProperties(numProperties);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetArchivePropertyInfo(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ COM_TRY_BEGIN
+ return GetArchive()->GetArchivePropertyInfo(index,
+ name, propID, varType);
+ COM_TRY_END
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/Agent.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/Agent.h
new file mode 100644
index 000000000..b95725e49
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/Agent.h
@@ -0,0 +1,232 @@
+// Agent/Agent.h
+
+#ifndef __AGENT_AGENT_H
+#define __AGENT_AGENT_H
+
+#include "Common/MyCom.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/OpenArchive.h"
+#include "../Common/UpdateAction.h"
+
+#ifdef NEW_FOLDER_INTERFACE
+#include "../FileManager/IFolder.h"
+#include "../Common/LoadCodecs.h"
+#endif
+
+#include "AgentProxy.h"
+#include "IFolderArchive.h"
+
+class CAgentFolder;
+
+DECL_INTERFACE(IArchiveFolderInternal, 0x01, 0xC)
+{
+ STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder) PURE;
+};
+
+struct CProxyItem
+{
+ CProxyFolder *Folder;
+ UInt32 Index;
+};
+
+class CAgent;
+
+class CAgentFolder:
+ public IFolderFolder,
+ public IFolderProperties,
+ public IGetFolderArchiveProperties,
+ public IArchiveFolder,
+ public IArchiveFolderInternal,
+ public IInArchiveGetStream,
+#ifdef NEW_FOLDER_INTERFACE
+ public IFolderOperations,
+ public IFolderSetFlatMode,
+#endif
+ public CMyUnknownImp
+{
+public:
+
+ MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_ENTRY(IFolderFolder)
+ MY_QUERYINTERFACE_ENTRY(IFolderProperties)
+ MY_QUERYINTERFACE_ENTRY(IGetFolderArchiveProperties)
+ MY_QUERYINTERFACE_ENTRY(IArchiveFolder)
+ MY_QUERYINTERFACE_ENTRY(IArchiveFolderInternal)
+ MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
+ #ifdef NEW_FOLDER_INTERFACE
+ MY_QUERYINTERFACE_ENTRY(IFolderOperations)
+ MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
+ #endif
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ void LoadFolder(CProxyFolder *folder);
+ HRESULT BindToFolder(CProxyFolder *folder, IFolderFolder **resultFolder);
+ void GetRealIndices(const UINT32 *indices, UINT32 numItems, CUIntVector &realIndices) const;
+
+ INTERFACE_FolderFolder(;)
+ INTERFACE_FolderProperties(;)
+
+ STDMETHOD(GetFolderArchiveProperties)(IFolderArchiveProperties **object);
+
+ // IArchiveFolder
+ STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems,
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode,
+ const wchar_t *path,
+ Int32 testMode,
+ IFolderArchiveExtractCallback *extractCallback);
+
+ STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder);
+
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+
+ #ifdef NEW_FOLDER_INTERFACE
+ INTERFACE_FolderOperations(;)
+
+ STDMETHOD(SetFlatMode)(Int32 flatMode);
+ #endif
+
+ CAgentFolder(): _proxyFolderItem(NULL), _flatMode(0) {}
+
+ void Init(CProxyArchive *proxyHandler,
+ CProxyFolder *proxyFolderItem,
+ IFolderFolder *parentFolder,
+ CAgent *agent)
+ {
+ _proxyArchive = proxyHandler;
+ _proxyFolderItem = proxyFolderItem;
+ _parentFolder = parentFolder;
+ _agent = (IInFolderArchive *)agent;
+ _agentSpec = agent;
+ }
+
+ void GetPathParts(UStringVector &pathParts);
+ HRESULT CommonUpdateOperation(
+ bool deleteOperation,
+ bool createFolderOperation,
+ bool renameOperation,
+ const wchar_t *newItemName,
+ const NUpdateArchive::CActionSet *actionSet,
+ const UINT32 *indices, UINT32 numItems,
+ IFolderArchiveUpdateCallback *updateCallback100);
+
+
+ UString GetPrefix(UInt32 index) const;
+ UString GetName(UInt32 index) const;
+ UString GetFullPathPrefixPlusPrefix(UInt32 index) const;
+ void GetPrefixIfAny(UInt32 index, NWindows::NCOM::CPropVariant &propVariant) const;
+
+public:
+ CProxyArchive *_proxyArchive;
+ CProxyFolder *_proxyFolderItem;
+ CMyComPtr<IFolderFolder> _parentFolder;
+ CMyComPtr<IInFolderArchive> _agent;
+ CAgent *_agentSpec;
+
+ CRecordVector<CProxyItem> _items;
+ bool _flatMode;
+private:
+};
+
+class CAgent:
+ public IInFolderArchive,
+ public IFolderArchiveProperties,
+ #ifndef EXTRACT_ONLY
+ public IOutFolderArchive,
+ public ISetProperties,
+ #endif
+ public CMyUnknownImp
+{
+public:
+
+ MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_ENTRY(IInFolderArchive)
+ MY_QUERYINTERFACE_ENTRY(IFolderArchiveProperties)
+ #ifndef EXTRACT_ONLY
+ MY_QUERYINTERFACE_ENTRY(IOutFolderArchive)
+ MY_QUERYINTERFACE_ENTRY(ISetProperties)
+ #endif
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ INTERFACE_IInFolderArchive(;)
+ INTERFACE_IFolderArchiveProperties(;)
+
+ #ifndef EXTRACT_ONLY
+ INTERFACE_IOutFolderArchive(;)
+
+ HRESULT CommonUpdate(
+ const wchar_t *newArchiveName,
+ int numUpdateItems,
+ IArchiveUpdateCallback *updateCallback);
+
+ HRESULT CreateFolder(
+ const wchar_t *newArchiveName,
+ const wchar_t *folderName,
+ IFolderArchiveUpdateCallback *updateCallback100);
+
+ HRESULT RenameItem(
+ const wchar_t *newArchiveName,
+ const UINT32 *indices, UINT32 numItems,
+ const wchar_t *newItemName,
+ IFolderArchiveUpdateCallback *updateCallback100);
+
+ // ISetProperties
+ STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
+ #endif
+
+ CCodecs *_codecs;
+ CMyComPtr<ICompressCodecsInfo> _compressCodecsInfo;
+
+ CAgent();
+ ~CAgent();
+private:
+ HRESULT ReadItems();
+public:
+ CProxyArchive *_proxyArchive;
+ CArchiveLink _archiveLink;
+
+
+ UString ArchiveType;
+
+ UStringVector _names;
+ UString _folderPrefix;
+
+ UString _archiveNamePrefix;
+ CAgentFolder *_agentFolder;
+
+ UString _archiveFilePath;
+
+ #ifndef EXTRACT_ONLY
+ CObjectVector<UString> m_PropNames;
+ CObjectVector<NWindows::NCOM::CPropVariant> m_PropValues;
+ #endif
+
+ const CArc &GetArc() { return _archiveLink.Arcs.Back(); }
+ IInArchive *GetArchive() { return GetArc().Archive; }
+ bool CanUpdate() const { return _archiveLink.Arcs.Size() == 1; }
+};
+
+#ifdef NEW_FOLDER_INTERFACE
+class CArchiveFolderManager:
+ public IFolderManager,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IFolderManager)
+
+ INTERFACE_IFolderManager(;)
+
+ CArchiveFolderManager(): _codecs(0) {}
+private:
+ void LoadFormats();
+ int FindFormat(const UString &type);
+ CCodecs *_codecs;
+ CMyComPtr<ICompressCodecsInfo> _compressCodecsInfo;
+};
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentOut.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentOut.cpp
new file mode 100644
index 000000000..51a5affa1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentOut.cpp
@@ -0,0 +1,535 @@
+// AgentOut.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Defs.h"
+#include "Windows/FileDir.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+#include "Windows/Time.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../../Common/FileStreams.h"
+
+#include "../Common/EnumDirItems.h"
+#include "../Common/HandlerLoader.h"
+#include "../Common/OpenArchive.h"
+#include "../Common/UpdateCallback.h"
+#include "../Common/UpdatePair.h"
+
+#include "Agent.h"
+#include "UpdateCallbackAgent.h"
+
+using namespace NWindows;
+using namespace NCOM;
+
+STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
+{
+ _archiveNamePrefix.Empty();
+ if (folder == NULL)
+ {
+ _agentFolder = NULL;
+ return S_OK;
+ }
+ else
+ {
+ CMyComPtr<IFolderFolder> archiveFolder = folder;
+ CMyComPtr<IArchiveFolderInternal> archiveFolderInternal;
+ RINOK(archiveFolder.QueryInterface(IID_IArchiveFolderInternal, &archiveFolderInternal));
+ RINOK(archiveFolderInternal->GetAgentFolder(&_agentFolder));
+ }
+
+ UStringVector pathParts;
+ pathParts.Clear();
+ CMyComPtr<IFolderFolder> folderItem = folder;
+ if (folderItem != NULL)
+ for (;;)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ folderItem->BindToParentFolder(&newFolder);
+ if (newFolder == NULL)
+ break;
+
+ NCOM::CPropVariant prop;
+ if (folderItem->GetFolderProperty(kpidName, &prop) == S_OK)
+ if (prop.vt == VT_BSTR)
+ pathParts.Insert(0, (const wchar_t *)prop.bstrVal);
+ folderItem = newFolder;
+ }
+
+ for (int i = 0; i < pathParts.Size(); i++)
+ {
+ _archiveNamePrefix += pathParts[i];
+ _archiveNamePrefix += WCHAR_PATH_SEPARATOR;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix,
+ const wchar_t **names, UInt32 numNames)
+{
+ _folderPrefix = folderPrefix;
+ _names.Clear();
+ _names.Reserve(numNames);
+ for (UInt32 i = 0; i < numNames; i++)
+ _names.Add(names[i]);
+ return S_OK;
+}
+
+static HRESULT EnumerateArchiveItems(CAgent *agent,
+ const CProxyFolder &item,
+ const UString &prefix,
+ CObjectVector<CArcItem> &arcItems)
+{
+ int i;
+ for (i = 0; i < item.Files.Size(); i++)
+ {
+ const CProxyFile &fileItem = item.Files[i];
+ CArcItem ai;
+ RINOK(agent->GetArc().GetItemMTime(fileItem.Index, ai.MTime, ai.MTimeDefined));
+
+ CPropVariant property;
+ agent->GetArchive()->GetProperty(fileItem.Index, kpidSize, &property);
+ ai.SizeDefined = (property.vt != VT_EMPTY);
+ if (ai.SizeDefined)
+ ai.Size = ConvertPropVariantToUInt64(property);
+ ai.IsDir = false;
+ ai.Name = prefix + fileItem.Name;
+ ai.Censored = true; // test it
+ ai.IndexInServer = fileItem.Index;
+ arcItems.Add(ai);
+ }
+ for (i = 0; i < item.Folders.Size(); i++)
+ {
+ const CProxyFolder &dirItem = item.Folders[i];
+ UString fullName = prefix + dirItem.Name;
+ if (dirItem.IsLeaf)
+ {
+ CArcItem ai;
+ RINOK(agent->GetArc().GetItemMTime(dirItem.Index, ai.MTime, ai.MTimeDefined));
+ ai.IsDir = true;
+ ai.SizeDefined = false;
+ ai.Name = fullName;
+ ai.Censored = true; // test it
+ ai.IndexInServer = dirItem.Index;
+ arcItems.Add(ai);
+ }
+ RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(WCHAR_PATH_SEPARATOR), arcItems));
+ }
+ return S_OK;
+}
+
+struct CAgUpCallbackImp: public IUpdateProduceCallback
+{
+ const CObjectVector<CArcItem> *_arcItems;
+ IFolderArchiveUpdateCallback *_callback;
+
+ CAgUpCallbackImp(const CObjectVector<CArcItem> *a,
+ IFolderArchiveUpdateCallback *callback): _arcItems(a), _callback(callback) {}
+ HRESULT ShowDeleteFile(int arcIndex);
+};
+
+HRESULT CAgUpCallbackImp::ShowDeleteFile(int arcIndex)
+{
+ return _callback->DeleteOperation((*_arcItems)[arcIndex].Name);
+}
+
+STDMETHODIMP CAgent::DoOperation(
+ CCodecs *codecs,
+ int formatIndex,
+ const wchar_t *newArchiveName,
+ const Byte *stateActions,
+ const wchar_t *sfxModule,
+ IFolderArchiveUpdateCallback *updateCallback100)
+{
+ if (!CanUpdate())
+ return E_NOTIMPL;
+ NUpdateArchive::CActionSet actionSet;
+ int i;
+ for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
+ actionSet.StateActions[i] = (NUpdateArchive::NPairAction::EEnum)stateActions[i];
+
+ CDirItems dirItems;
+
+ {
+ UString folderPrefix = _folderPrefix;
+ NFile::NName::NormalizeDirPathPrefix(folderPrefix);
+ UStringVector errorPaths;
+ CRecordVector<DWORD> errorCodes;
+ dirItems.EnumerateDirItems2(folderPrefix, _archiveNamePrefix, _names, errorPaths, errorCodes);
+ if (errorCodes.Size() > 0)
+ return errorCodes.Front();
+ }
+
+ CMyComPtr<IOutArchive> outArchive;
+ if (GetArchive())
+ {
+ RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive));
+ }
+ else
+ {
+ if (formatIndex < 0)
+ return E_FAIL;
+ RINOK(codecs->CreateOutArchive(formatIndex, outArchive));
+ #ifdef EXTERNAL_CODECS
+ {
+ CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
+ outArchive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
+ if (setCompressCodecsInfo)
+ {
+ RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs));
+ }
+ }
+ #endif
+
+ }
+
+ NFileTimeType::EEnum fileTimeType;
+ UInt32 value;
+ RINOK(outArchive->GetFileTimeType(&value));
+
+ switch(value)
+ {
+ case NFileTimeType::kWindows:
+ case NFileTimeType::kDOS:
+ case NFileTimeType::kUnix:
+ fileTimeType = NFileTimeType::EEnum(value);
+ break;
+ default:
+ return E_FAIL;
+ }
+
+
+ CObjectVector<CArcItem> arcItems;
+ if (GetArchive())
+ {
+ RINOK(ReadItems());
+ EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", arcItems);
+ }
+
+ CRecordVector<CUpdatePair2> updatePairs2;
+
+ {
+ CRecordVector<CUpdatePair> updatePairs;
+ GetUpdatePairInfoList(dirItems, arcItems, fileTimeType, updatePairs);
+ CAgUpCallbackImp upCallback(&arcItems, updateCallback100);
+ UpdateProduce(updatePairs, actionSet, updatePairs2, &upCallback);
+ }
+
+ UInt32 numFiles = 0;
+ for (i = 0; i < updatePairs2.Size(); i++)
+ if (updatePairs2[i].NewData)
+ numFiles++;
+
+ if (updateCallback100)
+ {
+ RINOK(updateCallback100->SetNumFiles(numFiles));
+ }
+
+ CUpdateCallbackAgent updateCallbackAgent;
+ updateCallbackAgent.SetCallback(updateCallback100);
+ CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
+ CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec );
+
+ updateCallbackSpec->DirItems = &dirItems;
+ updateCallbackSpec->ArcItems = &arcItems;
+ updateCallbackSpec->UpdatePairs = &updatePairs2;
+ updateCallbackSpec->Archive = GetArchive();
+ updateCallbackSpec->Callback = &updateCallbackAgent;
+
+ COutFileStream *outStreamSpec = new COutFileStream;
+ CMyComPtr<IOutStream> outStream(outStreamSpec);
+ UString archiveName = newArchiveName;
+ {
+ UString resultPath;
+ int pos;
+ if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
+ return E_FAIL;
+ NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
+ }
+ if (!outStreamSpec->Create(archiveName, true))
+ {
+ // ShowLastErrorMessage();
+ return E_FAIL;
+ }
+
+ CMyComPtr<ISetProperties> setProperties;
+ if (outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties) == S_OK)
+ {
+ if (m_PropNames.Size() == 0)
+ {
+ RINOK(setProperties->SetProperties(0, 0, 0));
+ }
+ else
+ {
+ CRecordVector<const wchar_t *> names;
+ for(i = 0; i < m_PropNames.Size(); i++)
+ names.Add((const wchar_t *)m_PropNames[i]);
+
+ NWindows::NCOM::CPropVariant *propValues = new NWindows::NCOM::CPropVariant[m_PropValues.Size()];
+ try
+ {
+ for (int i = 0; i < m_PropValues.Size(); i++)
+ propValues[i] = m_PropValues[i];
+ RINOK(setProperties->SetProperties(&names.Front(), propValues, names.Size()));
+ }
+ catch(...)
+ {
+ delete []propValues;
+ return E_FAIL;
+ }
+ delete []propValues;
+ }
+ }
+ m_PropNames.Clear();
+ m_PropValues.Clear();
+
+ if (sfxModule != NULL)
+ {
+ CInFileStream *sfxStreamSpec = new CInFileStream;
+ CMyComPtr<IInStream> sfxStream(sfxStreamSpec);
+ if (!sfxStreamSpec->Open(sfxModule))
+ return E_FAIL;
+ // throw "Can't open sfx module";
+ RINOK(NCompress::CopyStream(sfxStream, outStream, NULL));
+ }
+
+ RINOK(outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback));
+ return outStreamSpec->Close();
+}
+
+STDMETHODIMP CAgent::DoOperation2(
+ const wchar_t *newArchiveName,
+ const Byte *stateActions,
+ const wchar_t *sfxModule,
+ IFolderArchiveUpdateCallback *updateCallback100)
+{
+ return DoOperation(_codecs, -1, newArchiveName,
+ stateActions, sfxModule, updateCallback100);
+}
+
+HRESULT CAgent::CommonUpdate(
+ const wchar_t *newArchiveName,
+ int numUpdateItems,
+ IArchiveUpdateCallback *updateCallback)
+{
+ if (!CanUpdate())
+ return E_NOTIMPL;
+ CMyComPtr<IOutArchive> outArchive;
+ RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive));
+
+ COutFileStream *outStreamSpec = new COutFileStream;
+ CMyComPtr<IOutStream> outStream(outStreamSpec);
+
+ UString archiveName = newArchiveName;
+ {
+ UString resultPath;
+ int pos;
+ if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
+ throw 141716;
+ NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
+ }
+
+ /*
+ bool isOK = false;
+ for (int i = 0; i < (1 << 16); i++)
+ {
+ resultName = newArchiveName;
+ if (i > 0)
+ {
+ wchar_t s[16];
+ ConvertUInt32ToString(i, s);
+ resultName += s;
+ }
+ if (outStreamSpec->Open(realPath))
+ {
+ isOK = true;
+ break;
+ }
+ if (::GetLastError() != ERROR_FILE_EXISTS)
+ return ::GetLastError();
+ }
+ if (!isOK)
+ return ::GetLastError();
+ */
+ if (!outStreamSpec->Create(archiveName, true))
+ {
+ // ShowLastErrorMessage();
+ return E_FAIL;
+ }
+
+ RINOK(outArchive->UpdateItems(outStream, numUpdateItems, updateCallback));
+ return outStreamSpec->Close();
+}
+
+
+STDMETHODIMP CAgent::DeleteItems(
+ const wchar_t *newArchiveName,
+ const UInt32 *indices, UInt32 numItems,
+ IFolderArchiveUpdateCallback *updateCallback100)
+{
+ if (!CanUpdate())
+ return E_NOTIMPL;
+ CUpdateCallbackAgent updateCallbackAgent;
+ updateCallbackAgent.SetCallback(updateCallback100);
+ CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
+ CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
+
+ CUIntVector realIndices;
+ _agentFolder->GetRealIndices(indices, numItems, realIndices);
+ CRecordVector<CUpdatePair2> updatePairs;
+ int curIndex = 0;
+ UInt32 numItemsInArchive;
+ RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
+ for (UInt32 i = 0; i < numItemsInArchive; i++)
+ {
+ if (curIndex < realIndices.Size())
+ if (realIndices[curIndex] == i)
+ {
+ curIndex++;
+ continue;
+ }
+ CUpdatePair2 up2;
+ up2.NewData = up2.NewProps = false;
+ up2.IsAnti = false; // check it. Maybe it can be undefined
+ up2.ArcIndex = i;
+ updatePairs.Add(up2);
+ }
+ updateCallbackSpec->UpdatePairs = &updatePairs;
+ updateCallbackSpec->Archive = GetArchive();
+ updateCallbackSpec->Callback = &updateCallbackAgent;
+ return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
+}
+
+HRESULT CAgent::CreateFolder(
+ const wchar_t *newArchiveName,
+ const wchar_t *folderName,
+ IFolderArchiveUpdateCallback *updateCallback100)
+{
+ if (!CanUpdate())
+ return E_NOTIMPL;
+ CUpdateCallbackAgent updateCallbackAgent;
+ updateCallbackAgent.SetCallback(updateCallback100);
+ CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
+ CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
+
+ CRecordVector<CUpdatePair2> updatePairs;
+ UInt32 numItemsInArchive;
+ RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
+ for (UInt32 i = 0; i < numItemsInArchive; i++)
+ {
+ CUpdatePair2 up2;
+ up2.NewData = up2.NewProps = false;
+ up2.IsAnti = false; // check it.
+ up2.ArcIndex = i;
+ updatePairs.Add(up2);
+ }
+ CUpdatePair2 up2;
+ up2.NewData = up2.NewProps = true;
+ up2.IsAnti = false;
+ up2.DirIndex = 0;
+
+ updatePairs.Add(up2);
+
+ updatePairs.ReserveDown();
+
+ CDirItems dirItems;
+ CDirItem di;
+
+ di.Attrib = FILE_ATTRIBUTE_DIRECTORY;
+ di.Size = 0;
+ di.Name = _agentFolder->_proxyFolderItem->GetFullPathPrefix() + folderName;
+
+ FILETIME ft;
+ NTime::GetCurUtcFileTime(ft);
+ di.CTime = di.ATime = di.MTime = ft;
+
+ dirItems.Items.Add(di);
+
+ updateCallbackSpec->Callback = &updateCallbackAgent;
+ updateCallbackSpec->DirItems = &dirItems;
+ updateCallbackSpec->UpdatePairs = &updatePairs;
+ updateCallbackSpec->Archive = GetArchive();
+ return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
+}
+
+
+HRESULT CAgent::RenameItem(
+ const wchar_t *newArchiveName,
+ const UInt32 *indices, UInt32 numItems,
+ const wchar_t *newItemName,
+ IFolderArchiveUpdateCallback *updateCallback100)
+{
+ if (!CanUpdate())
+ return E_NOTIMPL;
+ if (numItems != 1)
+ return E_INVALIDARG;
+ CUpdateCallbackAgent updateCallbackAgent;
+ updateCallbackAgent.SetCallback(updateCallback100);
+ CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
+ CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
+
+ CUIntVector realIndices;
+ _agentFolder->GetRealIndices(indices, numItems, realIndices);
+
+ UString fullPrefix = _agentFolder->GetFullPathPrefixPlusPrefix(indices[0]);
+ UString oldItemPath = fullPrefix + _agentFolder->GetName(indices[0]);
+ UString newItemPath = fullPrefix + newItemName;
+
+ CRecordVector<CUpdatePair2> updatePairs;
+ UStringVector newNames;
+
+ int curIndex = 0;
+ UInt32 numItemsInArchive;
+ RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
+ for (UInt32 i = 0; i < numItemsInArchive; i++)
+ {
+ if (curIndex < realIndices.Size())
+ if (realIndices[curIndex] == i)
+ {
+ CUpdatePair2 up2;
+ up2.NewData = false;
+ up2.NewProps = true;
+ RINOK(GetArc().IsItemAnti(i, up2.IsAnti));
+ up2.ArcIndex = i;
+
+ UString oldFullPath;
+ RINOK(GetArc().GetItemPath(i, oldFullPath));
+
+ if (oldItemPath.CompareNoCase(oldFullPath.Left(oldItemPath.Length())) != 0)
+ return E_INVALIDARG;
+
+ up2.NewNameIndex = newNames.Add(newItemPath + oldFullPath.Mid(oldItemPath.Length()));
+ updatePairs.Add(up2);
+ curIndex++;
+ continue;
+ }
+ CUpdatePair2 up2;
+ up2.NewData = up2.NewProps = false;
+ up2.IsAnti = false;
+ up2.ArcIndex = i;
+ updatePairs.Add(up2);
+ }
+ updateCallbackSpec->Callback = &updateCallbackAgent;
+ updateCallbackSpec->UpdatePairs = &updatePairs;
+ updateCallbackSpec->NewNames = &newNames;
+ updateCallbackSpec->Archive = GetArchive();
+ return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
+}
+
+STDMETHODIMP CAgent::SetProperties(const wchar_t **names,
+ const PROPVARIANT *values, Int32 numProperties)
+{
+ m_PropNames.Clear();
+ m_PropValues.Clear();
+ for (int i = 0; i < numProperties; i++)
+ {
+ m_PropNames.Add(names[i]);
+ m_PropValues.Add(values[i]);
+ }
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentProxy.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentProxy.cpp
new file mode 100644
index 000000000..9686cf345
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentProxy.cpp
@@ -0,0 +1,246 @@
+// AgentProxy.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/Sort.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../Common/OpenArchive.h"
+
+#include "AgentProxy.h"
+
+using namespace NWindows;
+
+int CProxyFolder::FindDirSubItemIndex(const UString &name, int &insertPos) const
+{
+ int left = 0, right = Folders.Size();
+ for (;;)
+ {
+ if (left == right)
+ {
+ insertPos = left;
+ return -1;
+ }
+ int mid = (left + right) / 2;
+ int compare = name.CompareNoCase(Folders[mid].Name);
+ if (compare == 0)
+ return mid;
+ if (compare < 0)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+}
+
+int CProxyFolder::FindDirSubItemIndex(const UString &name) const
+{
+ int insertPos;
+ return FindDirSubItemIndex(name, insertPos);
+}
+
+void CProxyFolder::AddFileSubItem(UInt32 index, const UString &name)
+{
+ Files.Add(CProxyFile());
+ Files.Back().Name = name;
+ Files.Back().Index = index;
+}
+
+CProxyFolder* CProxyFolder::AddDirSubItem(UInt32 index, bool leaf, const UString &name)
+{
+ int insertPos;
+ int folderIndex = FindDirSubItemIndex(name, insertPos);
+ if (folderIndex >= 0)
+ {
+ CProxyFolder *item = &Folders[folderIndex];
+ if (leaf)
+ {
+ item->Index = index;
+ item->IsLeaf = true;
+ }
+ return item;
+ }
+ Folders.Insert(insertPos, CProxyFolder());
+ CProxyFolder *item = &Folders[insertPos];
+ item->Name = name;
+ item->Index = index;
+ item->Parent = this;
+ item->IsLeaf = leaf;
+ return item;
+}
+
+void CProxyFolder::Clear()
+{
+ Folders.Clear();
+ Files.Clear();
+}
+
+void CProxyFolder::GetPathParts(UStringVector &pathParts) const
+{
+ pathParts.Clear();
+ UString result;
+ const CProxyFolder *current = this;
+ while (current->Parent != NULL)
+ {
+ pathParts.Insert(0, (const wchar_t *)current->Name);
+ current = current->Parent;
+ }
+}
+
+UString CProxyFolder::GetFullPathPrefix() const
+{
+ UString result;
+ const CProxyFolder *current = this;
+ while (current->Parent != NULL)
+ {
+ result = current->Name + UString(WCHAR_PATH_SEPARATOR) + result;
+ current = current->Parent;
+ }
+ return result;
+}
+
+UString CProxyFolder::GetItemName(UInt32 index) const
+{
+ if (index < (UInt32)Folders.Size())
+ return Folders[index].Name;
+ return Files[index - Folders.Size()].Name;
+}
+
+void CProxyFolder::AddRealIndices(CUIntVector &realIndices) const
+{
+ if (IsLeaf)
+ realIndices.Add(Index);
+ int i;
+ for (i = 0; i < Folders.Size(); i++)
+ Folders[i].AddRealIndices(realIndices);
+ for (i = 0; i < Files.Size(); i++)
+ realIndices.Add(Files[i].Index);
+}
+
+void CProxyFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const
+{
+ realIndices.Clear();
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ int index = indices[i];
+ int numDirItems = Folders.Size();
+ if (index < numDirItems)
+ Folders[index].AddRealIndices(realIndices);
+ else
+ realIndices.Add(Files[index - numDirItems].Index);
+ }
+ HeapSort(&realIndices.Front(), realIndices.Size());
+}
+
+///////////////////////////////////////////////
+// CProxyArchive
+
+static UInt64 GetSize(IInArchive *archive, UInt32 index, PROPID propID)
+{
+ NCOM::CPropVariant prop;
+ if (archive->GetProperty(index, propID, &prop) == S_OK)
+ if (prop.vt != VT_EMPTY)
+ return ConvertPropVariantToUInt64(prop);
+ return 0;
+}
+
+void CProxyFolder::CalculateSizes(IInArchive *archive)
+{
+ Size = PackSize = 0;
+ NumSubFolders = Folders.Size();
+ NumSubFiles = Files.Size();
+ CrcIsDefined = true;
+ Crc = 0;
+ int i;
+ for (i = 0; i < Files.Size(); i++)
+ {
+ UInt32 index = Files[i].Index;
+ Size += GetSize(archive, index, kpidSize);
+ PackSize += GetSize(archive, index, kpidPackSize);
+ {
+ NCOM::CPropVariant prop;
+ if (archive->GetProperty(index, kpidCRC, &prop) == S_OK && prop.vt == VT_UI4)
+ Crc += prop.ulVal;
+ else
+ CrcIsDefined = false;
+ }
+ }
+ for (i = 0; i < Folders.Size(); i++)
+ {
+ CProxyFolder &f = Folders[i];
+ f.CalculateSizes(archive);
+ Size += f.Size;
+ PackSize += f.PackSize;
+ NumSubFiles += f.NumSubFiles;
+ NumSubFolders += f.NumSubFolders;
+ Crc += f.Crc;
+ if (!f.CrcIsDefined)
+ CrcIsDefined = false;
+ }
+}
+
+HRESULT CProxyArchive::Load(const CArc &arc, IProgress *progress)
+{
+ RootFolder.Clear();
+ IInArchive *archive = arc.Archive;
+ {
+ ThereIsPathProp = false;
+ UInt32 numProps;
+ archive->GetNumberOfProperties(&numProps);
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE varType;
+ RINOK(archive->GetPropertyInfo(i, &name, &propID, &varType));
+ if (propID == kpidPath)
+ {
+ ThereIsPathProp = true;
+ break;
+ }
+ }
+ }
+
+ UInt32 numItems;
+ RINOK(archive->GetNumberOfItems(&numItems));
+ if (progress != NULL)
+ {
+ UInt64 totalItems = numItems;
+ RINOK(progress->SetTotal(totalItems));
+ }
+ UString fileName;
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ if (progress != NULL && (i & 0xFFFFF) == 0)
+ {
+ UInt64 currentItemIndex = i;
+ RINOK(progress->SetCompleted(&currentItemIndex));
+ }
+ UString filePath;
+ RINOK(arc.GetItemPath(i, filePath));
+ CProxyFolder *curItem = &RootFolder;
+ int len = filePath.Length();
+ fileName.Empty();
+ for (int j = 0; j < len; j++)
+ {
+ wchar_t c = filePath[j];
+ if (c == WCHAR_PATH_SEPARATOR || c == L'/')
+ {
+ curItem = curItem->AddDirSubItem((UInt32)(Int32)-1, false, fileName);
+ fileName.Empty();
+ }
+ else
+ fileName += c;
+ }
+
+ bool isFolder;
+ RINOK(IsArchiveItemFolder(archive, i, isFolder));
+ if (isFolder)
+ curItem->AddDirSubItem(i, true, fileName);
+ else
+ curItem->AddFileSubItem(i, fileName);
+ }
+ RootFolder.CalculateSizes(archive);
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentProxy.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentProxy.h
new file mode 100644
index 000000000..d4caca164
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/AgentProxy.h
@@ -0,0 +1,53 @@
+// AgentProxy.h
+
+#ifndef __AGENT_PROXY_H
+#define __AGENT_PROXY_H
+
+#include "Common/MyString.h"
+
+#include "../Common/OpenArchive.h"
+
+struct CProxyFile
+{
+ UInt32 Index;
+ UString Name;
+};
+
+struct CProxyFolder: public CProxyFile
+{
+ CProxyFolder *Parent;
+ CObjectVector<CProxyFolder> Folders;
+ CObjectVector<CProxyFile> Files;
+ bool IsLeaf;
+
+ bool CrcIsDefined;
+ UInt64 Size;
+ UInt64 PackSize;
+ UInt32 Crc;
+ UInt32 NumSubFolders;
+ UInt32 NumSubFiles;
+
+ CProxyFolder(): Parent(NULL) {};
+ int FindDirSubItemIndex(const UString &name, int &insertPos) const;
+ int FindDirSubItemIndex(const UString &name) const;
+ CProxyFolder* AddDirSubItem(UInt32 index, bool leaf, const UString &name);
+ void AddFileSubItem(UInt32 index, const UString &name);
+ void Clear();
+
+ void GetPathParts(UStringVector &pathParts) const;
+ UString GetFullPathPrefix() const;
+ UString GetItemName(UInt32 index) const;
+ void AddRealIndices(CUIntVector &realIndices) const;
+ void GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const;
+ void CalculateSizes(IInArchive *archive);
+};
+
+struct CProxyArchive
+{
+ CProxyFolder RootFolder;
+ bool ThereIsPathProp;
+
+ HRESULT Load(const CArc &arc, IProgress *progress);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolder.cpp
new file mode 100644
index 000000000..57975e7d4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolder.cpp
@@ -0,0 +1,59 @@
+// Agent/ArchiveFolder.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+
+#include "../Common/ArchiveExtractCallback.h"
+
+#include "Agent.h"
+
+using namespace NWindows;
+using namespace NCOM;
+
+STDMETHODIMP CAgentFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback)
+{
+ COM_TRY_BEGIN
+ CArchiveExtractCallback *extractCallbackSpec = new
+ CArchiveExtractCallback;
+ CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
+ UStringVector pathParts;
+ CProxyFolder *currentProxyFolder = _proxyFolderItem;
+ while (currentProxyFolder->Parent)
+ {
+ pathParts.Insert(0, currentProxyFolder->Name);
+ currentProxyFolder = currentProxyFolder->Parent;
+ }
+
+ CMyComPtr<IFolderArchiveExtractCallback> extractCallback2;
+ {
+ CMyComPtr<IFolderOperationsExtractCallback> callbackWrap = callback;
+ RINOK(callbackWrap.QueryInterface(
+ IID_IFolderArchiveExtractCallback, &extractCallback2));
+ }
+
+ NExtract::NPathMode::EEnum pathMode = _flatMode ?
+ NExtract::NPathMode::kNoPathnames :
+ NExtract::NPathMode::kCurrentPathnames;
+
+ extractCallbackSpec->InitForMulti(false, pathMode, NExtract::NOverwriteMode::kAskBefore);
+ extractCallbackSpec->Init(NULL, &_agentSpec->GetArc(),
+ extractCallback2,
+ false, false, false,
+ path,
+ pathParts,
+ (UInt64)(Int64)-1);
+ CUIntVector realIndices;
+ GetRealIndices(indices, numItems, realIndices);
+ return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
+ realIndices.Size(), BoolToInt(false), extractCallback);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::MoveTo(const UInt32 * /* indices */, UInt32 /* numItems */,
+ const wchar_t * /* path */, IFolderOperationsExtractCallback * /* callback */)
+{
+ return E_NOTIMPL;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
new file mode 100644
index 000000000..98c75f4d9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
@@ -0,0 +1,121 @@
+// Zip/ArchiveFolder.cpp
+
+#include "StdAfx.h"
+
+#include "Agent.h"
+
+#include "Common/StringConvert.h"
+
+static inline UINT GetCurrentFileCodePage()
+ { return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+
+void CArchiveFolderManager::LoadFormats()
+{
+ if (!_codecs)
+ {
+ _compressCodecsInfo = _codecs = new CCodecs;
+ _codecs->Load();
+ }
+}
+
+int CArchiveFolderManager::FindFormat(const UString &type)
+{
+ for (int i = 0; i < _codecs->Formats.Size(); i++)
+ if (type.CompareNoCase(_codecs->Formats[i].Name) == 0)
+ return i;
+ return -1;
+}
+
+STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream, const wchar_t *filePath,
+ IFolderFolder **resultFolder, IProgress *progress)
+{
+ CMyComPtr<IArchiveOpenCallback> openArchiveCallback;
+ if (progress != 0)
+ {
+ CMyComPtr<IProgress> progressWrapper = progress;
+ progressWrapper.QueryInterface(IID_IArchiveOpenCallback, &openArchiveCallback);
+ }
+ CAgent *agent = new CAgent();
+ CMyComPtr<IInFolderArchive> archive = agent;
+ RINOK(agent->Open(inStream, filePath, NULL, openArchiveCallback));
+ return agent->BindToRootFolder(resultFolder);
+}
+
+/*
+HRESULT CAgent::FolderReOpen(
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ return ReOpenArchive(_archive, _archiveFilePath);
+}
+*/
+
+
+/*
+STDMETHODIMP CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *extensions)
+{
+ *extensions = 0;
+ int formatIndex = FindFormat(type);
+ if (formatIndex < 0)
+ return E_INVALIDARG;
+ // Exts[0].Ext;
+ return StringToBstr(_codecs.Formats[formatIndex].GetAllExtensions(), extensions);
+}
+*/
+STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions)
+{
+ LoadFormats();
+ *extensions = 0;
+ UString res;
+ for (int i = 0; i < _codecs->Libs.Size(); i++)
+ {
+ const CCodecLib &lib = _codecs->Libs[i];
+ for (int j = 0; j < lib.IconPairs.Size(); j++)
+ {
+ if (!res.IsEmpty())
+ res += L' ';
+ res += lib.IconPairs[j].Ext;
+ }
+ }
+ return StringToBstr(res, extensions);
+}
+
+STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex)
+{
+ LoadFormats();
+ *iconPath = 0;
+ *iconIndex = 0;
+ for (int i = 0; i < _codecs->Libs.Size(); i++)
+ {
+ const CCodecLib &lib = _codecs->Libs[i];
+ int ii = lib.FindIconIndex(ext);
+ if (ii >= 0)
+ {
+ *iconIndex = ii;
+ return StringToBstr(GetUnicodeString(lib.Path, GetCurrentFileCodePage()), iconPath);
+ }
+ }
+ return S_OK;
+}
+
+/*
+STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
+{
+ LoadFormats();
+ UString typesStrings;
+ for(int i = 0; i < _codecs.Formats.Size(); i++)
+ {
+ const CArcInfoEx &ai = _codecs.Formats[i];
+ if (ai.AssociateExts.Size() == 0)
+ continue;
+ if (i != 0)
+ typesStrings += L' ';
+ typesStrings += ai.Name;
+ }
+ return StringToBstr(typesStrings, types);
+}
+STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type,
+ const wchar_t * filePath, IProgress progress)
+{
+ return E_NOTIMPL;
+}
+*/
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
new file mode 100644
index 000000000..8f03f44de
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
@@ -0,0 +1,214 @@
+// FolderOut.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+
+#include "Windows/FileDir.h"
+
+#include "../Common/WorkDir.h"
+
+#include "Agent.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NDirectory;
+
+static LPCWSTR kTempArcivePrefix = L"7zA";
+
+void CAgentFolder::GetPathParts(UStringVector &pathParts)
+{
+ _proxyFolderItem->GetPathParts(pathParts);
+}
+
+HRESULT CAgentFolder::CommonUpdateOperation(
+ bool deleteOperation,
+ bool createFolderOperation,
+ bool renameOperation,
+ const wchar_t *newItemName,
+ const NUpdateArchive::CActionSet *actionSet,
+ const UINT32 *indices, UINT32 numItems,
+ IFolderArchiveUpdateCallback *updateCallback100)
+{
+ NWorkDir::CInfo workDirInfo;
+ ReadWorkDirInfo(workDirInfo);
+ UString archiveFilePath = _agentSpec->_archiveFilePath;
+ UString workDir = GetWorkDir(workDirInfo, archiveFilePath);
+ CreateComplexDirectory(workDir);
+
+ CTempFileW tempFile;
+ UString tempFileName;
+ if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
+ return E_FAIL;
+
+ /*
+ if (SetOutProperties(anOutArchive, aCompressionInfo.Method) != S_OK)
+ return NFileOperationReturnCode::kError;
+ */
+
+ ////////////////////////////
+ // Save FolderItem;
+
+ UStringVector pathParts;
+ GetPathParts(pathParts);
+
+ HRESULT result;
+ if (deleteOperation)
+ result = _agentSpec->DeleteItems(tempFileName,
+ indices, numItems, updateCallback100);
+ else if (createFolderOperation)
+ {
+ result = _agentSpec->CreateFolder(tempFileName,
+ newItemName, updateCallback100);
+ }
+ else if (renameOperation)
+ {
+ result = _agentSpec->RenameItem(
+ tempFileName,
+ indices, numItems,
+ newItemName,
+ updateCallback100);
+ }
+ else
+ {
+ Byte actionSetByte[NUpdateArchive::NPairState::kNumValues];
+ for (int i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
+ actionSetByte[i] = (Byte)actionSet->StateActions[i];
+ result = _agentSpec->DoOperation2(tempFileName, actionSetByte, NULL, updateCallback100);
+ }
+
+ if (result != S_OK)
+ return result;
+
+ _agentSpec->Close();
+
+ // m_FolderItem = NULL;
+
+ if (NFind::DoesFileExist(archiveFilePath))
+ if (!DeleteFileAlways(archiveFilePath))
+ return GetLastError();
+
+ tempFile.DisableDeleting();
+ if (!MyMoveFile(tempFileName, archiveFilePath))
+ return GetLastError();
+
+ {
+ CMyComPtr<IArchiveOpenCallback> openCallback;
+ if (updateCallback100)
+ {
+ RINOK(updateCallback100->QueryInterface(IID_IArchiveOpenCallback, (void **)&openCallback));
+ }
+ RINOK(_agentSpec->ReOpen(openCallback));
+ }
+
+ ////////////////////////////
+ // Restore FolderItem;
+
+ CMyComPtr<IFolderFolder> archiveFolder;
+ RINOK(_agentSpec->BindToRootFolder(&archiveFolder));
+ for (int i = 0; i < pathParts.Size(); i++)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ archiveFolder->BindToFolder(pathParts[i], &newFolder);
+ if(!newFolder)
+ break;
+ archiveFolder = newFolder;
+ }
+
+ CMyComPtr<IArchiveFolderInternal> archiveFolderInternal;
+ RINOK(archiveFolder.QueryInterface(IID_IArchiveFolderInternal, &archiveFolderInternal));
+ CAgentFolder *agentFolder;
+ RINOK(archiveFolderInternal->GetAgentFolder(&agentFolder));
+ _proxyFolderItem = agentFolder->_proxyFolderItem;
+ _proxyArchive = agentFolder->_proxyArchive;
+ _parentFolder = agentFolder->_parentFolder;
+
+ return S_OK;
+}
+
+STDMETHODIMP CAgentFolder::CopyFrom(
+ const wchar_t *fromFolderPath, // test it
+ const wchar_t **itemsPaths,
+ UINT32 numItems,
+ IProgress *progress)
+{
+ COM_TRY_BEGIN
+ CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
+ if (progress != 0)
+ {
+ RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&updateCallback100));
+ }
+ try
+ {
+ RINOK(_agentSpec->SetFiles(fromFolderPath, itemsPaths, numItems));
+ RINOK(_agentSpec->SetFolder(this));
+ return CommonUpdateOperation(false, false, false, NULL,
+ &NUpdateArchive::kAddActionSet, 0, 0, updateCallback100);
+ }
+ catch(const UString &s)
+ {
+ RINOK(updateCallback100->UpdateErrorMessage(UString(L"Error: ") + s));
+ return E_FAIL;
+ }
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::Delete(const UINT32 *indices, UINT32 numItems, IProgress *progress)
+{
+ COM_TRY_BEGIN
+ RINOK(_agentSpec->SetFolder(this));
+ CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
+ if (progress != 0)
+ {
+ CMyComPtr<IProgress> progressWrapper = progress;
+ RINOK(progressWrapper.QueryInterface(
+ IID_IFolderArchiveUpdateCallback, &updateCallback100));
+ }
+ return CommonUpdateOperation(true, false, false, NULL,
+ &NUpdateArchive::kDeleteActionSet, indices, numItems, updateCallback100);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::CreateFolder(const wchar_t *name, IProgress *progress)
+{
+ COM_TRY_BEGIN
+ if (_proxyFolderItem->FindDirSubItemIndex(name) >= 0)
+ return ERROR_ALREADY_EXISTS;
+ RINOK(_agentSpec->SetFolder(this));
+ CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
+ if (progress != 0)
+ {
+ CMyComPtr<IProgress> progressWrapper = progress;
+ RINOK(progressWrapper.QueryInterface(IID_IFolderArchiveUpdateCallback, &updateCallback100));
+ }
+ return CommonUpdateOperation(false, true, false, name, NULL, NULL, 0, updateCallback100);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::Rename(UINT32 index, const wchar_t *newName, IProgress *progress)
+{
+ COM_TRY_BEGIN
+ CUIntVector indices;
+ indices.Add(index);
+ RINOK(_agentSpec->SetFolder(this));
+ CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
+ if (progress != 0)
+ {
+ CMyComPtr<IProgress> progressWrapper = progress;
+ RINOK(progressWrapper.QueryInterface(IID_IFolderArchiveUpdateCallback, &updateCallback100));
+ }
+ return CommonUpdateOperation(false, false, true, newName, NULL, &indices.Front(),
+ indices.Size(), updateCallback100);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::CreateFile(const wchar_t * /* name */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CAgentFolder::SetProperty(UINT32 /* index */, PROPID /* propID */,
+ const PROPVARIANT * /* value */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/IFolderArchive.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/IFolderArchive.h
new file mode 100644
index 000000000..91da1150b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/IFolderArchive.h
@@ -0,0 +1,73 @@
+// IFolderArchive.h
+
+#ifndef __IFOLDER_ARCHIVE_H
+#define __IFOLDER_ARCHIVE_H
+
+#include "../../IDecl.h"
+#include "../../Archive/IArchive.h"
+#include "../../UI/Common/LoadCodecs.h"
+#include "../../UI/FileManager/IFolder.h"
+
+#include "../Common/ExtractMode.h"
+#include "../Common/IFileExtractCallback.h"
+
+#define FOLDER_ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 0x01, x)
+#define FOLDER_ARCHIVE_INTERFACE(i, x) FOLDER_ARCHIVE_INTERFACE_SUB(i, IUnknown, x)
+
+#define INTERFACE_IArchiveFolder(x) \
+ STDMETHOD(Extract)(const UInt32 *indices, UInt32 numItems, \
+ NExtract::NPathMode::EEnum pathMode, \
+ NExtract::NOverwriteMode::EEnum overwriteMode, \
+ const wchar_t *path, Int32 testMode, \
+ IFolderArchiveExtractCallback *extractCallback2) x; \
+
+FOLDER_ARCHIVE_INTERFACE(IArchiveFolder, 0x05)
+{
+ INTERFACE_IArchiveFolder(PURE)
+};
+
+#define INTERFACE_IInFolderArchive(x) \
+ STDMETHOD(Open)(IInStream *inStream, const wchar_t *filePath, BSTR *archiveType, IArchiveOpenCallback *openArchiveCallback) x; \
+ STDMETHOD(ReOpen)(IArchiveOpenCallback *openArchiveCallback) x; \
+ STDMETHOD(Close)() x; \
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
+ STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
+ STDMETHOD(BindToRootFolder)(IFolderFolder **resultFolder) x; \
+ STDMETHOD(Extract)(NExtract::NPathMode::EEnum pathMode, \
+ NExtract::NOverwriteMode::EEnum overwriteMode, const wchar_t *path, \
+ Int32 testMode, IFolderArchiveExtractCallback *extractCallback2) x; \
+
+FOLDER_ARCHIVE_INTERFACE(IInFolderArchive, 0x0D)
+{
+ INTERFACE_IInFolderArchive(PURE)
+};
+
+#define INTERFACE_IFolderArchiveUpdateCallback(x) \
+ STDMETHOD(CompressOperation)(const wchar_t *name) x; \
+ STDMETHOD(DeleteOperation)(const wchar_t *name) x; \
+ STDMETHOD(OperationResult)(Int32 operationResult) x; \
+ STDMETHOD(UpdateErrorMessage)(const wchar_t *message) x; \
+ STDMETHOD(SetNumFiles)(UInt64 numFiles) x; \
+
+FOLDER_ARCHIVE_INTERFACE_SUB(IFolderArchiveUpdateCallback, IProgress, 0x0B)
+{
+ INTERFACE_IFolderArchiveUpdateCallback(PURE)
+};
+
+#define INTERFACE_IOutFolderArchive(x) \
+ STDMETHOD(SetFolder)(IFolderFolder *folder) x; \
+ STDMETHOD(SetFiles)(const wchar_t *folderPrefix, const wchar_t **names, UInt32 numNames) x; \
+ STDMETHOD(DeleteItems)(const wchar_t *newArchiveName, \
+ const UInt32 *indices, UInt32 numItems, IFolderArchiveUpdateCallback *updateCallback) x; \
+ STDMETHOD(DoOperation)(CCodecs *codecs, int index, \
+ const wchar_t *newArchiveName, const Byte *stateActions, const wchar_t *sfxModule, \
+ IFolderArchiveUpdateCallback *updateCallback) x; \
+ STDMETHOD(DoOperation2)(const wchar_t *newArchiveName, const Byte *stateActions, \
+ const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback) x; \
+
+FOLDER_ARCHIVE_INTERFACE(IOutFolderArchive, 0x0A)
+{
+ INTERFACE_IOutFolderArchive(PURE)
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
new file mode 100644
index 000000000..21549c90f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
@@ -0,0 +1,121 @@
+// UpdateCallbackAgent.h
+
+#include "StdAfx.h"
+
+#include "Windows/Error.h"
+#include "Common/IntToString.h"
+
+#include "UpdateCallbackAgent.h"
+
+using namespace NWindows;
+
+void CUpdateCallbackAgent::SetCallback(IFolderArchiveUpdateCallback *callback)
+{
+ Callback = callback;
+ _compressProgress.Release();
+ if (Callback)
+ Callback.QueryInterface(IID_ICompressProgressInfo, &_compressProgress);
+}
+
+HRESULT CUpdateCallbackAgent::SetNumFiles(UInt64 numFiles)
+{
+ if (Callback)
+ return Callback->SetNumFiles(numFiles);
+ return S_OK;
+}
+
+
+HRESULT CUpdateCallbackAgent::SetTotal(UINT64 size)
+{
+ if (Callback)
+ return Callback->SetTotal(size);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackAgent::SetCompleted(const UINT64 *completeValue)
+{
+ if (Callback)
+ return Callback->SetCompleted(completeValue);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackAgent::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ if (_compressProgress)
+ return _compressProgress->SetRatioInfo(inSize, outSize);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackAgent::CheckBreak()
+{
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackAgent::Finilize()
+{
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackAgent::OpenFileError(const wchar_t *name, DWORD systemError)
+{
+ // if (systemError == ERROR_SHARING_VIOLATION)
+ {
+ if (Callback)
+ {
+ RINOK(Callback->UpdateErrorMessage(
+ UString(L"WARNING: ") +
+ NError::MyFormatMessageW(systemError) +
+ UString(L": ") +
+ UString(name)));
+ return S_FALSE;
+ }
+ }
+ // FailedFiles.Add(name);
+ return systemError;
+}
+
+HRESULT CUpdateCallbackAgent::GetStream(const wchar_t *name, bool /* isAnti */)
+{
+ if (Callback)
+ return Callback->CompressOperation(name);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackAgent::SetOperationResult(Int32 operationResult)
+{
+ if (Callback)
+ return Callback->OperationResult(operationResult);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackAgent::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ *password = NULL;
+ *passwordIsDefined = BoolToInt(false);
+ if (!_cryptoGetTextPassword)
+ {
+ if (!Callback)
+ return S_OK;
+ Callback.QueryInterface(IID_ICryptoGetTextPassword2, &_cryptoGetTextPassword);
+ if (!_cryptoGetTextPassword)
+ return S_OK;
+ }
+ return _cryptoGetTextPassword->CryptoGetTextPassword2(passwordIsDefined, password);
+}
+
+HRESULT CUpdateCallbackAgent::CryptoGetTextPassword(BSTR *password)
+{
+ *password = NULL;
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
+ Callback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
+ if (!getTextPassword)
+ return E_NOTIMPL;
+ return getTextPassword->CryptoGetTextPassword(password);
+}
+
+/*
+HRESULT CUpdateCallbackAgent::ShowDeleteFile(const wchar_t *name)
+{
+ return Callback->DeleteOperation(name);
+}
+*/ \ No newline at end of file
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/UpdateCallbackAgent.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/UpdateCallbackAgent.h
new file mode 100644
index 000000000..1d5ed17a0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/UpdateCallbackAgent.h
@@ -0,0 +1,19 @@
+// UpdateCallbackAgent.h
+
+#ifndef __UPDATECALLBACKAGENT_H
+#define __UPDATECALLBACKAGENT_H
+
+#include "../Common/UpdateCallback.h"
+#include "IFolderArchive.h"
+
+class CUpdateCallbackAgent: public IUpdateCallbackUI
+{
+ INTERFACE_IUpdateCallbackUI(;)
+ CMyComPtr<ICryptoGetTextPassword2> _cryptoGetTextPassword;
+ CMyComPtr<IFolderArchiveUpdateCallback> Callback;
+ CMyComPtr<ICompressProgressInfo> _compressProgress;
+public:
+ void SetCallback(IFolderArchiveUpdateCallback *callback);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Client7z/Client7z.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Client7z/Client7z.cpp
new file mode 100644
index 000000000..7c052171b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Client7z/Client7z.cpp
@@ -0,0 +1,853 @@
+// Client7z.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/MyInitGuid.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/DLL.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../Common/FileStreams.h"
+
+#include "../../Archive/IArchive.h"
+
+#include "../../IPassword.h"
+#include "../../MyVersion.h"
+
+// use another CLSIDs, if you want to support other formats (zip, rar, ...).
+// {23170F69-40C1-278A-1000-000110070000}
+DEFINE_GUID(CLSID_CFormat7z,
+ 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
+
+using namespace NWindows;
+
+#define kDllName "7z.dll"
+
+static const char *kCopyrightString = MY_7ZIP_VERSION
+" (" kDllName " client) "
+MY_COPYRIGHT " " MY_DATE;
+
+static const char *kHelpString =
+"Usage: Client7z.exe [a | l | x ] archive.7z [fileName ...]\n"
+"Examples:\n"
+" Client7z.exe a archive.7z f1.txt f2.txt : compress two files to archive.7z\n"
+" Client7z.exe l archive.7z : List contents of archive.7z\n"
+" Client7z.exe x archive.7z : eXtract files from archive.7z\n";
+
+
+typedef UINT32 (WINAPI * CreateObjectFunc)(
+ const GUID *clsID,
+ const GUID *interfaceID,
+ void **outObject);
+
+#ifdef _WIN32
+#ifndef _UNICODE
+bool g_IsNT = false;
+static inline bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+#endif
+
+void PrintString(const UString &s)
+{
+ printf("%s", (LPCSTR)GetOemString(s));
+}
+
+void PrintString(const AString &s)
+{
+ printf("%s", (LPCSTR)s);
+}
+
+void PrintNewLine()
+{
+ PrintString("\n");
+}
+
+void PrintStringLn(const AString &s)
+{
+ PrintString(s);
+ PrintNewLine();
+}
+
+void PrintError(const AString &s)
+{
+ PrintNewLine();
+ PrintString(s);
+ PrintNewLine();
+}
+
+static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result)
+{
+ NCOM::CPropVariant prop;
+ RINOK(archive->GetProperty(index, propID, &prop));
+ if (prop.vt == VT_BOOL)
+ result = VARIANT_BOOLToBool(prop.boolVal);
+ else if (prop.vt == VT_EMPTY)
+ result = false;
+ else
+ return E_FAIL;
+ return S_OK;
+}
+
+static HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result)
+{
+ return IsArchiveItemProp(archive, index, kpidIsDir, result);
+}
+
+
+static const wchar_t *kEmptyFileAlias = L"[Content]";
+
+
+//////////////////////////////////////////////////////////////
+// Archive Open callback class
+
+
+class CArchiveOpenCallback:
+ public IArchiveOpenCallback,
+ public ICryptoGetTextPassword,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
+
+ STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes);
+ STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes);
+
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+
+ bool PasswordIsDefined;
+ UString Password;
+
+ CArchiveOpenCallback() : PasswordIsDefined(false) {}
+};
+
+STDMETHODIMP CArchiveOpenCallback::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveOpenCallback::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
+{
+ if (!PasswordIsDefined)
+ {
+ // You can ask real password here from user
+ // Password = GetPassword(OutStream);
+ // PasswordIsDefined = true;
+ PrintError("Password is not defined");
+ return E_ABORT;
+ }
+ return StringToBstr(Password, password);
+}
+
+
+//////////////////////////////////////////////////////////////
+// Archive Extracting callback class
+
+static const wchar_t *kCantDeleteOutputFile = L"ERROR: Can not delete output file ";
+
+static const char *kTestingString = "Testing ";
+static const char *kExtractingString = "Extracting ";
+static const char *kSkippingString = "Skipping ";
+
+static const char *kUnsupportedMethod = "Unsupported Method";
+static const char *kCRCFailed = "CRC Failed";
+static const char *kDataError = "Data Error";
+static const char *kUnknownError = "Unknown Error";
+
+class CArchiveExtractCallback:
+ public IArchiveExtractCallback,
+ public ICryptoGetTextPassword,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
+
+ // IProgress
+ STDMETHOD(SetTotal)(UInt64 size);
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue);
+
+ // IArchiveExtractCallback
+ STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode);
+ STDMETHOD(PrepareOperation)(Int32 askExtractMode);
+ STDMETHOD(SetOperationResult)(Int32 resultEOperationResult);
+
+ // ICryptoGetTextPassword
+ STDMETHOD(CryptoGetTextPassword)(BSTR *aPassword);
+
+private:
+ CMyComPtr<IInArchive> _archiveHandler;
+ UString _directoryPath; // Output directory
+ UString _filePath; // name inside arcvhive
+ UString _diskFilePath; // full path to file on disk
+ bool _extractMode;
+ struct CProcessedFileInfo
+ {
+ FILETIME MTime;
+ UInt32 Attrib;
+ bool isDir;
+ bool AttribDefined;
+ bool MTimeDefined;
+ } _processedFileInfo;
+
+ COutFileStream *_outFileStreamSpec;
+ CMyComPtr<ISequentialOutStream> _outFileStream;
+
+public:
+ void Init(IInArchive *archiveHandler, const UString &directoryPath);
+
+ UInt64 NumErrors;
+ bool PasswordIsDefined;
+ UString Password;
+
+ CArchiveExtractCallback() : PasswordIsDefined(false) {}
+};
+
+void CArchiveExtractCallback::Init(IInArchive *archiveHandler, const UString &directoryPath)
+{
+ NumErrors = 0;
+ _archiveHandler = archiveHandler;
+ _directoryPath = directoryPath;
+ NFile::NName::NormalizeDirPathPrefix(_directoryPath);
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetTotal(UInt64 /* size */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 * /* completeValue */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
+ ISequentialOutStream **outStream, Int32 askExtractMode)
+{
+ *outStream = 0;
+ _outFileStream.Release();
+
+ {
+ // Get Name
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));
+
+ UString fullPath;
+ if (prop.vt == VT_EMPTY)
+ fullPath = kEmptyFileAlias;
+ else
+ {
+ if (prop.vt != VT_BSTR)
+ return E_FAIL;
+ fullPath = prop.bstrVal;
+ }
+ _filePath = fullPath;
+ }
+
+ if (askExtractMode != NArchive::NExtract::NAskMode::kExtract)
+ return S_OK;
+
+ {
+ // Get Attrib
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop));
+ if (prop.vt == VT_EMPTY)
+ {
+ _processedFileInfo.Attrib = 0;
+ _processedFileInfo.AttribDefined = false;
+ }
+ else
+ {
+ if (prop.vt != VT_UI4)
+ return E_FAIL;
+ _processedFileInfo.Attrib = prop.ulVal;
+ _processedFileInfo.AttribDefined = true;
+ }
+ }
+
+ RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.isDir));
+
+ {
+ // Get Modified Time
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop));
+ _processedFileInfo.MTimeDefined = false;
+ switch(prop.vt)
+ {
+ case VT_EMPTY:
+ // _processedFileInfo.MTime = _utcMTimeDefault;
+ break;
+ case VT_FILETIME:
+ _processedFileInfo.MTime = prop.filetime;
+ _processedFileInfo.MTimeDefined = true;
+ break;
+ default:
+ return E_FAIL;
+ }
+
+ }
+ {
+ // Get Size
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
+ bool newFileSizeDefined = (prop.vt != VT_EMPTY);
+ UInt64 newFileSize;
+ if (newFileSizeDefined)
+ newFileSize = ConvertPropVariantToUInt64(prop);
+ }
+
+
+ {
+ // Create folders for file
+ int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (slashPos >= 0)
+ NFile::NDirectory::CreateComplexDirectory(_directoryPath + _filePath.Left(slashPos));
+ }
+
+ UString fullProcessedPath = _directoryPath + _filePath;
+ _diskFilePath = fullProcessedPath;
+
+ if (_processedFileInfo.isDir)
+ {
+ NFile::NDirectory::CreateComplexDirectory(fullProcessedPath);
+ }
+ else
+ {
+ NFile::NFind::CFileInfoW fi;
+ if (fi.Find(fullProcessedPath))
+ {
+ if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
+ {
+ PrintString(UString(kCantDeleteOutputFile) + fullProcessedPath);
+ return E_ABORT;
+ }
+ }
+
+ _outFileStreamSpec = new COutFileStream;
+ CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
+ if (!_outFileStreamSpec->Open(fullProcessedPath, CREATE_ALWAYS))
+ {
+ PrintString((UString)L"can not open output file " + fullProcessedPath);
+ return E_ABORT;
+ }
+ _outFileStream = outStreamLoc;
+ *outStream = outStreamLoc.Detach();
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
+{
+ _extractMode = false;
+ switch (askExtractMode)
+ {
+ case NArchive::NExtract::NAskMode::kExtract: _extractMode = true; break;
+ };
+ switch (askExtractMode)
+ {
+ case NArchive::NExtract::NAskMode::kExtract: PrintString(kExtractingString); break;
+ case NArchive::NExtract::NAskMode::kTest: PrintString(kTestingString); break;
+ case NArchive::NExtract::NAskMode::kSkip: PrintString(kSkippingString); break;
+ };
+ PrintString(_filePath);
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
+{
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kOK:
+ break;
+ default:
+ {
+ NumErrors++;
+ PrintString(" ");
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
+ PrintString(kUnsupportedMethod);
+ break;
+ case NArchive::NExtract::NOperationResult::kCRCError:
+ PrintString(kCRCFailed);
+ break;
+ case NArchive::NExtract::NOperationResult::kDataError:
+ PrintString(kDataError);
+ break;
+ default:
+ PrintString(kUnknownError);
+ }
+ }
+ }
+
+ if (_outFileStream != NULL)
+ {
+ if (_processedFileInfo.MTimeDefined)
+ _outFileStreamSpec->SetMTime(&_processedFileInfo.MTime);
+ RINOK(_outFileStreamSpec->Close());
+ }
+ _outFileStream.Release();
+ if (_extractMode && _processedFileInfo.AttribDefined)
+ NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attrib);
+ PrintNewLine();
+ return S_OK;
+}
+
+
+STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
+{
+ if (!PasswordIsDefined)
+ {
+ // You can ask real password here from user
+ // Password = GetPassword(OutStream);
+ // PasswordIsDefined = true;
+ PrintError("Password is not defined");
+ return E_ABORT;
+ }
+ return StringToBstr(Password, password);
+}
+
+
+
+//////////////////////////////////////////////////////////////
+// Archive Creating callback class
+
+struct CDirItem
+{
+ UInt64 Size;
+ FILETIME CTime;
+ FILETIME ATime;
+ FILETIME MTime;
+ UString Name;
+ UString FullPath;
+ UInt32 Attrib;
+
+ bool isDir() const { return (Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 ; }
+};
+
+class CArchiveUpdateCallback:
+ public IArchiveUpdateCallback2,
+ public ICryptoGetTextPassword2,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP2(IArchiveUpdateCallback2, ICryptoGetTextPassword2)
+
+ // IProgress
+ STDMETHOD(SetTotal)(UInt64 size);
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue);
+
+ // IUpdateCallback2
+ STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator);
+ STDMETHOD(GetUpdateItemInfo)(UInt32 index,
+ Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive);
+ STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream);
+ STDMETHOD(SetOperationResult)(Int32 operationResult);
+ STDMETHOD(GetVolumeSize)(UInt32 index, UInt64 *size);
+ STDMETHOD(GetVolumeStream)(UInt32 index, ISequentialOutStream **volumeStream);
+
+ STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
+
+public:
+ CRecordVector<UInt64> VolumesSizes;
+ UString VolName;
+ UString VolExt;
+
+ UString DirPrefix;
+ const CObjectVector<CDirItem> *DirItems;
+
+ bool PasswordIsDefined;
+ UString Password;
+ bool AskPassword;
+
+ bool m_NeedBeClosed;
+
+ UStringVector FailedFiles;
+ CRecordVector<HRESULT> FailedCodes;
+
+ CArchiveUpdateCallback(): PasswordIsDefined(false), AskPassword(false), DirItems(0) {};
+
+ ~CArchiveUpdateCallback() { Finilize(); }
+ HRESULT Finilize();
+
+ void Init(const CObjectVector<CDirItem> *dirItems)
+ {
+ DirItems = dirItems;
+ m_NeedBeClosed = false;
+ FailedFiles.Clear();
+ FailedCodes.Clear();
+ }
+};
+
+STDMETHODIMP CArchiveUpdateCallback::SetTotal(UInt64 /* size */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const UInt64 * /* completeValue */)
+{
+ return S_OK;
+}
+
+
+STDMETHODIMP CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG ** /* enumerator */)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
+ Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive)
+{
+ if (newData != NULL)
+ *newData = BoolToInt(true);
+ if (newProperties != NULL)
+ *newProperties = BoolToInt(true);
+ if (indexInArchive != NULL)
+ *indexInArchive = (UInt32)-1;
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+
+ if (propID == kpidIsAnti)
+ {
+ prop = false;
+ prop.Detach(value);
+ return S_OK;
+ }
+
+ {
+ const CDirItem &dirItem = (*DirItems)[index];
+ switch(propID)
+ {
+ case kpidPath: prop = dirItem.Name; break;
+ case kpidIsDir: prop = dirItem.isDir(); break;
+ case kpidSize: prop = dirItem.Size; break;
+ case kpidAttrib: prop = dirItem.Attrib; break;
+ case kpidCTime: prop = dirItem.CTime; break;
+ case kpidATime: prop = dirItem.ATime; break;
+ case kpidMTime: prop = dirItem.MTime; break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+HRESULT CArchiveUpdateCallback::Finilize()
+{
+ if (m_NeedBeClosed)
+ {
+ PrintNewLine();
+ m_NeedBeClosed = false;
+ }
+ return S_OK;
+}
+
+static void GetStream2(const wchar_t *name)
+{
+ PrintString("Compressing ");
+ if (name[0] == 0)
+ name = kEmptyFileAlias;
+ PrintString(name);
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
+{
+ RINOK(Finilize());
+
+ const CDirItem &dirItem = (*DirItems)[index];
+ GetStream2(dirItem.Name);
+
+ if (dirItem.isDir())
+ return S_OK;
+
+ {
+ CInFileStream *inStreamSpec = new CInFileStream;
+ CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
+ UString path = DirPrefix + dirItem.FullPath;
+ if (!inStreamSpec->Open(path))
+ {
+ DWORD sysError = ::GetLastError();
+ FailedCodes.Add(sysError);
+ FailedFiles.Add(path);
+ // if (systemError == ERROR_SHARING_VIOLATION)
+ {
+ PrintNewLine();
+ PrintError("WARNING: can't open file");
+ // PrintString(NError::MyFormatMessageW(systemError));
+ return S_FALSE;
+ }
+ // return sysError;
+ }
+ *inStream = inStreamLoc.Detach();
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveUpdateCallback::SetOperationResult(Int32 /* operationResult */)
+{
+ m_NeedBeClosed = true;
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size)
+{
+ if (VolumesSizes.Size() == 0)
+ return S_FALSE;
+ if (index >= (UInt32)VolumesSizes.Size())
+ index = VolumesSizes.Size() - 1;
+ *size = VolumesSizes[index];
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream)
+{
+ wchar_t temp[16];
+ ConvertUInt32ToString(index + 1, temp);
+ UString res = temp;
+ while (res.Length() < 2)
+ res = UString(L'0') + res;
+ UString fileName = VolName;
+ fileName += L'.';
+ fileName += res;
+ fileName += VolExt;
+ COutFileStream *streamSpec = new COutFileStream;
+ CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);
+ if (!streamSpec->Create(fileName, false))
+ return ::GetLastError();
+ *volumeStream = streamLoc.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ if (!PasswordIsDefined)
+ {
+ if (AskPassword)
+ {
+ // You can ask real password here from user
+ // Password = GetPassword(OutStream);
+ // PasswordIsDefined = true;
+ PrintError("Password is not defined");
+ return E_ABORT;
+ }
+ }
+ *passwordIsDefined = BoolToInt(PasswordIsDefined);
+ return StringToBstr(Password, password);
+}
+
+
+
+//////////////////////////////////////////////////////////////////////////
+// Main function
+
+int MY_CDECL main(int argc, char* argv[])
+{
+ #ifdef _WIN32
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+ #endif
+
+ PrintStringLn(kCopyrightString);
+
+ if (argc < 3)
+ {
+ PrintStringLn(kHelpString);
+ return 1;
+ }
+ NWindows::NDLL::CLibrary library;
+ if (!library.Load(TEXT(kDllName)))
+ {
+ PrintError("Can not load library");
+ return 1;
+ }
+ CreateObjectFunc createObjectFunc = (CreateObjectFunc)library.GetProcAddress("CreateObject");
+ if (createObjectFunc == 0)
+ {
+ PrintError("Can not get CreateObject");
+ return 1;
+ }
+
+ AString command = argv[1];
+ command.MakeLower();
+ UString archiveName = GetUnicodeString(argv[2], CP_OEMCP);
+ if (command.Compare("a") == 0)
+ {
+ // create archive command
+ if (argc < 4)
+ {
+ PrintStringLn(kHelpString);
+ return 1;
+ }
+ CObjectVector<CDirItem> dirItems;
+ int i;
+ for (i = 3; i < argc; i++)
+ {
+ CDirItem di;
+ UString name = GetUnicodeString(argv[i], CP_OEMCP);
+
+ NFile::NFind::CFileInfoW fi;
+ if (!fi.Find(name))
+ {
+ PrintString(UString(L"Can't find file") + name);
+ return 1;
+ }
+
+ di.Attrib = fi.Attrib;
+ di.Size = fi.Size;
+ di.CTime = fi.CTime;
+ di.ATime = fi.ATime;
+ di.MTime = fi.MTime;
+ di.Name = name;
+ di.FullPath = name;
+ dirItems.Add(di);
+ }
+ COutFileStream *outFileStreamSpec = new COutFileStream;
+ CMyComPtr<IOutStream> outFileStream = outFileStreamSpec;
+ if (!outFileStreamSpec->Create(archiveName, false))
+ {
+ PrintError("can't create archive file");
+ return 1;
+ }
+
+ CMyComPtr<IOutArchive> outArchive;
+ if (createObjectFunc(&CLSID_CFormat7z, &IID_IOutArchive, (void **)&outArchive) != S_OK)
+ {
+ PrintError("Can not get class object");
+ return 1;
+ }
+
+ CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
+ CMyComPtr<IArchiveUpdateCallback2> updateCallback(updateCallbackSpec);
+ updateCallbackSpec->Init(&dirItems);
+ // updateCallbackSpec->PasswordIsDefined = true;
+ // updateCallbackSpec->Password = L"1";
+
+ HRESULT result = outArchive->UpdateItems(outFileStream, dirItems.Size(), updateCallback);
+ updateCallbackSpec->Finilize();
+ if (result != S_OK)
+ {
+ PrintError("Update Error");
+ return 1;
+ }
+ for (i = 0; i < updateCallbackSpec->FailedFiles.Size(); i++)
+ {
+ PrintNewLine();
+ PrintString((UString)L"Error for file: " + updateCallbackSpec->FailedFiles[i]);
+ }
+ if (updateCallbackSpec->FailedFiles.Size() != 0)
+ return 1;
+ }
+ else
+ {
+ if (argc != 3)
+ {
+ PrintStringLn(kHelpString);
+ return 1;
+ }
+
+ bool listCommand;
+ if (command.Compare("l") == 0)
+ listCommand = true;
+ else if (command.Compare("x") == 0)
+ listCommand = false;
+ else
+ {
+ PrintError("incorrect command");
+ return 1;
+ }
+
+ CMyComPtr<IInArchive> archive;
+ if (createObjectFunc(&CLSID_CFormat7z, &IID_IInArchive, (void **)&archive) != S_OK)
+ {
+ PrintError("Can not get class object");
+ return 1;
+ }
+
+ CInFileStream *fileSpec = new CInFileStream;
+ CMyComPtr<IInStream> file = fileSpec;
+
+ if (!fileSpec->Open(archiveName))
+ {
+ PrintError("Can not open archive file");
+ return 1;
+ }
+
+ {
+ CArchiveOpenCallback *openCallbackSpec = new CArchiveOpenCallback;
+ CMyComPtr<IArchiveOpenCallback> openCallback(openCallbackSpec);
+ openCallbackSpec->PasswordIsDefined = false;
+ // openCallbackSpec->PasswordIsDefined = true;
+ // openCallbackSpec->Password = L"1";
+
+ if (archive->Open(file, 0, openCallback) != S_OK)
+ {
+ PrintError("Can not open archive");
+ return 1;
+ }
+ }
+
+ if (listCommand)
+ {
+ // List command
+ UInt32 numItems = 0;
+ archive->GetNumberOfItems(&numItems);
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ {
+ // Get uncompressed size of file
+ NWindows::NCOM::CPropVariant prop;
+ archive->GetProperty(i, kpidSize, &prop);
+ UString s = ConvertPropVariantToString(prop);
+ PrintString(s);
+ PrintString(" ");
+ }
+ {
+ // Get name of file
+ NWindows::NCOM::CPropVariant prop;
+ archive->GetProperty(i, kpidPath, &prop);
+ UString s = ConvertPropVariantToString(prop);
+ PrintString(s);
+ }
+ PrintString("\n");
+ }
+ }
+ else
+ {
+ // Extract command
+ CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
+ CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
+ extractCallbackSpec->Init(archive, L""); // second parameter is output folder path
+ extractCallbackSpec->PasswordIsDefined = false;
+ // extractCallbackSpec->PasswordIsDefined = true;
+ // extractCallbackSpec->Password = L"1";
+ HRESULT result = archive->Extract(NULL, (UInt32)(Int32)(-1), false, extractCallback);
+ if (result != S_OK)
+ {
+ PrintError("Extract Error");
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/ClientCodec/ClientCodec.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/ClientCodec/ClientCodec.cpp
new file mode 100644
index 000000000..664889bf7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/ClientCodec/ClientCodec.cpp
@@ -0,0 +1,370 @@
+// Client7z.cpp
+
+#include "StdAfx.h"
+
+#ifdef _WIN32
+#include <initguid.h>
+#else
+#include "Common/MyInitGuid.h"
+#endif
+
+#include "Windows/DLL.h"
+#include "../../ICoder.h"
+#include "Windows/PropVariant.h"
+#include "Common/MyCom.h"
+
+using namespace NWindows;
+
+class CFileIn : public ISequentialInStream, public CMyUnknownImp
+{
+ FILE *file_;
+ size_t pos_;
+ public:
+ MY_UNKNOWN_IMP
+
+ CFileIn() : file_(0) , pos_(0) { }
+ ~CFileIn() { this->close(); }
+
+ HRESULT open(const char *name)
+ {
+ file_ = fopen(name,"rb");
+ if (file_) return S_OK;
+ return E_FAIL;
+ }
+ void close()
+ {
+ if (file_) fclose(file_);
+ file_ = 0;
+ pos_ = 0;
+ }
+ HRESULT Read(void *data, UInt32 size, UInt32 *processedSize)
+ {
+ if (file_)
+ {
+ size_t ret = fread (data, 1, size, file_);
+ *processedSize = ret;
+ pos_ += ret;
+ // TBD : if ret == 0, test for feof/ferror
+ return S_OK;
+ }
+ return E_FAIL;
+ }
+ size_t pos() { return pos_; }
+};
+
+class CFileOut : public ISequentialOutStream, public CMyUnknownImp
+{
+ FILE *file_;
+ size_t pos_;
+ public:
+ MY_UNKNOWN_IMP
+
+ CFileOut() : file_(0) { }
+ ~CFileOut() { this->close(); }
+
+ HRESULT open(const char *name)
+ {
+ file_ = fopen(name,"wb");
+ if (file_) return S_OK;
+ return E_FAIL;
+ }
+ void close()
+ {
+ if (file_) fclose(file_);
+ file_ = 0;
+ }
+ HRESULT Write(const void *data, UInt32 size, UInt32 *processedSize)
+ {
+ if (file_)
+ {
+ size_t ret = fwrite(data, 1, size, file_);
+ *processedSize = ret;
+ pos_ += ret;
+ // TBD : if ret == 0, test for feof/ferror
+ return S_OK;
+ }
+ return E_FAIL;
+ }
+ size_t pos() { return pos_; }
+};
+
+//////////////////////////////////////////////////////////////////////////
+// Main function
+
+static const char *kHelpString =
+"Usage: ClientCodec codec.so [c | d | i] [file_in file_out]\n"
+"Examples:\n"
+" ClientCodec LZMA.so i : info about the codec\n"
+" ClientCodec LZMA.so e file_in file_out : encodes file_in to file_out\n"
+" ClientCodec LZMA.so d file_in file_out : decodes file_in to file_out\n"
+;
+
+typedef UINT32 (WINAPI * CreateObjectFunc)(
+ const GUID *clsID,
+ const GUID *interfaceID,
+ void **outObject);
+
+typedef UINT32 (WINAPI * GetNumberOfMethodsFunc)(UINT32 *numMethods);
+
+typedef UINT32 (WINAPI * GetMethodPropertyFunc)(UINT32 index, PROPID propID, PROPVARIANT *value);
+
+int main(int argc, char* argv[])
+{
+ if ((argc != 3) && (argc != 5))
+ {
+ printf(kHelpString);
+ return 1;
+ }
+
+ if ((argc == 3) && (strcmp(argv[2],"i") != 0))
+ {
+ printf(kHelpString);
+ return 1;
+ }
+
+ NWindows::NDLL::CLibrary library;
+ if (!library.Load(argv[1]))
+ {
+ printf("Can not load library %s\n",argv[1]);
+ return 1;
+ }
+ CreateObjectFunc createObjectFunc = (CreateObjectFunc)library.GetProcAddress("CreateObject");
+ if (createObjectFunc == 0)
+ {
+ printf("Can not get CreateObject\n");
+ return 1;
+ }
+
+ GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)library.GetProcAddress("GetNumberOfMethods");
+ if (getNumberOfMethodsFunc == 0)
+ {
+ printf("Can not get GetNumberOfMethodsFunc\n");
+ return 1;
+ }
+
+ UINT32 numMethods = 0;
+ HRESULT res = getNumberOfMethodsFunc(&numMethods);
+ if (res != S_OK)
+ {
+ printf("Error in GetNumberOfMethods\n");
+ return 1;
+ }
+
+ GetMethodPropertyFunc getMethodPropertyFunc = (GetMethodPropertyFunc)library.GetProcAddress("GetMethodProperty");
+ if (getMethodPropertyFunc == 0)
+ {
+ printf("Can not get GetMethodProperty\n");
+ return 1;
+ }
+
+ if (argv[2][0] == 'i')
+ {
+ printf("%s has %d method(s)\n",argv[1],(int)numMethods);
+
+ for(UINT32 m = 0; m < numMethods ; m++)
+ {
+ printf("\tMethod %d :\n",(int)m);
+ NCOM::CPropVariant propVariant;
+ res = getMethodPropertyFunc(m,NMethodPropID::kName,&propVariant);
+ if (res == S_OK)
+ {
+ if (propVariant.vt == VT_BSTR)
+ {
+ printf("\t\tName : %ls\n",propVariant.bstrVal); // Unicode Name
+ } else {
+ printf("\t\tName : Error\n");
+ }
+ } else {
+ printf("\t\tName : Unknown\n");
+ }
+ res = getMethodPropertyFunc(m,NMethodPropID::kDecoder,&propVariant);
+ if ((res == S_OK) && (propVariant.vt == VT_BSTR)) printf("\t\tDecoder : YES\n");
+ else printf("\t\tDecoder : NO\n");
+
+ res = getMethodPropertyFunc(m,NMethodPropID::kEncoder,&propVariant);
+ if ((res == S_OK) && (propVariant.vt == VT_BSTR)) printf("\t\tEncoder : YES\n");
+ else printf("\t\tEncoder : NO\n");
+ }
+ }
+
+ int numMethod = 0; // TBD
+
+ if (argv[2][0] == 'e')
+ {
+ NCOM::CPropVariant propVariant;
+ res = getMethodPropertyFunc(numMethod,NMethodPropID::kEncoder,&propVariant);
+ if ((res == S_OK) && (propVariant.vt == VT_BSTR))
+ {
+ CMyComPtr<ICompressCoder> outCoder;
+ if (createObjectFunc((const GUID *)propVariant.bstrVal, &IID_ICompressCoder, (void **)&outCoder) != S_OK)
+ {
+ printf("Can not get class object\n");
+ return 1;
+ }
+ printf("Encoding : ...\n");
+
+ CMyComPtr<CFileIn> inStream = new CFileIn;
+ res = inStream->open(argv[3]);
+ if (res != S_OK)
+ {
+ printf("cannot open %s\n",argv[3]);
+ return 1;
+ }
+
+ CMyComPtr<CFileOut> outStream = new CFileOut;
+ res = outStream->open(argv[4]);
+ if (res != S_OK)
+ {
+ printf("cannot open %s\n",argv[4]);
+ return 1;
+ }
+{
+ CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
+ outCoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
+ if (setCoderProperties != NULL)
+ {
+ printf("IID_ICompressSetCoderProperties : Found\n");
+ PROPID propID = NCoderPropID::kEndMarker;
+ NWindows::NCOM::CPropVariant value = true;
+ res = setCoderProperties->SetCoderProperties(&propID, &value, 1);
+ if (res = S_OK) printf("kEndMarker : ON\n");
+ else printf("kEndMarker : KO KO\n");
+ }
+ else
+ {
+ printf("IID_ICompressSetCoderProperties : NOT Found\n");
+ }
+}
+
+{
+ CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
+
+ outCoder.QueryInterface(IID_ICompressWriteCoderProperties, &writeCoderProperties);
+
+ if (writeCoderProperties != NULL)
+ {
+ UINT32 len = 5; // TBD
+ UInt32 processedSize;
+ outStream->Write(&len, sizeof(len), &processedSize);
+
+ printf("IID_ICompressWriteCoderProperties : Found\n");
+ size_t pos1 = outStream->pos();
+ writeCoderProperties->WriteCoderProperties(outStream);
+ size_t pos2 = outStream->pos();
+ printf("SizeOfProp : %d\n",(int)(pos2-pos1));
+/*
+ CSequentialOutStreamImp *outStreamSpec = new CSequentialOutStreamImp;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->Init();
+ writeCoderProperties->WriteCoderProperties(outStream);
+
+ size_t size = outStreamSpec->GetSize();
+
+ // encodingInfo.Properties.SetCapacity(size);
+ if (encodingInfo.AltCoders.Size() == 0)
+ encodingInfo.AltCoders.Add(CAltCoderInfo());
+ CAltCoderInfo &altCoderInfo = encodingInfo.AltCoders.Front();
+ altCoderInfo.Properties.SetCapacity(size);
+
+ memmove(altCoderInfo.Properties, outStreamSpec->GetBuffer(), size);
+*/
+ }
+ else
+ {
+ printf("IID_ICompressWriteCoderProperties : NOT Found\n");
+ UINT32 len = 0;
+ UInt32 processedSize;
+ outStream->Write(&len, sizeof(len), &processedSize);
+ }
+}
+
+ res = outCoder->Code(inStream,outStream,0,0,0);
+ inStream->close();
+ outStream->close();
+
+ if (res == S_OK)
+ {
+ printf("Encoding : Done\n");
+ } else {
+ printf("Encoding : Error\n");
+ return 1;
+ }
+ }
+ else
+ {
+ printf("Encoder not available\n");
+ return 1;
+ }
+ }
+
+ if (argv[2][0] == 'd')
+ {
+ NCOM::CPropVariant propVariant;
+ res = getMethodPropertyFunc(numMethod,NMethodPropID::kDecoder,&propVariant);
+ if ((res == S_OK) && (propVariant.vt == VT_BSTR))
+ {
+ CMyComPtr<ICompressCoder> outCoder;
+ if (createObjectFunc((const GUID *)propVariant.bstrVal, &IID_ICompressCoder, (void **)&outCoder) != S_OK)
+ {
+ printf("Can not get class object\n");
+ return 1;
+ }
+ printf("Decoding : ...\n");
+
+ CMyComPtr<CFileIn> inStream = new CFileIn;
+ res = inStream->open(argv[3]);
+ if (res != S_OK)
+ {
+ printf("cannot open %s\n",argv[3]);
+ return 1;
+ }
+
+ CMyComPtr<CFileOut> outStream = new CFileOut;
+ res = outStream->open(argv[4]);
+ if (res != S_OK)
+ {
+ printf("cannot open %s\n",argv[4]);
+ return 1;
+ }
+{
+ UINT32 len = 0;
+ UInt32 processedSize;
+ inStream->Read(&len, sizeof(len), &processedSize);
+
+ if (len > 0)
+ {
+ Byte props[256]; // TBD
+ inStream->Read(props, len, &processedSize);
+
+ CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
+ outCoder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
+ if (setDecoderProperties)
+ {
+ setDecoderProperties->SetDecoderProperties2(props, len);
+ printf("IID_ICompressSetDecoderProperties2 : Found (%d)\n",(int)len);
+ }
+ }
+}
+
+ // FIXME UInt64 outSize = 10511; // res = outCoder->Code(inStream,outStream,0,&outSize,0);
+ res = outCoder->Code(inStream,outStream,0,0,0);
+ inStream->close();
+ outStream->close();
+
+ if (res == S_OK)
+ {
+ printf("Decoding : Done\n");
+ } else {
+ printf("Decoding : Error\n");
+ return 1;
+ }
+ }
+ else
+ {
+ printf("Decoder not available\n");
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
new file mode 100644
index 000000000..2cec59a25
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
@@ -0,0 +1,1009 @@
+// ArchiveCommandLine.cpp
+
+#include "StdAfx.h"
+
+#ifdef _WIN32
+#include <io.h>
+#endif
+#include <stdio.h>
+
+#include "Common/ListFileUtils.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+#ifdef _WIN32
+//#include "Windows/FileMapping.h"
+//#include "Windows/Synchronization.h"
+#endif
+
+#include "ArchiveCommandLine.h"
+#include "EnumDirItems.h"
+#include "SortUtils.h"
+#include "Update.h"
+#include "UpdateAction.h"
+
+#include "myPrivate.h"
+
+#undef _WIN32
+
+extern bool g_CaseSensitive;
+
+#if _MSC_VER >= 1400
+#define MY_isatty_fileno(x) _isatty(_fileno(x))
+#else
+#define MY_isatty_fileno(x) isatty(fileno(x))
+#endif
+
+#define MY_IS_TERMINAL(x) (MY_isatty_fileno(x) != 0);
+
+using namespace NCommandLineParser;
+using namespace NWindows;
+using namespace NFile;
+
+namespace NKey {
+enum Enum
+{
+ kHelp1 = 0,
+ kHelp2,
+ kHelp3,
+ kDisableHeaders,
+ kDisablePercents,
+ kArchiveType,
+ kYes,
+ #ifndef _NO_CRYPTO
+ kPassword,
+ #endif
+ kProperty,
+ kOutputDir,
+ kWorkingDir,
+ kInclude,
+ kExclude,
+ kArInclude,
+ kArExclude,
+ kNoArName,
+ kUpdate,
+ kVolume,
+ kRecursed,
+ kSfx,
+ kStdIn,
+ kStdOut,
+ kOverwrite,
+ kEmail,
+ kShowDialog,
+ kUseLStat,
+ kTechMode,
+ kCaseSensitive,
+ kCalcCrc,
+};
+
+}
+
+
+static const wchar_t kRecursedIDChar = 'R';
+static const wchar_t *kRecursedPostCharSet = L"0-";
+
+namespace NRecursedPostCharIndex {
+ enum EEnum
+ {
+ kWildCardRecursionOnly = 0,
+ kNoRecursion = 1
+ };
+}
+
+static const char kImmediateNameID = '!';
+static const char kMapNameID = '#';
+static const char kFileListID = '@';
+
+static const char kSomeCludePostStringMinSize = 2; // at least <@|!><N>ame must be
+static const char kSomeCludeAfterRecursedPostStringMinSize = 2; // at least <@|!><N>ame must be
+
+static const wchar_t *kOverwritePostCharSet = L"asut";
+
+NExtract::NOverwriteMode::EEnum k_OverwriteModes[] =
+{
+ NExtract::NOverwriteMode::kWithoutPrompt,
+ NExtract::NOverwriteMode::kSkipExisting,
+ NExtract::NOverwriteMode::kAutoRename,
+ NExtract::NOverwriteMode::kAutoRenameExisting
+};
+
+static const CSwitchForm kSwitchForms[] =
+ {
+ { L"?", NSwitchType::kSimple, false, 0, 0, 0 },
+ { L"H", NSwitchType::kSimple, false, 0, 0, 0 },
+ { L"-HELP", NSwitchType::kSimple, false, 0, 0, 0 },
+ { L"BA", NSwitchType::kSimple, false, 0, 0, 0 },
+ { L"BD", NSwitchType::kSimple, false, 0, 0, 0 },
+ { L"T", NSwitchType::kUnLimitedPostString, false, 1, 0, 0 },
+ { L"Y", NSwitchType::kSimple, false, 0, 0, 0 },
+ #ifndef _NO_CRYPTO
+ { L"P", NSwitchType::kUnLimitedPostString, false, 0, 0, 0 },
+ #endif
+ { L"M", NSwitchType::kUnLimitedPostString, true, 1, 0, 0 },
+ { L"O", NSwitchType::kUnLimitedPostString, false, 1, 0, 0 },
+ { L"W", NSwitchType::kUnLimitedPostString, false, 0, 0, 0 },
+ { L"I", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize, 0, 0 },
+ { L"X", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize, 0, 0 },
+ { L"AI", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize, 0, 0 },
+ { L"AX", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize, 0, 0 },
+ { L"AN", NSwitchType::kSimple, false, 0, 0, 0 },
+ { L"U", NSwitchType::kUnLimitedPostString, true, 1, 0, 0 },
+ { L"V", NSwitchType::kUnLimitedPostString, true, 1, 0, 0 },
+ { L"R", NSwitchType::kPostChar, false, 0, 0, kRecursedPostCharSet },
+ { L"SFX", NSwitchType::kUnLimitedPostString, false, 0, 0, 0 },
+ { L"SI", NSwitchType::kUnLimitedPostString, false, 0, 0, 0 },
+ { L"SO", NSwitchType::kSimple, false, 0, 0 ,0 },
+ { L"AO", NSwitchType::kPostChar, false, 1, 1, kOverwritePostCharSet},
+ { L"SEML", NSwitchType::kUnLimitedPostString, false, 0, 0 ,0 },
+ { L"AD", NSwitchType::kSimple, false, 0, 0 ,0 },
+ { L"L", NSwitchType::kSimple, false, 0, 0, 0 },
+ { L"SLT", NSwitchType::kSimple, false, 0, 0 ,0 },
+ { L"SSC", NSwitchType::kPostChar, false, 0, 0, L"-" },
+ { L"SCRC", NSwitchType::kSimple, false, 0, 0, 0 }
+ };
+
+static const CCommandForm g_CommandForms[] =
+{
+ { L"A", false },
+ { L"U", false },
+ { L"D", false },
+ { L"T", false },
+ { L"E", false },
+ { L"X", false },
+ { L"L", false },
+ { L"B", false },
+ { L"I", false }
+};
+
+static const int kNumCommandForms = sizeof(g_CommandForms) / sizeof(g_CommandForms[0]);
+
+static const wchar_t *kUniversalWildcard = L"*";
+static const int kMinNonSwitchWords = 1;
+static const int kCommandIndex = 0;
+
+// ---------------------------
+// exception messages
+
+static const char *kUserErrorMessage = "Incorrect command line";
+static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
+static const char *kIncorrectWildCardInListFile = "Incorrect wildcard in listfile";
+static const char *kIncorrectWildCardInCommandLine = "Incorrect wildcard in command line";
+static const char *kTerminalOutError = "I won't write compressed data to a terminal";
+static const char *kSameTerminalError = "I won't write data and program's messages to same terminal";
+
+static void ThrowException(const char *errorMessage)
+{
+ throw CArchiveCommandLineException(errorMessage);
+};
+
+static void ThrowUserErrorException()
+{
+ ThrowException(kUserErrorMessage);
+};
+
+// ---------------------------
+
+bool CArchiveCommand::IsFromExtractGroup() const
+{
+ switch(CommandType)
+ {
+ case NCommandType::kTest:
+ case NCommandType::kExtract:
+ case NCommandType::kFullExtract:
+ return true;
+ default:
+ return false;
+ }
+}
+
+NExtract::NPathMode::EEnum CArchiveCommand::GetPathMode() const
+{
+ switch(CommandType)
+ {
+ case NCommandType::kTest:
+ case NCommandType::kFullExtract:
+ return NExtract::NPathMode::kFullPathnames;
+ default:
+ return NExtract::NPathMode::kNoPathnames;
+ }
+}
+
+bool CArchiveCommand::IsFromUpdateGroup() const
+{
+ return (CommandType == NCommandType::kAdd ||
+ CommandType == NCommandType::kUpdate ||
+ CommandType == NCommandType::kDelete);
+}
+
+static NRecursedType::EEnum GetRecursedTypeFromIndex(int index)
+{
+ switch (index)
+ {
+ case NRecursedPostCharIndex::kWildCardRecursionOnly:
+ return NRecursedType::kWildCardOnlyRecursed;
+ case NRecursedPostCharIndex::kNoRecursion:
+ return NRecursedType::kNonRecursed;
+ default:
+ return NRecursedType::kRecursed;
+ }
+}
+
+static bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &command)
+{
+ UString commandStringUpper = commandString;
+ commandStringUpper.MakeUpper();
+ UString postString;
+ int commandIndex = ParseCommand(kNumCommandForms, g_CommandForms, commandStringUpper,
+ postString) ;
+ if (commandIndex < 0)
+ return false;
+ command.CommandType = (NCommandType::EEnum)commandIndex;
+ return true;
+}
+
+// ------------------------------------------------------------------
+// filenames functions
+
+static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
+ const UString &name, bool include, NRecursedType::EEnum type)
+{
+ bool isWildCard = DoesNameContainWildCard(name);
+ bool recursed = false;
+
+ switch (type)
+ {
+ case NRecursedType::kWildCardOnlyRecursed:
+ recursed = isWildCard;
+ break;
+ case NRecursedType::kRecursed:
+ recursed = true;
+ break;
+ case NRecursedType::kNonRecursed:
+ recursed = false;
+ break;
+ }
+ wildcardCensor.AddItem(include, name, recursed);
+ return true;
+}
+
+static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
+ LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
+{
+ UStringVector names;
+ if (!ReadNamesFromListFile(fileName, names, codePage))
+ throw kIncorrectListFile;
+ for (int i = 0; i < names.Size(); i++)
+ if (!AddNameToCensor(wildcardCensor, names[i], include, type))
+ throw kIncorrectWildCardInListFile;
+}
+
+static void AddCommandLineWildCardToCensr(NWildcard::CCensor &wildcardCensor,
+ const UString &name, bool include, NRecursedType::EEnum recursedType)
+{
+ if (!AddNameToCensor(wildcardCensor, name, include, recursedType))
+ throw kIncorrectWildCardInCommandLine;
+}
+
+static void AddToCensorFromNonSwitchesStrings(
+ int startIndex,
+ NWildcard::CCensor &wildcardCensor,
+ const UStringVector &nonSwitchStrings, NRecursedType::EEnum type,
+ bool thereAreSwitchIncludes, UINT codePage)
+{
+ if (nonSwitchStrings.Size() == startIndex && (!thereAreSwitchIncludes))
+ AddCommandLineWildCardToCensr(wildcardCensor, kUniversalWildcard, true, type);
+ for (int i = startIndex; i < nonSwitchStrings.Size(); i++)
+ {
+ const UString &s = nonSwitchStrings[i];
+ if (s[0] == kFileListID)
+ AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type, codePage);
+ else
+ AddCommandLineWildCardToCensr(wildcardCensor, s, true, type);
+ }
+}
+
+#ifdef _WIN32
+static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
+ const UString &switchParam, bool include,
+ NRecursedType::EEnum commonRecursedType)
+{
+ int splitPos = switchParam.Find(L':');
+ if (splitPos < 0)
+ ThrowUserErrorException();
+ UString mappingName = switchParam.Left(splitPos);
+
+ UString switchParam2 = switchParam.Mid(splitPos + 1);
+ splitPos = switchParam2.Find(L':');
+ if (splitPos < 0)
+ ThrowUserErrorException();
+
+ UString mappingSize = switchParam2.Left(splitPos);
+ UString eventName = switchParam2.Mid(splitPos + 1);
+
+ UInt64 dataSize64 = ConvertStringToUInt64(mappingSize, NULL);
+ UInt32 dataSize = (UInt32)dataSize64;
+ {
+ CFileMapping fileMapping;
+ if (!fileMapping.Open(FILE_MAP_READ, false, GetSystemString(mappingName)))
+ ThrowException("Can not open mapping");
+ LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_READ, 0, dataSize);
+ if (data == NULL)
+ ThrowException("MapViewOfFile error");
+ try
+ {
+ const wchar_t *curData = (const wchar_t *)data;
+ if (*curData != 0)
+ ThrowException("Incorrect mapping data");
+ UInt32 numChars = dataSize / sizeof(wchar_t);
+ UString name;
+ for (UInt32 i = 1; i < numChars; i++)
+ {
+ wchar_t c = curData[i];
+ if (c == L'\0')
+ {
+ AddCommandLineWildCardToCensr(wildcardCensor,
+ name, include, commonRecursedType);
+ name.Empty();
+ }
+ else
+ name += c;
+ }
+ if (!name.IsEmpty())
+ ThrowException("data error");
+ }
+ catch(...)
+ {
+ UnmapViewOfFile(data);
+ throw;
+ }
+ UnmapViewOfFile(data);
+ }
+
+ {
+ NSynchronization::CManualResetEvent event;
+ if (event.Open(EVENT_MODIFY_STATE, false, GetSystemString(eventName)) == S_OK)
+ event.Set();
+ }
+}
+#endif
+
+static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
+ const UStringVector &strings, bool include,
+ NRecursedType::EEnum commonRecursedType, UINT codePage)
+{
+ for (int i = 0; i < strings.Size(); i++)
+ {
+ const UString &name = strings[i];
+ NRecursedType::EEnum recursedType;
+ int pos = 0;
+ if (name.Length() < kSomeCludePostStringMinSize)
+ ThrowUserErrorException();
+ if (::MyCharUpper(name[pos]) == kRecursedIDChar)
+ {
+ pos++;
+ int index = UString(kRecursedPostCharSet).Find(name[pos]);
+ recursedType = GetRecursedTypeFromIndex(index);
+ if (index >= 0)
+ pos++;
+ }
+ else
+ recursedType = commonRecursedType;
+ if (name.Length() < pos + kSomeCludeAfterRecursedPostStringMinSize)
+ ThrowUserErrorException();
+ UString tail = name.Mid(pos + 1);
+ if (name[pos] == kImmediateNameID)
+ AddCommandLineWildCardToCensr(wildcardCensor, tail, include, recursedType);
+ else if (name[pos] == kFileListID)
+ AddToCensorFromListFile(wildcardCensor, tail, include, recursedType, codePage);
+ #ifdef _WIN32
+ else if (name[pos] == kMapNameID)
+ ParseMapWithPaths(wildcardCensor, tail, include, recursedType);
+ #endif
+ else
+ ThrowUserErrorException();
+ }
+}
+
+#ifdef _WIN32
+
+// This code converts all short file names to long file names.
+
+static void ConvertToLongName(const UString &prefix, UString &name)
+{
+ if (name.IsEmpty() || DoesNameContainWildCard(name))
+ return;
+ NFind::CFileInfoW fi;
+ if (fi.Find(prefix + name))
+ name = fi.Name;
+}
+
+static void ConvertToLongNames(const UString &prefix, CObjectVector<NWildcard::CItem> &items)
+{
+ for (int i = 0; i < items.Size(); i++)
+ {
+ NWildcard::CItem &item = items[i];
+ if (item.Recursive || item.PathParts.Size() != 1)
+ continue;
+ ConvertToLongName(prefix, item.PathParts.Front());
+ }
+}
+
+static void ConvertToLongNames(const UString &prefix, NWildcard::CCensorNode &node)
+{
+ ConvertToLongNames(prefix, node.IncludeItems);
+ ConvertToLongNames(prefix, node.ExcludeItems);
+ int i;
+ for (i = 0; i < node.SubNodes.Size(); i++)
+ ConvertToLongName(prefix, node.SubNodes[i].Name);
+ // mix folders with same name
+ for (i = 0; i < node.SubNodes.Size(); i++)
+ {
+ NWildcard::CCensorNode &nextNode1 = node.SubNodes[i];
+ for (int j = i + 1; j < node.SubNodes.Size();)
+ {
+ const NWildcard::CCensorNode &nextNode2 = node.SubNodes[j];
+ if (nextNode1.Name.CompareNoCase(nextNode2.Name) == 0)
+ {
+ nextNode1.IncludeItems += nextNode2.IncludeItems;
+ nextNode1.ExcludeItems += nextNode2.ExcludeItems;
+ node.SubNodes.Delete(j);
+ }
+ else
+ j++;
+ }
+ }
+ for (i = 0; i < node.SubNodes.Size(); i++)
+ {
+ NWildcard::CCensorNode &nextNode = node.SubNodes[i];
+ ConvertToLongNames(prefix + nextNode.Name + wchar_t(NFile::NName::kDirDelimiter), nextNode);
+ }
+}
+
+static void ConvertToLongNames(NWildcard::CCensor &censor)
+{
+ for (int i = 0; i < censor.Pairs.Size(); i++)
+ {
+ NWildcard::CPair &pair = censor.Pairs[i];
+ ConvertToLongNames(pair.Prefix, pair.Head);
+ }
+}
+
+#endif
+
+static NUpdateArchive::NPairAction::EEnum GetUpdatePairActionType(int i)
+{
+ switch(i)
+ {
+ case NUpdateArchive::NPairAction::kIgnore: return NUpdateArchive::NPairAction::kIgnore;
+ case NUpdateArchive::NPairAction::kCopy: return NUpdateArchive::NPairAction::kCopy;
+ case NUpdateArchive::NPairAction::kCompress: return NUpdateArchive::NPairAction::kCompress;
+ case NUpdateArchive::NPairAction::kCompressAsAnti: return NUpdateArchive::NPairAction::kCompressAsAnti;
+ }
+ throw 98111603;
+}
+
+const UString kUpdatePairStateIDSet = L"PQRXYZW";
+const int kUpdatePairStateNotSupportedActions[] = {2, 2, 1, -1, -1, -1, -1};
+
+const UString kUpdatePairActionIDSet = L"0123"; //Ignore, Copy, Compress, Create Anti
+
+const wchar_t *kUpdateIgnoreItselfPostStringID = L"-";
+const wchar_t kUpdateNewArchivePostCharID = '!';
+
+
+static bool ParseUpdateCommandString2(const UString &command,
+ NUpdateArchive::CActionSet &actionSet, UString &postString)
+{
+ for (int i = 0; i < command.Length();)
+ {
+ wchar_t c = MyCharUpper(command[i]);
+ int statePos = kUpdatePairStateIDSet.Find(c);
+ if (statePos < 0)
+ {
+ postString = command.Mid(i);
+ return true;
+ }
+ i++;
+ if (i >= command.Length())
+ return false;
+ int actionPos = kUpdatePairActionIDSet.Find(::MyCharUpper(command[i]));
+ if (actionPos < 0)
+ return false;
+ actionSet.StateActions[statePos] = GetUpdatePairActionType(actionPos);
+ if (kUpdatePairStateNotSupportedActions[statePos] == actionPos)
+ return false;
+ i++;
+ }
+ postString.Empty();
+ return true;
+}
+
+static void ParseUpdateCommandString(CUpdateOptions &options,
+ const UStringVector &updatePostStrings,
+ const NUpdateArchive::CActionSet &defaultActionSet)
+{
+ for (int i = 0; i < updatePostStrings.Size(); i++)
+ {
+ const UString &updateString = updatePostStrings[i];
+ if (updateString.CompareNoCase(kUpdateIgnoreItselfPostStringID) == 0)
+ {
+ if (options.UpdateArchiveItself)
+ {
+ options.UpdateArchiveItself = false;
+ options.Commands.Delete(0);
+ }
+ }
+ else
+ {
+ NUpdateArchive::CActionSet actionSet = defaultActionSet;
+
+ UString postString;
+ if (!ParseUpdateCommandString2(updateString, actionSet, postString))
+ ThrowUserErrorException();
+ if (postString.IsEmpty())
+ {
+ if (options.UpdateArchiveItself)
+ options.Commands[0].ActionSet = actionSet;
+ }
+ else
+ {
+ if (MyCharUpper(postString[0]) != kUpdateNewArchivePostCharID)
+ ThrowUserErrorException();
+ CUpdateArchiveCommand uc;
+ UString archivePath = postString.Mid(1);
+ if (archivePath.IsEmpty())
+ ThrowUserErrorException();
+ uc.UserArchivePath = archivePath;
+ uc.ActionSet = actionSet;
+ options.Commands.Add(uc);
+ }
+ }
+ }
+}
+
+static const char kByteSymbol = 'B';
+static const char kKiloSymbol = 'K';
+static const char kMegaSymbol = 'M';
+static const char kGigaSymbol = 'G';
+
+static bool ParseComplexSize(const UString &src, UInt64 &result)
+{
+ UString s = src;
+ s.MakeUpper();
+
+ const wchar_t *start = s;
+ const wchar_t *end;
+ UInt64 number = ConvertStringToUInt64(start, &end);
+ int numDigits = (int)(end - start);
+ if (numDigits == 0 || s.Length() > numDigits + 1)
+ return false;
+ if (s.Length() == numDigits)
+ {
+ result = number;
+ return true;
+ }
+ int numBits;
+ switch (s[numDigits])
+ {
+ case kByteSymbol:
+ result = number;
+ return true;
+ case kKiloSymbol:
+ numBits = 10;
+ break;
+ case kMegaSymbol:
+ numBits = 20;
+ break;
+ case kGigaSymbol:
+ numBits = 30;
+ break;
+ default:
+ return false;
+ }
+ if (number >= ((UInt64)1 << (64 - numBits)))
+ return false;
+ result = number << numBits;
+ return true;
+}
+
+static void SetAddCommandOptions(
+ NCommandType::EEnum commandType,
+ const CParser &parser,
+ CUpdateOptions &options)
+{
+ NUpdateArchive::CActionSet defaultActionSet;
+ switch(commandType)
+ {
+ case NCommandType::kAdd:
+ defaultActionSet = NUpdateArchive::kAddActionSet;
+ break;
+ case NCommandType::kDelete:
+ defaultActionSet = NUpdateArchive::kDeleteActionSet;
+ break;
+ default:
+ defaultActionSet = NUpdateArchive::kUpdateActionSet;
+ }
+
+ options.UpdateArchiveItself = true;
+
+ options.Commands.Clear();
+ CUpdateArchiveCommand updateMainCommand;
+ updateMainCommand.ActionSet = defaultActionSet;
+ options.Commands.Add(updateMainCommand);
+ if (parser[NKey::kUpdate].ThereIs)
+ ParseUpdateCommandString(options, parser[NKey::kUpdate].PostStrings,
+ defaultActionSet);
+ if (parser[NKey::kWorkingDir].ThereIs)
+ {
+ const UString &postString = parser[NKey::kWorkingDir].PostStrings[0];
+ if (postString.IsEmpty())
+ NDirectory::MyGetTempPath(options.WorkingDir);
+ else
+ options.WorkingDir = postString;
+ }
+ options.SfxMode = parser[NKey::kSfx].ThereIs;
+ if (options.SfxMode)
+ options.SfxModule = parser[NKey::kSfx].PostStrings[0];
+
+ if (parser[NKey::kVolume].ThereIs)
+ {
+ const UStringVector &sv = parser[NKey::kVolume].PostStrings;
+ for (int i = 0; i < sv.Size(); i++)
+ {
+ UInt64 size = 0;
+ if (!ParseComplexSize(sv[i], size))
+ ThrowException("Incorrect volume size");
+ options.VolumesSizes.Add(size);
+ }
+ }
+}
+
+static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &properties)
+{
+ if (parser[NKey::kProperty].ThereIs)
+ {
+ // options.MethodMode.Properties.Clear();
+ for (int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
+ {
+ CProperty property;
+ const UString &postString = parser[NKey::kProperty].PostStrings[i];
+ int index = postString.Find(L'=');
+ if (index < 0)
+ property.Name = postString;
+ else
+ {
+ property.Name = postString.Left(index);
+ property.Value = postString.Mid(index + 1);
+ }
+ properties.Add(property);
+ }
+ }
+}
+
+CArchiveCommandLineParser::CArchiveCommandLineParser():
+ parser(sizeof(kSwitchForms) / sizeof(kSwitchForms[0])) {}
+
+void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
+ CArchiveCommandLineOptions &options)
+{
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
+ }
+ catch(...)
+ {
+ ThrowUserErrorException();
+ }
+
+ options.IsInTerminal = MY_IS_TERMINAL(stdin);
+ options.IsStdOutTerminal = MY_IS_TERMINAL(stdout);
+ options.IsStdErrTerminal = MY_IS_TERMINAL(stderr);
+ options.StdInMode = parser[NKey::kStdIn].ThereIs;
+ options.StdOutMode = parser[NKey::kStdOut].ThereIs;
+ options.EnableHeaders = !parser[NKey::kDisableHeaders].ThereIs;
+ options.HelpMode = parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs || parser[NKey::kHelp3].ThereIs;
+
+ #ifdef _WIN32
+ options.LargePages = false;
+ if (parser[NKey::kLargePages].ThereIs)
+ {
+ const UString &postString = parser[NKey::kLargePages].PostStrings.Front();
+ if (postString.IsEmpty())
+ options.LargePages = true;
+ }
+ #endif
+}
+
+static bool ConvertStringToUInt32(const wchar_t *s, UInt32 &v)
+{
+ const wchar_t *end;
+ UInt64 number = ConvertStringToUInt64(s, &end);
+ if (*end != 0)
+ return false;
+ if (number > (UInt32)0xFFFFFFFF)
+ return false;
+ v = (UInt32)number;
+ return true;
+}
+
+void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
+{
+ const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
+ int numNonSwitchStrings = nonSwitchStrings.Size();
+ if (numNonSwitchStrings < kMinNonSwitchWords)
+ ThrowUserErrorException();
+
+ if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], options.Command))
+ ThrowUserErrorException();
+
+ options.TechMode = parser[NKey::kTechMode].ThereIs;
+ options.CalcCrc = parser[NKey::kCalcCrc].ThereIs;
+
+ if (parser[NKey::kCaseSensitive].ThereIs)
+ g_CaseSensitive = (parser[NKey::kCaseSensitive].PostCharIndex < 0);
+
+ NRecursedType::EEnum recursedType;
+ if (parser[NKey::kRecursed].ThereIs)
+ recursedType = GetRecursedTypeFromIndex(parser[NKey::kRecursed].PostCharIndex);
+ else
+ recursedType = NRecursedType::kNonRecursed;
+
+ UINT codePage = CP_ACP;
+
+ bool thereAreSwitchIncludes = false;
+ if (parser[NKey::kInclude].ThereIs)
+ {
+ thereAreSwitchIncludes = true;
+ AddSwitchWildCardsToCensor(options.WildcardCensor,
+ parser[NKey::kInclude].PostStrings, true, recursedType, codePage);
+ }
+ if (parser[NKey::kExclude].ThereIs)
+ AddSwitchWildCardsToCensor(options.WildcardCensor,
+ parser[NKey::kExclude].PostStrings, false, recursedType, codePage);
+
+ int curCommandIndex = kCommandIndex + 1;
+ bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs &&
+ options.Command.CommandType != NCommandType::kBenchmark &&
+ options.Command.CommandType != NCommandType::kInfo;
+
+ bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
+ bool isExtractOrList = isExtractGroupCommand || options.Command.CommandType == NCommandType::kList;
+
+ if (isExtractOrList && options.StdInMode)
+ thereIsArchiveName = false;
+
+ if (thereIsArchiveName)
+ {
+ if (curCommandIndex >= numNonSwitchStrings)
+ ThrowUserErrorException();
+ options.ArchiveName = nonSwitchStrings[curCommandIndex++];
+ }
+
+ AddToCensorFromNonSwitchesStrings(
+ curCommandIndex, options.WildcardCensor,
+ nonSwitchStrings, recursedType, thereAreSwitchIncludes, codePage);
+
+ options.YesToAll = parser[NKey::kYes].ThereIs;
+
+#ifdef HAVE_LSTAT
+ global_use_lstat = !parser[NKey::kUseLStat].ThereIs;
+#endif
+
+ #ifndef _NO_CRYPTO
+ options.PasswordEnabled = parser[NKey::kPassword].ThereIs;
+ if (options.PasswordEnabled)
+ options.Password = parser[NKey::kPassword].PostStrings[0];
+ #endif
+
+ options.ShowDialog = parser[NKey::kShowDialog].ThereIs;
+
+ if (parser[NKey::kArchiveType].ThereIs)
+ options.ArcType = parser[NKey::kArchiveType].PostStrings[0];
+
+ if (isExtractOrList)
+ {
+ if (!options.WildcardCensor.AllAreRelative())
+ ThrowException("Cannot use absolute pathnames for this command");
+
+ NWildcard::CCensor archiveWildcardCensor;
+
+ if (parser[NKey::kArInclude].ThereIs)
+ {
+ AddSwitchWildCardsToCensor(archiveWildcardCensor,
+ parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage);
+ }
+ if (parser[NKey::kArExclude].ThereIs)
+ AddSwitchWildCardsToCensor(archiveWildcardCensor,
+ parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage);
+
+ bool directlyAddArchiveName = false;
+ if (thereIsArchiveName) {
+ if ((options.ArchiveName.Find(kUniversalWildcard) == -1) && (options.ArchiveName.Find(L"?") == -1)) {
+ // no wildcard => no need to scan
+ directlyAddArchiveName = true;
+ } else {
+ AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);
+ }
+ }
+
+ #ifdef _WIN32
+ ConvertToLongNames(archiveWildcardCensor);
+ #endif
+
+ archiveWildcardCensor.ExtendExclude();
+
+ if (options.StdInMode)
+ {
+ UString arcName = parser[NKey::kStdIn].PostStrings.Front();
+ options.ArchivePathsSorted.Add(arcName);
+ options.ArchivePathsFullSorted.Add(arcName);
+ }
+ else
+ {
+
+ UStringVector archivePaths;
+
+ {
+ CDirItems dirItems;
+ {
+ UStringVector errorPaths;
+ CRecordVector<DWORD> errorCodes;
+ HRESULT res = EnumerateItems(archiveWildcardCensor, dirItems, NULL, errorPaths, errorCodes);
+ if (res != S_OK || errorPaths.Size() > 0)
+ throw "cannot find archive";
+ }
+ for (int i = 0; i < dirItems.Items.Size(); i++)
+ {
+ const CDirItem &dirItem = dirItems.Items[i];
+ if (!dirItem.IsDir())
+ archivePaths.Add(dirItems.GetPhyPath(i));
+ }
+ }
+
+ // Because the pathname of archive can be a symbolic link
+ // do not use "AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName"
+ if (directlyAddArchiveName)
+ archivePaths.Add(options.ArchiveName);
+
+ if (archivePaths.Size() == 0)
+ throw "there is no such archive";
+
+ UStringVector archivePathsFull;
+
+ int i;
+ for (i = 0; i < archivePaths.Size(); i++)
+ {
+ UString fullPath;
+ NFile::NDirectory::MyGetFullPathName(archivePaths[i], fullPath);
+ archivePathsFull.Add(fullPath);
+ }
+ CIntVector indices;
+ SortFileNames(archivePathsFull, indices);
+ options.ArchivePathsSorted.Reserve(indices.Size());
+ options.ArchivePathsFullSorted.Reserve(indices.Size());
+ for (i = 0; i < indices.Size(); i++)
+ {
+ options.ArchivePathsSorted.Add(archivePaths[indices[i]]);
+ options.ArchivePathsFullSorted.Add(archivePathsFull[indices[i]]);
+ }
+
+ }
+
+ if (isExtractGroupCommand)
+ {
+ SetMethodOptions(parser, options.ExtractProperties);
+ if (options.StdOutMode && options.IsStdOutTerminal && options.IsStdErrTerminal)
+ throw kSameTerminalError;
+ if (parser[NKey::kOutputDir].ThereIs)
+ {
+ options.OutputDir = parser[NKey::kOutputDir].PostStrings[0];
+ NFile::NName::NormalizeDirPathPrefix(options.OutputDir);
+ }
+
+ options.OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
+ if (parser[NKey::kOverwrite].ThereIs)
+ options.OverwriteMode =
+ k_OverwriteModes[parser[NKey::kOverwrite].PostCharIndex];
+ else if (options.YesToAll)
+ options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
+ }
+ }
+ else if (options.Command.IsFromUpdateGroup())
+ {
+ CUpdateOptions &updateOptions = options.UpdateOptions;
+
+ SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
+
+ SetMethodOptions(parser, updateOptions.MethodMode.Properties);
+
+ options.EnablePercents = !parser[NKey::kDisablePercents].ThereIs;
+
+ if (options.EnablePercents)
+ {
+ if ((options.StdOutMode && !options.IsStdErrTerminal) ||
+ (!options.StdOutMode && !options.IsStdOutTerminal))
+ options.EnablePercents = false;
+ }
+
+ updateOptions.EMailMode = parser[NKey::kEmail].ThereIs;
+ if (updateOptions.EMailMode)
+ {
+ updateOptions.EMailAddress = parser[NKey::kEmail].PostStrings.Front();
+ if (updateOptions.EMailAddress.Length() > 0)
+ if (updateOptions.EMailAddress[0] == L'.')
+ {
+ updateOptions.EMailRemoveAfter = true;
+ updateOptions.EMailAddress.Delete(0);
+ }
+ }
+
+ updateOptions.StdOutMode = options.StdOutMode;
+ updateOptions.StdInMode = options.StdInMode;
+
+ if (updateOptions.StdOutMode && updateOptions.EMailMode)
+ throw "stdout mode and email mode cannot be combined";
+ if (updateOptions.StdOutMode && options.IsStdOutTerminal)
+ throw kTerminalOutError;
+ if (updateOptions.StdInMode)
+ updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();
+
+ #ifdef _WIN32
+ ConvertToLongNames(options.WildcardCensor);
+ #endif
+ }
+ else if (options.Command.CommandType == NCommandType::kBenchmark)
+ {
+ options.NumThreads = (UInt32)-1;
+ options.DictionarySize = (UInt32)-1;
+ options.NumIterations = 1;
+ if (curCommandIndex < numNonSwitchStrings)
+ {
+ if (!ConvertStringToUInt32(nonSwitchStrings[curCommandIndex++], options.NumIterations))
+ ThrowUserErrorException();
+ }
+ for (int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
+ {
+ UString postString = parser[NKey::kProperty].PostStrings[i];
+ postString.MakeUpper();
+ if (postString.Length() < 2)
+ ThrowUserErrorException();
+ if (postString[0] == 'D')
+ {
+ int pos = 1;
+ if (postString[pos] == '=')
+ pos++;
+ UInt32 logSize;
+ if (!ConvertStringToUInt32((const wchar_t *)postString + pos, logSize))
+ ThrowUserErrorException();
+ if (logSize > 31)
+ ThrowUserErrorException();
+ options.DictionarySize = 1 << logSize;
+ }
+ else if (postString[0] == 'M' && postString[1] == 'T' )
+ {
+ int pos = 2;
+ if (postString[pos] == '=')
+ pos++;
+ if (postString[pos] != 0)
+ if (!ConvertStringToUInt32((const wchar_t *)postString + pos, options.NumThreads))
+ ThrowUserErrorException();
+ }
+ else if (postString[0] == 'M' && postString[1] == '=' )
+ {
+ int pos = 2;
+ if (postString[pos] != 0)
+ options.Method = postString.Mid(2);
+ }
+ else
+ ThrowUserErrorException();
+ }
+ }
+ else if (options.Command.CommandType == NCommandType::kInfo)
+ {
+ }
+ else
+ ThrowUserErrorException();
+ options.WildcardCensor.ExtendExclude();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveCommandLine.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveCommandLine.h
new file mode 100644
index 000000000..6f79b7eeb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveCommandLine.h
@@ -0,0 +1,107 @@
+// ArchiveCommandLine.h
+
+#ifndef __ARCHIVECOMMANDLINE_H
+#define __ARCHIVECOMMANDLINE_H
+
+#include "Common/Wildcard.h"
+#include "Common/CommandLineParser.h"
+
+#include "Extract.h"
+#include "Update.h"
+
+struct CArchiveCommandLineException: public AString
+{
+ CArchiveCommandLineException(const char *errorMessage): AString(errorMessage) {}
+};
+
+namespace NCommandType { enum EEnum
+{
+ kAdd = 0,
+ kUpdate,
+ kDelete,
+ kTest,
+ kExtract,
+ kFullExtract,
+ kList,
+ kBenchmark,
+ kInfo
+};}
+
+namespace NRecursedType { enum EEnum
+{
+ kRecursed,
+ kWildCardOnlyRecursed,
+ kNonRecursed
+};}
+
+struct CArchiveCommand
+{
+ NCommandType::EEnum CommandType;
+ bool IsFromExtractGroup() const;
+ bool IsFromUpdateGroup() const;
+ bool IsTestMode() const { return CommandType == NCommandType::kTest; }
+ NExtract::NPathMode::EEnum GetPathMode() const;
+};
+
+struct CArchiveCommandLineOptions
+{
+ bool HelpMode;
+
+ #ifdef _WIN32
+ bool LargePages;
+ #endif
+
+ bool IsInTerminal;
+ bool IsStdOutTerminal;
+ bool IsStdErrTerminal;
+ bool StdInMode;
+ bool StdOutMode;
+ bool EnableHeaders;
+
+ bool YesToAll;
+ bool ShowDialog;
+ // NWildcard::CCensor ArchiveWildcardCensor;
+ NWildcard::CCensor WildcardCensor;
+
+ CArchiveCommand Command;
+ UString ArchiveName;
+
+ #ifndef _NO_CRYPTO
+ bool PasswordEnabled;
+ UString Password;
+ #endif
+
+ bool TechMode;
+ // Extract
+ bool CalcCrc;
+ bool AppendName;
+ UString OutputDir;
+ NExtract::NOverwriteMode::EEnum OverwriteMode;
+ UStringVector ArchivePathsSorted;
+ UStringVector ArchivePathsFullSorted;
+ CObjectVector<CProperty> ExtractProperties;
+
+ CUpdateOptions UpdateOptions;
+ UString ArcType;
+ bool EnablePercents;
+
+ // Benchmark
+ UInt32 NumIterations;
+ UInt32 NumThreads;
+ UInt32 DictionarySize;
+ UString Method;
+
+
+ CArchiveCommandLineOptions(): StdInMode(false), StdOutMode(false) {};
+};
+
+class CArchiveCommandLineParser
+{
+ NCommandLineParser::CParser parser;
+public:
+ CArchiveCommandLineParser();
+ void Parse1(const UStringVector &commandStrings, CArchiveCommandLineOptions &options);
+ void Parse2(CArchiveCommandLineOptions &options);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
new file mode 100644
index 000000000..acd1f0906
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
@@ -0,0 +1,490 @@
+// ArchiveExtractCallback.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/Wildcard.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../Common/FilePathAutoRename.h"
+
+#include "../Common/ExtractingFilePath.h"
+
+#include "ArchiveExtractCallback.h"
+
+using namespace NWindows;
+
+static const wchar_t *kCantAutoRename = L"ERROR: Can not create file with auto name";
+static const wchar_t *kCantRenameFile = L"ERROR: Can not rename existing file ";
+static const wchar_t *kCantDeleteOutputFile = L"ERROR: Can not delete output file ";
+
+void CArchiveExtractCallback::Init(
+ const NWildcard::CCensorNode *wildcardCensor,
+ const CArc *arc,
+ IFolderArchiveExtractCallback *extractCallback2,
+ bool stdOutMode, bool testMode, bool crcMode,
+ const UString &directoryPath,
+ const UStringVector &removePathParts,
+ UInt64 packSize)
+{
+ _wildcardCensor = wildcardCensor;
+
+ _stdOutMode = stdOutMode;
+ _testMode = testMode;
+ _crcMode = crcMode;
+ _unpTotal = 1;
+ _packTotal = packSize;
+
+ _extractCallback2 = extractCallback2;
+ _compressProgress.Release();
+ _extractCallback2.QueryInterface(IID_ICompressProgressInfo, &_compressProgress);
+
+ LocalProgressSpec->Init(extractCallback2, true);
+ LocalProgressSpec->SendProgress = false;
+
+
+ _removePathParts = removePathParts;
+ _arc = arc;
+ _directoryPath = directoryPath;
+ NFile::NName::NormalizeDirPathPrefix(_directoryPath);
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetTotal(UInt64 size)
+{
+ COM_TRY_BEGIN
+ _unpTotal = size;
+ if (!_multiArchives && _extractCallback2)
+ return _extractCallback2->SetTotal(size);
+ return S_OK;
+ COM_TRY_END
+}
+
+static void NormalizeVals(UInt64 &v1, UInt64 &v2)
+{
+ const UInt64 kMax = (UInt64)1 << 31;
+ while (v1 > kMax)
+ {
+ v1 >>= 1;
+ v2 >>= 1;
+ }
+}
+
+static UInt64 MyMultDiv64(UInt64 unpCur, UInt64 unpTotal, UInt64 packTotal)
+{
+ NormalizeVals(packTotal, unpTotal);
+ NormalizeVals(unpCur, unpTotal);
+ if (unpTotal == 0)
+ unpTotal = 1;
+ return unpCur * packTotal / unpTotal;
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 *completeValue)
+{
+ COM_TRY_BEGIN
+ if (!_extractCallback2)
+ return S_OK;
+
+ if (_multiArchives)
+ {
+ if (completeValue != NULL)
+ {
+ UInt64 packCur = LocalProgressSpec->InSize + MyMultDiv64(*completeValue, _unpTotal, _packTotal);
+ return _extractCallback2->SetCompleted(&packCur);
+ }
+ }
+ return _extractCallback2->SetCompleted(completeValue);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ COM_TRY_BEGIN
+ return _localProgress->SetRatioInfo(inSize, outSize);
+ COM_TRY_END
+}
+
+void CArchiveExtractCallback::CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath)
+{
+ fullPath = _directoryPath;
+ for (int i = 0; i < dirPathParts.Size(); i++)
+ {
+ if (i > 0)
+ fullPath += wchar_t(NFile::NName::kDirDelimiter);
+ fullPath += dirPathParts[i];
+ NFile::NDirectory::MyCreateDirectory(fullPath);
+ }
+}
+
+HRESULT CArchiveExtractCallback::GetTime(int index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined)
+{
+ filetimeIsDefined = false;
+ NCOM::CPropVariant prop;
+ RINOK(_arc->Archive->GetProperty(index, propID, &prop));
+ if (prop.vt == VT_FILETIME)
+ {
+ filetime = prop.filetime;
+ filetimeIsDefined = (filetime.dwHighDateTime != 0 || filetime.dwLowDateTime != 0);
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ return S_OK;
+}
+
+HRESULT CArchiveExtractCallback::GetUnpackSize()
+{
+ NCOM::CPropVariant prop;
+ RINOK(_arc->Archive->GetProperty(_index, kpidSize, &prop));
+ _curSizeDefined = (prop.vt != VT_EMPTY);
+ if (_curSizeDefined)
+ _curSize = ConvertPropVariantToUInt64(prop);
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)
+{
+ COM_TRY_BEGIN
+ _crcStream.Release();
+ *outStream = 0;
+ _outFileStream.Release();
+
+ _encrypted = false;
+ _isSplit = false;
+ _curSize = 0;
+ _curSizeDefined = false;
+ _index = index;
+
+ UString fullPath;
+
+ IInArchive *archive = _arc->Archive;
+ RINOK(_arc->GetItemPath(index, fullPath));
+ RINOK(IsArchiveItemFolder(archive, index, _fi.IsDir));
+
+ _filePath = fullPath;
+
+ {
+ NCOM::CPropVariant prop;
+ RINOK(archive->GetProperty(index, kpidPosition, &prop));
+ if (prop.vt != VT_EMPTY)
+ {
+ if (prop.vt != VT_UI8)
+ return E_FAIL;
+ _position = prop.uhVal.QuadPart;
+ _isSplit = true;
+ }
+ }
+
+ RINOK(GetArchiveItemBoolProp(archive, index, kpidEncrypted, _encrypted));
+
+ RINOK(GetUnpackSize());
+
+ if (_wildcardCensor)
+ {
+ if (!_wildcardCensor->CheckPath(fullPath, !_fi.IsDir))
+ return S_OK;
+ }
+
+ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
+ {
+ if (_stdOutMode)
+ {
+ CMyComPtr<ISequentialOutStream> outStreamLoc = new CStdOutFileStream;
+ *outStream = outStreamLoc.Detach();
+ return S_OK;
+ }
+
+ {
+ NCOM::CPropVariant prop;
+ RINOK(archive->GetProperty(index, kpidAttrib, &prop));
+ if (prop.vt == VT_UI4)
+ {
+ _fi.Attrib = prop.ulVal;
+ _fi.AttribDefined = true;
+ }
+ else if (prop.vt == VT_EMPTY)
+ _fi.AttribDefined = false;
+ else
+ return E_FAIL;
+ }
+
+ RINOK(GetTime(index, kpidCTime, _fi.CTime, _fi.CTimeDefined));
+ RINOK(GetTime(index, kpidATime, _fi.ATime, _fi.ATimeDefined));
+ RINOK(GetTime(index, kpidMTime, _fi.MTime, _fi.MTimeDefined));
+
+ bool isAnti = false;
+ RINOK(_arc->IsItemAnti(index, isAnti));
+
+ UStringVector pathParts;
+ SplitPathToParts(fullPath, pathParts);
+
+ if (pathParts.IsEmpty())
+ return E_FAIL;
+ int numRemovePathParts = 0;
+ switch(_pathMode)
+ {
+ case NExtract::NPathMode::kFullPathnames:
+ break;
+ case NExtract::NPathMode::kCurrentPathnames:
+ {
+ numRemovePathParts = _removePathParts.Size();
+ if (pathParts.Size() <= numRemovePathParts)
+ return E_FAIL;
+ for (int i = 0; i < numRemovePathParts; i++)
+ if (_removePathParts[i].CompareNoCase(pathParts[i]) != 0)
+ return E_FAIL;
+ break;
+ }
+ case NExtract::NPathMode::kNoPathnames:
+ {
+ numRemovePathParts = pathParts.Size() - 1;
+ break;
+ }
+ }
+ pathParts.Delete(0, numRemovePathParts);
+ MakeCorrectPath(pathParts);
+ UString processedPath = MakePathNameFromParts(pathParts);
+ if (!isAnti)
+ {
+ if (!_fi.IsDir)
+ {
+ if (!pathParts.IsEmpty())
+ pathParts.DeleteBack();
+ }
+
+ if (!pathParts.IsEmpty())
+ {
+ UString fullPathNew;
+ CreateComplexDirectory(pathParts, fullPathNew);
+ if (_fi.IsDir)
+ NFile::NDirectory::SetDirTime(fullPathNew,
+ (WriteCTime && _fi.CTimeDefined) ? &_fi.CTime : NULL,
+ (WriteATime && _fi.ATimeDefined) ? &_fi.ATime : NULL,
+ (WriteMTime && _fi.MTimeDefined) ? &_fi.MTime : (_arc->MTimeDefined ? &_arc->MTime : NULL));
+ }
+ }
+
+
+ UString fullProcessedPath = _directoryPath + processedPath;
+
+ if (_fi.IsDir)
+ {
+ _diskFilePath = fullProcessedPath;
+ if (isAnti)
+ NFile::NDirectory::MyRemoveDirectory(_diskFilePath);
+ return S_OK;
+ }
+
+ if (!_isSplit)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if (fileInfo.Find(fullProcessedPath))
+ {
+ switch(_overwriteMode)
+ {
+ case NExtract::NOverwriteMode::kSkipExisting:
+ return S_OK;
+ case NExtract::NOverwriteMode::kAskBefore:
+ {
+ Int32 overwiteResult;
+ RINOK(_extractCallback2->AskOverwrite(
+ fullProcessedPath, &fileInfo.MTime, &fileInfo.Size, fullPath,
+ _fi.MTimeDefined ? &_fi.MTime : NULL,
+ _curSizeDefined ? &_curSize : NULL,
+ &overwiteResult))
+
+ switch(overwiteResult)
+ {
+ case NOverwriteAnswer::kCancel:
+ return E_ABORT;
+ case NOverwriteAnswer::kNo:
+ return S_OK;
+ case NOverwriteAnswer::kNoToAll:
+ _overwriteMode = NExtract::NOverwriteMode::kSkipExisting;
+ return S_OK;
+ case NOverwriteAnswer::kYesToAll:
+ _overwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
+ break;
+ case NOverwriteAnswer::kYes:
+ break;
+ case NOverwriteAnswer::kAutoRename:
+ _overwriteMode = NExtract::NOverwriteMode::kAutoRename;
+ break;
+ default:
+ return E_FAIL;
+ }
+ }
+ default:
+ break;
+ }
+ if (_overwriteMode == NExtract::NOverwriteMode::kAutoRename)
+ {
+ if (!AutoRenamePath(fullProcessedPath))
+ {
+ UString message = UString(kCantAutoRename) + fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return E_FAIL;
+ }
+ }
+ else if (_overwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting)
+ {
+ UString existPath = fullProcessedPath;
+ if (!AutoRenamePath(existPath))
+ {
+ UString message = kCantAutoRename + fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return E_FAIL;
+ }
+ if (!NFile::NDirectory::MyMoveFile(fullProcessedPath, existPath))
+ {
+ UString message = UString(kCantRenameFile) + fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return E_FAIL;
+ }
+ }
+ else
+ if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
+ {
+ UString message = UString(kCantDeleteOutputFile) + fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return S_OK;
+ // return E_FAIL;
+ }
+ }
+ }
+ if (!isAnti)
+ {
+ _outFileStreamSpec = new COutFileStream;
+ CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
+ if (!_outFileStreamSpec->Open(fullProcessedPath, _isSplit ? OPEN_ALWAYS: CREATE_ALWAYS))
+ {
+ // if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit)
+ {
+ UString message = L"can not open output file " + fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return S_OK;
+ }
+ }
+ if (_isSplit)
+ {
+ RINOK(_outFileStreamSpec->Seek(_position, STREAM_SEEK_SET, NULL));
+ }
+ _outFileStream = outStreamLoc;
+ *outStream = outStreamLoc.Detach();
+ }
+ _diskFilePath = fullProcessedPath;
+ }
+ else
+ {
+ *outStream = NULL;
+ }
+ if (_crcMode)
+ {
+ _crcStreamSpec = new COutStreamWithCRC;
+ _crcStream = _crcStreamSpec;
+ CMyComPtr<ISequentialOutStream> crcStream = _crcStreamSpec;
+ _crcStreamSpec->SetStream(*outStream);
+ if (*outStream)
+ (*outStream)->Release();
+ *outStream = crcStream.Detach();
+ _crcStreamSpec->Init(true);
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
+{
+ COM_TRY_BEGIN
+ _extractMode = false;
+ switch (askExtractMode)
+ {
+ case NArchive::NExtract::NAskMode::kExtract:
+ if (_testMode)
+ askExtractMode = NArchive::NExtract::NAskMode::kTest;
+ else
+ _extractMode = true;
+ break;
+ };
+ return _extractCallback2->PrepareOperation(_filePath, _fi.IsDir,
+ askExtractMode, _isSplit ? &_position: 0);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
+{
+ COM_TRY_BEGIN
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kOK:
+ case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
+ case NArchive::NExtract::NOperationResult::kCRCError:
+ case NArchive::NExtract::NOperationResult::kDataError:
+ break;
+ default:
+ _outFileStream.Release();
+ return E_FAIL;
+ }
+ if (_crcStream)
+ {
+ CrcSum += _crcStreamSpec->GetCRC();
+ _curSize = _crcStreamSpec->GetSize();
+ _curSizeDefined = true;
+ _crcStream.Release();
+ }
+ if (_outFileStream)
+ {
+ _outFileStreamSpec->SetTime(
+ (WriteCTime && _fi.CTimeDefined) ? &_fi.CTime : NULL,
+ (WriteATime && _fi.ATimeDefined) ? &_fi.ATime : NULL,
+ (WriteMTime && _fi.MTimeDefined) ? &_fi.MTime : (_arc->MTimeDefined ? &_arc->MTime : NULL));
+ _curSize = _outFileStreamSpec->ProcessedSize;
+ _curSizeDefined = true;
+ RINOK(_outFileStreamSpec->Close());
+ _outFileStream.Release();
+ }
+ if (!_curSizeDefined)
+ GetUnpackSize();
+ if (_curSizeDefined)
+ UnpackSize += _curSize;
+ if (_fi.IsDir)
+ NumFolders++;
+ else
+ NumFiles++;
+
+ if (_extractMode && _fi.AttribDefined)
+ NFile::NDirectory::MySetFileAttributes(_diskFilePath, _fi.Attrib);
+ RINOK(_extractCallback2->SetOperationResult(operationResult, _encrypted));
+ return S_OK;
+ COM_TRY_END
+}
+
+/*
+STDMETHODIMP CArchiveExtractCallback::GetInStream(
+ const wchar_t *name, ISequentialInStream **inStream)
+{
+ COM_TRY_BEGIN
+ CInFileStream *inFile = new CInFileStream;
+ CMyComPtr<ISequentialInStream> inStreamTemp = inFile;
+ if (!inFile->Open(_srcDirectoryPrefix + name))
+ return ::GetLastError();
+ *inStream = inStreamTemp.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+*/
+
+STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
+{
+ COM_TRY_BEGIN
+ if (!_cryptoGetTextPassword)
+ {
+ RINOK(_extractCallback2.QueryInterface(IID_ICryptoGetTextPassword,
+ &_cryptoGetTextPassword));
+ }
+ return _cryptoGetTextPassword->CryptoGetTextPassword(password);
+ COM_TRY_END
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveExtractCallback.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveExtractCallback.h
new file mode 100644
index 000000000..367e4b07d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveExtractCallback.h
@@ -0,0 +1,143 @@
+// ArchiveExtractCallback.h
+
+#ifndef __ARCHIVE_EXTRACT_CALLBACK_H
+#define __ARCHIVE_EXTRACT_CALLBACK_H
+
+#include "Common/MyCom.h"
+#include "Common/Wildcard.h"
+
+#include "../../IPassword.h"
+
+#include "../../Common/FileStreams.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Archive/IArchive.h"
+
+#include "../../Archive/Common/OutStreamWithCRC.h"
+
+#include "ExtractMode.h"
+#include "IFileExtractCallback.h"
+#include "OpenArchive.h"
+
+class CArchiveExtractCallback:
+ public IArchiveExtractCallback,
+ // public IArchiveVolumeExtractCallback,
+ public ICryptoGetTextPassword,
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+ const CArc *_arc;
+ const NWildcard::CCensorNode *_wildcardCensor;
+ CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2;
+ CMyComPtr<ICompressProgressInfo> _compressProgress;
+ CMyComPtr<ICryptoGetTextPassword> _cryptoGetTextPassword;
+ UString _directoryPath;
+ NExtract::NPathMode::EEnum _pathMode;
+ NExtract::NOverwriteMode::EEnum _overwriteMode;
+
+ UString _diskFilePath;
+ UString _filePath;
+ UInt64 _position;
+ bool _isSplit;
+
+ bool _extractMode;
+
+ bool WriteCTime;
+ bool WriteATime;
+ bool WriteMTime;
+
+ bool _encrypted;
+
+ struct CProcessedFileInfo
+ {
+ FILETIME CTime;
+ FILETIME ATime;
+ FILETIME MTime;
+ UInt32 Attrib;
+
+ bool CTimeDefined;
+ bool ATimeDefined;
+ bool MTimeDefined;
+ bool AttribDefined;
+
+ bool IsDir;
+ } _fi;
+
+ UInt32 _index;
+ UInt64 _curSize;
+ bool _curSizeDefined;
+ COutFileStream *_outFileStreamSpec;
+ CMyComPtr<ISequentialOutStream> _outFileStream;
+
+ COutStreamWithCRC *_crcStreamSpec;
+ CMyComPtr<ISequentialOutStream> _crcStream;
+
+ UStringVector _removePathParts;
+
+ bool _stdOutMode;
+ bool _testMode;
+ bool _crcMode;
+ bool _multiArchives;
+
+ CMyComPtr<ICompressProgressInfo> _localProgress;
+ UInt64 _packTotal;
+ UInt64 _unpTotal;
+
+ void CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath);
+ HRESULT GetTime(int index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined);
+ HRESULT GetUnpackSize();
+
+public:
+
+ CLocalProgress *LocalProgressSpec;
+
+ UInt64 NumFolders;
+ UInt64 NumFiles;
+ UInt64 UnpackSize;
+ UInt32 CrcSum;
+
+ MY_UNKNOWN_IMP2(ICryptoGetTextPassword, ICompressProgressInfo)
+ // COM_INTERFACE_ENTRY(IArchiveVolumeExtractCallback)
+
+ INTERFACE_IArchiveExtractCallback(;)
+
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+
+ // IArchiveVolumeExtractCallback
+ // STDMETHOD(GetInStream)(const wchar_t *name, ISequentialInStream **inStream);
+
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+
+ CArchiveExtractCallback():
+ WriteCTime(true),
+ WriteATime(true),
+ WriteMTime(true),
+ _multiArchives(false)
+ {
+ LocalProgressSpec = new CLocalProgress();
+ _localProgress = LocalProgressSpec;
+ }
+
+ void InitForMulti(bool multiArchives,
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode)
+ {
+ _multiArchives = multiArchives;
+ _pathMode = pathMode;
+ _overwriteMode = overwriteMode;
+ NumFolders = NumFiles = UnpackSize = 0;
+ CrcSum = 0;
+ }
+
+ void Init(
+ const NWildcard::CCensorNode *wildcardCensor,
+ const CArc *arc,
+ IFolderArchiveExtractCallback *extractCallback2,
+ bool stdOutMode, bool testMode, bool crcMode,
+ const UString &directoryPath,
+ const UStringVector &removePathParts,
+ UInt64 packSize);
+
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveName.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveName.cpp
new file mode 100644
index 000000000..c3684def8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveName.cpp
@@ -0,0 +1,54 @@
+// ArchiveName.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+
+#include "ExtractingFilePath.h"
+
+using namespace NWindows;
+
+static UString CreateArchiveName2(const UString &srcName, bool fromPrev, bool keepName)
+{
+ UString resultName = L"Archive";
+ if (fromPrev)
+ {
+ UString dirPrefix;
+ if (NFile::NDirectory::GetOnlyDirPrefix(srcName, dirPrefix))
+ {
+ if (dirPrefix.Length() > 0)
+ if (dirPrefix[dirPrefix.Length() - 1] == WCHAR_PATH_SEPARATOR)
+ {
+ dirPrefix.Delete(dirPrefix.Length() - 1);
+ NFile::NFind::CFileInfoW fileInfo;
+ if (fileInfo.Find(dirPrefix))
+ resultName = fileInfo.Name;
+ }
+ }
+ }
+ else
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if (!fileInfo.Find(srcName))
+ // return resultName;
+ return srcName;
+ resultName = fileInfo.Name;
+ if (!fileInfo.IsDir() && !keepName)
+ {
+ int dotPos = resultName.ReverseFind('.');
+ if (dotPos > 0)
+ {
+ UString archiveName2 = resultName.Left(dotPos);
+ if (archiveName2.ReverseFind('.') < 0)
+ resultName = archiveName2;
+ }
+ }
+ }
+ return resultName;
+}
+
+UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName)
+{
+ return GetCorrectFsPath(CreateArchiveName2(srcName, fromPrev, keepName));
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveName.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveName.h
new file mode 100644
index 000000000..9513fb2ba
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveName.h
@@ -0,0 +1,10 @@
+// ArchiveName.h
+
+#ifndef __ARCHIVENAME_H
+#define __ARCHIVENAME_H
+
+#include "Common/MyString.h"
+
+UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
new file mode 100644
index 000000000..619d89823
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
@@ -0,0 +1,133 @@
+// ArchiveOpenCallback.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+#include "Common/ComTry.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../Common/FileStreams.h"
+
+#include "ArchiveOpenCallback.h"
+
+using namespace NWindows;
+
+STDMETHODIMP COpenCallbackImp::SetTotal(const UInt64 *files, const UInt64 *bytes)
+{
+ COM_TRY_BEGIN
+ if (ReOpenCallback)
+ return ReOpenCallback->SetTotal(files, bytes);
+ if (!Callback)
+ return S_OK;
+ return Callback->Open_SetTotal(files, bytes);
+ COM_TRY_END
+}
+
+STDMETHODIMP COpenCallbackImp::SetCompleted(const UInt64 *files, const UInt64 *bytes)
+{
+ COM_TRY_BEGIN
+ if (ReOpenCallback)
+ return ReOpenCallback->SetCompleted(files, bytes);
+ if (!Callback)
+ return S_OK;
+ return Callback->Open_SetCompleted(files, bytes);
+ COM_TRY_END
+}
+
+STDMETHODIMP COpenCallbackImp::GetProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ if (_subArchiveMode)
+ switch(propID)
+ {
+ case kpidName: prop = _subArchiveName; break;
+ }
+ else
+ switch(propID)
+ {
+ case kpidName: prop = _fileInfo.Name; break;
+ case kpidIsDir: prop = _fileInfo.IsDir(); break;
+ case kpidSize: prop = _fileInfo.Size; break;
+ case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
+ case kpidCTime: prop = _fileInfo.CTime; break;
+ case kpidATime: prop = _fileInfo.ATime; break;
+ case kpidMTime: prop = _fileInfo.MTime; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+int COpenCallbackImp::FindName(const UString &name)
+{
+ for (int i = 0; i < FileNames.Size(); i++)
+ if (name.CompareNoCase(FileNames[i]) == 0)
+ return i;
+ return -1;
+}
+
+struct CInFileStreamVol: public CInFileStream
+{
+ UString Name;
+ COpenCallbackImp *OpenCallbackImp;
+ CMyComPtr<IArchiveOpenCallback> OpenCallbackRef;
+ ~CInFileStreamVol()
+ {
+ if (OpenCallbackRef) /* FIXED */
+ {
+ int index = OpenCallbackImp->FindName(Name);
+ if (index >= 0)
+ OpenCallbackImp->FileNames.Delete(index);
+ }
+ }
+};
+
+STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStream)
+{
+ COM_TRY_BEGIN
+ if (_subArchiveMode)
+ return S_FALSE;
+ if (Callback)
+ {
+ RINOK(Callback->Open_CheckBreak());
+ }
+ *inStream = NULL;
+ UString fullPath = _folderPrefix + name;
+ if (!_fileInfo.Find(fullPath))
+ return S_FALSE;
+ if (_fileInfo.IsDir())
+ return S_FALSE;
+ CInFileStreamVol *inFile = new CInFileStreamVol;
+ CMyComPtr<IInStream> inStreamTemp = inFile;
+ if (!inFile->Open(fullPath))
+ return ::GetLastError();
+ *inStream = inStreamTemp.Detach();
+ inFile->Name = name;
+ inFile->OpenCallbackImp = this;
+ inFile->OpenCallbackRef = this;
+ FileNames.Add(name);
+ TotalSize += _fileInfo.Size;
+ return S_OK;
+ COM_TRY_END
+}
+
+#ifndef _NO_CRYPTO
+STDMETHODIMP COpenCallbackImp::CryptoGetTextPassword(BSTR *password)
+{
+ COM_TRY_BEGIN
+ if (ReOpenCallback)
+ {
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
+ ReOpenCallback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
+ if (getTextPassword)
+ return getTextPassword->CryptoGetTextPassword(password);
+ }
+ if (!Callback)
+ return E_NOTIMPL;
+ return Callback->Open_CryptoGetTextPassword(password);
+ COM_TRY_END
+}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveOpenCallback.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveOpenCallback.h
new file mode 100644
index 000000000..4abe7e164
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ArchiveOpenCallback.h
@@ -0,0 +1,104 @@
+// ArchiveOpenCallback.h
+
+#ifndef __ARCHIVE_OPEN_CALLBACK_H
+#define __ARCHIVE_OPEN_CALLBACK_H
+
+#include "Common/MyCom.h"
+#include "Common/MyString.h"
+
+#include "Windows/FileFind.h"
+
+#ifndef _NO_CRYPTO
+#include "../../IPassword.h"
+#endif
+#include "../../Archive/IArchive.h"
+
+#ifdef _NO_CRYPTO
+
+#define INTERFACE_IOpenCallbackUI_Crypto(x)
+
+#else
+
+#define INTERFACE_IOpenCallbackUI_Crypto(x) \
+ virtual HRESULT Open_CryptoGetTextPassword(BSTR *password) x; \
+ virtual HRESULT Open_GetPasswordIfAny(UString &password) x; \
+ virtual bool Open_WasPasswordAsked() x; \
+ virtual void Open_ClearPasswordWasAskedFlag() x; \
+
+#endif
+
+#define INTERFACE_IOpenCallbackUI(x) \
+ virtual HRESULT Open_CheckBreak() x; \
+ virtual HRESULT Open_SetTotal(const UInt64 *files, const UInt64 *bytes) x; \
+ virtual HRESULT Open_SetCompleted(const UInt64 *files, const UInt64 *bytes) x; \
+ INTERFACE_IOpenCallbackUI_Crypto(x)
+
+struct IOpenCallbackUI
+{
+ virtual ~IOpenCallbackUI() {}
+ INTERFACE_IOpenCallbackUI(=0)
+};
+
+class COpenCallbackImp:
+ public IArchiveOpenCallback,
+ public IArchiveOpenVolumeCallback,
+ public IArchiveOpenSetSubArchiveName,
+ #ifndef _NO_CRYPTO
+ public ICryptoGetTextPassword,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ #ifndef _NO_CRYPTO
+ MY_UNKNOWN_IMP3(
+ IArchiveOpenVolumeCallback,
+ ICryptoGetTextPassword,
+ IArchiveOpenSetSubArchiveName
+ )
+ #else
+ MY_UNKNOWN_IMP2(
+ IArchiveOpenVolumeCallback,
+ IArchiveOpenSetSubArchiveName
+ )
+ #endif
+
+ INTERFACE_IArchiveOpenCallback(;)
+ INTERFACE_IArchiveOpenVolumeCallback(;)
+
+ #ifndef _NO_CRYPTO
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+ #endif
+
+ STDMETHOD(SetSubArchiveName(const wchar_t *name))
+ {
+ _subArchiveMode = true;
+ _subArchiveName = name;
+ TotalSize = 0;
+ return S_OK;
+ }
+
+private:
+ UString _folderPrefix;
+ NWindows::NFile::NFind::CFileInfoW _fileInfo;
+ bool _subArchiveMode;
+ UString _subArchiveName;
+public:
+ UStringVector FileNames;
+ IOpenCallbackUI *Callback;
+ CMyComPtr<IArchiveOpenCallback> ReOpenCallback;
+ UInt64 TotalSize;
+
+ COpenCallbackImp(): Callback(NULL) {}
+ void Init(const UString &folderPrefix, const UString &fileName)
+ {
+ _folderPrefix = folderPrefix;
+ if (!_fileInfo.Find(_folderPrefix + fileName))
+ throw 1;
+ FileNames.Clear();
+ _subArchiveMode = false;
+ TotalSize = 0;
+ }
+ int FindName(const UString &name);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/CompressCall.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/CompressCall.cpp
new file mode 100644
index 000000000..412422689
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/CompressCall.cpp
@@ -0,0 +1,446 @@
+// CompressCall.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+
+#include "CompressCall.h"
+
+// FIXME #include "Common/Random.h"
+#include "Common/IntToString.h"
+#include "Common/MyCom.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Synchronization.h"
+// FIXME #include "Windows/FileMapping.h"
+#include "Windows/FileDir.h"
+
+#include "../FileManager/ProgramLocation.h"
+#include "../FileManager/RegistryUtils.h"
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif // _UNICODE
+
+using namespace NWindows;
+
+static LPCWSTR kShowDialogSwitch = L" -ad";
+static LPCWSTR kEmailSwitch = L" -seml.";
+static LPCWSTR kMapSwitch = L" -i#";
+static LPCWSTR kArchiveNoNameSwitch = L" -an";
+static LPCWSTR kArchiveTypeSwitch = L" -t";
+static LPCWSTR kArchiveMapSwitch = L" -ai#";
+static LPCWSTR kStopSwitchParsing = L" --";
+static LPCWSTR kLargePagesDisable = L" -slp-";
+
+static void AddLagePagesSwitch(UString &params)
+{
+#ifdef _WIN32
+ if (!ReadLockMemoryEnable())
+ params += kLargePagesDisable;
+#endif
+}
+
+HRESULT MyCreateProcess(const UString &params,
+ LPCWSTR curDir, bool waitFinish,
+ NWindows::NSynchronization::CBaseEvent *event)
+{
+ printf("MyCreateProcess: waitFinish=%d event=%p\n",(unsigned)waitFinish,event);
+ printf("\tparams : %ls\n",(const wchar_t*)params);
+ printf("\tcurDir : %ls\n",(const wchar_t*)curDir);
+
+ wxString cmd(params);
+ wxString memoCurDir = wxGetCwd();
+
+ if (curDir) { // FIXME
+ wxSetWorkingDirectory(wxString(curDir));
+ }
+
+ printf("MyCreateProcess: cmd='%ls'\n",(const wchar_t *)cmd);
+ long pid = 0;
+ if (waitFinish) pid = wxExecute(cmd, wxEXEC_SYNC); // FIXME process never ends and stays zombie ...
+ else pid = wxExecute(cmd, wxEXEC_ASYNC);
+
+ if (curDir) {
+ wxSetWorkingDirectory(memoCurDir);
+ }
+
+ // FIXME if (pid == 0) return E_FAIL;
+
+ return S_OK;
+#ifdef _WIN32 // FIXME
+ const UString params2 = params;
+ BOOL result;
+ {
+ STARTUPINFOW startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessW(NULL, (LPWSTR)(LPCWSTR)params,
+ NULL, NULL, FALSE, 0, NULL,
+ curDir,
+ &startupInfo, &processInformation);
+ }
+ if (result == 0)
+ return ::GetLastError();
+ else
+ {
+ ::CloseHandle(processInformation.hThread);
+ if (waitFinish)
+ WaitForSingleObject(processInformation.hProcess, INFINITE);
+ else if (event != NULL)
+ {
+ HANDLE handles[] = {processInformation.hProcess, *event };
+ ::WaitForMultipleObjects(sizeof(handles) / sizeof(handles[0]),
+ handles, FALSE, INFINITE);
+ }
+ ::CloseHandle(processInformation.hProcess);
+ }
+ return S_OK;
+#endif
+}
+
+static UString GetQuotedString(const UString &s)
+{
+ return UString(L"\"") + s + UString(L"\"");
+}
+
+static UString Get7zGuiPath()
+{
+ UString path;
+ UString folder;
+ if (GetProgramFolderPath(folder))
+ path += folder;
+#ifdef _WIN32
+ path += L"7zG.exe";
+#else
+ path += L"7zG";
+#endif
+ return GetQuotedString(path);
+}
+
+#ifdef _WIN32
+static HRESULT CreateTempEvent(const wchar_t *name,
+ NSynchronization::CManualResetEvent &event, UString &eventName)
+{
+ CRandom random;
+ random.Init(GetTickCount());
+ for (;;)
+ {
+ int number = random.Generate();
+ wchar_t temp[32];
+ ConvertUInt64ToString((UInt32)number, temp);
+ eventName = name;
+ eventName += temp;
+ RINOK(event.CreateWithName(false, GetSystemString(eventName)));
+ if (::GetLastError() != ERROR_ALREADY_EXISTS)
+ return S_OK;
+ event.Close();
+ }
+}
+
+static HRESULT CreateMap(const UStringVector &names,
+ const UString &id,
+ CFileMapping &fileMapping, NSynchronization::CManualResetEvent &event,
+ UString &params)
+{
+ UInt32 extraSize = 2;
+ UInt32 dataSize = 0;
+ for (int i = 0; i < names.Size(); i++)
+ dataSize += (names[i].Length() + 1) * sizeof(wchar_t);
+ UInt32 totalSize = extraSize + dataSize;
+
+ UString mappingName;
+
+ CRandom random;
+ random.Init(GetTickCount());
+ for (;;)
+ {
+ int number = random.Generate();
+ wchar_t temp[32];
+ ConvertUInt64ToString(UInt32(number), temp);
+ mappingName = id;
+ mappingName += L"Mapping";
+ mappingName += temp;
+ if (!fileMapping.Create(INVALID_HANDLE_VALUE, NULL,
+ PAGE_READWRITE, totalSize, GetSystemString(mappingName)))
+ return E_FAIL;
+ if (::GetLastError() != ERROR_ALREADY_EXISTS)
+ break;
+ fileMapping.Close();
+ }
+
+ UString eventName;
+ RINOK(CreateTempEvent(id + L"MappingEndEvent", event, eventName));
+
+ params += mappingName;
+ params += L":";
+ wchar_t string[10];
+ ConvertUInt64ToString(totalSize, string);
+ params += string;
+
+ params += L":";
+ params += eventName;
+
+ LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_WRITE, 0, totalSize);
+ if (data == NULL)
+ return E_FAIL;
+ {
+ wchar_t *curData = (wchar_t *)data;
+ *curData = 0;
+ curData++;
+ for (int i = 0; i < names.Size(); i++)
+ {
+ const UString &s = names[i];
+ memcpy(curData, (const wchar_t *)s, s.Length() * sizeof(wchar_t));
+ curData += s.Length();
+ *curData++ = L'\0';
+ }
+ }
+ return S_OK;
+}
+#endif
+
+HRESULT CompressFiles(
+ const UString &curDir,
+ const UString &archiveName,
+ const UString &archiveType,
+ const UStringVector &names,
+ // const UString &outFolder,
+ bool email,
+ bool showDialog,
+ bool waitFinish)
+{
+ /*
+ UString curDir;
+ if (names.Size() > 0)
+ {
+ NFile::NDirectory::GetOnlyDirPrefix(names[0], curDir);
+ }
+ */
+ UString params;
+ params = Get7zGuiPath();
+ params += L" a";
+#ifdef _WIN32
+ params += kMapSwitch;
+ // params += _fileNames[0];
+
+ UInt32 extraSize = 2;
+ UInt32 dataSize = 0;
+ for (int i = 0; i < names.Size(); i++)
+ dataSize += (names[i].Length() + 1) * sizeof(wchar_t);
+ UInt32 totalSize = extraSize + dataSize;
+
+ UString mappingName;
+
+ CFileMapping fileMapping;
+ CRandom random;
+ random.Init(GetTickCount());
+ for (;;)
+ {
+ int number = random.Generate();
+ wchar_t temp[32];
+ ConvertUInt64ToString(UInt32(number), temp);
+ mappingName = L"7zCompressMapping";
+ mappingName += temp;
+ if (!fileMapping.Create(INVALID_HANDLE_VALUE, NULL,
+ PAGE_READWRITE, totalSize, GetSystemString(mappingName)))
+ {
+ // MyMessageBox(IDS_ERROR, 0x02000605);
+ return E_FAIL;
+ }
+ if (::GetLastError() != ERROR_ALREADY_EXISTS)
+ break;
+ fileMapping.Close();
+ }
+
+ NSynchronization::CManualResetEvent event;
+ UString eventName;
+ RINOK(CreateTempEvent(L"7zCompressMappingEndEvent", event, eventName));
+
+ params += mappingName;
+ params += L":";
+ wchar_t string[10];
+ ConvertUInt64ToString(totalSize, string);
+ params += string;
+
+ params += L":";
+ params += eventName;
+#else
+ char tempFile[256];
+ static int count = 1000;
+
+ sprintf(tempFile,"/tmp/7zCompress_%d_%d.tmp",(int)getpid(),count++);
+
+ FILE * file = fopen(tempFile,"w");
+ if (file)
+ {
+ for (int i = 0; i < names.Size(); i++) {
+ fprintf(file,"%ls\n",(const wchar_t *)names[i]);
+ printf(" TMP_%d : '%ls'\n",i,(const wchar_t *)names[i]);
+ }
+
+ fclose(file);
+ }
+ params += L" -i@";
+ params += GetUnicodeString(tempFile);
+#endif
+
+ if (!archiveType.IsEmpty())
+ {
+ params += kArchiveTypeSwitch;
+ params += archiveType;
+ }
+
+ if (email)
+ params += kEmailSwitch;
+
+ if (showDialog)
+ params += kShowDialogSwitch;
+
+ AddLagePagesSwitch(params);
+
+ params += kStopSwitchParsing;
+ params += L" ";
+
+ params += GetQuotedString(archiveName);
+
+#ifdef _WIN32
+ LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_WRITE, 0, totalSize);
+ if (data == NULL)
+ {
+ // MyMessageBox(IDS_ERROR, 0x02000605);
+ return E_FAIL;
+ }
+ try
+ {
+ wchar_t *curData = (wchar_t *)data;
+ *curData = 0;
+ curData++;
+ for (int i = 0; i < names.Size(); i++)
+ {
+ const UString &unicodeString = names[i];
+ memcpy(curData, (const wchar_t *)unicodeString ,
+ unicodeString .Length() * sizeof(wchar_t));
+ curData += unicodeString.Length();
+ *curData++ = L'\0';
+ }
+ // MessageBox(0, params, 0, 0);
+ RINOK(MyCreateProcess(params,
+ (curDir.IsEmpty()? 0: (LPCWSTR)curDir),
+ waitFinish, &event));
+ }
+ catch(...)
+ {
+ UnmapViewOfFile(data);
+ throw;
+ }
+ UnmapViewOfFile(data);
+
+
+ /*
+ CThreadCompressMain *compressor = new CThreadCompressMain();;
+ compressor->FileNames = _fileNames;
+ CThread thread;
+ if (!thread.Create(CThreadCompressMain::MyThreadFunction, compressor))
+ throw 271824;
+ */
+#else
+ printf("CompressFiles : -%ls-\n",(const wchar_t *)params);
+ HRESULT res = MyCreateProcess(params,
+ (curDir.IsEmpty()? 0: (LPCWSTR)curDir),
+ true, /* &event FIXME */ 0);
+ printf("CompressFiles : END\n");
+
+ remove(tempFile);
+#endif
+ return S_OK;
+}
+
+static HRESULT ExtractGroupCommand(const UStringVector &archivePaths,
+ const UString &params)
+{
+ UString params2 = params;
+ AddLagePagesSwitch(params2);
+ params2 += kArchiveNoNameSwitch;
+#ifdef _WIN32
+ params2 += kArchiveMapSwitch;
+ CFileMapping fileMapping;
+ NSynchronization::CManualResetEvent event;
+ RINOK(CreateMap(archivePaths, L"7zExtract", fileMapping, event, params2));
+ return MyCreateProcess(params2, 0, false, &event);
+#else
+ char tempFile[256];
+ static int count = 1000;
+
+ sprintf(tempFile,"/tmp/7zExtract_%d_%d.tmp",(int)getpid(),count++);
+
+ FILE * file = fopen(tempFile,"w");
+ if (file)
+ {
+ for (int i = 0; i < archivePaths.Size(); i++) {
+ fprintf(file,"%ls\n",(const wchar_t *)archivePaths[i]);
+ printf(" TMP_%d : '%ls'\n",i,(const wchar_t *)archivePaths[i]);
+ }
+
+ fclose(file);
+ }
+ params2 += L" -ai@";
+ params2 += GetUnicodeString(tempFile);
+ printf("ExtractGroupCommand : -%ls-\n",(const wchar_t *)params2);
+ HRESULT res = MyCreateProcess(params2, 0, true, /* &event FIXME */ 0);
+ printf("ExtractGroupCommand : END\n");
+
+ remove(tempFile);
+
+ return res;
+#endif
+}
+
+HRESULT ExtractArchives(const UStringVector &archivePaths,
+ const UString &outFolder, bool showDialog)
+{
+ UString params;
+ params = Get7zGuiPath();
+ params += L" x";
+ if (!outFolder.IsEmpty())
+ {
+ params += L" \"-o";
+ params += outFolder;
+ params += L"\"";
+ }
+ if (showDialog)
+ params += kShowDialogSwitch;
+ return ExtractGroupCommand(archivePaths, params);
+}
+
+HRESULT TestArchives(const UStringVector &archivePaths)
+{
+ UString params;
+ params = Get7zGuiPath();
+ params += L" t";
+ return ExtractGroupCommand(archivePaths, params);
+}
+
+HRESULT Benchmark()
+{
+ UString params;
+ params = Get7zGuiPath();
+ params += L" b";
+ return MyCreateProcess(params, 0, false, NULL);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/CompressCall.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/CompressCall.h
new file mode 100644
index 000000000..feb457906
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/CompressCall.h
@@ -0,0 +1,30 @@
+// CompressCall.h
+
+#ifndef __COMPRESSCALL_H
+#define __COMPRESSCALL_H
+
+#include "Common/MyString.h"
+#include "Windows/Synchronization.h"
+
+HRESULT MyCreateProcess(const UString &params,
+ LPCWSTR lpCurrentDirectory, bool waitFinish,
+ NWindows::NSynchronization::CBaseEvent *event);
+
+HRESULT CompressFiles(
+ const UString &curDir,
+ const UString &archiveName,
+ const UString &archiveType,
+ const UStringVector &names,
+ // const UString &outFolder,
+ bool email, bool showDialog, bool waitFinish);
+
+HRESULT ExtractArchives(
+ const UStringVector &archivePaths,
+ const UString &outFolder, bool showDialog);
+
+HRESULT TestArchives(const UStringVector &archivePaths);
+
+HRESULT Benchmark();
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DefaultName.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DefaultName.cpp
new file mode 100644
index 000000000..4335e2731
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DefaultName.cpp
@@ -0,0 +1,35 @@
+// DefaultName.cpp
+
+#include "StdAfx.h"
+
+#include "DefaultName.h"
+
+static UString GetDefaultName3(const UString &fileName,
+ const UString &extension, const UString &addSubExtension)
+{
+ int extLength = extension.Length();
+ int fileNameLength = fileName.Length();
+ if (fileNameLength > extLength + 1)
+ {
+ int dotPos = fileNameLength - (extLength + 1);
+ if (fileName[dotPos] == '.')
+ if (extension.CompareNoCase(fileName.Mid(dotPos + 1)) == 0)
+ return fileName.Left(dotPos) + addSubExtension;
+ }
+ int dotPos = fileName.ReverseFind(L'.');
+ if (dotPos > 0)
+ return fileName.Left(dotPos) + addSubExtension;
+
+ if (addSubExtension.IsEmpty())
+ return fileName + L"~";
+ else
+ return fileName + addSubExtension;
+}
+
+UString GetDefaultName2(const UString &fileName,
+ const UString &extension, const UString &addSubExtension)
+{
+ UString name = GetDefaultName3(fileName, extension, addSubExtension);
+ name.TrimRight();
+ return name;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DefaultName.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DefaultName.h
new file mode 100644
index 000000000..9764ff871
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DefaultName.h
@@ -0,0 +1,11 @@
+// DefaultName.h
+
+#ifndef __DEFAULTNAME_H
+#define __DEFAULTNAME_H
+
+#include "Common/MyString.h"
+
+UString GetDefaultName2(const UString &fileName,
+ const UString &extension, const UString &addSubExtension);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DirItem.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DirItem.h
new file mode 100644
index 000000000..29cc60d93
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/DirItem.h
@@ -0,0 +1,69 @@
+// DirItem.h
+
+#ifndef __DIR_ITEM_H
+#define __DIR_ITEM_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+#include "../../Archive/IArchive.h"
+
+struct CDirItem
+{
+ UInt64 Size;
+ FILETIME CTime;
+ FILETIME ATime;
+ FILETIME MTime;
+ UString Name;
+ UInt32 Attrib;
+ int PhyParent;
+ int LogParent;
+
+ CDirItem(): PhyParent(-1), LogParent(-1) {}
+ bool IsDir() const { return (Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 ; }
+};
+
+class CDirItems
+{
+ UStringVector Prefixes;
+ CIntVector PhyParents;
+ CIntVector LogParents;
+
+ UString GetPrefixesPath(const CIntVector &parents, int index, const UString &name) const;
+public:
+ CObjectVector<CDirItem> Items;
+
+ int GetNumFolders() const { return Prefixes.Size(); }
+ UString GetPhyPath(int index) const;
+ UString GetLogPath(int index) const;
+
+ int AddPrefix(int phyParent, int logParent, const UString &prefix);
+ void DeleteLastPrefix();
+
+ void EnumerateDirectory(int phyParent, int logParent, const UString &phyPrefix,
+ UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
+
+ void EnumerateDirItems2(
+ const UString &phyPrefix,
+ const UString &logPrefix,
+ const UStringVector &filePaths,
+ UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
+
+ void ReserveDown();
+};
+
+struct CArcItem
+{
+ UInt64 Size;
+ FILETIME MTime;
+ UString Name;
+ bool IsDir;
+ bool SizeDefined;
+ bool MTimeDefined;
+ bool Censored;
+ UInt32 IndexInServer;
+ int TimeType;
+
+ CArcItem(): IsDir(false), SizeDefined(false), MTimeDefined(false), Censored(false), TimeType(-1) {}
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/EnumDirItems.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/EnumDirItems.cpp
new file mode 100644
index 000000000..ba03ea35c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/EnumDirItems.cpp
@@ -0,0 +1,361 @@
+// EnumDirItems.cpp
+
+#include "StdAfx.h"
+
+#include "EnumDirItems.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NName;
+
+void AddDirFileInfo(int phyParent, int logParent,
+ const NFind::CFileInfoW &fi, CObjectVector<CDirItem> &dirItems)
+{
+ CDirItem di;
+ di.Size = fi.Size;
+ di.CTime = fi.CTime;
+ di.ATime = fi.ATime;
+ di.MTime = fi.MTime;
+ di.Attrib = fi.Attrib;
+ di.PhyParent = phyParent;
+ di.LogParent = logParent;
+ di.Name = fi.Name;
+ dirItems.Add(di);
+}
+
+UString CDirItems::GetPrefixesPath(const CIntVector &parents, int index, const UString &name) const
+{
+ UString path;
+ int len = name.Length();
+ int i;
+ for (i = index; i >= 0; i = parents[i])
+ len += Prefixes[i].Length();
+ int totalLen = len;
+ wchar_t *p = path.GetBuffer(len);
+ p[len] = 0;
+ len -= name.Length();
+ memcpy(p + len, (const wchar_t *)name, name.Length() * sizeof(wchar_t));
+ for (i = index; i >= 0; i = parents[i])
+ {
+ const UString &s = Prefixes[i];
+ len -= s.Length();
+ memcpy(p + len, (const wchar_t *)s, s.Length() * sizeof(wchar_t));
+ }
+ path.ReleaseBuffer(totalLen);
+ return path;
+}
+
+UString CDirItems::GetPhyPath(int index) const
+{
+ const CDirItem &di = Items[index];
+ return GetPrefixesPath(PhyParents, di.PhyParent, di.Name);
+}
+
+UString CDirItems::GetLogPath(int index) const
+{
+ const CDirItem &di = Items[index];
+ return GetPrefixesPath(LogParents, di.LogParent, di.Name);
+}
+
+void CDirItems::ReserveDown()
+{
+ Prefixes.ReserveDown();
+ PhyParents.ReserveDown();
+ LogParents.ReserveDown();
+ Items.ReserveDown();
+}
+
+int CDirItems::AddPrefix(int phyParent, int logParent, const UString &prefix)
+{
+ PhyParents.Add(phyParent);
+ LogParents.Add(logParent);
+ return Prefixes.Add(prefix);
+}
+
+void CDirItems::DeleteLastPrefix()
+{
+ PhyParents.DeleteBack();
+ LogParents.DeleteBack();
+ Prefixes.DeleteBack();
+}
+
+void CDirItems::EnumerateDirectory(int phyParent, int logParent, const UString &phyPrefix,
+ UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
+{
+ NFind::CEnumeratorW enumerator(phyPrefix + (wchar_t)kAnyStringWildcard);
+ for (;;)
+ {
+ NFind::CFileInfoW fi;
+ bool found;
+ if (!enumerator.Next(fi, found))
+ {
+ errorCodes.Add(::GetLastError());
+ errorPaths.Add(phyPrefix);
+ return;
+ }
+ if (!found)
+ break;
+ AddDirFileInfo(phyParent, logParent, fi, Items);
+ if (fi.IsDir())
+ {
+ const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
+ int parent = AddPrefix(phyParent, logParent, name2);
+ EnumerateDirectory(parent, parent, phyPrefix + name2, errorPaths, errorCodes);
+ }
+ }
+}
+
+void CDirItems::EnumerateDirItems2(const UString &phyPrefix, const UString &logPrefix,
+ const UStringVector &filePaths, UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
+{
+ int phyParent = phyPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, phyPrefix);
+ int logParent = logPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, logPrefix);
+
+ for (int i = 0; i < filePaths.Size(); i++)
+ {
+ const UString &filePath = filePaths[i];
+ NFind::CFileInfoW fi;
+ const UString phyPath = phyPrefix + filePath;
+ if (!fi.Find(phyPath))
+ {
+ errorCodes.Add(::GetLastError());
+ errorPaths.Add(phyPath);
+ continue;
+ }
+ int delimiter = filePath.ReverseFind((wchar_t)kDirDelimiter);
+ UString phyPrefixCur;
+ int phyParentCur = phyParent;
+ if (delimiter >= 0)
+ {
+ phyPrefixCur = filePath.Left(delimiter + 1);
+ phyParentCur = AddPrefix(phyParent, logParent, phyPrefixCur);
+ }
+ AddDirFileInfo(phyParentCur, logParent, fi, Items);
+ if (fi.IsDir())
+ {
+ const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
+ int parent = AddPrefix(phyParentCur, logParent, name2);
+ EnumerateDirectory(parent, parent, phyPrefix + phyPrefixCur + name2, errorPaths, errorCodes);
+ }
+ }
+ ReserveDown();
+}
+
+static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
+ int phyParent, int logParent, const UString &phyPrefix,
+ const UStringVector &addArchivePrefix,
+ CDirItems &dirItems,
+ bool enterToSubFolders,
+ IEnumDirItemCallback *callback,
+ UStringVector &errorPaths,
+ CRecordVector<DWORD> &errorCodes);
+
+static HRESULT EnumerateDirItems_Spec(const NWildcard::CCensorNode &curNode,
+ int phyParent, int logParent, const UString &curFolderName,
+ const UString &phyPrefix,
+ const UStringVector &addArchivePrefix,
+ CDirItems &dirItems,
+ bool enterToSubFolders,
+ IEnumDirItemCallback *callback,
+ UStringVector &errorPaths,
+ CRecordVector<DWORD> &errorCodes)
+
+{
+ const UString name2 = curFolderName + (wchar_t)kDirDelimiter;
+ int parent = dirItems.AddPrefix(phyParent, logParent, name2);
+ int numItems = dirItems.Items.Size();
+ HRESULT res = EnumerateDirItems(curNode, parent, parent, phyPrefix + name2,
+ addArchivePrefix, dirItems, enterToSubFolders, callback, errorPaths, errorCodes);
+ if (numItems == dirItems.Items.Size())
+ dirItems.DeleteLastPrefix();
+ return res;
+}
+
+
+static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
+ int phyParent, int logParent, const UString &phyPrefix,
+ const UStringVector &addArchivePrefix, // prefix from curNode
+ CDirItems &dirItems,
+ bool enterToSubFolders,
+ IEnumDirItemCallback *callback,
+ UStringVector &errorPaths,
+ CRecordVector<DWORD> &errorCodes)
+{
+ if (!enterToSubFolders)
+ if (curNode.NeedCheckSubDirs())
+ enterToSubFolders = true;
+ if (callback)
+ RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), phyPrefix));
+
+ // try direct_names case at first
+ if (addArchivePrefix.IsEmpty() && !enterToSubFolders)
+ {
+ // check that all names are direct
+ int i;
+ for (i = 0; i < curNode.IncludeItems.Size(); i++)
+ {
+ const NWildcard::CItem &item = curNode.IncludeItems[i];
+ if (item.Recursive || item.PathParts.Size() != 1)
+ break;
+ const UString &name = item.PathParts.Front();
+ if (name.IsEmpty() || DoesNameContainWildCard(name))
+ break;
+ }
+ if (i == curNode.IncludeItems.Size())
+ {
+ // all names are direct (no wildcards)
+ // so we don't need file_system's dir enumerator
+ CRecordVector<bool> needEnterVector;
+ for (i = 0; i < curNode.IncludeItems.Size(); i++)
+ {
+ const NWildcard::CItem &item = curNode.IncludeItems[i];
+ const UString &name = item.PathParts.Front();
+ const UString fullPath = phyPrefix + name;
+ NFind::CFileInfoW fi;
+ if (!fi.Find(fullPath))
+ {
+ errorCodes.Add(::GetLastError());
+ errorPaths.Add(fullPath);
+ continue;
+ }
+ bool isDir = fi.IsDir();
+ if (isDir && !item.ForDir || !isDir && !item.ForFile)
+ {
+ errorCodes.Add((DWORD)E_FAIL);
+ errorPaths.Add(fullPath);
+ continue;
+ }
+ {
+ UStringVector pathParts;
+ pathParts.Add(fi.Name);
+ if (curNode.CheckPathToRoot(false, pathParts, !isDir))
+ continue;
+ }
+ AddDirFileInfo(phyParent, logParent, fi, dirItems.Items);
+ if (!isDir)
+ continue;
+
+ UStringVector addArchivePrefixNew;
+ const NWildcard::CCensorNode *nextNode = 0;
+ int index = curNode.FindSubNode(name);
+ if (index >= 0)
+ {
+ for (int t = needEnterVector.Size(); t <= index; t++)
+ needEnterVector.Add(true);
+ needEnterVector[index] = false;
+ nextNode = &curNode.SubNodes[index];
+ }
+ else
+ {
+ nextNode = &curNode;
+ addArchivePrefixNew.Add(name); // don't change it to fi.Name. It's for shortnames support
+ }
+
+ RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, fi.Name, phyPrefix,
+ addArchivePrefixNew, dirItems, true, callback, errorPaths, errorCodes));
+ }
+ for (i = 0; i < curNode.SubNodes.Size(); i++)
+ {
+ if (i < needEnterVector.Size())
+ if (!needEnterVector[i])
+ continue;
+ const NWildcard::CCensorNode &nextNode = curNode.SubNodes[i];
+ const UString fullPath = phyPrefix + nextNode.Name;
+ NFind::CFileInfoW fi;
+ if (!fi.Find(fullPath))
+ {
+ if (!nextNode.AreThereIncludeItems())
+ continue;
+ errorCodes.Add(::GetLastError());
+ errorPaths.Add(fullPath);
+ continue;
+ }
+ if (!fi.IsDir())
+ {
+ errorCodes.Add((DWORD)E_FAIL);
+ errorPaths.Add(fullPath);
+ continue;
+ }
+
+ RINOK(EnumerateDirItems_Spec(nextNode, phyParent, logParent, fi.Name, phyPrefix,
+ UStringVector(), dirItems, false, callback, errorPaths, errorCodes));
+ }
+ return S_OK;
+ }
+ }
+
+
+ NFind::CEnumeratorW enumerator(phyPrefix + wchar_t(kAnyStringWildcard));
+ for (int ttt = 0; ; ttt++)
+ {
+ NFind::CFileInfoW fi;
+ bool found;
+ if (!enumerator.Next(fi, found))
+ {
+ errorCodes.Add(::GetLastError());
+ errorPaths.Add(phyPrefix);
+ break;
+ }
+ if (!found)
+ break;
+
+ if (callback && (ttt & 0xFF) == 0xFF)
+ RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), phyPrefix));
+ const UString &name = fi.Name;
+ bool enterToSubFolders2 = enterToSubFolders;
+ UStringVector addArchivePrefixNew = addArchivePrefix;
+ addArchivePrefixNew.Add(name);
+ {
+ UStringVector addArchivePrefixNewTemp(addArchivePrefixNew);
+ if (curNode.CheckPathToRoot(false, addArchivePrefixNewTemp, !fi.IsDir()))
+ continue;
+ }
+ if (curNode.CheckPathToRoot(true, addArchivePrefixNew, !fi.IsDir()))
+ {
+ AddDirFileInfo(phyParent, logParent, fi, dirItems.Items);
+ if (fi.IsDir())
+ enterToSubFolders2 = true;
+ }
+ if (!fi.IsDir())
+ continue;
+
+ const NWildcard::CCensorNode *nextNode = 0;
+ if (addArchivePrefix.IsEmpty())
+ {
+ int index = curNode.FindSubNode(name);
+ if (index >= 0)
+ nextNode = &curNode.SubNodes[index];
+ }
+ if (!enterToSubFolders2 && nextNode == 0)
+ continue;
+
+ addArchivePrefixNew = addArchivePrefix;
+ if (nextNode == 0)
+ {
+ nextNode = &curNode;
+ addArchivePrefixNew.Add(name);
+ }
+
+ RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, name, phyPrefix,
+ addArchivePrefixNew, dirItems, enterToSubFolders2, callback, errorPaths, errorCodes));
+ }
+ return S_OK;
+}
+
+HRESULT EnumerateItems(
+ const NWildcard::CCensor &censor,
+ CDirItems &dirItems,
+ IEnumDirItemCallback *callback,
+ UStringVector &errorPaths,
+ CRecordVector<DWORD> &errorCodes)
+{
+ for (int i = 0; i < censor.Pairs.Size(); i++)
+ {
+ const NWildcard::CPair &pair = censor.Pairs[i];
+ int phyParent = pair.Prefix.IsEmpty() ? -1 : dirItems.AddPrefix(-1, -1, pair.Prefix);
+ RINOK(EnumerateDirItems(pair.Head, phyParent, -1, pair.Prefix, UStringVector(), dirItems, false,
+ callback, errorPaths, errorCodes));
+ }
+ dirItems.ReserveDown();
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/EnumDirItems.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/EnumDirItems.h
new file mode 100644
index 000000000..eca2f8850
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/EnumDirItems.h
@@ -0,0 +1,26 @@
+// EnumDirItems.h
+
+#ifndef __ENUM_DIR_ITEMS_H
+#define __ENUM_DIR_ITEMS_H
+
+#include "Common/Wildcard.h"
+#include "Windows/FileFind.h"
+#include "DirItem.h"
+
+void AddDirFileInfo(int phyParent, int logParent,
+ const NWindows::NFile::NFind::CFileInfoW &fi, CObjectVector<CDirItem> &dirItems);
+
+struct IEnumDirItemCallback
+{
+ virtual ~IEnumDirItemCallback() {}
+ virtual HRESULT ScanProgress(UInt64 numFolders, UInt64 numFiles, const wchar_t *path) = 0;
+};
+
+HRESULT EnumerateItems(
+ const NWildcard::CCensor &censor,
+ CDirItems &dirItems,
+ IEnumDirItemCallback *callback,
+ UStringVector &errorPaths,
+ CRecordVector<DWORD> &errorCodes);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExitCode.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExitCode.h
new file mode 100644
index 000000000..b6d7d4dfc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExitCode.h
@@ -0,0 +1,27 @@
+// ExitCode.h
+
+#ifndef __EXIT_CODE_H
+#define __EXIT_CODE_H
+
+namespace NExitCode {
+
+enum EEnum {
+
+ kSuccess = 0, // Successful operation
+ kWarning = 1, // Non fatal error(s) occurred
+ kFatalError = 2, // A fatal error occurred
+ // kCRCError = 3, // A CRC error occurred when unpacking
+ // kLockedArchive = 4, // Attempt to modify an archive previously locked
+ // kWriteError = 5, // Write to disk error
+ // kOpenError = 6, // Open file error
+ kUserError = 7, // Command line option error
+ kMemoryError = 8, // Not enough memory for operation
+ // kCreateFileError = 9, // Create file error
+
+ kUserBreak = 255 // User stopped the process
+
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Extract.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Extract.cpp
new file mode 100644
index 000000000..933290910
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Extract.cpp
@@ -0,0 +1,253 @@
+// Extract.cpp
+
+#include "StdAfx.h"
+
+#include <stdio.h>
+
+#include "Windows/FileDir.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../Common/ExtractingFilePath.h"
+
+#include "Extract.h"
+#include "SetProperties.h"
+
+using namespace NWindows;
+
+static HRESULT DecompressArchive(
+ const CArc &arc,
+ UInt64 packSize,
+ const NWildcard::CCensorNode &wildcardCensor,
+ const CExtractOptions &options,
+ IExtractCallbackUI *callback,
+ CArchiveExtractCallback *extractCallbackSpec,
+ UString &errorMessage,
+ UInt64 &stdInProcessed)
+{
+ stdInProcessed = 0;
+ IInArchive *archive = arc.Archive;
+ CRecordVector<UInt32> realIndices;
+ if (!options.StdInMode)
+ {
+ UInt32 numItems;
+ RINOK(archive->GetNumberOfItems(&numItems));
+
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ UString filePath;
+ RINOK(arc.GetItemPath(i, filePath));
+ bool isFolder;
+ RINOK(IsArchiveItemFolder(archive, i, isFolder));
+ if (!wildcardCensor.CheckPath(filePath, !isFolder))
+ continue;
+ realIndices.Add(i);
+ }
+ if (realIndices.Size() == 0)
+ {
+ callback->ThereAreNoFiles();
+ return S_OK;
+ }
+ }
+
+ UStringVector removePathParts;
+
+ UString outDir = options.OutputDir;
+ outDir.Replace(L"*", GetCorrectFsPath(arc.DefaultName));
+ #ifdef _WIN32
+ outDir.TrimRight();
+ outDir = GetCorrectFullFsPath(outDir);
+ #endif
+
+ if (!outDir.IsEmpty())
+ if (!NFile::NDirectory::CreateComplexDirectory(outDir))
+ {
+ HRESULT res = ::GetLastError();
+ if (res == S_OK)
+ res = E_FAIL;
+ errorMessage = ((UString)L"Can not create output directory ") + outDir;
+ return res;
+ }
+
+ extractCallbackSpec->Init(
+ options.StdInMode ? &wildcardCensor : NULL,
+ &arc,
+ callback,
+ options.StdOutMode, options.TestMode, options.CalcCrc,
+ outDir,
+ removePathParts,
+ packSize);
+
+ #ifdef COMPRESS_MT
+ RINOK(SetProperties(archive, options.Properties));
+ #endif
+
+ HRESULT result;
+ Int32 testMode = (options.TestMode && !options.CalcCrc) ? 1: 0;
+ if (options.StdInMode)
+ {
+ result = archive->Extract(NULL, (UInt32)(Int32)-1, testMode, extractCallbackSpec);
+ NCOM::CPropVariant prop;
+ if (archive->GetArchiveProperty(kpidPhySize, &prop) == S_OK)
+ if (prop.vt == VT_UI8 || prop.vt == VT_UI4)
+ stdInProcessed = ConvertPropVariantToUInt64(prop);
+ }
+ else
+ result = archive->Extract(&realIndices.Front(), realIndices.Size(), testMode, extractCallbackSpec);
+
+ return callback->ExtractResult(result);
+}
+
+HRESULT DecompressArchives(
+ CCodecs *codecs, const CIntVector &formatIndices,
+ UStringVector &arcPaths, UStringVector &arcPathsFull,
+ const NWildcard::CCensorNode &wildcardCensor,
+ const CExtractOptions &options,
+ IOpenCallbackUI *openCallback,
+ IExtractCallbackUI *extractCallback,
+ UString &errorMessage,
+ CDecompressStat &stat)
+{
+ stat.Clear();
+ int i;
+ UInt64 totalPackSize = 0;
+ CRecordVector<UInt64> archiveSizes;
+
+ int numArcs = options.StdInMode ? 1 : arcPaths.Size();
+
+ for (i = 0; i < numArcs; i++)
+ {
+ NFile::NFind::CFileInfoW fi;
+ fi.Size = 0;
+ if (!options.StdInMode)
+ {
+ const UString &arcPath = arcPaths[i];
+ if (!fi.Find(arcPath))
+ throw "there is no such archive";
+ if (fi.IsDir())
+ throw "can't decompress folder";
+ }
+ archiveSizes.Add(fi.Size);
+ totalPackSize += fi.Size;
+ }
+ CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
+ CMyComPtr<IArchiveExtractCallback> ec(extractCallbackSpec);
+ bool multi = (numArcs > 1);
+ extractCallbackSpec->InitForMulti(multi, options.PathMode, options.OverwriteMode);
+ if (multi)
+ {
+ RINOK(extractCallback->SetTotal(totalPackSize));
+ }
+ for (i = 0; i < numArcs; i++)
+ {
+ const UString &arcPath = arcPaths[i];
+ NFile::NFind::CFileInfoW fi;
+ if (options.StdInMode)
+ {
+ fi.Size = 0;
+ fi.Attrib = 0;
+ }
+ else
+ {
+ if (!fi.Find(arcPath) || fi.IsDir())
+ throw "there is no such archive";
+ }
+
+ #ifndef _NO_CRYPTO
+ openCallback->Open_ClearPasswordWasAskedFlag();
+ #endif
+
+ RINOK(extractCallback->BeforeOpen(arcPath));
+ CArchiveLink archiveLink;
+
+ CIntVector formatIndices2 = formatIndices;
+ #ifndef _SFX
+ if (formatIndices.IsEmpty())
+ {
+ int pos = arcPath.ReverseFind(L'.');
+ if (pos >= 0)
+ {
+ UString s = arcPath.Mid(pos + 1);
+ int index = codecs->FindFormatForExtension(s);
+ if (index >= 0 && s == L"001")
+ {
+ s = arcPath.Left(pos);
+ pos = s.ReverseFind(L'.');
+ if (pos >= 0)
+ {
+ int index2 = codecs->FindFormatForExtension(s.Mid(pos + 1));
+ if (index2 >= 0 && s.CompareNoCase(L"rar") != 0)
+ {
+ formatIndices2.Add(index2);
+ formatIndices2.Add(index);
+ }
+ }
+ }
+ }
+ }
+ #endif
+ HRESULT result = archiveLink.Open2(codecs, formatIndices2, options.StdInMode, NULL, arcPath, openCallback);
+ if (result == E_ABORT)
+ return result;
+
+ bool crypted = false;
+ #ifndef _NO_CRYPTO
+ crypted = openCallback->Open_WasPasswordAsked();
+ #endif
+
+ RINOK(extractCallback->OpenResult(arcPath, result, crypted));
+ if (result != S_OK)
+ continue;
+
+ if (!options.StdInMode)
+ for (int v = 0; v < archiveLink.VolumePaths.Size(); v++)
+ {
+ int index = arcPathsFull.FindInSorted(archiveLink.VolumePaths[v]);
+ if (index >= 0 && index > i)
+ {
+ arcPaths.Delete(index);
+ arcPathsFull.Delete(index);
+ totalPackSize -= archiveSizes[index];
+ archiveSizes.Delete(index);
+ numArcs = arcPaths.Size();
+ }
+ }
+ if (archiveLink.VolumePaths.Size() != 0)
+ {
+ totalPackSize += archiveLink.VolumesSize;
+ RINOK(extractCallback->SetTotal(totalPackSize));
+ }
+
+ #ifndef _NO_CRYPTO
+ UString password;
+ RINOK(openCallback->Open_GetPasswordIfAny(password));
+ if (!password.IsEmpty())
+ {
+ RINOK(extractCallback->SetPassword(password));
+ }
+ #endif
+
+ CArc &arc = archiveLink.Arcs.Back();
+ arc.MTimeDefined = (!options.StdInMode && !fi.IsDevice);
+ arc.MTime = fi.MTime;
+
+ UInt64 packProcessed;
+ RINOK(DecompressArchive(arc,
+ fi.Size + archiveLink.VolumesSize,
+ wildcardCensor, options, extractCallback, extractCallbackSpec, errorMessage, packProcessed));
+ if (!options.StdInMode)
+ packProcessed = fi.Size + archiveLink.VolumesSize;
+ extractCallbackSpec->LocalProgressSpec->InSize += packProcessed;
+ extractCallbackSpec->LocalProgressSpec->OutSize = extractCallbackSpec->UnpackSize;
+ if (!errorMessage.IsEmpty())
+ return E_FAIL;
+ }
+ stat.NumFolders = extractCallbackSpec->NumFolders;
+ stat.NumFiles = extractCallbackSpec->NumFiles;
+ stat.UnpackSize = extractCallbackSpec->UnpackSize;
+ stat.CrcSum = extractCallbackSpec->CrcSum;
+
+ stat.NumArchives = arcPaths.Size();
+ stat.PackSize = extractCallbackSpec->LocalProgressSpec->InSize;
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Extract.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Extract.h
new file mode 100644
index 000000000..442dd2b0d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Extract.h
@@ -0,0 +1,76 @@
+// Extract.h
+
+#ifndef __EXTRACT_H
+#define __EXTRACT_H
+
+#include "Windows/FileFind.h"
+
+#include "../../Archive/IArchive.h"
+
+#include "ArchiveExtractCallback.h"
+#include "ArchiveOpenCallback.h"
+#include "ExtractMode.h"
+#include "Property.h"
+
+#include "../Common/LoadCodecs.h"
+
+struct CExtractOptions
+{
+ bool StdInMode;
+ bool StdOutMode;
+ bool YesToAll;
+ bool TestMode;
+ bool CalcCrc;
+ NExtract::NPathMode::EEnum PathMode;
+ NExtract::NOverwriteMode::EEnum OverwriteMode;
+ UString OutputDir;
+
+ // bool ShowDialog;
+ // bool PasswordEnabled;
+ // UString Password;
+ #ifdef COMPRESS_MT
+ CObjectVector<CProperty> Properties;
+ #endif
+
+ #ifdef EXTERNAL_CODECS
+ CCodecs *Codecs;
+ #endif
+
+ CExtractOptions():
+ StdInMode(false),
+ StdOutMode(false),
+ YesToAll(false),
+ TestMode(false),
+ CalcCrc(false),
+ PathMode(NExtract::NPathMode::kFullPathnames),
+ OverwriteMode(NExtract::NOverwriteMode::kAskBefore)
+ {}
+};
+
+struct CDecompressStat
+{
+ UInt64 NumArchives;
+ UInt64 UnpackSize;
+ UInt64 PackSize;
+ UInt64 NumFolders;
+ UInt64 NumFiles;
+ UInt32 CrcSum;
+
+ void Clear()
+ {
+ NumArchives = UnpackSize = PackSize = NumFolders = NumFiles = 0;
+ CrcSum = 0;
+ }
+};
+
+HRESULT DecompressArchives(
+ CCodecs *codecs, const CIntVector &formatIndices,
+ UStringVector &archivePaths, UStringVector &archivePathsFull,
+ const NWildcard::CCensorNode &wildcardCensor,
+ const CExtractOptions &options,
+ IOpenCallbackUI *openCallback,
+ IExtractCallbackUI *extractCallback,
+ UString &errorMessage,
+ CDecompressStat &stat);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractMode.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractMode.h
new file mode 100644
index 000000000..b448fb30a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractMode.h
@@ -0,0 +1,31 @@
+// ExtractMode.h
+
+#ifndef __EXTRACT_MODE_H
+#define __EXTRACT_MODE_H
+
+namespace NExtract {
+
+ namespace NPathMode
+ {
+ enum EEnum
+ {
+ kFullPathnames,
+ kCurrentPathnames,
+ kNoPathnames
+ };
+ }
+
+ namespace NOverwriteMode
+ {
+ enum EEnum
+ {
+ kAskBefore,
+ kWithoutPrompt,
+ kSkipExisting,
+ kAutoRename,
+ kAutoRenameExisting
+ };
+ }
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractingFilePath.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractingFilePath.cpp
new file mode 100644
index 000000000..f3968cd19
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractingFilePath.cpp
@@ -0,0 +1,141 @@
+// ExtractingFilePath.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Wildcard.h"
+#include "Common/MyWindows.h"
+
+#include "ExtractingFilePath.h"
+
+static UString ReplaceIncorrectChars(const UString &s)
+{
+ #ifdef _WIN32
+ UString res;
+ for (int i = 0; i < s.Length(); i++)
+ {
+ wchar_t c = s[i];
+ if (c < 0x20 || c == '*' || c == '?' || c == '<' || c == '>' || c == '|' || c == ':' || c == '"')
+ c = '_';
+ res += c;
+ }
+ res.TrimRight();
+ while (!res.IsEmpty() && res[res.Length() - 1] == '.')
+ res.Delete(res.Length() - 1);
+ return res;
+ #else
+ return s;
+ #endif
+}
+
+#ifdef _WIN32
+static const wchar_t *g_ReservedNames[] =
+{
+ L"CON", L"PRN", L"AUX", L"NUL"
+};
+
+static bool CheckTail(const UString &name, int len)
+{
+ int dotPos = name.Find(L'.');
+ if (dotPos < 0)
+ dotPos = name.Length();
+ UString s = name.Left(dotPos);
+ s.TrimRight();
+ return (s.Length() != len);
+}
+
+static bool CheckNameNum(const UString &name, const wchar_t *reservedName)
+{
+ int len = MyStringLen(reservedName);
+ if (name.Length() <= len)
+ return true;
+ if (name.Left(len).CompareNoCase(reservedName) != 0)
+ return true;
+ wchar_t c = name[len];
+ if (c < L'0' || c > L'9')
+ return true;
+ return CheckTail(name, len + 1);
+}
+
+static bool IsSupportedName(const UString &name)
+{
+ for (int i = 0; i < sizeof(g_ReservedNames) / sizeof(g_ReservedNames[0]); i++)
+ {
+ const wchar_t *reservedName = g_ReservedNames[i];
+ int len = MyStringLen(reservedName);
+ if (name.Length() < len)
+ continue;
+ if (name.Left(len).CompareNoCase(reservedName) != 0)
+ continue;
+ if (!CheckTail(name, len))
+ return false;
+ }
+ if (!CheckNameNum(name, L"COM"))
+ return false;
+ return CheckNameNum(name, L"LPT");
+}
+#endif
+
+static UString GetCorrectFileName(const UString &path)
+{
+ if (path == L".." || path == L".")
+ return UString();
+ return ReplaceIncorrectChars(path);
+}
+
+void MakeCorrectPath(UStringVector &pathParts)
+{
+ for (int i = 0; i < pathParts.Size();)
+ {
+ UString &s = pathParts[i];
+ s = GetCorrectFileName(s);
+ if (s.IsEmpty())
+ pathParts.Delete(i);
+ else
+ {
+ #ifdef _WIN32
+ if (!IsSupportedName(s))
+ s = (UString)L"_" + s;
+ #endif
+ i++;
+ }
+ }
+}
+
+UString MakePathNameFromParts(const UStringVector &parts)
+{
+ UString result;
+ for (int i = 0; i < parts.Size(); i++)
+ {
+ if (i != 0)
+ result += WCHAR_PATH_SEPARATOR;
+ result += parts[i];
+ }
+ return result;
+}
+
+UString GetCorrectFsPath(const UString &path)
+{
+ UString res = GetCorrectFileName(path);
+ #ifdef _WIN32
+ if (!IsSupportedName(res))
+ res = (UString)L"_" + res;
+ #endif
+ return res;
+}
+
+UString GetCorrectFullFsPath(const UString &path)
+{
+ UStringVector parts;
+ SplitPathToParts(path, parts);
+ for (int i = 0; i < parts.Size(); i++)
+ {
+ #ifdef _WIN32
+ UString &s = parts[i];
+ while (!s.IsEmpty() && s[s.Length() - 1] == '.')
+ s.Delete(s.Length() - 1);
+ if (!IsSupportedName(s))
+ s = (UString)L"_" + s;
+ #endif
+ }
+ return MakePathNameFromParts(parts);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractingFilePath.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractingFilePath.h
new file mode 100644
index 000000000..da28bfc23
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ExtractingFilePath.h
@@ -0,0 +1,13 @@
+// ExtractingFilePath.h
+
+#ifndef __EXTRACTING_FILE_PATH_H
+#define __EXTRACTING_FILE_PATH_H
+
+#include "Common/MyString.h"
+
+UString MakePathNameFromParts(const UStringVector &parts);
+void MakeCorrectPath(UStringVector &pathParts);
+UString GetCorrectFsPath(const UString &path);
+UString GetCorrectFullFsPath(const UString &path);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/HandlerLoader.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/HandlerLoader.h
new file mode 100644
index 000000000..4c7e1a8f4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/HandlerLoader.h
@@ -0,0 +1,38 @@
+// HandlerLoader.h
+
+#ifndef __HANDLERLOADER_H
+#define __HANDLERLOADER_H
+
+#include "../../ICoder.h"
+#include "Windows/DLL.h"
+
+typedef UInt32 (WINAPI * CreateObjectFunc)(
+ const GUID *clsID,
+ const GUID *interfaceID,
+ void **outObject);
+
+class CHandlerLoader: public NWindows::NDLL::CLibrary
+{
+public:
+ HRESULT CreateHandler(LPCWSTR filepath, REFGUID clsID,
+ void **archive, bool outHandler)
+ {
+ if (!Load(filepath))
+ return GetLastError();
+ CreateObjectFunc createObject = (CreateObjectFunc)
+ GetProcAddress("CreateObject");
+ if (createObject == NULL)
+ {
+ HRESULT res = ::GetLastError();
+ Free();
+ return res;
+ }
+ HRESULT res = createObject(&clsID,
+ outHandler ? &IID_IOutArchive : &IID_IInArchive, (void **)archive);
+ if (res != 0)
+ Free();
+ return res;
+ }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/IFileExtractCallback.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/IFileExtractCallback.h
new file mode 100644
index 000000000..e8dcdce5f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/IFileExtractCallback.h
@@ -0,0 +1,46 @@
+// IFileExtractCallback.h
+
+#ifndef __IFILEEXTRACTCALLBACK_H
+#define __IFILEEXTRACTCALLBACK_H
+
+#include "Common/MyString.h"
+#include "../../IDecl.h"
+
+namespace NOverwriteAnswer
+{
+ enum EEnum
+ {
+ kYes,
+ kYesToAll,
+ kNo,
+ kNoToAll,
+ kAutoRename,
+ kCancel
+ };
+}
+
+DECL_INTERFACE_SUB(IFolderArchiveExtractCallback, IProgress, 0x01, 0x07)
+{
+public:
+ STDMETHOD(AskOverwrite)(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer) PURE;
+ STDMETHOD(PrepareOperation)(const wchar_t *name, bool isFolder, Int32 askExtractMode, const UInt64 *position) PURE;
+ STDMETHOD(MessageError)(const wchar_t *message) PURE;
+ STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted) PURE;
+};
+
+struct IExtractCallbackUI: IFolderArchiveExtractCallback
+{
+ virtual HRESULT BeforeOpen(const wchar_t *name) = 0;
+ virtual HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted) = 0;
+ virtual HRESULT ThereAreNoFiles() = 0;
+ virtual HRESULT ExtractResult(HRESULT result) = 0;
+
+ #ifndef _NO_CRYPTO
+ virtual HRESULT SetPassword(const UString &password) = 0;
+ #endif
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/LoadCodecs.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/LoadCodecs.cpp
new file mode 100644
index 000000000..ec607e8a2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/LoadCodecs.cpp
@@ -0,0 +1,697 @@
+// LoadCodecs.cpp
+
+#include "StdAfx.h"
+
+#include "LoadCodecs.h"
+
+#include "../../../Common/MyCom.h"
+#ifdef NEW_FOLDER_INTERFACE
+#include "../../../Common/StringToInt.h"
+#endif
+#include "../../../Windows/PropVariant.h"
+
+#include "../../ICoder.h"
+#include "../../Common/RegisterArc.h"
+
+#ifdef EXTERNAL_CODECS
+#include "../../../Windows/FileFind.h"
+#include "../../../Windows/DLL.h"
+#ifdef NEW_FOLDER_INTERFACE
+#include "../../../Windows/ResourceString.h"
+static const UINT kIconTypesResId = 100;
+#endif
+
+#ifdef _WIN32
+#include "Windows/Registry.h"
+#else
+#include "Common/StringConvert.h"
+#endif
+
+using namespace NWindows;
+using namespace NFile;
+
+#ifdef _WIN32
+extern HINSTANCE g_hInstance;
+#endif
+
+static CSysString GetLibraryFolderPrefix()
+{
+ #ifdef _WIN32
+ TCHAR fullPath[MAX_PATH + 1];
+ ::GetModuleFileName(g_hInstance, fullPath, MAX_PATH);
+ CSysString path = fullPath;
+ int pos = path.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
+ return path.Left(pos + 1);
+ #else
+ const char *p7zip_home_dir = getenv("P7ZIP_HOME_DIR");
+ if (p7zip_home_dir == 0) p7zip_home_dir="./";
+#ifdef _UNICODE
+ return MultiByteToUnicodeString(p7zip_home_dir);
+#else
+ return p7zip_home_dir;
+#endif
+ #endif
+}
+
+#define kCodecsFolderName TEXT("Codecs")
+#define kFormatsFolderName TEXT("Formats")
+static const TCHAR *kMainDll = TEXT("7z.dll");
+
+#ifdef _WIN32
+static LPCTSTR kRegistryPath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-zip");
+static LPCTSTR kProgramPathValue = TEXT("Path");
+static bool ReadPathFromRegistry(HKEY baseKey, CSysString &path)
+{
+ NRegistry::CKey key;
+ if(key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
+ if (key.QueryValue(kProgramPathValue, path) == ERROR_SUCCESS)
+ {
+ NName::NormalizeDirPathPrefix(path);
+ return true;
+ }
+ return false;
+}
+
+#endif
+
+CSysString GetBaseFolderPrefixFromRegistry()
+{
+ CSysString moduleFolderPrefix = GetLibraryFolderPrefix();
+#ifdef _UNICODE
+ NFind::CFileInfoW fi;
+#else
+ NFind::CFileInfo fi;
+#endif
+ if (NFind::FindFile(moduleFolderPrefix + kMainDll, fi))
+ if (!fi.IsDir())
+ return moduleFolderPrefix;
+ if (NFind::FindFile(moduleFolderPrefix + kCodecsFolderName, fi))
+ if (fi.IsDir())
+ return moduleFolderPrefix;
+ if (NFind::FindFile(moduleFolderPrefix + kFormatsFolderName, fi))
+ if (fi.IsDir())
+ return moduleFolderPrefix;
+ #ifdef _WIN32
+ CSysString path;
+ if (ReadPathFromRegistry(HKEY_CURRENT_USER, path))
+ return path;
+ if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
+ return path;
+ #endif
+ return moduleFolderPrefix;
+}
+
+typedef UInt32 (WINAPI *GetNumberOfMethodsFunc)(UInt32 *numMethods);
+typedef UInt32 (WINAPI *GetNumberOfFormatsFunc)(UInt32 *numFormats);
+typedef UInt32 (WINAPI *GetHandlerPropertyFunc)(PROPID propID, PROPVARIANT *value);
+typedef UInt32 (WINAPI *GetHandlerPropertyFunc2)(UInt32 index, PROPID propID, PROPVARIANT *value);
+typedef UInt32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *iid, void **outObject);
+typedef UInt32 (WINAPI *SetLargePageModeFunc)();
+
+
+static HRESULT GetCoderClass(GetMethodPropertyFunc getMethodProperty, UInt32 index,
+ PROPID propId, CLSID &clsId, bool &isAssigned)
+{
+ NWindows::NCOM::CPropVariant prop;
+ isAssigned = false;
+ RINOK(getMethodProperty(index, propId, &prop));
+ if (prop.vt == VT_BSTR)
+ {
+ isAssigned = true;
+ clsId = *(const GUID *)prop.bstrVal;
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ return S_OK;
+}
+
+HRESULT CCodecs::LoadCodecs()
+{
+ CCodecLib &lib = Libs.Back();
+ lib.GetMethodProperty = (GetMethodPropertyFunc)lib.Lib.GetProcAddress("GetMethodProperty");
+ if (lib.GetMethodProperty == NULL)
+ return S_OK;
+
+ UInt32 numMethods = 1;
+ GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)lib.Lib.GetProcAddress("GetNumberOfMethods");
+ if (getNumberOfMethodsFunc != NULL)
+ {
+ RINOK(getNumberOfMethodsFunc(&numMethods));
+ }
+
+ for(UInt32 i = 0; i < numMethods; i++)
+ {
+ CDllCodecInfo info;
+ info.LibIndex = Libs.Size() - 1;
+ info.CodecIndex = i;
+
+ RINOK(GetCoderClass(lib.GetMethodProperty, i, NMethodPropID::kEncoder, info.Encoder, info.EncoderIsAssigned));
+ RINOK(GetCoderClass(lib.GetMethodProperty, i, NMethodPropID::kDecoder, info.Decoder, info.DecoderIsAssigned));
+
+ Codecs.Add(info);
+ }
+ return S_OK;
+}
+
+static HRESULT ReadProp(
+ GetHandlerPropertyFunc getProp,
+ GetHandlerPropertyFunc2 getProp2,
+ UInt32 index, PROPID propID, NCOM::CPropVariant &prop)
+{
+ if (getProp2)
+ return getProp2(index, propID, &prop);;
+ return getProp(propID, &prop);
+}
+
+static HRESULT ReadBoolProp(
+ GetHandlerPropertyFunc getProp,
+ GetHandlerPropertyFunc2 getProp2,
+ UInt32 index, PROPID propID, bool &res)
+{
+ NCOM::CPropVariant prop;
+ RINOK(ReadProp(getProp, getProp2, index, propID, prop));
+ if (prop.vt == VT_BOOL)
+ res = VARIANT_BOOLToBool(prop.boolVal);
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ return S_OK;
+}
+
+static HRESULT ReadStringProp(
+ GetHandlerPropertyFunc getProp,
+ GetHandlerPropertyFunc2 getProp2,
+ UInt32 index, PROPID propID, UString &res)
+{
+ NCOM::CPropVariant prop;
+ RINOK(ReadProp(getProp, getProp2, index, propID, prop));
+ if (prop.vt == VT_BSTR)
+ res = prop.bstrVal;
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ return S_OK;
+}
+
+#endif
+
+static const unsigned int kNumArcsMax = 32;
+static unsigned int g_NumArcs = 0;
+static const CArcInfo *g_Arcs[kNumArcsMax];
+void RegisterArc(const CArcInfo *arcInfo)
+{
+ if (g_NumArcs < kNumArcsMax)
+ g_Arcs[g_NumArcs++] = arcInfo;
+}
+
+static void SplitString(const UString &srcString, UStringVector &destStrings)
+{
+ destStrings.Clear();
+ UString s;
+ int len = srcString.Length();
+ if (len == 0)
+ return;
+ for (int i = 0; i < len; i++)
+ {
+ wchar_t c = srcString[i];
+ if (c == L' ')
+ {
+ if (!s.IsEmpty())
+ {
+ destStrings.Add(s);
+ s.Empty();
+ }
+ }
+ else
+ s += c;
+ }
+ if (!s.IsEmpty())
+ destStrings.Add(s);
+}
+
+void CArcInfoEx::AddExts(const wchar_t* ext, const wchar_t* addExt)
+{
+ UStringVector exts, addExts;
+ SplitString(ext, exts);
+ if (addExt != 0)
+ SplitString(addExt, addExts);
+ for (int i = 0; i < exts.Size(); i++)
+ {
+ CArcExtInfo extInfo;
+ extInfo.Ext = exts[i];
+ if (i < addExts.Size())
+ {
+ extInfo.AddExt = addExts[i];
+ if (extInfo.AddExt == L"*")
+ extInfo.AddExt.Empty();
+ }
+ Exts.Add(extInfo);
+ }
+}
+
+#ifdef EXTERNAL_CODECS
+
+HRESULT CCodecs::LoadFormats()
+{
+ const NDLL::CLibrary &lib = Libs.Back().Lib;
+ GetHandlerPropertyFunc getProp = 0;
+ GetHandlerPropertyFunc2 getProp2 = (GetHandlerPropertyFunc2)
+ lib.GetProcAddress("GetHandlerProperty2");
+ if (getProp2 == NULL)
+ {
+ getProp = (GetHandlerPropertyFunc)
+ lib.GetProcAddress("GetHandlerProperty");
+ if (getProp == NULL)
+ return S_OK;
+ }
+
+ UInt32 numFormats = 1;
+ GetNumberOfFormatsFunc getNumberOfFormats = (GetNumberOfFormatsFunc)
+ lib.GetProcAddress("GetNumberOfFormats");
+ if (getNumberOfFormats != NULL)
+ {
+ RINOK(getNumberOfFormats(&numFormats));
+ }
+ if (getProp2 == NULL)
+ numFormats = 1;
+
+ for(UInt32 i = 0; i < numFormats; i++)
+ {
+ CArcInfoEx item;
+ item.LibIndex = Libs.Size() - 1;
+ item.FormatIndex = i;
+
+ RINOK(ReadStringProp(getProp, getProp2, i, NArchive::kName, item.Name));
+
+ NCOM::CPropVariant prop;
+ if (ReadProp(getProp, getProp2, i, NArchive::kClassID, prop) != S_OK)
+ continue;
+ if (prop.vt != VT_BSTR)
+ continue;
+ item.ClassID = *(const GUID *)prop.bstrVal;
+ prop.Clear();
+
+ UString ext, addExt;
+ RINOK(ReadStringProp(getProp, getProp2, i, NArchive::kExtension, ext));
+ RINOK(ReadStringProp(getProp, getProp2, i, NArchive::kAddExtension, addExt));
+ item.AddExts(ext, addExt);
+
+ ReadBoolProp(getProp, getProp2, i, NArchive::kUpdate, item.UpdateEnabled);
+ if (item.UpdateEnabled)
+ ReadBoolProp(getProp, getProp2, i, NArchive::kKeepName, item.KeepName);
+
+ if (ReadProp(getProp, getProp2, i, NArchive::kStartSignature, prop) == S_OK)
+ if (prop.vt == VT_BSTR)
+ {
+ UINT len = ::SysStringByteLen(prop.bstrVal);
+ item.StartSignature.SetCapacity(len);
+ memmove(item.StartSignature, prop.bstrVal, len);
+ }
+ Formats.Add(item);
+ }
+ return S_OK;
+}
+
+#ifdef NEW_FOLDER_INTERFACE
+void CCodecLib::LoadIcons()
+{
+#ifdef _WIN32
+ UString iconTypes = MyLoadStringW((HMODULE)Lib, kIconTypesResId);
+ UStringVector pairs;
+ SplitString(iconTypes, pairs);
+ for (int i = 0; i < pairs.Size(); i++)
+ {
+ const UString &s = pairs[i];
+ int pos = s.Find(L':');
+ if (pos < 0)
+ continue;
+ CIconPair iconPair;
+ const wchar_t *end;
+ UString num = s.Mid(pos + 1);
+ iconPair.IconIndex = (UInt32)ConvertStringToUInt64(num, &end);
+ if (*end != L'\0')
+ continue;
+ iconPair.Ext = s.Left(pos);
+ IconPairs.Add(iconPair);
+ }
+#endif // #ifdef _WIN32
+}
+
+int CCodecLib::FindIconIndex(const UString &ext) const
+{
+#ifdef _WIN32
+ for (int i = 0; i < IconPairs.Size(); i++)
+ {
+ const CIconPair &pair = IconPairs[i];
+ if (ext.CompareNoCase(pair.Ext) == 0)
+ return pair.IconIndex;
+ }
+#endif // #ifdef _WIN32
+ return -1;
+}
+#endif
+
+#ifdef _7ZIP_LARGE_PAGES
+extern "C"
+{
+ extern SIZE_T g_LargePageSize;
+}
+#endif
+
+HRESULT CCodecs::LoadDll(const CSysString &dllPath)
+{
+#ifdef _WIN32
+ {
+ NDLL::CLibrary library;
+ if (!library.LoadEx(dllPath, LOAD_LIBRARY_AS_DATAFILE))
+ return S_OK;
+ }
+#endif
+ Libs.Add(CCodecLib());
+ CCodecLib &lib = Libs.Back();
+ #ifdef NEW_FOLDER_INTERFACE
+ lib.Path = dllPath;
+ #endif
+ bool used = false;
+ HRESULT res = S_OK;
+ if (lib.Lib.Load(dllPath))
+ {
+ #ifdef NEW_FOLDER_INTERFACE
+ lib.LoadIcons();
+ #endif
+
+ #ifdef _7ZIP_LARGE_PAGES
+ if (g_LargePageSize != 0)
+ {
+ SetLargePageModeFunc setLargePageMode = (SetLargePageModeFunc)lib.Lib.GetProcAddress("SetLargePageMode");
+ if (setLargePageMode != 0)
+ setLargePageMode();
+ }
+ #endif
+
+ lib.CreateObject = (CreateObjectFunc)lib.Lib.GetProcAddress("CreateObject");
+ if (lib.CreateObject != 0)
+ {
+ int startSize = Codecs.Size();
+ res = LoadCodecs();
+ used = (Codecs.Size() != startSize);
+ if (res == S_OK)
+ {
+ startSize = Formats.Size();
+ res = LoadFormats();
+ used = used || (Formats.Size() != startSize);
+ }
+ }
+ }
+ if (!used)
+ Libs.DeleteBack();
+ return res;
+}
+
+HRESULT CCodecs::LoadDllsFromFolder(const CSysString &folderPrefix)
+{
+#ifdef _UNICODE
+ NFile::NFind::CEnumeratorW enumerator(folderPrefix + CSysString(TEXT("*")));
+ NFile::NFind::CFileInfoW fi;
+#else
+ NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*")));
+ NFile::NFind::CFileInfo fi;
+#endif
+ while (enumerator.Next(fi))
+ {
+ if (fi.IsDir())
+ continue;
+ RINOK(LoadDll(folderPrefix + fi.Name));
+ }
+ return S_OK;
+}
+
+#endif
+
+#ifndef _SFX
+static inline void SetBuffer(CByteBuffer &bb, const Byte *data, int size)
+{
+ bb.SetCapacity(size);
+ memmove((Byte *)bb, data, size);
+}
+#endif
+
+HRESULT CCodecs::Load()
+{
+ Formats.Clear();
+ #ifdef EXTERNAL_CODECS
+ Codecs.Clear();
+ #endif
+ for (UInt32 i = 0; i < g_NumArcs; i++)
+ {
+ const CArcInfo &arc = *g_Arcs[i];
+ CArcInfoEx item;
+ item.Name = arc.Name;
+ item.CreateInArchive = arc.CreateInArchive;
+ item.CreateOutArchive = arc.CreateOutArchive;
+ item.AddExts(arc.Ext, arc.AddExt);
+ item.UpdateEnabled = (arc.CreateOutArchive != 0);
+ item.KeepName = arc.KeepName;
+
+ #ifndef _SFX
+ SetBuffer(item.StartSignature, arc.Signature, arc.SignatureSize);
+ #endif
+ Formats.Add(item);
+ }
+ #ifdef EXTERNAL_CODECS
+ const CSysString baseFolder = GetBaseFolderPrefixFromRegistry();
+ RINOK(LoadDll(baseFolder + kMainDll));
+ RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName TEXT(STRING_PATH_SEPARATOR)));
+ RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName TEXT(STRING_PATH_SEPARATOR)));
+ #endif
+ return S_OK;
+}
+
+#ifndef _SFX
+
+int CCodecs::FindFormatForArchiveName(const UString &arcPath) const
+{
+ int slashPos1 = arcPath.ReverseFind(WCHAR_PATH_SEPARATOR);
+ int slashPos2 = arcPath.ReverseFind(L'.');
+ int dotPos = arcPath.ReverseFind(L'.');
+ if (dotPos < 0 || dotPos < slashPos1 || dotPos < slashPos2)
+ return -1;
+ UString ext = arcPath.Mid(dotPos + 1);
+ for (int i = 0; i < Formats.Size(); i++)
+ {
+ const CArcInfoEx &arc = Formats[i];
+ if (!arc.UpdateEnabled)
+ continue;
+ // if (arc.FindExtension(ext) >= 0)
+ UString mainExt = arc.GetMainExt();
+ if (!mainExt.IsEmpty() && ext.CompareNoCase(mainExt) == 0)
+ return i;
+ }
+ return -1;
+}
+
+int CCodecs::FindFormatForExtension(const UString &ext) const
+{
+ if (ext.IsEmpty())
+ return -1;
+ for (int i = 0; i < Formats.Size(); i++)
+ if (Formats[i].FindExtension(ext) >= 0)
+ return i;
+ return -1;
+}
+
+int CCodecs::FindFormatForArchiveType(const UString &arcType) const
+{
+ for (int i = 0; i < Formats.Size(); i++)
+ if (Formats[i].Name.CompareNoCase(arcType) == 0)
+ return i;
+ return -1;
+}
+
+bool CCodecs::FindFormatForArchiveType(const UString &arcType, CIntVector &formatIndices) const
+{
+ formatIndices.Clear();
+ for (int pos = 0; pos < arcType.Length();)
+ {
+ int pos2 = arcType.Find('.', pos);
+ if (pos2 < 0)
+ pos2 = arcType.Length();
+ const UString name = arcType.Mid(pos, pos2 - pos);
+ int index = FindFormatForArchiveType(name);
+ if (index < 0 && name != L"*")
+ {
+ formatIndices.Clear();
+ return false;
+ }
+ formatIndices.Add(index);
+ pos = pos2 + 1;
+ }
+ return true;
+}
+
+#endif
+
+#ifdef EXTERNAL_CODECS
+
+#ifdef EXPORT_CODECS
+extern unsigned int g_NumCodecs;
+STDAPI CreateCoder2(bool encode, UInt32 index, const GUID *iid, void **outObject);
+STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value);
+// STDAPI GetNumberOfMethods(UInt32 *numCodecs);
+#endif
+
+STDMETHODIMP CCodecs::GetNumberOfMethods(UInt32 *numMethods)
+{
+ *numMethods =
+ #ifdef EXPORT_CODECS
+ g_NumCodecs +
+ #endif
+ Codecs.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CCodecs::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ return GetMethodProperty(index, propID, value);
+ #endif
+
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+
+ if (propID == NMethodPropID::kDecoderIsAssigned)
+ {
+ NWindows::NCOM::CPropVariant propVariant;
+ propVariant = ci.DecoderIsAssigned;
+ propVariant.Detach(value);
+ return S_OK;
+ }
+ if (propID == NMethodPropID::kEncoderIsAssigned)
+ {
+ NWindows::NCOM::CPropVariant propVariant;
+ propVariant = ci.EncoderIsAssigned;
+ propVariant.Detach(value);
+ return S_OK;
+ }
+ return Libs[ci.LibIndex].GetMethodProperty(ci.CodecIndex, propID, value);
+}
+
+STDMETHODIMP CCodecs::CreateDecoder(UInt32 index, const GUID *iid, void **coder)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ return CreateCoder2(false, index, iid, coder);
+ #endif
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+ if (ci.DecoderIsAssigned)
+ return Libs[ci.LibIndex].CreateObject(&ci.Decoder, iid, (void **)coder);
+ return S_OK;
+}
+
+STDMETHODIMP CCodecs::CreateEncoder(UInt32 index, const GUID *iid, void **coder)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ return CreateCoder2(true, index, iid, coder);
+ #endif
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+ if (ci.EncoderIsAssigned)
+ return Libs[ci.LibIndex].CreateObject(&ci.Encoder, iid, (void **)coder);
+ return S_OK;
+}
+
+HRESULT CCodecs::CreateCoder(const UString &name, bool encode, CMyComPtr<ICompressCoder> &coder) const
+{
+ for (int i = 0; i < Codecs.Size(); i++)
+ {
+ const CDllCodecInfo &codec = Codecs[i];
+ if (encode && !codec.EncoderIsAssigned || !encode && !codec.DecoderIsAssigned)
+ continue;
+ const CCodecLib &lib = Libs[codec.LibIndex];
+ UString res;
+ NWindows::NCOM::CPropVariant prop;
+ RINOK(lib.GetMethodProperty(codec.CodecIndex, NMethodPropID::kName, &prop));
+ if (prop.vt == VT_BSTR)
+ res = prop.bstrVal;
+ else if (prop.vt != VT_EMPTY)
+ continue;
+ if (name.CompareNoCase(res) == 0)
+ return lib.CreateObject(encode ? &codec.Encoder : &codec.Decoder, &IID_ICompressCoder, (void **)&coder);
+ }
+ return CLASS_E_CLASSNOTAVAILABLE;
+}
+
+int CCodecs::GetCodecLibIndex(UInt32 index)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ return -1;
+ #endif
+ #ifdef EXTERNAL_CODECS
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+ return ci.LibIndex;
+ #else
+ return -1;
+ #endif
+}
+
+bool CCodecs::GetCodecEncoderIsAssigned(UInt32 index)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ {
+ NWindows::NCOM::CPropVariant prop;
+ if (GetProperty(index, NMethodPropID::kEncoder, &prop) == S_OK)
+ if (prop.vt != VT_EMPTY)
+ return true;
+ return false;
+ }
+ #endif
+ #ifdef EXTERNAL_CODECS
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+ return ci.EncoderIsAssigned;
+ #else
+ return false;
+ #endif
+}
+
+HRESULT CCodecs::GetCodecId(UInt32 index, UInt64 &id)
+{
+ UString s;
+ NWindows::NCOM::CPropVariant prop;
+ RINOK(GetProperty(index, NMethodPropID::kID, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ id = prop.uhVal.QuadPart;
+ return S_OK;
+}
+
+UString CCodecs::GetCodecName(UInt32 index)
+{
+ UString s;
+ NWindows::NCOM::CPropVariant prop;
+ if (GetProperty(index, NMethodPropID::kName, &prop) == S_OK)
+ if (prop.vt == VT_BSTR)
+ s = prop.bstrVal;
+ return s;
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/LoadCodecs.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/LoadCodecs.h
new file mode 100644
index 000000000..71de2ff1e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/LoadCodecs.h
@@ -0,0 +1,220 @@
+// LoadCodecs.h
+
+#ifndef __LOADCODECS_H
+#define __LOADCODECS_H
+
+#include "../../../Common/Types.h"
+#include "../../../Common/MyCom.h"
+#include "../../../Common/MyString.h"
+#include "../../../Common/Buffer.h"
+#include "../../ICoder.h"
+
+#ifdef EXTERNAL_CODECS
+#include "../../../Windows/DLL.h"
+#endif
+
+struct CDllCodecInfo
+{
+ CLSID Encoder;
+ CLSID Decoder;
+ bool EncoderIsAssigned;
+ bool DecoderIsAssigned;
+ int LibIndex;
+ UInt32 CodecIndex;
+};
+
+#include "../../Archive/IArchive.h"
+
+typedef IInArchive * (*CreateInArchiveP)();
+typedef IOutArchive * (*CreateOutArchiveP)();
+
+struct CArcExtInfo
+{
+ UString Ext;
+ UString AddExt;
+ CArcExtInfo() {}
+ CArcExtInfo(const UString &ext): Ext(ext) {}
+ CArcExtInfo(const UString &ext, const UString &addExt): Ext(ext), AddExt(addExt) {}
+};
+
+
+struct CArcInfoEx
+{
+ #ifdef EXTERNAL_CODECS
+ int LibIndex;
+ UInt32 FormatIndex;
+ CLSID ClassID;
+ #endif
+ bool UpdateEnabled;
+ CreateInArchiveP CreateInArchive;
+ CreateOutArchiveP CreateOutArchive;
+ UString Name;
+ CObjectVector<CArcExtInfo> Exts;
+ #ifndef _SFX
+ CByteBuffer StartSignature;
+ // CByteBuffer FinishSignature;
+ #ifdef NEW_FOLDER_INTERFACE
+ UStringVector AssociateExts;
+ #endif
+ #endif
+ bool KeepName;
+ UString GetMainExt() const
+ {
+ if (Exts.IsEmpty())
+ return UString();
+ return Exts[0].Ext;
+ }
+ int FindExtension(const UString &ext) const
+ {
+ for (int i = 0; i < Exts.Size(); i++)
+ if (ext.CompareNoCase(Exts[i].Ext) == 0)
+ return i;
+ return -1;
+ }
+ UString GetAllExtensions() const
+ {
+ UString s;
+ for (int i = 0; i < Exts.Size(); i++)
+ {
+ if (i > 0)
+ s += ' ';
+ s += Exts[i].Ext;
+ }
+ return s;
+ }
+
+ void AddExts(const wchar_t* ext, const wchar_t* addExt);
+
+ CArcInfoEx():
+ #ifdef EXTERNAL_CODECS
+ LibIndex(-1),
+ #endif
+ UpdateEnabled(false),
+ CreateInArchive(0), CreateOutArchive(0),
+ KeepName(false)
+ #ifndef _SFX
+ #endif
+ {}
+};
+
+#ifdef EXTERNAL_CODECS
+typedef UInt32 (WINAPI *GetMethodPropertyFunc)(UInt32 index, PROPID propID, PROPVARIANT *value);
+typedef UInt32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *interfaceID, void **outObject);
+
+
+struct CCodecLib
+{
+ NWindows::NDLL::CLibrary Lib;
+ GetMethodPropertyFunc GetMethodProperty;
+ CreateObjectFunc CreateObject;
+ #ifdef NEW_FOLDER_INTERFACE
+ struct CIconPair
+ {
+ UString Ext;
+ UInt32 IconIndex;
+ };
+ CSysString Path;
+ CObjectVector<CIconPair> IconPairs;
+ void LoadIcons();
+ int FindIconIndex(const UString &ext) const;
+ #endif
+ CCodecLib(): GetMethodProperty(0) {}
+};
+#endif
+
+class CCodecs:
+ #ifdef EXTERNAL_CODECS
+ public ICompressCodecsInfo,
+ #else
+ public IUnknown,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ #ifdef EXTERNAL_CODECS
+ CObjectVector<CCodecLib> Libs;
+ CObjectVector<CDllCodecInfo> Codecs;
+ HRESULT LoadCodecs();
+ HRESULT LoadFormats();
+ HRESULT LoadDll(const CSysString &path);
+ HRESULT LoadDllsFromFolder(const CSysString &folderPrefix);
+
+ HRESULT CreateArchiveHandler(const CArcInfoEx &ai, void **archive, bool outHandler) const
+ {
+ return Libs[ai.LibIndex].CreateObject(&ai.ClassID, outHandler ? &IID_IOutArchive : &IID_IInArchive, (void **)archive);
+ }
+ #endif
+
+public:
+ CObjectVector<CArcInfoEx> Formats;
+ HRESULT Load();
+
+ #ifndef _SFX
+ int FindFormatForArchiveName(const UString &arcPath) const;
+ int FindFormatForExtension(const UString &ext) const;
+ int FindFormatForArchiveType(const UString &arcType) const;
+ bool FindFormatForArchiveType(const UString &arcType, CIntVector &formatIndices) const;
+ #endif
+
+ MY_UNKNOWN_IMP
+
+ #ifdef EXTERNAL_CODECS
+ STDMETHOD(GetNumberOfMethods)(UInt32 *numMethods);
+ STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
+ STDMETHOD(CreateDecoder)(UInt32 index, const GUID *interfaceID, void **coder);
+ STDMETHOD(CreateEncoder)(UInt32 index, const GUID *interfaceID, void **coder);
+ #endif
+
+ int GetCodecLibIndex(UInt32 index);
+ bool GetCodecEncoderIsAssigned(UInt32 index);
+ HRESULT GetCodecId(UInt32 index, UInt64 &id);
+ UString GetCodecName(UInt32 index);
+
+ HRESULT CreateInArchive(int formatIndex, CMyComPtr<IInArchive> &archive) const
+ {
+ const CArcInfoEx &ai = Formats[formatIndex];
+ #ifdef EXTERNAL_CODECS
+ if (ai.LibIndex < 0)
+ #endif
+ {
+ archive = ai.CreateInArchive();
+ return S_OK;
+ }
+ #ifdef EXTERNAL_CODECS
+ return CreateArchiveHandler(ai, (void **)&archive, false);
+ #endif
+ }
+ HRESULT CreateOutArchive(int formatIndex, CMyComPtr<IOutArchive> &archive) const
+ {
+ const CArcInfoEx &ai = Formats[formatIndex];
+ #ifdef EXTERNAL_CODECS
+ if (ai.LibIndex < 0)
+ #endif
+ {
+ archive = ai.CreateOutArchive();
+ return S_OK;
+ }
+ #ifdef EXTERNAL_CODECS
+ return CreateArchiveHandler(ai, (void **)&archive, true);
+ #endif
+ }
+ int FindOutFormatFromName(const UString &name) const
+ {
+ for (int i = 0; i < Formats.Size(); i++)
+ {
+ const CArcInfoEx &arc = Formats[i];
+ if (!arc.UpdateEnabled)
+ continue;
+ if (arc.Name.CompareNoCase(name) == 0)
+ return i;
+ }
+ return -1;
+ }
+
+ #ifdef EXTERNAL_CODECS
+ HRESULT CreateCoder(const UString &name, bool encode, CMyComPtr<ICompressCoder> &coder) const;
+ #endif
+
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/OpenArchive.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/OpenArchive.cpp
new file mode 100644
index 000000000..d7d2f0f7c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/OpenArchive.cpp
@@ -0,0 +1,509 @@
+// OpenArchive.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Wildcard.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/PropVariant.h"
+
+#include "../../Common/FileStreams.h"
+#include "../../Common/StreamUtils.h"
+
+#include "DefaultName.h"
+#include "OpenArchive.h"
+
+using namespace NWindows;
+
+// Static-SFX (for Linux) can be big.
+const UInt64 kMaxCheckStartPosition = 1 << 22;
+
+HRESULT GetArchiveItemBoolProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result)
+{
+ NCOM::CPropVariant prop;
+ result = false;
+ RINOK(archive->GetProperty(index, propID, &prop));
+ if (prop.vt == VT_BOOL)
+ result = VARIANT_BOOLToBool(prop.boolVal);
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ return S_OK;
+}
+
+HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result)
+{
+ return GetArchiveItemBoolProp(archive, index, kpidIsDir, result);
+}
+
+HRESULT CArc::GetItemPath(UInt32 index, UString &result) const
+{
+ {
+ NCOM::CPropVariant prop;
+ RINOK(Archive->GetProperty(index, kpidPath, &prop));
+ if (prop.vt == VT_BSTR)
+ result = prop.bstrVal;
+ else if (prop.vt == VT_EMPTY)
+ result.Empty();
+ else
+ return E_FAIL;
+ }
+ if (result.IsEmpty())
+ {
+ result = DefaultName;
+ NCOM::CPropVariant prop;
+ RINOK(Archive->GetProperty(index, kpidExtension, &prop));
+ if (prop.vt == VT_BSTR)
+ {
+ result += L'.';
+ result += prop.bstrVal;
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ }
+ return S_OK;
+}
+
+HRESULT CArc::GetItemMTime(UInt32 index, FILETIME &ft, bool &defined) const
+{
+ NCOM::CPropVariant prop;
+ defined = false;
+ ft.dwHighDateTime = ft.dwLowDateTime = 0;
+ RINOK(Archive->GetProperty(index, kpidMTime, &prop));
+ if (prop.vt == VT_FILETIME)
+ {
+ ft = prop.filetime;
+ defined = true;
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ else if (MTimeDefined)
+ {
+ ft = MTime;
+ defined = true;
+ }
+ return S_OK;
+}
+
+#ifndef _SFX
+static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size)
+{
+ for (size_t i = 0; i < size; i++)
+ if (p1[i] != p2[i])
+ return false;
+ return true;
+}
+#endif
+
+HRESULT CArc::OpenStream(
+ CCodecs *codecs,
+ int formatIndex,
+ IInStream *stream,
+ ISequentialInStream *seqStream,
+ IArchiveOpenCallback *callback)
+{
+ Archive.Release();
+ const UString fileName = ExtractFileNameFromPath(Path);
+ UString extension;
+ {
+ int dotPos = fileName.ReverseFind(L'.');
+ if (dotPos >= 0)
+ extension = fileName.Mid(dotPos + 1);
+ }
+ CIntVector orderIndices;
+ if (formatIndex >= 0)
+ orderIndices.Add(formatIndex);
+ else
+ {
+
+ int i;
+ int numFinded = 0;
+ for (i = 0; i < codecs->Formats.Size(); i++)
+ if (codecs->Formats[i].FindExtension(extension) >= 0)
+ orderIndices.Insert(numFinded++, i);
+ else
+ orderIndices.Add(i);
+
+ if (!stream)
+ {
+ if (numFinded != 1)
+ return E_NOTIMPL;
+ orderIndices.DeleteFrom(1);
+ }
+
+ #ifndef _SFX
+ if (numFinded == 0)
+ {
+ CIntVector orderIndices2;
+ CByteBuffer byteBuffer;
+ const size_t kBufferSize = (1 << 21);
+ byteBuffer.SetCapacity(kBufferSize);
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
+ size_t processedSize = kBufferSize;
+ RINOK(ReadStream(stream, byteBuffer, &processedSize));
+ if (processedSize == 0)
+ return S_FALSE;
+
+ const Byte *buf = byteBuffer;
+ Byte hash[1 << 16];
+ memset(hash, 0xFF, 1 << 16);
+ Byte prevs[256];
+ if (orderIndices.Size() > 255)
+ return S_FALSE;
+ int i;
+ for (i = 0; i < orderIndices.Size(); i++)
+ {
+ const CArcInfoEx &ai = codecs->Formats[orderIndices[i]];
+ const CByteBuffer &sig = ai.StartSignature;
+ if (sig.GetCapacity() < 2)
+ continue;
+ UInt32 v = sig[0] | ((UInt32)sig[1] << 8);
+ prevs[i] = hash[v];
+ hash[v] = (Byte)i;
+ }
+
+ processedSize--;
+ for (UInt32 pos = 0; pos < processedSize; pos++)
+ {
+ for (; pos < processedSize && hash[buf[pos] | ((UInt32)buf[pos + 1] << 8)] == 0xFF; pos++);
+ if (pos == processedSize)
+ break;
+ UInt32 v = buf[pos] | ((UInt32)buf[pos + 1] << 8);
+ Byte *ptr = &hash[v];
+ int i = *ptr;
+ do
+ {
+ int index = orderIndices[i];
+ if( index != 0xFF )
+ {
+ const CArcInfoEx &ai = codecs->Formats[index];
+ const CByteBuffer &sig = ai.StartSignature;
+ if( sig.GetCapacity() != 0 && pos + sig.GetCapacity() <= processedSize + 1)
+ if (TestSignature(buf + pos, sig, sig.GetCapacity()))
+ {
+ orderIndices2.Add(index);
+ orderIndices[i] = 0xFF;
+ *ptr = prevs[i];
+ }
+ }
+ ptr = &prevs[i];
+ i = *ptr;
+ }
+ while (i != 0xFF);
+ }
+
+ for (i = 0; i < orderIndices.Size(); i++)
+ {
+ int val = orderIndices[i];
+ if (val != 0xFF)
+ orderIndices2.Add(val);
+ }
+ orderIndices = orderIndices2;
+ }
+ else if (extension == L"000" || extension == L"001")
+ {
+ CByteBuffer byteBuffer;
+ const size_t kBufferSize = (1 << 10);
+ byteBuffer.SetCapacity(kBufferSize);
+ Byte *buffer = byteBuffer;
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
+ size_t processedSize = kBufferSize;
+ RINOK(ReadStream(stream, buffer, &processedSize));
+ if (processedSize >= 16)
+ {
+ Byte kRarHeader[] = {0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00};
+ if (TestSignature(buffer, kRarHeader, 7) && buffer[9] == 0x73 && (buffer[10] & 1) != 0)
+ {
+ for (int i = 0; i < orderIndices.Size(); i++)
+ {
+ int index = orderIndices[i];
+ const CArcInfoEx &ai = codecs->Formats[index];
+ if (ai.Name.CompareNoCase(L"rar") != 0)
+ continue;
+ orderIndices.Delete(i--);
+ orderIndices.Insert(0, index);
+ break;
+ }
+ }
+ }
+ }
+ if (orderIndices.Size() >= 2)
+ {
+ int isoIndex = codecs->FindFormatForArchiveType(L"iso");
+ int udfIndex = codecs->FindFormatForArchiveType(L"udf");
+ int iIso = -1;
+ int iUdf = -1;
+ for (int i = 0; i < orderIndices.Size(); i++)
+ {
+ if (orderIndices[i] == isoIndex) iIso = i;
+ if (orderIndices[i] == udfIndex) iUdf = i;
+ }
+ if (iUdf > iIso && iIso >= 0)
+ {
+ orderIndices[iUdf] = isoIndex;
+ orderIndices[iIso] = udfIndex;
+ }
+ }
+
+ #endif
+ }
+
+ for (int i = 0; i < orderIndices.Size(); i++)
+ {
+ if (stream)
+ {
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
+ }
+ CMyComPtr<IInArchive> archive;
+
+ FormatIndex = orderIndices[i];
+ RINOK(codecs->CreateInArchive(FormatIndex, archive));
+ if (!archive)
+ continue;
+
+ #ifdef EXTERNAL_CODECS
+ {
+ CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
+ archive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
+ if (setCompressCodecsInfo)
+ {
+ RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs));
+ }
+ }
+ #endif
+
+ // OutputDebugStringW(codecs->Formats[FormatIndex].Name);
+
+ HRESULT result;
+ if (stream)
+ result = archive->Open(stream, &kMaxCheckStartPosition, callback);
+ else
+ {
+ CMyComPtr<IArchiveOpenSeq> openSeq;
+ archive.QueryInterface(IID_IArchiveOpenSeq, (void **)&openSeq);
+ if (!openSeq)
+ return E_NOTIMPL;
+ result = openSeq->OpenSeq(seqStream);
+ }
+
+ if (result == S_FALSE)
+ continue;
+ RINOK(result);
+
+ Archive = archive;
+ const CArcInfoEx &format = codecs->Formats[FormatIndex];
+ if (format.Exts.Size() == 0)
+ DefaultName = GetDefaultName2(fileName, L"", L"");
+ else
+ {
+ int subExtIndex = format.FindExtension(extension);
+ if (subExtIndex < 0)
+ subExtIndex = 0;
+ const CArcExtInfo &extInfo = format.Exts[subExtIndex];
+ DefaultName = GetDefaultName2(fileName, extInfo.Ext, extInfo.AddExt);
+ }
+ return S_OK;
+ }
+ return S_FALSE;
+}
+
+HRESULT CArc::OpenStreamOrFile(
+ CCodecs *codecs,
+ int formatIndex,
+ bool stdInMode,
+ IInStream *stream,
+ IArchiveOpenCallback *callback)
+{
+ CMyComPtr<IInStream> fileStream;
+ CMyComPtr<ISequentialInStream> seqStream;
+ if (stdInMode)
+ seqStream = new CStdInFileStream;
+ else if (!stream)
+ {
+ CInFileStream *fileStreamSpec = new CInFileStream(true);
+ fileStream = fileStreamSpec;
+ if (!fileStreamSpec->Open(Path))
+ return GetLastError();
+ stream = fileStream;
+ }
+
+ return OpenStream(codecs, formatIndex, stream, seqStream, callback);
+}
+
+HRESULT CArchiveLink::Close()
+{
+ for (int i = Arcs.Size() - 1; i >= 0; i--)
+ {
+ RINOK(Arcs[i].Archive->Close());
+ }
+ IsOpen = false;
+ return S_OK;
+}
+
+void CArchiveLink::Release()
+{
+ while (!Arcs.IsEmpty())
+ Arcs.DeleteBack();
+}
+
+HRESULT CArchiveLink::Open(
+ CCodecs *codecs,
+ const CIntVector &formatIndices,
+ bool stdInMode,
+ IInStream *stream,
+ const UString &filePath,
+ IArchiveOpenCallback *callback)
+{
+ Release();
+ if (formatIndices.Size() >= 32)
+ return E_NOTIMPL;
+
+ HRESULT resSpec;
+
+ for (;;)
+ {
+ resSpec = S_OK;
+ int formatIndex = -1;
+ if (formatIndices.Size() >= 1)
+ {
+ if (Arcs.Size() >= formatIndices.Size())
+ break;
+ formatIndex = formatIndices[formatIndices.Size() - Arcs.Size() - 1];
+ }
+ else if (Arcs.Size() >= 32)
+ break;
+
+ if (Arcs.IsEmpty())
+ {
+ CArc arc;
+ arc.Path = filePath;
+ arc.SubfileIndex = (UInt32)(Int32)-1;
+ RINOK(arc.OpenStreamOrFile(codecs, formatIndex, stdInMode, stream, callback));
+ Arcs.Add(arc);
+ continue;
+ }
+
+ const CArc &arc = Arcs.Back();
+
+ resSpec = (formatIndices.Size() == 0 ? S_OK : E_NOTIMPL);
+
+ UInt32 mainSubfile;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(arc.Archive->GetArchiveProperty(kpidMainSubfile, &prop));
+ if (prop.vt == VT_UI4)
+ mainSubfile = prop.ulVal;
+ else
+ break;
+ UInt32 numItems;
+ RINOK(arc.Archive->GetNumberOfItems(&numItems));
+ if (mainSubfile >= numItems)
+ break;
+ }
+
+
+ CMyComPtr<IInArchiveGetStream> getStream;
+ if (arc.Archive->QueryInterface(IID_IInArchiveGetStream, (void **)&getStream) != S_OK || !getStream)
+ break;
+
+ CMyComPtr<ISequentialInStream> subSeqStream;
+ if (getStream->GetStream(mainSubfile, &subSeqStream) != S_OK || !subSeqStream)
+ break;
+
+ CMyComPtr<IInStream> subStream;
+ if (subSeqStream.QueryInterface(IID_IInStream, &subStream) != S_OK || !subStream)
+ break;
+
+ CArc arc2;
+ RINOK(arc.GetItemPath(mainSubfile, arc2.Path));
+
+ CMyComPtr<IArchiveOpenSetSubArchiveName> setSubArchiveName;
+ callback->QueryInterface(IID_IArchiveOpenSetSubArchiveName, (void **)&setSubArchiveName);
+ if (setSubArchiveName)
+ setSubArchiveName->SetSubArchiveName(arc2.Path);
+
+ arc2.SubfileIndex = mainSubfile;
+ HRESULT result = arc2.OpenStream(codecs, formatIndex, subStream, NULL, callback);
+ resSpec = (formatIndices.Size() == 0 ? S_OK : S_FALSE);
+ if (result == S_FALSE)
+ break;
+ RINOK(result);
+ RINOK(arc.GetItemMTime(mainSubfile, arc2.MTime, arc2.MTimeDefined));
+ Arcs.Add(arc2);
+ }
+ IsOpen = !Arcs.IsEmpty();
+ return S_OK;
+}
+
+static void SetCallback(const UString &filePath,
+ IOpenCallbackUI *callbackUI,
+ IArchiveOpenCallback *reOpenCallback,
+ CMyComPtr<IArchiveOpenCallback> &callback)
+{
+ COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
+ callback = openCallbackSpec;
+ openCallbackSpec->Callback = callbackUI;
+ openCallbackSpec->ReOpenCallback = reOpenCallback;
+
+ UString fullName;
+ int fileNamePartStartIndex;
+ NFile::NDirectory::MyGetFullPathName(filePath, fullName, fileNamePartStartIndex);
+ openCallbackSpec->Init(
+ fullName.Left(fileNamePartStartIndex),
+ fullName.Mid(fileNamePartStartIndex));
+}
+
+HRESULT CArchiveLink::Open2(CCodecs *codecs,
+ const CIntVector &formatIndices,
+ bool stdInMode,
+ IInStream *stream,
+ const UString &filePath,
+ IOpenCallbackUI *callbackUI)
+{
+ VolumesSize = 0;
+ COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
+ CMyComPtr<IArchiveOpenCallback> callback = openCallbackSpec;
+ openCallbackSpec->Callback = callbackUI;
+
+ UString fullName, prefix, name;
+ if (!stream && !stdInMode)
+ {
+ int fileNamePartStartIndex;
+ if (!NFile::NDirectory::MyGetFullPathName(filePath, fullName, fileNamePartStartIndex))
+ return GetLastError();
+ prefix = fullName.Left(fileNamePartStartIndex);
+ name = fullName.Mid(fileNamePartStartIndex);
+ openCallbackSpec->Init(prefix, name);
+ }
+ else
+ {
+ openCallbackSpec->SetSubArchiveName(filePath);
+ }
+
+ RINOK(Open(codecs, formatIndices, stdInMode, stream, filePath, callback));
+ VolumePaths.Add(prefix + name);
+ for (int i = 0; i < openCallbackSpec->FileNames.Size(); i++)
+ VolumePaths.Add(prefix + openCallbackSpec->FileNames[i]);
+ VolumesSize = openCallbackSpec->TotalSize;
+ return S_OK;
+}
+
+HRESULT CArchiveLink::ReOpen(CCodecs *codecs, const UString &filePath,
+ IArchiveOpenCallback *callback)
+{
+ if (Arcs.Size() > 1)
+ return E_NOTIMPL;
+
+ if (Arcs.Size() == 0)
+ return Open2(codecs, CIntVector(), false, NULL, filePath, 0);
+
+ CMyComPtr<IArchiveOpenCallback> openCallbackNew;
+ SetCallback(filePath, NULL, callback, openCallbackNew);
+
+ CInFileStream *fileStreamSpec = new CInFileStream(true);
+ CMyComPtr<IInStream> stream(fileStreamSpec);
+ if (!fileStreamSpec->Open(filePath))
+ return GetLastError();
+ HRESULT res = GetArchive()->Open(stream, &kMaxCheckStartPosition, callback);
+ IsOpen = (res == S_OK);
+ return res;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/OpenArchive.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/OpenArchive.h
new file mode 100644
index 000000000..921036235
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/OpenArchive.h
@@ -0,0 +1,86 @@
+// OpenArchive.h
+
+#ifndef __OPEN_ARCHIVE_H
+#define __OPEN_ARCHIVE_H
+
+#include "Common/MyString.h"
+
+#include "Windows/FileFind.h"
+
+#include "../../Archive/IArchive.h"
+
+#include "ArchiveOpenCallback.h"
+#include "LoadCodecs.h"
+
+HRESULT GetArchiveItemBoolProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result);
+HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result);
+
+struct CArc
+{
+ CMyComPtr<IInArchive> Archive;
+ UString Path;
+ UString DefaultName;
+ int FormatIndex;
+ int SubfileIndex;
+ FILETIME MTime;
+ bool MTimeDefined;
+
+ CArc(): MTimeDefined(false) {}
+
+ HRESULT GetItemPath(UInt32 index, UString &result) const;
+ HRESULT GetItemMTime(UInt32 index, FILETIME &ft, bool &defined) const;
+ HRESULT IsItemAnti(UInt32 index, bool &result) const
+ { return GetArchiveItemBoolProp(Archive, index, kpidIsAnti, result); }
+
+ HRESULT OpenStream(
+ CCodecs *codecs,
+ int formatIndex,
+ IInStream *stream,
+ ISequentialInStream *seqStream,
+ IArchiveOpenCallback *callback);
+
+ HRESULT OpenStreamOrFile(
+ CCodecs *codecs,
+ int formatIndex,
+ bool stdInMode,
+ IInStream *stream,
+ IArchiveOpenCallback *callback);
+};
+
+struct CArchiveLink
+{
+ CObjectVector<CArc> Arcs;
+ UStringVector VolumePaths;
+ UInt64 VolumesSize;
+ bool IsOpen;
+
+ CArchiveLink(): VolumesSize(0), IsOpen(false) {}
+ HRESULT Close();
+ void Release();
+ ~CArchiveLink() { Release(); }
+
+ IInArchive *GetArchive() const { return Arcs.Back().Archive; }
+
+ HRESULT Open(
+ CCodecs *codecs,
+ const CIntVector &formatIndices,
+ bool stdInMode,
+ IInStream *stream,
+ const UString &filePath,
+ IArchiveOpenCallback *callback);
+
+ HRESULT Open2(
+ CCodecs *codecs,
+ const CIntVector &formatIndices,
+ bool stdInMode,
+ IInStream *stream,
+ const UString &filePath,
+ IOpenCallbackUI *callbackUI);
+
+ HRESULT ReOpen(
+ CCodecs *codecs,
+ const UString &filePath,
+ IArchiveOpenCallback *callback);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/PropIDUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/PropIDUtils.cpp
new file mode 100644
index 000000000..d8c0e7d64
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/PropIDUtils.cpp
@@ -0,0 +1,96 @@
+// PropIDUtils.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+
+#include "Windows/FileFind.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../PropID.h"
+
+#include "PropIDUtils.h"
+
+using namespace NWindows;
+
+void ConvertUInt32ToHex(UInt32 value, wchar_t *s)
+{
+ for (int i = 0; i < 8; i++)
+ {
+ int t = value & 0xF;
+ value >>= 4;
+ s[7 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
+ }
+ s[8] = L'\0';
+}
+
+#define MY_ATTR_CHAR(a, n, c) ((a )& (1 << (n))) ? c : L'-';
+
+UString ConvertPropertyToString(const PROPVARIANT &prop, PROPID propID, bool full)
+{
+ switch(propID)
+ {
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
+ {
+ if (prop.vt != VT_FILETIME)
+ break;
+ FILETIME localFileTime;
+ if ((prop.filetime.dwHighDateTime == 0 &&
+ prop.filetime.dwLowDateTime == 0) ||
+ !::FileTimeToLocalFileTime(&prop.filetime, &localFileTime))
+ return UString();
+ return ConvertFileTimeToString(localFileTime, true, full);
+ }
+ case kpidCRC:
+ {
+ if (prop.vt != VT_UI4)
+ break;
+ wchar_t temp[12];
+ ConvertUInt32ToHex(prop.ulVal, temp);
+ return temp;
+ }
+ case kpidAttrib:
+ {
+ if (prop.vt != VT_UI4)
+ break;
+ UString res;
+ UInt32 a = prop.ulVal;
+ if (NFile::NFind::NAttributes::IsReadOnly(a)) res += L'R';
+ if (NFile::NFind::NAttributes::IsHidden(a)) res += L'H';
+ if (NFile::NFind::NAttributes::IsSystem(a)) res += L'S';
+ if (NFile::NFind::NAttributes::IsDir(a)) res += L'D';
+ if (NFile::NFind::NAttributes::IsArchived(a)) res += L'A';
+ if (NFile::NFind::NAttributes::IsCompressed(a)) res += L'C';
+ if (NFile::NFind::NAttributes::IsEncrypted(a)) res += L'E';
+ return res;
+ }
+ case kpidPosixAttrib:
+ {
+ if (prop.vt != VT_UI4)
+ break;
+ UString res;
+ UInt32 a = prop.ulVal;
+ wchar_t temp[16];
+ temp[0] = MY_ATTR_CHAR(a, 14, L'd');
+ for (int i = 6; i >= 0; i -= 3)
+ {
+ temp[7 - i] = MY_ATTR_CHAR(a, i + 2, L'r');
+ temp[8 - i] = MY_ATTR_CHAR(a, i + 1, L'w');
+ temp[9 - i] = MY_ATTR_CHAR(a, i + 0, L'x');
+ }
+ temp[10] = 0;
+ res = temp;
+ a &= ~0x1FF;
+ a &= ~0xC000;
+ if (a != 0)
+ {
+ ConvertUInt32ToHex(a, temp);
+ res = UString(temp) + L' ' + res;
+ }
+ return res;
+ }
+ }
+ return ConvertPropVariantToString(prop);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/PropIDUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/PropIDUtils.h
new file mode 100644
index 000000000..ca14d091d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/PropIDUtils.h
@@ -0,0 +1,12 @@
+// PropIDUtils.h
+
+#ifndef __PROPID_UTILS_H
+#define __PROPID_UTILS_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+
+void ConvertUInt32ToHex(UInt32 value, wchar_t *s);
+UString ConvertPropertyToString(const PROPVARIANT &propVariant, PROPID propID, bool full = true);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Property.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Property.h
new file mode 100644
index 000000000..9fd340cbc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Property.h
@@ -0,0 +1,14 @@
+// Property.h
+
+#ifndef __PROPERTY_H
+#define __PROPERTY_H
+
+#include "Common/MyString.h"
+
+struct CProperty
+{
+ UString Name;
+ UString Value;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SetProperties.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SetProperties.cpp
new file mode 100644
index 000000000..4827f2a78
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SetProperties.cpp
@@ -0,0 +1,79 @@
+// SetProperties.cpp
+
+#include "StdAfx.h"
+
+#include "SetProperties.h"
+
+#include "Windows/PropVariant.h"
+#include "Common/MyString.h"
+#include "Common/StringToInt.h"
+#include "Common/MyCom.h"
+
+#include "../../Archive/IArchive.h"
+
+using namespace NWindows;
+using namespace NCOM;
+
+static void ParseNumberString(const UString &s, NCOM::CPropVariant &prop)
+{
+ const wchar_t *endPtr;
+ UInt64 result = ConvertStringToUInt64(s, &endPtr);
+ if (endPtr - (const wchar_t *)s != s.Length())
+ prop = s;
+ else if (result <= 0xFFFFFFFF)
+ prop = (UInt32)result;
+ else
+ prop = result;
+}
+
+HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &properties)
+{
+ if (properties.IsEmpty())
+ return S_OK;
+ CMyComPtr<ISetProperties> setProperties;
+ unknown->QueryInterface(IID_ISetProperties, (void **)&setProperties);
+ if (!setProperties)
+ return S_OK;
+
+ UStringVector realNames;
+ CPropVariant *values = new CPropVariant[properties.Size()];
+ try
+ {
+ int i;
+ for(i = 0; i < properties.Size(); i++)
+ {
+ const CProperty &property = properties[i];
+ NCOM::CPropVariant propVariant;
+ UString name = property.Name;
+ if (property.Value.IsEmpty())
+ {
+ if (!name.IsEmpty())
+ {
+ wchar_t c = name[name.Length() - 1];
+ if (c == L'-')
+ propVariant = false;
+ else if (c == L'+')
+ propVariant = true;
+ if (propVariant.vt != VT_EMPTY)
+ name = name.Left(name.Length() - 1);
+ }
+ }
+ else
+ ParseNumberString(property.Value, propVariant);
+ realNames.Add(name);
+ values[i] = propVariant;
+ }
+ CRecordVector<const wchar_t *> names;
+ for(i = 0; i < realNames.Size(); i++)
+ names.Add((const wchar_t *)realNames[i]);
+
+ RINOK(setProperties->SetProperties(&names.Front(), values, names.Size()));
+ }
+ catch(...)
+ {
+ delete []values;
+ throw;
+ }
+ delete []values;
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SetProperties.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SetProperties.h
new file mode 100644
index 000000000..892f1a210
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SetProperties.h
@@ -0,0 +1,10 @@
+// SetProperties.h
+
+#ifndef __SETPROPERTIES_H
+#define __SETPROPERTIES_H
+
+#include "Property.h"
+
+HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &properties);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SortUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SortUtils.cpp
new file mode 100644
index 000000000..061e77730
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SortUtils.cpp
@@ -0,0 +1,22 @@
+// SortUtils.cpp
+
+#include "StdAfx.h"
+
+#include "SortUtils.h"
+#include "Common/Wildcard.h"
+
+static int CompareStrings(const int *p1, const int *p2, void *param)
+{
+ const UStringVector &strings = *(const UStringVector *)param;
+ return CompareFileNames(strings[*p1], strings[*p2]);
+}
+
+void SortFileNames(const UStringVector &strings, CIntVector &indices)
+{
+ indices.Clear();
+ int numItems = strings.Size();
+ indices.Reserve(numItems);
+ for(int i = 0; i < numItems; i++)
+ indices.Add(i);
+ indices.Sort(CompareStrings, (void *)&strings);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SortUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SortUtils.h
new file mode 100644
index 000000000..e15224611
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/SortUtils.h
@@ -0,0 +1,10 @@
+// SortUtils.h
+
+#ifndef __SORTUTLS_H
+#define __SORTUTLS_H
+
+#include "Common/MyString.h"
+
+void SortFileNames(const UStringVector &strings, CIntVector &indices);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/TempFiles.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/TempFiles.cpp
new file mode 100644
index 000000000..eeaec1802
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/TempFiles.cpp
@@ -0,0 +1,22 @@
+// TempFiles.cpp
+
+#include "StdAfx.h"
+
+#include "TempFiles.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileIO.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+void CTempFiles::Clear()
+{
+ while(!Paths.IsEmpty())
+ {
+ NDirectory::DeleteFileAlways((LPCWSTR)Paths.Back());
+ Paths.DeleteBack();
+ }
+}
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/TempFiles.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/TempFiles.h
new file mode 100644
index 000000000..eb474a760
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/TempFiles.h
@@ -0,0 +1,16 @@
+// TempFiles.h
+
+#ifndef __TEMPFILES_H
+#define __TEMPFILES_H
+
+#include "Common/MyString.h"
+
+class CTempFiles
+{
+ void Clear();
+public:
+ UStringVector Paths;
+ ~CTempFiles() { Clear(); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Update.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Update.cpp
new file mode 100644
index 000000000..fd40be017
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Update.cpp
@@ -0,0 +1,908 @@
+// Update.cpp
+
+#include "StdAfx.h"
+
+#include "Update.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#ifdef _WIN32
+//#include "Windows/DLL.h"
+#endif
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+#include "Windows/Time.h"
+
+#include "../../Common/FileStreams.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../Common/DirItem.h"
+#include "../Common/EnumDirItems.h"
+#include "../Common/OpenArchive.h"
+#include "../Common/UpdateProduce.h"
+
+#include "EnumDirItems.h"
+#include "SetProperties.h"
+#include "TempFiles.h"
+#include "UpdateCallback.h"
+
+#undef _WIN32
+
+static const char *kUpdateIsNotSupoorted =
+ "update operations are not supported for this archive";
+
+using namespace NWindows;
+using namespace NCOM;
+using namespace NFile;
+using namespace NName;
+
+//static const wchar_t *kTempFolderPrefix = L"7zE";
+
+using namespace NUpdateArchive;
+
+class COutMultiVolStream:
+ public IOutStream,
+ public CMyUnknownImp
+{
+ int _streamIndex; // required stream
+ UInt64 _offsetPos; // offset from start of _streamIndex index
+ UInt64 _absPos;
+ UInt64 _length;
+
+ struct CSubStreamInfo
+ {
+ COutFileStream *StreamSpec;
+ CMyComPtr<IOutStream> Stream;
+ UString Name;
+ UInt64 Pos;
+ UInt64 RealSize;
+ };
+ CObjectVector<CSubStreamInfo> Streams;
+public:
+ // CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
+ CRecordVector<UInt64> Sizes;
+ UString Prefix;
+ CTempFiles *TempFiles;
+
+ void Init()
+ {
+ _streamIndex = 0;
+ _offsetPos = 0;
+ _absPos = 0;
+ _length = 0;
+ }
+
+ HRESULT Close();
+
+ MY_UNKNOWN_IMP1(IOutStream)
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+ STDMETHOD(SetSize)(Int64 newSize);
+};
+
+// static NSynchronization::CCriticalSection g_TempPathsCS;
+
+HRESULT COutMultiVolStream::Close()
+{
+ HRESULT res = S_OK;
+ for (int i = 0; i < Streams.Size(); i++)
+ {
+ CSubStreamInfo &s = Streams[i];
+ if (s.StreamSpec)
+ {
+ HRESULT res2 = s.StreamSpec->Close();
+ if (res2 != S_OK)
+ res = res2;
+ }
+ }
+ return res;
+}
+
+STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ while(size > 0)
+ {
+ if (_streamIndex >= Streams.Size())
+ {
+ CSubStreamInfo subStream;
+
+ wchar_t temp[16];
+ ConvertUInt32ToString(_streamIndex + 1, temp);
+ UString res = temp;
+ while (res.Length() < 3)
+ res = UString(L'0') + res;
+ UString name = Prefix + res;
+ subStream.StreamSpec = new COutFileStream;
+ subStream.Stream = subStream.StreamSpec;
+ if (!subStream.StreamSpec->Create(name, false))
+ return ::GetLastError();
+ {
+ // NSynchronization::CCriticalSectionLock lock(g_TempPathsCS);
+ TempFiles->Paths.Add(name);
+ }
+
+ subStream.Pos = 0;
+ subStream.RealSize = 0;
+ subStream.Name = name;
+ Streams.Add(subStream);
+ continue;
+ }
+ CSubStreamInfo &subStream = Streams[_streamIndex];
+
+ int index = _streamIndex;
+ if (index >= Sizes.Size())
+ index = Sizes.Size() - 1;
+ UInt64 volSize = Sizes[index];
+
+ if (_offsetPos >= volSize)
+ {
+ _offsetPos -= volSize;
+ _streamIndex++;
+ continue;
+ }
+ if (_offsetPos != subStream.Pos)
+ {
+ // CMyComPtr<IOutStream> outStream;
+ // RINOK(subStream.Stream.QueryInterface(IID_IOutStream, &outStream));
+ RINOK(subStream.Stream->Seek(_offsetPos, STREAM_SEEK_SET, NULL));
+ subStream.Pos = _offsetPos;
+ }
+
+ UInt32 curSize = (UInt32)MyMin((UInt64)size, volSize - subStream.Pos);
+ UInt32 realProcessed;
+ RINOK(subStream.Stream->Write(data, curSize, &realProcessed));
+ data = (void *)((Byte *)data + realProcessed);
+ size -= realProcessed;
+ subStream.Pos += realProcessed;
+ _offsetPos += realProcessed;
+ _absPos += realProcessed;
+ if (_absPos > _length)
+ _length = _absPos;
+ if (_offsetPos > subStream.RealSize)
+ subStream.RealSize = _offsetPos;
+ if (processedSize != NULL)
+ *processedSize += realProcessed;
+ if (subStream.Pos == volSize)
+ {
+ _streamIndex++;
+ _offsetPos = 0;
+ }
+ if (realProcessed == 0 && curSize != 0)
+ return E_FAIL;
+ break;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP COutMultiVolStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ if (seekOrigin >= 3)
+ return STG_E_INVALIDFUNCTION;
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET:
+ _absPos = offset;
+ break;
+ case STREAM_SEEK_CUR:
+ _absPos += offset;
+ break;
+ case STREAM_SEEK_END:
+ _absPos = _length + offset;
+ break;
+ }
+ _offsetPos = _absPos;
+ if (newPosition != NULL)
+ *newPosition = _absPos;
+ _streamIndex = 0;
+ return S_OK;
+}
+
+STDMETHODIMP COutMultiVolStream::SetSize(Int64 newSize)
+{
+ if (newSize < 0)
+ return E_INVALIDARG;
+ int i = 0;
+ while (i < Streams.Size())
+ {
+ CSubStreamInfo &subStream = Streams[i++];
+ if ((UInt64)newSize < subStream.RealSize)
+ {
+ RINOK(subStream.Stream->SetSize(newSize));
+ subStream.RealSize = newSize;
+ break;
+ }
+ newSize -= subStream.RealSize;
+ }
+ while (i < Streams.Size())
+ {
+ {
+ CSubStreamInfo &subStream = Streams.Back();
+ subStream.Stream.Release();
+ NDirectory::DeleteFileAlways(subStream.Name);
+ }
+ Streams.DeleteBack();
+ }
+ _offsetPos = _absPos;
+ _streamIndex = 0;
+ _length = newSize;
+ return S_OK;
+}
+
+static const wchar_t *kDefaultArchiveType = L"7z";
+static const wchar_t *kSFXExtension =
+ #ifdef _WIN32
+ L"exe";
+ #else
+ L"";
+ #endif
+
+bool CUpdateOptions::Init(const CCodecs *codecs, const CIntVector &formatIndices, const UString &arcPath)
+{
+ if (formatIndices.Size() > 1)
+ return false;
+ int arcTypeIndex = -1;
+ if (formatIndices.Size() != 0)
+ arcTypeIndex = formatIndices[0];
+ if (arcTypeIndex >= 0)
+ MethodMode.FormatIndex = arcTypeIndex;
+ else
+ {
+ MethodMode.FormatIndex = codecs->FindFormatForArchiveName(arcPath);
+ // It works incorrectly for update command if archive has some non-default extension!
+ if (MethodMode.FormatIndex < 0)
+ MethodMode.FormatIndex = codecs->FindFormatForArchiveType(kDefaultArchiveType);
+ }
+ if (MethodMode.FormatIndex < 0)
+ return false;
+ const CArcInfoEx &arcInfo = codecs->Formats[MethodMode.FormatIndex];
+ if (!arcInfo.UpdateEnabled)
+ return false;
+ UString typeExt = arcInfo.GetMainExt();
+ UString ext = typeExt;
+ if (SfxMode)
+ ext = kSFXExtension;
+ ArchivePath.BaseExtension = ext;
+ ArchivePath.VolExtension = typeExt;
+ ArchivePath.ParseFromPath(arcPath);
+ for (int i = 0; i < Commands.Size(); i++)
+ {
+ CUpdateArchiveCommand &uc = Commands[i];
+ uc.ArchivePath.BaseExtension = ext;
+ uc.ArchivePath.VolExtension = typeExt;
+ uc.ArchivePath.ParseFromPath(uc.UserArchivePath);
+ }
+ return true;
+}
+
+/*
+struct CUpdateProduceCallbackImp: public IUpdateProduceCallback
+{
+ const CObjectVector<CArcItem> *_arcItems;
+ IUpdateCallbackUI *_callback;
+
+ CUpdateProduceCallbackImp(const CObjectVector<CArcItem> *a,
+ IUpdateCallbackUI *callback): _arcItems(a), _callback(callback) {}
+ virtual HRESULT ShowDeleteFile(int arcIndex);
+};
+
+HRESULT CUpdateProduceCallbackImp::ShowDeleteFile(int arcIndex)
+{
+ return _callback->ShowDeleteFile((*_arcItems)[arcIndex].Name);
+}
+*/
+
+static HRESULT Compress(
+ CCodecs *codecs,
+ const CActionSet &actionSet,
+ IInArchive *archive,
+ const CCompressionMethodMode &compressionMethod,
+ CArchivePath &archivePath,
+ const CObjectVector<CArcItem> &arcItems,
+ bool shareForWrite,
+ bool stdInMode,
+ /* const UString & stdInFileName, */
+ bool stdOutMode,
+ const CDirItems &dirItems,
+ bool sfxMode,
+ const UString &sfxModule,
+ const CRecordVector<UInt64> &volumesSizes,
+ CTempFiles &tempFiles,
+ CUpdateErrorInfo &errorInfo,
+ IUpdateCallbackUI *callback)
+{
+ CMyComPtr<IOutArchive> outArchive;
+ if (archive != NULL)
+ {
+ CMyComPtr<IInArchive> archive2 = archive;
+ HRESULT result = archive2.QueryInterface(IID_IOutArchive, &outArchive);
+ if (result != S_OK)
+ throw kUpdateIsNotSupoorted;
+ }
+ else
+ {
+ RINOK(codecs->CreateOutArchive(compressionMethod.FormatIndex, outArchive));
+
+ #ifdef EXTERNAL_CODECS
+ {
+ CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
+ outArchive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
+ if (setCompressCodecsInfo)
+ {
+ RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs));
+ }
+ }
+ #endif
+ }
+ if (outArchive == 0)
+ throw kUpdateIsNotSupoorted;
+
+ NFileTimeType::EEnum fileTimeType;
+ UInt32 value;
+ RINOK(outArchive->GetFileTimeType(&value));
+
+ switch(value)
+ {
+ case NFileTimeType::kWindows:
+ case NFileTimeType::kUnix:
+ case NFileTimeType::kDOS:
+ fileTimeType = (NFileTimeType::EEnum)value;
+ break;
+ default:
+ return E_FAIL;
+ }
+
+ CRecordVector<CUpdatePair2> updatePairs2;
+
+ {
+ CRecordVector<CUpdatePair> updatePairs;
+ GetUpdatePairInfoList(dirItems, arcItems, fileTimeType, updatePairs); // must be done only once!!!
+ // CUpdateProduceCallbackImp upCallback(&arcItems, callback);
+ UpdateProduce(updatePairs, actionSet, updatePairs2, NULL /* &upCallback */);
+ }
+
+ UInt32 numFiles = 0;
+ for (int i = 0; i < updatePairs2.Size(); i++)
+ if (updatePairs2[i].NewData)
+ numFiles++;
+
+ RINOK(callback->SetNumFiles(numFiles));
+
+
+ CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
+ CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
+
+ updateCallbackSpec->ShareForWrite = shareForWrite;
+ updateCallbackSpec->StdInMode = stdInMode;
+ updateCallbackSpec->Callback = callback;
+ updateCallbackSpec->DirItems = &dirItems;
+ updateCallbackSpec->ArcItems = &arcItems;
+ updateCallbackSpec->UpdatePairs = &updatePairs2;
+
+ CMyComPtr<ISequentialOutStream> outStream;
+
+ const UString &archiveName = archivePath.GetFinalPath();
+ if (!stdOutMode)
+ {
+ UString resultPath;
+ int pos;
+ if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
+ throw 1417161;
+ NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
+ }
+
+ COutFileStream *outStreamSpec = NULL;
+ COutMultiVolStream *volStreamSpec = NULL;
+
+ if (volumesSizes.Size() == 0)
+ {
+ if (stdOutMode)
+ outStream = new CStdOutFileStream;
+ else
+ {
+ outStreamSpec = new COutFileStream;
+ outStream = outStreamSpec;
+ bool isOK = false;
+ UString realPath;
+ for (int i = 0; i < (1 << 16); i++)
+ {
+ if (archivePath.Temp)
+ {
+ if (i > 0)
+ {
+ wchar_t s[16];
+ ConvertUInt32ToString(i, s);
+ archivePath.TempPostfix = s;
+ }
+ realPath = archivePath.GetTempPath();
+ }
+ else
+ realPath = archivePath.GetFinalPath();
+ if (outStreamSpec->Create(realPath, false))
+ {
+ tempFiles.Paths.Add(realPath);
+ isOK = true;
+ break;
+ }
+ if (::GetLastError() != ERROR_FILE_EXISTS)
+ break;
+ if (!archivePath.Temp)
+ break;
+ }
+ if (!isOK)
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.FileName = realPath;
+ errorInfo.Message = L"Can not open file";
+ return E_FAIL;
+ }
+ }
+ }
+ else
+ {
+ if (stdOutMode)
+ return E_FAIL;
+ volStreamSpec = new COutMultiVolStream;
+ outStream = volStreamSpec;
+ volStreamSpec->Sizes = volumesSizes;
+ volStreamSpec->Prefix = archivePath.GetFinalPath() + UString(L".");
+ volStreamSpec->TempFiles = &tempFiles;
+ volStreamSpec->Init();
+
+ /*
+ updateCallbackSpec->VolumesSizes = volumesSizes;
+ updateCallbackSpec->VolName = archivePath.Prefix + archivePath.Name;
+ if (!archivePath.VolExtension.IsEmpty())
+ updateCallbackSpec->VolExt = UString(L'.') + archivePath.VolExtension;
+ */
+ }
+
+ RINOK(SetProperties(outArchive, compressionMethod.Properties));
+
+ if (sfxMode)
+ {
+ CInFileStream *sfxStreamSpec = new CInFileStream;
+ CMyComPtr<IInStream> sfxStream(sfxStreamSpec);
+ if (!sfxStreamSpec->Open(sfxModule))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"Can't open sfx module";
+ errorInfo.FileName = sfxModule;
+ return E_FAIL;
+ }
+
+ CMyComPtr<ISequentialOutStream> sfxOutStream;
+ COutFileStream *outStreamSpec = NULL;
+ if (volumesSizes.Size() == 0)
+ sfxOutStream = outStream;
+ else
+ {
+ outStreamSpec = new COutFileStream;
+ sfxOutStream = outStreamSpec;
+ UString realPath = archivePath.GetFinalPath();
+ if (!outStreamSpec->Create(realPath, false))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.FileName = realPath;
+ errorInfo.Message = L"Can not open file";
+ return E_FAIL;
+ }
+ }
+ RINOK(NCompress::CopyStream(sfxStream, sfxOutStream, NULL));
+ if (outStreamSpec)
+ {
+ RINOK(outStreamSpec->Close());
+ }
+ }
+
+ HRESULT result = outArchive->UpdateItems(outStream, updatePairs2.Size(), updateCallback);
+ callback->Finilize();
+ RINOK(result);
+ if (outStreamSpec)
+ result = outStreamSpec->Close();
+ else if (volStreamSpec)
+ result = volStreamSpec->Close();
+ return result;
+}
+
+HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
+ const CArc &arc,
+ CObjectVector<CArcItem> &arcItems)
+{
+ arcItems.Clear();
+ UInt32 numItems;
+ IInArchive *archive = arc.Archive;
+ RINOK(archive->GetNumberOfItems(&numItems));
+ arcItems.Reserve(numItems);
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ CArcItem ai;
+
+ RINOK(arc.GetItemPath(i, ai.Name));
+ RINOK(IsArchiveItemFolder(archive, i, ai.IsDir));
+ ai.Censored = censor.CheckPath(ai.Name, !ai.IsDir);
+ RINOK(arc.GetItemMTime(i, ai.MTime, ai.MTimeDefined));
+
+ {
+ CPropVariant prop;
+ RINOK(archive->GetProperty(i, kpidSize, &prop));
+ ai.SizeDefined = (prop.vt != VT_EMPTY);
+ if (ai.SizeDefined)
+ ai.Size = ConvertPropVariantToUInt64(prop);
+ }
+
+ {
+ CPropVariant prop;
+ RINOK(archive->GetProperty(i, kpidTimeType, &prop));
+ if (prop.vt == VT_UI4)
+ {
+ ai.TimeType = (int)(NFileTimeType::EEnum)prop.ulVal;
+ switch(ai.TimeType)
+ {
+ case NFileTimeType::kWindows:
+ case NFileTimeType::kUnix:
+ case NFileTimeType::kDOS:
+ break;
+ default:
+ return E_FAIL;
+ }
+ }
+ }
+
+ ai.IndexInServer = i;
+ arcItems.Add(ai);
+ }
+ return S_OK;
+}
+
+
+static HRESULT UpdateWithItemLists(
+ CCodecs *codecs,
+ CUpdateOptions &options,
+ IInArchive *archive,
+ const CObjectVector<CArcItem> &arcItems,
+ CDirItems &dirItems,
+ CTempFiles &tempFiles,
+ CUpdateErrorInfo &errorInfo,
+ IUpdateCallbackUI2 *callback)
+{
+ for(int i = 0; i < options.Commands.Size(); i++)
+ {
+ CUpdateArchiveCommand &command = options.Commands[i];
+ if (options.StdOutMode)
+ {
+ RINOK(callback->StartArchive(L"stdout", archive != 0));
+ }
+ else
+ {
+ RINOK(callback->StartArchive(command.ArchivePath.GetFinalPath(),
+ i == 0 && options.UpdateArchiveItself && archive != 0));
+ }
+
+ RINOK(Compress(
+ codecs,
+ command.ActionSet, archive,
+ options.MethodMode,
+ command.ArchivePath,
+ arcItems,
+ options.OpenShareForWrite,
+ options.StdInMode,
+ /* options.StdInFileName, */
+ options.StdOutMode,
+ dirItems,
+ options.SfxMode, options.SfxModule,
+ options.VolumesSizes,
+ tempFiles,
+ errorInfo, callback));
+
+ RINOK(callback->FinishArchive());
+ }
+ return S_OK;
+}
+
+#ifdef _WIN32
+class CCurrentDirRestorer
+{
+ UString m_CurrentDirectory;
+public:
+ CCurrentDirRestorer()
+ { NFile::NDirectory::MyGetCurrentDirectory(m_CurrentDirectory); }
+ ~CCurrentDirRestorer()
+ { RestoreDirectory();}
+ bool RestoreDirectory()
+ { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(m_CurrentDirectory)); }
+};
+#endif
+
+struct CEnumDirItemUpdateCallback: public IEnumDirItemCallback
+{
+ IUpdateCallbackUI2 *Callback;
+ HRESULT ScanProgress(UInt64 numFolders, UInt64 numFiles, const wchar_t *path)
+ {
+ return Callback->ScanProgress(numFolders, numFiles, path);
+ }
+};
+
+#ifdef _WIN32
+typedef ULONG (FAR PASCAL MY_MAPISENDDOCUMENTS)(
+ ULONG_PTR ulUIParam,
+ LPSTR lpszDelimChar,
+ LPSTR lpszFilePaths,
+ LPSTR lpszFileNames,
+ ULONG ulReserved
+);
+typedef MY_MAPISENDDOCUMENTS FAR *MY_LPMAPISENDDOCUMENTS;
+#endif
+
+HRESULT UpdateArchive(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
+ CUpdateOptions &options,
+ CUpdateErrorInfo &errorInfo,
+ IOpenCallbackUI *openCallback,
+ IUpdateCallbackUI2 *callback)
+{
+ if (options.StdOutMode && options.EMailMode)
+ return E_FAIL;
+
+ if (options.VolumesSizes.Size() > 0 && (options.EMailMode || options.SfxMode))
+ return E_NOTIMPL;
+
+ if (options.SfxMode)
+ {
+ CProperty property;
+ property.Name = L"rsfx";
+ property.Value = L"on";
+ options.MethodMode.Properties.Add(property);
+ if (options.SfxModule.IsEmpty())
+ {
+ errorInfo.Message = L"sfx file is not specified";
+ return E_FAIL;
+ }
+ UString name = options.SfxModule;
+ if (!NDirectory::MySearchPath(NULL, name, NULL, options.SfxModule))
+ {
+ errorInfo.Message = L"can't find specified sfx module";
+ return E_FAIL;
+ }
+ }
+
+ const UString archiveName = options.ArchivePath.GetFinalPath();
+
+ CArchiveLink archiveLink;
+ NFind::CFileInfoW archiveFileInfo;
+
+ if (archiveFileInfo.Find(archiveName))
+ {
+ if (archiveFileInfo.IsDir())
+ throw "there is no such archive";
+ if (options.VolumesSizes.Size() > 0)
+ return E_NOTIMPL;
+ CIntVector formatIndices;
+ if (options.MethodMode.FormatIndex >= 0)
+ formatIndices.Add(options.MethodMode.FormatIndex);
+ HRESULT result = archiveLink.Open2(codecs, formatIndices, false, NULL, archiveName, openCallback);
+ if (result == E_ABORT)
+ return result;
+ RINOK(callback->OpenResult(archiveName, result));
+ RINOK(result);
+ if (archiveLink.VolumePaths.Size() > 1)
+ {
+ errorInfo.SystemError = (DWORD)E_NOTIMPL;
+ errorInfo.Message = L"Updating for multivolume archives is not implemented";
+ return E_NOTIMPL;
+ }
+
+ CArc &arc = archiveLink.Arcs.Back();
+ arc.MTimeDefined = !archiveFileInfo.IsDevice;
+ arc.MTime = archiveFileInfo.MTime;
+ }
+ else
+ {
+ /*
+ if (archiveType.IsEmpty())
+ throw "type of archive is not specified";
+ */
+ }
+
+ CDirItems dirItems;
+ if (options.StdInMode)
+ {
+ CDirItem di;
+ di.Name = options.StdInFileName;
+ di.Size = (UInt64)(Int64)-1;
+ di.Attrib = 0;
+ NTime::GetCurUtcFileTime(di.MTime);
+ di.CTime = di.ATime = di.MTime;
+ dirItems.Items.Add(di);
+ }
+ else
+ {
+ bool needScanning = false;
+ for(int i = 0; i < options.Commands.Size(); i++)
+ if (options.Commands[i].ActionSet.NeedScanning())
+ needScanning = true;
+ if (needScanning)
+ {
+ CEnumDirItemUpdateCallback enumCallback;
+ enumCallback.Callback = callback;
+ RINOK(callback->StartScanning());
+ UStringVector errorPaths;
+ CRecordVector<DWORD> errorCodes;
+ HRESULT res = EnumerateItems(censor, dirItems, &enumCallback, errorPaths, errorCodes);
+ for (int i = 0; i < errorPaths.Size(); i++)
+ {
+ RINOK(callback->CanNotFindError(errorPaths[i], errorCodes[i]));
+ }
+ if (res != S_OK)
+ {
+ if (res != E_ABORT)
+ errorInfo.Message = L"Scanning error";
+ // errorInfo.FileName = errorPath;
+ return res;
+ }
+ RINOK(callback->FinishScanning());
+ }
+ }
+
+ UString tempDirPrefix;
+ bool usesTempDir = false;
+
+ #ifdef _WIN32
+ NDirectory::CTempDirectoryW tempDirectory;
+ if (options.EMailMode && options.EMailRemoveAfter)
+ {
+ tempDirectory.Create(kTempFolderPrefix);
+ tempDirPrefix = tempDirectory.GetPath();
+ NormalizeDirPathPrefix(tempDirPrefix);
+ usesTempDir = true;
+ }
+ #endif
+
+ CTempFiles tempFiles;
+
+ bool createTempFile = false;
+
+ bool thereIsInArchive = archiveLink.IsOpen;
+
+ if (!options.StdOutMode && options.UpdateArchiveItself)
+ {
+ CArchivePath &ap = options.Commands[0].ArchivePath;
+ ap = options.ArchivePath;
+ // if ((archive != 0 && !usesTempDir) || !options.WorkingDir.IsEmpty())
+ if ((thereIsInArchive || !options.WorkingDir.IsEmpty()) && !usesTempDir && options.VolumesSizes.Size() == 0)
+ {
+ createTempFile = true;
+ ap.Temp = true;
+ if (!options.WorkingDir.IsEmpty())
+ {
+ ap.TempPrefix = options.WorkingDir;
+ NormalizeDirPathPrefix(ap.TempPrefix);
+ }
+ }
+ }
+
+ for(int i = 0; i < options.Commands.Size(); i++)
+ {
+ CArchivePath &ap = options.Commands[i].ArchivePath;
+ if (usesTempDir)
+ {
+ // Check it
+ ap.Prefix = tempDirPrefix;
+ // ap.Temp = true;
+ // ap.TempPrefix = tempDirPrefix;
+ }
+ if (i > 0 || !createTempFile)
+ {
+ const UString &path = ap.GetFinalPath();
+ if (NFind::DoesFileOrDirExist(path))
+ {
+ errorInfo.SystemError = 0;
+ errorInfo.Message = L"File already exists";
+ errorInfo.FileName = path;
+ return E_FAIL;
+ }
+ }
+ }
+
+ CObjectVector<CArcItem> arcItems;
+ if (thereIsInArchive)
+ {
+ RINOK(EnumerateInArchiveItems(censor, archiveLink.Arcs.Back(), arcItems));
+ }
+
+ RINOK(UpdateWithItemLists(codecs, options,
+ thereIsInArchive ? archiveLink.GetArchive() : 0,
+ arcItems, dirItems,
+ tempFiles, errorInfo, callback));
+
+ if (thereIsInArchive)
+ {
+ RINOK(archiveLink.Close());
+ archiveLink.Release();
+ }
+
+ tempFiles.Paths.Clear();
+ if (createTempFile)
+ {
+ try
+ {
+ CArchivePath &ap = options.Commands[0].ArchivePath;
+ const UString &tempPath = ap.GetTempPath();
+ if (thereIsInArchive)
+ if (!NDirectory::DeleteFileAlways(archiveName))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"delete file error";
+ errorInfo.FileName = archiveName;
+ return E_FAIL;
+ }
+ if (!NDirectory::MyMoveFile(tempPath, archiveName))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"move file error";
+ errorInfo.FileName = tempPath;
+ errorInfo.FileName2 = archiveName;
+ return E_FAIL;
+ }
+ }
+ catch(...)
+ {
+ throw;
+ }
+ }
+
+ #ifdef _WIN32
+ if (options.EMailMode)
+ {
+ NDLL::CLibrary mapiLib;
+ if (!mapiLib.Load(TEXT("Mapi32.dll")))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"can not load Mapi32.dll";
+ return E_FAIL;
+ }
+ MY_LPMAPISENDDOCUMENTS fnSend = (MY_LPMAPISENDDOCUMENTS)
+ mapiLib.GetProcAddress("MAPISendDocuments");
+ if (fnSend == 0)
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"can not find MAPISendDocuments function";
+ return E_FAIL;
+ }
+ UStringVector fullPaths;
+ int i;
+ for(i = 0; i < options.Commands.Size(); i++)
+ {
+ CArchivePath &ap = options.Commands[i].ArchivePath;
+ UString arcPath;
+ if (!NFile::NDirectory::MyGetFullPathName(ap.GetFinalPath(), arcPath))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ return E_FAIL;
+ }
+ fullPaths.Add(arcPath);
+ }
+ CCurrentDirRestorer curDirRestorer;
+ for(i = 0; i < fullPaths.Size(); i++)
+ {
+ UString arcPath = fullPaths[i];
+ UString fileName = ExtractFileNameFromPath(arcPath);
+ AString path = GetAnsiString(arcPath);
+ AString name = GetAnsiString(fileName);
+ // Warning!!! MAPISendDocuments function changes Current directory
+ fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0);
+ }
+ }
+ #endif
+ return S_OK;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Update.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Update.h
new file mode 100644
index 000000000..731e9344f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/Update.h
@@ -0,0 +1,166 @@
+// Update.h
+
+#ifndef __UPDATE_H
+#define __UPDATE_H
+
+#include "Common/Wildcard.h"
+#include "Windows/FileFind.h"
+#include "../../Archive/IArchive.h"
+
+#include "UpdateAction.h"
+#include "ArchiveOpenCallback.h"
+#include "UpdateCallback.h"
+#include "Property.h"
+#include "LoadCodecs.h"
+
+struct CArchivePath
+{
+ UString Prefix; // path(folder) prefix including slash
+ UString Name; // base name
+ UString BaseExtension; // archive type extension or "exe" extension
+ UString VolExtension; // archive type extension for volumes
+
+ bool Temp;
+ UString TempPrefix; // path(folder) for temp location
+ UString TempPostfix;
+
+ CArchivePath(): Temp(false) {};
+
+ void ParseFromPath(const UString &path)
+ {
+ SplitPathToParts(path, Prefix, Name);
+ if (Name.IsEmpty())
+ return;
+ int dotPos = Name.ReverseFind(L'.');
+ if (dotPos <= 0)
+ return;
+ if (dotPos == Name.Length() - 1)
+ {
+ Name = Name.Left(dotPos);
+ BaseExtension.Empty();
+ return;
+ }
+ if (BaseExtension.CompareNoCase(Name.Mid(dotPos + 1)) == 0)
+ {
+ BaseExtension = Name.Mid(dotPos + 1);
+ Name = Name.Left(dotPos);
+ }
+ else
+ BaseExtension.Empty();
+ }
+
+ UString GetPathWithoutExt() const
+ {
+ return Prefix + Name;
+ }
+
+ UString GetFinalPath() const
+ {
+ UString path = GetPathWithoutExt();
+ if (!BaseExtension.IsEmpty())
+ path += UString(L'.') + BaseExtension;
+ return path;
+ }
+
+
+ UString GetTempPath() const
+ {
+ UString path = TempPrefix + Name;
+ if (!BaseExtension.IsEmpty())
+ path += UString(L'.') + BaseExtension;
+ path += L".tmp";
+ path += TempPostfix;
+ return path;
+ }
+};
+
+struct CUpdateArchiveCommand
+{
+ UString UserArchivePath;
+ CArchivePath ArchivePath;
+ NUpdateArchive::CActionSet ActionSet;
+};
+
+struct CCompressionMethodMode
+{
+ int FormatIndex;
+ CObjectVector<CProperty> Properties;
+ CCompressionMethodMode(): FormatIndex(-1) {}
+};
+
+struct CUpdateOptions
+{
+ CCompressionMethodMode MethodMode;
+
+ CObjectVector<CUpdateArchiveCommand> Commands;
+ bool UpdateArchiveItself;
+ CArchivePath ArchivePath;
+
+ bool SfxMode;
+ UString SfxModule;
+
+ bool OpenShareForWrite;
+
+ bool StdInMode;
+ UString StdInFileName;
+ bool StdOutMode;
+
+ bool EMailMode;
+ bool EMailRemoveAfter;
+ UString EMailAddress;
+
+ UString WorkingDir;
+
+ bool Init(const CCodecs *codecs, const CIntVector &formatIndices, const UString &arcPath);
+
+ CUpdateOptions():
+ UpdateArchiveItself(true),
+ SfxMode(false),
+ OpenShareForWrite(false),
+ StdInMode(false),
+ StdOutMode(false),
+ EMailMode(false),
+ EMailRemoveAfter(false)
+ {}
+ CRecordVector<UInt64> VolumesSizes;
+};
+
+struct CErrorInfo
+{
+ DWORD SystemError;
+ UString FileName;
+ UString FileName2;
+ UString Message;
+ // UStringVector ErrorPaths;
+ // CRecordVector<DWORD> ErrorCodes;
+ CErrorInfo(): SystemError(0) {};
+};
+
+struct CUpdateErrorInfo: public CErrorInfo
+{
+};
+
+#define INTERFACE_IUpdateCallbackUI2(x) \
+ INTERFACE_IUpdateCallbackUI(x) \
+ virtual HRESULT OpenResult(const wchar_t *name, HRESULT result) x; \
+ virtual HRESULT StartScanning() x; \
+ virtual HRESULT ScanProgress(UInt64 numFolders, UInt64 numFiles, const wchar_t *path) x; \
+ virtual HRESULT CanNotFindError(const wchar_t *name, DWORD systemError) x; \
+ virtual HRESULT FinishScanning() x; \
+ virtual HRESULT StartArchive(const wchar_t *name, bool updating) x; \
+ virtual HRESULT FinishArchive() x; \
+
+struct IUpdateCallbackUI2: public IUpdateCallbackUI
+{
+ INTERFACE_IUpdateCallbackUI2(=0)
+};
+
+HRESULT UpdateArchive(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
+ CUpdateOptions &options,
+ CUpdateErrorInfo &errorInfo,
+ IOpenCallbackUI *openCallback,
+ IUpdateCallbackUI2 *callback);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateAction.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateAction.cpp
new file mode 100644
index 000000000..845384fbb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateAction.cpp
@@ -0,0 +1,64 @@
+// UpdateAction.cpp
+
+#include "StdAfx.h"
+
+#include "UpdateAction.h"
+
+namespace NUpdateArchive {
+
+const CActionSet kAddActionSet =
+{
+ NPairAction::kCopy,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCompress,
+ NPairAction::kCompress,
+ NPairAction::kCompress,
+ NPairAction::kCompress
+};
+
+const CActionSet kUpdateActionSet =
+{
+ NPairAction::kCopy,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress
+};
+
+const CActionSet kFreshActionSet =
+{
+ NPairAction::kCopy,
+ NPairAction::kCopy,
+ NPairAction::kIgnore,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress
+};
+
+const CActionSet kSynchronizeActionSet =
+{
+ NPairAction::kCopy,
+ NPairAction::kIgnore,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+};
+
+const CActionSet kDeleteActionSet =
+{
+ NPairAction::kCopy,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore
+};
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateAction.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateAction.h
new file mode 100644
index 000000000..7da5ff2eb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateAction.h
@@ -0,0 +1,57 @@
+// UpdateAction.h
+
+#ifndef __UPDATE_ACTION_H
+#define __UPDATE_ACTION_H
+
+namespace NUpdateArchive {
+
+ namespace NPairState
+ {
+ const int kNumValues = 7;
+ enum EEnum
+ {
+ kNotMasked = 0,
+ kOnlyInArchive,
+ kOnlyOnDisk,
+ kNewInArchive,
+ kOldInArchive,
+ kSameFiles,
+ kUnknowNewerFiles
+ };
+ }
+ namespace NPairAction
+ {
+ enum EEnum
+ {
+ kIgnore = 0,
+ kCopy,
+ kCompress,
+ kCompressAsAnti
+ };
+ }
+ struct CActionSet
+ {
+ NPairAction::EEnum StateActions[NPairState::kNumValues];
+ bool NeedScanning() const
+ {
+ int i;
+ for (i = 0; i < NPairState::kNumValues; i++)
+ if (StateActions[i] == NPairAction::kCompress)
+ return true;
+ for (i = 1; i < NPairState::kNumValues; i++)
+ if (StateActions[i] != NPairAction::kIgnore)
+ return true;
+ return false;
+ }
+ };
+ extern const CActionSet kAddActionSet;
+ extern const CActionSet kUpdateActionSet;
+ extern const CActionSet kFreshActionSet;
+ extern const CActionSet kSynchronizeActionSet;
+ extern const CActionSet kDeleteActionSet;
+};
+
+
+#endif
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateCallback.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateCallback.cpp
new file mode 100644
index 000000000..0f229058c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateCallback.cpp
@@ -0,0 +1,249 @@
+// UpdateCallback.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/Defs.h"
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../Common/FileStreams.h"
+
+#include "UpdateCallback.h"
+
+using namespace NWindows;
+
+CArchiveUpdateCallback::CArchiveUpdateCallback():
+ Callback(0),
+ ShareForWrite(false),
+ StdInMode(false),
+ DirItems(0),
+ ArcItems(0),
+ UpdatePairs(0),
+ NewNames(0)
+ {}
+
+
+STDMETHODIMP CArchiveUpdateCallback::SetTotal(UInt64 size)
+{
+ COM_TRY_BEGIN
+ return Callback->SetTotal(size);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const UInt64 *completeValue)
+{
+ COM_TRY_BEGIN
+ return Callback->SetCompleted(completeValue);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ COM_TRY_BEGIN
+ return Callback->SetRatioInfo(inSize, outSize);
+ COM_TRY_END
+}
+
+
+/*
+STATPROPSTG kProperties[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidIsAnti, VT_BOOL}
+};
+
+STDMETHODIMP CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG **)
+{
+ return CStatPropEnumerator::CreateEnumerator(kProperties, sizeof(kProperties) / sizeof(kProperties[0]), enumerator);
+}
+*/
+
+STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index,
+ Int32 *newData, Int32 *newProps, UInt32 *indexInArchive)
+{
+ COM_TRY_BEGIN
+ RINOK(Callback->CheckBreak());
+ const CUpdatePair2 &up = (*UpdatePairs)[index];
+ if (newData != NULL) *newData = BoolToInt(up.NewData);
+ if (newProps != NULL) *newProps = BoolToInt(up.NewProps);
+ if (indexInArchive != NULL)
+ {
+ *indexInArchive = (UInt32)-1;
+ if (up.ExistInArchive())
+ *indexInArchive = (ArcItems == 0) ? up.ArcIndex : (*ArcItems)[up.ArcIndex].IndexInServer;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ const CUpdatePair2 &up = (*UpdatePairs)[index];
+ NWindows::NCOM::CPropVariant prop;
+
+ if (propID == kpidIsAnti)
+ {
+ prop = up.IsAnti;
+ prop.Detach(value);
+ return S_OK;
+ }
+
+ if (up.IsAnti)
+ {
+ switch(propID)
+ {
+ case kpidIsDir:
+ case kpidPath:
+ break;
+ case kpidSize:
+ prop = (UInt64)0;
+ prop.Detach(value);
+ return S_OK;
+ default:
+ prop.Detach(value);
+ return S_OK;
+ }
+ }
+
+ if (up.ExistOnDisk())
+ {
+ const CDirItem &di = DirItems->Items[up.DirIndex];
+ switch(propID)
+ {
+ case kpidPath: prop = DirItems->GetLogPath(up.DirIndex); break;
+ case kpidIsDir: prop = di.IsDir(); break;
+ case kpidSize: prop = di.Size; break;
+ case kpidAttrib: prop = di.Attrib; break;
+ case kpidCTime: prop = di.CTime; break;
+ case kpidATime: prop = di.ATime; break;
+ case kpidMTime: prop = di.MTime; break;
+ }
+ }
+ else
+ {
+ if (propID == kpidPath)
+ {
+ if (up.NewNameIndex >= 0)
+ {
+ prop = (*NewNames)[up.NewNameIndex];
+ prop.Detach(value);
+ return S_OK;
+ }
+ }
+ if (up.ExistInArchive() && Archive)
+ {
+ UInt32 indexInArchive;
+ if (ArcItems == 0)
+ indexInArchive = up.ArcIndex;
+ else
+ indexInArchive = (*ArcItems)[up.ArcIndex].IndexInServer;
+ return Archive->GetProperty(indexInArchive, propID, value);
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
+{
+ COM_TRY_BEGIN
+ const CUpdatePair2 &up = (*UpdatePairs)[index];
+ if (!up.NewData)
+ return E_FAIL;
+
+ RINOK(Callback->CheckBreak());
+ RINOK(Callback->Finilize());
+
+ if (up.IsAnti)
+ {
+ return Callback->GetStream((*ArcItems)[up.ArcIndex].Name, true);
+ }
+ const CDirItem &di = DirItems->Items[up.DirIndex];
+ RINOK(Callback->GetStream(DirItems->GetLogPath(up.DirIndex), false));
+
+ if (di.IsDir())
+ return S_OK;
+
+ if (StdInMode)
+ {
+ CStdInFileStream *inStreamSpec = new CStdInFileStream;
+ CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
+ *inStream = inStreamLoc.Detach();
+ }
+ else
+ {
+ CInFileStream *inStreamSpec = new CInFileStream;
+ CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
+ const UString path = DirItems->GetPhyPath(up.DirIndex);
+ if (!inStreamSpec->OpenShared(path, ShareForWrite))
+ {
+ return Callback->OpenFileError(path, ::GetLastError());
+ }
+ *inStream = inStreamLoc.Detach();
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::SetOperationResult(Int32 operationResult)
+{
+ COM_TRY_BEGIN
+ return Callback->SetOperationResult(operationResult);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size)
+{
+ if (VolumesSizes.Size() == 0)
+ return S_FALSE;
+ if (index >= (UInt32)VolumesSizes.Size())
+ index = VolumesSizes.Size() - 1;
+ *size = VolumesSizes[index];
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream)
+{
+ COM_TRY_BEGIN
+ wchar_t temp[16];
+ ConvertUInt32ToString(index + 1, temp);
+ UString res = temp;
+ while (res.Length() < 2)
+ res = UString(L'0') + res;
+ UString fileName = VolName;
+ fileName += L'.';
+ fileName += res;
+ fileName += VolExt;
+ COutFileStream *streamSpec = new COutFileStream;
+ CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);
+ if (!streamSpec->Create(fileName, false))
+ return ::GetLastError();
+ *volumeStream = streamLoc.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ COM_TRY_BEGIN
+ return Callback->CryptoGetTextPassword2(passwordIsDefined, password);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword(BSTR *password)
+{
+ COM_TRY_BEGIN
+ return Callback->CryptoGetTextPassword(password);
+ COM_TRY_END
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateCallback.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateCallback.h
new file mode 100644
index 000000000..7618574ca
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateCallback.h
@@ -0,0 +1,76 @@
+// UpdateCallback.h
+
+#ifndef __UPDATECALLBACK_H
+#define __UPDATECALLBACK_H
+
+#include "Common/MyCom.h"
+#include "Common/MyString.h"
+
+#include "../../IPassword.h"
+#include "../../ICoder.h"
+
+#include "../Common/UpdatePair.h"
+#include "../Common/UpdateProduce.h"
+
+#define INTERFACE_IUpdateCallbackUI(x) \
+ virtual HRESULT SetTotal(UInt64 size) x; \
+ virtual HRESULT SetCompleted(const UInt64 *completeValue) x; \
+ virtual HRESULT SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) x; \
+ virtual HRESULT CheckBreak() x; \
+ virtual HRESULT Finilize() x; \
+ virtual HRESULT SetNumFiles(UInt64 numFiles) x; \
+ virtual HRESULT GetStream(const wchar_t *name, bool isAnti) x; \
+ virtual HRESULT OpenFileError(const wchar_t *name, DWORD systemError) x; \
+ virtual HRESULT SetOperationResult(Int32 operationResult) x; \
+ virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \
+ virtual HRESULT CryptoGetTextPassword(BSTR *password) x;
+
+ // virtual HRESULT ShowDeleteFile(const wchar_t *name) x;
+ // virtual HRESULT CloseProgress() { return S_OK; };
+
+struct IUpdateCallbackUI
+{
+ virtual ~IUpdateCallbackUI() {}
+ INTERFACE_IUpdateCallbackUI(=0)
+};
+
+class CArchiveUpdateCallback:
+ public IArchiveUpdateCallback2,
+ public ICryptoGetTextPassword2,
+ public ICryptoGetTextPassword,
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP4(
+ IArchiveUpdateCallback2,
+ ICryptoGetTextPassword2,
+ ICryptoGetTextPassword,
+ ICompressProgressInfo)
+
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+
+ INTERFACE_IArchiveUpdateCallback2(;)
+
+ STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+
+public:
+ CRecordVector<UInt64> VolumesSizes;
+ UString VolName;
+ UString VolExt;
+
+ IUpdateCallbackUI *Callback;
+
+ bool ShareForWrite;
+ bool StdInMode;
+ const CDirItems *DirItems;
+ const CObjectVector<CArcItem> *ArcItems;
+ const CRecordVector<CUpdatePair2> *UpdatePairs;
+ const UStringVector *NewNames;
+ CMyComPtr<IInArchive> Archive;
+
+ CArchiveUpdateCallback();
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdatePair.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdatePair.cpp
new file mode 100644
index 000000000..a43a9e770
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdatePair.cpp
@@ -0,0 +1,158 @@
+// UpdatePair.cpp
+
+#include "StdAfx.h"
+
+#include <time.h>
+
+#include "Common/Defs.h"
+#include "Common/Wildcard.h"
+
+#include "Windows/Time.h"
+
+#include "SortUtils.h"
+#include "UpdatePair.h"
+
+using namespace NWindows;
+using namespace NTime;
+
+static int MyCompareTime(NFileTimeType::EEnum fileTimeType, const FILETIME &time1, const FILETIME &time2)
+{
+ switch(fileTimeType)
+ {
+ case NFileTimeType::kWindows:
+ return ::CompareFileTime(&time1, &time2);
+ case NFileTimeType::kUnix:
+ {
+ UInt32 unixTime1, unixTime2;
+ FileTimeToUnixTime(time1, unixTime1);
+ FileTimeToUnixTime(time2, unixTime2);
+ return MyCompare(unixTime1, unixTime2);
+ }
+ case NFileTimeType::kDOS:
+ {
+ UInt32 dosTime1, dosTime2;
+ FileTimeToDosTime(time1, dosTime1);
+ FileTimeToDosTime(time2, dosTime2);
+ return MyCompare(dosTime1, dosTime2);
+ }
+ }
+ throw 4191618;
+}
+
+static const wchar_t *kDuplicateFileNameMessage = L"Duplicate filename:";
+static const wchar_t *kNotCensoredCollisionMessaged = L"Internal file name collision (file on disk, file in archive):";
+
+static void ThrowError(const UString &message, const UString &s1, const UString &s2)
+{
+ UString m = message;
+ m += L'\n';
+ m += s1;
+ m += L'\n';
+ m += s2;
+ throw m;
+}
+
+static void TestDuplicateString(const UStringVector &strings, const CIntVector &indices)
+{
+ for(int i = 0; i + 1 < indices.Size(); i++)
+ if (CompareFileNames(strings[indices[i]], strings[indices[i + 1]]) == 0)
+ ThrowError(kDuplicateFileNameMessage, strings[indices[i]], strings[indices[i + 1]]);
+}
+
+void GetUpdatePairInfoList(
+ const CDirItems &dirItems,
+ const CObjectVector<CArcItem> &arcItems,
+ NFileTimeType::EEnum fileTimeType,
+ CRecordVector<CUpdatePair> &updatePairs)
+{
+ CIntVector dirIndices, arcIndices;
+
+ int numDirItems = dirItems.Items.Size();
+ int numArcItems = arcItems.Size();
+
+
+ {
+ UStringVector arcNames;
+ arcNames.Reserve(numArcItems);
+ for (int i = 0; i < numArcItems; i++)
+ arcNames.Add(arcItems[i].Name);
+ SortFileNames(arcNames, arcIndices);
+ TestDuplicateString(arcNames, arcIndices);
+ }
+
+ UStringVector dirNames;
+ {
+ dirNames.Reserve(numDirItems);
+ for (int i = 0; i < numDirItems; i++)
+ dirNames.Add(dirItems.GetLogPath(i));
+ SortFileNames(dirNames, dirIndices);
+ TestDuplicateString(dirNames, dirIndices);
+ }
+
+ int dirIndex = 0, arcIndex = 0;
+ while (dirIndex < numDirItems && arcIndex < numArcItems)
+ {
+ CUpdatePair pair;
+ int dirIndex2 = dirIndices[dirIndex];
+ int arcIndex2 = arcIndices[arcIndex];
+ const CDirItem &di = dirItems.Items[dirIndex2];
+ const CArcItem &ai = arcItems[arcIndex2];
+ int compareResult = CompareFileNames(dirNames[dirIndex2], ai.Name);
+ if (compareResult < 0)
+ {
+ pair.State = NUpdateArchive::NPairState::kOnlyOnDisk;
+ pair.DirIndex = dirIndex2;
+ dirIndex++;
+ }
+ else if (compareResult > 0)
+ {
+ pair.State = ai.Censored ?
+ NUpdateArchive::NPairState::kOnlyInArchive:
+ NUpdateArchive::NPairState::kNotMasked;
+ pair.ArcIndex = arcIndex2;
+ arcIndex++;
+ }
+ else
+ {
+ if (!ai.Censored)
+ ThrowError(kNotCensoredCollisionMessaged, dirNames[dirIndex2], ai.Name);
+ pair.DirIndex = dirIndex2;
+ pair.ArcIndex = arcIndex2;
+ switch (ai.MTimeDefined ? MyCompareTime(
+ ai.TimeType != - 1 ? (NFileTimeType::EEnum)ai.TimeType : fileTimeType,
+ di.MTime, ai.MTime): 0)
+ {
+ case -1: pair.State = NUpdateArchive::NPairState::kNewInArchive; break;
+ case 1: pair.State = NUpdateArchive::NPairState::kOldInArchive; break;
+ default:
+ pair.State = (ai.SizeDefined && di.Size == ai.Size) ?
+ NUpdateArchive::NPairState::kSameFiles :
+ NUpdateArchive::NPairState::kUnknowNewerFiles;
+ }
+ dirIndex++;
+ arcIndex++;
+ }
+ updatePairs.Add(pair);
+ }
+
+ for (; dirIndex < numDirItems; dirIndex++)
+ {
+ CUpdatePair pair;
+ pair.State = NUpdateArchive::NPairState::kOnlyOnDisk;
+ pair.DirIndex = dirIndices[dirIndex];
+ updatePairs.Add(pair);
+ }
+
+ for (; arcIndex < numArcItems; arcIndex++)
+ {
+ CUpdatePair pair;
+ int arcIndex2 = arcIndices[arcIndex];
+ pair.State = arcItems[arcIndex2].Censored ?
+ NUpdateArchive::NPairState::kOnlyInArchive:
+ NUpdateArchive::NPairState::kNotMasked;
+ pair.ArcIndex = arcIndex2;
+ updatePairs.Add(pair);
+ }
+
+ updatePairs.ReserveDown();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdatePair.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdatePair.h
new file mode 100644
index 000000000..3a332649c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdatePair.h
@@ -0,0 +1,25 @@
+// UpdatePair.h
+
+#ifndef __UPDATE_PAIR_H
+#define __UPDATE_PAIR_H
+
+#include "DirItem.h"
+#include "UpdateAction.h"
+
+#include "../../Archive/IArchive.h"
+
+struct CUpdatePair
+{
+ NUpdateArchive::NPairState::EEnum State;
+ int ArcIndex;
+ int DirIndex;
+ CUpdatePair(): ArcIndex(-1), DirIndex(-1) {}
+};
+
+void GetUpdatePairInfoList(
+ const CDirItems &dirItems,
+ const CObjectVector<CArcItem> &arcItems,
+ NFileTimeType::EEnum fileTimeType,
+ CRecordVector<CUpdatePair> &updatePairs);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateProduce.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateProduce.cpp
new file mode 100644
index 000000000..c21db3b2a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateProduce.cpp
@@ -0,0 +1,58 @@
+// UpdateProduce.cpp
+
+#include "StdAfx.h"
+
+#include "UpdateProduce.h"
+
+using namespace NUpdateArchive;
+
+static const char *kUpdateActionSetCollision = "Internal collision in update action set";
+
+void UpdateProduce(
+ const CRecordVector<CUpdatePair> &updatePairs,
+ const CActionSet &actionSet,
+ CRecordVector<CUpdatePair2> &operationChain,
+ IUpdateProduceCallback *callback)
+{
+ for (int i = 0; i < updatePairs.Size(); i++)
+ {
+ const CUpdatePair &pair = updatePairs[i];
+
+ CUpdatePair2 up2;
+ up2.IsAnti = false;
+ up2.DirIndex = pair.DirIndex;
+ up2.ArcIndex = pair.ArcIndex;
+ up2.NewData = up2.NewProps = true;
+
+ switch(actionSet.StateActions[pair.State])
+ {
+ case NPairAction::kIgnore:
+ /*
+ if (pair.State != NPairState::kOnlyOnDisk)
+ IgnoreArchiveItem(m_ArchiveItems[pair.ArcIndex]);
+ // cout << "deleting";
+ */
+ if (callback)
+ callback->ShowDeleteFile(pair.ArcIndex);
+ continue;
+
+ case NPairAction::kCopy:
+ if (pair.State == NPairState::kOnlyOnDisk)
+ throw kUpdateActionSetCollision;
+ up2.NewData = up2.NewProps = false;
+ break;
+
+ case NPairAction::kCompress:
+ if (pair.State == NPairState::kOnlyInArchive ||
+ pair.State == NPairState::kNotMasked)
+ throw kUpdateActionSetCollision;
+ break;
+
+ case NPairAction::kCompressAsAnti:
+ up2.IsAnti = true;
+ break;
+ }
+ operationChain.Add(up2);
+ }
+ operationChain.ReserveDown();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateProduce.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateProduce.h
new file mode 100644
index 000000000..66b6e95b7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/UpdateProduce.h
@@ -0,0 +1,36 @@
+// UpdateProduce.h
+
+#ifndef __UPDATE_PRODUCE_H
+#define __UPDATE_PRODUCE_H
+
+#include "UpdatePair.h"
+
+struct CUpdatePair2
+{
+ bool NewData;
+ bool NewProps;
+ bool IsAnti;
+
+ int DirIndex;
+ int ArcIndex;
+ int NewNameIndex;
+
+ bool ExistOnDisk() const { return DirIndex != -1; }
+ bool ExistInArchive() const { return ArcIndex != -1; }
+
+ CUpdatePair2(): IsAnti(false), DirIndex(-1), ArcIndex(-1), NewNameIndex(-1) {}
+};
+
+struct IUpdateProduceCallback
+{
+ virtual ~IUpdateProduceCallback() {}
+ virtual HRESULT ShowDeleteFile(int arcIndex) = 0;
+};
+
+void UpdateProduce(
+ const CRecordVector<CUpdatePair> &updatePairs,
+ const NUpdateArchive::CActionSet &actionSet,
+ CRecordVector<CUpdatePair2> &operationChain,
+ IUpdateProduceCallback *callback);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/WorkDir.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/WorkDir.cpp
new file mode 100644
index 000000000..ea5dfef43
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/WorkDir.cpp
@@ -0,0 +1,69 @@
+// WorkDir.cpp
+
+#include "StdAfx.h"
+
+#include "WorkDir.h"
+
+#include "Common/StringConvert.h"
+#include "Common/Wildcard.h"
+
+#include "Windows/FileName.h"
+#include "Windows/FileDir.h"
+
+#if _WIN32
+static inline UINT GetCurrentCodePage()
+ { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NName;
+
+UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
+{
+ NWorkDir::NMode::EEnum mode = workDirInfo.Mode;
+ if (workDirInfo.ForRemovableOnly)
+ {
+ mode = NWorkDir::NMode::kCurrent;
+ UString prefix = path.Left(3);
+ if (prefix[1] == L':' && prefix[2] == WCHAR_PATH_SEPARATOR)
+ {
+ UINT driveType = GetDriveType(GetSystemString(prefix, GetCurrentCodePage()));
+ if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE)
+ mode = workDirInfo.Mode;
+ }
+ /*
+ CParsedPath parsedPath;
+ parsedPath.ParsePath(archiveName);
+ UINT driveType = GetDriveType(parsedPath.Prefix);
+ if ((driveType != DRIVE_CDROM) && (driveType != DRIVE_REMOVABLE))
+ mode = NZipSettings::NWorkDir::NMode::kCurrent;
+ */
+ }
+ switch(mode)
+ {
+ case NWorkDir::NMode::kCurrent:
+ {
+ return ExtractDirPrefixFromPath(path);
+ }
+ case NWorkDir::NMode::kSpecified:
+ {
+ UString tempDir = workDirInfo.Path;
+ NormalizeDirPathPrefix(tempDir);
+ return tempDir;
+ }
+ default:
+ {
+ UString tempDir;
+ if(!NFile::NDirectory::MyGetTempPath(tempDir))
+ throw 141717;
+ return tempDir;
+ }
+ }
+}
+#else
+UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
+{
+ return L"."; // FIXME
+}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/WorkDir.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/WorkDir.h
new file mode 100644
index 000000000..0643d67a4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/WorkDir.h
@@ -0,0 +1,10 @@
+// WorkDir.h
+
+#ifndef __WORKDIR_H
+#define __WORKDIR_H
+
+#include "ZipRegistry.h"
+
+UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ZipRegistry.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ZipRegistry.cpp
new file mode 100644
index 000000000..16df878fb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ZipRegistry.cpp
@@ -0,0 +1,417 @@
+// ZipRegistry.cpp
+
+#include "StdAfx.h"
+
+#include "ZipRegistry.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Synchronization.h"
+#include "Windows/Registry.h"
+
+#include "Windows/FileDir.h"
+
+using namespace NWindows;
+using namespace NRegistry;
+
+static const TCHAR *kCUBasePath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP");
+
+static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection;
+
+//////////////////////
+// ExtractionInfo
+
+static const TCHAR *kExtractionKeyName = TEXT("Extraction");
+
+static const TCHAR *kExtractionPathHistoryKeyName = TEXT("PathHistory");
+static const TCHAR *kExtractionExtractModeValueName = TEXT("ExtarctMode");
+static const TCHAR *kExtractionOverwriteModeValueName = TEXT("OverwriteMode");
+static const TCHAR *kExtractionShowPasswordValueName = TEXT("ShowPassword");
+
+static CSysString GetKeyPath(const CSysString &path)
+{
+ return CSysString(kCUBasePath) + CSysString(CHAR_PATH_SEPARATOR) + path;
+}
+
+void SaveExtractionInfo(const NExtract::CInfo &info)
+{
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey extractionKey;
+ extractionKey.Create(HKEY_CURRENT_USER, GetKeyPath(kExtractionKeyName));
+ extractionKey.RecurseDeleteKey(kExtractionPathHistoryKeyName);
+ {
+ CKey pathHistoryKey;
+ pathHistoryKey.Create(extractionKey, kExtractionPathHistoryKeyName);
+ for(int i = 0; i < info.Paths.Size(); i++)
+ {
+ wchar_t numberString[16];
+ ConvertUInt32ToString(i, numberString);
+ pathHistoryKey.SetValue(numberString, info.Paths[i]);
+ }
+ }
+ extractionKey.SetValue(kExtractionExtractModeValueName, UInt32(info.PathMode));
+ extractionKey.SetValue(kExtractionOverwriteModeValueName, UInt32(info.OverwriteMode));
+ extractionKey.SetValue(kExtractionShowPasswordValueName, info.ShowPassword);
+}
+
+void ReadExtractionInfo(NExtract::CInfo &info)
+{
+ info.Paths.Clear();
+ info.PathMode = NExtract::NPathMode::kCurrentPathnames;
+ info.OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
+ info.ShowPassword = false;
+
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey extractionKey;
+ if(extractionKey.Open(HKEY_CURRENT_USER, GetKeyPath(kExtractionKeyName), KEY_READ) != ERROR_SUCCESS)
+ return;
+
+ {
+ CKey pathHistoryKey;
+ if(pathHistoryKey.Open(extractionKey, kExtractionPathHistoryKeyName, KEY_READ) ==
+ ERROR_SUCCESS)
+ {
+ for (;;)
+ {
+ wchar_t numberString[16];
+ ConvertUInt32ToString(info.Paths.Size(), numberString);
+ UString path;
+ if (pathHistoryKey.QueryValue(numberString, path) != ERROR_SUCCESS)
+ break;
+ info.Paths.Add(path);
+ }
+ }
+ }
+ UInt32 extractModeIndex;
+ if (extractionKey.QueryValue(kExtractionExtractModeValueName, extractModeIndex) == ERROR_SUCCESS)
+ {
+ switch (extractModeIndex)
+ {
+ case NExtract::NPathMode::kFullPathnames:
+ case NExtract::NPathMode::kCurrentPathnames:
+ case NExtract::NPathMode::kNoPathnames:
+ info.PathMode = NExtract::NPathMode::EEnum(extractModeIndex);
+ break;
+ }
+ }
+ UInt32 overwriteModeIndex;
+ if (extractionKey.QueryValue(kExtractionOverwriteModeValueName, overwriteModeIndex) == ERROR_SUCCESS)
+ {
+ switch (overwriteModeIndex)
+ {
+ case NExtract::NOverwriteMode::kAskBefore:
+ case NExtract::NOverwriteMode::kWithoutPrompt:
+ case NExtract::NOverwriteMode::kSkipExisting:
+ case NExtract::NOverwriteMode::kAutoRename:
+ case NExtract::NOverwriteMode::kAutoRenameExisting:
+ info.OverwriteMode = NExtract::NOverwriteMode::EEnum(overwriteModeIndex);
+ break;
+ }
+ }
+ if (extractionKey.QueryValue(kExtractionShowPasswordValueName,
+ info.ShowPassword) != ERROR_SUCCESS)
+ info.ShowPassword = false;
+}
+
+///////////////////////////////////
+// CompressionInfo
+
+static const TCHAR *kCompressionKeyName = TEXT("Compression");
+
+static const TCHAR *kCompressionHistoryArchivesKeyName = TEXT("ArcHistory");
+static const TCHAR *kCompressionLevelValueName = TEXT("Level");
+static const TCHAR *kCompressionLastFormatValueName = TEXT("Archiver");
+static const TCHAR *kCompressionShowPasswordValueName = TEXT("ShowPassword");
+static const TCHAR *kCompressionEncryptHeadersValueName = TEXT("EncryptHeaders");
+
+static const TCHAR *kCompressionOptionsKeyName = TEXT("Options");
+// static const TCHAR *kSolid = TEXT("Solid");
+// static const TCHAR *kMultiThread = TEXT("Multithread");
+
+static const WCHAR *kCompressionOptions = L"Options";
+static const TCHAR *kCompressionLevel = TEXT("Level");
+static const WCHAR *kCompressionMethod = L"Method";
+static const WCHAR *kEncryptionMethod = L"EncryptionMethod";
+static const TCHAR *kCompressionDictionary = TEXT("Dictionary");
+static const TCHAR *kCompressionOrder = TEXT("Order");
+static const TCHAR *kCompressionNumThreads = TEXT("NumThreads");
+static const TCHAR *kCompressionBlockSize = TEXT("BlockSize");
+
+
+static void SetRegString(CKey &key, const WCHAR *name, const UString &value)
+{
+ if (value.IsEmpty())
+ key.DeleteValue(name);
+ else
+ key.SetValue(name, value);
+}
+
+static void SetRegUInt32(CKey &key, const TCHAR *name, UInt32 value)
+{
+ if (value == (UInt32)-1)
+ key.DeleteValue(name);
+ else
+ key.SetValue(name, value);
+}
+
+static void GetRegString(CKey &key, const WCHAR *name, UString &value)
+{
+ if (key.QueryValue(name, value) != ERROR_SUCCESS)
+ value.Empty();
+}
+
+static void GetRegUInt32(CKey &key, const TCHAR *name, UInt32 &value)
+{
+ if (key.QueryValue(name, value) != ERROR_SUCCESS)
+ value = UInt32(-1);
+}
+
+void SaveCompressionInfo(const NCompression::CInfo &info)
+{
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+
+ CKey compressionKey;
+ compressionKey.Create(HKEY_CURRENT_USER, GetKeyPath(kCompressionKeyName));
+ compressionKey.RecurseDeleteKey(kCompressionHistoryArchivesKeyName);
+ {
+ CKey historyArchivesKey;
+ historyArchivesKey.Create(compressionKey, kCompressionHistoryArchivesKeyName);
+ for(int i = 0; i < info.HistoryArchives.Size(); i++)
+ {
+ wchar_t numberString[16];
+ ConvertUInt32ToString(i, numberString);
+ historyArchivesKey.SetValue(numberString, info.HistoryArchives[i]);
+ }
+ }
+
+ // compressionKey.SetValue(kSolid, info.Solid);
+ // compressionKey.SetValue(kMultiThread, info.MultiThread);
+ compressionKey.RecurseDeleteKey(kCompressionOptionsKeyName);
+ {
+ CKey optionsKey;
+ optionsKey.Create(compressionKey, kCompressionOptionsKeyName);
+ for(int i = 0; i < info.FormatOptionsVector.Size(); i++)
+ {
+ const NCompression::CFormatOptions &fo = info.FormatOptionsVector[i];
+ CKey formatKey;
+ formatKey.Create(optionsKey, fo.FormatID);
+
+ SetRegString(formatKey, kCompressionOptions, fo.Options);
+ SetRegString(formatKey, kCompressionMethod, fo.Method);
+ SetRegString(formatKey, kEncryptionMethod, fo.EncryptionMethod);
+
+ SetRegUInt32(formatKey, kCompressionLevel, fo.Level);
+ SetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary);
+ SetRegUInt32(formatKey, kCompressionOrder, fo.Order);
+ SetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize);
+ SetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads);
+ }
+ }
+
+ compressionKey.SetValue(kCompressionLevelValueName, UInt32(info.Level));
+ compressionKey.SetValue(kCompressionLastFormatValueName, GetSystemString(info.ArchiveType));
+
+ compressionKey.SetValue(kCompressionShowPasswordValueName, info.ShowPassword);
+ compressionKey.SetValue(kCompressionEncryptHeadersValueName, info.EncryptHeaders);
+ // compressionKey.SetValue(kCompressionMaximizeValueName, info.Maximize);
+}
+
+void ReadCompressionInfo(NCompression::CInfo &info)
+{
+ info.HistoryArchives.Clear();
+
+ // info.Solid = true;
+ // info.MultiThread = IsMultiProcessor();
+ info.FormatOptionsVector.Clear();
+
+ info.Level = 5;
+ info.ArchiveType = L"7z";
+ // definedStatus.Maximize = false;
+ info.ShowPassword = false;
+ info.EncryptHeaders = false;
+
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey compressionKey;
+
+ if(compressionKey.Open(HKEY_CURRENT_USER,
+ GetKeyPath(kCompressionKeyName), KEY_READ) != ERROR_SUCCESS)
+ return;
+
+ {
+ CKey historyArchivesKey;
+ if(historyArchivesKey.Open(compressionKey, kCompressionHistoryArchivesKeyName, KEY_READ) ==
+ ERROR_SUCCESS)
+ {
+ for (;;)
+ {
+ wchar_t numberString[16];
+ ConvertUInt32ToString(info.HistoryArchives.Size(), numberString);
+ UString path;
+ if (historyArchivesKey.QueryValue(numberString, path) != ERROR_SUCCESS)
+ break;
+ info.HistoryArchives.Add(path);
+ }
+ }
+ }
+
+
+ /*
+ bool solid = false;
+ if (compressionKey.QueryValue(kSolid, solid) == ERROR_SUCCESS)
+ info.Solid = solid;
+ bool multiThread = false;
+ if (compressionKey.QueryValue(kMultiThread, multiThread) == ERROR_SUCCESS)
+ info.MultiThread = multiThread;
+ */
+
+ {
+ CKey optionsKey;
+ if(optionsKey.Open(compressionKey, kCompressionOptionsKeyName, KEY_READ) ==
+ ERROR_SUCCESS)
+ {
+ CSysStringVector formatIDs;
+ optionsKey.EnumKeys(formatIDs);
+ for(int i = 0; i < formatIDs.Size(); i++)
+ {
+ CKey formatKey;
+ NCompression::CFormatOptions fo;
+ fo.FormatID = formatIDs[i];
+ if(formatKey.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS)
+ {
+ GetRegString(formatKey, kCompressionOptions, fo.Options);
+ GetRegString(formatKey, kCompressionMethod, fo.Method);
+ GetRegString(formatKey, kEncryptionMethod, fo.EncryptionMethod);
+
+ GetRegUInt32(formatKey, kCompressionLevel, fo.Level);
+ GetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary);
+ GetRegUInt32(formatKey, kCompressionOrder, fo.Order);
+ GetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize);
+ GetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads);
+
+ info.FormatOptionsVector.Add(fo);
+ }
+
+ }
+ }
+ }
+
+ UInt32 level;
+ if (compressionKey.QueryValue(kCompressionLevelValueName, level) == ERROR_SUCCESS)
+ info.Level = level;
+ CSysString archiveType;
+ if (compressionKey.QueryValue(kCompressionLastFormatValueName, archiveType) == ERROR_SUCCESS)
+ info.ArchiveType = GetUnicodeString(archiveType);
+ if (compressionKey.QueryValue(kCompressionShowPasswordValueName,
+ info.ShowPassword) != ERROR_SUCCESS)
+ info.ShowPassword = false;
+ if (compressionKey.QueryValue(kCompressionEncryptHeadersValueName,
+ info.EncryptHeaders) != ERROR_SUCCESS)
+ info.EncryptHeaders = false;
+ /*
+ if (compressionKey.QueryValue(kCompressionLevelValueName, info.Maximize) == ERROR_SUCCESS)
+ definedStatus.Maximize = true;
+ */
+}
+
+
+///////////////////////////////////
+// WorkDirInfo
+
+static const TCHAR *kOptionsInfoKeyName = TEXT("Options");
+
+static const TCHAR *kWorkDirTypeValueName = TEXT("WorkDirType");
+static const WCHAR *kWorkDirPathValueName = L"WorkDirPath";
+static const TCHAR *kTempRemovableOnlyValueName = TEXT("TempRemovableOnly");
+static const TCHAR *kCascadedMenuValueName = TEXT("CascadedMenu");
+static const TCHAR *kContextMenuValueName = TEXT("ContextMenu");
+
+void SaveWorkDirInfo(const NWorkDir::CInfo &info)
+{
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey optionsKey;
+ optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName));
+ optionsKey.SetValue(kWorkDirTypeValueName, UInt32(info.Mode));
+ optionsKey.SetValue(kWorkDirPathValueName, info.Path);
+ optionsKey.SetValue(kTempRemovableOnlyValueName, info.ForRemovableOnly);
+}
+
+void ReadWorkDirInfo(NWorkDir::CInfo &info)
+{
+ info.SetDefault();
+
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey optionsKey;
+ if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS)
+ return;
+
+ UInt32 dirType;
+ if (optionsKey.QueryValue(kWorkDirTypeValueName, dirType) != ERROR_SUCCESS)
+ return;
+ switch (dirType)
+ {
+ case NWorkDir::NMode::kSystem:
+ case NWorkDir::NMode::kCurrent:
+ case NWorkDir::NMode::kSpecified:
+ info.Mode = NWorkDir::NMode::EEnum(dirType);
+ }
+ UString sysWorkDir;
+ if (optionsKey.QueryValue(kWorkDirPathValueName, sysWorkDir) != ERROR_SUCCESS)
+ {
+ info.Path.Empty();
+ if (info.Mode == NWorkDir::NMode::kSpecified)
+ info.Mode = NWorkDir::NMode::kSystem;
+ }
+ info.Path = GetUnicodeString(sysWorkDir);
+ if (optionsKey.QueryValue(kTempRemovableOnlyValueName, info.ForRemovableOnly) != ERROR_SUCCESS)
+ info.SetForRemovableOnlyDefault();
+}
+
+static void SaveOption(const TCHAR *value, bool enabled)
+{
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey optionsKey;
+ optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName));
+ optionsKey.SetValue(value, enabled);
+}
+
+static bool ReadOption(const TCHAR *value, bool defaultValue)
+{
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey optionsKey;
+ if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS)
+ return defaultValue;
+ bool enabled;
+ if (optionsKey.QueryValue(value, enabled) != ERROR_SUCCESS)
+ return defaultValue;
+ return enabled;
+}
+
+void SaveCascadedMenu(bool show)
+ { SaveOption(kCascadedMenuValueName, show); }
+bool ReadCascadedMenu()
+ { return ReadOption(kCascadedMenuValueName, true); }
+
+
+static void SaveValue(const TCHAR *value, UInt32 valueToWrite)
+{
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey optionsKey;
+ optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName));
+ optionsKey.SetValue(value, valueToWrite);
+}
+
+static bool ReadValue(const TCHAR *value, UInt32 &result)
+{
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey optionsKey;
+ if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS)
+ return false;
+ return (optionsKey.QueryValue(value, result) == ERROR_SUCCESS);
+}
+
+void SaveContextMenuStatus(UInt32 value)
+ { SaveValue(kContextMenuValueName, value); }
+
+bool ReadContextMenuStatus(UInt32 &value)
+ { return ReadValue(kContextMenuValueName, value); }
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ZipRegistry.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ZipRegistry.h
new file mode 100644
index 000000000..30be8d895
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Common/ZipRegistry.h
@@ -0,0 +1,98 @@
+// ZipRegistry.h
+
+#ifndef __ZIPREGISTRY_H
+#define __ZIPREGISTRY_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+#include "ExtractMode.h"
+
+namespace NExtract
+{
+ struct CInfo
+ {
+ NPathMode::EEnum PathMode;
+ NOverwriteMode::EEnum OverwriteMode;
+ UStringVector Paths;
+ bool ShowPassword;
+ };
+}
+
+namespace NCompression {
+
+ struct CFormatOptions
+ {
+ CSysString FormatID;
+ UString Options;
+ UString Method;
+ UString EncryptionMethod;
+ UInt32 Level;
+ UInt32 Dictionary;
+ UInt32 Order;
+ UInt32 BlockLogSize;
+ UInt32 NumThreads;
+ void ResetForLevelChange()
+ {
+ BlockLogSize = NumThreads = Level = Dictionary = Order = UInt32(-1);
+ Method.Empty();
+ // EncryptionMethod.Empty();
+ // Options.Empty();
+ }
+ CFormatOptions() { ResetForLevelChange(); }
+ };
+
+ struct CInfo
+ {
+ UStringVector HistoryArchives;
+ UInt32 Level;
+ UString ArchiveType;
+
+ CObjectVector<CFormatOptions> FormatOptionsVector;
+
+ bool ShowPassword;
+ bool EncryptHeaders;
+ };
+}
+
+namespace NWorkDir{
+
+ namespace NMode
+ {
+ enum EEnum
+ {
+ kSystem,
+ kCurrent,
+ kSpecified
+ };
+ }
+ struct CInfo
+ {
+ NMode::EEnum Mode;
+ UString Path;
+ bool ForRemovableOnly;
+ void SetForRemovableOnlyDefault() { ForRemovableOnly = true; }
+ void SetDefault()
+ {
+ Mode = NMode::kSystem;
+ Path.Empty();
+ SetForRemovableOnlyDefault();
+ }
+ };
+}
+
+void SaveExtractionInfo(const NExtract::CInfo &info);
+void ReadExtractionInfo(NExtract::CInfo &info);
+
+void SaveCompressionInfo(const NCompression::CInfo &info);
+void ReadCompressionInfo(NCompression::CInfo &info);
+
+void SaveWorkDirInfo(const NWorkDir::CInfo &info);
+void ReadWorkDirInfo(NWorkDir::CInfo &info);
+
+void SaveCascadedMenu(bool enabled);
+bool ReadCascadedMenu();
+
+void SaveContextMenuStatus(UInt32 value);
+bool ReadContextMenuStatus(UInt32 &value);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ConsoleClose.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ConsoleClose.cpp
new file mode 100644
index 000000000..9bb2082bf
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ConsoleClose.cpp
@@ -0,0 +1,49 @@
+// ConsoleClose.cpp
+
+#include "StdAfx.h"
+
+#include "ConsoleClose.h"
+
+#include <signal.h>
+
+static int g_BreakCounter = 0;
+static const int kBreakAbortThreshold = 2;
+
+namespace NConsoleClose {
+
+static void HandlerRoutine(int)
+{
+ g_BreakCounter++;
+ if (g_BreakCounter < kBreakAbortThreshold)
+ return ;
+ exit(EXIT_FAILURE);
+}
+
+bool TestBreakSignal()
+{
+ return (g_BreakCounter > 0);
+}
+
+void CheckCtrlBreak()
+{
+ if (TestBreakSignal())
+ throw CCtrlBreakException();
+}
+
+CCtrlHandlerSetter::CCtrlHandlerSetter()
+{
+ memo_sig_int = signal(SIGINT,HandlerRoutine); // CTRL-C
+ if (memo_sig_int == SIG_ERR)
+ throw "SetConsoleCtrlHandler fails (SIGINT)";
+ memo_sig_term = signal(SIGTERM,HandlerRoutine); // for kill -15 (before "kill -9")
+ if (memo_sig_term == SIG_ERR)
+ throw "SetConsoleCtrlHandler fails (SIGTERM)";
+}
+
+CCtrlHandlerSetter::~CCtrlHandlerSetter()
+{
+ signal(SIGINT,memo_sig_int); // CTRL-C
+ signal(SIGTERM,memo_sig_term); // kill {pid}
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ConsoleClose.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ConsoleClose.h
new file mode 100644
index 000000000..042aaf2d6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ConsoleClose.h
@@ -0,0 +1,26 @@
+// ConsoleCloseUtils.h
+
+#ifndef __CONSOLECLOSEUTILS_H
+#define __CONSOLECLOSEUTILS_H
+
+namespace NConsoleClose {
+
+bool TestBreakSignal();
+
+class CCtrlHandlerSetter
+{
+ void (*memo_sig_int)(int);
+ void (*memo_sig_term)(int);
+public:
+ CCtrlHandlerSetter();
+ virtual ~CCtrlHandlerSetter();
+};
+
+class CCtrlBreakException
+{};
+
+void CheckCtrlBreak();
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
new file mode 100644
index 000000000..af65739c3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
@@ -0,0 +1,228 @@
+// ExtractCallbackConsole.h
+
+#include "StdAfx.h"
+
+#include "ExtractCallbackConsole.h"
+#include "UserInputUtils.h"
+#include "ConsoleClose.h"
+
+#include "Common/Wildcard.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/Time.h"
+#include "Windows/Defs.h"
+#include "Windows/PropVariant.h"
+#include "Windows/Error.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../Common/FilePathAutoRename.h"
+
+#include "../Common/ExtractingFilePath.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NDirectory;
+
+static const char *kTestString = "Testing ";
+static const char *kExtractString = "Extracting ";
+static const char *kSkipString = "Skipping ";
+
+// static const char *kCantAutoRename = "can not create file with auto name\n";
+// static const char *kCantRenameFile = "can not rename existing file\n";
+// static const char *kCantDeleteOutputFile = "can not delete output file ";
+static const char *kError = "ERROR: ";
+static const char *kMemoryExceptionMessage = "Can't allocate required memory!";
+
+static const char *kProcessing = "Processing archive: ";
+static const char *kEverythingIsOk = "Everything is Ok";
+static const char *kNoFiles = "No files to process";
+
+static const char *kUnsupportedMethod = "Unsupported Method";
+static const char *kCrcFailed = "CRC Failed";
+static const char *kCrcFailedEncrypted = "CRC Failed in encrypted file. Wrong password?";
+static const char *kDataError = "Data Error";
+static const char *kDataErrorEncrypted = "Data Error in encrypted file. Wrong password?";
+static const char *kUnknownError = "Unknown Error";
+
+STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
+ const wchar_t *existName, const FILETIME *, const UInt64 *,
+ const wchar_t *newName, const FILETIME *, const UInt64 *,
+ Int32 *answer)
+{
+ (*OutStream) << "file " << existName <<
+ "\nalready exists. Overwrite with " << endl;
+ (*OutStream) << newName;
+
+ NUserAnswerMode::EEnum overwriteAnswer = ScanUserYesNoAllQuit(OutStream);
+
+ switch(overwriteAnswer)
+ {
+ case NUserAnswerMode::kQuit: return E_ABORT;
+ case NUserAnswerMode::kNo: *answer = NOverwriteAnswer::kNo; break;
+ case NUserAnswerMode::kNoAll: *answer = NOverwriteAnswer::kNoToAll; break;
+ case NUserAnswerMode::kYesAll: *answer = NOverwriteAnswer::kYesToAll; break;
+ case NUserAnswerMode::kYes: *answer = NOverwriteAnswer::kYes; break;
+ case NUserAnswerMode::kAutoRenameAll: *answer = NOverwriteAnswer::kAutoRename; break;
+ default: return E_FAIL;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, bool /* isFolder */, Int32 askExtractMode, const UInt64 *position)
+{
+ switch (askExtractMode)
+ {
+ case NArchive::NExtract::NAskMode::kExtract: (*OutStream) << kExtractString; break;
+ case NArchive::NExtract::NAskMode::kTest: (*OutStream) << kTestString; break;
+ case NArchive::NExtract::NAskMode::kSkip: (*OutStream) << kSkipString; break;
+ };
+ (*OutStream) << name;
+ if (position != 0)
+ (*OutStream) << " <" << *position << ">";
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
+{
+ (*OutStream) << message << endl;
+ NumFileErrorsInCurrentArchive++;
+ NumFileErrors++;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 operationResult, bool encrypted)
+{
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kOK:
+ break;
+ default:
+ {
+ NumFileErrorsInCurrentArchive++;
+ NumFileErrors++;
+ (*OutStream) << " ";
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
+ (*OutStream) << kUnsupportedMethod;
+ break;
+ case NArchive::NExtract::NOperationResult::kCRCError:
+ (*OutStream) << (encrypted ? kCrcFailedEncrypted: kCrcFailed);
+ break;
+ case NArchive::NExtract::NOperationResult::kDataError:
+ (*OutStream) << (encrypted ? kDataErrorEncrypted : kDataError);
+ break;
+ default:
+ (*OutStream) << kUnknownError;
+ }
+ }
+ }
+ (*OutStream) << endl;
+ return S_OK;
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
+{
+ PasswordIsDefined = true;
+ Password = password;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
+{
+ if (!PasswordIsDefined)
+ {
+ Password = GetPassword(OutStream);
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
+
+#endif
+
+HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name)
+{
+ NumArchives++;
+ NumFileErrorsInCurrentArchive = 0;
+ (*OutStream) << endl << kProcessing << name << endl;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::OpenResult(const wchar_t * /* name */, HRESULT result, bool encrypted)
+{
+ (*OutStream) << endl;
+ if (result != S_OK)
+ {
+ (*OutStream) << "Error: ";
+ if (result == S_FALSE)
+ {
+ (*OutStream) << (encrypted ?
+ "Can not open encrypted archive. Wrong password?" :
+ "Can not open file as archive");
+ }
+ else
+ {
+ if (result == E_OUTOFMEMORY)
+ (*OutStream) << "Can't allocate required memory";
+ else
+ (*OutStream) << NError::MyFormatMessage(result);
+ }
+ (*OutStream) << endl;
+ NumArchiveErrors++;
+ }
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::ThereAreNoFiles()
+{
+ (*OutStream) << endl << kNoFiles << endl;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
+{
+ if (result == S_OK)
+ {
+ (*OutStream) << endl;
+ if (NumFileErrorsInCurrentArchive == 0)
+ (*OutStream) << kEverythingIsOk << endl;
+ else
+ {
+ NumArchiveErrors++;
+ (*OutStream) << "Sub items Errors: " << NumFileErrorsInCurrentArchive << endl;
+ }
+ }
+ if (result == S_OK)
+ return result;
+ NumArchiveErrors++;
+ if (result == E_ABORT || result == ERROR_DISK_FULL)
+ return result;
+ (*OutStream) << endl << kError;
+ if (result == E_OUTOFMEMORY)
+ (*OutStream) << kMemoryExceptionMessage;
+ else
+ {
+ UString message;
+ NError::MyFormatMessage(result, message);
+ (*OutStream) << message;
+ }
+ (*OutStream) << endl;
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ExtractCallbackConsole.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ExtractCallbackConsole.h
new file mode 100644
index 000000000..e42ca6f40
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/ExtractCallbackConsole.h
@@ -0,0 +1,73 @@
+// ExtractCallbackConsole.h
+
+#ifndef __EXTRACTCALLBACKCONSOLE_H
+#define __EXTRACTCALLBACKCONSOLE_H
+
+#include "Common/MyString.h"
+#include "Common/StdOutStream.h"
+#include "../../Common/FileStreams.h"
+#include "../../IPassword.h"
+#include "../../Archive/IArchive.h"
+#include "../Common/ArchiveExtractCallback.h"
+
+class CExtractCallbackConsole:
+ public IExtractCallbackUI,
+ #ifndef _NO_CRYPTO
+ public ICryptoGetTextPassword,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ MY_QUERYINTERFACE_BEGIN2(IFolderArchiveExtractCallback)
+ #ifndef _NO_CRYPTO
+ MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword)
+ #endif
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ STDMETHOD(SetTotal)(UInt64 total);
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue);
+
+ // IFolderArchiveExtractCallback
+ STDMETHOD(AskOverwrite)(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer);
+ STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, Int32 askExtractMode, const UInt64 *position);
+
+ STDMETHOD(MessageError)(const wchar_t *message);
+ STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted);
+
+ HRESULT BeforeOpen(const wchar_t *name);
+ HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted);
+ HRESULT ThereAreNoFiles();
+ HRESULT ExtractResult(HRESULT result);
+
+
+ #ifndef _NO_CRYPTO
+ HRESULT SetPassword(const UString &password);
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+
+ bool PasswordIsDefined;
+ UString Password;
+
+ #endif
+
+ UInt64 NumArchives;
+ UInt64 NumArchiveErrors;
+ UInt64 NumFileErrors;
+ UInt64 NumFileErrorsInCurrentArchive;
+
+ CStdOutStream *OutStream;
+
+ void Init()
+ {
+ NumArchives = 0;
+ NumArchiveErrors = 0;
+ NumFileErrors = 0;
+ NumFileErrorsInCurrentArchive = 0;
+ }
+
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/List.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/List.cpp
new file mode 100644
index 000000000..411f995f7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/List.cpp
@@ -0,0 +1,616 @@
+// List.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/MyCom.h"
+#include "Common/StdOutStream.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../Archive/IArchive.h"
+
+#include "../Common/OpenArchive.h"
+#include "../Common/PropIDUtils.h"
+
+#include "ConsoleClose.h"
+#include "List.h"
+#include "OpenCallbackConsole.h"
+
+using namespace NWindows;
+
+struct CPropIdToName
+{
+ PROPID PropID;
+ const wchar_t *Name;
+};
+
+static CPropIdToName kPropIdToName[] =
+{
+ { kpidPath, L"Path" },
+ { kpidName, L"Name" },
+ { kpidIsDir, L"Folder" },
+ { kpidSize, L"Size" },
+ { kpidPackSize, L"Packed Size" },
+ { kpidAttrib, L"Attributes" },
+ { kpidCTime, L"Created" },
+ { kpidATime, L"Accessed" },
+ { kpidMTime, L"Modified" },
+ { kpidSolid, L"Solid" },
+ { kpidCommented, L"Commented" },
+ { kpidEncrypted, L"Encrypted" },
+ { kpidSplitBefore, L"Split Before" },
+ { kpidSplitAfter, L"Split After" },
+ { kpidDictionarySize, L"Dictionary Size" },
+ { kpidCRC, L"CRC" },
+ { kpidType, L"Type" },
+ { kpidIsAnti, L"Anti" },
+ { kpidMethod, L"Method" },
+ { kpidHostOS, L"Host OS" },
+ { kpidFileSystem, L"File System" },
+ { kpidUser, L"User" },
+ { kpidGroup, L"Group" },
+ { kpidBlock, L"Block" },
+ { kpidComment, L"Comment" },
+ { kpidPosition, L"Position" },
+ { kpidPrefix, L"Prefix" },
+ { kpidNumSubDirs, L"Folders" },
+ { kpidNumSubFiles, L"Files" },
+ { kpidUnpackVer, L"Version" },
+ { kpidVolume, L"Volume" },
+ { kpidIsVolume, L"Multivolume" },
+ { kpidOffset, L"Offset" },
+ { kpidLinks, L"Links" },
+ { kpidNumBlocks, L"Blocks" },
+ { kpidNumVolumes, L"Volumes" },
+
+ { kpidBit64, L"64-bit" },
+ { kpidBigEndian, L"Big-endian" },
+ { kpidCpu, L"CPU" },
+ { kpidPhySize, L"Physical Size" },
+ { kpidHeadersSize, L"Headers Size" },
+ { kpidChecksum, L"Checksum" },
+ { kpidCharacts, L"Characteristics" },
+ { kpidVa, L"Virtual Address" },
+ { kpidId, L"ID" },
+ { kpidShortName, L"Short Name" },
+ { kpidCreatorApp, L"Creator Application"},
+ { kpidSectorSize, L"Sector Size" },
+ { kpidPosixAttrib, L"Mode" },
+ { kpidLink, L"Link" },
+
+ { kpidTotalSize, L"Total Size" },
+ { kpidFreeSpace, L"Free Space" },
+ { kpidClusterSize, L"Cluster Size" },
+ { kpidVolumeName, L"Label" }
+};
+
+static const char kEmptyAttribChar = '.';
+
+static const char *kListing = "Listing archive: ";
+static const wchar_t *kFilesMessage = L"files";
+static const wchar_t *kDirsMessage = L"folders";
+
+static void GetAttribString(DWORD wa, bool isDir, char *s)
+{
+ s[0] = ((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : kEmptyAttribChar;
+ s[1] = ((wa & FILE_ATTRIBUTE_READONLY) != 0) ? 'R': kEmptyAttribChar;
+ s[2] = ((wa & FILE_ATTRIBUTE_HIDDEN) != 0) ? 'H': kEmptyAttribChar;
+ s[3] = ((wa & FILE_ATTRIBUTE_SYSTEM) != 0) ? 'S': kEmptyAttribChar;
+ s[4] = ((wa & FILE_ATTRIBUTE_ARCHIVE) != 0) ? 'A': kEmptyAttribChar;
+ s[5] = '\0';
+}
+
+enum EAdjustment
+{
+ kLeft,
+ kCenter,
+ kRight
+};
+
+struct CFieldInfo
+{
+ PROPID PropID;
+ UString Name;
+ EAdjustment TitleAdjustment;
+ EAdjustment TextAdjustment;
+ int PrefixSpacesWidth;
+ int Width;
+};
+
+struct CFieldInfoInit
+{
+ PROPID PropID;
+ const wchar_t *Name;
+ EAdjustment TitleAdjustment;
+ EAdjustment TextAdjustment;
+ int PrefixSpacesWidth;
+ int Width;
+};
+
+static CFieldInfoInit kStandardFieldTable[] =
+{
+ { kpidMTime, L" Date Time", kLeft, kLeft, 0, 19 },
+ { kpidAttrib, L"Attr", kRight, kCenter, 1, 5 },
+ { kpidSize, L"Size", kRight, kRight, 1, 12 },
+ { kpidPackSize, L"Compressed", kRight, kRight, 1, 12 },
+ { kpidPath, L"Name", kLeft, kLeft, 2, 24 }
+};
+
+static void PrintSpaces(int numSpaces)
+{
+ for (int i = 0; i < numSpaces; i++)
+ g_StdOut << ' ';
+}
+
+static void PrintString(EAdjustment adjustment, int width, const UString &textString)
+{
+ const int numSpaces = width - textString.Length();
+ int numLeftSpaces = 0;
+ switch (adjustment)
+ {
+ case kLeft:
+ numLeftSpaces = 0;
+ break;
+ case kCenter:
+ numLeftSpaces = numSpaces / 2;
+ break;
+ case kRight:
+ numLeftSpaces = numSpaces;
+ break;
+ }
+ PrintSpaces(numLeftSpaces);
+ g_StdOut << textString;
+ PrintSpaces(numSpaces - numLeftSpaces);
+}
+
+class CFieldPrinter
+{
+ CObjectVector<CFieldInfo> _fields;
+public:
+ void Clear() { _fields.Clear(); }
+ void Init(const CFieldInfoInit *standardFieldTable, int numItems);
+ HRESULT Init(IInArchive *archive);
+ void PrintTitle();
+ void PrintTitleLines();
+ HRESULT PrintItemInfo(const CArc &arc, UInt32 index, bool techMode);
+ HRESULT PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
+ const UInt64 *size, const UInt64 *compressedSize);
+};
+
+void CFieldPrinter::Init(const CFieldInfoInit *standardFieldTable, int numItems)
+{
+ Clear();
+ for (int i = 0; i < numItems; i++)
+ {
+ CFieldInfo fieldInfo;
+ const CFieldInfoInit &fieldInfoInit = standardFieldTable[i];
+ fieldInfo.PropID = fieldInfoInit.PropID;
+ fieldInfo.Name = fieldInfoInit.Name;
+ fieldInfo.TitleAdjustment = fieldInfoInit.TitleAdjustment;
+ fieldInfo.TextAdjustment = fieldInfoInit.TextAdjustment;
+ fieldInfo.PrefixSpacesWidth = fieldInfoInit.PrefixSpacesWidth;
+ fieldInfo.Width = fieldInfoInit.Width;
+ _fields.Add(fieldInfo);
+ }
+}
+
+static UString GetPropName(PROPID propID, BSTR name)
+{
+ for (unsigned int i = 0; i < sizeof(kPropIdToName) / sizeof(kPropIdToName[0]); i++)
+ {
+ const CPropIdToName &propIdToName = kPropIdToName[i];
+ if (propIdToName.PropID == propID)
+ return propIdToName.Name;
+ }
+ if (name)
+ return name;
+ wchar_t s[16];
+ ConvertUInt32ToString(propID, s);
+ return s;
+}
+
+HRESULT CFieldPrinter::Init(IInArchive *archive)
+{
+ Clear();
+ UInt32 numProps;
+ RINOK(archive->GetNumberOfProperties(&numProps));
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ RINOK(archive->GetPropertyInfo(i, &name, &propID, &vt));
+ CFieldInfo fieldInfo;
+ fieldInfo.PropID = propID;
+ fieldInfo.Name = GetPropName(propID, name);
+ _fields.Add(fieldInfo);
+ }
+ return S_OK;
+}
+
+void CFieldPrinter::PrintTitle()
+{
+ for (int i = 0; i < _fields.Size(); i++)
+ {
+ const CFieldInfo &fieldInfo = _fields[i];
+ PrintSpaces(fieldInfo.PrefixSpacesWidth);
+ PrintString(fieldInfo.TitleAdjustment,
+ ((fieldInfo.PropID == kpidPath) ? 0: fieldInfo.Width), fieldInfo.Name);
+ }
+}
+
+void CFieldPrinter::PrintTitleLines()
+{
+ for (int i = 0; i < _fields.Size(); i++)
+ {
+ const CFieldInfo &fieldInfo = _fields[i];
+ PrintSpaces(fieldInfo.PrefixSpacesWidth);
+ for (int i = 0; i < fieldInfo.Width; i++)
+ g_StdOut << '-';
+ }
+}
+
+
+static BOOL IsFileTimeZero(CONST FILETIME *lpFileTime)
+{
+ return (lpFileTime->dwLowDateTime == 0) && (lpFileTime->dwHighDateTime == 0);
+}
+
+static const char *kEmptyTimeString = " ";
+static void PrintTime(const NCOM::CPropVariant &prop)
+{
+ if (prop.vt != VT_FILETIME)
+ throw "incorrect item";
+ if (IsFileTimeZero(&prop.filetime))
+ g_StdOut << kEmptyTimeString;
+ else
+ {
+ FILETIME localFileTime;
+ if (!FileTimeToLocalFileTime(&prop.filetime, &localFileTime))
+ throw "FileTimeToLocalFileTime error";
+ char s[32];
+ if (ConvertFileTimeToString(localFileTime, s, true, true))
+ g_StdOut << s;
+ else
+ g_StdOut << kEmptyTimeString;
+ }
+}
+
+HRESULT CFieldPrinter::PrintItemInfo(const CArc &arc, UInt32 index, bool techMode)
+{
+ /*
+ if (techMode)
+ {
+ g_StdOut << "Index = ";
+ g_StdOut << (UInt64)index;
+ g_StdOut << endl;
+ }
+ */
+ for (int i = 0; i < _fields.Size(); i++)
+ {
+ const CFieldInfo &fieldInfo = _fields[i];
+ if (!techMode)
+ PrintSpaces(fieldInfo.PrefixSpacesWidth);
+
+ NCOM::CPropVariant prop;
+ if (fieldInfo.PropID == kpidPath)
+ {
+ UString s;
+ RINOK(arc.GetItemPath(index, s));
+ prop = s;
+ }
+ else
+ {
+ RINOK(arc.Archive->GetProperty(index, fieldInfo.PropID, &prop));
+ }
+ if (techMode)
+ {
+ g_StdOut << fieldInfo.Name << " = ";
+ }
+ int width = (fieldInfo.PropID == kpidPath) ? 0: fieldInfo.Width;
+ if (fieldInfo.PropID == kpidAttrib && (prop.vt == VT_EMPTY || prop.vt == VT_UI4))
+ {
+ UInt32 attrib = (prop.vt == VT_EMPTY) ? 0 : prop.ulVal;
+ bool isFolder;
+ RINOK(IsArchiveItemFolder(arc.Archive, index, isFolder));
+ char s[8];
+ GetAttribString(attrib, isFolder, s);
+ g_StdOut << s;
+ }
+ else if (prop.vt == VT_EMPTY)
+ {
+ if (!techMode)
+ PrintSpaces(width);
+ }
+ else if (fieldInfo.PropID == kpidMTime)
+ {
+ PrintTime(prop);
+ }
+ else if (prop.vt == VT_BSTR)
+ {
+ if (techMode)
+ g_StdOut << prop.bstrVal;
+ else
+ PrintString(fieldInfo.TextAdjustment, width, prop.bstrVal);
+ }
+ else
+ {
+ UString s = ConvertPropertyToString(prop, fieldInfo.PropID);
+ s.Replace(wchar_t(0xA), L' ');
+ s.Replace(wchar_t(0xD), L' ');
+
+ if (techMode)
+ g_StdOut << s;
+ else
+ PrintString(fieldInfo.TextAdjustment, width, s);
+ }
+ if (techMode)
+ g_StdOut << endl;
+ }
+ return S_OK;
+}
+
+static void PrintNumberString(EAdjustment adjustment, int width, const UInt64 *value)
+{
+ wchar_t textString[32] = { 0 };
+ if (value != NULL)
+ ConvertUInt64ToString(*value, textString);
+ PrintString(adjustment, width, textString);
+}
+
+
+HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
+ const UInt64 *size, const UInt64 *compressedSize)
+{
+ for (int i = 0; i < _fields.Size(); i++)
+ {
+ const CFieldInfo &fieldInfo = _fields[i];
+ PrintSpaces(fieldInfo.PrefixSpacesWidth);
+ NCOM::CPropVariant prop;
+ if (fieldInfo.PropID == kpidSize)
+ PrintNumberString(fieldInfo.TextAdjustment, fieldInfo.Width, size);
+ else if (fieldInfo.PropID == kpidPackSize)
+ PrintNumberString(fieldInfo.TextAdjustment, fieldInfo.Width, compressedSize);
+ else if (fieldInfo.PropID == kpidPath)
+ {
+ wchar_t textString[32];
+ ConvertUInt64ToString(numFiles, textString);
+ UString temp = textString;
+ temp += L" ";
+ temp += kFilesMessage;
+ temp += L", ";
+ ConvertUInt64ToString(numDirs, textString);
+ temp += textString;
+ temp += L" ";
+ temp += kDirsMessage;
+ PrintString(fieldInfo.TextAdjustment, 0, temp);
+ }
+ else
+ PrintString(fieldInfo.TextAdjustment, fieldInfo.Width, L"");
+ }
+ return S_OK;
+}
+
+bool GetUInt64Value(IInArchive *archive, UInt32 index, PROPID propID, UInt64 &value)
+{
+ NCOM::CPropVariant prop;
+ if (archive->GetProperty(index, propID, &prop) != S_OK)
+ throw "GetPropertyValue error";
+ if (prop.vt == VT_EMPTY)
+ return false;
+ value = ConvertPropVariantToUInt64(prop);
+ return true;
+}
+
+static void PrintPropPair(const wchar_t *name, const wchar_t *value)
+{
+ g_StdOut << name << " = " << value << endl;
+}
+
+HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
+ bool stdInMode,
+ UStringVector &arcPaths, UStringVector &arcPathsFull,
+ const NWildcard::CCensorNode &wildcardCensor,
+ bool enableHeaders, bool techMode,
+ #ifndef _NO_CRYPTO
+ bool &passwordEnabled, UString &password,
+ #endif
+ UInt64 &numErrors)
+{
+ numErrors = 0;
+ CFieldPrinter fieldPrinter;
+ if (!techMode)
+ fieldPrinter.Init(kStandardFieldTable, sizeof(kStandardFieldTable) / sizeof(kStandardFieldTable[0]));
+
+ UInt64 numFiles2 = 0, numDirs2 = 0, totalPackSize2 = 0, totalUnPackSize2 = 0;
+ UInt64 *totalPackSizePointer2 = 0, *totalUnPackSizePointer2 = 0;
+ int numArcs = /* stdInMode ? 1 : */ arcPaths.Size();
+ for (int i = 0; i < numArcs; i++)
+ {
+ const UString &archiveName = arcPaths[i];
+ if (!stdInMode)
+ {
+ NFile::NFind::CFileInfoW fi;
+ if (!fi.Find(archiveName) || fi.IsDir())
+ {
+ g_StdOut << endl << "Error: " << archiveName << " is not file" << endl;
+ numErrors++;
+ continue;
+ }
+ }
+
+ CArchiveLink archiveLink;
+
+ COpenCallbackConsole openCallback;
+ openCallback.OutStream = &g_StdOut;
+
+ #ifndef _NO_CRYPTO
+
+ openCallback.PasswordIsDefined = passwordEnabled;
+ openCallback.Password = password;
+
+ #endif
+
+ HRESULT result = archiveLink.Open2(codecs, formatIndices, stdInMode, NULL, archiveName, &openCallback);
+ if (result != S_OK)
+ {
+ if (result == E_ABORT)
+ return result;
+ g_StdOut << endl << "Error: " << archiveName << ": ";
+ if (result == S_FALSE)
+ {
+ #ifndef _NO_CRYPTO
+ if (openCallback.Open_WasPasswordAsked())
+ g_StdOut << "Can not open encrypted archive. Wrong password?";
+ else
+ #endif
+ g_StdOut << "Can not open file as archive";
+ }
+ else if (result == E_OUTOFMEMORY)
+ g_StdOut << "Can't allocate required memory";
+ else
+ g_StdOut << NError::MyFormatMessage(result);
+ g_StdOut << endl;
+ numErrors++;
+ continue;
+ }
+
+ if (!stdInMode)
+ for (int v = 0; v < archiveLink.VolumePaths.Size(); v++)
+ {
+ int index = arcPathsFull.FindInSorted(archiveLink.VolumePaths[v]);
+ if (index >= 0 && index > i)
+ {
+ arcPaths.Delete(index);
+ arcPathsFull.Delete(index);
+ numArcs = arcPaths.Size();
+ }
+ }
+
+ if (enableHeaders)
+ {
+ g_StdOut << endl << kListing << archiveName << endl << endl;
+
+ for (int i = 0; i < archiveLink.Arcs.Size(); i++)
+ {
+ const CArc &arc = archiveLink.Arcs[i];
+
+ g_StdOut << "----\n";
+ PrintPropPair(L"Path", arc.Path);
+ PrintPropPair(L"Type", codecs->Formats[arc.FormatIndex].Name);
+ UInt32 numProps;
+ IInArchive *archive = arc.Archive;
+ if (archive->GetNumberOfArchiveProperties(&numProps) == S_OK)
+ {
+ for (UInt32 j = 0; j < numProps; j++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ if (archive->GetArchivePropertyInfo(j, &name, &propID, &vt) != S_OK)
+ continue;
+ NCOM::CPropVariant prop;
+ if (archive->GetArchiveProperty(propID, &prop) != S_OK)
+ continue;
+ UString s = ConvertPropertyToString(prop, propID);
+ if (!s.IsEmpty())
+ PrintPropPair(GetPropName(propID, name), s);
+ }
+ }
+ }
+ g_StdOut << endl;
+ if (techMode)
+ g_StdOut << "----------\n";
+ }
+
+ if (enableHeaders && !techMode)
+ {
+ fieldPrinter.PrintTitle();
+ g_StdOut << endl;
+ fieldPrinter.PrintTitleLines();
+ g_StdOut << endl;
+ }
+
+ const CArc &arc = archiveLink.Arcs.Back();
+ IInArchive *archive = arc.Archive;
+ if (techMode)
+ {
+ RINOK(fieldPrinter.Init(archive));
+ }
+ UInt64 numFiles = 0, numDirs = 0, totalPackSize = 0, totalUnPackSize = 0;
+ UInt64 *totalPackSizePointer = 0, *totalUnPackSizePointer = 0;
+ UInt32 numItems;
+ RINOK(archive->GetNumberOfItems(&numItems));
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+
+ UString filePath;
+ HRESULT res = arc.GetItemPath(i, filePath);
+ if (stdInMode && res == E_INVALIDARG)
+ break;
+ RINOK(res);
+
+ bool isFolder;
+ RINOK(IsArchiveItemFolder(archive, i, isFolder));
+ if (!wildcardCensor.CheckPath(filePath, !isFolder))
+ continue;
+
+ fieldPrinter.PrintItemInfo(arc, i, techMode);
+
+ UInt64 packSize, unpackSize;
+ if (!GetUInt64Value(archive, i, kpidSize, unpackSize))
+ unpackSize = 0;
+ else
+ totalUnPackSizePointer = &totalUnPackSize;
+ if (!GetUInt64Value(archive, i, kpidPackSize, packSize))
+ packSize = 0;
+ else
+ totalPackSizePointer = &totalPackSize;
+
+ g_StdOut << endl;
+
+ if (isFolder)
+ numDirs++;
+ else
+ numFiles++;
+ totalPackSize += packSize;
+ totalUnPackSize += unpackSize;
+ }
+ if (enableHeaders && !techMode)
+ {
+ fieldPrinter.PrintTitleLines();
+ g_StdOut << endl;
+ fieldPrinter.PrintSummaryInfo(numFiles, numDirs, totalUnPackSizePointer, totalPackSizePointer);
+ g_StdOut << endl;
+ }
+ if (totalPackSizePointer != 0)
+ {
+ totalPackSizePointer2 = &totalPackSize2;
+ totalPackSize2 += totalPackSize;
+ }
+ if (totalUnPackSizePointer != 0)
+ {
+ totalUnPackSizePointer2 = &totalUnPackSize2;
+ totalUnPackSize2 += totalUnPackSize;
+ }
+ numFiles2 += numFiles;
+ numDirs2 += numDirs;
+ }
+ if (enableHeaders && !techMode && numArcs > 1)
+ {
+ g_StdOut << endl;
+ fieldPrinter.PrintTitleLines();
+ g_StdOut << endl;
+ fieldPrinter.PrintSummaryInfo(numFiles2, numDirs2, totalUnPackSizePointer2, totalPackSizePointer2);
+ g_StdOut << endl;
+ g_StdOut << "Archives: " << numArcs << endl;
+ }
+ return S_OK;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/List.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/List.h
new file mode 100644
index 000000000..97d9fb15a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/List.h
@@ -0,0 +1,20 @@
+// List.h
+
+#ifndef __LIST_H
+#define __LIST_H
+
+#include "Common/Wildcard.h"
+#include "../Common/LoadCodecs.h"
+
+HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
+ bool stdInMode,
+ UStringVector &archivePaths, UStringVector &archivePathsFull,
+ const NWildcard::CCensorNode &wildcardCensor,
+ bool enableHeaders, bool techMode,
+ #ifndef _NO_CRYPTO
+ bool &passwordEnabled, UString &password,
+ #endif
+ UInt64 &errors);
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/Main.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/Main.cpp
new file mode 100644
index 000000000..83feae3ce
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/Main.cpp
@@ -0,0 +1,642 @@
+// Main.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+
+#include "Common/CommandLineParser.h"
+#include "Common/IntToString.h"
+#include "Common/MyException.h"
+#include "Common/StdOutStream.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/Defs.h"
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+//#ifdef _WIN32
+//#include "Windows/MemoryLock.h"
+//#endif
+
+#include "../../ICoder.h"
+#include "../../IPassword.h"
+
+#include "../Common/ArchiveCommandLine.h"
+#include "../Common/ExitCode.h"
+#include "../Common/Extract.h"
+#ifdef EXTERNAL_CODECS
+#include "../Common/LoadCodecs.h"
+#endif
+#include "../Common/PropIDUtils.h"
+#include "../Common/Update.h"
+#include "../Common/UpdateAction.h"
+
+#include "../../Compress/LZMA_Alone/LzmaBenchCon.h"
+
+#include "ExtractCallbackConsole.h"
+#include "List.h"
+#include "OpenCallbackConsole.h"
+#include "UpdateCallbackConsole.h"
+
+#include "../../MyVersion.h"
+
+#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES)
+#include "../../../../C/Alloc.h"
+#endif
+
+#include "myPrivate.h"
+#include "Windows/System.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NCommandLineParser;
+
+// HINSTANCE g_hInstance = 0;
+extern CStdOutStream *g_StdStream;
+
+static const char *kCopyrightString = "\n7-Zip"
+#ifndef EXTERNAL_CODECS
+" (A)"
+#endif
+
+#ifdef _WIN64
+" [64]"
+#endif
+
+" " MY_VERSION_COPYRIGHT_DATE "\n"
+"p7zip Version " P7ZIP_VERSION ;
+
+static const char *kHelpString =
+ "\nUsage: 7z"
+#ifdef _NO_CRYPTO
+ "r"
+#else
+#ifndef EXTERNAL_CODECS
+ "a"
+#endif
+#endif
+ " <command> [<switches>...] <archive_name> [<file_names>...]\n"
+ " [<@listfiles...>]\n"
+ "\n"
+ "<Commands>\n"
+ " a: Add files to archive\n"
+ " b: Benchmark\n"
+ " d: Delete files from archive\n"
+ " e: Extract files from archive (without using directory names)\n"
+ " l: List contents of archive\n"
+// " l[a|t][f]: List contents of archive\n"
+// " a - with Additional fields\n"
+// " t - with all fields\n"
+// " f - with Full pathnames\n"
+ " t: Test integrity of archive\n"
+ " u: Update files to archive\n"
+ " x: eXtract files with full paths\n"
+ "<Switches>\n"
+ " -ai[r[-|0]]{@listfile|!wildcard}: Include archives\n"
+ " -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives\n"
+ " -bd: Disable percentage indicator\n"
+ " -i[r[-|0]]{@listfile|!wildcard}: Include filenames\n"
+ " -m{Parameters}: set compression Method (see the manual)\n"
+#ifdef HAVE_LSTAT
+ " -l: don't store symlinks; store the files/directories they point to\n"
+ " CAUTION : the scanning stage can never end because of symlinks like '..'\n"
+ " (ex: ln -s .. ldir)\n"
+#endif
+ " -o{Directory}: set Output directory\n"
+ #ifndef _NO_CRYPTO
+ " -p{Password}: set Password\n"
+ #endif
+ " -r[-|0]: Recurse subdirectories\n"
+ " (CAUTION: this flag does not do what you think, avoid using it)\n"
+ " -sfx[{name}]: Create SFX archive\n"
+ " -si[{name}]: read data from stdin\n"
+ " -slt: show technical information for l (List) command\n"
+ " -so: write data to stdout (eg: "
+ "7z"
+#ifdef _NO_CRYPTO
+ "r"
+#elif EXCLUDE_COM
+ "a"
+#endif
+ " a dummy -tgzip -so Doc.txt > archive.gz)\n"
+ " -ssc[-]: set sensitive case mode\n"
+ " -t{Type}: Set type of archive\n"
+ " -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options\n"
+ " -v{Size}[b|k|m|g]: Create volumes\n"
+ " -w[{path}]: assign Work directory. Empty path means a temporary directory\n"
+ " -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames\n"
+ " -y: assume Yes on all queries\n";
+
+// ---------------------------
+// exception messages
+
+static const char *kEverythingIsOk = "Everything is Ok";
+static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode::kUserError
+static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
+
+static const wchar_t *kDefaultSfxModule = L"7zCon.sfx";
+
+static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExitCode::EEnum code)
+{
+ s << message << endl;
+ throw code;
+}
+
+static void PrintHelpAndExit(CStdOutStream &s) // yyy
+{
+ s << kHelpString;
+ ShowMessageAndThrowException(s, kUserErrorMessage, NExitCode::kUserError);
+}
+
+#ifndef _WIN32
+static void GetArguments(int numArguments, const char *arguments[], UStringVector &parts)
+{
+ parts.Clear();
+ for(int i = 0; i < numArguments; i++)
+ {
+ UString s = MultiByteToUnicodeString(arguments[i]);
+ parts.Add(s);
+ }
+}
+#endif
+
+static void ShowCopyrightAndHelp(CStdOutStream &s, bool needHelp)
+{
+ s << kCopyrightString << " (locale=" << /*my_getlocale() <<*/",Utf16=";
+ if (global_use_utf16_conversion) s << "on";
+ else s << "off";
+ s << ",HugeFiles=";
+ if (sizeof(off_t) >= 8) s << "on,";
+ else s << "off,";
+ int nbcpu = NWindows::NSystem::GetNumberOfProcessors();
+ if (nbcpu > 1) s << nbcpu << " CPUs)\n";
+ else s << nbcpu << " CPU)\n";
+
+ if (needHelp)
+ s << kHelpString;
+}
+
+#ifdef EXTERNAL_CODECS
+static void PrintString(CStdOutStream &stdStream, const AString &s, int size)
+{
+ int len = s.Length();
+ stdStream << s;
+ for (int i = len; i < size; i++)
+ stdStream << ' ';
+}
+#endif
+
+static void PrintString(CStdOutStream &stdStream, const UString &s, int size)
+{
+ int len = s.Length();
+ stdStream << s;
+ for (int i = len; i < size; i++)
+ stdStream << ' ';
+}
+
+static inline char GetHex(Byte value)
+{
+ return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
+}
+
+const char *kUnsupportedArcTypeMessage = "Unsupported archive type";
+
+int Main2(
+ #ifndef _WIN32
+ int numArguments, const char *arguments[]
+ #endif
+)
+{
+ #ifdef _WIN32
+ SetFileApisToOEM();
+ #endif
+
+ UStringVector commandStrings;
+ #ifdef _WIN32
+ NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
+ #else
+ // GetArguments(numArguments, arguments, commandStrings);
+ extern void mySplitCommandLine(int numArguments,const char *arguments[],UStringVector &parts);
+ mySplitCommandLine(numArguments,arguments,commandStrings);
+ #endif
+
+ if (commandStrings.Size() == 1)
+ {
+ ShowCopyrightAndHelp(g_StdOut, true);
+ return 0;
+ }
+ commandStrings.Delete(0);
+
+ CArchiveCommandLineOptions options;
+
+ CArchiveCommandLineParser parser;
+
+ parser.Parse1(commandStrings, options);
+
+ if (options.HelpMode)
+ {
+ ShowCopyrightAndHelp(g_StdOut, true);
+ return 0;
+ }
+
+ #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
+ if (options.LargePages)
+ {
+ SetLargePageSize();
+ NSecurity::EnableLockMemoryPrivilege();
+ }
+ #endif
+
+ CStdOutStream &stdStream = options.StdOutMode ? g_StdErr : g_StdOut;
+ g_StdStream = &stdStream;
+
+ if (options.EnableHeaders)
+ ShowCopyrightAndHelp(stdStream, false);
+
+ parser.Parse2(options);
+
+ CCodecs *codecs = new CCodecs;
+ CMyComPtr<
+ #ifdef EXTERNAL_CODECS
+ ICompressCodecsInfo
+ #else
+ IUnknown
+ #endif
+ > compressCodecsInfo = codecs;
+ HRESULT result = codecs->Load();
+ if (result != S_OK)
+ throw CSystemException(result);
+
+ bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
+
+ if (codecs->Formats.Size() == 0 &&
+ (isExtractGroupCommand ||
+ options.Command.CommandType == NCommandType::kList ||
+ options.Command.IsFromUpdateGroup()))
+ throw kNoFormats;
+
+ CIntVector formatIndices;
+ if (!codecs->FindFormatForArchiveType(options.ArcType, formatIndices))
+ throw kUnsupportedArcTypeMessage;
+
+ if (options.Command.CommandType == NCommandType::kInfo)
+ {
+ stdStream << endl << "Formats:" << endl;
+ int i;
+ for (i = 0; i < codecs->Formats.Size(); i++)
+ {
+ const CArcInfoEx &arc = codecs->Formats[i];
+ #ifdef EXTERNAL_CODECS
+ if (arc.LibIndex >= 0)
+ {
+ char s[16];
+ ConvertUInt32ToString(arc.LibIndex, s);
+ PrintString(stdStream, s, 2);
+ }
+ else
+ #endif
+ stdStream << " ";
+ stdStream << ' ';
+ stdStream << (char)(arc.UpdateEnabled ? 'C' : ' ');
+ stdStream << (char)(arc.KeepName ? 'K' : ' ');
+ stdStream << " ";
+ PrintString(stdStream, arc.Name, 6);
+ stdStream << " ";
+ UString s;
+ for (int t = 0; t < arc.Exts.Size(); t++)
+ {
+ const CArcExtInfo &ext = arc.Exts[t];
+ s += ext.Ext;
+ if (!ext.AddExt.IsEmpty())
+ {
+ s += L" (";
+ s += ext.AddExt;
+ s += L')';
+ }
+ s += L' ';
+ }
+ PrintString(stdStream, s, 14);
+ stdStream << " ";
+ const CByteBuffer &sig = arc.StartSignature;
+ for (size_t j = 0; j < sig.GetCapacity(); j++)
+ {
+ Byte b = sig[j];
+ if (b > 0x20 && b < 0x80)
+ {
+ stdStream << (char)b;
+ }
+ else
+ {
+ stdStream << GetHex((Byte)((b >> 4) & 0xF));
+ stdStream << GetHex((Byte)(b & 0xF));
+ }
+ stdStream << ' ';
+ }
+ stdStream << endl;
+ }
+ stdStream << endl << "Codecs:" << endl;
+
+ #ifdef EXTERNAL_CODECS
+ UInt32 numMethods;
+ if (codecs->GetNumberOfMethods(&numMethods) == S_OK)
+ for (UInt32 j = 0; j < numMethods; j++)
+ {
+ int libIndex = codecs->GetCodecLibIndex(j);
+ if (libIndex >= 0)
+ {
+ char s[16];
+ ConvertUInt32ToString(libIndex, s);
+ PrintString(stdStream, s, 2);
+ }
+ else
+ stdStream << " ";
+ stdStream << ' ';
+ stdStream << (char)(codecs->GetCodecEncoderIsAssigned(j) ? 'C' : ' ');
+ UInt64 id;
+ stdStream << " ";
+ HRESULT res = codecs->GetCodecId(j, id);
+ if (res != S_OK)
+ id = (UInt64)(Int64)-1;
+ char s[32];
+ ConvertUInt64ToString(id, s, 16);
+ PrintString(stdStream, s, 8);
+ stdStream << " ";
+ PrintString(stdStream, codecs->GetCodecName(j), 11);
+ stdStream << endl;
+ /*
+ if (res != S_OK)
+ throw "incorrect Codec ID";
+ */
+ }
+ #endif
+ return S_OK;
+ }
+ else if (options.Command.CommandType == NCommandType::kBenchmark)
+ {
+ if (options.Method.CompareNoCase(L"CRC") == 0)
+ {
+ HRESULT res = CrcBenchCon((FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
+ if (res != S_OK)
+ {
+ if (res == S_FALSE)
+ {
+ stdStream << "\nCRC Error\n";
+ return NExitCode::kFatalError;
+ }
+ throw CSystemException(res);
+ }
+ }
+ else
+ {
+ HRESULT res = LzmaBenchCon(
+ #ifdef EXTERNAL_LZMA
+ codecs,
+ #endif
+ (FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
+ if (res != S_OK)
+ {
+ if (res == S_FALSE)
+ {
+ stdStream << "\nDecoding Error\n";
+ return NExitCode::kFatalError;
+ }
+ throw CSystemException(res);
+ }
+ }
+ }
+ else if (isExtractGroupCommand || options.Command.CommandType == NCommandType::kList)
+ {
+ if (isExtractGroupCommand)
+ {
+ CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
+ CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
+
+ ecs->OutStream = &stdStream;
+
+ #ifndef _NO_CRYPTO
+ ecs->PasswordIsDefined = options.PasswordEnabled;
+ ecs->Password = options.Password;
+ #endif
+
+ ecs->Init();
+
+ COpenCallbackConsole openCallback;
+ openCallback.OutStream = &stdStream;
+
+ #ifndef _NO_CRYPTO
+ openCallback.PasswordIsDefined = options.PasswordEnabled;
+ openCallback.Password = options.Password;
+ #endif
+
+ CExtractOptions eo;
+ eo.StdInMode = options.StdInMode;
+ eo.StdOutMode = options.StdOutMode;
+ eo.PathMode = options.Command.GetPathMode();
+ eo.TestMode = options.Command.IsTestMode();
+ eo.OverwriteMode = options.OverwriteMode;
+ eo.OutputDir = options.OutputDir;
+ eo.YesToAll = options.YesToAll;
+ eo.CalcCrc = options.CalcCrc;
+ #ifdef COMPRESS_MT
+ eo.Properties = options.ExtractProperties;
+ #endif
+ UString errorMessage;
+ CDecompressStat stat;
+ HRESULT result = DecompressArchives(
+ codecs,
+ formatIndices,
+ options.ArchivePathsSorted,
+ options.ArchivePathsFullSorted,
+ options.WildcardCensor.Pairs.Front().Head,
+ eo, &openCallback, ecs, errorMessage, stat);
+ if (!errorMessage.IsEmpty())
+ {
+ stdStream << endl << "Error: " << errorMessage;
+ if (result == S_OK)
+ result = E_FAIL;
+ }
+
+ stdStream << endl;
+ if (ecs->NumArchives > 1)
+ stdStream << "Archives: " << ecs->NumArchives << endl;
+ if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
+ {
+ if (ecs->NumArchives > 1)
+ {
+ stdStream << endl;
+ if (ecs->NumArchiveErrors != 0)
+ stdStream << "Archive Errors: " << ecs->NumArchiveErrors << endl;
+ if (ecs->NumFileErrors != 0)
+ stdStream << "Sub items Errors: " << ecs->NumFileErrors << endl;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ return NExitCode::kFatalError;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ if (stat.NumFolders != 0)
+ stdStream << "Folders: " << stat.NumFolders << endl;
+ if (stat.NumFiles != 1 || stat.NumFolders != 0)
+ stdStream << "Files: " << stat.NumFiles << endl;
+ stdStream
+ << "Size: " << stat.UnpackSize << endl
+ << "Compressed: " << stat.PackSize << endl;
+ if (options.CalcCrc)
+ {
+ wchar_t s[16];
+ ConvertUInt32ToHex(stat.CrcSum, s);
+ stdStream << "CRC: " << s << endl;
+ }
+ }
+ else
+ {
+ UInt64 numErrors = 0;
+ HRESULT result = ListArchives(
+ codecs,
+ formatIndices,
+ options.StdInMode,
+ options.ArchivePathsSorted,
+ options.ArchivePathsFullSorted,
+ options.WildcardCensor.Pairs.Front().Head,
+ options.EnableHeaders,
+ options.TechMode,
+ #ifndef _NO_CRYPTO
+ options.PasswordEnabled,
+ options.Password,
+ #endif
+ numErrors);
+ if (numErrors > 0)
+ {
+ g_StdOut << endl << "Errors: " << numErrors;
+ return NExitCode::kFatalError;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ }
+ }
+ else if (options.Command.IsFromUpdateGroup())
+ {
+ CUpdateOptions &uo = options.UpdateOptions;
+ if (uo.SfxMode && uo.SfxModule.IsEmpty())
+ uo.SfxModule = kDefaultSfxModule;
+
+ COpenCallbackConsole openCallback;
+ openCallback.OutStream = &stdStream;
+
+ #ifndef _NO_CRYPTO
+ bool passwordIsDefined =
+ options.PasswordEnabled && !options.Password.IsEmpty();
+ openCallback.PasswordIsDefined = passwordIsDefined;
+ openCallback.Password = options.Password;
+ #endif
+
+ CUpdateCallbackConsole callback;
+ callback.EnablePercents = options.EnablePercents;
+
+ #ifndef _NO_CRYPTO
+ callback.PasswordIsDefined = passwordIsDefined;
+ callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
+ callback.Password = options.Password;
+ #endif
+ callback.StdOutMode = uo.StdOutMode;
+ callback.Init(&stdStream);
+
+ CUpdateErrorInfo errorInfo;
+
+ if (!uo.Init(codecs, formatIndices, options.ArchiveName))
+ throw kUnsupportedArcTypeMessage;
+ HRESULT result = UpdateArchive(codecs,
+ options.WildcardCensor, uo,
+ errorInfo, &openCallback, &callback);
+
+#ifdef ENV_UNIX
+ if (uo.SfxMode)
+ {
+ void myAddExeFlag(const UString &name);
+ for(int i = 0; i < uo.Commands.Size(); i++)
+ {
+ CUpdateArchiveCommand &command = uo.Commands[i];
+ if (!uo.StdOutMode)
+ {
+ myAddExeFlag(command.ArchivePath.GetFinalPath());
+ }
+ }
+ }
+#endif
+
+ int exitCode = NExitCode::kSuccess;
+ if (callback.CantFindFiles.Size() > 0)
+ {
+ stdStream << endl;
+ stdStream << "WARNINGS for files:" << endl << endl;
+ int numErrors = callback.CantFindFiles.Size();
+ for (int i = 0; i < numErrors; i++)
+ {
+ stdStream << callback.CantFindFiles[i] << " : ";
+ stdStream << NError::MyFormatMessageW(callback.CantFindCodes[i]) << endl;
+ }
+ stdStream << "----------------" << endl;
+ stdStream << "WARNING: Cannot find " << numErrors << " file";
+ if (numErrors > 1)
+ stdStream << "s";
+ stdStream << endl;
+ exitCode = NExitCode::kWarning;
+ }
+
+ if (result != S_OK)
+ {
+ UString message;
+ if (!errorInfo.Message.IsEmpty())
+ {
+ message += errorInfo.Message;
+ message += L"\n";
+ }
+ if (!errorInfo.FileName.IsEmpty())
+ {
+ message += errorInfo.FileName;
+ message += L"\n";
+ }
+ if (!errorInfo.FileName2.IsEmpty())
+ {
+ message += errorInfo.FileName2;
+ message += L"\n";
+ }
+ if (errorInfo.SystemError != 0)
+ {
+ message += NError::MyFormatMessageW(errorInfo.SystemError);
+ message += L"\n";
+ }
+ if (!message.IsEmpty())
+ stdStream << L"\nError:\n" << message;
+ throw CSystemException(result);
+ }
+ int numErrors = callback.FailedFiles.Size();
+ if (numErrors == 0)
+ {
+ if (callback.CantFindFiles.Size() == 0)
+ stdStream << kEverythingIsOk << endl;
+ }
+ else
+ {
+ stdStream << endl;
+ stdStream << "WARNINGS for files:" << endl << endl;
+ for (int i = 0; i < numErrors; i++)
+ {
+ stdStream << callback.FailedFiles[i] << " : ";
+ stdStream << NError::MyFormatMessageW(callback.FailedCodes[i]) << endl;
+ }
+ stdStream << "----------------" << endl;
+ stdStream << "WARNING: Cannot open " << numErrors << " file";
+ if (numErrors > 1)
+ stdStream << "s";
+ stdStream << endl;
+ exitCode = NExitCode::kWarning;
+ }
+ return exitCode;
+ }
+ else
+ PrintHelpAndExit(stdStream);
+ return 0;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/MainAr.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/MainAr.cpp
new file mode 100644
index 000000000..02918d79d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/MainAr.cpp
@@ -0,0 +1,157 @@
+// MainAr.cpp
+
+#include "StdAfx.h"
+
+// #include <locale.h>
+
+#include "Windows/Error.h"
+
+#include "Common/StdOutStream.h"
+#include "Common/NewHandler.h"
+#include "Common/MyException.h"
+#include "Common/StringConvert.h"
+
+#include "../Common/ExitCode.h"
+#include "../Common/ArchiveCommandLine.h"
+#include "ConsoleClose.h"
+
+using namespace NWindows;
+
+CStdOutStream *g_StdStream = 0;
+
+#ifdef _WIN32
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
+#if !defined(_UNICODE) || !defined(_WIN64)
+static inline bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+#endif
+
+extern int Main2(
+ #ifndef _WIN32
+ int numArguments, const char *arguments[]
+ #endif
+);
+
+static const char *kExceptionErrorMessage = "\n\nError:\n";
+static const char *kUserBreak = "\nBreak signaled\n";
+
+static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required memory!\n";
+static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n";
+static const char *kInternalExceptionMessage = "\n\nInternal Error #";
+
+int MY_CDECL main
+(
+#ifndef _WIN32
+int numArguments, const char *arguments[]
+#endif
+)
+{
+ g_StdStream = &g_StdOut;
+ #ifdef _WIN32
+
+ #ifdef _UNICODE
+ #ifndef _WIN64
+ if (!IsItWindowsNT())
+ {
+ (*g_StdStream) << "This program requires Windows NT/2000/2003/2008/XP/Vista";
+ return NExitCode::kFatalError;
+ }
+ #endif
+ #else
+ g_IsNT = IsItWindowsNT();
+ #endif
+
+ #endif
+
+ // setlocale(LC_COLLATE, ".OCP");
+ NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
+ int res = 0;
+ try
+ {
+ res = Main2(
+#ifndef _WIN32
+ numArguments, arguments
+#endif
+ );
+ }
+ catch(const CNewException &)
+ {
+ (*g_StdStream) << kMemoryExceptionMessage;
+ return (NExitCode::kMemoryError);
+ }
+ catch(const NConsoleClose::CCtrlBreakException &)
+ {
+ (*g_StdStream) << endl << kUserBreak;
+ return (NExitCode::kUserBreak);
+ }
+ catch(const CArchiveCommandLineException &e)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << e << endl;
+ return (NExitCode::kUserError);
+ }
+ catch(const CSystemException &systemError)
+ {
+ if (systemError.ErrorCode == E_OUTOFMEMORY)
+ {
+ (*g_StdStream) << kMemoryExceptionMessage;
+ return (NExitCode::kMemoryError);
+ }
+ if (systemError.ErrorCode == E_ABORT)
+ {
+ (*g_StdStream) << endl << kUserBreak;
+ return (NExitCode::kUserBreak);
+ }
+ UString message;
+ NError::MyFormatMessage(systemError.ErrorCode, message);
+ (*g_StdStream) << endl << endl << "System error:" << endl <<
+ message << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(NExitCode::EEnum &exitCode)
+ {
+ (*g_StdStream) << kInternalExceptionMessage << exitCode << endl;
+ return (exitCode);
+ }
+ /*
+ catch(const NExitCode::CMultipleErrors &multipleErrors)
+ {
+ (*g_StdStream) << endl << multipleErrors.NumErrors << " errors" << endl;
+ return (NExitCode::kFatalError);
+ }
+ */
+ catch(const UString &s)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << s << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(const AString &s)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << s << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(const char *s)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << s << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(int t)
+ {
+ (*g_StdStream) << kInternalExceptionMessage << t << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(...)
+ {
+ (*g_StdStream) << kUnknownExceptionMessage;
+ return (NExitCode::kFatalError);
+ }
+ return res;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/OpenCallbackConsole.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/OpenCallbackConsole.cpp
new file mode 100644
index 000000000..7dba2ad5d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/OpenCallbackConsole.cpp
@@ -0,0 +1,58 @@
+// OpenCallbackConsole.cpp
+
+#include "StdAfx.h"
+
+#include "OpenCallbackConsole.h"
+
+#include "ConsoleClose.h"
+#include "UserInputUtils.h"
+
+HRESULT COpenCallbackConsole::Open_CheckBreak()
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT COpenCallbackConsole::Open_SetTotal(const UInt64 *, const UInt64 *)
+{
+ return Open_CheckBreak();
+}
+
+HRESULT COpenCallbackConsole::Open_SetCompleted(const UInt64 *, const UInt64 *)
+{
+ return Open_CheckBreak();
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
+{
+ PasswordWasAsked = true;
+ RINOK(Open_CheckBreak());
+ if (!PasswordIsDefined)
+ {
+ Password = GetPassword(OutStream);
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
+
+HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(UString &password)
+{
+ if (PasswordIsDefined)
+ password = Password;
+ return S_OK;
+}
+
+bool COpenCallbackConsole::Open_WasPasswordAsked()
+{
+ return PasswordWasAsked;
+}
+
+void COpenCallbackConsole::Open_ClearPasswordWasAskedFlag()
+{
+ PasswordWasAsked = false;
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/OpenCallbackConsole.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/OpenCallbackConsole.h
new file mode 100644
index 000000000..c002e6a72
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/OpenCallbackConsole.h
@@ -0,0 +1,24 @@
+// OpenCallbackConsole.h
+
+#ifndef __OPENCALLBACKCONSOLE_H
+#define __OPENCALLBACKCONSOLE_H
+
+#include "Common/StdOutStream.h"
+#include "../Common/ArchiveOpenCallback.h"
+
+class COpenCallbackConsole: public IOpenCallbackUI
+{
+public:
+ INTERFACE_IOpenCallbackUI(;)
+
+ CStdOutStream *OutStream;
+
+ #ifndef _NO_CRYPTO
+ bool PasswordIsDefined;
+ bool PasswordWasAsked;
+ UString Password;
+ COpenCallbackConsole(): PasswordIsDefined(false), PasswordWasAsked(false) {}
+ #endif
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/PercentPrinter.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/PercentPrinter.cpp
new file mode 100644
index 000000000..28452b177
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/PercentPrinter.cpp
@@ -0,0 +1,90 @@
+// PercentPrinter.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/MyString.h"
+
+#include "PercentPrinter.h"
+
+const int kPaddingSize = 2;
+const int kPercentsSize = 4;
+const int kMaxExtraSize = kPaddingSize + 32 + kPercentsSize;
+
+static void ClearPrev(char *p, int num)
+{
+ int i;
+ for (i = 0; i < num; i++) *p++ = '\b';
+ for (i = 0; i < num; i++) *p++ = ' ';
+ for (i = 0; i < num; i++) *p++ = '\b';
+ *p = '\0';
+}
+
+void CPercentPrinter::ClosePrint()
+{
+ if (m_NumExtraChars == 0)
+ return;
+ char s[kMaxExtraSize * 3 + 1];
+ ClearPrev(s, m_NumExtraChars);
+ (*OutStream) << s;
+ m_NumExtraChars = 0;
+}
+
+void CPercentPrinter::PrintString(const char *s)
+{
+ ClosePrint();
+ (*OutStream) << s;
+}
+
+void CPercentPrinter::PrintString(const wchar_t *s)
+{
+ ClosePrint();
+ (*OutStream) << s;
+}
+
+void CPercentPrinter::PrintNewLine()
+{
+ ClosePrint();
+ (*OutStream) << "\n";
+}
+
+void CPercentPrinter::RePrintRatio()
+{
+ char s[32];
+ ConvertUInt64ToString(((m_Total == 0) ? 0 : (m_CurValue * 100 / m_Total)), s);
+ int size = (int)strlen(s);
+ s[size++] = '%';
+ s[size] = '\0';
+
+ int extraSize = kPaddingSize + MyMax(size, kPercentsSize);
+ if (extraSize < m_NumExtraChars)
+ extraSize = m_NumExtraChars;
+
+ char fullString[kMaxExtraSize * 3];
+ char *p = fullString;
+ int i;
+ if (m_NumExtraChars == 0)
+ {
+ for (i = 0; i < extraSize; i++)
+ *p++ = ' ';
+ m_NumExtraChars = extraSize;
+ }
+
+ for (i = 0; i < m_NumExtraChars; i++)
+ *p++ = '\b';
+ m_NumExtraChars = extraSize;
+ for (; size < m_NumExtraChars; size++)
+ *p++ = ' ';
+ MyStringCopy(p, s);
+ (*OutStream) << fullString;
+ OutStream->Flush();
+ m_PrevValue = m_CurValue;
+}
+
+void CPercentPrinter::PrintRatio()
+{
+ if (m_CurValue < m_PrevValue + m_MinStepSize &&
+ m_CurValue + m_MinStepSize > m_PrevValue && m_NumExtraChars != 0)
+ return;
+ RePrintRatio();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/PercentPrinter.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/PercentPrinter.h
new file mode 100644
index 000000000..97f2e6adb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/PercentPrinter.h
@@ -0,0 +1,31 @@
+// PercentPrinter.h
+
+#ifndef __PERCENTPRINTER_H
+#define __PERCENTPRINTER_H
+
+#include "Common/Types.h"
+#include "Common/StdOutStream.h"
+
+class CPercentPrinter
+{
+ UInt64 m_MinStepSize;
+ UInt64 m_PrevValue;
+ UInt64 m_CurValue;
+ UInt64 m_Total;
+ int m_NumExtraChars;
+public:
+ CStdOutStream *OutStream;
+
+ CPercentPrinter(UInt64 minStepSize = 1): m_MinStepSize(minStepSize),
+ m_PrevValue(0), m_CurValue(0), m_Total(1), m_NumExtraChars(0) {}
+ void SetTotal(UInt64 total) { m_Total = total; m_PrevValue = 0; }
+ void SetRatio(UInt64 doneValue) { m_CurValue = doneValue; }
+ void PrintString(const char *s);
+ void PrintString(const wchar_t *s);
+ void PrintNewLine();
+ void ClosePrint();
+ void RePrintRatio();
+ void PrintRatio();
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
new file mode 100644
index 000000000..cfd8e8321
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
@@ -0,0 +1,261 @@
+// UpdateCallbackConsole.cpp
+
+#include "StdAfx.h"
+
+#include "UpdateCallbackConsole.h"
+
+#include "Windows/Error.h"
+#ifdef COMPRESS_MT
+#include "Windows/Synchronization.h"
+#endif
+
+#include "ConsoleClose.h"
+#include "UserInputUtils.h"
+
+using namespace NWindows;
+
+#ifdef COMPRESS_MT
+static NSynchronization::CCriticalSection g_CriticalSection;
+#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+#else
+#define MT_LOCK
+#endif
+
+static const wchar_t *kEmptyFileAlias = L"[Content]";
+
+static const char *kCreatingArchiveMessage = "Creating archive ";
+static const char *kUpdatingArchiveMessage = "Updating archive ";
+static const char *kScanningMessage = "Scanning";
+
+
+HRESULT CUpdateCallbackConsole::OpenResult(const wchar_t *name, HRESULT result)
+{
+ (*OutStream) << endl;
+ if (result != S_OK)
+ (*OutStream) << "Error: " << name << " is not supported archive" << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::StartScanning()
+{
+ (*OutStream) << kScanningMessage;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::ScanProgress(UInt64 /* numFolders */, UInt64 /* numFiles */, const wchar_t * /* path */)
+{
+ return CheckBreak();
+}
+
+HRESULT CUpdateCallbackConsole::CanNotFindError(const wchar_t *name, DWORD systemError)
+{
+ CantFindFiles.Add(name);
+ CantFindCodes.Add(systemError);
+ // m_PercentPrinter.ClosePrint();
+ if (!m_WarningsMode)
+ {
+ (*OutStream) << endl << endl;
+ m_PercentPrinter.PrintNewLine();
+ m_WarningsMode = true;
+ }
+ m_PercentPrinter.PrintString(name);
+ m_PercentPrinter.PrintString(": WARNING: ");
+ m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
+ m_PercentPrinter.PrintNewLine();
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::FinishScanning()
+{
+ (*OutStream) << endl << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::StartArchive(const wchar_t *name, bool updating)
+{
+ if(updating)
+ (*OutStream) << kUpdatingArchiveMessage;
+ else
+ (*OutStream) << kCreatingArchiveMessage;
+ if (name != 0)
+ (*OutStream) << name;
+ else
+ (*OutStream) << "StdOut";
+ (*OutStream) << endl << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::FinishArchive()
+{
+ (*OutStream) << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::CheckBreak()
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::Finilize()
+{
+ MT_LOCK
+ if (m_NeedBeClosed)
+ {
+ if (EnablePercents)
+ {
+ m_PercentPrinter.ClosePrint();
+ }
+ if (!StdOutMode && m_NeedNewLine)
+ {
+ m_PercentPrinter.PrintNewLine();
+ m_NeedNewLine = false;
+ }
+ m_NeedBeClosed = false;
+ }
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetNumFiles(UInt64 /* numFiles */)
+{
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetTotal(UInt64 size)
+{
+ MT_LOCK
+ if (EnablePercents)
+ m_PercentPrinter.SetTotal(size);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetCompleted(const UInt64 *completeValue)
+{
+ MT_LOCK
+ if (completeValue != NULL)
+ {
+ if (EnablePercents)
+ {
+ m_PercentPrinter.SetRatio(*completeValue);
+ m_PercentPrinter.PrintRatio();
+ m_NeedBeClosed = true;
+ }
+ }
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetRatioInfo(const UInt64 * /* inSize */, const UInt64 * /* outSize */)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool isAnti)
+{
+ MT_LOCK
+ if (StdOutMode)
+ return S_OK;
+ if(isAnti)
+ m_PercentPrinter.PrintString("Anti item ");
+ else
+ m_PercentPrinter.PrintString("Compressing ");
+ if (name[0] == 0)
+ name = kEmptyFileAlias;
+ m_PercentPrinter.PrintString(name);
+ if (EnablePercents)
+ m_PercentPrinter.RePrintRatio();
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::OpenFileError(const wchar_t *name, DWORD systemError)
+{
+ MT_LOCK
+ FailedCodes.Add(systemError);
+ FailedFiles.Add(name);
+ // if (systemError == ERROR_SHARING_VIOLATION)
+ {
+ m_PercentPrinter.ClosePrint();
+ m_PercentPrinter.PrintNewLine();
+ m_PercentPrinter.PrintString("WARNING: ");
+ m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
+ return S_FALSE;
+ }
+ // return systemError;
+}
+
+HRESULT CUpdateCallbackConsole::SetOperationResult(Int32 )
+{
+ m_NeedBeClosed = true;
+ m_NeedNewLine = true;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ *password = NULL;
+
+ #ifdef _NO_CRYPTO
+
+ *passwordIsDefined = false;
+ return S_OK;
+
+ #else
+
+ if (!PasswordIsDefined)
+ {
+ if (AskPassword)
+ {
+ Password = GetPassword(OutStream,true);
+ PasswordIsDefined = true;
+ }
+ }
+ *passwordIsDefined = BoolToInt(PasswordIsDefined);
+ return StringToBstr(Password, password);
+
+ #endif
+}
+
+HRESULT CUpdateCallbackConsole::CryptoGetTextPassword(BSTR *password)
+{
+ *password = NULL;
+
+ #ifdef _NO_CRYPTO
+
+ return E_NOTIMPL;
+
+ #else
+
+ if (!PasswordIsDefined)
+ {
+ {
+ Password = GetPassword(OutStream);
+ PasswordIsDefined = true;
+ }
+ }
+ return StringToBstr(Password, password);
+
+ #endif
+}
+
+/*
+HRESULT CUpdateCallbackConsole::ShowDeleteFile(const wchar_t *name)
+{
+ // MT_LOCK
+ if (StdOutMode)
+ return S_OK;
+ RINOK(Finilize());
+ m_PercentPrinter.PrintString("Deleting ");
+ if (name[0] == 0)
+ name = kEmptyFileAlias;
+ m_PercentPrinter.PrintString(name);
+ if (EnablePercents)
+ m_PercentPrinter.RePrintRatio();
+ m_NeedBeClosed = true;
+ m_NeedNewLine = true;
+ return S_OK;
+}
+*/
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UpdateCallbackConsole.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UpdateCallbackConsole.h
new file mode 100644
index 000000000..370b2c534
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UpdateCallbackConsole.h
@@ -0,0 +1,63 @@
+// UpdateCallbackConsole.h
+
+#ifndef __UPDATE_CALLBACK_CONSOLE_H
+#define __UPDATE_CALLBACK_CONSOLE_H
+
+#include "Common/StdOutStream.h"
+
+#include "../Common/Update.h"
+
+#include "PercentPrinter.h"
+
+class CUpdateCallbackConsole: public IUpdateCallbackUI2
+{
+ CPercentPrinter m_PercentPrinter;
+ bool m_NeedBeClosed;
+ bool m_NeedNewLine;
+
+ bool m_WarningsMode;
+
+ CStdOutStream *OutStream;
+public:
+ bool EnablePercents;
+ bool StdOutMode;
+
+ #ifndef _NO_CRYPTO
+ bool PasswordIsDefined;
+ UString Password;
+ bool AskPassword;
+ #endif
+
+ CUpdateCallbackConsole():
+ m_PercentPrinter(1 << 16),
+ m_WarningsMode(false),
+ EnablePercents(true),
+ StdOutMode(false)
+ #ifndef _NO_CRYPTO
+ ,
+ PasswordIsDefined(false),
+ AskPassword(false)
+ #endif
+ {}
+
+ ~CUpdateCallbackConsole() { Finilize(); }
+ void Init(CStdOutStream *outStream)
+ {
+ m_NeedBeClosed = false;
+ m_NeedNewLine = false;
+ FailedFiles.Clear();
+ FailedCodes.Clear();
+ OutStream = outStream;
+ m_PercentPrinter.OutStream = outStream;
+ }
+
+ INTERFACE_IUpdateCallbackUI2(;)
+
+ UStringVector FailedFiles;
+ CRecordVector<HRESULT> FailedCodes;
+
+ UStringVector CantFindFiles;
+ CRecordVector<HRESULT> CantFindCodes;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UserInputUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UserInputUtils.cpp
new file mode 100644
index 000000000..77d4ba94c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UserInputUtils.cpp
@@ -0,0 +1,90 @@
+// UserInputUtils.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StdInStream.h"
+#include "Common/StringConvert.h"
+
+#include "UserInputUtils.h"
+
+#ifdef USE_FLTK
+// the programs like file-roller or xarchiver do not support archives with password
+// these programs freeze because p7zip is waiting for a password
+// defining USE_FLTK allows p7zip to use a popup in order to ask the password.
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
+#include <FL/fl_ask.H>
+#else
+#ifdef HAVE_GETPASS
+#include <pwd.h>
+#include <unistd.h>
+#include "Common/MyException.h"
+#endif
+#endif
+
+static const char kYes = 'Y';
+static const char kNo = 'N';
+static const char kYesAll = 'A';
+static const char kNoAll = 'S';
+static const char kAutoRenameAll = 'U';
+static const char kQuit = 'Q';
+
+static const char *kFirstQuestionMessage = "?\n";
+static const char *kHelpQuestionMessage =
+ "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? ";
+
+// return true if pressed Quite;
+
+NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
+{
+ (*outStream) << kFirstQuestionMessage;
+ for(;;)
+ {
+ (*outStream) << kHelpQuestionMessage;
+ AString scannedString = g_StdIn.ScanStringUntilNewLine();
+ scannedString.Trim();
+ if(!scannedString.IsEmpty())
+ switch(::MyCharUpper(scannedString[0]))
+ {
+ case kYes:
+ return NUserAnswerMode::kYes;
+ case kNo:
+ return NUserAnswerMode::kNo;
+ case kYesAll:
+ return NUserAnswerMode::kYesAll;
+ case kNoAll:
+ return NUserAnswerMode::kNoAll;
+ case kAutoRenameAll:
+ return NUserAnswerMode::kAutoRenameAll;
+ case kQuit:
+ return NUserAnswerMode::kQuit;
+ }
+ }
+}
+
+UString GetPassword(CStdOutStream *outStream,bool verify)
+{
+#ifdef USE_FLTK
+ const char *r = fl_password("Enter password", 0);
+ AString oemPassword = "";
+ if (r) oemPassword = r;
+#else /* USE_FLTK */
+#ifdef HAVE_GETPASS
+ (*outStream) << "\nEnter password (will not be echoed) :";
+ outStream->Flush();
+ AString oemPassword = getpass("");
+ if (verify)
+ {
+ (*outStream) << "Verify password (will not be echoed) :";
+ outStream->Flush();
+ AString oemPassword2 = getpass("");
+ if (oemPassword != oemPassword2) throw "password verification failed";
+ }
+#else
+ (*outStream) << "\nEnter password:";
+ outStream->Flush();
+ AString oemPassword = g_StdIn.ScanStringUntilNewLine();
+#endif
+#endif /* USE_FLTK */
+ return MultiByteToUnicodeString(oemPassword, CP_OEMCP);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UserInputUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UserInputUtils.h
new file mode 100644
index 000000000..8c575194d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Console/UserInputUtils.h
@@ -0,0 +1,24 @@
+// UserInputUtils.h
+
+#ifndef __USERINPUTUTILS_H
+#define __USERINPUTUTILS_H
+
+#include "Common/StdOutStream.h"
+
+namespace NUserAnswerMode {
+
+enum EEnum
+{
+ kYes,
+ kNo,
+ kYesAll,
+ kNoAll,
+ kAutoRenameAll,
+ kQuit
+};
+}
+
+NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream);
+UString GetPassword(CStdOutStream *outStream,bool verify = false);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Explorer/MyMessages.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Explorer/MyMessages.cpp
new file mode 100644
index 000000000..62ac42ec1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Explorer/MyMessages.cpp
@@ -0,0 +1,58 @@
+// MyMessages.cpp
+
+#include "StdAfx.h"
+
+#include "MyMessages.h"
+
+#include "Windows/Error.h"
+#include "Windows/ResourceString.h"
+
+#ifdef LANG
+#include "../FileManager/LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+void ShowErrorMessage(HWND window, LPCWSTR message)
+{
+ ::MessageBoxW(window, message, L"7-Zip", MB_OK | MB_ICONSTOP);
+}
+
+void ShowErrorMessageHwndRes(HWND window, UINT resID
+ #ifdef LANG
+ , UInt32 langID
+ #endif
+ )
+{
+ ShowErrorMessage(window,
+ #ifdef LANG
+ LangString(resID, langID)
+ #else
+ MyLoadStringW(resID)
+ #endif
+ );
+}
+
+void ShowErrorMessageRes(UINT resID
+ #ifdef LANG
+ , UInt32 langID
+ #endif
+ )
+{
+ ShowErrorMessageHwndRes(0, resID
+ #ifdef LANG
+ , langID
+ #endif
+ );
+}
+
+void ShowErrorMessageDWORD(HWND window, DWORD errorCode)
+{
+ ShowErrorMessage(window, NError::MyFormatMessageW(errorCode));
+}
+
+void ShowLastErrorMessage(HWND window)
+{
+ ShowErrorMessageDWORD(window, ::GetLastError());
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Explorer/MyMessages.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Explorer/MyMessages.h
new file mode 100644
index 000000000..10da975b2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Explorer/MyMessages.h
@@ -0,0 +1,28 @@
+// MyMessages.h
+
+#ifndef __MYMESSAGES_H
+#define __MYMESSAGES_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+
+void ShowErrorMessage(HWND window, LPCWSTR message);
+inline void ShowErrorMessage(LPCWSTR message) { ShowErrorMessage(0, message); }
+
+void ShowErrorMessageHwndRes(HWND window, UINT resID
+ #ifdef LANG
+ , UInt32 langID
+ #endif
+ );
+
+void ShowErrorMessageRes(UINT resID
+ #ifdef LANG
+ , UInt32 langID
+ #endif
+ );
+
+// void ShowErrorMessageDWORD(HWND window, DWORD errorCode);
+// inline void ErrorMessageDWORD(DWORD errorCode) { ShowErrorMessageDWORD(0, errorCode); }
+void ShowLastErrorMessage(HWND window = 0);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/App.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/App.cpp
new file mode 100644
index 000000000..a6103f404
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/App.cpp
@@ -0,0 +1,910 @@
+// App.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+#include "OverwriteDialogRes.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/COM.h"
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+#include "Windows/Thread.h"
+
+#include "App.h"
+#include "CopyDialog.h"
+#include "ExtractCallback.h"
+#include "FormatUtils.h"
+#include "IFolder.h"
+#include "LangUtils.h"
+#include "RegistryUtils.h"
+#include "ViewSettings.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+extern DWORD g_ComCtl32Version;
+extern HINSTANCE g_hInstance;
+
+static LPCWSTR kTempDirPrefix = L"7zE";
+
+void CPanelCallbackImp::OnTab()
+{
+ if (g_App.NumPanels != 1)
+ _app->Panels[1 - _index].SetFocusToList();
+ _app->RefreshTitle();
+}
+
+void CPanelCallbackImp::SetFocusToPath(int index)
+{
+ int newPanelIndex = index;
+ if (g_App.NumPanels == 1)
+ newPanelIndex = g_App.LastFocusedPanel;
+ // FIXME _app->Panels[newPanelIndex]._headerComboBox.SetFocus();
+ _app->RefreshTitle();
+}
+
+
+void CPanelCallbackImp::OnCopy(bool move, bool copyToSame) { _app->OnCopy(move, copyToSame, _index); }
+void CPanelCallbackImp::OnSetSameFolder() { _app->OnSetSameFolder(_index); }
+void CPanelCallbackImp::OnSetSubFolder() { _app->OnSetSubFolder(_index); }
+void CPanelCallbackImp::PanelWasFocused() { _app->SetFocusedPanel(_index); _app->RefreshTitle(_index); }
+void CPanelCallbackImp::DragBegin() { /* FIXME _app->DragBegin(_index);*/ }
+void CPanelCallbackImp::DragEnd() { /* FIXME _app->DragEnd();*/ }
+void CPanelCallbackImp::RefreshTitle(bool always) { _app->RefreshTitle(_index, always); }
+
+void CApp::SetListSettings()
+{
+ bool showDots = ReadShowDots();
+ bool showRealFileIcons = ReadShowRealFileIcons();
+
+ DWORD extendedStyle =0; /* FIXME = LVS_EX_HEADERDRAGDROP;
+ if (ReadFullRow())
+ extendedStyle |= LVS_EX_FULLROWSELECT;
+ if (ReadShowGrid())
+ extendedStyle |= LVS_EX_GRIDLINES;
+ */
+ bool mySelectionMode = ReadAlternativeSelection();
+
+ /*
+ if (ReadSingleClick())
+ {
+ extendedStyle |= LVS_EX_ONECLICKACTIVATE
+ | LVS_EX_TRACKSELECT;
+ if (ReadUnderline())
+ extendedStyle |= LVS_EX_UNDERLINEHOT;
+ }
+ */
+
+ for (int i = 0; i < kNumPanelsMax; i++)
+ {
+ CPanel &panel = Panels[i];
+ panel._mySelectMode = mySelectionMode;
+ panel._showDots = showDots;
+ panel._showRealFileIcons = showRealFileIcons;
+ panel._exStyle = extendedStyle;
+
+ /* FIXME
+ DWORD style = (DWORD)panel._listView.GetStyle();
+ if (mySelectionMode)
+ style |= LVS_SINGLESEL;
+ else
+ style &= ~LVS_SINGLESEL;
+ panel._listView.SetStyle(style);
+ */
+ panel.SetExtendedStyle();
+ }
+}
+
+void CApp::SetShowSystemMenu()
+{
+ ShowSystemMenu = ReadShowSystemMenu();
+}
+
+void CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted)
+{
+ if (PanelsCreated[panelIndex])
+ return;
+ m_PanelCallbackImp[panelIndex].Init(this, panelIndex);
+ UString path;
+ if (mainPath.IsEmpty())
+ {
+ if (!::ReadPanelPath(panelIndex, path))
+ path.Empty();
+ }
+ else
+ path = mainPath;
+ int id = 1000 + 100 * panelIndex;
+ Panels[panelIndex].Create(_window, _window,
+ id, path, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted);
+ PanelsCreated[panelIndex] = true;
+}
+
+#if _WIN32
+static void CreateToolbar(
+ HWND parent,
+ NWindows::NControl::CImageList &imageList,
+ NWindows::NControl::CToolBar &toolBar,
+ bool LargeButtons)
+{
+ toolBar.Attach(::CreateWindowEx(0,
+ TOOLBARCLASSNAME,
+ NULL, 0
+ | WS_VISIBLE
+ | TBSTYLE_FLAT
+ | TBSTYLE_TOOLTIPS
+ | WS_CHILD
+ | CCS_NOPARENTALIGN
+ | CCS_NORESIZE
+ | CCS_NODIVIDER
+ // | TBSTYLE_AUTOSIZE
+ // | CCS_ADJUSTABLE
+ ,0,0,0,0, parent, NULL, g_hInstance, NULL));
+
+ // TB_BUTTONSTRUCTSIZE message, which is required for
+ // backward compatibility.
+ toolBar.ButtonStructSize();
+
+ imageList.Create(
+ LargeButtons ? 48: 24,
+ LargeButtons ? 36: 24,
+ ILC_MASK, 0, 0);
+ toolBar.SetImageList(0, imageList);
+}
+#endif
+
+struct CButtonInfo
+{
+ UINT commandID;
+ UINT BitmapResID;
+ UINT Bitmap2ResID;
+ UINT StringResID;
+ UINT32 LangID;
+ UString GetText()const { return LangString(StringResID, LangID); };
+};
+
+static CButtonInfo g_StandardButtons[] =
+{
+ { IDM_COPY_TO, IDB_COPY, IDB_COPY2, IDS_BUTTON_COPY, 0x03020420},
+ { IDM_MOVE_TO, IDB_MOVE, IDB_MOVE2, IDS_BUTTON_MOVE, 0x03020421},
+ { IDM_DELETE, IDB_DELETE, IDB_DELETE2, IDS_BUTTON_DELETE, 0x03020422} ,
+ { IDM_FILE_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO, 0x03020423}
+};
+
+static CButtonInfo g_ArchiveButtons[] =
+{
+ { kAddCommand, IDB_ADD, IDB_ADD2, IDS_ADD, 0x03020400},
+ { kExtractCommand, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT, 0x03020401},
+ { kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402}
+};
+
+bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, UString &s)
+{
+ for (int i = 0; i < numButtons; i++)
+ {
+ const CButtonInfo &b = buttons[i];
+ if (b.commandID == commandID)
+ {
+ s = b.GetText();
+ return true;
+ }
+ }
+ return false;
+}
+
+void SetButtonText(UINT32 commandID, UString &s)
+{
+ if (SetButtonText(commandID, g_StandardButtons,
+ sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s))
+ return;
+ SetButtonText(commandID, g_ArchiveButtons,
+ sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s);
+}
+
+#ifdef _WIN32
+static void AddButton(
+ NControl::CImageList &imageList,
+ NControl::CToolBar &toolBar,
+ CButtonInfo &butInfo,
+ bool showText,
+ bool large)
+{
+ TBBUTTON but;
+ but.iBitmap = 0;
+ but.idCommand = butInfo.commandID;
+ but.fsState = TBSTATE_ENABLED;
+ but.fsStyle = BTNS_BUTTON
+ // | BTNS_AUTOSIZE
+ ;
+ but.dwData = 0;
+
+ UString s = butInfo.GetText();
+ but.iString = 0;
+ if (showText)
+ but.iString = (INT_PTR)(LPCWSTR)s;
+
+ but.iBitmap = imageList.GetImageCount();
+ HBITMAP b = ::LoadBitmap(g_hInstance,
+ large ?
+ MAKEINTRESOURCE(butInfo.BitmapResID):
+ MAKEINTRESOURCE(butInfo.Bitmap2ResID));
+ if (b != 0)
+ {
+ imageList.AddMasked(b, RGB(255, 0, 255));
+ ::DeleteObject(b);
+ }
+ #ifdef _UNICODE
+ toolBar.AddButton(1, &but);
+ #else
+ toolBar.AddButtonW(1, &but);
+ #endif
+}
+
+static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar)
+{
+ SIZE size;
+ toolBar.GetMaxSize(&size);
+
+ RECT rect;
+ toolBar.GetWindowRect(&rect);
+
+ REBARBANDINFO rbBand;
+ rbBand.cbSize = sizeof(REBARBANDINFO); // Required
+ rbBand.fMask = RBBIM_STYLE
+ | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
+ rbBand.fStyle = RBBS_CHILDEDGE; // RBBS_NOGRIPPER;
+ rbBand.cxMinChild = size.cx; // rect.right - rect.left;
+ rbBand.cyMinChild = size.cy; // rect.bottom - rect.top;
+ rbBand.cyChild = rbBand.cyMinChild;
+ rbBand.cx = rbBand.cxMinChild;
+ rbBand.cxIdeal = rbBand.cxMinChild;
+ rbBand.hwndChild = toolBar;
+ reBar.InsertBand(-1, &rbBand);
+}
+
+void CApp::ReloadToolbars()
+{
+ if (!_rebar)
+ return;
+ HWND parent = _rebar;
+
+ while(_rebar.GetBandCount() > 0)
+ _rebar.DeleteBand(0);
+
+ _archiveToolBar.Destroy();
+ _archiveButtonsImageList.Destroy();
+
+ _standardButtonsImageList.Destroy();
+ _standardToolBar.Destroy();
+
+ if (ShowArchiveToolbar)
+ {
+ CreateToolbar(parent, _archiveButtonsImageList, _archiveToolBar, LargeButtons);
+ for (int i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++)
+ AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i],
+ ShowButtonsLables, LargeButtons);
+ AddBand(_rebar, _archiveToolBar);
+ }
+
+ if (ShowStandardToolbar)
+ {
+ CreateToolbar(parent, _standardButtonsImageList, _standardToolBar, LargeButtons);
+ for (int i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++)
+ AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i],
+ ShowButtonsLables, LargeButtons);
+ AddBand(_rebar, _standardToolBar);
+ }
+}
+#endif
+
+void CApp::ReloadRebar(HWND hwnd)
+{
+#ifdef _WIN32
+ _rebar.Destroy();
+ if (!ShowArchiveToolbar && !ShowStandardToolbar)
+ return;
+ if (g_ComCtl32Version >= MAKELONG(71, 4))
+ {
+ INITCOMMONCONTROLSEX icex;
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ _rebar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
+ REBARCLASSNAME,
+ NULL,
+ WS_VISIBLE
+ | WS_BORDER
+ | WS_CHILD
+ | WS_CLIPCHILDREN
+ | WS_CLIPSIBLINGS
+ // | CCS_NODIVIDER
+ // | CCS_NOPARENTALIGN // it's bead for moveing of two bands
+ // | CCS_TOP
+ | RBS_VARHEIGHT
+ | RBS_BANDBORDERS
+ // | RBS_AUTOSIZE
+ ,0,0,0,0, hwnd, NULL, g_hInstance, NULL));
+ }
+ if (_rebar == 0)
+ return;
+ REBARINFO rbi;
+ rbi.cbSize = sizeof(REBARINFO); // Required when using this struct.
+ rbi.fMask = 0;
+ rbi.himl = (HIMAGELIST)NULL;
+ _rebar.SetBarInfo(&rbi);
+ ReloadToolbars();
+#endif // #ifdef _WIN32
+}
+
+void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted)
+{
+#ifdef _WIN32
+ ReadToolbar();
+ ReloadRebar(hwnd);
+#endif
+
+ int i;
+ for (i = 0; i < kNumPanelsMax; i++)
+ PanelsCreated[i] = false;
+
+ _window.Attach(hwnd);
+ AppState.Read();
+ SetListSettings();
+ SetShowSystemMenu();
+ if (LastFocusedPanel >= kNumPanelsMax)
+ LastFocusedPanel = 0;
+
+ CListMode listMode;
+ ReadListMode(listMode);
+ for (i = 0; i < kNumPanelsMax; i++)
+ {
+ Panels[i]._ListViewMode = listMode.Panels[i];
+ Panels[i]._xSize = xSizes[i];
+ }
+ for (i = 0; i < kNumPanelsMax; i++)
+ if (NumPanels > 1 || i == LastFocusedPanel)
+ {
+ if (NumPanels == 1)
+ Panels[i]._xSize = xSizes[0] + xSizes[1];
+ bool archiveIsOpened2 = false;
+ bool encrypted2 = false;
+ bool mainPanel = (i == LastFocusedPanel);
+ CreateOnePanel(i, mainPanel ? mainPath : L"", archiveIsOpened2, encrypted2);
+ if (mainPanel)
+ {
+ archiveIsOpened = archiveIsOpened2;
+ encrypted = encrypted2;
+ }
+ }
+ SetFocusedPanel(LastFocusedPanel);
+ Panels[LastFocusedPanel].SetFocusToList();
+}
+
+extern void MoveSubWindows(HWND hWnd);
+
+void CApp::SwitchOnOffOnePanel()
+{
+ if (NumPanels == 1)
+ {
+ NumPanels++;
+ bool archiveIsOpened, encrypted;
+ CreateOnePanel(1 - LastFocusedPanel, UString(), archiveIsOpened, encrypted);
+ // FIXME Panels[1 - LastFocusedPanel].Enable(true);
+ // FIXME Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
+ }
+ else
+ {
+ NumPanels--;
+ // FIXME Panels[1 - LastFocusedPanel].Enable(false);
+ // FIXME Panels[1 - LastFocusedPanel].Show(SW_HIDE);
+ }
+ MoveSubWindows(_window);
+}
+
+void CApp::Save()
+{
+ AppState.Save();
+ CListMode listMode;
+ for (int i = 0; i < kNumPanelsMax; i++)
+ {
+ const CPanel &panel = Panels[i];
+ UString path;
+ if (panel._parentFolders.IsEmpty())
+ path = panel._currentFolderPrefix;
+ else
+ path = GetFolderPath(panel._parentFolders[0].ParentFolder);
+ SavePanelPath(i, path);
+ listMode.Panels[i] = panel.GetListViewMode();
+ }
+ SaveListMode(listMode);
+}
+
+void CApp::Release()
+{
+ // It's for unloading COM dll's: don't change it.
+ for (int i = 0; i < kNumPanelsMax; i++)
+ Panels[i].Release();
+}
+
+static bool IsThereFolderOfPath(const UString &path)
+{
+ CFileInfoW fileInfo;
+ if (!FindFile(path, fileInfo))
+ return false;
+ return fileInfo.IsDir();
+}
+
+// reduces path to part that exists on disk
+static void ReducePathToRealFileSystemPath(UString &path)
+{
+ while(!path.IsEmpty())
+ {
+ if (IsThereFolderOfPath(path))
+ {
+ NName::NormalizeDirPathPrefix(path);
+ break;
+ }
+ int pos = path.ReverseFind(CHAR_PATH_SEPARATOR);
+ if (pos < 0)
+ path.Empty();
+ else
+ {
+ path = path.Left(pos + 1);
+ if (path.Length() == 3 && path[1] == L':')
+ break;
+ if (path.Length() > 2 && path[0] == CHAR_PATH_SEPARATOR && path[1] == CHAR_PATH_SEPARATOR)
+ {
+ int nextPos = path.Find(CHAR_PATH_SEPARATOR, 2); // pos after \\COMPNAME
+ if (nextPos > 0 && path.Find(CHAR_PATH_SEPARATOR, nextPos + 1) == pos)
+ break;
+ }
+ path = path.Left(pos);
+ }
+ }
+}
+
+// return true for dir\, if dir exist
+static bool CheckFolderPath(const UString &path)
+{
+ UString pathReduced = path;
+ ReducePathToRealFileSystemPath(pathReduced);
+ return (pathReduced == path);
+}
+
+static bool IsPathAbsolute(const UString &path)
+{
+ if ((path.Length() >= 1 && path[0] == WCHAR_PATH_SEPARATOR) ||
+ (path.Length() >= 3 && path[1] == L':' && path[2] == WCHAR_PATH_SEPARATOR))
+ return true;
+ return false;
+}
+
+extern UString ConvertSizeToString(UInt64 value);
+
+static UString AddSizeValue(UInt64 size)
+{
+ return MyFormatNew(IDS_FILE_SIZE, 0x02000982, ConvertSizeToString(size));
+}
+
+static void AddValuePair1(UINT resourceID, UInt32 langID, UInt64 size, UString &s)
+{
+ s += LangString(resourceID, langID);
+ s += L" ";
+ s += AddSizeValue(size);
+ s += L"\n";
+}
+
+void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s)
+{
+ if (num == 0)
+ return;
+ s += LangString(resourceID, langID);
+ s += L" ";
+ s += ConvertSizeToString(num);
+
+ if (size != (UInt64)(Int64)-1)
+ {
+ s += L" ( ";
+ s += AddSizeValue(size);
+ s += L" )";
+ }
+ s += L"\n";
+}
+
+static void AddPropValueToSum(IFolderFolder *folder, int index, PROPID propID, UInt64 &sum)
+{
+ if (sum == (UInt64)(Int64)-1)
+ return;
+ NCOM::CPropVariant prop;
+ folder->GetProperty(index, propID, &prop);
+ switch(prop.vt)
+ {
+ case VT_UI4:
+ case VT_UI8:
+ sum += ConvertPropVariantToUInt64(prop);
+ break;
+ default:
+ sum = (UInt64)(Int64)-1;
+ }
+}
+
+UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
+{
+ UString info;
+ UInt64 numDirs, numFiles, filesSize, foldersSize;
+ numDirs = numFiles = filesSize = foldersSize = 0;
+ int i;
+ for (i = 0; i < indices.Size(); i++)
+ {
+ int index = indices[i];
+ if (IsItemFolder(index))
+ {
+ AddPropValueToSum(_folder, index, kpidSize, foldersSize);
+ numDirs++;
+ }
+ else
+ {
+ AddPropValueToSum(_folder, index, kpidSize, filesSize);
+ numFiles++;
+ }
+ }
+
+ AddValuePair2(IDS_FOLDERS_COLON, 0x02000321, numDirs, foldersSize, info);
+ AddValuePair2(IDS_FILES_COLON, 0x02000320, numFiles, filesSize, info);
+ int numDefined = ((foldersSize != (UInt64)(Int64)-1) && foldersSize != 0) ? 1: 0;
+ numDefined += ((filesSize != (UInt64)(Int64)-1) && filesSize != 0) ? 1: 0;
+ if (numDefined == 2)
+ AddValuePair1(IDS_SIZE_COLON, 0x02000322, filesSize + foldersSize, info);
+
+ info += L"\n";
+ info += _currentFolderPrefix;
+
+ for (i = 0; i < indices.Size() && i < kCopyDialog_NumInfoLines - 6; i++)
+ {
+ info += L"\n ";
+ int index = indices[i];
+ info += GetItemRelPath(index);
+ if (IsItemFolder(index))
+ info += L'\\';
+ }
+ if (i != indices.Size())
+ info += L"\n ...";
+ return info;
+}
+
+void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
+{
+ int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ CPanel &destPanel = Panels[destPanelIndex];
+
+ CPanel::CDisableTimerProcessing disableTimerProcessing1(destPanel);
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(srcPanel);
+
+ if (!srcPanel.DoesItSupportOperations())
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+
+ CRecordVector<UInt32> indices;
+ UString destPath;
+ bool useDestPanel = false;
+
+ {
+ if (copyToSame)
+ {
+ int focusedItem = srcPanel._listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = srcPanel.GetRealItemIndex(focusedItem);
+ if (realIndex == kParentIndex)
+ return;
+ indices.Add(realIndex);
+ destPath = srcPanel.GetItemName(realIndex);
+ }
+ else
+ {
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.Size() == 0)
+ return;
+ destPath = destPanel._currentFolderPrefix;
+ if (NumPanels == 1)
+ ReducePathToRealFileSystemPath(destPath);
+ }
+
+ CCopyDialog copyDialog;
+ UStringVector copyFolders;
+ ReadCopyHistory(copyFolders);
+
+ copyDialog.Strings = copyFolders;
+ copyDialog.Value = destPath;
+
+ copyDialog.Title = move ?
+ LangString(IDS_MOVE, 0x03020202):
+ LangString(IDS_COPY, 0x03020201);
+ copyDialog.Static = move ?
+ LangString(IDS_MOVE_TO, 0x03020204):
+ LangString(IDS_COPY_TO, 0x03020203);
+
+ copyDialog.Info = srcPanel.GetItemsInfoString(indices);
+
+ if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
+ return;
+
+ destPath = copyDialog.Value;
+
+ if (destPath.IsEmpty())
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+
+ if (!IsPathAbsolute(destPath))
+ {
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ destPath = srcPanel._currentFolderPrefix + destPath;
+ }
+
+ printf("destPath='%ls'\n",(const wchar_t *)destPath);
+#ifdef _WIN32
+ if (destPath.Length() > 0 && destPath[0] == CHAR_PATH_SEPARATOR)
+ if (destPath.Length() == 1 || destPath[1] != CHAR_PATH_SEPARATOR)
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+#endif
+
+ if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind(CHAR_PATH_SEPARATOR) == destPath.Length() - 1) ||
+ IsThereFolderOfPath(destPath))
+ {
+ NDirectory::CreateComplexDirectory(destPath);
+ NName::NormalizeDirPathPrefix(destPath);
+ if (!CheckFolderPath(destPath))
+ {
+ if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ useDestPanel = true;
+ }
+ }
+ else
+ {
+ int pos = destPath.ReverseFind(CHAR_PATH_SEPARATOR);
+ if (pos >= 0)
+ {
+ UString prefix = destPath.Left(pos + 1);
+ NDirectory::CreateComplexDirectory(prefix);
+ if (!CheckFolderPath(prefix))
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ }
+ }
+
+ AddUniqueStringToHeadOfList(copyFolders, destPath);
+ while (copyFolders.Size() > 20)
+ copyFolders.DeleteBack();
+ SaveCopyHistory(copyFolders);
+ }
+
+ bool useSrcPanel = (!useDestPanel || !srcPanel.IsFSFolder() || destPanel.IsFSFolder());
+ bool useTemp = useSrcPanel && useDestPanel;
+ // FIXME NFile::NDirectory::CTempDirectoryW tempDirectory;
+ UString tempDirPrefix;
+ if (useTemp)
+ {
+ /* FIXME
+ tempDirectory.Create(kTempDirPrefix);
+ tempDirPrefix = tempDirectory.GetPath();
+ NFile::NName::NormalizeDirPathPrefix(tempDirPrefix);
+ */
+ printf("useTemp : Not Implemented\n");
+ exit(EXIT_FAILURE);
+ }
+
+ CSelectedState srcSelState;
+ CSelectedState destSelState;
+ srcPanel.SaveSelectedState(srcSelState);
+ destPanel.SaveSelectedState(destSelState);
+
+ HRESULT result;
+ if (useSrcPanel)
+ {
+ UString folder = useTemp ? tempDirPrefix : destPath;
+ result = srcPanel.CopyTo(indices, folder, move, true, 0);
+ if (result != S_OK)
+ {
+ disableTimerProcessing1.Restore();
+ disableTimerProcessing2.Restore();
+ // For Password:
+ srcPanel.SetFocusToList();
+ if (result != E_ABORT)
+ srcPanel.MessageBoxError(result, L"Error");
+ return;
+ }
+ }
+
+ if (useDestPanel)
+ {
+ UStringVector filePaths;
+ UString folderPrefix;
+ if (useTemp)
+ folderPrefix = tempDirPrefix;
+ else
+ folderPrefix = srcPanel._currentFolderPrefix;
+ filePaths.Reserve(indices.Size());
+ for(int i = 0; i < indices.Size(); i++)
+ filePaths.Add(srcPanel.GetItemRelPath(indices[i]));
+
+ result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0);
+
+ if (result != S_OK)
+ {
+ disableTimerProcessing1.Restore();
+ disableTimerProcessing2.Restore();
+ // For Password:
+ srcPanel.SetFocusToList();
+ if (result != E_ABORT)
+ srcPanel.MessageBoxError(result, L"Error");
+ return;
+ }
+ }
+
+ RefreshTitleAlways();
+ if (copyToSame || move)
+ {
+ srcPanel.RefreshListCtrl(srcSelState);
+ }
+ if (!copyToSame)
+ {
+ destPanel.RefreshListCtrl(destSelState);
+ srcPanel.KillSelection();
+ }
+ disableTimerProcessing1.Restore();
+ disableTimerProcessing2.Restore();
+ srcPanel.SetFocusToList();
+}
+
+void CApp::OnSetSameFolder(int srcPanelIndex)
+{
+ if (NumPanels <= 1)
+ return;
+ const CPanel &srcPanel = Panels[srcPanelIndex];
+ CPanel &destPanel = Panels[1 - srcPanelIndex];
+ destPanel.BindToPathAndRefresh(srcPanel._currentFolderPrefix);
+}
+
+void CApp::OnSetSubFolder(int srcPanelIndex)
+{
+ if (NumPanels <= 1)
+ return;
+ const CPanel &srcPanel = Panels[srcPanelIndex];
+ CPanel &destPanel = Panels[1 - srcPanelIndex];
+
+ int focusedItem = srcPanel._listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = srcPanel.GetRealItemIndex(focusedItem);
+ if (!srcPanel.IsItemFolder(realIndex))
+ return;
+
+
+ /*
+ UString string = srcPanel._currentFolderPrefix +
+ srcPanel.GetItemName(realIndex) + WCHAR_PATH_SEPARATOR;
+ destPanel.BindToFolder(string);
+ */
+ CMyComPtr<IFolderFolder> newFolder;
+ if (realIndex == kParentIndex)
+ {
+ if (srcPanel._folder->BindToParentFolder(&newFolder) != S_OK)
+ return;
+ }
+ else
+ {
+ if (srcPanel._folder->BindToFolder(realIndex, &newFolder) != S_OK)
+ return;
+ }
+ destPanel.CloseOpenFolders();
+ destPanel._folder = newFolder;
+ destPanel.RefreshListCtrl();
+}
+
+/*
+int CApp::GetFocusedPanelIndex() const
+{
+ return LastFocusedPanel;
+ HWND hwnd = ::GetFocus();
+ for (;;)
+ {
+ if (hwnd == 0)
+ return 0;
+ for (int i = 0; i < kNumPanelsMax; i++)
+ {
+ if (PanelsCreated[i] &&
+ ((HWND)Panels[i] == hwnd || Panels[i]._listView == hwnd))
+ return i;
+ }
+ hwnd = GetParent(hwnd);
+ }
+}
+ */
+
+static UString g_ToolTipBuffer;
+static CSysString g_ToolTipBufferSys;
+
+#ifdef _WIN32
+void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
+{
+ if (pnmh->hwndFrom == _rebar)
+ {
+ switch(pnmh->code)
+ {
+ case RBN_HEIGHTCHANGE:
+ {
+ MoveSubWindows(g_HWND);
+ return;
+ }
+ }
+ return ;
+ }
+ else
+ {
+ if (pnmh->code == TTN_GETDISPINFO)
+ {
+ LPNMTTDISPINFO info = (LPNMTTDISPINFO)pnmh;
+ info->hinst = 0;
+ g_ToolTipBuffer.Empty();
+ SetButtonText((UINT32)info->hdr.idFrom, g_ToolTipBuffer);
+ g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
+ info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBufferSys;
+ return;
+ }
+ #ifndef _UNICODE
+ if (pnmh->code == TTN_GETDISPINFOW)
+ {
+ LPNMTTDISPINFOW info = (LPNMTTDISPINFOW)pnmh;
+ info->hinst = 0;
+ g_ToolTipBuffer.Empty();
+ SetButtonText((UINT32)info->hdr.idFrom, g_ToolTipBuffer);
+ info->lpszText = (LPWSTR)(LPCWSTR)g_ToolTipBuffer;
+ return;
+ }
+ #endif
+ }
+}
+#endif
+
+void CApp::RefreshTitle(bool always)
+{
+ UString path = GetFocusedPanel()._currentFolderPrefix;
+ if (path.IsEmpty())
+ path += LangString(IDS_APP_TITLE, 0x03000000);
+ if (!always && path == PrevTitle)
+ return;
+ PrevTitle = path;
+ NWindows::MySetWindowText(_window, path);
+}
+
+void CApp::RefreshTitle(int panelIndex, bool always)
+{
+ if (panelIndex != GetFocusedPanelIndex())
+ return;
+ RefreshTitle(always);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/App.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/App.h
new file mode 100644
index 000000000..f0c9a933f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/App.h
@@ -0,0 +1,344 @@
+// App.h
+
+#ifndef __APP_H
+#define __APP_H
+
+#include "Panel.h"
+#include "AppState.h"
+// FIXME #include "Windows/Control/ImageList.h"
+
+class CApp;
+
+extern CApp g_App;
+extern HWND g_HWND;
+
+const int kNumPanelsMax = 2;
+
+extern void MoveSubWindows(HWND hWnd);
+
+enum
+{
+ kAddCommand = kToolbarStartID,
+ kExtractCommand,
+ kTestCommand
+};
+
+class CPanelCallbackImp: public CPanelCallback
+{
+ CApp *_app;
+ int _index;
+public:
+ void Init(CApp *app, int index)
+ {
+ _app = app;
+ _index = index;
+ }
+ virtual void OnTab();
+ virtual void SetFocusToPath(int index);
+ virtual void OnCopy(bool move, bool copyToSame);
+ virtual void OnSetSameFolder();
+ virtual void OnSetSubFolder();
+ virtual void PanelWasFocused();
+ virtual void DragBegin();
+ virtual void DragEnd();
+ virtual void RefreshTitle(bool always);
+};
+
+class CApp;
+
+#if _WIN32
+class CDropTarget:
+ public IDropTarget,
+ public CMyUnknownImp
+{
+ CMyComPtr<IDataObject> m_DataObject;
+ UStringVector m_SourcePaths;
+ int m_SelectionIndex;
+ bool m_DropIsAllowed; // = true, if data contain fillist
+ bool m_PanelDropIsAllowed; // = false, if current target_panel is source_panel.
+ // check it only if m_DropIsAllowed == true
+ int m_SubFolderIndex;
+ UString m_SubFolderName;
+
+ CPanel *m_Panel;
+ bool m_IsAppTarget; // true, if we want to drop to app window (not to panel).
+
+ bool m_SetPathIsOK;
+
+ bool IsItSameDrive() const;
+
+ void QueryGetData(IDataObject *dataObject);
+ bool IsFsFolderPath() const;
+ DWORD GetEffect(DWORD keyState, POINTL pt, DWORD allowedEffect);
+ void RemoveSelection();
+ void PositionCursor(POINTL ptl);
+ UString GetTargetPath() const;
+ bool SetPath(bool enablePath) const;
+ bool SetPath();
+
+public:
+ MY_UNKNOWN_IMP1_MT(IDropTarget)
+ STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState,
+ POINTL pt, DWORD *effect);
+ STDMETHOD(DragOver)(DWORD keyState, POINTL pt, DWORD * effect);
+ STDMETHOD(DragLeave)();
+ STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState,
+ POINTL pt, DWORD *effect);
+
+ CDropTarget():
+ TargetPanelIndex(-1),
+ SrcPanelIndex(-1),
+ m_IsAppTarget(false),
+ m_Panel(0),
+ App(0),
+ m_PanelDropIsAllowed(false),
+ m_DropIsAllowed(false),
+ m_SelectionIndex(-1),
+ m_SubFolderIndex(-1),
+ m_SetPathIsOK(false) {}
+
+ CApp *App;
+ int SrcPanelIndex; // index of D&D source_panel
+ int TargetPanelIndex; // what panel to use as target_panel of Application
+};
+#endif
+
+class CApp
+{
+public:
+ NWindows::CWindow _window;
+ bool ShowSystemMenu;
+ int NumPanels;
+ int LastFocusedPanel;
+
+ bool ShowStandardToolbar;
+ bool ShowArchiveToolbar;
+ bool ShowButtonsLables;
+ bool LargeButtons;
+
+ CAppState AppState;
+ CPanelCallbackImp m_PanelCallbackImp[kNumPanelsMax];
+ CPanel Panels[kNumPanelsMax];
+ bool PanelsCreated[kNumPanelsMax];
+
+#ifdef _WIN32
+ NWindows::NControl::CImageList _archiveButtonsImageList;
+ NWindows::NControl::CImageList _standardButtonsImageList;
+
+ NWindows::NControl::CReBar _rebar;
+ NWindows::NControl::CToolBar _archiveToolBar;
+ NWindows::NControl::CToolBar _standardToolBar;
+
+ CDropTarget *_dropTargetSpec;
+ CMyComPtr<IDropTarget> _dropTarget;
+
+ void CreateDragTarget()
+ {
+ _dropTargetSpec = new CDropTarget();
+ _dropTarget = _dropTargetSpec;
+ _dropTargetSpec->App = (this);
+ }
+#endif
+
+ void SetFocusedPanel(int index)
+ {
+ LastFocusedPanel = index;
+ // FIXME _dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
+ }
+
+#ifdef _WIN32
+ void DragBegin(int panelIndex)
+ {
+ _dropTargetSpec->TargetPanelIndex = (NumPanels > 1) ? 1 - panelIndex : panelIndex;
+ _dropTargetSpec->SrcPanelIndex = panelIndex;
+ }
+
+ void DragEnd()
+ {
+ _dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
+ _dropTargetSpec->SrcPanelIndex = -1;
+ }
+#endif
+
+
+ void OnCopy(bool move, bool copyToSame, int srcPanelIndex);
+ void OnSetSameFolder(int srcPanelIndex);
+ void OnSetSubFolder(int srcPanelIndex);
+
+ void CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted);
+ void Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted);
+ void Read();
+ void Save();
+ void Release();
+
+
+ /*
+ void SetFocus(int panelIndex)
+ { Panels[panelIndex].SetFocusToList(); }
+ */
+ void SetFocusToLastItem()
+ { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); }
+
+ int GetFocusedPanelIndex() const { return LastFocusedPanel; }
+
+ bool IsPanelVisible(int index) const { return (NumPanels > 1 || index == LastFocusedPanel); }
+
+ /*
+ void SetCurrentIndex()
+ { CurrentPanel = GetFocusedPanelIndex(); }
+ */
+
+ CApp(): NumPanels(2), LastFocusedPanel(0) {}
+ CPanel &GetFocusedPanel()
+ { return Panels[GetFocusedPanelIndex()]; }
+
+ // File Menu
+ void OpenItem()
+ { GetFocusedPanel().OpenSelectedItems(true); }
+ void OpenItemInside()
+ { GetFocusedPanel().OpenFocusedItemAsInternal(); }
+ void OpenItemOutside()
+ { GetFocusedPanel().OpenSelectedItems(false); }
+ void EditItem()
+ { GetFocusedPanel().EditItem(); }
+ void Rename()
+ { GetFocusedPanel().RenameFile(); }
+ void CopyTo()
+ { OnCopy(false, false, GetFocusedPanelIndex()); }
+ void MoveTo()
+ { OnCopy(true, false, GetFocusedPanelIndex()); }
+ void Delete(bool toRecycleBin)
+ { GetFocusedPanel().DeleteItems(toRecycleBin); }
+ void CalculateCrc();
+ void Split();
+ void Combine();
+ void Properties()
+ { GetFocusedPanel().Properties(); }
+ void Comment()
+ { GetFocusedPanel().ChangeComment(); }
+
+ void CreateFolder()
+ { GetFocusedPanel().CreateFolder(); }
+ void CreateFile()
+ { GetFocusedPanel().CreateFile(); }
+
+ // Edit
+ void EditCut()
+ { GetFocusedPanel().EditCut(); }
+ void EditCopy()
+ { GetFocusedPanel().EditCopy(); }
+ void EditPaste()
+ { GetFocusedPanel().EditPaste(); }
+
+ void SelectAll(bool selectMode)
+ { GetFocusedPanel().SelectAll(selectMode); }
+ void InvertSelection()
+ { GetFocusedPanel().InvertSelection(); }
+ void SelectSpec(bool selectMode)
+ { GetFocusedPanel().SelectSpec(selectMode); }
+ void SelectByType(bool selectMode)
+ { GetFocusedPanel().SelectByType(selectMode); }
+
+ void RefreshStatusBar()
+ { GetFocusedPanel().RefreshStatusBar(); }
+
+ void SetListViewMode(UINT32 index)
+ { GetFocusedPanel().SetListViewMode(index); }
+ UINT32 GetListViewMode()
+ { return GetFocusedPanel().GetListViewMode(); }
+
+ void SortItemsWithPropID(PROPID propID)
+ { GetFocusedPanel().SortItemsWithPropID(propID); }
+
+ void OpenRootFolder()
+ { GetFocusedPanel().OpenDrivesFolder(); }
+ void OpenParentFolder()
+ { GetFocusedPanel().OpenParentFolder(); }
+ void FoldersHistory()
+ { GetFocusedPanel().FoldersHistory(); }
+ void RefreshView()
+ { GetFocusedPanel().OnReload(); }
+ void RefreshAllPanels()
+ {
+ for (int i = 0; i < NumPanels; i++)
+ {
+ int index = i;
+ if (NumPanels == 1)
+ index = LastFocusedPanel;
+ Panels[index].OnReload();
+ }
+ }
+ void SetListSettings();
+ void SetShowSystemMenu();
+ void SwitchOnOffOnePanel();
+ bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); }
+ void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); }
+
+ void OpenBookmark(int index)
+ { GetFocusedPanel().OpenBookmark(index); }
+ void SetBookmark(int index)
+ { GetFocusedPanel().SetBookmark(index); }
+
+ void ReloadRebar(HWND hwnd);
+ void ReloadToolbars();
+ void ReadToolbar()
+ {
+ UINT32 mask = ReadToolbarsMask();
+ ShowButtonsLables = ((mask & 1) != 0);
+ LargeButtons = ((mask & 2) != 0);
+ ShowStandardToolbar = ((mask & 4) != 0);
+ ShowArchiveToolbar = ((mask & 8) != 0);
+ }
+ void SaveToolbar()
+ {
+ UINT32 mask = 0;
+ if (ShowButtonsLables) mask |= 1;
+ if (LargeButtons) mask |= 2;
+ if (ShowStandardToolbar) mask |= 4;
+ if (ShowArchiveToolbar) mask |= 8;
+ SaveToolbarsMask(mask);
+ }
+ void SwitchStandardToolbar()
+ {
+ ShowStandardToolbar = !ShowStandardToolbar;
+ SaveToolbar();
+ ReloadRebar(g_HWND);
+ MoveSubWindows(_window);
+ }
+ void SwitchArchiveToolbar()
+ {
+ ShowArchiveToolbar = !ShowArchiveToolbar;
+ SaveToolbar();
+ ReloadRebar(g_HWND);
+ MoveSubWindows(_window);
+ }
+ void SwitchButtonsLables()
+ {
+ ShowButtonsLables = !ShowButtonsLables;
+ SaveToolbar();
+ ReloadRebar(g_HWND);
+ MoveSubWindows(_window);
+ }
+ void SwitchLargeButtons()
+ {
+ LargeButtons = !LargeButtons;
+ SaveToolbar();
+ ReloadRebar(g_HWND);
+ MoveSubWindows(_window);
+ }
+
+ void AddToArchive() { GetFocusedPanel().AddToArchive(); }
+ void ExtractArchives() { GetFocusedPanel().ExtractArchives(); }
+ void TestArchives() { GetFocusedPanel().TestArchives(); }
+
+#ifdef _WIN32
+ void OnNotify(int ctrlID, LPNMHDR pnmh);
+#endif
+
+ UString PrevTitle;
+ void RefreshTitle(bool always = false);
+ void RefreshTitleAlways() { RefreshTitle(true); }
+ void RefreshTitle(int panelIndex, bool always = false);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/AppState.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/AppState.h
new file mode 100644
index 000000000..7b59d4547
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/AppState.h
@@ -0,0 +1,114 @@
+// AppState.h
+
+#ifndef __APPSTATE_H
+#define __APPSTATE_H
+
+#include "Windows/Synchronization.h"
+
+void inline AddUniqueStringToHead(UStringVector &list,
+ const UString &string)
+{
+ for(int i = 0; i < list.Size();)
+ if (string.CompareNoCase(list[i]) == 0)
+ list.Delete(i);
+ else
+ i++;
+ list.Insert(0, string);
+}
+
+class CFastFolders
+{
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+public:
+ UStringVector Strings;
+ void SetString(int index, const UString &string)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ while(Strings.Size() <= index)
+ Strings.Add(UString());
+ Strings[index] = string;
+ }
+ UString GetString(int index)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ if (index >= Strings.Size())
+ return UString();
+ return Strings[index];
+ }
+ void Save()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ SaveFastFolders(Strings);
+ }
+ void Read()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ ReadFastFolders(Strings);
+ }
+};
+
+class CFolderHistory
+{
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+ UStringVector Strings;
+ void Normalize()
+ {
+ const int kMaxSize = 100;
+ if (Strings.Size() > kMaxSize)
+ Strings.Delete(kMaxSize, Strings.Size() - kMaxSize);
+ }
+
+public:
+
+ void GetList(UStringVector &foldersHistory)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ foldersHistory = Strings;
+ }
+
+ void AddString(const UString &string)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ AddUniqueStringToHead(Strings, string);
+ Normalize();
+ }
+
+ void RemoveAll()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ Strings.Clear();
+ }
+
+ void Save()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ SaveFolderHistory(Strings);
+ }
+
+ void Read()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ ReadFolderHistory(Strings);
+ Normalize();
+ }
+};
+
+struct CAppState
+{
+ CFastFolders FastFolders;
+ CFolderHistory FolderHistory;
+ void Save()
+ {
+ FastFolders.Save();
+ FolderHistory.Save();
+ }
+ void Read()
+ {
+ FastFolders.Read();
+ FolderHistory.Read();
+ }
+};
+
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ClassDefs.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ClassDefs.cpp
new file mode 100644
index 000000000..5b4401a10
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ClassDefs.cpp
@@ -0,0 +1,17 @@
+// ClassDefs.cpp
+
+#include "StdAfx.h"
+
+#include <initguid.h>
+
+#include "IFolder.h"
+#include "../../IPassword.h"
+#include "PluginInterface.h"
+#include "ExtractCallback.h"
+#include "../../ICoder.h"
+
+#include "../Agent/Agent.h"
+
+// {23170F69-40C1-278A-1000-000100020000}
+DEFINE_GUID(CLSID_CZipContextMenu,
+0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog.cpp
new file mode 100644
index 000000000..807a5dd25
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog.cpp
@@ -0,0 +1,53 @@
+// ComboDialog.cpp
+
+#include "StdAfx.h"
+#include "ComboDialog.h"
+
+#include "Windows/Control/Static.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+bool CComboDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _comboBox.Attach(GetItem(IDC_COMBO_COMBO));
+
+ /*
+ // why it doesn't work ?
+ DWORD style = _comboBox.GetStyle();
+ if (Sorted)
+ style |= CBS_SORT;
+ else
+ style &= ~CBS_SORT;
+ _comboBox.SetStyle(style);
+ */
+ SetText(Title);
+
+ NControl::CStatic staticContol;
+ staticContol.Attach(GetItem(IDC_COMBO_STATIC));
+ staticContol.SetText(Static);
+ _comboBox.SetText(Value);
+ for(int i = 0; i < Strings.Size(); i++)
+ _comboBox.AddString(Strings[i]);
+ return CModalDialog::OnInit();
+}
+
+void CComboDialog::OnOK()
+{
+ _comboBox.GetText(Value);
+ CModalDialog::OnOK();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog.h
new file mode 100644
index 000000000..0a1addc54
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog.h
@@ -0,0 +1,25 @@
+// ComboDialog.h
+
+#ifndef __COMBODIALOG_H
+#define __COMBODIALOG_H
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ComboBox.h"
+#include "ComboDialogRes.h"
+
+class CComboDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox _comboBox;
+ virtual void OnOK();
+ virtual bool OnInit();
+public:
+ // bool Sorted;
+ UString Title;
+ UString Static;
+ UString Value;
+ UStringVector Strings;
+ // CComboDialog(): Sorted(false) {};
+ INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COMBO, parentWindow); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialogRes.h
new file mode 100644
index 000000000..b5111ddfd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialogRes.h
@@ -0,0 +1,4 @@
+#define IDD_DIALOG_COMBO 200
+
+#define IDC_COMBO_STATIC 1000
+#define IDC_COMBO_COMBO 1001
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog_rc.cpp
new file mode 100644
index 000000000..086d0a4b4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ComboDialog_rc.cpp
@@ -0,0 +1,57 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "ComboDialogRes.h"
+
+class ComboDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ ComboDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) : CModalDialogImpl(dialog, parent, id, wxT("Combo"))
+ {
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+
+ topsizer->Add(new wxStaticText(this, IDC_COMBO_STATIC, _T("")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+
+ wxArrayString pathArray;
+ wxComboBox *combo = new wxComboBox(this, IDC_COMBO_COMBO, wxEmptyString, wxDefaultPosition, wxSize(200,-1), pathArray, wxCB_DROPDOWN|wxCB_SORT);
+
+ topsizer->Add(combo, 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+REGISTER_DIALOG(IDD_DIALOG_COMBO,ComboDialog,0)
+
+BEGIN_EVENT_TABLE(ComboDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog.cpp
new file mode 100644
index 000000000..2bf603019
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog.cpp
@@ -0,0 +1,82 @@
+// CopyDialog.cpp
+
+#include "StdAfx.h"
+#include "CopyDialog.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/Control/Static.h"
+#include "Windows/Shell.h"
+#include "Windows/FileName.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+bool CCopyDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _path.Attach(GetItem(IDC_COPY_COMBO));
+ SetText(Title);
+
+ NControl::CStatic staticContol;
+ staticContol.Attach(GetItem(IDC_COPY_STATIC));
+ staticContol.SetText(Static);
+ for (int i = 0; i < Strings.Size(); i++)
+ _path.AddString(Strings[i]);
+ _path.SetText(Value);
+ SetItemText(IDC_COPY_INFO, Info);
+ return CModalDialog::OnInit();
+}
+
+bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_COPY_SET_PATH:
+ OnButtonSetPath();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CCopyDialog::OnButtonSetPath()
+{
+ UString currentPath;
+ _path.GetText(currentPath);
+
+ /*
+ #ifdef LANG
+ UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
+ #else
+ UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
+ #endif
+ */
+ UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209);
+ // UString title = L"Specify a location for output folder";
+
+ UString resultPath;
+ if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
+ return;
+ NFile::NName::NormalizeDirPathPrefix(resultPath);
+ _path.SetCurSel(-1);
+ _path.SetText(resultPath);
+}
+
+void CCopyDialog::OnOK()
+{
+ _path.GetText(Value);
+ CModalDialog::OnOK();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog.h
new file mode 100644
index 000000000..55872f1c1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog.h
@@ -0,0 +1,30 @@
+// CopyDialog.h
+
+#ifndef __COPYDIALOG_H
+#define __COPYDIALOG_H
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ComboBox.h"
+#include "CopyDialogRes.h"
+
+const int kCopyDialog_NumInfoLines = 11;
+
+class CCopyDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox _path;
+ virtual void OnOK();
+ virtual bool OnInit();
+ void OnButtonSetPath();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+public:
+ UString Title;
+ UString Static;
+ UString Value;
+ UStringVector Strings;
+
+ UString Info;
+
+ INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialogRes.h
new file mode 100644
index 000000000..900bf29f3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialogRes.h
@@ -0,0 +1,8 @@
+#define IDD_DIALOG_COPY 202
+
+#define IDC_COPY_STATIC 1000
+#define IDC_COPY_COMBO 1001
+#define IDC_COPY_SET_PATH 1002
+#define IDC_COPY_INFO 1003
+
+#define IDS_SET_FOLDER 210
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog_rc.cpp
new file mode 100644
index 000000000..700a78a5f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/CopyDialog_rc.cpp
@@ -0,0 +1,73 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "CopyDialogRes.h"
+
+class CopyDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CopyDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) : CModalDialogImpl(dialog, parent, id, wxT("Copy"))
+ {
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+
+ topsizer->Add(new wxStaticText(this, IDC_COPY_STATIC, _T("")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+
+ {
+ wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL);
+
+ wxArrayString pathArray;
+ wxComboBox *combo = new wxComboBox(this, IDC_COPY_COMBO, wxEmptyString, wxDefaultPosition, wxSize(600,-1), pathArray, wxCB_DROPDOWN|wxCB_SORT);
+ wxButton *button = new wxButton(this, IDC_COPY_SET_PATH, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pathSizer->Add(combo, 1, wxLEFT|wxRIGHT|wxEXPAND, 5);
+ pathSizer->Add(button, 0, wxLEFT|wxRIGHT|wxEXPAND, 5);
+
+ topsizer->Add(pathSizer, 0 ,wxALL | wxALIGN_LEFT, 5 );
+ }
+
+ topsizer->Add(new wxStaticText(this, IDC_COPY_INFO, _T("line1\nline2\nline3\nline4\n")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { IDS_SET_FOLDER, L"Specify a location for output folder." },
+ { 0 , 0 }
+};
+
+
+REGISTER_DIALOG(IDD_DIALOG_COPY,CopyDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(CopyDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ExtractCallback.cpp
new file mode 100644
index 000000000..9902e9a1d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ExtractCallback.cpp
@@ -0,0 +1,478 @@
+// ExtractCallback.h
+
+#include "StdAfx.h"
+
+#include "Common/Wildcard.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/ResourceString.h"
+
+#include "../../Common/FilePathAutoRename.h"
+
+#include "../GUI/ExtractRes.h"
+#include "../GUI/resource.h"
+
+#include "ExtractCallback.h"
+#include "FormatUtils.h"
+#include "MessagesDialog.h"
+#include "OverwriteDialog.h"
+#ifndef _NO_CRYPTO
+#include "PasswordDialog.h"
+#endif
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+CExtractCallbackImp::~CExtractCallbackImp()
+{
+ if (ShowMessages && !Messages.IsEmpty())
+ {
+ CMessagesDialog messagesDialog;
+ messagesDialog.Messages = &Messages;
+ messagesDialog.Create(ParentWindow);
+ }
+}
+
+void CExtractCallbackImp::Init()
+{
+ Messages.Clear();
+ NumArchiveErrors = 0;
+ #ifndef _SFX
+ NumFolders = NumFiles = 0;
+ NeedAddFile = false;
+ #endif
+}
+
+void CExtractCallbackImp::AddErrorMessage(LPCWSTR message)
+{
+ Messages.Add(message);
+}
+
+STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64
+ #ifndef _SFX
+ numFiles
+ #endif
+ )
+{
+ #ifndef _SFX
+ ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles);
+ #endif
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total)
+{
+ ProgressDialog.ProgressSynch.SetProgress(total, 0);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value)
+{
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ if (value != NULL)
+ ProgressDialog.ProgressSynch.SetPos(*value);
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::Open_CheckBreak()
+{
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles);
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles);
+ return S_OK;
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT CExtractCallbackImp::Open_CryptoGetTextPassword(BSTR *password)
+{
+ return CryptoGetTextPassword(password);
+}
+
+HRESULT CExtractCallbackImp::Open_GetPasswordIfAny(UString &password)
+{
+ if (PasswordIsDefined)
+ password = Password;
+ return S_OK;
+}
+
+bool CExtractCallbackImp::Open_WasPasswordAsked()
+{
+ return PasswordWasAsked;
+}
+
+void CExtractCallbackImp::Open_ClearPasswordWasAskedFlag()
+{
+ PasswordWasAsked = false;
+}
+
+#endif
+
+
+#ifndef _SFX
+STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize);
+ return S_OK;
+}
+#endif
+
+/*
+STDMETHODIMP CExtractCallbackImp::SetTotalFiles(UInt64 total)
+{
+ ProgressDialog.ProgressSynch.SetNumFilesTotal(total);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value)
+{
+ if (value != NULL)
+ ProgressDialog.ProgressSynch.SetNumFilesCur(*value);
+ return S_OK;
+}
+*/
+
+STDMETHODIMP CExtractCallbackImp::AskOverwrite(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer)
+{
+ COverwriteDialog dialog;
+
+ dialog.OldFileInfo.Time = *existTime;
+ dialog.OldFileInfo.SizeIsDefined = (existSize != NULL);
+ if (dialog.OldFileInfo.SizeIsDefined)
+ dialog.OldFileInfo.Size = *existSize;
+ dialog.OldFileInfo.Name = existName;
+
+ if (newTime == 0)
+ dialog.NewFileInfo.TimeIsDefined = false;
+ else
+ {
+ dialog.NewFileInfo.TimeIsDefined = true;
+ dialog.NewFileInfo.Time = *newTime;
+ }
+
+ dialog.NewFileInfo.SizeIsDefined = (newSize != NULL);
+ if (dialog.NewFileInfo.SizeIsDefined)
+ dialog.NewFileInfo.Size = *newSize;
+ dialog.NewFileInfo.Name = newName;
+
+ /*
+ NOverwriteDialog::NResult::EEnum writeAnswer =
+ NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
+ */
+ INT_PTR writeAnswer = dialog.Create(ProgressDialog); // ParentWindow doesn't work with 7z
+
+ switch(writeAnswer)
+ {
+ case IDCANCEL: *answer = NOverwriteAnswer::kCancel; return E_ABORT;
+ case IDYES: *answer = NOverwriteAnswer::kYes; break;
+ case IDNO: *answer = NOverwriteAnswer::kNo; break;
+ case IDC_BUTTON_OVERWRITE_YES_TO_ALL: *answer = NOverwriteAnswer::kYesToAll; break;
+ case IDC_BUTTON_OVERWRITE_NO_TO_ALL: *answer = NOverwriteAnswer::kNoToAll; break;
+ case IDC_BUTTON_OVERWRITE_AUTO_RENAME: *answer = NOverwriteAnswer::kAutoRename; break;
+ default: return E_FAIL;
+ }
+ return S_OK;
+}
+
+
+STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, bool isFolder, Int32 /* askExtractMode */, const UInt64 * /* position */)
+{
+ _isFolder = isFolder;
+ return SetCurrentFilePath2(name);
+}
+
+STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
+{
+ AddErrorMessage(message);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *message)
+{
+ AddErrorMessage(message);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool encrypted)
+{
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kOK:
+ break;
+ default:
+ {
+ UINT messageID;
+ UInt32 langID;
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
+ messageID = IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD;
+ langID = 0x02000A91;
+ break;
+ case NArchive::NExtract::NOperationResult::kDataError:
+ messageID = encrypted ?
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED:
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR;
+ langID = encrypted ? 0x02000A94 : 0x02000A92;
+ break;
+ case NArchive::NExtract::NOperationResult::kCRCError:
+ messageID = encrypted ?
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED:
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC;
+ langID = encrypted ? 0x02000A95 : 0x02000A93;
+ break;
+ default:
+ return E_FAIL;
+ }
+ if (_needWriteArchivePath)
+ {
+ AddErrorMessage(_currentArchivePath);
+ _needWriteArchivePath = false;
+ }
+ AddErrorMessage(
+ MyFormatNew(messageID,
+ #ifdef LANG
+ langID,
+ #endif
+ _currentFilePath));
+ }
+ }
+ #ifndef _SFX
+ if (_isFolder)
+ NumFolders++;
+ else
+ NumFiles++;
+ ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles);
+ #endif
+ return S_OK;
+}
+
+////////////////////////////////////////
+// IExtractCallbackUI
+
+HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name)
+{
+ #ifndef _SFX
+ ProgressDialog.ProgressSynch.SetTitleFileName(name);
+ #endif
+ _currentArchivePath = name;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path)
+{
+ _currentFilePath = path;
+ #ifndef _SFX
+ ProgressDialog.ProgressSynch.SetCurrentFileName(path);
+ #endif
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path)
+{
+ #ifndef _SFX
+ if (NeedAddFile)
+ NumFiles++;
+ NeedAddFile = true;
+ ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles);
+ #endif
+ return SetCurrentFilePath2(path);
+}
+
+HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, bool encrypted)
+{
+ if (result != S_OK)
+ {
+ UString message;
+ if (result == S_FALSE)
+ {
+ message = MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE,
+ #ifdef LANG
+ (encrypted ? 0x0200060A : 0x02000609),
+ #endif
+ name);
+ }
+ else
+ {
+ message = name;
+ message += L": ";
+ UString message2;
+ if (result == E_OUTOFMEMORY)
+ message2 =
+ #ifdef LANG
+ LangString(IDS_MEM_ERROR, 0x0200060B);
+ #else
+ MyLoadStringW(IDS_MEM_ERROR);
+ #endif
+ else
+ NError::MyFormatMessage(result, message2);
+ message += message2;
+ }
+ MessageError(message);
+ NumArchiveErrors++;
+ }
+ _currentArchivePath = name;
+ _needWriteArchivePath = true;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::ThereAreNoFiles()
+{
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::ExtractResult(HRESULT result)
+{
+ if (result == S_OK)
+ return result;
+ NumArchiveErrors++;
+ if (result == E_ABORT || result == ERROR_DISK_FULL)
+ return result;
+ MessageError(_currentFilePath);
+ MessageError(NError::MyFormatMessageW(result));
+ return S_OK;
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT CExtractCallbackImp::SetPassword(const UString &password)
+{
+ PasswordIsDefined = true;
+ Password = password;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
+{
+ PasswordWasAsked = true;
+ if (!PasswordIsDefined)
+ {
+ CPasswordDialog dialog;
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
+ return E_ABORT;
+ Password = dialog.Password;
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
+
+#endif
+
+// IExtractCallBack3
+STDMETHODIMP CExtractCallbackImp::AskWrite(
+ const wchar_t *srcPath, Int32 srcIsFolder,
+ const FILETIME *srcTime, const UInt64 *srcSize,
+ const wchar_t *destPath,
+ BSTR *destPathResult,
+ Int32 *writeAnswer)
+{
+ UString destPathResultTemp = destPath;
+
+ // RINOK(StringToBstr(destPath, destPathResult));
+
+ *destPathResult = 0;
+ *writeAnswer = BoolToInt(false);
+
+ UString destPathSpec = destPath;
+ UString destPathSys = destPathSpec;
+ bool srcIsFolderSpec = IntToBool(srcIsFolder);
+ CFileInfoW destFileInfo;
+ if (destFileInfo.Find(destPathSys))
+ {
+ if (srcIsFolderSpec)
+ {
+ if (!destFileInfo.IsDir())
+ {
+ UString message = UString(L"can not replace file \'")
+ + destPathSpec +
+ UString(L"\' with folder with same name");
+ RINOK(MessageError(message));
+ return E_ABORT;
+ }
+ *writeAnswer = BoolToInt(false);
+ return S_OK;
+ }
+ if (destFileInfo.IsDir())
+ {
+ UString message = UString(L"can not replace folder \'")
+ + destPathSpec +
+ UString(L"\' with file with same name");
+ RINOK(MessageError(message));
+ return E_FAIL;
+ }
+
+ switch(OverwriteMode)
+ {
+ case NExtract::NOverwriteMode::kSkipExisting:
+ return S_OK;
+ case NExtract::NOverwriteMode::kAskBefore:
+ {
+ Int32 overwiteResult;
+ RINOK(AskOverwrite(
+ destPathSpec,
+ &destFileInfo.MTime, &destFileInfo.Size,
+ srcPath,
+ srcTime, srcSize,
+ &overwiteResult));
+ switch(overwiteResult)
+ {
+ case NOverwriteAnswer::kCancel:
+ return E_ABORT;
+ case NOverwriteAnswer::kNo:
+ return S_OK;
+ case NOverwriteAnswer::kNoToAll:
+ OverwriteMode = NExtract::NOverwriteMode::kSkipExisting;
+ return S_OK;
+ case NOverwriteAnswer::kYesToAll:
+ OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
+ break;
+ case NOverwriteAnswer::kYes:
+ break;
+ case NOverwriteAnswer::kAutoRename:
+ OverwriteMode = NExtract::NOverwriteMode::kAutoRename;
+ break;
+ default:
+ return E_FAIL;
+ }
+ }
+ }
+ if (OverwriteMode == NExtract::NOverwriteMode::kAutoRename)
+ {
+ if (!AutoRenamePath(destPathSys))
+ {
+ UString message = UString(L"can not create name of file ")
+ + destPathSys;
+ RINOK(MessageError(message));
+ return E_ABORT;
+ }
+ destPathResultTemp = destPathSys;
+ }
+ else
+ if (!NFile::NDirectory::DeleteFileAlways(destPathSys))
+ {
+ UString message = UString(L"can not delete output file ")
+ + destPathSys;
+ RINOK(MessageError(message));
+ return E_ABORT;
+ }
+ }
+ *writeAnswer = BoolToInt(true);
+ return StringToBstr(destPathResultTemp, destPathResult);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ExtractCallback.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ExtractCallback.h
new file mode 100644
index 000000000..ee46222a2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ExtractCallback.h
@@ -0,0 +1,150 @@
+// ExtractCallback.h
+
+#ifndef __EXTRACTCALLBACK_H
+#define __EXTRACTCALLBACK_H
+
+#include "../Agent/IFolderArchive.h"
+#include "Common/MyString.h"
+#include "../Common/ArchiveOpenCallback.h"
+
+#ifdef _SFX
+#include "ProgressDialog.h"
+#else
+#include "ProgressDialog2.h"
+#endif
+
+#include "Windows/ResourceString.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+#ifndef _NO_CRYPTO
+#include "../../IPassword.h"
+#endif
+#include "Common/MyCom.h"
+#include "IFolder.h"
+
+class CExtractCallbackImp:
+ public IExtractCallbackUI,
+ public IOpenCallbackUI,
+ public IFolderOperationsExtractCallback,
+ // public IFolderArchiveExtractCallback, // mkultiple from IProgress
+ #ifndef _SFX
+ public ICompressProgressInfo,
+ #endif
+ #ifndef _NO_CRYPTO
+ public ICryptoGetTextPassword,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ MY_QUERYINTERFACE_BEGIN2(IFolderOperationsExtractCallback)
+ MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback)
+ #ifndef _SFX
+ MY_QUERYINTERFACE_ENTRY(ICompressProgressInfo)
+ #endif
+ #ifndef _NO_CRYPTO
+ MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword)
+ #endif
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ #ifndef _SFX
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+ #endif
+
+ INTERFACE_IProgress(;)
+ INTERFACE_IOpenCallbackUI(;)
+
+ // IFolderArchiveExtractCallback
+ // STDMETHOD(SetTotalFiles)(UInt64 total);
+ // STDMETHOD(SetCompletedFiles)(const UInt64 *value);
+ STDMETHOD(AskOverwrite)(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer);
+ STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, Int32 askExtractMode, const UInt64 *position);
+
+ STDMETHOD(MessageError)(const wchar_t *message);
+ STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted);
+
+ // IExtractCallbackUI
+
+ HRESULT BeforeOpen(const wchar_t *name);
+ HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted);
+ HRESULT ThereAreNoFiles();
+ HRESULT ExtractResult(HRESULT result);
+
+ #ifndef _NO_CRYPTO
+ HRESULT SetPassword(const UString &password);
+ #endif
+
+ // IFolderOperationsExtractCallback
+ STDMETHOD(AskWrite)(
+ const wchar_t *srcPath,
+ Int32 srcIsFolder,
+ const FILETIME *srcTime,
+ const UInt64 *srcSize,
+ const wchar_t *destPathRequest,
+ BSTR *destPathResult,
+ Int32 *writeAnswer);
+ STDMETHOD(ShowMessage)(const wchar_t *message);
+ STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath);
+ STDMETHOD(SetNumFiles)(UInt64 numFiles);
+
+ // ICryptoGetTextPassword
+ #ifndef _NO_CRYPTO
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+ #endif
+
+private:
+ // bool _extractMode;
+ UString _currentArchivePath;
+ bool _needWriteArchivePath;
+
+ UString _currentFilePath;
+ bool _isFolder;
+
+ // void CreateComplexDirectory(const UStringVector &aDirPathParts);
+
+ HRESULT SetCurrentFilePath2(const wchar_t *filePath);
+ void AddErrorMessage(LPCWSTR message);
+public:
+ CProgressDialog ProgressDialog;
+ UStringVector Messages;
+ bool ShowMessages;
+ #ifndef _SFX
+ UInt64 NumFolders;
+ UInt64 NumFiles;
+ bool NeedAddFile;
+ #endif
+ HWND ParentWindow;
+ INT_PTR StartProgressDialog(const UString &title)
+ {
+ return ProgressDialog.Create(title, ParentWindow);
+ }
+ UInt32 NumArchiveErrors;
+ NExtract::NOverwriteMode::EEnum OverwriteMode;
+
+ #ifndef _NO_CRYPTO
+ bool PasswordIsDefined;
+ bool PasswordWasAsked;
+ UString Password;
+ #endif
+
+ CExtractCallbackImp():
+ #ifndef _NO_CRYPTO
+ PasswordIsDefined(false),
+ PasswordWasAsked(false),
+ #endif
+ OverwriteMode(NExtract::NOverwriteMode::kAskBefore),
+ ParentWindow(0),
+ ShowMessages(true)
+ {}
+
+ ~CExtractCallbackImp();
+ void Init();
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FM.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FM.cpp
new file mode 100644
index 000000000..6c81d4b60
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FM.cpp
@@ -0,0 +1,914 @@
+// FM.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+#include "Panel.h"
+
+extern "C"
+{
+ #include "../../../../C/Alloc.h"
+}
+
+#include "Common/Defs.h"
+#include "Common/StringConvert.h"
+// #include "Common/CommandLineParser.h"
+
+// FIXME #include "Windows/Control/Toolbar.h"
+#include "Windows/Error.h"
+#include "Windows/COM.h"
+#include "Windows/DLL.h"
+// FIXME #include "Windows/Security.h"
+// FIXME #include "Windows/MemoryLock.h"
+
+#include "ViewSettings.h"
+#include "../GUI/ExtractRes.h"
+
+#include "App.h"
+#include "StringUtils.h"
+
+#include "MyLoadMenu.h"
+#include "LangUtils.h"
+#include "FormatUtils.h"
+#include "RegistryUtils.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+// using namespace NCommandLineParser;
+
+#define MAX_LOADSTRING 100
+
+#define MENU_HEIGHT 26
+
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
+HINSTANCE g_hInstance;
+HWND g_HWND;
+bool g_OpenArchive = false;
+static UString g_MainPath;
+
+const int kNumDefaultPanels = 1;
+
+const int kSplitterWidth = 4;
+int kSplitterRateMax = 1 << 16;
+
+// bool OnMenuCommand(HWND hWnd, int id);
+
+static void local_WM_CREATE(HWND hWnd);
+
+#ifdef _WIN32
+static UString GetProgramPath()
+{
+ UString s;
+ NDLL::MyGetModuleFileName(g_hInstance, s);
+ return s;
+}
+
+UString GetProgramFolderPrefix()
+{
+ UString path = GetProgramPath();
+ int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ return path.Left(pos + 1);
+}
+
+
+class CSplitterPos
+{
+ int _ratio; // 10000 is max
+ int _pos;
+ int _fullWidth;
+ void SetRatioFromPos(HWND hWnd)
+ { _ratio = (_pos + kSplitterWidth / 2) * kSplitterRateMax /
+ MyMax(GetWidth(hWnd), 1); }
+public:
+ int GetPos() const
+ { return _pos; }
+ int GetWidth(HWND hWnd) const
+ {
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ return rect.right;
+ }
+ void SetRatio(HWND hWnd, int aRatio)
+ {
+ _ratio = aRatio;
+ SetPosFromRatio(hWnd);
+ }
+ void SetPosPure(HWND hWnd, int pos)
+ {
+ int posMax = GetWidth(hWnd) - kSplitterWidth;
+ if (pos > posMax)
+ pos = posMax;
+ if (pos < 0)
+ pos = 0;
+ _pos = pos;
+ }
+ void SetPos(HWND hWnd, int pos)
+ {
+ _fullWidth = GetWidth(hWnd);
+ SetPosPure(hWnd, pos);
+ SetRatioFromPos(hWnd);
+ }
+ void SetPosFromRatio(HWND hWnd)
+ {
+ int fullWidth = GetWidth(hWnd);
+ if (_fullWidth != fullWidth)
+ {
+ _fullWidth = fullWidth;
+ SetPosPure(hWnd, GetWidth(hWnd) * _ratio / kSplitterRateMax - kSplitterWidth / 2);
+ }
+ }
+};
+#endif
+
+bool g_CanChangeSplitter = false;
+UINT32 g_SplitterPos = 0;
+// FIXME CSplitterPos g_Splitter;
+bool g_PanelsInfoDefined = false;
+
+int g_StartCaptureMousePos;
+int g_StartCaptureSplitterPos;
+
+CApp g_App;
+
+void MoveSubWindows(HWND hWnd);
+void OnSize(HWND hWnd);
+
+// FIXME LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+const wchar_t *kWindowClass = L"FM";
+
+#ifndef _UNICODE
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+
+// FUNCTION: InitInstance(HANDLE, int)
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+ CWindow wnd;
+
+ g_hInstance = hInstance;
+
+ ReloadLangSmart();
+
+ // LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING);
+
+ // LoadString(hInstance, IDS_APP_TITLE, title, MAX_LOADSTRING);
+ UString title = LangString(IDS_APP_TITLE, 0x03000000);
+
+ /*
+ //If it is already running, then focus on the window
+ hWnd = FindWindow(windowClass, title);
+ if (hWnd)
+ {
+ SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));
+ return 0;
+ }
+ */
+
+#ifdef _WIN32
+ WNDCLASSW wc;
+
+ // wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.style = 0;
+ wc.lpfnWndProc = (WNDPROC) WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FAM));
+
+ // wc.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wc.hCursor = ::LoadCursor(0, IDC_SIZEWE);
+ // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
+
+ wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
+ wc.lpszClassName = kWindowClass;
+
+ MyRegisterClass(&wc);
+
+ // RECT rect;
+ // GetClientRect(hWnd, &rect);
+
+ DWORD style = WS_OVERLAPPEDWINDOW;
+ // DWORD style = 0;
+
+ RECT rect;
+ bool maximized = false;
+ int x , y, xSize, ySize;
+ x = y = xSize = ySize = CW_USEDEFAULT;
+ bool windowPosIsRead = ReadWindowSize(rect, maximized);
+
+ if (windowPosIsRead)
+ {
+ // x = rect.left;
+ // y = rect.top;
+ xSize = rect.right - rect.left;
+ ySize = rect.bottom - rect.top;
+ }
+#endif
+
+ UINT32 numPanels, currentPanel;
+ g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos);
+ if (g_PanelsInfoDefined)
+ {
+ if (numPanels < 1 || numPanels > 2)
+ numPanels = kNumDefaultPanels;
+ if (currentPanel >= 2)
+ currentPanel = 0;
+ }
+ else
+ {
+ numPanels = kNumDefaultPanels;
+ currentPanel = 0;
+ }
+ g_App.NumPanels = numPanels;
+ g_App.LastFocusedPanel = currentPanel;
+
+#ifdef _WIN32 // FIXME
+ if (!wnd.Create(kWindowClass, title, style,
+ x, y, xSize, ySize, NULL, NULL, hInstance, NULL))
+ return FALSE;
+ g_HWND = (HWND)wnd;
+#else
+ {
+ extern HWND myCreateAndShowMainWindow(LPCTSTR title,void (*fct)(HWND));
+ g_HWND = myCreateAndShowMainWindow(title,local_WM_CREATE);
+ }
+#endif
+
+#ifdef _WIN32
+ WINDOWPLACEMENT placement;
+ placement.length = sizeof(placement);
+ if (wnd.GetPlacement(&placement))
+ {
+ if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
+ nCmdShow == SW_SHOWDEFAULT)
+ {
+ if (maximized)
+ placement.showCmd = SW_SHOWMAXIMIZED;
+ else
+ placement.showCmd = SW_SHOWNORMAL;
+ }
+ else
+ placement.showCmd = nCmdShow;
+ if (windowPosIsRead)
+ placement.rcNormalPosition = rect;
+ wnd.SetPlacement(&placement);
+ // window.Show(nCmdShow);
+ }
+ else
+ wnd.Show(nCmdShow);
+#endif
+ return TRUE;
+}
+
+/*
+static void GetCommands(const UString &aCommandLine, UString &aCommands)
+{
+ UString aProgramName;
+ aCommands.Empty();
+ bool aQuoteMode = false;
+ for (int i = 0; i < aCommandLine.Length(); i++)
+ {
+ wchar_t aChar = aCommandLine[i];
+ if (aChar == L'\"')
+ aQuoteMode = !aQuoteMode;
+ else if (aChar == L' ' && !aQuoteMode)
+ {
+ if (!aQuoteMode)
+ {
+ i++;
+ break;
+ }
+ }
+ else
+ aProgramName += aChar;
+ }
+ aCommands = aCommandLine.Mid(i);
+}
+*/
+
+#ifdef _WIN32
+DWORD GetDllVersion(LPCTSTR lpszDllName)
+{
+ HINSTANCE hinstDll;
+ DWORD dwVersion = 0;
+ hinstDll = LoadLibrary(lpszDllName);
+ if(hinstDll)
+ {
+ DLLGETVERSIONPROC pDllGetVersion;
+ pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
+
+ /*Because some DLLs might not implement this function, you
+ must test for it explicitly. Depending on the particular
+ DLL, the lack of a DllGetVersion function can be a useful
+ indicator of the version.
+ */
+ if(pDllGetVersion)
+ {
+ DLLVERSIONINFO dvi;
+ HRESULT hr;
+
+ ZeroMemory(&dvi, sizeof(dvi));
+ dvi.cbSize = sizeof(dvi);
+
+ hr = (*pDllGetVersion)(&dvi);
+
+ if(SUCCEEDED(hr))
+ {
+ dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
+ }
+ }
+ FreeLibrary(hinstDll);
+ }
+ return dwVersion;
+}
+
+DWORD g_ComCtl32Version;
+#endif
+
+/*
+#ifndef _WIN64
+typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
+
+static bool IsWow64()
+{
+ LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
+ GetModuleHandle("kernel32"), "IsWow64Process");
+ if (fnIsWow64Process == NULL)
+ return false;
+ BOOL isWow;
+ if (!fnIsWow64Process(GetCurrentProcess(),&isWow))
+ return false;
+ return isWow != FALSE;
+}
+#endif
+*/
+
+#ifdef _WIN32
+bool IsLargePageSupported()
+{
+ #ifdef _WIN64
+ return true;
+ #else
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 5)
+ return false;
+ if (versionInfo.dwMajorVersion > 5)
+ return true;
+ if (versionInfo.dwMinorVersion < 1)
+ return false;
+ if (versionInfo.dwMinorVersion > 1)
+ return true;
+ // return IsWow64();
+ return false;
+ #endif
+}
+
+static void SetMemoryLock()
+{
+ if (!IsLargePageSupported())
+ return;
+ // if (ReadLockMemoryAdd())
+ NSecurity::AddLockMemoryPrivilege();
+
+ if (ReadLockMemoryEnable())
+ NSecurity::EnableLockMemoryPrivilege();
+}
+#endif
+
+/*
+static const int kNumSwitches = 1;
+
+namespace NKey {
+enum Enum
+{
+ kOpenArachive = 0,
+};
+
+}
+
+static const CSwitchForm kSwitchForms[kNumSwitches] =
+ {
+ { L"SOA", NSwitchType::kSimple, false },
+ };
+*/
+
+// int APIENTRY WinMain2(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */);
+
+#ifdef _WIN32
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int nCmdShow)
+{
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+
+ InitCommonControls();
+
+ g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
+
+ // OleInitialize is required for drag and drop.
+ OleInitialize(NULL);
+ // Maybe needs CoInitializeEx also ?
+ // NCOM::CComInitializer comInitializer;
+
+ UString programString, commandsString;
+ // MessageBoxW(0, GetCommandLineW(), L"", 0);
+ SplitStringToTwoStrings(GetCommandLineW(), programString, commandsString);
+
+ commandsString.Trim();
+ UString paramString, tailString;
+ SplitStringToTwoStrings(commandsString, paramString, tailString);
+ paramString.Trim();
+
+ if (!paramString.IsEmpty())
+ {
+ g_MainPath = paramString;
+ // return WinMain2(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
+
+ // MessageBoxW(0, paramString, L"", 0);
+ }
+ /*
+ UStringVector commandStrings;
+ NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
+ NCommandLineParser::CParser parser(kNumSwitches);
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
+ const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
+ if(nonSwitchStrings.Size() > 1)
+ {
+ g_MainPath = nonSwitchStrings[1];
+ // g_OpenArchive = parser[NKey::kOpenArachive].ThereIs;
+ CFileInfoW fileInfo;
+ if (FindFile(g_MainPath, fileInfo))
+ {
+ if (!fileInfo.IsDir())
+ g_OpenArchive = true;
+ }
+ }
+ }
+ catch(...) { }
+ */
+
+
+ SetMemoryLock();
+
+ MSG msg;
+ if (!InitInstance (hInstance, nCmdShow))
+ return FALSE;
+
+ MyLoadMenu(g_HWND);
+
+ #ifndef _UNICODE
+ if (g_IsNT)
+ {
+ HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
+ while (GetMessageW(&msg, NULL, 0, 0))
+ {
+ if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
+ {
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+ }
+ }
+ else
+ #endif
+ {
+ HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
+ {
+ // if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
+ // if (!IsDialogMessage(g_Hwnd, &msg))
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ }
+
+ g_HWND = 0;
+ OleUninitialize();
+ return (int)msg.wParam;
+}
+
+static void SaveWindowInfo(HWND aWnd)
+{
+ /*
+ RECT rect;
+ if (!::GetWindowRect(aWnd, &rect))
+ return;
+ */
+ WINDOWPLACEMENT placement;
+ placement.length = sizeof(placement);
+ if (!::GetWindowPlacement(aWnd, &placement))
+ return;
+ SaveWindowSize(placement.rcNormalPosition,
+ BOOLToBool(::IsZoomed(aWnd)));
+ SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel,
+ g_Splitter.GetPos());
+}
+#else
+int Main1(int argc,TCHAR **argv)
+{
+ if (argc >= 2)
+ {
+ g_MainPath = argv[1];
+ }
+
+ if (!InitInstance (0, 0))
+ return FALSE;
+
+ MyLoadMenu(g_HWND);
+
+ // FIXME : install Accelerators ?
+
+ return 0;
+}
+
+#endif
+
+void ExecuteCommand(UINT commandID)
+{
+ printf("FM - ExecuteCommand(%d)\n",commandID);
+ switch (commandID)
+ {
+ case kAddCommand:
+ g_App.AddToArchive();
+ break;
+ case kExtractCommand:
+ g_App.ExtractArchives();
+ break;
+ case kTestCommand:
+ g_App.TestArchives();
+ break;
+ }
+}
+
+#ifdef _WIN32
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId, wmEvent;
+ switch (message)
+ {
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+ if ((HWND) lParam != NULL && wmEvent != 0)
+ break;
+ if (wmId >= kToolbarStartID)
+ {
+ ExecuteCommand(wmId);
+ return 0;
+ }
+ if (OnMenuCommand(hWnd, wmId))
+ return 0;
+ break;
+ case WM_INITMENUPOPUP:
+ OnMenuActivating(hWnd, HMENU(wParam), LOWORD(lParam));
+ break;
+
+ /*
+ It doesn't help
+ case WM_EXITMENULOOP:
+ {
+ OnMenuUnActivating(hWnd);
+ break;
+ }
+ case WM_UNINITMENUPOPUP:
+ OnMenuUnActivating(hWnd, HMENU(wParam), lParam);
+ break;
+ */
+
+ case WM_CREATE:
+ {
+
+ /*
+ INITCOMMONCONTROLSEX icex;
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ // Toolbar buttons used to create the first 4 buttons.
+ TBBUTTON tbb [ ] =
+ {
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ // {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ {VIEW_NEWFOLDER, ID_FILE_CREATEFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ };
+
+ int baseID = 100;
+ NWindows::NControl::CToolBar aToolBar;
+ aToolBar.Attach(::CreateToolbarEx (hWnd,
+ WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT
+ baseID + 2, 11,
+ (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR,
+ (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
+ 0, 0, 100, 30, sizeof (TBBUTTON)));
+ */
+ // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
+ // ::SetCursor(cursor);
+
+ if (g_PanelsInfoDefined)
+ g_Splitter.SetPos(hWnd, g_SplitterPos);
+ else
+ {
+ g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
+ g_SplitterPos = g_Splitter.GetPos();
+ }
+
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int xSizes[2];
+ xSizes[0] = g_Splitter.GetPos();
+ xSizes[1] = xSize - kSplitterWidth - xSizes[0];
+ if (xSizes[1] < 0)
+ xSizes[1] = 0;
+
+ g_App.CreateDragTarget();
+ bool archiveIsOpened;
+ bool encrypted;
+ bool needOpenFile = false;
+ if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if (NFile::NFind::FindFile(g_MainPath, fileInfo))
+ if (!fileInfo.IsDir())
+ needOpenFile = true;
+ }
+ g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted);
+
+ if (needOpenFile && !archiveIsOpened)
+ {
+ UString message;
+ if (encrypted)
+ message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath);
+ else
+ message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath);
+ MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
+ return -1;
+ }
+ // g_SplitterPos = 0;
+
+ // ::DragAcceptFiles(hWnd, TRUE);
+ RegisterDragDrop(hWnd, g_App._dropTarget);
+
+ break;
+ }
+ case WM_DESTROY:
+ {
+ // ::DragAcceptFiles(hWnd, FALSE);
+ RevokeDragDrop(hWnd);
+ g_App._dropTarget.Release();
+
+ g_App.Save();
+ g_App.Release();
+ SaveWindowInfo(hWnd);
+ PostQuitMessage(0);
+ break;
+ }
+ /*
+ case WM_MOVE:
+ {
+ break;
+ }
+ */
+ case WM_LBUTTONDOWN:
+ g_StartCaptureMousePos = LOWORD(lParam);
+ g_StartCaptureSplitterPos = g_Splitter.GetPos();
+ ::SetCapture(hWnd);
+ break;
+ case WM_LBUTTONUP:
+ {
+ ::ReleaseCapture();
+ break;
+ }
+ case WM_MOUSEMOVE:
+ {
+ if ((wParam & MK_LBUTTON) != 0 && ::GetCapture() == hWnd)
+ {
+ g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos +
+ (short)LOWORD(lParam) - g_StartCaptureMousePos);
+ MoveSubWindows(hWnd);
+ }
+ break;
+ }
+
+ case WM_SIZE:
+ {
+ if (g_CanChangeSplitter)
+ g_Splitter.SetPosFromRatio(hWnd);
+ else
+ {
+ g_Splitter.SetPos(hWnd, g_SplitterPos );
+ g_CanChangeSplitter = true;
+ }
+
+ OnSize(hWnd);
+ /*
+ int xSize = LOWORD(lParam);
+ int ySize = HIWORD(lParam);
+ // int xSplitter = 2;
+ int xWidth = g_SplitPos;
+ // int xSplitPos = xWidth;
+ g_Panel[0]._listView.MoveWindow(0, 0, xWidth, ySize);
+ g_Panel[1]._listView.MoveWindow(xSize - xWidth, 0, xWidth, ySize);
+ */
+ return 0;
+ break;
+ }
+ case WM_SETFOCUS:
+ // g_App.SetFocus(g_App.LastFocusedPanel);
+ g_App.SetFocusToLastItem();
+ break;
+ /*
+ case WM_ACTIVATE:
+ {
+ int fActive = LOWORD(wParam);
+ switch (fActive)
+ {
+ case WA_INACTIVE:
+ {
+ // g_FocusIndex = g_App.LastFocusedPanel;
+ // g_App.LastFocusedPanel = g_App.GetFocusedPanelIndex();
+ // return 0;
+ }
+ }
+ break;
+ }
+ */
+ /*
+ case kLangWasChangedMessage:
+ MyLoadMenu(g_HWND);
+ return 0;
+ */
+
+ /*
+ case WM_SETTINGCHANGE:
+ break;
+ */
+ case WM_NOTIFY:
+ {
+ g_App.OnNotify((int)wParam, (LPNMHDR)lParam);
+ break;
+ }
+ /*
+ case WM_DROPFILES:
+ {
+ g_App.GetFocusedPanel().CompressDropFiles((HDROP)wParam);
+ return 0 ;
+ }
+ */
+ }
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(hWnd, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(hWnd, message, wParam, lParam);
+
+}
+
+void OnSize(HWND hWnd)
+{
+ /*
+ if (g_App._rebar)
+ {
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int ySize = rect.bottom;
+ // rect.bottom = 0;
+ // g_App._rebar.SizeToRect(&rect);
+ // g_App._rebar.Move(0, 0, xSize, ySize);
+ }
+ */
+ MoveSubWindows(hWnd);
+}
+
+int Window_GetRealHeight(NWindows::CWindow &w)
+{
+ RECT rect;
+ WINDOWPLACEMENT placement;
+ w.GetWindowRect(&rect);
+ int res = rect.bottom - rect.top;
+ if (w.GetPlacement(&placement))
+ res += placement.rcNormalPosition.top;
+ return res;
+}
+#else // _WIN32
+static void local_WM_CREATE(HWND hWnd)
+ {
+ printf("**local_WM_CREATE**\n");
+#if 0
+ if (g_PanelsInfoDefined)
+ g_Splitter.SetPos(hWnd, g_SplitterPos);
+ else
+ {
+ g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
+ g_SplitterPos = g_Splitter.GetPos();
+ }
+
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int xSizes[2];
+ xSizes[0] = g_Splitter.GetPos();
+ xSizes[1] = xSize - kSplitterWidth - xSizes[0];
+ if (xSizes[1] < 0)
+ xSizes[1] = 0;
+
+ g_App.CreateDragTarget();
+#else
+ int xSizes[2] = { 0,0 };
+#endif
+ bool archiveIsOpened;
+ bool encrypted;
+ bool needOpenFile = false;
+ if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if (NFile::NFind::FindFile(g_MainPath, fileInfo))
+ if (!fileInfo.IsDir())
+ needOpenFile = true;
+ }
+ g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted);
+
+ if (needOpenFile && !archiveIsOpened)
+ {
+ UString message;
+ if (encrypted)
+ message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath);
+ else
+ message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath);
+ MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
+ return ;// -1;
+ }
+ // g_SplitterPos = 0;
+
+ // FIXME RegisterDragDrop(hWnd, g_App._dropTarget);
+
+}
+
+void main_WM_DESTROY()
+{
+ // RevokeDragDrop(hWnd);
+ // g_App._dropTarget.Release();
+printf("main_WM_DESTROY\n");
+ g_App.Save();
+ g_App.Release();
+ // SaveWindowInfo(hWnd);
+ // PostQuitMessage(0);
+}
+#endif
+
+void MoveSubWindows(HWND hWnd)
+{
+#ifdef _WIN32
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int headerSize = 0;
+ if (g_App._rebar)
+ headerSize = Window_GetRealHeight(g_App._rebar);
+ int ySize = MyMax((int)(rect.bottom - headerSize), 0);
+
+ if (g_App.NumPanels > 1)
+ {
+ g_App.Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize);
+ int xWidth1 = g_Splitter.GetPos() + kSplitterWidth;
+ g_App.Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize);
+ }
+ else
+ {
+ /*
+ int otherPanel = 1 - g_App.LastFocusedPanel;
+ if (g_App.PanelsCreated[otherPanel])
+ g_App.Panels[otherPanel].Move(0, headerSize, 0, ySize);
+ */
+ g_App.Panels[g_App.LastFocusedPanel].Move(0, headerSize, xSize, ySize);
+ }
+#endif
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FM_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FM_rc.cpp
new file mode 100644
index 000000000..53d242c6a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FM_rc.cpp
@@ -0,0 +1,970 @@
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#include "wx/mimetype.h"
+#include "wx/artprov.h"
+#include "wx/imaglist.h"
+
+#include "resource.h"
+
+#include "App.h"
+
+#include "Windows/Control/DialogImpl.h"
+#include "Windows/Control/ListView.h"
+#include "Windows/Control/Window2.h"
+
+// FIXME
+#undef IDCLOSE
+#define IDCLOSE wxID_EXIT
+
+#define static const
+#include "../GUI/p7zip_32.xpm"
+#undef static
+
+extern HWND g_HWND;
+
+#define BASE_ID_PANEL_1 (1000 + 100 * 0)
+#define BASE_ID_PANEL_2 (1000 + 100 * 1)
+
+////////////////////////////////////// Tool bar images
+#include "res/AddPNG.h"
+#include "res/Add2PNG.h"
+#include "res/ExtractPNG.h"
+#include "res/Extract2PNG.h"
+#include "res/TestPNG.h"
+#include "res/Test2PNG.h"
+#include "res/CopyPNG.h"
+#include "res/Copy2PNG.h"
+#include "res/MovePNG.h"
+#include "res/Move2PNG.h"
+#include "res/DeletePNG.h"
+#include "res/Delete2PNG.h"
+#include "res/InfoPNG.h"
+#include "res/Info2PNG.h"
+
+#include <wx/mstream.h>
+#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name ## _png, sizeof(name ## _png))
+
+static inline wxBitmap _wxGetBitmapFromMemory(const unsigned char *data, int length) {
+ wxMemoryInputStream is(data, length);
+ return wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1);
+}
+
+///////////////////////////////////// SevenZipPanel.h /////////////////////
+
+#include <wx/listctrl.h>
+
+typedef wxListCtrl CExplorerListCtrl;
+
+class MyFrame;
+
+class SevenZipPanel : public wxPanel
+{
+ static int count;
+
+ CExplorerListCtrl *m_pListCtrlExplorer;
+ NWindows::NControl::CWindow2 *_wList;
+
+
+ wxBitmapButton *m_pBmpButtonParentFolder;
+ wxComboBox *m_pComboBoxPath;
+ wxStatusBar *m_pStatusBar;
+
+ MyFrame *m_frame;
+
+ wxImageList imgList;
+
+ int _panelIndex;
+
+ // wxString m_currentDirectory;
+
+ // int m_nbDirs;
+
+ // wxString m_prompt;
+
+public:
+ SevenZipPanel(MyFrame *frame, wxWindow *parent,int id,int panelIndex);
+
+ void registerWindow2(NWindows::NControl::CWindow2 *w)
+ {
+ _wList = w;
+ _wList->OnMessage(WM_CREATE,0,0);
+ }
+
+ void OnAnyButton( wxCommandEvent &event );
+ void OnSelected(wxListEvent& event);
+ void OnDeselected(wxListEvent& event);
+ void OnActivated(wxListEvent& event);
+ void OnFocused(wxListEvent& event);
+ void OnLeftDownBeginDrag(wxListEvent& event);
+ void OnRightClick(wxListEvent& event);
+ void OnColumnClick(wxListEvent& event);
+
+ void OnLeftDown(wxMouseEvent &event );
+ void OnRightDown(wxMouseEvent &event );
+
+ void WriteText(const wxString& text) {
+ printf("DEBUG : %ls\n",(const wchar_t *)text);
+ }
+
+ /* Don't work ...
+ void OnCloseWindow(wxCloseEvent& WXUNUSED(event)) {
+ _wList->OnDestroy();
+ }
+ */
+
+ void evt_destroy() {
+ _wList->OnDestroy();
+ }
+
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+
+
+///////////////////////////////////// SevenZipPanel.h /////////////////////
+
+
+
+class MyFrame: public wxFrame
+{
+public:
+ // ctor
+ MyFrame(void (*fct)(HWND),wxFrame *frame, const wxString& title, int x, int y, int w, int h);
+ // virtual ~MyFrame();
+
+ void registerWindow2(int baseID,NWindows::NControl::CWindow2 *w)
+ {
+ printf("MyFrame::registerWindow2(%d,%p)\n",baseID,w);
+ switch (baseID)
+ {
+ case BASE_ID_PANEL_1: _panel1->registerWindow2(w); break;
+ case BASE_ID_PANEL_2: _panel2->registerWindow2(w); break;
+ default: printf("FIXME - MyFrame::registerWindow2\n");
+ }
+ }
+
+ void PopulateToolbar(wxToolBar* toolBar);
+ void RecreateToolbar();
+
+
+protected:
+ // callbacks
+ void OnWorkerEvent(wxCommandEvent& event);
+ void OnAnyMenu(wxCommandEvent& event)
+ {
+ extern bool OnMenuCommand(HWND hWnd, int id);
+ extern void ExecuteCommand(UINT commandID);
+
+ int wmId = event.GetId();
+
+ if (wmId >= kToolbarStartID)
+ {
+ ExecuteCommand(wmId);
+ return ; // 0;
+ }
+ OnMenuCommand(this, wmId);
+ }
+ void OnCloseWindow(wxCloseEvent& WXUNUSED(event))
+ {
+ if (_panel1) _panel1->evt_destroy();
+ if (_panel2) _panel2->evt_destroy();
+
+ extern void main_WM_DESTROY();
+ main_WM_DESTROY();
+ Destroy();
+ }
+private:
+ SevenZipPanel * _panel1;
+ SevenZipPanel * _panel2;
+ DECLARE_EVENT_TABLE()
+};
+
+enum {
+ WORKER_EVENT=100 // this one gets sent from the worker thread
+};
+
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ EVT_MENU(WORKER_EVENT, MyFrame::OnWorkerEvent)
+ EVT_MENU(wxID_ANY, MyFrame::OnAnyMenu)
+ EVT_CLOSE(MyFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
+// My frame constructor
+MyFrame::MyFrame(void (*wm_create)(HWND),wxFrame *frame, const wxString& title,
+ int x, int y, int w, int h)
+ : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
+{
+printf("===MyFrame::MyFrame===BEGIN===\n");
+
+ this->SetIcon(wxICON(p7zip_32));
+
+ g_HWND = this; // FIXME
+
+ wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
+
+ _panel1 = new SevenZipPanel(this,this,BASE_ID_PANEL_1,0); // FIXME panelIndex = 0
+ _panel2 = 0;
+ topsizer->Add(
+ _panel1,
+ 1, // make vertically stretchable
+ wxEXPAND | // make horizontally stretchable
+ wxALL, // and make border all around
+ 0 ); // set border width to 10
+
+ // Create the toolbar
+ // FIXME RecreateToolbar();
+printf("===MyFrame::MyFrame===WM_CREATE===\n");
+ wm_create(this);
+
+ // Create the toolbar // FIXME
+ RecreateToolbar();
+
+
+printf("===MyFrame::MyFrame===SIZER===\n");
+
+ SetSizer( topsizer ); // use the sizer for layout
+
+ topsizer->SetSizeHints( this ); // set size hints to honour minimum size
+printf("===MyFrame::MyFrame===END===\n");
+}
+
+void myCreateHandle(int n);
+void MyFrame::OnWorkerEvent(wxCommandEvent& event)
+{
+ int n = event.GetInt();
+ myCreateHandle(n);
+}
+
+wxWindow * g_window=0;
+HWND myCreateAndShowMainWindow(LPCTSTR title,void (*fct)(HWND))
+{
+ MyFrame *frame = new MyFrame(fct,(wxFrame *)NULL, title, 50, 50, 450, 340);
+ // Don't Show the frame !
+ frame->Show(true); // FIXME
+
+ // FIXME : SetTopWindow(g_HWND);
+
+ g_window = frame;
+
+ return frame;
+}
+
+
+class myToolBar
+{
+ wxToolBar * m_toolbar;
+
+ bool m_bShowText;
+
+public:
+ myToolBar(wxToolBar * toolbar,bool bShowText ) : m_toolbar(toolbar), m_bShowText(bShowText) { }
+
+ myToolBar* AddTool(int toolId, const wxString& label, const wxBitmap& bitmap1, const wxString& shortHelpString = _T(""), wxItemKind kind = wxITEM_NORMAL)
+ {
+ wxString text = wxEmptyString;
+ if (m_bShowText) text = label;
+
+ wxSize tb_size = m_toolbar->GetToolBitmapSize();
+ int tb_witdh = tb_size.GetWidth();
+ int tb_height = tb_size.GetHeight();
+
+ if ((bitmap1.GetWidth() > tb_witdh) || ( bitmap1.GetHeight()> tb_height))
+ {
+ wxBitmap bmp(bitmap1.ConvertToImage().Scale(tb_witdh, tb_height));
+ m_toolbar->AddTool(toolId,text,bmp,shortHelpString,kind);
+ }
+ else
+ {
+ m_toolbar->AddTool(toolId,text,bitmap1,shortHelpString,kind);
+ }
+
+ return this;
+ }
+
+ void SetToolBitmapSize(const wxSize& size)
+ {
+ m_toolbar->SetToolBitmapSize(size);
+ }
+
+ bool Realize()
+ {
+ return m_toolbar->Realize();
+ }
+
+ void AddSeparator() { m_toolbar->AddSeparator(); }
+};
+
+void MyFrame::PopulateToolbar(wxToolBar* p_toolBar)
+{/*
+ toolBar->AddTool(wxID_NEW, _T("New"),toolBarBitmaps[Tool_new], wxNullBitmap, wxITEM_NORMAL,
+ _T("New file"), _T("This is help for new file tool"));
+ */
+ myToolBar toolBar(p_toolBar,true);
+
+ const int kWidth = 24;
+ const int kHeight = 24;
+
+ // FIXME toolBar->SetToolBitmapSize(wxSize(24,24));
+ toolBar.SetToolBitmapSize(wxSize(kWidth,kHeight));
+ toolBar.AddTool(kAddCommand, wxT("Add"), wxGetBitmapFromMemory(ADD2));
+ toolBar.AddTool(kExtractCommand,wxT("Extract"), wxGetBitmapFromMemory(EXTRACT2));
+ toolBar.AddTool(kTestCommand, wxT("Test"), wxGetBitmapFromMemory(TEST2));
+
+ toolBar.AddSeparator();
+
+ toolBar.AddTool(IDM_COPY_TO, wxT("Copy"), wxGetBitmapFromMemory(COPY2));
+ toolBar.AddTool(IDM_MOVE_TO, wxT("Move"), wxGetBitmapFromMemory(MOVE2));
+ toolBar.AddTool(IDM_DELETE, wxT("Delete"), wxGetBitmapFromMemory(DELETE2));
+ toolBar.AddTool(IDM_FILE_PROPERTIES, wxT("Info"), wxGetBitmapFromMemory(INFO2));
+
+ ////////////////////////////////////////////////////////
+
+ /* FIXME
+ if (g_mimeDatabase)
+ {
+ toolBar.AddSeparator();
+
+ TryMime(&toolBar, _T("txt"));
+ TryMime(&toolBar, _T("rar"));
+ TryMime(&toolBar, _T("7z"));
+ }
+
+ toolBar.AddSeparator();
+
+ wxIcon i_plus = wxArtProvider::GetIcon(wxART_ADD_BOOKMARK , wxART_TOOLBAR , wxSize(kWidth,kHeight));
+ toolBar.AddTool(wxID_ANY, wxT("Add Bookmark"), i_plus);
+
+ wxIcon i_go_up_dir = wxArtProvider::GetIcon(wxART_GO_DIR_UP , wxART_TOOLBAR , wxSize(kWidth,kHeight));
+ toolBar.AddTool(wxID_ANY, wxT("Go up dir"), i_go_up_dir);
+
+ wxIcon i_folder = wxArtProvider::GetIcon(wxART_FOLDER , wxART_TOOLBAR , wxSize(kWidth,kHeight));
+ toolBar.AddTool(wxID_ANY, wxT("Folder"), i_folder);
+
+ wxIcon i_missing_image = wxArtProvider::GetIcon(wxART_MISSING_IMAGE , wxART_TOOLBAR , wxSize(kWidth,kHeight));
+ toolBar.AddTool(wxID_ANY, wxT("missing image"), i_missing_image);
+ */
+
+ ///////////////////////////////////////////////////////
+
+ toolBar.Realize();
+
+ // toolBar->SetRows(!(toolBar->IsVertical()) ? m_rows : 10 / m_rows);
+}
+void MyFrame::RecreateToolbar()
+{
+ // delete and recreate the toolbar
+ wxToolBar *toolBar = GetToolBar();
+ // long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;
+
+ SetToolBar(NULL);
+
+ delete toolBar;
+ /*
+ style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT);
+ switch( m_toolbarPosition )
+ {
+ case TOOLBAR_LEFT:style |= wxTB_LEFT; break;
+ case TOOLBAR_TOP: style |= wxTB_TOP;break;
+ case TOOLBAR_RIGHT:style |= wxTB_RIGHT;break;
+ case TOOLBAR_BOTTOM:style |= wxTB_BOTTOM;break;
+ }
+ */
+ long style = wxTB_FLAT | wxTB_NODIVIDER | wxTB_TEXT; // TOOLBAR_STYLE | wxTB_TOP;
+ /*
+ if ( m_showTooltips ) style &= ~wxTB_NO_TOOLTIPS;
+ else style |= wxTB_NO_TOOLTIPS;
+
+ if ( style & wxTB_TEXT && !(style & wxTB_NOICONS) && m_horzText ) style |= wxTB_HORZ_LAYOUT;
+ */
+ toolBar = CreateToolBar(style, wxID_ANY);
+
+ PopulateToolbar(toolBar);
+}
+
+void registerWindow2(int baseID,NWindows::NControl::CWindow2 *w)
+{
+ MyFrame * f = (MyFrame *) g_HWND;
+ f->registerWindow2(baseID,w);
+
+}
+
+
+/////////////////////////////////////////////////////////
+#include "LangUtils.h"
+
+static const UINT kOpenBookmarkMenuID = 730; // FIXME / duplicate
+static const UINT kSetBookmarkMenuID = 740;
+
+
+void rc_MyLoadMenu(HWND hWnd)
+{
+ wxFrame *hwnd = (wxFrame *)hWnd;
+ wxMenu *m;
+ wxMenu *m_file = m = new wxMenu;
+ {
+ m->Append(IDM_FILE_OPEN, _T("&Open\tEnter"));
+ m->Append(IDM_FILE_OPEN_INSIDE,_T("Open &Inside\tCtrl+PgDn"));
+ m->Append(IDM_FILE_OPEN_OUTSIDE,_T("Open O&utside\tShift+Enter"));
+ m->Append(IDM_FILE_EDIT,_T("&Edit\tF4"));
+ m->AppendSeparator();
+ m->Append(IDM_RENAME,_T("Rena&me\tF2"));
+ m->Append(IDM_COPY_TO,_T("&Copy To...\tF5"));
+ m->Append(IDM_MOVE_TO,_T("&Move To...\tF6"));
+ m->Append(IDM_DELETE,_T("&Delete\tDel"));
+ m->AppendSeparator();
+ m->Append(IDM_FILE_SPLIT,_T("&Split file..."));
+ m->Append(IDM_FILE_COMBINE,_T("Com&bine files..."));
+ m->AppendSeparator();
+ m->Append(IDM_FILE_PROPERTIES,_T("P&roperties\tAlt+Enter"));
+ m->Append(IDM_FILE_COMMENT,_T("Comme&nt\tCtrl+Z"));
+ m->Append(IDM_FILE_CRC,_T("Calculate checksum"));
+ m->AppendSeparator();
+ m->Append(IDM_CREATE_FOLDER,_T("Create Folder\tF7"));
+ m->Append(IDM_CREATE_FILE,_T("Create File\tCtrl+N"));
+ m->AppendSeparator();
+ m->Append(IDCLOSE,_T("E&xit\tAlt+F4"));
+ }
+ wxMenu *m_edit = m = new wxMenu;
+ {
+ m->Append(IDM_EDIT_CUT, _T("Cu&t\tCtrl+X"))->Enable(true); // GRAYED
+ // m->Enable(IDM_EDIT_CUT, false);
+ m->Append(IDM_EDIT_COPY, _T("&Copy\tCtrl+C"))->Enable(true); // GRAYED
+ m->Append(IDM_EDIT_PASTE, _T("&Paste\tCtrl+V"))->Enable(true); // GRAYED
+ m->AppendSeparator();
+ m->Append(IDM_SELECT_ALL, _T("Select &All\tShift+[Grey +]"));
+ m->Append(IDM_DESELECT_ALL, _T("Deselect All\tShift+[Grey -]"));
+ m->Append(IDM_INVERT_SELECTION, _T("&Invert Selection\tGrey *"));
+ m->Append(IDM_SELECT, _T("Select...\tGrey +"));
+ m->Append(IDM_DESELECT, _T("Deselect...\tGrey -"));
+ m->Append(IDM_SELECT_BY_TYPE, _T("Select by Type\tAlt+[Grey+]"));
+ m->Append(IDM_DESELECT_BY_TYPE, _T("Deselect by Type\tAlt+[Grey -]"));
+ }
+ wxMenu *m_view = m = new wxMenu;
+ {
+ m->AppendRadioItem(IDM_VIEW_LARGE_ICONS, _T("Lar&ge Icons\tCtrl+1"));
+ m->AppendRadioItem(IDM_VIEW_SMALL_ICONS, _T("S&mall Icons\tCtrl+2"));
+ m->AppendRadioItem(IDM_VIEW_LIST, _T("&List\tCtrl+3"));
+ m->AppendRadioItem(IDM_VIEW_DETAILS, _T("&Details\tCtrl+4"))->Check(true); // CHECKED
+ m->AppendSeparator();
+ m->Append(IDM_VIEW_ARANGE_BY_NAME, _T("Name\tCtrl+F3"));
+ m->Append(IDM_VIEW_ARANGE_BY_TYPE, _T("Type\tCtrl+F4"));
+ m->Append(IDM_VIEW_ARANGE_BY_DATE, _T("Date\tCtrl+F5"));
+ m->Append(IDM_VIEW_ARANGE_BY_SIZE, _T("Size\tCtrl+F6"));
+ m->Append(IDM_VIEW_ARANGE_NO_SORT, _T("Unsorted\tCtrl+F7"));
+ m->AppendSeparator();
+ m->AppendCheckItem(IDM_VIEW_FLAT_VIEW, _T("Flat View"));
+ m->AppendCheckItem(IDM_VIEW_TWO_PANELS, _T("&2 Panels\tF9"));
+
+ {
+ wxMenu* subMenu = new wxMenu;
+ subMenu->AppendCheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, _T("Archive Toolbar"));
+ subMenu->AppendCheckItem(IDM_VIEW_STANDARD_TOOLBAR, _T("Standard Toolbar"));
+ subMenu->AppendSeparator();
+ subMenu->AppendCheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, _T("Large Buttons"));
+ subMenu->AppendCheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, _T("Show Buttons Text"));
+ m->Append(12112, _T("Toolbars"), subMenu); // FIXME ID ?
+ }
+ m->AppendSeparator();
+ m->Append(IDM_OPEN_ROOT_FOLDER, _T("Open Root Folder\t" STRING_PATH_SEPARATOR));
+ m->Append(IDM_OPEN_PARENT_FOLDER, _T("Up One Level\tBackspace"));
+ m->Append(IDM_FOLDERS_HISTORY, _T("Folders History...\tAlt+F12"));
+ m->AppendSeparator();
+ m->Append(IDM_VIEW_REFRESH, _T("&Refresh\tCtrl+R"));
+ }
+ wxMenu *m_favorites = m = new wxMenu;
+ {
+ {
+ wxMenu* subMenu = new wxMenu;
+ for (int i = 0; i < 10; i++)
+ {
+ UString s = LangString(IDS_BOOKMARK, 0x03000720);
+ s += L" ";
+ wchar_t c = (wchar_t)(L'0' + i);
+ s += c;
+ s += L"\tAlt+Shift+";
+ s += c;
+ subMenu->Append( kSetBookmarkMenuID + i, wxString(s));
+ }
+
+ m->Append(12111, _T("&Add folder to Favorites as"), subMenu); // FIXME ID ?
+ }
+ m->AppendSeparator();
+ for (int i = 0; i < 10; i++)
+ {
+ UString path = g_App.AppState.FastFolders.GetString(i);
+ const int kMaxSize = 100;
+ const int kFirstPartSize = kMaxSize / 2;
+ if (path.Length() > kMaxSize)
+ {
+ path = path.Left(kFirstPartSize) + UString(L" ... ") +
+ path.Right(kMaxSize - kFirstPartSize);
+ }
+ UString s = path;
+ if (s.IsEmpty())
+ s = L"-";
+ s += L"\tAlt+";
+ s += (wchar_t)(L'0' + i);
+ // menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
+ m->Append( kOpenBookmarkMenuID + i, wxString(s));
+ }
+
+ }
+ wxMenu *m_tools = m = new wxMenu;
+ {
+ m->Append(IDM_OPTIONS, _T("&Options..."));
+ m->Append(IDM_BENCHMARK, _T("&Benchmark"));
+ }
+ wxMenu *m_help = m = new wxMenu;
+ {
+ m->Append(IDM_HELP_CONTENTS, _T("&Contents...\tF1"));
+ m->AppendSeparator();
+ m->Append(IDM_ABOUT, _T("&About 7-Zip..."));
+ }
+
+ wxMenuBar *menuBar = new wxMenuBar;
+
+ menuBar->Append(m_file, _T("&File"));
+ menuBar->Append(m_edit, _T("&Edit"));
+ menuBar->Append(m_view, _T("&View"));
+ menuBar->Append(m_favorites, _T("F&avorites"));
+ menuBar->Append(m_tools, _T("&Tools"));
+ menuBar->Append(m_help, _T("&Help"));
+ hwnd->SetMenuBar(menuBar);
+}
+
+//////////////////////////////////////////////////////////////////
+
+
+static CStringTable g_stringTable[] =
+{
+ /* resource.rc */
+ /***************/
+ { IDS_APP_TITLE, L"7-Zip File Manager" },
+
+ { IDS_COPY , L"Copy" },
+ { IDS_MOVE , L"Move" },
+ { IDS_COPY_TO , L"Copy to:" },
+ { IDS_MOVE_TO , L"Move to:" },
+ { IDS_COPYING , L"Copying..." },
+ { IDS_MOVING , L"Moving..." },
+ { IDS_CANNOT_COPY , L"You cannot move or copy items for such folders." },
+ { IDS_SPLITTING , L"Splitting..." },
+ { IDS_SPLIT_CONFIRM_TITLE , L"Confirm Splitting" },
+ { IDS_SPLIT_CONFIRM_MESSAGE , L"Are you sure you want to split file into {0} volumes?" },
+ { IDS_SPLIT_VOL_MUST_BE_SMALLER , L"Volume size must be smaller than size of original file" },
+
+ { IDS_COMBINE , L"Combine Files" },
+ { IDS_COMBINE_TO , L"&Combine to:" },
+ { IDS_COMBINING , L"Combining..." },
+ { IDS_COMBINE_SELECT_ONE_FILE , L"Select only first file" },
+
+ { IDS_CHECKSUM_CALCULATING , L"Checksum calculating..." },
+ { IDS_CHECKSUM_INFORMATION , L"Checksum information" },
+ { IDS_CHECKSUM_CRC_DATA , L"CRC checksum for data:" },
+ { IDS_CHECKSUM_CRC_DATA_NAMES , L"CRC checksum for data and names:" },
+
+ { IDS_SCANNING , L"Scanning..." },
+
+ { IDS_PROPERTIES , L"Properties" },
+
+ { IDS_OPERATION_IS_NOT_SUPPORTED , L"Operation is not supported." },
+
+ { IDS_CONFIRM_FILE_DELETE , L"Confirm File Delete" },
+ { IDS_CONFIRM_FOLDER_DELETE , L"Confirm Folder Delete" },
+ { IDS_CONFIRM_ITEMS_DELETE , L"Confirm Multiple File Delete" },
+ { IDS_WANT_TO_DELETE_FILE , L"Are you sure you want to delete '{0}'?" },
+ { IDS_WANT_TO_DELETE_FOLDER , L"Are you sure you want to delete the folder '{0}' and all its contents?" },
+ { IDS_WANT_TO_DELETE_ITEMS , L"Are you sure you want to delete these {0} items?" },
+ { IDS_DELETING , L"Deleting..." },
+ { IDS_ERROR_DELETING , L"Error Deleting File or Folder" },
+ { IDS_RENAMING , L"Renaming..." },
+ { IDS_ERROR_RENAMING , L"Error Renaming File or Folder" },
+ { IDS_CONFIRM_FILE_COPY , L"Confirm File Copy" },
+ { IDS_WANT_TO_COPY_FILES , L"Are you sure you want to copy files to archive" },
+
+ { IDS_CREATE_FOLDER , L"Create Folder" },
+ { IDS_CREATE_FOLDER_NAME , L"Folder name:" },
+ { IDS_CREATE_FOLDER_DEFAULT_NAME , L"New Folder" },
+ { IDS_CREATE_FOLDER_ERROR , L"Error Creating Folder" },
+ { IDS_CREATE_FILE , L"Create File" },
+ { IDS_CREATE_FILE_NAME , L"File Name:" },
+ { IDS_CREATE_FILE_DEFAULT_NAME , L"New File" },
+ { IDS_CREATE_FILE_ERROR , L"Error Creating File" },
+ { IDS_SELECT , L"Select" },
+ { IDS_DESELECT , L"Deselect" },
+ { IDS_SELECT_MASK , L"Mask:" },
+ { IDS_FOLDERS_HISTORY , L"Folders History" },
+ { IDS_N_SELECTED_ITEMS , L"{0} object(s) selected" },
+ { IDS_FILES_COLON , L"Files:" },
+ { IDS_FOLDERS_COLON , L"Folders:" },
+ { IDS_SIZE_COLON , L"Size:" },
+
+ { IDS_PROP_TOTAL_SIZE , L"Total Size" },
+ { IDS_PROP_FREE_SPACE , L"Free Space" },
+ { IDS_PROP_CLUSTER_SIZE , L"Cluster Size" },
+ { IDS_PROP_VOLUME_NAME , L"Label" },
+ { IDS_PROP_LOCAL_NAME , L"Local Name" },
+ { IDS_PROP_PROVIDER , L"Provider" },
+ { IDS_OPTIONS , L"Options" },
+ { IDS_COMMENT , L"Comment" },
+ { IDS_COMMENT2 , L"&Comment:" },
+ { IDS_SYSTEM , L"System" },
+ { IDS_TOO_MANY_ITEMS , L"Too many items" },
+ { IDS_WANT_UPDATE_MODIFIED_FILE , L"File '{0}' was modified.\nDo you want to update it in the archive?" },
+ { IDS_CANNOT_UPDATE_FILE , L"Can not update file\n'{0}'" },
+ { IDS_CANNOT_START_EDITOR , L"Cannot start editor." },
+ { IDS_OPENNING , L"Opening..." },
+ { IDS_ADD , L"Add" },
+ { IDS_EXTRACT , L"Extract" },
+ { IDS_TEST , L"Test" },
+ { IDS_BUTTON_COPY , L"Copy" },
+ { IDS_BUTTON_MOVE , L"Move" },
+ { IDS_BUTTON_DELETE , L"Delete" },
+ { IDS_BUTTON_INFO , L"Info" },
+ { IDS_BOOKMARK , L"Bookmark" },
+ { IDS_COMPUTER , L"Computer" },
+ { IDS_NETWORK , L"Network" },
+
+ { IDS_PROGRESS_TESTING , L"Testing" },
+ { IDS_MESSAGE_NO_ERRORS , L"There are no errors" },
+
+ { 0 , 0 }
+};
+
+REGISTER_STRINGTABLE(g_stringTable)
+
+/////////////////////////////////////////////////////
+
+#include "res/ParentFolder.h"
+
+ SevenZipPanel::SevenZipPanel(MyFrame *frame, wxWindow *parent,int id,int panelIndex) :
+ wxPanel(parent,id) , m_frame(frame), _wList(0)
+ {
+ _panelIndex = panelIndex;
+
+ int _baseID = id; // FIXME
+ int _listID = _baseID + 1;
+ int _comboBoxID = _baseID + 3;
+ int _statusBarID = _comboBoxID + 1;
+ int kParentFolderID = 100; // FIXME Panel.h
+
+
+ ///Sizer for adding the controls created by users
+ wxBoxSizer* pMainSizer = new wxBoxSizer(wxVERTICAL);
+ int sizes[] = {150, 250, 350, -1};
+ wxArrayString pathArray;
+ wxBoxSizer *pPathSizer = new wxBoxSizer(wxHORIZONTAL);
+ m_pBmpButtonParentFolder = new wxBitmapButton(this, kParentFolderID, wxGetBitmapFromMemory(PARENT_FOLDER), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW);
+ m_pComboBoxPath = new wxComboBox(this, _comboBoxID, wxEmptyString, wxDefaultPosition, wxSize(300,-1), pathArray, wxCB_DROPDOWN | wxCB_SORT );
+ pPathSizer->Add(m_pBmpButtonParentFolder, 0, wxALL|wxEXPAND, 0);
+ pPathSizer->Add(m_pComboBoxPath, 1, wxALL|wxEXPAND, 5);
+
+ m_pListCtrlExplorer = new CExplorerListCtrl(this,_listID,wxDefaultPosition, wxSize(300,300),
+ wxLC_REPORT |
+ wxSUNKEN_BORDER | wxLC_EDIT_LABELS);
+
+ printf("DEBUG : new CExplorerListCtrl(id=%d) => %p\n",_listID,m_pListCtrlExplorer);
+
+ m_pStatusBar = new wxStatusBar(this, _statusBarID);
+ m_pStatusBar->SetFieldsCount(4, sizes);
+ pMainSizer->Add(pPathSizer, 0, wxALL|wxEXPAND, 0);
+ pMainSizer->Add(m_pListCtrlExplorer, 1, wxALL|wxEXPAND, 0);
+ pMainSizer->Add(m_pStatusBar, 0, wxALL|wxEXPAND, 0);
+ SetSizer(pMainSizer);
+ SetAutoLayout (true);
+ Layout();
+
+
+ // m_pListCtrlExplorer->SetDropTarget(new DnDFile(this));
+
+ }
+
+ void SevenZipPanel::OnAnyButton( wxCommandEvent &event )
+ {
+ count++;
+
+ int id = event.GetId();
+
+ wxString msg = wxString::Format(_T("P %d : button %d \n"), count,id);
+
+ WriteText(msg);
+
+ _wList->OnMessage(WM_COMMAND , id , 0);
+ }
+
+ void SevenZipPanel::OnSelected(wxListEvent& event)
+ {
+ const wxListItem & item = event.GetItem();
+ count++;
+
+ wxString msg = wxString::Format(_T("P %d : OnSelected %d \n"), count,event.GetId());
+
+ WriteText(msg);
+
+ NMLISTVIEW info;
+ info.hdr.hwndFrom = m_pListCtrlExplorer;
+ info.hdr.code = LVN_ITEMCHANGED;
+ info.uOldState = 0;
+ info.uNewState = LVIS_SELECTED;
+ info.lParam = item.GetData(); // event.GetIndex(); // FIXME ? event.GetData();
+ _wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
+ /*
+ if ( GetWindowStyle() & wxLC_REPORT )
+ {
+ wxListItem info;
+ info.m_itemId = event.m_itemIndex;
+ info.m_col = 1;
+ info.m_mask = wxLIST_MASK_TEXT;
+ if ( GetItem(info) )
+ {
+ wxLogMessage(wxT("Value of the 2nd field of the selected item: %s"),
+ info.m_text.c_str());
+ }
+ else
+ {
+ wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
+ }
+ }
+ */
+ }
+
+ void SevenZipPanel::OnDeselected(wxListEvent& event)
+ {
+ const wxListItem & item = event.GetItem();
+ count++;
+ wxString msg = wxString::Format(_T("P %d : OnDeselected %d \n"), count,event.GetId());
+ WriteText(msg);
+
+ NMLISTVIEW info;
+ info.hdr.hwndFrom = m_pListCtrlExplorer;
+ info.hdr.code = LVN_ITEMCHANGED;
+ info.uOldState = LVIS_SELECTED;
+ info.uNewState = 0;
+ info.lParam = item.GetData(); // event.GetIndex(); // FIXME ? event.GetData();
+ _wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
+ }
+
+ void SevenZipPanel::OnColumnClick(wxListEvent& event)
+ {
+ count++;
+ wxString msg = wxString::Format(_T("P %d : OnColumnClick %d col=%d\n"), count,event.GetId(),event.GetColumn());
+ WriteText(msg);
+
+ NMLISTVIEW info;
+ info.hdr.hwndFrom = m_pListCtrlExplorer;
+ info.hdr.code = LVN_COLUMNCLICK;
+ info.iSubItem = event.GetColumn();
+ _wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
+
+ }
+
+
+ void SevenZipPanel::OnActivated(wxListEvent& event)
+ {
+ count++;
+
+ int ind = event.GetIndex();
+
+ NMHDR info;
+ info.hwndFrom = m_pListCtrlExplorer;
+ info.code = NM_DBLCLK;
+ _wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
+
+ /*
+ if ((ind >= 0) && ( ind < m_nbDirs))
+ {
+ wxString msg = wxString::Format(_T("P %d : OnActivated %d : DIR = %d\n"), count,event.GetId(),ind);
+ WriteText(msg);
+
+ wxString name = m_pListCtrlExplorer->GetItemText(ind);
+
+ wxFileName filename (m_currentDirectory,name);
+ BinPath(filename.GetFullPath());
+
+ }
+ else
+ */
+ {
+ wxString msg = wxString::Format(_T("P %d : OnActivated %d : FILE = %d\n"), count,event.GetId(),ind);
+ WriteText(msg);
+ }
+
+
+ }
+
+ void SevenZipPanel::OnFocused(wxListEvent& event)
+ {
+ count++;
+
+ wxString msg = wxString::Format(_T("P %d : OnFocused %d \n"), count,event.GetId());
+
+ WriteText(msg);
+
+ event.Skip();
+ }
+
+ void SevenZipPanel::OnLeftDownBeginDrag(wxListEvent& event)
+ {
+ count++;
+
+ wxString msg = wxString::Format(_T("P %d : OnLeftDownBeginDrag %d \n"), count,event.GetId());
+ WriteText(msg);
+
+#if 0
+ if ( m_pListCtrlExplorer->GetSelectedItemCount() < 1) return ;
+
+ // start drag operation
+ wxFileDataObject filesData;
+
+
+ long item = -1;
+ for ( ;; )
+ {
+ item = m_pListCtrlExplorer->GetNextItem(item,
+ wxLIST_NEXT_ALL,
+ wxLIST_STATE_SELECTED);
+ if ( item == -1 )
+ break;
+
+ // this item is selected - do whatever is needed with it
+ // wxLogMessage("Item %ld is selected.", item);
+ wxString file = m_currentDirectory + _T("/") + m_pListCtrlExplorer->GetItemText(item);
+
+ filesData.AddFile(file);
+
+ }
+
+ msg = wxString::Format(_T("P %d : wxDropSource %d \n"), count,event.GetId());
+ WriteText(msg);
+
+ wxDropSource source(filesData, this,
+ wxDROP_ICON(dnd_copy),
+ wxDROP_ICON(dnd_move),
+ wxDROP_ICON(dnd_none));
+
+ int flags = 0;
+ /*
+ if ( m_moveByDefault )
+ flags |= wxDrag_DefaultMove;
+ else if ( m_moveAllow )
+ flags |= wxDrag_AllowMove;
+ */
+ flags |= wxDrag_AllowMove;
+
+ msg = wxString::Format(_T("P %d : DoDragDrop %d \n"), count,event.GetId());
+ WriteText(msg);
+
+
+ wxDragResult result = source.DoDragDrop(flags);
+
+
+ const wxChar *pc;
+ switch ( result )
+ {
+ case wxDragError: pc = _T("Error!"); break;
+ case wxDragNone: pc = _T("Nothing"); break;
+ case wxDragCopy: pc = _T("Copied"); break;
+ case wxDragMove: pc = _T("Moved"); break;
+ case wxDragCancel: pc = _T("Cancelled"); break;
+ default: pc = _T("Huh?"); break;
+ }
+
+ WriteText(wxString(_T(" Drag result: ")) + pc);
+#endif
+ }
+
+void SevenZipPanel::OnLeftDown(wxMouseEvent &WXUNUSED(event) )
+{
+ WriteText(_T("OnLeftDown"));
+#if 0
+ if ( !m_strText.empty() )
+ {
+ // start drag operation
+ wxTextDataObject textData(m_strText);
+ wxDropSource source(textData, this,
+ wxDROP_ICON(dnd_copy),
+ wxDROP_ICON(dnd_move),
+ wxDROP_ICON(dnd_none));
+
+ int flags = 0;
+ if ( m_moveByDefault )
+ flags |= wxDrag_DefaultMove;
+ else if ( m_moveAllow )
+ flags |= wxDrag_AllowMove;
+
+ wxDragResult result = source.DoDragDrop(flags);
+
+#if wxUSE_STATUSBAR
+ const wxChar *pc;
+ switch ( result )
+ {
+ case wxDragError: pc = _T("Error!"); break;
+ case wxDragNone: pc = _T("Nothing"); break;
+ case wxDragCopy: pc = _T("Copied"); break;
+ case wxDragMove: pc = _T("Moved"); break;
+ case wxDragCancel: pc = _T("Cancelled"); break;
+ default: pc = _T("Huh?"); break;
+ }
+
+ SetStatusText(wxString(_T("Drag result: ")) + pc);
+#else
+ wxUnusedVar(result);
+#endif // wxUSE_STATUSBAR
+ }
+#endif // wxUSE_DRAG_AND_DROP
+}
+
+void SevenZipPanel::OnRightClick(wxListEvent& event)
+{
+ wxPoint point = event.GetPoint();
+
+ WriteText(_T("OnRightClick"));
+ wxMenu menu; // (_T("Dnd sample menu"));
+
+ menu.Append(wxID_ANY, _T("&Test drag..."));
+ menu.AppendSeparator();
+ menu.Append(wxID_ANY, _T("item1"));
+ menu.Append(wxID_ANY, _T("item2"));
+ menu.Append(wxID_ANY, _T("item3"));
+ menu.Append(wxID_ANY, _T("&About"));
+
+ PopupMenu( &menu, point.x, point.y );
+}
+
+int SevenZipPanel::count = 0;
+
+BEGIN_EVENT_TABLE(SevenZipPanel, wxPanel)
+// EVT_MENU(wxID_ANY, SevenZipPanel::OnAnyMenu)
+// EVT_LISTBOX (wxID_ANY, MyPanel::OnListBox)
+// EVT_LISTBOX_DCLICK(wxID_ANY, MyPanel::OnAnyListBoxDoubleClick)
+EVT_BUTTON (wxID_ANY, SevenZipPanel::OnAnyButton)
+
+ // EVT_CLOSE(SevenZipPanel::OnCloseWindow)
+
+/////////////////
+EVT_LIST_ITEM_SELECTED(wxID_ANY, SevenZipPanel::OnSelected)
+EVT_LIST_ITEM_DESELECTED(wxID_ANY, SevenZipPanel::OnDeselected)
+EVT_LIST_ITEM_ACTIVATED(wxID_ANY, SevenZipPanel::OnActivated)
+EVT_LIST_ITEM_FOCUSED(wxID_ANY, SevenZipPanel::OnFocused)
+
+EVT_LIST_BEGIN_DRAG(wxID_ANY, SevenZipPanel::OnLeftDownBeginDrag)
+EVT_LIST_ITEM_RIGHT_CLICK(wxID_ANY, SevenZipPanel::OnRightClick)
+
+EVT_LIST_COL_CLICK(wxID_ANY, SevenZipPanel::OnColumnClick)
+
+END_EVENT_TABLE()
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSDrives.h.out b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSDrives.h.out
new file mode 100644
index 000000000..84db5b7e2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSDrives.h.out
@@ -0,0 +1,49 @@
+// FSDrives.h
+
+#ifndef __FSDRIVES_H
+#define __FSDRIVES_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+#include "Common/MyCom.h"
+#include "Windows/FileFind.h"
+#include "Windows/PropVariant.h"
+
+#include "IFolder.h"
+
+struct CDriveInfo
+{
+ UString Name;
+ UString FullSystemName;
+ bool KnownSizes;
+ UInt64 DriveSize;
+ UInt64 FreeSpace;
+ UInt64 ClusterSize;
+ UString Type;
+ UString VolumeName;
+ UString FileSystemName;
+};
+
+class CFSDrives:
+ public IFolderFolder,
+ public IFolderGetSystemIconIndex,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(
+ IFolderGetSystemIconIndex
+ )
+
+ INTERFACE_FolderFolder(;)
+
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
+
+private:
+ HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
+ CObjectVector<CDriveInfo> _drives;
+ bool _volumeMode;
+public:
+ void Init() { _volumeMode = false;}
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolder.cpp
new file mode 100644
index 000000000..9c2aaa613
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolder.cpp
@@ -0,0 +1,701 @@
+// FSFolder.cpp
+
+#include "StdAfx.h"
+
+#include "FSFolder.h"
+
+#include "Common/StringConvert.h"
+#include "Common/UTFConvert.h"
+#include "Common/ComTry.h"
+
+#include "Windows/Defs.h"
+#include "Windows/PropVariant.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileIO.h"
+
+#include "../../PropID.h"
+
+#include "SysIconUtils.h"
+#ifdef _WIN32
+#include "FSDrives.h"
+#include "NetFolder.h"
+#endif
+
+namespace NWindows {
+namespace NFile {
+
+bool GetLongPath(LPCWSTR path, UString &longPath);
+
+}}
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+namespace NFsFolder {
+
+static STATPROPSTG kProperties[] =
+{
+ { NULL, kpidName, VT_BSTR},
+ // { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidComment, VT_BSTR},
+ { NULL, kpidPrefix, VT_BSTR}
+};
+
+HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
+{
+ _parentFolder = parentFolder;
+ _path = path;
+
+#ifdef _WIN32
+ _findChangeNotification.FindFirst(_path, false,
+ FILE_NOTIFY_CHANGE_FILE_NAME |
+ FILE_NOTIFY_CHANGE_DIR_NAME |
+ FILE_NOTIFY_CHANGE_ATTRIBUTES |
+ FILE_NOTIFY_CHANGE_SIZE |
+ FILE_NOTIFY_CHANGE_LAST_WRITE /*|
+ FILE_NOTIFY_CHANGE_LAST_ACCESS |
+ FILE_NOTIFY_CHANGE_CREATION |
+ FILE_NOTIFY_CHANGE_SECURITY */);
+ if (!_findChangeNotification.IsHandleAllocated())
+ {
+ DWORD lastError = GetLastError();
+ CFindFile findFile;
+ CFileInfoW fileInfo;
+ if (!findFile.FindFirst(_path + UString(L"*"), fileInfo))
+ return lastError;
+ }
+#endif
+ return S_OK;
+}
+
+HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
+{
+ RINOK(progress->SetCompleted(NULL));
+ numFiles = numFolders = size = 0;
+ CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*"));
+ CFileInfoW fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ if (fileInfo.IsDir())
+ {
+ UInt64 subFolders, subFiles, subSize;
+ RINOK(GetFolderSize(path + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name, subFolders, subFiles, subSize, progress));
+ numFolders += subFolders;
+ numFolders++;
+ numFiles += subFiles;
+ size += subSize;
+ }
+ else
+ {
+ numFiles++;
+ size += fileInfo.Size;
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
+{
+ {
+ CEnumeratorW enumerator(path + L"*");
+ CDirItem fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ fileInfo.CompressedSizeIsDefined = false;
+ /*
+ if (!GetCompressedFileSize(_path + fileInfo.Name,
+ fileInfo.CompressedSize))
+ fileInfo.CompressedSize = fileInfo.Size;
+ */
+ if (fileInfo.IsDir())
+ {
+ // fileInfo.Size = GetFolderSize(_path + fileInfo.Name);
+ fileInfo.Size = 0;
+ }
+ dirItem.Files.Add(fileInfo);
+ }
+ }
+ if (!_flatMode)
+ return S_OK;
+
+ for (int i = 0; i < dirItem.Files.Size(); i++)
+ {
+ CDirItem &item = dirItem.Files[i];
+ if (item.IsDir())
+ LoadSubItems(item, path + item.Name + WCHAR_PATH_SEPARATOR);
+ }
+ return S_OK;
+}
+
+void CFSFolder::AddRefs(CDirItem &dirItem)
+{
+ int i;
+ for (i = 0; i < dirItem.Files.Size(); i++)
+ {
+ CDirItem &item = dirItem.Files[i];
+ item.Parent = &dirItem;
+ _refs.Add(&item);
+ }
+ if (!_flatMode)
+ return;
+ for (i = 0; i < dirItem.Files.Size(); i++)
+ {
+ CDirItem &item = dirItem.Files[i];
+ if (item.IsDir())
+ AddRefs(item);
+ }
+}
+
+STDMETHODIMP CFSFolder::LoadItems()
+{
+ // OutputDebugString(TEXT("Start\n"));
+ INT32 dummy;
+ WasChanged(&dummy);
+ Clear();
+ RINOK(LoadSubItems(_root, _path));
+ AddRefs(_root);
+
+ // OutputDebugString(TEXT("Finish\n"));
+ _commentsAreLoaded = false;
+ return S_OK;
+}
+
+static const wchar_t *kDescriptionFileName = L"descript.ion";
+
+bool CFSFolder::LoadComments()
+{
+ if (_commentsAreLoaded)
+ return true;
+ _comments.Clear();
+ _commentsAreLoaded = true;
+ NIO::CInFile file;
+ if (!file.Open(_path + kDescriptionFileName))
+ return false;
+ UInt64 length;
+ if (!file.GetLength(length))
+ return false;
+ if (length >= (1 << 28))
+ return false;
+ AString s;
+ char *p = s.GetBuffer((int)((size_t)length + 1));
+ UInt32 processedSize;
+ file.Read(p, (UInt32)length, processedSize);
+ p[length] = 0;
+ s.ReleaseBuffer();
+ if (processedSize != length)
+ return false;
+ file.Close();
+ UString unicodeString;
+ if (!ConvertUTF8ToUnicode(s, unicodeString))
+ return false;
+ return _comments.ReadFromString(unicodeString);
+}
+
+static bool IsAscii(const UString &testString)
+{
+ for (int i = 0; i < testString.Length(); i++)
+ if (testString[i] >= 0x80)
+ return false;
+ return true;
+}
+
+bool CFSFolder::SaveComments()
+{
+ NIO::COutFile file;
+ if (!file.Create(_path + kDescriptionFileName, true))
+ return false;
+ UString unicodeString;
+ _comments.SaveToString(unicodeString);
+ AString utfString;
+ ConvertUnicodeToUTF8(unicodeString, utfString);
+ UInt32 processedSize;
+ if (!IsAscii(unicodeString))
+ {
+ Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A };
+ file.Write(bom , sizeof(bom), processedSize);
+ }
+ file.Write(utfString, utfString.Length(), processedSize);
+ _commentsAreLoaded = false;
+ return true;
+}
+
+STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _refs.Size();
+ return S_OK;
+}
+
+/*
+STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
+{
+ UInt32 numSubFoldersLoc = 0;
+ for (int i = 0; i < _files.Size(); i++)
+ if (_files[i].IsDir())
+ numSubFoldersLoc++;
+ *numSubFolders = numSubFoldersLoc;
+ return S_OK;
+}
+*/
+
+#ifdef _WIN32
+bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
+{
+ DWORD highPart;
+ DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
+ if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
+ {
+ #ifdef WIN_LONG_PATH
+ {
+ UString longPath;
+ if (GetLongPath(fileName, longPath))
+ lowPart = ::GetCompressedFileSizeW(longPath, &highPart);
+ }
+ #endif
+ if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
+ return false;
+ }
+ size = (UInt64(highPart) << 32) | lowPart;
+ return true;
+}
+#endif
+
+STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ if (itemIndex >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ CDirItem &fileInfo = *_refs[itemIndex];
+ switch(propID)
+ {
+ case kpidIsDir: prop = fileInfo.IsDir(); break;
+ case kpidName: prop = fileInfo.Name; break;
+ case kpidSize: if (!fileInfo.IsDir()) prop = fileInfo.Size; break;
+ case kpidPackSize:
+ if (!fileInfo.CompressedSizeIsDefined)
+ {
+ fileInfo.CompressedSizeIsDefined = true;
+#ifdef _WIN32
+ if (fileInfo.IsDir () ||
+ !MyGetCompressedFileSizeW(_path + GetRelPath(fileInfo), fileInfo.CompressedSize))
+#endif
+ fileInfo.CompressedSize = fileInfo.Size;
+ }
+ prop = fileInfo.CompressedSize;
+ break;
+ case kpidAttrib: prop = (UInt32)fileInfo.Attrib; break;
+ case kpidCTime: prop = fileInfo.CTime; break;
+ case kpidATime: prop = fileInfo.ATime; break;
+ case kpidMTime: prop = fileInfo.MTime; break;
+ case kpidComment:
+ {
+ LoadComments();
+ UString comment;
+ if (_comments.GetValue(GetRelPath(fileInfo), comment))
+ prop = comment;
+ break;
+ }
+ case kpidPrefix:
+ {
+ if (_flatMode)
+ {
+ prop = GetPrefix(fileInfo);
+ }
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ CFSFolder *folderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> subFolder = folderSpec;
+ RINOK(folderSpec->Init(_path + name + UString(WCHAR_PATH_SEPARATOR), 0));
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+}
+
+UString CFSFolder::GetPrefix(const CDirItem &item) const
+{
+ UString path;
+ CDirItem *cur = item.Parent;
+ while (cur->Parent != 0)
+ {
+ path = cur->Name + UString(WCHAR_PATH_SEPARATOR) + path;
+ cur = cur->Parent;
+ }
+ return path;
+}
+
+UString CFSFolder::GetRelPath(const CDirItem &item) const
+{
+ return GetPrefix(item) + item.Name;
+}
+
+STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ const CDirItem &fileInfo = *_refs[index];
+ if (!fileInfo.IsDir())
+ return E_INVALIDARG;
+ return BindToFolderSpec(GetRelPath(fileInfo), resultFolder);
+}
+
+STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ return BindToFolderSpec(name, resultFolder);
+}
+
+STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ if (_parentFolder)
+ {
+ CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
+ *resultFolder = parentFolder.Detach();
+ return S_OK;
+ }
+ if (_path.IsEmpty())
+ return E_INVALIDARG;
+ printf("CFSFolder::BindToParentFolder path='%ls'\n",(const wchar_t *)_path);
+ int pos = _path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0 || pos != _path.Length() - 1)
+ return E_FAIL;
+ UString parentPath = _path.Left(pos);
+ printf("CFSFolder::BindToParentFolder parentPath='%ls'\n",(const wchar_t *)parentPath);
+ pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0)
+ {
+#ifdef _WIN32
+ parentPath.Empty();
+ CFSDrives *drivesFolderSpec = new CFSDrives;
+ CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
+ drivesFolderSpec->Init();
+ *resultFolder = drivesFolder.Detach();
+#else
+ parentPath = WSTRING_PATH_SEPARATOR;
+ CFSFolder *parentFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
+ printf("CFSFolder::BindToParentFolder Init-0 with parentPath='%ls'\n",(const wchar_t *)parentPath);
+ RINOK(parentFolderSpec->Init(parentPath, 0));
+ *resultFolder = parentFolder.Detach();
+#endif
+ return S_OK;
+ }
+ UString parentPathReduced = parentPath.Left(pos);
+ parentPath = parentPath.Left(pos + 1);
+ pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos == 1)
+ {
+#ifdef _WIN32
+ if (parentPath[0] != WCHAR_PATH_SEPARATOR)
+ return E_FAIL;
+ CNetFolder *netFolderSpec = new CNetFolder;
+ CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
+ netFolderSpec->Init(parentPath);
+ *resultFolder = netFolder.Detach();
+#else
+ parentPath = WSTRING_PATH_SEPARATOR;
+ CFSFolder *parentFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
+ printf("CFSFolder::BindToParentFolder Init-1 with parentPath='%ls'\n",(const wchar_t *)parentPath);
+ RINOK(parentFolderSpec->Init(parentPath, 0));
+ *resultFolder = parentFolder.Detach();
+#endif // ifdef _WIN32
+ return S_OK;
+ }
+ CFSFolder *parentFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
+ printf("CFSFolder::BindToParentFolder Init-2 with parentPath='%ls'\n",(const wchar_t *)parentPath);
+ RINOK(parentFolderSpec->Init(parentPath, 0));
+ *resultFolder = parentFolder.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties)
+{
+ *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
+ if (!_flatMode)
+ (*numProperties)--;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
+ return E_INVALIDARG;
+ const STATPROPSTG &prop = kProperties[index];
+ *propID = prop.propid;
+ *varType = prop.vt;
+ *name = 0;
+ return S_OK;
+}
+
+
+STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidType: prop = L"FSFolder"; break;
+ case kpidPath: prop = _path; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CFSFolder::WasChanged(INT32 *wasChanged)
+{
+ bool wasChangedMain = false;
+#ifdef _WIN32
+ for (;;)
+ {
+ if (!_findChangeNotification.IsHandleAllocated())
+ {
+ *wasChanged = BoolToInt(false);
+ return S_OK;
+ }
+
+ DWORD waitResult = ::WaitForSingleObject(_findChangeNotification, 0);
+ bool wasChangedLoc = (waitResult == WAIT_OBJECT_0);
+ if (wasChangedLoc)
+ {
+ _findChangeNotification.FindNext();
+ wasChangedMain = true;
+ }
+ else
+ break;
+ }
+#endif
+ *wasChanged = BoolToInt(wasChangedMain);
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
+{
+ CFSFolder *fsFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> folderNew = fsFolderSpec;
+ fsFolderSpec->Init(_path, 0);
+ *resultFolder = folderNew.Detach();
+ return S_OK;
+}
+
+HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
+ UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
+{
+ numFiles = numFolders = size = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ int index = indices[i];
+ if (index >= _refs.Size())
+ return E_INVALIDARG;
+ const CDirItem &fileInfo = *_refs[index];
+ if (fileInfo.IsDir())
+ {
+ UInt64 subFolders, subFiles, subSize;
+ RINOK(GetFolderSize(_path + GetRelPath(fileInfo), subFolders, subFiles, subSize, progress));
+ numFolders += subFolders;
+ numFolders++;
+ numFiles += subFiles;
+ size += subSize;
+ }
+ else
+ {
+ numFiles++;
+ size += fileInfo.Size;
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
+{
+ const CDirItem &fileInfo = *_refs[index];
+ if (fileInfo.IsDir())
+ {
+ /*
+ CMyComPtr<IFolderFolder> subFolder;
+ RINOK(BindToFolder(index, &subFolder));
+ CMyComPtr<IFolderReload> aFolderReload;
+ subFolder.QueryInterface(&aFolderReload);
+ aFolderReload->Reload();
+ UInt32 numItems;
+ RINOK(subFolder->GetNumberOfItems(&numItems));
+ CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize;
+ subFolder.QueryInterface(&aGetItemFullSize);
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ UInt64 size;
+ RINOK(aGetItemFullSize->GetItemFullSize(i, &size));
+ *totalSize += size;
+ }
+ */
+ UInt64 numFolders, numFiles;
+ return GetFolderSize(_path + GetRelPath(fileInfo), numFolders, numFiles, size, progress);
+ }
+ size = fileInfo.Size;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
+{
+ NCOM::CPropVariant prop;
+ if (index >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ UInt64 size = 0;
+ HRESULT result = GetItemFullSize(index, size, progress);
+ prop = size;
+ prop.Detach(value);
+ return result;
+}
+
+HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
+{
+ UString newName = name;
+ resultPath = _path + newName;
+ if (newName.Length() < 1)
+ return S_OK;
+ if (newName[0] == WCHAR_PATH_SEPARATOR)
+ {
+ resultPath = newName;
+ return S_OK;
+ }
+ if (newName.Length() < 2)
+ return S_OK;
+ if (newName[1] == L':')
+ resultPath = newName;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */)
+{
+ UString processedName;
+ RINOK(GetComplexName(name, processedName));
+ if(NDirectory::MyCreateDirectory(processedName))
+ return S_OK;
+ if(::GetLastError() == ERROR_ALREADY_EXISTS)
+ return ::GetLastError();
+ if (!NDirectory::CreateComplexDirectory(processedName))
+ return ::GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */)
+{
+ UString processedName;
+ RINOK(GetComplexName(name, processedName));
+ NIO::COutFile outFile;
+ if (!outFile.Create(processedName, false))
+ return ::GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */)
+{
+ const CDirItem &fileInfo = *_refs[index];
+ const UString fullPrefix = _path + GetPrefix(fileInfo);
+ if (!NDirectory::MyMoveFile(fullPrefix + fileInfo.Name, fullPrefix + newName))
+ return GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress)
+{
+#ifdef _WIN32
+ RINOK(progress->SetTotal(numItems));
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ const CDirItem &fileInfo = *_refs[indices[i]];
+ const UString fullPath = _path + GetRelPath(fileInfo);
+ bool result;
+ if (fileInfo.IsDir())
+ result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
+ else
+ result = NDirectory::DeleteFileAlways(fullPath);
+ if (!result)
+ return GetLastError();
+ UInt64 completed = i;
+ RINOK(progress->SetCompleted(&completed));
+ }
+#endif
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
+ const PROPVARIANT *value, IProgress * /* progress */)
+{
+ if (index >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ CDirItem &fileInfo = *_refs[index];
+ if (fileInfo.Parent->Parent != 0)
+ return E_NOTIMPL;
+ switch(propID)
+ {
+ case kpidComment:
+ {
+ UString filename = fileInfo.Name;
+ filename.Trim();
+ if (value->vt == VT_EMPTY)
+ _comments.DeletePair(filename);
+ else if (value->vt == VT_BSTR)
+ {
+ CTextPair pair;
+ pair.ID = filename;
+ pair.ID.Trim();
+ pair.Value = value->bstrVal;
+ pair.Value.Trim();
+ if (pair.Value.IsEmpty())
+ _comments.DeletePair(filename);
+ else
+ _comments.AddPair(pair);
+ }
+ else
+ return E_INVALIDARG;
+ SaveComments();
+ break;
+ }
+ default:
+ return E_NOTIMPL;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
+{
+#ifdef _WIN32
+ if (index >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ const CDirItem &fileInfo = *_refs[index];
+ *iconIndex = 0;
+ int iconIndexTemp;
+ if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attributes, iconIndexTemp) != 0)
+ {
+ *iconIndex = iconIndexTemp;
+ return S_OK;
+ }
+ return GetLastError();
+#endif
+ *iconIndex = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::SetFlatMode(Int32 flatMode)
+{
+ _flatMode = IntToBool(flatMode);
+ return S_OK;
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolder.h
new file mode 100644
index 000000000..4f65f9771
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolder.h
@@ -0,0 +1,120 @@
+// FSFolder.h
+
+#ifndef __FSFOLDER_H
+#define __FSFOLDER_H
+
+#include "Common/MyString.h"
+#include "Common/MyCom.h"
+#include "Windows/FileFind.h"
+#include "Windows/PropVariant.h"
+
+#include "IFolder.h"
+
+#include "TextPairs.h"
+
+namespace NFsFolder {
+
+class CFSFolder;
+
+struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
+{
+ bool CompressedSizeIsDefined;
+ UInt64 CompressedSize;
+};
+
+struct CDirItem;
+
+struct CDirItem: public CFileInfoEx
+{
+ CDirItem *Parent;
+ CObjectVector<CDirItem> Files;
+
+ CDirItem(): Parent(0) {}
+ void Clear()
+ {
+ Files.Clear();
+ Parent = 0;
+ }
+};
+
+class CFSFolder:
+ public IFolderFolder,
+ public IFolderWasChanged,
+ public IFolderOperations,
+ // public IFolderOperationsDeleteToRecycleBin,
+ public IFolderGetItemFullSize,
+ public IFolderClone,
+ public IFolderGetSystemIconIndex,
+ public IFolderSetFlatMode,
+ public CMyUnknownImp
+{
+ UInt64 GetSizeOfItem(int anIndex) const;
+public:
+ MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
+ // MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin)
+ MY_QUERYINTERFACE_ENTRY(IFolderOperations)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize)
+ MY_QUERYINTERFACE_ENTRY(IFolderClone)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex)
+ MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+
+ INTERFACE_FolderFolder(;)
+ INTERFACE_FolderOperations(;)
+
+ STDMETHOD(WasChanged)(INT32 *wasChanged);
+ STDMETHOD(Clone)(IFolderFolder **resultFolder);
+ STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
+
+ STDMETHOD(SetFlatMode)(Int32 flatMode);
+
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
+
+private:
+ UString _path;
+ CDirItem _root;
+ CRecordVector<CDirItem *> _refs;
+
+ CMyComPtr<IFolderFolder> _parentFolder;
+
+ bool _commentsAreLoaded;
+ CPairsStorage _comments;
+
+ bool _flatMode;
+
+ // FIXME NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
+
+ HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
+ UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
+ HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
+ HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
+ HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
+
+ bool LoadComments();
+ bool SaveComments();
+ HRESULT LoadSubItems(CDirItem &dirItem, const UString &path);
+ void AddRefs(CDirItem &dirItem);
+public:
+ HRESULT Init(const UString &path, IFolderFolder *parentFolder);
+
+ CFSFolder() : _flatMode(false) {}
+
+ UString GetPrefix(const CDirItem &item) const;
+ UString GetRelPath(const CDirItem &item) const;
+ UString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
+
+ void Clear()
+ {
+ _root.Clear();
+ _refs.Clear();
+ }
+};
+
+HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
new file mode 100644
index 000000000..db1ba2ba4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
@@ -0,0 +1,523 @@
+// FSFolderCopy.cpp
+
+#include "StdAfx.h"
+
+// FIXME #include <Winbase.h>
+
+#include "FSFolder.h"
+#include "Windows/FileDir.h"
+#include "Windows/Error.h"
+
+#include "Common/StringConvert.h"
+
+#include "../../Common/FilePathAutoRename.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NFsFolder {
+
+/*
+static bool IsItWindows2000orHigher()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
+ (versionInfo.dwMajorVersion >= 5);
+}
+*/
+
+struct CProgressInfo
+{
+ UInt64 StartPos;
+ IProgress *Progress;
+};
+
+#ifdef _WIN32
+
+static DWORD CALLBACK CopyProgressRoutine(
+ LARGE_INTEGER /* TotalFileSize */, // file size
+ LARGE_INTEGER TotalBytesTransferred, // bytes transferred
+ LARGE_INTEGER /* StreamSize */, // bytes in stream
+ LARGE_INTEGER /* StreamBytesTransferred */, // bytes transferred for stream
+ DWORD /* dwStreamNumber */, // current stream
+ DWORD /* dwCallbackReason */, // callback reason
+ HANDLE /* hSourceFile */, // handle to source file
+ HANDLE /* hDestinationFile */, // handle to destination file
+ LPVOID lpData // from CopyFileEx
+)
+{
+ CProgressInfo &progressInfo = *(CProgressInfo *)lpData;
+ UInt64 completed = progressInfo.StartPos + TotalBytesTransferred.QuadPart;
+ if (progressInfo.Progress->SetCompleted(&completed) != S_OK)
+ return PROGRESS_CANCEL;
+ return PROGRESS_CONTINUE;
+}
+
+typedef BOOL (WINAPI * CopyFileExPointer)(
+ IN LPCSTR lpExistingFileName,
+ IN LPCSTR lpNewFileName,
+ IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
+ IN LPVOID lpData OPTIONAL,
+ IN LPBOOL pbCancel OPTIONAL,
+ IN DWORD dwCopyFlags
+ );
+
+typedef BOOL (WINAPI * CopyFileExPointerW)(
+ IN LPCWSTR lpExistingFileName,
+ IN LPCWSTR lpNewFileName,
+ IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
+ IN LPVOID lpData OPTIONAL,
+ IN LPBOOL pbCancel OPTIONAL,
+ IN DWORD dwCopyFlags
+ );
+
+#ifndef _UNICODE
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static CSysString GetSysPath(LPCWSTR sysPath)
+ { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
+#endif
+
+#endif
+
+static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
+{
+#ifdef _WIN32
+ CProgressInfo progressInfo;
+ progressInfo.Progress = progress;
+ progressInfo.StartPos = completedSize;
+ BOOL CancelFlag = FALSE;
+ #ifndef _UNICODE
+ if (g_IsNT)
+ #endif
+ {
+ CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
+ ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"),
+ "CopyFileExW");
+ if (copyFunctionW == 0)
+ return false;
+ if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
+ &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ return true;
+ #ifdef WIN_LONG_PATH
+ UString longPathExisting, longPathNew;
+ if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew))
+ return false;
+ if (copyFunctionW(longPathExisting, longPathNew, CopyProgressRoutine,
+ &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ return true;
+ #endif
+ return false;
+ }
+ #ifndef _UNICODE
+ else
+ {
+ CopyFileExPointer copyFunction = (CopyFileExPointer)
+ ::GetProcAddress(::GetModuleHandleA("kernel32.dll"),
+ "CopyFileExA");
+ if (copyFunction != 0)
+ {
+ if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
+ CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ return true;
+ if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ return false;
+ }
+ return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
+ }
+ #endif
+#else
+ extern bool wxw_CopyFile(LPCWSTR existingFile, LPCWSTR newFile, bool overwrite);
+ return wxw_CopyFile(existingFile, newFile, true);
+#endif
+}
+
+#ifdef _WIN32
+typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
+ IN LPCWSTR lpExistingFileName,
+ IN LPCWSTR lpNewFileName,
+ IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
+ IN LPVOID lpData OPTIONAL,
+ IN DWORD dwFlags
+ );
+#endif
+
+static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
+{
+#ifdef _WIN32
+ // if (IsItWindows2000orHigher())
+ // {
+ CProgressInfo progressInfo;
+ progressInfo.Progress = progress;
+ progressInfo.StartPos = completedSize;
+
+ MoveFileWithProgressPointer moveFunction = (MoveFileWithProgressPointer)
+ ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
+ "MoveFileWithProgressW");
+ if (moveFunction != 0)
+ {
+ if (moveFunction(
+ existingFile, newFile, CopyProgressRoutine,
+ &progressInfo, MOVEFILE_COPY_ALLOWED))
+ return true;
+ if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ {
+ #ifdef WIN_LONG_PATH
+ UString longPathExisting, longPathNew;
+ if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew))
+ return false;
+ if (moveFunction(longPathExisting, longPathNew, CopyProgressRoutine,
+ &progressInfo, MOVEFILE_COPY_ALLOWED))
+ return true;
+ #endif
+ if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ return false;
+ }
+ }
+ // }
+ // else
+#endif
+ return NDirectory::MyMoveFile(existingFile, newFile);
+}
+
+static HRESULT MyCopyFile(
+ const UString &srcPath,
+ const CFileInfoW &srcFileInfo,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UInt64 &completedSize)
+{
+ UString destPath = destPathSpec;
+ if (destPath.CompareNoCase(srcPath) == 0)
+ {
+ UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+
+ INT32 writeAskResult;
+ CMyComBSTR destPathResult;
+ RINOK(callback->AskWrite(
+ srcPath,
+ BoolToInt(false),
+ &srcFileInfo.MTime, &srcFileInfo.Size,
+ destPath,
+ &destPathResult,
+ &writeAskResult));
+ if (IntToBool(writeAskResult))
+ {
+ UString destPathNew = UString(destPathResult);
+ RINOK(callback->SetCurrentFilePath(srcPath));
+ if (!MyCopyFile(srcPath, destPathNew, callback, completedSize))
+ {
+ UString message = NError::MyFormatMessageW(GetLastError()) +
+ UString(L" \'") +
+ UString(destPathNew) +
+ UString(L"\'");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ }
+ completedSize += srcFileInfo.Size;
+ return callback->SetCompleted(&completedSize);
+}
+
+static HRESULT CopyFolder(
+ const UString &srcPath,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UInt64 &completedSize)
+{
+ RINOK(callback->SetCompleted(&completedSize));
+
+ UString destPath = destPathSpec;
+ int len = srcPath.Length();
+ if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
+ {
+ if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
+ {
+ UString message = UString(L"can not copy folder \'") +
+ destPath + UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ }
+
+ if (!NDirectory::CreateComplexDirectory(destPath))
+ {
+ UString message = UString(L"can not create folder ") + destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ CEnumeratorW enumerator(srcPath + UString(WSTRING_PATH_SEPARATOR L"*"));
+ CFileInfoEx fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ const UString srcPath2 = srcPath + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name;
+ const UString destPath2 = destPath + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name;
+ if (fileInfo.IsDir())
+ {
+ RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ return S_OK;
+}
+
+
+STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback)
+{
+ if (numItems == 0)
+ return S_OK;
+
+ UInt64 numFolders, numFiles, totalSize;
+ GetItemsFullSize(indices, numItems, numFolders, numFiles, totalSize, callback);
+ RINOK(callback->SetTotal(totalSize));
+ RINOK(callback->SetNumFiles(numFiles));
+
+ UString destPath = path;
+ if (destPath.IsEmpty())
+ return E_INVALIDARG;
+ bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ if (directName)
+ {
+ if (numItems > 1)
+ return E_INVALIDARG;
+ }
+ /*
+ // doesn't work in network
+ else
+ if (!NDirectory::CreateComplexDirectory(destPath)))
+ {
+ DWORD lastError = ::GetLastError();
+ UString message = UString(L"can not create folder ") +
+ destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ */
+
+ UInt64 completedSize = 0;
+ RINOK(callback->SetCompleted(&completedSize));
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ const CDirItem &fileInfo = *_refs[indices[i]];
+ UString destPath2 = destPath;
+ if (!directName)
+ destPath2 += fileInfo.Name;
+ UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
+ if (fileInfo.IsDir())
+ {
+ RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ return S_OK;
+}
+
+/////////////////////////////////////////////////
+// Move Operations
+
+HRESULT MyMoveFile(
+ const UString &srcPath,
+ const CFileInfoW &srcFileInfo,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UInt64 &completedSize)
+{
+ UString destPath = destPathSpec;
+ if (destPath.CompareNoCase(srcPath) == 0)
+ {
+ UString message = UString(L"can not move file \'")
+ + destPath +
+ UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+
+ INT32 writeAskResult;
+ CMyComBSTR destPathResult;
+ RINOK(callback->AskWrite(
+ srcPath,
+ BoolToInt(false),
+ &srcFileInfo.MTime, &srcFileInfo.Size,
+ destPath,
+ &destPathResult,
+ &writeAskResult));
+ if (IntToBool(writeAskResult))
+ {
+ UString destPathNew = UString(destPathResult);
+ RINOK(callback->SetCurrentFilePath(srcPath));
+ if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
+ {
+ UString message = UString(L"can not move to file ") + destPathNew;
+ RINOK(callback->ShowMessage(message));
+ }
+ }
+ completedSize += srcFileInfo.Size;
+ RINOK(callback->SetCompleted(&completedSize));
+ return S_OK;
+}
+
+HRESULT MyMoveFolder(
+ const UString &srcPath,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UInt64 &completedSize)
+{
+ UString destPath = destPathSpec;
+ int len = srcPath.Length();
+ if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
+ {
+ if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
+ {
+ UString message = UString(L"can not move folder \'") +
+ destPath + UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ }
+
+ if (MyMoveFile(srcPath, destPath, callback, completedSize))
+ return S_OK;
+
+ if (!NDirectory::CreateComplexDirectory(destPath))
+ {
+ UString message = UString(L"can not create folder ") + destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ {
+ CEnumeratorW enumerator(srcPath + UString(WSTRING_PATH_SEPARATOR L"*"));
+ CFileInfoEx fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ const UString srcPath2 = srcPath + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name;
+ const UString destPath2 = destPath + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name;
+ if (fileInfo.IsDir())
+ {
+ RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ }
+ if (!NDirectory::MyRemoveDirectory(srcPath))
+ {
+ UString message = UString(L"can not remove folder") + srcPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::MoveTo(
+ const UInt32 *indices,
+ UInt32 numItems,
+ const wchar_t *path,
+ IFolderOperationsExtractCallback *callback)
+{
+ if (numItems == 0)
+ return S_OK;
+
+ UInt64 numFolders, numFiles, totalSize;
+ GetItemsFullSize(indices, numItems, numFolders, numFiles, totalSize, callback);
+ RINOK(callback->SetTotal(totalSize));
+ RINOK(callback->SetNumFiles(numFiles));
+
+ UString destPath = path;
+ if (destPath.IsEmpty())
+ return E_INVALIDARG;
+ bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ if (directName)
+ {
+ if (numItems > 1)
+ return E_INVALIDARG;
+ }
+ else
+ if (!NDirectory::CreateComplexDirectory(destPath))
+ {
+ UString message = UString(L"can not create folder ") +
+ destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+
+ UInt64 completedSize = 0;
+ RINOK(callback->SetCompleted(&completedSize));
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ const CDirItem &fileInfo = *_refs[indices[i]];
+ UString destPath2 = destPath;
+ if (!directName)
+ destPath2 += fileInfo.Name;
+ UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
+ if (fileInfo.IsDir())
+ {
+ RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
+ const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */)
+{
+ /*
+ UInt64 numFolders, numFiles, totalSize;
+ numFiles = numFolders = totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ UString path = (UString)fromFolderPath + itemsPaths[i];
+
+ CFileInfoW fileInfo;
+ if (!FindFile(path, fileInfo))
+ return ::GetLastError();
+ if (fileInfo.IsDir())
+ {
+ UInt64 subFolders, subFiles, subSize;
+ RINOK(GetFolderSize(path + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name, subFolders, subFiles, subSize, progress));
+ numFolders += subFolders;
+ numFolders++;
+ numFiles += subFiles;
+ totalSize += subSize;
+ }
+ else
+ {
+ numFiles++;
+ totalSize += fileInfo.Size;
+ }
+ }
+ RINOK(progress->SetTotal(totalSize));
+ RINOK(callback->SetNumFiles(numFiles));
+ for (i = 0; i < numItems; i++)
+ {
+ UString path = (UString)fromFolderPath + itemsPaths[i];
+ }
+ return S_OK;
+ */
+ return E_NOTIMPL;
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
new file mode 100644
index 000000000..cfc15d383
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
@@ -0,0 +1,165 @@
+// FileFolderPluginOpen.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Windows/Thread.h"
+
+#include "../Agent/Agent.h"
+
+#include "LangUtils.h"
+#include "OpenCallback.h"
+#include "PluginLoader.h"
+#include "RegistryAssociations.h"
+#include "RegistryPlugins.h"
+
+using namespace NWindows;
+using namespace NRegistryAssociations;
+
+struct CThreadArchiveOpen
+{
+ UString Path;
+ CMyComPtr<IInStream> InStream;
+ CMyComPtr<IFolderManager> FolderManager;
+ CMyComPtr<IProgress> OpenCallback;
+ COpenArchiveCallback *OpenCallbackSpec;
+
+ CMyComPtr<IFolderFolder> Folder;
+ HRESULT Result;
+
+ void Process()
+ {
+ OpenCallbackSpec->ProgressDialog.WaitCreating();
+ Result = FolderManager->OpenFolderFile(InStream, Path, &Folder, OpenCallback);
+ OpenCallbackSpec->ProgressDialog.MyClose();
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadArchiveOpen *)param)->Process();
+ return 0;
+ }
+};
+
+static int FindPlugin(const CObjectVector<CPluginInfo> &plugins,
+ const UString &pluginName)
+{
+ for (int i = 0; i < plugins.Size(); i++)
+ if (plugins[i].Name.CompareNoCase(pluginName) == 0)
+ return i;
+ return -1;
+}
+
+HRESULT OpenFileFolderPlugin(
+ IInStream *inStream,
+ const UString &path,
+ HMODULE *module,
+ IFolderFolder **resultFolder,
+ HWND parentWindow,
+ bool &encrypted, UString &password)
+{
+#ifdef _WIN32
+ CObjectVector<CPluginInfo> plugins;
+ ReadFileFolderPluginInfoList(plugins);
+#endif
+
+ UString extension, name, pureName, dot;
+
+ int slashPos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ UString dirPrefix;
+ UString fileName;
+ if (slashPos >= 0)
+ {
+ dirPrefix = path.Left(slashPos + 1);
+ fileName = path.Mid(slashPos + 1);
+ }
+ else
+ fileName = path;
+
+ NFile::NName::SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
+
+#ifdef _WIN32
+ if (!extension.IsEmpty())
+ {
+ CExtInfo extInfo;
+ if (ReadInternalAssociation(extension, extInfo))
+ {
+ for (int i = extInfo.Plugins.Size() - 1; i >= 0; i--)
+ {
+ int pluginIndex = FindPlugin(plugins, extInfo.Plugins[i]);
+ if (pluginIndex >= 0)
+ {
+ const CPluginInfo plugin = plugins[pluginIndex];
+ plugins.Delete(pluginIndex);
+ plugins.Insert(0, plugin);
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < plugins.Size(); i++)
+ {
+ const CPluginInfo &plugin = plugins[i];
+ if (!plugin.ClassIDDefined)
+ continue;
+#endif // #ifdef _WIN32
+ CPluginLibrary library;
+
+ CThreadArchiveOpen t;
+
+#ifdef _WIN32
+ if (plugin.FilePath.IsEmpty())
+ t.FolderManager = new CArchiveFolderManager;
+ else if (library.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &t.FolderManager) != S_OK)
+ continue;
+#else
+ t.FolderManager = new CArchiveFolderManager;
+#endif
+
+ t.OpenCallbackSpec = new COpenArchiveCallback;
+ t.OpenCallback = t.OpenCallbackSpec;
+ t.OpenCallbackSpec->PasswordIsDefined = encrypted;
+ t.OpenCallbackSpec->Password = password;
+ t.OpenCallbackSpec->ParentWindow = parentWindow;
+
+ if (inStream)
+ t.OpenCallbackSpec->SetSubArchiveName(fileName);
+ else
+ t.OpenCallbackSpec->LoadFileInfo(dirPrefix, fileName);
+
+ t.InStream = inStream;
+ t.Path = path;
+
+ UString progressTitle = LangString(IDS_OPENNING, 0x03020283);
+ t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow;
+ t.OpenCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
+
+ NWindows::CThread thread;
+ if (thread.Create(CThreadArchiveOpen::MyThreadFunction, &t) != S_OK)
+ throw 271824;
+ t.OpenCallbackSpec->StartProgressDialog(progressTitle);
+
+ if (t.Result == E_ABORT)
+ return t.Result;
+
+ if (t.Result == S_OK)
+ {
+ // if (openCallbackSpec->PasswordWasAsked)
+ {
+ encrypted = t.OpenCallbackSpec->PasswordIsDefined;
+ password = t.OpenCallbackSpec->Password;
+ }
+ *module = library.Detach();
+ *resultFolder = t.Folder.Detach();
+ return S_OK;
+ }
+
+ if (t.Result != S_FALSE)
+ return t.Result;
+#ifdef _WIN32
+ }
+#endif
+ return S_FALSE;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
new file mode 100644
index 000000000..692417ba1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
@@ -0,0 +1,9 @@
+// FileFolderPluginOpen.h
+
+#ifndef __FILE_FOLDER_PLUGIN_OPEN_H
+#define __FILE_FOLDER_PLUGIN_OPEN_H
+
+HRESULT OpenFileFolderPlugin(IInStream *inStream, const UString &path,
+ HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FormatUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FormatUtils.cpp
new file mode 100644
index 000000000..98bb043ef
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FormatUtils.cpp
@@ -0,0 +1,40 @@
+// FormatUtils.cpp
+
+#include "StdAfx.h"
+
+#include "FormatUtils.h"
+#include "Common/IntToString.h"
+#include "Windows/ResourceString.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+UString NumberToString(UInt64 number)
+{
+ wchar_t numberString[32];
+ ConvertUInt64ToString(number, numberString);
+ return numberString;
+}
+
+UString MyFormatNew(const UString &format, const UString &argument)
+{
+ UString result = format;
+ result.Replace(L"{0}", argument);
+ return result;
+}
+
+UString MyFormatNew(UINT resourceID,
+ #ifdef LANG
+ UInt32 langID,
+ #endif
+ const UString &argument)
+{
+ return MyFormatNew(
+ #ifdef LANG
+ LangString(resourceID, langID),
+ #else
+ NWindows::MyLoadStringW(resourceID),
+ #endif
+ argument);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FormatUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FormatUtils.h
new file mode 100644
index 000000000..70a444347
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FormatUtils.h
@@ -0,0 +1,18 @@
+// FormatUtils.h
+
+#ifndef __FORMATUTILS_H
+#define __FORMATUTILS_H
+
+#include "Common/Types.h"
+#include "Common/MyString.h"
+
+UString NumberToString(UInt64 number);
+
+UString MyFormatNew(const UString &format, const UString &argument);
+UString MyFormatNew(UINT resourceID,
+ #ifdef LANG
+ UInt32 langID,
+ #endif
+ const UString &argument);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/HelpUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/HelpUtils.h
new file mode 100644
index 000000000..2a7b85aff
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/HelpUtils.h
@@ -0,0 +1,10 @@
+// HelpUtils.h
+
+#ifndef __HELPUTILS_H
+#define __HELPUTILS_H
+
+#include "Common/MyString.h"
+
+void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/IFolder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/IFolder.h
new file mode 100644
index 000000000..b301f5134
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/IFolder.h
@@ -0,0 +1,157 @@
+// IFolder.h
+
+#ifndef __IFOLDER_H
+#define __IFOLDER_H
+
+#include "../../IProgress.h"
+#include "../../IStream.h"
+
+#define FOLDER_INTERFACE_SUB(i, b, x) DECL_INTERFACE_SUB(i, b, 8, x)
+#define FOLDER_INTERFACE(i, x) FOLDER_INTERFACE_SUB(i, IUnknown, x)
+
+namespace NPlugin
+{
+ enum
+ {
+ kName = 0,
+ kType,
+ kClassID,
+ kOptionsClassID
+ };
+}
+
+#define INTERFACE_FolderFolder(x) \
+ STDMETHOD(LoadItems)() x; \
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems) x; \
+ STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder) x; \
+ STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder) x; \
+ STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder) x; \
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
+ STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
+ STDMETHOD(GetFolderProperty)(PROPID propID, PROPVARIANT *value) x; \
+
+FOLDER_INTERFACE(IFolderFolder, 0x00)
+{
+ INTERFACE_FolderFolder(PURE)
+};
+
+FOLDER_INTERFACE(IFolderWasChanged, 0x04)
+{
+ STDMETHOD(WasChanged)(Int32 *wasChanged) PURE;
+};
+
+FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B)
+{
+ // STDMETHOD(SetTotalFiles)(UInt64 total) PURE;
+ // STDMETHOD(SetCompletedFiles)(const UInt64 *completedValue) PURE;
+ STDMETHOD(AskWrite)(
+ const wchar_t *srcPath,
+ Int32 srcIsFolder,
+ const FILETIME *srcTime,
+ const UInt64 *srcSize,
+ const wchar_t *destPathRequest,
+ BSTR *destPathResult,
+ Int32 *writeAnswer) PURE;
+ STDMETHOD(ShowMessage)(const wchar_t *message) PURE;
+ STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE;
+ STDMETHOD(SetNumFiles)(UInt64 numFiles) PURE;
+};
+
+#define INTERFACE_FolderOperations(x) \
+ STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress) x; \
+ STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress) x; \
+ STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress) x; \
+ STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress) x; \
+ STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems, \
+ const wchar_t *path, IFolderOperationsExtractCallback *callback) x; \
+ STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems, \
+ const wchar_t *path, IFolderOperationsExtractCallback *callback) x; \
+ STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath, \
+ const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress) x; \
+ STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) x; \
+
+FOLDER_INTERFACE(IFolderOperations, 0x06)
+{
+ INTERFACE_FolderOperations(PURE)
+};
+
+/*
+FOLDER_INTERFACE2(IFolderOperationsDeleteToRecycleBin, 0x06, 0x03)
+{
+ STDMETHOD(DeleteToRecycleBin)(const UInt32 *indices, UInt32 numItems, IProgress *progress) PURE;
+};
+*/
+
+FOLDER_INTERFACE(IFolderGetSystemIconIndex, 0x07)
+{
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex) PURE;
+};
+
+FOLDER_INTERFACE(IFolderGetItemFullSize, 0x08)
+{
+ STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress) PURE;
+};
+
+FOLDER_INTERFACE(IFolderClone, 0x09)
+{
+ STDMETHOD(Clone)(IFolderFolder **resultFolder) PURE;
+};
+
+FOLDER_INTERFACE(IFolderSetFlatMode, 0x0A)
+{
+ STDMETHOD(SetFlatMode)(Int32 flatMode) PURE;
+};
+
+#define INTERFACE_FolderProperties(x) \
+ STDMETHOD(GetNumberOfFolderProperties)(UInt32 *numProperties) x; \
+ STDMETHOD(GetFolderPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
+
+FOLDER_INTERFACE(IFolderProperties, 0x0E)
+{
+ INTERFACE_FolderProperties(PURE)
+};
+
+#define INTERFACE_IFolderArchiveProperties(x) \
+ STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) x; \
+ STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x;
+
+FOLDER_INTERFACE(IFolderArchiveProperties, 0x0C)
+{
+ INTERFACE_IFolderArchiveProperties(PURE)
+};
+
+FOLDER_INTERFACE(IGetFolderArchiveProperties, 0x0D)
+{
+ STDMETHOD(GetFolderArchiveProperties)(IFolderArchiveProperties **object) PURE;
+};
+
+#define FOLDER_MANAGER_INTERFACE(i, x) DECL_INTERFACE(i, 9, x)
+
+#define INTERFACE_IFolderManager(x) \
+ STDMETHOD(OpenFolderFile)(IInStream *inStream, const wchar_t *filePath, IFolderFolder **resultFolder, IProgress *progress) x; \
+ STDMETHOD(GetExtensions)(BSTR *extensions) x; \
+ STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex) x; \
+
+ // STDMETHOD(GetTypes)(BSTR *types) PURE;
+ // STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress) PURE;
+
+FOLDER_MANAGER_INTERFACE(IFolderManager, 0x04)
+{
+ INTERFACE_IFolderManager(PURE);
+};
+
+
+#define IMP_IFolderFolder_GetProp(k) \
+ (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
+ { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \
+ const STATPROPSTG &srcItem = k[index]; \
+ *propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \
+
+#define IMP_IFolderFolder_Props(c) \
+ STDMETHODIMP c::GetNumberOfProperties(UInt32 *numProperties) \
+ { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \
+ STDMETHODIMP c::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps)
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/LangUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/LangUtils.cpp
new file mode 100644
index 000000000..52f853489
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/LangUtils.cpp
@@ -0,0 +1,208 @@
+// LangUtils.cpp
+
+#include "StdAfx.h"
+
+#include "LangUtils.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+#include "Windows/Synchronization.h"
+#include "Windows/Window.h"
+#include "Windows/FileFind.h"
+#include "RegistryUtils.h"
+#include "ProgramLocation.h"
+
+using namespace NWindows;
+
+static CLang g_Lang;
+UString g_LangID;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+void ReloadLang()
+{
+ ReadRegLang(g_LangID);
+ g_Lang.Clear();
+ if (!g_LangID.IsEmpty() && g_LangID != L"-")
+ {
+ UString langPath = g_LangID;
+ if (langPath.Find(WCHAR_PATH_SEPARATOR) < 0)
+ {
+ if (langPath.Find(L'.') < 0)
+ langPath += L".txt";
+ UString folderPath;
+ if (GetProgramFolderPath(folderPath))
+ langPath = folderPath + UString(L"Lang" WSTRING_PATH_SEPARATOR) + langPath;
+ }
+ g_Lang.Open(langPath);
+ }
+}
+
+static bool g_Loaded = false;
+static NSynchronization::CCriticalSection g_CriticalSection;
+
+void LoadLangOneTime()
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ if (g_Loaded)
+ return;
+ g_Loaded = true;
+ ReloadLang();
+}
+
+void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems)
+{
+ for (int i = 0; i < numItems; i++)
+ {
+ const CIDLangPair &idLangPair = idLangPairs[i];
+ UString message;
+ if (g_Lang.GetMessage(idLangPair.LangID, message))
+ {
+ NWindows::CWindow window(GetDlgItem(dialogWindow, idLangPair.ControlID));
+ window.SetText(message);
+ }
+ }
+}
+
+void LangSetWindowText(HWND window, UInt32 langID)
+{
+ UString message;
+ if (g_Lang.GetMessage(langID, message))
+ MySetWindowText(window, message);
+}
+
+UString LangString(UInt32 langID)
+{
+ UString message;
+ if (g_Lang.GetMessage(langID, message))
+ return message;
+ return UString();
+}
+
+UString LangString(UINT resourceID, UInt32 langID)
+{
+ UString message;
+ if (g_Lang.GetMessage(langID, message))
+ return message;
+ return NWindows::MyLoadStringW(resourceID);
+}
+
+void LoadLangs(CObjectVector<CLangEx> &langs)
+{
+ langs.Clear();
+ UString folderPath;
+ if (!::GetProgramFolderPath(folderPath))
+ return;
+ folderPath += L"Lang" WSTRING_PATH_SEPARATOR;
+ NWindows::NFile::NFind::CEnumeratorW enumerator(folderPath + L"*.txt");
+ NWindows::NFile::NFind::CFileInfoW fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ if (fileInfo.IsDir())
+ continue;
+ CLangEx lang;
+ UString filePath = folderPath + fileInfo.Name;
+ const int kExtSize = 4;
+ const UString ext = fileInfo.Name.Right(kExtSize);
+ if (ext.CompareNoCase(L".txt") != 0)
+ continue;
+ lang.ShortName = fileInfo.Name.Left(fileInfo.Name.Length() - kExtSize);
+ if (lang.Lang.Open(filePath))
+ langs.Add(lang);
+ }
+}
+
+bool SplidID(const UString &id, WORD &primID, WORD &subID)
+{
+ primID = 0;
+ subID = 0;
+ const wchar_t *start = id;
+ const wchar_t *end;
+ UInt64 value = ConvertStringToUInt64(start, &end);
+ if (start == end)
+ return false;
+ primID = (WORD)value;
+ if (*end == 0)
+ return true;
+ if (*end != L'-')
+ return false;
+ start = end + 1;
+ value = ConvertStringToUInt64(start, &end);
+ if (start == end)
+ return false;
+ subID = (WORD)value;
+ return (*end == 0);
+}
+
+typedef LANGID (WINAPI *GetUserDefaultUILanguageP)();
+
+void FindMatchLang(UString &shortName)
+{
+ shortName.Empty();
+
+ LANGID SystemDefaultLangID = GetSystemDefaultLangID(); // Lang for non-Unicode in XP64
+ LANGID UserDefaultLangID = GetUserDefaultLangID(); // Standarts and formats in XP64
+
+ if (SystemDefaultLangID != UserDefaultLangID)
+ return;
+ LANGID langID = UserDefaultLangID;
+ /*
+ LANGID SystemDefaultUILanguage; // english in XP64
+ LANGID UserDefaultUILanguage; // english in XP64
+
+ GetUserDefaultUILanguageP fn = (GetUserDefaultUILanguageP)GetProcAddress(
+ GetModuleHandle("kernel32"), "GetUserDefaultUILanguage");
+ if (fn != NULL)
+ UserDefaultUILanguage = fn();
+ fn = (GetUserDefaultUILanguageP)GetProcAddress(
+ GetModuleHandle("kernel32"), "GetSystemDefaultUILanguage");
+ if (fn != NULL)
+ SystemDefaultUILanguage = fn();
+ */
+
+ WORD primLang = (WORD)(PRIMARYLANGID(langID));
+ WORD subLang = (WORD)(SUBLANGID(langID));
+ CObjectVector<CLangEx> langs;
+ LoadLangs(langs);
+ for (int i = 0; i < langs.Size(); i++)
+ {
+ const CLangEx &lang = langs[i];
+ UString id;
+ if (lang.Lang.GetMessage(0x00000002, id))
+ {
+ WORD primID;
+ WORD subID;
+ if (SplidID(id, primID, subID))
+ if (primID == primLang)
+ {
+ if (subID == 0)
+ shortName = lang.ShortName;
+ if (subLang == subID)
+ {
+ shortName = lang.ShortName;
+ return;
+ }
+ }
+ }
+ }
+}
+
+void ReloadLangSmart()
+{
+ #ifndef _UNICODE
+ if (g_IsNT)
+ #endif
+ {
+ ReadRegLang(g_LangID);
+ if (g_LangID.IsEmpty())
+ {
+ UString shortName;
+ FindMatchLang(shortName);
+ if (shortName.IsEmpty())
+ shortName = L"-";
+ SaveRegLang(shortName);
+ }
+ }
+ ReloadLang();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/LangUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/LangUtils.h
new file mode 100644
index 000000000..40debdfe4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/LangUtils.h
@@ -0,0 +1,41 @@
+// LangUtils.h
+
+#ifndef __LANGUTILS_H
+#define __LANGUTILS_H
+
+#include "Common/Lang.h"
+#include "Windows/ResourceString.h"
+
+extern UString g_LangID;
+
+struct CIDLangPair
+{
+ int ControlID;
+ UInt32 LangID;
+};
+
+void ReloadLang();
+void LoadLangOneTime();
+void ReloadLangSmart();
+
+struct CLangEx
+{
+ CLang Lang;
+ UString ShortName;
+};
+
+void LoadLangs(CObjectVector<CLangEx> &langs);
+
+void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems);
+void LangSetWindowText(HWND window, UInt32 langID);
+
+UString LangString(UInt32 langID);
+UString LangString(UINT resourceID, UInt32 langID);
+
+#ifdef LANG
+#define LangStringSpec(resourceID, langID) LangString(resourceID, langID)
+#else
+#define LangStringSpec(resourceID, langID) NWindows::MyLoadStringW(resourceID)
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog.cpp
new file mode 100644
index 000000000..667e6acc0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog.cpp
@@ -0,0 +1,96 @@
+// ListViewDialog.cpp
+
+#include "StdAfx.h"
+#include "ListViewDialog.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+bool CListViewDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _listView.Attach(GetItem(IDC_LISTVIEW_LIST));
+ SetText(Title);
+
+ LVCOLUMN columnInfo;
+ columnInfo.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
+ columnInfo.fmt = LVCFMT_LEFT;
+ columnInfo.iSubItem = 0;
+ columnInfo.cx = 1000;
+
+ _listView.InsertColumn(0, &columnInfo);
+
+ for (int i = 0; i < Strings.Size(); i++)
+ _listView.InsertItem(i, Strings[i]);
+
+ if (Strings.Size() > 0)
+ _listView.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
+ StringsWereChanged = false;
+ return CModalDialog::OnInit();
+}
+
+#ifdef _WIN32 // FIXME
+bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
+{
+ if (header->hwndFrom != _listView)
+ return false;
+ switch(header->code)
+ {
+ case LVN_KEYDOWN:
+ {
+ LPNMLVKEYDOWN keyDownInfo = LPNMLVKEYDOWN(header);
+ switch(keyDownInfo->wVKey)
+ {
+ case VK_DELETE:
+ {
+ if (!DeleteIsAllowed)
+ return false;
+ int focusedIndex = _listView.GetFocusedItem();
+ if (focusedIndex < 0)
+ focusedIndex = 0;
+ for (;;)
+ {
+ int index = _listView.GetNextSelectedItem(-1);
+ if (index < 0)
+ break;
+ StringsWereChanged = true;
+ _listView.DeleteItem(index);
+ Strings.Delete(index);
+ }
+ if (focusedIndex >= _listView.GetItemCount())
+ focusedIndex = _listView.GetItemCount() - 1;
+ if (focusedIndex >= 0)
+ _listView.SetItemState(focusedIndex, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
+ return true;
+ }
+ case 'A':
+ {
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ if (ctrl)
+ {
+ int numItems = _listView.GetItemCount();
+ for (int i = 0; i < numItems; i++)
+ _listView.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+#endif
+
+void CListViewDialog::OnOK()
+{
+ FocusedItemIndex = _listView.GetFocusedItem();
+ CModalDialog::OnOK();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog.h
new file mode 100644
index 000000000..f27b81697
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog.h
@@ -0,0 +1,32 @@
+// ListViewDialog.h
+
+#ifndef __LISTVIEWDIALOG_H
+#define __LISTVIEWDIALOG_H
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ListView.h"
+#include "ListViewDialogRes.h"
+
+class CListViewDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CListView _listView;
+ virtual void OnOK();
+ virtual bool OnInit();
+#ifdef _WIN32 // FIXME
+ virtual bool OnNotify(UINT controlID, LPNMHDR header);
+#endif
+
+public:
+ UString Title;
+ bool DeleteIsAllowed;
+ UStringVector Strings;
+ bool StringsWereChanged;
+ int FocusedItemIndex;
+
+ INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_LISTVIEW, wndParent); }
+
+ CListViewDialog(): DeleteIsAllowed(false) {}
+
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialogRes.h
new file mode 100644
index 000000000..440d14b02
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialogRes.h
@@ -0,0 +1,3 @@
+#define IDD_DIALOG_LISTVIEW 201
+
+#define IDC_LISTVIEW_LIST 1000
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog_rc.cpp
new file mode 100644
index 000000000..3b707ec31
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ListViewDialog_rc.cpp
@@ -0,0 +1,55 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "ListViewDialogRes.h"
+
+class CListViewDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CListViewDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) :
+ CModalDialogImpl(dialog,parent, id, wxT("ListView"), wxDefaultPosition, wxDefaultSize,
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)
+
+ {
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ wxListCtrl *list = new wxListCtrl(this, IDC_LISTVIEW_LIST, wxDefaultPosition, wxSize(645,195), wxLC_REPORT | wxLC_NO_HEADER);
+
+ topsizer->Add(list, 1, wxALL|wxEXPAND, 5);
+
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+REGISTER_DIALOG(IDD_DIALOG_LISTVIEW,CListViewDialog,0)
+
+BEGIN_EVENT_TABLE(CListViewDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog.cpp
new file mode 100644
index 000000000..201c0bae7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog.cpp
@@ -0,0 +1,76 @@
+// MessagesDialog.cpp
+
+#include "StdAfx.h"
+#include "MessagesDialog.h"
+#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
+#include "Windows/ResourceString.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000713 }
+};
+#endif
+
+void CMessagesDialog::AddMessageDirect(LPCWSTR message)
+{
+ int itemIndex = _messageList.GetItemCount();
+ wchar_t sz[32];
+ ConvertInt64ToString(itemIndex, sz);
+ _messageList.InsertItem(itemIndex, sz);
+ _messageList.SetSubItem(itemIndex, 1, message);
+}
+
+void CMessagesDialog::AddMessage(LPCWSTR message)
+{
+ UString s = message;
+ while (!s.IsEmpty())
+ {
+ int pos = s.Find(L'\n');
+ if (pos < 0)
+ break;
+ AddMessageDirect(s.Left(pos));
+ s.Delete(0, pos + 1);
+ }
+ AddMessageDirect(s);
+}
+
+bool CMessagesDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000A00);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _messageList.Attach(GetItem(IDC_MESSAGE_LIST));
+ _messageList.SetUnicodeFormat(true);
+
+ _messageList.InsertColumn(0, L"#", 30);
+
+ const UString s =
+ #ifdef LANG
+ LangString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80);
+ #else
+ MyLoadStringW(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN);
+ #endif
+
+ _messageList.InsertColumn(1, s, 600);
+
+ for(int i = 0; i < Messages->Size(); i++)
+ AddMessage((*Messages)[i]);
+
+ /*
+ if(_messageList.GetItemCount() > 0)
+ {
+ UINT aState = LVIS_SELECTED | LVIS_FOCUSED;
+ _messageList.SetItemState(0, aState, aState);
+ }
+ */
+ return CModalDialog::OnInit();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog.h
new file mode 100644
index 000000000..6df0d46cc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog.h
@@ -0,0 +1,22 @@
+// MessagesDialog.h
+
+#ifndef __MESSAGESDIALOG_H
+#define __MESSAGESDIALOG_H
+
+#include "MessagesDialogRes.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ListView.h"
+
+class CMessagesDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CListView _messageList;
+ void AddMessageDirect(LPCWSTR message);
+ void AddMessage(LPCWSTR message);
+ virtual bool OnInit();
+public:
+ const UStringVector *Messages;
+ INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_MESSAGES, parent); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialogRes.h
new file mode 100644
index 000000000..39d49f573
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialogRes.h
@@ -0,0 +1,3 @@
+#define IDS_MESSAGES_DIALOG_MESSAGE_COLUMN 503
+#define IDD_DIALOG_MESSAGES 503
+#define IDC_MESSAGE_LIST 1000
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog_rc.cpp
new file mode 100644
index 000000000..bd1fb1f06
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MessagesDialog_rc.cpp
@@ -0,0 +1,81 @@
+// MessagesDialog_rc.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "Windows/Control/DialogImpl.h"
+#include "MessagesDialogRes.h"
+
+/*
+IDD_DIALOG_MESSAGES DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
+CAPTION "7-Zip: Diagnostic messages"
+MY_FONT
+BEGIN
+ DEFPUSHBUTTON "&Close", IDOK, bXPos, bYPos, bXSize, bYSize
+ CONTROL "List1",IDC_MESSAGE_LIST,"SysListView32",
+ LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
+ marg, marg, xSize2, ySize2 - bYSize - 6
+END
+
+STRINGTABLE
+BEGIN
+ IDS_MESSAGES_DIALOG_MESSAGE_COLUMN "Message"
+END
+*/
+
+class CMessagesDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CMessagesDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) :
+ CModalDialogImpl(dialog,parent, id, wxT("7-Zip: Diagnostic messages"), wxDefaultPosition, wxDefaultSize,
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)
+ {
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ wxListCtrl *list = new wxListCtrl(this, IDC_MESSAGE_LIST, wxDefaultPosition, wxSize(645,195), wxLC_REPORT );
+
+#if 0
+ list->InsertColumn(0, wxT("Col1"), wxLIST_FORMAT_LEFT);
+ list->InsertColumn(1, wxT("Col2"), wxLIST_FORMAT_RIGHT);
+ list->InsertItem(0, wxT("#1"));
+ list->SetItem(0, 1, L"message 1");
+ list->InsertItem(1, wxT("#2"));
+ list->SetItem(1, 1, L"message 2");
+#endif
+ topsizer->Add(list , 1, wxALL|wxEXPAND, 5);
+ topsizer->Add(new wxButton(this, wxID_OK, _T("&Close")) , 0, wxALL | wxALIGN_RIGHT, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, L"Message" },
+ { 0 , 0 }
+};
+
+REGISTER_DIALOG(IDD_DIALOG_MESSAGES,CMessagesDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(CMessagesDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
new file mode 100644
index 000000000..839e1f8c7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
@@ -0,0 +1,733 @@
+// MyLoadMenu
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+typedef wxMenuBar * HMENU;
+
+#include "Common/StringConvert.h"
+
+// FIXME #include "Windows/Menu.h"
+#include "Windows/Error.h"
+// FIXME #include "Windows/Clipboard.h"
+
+#include "../../PropID.h"
+
+#include "resource.h"
+#include "App.h"
+// FIXME #include "AboutDialog.h"
+#include "../Common/CompressCall.h"
+
+#include "HelpUtils.h"
+#include "LangUtils.h"
+#include "PluginInterface.h"
+
+static const UINT kOpenBookmarkMenuID = 730;
+static const UINT kSetBookmarkMenuID = 740;
+
+extern HINSTANCE g_hInstance;
+
+static LPCWSTR kFMHelpTopic = L"fm/index.htm";
+
+extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance);
+
+using namespace NWindows;
+
+static const int kFileMenuIndex = 0;
+static const int kEditMenuIndex = 1;
+static const int kViewMenuIndex = 2;
+static const int kBookmarksMenuIndex = kViewMenuIndex + 1;
+
+struct CStringLangPair
+{
+ wchar_t *String;
+ UINT32 LangID;
+};
+
+static CStringLangPair kStringLangPairs[] =
+{
+ { L"&File", 0x03000102 },
+ { L"&Edit", 0x03000103 },
+ { L"&View", 0x03000104 },
+ { L"&Bookmarks", 0x03000107 },
+ { L"&Tools", 0x03000105 },
+ { L"&Help", 0x03000106 },
+};
+
+UINT32 kAddToFavoritesLangID = 0x03000710;
+UINT32 kToolbarsLangID = 0x03000451;
+
+/*
+static int FindStringLangItem(const UString &anItem)
+{
+ for (int i = 0; i < sizeof(kStringLangPairs) /
+ sizeof(kStringLangPairs[0]); i++)
+ if (anItem.CompareNoCase(kStringLangPairs[i].String) == 0)
+ return i;
+ return -1;
+}
+*/
+
+static CIDLangPair kIDLangPairs[] =
+{
+ // File
+ { IDM_FILE_OPEN, 0x03000210 },
+ { IDM_FILE_OPEN_INSIDE, 0x03000211 },
+ { IDM_FILE_OPEN_OUTSIDE, 0x03000212 },
+ // { IDM_FILE_VIEW, 0x03000220 }, // FIXME : does not exist !
+ { IDM_FILE_EDIT, 0x03000221 },
+ { IDM_RENAME, 0x03000230 },
+ { IDM_COPY_TO, 0x03000231 },
+ { IDM_MOVE_TO, 0x03000232 },
+ { IDM_DELETE, 0x03000233 },
+ { IDM_FILE_PROPERTIES, 0x03000240 },
+ { IDM_FILE_COMMENT, 0x03000241 },
+ { IDM_FILE_CRC, 0x03000242 },
+ { IDM_FILE_SPLIT, 0x03000270 },
+ { IDM_FILE_COMBINE, 0x03000271 },
+ { IDM_CREATE_FOLDER, 0x03000250 },
+ { IDM_CREATE_FILE, 0x03000251 },
+ // FIXME { IDCLOSE, 0x03000260 },
+
+ // Edit
+ { IDM_EDIT_CUT, 0x03000320 },
+ { IDM_EDIT_COPY, 0x03000321 },
+ { IDM_EDIT_PASTE, 0x03000322 },
+
+ { IDM_SELECT_ALL, 0x03000330 },
+ { IDM_DESELECT_ALL, 0x03000331 },
+ { IDM_INVERT_SELECTION, 0x03000332 },
+ { IDM_SELECT, 0x03000333 },
+ { IDM_DESELECT, 0x03000334 },
+ { IDM_SELECT_BY_TYPE, 0x03000335 },
+ { IDM_DESELECT_BY_TYPE, 0x03000336 },
+
+ { IDM_VIEW_LARGE_ICONS, 0x03000410 },
+ { IDM_VIEW_SMALL_ICONS, 0x03000411 },
+ { IDM_VIEW_LIST, 0x03000412 },
+ { IDM_VIEW_DETAILS, 0x03000413 },
+
+ { IDM_VIEW_ARANGE_BY_NAME, 0x02000204 },
+ { IDM_VIEW_ARANGE_BY_TYPE, 0x02000214 },
+ { IDM_VIEW_ARANGE_BY_DATE, 0x0200020C },
+ { IDM_VIEW_ARANGE_BY_SIZE, 0x02000207 },
+ { IDM_VIEW_ARANGE_NO_SORT, 0x03000420 },
+
+ { IDM_OPEN_ROOT_FOLDER, 0x03000430 },
+ { IDM_OPEN_PARENT_FOLDER, 0x03000431 },
+ { IDM_FOLDERS_HISTORY, 0x03000432 },
+
+ { IDM_VIEW_REFRESH, 0x03000440 },
+
+ { IDM_VIEW_FLAT_VIEW, 0x03000449 },
+ { IDM_VIEW_TWO_PANELS, 0x03000450 },
+ { IDM_VIEW_ARCHIVE_TOOLBAR, 0x03000460 },
+ { IDM_VIEW_STANDARD_TOOLBAR, 0x03000461 },
+ { IDM_VIEW_TOOLBARS_LARGE_BUTTONS, 0x03000462 },
+ { IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, 0x03000463 },
+
+ { IDM_OPTIONS, 0x03000510 },
+ { IDM_BENCHMARK, 0x03000511 },
+
+ { IDM_HELP_CONTENTS, 0x03000610 },
+ { IDM_ABOUT, 0x03000620 },
+
+ { 12111 , 0x03000710 }, // FIXME kAddToFavoritesLangID
+ { 12112 , 0x03000451 } // FIXME kToolbarsLangID
+};
+
+
+#ifdef _WIN32
+static int FindLangItem(int ControlID)
+{
+ for (int i = 0; i < sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]); i++)
+ if (kIDLangPairs[i].ControlID == ControlID)
+ return i;
+ return -1;
+}
+#endif
+
+
+/*
+static bool g_IsNew_fMask = true;
+
+class CInit_fMask
+{
+public:
+ CInit_fMask()
+ {
+ g_IsNew_fMask = false;
+ OSVERSIONINFO vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (::GetVersionEx(&vi))
+ {
+ g_IsNew_fMask = (vi.dwMajorVersion > 4 ||
+ (vi.dwMajorVersion == 4 && vi.dwMinorVersion > 0));
+ }
+ g_IsNew_fMask = false;
+ }
+} g_Init_fMask;
+
+// it's hack for supporting Windows NT
+// constants are from WinUser.h
+
+#if(WINVER < 0x0500)
+#define MIIM_STRING 0x00000040
+#define MIIM_BITMAP 0x00000080
+#define MIIM_FTYPE 0x00000100
+#endif
+
+static UINT Get_fMaskForString()
+{
+ return g_IsNew_fMask ? MIIM_STRING : MIIM_TYPE;
+}
+
+static UINT Get_fMaskForFTypeAndString()
+{
+ return g_IsNew_fMask ? (MIIM_STRING | MIIM_FTYPE) : MIIM_TYPE;
+}
+*/
+
+#ifdef _WIN32
+static UINT Get_fMaskForString()
+{
+ return MIIM_TYPE;
+}
+
+static UINT Get_fMaskForFTypeAndString()
+{
+ return MIIM_TYPE;
+}
+#endif
+
+
+static void MyChangeItem(wxMenuItem * mi,int LangID)
+{
+ UString newString = LangString(LangID);
+ if (newString.IsEmpty())
+ return;
+ wxString ss = mi->GetItemLabel();
+ UString shorcutString((const wchar_t *)ss); // = item.StringValue;
+ int tabPos = shorcutString.ReverseFind(wchar_t('\t'));
+ if (tabPos >= 0)
+ newString += shorcutString.Mid(tabPos);
+ // printf("Change Menu : %ls => %ls\n",(const wchar_t *)ss,(const wchar_t *)newString);
+ mi->SetItemLabel((const wchar_t *)newString);
+
+}
+
+static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
+{
+ // Sets the label of the top-level menus
+ for (int i1= 0; i1< sizeof(kStringLangPairs) / sizeof(kStringLangPairs[0]); i1++)
+ {
+ UString newString = LangString(kStringLangPairs[i1].LangID);
+ if (! newString.IsEmpty()) menuLoc->SetMenuLabel(i1, (const TCHAR *)newString);
+ }
+
+ // sub-menu items
+ for (int i = 0; i < sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]); i++)
+ {
+ wxMenuItem * mi = menuLoc->FindItem(kIDLangPairs[i].ControlID);
+ if (mi)
+ {
+ MyChangeItem(mi,kIDLangPairs[i].LangID);
+ }
+ else
+ printf("Change Menu : id=%d index=%d<>\n",kIDLangPairs[i].ControlID,i);
+ }
+}
+
+#ifdef _WIN32
+CMenu g_FileMenu;
+
+class CFileMenuDestroyer
+{
+public:
+ ~CFileMenuDestroyer()
+ {
+ if ((HMENU)g_FileMenu != 0)
+ g_FileMenu.Destroy();
+ }
+} g_FileMenuDestroyer;
+#endif
+
+
+void MyLoadMenu(HWND hWnd)
+{
+#ifdef _WIN32
+ if ((HMENU)g_FileMenu != 0)
+ g_FileMenu.Destroy();
+ HMENU oldMenu = ::GetMenu(hWnd);
+ HMENU baseMenu = ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU));
+ ::SetMenu(hWnd, baseMenu);
+ ::DestroyMenu(oldMenu);
+ if (!g_LangID.IsEmpty())
+ {
+ HMENU menuOld = ::GetMenu(hWnd);
+ MyChangeMenu(menuOld, 0, 0);
+ }
+ ::DrawMenuBar(hWnd);
+#else
+ extern void rc_MyLoadMenu(HWND hWnd);
+ rc_MyLoadMenu(hWnd);
+ if (!g_LangID.IsEmpty())
+ {
+ HMENU menuOld = ((wxFrame *)hWnd)->GetMenuBar(); // ::GetMenu(hWnd);
+ MyChangeMenu(menuOld, 0, 0);
+ }
+#endif
+}
+
+#ifdef _WIN32
+extern HWND g_HWND;
+void MyLoadMenu()
+{
+ MyLoadMenu(g_HWND);
+}
+
+static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
+{
+ CMenu srcMenu;
+ srcMenu.Attach(srcMenuSpec);
+ CMenu destMenu;
+ destMenu.Attach(destMenuSpec);
+ int startPos = 0;
+ for (int i = 0; i < srcMenu.GetItemCount(); i++)
+ {
+ CMenuItem item;
+ item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
+ item.fType = MFT_STRING;
+ if (srcMenu.GetItem(i, true, item))
+ if (destMenu.InsertItem(startPos, true, item))
+ startPos++;
+ }
+}
+
+void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
+{
+ if (::GetSubMenu(::GetMenu(g_HWND), position) != hMenu)
+ return;
+ if (position == kFileMenuIndex)
+ {
+ if ((HMENU)g_FileMenu == 0)
+ {
+ g_FileMenu.CreatePopup();
+ CopyMenu(hMenu, g_FileMenu);
+ }
+ CMenu menu;
+ menu.Attach(hMenu);
+ while (menu.GetItemCount() > 0)
+ {
+ if (!menu.RemoveItem(0, MF_BYPOSITION))
+ break;
+ }
+ // CopyMenu(g_FileMenu, hMenu);
+ g_App.GetFocusedPanel().CreateFileMenu(hMenu);
+ }
+ else if (position == kEditMenuIndex)
+ {
+ /*
+ CMenu menu;
+ menu.Attach(hMenu);
+ menu.EnableItem(IDM_EDIT_CUT, MF_ENABLED);
+ menu.EnableItem(IDM_EDIT_COPY, MF_ENABLED);
+ menu.EnableItem(IDM_EDIT_PASTE, IsClipboardFormatAvailableHDROP() ? MF_ENABLED : MF_GRAYED);
+ */
+ }
+ else if (position == kViewMenuIndex)
+ {
+ // View;
+ CMenu menu;
+ menu.Attach(hMenu);
+ menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
+ IDM_VIEW_LARGE_ICONS + g_App.GetListViewMode(), MF_BYCOMMAND);
+ menu.CheckItem(IDM_VIEW_TWO_PANELS, MF_BYCOMMAND |
+ ((g_App.NumPanels == 2) ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_FLAT_VIEW, MF_BYCOMMAND |
+ ((g_App.GetFlatMode()) ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, MF_BYCOMMAND |
+ (g_App.ShowArchiveToolbar ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_STANDARD_TOOLBAR, MF_BYCOMMAND |
+ (g_App.ShowStandardToolbar ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, MF_BYCOMMAND |
+ (g_App.LargeButtons ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, MF_BYCOMMAND |
+ (g_App.ShowButtonsLables ? MF_CHECKED : MF_UNCHECKED));
+ }
+ else if (position == kBookmarksMenuIndex)
+ {
+ CMenu menu;
+ menu.Attach(hMenu);
+
+ CMenu subMenu;
+ subMenu.Attach(menu.GetSubMenu(0));
+ while (subMenu.GetItemCount() > 0)
+ subMenu.RemoveItem(subMenu.GetItemCount() - 1, MF_BYPOSITION);
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ UString s = LangString(IDS_BOOKMARK, 0x03000720);
+ s += L" ";
+ wchar_t c = (wchar_t)(L'0' + i);
+ s += c;
+ s += L"\tAlt+Shift+";
+ s += c;
+ subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s);
+ }
+
+ while (menu.GetItemCount() > 2)
+ menu.RemoveItem(menu.GetItemCount() - 1, MF_BYPOSITION);
+
+ for (i = 0; i < 10; i++)
+ {
+ UString path = g_App.AppState.FastFolders.GetString(i);
+ const int kMaxSize = 100;
+ const int kFirstPartSize = kMaxSize / 2;
+ if (path.Length() > kMaxSize)
+ {
+ path = path.Left(kFirstPartSize) + UString(L" ... ") +
+ path.Right(kMaxSize - kFirstPartSize);
+ }
+ UString s = path;
+ if (s.IsEmpty())
+ s = L"-";
+ s += L"\tAlt+";
+ s += (wchar_t)(L'0' + i);
+ menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
+ }
+ }
+}
+
+/*
+It doesn't help
+void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id)
+{
+ if (::GetSubMenu(::GetMenu(g_HWND), 0) != hMenu)
+ return;
+ // g_App.GetFocusedPanel()._contextMenu.Release();
+}
+
+void OnMenuUnActivating(HWND hWnd)
+{
+}
+*/
+
+
+void LoadFileMenu(HMENU hMenu, int startPos, bool /* forFileMode */, bool programMenu)
+{
+ {
+ CMenu srcMenu;
+ srcMenu.Attach(::GetSubMenu(::GetMenu(g_HWND), 0));
+ if ((HMENU)g_FileMenu == 0)
+ {
+ g_FileMenu.CreatePopup();
+ CopyMenu(srcMenu, g_FileMenu);
+ }
+ }
+
+ CMenu destMenu;
+ destMenu.Attach(hMenu);
+
+ for (int i = 0; i < g_FileMenu.GetItemCount(); i++)
+ {
+ CMenuItem item;
+
+ item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
+ item.fType = MFT_STRING;
+ if (g_FileMenu.GetItem(i, true, item))
+ {
+ if (!programMenu)
+ if (item.wID == IDCLOSE)
+ continue;
+ /*
+ bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE);
+ if (forFileMode)
+ {
+ if (createItem)
+ continue;
+ }
+ else
+ {
+ if (!createItem)
+ continue;
+ }
+ */
+ if (destMenu.InsertItem(startPos, true, item))
+ startPos++;
+ }
+ }
+ while (destMenu.GetItemCount() > 0)
+ {
+ CMenuItem item;
+ item.fMask = MIIM_TYPE;
+ item.fType = 0;
+ // item.dwTypeData = 0;
+ int lastIndex = destMenu.GetItemCount() - 1;
+ if (!destMenu.GetItem(lastIndex, true, item))
+ break;
+ if(item.fType != MFT_SEPARATOR)
+ break;
+ if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION))
+ break;
+ }
+}
+#endif
+
+bool ExecuteFileCommand(int id)
+{
+ if (id >= kPluginMenuStartID)
+ {
+#ifdef _WIN32
+ g_App.GetFocusedPanel().InvokePluginCommand(id);
+ g_App.GetFocusedPanel()._sevenZipContextMenu.Release();
+ g_App.GetFocusedPanel()._systemContextMenu.Release();
+#endif
+ return true;
+ }
+
+ switch (id)
+ {
+ // File
+ case IDM_FILE_OPEN:
+ g_App.OpenItem();
+ break;
+ case IDM_FILE_OPEN_INSIDE:
+ g_App.OpenItemInside();
+ break;
+ case IDM_FILE_OPEN_OUTSIDE:
+ g_App.OpenItemOutside();
+ break;
+ case IDM_FILE_VIEW:
+ break;
+ case IDM_FILE_EDIT:
+ g_App.EditItem();
+ break;
+ case IDM_RENAME:
+ g_App.Rename();
+ break;
+ case IDM_COPY_TO:
+ g_App.CopyTo();
+ break;
+ case IDM_MOVE_TO:
+ g_App.MoveTo();
+ break;
+ case IDM_DELETE:
+ {
+#ifdef _WIN32 // FIXME
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ g_App.Delete(!shift);
+#endif
+ break;
+ }
+ case IDM_FILE_CRC:
+ g_App.CalculateCrc();
+ break;
+ case IDM_FILE_SPLIT:
+ g_App.Split();
+ break;
+ case IDM_FILE_COMBINE:
+ g_App.Combine();
+ break;
+ case IDM_FILE_PROPERTIES:
+ g_App.Properties();
+ break;
+ case IDM_FILE_COMMENT:
+ g_App.Comment();
+ break;
+
+ case IDM_CREATE_FOLDER:
+ g_App.CreateFolder();
+ break;
+ case IDM_CREATE_FILE:
+ g_App.CreateFile();
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+bool OnMenuCommand(HWND hWnd, int id)
+{
+ printf("DEBUG : OnMenuCommand(%p,id=%d)-0\n",hWnd,id);
+
+ if (ExecuteFileCommand(id))
+ return true;
+
+ printf("DEBUG : OnMenuCommand(%p,id=%d)-1\n",hWnd,id);
+
+ switch (id)
+ {
+ // File
+ /* FIXME
+ case IDCLOSE:
+ SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
+ SendMessage (hWnd, WM_CLOSE, 0, 0);
+ break;
+ */
+
+ // Edit
+ case IDM_EDIT_CUT:
+ g_App.EditCut();
+ break;
+ case IDM_EDIT_COPY:
+ g_App.EditCopy();
+ break;
+ case IDM_EDIT_PASTE:
+ g_App.EditPaste();
+ break;
+ case IDM_SELECT_ALL:
+ g_App.SelectAll(true);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_DESELECT_ALL:
+ g_App.SelectAll(false);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_INVERT_SELECTION:
+ g_App.InvertSelection();
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_SELECT:
+ g_App.SelectSpec(true);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_DESELECT:
+ g_App.SelectSpec(false);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_SELECT_BY_TYPE:
+ g_App.SelectByType(true);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_DESELECT_BY_TYPE:
+ g_App.SelectByType(false);
+ g_App.RefreshStatusBar();
+ break;
+
+ //View
+ case IDM_VIEW_LARGE_ICONS:
+ case IDM_VIEW_SMALL_ICONS:
+ case IDM_VIEW_LIST:
+ case IDM_VIEW_DETAILS:
+ {
+ UINT index = id - IDM_VIEW_LARGE_ICONS;
+ if (index < 4)
+ {
+ g_App.SetListViewMode(index);
+ /*
+ CMenu menu;
+ menu.Attach(::GetSubMenu(::GetMenu(hWnd), kViewMenuIndex));
+ menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
+ id, MF_BYCOMMAND);
+ */
+ }
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_NAME:
+ {
+ g_App.SortItemsWithPropID(kpidName);
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_TYPE:
+ {
+ g_App.SortItemsWithPropID(kpidExtension);
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_DATE:
+ {
+ g_App.SortItemsWithPropID(kpidMTime);
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_SIZE:
+ {
+ g_App.SortItemsWithPropID(kpidSize);
+ break;
+ }
+ case IDM_VIEW_ARANGE_NO_SORT:
+ {
+ g_App.SortItemsWithPropID(kpidNoProperty);
+ break;
+ }
+
+ case IDM_OPEN_ROOT_FOLDER:
+ g_App.OpenRootFolder();
+ break;
+ case IDM_OPEN_PARENT_FOLDER:
+ g_App.OpenParentFolder();
+ break;
+ case IDM_FOLDERS_HISTORY:
+ g_App.FoldersHistory();
+ break;
+ case IDM_VIEW_REFRESH:
+ g_App.RefreshView();
+ break;
+ case IDM_VIEW_FLAT_VIEW:
+ g_App.ChangeFlatMode();
+ break;
+ case IDM_VIEW_TWO_PANELS:
+ g_App.SwitchOnOffOnePanel();
+ break;
+ case IDM_VIEW_STANDARD_TOOLBAR:
+ g_App.SwitchStandardToolbar();
+ break;
+ case IDM_VIEW_ARCHIVE_TOOLBAR:
+ g_App.SwitchArchiveToolbar();
+ break;
+ case IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT:
+ g_App.SwitchButtonsLables();
+ break;
+ case IDM_VIEW_TOOLBARS_LARGE_BUTTONS:
+ g_App.SwitchLargeButtons();
+ break;
+
+ // Tools
+ case IDM_OPTIONS:
+ // FIXME OptionsDialog(hWnd, g_hInstance);
+ break;
+
+ case IDM_BENCHMARK:
+ Benchmark();
+ break;
+ // Help
+ case IDM_HELP_CONTENTS:
+ ShowHelpWindow(NULL, kFMHelpTopic);
+ break;
+ case IDM_ABOUT:
+ {
+ /* FIXME
+ CAboutDialog dialog;
+ dialog.Create(hWnd);
+ */
+ printf("IDM_ABOUT ...\n");
+ break;
+ }
+ default:
+ {
+ if (id >= kOpenBookmarkMenuID && id <= kOpenBookmarkMenuID + 9)
+ {
+ g_App.OpenBookmark(id - kOpenBookmarkMenuID);
+ return true;
+ }
+ else if (id >= kSetBookmarkMenuID && id <= kSetBookmarkMenuID + 9)
+ {
+ g_App.SetBookmark(id - kSetBookmarkMenuID);
+ return true;
+ }
+ return false;
+ }
+ }
+ return true;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MyLoadMenu.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MyLoadMenu.h
new file mode 100644
index 000000000..9dae77f00
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/MyLoadMenu.h
@@ -0,0 +1,20 @@
+// MyLoadMenu.h
+
+#ifndef __MYLOADMENU_H
+#define __MYLOADMENU_H
+
+class myHMENU; // FIXME
+typedef myHMENU * HMENU; // FIXME
+
+void OnMenuActivating(HWND hWnd, HMENU hMenu, int position);
+// void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id);
+// void OnMenuUnActivating(HWND hWnd);
+
+void MyLoadMenu(HWND hWnd);
+bool OnMenuCommand(HWND hWnd, int id);
+void MyLoadMenu();
+void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu,
+ bool isFsFolder, int numItems, bool allAreFiles);
+bool ExecuteFileCommand(int id);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/NetFolder.h.OUT b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/NetFolder.h.OUT
new file mode 100644
index 000000000..384e7f190
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/NetFolder.h.OUT
@@ -0,0 +1,56 @@
+// NetFolder.h
+
+#ifndef __NETFOLDER_H
+#define __NETFOLDER_H
+
+#include "Common/MyString.h"
+#include "Common/Buffer.h"
+#include "Common/MyCom.h"
+#include "Windows/PropVariant.h"
+// FIXME #include "Windows/Net.h"
+
+#include "IFolder.h"
+
+struct CResourceEx // FIXME : public NWindows::NNet::CResourceW
+{
+ UString Name;
+};
+
+class CNetFolder:
+ public IFolderFolder,
+ public IFolderGetSystemIconIndex,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(
+ IFolderGetSystemIconIndex
+ )
+
+ INTERFACE_FolderFolder(;)
+
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
+
+private:
+#ifdef _WIN32
+ NWindows::NNet::CResourceW _netResource;
+ NWindows::NNet::CResourceW *_netResourcePointer;
+#else
+ int _netResource;
+ int *_netResourcePointer;
+#endif
+
+ CObjectVector<CResourceEx> _items;
+
+ CMyComPtr<IFolderFolder> _parentFolder;
+ UString _path;
+
+public:
+ void Init(const UString &path);
+#ifdef _WIN32
+ void Init(const NWindows::NNet::CResourceW *netResource,
+ IFolderFolder *parentFolder, const UString &path);
+ CNetFolder(): _netResourcePointer(0) {}
+#endif
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OpenCallback.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OpenCallback.cpp
new file mode 100644
index 000000000..a275f89bc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OpenCallback.cpp
@@ -0,0 +1,122 @@
+// OpenCallback.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../Common/FileStreams.h"
+
+#include "OpenCallback.h"
+#include "PasswordDialog.h"
+
+using namespace NWindows;
+
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes)
+{
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ {
+ NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ if (numFiles != NULL)
+ {
+ ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles);
+ ProgressDialog.ProgressSynch.SetBytesProgressMode(false);
+ }
+ if (numBytes != NULL)
+ ProgressDialog.ProgressSynch.SetNumBytesTotal(*numBytes);
+ }
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes)
+{
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ if (numFiles != NULL)
+ ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles);
+ if (numBytes != NULL)
+ ProgressDialog.ProgressSynch.SetPos(*numBytes);
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 total)
+{
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ ProgressDialog.ProgressSynch.SetNumBytesTotal(total);
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed)
+{
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ if (completed != NULL)
+ ProgressDialog.ProgressSynch.SetPos(*completed);
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ if (_subArchiveMode)
+ {
+ switch(propID)
+ {
+ case kpidName: prop = _subArchiveName; break;
+ }
+ }
+ else
+ {
+ switch(propID)
+ {
+ case kpidName: prop = _fileInfo.Name; break;
+ case kpidIsDir: prop = _fileInfo.IsDir(); break;
+ case kpidSize: prop = _fileInfo.Size; break;
+ case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
+ case kpidCTime: prop = _fileInfo.CTime; break;
+ case kpidATime: prop = _fileInfo.ATime; break;
+ case kpidMTime: prop = _fileInfo.MTime; break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
+ IInStream **inStream)
+{
+ *inStream = NULL;
+ if (_subArchiveMode)
+ return S_FALSE;
+
+ NFile::NFind::CFileInfoW fileInfo;
+
+ UString fullPath = _folderPrefix + name;
+ if (!fileInfo.Find(fullPath))
+ return S_FALSE;
+ _fileInfo = fileInfo;
+ if (_fileInfo.IsDir())
+ return S_FALSE;
+ CInFileStream *inFile = new CInFileStream;
+ CMyComPtr<IInStream> inStreamTemp = inFile;
+ if (!inFile->Open(fullPath))
+ return ::GetLastError();
+ *inStream = inStreamTemp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
+{
+ PasswordWasAsked = true;
+ if (!PasswordIsDefined)
+ {
+ CPasswordDialog dialog;
+
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
+ return E_ABORT;
+
+ Password = dialog.Password;
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OpenCallback.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OpenCallback.h
new file mode 100644
index 000000000..5f0fbefc1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OpenCallback.h
@@ -0,0 +1,92 @@
+// OpenCallback.h
+
+#ifndef __OPENCALLBACK_H
+#define __OPENCALLBACK_H
+
+#include "Common/MyCom.h"
+#include "Common/MyString.h"
+
+#include "Windows/FileFind.h"
+
+#include "../../IPassword.h"
+
+#include "../../Archive/IArchive.h"
+
+#ifdef _SFX
+#include "ProgressDialog.h"
+#else
+#include "ProgressDialog2.h"
+#endif
+
+
+class COpenArchiveCallback:
+ public IArchiveOpenCallback,
+ public IArchiveOpenVolumeCallback,
+ public IArchiveOpenSetSubArchiveName,
+ public IProgress,
+ public ICryptoGetTextPassword,
+ public CMyUnknownImp
+{
+ UString _folderPrefix;
+ NWindows::NFile::NFind::CFileInfoW _fileInfo;
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+ bool _subArchiveMode;
+ UString _subArchiveName;
+
+public:
+ bool PasswordIsDefined;
+ bool PasswordWasAsked;
+ UString Password;
+ HWND ParentWindow;
+ CProgressDialog ProgressDialog;
+
+ MY_UNKNOWN_IMP5(
+ IArchiveOpenCallback,
+ IArchiveOpenVolumeCallback,
+ IArchiveOpenSetSubArchiveName,
+ IProgress,
+ ICryptoGetTextPassword)
+
+ INTERFACE_IProgress(;)
+ INTERFACE_IArchiveOpenCallback(;)
+ INTERFACE_IArchiveOpenVolumeCallback(;)
+
+ // ICryptoGetTextPassword
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+
+ STDMETHOD(SetSubArchiveName(const wchar_t *name))
+ {
+ _subArchiveMode = true;
+ _subArchiveName = name;
+ return S_OK;
+ }
+
+ COpenArchiveCallback():
+ ParentWindow(0)
+ {
+ _subArchiveMode = false;
+ PasswordIsDefined = false;
+ PasswordWasAsked = false;
+ }
+ /*
+ void Init()
+ {
+ PasswordIsDefined = false;
+ _subArchiveMode = false;
+ }
+ */
+ void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
+ {
+ _folderPrefix = folderPrefix;
+ if (!_fileInfo.Find(_folderPrefix + fileName))
+ throw 1;
+ }
+ void ShowMessage(const UInt64 *completed);
+
+ INT_PTR StartProgressDialog(const UString &title)
+ {
+ return ProgressDialog.Create(title, ParentWindow);
+ }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog.cpp
new file mode 100644
index 000000000..2d6bc5217
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog.cpp
@@ -0,0 +1,126 @@
+// OverwriteDialog.cpp
+
+#include "StdAfx.h"
+
+#include "OverwriteDialog.h"
+
+#include "Common/StringConvert.h"
+#include "Windows/FileName.h"
+#include "Windows/Defs.h"
+#include "Windows/ResourceString.h"
+#include "Windows/Control/Static.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "FormatUtils.h"
+
+// #include "../resource.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_OVERWRITE_HEADER, 0x02000901},
+ { IDC_STATIC_OVERWRITE_QUESTION_BEGIN, 0x02000902 },
+ { IDC_STATIC_OVERWRITE_QUESTION_END, 0x02000903 },
+ { IDYES, 0x02000705 },
+ { IDC_BUTTON_OVERWRITE_YES_TO_ALL, 0x02000707 },
+ { IDNO, 0x02000709 },
+ { IDC_BUTTON_OVERWRITE_NO_TO_ALL,0x0200070B },
+ { IDC_BUTTON_OVERWRITE_AUTO_RENAME, 0x02000911 },
+ { IDCANCEL, 0x02000711 }
+};
+#endif
+
+void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
+ const NOverwriteDialog::CFileInfo &fileInfo)
+{
+ UString sizeString;
+ if (fileInfo.SizeIsDefined)
+ sizeString = MyFormatNew(IDS_FILE_SIZE,
+ #ifdef LANG
+ 0x02000982,
+ #endif
+ NumberToString(fileInfo.Size));
+
+ UString reducedName;
+ const int kLineSize = 88;
+ for (int i = 0; i < fileInfo.Name.Length();)
+ {
+ reducedName += fileInfo.Name.Mid(i, kLineSize);
+ reducedName += L" ";
+ i += kLineSize;
+ }
+
+ UString fullString = reducedName;
+ fullString += L"\n";
+ fullString += sizeString;
+ fullString += L"\n";
+
+ if (fileInfo.TimeIsDefined)
+ {
+ UString timeString;
+ FILETIME localFileTime;
+ if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
+ throw 4190402;
+ timeString = ConvertFileTimeToString(localFileTime);
+
+ fullString +=
+ #ifdef LANG
+ LangString(IDS_FILE_MODIFIED, 0x02000983);
+ #else
+ MyLoadStringW(IDS_FILE_MODIFIED);
+ #endif
+
+ fullString += L" ";
+ fullString += timeString;
+ }
+
+ NWindows::NControl::CDialogChildControl control;
+ control.Init(*this, textID);
+ control.SetText(fullString);
+
+#ifdef _WIN32 // FIXME
+ SHFILEINFO shellFileInfo;
+ if (::SHGetFileInfo(
+ GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo,
+ sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON))
+ {
+ NControl::CStatic staticContol;
+ staticContol.Attach(GetItem(iconID));
+ staticContol.SetIcon(shellFileInfo.hIcon);
+ }
+#endif
+}
+
+bool COverwriteDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000900);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME,
+ IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo);
+ SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME,
+ IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo);
+ return CModalDialog::OnInit();
+}
+
+bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDYES:
+ case IDC_BUTTON_OVERWRITE_YES_TO_ALL:
+ case IDNO:
+ case IDC_BUTTON_OVERWRITE_NO_TO_ALL:
+ case IDC_BUTTON_OVERWRITE_AUTO_RENAME:
+ End(buttonID);
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog.h
new file mode 100644
index 000000000..d206fb015
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog.h
@@ -0,0 +1,34 @@
+// OverwriteDialog.h
+
+#ifndef __OVERWRITEDIALOG_H
+#define __OVERWRITEDIALOG_H
+
+#include "OverwriteDialogRes.h"
+#include "Windows/Control/Dialog.h"
+
+namespace NOverwriteDialog
+{
+ struct CFileInfo
+ {
+ bool SizeIsDefined;
+ UINT64 Size;
+ bool TimeIsDefined;
+ FILETIME Time;
+ UString Name;
+ };
+}
+
+class COverwriteDialog: public NWindows::NControl::CModalDialog
+{
+ void SetFileInfoControl(int textID, int iconID,
+ const NOverwriteDialog::CFileInfo &fileInfo);
+ virtual bool OnInit();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+public:
+ INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_OVERWRITE, parent); }
+
+ NOverwriteDialog::CFileInfo OldFileInfo;
+ NOverwriteDialog::CFileInfo NewFileInfo;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialogRes.h
new file mode 100644
index 000000000..66710f848
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialogRes.h
@@ -0,0 +1,19 @@
+#define IDS_FILE_MODIFIED 600
+#define IDS_FILE_SIZE 601
+
+#define IDD_DIALOG_OVERWRITE 502
+
+#define IDC_STATIC_OVERWRITE_HEADER 1000
+
+#define IDC_STATIC_OVERWRITE_QUESTION_BEGIN 1001
+#define IDC_STATIC_OVERWRITE_QUESTION_END 1002
+
+#define IDC_STATIC_OVERWRITE_OLD_FILE_ICON 1003
+#define IDC_STATIC_OVERWRITE_NEW_FILE_ICON 1004
+
+#define IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME 1005
+#define IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME 1006
+
+#define IDC_BUTTON_OVERWRITE_YES_TO_ALL 1010
+#define IDC_BUTTON_OVERWRITE_NO_TO_ALL 1011
+#define IDC_BUTTON_OVERWRITE_AUTO_RENAME 1012
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog_rc.cpp
new file mode 100644
index 000000000..08ddd36de
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/OverwriteDialog_rc.cpp
@@ -0,0 +1,96 @@
+// OverwriteDialog_rc.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "OverwriteDialogRes.h"
+#include "Windows/Control/DialogImpl.h"
+
+/*
+IDD_DIALOG_OVERWRITE DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
+CAPTION "Confirm File Replace"
+MY_FONT
+BEGIN
+ LTEXT "Destination folder already contains processed file.", IDC_STATIC_OVERWRITE_HEADER, marg, 7, xSize2, 8
+ LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, marg, 28, xSize2, 8
+ ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, marg, 44, iconSize, iconSize
+ LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, fiXPos, 44, fiXSize, fiYSize, SS_NOPREFIX
+ LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, marg, 98, xSize2, 8
+ ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, marg, 114, iconSize, iconSize
+ LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, fiXPos, 114, fiXSize, fiYSize, SS_NOPREFIX
+ PUSHBUTTON "&Yes", IDYES, 78, b2YPos, bXSize, bYSize
+ PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, 152, b2YPos, bXSize, bYSize
+ PUSHBUTTON "&No", IDNO, 226, b2YPos, bXSize, bYSize
+ PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, 300, b2YPos, bXSize, bYSize
+ PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, 181, b1YPos, 109, bYSize
+ PUSHBUTTON "&Cancel", IDCANCEL, 300, b1YPos, bXSize, bYSize
+END
+*/
+
+class COverwriteDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ COverwriteDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Confirm File Replace"))
+ {
+ ///Sizer for adding the controls created by users
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_HEADER, _T("Destination folder already contains processed file.")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_QUESTION_BEGIN, _T("Would you like to replace the existing file")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+ // FIXME ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, marg, 44, iconSize, iconSize
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, _T(""),
+ wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT) , 0 ,wxALL | wxALIGN_LEFT, 15 );
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_QUESTION_END, _T("with this one?")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+ // FIXME ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, marg, 114, iconSize, iconSize
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, _T(""),
+ wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT) , 0 ,wxALL | wxALIGN_LEFT, 15 );
+
+ wxBoxSizer* Sizer1 = new wxBoxSizer(wxHORIZONTAL);
+ Sizer1->Add(new wxButton(this, wxID_YES, _T("&Yes")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ Sizer1->Add(new wxButton(this, IDC_BUTTON_OVERWRITE_YES_TO_ALL, _T("Yes to &All")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ Sizer1->Add(new wxButton(this, wxID_NO, _T("&No")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ Sizer1->Add(new wxButton(this, IDC_BUTTON_OVERWRITE_NO_TO_ALL, _T("No to A&ll")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ topsizer->Add(Sizer1 , 0, wxALL | wxALIGN_RIGHT, 5);
+
+ wxBoxSizer* Sizer2 = new wxBoxSizer(wxHORIZONTAL);
+ Sizer2->Add(new wxButton(this, IDC_BUTTON_OVERWRITE_AUTO_RENAME, _T("A&uto Rename")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ Sizer2->Add(new wxButton(this, wxID_CANCEL, _T("&Cancel")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ topsizer->Add(Sizer2 , 1, wxALL | wxALIGN_RIGHT, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { IDS_FILE_MODIFIED, L"modified on" },
+ { IDS_FILE_SIZE, L"{0} bytes" },
+ { 0 , 0 }
+};
+
+REGISTER_DIALOG(IDD_DIALOG_OVERWRITE,COverwriteDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(COverwriteDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/Panel.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/Panel.cpp
new file mode 100644
index 000000000..a9123da80
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/Panel.cpp
@@ -0,0 +1,1100 @@
+// Panel.cpp
+
+#include "StdAfx.h"
+
+#ifdef _WIN32
+#include <Windowsx.h>
+#endif
+
+#include "Common/Defs.h"
+#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
+#include "Windows/Error.h"
+#include "Windows/PropVariant.h"
+#include "Windows/Thread.h"
+
+#include "../../PropID.h"
+
+#include "Panel.h"
+#include "RootFolder.h"
+#include "FSFolder.h"
+#include "FormatUtils.h"
+#include "App.h"
+#include "ExtractCallback.h"
+
+#include "resource.h"
+#include "../GUI/ExtractRes.h"
+
+#include "../Agent/IFolderArchive.h"
+
+#include "../Common/CompressCall.h"
+#include "../Common/ArchiveName.h"
+
+using namespace NWindows;
+using namespace NControl;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+static const UINT_PTR kTimerID = 1;
+static const UINT kTimerElapse = 1000;
+
+#ifdef _WIN32
+static DWORD kStyles[4] = { LVS_ICON, LVS_SMALLICON, LVS_LIST, LVS_REPORT };
+#endif
+
+// static const int kCreateFolderID = 101;
+// static const UINT kFileChangeNotifyMessage = WM_APP;
+
+extern HINSTANCE g_hInstance;
+extern DWORD g_ComCtl32Version;
+
+void CPanel::Release()
+{
+ // It's for unloading COM dll's: don't change it.
+ CloseOpenFolders();
+#ifdef _WIN32
+ _sevenZipContextMenu.Release();
+ _systemContextMenu.Release();
+#endif
+}
+
+CPanel::~CPanel()
+{
+ CloseOpenFolders();
+}
+
+#ifdef _WIN32 // FIXME
+HWND CPanel::GetParent()
+{
+ HWND h = CWindow2::GetParent();
+ return (h == 0) ? _mainWindow : h;
+}
+#endif
+
+static LPCWSTR kClassName = L"7-Zip::Panel";
+
+
+HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
+ const UString &currentFolderPrefix, CPanelCallback *panelCallback, CAppState *appState,
+ bool &archiveIsOpened, bool &encrypted)
+{
+ _mainWindow = mainWindow;
+ _processTimer = true;
+ _processNotify = true;
+
+ _panelCallback = panelCallback;
+ _appState = appState;
+ // _index = index;
+ _baseID = id;
+ _comboBoxID = _baseID + 3;
+ _statusBarID = _comboBoxID + 1;
+
+ UString cfp = currentFolderPrefix;
+
+ if (!currentFolderPrefix.IsEmpty())
+ if (currentFolderPrefix[0] == L'.')
+ if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp))
+ cfp = currentFolderPrefix;
+ RINOK(BindToPath(cfp, archiveIsOpened, encrypted));
+
+#ifdef _WIN32
+ if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
+ 0, 0, _xSize, 260,
+ parentWindow, (HMENU)(UINT_PTR)id, g_hInstance))
+ return E_FAIL;
+#else
+ {
+ // printf("WARNING CPanel::Create => CreateEx\n");
+ // this->OnCreate(0);
+ extern void registerWindow2(int baseID,NWindows::NControl::CWindow2 *w);
+ registerWindow2(_baseID,this);
+ }
+#endif
+
+ return S_OK;
+}
+
+LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message)
+ {
+ case kShiftSelectMessage:
+ OnShiftSelectMessage();
+ return 0;
+ case kReLoadMessage:
+ RefreshListCtrl(_selectedState);
+ return 0;
+ case kSetFocusToListView:
+ _listView.SetFocus();
+ return 0;
+ case kOpenItemChanged:
+ return OnOpenItemChanged(lParam);
+ case kRefreshStatusBar:
+ OnRefreshStatusBar();
+ return 0;
+#ifdef _WIN32
+ case WM_TIMER:
+ OnTimer();
+ return 0;
+ case WM_CONTEXTMENU:
+ if (OnContextMenu(HANDLE(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))
+ return 0;
+ break;
+ /*
+ case WM_DROPFILES:
+ CompressDropFiles(HDROP(wParam));
+ return 0;
+ */
+#endif
+ }
+ return CWindow2::OnMessage(message, wParam, lParam);
+}
+
+#ifdef _WIN32
+static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ CWindow tempDialog(hwnd);
+ CMyListView *w = (CMyListView *)(tempDialog.GetUserDataLongPtr());
+ if (w == NULL)
+ return 0;
+ return w->OnMessage(message, wParam, lParam);
+}
+
+LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ if (message == WM_CHAR)
+ {
+ UINT scanCode = (UINT)((lParam >> 16) & 0xFF);
+ bool extended = ((lParam & 0x1000000) != 0);
+ UINT virtualKey = MapVirtualKey(scanCode, 1);
+ if (virtualKey == VK_MULTIPLY || virtualKey == VK_ADD ||
+ virtualKey == VK_SUBTRACT)
+ return 0;
+ if ((wParam == '/' && extended)
+ || wParam == CHAR_PATH_SEPARATOR || wParam == '/')
+ {
+ _panel->OpenDrivesFolder();
+ return 0;
+ }
+ }
+ else if (message == WM_SYSCHAR)
+ {
+ // For Alt+Enter Beep disabling
+ UINT scanCode = (UINT)(lParam >> 16) & 0xFF;
+ UINT virtualKey = MapVirtualKey(scanCode, 1);
+ if (virtualKey == VK_RETURN || virtualKey == VK_MULTIPLY ||
+ virtualKey == VK_ADD || virtualKey == VK_SUBTRACT)
+ return 0;
+ }
+ /*
+ else if (message == WM_SYSKEYDOWN)
+ {
+ // return 0;
+ }
+ */
+ else if (message == WM_KEYDOWN)
+ {
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
+ // bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ switch(wParam)
+ {
+ case VK_RETURN:
+ {
+ if (shift && !alt && !ctrl)
+ {
+ _panel->OpenSelectedItems(false);
+ return 0;
+ }
+ break;
+ }
+ case VK_NEXT:
+ {
+ if (ctrl && !alt && !shift)
+ {
+ _panel->OpenFocusedItemAsInternal();
+ return 0;
+ }
+ break;
+ }
+ case VK_PRIOR:
+ if (ctrl && !alt && !shift)
+ {
+ _panel->OpenParentFolder();
+ return 0;
+ }
+ }
+ }
+ else if (message == WM_SETFOCUS)
+ {
+ _panel->_lastFocusedIsList = true;
+ _panel->_panelCallback->PanelWasFocused();
+ }
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ else
+ #endif
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+}
+
+/*
+static LRESULT APIENTRY ComboBoxSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ CWindow tempDialog(hwnd);
+ CMyComboBox *w = (CMyComboBox *)(tempDialog.GetUserDataLongPtr());
+ if (w == NULL)
+ return 0;
+ return w->OnMessage(message, wParam, lParam);
+}
+
+LRESULT CMyComboBox::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+}
+*/
+static LRESULT APIENTRY ComboBoxEditSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ CWindow tempDialog(hwnd);
+ CMyComboBoxEdit *w = (CMyComboBoxEdit *)(tempDialog.GetUserDataLongPtr());
+ if (w == NULL)
+ return 0;
+ return w->OnMessage(message, wParam, lParam);
+}
+
+LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ // See MSDN / Subclassing a Combo Box / Creating a Combo-box Toolbar
+ switch (message)
+ {
+ case WM_SYSKEYDOWN:
+ switch (wParam)
+ {
+ case VK_F1:
+ case VK_F2:
+ {
+ // check ALT
+ if ((lParam & (1<<29)) == 0)
+ break;
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ if (alt && !ctrl && !shift)
+ {
+ _panel->_panelCallback->SetFocusToPath(wParam == VK_F1 ? 0 : 1);
+ return 0;
+ }
+ break;
+ }
+ }
+ break;
+ case WM_KEYDOWN:
+ switch (wParam)
+ {
+ case VK_TAB:
+ // SendMessage(hwndMain, WM_ENTER, 0, 0);
+ _panel->SetFocusToList();
+ return 0;
+ case VK_F9:
+ {
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ if (!alt && !ctrl && !shift)
+ {
+ g_App.SwitchOnOffOnePanel();;
+ return 0;
+ }
+ break;
+ }
+ }
+ break;
+ case WM_CHAR:
+ switch (wParam)
+ {
+ case VK_TAB:
+ case VK_ESCAPE:
+ return 0;
+ }
+ }
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ else
+ #endif
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+}
+
+static HIMAGELIST GetSysImageList(bool smallIcons)
+{
+ SHFILEINFO shellInfo;
+ return (HIMAGELIST)SHGetFileInfo(TEXT(""),
+ FILE_ATTRIBUTE_NORMAL |FILE_ATTRIBUTE_DIRECTORY,
+ &shellInfo, sizeof(shellInfo),
+ SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON));
+}
+
+bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
+{
+ // _virtualMode = false;
+ // _sortIndex = 0;
+ _sortID = kpidName;
+ _ascending = true;
+ _lastFocusedIsList = true;
+
+ DWORD style = WS_CHILD | WS_VISIBLE; // | WS_BORDER ; // | LVS_SHAREIMAGELISTS; // | LVS_SHOWSELALWAYS;;
+
+ style |= LVS_SHAREIMAGELISTS;
+ // style |= LVS_AUTOARRANGE;
+ style |= WS_CLIPCHILDREN;
+ style |= WS_CLIPSIBLINGS;
+
+ const UInt32 kNumListModes = sizeof(kStyles) / sizeof(kStyles[0]);
+ if (_ListViewMode >= kNumListModes)
+ _ListViewMode = kNumListModes - 1;
+
+ style |= kStyles[_ListViewMode]
+ | WS_TABSTOP
+ | LVS_EDITLABELS;
+ if (_mySelectMode)
+ style |= LVS_SINGLESEL;
+
+ /*
+ if (_virtualMode)
+ style |= LVS_OWNERDATA;
+ */
+
+ DWORD exStyle;
+ exStyle = WS_EX_CLIENTEDGE;
+
+ if (!_listView.CreateEx(exStyle, style, 0, 0, 116, 260,
+ HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL))
+ return false;
+
+ _listView.SetUnicodeFormat(true);
+
+ _listView.SetUserDataLongPtr(LONG_PTR(&_listView));
+ _listView._panel = this;
+
+ #ifndef _UNICODE
+ if(g_IsNT)
+ _listView._origWindowProc =
+ (WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
+ else
+ #endif
+ _listView._origWindowProc =
+ (WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
+
+ _listView.SetImageList(GetSysImageList(true), LVSIL_SMALL);
+ _listView.SetImageList(GetSysImageList(false), LVSIL_NORMAL);
+
+ // _exStyle |= LVS_EX_HEADERDRAGDROP;
+ // DWORD extendedStyle = _listView.GetExtendedListViewStyle();
+ // extendedStyle |= _exStyle;
+ // _listView.SetExtendedListViewStyle(extendedStyle);
+ SetExtendedStyle();
+
+ _listView.Show(SW_SHOW);
+ _listView.InvalidateRect(NULL, true);
+ _listView.Update();
+
+ // Ensure that the common control DLL is loaded.
+ INITCOMMONCONTROLSEX icex;
+
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ TBBUTTON tbb [ ] =
+ {
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ // {VIEW_NEWFOLDER, kCreateFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ };
+
+ if (g_ComCtl32Version >= MAKELONG(71, 4))
+ {
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ _headerReBar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
+ REBARCLASSNAME,
+ NULL, WS_VISIBLE | WS_BORDER | WS_CHILD |
+ WS_CLIPCHILDREN | WS_CLIPSIBLINGS
+ | CCS_NODIVIDER
+ | CCS_NOPARENTALIGN
+ | CCS_TOP
+ | RBS_VARHEIGHT
+ | RBS_BANDBORDERS
+ ,0,0,0,0, HWND(*this), NULL, g_hInstance, NULL));
+ }
+
+ DWORD toolbarStyle = WS_CHILD | WS_VISIBLE ;
+ if (_headerReBar)
+ {
+ toolbarStyle |= 0
+ // | WS_CLIPCHILDREN
+ // | WS_CLIPSIBLINGS
+
+ | TBSTYLE_TOOLTIPS
+ | CCS_NODIVIDER
+ | CCS_NORESIZE
+ | TBSTYLE_FLAT
+ ;
+ }
+
+ _headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle,
+ _baseID + 2, 11,
+ (HINSTANCE)HINST_COMMCTRL,
+ IDB_VIEW_SMALL_COLOR,
+ (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
+ 0, 0, 0, 0, sizeof (TBBUTTON)));
+
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_USEREX_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
+ WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
+ 0, 0, 100, 520,
+ ((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
+ (HMENU)(UINT_PTR)(_comboBoxID),
+ g_hInstance, NULL);
+ _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
+ _headerComboBox.SetImageList(GetSysImageList(true));
+
+ _headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
+
+ /*
+ _headerComboBox.SetUserDataLongPtr(LONG_PTR(&_headerComboBox));
+ _headerComboBox._panel = this;
+ _headerComboBox._origWindowProc =
+ (WNDPROC)_headerComboBox.SetLongPtr(GWLP_WNDPROC,
+ LONG_PTR(ComboBoxSubclassProc));
+ */
+ _comboBoxEdit.Attach(_headerComboBox.GetEditControl());
+
+ // _comboBoxEdit.SendMessage(CCM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
+ _comboBoxEdit.SetUserDataLongPtr(LONG_PTR(&_comboBoxEdit));
+ _comboBoxEdit._panel = this;
+ #ifndef _UNICODE
+ if(g_IsNT)
+ _comboBoxEdit._origWindowProc =
+ (WNDPROC)_comboBoxEdit.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
+ else
+ #endif
+ _comboBoxEdit._origWindowProc =
+ (WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
+
+ if (_headerReBar)
+ {
+ REBARINFO rbi;
+ rbi.cbSize = sizeof(REBARINFO); // Required when using this struct.
+ rbi.fMask = 0;
+ rbi.himl = (HIMAGELIST)NULL;
+ _headerReBar.SetBarInfo(&rbi);
+
+ // Send the TB_BUTTONSTRUCTSIZE message, which is required for
+ // backward compatibility.
+ // _headerToolBar.SendMessage(TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
+ SIZE size;
+ _headerToolBar.GetMaxSize(&size);
+
+ REBARBANDINFO rbBand;
+ rbBand.cbSize = sizeof(REBARBANDINFO); // Required
+ rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
+ rbBand.fStyle = RBBS_NOGRIPPER;
+ rbBand.cxMinChild = size.cx;
+ rbBand.cyMinChild = size.cy;
+ rbBand.cyChild = size.cy;
+ rbBand.cx = size.cx;
+ rbBand.hwndChild = _headerToolBar;
+ _headerReBar.InsertBand(-1, &rbBand);
+
+ RECT rc;
+ ::GetWindowRect(_headerComboBox, &rc);
+ rbBand.cxMinChild = 30;
+ rbBand.cyMinChild = rc.bottom - rc.top;
+ rbBand.cx = 1000;
+ rbBand.hwndChild = _headerComboBox;
+ _headerReBar.InsertBand(-1, &rbBand);
+ // _headerReBar.MaximizeBand(1, false);
+ }
+
+ _statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
+ // _statusBar2.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID + 1);
+
+ int sizes[] = {150, 250, 350, -1};
+ _statusBar.SetParts(4, sizes);
+ // _statusBar2.SetParts(5, sizes);
+
+ /*
+ RECT rect;
+ GetClientRect(&rect);
+ OnSize(0, rect.right - rect.left, rect.top - rect.bottom);
+ */
+
+ SetTimer(kTimerID, kTimerElapse);
+
+ // InitListCtrl();
+ RefreshListCtrl();
+ RefreshStatusBar();
+
+ return true;
+}
+#else
+bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
+{
+ printf("WARNING CPanel::OnCreate\n");
+ _sortID = kpidName;
+ _ascending = true;
+ _lastFocusedIsList = true;
+
+ extern HWND g_HWND;
+ HWND w = GetDlgItem(g_HWND, _comboBoxID);
+ if (w == 0)
+ {
+ printf("Can't find id=%d\n",_comboBoxID);
+ return false;
+ }
+ printf("CPanel::OnCreate : _headerComboBox.Attach(%p)\n",w);
+ _headerComboBox.Attach(w);
+
+ w = GetDlgItem(g_HWND, _statusBarID);
+ if (w == 0)
+ {
+ printf("Can't find id=%d\n",_statusBarID);
+ return false;
+ }
+ printf("CPanel::OnCreate : _statusBar.Attach(%p)\n",w);
+ _statusBar.Attach(w);
+
+ w = GetDlgItem(g_HWND, _baseID + 1);
+ if (w == 0)
+ {
+ printf("Can't find id=%d\n",_baseID + 1);
+ return false;
+ }
+ printf("CPanel::OnCreate : _listView.Attach(%p)\n",w);
+ _listView.Attach(w);
+
+ _listView.SetUnicodeFormat(true);
+
+ // _listView.SetUserDataLongPtr(LONG_PTR(&_listView));
+ _listView._panel = this;
+
+ // FIXME _listView.SetImageList(GetSysImageList(true), LVSIL_SMALL);
+ // FIXME _listView.SetImageList(GetSysImageList(false), LVSIL_NORMAL);
+
+ // FIXME SetExtendedStyle();
+
+ // FIXME _listView.Show(SW_SHOW);
+ // FIXME _listView.InvalidateRect(NULL, true);
+ _listView.Update();
+
+ /* FIXME
+ _headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle,
+ _baseID + 2, 11,
+ (HINSTANCE)HINST_COMMCTRL,
+ IDB_VIEW_SMALL_COLOR,
+ (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
+ 0, 0, 0, 0, sizeof (TBBUTTON)));
+ */
+
+ /* FIXME
+ _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
+ WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
+ 0, 0, 100, 520,
+ ((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
+ (HMENU)(UINT_PTR)(_comboBoxID),
+ g_hInstance, NULL);
+ _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
+ _headerComboBox.SetImageList(GetSysImageList(true));
+
+ _headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
+ */
+
+ // FIXME _comboBoxEdit.Attach(_headerComboBox.GetEditControl());
+
+ _comboBoxEdit._panel = this;
+
+ // FIXME if (_headerReBar) ...
+
+ // _statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
+
+ // int sizes[] = {150, 250, 350, -1};
+ // _statusBar.SetParts(4, sizes);
+
+ // SetTimer(kTimerID, kTimerElapse);
+
+ // InitListCtrl();
+ RefreshListCtrl();
+ RefreshStatusBar();
+
+ return true;
+}
+#endif
+
+
+void CPanel::OnDestroy()
+{
+ printf("CPanel::OnDestroy\n");
+
+ SaveListViewInfo();
+ CWindow2::OnDestroy();
+}
+
+#ifdef _WIN32
+void CPanel::ChangeWindowSize(int xSize, int ySize)
+{
+ int kHeaderSize;
+ int kStatusBarSize;
+ // int kStatusBar2Size;
+ RECT rect;
+ if (_headerReBar)
+ _headerReBar.GetWindowRect(&rect);
+ else
+ _headerToolBar.GetWindowRect(&rect);
+
+ kHeaderSize = rect.bottom - rect.top;
+
+ _statusBar.GetWindowRect(&rect);
+ kStatusBarSize = rect.bottom - rect.top;
+
+ // _statusBar2.GetWindowRect(&rect);
+ // kStatusBar2Size = rect.bottom - rect.top;
+
+ int yListViewSize = MyMax(ySize - kHeaderSize - kStatusBarSize, 0);
+ const int kStartXPos = 32;
+ if (_headerReBar)
+ {
+ }
+ else
+ {
+ _headerToolBar.Move(0, 0, xSize, 0);
+ _headerComboBox.Move(kStartXPos, 2,
+ MyMax(xSize - kStartXPos - 10, kStartXPos), 0);
+ }
+ _listView.Move(0, kHeaderSize, xSize, yListViewSize);
+ _statusBar.Move(0, kHeaderSize + yListViewSize, xSize, kStatusBarSize);
+ // _statusBar2.MoveWindow(0, kHeaderSize + yListViewSize + kStatusBarSize, xSize, kStatusBar2Size);
+ // _statusBar.MoveWindow(0, 100, xSize, kStatusBarSize);
+ // _statusBar2.MoveWindow(0, 200, xSize, kStatusBar2Size);
+}
+
+bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
+{
+ if (_headerReBar)
+ _headerReBar.Move(0, 0, xSize, 0);
+ ChangeWindowSize(xSize, ySize);
+ return true;
+}
+
+bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */)
+{
+ switch(header->code)
+ {
+ case RBN_HEIGHTCHANGE:
+ {
+ RECT rect;
+ GetWindowRect(&rect);
+ ChangeWindowSize(rect.right - rect.left, rect.bottom - rect.top);
+ return false;
+ }
+ }
+ return false;
+}
+#endif
+
+bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
+{
+ if (!_processNotify)
+ return false;
+#ifdef _WIN32
+ if (header->hwndFrom == _headerComboBox)
+ return OnNotifyComboBox(header, result);
+ else if (header->hwndFrom == _headerReBar)
+ return OnNotifyReBar(header, result);
+ // if (header->hwndFrom == _listView)
+#endif
+ else if (header->hwndFrom == _listView)
+ return OnNotifyList(header, result);
+#ifdef _WIN32
+ else if (::GetParent(header->hwndFrom) == _listView &&
+ header->code == NM_RCLICK)
+ return OnRightClick((LPNMITEMACTIVATE)header, result);
+#endif
+ return false;
+}
+
+bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result)
+{
+ printf("CPanel::OnCommand(code=%d,itemID=%d)\n",code,itemID);
+ if (itemID == kParentFolderID)
+ {
+ OpenParentFolder();
+ result = 0;
+ return true;
+ }
+ /*
+ if (itemID == kCreateFolderID)
+ {
+ CreateFolder();
+ result = 0;
+ return true;
+ }
+ */
+ if (itemID == _comboBoxID)
+ {
+ // FIXME if (OnComboBoxCommand(code, lParam, result))
+ return true;
+ }
+ return CWindow2::OnCommand(code, itemID, lParam, result);
+}
+
+void CPanel::MessageBoxInfo(LPCWSTR message, LPCWSTR caption)
+ { ::MessageBoxW(HWND(*this), message, caption, MB_OK); }
+void CPanel::MessageBox(LPCWSTR message, LPCWSTR caption)
+ { ::MessageBoxW(HWND(*this), message, caption, MB_OK | MB_ICONSTOP); }
+void CPanel::MessageBox(LPCWSTR message)
+ { MessageBox(message, L"7-Zip"); }
+void CPanel::MessageBoxMyError(LPCWSTR message)
+ { MessageBox(message, L"Error"); }
+void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption)
+{
+ UString message;
+ if (errorCode == E_OUTOFMEMORY)
+ message = LangString(IDS_MEM_ERROR, 0x0200060B);
+ else
+ if (!NError::MyFormatMessage(errorCode, message))
+ message = L"Error";
+ MessageBox(message, caption);
+}
+
+void CPanel::MessageBoxError(HRESULT errorCode)
+ { MessageBoxError(errorCode, L"7-Zip"); }
+void CPanel::MessageBoxLastError(LPCWSTR caption)
+ { MessageBoxError(::GetLastError(), caption); }
+void CPanel::MessageBoxLastError()
+ { MessageBoxLastError(L"Error"); }
+
+void CPanel::MessageBoxErrorLang(UINT resourceID, UInt32 langID)
+ { MessageBox(LangString(resourceID, langID)); }
+
+
+void CPanel::SetFocusToList()
+{
+ _listView.SetFocus();
+ // SetCurrentPathText();
+}
+
+void CPanel::SetFocusToLastRememberedItem()
+{
+ if (_lastFocusedIsList)
+ SetFocusToList();
+#ifdef _WIN32 // FIXME
+ else
+ _headerComboBox.SetFocus();
+#endif
+}
+
+UString CPanel::GetFolderTypeID() const
+{
+ NCOM::CPropVariant prop;
+ if (_folder->GetFolderProperty(kpidType, &prop) == S_OK)
+ if (prop.vt == VT_BSTR)
+ return (const wchar_t *)prop.bstrVal;
+ return L"";
+}
+
+bool CPanel::IsRootFolder() const
+{
+ return (GetFolderTypeID() == L"RootFolder");
+}
+
+bool CPanel::IsFSFolder() const
+{
+ return (GetFolderTypeID() == L"FSFolder");
+}
+
+bool CPanel::IsFSDrivesFolder() const
+{
+ return (GetFolderTypeID() == L"FSDrives");
+}
+
+UString CPanel::GetFsPath() const
+{
+ if (IsFSDrivesFolder())
+ return UString();
+ return _currentFolderPrefix;
+}
+
+UString CPanel::GetDriveOrNetworkPrefix() const
+{
+ if (!IsFSFolder())
+ return UString();
+ UString drive = GetFsPath();
+ if (drive.Length() < 3)
+ return UString();
+ if (drive[0] == L'\\' && drive[1] == L'\\')
+ {
+ // if network
+ int pos = drive.Find(L'\\', 2);
+ if (pos < 0)
+ return UString();
+ pos = drive.Find(L'\\', pos + 1);
+ if (pos < 0)
+ return UString();
+ return drive.Left(pos + 1);
+ }
+ if (drive[1] != L':' || drive[2] != L'\\')
+ return UString();
+ return drive.Left(3);
+}
+
+bool CPanel::DoesItSupportOperations() const
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ return _folder.QueryInterface(IID_IFolderOperations, &folderOperations) == S_OK;
+}
+
+void CPanel::SetListViewMode(UInt32 index)
+{
+#ifdef _WIN32 // FIXME
+ if (index >= 4)
+ return;
+ _ListViewMode = index;
+ DWORD oldStyle = (DWORD)_listView.GetStyle();
+ DWORD newStyle = kStyles[index];
+ if ((oldStyle & LVS_TYPEMASK) != newStyle)
+ _listView.SetStyle((oldStyle & ~LVS_TYPEMASK) | newStyle);
+ // RefreshListCtrlSaveFocused();
+#endif
+}
+
+void CPanel::ChangeFlatMode()
+{
+ _flatMode = !_flatMode;
+ RefreshListCtrlSaveFocused();
+}
+
+
+void CPanel::RefreshStatusBar()
+{
+ // FIXME PostMessage(kRefreshStatusBar);
+}
+
+void CPanel::AddToArchive()
+{
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ if (!IsFSFolder())
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ if (indices.Size() == 0)
+ {
+ MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03);
+ return;
+ }
+ UStringVector names;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ int index = indices[i];
+ names.Add(_currentFolderPrefix + GetItemRelPath(index));
+ }
+ const UString archiveName = CreateArchiveName(
+ names.Front(), (names.Size() > 1), false);
+ HRESULT res = CompressFiles(_currentFolderPrefix, archiveName, L"", names, false, true, false);
+ if (res != S_OK)
+ {
+ if (_currentFolderPrefix.Length() >= MAX_PATH)
+ MessageBoxErrorLang(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER, 0x03020A01);
+ else
+ MessageBoxError(res);
+ }
+ // KillSelection();
+}
+
+static UString GetSubFolderNameForExtract(const UString &archiveName)
+{
+ int slashPos = archiveName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ int dotPos = archiveName.ReverseFind(L'.');
+ if (dotPos < 0 || slashPos > dotPos)
+ return archiveName + UString(L"~");
+ UString res = archiveName.Left(dotPos);
+ res.TrimRight();
+ return res;
+}
+
+void CPanel::GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths)
+{
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ int index = indices[i];
+ if (IsItemFolder(index))
+ {
+ paths.Clear();
+ break;
+ }
+ paths.Add(_currentFolderPrefix + GetItemRelPath(index));
+ }
+ if (paths.Size() == 0)
+ {
+ MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03);
+ return;
+ }
+}
+
+void CPanel::ExtractArchives()
+{
+ if (_parentFolders.Size() > 0)
+ {
+ _panelCallback->OnCopy(false, false);
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ UStringVector paths;
+ GetFilePaths(indices, paths);
+ if (paths.IsEmpty())
+ return;
+ UString folderName;
+ if (indices.Size() == 1)
+ folderName = GetSubFolderNameForExtract(GetItemRelPath(indices[0]));
+ else
+ folderName = L"*";
+ ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(WSTRING_PATH_SEPARATOR), true);
+}
+
+struct CThreadTest
+{
+ CRecordVector<UInt32> Indices;
+ CExtractCallbackImp *ExtractCallbackSpec;
+ CMyComPtr<IFolderArchiveExtractCallback> ExtractCallback;
+ CMyComPtr<IArchiveFolder> ArchiveFolder;
+ HRESULT Result;
+
+ void Test()
+ {
+ ExtractCallbackSpec->ProgressDialog.WaitCreating();
+ Result = ArchiveFolder->Extract(&Indices[0], Indices.Size(),
+ NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore,
+ NULL, BoolToInt(true), ExtractCallback);
+ ExtractCallbackSpec->ProgressDialog.MyClose();
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadTest*)param)->Test();
+ return 0;
+ }
+};
+
+static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s)
+{
+ wchar_t sz[32];
+ s += LangString(resourceID, langID);
+ s += L" ";
+ ConvertUInt64ToString(value, sz);
+ s += sz;
+ s += L"\n";
+}
+
+/*
+static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s)
+{
+ wchar_t sz[32];
+ s += LangString(resourceID, langID);
+ s += L" ";
+ ConvertUInt64ToString(value, sz);
+ s += sz;
+ ConvertUInt64ToString(value >> 20, sz);
+ s += L" (";
+ s += sz;
+ s += L" MB)";
+ s += L"\n";
+}
+*/
+
+void CPanel::TestArchives()
+{
+ CRecordVector<UInt32> indices;
+ GetOperatedIndicesSmart(indices);
+ CMyComPtr<IArchiveFolder> archiveFolder;
+ _folder.QueryInterface(IID_IArchiveFolder, &archiveFolder);
+ if (archiveFolder)
+ {
+ {
+ CThreadTest extracter;
+
+ extracter.ArchiveFolder = archiveFolder;
+ extracter.ExtractCallbackSpec = new CExtractCallbackImp;
+ extracter.ExtractCallback = extracter.ExtractCallbackSpec;
+ extracter.ExtractCallbackSpec->ParentWindow = GetParent();
+ extracter.ExtractCallbackSpec->ShowMessages = true;
+
+ if (indices.IsEmpty())
+ return;
+
+ extracter.Indices = indices;
+
+ UString title = LangString(IDS_PROGRESS_TESTING, 0x02000F90);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+
+ extracter.ExtractCallbackSpec->ProgressDialog.CompressingMode = false;
+ extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent();
+ extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
+ extracter.ExtractCallbackSpec->ProgressDialog.MainAddTitle = title + L" ";
+
+ extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
+ extracter.ExtractCallbackSpec->Init();
+
+ NWindows::CThread extractThread;
+ if (extractThread.Create(CThreadTest::MyThreadFunction, &extracter) != S_OK)
+ return;
+ extracter.ExtractCallbackSpec->StartProgressDialog(title);
+
+ if (extracter.ExtractCallbackSpec->Messages.IsEmpty() && extracter.Result == S_OK)
+ {
+ UString s;
+ AddValuePair(IDS_FOLDERS_COLON, 0x02000321, extracter.ExtractCallbackSpec->NumFolders, s);
+ AddValuePair(IDS_FILES_COLON, 0x02000320, extracter.ExtractCallbackSpec->NumFiles, s);
+ // AddSizePair(IDS_SIZE_COLON, 0x02000322, extracter.Stat.UnpackSize, s);
+ // AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, extracter.Stat.PackSize, s);
+ s += L"\n";
+ s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608);
+ MessageBoxInfo(s, LangString(IDS_PROGRESS_TESTING, 0x02000F90));
+ }
+ else
+ {
+ if (extracter.Result != S_OK && extracter.Result != E_ABORT)
+ MessageBoxError(extracter.Result, L"Testing Error");
+ }
+ }
+ RefreshTitleAlways();
+ return;
+ }
+
+ if (!IsFSFolder())
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ UStringVector paths;
+ GetFilePaths(indices, paths);
+ if (paths.IsEmpty())
+ return;
+ ::TestArchives(paths);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/Panel.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/Panel.h
new file mode 100644
index 000000000..dff858f87
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/Panel.h
@@ -0,0 +1,577 @@
+// Panel.h
+
+#ifndef __PANEL_H
+#define __PANEL_H
+
+#include "Common/MyCom.h"
+
+#include "Windows/DLL.h"
+#include "Windows/FileFind.h"
+#include "Windows/FileDir.h"
+#include "Windows/Synchronization.h"
+// #include "Windows/Handle.h"
+
+// #include "Windows/Control/ToolBar.h"
+// #include "Windows/Control/ReBar.h"
+#include "Windows/Control/ListView.h"
+#include "Windows/Control/Static.h"
+#include "Windows/Control/Edit.h"
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Control/Window2.h"
+#include "Windows/Control/StatusBar.h"
+
+#include "SysIconUtils.h"
+#include "IFolder.h"
+#include "ViewSettings.h"
+#include "AppState.h"
+// #include "MyCom2.h"
+
+const int kParentFolderID = 100;
+const int kPluginMenuStartID = 1000;
+const int kToolbarStartID = 2000;
+
+const int kParentIndex = -1;
+
+struct CPanelCallback
+{
+ virtual void OnTab() = 0;
+ virtual void SetFocusToPath(int index) = 0;
+ virtual void OnCopy(bool move, bool copyToSame) = 0;
+ virtual void OnSetSameFolder() = 0;
+ virtual void OnSetSubFolder() = 0;
+ virtual void PanelWasFocused() = 0;
+ virtual void DragBegin() = 0;
+ virtual void DragEnd() = 0;
+ virtual void RefreshTitle(bool always) = 0;
+};
+
+void PanelCopyItems();
+
+struct CItemProperty
+{
+ UString Name;
+ PROPID ID;
+ VARTYPE Type;
+ int Order;
+ bool IsVisible;
+ UInt32 Width;
+};
+
+inline bool operator<(const CItemProperty &a1, const CItemProperty &a2)
+ { return (a1.Order < a2.Order); }
+
+inline bool operator==(const CItemProperty &a1, const CItemProperty &a2)
+ { return (a1.Order == a2.Order); }
+
+class CItemProperties: public CObjectVector<CItemProperty>
+{
+public:
+ int FindItemWithID(PROPID id)
+ {
+ for (int i = 0; i < Size(); i++)
+ if ((*this)[i].ID == id)
+ return i;
+ return -1;
+ }
+};
+
+struct CTempFileInfo
+{
+ UString ItemName;
+ UString FolderPath;
+ UString FilePath;
+ NWindows::NFile::NFind::CFileInfoW FileInfo;
+ bool NeedDelete;
+
+ CTempFileInfo(): NeedDelete(false) {}
+ void DeleteDirAndFile() const
+ {
+ if (NeedDelete)
+ {
+ NWindows::NFile::NDirectory::DeleteFileAlways(FilePath);
+ NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath);
+ }
+ }
+ bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
+ {
+ return newFileInfo.Size != FileInfo.Size ||
+ CompareFileTime(&newFileInfo.MTime, &FileInfo.MTime) != 0;
+ }
+};
+
+struct CFolderLink: public CTempFileInfo
+{
+ NWindows::NDLL::CLibrary Library;
+ CMyComPtr<IFolderFolder> ParentFolder;
+ bool UsePassword;
+ UString Password;
+ bool IsVirtual;
+
+ UString VirtualPath;
+ CFolderLink(): UsePassword(false), IsVirtual(false) {}
+
+ bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
+ {
+ return IsVirtual || CTempFileInfo::WasChanged(newFileInfo);
+ }
+
+};
+
+enum MyMessages
+{
+ kShiftSelectMessage = 20000, // FIXME = WM_USER + 1,
+ kReLoadMessage,
+ kSetFocusToListView,
+ kOpenItemChanged,
+ kRefreshStatusBar
+};
+
+UString GetFolderPath(IFolderFolder * folder);
+
+class CPanel;
+
+class CMyListView: public NWindows::NControl::CListView
+{
+public:
+ WNDPROC _origWindowProc;
+ CPanel *_panel;
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+};
+
+/*
+class CMyComboBox: public NWindows::NControl::CComboBoxEx
+{
+public:
+ WNDPROC _origWindowProc;
+ CPanel *_panel;
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+};
+*/
+class CMyComboBoxEdit: public NWindows::NControl::CEdit
+{
+public:
+ WNDPROC _origWindowProc;
+ CPanel *_panel;
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+};
+
+struct CSelectedState
+{
+ int FocusedItem;
+ UString FocusedName;
+ bool SelectFocused;
+ UStringVector SelectedNames;
+ CSelectedState(): FocusedItem(-1), SelectFocused(false) {}
+};
+
+class CPanel :public NWindows::NControl::CWindow2
+{
+ // FIXME CExtToIconMap _extToIconMap;
+ UINT _baseID;
+ int _comboBoxID;
+ UINT _statusBarID;
+
+ CAppState *_appState;
+
+ bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result);
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual bool OnCreate(CREATESTRUCT *createStruct);
+ // FIXME virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
+ virtual void OnDestroy();
+ virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result);
+ void OnComboBoxCommand(UINT code, LPARAM &aParam);
+ // FIXME bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
+ #ifndef _UNICODE
+ bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
+ #endif
+ // FIXME bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result);
+ // FIXME bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result);
+ void OnItemChanged(NMLISTVIEW *item);
+ bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
+ // FIXME void OnDrag(LPNMLISTVIEW nmListView);
+ // FIXME bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
+ // FIXME BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
+ // FIXME BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
+ void OnColumnClick(LPNMLISTVIEW info);
+ // FIXME bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
+
+public:
+ HWND _mainWindow;
+ CPanelCallback *_panelCallback;
+
+/* FIXME BEGIN */
+ HWND GetParent() { return 0; }
+ operator HWND() const { return 0; }
+/* FIXME END */
+
+ void DeleteItems(bool toRecycleBin);
+ void DeleteItemsInternal(CRecordVector<UInt32> &indices);
+ void CreateFolder();
+ void CreateFile();
+
+private:
+
+ void ChangeWindowSize(int xSize, int ySize);
+
+ void InitColumns();
+ // void InitColumns2(PROPID sortID);
+ void InsertColumn(int index);
+
+ void SetFocusedSelectedItem(int index, bool select);
+ void RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
+ const UStringVector &selectedNames);
+
+ void OnShiftSelectMessage();
+ void OnArrowWithShift();
+
+ void OnInsert();
+ // void OnUpWithShift();
+ // void OnDownWithShift();
+public:
+ void myTests();
+ void UpdateSelection();
+ void SelectSpec(bool selectMode);
+ void SelectByType(bool selectMode);
+ void SelectAll(bool selectMode);
+ void InvertSelection();
+private:
+
+ // UString GetFileType(UInt32 index);
+ LRESULT SetItemText(LVITEMW &item);
+
+ // CRecordVector<PROPID> m_ColumnsPropIDs;
+
+public:
+ // FIXME NWindows::NControl::CReBar _headerReBar;
+ // FIXME NWindows::NControl::CToolBar _headerToolBar;
+ NWindows::NControl::CComboBoxEx _headerComboBox;
+ // CMyComboBox _headerComboBox;
+ CMyComboBoxEdit _comboBoxEdit;
+ CMyListView _listView;
+ NWindows::NControl::CStatusBar _statusBar;
+ bool _lastFocusedIsList;
+ // NWindows::NControl::CStatusBar _statusBar2;
+
+ DWORD _exStyle;
+ bool _showDots;
+ bool _showRealFileIcons;
+ // bool _virtualMode;
+ // CUIntVector _realIndices;
+ bool _enableItemChangeNotify;
+ bool _mySelectMode;
+ CBoolVector _selectedStatusVector;
+
+ CSelectedState _selectedState;
+
+ UInt32 GetRealIndex(const LVITEMW &item) const
+ {
+ /*
+ if (_virtualMode)
+ return _realIndices[item.iItem];
+ */
+ return (UInt32)item.lParam;
+ }
+ int GetRealItemIndex(int indexInListView) const
+ {
+ /*
+ if (_virtualMode)
+ return indexInListView;
+ */
+ LPARAM param;
+ if (!_listView.GetItemParam(indexInListView, param))
+ throw 1;
+ return (int)param;
+ }
+
+ UInt32 _ListViewMode;
+ int _xSize;
+
+ bool _flatMode;
+ bool _flatModeForDisk;
+ bool _flatModeForArc;
+
+ bool _dontShowMode;
+
+
+ UString _currentFolderPrefix;
+
+ CObjectVector<CFolderLink> _parentFolders;
+ NWindows::NDLL::CLibrary _library;
+ CMyComPtr<IFolderFolder> _folder;
+ // CMyComPtr<IFolderGetSystemIconIndex> _folderGetSystemIconIndex;
+
+ UStringVector _fastFolders;
+
+ void GetSelectedNames(UStringVector &selectedNames);
+ void SaveSelectedState(CSelectedState &s);
+ void RefreshListCtrl(const CSelectedState &s);
+ void RefreshListCtrlSaveFocused();
+
+ UString GetItemName(int itemIndex) const;
+ UString GetItemPrefix(int itemIndex) const;
+ UString GetItemRelPath(int itemIndex) const;
+ bool IsItemFolder(int itemIndex) const;
+ UInt64 GetItemSize(int itemIndex) const;
+
+ ////////////////////////
+ // PanelFolderChange.cpp
+
+ void SetToRootFolder();
+ HRESULT BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted); // can be prefix
+ HRESULT BindToPathAndRefresh(const UString &path);
+ void OpenDrivesFolder();
+
+ void SetBookmark(int index);
+ void OpenBookmark(int index);
+
+ void LoadFullPath();
+ void LoadFullPathAndShow();
+ void FoldersHistory();
+ void OpenParentFolder();
+ void CloseOpenFolders();
+ void OpenRootFolder();
+
+
+ HRESULT Create(HWND mainWindow, HWND parentWindow,
+ UINT id,
+ const UString &currentFolderPrefix,
+ CPanelCallback *panelCallback,
+ CAppState *appState, bool &archiveIsOpened, bool &encrypted);
+ void SetFocusToList();
+ void SetFocusToLastRememberedItem();
+
+
+ void ReadListViewInfo();
+ void SaveListViewInfo();
+
+ CPanel() :
+ // _virtualMode(flase),
+ _exStyle(0),
+ _showDots(false),
+ _showRealFileIcons(false),
+ _needSaveInfo(false),
+ _startGroupSelect(0),
+ _selectionIsDefined(false),
+ _ListViewMode(3),
+ _flatMode(false),
+ _flatModeForDisk(false),
+ _flatModeForArc(false),
+ _xSize(300),
+ _mySelectMode(false),
+ _enableItemChangeNotify(true),
+ _dontShowMode(false)
+ {}
+
+
+ void SetExtendedStyle()
+ {
+/* FIXME
+ if (_listView != 0)
+ _listView.SetExtendedListViewStyle(_exStyle);
+ */
+ }
+
+
+ bool _needSaveInfo;
+ UString _typeIDString;
+ CListViewInfo _listViewInfo;
+ CItemProperties _properties;
+ CItemProperties _visibleProperties;
+
+ PROPID _sortID;
+ // int _sortIndex;
+ bool _ascending;
+
+ void Release();
+ ~CPanel();
+ // FIXME void OnLeftClick(LPNMITEMACTIVATE itemActivate);
+ // FIXME bool OnRightClick(LPNMITEMACTIVATE itemActivate, LRESULT &result);
+
+ void OnTimer();
+ void OnReload();
+ bool OnContextMenu(HANDLE windowHandle, int xPos, int yPos);
+
+#ifdef _WIN32
+ CMyComPtr<IContextMenu> _sevenZipContextMenu;
+ CMyComPtr<IContextMenu> _systemContextMenu;
+ HRESULT CreateShellContextMenu(
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu);
+ void CreateSystemMenu(HMENU menu,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu);
+ void CreateSevenZipMenu(HMENU menu,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &sevenZipContextMenu);
+ void CreateFileMenu(HMENU menu,
+ CMyComPtr<IContextMenu> &sevenZipContextMenu,
+ CMyComPtr<IContextMenu> &systemContextMenu,
+ bool programMenu);
+ void CreateFileMenu(HMENU menu);
+ bool InvokePluginCommand(int id);
+ bool InvokePluginCommand(int id, IContextMenu *sevenZipContextMenu,
+ IContextMenu *systemContextMenu);
+#endif // ifdef _WIN32
+
+ void InvokeSystemCommand(const char *command);
+ void Properties();
+ void EditCut();
+ void EditCopy();
+ void EditPaste();
+
+ int _startGroupSelect;
+
+ bool _selectionIsDefined;
+ bool _selectMark;
+ int _prevFocusedItem;
+
+
+ // void SortItems(int index);
+ void SortItemsWithPropID(PROPID propID);
+
+ void GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const;
+ void GetOperatedItemIndices(CRecordVector<UInt32> &indices) const;
+ void GetAllItemIndices(CRecordVector<UInt32> &indices) const;
+ void GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const;
+ // void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const;
+ void KillSelection();
+
+ UString GetFolderTypeID() const;
+ bool IsRootFolder() const;
+ bool IsFSFolder() const;
+ bool IsFSDrivesFolder() const;
+
+ UString GetFsPath() const;
+ UString GetDriveOrNetworkPrefix() const;
+
+ bool DoesItSupportOperations() const;
+
+ bool _processTimer;
+ bool _processNotify;
+
+ class CDisableTimerProcessing
+ {
+ bool _processTimerMem;
+ bool _processNotifyMem;
+
+ CPanel &_panel;
+ public:
+
+ CDisableTimerProcessing(CPanel &panel): _panel(panel)
+ {
+ Disable();
+ }
+ void Disable()
+ {
+ _processTimerMem = _panel._processTimer;
+ _processNotifyMem = _panel._processNotify;
+ _panel._processTimer = false;
+ _panel._processNotify = false;
+ }
+ void Restore()
+ {
+ _panel._processTimer = _processTimerMem;
+ _panel._processNotify = _processNotifyMem;
+ }
+ ~CDisableTimerProcessing()
+ {
+ Restore();
+ }
+ CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
+ };
+
+ // bool _passwordIsDefined;
+ // UString _password;
+
+ void RefreshListCtrl();
+
+ void MessageBoxInfo(LPCWSTR message, LPCWSTR caption);
+ void MessageBox(LPCWSTR message);
+ void MessageBox(LPCWSTR message, LPCWSTR caption);
+ void MessageBoxMyError(LPCWSTR message);
+ void MessageBoxError(HRESULT errorCode, LPCWSTR caption);
+ void MessageBoxError(HRESULT errorCode);
+ void MessageBoxLastError(LPCWSTR caption);
+ void MessageBoxLastError();
+
+ void MessageBoxErrorLang(UINT resourceID, UInt32 langID);
+
+ void OpenFocusedItemAsInternal();
+ void OpenSelectedItems(bool internal);
+
+ void OpenFolderExternal(int index);
+
+ void OpenFolder(int index);
+ HRESULT OpenParentArchiveFolder();
+ HRESULT OpenItemAsArchive(IInStream *inStream,
+ const CTempFileInfo &tempFileInfo,
+ const UString &virtualFilePath,
+ bool &encrypted);
+ HRESULT OpenItemAsArchive(const UString &name, bool &encrypted);
+ HRESULT OpenItemAsArchive(int index);
+ void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
+ bool editMode);
+ HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password);
+ LRESULT OnOpenItemChanged(LPARAM lParam);
+
+ void OpenItem(int index, bool tryInternal, bool tryExternal);
+ void EditItem();
+ void EditItem(int index);
+
+ void RenameFile();
+ void ChangeComment();
+
+ void SetListViewMode(UInt32 index);
+ UInt32 GetListViewMode() const { return _ListViewMode; };
+
+ void ChangeFlatMode();
+ bool GetFlatMode() const { return _flatMode; };
+
+ void RefreshStatusBar();
+ void OnRefreshStatusBar();
+
+ void AddToArchive();
+
+ void GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths);
+ void ExtractArchives();
+ void TestArchives();
+
+ HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages,
+ bool &usePassword, UString &password);
+
+ HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages)
+ {
+ bool usePassword = false;
+ UString password;
+ if (_parentFolders.Size() > 0)
+ {
+ const CFolderLink &fl = _parentFolders.Back();
+ usePassword = fl.UsePassword;
+ password = fl.Password;
+ }
+ return CopyTo(indices, folder, moveMode, showErrorMessages, messages, usePassword, password);
+ }
+
+ HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
+ bool showErrorMessages, UStringVector *messages);
+
+ void CopyFromNoAsk(const UStringVector &filePaths);
+ void CopyFromAsk(const UStringVector &filePaths);
+
+ // empty folderPath means create new Archive to path of first fileName.
+ #ifdef _WIN32
+ void DropObject(IDataObject * dataObject, const UString &folderPath);
+
+ // empty folderPath means create new Archive to path of first fileName.
+ void CompressDropFiles(const UStringVector &fileNames, const UString &folderPath);
+#endif
+
+ void RefreshTitle(bool always = false) { _panelCallback->RefreshTitle(always); }
+ void RefreshTitleAlways() { RefreshTitle(true); }
+
+ UString GetItemsInfoString(const CRecordVector<UInt32> &indices);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelCopy.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelCopy.cpp
new file mode 100644
index 000000000..8ad3d4c91
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelCopy.cpp
@@ -0,0 +1,228 @@
+// PanelExtract.cpp
+
+#include "StdAfx.h"
+
+#include "Panel.h"
+#include "resource.h"
+#include "LangUtils.h"
+#include "ExtractCallback.h"
+#include "Windows/Thread.h"
+////////////////////////////////////////////////////////////////
+
+#include "UpdateCallback100.h"
+
+using namespace NWindows;
+
+struct CThreadExtractInArchive2
+{
+ CMyComPtr<IFolderOperations> FolderOperations;
+ CRecordVector<UInt32> Indices;
+ UString DestPath;
+ CExtractCallbackImp *ExtractCallbackSpec;
+ CMyComPtr<IFolderOperationsExtractCallback> ExtractCallback;
+ HRESULT Result;
+ bool MoveMode;
+
+ CThreadExtractInArchive2(): MoveMode(false) {}
+
+ DWORD Extract()
+ {
+ ExtractCallbackSpec->ProgressDialog.WaitCreating();
+ if (MoveMode)
+ Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(),
+ DestPath, ExtractCallback);
+ else
+ Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(),
+ DestPath, ExtractCallback);
+ ExtractCallbackSpec->ProgressDialog.MyClose();
+ return 0;
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ return ((CThreadExtractInArchive2 *)param)->Extract();
+ }
+};
+
+HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages,
+ bool &usePassword, UString &password)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ if (showErrorMessages)
+ MessageBox(errorMessage);
+ else if (messages != 0)
+ messages->Add(errorMessage);
+ return E_FAIL;
+ }
+
+ HRESULT res;
+ {
+ CThreadExtractInArchive2 extracter;
+
+ extracter.ExtractCallbackSpec = new CExtractCallbackImp;
+ extracter.ExtractCallback = extracter.ExtractCallbackSpec;
+ extracter.ExtractCallbackSpec->ParentWindow = GetParent();
+ extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages;
+ extracter.ExtractCallbackSpec->ProgressDialog.CompressingMode = false;
+
+ UString title = moveMode ?
+ LangString(IDS_MOVING, 0x03020206):
+ LangString(IDS_COPYING, 0x03020205);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+
+ extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent();
+ extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
+ extracter.ExtractCallbackSpec->ProgressDialog.MainAddTitle = title + L" ";
+
+ extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
+ extracter.ExtractCallbackSpec->Init();
+ extracter.Indices = indices;
+ extracter.DestPath = folder;
+ extracter.FolderOperations = folderOperations;
+ extracter.MoveMode = moveMode;
+
+ extracter.ExtractCallbackSpec->PasswordIsDefined = usePassword;
+ extracter.ExtractCallbackSpec->Password = password;
+
+ NWindows::CThread extractThread;
+ RINOK(extractThread.Create(CThreadExtractInArchive2::MyThreadFunction, &extracter));
+ extracter.ExtractCallbackSpec->StartProgressDialog(title);
+
+ if (messages != 0)
+ *messages = extracter.ExtractCallbackSpec->Messages;
+ res = extracter.Result;
+
+ if (res == S_OK && extracter.ExtractCallbackSpec->Messages.IsEmpty())
+ {
+ usePassword = extracter.ExtractCallbackSpec->PasswordIsDefined;
+ password = extracter.ExtractCallbackSpec->Password;
+ }
+ }
+ RefreshTitleAlways();
+ return res;
+}
+
+
+struct CThreadUpdate
+{
+ CMyComPtr<IFolderOperations> FolderOperations;
+ UString FolderPrefix;
+ UStringVector FileNames;
+ CRecordVector<const wchar_t *> FileNamePointers;
+ CMyComPtr<IFolderArchiveUpdateCallback> UpdateCallback;
+ CUpdateCallback100Imp *UpdateCallbackSpec;
+ HRESULT Result;
+
+ DWORD Process()
+ {
+ UpdateCallbackSpec->ProgressDialog.WaitCreating();
+ Result = FolderOperations->CopyFrom(
+ FolderPrefix,
+ &FileNamePointers.Front(),
+ FileNamePointers.Size(),
+ UpdateCallback);
+ UpdateCallbackSpec->ProgressDialog.MyClose();
+ return 0;
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ return ((CThreadUpdate *)param)->Process();
+ }
+};
+
+
+HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
+ bool showErrorMessages, UStringVector *messages)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ if (showErrorMessages)
+ MessageBox(errorMessage);
+ else if (messages != 0)
+ messages->Add(errorMessage);
+ return E_FAIL;
+ }
+
+ HRESULT res;
+ {
+ CThreadUpdate updater;
+ updater.UpdateCallbackSpec = new CUpdateCallback100Imp;
+ updater.UpdateCallback = updater.UpdateCallbackSpec;
+
+ UString title = LangString(IDS_COPYING, 0x03020205);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+
+ updater.UpdateCallbackSpec->ProgressDialog.MainWindow = GetParent();
+ updater.UpdateCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
+ updater.UpdateCallbackSpec->ProgressDialog.MainAddTitle = title + UString(L" ");
+
+ updater.UpdateCallbackSpec->Init((HWND)*this, false, L"");
+ updater.FolderOperations = folderOperations;
+ updater.FolderPrefix = folderPrefix;
+ updater.FileNames.Reserve(filePaths.Size());
+ int i;
+ for(i = 0; i < filePaths.Size(); i++)
+ updater.FileNames.Add(filePaths[i]);
+ updater.FileNamePointers.Reserve(updater.FileNames.Size());
+ for(i = 0; i < updater.FileNames.Size(); i++)
+ updater.FileNamePointers.Add(updater.FileNames[i]);
+
+ NWindows::CThread thread;
+ RINOK(thread.Create(CThreadUpdate::MyThreadFunction, &updater));
+ updater.UpdateCallbackSpec->StartProgressDialog(title);
+
+ if (messages != 0)
+ *messages = updater.UpdateCallbackSpec->Messages;
+
+ res = updater.Result;
+ }
+ RefreshTitleAlways();
+ return res;
+}
+
+void CPanel::CopyFromNoAsk(const UStringVector &filePaths)
+{
+ CDisableTimerProcessing disableTimerProcessing(*this);
+
+ CSelectedState srcSelState;
+ SaveSelectedState(srcSelState);
+
+ HRESULT result = CopyFrom(L"", filePaths, true, 0);
+
+ if (result != S_OK)
+ {
+ disableTimerProcessing.Restore();
+ // For Password:
+ SetFocusToList();
+ if (result != E_ABORT)
+ MessageBoxError(result);
+ return;
+ }
+
+ RefreshListCtrl(srcSelState);
+
+ disableTimerProcessing.Restore();
+ SetFocusToList();
+}
+
+void CPanel::CopyFromAsk(const UStringVector &filePaths)
+{
+ UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222);
+ UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223);
+ message += L"\n\'";
+ message += _currentFolderPrefix;
+ message += L"\' ?";
+ int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION | MB_SYSTEMMODAL);
+ if (res != IDYES)
+ return;
+
+ CopyFromNoAsk(filePaths);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelCrc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelCrc.cpp
new file mode 100644
index 000000000..61490b578
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelCrc.cpp
@@ -0,0 +1,368 @@
+// PanelSplitFile.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+extern "C"
+{
+ #include "../../../../C/Alloc.h"
+ #include "../../../../C/7zCrc.h"
+}
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/FileIO.h"
+#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
+#include "Windows/Thread.h"
+#include "Windows/Error.h"
+
+#include "ProgressDialog2.h"
+#include "OverwriteDialogRes.h"
+
+#include "App.h"
+#include "FormatUtils.h"
+#include "LangUtils.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NName;
+
+static const UInt32 kBufSize = (1 << 15);
+
+struct CDirEnumerator
+{
+ bool FlatMode;
+ UString BasePrefix;
+ UStringVector FileNames;
+
+ CObjectVector<NFind::CEnumeratorW> Enumerators;
+ UStringVector Prefixes;
+ int Index;
+ bool GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath, DWORD &errorCode);
+ void Init();
+
+ CDirEnumerator(): FlatMode(false) {};
+};
+
+void CDirEnumerator::Init()
+{
+ Enumerators.Clear();
+ Prefixes.Clear();
+ Index = 0;
+}
+
+bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath, DWORD &errorCode)
+{
+ filled = false;
+ for (;;)
+ {
+ if (Enumerators.IsEmpty())
+ {
+ if (Index >= FileNames.Size())
+ return true;
+ const UString &path = FileNames[Index];
+ int pos = path.ReverseFind('\\');
+ resPath.Empty();
+ if (pos >= 0)
+ resPath = path.Left(pos + 1);
+ if (!NFind::FindFile(BasePrefix + path, fileInfo))
+ {
+ errorCode = ::GetLastError();
+ resPath = path;
+ return false;
+ }
+ Index++;
+ break;
+ }
+ bool found;
+ if (!Enumerators.Back().Next(fileInfo, found))
+ {
+ errorCode = ::GetLastError();
+ resPath = Prefixes.Back();
+ return false;
+ }
+ if (found)
+ {
+ resPath = Prefixes.Back();
+ break;
+ }
+ Enumerators.DeleteBack();
+ Prefixes.DeleteBack();
+ }
+ resPath += fileInfo.Name;
+ if (!FlatMode && fileInfo.IsDir())
+ {
+ UString prefix = resPath + (UString)(wchar_t)kDirDelimiter;
+ Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)kAnyStringWildcard));
+ Prefixes.Add(prefix);
+ }
+ filled = true;
+ return true;
+}
+
+struct CThreadCrc
+{
+ class CMyBuffer
+ {
+ void *_data;
+ public:
+ CMyBuffer(): _data(0) {}
+ operator void *() { return _data; }
+ bool Allocate(size_t size)
+ {
+ if (_data != 0)
+ return false;
+ _data = ::MidAlloc(size);
+ return _data != 0;
+ }
+ ~CMyBuffer() { ::MidFree(_data); }
+ };
+
+ CProgressDialog *ProgressDialog;
+
+ CDirEnumerator DirEnumerator;
+
+ UInt64 NumFiles;
+ UInt64 NumFolders;
+ UInt64 DataSize;
+ UInt32 DataCrcSum;
+ UInt32 DataNameCrcSum;
+
+ HRESULT Result;
+ DWORD ErrorCode;
+ UString ErrorPath;
+ UString Error;
+ bool ThereIsError;
+
+ void Process2()
+ {
+ DataSize = NumFolders = NumFiles = DataCrcSum = DataNameCrcSum = 0;
+ ProgressDialog->WaitCreating();
+
+ CMyBuffer bufferObject;
+ if (!bufferObject.Allocate(kBufSize))
+ {
+ Error = L"Can not allocate memory";
+ ThereIsError = true;
+ return;
+ }
+ Byte *buffer = (Byte *)(void *)bufferObject;
+
+ UInt64 totalSize = 0;
+
+ DirEnumerator.Init();
+
+ UString scanningStr = LangString(IDS_SCANNING, 0x03020800);
+ scanningStr += L" ";
+
+ for (;;)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ bool filled;
+ UString resPath;
+ if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode))
+ {
+ ThereIsError = true;
+ ErrorPath = resPath;
+ return;
+ }
+ if (!filled)
+ break;
+ if (!fileInfo.IsDir())
+ totalSize += fileInfo.Size;
+ ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath);
+ ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
+ Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(0);
+ if (Result != S_OK)
+ return;
+ }
+
+ ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
+
+ DirEnumerator.Init();
+
+ for (;;)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ bool filled;
+ UString resPath;
+ if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode))
+ {
+ ThereIsError = true;
+ ErrorPath = resPath;
+ return;
+ }
+ if (!filled)
+ break;
+
+ UInt32 crc = CRC_INIT_VAL;
+ if (fileInfo.IsDir())
+ NumFolders++;
+ else
+ {
+ NFile::NIO::CInFile inFile;
+ if (!inFile.Open(DirEnumerator.BasePrefix + resPath))
+ {
+ ErrorCode = ::GetLastError();
+ ThereIsError = true;
+ ErrorPath = resPath;
+ return;
+ }
+ NumFiles++;
+ ProgressDialog->ProgressSynch.SetCurrentFileName(resPath);
+ for (;;)
+ {
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, kBufSize, processedSize))
+ {
+ ErrorCode = ::GetLastError();
+ ThereIsError = true;
+ ErrorPath = resPath;
+ return;
+ }
+ if (processedSize == 0)
+ break;
+ crc = CrcUpdate(crc, buffer, processedSize);
+ DataSize += processedSize;
+ Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
+ if (Result != S_OK)
+ return;
+ }
+ DataCrcSum += CRC_GET_DIGEST(crc);
+ }
+ for (int i = 0; i < resPath.Length(); i++)
+ {
+ wchar_t c = resPath[i];
+ crc = CRC_UPDATE_BYTE(crc, ((Byte)(c & 0xFF)));
+ crc = CRC_UPDATE_BYTE(crc, ((Byte)((c >> 8) & 0xFF)));
+ }
+ DataNameCrcSum += CRC_GET_DIGEST(crc);
+ Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
+ if (Result != S_OK)
+ return;
+ }
+ }
+ DWORD Process()
+ {
+ try { Process2(); }
+ catch(...) { Error = L"Error"; ThereIsError = true;}
+ ProgressDialog->MyClose();
+ return 0;
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ return ((CThreadCrc *)param)->Process();
+ }
+};
+
+static void ConvertUInt32ToHex(UInt32 value, wchar_t *s)
+{
+ for (int i = 0; i < 8; i++)
+ {
+ int t = value & 0xF;
+ value >>= 4;
+ s[7 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
+ }
+ s[8] = L'\0';
+}
+
+void CApp::CalculateCrc()
+{
+ int srcPanelIndex = GetFocusedPanelIndex();
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+
+ CThreadCrc combiner;
+ for (int i = 0; i < indices.Size(); i++)
+ combiner.DirEnumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i]));
+ combiner.DirEnumerator.BasePrefix = srcPanel._currentFolderPrefix;
+ combiner.DirEnumerator.FlatMode = GetFlatMode();
+
+ {
+ CProgressDialog progressDialog;
+ combiner.ProgressDialog = &progressDialog;
+ combiner.ErrorCode = 0;
+ combiner.Result = S_OK;
+ combiner.ThereIsError = false;
+
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_CHECKSUM_CALCULATING, 0x03020710);
+
+ progressDialog.MainWindow = _window;
+ progressDialog.MainTitle = progressWindowTitle;
+ progressDialog.MainAddTitle = title + UString(L" ");
+
+ NWindows::CThread thread;
+ if (thread.Create(CThreadCrc::MyThreadFunction, &combiner) != S_OK)
+ return;
+ progressDialog.Create(title, _window);
+
+ if (combiner.Result != S_OK)
+ {
+ if (combiner.Result != E_ABORT)
+ srcPanel.MessageBoxError(combiner.Result);
+ }
+ else if (combiner.ThereIsError)
+ {
+ if (combiner.Error.IsEmpty())
+ {
+ UString message = combiner.DirEnumerator.BasePrefix + combiner.ErrorPath;
+ message += L"\n";
+ message += NError::MyFormatMessageW(combiner.ErrorCode);
+ srcPanel.MessageBoxMyError(message);
+ }
+ else
+ srcPanel.MessageBoxMyError(combiner.Error);
+ }
+ else
+ {
+ UString s;
+ {
+ wchar_t sz[32];
+
+ s += LangString(IDS_FILES_COLON, 0x02000320);
+ s += L" ";
+ ConvertUInt64ToString(combiner.NumFiles, sz);
+ s += sz;
+ s += L"\n";
+
+ s += LangString(IDS_FOLDERS_COLON, 0x02000321);
+ s += L" ";
+ ConvertUInt64ToString(combiner.NumFolders, sz);
+ s += sz;
+ s += L"\n";
+
+ s += LangString(IDS_SIZE_COLON, 0x02000322);
+ s += L" ";
+ ConvertUInt64ToString(combiner.DataSize, sz);
+ s += MyFormatNew(IDS_FILE_SIZE, 0x02000982, sz);;
+ s += L"\n";
+
+ s += LangString(IDS_CHECKSUM_CRC_DATA, 0x03020721);
+ s += L" ";
+ ConvertUInt32ToHex(combiner.DataCrcSum, sz);
+ s += sz;
+ s += L"\n";
+
+ s += LangString(IDS_CHECKSUM_CRC_DATA_NAMES, 0x03020722);
+ s += L" ";
+ ConvertUInt32ToHex(combiner.DataNameCrcSum, sz);
+ s += sz;
+ }
+ srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720));
+ }
+ }
+ RefreshTitleAlways();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
new file mode 100644
index 000000000..3364dc9c7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
@@ -0,0 +1,597 @@
+// PanelFolderChange.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+#include "Common/Wildcard.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../PropID.h"
+
+#ifdef _WIN32
+#include "FSDrives.h"
+#endif
+#include "LangUtils.h"
+#include "ListViewDialog.h"
+#include "Panel.h"
+#include "RootFolder.h"
+#include "ViewSettings.h"
+
+#include "resource.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+void CPanel::SetToRootFolder()
+{
+ _folder.Release();
+ _library.Free();
+ CRootFolder *rootFolderSpec = new CRootFolder;
+ _folder = rootFolderSpec;
+ rootFolderSpec->Init();
+}
+
+HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted)
+{
+ archiveIsOpened = false;
+ encrypted = false;
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+
+ printf("CPanel::BindToPath(%ls)\n",(const wchar_t *)fullPath);
+
+ if (_parentFolders.Size() > 0)
+ {
+ const UString &virtPath = _parentFolders.Back().VirtualPath;
+ if (fullPath.Left(virtPath.Length()) == virtPath)
+ {
+ for (;;)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ HRESULT res = _folder->BindToParentFolder(&newFolder);
+ if (!newFolder || res != S_OK)
+ break;
+ _folder = newFolder;
+ }
+ UStringVector parts;
+ SplitPathToParts(fullPath.Mid(virtPath.Length()), parts);
+ for (int i = 0; i < parts.Size(); i++)
+ {
+ const UString &s = parts[i];
+ if ((i == 0 || i == parts.Size() - 1) && s.IsEmpty())
+ continue;
+ CMyComPtr<IFolderFolder> newFolder;
+ HRESULT res = _folder->BindToFolder(s, &newFolder);
+ if (!newFolder || res != S_OK)
+ break;
+ _folder = newFolder;
+ }
+ return S_OK;
+ }
+ }
+
+ CloseOpenFolders();
+ UString sysPath = fullPath;
+ CFileInfoW fileInfo;
+ UStringVector reducedParts;
+ while (!sysPath.IsEmpty())
+ {
+ if (fileInfo.Find(sysPath))
+ break;
+ int pos = sysPath.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0)
+ sysPath.Empty();
+ else
+ {
+ if (reducedParts.Size() > 0 || pos < sysPath.Length() - 1)
+ reducedParts.Add(sysPath.Mid(pos + 1));
+ sysPath = sysPath.Left(pos);
+ }
+ }
+ SetToRootFolder();
+ CMyComPtr<IFolderFolder> newFolder;
+ if (sysPath.IsEmpty())
+ {
+ if (_folder->BindToFolder(fullPath, &newFolder) == S_OK)
+ _folder = newFolder;
+ }
+ else if (fileInfo.IsDir())
+ {
+ NName::NormalizeDirPathPrefix(sysPath);
+ if (_folder->BindToFolder(sysPath, &newFolder) == S_OK)
+ _folder = newFolder;
+ }
+ else
+ {
+ UString dirPrefix;
+ if (!NDirectory::GetOnlyDirPrefix(sysPath, dirPrefix))
+ dirPrefix.Empty();
+ if (_folder->BindToFolder(dirPrefix, &newFolder) == S_OK)
+ {
+ _folder = newFolder;
+ LoadFullPath();
+ UString fileName;
+ if (NDirectory::GetOnlyName(sysPath, fileName))
+ {
+ HRESULT res = OpenItemAsArchive(fileName, encrypted);
+ if (res != S_FALSE)
+ {
+ RINOK(res);
+ }
+ /*
+ if (res == E_ABORT)
+ return res;
+ */
+ if (res == S_OK)
+ {
+ archiveIsOpened = true;
+ for (int i = reducedParts.Size() - 1; i >= 0; i--)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToFolder(reducedParts[i], &newFolder);
+ if (!newFolder)
+ break;
+ _folder = newFolder;
+ }
+ }
+ }
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CPanel::BindToPathAndRefresh(const UString &path)
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ bool archiveIsOpened, encrypted;
+ RINOK(BindToPath(path, archiveIsOpened, encrypted));
+ RefreshListCtrl(UString(), -1, true, UStringVector());
+ return S_OK;
+}
+
+void CPanel::SetBookmark(int index)
+{
+ _appState->FastFolders.SetString(index, _currentFolderPrefix);
+}
+
+void CPanel::OpenBookmark(int index)
+{
+ BindToPathAndRefresh(_appState->FastFolders.GetString(index));
+}
+
+UString GetFolderPath(IFolderFolder *folder)
+{
+ NCOM::CPropVariant prop;
+ if (folder->GetFolderProperty(kpidPath, &prop) == S_OK)
+ if (prop.vt == VT_BSTR)
+ return (wchar_t *)prop.bstrVal;
+ return UString();
+}
+
+void CPanel::LoadFullPath()
+{
+ _currentFolderPrefix.Empty();
+ for (int i = 0; i < _parentFolders.Size(); i++)
+ {
+ const CFolderLink &folderLink = _parentFolders[i];
+ _currentFolderPrefix += GetFolderPath(folderLink.ParentFolder);
+ _currentFolderPrefix += folderLink.ItemName;
+ _currentFolderPrefix += WCHAR_PATH_SEPARATOR;
+ }
+ if (_folder)
+ _currentFolderPrefix += GetFolderPath(_folder);
+}
+
+static int GetRealIconIndex(LPCWSTR path, DWORD attributes)
+{
+ int index = -1;
+ if (GetRealIconIndex(path, attributes, index) != 0)
+ return index;
+ return -1;
+}
+
+void CPanel::LoadFullPathAndShow()
+{
+ LoadFullPath();
+ _appState->FolderHistory.AddString(_currentFolderPrefix);
+
+ _headerComboBox.SetText(_currentFolderPrefix);
+#ifdef _WIN32 // FIXME
+ COMBOBOXEXITEM item;
+ item.mask = 0;
+
+ UString path = _currentFolderPrefix;
+ if (path.Length() >
+ #ifdef _WIN32
+ 3
+ #else
+ 1
+ #endif
+ && path[path.Length() - 1] == WCHAR_PATH_SEPARATOR)
+ path.Delete(path.Length() - 1);
+
+ CFileInfoW info;
+ DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
+ if (info.Find(path))
+ attrib = info.Attrib;
+
+ item.iImage = GetRealIconIndex(path, attrib);
+
+ if (item.iImage >= 0)
+ {
+ item.iSelectedImage = item.iImage;
+ item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE);
+ }
+ item.iItem = -1;
+ _headerComboBox.SetItem(&item);
+#endif
+
+ RefreshTitle();
+}
+
+#ifdef _WIN32
+LRESULT CPanel::OnNotifyComboBoxEnter(const UString &s)
+{
+ if (BindToPathAndRefresh(GetUnicodeString(s)) == S_OK)
+ {
+ PostMessage(kSetFocusToListView);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result)
+{
+ if (info->iWhy == CBENF_ESCAPE)
+ {
+ _headerComboBox.SetText(_currentFolderPrefix);
+ PostMessage(kSetFocusToListView);
+ result = FALSE;
+ return true;
+ }
+
+ /*
+ if (info->iWhy == CBENF_DROPDOWN)
+ {
+ result = FALSE;
+ return true;
+ }
+ */
+
+ if (info->iWhy == CBENF_RETURN)
+ {
+ // When we use Edit control and press Enter.
+ UString s;
+ _headerComboBox.GetText(s);
+ result = OnNotifyComboBoxEnter(s);
+ return true;
+ }
+ return false;
+}
+
+#ifndef _UNICODE
+bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
+{
+ if (info->iWhy == CBENF_ESCAPE)
+ {
+ _headerComboBox.SetText(_currentFolderPrefix);
+ PostMessage(kSetFocusToListView);
+ result = FALSE;
+ return true;
+ }
+ /*
+ if (info->iWhy == CBENF_DROPDOWN)
+ {
+ result = FALSE;
+ return true;
+ }
+ */
+
+ if (info->iWhy == CBENF_RETURN)
+ {
+ UString s;
+ _headerComboBox.GetText(s);
+ // GetUnicodeString(info->szText)
+ result = OnNotifyComboBoxEnter(s);
+ return true;
+ }
+ return false;
+}
+#endif
+
+void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList)
+{
+ COMBOBOXEXITEMW item;
+ item.mask = CBEIF_TEXT | CBEIF_INDENT;
+ item.iSelectedImage = item.iImage = iconIndex;
+ if (iconIndex >= 0)
+ item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE);
+ item.iItem = -1;
+ item.iIndent = indent;
+ item.pszText = (LPWSTR)(LPCWSTR)name;
+ _headerComboBox.InsertItem(&item);
+ if (addToList)
+ ComboBoxPaths.Add(name);
+}
+
+extern UString RootFolder_GetName_Computer(int &iconIndex);
+extern UString RootFolder_GetName_Network(int &iconIndex);
+extern UString RootFolder_GetName_Documents(int &iconIndex);
+
+bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
+{
+ result = FALSE;
+ switch(code)
+ {
+ case CBN_DROPDOWN:
+ {
+ ComboBoxPaths.Clear();
+ _headerComboBox.ResetContent();
+
+ int iconIndex;
+ UString name;
+
+ int i;
+ UStringVector pathParts;
+
+ SplitPathToParts(_currentFolderPrefix, pathParts);
+ UString sumPass;
+ for (i = 0; i < pathParts.Size(); i++)
+ {
+ UString name = pathParts[i];
+ if (name.IsEmpty())
+ continue;
+ sumPass += name;
+ UString curName = sumPass;
+ if (i == 0)
+ curName += WCHAR_PATH_SEPARATOR;
+ CFileInfoW info;
+ DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
+ if (info.Find(sumPass))
+ attrib = info.Attrib;
+ sumPass += WCHAR_PATH_SEPARATOR;
+ AddComboBoxItem(name, GetRealIconIndex(curName, attrib), i, false);
+ ComboBoxPaths.Add(sumPass);
+ }
+
+ name = RootFolder_GetName_Documents(iconIndex);
+ AddComboBoxItem(name, iconIndex, 0, true);
+
+ name = RootFolder_GetName_Computer(iconIndex);
+ AddComboBoxItem(name, iconIndex, 0, true);
+
+ UStringVector driveStrings;
+ MyGetLogicalDriveStrings(driveStrings);
+ for (i = 0; i < driveStrings.Size(); i++)
+ {
+ UString s = driveStrings[i];
+ ComboBoxPaths.Add(s);
+ int iconIndex = GetRealIconIndex(s, 0);
+ if (s.Length() > 0 && s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
+ s.Delete(s.Length() - 1);
+ AddComboBoxItem(s, iconIndex, 1, false);
+ }
+
+ name = RootFolder_GetName_Network(iconIndex);
+ AddComboBoxItem(name, iconIndex, 0, true);
+
+ // UStringVector strings; _appState->FolderHistory.GetList(strings);
+
+ return false;
+ }
+
+ case CBN_SELENDOK:
+ {
+ code = code;
+ int index = _headerComboBox.GetCurSel();
+ if (index >= 0)
+ {
+ UString pass = ComboBoxPaths[index];
+ _headerComboBox.SetCurSel(-1);
+ _headerComboBox.SetText(pass); // it's fix for seclecting by mouse.
+ if (BindToPathAndRefresh(pass) == S_OK)
+ {
+ PostMessage(kSetFocusToListView);
+ return true;
+ }
+ }
+ return false;
+ }
+ /*
+ case CBN_CLOSEUP:
+ {
+ LoadFullPathAndShow();
+ true;
+
+ }
+ case CBN_SELCHANGE:
+ {
+ // LoadFullPathAndShow();
+ return true;
+ }
+ */
+ }
+ return false;
+}
+
+bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result)
+{
+ switch(header->code)
+ {
+ case CBEN_BEGINEDIT:
+ {
+ _lastFocusedIsList = false;
+ _panelCallback->PanelWasFocused();
+ break;
+ }
+ #ifndef _UNICODE
+ case CBEN_ENDEDIT:
+ {
+ return OnNotifyComboBoxEndEdit((PNMCBEENDEDIT)header, result);
+ }
+ #endif
+ case CBEN_ENDEDITW:
+ {
+ return OnNotifyComboBoxEndEdit((PNMCBEENDEDITW)header, result);
+ }
+ }
+ return false;
+}
+#endif
+
+
+void CPanel::FoldersHistory()
+{
+ CListViewDialog listViewDialog;
+ listViewDialog.DeleteIsAllowed = true;
+ listViewDialog.Title = LangString(IDS_FOLDERS_HISTORY, 0x03020260);
+ _appState->FolderHistory.GetList(listViewDialog.Strings);
+ if (listViewDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ UString selectString;
+ if (listViewDialog.StringsWereChanged)
+ {
+ _appState->FolderHistory.RemoveAll();
+ for (int i = listViewDialog.Strings.Size() - 1; i >= 0; i--)
+ _appState->FolderHistory.AddString(listViewDialog.Strings[i]);
+ if (listViewDialog.FocusedItemIndex >= 0)
+ selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
+ }
+ else
+ {
+ if (listViewDialog.FocusedItemIndex >= 0)
+ selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
+ }
+ if (listViewDialog.FocusedItemIndex >= 0)
+ BindToPathAndRefresh(selectString);
+}
+
+void CPanel::OpenParentFolder()
+{
+printf("CPanel::OpenParentFolder\n");
+ LoadFullPath(); // Maybe we don't need it ??
+ UString focucedName;
+ if (!_currentFolderPrefix.IsEmpty())
+ {
+ UString string = _currentFolderPrefix;
+ string.Delete(string.Length() - 1);
+ int pos = string.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0)
+ pos = 0;
+ else
+ pos++;
+ focucedName = string.Mid(pos);
+ }
+
+ printf("CPanel::OpenParentFolder focucedName=%ls\n",(const wchar_t *)focucedName);
+
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToParentFolder(&newFolder);
+ if (newFolder)
+ _folder = newFolder;
+ else
+ {
+ if (_parentFolders.IsEmpty())
+ {
+ SetToRootFolder();
+ if (focucedName.IsEmpty())
+ focucedName = GetItemName(0);
+ }
+ else
+ {
+ _folder.Release();
+ _library.Free();
+ CFolderLink &link = _parentFolders.Back();
+ _folder = link.ParentFolder;
+ _library.Attach(link.Library.Detach());
+ focucedName = link.ItemName;
+ if (_parentFolders.Size() > 1)
+ OpenParentArchiveFolder();
+ _parentFolders.DeleteBack();
+ if (_parentFolders.IsEmpty())
+ _flatMode = _flatModeForDisk;
+ }
+ }
+
+ UStringVector selectedItems;
+ /*
+ if (!focucedName.IsEmpty())
+ selectedItems.Add(focucedName);
+ */
+ LoadFullPath();
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
+ RefreshListCtrl(focucedName, -1, true, selectedItems);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+ RefreshStatusBar();
+
+ printf("CPanel::OpenParentFolder-end\n");
+}
+
+void CPanel::CloseOpenFolders()
+{
+ while (_parentFolders.Size() > 0)
+ {
+ _folder.Release();
+ _library.Free();
+ _folder = _parentFolders.Back().ParentFolder;
+ _library.Attach(_parentFolders.Back().Library.Detach());
+ if (_parentFolders.Size() > 1)
+ OpenParentArchiveFolder();
+ _parentFolders.DeleteBack();
+ }
+ _flatMode = _flatModeForDisk;
+ _folder.Release();
+ _library.Free();
+}
+
+void CPanel::OpenRootFolder()
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ _parentFolders.Clear();
+ SetToRootFolder();
+ RefreshListCtrl(UString(), -1, true, UStringVector());
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
+ /*
+ BeforeChangeFolder();
+ _currentFolderPrefix.Empty();
+ AfterChangeFolder();
+ SetCurrentPathText();
+ RefreshListCtrl(UString(), 0, UStringVector());
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+ */
+}
+
+void CPanel::OpenDrivesFolder()
+{
+#ifdef _WIN32
+ CloseOpenFolders();
+ CFSDrives *fsFolderSpec = new CFSDrives;
+ _folder = fsFolderSpec;
+ fsFolderSpec->Init();
+ RefreshListCtrl();
+#else
+ printf("CPanel::OpenDrivesFolder : FIXME\n");
+#endif
+}
+
+void CPanel::OpenFolder(int index)
+{
+ if (index == kParentIndex)
+ {
+ OpenParentFolder();
+ return;
+ }
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToFolder(index, &newFolder);
+ if (!newFolder)
+ return;
+ _folder = newFolder;
+ LoadFullPath();
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
+ RefreshListCtrl();
+ UINT state = LVIS_SELECTED;
+ _listView.SetItemState(_listView.GetFocusedItem(), state, state);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
new file mode 100644
index 000000000..814507925
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
@@ -0,0 +1,621 @@
+// PanelItemOpen.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+#include "wx/mimetype.h"
+
+#include "resource.h"
+
+#include "Common/StringConvert.h"
+// FIXME #include "Common/Random.h"
+#include "Common/StringConvert.h"
+#include "Common/AutoPtr.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/Thread.h"
+#include "Windows/Synchronization.h"
+#include "Windows/Error.h"
+
+#include "ExtractCallback.h"
+#include "UpdateCallback100.h"
+#include "IFolder.h"
+#include "FileFolderPluginOpen.h"
+#include "FormatUtils.h"
+#include "Panel.h"
+#include "RegistryUtils.h"
+#include "LangUtils.h"
+
+using namespace NWindows;
+using namespace NSynchronization;
+using namespace NFile;
+using namespace NDirectory;
+
+extern HWND g_HWND;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+static const wchar_t *kTempDirPrefix = L"7zO";
+
+
+static bool IsNameVirus(const UString &name)
+{
+ return (name.Find(L" ") >= 0);
+}
+
+struct CTmpProcessInfo: public CTempFileInfo
+{
+ HANDLE ProcessHandle;
+ HWND Window;
+ UString FullPathFolderPrefix;
+ bool UsePassword;
+ UString Password;
+ CTmpProcessInfo(): UsePassword(false) {}
+};
+
+class CTmpProcessInfoRelease
+{
+ CTmpProcessInfo *_tmpProcessInfo;
+public:
+ bool _needDelete;
+ CTmpProcessInfoRelease(CTmpProcessInfo &tmpProcessInfo):
+ _tmpProcessInfo(&tmpProcessInfo), _needDelete(true) {}
+ ~CTmpProcessInfoRelease()
+ {
+ if (_needDelete)
+ _tmpProcessInfo->DeleteDirAndFile();
+ }
+};
+
+HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
+ const CTempFileInfo &tempFileInfo,
+ const UString &virtualFilePath,
+ bool &encrypted)
+{
+ encrypted = false;
+ CFolderLink folderLink;
+ (CTempFileInfo &)folderLink = tempFileInfo;
+ if (inStream)
+ folderLink.IsVirtual = true;
+ else
+ {
+ if (!folderLink.FileInfo.Find(folderLink.FilePath))
+ return ::GetLastError();
+ if (folderLink.FileInfo.IsDir())
+ return S_FALSE;
+ folderLink.IsVirtual = false;
+ }
+
+ folderLink.VirtualPath = virtualFilePath;
+
+ CMyComPtr<IFolderFolder> newFolder;
+
+ // _passwordIsDefined = false;
+ // _password.Empty();
+
+ NDLL::CLibrary library;
+
+ UString password;
+ RINOK(OpenFileFolderPlugin(inStream,
+ folderLink.FilePath.IsEmpty() ? virtualFilePath : folderLink.FilePath,
+ &library, &newFolder, GetParent(), encrypted, password));
+
+ folderLink.Password = password;
+ folderLink.UsePassword = encrypted;
+
+ folderLink.ParentFolder = _folder;
+ _parentFolders.Add(folderLink);
+ _parentFolders.Back().Library.Attach(_library.Detach());
+
+ _folder.Release();
+ _library.Free();
+ _folder = newFolder;
+ _library.Attach(library.Detach());
+
+ _flatMode = _flatModeForArc;
+
+ return S_OK;
+}
+
+HRESULT CPanel::OpenItemAsArchive(const UString &name, bool &encrypted)
+{
+ CTempFileInfo tfi;
+ tfi.ItemName = name;
+ tfi.FolderPath = _currentFolderPrefix;
+ tfi.FilePath = _currentFolderPrefix + name;
+ return OpenItemAsArchive(NULL, tfi, _currentFolderPrefix + name, encrypted);
+}
+
+HRESULT CPanel::OpenItemAsArchive(int index)
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ bool encrypted;
+ RINOK(OpenItemAsArchive(GetItemRelPath(index), encrypted));
+ RefreshListCtrl();
+ return S_OK;
+}
+
+HRESULT CPanel::OpenParentArchiveFolder()
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ if (_parentFolders.Size() < 2)
+ return S_OK;
+ CFolderLink &folderLink = _parentFolders.Back();
+ NFind::CFileInfoW newFileInfo;
+ if (NFind::FindFile(folderLink.FilePath, newFileInfo))
+ {
+ if (newFileInfo.Size != folderLink.FileInfo.Size ||
+ CompareFileTime(&newFileInfo.MTime, &folderLink.FileInfo.MTime) != 0)
+ {
+ UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
+ 0x03020280, folderLink.ItemName);
+ if (::MessageBoxW(HWND(*this), message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
+ {
+ if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName,
+ folderLink.UsePassword, folderLink.Password) != S_OK)
+ {
+ ::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
+ 0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ return S_OK;
+ }
+ }
+ }
+ }
+ folderLink.DeleteDirAndFile();
+ return S_OK;
+}
+
+static const wchar_t *kStartExtensions[] =
+{
+ L"exe", L"bat", L"com",
+ L"chm",
+ L"msi", L"doc", L"xls", L"ppt", L"pps", L"wps", L"wpt", L"wks", L"xlr", L"wdb",
+
+ L"docx", L"docm", L"dotx", L"dotm", L"xlsx", L"xlsm", L"xltx", L"xltm", L"xlsb",
+ L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn",
+
+ L"dwf",
+
+ L"odt", L"ods",
+ L"wb3",
+ L"pdf"
+};
+
+static bool DoItemAlwaysStart(const UString &name)
+{
+ int extPos = name.ReverseFind('.');
+ if (extPos < 0)
+ return false;
+ UString ext = name.Mid(extPos + 1);
+ ext.MakeLower();
+ for (int i = 0; i < sizeof(kStartExtensions) / sizeof(kStartExtensions[0]); i++)
+ if (ext.Compare(kStartExtensions[i]) == 0)
+ return true;
+ return false;
+}
+
+#ifdef _WIN32
+static HANDLE StartEditApplication(const UString &path, HWND window)
+{
+ UString command;
+ ReadRegEditor(command);
+ if (command.IsEmpty())
+ {
+ if (!MyGetWindowsDirectory(command))
+ return 0;
+ NFile::NName::NormalizeDirPathPrefix(command);
+ command += L"notepad.exe";
+ }
+ command = UString(L"\"") + command + UString(L"\"");
+ command += L" \"";
+ command += UString(path);
+ command += L"\"";
+
+ PROCESS_INFORMATION processInformation;
+ BOOL result;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ STARTUPINFOA startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command),
+ NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+ else
+ #endif
+ {
+ STARTUPINFOW startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command,
+ NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+
+ if (result != FALSE)
+ {
+ ::CloseHandle(processInformation.hThread);
+ return processInformation.hProcess;
+ }
+ ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282),
+ L"7-Zip", MB_OK | MB_ICONSTOP);
+ return 0;
+}
+
+#ifndef _UNICODE
+typedef BOOL (WINAPI * ShellExecuteExWP)(LPSHELLEXECUTEINFOW lpExecInfo);
+#endif
+
+#endif // _WIN32
+
+static void StartApplication(const UString &path, HWND window)
+{
+ // FIXME
+ extern const TCHAR * nameWindowToUnix(const TCHAR * lpFileName);
+ UString tmpPath = path;
+
+ wxString filename(nameWindowToUnix(tmpPath));
+
+
+ wxString ext = filename.AfterLast(_T('.'));
+
+ printf("StartApplication(%ls) ext='%ls'\n",(const wchar_t *)filename,(const wchar_t *)ext);
+
+ if ( ! ext.empty() )
+ {
+ wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
+ // printf("StartApplication(%ls) ft=%p\n",(const wchar_t *)filename,ft);
+ if (ft)
+ {
+ wxString cmd;
+ // wxString type; ft->GetMimeType(&type);
+ wxFileType::MessageParameters params(filename); // , type);
+ bool ok = ft->GetOpenCommand(&cmd, params);
+ // printf("StartApplication(%ls) ok=%d\n",(const wchar_t *)filename,(int)ok);
+ delete ft;
+ if ( ok )
+ {
+ printf("StartApplication(%ls) cmd='%ls'\n",(const wchar_t *)filename,(const wchar_t *)cmd);
+ long pid = wxExecute(cmd, wxEXEC_ASYNC);
+ if (pid) return ;
+ }
+ }
+ }
+ ::MessageBoxW(window,
+ // NError::MyFormatMessageW(::GetLastError()),
+ L"There is no application associated with the given file name extension",
+ L"7-Zip", MB_OK | MB_ICONSTOP);
+}
+
+void CPanel::EditItem(int index)
+{
+ if (!_parentFolders.IsEmpty())
+ {
+ OpenItemInArchive(index, false, true, true);
+ return;
+ }
+#ifdef _WIN32
+ HANDLE hProcess = StartEditApplication(_currentFolderPrefix + GetItemRelPath(index), (HWND)*this);
+ if (hProcess != 0)
+ ::CloseHandle(hProcess);
+#endif
+}
+
+void CPanel::OpenFolderExternal(int index)
+{
+#ifdef _WIN32
+ HANDLE hProcess = StartApplication(GetFsPath() + GetItemRelPath(index), (HWND)*this);
+ if (hProcess != 0)
+ ::CloseHandle(hProcess);
+#else
+ printf(" CPanel::OpenFolderExternal : FIXME\n");
+#endif
+}
+
+void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal)
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ if (!_parentFolders.IsEmpty())
+ {
+ OpenItemInArchive(index, tryInternal, tryExternal, false);
+ return;
+ }
+ UString name = GetItemRelPath(index);
+ if (IsNameVirus(name))
+ {
+ MessageBoxErrorLang(IDS_VIRUS, 0x03020284);
+ return;
+ }
+ UString fullPath = _currentFolderPrefix + name;
+ if (tryInternal)
+ if (!tryExternal || !DoItemAlwaysStart(name))
+ {
+ HRESULT res = OpenItemAsArchive(index);
+ if (res == S_OK || res == E_ABORT)
+ return;
+ if (res != S_FALSE)
+ {
+ MessageBoxError(res);
+ return;
+ }
+ }
+ if (tryExternal)
+ {
+ // SetCurrentDirectory opens HANDLE to folder!!!
+ // NDirectory::MySetCurrentDirectory(_currentFolderPrefix);
+#ifdef _WIN32
+ HANDLE hProcess = StartApplication(fullPath, (HWND)*this);
+ if (hProcess != 0)
+ ::CloseHandle(hProcess);
+#else
+ StartApplication(fullPath, (HWND)*this);
+#endif
+ }
+}
+
+HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName,
+ bool usePassword, const UString &password)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return E_FAIL;
+ }
+ UStringVector fileNames;
+ CRecordVector<const wchar_t *> fileNamePointers;
+ fileNames.Add(itemName);
+ fileNamePointers.Add(fileNames[0]);
+
+ UString pathPrefix = folderPath;
+ NName::NormalizeDirPathPrefix(pathPrefix);
+
+ CUpdateCallback100Imp *callbackSpec = new CUpdateCallback100Imp;
+ CMyComPtr<IProgress> callback = callbackSpec;
+ callbackSpec->Init((HWND)*this, usePassword, password);
+
+ return folderOperations->CopyFrom(pathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), callback);
+}
+
+LRESULT CPanel::OnOpenItemChanged(LPARAM lParam)
+{
+ CTmpProcessInfo &tmpProcessInfo = *(CTmpProcessInfo *)lParam;
+ // LoadCurrentPath()
+ if (tmpProcessInfo.FullPathFolderPrefix != _currentFolderPrefix)
+ return 0;
+
+ CSelectedState state;
+ SaveSelectedState(state);
+
+ HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName,
+ tmpProcessInfo.UsePassword, tmpProcessInfo.Password);
+ if (result != S_OK)
+ return 0;
+ RefreshListCtrl(state);
+ return 1;
+}
+
+/*
+class CTmpProcessInfoList
+{
+public:
+ CObjectVector<CTmpProcessInfo> _items;
+} g_TmpProcessInfoList;
+*/
+
+class CExitEventLauncher
+{
+public:
+ NWindows::NSynchronization::CManualResetEvent _exitEvent;
+ CExitEventLauncher()
+ {
+ if (_exitEvent.Create(false) != S_OK)
+ throw 9387173;
+ };
+ ~CExitEventLauncher() { _exitEvent.Set(); }
+} g_ExitEventLauncher;
+
+#ifdef _WIN32
+static THREAD_FUNC_DECL MyThreadFunction(void *param)
+{
+ CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr((CTmpProcessInfo *)param);
+ CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
+
+ HANDLE hProcess = tmpProcessInfo->ProcessHandle;
+ HANDLE events[2] = { g_ExitEventLauncher._exitEvent, hProcess};
+ DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
+ ::CloseHandle(hProcess);
+ if (waitResult == WAIT_OBJECT_0 + 0)
+ return 0;
+ if (waitResult != WAIT_OBJECT_0 + 1)
+ return 1;
+ Sleep(200);
+ NFind::CFileInfoW newFileInfo;
+ if (NFind::FindFile(tmpProcessInfo->FilePath, newFileInfo))
+ {
+ if (newFileInfo.Size != tmpProcessInfo->FileInfo.Size ||
+ CompareFileTime(&newFileInfo.MTime, &tmpProcessInfo->FileInfo.MTime) != 0)
+ {
+ UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
+ 0x03020280, tmpProcessInfo->ItemName);
+ if (::MessageBoxW(g_HWND, message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
+ {
+ if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
+ {
+ ::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
+ 0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ return 0;
+ }
+ }
+ }
+ }
+ tmpProcessInfo->DeleteDirAndFile();
+ return 0;
+}
+#endif
+
+void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode)
+{
+ const UString name = GetItemName(index);
+ if (IsNameVirus(name))
+ {
+ MessageBoxErrorLang(IDS_VIRUS, 0x03020284);
+ return;
+ }
+
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+
+#ifdef _WIN32
+ NFile::NDirectory::CTempDirectoryW tempDirectory;
+ tempDirectory.Create(kTempDirPrefix);
+ UString tempDir = tempDirectory.GetPath();
+ UString tempDirNorm = tempDir;
+ NFile::NName::NormalizeDirPathPrefix(tempDirNorm);
+
+ CRecordVector<UInt32> indices;
+ indices.Add(index);
+
+ UStringVector messages;
+
+ bool usePassword = false;
+ UString password;
+ if (_parentFolders.Size() > 0)
+ {
+ const CFolderLink &fl = _parentFolders.Back();
+ usePassword = fl.UsePassword;
+ password = fl.Password;
+ }
+
+ HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages, usePassword, password);
+
+ if (_parentFolders.Size() > 0)
+ {
+ CFolderLink &fl = _parentFolders.Back();
+ fl.UsePassword = usePassword;
+ fl.Password = password;
+ }
+
+ if (!messages.IsEmpty())
+ return;
+ if (result != S_OK)
+ {
+ if (result != E_ABORT)
+ MessageBoxError(result);
+ return;
+ }
+
+ UString tempFilePath = tempDirNorm + name;
+
+ CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo());
+ CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
+ tmpProcessInfo->FolderPath = tempDir;
+ tmpProcessInfo->FilePath = tempFilePath;
+ tmpProcessInfo->UsePassword = usePassword;
+ tmpProcessInfo->Password = password;
+
+ if (!NFind::FindFile(tempFilePath, tmpProcessInfo->FileInfo))
+ return;
+
+ if (tryInternal)
+ {
+ if (!tryExternal || !DoItemAlwaysStart(name))
+ {
+ bool encrypted;
+ if (OpenItemAsArchive(name, tempDir, tempFilePath,
+ _currentFolderPrefix + name, encrypted) == S_OK)
+ {
+ RefreshListCtrl();
+ return;
+ }
+ }
+ }
+
+ CTmpProcessInfoRelease tmpProcessInfoRelease(*tmpProcessInfo);
+
+ if (!tryExternal)
+ return;
+
+ HANDLE hProcess;
+ if (editMode)
+ hProcess = StartEditApplication(tempFilePath, (HWND)*this);
+ else
+ hProcess = StartApplication(tempFilePath, (HWND)*this);
+
+ if (hProcess == 0)
+ return;
+
+ tmpProcessInfo->Window = (HWND)(*this);
+ tmpProcessInfo->FullPathFolderPrefix = _currentFolderPrefix;
+ tmpProcessInfo->ItemName = name;
+ tmpProcessInfo->ProcessHandle = hProcess;
+
+ NWindows::CThread thread;
+ if (thread.Create(MyThreadFunction, tmpProcessInfo) != S_OK)
+ throw 271824;
+ tempDirectory.DisableDeleting();
+ tmpProcessInfoPtr.release();
+ tmpProcessInfoRelease._needDelete = false;
+#else
+ printf(" CPanel::OpenItemInArchive : FIXME\n");
+#endif
+}
+
+/*
+static const UINT64 kTimeLimit = UINT64(10000000) * 3600 * 24;
+
+static bool CheckDeleteItem(UINT64 currentFileTime, UINT64 folderFileTime)
+{
+ return (currentFileTime - folderFileTime > kTimeLimit &&
+ folderFileTime - currentFileTime > kTimeLimit);
+}
+
+void DeleteOldTempFiles()
+{
+ UString tempPath;
+ if(!NFile::NDirectory::MyGetTempPath(tempPath))
+ throw 1;
+
+ UINT64 currentFileTime;
+ NTime::GetCurUtcFileTime(currentFileTime);
+ UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
+ searchWildCard += WCHAR(NName::kAnyStringWildcard);
+ NFind::CEnumeratorW enumerator(searchWildCard);
+ NFind::CFileInfoW fileInfo;
+ while(enumerator.Next(fileInfo))
+ {
+ if (!fileInfo.IsDir())
+ continue;
+ const UINT64 &cTime = *(const UINT64 *)(&fileInfo.CTime);
+ if(CheckDeleteItem(cTime, currentFileTime))
+ RemoveDirectoryWithSubItems(tempPath + fileInfo.Name);
+ }
+}
+*/
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelItems.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelItems.cpp
new file mode 100644
index 000000000..38d925355
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelItems.cpp
@@ -0,0 +1,828 @@
+// PanelItems.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+// FIXME #include "Windows/Menu.h"
+
+#include "../../PropID.h"
+
+#include "resource.h"
+
+#include "LangUtils.h"
+#include "Panel.h"
+#include "PropertyName.h"
+#include "RootFolder.h"
+
+extern "C"
+{
+ #include "../../../../C/Sort.h"
+}
+
+using namespace NWindows;
+
+static int GetColumnAlign(PROPID propID, VARTYPE varType)
+{
+ switch(propID)
+ {
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
+ return LVCFMT_LEFT;
+ }
+ switch(varType)
+ {
+ case VT_UI1:
+ case VT_I2:
+ case VT_UI2:
+ case VT_I4:
+ case VT_INT:
+ case VT_UI4:
+ case VT_UINT:
+ case VT_I8:
+ case VT_UI8:
+ case VT_BOOL:
+ return LVCFMT_RIGHT;
+
+ case VT_EMPTY:
+ case VT_I1:
+ case VT_FILETIME:
+ case VT_BSTR:
+ return LVCFMT_LEFT;
+
+ default:
+ return LVCFMT_CENTER;
+ }
+}
+
+void CPanel::InitColumns()
+{
+ printf("CPanel::InitColumns\n");
+ if (_needSaveInfo)
+ SaveListViewInfo();
+
+ _listView.DeleteAllItems();
+ _selectedStatusVector.Clear();
+
+ ReadListViewInfo();
+
+
+ PROPID sortID;
+ /*
+ if (_listViewInfo.SortIndex >= 0)
+ sortID = _listViewInfo.Columns[_listViewInfo.SortIndex].PropID;
+ */
+ sortID = _listViewInfo.SortID;
+
+ _ascending = _listViewInfo.Ascending;
+
+ _properties.Clear();
+
+ _needSaveInfo = true;
+
+ UInt32 numProperties;
+ _folder->GetNumberOfProperties(&numProperties);
+ int i;
+ for (i = 0; i < (int)numProperties; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE varType;
+
+ if (_folder->GetPropertyInfo(i, &name, &propID, &varType) != S_OK)
+ throw 1;
+
+ if (propID == kpidIsDir)
+ continue;
+
+ CItemProperty prop;
+ prop.Type = varType;
+ prop.ID = propID;
+ prop.Name = GetNameOfProperty(propID, name);
+ prop.Order = -1;
+ prop.IsVisible = true;
+ prop.Width = 100;
+ _properties.Add(prop);
+ }
+ // InitColumns2(sortID);
+
+ for (;;)
+ if (!_listView.DeleteColumn(0))
+ break;
+
+ int order = 0;
+ for(i = 0; i < _listViewInfo.Columns.Size(); i++)
+ {
+ const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
+ int index = _properties.FindItemWithID(columnInfo.PropID);
+ if (index >= 0)
+ {
+ CItemProperty &item = _properties[index];
+ item.IsVisible = columnInfo.IsVisible;
+ item.Width = columnInfo.Width;
+ if (columnInfo.IsVisible)
+ item.Order = order++;
+ continue;
+ }
+ }
+ for(i = 0; i < _properties.Size(); i++)
+ {
+ CItemProperty &item = _properties[i];
+ if (item.Order < 0)
+ item.Order = order++;
+ }
+
+ _visibleProperties.Clear();
+ for (i = 0; i < _properties.Size(); i++)
+ {
+ const CItemProperty &property = _properties[i];
+ if (property.IsVisible)
+ _visibleProperties.Add(property);
+ }
+
+ // _sortIndex = 0;
+ _sortID = kpidName;
+ /*
+ if (_listViewInfo.SortIndex >= 0)
+ {
+ int sortIndex = _properties.FindItemWithID(sortID);
+ if (sortIndex >= 0)
+ _sortIndex = sortIndex;
+ }
+ */
+ _sortID = _listViewInfo.SortID;
+
+ for (i = 0; i < _visibleProperties.Size(); i++)
+ {
+ InsertColumn(i);
+ }
+}
+
+void CPanel::InsertColumn(int index)
+{
+ //printf("CPanel::InsertColumn\n");
+ const CItemProperty &property = _visibleProperties[index];
+ LV_COLUMNW column;
+ column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
+ column.cx = property.Width;
+ column.fmt = GetColumnAlign(property.ID, property.Type);
+ column.iOrder = property.Order;
+ column.iSubItem = index;
+ column.pszText = (wchar_t *)(const wchar_t *)property.Name;
+ _listView.InsertColumn(index, &column);
+}
+
+void CPanel::RefreshListCtrl()
+{
+ RefreshListCtrl(UString(), -1, true, UStringVector());
+}
+
+int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
+
+
+void CPanel::GetSelectedNames(UStringVector &selectedNames)
+{
+ selectedNames.Clear();
+
+ CRecordVector<UInt32> indices;
+ GetSelectedItemsIndices(indices);
+ selectedNames.Reserve(indices.Size());
+ for (int i = 0; i < indices.Size(); i++)
+ selectedNames.Add(GetItemRelPath(indices[i]));
+
+ /*
+ for (int i = 0; i < _listView.GetItemCount(); i++)
+ {
+ const int kSize = 1024;
+ WCHAR name[kSize + 1];
+ LVITEMW item;
+ item.iItem = i;
+ item.pszText = name;
+ item.cchTextMax = kSize;
+ item.iSubItem = 0;
+ item.mask = LVIF_TEXT | LVIF_PARAM;
+ if (!_listView.GetItem(&item))
+ continue;
+ int realIndex = GetRealIndex(item);
+ if (realIndex == kParentIndex)
+ continue;
+ if (_selectedStatusVector[realIndex])
+ selectedNames.Add(item.pszText);
+ }
+ */
+ selectedNames.Sort();
+}
+
+void CPanel::SaveSelectedState(CSelectedState &s)
+{
+ s.FocusedName.Empty();
+ s.SelectedNames.Clear();
+ s.FocusedItem = _listView.GetFocusedItem();
+ {
+ if (s.FocusedItem >= 0)
+ {
+ int realIndex = GetRealItemIndex(s.FocusedItem);
+ if (realIndex != kParentIndex)
+ s.FocusedName = GetItemRelPath(realIndex);
+ /*
+ const int kSize = 1024;
+ WCHAR name[kSize + 1];
+ LVITEMW item;
+ item.iItem = focusedItem;
+ item.pszText = name;
+ item.cchTextMax = kSize;
+ item.iSubItem = 0;
+ item.mask = LVIF_TEXT;
+ if (_listView.GetItem(&item))
+ focusedName = item.pszText;
+ */
+ }
+ }
+ GetSelectedNames(s.SelectedNames);
+}
+
+void CPanel::RefreshListCtrl(const CSelectedState &s)
+{
+ bool selectFocused = s.SelectFocused;
+ if (_mySelectMode)
+ selectFocused = true;
+ RefreshListCtrl(s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
+}
+
+void CPanel::RefreshListCtrlSaveFocused()
+{
+ CSelectedState state;
+ SaveSelectedState(state);
+ RefreshListCtrl(state);
+}
+
+void CPanel::SetFocusedSelectedItem(int index, bool select)
+{
+ UINT state = LVIS_FOCUSED;
+ if (select)
+ state |= LVIS_SELECTED;
+ _listView.SetItemState(index, state, state);
+ if (!_mySelectMode && select)
+ {
+ int realIndex = GetRealItemIndex(index);
+ if (realIndex != kParentIndex)
+ _selectedStatusVector[realIndex] = true;
+ }
+}
+
+void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
+ const UStringVector &selectedNames)
+{
+printf("CPanel::RefreshListCtrl\n");
+ _dontShowMode = false;
+ LoadFullPathAndShow();
+ // OutputDebugStringA("=======\n");
+ // OutputDebugStringA("s1 \n");
+ CDisableTimerProcessing timerProcessing(*this);
+
+ if (focusedPos < 0)
+ focusedPos = 0;
+
+ _listView.SetRedraw(false);
+ // m_RedrawEnabled = false;
+
+#ifdef _WIN32
+ LVITEMW item;
+ ZeroMemory(&item, sizeof(item));
+#else
+ LVITEMW item = { 0 };
+#endif
+
+ _listView.DeleteAllItems();
+ _selectedStatusVector.Clear();
+ // _realIndices.Clear();
+ _startGroupSelect = 0;
+
+ _selectionIsDefined = false;
+
+ // m_Files.Clear();
+ // _folder.Release();
+
+ if (!_folder)
+ {
+ // throw 1;
+ SetToRootFolder();
+ }
+
+ // FIXME _headerToolBar.EnableButton(kParentFolderID, !IsRootFolder());
+
+ CMyComPtr<IFolderSetFlatMode> folderSetFlatMode;
+ _folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode);
+ if (folderSetFlatMode)
+ folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
+
+ if (_folder->LoadItems() != S_OK)
+ return;
+
+ InitColumns();
+
+
+ // OutputDebugString(TEXT("Start Dir\n"));
+ UInt32 numItems;
+ _folder->GetNumberOfItems(&numItems);
+
+ bool showDots = _showDots && !IsRootFolder();
+
+ _listView.SetItemCount(numItems + (showDots ? 1 : 0));
+
+ _selectedStatusVector.Reserve(numItems);
+ int cursorIndex = -1;
+
+ CMyComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
+ if (!IsFSFolder() || _showRealFileIcons)
+ _folder.QueryInterface(IID_IFolderGetSystemIconIndex, &folderGetSystemIconIndex);
+
+ if (showDots)
+ {
+ UString itemName = L"..";
+ item.iItem = _listView.GetItemCount();
+ if (itemName.CompareNoCase(focusedName) == 0)
+ cursorIndex = item.iItem;
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ int subItem = 0;
+ item.iSubItem = subItem++;
+ item.lParam = kParentIndex;
+ item.pszText = (wchar_t *)(const wchar_t *)itemName;
+ UInt32 attributes = FILE_ATTRIBUTE_DIRECTORY;
+ /* FIXME
+ item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
+ if (item.iImage < 0)
+ item.iImage = 0;
+ */
+ item.iImage = -1; // FIXME
+ if(_listView.InsertItem(&item) == -1)
+ return;
+ }
+
+ // OutputDebugStringA("S1\n");
+
+ for(UInt32 i = 0; i < numItems; i++)
+ {
+ UString itemName = GetItemName(i);
+ const UString relPath = GetItemRelPath(i);
+ if (relPath.CompareNoCase(focusedName) == 0)
+ cursorIndex = _listView.GetItemCount();
+ bool selected = false;
+ if (selectedNames.FindInSorted(relPath) >= 0)
+ selected = true;
+ _selectedStatusVector.Add(selected);
+
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+
+ if (!_mySelectMode)
+ if (selected)
+ {
+ item.mask |= LVIF_STATE;
+ item.state = LVIS_SELECTED;
+ }
+
+ int subItem = 0;
+ item.iItem = _listView.GetItemCount();
+
+ item.iSubItem = subItem++;
+ item.lParam = i;
+
+ UString correctedName;
+ if (itemName.Find(L" ") >= 0)
+ {
+ int pos = 0;
+ for (;;)
+ {
+ int posNew = itemName.Find(L" ", pos);
+ if (posNew < 0)
+ {
+ correctedName += itemName.Mid(pos);
+ break;
+ }
+ correctedName += itemName.Mid(pos, posNew - pos);
+ correctedName += L" ... ";
+ pos = posNew;
+ while (itemName[++pos] == ' ');
+ }
+ item.pszText = (wchar_t *)(const wchar_t *)correctedName;
+ }
+ else
+ item.pszText = (wchar_t *)(const wchar_t *)itemName;
+
+ NCOM::CPropVariant propVariant;
+ _folder->GetProperty(i, kpidAttrib, &propVariant);
+ UInt32 attributes = 0;
+ if (propVariant.vt == VT_UI4)
+ attributes = propVariant.ulVal;
+ else
+ {
+ if (IsItemFolder(i))
+ attributes |= FILE_ATTRIBUTE_DIRECTORY;
+ }
+
+ bool defined = false;
+
+ if (folderGetSystemIconIndex)
+ {
+ folderGetSystemIconIndex->GetSystemIconIndex(i, &item.iImage);
+ defined = (item.iImage > 0);
+ }
+ if (!defined)
+ {
+ if (_currentFolderPrefix.IsEmpty())
+ {
+ int iconIndexTemp = -1;
+ GetRealIconIndex(itemName + WSTRING_PATH_SEPARATOR, attributes, iconIndexTemp);
+ item.iImage = iconIndexTemp;
+ }
+ else
+ {
+ item.iImage = -1; // FIXME _extToIconMap.GetIconIndex(attributes, itemName);
+ }
+ }
+ if (item.iImage < 0)
+ item.iImage = 0;
+
+ if(_listView.InsertItem(&item) == -1)
+ return; // error
+
+ // FIXME Added
+ item.pszText = (LPWSTR)malloc(4096); // FIXME
+ for(int col=1;col < _listView.GetColumnCount(); col++)
+ {
+ item.iSubItem = col;
+ item.cchTextMax = 4096 / sizeof(item.pszText[0]);
+ this->SetItemText(item);
+ _listView.SetItem(&item);
+ }
+ free(item.pszText); item.pszText = 0;
+
+ }
+ // OutputDebugStringA("End2\n");
+
+ if(_listView.GetItemCount() > 0 && cursorIndex >= 0)
+ SetFocusedSelectedItem(cursorIndex, selectFocused);
+ _listView.SortItems(CompareItems, (LPARAM)this);
+ if (cursorIndex < 0 && _listView.GetItemCount() > 0)
+ {
+ if (focusedPos >= _listView.GetItemCount())
+ focusedPos = _listView.GetItemCount() - 1;
+ SetFocusedSelectedItem(focusedPos, showDots);
+ }
+ // m_RedrawEnabled = true;
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+ _listView.SetRedraw(true);
+ _listView.InvalidateRect(NULL, true);
+ // OutputDebugStringA("End1\n");
+ /*
+ _listView.UpdateWindow();
+ */
+}
+
+void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
+{
+ indices.Clear();
+#if 0 // FIXME - not needed anymore ? (UNIX_ENV)
+ int itemIndex = -1;
+ while ((itemIndex = _listView.GetNextItem(itemIndex, LVNI_SELECTED)) != -1)
+ {
+ LPARAM param;
+ if (_listView.GetItemParam(itemIndex, param))
+ indices.Add(param);
+ }
+#else
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (_selectedStatusVector[i])
+ indices.Add(i);
+#endif
+ HeapSort(&indices.Front(), indices.Size());
+}
+
+void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
+{
+ GetSelectedItemsIndices(indices);
+ if (!indices.IsEmpty())
+ return;
+ if (_listView.GetSelectedCount() == 0)
+ return;
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem >= 0)
+ {
+ if(_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
+ {
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex != kParentIndex)
+ indices.Add(realIndex);
+ }
+ }
+}
+
+void CPanel::GetAllItemIndices(CRecordVector<UInt32> &indices) const
+{
+ indices.Clear();
+ UInt32 numItems;
+ if (_folder->GetNumberOfItems(&numItems) == S_OK)
+ for (UInt32 i = 0; i < numItems; i++)
+ indices.Add(i);
+}
+
+void CPanel::GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const
+{
+ GetOperatedItemIndices(indices);
+ if (indices.IsEmpty() || (indices.Size() == 1 && indices[0] == (UInt32)(Int32)-1))
+ GetAllItemIndices(indices);
+}
+
+/*
+void CPanel::GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const
+{
+ indices.Clear();
+ int numItems = _listView.GetItemCount();
+ for (int i = 0; i < numItems; i++)
+ {
+ int realIndex = GetRealItemIndex(i);
+ if (realIndex >= 0)
+ if (_selectedStatusVector[realIndex])
+ indices.Add(i);
+ }
+ if (indices.IsEmpty())
+ {
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem >= 0)
+ indices.Add(focusedItem);
+ }
+}
+*/
+
+void CPanel::EditItem()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex == kParentIndex)
+ return;
+ if (!IsItemFolder(realIndex))
+ EditItem(realIndex);
+}
+
+void CPanel::OpenFocusedItemAsInternal()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (IsItemFolder(realIndex))
+ OpenFolder(realIndex);
+ else
+ OpenItem(realIndex, true, false);
+}
+
+void CPanel::OpenSelectedItems(bool tryInternal)
+{
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ if (indices.Size() > 20)
+ {
+ MessageBoxErrorLang(IDS_TOO_MANY_ITEMS, 0x02000606);
+ return;
+ }
+
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem >= 0)
+ {
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0))
+ indices.Insert(0, realIndex);
+ }
+
+ bool dirIsStarted = false;
+ for(int i = 0; i < indices.Size(); i++)
+ {
+ UInt32 index = indices[i];
+ // CFileInfo &aFile = m_Files[index];
+ if (IsItemFolder(index))
+ {
+ if (!dirIsStarted)
+ {
+ if (tryInternal)
+ {
+ OpenFolder(index);
+ dirIsStarted = true;
+ break;
+ }
+ else
+ OpenFolderExternal(index);
+ }
+ }
+ else
+ OpenItem(index, (tryInternal && indices.Size() == 1), true);
+ }
+}
+
+UString CPanel::GetItemName(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return L"..";
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(itemIndex, kpidName, &propVariant) != S_OK)
+ throw 2723400;
+ if (propVariant.vt != VT_BSTR)
+ throw 2723401;
+ return (propVariant.bstrVal);
+}
+
+UString CPanel::GetItemPrefix(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return UString();
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(itemIndex, kpidPrefix, &propVariant) != S_OK)
+ throw 2723400;
+ UString prefix;
+ if (propVariant.vt == VT_BSTR)
+ prefix = propVariant.bstrVal;
+ return prefix;
+}
+
+UString CPanel::GetItemRelPath(int itemIndex) const
+{
+ return GetItemPrefix(itemIndex) + GetItemName(itemIndex);
+}
+
+
+bool CPanel::IsItemFolder(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return true;
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(itemIndex, kpidIsDir, &propVariant) != S_OK)
+ throw 2723400;
+ if (propVariant.vt == VT_BOOL)
+ return VARIANT_BOOLToBool(propVariant.boolVal);
+ if (propVariant.vt == VT_EMPTY)
+ return false;
+ return false;
+}
+
+UINT64 CPanel::GetItemSize(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return 0;
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(itemIndex, kpidSize, &propVariant) != S_OK)
+ throw 2723400;
+ if (propVariant.vt == VT_EMPTY)
+ return 0;
+ return ConvertPropVariantToUInt64(propVariant);
+}
+
+void CPanel::ReadListViewInfo()
+{
+ _typeIDString = GetFolderTypeID();
+ if (!_typeIDString.IsEmpty())
+ ::ReadListViewInfo(_typeIDString, _listViewInfo);
+}
+
+void CPanel::SaveListViewInfo()
+{
+ int i;
+ for(i = 0; i < _visibleProperties.Size(); i++)
+ {
+ CItemProperty &property = _visibleProperties[i];
+ LVCOLUMN winColumnInfo;
+ winColumnInfo.mask = LVCF_ORDER | LVCF_WIDTH;
+ if (!_listView.GetColumn(i, &winColumnInfo))
+ throw 1;
+ property.Order = winColumnInfo.iOrder;
+ property.Width = winColumnInfo.cx;
+ }
+
+ CListViewInfo viewInfo;
+
+ // PROPID sortPropID = _properties[_sortIndex].ID;
+ PROPID sortPropID = _sortID;
+
+ _visibleProperties.Sort();
+ for(i = 0; i < _visibleProperties.Size(); i++)
+ {
+ const CItemProperty &property = _visibleProperties[i];
+ CColumnInfo columnInfo;
+ columnInfo.IsVisible = property.IsVisible;
+ columnInfo.PropID = property.ID;
+ columnInfo.Width = property.Width;
+ viewInfo.Columns.Add(columnInfo);
+ }
+ for(i = 0; i < _properties.Size(); i++)
+ {
+ const CItemProperty &property = _properties[i];
+ if (!property.IsVisible)
+ {
+ CColumnInfo columnInfo;
+ columnInfo.IsVisible = property.IsVisible;
+ columnInfo.PropID = property.ID;
+ columnInfo.Width = property.Width;
+ viewInfo.Columns.Add(columnInfo);
+ }
+ }
+
+ // viewInfo.SortIndex = viewInfo.FindColumnWithID(sortPropID);
+ viewInfo.SortID = sortPropID;
+
+ viewInfo.Ascending = _ascending;
+ if (!_listViewInfo.IsEqual(viewInfo))
+ {
+ ::SaveListViewInfo(_typeIDString, viewInfo);
+ _listViewInfo = viewInfo;
+ }
+}
+
+#ifdef _WIN32
+bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result)
+{
+ if(itemActiveate->hdr.hwndFrom == HWND(_listView))
+ return false;
+
+ POINT point;
+ ::GetCursorPos(&point);
+
+ CMenu menu;
+ CMenuDestroyer menuDestroyer(menu);
+
+ menu.CreatePopup();
+
+ const int kCommandStart = 100;
+ for(int i = 0; i < _properties.Size(); i++)
+ {
+ const CItemProperty &property = _properties[i];
+ UINT flags = MF_STRING;
+ if (property.IsVisible)
+ flags |= MF_CHECKED;
+ if (i == 0)
+ flags |= MF_GRAYED;
+ menu.AppendItem(flags, kCommandStart + i, GetSystemString(property.Name));
+ }
+ int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY,
+ point.x, point.y, _listView);
+ if (menuResult >= kCommandStart && menuResult <= kCommandStart + _properties.Size())
+ {
+ int index = menuResult - kCommandStart;
+ CItemProperty &property = _properties[index];
+ property.IsVisible = !property.IsVisible;
+
+ if (property.IsVisible)
+ {
+ int prevVisibleSize = _visibleProperties.Size();
+ property.Order = prevVisibleSize;
+ _visibleProperties.Add(property);
+ InsertColumn(prevVisibleSize);
+ }
+ else
+ {
+ int visibleIndex = _visibleProperties.FindItemWithID(property.ID);
+ _visibleProperties.Delete(visibleIndex);
+ /*
+ if (_sortIndex == index)
+ {
+ _sortIndex = 0;
+ _ascending = true;
+ }
+ */
+ if (_sortID == property.ID)
+ {
+ _sortID = kpidName;
+ _ascending = true;
+ }
+
+ _listView.DeleteColumn(visibleIndex);
+ }
+ }
+ result = TRUE;
+ return true;
+}
+#endif // _WIN32
+
+void CPanel::OnReload()
+{
+ RefreshListCtrlSaveFocused();
+ OnRefreshStatusBar();
+}
+
+void CPanel::OnTimer()
+{
+ if (!_processTimer)
+ return;
+ CMyComPtr<IFolderWasChanged> folderWasChanged;
+ if (_folder.QueryInterface(IID_IFolderWasChanged, &folderWasChanged) != S_OK)
+ return;
+ INT32 wasChanged;
+ if (folderWasChanged->WasChanged(&wasChanged) != S_OK)
+ return;
+ if (wasChanged == 0)
+ return;
+ OnReload();
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelListNotify.cpp
new file mode 100644
index 000000000..4e956324c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelListNotify.cpp
@@ -0,0 +1,429 @@
+// PanelListNotify.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../Common/PropIDUtils.h"
+#include "../../PropID.h"
+
+#include "Panel.h"
+#include "FormatUtils.h"
+
+using namespace NWindows;
+
+static UString ConvertSizeToStringShort(UInt64 value)
+{
+ wchar_t s[32];
+ wchar_t c, c2 = L'B';
+ if (value < (UInt64)10000)
+ {
+ c = L'B';
+ c2 = L'\0';
+ }
+ else if (value < ((UInt64)10000 << 10))
+ {
+ value >>= 10;
+ c = L'K';
+ }
+ else if (value < ((UInt64)10000 << 20))
+ {
+ value >>= 20;
+ c = L'M';
+ }
+ else
+ {
+ value >>= 30;
+ c = L'G';
+ }
+ ConvertUInt64ToString(value, s);
+ int p = MyStringLen(s);
+ s[p++] = L' ';
+ s[p++] = c;
+ s[p++] = c2;
+ s[p++] = L'\0';
+ return s;
+}
+
+UString ConvertSizeToString(UInt64 value)
+{
+ wchar_t s[32];
+ ConvertUInt64ToString(value, s);
+ int i = MyStringLen(s);
+ int pos = sizeof(s) / sizeof(s[0]);
+ s[--pos] = L'\0';
+ while (i > 3)
+ {
+ s[--pos] = s[--i];
+ s[--pos] = s[--i];
+ s[--pos] = s[--i];
+ s[--pos] = L' ';
+ }
+ while (i > 0)
+ s[--pos] = s[--i];
+ return s + pos;
+}
+
+LRESULT CPanel::SetItemText(LVITEMW &item)
+{
+ if (_dontShowMode)
+ return 0;
+
+ UINT32 realIndex = GetRealIndex(item);
+ // printf(" CPanel::SetItemText : realIndex=%d\n",realIndex);
+
+ /*
+ if ((item.mask & LVIF_IMAGE) != 0)
+ {
+ bool defined = false;
+ CComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
+ _folder.QueryInterface(&folderGetSystemIconIndex);
+ if (folderGetSystemIconIndex)
+ {
+ folderGetSystemIconIndex->GetSystemIconIndex(index, &item.iImage);
+ defined = (item.iImage > 0);
+ }
+ if (!defined)
+ {
+ NCOM::CPropVariant prop;
+ _folder->GetProperty(index, kpidAttrib, &prop);
+ UINT32 attrib = 0;
+ if (prop.vt == VT_UI4)
+ attrib = prop.ulVal;
+ else if (IsItemFolder(index))
+ attrib |= FILE_ATTRIBUTE_DIRECTORY;
+ if (_currentFolderPrefix.IsEmpty())
+ throw 1;
+ else
+ item.iImage = _extToIconMap.GetIconIndex(attrib, GetSystemString(GetItemName(index)));
+ }
+ // item.iImage = 1;
+ }
+ */
+
+ if ((item.mask & LVIF_TEXT) == 0)
+ return 0;
+
+ if (realIndex == kParentIndex)
+ return 0;
+ UString s;
+ UINT32 subItemIndex = item.iSubItem;
+ PROPID propID = _visibleProperties[subItemIndex].ID;
+ /*
+ {
+ NCOM::CPropVariant property;
+ if(propID == kpidType)
+ string = GetFileType(index);
+ else
+ {
+ HRESULT result = m_ArchiveFolder->GetProperty(index, propID, &property);
+ if (result != S_OK)
+ {
+ // PrintMessage("GetPropertyValue error");
+ return 0;
+ }
+ string = ConvertPropertyToString(property, propID, false);
+ }
+ }
+ */
+ // const NFind::CFileInfo &aFileInfo = m_Files[index];
+
+ NCOM::CPropVariant prop;
+ /*
+ bool needRead = true;
+ if (propID == kpidSize)
+ {
+ CComPtr<IFolderGetItemFullSize> getItemFullSize;
+ if (_folder.QueryInterface(&getItemFullSize) == S_OK)
+ {
+ if (getItemFullSize->GetItemFullSize(index, &prop) == S_OK)
+ needRead = false;
+ }
+ }
+ if (needRead)
+ */
+
+ if (_folder->GetProperty(realIndex, propID, &prop) != S_OK)
+ throw 2723407;
+
+ if ((propID == kpidSize || propID == kpidPackSize || propID == kpidClusterSize ||
+ propID == kpidNumSubDirs || propID == kpidNumSubFiles) &&
+ (prop.vt == VT_UI8 || prop.vt == VT_UI4))
+ s = ConvertSizeToString(ConvertPropVariantToUInt64(prop));
+ else if ((propID == kpidTotalSize || propID == kpidFreeSpace) &&
+ (prop.vt == VT_UI8 || prop.vt == VT_UI4))
+ s = ConvertSizeToStringShort(ConvertPropVariantToUInt64(prop));
+ else
+ {
+ s = ConvertPropertyToString(prop, propID, false);
+ s.Replace(wchar_t(0xA), L' ');
+ s.Replace(wchar_t(0xD), L' ');
+ }
+ int size = item.cchTextMax;
+ if(size > 0)
+ {
+ if(s.Length() + 1 > size)
+ s = s.Left(size - 1);
+ MyStringCopy(item.pszText, (const wchar_t *)s);
+ }
+ return 0;
+}
+
+#ifdef _WIN32
+extern DWORD g_ComCtl32Version;
+#endif
+
+void CPanel::OnItemChanged(NMLISTVIEW *item)
+{
+ int index = (int)item->lParam;
+ if (index == kParentIndex)
+ return;
+ bool oldSelected = (item->uOldState & LVIS_SELECTED) != 0;
+ bool newSelected = (item->uNewState & LVIS_SELECTED) != 0;
+ // Don't change this code. It works only with such check
+ printf("CPanel::OnItemChanged : index=%d oldSel=%d newSel=%d\n",index,(int)oldSelected,(int)newSelected);
+ if(oldSelected != newSelected) {
+ printf("CPanel::OnItemChanged : _selectedStatusVector[%d] = %d\n",index,(int)newSelected);
+ _selectedStatusVector[index] = newSelected;
+ }
+}
+
+bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
+{
+ printf("CPanel::OnNotifyList : FIXME\n");
+ // bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ // bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ // bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ switch(header->code)
+ {
+ case LVN_ITEMCHANGED:
+ {
+ if (_enableItemChangeNotify)
+ {
+ if (!_mySelectMode)
+ OnItemChanged((LPNMLISTVIEW)header);
+ RefreshStatusBar();
+ }
+ return false;
+ }
+ /*
+
+ case LVN_ODSTATECHANGED:
+ {
+ break;
+ }
+ */
+
+#ifdef _WIN32
+ case LVN_GETDISPINFOW:
+ {
+ LV_DISPINFOW *dispInfo = (LV_DISPINFOW *)header;
+
+ //is the sub-item information being requested?
+
+ if((dispInfo->item.mask & LVIF_TEXT) != 0 ||
+ (dispInfo->item.mask & LVIF_IMAGE) != 0)
+ SetItemText(dispInfo->item);
+ return false;
+ }
+ case LVN_KEYDOWN:
+ {
+ bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result);
+ RefreshStatusBar();
+ return boolResult;
+ }
+#endif
+
+ case LVN_COLUMNCLICK:
+ OnColumnClick(LPNMLISTVIEW(header));
+ return false;
+ /*
+ case LVN_ITEMACTIVATE:
+ RefreshStatusBar();
+ if (!alt && !ctrl && !shift)
+ OpenSelectedItems(true);
+ return false;
+ */
+
+ case NM_DBLCLK:
+ RefreshStatusBar();
+ OpenSelectedItems(true);
+ return false;
+#ifdef _WIN32
+ case NM_RETURN:
+ {
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
+ // bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ if (!shift && alt && !ctrl)
+ {
+ Properties();
+ return false;
+ }
+ OpenSelectedItems(true);
+ return false;
+ }
+ case NM_RCLICK:
+ RefreshStatusBar();
+ break;
+
+ /*
+ return OnRightClick((LPNMITEMACTIVATE)header, result);
+ */
+ /*
+ case NM_CLICK:
+ SendRefreshStatusBarMessage();
+ return 0;
+
+ // TODO : Handler default action...
+ return 0;
+ case LVN_ITEMCHANGED:
+ {
+ NMLISTVIEW *pNMLV = (NMLISTVIEW *) lpnmh;
+ SelChange(pNMLV);
+ return TRUE;
+ }
+ case NM_SETFOCUS:
+ return onSetFocus(NULL);
+ case NM_KILLFOCUS:
+ return onKillFocus(NULL);
+ */
+ case NM_CLICK:
+ {
+ // we need SetFocusToList, if we drag-select items from other panel.
+ SetFocusToList();
+ RefreshStatusBar();
+ if(_mySelectMode)
+ if(g_ComCtl32Version >= MAKELONG(71, 4))
+ OnLeftClick((LPNMITEMACTIVATE)header);
+ return false;
+ }
+ case LVN_BEGINLABELEDITW:
+ result = OnBeginLabelEdit((LV_DISPINFOW *)header);
+ return true;
+ case LVN_ENDLABELEDITW:
+ result = OnEndLabelEdit((LV_DISPINFOW *)header);
+ return true;
+
+ case NM_CUSTOMDRAW:
+ {
+ if (_mySelectMode)
+ return OnCustomDraw((LPNMLVCUSTOMDRAW)header, result);
+ break;
+ }
+ case LVN_BEGINDRAG:
+ {
+ OnDrag((LPNMLISTVIEW)header);
+ RefreshStatusBar();
+ break;
+ }
+#endif
+ // case LVN_BEGINRDRAG:
+ }
+ return false;
+}
+
+#ifdef _WIN32
+bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result)
+{
+ switch(lplvcd->nmcd.dwDrawStage)
+ {
+ case CDDS_PREPAINT :
+ result = CDRF_NOTIFYITEMDRAW;
+ return true;
+
+ case CDDS_ITEMPREPAINT:
+ /*
+ SelectObject(lplvcd->nmcd.hdc,
+ GetFontForItem(lplvcd->nmcd.dwItemSpec,
+ lplvcd->nmcd.lItemlParam) );
+ lplvcd->clrText = GetColorForItem(lplvcd->nmcd.dwItemSpec,
+ lplvcd->nmcd.lItemlParam);
+ lplvcd->clrTextBk = GetBkColorForItem(lplvcd->nmcd.dwItemSpec,
+ lplvcd->nmcd.lItemlParam);
+ */
+ int realIndex = (int)lplvcd->nmcd.lItemlParam;
+ bool selected = false;
+ if (realIndex != kParentIndex)
+ selected = _selectedStatusVector[realIndex];
+ if (selected)
+ lplvcd->clrTextBk = RGB(255, 192, 192);
+ // lplvcd->clrText = RGB(255, 0, 128);
+ else
+ lplvcd->clrTextBk = _listView.GetBkColor();
+ // lplvcd->clrText = RGB(0, 0, 0);
+ // result = CDRF_NEWFONT;
+ result = CDRF_NOTIFYITEMDRAW;
+ return true;
+
+ // return false;
+ // return true;
+ /*
+ case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
+ if (lplvcd->iSubItem == 0)
+ {
+ // lplvcd->clrText = RGB(255, 0, 0);
+ lplvcd->clrTextBk = RGB(192, 192, 192);
+ }
+ else
+ {
+ lplvcd->clrText = RGB(0, 0, 0);
+ lplvcd->clrTextBk = RGB(255, 255, 255);
+ }
+ return true;
+ */
+
+ /* At this point, you can change the background colors for the item
+ and any subitems and return CDRF_NEWFONT. If the list-view control
+ is in report mode, you can simply return CDRF_NOTIFYSUBITEMREDRAW
+ to customize the item's subitems individually */
+ }
+ return false;
+}
+#endif //#ifdef _WIN32
+
+void CPanel::OnRefreshStatusBar()
+{
+ CRecordVector<UINT32> indices;
+ GetOperatedItemIndices(indices);
+
+ _statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, 0x02000301, NumberToString(indices.Size())));
+
+ UString selectSizeString;
+
+ if (indices.Size() > 0)
+ {
+ UInt64 totalSize = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ totalSize += GetItemSize(indices[i]);
+ selectSizeString = ConvertSizeToString(totalSize);
+ }
+ _statusBar.SetText(1, selectSizeString);
+
+ int focusedItem = _listView.GetFocusedItem();
+ UString sizeString;
+ UString dateString;
+ if (focusedItem >= 0 && _listView.GetSelectedCount() > 0)
+ {
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex != kParentIndex)
+ {
+ sizeString = ConvertSizeToString(GetItemSize(realIndex));
+ NCOM::CPropVariant prop;
+ if (_folder->GetProperty(realIndex, kpidMTime, &prop) == S_OK)
+ dateString = ConvertPropertyToString(prop, kpidMTime, false);
+ }
+ }
+ _statusBar.SetText(2, sizeString);
+ _statusBar.SetText(3, dateString);
+ // _statusBar.SetText(4, nameString);
+ // _statusBar2.SetText(1, MyFormatNew(L"{0} bytes", NumberToStringW(totalSize)));
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelMenu.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelMenu.cpp
new file mode 100644
index 000000000..55ac88b96
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelMenu.cpp
@@ -0,0 +1,621 @@
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/COM.h"
+#include "Windows/Clipboard.h"
+// FIXME #include "Windows/Menu.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../Common/PropIDUtils.h"
+#include "../../PropID.h"
+
+#include "App.h"
+#include "LangUtils.h"
+#include "MyLoadMenu.h"
+#include "PluginInterface.h"
+#include "PropertyName.h"
+
+#include "resource.h"
+#include "PropertyNameRes.h"
+
+using namespace NWindows;
+
+// {23170F69-40C1-278A-1000-000100020000}
+DEFINE_GUID(CLSID_CZipContextMenu,
+0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
+
+static const UINT kSevenZipStartMenuID = kPluginMenuStartID ;
+static const UINT kSystemStartMenuID = kPluginMenuStartID + 100;
+
+void CPanel::InvokeSystemCommand(const char *command)
+{
+#ifdef _WIN32
+ NCOM::CComInitializer comInitializer;
+ if (!IsFsOrPureDrivesFolder())
+ return;
+ CRecordVector<UInt32> operatedIndices;
+ GetOperatedItemIndices(operatedIndices);
+ if (operatedIndices.IsEmpty())
+ return;
+ CMyComPtr<IContextMenu> contextMenu;
+ if (CreateShellContextMenu(operatedIndices, contextMenu) != S_OK)
+ return;
+
+ CMINVOKECOMMANDINFO ci;
+ ZeroMemory(&ci, sizeof(ci));
+ ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
+ ci.hwnd = GetParent();
+ ci.lpVerb = command;
+ contextMenu->InvokeCommand(&ci);
+#endif
+}
+
+static const wchar_t *kSeparator = L"--------------------------------------\n";
+static const wchar_t *kPropValueSeparator = L": ";
+
+extern UString ConvertSizeToString(UInt64 value);
+
+static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
+ const NCOM::CPropVariant &prop, UString &s)
+{
+ if (prop.vt != VT_EMPTY)
+ {
+ UString val;
+
+ if ((prop.vt == VT_UI8 || prop.vt == VT_UI4) && (
+ propID == kpidSize ||
+ propID == kpidPackSize ||
+ propID == kpidNumSubDirs ||
+ propID == kpidNumSubFiles ||
+ propID == kpidNumBlocks ||
+ propID == kpidClusterSize ||
+ propID == kpidTotalSize ||
+ propID == kpidFreeSpace ||
+ propID == kpidPhySize ||
+ propID == kpidHeadersSize ||
+ propID == kpidFreeSpace
+ ))
+ val = ConvertSizeToString(ConvertPropVariantToUInt64(prop));
+ else
+ val = ConvertPropertyToString(prop, propID);
+
+ if (!val.IsEmpty())
+ {
+ s += GetNameOfProperty(propID, nameBSTR);
+ s += kPropValueSeparator;
+ /*
+ if (propID == kpidComment)
+ s += L'\n';
+ */
+ s += val;
+ s += L'\n';
+ }
+ }
+}
+
+void CPanel::Properties()
+{
+ CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties;
+ _folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties);
+ if (!getFolderArchiveProperties)
+ {
+ InvokeSystemCommand("properties");
+ return;
+ }
+
+ {
+ UString message;
+
+ CRecordVector<UInt32> operatedIndices;
+ GetOperatedItemIndices(operatedIndices);
+ if (operatedIndices.Size() == 1)
+ {
+ UInt32 index = operatedIndices[0];
+ // message += L"Item:\n";
+ UInt32 numProps;
+ if (_folder->GetNumberOfProperties(&numProps) == S_OK)
+ {
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE varType;
+
+ if (_folder->GetPropertyInfo(i, &name, &propID, &varType) != S_OK)
+ continue;
+
+ NCOM::CPropVariant prop;
+ if (_folder->GetProperty(index, propID, &prop) != S_OK)
+ continue;
+ AddPropertyString(propID, name, prop, message);
+ }
+ }
+ message += kSeparator;
+ }
+
+ message += LangString(IDS_PROP_FILE_TYPE, 0x02000214);
+ message += kPropValueSeparator;
+ message += GetFolderTypeID();
+ message += L"\n";
+
+ {
+ NCOM::CPropVariant prop;
+ if (_folder->GetFolderProperty(kpidPath, &prop) == S_OK)
+ {
+ AddPropertyString(kpidName, L"Path", prop, message);
+ }
+ }
+
+ CMyComPtr<IFolderProperties> folderProperties;
+ _folder.QueryInterface(IID_IFolderProperties, &folderProperties);
+ if (folderProperties)
+ {
+ UInt32 numProps;
+ if (folderProperties->GetNumberOfFolderProperties(&numProps) == S_OK)
+ {
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ if (folderProperties->GetFolderPropertyInfo(i, &name, &propID, &vt) != S_OK)
+ continue;
+ NCOM::CPropVariant prop;
+ if (_folder->GetFolderProperty(propID, &prop) != S_OK)
+ continue;
+ AddPropertyString(propID, name, prop, message);
+ }
+ }
+ }
+
+ CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties;
+ _folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties);
+ if (getFolderArchiveProperties)
+ {
+ CMyComPtr<IFolderArchiveProperties> getProps;
+ getFolderArchiveProperties->GetFolderArchiveProperties(&getProps);
+ if (getProps)
+ {
+ UInt32 numProps;
+ if (getProps->GetNumberOfArchiveProperties(&numProps) == S_OK)
+ {
+ if (numProps > 0)
+ message += kSeparator;
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ if (getProps->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK)
+ continue;
+ NCOM::CPropVariant prop;
+ if (getProps->GetArchiveProperty(propID, &prop) != S_OK)
+ continue;
+ AddPropertyString(propID, name, prop, message);
+ }
+ }
+ }
+ }
+ ::MessageBoxW(*(this), message, LangString(IDS_PROPERTIES, 0x03020900), MB_OK);
+ }
+}
+
+void CPanel::EditCut()
+{
+ // InvokeSystemCommand("cut");
+}
+
+void CPanel::EditCopy()
+{
+ /*
+ CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties;
+ _folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties);
+ if (!getFolderArchiveProperties)
+ {
+ InvokeSystemCommand("copy");
+ return;
+ }
+ */
+ UString s;
+ CRecordVector<UInt32> indices;
+ GetSelectedItemsIndices(indices);
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ if (i > 0)
+ s += L"\xD\n";
+ s += GetItemName(indices[i]);
+ }
+ ClipboardSetText(_mainWindow, s);
+}
+
+void CPanel::EditPaste()
+{
+ /*
+ UStringVector names;
+ ClipboardGetFileNames(names);
+ CopyFromNoAsk(names);
+ UString s;
+ for (int i = 0; i < names.Size(); i++)
+ {
+ s += L" ";
+ s += names[i];
+ }
+
+ MessageBoxW(0, s, L"", 0);
+ */
+
+ // InvokeSystemCommand("paste");
+}
+
+#ifdef _WIN32
+HRESULT CPanel::CreateShellContextMenu(
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu)
+{
+ systemContextMenu.Release();
+ UString folderPath = GetFsPath();
+
+ CMyComPtr<IShellFolder> desktopFolder;
+ RINOK(::SHGetDesktopFolder(&desktopFolder));
+ if (!desktopFolder)
+ {
+ // ShowMessage("Failed to get Desktop folder.");
+ return E_FAIL;
+ }
+
+ // Separate the file from the folder.
+
+
+ // Get a pidl for the folder the file
+ // is located in.
+ LPITEMIDLIST parentPidl;
+ DWORD eaten;
+ RINOK(desktopFolder->ParseDisplayName(
+ GetParent(), 0, (wchar_t *)(const wchar_t *)folderPath,
+ &eaten, &parentPidl, 0));
+
+ // Get an IShellFolder for the folder
+ // the file is located in.
+ CMyComPtr<IShellFolder> parentFolder;
+ RINOK(desktopFolder->BindToObject(parentPidl,
+ 0, IID_IShellFolder, (void**)&parentFolder));
+ if (!parentFolder)
+ {
+ // ShowMessage("Invalid file name.");
+ return E_FAIL;
+ }
+
+ // Get a pidl for the file itself.
+ CRecordVector<LPITEMIDLIST> pidls;
+ pidls.Reserve(operatedIndices.Size());
+ for (int i = 0; i < operatedIndices.Size(); i++)
+ {
+ LPITEMIDLIST pidl;
+ UString fileName = GetItemRelPath(operatedIndices[i]);
+ if (IsFSDrivesFolder())
+ fileName += WCHAR_PATH_SEPARATOR;
+ RINOK(parentFolder->ParseDisplayName(GetParent(), 0,
+ (wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0));
+ pidls.Add(pidl);
+ }
+
+ ITEMIDLIST temp;
+ if (pidls.Size() == 0)
+ {
+ temp.mkid.cb = 0;
+ /*
+ LPITEMIDLIST pidl;
+ HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0,
+ L"." WSTRING_PATH_SEPARATOR, &eaten, &pidl, 0);
+ if (result != NOERROR)
+ return;
+ */
+ pidls.Add(&temp);
+ }
+
+ // Get the IContextMenu for the file.
+ CMyComPtr<IContextMenu> cm;
+ RINOK( parentFolder->GetUIObjectOf(GetParent(), pidls.Size(),
+ (LPCITEMIDLIST *)&pidls.Front(), IID_IContextMenu, 0, (void**)&cm));
+ if (!cm)
+ {
+ // ShowMessage("Unable to get context menu interface.");
+ return E_FAIL;
+ }
+ systemContextMenu = cm;
+ return S_OK;
+}
+
+void CPanel::CreateSystemMenu(HMENU menuSpec,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu)
+{
+ systemContextMenu.Release();
+
+ CreateShellContextMenu(operatedIndices, systemContextMenu);
+
+ if (systemContextMenu == 0)
+ return;
+
+ // Set up a CMINVOKECOMMANDINFO structure.
+ CMINVOKECOMMANDINFO ci;
+ ZeroMemory(&ci, sizeof(ci));
+ ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
+ ci.hwnd = GetParent();
+
+ /*
+ if (Sender == GoBtn)
+ {
+ // Verbs that can be used are cut, paste,
+ // properties, delete, and so on.
+ String action;
+ if (CutRb->Checked)
+ action = "cut";
+ else if (CopyRb->Checked)
+ action = "copy";
+ else if (DeleteRb->Checked)
+ action = "delete";
+ else if (PropertiesRb->Checked)
+ action = "properties";
+
+ ci.lpVerb = action.c_str();
+ result = cm->InvokeCommand(&ci);
+ if (result)
+ ShowMessage(
+ "Error copying file to clipboard.");
+
+ }
+ else
+ */
+ {
+ // HMENU hMenu = CreatePopupMenu();
+ CMenu popupMenu;
+ // CMenuDestroyer menuDestroyer(popupMenu);
+ if(!popupMenu.CreatePopup())
+ throw 210503;
+
+ HMENU hMenu = popupMenu;
+
+ DWORD Flags = CMF_EXPLORE;
+ // Optionally the shell will show the extended
+ // context menu on some operating systems when
+ // the shift key is held down at the time the
+ // context menu is invoked. The following is
+ // commented out but you can uncommnent this
+ // line to show the extended context menu.
+ // Flags |= 0x00000080;
+ systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, Flags);
+
+
+ {
+ CMenu menu;
+ menu.Attach(menuSpec);
+ CMenuItem menuItem;
+ menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
+ menuItem.fType = MFT_STRING;
+ menuItem.hSubMenu = popupMenu.Detach();
+ // menuDestroyer.Disable();
+ menuItem.StringValue = LangString(IDS_SYSTEM, 0x030202A0);
+ menu.InsertItem(0, true, menuItem);
+ }
+ /*
+ if (Cmd < 100 && Cmd != 0)
+ {
+ ci.lpVerb = MAKEINTRESOURCE(Cmd - 1);
+ ci.lpParameters = "";
+ ci.lpDirectory = "";
+ ci.nShow = SW_SHOWNORMAL;
+ cm->InvokeCommand(&ci);
+ }
+ // If Cmd is > 100 then it's one of our
+ // inserted menu items.
+ else
+ // Find the menu item.
+ for (int i = 0; i < popupMenu1->Items->Count; i++)
+ {
+ TMenuItem* menu = popupMenu1->Items->Items[i];
+ // Call its OnClick handler.
+ if (menu->Command == Cmd - 100)
+ menu->OnClick(this);
+ }
+ // Release the memory allocated for the menu.
+ DestroyMenu(hMenu);
+ */
+ }
+}
+
+void CPanel::CreateFileMenu(HMENU menuSpec)
+{
+ CreateFileMenu(menuSpec, _sevenZipContextMenu, _systemContextMenu, true);
+}
+
+void CPanel::CreateSevenZipMenu(HMENU menuSpec,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &sevenZipContextMenu)
+{
+ sevenZipContextMenu.Release();
+
+ CMenu menu;
+ menu.Attach(menuSpec);
+ // CMenuDestroyer menuDestroyer(menu);
+ // menu.CreatePopup();
+
+ bool sevenZipMenuCreated = false;
+
+ CMyComPtr<IContextMenu> contextMenu;
+ if (contextMenu.CoCreateInstance(CLSID_CZipContextMenu, IID_IContextMenu) == S_OK)
+ {
+ CMyComPtr<IInitContextMenu> initContextMenu;
+ if (contextMenu.QueryInterface(IID_IInitContextMenu, &initContextMenu) != S_OK)
+ return;
+ UString currentFolderUnicode = _currentFolderPrefix;
+ UStringVector names;
+ int i;
+ for(i = 0; i < operatedIndices.Size(); i++)
+ names.Add(currentFolderUnicode + GetItemRelPath(operatedIndices[i]));
+ CRecordVector<const wchar_t *> namePointers;
+ for(i = 0; i < operatedIndices.Size(); i++)
+ namePointers.Add(names[i]);
+
+ // NFile::NDirectory::MySetCurrentDirectory(currentFolderUnicode);
+ if (initContextMenu->InitContextMenu(currentFolderUnicode, &namePointers.Front(),
+ operatedIndices.Size()) == S_OK)
+ {
+ HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID,
+ kSystemStartMenuID - 1, 0);
+ sevenZipMenuCreated = (HRESULT_SEVERITY(res) == SEVERITY_SUCCESS);
+ if (sevenZipMenuCreated)
+ sevenZipContextMenu = contextMenu;
+ // int code = HRESULT_CODE(res);
+ // int nextItemID = code;
+ }
+ }
+}
+
+void CPanel::CreateFileMenu(HMENU menuSpec,
+ CMyComPtr<IContextMenu> &sevenZipContextMenu,
+ CMyComPtr<IContextMenu> &systemContextMenu,
+ bool programMenu)
+{
+ sevenZipContextMenu.Release();
+ systemContextMenu.Release();
+
+ CRecordVector<UInt32> operatedIndices;
+ GetOperatedItemIndices(operatedIndices);
+
+ CMenu menu;
+ menu.Attach(menuSpec);
+
+ CreateSevenZipMenu(menu, operatedIndices, sevenZipContextMenu);
+ if (g_App.ShowSystemMenu)
+ CreateSystemMenu(menu, operatedIndices, systemContextMenu);
+
+ if (menu.GetItemCount() > 0)
+ menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0);
+
+ int i;
+ for (i = 0; i < operatedIndices.Size(); i++)
+ if (IsItemFolder(operatedIndices[i]))
+ break;
+ bool allAreFiles = (i == operatedIndices.Size());
+ LoadFileMenu(menu, menu.GetItemCount(), programMenu,
+ IsFSFolder(), operatedIndices.Size(), allAreFiles);
+}
+
+bool CPanel::InvokePluginCommand(int id)
+{
+ return InvokePluginCommand(id, _sevenZipContextMenu, _systemContextMenu);
+}
+
+bool CPanel::InvokePluginCommand(int id,
+ IContextMenu *sevenZipContextMenu, IContextMenu *systemContextMenu)
+{
+ UInt32 offset;
+ bool isSystemMenu = (id >= kSystemStartMenuID);
+ if (isSystemMenu)
+ offset = id - kSystemStartMenuID;
+ else
+ offset = id - kSevenZipStartMenuID;
+
+ CMINVOKECOMMANDINFOEX commandInfo;
+ commandInfo.cbSize = sizeof(commandInfo);
+ commandInfo.fMask = CMIC_MASK_UNICODE;
+ commandInfo.hwnd = GetParent();
+ commandInfo.lpVerb = (LPCSTR)(MAKEINTRESOURCE(offset));
+ commandInfo.lpParameters = NULL;
+ CSysString currentFolderSys = GetSystemString(_currentFolderPrefix);
+ commandInfo.lpDirectory = (LPCSTR)(LPCTSTR)(currentFolderSys);
+ commandInfo.nShow = SW_SHOW;
+ commandInfo.lpTitle = "";
+ commandInfo.lpVerbW = (LPCWSTR)(MAKEINTRESOURCEW(offset));
+ commandInfo.lpParameters = NULL;
+ UString currentFolderUnicode = _currentFolderPrefix;
+ commandInfo.lpDirectoryW = currentFolderUnicode;
+ commandInfo.lpTitleW = L"";
+ // commandInfo.ptInvoke.x = xPos;
+ // commandInfo.ptInvoke.y = yPos;
+ commandInfo.ptInvoke.x = 0;
+ commandInfo.ptInvoke.y = 0;
+ HRESULT result;
+ if (isSystemMenu)
+ result = systemContextMenu->InvokeCommand(LPCMINVOKECOMMANDINFO(&commandInfo));
+ else
+ result = sevenZipContextMenu->InvokeCommand(LPCMINVOKECOMMANDINFO(&commandInfo));
+ if (result == NOERROR)
+ {
+ KillSelection();
+ return true;
+ }
+ return false;
+}
+
+bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos)
+{
+ if (windowHandle != _listView)
+ return false;
+ /*
+ POINT point;
+ point.x = xPos;
+ point.y = yPos;
+ if (!_listView.ScreenToClient(&point))
+ return false;
+
+ LVHITTESTINFO info;
+ info.pt = point;
+ int index = _listView.HitTest(&info);
+ */
+
+ CRecordVector<UInt32> operatedIndices;
+ GetOperatedItemIndices(operatedIndices);
+
+ if (xPos < 0 || yPos < 0)
+ {
+ if (operatedIndices.Size() == 0)
+ {
+ xPos = 0;
+ yPos = 0;
+ }
+ else
+ {
+ int itemIndex = _listView.GetNextItem(-1, LVNI_FOCUSED);
+ if (itemIndex == -1)
+ return false;
+ RECT rect;
+ if (!_listView.GetItemRect(itemIndex, &rect, LVIR_ICON))
+ return false;
+ xPos = (rect.left + rect.right) / 2;
+ yPos = (rect.top + rect.bottom) / 2;
+ }
+ POINT point = {xPos, yPos};
+ _listView.ClientToScreen(&point);
+ xPos = point.x;
+ yPos = point.y;
+ }
+
+ CMenu menu;
+ CMenuDestroyer menuDestroyer(menu);
+ menu.CreatePopup();
+
+ CMyComPtr<IContextMenu> sevenZipContextMenu;
+ CMyComPtr<IContextMenu> systemContextMenu;
+ CreateFileMenu(menu, sevenZipContextMenu, systemContextMenu, false);
+
+ int result = menu.Track(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY,
+ xPos, yPos, _listView);
+
+ if (result == 0)
+ return true;
+
+ if (result >= kPluginMenuStartID)
+ {
+ InvokePluginCommand(result, sevenZipContextMenu, systemContextMenu);
+ return true;
+ }
+ if (ExecuteFileCommand(result))
+ return true;
+ return true;
+}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelOperations.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelOperations.cpp
new file mode 100644
index 000000000..5a0d052c4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelOperations.cpp
@@ -0,0 +1,470 @@
+// PanelOperations.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Panel.h"
+
+#include "Common/StringConvert.h"
+#include "Common/DynamicBuffer.h"
+#include "Windows/FileDir.h"
+#include "Windows/ResourceString.h"
+#include "Windows/Thread.h"
+#include "Windows/COM.h"
+
+#include "ComboDialog.h"
+
+#include "FSFolder.h"
+#include "LangUtils.h"
+#include "FormatUtils.h"
+
+#include "UpdateCallback100.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+enum EFolderOpType
+{
+ FOLDER_TYPE_CREATE_FOLDER = 0,
+ FOLDER_TYPE_DELETE = 1,
+ FOLDER_TYPE_RENAME = 2
+};
+
+struct CThreadFolderOperations
+{
+ EFolderOpType OpType;
+ UString Name;
+ UInt32 Index;
+ CRecordVector<UInt32> Indices;
+
+ CMyComPtr<IFolderOperations> FolderOperations;
+ CMyComPtr<IProgress> UpdateCallback;
+ CUpdateCallback100Imp *UpdateCallbackSpec;
+ HRESULT Result;
+
+ CThreadFolderOperations(EFolderOpType opType);
+
+ void Process()
+ {
+#ifdef _WIN32
+ NCOM::CComInitializer comInitializer;
+#endif
+ UpdateCallbackSpec->ProgressDialog.WaitCreating();
+
+ switch(OpType)
+ {
+ case FOLDER_TYPE_CREATE_FOLDER:
+ Result = FolderOperations->CreateFolder(Name, UpdateCallback);
+ break;
+ case FOLDER_TYPE_DELETE:
+ Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback);
+ break;
+ case FOLDER_TYPE_RENAME:
+ Result = FolderOperations->Rename(Index, Name, UpdateCallback);
+ break;
+ default:
+ Result = E_FAIL;
+ }
+ UpdateCallbackSpec->ProgressDialog.MyClose();
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadFolderOperations *)param)->Process();
+ return 0;
+ }
+};
+
+CThreadFolderOperations::CThreadFolderOperations(EFolderOpType opType): OpType(opType) {};
+
+static void DoOperation(CThreadFolderOperations &op, CPanel &panel, const UString &progressTitle)
+{
+ op.UpdateCallbackSpec = new CUpdateCallback100Imp;
+ op.UpdateCallback = op.UpdateCallbackSpec;
+
+ bool usePassword = false;
+ UString password;
+ if (panel._parentFolders.Size() > 0)
+ {
+ const CFolderLink &fl = panel._parentFolders.Back();
+ usePassword = fl.UsePassword;
+ password = fl.Password;
+ }
+
+ op.UpdateCallbackSpec->Init(panel.GetParent(), usePassword, password);
+
+ op.UpdateCallbackSpec->ProgressDialog.MainWindow = panel._mainWindow;
+ op.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ op.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
+
+ // op.FolderOperations = folderOperations;
+ // op.Index = realIndex;
+ // op.Name = newName;
+ // HRESULT result = folderOperations->Rename(realIndex, newName, 0);
+
+ NWindows::CThread thread;
+ if (thread.Create(CThreadFolderOperations::MyThreadFunction, &op) != S_OK)
+ throw 271824;
+ op.UpdateCallbackSpec->StartProgressDialog(progressTitle);
+}
+
+#ifndef _UNICODE
+typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp);
+#endif
+
+void CPanel::DeleteItems(bool toRecycleBin)
+{
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+ CSelectedState state;
+ SaveSelectedState(state);
+ bool useInternalDelete = false;
+ if (IsFSFolder() && toRecycleBin)
+ {
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ CDynamicBuffer<CHAR> buffer;
+ size_t size = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ const AString path = GetSystemString(GetFsPath() + GetItemRelPath(indices[i]));
+ buffer.EnsureCapacity(size + path.Length() + 1);
+ memmove(((CHAR *)buffer) + size, (const CHAR *)path, (path.Length() + 1) * sizeof(CHAR));
+ size += path.Length() + 1;
+ }
+ buffer.EnsureCapacity(size + 1);
+ ((CHAR *)buffer)[size] = 0;
+ SHFILEOPSTRUCTA fo;
+ fo.hwnd = GetParent();
+ fo.wFunc = FO_DELETE;
+ fo.pFrom = (const CHAR *)buffer;
+ fo.pTo = 0;
+ fo.fFlags = 0;
+ if (toRecycleBin)
+ fo.fFlags |= FOF_ALLOWUNDO;
+ // fo.fFlags |= FOF_NOCONFIRMATION;
+ // fo.fFlags |= FOF_NOERRORUI;
+ // fo.fFlags |= FOF_SILENT;
+ // fo.fFlags |= FOF_WANTNUKEWARNING;
+ fo.fAnyOperationsAborted = FALSE;
+ fo.hNameMappings = 0;
+ fo.lpszProgressTitle = 0;
+ /* int res = */ ::SHFileOperationA(&fo);
+ }
+ else
+ #endif
+ {
+ CDynamicBuffer<WCHAR> buffer;
+ size_t size = 0;
+ int maxLen = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ // L"\\\\?\\") doesn't work here.
+ const UString path = GetFsPath() + GetItemRelPath(indices[i]);
+ if (path.Length() > maxLen)
+ maxLen = path.Length();
+ buffer.EnsureCapacity(size + path.Length() + 1);
+ memmove(((WCHAR *)buffer) + size, (const WCHAR *)path, (path.Length() + 1) * sizeof(WCHAR));
+ size += path.Length() + 1;
+ }
+ buffer.EnsureCapacity(size + 1);
+ ((WCHAR *)buffer)[size] = 0;
+#ifdef _WIN32
+ if (maxLen >= MAX_PATH)
+ {
+ if (toRecycleBin)
+ {
+ MessageBoxErrorLang(IDS_ERROR_LONG_PATH_TO_RECYCLE, 0x03020218);
+ return;
+ }
+ useInternalDelete = true;
+ }
+ else
+ {
+ SHFILEOPSTRUCTW fo;
+ fo.hwnd = GetParent();
+ fo.wFunc = FO_DELETE;
+ fo.pFrom = (const WCHAR *)buffer;
+ fo.pTo = 0;
+ fo.fFlags = 0;
+ if (toRecycleBin)
+ fo.fFlags |= FOF_ALLOWUNDO;
+ fo.fAnyOperationsAborted = FALSE;
+ fo.hNameMappings = 0;
+ fo.lpszProgressTitle = 0;
+ int res;
+ #ifdef _UNICODE
+ res = ::SHFileOperationW(&fo);
+ #else
+ SHFileOperationWP shFileOperationW = (SHFileOperationWP)
+ ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHFileOperationW");
+ if (shFileOperationW == 0)
+ return;
+ res = shFileOperationW(&fo);
+ #endif
+ }
+#else
+ // FIXME - how to use the recycle bin undex Gnome or KDE ?
+ useInternalDelete = true;
+#endif
+ }
+ /*
+ if (fo.fAnyOperationsAborted)
+ MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
+ */
+ }
+ else
+ useInternalDelete = true;
+ if (useInternalDelete)
+ DeleteItemsInternal(indices);
+ RefreshListCtrl(state);
+}
+
+void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+
+ UString title;
+ UString message;
+ if (indices.Size() == 1)
+ {
+ int index = indices[0];
+ const UString itemName = GetItemRelPath(index);
+ if (IsItemFolder(index))
+ {
+ title = LangString(IDS_CONFIRM_FOLDER_DELETE, 0x03020211);
+ message = MyFormatNew(IDS_WANT_TO_DELETE_FOLDER, 0x03020214, itemName);
+ }
+ else
+ {
+ title = LangString(IDS_CONFIRM_FILE_DELETE, 0x03020210);
+ message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName);
+ }
+ }
+ else
+ {
+ title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
+ message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215,
+ NumberToString(indices.Size()));
+ }
+ if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK)
+ return;
+
+ {
+ CThreadFolderOperations op(FOLDER_TYPE_DELETE);
+ op.FolderOperations = folderOperations;
+ op.Indices = indices;
+ DoOperation(op, *this, LangString(IDS_DELETING, 0x03020216));
+ if (op.Result != S_OK)
+ MessageBoxError(op.Result, LangString(IDS_ERROR_DELETING, 0x03020217));
+ }
+ RefreshTitleAlways();
+}
+
+#ifdef _WIN32
+BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
+{
+ int realIndex = GetRealIndex(lpnmh->item);
+ if (realIndex == kParentIndex)
+ return TRUE;
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ return TRUE;
+ return FALSE;
+}
+
+BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
+{
+ if (lpnmh->item.pszText == NULL)
+ return FALSE;
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return FALSE;
+ }
+ const UString newName = lpnmh->item.pszText;
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+
+ SaveSelectedState(_selectedState);
+
+ int realIndex = GetRealIndex(lpnmh->item);
+ if (realIndex == kParentIndex)
+ return FALSE;
+ const UString prefix = GetItemPrefix(realIndex);
+
+
+ {
+ CThreadFolderOperations op(FOLDER_TYPE_RENAME);
+ op.FolderOperations = folderOperations;
+ op.Index = realIndex;
+ op.Name = newName;
+ DoOperation(op, *this, LangString(IDS_RENAMING, 0x03020220));
+ if (op.Result != S_OK)
+ {
+ MessageBoxError(op.Result, LangString(IDS_ERROR_RENAMING, 0x03020221));
+ return FALSE;
+ }
+ }
+
+ // Can't use RefreshListCtrl here.
+ // RefreshListCtrlSaveFocused();
+ _selectedState.FocusedName = prefix + newName;
+ _selectedState.SelectFocused = true;
+
+ // We need clear all items to disable GetText before Reload:
+ // number of items can change.
+ // _listView.DeleteAllItems();
+ // But seems it can still call GetText (maybe for current item)
+ // so we can't delete items.
+
+ _dontShowMode = true;
+
+ PostMessage(kReLoadMessage);
+ return TRUE;
+}
+#endif
+
+void CPanel::CreateFolder()
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ CSelectedState state;
+ SaveSelectedState(state);
+ CComboDialog comboDialog;
+ comboDialog.Title = LangString(IDS_CREATE_FOLDER, 0x03020230);
+ comboDialog.Static = LangString(IDS_CREATE_FOLDER_NAME, 0x03020231);
+ comboDialog.Value = LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+
+ UString newName = comboDialog.Value;
+
+ {
+ CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER);
+ op.FolderOperations = folderOperations;
+ op.Name = newName;
+ DoOperation(op, *this, LangString(IDS_CREATE_FOLDER, 0x03020230));
+
+ if (op.Result != S_OK)
+ {
+ MessageBoxError(op.Result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
+ return;
+ }
+ }
+ int pos = newName.Find(L'\\');
+ if (pos >= 0)
+ newName = newName.Left(pos);
+ if (!_mySelectMode)
+ state.SelectedNames.Clear();
+ state.FocusedName = newName;
+ state.SelectFocused = true;
+ RefreshTitleAlways();
+ RefreshListCtrl(state);
+}
+
+void CPanel::CreateFile()
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ CSelectedState state;
+ SaveSelectedState(state);
+ CComboDialog comboDialog;
+ comboDialog.Title = LangString(IDS_CREATE_FILE, 0x03020240);
+ comboDialog.Static = LangString(IDS_CREATE_FILE_NAME, 0x03020241);
+ comboDialog.Value = LangString(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ UString newName = comboDialog.Value;
+ HRESULT result = folderOperations->CreateFile(newName, 0);
+ if (result != S_OK)
+ {
+ MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243));
+ return;
+ }
+ int pos = newName.Find(L'\\');
+ if (pos >= 0)
+ newName = newName.Left(pos);
+ if (!_mySelectMode)
+ state.SelectedNames.Clear();
+ state.FocusedName = newName;
+ state.SelectFocused = true;
+ RefreshListCtrl(state);
+}
+
+void CPanel::RenameFile()
+{
+ int index = _listView.GetFocusedItem();
+ if (index >= 0)
+ _listView.EditLabel(index);
+}
+
+void CPanel::ChangeComment()
+{
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ int index = _listView.GetFocusedItem();
+ if (index < 0)
+ return;
+ int realIndex = GetRealItemIndex(index);
+ if (realIndex == kParentIndex)
+ return;
+ CSelectedState state;
+ SaveSelectedState(state);
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+
+ UString comment;
+ {
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(realIndex, kpidComment, &propVariant) != S_OK)
+ return;
+ if (propVariant.vt == VT_BSTR)
+ comment = propVariant.bstrVal;
+ else if (propVariant.vt != VT_EMPTY)
+ return;
+ }
+ UString name = GetItemRelPath(realIndex);
+ CComboDialog comboDialog;
+ comboDialog.Title = name + L" " + LangString(IDS_COMMENT, 0x03020290);
+ comboDialog.Value = comment;
+ comboDialog.Static = LangString(IDS_COMMENT2, 0x03020291);
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ NCOM::CPropVariant propVariant(comboDialog.Value);
+
+ HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);
+ if (result != S_OK)
+ {
+ MessageBoxError(result, L"Set Comment Error");
+ }
+ RefreshListCtrl(state);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSelect.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSelect.cpp
new file mode 100644
index 000000000..0e2423003
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSelect.cpp
@@ -0,0 +1,305 @@
+// PanelSelect.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Common/StringConvert.h"
+#include "Common/Wildcard.h"
+
+#include "Panel.h"
+
+#include "ComboDialog.h"
+
+#include "LangUtils.h"
+
+void CPanel::OnShiftSelectMessage()
+{
+ if (!_mySelectMode)
+ return;
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ if (!_selectionIsDefined)
+ return;
+ int startItem = MyMin(focusedItem, _prevFocusedItem);
+ int finishItem = MyMax(focusedItem, _prevFocusedItem);
+ for (int i = 0; i < _listView.GetItemCount(); i++)
+ {
+ int realIndex = GetRealItemIndex(i);
+ if (realIndex == kParentIndex)
+ continue;
+ if (i >= startItem && i <= finishItem)
+ if (_selectedStatusVector[realIndex] != _selectMark)
+ {
+ _selectedStatusVector[realIndex] = _selectMark;
+ _listView.RedrawItem(i);
+ }
+ }
+ _prevFocusedItem = focusedItem;
+}
+
+#ifdef _WIN32
+void CPanel::OnArrowWithShift()
+{
+ if (!_mySelectMode)
+ return;
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (_selectionIsDefined)
+ {
+ if (realIndex != kParentIndex)
+ _selectedStatusVector[realIndex] = _selectMark;
+ }
+ else
+ {
+ if (realIndex == kParentIndex)
+ {
+ _selectionIsDefined = true;
+ _selectMark = true;
+ }
+ else
+ {
+ _selectionIsDefined = true;
+ _selectMark = !_selectedStatusVector[realIndex];
+ _selectedStatusVector[realIndex] = _selectMark;
+ }
+ }
+ _prevFocusedItem = focusedItem;
+ PostMessage(kShiftSelectMessage);
+ _listView.RedrawItem(focusedItem);
+}
+
+void CPanel::OnInsert()
+{
+ /*
+ const int kState = CDIS_MARKED; // LVIS_DROPHILITED;
+ UINT state = (_listView.GetItemState(focusedItem, LVIS_CUT) == 0) ?
+ LVIS_CUT : 0;
+ _listView.SetItemState(focusedItem, state, LVIS_CUT);
+ // _listView.SetItemState(focusedItem, LVIS_SELECTED, LVIS_SELECTED);
+
+ */
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ bool isSelected = !_selectedStatusVector[realIndex];
+ if (realIndex != kParentIndex)
+ _selectedStatusVector[realIndex] = isSelected;
+
+ if (!_mySelectMode)
+ _listView.SetItemState(focusedItem, isSelected ? LVIS_SELECTED: 0, LVIS_SELECTED);
+
+ _listView.RedrawItem(focusedItem);
+
+ int nextIndex = focusedItem + 1;
+ if (nextIndex < _listView.GetItemCount())
+ {
+ _listView.SetItemState(nextIndex, LVIS_FOCUSED | LVIS_SELECTED,
+ LVIS_FOCUSED | LVIS_SELECTED);
+ _listView.EnsureVisible(nextIndex, false);
+ }
+}
+#endif // _WIN32
+
+/*
+void CPanel::OnUpWithShift()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int index = GetRealItemIndex(focusedItem);
+ _selectedStatusVector[index] = !_selectedStatusVector[index];
+ _listView.RedrawItem(index);
+}
+
+void CPanel::OnDownWithShift()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int index = GetRealItemIndex(focusedItem);
+ _selectedStatusVector[index] = !_selectedStatusVector[index];
+ _listView.RedrawItem(index);
+}
+*/
+
+void CPanel::UpdateSelection()
+{
+printf("CPanel::UpdateSelection : _mySelectMode=%d\n",(int)_mySelectMode);
+ if (!_mySelectMode)
+ {
+ bool enableTemp = _enableItemChangeNotify;
+ _enableItemChangeNotify = false;
+ int numItems = _listView.GetItemCount();
+printf("CPanel::UpdateSelection : numItems=%d\n",(int)numItems);
+ for (int i = 0; i < numItems; i++)
+ {
+ int realIndex = GetRealItemIndex(i);
+ if (realIndex != kParentIndex)
+ {
+ UINT value = 0;
+ value = _selectedStatusVector[realIndex] ? LVIS_SELECTED: 0;
+printf("CPanel::UpdateSelection : SetItemState(%d,%d,LVIS_SELECTED)\n",(int)i,(unsigned)value);
+ _listView.SetItemState(i, value, LVIS_SELECTED);
+ }
+ }
+ _enableItemChangeNotify = enableTemp;
+ }
+ _listView.RedrawAllItems();
+}
+
+
+void CPanel::SelectSpec(bool selectMode)
+{
+ CComboDialog comboDialog;
+ comboDialog.Title = selectMode ?
+ LangString(IDS_SELECT, 0x03020250):
+ LangString(IDS_DESELECT, 0x03020251);
+ comboDialog.Static = LangString(IDS_SELECT_MASK, 0x03020252);
+ comboDialog.Value = L"*";
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ const UString &mask = comboDialog.Value;
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (CompareWildCardWithName(mask, GetItemName(i)))
+ _selectedStatusVector[i] = selectMode;
+ UpdateSelection();
+}
+
+void CPanel::SelectByType(bool selectMode)
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ UString name = GetItemName(realIndex);
+ bool isItemFolder = IsItemFolder(realIndex);
+
+ /*
+ UINT32 numItems;
+ _folder->GetNumberOfItems(&numItems);
+ if ((UInt32)_selectedStatusVector.Size() != numItems)
+ throw 11111;
+ */
+
+ if (isItemFolder)
+ {
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (IsItemFolder(i) == isItemFolder)
+ _selectedStatusVector[i] = selectMode;
+ }
+ else
+ {
+ int pos = name.ReverseFind(L'.');
+ if (pos < 0)
+ {
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (IsItemFolder(i) == isItemFolder && GetItemName(i).ReverseFind(L'.') < 0)
+ _selectedStatusVector[i] = selectMode;
+ }
+ else
+ {
+ UString mask = UString(L'*') + name.Mid(pos);
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (IsItemFolder(i) == isItemFolder && CompareWildCardWithName(mask, GetItemName(i)))
+ _selectedStatusVector[i] = selectMode;
+ }
+ }
+ UpdateSelection();
+}
+
+void CPanel::SelectAll(bool selectMode)
+{
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ _selectedStatusVector[i] = selectMode;
+ UpdateSelection();
+}
+
+void CPanel::InvertSelection()
+{
+ if (!_mySelectMode)
+ {
+ int numSelected = 0;
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (_selectedStatusVector[i])
+ numSelected++;
+ if (numSelected == 1)
+ {
+ int focused = _listView.GetFocusedItem();
+ if (focused >= 0)
+ {
+ int realIndex = GetRealItemIndex(focused);
+ if (realIndex >= 0)
+ if (_selectedStatusVector[realIndex])
+ _selectedStatusVector[realIndex] = false;
+ }
+ }
+ }
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ _selectedStatusVector[i] = !_selectedStatusVector[i];
+ UpdateSelection();
+}
+
+void CPanel::KillSelection()
+{
+ SelectAll(false);
+ if (!_mySelectMode)
+ {
+ int focused = _listView.GetFocusedItem();
+ if (focused >= 0)
+ _listView.SetItemState(focused, LVIS_SELECTED, LVIS_SELECTED);
+ }
+}
+
+#ifdef _WIN32
+void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate)
+{
+ if(itemActivate->hdr.hwndFrom != HWND(_listView))
+ return;
+ // It will be work only for Version 4.71 (IE 4);
+ int indexInList = itemActivate->iItem;
+ if (indexInList < 0)
+ return;
+ if ((itemActivate->uKeyFlags & LVKF_SHIFT) != 0)
+ {
+ // int focusedIndex = _listView.GetFocusedItem();
+ int focusedIndex = _startGroupSelect;
+ if (focusedIndex < 0)
+ return;
+ int startItem = MyMin(focusedIndex, indexInList);
+ int finishItem = MyMax(focusedIndex, indexInList);
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ {
+ int realIndex = GetRealItemIndex(i);
+ if (realIndex == kParentIndex)
+ continue;
+ bool selected = (i >= startItem && i <= finishItem);
+ if (_selectedStatusVector[realIndex] != selected)
+ {
+ _selectedStatusVector[realIndex] = selected;
+ _listView.RedrawItem(i);
+ }
+ }
+ }
+ else
+ {
+ _startGroupSelect = indexInList;
+ if ((itemActivate->uKeyFlags & LVKF_CONTROL) != 0)
+ {
+ int realIndex = GetRealItemIndex(indexInList);
+ if (realIndex != kParentIndex)
+ {
+ _selectedStatusVector[realIndex] = !_selectedStatusVector[realIndex];
+ _listView.RedrawItem(indexInList);
+ }
+ }
+ }
+ return;
+}
+#endif
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSort.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSort.cpp
new file mode 100644
index 000000000..5a8f87556
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSort.cpp
@@ -0,0 +1,163 @@
+// PanelSort.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../PropID.h"
+
+#include "Panel.h"
+
+using namespace NWindows;
+
+static UString GetExtension(const UString &name)
+{
+ int dotPos = name.ReverseFind(L'.');
+ if (dotPos < 0)
+ return UString();
+ return name.Mid(dotPos);
+}
+
+int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
+{
+ if (lpData == 0) // FIXME NULL)
+ return 0;
+ CPanel *panel = (CPanel*)lpData;
+
+ switch(panel->_sortID)
+ {
+ // if (panel->_sortIndex == 0)
+ case kpidName:
+ {
+ const UString name1 = panel->GetItemName((int)lParam1);
+ const UString name2 = panel->GetItemName((int)lParam2);
+ int res = name1.CompareNoCase(name2);
+ /*
+ if (res != 0 || !panel->_flatMode)
+ return res;
+ const UString prefix1 = panel->GetItemPrefix(lParam1);
+ const UString prefix2 = panel->GetItemPrefix(lParam2);
+ return res = prefix1.CompareNoCase(prefix2);
+ */
+ return res;
+ }
+ case kpidNoProperty:
+ {
+ return MyCompare(lParam1, lParam2);
+ }
+ case kpidExtension:
+ {
+ const UString ext1 = GetExtension(panel->GetItemName((int)lParam1));
+ const UString ext2 = GetExtension(panel->GetItemName((int)lParam2));
+ return ext1.CompareNoCase(ext2);
+ }
+ }
+ /*
+ if (panel->_sortIndex == 1)
+ return MyCompare(file1.Size, file2.Size);
+ return ::CompareFileTime(&file1.MTime, &file2.MTime);
+ */
+
+ // PROPID propID = panel->_properties[panel->_sortIndex].ID;
+ PROPID propID = panel->_sortID;
+
+ NCOM::CPropVariant propVariant1, propVariant2;
+ // Name must be first property
+ panel->_folder->GetProperty((UINT32)lParam1, propID, &propVariant1);
+ panel->_folder->GetProperty((UINT32)lParam2, propID, &propVariant2);
+ if (propVariant1.vt != propVariant2.vt)
+ return 0; // It means some BUG
+ if (propVariant1.vt == VT_BSTR)
+ {
+#ifdef _WIN32
+ return _wcsicmp(propVariant1.bstrVal, propVariant2.bstrVal);
+#else
+ return wcscmp(propVariant1.bstrVal, propVariant2.bstrVal); // FIXME _wcsicmp ?
+#endif
+ }
+ return propVariant1.Compare(propVariant2);
+ // return 0;
+}
+
+int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
+{
+ if (lpData == 0) // FIXME NULL)
+ return 0;
+ if (lParam1 == kParentIndex) return -1;
+ if (lParam2 == kParentIndex) return 1;
+
+ CPanel *panel = (CPanel*)lpData;
+
+ bool isDir1 = panel->IsItemFolder((int)lParam1);
+ bool isDir2 = panel->IsItemFolder((int)lParam2);
+
+ if (isDir1 && !isDir2) return -1;
+ if (isDir2 && !isDir1) return 1;
+
+ int result = CompareItems2(lParam1, lParam2, lpData);
+ return panel->_ascending ? result: (-result);
+}
+
+
+/*
+void CPanel::SortItems(int index)
+{
+ if (index == _sortIndex)
+ _ascending = !_ascending;
+ else
+ {
+ _sortIndex = index;
+ _ascending = true;
+ switch (_properties[_sortIndex].ID)
+ {
+ case kpidSize:
+ case kpidPackedSize:
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
+ _ascending = false;
+ break;
+ }
+ }
+ _listView.SortItems(CompareItems, (LPARAM)this);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+}
+void CPanel::SortItemsWithPropID(PROPID propID)
+{
+ int index = _properties.FindItemWithID(propID);
+ if (index >= 0)
+ SortItems(index);
+}
+*/
+void CPanel::SortItemsWithPropID(PROPID propID)
+{
+ if (propID == _sortID)
+ _ascending = !_ascending;
+ else
+ {
+ _sortID = propID;
+ _ascending = true;
+ switch (propID)
+ {
+ case kpidSize:
+ case kpidPackSize:
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
+ _ascending = false;
+ break;
+ }
+ }
+ _listView.SortItems(CompareItems, (LPARAM)this);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+}
+
+
+void CPanel::OnColumnClick(LPNMLISTVIEW info)
+{
+ /*
+ int index = _properties.FindItemWithID(_visibleProperties[info->iSubItem].ID);
+ SortItems(index);
+ */
+ SortItemsWithPropID(_visibleProperties[info->iSubItem].ID);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
new file mode 100644
index 000000000..36146d7a4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
@@ -0,0 +1,528 @@
+// PanelSplitFile.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+extern "C"
+{
+ #include "../../../../C/Alloc.h"
+}
+
+#include "Common/Types.h"
+#include "Common/IntToString.h"
+
+// #include "Windows/COM.h"
+#include "Windows/FileIO.h"
+#include "Windows/FileFind.h"
+#include "Windows/Thread.h"
+#include "ProgressDialog2.h"
+#include "SplitDialog.h"
+#include "CopyDialog.h"
+
+#include "../GUI/ExtractRes.h"
+
+#include "SplitUtils.h"
+#include "App.h"
+#include "FormatUtils.h"
+#include "LangUtils.h"
+
+using namespace NWindows;
+
+class CMyBuffer
+{
+ void *_data;
+public:
+ CMyBuffer(): _data(0) {}
+ operator void *() { return _data; }
+ bool Allocate(size_t size)
+ {
+ if (_data != 0)
+ return false;
+ _data = ::MidAlloc(size);
+ return _data != 0;
+ }
+ ~CMyBuffer() { ::MidFree(_data); }
+};
+
+struct CVolSeqName
+{
+ UString UnchangedPart;
+ UString ChangedPart;
+ CVolSeqName(): ChangedPart(L"000") {};
+
+ bool ParseName(const UString &name)
+ {
+ if (name.Right(2) != L"01")
+ return false;
+ int numLetters = 2;
+ while (numLetters < name.Length())
+ {
+ if (name[name.Length() - numLetters - 1] != '0')
+ break;
+ numLetters++;
+ }
+ UnchangedPart = name.Left(name.Length() - numLetters);
+ ChangedPart = name.Right(numLetters);
+ return true;
+ }
+
+ UString GetNextName()
+ {
+ UString newName;
+ int i;
+ int numLetters = ChangedPart.Length();
+ for (i = numLetters - 1; i >= 0; i--)
+ {
+ wchar_t c = ChangedPart[i];
+ if (c == L'9')
+ {
+ c = L'0';
+ newName = c + newName;
+ if (i == 0)
+ newName = UString(L'1') + newName;
+ continue;
+ }
+ c++;
+ newName = c + newName;
+ i--;
+ for (; i >= 0; i--)
+ newName = ChangedPart[i] + newName;
+ break;
+ }
+ ChangedPart = newName;
+ return UnchangedPart + ChangedPart;
+ }
+};
+
+static const UInt32 kBufSize = (1 << 20);
+
+struct CThreadSplit
+{
+ // HRESULT Result;
+ // CPanel *Panel;
+ CProgressDialog *ProgressDialog;
+ UString FilePath;
+ UString VolBasePath;
+ CRecordVector<UInt64> VolumeSizes;
+ UString Error;
+
+ void Process2()
+ {
+ // NCOM::CComInitializer comInitializer;
+ ProgressDialog->WaitCreating();
+ NFile::NIO::CInFile inFile;
+ if (!inFile.Open(FilePath))
+ throw L"Can not open file";
+ NFile::NIO::COutFile outFile;
+ CMyBuffer bufferObject;
+ if (!bufferObject.Allocate(kBufSize))
+ throw L"Can not allocate buffer";
+ Byte *buffer = (Byte *)(void *)bufferObject;
+ UInt64 curVolSize = 0;
+ CVolSeqName seqName;
+ UInt64 length;
+ if (!inFile.GetLength(length))
+ throw "error";
+
+ ProgressDialog->ProgressSynch.SetProgress(length, 0);
+ UInt64 pos = 0;
+
+ int volIndex = 0;
+
+ for (;;)
+ {
+ UInt64 volSize;
+ if (volIndex < VolumeSizes.Size())
+ volSize = VolumeSizes[volIndex];
+ else
+ volSize = VolumeSizes.Back();
+
+ UInt32 needSize = (UInt32)(MyMin((UInt64)kBufSize, volSize - curVolSize));
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, needSize, processedSize))
+ throw L"Can not read input file";
+ if (processedSize == 0)
+ break;
+ needSize = processedSize;
+ if (curVolSize == 0)
+ {
+ UString name = VolBasePath;
+ name += L".";
+ name += seqName.GetNextName();
+ if (!outFile.Create(name, false))
+ throw L"Can not create output file";
+ ProgressDialog->ProgressSynch.SetCurrentFileName(name);
+ }
+ if (!outFile.Write(buffer, needSize, processedSize))
+ throw L"Can not write output file";
+ if (needSize != processedSize)
+ throw L"Can not write output file";
+ curVolSize += processedSize;
+ if (curVolSize == volSize)
+ {
+ outFile.Close();
+ if (volIndex < VolumeSizes.Size())
+ volIndex++;
+ curVolSize = 0;
+ }
+ pos += processedSize;
+ HRESULT res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos);
+ if (res != S_OK)
+ return;
+ }
+ }
+ void Process()
+ {
+ try { Process2(); }
+ catch(const wchar_t *s) { Error = s; }
+ catch(...) { Error = L"Error"; }
+ ProgressDialog->MyClose();
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadSplit *)param)->Process();
+ return 0;
+ }
+};
+
+void CApp::Split()
+{
+ int srcPanelIndex = GetFocusedPanelIndex();
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+ if (indices.Size() != 1)
+ {
+ srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02);
+ return;
+ }
+ int index = indices[0];
+ if (srcPanel.IsItemFolder(index))
+ {
+ srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02);
+ return;
+ }
+ const UString itemName = srcPanel.GetItemName(index);
+
+ UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index);
+ UString path = srcPath;
+ int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
+ CPanel &destPanel = Panels[destPanelIndex];
+ if (NumPanels > 1)
+ if (destPanel.IsFSFolder())
+ path = destPanel._currentFolderPrefix;
+ CSplitDialog splitDialog;
+ splitDialog.FilePath = srcPanel.GetItemRelPath(index);
+ splitDialog.Path = path;
+ if (splitDialog.Create(srcPanel.GetParent()) == IDCANCEL)
+ return;
+
+ NFile::NFind::CFileInfoW fileInfo;
+ if (!NFile::NFind::FindFile(srcPath + itemName, fileInfo))
+ {
+ srcPanel.MessageBoxMyError(L"Can not find file");
+ return;
+ }
+ if (fileInfo.Size <= splitDialog.VolumeSizes.Front())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_SPLIT_VOL_MUST_BE_SMALLER, 0x03020522);
+ return;
+ }
+ const UInt64 numVolumes = GetNumberOfVolumes(fileInfo.Size, splitDialog.VolumeSizes);
+ if (numVolumes >= 100)
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString(numVolumes, s);
+ if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s),
+ LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520),
+ MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES)
+ return;
+ }
+
+ path = splitDialog.Path;
+ NFile::NName::NormalizeDirPathPrefix(path);
+ if (!NFile::NDirectory::CreateComplexDirectory(path))
+ {
+ srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
+ return;
+ }
+
+ CThreadSplit spliter;
+ // spliter.Panel = this;
+
+ {
+ CProgressDialog progressDialog;
+ spliter.ProgressDialog = &progressDialog;
+
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_SPLITTING, 0x03020510);
+
+ progressDialog.MainWindow = _window;
+ progressDialog.MainTitle = progressWindowTitle;
+ progressDialog.MainAddTitle = title + UString(L" ");
+ progressDialog.ProgressSynch.SetTitleFileName(itemName);
+
+
+ spliter.FilePath = srcPath + itemName;
+ spliter.VolBasePath = path + itemName;
+ spliter.VolumeSizes = splitDialog.VolumeSizes;
+
+ // if (splitDialog.VolumeSizes.Size() == 0) return;
+
+ // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
+ // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
+
+ NWindows::CThread thread;
+ if (thread.Create(CThreadSplit::MyThreadFunction, &spliter) != S_OK)
+ throw 271824;
+ progressDialog.Create(title, _window);
+ }
+ RefreshTitleAlways();
+
+
+ if (!spliter.Error.IsEmpty())
+ srcPanel.MessageBoxMyError(spliter.Error);
+ // disableTimerProcessing1.Restore();
+ // disableTimerProcessing2.Restore();
+ // srcPanel.SetFocusToList();
+ // srcPanel.RefreshListCtrlSaveFocused();
+}
+
+
+struct CThreadCombine
+{
+ CProgressDialog *ProgressDialog;
+
+ UString InputDirPrefix;
+ UStringVector Names;
+ UString OutputPath;
+ UInt64 TotalSize;
+
+ UString Error;
+ HRESULT Res;
+
+ void Process2()
+ {
+ NFile::NIO::COutFile outFile;
+ if (!outFile.Create(OutputPath, false))
+ {
+ Error = L"Can create open output file:\n" + OutputPath;
+ return;
+ }
+
+ ProgressDialog->ProgressSynch.SetProgress(TotalSize, 0);
+
+ CMyBuffer bufferObject;
+ if (!bufferObject.Allocate(kBufSize))
+ throw L"Can not allocate buffer";
+ Byte *buffer = (Byte *)(void *)bufferObject;
+ UInt64 pos = 0;
+ for (int i = 0; i < Names.Size(); i++)
+ {
+ NFile::NIO::CInFile inFile;
+ const UString nextName = InputDirPrefix + Names[i];
+ if (!inFile.Open(nextName))
+ {
+ Error = L"Can not open input file:\n" + nextName;
+ return;
+ }
+ ProgressDialog->ProgressSynch.SetCurrentFileName(nextName);
+ for (;;)
+ {
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, kBufSize, processedSize))
+ throw L"Can not read input file";
+ if (processedSize == 0)
+ break;
+ UInt32 needSize = processedSize;
+ if (!outFile.Write(buffer, needSize, processedSize) || needSize != processedSize)
+ throw L"Can not write output file";
+ pos += processedSize;
+ Res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos);
+ if (Res != S_OK)
+ return;
+ }
+ }
+ }
+
+ void Process()
+ {
+ Res = S_OK;
+ ProgressDialog->WaitCreating();
+ try { Process2(); }
+ catch(const wchar_t *s) { Error = s; }
+ catch(...) { Error = L"Error";}
+ ProgressDialog->MyClose();
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadCombine *)param)->Process();
+ return 0;
+ }
+};
+
+extern void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s);
+
+static void AddInfoFileName(const UString &name, UString &dest)
+{
+ dest += L"\n ";
+ dest += name;
+}
+
+void CApp::Combine()
+{
+ int srcPanelIndex = GetFocusedPanelIndex();
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+ int index = indices[0];
+ if (indices.Size() != 1 || srcPanel.IsItemFolder(index))
+ {
+ srcPanel.MessageBoxErrorLang(IDS_COMBINE_SELECT_ONE_FILE, 0x03020620);
+ return;
+ }
+ const UString itemName = srcPanel.GetItemName(index);
+
+ UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index);
+ UString path = srcPath;
+ int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
+ CPanel &destPanel = Panels[destPanelIndex];
+ if (NumPanels > 1)
+ if (destPanel.IsFSFolder())
+ path = destPanel._currentFolderPrefix;
+
+ CVolSeqName volSeqName;
+ if (!volSeqName.ParseName(itemName))
+ {
+ srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_DETECT_SPLIT_FILE, 0x03020621);
+ return;
+ }
+
+ CThreadCombine combiner;
+
+ UString nextName = itemName;
+ combiner.TotalSize = 0;
+ for (;;)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if (!NFile::NFind::FindFile(srcPath + nextName, fileInfo) || fileInfo.IsDir())
+ break;
+ combiner.Names.Add(nextName);
+ combiner.TotalSize += fileInfo.Size;
+ nextName = volSeqName.GetNextName();
+ }
+ if (combiner.Names.Size() == 1)
+ {
+ srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART, 0x03020622);
+ return;
+ }
+
+ if (combiner.TotalSize == 0)
+ {
+ srcPanel.MessageBoxMyError(L"No data");
+ return;
+ }
+
+ UString info;
+ AddValuePair2(IDS_FILES_COLON, 0x02000320, combiner.Names.Size(), combiner.TotalSize, info);
+
+ info += L"\n";
+ info += srcPath;
+
+ int i;
+ for (i = 0; i < combiner.Names.Size() && i < 2; i++)
+ AddInfoFileName(combiner.Names[i], info);
+ if (i != combiner.Names.Size())
+ {
+ if (i + 1 != combiner.Names.Size())
+ AddInfoFileName(L"...", info);
+ AddInfoFileName(combiner.Names.Back(), info);
+ }
+
+ {
+ CCopyDialog copyDialog;
+ copyDialog.Value = path;
+ copyDialog.Title = LangString(IDS_COMBINE, 0x03020600);
+ copyDialog.Title += ' ';
+ copyDialog.Title += srcPanel.GetItemRelPath(index);
+ copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601);
+ copyDialog.Info = info;
+ if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
+ return;
+ path = copyDialog.Value;
+ }
+
+ NFile::NName::NormalizeDirPathPrefix(path);
+ if (!NFile::NDirectory::CreateComplexDirectory(path))
+ {
+ srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
+ return;
+ }
+
+ UString outName = volSeqName.UnchangedPart;
+ while (!outName.IsEmpty())
+ {
+ int lastIndex = outName.Length() - 1;
+ if (outName[lastIndex] != L'.')
+ break;
+ outName.Delete(lastIndex);
+ }
+ if (outName.IsEmpty())
+ outName = L"file";
+
+ NFile::NFind::CFileInfoW fileInfo;
+ UString destFilePath = path + outName;
+ combiner.OutputPath = destFilePath;
+ if (NFile::NFind::FindFile(destFilePath, fileInfo))
+ {
+ srcPanel.MessageBoxMyError(MyFormatNew(IDS_FILE_EXIST, 0x03020A04, destFilePath));
+ return;
+ }
+
+ {
+ CProgressDialog progressDialog;
+ combiner.ProgressDialog = &progressDialog;
+
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_COMBINING, 0x03020610);
+
+ progressDialog.MainWindow = _window;
+ progressDialog.MainTitle = progressWindowTitle;
+ progressDialog.MainAddTitle = title + UString(L" ");
+
+ combiner.InputDirPrefix = srcPath;
+
+ // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
+ // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
+
+ NWindows::CThread thread;
+ if (thread.Create(CThreadCombine::MyThreadFunction, &combiner) != S_OK)
+ throw 271824;
+ progressDialog.Create(title, _window);
+ }
+ RefreshTitleAlways();
+
+ if (!combiner.Error.IsEmpty())
+ srcPanel.MessageBoxMyError(combiner.Error);
+ // disableTimerProcessing1.Restore();
+ // disableTimerProcessing2.Restore();
+ // srcPanel.SetFocusToList();
+ // srcPanel.RefreshListCtrlSaveFocused();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog.cpp
new file mode 100644
index 000000000..94e8219d4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog.cpp
@@ -0,0 +1,50 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+#include "PasswordDialog.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_PASSWORD_HEADER, 0x02000B01 },
+ { IDC_CHECK_PASSWORD_SHOW, 0x02000B02 },
+
+};
+#endif
+
+
+bool CPasswordDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000B00);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _passwordControl.Attach(GetItem(IDC_EDIT_PASSWORD));
+ _passwordControl.SetText(Password);
+ _passwordControl.SetPasswordChar(TEXT('*'));
+ return CModalDialog::OnInit();
+}
+
+bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ if (buttonID == IDC_CHECK_PASSWORD_SHOW)
+ {
+ _passwordControl.SetPasswordChar((IsButtonChecked(
+ IDC_CHECK_PASSWORD_SHOW) == BST_CHECKED) ? 0: TEXT('*'));
+ UString password;
+ _passwordControl.GetText(password);
+ _passwordControl.SetText(password);
+ return true;
+ }
+ return CDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CPasswordDialog::OnOK()
+{
+ _passwordControl.GetText(Password);
+ CModalDialog::OnOK();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog.h
new file mode 100644
index 000000000..e5a960731
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog.h
@@ -0,0 +1,21 @@
+// PasswordDialog.h
+
+#ifndef __PASSWORDDIALOG_H
+#define __PASSWORDDIALOG_H
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/Edit.h"
+#include "PasswordDialogRes.h"
+
+class CPasswordDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CEdit _passwordControl;
+ virtual void OnOK();
+ virtual bool OnInit();
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+public:
+ UString Password;
+ INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_PASSWORD, parentWindow); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialogRes.h
new file mode 100644
index 000000000..e0b426614
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialogRes.h
@@ -0,0 +1,4 @@
+#define IDD_DIALOG_PASSWORD 501
+#define IDC_STATIC_PASSWORD_HEADER 1000
+#define IDC_EDIT_PASSWORD 1001
+#define IDC_CHECK_PASSWORD_SHOW 1002
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog_rc.cpp
new file mode 100644
index 000000000..533919868
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PasswordDialog_rc.cpp
@@ -0,0 +1,63 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "PasswordDialogRes.h"
+
+class CPasswordDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CPasswordDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) : CModalDialogImpl(dialog, parent, id, wxT("Enter password"))
+ {
+ bool bShowPassword = false;
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ {
+ wxStaticBoxSizer *passwdSizer = new wxStaticBoxSizer(new wxStaticBox(this,IDC_STATIC_PASSWORD_HEADER,_T("&Enter password:")),wxVERTICAL);
+
+ wxTextCtrl *TxtPasswd = new wxTextCtrl(this, IDC_EDIT_PASSWORD, L"",
+ wxDefaultPosition, wxSize(260,-1), bShowPassword?wxTE_LEFT:wxTE_PASSWORD );
+
+ wxCheckBox *ChkShowPasswd = new wxCheckBox(this, IDC_CHECK_PASSWORD_SHOW, wxT("&Show password"));
+
+ ChkShowPasswd->SetValue(bShowPassword);
+ passwdSizer->Add(TxtPasswd, 0, wxALL, 5);
+ passwdSizer->Add(ChkShowPasswd, 0, wxALL, 5);
+
+ topsizer->Add(passwdSizer, 0, wxALL, 5);
+ }
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+REGISTER_DIALOG(IDD_DIALOG_PASSWORD,CPasswordDialog,0)
+
+BEGIN_EVENT_TABLE(CPasswordDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PluginInterface.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PluginInterface.h
new file mode 100644
index 000000000..905aff9a4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PluginInterface.h
@@ -0,0 +1,42 @@
+// PluginInterface.h
+
+#ifndef __PLUGININTERFACE_H
+#define __PLUGININTERFACE_H
+
+#include "Common/MyString.h"
+
+// {23170F69-40C1-278D-0000-000100010000}
+DEFINE_GUID(IID_IInitContextMenu,
+0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00);
+MIDL_INTERFACE("23170F69-40C1-278D-0000-000100010000")
+IInitContextMenu: public IUnknown
+{
+public:
+ STDMETHOD(InitContextMenu)(const wchar_t *aFolder, const wchar_t **aNames, UINT32 aNumFiles) PURE;
+
+};
+
+// {23170F69-40C1-278D-0000-000100020100}
+DEFINE_GUID(IID_IPluginOptionsCallback,
+0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
+MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000")
+IPluginOptionsCallback: public IUnknown
+{
+public:
+ STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE;
+ STDMETHOD(GetProgramPath)(BSTR *value) PURE;
+ STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE;
+};
+
+// {23170F69-40C1-278D-0000-000100020000}
+DEFINE_GUID(IID_IPluginOptions,
+0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
+MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000")
+IPluginOptions: public IUnknown
+{
+public:
+ STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE;
+ // STDMETHOD(GetFileExtensions)(BSTR *extensions) PURE;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PluginLoader.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PluginLoader.h
new file mode 100644
index 000000000..f48c9e97a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PluginLoader.h
@@ -0,0 +1,32 @@
+// PluginLoader.h
+
+#ifndef __PLUGINLOADER_H
+#define __PLUGINLOADER_H
+
+#include "Windows/DLL.h"
+
+typedef UINT32 (WINAPI * CreateObjectPointer)(
+ const GUID *clsID,
+ const GUID *interfaceID,
+ void **outObject);
+
+class CPluginLibrary: public NWindows::NDLL::CLibrary
+{
+public:
+ HRESULT CreateManager(REFGUID clsID, IFolderManager **manager)
+ {
+ CreateObjectPointer createObject = (CreateObjectPointer)
+ GetProcAddress("CreateObject");
+ if (createObject == NULL)
+ return GetLastError();
+ return createObject(&clsID, &IID_IFolderManager, (void **)manager);
+ }
+ HRESULT LoadAndCreateManager(LPCWSTR filePath, REFGUID clsID, IFolderManager **manager)
+ {
+ if (!Load(filePath))
+ return GetLastError();
+ return CreateManager(clsID, manager);
+ }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgramLocation.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgramLocation.cpp
new file mode 100644
index 000000000..ea8afd558
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgramLocation.cpp
@@ -0,0 +1,20 @@
+// ProgramLocation.h
+
+#include "StdAfx.h"
+
+#include "ProgramLocation.h"
+
+// #include "Windows/FileName.h"
+#include "Common/StringConvert.h"
+
+
+bool GetProgramFolderPath(UString &folder)
+{
+ const char *p7zip_home_dir = getenv("P7ZIP_HOME_DIR");
+ if (p7zip_home_dir == 0) p7zip_home_dir="./";
+
+ folder = MultiByteToUnicodeString(p7zip_home_dir);
+
+ return true;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgramLocation.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgramLocation.h
new file mode 100644
index 000000000..38317b45f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgramLocation.h
@@ -0,0 +1,10 @@
+// ProgramLocation.h
+
+#ifndef __PROGRAMLOCATION_H
+#define __PROGRAMLOCATION_H
+
+#include "Common/MyString.h"
+
+bool GetProgramFolderPath(UString &folder); // normalized
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
new file mode 100644
index 000000000..87a1521d0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
@@ -0,0 +1,507 @@
+// ProgressDialog2.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+
+#include "ProgressDialog2.h"
+
+using namespace NWindows;
+
+static const UINT_PTR kTimerID = 3;
+static const UINT kTimerElapse = 100;
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDCANCEL, 0x02000C00 },
+ { IDC_PROGRESS_ELAPSED, 0x02000C01 },
+ { IDC_PROGRESS_REMAINING, 0x02000C02 },
+ { IDC_PROGRESS_TOTAL, 0x02000C03 },
+ { IDC_PROGRESS_SPEED, 0x02000C04 },
+ { IDC_PROGRESS_UNPACKED, 0x02000C05 },
+ { IDC_PROGRESS_PACKED, 0x02000323 },
+ { IDC_PROGRESS_RATIO, 0x02000C06 },
+ { IDC_PROGRESS_SPEED, 0x02000C04 },
+ { IDC_PROGRESS_FILES, 0x02000320 },
+ { IDC_BUTTON_PROGRESS_PRIORITY, 0x02000C10 },
+ { IDC_BUTTON_PAUSE, 0x02000C12 },
+ { IDCANCEL, 0x02000711 },
+};
+#endif
+
+HRESULT CProgressSynch::ProcessStopAndPause()
+{
+ for (;;)
+ {
+ if (GetStopped())
+ return E_ABORT;
+ if (!GetPaused())
+ break;
+ ::Sleep(100);
+ }
+ return S_OK;
+}
+
+HRESULT CProgressSynch::SetPosAndCheckPaused(UInt64 completed)
+{
+ RINOK(ProcessStopAndPause());
+ SetPos(completed);
+ return S_OK;
+}
+
+#ifndef _SFX
+CProgressDialog::~CProgressDialog()
+{
+ AddToTitle(L"");
+}
+void CProgressDialog::AddToTitle(LPCWSTR s)
+{
+ if (MainWindow != 0)
+ {
+ CWindow window(MainWindow);
+ window.SetText(s + UString(MainTitle));
+ }
+}
+
+static const int kTitleFileNameSizeLimit = 40;
+static const int kCurrentFileNameSizeLimit = 82;
+
+static void ReduceString(UString &s, int size)
+{
+ if (s.Length() > size)
+ s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2);
+}
+#endif
+
+bool CProgressDialog::OnInit()
+{
+ _range = (UInt64)(Int64)(-1);
+ _prevPercentValue = UInt32(-1);
+ _prevElapsedSec = UInt32(-1);
+ _prevRemainingSec = UInt32(-1);
+ _prevSpeed = UInt32(-1);
+ _prevMode = kSpeedBytes;
+ _prevTime = ::GetTickCount();
+ _elapsedTime = 0;
+ _foreground = true;
+
+ #ifdef LANG
+ // LangSetWindowText(HWND(*this), 0x02000C00);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+
+
+ CWindow window(GetItem(IDC_BUTTON_PROGRESS_PRIORITY));
+ window.GetText(backgroundString);
+ backgroundedString = backgroundString;
+ backgroundedString.Replace(L"&", L"");
+
+ window = GetItem(IDC_BUTTON_PAUSE);
+ window.GetText(pauseString);
+
+ foregroundString = LangString(IDS_PROGRESS_FOREGROUND, 0x02000C11);
+ continueString = LangString(IDS_PROGRESS_CONTINUE, 0x02000C13);
+ pausedString = LangString(IDS_PROGRESS_PAUSED, 0x02000C20);
+
+ m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
+ _timer = SetTimer(kTimerID, kTimerElapse);
+ _dialogCreatedEvent.Set();
+ SetText(_title);
+ SetPauseText();
+ SetPriorityText();
+ return CModalDialog::OnInit();
+}
+
+void CProgressDialog::OnCancel()
+{
+ ProgressSynch.SetStopped(true);
+}
+
+static void ConvertSizeToString(UInt64 value, wchar_t *s)
+{
+ const wchar_t *kModif = L" KM";
+ for (int i = 0; ; i++)
+ if (i == 2 || value < (UInt64(10000) << (i * 10)))
+ {
+ ConvertUInt64ToString(value >> (i * 10), s);
+ s += wcslen(s);
+ *s++ = ' ';
+ if (i != 0)
+ *s++ = kModif[i];
+ *s++ = L'B';
+ *s++ = L'\0';
+ return;
+ }
+}
+
+void CProgressDialog::SetRange(UInt64 range)
+{
+ _range = range;
+ _previousPos = (UInt64)(Int64)-1;
+ _converter.Init(range);
+ m_ProgressBar.SetRange32(0, _converter.Count(range)); // Test it for 100%
+}
+
+void CProgressDialog::SetPos(UInt64 pos)
+{
+ bool redraw = true;
+ if (pos < _range && pos > _previousPos)
+ {
+ if (pos - _previousPos < (_range >> 10))
+ redraw = false;
+ }
+ if(redraw)
+ {
+ m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100%
+ _previousPos = pos;
+ }
+}
+
+static void GetTimeString(UInt64 timeValue, TCHAR *s)
+{
+ wsprintf(s, TEXT("%02d:%02d:%02d"),
+ UInt32(timeValue / 3600),
+ UInt32((timeValue / 60) % 60),
+ UInt32(timeValue % 60));
+}
+
+void CProgressDialog::ShowSize(int id, UInt64 value)
+{
+ wchar_t s[40];
+ s[0] = 0;
+ if (value != (UInt64)(Int64)-1)
+ ConvertSizeToString(value, s);
+ SetItemText(id, s);
+}
+
+bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
+{
+ if (ProgressSynch.GetPaused())
+ return true;
+ UInt64 total, completed, totalFiles, completedFiles, inSize, outSize;
+ bool bytesProgressMode;
+ ProgressSynch.GetProgress(total, completed, totalFiles, completedFiles, inSize, outSize, bytesProgressMode);
+
+ UInt32 curTime = ::GetTickCount();
+
+ UInt64 progressTotal = bytesProgressMode ? total : totalFiles;
+ UInt64 progressCompleted = bytesProgressMode ? completed : completedFiles;
+
+ if (progressTotal != _range)
+ SetRange(progressTotal);
+ if (progressTotal == (UInt64)(Int64)-1)
+ {
+ SetPos(0);
+ SetRange(progressCompleted);
+ }
+ else
+ SetPos(progressCompleted);
+
+ wchar_t s[32] = { 0 };
+ if (total != (UInt64)(Int64)-1)
+ ConvertSizeToString(total, s);
+ SetItemText(IDC_PROGRESS_TOTAL_VALUE, s);
+
+ _elapsedTime += (curTime - _prevTime);
+ _prevTime = curTime;
+
+ UInt32 elapsedSec = _elapsedTime / 1000;
+
+ bool elapsedChanged = false;
+ if (elapsedSec != _prevElapsedSec)
+ {
+ TCHAR s[40];
+ GetTimeString(elapsedSec, s);
+ SetItemText(IDC_PROGRESS_ELAPSED_VALUE, s);
+ _prevElapsedSec = elapsedSec;
+ elapsedChanged = true;
+ }
+
+ if (elapsedChanged)
+ {
+ if (completed != 0)
+ {
+
+ if (total == (UInt64)(Int64)-1)
+ {
+ SetItemText(IDC_PROGRESS_REMAINING_VALUE, L"");
+ }
+ else
+ {
+ UInt64 remainingTime = 0;
+ if (completed < total)
+ remainingTime = _elapsedTime * (total - completed) / completed;
+ UInt64 remainingSec = remainingTime / 1000;
+ if (remainingSec != _prevRemainingSec)
+ {
+ TCHAR s[40];
+ GetTimeString(remainingSec, s);
+ SetItemText(IDC_PROGRESS_REMAINING_VALUE, s);
+ _prevRemainingSec = remainingSec;
+ }
+ }
+ // if (elapsedChanged)
+ {
+ UInt32 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime;
+ UInt64 speedB = (completed * 1000) / elapsedTime;
+ UInt64 speedKB = speedB / 1024;
+ UInt64 speedMB = speedKB / 1024;
+ const UInt32 kLimit1 = 10;
+ TCHAR s[40];
+ bool needRedraw = false;
+ if (speedMB >= kLimit1)
+ {
+ if (_prevMode != kSpeedMBytes || speedMB != _prevSpeed)
+ {
+ ConvertUInt64ToString(speedMB, s);
+ lstrcat(s, TEXT(" MB/s"));
+ _prevMode = kSpeedMBytes;
+ _prevSpeed = speedMB;
+ needRedraw = true;
+ }
+ }
+ else if (speedKB >= kLimit1)
+ {
+ if (_prevMode != kSpeedKBytes || speedKB != _prevSpeed)
+ {
+ ConvertUInt64ToString(speedKB, s);
+ lstrcat(s, TEXT(" KB/s"));
+ _prevMode = kSpeedKBytes;
+ _prevSpeed = speedKB;
+ needRedraw = true;
+ }
+ }
+ else
+ {
+ if (_prevMode != kSpeedBytes || speedB != _prevSpeed)
+ {
+ ConvertUInt64ToString(speedB, s);
+ lstrcat(s, TEXT(" B/s"));
+ _prevMode = kSpeedBytes;
+ _prevSpeed = speedB;
+ needRedraw = true;
+ }
+ }
+ if (needRedraw)
+ SetItemText(IDC_PROGRESS_SPEED_VALUE, s);
+ }
+ }
+
+ if (total == 0)
+ total = 1;
+ UInt32 percentValue = (UInt32)(completed * 100 / total);
+ UString titleName;
+ ProgressSynch.GetTitleFileName(titleName);
+ if (percentValue != _prevPercentValue || _prevTitleName != titleName)
+ {
+ _prevPercentValue = percentValue;
+ SetTitleText();
+ _prevTitleName = titleName;
+ }
+
+ TCHAR s[64];
+ ConvertUInt64ToString(completedFiles, s);
+ if (totalFiles != (UInt64)(Int64)-1)
+ {
+ lstrcat(s, TEXT(" / "));
+ ConvertUInt64ToString(totalFiles, s + lstrlen(s));
+ }
+
+ SetItemText(IDC_PROGRESS_FILES_VALUE, s);
+
+ const UInt64 packSize = CompressingMode ? outSize : inSize;
+ const UInt64 unpackSize = CompressingMode ? inSize : outSize;
+
+ if (unpackSize == (UInt64)(Int64)-1 && packSize == (UInt64)(Int64)-1)
+ {
+ ShowSize(IDC_PROGRESS_UNPACKED_VALUE, completed);
+ SetItemText(IDC_PROGRESS_PACKED_VALUE, L"");
+ }
+ else
+ {
+ ShowSize(IDC_PROGRESS_UNPACKED_VALUE, unpackSize);
+ ShowSize(IDC_PROGRESS_PACKED_VALUE, packSize);
+
+ if (packSize != (UInt64)(Int64)-1 && unpackSize != (UInt64)(Int64)-1 && unpackSize != 0)
+ {
+ UInt64 ratio = packSize * 100 / unpackSize;
+ ConvertUInt64ToString(ratio, s);
+ lstrcat(s, TEXT("%"));
+ SetItemText(IDC_PROGRESS_RATIO_VALUE, s);
+ }
+ }
+ }
+
+
+ UString fileName;
+ ProgressSynch.GetCurrentFileName(fileName);
+ if (_prevFileName != fileName)
+ {
+ int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ UString s1, s2;
+ if (slashPos >= 0)
+ {
+ s1 = fileName.Left(slashPos + 1);
+ s2 = fileName.Mid(slashPos + 1);
+ }
+ else
+ s2 = fileName;
+ ReduceString(s1, kCurrentFileNameSizeLimit);
+ ReduceString(s2, kCurrentFileNameSizeLimit);
+ UString s = s1 + L"\n" + s2;
+ SetItemText(IDC_PROGRESS_FILE_NAME, s);
+ _prevFileName == fileName;
+ }
+
+ return true;
+}
+
+
+////////////////////
+// CU64ToI32Converter
+
+static const UInt64 kMaxIntValue = 0x7FFFFFFF;
+
+void CU64ToI32Converter::Init(UInt64 range)
+{
+ _numShiftBits = 0;
+ while(range > kMaxIntValue)
+ {
+ range >>= 1;
+ _numShiftBits++;
+ }
+}
+
+int CU64ToI32Converter::Count(UInt64 aValue)
+{
+ return int(aValue >> _numShiftBits);
+}
+
+const UINT CProgressDialog::kCloseMessage = WM_USER + 1;
+
+bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message)
+ {
+ case kCloseMessage:
+ {
+ KillTimer(_timer);
+ _timer = 0;
+ End(0);
+ return true;
+ }
+ case WM_SETTEXT:
+ {
+ if (_timer == 0)
+ return true;
+ }
+ }
+ return CModalDialog::OnMessage(message, wParam, lParam);
+}
+
+void CProgressDialog::SetTitleText()
+{
+ UString title;
+ if (ProgressSynch.GetPaused())
+ {
+ title = pausedString;
+ title += L" ";
+ }
+ if (_prevPercentValue != UInt32(-1))
+ {
+ wchar_t s[64];
+ ConvertUInt64ToString(_prevPercentValue, s);
+ title += s;
+ title += L"%";
+ }
+ if (!_foreground)
+ {
+ title += L" ";
+ title += backgroundedString;
+ }
+ title += L" ";
+ UString totalTitle = title + _title;
+ UString fileName;
+ ProgressSynch.GetTitleFileName(fileName);
+ if (!fileName.IsEmpty())
+ {
+ ReduceString(fileName, kTitleFileNameSizeLimit);
+ totalTitle += L" ";
+ totalTitle += fileName;
+ }
+ SetText(totalTitle);
+ #ifndef _SFX
+ AddToTitle(title + MainAddTitle);
+ #endif
+}
+
+void CProgressDialog::SetPauseText()
+{
+ SetItemText(IDC_BUTTON_PAUSE, ProgressSynch.GetPaused() ?
+ continueString : pauseString);
+ SetTitleText();
+}
+
+void CProgressDialog::OnPauseButton()
+{
+ bool paused = !ProgressSynch.GetPaused();
+ ProgressSynch.SetPaused(paused);
+ UInt32 curTime = ::GetTickCount();
+ if (paused)
+ _elapsedTime += (curTime - _prevTime);
+ _prevTime = curTime;
+ SetPauseText();
+}
+
+void CProgressDialog::SetPriorityText()
+{
+ SetItemText(IDC_BUTTON_PROGRESS_PRIORITY, _foreground ?
+ backgroundString :
+ foregroundString);
+ SetTitleText();
+}
+
+void CProgressDialog::OnPriorityButton()
+{
+ _foreground = !_foreground;
+ SetPriorityClass(GetCurrentProcess(), _foreground ?
+ NORMAL_PRIORITY_CLASS: IDLE_PRIORITY_CLASS);
+ SetPriorityText();
+}
+
+bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDCANCEL:
+ {
+ bool paused = ProgressSynch.GetPaused();;
+ // ProgressSynch.SetPaused(true);
+ if (!paused)
+ OnPauseButton();
+ int res = ::MessageBoxW(HWND(*this),
+ LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30),
+ _title, MB_YESNOCANCEL);
+ // ProgressSynch.SetPaused(paused);
+ if (!paused)
+ OnPauseButton();
+ if (res == IDCANCEL || res == IDNO)
+ return true;
+ break;
+ }
+ case IDC_BUTTON_PAUSE:
+ OnPauseButton();
+ return true;
+ case IDC_BUTTON_PROGRESS_PRIORITY:
+ {
+ OnPriorityButton();
+ return true;
+ }
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2.h
new file mode 100644
index 000000000..3ab9f4c05
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2.h
@@ -0,0 +1,242 @@
+// ProgressDialog2.h
+
+#ifndef __PROGRESS_DIALOG2_H
+#define __PROGRESS_DIALOG2_H
+
+#include "Common/Types.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ProgressBar.h"
+#include "Windows/Synchronization.h"
+
+#include "ProgressDialog2Res.h"
+
+class CProgressSynch
+{
+ NWindows::NSynchronization::CCriticalSection _cs;
+ bool _stopped;
+ bool _paused;
+ bool _bytesProgressMode;
+
+ UInt64 _totalBytes;
+ UInt64 _curBytes;
+ UInt64 _totalFiles;
+ UInt64 _curFiles;
+ UInt64 _inSize;
+ UInt64 _outSize;
+
+ UString TitleFileName;
+ UString CurrentFileName;
+
+public:
+ CProgressSynch():
+ _stopped(false), _paused(false),
+ _totalBytes((UInt64)(Int64)-1), _curBytes(0),
+ _totalFiles((UInt64)(Int64)-1), _curFiles(0),
+ _inSize((UInt64)(Int64)-1),
+ _outSize((UInt64)(Int64)-1),
+ _bytesProgressMode(true)
+ {}
+
+ bool GetStopped()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ return _stopped;
+ }
+ void SetStopped(bool value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _stopped = value;
+ }
+ bool GetPaused()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ return _paused;
+ }
+ void SetPaused(bool value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _paused = value;
+ }
+ void SetBytesProgressMode(bool bytesProgressMode)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _bytesProgressMode = bytesProgressMode;
+ }
+ void SetProgress(UInt64 total, UInt64 completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _totalBytes = total;
+ _curBytes = completed;
+ }
+ void SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ if (inSize)
+ _inSize = *inSize;
+ if (outSize)
+ _outSize = *outSize;
+ }
+ void SetPos(UInt64 completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _curBytes = completed;
+ }
+ void SetNumBytesTotal(UInt64 value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _totalBytes = value;
+ }
+ void SetNumFilesTotal(UInt64 value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _totalFiles = value;
+ }
+ void SetNumFilesCur(UInt64 value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _curFiles = value;
+ }
+ HRESULT ProcessStopAndPause();
+ HRESULT SetPosAndCheckPaused(UInt64 completed);
+ void GetProgress(UInt64 &total, UInt64 &completed,
+ UInt64 &totalFiles, UInt64 &curFiles,
+ UInt64 &inSize, UInt64 &outSize,
+ bool &bytesProgressMode)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ total = _totalBytes;
+ completed = _curBytes;
+ totalFiles = _totalFiles;
+ curFiles = _curFiles;
+ inSize = _inSize;
+ outSize = _outSize;
+ bytesProgressMode = _bytesProgressMode;
+ }
+ void SetTitleFileName(const UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ TitleFileName = fileName;
+ }
+ void GetTitleFileName(UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ fileName = TitleFileName;
+ }
+ void SetCurrentFileName(const UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ CurrentFileName = fileName;
+ }
+ void GetCurrentFileName(UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ fileName = CurrentFileName;
+ }
+};
+
+class CU64ToI32Converter
+{
+ UInt64 _numShiftBits;
+public:
+ void Init(UInt64 _range);
+ int Count(UInt64 aValue);
+};
+
+// class CProgressDialog: public NWindows::NControl::CModelessDialog
+
+enum ESpeedMode
+{
+ kSpeedBytes,
+ kSpeedKBytes,
+ kSpeedMBytes
+};
+
+class CProgressDialog: public NWindows::NControl::CModalDialog
+{
+ UString _prevFileName;
+ UString _prevTitleName;
+private:
+ UString backgroundString;
+ UString backgroundedString;
+ UString foregroundString;
+ UString pauseString;
+ UString continueString;
+ UString pausedString;
+
+
+
+ UINT_PTR _timer;
+
+ UString _title;
+ CU64ToI32Converter _converter;
+ UInt64 _previousPos;
+ UInt64 _range;
+ NWindows::NControl::CProgressBar m_ProgressBar;
+
+ UInt32 _prevPercentValue;
+ UInt32 _prevTime;
+ UInt32 _elapsedTime;
+ UInt32 _prevElapsedSec;
+ UInt64 _prevRemainingSec;
+ ESpeedMode _prevMode;
+ UInt64 _prevSpeed;
+
+ bool _foreground;
+
+ bool OnTimer(WPARAM timerID, LPARAM callback);
+ void SetRange(UInt64 range);
+ void SetPos(UInt64 pos);
+ virtual bool OnInit();
+ virtual void OnCancel();
+ NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
+ #ifndef _SFX
+ void AddToTitle(LPCWSTR string);
+ #endif
+
+ void SetPauseText();
+ void SetPriorityText();
+ void OnPauseButton();
+ void OnPriorityButton();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+
+ void SetTitleText();
+ void ShowSize(int id, UInt64 value);
+
+public:
+ CProgressSynch ProgressSynch;
+ bool CompressingMode;
+
+ #ifndef _SFX
+ HWND MainWindow;
+ UString MainTitle;
+ UString MainAddTitle;
+ ~CProgressDialog();
+ #endif
+
+ CProgressDialog(): _timer(0), CompressingMode(true)
+ #ifndef _SFX
+ ,MainWindow(0)
+ #endif
+ {
+ if (_dialogCreatedEvent.Create() != S_OK)
+ throw 1334987;
+ }
+
+ void WaitCreating() { _dialogCreatedEvent.Lock(); }
+
+
+ INT_PTR Create(const UString &title, HWND wndParent = 0)
+ {
+ _title = title;
+ return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
+ }
+
+ static const UINT kCloseMessage;
+
+ virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+
+ void MyClose() { PostMessage(kCloseMessage); };
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2Res.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2Res.h
new file mode 100644
index 000000000..16bf26342
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2Res.h
@@ -0,0 +1,26 @@
+#define IDC_BUTTON_PAUSE 3
+#define IDC_BUTTON_PROGRESS_PRIORITY 4
+#define IDD_DIALOG_PROGRESS 500
+#define IDS_PROGRESS_PAUSED 700
+#define IDS_PROGRESS_FOREGROUND 701
+#define IDS_PROGRESS_CONTINUE 702
+#define IDS_PROGRESS_ASK_CANCEL 703
+#define IDC_PROGRESS1 1000
+#define IDC_PROGRESS_ELAPSED 1002
+#define IDC_PROGRESS_ELAPSED_VALUE 1003
+#define IDC_PROGRESS_REMAINING 1004
+#define IDC_PROGRESS_REMAINING_VALUE 1005
+#define IDC_PROGRESS_SPEED 1006
+#define IDC_PROGRESS_SPEED_VALUE 1007
+#define IDC_PROGRESS_TOTAL 1008
+#define IDC_PROGRESS_TOTAL_VALUE 1009
+#define IDC_PROGRESS_FILE_NAME 1010
+
+#define IDC_PROGRESS_FILES 1012
+#define IDC_PROGRESS_FILES_VALUE 1013
+#define IDC_PROGRESS_RATIO 1014
+#define IDC_PROGRESS_RATIO_VALUE 1015
+#define IDC_PROGRESS_PACKED 1016
+#define IDC_PROGRESS_PACKED_VALUE 1017
+#define IDC_PROGRESS_UNPACKED 1018
+#define IDC_PROGRESS_UNPACKED_VALUE 1019
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2_rc.cpp
new file mode 100644
index 000000000..016c9c85a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialog2_rc.cpp
@@ -0,0 +1,171 @@
+// ProgressDialog2_rc.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "ProgressDialog2Res.h"
+
+#include "Windows/Control/DialogImpl.h"
+
+/*
+IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
+CAPTION "Progress"
+MY_FONT
+BEGIN
+ PUSHBUTTON "&Background", IDC_BUTTON_PROGRESS_PRIORITY, bXPos3, bYPos, bXSize, bYSize
+ PUSHBUTTON "&Pause", IDC_BUTTON_PAUSE, bXPos2, bYPos, bXSize, bYSize
+ PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize
+ LTEXT "Elapsed time:", IDC_PROGRESS_ELAPSED, marg, y0, x0Size, 8
+ LTEXT "Remaining time:", IDC_PROGRESS_REMAINING, marg, y1, x0Size, 8
+ LTEXT "Files:", IDC_PROGRESS_FILES, marg, y2, x0Size, 8
+ LTEXT "Compression ratio:",IDC_PROGRESS_RATIO, marg, y3, x0Size, 8
+
+ LTEXT "Total size:", IDC_PROGRESS_TOTAL, x2, y0, x2Size, 8
+ LTEXT "Speed:", IDC_PROGRESS_SPEED, x2, y1, x2Size, 8
+ LTEXT "Processed:", IDC_PROGRESS_UNPACKED, x2, y2, x2Size, 8
+ LTEXT "Compressed size:", IDC_PROGRESS_PACKED, x2, y3, x2Size, 8
+
+ RTEXT "00:00:00", IDC_PROGRESS_ELAPSED_VALUE, x1, y0, x1Size, 8
+ RTEXT "", IDC_PROGRESS_REMAINING_VALUE, x1, y1, x1Size, 8
+ RTEXT "", IDC_PROGRESS_FILES_VALUE, x1, y2, x1Size, 8
+ RTEXT "", IDC_PROGRESS_RATIO_VALUE, x1, y3, x1Size, 8
+
+ RTEXT "", IDC_PROGRESS_TOTAL_VALUE, x3, y0, x3Size, 8
+ RTEXT "", IDC_PROGRESS_SPEED_VALUE, x3, y1, x3Size, 8
+ RTEXT "", IDC_PROGRESS_UNPACKED_VALUE, x3, y2, x3Size, 8
+ RTEXT "", IDC_PROGRESS_PACKED_VALUE, x3, y3, x3Size, 8
+
+ LTEXT "", IDC_PROGRESS_FILE_NAME, marg, bYPos - 30, xSize2, 8, SS_NOPREFIX
+ CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, marg, bYPos - 20, xSize2, 13
+END
+
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_PROGRESS_PAUSED "Paused"
+ IDS_PROGRESS_FOREGROUND "&Foreground"
+ IDS_PROGRESS_CONTINUE "&Continue"
+ IDS_PROGRESS_ASK_CANCEL "Are you sure you want to cancel?"
+END
+
+*/
+class CProgressDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CProgressDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Progress"))
+ {
+// FIXME : ProgressDialog2 but ProgressDialog ...
+
+ ///Sizer for adding the controls created by users
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ wxStaticText *pStaticTextElapsedTime = new wxStaticText(this, IDC_PROGRESS_ELAPSED, wxT("Elapsed time:"));
+ wxStaticText *m_pStaticTextElapsedTime = new wxStaticText(this, IDC_PROGRESS_ELAPSED_VALUE, wxT("00:00:00"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ wxStaticText *pStaticTextRemainingTime = new wxStaticText(this, IDC_PROGRESS_REMAINING, wxT("Remaining time"));
+ wxStaticText *m_pStaticTextRemainingTime = new wxStaticText(this, IDC_PROGRESS_REMAINING_VALUE, wxT("00:00:00"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxStaticText *pStaticTextFiles = new wxStaticText(this, IDC_PROGRESS_FILES, wxT("Files:"));
+ wxStaticText *m_pStaticTextFiles = new wxStaticText(this, IDC_PROGRESS_FILES_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxStaticText *pStaticTextRatio = new wxStaticText(this, IDC_PROGRESS_RATIO, wxT("Compression ratio:"));
+ wxStaticText *m_pStaticTextRatio = new wxStaticText(this, IDC_PROGRESS_RATIO_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+
+ wxStaticText *pStaticTextSize = new wxStaticText(this, IDC_PROGRESS_TOTAL, wxT("Total Size:"));
+ wxStaticText *m_pStaticTextSize = new wxStaticText(this, IDC_PROGRESS_TOTAL_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ wxStaticText *pStaticTextSpeed = new wxStaticText(this, IDC_PROGRESS_SPEED, wxT("Speed:"));
+ wxStaticText *m_pStaticTextSpeed = new wxStaticText(this, IDC_PROGRESS_SPEED_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxStaticText *pStaticTextUnpacked = new wxStaticText(this, IDC_PROGRESS_UNPACKED, wxT("Processed:"));
+ wxStaticText *m_pStaticTextUnpacked = new wxStaticText(this, IDC_PROGRESS_UNPACKED, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxStaticText *pStaticTextPacked = new wxStaticText(this, IDC_PROGRESS_PACKED, wxT("Compressed size:"));
+ wxStaticText *m_pStaticTextPacked = new wxStaticText(this, IDC_PROGRESS_PACKED_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxBoxSizer *pInfoSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pTimeSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pTimeLabelSizer = new wxBoxSizer(wxVERTICAL);
+ pTimeLabelSizer->Add(pStaticTextElapsedTime , 0, wxALL|wxEXPAND, 5);
+ pTimeLabelSizer->Add(pStaticTextRemainingTime, 0, wxALL|wxEXPAND, 5);
+ pTimeLabelSizer->Add(pStaticTextFiles , 0, wxALL|wxEXPAND, 5);
+ pTimeLabelSizer->Add(pStaticTextRatio , 0, wxALL|wxEXPAND, 5);
+ wxBoxSizer *pTimeInfoSizer = new wxBoxSizer(wxVERTICAL);
+ pTimeInfoSizer->Add(m_pStaticTextElapsedTime , 0, wxALL|wxEXPAND, 5);
+ pTimeInfoSizer->Add(m_pStaticTextRemainingTime, 0, wxALL|wxEXPAND, 5);
+ pTimeInfoSizer->Add(m_pStaticTextFiles , 0, wxALL|wxEXPAND, 5);
+ pTimeInfoSizer->Add(m_pStaticTextRatio , 0, wxALL|wxEXPAND, 5);
+ pTimeSizer->Add(pTimeLabelSizer , 0, wxALL|wxEXPAND, 5);
+ pTimeSizer->Add(pTimeInfoSizer , 0, wxALL|wxEXPAND, 5);
+ wxBoxSizer *pSizeSpeedSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pSizeSpeedLabelSizer = new wxBoxSizer(wxVERTICAL);
+ pSizeSpeedLabelSizer->Add(pStaticTextSize , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedLabelSizer->Add(pStaticTextSpeed , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedLabelSizer->Add(pStaticTextUnpacked , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedLabelSizer->Add(pStaticTextPacked , 0, wxALL|wxEXPAND, 5);
+
+ wxBoxSizer *pSizeSpeedInfoSizer = new wxBoxSizer(wxVERTICAL);
+ pSizeSpeedInfoSizer->Add(m_pStaticTextSize , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedInfoSizer->Add(m_pStaticTextSpeed , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedInfoSizer->Add(m_pStaticTextUnpacked, 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedInfoSizer->Add(m_pStaticTextPacked , 0, wxALL|wxEXPAND, 5);
+
+ pSizeSpeedSizer->Add(pSizeSpeedLabelSizer, 1, wxALL|wxEXPAND, 5);
+ pSizeSpeedSizer->Add(pSizeSpeedInfoSizer, 1, wxALL|wxEXPAND, 5);
+ pInfoSizer->Add(pTimeSizer, 0, wxALL|wxEXPAND, 5);
+ pInfoSizer->Add(pSizeSpeedSizer, 0, wxALL|wxEXPAND, 5);
+
+ wxStaticText *m_pStaticArchiveName = new wxStaticText(this, IDC_PROGRESS_FILE_NAME, wxT(" \n "));
+ wxGauge *m_pGaugeProgress = new wxGauge(this, IDC_PROGRESS1, 100);
+
+ wxBoxSizer *pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxButton *m_pButtonBackground = new wxButton(this, IDC_BUTTON_PROGRESS_PRIORITY, wxT("&Background"));
+ wxButton *m_pButtonPause = new wxButton(this, IDC_BUTTON_PAUSE, wxT("&Pause"));
+ wxButton *m_pButtonCancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));
+ // FIXME pButtonSizer->AddStretchSpacer(1);
+ pButtonSizer->Add(m_pButtonBackground, 0, wxALL|wxEXPAND, 5);
+ pButtonSizer->Add(m_pButtonPause, 0, wxALL|wxEXPAND, 5);
+ pButtonSizer->Add(m_pButtonCancel, 0, wxALL|wxEXPAND, 5);
+
+ topsizer->Add(pInfoSizer, 0, wxBOTTOM|wxEXPAND, 5);
+ topsizer->Add(m_pStaticArchiveName, 0, wxLEFT|wxRIGHT|wxEXPAND, 10);
+ topsizer->Add(m_pGaugeProgress, 0, wxALL|wxEXPAND, 10);
+ topsizer->Add(pButtonSizer, 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { IDS_PROGRESS_PAUSED , L"Paused" },
+ { IDS_PROGRESS_FOREGROUND , L"&Foreground" },
+ { IDS_PROGRESS_CONTINUE , L"&Continue" },
+ { IDS_PROGRESS_ASK_CANCEL , L"Are you sure you want to cancel?" },
+ { 0 , 0 }
+};
+
+REGISTER_DIALOG(IDD_DIALOG_PROGRESS,CProgressDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(CProgressDialogImpl, wxDialog)
+ EVT_TIMER(wxID_ANY, CModalDialogImpl::OnAnyTimer)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialogRes.h
new file mode 100644
index 000000000..97e47228d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ProgressDialogRes.h
@@ -0,0 +1,3 @@
+#define IDD_DIALOG_PROGRESS 500
+
+#define IDC_PROGRESS1 1000
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyName.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyName.cpp
new file mode 100644
index 000000000..48090d38b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyName.cpp
@@ -0,0 +1,109 @@
+// PropertyName.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+
+#include "Windows/ResourceString.h"
+
+#include "../../PropID.h"
+
+#include "LangUtils.h"
+#include "PropertyName.h"
+
+#include "resource.h"
+#include "PropertyNameRes.h"
+
+struct CPropertyIDNamePair
+{
+ PROPID PropID;
+ UINT ResourceID;
+ UInt32 LangID;
+};
+
+static CPropertyIDNamePair kPropertyIDNamePairs[] =
+{
+ { kpidPath, IDS_PROP_PATH, 0x02000203 },
+ { kpidName, IDS_PROP_NAME, 0x02000204 },
+ { kpidExtension, IDS_PROP_EXTENSION, 0x02000205 },
+ { kpidIsDir, IDS_PROP_IS_FOLDER, 0x02000206},
+ { kpidSize, IDS_PROP_SIZE, 0x02000207},
+ { kpidPackSize, IDS_PROP_PACKED_SIZE, 0x02000208 },
+ { kpidAttrib, IDS_PROP_ATTRIBUTES, 0x02000209 },
+ { kpidCTime, IDS_PROP_CTIME, 0x0200020A },
+ { kpidATime, IDS_PROP_ATIME, 0x0200020B },
+ { kpidMTime, IDS_PROP_MTIME, 0x0200020C },
+ { kpidSolid, IDS_PROP_SOLID, 0x0200020D },
+ { kpidCommented, IDS_PROP_C0MMENTED, 0x0200020E },
+ { kpidEncrypted, IDS_PROP_ENCRYPTED, 0x0200020F },
+ { kpidSplitBefore, IDS_PROP_SPLIT_BEFORE, 0x02000210 },
+ { kpidSplitAfter, IDS_PROP_SPLIT_AFTER, 0x02000211 },
+ { kpidDictionarySize, IDS_PROP_DICTIONARY_SIZE, 0x02000212 },
+ { kpidCRC, IDS_PROP_CRC, 0x02000213 },
+ { kpidType, IDS_PROP_FILE_TYPE, 0x02000214},
+ { kpidIsAnti, IDS_PROP_ANTI, 0x02000215 },
+ { kpidMethod, IDS_PROP_METHOD, 0x02000216 },
+ { kpidHostOS, IDS_PROP_HOST_OS, 0x02000217 },
+ { kpidFileSystem, IDS_PROP_FILE_SYSTEM, 0x02000218},
+ { kpidUser, IDS_PROP_USER, 0x02000219},
+ { kpidGroup, IDS_PROP_GROUP, 0x0200021A},
+ { kpidBlock, IDS_PROP_BLOCK, 0x0200021B },
+ { kpidComment, IDS_PROP_COMMENT, 0x0200021C },
+ { kpidPosition, IDS_PROP_POSITION, 0x0200021D },
+ { kpidPrefix, IDS_PROP_PREFIX, 0x0200021E },
+ { kpidNumSubDirs, IDS_PROP_FOLDERS, 0x0200021F },
+ { kpidNumSubFiles, IDS_PROP_FILES, 0x02000220 },
+ { kpidUnpackVer, IDS_PROP_VERSION, 0x02000221},
+ { kpidVolume, IDS_PROP_VOLUME, 0x02000222},
+ { kpidIsVolume, IDS_PROP_IS_VOLUME, 0x02000223},
+ { kpidOffset, IDS_PROP_OFFSET, 0x02000224},
+ { kpidLinks, IDS_PROP_LINKS, 0x02000225},
+ { kpidNumBlocks, IDS_PROP_NUM_BLOCKS, 0x02000226},
+ { kpidNumVolumes, IDS_PROP_NUM_VOLUMES, 0x02000227},
+
+ { kpidBit64, IDS_PROP_BIT64, 0x02000229},
+ { kpidBigEndian, IDS_PROP_BIG_ENDIAN, 0x0200022A},
+ { kpidCpu, IDS_PROP_CPU, 0x0200022B},
+ { kpidPhySize, IDS_PROP_PHY_SIZE, 0x0200022C},
+ { kpidHeadersSize, IDS_PROP_HEADERS_SIZE, 0x0200022D},
+ { kpidChecksum, IDS_PROP_CHECKSUM, 0x0200022E},
+ { kpidCharacts, IDS_PROP_CHARACTS, 0x0200022F},
+ { kpidVa, IDS_PROP_VA, 0x02000230},
+ { kpidId, IDS_PROP_ID, 0x02000231 },
+ { kpidShortName, IDS_PROP_SHORT_NAME, 0x02000232 },
+ { kpidCreatorApp, IDS_PROP_CREATOR_APP, 0x02000233 },
+ { kpidSectorSize, IDS_PROP_SECTOR_SIZE, 0x02000234 },
+ { kpidPosixAttrib, IDS_PROP_POSIX_ATTRIB, 0x02000235 },
+ { kpidLink, IDS_PROP_LINK, 0x02000236 },
+
+ { kpidTotalSize, IDS_PROP_TOTAL_SIZE, 0x03031100 },
+ { kpidFreeSpace, IDS_PROP_FREE_SPACE, 0x03031101 },
+ { kpidClusterSize, IDS_PROP_CLUSTER_SIZE, 0x03031102},
+ { kpidVolumeName, IDS_PROP_VOLUME_NAME, 0x03031103 },
+
+ { kpidLocalName, IDS_PROP_LOCAL_NAME, 0x03031200 },
+ { kpidProvider, IDS_PROP_PROVIDER, 0x03031201 }
+};
+
+int FindProperty(PROPID propID)
+{
+ for (int i = 0; i < sizeof(kPropertyIDNamePairs) / sizeof(kPropertyIDNamePairs[0]); i++)
+ if (kPropertyIDNamePairs[i].PropID == propID)
+ return i;
+ return -1;
+}
+
+UString GetNameOfProperty(PROPID propID, const wchar_t *name)
+{
+ int index = FindProperty(propID);
+ if (index < 0)
+ {
+ if (name)
+ return name;
+ wchar_t s[16];
+ ConvertUInt32ToString(propID, s);
+ return s;
+ }
+ const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index];
+ return LangString(pair.ResourceID, pair.LangID);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyName.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyName.h
new file mode 100644
index 000000000..95e9dc9b3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyName.h
@@ -0,0 +1,10 @@
+// PropertyName.h
+
+#ifndef __PROPERTYNAME_H
+#define __PROPERTYNAME_H
+
+#include "Common/MyString.h"
+
+UString GetNameOfProperty(PROPID propID, const wchar_t *name);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyNameRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyNameRes.h
new file mode 100644
index 000000000..00458a24f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/PropertyNameRes.h
@@ -0,0 +1,52 @@
+#define IDS_PROP_PATH 3
+#define IDS_PROP_NAME 4
+#define IDS_PROP_EXTENSION 5
+#define IDS_PROP_IS_FOLDER 6
+#define IDS_PROP_SIZE 7
+#define IDS_PROP_PACKED_SIZE 8
+#define IDS_PROP_ATTRIBUTES 9
+#define IDS_PROP_CTIME 10
+#define IDS_PROP_ATIME 11
+#define IDS_PROP_MTIME 12
+#define IDS_PROP_SOLID 13
+#define IDS_PROP_C0MMENTED 14
+#define IDS_PROP_ENCRYPTED 15
+#define IDS_PROP_DICTIONARY_SIZE 16
+#define IDS_PROP_SPLIT_BEFORE 17
+#define IDS_PROP_SPLIT_AFTER 18
+#define IDS_PROP_CRC 19
+#define IDS_PROP_FILE_TYPE 20
+#define IDS_PROP_ANTI 21
+#define IDS_PROP_METHOD 22
+#define IDS_PROP_HOST_OS 23
+#define IDS_PROP_FILE_SYSTEM 24
+#define IDS_PROP_USER 25
+#define IDS_PROP_GROUP 26
+#define IDS_PROP_BLOCK 27
+#define IDS_PROP_COMMENT 28
+#define IDS_PROP_POSITION 29
+#define IDS_PROP_PREFIX 30
+#define IDS_PROP_FOLDERS 31
+#define IDS_PROP_FILES 32
+#define IDS_PROP_VERSION 33
+#define IDS_PROP_VOLUME 34
+#define IDS_PROP_IS_VOLUME 35
+#define IDS_PROP_OFFSET 36
+#define IDS_PROP_LINKS 37
+#define IDS_PROP_NUM_BLOCKS 38
+#define IDS_PROP_NUM_VOLUMES 39
+
+#define IDS_PROP_BIT64 41
+#define IDS_PROP_BIG_ENDIAN 42
+#define IDS_PROP_CPU 43
+#define IDS_PROP_PHY_SIZE 44
+#define IDS_PROP_HEADERS_SIZE 45
+#define IDS_PROP_CHECKSUM 46
+#define IDS_PROP_CHARACTS 47
+#define IDS_PROP_VA 48
+#define IDS_PROP_ID 49
+#define IDS_PROP_SHORT_NAME 50
+#define IDS_PROP_CREATOR_APP 51
+#define IDS_PROP_SECTOR_SIZE 52
+#define IDS_PROP_POSIX_ATTRIB 53
+#define IDS_PROP_LINK 54
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
new file mode 100644
index 000000000..d4fbfe139
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
@@ -0,0 +1,301 @@
+// RegistryAssociations.cpp
+
+#include "StdAfx.h"
+
+#include "RegistryAssociations.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/Registry.h"
+#include "Windows/Synchronization.h"
+
+#include "StringUtils.h"
+
+using namespace NWindows;
+using namespace NRegistry;
+
+namespace NRegistryAssociations {
+
+static NSynchronization::CCriticalSection g_CriticalSection;
+
+#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") TEXT(STRING_PATH_SEPARATOR) TEXT("FM")
+
+static const TCHAR *kCUKeyPath = REG_PATH_FM;
+static const WCHAR *kExtPlugins = L"Plugins";
+static const TCHAR *kExtEnabled = TEXT("Enabled");
+
+#define kAssociations TEXT("Associations")
+#define kAssociationsPath REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) kAssociations
+
+bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER,
+ CSysString(kAssociationsPath TEXT(STRING_PATH_SEPARATOR)) +
+ GetSystemString(ext), KEY_READ) != ERROR_SUCCESS)
+ return false;
+ UString pluginsString;
+ key.QueryValue(kExtPlugins, pluginsString);
+ SplitString(pluginsString, extInfo.Plugins);
+ return true;
+}
+
+void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
+{
+ items.Clear();
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey associationsKey;
+ if (associationsKey.Open(HKEY_CURRENT_USER, kAssociationsPath, KEY_READ) != ERROR_SUCCESS)
+ return;
+ CSysStringVector extNames;
+ associationsKey.EnumKeys(extNames);
+ for(int i = 0; i < extNames.Size(); i++)
+ {
+ const CSysString extName = extNames[i];
+ CExtInfo extInfo;
+ // extInfo.Enabled = false;
+ extInfo.Ext = GetUnicodeString(extName);
+ CKey key;
+ if (key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS)
+ return;
+ UString pluginsString;
+ key.QueryValue(kExtPlugins, pluginsString);
+ SplitString(pluginsString, extInfo.Plugins);
+ /*
+ if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS)
+ extInfo.Enabled = false;
+ */
+ items.Add(extInfo);
+ }
+}
+
+void WriteInternalAssociations(const CObjectVector<CExtInfo> &items)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey mainKey;
+ mainKey.Create(HKEY_CURRENT_USER, kCUKeyPath);
+ mainKey.RecurseDeleteKey(kAssociations);
+ CKey associationsKey;
+ associationsKey.Create(mainKey, kAssociations);
+ for(int i = 0; i < items.Size(); i++)
+ {
+ const CExtInfo &extInfo = items[i];
+ CKey key;
+ key.Create(associationsKey, GetSystemString(extInfo.Ext));
+ key.SetValue(kExtPlugins, JoinStrings(extInfo.Plugins));
+ // key.SetValue(kExtEnabled, extInfo.Enabled);
+ }
+}
+
+///////////////////////////////////
+// External
+
+static const TCHAR *kShellNewKeyName = TEXT("ShellNew");
+static const TCHAR *kShellNewDataValueName = TEXT("Data");
+
+static const TCHAR *kDefaultIconKeyName = TEXT("DefaultIcon");
+static const TCHAR *kShellKeyName = TEXT("shell");
+static const TCHAR *kOpenKeyName = TEXT("open");
+static const TCHAR *kCommandKeyName = TEXT("command");
+
+static CSysString GetExtensionKeyName(const CSysString &extension)
+{
+ return CSysString(TEXT(".")) + extension;
+}
+
+static CSysString GetExtProgramKeyName(const CSysString &extension)
+{
+ return CSysString(TEXT("7-Zip.")) + extension;
+}
+
+static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconPath, int &iconIndex)
+{
+ iconIndex = -1;
+ iconPath.Empty();
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey extKey;
+ if (extKey.Open(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension), KEY_READ) != ERROR_SUCCESS)
+ return false;
+ CSysString programNameValue;
+ if (extKey.QueryValue(NULL, programNameValue) != ERROR_SUCCESS)
+ return false;
+ CSysString extProgramKeyName = GetExtProgramKeyName(extension);
+ UString programNameValueU = GetUnicodeString(programNameValue);
+ if (programNameValueU.CompareNoCase(GetUnicodeString(extProgramKeyName)) != 0)
+ return false;
+ CKey iconKey;
+ if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS)
+ return false;
+ UString value;
+ if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS)
+ {
+ int pos = value.ReverseFind(L',');
+ iconPath = value;
+ if (pos >= 0)
+ {
+ const wchar_t *end;
+ UInt64 index = ConvertStringToUInt64((const wchar_t *)value + pos + 1, &end);
+ if (*end == 0)
+ {
+ iconIndex = (int)index;
+ iconPath = value.Left(pos);
+ }
+ }
+ }
+ return true;
+}
+
+bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ if (!CheckShellExtensionInfo2(extension, iconPath, iconIndex))
+ return false;
+ CKey extProgKey;
+ return (extProgKey.Open(HKEY_CLASSES_ROOT, GetExtProgramKeyName(extension), KEY_READ) == ERROR_SUCCESS);
+}
+
+static void DeleteShellExtensionKey(const CSysString &extension)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey rootKey;
+ rootKey.Attach(HKEY_CLASSES_ROOT);
+ rootKey.RecurseDeleteKey(GetExtensionKeyName(extension));
+ rootKey.Detach();
+}
+
+static void DeleteShellExtensionProgramKey(const CSysString &extension)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey rootKey;
+ rootKey.Attach(HKEY_CLASSES_ROOT);
+ rootKey.RecurseDeleteKey(GetExtProgramKeyName(extension));
+ rootKey.Detach();
+}
+
+void DeleteShellExtensionInfo(const CSysString &extension)
+{
+ UString iconPath;
+ int iconIndex;
+ if (CheckShellExtensionInfo2(extension, iconPath, iconIndex))
+ DeleteShellExtensionKey(extension);
+ DeleteShellExtensionProgramKey(extension);
+}
+
+void AddShellExtensionInfo(const CSysString &extension,
+ const UString &programTitle,
+ const UString &programOpenCommand,
+ const UString &iconPath, int iconIndex,
+ const void *shellNewData, int shellNewDataSize)
+{
+ DeleteShellExtensionKey(extension);
+ DeleteShellExtensionProgramKey(extension);
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CSysString programKeyName = GetExtProgramKeyName(extension);
+ {
+ CKey extKey;
+ extKey.Create(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension));
+ extKey.SetValue(NULL, programKeyName);
+ if (shellNewData != NULL)
+ {
+ CKey shellNewKey;
+ shellNewKey.Create(extKey, kShellNewKeyName);
+ shellNewKey.SetValue(kShellNewDataValueName, shellNewData, shellNewDataSize);
+ }
+ }
+ CKey programKey;
+ programKey.Create(HKEY_CLASSES_ROOT, programKeyName);
+ programKey.SetValue(NULL, programTitle);
+ {
+ CKey iconKey;
+ iconKey.Create(programKey, kDefaultIconKeyName);
+ UString iconPathFull = iconPath;
+ if (iconIndex >= 0)
+ {
+ iconPathFull += L",";
+ wchar_t s[16];
+ ConvertUInt32ToString(iconIndex, s);
+ iconPathFull += s;
+ }
+ iconKey.SetValue(NULL, iconPathFull);
+ }
+
+ CKey shellKey;
+ shellKey.Create(programKey, kShellKeyName);
+ shellKey.SetValue(NULL, TEXT(""));
+
+ CKey openKey;
+ openKey.Create(shellKey, kOpenKeyName);
+ openKey.SetValue(NULL, TEXT(""));
+
+ CKey commandKey;
+ commandKey.Create(openKey, kCommandKeyName);
+
+ commandKey.SetValue(NULL, programOpenCommand);
+}
+
+///////////////////////////
+// ContextMenu
+/*
+
+static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-ZIP");
+static const TCHAR *kContextMenuHandlerCLASSIDValue =
+ TEXT("{23170F69-40C1-278A-1000-000100020000}");
+static const TCHAR *kRootKeyNameForFile = TEXT("*");
+static const TCHAR *kRootKeyNameForFolder = TEXT("Folder");
+
+static CSysString GetFullContextMenuKeyName(const CSysString &aKeyName)
+ { return (aKeyName + kContextMenuKeyName); }
+
+static bool CheckContextMenuHandlerCommon(const CSysString &aKeyName)
+{
+ NSynchronization::CCriticalSectionLock lock(&g_CriticalSection, true);
+ CKey aKey;
+ if (aKey.Open(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(aKeyName), KEY_READ)
+ != ERROR_SUCCESS)
+ return false;
+ CSysString aValue;
+ if (aKey.QueryValue(NULL, aValue) != ERROR_SUCCESS)
+ return false;
+ return (aValue.CompareNoCase(kContextMenuHandlerCLASSIDValue) == 0);
+}
+
+bool CheckContextMenuHandler()
+{
+ return CheckContextMenuHandlerCommon(kRootKeyNameForFile) &&
+ CheckContextMenuHandlerCommon(kRootKeyNameForFolder);
+}
+
+static void DeleteContextMenuHandlerCommon(const CSysString &aKeyName)
+{
+ CKey rootKey;
+ rootKey.Attach(HKEY_CLASSES_ROOT);
+ rootKey.RecurseDeleteKey(GetFullContextMenuKeyName(aKeyName));
+ rootKey.Detach();
+}
+
+void DeleteContextMenuHandler()
+{
+ DeleteContextMenuHandlerCommon(kRootKeyNameForFile);
+ DeleteContextMenuHandlerCommon(kRootKeyNameForFolder);
+}
+
+static void AddContextMenuHandlerCommon(const CSysString &aKeyName)
+{
+ DeleteContextMenuHandlerCommon(aKeyName);
+ NSynchronization::CCriticalSectionLock lock(&g_CriticalSection, true);
+ CKey aKey;
+ aKey.Create(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(aKeyName));
+ aKey.SetValue(NULL, kContextMenuHandlerCLASSIDValue);
+}
+
+void AddContextMenuHandler()
+{
+ AddContextMenuHandlerCommon(kRootKeyNameForFile);
+ AddContextMenuHandlerCommon(kRootKeyNameForFolder);
+}
+*/
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryAssociations.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryAssociations.h
new file mode 100644
index 000000000..2516fd2b6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryAssociations.h
@@ -0,0 +1,44 @@
+// RegistryAssociations.h
+
+#ifndef __REGISTRYASSOCIATIONS_H
+#define __REGISTRYASSOCIATIONS_H
+
+#include "Common/MyString.h"
+
+namespace NRegistryAssociations {
+
+ struct CExtInfo
+ {
+ UString Ext;
+ UStringVector Plugins;
+ // bool Enabled;
+ };
+ bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo);
+ void ReadInternalAssociations(CObjectVector<CExtInfo> &items);
+ void WriteInternalAssociations(const CObjectVector<CExtInfo> &items);
+
+ bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex);
+
+ // void ReadCompressionInfo(NZipSettings::NCompression::CInfo &anInfo,
+ void DeleteShellExtensionInfo(const CSysString &extension);
+
+ void AddShellExtensionInfo(const CSysString &extension,
+ const UString &programTitle,
+ const UString &programOpenCommand,
+ const UString &iconPath, int iconIndex,
+ const void *shellNewData, int shellNewDataSize);
+
+
+ ///////////////////////////
+ // ContextMenu
+ /*
+ bool CheckContextMenuHandler();
+ void AddContextMenuHandler();
+ void DeleteContextMenuHandler();
+ */
+
+}
+
+// bool GetProgramDirPrefix(CSysString &aFolder);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryPlugins.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryPlugins.h
new file mode 100644
index 000000000..77055ac77
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryPlugins.h
@@ -0,0 +1,32 @@
+// RegistryPlugins.h
+
+#ifndef __REGISTRYPLUGINS_H
+#define __REGISTRYPLUGINS_H
+
+#include "Common/MyString.h"
+
+enum EPluginType
+{
+ kPluginTypeFF = 0
+};
+
+struct CPluginInfo
+{
+ UString FilePath;
+ EPluginType Type;
+ UString Name;
+ CLSID ClassID;
+ CLSID OptionsClassID;
+ bool ClassIDDefined;
+ bool OptionsClassIDDefined;
+
+ // CSysString Extension;
+ // CSysString AddExtension;
+ // bool UpdateEnabled;
+ // bool KeepName;
+};
+
+void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins);
+void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryUtils.cpp
new file mode 100644
index 000000000..f071a9c95
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryUtils.cpp
@@ -0,0 +1,152 @@
+// RegistryUtils.cpp
+
+#include "StdAfx.h"
+
+#include "RegistryUtils.h"
+#include "Windows/Registry.h"
+
+using namespace NWindows;
+using namespace NRegistry;
+
+#define REG_PATH_7Z TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP")
+
+static const TCHAR *kCUBasePath = REG_PATH_7Z;
+static const TCHAR *kCU_FMPath = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM");
+// static const TCHAR *kLM_Path = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM");
+
+static const WCHAR *kLangValueName = L"Lang";
+static const WCHAR *kEditor = L"Editor";
+static const TCHAR *kShowDots = TEXT("ShowDots");
+static const TCHAR *kShowRealFileIcons = TEXT("ShowRealFileIcons");
+static const TCHAR *kShowSystemMenu = TEXT("ShowSystemMenu");
+
+static const TCHAR *kFullRow = TEXT("FullRow");
+static const TCHAR *kShowGrid = TEXT("ShowGrid");
+static const TCHAR *kAlternativeSelection = TEXT("AlternativeSelection");
+// static const TCHAR *kLockMemoryAdd = TEXT("LockMemoryAdd");
+static const TCHAR *kLargePagesEnable = TEXT("LargePages");
+// static const TCHAR *kSingleClick = TEXT("SingleClick");
+// static const TCHAR *kUnderline = TEXT("Underline");
+
+void SaveRegLang(const UString &langFile)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(kLangValueName, langFile);
+}
+
+void ReadRegLang(UString &langFile)
+{
+ langFile.Empty();
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
+ key.QueryValue(kLangValueName, langFile);
+}
+
+void SaveRegEditor(const UString &editorPath)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCU_FMPath);
+ key.SetValue(kEditor, editorPath);
+}
+
+void ReadRegEditor(UString &editorPath)
+{
+ editorPath.Empty();
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
+ key.QueryValue(kEditor, editorPath);
+}
+
+static void Save7ZipOption(const TCHAR *value, bool enabled)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(value, enabled);
+}
+
+static void SaveOption(const TCHAR *value, bool enabled)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCU_FMPath);
+ key.SetValue(value, enabled);
+}
+
+static bool Read7ZipOption(const TCHAR *value, bool defaultValue)
+{
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
+ {
+ bool enabled;
+ if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
+ return enabled;
+ }
+ return defaultValue;
+}
+
+static bool ReadOption(const TCHAR *value, bool defaultValue)
+{
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
+ {
+ bool enabled;
+ if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
+ return enabled;
+ }
+ return defaultValue;
+}
+
+/*
+static void SaveLmOption(const TCHAR *value, bool enabled)
+{
+ CKey key;
+ key.Create(HKEY_LOCAL_MACHINE, kLM_Path);
+ key.SetValue(value, enabled);
+}
+
+static bool ReadLmOption(const TCHAR *value, bool defaultValue)
+{
+ CKey key;
+ if (key.Open(HKEY_LOCAL_MACHINE, kLM_Path, KEY_READ) == ERROR_SUCCESS)
+ {
+ bool enabled;
+ if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
+ return enabled;
+ }
+ return defaultValue;
+}
+*/
+
+void SaveShowDots(bool showDots) { SaveOption(kShowDots, showDots); }
+bool ReadShowDots() { return ReadOption(kShowDots, false); }
+
+void SaveShowRealFileIcons(bool show) { SaveOption(kShowRealFileIcons, show); }
+bool ReadShowRealFileIcons() { return ReadOption(kShowRealFileIcons, false); }
+
+void SaveShowSystemMenu(bool show) { SaveOption(kShowSystemMenu, show); }
+bool ReadShowSystemMenu(){ return ReadOption(kShowSystemMenu, false); }
+
+void SaveFullRow(bool enable) { SaveOption(kFullRow, enable); }
+bool ReadFullRow() { return ReadOption(kFullRow, false); }
+
+void SaveShowGrid(bool enable) { SaveOption(kShowGrid, enable); }
+bool ReadShowGrid(){ return ReadOption(kShowGrid, false); }
+
+void SaveAlternativeSelection(bool enable) { SaveOption(kAlternativeSelection, enable); }
+bool ReadAlternativeSelection(){ return ReadOption(kAlternativeSelection, false); }
+
+/*
+void SaveSingleClick(bool enable) { SaveOption(kSingleClick, enable); }
+bool ReadSingleClick(){ return ReadOption(kSingleClick, false); }
+
+void SaveUnderline(bool enable) { SaveOption(kUnderline, enable); }
+bool ReadUnderline(){ return ReadOption(kUnderline, false); }
+*/
+
+// void SaveLockMemoryAdd(bool enable) { SaveLmOption(kLockMemoryAdd, enable); }
+// bool ReadLockMemoryAdd() { return ReadLmOption(kLockMemoryAdd, true); }
+
+void SaveLockMemoryEnable(bool enable) { Save7ZipOption(kLargePagesEnable, enable); }
+bool ReadLockMemoryEnable() { return Read7ZipOption(kLargePagesEnable, false); }
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryUtils.h
new file mode 100644
index 000000000..0fec6f80c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RegistryUtils.h
@@ -0,0 +1,46 @@
+// RegistryUtils.h
+
+#include "Common/StringConvert.h"
+
+#ifndef __REGISTRYUTILS_H
+#define __REGISTRYUTILS_H
+
+void SaveRegLang(const UString &langFile);
+void ReadRegLang(UString &langFile);
+
+void SaveRegEditor(const UString &editorPath);
+void ReadRegEditor(UString &editorPath);
+
+void SaveShowDots(bool showDots);
+bool ReadShowDots();
+
+void SaveShowRealFileIcons(bool show);
+bool ReadShowRealFileIcons();
+
+void SaveShowSystemMenu(bool showSystemMenu);
+bool ReadShowSystemMenu();
+
+void SaveFullRow(bool enable);
+bool ReadFullRow();
+
+void SaveShowGrid(bool enable);
+bool ReadShowGrid();
+
+void SaveAlternativeSelection(bool enable);
+bool ReadAlternativeSelection();
+
+// void SaveLockMemoryAdd(bool enable);
+// bool ReadLockMemoryAdd();
+
+bool ReadLockMemoryEnable();
+void SaveLockMemoryEnable(bool enable);
+
+/*
+void SaveSingleClick(bool enable);
+bool ReadSingleClick();
+
+void SaveUnderline(bool enable);
+bool ReadUnderline();
+*/
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RootFolder.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RootFolder.cpp
new file mode 100644
index 000000000..bf9083bc4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RootFolder.cpp
@@ -0,0 +1,278 @@
+// RootFolder.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "RootFolder.h"
+
+#include "Common/StringConvert.h"
+#include "../../PropID.h"
+#include "Windows/Defs.h"
+#include "Windows/PropVariant.h"
+
+#ifdef _WIN32
+#include "FSDrives.h"
+#include "PhysDriveFolder.h"
+#include "NetFolder.h"
+#endif
+#include "SysIconUtils.h"
+#include "LangUtils.h"
+
+using namespace NWindows;
+
+
+static const STATPROPSTG kProperties[] =
+{
+ { NULL, kpidName, VT_BSTR}
+};
+
+// static const wchar_t *kMyComputerTitle = L"Computer";
+// static const wchar_t *kMyNetworkTitle = L"Network";
+
+#ifdef _WIN32
+UString RootFolder_GetName_Computer(int &iconIndex)
+{
+ iconIndex = GetIconIndexForCSIDL(CSIDL_DRIVES);
+ return LangString(IDS_COMPUTER, 0x03020300);
+}
+
+UString RootFolder_GetName_Network(int &iconIndex)
+{
+ iconIndex = GetIconIndexForCSIDL(CSIDL_NETWORK);
+ return LangString(IDS_NETWORK, 0x03020301);
+}
+
+UString RootFolder_GetName_Documents(int &iconIndex)
+{
+ iconIndex = GetIconIndexForCSIDL(CSIDL_PERSONAL);
+ return LangString(IDS_DOCUMENTS, 0x03020302); ;
+}
+
+const int ROOT_INDEX_COMPUTER = 0;
+const int ROOT_INDEX_DOCUMENTS = 1;
+const int ROOT_INDEX_NETWORK = 2;
+
+void CRootFolder::Init()
+{
+ _names[ROOT_INDEX_COMPUTER] = RootFolder_GetName_Computer(_iconIndices[ROOT_INDEX_COMPUTER]);
+ _names[ROOT_INDEX_DOCUMENTS] = RootFolder_GetName_Documents(_iconIndices[ROOT_INDEX_DOCUMENTS]);
+ _names[ROOT_INDEX_NETWORK] = RootFolder_GetName_Network(_iconIndices[ROOT_INDEX_NETWORK]);
+};
+#else
+void CRootFolder::Init()
+{
+}
+#endif
+
+STDMETHODIMP CRootFolder::LoadItems()
+{
+ Init();
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetNumberOfItems(UInt32 *numItems)
+{
+#ifdef _WIN32
+ *numItems = kNumRootFolderItems;
+#else
+ *numItems = 1; // only "/" !
+#endif
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidIsDir: prop = true; break;
+#ifdef _WIN32
+ case kpidName: prop = _names[itemIndex]; break;
+#else
+ case kpidName: prop = L"/"; break;
+#endif
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+#ifdef _WIN32
+UString GetMyDocsPath()
+{
+ UString us;
+ WCHAR s[MAX_PATH + 1];
+ if (SHGetSpecialFolderPathW(0, s, CSIDL_PERSONAL, FALSE))
+ us = s;
+ #ifndef _UNICODE
+ else
+ {
+ CHAR s2[MAX_PATH + 1];
+ if (SHGetSpecialFolderPathA(0, s2, CSIDL_PERSONAL, FALSE))
+ us = GetUnicodeString(s2);
+ }
+ #endif
+ if (us.Length() > 0 && us[us.Length() - 1] != L'\\')
+ us += L'\\';
+ return us;
+}
+#endif
+
+STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
+{
+#ifdef _WIN32
+ if (index == ROOT_INDEX_COMPUTER)
+ {
+ CFSDrives *fsDrivesSpec = new CFSDrives;
+ CMyComPtr<IFolderFolder> subFolder = fsDrivesSpec;
+ fsDrivesSpec->Init();
+ *resultFolder = subFolder.Detach();
+ }
+ else if (index == ROOT_INDEX_NETWORK)
+ {
+ CNetFolder *netFolderSpec = new CNetFolder;
+ CMyComPtr<IFolderFolder> subFolder = netFolderSpec;
+ netFolderSpec->Init(0, 0, _names[ROOT_INDEX_NETWORK] + L'\\');
+ *resultFolder = subFolder.Detach();
+ }
+ else if (index == ROOT_INDEX_DOCUMENTS)
+ {
+ UString s = GetMyDocsPath();
+ if (!s.IsEmpty())
+ {
+ NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
+ CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
+ RINOK(fsFolderSpec->Init(s, NULL));
+ *resultFolder = subFolder.Detach();
+ }
+ }
+ else
+ return E_INVALIDARG;
+ return S_OK;
+#else
+ return E_INVALIDARG;
+#endif
+}
+
+static bool AreEqualNames(const UString &name1, const UString &name2)
+{
+ return (name1 == name2 || name1 == (name2 + UString(WCHAR_PATH_SEPARATOR)));
+}
+
+STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ UString name2 = name;
+ name2.Trim();
+ if (name2.IsEmpty())
+ {
+ CRootFolder *rootFolderSpec = new CRootFolder;
+ CMyComPtr<IFolderFolder> rootFolder = rootFolderSpec;
+ rootFolderSpec->Init();
+ *resultFolder = rootFolder.Detach();
+ return S_OK;
+ }
+#ifdef _WIN32
+ for (int i = 0; i < kNumRootFolderItems; i++)
+ if (AreEqualNames(name2, _names[i]))
+ return BindToFolder((UInt32)i, resultFolder);
+ if (AreEqualNames(name2, L"My Documents") ||
+ AreEqualNames(name2, L"Documents"))
+ return BindToFolder((UInt32)ROOT_INDEX_DOCUMENTS, resultFolder);
+ if (AreEqualNames(name2, L"My Computer") ||
+ AreEqualNames(name2, L"Computer"))
+ return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder);
+#endif
+ if (name2 == UString(WCHAR_PATH_SEPARATOR))
+ {
+ CMyComPtr<IFolderFolder> subFolder = this;
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+ }
+
+ if (name2.Length () < 2)
+ return E_INVALIDARG;
+
+ CMyComPtr<IFolderFolder> subFolder;
+
+#ifdef _WIN32
+ if (name2.Left(4) == L"\\\\.\\")
+ {
+ CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
+ subFolder = folderSpec;
+ RINOK(folderSpec->Init(name2.Mid(4, 2)));
+ }
+ else
+#endif
+ {
+ if (name2[name2.Length () - 1] != WCHAR_PATH_SEPARATOR)
+ name2 += WCHAR_PATH_SEPARATOR;
+ NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
+ subFolder = fsFolderSpec;
+ if (fsFolderSpec->Init(name2, 0) != S_OK)
+ {
+#ifdef _WIN32
+ if (name2[0] == WCHAR_PATH_SEPARATOR)
+ {
+ CNetFolder *netFolderSpec = new CNetFolder;
+ subFolder = netFolderSpec;
+ netFolderSpec->Init(name2);
+ }
+ else
+#endif
+ return E_INVALIDARG;
+ }
+ }
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::BindToParentFolder(IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetNumberOfProperties(UInt32 *numProperties)
+{
+ *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetPropertyInfo(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
+ return E_INVALIDARG;
+ const STATPROPSTG &prop = kProperties[index];
+ *propID = prop.propid;
+ *varType = prop.vt;
+ *name = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidType: prop = L"RootFolder"; break;
+ case kpidPath: prop = L""; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
+{
+#ifdef _WIN32
+ *iconIndex = _iconIndices[index];
+#else
+ *iconIndex = -1; // FIXME - folder icon ?
+#endif
+ return S_OK;
+}
+
+
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RootFolder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RootFolder.h
new file mode 100644
index 000000000..a65bb7601
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/RootFolder.h
@@ -0,0 +1,38 @@
+// RootFolder.h
+
+#ifndef __ROOTFOLDER_H
+#define __ROOTFOLDER_H
+
+#include "Common/MyString.h"
+
+#include "Windows/PropVariant.h"
+
+#include "FSFolder.h"
+
+#ifdef _WIN32
+const int kNumRootFolderItems = 3;
+#endif
+
+class CRootFolder:
+ public IFolderFolder,
+ public IFolderGetSystemIconIndex,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(
+ IFolderGetSystemIconIndex
+ )
+
+ INTERFACE_FolderFolder(;)
+
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
+
+ void Init();
+private:
+#ifdef _WIN32
+ UString _names[kNumRootFolderItems];
+ int _iconIndices[kNumRootFolderItems];
+#endif
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog.cpp
new file mode 100644
index 000000000..bab319d19
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog.cpp
@@ -0,0 +1,89 @@
+// SplitDialog.cpp
+
+#include "StdAfx.h"
+#include "SplitDialog.h"
+
+#include "Common/StringToInt.h"
+#include "Windows/Shell.h"
+#include "Windows/FileName.h"
+
+#include "SplitUtils.h"
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+#include "CopyDialogRes.h"
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_SPLIT_PATH, 0x03020501 },
+ { IDC_STATIC_SPLIT_VOLUME, 0x02000D40 },
+};
+#endif
+
+
+bool CSplitDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x03020500);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _pathCombo.Attach(GetItem(IDC_COMBO_SPLIT_PATH));
+ _volumeCombo.Attach(GetItem(IDC_COMBO_SPLIT_VOLUME));
+
+ if (!FilePath.IsEmpty())
+ {
+ UString title;
+ GetText(title);
+ title += L' ';
+ title += FilePath;
+ SetText(title);
+ }
+ _pathCombo.SetText(Path);
+ AddVolumeItems(_volumeCombo);
+ _volumeCombo.SetCurSel(0);
+ return CModalDialog::OnInit();
+}
+
+bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_BUTTON_SPLIT_PATH:
+ OnButtonSetPath();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CSplitDialog::OnButtonSetPath()
+{
+ UString currentPath;
+ _pathCombo.GetText(currentPath);
+ // UString title = L"Specify a location for output folder";
+ UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209);
+
+ UString resultPath;
+ if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
+ return;
+ NFile::NName::NormalizeDirPathPrefix(resultPath);
+ _pathCombo.SetCurSel(-1);
+ _pathCombo.SetText(resultPath);
+}
+
+void CSplitDialog::OnOK()
+{
+ _pathCombo.GetText(Path);
+ UString volumeString;
+ _volumeCombo.GetText(volumeString);
+ volumeString.Trim();
+ if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0)
+ {
+ ::MessageBoxW(*this, LangString(IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0);
+ return;
+ }
+ CModalDialog::OnOK();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog.h
new file mode 100644
index 000000000..607a3daf5
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog.h
@@ -0,0 +1,27 @@
+// SplitDialog.h
+
+#ifndef __SPLITDIALOG_H
+#define __SPLITDIALOG_H
+
+#include "Common/Types.h"
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ComboBox.h"
+#include "SplitDialogRes.h"
+
+class CSplitDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox _pathCombo;
+ NWindows::NControl::CComboBox _volumeCombo;
+ virtual void OnOK();
+ virtual bool OnInit();
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ void OnButtonSetPath();
+public:
+ UString FilePath;
+ UString Path;
+ CRecordVector<UInt64> VolumeSizes;
+ INT_PTR Create(HWND parentWindow = 0)
+ { return CModalDialog::Create(IDD_DIALOG_SPLIT, parentWindow); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialogRes.h
new file mode 100644
index 000000000..019b70292
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialogRes.h
@@ -0,0 +1,8 @@
+#define IDD_DIALOG_SPLIT 504
+#define IDC_STATIC_SPLIT_PATH 1000
+#define IDC_COMBO_SPLIT_PATH 1001
+#define IDC_BUTTON_SPLIT_PATH 1002
+#define IDC_STATIC_SPLIT_VOLUME 1010
+#define IDC_COMBO_SPLIT_VOLUME 1011
+
+#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog_rc.cpp
new file mode 100644
index 000000000..848b84ad7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitDialog_rc.cpp
@@ -0,0 +1,79 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "SplitDialogRes.h"
+
+class CSplitDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CSplitDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) : CModalDialogImpl(dialog, parent, id, wxT("Split File"))
+ {
+
+ wxArrayString pathArray;
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_SPLIT_PATH, _T("&Split to:")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+
+ {
+ wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL);
+
+ wxComboBox *combo = new wxComboBox(this, IDC_COMBO_SPLIT_PATH, wxEmptyString, wxDefaultPosition, wxSize(600,-1), pathArray, wxCB_DROPDOWN|wxCB_SORT);
+ wxButton *button = new wxButton(this, IDC_BUTTON_SPLIT_PATH, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pathSizer->Add(combo, 1, wxLEFT|wxRIGHT|wxEXPAND, 5);
+ pathSizer->Add(button, 0, wxLEFT|wxRIGHT|wxEXPAND, 5);
+
+ topsizer->Add(pathSizer, 0 ,wxALL | wxALIGN_LEFT, 5 );
+ }
+
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_SPLIT_VOLUME, _T("Split to &volumes, bytes:")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+ wxComboBox *combo = new wxComboBox(this, IDC_COMBO_SPLIT_VOLUME, wxEmptyString, wxDefaultPosition, wxSize(600,-1), pathArray, wxCB_DROPDOWN|wxCB_SORT);
+
+ topsizer->Add(combo, 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { IDS_COMPRESS_INCORRECT_VOLUME_SIZE, L"Incorrect volume size" },
+ { 0 , 0 }
+};
+
+
+REGISTER_DIALOG(IDD_DIALOG_SPLIT,CSplitDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(CSplitDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitUtils.cpp
new file mode 100644
index 000000000..3a7635fa1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitUtils.cpp
@@ -0,0 +1,85 @@
+// SplitUtils.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringToInt.h"
+
+#include "SplitUtils.h"
+#include "StringUtils.h"
+
+bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values)
+{
+ values.Clear();
+ UStringVector destStrings;
+ SplitString(s, destStrings);
+ bool prevIsNumber = false;
+ for (int i = 0; i < destStrings.Size(); i++)
+ {
+ UString subString = destStrings[i];
+ subString.MakeUpper();
+ if (subString.IsEmpty())
+ return false;
+ if (subString == L"-")
+ return true;
+ if (prevIsNumber)
+ {
+ wchar_t c = subString[0];
+ UInt64 &value = values.Back();
+ prevIsNumber = false;
+ switch(c)
+ {
+ case L'B':
+ continue;
+ case L'K':
+ value <<= 10;
+ continue;
+ case L'M':
+ value <<= 20;
+ continue;
+ case L'G':
+ value <<= 30;
+ continue;
+ }
+ }
+ const wchar_t *start = subString;
+ const wchar_t *end;
+ UInt64 value = ConvertStringToUInt64(start, &end);
+ if (start == end)
+ return false;
+ if (value == 0)
+ return false;
+ values.Add(value);
+ prevIsNumber = true;
+ UString rem = subString.Mid((int)(end - start));
+ if (!rem.IsEmpty())
+ destStrings.Insert(i + 1, rem);
+ }
+ return true;
+}
+
+void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo)
+{
+ volumeCombo.AddString(TEXT("1457664 - 3.5\" floppy"));
+ volumeCombo.AddString(TEXT("650M - CD"));
+ volumeCombo.AddString(TEXT("700M - CD"));
+ volumeCombo.AddString(TEXT("4480M - DVD"));
+}
+
+UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector<UInt64> &volSizes)
+{
+ if (size == 0 || volSizes.Size() == 0)
+ return 1;
+ UInt64 numVolumes = 0;
+ for (int i = 0; i < volSizes.Size(); i++)
+ {
+ UInt64 volSize = volSizes[i];
+ numVolumes++;
+ if (volSize >= size)
+ return numVolumes;
+ size -= volSize;
+ }
+ UInt64 volSize = volSizes.Back();
+ if (volSize == 0)
+ return (UInt64)(Int64)-1;
+ return numVolumes + (size - 1) / volSize + 1;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitUtils.h
new file mode 100644
index 000000000..755c707c3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SplitUtils.h
@@ -0,0 +1,15 @@
+// SplitUtils.h
+
+#ifndef __SPLITUTILS_H
+#define __SPLITUTILS_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+#include "Windows/Control/ComboBox.h"
+
+bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values);
+void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo);
+
+UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector<UInt64> &volSizes);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/StringUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/StringUtils.cpp
new file mode 100644
index 000000000..bddaa971e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/StringUtils.cpp
@@ -0,0 +1,68 @@
+// StringUtils.cpp
+
+#include "StdAfx.h"
+
+#include "StringUtils.h"
+
+void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2)
+{
+ dest1.Empty();
+ dest2.Empty();
+ bool quoteMode = false;
+ int i;
+ for (i = 0; i < src.Length(); i++)
+ {
+ wchar_t c = src[i];
+ if (c == L'\"')
+ quoteMode = !quoteMode;
+ else if (c == L' ' && !quoteMode)
+ {
+ if (!quoteMode)
+ {
+ i++;
+ break;
+ }
+ }
+ else
+ dest1 += c;
+ }
+ dest2 = src.Mid(i);
+}
+
+void SplitString(const UString &srcString, UStringVector &destStrings)
+{
+ destStrings.Clear();
+ UString string;
+ int len = srcString.Length();
+ if (len == 0)
+ return;
+ for (int i = 0; i < len; i++)
+ {
+ wchar_t c = srcString[i];
+ if (c == L' ')
+ {
+ if (!string.IsEmpty())
+ {
+ destStrings.Add(string);
+ string.Empty();
+ }
+ }
+ else
+ string += c;
+ }
+ if (!string.IsEmpty())
+ destStrings.Add(string);
+}
+
+UString JoinStrings(const UStringVector &srcStrings)
+{
+ UString destString;
+ for (int i = 0; i < srcStrings.Size(); i++)
+ {
+ if (i != 0)
+ destString += L' ';
+ destString += srcStrings[i];
+ }
+ return destString;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/StringUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/StringUtils.h
new file mode 100644
index 000000000..7f72b7641
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/StringUtils.h
@@ -0,0 +1,13 @@
+// StringUtils.h
+
+#ifndef __STRINGUTILS_H
+#define __STRINGUTILS_H
+
+#include "Common/MyString.h"
+
+void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2);
+
+void SplitString(const UString &srcString, UStringVector &destStrings);
+UString JoinStrings(const UStringVector &srcStrings);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SysIconUtils.cpp
new file mode 100644
index 000000000..d177b66e1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SysIconUtils.cpp
@@ -0,0 +1,167 @@
+// SysIconUtils.h
+
+#include "StdAfx.h"
+
+#include "SysIconUtils.h"
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+int GetIconIndexForCSIDL(int csidl)
+{
+#ifdef _WIN32
+ LPITEMIDLIST pidl = 0;
+ SHGetSpecialFolderLocation(NULL, csidl, &pidl);
+ if (pidl)
+ {
+ SHFILEINFO shellInfo;
+ SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL,
+ &shellInfo, sizeof(shellInfo),
+ SHGFI_PIDL | SHGFI_SYSICONINDEX);
+ IMalloc *pMalloc;
+ SHGetMalloc(&pMalloc);
+ if(pMalloc)
+ {
+ pMalloc->Free(pidl);
+ pMalloc->Release();
+ }
+ return shellInfo.iIcon;
+ }
+#endif // FIXME -1 ?
+ return 0;
+}
+
+DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex)
+{
+#ifdef _WIN32
+ SHFILEINFO shellInfo;
+ DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
+ iconIndex = shellInfo.iIcon;
+ return res;
+#else
+ return -1;
+#endif
+}
+
+
+#ifdef _WIN32
+
+#ifndef _UNICODE
+typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags);
+
+struct CSHGetFileInfoInit
+{
+ SHGetFileInfoWP shGetFileInfoW;
+ CSHGetFileInfoInit()
+ {
+ shGetFileInfoW = (SHGetFileInfoWP)
+ ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHGetFileInfoW");
+ }
+} g_SHGetFileInfoInit;
+#endif
+
+DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags)
+{
+ #ifdef _UNICODE
+ return SHGetFileInfoW(
+ #else
+ if (g_SHGetFileInfoInit.shGetFileInfoW == 0)
+ return 0;
+ return g_SHGetFileInfoInit.shGetFileInfoW(
+ #endif
+ pszPath, dwFileAttributes, psfi, cbFileInfo, uFlags);
+}
+
+#ifndef _UNICODE
+// static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex)
+{
+ if(g_IsNT)
+ {
+ SHFILEINFOW shellInfo;
+ DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
+ else
+ return GetRealIconIndex(UnicodeStringToMultiByte(path), attributes, iconIndex);
+}
+#endif
+
+DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attributes,
+ int &iconIndex, UString &typeName)
+{
+ #ifndef _UNICODE
+ if(!g_IsNT)
+ {
+ SHFILEINFO shellInfo;
+ shellInfo.szTypeName[0] = 0;
+ DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX
+ | SHGFI_TYPENAME);
+ typeName = GetUnicodeString(shellInfo.szTypeName);
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
+ else
+ #endif
+ {
+ SHFILEINFOW shellInfo;
+ shellInfo.szTypeName[0] = 0;
+ DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX
+ | SHGFI_TYPENAME);
+ typeName = shellInfo.szTypeName;
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
+}
+
+int CExtToIconMap::GetIconIndex(UINT32 attributes, const UString &fileNameSpec, UString &typeName)
+{
+ UString fileName = fileNameSpec;
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
+ {
+ fileName = L"__Fldr__";
+ if (_dirIconIndex < 0)
+ GetRealIconIndex(fileName, attributes, _dirIconIndex, _dirTypeName);
+ typeName = _dirTypeName;
+ return _dirIconIndex;
+ }
+ int dotPos = fileName.ReverseFind('.');
+ if (dotPos < 0)
+ {
+ fileName = L"__File__";
+ if (_noExtIconIndex < 0)
+ {
+ int iconIndexTemp;
+ GetRealIconIndex(fileName, attributes, iconIndexTemp, _noExtTypeName);
+ }
+ typeName = _noExtTypeName;
+ return _noExtIconIndex;
+ }
+ CExtIconPair extIconPair;
+ extIconPair.Ext = fileName.Mid(dotPos + 1);
+ int anIndex = _map.FindInSorted(extIconPair);
+ if (anIndex >= 0)
+ return _map[anIndex].IconIndex;
+ fileName = fileName.Mid(dotPos);
+ GetRealIconIndex(fileName, attributes, extIconPair.IconIndex, extIconPair.TypeName);
+ _map.AddToSorted(extIconPair);
+ typeName = extIconPair.TypeName;
+ return extIconPair.IconIndex;
+}
+
+int CExtToIconMap::GetIconIndex(UINT32 attributes, const UString &fileName)
+{
+ UString typeName;
+ return GetIconIndex(attributes, fileName, typeName);
+}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SysIconUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SysIconUtils.h
new file mode 100644
index 000000000..a90d28bc2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/SysIconUtils.h
@@ -0,0 +1,51 @@
+// SysIconUtils.h
+
+#ifndef __SYSICONUTILS_H
+#define __SYSICONUTILS_H
+
+#include "Common/MyString.h"
+
+struct CExtIconPair
+{
+ UString Ext;
+ int IconIndex;
+ UString TypeName;
+
+};
+
+inline bool operator==(const CExtIconPair &a1, const CExtIconPair &a2)
+{
+ return (a1.Ext == a2.Ext);
+}
+
+inline bool operator<(const CExtIconPair &a1, const CExtIconPair &a2)
+{
+ return (a1.Ext < a2.Ext);
+}
+
+class CExtToIconMap
+{
+ int _dirIconIndex;
+ UString _dirTypeName;
+ int _noExtIconIndex;
+ UString _noExtTypeName;
+ CObjectVector<CExtIconPair> _map;
+public:
+ CExtToIconMap(): _dirIconIndex(-1), _noExtIconIndex(-1) {}
+ void Clear()
+ {
+ _dirIconIndex = -1;
+ _noExtIconIndex = -1;
+ _map.Clear();
+ }
+ int GetIconIndex(UINT32 attributes, const UString &fileName, UString &typeName);
+ int GetIconIndex(UINT32 attributes, const UString &fileName);
+};
+
+DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex);
+#ifndef _UNICODE
+DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex);
+#endif
+int GetIconIndexForCSIDL(int csidl);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/TextPairs.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/TextPairs.cpp
new file mode 100644
index 000000000..cc57c0d56
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/TextPairs.cpp
@@ -0,0 +1,189 @@
+// TextPairs.cpp
+
+#include "StdAfx.h"
+
+#include "TextPairs.h"
+
+static const wchar_t kNewLineChar = '\n';
+static const wchar_t kQuoteChar = '\"';
+
+static const wchar_t kBOM = (wchar_t)0xFEFF;
+
+static bool IsSeparatorChar(wchar_t c)
+{
+ return (c == ' ' || c == '\t');
+}
+
+static void RemoveCr(UString &s)
+{
+ s.Replace(L"\x0D", L"");
+}
+
+static UString GetIDString(const wchar_t *srcString, int &finishPos)
+{
+ UString result;
+ bool quotes = false;
+ for (finishPos = 0;;)
+ {
+ wchar_t c = srcString[finishPos];
+ if (c == 0)
+ break;
+ finishPos++;
+ bool isSeparatorChar = IsSeparatorChar(c);
+ if (c == kNewLineChar || (isSeparatorChar && !quotes)
+ || (c == kQuoteChar && quotes))
+ break;
+ else if (c == kQuoteChar)
+ quotes = true;
+ else
+ result += c;
+ }
+ result.Trim();
+ RemoveCr(result);
+ return result;
+}
+
+static UString GetValueString(const wchar_t *srcString, int &finishPos)
+{
+ UString result;
+ for (finishPos = 0;;)
+ {
+ wchar_t c = srcString[finishPos];
+ if (c == 0)
+ break;
+ finishPos++;
+ if (c == kNewLineChar)
+ break;
+ result += c;
+ }
+ result.Trim();
+ RemoveCr(result);
+ return result;
+}
+
+static bool GetTextPairs(const UString &srcString, CObjectVector<CTextPair> &pairs)
+{
+ pairs.Clear();
+ int pos = 0;
+
+ if (srcString.Length() > 0)
+ {
+ if (srcString[0] == kBOM)
+ pos++;
+ }
+ while (pos < srcString.Length())
+ {
+ int finishPos;
+ UString id = GetIDString((const wchar_t *)srcString + pos, finishPos);
+ pos += finishPos;
+ if (id.IsEmpty())
+ continue;
+ UString value = GetValueString((const wchar_t *)srcString + pos, finishPos);
+ pos += finishPos;
+ if (!id.IsEmpty())
+ {
+ CTextPair pair;
+ pair.ID = id;
+ pair.Value = value;
+ pairs.Add(pair);
+ }
+ }
+ return true;
+}
+
+static int ComparePairIDs(const UString &s1, const UString &s2)
+ { return s1.CompareNoCase(s2); }
+static int ComparePairItems(const CTextPair &p1, const CTextPair &p2)
+ { return ComparePairIDs(p1.ID, p2.ID); }
+
+static int ComparePairItems(void *const *a1, void *const *a2, void * /* param */)
+ { return ComparePairItems(**(const CTextPair **)a1, **(const CTextPair **)a2); }
+
+void CPairsStorage::Sort() { Pairs.Sort(ComparePairItems, 0); }
+
+int CPairsStorage::FindID(const UString &id, int &insertPos)
+{
+ int left = 0, right = Pairs.Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ int compResult = ComparePairIDs(id, Pairs[mid].ID);
+ if (compResult == 0)
+ return mid;
+ if (compResult < 0)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ insertPos = left;
+ return -1;
+}
+
+int CPairsStorage::FindID(const UString &id)
+{
+ int pos;
+ return FindID(id, pos);
+}
+
+void CPairsStorage::AddPair(const CTextPair &pair)
+{
+ int insertPos;
+ int pos = FindID(pair.ID, insertPos);
+ if (pos >= 0)
+ Pairs[pos] = pair;
+ else
+ Pairs.Insert(insertPos, pair);
+}
+
+void CPairsStorage::DeletePair(const UString &id)
+{
+ int pos = FindID(id);
+ if (pos >= 0)
+ Pairs.Delete(pos);
+}
+
+bool CPairsStorage::GetValue(const UString &id, UString &value)
+{
+ value.Empty();
+ int pos = FindID(id);
+ if (pos < 0)
+ return false;
+ value = Pairs[pos].Value;
+ return true;
+}
+
+UString CPairsStorage::GetValue(const UString &id)
+{
+ int pos = FindID(id);
+ if (pos < 0)
+ return UString();
+ return Pairs[pos].Value;
+}
+
+bool CPairsStorage::ReadFromString(const UString &text)
+{
+ bool result = ::GetTextPairs(text, Pairs);
+ if (result)
+ Sort();
+ else
+ Pairs.Clear();
+ return result;
+}
+
+void CPairsStorage::SaveToString(UString &text)
+{
+ for (int i = 0; i < Pairs.Size(); i++)
+ {
+ const CTextPair &pair = Pairs[i];
+ bool multiWord = (pair.ID.Find(L' ') >= 0);
+ if (multiWord)
+ text += L'\"';
+ text += pair.ID;
+ if (multiWord)
+ text += L'\"';
+ text += L' ';
+ text += pair.Value;
+ text += L'\x0D';
+ text += L'\n';
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/TextPairs.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/TextPairs.h
new file mode 100644
index 000000000..2670e0307
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/TextPairs.h
@@ -0,0 +1,31 @@
+// TextPairs.h
+
+#ifndef __FM_TEXT_PAIRS_H
+#define __FM_TEXT_PAIRS_H
+
+#include "Common/MyString.h"
+
+struct CTextPair
+{
+ UString ID;
+ UString Value;
+};
+
+class CPairsStorage
+{
+ CObjectVector<CTextPair> Pairs;
+ int FindID(const UString &id, int &insertPos);
+ int FindID(const UString &id);
+ void Sort();
+public:
+ void Clear() { Pairs.Clear(); };
+ bool ReadFromString(const UString &text);
+ void SaveToString(UString &text);
+
+ bool GetValue(const UString &id, UString &value);
+ UString GetValue(const UString &id);
+ void AddPair(const CTextPair &pair);
+ void DeletePair(const UString &id);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/UpdateCallback100.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/UpdateCallback100.cpp
new file mode 100644
index 000000000..3701d2bbf
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/UpdateCallback100.cpp
@@ -0,0 +1,106 @@
+// UpdateCallback100.cpp
+
+#include "StdAfx.h"
+
+#include "MessagesDialog.h"
+#include "PasswordDialog.h"
+#include "UpdateCallback100.h"
+
+CUpdateCallback100Imp::~CUpdateCallback100Imp()
+{
+ if (ShowMessages && !Messages.IsEmpty())
+ {
+ CMessagesDialog messagesDialog;
+ messagesDialog.Messages = &Messages;
+ messagesDialog.Create(_parentWindow);
+ }
+}
+
+void CUpdateCallback100Imp::AddErrorMessage(LPCWSTR message)
+{
+ Messages.Add(message);
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles)
+{
+ ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size)
+{
+ ProgressDialog.ProgressSynch.SetProgress(size, 0);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue)
+{
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ if (completeValue != NULL)
+ ProgressDialog.ProgressSynch.SetPos(*completeValue);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *name)
+{
+ ProgressDialog.ProgressSynch.SetCurrentFileName(name);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *name)
+{
+ ProgressDialog.ProgressSynch.SetCurrentFileName(name);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */)
+{
+ NumFiles++;
+ ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message)
+{
+ AddErrorMessage(message);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ *password = NULL;
+ *passwordIsDefined = BoolToInt(_passwordIsDefined);
+ if (!_passwordIsDefined)
+ return S_OK;
+ return StringToBstr(_password, password);
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
+{
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password)
+{
+ *password = NULL;
+ if (!_passwordIsDefined)
+ {
+ CPasswordDialog dialog;
+ if (dialog.Create(_parentWindow) == IDCANCEL)
+ return E_ABORT;
+ _password = dialog.Password;
+ _passwordIsDefined = true;
+ }
+ return StringToBstr(_password, password);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/UpdateCallback100.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/UpdateCallback100.h
new file mode 100644
index 000000000..5ae194a2a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/UpdateCallback100.h
@@ -0,0 +1,72 @@
+// UpdateCallback100.h
+
+#ifndef __UPDATE_CALLBACK100_H
+#define __UPDATE_CALLBACK100_H
+
+#include "Common/MyCom.h"
+#include "Common/MyString.h"
+
+#include "../Agent/IFolderArchive.h"
+#include "ProgressDialog2.h"
+#include "../../IPassword.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+class CUpdateCallback100Imp:
+ public IFolderArchiveUpdateCallback,
+ public ICryptoGetTextPassword2,
+ public ICryptoGetTextPassword,
+ public IArchiveOpenCallback,
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP5(
+ IFolderArchiveUpdateCallback,
+ ICryptoGetTextPassword2,
+ ICryptoGetTextPassword,
+ IArchiveOpenCallback,
+ ICompressProgressInfo)
+
+ INTERFACE_IProgress(;)
+ INTERFACE_IArchiveOpenCallback(;)
+ INTERFACE_IFolderArchiveUpdateCallback(;)
+
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+ STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
+private:
+ bool _passwordIsDefined;
+ UString _password;
+
+ void AddErrorMessage(LPCWSTR message);
+ bool ShowMessages;
+
+public:
+ CUpdateCallback100Imp(): ShowMessages(true) {}
+ ~CUpdateCallback100Imp();
+ CProgressDialog ProgressDialog;
+ HWND _parentWindow;
+ UStringVector Messages;
+ UInt64 NumFolders;
+ UInt64 NumFiles;
+
+ void Init(HWND parentWindow,
+ bool passwordIsDefined, const UString &password)
+ {
+ _passwordIsDefined = passwordIsDefined;
+ _password = password;
+ _parentWindow = parentWindow;
+ NumFolders = NumFiles = 0;
+ }
+ void StartProgressDialog(const UString &title)
+ {
+ ProgressDialog.Create(title, _parentWindow);
+ }
+
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ViewSettings.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ViewSettings.cpp
new file mode 100644
index 000000000..53974eab1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ViewSettings.cpp
@@ -0,0 +1,426 @@
+// ViewSettings.h
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "ViewSettings.h"
+#include "Windows/Registry.h"
+#include "Windows/Synchronization.h"
+
+using namespace NWindows;
+using namespace NRegistry;
+
+#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") TEXT(STRING_PATH_SEPARATOR) TEXT("FM")
+
+static const TCHAR *kCUBasePath = REG_PATH_FM;
+static const TCHAR *kCulumnsKeyName = REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) TEXT("Columns");
+
+static const TCHAR *kPositionValueName = TEXT("Position");
+static const TCHAR *kPanelsInfoValueName = TEXT("Panels");
+static const TCHAR *kToolbars = TEXT("Toolbars");
+
+static const WCHAR *kPanelPathValueName = L"PanelPath";
+static const TCHAR *kListMode = TEXT("ListMode");
+static const TCHAR *kFolderHistoryValueName = TEXT("FolderHistory");
+static const TCHAR *kFastFoldersValueName = TEXT("FolderShortcuts");
+static const TCHAR *kCopyHistoryValueName = TEXT("CopyHistory");
+
+/*
+class CColumnInfoSpec
+{
+ UInt32 PropID;
+ Byte IsVisible;
+ UInt32 Width;
+};
+
+struct CColumnHeader
+{
+ UInt32 Version;
+ UInt32 SortID;
+ Byte Ascending;
+};
+*/
+
+static const UInt32 kColumnInfoSpecHeader = 12;
+static const UInt32 kColumnHeaderSize = 12;
+
+static const UInt32 kColumnInfoVersion = 1;
+
+static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection;
+
+class CTempOutBufferSpec
+{
+ CByteBuffer Buffer;
+ UInt32 Size;
+ UInt32 Pos;
+public:
+ operator const Byte *() const { return (const Byte *)Buffer; }
+ void Init(UInt32 dataSize)
+ {
+ Buffer.SetCapacity(dataSize);
+ Size = dataSize;
+ Pos = 0;
+ }
+ void WriteByte(Byte value)
+ {
+ if (Pos >= Size)
+ throw "overflow";
+ ((Byte *)Buffer)[Pos++] = value;
+ }
+ void WriteUInt32(UInt32 value)
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ WriteByte((Byte)value);
+ value >>= 8;
+ }
+ }
+ void WriteBool(bool value)
+ {
+ WriteUInt32(value ? 1 : 0);
+ }
+};
+
+class CTempInBufferSpec
+{
+public:
+ Byte *Buffer;
+ UInt32 Size;
+ UInt32 Pos;
+ Byte ReadByte()
+ {
+ if (Pos >= Size)
+ throw "overflow";
+ return Buffer[Pos++];
+ }
+ UInt32 ReadUInt32()
+ {
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ value |= (((UInt32)ReadByte()) << (8 * i));
+ return value;
+ }
+ bool ReadBool()
+ {
+ return (ReadUInt32() != 0);
+ }
+};
+
+void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo)
+{
+ const CObjectVector<CColumnInfo> &columns = viewInfo.Columns;
+ CTempOutBufferSpec buffer;
+ UInt32 dataSize = kColumnHeaderSize + kColumnInfoSpecHeader * columns.Size();
+ buffer.Init(dataSize);
+
+ buffer.WriteUInt32(kColumnInfoVersion);
+ buffer.WriteUInt32(viewInfo.SortID);
+ buffer.WriteBool(viewInfo.Ascending);
+ for(int i = 0; i < columns.Size(); i++)
+ {
+ const CColumnInfo &column = columns[i];
+ buffer.WriteUInt32(column.PropID);
+ buffer.WriteBool(column.IsVisible);
+ buffer.WriteUInt32(column.Width);
+ }
+ {
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCulumnsKeyName);
+ key.SetValue(GetSystemString(id), (const Byte *)buffer, dataSize);
+ }
+}
+
+void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo)
+{
+ viewInfo.Clear();
+ CObjectVector<CColumnInfo> &columns = viewInfo.Columns;
+ CByteBuffer buffer;
+ UInt32 size;
+ {
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ CKey key;
+ if(key.Open(HKEY_CURRENT_USER, kCulumnsKeyName, KEY_READ) != ERROR_SUCCESS)
+ return;
+ if (key.QueryValue(GetSystemString(id), buffer, size) != ERROR_SUCCESS)
+ return;
+ }
+ if (size < kColumnHeaderSize)
+ return;
+ CTempInBufferSpec inBuffer;
+ inBuffer.Size = size;
+ inBuffer.Buffer = (Byte *)buffer;
+ inBuffer.Pos = 0;
+
+
+ UInt32 version = inBuffer.ReadUInt32();
+ if (version != kColumnInfoVersion)
+ return;
+ viewInfo.SortID = inBuffer.ReadUInt32();
+ viewInfo.Ascending = inBuffer.ReadBool();
+
+ size -= kColumnHeaderSize;
+ if (size % kColumnInfoSpecHeader != 0)
+ return;
+ int numItems = size / kColumnInfoSpecHeader;
+ columns.Reserve(numItems);
+ for(int i = 0; i < numItems; i++)
+ {
+ CColumnInfo columnInfo;
+ columnInfo.PropID = inBuffer.ReadUInt32();
+ columnInfo.IsVisible = inBuffer.ReadBool();
+ columnInfo.Width = inBuffer.ReadUInt32();
+ columns.Add(columnInfo);
+ }
+}
+
+static const UInt32 kWindowPositionHeaderSize = 5 * 4;
+static const UInt32 kPanelsInfoHeaderSize = 3 * 4;
+
+/*
+struct CWindowPosition
+{
+ RECT Rect;
+ UInt32 Maximized;
+};
+
+struct CPanelsInfo
+{
+ UInt32 NumPanels;
+ UInt32 CurrentPanel;
+ UInt32 SplitterPos;
+};
+*/
+
+#ifdef _WIN32
+void SaveWindowSize(const RECT &rect, bool maximized)
+{
+ CSysString keyName = kCUBasePath;
+ CKey key;
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ key.Create(HKEY_CURRENT_USER, keyName);
+ // CWindowPosition position;
+ CTempOutBufferSpec buffer;
+ buffer.Init(kWindowPositionHeaderSize);
+ buffer.WriteUInt32(rect.left);
+ buffer.WriteUInt32(rect.top);
+ buffer.WriteUInt32(rect.right);
+ buffer.WriteUInt32(rect.bottom);
+ buffer.WriteBool(maximized);
+ key.SetValue(kPositionValueName, (const Byte *)buffer, kWindowPositionHeaderSize);
+}
+
+bool ReadWindowSize(RECT &rect, bool &maximized)
+{
+ CSysString keyName = kCUBasePath;
+ CKey key;
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ if(key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS)
+ return false;
+ CByteBuffer buffer;
+ UInt32 size;
+ if (key.QueryValue(kPositionValueName, buffer, size) != ERROR_SUCCESS)
+ return false;
+ if (size != kWindowPositionHeaderSize)
+ return false;
+ CTempInBufferSpec inBuffer;
+ inBuffer.Size = size;
+ inBuffer.Buffer = (Byte *)buffer;
+ inBuffer.Pos = 0;
+ rect.left = inBuffer.ReadUInt32();
+ rect.top = inBuffer.ReadUInt32();
+ rect.right = inBuffer.ReadUInt32();
+ rect.bottom = inBuffer.ReadUInt32();
+ maximized = inBuffer.ReadBool();
+ return true;
+}
+#endif
+
+void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos)
+{
+ CSysString keyName = kCUBasePath;
+ CKey key;
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ key.Create(HKEY_CURRENT_USER, keyName);
+
+ CTempOutBufferSpec buffer;
+ buffer.Init(kPanelsInfoHeaderSize);
+ buffer.WriteUInt32(numPanels);
+ buffer.WriteUInt32(currentPanel);
+ buffer.WriteUInt32(splitterPos);
+ key.SetValue(kPanelsInfoValueName, (const Byte *)buffer, kPanelsInfoHeaderSize);
+}
+
+bool ReadPanelsInfo(UInt32 &numPanels, UInt32 &currentPanel, UInt32 &splitterPos)
+{
+ CSysString keyName = kCUBasePath;
+ CKey key;
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ if(key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS)
+ return false;
+ CByteBuffer buffer;
+ UInt32 size;
+ if (key.QueryValue(kPanelsInfoValueName, buffer, size) != ERROR_SUCCESS)
+ return false;
+ if (size != kPanelsInfoHeaderSize)
+ return false;
+ CTempInBufferSpec inBuffer;
+ inBuffer.Size = size;
+ inBuffer.Buffer = (Byte *)buffer;
+ inBuffer.Pos = 0;
+ numPanels = inBuffer.ReadUInt32();
+ currentPanel = inBuffer.ReadUInt32();
+ splitterPos = inBuffer.ReadUInt32();
+ return true;
+}
+
+void SaveToolbarsMask(UInt32 toolbarMask)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(kToolbars, toolbarMask);
+}
+
+static const UInt32 kDefaultToolbarMask = 8 | 4 | 1;
+
+UInt32 ReadToolbarsMask()
+{
+ CKey key;
+ if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS)
+ return kDefaultToolbarMask;
+ UInt32 mask;
+ if (key.QueryValue(kToolbars, mask) != ERROR_SUCCESS)
+ return kDefaultToolbarMask;
+ return mask;
+}
+
+
+static UString GetPanelPathName(UInt32 panelIndex)
+{
+ WCHAR panelString[32];
+ ConvertUInt64ToString(panelIndex, panelString);
+ return UString(kPanelPathValueName) + panelString;
+}
+
+
+void SavePanelPath(UInt32 panel, const UString &path)
+{
+ CKey key;
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(GetPanelPathName(panel), path);
+}
+
+bool ReadPanelPath(UInt32 panel, UString &path)
+{
+ CKey key;
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS)
+ return false;
+ return (key.QueryValue(GetPanelPathName(panel), path) == ERROR_SUCCESS);
+}
+
+void SaveListMode(const CListMode &listMode)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ UInt32 t = 0;
+ for (int i = 0; i < 2; i++)
+ t |= ((listMode.Panels[i]) & 0xFF) << (i * 8);
+ key.SetValue(kListMode, t);
+}
+
+void ReadListMode(CListMode &listMode)
+{
+ CKey key;
+ listMode.Init();
+ if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS)
+ return;
+ UInt32 t;
+ if (key.QueryValue(kListMode, t) != ERROR_SUCCESS)
+ return;
+ for (int i = 0; i < 2; i++)
+ {
+ listMode.Panels[i] = (t & 0xFF);
+ t >>= 8;
+ }
+}
+
+
+void SaveStringList(LPCTSTR valueName, const UStringVector &folders)
+{
+ UInt32 sizeInChars = 0;
+ int i;
+ for (i = 0; i < folders.Size(); i++)
+ sizeInChars += folders[i].Length() + 1;
+ CBuffer<wchar_t> buffer;
+ buffer.SetCapacity(sizeInChars);
+ int pos = 0;
+ for (i = 0; i < folders.Size(); i++)
+ {
+ MyStringCopy((wchar_t *)buffer + pos, (const wchar_t *)folders[i]);
+ pos += folders[i].Length() + 1;
+ }
+ CKey key;
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(valueName, buffer, sizeInChars * sizeof(wchar_t));
+}
+
+void ReadStringList(LPCTSTR valueName, UStringVector &folders)
+{
+ folders.Clear();
+ CKey key;
+ NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
+ if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS)
+ return;
+ CByteBuffer buffer;
+ UInt32 dataSize;
+ if (key.QueryValue(valueName, buffer, dataSize) != ERROR_SUCCESS)
+ return;
+ if (dataSize % sizeof(wchar_t) != 0)
+ return;
+ const wchar_t *data = (const wchar_t *)(const Byte *)buffer;
+ int sizeInChars = dataSize / sizeof(wchar_t);
+ UString string;
+ for (int i = 0; i < sizeInChars; i++)
+ {
+ wchar_t c = data[i];
+ if (c == L'\0')
+ {
+ folders.Add(string);
+ string.Empty();
+ }
+ else
+ string += c;
+ }
+}
+
+void SaveFolderHistory(const UStringVector &folders)
+ { SaveStringList(kFolderHistoryValueName, folders); }
+void ReadFolderHistory(UStringVector &folders)
+ { ReadStringList(kFolderHistoryValueName, folders); }
+
+void SaveFastFolders(const UStringVector &folders)
+ { SaveStringList(kFastFoldersValueName, folders); }
+void ReadFastFolders(UStringVector &folders)
+ { ReadStringList(kFastFoldersValueName, folders); }
+
+void SaveCopyHistory(const UStringVector &folders)
+ { SaveStringList(kCopyHistoryValueName, folders); }
+void ReadCopyHistory(UStringVector &folders)
+ { ReadStringList(kCopyHistoryValueName, folders); }
+
+void AddUniqueStringToHeadOfList(UStringVector &list,
+ const UString &string)
+{
+ for(int i = 0; i < list.Size();)
+ if (string.CompareNoCase(list[i]) == 0)
+ list.Delete(i);
+ else
+ i++;
+ list.Insert(0, string);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ViewSettings.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ViewSettings.h
new file mode 100644
index 000000000..c27e70e6f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/ViewSettings.h
@@ -0,0 +1,100 @@
+// ViewSettings.h
+
+#ifndef __VIEWSETTINGS_H
+#define __VIEWSETTINGS_H
+
+#include "Common/MyString.h"
+
+struct CColumnInfo
+{
+ PROPID PropID;
+ bool IsVisible;
+ UInt32 Width;
+};
+
+inline bool operator==(const CColumnInfo &a1, const CColumnInfo &a2)
+{
+ return (a1.PropID == a2.PropID) &&
+ (a1.IsVisible == a2.IsVisible) && (a1.Width == a2.Width);
+}
+
+inline bool operator!=(const CColumnInfo &a1, const CColumnInfo &a2)
+{
+ return !(a1 == a2);
+}
+
+struct CListViewInfo
+{
+ CObjectVector<CColumnInfo> Columns;
+ PROPID SortID;
+ bool Ascending;
+
+ void Clear()
+ {
+ SortID = 0;
+ Ascending = true;
+ Columns.Clear();
+ }
+
+ int FindColumnWithID(PROPID propID) const
+ {
+ for (int i = 0; i < Columns.Size(); i++)
+ if (Columns[i].PropID == propID)
+ return i;
+ return -1;
+ }
+
+ bool IsEqual(const CListViewInfo &aNewInfo) const
+ {
+ if (Columns.Size() != aNewInfo.Columns.Size() ||
+ // SortIndex != aNewInfo.SortIndex ||
+ SortID != aNewInfo.SortID ||
+ Ascending != aNewInfo.Ascending)
+ return false;
+ for (int i = 0; i < Columns.Size(); i++)
+ if (Columns[i] != aNewInfo.Columns[i])
+ return false;
+ return true;
+ }
+};
+
+void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo);
+void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo);
+
+#ifdef _WIN32
+void SaveWindowSize(const RECT &rect, bool maximized);
+bool ReadWindowSize(RECT &rect, bool &maximized);
+#endif
+
+void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos);
+bool ReadPanelsInfo(UInt32 &numPanels, UInt32 &currentPanel, UInt32 &splitterPos);
+
+void SaveToolbarsMask(UInt32 toolbarMask);
+UInt32 ReadToolbarsMask();
+
+void SavePanelPath(UInt32 panel, const UString &path);
+bool ReadPanelPath(UInt32 panel, UString &path);
+
+struct CListMode
+{
+ UInt32 Panels[2];
+ void Init() { Panels[0] = Panels[1] = 3; }
+ CListMode() { Init(); }
+};
+
+void SaveListMode(const CListMode &listMode);
+void ReadListMode(CListMode &listMode);
+
+void SaveFolderHistory(const UStringVector &folders);
+void ReadFolderHistory(UStringVector &folders);
+
+void SaveFastFolders(const UStringVector &folders);
+void ReadFastFolders(UStringVector &folders);
+
+void SaveCopyHistory(const UStringVector &folders);
+void ReadCopyHistory(UStringVector &folders);
+
+void AddUniqueStringToHeadOfList(UStringVector &list,
+ const UString &string);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Add2PNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Add2PNG.h
new file mode 100644
index 000000000..a507a3066
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Add2PNG.h
@@ -0,0 +1,20 @@
+static const unsigned char ADD2_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x12, 0x59, 0x20, 0xcb, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x3b, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x60, 0xc0, 0x0b, 0x78, 0xef, 0xde,
+0xbd, 0x8b, 0xe0, 0xac, 0x5a, 0xb5, 0xb6, 0x80, 0x6c, 0x0e, 0xc8, 0x28,
+0x20, 0x07, 0x62, 0x20, 0x50, 0x18, 0x02, 0x40, 0x92, 0x64, 0x71, 0xe0,
+0xa6, 0x81, 0x4c, 0x2f, 0x2f, 0x2f, 0x07, 0x72, 0x80, 0x64, 0x01, 0xf9,
+0x0e, 0x85, 0x1a, 0x05, 0x01, 0x70, 0xa3, 0x70, 0x01, 0x00, 0x61, 0xed,
+0x52, 0x81, 0x19, 0x73, 0x26, 0x18, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
+0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/AddPNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/AddPNG.h
new file mode 100644
index 000000000..be1ac9124
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/AddPNG.h
@@ -0,0 +1,22 @@
+static const unsigned char ADD_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x24,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x6b, 0xa4, 0x39, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x4d, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x60, 0xa0, 0x01, 0xe0, 0xbd, 0x0b,
+0x04, 0x17, 0xb0, 0x49, 0xac, 0x02, 0x82, 0xeb, 0x43, 0x5b, 0x02, 0xe4,
+0xb7, 0xbb, 0x20, 0x09, 0x30, 0x03, 0x49, 0xe2, 0xd6, 0x2a, 0x24, 0xb0,
+0xb6, 0x60, 0xc8, 0x4a, 0xa0, 0x7a, 0x10, 0x49, 0x82, 0xbd, 0xbc, 0xbc,
+0xbc, 0x16, 0x1c, 0x24, 0x40, 0x46, 0x39, 0x92, 0x04, 0xe9, 0x81, 0x38,
+0xf0, 0x12, 0x20, 0xbf, 0x61, 0x93, 0x60, 0x00, 0xf9, 0xad, 0x1c, 0x9b,
+0x04, 0xcd, 0x00, 0x00, 0xa3, 0xbb, 0xae, 0x61, 0x7b, 0x93, 0x6d, 0x0f,
+0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
+0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Copy2PNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Copy2PNG.h
new file mode 100644
index 000000000..14781e2a1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Copy2PNG.h
@@ -0,0 +1,22 @@
+static const unsigned char COPY2_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x12, 0x59, 0x20, 0xcb, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x52, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x95, 0xce, 0x31, 0x0a, 0xc0, 0x30, 0x08,
+0x40, 0x51, 0xb7, 0xdc, 0xd4, 0x4d, 0x70, 0xf3, 0x9a, 0x99, 0xec, 0xe4,
+0x5d, 0x9a, 0x18, 0x68, 0xff, 0x1a, 0xc9, 0xf2, 0x79, 0x22, 0x11, 0xb9,
+0x9a, 0xc9, 0x28, 0x46, 0x92, 0xd2, 0x18, 0xda, 0x54, 0xb5, 0x5e, 0xa5,
+0xda, 0x59, 0xf0, 0xd4, 0x3d, 0x93, 0x61, 0x8c, 0x4d, 0xbf, 0x38, 0xe2,
+0xe9, 0x6b, 0x7e, 0xae, 0x2d, 0x90, 0x11, 0x3e, 0x22, 0xb2, 0xe1, 0xfb,
+0x81, 0x23, 0x00, 0x52, 0x00, 0x21, 0x5c, 0xcd, 0x0b, 0x7e, 0x4c, 0x37,
+0xbb, 0x3f, 0x86, 0x84, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
+0x44, 0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/CopyPNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/CopyPNG.h
new file mode 100644
index 000000000..69770b9e0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/CopyPNG.h
@@ -0,0 +1,26 @@
+static const unsigned char COPY_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x24,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x6b, 0xa4, 0x39, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x80, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0xbd, 0xd1, 0x31, 0x0e, 0x80, 0x20, 0x0c,
+0x85, 0xe1, 0x6e, 0x4e, 0x5c, 0x93, 0x8d, 0xa4, 0x1b, 0xd7, 0x64, 0x2a,
+0x53, 0xef, 0xe2, 0x43, 0x23, 0x12, 0xed, 0x5b, 0xe9, 0x60, 0x62, 0x7e,
+0xbf, 0x00, 0x22, 0xb2, 0x7d, 0x1a, 0x0b, 0xce, 0x82, 0x31, 0x62, 0x85,
+0x85, 0x4c, 0x88, 0x65, 0x42, 0x2c, 0x13, 0x82, 0x10, 0x13, 0x84, 0x85,
+0x24, 0x77, 0xec, 0xdf, 0xc7, 0x8c, 0xf0, 0x92, 0x84, 0x17, 0xbd, 0x3e,
+0xbe, 0xa7, 0xb1, 0x50, 0x58, 0x98, 0xe4, 0x17, 0x0a, 0x0b, 0x9d, 0xad,
+0xa1, 0x24, 0xf4, 0xb9, 0x38, 0x0e, 0xa0, 0xcb, 0x39, 0x1e, 0x20, 0x52,
+0x6b, 0x55, 0x39, 0xf0, 0xac, 0xb6, 0x82, 0xef, 0xbf, 0x52, 0x12, 0x42,
+0x30, 0xee, 0x23, 0x04, 0x08, 0x31, 0xc0, 0x9d, 0xc7, 0x40, 0x8c, 0x00,
+0x71, 0x02, 0x84, 0x81, 0xcd, 0x73, 0x02, 0xb6, 0x2b, 0x69, 0xbd, 0x15,
+0x92, 0x2f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
+0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Delete2PNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Delete2PNG.h
new file mode 100644
index 000000000..5f0907754
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Delete2PNG.h
@@ -0,0 +1,23 @@
+static const unsigned char DELETE2_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x12, 0x59, 0x20, 0xcb, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x5a, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x9d, 0x8e, 0xc1, 0x11, 0x00, 0x21, 0x08,
+0x03, 0x69, 0xc0, 0x5e, 0x6d, 0xe0, 0x0a, 0xc9, 0xc3, 0x9e, 0xf8, 0x31,
+0x76, 0x73, 0x80, 0x06, 0x7d, 0xde, 0x5c, 0x46, 0xf3, 0x60, 0x27, 0x10,
+0x91, 0xcf, 0x6a, 0x65, 0xae, 0xa9, 0x34, 0x9f, 0x61, 0x6c, 0x8b, 0x19,
+0xa0, 0xcb, 0x92, 0x60, 0xc4, 0xef, 0x44, 0xfe, 0x6c, 0x6f, 0x03, 0x0a,
+0x24, 0x22, 0x58, 0x29, 0x82, 0x24, 0x2a, 0x77, 0xe6, 0x00, 0x9e, 0xc9,
+0xc4, 0x83, 0xd3, 0xc0, 0xae, 0x06, 0xbe, 0xaa, 0x55, 0x03, 0xa3, 0x05,
+0xea, 0xb4, 0x1f, 0x7a, 0x01, 0xc5, 0x78, 0x3b, 0x10, 0xc3, 0x1f, 0xc3,
+0xce, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60,
+0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/DeletePNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/DeletePNG.h
new file mode 100644
index 000000000..7795bc0a8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/DeletePNG.h
@@ -0,0 +1,26 @@
+static const unsigned char DELETE_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x24,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x6b, 0xa4, 0x39, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x81, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0xc5, 0xd1, 0xc1, 0x0d, 0x80, 0x30, 0x08,
+0x05, 0x50, 0x17, 0x60, 0x57, 0xd7, 0xe1, 0xd0, 0x9d, 0x7a, 0x23, 0x6e,
+0x63, 0x2c, 0x14, 0x2d, 0xff, 0x7b, 0x55, 0x2e, 0xfd, 0x31, 0xbc, 0x58,
+0xe8, 0xb6, 0x7d, 0x57, 0x1d, 0x82, 0x97, 0xb4, 0x1a, 0xa2, 0x0e, 0xed,
+0x25, 0x44, 0x9f, 0x6a, 0x5b, 0x43, 0x02, 0xf5, 0xce, 0x0c, 0xb7, 0x18,
+0x9d, 0xe3, 0xdc, 0x09, 0xb9, 0x0e, 0x5b, 0x6f, 0x35, 0x08, 0x82, 0x20,
+0x08, 0x82, 0x10, 0xe0, 0x84, 0x00, 0x27, 0x0c, 0x04, 0x41, 0xc0, 0x66,
+0x78, 0x8a, 0x8e, 0xdf, 0xe3, 0x1f, 0x2f, 0x80, 0x90, 0x9c, 0x83, 0x01,
+0xab, 0xbb, 0xcd, 0x2b, 0x09, 0x92, 0xd8, 0x12, 0x90, 0x39, 0x03, 0x90,
+0x5c, 0x2b, 0x79, 0x41, 0x1f, 0x5a, 0xf0, 0x05, 0xad, 0x84, 0x49, 0x66,
+0x9f, 0xd4, 0x75, 0x19, 0x84, 0x3f, 0xeb, 0x04, 0x1a, 0xa7, 0x7e, 0xab,
+0x5a, 0xf7, 0xe4, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
+0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Extract2PNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Extract2PNG.h
new file mode 100644
index 000000000..ee01ef69d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Extract2PNG.h
@@ -0,0 +1,18 @@
+static const unsigned char EXTRACT2_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x12, 0x59, 0x20, 0xcb, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x22, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x60, 0xa0, 0x17, 0xe0, 0xbd, 0x0b,
+0x05, 0x17, 0x40, 0x9c, 0x33, 0x50, 0x70, 0x9d, 0x5c, 0x0e, 0xcc, 0x34,
+0x10, 0x87, 0xa1, 0x1c, 0x06, 0xe8, 0xe6, 0x1b, 0x00, 0xa6, 0x78, 0x38,
+0x15, 0x21, 0xee, 0x22, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
+0x44, 0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/ExtractPNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/ExtractPNG.h
new file mode 100644
index 000000000..807f8e4f6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/ExtractPNG.h
@@ -0,0 +1,18 @@
+static const unsigned char EXTRACT_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x24,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x6b, 0xa4, 0x39, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x28, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x60, 0x18, 0x05, 0xa4, 0x81, 0xbb,
+0x28, 0x00, 0x49, 0xe2, 0xce, 0x19, 0x24, 0x70, 0xb6, 0x60, 0xc8, 0x4a,
+0xa0, 0x7a, 0x10, 0x49, 0x82, 0xbd, 0x1c, 0x19, 0x20, 0x49, 0x8c, 0x02,
+0x8a, 0x00, 0x00, 0x11, 0x6c, 0x7c, 0x67, 0x00, 0x94, 0xd4, 0x2c, 0x00,
+0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Info2PNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Info2PNG.h
new file mode 100644
index 000000000..b517084c9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Info2PNG.h
@@ -0,0 +1,21 @@
+static const unsigned char INFO2_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x12, 0x59, 0x20, 0xcb, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x46, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x60, 0x40, 0x07, 0xbc, 0x77, 0xef,
+0x5e, 0x40, 0x70, 0x76, 0xef, 0xbe, 0x8e, 0x83, 0x73, 0xf7, 0x2e, 0x82,
+0xc3, 0x50, 0x5e, 0x5e, 0x8e, 0x61, 0x10, 0x54, 0x15, 0xc2, 0x34, 0xa0,
+0x7e, 0x84, 0x01, 0xbc, 0x77, 0x91, 0x4d, 0xab, 0xc5, 0x6d, 0x0f, 0xe9,
+0x1c, 0x90, 0xd1, 0x70, 0x5b, 0x41, 0x96, 0xc2, 0xa5, 0x40, 0xce, 0x41,
+0x38, 0xbb, 0xbc, 0x1c, 0x97, 0xb3, 0x09, 0x03, 0x00, 0x3a, 0xb2, 0x32,
+0x23, 0xbc, 0x78, 0x77, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
+0x44, 0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/InfoPNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/InfoPNG.h
new file mode 100644
index 000000000..18109837c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/InfoPNG.h
@@ -0,0 +1,22 @@
+static const unsigned char INFO_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x24,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x6b, 0xa4, 0x39, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x57, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x60, 0xa0, 0x05, 0xb8, 0x0b, 0x04,
+0x17, 0xb0, 0x49, 0xdc, 0xde, 0xbd, 0x7b, 0xf7, 0x75, 0xea, 0x48, 0x80,
+0xec, 0xc0, 0x2a, 0xc1, 0x5e, 0x0e, 0x04, 0xc4, 0xba, 0x94, 0x2c, 0xc0,
+0x7b, 0x17, 0x87, 0x07, 0x79, 0x77, 0xef, 0xc6, 0xee, 0x5c, 0xdc, 0x12,
+0x77, 0x71, 0x79, 0xb0, 0x9c, 0x8a, 0x61, 0x35, 0x18, 0x25, 0x20, 0x3e,
+0xbf, 0x7b, 0x17, 0x53, 0x02, 0x1c, 0x56, 0xbb, 0xf7, 0x16, 0x10, 0x2f,
+0x71, 0x17, 0x02, 0x30, 0x24, 0x18, 0xca, 0x21, 0x00, 0x53, 0x62, 0x30,
+0x01, 0x00, 0xd3, 0xa5, 0x67, 0xc0, 0x11, 0x9d, 0x79, 0xc0, 0x00, 0x00,
+0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Move2PNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Move2PNG.h
new file mode 100644
index 000000000..6eafd8dfd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Move2PNG.h
@@ -0,0 +1,21 @@
+static const unsigned char MOVE2_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x12, 0x59, 0x20, 0xcb, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x4c, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x95, 0xce, 0xb1, 0x0d, 0xc0, 0x20, 0x0c,
+0x44, 0xd1, 0xeb, 0xb2, 0x18, 0xad, 0x77, 0xa1, 0x63, 0x4d, 0x0a, 0x4b,
+0xa9, 0xbc, 0x4b, 0x82, 0x41, 0xf0, 0x5b, 0xae, 0xfb, 0x3c, 0xc9, 0x42,
+0xba, 0x5a, 0x67, 0x04, 0xc3, 0x49, 0x6e, 0x8c, 0x92, 0x14, 0x39, 0x2f,
+0x36, 0xdf, 0xd6, 0x3a, 0xc3, 0x18, 0x83, 0x8e, 0x54, 0xc4, 0xcb, 0x6b,
+0x3f, 0xe8, 0x69, 0x63, 0x9e, 0xb0, 0x7f, 0x50, 0x11, 0x00, 0x05, 0x40,
+0x84, 0xab, 0x7d, 0xa9, 0x14, 0x30, 0x23, 0x6c, 0x8b, 0xd3, 0x1c, 0x00,
+0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/MovePNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/MovePNG.h
new file mode 100644
index 000000000..a0dc143a9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/MovePNG.h
@@ -0,0 +1,25 @@
+static const unsigned char MOVE_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x24,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x6b, 0xa4, 0x39, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x71, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0xbd, 0xd1, 0xb1, 0x0d, 0xc0, 0x20, 0x0c,
+0x05, 0x51, 0x2f, 0xc0, 0x56, 0x6e, 0xd9, 0x85, 0x2e, 0x6b, 0x52, 0x58,
+0xa2, 0x62, 0x97, 0x98, 0x22, 0x84, 0x10, 0x5f, 0xcb, 0x6f, 0x4f, 0x4f,
+0x08, 0x10, 0x39, 0xbe, 0x4a, 0xa1, 0x53, 0x30, 0x22, 0x96, 0x29, 0x28,
+0x10, 0x53, 0x20, 0xa6, 0x40, 0x3c, 0xc4, 0xc4, 0xc3, 0x42, 0x52, 0x9f,
+0x1b, 0xe1, 0x25, 0x49, 0xbf, 0xab, 0x14, 0x32, 0x85, 0x49, 0x7e, 0x21,
+0x53, 0x68, 0x74, 0x46, 0x81, 0xd0, 0xe6, 0xe1, 0xdb, 0x3d, 0x1e, 0x20,
+0x72, 0xcd, 0xd9, 0x0a, 0xf6, 0xb7, 0x2a, 0x10, 0x42, 0x30, 0xfe, 0x23,
+0x04, 0x1e, 0x62, 0xe0, 0x7f, 0x1e, 0x03, 0x31, 0x00, 0xd2, 0x01, 0x08,
+0x81, 0xc3, 0xbb, 0x01, 0xf5, 0x5d, 0x59, 0xea, 0x53, 0xc3, 0x86, 0x77,
+0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
+0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/ParentFolder.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/ParentFolder.h
new file mode 100644
index 000000000..544b9c7cf
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/ParentFolder.h
@@ -0,0 +1,91 @@
+static unsigned char PARENT_FOLDER_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,
+0x08, 0x03, 0x00, 0x00, 0x00, 0x28, 0x2d, 0x0f, 0x53, 0x00, 0x00, 0x03,
+0x00, 0x50, 0x4c, 0x54, 0x45, 0x01, 0x67, 0x01, 0x08, 0x6e, 0x05, 0x08,
+0x77, 0x04, 0x0c, 0x79, 0x07, 0x11, 0x70, 0x0a, 0x11, 0x7c, 0x09, 0x16,
+0x7c, 0x0c, 0x17, 0x79, 0x13, 0x1f, 0x78, 0x1f, 0x37, 0x7a, 0x0b, 0x21,
+0x7d, 0x21, 0x14, 0x8c, 0x0b, 0x19, 0x98, 0x0d, 0x1c, 0xa0, 0x0f, 0x22,
+0x81, 0x17, 0x27, 0x8c, 0x14, 0x27, 0x8f, 0x14, 0x26, 0x8b, 0x1a, 0x27,
+0x8c, 0x1b, 0x2f, 0x94, 0x1f, 0x31, 0x81, 0x1b, 0x2f, 0x81, 0x2f, 0x3b,
+0x85, 0x2e, 0x3d, 0x8a, 0x3d, 0x3e, 0x8a, 0x3f, 0x3c, 0xa1, 0x1f, 0x34,
+0xb3, 0x1b, 0x41, 0x8c, 0x3e, 0x51, 0x8e, 0x29, 0x43, 0xad, 0x22, 0x44,
+0xb7, 0x22, 0x49, 0xbd, 0x25, 0x59, 0xbe, 0x39, 0x61, 0x93, 0x2e, 0x4e,
+0x8f, 0x41, 0x6b, 0xa5, 0x6c, 0x6c, 0xa6, 0x6d, 0x79, 0xad, 0x7a, 0x57,
+0xc4, 0x2c, 0x67, 0xcc, 0x34, 0x6c, 0xd1, 0x39, 0x60, 0xc5, 0x40, 0x75,
+0xda, 0x42, 0x74, 0xd8, 0x47, 0x7f, 0xe3, 0x4c, 0xb9, 0x9c, 0x11, 0x81,
+0xac, 0x47, 0x85, 0xea, 0x53, 0x8e, 0xf4, 0x5c, 0xcc, 0x99, 0x01, 0xd6,
+0xa5, 0x17, 0xd1, 0xa4, 0x1e, 0xd3, 0xa9, 0x2c, 0xdd, 0xaf, 0x35, 0xde,
+0xb5, 0x36, 0xdf, 0xba, 0x3c, 0xe6, 0xbc, 0x3e, 0xde, 0xbe, 0x51, 0xd9,
+0xb9, 0x58, 0xdb, 0xbe, 0x66, 0xe2, 0xb8, 0x43, 0xe6, 0xbc, 0x51, 0xdf,
+0xc3, 0x6b, 0xe6, 0xc2, 0x44, 0xec, 0xc6, 0x4e, 0xea, 0xc0, 0x57, 0xf2,
+0xcc, 0x5b, 0xe2, 0xc6, 0x71, 0xe6, 0xc9, 0x79, 0xe6, 0xd1, 0x63, 0xf2,
+0xd5, 0x64, 0xf5, 0xdf, 0x79, 0xff, 0xdc, 0x77, 0xef, 0xe0, 0x7b, 0xfc,
+0xe4, 0x7c, 0x89, 0xb7, 0x8b, 0x8f, 0xbc, 0x87, 0xb7, 0xd3, 0xba, 0xdf,
+0xec, 0x86, 0xdf, 0xe6, 0xaf, 0xe3, 0xce, 0x92, 0xe4, 0xd3, 0x9e, 0xe4,
+0xd4, 0x9e, 0xec, 0xd9, 0x99, 0xec, 0xd9, 0x9f, 0xfc, 0xd4, 0x83, 0xff,
+0xdb, 0x89, 0xe5, 0xd6, 0xa3, 0xe5, 0xd7, 0xab, 0xef, 0xdf, 0xab, 0xff,
+0xe8, 0x83, 0xff, 0xea, 0x95, 0xff, 0xf2, 0x8c, 0xff, 0xf9, 0x93, 0xff,
+0xff, 0x99, 0xef, 0xf5, 0xbc, 0xf2, 0xe6, 0xa4, 0xff, 0xe6, 0xa0, 0xff,
+0xf2, 0xa9, 0xff, 0xf8, 0xa6, 0xff, 0xff, 0xac, 0xff, 0xff, 0xbe, 0xc6,
+0xdb, 0xc9, 0xd6, 0xe3, 0xd9, 0xea, 0xe2, 0xca, 0xeb, 0xe7, 0xd6, 0xee,
+0xea, 0xdb, 0xf5, 0xea, 0xc1, 0xff, 0xf4, 0xc8, 0xff, 0xfe, 0xc6, 0xfc,
+0xf9, 0xcf, 0xff, 0xff, 0xd1, 0xff, 0xff, 0xd9, 0xe5, 0xed, 0xe9, 0xff,
+0xff, 0xe7, 0xf3, 0xf4, 0xf7, 0xff, 0xff, 0xf2, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0xd0, 0xf6, 0xa4, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0e, 0xc4, 0x00, 0x00,
+0x0e, 0xc4, 0x01, 0x95, 0x2b, 0x0e, 0x1b, 0x00, 0x00, 0x00, 0xc1, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x28, 0x86, 0x02, 0x15, 0x89, 0x74,
+0x30, 0xcd, 0x00, 0xe5, 0xfb, 0x32, 0xf1, 0xb0, 0x7b, 0x23, 0x09, 0x14,
+0x72, 0xf1, 0x4a, 0xc9, 0x09, 0x88, 0xa6, 0xc1, 0x05, 0x94, 0xb9, 0xa5,
+0xe4, 0xd5, 0xd4, 0x25, 0x19, 0x55, 0xc1, 0x02, 0xa6, 0xa6, 0xa6, 0x0c,
+0xcc, 0xac, 0xb2, 0xea, 0x1a, 0x1c, 0xac, 0xac, 0x20, 0x01, 0xd3, 0xe0,
+0xbc, 0x78, 0xa0, 0x18, 0xbf, 0x86, 0x96, 0x38, 0xc4, 0x0c, 0xd3, 0xdc,
+0xb8, 0xb8, 0xd4, 0xfc, 0x5c, 0x36, 0x2d, 0x1d, 0x31, 0xa8, 0x40, 0x72,
+0x2c, 0x10, 0x98, 0x72, 0xea, 0x68, 0x2b, 0x99, 0x9a, 0x82, 0x05, 0xa2,
+0xbd, 0xdc, 0xec, 0xcd, 0x43, 0xa4, 0xf5, 0x15, 0x7c, 0x4a, 0xec, 0xc0,
+0x02, 0x61, 0x36, 0x91, 0x45, 0x05, 0xb9, 0x7c, 0x06, 0x82, 0xfe, 0x09,
+0xe1, 0x60, 0x81, 0x50, 0xe7, 0x94, 0xb8, 0x38, 0x3f, 0x61, 0x4d, 0xc5,
+0x24, 0x4b, 0x88, 0x19, 0x8e, 0xd9, 0x31, 0x31, 0x31, 0x7a, 0x42, 0x22,
+0x9e, 0xee, 0x01, 0x10, 0x01, 0xdb, 0x9c, 0xa8, 0xa8, 0x28, 0x16, 0x19,
+0x57, 0x07, 0xb3, 0x2c, 0x88, 0x80, 0x4b, 0xa2, 0x87, 0x93, 0x85, 0xae,
+0xa1, 0xb1, 0x55, 0x10, 0xd4, 0xda, 0x10, 0x23, 0x43, 0x13, 0xeb, 0xc0,
+0x8c, 0x62, 0x98, 0x6f, 0x4d, 0x4d, 0x23, 0x32, 0x8b, 0xe1, 0x00, 0x00,
+0xfc, 0x33, 0x50, 0x72, 0x6d, 0x03, 0x36, 0xf2, 0x00, 0x00, 0x00, 0x00,
+0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Test2PNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Test2PNG.h
new file mode 100644
index 000000000..80a768ac6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/Test2PNG.h
@@ -0,0 +1,21 @@
+static const unsigned char TEST2_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x12, 0x59, 0x20, 0xcb, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x47, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0xb5, 0xcd, 0xbb, 0x11, 0x00, 0x20, 0x08,
+0x03, 0x50, 0x16, 0x60, 0x57, 0x47, 0xb5, 0xb3, 0xc2, 0x0d, 0xcc, 0x0c,
+0x22, 0x9f, 0xc3, 0xde, 0x33, 0x05, 0x29, 0x5e, 0xee, 0x20, 0xfa, 0x1e,
+0x16, 0x91, 0x1e, 0x97, 0x26, 0xb0, 0x9a, 0x17, 0x31, 0x80, 0x71, 0x06,
+0xda, 0x3d, 0xc0, 0x29, 0xc0, 0x29, 0xc1, 0x28, 0xc1, 0x29, 0xc1, 0x68,
+0xd4, 0xc7, 0x0b, 0x94, 0x0a, 0x94, 0x2e, 0x78, 0xc9, 0x06, 0xae, 0xb5,
+0x39, 0x27, 0x85, 0x82, 0xfa, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
+0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/TestPNG.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/TestPNG.h
new file mode 100644
index 000000000..c1c0887eb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/res/TestPNG.h
@@ -0,0 +1,25 @@
+static const unsigned char TEST_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x24,
+0x04, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x6b, 0xa4, 0x39, 0x00, 0x00, 0x00,
+0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00,
+0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00,
+0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x14, 0x3b, 0x9d, 0x00, 0x00, 0x00,
+0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0xea, 0x65, 0x16, 0xa4, 0x00, 0x00, 0x00, 0x75, 0x49,
+0x44, 0x41, 0x54, 0x78, 0x9c, 0xd5, 0xd1, 0x31, 0x1a, 0x80, 0x20, 0x08,
+0x05, 0x60, 0xc7, 0x96, 0xee, 0xdb, 0xd8, 0x05, 0xb8, 0x9b, 0x9b, 0x53,
+0xdd, 0xa0, 0xce, 0x10, 0x20, 0xfa, 0x55, 0xef, 0xd5, 0x2e, 0x23, 0xf2,
+0x2b, 0x60, 0x4a, 0x63, 0xc4, 0x66, 0x91, 0x31, 0x3f, 0x9f, 0x1a, 0xc7,
+0x82, 0x07, 0xbb, 0x1d, 0x94, 0xf5, 0x1f, 0xdc, 0x6f, 0x7d, 0x00, 0xf1,
+0x2a, 0xf2, 0xc2, 0xe4, 0x65, 0x99, 0xbc, 0xd0, 0xc9, 0xbb, 0xa5, 0x4e,
+0xa0, 0xa5, 0x20, 0x38, 0x43, 0x10, 0x32, 0x43, 0x25, 0x64, 0xe8, 0x4a,
+0xd8, 0xd0, 0x12, 0x79, 0xd8, 0x52, 0x23, 0xb8, 0x25, 0xe1, 0xa0, 0x11,
+0xb2, 0x56, 0x27, 0xec, 0x1f, 0x9c, 0x30, 0x60, 0x84, 0x02, 0x23, 0x1c,
+0x28, 0xe1, 0x40, 0xc9, 0x07, 0x18, 0x21, 0x2e, 0x97, 0xf8, 0xa1, 0xe3,
+0xf9, 0x5b, 0x6d, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
+0xae, 0x42, 0x60, 0x82, 0x00,
+};
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/resource.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/resource.h
new file mode 100644
index 000000000..4bebb95a6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/resource.h
@@ -0,0 +1,168 @@
+#define IDI_FAM 101
+#define IDI_FM 101
+#define IDR_MENUBAR1 103
+#define IDM_MENU 103
+#define IDR_ACCELERATOR1 209
+#define IDM_FILE_OPEN 210
+#define IDM_FILE_OPEN_INSIDE 211
+#define IDM_FILE_OPEN_OUTSIDE 212
+#define IDM_FILE_VIEW 220
+#define IDM_FILE_EDIT 221
+#define IDM_RENAME 230
+#define IDM_COPY_TO 231
+#define IDM_MOVE_TO 232
+#define IDM_DELETE 233
+#define IDM_FILE_SPLIT 238
+#define IDM_FILE_COMBINE 239
+#define IDM_FILE_PROPERTIES 240
+#define IDM_FILE_COMMENT 241
+#define IDM_FILE_CRC 242
+#define IDM_CREATE_FOLDER 250
+#define IDM_CREATE_FILE 251
+#define IDM_EDIT_CUT 320
+#define IDM_EDIT_COPY 321
+#define IDM_EDIT_PASTE 322
+#define IDM_SELECT_ALL 330
+#define IDM_DESELECT_ALL 331
+#define IDM_INVERT_SELECTION 332
+#define IDM_SELECT 333
+#define IDM_DESELECT 334
+#define IDM_SELECT_BY_TYPE 335
+#define IDM_DESELECT_BY_TYPE 336
+#define IDM_VIEW_LARGE_ICONS 410
+#define IDM_VIEW_SMALL_ICONS 411
+#define IDM_VIEW_LIST 412
+#define IDM_VIEW_DETAILS 413
+#define IDM_VIEW_ARANGE_BY_NAME 420
+#define IDM_VIEW_ARANGE_BY_TYPE 421
+#define IDM_VIEW_ARANGE_BY_DATE 422
+#define IDM_VIEW_ARANGE_BY_SIZE 423
+#define IDM_VIEW_ARANGE_NO_SORT 424
+#define IDM_OPEN_ROOT_FOLDER 430
+#define IDM_OPEN_PARENT_FOLDER 431
+#define IDM_FOLDERS_HISTORY 432
+#define IDM_VIEW_REFRESH 440
+#define IDM_VIEW_FLAT_VIEW 449
+#define IDM_VIEW_TWO_PANELS 450
+#define IDM_VIEW_TOOLBARS 451
+#define IDM_VIEW_STANDARD_TOOLBAR 460
+#define IDM_VIEW_ARCHIVE_TOOLBAR 461
+#define IDM_VIEW_TOOLBARS_LARGE_BUTTONS 462
+#define IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 463
+#define IDM_OPTIONS 510
+#define IDM_BENCHMARK 511
+#define IDM_HELP_CONTENTS 610
+#define IDM_ABOUT 620
+#define IDS_BOOKMARK 720
+#define IDB_ADD 2002
+#define IDB_EXTRACT 2003
+#define IDB_TEST 2004
+#define IDB_COPY 2010
+#define IDB_MOVE 2011
+#define IDB_DELETE 2012
+#define IDB_INFO 2013
+#define IDB_ADD2 2082
+#define IDB_EXTRACT2 2083
+#define IDB_TEST2 2084
+#define IDB_COPY2 2090
+#define IDB_MOVE2 2091
+#define IDB_DELETE2 2092
+#define IDB_INFO2 2093
+#define IDS_APP_TITLE 2200
+#define IDS_COPY 2201
+#define IDS_MOVE 2202
+#define IDS_COPY_TO 2203
+#define IDS_MOVE_TO 2204
+#define IDS_COPYING 2205
+#define IDS_MOVING 2206
+#define IDS_CANNOT_COPY 2207
+#define IDS_OPERATION_IS_NOT_SUPPORTED 2208
+
+#define IDS_CONFIRM_FILE_DELETE 2210
+#define IDS_CONFIRM_FOLDER_DELETE 2211
+#define IDS_CONFIRM_ITEMS_DELETE 2212
+#define IDS_WANT_TO_DELETE_FILE 2213
+#define IDS_WANT_TO_DELETE_FOLDER 2214
+#define IDS_WANT_TO_DELETE_ITEMS 2215
+#define IDS_DELETING 2216
+#define IDS_ERROR_DELETING 2217
+#define IDS_ERROR_LONG_PATH_TO_RECYCLE 2218
+
+#define IDS_RENAMING 2220
+#define IDS_ERROR_RENAMING 2221
+#define IDS_CONFIRM_FILE_COPY 2222
+#define IDS_WANT_TO_COPY_FILES 2223
+
+
+#define IDS_CREATE_FOLDER 2230
+#define IDS_CREATE_FOLDER_NAME 2231
+#define IDS_CREATE_FOLDER_DEFAULT_NAME 2232
+#define IDS_CREATE_FOLDER_ERROR 2233
+#define IDS_CREATE_FILE 2240
+#define IDS_CREATE_FILE_NAME 2241
+#define IDS_CREATE_FOLDER_DEFAULT_FILE_NAME 2242
+#define IDS_CREATE_FILE_DEFAULT_NAME 2242
+#define IDS_CREATE_FILE_ERROR 2243
+#define IDS_SELECT 2250
+#define IDS_DESELECT 2251
+#define IDS_SELECT_MASK 2252
+#define IDS_FOLDERS_HISTORY 2260
+#define IDS_N_SELECTED_ITEMS 2270
+#define IDS_FILES_COLON 2274
+#define IDS_FOLDERS_COLON 2275
+#define IDS_SIZE_COLON 2276
+
+#define IDS_TOO_MANY_ITEMS 2279
+#define IDS_WANT_UPDATE_MODIFIED_FILE 2280
+#define IDS_CANNOT_UPDATE_FILE 2281
+#define IDS_CANNOT_START_EDITOR 2282
+#define IDS_OPENNING 2283
+#define IDS_VIRUS 2284
+#define IDS_COMPUTER 2300
+#define IDS_NETWORK 2301
+#define IDS_DOCUMENTS 2302
+#define IDS_ADD 2400
+#define IDS_EXTRACT 2401
+#define IDS_TEST 2402
+#define IDS_BUTTON_COPY 2420
+#define IDS_BUTTON_MOVE 2421
+#define IDS_BUTTON_DELETE 2422
+#define IDS_BUTTON_INFO 2423
+#define IDS_PROP_TOTAL_SIZE 3100
+#define IDS_PROP_FREE_SPACE 3101
+#define IDS_PROP_CLUSTER_SIZE 3102
+#define IDS_PROP_VOLUME_NAME 3103
+#define IDS_PROP_LOCAL_NAME 3200
+#define IDS_PROP_PROVIDER 3201
+#define IDS_OPTIONS 4000
+#define IDS_COMMENT 4001
+#define IDS_COMMENT2 4002
+#define IDS_SYSTEM 4010
+
+#define IDS_SPLITTING 4020
+#define IDS_SPLIT_CONFIRM_TITLE 4021
+#define IDS_SPLIT_CONFIRM_MESSAGE 4022
+#define IDS_SPLIT_VOL_MUST_BE_SMALLER 4023
+
+#define IDS_COMBINE 4030
+#define IDS_COMBINE_TO 4031
+#define IDS_COMBINING 4032
+#define IDS_COMBINE_SELECT_ONE_FILE 4033
+#define IDS_COMBINE_CANT_DETECT_SPLIT_FILE 4034
+#define IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART 4035
+
+#define IDS_CHECKSUM_CALCULATING 4040
+#define IDS_CHECKSUM_INFORMATION 4041
+#define IDS_CHECKSUM_CRC_DATA 4042
+#define IDS_CHECKSUM_CRC_DATA_NAMES 4043
+
+#define IDS_SCANNING 4050
+#define IDS_PROPERTIES 4060
+
+#define IDS_PROGRESS_TESTING 4100
+#define IDS_MESSAGE_NO_ERRORS 4200
+
+#define IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER 4301
+#define IDS_SELECT_ONE_FILE 4302
+#define IDS_SELECT_FILES 4303
+#define IDS_FILE_EXIST 4304
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/wxFM.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/wxFM.cpp
new file mode 100644
index 000000000..1fa11d1e7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/wxFM.cpp
@@ -0,0 +1,345 @@
+// wxFM.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+// #include "../GUI/p7zip_32.xpm"
+
+int Main1(int argc,TCHAR **argv);
+
+/*
+int Main1(int argc,TCHAR **argv)
+{
+ // FIXME
+ Sleep(10000);
+}
+*/
+
+
+#include "Windows/Registry.h"
+using namespace NWindows;
+using namespace NRegistry;
+
+
+#include "Common/StringConvert.h"
+#include "Windows/FileDir.h"
+#include "Windows/Synchronization.h"
+
+// FIXME #include "ExtractRes.h"
+#include "../Explorer/MyMessages.h"
+
+// FIXME #include "ExtractGUI.h"
+// FIXME #include "UpdateGUI.h"
+// FIXME #include "BenchmarkDialog.h"
+#include "RegistryUtils.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+#include "../FileManager/ProgramLocation.h"
+
+static LPCWSTR kHelpFileName = L"help/";
+
+void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
+{
+ UString path;
+ if (!::GetProgramFolderPath(path))
+ return;
+ path += kHelpFileName;
+ path += topicFile;
+ printf("ShowHelpWindow(%p,%ls)=>%ls\n",hwnd,topicFile,(const wchar_t *)path);
+ // HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);
+ wxString path2(path);
+ wxLaunchDefaultBrowser(path2);
+}
+
+////////////////////////////// TRIES ///////////////////////////////////
+
+// FIXME : duplicate
+
+#if 0
+static const TCHAR *kCUBasePath = TEXT("Software/7-ZIP");
+static const WCHAR *kLangValueName = L"Lang";
+
+void SaveRegLang(const UString &langFile)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(kLangValueName, langFile);
+}
+
+void ReadRegLang(UString &langFile)
+{
+ langFile.Empty();
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
+ key.QueryValue(kLangValueName, langFile);
+}
+#endif
+
+
+//////////////////////////////////
+
+#define NEED_NAME_WINDOWS_TO_UNIX
+#include "myPrivate.h" // global_use_utf16_conversion
+
+void mySplitCommandLineW(int numArguments, TCHAR **arguments,UStringVector &parts) {
+
+ parts.Clear();
+ for(int ind=0;ind < numArguments; ind++) {
+ UString tmp = arguments[ind];
+ // tmp.Trim(); " " is a valid filename ...
+ if (!tmp.IsEmpty()) {
+ parts.Add(tmp);
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+// private classes
+// ----------------------------------------------------------------------------
+
+// Define a new frame type
+#if 0
+class MyFrame: public wxFrame
+{
+public:
+ // ctor
+ MyFrame(wxFrame *frame, const wxString& title, int x, int y, int w, int h);
+ // virtual ~MyFrame();
+
+ // operations
+ void WriteText(const wxString& text) { m_txtctrl->WriteText(text); }
+
+protected:
+ // callbacks
+ void OnWorkerEvent(wxCommandEvent& event);
+private:
+ // just some place to put our messages in
+ wxTextCtrl *m_txtctrl;
+ DECLARE_EVENT_TABLE()
+};
+
+enum {
+ WORKER_EVENT=100 // this one gets sent from the worker thread
+};
+
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ EVT_MENU(WORKER_EVENT, MyFrame::OnWorkerEvent)
+ // EVT_IDLE(MyFrame::OnIdle)
+END_EVENT_TABLE()
+
+// My frame constructor
+MyFrame::MyFrame(wxFrame *frame, const wxString& title,
+ int x, int y, int w, int h)
+ : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
+{
+ //FIXME this->SetIcon(wxICON(p7zip_32));
+
+#if wxUSE_STATUSBAR
+ CreateStatusBar(2);
+#endif // wxUSE_STATUSBAR
+
+ m_txtctrl = new wxTextCtrl(this, wxID_ANY, _T(""), wxPoint(0, 0), wxSize(0, 0), wxTE_MULTILINE | wxTE_READONLY);
+}
+
+void myCreateHandle(int n);
+void MyFrame::OnWorkerEvent(wxCommandEvent& event)
+{
+ int n = event.GetInt();
+ myCreateHandle(n);
+}
+
+wxWindow * g_window=0;
+#endif
+
+
+// Define a new application type, each program should derive a class from wxApp
+class MyApp : public wxApp
+{
+public:
+ // override base class virtuals
+ // ----------------------------
+
+ // this one is called on application startup and is a good place for the app
+ // initialization (doing it here and not in the ctor allows to have an error
+ // return: if OnInit() returns false, the application terminates)
+ virtual bool OnInit();
+};
+
+// Create a new application object: this macro will allow wxWidgets to create
+// the application object during program execution (it's better than using a
+// static object for many reasons) and also implements the accessor function
+// wxGetApp() which will return the reference of the right type (i.e. MyApp and
+// not wxApp)
+IMPLEMENT_APP(MyApp)
+
+time_t g_T0 = 0;
+
+#if 0
+class MyThread : public wxThread
+{
+ int _argc;
+ TCHAR **_argv;
+public:
+ MyThread(int argc,TCHAR **argv): wxThread(),_argc(argc), _argv(argv) {}
+
+ // thread execution starts here
+ virtual void *Entry()
+ {
+ int ret = Main1(_argc,_argv);
+ exit(ret);
+ }
+};
+#endif
+
+// 'Main program' equivalent: the program execution "starts" here
+bool MyApp::OnInit()
+{
+ // don't parse the command-line options !
+ // : if ( !wxApp::OnInit() ) return false;
+
+ { // define P7ZIP_HOME_DIR
+ extern void my_windows_split_path(const AString &p_path, AString &dir , AString &base);
+ static char p7zip_home_dir[MAX_PATH];
+
+ UString fullPath;
+ NDirectory::MyGetFullPathName(wxApp::argv[0], fullPath);
+ AString afullPath = GetAnsiString(fullPath);
+
+ AString dir,name;
+
+ my_windows_split_path(afullPath,dir,name);
+
+ const char *dir2 = nameWindowToUnix((const char *)dir);
+ snprintf(p7zip_home_dir,sizeof(p7zip_home_dir),"P7ZIP_HOME_DIR=%s/",dir2);
+ p7zip_home_dir[sizeof(p7zip_home_dir)-1] = 0;
+ putenv(p7zip_home_dir);
+ // DEBUG printf("putenv(%s)\n",p7zip_home_dir);
+ }
+ global_use_utf16_conversion = 1; // UNICODE !
+
+ g_T0 = time(0);
+ // DEBUG printf("MAIN Thread : 0x%lx\n",wxThread::GetCurrentId());
+
+ // Create the main frame window
+#if 0
+ MyFrame *frame = new MyFrame((wxFrame *)NULL, _T("7-zip Main Window"), 50, 50, 450, 340);
+ // Don't Show the frame !
+ frame->Show(true); // FIXME
+
+ SetTopWindow(frame);
+
+ g_window = frame;
+#endif
+
+ /*
+ MyThread *thread = new MyThread(wxApp::argc,wxApp::argv);
+ thread->Create(); // != wxTHREAD_NO_ERROR
+ thread->Run();
+ */
+
+ wxInitAllImageHandlers();
+
+ Main1(wxApp::argc,wxApp::argv);
+
+ // success: wxApp::OnRun() will be called which will enter the main message
+ // loop and the application will run. If we returned false here, the
+ // application would exit immediately.
+ return true;
+}
+
+DWORD WINAPI GetTickCount(VOID) {
+ static wxStopWatch sw;
+ return sw.Time();
+}
+
+//////////////////////////////////////////
+
+#if 0
+#include "resource.h"
+#include "ExtractRes.h"
+
+static CStringTable g_stringTable[] =
+{
+ /* resource.rc */
+ /***************/
+ { IDS_OPEN_TYPE_ALL_FILES, L"All Files" },
+ { IDS_METHOD_STORE, L"Store" },
+ { IDS_METHOD_NORMAL, L"Normal" },
+ { IDS_METHOD_MAXIMUM, L"Maximum" },
+ { IDS_METHOD_FAST, L"Fast" },
+ { IDS_METHOD_FASTEST, L"Fastest" },
+ { IDS_METHOD_ULTRA, L"Ultra" },
+ { IDS_COMPRESS_NON_SOLID, L"Non-solid" },
+ { IDS_COMPRESS_SOLID, L"Solid" },
+
+ { IDS_COMPRESS_UPDATE_MODE_ADD, L"Add and replace files" },
+ { IDS_COMPRESS_UPDATE_MODE_UPDATE, L"Update and add files" },
+ { IDS_COMPRESS_UPDATE_MODE_FRESH, L"Freshen existing files" },
+ { IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE, L"Synchronize files" },
+ { IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, L"Browse" },
+ { IDS_COMPRESS_INCORRECT_VOLUME_SIZE, L"Incorrect volume size" },
+ { IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, L"Specified volume size: {0} bytes.\nAre you sure you want to split archive into such volumes?" },
+
+ { IDS_PASSWORD_USE_ASCII, L"Use only English letters, numbers and special characters (!, #, $, ...) for password." },
+ { IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH, L"Passwords do not match" },
+ { IDS_PASSWORD_IS_TOO_LONG, L"Password is too long" },
+
+ { IDS_PROGRESS_COMPRESSING, L"Compressing" },
+ { IDS_PROGRESS_TESTING, L"Testing" },
+ { IDS_MESSAGE_NO_ERRORS, L"There are no errors" },
+ { IDS_FILES_COLON, L"Files:" },
+ { IDS_FOLDERS_COLON, L"Folders:" },
+ { IDS_SIZE_COLON, L"Size:" },
+ { IDS_COMPRESSED_COLON, L"Compressed size:" },
+ { IDS_ARCHIVES_COLON, L"Archives:" },
+
+ /* Extract.rc */
+ /**************/
+ { IDS_CANNOT_CREATE_FOLDER , L"Cannot create folder '{0}'"},
+ { IDS_OPEN_IS_NOT_SUPORTED_ARCHIVE, L"File is not supported archive."},
+
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC , L"CRC failed in '{0}'. File is broken."},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR , L"Data error in '{0}'. File is broken"},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD , L"Unsupported compression method for '{0}'."},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED , L"CRC failed in encrypted file '{0}'. Wrong password?"},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED , L"Data error in encrypted file '{0}'. Wrong password?"},
+
+ { IDS_EXTRACT_SET_FOLDER , L"Specify a location for extracted files."},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CANNOT_OPEN_FILE, L"Can not open output file '{0}'."},
+ { IDS_PROGRESS_EXTRACTING, L"Extracting" },
+
+ { IDS_CANT_OPEN_ARCHIVE , L"Can not open file '{0}' as archive"},
+ { IDS_CANT_OPEN_ENCRYPTED_ARCHIVE , L"Can not open encrypted archive '{0}'. Wrong password?"},
+
+ { 0 , 0 }
+};
+
+REGISTER_STRINGTABLE(g_stringTable)
+#endif
+
+
+///////////////////////////////////////////
+
+namespace NFsFolder {
+
+ // FIXME
+ bool wxw_CopyFile(LPCWSTR existingFile, LPCWSTR newFile, bool overwrite)
+ {
+ return wxCopyFile(wxString(existingFile), wxString(newFile), overwrite);
+ }
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
new file mode 100644
index 000000000..c7a1cc5be
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
@@ -0,0 +1,581 @@
+// BenchmarkDialog.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringToInt.h"
+#include "Common/MyException.h"
+#include "Windows/Thread.h"
+#include "Windows/Error.h"
+#include "Windows/System.h"
+#include "../FileManager/HelpUtils.h"
+// #include "BenchmarkDialogRes.h"
+#include "BenchmarkDialog.h"
+
+using namespace NWindows;
+
+// const int kNumBenchDictionaryBitsStart = 21;
+
+static LPCWSTR kHelpTopic = L"fm/benchmark.htm";
+
+static const UINT_PTR kTimerID = 4;
+static const UINT kTimerElapse = 1000;
+
+#ifdef LANG
+#include "../FileManager/LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_BENCHMARK_DICTIONARY, 0x02000D0C },
+ { IDC_BENCHMARK_MEMORY, 0x03080001 },
+ { IDC_BENCHMARK_NUM_THREADS, 0x02000D12 },
+ { IDC_BENCHMARK_SPEED_LABEL, 0x03080004 },
+ { IDC_BENCHMARK_RATING_LABEL, 0x03080005 },
+ { IDC_BENCHMARK_COMPRESSING, 0x03080002 },
+ { IDC_BENCHMARK_DECOMPRESSING, 0x03080003 },
+ { IDC_BENCHMARK_CURRENT, 0x03080007 },
+ { IDC_BENCHMARK_RESULTING, 0x03080008 },
+ { IDC_BENCHMARK_CURRENT2, 0x03080007 },
+ { IDC_BENCHMARK_RESULTING2, 0x03080008 },
+ { IDC_BENCHMARK_TOTAL_RATING, 0x03080006 },
+ { IDC_BENCHMARK_ELAPSED, 0x02000C01 },
+ { IDC_BENCHMARK_SIZE, 0x02000C03 },
+ { IDC_BENCHMARK_PASSES, 0x03080009 },
+ // { IDC_BENCHMARK_ERRORS, 0x0308000A },
+ { IDC_BENCHMARK_USAGE_LABEL, 0x0308000B },
+ { IDC_BENCHMARK_RPU_LABEL, 0x0308000C },
+ { IDC_BENCHMARK_COMBO_NUM_THREADS, 0x02000D12},
+
+ { IDC_BUTTON_STOP, 0x02000714 },
+ { IDC_BUTTON_RESTART, 0x02000715 },
+ { IDHELP, 0x02000720 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+static void MyMessageBoxError(HWND hwnd, LPCWSTR message)
+{
+ MessageBoxW(hwnd, message, L"7-Zip", MB_ICONERROR);
+}
+
+const LPCTSTR kProcessingString = TEXT("...");
+const LPCTSTR kMB = TEXT(" MB");
+const LPCTSTR kMIPS = TEXT(" MIPS");
+const LPCTSTR kKBs = TEXT(" KB/s");
+
+static const int kMinDicLogSize = 21;
+static const UInt32 kMinDicSize = (1 << kMinDicLogSize);
+static const UInt32 kMaxDicSize =
+ #ifdef _WIN64
+ (1 << 30);
+ #else
+ (1 << 27);
+ #endif
+
+bool CBenchmarkDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x03080000);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+
+ _syncInfo.Init();
+
+ m_Dictionary.Attach(GetItem(IDC_BENCHMARK_COMBO_DICTIONARY));
+ int cur = 0;
+ // _syncInfo.DictionarySize = (1 << kNumBenchDictionaryBitsStart);
+
+ UInt32 numCPUs = NSystem::GetNumberOfProcessors();
+ if (numCPUs < 1)
+ numCPUs = 1;
+ numCPUs = MyMin(numCPUs, (UInt32)(1 << 8));
+ cur = 0;
+ bool setDefaultThreads = (_syncInfo.NumThreads == (UInt32)(-1));
+ if (setDefaultThreads)
+ {
+ _syncInfo.NumThreads = numCPUs;
+ if (_syncInfo.NumThreads > 1)
+ _syncInfo.NumThreads &= ~1;
+ }
+
+ UInt64 ramSize = NSystem::GetRamSize();
+ bool setDefaultDictionary = (_syncInfo.DictionarySize == (UInt32)(-1));
+ if (setDefaultDictionary)
+ {
+ int dicSizeLog;
+ for (dicSizeLog = 25; dicSizeLog >= kBenchMinDicLogSize; dicSizeLog--)
+ if (GetBenchMemoryUsage(_syncInfo.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
+ break;
+ _syncInfo.DictionarySize = (1 << dicSizeLog);
+ }
+ if (_syncInfo.DictionarySize < kMinDicSize)
+ _syncInfo.DictionarySize = kMinDicSize;
+ if (_syncInfo.DictionarySize > kMaxDicSize)
+ _syncInfo.DictionarySize = kMaxDicSize;
+
+ for (int i = kMinDicLogSize; i <= 30; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ UInt32 dictionary = (1 << i) + (j << (i - 1));
+ if (dictionary > kMaxDicSize)
+ continue;
+ TCHAR s[40];
+ ConvertUInt64ToString((dictionary >> 20), s);
+ lstrcat(s, kMB);
+ int index = (int)m_Dictionary.AddString(s);
+ m_Dictionary.SetItemData(index, dictionary);
+ if (dictionary <= _syncInfo.DictionarySize)
+ cur = index;
+ }
+ m_Dictionary.SetCurSel(cur);
+
+ m_NumThreads.Attach(GetItem(IDC_BENCHMARK_COMBO_NUM_THREADS));
+ for (UInt32 num = 1; ;)
+ {
+ if (num > numCPUs * 2)
+ break;
+ TCHAR s[40];
+ ConvertUInt64ToString(num, s);
+ int index = (int)m_NumThreads.AddString(s);
+ m_NumThreads.SetItemData(index, num);
+ if (num <= numCPUs && setDefaultThreads)
+ {
+ _syncInfo.NumThreads = num;
+ cur = index;
+ }
+ if (num > 1)
+ num++;
+ num++;
+ }
+ m_NumThreads.SetCurSel(cur);
+
+ OnChangeSettings();
+
+ _syncInfo._startEvent.Set();
+ _timer = SetTimer(kTimerID, kTimerElapse);
+ return CModalDialog::OnInit();
+}
+
+UInt32 CBenchmarkDialog::GetNumberOfThreads()
+{
+ return (UInt32)m_NumThreads.GetItemData(m_NumThreads.GetCurSel());
+}
+
+UInt32 CBenchmarkDialog::OnChangeDictionary()
+{
+ UInt32 dictionary = (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
+ UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dictionary);
+ memUsage = (memUsage + (1 << 20) - 1) >> 20;
+ TCHAR s[40];
+ ConvertUInt64ToString(memUsage, s);
+ lstrcat(s, kMB);
+ SetItemText(IDC_BENCHMARK_MEMORY_VALUE, s);
+ return dictionary;
+}
+
+static const UInt32 g_IDs[] =
+{
+ IDC_BENCHMARK_COMPRESSING_USAGE,
+ IDC_BENCHMARK_COMPRESSING_USAGE2,
+ IDC_BENCHMARK_COMPRESSING_SPEED,
+ IDC_BENCHMARK_COMPRESSING_SPEED2,
+ IDC_BENCHMARK_COMPRESSING_RATING,
+ IDC_BENCHMARK_COMPRESSING_RATING2,
+ IDC_BENCHMARK_COMPRESSING_RPU,
+ IDC_BENCHMARK_COMPRESSING_RPU2,
+
+ IDC_BENCHMARK_DECOMPRESSING_SPEED,
+ IDC_BENCHMARK_DECOMPRESSING_SPEED2,
+ IDC_BENCHMARK_DECOMPRESSING_RATING,
+ IDC_BENCHMARK_DECOMPRESSING_RATING2,
+ IDC_BENCHMARK_DECOMPRESSING_USAGE,
+ IDC_BENCHMARK_DECOMPRESSING_USAGE2,
+ IDC_BENCHMARK_DECOMPRESSING_RPU,
+ IDC_BENCHMARK_DECOMPRESSING_RPU2,
+
+ IDC_BENCHMARK_TOTAL_USAGE_VALUE,
+ IDC_BENCHMARK_TOTAL_RATING_VALUE,
+ IDC_BENCHMARK_TOTAL_RPU_VALUE
+};
+
+void CBenchmarkDialog::OnChangeSettings()
+{
+ EnableItem(IDC_BUTTON_STOP, true);
+ UInt32 dictionary = OnChangeDictionary();
+ TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 };
+ ConvertUInt64ToString(NSystem::GetNumberOfProcessors(), s + 2);
+ SetItemText(IDC_BENCHMARK_HARDWARE_THREADS, s);
+ for (int i = 0; i < sizeof(g_IDs) / sizeof(g_IDs[0]); i++)
+ SetItemText(g_IDs[i], kProcessingString);
+ _startTime = GetTickCount();
+ PrintTime();
+ NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
+ _syncInfo.Init();
+ _syncInfo.DictionarySize = dictionary;
+ _syncInfo.Changed = true;
+ _syncInfo.NumThreads = GetNumberOfThreads();
+}
+
+void CBenchmarkDialog::OnRestartButton()
+{
+ OnChangeSettings();
+}
+
+void CBenchmarkDialog::OnStopButton()
+{
+ EnableItem(IDC_BUTTON_STOP, false);
+ _syncInfo.Pause();
+}
+
+void CBenchmarkDialog::OnHelp()
+{
+ ShowHelpWindow(NULL, kHelpTopic);
+}
+
+void CBenchmarkDialog::OnCancel()
+{
+ _syncInfo.Stop();
+ KillTimer(_timer);
+ CModalDialog::OnCancel();
+}
+
+static void GetTimeString(UInt64 timeValue, TCHAR *s)
+{
+ wsprintf(s, TEXT("%02d:%02d:%02d"),
+ UInt32(timeValue / 3600),
+ UInt32((timeValue / 60) % 60),
+ UInt32(timeValue % 60));
+}
+
+void CBenchmarkDialog::PrintTime()
+{
+ UInt32 curTime = ::GetTickCount();
+ UInt32 elapsedTime = (curTime - _startTime);
+ UInt32 elapsedSec = elapsedTime / 1000;
+ if (elapsedSec != 0 && _syncInfo.WasPaused())
+ return;
+ TCHAR s[40];
+ GetTimeString(elapsedSec, s);
+ SetItemText(IDC_BENCHMARK_ELAPSED_VALUE, s);
+}
+
+void CBenchmarkDialog::PrintRating(UInt64 rating, UINT controlID)
+{
+ TCHAR s[40];
+ ConvertUInt64ToString(rating / 1000000, s);
+ lstrcat(s, kMIPS);
+ SetItemText(controlID, s);
+}
+
+void CBenchmarkDialog::PrintUsage(UInt64 usage, UINT controlID)
+{
+ TCHAR s[40];
+ ConvertUInt64ToString((usage + 5000) / 10000, s);
+ lstrcat(s, TEXT("%"));
+ SetItemText(controlID, s);
+}
+
+void CBenchmarkDialog::PrintResults(
+ UInt32 dictionarySize,
+ const CBenchInfo2 &info,
+ UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
+ bool decompressMode)
+{
+ if (info.GlobalTime == 0)
+ return;
+
+ UInt64 size = info.UnpackSize;
+ TCHAR s[40];
+ {
+ UInt64 speed = size * info.GlobalFreq / info.GlobalTime;
+ ConvertUInt64ToString(speed / 1024, s);
+ lstrcat(s, kKBs);
+ SetItemText(speedID, s);
+ }
+ UInt64 rating;
+ if (decompressMode)
+ rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, size, info.PackSize, 1);
+ else
+ rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, size * info.NumIterations);
+
+ PrintRating(rating, ratingID);
+ PrintRating(GetRatingPerUsage(info, rating), rpuID);
+ PrintUsage(GetUsage(info), usageID);
+}
+
+bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
+{
+ PrintTime();
+ NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
+
+ TCHAR s[40];
+ ConvertUInt64ToString((_syncInfo.ProcessedSize >> 20), s);
+ lstrcat(s, kMB);
+ SetItemText(IDC_BENCHMARK_SIZE_VALUE, s);
+
+ ConvertUInt64ToString(_syncInfo.NumPasses, s);
+ SetItemText(IDC_BENCHMARK_PASSES_VALUE, s);
+
+ /*
+ ConvertUInt64ToString(_syncInfo.NumErrors, s);
+ SetItemText(IDC_BENCHMARK_ERRORS_VALUE, s);
+ */
+
+ {
+ UInt32 dicSizeTemp = (UInt32)MyMax(_syncInfo.ProcessedSize, UInt64(1) << 20);
+ dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize),
+ PrintResults(dicSizeTemp,
+ _syncInfo.CompressingInfoTemp,
+ IDC_BENCHMARK_COMPRESSING_USAGE,
+ IDC_BENCHMARK_COMPRESSING_SPEED,
+ IDC_BENCHMARK_COMPRESSING_RPU,
+ IDC_BENCHMARK_COMPRESSING_RATING);
+ }
+
+ {
+ PrintResults(
+ _syncInfo.DictionarySize,
+ _syncInfo.CompressingInfo,
+ IDC_BENCHMARK_COMPRESSING_USAGE2,
+ IDC_BENCHMARK_COMPRESSING_SPEED2,
+ IDC_BENCHMARK_COMPRESSING_RPU2,
+ IDC_BENCHMARK_COMPRESSING_RATING2);
+ }
+
+ {
+ PrintResults(
+ _syncInfo.DictionarySize,
+ _syncInfo.DecompressingInfoTemp,
+ IDC_BENCHMARK_DECOMPRESSING_USAGE,
+ IDC_BENCHMARK_DECOMPRESSING_SPEED,
+ IDC_BENCHMARK_DECOMPRESSING_RPU,
+ IDC_BENCHMARK_DECOMPRESSING_RATING,
+ true);
+ }
+ {
+ PrintResults(
+ _syncInfo.DictionarySize,
+ _syncInfo.DecompressingInfo,
+ IDC_BENCHMARK_DECOMPRESSING_USAGE2,
+ IDC_BENCHMARK_DECOMPRESSING_SPEED2,
+ IDC_BENCHMARK_DECOMPRESSING_RPU2,
+ IDC_BENCHMARK_DECOMPRESSING_RATING2,
+ true);
+ if (_syncInfo.DecompressingInfo.GlobalTime > 0 &&
+ _syncInfo.CompressingInfo.GlobalTime > 0)
+ {
+ UInt64 comprRating = GetCompressRating(_syncInfo.DictionarySize,
+ _syncInfo.CompressingInfo.GlobalTime, _syncInfo.CompressingInfo.GlobalFreq, _syncInfo.CompressingInfo.UnpackSize);
+ UInt64 decomprRating = GetDecompressRating(_syncInfo.DecompressingInfo.GlobalTime,
+ _syncInfo.DecompressingInfo.GlobalFreq, _syncInfo.DecompressingInfo.UnpackSize,
+ _syncInfo.DecompressingInfo.PackSize, 1);
+ PrintRating((comprRating + decomprRating) / 2, IDC_BENCHMARK_TOTAL_RATING_VALUE);
+ PrintRating((
+ GetRatingPerUsage(_syncInfo.CompressingInfo, comprRating) +
+ GetRatingPerUsage(_syncInfo.DecompressingInfo, decomprRating)) / 2, IDC_BENCHMARK_TOTAL_RPU_VALUE);
+ PrintUsage((GetUsage(_syncInfo.CompressingInfo) + GetUsage(_syncInfo.DecompressingInfo)) / 2, IDC_BENCHMARK_TOTAL_USAGE_VALUE);
+ }
+ }
+ return true;
+}
+
+bool CBenchmarkDialog::OnCommand(int code, int itemID, LPARAM lParam)
+{
+ if (code == CBN_SELCHANGE &&
+ (itemID == IDC_BENCHMARK_COMBO_DICTIONARY ||
+ itemID == IDC_BENCHMARK_COMBO_NUM_THREADS))
+ {
+ OnChangeSettings();
+ return true;
+ }
+ return CModalDialog::OnCommand(code, itemID, lParam);
+}
+
+bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_BUTTON_RESTART:
+ OnRestartButton();
+ return true;
+ case IDC_BUTTON_STOP:
+ OnStopButton();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+struct CThreadBenchmark
+{
+ CProgressSyncInfo *SyncInfo;
+ UInt64 _startTime;
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs;
+ #endif
+ // UInt32 dictionarySize;
+ // UInt32 numThreads;
+
+ HRESULT Process();
+ HRESULT Result;
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadBenchmark *)param)->Result = ((CThreadBenchmark *)param)->Process();
+ return 0;
+ }
+};
+
+struct CBenchCallback: public IBenchCallback
+{
+ UInt32 dictionarySize;
+ CProgressSyncInfo *SyncInfo;
+ HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
+ HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
+};
+
+HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
+{
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped)
+ return E_ABORT;
+ SyncInfo->ProcessedSize = info.UnpackSize;
+ if (final && SyncInfo->CompressingInfo.GlobalTime == 0)
+ {
+ (CBenchInfo&)SyncInfo->CompressingInfo = info;
+ if (SyncInfo->CompressingInfo.GlobalTime == 0)
+ SyncInfo->CompressingInfo.GlobalTime = 1;
+ }
+ else
+ (CBenchInfo&)SyncInfo->CompressingInfoTemp = info;
+
+ return S_OK;
+}
+
+HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
+{
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped)
+ return E_ABORT;
+ CBenchInfo info2 = info;
+ if (info2.NumIterations == 0)
+ info2.NumIterations = 1;
+
+ info2.UnpackSize *= info2.NumIterations;
+ info2.PackSize *= info2.NumIterations;
+ info2.NumIterations = 1;
+
+ if (final && SyncInfo->DecompressingInfo.GlobalTime == 0)
+ {
+ (CBenchInfo&)SyncInfo->DecompressingInfo = info2;
+ if (SyncInfo->DecompressingInfo.GlobalTime == 0)
+ SyncInfo->DecompressingInfo.GlobalTime = 1;
+ }
+ else
+ (CBenchInfo&)SyncInfo->DecompressingInfoTemp = info2;
+ return S_OK;
+}
+
+HRESULT CThreadBenchmark::Process()
+{
+ try
+ {
+ SyncInfo->WaitCreating();
+ for (;;)
+ {
+ if (SyncInfo->WasStopped())
+ return 0;
+ if (SyncInfo->WasPaused())
+ {
+ Sleep(200);
+ continue;
+ }
+ UInt32 dictionarySize;
+ UInt32 numThreads;
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (SyncInfo->Stopped || SyncInfo->Paused)
+ continue;
+ if (SyncInfo->Changed)
+ SyncInfo->Init();
+ dictionarySize = SyncInfo->DictionarySize;
+ numThreads = SyncInfo->NumThreads;
+ }
+
+ CBenchCallback callback;
+ callback.dictionarySize = dictionarySize;
+ callback.SyncInfo = SyncInfo;
+ HRESULT result;
+ try
+ {
+ result = LzmaBench(
+ #ifdef EXTERNAL_LZMA
+ codecs,
+ #endif
+ numThreads, dictionarySize, &callback);
+ }
+ catch(...)
+ {
+ result = E_FAIL;
+ }
+
+ if (result != S_OK)
+ {
+ if (result != E_ABORT)
+ {
+ // SyncInfo->NumErrors++;
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ SyncInfo->Pause();
+ }
+ CSysString message;
+ if (result == S_FALSE)
+ message = TEXT("Decoding error");
+ else
+ message = NError::MyFormatMessage(result);
+ MessageBox(0, message, TEXT("7-Zip"), MB_ICONERROR);
+ }
+ }
+ else
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ SyncInfo->NumPasses++;
+ }
+ }
+ // return S_OK;
+ }
+ catch(CSystemException &e)
+ {
+ MessageBox(0, NError::MyFormatMessage(e.ErrorCode), TEXT("7-Zip"), MB_ICONERROR);
+ return E_FAIL;
+ }
+ catch(...)
+ {
+ MyMessageBoxError(0, L"Some error");
+ return E_FAIL;
+ }
+}
+
+HRESULT Benchmark(
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs,
+ #endif
+ UInt32 numThreads, UInt32 dictionarySize)
+{
+ CThreadBenchmark benchmarker;
+ #ifdef EXTERNAL_LZMA
+ benchmarker.codecs = codecs;
+ #endif
+
+ CBenchmarkDialog benchmarkDialog;
+ benchmarkDialog._syncInfo.DictionarySize = dictionarySize;
+ benchmarkDialog._syncInfo.NumThreads = numThreads;
+
+ benchmarker.SyncInfo = &benchmarkDialog._syncInfo;
+ NWindows::CThread thread;
+ RINOK(thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker));
+ benchmarkDialog.Create(0);
+ return thread.Wait();
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.h
new file mode 100644
index 000000000..a57cdb399
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.h
@@ -0,0 +1,131 @@
+// BenchmarkDialog.h
+
+#ifndef __BENCHMARKDIALOG_H
+#define __BENCHMARKDIALOG_H
+
+#include "BenchmarkDialogRes.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Synchronization.h"
+#include "../../Compress/LZMA_Alone/LzmaBench.h"
+
+#ifdef EXTERNAL_LZMA
+#include "../Common/LoadCodecs.h"
+#endif
+
+struct CBenchInfo2 : public CBenchInfo
+{
+ void Init() { GlobalTime = UserTime = 0; }
+};
+
+class CProgressSyncInfo
+{
+public:
+ bool Stopped;
+ bool Paused;
+ bool Changed;
+ UInt32 DictionarySize;
+ UInt32 NumThreads;
+ UInt64 NumPasses;
+ // UInt64 NumErrors;
+ NWindows::NSynchronization::CManualResetEvent _startEvent;
+ NWindows::NSynchronization::CCriticalSection CS;
+
+ CBenchInfo2 CompressingInfoTemp;
+ CBenchInfo2 CompressingInfo;
+ UInt64 ProcessedSize;
+
+ CBenchInfo2 DecompressingInfoTemp;
+ CBenchInfo2 DecompressingInfo;
+
+ CProgressSyncInfo()
+ {
+ if (_startEvent.Create() != S_OK)
+ throw 3986437;
+ }
+ void Init()
+ {
+ Changed = false;
+ Stopped = false;
+ Paused = false;
+ CompressingInfoTemp.Init();
+ CompressingInfo.Init();
+ ProcessedSize = 0;
+
+ DecompressingInfoTemp.Init();
+ DecompressingInfo.Init();
+
+ NumPasses = 0;
+ // NumErrors = 0;
+ }
+ void Stop()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ Stopped = true;
+ }
+ bool WasStopped()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ return Stopped;
+ }
+ void Pause()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ Paused = true;
+ }
+ void Start()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ Paused = false;
+ }
+ bool WasPaused()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ return Paused;
+ }
+ void WaitCreating() { _startEvent.Lock(); }
+};
+
+class CBenchmarkDialog:
+ public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox m_Dictionary;
+ NWindows::NControl::CComboBox m_NumThreads;
+ UINT_PTR _timer;
+ UINT32 _startTime;
+
+ bool OnTimer(WPARAM timerID, LPARAM callback);
+ virtual bool OnInit();
+ void OnRestartButton();
+ void OnStopButton();
+ void OnHelp();
+ virtual void OnCancel();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ bool OnCommand(int code, int itemID, LPARAM lParam);
+
+ void PrintTime();
+ void PrintRating(UInt64 rating, UINT controlID);
+ void PrintUsage(UInt64 usage, UINT controlID);
+ void PrintResults(
+ UINT32 dictionarySize,
+ const CBenchInfo2 &info, UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
+ bool decompressMode = false);
+
+ UInt32 GetNumberOfThreads();
+ UInt32 OnChangeDictionary();
+ void OnChangeSettings();
+public:
+ CProgressSyncInfo _syncInfo;
+
+ CBenchmarkDialog(): _timer(0) {}
+ INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
+};
+
+HRESULT Benchmark(
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs,
+ #endif
+ UInt32 dictionarySize, UInt32 numThreads);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialogRes.h
new file mode 100644
index 000000000..6ef521881
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialogRes.h
@@ -0,0 +1,54 @@
+#define IDD_DIALOG_BENCHMARK 800
+#define IDC_BUTTON_STOP 1001
+#define IDC_BUTTON_RESTART 1002
+#define IDC_BENCHMARK_DICTIONARY 1010
+#define IDC_BENCHMARK_COMBO_DICTIONARY 1011
+#define IDC_BENCHMARK_MEMORY 1012
+#define IDC_BENCHMARK_MEMORY_VALUE 1013
+#define IDC_BENCHMARK_NUM_THREADS 1014
+#define IDC_BENCHMARK_COMBO_NUM_THREADS 1015
+#define IDC_BENCHMARK_HARDWARE_THREADS 1016
+
+#define IDC_BENCHMARK_SPEED_LABEL 1020
+#define IDC_BENCHMARK_RATING_LABEL 1021
+#define IDC_BENCHMARK_COMPRESSING 1022
+#define IDC_BENCHMARK_DECOMPRESSING 1023
+#define IDC_BENCHMARK_CURRENT 1024
+#define IDC_BENCHMARK_RESULTING 1025
+#define IDC_BENCHMARK_CURRENT2 1026
+#define IDC_BENCHMARK_RESULTING2 1027
+#define IDC_BENCHMARK_USAGE_LABEL 1028
+#define IDC_BENCHMARK_RPU_LABEL 1029
+
+#define IDC_BENCHMARK_COMPRESSING_SPEED 1030
+#define IDC_BENCHMARK_COMPRESSING_SPEED2 1031
+#define IDC_BENCHMARK_COMPRESSING_RATING 1032
+#define IDC_BENCHMARK_COMPRESSING_RATING2 1033
+#define IDC_BENCHMARK_COMPRESSING_USAGE 1034
+#define IDC_BENCHMARK_COMPRESSING_USAGE2 1035
+#define IDC_BENCHMARK_COMPRESSING_RPU 1036
+#define IDC_BENCHMARK_COMPRESSING_RPU2 1037
+
+
+#define IDC_BENCHMARK_DECOMPRESSING_SPEED 1040
+#define IDC_BENCHMARK_DECOMPRESSING_SPEED2 1041
+#define IDC_BENCHMARK_DECOMPRESSING_RATING 1042
+#define IDC_BENCHMARK_DECOMPRESSING_RATING2 1043
+#define IDC_BENCHMARK_DECOMPRESSING_USAGE 1044
+#define IDC_BENCHMARK_DECOMPRESSING_USAGE2 1045
+#define IDC_BENCHMARK_DECOMPRESSING_RPU 1046
+#define IDC_BENCHMARK_DECOMPRESSING_RPU2 1047
+
+
+#define IDC_BENCHMARK_TOTAL_RATING 1050
+
+#define IDC_BENCHMARK_TOTAL_RATING_VALUE 1051
+#define IDC_BENCHMARK_TOTAL_RPU_VALUE 1052
+#define IDC_BENCHMARK_TOTAL_USAGE_VALUE 1053
+
+#define IDC_BENCHMARK_ELAPSED 1060
+#define IDC_BENCHMARK_ELAPSED_VALUE 1061
+#define IDC_BENCHMARK_SIZE 1062
+#define IDC_BENCHMARK_SIZE_VALUE 1063
+#define IDC_BENCHMARK_PASSES 1066
+#define IDC_BENCHMARK_PASSES_VALUE 1067
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog_rc.cpp
new file mode 100644
index 000000000..ae6b26f2c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog_rc.cpp
@@ -0,0 +1,245 @@
+// BenchmarkDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "Windows/Control/DialogImpl.h"
+#include "BenchmarkDialogRes.h"
+
+#if 0
+
+
+IDD_DIALOG_BENCHMARK DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
+CAPTION "Benchmark"
+MY_FONT
+BEGIN
+OK PUSHBUTTON "&Restart", IDC_BUTTON_RESTART, bXPos1, marg, bXSize, bYSize
+OK PUSHBUTTON "&Stop", IDC_BUTTON_STOP, bXPos1, 27, bXSize, bYSize
+
+ PUSHBUTTON "&Help", IDHELP, bXPos2, bYPos, bXSize,bYSize
+ PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize
+
+OK LTEXT "&Dictionary size:", IDC_BENCHMARK_DICTIONARY, marg, marg + 1, g0XSize, 8
+OK COMBOBOX IDC_BENCHMARK_COMBO_DICTIONARY, g1XPos, marg, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+
+ LTEXT "&Number of CPU threads:", IDC_BENCHMARK_NUM_THREADS, marg, 24, g0XSize, 8
+ COMBOBOX IDC_BENCHMARK_COMBO_NUM_THREADS, g1XPos, 23, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+
+ LTEXT "Memory usage:", IDC_BENCHMARK_MEMORY, gc2XPos, marg + 1, gc2XSize, 8
+ LTEXT "0 MB", IDC_BENCHMARK_MEMORY_VALUE, gc2XPos + gc2XSize, marg + 1, 40, 8
+ LTEXT "1", IDC_BENCHMARK_HARDWARE_THREADS, gc2XPos, 24, 40, 8
+
+ RTEXT "CPU Usage", IDC_BENCHMARK_USAGE_LABEL, gUsagePos, 53, gUsageSize, 8
+ RTEXT "Speed", IDC_BENCHMARK_SPEED_LABEL, gSpeedPos, 53, gSpeedSize, 8
+ RTEXT "Rating / Usage", IDC_BENCHMARK_RPU_LABEL, gRpuPos, 53, gRpuSize, 8
+ RTEXT "Rating", IDC_BENCHMARK_RATING_LABEL, gRatingPos, 53, gRatingSize, 8
+
+ GROUPBOX "Compressing", IDC_BENCHMARK_COMPRESSING, marg, 64, xSize2, 40
+
+ LTEXT "Current", IDC_BENCHMARK_CURRENT, g10XPos, 76, gLabelSize, 8
+ RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE, gUsagePos, 76, gUsageSize, 8
+ RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED, gSpeedPos, 76, gSpeedSize, 8
+ RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU, gRpuPos, 76, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING, gRatingPos, 76, gRatingSize, 8
+
+ LTEXT "Resulting", IDC_BENCHMARK_RESULTING, g10XPos, 89, gLabelSize, 8
+ RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE2, gUsagePos, 89, gUsageSize, 8
+ RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED2, gSpeedPos, 89, gSpeedSize, 8
+ RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU2, gRpuPos, 89, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING2, gRatingPos, 89, gRatingSize, 8
+
+ GROUPBOX "Decompressing", IDC_BENCHMARK_DECOMPRESSING, marg, 111, xSize2, 40
+
+ LTEXT "Current", IDC_BENCHMARK_CURRENT2, g10XPos, 123, gLabelSize, 8
+ RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE, gUsagePos, 123, gUsageSize, 8
+ RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED, gSpeedPos, 123, gSpeedSize, 8
+ RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU, gRpuPos, 123, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING, gRatingPos, 123, gRatingSize, 8
+
+ LTEXT "Resulting", IDC_BENCHMARK_RESULTING2, g10XPos, 136, gLabelSize, 8
+ RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE2, gUsagePos, 136, gUsageSize, 8
+ RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED2, gSpeedPos, 136, gSpeedSize, 8
+ RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU2, gRpuPos, 136, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING2, gRatingPos, 136, gRatingSize, 8
+
+ GROUPBOX "Total Rating", IDC_BENCHMARK_TOTAL_RATING, gTotalRatingPos, 163, gTotalRatingSize, 38
+ RTEXT "0", IDC_BENCHMARK_TOTAL_USAGE_VALUE, gUsagePos, 181, gUsageSize, 8
+ RTEXT "0", IDC_BENCHMARK_TOTAL_RPU_VALUE, gRpuPos, 181, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_TOTAL_RATING_VALUE, gRatingPos, 181, gRatingSize, 8
+
+ LTEXT "Elapsed time:", IDC_BENCHMARK_ELAPSED, marg, 163, g2XSize, 8
+ LTEXT "Size:", IDC_BENCHMARK_SIZE, marg, 176, g2XSize, 8
+ LTEXT "Passes:", IDC_BENCHMARK_PASSES, marg, 189, g2XSize, 8
+ RTEXT "00:00:00", IDC_BENCHMARK_ELAPSED_VALUE, g3XPos, 163, g3XSize, 8
+ RTEXT "0", IDC_BENCHMARK_SIZE_VALUE, g3XPos, 176, g3XSize, 8
+ RTEXT "0", IDC_BENCHMARK_PASSES_VALUE, g3XPos, 189, g3XSize, 8
+END
+#endif // #if 0
+
+class CBenchmarkDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CBenchmarkDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Benchmark"))
+ {
+
+ wxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
+
+ wxSizer *sizerLine1 = new wxBoxSizer(wxHORIZONTAL);
+
+ wxSizer *sizeLine1Btn = new wxBoxSizer(wxVERTICAL);
+ sizeLine1Btn->Add(new wxButton(this, IDC_BUTTON_RESTART, _T("&Restart")) , 0, wxALL|wxEXPAND, 5 );
+ sizeLine1Btn->Add(new wxButton(this, IDC_BUTTON_STOP, _T("&Stop")) , 0, wxALL|wxEXPAND, 5 );
+
+ wxSizer *sizeLine1Combo = new wxBoxSizer(wxVERTICAL);
+
+ wxComboBox * chcDicoSize = new wxComboBox(this, IDC_BENCHMARK_COMBO_DICTIONARY,
+ wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+ wxComboBox * chcThread = new wxComboBox(this, IDC_BENCHMARK_COMBO_NUM_THREADS,
+ wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+ sizeLine1Combo->Add(chcDicoSize , 0, wxALL, 5 );
+ sizeLine1Combo->Add(chcThread , 0, wxALL, 5 );
+
+ wxSizer *sizeLine1ComboLabel = new wxBoxSizer(wxVERTICAL);
+ sizeLine1ComboLabel->Add(new wxStaticText(this, IDC_BENCHMARK_DICTIONARY, _T("&Dictionary size:")) , 1, wxALL|wxEXPAND, 5 );
+ sizeLine1ComboLabel->Add(new wxStaticText(this, IDC_BENCHMARK_NUM_THREADS, _T("&Number of CPU threads:")) , 1, wxALL|wxEXPAND, 5 );
+
+ wxSizer *sizeLine1Col3 = new wxBoxSizer(wxVERTICAL);
+ sizeLine1Col3->Add(new wxStaticText(this, IDC_BENCHMARK_MEMORY, _T("Memory usage:")) , 1, wxALL|wxEXPAND, 5 );
+ sizeLine1Col3->Add(new wxStaticText(this, IDC_BENCHMARK_HARDWARE_THREADS, _T("1")) , 1, wxALL|wxEXPAND, 5 );
+
+ wxSizer *sizeLine1Col4 = new wxBoxSizer(wxVERTICAL);
+ sizeLine1Col4->Add(new wxStaticText(this, IDC_BENCHMARK_MEMORY_VALUE, _T("0 MB")) , 0, wxALL|wxEXPAND, 5 );
+
+ sizerLine1->Add(sizeLine1ComboLabel,0, wxALL|wxEXPAND, 5);
+ sizerLine1->Add(sizeLine1Combo,0, wxALL|wxEXPAND, 5);
+ sizerLine1->Add(sizeLine1Col3,0, wxALL|wxEXPAND, 5);
+ sizerLine1->Add(sizeLine1Col4,0, wxALL|wxEXPAND, 5);
+ sizerLine1->Add(sizeLine1Btn,0, wxALL|wxEXPAND, 5);
+
+ // LABEL (copy the structure of the compressing or decompressing group
+
+ wxStaticBoxSizer * sizerLine2 = new wxStaticBoxSizer(new wxStaticBox(this,wxID_ANY,_T("")),wxVERTICAL);
+ wxSizer *sizerLabel = new wxBoxSizer(wxHORIZONTAL);
+ sizerLabel->Add(new wxStaticText(this, wxID_ANY, _T(" ")) , 1, wxALL|wxEXPAND, 5 );
+ sizerLabel->Add(new wxStaticText(this, IDC_BENCHMARK_SPEED_LABEL, _T("Speed")) , 1, wxALL|wxEXPAND, 5 );
+ sizerLabel->Add(new wxStaticText(this, IDC_BENCHMARK_USAGE_LABEL, _T("CPU Usage")) , 1, wxALL|wxEXPAND, 5 );
+ sizerLabel->Add(new wxStaticText(this, IDC_BENCHMARK_RPU_LABEL, _T("Rating / Usage")), 1, wxALL|wxEXPAND, 5 );
+ sizerLabel->Add(new wxStaticText(this, IDC_BENCHMARK_RATING_LABEL, _T("Rating")) , 1, wxALL|wxEXPAND, 5 );
+
+ sizerLine2->Add(sizerLabel, 0, wxALL|wxEXPAND, 5);
+
+ // GROUP COMPRESSING
+
+ wxStaticBoxSizer * grpCompress = new wxStaticBoxSizer(new wxStaticBox(this,IDC_BENCHMARK_COMPRESSING,_T("Compressing")),wxVERTICAL);
+ wxSizer *grpCompress1 = new wxBoxSizer(wxHORIZONTAL);
+ grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_CURRENT, _T("Current")) , 1, wxALL|wxEXPAND, 5 );
+ grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_SPEED, _T("100 KB/s")) , 1, wxALL|wxEXPAND, 5 );
+ grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_USAGE, _T("100%")) , 1, wxALL|wxEXPAND, 5 );
+ grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_RPU, _T("0")), 1, wxALL|wxEXPAND, 5 );
+ grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_RATING, _T("0")) , 1, wxALL|wxEXPAND, 5 );
+
+ wxSizer *grpCompress2 = new wxBoxSizer(wxHORIZONTAL);
+ grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_RESULTING, _T("Resulting")) , 1, wxALL|wxEXPAND, 5 );
+ grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_SPEED2, _T("100 KB/s")) , 1, wxALL|wxEXPAND, 5 );
+ grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_USAGE2, _T("100%")) , 1, wxALL|wxEXPAND, 5 );
+ grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_RPU2, _T("0")) , 1, wxALL|wxEXPAND, 5);
+ grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_RATING2, _T("0")) , 1, wxALL|wxEXPAND, 5 );
+
+ grpCompress->Add(grpCompress1, 0, wxALL|wxEXPAND, 5);
+ grpCompress->Add(grpCompress2, 0, wxALL|wxEXPAND, 5);
+
+ // GROUP DECOMPRESSING
+
+ wxStaticBoxSizer * grpDecompress = new wxStaticBoxSizer(new wxStaticBox(this,IDC_BENCHMARK_DECOMPRESSING,_T("Decompressing")),wxVERTICAL);
+ wxSizer *grpDecompress1 = new wxBoxSizer(wxHORIZONTAL);
+ grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_CURRENT2, _T("Current")) , 1, wxALL|wxEXPAND, 5 );
+ grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_SPEED, _T("100 KB/s")) , 1, wxALL|wxEXPAND, 5 );
+ grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_USAGE, _T("100%")) , 1, wxALL|wxEXPAND, 5 );
+ grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_RPU, _T("0")), 1, wxALL|wxEXPAND, 5 );
+ grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_RATING, _T("0")) , 1, wxALL|wxEXPAND, 5 );
+
+ wxSizer *grpDecompress2 = new wxBoxSizer(wxHORIZONTAL);
+ grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_RESULTING2, _T("Resulting")) , 1, wxALL|wxEXPAND, 5 );
+ grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_SPEED2, _T("100 KB/s")) , 1, wxALL|wxEXPAND, 5 );
+ grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_USAGE2, _T("100%")) , 1, wxALL|wxEXPAND, 5 );
+ grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_RPU2, _T("0")) , 1, wxALL|wxEXPAND, 5);
+ grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_RATING2, _T("0")) , 1, wxALL|wxEXPAND, 5 );
+
+ grpDecompress->Add(grpDecompress1, 0, wxALL|wxEXPAND, 5);
+ grpDecompress->Add(grpDecompress2, 0, wxALL|wxEXPAND, 5);
+
+ // GROUPE TOTAL RATING
+ wxStaticBoxSizer * grpTotalRating = new wxStaticBoxSizer(new wxStaticBox(this,IDC_BENCHMARK_TOTAL_RATING,_T("Total Rating")),wxHORIZONTAL);
+ grpTotalRating->Add(new wxStaticText(this, wxID_ANY, _T("")) , 1, wxALL|wxEXPAND, 5 );
+ grpTotalRating->Add(new wxStaticText(this, IDC_BENCHMARK_TOTAL_USAGE_VALUE, _T("0")) , 1, wxALL|wxEXPAND, 5 );
+ grpTotalRating->Add(new wxStaticText(this, IDC_BENCHMARK_TOTAL_RPU_VALUE, _T("0")) , 1, wxALL|wxEXPAND, 5 );
+ grpTotalRating->Add(new wxStaticText(this, IDC_BENCHMARK_TOTAL_RATING_VALUE, _T("0")) , 1, wxALL|wxEXPAND, 5 );
+
+ // GROUPE ELAPSED TIME
+ wxSizer * grpElapsedTime = new wxBoxSizer(wxHORIZONTAL);
+
+ wxSizer * grpElapsedTime1 = new wxBoxSizer(wxVERTICAL);
+ grpElapsedTime1->Add(new wxStaticText(this, IDC_BENCHMARK_ELAPSED, _T("Elapsed time:")) , 0, wxALL|wxEXPAND, 5 );
+ grpElapsedTime1->Add(new wxStaticText(this, IDC_BENCHMARK_SIZE, _T("Size:")) , 0, wxALL|wxEXPAND, 5 );
+ grpElapsedTime1->Add(new wxStaticText(this, IDC_BENCHMARK_PASSES, _T("Passes:")) , 0, wxALL|wxEXPAND, 5 );
+
+ wxSizer * grpElapsedTime2 = new wxBoxSizer(wxVERTICAL);
+ grpElapsedTime2->Add(new wxStaticText(this, IDC_BENCHMARK_ELAPSED_VALUE, _T("00:00:00")) , 0, wxALL|wxEXPAND, 5 );
+ grpElapsedTime2->Add(new wxStaticText(this, IDC_BENCHMARK_SIZE_VALUE, _T("0")) , 0, wxALL|wxEXPAND, 5 );
+ grpElapsedTime2->Add(new wxStaticText(this, IDC_BENCHMARK_PASSES_VALUE, _T("0")) , 0, wxALL|wxEXPAND, 5 );
+
+ grpElapsedTime->Add(grpElapsedTime1,0, wxALL|wxEXPAND, 5);
+ grpElapsedTime->Add(grpElapsedTime2,0, wxALL|wxEXPAND, 5);
+
+ wxSizer * grp_ElapsedTime_TotalRating = new wxBoxSizer(wxHORIZONTAL);
+ grp_ElapsedTime_TotalRating->Add(grpElapsedTime, 0, wxALL|wxEXPAND, 5);
+ grp_ElapsedTime_TotalRating->Add(grpTotalRating, 1, wxALL|wxEXPAND, 5);
+
+ // TOP
+ topsizer->Add(sizerLine1,0, wxALL|wxEXPAND, 5);
+ topsizer->Add(sizerLine2,0, wxALL|wxEXPAND, 5);
+ topsizer->Add(grpCompress, 0, wxALL|wxEXPAND, 5);
+ topsizer->Add(grpDecompress, 0, wxALL|wxEXPAND, 5);
+ topsizer->Add(grp_ElapsedTime_TotalRating, 0, wxALL|wxEXPAND, 5);
+
+ topsizer->Add(CreateButtonSizer(wxHELP|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+REGISTER_DIALOG(IDD_DIALOG_BENCHMARK,CBenchmarkDialog,0)
+
+// ----------------------------------------------------------------------------
+// event tables and other macros for wxWidgets
+// ----------------------------------------------------------------------------
+
+// the event tables connect the wxWidgets events with the functions (event
+// handlers) which process them. It can be also done at run-time, but for the
+// simple menu events like this the static method is much simpler.
+BEGIN_EVENT_TABLE(CBenchmarkDialogImpl, wxDialog)
+ EVT_TIMER(wxID_ANY, CModalDialogImpl::OnAnyTimer)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_COMBOBOX(wxID_ANY, CModalDialogImpl::OnAnyChoice)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.cpp
new file mode 100644
index 000000000..04a40a437
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.cpp
@@ -0,0 +1,1455 @@
+// CompressDialog.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Defs.h"
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/CommonDialog.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+#include "Windows/ResourceString.h"
+#include "Windows/System.h"
+
+#include "../FileManager/FormatUtils.h"
+#include "../FileManager/HelpUtils.h"
+#include "../FileManager/SplitUtils.h"
+
+#include "../Explorer/MyMessages.h"
+
+#include "../Common/ZipRegistry.h"
+
+#include "CompressDialog.h"
+
+#include "resource.h"
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+#ifdef LANG
+#include "../FileManager/LangUtils.h"
+#endif
+
+#include "CompressDialogRes.h"
+
+#define MY_SIZE_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_COMPRESS_ARCHIVE, 0x02000D01 },
+ { IDC_STATIC_COMPRESS_FORMAT, 0x02000D03 },
+ { IDC_STATIC_COMPRESS_LEVEL, 0x02000D0B },
+ { IDC_STATIC_COMPRESS_METHOD, 0x02000D04 },
+ { IDC_STATIC_COMPRESS_DICTIONARY, 0x02000D0C },
+ { IDC_STATIC_COMPRESS_ORDER, 0x02000D0D },
+ { IDC_STATIC_COMPRESS_MEMORY, 0x02000D0E },
+ { IDC_STATIC_COMPRESS_MEMORY_DE, 0x02000D0F },
+ { IDC_STATIC_COMPRESS_THREADS, 0x02000D12 },
+ { IDC_STATIC_COMPRESS_SOLID, 0x02000D13 },
+ { IDC_STATIC_COMPRESS_VOLUME, 0x02000D40 },
+ { IDC_STATIC_COMPRESS_PARAMETERS, 0x02000D06 },
+
+ { IDC_STATIC_COMPRESS_UPDATE_MODE, 0x02000D02 },
+ { IDC_STATIC_COMPRESS_OPTIONS, 0x02000D07 },
+ { IDC_COMPRESS_SFX, 0x02000D08 },
+ { IDC_COMPRESS_SHARED, 0x02000D16 },
+
+ { IDC_COMPRESS_ENCRYPTION, 0x02000D10 },
+ { IDC_STATIC_COMPRESS_PASSWORD1, 0x02000B01 },
+ { IDC_STATIC_COMPRESS_PASSWORD2, 0x02000B03 },
+ { IDC_COMPRESS_CHECK_SHOW_PASSWORD, 0x02000B02 },
+ { IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, 0x02000D11 },
+ { IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, 0x02000D0A },
+
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 },
+ { IDHELP, 0x02000720 }
+};
+#endif
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NName;
+using namespace NDirectory;
+
+static const int kHistorySize = 20;
+
+static LPCWSTR kExeExt = L".exe";
+static LPCWSTR k7zFormat = L"7z";
+
+struct CLevelInfo
+{
+ UInt32 ResourceID;
+ UInt32 LangID;
+};
+
+enum ELevel
+{
+ kStore = 0,
+ kFastest = 1,
+ kFast = 3,
+ kNormal = 5,
+ kMaximum = 7,
+ kUltra = 9
+};
+
+static const CLevelInfo g_Levels[] =
+{
+ { IDS_METHOD_STORE, 0x02000D81 },
+ { IDS_METHOD_FASTEST, 0x02000D85 },
+ { 0, 0 },
+ { IDS_METHOD_FAST, 0x02000D84 },
+ { 0, 0 },
+ { IDS_METHOD_NORMAL, 0x02000D82 },
+ { 0, 0 },
+ { IDS_METHOD_MAXIMUM, 0x02000D83 },
+ { 0, 0 },
+ { IDS_METHOD_ULTRA, 0x02000D86 }
+};
+
+enum EMethodID
+{
+ kCopy,
+ kLZMA,
+ kLZMA2,
+ kPPMd,
+ kBZip2,
+ kDeflate,
+ kDeflate64
+};
+
+static const LPCWSTR kMethodsNames[] =
+{
+ L"Copy",
+ L"LZMA",
+ L"LZMA2",
+ L"PPMd",
+ L"BZip2",
+ L"Deflate",
+ L"Deflate64"
+};
+
+static const EMethodID g_7zMethods[] =
+{
+ kLZMA,
+ kLZMA2,
+ kPPMd,
+ kBZip2
+};
+
+static const EMethodID g_7zSfxMethods[] =
+{
+ kCopy,
+ kLZMA,
+ kLZMA2,
+ kPPMd
+};
+
+static EMethodID g_ZipMethods[] =
+{
+ kDeflate,
+ kDeflate64,
+ kBZip2,
+ kLZMA
+};
+
+static EMethodID g_GZipMethods[] =
+{
+ kDeflate
+};
+
+static EMethodID g_BZip2Methods[] =
+{
+ kBZip2
+};
+
+static EMethodID g_XzMethods[] =
+{
+ kLZMA2
+};
+
+struct CFormatInfo
+{
+ LPCWSTR Name;
+ UInt32 LevelsMask;
+ const EMethodID *MathodIDs;
+ int NumMethods;
+ bool Filter;
+ bool Solid;
+ bool MultiThread;
+ bool SFX;
+ bool Encrypt;
+ bool EncryptFileNames;
+};
+
+#define METHODS_PAIR(x) x, MY_SIZE_OF_ARRAY(x)
+
+static const CFormatInfo g_Formats[] =
+{
+ {
+ L"",
+ (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
+ 0, 0,
+ false, false, false, false, false, false
+ },
+ {
+ k7zFormat,
+ (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
+ METHODS_PAIR(g_7zMethods),
+ true, true, true, true, true, true
+ },
+ {
+ L"Zip",
+ (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
+ METHODS_PAIR(g_ZipMethods),
+ false, false, true, false, true, false
+ },
+ {
+ L"GZip",
+ (1 << 1) | (1 << 5) | (1 << 7) | (1 << 9),
+ METHODS_PAIR(g_GZipMethods),
+ false, false, false, false, false, false
+ },
+ {
+ L"BZip2",
+ (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
+ METHODS_PAIR(g_BZip2Methods),
+ false, false, true, false, false, false
+ },
+ {
+ L"xz",
+ (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
+ METHODS_PAIR(g_XzMethods),
+ false, false, true, false, false, false
+ },
+ {
+ L"Tar",
+ (1 << 0),
+ 0, 0,
+ false, false, false, false, false, false
+ }
+};
+
+static bool IsMethodSupportedBySfx(int methodID)
+{
+ for (int i = 0; i < MY_SIZE_OF_ARRAY(g_7zSfxMethods); i++)
+ if (methodID == g_7zSfxMethods[i])
+ return true;
+ return false;
+};
+
+static UInt64 GetMaxRamSizeForProgram()
+{
+ UInt64 physSize = NSystem::GetRamSize();
+ const UInt64 kMinSysSize = (1 << 24);
+ if (physSize <= kMinSysSize)
+ physSize = 0;
+ else
+ physSize -= kMinSysSize;
+ const UInt64 kMinUseSize = (1 << 25);
+ if (physSize < kMinUseSize)
+ physSize = kMinUseSize;
+ return physSize;
+}
+
+bool CCompressDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000D00);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, MY_SIZE_OF_ARRAY(kIDLangPairs) );
+ #endif
+ _password1Control.Attach(GetItem(IDC_COMPRESS_EDIT_PASSWORD1));
+ _password2Control.Attach(GetItem(IDC_COMPRESS_EDIT_PASSWORD2));
+ _password1Control.SetText(Info.Password);
+ _password2Control.SetText(Info.Password);
+ _encryptionMethod.Attach(GetItem(IDC_COMPRESS_COMBO_ENCRYPTION_METHOD));
+
+ m_ArchivePath.Attach(GetItem(IDC_COMPRESS_COMBO_ARCHIVE));
+ m_Format.Attach(GetItem(IDC_COMPRESS_COMBO_FORMAT));
+ m_Level.Attach(GetItem(IDC_COMPRESS_COMBO_LEVEL));
+ m_Method.Attach(GetItem(IDC_COMPRESS_COMBO_METHOD));
+ m_Dictionary.Attach(GetItem(IDC_COMPRESS_COMBO_DICTIONARY));
+ m_Order.Attach(GetItem(IDC_COMPRESS_COMBO_ORDER));
+ m_Solid.Attach(GetItem(IDC_COMPRESS_COMBO_SOLID));
+ m_NumThreads.Attach(GetItem(IDC_COMPRESS_COMBO_THREADS));
+
+ m_UpdateMode.Attach(GetItem(IDC_COMPRESS_COMBO_UPDATE_MODE));
+ m_Volume.Attach(GetItem(IDC_COMPRESS_COMBO_VOLUME));
+ m_Params.Attach(GetItem(IDC_COMPRESS_EDIT_PARAMETERS));
+
+ AddVolumeItems(m_Volume);
+
+ ReadCompressionInfo(m_RegistryInfo);
+ CheckButton(IDC_COMPRESS_CHECK_SHOW_PASSWORD, m_RegistryInfo.ShowPassword);
+ CheckButton(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, m_RegistryInfo.EncryptHeaders);
+
+ UpdatePasswordControl();
+
+ Info.ArchiverInfoIndex = 0;
+ int i;
+ for (i = 0; i < m_ArchiverInfoList.Size(); i++)
+ {
+ const CArcInfoEx &ai = m_ArchiverInfoList[i];
+ int index = (int)m_Format.AddString(ai.Name);
+ m_Format.SetItemData(index, i);
+ if (ai.Name.CompareNoCase(m_RegistryInfo.ArchiveType) == 0 || i == 0)
+ {
+ m_Format.SetCurSel(index);
+ Info.ArchiverInfoIndex = i;
+ }
+ }
+
+ SetArchiveName(Info.ArchiveName);
+ SetLevel();
+ SetParams();
+
+ for (i = 0; i < m_RegistryInfo.HistoryArchives.Size() && i < kHistorySize; i++)
+ m_ArchivePath.AddString(m_RegistryInfo.HistoryArchives[i]);
+
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_ADD, 0x02000DA1));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_UPDATE, 0x02000DA2));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_FRESH, 0x02000DA3));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE, 0x02000DA4));
+
+ m_UpdateMode.SetCurSel(0);
+
+ SetSolidBlockSize();
+ SetNumThreads();
+
+ TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 };
+ ConvertUInt32ToString(NSystem::GetNumberOfProcessors(), s + 2);
+ SetItemText(IDC_COMPRESS_HARDWARE_THREADS, s);
+
+ CheckButton(IDC_COMPRESS_SFX, Info.SFXMode);
+ CheckButton(IDC_COMPRESS_SHARED, Info.OpenShareForWrite);
+
+ CheckControlsEnable();
+
+ OnButtonSFX();
+
+ SetEncryptionMethod();
+ SetMemoryUsage();
+ return CModalDialog::OnInit();
+}
+
+namespace NCompressDialog
+{
+ bool CInfo::GetFullPathName(UString &result) const
+ {
+ NDirectory::MySetCurrentDirectory(CurrentDirPrefix);
+ return MyGetFullPathName(ArchiveName, result);
+ }
+}
+
+void CCompressDialog::UpdatePasswordControl()
+{
+ bool showPassword = IsShowPasswordChecked();
+ TCHAR c = showPassword ? 0: TEXT('*');
+ _password1Control.SetPasswordChar(c);
+ _password2Control.SetPasswordChar(c);
+ UString password;
+ _password1Control.GetText(password);
+ _password1Control.SetText(password);
+ _password2Control.GetText(password);
+ _password2Control.SetText(password);
+
+ int cmdShow = showPassword ? SW_HIDE : SW_SHOW;
+ ShowItem(IDC_STATIC_COMPRESS_PASSWORD2, cmdShow);
+ _password2Control.Show(cmdShow);
+}
+
+bool CCompressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_COMPRESS_BUTTON_SET_ARCHIVE:
+ {
+ OnButtonSetArchive();
+ return true;
+ }
+ case IDC_COMPRESS_SFX:
+ {
+ OnButtonSFX();
+ SetMemoryUsage();
+ return true;
+ }
+ case IDC_COMPRESS_CHECK_SHOW_PASSWORD:
+ {
+ UpdatePasswordControl();
+ return true;
+ }
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CCompressDialog::CheckSFXControlsEnable()
+{
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ bool enable = fi.SFX;
+ if (enable)
+ {
+ int methodID = GetMethodID();
+ enable = (methodID == -1 || IsMethodSupportedBySfx(methodID));
+ }
+ if (!enable)
+ CheckButton(IDC_COMPRESS_SFX, false);
+ EnableItem(IDC_COMPRESS_SFX, enable);
+}
+
+void CCompressDialog::CheckVolumeEnable()
+{
+ bool isSFX = IsSFX();
+ m_Volume.Enable(!isSFX);
+ if (isSFX)
+ m_Volume.SetText(TEXT(""));
+}
+
+void CCompressDialog::CheckControlsEnable()
+{
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ Info.SolidIsSpecified = fi.Solid;
+ bool multiThreadEnable = fi.MultiThread;
+ Info.MultiThreadIsAllowed = multiThreadEnable;
+ Info.EncryptHeadersIsAllowed = fi.EncryptFileNames;
+
+ EnableItem(IDC_COMPRESS_COMBO_SOLID, fi.Solid);
+ EnableItem(IDC_COMPRESS_COMBO_THREADS, multiThreadEnable);
+ CheckSFXControlsEnable();
+ CheckVolumeEnable();
+
+ EnableItem(IDC_COMPRESS_ENCRYPTION, fi.Encrypt);
+
+ EnableItem(IDC_STATIC_COMPRESS_PASSWORD1, fi.Encrypt);
+ EnableItem(IDC_STATIC_COMPRESS_PASSWORD2, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_EDIT_PASSWORD1, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_EDIT_PASSWORD2, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_CHECK_SHOW_PASSWORD, fi.Encrypt);
+
+ EnableItem(IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames);
+
+ ShowItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames ? SW_SHOW : SW_HIDE);
+}
+
+bool CCompressDialog::IsSFX()
+{
+ CWindow sfxButton = GetItem(IDC_COMPRESS_SFX);
+ return sfxButton.IsEnabled() && IsButtonCheckedBool(IDC_COMPRESS_SFX);
+}
+
+void CCompressDialog::OnButtonSFX()
+{
+ SetMethod(GetMethodID());
+
+ UString fileName;
+ m_ArchivePath.GetText(fileName);
+ int dotPos = fileName.ReverseFind(L'.');
+ int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (dotPos < 0 || dotPos <= slashPos)
+ dotPos = -1;
+ if (IsSFX())
+ {
+ if (dotPos >= 0)
+ fileName = fileName.Left(dotPos);
+ fileName += kExeExt;
+ m_ArchivePath.SetText(fileName);
+ }
+ else
+ {
+ if (dotPos >= 0)
+ {
+ UString ext = fileName.Mid(dotPos);
+ if (ext.CompareNoCase(kExeExt) == 0)
+ {
+ fileName = fileName.Left(dotPos);
+ m_ArchivePath.SetText(fileName);
+ }
+ }
+ SetArchiveName2(false); // it's for OnInit
+ }
+
+ CheckVolumeEnable();
+}
+
+void CCompressDialog::OnButtonSetArchive()
+{
+ UString fileName;
+ m_ArchivePath.GetText(fileName);
+ fileName.Trim();
+ Info.ArchiveName = fileName;
+ UString fullFileName;
+ if (!Info.GetFullPathName(fullFileName))
+ {
+ fullFileName = Info.ArchiveName;
+ return;
+ }
+ UString title = LangString(IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, 0x02000D90);
+ UString s = LangString(IDS_OPEN_TYPE_ALL_FILES, 0x02000DB1);
+ s += L" (*.*)";
+ UString resPath;
+ if (!MyGetOpenFileName(HWND(*this), title, fullFileName, s, resPath))
+ return;
+ m_ArchivePath.SetText(resPath);
+}
+
+// in ExtractDialog.cpp
+extern void AddUniqueString(UStringVector &strings, const UString &srcString);
+
+static bool IsAsciiString(const UString &s)
+{
+ for (int i = 0; i < s.Length(); i++)
+ {
+ wchar_t c = s[i];
+ if (c < 0x20 || c > 0x7F)
+ return false;
+ }
+ return true;
+}
+
+void CCompressDialog::OnOK()
+{
+ _password1Control.GetText(Info.Password);
+ if (IsZipFormat())
+ {
+ if (!IsAsciiString(Info.Password))
+ {
+ ShowErrorMessageHwndRes(*this, IDS_PASSWORD_USE_ASCII, 0x02000B11);
+ return;
+ }
+ UString method = GetEncryptionMethodSpec();
+ method.MakeUpper();
+ if (method.Find(L"AES") == 0)
+ {
+ if (Info.Password.Length() > 99)
+ {
+ ShowErrorMessageHwndRes(*this, IDS_PASSWORD_IS_TOO_LONG, 0x02000B12);
+ return;
+ }
+ }
+ }
+ if (!IsShowPasswordChecked())
+ {
+ UString password2;
+ _password2Control.GetText(password2);
+ if (password2 != Info.Password)
+ {
+ ShowErrorMessageHwndRes(*this, IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH, 0x02000B10);
+ return;
+ }
+ }
+
+ SaveOptionsInMem();
+ UString s;
+ m_ArchivePath.GetText(s);
+ s.Trim();
+ m_RegistryInfo.HistoryArchives.Clear();
+ AddUniqueString(m_RegistryInfo.HistoryArchives, s);
+ Info.ArchiveName = s;
+ Info.UpdateMode = NCompressDialog::NUpdateMode::EEnum(m_UpdateMode.GetCurSel());
+
+ Info.Level = GetLevelSpec();
+ Info.Dictionary = GetDictionarySpec();
+ Info.Order = GetOrderSpec();
+ Info.OrderMode = GetOrderMode();
+ Info.NumThreads = GetNumThreadsSpec();
+
+ UInt32 solidLogSize = GetBlockSizeSpec();
+ Info.SolidBlockSize = 0;
+ if (solidLogSize > 0 && solidLogSize != (UInt32)-1)
+ Info.SolidBlockSize = (solidLogSize >= 64) ? (UInt64)(Int64)-1 : ((UInt64)1 << solidLogSize);
+
+ Info.Method = GetMethodSpec();
+ Info.EncryptionMethod = GetEncryptionMethodSpec();
+ Info.ArchiverInfoIndex = GetFormatIndex();
+ Info.SFXMode = IsSFX();
+ Info.OpenShareForWrite = IsButtonCheckedBool(IDC_COMPRESS_SHARED);
+
+ m_RegistryInfo.EncryptHeaders = Info.EncryptHeaders = IsButtonCheckedBool(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES);
+
+ m_Params.GetText(Info.Options);
+ UString volumeString;
+ m_Volume.GetText(volumeString);
+ volumeString.Trim();
+ Info.VolumeSizes.Clear();
+ if (!volumeString.IsEmpty())
+ {
+ if (!ParseVolumeSizes(volumeString, Info.VolumeSizes))
+ {
+ ShowErrorMessageHwndRes(*this, IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41);
+ return;
+ }
+ if (!Info.VolumeSizes.IsEmpty())
+ {
+ const UInt64 volumeSize = Info.VolumeSizes.Back();
+ if (volumeSize < (100 << 10))
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString(volumeSize, s);
+ if (::MessageBoxW(*this, MyFormatNew(IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, 0x02000D42, s),
+ L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES)
+ return;
+ }
+ }
+ }
+
+ for (int i = 0; i < m_ArchivePath.GetCount(); i++)
+ {
+ UString sTemp;
+ m_ArchivePath.GetLBText(i, sTemp);
+ sTemp.Trim();
+ AddUniqueString(m_RegistryInfo.HistoryArchives, sTemp);
+ }
+ if (m_RegistryInfo.HistoryArchives.Size() > kHistorySize)
+ m_RegistryInfo.HistoryArchives.DeleteBack();
+
+ m_RegistryInfo.ArchiveType = m_ArchiverInfoList[Info.ArchiverInfoIndex].Name;
+ m_RegistryInfo.ShowPassword = IsShowPasswordChecked();
+
+ SaveCompressionInfo(m_RegistryInfo);
+
+ CModalDialog::OnOK();
+}
+
+static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/add.htm";
+
+void CCompressDialog::OnHelp()
+{
+ ShowHelpWindow(NULL, kHelpTopic);
+}
+
+bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
+{
+ if (code == CBN_SELCHANGE)
+ {
+ switch(itemID)
+ {
+ case IDC_COMPRESS_COMBO_FORMAT:
+ {
+ bool isSFX = IsSFX();
+ SaveOptionsInMem();
+ SetLevel();
+ SetSolidBlockSize();
+ SetNumThreads();
+ SetParams();
+ CheckControlsEnable();
+ SetArchiveName2(isSFX);
+ SetEncryptionMethod();
+ SetMemoryUsage();
+ return true;
+ }
+ case IDC_COMPRESS_COMBO_LEVEL:
+ {
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ int index = FindRegistryFormatAlways(ai.Name);
+ NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ fo.ResetForLevelChange();
+ SetMethod();
+ SetSolidBlockSize();
+ SetNumThreads();
+ CheckSFXNameChange();
+ SetMemoryUsage();
+ return true;
+ }
+ case IDC_COMPRESS_COMBO_METHOD:
+ {
+ SetDictionary();
+ SetOrder();
+ SetSolidBlockSize();
+ SetNumThreads();
+ CheckSFXNameChange();
+ SetMemoryUsage();
+ return true;
+ }
+ case IDC_COMPRESS_COMBO_DICTIONARY:
+ case IDC_COMPRESS_COMBO_ORDER:
+ {
+ SetSolidBlockSize();
+ SetMemoryUsage();
+ return true;
+ }
+ case IDC_COMPRESS_COMBO_THREADS:
+ {
+ SetMemoryUsage();
+ return true;
+ }
+ }
+ }
+ return CModalDialog::OnCommand(code, itemID, lParam);
+}
+
+void CCompressDialog::CheckSFXNameChange()
+{
+ bool isSFX = IsSFX();
+ CheckSFXControlsEnable();
+ if (isSFX != IsSFX())
+ SetArchiveName2(isSFX);
+}
+
+void CCompressDialog::SetArchiveName2(bool prevWasSFX)
+{
+ UString fileName;
+ m_ArchivePath.GetText(fileName);
+ const CArcInfoEx &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat];
+ if (prevArchiverInfo.KeepName || Info.KeepName)
+ {
+ UString prevExtension = prevArchiverInfo.GetMainExt();
+ if (prevWasSFX)
+ prevExtension = kExeExt;
+ else
+ prevExtension = UString('.') + prevExtension;
+ const int prevExtensionLen = prevExtension.Length();
+ if (fileName.Length() >= prevExtensionLen)
+ if (fileName.Right(prevExtensionLen).CompareNoCase(prevExtension) == 0)
+ fileName = fileName.Left(fileName.Length() - prevExtensionLen);
+ }
+ SetArchiveName(fileName);
+}
+
+// if type.KeepName then use OriginalFileName
+// else if !KeepName remove extension
+// add new extension
+
+void CCompressDialog::SetArchiveName(const UString &name)
+{
+ UString fileName = name;
+ Info.ArchiverInfoIndex = GetFormatIndex();
+ const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
+ m_PrevFormat = Info.ArchiverInfoIndex;
+ if (ai.KeepName)
+ {
+ fileName = OriginalFileName;
+ }
+ else
+ {
+ if (!Info.KeepName)
+ {
+ int dotPos = fileName.ReverseFind('.');
+ int slashPos = MyMax(fileName.ReverseFind(WCHAR_PATH_SEPARATOR), fileName.ReverseFind('/'));
+ if (dotPos >= 0 && dotPos > slashPos + 1)
+ fileName = fileName.Left(dotPos);
+ }
+ }
+
+ if (IsSFX())
+ fileName += kExeExt;
+ else
+ {
+ fileName += L'.';
+ fileName += ai.GetMainExt();
+ }
+ m_ArchivePath.SetText(fileName);
+}
+
+int CCompressDialog::FindRegistryFormat(const UString &name)
+{
+ for (int i = 0; i < m_RegistryInfo.FormatOptionsVector.Size(); i++)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[i];
+ if (GetUnicodeString(fo.FormatID) == name)
+ return i;
+ }
+ return -1;
+}
+
+int CCompressDialog::FindRegistryFormatAlways(const UString &name)
+{
+ int index = FindRegistryFormat(name);
+ if (index < 0)
+ {
+ NCompression::CFormatOptions fo;
+ fo.FormatID = GetSystemString(name);
+ index = m_RegistryInfo.FormatOptionsVector.Add(fo);
+ }
+ return index;
+}
+
+int CCompressDialog::GetStaticFormatIndex()
+{
+ int formatIndex = GetFormatIndex();
+ const CArcInfoEx &ai = m_ArchiverInfoList[formatIndex];
+ for (int i = 0; i < MY_SIZE_OF_ARRAY(g_Formats); i++)
+ if (ai.Name.CompareNoCase(g_Formats[i].Name) == 0)
+ return i;
+ return 0; // -1;
+}
+
+void CCompressDialog::SetNearestSelectComboBox(NControl::CComboBox &comboBox, UInt32 value)
+{
+ for (int i = comboBox.GetCount() - 1; i >= 0; i--)
+ if ((UInt32)comboBox.GetItemData(i) <= value)
+ {
+ comboBox.SetCurSel(i);
+ return;
+ }
+ if (comboBox.GetCount() > 0)
+ comboBox.SetCurSel(0);
+}
+
+void CCompressDialog::SetLevel()
+{
+ m_Level.ResetContent();
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ int index = FindRegistryFormat(ai.Name);
+ UInt32 level = kNormal;
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Level <= kUltra)
+ level = fo.Level;
+ else
+ level = kUltra;
+ }
+ int i;
+ for (i = 0; i <= kUltra; i++)
+ {
+ if ((fi.LevelsMask & (1 << i)) != 0)
+ {
+ const CLevelInfo &levelInfo = g_Levels[i];
+ int index = (int)m_Level.AddString(LangString(levelInfo.ResourceID, levelInfo.LangID));
+ m_Level.SetItemData(index, i);
+ }
+ }
+ SetNearestSelectComboBox(m_Level, level);
+ SetMethod();
+}
+
+void CCompressDialog::SetMethod(int keepMethodId)
+{
+ m_Method.ResetContent();
+ UInt32 level = GetLevel();
+ if (level == 0)
+ {
+ SetDictionary();
+ SetOrder();
+ return;
+ }
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ int index = FindRegistryFormat(ai.Name);
+ UString defaultMethod;
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ defaultMethod = fo.Method;
+ }
+ bool isSfx = IsSFX();
+ bool weUseSameMethod = false;
+ for (int m = 0; m < fi.NumMethods; m++)
+ {
+ EMethodID methodID = fi.MathodIDs[m];
+ if (isSfx)
+ if (!IsMethodSupportedBySfx(methodID))
+ continue;
+ const LPCWSTR method = kMethodsNames[methodID];
+ int itemIndex = (int)m_Method.AddString(GetSystemString(method));
+ if (keepMethodId == methodID)
+ {
+ m_Method.SetCurSel(itemIndex);
+ weUseSameMethod = true;
+ continue;
+ }
+ if ((defaultMethod.CompareNoCase(method) == 0 || m == 0) && !weUseSameMethod)
+ m_Method.SetCurSel(itemIndex);
+ }
+ if (!weUseSameMethod)
+ {
+ SetDictionary();
+ SetOrder();
+ }
+}
+
+bool CCompressDialog::IsZipFormat()
+{
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ return (ai.Name.CompareNoCase(L"zip") == 0);
+}
+
+void CCompressDialog::SetEncryptionMethod()
+{
+ _encryptionMethod.ResetContent();
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ if (ai.Name.CompareNoCase(L"7z") == 0)
+ {
+ _encryptionMethod.AddString(TEXT("AES-256"));
+ _encryptionMethod.SetCurSel(0);
+ }
+ else if (ai.Name.CompareNoCase(L"zip") == 0)
+ {
+ int index = FindRegistryFormat(ai.Name);
+ UString encryptionMethod;
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ encryptionMethod = fo.EncryptionMethod;
+ }
+ _encryptionMethod.AddString(TEXT("ZipCrypto"));
+ _encryptionMethod.AddString(TEXT("AES-256"));
+ _encryptionMethod.SetCurSel(encryptionMethod.Find(L"AES") == 0 ? 1 : 0);
+ }
+}
+
+int CCompressDialog::GetMethodID()
+{
+ UString methodName;
+ m_Method.GetText(methodName);
+ for (int i = 0; i < MY_SIZE_OF_ARRAY(kMethodsNames); i++)
+ if (methodName.CompareNoCase(kMethodsNames[i]) == 0)
+ return i;
+ return -1;
+}
+
+UString CCompressDialog::GetMethodSpec()
+{
+ if (m_Method.GetCount() <= 1)
+ return UString();
+ UString result;
+ m_Method.GetText(result);
+ return result;
+}
+
+UString CCompressDialog::GetEncryptionMethodSpec()
+{
+ if (_encryptionMethod.GetCount() <= 1)
+ return UString();
+ if (_encryptionMethod.GetCurSel() <= 0)
+ return UString();
+ UString result;
+ _encryptionMethod.GetText(result);
+ result.Replace(L"-", L"");
+ return result;
+}
+
+int CCompressDialog::AddDictionarySize(UInt32 size, bool kilo, bool maga)
+{
+ UInt32 sizePrint = size;
+ if (kilo)
+ sizePrint >>= 10;
+ else if (maga)
+ sizePrint >>= 20;
+ TCHAR s[40];
+ ConvertUInt32ToString(sizePrint, s);
+ if (kilo)
+ lstrcat(s, TEXT(" K"));
+ else if (maga)
+ lstrcat(s, TEXT(" M"));
+ else
+ lstrcat(s, TEXT(" "));
+ lstrcat(s, TEXT("B"));
+ int index = (int)m_Dictionary.AddString(s);
+ m_Dictionary.SetItemData(index, size);
+ return index;
+}
+
+int CCompressDialog::AddDictionarySize(UInt32 size)
+{
+ if (size > 0)
+ {
+ if ((size & 0xFFFFF) == 0)
+ return AddDictionarySize(size, false, true);
+ if ((size & 0x3FF) == 0)
+ return AddDictionarySize(size, true, false);
+ }
+ return AddDictionarySize(size, false, false);
+}
+
+void CCompressDialog::SetDictionary()
+{
+ m_Dictionary.ResetContent();
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ int index = FindRegistryFormat(ai.Name);
+ UInt32 defaultDictionary = UInt32(-1);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
+ defaultDictionary = fo.Dictionary;
+ }
+ int methodID = GetMethodID();
+ UInt32 level = GetLevel2();
+ if (methodID < 0)
+ return;
+ const UInt64 maxRamSize = GetMaxRamSizeForProgram();
+ switch (methodID)
+ {
+ case kLZMA:
+ case kLZMA2:
+ {
+ static const UInt32 kMinDicSize = (1 << 16);
+ if (defaultDictionary == UInt32(-1))
+ {
+ if (level >= 9) defaultDictionary = (1 << 26);
+ else if (level >= 7) defaultDictionary = (1 << 25);
+ else if (level >= 5) defaultDictionary = (1 << 24);
+ else if (level >= 3) defaultDictionary = (1 << 20);
+ else defaultDictionary = (kMinDicSize);
+ }
+ int i;
+ AddDictionarySize(kMinDicSize);
+ m_Dictionary.SetCurSel(0);
+ for (i = 20; i <= 30; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ if (i == 20 && j > 0)
+ continue;
+ UInt32 dictionary = (1 << i) + (j << (i - 1));
+ if (dictionary >
+ #ifdef _WIN64
+ (1 << 30)
+ #else
+ (1 << 26)
+ #endif
+ )
+ continue;
+ AddDictionarySize(dictionary);
+ UInt64 decomprSize;
+ UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize);
+ if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize)
+ m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
+ }
+
+ // SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
+ break;
+ }
+ case kPPMd:
+ {
+ if (defaultDictionary == UInt32(-1))
+ {
+ if (level >= 9) defaultDictionary = (192 << 20);
+ else if (level >= 7) defaultDictionary = ( 64 << 20);
+ else if (level >= 5) defaultDictionary = ( 16 << 20);
+ else defaultDictionary = ( 4 << 20);
+ }
+ int i;
+ for (i = 20; i < 31; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ if (i == 20 && j > 0)
+ continue;
+ UInt32 dictionary = (1 << i) + (j << (i - 1));
+ if (dictionary >= (1 << 31))
+ continue;
+ AddDictionarySize(dictionary);
+ UInt64 decomprSize;
+ UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize);
+ if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
+ m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
+ }
+ SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
+ break;
+ }
+ case kDeflate:
+ {
+ AddDictionarySize(32 << 10);
+ m_Dictionary.SetCurSel(0);
+ break;
+ }
+ case kDeflate64:
+ {
+ AddDictionarySize(64 << 10);
+ m_Dictionary.SetCurSel(0);
+ break;
+ }
+ case kBZip2:
+ {
+ // UInt32 defaultDictionary;
+ if (defaultDictionary == UInt32(-1))
+ {
+ if (level >= 5)
+ defaultDictionary = (900 << 10);
+ else if (level >= 3)
+ defaultDictionary = (500 << 10);
+ else
+ defaultDictionary = (100 << 10);
+ }
+ for (int i = 1; i <= 9; i++)
+ {
+ UInt32 dictionary = (i * 100) << 10;
+ AddDictionarySize(dictionary);
+ if (dictionary <= defaultDictionary || m_Dictionary.GetCount() == 0)
+ m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
+ }
+ break;
+ }
+ }
+}
+
+UInt32 CCompressDialog::GetComboValue(NWindows::NControl::CComboBox &c, int defMax)
+{
+ if (c.GetCount() <= defMax)
+ return (UInt32)-1;
+ return (UInt32)c.GetItemData(c.GetCurSel());
+}
+
+UInt32 CCompressDialog::GetLevel2()
+{
+ UInt32 level = GetLevel();
+ if (level == (UInt32)-1)
+ level = 5;
+ return level;
+}
+
+int CCompressDialog::AddOrder(UInt32 size)
+{
+ TCHAR s[40];
+ ConvertUInt32ToString(size, s);
+ int index = (int)m_Order.AddString(s);
+ m_Order.SetItemData(index, size);
+ return index;
+}
+
+void CCompressDialog::SetOrder()
+{
+ m_Order.ResetContent();
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ int index = FindRegistryFormat(ai.Name);
+ UInt32 defaultOrder = UInt32(-1);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
+ defaultOrder = fo.Order;
+ }
+ int methodID = GetMethodID();
+ UInt32 level = GetLevel2();
+ if (methodID < 0)
+ return;
+ switch (methodID)
+ {
+ case kLZMA:
+ case kLZMA2:
+ {
+ if (defaultOrder == UInt32(-1))
+ defaultOrder = (level >= 7) ? 64 : 32;
+ for (int i = 3; i <= 8; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ UInt32 order = (1 << i) + (j << (i - 1));
+ if (order <= 256)
+ AddOrder(order);
+ }
+ AddOrder(273);
+ SetNearestSelectComboBox(m_Order, defaultOrder);
+ break;
+ }
+ case kPPMd:
+ {
+ if (defaultOrder == UInt32(-1))
+ {
+ if (level >= 9)
+ defaultOrder = 32;
+ else if (level >= 7)
+ defaultOrder = 16;
+ else if (level >= 5)
+ defaultOrder = 6;
+ else
+ defaultOrder = 4;
+ }
+ int i;
+ AddOrder(2);
+ AddOrder(3);
+ for (i = 2; i < 8; i++)
+ for (int j = 0; j < 4; j++)
+ {
+ UInt32 order = (1 << i) + (j << (i - 2));
+ if (order < 32)
+ AddOrder(order);
+ }
+ AddOrder(32);
+ SetNearestSelectComboBox(m_Order, defaultOrder);
+ break;
+ }
+ case kDeflate:
+ case kDeflate64:
+ {
+ if (defaultOrder == UInt32(-1))
+ {
+ if (level >= 9)
+ defaultOrder = 128;
+ else if (level >= 7)
+ defaultOrder = 64;
+ else
+ defaultOrder = 32;
+ }
+ int i;
+ for (i = 3; i <= 8; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ UInt32 order = (1 << i) + (j << (i - 1));
+ if (order <= 256)
+ AddOrder(order);
+ }
+ AddOrder(methodID == kDeflate64 ? 257 : 258);
+ SetNearestSelectComboBox(m_Order, defaultOrder);
+ break;
+ }
+ case kBZip2:
+ {
+ break;
+ }
+ }
+}
+
+bool CCompressDialog::GetOrderMode()
+{
+ switch (GetMethodID())
+ {
+ case kPPMd:
+ return true;
+ }
+ return false;
+}
+
+static const UInt32 kNoSolidBlockSize = 0;
+static const UInt32 kSolidBlockSize = 64;
+
+void CCompressDialog::SetSolidBlockSize()
+{
+ m_Solid.ResetContent();
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ if (!fi.Solid)
+ return;
+
+ UInt32 level = GetLevel2();
+ if (level == 0)
+ return;
+
+ UInt32 dictionary = GetDictionarySpec();
+ if (dictionary == UInt32(-1))
+ dictionary = 1;
+
+ UInt32 defaultBlockSize = (UInt32)-1;
+
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ int index = FindRegistryFormat(ai.Name);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
+ defaultBlockSize = fo.BlockLogSize;
+ }
+
+ index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_NON_SOLID, 0x02000D14));
+ m_Solid.SetItemData(index, (UInt32)kNoSolidBlockSize);
+ m_Solid.SetCurSel(0);
+ bool needSet = defaultBlockSize == (UInt32)-1;
+ for (int i = 20; i <= 36; i++)
+ {
+ if (needSet && dictionary >= (((UInt64)1 << (i - 7))) && i <= 32)
+ defaultBlockSize = i;
+ TCHAR s[40];
+ ConvertUInt32ToString(1 << (i % 10), s);
+ if (i < 30) lstrcat(s, TEXT(" M"));
+ else lstrcat(s, TEXT(" G"));
+ lstrcat(s, TEXT("B"));
+ int index = (int)m_Solid.AddString(s);
+ m_Solid.SetItemData(index, (UInt32)i);
+ }
+ index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_SOLID, 0x02000D15));
+ m_Solid.SetItemData(index, kSolidBlockSize);
+ if (defaultBlockSize == (UInt32)-1)
+ defaultBlockSize = kSolidBlockSize;
+ if (defaultBlockSize != kNoSolidBlockSize)
+ SetNearestSelectComboBox(m_Solid, defaultBlockSize);
+}
+
+void CCompressDialog::SetNumThreads()
+{
+ m_NumThreads.ResetContent();
+
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ if (!fi.MultiThread)
+ return;
+
+ UInt32 numHardwareThreads = NSystem::GetNumberOfProcessors();
+ UInt32 defaultValue = numHardwareThreads;
+
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ int index = FindRegistryFormat(ai.Name);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
+ defaultValue = fo.NumThreads;
+ }
+
+ UInt32 numAlgoThreadsMax = 1;
+ int methodID = GetMethodID();
+ switch (methodID)
+ {
+ case kLZMA: numAlgoThreadsMax = 2; break;
+ case kLZMA2: numAlgoThreadsMax = 32; break;
+ case kBZip2: numAlgoThreadsMax = 32; break;
+ }
+ if (IsZipFormat())
+ numAlgoThreadsMax = 128;
+ for (UInt32 i = 1; i <= numHardwareThreads * 2 && i <= numAlgoThreadsMax; i++)
+ {
+ TCHAR s[40];
+ ConvertUInt32ToString(i, s);
+ int index = (int)m_NumThreads.AddString(s);
+ m_NumThreads.SetItemData(index, (UInt32)i);
+ }
+ SetNearestSelectComboBox(m_NumThreads, defaultValue);
+}
+
+
+UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory)
+{
+ decompressMemory = UInt64(Int64(-1));
+ UInt32 level = GetLevel2();
+ if (level == 0)
+ {
+ decompressMemory = (1 << 20);
+ return decompressMemory;
+ }
+ UInt64 size = 0;
+
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ if (fi.Filter && level >= 9)
+ size += (12 << 20) * 2 + (5 << 20);
+ UInt32 numThreads = GetNumThreads2();
+ if (IsZipFormat())
+ {
+ UInt32 numSubThreads = 1;
+ if (GetMethodID() == kLZMA && numThreads > 1 && level >= 5)
+ numSubThreads = 2;
+ UInt32 numMainThreads = numThreads / numSubThreads;
+ if (numMainThreads > 1)
+ size += (UInt64)numMainThreads << 25;
+ }
+ int methidId = GetMethodID();
+ switch (methidId)
+ {
+ case kLZMA:
+ case kLZMA2:
+ {
+ UInt32 hs = dictionary - 1;
+ hs |= (hs >> 1);
+ hs |= (hs >> 2);
+ hs |= (hs >> 4);
+ hs |= (hs >> 8);
+ hs >>= 1;
+ hs |= 0xFFFF;
+ if (hs > (1 << 24))
+ hs >>= 1;
+ hs++;
+ UInt64 size1 = (UInt64)hs * 4;
+ size1 += (UInt64)dictionary * 4;
+ if (level >= 5)
+ size1 += (UInt64)dictionary * 4;
+ size1 += (2 << 20);
+
+ UInt32 numThreads1 = 1;
+ if (numThreads > 1 && level >= 5)
+ {
+ size1 += (2 << 20) + (4 << 20);
+ numThreads1 = 2;
+ }
+ UInt32 numBlockThreads = numThreads / numThreads1;
+ if (methidId == kLZMA || numBlockThreads == 1)
+ size1 += (UInt64)dictionary * 3 / 2;
+ else
+ {
+ UInt64 chunkSize = (UInt64)dictionary << 2;
+ chunkSize = MyMax(chunkSize, (UInt64)(1 << 20));
+ chunkSize = MyMin(chunkSize, (UInt64)(1 << 28));
+ chunkSize = MyMax(chunkSize, (UInt64)dictionary);
+ size1 += chunkSize * 2;
+ }
+ size += size1 * numBlockThreads;
+
+ decompressMemory = dictionary + (2 << 20);
+ return size;
+ }
+ case kPPMd:
+ {
+ decompressMemory = dictionary + (2 << 20);
+ return size + decompressMemory;
+ }
+ case kDeflate:
+ case kDeflate64:
+ {
+ UInt32 order = GetOrder();
+ if (order == UInt32(-1))
+ order = 32;
+ if (level >= 7)
+ size += (1 << 20);
+ size += 3 << 20;
+ decompressMemory = (2 << 20);
+ return size;
+ }
+ case kBZip2:
+ {
+ decompressMemory = (7 << 20);
+ UInt64 memForOneThread = (10 << 20);
+ return size + memForOneThread * numThreads;
+ }
+ }
+ return UInt64(Int64(-1));
+}
+
+UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
+{
+ return GetMemoryUsage(GetDictionary(), decompressMemory);
+}
+
+void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
+{
+ if (value == (UInt64)(Int64)-1)
+ {
+ SetItemText(res, TEXT("?"));
+ return;
+ }
+ value = (value + (1 << 20) - 1) >> 20;
+ TCHAR s[40];
+ ConvertUInt64ToString(value, s);
+ lstrcat(s, TEXT(" MB"));
+ SetItemText(res, s);
+}
+
+void CCompressDialog::SetMemoryUsage()
+{
+ UInt64 decompressMem;
+ UInt64 memUsage = GetMemoryUsage(decompressMem);
+ PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_VALUE, memUsage);
+ PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, decompressMem);
+}
+
+void CCompressDialog::SetParams()
+{
+ const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ m_Params.SetText(TEXT(""));
+ int index = FindRegistryFormat(ai.Name);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ m_Params.SetText(fo.Options);
+ }
+}
+
+void CCompressDialog::SaveOptionsInMem()
+{
+ const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
+ int index = FindRegistryFormatAlways(ai.Name);
+ m_Params.GetText(Info.Options);
+ Info.Options.Trim();
+ NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ fo.Options = Info.Options;
+ fo.Level = GetLevelSpec();
+ fo.Dictionary = GetDictionarySpec();
+ fo.Order = GetOrderSpec();
+ fo.Method = GetMethodSpec();
+ fo.EncryptionMethod = GetEncryptionMethodSpec();
+ fo.NumThreads = GetNumThreadsSpec();
+ fo.BlockLogSize = GetBlockSizeSpec();
+}
+
+int CCompressDialog::GetFormatIndex()
+{
+ return (int)m_Format.GetItemData(m_Format.GetCurSel());
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.h
new file mode 100644
index 000000000..75eeeee82
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.h
@@ -0,0 +1,184 @@
+// CompressDialog.h
+
+#ifndef __COMPRESS_DIALOG_H
+#define __COMPRESS_DIALOG_H
+
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/Edit.h"
+
+#include "../Common/LoadCodecs.h"
+#include "../Common/ZipRegistry.h"
+
+#include "CompressDialogRes.h"
+
+namespace NCompressDialog
+{
+ namespace NUpdateMode
+ {
+ enum EEnum
+ {
+ kAdd,
+ kUpdate,
+ kFresh,
+ kSynchronize,
+ };
+ }
+ struct CInfo
+ {
+ NUpdateMode::EEnum UpdateMode;
+ bool SolidIsSpecified;
+ bool MultiThreadIsAllowed;
+ UInt64 SolidBlockSize;
+ UInt32 NumThreads;
+
+ CRecordVector<UInt64> VolumeSizes;
+
+ UInt32 Level;
+ UString Method;
+ UInt32 Dictionary;
+ bool OrderMode;
+ UInt32 Order;
+ UString Options;
+
+ UString EncryptionMethod;
+
+ bool SFXMode;
+ bool OpenShareForWrite;
+
+
+ UString ArchiveName; // in: Relative for ; out: abs
+ UString CurrentDirPrefix;
+ bool KeepName;
+
+ bool GetFullPathName(UString &result) const;
+
+ int ArchiverInfoIndex;
+
+ UString Password;
+ bool EncryptHeadersIsAllowed;
+ bool EncryptHeaders;
+
+ void Init()
+ {
+ Level = Dictionary = Order = UInt32(-1);
+ OrderMode = false;
+ Method.Empty();
+ Options.Empty();
+ EncryptionMethod.Empty();
+ }
+ CInfo()
+ {
+ Init();
+ }
+ };
+}
+
+class CCompressDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox m_ArchivePath;
+ NWindows::NControl::CComboBox m_Format;
+ NWindows::NControl::CComboBox m_Level;
+ NWindows::NControl::CComboBox m_Method;
+ NWindows::NControl::CComboBox m_Dictionary;
+ NWindows::NControl::CComboBox m_Order;
+ NWindows::NControl::CComboBox m_Solid;
+ NWindows::NControl::CComboBox m_NumThreads;
+ NWindows::NControl::CComboBox m_UpdateMode;
+ NWindows::NControl::CComboBox m_Volume;
+ NWindows::NControl::CDialogChildControl m_Params;
+
+ NWindows::NControl::CEdit _password1Control;
+ NWindows::NControl::CEdit _password2Control;
+ NWindows::NControl::CComboBox _encryptionMethod;
+
+ NCompression::CInfo m_RegistryInfo;
+
+ int m_PrevFormat;
+ void SetArchiveName(const UString &name);
+ int FindRegistryFormat(const UString &name);
+ int FindRegistryFormatAlways(const UString &name);
+
+ void CheckSFXNameChange();
+ void SetArchiveName2(bool prevWasSFX);
+
+ int GetStaticFormatIndex();
+
+ void SetNearestSelectComboBox(NWindows::NControl::CComboBox &comboBox, UInt32 value);
+
+ void SetLevel();
+
+ void SetMethod(int keepMethodId = -1);
+ int GetMethodID();
+ UString GetMethodSpec();
+ UString GetEncryptionMethodSpec();
+
+ bool IsZipFormat();
+
+ void SetEncryptionMethod();
+
+ int AddDictionarySize(UInt32 size, bool kilo, bool maga);
+ int AddDictionarySize(UInt32 size);
+
+ void SetDictionary();
+
+ UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);
+
+ UInt32 GetLevel() { return GetComboValue(m_Level); }
+ UInt32 GetLevelSpec() { return GetComboValue(m_Level, 1); }
+ UInt32 GetLevel2();
+ UInt32 GetDictionary() { return GetComboValue(m_Dictionary); }
+ UInt32 GetDictionarySpec() { return GetComboValue(m_Dictionary, 1); }
+ UInt32 GetOrder() { return GetComboValue(m_Order); }
+ UInt32 GetOrderSpec() { return GetComboValue(m_Order, 1); }
+ UInt32 GetNumThreadsSpec() { return GetComboValue(m_NumThreads, 1); }
+ UInt32 GetNumThreads2() { UInt32 num = GetNumThreadsSpec(); if (num == UInt32(-1)) num = 1; return num; }
+ UInt32 GetBlockSizeSpec() { return GetComboValue(m_Solid, 1); }
+
+ int AddOrder(UInt32 size);
+ void SetOrder();
+ bool GetOrderMode();
+
+ void SetSolidBlockSize();
+ void SetNumThreads();
+
+ UInt64 GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory);
+ UInt64 GetMemoryUsage(UInt64 &decompressMemory);
+ void PrintMemUsage(UINT res, UInt64 value);
+ void SetMemoryUsage();
+ void SetParams();
+ void SaveOptionsInMem();
+
+ void UpdatePasswordControl();
+ bool IsShowPasswordChecked() const
+ { return IsButtonChecked(IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED; }
+
+ int GetFormatIndex();
+public:
+ CObjectVector<CArcInfoEx> m_ArchiverInfoList;
+
+ NCompressDialog::CInfo Info;
+ UString OriginalFileName; // for bzip2, gzip2
+
+ INT_PTR Create(HWND wndParent = 0)
+ { return CModalDialog::Create(IDD_DIALOG_COMPRESS, wndParent); }
+
+protected:
+
+ void CheckSFXControlsEnable();
+ void CheckVolumeEnable();
+ void CheckControlsEnable();
+
+ void OnButtonSetArchive();
+ bool IsSFX();
+ void OnButtonSFX();
+
+ virtual bool OnInit();
+ virtual bool OnCommand(int code, int itemID, LPARAM lParam);
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ virtual void OnOK();
+ virtual void OnHelp();
+
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialogRes.h
new file mode 100644
index 000000000..beedde4ef
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialogRes.h
@@ -0,0 +1,52 @@
+#define IDD_DIALOG_COMPRESS 152
+#define IDC_STATIC_COMPRESS_MEMORY 1022
+#define IDC_STATIC_COMPRESS_MEMORY_DE 1023
+#define IDC_STATIC_COMPRESS_MEMORY_VALUE 1027
+#define IDC_STATIC_COMPRESS_MEMORY_DE_VALUE 1028
+#define IDC_COMPRESS_COMBO_ARCHIVE 1072
+#define IDC_COMPRESS_BUTTON_SET_ARCHIVE 1073
+#define IDC_COMPRESS_COMBO_LEVEL 1074
+#define IDC_COMPRESS_COMBO_UPDATE_MODE 1075
+#define IDC_COMPRESS_COMBO_FORMAT 1076
+#define IDC_COMPRESS_COMBO_VOLUME 1077
+#define IDC_COMPRESS_COMBO_METHOD 1078
+#define IDC_COMPRESS_COMBO_DICTIONARY 1079
+#define IDC_COMPRESS_COMBO_ORDER 1080
+
+#define IDC_COMPRESS_COMBO_SOLID 1081
+#define IDC_COMPRESS_COMBO_THREADS 1082
+#define IDC_COMPRESS_HARDWARE_THREADS 1083
+
+#define IDC_COMPRESS_SFX 1090
+#define IDC_COMPRESS_EDIT_PARAMETERS 1091
+
+// #define IDC_COMPRESS_SOLID 1092
+// #define IDC_COMPRESS_MULTI_THREAD 1093
+
+#define IDC_STATIC_COMPRESS_ARCHIVE 1097
+#define IDC_STATIC_COMPRESS_FORMAT 1098
+#define IDC_STATIC_COMPRESS_LEVEL 1099
+#define IDC_STATIC_COMPRESS_PARAMETERS 1100
+#define IDC_STATIC_COMPRESS_UPDATE_MODE 1101
+#define IDC_STATIC_COMPRESS_OPTIONS 1102
+#define IDC_STATIC_COMPRESS_VOLUME 1103
+#define IDC_STATIC_COMPRESS_METHOD 1104
+#define IDC_STATIC_COMPRESS_DICTIONARY 1105
+#define IDC_STATIC_COMPRESS_ORDER 1106
+
+#define IDC_STATIC_COMPRESS_SOLID 1107
+#define IDC_STATIC_COMPRESS_THREADS 1108
+
+#define IDC_COMPRESS_ENCRYPTION 1110
+#define IDC_STATIC_COMPRESS_PASSWORD1 1111
+#define IDC_COMPRESS_EDIT_PASSWORD1 1112
+#define IDC_STATIC_COMPRESS_PASSWORD2 1113
+#define IDC_COMPRESS_EDIT_PASSWORD2 1114
+#define IDC_COMPRESS_CHECK_SHOW_PASSWORD 1115
+
+#define IDC_STATIC_COMPRESS_ENCRYPTION_METHOD 1120
+#define IDC_COMPRESS_COMBO_ENCRYPTION_METHOD 1121
+
+#define IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES 1122
+
+#define IDC_COMPRESS_SHARED 1130
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog_rc.cpp
new file mode 100644
index 000000000..b69ab8daf
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog_rc.cpp
@@ -0,0 +1,283 @@
+// CompressDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "resource.h"
+#include "Windows/Control/DialogImpl.h"
+
+#include "CompressDialogRes.h"
+
+class CCompressDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CCompressDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Add to Archive"))
+ {
+ wxStaticText *m_pStaticTextMemoryCompress;
+ wxStaticText *m_pStaticTextMemoryDecompress;
+ wxTextCtrl *m_pTextCtrlPassword;
+ wxTextCtrl *m_pTextCtrlRePassword;
+ wxTextCtrl *m_pTextCtrlParameters;
+ wxComboBox *m_pComboBoxArchiveName;
+ wxComboBox *m_pComboBoxArchiveFormat;
+ wxComboBox *m_pComboBoxCompressionLevel;
+ wxComboBox *m_pComboBoxCompressionMethod;
+ wxComboBox *m_pComboBoxDictionarySize;
+ wxComboBox *m_pComboBoxWordSize;
+ wxComboBox *m_pComboBoxUpdateMode;
+ wxComboBox *m_pComboBoxEncryptionMethod;
+ wxComboBox *m_pComboBoxSplitToVolumes;
+ wxCheckBox *m_pCheckBoxShowPassword;
+ wxCheckBox *m_pCheckBoxEncryptFileNames;
+ wxButton *m_pButtonBrowse;
+
+
+ ///Sizer for adding the controls created by users
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ wxStaticText *pStaticTextArchive = new wxStaticText(this, IDC_STATIC_COMPRESS_ARCHIVE, wxT("&Archive:"));
+ wxBoxSizer *pArchiveNameSizer = new wxBoxSizer(wxHORIZONTAL);
+ m_pComboBoxArchiveName = new wxComboBox(this, IDC_COMPRESS_COMBO_ARCHIVE, wxEmptyString, wxDefaultPosition, wxSize(600,-1), wxArrayString(), wxCB_DROPDOWN|wxCB_SORT);
+ m_pButtonBrowse = new wxButton(this, IDC_COMPRESS_BUTTON_SET_ARCHIVE, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pArchiveNameSizer->Add(m_pComboBoxArchiveName, 1, wxALL|wxEXPAND, 5);
+ pArchiveNameSizer->Add(m_pButtonBrowse, 0, wxALL|wxEXPAND, 5);
+ wxBoxSizer *pControlSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pLeftSizer = new wxBoxSizer(wxVERTICAL);
+
+ wxBoxSizer *pCompressionOptionsSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pCompressionStaticSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *pCompressionComboSizer = new wxBoxSizer(wxVERTICAL);
+
+ wxStaticText *pStaticTextArchiveFormat = new wxStaticText(this, IDC_STATIC_COMPRESS_FORMAT, wxT("Archive &format:"));
+ /*
+ wxArrayString archiveFormatArray;
+ archiveFormatArray.Add(wxT("7z"));
+ archiveFormatArray.Add(wxT("Tar"));
+ archiveFormatArray.Add(wxT("Zip"));
+ m_pComboBoxArchiveFormat = new wxComboBox(this, IDC_COMPRESS_COMBO_FORMAT, archiveFormatArray.Item(0), wxDefaultPosition, wxDefaultSize, archiveFormatArray, wxCB_READONLY);
+ */
+
+ m_pComboBoxArchiveFormat = new wxComboBox(this, IDC_COMPRESS_COMBO_FORMAT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+ wxStaticText *pStaticTextCompressionLevel = new wxStaticText(this, IDC_STATIC_COMPRESS_LEVEL, wxT("Compression &level:"));
+ wxArrayString compressionLevelArray;
+ /*
+ compressionLevelArray.Add(wxT("Store"));
+ compressionLevelArray.Add(wxT("Fastest"));
+ compressionLevelArray.Add(wxT("Fast"));
+ compressionLevelArray.Add(wxT("Normal"));
+ compressionLevelArray.Add(wxT("Maximum"));
+ compressionLevelArray.Add(wxT("Ultra"));
+ m_pComboBoxCompressionLevel = new wxComboBox(this, IDC_COMPRESS_COMBO_LEVEL, compressionLevelArray.Item(0), wxDefaultPosition, wxDefaultSize, compressionLevelArray, wxCB_READONLY);
+ */
+ m_pComboBoxCompressionLevel = new wxComboBox(this, IDC_COMPRESS_COMBO_LEVEL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+ wxStaticText *pStaticTextCompressionMethod = new wxStaticText(this, IDC_STATIC_COMPRESS_METHOD, wxT("Compression &method:"));
+/*
+ wxArrayString compressionMethodArray;
+ compressionMethodArray.Add(wxT("LZMA"));
+ compressionMethodArray.Add(wxT("PPMd"));
+ compressionMethodArray.Add(wxT("BZip2"));
+ m_pComboBoxCompressionMethod = new wxComboBox(this, IDC_COMPRESS_COMBO_METHOD, compressionMethodArray.Item(0), wxDefaultPosition, wxDefaultSize, compressionMethodArray, wxCB_READONLY);
+*/
+ m_pComboBoxCompressionMethod = new wxComboBox(this, IDC_COMPRESS_COMBO_METHOD, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+ wxStaticText *pStaticTextDictionarySize = new wxStaticText(this, IDC_STATIC_COMPRESS_DICTIONARY, wxT("&Dictionary size:"));
+/*
+ wxArrayString dictionarySizeArray;
+ dictionarySizeArray.Add(wxT("64 KB"));
+ dictionarySizeArray.Add(wxT("1 MB"));
+ dictionarySizeArray.Add(wxT("1 MB"));
+ dictionarySizeArray.Add(wxT("2 MB"));
+ dictionarySizeArray.Add(wxT("3 MB"));
+ dictionarySizeArray.Add(wxT("4 MB"));
+ dictionarySizeArray.Add(wxT("6 MB"));
+ dictionarySizeArray.Add(wxT("8 MB"));
+ dictionarySizeArray.Add(wxT("12 MB"));
+ dictionarySizeArray.Add(wxT("16 MB"));
+ dictionarySizeArray.Add(wxT("24 MB"));
+ dictionarySizeArray.Add(wxT("32 MB"));
+ dictionarySizeArray.Add(wxT("48 MB"));
+ dictionarySizeArray.Add(wxT("64 MB"));
+ dictionarySizeArray.Add(wxT("96 MB"));
+ dictionarySizeArray.Add(wxT("128 MB"));
+ m_pComboBoxDictionarySize = new wxComboBox(this, IDC_COMPRESS_COMBO_DICTIONARY, dictionarySizeArray.Item(0), wxDefaultPosition, wxDefaultSize, dictionarySizeArray, wxCB_READONLY);
+*/
+ m_pComboBoxDictionarySize = new wxComboBox(this, IDC_COMPRESS_COMBO_DICTIONARY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+ wxStaticText *pStaticTextNumberOfThreads = new wxStaticText(this, IDC_STATIC_COMPRESS_THREADS, wxT("&Number of CPU threads:"));
+/*
+ wxArrayString numberOfThreadsArray;
+ numberOfThreadsArray.Add(wxT("1"));
+ numberOfThreadsArray.Add(wxT("2"));
+ wxComboBox *m_pComboBoxNumberOfThreads = new wxComboBox(this, IDC_COMPRESS_COMBO_THREADS, numberOfThreadsArray.Item(0), wxDefaultPosition, wxDefaultSize, numberOfThreadsArray, wxCB_READONLY);
+*/
+ wxComboBox *m_pComboBoxNumberOfThreads = new wxComboBox(this, IDC_COMPRESS_COMBO_THREADS, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+
+
+
+
+
+ wxStaticText *pStaticTextWordSize = new wxStaticText(this, IDC_STATIC_COMPRESS_ORDER, wxT("&Word size:"));
+/*
+ wxArrayString wordSizeArray;
+ wordSizeArray.Add(wxT("8"));
+ wordSizeArray.Add(wxT("12"));
+ wordSizeArray.Add(wxT("16"));
+ wordSizeArray.Add(wxT("24"));
+ wordSizeArray.Add(wxT("32"));
+ wordSizeArray.Add(wxT("48"));
+ wordSizeArray.Add(wxT("64"));
+ wordSizeArray.Add(wxT("96"));
+ wordSizeArray.Add(wxT("128"));
+ wordSizeArray.Add(wxT("192"));
+ wordSizeArray.Add(wxT("256"));
+ wordSizeArray.Add(wxT("273"));
+ m_pComboBoxWordSize = new wxComboBox(this, IDC_COMPRESS_COMBO_ORDER, wordSizeArray.Item(0), wxDefaultPosition, wxDefaultSize, wordSizeArray, wxCB_READONLY);
+*/
+ m_pComboBoxWordSize = new wxComboBox(this, IDC_COMPRESS_COMBO_ORDER, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+
+ wxStaticText *pStaticTextBlockSize = new wxStaticText(this, IDC_STATIC_COMPRESS_SOLID, wxT("&Solid Block size:"));
+
+ wxComboBox *m_pComboBoxBlockSize = new wxComboBox(this, IDC_COMPRESS_COMBO_SOLID, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+ pCompressionStaticSizer->Add(pStaticTextArchiveFormat, 1, wxALL|wxEXPAND, 5);
+ pCompressionStaticSizer->Add(pStaticTextCompressionLevel, 1, wxALL|wxEXPAND, 5);
+ pCompressionStaticSizer->Add(pStaticTextCompressionMethod, 1, wxALL|wxEXPAND, 5);
+ pCompressionStaticSizer->Add(pStaticTextDictionarySize, 1, wxALL|wxEXPAND, 5);
+ pCompressionStaticSizer->Add(pStaticTextWordSize, 1, wxALL|wxEXPAND, 5);
+ pCompressionStaticSizer->Add(pStaticTextBlockSize, 1, wxALL|wxEXPAND, 5);
+ pCompressionStaticSizer->Add(pStaticTextNumberOfThreads, 1, wxALL|wxEXPAND, 5);
+ pCompressionComboSizer->Add(m_pComboBoxArchiveFormat, 1, wxALL|wxEXPAND, 5);
+ pCompressionComboSizer->Add(m_pComboBoxCompressionLevel, 1, wxALL|wxEXPAND, 5);
+ pCompressionComboSizer->Add(m_pComboBoxCompressionMethod, 1, wxALL|wxEXPAND, 5);
+ pCompressionComboSizer->Add(m_pComboBoxDictionarySize, 1, wxALL|wxEXPAND, 5);
+ pCompressionComboSizer->Add(m_pComboBoxWordSize, 1, wxALL|wxEXPAND, 5);
+ pCompressionComboSizer->Add(m_pComboBoxBlockSize, 1, wxALL|wxEXPAND, 5);
+ pCompressionComboSizer->Add(m_pComboBoxNumberOfThreads, 1, wxALL|wxEXPAND, 5);
+ pCompressionOptionsSizer->Add(pCompressionStaticSizer, 1, wxALL|wxEXPAND, 0);
+ pCompressionOptionsSizer->Add(pCompressionComboSizer, 1, wxALL|wxEXPAND, 0);
+
+ wxBoxSizer *pMemoryUsageSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pMemoryUsageLabelSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *pMemoryUsageInfoSizer = new wxBoxSizer(wxVERTICAL);
+ wxStaticText *pStaticTextCompressMemoryUsage = new wxStaticText(this, IDC_STATIC_COMPRESS_MEMORY, wxT("Memory usage for Compressing:"));
+ m_pStaticTextMemoryCompress = new wxStaticText(this, IDC_STATIC_COMPRESS_MEMORY_VALUE, wxT("709 MB"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ wxStaticText *pStaticTextDecompressMemoryUsage = new wxStaticText(this, IDC_STATIC_COMPRESS_MEMORY_DE, wxT("Memory usage for Decompressing"));
+ m_pStaticTextMemoryDecompress = new wxStaticText(this, IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, wxT("66 MB"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ pMemoryUsageLabelSizer->Add(pStaticTextCompressMemoryUsage, 1, wxALL|wxEXPAND, 5);
+ pMemoryUsageLabelSizer->Add(pStaticTextDecompressMemoryUsage, 1, wxALL|wxEXPAND, 5);
+ pMemoryUsageInfoSizer->Add(m_pStaticTextMemoryCompress, 1, wxALL|wxEXPAND, 5);
+ pMemoryUsageInfoSizer->Add(m_pStaticTextMemoryDecompress, 1, wxALL|wxEXPAND, 5);
+ pMemoryUsageSizer->Add(pMemoryUsageLabelSizer, 1, wxALL|wxEXPAND, 0);
+ pMemoryUsageSizer->Add(pMemoryUsageInfoSizer, 0, wxALL|wxEXPAND, 0);
+
+ wxStaticText *pStaticSplit2Volumes = new wxStaticText(this, IDC_STATIC_COMPRESS_VOLUME, wxT("Split to &volumes, bytes:"));
+/*
+ wxArrayString split2VolumesArray;
+ split2VolumesArray.Add(wxT("1457664 - 3.5\" floppy"));
+ split2VolumesArray.Add(wxT("650M - CD"));
+ split2VolumesArray.Add(wxT("700M - CD"));
+ split2VolumesArray.Add(wxT("4480M - DVD"));
+ m_pComboBoxSplitToVolumes = new wxComboBox(this, IDC_COMPRESS_COMBO_VOLUME, wxEmptyString, wxDefaultPosition, wxDefaultSize, split2VolumesArray, wxCB_DROPDOWN);
+*/
+ m_pComboBoxSplitToVolumes = new wxComboBox(this, IDC_COMPRESS_COMBO_VOLUME, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_DROPDOWN);
+
+ pLeftSizer->Add(pCompressionOptionsSizer, 0, wxALL|wxEXPAND, 0);
+ pLeftSizer->Add(pMemoryUsageSizer, 1, wxALL|wxEXPAND, 0);
+ pLeftSizer->Add(pStaticSplit2Volumes, 0, wxALL|wxEXPAND, 5);
+ pLeftSizer->Add(m_pComboBoxSplitToVolumes, 0, wxALL|wxEXPAND, 5);
+
+ wxBoxSizer *pRightSizer = new wxBoxSizer(wxVERTICAL);
+ wxStaticText *pStaticTextUpdateMode = new wxStaticText(this, IDC_STATIC_COMPRESS_UPDATE_MODE, wxT("&Update mode:"));
+/*
+ wxArrayString updateModeArray;
+ updateModeArray.Add(wxT("Add and replace files"));
+ updateModeArray.Add(wxT("Update and add files"));
+ updateModeArray.Add(wxT("Freshen existing files"));
+ updateModeArray.Add(wxT("Synchronize files"));
+ m_pComboBoxUpdateMode = new wxComboBox(this, IDC_COMPRESS_COMBO_UPDATE_MODE, updateModeArray.Item(0), wxDefaultPosition, wxDefaultSize, updateModeArray, wxCB_READONLY);
+*/
+ m_pComboBoxUpdateMode = new wxComboBox(this, IDC_COMPRESS_COMBO_UPDATE_MODE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+ wxStaticBoxSizer *pOptionsSizer = new wxStaticBoxSizer(new wxStaticBox(this,IDC_STATIC_COMPRESS_OPTIONS,_T("Options")),wxVERTICAL);
+ wxCheckBox *m_pCheckBoxSFXArchive = new wxCheckBox(this, IDC_COMPRESS_SFX, wxT("Create SF&X archive"));
+ pOptionsSizer->Add(m_pCheckBoxSFXArchive, 1, wxALL|wxEXPAND, 5);
+ wxCheckBox *m_pCheckBoxCompressSharedFiles = new wxCheckBox(this, IDC_COMPRESS_SHARED, wxT("Compress shared files"));
+ m_pCheckBoxCompressSharedFiles->Show(false); // this option is useless undex Unix ...
+ pOptionsSizer->Add(m_pCheckBoxCompressSharedFiles, 1, wxALL|wxEXPAND, 5);
+
+ wxStaticBoxSizer * pEncryptSizer = new wxStaticBoxSizer(new wxStaticBox(this,IDC_COMPRESS_ENCRYPTION,_T("Encryption")),wxVERTICAL);
+ wxStaticText *pStaticTextPassword = new wxStaticText(this, IDC_STATIC_COMPRESS_PASSWORD1, wxT("Enter password:"));
+ m_pTextCtrlPassword = new wxTextCtrl(this, IDC_COMPRESS_EDIT_PASSWORD1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
+ wxStaticText *pStaticTextRePassword = new wxStaticText(this, IDC_STATIC_COMPRESS_PASSWORD2, wxT("Re-enter password:"));
+ m_pTextCtrlRePassword = new wxTextCtrl(this, IDC_COMPRESS_EDIT_PASSWORD2, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
+ m_pCheckBoxShowPassword = new wxCheckBox(this, IDC_COMPRESS_CHECK_SHOW_PASSWORD, wxT("Show Password"));
+ wxBoxSizer *pEncryptionMethodSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxStaticText *pStaticTextEncryptionMethod = new wxStaticText(this, IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, wxT("&Encryption method:"));
+/*
+ wxArrayString encryptionMethodArray;
+ encryptionMethodArray.Add(wxT("AES-256"));
+ m_pComboBoxEncryptionMethod =new wxComboBox(this, IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, encryptionMethodArray.Item(0), wxDefaultPosition, wxDefaultSize, encryptionMethodArray, wxCB_READONLY);
+*/
+ m_pComboBoxEncryptionMethod =new wxComboBox(this, IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);
+
+ pEncryptionMethodSizer->Add(pStaticTextEncryptionMethod, 1, wxALL|wxEXPAND, 5);
+ pEncryptionMethodSizer->Add(m_pComboBoxEncryptionMethod, 1, wxALL|wxEXPAND, 5);
+ m_pCheckBoxEncryptFileNames = new wxCheckBox(this, IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, wxT("Encrypt file &names"));
+ pEncryptSizer->Add(pStaticTextPassword, 0, wxALL|wxEXPAND, 5);
+ pEncryptSizer->Add(m_pTextCtrlPassword, 0, wxLEFT|wxRIGHT|wxEXPAND, 5);
+ pEncryptSizer->Add(pStaticTextRePassword, 0, wxALL|wxEXPAND, 5);
+ pEncryptSizer->Add(m_pTextCtrlRePassword, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5);
+ pEncryptSizer->Add(m_pCheckBoxShowPassword, 0, wxALL|wxEXPAND, 5);
+ pEncryptSizer->Add(pEncryptionMethodSizer, 0, wxLEFT|wxRIGHT|wxEXPAND, 0);
+ pEncryptSizer->Add(m_pCheckBoxEncryptFileNames, 0, wxALL|wxEXPAND, 5);
+
+ pRightSizer->Add(pStaticTextUpdateMode, 0, wxALL|wxEXPAND, 5);
+ pRightSizer->Add(m_pComboBoxUpdateMode, 0, wxALL|wxEXPAND, 5);
+ pRightSizer->Add(pOptionsSizer, 1, wxALL|wxEXPAND, 5);
+ pRightSizer->Add(pEncryptSizer, 0, wxALL|wxEXPAND, 5);
+
+ pControlSizer->Add(pLeftSizer, 1, wxALL|wxEXPAND, 5);
+ pControlSizer->Add(pRightSizer, 1, wxALL|wxEXPAND, 5);
+ wxStaticText *pStaticTextParameters = new wxStaticText(this, IDC_STATIC_COMPRESS_PARAMETERS, wxT("&Parameters:"));
+ m_pTextCtrlParameters = new wxTextCtrl(this, IDC_COMPRESS_EDIT_PARAMETERS, wxEmptyString);
+ topsizer->Add(pStaticTextArchive, 0, wxLEFT | wxRIGHT | wxTOP |wxEXPAND, 10);
+ topsizer->Add(pArchiveNameSizer, 1, wxLEFT | wxRIGHT |wxEXPAND, 5);
+ topsizer->Add(pControlSizer, 0, wxALL|wxEXPAND, 5);
+ topsizer->Add(pStaticTextParameters, 0, wxLEFT | wxRIGHT | wxBOTTOM |wxEXPAND, 10);
+ topsizer->Add(m_pTextCtrlParameters, 0, wxLEFT | wxRIGHT |wxEXPAND, 10);
+ topsizer->Add(CreateButtonSizer(wxOK | wxCANCEL | wxHELP), 0, wxALL|wxEXPAND, 10);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+REGISTER_DIALOG(IDD_DIALOG_COMPRESS,CCompressDialog,0)
+
+BEGIN_EVENT_TABLE(CCompressDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_COMBOBOX(wxID_ANY, CModalDialogImpl::OnAnyChoice)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.cpp
new file mode 100644
index 000000000..6b3887006
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.cpp
@@ -0,0 +1,374 @@
+// ExtractDialog.cpp
+
+#include "StdAfx.h"
+
+// #include <HtmlHelp.h>
+
+#include "ExtractDialog.h"
+
+#include "Common/StringConvert.h"
+#include "Windows/Shell.h"
+#include "Windows/FileName.h"
+#include "Windows/FileDir.h"
+#include "Windows/ResourceString.h"
+
+#ifndef NO_REGISTRY
+#include "../FileManager/HelpUtils.h"
+#endif
+
+#include "../Common/ZipRegistry.h"
+
+#include "../FileManager/LangUtils.h"
+
+#include "ExtractRes.h"
+#include "ExtractDialogRes.h"
+
+// #include "Help/Context/Extract.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NName;
+
+static const int kPathModeButtons[] =
+{
+ IDC_EXTRACT_RADIO_FULL_PATHNAMES,
+ IDC_EXTRACT_RADIO_CURRENT_PATHNAMES,
+ IDC_EXTRACT_RADIO_NO_PATHNAMES
+};
+
+#ifndef _SFX
+
+static const NExtract::NPathMode::EEnum kPathModeButtonsVals[] =
+{
+ NExtract::NPathMode::kFullPathnames,
+ NExtract::NPathMode::kCurrentPathnames,
+ NExtract::NPathMode::kNoPathnames
+};
+
+static const int kNumPathnamesButtons = sizeof(kPathModeButtons) / sizeof(kPathModeButtons[0]);
+
+static const int kOverwriteButtons[] =
+{
+ IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE,
+ IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT,
+ IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES,
+ IDC_EXTRACT_RADIO_AUTO_RENAME,
+ IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING,
+};
+
+static const NExtract::NOverwriteMode::EEnum kOverwriteButtonsVals[] =
+{
+ NExtract::NOverwriteMode::kAskBefore,
+ NExtract::NOverwriteMode::kWithoutPrompt,
+ NExtract::NOverwriteMode::kSkipExisting,
+ NExtract::NOverwriteMode::kAutoRename,
+ NExtract::NOverwriteMode::kAutoRenameExisting
+};
+
+static const int kNumOverwriteButtons = sizeof(kOverwriteButtons) / sizeof(kOverwriteButtons[0]);
+
+/*
+static const int kFilesButtons[] =
+{
+ IDC_EXTRACT_RADIO_SELECTED_FILES,
+ IDC_EXTRACT_RADIO_ALL_FILES
+};
+static const int kNumFilesButtons = sizeof(kFilesButtons) / sizeof(kFilesButtons[0]);
+*/
+
+void CExtractDialog::GetPathMode()
+{
+ for (int i = 0; i < kNumPathnamesButtons; i++)
+ if(IsButtonCheckedBool(kPathModeButtons[i]))
+ {
+ PathMode = kPathModeButtonsVals[i];
+ return;
+ }
+ throw 1;
+}
+
+void CExtractDialog::SetPathMode()
+{
+ for (int j = 0; j < 2; j++)
+ {
+ for (int i = 0; i < kNumPathnamesButtons; i++)
+ if(PathMode == kPathModeButtonsVals[i])
+ {
+ CheckRadioButton(kPathModeButtons[0], kPathModeButtons[kNumPathnamesButtons - 1],
+ kPathModeButtons[i]);
+ return;
+ }
+ PathMode = kPathModeButtonsVals[0];
+ }
+ throw 1;
+}
+
+void CExtractDialog::GetOverwriteMode()
+{
+ for (int i = 0; i < kNumOverwriteButtons; i++)
+ if(IsButtonCheckedBool(kOverwriteButtons[i]))
+ {
+ OverwriteMode = kOverwriteButtonsVals[i];
+ return;
+ }
+ throw 0;
+}
+
+void CExtractDialog::SetOverwriteMode()
+{
+ for (int j = 0; j < 2; j++)
+ {
+ for (int i = 0; i < kNumOverwriteButtons; i++)
+ if(OverwriteMode == kOverwriteButtonsVals[i])
+ {
+ CheckRadioButton(kOverwriteButtons[0], kOverwriteButtons[kNumOverwriteButtons - 1],
+ kOverwriteButtons[i]);
+ return;
+ }
+ OverwriteMode = kOverwriteButtonsVals[0];
+ }
+ throw 1;
+}
+
+/*
+int CExtractDialog::GetFilesMode() const
+{
+ for (int i = 0; i < kNumFilesButtons; i++)
+ if(IsButtonCheckedBool(kFilesButtons[i]))
+ return i;
+ throw 0;
+}
+*/
+
+#endif
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_EXTRACT_EXTRACT_TO, 0x02000801 },
+ { IDC_EXTRACT_PATH_MODE, 0x02000810 },
+ { IDC_EXTRACT_RADIO_FULL_PATHNAMES, 0x02000811 },
+ { IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, 0x02000812 },
+ { IDC_EXTRACT_RADIO_NO_PATHNAMES, 0x02000813 },
+ { IDC_EXTRACT_OVERWRITE_MODE, 0x02000820 },
+ { IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, 0x02000821 },
+ { IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, 0x02000822 },
+ { IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, 0x02000823 },
+ { IDC_EXTRACT_RADIO_AUTO_RENAME, 0x02000824 },
+ { IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, 0x02000825 },
+ { IDC_EXTRACT_FILES, 0x02000830 },
+ { IDC_EXTRACT_RADIO_SELECTED_FILES, 0x02000831 },
+ { IDC_EXTRACT_RADIO_ALL_FILES, 0x02000832 },
+ { IDC_EXTRACT_PASSWORD, 0x02000802 },
+ { IDC_EXTRACT_CHECK_SHOW_PASSWORD, 0x02000B02 },
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 },
+ { IDHELP, 0x02000720 }
+
+};
+#endif
+
+// static const int kWildcardsButtonIndex = 2;
+
+#ifndef NO_REGISTRY
+static const int kHistorySize = 8;
+#endif
+
+bool CExtractDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000800);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ #ifndef _SFX
+ _passwordControl.Attach(GetItem(IDC_EXTRACT_EDIT_PASSWORD));
+ _passwordControl.SetText(Password);
+ _passwordControl.SetPasswordChar(TEXT('*'));
+ #endif
+
+ NExtract::CInfo extractionInfo;
+
+ #ifdef NO_REGISTRY
+ PathMode = NExtract::NPathMode::kFullPathnames;
+ OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
+ // extractionInfo.Paths = NExtract::NPathMode::kFullPathnames;
+ #else
+ ReadExtractionInfo(extractionInfo);
+ CheckButton(IDC_EXTRACT_CHECK_SHOW_PASSWORD, extractionInfo.ShowPassword);
+ UpdatePasswordControl();
+ PathMode = extractionInfo.PathMode;
+ OverwriteMode = extractionInfo.OverwriteMode;
+ #endif
+
+ _path.Attach(GetItem(IDC_EXTRACT_COMBO_PATH));
+
+ _path.SetText(DirectoryPath);
+
+ #ifndef NO_REGISTRY
+ for(int i = 0; i < extractionInfo.Paths.Size() && i < kHistorySize; i++)
+ _path.AddString(extractionInfo.Paths[i]);
+ #endif
+
+ /*
+ if(extractionInfo.Paths.Size() > 0)
+ _path.SetCurSel(0);
+ else
+ _path.SetCurSel(-1);
+ */
+
+
+
+ #ifndef _SFX
+ SetPathMode();
+ SetOverwriteMode();
+
+ /*
+ CheckRadioButton(kFilesButtons[0], kFilesButtons[kNumFilesButtons - 1],
+ kFilesButtons[_filesMode]);
+ */
+
+ // CWindow selectedFilesWindow = GetItem(IDC_EXTRACT_RADIO_SELECTED_FILES);
+ // selectedFilesWindow.Enable(_enableSelectedFilesButton);
+
+
+ #endif
+
+
+ // CWindow filesWindow = GetItem(IDC_EXTRACT_RADIO_FILES);
+ // filesWindow.Enable(_enableFilesButton);
+
+ // UpdateWildCardState();
+ return CModalDialog::OnInit();
+}
+
+#ifndef _SFX
+void CExtractDialog::UpdatePasswordControl()
+{
+ _passwordControl.SetPasswordChar((IsButtonChecked(
+ IDC_EXTRACT_CHECK_SHOW_PASSWORD) == BST_CHECKED) ? 0: TEXT('*'));
+ UString password;
+ _passwordControl.GetText(password);
+ _passwordControl.SetText(password);
+}
+#endif
+
+bool CExtractDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ /*
+ for (int i = 0; i < kNumFilesButtons; i++)
+ if (buttonID == kFilesButtons[i])
+ {
+ UpdateWildCardState();
+ return true;
+ }
+ */
+ switch(buttonID)
+ {
+ case IDC_EXTRACT_BUTTON_SET_PATH:
+ OnButtonSetPath();
+ return true;
+ #ifndef _SFX
+ case IDC_EXTRACT_CHECK_SHOW_PASSWORD:
+ {
+ UpdatePasswordControl();
+ return true;
+ }
+ #endif
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CExtractDialog::OnButtonSetPath()
+{
+ UString currentPath;
+ _path.GetText(currentPath);
+ UString title = LangStringSpec(IDS_EXTRACT_SET_FOLDER, 0x02000881);
+ UString resultPath;
+ if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
+ return;
+ #ifndef NO_REGISTRY
+ _path.SetCurSel(-1);
+ #endif
+ _path.SetText(resultPath);
+}
+
+void AddUniqueString(UStringVector &list, const UString &s)
+{
+ for(int i = 0; i < list.Size(); i++)
+ if (s.CompareNoCase(list[i]) == 0)
+ return;
+ list.Add(s);
+}
+
+void CExtractDialog::OnOK()
+{
+ #ifndef _SFX
+ GetPathMode();
+ GetOverwriteMode();
+ // _filesMode = (NExtractionDialog::NFilesMode::EEnum)GetFilesMode();
+
+ _passwordControl.GetText(Password);
+ #endif
+
+ NExtract::CInfo extractionInfo;
+ extractionInfo.PathMode = PathMode;
+ extractionInfo.OverwriteMode = OverwriteMode;
+ extractionInfo.ShowPassword = (IsButtonChecked(
+ IDC_EXTRACT_CHECK_SHOW_PASSWORD) == BST_CHECKED);
+
+ UString s;
+
+ #ifdef NO_REGISTRY
+
+ _path.GetText(s);
+
+ #else
+
+ int currentItem = _path.GetCurSel();
+ if(currentItem == CB_ERR)
+ {
+ _path.GetText(s);
+ if(_path.GetCount() >= kHistorySize)
+ currentItem = _path.GetCount() - 1;
+ }
+ else
+ _path.GetLBText(currentItem, s);
+
+ #endif
+
+ s.Trim();
+ #ifndef _SFX
+ AddUniqueString(extractionInfo.Paths, s);
+ #endif
+ DirectoryPath = s;
+ #ifndef NO_REGISTRY
+ for(int i = 0; i < _path.GetCount(); i++)
+ if(i != currentItem)
+ {
+ UString sTemp;
+ _path.GetLBText(i, sTemp);
+ sTemp.Trim();
+ AddUniqueString(extractionInfo.Paths, sTemp);
+ }
+ SaveExtractionInfo(extractionInfo);
+ #endif
+ CModalDialog::OnOK();
+}
+
+/*
+void CExtractDialog::UpdateWildCardState()
+{
+ // UpdateData(TRUE);
+ // m_Wildcards.EnableWindow(BoolToBOOL(m_Files == kWildcardsButtonIndex));
+}
+*/
+
+#ifndef NO_REGISTRY
+static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/extract.htm";
+void CExtractDialog::OnHelp()
+{
+ ShowHelpWindow(NULL, kHelpTopic);
+ CModalDialog::OnHelp();
+}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.h
new file mode 100644
index 000000000..6ac82f740
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.h
@@ -0,0 +1,77 @@
+// ExtractDialog.h
+
+#ifndef __EXTRACTDIALOG_H
+#define __EXTRACTDIALOG_H
+
+#include "ExtractDialogRes.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/Edit.h"
+#include "Windows/Control/ComboBox.h"
+
+#ifndef NO_REGISTRY
+#include "../Common/ZipRegistry.h"
+#endif
+#include "../Common/ExtractMode.h"
+
+namespace NExtractionDialog
+{
+ /*
+ namespace NFilesMode
+ {
+ enum EEnum
+ {
+ kSelected,
+ kAll,
+ kSpecified
+ };
+ }
+ */
+}
+
+class CExtractDialog: public NWindows::NControl::CModalDialog
+{
+ #ifdef NO_REGISTRY
+ NWindows::NControl::CDialogChildControl _path;
+ #else
+ NWindows::NControl::CComboBox _path;
+ #endif
+
+ #ifndef _SFX
+ NWindows::NControl::CEdit _passwordControl;
+ #endif
+
+ #ifndef _SFX
+ void GetPathMode();
+ void SetPathMode();
+ void GetOverwriteMode();
+ void SetOverwriteMode();
+ // int GetFilesMode() const;
+ void UpdatePasswordControl();
+ #endif
+
+ void OnButtonSetPath();
+
+ virtual bool OnInit();
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ virtual void OnOK();
+ #ifndef NO_REGISTRY
+ virtual void OnHelp();
+ #endif
+public:
+ // bool _enableSelectedFilesButton;
+ // bool _enableFilesButton;
+ // NExtractionDialog::NFilesMode::EEnum FilesMode;
+
+ UString DirectoryPath;
+ #ifndef _SFX
+ UString Password;
+ #endif
+ NExtract::NPathMode::EEnum PathMode;
+ NExtract::NOverwriteMode::EEnum OverwriteMode;
+
+ INT_PTR Create(HWND aWndParent = 0)
+ { return CModalDialog::Create(IDD_DIALOG_EXTRACT, aWndParent); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialogRes.h
new file mode 100644
index 000000000..bc45ed239
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialogRes.h
@@ -0,0 +1,28 @@
+#define IDD_DIALOG_EXTRACT 137
+
+#define IDC_STATIC_EXTRACT_EXTRACT_TO 1020
+#define IDC_EXTRACT_COMBO_PATH 1021
+#define IDC_EXTRACT_BUTTON_SET_PATH 1022
+
+
+#define IDC_EXTRACT_PATH_MODE 1040
+#define IDC_EXTRACT_RADIO_FULL_PATHNAMES 1041
+#define IDC_EXTRACT_RADIO_CURRENT_PATHNAMES 1042
+#define IDC_EXTRACT_RADIO_NO_PATHNAMES 1043
+
+#define IDC_EXTRACT_OVERWRITE_MODE 1050
+#define IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE 1051
+#define IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT 1052
+#define IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES 1053
+#define IDC_EXTRACT_RADIO_SELECTED_FILES 1054
+#define IDC_EXTRACT_RADIO_ALL_FILES 1055
+#define IDC_EXTRACT_RADIO_AUTO_RENAME 1056
+#define IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING 1057
+
+
+#define IDC_EXTRACT_FILES 1060
+
+#define IDC_EXTRACT_PASSWORD 1100
+#define IDC_EXTRACT_EDIT_PASSWORD 1101
+#define IDC_EXTRACT_CHECK_SHOW_PASSWORD 1102
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog_rc.cpp
new file mode 100644
index 000000000..3e3b1c166
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog_rc.cpp
@@ -0,0 +1,145 @@
+// ExtractDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "ExtractRes.h"
+#include "ExtractDialogRes.h"
+
+/*
+IDD_DIALOG_EXTRACT DIALOG DISCARDABLE 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
+CAPTION "Extract"
+MY_FONT
+BEGIN
+ LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, marg, marg, xSize2, 8
+
+ COMBOBOX IDC_EXTRACT_COMBO_PATH, marg, 21, xSize2 - bDotsSize - 13, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+
+ PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xSize - marg - bDotsSize, 20, bDotsSize, bYSize, WS_GROUP
+
+ GROUPBOX "Path mode",IDC_EXTRACT_PATH_MODE, marg, 44, g1XSize, 57
+ CONTROL "Full pathnames", IDC_EXTRACT_RADIO_FULL_PATHNAMES,"Button", BS_AUTORADIOBUTTON | WS_GROUP,
+ g1XPos2, 57, g1XSize2, 10
+ CONTROL "Current pathnames",IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, "Button", BS_AUTORADIOBUTTON,
+ g1XPos2, 71, g1XSize2, 10
+ CONTROL "No pathnames", IDC_EXTRACT_RADIO_NO_PATHNAMES, "Button", BS_AUTORADIOBUTTON,
+ g1XPos2, 85, g1XSize2, 10
+
+ GROUPBOX "Overwrite mode",IDC_EXTRACT_OVERWRITE_MODE, g2XPos, 44, g2XSize, 88, WS_GROUP
+ CONTROL "Ask before overwrite", IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, "Button", BS_AUTORADIOBUTTON | WS_GROUP,
+ g2XPos2, 57, g2XSize2, 10
+ CONTROL "Overwrite without prompt", IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, "Button", BS_AUTORADIOBUTTON,
+ g2XPos2, 71, g2XSize2, 10
+ CONTROL "Skip existing files", IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, "Button", BS_AUTORADIOBUTTON,
+ g2XPos2, 85, g2XSize2, 10
+ CONTROL "Auto rename", IDC_EXTRACT_RADIO_AUTO_RENAME, "Button", BS_AUTORADIOBUTTON,
+ g2XPos2, 99, g2XSize2, 10
+ CONTROL "Auto rename existing files", IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, "Button", BS_AUTORADIOBUTTON,
+ g2XPos2,113, g2XSize2, 10
+
+ GROUPBOX "Files",IDC_EXTRACT_FILES, marg, 140, 127, 48, NOT WS_VISIBLE | WS_DISABLED | WS_GROUP
+ CONTROL "&Selected files",IDC_EXTRACT_RADIO_SELECTED_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_GROUP,
+ g1XPos2, 153, g1XSize2, 10
+ CONTROL "&All files",IDC_EXTRACT_RADIO_ALL_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED,
+ g1XPos2, 166, g1XSize2, 10
+
+ GROUPBOX "Password",IDC_EXTRACT_PASSWORD, g2XPos, 142, g2XSize, 46
+ EDITTEXT IDC_EXTRACT_EDIT_PASSWORD,154,153,130,14, ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Show Password",IDC_EXTRACT_CHECK_SHOW_PASSWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ g2XPos2, 172, g2XSize2, 10
+
+ DEFPUSHBUTTON "OK", IDOK, bXPos3, bYPos, bXSize, bYSize, WS_GROUP
+ PUSHBUTTON "Cancel", IDCANCEL, bXPos2, bYPos, bXSize, bYSize
+ PUSHBUTTON "Help", IDHELP, bXPos1, bYPos, bXSize, bYSize
+END
+*/
+
+
+class CExtractDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CExtractDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Extract"))
+ {
+ wxStaticText *m_pStaticTextExtractTo;
+ wxTextCtrl *m_pTextCtrlPassword;
+ wxButton *m_pButtonBrowse;
+ wxComboBox *m_pComboBoxExtractTo;
+ wxCheckBox *m_pCheckBoxShowPassword;
+
+
+ ///Sizer for adding the controls created by users
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ wxArrayString pathArray;
+ m_pStaticTextExtractTo = new wxStaticText(this, IDC_STATIC_EXTRACT_EXTRACT_TO, wxT("E&xtract To:"));
+ wxBoxSizer *pPathSizer = new wxBoxSizer(wxHORIZONTAL);
+ m_pComboBoxExtractTo = new wxComboBox(this, IDC_EXTRACT_COMBO_PATH, wxEmptyString, wxDefaultPosition, wxDefaultSize, pathArray, wxCB_DROPDOWN|wxCB_SORT);
+ m_pButtonBrowse = new wxButton(this, IDC_EXTRACT_BUTTON_SET_PATH, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pPathSizer->Add(m_pComboBoxExtractTo, 1, wxLEFT|wxRIGHT|wxEXPAND, 5);
+ pPathSizer->Add(m_pButtonBrowse, 0, wxLEFT|wxRIGHT|wxEXPAND, 5);
+
+ wxBoxSizer *pControlSizer = new wxBoxSizer(wxHORIZONTAL);
+
+ wxStaticBoxSizer * grpPathMode = new wxStaticBoxSizer(new wxStaticBox(this,IDC_EXTRACT_PATH_MODE,_T("Path mode")),wxVERTICAL);
+ grpPathMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_FULL_PATHNAMES, wxT("Full pathnames"),wxDefaultPosition, wxDefaultSize, wxRB_GROUP ) , 0 );
+ grpPathMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, wxT("Current pathnames"),wxDefaultPosition, wxDefaultSize) , 0 );
+ grpPathMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_NO_PATHNAMES, wxT("no pathnames"),wxDefaultPosition, wxDefaultSize) , 0 );
+
+ wxBoxSizer *pRightSizer = new wxBoxSizer(wxVERTICAL);
+
+ wxStaticBoxSizer * grpOverWriteMode = new wxStaticBoxSizer(new wxStaticBox(this,IDC_EXTRACT_OVERWRITE_MODE,wxT("Overwrite mode")),wxVERTICAL);
+ grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, wxT("Ask before overwrite"),wxDefaultPosition, wxDefaultSize, wxRB_GROUP) , 1 );
+ grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, wxT("Overwrite without prompt"),wxDefaultPosition, wxDefaultSize) , 1 );
+ grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, wxT("Skip existing files"),wxDefaultPosition, wxDefaultSize) , 1 );
+ grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_AUTO_RENAME, wxT("Auto rename"),wxDefaultPosition, wxDefaultSize) , 1 );
+ grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, wxT("Auto rename existing files"),wxDefaultPosition, wxDefaultSize) , 1 );
+
+ wxStaticBoxSizer *pPasswordSizer = new wxStaticBoxSizer(new wxStaticBox(this,IDC_EXTRACT_PASSWORD,wxT("Password mode")),wxVERTICAL);
+
+ m_pTextCtrlPassword = new wxTextCtrl(this, IDC_EXTRACT_EDIT_PASSWORD, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
+ m_pCheckBoxShowPassword = new wxCheckBox(this, IDC_EXTRACT_CHECK_SHOW_PASSWORD, wxT("Show Password"));
+ pPasswordSizer->Add(m_pTextCtrlPassword, 0, wxALL|wxEXPAND, 5);
+ pPasswordSizer->Add(m_pCheckBoxShowPassword, 0, wxALL|wxEXPAND, 5);
+
+ pRightSizer->Add(grpOverWriteMode, 1, wxALL|wxEXPAND, 5);
+ pRightSizer->Add(pPasswordSizer, 0, wxALL|wxEXPAND, 5);
+
+ pControlSizer->Add(grpPathMode, 1, wxALL|wxEXPAND, 5);
+ pControlSizer->Add(pRightSizer, 1, wxLEFT | wxRIGHT | wxEXPAND, 5);
+
+ topsizer->Add(m_pStaticTextExtractTo, 0, wxALL | wxEXPAND , 10);
+ topsizer->Add(pPathSizer, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND , 5);
+ topsizer->Add(pControlSizer, 1, wxALL | wxEXPAND , 5);
+ topsizer->Add(CreateButtonSizer(wxOK | wxCANCEL | wxHELP), 0, wxALL | wxEXPAND , 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+REGISTER_DIALOG(IDD_DIALOG_EXTRACT,CExtractDialog,0)
+
+BEGIN_EVENT_TABLE(CExtractDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+END_EVENT_TABLE()
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.cpp
new file mode 100644
index 000000000..2f3663b0d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.cpp
@@ -0,0 +1,230 @@
+// ExtractGUI.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/Thread.h"
+
+#include "../FileManager/ExtractCallback.h"
+#include "../FileManager/FormatUtils.h"
+#include "../FileManager/LangUtils.h"
+
+#include "../Common/ArchiveExtractCallback.h"
+#include "../Common/PropIDUtils.h"
+
+#include "../Explorer/MyMessages.h"
+
+#include "resource.h"
+#include "ExtractRes.h"
+#include "ExtractDialog.h"
+#include "ExtractGUI.h"
+
+using namespace NWindows;
+
+static const wchar_t *kIncorrectOutDir = L"Incorrect output directory path";
+
+struct CThreadExtracting
+{
+ CCodecs *codecs;
+ CExtractCallbackImp *ExtractCallbackSpec;
+ CIntVector FormatIndices;
+
+ UStringVector *ArchivePaths;
+ UStringVector *ArchivePathsFull;
+ const NWildcard::CCensorNode *WildcardCensor;
+ const CExtractOptions *Options;
+ CMyComPtr<IExtractCallbackUI> ExtractCallback;
+ CDecompressStat Stat;
+ UString ErrorMessage;
+ HRESULT Result;
+
+ DWORD Process()
+ {
+ ExtractCallbackSpec->ProgressDialog.WaitCreating();
+ try
+ {
+ Result = DecompressArchives(
+ codecs, FormatIndices,
+ *ArchivePaths, *ArchivePathsFull,
+ *WildcardCensor, *Options, ExtractCallbackSpec, ExtractCallback, ErrorMessage, Stat);
+ }
+ catch(const UString &s)
+ {
+ ErrorMessage = s;
+ Result = E_FAIL;
+ }
+ catch(const wchar_t *s)
+ {
+ ErrorMessage = s;
+ Result = E_FAIL;
+ }
+ catch(const char *s)
+ {
+ ErrorMessage = GetUnicodeString(s);
+ Result = E_FAIL;
+ }
+ catch(...)
+ {
+ Result = E_FAIL;
+ }
+ ExtractCallbackSpec->ProgressDialog.MyClose();
+ return 0;
+ }
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ return ((CThreadExtracting *)param)->Process();
+ }
+};
+
+#ifndef _SFX
+
+static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s)
+{
+ wchar_t sz[32];
+ s += LangString(resourceID, langID);
+ s += L" ";
+ ConvertUInt64ToString(value, sz);
+ s += sz;
+ s += L"\n";
+}
+
+static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s)
+{
+ wchar_t sz[32];
+ s += LangString(resourceID, langID);
+ s += L" ";
+ ConvertUInt64ToString(value, sz);
+ s += sz;
+ ConvertUInt64ToString(value >> 20, sz);
+ s += L" (";
+ s += sz;
+ s += L" MB)";
+ s += L"\n";
+}
+
+#endif
+
+HRESULT ExtractGUI(
+ CCodecs *codecs,
+ const CIntVector &formatIndices,
+ UStringVector &archivePaths,
+ UStringVector &archivePathsFull,
+ const NWildcard::CCensorNode &wildcardCensor,
+ CExtractOptions &options,
+ bool showDialog,
+ CExtractCallbackImp *extractCallback)
+{
+ CThreadExtracting extracter;
+ extracter.codecs = codecs;
+ extracter.FormatIndices = formatIndices;
+
+ if (!options.TestMode)
+ {
+ UString outputDir = options.OutputDir;
+ if (outputDir.IsEmpty())
+ NFile::NDirectory::MyGetCurrentDirectory(outputDir);
+ if (showDialog)
+ {
+ CExtractDialog dialog;
+ if (!NFile::NDirectory::MyGetFullPathName(outputDir, dialog.DirectoryPath))
+ {
+ ShowErrorMessage(kIncorrectOutDir);
+ return E_FAIL;
+ }
+ NFile::NName::NormalizeDirPathPrefix(dialog.DirectoryPath);
+#ifndef _WIN32
+ {
+ extern const TCHAR * nameWindowToUnix(const TCHAR * lpFileName);
+ UString tmpDirectoryPath = dialog.DirectoryPath;
+ dialog.DirectoryPath = nameWindowToUnix(tmpDirectoryPath);
+ }
+#endif
+
+
+ // dialog.OverwriteMode = options.OverwriteMode;
+ // dialog.PathMode = options.PathMode;
+
+ if(dialog.Create(0) != IDOK)
+ return E_ABORT;
+ outputDir = dialog.DirectoryPath;
+ options.OverwriteMode = dialog.OverwriteMode;
+ options.PathMode = dialog.PathMode;
+ #ifndef _SFX
+ extractCallback->Password = dialog.Password;
+ extractCallback->PasswordIsDefined = !dialog.Password.IsEmpty();
+ #endif
+ }
+ if (!NFile::NDirectory::MyGetFullPathName(outputDir, options.OutputDir))
+ {
+ ShowErrorMessage(kIncorrectOutDir);
+ return E_FAIL;
+ }
+ NFile::NName::NormalizeDirPathPrefix(options.OutputDir);
+
+ /*
+ if(!NFile::NDirectory::CreateComplexDirectory(options.OutputDir))
+ {
+ UString s = GetUnicodeString(NError::MyFormatMessage(GetLastError()));
+ UString s2 = MyFormatNew(IDS_CANNOT_CREATE_FOLDER,
+ #ifdef LANG
+ 0x02000603,
+ #endif
+ options.OutputDir);
+ MyMessageBox(s2 + UString(L"\n") + s);
+ return E_FAIL;
+ }
+ */
+ }
+
+ UString title = LangStringSpec(options.TestMode ? IDS_PROGRESS_TESTING : IDS_PROGRESS_EXTRACTING,
+ options.TestMode ? 0x02000F90: 0x02000890);
+
+ extracter.ExtractCallbackSpec = extractCallback;
+ extracter.ExtractCallback = extractCallback;
+ extracter.ExtractCallbackSpec->Init();
+
+ extracter.ArchivePaths = &archivePaths;
+ extracter.ArchivePathsFull = &archivePathsFull;
+ extracter.WildcardCensor = &wildcardCensor;
+ extracter.Options = &options;
+
+ NWindows::CThread thread;
+ RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &extracter));
+ extracter.ExtractCallbackSpec->StartProgressDialog(title);
+ if (extracter.Result == S_OK && options.TestMode &&
+ extracter.ExtractCallbackSpec->Messages.IsEmpty() &&
+ extracter.ExtractCallbackSpec->NumArchiveErrors == 0)
+ {
+ #ifndef _SFX
+ UString s;
+ AddValuePair(IDS_ARCHIVES_COLON, 0x02000324, extracter.Stat.NumArchives, s);
+ AddValuePair(IDS_FOLDERS_COLON, 0x02000321, extracter.Stat.NumFolders, s);
+ AddValuePair(IDS_FILES_COLON, 0x02000320, extracter.Stat.NumFiles, s);
+ AddSizePair(IDS_SIZE_COLON, 0x02000322, extracter.Stat.UnpackSize, s);
+ AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, extracter.Stat.PackSize, s);
+
+ if (options.CalcCrc)
+ {
+ wchar_t temp[16];
+ ConvertUInt32ToHex(extracter.Stat.CrcSum, temp);
+ s += L"CRC: ";
+ s += temp;
+ s += L"\n";
+ }
+
+ s += L"\n";
+ s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608);
+
+ MessageBoxW(0, s, LangString(IDS_PROGRESS_TESTING, 0x02000F90), 0);
+ #endif
+ }
+ if (extracter.Result != S_OK)
+ if (!extracter.ErrorMessage.IsEmpty())
+ throw extracter.ErrorMessage;
+ return extracter.Result;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.h
new file mode 100644
index 000000000..ffefabfe0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.h
@@ -0,0 +1,20 @@
+// GUI/ExtractGUI.h
+
+#ifndef __EXTRACT_GUI_H
+#define __EXTRACT_GUI_H
+
+#include "../Common/Extract.h"
+
+#include "../FileManager/ExtractCallback.h"
+
+HRESULT ExtractGUI(
+ CCodecs *codecs,
+ const CIntVector &formatIndices,
+ UStringVector &archivePaths,
+ UStringVector &archivePathsFull,
+ const NWildcard::CCensorNode &wildcardCensor,
+ CExtractOptions &options,
+ bool showDialog,
+ CExtractCallbackImp *extractCallback);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractRes.h
new file mode 100644
index 000000000..084181ea4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractRes.h
@@ -0,0 +1,19 @@
+#define IDS_UPDATE_NOT_SUPPORTED 199
+#define IDS_CANNOT_CREATE_FOLDER 200
+#define IDS_OPEN_IS_NOT_SUPORTED_ARCHIVE 201
+
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC 202
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR 203
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD 204
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED 205
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED 206
+
+#define IDS_EXTRACT_SET_FOLDER 207
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CANNOT_OPEN_FILE 208
+#define IDS_PROGRESS_EXTRACTING 209
+
+#define IDS_CANT_OPEN_ARCHIVE 103
+#define IDS_CANT_OPEN_ENCRYPTED_ARCHIVE 104
+#define IDS_MEM_ERROR 105
+#define IDS_UNKNOWN_ERROR 106
+#define IDS_UNSUPPORTED_ARCHIVE_TYPE 107
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/GUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/GUI.cpp
new file mode 100644
index 000000000..d01e958b3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/GUI.cpp
@@ -0,0 +1,294 @@
+// GUI.cpp
+
+#include "StdAfx.h"
+
+#include <initguid.h>
+
+#include "../../../../C/Alloc.h"
+
+#include "Common/CommandLineParser.h"
+#include "Common/MyException.h"
+#include "Common/NewHandler.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Error.h"
+#ifdef _WIN32
+#include "Windows/MemoryLock.h"
+#endif
+
+#include "../Common/ArchiveCommandLine.h"
+#include "../Common/ExitCode.h"
+
+#include "../FileManager/StringUtils.h"
+
+#include "BenchmarkDialog.h"
+#include "ExtractGUI.h"
+#include "UpdateGUI.h"
+
+#include "ExtractRes.h"
+
+using namespace NWindows;
+
+HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
+
+static void ErrorMessage(LPCWSTR message)
+{
+ MessageBoxW(NULL, message, L"7-Zip", MB_ICONERROR | MB_OK);
+}
+
+static void ErrorLangMessage(UINT resourceID, UInt32 langID)
+{
+ ErrorMessage(LangString(resourceID, langID));
+}
+
+static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
+
+static int ShowMemErrorMessage()
+{
+ ErrorLangMessage(IDS_MEM_ERROR, 0x0200060B);
+ return NExitCode::kMemoryError;
+}
+
+static int ShowSysErrorMessage(DWORD errorCode)
+{
+ if (errorCode == E_OUTOFMEMORY)
+ return ShowMemErrorMessage();
+ ErrorMessage(NError::MyFormatMessageW(errorCode));
+ return NExitCode::kFatalError;
+}
+
+int Main2(int argc,TCHAR **argv)
+{
+ UStringVector commandStrings;
+ #ifdef _WIN32
+ NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
+ #else
+ extern void mySplitCommandLineW(int numArguments,TCHAR **arguments,UStringVector &parts);
+ mySplitCommandLineW(argc,argv,commandStrings);
+ #endif
+
+ if (commandStrings.Size() <= 1)
+ {
+ MessageBoxW(0, L"Specify command", L"7-Zip", 0);
+ return 0;
+ }
+ commandStrings.Delete(0);
+
+ CArchiveCommandLineOptions options;
+ CArchiveCommandLineParser parser;
+
+ parser.Parse1(commandStrings, options);
+ parser.Parse2(options);
+
+ #ifdef _WIN32
+ if (options.LargePages)
+ NSecurity::EnableLockMemoryPrivilege();
+ #endif
+
+ CCodecs *codecs = new CCodecs;
+ CMyComPtr<IUnknown> compressCodecsInfo = codecs;
+ HRESULT result = codecs->Load();
+ if (result != S_OK)
+ throw CSystemException(result);
+
+ bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
+ if (codecs->Formats.Size() == 0 &&
+ (isExtractGroupCommand ||
+ options.Command.IsFromUpdateGroup()))
+ throw kNoFormats;
+
+ CIntVector formatIndices;
+ if (!codecs->FindFormatForArchiveType(options.ArcType, formatIndices))
+ {
+ ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE, 0x0200060D);
+ return NExitCode::kFatalError;
+ }
+
+ if (options.Command.CommandType == NCommandType::kBenchmark)
+ {
+ HRESULT res = Benchmark(
+ #ifdef EXTERNAL_LZMA
+ codecs,
+ #endif
+ options.NumThreads, options.DictionarySize);
+ if (res != S_OK)
+ throw CSystemException(res);
+ }
+ else if (isExtractGroupCommand)
+ {
+ CExtractCallbackImp *ecs = new CExtractCallbackImp;
+ CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
+ ecs->ProgressDialog.CompressingMode = false;
+
+ #ifndef _NO_CRYPTO
+ ecs->PasswordIsDefined = options.PasswordEnabled;
+ ecs->Password = options.Password;
+ #endif
+
+ ecs->Init();
+
+ CExtractOptions eo;
+ eo.StdOutMode = options.StdOutMode;
+ eo.OutputDir = options.OutputDir;
+ eo.YesToAll = options.YesToAll;
+ eo.OverwriteMode = options.OverwriteMode;
+ eo.PathMode = options.Command.GetPathMode();
+ eo.TestMode = options.Command.IsTestMode();
+ eo.CalcCrc = options.CalcCrc;
+ #ifdef COMPRESS_MT
+ eo.Properties = options.ExtractProperties;
+ #endif
+
+ HRESULT result = ExtractGUI(codecs, formatIndices,
+ options.ArchivePathsSorted,
+ options.ArchivePathsFullSorted,
+ options.WildcardCensor.Pairs.Front().Head,
+ eo, options.ShowDialog, ecs);
+ if (result != S_OK)
+ throw CSystemException(result);
+ if (ecs->Messages.Size() > 0 || ecs->NumArchiveErrors != 0)
+ return NExitCode::kFatalError;
+ }
+ else if (options.Command.IsFromUpdateGroup())
+ {
+ #ifndef _NO_CRYPTO
+ bool passwordIsDefined = options.PasswordEnabled && !options.Password.IsEmpty();
+ #endif
+
+ CUpdateCallbackGUI callback;
+ // callback.EnablePercents = options.EnablePercents;
+
+ #ifndef _NO_CRYPTO
+ callback.PasswordIsDefined = passwordIsDefined;
+ callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
+ callback.Password = options.Password;
+ #endif
+
+ // callback.StdOutMode = options.UpdateOptions.StdOutMode;
+ callback.Init();
+
+ CUpdateErrorInfo errorInfo;
+
+ if (!options.UpdateOptions.Init(codecs, formatIndices, options.ArchiveName))
+ {
+ ErrorLangMessage(IDS_UPDATE_NOT_SUPPORTED, 0x02000601);
+ return NExitCode::kFatalError;
+ }
+ HRESULT result = UpdateGUI(
+ codecs,
+ options.WildcardCensor, options.UpdateOptions,
+ options.ShowDialog,
+ errorInfo, &callback);
+
+ if (result != S_OK)
+ {
+ if (!errorInfo.Message.IsEmpty())
+ {
+ ErrorMessage(errorInfo.Message);
+ if (result == E_FAIL)
+ return NExitCode::kFatalError;
+ }
+ throw CSystemException(result);
+ }
+ if (callback.FailedFiles.Size() > 0)
+ return NExitCode::kWarning;
+ }
+ else
+ {
+ throw "Unsupported command";
+ }
+ return 0;
+}
+
+#ifdef _WIN32
+static bool inline IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+
+int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */)
+{
+ g_hInstance = hInstance;
+ #ifdef _UNICODE
+ if (!IsItWindowsNT())
+ {
+ ErrorMessage(L"This program requires Windows NT/2000/2003/2008/XP/Vista");
+ return NExitCode::kFatalError;
+ }
+ #else
+ g_IsNT = IsItWindowsNT();
+ #endif
+
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+
+ InitCommonControls();
+
+ ReloadLang();
+
+ // setlocale(LC_COLLATE, ".ACP");
+ try
+ {
+ return Main2();
+ }
+#else
+int Main1(int argc,TCHAR **argv)
+{
+ ReloadLangSmart(); // ReloadLang();
+
+ // setlocale(LC_COLLATE, ".ACP");
+ try
+ {
+ return Main2(argc,argv);
+ }
+#endif
+ catch(const CNewException &)
+ {
+ return ShowMemErrorMessage();
+ }
+ catch(const CArchiveCommandLineException &e)
+ {
+ ErrorMessage(GetUnicodeString(e));
+ return NExitCode::kUserError;
+ }
+ catch(const CSystemException &systemError)
+ {
+ if (systemError.ErrorCode == E_ABORT)
+ return NExitCode::kUserBreak;
+ return ShowSysErrorMessage(systemError.ErrorCode);
+ }
+ catch(const UString &s)
+ {
+ ErrorMessage(s);
+ return NExitCode::kFatalError;
+ }
+ catch(const AString &s)
+ {
+ ErrorMessage(GetUnicodeString(s));
+ return NExitCode::kFatalError;
+ }
+ catch(const wchar_t *s)
+ {
+ ErrorMessage(s);
+ return NExitCode::kFatalError;
+ }
+ catch(const char *s)
+ {
+ ErrorMessage(GetUnicodeString(s));
+ return NExitCode::kFatalError;
+ }
+ catch(...)
+ {
+ ErrorLangMessage(IDS_UNKNOWN_ERROR, 0x0200060C);
+ return NExitCode::kFatalError;
+ }
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp
new file mode 100644
index 000000000..07c74e9b5
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp
@@ -0,0 +1,256 @@
+// UpdateCallbackGUI.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Defs.h"
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Error.h"
+#include "Windows/PropVariant.h"
+
+#include "../FileManager/MessagesDialog.h"
+#include "../FileManager/PasswordDialog.h"
+
+#include "UpdateCallbackGUI.h"
+
+using namespace NWindows;
+
+CUpdateCallbackGUI::~CUpdateCallbackGUI()
+{
+ if (!Messages.IsEmpty())
+ {
+ CMessagesDialog messagesDialog;
+ messagesDialog.Messages = &Messages;
+ messagesDialog.Create(ParentWindow);
+ }
+}
+
+void CUpdateCallbackGUI::Init()
+{
+ FailedFiles.Clear();
+ Messages.Clear();
+ NumArchiveErrors = 0;
+ NumFiles = 0;
+}
+
+void CUpdateCallbackGUI::AddErrorMessage(LPCWSTR message)
+{
+ Messages.Add(message);
+}
+
+void CUpdateCallbackGUI::AddErrorMessage(const wchar_t *name, DWORD systemError)
+{
+ AddErrorMessage(
+ UString(L"WARNING: ") +
+ NError::MyFormatMessageW(systemError) +
+ UString(L": ") +
+ UString(name));
+}
+
+HRESULT CUpdateCallbackGUI::OpenResult(const wchar_t *name, HRESULT result)
+{
+ if (result != S_OK)
+ {
+ AddErrorMessage (UString(L"Error: ") + name +
+ UString(L" is not supported archive"));
+ }
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::StartScanning()
+{
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::CanNotFindError(const wchar_t *name, DWORD systemError)
+{
+ FailedFiles.Add(name);
+ AddErrorMessage(name, systemError);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::FinishScanning()
+{
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::StartArchive(const wchar_t *name, bool /* updating */)
+{
+ ProgressDialog.ProgressSynch.SetTitleFileName(name);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::FinishArchive()
+{
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::CheckBreak()
+{
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+HRESULT CUpdateCallbackGUI::ScanProgress(UInt64 /* numFolders */, UInt64 numFiles, const wchar_t *path)
+{
+ ProgressDialog.ProgressSynch.SetCurrentFileName(path);
+ ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles);
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+HRESULT CUpdateCallbackGUI::Finilize()
+{
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::SetNumFiles(UInt64 numFiles)
+{
+ ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::SetTotal(UInt64 total)
+{
+ ProgressDialog.ProgressSynch.SetProgress(total, 0);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::SetCompleted(const UInt64 *completeValue)
+{
+ RINOK(CheckBreak());
+ if (completeValue != NULL)
+ ProgressDialog.ProgressSynch.SetPos(*completeValue);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ RINOK(CheckBreak());
+ ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::GetStream(const wchar_t *name, bool /* isAnti */)
+{
+ ProgressDialog.ProgressSynch.SetCurrentFileName(name);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::OpenFileError(const wchar_t *name, DWORD systemError)
+{
+ FailedFiles.Add(name);
+ // if (systemError == ERROR_SHARING_VIOLATION)
+ {
+ AddErrorMessage(name, systemError);
+ return S_FALSE;
+ }
+ // return systemError;
+}
+
+HRESULT CUpdateCallbackGUI::SetOperationResult(Int32 /* operationResult */)
+{
+ NumFiles++;
+ ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ *password = NULL;
+ if (!PasswordIsDefined)
+ {
+ if (AskPassword)
+ {
+ CPasswordDialog dialog;
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
+ return E_ABORT;
+ Password = dialog.Password;
+ PasswordIsDefined = true;
+ }
+ }
+ *passwordIsDefined = BoolToInt(PasswordIsDefined);
+ return StringToBstr(Password, password);
+}
+
+HRESULT CUpdateCallbackGUI::CryptoGetTextPassword(BSTR *password)
+{
+ *password = NULL;
+ if (!PasswordIsDefined)
+ {
+ CPasswordDialog dialog;
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
+ return E_ABORT;
+ Password = dialog.Password;
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
+
+/*
+It doesn't work, since main stream waits Dialog
+HRESULT CUpdateCallbackGUI::CloseProgress()
+{
+ ProgressDialog.MyClose();
+ return S_OK;
+};
+*/
+
+
+HRESULT CUpdateCallbackGUI::Open_CheckBreak()
+{
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+HRESULT CUpdateCallbackGUI::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT CUpdateCallbackGUI::Open_CryptoGetTextPassword(BSTR *password)
+{
+ PasswordWasAsked = true;
+ if (!PasswordIsDefined)
+ {
+ CPasswordDialog dialog;
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
+ return E_ABORT;
+ Password = dialog.Password;
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
+
+HRESULT CUpdateCallbackGUI::Open_GetPasswordIfAny(UString &password)
+{
+ if (PasswordIsDefined)
+ password = Password;
+ return S_OK;
+}
+
+bool CUpdateCallbackGUI::Open_WasPasswordAsked()
+{
+ return PasswordWasAsked;
+}
+
+void CUpdateCallbackGUI::Open_ClearPasswordWasAskedFlag()
+{
+ PasswordWasAsked = false;
+}
+
+/*
+HRESULT CUpdateCallbackGUI::ShowDeleteFile(const wchar_t *name)
+{
+ ProgressDialog.ProgressSynch.SetCurrentFileName(name);
+ return S_OK;
+}
+*/
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.h
new file mode 100644
index 000000000..1f8b70e09
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.h
@@ -0,0 +1,53 @@
+// UpdateCallbackGUI.h
+
+#ifndef __UPDATE_CALLBACK_GUI_H
+#define __UPDATE_CALLBACK_GUI_H
+
+#include "../Common/Update.h"
+#include "../Common/ArchiveOpenCallback.h"
+#include "../FileManager/ProgressDialog2.h"
+
+class CUpdateCallbackGUI:
+ public IOpenCallbackUI,
+ public IUpdateCallbackUI2
+{
+public:
+ // bool StdOutMode;
+ bool PasswordIsDefined;
+ UString Password;
+ bool AskPassword;
+ bool PasswordWasAsked;
+ UInt64 NumFiles;
+
+ CUpdateCallbackGUI():
+ PasswordIsDefined(false),
+ PasswordWasAsked(false),
+ AskPassword(false),
+ // StdOutMode(false)
+ ParentWindow(0)
+ {}
+
+ ~CUpdateCallbackGUI();
+ void Init();
+
+ INTERFACE_IUpdateCallbackUI2(;)
+ INTERFACE_IOpenCallbackUI(;)
+
+ // HRESULT CloseProgress();
+
+ UStringVector FailedFiles;
+
+ CProgressDialog ProgressDialog;
+ HWND ParentWindow;
+ void StartProgressDialog(const UString &title)
+ {
+ ProgressDialog.Create(title, ParentWindow);
+ }
+
+ UStringVector Messages;
+ int NumArchiveErrors;
+ void AddErrorMessage(LPCWSTR message);
+ void AddErrorMessage(const wchar_t *name, DWORD systemError);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.cpp
new file mode 100644
index 000000000..2d4dbbc2c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.cpp
@@ -0,0 +1,389 @@
+// UpdateGUI.cpp
+
+#include "StdAfx.h"
+
+#include "UpdateGUI.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/Thread.h"
+
+#include "../Common/WorkDir.h"
+
+#include "../Explorer/MyMessages.h"
+
+#include "../FileManager/StringUtils.h"
+
+#include "CompressDialog.h"
+#include "UpdateGUI.h"
+
+#include "resource.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+static const wchar_t *kDefaultSfxModule = L"7z.sfx";
+static const wchar_t *kSFXExtension = L"exe";
+
+struct CThreadUpdating
+{
+ CCodecs *codecs;
+
+ CUpdateCallbackGUI *UpdateCallbackGUI;
+ const NWildcard::CCensor *WildcardCensor;
+ CUpdateOptions *Options;
+
+ CUpdateErrorInfo *ErrorInfo;
+ HRESULT Result;
+
+ DWORD Process()
+ {
+ UpdateCallbackGUI->ProgressDialog.WaitCreating();
+ try
+ {
+ Result = UpdateArchive(codecs, *WildcardCensor, *Options,
+ *ErrorInfo, UpdateCallbackGUI, UpdateCallbackGUI);
+ }
+ catch(const UString &s)
+ {
+ ErrorInfo->Message = s;
+ Result = E_FAIL;
+ }
+ catch(const wchar_t *s)
+ {
+ ErrorInfo->Message = s;
+ Result = E_FAIL;
+ }
+ catch(const char *s)
+ {
+ ErrorInfo->Message = GetUnicodeString(s);
+ Result = E_FAIL;
+ }
+ catch(...)
+ {
+ Result = E_FAIL;
+ }
+ UpdateCallbackGUI->ProgressDialog.MyClose();
+ return 0;
+ }
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ return ((CThreadUpdating *)param)->Process();
+ }
+};
+
+static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value)
+{
+ CProperty prop;
+ prop.Name = name;
+ prop.Value = value;
+ properties.Add(prop);
+}
+
+static void AddProp(CObjectVector<CProperty> &properties, const UString &name, UInt32 value)
+{
+ wchar_t tmp[32];
+ ConvertUInt64ToString(value, tmp);
+ AddProp(properties, name, tmp);
+}
+
+static void AddProp(CObjectVector<CProperty> &properties, const UString &name, bool value)
+{
+ AddProp(properties, name, value ? UString(L"on"): UString(L"off"));
+}
+
+static bool IsThereMethodOverride(bool is7z, const UString &propertiesString)
+{
+ UStringVector strings;
+ SplitString(propertiesString, strings);
+ for (int i = 0; i < strings.Size(); i++)
+ {
+ const UString &s = strings[i];
+ if (is7z)
+ {
+ const wchar_t *end;
+ UInt64 n = ConvertStringToUInt64(s, &end);
+ if (n == 0 && *end == L'=')
+ return true;
+ }
+ else
+ {
+ if (s.Length() > 0)
+ if (s[0] == L'm' && s[1] == L'=')
+ return true;
+ }
+ }
+ return false;
+}
+
+static void ParseAndAddPropertires(CObjectVector<CProperty> &properties,
+ const UString &propertiesString)
+{
+ UStringVector strings;
+ SplitString(propertiesString, strings);
+ for (int i = 0; i < strings.Size(); i++)
+ {
+ const UString &s = strings[i];
+ CProperty property;
+ int index = s.Find(L'=');
+ if (index < 0)
+ property.Name = s;
+ else
+ {
+ property.Name = s.Left(index);
+ property.Value = s.Mid(index + 1);
+ }
+ properties.Add(property);
+ }
+}
+
+static UString GetNumInBytesString(UInt64 v)
+{
+ wchar_t s[32];
+ ConvertUInt64ToString(v, s);
+ size_t len = wcslen(s);
+ s[len++] = L'B';
+ s[len] = L'\0';
+ return s;
+}
+
+static void SetOutProperties(
+ CObjectVector<CProperty> &properties,
+ bool is7z,
+ UInt32 level,
+ bool setMethod,
+ const UString &method,
+ UInt32 dictionary,
+ bool orderMode,
+ UInt32 order,
+ bool solidIsSpecified, UInt64 solidBlockSize,
+ bool multiThreadIsAllowed, UInt32 numThreads,
+ const UString &encryptionMethod,
+ bool encryptHeadersIsAllowed, bool encryptHeaders,
+ bool /* sfxMode */)
+{
+ if (level != (UInt32)(Int32)-1)
+ AddProp(properties, L"x", (UInt32)level);
+ if (setMethod)
+ {
+ if (!method.IsEmpty())
+ AddProp(properties, is7z ? L"0": L"m", method);
+ if (dictionary != (UInt32)(Int32)-1)
+ {
+ UString name;
+ if (is7z)
+ name = L"0";
+ if (orderMode)
+ name += L"mem";
+ else
+ name += L"d";
+ AddProp(properties, name, GetNumInBytesString(dictionary));
+ }
+ if (order != (UInt32)(Int32)-1)
+ {
+ UString name;
+ if (is7z)
+ name = L"0";
+ if (orderMode)
+ name += L"o";
+ else
+ name += L"fb";
+ AddProp(properties, name, (UInt32)order);
+ }
+ }
+
+ if (!encryptionMethod.IsEmpty())
+ AddProp(properties, L"em", encryptionMethod);
+
+ if (encryptHeadersIsAllowed)
+ AddProp(properties, L"he", encryptHeaders);
+ if (solidIsSpecified)
+ AddProp(properties, L"s", GetNumInBytesString(solidBlockSize));
+ if (multiThreadIsAllowed)
+ AddProp(properties, L"mt", numThreads);
+}
+
+static HRESULT ShowDialog(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
+ CUpdateOptions &options, CUpdateCallbackGUI *callback)
+{
+ if (options.Commands.Size() != 1)
+ throw "It must be one command";
+ UString currentDirPrefix;
+ {
+ if (!NDirectory::MyGetCurrentDirectory(currentDirPrefix))
+ return E_FAIL;
+ NName::NormalizeDirPathPrefix(currentDirPrefix);
+ }
+
+ bool oneFile = false;
+ NFind::CFileInfoW fileInfo;
+ if (censor.Pairs.Size() > 0)
+ {
+ const NWildcard::CPair &pair = censor.Pairs[0];
+ if (pair.Head.IncludeItems.Size() > 0)
+ {
+ const NWildcard::CItem &item = pair.Head.IncludeItems[0];
+ if (item.ForFile)
+ {
+ UString name = pair.Prefix;
+ for (int i = 0; i < item.PathParts.Size(); i++)
+ {
+ if (i > 0)
+ name += WCHAR_PATH_SEPARATOR;
+ name += item.PathParts[i];
+ }
+ if (fileInfo.Find(name))
+ {
+ if (censor.Pairs.Size() == 1 && pair.Head.IncludeItems.Size() == 1)
+ oneFile = !fileInfo.IsDir();
+ }
+ }
+ }
+ }
+
+ CCompressDialog dialog;
+ NCompressDialog::CInfo &di = dialog.Info;
+ for(int i = 0; i < codecs->Formats.Size(); i++)
+ {
+ const CArcInfoEx &ai = codecs->Formats[i];
+ if (ai.UpdateEnabled && (oneFile || !ai.KeepName))
+ dialog.m_ArchiverInfoList.Add(ai);
+ }
+ if(dialog.m_ArchiverInfoList.Size() == 0)
+ {
+ ShowErrorMessage(L"No Update Engines");
+ return E_FAIL;
+ }
+
+ // di.ArchiveName = options.ArchivePath.GetFinalPath();
+ di.ArchiveName = options.ArchivePath.GetPathWithoutExt();
+ dialog.OriginalFileName = fileInfo.Name;
+
+ di.CurrentDirPrefix = currentDirPrefix;
+ di.SFXMode = options.SfxMode;
+ di.OpenShareForWrite = options.OpenShareForWrite;
+
+ if (callback->PasswordIsDefined)
+ di.Password = callback->Password;
+
+ di.KeepName = !oneFile;
+
+ if(dialog.Create(0) != IDOK)
+ return E_ABORT;
+
+ options.VolumesSizes = di.VolumeSizes;
+ /*
+ if (di.VolumeSizeIsDefined)
+ {
+ MyMessageBox(L"Splitting to volumes is not supported");
+ return E_FAIL;
+ }
+ */
+
+ NUpdateArchive::CActionSet &actionSet = options.Commands.Front().ActionSet;
+
+ switch(di.UpdateMode)
+ {
+ case NCompressDialog::NUpdateMode::kAdd:
+ actionSet = NUpdateArchive::kAddActionSet;
+ break;
+ case NCompressDialog::NUpdateMode::kUpdate:
+ actionSet = NUpdateArchive::kUpdateActionSet;
+ break;
+ case NCompressDialog::NUpdateMode::kFresh:
+ actionSet = NUpdateArchive::kFreshActionSet;
+ break;
+ case NCompressDialog::NUpdateMode::kSynchronize:
+ actionSet = NUpdateArchive::kSynchronizeActionSet;
+ break;
+ default:
+ throw 1091756;
+ }
+ const CArcInfoEx &archiverInfo = dialog.m_ArchiverInfoList[di.ArchiverInfoIndex];
+ callback->PasswordIsDefined = (!di.Password.IsEmpty());
+ if (callback->PasswordIsDefined)
+ callback->Password = di.Password;
+
+ options.MethodMode.Properties.Clear();
+
+ bool is7z = archiverInfo.Name.CompareNoCase(L"7z") == 0;
+ bool methodOverride = IsThereMethodOverride(is7z, di.Options);
+
+ SetOutProperties(
+ options.MethodMode.Properties,
+ is7z,
+ di.Level,
+ !methodOverride,
+ di.Method,
+ di.Dictionary,
+ di.OrderMode, di.Order,
+ di.SolidIsSpecified, di.SolidBlockSize,
+ di.MultiThreadIsAllowed, di.NumThreads,
+ di.EncryptionMethod,
+ di.EncryptHeadersIsAllowed, di.EncryptHeaders,
+ di.SFXMode);
+
+ options.OpenShareForWrite = di.OpenShareForWrite;
+ ParseAndAddPropertires(options.MethodMode.Properties, di.Options);
+
+ if (di.SFXMode)
+ options.SfxMode = true;
+ options.MethodMode.FormatIndex = archiverInfo.FormatIndex;
+
+ options.ArchivePath.VolExtension = archiverInfo.GetMainExt();
+ if(di.SFXMode)
+ options.ArchivePath.BaseExtension = kSFXExtension;
+ else
+ options.ArchivePath.BaseExtension = options.ArchivePath.VolExtension;
+ options.ArchivePath.ParseFromPath(di.ArchiveName);
+
+ NWorkDir::CInfo workDirInfo;
+ ReadWorkDirInfo(workDirInfo);
+ options.WorkingDir.Empty();
+ if (workDirInfo.Mode != NWorkDir::NMode::kCurrent)
+ {
+ UString fullPath;
+ NDirectory::MyGetFullPathName(di.ArchiveName, fullPath);
+ options.WorkingDir = GetWorkDir(workDirInfo, fullPath);
+ NDirectory::CreateComplexDirectory(options.WorkingDir);
+ }
+ return S_OK;
+}
+
+HRESULT UpdateGUI(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
+ CUpdateOptions &options,
+ bool showDialog,
+ CUpdateErrorInfo &errorInfo,
+ CUpdateCallbackGUI *callback)
+{
+ if (showDialog)
+ {
+ RINOK(ShowDialog(codecs, censor, options, callback));
+ }
+ if (options.SfxMode && options.SfxModule.IsEmpty())
+ options.SfxModule = kDefaultSfxModule;
+
+ CThreadUpdating tu;
+
+ tu.codecs = codecs;
+
+ tu.UpdateCallbackGUI = callback;
+ tu.UpdateCallbackGUI->Init();
+
+ tu.WildcardCensor = &censor;
+ tu.Options = &options;
+ tu.ErrorInfo = &errorInfo;
+
+ NWindows::CThread thread;
+ RINOK(thread.Create(CThreadUpdating::MyThreadFunction, &tu))
+ tu.UpdateCallbackGUI->StartProgressDialog(LangString(IDS_PROGRESS_COMPRESSING, 0x02000DC0));
+ return tu.Result;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.h
new file mode 100644
index 000000000..112eff0ff
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.h
@@ -0,0 +1,19 @@
+// GUI/UpdateGUI.h
+
+#ifndef __UPDATE_GUI_H
+#define __UPDATE_GUI_H
+
+#include "../Common/Update.h"
+#include "UpdateCallbackGUI.h"
+
+#include "../FileManager/UpdateCallback100.h"
+
+HRESULT UpdateGUI(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
+ CUpdateOptions &options,
+ bool showDialog,
+ CUpdateErrorInfo &errorInfo,
+ CUpdateCallbackGUI *callback);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/resource.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/resource.h
new file mode 100644
index 000000000..e154e035f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/resource.h
@@ -0,0 +1,49 @@
+#define IDS_CONTEXT_EXTRACT 142
+#define IDS_CONTEXT_EXTRACT_HELP 143
+#define IDS_CONTEXT_COMPRESS 144
+#define IDS_CONTEXT_COMPRESS_HELP 145
+#define IDS_CONTEXT_OPEN 146
+#define IDS_CONTEXT_OPEN_HELP 147
+#define IDS_CONTEXT_TEST 148
+#define IDS_CONTEXT_TEST_HELP 149
+#define IDS_CONTEXT_CAPTION_HELP 150
+#define IDS_CONTEXT_POPUP_CAPTION 151
+#define IDS_OPEN_TYPE_ALL_FILES 80
+
+#define IDS_METHOD_STORE 81
+#define IDS_METHOD_NORMAL 82
+#define IDS_METHOD_MAXIMUM 83
+#define IDS_METHOD_FAST 84
+#define IDS_METHOD_FASTEST 85
+#define IDS_METHOD_ULTRA 86
+
+#define IDS_COMPRESS_NON_SOLID 88
+#define IDS_COMPRESS_SOLID 89
+
+#define IDS_COMPRESS_UPDATE_MODE_ADD 90
+#define IDS_COMPRESS_UPDATE_MODE_UPDATE 91
+#define IDS_COMPRESS_UPDATE_MODE_FRESH 92
+#define IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE 93
+
+#define IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE 94
+#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95
+
+#define IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE 96
+#define IDS_CANT_UPDATE_ARCHIVE 97
+
+#define IDS_PROGRESS_COMPRESSING 98
+#define IDS_PROGRESS_TESTING 99
+#define IDS_ERROR 100
+#define IDS_MESSAGE_NO_ERRORS 101
+#define IDS_CONFIG_DIALOG_CAPTION 102
+
+#define IDS_PASSWORD_USE_ASCII 110
+#define IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH 111
+#define IDS_PASSWORD_IS_TOO_LONG 112
+
+#define IDS_FILES_COLON 2274
+#define IDS_FOLDERS_COLON 2275
+#define IDS_SIZE_COLON 2276
+#define IDS_COMPRESSED_COLON 2277
+#define IDS_ARCHIVES_COLON 2278
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/wxGUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/wxGUI.cpp
new file mode 100644
index 000000000..366bd40c4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/wxGUI.cpp
@@ -0,0 +1,575 @@
+// wxGUI.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#define static const
+#include "../GUI/p7zip_32.xpm"
+#undef static
+
+#undef ACTIVATE_DIALOG_TESTS
+
+int Main1(int argc,TCHAR **argv);
+
+#include "Windows/Registry.h"
+using namespace NWindows;
+using namespace NRegistry;
+
+
+#include "Common/StringConvert.h"
+#include "Windows/FileDir.h"
+#include "Windows/Synchronization.h"
+
+#include "ExtractRes.h"
+#include "../Explorer/MyMessages.h"
+
+#include "ExtractGUI.h"
+#include "UpdateGUI.h"
+#include "BenchmarkDialog.h"
+#include "../FileManager/RegistryUtils.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+#include "../FileManager/ProgramLocation.h"
+
+static LPCWSTR kHelpFileName = L"help/";
+
+void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
+{
+ UString path;
+ if (!::GetProgramFolderPath(path))
+ return;
+ path += kHelpFileName;
+ path += topicFile;
+ printf("ShowHelpWindow(%p,%ls)=>%ls\n",hwnd,topicFile,(const wchar_t *)path);
+ // HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);
+ wxString path2(path);
+ wxLaunchDefaultBrowser(path2);
+}
+
+////////////////////////////// TRIES ///////////////////////////////////
+
+#ifdef ACTIVATE_DIALOG_TESTS
+static void ErrorMessage(const wchar_t *message)
+{
+ MessageBox(0,message, wxT("7-Zip GUI"),wxICON_ERROR);
+}
+
+#include "../FileManager/PasswordDialog.h"
+#include "../FileManager/MessagesDialog.h"
+#include "../FileManager/OverwriteDialog.h"
+#include "Windows/Thread.h"
+
+void myErrorMsg(const wchar_t *message)
+{
+ MessageBox(0,message, wxT("Message"),wxICON_ERROR);
+}
+
+void testCMessagesDialog()
+{
+ UStringVector Messages;
+
+ Messages.Add(L"message 1");
+ Messages.Add(L"message 2");
+ Messages.Add(L"message 3");
+ Messages.Add(L"message 4");
+ Messages.Add(L"message 5");
+ Messages.Add(L"message 6");
+ Messages.Add(L"message 7");
+ Messages.Add(L"message 8");
+ Messages.Add(L"message 9");
+
+ CMessagesDialog messagesDialog;
+ messagesDialog.Messages = &Messages;
+ int ret = messagesDialog.Create( 0 ); // ParentWindow
+
+ if (ret == IDOK) myErrorMsg(wxT("CMessagesDialog => IDOK"));
+ else if (ret == IDCANCEL) myErrorMsg(wxT("CMessagesDialog => IDCANCEL"));
+ else myErrorMsg(wxT("CMessagesDialog => ?"));
+
+}
+
+void testCOverwriteDialog()
+{
+SYSTEMTIME systemTime;
+GetSystemTime( &systemTime );
+
+
+const wchar_t *existName = L"existName";
+FILETIME data_existTime;
+FILETIME *existTime = &data_existTime ;
+UInt64 data_existSize = 1234;
+UInt64 *existSize = &data_existSize;
+const wchar_t *newName = L"newName";
+FILETIME data_newTime;
+FILETIME *newTime = &data_newTime;
+UInt64 data_newSize = 45678;
+UInt64 *newSize = &data_newSize;
+Int32 data_answer=0;
+Int32 *answer = &data_answer;
+
+SystemTimeToFileTime( &systemTime , &data_existTime);
+SystemTimeToFileTime( &systemTime , &data_newTime);
+
+ COverwriteDialog dialog;
+
+ dialog.OldFileInfo.Time = *existTime;
+ dialog.OldFileInfo.TimeIsDefined = true; // FIXME : look again at the sample !
+
+ dialog.OldFileInfo.SizeIsDefined = (existSize != NULL);
+ if (dialog.OldFileInfo.SizeIsDefined)
+ dialog.OldFileInfo.Size = *existSize;
+ dialog.OldFileInfo.Name = existName;
+
+ if (newTime == 0)
+ dialog.NewFileInfo.TimeIsDefined = false;
+ else
+ {
+ dialog.NewFileInfo.TimeIsDefined = true;
+ dialog.NewFileInfo.Time = *newTime;
+ }
+
+ dialog.NewFileInfo.SizeIsDefined = (newSize != NULL);
+ if (dialog.NewFileInfo.SizeIsDefined)
+ dialog.NewFileInfo.Size = *newSize;
+ dialog.NewFileInfo.Name = newName;
+
+ /*
+ NOverwriteDialog::NResult::EEnum writeAnswer =
+ NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
+ */
+ INT_PTR writeAnswer = dialog.Create(NULL); // ParentWindow doesn't work with 7z
+
+ switch(writeAnswer)
+ {
+ case IDCANCEL: myErrorMsg(wxT("COverwriteDialog => IDCANCEL")); break;
+ case IDNO: myErrorMsg(wxT("COverwriteDialog => IDNO")); break;
+ case IDC_BUTTON_OVERWRITE_NO_TO_ALL: myErrorMsg(wxT("COverwriteDialog => IDC_BUTTON_OVERWRITE_NO_TO_ALL")); break;
+ case IDC_BUTTON_OVERWRITE_YES_TO_ALL:myErrorMsg(wxT("COverwriteDialog => IDC_BUTTON_OVERWRITE_YES_TO_ALL")); break;
+ case IDC_BUTTON_OVERWRITE_AUTO_RENAME:myErrorMsg(wxT("COverwriteDialog => IDC_BUTTON_OVERWRITE_AUTO_RENAME")); break;
+ case IDYES: myErrorMsg(wxT("COverwriteDialog => IDYES")); break;
+ default: myErrorMsg(wxT("COverwriteDialog => default")); break;
+ }
+}
+
+void testCPasswordDialog()
+{
+ CPasswordDialog dialog;
+
+ int ret = dialog.Create(0);
+ if (ret == IDOK) {
+ UString Password = dialog.Password;
+ UString msg = wxT("CPasswordDialog => IDOK password=\"");
+ msg += Password;
+ msg += wxT("\"");
+ myErrorMsg(msg);
+ }
+ else if (ret == IDCANCEL) myErrorMsg(wxT("CPasswordDialog => IDCANCEL"));
+ else myErrorMsg(wxT("CPasswordDialog => ?"));
+
+}
+
+struct CThreadProgressDialog
+{
+ CProgressDialog * ProgressDialog;
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadProgressDialog *)param)->Result = ((CThreadProgressDialog *)param)->Process();
+ return 0;
+ }
+ HRESULT Result;
+ HRESULT Process()
+ {
+ Sleep(1000);
+ int total = 1000;
+
+ ProgressDialog->ProgressSynch.SetTitleFileName(L"SetTitleFileName");
+ ProgressDialog->ProgressSynch.SetNumFilesTotal(100);
+ ProgressDialog->ProgressSynch.SetNumFilesCur(1);
+ ProgressDialog->ProgressSynch.SetProgress(total, 0);
+ // ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize);
+ // ProgressDialog.ProgressSynch.SetCurrentFileName(name);
+
+ ProgressDialog->ProgressSynch.SetPos(total/10);
+ ProgressDialog->ProgressSynch.SetCurrentFileName(L"File1");
+ Sleep(1000);
+ ProgressDialog->ProgressSynch.SetPos(total/2);
+ ProgressDialog->ProgressSynch.SetCurrentFileName(L"File2");
+ Sleep(1000);
+ ProgressDialog->ProgressSynch.SetPos(total);
+ ProgressDialog->ProgressSynch.SetCurrentFileName(L"File3");
+ Sleep(1000);
+ ProgressDialog->MyClose();
+ return 0;
+ }
+};
+
+void testCProgressDialog()
+{
+ CProgressDialog ProgressDialog;
+
+ CThreadProgressDialog benchmarker;
+ benchmarker.ProgressDialog = &ProgressDialog;
+ NWindows::CThread thread;
+ thread.Create(CThreadProgressDialog::MyThreadFunction, &benchmarker);
+
+ // void StartProgressDialog(const UString &title)
+ int ret = ProgressDialog.Create(L"testCProgressDialog", 0);
+
+ if (ret == IDOK) myErrorMsg(wxT("CProgressDialog => IDOK"));
+ else if (ret == IDCANCEL) myErrorMsg(wxT("CProgressDialog => IDCANCEL"));
+ else myErrorMsg(wxT("CProgressDialog => ?"));
+
+}
+
+void testDialog(int num)
+{
+ NWindows::NControl::CModalDialog dialog;
+
+ printf("Generic Dialog(%d)\n",num);
+ int ret = dialog.Create(num, 0);
+ if (ret == IDOK) myErrorMsg(wxT("Generic Dialog => IDOK"));
+ else if (ret == IDCANCEL) myErrorMsg(wxT("Generic Dialog => IDCANCEL"));
+ else myErrorMsg(wxT("Generic Dialog => ?"));
+}
+
+void testMessageBox()
+{
+ int ret = MessageBoxW(0, L"test yes/no/cancel",
+ L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL);
+ if (ret == IDYES) myErrorMsg(wxT("MessageBoxW => IDYES"));
+ else if (ret == IDNO) myErrorMsg(wxT("MessageBoxW => IDNO"));
+ else if (ret == IDCANCEL) myErrorMsg(wxT("MessageBoxW => IDCANCEL"));
+ else myErrorMsg(wxT("MessageBoxW => ?"));
+}
+
+static void testRegistry()
+{
+ SaveRegLang(L"fr");
+
+ UString langFile;
+ ReadRegLang(langFile);
+
+ printf("testRegistry : -%ls-\n",(const wchar_t *)langFile);
+}
+
+
+int Main2(int argc,TCHAR **argv);
+
+int Main3(int argc,wxChar **argv)
+{
+ testRegistry();
+
+ int num = -1;
+
+ if (argc >=2 )
+ {
+ num = argv[1][0] - L'0';
+ }
+ printf("num=%d\n",num);
+
+
+ switch(num)
+ {
+ case 0:
+ {
+ TCHAR **argv2 = (TCHAR **)calloc(argc,sizeof(*argv));
+
+ argv2[0] = argv[0];
+ for(int i = 2; i < argc; i++) argv2[i-1] = argv[i];
+
+ return Main2(argc-1,argv2);
+ }
+ // TODO Benchmark
+ // TODO CCompressDialog
+ // TODO CExtractDialog ?
+ case 1 : testCMessagesDialog(); break;
+ case 2 : testCOverwriteDialog(); break;
+ case 3 : testCPasswordDialog(); break;
+ case 4 : testCProgressDialog(); break;
+ case 5 : testMessageBox(); break;
+ case 9 :
+ if (argc >= 3)
+ {
+ AString str = GetAnsiString(argv[2]);
+ int num = atoi((const char*)str);
+ testDialog(num);
+ }
+ else
+ {
+ printf("usage : 7zG 9 <windowID>\n");
+ }
+ break;
+ default :
+ printf("usage : 7zG number\n");
+
+ };
+
+ return 0;
+}
+
+#endif // ACTIVATE_DIALOG_TESTS
+
+static const TCHAR *kCUBasePath = TEXT("Software/7-ZIP");
+static const WCHAR *kLangValueName = L"Lang";
+
+void SaveRegLang(const UString &langFile)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(kLangValueName, langFile);
+}
+
+void ReadRegLang(UString &langFile)
+{
+ langFile.Empty();
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
+ key.QueryValue(kLangValueName, langFile);
+}
+
+
+//////////////////////////////////
+
+#define NEED_NAME_WINDOWS_TO_UNIX
+#include "myPrivate.h" // global_use_utf16_conversion
+
+void mySplitCommandLineW(int numArguments, TCHAR **arguments,UStringVector &parts) {
+
+ parts.Clear();
+ for(int ind=0;ind < numArguments; ind++) {
+ UString tmp = arguments[ind];
+ // tmp.Trim(); " " is a valid filename ...
+ if (!tmp.IsEmpty()) {
+ parts.Add(tmp);
+// DEBUG printf("ARG %d : '%ls'\n",ind,(const wchar_t *)tmp);
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+// private classes
+// ----------------------------------------------------------------------------
+
+// Define a new frame type
+class MyFrame: public wxFrame
+{
+public:
+ // ctor
+ MyFrame(wxFrame *frame, const wxString& title, int x, int y, int w, int h);
+ // virtual ~MyFrame();
+
+ // operations
+ void WriteText(const wxString& text) { m_txtctrl->WriteText(text); }
+
+protected:
+ // callbacks
+ void OnWorkerEvent(wxCommandEvent& event);
+private:
+ // just some place to put our messages in
+ wxTextCtrl *m_txtctrl;
+ DECLARE_EVENT_TABLE()
+};
+
+enum {
+ WORKER_EVENT=100 // this one gets sent from the worker thread
+};
+
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ EVT_MENU(WORKER_EVENT, MyFrame::OnWorkerEvent)
+ // EVT_IDLE(MyFrame::OnIdle)
+END_EVENT_TABLE()
+
+// My frame constructor
+MyFrame::MyFrame(wxFrame *frame, const wxString& title,
+ int x, int y, int w, int h)
+ : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
+{
+ this->SetIcon(wxICON(p7zip_32));
+
+#if wxUSE_STATUSBAR
+ CreateStatusBar(2);
+#endif // wxUSE_STATUSBAR
+
+ m_txtctrl = new wxTextCtrl(this, wxID_ANY, _T(""), wxPoint(0, 0), wxSize(0, 0), wxTE_MULTILINE | wxTE_READONLY);
+}
+
+void myCreateHandle(int n);
+wxWindow * g_window=0;
+
+void MyFrame::OnWorkerEvent(wxCommandEvent& event)
+{
+ int n = event.GetInt();
+ myCreateHandle(n);
+}
+
+
+// Define a new application type, each program should derive a class from wxApp
+class MyApp : public wxApp
+{
+public:
+ // override base class virtuals
+ // ----------------------------
+
+ // this one is called on application startup and is a good place for the app
+ // initialization (doing it here and not in the ctor allows to have an error
+ // return: if OnInit() returns false, the application terminates)
+ virtual bool OnInit();
+};
+
+// Create a new application object: this macro will allow wxWidgets to create
+// the application object during program execution (it's better than using a
+// static object for many reasons) and also implements the accessor function
+// wxGetApp() which will return the reference of the right type (i.e. MyApp and
+// not wxApp)
+IMPLEMENT_APP(MyApp)
+
+time_t g_T0 = 0;
+class MyThread : public wxThread
+{
+ int _argc;
+ TCHAR **_argv;
+public:
+ MyThread(int argc,TCHAR **argv): wxThread(),_argc(argc), _argv(argv) {}
+
+ // thread execution starts here
+ virtual void *Entry()
+ {
+#ifdef ACTIVATE_DIALOG_TESTS
+ int ret = Main3(_argc,_argv);
+#else
+ int ret = Main1(_argc,_argv);
+#endif
+ exit(ret);
+ }
+};
+
+// 'Main program' equivalent: the program execution "starts" here
+bool MyApp::OnInit()
+{
+ // don't parse the command-line options !
+ // : if ( !wxApp::OnInit() ) return false;
+
+ { // define P7ZIP_HOME_DIR
+ extern void my_windows_split_path(const AString &p_path, AString &dir , AString &base);
+ static char p7zip_home_dir[MAX_PATH];
+
+ UString fullPath;
+ NDirectory::MyGetFullPathName(wxApp::argv[0], fullPath);
+ AString afullPath = GetAnsiString(fullPath);
+
+ AString dir,name;
+
+ my_windows_split_path(afullPath,dir,name);
+
+ const char *dir2 = nameWindowToUnix((const char *)dir);
+ snprintf(p7zip_home_dir,sizeof(p7zip_home_dir),"P7ZIP_HOME_DIR=%s/",dir2);
+ p7zip_home_dir[sizeof(p7zip_home_dir)-1] = 0;
+ putenv(p7zip_home_dir);
+ // DEBUG printf("putenv(%s)\n",p7zip_home_dir);
+ }
+ global_use_utf16_conversion = 1; // UNICODE !
+
+ g_T0 = time(0);
+ // DEBUG printf("MAIN Thread : 0x%lx\n",wxThread::GetCurrentId());
+
+ // Create the main frame window
+ MyFrame *frame = new MyFrame((wxFrame *)NULL, _T("7-zip Main Window"), 50, 50, 450, 340);
+ // Don't Show the frame !
+ // frame->Show(true);
+
+ SetTopWindow(frame);
+
+ g_window = frame;
+
+ MyThread *thread = new MyThread(wxApp::argc,wxApp::argv);
+ thread->Create(); // != wxTHREAD_NO_ERROR
+ thread->Run();
+
+ // success: wxApp::OnRun() will be called which will enter the main message
+ // loop and the application will run. If we returned false here, the
+ // application would exit immediately.
+ return true;
+}
+
+DWORD WINAPI GetTickCount(VOID) {
+ static wxStopWatch sw;
+ return sw.Time();
+}
+
+//////////////////////////////////////////
+
+#include "resource.h"
+#include "ExtractRes.h"
+
+static CStringTable g_stringTable[] =
+{
+ /* resource.rc */
+ /***************/
+ { IDS_OPEN_TYPE_ALL_FILES, L"All Files" },
+ { IDS_METHOD_STORE, L"Store" },
+ { IDS_METHOD_NORMAL, L"Normal" },
+ { IDS_METHOD_MAXIMUM, L"Maximum" },
+ { IDS_METHOD_FAST, L"Fast" },
+ { IDS_METHOD_FASTEST, L"Fastest" },
+ { IDS_METHOD_ULTRA, L"Ultra" },
+ { IDS_COMPRESS_NON_SOLID, L"Non-solid" },
+ { IDS_COMPRESS_SOLID, L"Solid" },
+
+ { IDS_COMPRESS_UPDATE_MODE_ADD, L"Add and replace files" },
+ { IDS_COMPRESS_UPDATE_MODE_UPDATE, L"Update and add files" },
+ { IDS_COMPRESS_UPDATE_MODE_FRESH, L"Freshen existing files" },
+ { IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE, L"Synchronize files" },
+ { IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, L"Browse" },
+ { IDS_COMPRESS_INCORRECT_VOLUME_SIZE, L"Incorrect volume size" },
+ { IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, L"Specified volume size: {0} bytes.\nAre you sure you want to split archive into such volumes?" },
+
+ { IDS_PASSWORD_USE_ASCII, L"Use only English letters, numbers and special characters (!, #, $, ...) for password." },
+ { IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH, L"Passwords do not match" },
+ { IDS_PASSWORD_IS_TOO_LONG, L"Password is too long" },
+
+ { IDS_PROGRESS_COMPRESSING, L"Compressing" },
+ { IDS_PROGRESS_TESTING, L"Testing" },
+ { IDS_MESSAGE_NO_ERRORS, L"There are no errors" },
+ { IDS_FILES_COLON, L"Files:" },
+ { IDS_FOLDERS_COLON, L"Folders:" },
+ { IDS_SIZE_COLON, L"Size:" },
+ { IDS_COMPRESSED_COLON, L"Compressed size:" },
+ { IDS_ARCHIVES_COLON, L"Archives:" },
+
+ /* Extract.rc */
+ /**************/
+ { IDS_CANNOT_CREATE_FOLDER , L"Cannot create folder '{0}'"},
+ { IDS_OPEN_IS_NOT_SUPORTED_ARCHIVE, L"File is not supported archive."},
+
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC , L"CRC failed in '{0}'. File is broken."},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR , L"Data error in '{0}'. File is broken"},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD , L"Unsupported compression method for '{0}'."},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED , L"CRC failed in encrypted file '{0}'. Wrong password?"},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED , L"Data error in encrypted file '{0}'. Wrong password?"},
+
+ { IDS_EXTRACT_SET_FOLDER , L"Specify a location for extracted files."},
+ { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CANNOT_OPEN_FILE, L"Can not open output file '{0}'."},
+ { IDS_PROGRESS_EXTRACTING, L"Extracting" },
+
+ { IDS_CANT_OPEN_ARCHIVE , L"Can not open file '{0}' as archive"},
+ { IDS_CANT_OPEN_ENCRYPTED_ARCHIVE , L"Can not open encrypted archive '{0}'. Wrong password?"},
+
+ { 0 , 0 }
+};
+
+REGISTER_STRINGTABLE(g_stringTable)
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/AutoPtr.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/AutoPtr.h
new file mode 100644
index 000000000..006d31551
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/AutoPtr.h
@@ -0,0 +1,35 @@
+// Common/AutoPtr.h
+
+#ifndef __COMMON_AUTOPTR_H
+#define __COMMON_AUTOPTR_H
+
+template<class T> class CMyAutoPtr
+{
+ T *_p;
+public:
+ CMyAutoPtr(T *p = 0) : _p(p) {}
+ CMyAutoPtr(CMyAutoPtr<T>& p): _p(p.release()) {}
+ CMyAutoPtr<T>& operator=(CMyAutoPtr<T>& p)
+ {
+ reset(p.release());
+ return (*this);
+ }
+ ~CMyAutoPtr() { delete _p; }
+ T& operator*() const { return *_p; }
+ // T* operator->() const { return (&**this); }
+ T* get() const { return _p; }
+ T* release()
+ {
+ T *tmp = _p;
+ _p = 0;
+ return tmp;
+ }
+ void reset(T* p = 0)
+ {
+ if (p != _p)
+ delete _p;
+ _p = p;
+ }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Buffer.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Buffer.h
new file mode 100644
index 000000000..b6960fa8a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Buffer.h
@@ -0,0 +1,77 @@
+// Common/Buffer.h
+
+#ifndef __COMMON_BUFFER_H
+#define __COMMON_BUFFER_H
+
+#include "Defs.h"
+
+template <class T> class CBuffer
+{
+protected:
+ size_t _capacity;
+ T *_items;
+public:
+ void Free()
+ {
+ delete []_items;
+ _items = 0;
+ _capacity = 0;
+ }
+ CBuffer(): _capacity(0), _items(0) {};
+ CBuffer(const CBuffer &buffer): _capacity(0), _items(0) { *this = buffer; }
+ CBuffer(size_t size): _items(0), _capacity(0) { SetCapacity(size); }
+ virtual ~CBuffer() { delete []_items; }
+ operator T *() { return _items; };
+ operator const T *() const { return _items; };
+ size_t GetCapacity() const { return _capacity; }
+ void SetCapacity(size_t newCapacity)
+ {
+ if (newCapacity == _capacity)
+ return;
+ T *newBuffer;
+ if (newCapacity > 0)
+ {
+ newBuffer = new T[newCapacity];
+ if (_capacity > 0)
+ memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T));
+ }
+ else
+ newBuffer = 0;
+ delete []_items;
+ _items = newBuffer;
+ _capacity = newCapacity;
+ }
+ CBuffer& operator=(const CBuffer &buffer)
+ {
+ Free();
+ if (buffer._capacity > 0)
+ {
+ SetCapacity(buffer._capacity);
+ memmove(_items, buffer._items, buffer._capacity * sizeof(T));
+ }
+ return *this;
+ }
+};
+
+template <class T>
+bool operator==(const CBuffer<T>& b1, const CBuffer<T>& b2)
+{
+ if (b1.GetCapacity() != b2.GetCapacity())
+ return false;
+ for (size_t i = 0; i < b1.GetCapacity(); i++)
+ if (b1[i] != b2[i])
+ return false;
+ return true;
+}
+
+template <class T>
+bool operator!=(const CBuffer<T>& b1, const CBuffer<T>& b2)
+{
+ return !(b1 == b2);
+}
+
+typedef CBuffer<char> CCharBuffer;
+typedef CBuffer<wchar_t> CWCharBuffer;
+typedef CBuffer<unsigned char> CByteBuffer;
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CRC.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CRC.cpp
new file mode 100644
index 000000000..9a9f81fb7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CRC.cpp
@@ -0,0 +1,7 @@
+// Common/CRC.cpp
+
+#include "StdAfx.h"
+
+#include "../../C/7zCrc.h"
+
+struct CCRCTableInit { CCRCTableInit() { CrcGenerateTable(); } } g_CRCTableInit;
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/C_FileIO.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/C_FileIO.cpp
new file mode 100644
index 000000000..b4893d658
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/C_FileIO.cpp
@@ -0,0 +1,88 @@
+// Common/C_FileIO.h
+
+#include "C_FileIO.h"
+
+#include <fcntl.h>
+#include <unistd.h>
+
+namespace NC {
+namespace NFile {
+namespace NIO {
+
+bool CFileBase::OpenBinary(const char *name, int flags)
+{
+ #ifdef O_BINARY
+ flags |= O_BINARY;
+ #endif
+ Close();
+ _handle = ::open(name, flags, 0666);
+ return _handle != -1;
+}
+
+bool CFileBase::Close()
+{
+ if (_handle == -1)
+ return true;
+ if (close(_handle) != 0)
+ return false;
+ _handle = -1;
+ return true;
+}
+
+bool CFileBase::GetLength(UInt64 &length) const
+{
+ off_t curPos = Seek(0, SEEK_CUR);
+ off_t lengthTemp = Seek(0, SEEK_END);
+ Seek(curPos, SEEK_SET);
+ length = (UInt64)lengthTemp;
+ return true;
+}
+
+off_t CFileBase::Seek(off_t distanceToMove, int moveMethod) const
+{
+ return ::lseek(_handle, distanceToMove, moveMethod);
+}
+
+/////////////////////////
+// CInFile
+
+bool CInFile::Open(const char *name)
+{
+ return CFileBase::OpenBinary(name, O_RDONLY);
+}
+
+bool CInFile::OpenShared(const char *name, bool)
+{
+ return Open(name);
+}
+
+ssize_t CInFile::Read(void *data, size_t size)
+{
+ return read(_handle, data, size);
+}
+
+/////////////////////////
+// COutFile
+
+bool COutFile::Create(const char *name, bool createAlways)
+{
+ if (createAlways)
+ {
+ Close();
+ _handle = ::creat(name, 0666);
+ return _handle != -1;
+ }
+ return OpenBinary(name, O_CREAT | O_EXCL | O_WRONLY);
+}
+
+bool COutFile::Open(const char *name, DWORD creationDisposition)
+{
+ return Create(name, false);
+}
+
+ssize_t COutFile::Write(const void *data, size_t size)
+{
+ return write(_handle, data, size);
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/C_FileIO.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/C_FileIO.h
new file mode 100644
index 000000000..27aa56869
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/C_FileIO.h
@@ -0,0 +1,47 @@
+// Common/C_FileIO.h
+
+#ifndef __COMMON_C_FILEIO_H
+#define __COMMON_C_FILEIO_H
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "Types.h"
+#include "MyWindows.h"
+
+namespace NC {
+namespace NFile {
+namespace NIO {
+
+class CFileBase
+{
+protected:
+ int _handle;
+ bool OpenBinary(const char *name, int flags);
+public:
+ CFileBase(): _handle(-1) {};
+ ~CFileBase() { Close(); }
+ bool Close();
+ bool GetLength(UInt64 &length) const;
+ off_t Seek(off_t distanceToMove, int moveMethod) const;
+};
+
+class CInFile: public CFileBase
+{
+public:
+ bool Open(const char *name);
+ bool OpenShared(const char *name, bool shareForWrite);
+ ssize_t Read(void *data, size_t size);
+};
+
+class COutFile: public CFileBase
+{
+public:
+ bool Create(const char *name, bool createAlways);
+ bool Open(const char *name, DWORD creationDisposition);
+ ssize_t Write(const void *data, size_t size);
+};
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ComTry.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ComTry.h
new file mode 100644
index 000000000..c061c4cde
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ComTry.h
@@ -0,0 +1,18 @@
+// ComTry.h
+
+#ifndef __COM_TRY_H
+#define __COM_TRY_H
+
+#include "MyWindows.h"
+// #include "Exception.h"
+// #include "NewHandler.h"
+
+#define COM_TRY_BEGIN try {
+#define COM_TRY_END } catch(const char * s) { throw s ; } \
+ catch(...) { return E_OUTOFMEMORY; }
+
+ // catch(const CNewException &) { return E_OUTOFMEMORY; }
+ // catch(const CSystemException &e) { return e.ErrorCode; }
+ // catch(...) { return E_FAIL; }
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CommandLineParser.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CommandLineParser.cpp
new file mode 100644
index 000000000..3a46cc886
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CommandLineParser.cpp
@@ -0,0 +1,233 @@
+// CommandLineParser.cpp
+
+#include "StdAfx.h"
+
+#include "CommandLineParser.h"
+
+namespace NCommandLineParser {
+
+#ifdef _WIN32
+void SplitCommandLine(const UString &src, UString &dest1, UString &dest2)
+{
+ dest1.Empty();
+ dest2.Empty();
+ bool quoteMode = false;
+ int i;
+ for (i = 0; i < src.Length(); i++)
+ {
+ wchar_t c = src[i];
+ if (c == L'\"')
+ quoteMode = !quoteMode;
+ else if (c == L' ' && !quoteMode)
+ {
+ i++;
+ break;
+ }
+ else
+ dest1 += c;
+ }
+ dest2 = src.Mid(i);
+}
+
+void SplitCommandLine(const UString &s, UStringVector &parts)
+{
+ UString sTemp = s;
+ sTemp.Trim();
+ parts.Clear();
+ for (;;)
+ {
+ UString s1, s2;
+ SplitCommandLine(sTemp, s1, s2);
+ // s1.Trim();
+ // s2.Trim();
+ if (!s1.IsEmpty())
+ parts.Add(s1);
+ if (s2.IsEmpty())
+ break;
+ sTemp = s2;
+ }
+}
+#endif
+
+static const wchar_t kSwitchID1 = '-';
+// static const wchar_t kSwitchID2 = '/';
+
+static const wchar_t kSwitchMinus = '-';
+static const wchar_t *kStopSwitchParsing = L"--";
+
+static bool IsItSwitchChar(wchar_t c)
+{
+ return (c == kSwitchID1 /*|| c == kSwitchID2 */);
+}
+
+CParser::CParser(int numSwitches):
+ _numSwitches(numSwitches)
+{
+ _switches = new CSwitchResult[_numSwitches];
+}
+
+CParser::~CParser()
+{
+ delete []_switches;
+}
+
+void CParser::ParseStrings(const CSwitchForm *switchForms,
+ const UStringVector &commandStrings)
+{
+ int numCommandStrings = commandStrings.Size();
+ bool stopSwitch = false;
+ for (int i = 0; i < numCommandStrings; i++)
+ {
+ const UString &s = commandStrings[i];
+ if (stopSwitch)
+ NonSwitchStrings.Add(s);
+ else
+ if (s == kStopSwitchParsing)
+ stopSwitch = true;
+ else
+ if (!ParseString(s, switchForms))
+ NonSwitchStrings.Add(s);
+ }
+}
+
+// if string contains switch then function updates switch structures
+// out: (string is a switch)
+bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
+{
+ int len = s.Length();
+ if (len == 0)
+ return false;
+ int pos = 0;
+ if (!IsItSwitchChar(s[pos]))
+ return false;
+ while (pos < len)
+ {
+ if (IsItSwitchChar(s[pos]))
+ pos++;
+ const int kNoLen = -1;
+ int matchedSwitchIndex = 0; // GCC Warning
+ int maxLen = kNoLen;
+ for (int switchIndex = 0; switchIndex < _numSwitches; switchIndex++)
+ {
+ int switchLen = MyStringLen(switchForms[switchIndex].IDString);
+ if (switchLen <= maxLen || pos + switchLen > len)
+ continue;
+
+ UString temp = s + pos;
+ temp = temp.Left(switchLen);
+ if (temp.CompareNoCase(switchForms[switchIndex].IDString) == 0)
+ // if (_strnicmp(switchForms[switchIndex].IDString, LPCSTR(s) + pos, switchLen) == 0)
+ {
+ matchedSwitchIndex = switchIndex;
+ maxLen = switchLen;
+ }
+ }
+ if (maxLen == kNoLen)
+ throw "maxLen == kNoLen";
+ CSwitchResult &matchedSwitch = _switches[matchedSwitchIndex];
+ const CSwitchForm &switchForm = switchForms[matchedSwitchIndex];
+ if ((!switchForm.Multi) && matchedSwitch.ThereIs)
+ throw "switch must be single";
+ matchedSwitch.ThereIs = true;
+ pos += maxLen;
+ int tailSize = len - pos;
+ NSwitchType::EEnum type = switchForm.Type;
+ switch(type)
+ {
+ case NSwitchType::kPostMinus:
+ {
+ if (tailSize == 0)
+ matchedSwitch.WithMinus = false;
+ else
+ {
+ matchedSwitch.WithMinus = (s[pos] == kSwitchMinus);
+ if (matchedSwitch.WithMinus)
+ pos++;
+ }
+ break;
+ }
+ case NSwitchType::kPostChar:
+ {
+ if (tailSize < switchForm.MinLen)
+ throw "switch is not full";
+ UString set = switchForm.PostCharSet;
+ const int kEmptyCharValue = -1;
+ if (tailSize == 0)
+ matchedSwitch.PostCharIndex = kEmptyCharValue;
+ else
+ {
+ int index = set.Find(s[pos]);
+ if (index < 0)
+ matchedSwitch.PostCharIndex = kEmptyCharValue;
+ else
+ {
+ matchedSwitch.PostCharIndex = index;
+ pos++;
+ }
+ }
+ break;
+ }
+ case NSwitchType::kLimitedPostString:
+ case NSwitchType::kUnLimitedPostString:
+ {
+ int minLen = switchForm.MinLen;
+ if (tailSize < minLen)
+ throw "switch is not full";
+ if (type == NSwitchType::kUnLimitedPostString)
+ {
+ matchedSwitch.PostStrings.Add(s.Mid(pos));
+ return true;
+ }
+ int maxLen = switchForm.MaxLen;
+ UString stringSwitch = s.Mid(pos, minLen);
+ pos += minLen;
+ for (int i = minLen; i < maxLen && pos < len; i++, pos++)
+ {
+ wchar_t c = s[pos];
+ if (IsItSwitchChar(c))
+ break;
+ stringSwitch += c;
+ }
+ matchedSwitch.PostStrings.Add(stringSwitch);
+ break;
+ }
+ case NSwitchType::kSimple:
+ break;
+ }
+ }
+ return true;
+}
+
+const CSwitchResult& CParser::operator[](size_t index) const
+{
+ return _switches[index];
+}
+
+/////////////////////////////////
+// Command parsing procedures
+
+int ParseCommand(int numCommandForms, const CCommandForm *commandForms,
+ const UString &commandString, UString &postString)
+{
+ for (int i = 0; i < numCommandForms; i++)
+ {
+ const UString id = commandForms[i].IDString;
+ if (commandForms[i].PostStringMode)
+ {
+ if (commandString.Find(id) == 0)
+ {
+ postString = commandString.Mid(id.Length());
+ return i;
+ }
+ }
+ else
+ if (commandString == id)
+ {
+ postString.Empty();
+ return i;
+ }
+ }
+ return -1;
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CommandLineParser.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CommandLineParser.h
new file mode 100644
index 000000000..6c7226a14
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/CommandLineParser.h
@@ -0,0 +1,72 @@
+// Common/CommandLineParser.h
+
+#ifndef __COMMON_COMMANDLINEPARSER_H
+#define __COMMON_COMMANDLINEPARSER_H
+
+#include "MyString.h"
+
+namespace NCommandLineParser {
+
+void SplitCommandLine(const UString &src, UString &dest1, UString &dest2);
+void SplitCommandLine(const UString &s, UStringVector &parts);
+
+namespace NSwitchType {
+ enum EEnum
+ {
+ kSimple,
+ kPostMinus,
+ kLimitedPostString,
+ kUnLimitedPostString,
+ kPostChar
+ };
+}
+
+struct CSwitchForm
+{
+ const wchar_t *IDString;
+ NSwitchType::EEnum Type;
+ bool Multi;
+ int MinLen;
+ int MaxLen;
+ const wchar_t *PostCharSet;
+};
+
+struct CSwitchResult
+{
+ bool ThereIs;
+ bool WithMinus;
+ UStringVector PostStrings;
+ int PostCharIndex;
+ CSwitchResult(): ThereIs(false) {};
+};
+
+class CParser
+{
+ int _numSwitches;
+ CSwitchResult *_switches;
+ bool ParseString(const UString &s, const CSwitchForm *switchForms);
+public:
+ UStringVector NonSwitchStrings;
+ CParser(int numSwitches);
+ ~CParser();
+ void ParseStrings(const CSwitchForm *switchForms,
+ const UStringVector &commandStrings);
+ const CSwitchResult& operator[](size_t index) const;
+};
+
+/////////////////////////////////
+// Command parsing procedures
+
+struct CCommandForm
+{
+ wchar_t *IDString;
+ bool PostStringMode;
+};
+
+// Returns: Index of form and postString; -1, if there is no match
+int ParseCommand(int numCommandForms, const CCommandForm *commandForms,
+ const UString &commandString, UString &postString);
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Defs.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Defs.h
new file mode 100644
index 000000000..dad3ae8f1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Defs.h
@@ -0,0 +1,20 @@
+// Common/Defs.h
+
+#ifndef __COMMON_DEFS_H
+#define __COMMON_DEFS_H
+
+template <class T> inline T MyMin(T a, T b)
+ { return a < b ? a : b; }
+template <class T> inline T MyMax(T a, T b)
+ { return a > b ? a : b; }
+
+template <class T> inline int MyCompare(T a, T b)
+ { return a < b ? -1 : (a == b ? 0 : 1); }
+
+inline int BoolToInt(bool value)
+ { return (value ? 1: 0); }
+
+inline bool IntToBool(int value)
+ { return (value != 0); }
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/DynamicBuffer.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/DynamicBuffer.h
new file mode 100644
index 000000000..fd33cec3d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/DynamicBuffer.h
@@ -0,0 +1,47 @@
+// Common/DynamicBuffer.h
+
+#ifndef __COMMON_DYNAMICBUFFER_H
+#define __COMMON_DYNAMICBUFFER_H
+
+#include "Buffer.h"
+
+template <class T> class CDynamicBuffer: public CBuffer<T>
+{
+ void GrowLength(size_t size)
+ {
+ size_t delta;
+ if (this->_capacity > 64)
+ delta = this->_capacity / 4;
+ else if (this->_capacity > 8)
+ delta = 16;
+ else
+ delta = 4;
+ delta = MyMax(delta, size);
+ SetCapacity(this->_capacity + delta);
+ }
+public:
+ CDynamicBuffer(): CBuffer<T>() {};
+ CDynamicBuffer(const CDynamicBuffer &buffer): CBuffer<T>(buffer) {};
+ CDynamicBuffer(size_t size): CBuffer<T>(size) {};
+ CDynamicBuffer& operator=(const CDynamicBuffer &buffer)
+ {
+ this->Free();
+ if (buffer._capacity > 0)
+ {
+ SetCapacity(buffer._capacity);
+ memmove(this->_items, buffer._items, buffer._capacity * sizeof(T));
+ }
+ return *this;
+ }
+ void EnsureCapacity(size_t capacity)
+ {
+ if (this->_capacity < capacity)
+ GrowLength(capacity - this->_capacity);
+ }
+};
+
+typedef CDynamicBuffer<char> CCharDynamicBuffer;
+typedef CDynamicBuffer<wchar_t> CWCharDynamicBuffer;
+typedef CDynamicBuffer<unsigned char> CByteDynamicBuffer;
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/IntToString.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/IntToString.cpp
new file mode 100644
index 000000000..31070b411
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/IntToString.cpp
@@ -0,0 +1,66 @@
+// Common/IntToString.cpp
+
+#include "StdAfx.h"
+
+#include "IntToString.h"
+
+void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base)
+{
+ if (base < 2 || base > 36)
+ {
+ *s = '\0';
+ return;
+ }
+ char temp[72];
+ int pos = 0;
+ do
+ {
+ int delta = (int)(value % base);
+ temp[pos++] = (char)((delta < 10) ? ('0' + delta) : ('a' + (delta - 10)));
+ value /= base;
+ }
+ while (value != 0);
+ do
+ *s++ = temp[--pos];
+ while (pos > 0);
+ *s = '\0';
+}
+
+void ConvertUInt64ToString(UInt64 value, wchar_t *s)
+{
+ wchar_t temp[32];
+ int pos = 0;
+ do
+ {
+ temp[pos++] = (wchar_t)(L'0' + (int)(value % 10));
+ value /= 10;
+ }
+ while (value != 0);
+ do
+ *s++ = temp[--pos];
+ while (pos > 0);
+ *s = L'\0';
+}
+
+void ConvertUInt32ToString(UInt32 value, char *s) { ConvertUInt64ToString(value, s); }
+void ConvertUInt32ToString(UInt32 value, wchar_t *s) { ConvertUInt64ToString(value, s); }
+
+void ConvertInt64ToString(Int64 value, char *s)
+{
+ if (value < 0)
+ {
+ *s++ = '-';
+ value = -value;
+ }
+ ConvertUInt64ToString(value, s);
+}
+
+void ConvertInt64ToString(Int64 value, wchar_t *s)
+{
+ if (value < 0)
+ {
+ *s++ = L'-';
+ value = -value;
+ }
+ ConvertUInt64ToString(value, s);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/IntToString.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/IntToString.h
new file mode 100644
index 000000000..bad17e4a0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/IntToString.h
@@ -0,0 +1,17 @@
+// Common/IntToString.h
+
+#ifndef __COMMON_INT_TO_STRING_H
+#define __COMMON_INT_TO_STRING_H
+
+#include <stddef.h>
+#include "Types.h"
+
+void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base = 10);
+void ConvertUInt64ToString(UInt64 value, wchar_t *s);
+void ConvertInt64ToString(Int64 value, char *s);
+void ConvertInt64ToString(Int64 value, wchar_t *s);
+
+void ConvertUInt32ToString(UInt32 value, char *s);
+void ConvertUInt32ToString(UInt32 value, wchar_t *s);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Lang.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Lang.cpp
new file mode 100644
index 000000000..75dfed426
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Lang.cpp
@@ -0,0 +1,130 @@
+// Common/Lang.cpp
+
+#include "StdAfx.h"
+
+#include "Lang.h"
+#include "TextConfig.h"
+
+#include "../Windows/FileIO.h"
+#include "UTFConvert.h"
+#include "Defs.h"
+
+static bool HexStringToNumber(const UString &s, UInt32 &value)
+{
+ value = 0;
+ if (s.IsEmpty())
+ return false;
+ for (int i = 0; i < s.Length(); i++)
+ {
+ wchar_t c = s[i];
+ int a;
+ if (c >= L'0' && c <= L'9')
+ a = c - L'0';
+ else if (c >= L'A' && c <= L'F')
+ a = 10 + c - L'A';
+ else if (c >= L'a' && c <= L'f')
+ a = 10 + c - L'a';
+ else
+ return false;
+ value *= 0x10;
+ value += a;
+ }
+ return true;
+}
+
+
+static bool WaitNextLine(const AString &s, int &pos)
+{
+ for (; pos < s.Length(); pos++)
+ if (s[pos] == 0x0A)
+ return true;
+ return false;
+}
+
+static int CompareLangItems(void *const *elem1, void *const *elem2, void *)
+{
+ const CLangPair &langPair1 = *(*((const CLangPair **)elem1));
+ const CLangPair &langPair2 = *(*((const CLangPair **)elem2));
+ return MyCompare(langPair1.Value, langPair2.Value);
+}
+
+bool CLang::Open(LPCWSTR fileName)
+{
+ _langPairs.Clear();
+ NWindows::NFile::NIO::CInFile file;
+ if (!file.Open(fileName))
+ return false;
+ UInt64 length;
+ if (!file.GetLength(length))
+ return false;
+ if (length > (1 << 20))
+ return false;
+ AString s;
+ char *p = s.GetBuffer((int)length + 1);
+ UInt32 processed;
+ if (!file.Read(p, (UInt32)length, processed))
+ return false;
+ p[(UInt32)length] = 0;
+ s.ReleaseBuffer();
+ file.Close();
+ int pos = 0;
+ if (s.Length() >= 3)
+ {
+ if (Byte(s[0]) == 0xEF && Byte(s[1]) == 0xBB && Byte(s[2]) == 0xBF)
+ pos += 3;
+ }
+
+ /////////////////////
+ // read header
+
+ AString stringID = ";!@Lang@!UTF-8!";
+ if (s.Mid(pos, stringID.Length()) != stringID)
+ return false;
+ pos += stringID.Length();
+
+ if (!WaitNextLine(s, pos))
+ return false;
+
+ CObjectVector<CTextConfigPair> pairs;
+ if (!GetTextConfig(s.Mid(pos), pairs))
+ return false;
+
+ _langPairs.Reserve(_langPairs.Size());
+ for (int i = 0; i < pairs.Size(); i++)
+ {
+ CTextConfigPair textConfigPair = pairs[i];
+ CLangPair langPair;
+ if (!HexStringToNumber(textConfigPair.ID, langPair.Value))
+ return false;
+ langPair.String = textConfigPair.String;
+ _langPairs.Add(langPair);
+ }
+ _langPairs.Sort(CompareLangItems, NULL);
+ return true;
+}
+
+int CLang::FindItem(UInt32 value) const
+{
+ int left = 0, right = _langPairs.Size();
+ while (left != right)
+ {
+ UInt32 mid = (left + right) / 2;
+ UInt32 midValue = _langPairs[mid].Value;
+ if (value == midValue)
+ return mid;
+ if (value < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ return -1;
+}
+
+bool CLang::GetMessage(UInt32 value, UString &message) const
+{
+ int index = FindItem(value);
+ if (index < 0)
+ return false;
+ message = _langPairs[index].String;
+ return true;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Lang.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Lang.h
new file mode 100644
index 000000000..cf978758e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Lang.h
@@ -0,0 +1,28 @@
+// Common/Lang.h
+
+#ifndef __COMMON_LANG_H
+#define __COMMON_LANG_H
+
+#include "MyVector.h"
+#include "MyString.h"
+#include "Types.h"
+
+struct CLangPair
+{
+ UInt32 Value;
+ UString String;
+};
+
+class CLang
+{
+ CObjectVector<CLangPair> _langPairs;
+public:
+ bool Open(LPCWSTR fileName);
+ void Clear() { _langPairs.Clear(); }
+ int FindItem(UInt32 value) const;
+ bool GetMessage(UInt32 value, UString &message) const;
+};
+
+#endif
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ListFileUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ListFileUtils.cpp
new file mode 100644
index 000000000..8e409016e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ListFileUtils.cpp
@@ -0,0 +1,75 @@
+// Common/ListFileUtils.cpp
+
+#include "StdAfx.h"
+
+#include "MyWindows.h"
+#include "../Windows/FileIO.h"
+
+#include "ListFileUtils.h"
+#include "StringConvert.h"
+#include "UTFConvert.h"
+
+static const char kQuoteChar = '\"';
+static void RemoveQuote(UString &s)
+{
+ if (s.Length() >= 2)
+ if (s[0] == kQuoteChar && s[s.Length() - 1] == kQuoteChar)
+ s = s.Mid(1, s.Length() - 2);
+}
+
+bool ReadNamesFromListFile(LPCWSTR fileName, UStringVector &resultStrings, UINT codePage)
+{
+ NWindows::NFile::NIO::CInFile file;
+ if (!file.Open(fileName,true)) /* follow the symbolic link */
+ return false;
+ UInt64 length;
+ if (!file.GetLength(length))
+ return false;
+ if (length > ((UInt32)1 << 31))
+ return false;
+ AString s;
+ char *p = s.GetBuffer((int)length + 1);
+ UInt32 processed;
+ if (!file.Read(p, (UInt32)length, processed))
+ return false;
+ p[(UInt32)length] = 0;
+ s.ReleaseBuffer();
+ file.Close();
+
+ UString u;
+ #ifdef CP_UTF8
+ if (codePage == CP_UTF8)
+ {
+ if (!ConvertUTF8ToUnicode(s, u))
+ return false;
+ }
+ else
+ #endif
+ u = MultiByteToUnicodeString(s, codePage);
+ if (!u.IsEmpty())
+ {
+ if (u[0] == 0xFEFF)
+ u.Delete(0);
+ }
+
+ UString t;
+ for (int i = 0; i < u.Length(); i++)
+ {
+ wchar_t c = u[i];
+ if (c == L'\n' || c == 0xD)
+ {
+ t.Trim();
+ RemoveQuote(t);
+ if (!t.IsEmpty())
+ resultStrings.Add(t);
+ t.Empty();
+ }
+ else
+ t += c;
+ }
+ t.Trim();
+ RemoveQuote(t);
+ if (!t.IsEmpty())
+ resultStrings.Add(t);
+ return true;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ListFileUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ListFileUtils.h
new file mode 100644
index 000000000..c58a8bd42
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/ListFileUtils.h
@@ -0,0 +1,11 @@
+// Common/ListFileUtils.h
+
+#ifndef __COMMON_LISTFILEUTILS_H
+#define __COMMON_LISTFILEUTILS_H
+
+#include "MyString.h"
+#include "Types.h"
+
+bool ReadNamesFromListFile(LPCWSTR fileName, UStringVector &strings, UINT codePage = CP_OEMCP);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyCom.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyCom.h
new file mode 100644
index 000000000..2f00c258f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyCom.h
@@ -0,0 +1,225 @@
+// MyCom.h
+
+#ifndef __MYCOM_H
+#define __MYCOM_H
+
+#include "MyWindows.h"
+
+#ifndef RINOK
+#define RINOK(x) { HRESULT __result_ = (x); if (__result_ != S_OK) return __result_; }
+#endif
+
+template <class T>
+class CMyComPtr
+{
+ T* _p;
+public:
+ // typedef T _PtrClass;
+ CMyComPtr() { _p = NULL;}
+ CMyComPtr(T* p) {if ((_p = p) != NULL) p->AddRef(); }
+ CMyComPtr(const CMyComPtr<T>& lp)
+ {
+ if ((_p = lp._p) != NULL)
+ _p->AddRef();
+ }
+ ~CMyComPtr() { if (_p) _p->Release(); }
+ void Release() { if (_p) { _p->Release(); _p = NULL; } }
+ operator T*() const { return (T*)_p; }
+ // T& operator*() const { return *_p; }
+ T** operator&() { return &_p; }
+ T* operator->() const { return _p; }
+ T* operator=(T* p)
+ {
+ if (p != 0)
+ p->AddRef();
+ if (_p)
+ _p->Release();
+ _p = p;
+ return p;
+ }
+ T* operator=(const CMyComPtr<T>& lp) { return (*this = lp._p); }
+ bool operator!() const { return (_p == NULL); }
+ // bool operator==(T* pT) const { return _p == pT; }
+ // Compare two objects for equivalence
+ void Attach(T* p2)
+ {
+ Release();
+ _p = p2;
+ }
+ T* Detach()
+ {
+ T* pt = _p;
+ _p = NULL;
+ return pt;
+ }
+ #ifdef _WIN32
+ HRESULT CoCreateInstance(REFCLSID rclsid, REFIID iid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+ {
+ return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, (void**)&_p);
+ }
+ #endif
+ /*
+ HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+ {
+ CLSID clsid;
+ HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
+ ATLASSERT(_p == NULL);
+ if (SUCCEEDED(hr))
+ hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&_p);
+ return hr;
+ }
+ */
+ template <class Q>
+ HRESULT QueryInterface(REFGUID iid, Q** pp) const
+ {
+ return _p->QueryInterface(iid, (void**)pp);
+ }
+};
+
+//////////////////////////////////////////////////////////
+
+inline HRESULT StringToBstr(LPCOLESTR src, BSTR *bstr)
+{
+ *bstr = ::SysAllocString(src);
+ return (*bstr != 0) ? S_OK : E_OUTOFMEMORY;
+}
+
+class CMyComBSTR
+{
+public:
+ BSTR m_str;
+ CMyComBSTR(): m_str(NULL) {}
+ CMyComBSTR(LPCOLESTR src) { m_str = ::SysAllocString(src); }
+ // CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); }
+ // CMyComBSTR(int nSize, LPCOLESTR sz) { m_str = ::SysAllocStringLen(sz, nSize); }
+ CMyComBSTR(const CMyComBSTR& src) { m_str = src.MyCopy(); }
+ /*
+ CMyComBSTR(REFGUID src)
+ {
+ LPOLESTR szGuid;
+ StringFromCLSID(src, &szGuid);
+ m_str = ::SysAllocString(szGuid);
+ CoTaskMemFree(szGuid);
+ }
+ */
+ ~CMyComBSTR() { ::SysFreeString(m_str); }
+ CMyComBSTR& operator=(const CMyComBSTR& src)
+ {
+ if (m_str != src.m_str)
+ {
+ if (m_str)
+ ::SysFreeString(m_str);
+ m_str = src.MyCopy();
+ }
+ return *this;
+ }
+ CMyComBSTR& operator=(LPCOLESTR src)
+ {
+ ::SysFreeString(m_str);
+ m_str = ::SysAllocString(src);
+ return *this;
+ }
+ unsigned int Length() const { return ::SysStringLen(m_str); }
+ operator BSTR() const { return m_str; }
+ BSTR* operator&() { return &m_str; }
+ BSTR MyCopy() const
+ {
+ int byteLen = ::SysStringByteLen(m_str);
+ BSTR res = ::SysAllocStringByteLen(NULL, byteLen);
+ memcpy(res, m_str, byteLen);
+ return res;
+ }
+ /*
+ void Attach(BSTR src) { m_str = src; }
+ BSTR Detach()
+ {
+ BSTR s = m_str;
+ m_str = NULL;
+ return s;
+ }
+ */
+ void Empty()
+ {
+ ::SysFreeString(m_str);
+ m_str = NULL;
+ }
+ bool operator!() const { return (m_str == NULL); }
+};
+
+//////////////////////////////////////////////////////////
+
+class CMyUnknownImp
+{
+public:
+ ULONG __m_RefCount;
+ CMyUnknownImp(): __m_RefCount(0) {}
+};
+
+#define MY_QUERYINTERFACE_BEGIN STDMETHOD(QueryInterface) \
+ (REFGUID iid, void **outObject) {
+
+#define MY_QUERYINTERFACE_ENTRY(i) if (iid == IID_ ## i) \
+ { *outObject = (void *)(i *)this; AddRef(); return S_OK; }
+
+#define MY_QUERYINTERFACE_ENTRY_UNKNOWN(i) if (iid == IID_IUnknown) \
+ { *outObject = (void *)(IUnknown *)(i *)this; AddRef(); return S_OK; }
+
+#define MY_QUERYINTERFACE_BEGIN2(i) MY_QUERYINTERFACE_BEGIN \
+ MY_QUERYINTERFACE_ENTRY_UNKNOWN(i) \
+ MY_QUERYINTERFACE_ENTRY(i)
+
+#define MY_QUERYINTERFACE_END return E_NOINTERFACE; }
+
+#define MY_ADDREF_RELEASE \
+STDMETHOD_(ULONG, AddRef)() { return ++__m_RefCount; } \
+STDMETHOD_(ULONG, Release)() { if (--__m_RefCount != 0) \
+ return __m_RefCount; delete this; return 0; }
+
+#define MY_UNKNOWN_IMP_SPEC(i) \
+ MY_QUERYINTERFACE_BEGIN \
+ i \
+ MY_QUERYINTERFACE_END \
+ MY_ADDREF_RELEASE
+
+
+#define MY_UNKNOWN_IMP MY_QUERYINTERFACE_BEGIN \
+ MY_QUERYINTERFACE_ENTRY_UNKNOWN(IUnknown) \
+ MY_QUERYINTERFACE_END \
+ MY_ADDREF_RELEASE
+
+#define MY_UNKNOWN_IMP1(i) MY_UNKNOWN_IMP_SPEC( \
+ MY_QUERYINTERFACE_ENTRY_UNKNOWN(i) \
+ MY_QUERYINTERFACE_ENTRY(i) \
+ )
+
+#define MY_UNKNOWN_IMP2(i1, i2) MY_UNKNOWN_IMP_SPEC( \
+ MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \
+ MY_QUERYINTERFACE_ENTRY(i1) \
+ MY_QUERYINTERFACE_ENTRY(i2) \
+ )
+
+#define MY_UNKNOWN_IMP3(i1, i2, i3) MY_UNKNOWN_IMP_SPEC( \
+ MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \
+ MY_QUERYINTERFACE_ENTRY(i1) \
+ MY_QUERYINTERFACE_ENTRY(i2) \
+ MY_QUERYINTERFACE_ENTRY(i3) \
+ )
+
+#define MY_UNKNOWN_IMP4(i1, i2, i3, i4) MY_UNKNOWN_IMP_SPEC( \
+ MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \
+ MY_QUERYINTERFACE_ENTRY(i1) \
+ MY_QUERYINTERFACE_ENTRY(i2) \
+ MY_QUERYINTERFACE_ENTRY(i3) \
+ MY_QUERYINTERFACE_ENTRY(i4) \
+ )
+
+#define MY_UNKNOWN_IMP5(i1, i2, i3, i4, i5) MY_UNKNOWN_IMP_SPEC( \
+ MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \
+ MY_QUERYINTERFACE_ENTRY(i1) \
+ MY_QUERYINTERFACE_ENTRY(i2) \
+ MY_QUERYINTERFACE_ENTRY(i3) \
+ MY_QUERYINTERFACE_ENTRY(i4) \
+ MY_QUERYINTERFACE_ENTRY(i5) \
+ )
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyException.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyException.h
new file mode 100644
index 000000000..f0ad11158
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyException.h
@@ -0,0 +1,14 @@
+// Common/Exception.h
+
+#ifndef __COMMON_EXCEPTION_H
+#define __COMMON_EXCEPTION_H
+
+#include "MyWindows.h"
+
+struct CSystemException
+{
+ HRESULT ErrorCode;
+ CSystemException(HRESULT errorCode): ErrorCode(errorCode) {}
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyGuidDef.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyGuidDef.h
new file mode 100644
index 000000000..ddb9f0f43
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyGuidDef.h
@@ -0,0 +1,65 @@
+// Common/MyGuidDef.h
+
+#ifndef GUID_DEFINED
+#define GUID_DEFINED
+
+#include "Types.h"
+
+typedef struct {
+ UInt32 Data1;
+ UInt16 Data2;
+ UInt16 Data3;
+ unsigned char Data4[8];
+} GUID;
+
+#ifdef __cplusplus
+#define REFGUID const GUID &
+#else
+#define REFGUID const GUID *
+#endif
+
+#define REFCLSID REFGUID
+#define REFIID REFGUID
+
+#ifdef __cplusplus
+inline int operator==(REFGUID g1, REFGUID g2)
+{
+ for (int i = 0; i < (int)sizeof(g1); i++)
+ if (((unsigned char *)&g1)[i] != ((unsigned char *)&g2)[i])
+ return 0;
+ return 1;
+}
+inline int operator!=(REFGUID g1, REFGUID g2) { return !(g1 == g2); }
+#endif
+
+#ifdef __cplusplus
+ #define MY_EXTERN_C extern "C"
+#else
+ #define MY_EXTERN_C extern
+#endif
+
+#endif // GUID_DEFINED
+
+
+#ifdef DEFINE_GUID
+#undef DEFINE_GUID
+#endif
+
+#ifdef INITGUID
+#ifdef __cplusplus
+ #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+ extern "C" const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
+#else
+ #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+ extern const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
+#endif
+
+#else
+#ifdef __cplusplus
+ #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+ extern "C" const GUID name
+#else
+ #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+ extern const GUID name
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyInitGuid.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyInitGuid.h
new file mode 100644
index 000000000..f40d5fd14
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyInitGuid.h
@@ -0,0 +1,15 @@
+// Common/MyInitGuid.h
+
+#ifndef __COMMON_MYINITGUID_H
+#define __COMMON_MYINITGUID_H
+
+//#ifdef _WIN32
+//#include <initguid.h>
+//#else
+#define INITGUID
+#include "MyGuidDef.h"
+DEFINE_GUID(IID_IUnknown,
+0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
+//#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyMap.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyMap.cpp
new file mode 100644
index 000000000..0ee11e8cd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyMap.cpp
@@ -0,0 +1,140 @@
+// MyMap.cpp
+
+#include "StdAfx.h"
+
+#include "MyMap.h"
+
+static const unsigned kNumBitsMax = sizeof(UInt32) * 8;
+
+static UInt32 GetSubBits(UInt32 value, unsigned startPos, unsigned numBits)
+{
+ if (startPos == sizeof(value) * 8)
+ return 0;
+ value >>= startPos;
+ if (numBits == sizeof(value) * 8)
+ return value;
+ return value & (((UInt32)1 << numBits) - 1);
+}
+
+static inline unsigned GetSubBit(UInt32 v, unsigned n) { return (unsigned)(v >> n) & 1; }
+
+bool CMap32::Find(UInt32 key, UInt32 &valueRes) const
+{
+ valueRes = (UInt32)(Int32)-1;
+ if (Nodes.Size() == 0)
+ return false;
+ if (Nodes.Size() == 1)
+ {
+ const CNode &n = Nodes[0];
+ if (n.Len == kNumBitsMax)
+ {
+ valueRes = n.Values[0];
+ return (key == n.Key);
+ }
+ }
+
+ int cur = 0;
+ unsigned bitPos = kNumBitsMax;
+ for (;;)
+ {
+ const CNode &n = Nodes[cur];
+ bitPos -= n.Len;
+ if (GetSubBits(key, bitPos, n.Len) != GetSubBits(n.Key, bitPos, n.Len))
+ return false;
+ unsigned bit = GetSubBit(key, --bitPos);
+ if (n.IsLeaf[bit])
+ {
+ valueRes = n.Values[bit];
+ return (key == n.Keys[bit]);
+ }
+ cur = (int)n.Keys[bit];
+ }
+}
+
+bool CMap32::Set(UInt32 key, UInt32 value)
+{
+ if (Nodes.Size() == 0)
+ {
+ CNode n;
+ n.Key = n.Keys[0] = n.Keys[1] = key;
+ n.Values[0] = n.Values[1] = value;
+ n.IsLeaf[0] = n.IsLeaf[1] = 1;
+ n.Len = kNumBitsMax;
+ Nodes.Add(n);
+ return false;
+ }
+ if (Nodes.Size() == 1)
+ {
+ CNode &n = Nodes[0];
+ if (n.Len == kNumBitsMax)
+ {
+ if (key == n.Key)
+ {
+ n.Values[0] = n.Values[1] = value;
+ return true;
+ }
+ unsigned i = kNumBitsMax - 1;
+ for (;GetSubBit(key, i) == GetSubBit(n.Key, i); i--);
+ n.Len = (UInt16)(kNumBitsMax - (1 + i));
+ unsigned newBit = GetSubBit(key, i);
+ n.Values[newBit] = value;
+ n.Keys[newBit] = key;
+ return false;
+ }
+ }
+
+ int cur = 0;
+ unsigned bitPos = kNumBitsMax;
+ for (;;)
+ {
+ CNode &n = Nodes[cur];
+ bitPos -= n.Len;
+ if (GetSubBits(key, bitPos, n.Len) != GetSubBits(n.Key, bitPos, n.Len))
+ {
+ unsigned i = n.Len - 1;
+ for (; GetSubBit(key, bitPos + i) == GetSubBit(n.Key, bitPos + i); i--);
+
+ CNode e2(n);
+ e2.Len = (UInt16)i;
+
+ n.Len = (UInt16)(n.Len - (1 + i));
+ unsigned newBit = GetSubBit(key, bitPos + i);
+ n.Values[newBit] = value;
+ n.IsLeaf[newBit] = 1;
+ n.IsLeaf[1 - newBit] = 0;
+ n.Keys[newBit] = key;
+ n.Keys[1 - newBit] = Nodes.Size();
+ Nodes.Add(e2);
+ return false;
+ }
+ unsigned bit = GetSubBit(key, --bitPos);
+
+ if (n.IsLeaf[bit])
+ {
+ if (key == n.Keys[bit])
+ {
+ n.Values[bit] = value;
+ return true;
+ }
+ unsigned i = bitPos - 1;
+ for (;GetSubBit(key, i) == GetSubBit(n.Keys[bit], i); i--);
+
+ CNode e2;
+
+ unsigned newBit = GetSubBit(key, i);
+ e2.Values[newBit] = value;
+ e2.Values[1 - newBit] = n.Values[bit];
+ e2.IsLeaf[newBit] = e2.IsLeaf[1 - newBit] = 1;
+ e2.Keys[newBit] = key;
+ e2.Keys[1 - newBit] = e2.Key = n.Keys[bit];
+ e2.Len = (UInt16)(bitPos - (1 + i));
+
+ n.IsLeaf[bit] = 0;
+ n.Keys[bit] = Nodes.Size();
+
+ Nodes.Add(e2);
+ return false;
+ }
+ cur = (int)n.Keys[bit];
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyMap.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyMap.h
new file mode 100644
index 000000000..d0dd43f53
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyMap.h
@@ -0,0 +1,28 @@
+// MyMap.h
+
+#ifndef __COMMON_MYMAP_H
+#define __COMMON_MYMAP_H
+
+#include "MyVector.h"
+#include "Types.h"
+
+class CMap32
+{
+ struct CNode
+ {
+ UInt32 Key;
+ UInt32 Keys[2];
+ UInt32 Values[2];
+ UInt16 Len;
+ Byte IsLeaf[2];
+ };
+ CRecordVector<CNode> Nodes;
+
+public:
+
+ void Clear() { Nodes.Clear(); }
+ bool Find(UInt32 key, UInt32 &valueRes) const;
+ bool Set(UInt32 key, UInt32 value); // returns true, if there is such key already
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyString.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyString.cpp
new file mode 100644
index 000000000..c2e5311aa
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyString.cpp
@@ -0,0 +1,164 @@
+// Common/String.cpp
+
+#include "StdAfx.h"
+
+#include <ctype.h>
+#ifdef HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+#include "StringConvert.h" // FIXED
+
+#include "MyString.h" // FIXED to avoid confusion with <string.h> on some filesystems
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef HAVE_WCHAR__H
+#include <wchar.h>
+#endif
+
+#include <limits.h>
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 1024
+#endif
+
+#include "myPrivate.h"
+
+#ifdef ENV_UNIX
+LPSTR WINAPI CharPrevA( LPCSTR start, LPCSTR ptr ) { // OK for MBS
+ while (*start && (start < ptr)) {
+ LPCSTR next = CharNextA( start );
+ if (next >= ptr)
+ break;
+ start = next;
+ }
+ return (LPSTR)start;
+}
+
+LPSTR WINAPI CharNextA( LPCSTR ptr ) {
+ if (!*ptr)
+ return (LPSTR)ptr;
+// #ifdef HAVE_MBRTOWC
+// if (global_use_utf16_conversion)
+// {
+// wchar_t wc;
+// size_t len = mbrtowc(&wc,ptr,MB_LEN_MAX,0); // mbrtowc stales on some configurations.
+// if (len >= 1) return (LPSTR)(ptr + len);
+// printf("INTERNAL ERROR - CharNextA\n");
+// exit(EXIT_FAILURE);
+// } else {
+// return (LPSTR)(ptr + 1);
+// }
+//#else
+ return (LPSTR)(ptr + 1); // p7zip search only for ASCII characters like '/' so no need to worry about current locale
+//#endif
+}
+#endif
+
+wchar_t MyCharLower(wchar_t c)
+{
+#ifdef HAVE_TOWUPPER
+ return towlower(c);
+#else
+ int ret = c;
+ if ((ret >= 1) && (ret <256)) ret = tolower(ret);
+ return (wchar_t)ret;
+#endif
+}
+
+char * MyStringLower(char *s)
+{
+ if (s == 0)
+ return 0;
+ char *ret = s;
+ while (*s)
+ {
+ *s = MyCharLower(*s);
+ s++;
+ }
+ return ret;
+}
+
+wchar_t * MyStringLower(wchar_t *s)
+{
+ if (s == 0)
+ return 0;
+ wchar_t *ret = s;
+ while (*s)
+ {
+ *s = MyCharLower(*s);
+ s++;
+ }
+ return ret;
+}
+
+wchar_t MyCharUpper(wchar_t c)
+{
+#ifdef HAVE_TOWUPPER
+ return towupper(c);
+#else
+ int ret = c;
+ if ((ret >= 1) && (ret <256)) ret = toupper(ret);
+ return (wchar_t)ret;
+#endif
+}
+
+wchar_t * MyStringUpper(wchar_t *s)
+{
+ if (s == 0)
+ return 0;
+ wchar_t *ret = s;
+ while (*s)
+ {
+ *s = MyCharUpper(*s);
+ s++;
+ }
+ return ret;
+}
+
+int MyStringCompare(const char *s1, const char *s2)
+{
+ while (true)
+ {
+ unsigned char c1 = (unsigned char)*s1++;
+ unsigned char c2 = (unsigned char)*s2++;
+ if (c1 < c2) return -1;
+ if (c1 > c2) return 1;
+ if (c1 == 0) return 0;
+ }
+}
+
+int MyStringCompare(const wchar_t *s1, const wchar_t *s2)
+{
+ while (true)
+ {
+ wchar_t c1 = *s1++;
+ wchar_t c2 = *s2++;
+ if (c1 < c2) return -1;
+ if (c1 > c2) return 1;
+ if (c1 == 0) return 0;
+ }
+}
+
+int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2)
+{
+ while (true)
+ {
+ wchar_t c1 = *s1++;
+ wchar_t c2 = *s2++;
+ if (c1 != c2)
+ {
+ wchar_t u1 = MyCharUpper(c1);
+ wchar_t u2 = MyCharUpper(c2);
+ if (u1 < u2) return -1;
+ if (u1 > u2) return 1;
+ }
+ if (c1 == 0) return 0;
+ }
+}
+
+int MyStringCompareNoCase(const char *s1, const char *s2)
+{
+ return MyStringCompareNoCase(MultiByteToUnicodeString(s1), MultiByteToUnicodeString(s2));
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyString.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyString.h
new file mode 100644
index 000000000..98c20d776
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyString.h
@@ -0,0 +1,598 @@
+// Common/String.h
+
+#ifndef __COMMON_STRING_H
+#define __COMMON_STRING_H
+
+#include <string.h>
+// #include <wchar.h>
+
+#include "MyVector.h"
+
+#ifdef ENV_UNIX
+LPSTR WINAPI CharNextA( LPCSTR ptr );
+LPSTR WINAPI CharPrevA( LPCSTR start, LPCSTR ptr );
+#endif
+
+template <class T>
+inline int MyStringLen(const T *s)
+{
+ int i;
+ for (i = 0; s[i] != '\0'; i++) {}
+ return i;
+}
+
+template <class T>
+inline T * MyStringCopy(T *dest, const T *src)
+{
+ T *destStart = dest;
+ while ((*dest++ = *src++) != 0) {}
+ return destStart;
+}
+
+inline wchar_t* MyStringGetNextCharPointer(wchar_t *p)
+ { return (p + 1); }
+inline const wchar_t* MyStringGetNextCharPointer(const wchar_t *p)
+ { return (p + 1); }
+inline wchar_t* MyStringGetPrevCharPointer(const wchar_t *, wchar_t *p)
+ { return (p - 1); }
+inline const wchar_t* MyStringGetPrevCharPointer(const wchar_t *, const wchar_t *p)
+ { return (p - 1); }
+
+wchar_t MyCharUpper(wchar_t c);
+char * MyStringUpper(char *s);
+wchar_t * MyStringUpper(wchar_t *s);
+
+char * MyStringLower(char *s);
+wchar_t * MyStringLower(wchar_t *s);
+
+
+inline char* MyStringGetPrevCharPointer(char *base, char *p)
+ { return CharPrevA(base, p); }
+inline const char* MyStringGetPrevCharPointer(const char *base, const char *p)
+ { return CharPrevA(base, p); }
+inline char* MyStringGetNextCharPointer(char *p)
+ { return CharNextA(p); }
+inline const char* MyStringGetNextCharPointer(const char *p)
+ { return CharNextA(p); }
+
+//////////////////////////////////////
+// Compare
+
+/*
+#ifndef _WIN32_WCE
+int MyStringCollate(const char *s1, const char *s2);
+int MyStringCollateNoCase(const char *s1, const char *s2);
+#endif
+int MyStringCollate(const wchar_t *s1, const wchar_t *s2);
+int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2);
+*/
+
+int MyStringCompare(const char *s1, const char *s2);
+int MyStringCompare(const wchar_t *s1, const wchar_t *s2);
+
+// int MyStringCompareNoCase(const char *s1, const char *s2);
+int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2);
+
+template <class T>
+class CStringBase
+{
+ void TrimLeftWithCharSet(const CStringBase &charSet)
+ {
+ const T *p = _chars;
+ while (charSet.Find(*p) >= 0 && (*p != 0))
+ p = GetNextCharPointer(p);
+ Delete(0, (int)(p - _chars));
+ }
+ void TrimRightWithCharSet(const CStringBase &charSet)
+ {
+ const T *p = _chars;
+ const T *pLast = NULL;
+ while (*p != 0)
+ {
+ if (charSet.Find(*p) >= 0)
+ {
+ if (pLast == NULL)
+ pLast = p;
+ }
+ else
+ pLast = NULL;
+ p = GetNextCharPointer(p);
+ }
+ if (pLast != NULL)
+ {
+ int i = (int)(pLast - _chars);
+ Delete(i, _length - i);
+ }
+
+ }
+ void MoveItems(int destIndex, int srcIndex)
+ {
+ memmove(_chars + destIndex, _chars + srcIndex,
+ sizeof(T) * (_length - srcIndex + 1));
+ }
+
+ void InsertSpace(int &index, int size)
+ {
+ CorrectIndex(index);
+ GrowLength(size);
+ MoveItems(index + size, index);
+ }
+
+ static T *GetNextCharPointer(T *p)
+ { return MyStringGetNextCharPointer(p); }
+ static const T *GetNextCharPointer(const T *p)
+ { return MyStringGetNextCharPointer(p); }
+ static T *GetPrevCharPointer(T *base, T *p)
+ { return MyStringGetPrevCharPointer(base, p); }
+ static const T *GetPrevCharPointer(const T *base, const T *p)
+ { return MyStringGetPrevCharPointer(base, p); }
+protected:
+ T *_chars;
+ int _length;
+ int _capacity;
+
+ void SetCapacity(int newCapacity)
+ {
+ int realCapacity = newCapacity + 1;
+ if (realCapacity == _capacity)
+ return;
+ /*
+ const int kMaxStringSize = 0x20000000;
+ #ifndef _WIN32_WCE
+ if (newCapacity > kMaxStringSize || newCapacity < _length)
+ throw 1052337;
+ #endif
+ */
+ T *newBuffer = new T[realCapacity];
+ if (_capacity > 0)
+ {
+ for (int i = 0; i < _length; i++)
+ newBuffer[i] = _chars[i];
+ delete []_chars;
+ }
+ _chars = newBuffer;
+ _chars[_length] = 0;
+ _capacity = realCapacity;
+ }
+
+ void GrowLength(int n)
+ {
+ int freeSize = _capacity - _length - 1;
+ if (n <= freeSize)
+ return;
+ int delta;
+ if (_capacity > 64)
+ delta = _capacity / 2;
+ else if (_capacity > 8)
+ delta = 16;
+ else
+ delta = 4;
+ if (freeSize + delta < n)
+ delta = n - freeSize;
+ SetCapacity(_capacity + delta);
+ }
+
+ void CorrectIndex(int &index) const
+ {
+ if (index > _length)
+ index = _length;
+ }
+
+public:
+ CStringBase(): _chars(0), _length(0), _capacity(0) { SetCapacity(3); }
+ CStringBase(T c): _chars(0), _length(0), _capacity(0)
+ {
+ SetCapacity(1);
+ _chars[0] = c;
+ _chars[1] = 0;
+ _length = 1;
+ }
+ CStringBase(const T *chars): _chars(0), _length(0), _capacity(0)
+ {
+ int length = MyStringLen(chars);
+ SetCapacity(length);
+ MyStringCopy(_chars, chars); // can be optimized by memove()
+ _length = length;
+ }
+ CStringBase(const CStringBase &s): _chars(0), _length(0), _capacity(0)
+ {
+ SetCapacity(s._length);
+ MyStringCopy(_chars, s._chars);
+ _length = s._length;
+ }
+ ~CStringBase() { delete []_chars; }
+
+ operator const T*() const { return _chars;}
+
+ // The minimum size of the character buffer in characters.
+ // This value does not include space for a null terminator.
+ T* GetBuffer(int minBufLength)
+ {
+ if (minBufLength >= _capacity)
+ SetCapacity(minBufLength);
+ return _chars;
+ }
+ void ReleaseBuffer() { ReleaseBuffer(MyStringLen(_chars)); }
+ void ReleaseBuffer(int newLength)
+ {
+ /*
+ #ifndef _WIN32_WCE
+ if (newLength >= _capacity)
+ throw 282217;
+ #endif
+ */
+ _chars[newLength] = 0;
+ _length = newLength;
+ }
+
+ CStringBase& operator=(T c)
+ {
+ Empty();
+ SetCapacity(1);
+ _chars[0] = c;
+ _chars[1] = 0;
+ _length = 1;
+ return *this;
+ }
+ CStringBase& operator=(const T *chars)
+ {
+ Empty();
+ int length = MyStringLen(chars);
+ SetCapacity(length);
+ MyStringCopy(_chars, chars);
+ _length = length;
+ return *this;
+ }
+ CStringBase& operator=(const CStringBase& s)
+ {
+ if (&s == this)
+ return *this;
+ Empty();
+ SetCapacity(s._length);
+ MyStringCopy(_chars, s._chars);
+ _length = s._length;
+ return *this;
+ }
+
+ CStringBase& operator+=(T c)
+ {
+ GrowLength(1);
+ _chars[_length] = c;
+ _chars[++_length] = 0;
+ return *this;
+ }
+ CStringBase& operator+=(const T *s)
+ {
+ int len = MyStringLen(s);
+ GrowLength(len);
+ MyStringCopy(_chars + _length, s);
+ _length += len;
+ return *this;
+ }
+ CStringBase& operator+=(const CStringBase &s)
+ {
+ GrowLength(s._length);
+ MyStringCopy(_chars + _length, s._chars);
+ _length += s._length;
+ return *this;
+ }
+ void Empty()
+ {
+ _length = 0;
+ _chars[0] = 0;
+ }
+ int Length() const { return _length; }
+ bool IsEmpty() const { return (_length == 0); }
+
+ CStringBase Mid(int startIndex) const
+ { return Mid(startIndex, _length - startIndex); }
+ CStringBase Mid(int startIndex, int count ) const
+ {
+ if (startIndex + count > _length)
+ count = _length - startIndex;
+
+ if (startIndex == 0 && startIndex + count == _length)
+ return *this;
+
+ CStringBase<T> result;
+ result.SetCapacity(count);
+ // MyStringNCopy(result._chars, _chars + startIndex, count);
+ for (int i = 0; i < count; i++)
+ result._chars[i] = _chars[startIndex + i];
+ result._chars[count] = 0;
+ result._length = count;
+ return result;
+ }
+ CStringBase Left(int count) const
+ { return Mid(0, count); }
+ CStringBase Right(int count) const
+ {
+ if (count > _length)
+ count = _length;
+ return Mid(_length - count, count);
+ }
+
+ void MakeUpper()
+ { MyStringUpper(_chars); }
+ void MakeLower()
+ { MyStringLower(_chars); }
+
+ int Compare(const CStringBase& s) const
+ { return MyStringCompare(_chars, s._chars); }
+
+ int Compare(const T *s) const
+ { return MyStringCompare(_chars, s); }
+
+ int CompareNoCase(const CStringBase& s) const
+ { return MyStringCompareNoCase(_chars, s._chars); }
+
+ int CompareNoCase(const T *s) const
+ { return MyStringCompareNoCase(_chars, s); }
+
+ /*
+ int Collate(const CStringBase& s) const
+ { return MyStringCollate(_chars, s._chars); }
+ int CollateNoCase(const CStringBase& s) const
+ { return MyStringCollateNoCase(_chars, s._chars); }
+ */
+
+ int Find(T c) const { return Find(c, 0); }
+ int Find(T c, int startIndex) const
+ {
+ T *p = _chars + startIndex;
+ for (;;)
+ {
+ if (*p == c)
+ return (int)(p - _chars);
+ if (*p == 0)
+ return -1;
+ p = GetNextCharPointer(p);
+ }
+ }
+ int Find(const CStringBase &s) const { return Find(s, 0); }
+ int Find(const CStringBase &s, int startIndex) const
+ {
+ if (s.IsEmpty())
+ return startIndex;
+ for (; startIndex < _length; startIndex++)
+ {
+ int j;
+ for (j = 0; j < s._length && startIndex + j < _length; j++)
+ if (_chars[startIndex+j] != s._chars[j])
+ break;
+ if (j == s._length)
+ return startIndex;
+ }
+ return -1;
+ }
+ int ReverseFind(T c) const
+ {
+ if (_length == 0)
+ return -1;
+ T *p = _chars + _length - 1;
+ for (;;)
+ {
+ if (*p == c)
+ return (int)(p - _chars);
+ if (p == _chars)
+ return -1;
+ p = GetPrevCharPointer(_chars, p);
+ }
+ }
+ int FindOneOf(const CStringBase &s) const
+ {
+ for (int i = 0; i < _length; i++)
+ if (s.Find(_chars[i]) >= 0)
+ return i;
+ return -1;
+ }
+
+ void TrimLeft(T c)
+ {
+ const T *p = _chars;
+ while (c == *p)
+ p = GetNextCharPointer(p);
+ Delete(0, p - _chars);
+ }
+ private:
+ CStringBase GetTrimDefaultCharSet()
+ {
+ CStringBase<T> charSet;
+ charSet += (T)' ';
+ charSet += (T)'\n';
+ charSet += (T)'\t';
+ return charSet;
+ }
+ public:
+
+ void TrimLeft()
+ {
+ TrimLeftWithCharSet(GetTrimDefaultCharSet());
+ }
+ void TrimRight()
+ {
+ TrimRightWithCharSet(GetTrimDefaultCharSet());
+ }
+ void TrimRight(T c)
+ {
+ const T *p = _chars;
+ const T *pLast = NULL;
+ while (*p != 0)
+ {
+ if (*p == c)
+ {
+ if (pLast == NULL)
+ pLast = p;
+ }
+ else
+ pLast = NULL;
+ p = GetNextCharPointer(p);
+ }
+ if (pLast != NULL)
+ {
+ int i = pLast - _chars;
+ Delete(i, _length - i);
+ }
+ }
+ void Trim()
+ {
+ TrimRight();
+ TrimLeft();
+ }
+
+ int Insert(int index, T c)
+ {
+ InsertSpace(index, 1);
+ _chars[index] = c;
+ _length++;
+ return _length;
+ }
+ int Insert(int index, const CStringBase &s)
+ {
+ CorrectIndex(index);
+ if (s.IsEmpty())
+ return _length;
+ int numInsertChars = s.Length();
+ InsertSpace(index, numInsertChars);
+ for (int i = 0; i < numInsertChars; i++)
+ _chars[index + i] = s[i];
+ _length += numInsertChars;
+ return _length;
+ }
+
+ // !!!!!!!!!!!!!!! test it if newChar = '\0'
+ int Replace(T oldChar, T newChar)
+ {
+ if (oldChar == newChar)
+ return 0;
+ int number = 0;
+ int pos = 0;
+ while (pos < Length())
+ {
+ pos = Find(oldChar, pos);
+ if (pos < 0)
+ break;
+ _chars[pos] = newChar;
+ pos++;
+ number++;
+ }
+ return number;
+ }
+ int Replace(const CStringBase &oldString, const CStringBase &newString)
+ {
+ if (oldString.IsEmpty())
+ return 0;
+ if (oldString == newString)
+ return 0;
+ int oldStringLength = oldString.Length();
+ int newStringLength = newString.Length();
+ int number = 0;
+ int pos = 0;
+ while (pos < _length)
+ {
+ pos = Find(oldString, pos);
+ if (pos < 0)
+ break;
+ Delete(pos, oldStringLength);
+ Insert(pos, newString);
+ pos += newStringLength;
+ number++;
+ }
+ return number;
+ }
+ int Delete(int index, int count = 1 )
+ {
+ if (index + count > _length)
+ count = _length - index;
+ if (count > 0)
+ {
+ MoveItems(index, index + count);
+ _length -= count;
+ }
+ return _length;
+ }
+};
+
+template <class T>
+CStringBase<T> operator+(const CStringBase<T>& s1, const CStringBase<T>& s2)
+{
+ CStringBase<T> result(s1);
+ result += s2;
+ return result;
+}
+
+template <class T>
+CStringBase<T> operator+(const CStringBase<T>& s, T c)
+{
+ CStringBase<T> result(s);
+ result += c;
+ return result;
+}
+
+template <class T>
+CStringBase<T> operator+(T c, const CStringBase<T>& s)
+{
+ CStringBase<T> result(c);
+ result += s;
+ return result;
+}
+
+template <class T>
+CStringBase<T> operator+(const CStringBase<T>& s, const T * chars)
+{
+ CStringBase<T> result(s);
+ result += chars;
+ return result;
+}
+
+template <class T>
+CStringBase<T> operator+(const T * chars, const CStringBase<T>& s)
+{
+ CStringBase<T> result(chars);
+ result += s;
+ return result;
+}
+
+template <class T>
+bool operator==(const CStringBase<T>& s1, const CStringBase<T>& s2)
+ { return (s1.Compare(s2) == 0); }
+
+template <class T>
+bool operator<(const CStringBase<T>& s1, const CStringBase<T>& s2)
+ { return (s1.Compare(s2) < 0); }
+
+template <class T>
+bool operator==(const T *s1, const CStringBase<T>& s2)
+ { return (s2.Compare(s1) == 0); }
+
+template <class T>
+bool operator==(const CStringBase<T>& s1, const T *s2)
+ { return (s1.Compare(s2) == 0); }
+
+template <class T>
+bool operator!=(const CStringBase<T>& s1, const CStringBase<T>& s2)
+ { return (s1.Compare(s2) != 0); }
+
+template <class T>
+bool operator!=(const T *s1, const CStringBase<T>& s2)
+ { return (s2.Compare(s1) != 0); }
+
+template <class T>
+bool operator!=(const CStringBase<T>& s1, const T *s2)
+ { return (s1.Compare(s2) != 0); }
+
+typedef CStringBase<char> AString;
+typedef CStringBase<wchar_t> UString;
+
+typedef CObjectVector<AString> AStringVector;
+typedef CObjectVector<UString> UStringVector;
+
+#ifdef _UNICODE
+ typedef UString CSysString;
+#else
+ typedef AString CSysString;
+#endif
+
+typedef CObjectVector<CSysString> CSysStringVector;
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyUnknown.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyUnknown.h
new file mode 100644
index 000000000..136145a79
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyUnknown.h
@@ -0,0 +1,24 @@
+// MyUnknown.h
+
+#ifndef __MYUNKNOWN_H
+#define __MYUNKNOWN_H
+
+#ifdef _WIN32
+
+#ifdef _WIN32_WCE
+#if (_WIN32_WCE > 300)
+#include <basetyps.h>
+#else
+#define MIDL_INTERFACE(x) struct
+#endif
+#else
+#include <basetyps.h>
+#endif
+
+#include <unknwn.h>
+
+#else
+#include "MyWindows.h"
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyVector.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyVector.cpp
new file mode 100644
index 000000000..88d9993a6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyVector.cpp
@@ -0,0 +1,87 @@
+// Common/MyVector.cpp
+
+#include "StdAfx.h"
+
+#include <string.h>
+
+#include "MyVector.h"
+
+CBaseRecordVector::~CBaseRecordVector() { ClearAndFree(); }
+
+void CBaseRecordVector::ClearAndFree()
+{
+ Clear();
+ delete []((unsigned char *)_items);
+ _capacity = 0;
+ _size = 0;
+ _items = 0;
+}
+
+void CBaseRecordVector::Clear() { DeleteFrom(0); }
+void CBaseRecordVector::DeleteBack() { Delete(_size - 1); }
+void CBaseRecordVector::DeleteFrom(int index) { Delete(index, _size - index); }
+
+void CBaseRecordVector::ReserveOnePosition()
+{
+ if (_size != _capacity)
+ return;
+ int delta = 1;
+ if (_capacity >= 64)
+ delta = _capacity / 4;
+ else if (_capacity >= 8)
+ delta = 8;
+ Reserve(_capacity + delta);
+}
+
+void CBaseRecordVector::Reserve(int newCapacity)
+{
+ // if (newCapacity <= _capacity)
+ if (newCapacity == _capacity)
+ return;
+ if ((unsigned)newCapacity >= ((unsigned)1 << (sizeof(unsigned) * 8 - 1)))
+ throw 1052353;
+ size_t newSize = (size_t)(unsigned)newCapacity * _itemSize;
+ if (newSize / _itemSize != (size_t)(unsigned)newCapacity)
+ throw 1052354;
+ unsigned char *p = NULL;
+ if (newSize > 0)
+ {
+ p = new unsigned char[newSize];
+ if (p == 0)
+ throw 1052355;
+ int numRecordsToMove = (_size < newCapacity ? _size : newCapacity);
+ memcpy(p, _items, _itemSize * numRecordsToMove);
+ }
+ delete [](unsigned char *)_items;
+ _items = p;
+ _capacity = newCapacity;
+}
+
+void CBaseRecordVector::ReserveDown()
+{
+ Reserve(_size);
+}
+
+void CBaseRecordVector::MoveItems(int destIndex, int srcIndex)
+{
+ memmove(((unsigned char *)_items) + destIndex * _itemSize,
+ ((unsigned char *)_items) + srcIndex * _itemSize,
+ _itemSize * (_size - srcIndex));
+}
+
+void CBaseRecordVector::InsertOneItem(int index)
+{
+ ReserveOnePosition();
+ MoveItems(index + 1, index);
+ _size++;
+}
+
+void CBaseRecordVector::Delete(int index, int num)
+{
+ TestIndexAndCorrectNum(index, num);
+ if (num > 0)
+ {
+ MoveItems(index, index + num);
+ _size -= num;
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyVector.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyVector.h
new file mode 100644
index 000000000..9be4aeda8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyVector.h
@@ -0,0 +1,250 @@
+// Common/Vector.h
+
+#ifndef __COMMON_VECTOR_H
+#define __COMMON_VECTOR_H
+
+#include "Defs.h"
+
+class CBaseRecordVector
+{
+ void MoveItems(int destIndex, int srcIndex);
+protected:
+ int _capacity;
+ int _size;
+ void *_items;
+ size_t _itemSize;
+
+ void ReserveOnePosition();
+ void InsertOneItem(int index);
+ void TestIndexAndCorrectNum(int index, int &num) const
+ { if (index + num > _size) num = _size - index; }
+public:
+ CBaseRecordVector(size_t itemSize): _capacity(0), _size(0), _items(0), _itemSize(itemSize) {}
+ virtual ~CBaseRecordVector();
+ void ClearAndFree();
+ int Size() const { return _size; }
+ bool IsEmpty() const { return (_size == 0); }
+ void Reserve(int newCapacity);
+ void ReserveDown();
+ virtual void Delete(int index, int num = 1);
+ void Clear();
+ void DeleteFrom(int index);
+ void DeleteBack();
+};
+
+template <class T>
+class CRecordVector: public CBaseRecordVector
+{
+public:
+ CRecordVector(): CBaseRecordVector(sizeof(T)){};
+ CRecordVector(const CRecordVector &v): CBaseRecordVector(sizeof(T)) { *this = v; }
+ CRecordVector& operator=(const CRecordVector &v)
+ {
+ Clear();
+ return (*this += v);
+ }
+ CRecordVector& operator+=(const CRecordVector &v)
+ {
+ int size = v.Size();
+ Reserve(Size() + size);
+ for (int i = 0; i < size; i++)
+ Add(v[i]);
+ return *this;
+ }
+ int Add(T item)
+ {
+ ReserveOnePosition();
+ ((T *)_items)[_size] = item;
+ return _size++;
+ }
+ void Insert(int index, T item)
+ {
+ InsertOneItem(index);
+ ((T *)_items)[index] = item;
+ }
+ // T* GetPointer() const { return (T*)_items; }
+ // operator const T *() const { return _items; };
+ const T& operator[](int index) const { return ((T *)_items)[index]; }
+ T& operator[](int index) { return ((T *)_items)[index]; }
+ const T& Front() const { return operator[](0); }
+ T& Front() { return operator[](0); }
+ const T& Back() const { return operator[](_size - 1); }
+ T& Back() { return operator[](_size - 1); }
+
+ void Swap(int i, int j)
+ {
+ T temp = operator[](i);
+ operator[](i) = operator[](j);
+ operator[](j) = temp;
+ }
+
+ int FindInSorted(const T& item) const
+ {
+ int left = 0, right = Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ const T& midValue = (*this)[mid];
+ if (item == midValue)
+ return mid;
+ if (item < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ return -1;
+ }
+
+ int AddToUniqueSorted(const T& item)
+ {
+ int left = 0, right = Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ const T& midValue = (*this)[mid];
+ if (item == midValue)
+ return mid;
+ if (item < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ Insert(right, item);
+ return right;
+ }
+
+ static void SortRefDown(T* p, int k, int size, int (*compare)(const T*, const T*, void *), void *param)
+ {
+ T temp = p[k];
+ for (;;)
+ {
+ int s = (k << 1);
+ if (s > size)
+ break;
+ if (s < size && compare(p + s + 1, p + s, param) > 0)
+ s++;
+ if (compare(&temp, p + s, param) >= 0)
+ break;
+ p[k] = p[s];
+ k = s;
+ }
+ p[k] = temp;
+ }
+
+ void Sort(int (*compare)(const T*, const T*, void *), void *param)
+ {
+ int size = _size;
+ if (size <= 1)
+ return;
+ T* p = (&Front()) - 1;
+ {
+ int i = size / 2;
+ do
+ SortRefDown(p, i, size, compare, param);
+ while (--i != 0);
+ }
+ do
+ {
+ T temp = p[size];
+ p[size--] = p[1];
+ p[1] = temp;
+ SortRefDown(p, 1, size, compare, param);
+ }
+ while (size > 1);
+ }
+};
+
+typedef CRecordVector<int> CIntVector;
+typedef CRecordVector<unsigned int> CUIntVector;
+typedef CRecordVector<bool> CBoolVector;
+typedef CRecordVector<unsigned char> CByteVector;
+typedef CRecordVector<void *> CPointerVector;
+
+template <class T>
+class CObjectVector: public CPointerVector
+{
+public:
+ CObjectVector() {};
+ ~CObjectVector() { Clear(); };
+ CObjectVector(const CObjectVector &v) : CPointerVector() { *this = v; }
+ CObjectVector& operator=(const CObjectVector &v)
+ {
+ Clear();
+ return (*this += v);
+ }
+ CObjectVector& operator+=(const CObjectVector &v)
+ {
+ int size = v.Size();
+ Reserve(Size() + size);
+ for (int i = 0; i < size; i++)
+ Add(v[i]);
+ return *this;
+ }
+ const T& operator[](int index) const { return *((T *)CPointerVector::operator[](index)); }
+ T& operator[](int index) { return *((T *)CPointerVector::operator[](index)); }
+ T& Front() { return operator[](0); }
+ const T& Front() const { return operator[](0); }
+ T& Back() { return operator[](_size - 1); }
+ const T& Back() const { return operator[](_size - 1); }
+ int Add(const T& item) { return CPointerVector::Add(new T(item)); }
+ void Insert(int index, const T& item) { CPointerVector::Insert(index, new T(item)); }
+ virtual void Delete(int index, int num = 1)
+ {
+ TestIndexAndCorrectNum(index, num);
+ for (int i = 0; i < num; i++)
+ delete (T *)(((void **)_items)[index + i]);
+ CPointerVector::Delete(index, num);
+ }
+ int Find(const T& item) const
+ {
+ for (int i = 0; i < Size(); i++)
+ if (item == (*this)[i])
+ return i;
+ return -1;
+ }
+ int FindInSorted(const T& item) const
+ {
+ int left = 0, right = Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ const T& midValue = (*this)[mid];
+ if (item == midValue)
+ return mid;
+ if (item < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ return -1;
+ }
+ int AddToSorted(const T& item)
+ {
+ int left = 0, right = Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ const T& midValue = (*this)[mid];
+ if (item == midValue)
+ {
+ right = mid + 1;
+ break;
+ }
+ if (item < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ Insert(right, item);
+ return right;
+ }
+
+ void Sort(int (*compare)(void *const *, void *const *, void *), void *param)
+ { CPointerVector::Sort(compare, param); }
+
+ static int CompareObjectItems(void *const *a1, void *const *a2, void * /* param */)
+ { return MyCompare(*(*((const T **)a1)), *(*((const T **)a2))); }
+ void Sort() { CPointerVector::Sort(CompareObjectItems, 0); }
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyWindows.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyWindows.cpp
new file mode 100644
index 000000000..bee4acd47
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyWindows.cpp
@@ -0,0 +1,111 @@
+// MyWindows.cpp
+
+#include "StdAfx.h"
+
+#ifndef _WIN32
+
+#include "MyWindows.h"
+#include "Types.h"
+#include <stdlib.h> /* FIXED <malloc.h> */
+
+static inline void *AllocateForBSTR(size_t cb) { return ::malloc(cb); }
+static inline void FreeForBSTR(void *pv) { ::free(pv);}
+
+static UINT MyStringLen(const wchar_t *s)
+{
+ UINT i;
+ for (i = 0; s[i] != '\0'; i++);
+ return i;
+}
+
+BSTR SysAllocStringByteLen(LPCSTR psz, UINT len)
+{
+ // FIXED int realLen = len + sizeof(UINT) + 3;
+ const int LEN_ADDON = sizeof(wchar_t) - 1;
+ int realLen = len + sizeof(UINT) + sizeof(wchar_t) + LEN_ADDON;
+ void *p = AllocateForBSTR(realLen);
+ if (p == 0)
+ return 0;
+ *(UINT *)p = len;
+ // "void *" instead of "BSTR" to avoid unaligned copy of "wchar_t" because of optimizer on Solaris
+ void * bstr = (void *)((UINT *)p + 1);
+ if (psz) memmove(bstr, psz, len); // psz does not always have "wchar_t" alignment.
+ void *pb = (void *)(((Byte *)bstr) + len);
+ memset(pb,0,sizeof(wchar_t) + LEN_ADDON);
+ return (BSTR)bstr;
+}
+
+BSTR SysAllocString(const OLECHAR *sz)
+{
+ if (sz == 0)
+ return 0;
+ UINT strLen = MyStringLen(sz);
+ UINT len = (strLen + 1) * sizeof(OLECHAR);
+ void *p = AllocateForBSTR(len + sizeof(UINT));
+ if (p == 0)
+ return 0;
+ *(UINT *)p = strLen * sizeof(OLECHAR); // FIXED
+ void * bstr = (void *)((UINT *)p + 1);
+ memmove(bstr, sz, len); // sz does not always have "wchar_t" alignment.
+ return (BSTR)bstr;
+}
+
+void SysFreeString(BSTR bstr)
+{
+ if (bstr != 0)
+ FreeForBSTR((UINT *)bstr - 1);
+}
+
+UINT SysStringByteLen(BSTR bstr)
+{
+ if (bstr == 0)
+ return 0;
+ return *((UINT *)bstr - 1);
+
+}
+
+UINT SysStringLen(BSTR bstr)
+{
+ return SysStringByteLen(bstr) / sizeof(OLECHAR);
+}
+
+HRESULT VariantClear(VARIANTARG *prop)
+{
+ if (prop->vt == VT_BSTR)
+ SysFreeString(prop->bstrVal);
+ prop->vt = VT_EMPTY;
+ return S_OK;
+}
+
+HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src)
+{
+ HRESULT res = ::VariantClear(dest);
+ if (res != S_OK)
+ return res;
+ if (src->vt == VT_BSTR)
+ {
+ dest->bstrVal = SysAllocStringByteLen((LPCSTR)src->bstrVal,
+ SysStringByteLen(src->bstrVal));
+ if (dest->bstrVal == 0)
+ return E_OUTOFMEMORY;
+ dest->vt = VT_BSTR;
+ }
+ else
+ *dest = *src;
+ return S_OK;
+}
+
+LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2)
+{
+ if(ft1->dwHighDateTime < ft2->dwHighDateTime)
+ return -1;
+ if(ft1->dwHighDateTime > ft2->dwHighDateTime)
+ return 1;
+ if(ft1->dwLowDateTime < ft2->dwLowDateTime)
+ return -1;
+ if(ft1->dwLowDateTime > ft2->dwLowDateTime)
+ return 1;
+ return 0;
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyWindows.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyWindows.h
new file mode 100644
index 000000000..6d63fad88
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyWindows.h
@@ -0,0 +1,228 @@
+// MyWindows.h
+
+#ifndef __MYWINDOWS_H
+#define __MYWINDOWS_H
+
+#ifdef _WIN32
+
+#include <windows.h>
+
+#define CHAR_PATH_SEPARATOR '\\'
+#define WCHAR_PATH_SEPARATOR L'\\'
+#define STRING_PATH_SEPARATOR "\\"
+#define WSTRING_PATH_SEPARATOR L"\\"
+
+#include "MyGuidDef.h"
+
+#else
+
+#define CHAR_PATH_SEPARATOR '/'
+#define WCHAR_PATH_SEPARATOR L'/'
+#define STRING_PATH_SEPARATOR "/"
+#define WSTRING_PATH_SEPARATOR L"/"
+
+#include <stddef.h> // for wchar_t
+#include <string.h>
+
+#include "MyGuidDef.h"
+
+typedef char CHAR;
+typedef unsigned char UCHAR;
+
+#undef BYTE
+typedef unsigned char BYTE;
+
+typedef short SHORT;
+typedef unsigned short USHORT;
+
+#undef WORD
+typedef unsigned short WORD;
+typedef short VARIANT_BOOL;
+
+typedef int INT;
+typedef Int32 INT32;
+typedef unsigned int UINT;
+typedef UInt32 UINT32;
+typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit
+typedef UINT32 ULONG;
+
+#undef DWORD
+typedef UINT32 DWORD;
+
+typedef Int64 LONGLONG;
+typedef UInt64 ULONGLONG;
+
+typedef struct LARGE_INTEGER { LONGLONG QuadPart; }LARGE_INTEGER;
+typedef struct _ULARGE_INTEGER { ULONGLONG QuadPart;} ULARGE_INTEGER;
+
+typedef const CHAR *LPCSTR;
+typedef wchar_t WCHAR;
+
+#ifdef _UNICODE
+typedef WCHAR TCHAR;
+#define lstrcpy wcscpy
+#define lstrcat wcscat
+#define lstrlen wcslen
+#else
+typedef CHAR TCHAR;
+#define lstrcpy strcpy
+#define lstrcat strcat
+#define lstrlen strlen
+#endif
+
+typedef const TCHAR *LPCTSTR;
+typedef WCHAR OLECHAR;
+typedef const WCHAR *LPCWSTR;
+typedef OLECHAR *BSTR;
+typedef const OLECHAR *LPCOLESTR;
+typedef OLECHAR *LPOLESTR;
+
+typedef struct _FILETIME
+{
+ DWORD dwLowDateTime;
+ DWORD dwHighDateTime;
+}FILETIME;
+
+#define HRESULT LONG
+#define FAILED(Status) ((HRESULT)(Status)<0)
+typedef ULONG PROPID;
+typedef LONG SCODE;
+
+#define S_OK ((HRESULT)0x00000000L)
+#define S_FALSE ((HRESULT)0x00000001L)
+#define E_NOTIMPL ((HRESULT)0x80004001L)
+#define E_NOINTERFACE ((HRESULT)0x80004002L)
+#define E_ABORT ((HRESULT)0x80004004L)
+#define E_FAIL ((HRESULT)0x80004005L)
+#define STG_E_INVALIDFUNCTION ((HRESULT)0x80030001L)
+#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
+#define E_INVALIDARG ((HRESULT)0x80070057L)
+
+#ifdef _MSC_VER
+#define STDMETHODCALLTYPE __stdcall
+#else
+#define STDMETHODCALLTYPE
+#endif
+
+#define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f
+#define STDMETHOD(f) STDMETHOD_(HRESULT, f)
+#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
+#define STDMETHODIMP STDMETHODIMP_(HRESULT)
+
+#define PURE = 0
+
+#define MIDL_INTERFACE(x) struct
+
+#ifdef __cplusplus
+
+DEFINE_GUID(IID_IUnknown,
+0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
+struct IUnknown
+{
+ STDMETHOD(QueryInterface) (REFIID iid, void **outObject) PURE;
+ STDMETHOD_(ULONG, AddRef)() PURE;
+ STDMETHOD_(ULONG, Release)() PURE;
+ #ifndef _WIN32
+ virtual ~IUnknown() {}
+ #endif
+};
+
+typedef IUnknown *LPUNKNOWN;
+
+#endif
+
+#define VARIANT_TRUE ((VARIANT_BOOL)-1)
+#define VARIANT_FALSE ((VARIANT_BOOL)0)
+
+enum VARENUM
+{
+ VT_EMPTY = 0,
+ VT_NULL = 1,
+ VT_I2 = 2,
+ VT_I4 = 3,
+ VT_R4 = 4,
+ VT_R8 = 5,
+ VT_CY = 6,
+ VT_DATE = 7,
+ VT_BSTR = 8,
+ VT_DISPATCH = 9,
+ VT_ERROR = 10,
+ VT_BOOL = 11,
+ VT_VARIANT = 12,
+ VT_UNKNOWN = 13,
+ VT_DECIMAL = 14,
+ VT_I1 = 16,
+ VT_UI1 = 17,
+ VT_UI2 = 18,
+ VT_UI4 = 19,
+ VT_I8 = 20,
+ VT_UI8 = 21,
+ VT_INT = 22,
+ VT_UINT = 23,
+ VT_VOID = 24,
+ VT_HRESULT = 25,
+ VT_FILETIME = 64
+};
+
+typedef unsigned short VARTYPE;
+typedef WORD PROPVAR_PAD1;
+typedef WORD PROPVAR_PAD2;
+typedef WORD PROPVAR_PAD3;
+
+#ifdef __cplusplus
+
+typedef struct tagPROPVARIANT
+{
+ VARTYPE vt;
+ PROPVAR_PAD1 wReserved1;
+ PROPVAR_PAD2 wReserved2;
+ PROPVAR_PAD3 wReserved3;
+ union
+ {
+ CHAR cVal;
+ UCHAR bVal;
+ SHORT iVal;
+ USHORT uiVal;
+ LONG lVal;
+ ULONG ulVal;
+ INT intVal;
+ UINT uintVal;
+ LARGE_INTEGER hVal;
+ ULARGE_INTEGER uhVal;
+ VARIANT_BOOL boolVal;
+ SCODE scode;
+ FILETIME filetime;
+ BSTR bstrVal;
+ };
+} PROPVARIANT;
+
+typedef PROPVARIANT tagVARIANT;
+typedef tagVARIANT VARIANT;
+typedef VARIANT VARIANTARG;
+
+MY_EXTERN_C HRESULT VariantClear(VARIANTARG *prop);
+MY_EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src);
+
+#endif
+
+MY_EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len);
+MY_EXTERN_C BSTR SysAllocString(const OLECHAR *sz);
+MY_EXTERN_C void SysFreeString(BSTR bstr);
+MY_EXTERN_C UINT SysStringByteLen(BSTR bstr);
+MY_EXTERN_C UINT SysStringLen(BSTR bstr);
+
+/* MY_EXTERN_C DWORD GetLastError(); */
+MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2);
+
+#define CP_ACP 0
+#define CP_OEMCP 1
+
+typedef enum tagSTREAM_SEEK
+{
+ STREAM_SEEK_SET = 0,
+ STREAM_SEEK_CUR = 1,
+ STREAM_SEEK_END = 2
+} STREAM_SEEK;
+
+#endif
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyXml.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyXml.cpp
new file mode 100644
index 000000000..8aa9ce8cd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyXml.cpp
@@ -0,0 +1,209 @@
+// MyXml.cpp
+
+#include "StdAfx.h"
+
+#include "MyXml.h"
+
+static bool IsValidChar(char c)
+{
+ return
+ c >= 'a' && c <= 'z' ||
+ c >= 'A' && c <= 'Z' ||
+ c >= '0' && c <= '9' ||
+ c == '-';
+}
+
+static bool IsSpaceChar(char c)
+{
+ return (c == ' ' || c == '\t' || c == 0x0D || c == 0x0A);
+}
+
+#define SKIP_SPACES(s, pos) while (IsSpaceChar(s[pos])) pos++;
+
+static bool ReadProperty(const AString &s, int &pos, CXmlProp &prop)
+{
+ prop.Name.Empty();
+ prop.Value.Empty();
+ for (; pos < s.Length(); pos++)
+ {
+ char c = s[pos];
+ if (!IsValidChar(c))
+ break;
+ prop.Name += c;
+ }
+
+ if (prop.Name.IsEmpty())
+ return false;
+
+ SKIP_SPACES(s, pos);
+ if (s[pos++] != '=')
+ return false;
+
+ SKIP_SPACES(s, pos);
+ if (s[pos++] != '\"')
+ return false;
+
+ while (pos < s.Length())
+ {
+ char c = s[pos++];
+ if (c == '\"')
+ return true;
+ prop.Value += c;
+ }
+ return false;
+}
+
+int CXmlItem::FindProperty(const AString &propName) const
+{
+ for (int i = 0; i < Props.Size(); i++)
+ if (Props[i].Name == propName)
+ return i;
+ return -1;
+}
+
+AString CXmlItem::GetPropertyValue(const AString &propName) const
+{
+ int index = FindProperty(propName);
+ if (index >= 0)
+ return Props[index].Value;
+ return AString();
+}
+
+bool CXmlItem::IsTagged(const AString &tag) const
+{
+ return (IsTag && Name == tag);
+}
+
+int CXmlItem::FindSubTag(const AString &tag) const
+{
+ for (int i = 0; i < SubItems.Size(); i++)
+ if (SubItems[i].IsTagged(tag))
+ return i;
+ return -1;
+}
+
+AString CXmlItem::GetSubString() const
+{
+ if (SubItems.Size() == 1)
+ {
+ const CXmlItem &item = SubItems[0];
+ if (!item.IsTag)
+ return item.Name;
+ }
+ return AString();
+}
+
+AString CXmlItem::GetSubStringForTag(const AString &tag) const
+{
+ int index = FindSubTag(tag);
+ if (index >= 0)
+ return SubItems[index].GetSubString();
+ return AString();
+}
+
+bool CXmlItem::ParseItems(const AString &s, int &pos, int numAllowedLevels)
+{
+ if (numAllowedLevels == 0)
+ return false;
+ SubItems.Clear();
+ AString finishString = "</";
+ for (;;)
+ {
+ SKIP_SPACES(s, pos);
+
+ if (s.Mid(pos, finishString.Length()) == finishString)
+ return true;
+
+ CXmlItem item;
+ if (!item.ParseItem(s, pos, numAllowedLevels - 1))
+ return false;
+ SubItems.Add(item);
+ }
+}
+
+bool CXmlItem::ParseItem(const AString &s, int &pos, int numAllowedLevels)
+{
+ SKIP_SPACES(s, pos);
+
+ int pos2 = s.Find('<', pos);
+ if (pos2 < 0)
+ return false;
+ if (pos2 != pos)
+ {
+ IsTag = false;
+ Name += s.Mid(pos, pos2 - pos);
+ pos = pos2;
+ return true;
+ }
+ IsTag = true;
+
+ pos++;
+ SKIP_SPACES(s, pos);
+
+ for (; pos < s.Length(); pos++)
+ {
+ char c = s[pos];
+ if (!IsValidChar(c))
+ break;
+ Name += c;
+ }
+ if (Name.IsEmpty() || pos == s.Length())
+ return false;
+
+ int posTemp = pos;
+ for (;;)
+ {
+ SKIP_SPACES(s, pos);
+ if (s[pos] == '/')
+ {
+ pos++;
+ // SKIP_SPACES(s, pos);
+ return (s[pos++] == '>');
+ }
+ if (s[pos] == '>')
+ {
+ if (!ParseItems(s, ++pos, numAllowedLevels))
+ return false;
+ AString finishString = AString("</") + Name + AString(">");
+ if (s.Mid(pos, finishString.Length()) != finishString)
+ return false;
+ pos += finishString.Length();
+ return true;
+ }
+ if (posTemp == pos)
+ return false;
+
+ CXmlProp prop;
+ if (!ReadProperty(s, pos, prop))
+ return false;
+ Props.Add(prop);
+ posTemp = pos;
+ }
+}
+
+static bool SkipHeader(const AString &s, int &pos, const AString &startString, const AString &endString)
+{
+ SKIP_SPACES(s, pos);
+ if (s.Mid(pos, startString.Length()) == startString)
+ {
+ pos = s.Find(endString, pos);
+ if (pos < 0)
+ return false;
+ pos += endString.Length();
+ SKIP_SPACES(s, pos);
+ }
+ return true;
+}
+
+bool CXml::Parse(const AString &s)
+{
+ int pos = 0;
+ if (!SkipHeader(s, pos, "<?xml", "?>"))
+ return false;
+ if (!SkipHeader(s, pos, "<!DOCTYPE", ">"))
+ return false;
+ if (!Root.ParseItem(s, pos, 1000))
+ return false;
+ SKIP_SPACES(s, pos);
+ return (pos == s.Length() && Root.IsTag);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyXml.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyXml.h
new file mode 100644
index 000000000..c6e8829ad
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/MyXml.h
@@ -0,0 +1,40 @@
+// MyXml.h
+
+#ifndef __MYXML_H
+#define __MYXML_H
+
+#include "MyString.h"
+
+struct CXmlProp
+{
+ AString Name;
+ AString Value;
+};
+
+class CXmlItem
+{
+ bool ParseItems(const AString &s, int &pos, int numAllowedLevels);
+
+public:
+ AString Name;
+ bool IsTag;
+ CObjectVector<CXmlProp> Props;
+ CObjectVector<CXmlItem> SubItems;
+
+ bool ParseItem(const AString &s, int &pos, int numAllowedLevels);
+
+ bool IsTagged(const AString &tag) const;
+ int FindProperty(const AString &propName) const;
+ AString GetPropertyValue(const AString &propName) const;
+ AString GetSubString() const;
+ int FindSubTag(const AString &tag) const;
+ AString GetSubStringForTag(const AString &tag) const;
+};
+
+struct CXml
+{
+ CXmlItem Root;
+ bool Parse(const AString &s);
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/NewHandler.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/NewHandler.h
new file mode 100644
index 000000000..215ba05f1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/NewHandler.h
@@ -0,0 +1,16 @@
+// Common/NewHandler.h
+
+#ifndef __COMMON_NEWHANDLER_H
+#define __COMMON_NEWHANDLER_H
+
+class CNewException {};
+
+#ifdef _WIN32
+void
+#ifdef _MSC_VER
+__cdecl
+#endif
+operator delete(void *p) throw();
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdInStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdInStream.cpp
new file mode 100644
index 000000000..b3d009205
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdInStream.cpp
@@ -0,0 +1,84 @@
+// Common/StdInStream.cpp
+
+#include "StdAfx.h"
+
+#include <tchar.h>
+#include "StdInStream.h"
+
+#ifdef _MSC_VER
+// "was declared deprecated" disabling
+#pragma warning(disable : 4996 )
+#endif
+
+static const char kIllegalChar = '\0';
+static const char kNewLineChar = '\n';
+
+static const char *kEOFMessage = "Unexpected end of input stream";
+static const char *kReadErrorMessage ="Error reading input stream";
+static const char *kIllegalCharMessage = "Illegal character in input stream";
+
+static LPCTSTR kFileOpenMode = TEXT("r");
+
+CStdInStream g_StdIn(stdin);
+
+bool CStdInStream::Open(LPCTSTR fileName)
+{
+ Close();
+ _stream = _tfopen(fileName, kFileOpenMode);
+ _streamIsOpen = (_stream != 0);
+ return _streamIsOpen;
+}
+
+bool CStdInStream::Close()
+{
+ if (!_streamIsOpen)
+ return true;
+ _streamIsOpen = (fclose(_stream) != 0);
+ return !_streamIsOpen;
+}
+
+CStdInStream::~CStdInStream()
+{
+ Close();
+}
+
+AString CStdInStream::ScanStringUntilNewLine()
+{
+ AString s;
+ for (;;)
+ {
+ int intChar = GetChar();
+ if (intChar == EOF)
+ throw kEOFMessage;
+ char c = char(intChar);
+ if (c == kIllegalChar)
+ throw kIllegalCharMessage;
+ if (c == kNewLineChar)
+ break;
+ s += c;
+ }
+ return s;
+}
+
+void CStdInStream::ReadToString(AString &resultString)
+{
+ resultString.Empty();
+ int c;
+ while ((c = GetChar()) != EOF)
+ resultString += char(c);
+}
+
+bool CStdInStream::Eof()
+{
+ return (feof(_stream) != 0);
+}
+
+int CStdInStream::GetChar()
+{
+ int c = fgetc(_stream); // getc() doesn't work in BeOS?
+ if (c == EOF && !Eof())
+ throw kReadErrorMessage;
+ return c;
+}
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdInStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdInStream.h
new file mode 100644
index 000000000..9edc25eba
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdInStream.h
@@ -0,0 +1,32 @@
+// Common/StdInStream.h
+
+#ifndef __COMMON_STDINSTREAM_H
+#define __COMMON_STDINSTREAM_H
+
+#include <stdio.h>
+
+#include "MyString.h"
+#include "Types.h"
+
+class CStdInStream
+{
+ bool _streamIsOpen;
+ FILE *_stream;
+public:
+ CStdInStream(): _streamIsOpen(false) {};
+ CStdInStream(FILE *stream): _streamIsOpen(false), _stream(stream) {};
+ ~CStdInStream();
+ bool Open(LPCTSTR fileName);
+ bool Close();
+
+ AString ScanStringUntilNewLine();
+ void ReadToString(AString &resultString);
+ UString ScanUStringUntilNewLine();
+
+ bool Eof();
+ int GetChar();
+};
+
+extern CStdInStream g_StdIn;
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdOutStream.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdOutStream.cpp
new file mode 100644
index 000000000..b93e255f9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdOutStream.cpp
@@ -0,0 +1,93 @@
+// Common/StdOutStream.cpp
+
+#include "StdAfx.h"
+
+#include <tchar.h>
+
+#include "StdOutStream.h"
+#include "IntToString.h"
+#include "StringConvert.h"
+
+#ifdef _MSC_VER
+// "was declared deprecated" disabling
+#pragma warning(disable : 4996 )
+#endif
+
+static const char kNewLineChar = '\n';
+
+static const char *kFileOpenMode = "wt";
+
+CStdOutStream g_StdOut(stdout);
+CStdOutStream g_StdErr(stderr);
+
+bool CStdOutStream::Open(const char *fileName)
+{
+ Close();
+ _stream = fopen(fileName, kFileOpenMode);
+ _streamIsOpen = (_stream != 0);
+ return _streamIsOpen;
+}
+
+bool CStdOutStream::Close()
+{
+ if (!_streamIsOpen)
+ return true;
+ if (fclose(_stream) != 0)
+ return false;
+ _stream = 0;
+ _streamIsOpen = false;
+ return true;
+}
+
+bool CStdOutStream::Flush()
+{
+ return (fflush(_stream) == 0);
+}
+
+CStdOutStream::~CStdOutStream ()
+{
+ Close();
+}
+
+CStdOutStream & CStdOutStream::operator<<(CStdOutStream & (*aFunction)(CStdOutStream &))
+{
+ (*aFunction)(*this);
+ return *this;
+}
+
+CStdOutStream & endl(CStdOutStream & outStream)
+{
+ return outStream << kNewLineChar;
+}
+
+CStdOutStream & CStdOutStream::operator<<(const char *string)
+{
+ fputs(string, _stream);
+ return *this;
+}
+
+CStdOutStream & CStdOutStream::operator<<(const wchar_t *string)
+{
+ *this << (const char *)UnicodeStringToMultiByte(string, CP_OEMCP);
+ return *this;
+}
+
+CStdOutStream & CStdOutStream::operator<<(char c)
+{
+ fputc(c, _stream);
+ return *this;
+}
+
+CStdOutStream & CStdOutStream::operator<<(int number)
+{
+ char textString[32];
+ ConvertInt64ToString(number, textString);
+ return operator<<(textString);
+}
+
+CStdOutStream & CStdOutStream::operator<<(UInt64 number)
+{
+ char textString[32];
+ ConvertUInt64ToString(number, textString);
+ return operator<<(textString);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdOutStream.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdOutStream.h
new file mode 100644
index 000000000..b0b2c615c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StdOutStream.h
@@ -0,0 +1,35 @@
+// Common/StdOutStream.h
+
+#ifndef __COMMON_STDOUTSTREAM_H
+#define __COMMON_STDOUTSTREAM_H
+
+#include <stdio.h>
+
+#include "Types.h"
+
+class CStdOutStream
+{
+ bool _streamIsOpen;
+ FILE *_stream;
+public:
+ CStdOutStream (): _streamIsOpen(false), _stream(0) {};
+ CStdOutStream (FILE *stream): _streamIsOpen(false), _stream(stream) {};
+ ~CStdOutStream ();
+ operator FILE *() { return _stream; }
+ bool Open(const char *fileName);
+ bool Close();
+ bool Flush();
+ CStdOutStream & operator<<(CStdOutStream & (* aFunction)(CStdOutStream &));
+ CStdOutStream & operator<<(const char *string);
+ CStdOutStream & operator<<(const wchar_t *string);
+ CStdOutStream & operator<<(char c);
+ CStdOutStream & operator<<(int number);
+ CStdOutStream & operator<<(UInt64 number);
+};
+
+CStdOutStream & endl(CStdOutStream & outStream);
+
+extern CStdOutStream g_StdOut;
+extern CStdOutStream g_StdErr;
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringConvert.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringConvert.cpp
new file mode 100644
index 000000000..a92470fd7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringConvert.cpp
@@ -0,0 +1,104 @@
+// Common/StringConvert.cpp
+
+#include "StdAfx.h"
+#include <stdlib.h>
+
+#include "StringConvert.h"
+extern "C"
+{
+int global_use_utf16_conversion = 0;
+}
+
+namespace utf8
+{
+#include "UTFConvert.cpp"
+}
+
+
+#ifdef LOCALE_IS_UTF8
+
+UString MultiByteToUnicodeString(const AString &srcString, UINT /*codePage*/)
+{
+ if ((global_use_utf16_conversion) && (!srcString.IsEmpty()))
+ {
+ UString resultString;
+ bool bret = utf8::ConvertUTF8ToUnicode(srcString,resultString);
+ if (bret) return resultString;
+ }
+
+ UString resultString;
+ for (int i = 0; i < srcString.Length(); i++)
+ resultString += wchar_t(srcString[i] & 255);
+
+ return resultString;
+}
+
+AString UnicodeStringToMultiByte(const UString &srcString, UINT /*codePage*/)
+{
+ if ((global_use_utf16_conversion) && (!srcString.IsEmpty()))
+ {
+ AString resultString;
+ bool bret = utf8::ConvertUnicodeToUTF8(srcString,resultString);
+ if (bret) return resultString;
+ }
+
+ AString resultString;
+ for (int i = 0; i < srcString.Length(); i++)
+ {
+ if (srcString[i] >= 256) resultString += '?';
+ else resultString += char(srcString[i]);
+ }
+ return resultString;
+}
+
+#else /* LOCALE_IS_UTF8 */
+
+UString MultiByteToUnicodeString(const AString &srcString, UINT /*codePage*/)
+{
+#ifdef HAVE_MBSTOWCS
+ if ((global_use_utf16_conversion) && (!srcString.IsEmpty()))
+ {
+ UString resultString;
+ int numChars = mbstowcs(resultString.GetBuffer(srcString.Length()),srcString,srcString.Length()+1);
+ if (numChars >= 0) {
+ resultString.ReleaseBuffer(numChars);
+ return resultString;
+ }
+ }
+#endif
+
+ UString resultString;
+ for (int i = 0; i < srcString.Length(); i++)
+ resultString += wchar_t(srcString[i] & 255);
+
+ return resultString;
+}
+
+AString UnicodeStringToMultiByte(const UString &srcString, UINT /*codePage*/)
+{
+#ifdef HAVE_WCSTOMBS
+ if ((global_use_utf16_conversion) && (!srcString.IsEmpty()))
+ {
+ AString resultString;
+ int numRequiredBytes = srcString.Length() * 6+1;
+ int numChars = wcstombs(resultString.GetBuffer(numRequiredBytes),srcString,numRequiredBytes);
+ if (numChars >= 0) {
+ resultString.ReleaseBuffer(numChars);
+ return resultString;
+ }
+ }
+#endif
+
+ AString resultString;
+ for (int i = 0; i < srcString.Length(); i++)
+ {
+ if (srcString[i] >= 256) resultString += '?';
+ else resultString += char(srcString[i]);
+ }
+ return resultString;
+}
+
+#endif /* LOCALE_IS_UTF8 */
+
+#include "UTFConvert.cpp"
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringConvert.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringConvert.h
new file mode 100644
index 000000000..0c37eb075
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringConvert.h
@@ -0,0 +1,73 @@
+// Common/StringConvert.h
+
+#ifndef __COMMON_STRINGCONVERT_H
+#define __COMMON_STRINGCONVERT_H
+
+#include "MyWindows.h"
+#include "MyString.h"
+#include "Types.h"
+
+UString MultiByteToUnicodeString(const AString &srcString, UINT codePage = CP_ACP);
+AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage, char defaultChar, bool &defaultCharWasUsed);
+AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage = CP_ACP);
+
+
+inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString)
+ { return unicodeString; }
+inline const UString& GetUnicodeString(const UString &unicodeString)
+ { return unicodeString; }
+inline UString GetUnicodeString(const AString &ansiString)
+ { return MultiByteToUnicodeString(ansiString); }
+inline UString GetUnicodeString(const AString &multiByteString, UINT codePage)
+ { return MultiByteToUnicodeString(multiByteString, codePage); }
+inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString, UINT)
+ { return unicodeString; }
+inline const UString& GetUnicodeString(const UString &unicodeString, UINT)
+ { return unicodeString; }
+
+inline const char* GetAnsiString(const char* ansiString)
+ { return ansiString; }
+inline const AString& GetAnsiString(const AString &ansiString)
+ { return ansiString; }
+inline AString GetAnsiString(const UString &unicodeString)
+ { return UnicodeStringToMultiByte(unicodeString); }
+
+inline const char* GetOemString(const char* oemString)
+ { return oemString; }
+inline const AString& GetOemString(const AString &oemString)
+ { return oemString; }
+inline AString GetOemString(const UString &unicodeString)
+ { return UnicodeStringToMultiByte(unicodeString, CP_OEMCP); }
+
+
+#ifdef _UNICODE
+ inline const wchar_t* GetSystemString(const wchar_t* unicodeString)
+ { return unicodeString;}
+ inline const UString& GetSystemString(const UString &unicodeString)
+ { return unicodeString;}
+ inline const wchar_t* GetSystemString(const wchar_t* unicodeString, UINT /* codePage */)
+ { return unicodeString;}
+ inline const UString& GetSystemString(const UString &unicodeString, UINT /* codePage */)
+ { return unicodeString;}
+ inline UString GetSystemString(const AString &multiByteString, UINT codePage)
+ { return MultiByteToUnicodeString(multiByteString, codePage);}
+ inline UString GetSystemString(const AString &multiByteString)
+ { return MultiByteToUnicodeString(multiByteString);}
+#else
+ inline const char* GetSystemString(const char *ansiString)
+ { return ansiString; }
+ inline const AString& GetSystemString(const AString &multiByteString, UINT)
+ { return multiByteString; }
+ inline const char * GetSystemString(const char *multiByteString, UINT)
+ { return multiByteString; }
+ inline AString GetSystemString(const UString &unicodeString)
+ { return UnicodeStringToMultiByte(unicodeString); }
+ inline AString GetSystemString(const UString &unicodeString, UINT codePage)
+ { return UnicodeStringToMultiByte(unicodeString, codePage); }
+#endif
+
+#ifndef _WIN32_WCE
+AString SystemStringToOemString(const CSysString &srcString);
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringToInt.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringToInt.cpp
new file mode 100644
index 000000000..9473766bc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringToInt.cpp
@@ -0,0 +1,90 @@
+// Common/StringToInt.cpp
+
+#include "StdAfx.h"
+
+#include "StringToInt.h"
+
+UInt64 ConvertStringToUInt64(const char *s, const char **end)
+{
+ UInt64 result = 0;
+ for (;;)
+ {
+ char c = *s;
+ if (c < '0' || c > '9')
+ {
+ if (end != NULL)
+ *end = s;
+ return result;
+ }
+ result *= 10;
+ result += (c - '0');
+ s++;
+ }
+}
+
+UInt64 ConvertOctStringToUInt64(const char *s, const char **end)
+{
+ UInt64 result = 0;
+ for (;;)
+ {
+ char c = *s;
+ if (c < '0' || c > '7')
+ {
+ if (end != NULL)
+ *end = s;
+ return result;
+ }
+ result <<= 3;
+ result += (c - '0');
+ s++;
+ }
+}
+
+UInt64 ConvertHexStringToUInt64(const char *s, const char **end)
+{
+ UInt64 result = 0;
+ for (;;)
+ {
+ char c = *s;
+ UInt32 v;
+ if (c >= '0' && c <= '9') v = (c - '0');
+ else if (c >= 'A' && c <= 'F') v = 10 + (c - 'A');
+ else if (c >= 'a' && c <= 'f') v = 10 + (c - 'a');
+ else
+ {
+ if (end != NULL)
+ *end = s;
+ return result;
+ }
+ result <<= 4;
+ result |= v;
+ s++;
+ }
+}
+
+
+UInt64 ConvertStringToUInt64(const wchar_t *s, const wchar_t **end)
+{
+ UInt64 result = 0;
+ for (;;)
+ {
+ wchar_t c = *s;
+ if (c < '0' || c > '9')
+ {
+ if (end != NULL)
+ *end = s;
+ return result;
+ }
+ result *= 10;
+ result += (c - '0');
+ s++;
+ }
+}
+
+
+Int64 ConvertStringToInt64(const char *s, const char **end)
+{
+ if (*s == '-')
+ return -(Int64)ConvertStringToUInt64(s + 1, end);
+ return ConvertStringToUInt64(s, end);
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringToInt.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringToInt.h
new file mode 100644
index 000000000..c0d860eff
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/StringToInt.h
@@ -0,0 +1,18 @@
+// Common/StringToInt.h
+
+#ifndef __COMMON_STRINGTOINT_H
+#define __COMMON_STRINGTOINT_H
+
+#include <string.h>
+#include "Types.h"
+
+UInt64 ConvertStringToUInt64(const char *s, const char **end);
+UInt64 ConvertOctStringToUInt64(const char *s, const char **end);
+UInt64 ConvertHexStringToUInt64(const char *s, const char **end);
+UInt64 ConvertStringToUInt64(const wchar_t *s, const wchar_t **end);
+
+Int64 ConvertStringToInt64(const char *s, const char **end);
+
+#endif
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/TextConfig.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/TextConfig.cpp
new file mode 100644
index 000000000..6a55012c3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/TextConfig.cpp
@@ -0,0 +1,138 @@
+// Common/TextConfig.cpp
+
+#include "StdAfx.h"
+
+#include "TextConfig.h"
+
+#include "Defs.h"
+#include "UTFConvert.h"
+
+static bool IsDelimitChar(char c)
+{
+ return (c == ' ' || c == 0x0A || c == 0x0D ||
+ c == '\0' || c == '\t');
+}
+
+static AString GetIDString(const char *string, int &finishPos)
+{
+ AString result;
+ for (finishPos = 0; ; finishPos++)
+ {
+ char c = string[finishPos];
+ if (IsDelimitChar(c) || c == '=')
+ break;
+ result += c;
+ }
+ return result;
+}
+
+static bool WaitNextLine(const AString &string, int &pos)
+{
+ for (;pos < string.Length(); pos++)
+ if (string[pos] == 0x0A)
+ return true;
+ return false;
+}
+
+static bool SkipSpaces(const AString &string, int &pos)
+{
+ for (;pos < string.Length(); pos++)
+ {
+ char c = string[pos];
+ if (!IsDelimitChar(c))
+ {
+ if (c != ';')
+ return true;
+ if (!WaitNextLine(string, pos))
+ return false;
+ }
+ }
+ return false;
+}
+
+bool GetTextConfig(const AString &string, CObjectVector<CTextConfigPair> &pairs)
+{
+ pairs.Clear();
+ int pos = 0;
+
+ /////////////////////
+ // read strings
+
+ for (;;)
+ {
+ if (!SkipSpaces(string, pos))
+ break;
+ CTextConfigPair pair;
+ int finishPos;
+ AString temp = GetIDString(((const char *)string) + pos, finishPos);
+ if (!ConvertUTF8ToUnicode(temp, pair.ID))
+ return false;
+ if (finishPos == 0)
+ return false;
+ pos += finishPos;
+ if (!SkipSpaces(string, pos))
+ return false;
+ if (string[pos] != '=')
+ return false;
+ pos++;
+ if (!SkipSpaces(string, pos))
+ return false;
+ if (string[pos] != '\"')
+ return false;
+ pos++;
+ AString message;
+ for (;;)
+ {
+ if (pos >= string.Length())
+ return false;
+ char c = string[pos++];
+ if (c == '\"')
+ break;
+ if (c == '\\') // FIXME ?
+ {
+ char c = string[pos++];
+ switch(c)
+ {
+ case 'n':
+ message += '\n';
+ break;
+ case 't':
+ message += '\t';
+ break;
+ case '\\': // FIXME ?
+ message += '\\';
+ break;
+ case '\"':
+ message += '\"';
+ break;
+ default:
+ message += '\\'; // FIXME ?
+ message += c;
+ break;
+ }
+ }
+ else
+ message += c;
+ }
+ if (!ConvertUTF8ToUnicode(message, pair.String))
+ return false;
+ pairs.Add(pair);
+ }
+ return true;
+}
+
+int FindTextConfigItem(const CObjectVector<CTextConfigPair> &pairs, const UString &id)
+{
+ for (int i = 0; i < pairs.Size(); i++)
+ if (pairs[i].ID.Compare(id) == 0)
+ return i;
+ return -1;
+}
+
+UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const UString &id)
+{
+ int index = FindTextConfigItem(pairs, id);
+ if (index < 0)
+ return UString();
+ return pairs[index].String;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/TextConfig.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/TextConfig.h
new file mode 100644
index 000000000..a25142a70
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/TextConfig.h
@@ -0,0 +1,22 @@
+// Common/TextConfig.h
+
+#ifndef __COMMON_TEXTCONFIG_H
+#define __COMMON_TEXTCONFIG_H
+
+#include "MyVector.h"
+#include "MyString.h"
+
+struct CTextConfigPair
+{
+ UString ID;
+ UString String;
+};
+
+bool GetTextConfig(const AString &text, CObjectVector<CTextConfigPair> &pairs);
+
+int FindTextConfigItem(const CObjectVector<CTextConfigPair> &pairs, const UString &id);
+UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const UString &id);
+
+#endif
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Types.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Types.h
new file mode 100644
index 000000000..9365b327f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Types.h
@@ -0,0 +1,11 @@
+// Common/Types.h
+
+#ifndef __COMMON_TYPES_H
+#define __COMMON_TYPES_H
+
+#include "../../C/Types.h"
+
+typedef int HRes;
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/UTFConvert.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/UTFConvert.cpp
new file mode 100644
index 000000000..9d1fd0058
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/UTFConvert.cpp
@@ -0,0 +1,145 @@
+// UTFConvert.cpp
+
+#include "StdAfx.h"
+
+#include "UTFConvert.h"
+#include "Types.h"
+
+static const Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+
+static Bool Utf8_To_Utf16(wchar_t *dest, size_t *destLen, const char *src, size_t srcLen)
+{
+ size_t destPos = 0, srcPos = 0;
+ for (;;)
+ {
+ Byte c;
+ int numAdds;
+ if (srcPos == srcLen)
+ {
+ *destLen = destPos;
+ return True;
+ }
+ c = (Byte)src[srcPos++];
+
+ if (c < 0x80)
+ {
+ if (dest)
+ dest[destPos] = (wchar_t)c;
+ destPos++;
+ continue;
+ }
+ if (c < 0xC0)
+ break;
+ for (numAdds = 1; numAdds < 5; numAdds++)
+ if (c < kUtf8Limits[numAdds])
+ break;
+ UInt32 value = (c - kUtf8Limits[numAdds - 1]);
+
+ do
+ {
+ Byte c2;
+ if (srcPos == srcLen)
+ break;
+ c2 = (Byte)src[srcPos++];
+ if (c2 < 0x80 || c2 >= 0xC0)
+ break;
+ value <<= 6;
+ value |= (c2 - 0x80);
+ }
+ while (--numAdds != 0);
+
+ if (value < 0x10000)
+ {
+ if (dest)
+ dest[destPos] = (wchar_t)value;
+ destPos++;
+ }
+ else
+ {
+ value -= 0x10000;
+ if (value >= 0x100000)
+ break;
+ if (dest)
+ {
+ dest[destPos + 0] = (wchar_t)(0xD800 + (value >> 10));
+ dest[destPos + 1] = (wchar_t)(0xDC00 + (value & 0x3FF));
+ }
+ destPos += 2;
+ }
+ }
+ *destLen = destPos;
+ return False;
+}
+
+static Bool Utf16_To_Utf8(char *dest, size_t *destLen, const wchar_t *src, size_t srcLen)
+{
+ size_t destPos = 0, srcPos = 0;
+ for (;;)
+ {
+ unsigned numAdds;
+ UInt32 value;
+ if (srcPos == srcLen)
+ {
+ *destLen = destPos;
+ return True;
+ }
+ value = src[srcPos++];
+ if (value < 0x80)
+ {
+ if (dest)
+ dest[destPos] = (char)value;
+ destPos++;
+ continue;
+ }
+ if (value >= 0xD800 && value < 0xE000)
+ {
+ UInt32 c2;
+ if (value >= 0xDC00 || srcPos == srcLen)
+ break;
+ c2 = src[srcPos++];
+ if (c2 < 0xDC00 || c2 >= 0xE000)
+ break;
+ value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
+ }
+ for (numAdds = 1; numAdds < 5; numAdds++)
+ if (value < (((UInt32)1) << (numAdds * 5 + 6)))
+ break;
+ if (dest)
+ dest[destPos] = (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds)));
+ destPos++;
+ do
+ {
+ numAdds--;
+ if (dest)
+ dest[destPos] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F));
+ destPos++;
+ }
+ while (numAdds != 0);
+ }
+ *destLen = destPos;
+ return False;
+}
+
+bool ConvertUTF8ToUnicode(const AString &src, UString &dest)
+{
+ dest.Empty();
+ size_t destLen = 0;
+ Utf8_To_Utf16(NULL, &destLen, src, src.Length());
+ wchar_t *p = dest.GetBuffer((int)destLen);
+ Bool res = Utf8_To_Utf16(p, &destLen, src, src.Length());
+ p[destLen] = 0;
+ dest.ReleaseBuffer();
+ return res ? true : false;
+}
+
+bool ConvertUnicodeToUTF8(const UString &src, AString &dest)
+{
+ dest.Empty();
+ size_t destLen = 0;
+ Utf16_To_Utf8(NULL, &destLen, src, src.Length());
+ char *p = dest.GetBuffer((int)destLen);
+ Bool res = Utf16_To_Utf8(p, &destLen, src, src.Length());
+ p[destLen] = 0;
+ dest.ReleaseBuffer();
+ return res ? true : false;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/UTFConvert.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/UTFConvert.h
new file mode 100644
index 000000000..2a14600d9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/UTFConvert.h
@@ -0,0 +1,11 @@
+// Common/UTFConvert.h
+
+#ifndef __COMMON_UTFCONVERT_H
+#define __COMMON_UTFCONVERT_H
+
+#include "MyString.h"
+
+bool ConvertUTF8ToUnicode(const AString &utfString, UString &resultString);
+bool ConvertUnicodeToUTF8(const UString &unicodeString, AString &resultString);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Wildcard.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Wildcard.cpp
new file mode 100644
index 000000000..9e0666895
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Wildcard.cpp
@@ -0,0 +1,461 @@
+// Common/Wildcard.cpp
+
+#include "StdAfx.h"
+
+#include "Wildcard.h"
+#include "MyWindows.h"
+
+bool g_CaseSensitive =
+ #ifdef _WIN32
+ false;
+ #else
+ true;
+ #endif
+
+static const wchar_t kAnyCharsChar = L'*';
+static const wchar_t kAnyCharChar = L'?';
+
+#ifdef _WIN32
+static const wchar_t kDirDelimiter1 = L'\\';
+#endif
+static const wchar_t kDirDelimiter2 = L'/';
+
+static const UString kWildCardCharSet = L"?*";
+
+static const UString kIllegalWildCardFileNameChars=
+ L"\x1\x2\x3\x4\x5\x6\x7\x8\x9\xA\xB\xC\xD\xE\xF"
+ L"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
+ L"\"/:<>\\|";
+
+
+static inline bool IsCharDirLimiter(wchar_t c)
+{
+ return (
+ #ifdef _WIN32
+ c == kDirDelimiter1 ||
+ #endif
+ c == kDirDelimiter2);
+}
+
+int CompareFileNames(const UString &s1, const UString &s2)
+{
+ if (g_CaseSensitive)
+ return s1.Compare(s2);
+ return s1.CompareNoCase(s2);
+}
+
+// -----------------------------------------
+// this function compares name with mask
+// ? - any char
+// * - any char or empty
+
+static bool EnhancedMaskTest(const wchar_t *mask, const wchar_t *name)
+{
+ for (;;)
+ {
+ wchar_t m = *mask;
+ wchar_t c = *name;
+ if (m == 0)
+ return (c == 0);
+ if (m == kAnyCharsChar)
+ {
+ if (EnhancedMaskTest(mask + 1, name))
+ return true;
+ if (c == 0)
+ return false;
+ }
+ else
+ {
+ if (m == kAnyCharChar)
+ {
+ if (c == 0)
+ return false;
+ }
+ else if (m != c)
+ if (g_CaseSensitive || MyCharUpper(m) != MyCharUpper(c))
+ return false;
+ mask++;
+ }
+ name++;
+ }
+}
+
+// --------------------------------------------------
+// Splits path to strings
+
+void SplitPathToParts(const UString &path, UStringVector &pathParts)
+{
+ pathParts.Clear();
+ UString name;
+ int len = path.Length();
+ if (len == 0)
+ return;
+ for (int i = 0; i < len; i++)
+ {
+ wchar_t c = path[i];
+ if (IsCharDirLimiter(c))
+ {
+ pathParts.Add(name);
+ name.Empty();
+ }
+ else
+ name += c;
+ }
+ pathParts.Add(name);
+}
+
+void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name)
+{
+ int i;
+ for (i = path.Length() - 1; i >= 0; i--)
+ if (IsCharDirLimiter(path[i]))
+ break;
+ dirPrefix = path.Left(i + 1);
+ name = path.Mid(i + 1);
+}
+
+UString ExtractDirPrefixFromPath(const UString &path)
+{
+ int i;
+ for (i = path.Length() - 1; i >= 0; i--)
+ if (IsCharDirLimiter(path[i]))
+ break;
+ return path.Left(i + 1);
+}
+
+UString ExtractFileNameFromPath(const UString &path)
+{
+ int i;
+ for (i = path.Length() - 1; i >= 0; i--)
+ if (IsCharDirLimiter(path[i]))
+ break;
+ return path.Mid(i + 1);
+}
+
+
+bool CompareWildCardWithName(const UString &mask, const UString &name)
+{
+ return EnhancedMaskTest(mask, name);
+}
+
+bool DoesNameContainWildCard(const UString &path)
+{
+ return (path.FindOneOf(kWildCardCharSet) >= 0);
+}
+
+
+// ----------------------------------------------------------'
+// NWildcard
+
+namespace NWildcard {
+
+
+/*
+M = MaskParts.Size();
+N = TestNameParts.Size();
+
+ File Dir
+ForFile req M<=N [N-M, N) -
+ nonreq M=N [0, M) -
+
+ForDir req M<N [0, M) ... [N-M-1, N-1) same as ForBoth-File
+ nonreq [0, M) same as ForBoth-File
+
+ForBoth req m<=N [0, M) ... [N-M, N) same as ForBoth-File
+ nonreq [0, M) same as ForBoth-File
+
+*/
+
+bool CItem::CheckPath(const UStringVector &pathParts, bool isFile) const
+{
+ if (!isFile && !ForDir)
+ return false;
+ int delta = (int)pathParts.Size() - (int)PathParts.Size();
+ if (delta < 0)
+ return false;
+ int start = 0;
+ int finish = 0;
+ if (isFile)
+ {
+ if (!ForDir && !Recursive && delta !=0)
+ return false;
+ if (!ForFile && delta == 0)
+ return false;
+ if (!ForDir && Recursive)
+ start = delta;
+ }
+ if (Recursive)
+ {
+ finish = delta;
+ if (isFile && !ForFile)
+ finish = delta - 1;
+ }
+ for (int d = start; d <= finish; d++)
+ {
+ int i;
+ for (i = 0; i < PathParts.Size(); i++)
+ if (!CompareWildCardWithName(PathParts[i], pathParts[i + d]))
+ break;
+ if (i == PathParts.Size())
+ return true;
+ }
+ return false;
+}
+
+int CCensorNode::FindSubNode(const UString &name) const
+{
+ for (int i = 0; i < SubNodes.Size(); i++)
+ if (CompareFileNames(SubNodes[i].Name, name) == 0)
+ return i;
+ return -1;
+}
+
+void CCensorNode::AddItemSimple(bool include, CItem &item)
+{
+ if (include)
+ IncludeItems.Add(item);
+ else
+ ExcludeItems.Add(item);
+}
+
+void CCensorNode::AddItem(bool include, CItem &item)
+{
+ if (item.PathParts.Size() <= 1)
+ {
+ AddItemSimple(include, item);
+ return;
+ }
+ const UString &front = item.PathParts.Front();
+ if (DoesNameContainWildCard(front))
+ {
+ AddItemSimple(include, item);
+ return;
+ }
+ int index = FindSubNode(front);
+ if (index < 0)
+ index = SubNodes.Add(CCensorNode(front, this));
+ item.PathParts.Delete(0);
+ SubNodes[index].AddItem(include, item);
+}
+
+void CCensorNode::AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir)
+{
+ CItem item;
+ SplitPathToParts(path, item.PathParts);
+ item.Recursive = recursive;
+ item.ForFile = forFile;
+ item.ForDir = forDir;
+ AddItem(include, item);
+}
+
+bool CCensorNode::NeedCheckSubDirs() const
+{
+ for (int i = 0; i < IncludeItems.Size(); i++)
+ {
+ const CItem &item = IncludeItems[i];
+ if (item.Recursive || item.PathParts.Size() > 1)
+ return true;
+ }
+ return false;
+}
+
+bool CCensorNode::AreThereIncludeItems() const
+{
+ if (IncludeItems.Size() > 0)
+ return true;
+ for (int i = 0; i < SubNodes.Size(); i++)
+ if (SubNodes[i].AreThereIncludeItems())
+ return true;
+ return false;
+}
+
+bool CCensorNode::CheckPathCurrent(bool include, const UStringVector &pathParts, bool isFile) const
+{
+ const CObjectVector<CItem> &items = include ? IncludeItems : ExcludeItems;
+ for (int i = 0; i < items.Size(); i++)
+ if (items[i].CheckPath(pathParts, isFile))
+ return true;
+ return false;
+}
+
+bool CCensorNode::CheckPath(UStringVector &pathParts, bool isFile, bool &include) const
+{
+ if (CheckPathCurrent(false, pathParts, isFile))
+ {
+ include = false;
+ return true;
+ }
+ include = true;
+ bool finded = CheckPathCurrent(true, pathParts, isFile);
+ if (pathParts.Size() == 1)
+ return finded;
+ int index = FindSubNode(pathParts.Front());
+ if (index >= 0)
+ {
+ UStringVector pathParts2 = pathParts;
+ pathParts2.Delete(0);
+ if (SubNodes[index].CheckPath(pathParts2, isFile, include))
+ return true;
+ }
+ return finded;
+}
+
+bool CCensorNode::CheckPath(const UString &path, bool isFile, bool &include) const
+{
+ UStringVector pathParts;
+ SplitPathToParts(path, pathParts);
+ return CheckPath(pathParts, isFile, include);
+}
+
+bool CCensorNode::CheckPath(const UString &path, bool isFile) const
+{
+ bool include;
+ if (CheckPath(path, isFile, include))
+ return include;
+ return false;
+}
+
+bool CCensorNode::CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const
+{
+ if (CheckPathCurrent(include, pathParts, isFile))
+ return true;
+ if (Parent == 0)
+ return false;
+ pathParts.Insert(0, Name);
+ return Parent->CheckPathToRoot(include, pathParts, isFile);
+}
+
+/*
+bool CCensorNode::CheckPathToRoot(bool include, const UString &path, bool isFile) const
+{
+ UStringVector pathParts;
+ SplitPathToParts(path, pathParts);
+ return CheckPathToRoot(include, pathParts, isFile);
+}
+*/
+
+void CCensorNode::AddItem2(bool include, const UString &path, bool recursive)
+{
+ if (path.IsEmpty())
+ return;
+ bool forFile = true;
+ bool forFolder = true;
+ UString path2 = path;
+ if (IsCharDirLimiter(path[path.Length() - 1]))
+ {
+ path2.Delete(path.Length() - 1);
+ forFile = false;
+ }
+ AddItem(include, path2, recursive, forFile, forFolder);
+}
+
+void CCensorNode::ExtendExclude(const CCensorNode &fromNodes)
+{
+ ExcludeItems += fromNodes.ExcludeItems;
+ for (int i = 0; i < fromNodes.SubNodes.Size(); i++)
+ {
+ const CCensorNode &node = fromNodes.SubNodes[i];
+ int subNodeIndex = FindSubNode(node.Name);
+ if (subNodeIndex < 0)
+ subNodeIndex = SubNodes.Add(CCensorNode(node.Name, this));
+ SubNodes[subNodeIndex].ExtendExclude(node);
+ }
+}
+
+int CCensor::FindPrefix(const UString &prefix) const
+{
+ for (int i = 0; i < Pairs.Size(); i++)
+ if (CompareFileNames(Pairs[i].Prefix, prefix) == 0)
+ return i;
+ return -1;
+}
+
+void CCensor::AddItem(bool include, const UString &path, bool recursive)
+{
+ UStringVector pathParts;
+ SplitPathToParts(path, pathParts);
+ bool forFile = true;
+ if (pathParts.Back().IsEmpty())
+ {
+ forFile = false;
+ pathParts.DeleteBack();
+ }
+ const UString &front = pathParts.Front();
+ bool isAbs = false;
+ if (front.IsEmpty())
+ isAbs = true;
+ else if (front.Length() == 2 && front[1] == L':')
+ isAbs = true;
+ else
+ {
+ for (int i = 0; i < pathParts.Size(); i++)
+ {
+ const UString &part = pathParts[i];
+ if (part == L".." || part == L".")
+ {
+ isAbs = true;
+ break;
+ }
+ }
+ }
+ int numAbsParts = 0;
+ if (isAbs)
+ {
+ if (pathParts.Size() > 1)
+ numAbsParts = pathParts.Size() - 1;
+ else
+ numAbsParts = 1;
+ }
+ UString prefix;
+ for (int i = 0; i < numAbsParts; i++)
+ {
+ const UString &front = pathParts.Front();
+ if (DoesNameContainWildCard(front))
+ break;
+ prefix += front;
+ prefix += WCHAR_PATH_SEPARATOR;
+ pathParts.Delete(0);
+ }
+ int index = FindPrefix(prefix);
+ if (index < 0)
+ index = Pairs.Add(CPair(prefix));
+
+ CItem item;
+ item.PathParts = pathParts;
+ item.ForDir = true;
+ item.ForFile = forFile;
+ item.Recursive = recursive;
+ Pairs[index].Head.AddItem(include, item);
+}
+
+bool CCensor::CheckPath(const UString &path, bool isFile) const
+{
+ bool finded = false;
+ for (int i = 0; i < Pairs.Size(); i++)
+ {
+ bool include;
+ if (Pairs[i].Head.CheckPath(path, isFile, include))
+ {
+ if (!include)
+ return false;
+ finded = true;
+ }
+ }
+ return finded;
+}
+
+void CCensor::ExtendExclude()
+{
+ int i;
+ for (i = 0; i < Pairs.Size(); i++)
+ if (Pairs[i].Prefix.IsEmpty())
+ break;
+ if (i == Pairs.Size())
+ return;
+ int index = i;
+ for (i = 0; i < Pairs.Size(); i++)
+ if (index != i)
+ Pairs[i].Head.ExtendExclude(Pairs[index].Head);
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Wildcard.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Wildcard.h
new file mode 100644
index 000000000..a55bc597b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Common/Wildcard.h
@@ -0,0 +1,80 @@
+// Common/Wildcard.h
+
+#ifndef __COMMON_WILDCARD_H
+#define __COMMON_WILDCARD_H
+
+#include "MyString.h"
+
+int CompareFileNames(const UString &s1, const UString &s2);
+
+void SplitPathToParts(const UString &path, UStringVector &pathParts);
+void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name);
+UString ExtractDirPrefixFromPath(const UString &path);
+UString ExtractFileNameFromPath(const UString &path);
+bool DoesNameContainWildCard(const UString &path);
+bool CompareWildCardWithName(const UString &mask, const UString &name);
+
+namespace NWildcard {
+
+struct CItem
+{
+ UStringVector PathParts;
+ bool Recursive;
+ bool ForFile;
+ bool ForDir;
+ bool CheckPath(const UStringVector &pathParts, bool isFile) const;
+};
+
+class CCensorNode
+{
+ CCensorNode *Parent;
+ bool CheckPathCurrent(bool include, const UStringVector &pathParts, bool isFile) const;
+ void AddItemSimple(bool include, CItem &item);
+ bool CheckPath(UStringVector &pathParts, bool isFile, bool &include) const;
+public:
+ CCensorNode(): Parent(0) { }
+ CCensorNode(const UString &name, CCensorNode *parent): Parent(parent), Name(name) { }
+ UString Name;
+ CObjectVector<CCensorNode> SubNodes;
+ CObjectVector<CItem> IncludeItems;
+ CObjectVector<CItem> ExcludeItems;
+
+ int FindSubNode(const UString &path) const;
+
+ void AddItem(bool include, CItem &item);
+ void AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir);
+ void AddItem2(bool include, const UString &path, bool recursive);
+
+ bool NeedCheckSubDirs() const;
+ bool AreThereIncludeItems() const;
+
+ bool CheckPath(const UString &path, bool isFile, bool &include) const;
+ bool CheckPath(const UString &path, bool isFile) const;
+
+ bool CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const;
+ // bool CheckPathToRoot(const UString &path, bool isFile, bool include) const;
+ void ExtendExclude(const CCensorNode &fromNodes);
+};
+
+struct CPair
+{
+ UString Prefix;
+ CCensorNode Head;
+ CPair(const UString &prefix): Prefix(prefix) { };
+};
+
+class CCensor
+{
+ int FindPrefix(const UString &prefix) const;
+public:
+ CObjectVector<CPair> Pairs;
+ bool AllAreRelative() const
+ { return (Pairs.Size() == 1 && Pairs.Front().Prefix.IsEmpty()); }
+ void AddItem(bool include, const UString &path, bool recursive);
+ bool CheckPath(const UString &path, bool isFile) const;
+ void ExtendExclude();
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/COM.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/COM.cpp
new file mode 100644
index 000000000..2f9fdcdab
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/COM.cpp
@@ -0,0 +1,37 @@
+// Windows/COM.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/COM.h"
+#include "Common/StringConvert.h"
+
+namespace NWindows {
+namespace NCOM {
+
+// CoInitialize (NULL); must be called!
+
+UString GUIDToStringW(REFGUID guid)
+{
+ UString string;
+ const int kStringSize = 48;
+ StringFromGUID2(guid, string.GetBuffer(kStringSize), kStringSize);
+ string.ReleaseBuffer();
+ return string;
+}
+
+AString GUIDToStringA(REFGUID guid)
+{
+ return UnicodeStringToMultiByte(GUIDToStringW(guid));
+}
+
+HRESULT StringToGUIDW(const wchar_t *string, GUID &classID)
+{
+ return CLSIDFromString((wchar_t *)string, &classID);
+}
+
+HRESULT StringToGUIDA(const char *string, GUID &classID)
+{
+ return StringToGUIDW(MultiByteToUnicodeString(string), classID);
+}
+
+}} \ No newline at end of file
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/COM.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/COM.h
new file mode 100644
index 000000000..ceffc97f9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/COM.h
@@ -0,0 +1,61 @@
+// Windows/COM.h
+
+#ifndef __WINDOWS_COM_H
+#define __WINDOWS_COM_H
+
+#include "Common/MyString.h"
+
+namespace NWindows {
+namespace NCOM {
+
+#ifdef _WIN32
+
+class CComInitializer
+{
+public:
+ CComInitializer() { CoInitialize(NULL);};
+ ~CComInitializer() { CoUninitialize(); };
+};
+
+class CStgMedium
+{
+ STGMEDIUM _object;
+public:
+ bool _mustBeReleased;
+ CStgMedium(): _mustBeReleased(false) {}
+ ~CStgMedium() { Free(); }
+ void Free()
+ {
+ if (_mustBeReleased)
+ ReleaseStgMedium(&_object);
+ _mustBeReleased = false;
+ }
+ const STGMEDIUM* operator->() const { return &_object;}
+ STGMEDIUM* operator->() { return &_object;}
+ STGMEDIUM* operator&() { return &_object; }
+};
+
+#endif
+
+//////////////////////////////////
+// GUID <--> String Conversions
+UString GUIDToStringW(REFGUID guid);
+AString GUIDToStringA(REFGUID guid);
+#ifdef UNICODE
+ #define GUIDToString GUIDToStringW
+#else
+ #define GUIDToString GUIDToStringA
+#endif // !UNICODE
+
+HRESULT StringToGUIDW(const wchar_t *string, GUID &classID);
+HRESULT StringToGUIDA(const char *string, GUID &classID);
+#ifdef UNICODE
+ #define StringToGUID StringToGUIDW
+#else
+ #define StringToGUID StringToGUIDA
+#endif // !UNICODE
+
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Clipboard.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Clipboard.cpp
new file mode 100644
index 000000000..b843745c9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Clipboard.cpp
@@ -0,0 +1,159 @@
+// Windows/Clipboard.cpp
+
+#include "StdAfx.h"
+
+
+#include "Windows/Clipboard.h"
+#include "Windows/Defs.h"
+#ifdef _WIN32
+#include "Windows/Memory.h"
+#include "Windows/Shell.h"
+#include "Windows/Memory.h"
+#else
+#include <wx/clipbrd.h>
+#include <wx/dataobj.h>
+#endif
+
+#include "Common/StringConvert.h"
+
+namespace NWindows {
+
+bool CClipboard::Open(HWND wndNewOwner)
+{
+#ifdef _WIN32
+ m_Open = BOOLToBool(::OpenClipboard(wndNewOwner));
+#else
+ m_Open = wxTheClipboard->Open();
+#endif
+ return m_Open;
+}
+
+CClipboard::~CClipboard()
+{
+ Close();
+}
+
+bool CClipboard::Close()
+{
+ if (!m_Open)
+ return true;
+#ifdef _WIN32
+ m_Open = !BOOLToBool(CloseClipboard());
+#else
+ wxTheClipboard->Close();
+ m_Open = false;
+#endif
+ return !m_Open;
+}
+
+#ifdef _WIN32
+bool ClipboardIsFormatAvailableHDROP()
+{
+ return BOOLToBool(IsClipboardFormatAvailable(CF_HDROP));
+}
+#endif
+
+/*
+bool ClipboardGetTextString(AString &s)
+{
+ s.Empty();
+ if (!IsClipboardFormatAvailable(CF_TEXT))
+ return false;
+ CClipboard clipboard;
+
+ if (!clipboard.Open(NULL))
+ return false;
+
+ HGLOBAL h = ::GetClipboardData(CF_TEXT);
+ if (h != NULL)
+ {
+ NMemory::CGlobalLock globalLock(h);
+ const char *p = (const char *)globalLock.GetPointer();
+ if (p != NULL)
+ {
+ s = p;
+ return true;
+ }
+ }
+ return false;
+}
+*/
+
+/*
+bool ClipboardGetFileNames(UStringVector &names)
+{
+ names.Clear();
+ if (!IsClipboardFormatAvailable(CF_HDROP))
+ return false;
+ CClipboard clipboard;
+
+ if (!clipboard.Open(NULL))
+ return false;
+
+ HGLOBAL h = ::GetClipboardData(CF_HDROP);
+ if (h != NULL)
+ {
+ NMemory::CGlobalLock globalLock(h);
+ void *p = (void *)globalLock.GetPointer();
+ if (p != NULL)
+ {
+ NShell::CDrop drop(false);
+ drop.Attach((HDROP)p);
+ drop.QueryFileNames(names);
+ return true;
+ }
+ }
+ return false;
+}
+*/
+
+#ifdef _WIN32
+static bool ClipboardSetData(UINT uFormat, const void *data, size_t size)
+{
+ NMemory::CGlobal global;
+ if (!global.Alloc(GMEM_DDESHARE | GMEM_MOVEABLE, size))
+ return false;
+ {
+ NMemory::CGlobalLock globalLock(global);
+ LPVOID p = globalLock.GetPointer();
+ if (p == NULL)
+ return false;
+ memcpy(p, data, size);
+ }
+ if (::SetClipboardData(uFormat, global) == NULL)
+ return false;
+ global.Detach();
+ return true;
+}
+#endif
+
+bool ClipboardSetText(HWND owner, const UString &s)
+{
+ CClipboard clipboard;
+ if (!clipboard.Open(owner))
+ return false;
+#ifdef _WIN32
+ if (!::EmptyClipboard())
+ return false;
+
+ bool res;
+ res = ClipboardSetData(CF_UNICODETEXT, (const wchar_t *)s, (s.Length() + 1) * sizeof(wchar_t));
+ #ifndef _UNICODE
+ AString a;
+ a = UnicodeStringToMultiByte(s, CP_ACP);
+ res |= ClipboardSetData(CF_TEXT, (const char *)a, (a.Length() + 1) * sizeof(char));
+ a = UnicodeStringToMultiByte(s, CP_OEMCP);
+ res |= ClipboardSetData(CF_OEMTEXT, (const char *)a, (a.Length() + 1) * sizeof(char));
+ #endif
+ return res;
+#else
+ wxTheClipboard->Clear();
+ // This data objects are held by the clipboard,
+ // so do not delete them in the app.
+ wxString ws(s);
+ wxTheClipboard->SetData( new wxTextDataObject(ws) );
+ return true;
+#endif
+}
+
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Clipboard.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Clipboard.h
new file mode 100644
index 000000000..c80ba5ea7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Clipboard.h
@@ -0,0 +1,28 @@
+// Windows/Clipboard.h
+
+#ifndef __CLIPBOARD_H
+#define __CLIPBOARD_H
+
+#include "Common/MyString.h"
+
+namespace NWindows {
+
+class CClipboard
+{
+ bool m_Open;
+public:
+ CClipboard(): m_Open(false) {};
+ ~CClipboard();
+ bool Open(HWND wndNewOwner);
+ bool Close();
+};
+
+bool ClipboardIsFormatAvailableHDROP();
+
+// bool ClipboardGetFileNames(UStringVector &names);
+// bool ClipboardGetTextString(AString &s);
+bool ClipboardSetText(HWND owner, const UString &s);
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/CommonDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/CommonDialog.h
new file mode 100644
index 000000000..250c64f70
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/CommonDialog.h
@@ -0,0 +1,17 @@
+// Windows/CommonDialog.h
+
+#ifndef __WINDOWS_COMMONDIALOG_H
+#define __WINDOWS_COMMONDIALOG_H
+
+#include <windows.h>
+
+#include "Common/MyString.h"
+#include "Windows/Defs.h"
+
+namespace NWindows{
+
+bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s, UString &resPath);
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ComboBox.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ComboBox.h
new file mode 100644
index 000000000..726a62b5c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ComboBox.h
@@ -0,0 +1,67 @@
+// Windows/Control/ComboBox.h
+
+#ifndef __WINDOWS_WX_CONTROL_COMBOBOX_H
+#define __WINDOWS_WX_CONTROL_COMBOBOX_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+#ifndef _WIN32
+#define CB_ERR (-1) // wxNOT_FOUND
+#endif
+
+class wxComboBox;
+
+namespace NWindows {
+ namespace NControl {
+
+ class CComboBox // : public CWindow
+ {
+ wxComboBox* _choice;
+ public:
+ CComboBox() : _choice(0) {}
+
+ void Attach(wxWindow * newWindow);
+ wxWindow * Detach();
+
+ int AddString(const TCHAR * txt);
+
+ void SetText(LPCTSTR s);
+
+ void GetText(CSysString &s);
+
+ int GetCount() const ;
+ void GetLBText(int index, CSysString &s);
+
+ void SetCurSel(int index);
+ int GetCurSel();
+
+ void SetItemData(int index, int val);
+
+ int GetItemData(int index);
+
+ void Enable(bool state);
+
+ void ResetContent();
+ };
+
+ class CComboBoxEx : public CComboBox // : public CWindow
+ {
+ public:
+ /* FIXME
+ LRESULT DeleteItem(int index)
+ { return SendMessage(CBEM_DELETEITEM, index, 0); }
+ LRESULT InsertItem(COMBOBOXEXITEM *item)
+ { return SendMessage(CBEM_INSERTITEM, 0, (LPARAM)item); }
+ DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle)
+ { return (DWORD)SendMessage(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); }
+ HWND GetEditControl()
+ { return (HWND)SendMessage(CBEM_GETEDITCONTROL, 0, 0); }
+ */
+ };
+
+
+ }
+}
+
+#endif // __WINDOWS_WX_CONTROL_COMBOBOX_H
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Controls.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Controls.cpp
new file mode 100644
index 000000000..837f31a3e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Controls.cpp
@@ -0,0 +1,467 @@
+// Dialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+ #include "wx/imaglist.h"
+ #include "wx/listctrl.h"
+#endif
+
+#include "Windows/Control/Dialog.h"
+
+class LockGUI
+{
+ bool _IsMain;
+ public:
+ LockGUI() {
+ _IsMain = wxThread::IsMain();
+ if (!_IsMain) {
+ // DEBUG printf("GuiEnter(0x%lx)\n",wxThread::GetCurrentId());
+ wxMutexGuiEnter();
+ }
+ }
+ ~LockGUI() {
+ if (!_IsMain) {
+ wxMutexGuiLeave();
+ // DEBUG printf("GuiLeave(0x%lx)\n",wxThread::GetCurrentId());
+ }
+ }
+};
+/////////////////////////
+
+namespace NWindows {
+ namespace NControl {
+
+ void CDialogChildControl::SetText(LPCWSTR s)
+ {
+ LockGUI lock;
+ ((wxTextCtrl *)_window)->SetValue(s);
+ }
+
+ bool CDialogChildControl::GetText(CSysString &s)
+ {
+ wxString str;
+ {
+ LockGUI lock;
+ str = ((wxTextCtrl *)_window)->GetValue();
+ }
+ s = str;
+ return true;
+ }
+ }
+}
+
+///////////////////////// Windows/Control/ComboBox.cpp
+#include "Windows/Control/ComboBox.h"
+
+namespace NWindows {
+ namespace NControl {
+
+ void CComboBox::Attach(wxWindow * newWindow) { _choice = (wxComboBox*)newWindow; }
+
+ wxWindow * CComboBox::Detach()
+ {
+ wxWindow * window = _choice;
+ _choice = NULL;
+ return window;
+ }
+
+ int CComboBox::AddString(const TCHAR * txt) {
+ LockGUI lock;
+ wxString item(txt);
+ return _choice->Append(item);
+ }
+
+ void CComboBox::SetText(LPCTSTR s) {
+ LockGUI lock;
+ wxString str(s);
+ _choice->SetValue(str);
+ }
+
+ void CComboBox::GetText(CSysString &s) {
+ LockGUI lock;
+ wxString str = _choice->GetValue();
+ s = str;
+ }
+
+ int CComboBox::GetCount() const {
+ LockGUI lock;
+ return _choice->GetCount();
+ }
+
+ void CComboBox::GetLBText(int index, CSysString &s) {
+ LockGUI lock;
+ wxString str = _choice->GetString(index);
+ s = str;
+ }
+
+ void CComboBox::SetCurSel(int index) {
+ LockGUI lock;
+ _choice->SetSelection(index);
+ }
+
+ int CComboBox::GetCurSel() {
+ LockGUI lock;
+ return _choice->GetSelection();
+ }
+
+ void CComboBox::SetItemData(int index, int val) {
+ LockGUI lock;
+ _choice->SetClientData( index, (void *)(((char *)0) + val));
+ }
+
+ int CComboBox::GetItemData(int index)
+ {
+ LockGUI lock;
+ void * data = _choice->GetClientData(index);
+ int ret = (int)(((char *)data) - ((char *)0));
+ return ret;
+ }
+
+ void CComboBox::Enable(bool state) {
+ LockGUI lock;
+ _choice->Enable(state);
+ }
+
+ void CComboBox::ResetContent() {
+ LockGUI lock;
+ _choice->Clear();
+ }
+ }
+}
+
+///////////////////////// Windows/Control/Edit.cpp
+#include "Windows/Control/Edit.h"
+
+namespace NWindows {
+ namespace NControl {
+
+ void CEdit::SetPasswordChar(WPARAM c) // Warning : does not work for wxMSW
+ {
+ LockGUI lock;
+ long style = _window->GetWindowStyle();
+ if ( c == 0 ) style &= ~(wxTE_PASSWORD);
+ else style |= wxTE_PASSWORD;
+ _window->SetWindowStyle(style);
+ _window->Refresh();
+ }
+
+
+ void CEdit::Show(int cmdShow)
+ {
+ LockGUI lock;
+ // FIXME _window->Show(cmdShow != SW_HIDE);
+ _window->Enable(cmdShow != SW_HIDE);
+ }
+
+ void CEdit::SetText(LPCWSTR s)
+ {
+ LockGUI lock;
+ ((wxTextCtrl *)_window)->SetValue(s);
+ }
+
+ bool CEdit::GetText(CSysString &s)
+ {
+ wxString str;
+ {
+ LockGUI lock;
+ str = ((wxTextCtrl *)_window)->GetValue();
+ }
+ s = str;
+ return true;
+ }
+
+ }
+}
+
+///////////////////////// Windows/Control/ProgressBar.cpp
+#include "Windows/Control/ProgressBar.h"
+
+namespace NWindows {
+ namespace NControl {
+
+ CProgressBar::CProgressBar(wxWindow* newWindow):
+ _window((wxGauge *)newWindow) , _minValue(0), _range(0) { }
+
+ void CProgressBar::Attach(wxWindow* newWindow) {
+ _window = (wxGauge *)newWindow;
+ _minValue = 0;
+ _range = 0;
+ }
+
+ void CProgressBar::SetRange32(int minValue, int maxValue) {
+ int range = maxValue - minValue;
+ if (range >= 1)
+ {
+ LockGUI lock;
+ _minValue = minValue;
+ _range = range;
+ _window->SetRange(_range);
+ }
+ }
+
+ void CProgressBar::SetPos(int pos) {
+ if (_range >= 1)
+ {
+ LockGUI lock;
+ int value = pos - _minValue;
+ if ((value >= 0) && (value <= _range)) _window->SetValue(value);
+ }
+ }
+
+ }
+}
+
+///////////////////////// Windows/Control/StatusBar.cpp
+#include "Windows/Control/StatusBar.h"
+
+namespace NWindows {
+ namespace NControl {
+
+ void CStatusBar::Attach(wxWindow * newWindow) { _statusBar = (wxStatusBar*)newWindow; }
+
+ wxWindow * CStatusBar::Detach()
+ {
+ wxWindow * window = _statusBar;
+ _statusBar = NULL;
+ return window;
+ }
+
+ void CStatusBar::SetText(int index, LPCTSTR text)
+ {
+ _statusBar->SetStatusText(text,index);
+ }
+
+ }
+
+}
+
+///////////////////////// Windows/Control/ListView.cpp
+#include "Windows/Control/ListView.h"
+
+namespace NWindows {
+namespace NControl {
+
+ void CListView::Attach(wxWindow * newWindow) { _list = (wxListCtrl *)newWindow; }
+
+ CListView::operator HWND() const { return (HWND)_list; }
+
+ int CListView::GetItemCount() const {return _list->GetItemCount(); }
+
+ int CListView::InsertItem(int index, LPCTSTR text) { return _list->InsertItem(index, text); }
+ int CListView::InsertItem(const LVITEM* item) {
+ /*
+ int col = item->iSubItem;
+ wxString text;
+ if (item->mask & LVIF_TEXT) text = item->pszText;
+
+ // printf("%p->InsertItem(id=%d,%ls)\n",_list,item->iItem, (const wchar_t *)text);
+ return _list->InsertItem(item->iItem, text);
+ */
+ wxListItem info;
+ long mask = 0;
+ info.SetId(item->iItem);
+ if (item->mask & LVIF_TEXT)
+ {
+ info.SetText(item->pszText);
+ mask |= wxLIST_MASK_TEXT;
+ }
+ if (item->mask & LVIF_PARAM)
+ {
+ info.SetData(item->lParam);
+ mask |= wxLIST_MASK_DATA;
+ }
+ if (item->mask & LVIF_STATE)
+ {
+ info.SetState(item->state);
+ mask |= wxLIST_MASK_STATE;
+ }
+ // FIXME if (item->mask & LVIF_IMAGE)
+
+ info.SetMask(mask);
+
+ return _list->InsertItem(info);
+ }
+
+ void CListView::SetItem(const LVITEM* item) {
+ int col = item->iSubItem;
+ wxString text;
+ if (item->mask & LVIF_TEXT) text = item->pszText;
+ // printf("%p->SetItem(id=%d,col=%d,%ls)\n",_list,item->iItem, col,(const wchar_t *)text);
+ _list->SetItem(item->iItem, col, text);
+ }
+
+ int CListView::SetSubItem(int index, int subIndex, LPCTSTR text)
+ {
+ return _list->SetItem(index, subIndex, text);
+ }
+
+ void SetUnicodeFormat(bool fUnicode) { return ; }
+
+ void CListView::InsertColumn(int columnIndex, LPCTSTR text, int width)
+ {
+ _list->InsertColumn(columnIndex, text, wxLIST_FORMAT_LEFT, width);
+ }
+
+ void CListView::InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo)
+ {
+ wxString text;
+ int format = wxLIST_FORMAT_LEFT;
+ int width = -1;
+ if (columnInfo->mask & LVCF_FMT)
+ {
+ if (columnInfo->fmt == LVCFMT_LEFT) format = wxLIST_FORMAT_LEFT;
+ if (columnInfo->fmt == LVCFMT_RIGHT) format = wxLIST_FORMAT_RIGHT;
+ }
+ if (columnInfo->mask & LVCF_TEXT) text = columnInfo->pszText;
+ if (columnInfo->mask & LVCF_WIDTH) width = columnInfo->cx;
+ // FIXME LVCF_SUBITEM
+ // printf("%p->InsertColumn(%d,%ls)\n",_list,columnIndex,(const wchar_t *)heading);
+ _list->InsertColumn(columnIndex, text, format, width);
+ }
+
+ void CListView::DeleteAllItems() { _list->DeleteAllItems(); printf("%p->DeleteAllItems()\n",_list); }
+
+ void CListView::SetRedraw(bool b) {
+ if (b) _list->Thaw();
+ else _list->Freeze();
+ printf(" %p->SetRedraw()\n",_list);
+ }
+
+ void CListView::SetItemCount(int count) {
+ _list->SetItemCount(count);
+ printf(" %p->SetItemCount(%d)\n",_list,count);
+ }
+
+ void CListView::InvalidateRect(void *, bool) { printf("FIXME %p->InvalidateRect()\n",_list);/* FIXME */ }
+
+ int CListView::GetSelectedCount() const {
+ int nb = _list->GetSelectedItemCount();
+ printf(" %p->GetSelectedCount()=>%d\n",_list,nb);
+ return nb;
+ }
+
+ void /* bool */ CListView::EnsureVisible(int index, bool partialOK) {
+ _list->EnsureVisible(index);
+ printf(" %p->EnsureVisible(%d)\n",_list,index);
+ // return true;
+ }
+
+ void CListView::SetItemState(int index, UINT state, UINT mask) {
+ // don't work _list->SetItemState(index, state, mask); !?
+ // try SetItem ...
+ /*
+ wxListItem info;
+
+ info.m_mask = wxLIST_MASK_STATE;
+ info.m_itemId = index;
+ info.m_col = 0;
+ info.m_state = state;
+ info.m_mask = mask;
+
+ _list->SetItem(info);
+ */
+ if (mask & LVIS_FOCUSED) {
+ _list->SetItemState(index, state & LVIS_FOCUSED, mask & LVIS_FOCUSED);
+ }
+
+ if (mask & LVIS_SELECTED) {
+ _list->SetItemState(index, state & LVIS_SELECTED, mask & LVIS_SELECTED);
+ }
+
+ printf("FIXME %p->SetItemState(index=%d,state=0x%x,mask=0x%x)\n",_list,index,(unsigned)state,(unsigned)mask); /* FIXME */
+ }
+
+ UINT CListView::GetItemState(int index, UINT mask) const
+ {
+ UINT state = _list->GetItemState(index, mask);
+ printf("FIXME %p->GetItemState(index=%d,mask=0x%x)=0x%x\n",_list,index,(unsigned)mask,(unsigned)state); /* FIXME */
+
+ return state;
+ }
+
+ void /* bool */ CListView::Update() { printf("FIXME %p->Update()\n",_list); /* FIXME */ }
+
+ bool CListView::DeleteColumn(int columnIndex) {
+ // printf("%p->DeleteColumn()\n",_list);
+ if (_list->GetColumnCount() < 1) return false;
+ return _list->DeleteColumn(columnIndex); // always return true !?
+ }
+
+ bool CListView::GetItemParam(int itemIndex, LPARAM &param) const
+ {
+ param = _list->GetItemData(itemIndex);
+
+ // printf(" %p->GetItemParam(%d) => %ld\n",_list,itemIndex,(long)param);
+
+ return true;
+ }
+
+ int CListView::GetNextItem(int startIndex, UINT flags) const
+ {
+ int item = _list->GetNextItem(startIndex, wxLIST_NEXT_ALL, flags);
+ printf(" %p->GetNextItem(%d) => %d\n",_list,startIndex,item);
+ return item;
+
+ }
+
+ int CListView::GetFocusedItem() const
+ {
+ int item = _list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
+ printf(" %p->GetFocusedItem() => %d\n",_list,item);
+ return item;
+ }
+
+ void CListView::RedrawAllItems()
+ {
+ printf("FIXME %p->RedrawAllItems()\n",_list);
+ }
+
+ // FIXME added
+ int CListView::GetColumnCount()
+ {
+ return _list->GetColumnCount();
+ }
+
+ void CListView::SetFocus() { /* FIXME */ }
+
+ void CListView::RedrawItem(int item) { /* FIXME */ }
+
+ bool CListView::SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam) {
+ printf(" %p->SortItems()\n",_list);
+ return _list->SortItems(compareFunction, dataParam);
+ }
+
+ bool CListView::GetColumn(int columnIndex, LVCOLUMN* columnInfo)
+ {
+ wxListItem item;
+ bool ret = _list->GetColumn(columnIndex, item);
+
+ if (ret)
+ {
+ columnInfo->iOrder = 0; // FIXME
+ columnInfo->cx = item.GetWidth();
+ }
+
+ return ret;
+
+ }
+
+ // HWND EditLabel(int itemIndex)
+ void CListView::EditLabel(int itemIndex)
+ {
+ /* FIXME */
+ }
+
+}}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Dialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Dialog.cpp
new file mode 100644
index 000000000..d6ef1efc9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Dialog.cpp
@@ -0,0 +1,525 @@
+// Dialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "Windows/Control/DialogImpl.h"
+#include "Windows/Synchronization.h"
+
+// #include "../GUI/p7zip_32.xpm"
+extern const char * p7zip_32_xpm[];
+
+const TCHAR * nameWindowToUnix(const TCHAR * lpFileName) {
+ if ((lpFileName[0] == wxT('c')) && (lpFileName[1] == wxT(':'))) return lpFileName+2;
+ return lpFileName;
+}
+
+
+extern time_t g_T0; // FIXME
+
+extern wxWindow * g_window;
+
+enum { // FIXME - duplicate
+ WORKER_EVENT=100 // this one gets sent from the worker thread
+};
+
+#define DIALOG_ID_MESSAGEBOX 8100
+#define DIALOG_ID_DIR_DIALOG 8101
+#define DIALOG_ID_FILE_DIALOG 8102
+#define DIALOG_ID_POST_DIALOG 8190
+#define DIALOG_ID_END_DIALOG 8199
+
+static struct
+{
+ bool busy;
+
+ int id;
+ wxWindow *parentWindow;
+
+ // CreateDialog
+ NWindows::NControl::CModalDialog * dialog;
+
+ // EndModal
+ int value;
+ NWindows::NControl::CModalDialogImpl * window;
+
+ // MessageBox
+ const TCHAR * msg;
+ const TCHAR * title;
+ int flag;
+
+ //
+ LPCWSTR initialFolderOrFile;
+
+ wxSemaphore * sem;
+ int ret;
+
+ UString resultPath;
+
+#define MAX_CREATE 16
+} g_tabCreate[MAX_CREATE];
+
+static int myCreateHandle2(int n);
+
+static int findFreeInd()
+{
+static NWindows::NSynchronization::CCriticalSection g_CriticalSection;
+
+ g_CriticalSection.Enter();
+ int ind = 0;
+ while (ind < MAX_CREATE)
+ {
+ if (g_tabCreate[ind].busy == false)
+ {
+ g_tabCreate[ind].busy = true;
+ break;
+ }
+ ind++;
+ }
+ g_CriticalSection.Leave();
+
+ return ind;
+}
+
+static int WaitInd(int ind,int id,wxWindow * parent,UString &resultPath)
+{
+ int ret = 0;
+
+ g_tabCreate[ind].id = id;
+ g_tabCreate[ind].parentWindow = parent;
+ g_tabCreate[ind].ret = 0;
+ g_tabCreate[ind].resultPath = wxEmptyString;
+
+ if (wxThread::IsMain())
+ {
+ ret = myCreateHandle2(ind);
+ resultPath = g_tabCreate[ind].resultPath;
+ }
+ else
+ {
+ g_tabCreate[ind].sem = new wxSemaphore(0);
+
+ // create any type of command event here
+ wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, WORKER_EVENT );
+ event.SetInt( ind );
+
+ // send in a thread-safe way
+ // DEBUG printf("T=0x%lx - %d : WaitInd(%d,%p): BEGIN\n", wxThread::GetCurrentId(),time(0)-g_T0,g_tabCreate[ind].id,g_tabCreate[ind].parentWindow);
+ wxPostEvent( g_window, event );
+
+ g_tabCreate[ind].sem->Wait();
+
+ ret = g_tabCreate[ind].ret;
+ resultPath = g_tabCreate[ind].resultPath;
+ // DEBUG printf("T=0x%lx - %d : WaitInd(%d,%p): ret=%d\n", wxThread::GetCurrentId(),time(0)-g_T0,g_tabCreate[ind].id,g_tabCreate[ind].parentWindow,ret);
+ delete g_tabCreate[ind].sem;
+ g_tabCreate[ind].sem = 0;
+ }
+
+ g_tabCreate[ind].busy = false;
+
+ return ret;
+}
+
+static int WaitInd(int ind,int id,wxWindow * parent)
+{
+ UString resultPath;
+ return WaitInd(ind,id,parent,resultPath);
+}
+
+class LockGUI
+{
+ bool _IsMain;
+ public:
+ LockGUI() {
+ _IsMain = wxThread::IsMain();
+ if (!_IsMain) {
+ // DEBUG printf("GuiEnter(0x%lx)\n",wxThread::GetCurrentId());
+ wxMutexGuiEnter();
+ }
+ }
+ ~LockGUI() {
+ if (!_IsMain) {
+ wxMutexGuiLeave();
+ // DEBUG printf("GuiLeave(0x%lx)\n",wxThread::GetCurrentId());
+ }
+ }
+};
+
+static const unsigned int kNumDialogsMax = 32;
+static unsigned int g_NumDialogs = 0;
+static const CDialogInfo *g_Dialogs[kNumDialogsMax];
+
+void RegisterDialog(const CDialogInfo *dialogInfo)
+{
+ // DEBUG printf("RegisterDialog : %d\n",dialogInfo->id);
+ if (g_NumDialogs < kNumDialogsMax)
+ g_Dialogs[g_NumDialogs++] = dialogInfo;
+}
+
+namespace NWindows {
+
+ CSysString MyLoadString(unsigned int resourceID)
+ {
+ for(int i=0; i < g_NumDialogs; i++) {
+ if (g_Dialogs[i]->stringTable) {
+ int j = 0;
+ while(g_Dialogs[i]->stringTable[j].str) {
+ if (resourceID == g_Dialogs[i]->stringTable[j].id) {
+ return g_Dialogs[i]->stringTable[j].str;
+ }
+
+ j++;
+ }
+ }
+ }
+ return L"FIXME-MyLoadStringW-";
+ }
+
+ namespace NControl {
+
+/////////////////////////////////////////// CModalDialog //////////////////////////////////
+
+ bool CModalDialog::CheckButton(int buttonID, UINT checkState)
+ {
+ LockGUI lock;
+ wxCheckBox* w = (wxCheckBox*)_window->FindWindow(buttonID);
+ if (w)
+ {
+ w->SetValue(checkState == BST_CHECKED);
+ return true;
+ }
+ return false;
+ }
+
+ UINT CModalDialog::IsButtonChecked(int buttonID) const
+ {
+ LockGUI lock;
+ wxCheckBox* w = (wxCheckBox*)_window->FindWindow(buttonID);
+ if (w)
+ {
+ bool bret = w->GetValue();
+ if (bret) return BST_CHECKED;
+ }
+ return BST_UNCHECKED;
+ }
+
+ void CModalDialog::EnableItem(int id, bool state)
+ {
+ LockGUI lock;
+ wxWindow* w = _window->FindWindow(id);
+ if (w) w->Enable(state);
+ }
+
+ void CModalDialog::SetItemText(int id, const TCHAR *txt)
+ {
+ LockGUI lock;
+ wxWindow* w = _window->FindWindow(id);
+ if (w)
+ {
+ wxString label(txt);
+ w->SetLabel(label);
+ }
+ }
+
+ wxWindow * CModalDialog::GetItem(long id) const
+ {
+ LockGUI lock;
+ return _window->FindWindow(id);
+ }
+
+ void CModalDialog::ShowItem(int itemID, int cmdShow) const
+ {
+ LockGUI lock;
+ // cmdShow = SW_HIDE or SW_SHOW (sometimes false or true !)
+ wxWindow* w = _window->FindWindow(itemID);
+ if (w)
+ {
+// FIXME w->Show(cmdShow != SW_HIDE);
+ w->Enable(cmdShow != SW_HIDE);
+ }
+ }
+
+ UINT_PTR CModalDialog::SetTimer(UINT_PTR idEvent , unsigned milliseconds)
+ {
+ LockGUI lock;
+ return _window->SetTimer(idEvent , milliseconds);
+ }
+
+ void CModalDialog::KillTimer(UINT_PTR idEvent)
+ {
+ LockGUI lock;
+ _window->KillTimer(idEvent);
+ }
+
+ void CModalDialog::SetText(const TCHAR *_title) {
+ LockGUI lock;
+ _window->SetTitle(_title);
+ }
+
+
+ bool CModalDialog::GetText(CSysString &s) {
+ wxString str;
+ {
+ LockGUI lock;
+ str = _window->GetTitle();
+ }
+ s = str;
+ return true;
+ }
+
+ INT_PTR CModalDialog::Create(int id , HWND parentWindow)
+ {
+ int ind = findFreeInd();
+
+ g_tabCreate[ind].dialog = this;
+
+ return WaitInd(ind,id,parentWindow);
+ }
+
+ void CModalDialog::End(int result)
+ {
+ int ind = findFreeInd();
+
+ g_tabCreate[ind].window = _window;
+ g_tabCreate[ind].value = result;
+
+ WaitInd(ind,DIALOG_ID_END_DIALOG,0);
+ }
+
+ void CModalDialog::PostMessage(UINT message)
+ {
+ int ind = findFreeInd();
+
+ g_tabCreate[ind].dialog = this;
+ g_tabCreate[ind].value = message;
+
+ WaitInd(ind,DIALOG_ID_POST_DIALOG,0);
+ }
+
+/////////////////////////////////////////// CModalDialogImpl ///////////////////////////////////////
+
+ CModalDialogImpl::CModalDialogImpl(CDialog *dialog, wxWindow* parent, wxWindowID id,
+ const wxString& title, const wxPoint& pos,
+ const wxSize& size, long style) :
+ wxDialog(parent, id, title , pos , size, style /* | wxDIALOG_NO_PARENT */ ) ,
+ _timer(this, TIMER_ID_IMPL), _dialog(dialog)
+ {
+ // set the frame icon
+ this->SetIcon(wxICON(p7zip_32));
+ }
+
+ void CModalDialogImpl::OnAnyButton(wxCommandEvent& event)
+ {
+ int id = event.GetId();
+ if (id == wxID_OK)
+ {
+ if (_dialog) _dialog->OnOK();
+ // event.Skip(true);
+ }
+ else if (id == wxID_CANCEL)
+ {
+ if (_dialog) _dialog->OnCancel();
+ // event.Skip(true);
+ }
+ else if (id == wxID_HELP)
+ {
+ if (_dialog) _dialog->OnHelp();
+ }
+ else
+ {
+ if (_dialog)
+ {
+ bool bret = _dialog->OnButtonClicked(id, FindWindow(id) );
+ }
+ }
+ }
+
+ void CModalDialogImpl::OnAnyChoice(wxCommandEvent &event)
+ {
+ int itemID = event.GetId();
+ if (_dialog) _dialog->OnCommand(CBN_SELCHANGE, itemID, 0);
+ }
+
+ void CModalDialogImpl::OnAnyTimer(wxTimerEvent &event)
+ {
+ int timerID = event.GetId();
+ if (_dialog) _dialog->OnTimer(timerID , 0);
+ }
+ }
+}
+
+///////////////////////// myCreateHandle
+
+
+static int myCreateHandle2(int n)
+{
+ int id = g_tabCreate[n].id;
+ wxWindow * parentWindow = g_tabCreate[n].parentWindow;
+ NWindows::NControl::CModalDialogImpl * window = 0;
+
+ // DEBUG printf("T=0x%lx - %d : myCreateHandle(%d): BEGIN\n", wxThread::GetCurrentId(),time(0)-g_T0,n);
+
+ if (id == DIALOG_ID_END_DIALOG)
+ {
+ /* FIXME : the dialog must be shown before ending it ?
+ while (!_window->IsShownOnScreen()) Sleep(200);
+ Sleep(200);
+ */
+ g_tabCreate[n].window->EndModal(g_tabCreate[n].value);
+ return 0;
+ }
+
+ if (id == DIALOG_ID_POST_DIALOG)
+ {
+ g_tabCreate[n].dialog->OnMessage(g_tabCreate[n].value, 0, 0);
+ return 0;
+ }
+
+ if (id == DIALOG_ID_MESSAGEBOX)
+ {
+ long style = g_tabCreate[n].flag;
+ long decorated_style = style;
+ if ( ( style & ( wxICON_EXCLAMATION | wxICON_HAND | wxICON_INFORMATION |
+ wxICON_QUESTION ) ) == 0 )
+ {
+ decorated_style |= ( style & wxYES ) ? wxICON_QUESTION : wxICON_INFORMATION ;
+ }
+ wxMessageDialog dialog(parentWindow, g_tabCreate[n].msg, g_tabCreate[n].title, decorated_style);
+ dialog.SetIcon(wxICON(p7zip_32));
+ int ret = dialog.ShowModal();
+
+ return ret;
+ }
+
+ if (id == DIALOG_ID_DIR_DIALOG)
+ {
+ wxString defaultDir = g_tabCreate[n].initialFolderOrFile;
+ wxDirDialog dirDialog(g_tabCreate[n].parentWindow,
+ g_tabCreate[n].title, defaultDir);
+ dirDialog.SetIcon(wxICON(p7zip_32));
+ int ret = dirDialog.ShowModal();
+ if (ret == wxID_OK) g_tabCreate[n].resultPath = dirDialog.GetPath();
+ return ret;
+ }
+
+ if (id == DIALOG_ID_FILE_DIALOG)
+ {
+ wxString defaultFilename = g_tabCreate[n].initialFolderOrFile;
+ wxFileDialog fileDialog(g_tabCreate[n].parentWindow, g_tabCreate[n].title,
+ wxEmptyString, defaultFilename,
+ wxT("All Files (*.*)|*.*"), wxSAVE|wxOVERWRITE_PROMPT);
+ fileDialog.SetIcon(wxICON(p7zip_32));
+ int ret = fileDialog.ShowModal();
+ if (ret == wxID_OK) g_tabCreate[n].resultPath = fileDialog.GetPath();
+ return ret;
+ }
+
+ for(int i=0; i < g_NumDialogs; i++) {
+ if (id == g_Dialogs[i]->id) {
+ // DEBUG printf("%d : Create(%d,%p): CreateDialog-1\n",time(0)-g_T0,id,parentWindow);
+ window = (g_Dialogs[i]->createDialog)(g_tabCreate[n].dialog,g_tabCreate[n].parentWindow);
+ // DEBUG printf("%d : Create(%d,%p): CreateDialog-2\n",time(0)-g_T0,id,parentWindow);
+ break;
+ }
+ }
+
+ if (window) {
+
+ // DEBUG printf("%d : Create(%d,%p): %p->ShowModal()\n",time(0)-g_T0,id,parentWindow,window);
+
+ INT_PTR ret = window->ShowModal();
+
+ // DEBUG printf("%d : Create(%d,%p): %p->ShowModal() - ret=%d\n",time(0)-g_T0,id,parentWindow,window,ret);
+ window->Detach();
+ window->Destroy();
+
+ // DEBUG printf("%d : Create(%d,%p): END\n",time(0)-g_T0,id,parentWindow,window);
+
+ return ret;
+ }
+
+ // FIXME
+ printf("INTERNAL ERROR : cannot find dialog %d\n",id);
+
+ return 0;
+}
+
+void myCreateHandle(int n)
+{
+ int ret = myCreateHandle2(n);
+ g_tabCreate[n].ret = ret;
+ g_tabCreate[n].sem->Post();
+}
+
+int MessageBoxW(wxWindow * parent, const TCHAR * msg, const TCHAR * title,int flag)
+{
+ int ind = findFreeInd();
+
+ g_tabCreate[ind].msg = msg;
+ g_tabCreate[ind].title = title;
+ g_tabCreate[ind].flag = flag;
+
+ return WaitInd(ind,DIALOG_ID_MESSAGEBOX,parent);
+}
+
+
+
+// FIXME : should be in Windows/Shell.cpp
+
+namespace NWindows{
+namespace NShell{
+
+bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath)
+{
+ int ind = findFreeInd();
+
+ g_tabCreate[ind].title = title;
+ g_tabCreate[ind].initialFolderOrFile = nameWindowToUnix(initialFolder);
+
+ UString resTmp;
+ int ret = WaitInd(ind,DIALOG_ID_DIR_DIALOG,owner,resTmp);
+ if(ret == wxID_OK)
+ {
+ resultPath = resTmp;
+ return true;
+ }
+ return false;
+}
+
+}}
+
+/////////////////////////// CPP/Windows/CommonDialog.cpp
+namespace NWindows
+{
+
+ bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s, UString &resPath)
+ {
+ int ind = findFreeInd();
+
+ g_tabCreate[ind].title = title;
+ g_tabCreate[ind].initialFolderOrFile = nameWindowToUnix(fullFileName);
+
+ UString resTmp;
+ int ret = WaitInd(ind,DIALOG_ID_FILE_DIALOG,hwnd,resTmp);
+ if(ret == wxID_OK)
+ {
+ resPath = resTmp;
+ return true;
+ }
+ return false;
+ }
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Dialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Dialog.h
new file mode 100644
index 000000000..1b4712352
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Dialog.h
@@ -0,0 +1,172 @@
+// Windows/Control/Dialog.h
+
+#ifndef __WINDOWS_CONTROL_DIALOG_H
+#define __WINDOWS_CONTROL_DIALOG_H
+
+#include "Windows/Window.h"
+
+#ifndef _WIN32
+#define SW_HIDE 0
+#define SW_SHOW 5
+
+#define WM_SETTEXT (6000) // wxID_HIGHEST + 1
+#define WM_USER (6999) // wxID_HIGHEST + 1000
+
+#endif
+
+#ifndef _WIN32
+#define CBN_SELCHANGE 1
+#endif
+
+// FIXME
+#define IDOK (5100) // wxID_OK
+#define IDCANCEL (5101) // wxID_CANCEL
+#define IDABORT (5115) // wxID_ABORT
+#define IDYES (5103) // wxID_YES
+#define IDNO (5104) // wxID_NO
+#define IDHELP (5009) // wxID_HELP
+
+#define BST_CHECKED 1
+#define BST_UNCHECKED 0
+// #define BST_INDETERMINATE 0x0002
+
+#define wsprintf(a,b,c,d,e) swprintf(a,9999,b,c,d,e) // FIXME
+
+namespace NWindows {
+ namespace NControl {
+
+ class CModalDialogImpl;
+
+ class CDialog
+ {
+ protected:
+ CModalDialogImpl * _window;
+ public:
+ operator HWND() const { return HWND(_window); }
+
+ bool OnInit(CModalDialogImpl * window) {
+ _window = window;
+ return OnInit();
+ }
+ virtual bool OnInit() { return false; }
+ virtual void OnOK() {}
+ virtual void OnCancel() {}
+ virtual void OnHelp() {}
+ virtual bool OnButtonClicked(int buttonID, wxWindow * buttonHWND) { return false; }
+ virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { return false; }
+ virtual bool OnCommand(int code, int itemID, LPARAM lParam) { return false; }
+ virtual bool OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { return false; }
+ };
+
+ class CModalDialog : public CDialog
+ {
+ public:
+
+
+ ////////////////// COMPATIBILITY
+
+ bool CheckRadioButton(int firstButtonID, int lastButtonID, int checkButtonID)
+ {
+/*
+ for(int id = firstButtonID; id <= lastButtonID; id++)
+ {
+ CheckButton(id,id == checkButtonID);
+ }
+*/
+ this->CheckButton(checkButtonID,true);
+
+ return true;
+ }
+
+
+ bool CheckButton(int buttonID, UINT checkState);
+ bool CheckButton(int buttonID, bool checkState)
+ {
+ return CheckButton(buttonID, UINT(checkState ? BST_CHECKED : BST_UNCHECKED));
+ }
+
+
+ UINT IsButtonChecked(int buttonID) const;
+
+ bool IsButtonCheckedBool(long buttonID) const
+ { return (IsButtonChecked(buttonID) == BST_CHECKED); }
+
+ void EnableItem(int id, bool state);
+
+ void SetItemText(int id, const TCHAR *txt);
+
+ wxWindow * GetItem(long id) const ;
+
+ void ShowItem(int itemID, int cmdShow) const;
+
+ void End(int result);
+
+ void SetText(const TCHAR *_title); // { _dialog->SetTitle(_title); }
+
+ bool GetText(CSysString &s);
+
+ INT_PTR Create(int id , HWND parentWindow);
+
+ void PostMessage(UINT message);
+
+ virtual void OnHelp() {}
+
+ UINT_PTR SetTimer(UINT_PTR idEvent , unsigned milliseconds);
+
+ void KillTimer(UINT_PTR idEvent);
+
+ virtual void OnOK() { End(IDOK); }
+ virtual void OnCancel() { End(IDCANCEL); }
+ };
+
+class CDialogChildControl : public NWindows::CWindow
+{
+public:
+ CDialogChildControl() {}
+
+ int m_ID;
+ void Init(const NWindows::NControl::CModalDialog &parentDialog, int id)
+ {
+ m_ID = id;
+ this->Attach(parentDialog.GetItem(id));
+ }
+ virtual void SetText(LPCWSTR s);
+ virtual bool GetText(CSysString &s);
+};
+
+}
+}
+
+struct CStringTable
+{
+ int id;
+ const wchar_t *str;
+};
+
+struct CDialogInfo
+{
+ int id;
+ NWindows::NControl::CModalDialogImpl * (*createDialog)(NWindows::NControl::CModalDialog * dialog, HWND parentWindow);
+ CStringTable * stringTable;
+};
+
+void RegisterDialog(const CDialogInfo *dialogInfo);
+
+#define REGISTER_DIALOG_NAME(x) CRegister ## x
+
+#define REGISTER_DIALOG(id,x,stringTable) \
+ static NWindows::NControl::CModalDialogImpl * myCreate##x(NWindows::NControl::CModalDialog * dialog,HWND parentWindow) \
+ { return new x##Impl(dialog,parentWindow,id); } \
+ static struct CDialogInfo g_DialogInfo = { id , myCreate##x, stringTable }; \
+ struct REGISTER_DIALOG_NAME(x) { \
+ REGISTER_DIALOG_NAME(x)() { RegisterDialog(&g_DialogInfo); }}; \
+ static REGISTER_DIALOG_NAME(x) g_RegisterDialog;
+
+#define REGISTER_STRINGTABLE(stringTable) \
+ static struct CDialogInfo g_DialogInfo = { -1 , 0 , stringTable }; \
+ struct REGISTER_DIALOG_NAME(x) { \
+ REGISTER_DIALOG_NAME(x)() { RegisterDialog(&g_DialogInfo); }}; \
+ static REGISTER_DIALOG_NAME(x) g_RegisterDialog;
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/DialogImpl.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/DialogImpl.h
new file mode 100644
index 000000000..f76af1570
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/DialogImpl.h
@@ -0,0 +1,61 @@
+// Windows/Control/DialogImpl.h
+
+#ifndef __WINDOWS_CONTROL_DIALOGIMPL_H
+#define __WINDOWS_CONTROL_DIALOGIMPL_H
+
+#include "Windows/Window.h"
+#include "Windows/Control/Dialog.h"
+
+namespace NWindows {
+ namespace NControl {
+
+#define TIMER_ID_IMPL (1234)
+
+ class CModalDialogImpl : public wxDialog
+ {
+ wxTimer _timer;
+
+ CDialog *_dialog;
+ public:
+ CModalDialogImpl(CDialog *dialog, wxWindow* parent, wxWindowID id, const wxString& title,
+ const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+ long style = wxDEFAULT_DIALOG_STYLE );
+
+ CDialog * Detach()
+ {
+ CDialog * oldDialog = _dialog;
+ _dialog = NULL;
+ return oldDialog;
+ }
+
+ void OnInit()
+ {
+ if (_dialog) _dialog->OnInit(this);
+ }
+
+ void OnAnyButton(wxCommandEvent& event);
+ void OnAnyChoice(wxCommandEvent &event);
+ void OnAnyTimer(wxTimerEvent &event);
+
+ virtual void SetLabel(const wxString &title)
+ {
+ // Why we must do this "alias" ?
+ this->SetTitle(title);
+ }
+
+ //////////////////
+ UINT_PTR SetTimer(UINT_PTR /* FIXME idEvent */, unsigned milliseconds)
+ {
+ _timer.Start(milliseconds);
+ return TIMER_ID_IMPL;
+ }
+ void KillTimer(UINT_PTR idEvent)
+ {
+ if (idEvent == TIMER_ID_IMPL) _timer.Stop();
+ }
+ };
+}
+}
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Edit.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Edit.h
new file mode 100644
index 000000000..e6930e5d4
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Edit.h
@@ -0,0 +1,24 @@
+// Windows/Control/Edit.h
+
+#ifndef __WINDOWS_CONTROL_EDIT_H
+#define __WINDOWS_CONTROL_EDIT_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CEdit: public CWindow
+{
+public:
+ void SetPasswordChar(WPARAM c);
+ void Show(int cmdShow);
+ virtual void SetText(LPCWSTR s);
+ virtual bool GetText(CSysString &s);
+};
+
+}}
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ListView.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ListView.h
new file mode 100644
index 000000000..1756aa1b5
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ListView.h
@@ -0,0 +1,157 @@
+// Windows/Control/ListView.h
+
+#ifndef __WINDOWS_CONTROL_LISTVIEW_H
+#define __WINDOWS_CONTROL_LISTVIEW_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+/*
+#include <commctrl.h>
+*/
+
+#ifndef _WIN32
+
+#define LVCF_FMT 0x0001
+#define LVCF_WIDTH 0x0002
+#define LVCF_TEXT 0x0004
+#define LVCF_SUBITEM 0x0008
+#define LVCF_IMAGE 0x0010
+#define LVCF_ORDER 0x0020
+
+#define LVCFMT_LEFT 0x0000
+#define LVCFMT_RIGHT 0x0001
+#define LVCFMT_CENTER 0x0002
+#define LVCFMT_JUSTIFYMASK 0x0003
+
+
+// state
+#define LVIS_FOCUSED 0x0002 /* wxLIST_STATE_FOCUSED */
+#define LVIS_SELECTED 0x0004 /* wxLIST_STATE_SELECTED */
+
+#define LVNI_SELECTED 0x0004 /* wxLIST_STATE_SELECTED */
+
+typedef INT (CALLBACK *PFNLVCOMPARE)(LPARAM, LPARAM, LPARAM);
+
+typedef struct tagLVCOLUMNW
+{
+ UINT mask;
+ int fmt;
+ int cx;
+ LPWSTR pszText;
+ int cchTextMax;
+ int iSubItem;
+ int iOrder; // FIXME
+} LVCOLUMNW;
+
+#define LVCOLUMN LVCOLUMNW
+#define LV_COLUMNW LVCOLUMNW /* FIXME */
+
+
+
+typedef struct tagLVITEMW
+{
+ UINT mask;
+ int iItem;
+ int iSubItem;
+ UINT state;
+ UINT stateMask;
+ LPWSTR pszText;
+ int cchTextMax;
+ int iImage;
+ LPARAM lParam;
+#if (_WIN32_IE >= 0x0300)
+ int iIndent;
+#endif
+#if (_WIN32_WINNT >= 0x501)
+ int iGroupId;
+ UINT cColumns; // tile view columns
+ PUINT puColumns;
+#endif
+} LVITEMW;
+
+#define LVITEM LVITEMW
+
+#define LVIF_TEXT 0x0001
+// FIXME - mask
+#define LVIF_PARAM 2
+#define LVIF_IMAGE 4
+#define LVIF_STATE 8
+
+#endif
+
+class wxListCtrl;
+
+namespace NWindows {
+namespace NControl {
+
+class CListView // : public NWindows::CWindow
+{
+ wxListCtrl *_list;
+public:
+ CListView() : _list(0) {}
+ void Attach(wxWindow * newWindow);
+
+ operator HWND() const;
+
+ int GetItemCount() const;
+
+ int InsertItem(int index, LPCTSTR text);
+ int InsertItem(const LVITEM* item);
+
+ void SetItem(const LVITEM* item);
+
+ int SetSubItem(int index, int subIndex, LPCTSTR text);
+
+ void SetUnicodeFormat(bool fUnicode) { return ; }
+
+ void InsertColumn(int columnIndex, LPCTSTR text, int width);
+
+ void InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo);
+
+ void DeleteAllItems();
+
+ void SetRedraw(bool);
+
+ void SetItemCount(int );
+
+ void InvalidateRect(void *, bool);
+
+ int GetSelectedCount() const;
+
+ void /* bool */ EnsureVisible(int index, bool partialOK);
+
+ void SetItemState(int index, UINT state, UINT mask);
+
+ UINT GetItemState(int index, UINT mask) const;
+
+ void /* bool */ Update();
+
+ bool DeleteColumn(int columnIndex);
+
+ bool GetItemParam(int itemIndex, LPARAM &param) const;
+
+ int GetNextItem(int startIndex, UINT flags) const;
+
+ int GetFocusedItem() const;
+
+ void RedrawAllItems();
+ // FIXME added
+ int GetColumnCount();
+
+ void SetFocus();
+
+ void RedrawItem(int item);
+
+ bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam);
+
+ bool GetColumn(int columnIndex, LVCOLUMN* columnInfo);
+
+ // HWND EditLabel(int itemIndex)
+ void EditLabel(int itemIndex);
+
+};
+
+}}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ProgressBar.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ProgressBar.h
new file mode 100644
index 000000000..c7bfa8e8d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/ProgressBar.h
@@ -0,0 +1,34 @@
+// Windows/Control/ProgressBar.h
+
+#ifndef __WINDOWS_CONTROL_PROGRESSBAR_H
+#define __WINDOWS_CONTROL_PROGRESSBAR_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+class wxGauge;
+
+namespace NWindows {
+namespace NControl {
+
+
+class CProgressBar : public CWindow
+{
+protected:
+ wxGauge* _window;
+ int _minValue;
+ int _range;
+public:
+ CProgressBar(wxWindow* newWindow = NULL);
+
+ void Attach(wxWindow* newWindow);
+
+ void SetRange32(int minValue, int maxValue);
+
+ void SetPos(int pos);
+};
+
+}}
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Static.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Static.h
new file mode 100644
index 000000000..36469c18f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Static.h
@@ -0,0 +1,23 @@
+// Windows/Control/Static.h
+
+#ifndef __WINDOWS_CONTROL_STATIC_H
+#define __WINDOWS_CONTROL_STATIC_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+typedef void * HICON;
+
+namespace NWindows {
+namespace NControl {
+
+class CStatic : public CWindow
+{
+public:
+
+ HICON SetIcon(HICON icon) { return 0; } // FIXME
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/StatusBar.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/StatusBar.h
new file mode 100644
index 000000000..6b4417d10
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/StatusBar.h
@@ -0,0 +1,56 @@
+// Windows/Control/StatusBar.h
+
+#ifndef __WINDOWS_CONTROL_STATUSBAR_H
+#define __WINDOWS_CONTROL_STATUSBAR_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+class wxStatusBar;
+
+namespace NWindows {
+namespace NControl {
+
+class CStatusBar // : public NWindows::CWindow
+{
+ wxStatusBar * _statusBar;
+public:
+ CStatusBar() : _statusBar(0) {}
+
+ void Attach(wxWindow * newWindow);
+ wxWindow * Detach();
+
+ void SetText(int index, LPCTSTR text);
+
+/* FIXME
+ bool Create(LONG style, LPCTSTR text, HWND hwndParent, UINT id)
+ { return (_window = ::CreateStatusWindow(style, text, hwndParent, id)) != 0; }
+ bool SetParts(int numParts, const int *edgePostions)
+ { return LRESULTToBool(SendMessage(SB_SETPARTS, numParts, (LPARAM)edgePostions)); }
+ bool SetText(LPCTSTR text)
+ { return CWindow::SetText(text); }
+
+ bool SetText(int index, LPCTSTR text, UINT type)
+ { return LRESULTToBool(SendMessage(SB_SETTEXT, index | type, (LPARAM)text)); }
+ bool SetText(int index, LPCTSTR text)
+ { return SetText(index, text, 0); }
+ void Simple(bool simple)
+ { SendMessage(SB_SIMPLE, BoolToBOOL(simple), 0); }
+
+ #ifndef _UNICODE
+ bool Create(LONG style, LPCWSTR text, HWND hwndParent, UINT id)
+ { return (_window = ::CreateStatusWindowW(style, text, hwndParent, id)) != 0; }
+ bool SetText(LPCWSTR text)
+ { return CWindow::SetText(text); }
+ bool SetText(int index, LPCWSTR text, UINT type)
+ { return LRESULTToBool(SendMessage(SB_SETTEXTW, index | type, (LPARAM)text)); }
+ bool SetText(int index, LPCWSTR text)
+ { return SetText(index, text, 0); }
+ #endif
+*/
+};
+
+}}
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Window2.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Window2.cpp
new file mode 100644
index 000000000..dda1da090
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Window2.cpp
@@ -0,0 +1,211 @@
+// Windows/Control/Window2.cpp
+
+#include "StdAfx.h"
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+#include "Windows/Control/Window2.h"
+
+// extern HINSTANCE g_hInstance;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+
+#ifndef _UNICODE
+ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
+#endif
+
+namespace NControl {
+
+#ifdef _WIN32
+static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ CWindow tempWindow(aHWND);
+ if (message == WM_NCCREATE)
+ tempWindow.SetUserDataLongPtr(
+ LONG_PTR(((LPCREATESTRUCT)lParam)->lpCreateParams));
+ CWindow2 *window = (CWindow2*)(tempWindow.GetUserDataLongPtr());
+ if (window != NULL && message == WM_NCCREATE)
+ window->Attach(aHWND);
+ if (window == 0)
+ {
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(aHWND, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(aHWND, message, wParam, lParam);
+ }
+ return window->OnMessage(message, wParam, lParam);
+}
+
+bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className,
+ LPCTSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance)
+{
+ WNDCLASS windowClass;
+ if(!::GetClassInfo(instance, className, &windowClass))
+ {
+ // windowClass.style = CS_HREDRAW | CS_VREDRAW;
+ windowClass.style = 0;
+
+ windowClass.lpfnWndProc = WindowProcedure;
+ windowClass.cbClsExtra = NULL;
+ windowClass.cbWndExtra = NULL;
+ windowClass.hInstance = instance;
+ windowClass.hIcon = NULL;
+ windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ windowClass.lpszMenuName = NULL;
+ windowClass.lpszClassName = className;
+ if (::RegisterClass(&windowClass) == 0)
+ return false;
+ }
+ return CWindow::CreateEx(exStyle, className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, this);
+}
+
+#ifndef _UNICODE
+
+bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance)
+{
+ bool needRegister;
+ if(g_IsNT)
+ {
+ WNDCLASSW windowClass;
+ needRegister = ::GetClassInfoW(instance, className, &windowClass) == 0;
+ }
+ else
+ {
+ WNDCLASSA windowClassA;
+ AString classNameA;
+ LPCSTR classNameP;
+ if (IS_INTRESOURCE(className))
+ classNameP = (LPCSTR)className;
+ else
+ {
+ classNameA = GetSystemString(className);
+ classNameP = classNameA;
+ }
+ needRegister = ::GetClassInfoA(instance, classNameP, &windowClassA) == 0;
+ }
+ if (needRegister)
+ {
+ WNDCLASSW windowClass;
+ // windowClass.style = CS_HREDRAW | CS_VREDRAW;
+ windowClass.style = 0;
+ windowClass.lpfnWndProc = WindowProcedure;
+ windowClass.cbClsExtra = NULL;
+ windowClass.cbWndExtra = NULL;
+ windowClass.hInstance = instance;
+ windowClass.hIcon = NULL;
+ windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ windowClass.lpszMenuName = NULL;
+ windowClass.lpszClassName = className;
+ if (MyRegisterClass(&windowClass) == 0)
+ return false;
+ }
+ return CWindow::CreateEx(exStyle, className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, this);
+
+}
+#endif
+
+LRESULT CWindow2::DefProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(_window, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(_window, message, wParam, lParam);
+}
+#endif
+
+LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT result;
+ switch (message)
+ {
+ case WM_CREATE:
+ if (!OnCreate((CREATESTRUCT *)lParam))
+ return -1;
+ break;
+ case WM_COMMAND:
+ if (OnCommand(wParam, lParam, result))
+ return result;
+ break;
+ case WM_NOTIFY:
+ if (OnNotify((UINT)wParam, (LPNMHDR) lParam, result))
+ return result;
+ break;
+ case WM_DESTROY:
+ OnDestroy();
+ break;
+ case WM_CLOSE:
+ OnClose();
+ return 0;
+#ifdef _WIN32
+ case WM_SIZE:
+ if (OnSize(wParam, LOWORD(lParam), HIWORD(lParam)))
+ return 0;
+#endif
+ }
+#ifdef _WIN32
+ return DefProc(message, wParam, lParam);
+#else
+ return 0;
+#endif
+}
+
+bool CWindow2::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result)
+{
+ return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam, result);
+}
+
+bool CWindow2::OnCommand(int /* code */, int /* itemID */, LPARAM /* lParam */, LRESULT & /* result */)
+{
+ return false;
+ // return DefProc(message, wParam, lParam);
+ /*
+ if (code == BN_CLICKED)
+ return OnButtonClicked(itemID, (HWND)lParam);
+ */
+}
+
+/*
+bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(aButtonID)
+ {
+ case IDOK:
+ OnOK();
+ break;
+ case IDCANCEL:
+ OnCancel();
+ break;
+ case IDHELP:
+ OnHelp();
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+*/
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Window2.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Window2.h
new file mode 100644
index 000000000..cec666b16
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Control/Window2.h
@@ -0,0 +1,107 @@
+// Windows/Control/Window2.h
+
+#ifndef __WINDOWS_CONTROL_WINDOW2_H
+#define __WINDOWS_CONTROL_WINDOW2_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+#ifndef _WIN32
+typedef void * WNDPROC;
+typedef void * CREATESTRUCT;
+typedef struct
+{
+ HWND hwndFrom;
+
+ UINT code;
+#define NM_DBLCLK 1
+#define LVN_ITEMCHANGED 2
+#define LVN_COLUMNCLICK 3
+} NMHDR;
+typedef NMHDR * LPNMHDR;
+
+typedef struct tagNMLISTVIEW
+{
+ NMHDR hdr;
+ INT iItem;
+ INT iSubItem;
+ UINT uNewState;
+ UINT uOldState;
+ // UINT uChanged;
+ // POINT ptAction;
+ LPARAM lParam;
+} NMLISTVIEW, *LPNMLISTVIEW;
+
+typedef void * LPNMITEMACTIVATE;
+
+#define NM_RCLICK 1234 /* FIXME */
+
+// FIXME
+#define WM_CREATE 1
+#define WM_COMMAND 2
+#define WM_NOTIFY 3
+#define WM_DESTROY 4
+#define WM_CLOSE 5
+
+#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))
+#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xFFFF))
+
+
+#endif
+
+namespace NWindows {
+namespace NControl {
+
+class CWindow2 // : public CWindow
+{
+ // LRESULT DefProc(UINT message, WPARAM wParam, LPARAM lParam);
+public:
+ // CWindow2(HWND newWindow = NULL): CWindow(newWindow){};
+ CWindow2() {}
+ virtual ~CWindow2() {}
+
+#ifdef _WIN32
+ bool CreateEx(DWORD exStyle, LPCTSTR className,
+ LPCTSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance);
+
+ #ifndef _UNICODE
+ bool CreateEx(DWORD exStyle, LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance);
+ #endif
+#endif
+
+ virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual bool OnCreate(CREATESTRUCT * /* createStruct */) { return true; }
+ // virtual LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
+ virtual bool OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result);
+ virtual bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result);
+ virtual bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; }
+ virtual bool OnNotify(UINT /* controlID */, LPNMHDR /* lParam */, LRESULT & /* result */) { return false; }
+ virtual void OnDestroy() { /* FIXME PostQuitMessage(0); */ }
+ virtual void OnClose() { /* FIXME Destroy(); */ }
+ /*
+ virtual LRESULT OnHelp(LPHELPINFO helpInfo) { OnHelp(); };
+ virtual LRESULT OnHelp() {};
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ virtual void OnOK() {};
+ virtual void OnCancel() {};
+ */
+
+#ifdef _WIN32
+ LONG_PTR SetMsgResult(LONG_PTR newLongPtr )
+ { return SetLongPtr(DWLP_MSGRESULT, newLongPtr); }
+ LONG_PTR GetMsgResult() const
+ { return GetLongPtr(DWLP_MSGRESULT); }
+#endif
+};
+
+}}
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/DLL.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/DLL.cpp
new file mode 100644
index 000000000..32104c464
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/DLL.cpp
@@ -0,0 +1,193 @@
+// Windows/DLL.cpp
+
+#include "StdAfx.h"
+
+#ifdef __APPLE_CC__
+#include <mach-o/dyld.h>
+#elif ENV_BEOS
+#include <kernel/image.h>
+#include <Path.h>
+#else
+#define UINT64 DLL_UINT64 // HP-UX , dlfcn.h defines UINT64 but p7zip also defines UINT64
+#include <dlfcn.h> // dlopen ...
+#undef UINT64
+#endif
+
+#include "DLL.h"
+#include "Defs.h"
+#ifdef _UNICODE
+#include "../Common/StringConvert.h"
+#endif
+
+#define NEED_NAME_WINDOWS_TO_UNIX
+#include "myPrivate.h"
+
+// #define TRACEN(u) u;
+#define TRACEN(u) /* */
+
+namespace NWindows {
+namespace NDLL {
+
+CLibrary::~CLibrary()
+{
+ Free();
+}
+
+bool CLibrary::Free()
+{
+TRACEN((printf("CLibrary::Free(%p)\n",(void *)_module)))
+ if (_module == 0)
+ return true;
+
+#ifdef __APPLE_CC__
+ int ret = NSUnLinkModule ((NSModule)_module, 0);
+#elif ENV_BEOS
+ int ret = unload_add_on((image_id)_module);
+#else
+ int ret = dlclose(_module);
+#endif
+TRACEN((printf("CLibrary::Free dlclose(%p)=%d\n",(void *)_module,ret)))
+ if (ret != 0) return false;
+ _module = 0;
+ return true;
+}
+
+static FARPROC local_GetProcAddress(HMODULE module,LPCSTR lpProcName)
+{
+ void *ptr = 0;
+ TRACEN((printf("local_GetProcAddress(%p,%s)\n",(void *)module,lpProcName)))
+ if (module) {
+#ifdef __APPLE_CC__
+ char name[MAX_PATHNAME_LEN];
+ snprintf(name,sizeof(name),"_%s",lpProcName);
+ name[sizeof(name)-1] = 0;
+ TRACEN((printf("NSLookupSymbolInModule(%p,%s)\n",(void *)module,name)))
+ NSSymbol sym;
+ sym = NSLookupSymbolInModule((NSModule)module, name);
+ if (sym) {
+ ptr = NSAddressOfSymbol(sym);
+ } else {
+ ptr = 0;
+ }
+#elif ENV_BEOS
+ if (get_image_symbol((image_id)module, lpProcName, B_SYMBOL_TYPE_TEXT, &ptr) != B_OK)
+ ptr = 0;
+#else
+ ptr = dlsym (module, lpProcName);
+#endif
+ TRACEN((printf("CLibrary::GetProcAddress : dlsym(%p,%s)=%p\n",(void *)module,lpProcName,ptr)))
+ }
+ return (FARPROC)ptr;
+}
+
+FARPROC CLibrary::GetProcAddress(LPCSTR lpProcName) const
+{
+ TRACEN((printf("CLibrary::GetProcAddress(%p,%s)\n",(void *)_module,lpProcName)))
+ return local_GetProcAddress(_module,lpProcName);
+}
+
+bool CLibrary::LoadOperations(HMODULE newModule)
+{
+ if (newModule == NULL)
+ return false;
+ if(!Free())
+ return false;
+ _module = newModule;
+ return true;
+}
+
+bool CLibrary::Load(LPCTSTR lpLibFileName)
+{
+ void *handler = 0;
+ char name[MAX_PATHNAME_LEN+1];
+#ifdef _UNICODE
+ AString name2 = UnicodeStringToMultiByte(lpLibFileName);
+ strcpy(name,nameWindowToUnix((const char *)name2));
+#else
+ strcpy(name,nameWindowToUnix(lpLibFileName));
+#endif
+
+ // replace ".dll" with ".so"
+ size_t len = strlen(name);
+ if ((len >=4) && (strcmp(name+len-4,".dll") == 0)) {
+ strcpy(name+len-4,".so");
+ }
+
+ TRACEN((printf("CLibrary::Load(%s) => %s\n",lpLibFileName,name)))
+
+#ifdef __APPLE_CC__
+ NSObjectFileImage image;
+ NSObjectFileImageReturnCode nsret;
+
+ nsret = NSCreateObjectFileImageFromFile (name, &image);
+ if (nsret == NSObjectFileImageSuccess) {
+ TRACEN((printf("NSCreateObjectFileImageFromFile(%s) : OK\n",name)))
+ handler = (HMODULE)NSLinkModule(image,lpLibFileName,NSLINKMODULE_OPTION_RETURN_ON_ERROR
+ | NSLINKMODULE_OPTION_PRIVATE | NSLINKMODULE_OPTION_BINDNOW);
+ } else {
+ TRACEN((printf("NSCreateObjectFileImageFromFile(%s) : ERROR\n",name)))
+ }
+#elif ENV_BEOS
+ // normalize path (remove things like "./", "..", etc..), otherwise it won't work
+ BPath p(name, NULL, true);
+ status_t err = B_OK;
+ image_id image = load_add_on(p.Path());
+TRACEN((printf("load_add_on(%s)=%d\n",p.Path(),(int)image)))
+ if (image < 0) {
+ err = (image_id)handler;
+ handler = 0;
+ } else {
+ err = 0;
+ handler = (HMODULE)image;
+ }
+#else
+ int options_dlopen = 0;
+#ifdef RTLD_LOCAL
+ options_dlopen |= RTLD_LOCAL;
+#endif
+#ifdef RTLD_NOW
+ options_dlopen |= RTLD_NOW;
+#endif
+#ifdef RTLD_GROUP
+ #if ! (defined(hpux) || defined(__hpux))
+ options_dlopen |= RTLD_GROUP; // mainly for solaris but not for HPUX
+ #endif
+#endif
+ TRACEN((printf("CLibrary::Load - dlopen(%s,0x%d)\n",name,options_dlopen)))
+ handler = dlopen(name,options_dlopen);
+#endif // __APPLE_CC__
+ TRACEN((printf("CLibrary::Load(%s) => %p\n",name,handler)))
+ if (handler) {
+
+ // Call DllMain() like in Windows : useless now
+
+ // Propagate the value of global_use_utf16_conversion into the plugins
+ int *tmp = (int *)local_GetProcAddress(handler,"global_use_utf16_conversion");
+ if (tmp) *tmp = global_use_utf16_conversion;
+
+ tmp = (int *)local_GetProcAddress(handler,"global_use_lstat");
+ if (tmp) *tmp = global_use_lstat;
+
+ // test construtors calls
+ void (*fctTest)(void) = (void (*)(void))local_GetProcAddress(handler,"sync_TestConstructor");
+ if (fctTest) fctTest();
+
+ } else {
+#ifdef __APPLE_CC__
+ NSLinkEditErrors c;
+ int num_err;
+ const char *file,*err;
+ NSLinkEditError(&c,&num_err,&file,&err);
+ printf("Can't load '%s' (%s)\n", lpLibFileName,err);
+#elif ENV_BEOS
+ printf("Can't load '%s' (%s)\n", lpLibFileName,strerror(err));
+#else
+ printf("Can't load '%s' (%s)\n", lpLibFileName,dlerror());
+#endif
+ }
+
+ return LoadOperations(handler);
+}
+
+}}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/DLL.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/DLL.h
new file mode 100644
index 000000000..64dabb02a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/DLL.h
@@ -0,0 +1,48 @@
+// Windows/DLL.h
+
+#ifndef __WINDOWS_DLL_H
+#define __WINDOWS_DLL_H
+
+#include "../Common/MyString.h"
+
+typedef void * HMODULE;
+
+typedef int (*FARPROC)();
+
+namespace NWindows {
+namespace NDLL {
+
+class CLibrary
+{
+ bool LoadOperations(HMODULE newModule);
+ HMODULE _module;
+public:
+ operator HMODULE() const { return _module; }
+ HMODULE* operator&() { return &_module; }
+
+
+ CLibrary():_module(NULL) {};
+ ~CLibrary();
+
+ bool Free();
+
+ void Attach(HMODULE m)
+ {
+ Free();
+ _module = m;
+ }
+ HMODULE Detach()
+ {
+ HMODULE m = _module;
+ _module = NULL;
+ return m;
+ }
+
+
+ bool Load(LPCTSTR fileName);
+ FARPROC GetProcAddress(LPCSTR procName) const;
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Defs.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Defs.h
new file mode 100644
index 000000000..898be8d74
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Defs.h
@@ -0,0 +1,23 @@
+// Windows/Defs.h
+
+#ifndef __WINDOWS_DEFS_H
+#define __WINDOWS_DEFS_H
+
+inline bool BOOLToBool(BOOL value)
+ { return (value != FALSE); }
+
+#ifdef _WIN32
+inline bool LRESULTToBool(LRESULT value)
+ { return (value != FALSE); }
+#endif
+
+inline BOOL BoolToBOOL(bool value)
+ { return (value ? TRUE: FALSE); }
+
+inline VARIANT_BOOL BoolToVARIANT_BOOL(bool value)
+ { return (value ? VARIANT_TRUE: VARIANT_FALSE); }
+
+inline bool VARIANT_BOOLToBool(VARIANT_BOOL value)
+ { return (value != VARIANT_FALSE); }
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Error.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Error.cpp
new file mode 100644
index 000000000..0243b51fc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Error.cpp
@@ -0,0 +1,64 @@
+// Windows/Error.h
+
+#include "StdAfx.h"
+
+#include "Windows/Error.h"
+#include "Common/StringConvert.h"
+
+#include <stdio.h>
+
+namespace NWindows {
+namespace NError {
+
+bool MyFormatMessage(DWORD messageID, CSysString &message)
+{
+ const char * txt = 0;
+ AString msg;
+
+ switch(messageID) {
+ case ERROR_NO_MORE_FILES : txt = "No more files"; break ;
+ case E_NOTIMPL : txt = "E_NOTIMPL"; break ;
+ case E_NOINTERFACE : txt = "E_NOINTERFACE"; break ;
+ case E_ABORT : txt = "E_ABORT"; break ;
+ case E_FAIL : txt = "E_FAIL"; break ;
+ case STG_E_INVALIDFUNCTION : txt = "STG_E_INVALIDFUNCTION"; break ;
+ case E_OUTOFMEMORY : txt = "E_OUTOFMEMORY"; break ;
+ case E_INVALIDARG : txt = "E_INVALIDARG"; break ;
+ default:
+ txt = strerror(messageID);
+ }
+ if (txt) {
+ msg = txt;
+ } else {
+ char msgBuf[256];
+#ifdef ENV_UNIX
+ snprintf(msgBuf,sizeof(msgBuf),"error #%x",(unsigned)messageID);
+#else
+ _snprintf(msgBuf,sizeof(msgBuf),"error #%x",(unsigned)messageID);
+#endif
+ msgBuf[sizeof(msgBuf)-1] = 0;
+ msg = msgBuf;
+ }
+
+ msg += " ";
+
+#ifdef _UNICODE
+ message = MultiByteToUnicodeString(msg);
+#else
+ message = msg;
+#endif
+ return true;
+}
+
+#ifndef _UNICODE
+bool MyFormatMessage(DWORD messageID, UString &message)
+{
+ CSysString messageSys;
+ bool result = MyFormatMessage(messageID, messageSys);
+ message = GetUnicodeString(messageSys);
+ return result;
+}
+#endif
+
+}}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Error.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Error.h
new file mode 100644
index 000000000..05b5cd0ea
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Error.h
@@ -0,0 +1,33 @@
+// Windows/Error.h
+
+#ifndef __WINDOWS_ERROR_H
+#define __WINDOWS_ERROR_H
+
+#include "Common/MyString.h"
+
+namespace NWindows {
+namespace NError {
+
+bool MyFormatMessage(DWORD messageID, CSysString &message);
+inline CSysString MyFormatMessage(DWORD messageID)
+{
+ CSysString message;
+ MyFormatMessage(messageID, message);
+ return message;
+}
+#ifdef _UNICODE
+inline UString MyFormatMessageW(DWORD messageID)
+ { return MyFormatMessage(messageID); }
+#else
+bool MyFormatMessage(DWORD messageID, UString &message);
+inline UString MyFormatMessageW(DWORD messageID)
+{
+ UString message;
+ MyFormatMessage(messageID, message);
+ return message;
+}
+#endif
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileDir.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileDir.cpp
new file mode 100644
index 000000000..d901d8d8e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileDir.cpp
@@ -0,0 +1,987 @@
+// Windows/FileDir.cpp
+
+#include "StdAfx.h"
+
+#include "FileDir.h"
+#include "FileName.h"
+#include "FileFind.h"
+#include "Defs.h"
+#include "../Common/StringConvert.h"
+
+#define NEED_NAME_WINDOWS_TO_UNIX
+#include "myPrivate.h"
+#include "Windows/Synchronization.h"
+#ifdef ENV_UNIX
+#include <unistd.h> // rmdir
+#include <utime.h>
+#endif
+
+#include <errno.h>
+
+#include <sys/stat.h> // mkdir
+#include <sys/types.h>
+#include <fcntl.h>
+
+
+// #define TRACEN(u) u;
+#define TRACEN(u) /* */
+
+#ifdef ENV_UNIX
+class Umask
+{
+ public:
+ mode_t current_umask;
+ mode_t mask;
+ Umask() {
+ current_umask = umask (0); /* get and set the umask */
+ umask(current_umask); /* restore the umask */
+ mask = 0777 & (~current_umask);
+ }
+};
+
+static Umask gbl_umask;
+#endif
+
+#ifdef _UNICODE
+AString nameWindowToUnix2(LPCWSTR name) // FIXME : optimization ?
+{
+ AString astr = UnicodeStringToMultiByte(name);
+ return AString(nameWindowToUnix((const char *)astr));
+}
+#endif
+
+extern BOOLEAN WINAPI RtlTimeToSecondsSince1970( const LARGE_INTEGER *Time, DWORD *Seconds );
+
+#ifdef _UNICODE
+#ifdef ENV_UNIX
+DWORD WINAPI GetFullPathName( LPCTSTR name, DWORD len, LPTSTR buffer, LPTSTR *lastpart ) { // FIXME
+ if (name == 0) return 0;
+
+ DWORD name_len = lstrlen(name);
+
+ if (name[0] == '/') {
+ DWORD ret = name_len+2;
+ if (ret >= len) {
+ TRACEN((printf("GetFullPathNameA(%ls,%d,)=0000 (case 0)\n",name, (int)len)))
+ return 0;
+ }
+ lstrcpy(buffer,L"c:");
+ lstrcat(buffer,name);
+
+ *lastpart=buffer;
+ TCHAR *ptr=buffer;
+ while (*ptr) {
+ if (*ptr == '/')
+ *lastpart=ptr+1;
+ ptr++;
+ }
+ TRACEN((printf("GetFullPathNameA(%s,%d,%ls,%ls)=%d\n",name, (int)len,buffer, *lastpart,(int)ret)))
+ return ret;
+ }
+ if (isascii(name[0]) && (name[1] == ':')) { // FIXME isascii
+ DWORD ret = name_len;
+ if (ret >= len) {
+ TRACEN((printf("GetFullPathNameA(%ls,%d,)=0000 (case 1)\n",name, (int)len)))
+ return 0;
+ }
+ lstrcpy(buffer,name);
+
+ *lastpart=buffer;
+ TCHAR *ptr=buffer;
+ while (*ptr) {
+ if (*ptr == '/')
+ *lastpart=ptr+1;
+ ptr++;
+ }
+ TRACEN((printf("GetFullPathNameA(%sl,%d,%ls,%ls)=%d\n",name, (int)len,buffer, *lastpart,(int)ret)))
+ return ret;
+ }
+
+ // name is a relative pathname.
+ //
+ if (len < 2) {
+ TRACEN((printf("GetFullPathNameA(%s,%d,)=0000 (case 2)\n",name, (int)len)))
+ return 0;
+ }
+
+ DWORD ret = 0;
+ char begin[MAX_PATHNAME_LEN];
+ /* DWORD begin_len = GetCurrentDirectoryA(MAX_PATHNAME_LEN,begin); */
+ DWORD begin_len = 0;
+ begin[0]='c';
+ begin[1]=':';
+ char * cret = getcwd(begin+2, MAX_PATHNAME_LEN - 3);
+ if (cret) {
+ begin_len = strlen(begin);
+ }
+
+ if (begin_len >= 1) {
+ // strlen(begin) + strlen("/") + strlen(name)
+ ret = begin_len + 1 + name_len;
+
+ if (ret >= len) {
+ TRACEN((printf("GetFullPathNameA(%s,%d,)=0000 (case 4)\n",name, (int)len)))
+ return 0;
+ }
+ UString wbegin = GetUnicodeString(begin);
+ lstrcpy(buffer,wbegin);
+ lstrcat(buffer,L"/");
+ lstrcat(buffer,name);
+
+ *lastpart=buffer + begin_len + 1;
+ TCHAR *ptr=buffer;
+ while (*ptr) {
+ if (*ptr == '/')
+ *lastpart=ptr+1;
+ ptr++;
+ }
+ TRACEN((printf("GetFullPathNameA(%s,%d,%s,%s)=%d\n",name, (int)len,buffer, *lastpart,(int)ret)))
+ } else {
+ ret = 0;
+ TRACEN((printf("GetFullPathNameA(%s,%d,)=0000 (case 5)\n",name, (int)len)))
+ }
+ return ret;
+}
+#endif
+#endif
+
+#ifdef ENV_UNIX
+DWORD WINAPI GetFullPathName( LPCSTR name, DWORD len, LPSTR buffer, LPSTR *lastpart ) {
+ if (name == 0) return 0;
+
+ DWORD name_len = strlen(name);
+
+ if (name[0] == '/') {
+ DWORD ret = name_len+2;
+ if (ret >= len) {
+ TRACEN((printf("GetFullPathNameA(%s,%d,)=0000 (case 0)\n",name, (int)len)))
+ return 0;
+ }
+ strcpy(buffer,"c:");
+ strcat(buffer,name);
+
+ *lastpart=buffer;
+ char *ptr=buffer;
+ while (*ptr) {
+ if (*ptr == '/')
+ *lastpart=ptr+1;
+ ptr++;
+ }
+ TRACEN((printf("GetFullPathNameA(%s,%d,%s,%s)=%d\n",name, (int)len,buffer, *lastpart,(int)ret)))
+ return ret;
+ }
+ if (isascii(name[0]) && (name[1] == ':')) {
+ DWORD ret = name_len;
+ if (ret >= len) {
+ TRACEN((printf("GetFullPathNameA(%s,%d,)=0000 (case 1)\n",name, (int)len)))
+ return 0;
+ }
+ strcpy(buffer,name);
+
+ *lastpart=buffer;
+ char *ptr=buffer;
+ while (*ptr) {
+ if (*ptr == '/')
+ *lastpart=ptr+1;
+ ptr++;
+ }
+ TRACEN((printf("GetFullPathNameA(%s,%d,%s,%s)=%d\n",name, (int)len,buffer, *lastpart,(int)ret)))
+ return ret;
+ }
+
+ // name is a relative pathname.
+ //
+ if (len < 2) {
+ TRACEN((printf("GetFullPathNameA(%s,%d,)=0000 (case 2)\n",name, (int)len)))
+ return 0;
+ }
+
+ DWORD ret = 0;
+ char begin[MAX_PATHNAME_LEN];
+ /* DWORD begin_len = GetCurrentDirectoryA(MAX_PATHNAME_LEN,begin); */
+ DWORD begin_len = 0;
+ begin[0]='c';
+ begin[1]=':';
+ char * cret = getcwd(begin+2, MAX_PATHNAME_LEN - 3);
+ if (cret) {
+ begin_len = strlen(begin);
+ }
+
+ if (begin_len >= 1) {
+ // strlen(begin) + strlen("/") + strlen(name)
+ ret = begin_len + 1 + name_len;
+
+ if (ret >= len) {
+ TRACEN((printf("GetFullPathNameA(%s,%d,)=0000 (case 4)\n",name, (int)len)))
+ return 0;
+ }
+ strcpy(buffer,begin);
+ strcat(buffer,"/");
+ strcat(buffer,name);
+
+ *lastpart=buffer + begin_len + 1;
+ char *ptr=buffer;
+ while (*ptr) {
+ if (*ptr == '/')
+ *lastpart=ptr+1;
+ ptr++;
+ }
+ TRACEN((printf("GetFullPathNameA(%s,%d,%s,%s)=%d\n",name, (int)len,buffer, *lastpart,(int)ret)))
+ } else {
+ ret = 0;
+ TRACEN((printf("GetFullPathNameA(%s,%d,)=0000 (case 5)\n",name, (int)len)))
+ }
+ return ret;
+}
+
+static BOOL WINAPI RemoveDirectory(LPCSTR path) {
+ if (!path || !*path) {
+ SetLastError(ERROR_PATH_NOT_FOUND);
+ return FALSE;
+ }
+ const char * name = nameWindowToUnix(path);
+ TRACEN((printf("RemoveDirectoryA(%s)\n",name)))
+
+ if (rmdir( name ) != 0) {
+ return FALSE;
+ }
+ return TRUE;
+}
+#ifdef _UNICODE
+static BOOL WINAPI RemoveDirectory(LPCWSTR path) {
+ if (!path || !*path) {
+ SetLastError(ERROR_PATH_NOT_FOUND);
+ return FALSE;
+ }
+ AString name = nameWindowToUnix2(path);
+ TRACEN((printf("RemoveDirectoryA(%s)\n",(const char *)name)))
+
+ if (rmdir( (const char *)name ) != 0) {
+ return FALSE;
+ }
+ return TRUE;
+}
+#endif
+
+static int copy_fd(int fin,int fout)
+{
+ char buffer[16384];
+ ssize_t ret_in;
+ ssize_t ret_out;
+
+ do {
+ ret_out = -1;
+ do {
+ ret_in = read(fin, buffer,sizeof(buffer));
+ } while (ret_in < 0 && (errno == EINTR));
+ if (ret_in >= 1) {
+ do {
+ ret_out = write (fout, buffer, ret_in);
+ } while (ret_out < 0 && (errno == EINTR));
+ } else if (ret_in == 0) {
+ ret_out = 0;
+ }
+ } while (ret_out >= 1);
+ return ret_out;
+}
+
+static BOOL CopyFile(const char *src,const char *dst)
+{
+ int ret = -1;
+
+#ifdef O_BINARY
+ int flags = O_BINARY;
+#else
+ int flags = 0;
+#endif
+
+#ifdef O_LARGEFILE
+ flags |= O_LARGEFILE;
+#endif
+
+ int fout = open(dst,O_CREAT | O_WRONLY | O_EXCL | flags, 0600);
+ if (fout != -1)
+ {
+ int fin = open(src,O_RDONLY | flags , 0600);
+ if (fin != -1)
+ {
+ ret = copy_fd(fin,fout);
+ if (ret == 0) ret = close(fin);
+ else close(fin);
+ }
+ if (ret == 0) ret = close(fout);
+ else close(fout);
+ }
+ if (ret == 0) return TRUE;
+ return FALSE;
+}
+#endif
+
+/*****************************************************************************************/
+
+
+namespace NWindows {
+namespace NFile {
+namespace NDirectory {
+
+
+bool MySetCurrentDirectory(LPCWSTR wpath)
+{
+#ifdef ENV_UNIX
+ AString path = UnicodeStringToMultiByte(wpath);
+
+ return chdir((const char*)path) == 0;
+#else
+ return BOOLToBool( ::SetCurrentDirectoryW( wpath ) );
+#endif
+}
+
+#ifdef _UNICODE
+bool GetOnlyName(LPCTSTR fileName, CSysString &resultName)
+{
+ int index;
+ if (!MyGetFullPathName(fileName, resultName, index))
+ return false;
+ resultName = resultName.Mid(index);
+ return true;
+}
+
+bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName)
+{
+ int index;
+ if (!MyGetFullPathName(fileName, resultName, index))
+ return false;
+ resultName = resultName.Left(index);
+ return true;
+}
+#endif
+
+
+bool MyGetCurrentDirectory(CSysString &resultPath)
+{
+#ifdef ENV_UNIX
+ char begin[MAX_PATHNAME_LEN];
+ begin[0]='c';
+ begin[1]=':';
+ char * cret = getcwd(begin+2, MAX_PATHNAME_LEN - 3);
+ if (cret)
+ {
+#ifdef _UNICODE
+ resultPath = GetUnicodeString(begin);
+#else
+ resultPath = begin;
+#endif
+ return true;
+ }
+ return false;
+#else
+ wchar_t buffer[ MAX_PATH + 1 ];
+ const DWORD needLength = ::GetCurrentDirectoryW( MAX_PATH + 1, buffer );
+ resultPath = buffer;
+ return needLength > 0 && needLength <= MAX_PATH;
+#endif
+}
+
+bool MyMoveFile( LPCTSTR fn1, LPCTSTR fn2 ) {
+#ifdef ENV_UNIX
+#ifdef _UNICODE
+ AString src = nameWindowToUnix2(fn1);
+ AString dst = nameWindowToUnix2(fn2);
+#else
+ const char * src = nameWindowToUnix(fn1);
+ const char * dst = nameWindowToUnix(fn2);
+#endif
+
+ TRACEN((printf("MoveFileW(%s,%s)\n",src,dst)))
+
+ int ret = rename(src,dst);
+ if (ret != 0)
+ {
+ if (errno == EXDEV) // FIXED : bug #1112167 (Temporary directory must be on same partition as target)
+ {
+ BOOL bret = CopyFile(src,dst);
+ if (bret == FALSE) return false;
+
+ struct stat info_file;
+ ret = stat(src,&info_file);
+ if (ret == 0) {
+ TRACEN((printf("##DBG chmod-1(%s,%o)\n",dst,(unsigned)info_file.st_mode & gbl_umask.mask)))
+ ret = chmod(dst,info_file.st_mode & gbl_umask.mask);
+ }
+ if (ret == 0) {
+ ret = unlink(src);
+ }
+ if (ret == 0) return true;
+ }
+ return false;
+ }
+ return true;
+#else
+ if( ::MoveFile( fn1, fn2 ) )
+ return true;
+#ifdef WIN_LONG_PATH2
+ UString d1, d2;
+ if( GetLongPaths( fn1, fn2, d1, d2 ) )
+ return BOOLToBool( ::MoveFileW( d1, d2 ) );
+#endif
+ return false;
+#endif
+}
+
+bool MyRemoveDirectory(LPCTSTR pathName)
+{
+ return BOOLToBool(::RemoveDirectory(pathName));
+}
+
+bool SetDirTime(LPCWSTR fileName, const FILETIME * lpCreationTime,
+ const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime)
+{
+#ifdef ENV_UNIX
+ (void)lpCreationTime;
+ AString cfilename = UnicodeStringToMultiByte(fileName);
+ const char * unix_filename = nameWindowToUnix((const char *)cfilename);
+
+ struct utimbuf buf;
+
+ struct stat oldbuf;
+ int ret = stat(unix_filename,&oldbuf);
+ if (ret == 0) {
+ buf.actime = oldbuf.st_atime;
+ buf.modtime = oldbuf.st_mtime;
+ } else {
+ time_t current_time = time(0);
+ buf.actime = current_time;
+ buf.modtime = current_time;
+ }
+
+ if (lpLastAccessTime)
+ {
+ LARGE_INTEGER ltime;
+ DWORD dw;
+ ltime.QuadPart = lpLastAccessTime->dwHighDateTime;
+ ltime.QuadPart = (ltime.QuadPart << 32) | lpLastAccessTime->dwLowDateTime;
+ RtlTimeToSecondsSince1970( &ltime, &dw );
+ buf.actime = dw;
+ }
+
+ if (lpLastWriteTime)
+ {
+ LARGE_INTEGER ltime;
+ DWORD dw;
+ ltime.QuadPart = lpLastWriteTime->dwHighDateTime;
+ ltime.QuadPart = (ltime.QuadPart << 32) | lpLastWriteTime->dwLowDateTime;
+ RtlTimeToSecondsSince1970( &ltime, &dw );
+ buf.modtime = dw;
+ }
+
+ /* ret = */ utime(unix_filename, &buf);
+
+ return true;
+#else
+ HANDLE hDir = ::CreateFileW( fileName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
+#ifdef WIN_LONG_PATH
+ if( hDir == INVALID_HANDLE_VALUE )
+ {
+ UString longPath;
+ if( GetLongPath( fileName, longPath ) )
+ hDir = ::CreateFileW( longPath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
+ }
+#endif
+
+ bool res = false;
+ if( hDir != INVALID_HANDLE_VALUE )
+ {
+ res = BOOLToBool( ::SetFileTime( hDir, lpCreationTime, lpLastAccessTime, lpLastWriteTime ) );
+ ::CloseHandle( hDir );
+ }
+ return res;
+#endif
+}
+
+#ifndef _UNICODE
+bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes)
+{
+ return MySetFileAttributes(UnicodeStringToMultiByte(fileName, CP_ACP), fileAttributes);
+}
+
+bool MyRemoveDirectory(LPCWSTR pathName)
+{
+ return MyRemoveDirectory(UnicodeStringToMultiByte(pathName, CP_ACP));
+}
+
+bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName)
+{
+ UINT codePage = CP_ACP;
+ return MyMoveFile(UnicodeStringToMultiByte(existFileName, codePage), UnicodeStringToMultiByte(newFileName, codePage));
+}
+#endif
+
+#if ENV_UNIX
+static int convert_to_symlink(const char * name) {
+ FILE *file = fopen(name,"rb");
+ if (file) {
+ char buf[MAX_PATHNAME_LEN+1];
+ char * ret = fgets(buf,sizeof(buf)-1,file);
+ fclose(file);
+ if (ret) {
+ int ir = unlink(name);
+ if (ir == 0) {
+ ir = symlink(buf,name);
+ }
+ return ir;
+ }
+ }
+ return -1;
+}
+#endif
+
+bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes)
+{
+#ifdef ENV_UNIX
+ if (!fileName) {
+ SetLastError(ERROR_PATH_NOT_FOUND);
+ TRACEN((printf("MySetFileAttributes(NULL,%d) : false-1\n",fileAttributes)))
+ return false;
+ }
+#ifdef _UNICODE
+ AString name = nameWindowToUnix2(fileName);
+#else
+ const char * name = nameWindowToUnix(fileName);
+#endif
+ struct stat stat_info;
+#ifdef HAVE_LSTAT
+ if (global_use_lstat) {
+ if(lstat(name,&stat_info)!=0) {
+ TRACEN((printf("MySetFileAttributes(%s,%d) : false-2-1\n",name,fileAttributes)))
+ return false;
+ }
+ } else
+#endif
+ {
+ if(stat(name,&stat_info)!=0) {
+ TRACEN((printf("MySetFileAttributes(%s,%d) : false-2-2\n",name,fileAttributes)))
+ return false;
+ }
+ }
+
+ if (fileAttributes & FILE_ATTRIBUTE_UNIX_EXTENSION) {
+ stat_info.st_mode = fileAttributes >> 16;
+#ifdef HAVE_LSTAT
+ if (S_ISLNK(stat_info.st_mode)) {
+ if ( convert_to_symlink(name) != 0) {
+ TRACEN((printf("MySetFileAttributes(%s,%d) : false-3\n",name,fileAttributes)))
+ return false;
+ }
+ } else
+#endif
+ if (S_ISREG(stat_info.st_mode)) {
+ TRACEN((printf("##DBG chmod-2(%s,%o)\n",name,(unsigned)stat_info.st_mode & gbl_umask.mask)))
+ chmod(name,stat_info.st_mode & gbl_umask.mask);
+ } else if (S_ISDIR(stat_info.st_mode)) {
+ // user/7za must be able to create files in this directory
+ stat_info.st_mode |= (S_IRUSR | S_IWUSR | S_IXUSR);
+ TRACEN((printf("##DBG chmod-3(%s,%o)\n",name,(unsigned)stat_info.st_mode & gbl_umask.mask)))
+ chmod(name,stat_info.st_mode & gbl_umask.mask);
+ }
+#ifdef HAVE_LSTAT
+ } else if (!S_ISLNK(stat_info.st_mode)) {
+ // do not use chmod on a link
+#else
+ } else {
+#endif
+
+ /* Only Windows Attributes */
+ if( S_ISDIR(stat_info.st_mode)) {
+ /* Remark : FILE_ATTRIBUTE_READONLY ignored for directory. */
+ TRACEN((printf("##DBG chmod-4(%s,%o)\n",name,(unsigned)stat_info.st_mode & gbl_umask.mask)))
+ chmod(name,stat_info.st_mode & gbl_umask.mask);
+ } else {
+ if (fileAttributes & FILE_ATTRIBUTE_READONLY) stat_info.st_mode &= ~0222; /* octal!, clear write permission bits */
+ TRACEN((printf("##DBG chmod-5(%s,%o)\n",name,(unsigned)stat_info.st_mode & gbl_umask.mask)))
+ chmod(name,stat_info.st_mode & gbl_umask.mask);
+ }
+ }
+ TRACEN((printf("MySetFileAttributes(%s,%d) : true\n",name,fileAttributes)))
+
+ return true;
+#else
+ if( ::SetFileAttributes( fileName, fileAttributes ) )
+ return true;
+#ifdef WIN_LONG_PATH2
+ UString longPath;
+ if( GetLongPath( fileName, longPath ) )
+ return BOOLToBool( ::SetfileAttributesW( longPath, fileAttributes ) );
+#endif
+ return false;
+#endif
+}
+
+bool MyCreateDirectory(LPCTSTR pathName)
+{
+#ifdef ENV_UNIX
+ if (!pathName || !*pathName) {
+ SetLastError(ERROR_PATH_NOT_FOUND);
+ return false;
+ }
+
+#ifdef _UNICODE
+ AString name = nameWindowToUnix2(pathName);
+#else
+ const char * name = nameWindowToUnix(pathName);
+#endif
+ bool bret = false;
+ if (mkdir( name, 0700 ) == 0) bret = true;
+
+ TRACEN((printf("MyCreateDirectory(%s)=%d\n",name,(int)bret)))
+ return bret;
+#else
+ if( ::CreateDirectory( pathName, NULL ) )
+ return true;
+#ifdef WIN_LONG_PATH2
+ if( ::GetLastError() != ERROR_ALREADY_EXISTS )
+ {
+ UString longPath;
+ if( GetLongPath( pathName, longPath ) )
+ return BOOLToBool( ::CreateDirectoryW( longPath, NULL ) );
+ }
+#endif
+ return false;
+#endif
+}
+
+#ifndef _UNICODE
+bool MyCreateDirectory(LPCWSTR pathName)
+{
+ return MyCreateDirectory(UnicodeStringToMultiByte(pathName, CP_ACP));
+}
+#endif
+
+bool CreateComplexDirectory(LPCTSTR _aPathName)
+{
+ CSysString pathName = _aPathName;
+ int pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
+ if (pos > 0 && pos == pathName.Length() - 1)
+ {
+ if (pathName.Length() == 3 && pathName[1] == ':')
+ return true; // Disk folder;
+ pathName.Delete(pos);
+ }
+ CSysString pathName2 = pathName;
+ pos = pathName.Length();
+ while(true)
+ {
+ if(MyCreateDirectory(pathName))
+ break;
+ if(::GetLastError() == ERROR_ALREADY_EXISTS)
+ {
+#ifdef _WIN32 // FIXED for supporting symbolic link instead of a directory
+ NFind::CFileInfoW fileInfo;
+ if (!NFind::FindFile(pathName, fileInfo)) // For network folders
+ return true;
+ if (!fileInfo.IsDir())
+ return false;
+#endif
+ break;
+ }
+ pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
+ if (pos < 0 || pos == 0)
+ return false;
+ if (pathName[pos - 1] == ':')
+ return false;
+ pathName = pathName.Left(pos);
+ }
+ pathName = pathName2;
+ while(pos < pathName.Length())
+ {
+ pos = pathName.Find(TEXT(CHAR_PATH_SEPARATOR), pos + 1);
+ if (pos < 0)
+ pos = pathName.Length();
+ if(!MyCreateDirectory(pathName.Left(pos)))
+ return false;
+ }
+ return true;
+}
+
+#ifndef _UNICODE
+
+bool CreateComplexDirectory(LPCWSTR _aPathName)
+{
+ UString pathName = _aPathName;
+ int pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos > 0 && pos == pathName.Length() - 1)
+ {
+ if (pathName.Length() == 3 && pathName[1] == L':')
+ return true; // Disk folder;
+ pathName.Delete(pos);
+ }
+ UString pathName2 = pathName;
+ pos = pathName.Length();
+ while(true)
+ {
+ if(MyCreateDirectory(pathName))
+ break;
+ if(::GetLastError() == ERROR_ALREADY_EXISTS)
+ {
+#ifdef _WIN32 // FIXED for supporting symbolic link instead of a directory
+ NFind::CFileInfoW fileInfo;
+ if (!NFind::FindFile(pathName, fileInfo)) // For network folders
+ return true;
+ if (!fileInfo.IsDir())
+ return false;
+#endif
+ break;
+ }
+ pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0 || pos == 0)
+ return false;
+ if (pathName[pos - 1] == L':')
+ return false;
+ pathName = pathName.Left(pos);
+ }
+ pathName = pathName2;
+ while(pos < pathName.Length())
+ {
+ pos = pathName.Find(WCHAR_PATH_SEPARATOR, pos + 1);
+ if (pos < 0)
+ pos = pathName.Length();
+ if(!MyCreateDirectory(pathName.Left(pos)))
+ return false;
+ }
+ return true;
+}
+
+#endif
+
+bool DeleteFileAlways(LPCTSTR name)
+{
+#ifdef ENV_UNIX
+ if (!name || !*name) {
+ SetLastError(ERROR_PATH_NOT_FOUND);
+ return false;
+ }
+#ifdef _UNICODE
+ AString unixname = nameWindowToUnix2(name);
+#else
+ const char * unixname = nameWindowToUnix(name);
+#endif
+ bool bret = false;
+ if (remove(unixname) == 0) bret = true;
+ TRACEN((printf("DeleteFileAlways(%s)=%d\n",unixname,(int)bret)))
+ return bret;
+#else
+ if( !MySetFileAttributes( name, 0 ) )
+ return false;
+ if( ::DeleteFile( name ) )
+ return true;
+#ifdef WIN_LONG_PATH2
+ UString longPath;
+ if( GetLongPath( name, longPath ) )
+ return BOOLToBool( ::DeleteFileW( longPath ) );
+#endif
+ return false;
+#endif
+}
+
+#ifndef _UNICODE
+bool DeleteFileAlways(LPCWSTR name)
+{
+ return DeleteFileAlways(UnicodeStringToMultiByte(name, CP_ACP));
+}
+#endif
+
+#ifndef _WIN32_WCE
+
+bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
+ int &fileNamePartStartIndex)
+{
+ LPTSTR fileNamePointer = 0;
+ LPTSTR buffer = resultPath.GetBuffer(MAX_PATH);
+ DWORD needLength = ::GetFullPathName(fileName, MAX_PATH + 1,
+ buffer, &fileNamePointer);
+ resultPath.ReleaseBuffer();
+ if (needLength == 0 || needLength >= MAX_PATH)
+ return false;
+ if (fileNamePointer == 0)
+ fileNamePartStartIndex = lstrlen(fileName);
+ else
+ fileNamePartStartIndex = fileNamePointer - buffer;
+ return true;
+}
+
+#ifndef _UNICODE
+bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
+ int &fileNamePartStartIndex)
+{
+ const UINT currentPage = CP_ACP;
+ CSysString sysPath;
+ if (!MyGetFullPathName(UnicodeStringToMultiByte(fileName,
+ currentPage), sysPath, fileNamePartStartIndex))
+ return false;
+ UString resultPath1 = MultiByteToUnicodeString(
+ sysPath.Left(fileNamePartStartIndex), currentPage);
+ UString resultPath2 = MultiByteToUnicodeString(
+ sysPath.Mid(fileNamePartStartIndex), currentPage);
+ fileNamePartStartIndex = resultPath1.Length();
+ resultPath = resultPath1 + resultPath2;
+ return true;
+}
+#endif
+
+
+bool MyGetFullPathName(LPCTSTR fileName, CSysString &path)
+{
+ int index;
+ return MyGetFullPathName(fileName, path, index);
+}
+
+#ifndef _UNICODE
+bool MyGetFullPathName(LPCWSTR fileName, UString &path)
+{
+ int index;
+ return MyGetFullPathName(fileName, path, index);
+}
+#endif
+
+#endif
+
+#ifndef ENV_UNIX
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static UString GetUnicodePath(const CSysString &sysPath)
+{ return sysPath; }
+ //{ return MultiByteToUnicodeString(sysPath, GetCurrentCodePage()); }
+
+static CSysString GetSysPath(LPCWSTR sysPath)
+{ return sysPath; }
+ //{ return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
+
+bool MySearchPath( LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
+ CSysString& resultPath, UINT32& filePart )
+{
+ LPTSTR filePartPointer;
+ DWORD value = ::SearchPath( path, fileName, extension, MAX_PATH,
+ resultPath.GetBuffer( MAX_PATH + 1 ), &filePartPointer );
+ filePart = (UINT32)(filePartPointer - (LPCTSTR)resultPath );
+ resultPath.ReleaseBuffer();
+ return (value > 0 && value <= MAX_PATH);
+}
+#endif
+
+/* needed to find .DLL/.so and SFX */
+bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, UString &resultPath)
+{
+#ifdef ENV_UNIX
+ if (path != 0) {
+ printf("NOT EXPECTED : MySearchPath : path != NULL\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (extension != 0) {
+ printf("NOT EXPECTED : MySearchPath : extension != NULL\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (fileName == 0) {
+ printf("NOT EXPECTED : MySearchPath : fileName == NULL\n");
+ exit(EXIT_FAILURE);
+ }
+
+ const char *p7zip_home_dir = getenv("P7ZIP_HOME_DIR");
+ if (p7zip_home_dir) {
+ AString file_path = p7zip_home_dir;
+ file_path += UnicodeStringToMultiByte(fileName, CP_ACP);
+
+ TRACEN((printf("MySearchPath() fopen(%s)\n",(const char *)file_path)))
+ FILE *file = fopen((const char *)file_path,"r");
+ if (file) {
+ // file is found
+ fclose(file);
+ resultPath = MultiByteToUnicodeString(file_path, CP_ACP);
+ return true;
+ }
+ }
+ return false;
+#else
+ CSysString sysPath;
+ UINT32 filePart;
+ if( !MySearchPath(
+ path != 0 ? (LPCTSTR)GetSysPath( path ) : 0,
+ fileName != 0 ? (LPCTSTR)GetSysPath( fileName ) : 0,
+ extension != 0 ? (LPCTSTR)GetSysPath( extension ) : 0,
+ sysPath, filePart ) )
+ return false;
+ UString resultPath1 = GetUnicodePath( sysPath.Left( filePart ) );
+ UString resultPath2 = GetUnicodePath( sysPath.Mid( filePart ) );
+ filePart = resultPath1.Length();
+ resultPath = resultPath1 + resultPath2;
+ return true;
+#endif
+}
+
+#ifndef _UNICODE
+bool MyGetTempPath(CSysString &path)
+{
+ path = "c:/tmp/"; // final '/' is needed
+ return true;
+}
+#endif
+
+bool MyGetTempPath(UString &path)
+{
+ path = L"c:/tmp/"; // final '/' is needed
+ return true;
+}
+
+static NSynchronization::CCriticalSection g_CountCriticalSection;
+
+#ifndef ENV_UNIX
+static UINT MyGetTempFileName( LPCWSTR dirPath, LPCTSTR prefix, CSysString& path )
+{
+ UINT number = ::GetTempFileName( dirPath, prefix, 0, path.GetBuffer( MAX_PATH + 1 ) );
+ path.ReleaseBuffer();
+ return number;
+}
+#endif
+
+UINT CTempFile::Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath)
+{
+ static int memo_count = 0;
+ int count;
+
+ g_CountCriticalSection.Enter();
+ count = memo_count++;
+ g_CountCriticalSection.Leave();
+
+ Remove();
+#ifdef ENV_UNIX
+ UINT number = (UINT)getpid();
+ TCHAR * buf = resultPath.GetBuffer(MAX_PATH);
+#ifdef _UNICODE
+ swprintf(buf,MAX_PATH,L"%s%s#%x@%x.tmp",dirPath,prefix,(unsigned)number,count);
+#else
+ snprintf(buf,MAX_PATH,"%s%s#%x@%x.tmp",dirPath,prefix,(unsigned)number,count);
+#endif
+ buf[MAX_PATH-1]=0;
+ resultPath.ReleaseBuffer();
+
+#else
+ UINT number = MyGetTempFileName(dirPath, prefix, resultPath );
+#endif
+
+
+ _fileName = resultPath;
+ _mustBeDeleted = true;
+
+ return number;
+}
+
+bool CTempFile::Remove()
+{
+ if (!_mustBeDeleted)
+ return true;
+ _mustBeDeleted = !DeleteFileAlways(_fileName);
+ return !_mustBeDeleted;
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileDir.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileDir.h
new file mode 100644
index 000000000..ab27827a5
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileDir.h
@@ -0,0 +1,87 @@
+// Windows/FileDir.h
+
+#ifndef __WINDOWS_FILEDIR_H
+#define __WINDOWS_FILEDIR_H
+
+#include "../Common/MyString.h"
+#include "Defs.h"
+
+/* GetFullPathName for 7zAES.cpp */
+DWORD WINAPI GetFullPathName( LPCSTR name, DWORD len, LPSTR buffer, LPSTR *lastpart );
+
+namespace NWindows {
+namespace NFile {
+namespace NDirectory {
+
+bool SetDirTime(LPCWSTR fileName, const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
+
+bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes);
+#ifndef _UNICODE
+bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes);
+#endif
+
+bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName);
+#ifndef _UNICODE
+bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName);
+#endif
+
+bool MyRemoveDirectory(LPCTSTR pathName);
+#ifndef _UNICODE
+bool MyRemoveDirectory(LPCWSTR pathName);
+#endif
+
+bool MyCreateDirectory(LPCTSTR pathName);
+bool CreateComplexDirectory(LPCTSTR pathName);
+#ifndef _UNICODE
+bool MyCreateDirectory(LPCWSTR pathName);
+bool CreateComplexDirectory(LPCWSTR pathName);
+#endif
+
+bool DeleteFileAlways(LPCTSTR name);
+#ifndef _UNICODE
+bool DeleteFileAlways(LPCWSTR name);
+#endif
+
+#ifndef _WIN32_WCE
+bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
+ int &fileNamePartStartIndex);
+bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath);
+bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
+bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
+#ifndef _UNICODE
+bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
+ int &fileNamePartStartIndex);
+bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath);
+#endif
+
+#endif
+
+bool MySetCurrentDirectory(LPCWSTR path);
+bool MyGetCurrentDirectory(CSysString &resultPath);
+
+bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, UString &resultPath);
+
+bool MyGetTempPath(CSysString &resultPath);
+#ifndef _UNICODE
+bool MyGetTempPath(UString &resultPath);
+#endif
+
+class CTempFile
+{
+ bool _mustBeDeleted;
+ CSysString _fileName;
+public:
+ CTempFile(): _mustBeDeleted(false) {}
+ ~CTempFile() { Remove(); }
+ void DisableDeleting() { _mustBeDeleted = false; }
+ UINT Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
+ bool Remove();
+};
+
+#ifdef _UNICODE
+typedef CTempFile CTempFileW;
+#endif
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileFind.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileFind.cpp
new file mode 100644
index 000000000..3185d5b93
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileFind.cpp
@@ -0,0 +1,657 @@
+// Windows/FileFind.cpp
+
+#include "StdAfx.h"
+
+#include "FileFind.h"
+#include "../Common/StringConvert.h"
+
+#include <sys/stat.h>
+#ifdef ENV_UNIX
+#include <unistd.h>
+#endif
+#include <errno.h>
+
+#ifdef HAVE_LSTAT
+extern "C"
+{
+
+int global_use_lstat=1; // default behaviour : p7zip stores symlinks instead of dumping the files they point to
+}
+#endif
+
+#define NEED_NAME_WINDOWS_TO_UNIX
+#include "myPrivate.h"
+
+// #define TRACEN(u) u;
+#define TRACEN(u) /* */
+
+#ifdef ENV_UNIX
+void my_windows_split_path(const AString &p_path, AString &dir , AString &base) {
+ int pos = p_path.ReverseFind('/');
+ if (pos == -1) {
+ // no separator
+ dir = ".";
+ if (p_path.IsEmpty())
+ base = ".";
+ else
+ base = p_path;
+ } else if ((pos+1) < p_path.Length()) {
+ // true separator
+ base = p_path.Mid(pos+1);
+ while ((pos >= 1) && (p_path[pos-1] == '/'))
+ pos--;
+ if (pos == 0)
+ dir = "/";
+ else
+ dir = p_path.Left(pos);
+ } else {
+ // separator at the end of the path
+ // pos = p_path.find_last_not_of("/");
+ pos = -1;
+ int ind = 0;
+ while (p_path[ind]) {
+ if (p_path[ind] != '/')
+ pos = ind;
+ ind++;
+ }
+ if (pos == -1) {
+ base = "/";
+ dir = "/";
+ } else {
+ my_windows_split_path(p_path.Left(pos+1),dir,base);
+ }
+ }
+}
+
+static void my_windows_split_path(const UString &p_path, UString &dir , UString &base) {
+ int pos = p_path.ReverseFind(L'/');
+ if (pos == -1) {
+ // no separator
+ dir = L".";
+ if (p_path.IsEmpty())
+ base = L".";
+ else
+ base = p_path;
+ } else if ((pos+1) < p_path.Length()) {
+ // true separator
+ base = p_path.Mid(pos+1);
+ while ((pos >= 1) && (p_path[pos-1] == L'/'))
+ pos--;
+ if (pos == 0)
+ dir = L"/";
+ else
+ dir = p_path.Left(pos);
+ } else {
+ // separator at the end of the path
+ // pos = p_path.find_last_not_of("/");
+ pos = -1;
+ int ind = 0;
+ while (p_path[ind]) {
+ if (p_path[ind] != L'/')
+ pos = ind;
+ ind++;
+ }
+ if (pos == -1) {
+ base = L"/";
+ dir = L"/";
+ } else {
+ my_windows_split_path(p_path.Left(pos+1),dir,base);
+ }
+ }
+}
+
+static int filter_pattern(const char *string , const char *pattern , int flags_nocase) {
+ if ((string == 0) || (*string==0)) {
+ if (pattern == 0)
+ return 1;
+ while (*pattern=='*')
+ ++pattern;
+ return (!*pattern);
+ }
+
+ switch (*pattern) {
+ case '*':
+ if (!filter_pattern(string+1,pattern,flags_nocase))
+ return filter_pattern(string,pattern+1,flags_nocase);
+ return 1;
+ case 0:
+ if (*string==0)
+ return 1;
+ break;
+ case '?':
+ return filter_pattern(string+1,pattern+1,flags_nocase);
+ default:
+ if ( ((flags_nocase) && (tolower(*pattern)==tolower(*string)))
+ || (*pattern == *string)
+ ) {
+ return filter_pattern(string+1,pattern+1,flags_nocase);
+ }
+ break;
+ }
+ return 0;
+}
+#endif
+
+namespace NWindows {
+namespace NFile {
+namespace NFind {
+
+static const TCHAR kDot = TEXT('.');
+
+bool CFileInfo::IsDots() const
+{
+ if (!IsDir() || Name.IsEmpty())
+ return false;
+ if (Name[0] != kDot)
+ return false;
+ return Name.Length() == 1 || (Name[1] == kDot && Name.Length() == 2);
+}
+
+bool CFileInfoW::IsDots() const
+{
+ if (!IsDir() || Name.IsEmpty())
+ return false;
+ if (Name[0] != kDot)
+ return false;
+ return Name.Length() == 1 || (Name[1] == kDot && Name.Length() == 2);
+}
+
+static bool originalFilename(const UString & src, AString & res)
+{
+ // Try to recover the original filename
+ res = "";
+ int i=0;
+ while (src[i])
+ {
+ if (src[i] >= 256) {
+ return false;
+ } else {
+ res += char(src[i]);
+ }
+ i++;
+ }
+ return true;
+}
+
+
+#ifdef ENV_UNIX
+// Warning this function cannot update "fileInfo.Name"
+static int fillin_CFileInfo(CFileInfo &fileInfo,const char *filename) {
+ struct stat stat_info;
+
+ int ret;
+#ifdef HAVE_LSTAT
+ if (global_use_lstat) {
+ ret = lstat(filename,&stat_info);
+ } else
+#endif
+ {
+ ret = stat(filename,&stat_info);
+ }
+
+ if (ret != 0) return ret;
+
+ /* FIXME : FILE_ATTRIBUTE_HIDDEN ? */
+ if (S_ISDIR(stat_info.st_mode)) {
+ fileInfo.Attrib = FILE_ATTRIBUTE_DIRECTORY;
+ } else {
+ fileInfo.Attrib = FILE_ATTRIBUTE_ARCHIVE;
+ }
+
+ if (!(stat_info.st_mode & S_IWUSR))
+ fileInfo.Attrib |= FILE_ATTRIBUTE_READONLY;
+
+ fileInfo.Attrib |= FILE_ATTRIBUTE_UNIX_EXTENSION + ((stat_info.st_mode & 0xFFFF) << 16);
+
+ RtlSecondsSince1970ToFileTime( stat_info.st_ctime, &fileInfo.CTime );
+ RtlSecondsSince1970ToFileTime( stat_info.st_mtime, &fileInfo.MTime );
+ RtlSecondsSince1970ToFileTime( stat_info.st_atime, &fileInfo.ATime );
+
+ fileInfo.IsDevice = false;
+
+ if (S_ISDIR(stat_info.st_mode)) {
+ fileInfo.Size = 0;
+ } else { // file or symbolic link
+ fileInfo.Size = stat_info.st_size; // for a symbolic link, size = size of filename
+ }
+ return 0;
+}
+
+static int fillin_CFileInfo(CFileInfo &fileInfo,const char *dir,const char *name) {
+ /*struct stat stat_info;*/
+ char filename[MAX_PATHNAME_LEN];
+
+ size_t dir_len = strlen(dir);
+ size_t name_len = strlen(name);
+ size_t total = dir_len + 1 + name_len; // 1 = strlen("/");
+ if (total >= MAX_PATHNAME_LEN) throw "fillin_CFileInfo - internal error - MAX_PATHNAME_LEN";
+ memcpy(filename,dir,dir_len);
+ if (dir_len >= 1)
+ {
+ if (filename[dir_len-1] == CHAR_PATH_SEPARATOR)
+ { // delete the '/'
+ dir_len--;
+ }
+ }
+ filename[dir_len] = CHAR_PATH_SEPARATOR;
+ memcpy(filename+(dir_len+1),name,name_len+1); // copy also final '\0'
+
+ fileInfo.Name = name;
+
+ int ret = fillin_CFileInfo(fileInfo,filename);
+ if (ret != 0) {
+ AString err_msg = "stat error for ";
+ err_msg += filename;
+ err_msg += " (";
+ err_msg += strerror(errno);
+ err_msg += ")";
+ throw err_msg;
+ }
+ return ret;
+}
+#endif
+
+////////////////////////////////
+// CFindFile
+
+bool CFindFile::Close()
+{
+#ifdef ENV_UNIX
+ if(_dirp == 0)
+ return true;
+ int ret = closedir(_dirp);
+ if (ret == 0)
+ {
+ _dirp = 0;
+ return true;
+ }
+ return false;
+#else
+ if( _handle == INVALID_HANDLE_VALUE )
+ return true;
+ if( !::FindClose( _handle ) )
+ return false;
+ _handle = INVALID_HANDLE_VALUE;
+ return true;
+#endif
+}
+
+#ifndef ENV_UNIX
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+
+static void ConvertWIN32_FIND_DATA_To_FileInfo(const WIN32_FIND_DATAA &fd, CFileInfo &fi)
+{
+ fi.Attrib = fd.dwFileAttributes;
+ fi.CTime = fd.ftCreationTime;
+ fi.ATime = fd.ftLastAccessTime;
+ fi.MTime = fd.ftLastWriteTime;
+ fi.Size = (((UInt64)fd.nFileSizeHigh) << 32) + fd.nFileSizeLow;
+ fi.Name = (char*)fd.cFileName;
+ #ifndef _WIN32_WCE
+ fi.ReparseTag = fd.dwReserved0;
+ #else
+ fi.ObjectID = fd.dwOID;
+ #endif
+}
+#endif
+
+
+// bool CFindFile::FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo)
+bool CFindFile::FindFirst(LPCSTR wildcard, CFileInfo &fileInfo)
+{
+ if (!Close())
+ return false;
+
+#ifdef ENV_UNIX
+ if ((!wildcard) || (wildcard[0]==0)) {
+ SetLastError(ERROR_PATH_NOT_FOUND);
+ return false;
+ }
+
+ my_windows_split_path(nameWindowToUnix(wildcard),_directory,_pattern);
+
+ TRACEN((printf("CFindFile::FindFirst : %s (dirname=%s,pattern=%s)\n",wildcard,(const char *)_directory,(const char *)_pattern)))
+
+ _dirp = ::opendir((const char *)_directory);
+ TRACEN((printf("CFindFile::FindFirst : opendir=%p\n",_dirp)))
+
+ if ((_dirp == 0) && (global_use_utf16_conversion)) {
+ // Try to recover the original filename
+ UString ustr = MultiByteToUnicodeString(_directory, 0);
+ AString resultString;
+ bool is_good = originalFilename(ustr, resultString);
+ if (is_good) {
+ _dirp = ::opendir((const char *)resultString);
+ _directory = resultString;
+ }
+ }
+
+ if (_dirp == 0) return false;
+
+ struct dirent *dp;
+ while ((dp = readdir(_dirp)) != NULL) {
+ if (filter_pattern(dp->d_name,(const char *)_pattern,0) == 1) {
+ int retf = fillin_CFileInfo(fileInfo,(const char *)_directory,dp->d_name);
+ if (retf)
+ {
+ TRACEN((printf("CFindFile::FindFirst : closedir-1(dirp=%p)\n",_dirp)))
+ closedir(_dirp);
+ _dirp = 0;
+ SetLastError( ERROR_NO_MORE_FILES );
+ return false;
+ }
+ TRACEN((printf("CFindFile::FindFirst -%s- true\n",dp->d_name)))
+ return true;
+ }
+ }
+
+ TRACEN((printf("CFindFile::FindFirst : closedir-2(dirp=%p)\n",_dirp)))
+ closedir(_dirp);
+ _dirp = 0;
+ SetLastError( ERROR_NO_MORE_FILES );
+ return false;
+#else
+ WIN32_FIND_DATAA fd;
+ _handle = ::FindFirstFileA(wildcard, &fd);
+ #ifdef WIN_LONG_PATH2
+ if (_handle == INVALID_HANDLE_VALUE)
+ {
+ UString longPath;
+ if (GetLongPath(wildcard, longPath))
+ _handle = ::FindFirstFileW(longPath, &fd);
+ }
+ #endif
+ if (_handle == INVALID_HANDLE_VALUE)
+ return false;
+ ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
+ return true;
+#endif
+}
+
+bool CFindFile::FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo)
+{
+ if (!Close())
+ return false;
+ CFileInfo fileInfo0;
+ AString Awildcard = UnicodeStringToMultiByte(wildcard, CP_ACP);
+ bool bret = FindFirst((LPCSTR)Awildcard, fileInfo0);
+ if (bret)
+ {
+ fileInfo.Attrib = fileInfo0.Attrib;
+ fileInfo.CTime = fileInfo0.CTime;
+ fileInfo.ATime = fileInfo0.ATime;
+ fileInfo.MTime = fileInfo0.MTime;
+ fileInfo.Size = fileInfo0.Size;
+ fileInfo.IsDevice = fileInfo0.IsDevice;
+ fileInfo.Name = GetUnicodeString(fileInfo0.Name, CP_ACP);
+ }
+ return bret;
+}
+
+bool CFindFile::FindNext(CFileInfo &fileInfo)
+{
+#ifdef ENV_UNIX
+ if (_dirp == 0)
+ {
+ SetLastError( ERROR_INVALID_HANDLE );
+ return false;
+ }
+
+ struct dirent *dp;
+ while ((dp = readdir(_dirp)) != NULL) {
+ if (filter_pattern(dp->d_name,(const char *)_pattern,0) == 1) {
+ int retf = fillin_CFileInfo(fileInfo,(const char *)_directory,dp->d_name);
+ if (retf)
+ {
+ TRACEN((printf("FindNextFileA -%s- ret_handle=FALSE (errno=%d)\n",dp->d_name,errno)))
+ return false;
+
+ }
+ TRACEN((printf("FindNextFileA -%s- true\n",dp->d_name)))
+ return true;
+ }
+ }
+ TRACEN((printf("FindNextFileA ret_handle=FALSE (ERROR_NO_MORE_FILES)\n")))
+ SetLastError( ERROR_NO_MORE_FILES );
+ return false;
+#else
+ WIN32_FIND_DATAA fd;
+ bool result = BOOLToBool(::FindNextFileA(_handle, &fd));
+ if (result)
+ ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
+ return result;
+#endif
+}
+
+bool CFindFile::FindNext(CFileInfoW &fileInfo)
+{
+ CFileInfo fileInfo0;
+ bool bret = FindNext(fileInfo0);
+ if (bret)
+ {
+ fileInfo.Attrib = fileInfo0.Attrib;
+ fileInfo.CTime = fileInfo0.CTime;
+ fileInfo.ATime = fileInfo0.ATime;
+ fileInfo.MTime = fileInfo0.MTime;
+ fileInfo.Size = fileInfo0.Size;
+ fileInfo.IsDevice = fileInfo0.IsDevice;
+ fileInfo.Name = GetUnicodeString(fileInfo0.Name, CP_ACP);
+ }
+ return bret;
+}
+
+bool CFileInfo::Find(LPCSTR wildcard)
+{
+ #ifdef SUPPORT_DEVICE_FILE
+ if (IsDeviceName(wildcard))
+ {
+ Clear();
+ IsDevice = true;
+ NIO::CInFile inFile;
+ if (!inFile.Open(wildcard))
+ return false;
+ Name = wildcard + 4;
+ if (inFile.LengthDefined)
+ Size = inFile.Length;
+ return true;
+ }
+ #endif
+ CFindFile finder;
+ return finder.FindFirst(wildcard, *this);
+}
+
+
+// #ifndef _UNICODE
+bool CFileInfoW::Find(LPCWSTR wildcard)
+{
+ #ifdef SUPPORT_DEVICE_FILE
+ if (IsDeviceName(wildcard))
+ {
+ Clear();
+ IsDevice = true;
+ NIO::CInFile inFile;
+ if (!inFile.Open(wildcard))
+ return false;
+ Name = wildcard + 4;
+ if (inFile.LengthDefined)
+ Size = inFile.Length;
+ return true;
+ }
+ #endif
+ CFindFile finder;
+ return finder.FindFirst(wildcard, *this);
+}
+// #endif
+
+bool FindFile(LPCSTR wildcard, CFileInfo &fileInfo)
+{
+#ifndef ENV_UNIX
+ CFindFile finder;
+ return finder.FindFirst(wildcard, fileInfo);
+#else
+ AString dir,base;
+ my_windows_split_path(wildcard, dir , base);
+ int ret = fillin_CFileInfo(fileInfo,nameWindowToUnix(wildcard));
+ fileInfo.Name = base;
+ TRACEN((printf("FindFile(%s,CFileInfo) ret=%d\n",wildcard,ret)))
+ return (ret == 0);
+#endif
+}
+
+bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo)
+{
+#ifndef ENV_UNIX
+ CFindFile finder;
+ return finder.FindFirst(wildcard, fileInfo);
+#else
+ AString name = UnicodeStringToMultiByte(wildcard, CP_ACP);
+ CFileInfo fileInfo0;
+ int ret = fillin_CFileInfo(fileInfo0,nameWindowToUnix((const char *)name));
+ TRACEN((printf("FindFile-1(%s,CFileInfo) ret=%d\n",(const char *)name,ret)))
+ if (ret != 0)
+ {
+ // Try to recover the original filename
+ AString resultString;
+ bool is_good = originalFilename(wildcard, resultString);
+ if (is_good) {
+ ret = fillin_CFileInfo(fileInfo0,nameWindowToUnix((const char *)resultString));
+ TRACEN((printf("FindFile-2(%s,CFileInfo) ret=%d\n",(const char *)resultString,ret)))
+ }
+ }
+ if (ret == 0)
+ {
+ UString dir,base;
+ my_windows_split_path(wildcard, dir , base);
+ fileInfo.Attrib = fileInfo0.Attrib;
+ fileInfo.CTime = fileInfo0.CTime;
+ fileInfo.ATime = fileInfo0.ATime;
+ fileInfo.MTime = fileInfo0.MTime;
+ fileInfo.Size = fileInfo0.Size;
+ fileInfo.Name = base;
+ }
+ return (ret == 0);
+#endif
+}
+
+bool DoesFileExist(LPCSTR name) // FIXME
+{
+#ifdef ENV_UNIX
+ CFileInfo fi;
+ int ret = fillin_CFileInfo(fi,nameWindowToUnix(name));
+ TRACEN((printf("DoesFileExist(%s) ret=%d\n",name,ret)))
+ return (ret == 0) && !fi.IsDir();;
+#else
+ CFileInfo fileInfo;
+ bool exists = FindFile(name, fileInfo);
+ return exists && !fileInfo.IsDir();
+#endif
+}
+
+bool DoesFileOrDirExist(LPCSTR name)
+{
+#ifdef ENV_UNIX
+ CFileInfo fileInfo;
+ int ret = fillin_CFileInfo(fileInfo,nameWindowToUnix(name));
+ TRACEN((printf("DoesFileOrDirExist(%s) ret=%d\n",name,ret)))
+ return (ret == 0);
+#else
+ CFileInfo fileInfo;
+ return FindFile(name, fileInfo);
+#endif
+}
+
+bool DoesFileExist(LPCWSTR name)
+{
+ AString Aname = UnicodeStringToMultiByte(name, CP_ACP);
+ bool bret = DoesFileExist((LPCSTR)Aname);
+ if (bret) return bret;
+
+ // Try to recover the original filename
+ AString resultString;
+ bool is_good = originalFilename(name, resultString);
+ if (is_good) {
+ bret = DoesFileExist((const char *)resultString);
+ }
+ return bret;
+}
+
+bool DoesFileOrDirExist(LPCWSTR name)
+{
+ AString Aname = UnicodeStringToMultiByte(name, CP_ACP);
+ bool bret = DoesFileOrDirExist((LPCSTR)Aname);
+ if (bret) return bret;
+
+ // Try to recover the original filename
+ AString resultString;
+ bool is_good = originalFilename(name, resultString);
+ if (is_good) {
+ bret = DoesFileOrDirExist((const char *)resultString);
+ }
+ return bret;
+}
+
+/////////////////////////////////////
+// CEnumerator
+
+bool CEnumerator::NextAny(CFileInfo &fileInfo)
+{
+ if(_findFile.IsHandleAllocated())
+ return _findFile.FindNext(fileInfo);
+ else
+ return _findFile.FindFirst(_wildcard, fileInfo);
+}
+
+bool CEnumerator::Next(CFileInfo &fileInfo)
+{
+ while(true)
+ {
+ if(!NextAny(fileInfo))
+ return false;
+ if(!fileInfo.IsDots())
+ return true;
+ }
+}
+
+bool CEnumerator::Next(CFileInfo &fileInfo, bool &found)
+{
+ if (Next(fileInfo))
+ {
+ found = true;
+ return true;
+ }
+ found = false;
+ return (::GetLastError() == ERROR_NO_MORE_FILES);
+}
+
+bool CEnumeratorW::NextAny(CFileInfoW &fileInfo)
+{
+ if(_findFile.IsHandleAllocated())
+ return _findFile.FindNext(fileInfo);
+ else
+ return _findFile.FindFirst(_wildcard, fileInfo);
+}
+
+bool CEnumeratorW::Next(CFileInfoW &fileInfo)
+{
+ while(true)
+ {
+ if(!NextAny(fileInfo))
+ return false;
+ if(!fileInfo.IsDots())
+ return true;
+ }
+}
+
+bool CEnumeratorW::Next(CFileInfoW &fileInfo, bool &found)
+{
+ if (Next(fileInfo))
+ {
+ found = true;
+ return true;
+ }
+ found = false;
+ return (::GetLastError() == ERROR_NO_MORE_FILES);
+}
+
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileFind.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileFind.h
new file mode 100644
index 000000000..5b7298e23
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileFind.h
@@ -0,0 +1,147 @@
+// Windows/FileFind.h
+
+#ifndef __WINDOWS_FILEFIND_H
+#define __WINDOWS_FILEFIND_H
+
+#include "../Common/MyString.h"
+#include "FileName.h"
+#include "Defs.h"
+#include "../Common/MyWindows.h"
+
+#include <sys/types.h> /* for DIR */
+#ifdef ENV_UNIX
+#include <dirent.h>
+#else
+typedef void DIR;
+typedef unsigned long long UInt64;
+#endif
+
+namespace NWindows {
+namespace NFile {
+namespace NFind {
+
+namespace NAttributes
+{
+ inline bool IsReadOnly(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_READONLY) != 0; }
+ inline bool IsHidden(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_HIDDEN) != 0; }
+ inline bool IsSystem(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_SYSTEM) != 0; }
+ inline bool IsDir(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0; }
+ inline bool IsArchived(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_ARCHIVE) != 0; }
+ inline bool IsCompressed(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_COMPRESSED) != 0; }
+ inline bool IsEncrypted(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_ENCRYPTED) != 0; }
+}
+
+class CFileInfoBase
+{
+ bool MatchesMask(UINT32 mask) const { return ((Attrib & mask) != 0); }
+public:
+ UInt64 Size;
+ FILETIME CTime;
+ FILETIME ATime;
+ FILETIME MTime;
+ DWORD Attrib;
+ bool IsDevice;
+
+#ifndef ENV_UNIX
+#ifndef _WIN32_WCE
+ UINT32 ReparseTag;
+#else
+ DWORD ObjectID;
+#endif
+#endif
+
+ bool IsDir() const { return MatchesMask(FILE_ATTRIBUTE_DIRECTORY); }
+};
+
+class CFileInfo: public CFileInfoBase
+{
+public:
+ AString Name; // FIXME CSysString Name;
+ bool IsDots() const;
+ bool Find(LPCSTR wildcard);
+};
+
+// FIXME #ifdef _UNICODE
+// typedef CFileInfo CFileInfoW;
+// #else
+class CFileInfoW: public CFileInfoBase
+{
+public:
+ UString Name;
+ bool IsDots() const;
+ bool Find(LPCWSTR wildcard);
+};
+// #endif
+
+class CFindFile
+{
+ friend class CEnumerator;
+#ifdef ENV_UNIX
+ DIR *_dirp;
+#else
+ HANDLE _handle;
+#endif
+ AString _pattern;
+ AString _directory;
+public:
+#ifdef ENV_UNIX
+ CFindFile(): _dirp(0) {}
+ bool IsHandleAllocated() const { return (_dirp != 0); }
+#else
+ CFindFile(): _handle( INVALID_HANDLE_VALUE ) {}
+ bool IsHandleAllocated() const { return (_handle != INVALID_HANDLE_VALUE ); }
+#endif
+ ~CFindFile() { Close(); }
+ // bool FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo);
+ bool FindFirst(LPCSTR wildcard, CFileInfo &fileInfo);
+ bool FindNext(CFileInfo &fileInfo);
+ // FIXME #ifndef _UNICODE
+ bool FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo);
+ bool FindNext(CFileInfoW &fileInfo);
+ // FIXME #endif
+ bool Close();
+};
+
+bool FindFile(LPCSTR wildcard, CFileInfo &fileInfo);
+
+bool DoesFileExist(LPCSTR name);
+bool DoesFileOrDirExist(LPCSTR name);
+// #ifndef _UNICODE
+bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo);
+bool DoesFileExist(LPCWSTR name);
+bool DoesFileOrDirExist(LPCWSTR name);
+// #endif
+
+class CEnumerator
+{
+ CFindFile _findFile;
+ AString _wildcard; // FIXME CSysString _wildcard;
+ bool NextAny(CFileInfo &fileInfo);
+public:
+ CEnumerator(): _wildcard(NName::kAnyStringWildcard) {}
+ // FIXME CEnumerator(const CSysString &wildcard): _wildcard(wildcard) {}
+ CEnumerator(const AString &wildcard): _wildcard(wildcard) {}
+ bool Next(CFileInfo &fileInfo);
+ bool Next(CFileInfo &fileInfo, bool &found);
+};
+
+// FIXME #ifdef _UNICODE
+// typedef CEnumerator CEnumeratorW;
+// #else
+class CEnumeratorW
+{
+ CFindFile _findFile;
+ UString _wildcard;
+ bool NextAny(CFileInfoW &fileInfo);
+public:
+ CEnumeratorW(): _wildcard(NName::kAnyStringWildcard) {}
+ CEnumeratorW(const UString &wildcard): _wildcard(wildcard) {}
+ bool Next(CFileInfoW &fileInfo);
+ bool Next(CFileInfoW &fileInfo, bool &found);
+};
+// FIXME #endif
+
+}}}
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileIO.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileIO.cpp
new file mode 100644
index 000000000..5f2516cf6
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileIO.cpp
@@ -0,0 +1,578 @@
+// Windows/FileIO.cpp
+
+#include "StdAfx.h"
+
+#include "FileIO.h"
+#include "Defs.h"
+#include "../Common/StringConvert.h"
+
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef ENV_UNIX
+#include <unistd.h>
+#include <utime.h>
+#endif
+#include <fcntl.h>
+
+#define NEED_NAME_WINDOWS_TO_UNIX
+#include "myPrivate.h"
+
+#include <sys/types.h>
+
+#ifdef HAVE_LSTAT
+#define FD_LINK (-2)
+#endif
+
+#ifdef ENV_UNIX
+#define FILE_SHARE_READ 1
+#define GENERIC_READ 0x80000000
+#define GENERIC_WRITE 0x40000000
+
+extern BOOLEAN WINAPI RtlTimeToSecondsSince1970( const LARGE_INTEGER *Time, DWORD *Seconds );
+#endif
+
+namespace NWindows {
+namespace NFile {
+namespace NIO {
+
+CFileBase::~CFileBase()
+{
+ Close();
+}
+
+bool CFileBase::Create(LPCSTR filename, DWORD dwDesiredAccess,
+ DWORD dwShareMode, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,bool ignoreSymbolicLink)
+{
+#ifdef ENV_UNIX
+ (void)dwShareMode;
+ (void)dwFlagsAndAttributes;
+
+ Close();
+
+ const char * name = nameWindowToUnix(filename);
+
+#ifdef O_BINARY
+ int flags = O_BINARY;
+#else
+ int flags = 0;
+#endif
+
+#ifdef O_LARGEFILE
+ flags |= O_LARGEFILE;
+#endif
+
+ /* now use the umask value */
+ int mask = umask(0);
+ (void)umask(mask);
+ int mode = 0666 & ~(mask & 066); /* keep the R/W for the user */
+
+ if (dwDesiredAccess & GENERIC_WRITE) flags |= O_WRONLY;
+ if (dwDesiredAccess & GENERIC_READ) flags |= O_RDONLY;
+
+
+ switch (dwCreationDisposition)
+ {
+ case CREATE_NEW : flags |= O_CREAT | O_EXCL; break;
+ case CREATE_ALWAYS : flags |= O_CREAT; break;
+ case OPEN_EXISTING : break;
+ case OPEN_ALWAYS : flags |= O_CREAT; break;
+ // case TRUNCATE_EXISTING : flags |= O_TRUNC; break;
+ }
+ // printf("##DBG open(%s,0x%x,%o)##\n",name,flags,(unsigned)mode);
+
+ _fd = -1;
+#ifdef HAVE_LSTAT
+ if ((global_use_lstat) && (ignoreSymbolicLink == false))
+ {
+ _size = readlink(name, _buffer, sizeof(_buffer)-1);
+ if (_size > 0) {
+ if (dwDesiredAccess & GENERIC_READ) {
+ _fd = FD_LINK;
+ _offset = 0;
+ _buffer[_size]=0;
+ } else if (dwDesiredAccess & GENERIC_WRITE) {
+ // does not overwrite the file pointed by symbolic link
+ if (!unlink(name)) return false;
+ }
+ }
+ }
+#endif
+
+ if (_fd == -1) {
+ _fd = open(name,flags, mode);
+ }
+
+ if ((_fd == -1) && (global_use_utf16_conversion)) {
+ // bug #1204993 - Try to recover the original filename
+ UString ustr = MultiByteToUnicodeString(AString(name), 0);
+ AString resultString;
+ int is_good = 1;
+ for (int i = 0; i < ustr.Length(); i++)
+ {
+ if (ustr[i] >= 256) {
+ is_good = 0;
+ break;
+ } else {
+ resultString += char(ustr[i]);
+ }
+ }
+ if (is_good) {
+ _fd = open((const char *)resultString,flags, mode);
+ }
+ }
+
+ if (_fd == -1) {
+ /* !HAVE_LSTAT : an invalid symbolic link => errno == ENOENT */
+ return false;
+ } else {
+ _unix_filename = name;
+ }
+
+ return true;
+#else
+ if (!Close())
+ return false;
+ _handle = ::CreateFileA(filename, dwDesiredAccess, dwShareMode,
+ (LPSECURITY_ATTRIBUTES)NULL, dwCreationDisposition,
+ dwFlagsAndAttributes, (HANDLE)NULL);
+ #ifdef WIN_LONG_PATH2
+ if (_handle == INVALID_HANDLE_VALUE)
+ {
+ UString longPath;
+ if (GetLongPath(fileName, longPath))
+ _handle = ::CreateFileW(longPath, desiredAccess, shareMode,
+ (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
+ flagsAndAttributes, (HANDLE)NULL);
+ }
+ #endif
+ return (_handle != INVALID_HANDLE_VALUE);
+#endif
+}
+
+bool CFileBase::Create(LPCWSTR fileName, DWORD desiredAccess,
+ DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes,bool ignoreSymbolicLink)
+{
+ Close();
+ return Create(UnicodeStringToMultiByte(fileName, CP_ACP),
+ desiredAccess, shareMode, creationDisposition, flagsAndAttributes,ignoreSymbolicLink);
+}
+
+bool CFileBase::Close()
+{
+#ifdef ENV_UNIX
+ struct utimbuf buf;
+
+ buf.actime = _lastAccessTime;
+ buf.modtime = _lastWriteTime;
+
+ _lastAccessTime = _lastWriteTime = (time_t)-1;
+
+ if(_fd == -1)
+ return true;
+
+#ifdef HAVE_LSTAT
+ if(_fd == FD_LINK) {
+ _fd = -1;
+ return true;
+ }
+#endif
+
+ int ret = ::close(_fd);
+ if (ret == 0) {
+ _fd = -1;
+
+ /* On some OS (mingwin, MacOSX ...), you must close the file before updating times */
+ if ((buf.actime != (time_t)-1) || (buf.modtime != (time_t)-1)) {
+ struct stat oldbuf;
+ int ret = stat((const char*)(_unix_filename),&oldbuf);
+ if (ret == 0) {
+ if (buf.actime == (time_t)-1) buf.actime = oldbuf.st_atime;
+ if (buf.modtime == (time_t)-1) buf.modtime = oldbuf.st_mtime;
+ } else {
+ time_t current_time = time(0);
+ if (buf.actime == (time_t)-1) buf.actime = current_time;
+ if (buf.modtime == (time_t)-1) buf.modtime = current_time;
+ }
+ /* ret = */ utime((const char *)(_unix_filename), &buf);
+ }
+ return true;
+ }
+ return false;
+#else
+ if (_handle == INVALID_HANDLE_VALUE)
+ return true;
+ if (!::CloseHandle(_handle))
+ return false;
+ _handle = INVALID_HANDLE_VALUE;
+ return true;
+#endif
+}
+
+bool CFileBase::GetLength(UINT64 &length) const
+{
+#ifdef ENV_UNIX
+ if (_fd == -1)
+ {
+ SetLastError( ERROR_INVALID_HANDLE );
+ return false;
+ }
+
+#ifdef HAVE_LSTAT
+ if (_fd == FD_LINK) {
+ length = _size;
+ return true;
+ }
+#endif
+
+ off_t pos_cur = ::lseek(_fd, 0, SEEK_CUR);
+ if (pos_cur == (off_t)-1)
+ return false;
+
+ off_t pos_end = ::lseek(_fd, 0, SEEK_END);
+ if (pos_end == (off_t)-1)
+ return false;
+
+ off_t pos_cur2 = ::lseek(_fd, pos_cur, SEEK_SET);
+ if (pos_cur2 == (off_t)-1)
+ return false;
+
+ length = (UINT64)pos_end;
+
+ return true;
+#else
+ DWORD sizeHigh;
+ DWORD sizeLow = ::GetFileSize(_handle, &sizeHigh);
+ if (sizeLow == 0xFFFFFFFF)
+ if (::GetLastError() != NO_ERROR)
+ return false;
+ length = (((UInt64)sizeHigh) << 32) + sizeLow;
+ return true;
+#endif
+}
+
+bool CFileBase::Seek(INT64 distanceToMove, DWORD moveMethod, UINT64 &newPosition)
+{
+#ifdef ENV_UNIX
+ if (_fd == -1)
+ {
+ SetLastError( ERROR_INVALID_HANDLE );
+ return false;
+ }
+
+#ifdef HAVE_LSTAT
+ if (_fd == FD_LINK) {
+ INT64 offset;
+ switch (moveMethod) {
+ case STREAM_SEEK_SET : offset = distanceToMove; break;
+ case STREAM_SEEK_CUR : offset = _offset + distanceToMove; break;
+ case STREAM_SEEK_END : offset = _size + distanceToMove; break;
+ default : offset = -1;
+ }
+ if (offset < 0) {
+ SetLastError( EINVAL );
+ return false;
+ }
+ if (offset > _size) offset = _size;
+ newPosition = _offset = offset;
+ return true;
+ }
+#endif
+
+ bool ret = true;
+
+ off_t pos = (off_t)distanceToMove;
+
+ off_t newpos = ::lseek(_fd,pos,moveMethod);
+
+ if (newpos == ((off_t)-1)) {
+ ret = false;
+ } else {
+ newPosition = (UINT64)newpos;
+ }
+
+ return ret;
+#else
+ LARGE_INTEGER value;
+ value.QuadPart = distanceToMove;
+ value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod);
+ if (value.LowPart == 0xFFFFFFFF)
+ if (::GetLastError() != NO_ERROR)
+ return false;
+ newPosition = value.QuadPart;
+ return true;
+#endif
+}
+
+bool CFileBase::Seek(UINT64 position, UINT64 &newPosition)
+{
+ return Seek(position, FILE_BEGIN, newPosition);
+}
+
+/////////////////////////
+// CInFile
+
+bool CInFile::Open(LPCTSTR fileName, DWORD shareMode,
+ DWORD creationDisposition, DWORD flagsAndAttributes)
+{
+ return Create(fileName, GENERIC_READ, shareMode,
+ creationDisposition, flagsAndAttributes);
+}
+
+bool CInFile::Open(LPCTSTR fileName,bool ignoreSymbolicLink)
+{
+ return Create(fileName, GENERIC_READ , FILE_SHARE_READ, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,ignoreSymbolicLink);
+}
+
+#ifndef _UNICODE
+bool CInFile::Open(LPCWSTR fileName, DWORD shareMode,
+ DWORD creationDisposition, DWORD flagsAndAttributes)
+{
+ return Create(fileName, GENERIC_READ, shareMode,
+ creationDisposition, flagsAndAttributes);
+}
+
+bool CInFile::Open(LPCWSTR fileName,bool ignoreSymbolicLink)
+{
+ return Create(fileName, GENERIC_READ , FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,ignoreSymbolicLink);
+}
+#endif
+
+// ReadFile and WriteFile functions in Windows have BUG:
+// If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
+// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
+// (Insufficient system resources exist to complete the requested service).
+
+// static UINT32 kChunkSizeMax = (1 << 24);
+
+bool CInFile::ReadPart(void *data, UINT32 size, UINT32 &processedSize)
+{
+ // if (size > kChunkSizeMax)
+ // size = kChunkSizeMax;
+ return Read(data,size,processedSize);
+}
+
+bool CInFile::Read(void *buffer, UINT32 bytesToRead, UINT32 &bytesRead)
+{
+#ifdef ENV_UNIX
+ if (_fd == -1)
+ {
+ SetLastError( ERROR_INVALID_HANDLE );
+ return false;
+ }
+
+ if (bytesToRead == 0) {
+ bytesRead =0;
+ return TRUE;
+ }
+
+#ifdef HAVE_LSTAT
+ if (_fd == FD_LINK) {
+ if (_offset >= _size) {
+ bytesRead = 0;
+ return TRUE;
+ }
+ unsigned int len = (_size - _offset);
+ if (len > bytesToRead) len = bytesToRead;
+ memcpy(buffer,_buffer+_offset,len);
+ bytesRead = len;
+ _offset += len;
+ return TRUE;
+ }
+#endif
+
+ ssize_t ret;
+ do {
+ ret = read(_fd,buffer,bytesToRead);
+ } while (ret < 0 && (errno == EINTR));
+
+ if (ret != -1) {
+ bytesRead = ret;
+ return TRUE;
+ }
+ bytesRead =0;
+ return FALSE;
+#else
+ bytesRead = 0;
+ do
+ {
+ DWORD processedLoc = 0;
+ bool res = ::ReadFile( _handle, buffer, bytesToRead, &processedLoc, 0 );
+ bytesRead += processedLoc;
+ if (!res)
+ return false;
+ if (processedLoc == 0)
+ return true;
+ buffer = (void *)((unsigned char *)buffer + processedLoc);
+ bytesToRead -= processedLoc;
+ }
+ while (bytesToRead > 0);
+ return true;
+#endif
+}
+
+/////////////////////////
+// COutFile
+
+bool COutFile::Open(LPCTSTR fileName, DWORD shareMode,
+ DWORD creationDisposition, DWORD flagsAndAttributes)
+{
+ return CFileBase::Create(fileName, GENERIC_WRITE, shareMode,
+ creationDisposition, flagsAndAttributes);
+}
+
+static inline DWORD GetCreationDisposition(bool createAlways)
+ { return createAlways? CREATE_ALWAYS: CREATE_NEW; }
+
+bool COutFile::Open(LPCTSTR fileName, DWORD creationDisposition)
+{
+ return Open(fileName, FILE_SHARE_READ,
+ creationDisposition, FILE_ATTRIBUTE_NORMAL);
+}
+
+bool COutFile::Create(LPCTSTR fileName, bool createAlways)
+{
+ return Open(fileName, GetCreationDisposition(createAlways));
+}
+
+#ifndef _UNICODE
+
+bool COutFile::Open(LPCWSTR fileName, DWORD shareMode,
+ DWORD creationDisposition, DWORD flagsAndAttributes)
+{
+ return CFileBase::Create(fileName, GENERIC_WRITE, shareMode,
+ creationDisposition, flagsAndAttributes);
+}
+
+bool COutFile::Open(LPCWSTR fileName, DWORD creationDisposition)
+{
+ return Open(fileName, FILE_SHARE_READ,
+ creationDisposition, FILE_ATTRIBUTE_NORMAL);
+}
+
+bool COutFile::Create(LPCWSTR fileName, bool createAlways)
+{
+ return Open(fileName, GetCreationDisposition(createAlways));
+}
+
+#endif
+
+bool COutFile::SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime)
+{
+#ifdef ENV_UNIX
+ (void)cTime;
+ LARGE_INTEGER ltime;
+ DWORD dw;
+
+ if (_fd == -1) {
+ SetLastError( ERROR_INVALID_HANDLE );
+ return false;
+ }
+
+ /* On some OS (cygwin, MacOSX ...), you must close the file before updating times */
+ if (aTime) {
+ ltime.QuadPart = aTime->dwHighDateTime;
+ ltime.QuadPart = (ltime.QuadPart << 32) | aTime->dwLowDateTime;
+ RtlTimeToSecondsSince1970( &ltime, &dw );
+ _lastAccessTime = dw;
+ }
+ if (mTime) {
+ ltime.QuadPart = mTime->dwHighDateTime;
+ ltime.QuadPart = (ltime.QuadPart << 32) | mTime->dwLowDateTime;
+ RtlTimeToSecondsSince1970( &ltime, &dw );
+ _lastWriteTime = dw;
+ }
+
+ return true;
+#else
+ return BOOLToBool( ::SetFileTime( _handle, cTime, aTime, mTime ) );
+#endif
+}
+
+bool COutFile::SetMTime(const FILETIME *mTime)
+{
+ return SetTime(NULL, NULL, mTime);
+}
+
+bool COutFile::WritePart(const void *data, UINT32 size, UINT32 &processedSize)
+{
+// if (size > kChunkSizeMax)
+// size = kChunkSizeMax;
+
+ return Write(data,size,processedSize);
+}
+
+bool COutFile::Write(const void *buffer, UINT32 bytesToWrite, UINT32 &bytesWritten)
+{
+#ifdef ENV_UNIX
+ if (_fd == -1)
+ {
+ SetLastError( ERROR_INVALID_HANDLE );
+ return false;
+ }
+
+ ssize_t ret;
+ do {
+ ret = write(_fd,buffer, bytesToWrite);
+ } while (ret < 0 && (errno == EINTR));
+
+ if (ret != -1) {
+ bytesWritten = ret;
+ return TRUE;
+ }
+ bytesWritten =0;
+ return FALSE;
+#else
+ bytesWritten = 0;
+ do
+ {
+ DWORD processedLoc = 0;
+ BOOL res = ::WriteFile( _handle, buffer, bytesToWrite, &processedLoc, 0 );
+ bytesWritten += processedLoc;
+ if (!res)
+ return false;
+ if (processedLoc == 0)
+ return true;
+ buffer = (const void *)((const unsigned char *)buffer + processedLoc);
+ bytesToWrite -= processedLoc;
+ }
+ while (bytesToWrite > 0);
+ return true;
+#endif
+}
+
+bool COutFile::SetEndOfFile()
+{
+#ifdef ENV_UNIX
+ if (_fd == -1)
+ {
+ SetLastError( ERROR_INVALID_HANDLE );
+ return false;
+ }
+
+ bool bret = false;
+
+ off_t pos_cur = lseek(_fd, 0, SEEK_CUR);
+ if (pos_cur != (off_t)-1) {
+ int iret = ftruncate(_fd, pos_cur);
+ if (iret == 0) bret = true;
+ }
+
+ return bret;
+#else
+ return BOOLToBool( ::SetEndOfFile( _handle ) );
+#endif
+}
+
+bool COutFile::SetLength(UINT64 length)
+{
+ UINT64 newPosition;
+ if(!Seek(length, newPosition))
+ return false;
+ if(newPosition != length)
+ return false;
+ return SetEndOfFile();
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileIO.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileIO.h
new file mode 100644
index 000000000..010c09f22
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileIO.h
@@ -0,0 +1,115 @@
+// Windows/FileIO.h
+
+#ifndef __WINDOWS_FILEIO_H
+#define __WINDOWS_FILEIO_H
+
+#include <Common/MyString.h>
+
+#ifndef _WIN32
+
+#define FILE_BEGIN SEEK_SET
+#define FILE_CURRENT SEEK_CUR
+#define FILE_END SEEK_END
+#define INVALID_SET_FILE_POINTER ((DWORD)-1)
+
+#define CREATE_NEW 1
+#define CREATE_ALWAYS 2
+#define OPEN_EXISTING 3
+#define OPEN_ALWAYS 4
+/* #define TRUNCATE_EXISTING 5 */
+
+#endif
+
+namespace NWindows {
+namespace NFile {
+namespace NIO {
+
+
+class CFileBase
+{
+protected:
+#ifdef ENV_UNIX
+ int _fd;
+ AString _unix_filename;
+ time_t _lastAccessTime;
+ time_t _lastWriteTime;
+#ifdef HAVE_LSTAT
+ int _size;
+ char _buffer[MAX_PATHNAME_LEN+1];
+ int _offset;
+#endif
+#else
+ HANDLE _handle;
+#endif
+
+ bool Create(LPCSTR fileName, DWORD desiredAccess,
+ DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes,bool ignoreSymbolicLink=false);
+ bool Create(LPCWSTR fileName, DWORD desiredAccess,
+ DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes,bool ignoreSymbolicLink=false);
+
+public:
+#ifdef ENV_UNIX
+ CFileBase(): _fd(-1) {};
+#else
+ CFileBase(): _handle(INVALID_HANDLE_VALUE) {};
+#endif
+ virtual ~CFileBase();
+
+ virtual bool Close();
+
+ bool GetLength(UINT64 &length) const;
+
+ bool Seek(INT64 distanceToMove, DWORD moveMethod, UINT64 &newPosition);
+ bool Seek(UINT64 position, UINT64 &newPosition);
+};
+
+class CInFile: public CFileBase
+{
+public:
+ bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool OpenShared(LPCTSTR fileName, bool /* shareForWrite */ ,bool ignoreSymbolicLink=false) {
+ return Open(fileName,ignoreSymbolicLink);
+ }
+ bool Open(LPCTSTR fileName,bool ignoreSymbolicLink=false);
+ #ifndef _UNICODE
+ bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool OpenShared(LPCWSTR fileName, bool /* shareForWrite */ ,bool ignoreSymbolicLink=false) {
+ return Open(fileName,ignoreSymbolicLink);
+ }
+ bool Open(LPCWSTR fileName,bool ignoreSymbolicLink=false);
+ #endif
+ bool ReadPart(void *data, UINT32 size, UINT32 &processedSize);
+ bool Read(void *data, UINT32 size, UINT32 &processedSize);
+};
+
+class COutFile: public CFileBase
+{
+public:
+ bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCTSTR fileName, DWORD creationDisposition);
+ bool Create(LPCTSTR fileName, bool createAlways);
+
+ #ifndef _UNICODE
+ bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCWSTR fileName, DWORD creationDisposition);
+ bool Create(LPCWSTR fileName, bool createAlways);
+ #endif
+
+ /*
+ void SetOpenCreationDisposition(DWORD creationDisposition)
+ { m_CreationDisposition = creationDisposition; }
+ void SetOpenCreationDispositionCreateAlways()
+ { m_CreationDisposition = CREATE_ALWAYS; }
+ */
+
+ bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime);
+ bool SetMTime(const FILETIME *mTime);
+ bool WritePart(const void *data, UINT32 size, UINT32 &processedSize);
+ bool Write(const void *data, UINT32 size, UINT32 &processedSize);
+ bool SetEndOfFile();
+ bool SetLength(UINT64 length);
+};
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileName.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileName.cpp
new file mode 100644
index 000000000..8443a4af9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileName.cpp
@@ -0,0 +1,50 @@
+// Windows/FileName.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/FileName.h"
+#include "Common/Wildcard.h"
+
+namespace NWindows {
+namespace NFile {
+namespace NName {
+
+void NormalizeDirPathPrefix(CSysString &dirPath)
+{
+ if (dirPath.IsEmpty())
+ return;
+ if (dirPath.ReverseFind(kDirDelimiter) != dirPath.Length() - 1)
+ dirPath += kDirDelimiter;
+}
+
+#ifndef _UNICODE
+void NormalizeDirPathPrefix(UString &dirPath)
+{
+ if (dirPath.IsEmpty())
+ return;
+ if (dirPath.ReverseFind(wchar_t(kDirDelimiter)) != dirPath.Length() - 1)
+ dirPath += wchar_t(kDirDelimiter);
+}
+#endif
+
+const wchar_t kExtensionDelimiter = L'.';
+
+void SplitNameToPureNameAndExtension(const UString &fullName,
+ UString &pureName, UString &extensionDelimiter, UString &extension)
+{
+ int index = fullName.ReverseFind(kExtensionDelimiter);
+ if (index < 0)
+ {
+ pureName = fullName;
+ extensionDelimiter.Empty();
+ extension.Empty();
+ }
+ else
+ {
+ pureName = fullName.Left(index);
+ extensionDelimiter = kExtensionDelimiter;
+ extension = fullName.Mid(index + 1);
+ }
+}
+
+}}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileName.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileName.h
new file mode 100644
index 000000000..0b0034eb9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/FileName.h
@@ -0,0 +1,26 @@
+// Windows/FileName.h
+
+#ifndef __WINDOWS_FILENAME_H
+#define __WINDOWS_FILENAME_H
+
+#include "../Common/MyWindows.h"
+#include "../Common/MyString.h"
+
+namespace NWindows {
+namespace NFile {
+namespace NName {
+
+const TCHAR kDirDelimiter = CHAR_PATH_SEPARATOR;
+const TCHAR kAnyStringWildcard = '*';
+
+void NormalizeDirPathPrefix(CSysString &dirPath); // ensures that it ended with '\\'
+#ifndef _UNICODE
+void NormalizeDirPathPrefix(UString &dirPath); // ensures that it ended with '\\'
+#endif
+
+void SplitNameToPureNameAndExtension(const UString &fullName,
+ UString &pureName, UString &extensionDelimiter, UString &extension);
+
+}}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Handle.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Handle.h
new file mode 100644
index 000000000..0791b4acd
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Handle.h
@@ -0,0 +1,37 @@
+// Windows/Handle.h
+
+#ifndef __WINDOWS_HANDLE_H
+#define __WINDOWS_HANDLE_H
+
+namespace NWindows {
+
+class CHandle
+{
+protected:
+ HANDLE _handle;
+public:
+ operator HANDLE() { return _handle; }
+ CHandle(): _handle(NULL) {}
+ ~CHandle() { Close(); }
+ bool Close()
+ {
+ if (_handle == NULL)
+ return true;
+ if (!::CloseHandle(_handle))
+ return false;
+ _handle = NULL;
+ return true;
+ }
+ void Attach(HANDLE handle)
+ { _handle = handle; }
+ HANDLE Detach()
+ {
+ HANDLE handle = _handle;
+ _handle = NULL;
+ return handle;
+ }
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariant.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariant.cpp
new file mode 100644
index 000000000..1db6c236e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariant.cpp
@@ -0,0 +1,332 @@
+// Windows/PropVariant.cpp
+
+#include "StdAfx.h"
+
+#include "PropVariant.h"
+
+#include "../Common/Defs.h"
+
+namespace NWindows {
+namespace NCOM {
+
+CPropVariant::CPropVariant(const PROPVARIANT& varSrc)
+{
+ vt = VT_EMPTY;
+ InternalCopy(&varSrc);
+}
+
+CPropVariant::CPropVariant(const CPropVariant& varSrc)
+{
+ vt = VT_EMPTY;
+ InternalCopy(&varSrc);
+}
+
+CPropVariant::CPropVariant(BSTR bstrSrc)
+{
+ vt = VT_EMPTY;
+ *this = bstrSrc;
+}
+
+CPropVariant::CPropVariant(LPCOLESTR lpszSrc)
+{
+ vt = VT_EMPTY;
+ *this = lpszSrc;
+}
+
+CPropVariant& CPropVariant::operator=(const CPropVariant& varSrc)
+{
+ InternalCopy(&varSrc);
+ return *this;
+}
+CPropVariant& CPropVariant::operator=(const PROPVARIANT& varSrc)
+{
+ InternalCopy(&varSrc);
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(BSTR bstrSrc)
+{
+ *this = (LPCOLESTR)bstrSrc;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc)
+{
+ InternalClear();
+ vt = VT_BSTR;
+ wReserved1 = 0;
+ bstrVal = ::SysAllocString(lpszSrc);
+ if (bstrVal == NULL && lpszSrc != NULL)
+ {
+ vt = VT_ERROR;
+ scode = E_OUTOFMEMORY;
+ }
+ return *this;
+}
+
+
+CPropVariant& CPropVariant::operator=(const char *s)
+{
+ InternalClear();
+ vt = VT_BSTR;
+ wReserved1 = 0;
+ UINT len = (UINT)strlen(s);
+ bstrVal = ::SysAllocStringByteLen(0, (UINT)len * sizeof(OLECHAR));
+ if (bstrVal == NULL)
+ {
+ vt = VT_ERROR;
+ scode = E_OUTOFMEMORY;
+ }
+ else
+ {
+ for (UINT i = 0; i <= len; i++)
+ bstrVal[i] = s[i];
+ }
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(bool bSrc)
+{
+ if (vt != VT_BOOL)
+ {
+ InternalClear();
+ vt = VT_BOOL;
+ }
+ boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(UInt32 value)
+{
+ if (vt != VT_UI4)
+ {
+ InternalClear();
+ vt = VT_UI4;
+ }
+ ulVal = value;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(UInt64 value)
+{
+ if (vt != VT_UI8)
+ {
+ InternalClear();
+ vt = VT_UI8;
+ }
+ uhVal.QuadPart = value;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(const FILETIME &value)
+{
+ if (vt != VT_FILETIME)
+ {
+ InternalClear();
+ vt = VT_FILETIME;
+ }
+ filetime = value;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(Int32 value)
+{
+ if (vt != VT_I4)
+ {
+ InternalClear();
+ vt = VT_I4;
+ }
+ lVal = value;
+
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(Byte value)
+{
+ if (vt != VT_UI1)
+ {
+ InternalClear();
+ vt = VT_UI1;
+ }
+ bVal = value;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(Int16 value)
+{
+ if (vt != VT_I2)
+ {
+ InternalClear();
+ vt = VT_I2;
+ }
+ iVal = value;
+ return *this;
+}
+
+/*
+CPropVariant& CPropVariant::operator=(LONG value)
+{
+ if (vt != VT_I4)
+ {
+ InternalClear();
+ vt = VT_I4;
+ }
+ lVal = value;
+ return *this;
+}
+*/
+
+static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
+{
+ switch(propVariant->vt)
+ {
+ case VT_UI1:
+ case VT_I1:
+ case VT_I2:
+ case VT_UI2:
+ case VT_BOOL:
+ case VT_I4:
+ case VT_UI4:
+ case VT_R4:
+ case VT_INT:
+ case VT_UINT:
+ case VT_ERROR:
+ case VT_FILETIME:
+ case VT_UI8:
+ case VT_R8:
+ case VT_CY:
+ case VT_DATE:
+ propVariant->vt = VT_EMPTY;
+ propVariant->wReserved1 = 0;
+ return S_OK;
+ }
+ return ::VariantClear((VARIANTARG *)propVariant);
+}
+
+HRESULT CPropVariant::Clear()
+{
+ return MyPropVariantClear(this);
+}
+
+HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
+{
+ ::VariantClear((tagVARIANT *)this);
+ switch(pSrc->vt)
+ {
+ case VT_UI1:
+ case VT_I1:
+ case VT_I2:
+ case VT_UI2:
+ case VT_BOOL:
+ case VT_I4:
+ case VT_UI4:
+ case VT_R4:
+ case VT_INT:
+ case VT_UINT:
+ case VT_ERROR:
+ case VT_FILETIME:
+ case VT_UI8:
+ case VT_R8:
+ case VT_CY:
+ case VT_DATE:
+ memmove((PROPVARIANT*)this, pSrc, sizeof(PROPVARIANT));
+ return S_OK;
+ }
+ return ::VariantCopy((tagVARIANT *)this, (tagVARIANT *)(pSrc));
+}
+
+
+HRESULT CPropVariant::Attach(PROPVARIANT* pSrc)
+{
+ HRESULT hr = Clear();
+ if (FAILED(hr))
+ return hr;
+ memcpy(this, pSrc, sizeof(PROPVARIANT));
+ pSrc->vt = VT_EMPTY;
+ return S_OK;
+}
+
+HRESULT CPropVariant::Detach(PROPVARIANT* pDest)
+{
+ HRESULT hr = MyPropVariantClear(pDest);
+ if (FAILED(hr))
+ return hr;
+ memcpy(pDest, this, sizeof(PROPVARIANT));
+ vt = VT_EMPTY;
+ return S_OK;
+}
+
+HRESULT CPropVariant::InternalClear()
+{
+ HRESULT hr = Clear();
+ if (FAILED(hr))
+ {
+ vt = VT_ERROR;
+ scode = hr;
+ }
+ return hr;
+}
+
+void CPropVariant::InternalCopy(const PROPVARIANT* pSrc)
+{
+ HRESULT hr = Copy(pSrc);
+ if (FAILED(hr))
+ {
+ vt = VT_ERROR;
+ scode = hr;
+ }
+}
+
+int CPropVariant::Compare(const CPropVariant &a)
+{
+ if (vt != a.vt)
+ return 0; // it's mean some bug
+ switch (vt)
+ {
+ case VT_EMPTY:
+ return 0;
+
+ /*
+ case VT_I1:
+ return MyCompare(cVal, a.cVal);
+ */
+ case VT_UI1:
+ return MyCompare(bVal, a.bVal);
+
+ case VT_I2:
+ return MyCompare(iVal, a.iVal);
+ case VT_UI2:
+ return MyCompare(uiVal, a.uiVal);
+
+ case VT_I4:
+ return MyCompare(lVal, a.lVal);
+ /*
+ case VT_INT:
+ return MyCompare(intVal, a.intVal);
+ */
+ case VT_UI4:
+ return MyCompare(ulVal, a.ulVal);
+ /*
+ case VT_UINT:
+ return MyCompare(uintVal, a.uintVal);
+ */
+ case VT_I8:
+ return MyCompare(hVal.QuadPart, a.hVal.QuadPart);
+ case VT_UI8:
+ return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart);
+
+ case VT_BOOL:
+ return -MyCompare(boolVal, a.boolVal);
+
+ case VT_FILETIME:
+ return ::CompareFileTime(&filetime, &a.filetime);
+ case VT_BSTR:
+ return 0; // Not implemented
+ // return MyCompare(aPropVarint.cVal);
+
+ default:
+ return 0;
+ }
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariant.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariant.h
new file mode 100644
index 000000000..5552bbe2f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariant.h
@@ -0,0 +1,58 @@
+// Windows/PropVariant.h
+
+#ifndef __WINDOWS_PROPVARIANT_H
+#define __WINDOWS_PROPVARIANT_H
+
+#include "../Common/MyWindows.h"
+#include "../Common/Types.h"
+
+namespace NWindows {
+namespace NCOM {
+
+class CPropVariant : public tagPROPVARIANT
+{
+public:
+ CPropVariant() { vt = VT_EMPTY; wReserved1 = 0; }
+ ~CPropVariant() { Clear(); }
+ CPropVariant(const PROPVARIANT& varSrc);
+ CPropVariant(const CPropVariant& varSrc);
+ CPropVariant(BSTR bstrSrc);
+ CPropVariant(LPCOLESTR lpszSrc);
+ CPropVariant(bool bSrc) { vt = VT_BOOL; wReserved1 = 0; boolVal = (bSrc ? VARIANT_TRUE : VARIANT_FALSE); };
+ CPropVariant(UInt32 value) { vt = VT_UI4; wReserved1 = 0; ulVal = value; }
+ CPropVariant(UInt64 value) { vt = VT_UI8; wReserved1 = 0; uhVal = *(ULARGE_INTEGER*)&value; }
+ CPropVariant(const FILETIME &value) { vt = VT_FILETIME; wReserved1 = 0; filetime = value; }
+ CPropVariant(Int32 value) { vt = VT_I4; wReserved1 = 0; lVal = value; }
+ CPropVariant(Byte value) { vt = VT_UI1; wReserved1 = 0; bVal = value; }
+ CPropVariant(Int16 value) { vt = VT_I2; wReserved1 = 0; iVal = value; }
+ // CPropVariant(LONG value, VARTYPE vtSrc = VT_I4) { vt = vtSrc; lVal = value; }
+
+ CPropVariant& operator=(const CPropVariant& varSrc);
+ CPropVariant& operator=(const PROPVARIANT& varSrc);
+ CPropVariant& operator=(BSTR bstrSrc);
+ CPropVariant& operator=(LPCOLESTR lpszSrc);
+ CPropVariant& operator=(const char *s);
+ CPropVariant& operator=(bool bSrc);
+ CPropVariant& operator=(UInt32 value);
+ CPropVariant& operator=(UInt64 value);
+ CPropVariant& operator=(const FILETIME &value);
+
+ CPropVariant& operator=(Int32 value);
+ CPropVariant& operator=(Byte value);
+ CPropVariant& operator=(Int16 value);
+ // CPropVariant& operator=(LONG value);
+
+ HRESULT Clear();
+ HRESULT Copy(const PROPVARIANT* pSrc);
+ HRESULT Attach(PROPVARIANT* pSrc);
+ HRESULT Detach(PROPVARIANT* pDest);
+
+ HRESULT InternalClear();
+ void InternalCopy(const PROPVARIANT* pSrc);
+
+ int Compare(const CPropVariant &a1);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantConversions.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantConversions.cpp
new file mode 100644
index 000000000..63381a1bc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantConversions.cpp
@@ -0,0 +1,152 @@
+// PropVariantConversions.cpp
+
+#include "StdAfx.h"
+
+#include "PropVariantConversions.h"
+
+#include "Windows/Defs.h"
+
+#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
+
+static UString ConvertUInt64ToString(UInt64 value)
+{
+ wchar_t buffer[32];
+ ConvertUInt64ToString(value, buffer);
+ return buffer;
+}
+
+static UString ConvertInt64ToString(Int64 value)
+{
+ wchar_t buffer[32];
+ ConvertInt64ToString(value, buffer);
+ return buffer;
+}
+
+#ifdef _WIN32
+static char *UIntToStringSpec(char c, UInt32 value, char *s, int numPos)
+{
+ if (c != 0)
+ *s++ = c;
+ char temp[16];
+ int pos = 0;
+ do
+ {
+ temp[pos++] = (char)('0' + value % 10);
+ value /= 10;
+ }
+ while (value != 0);
+ int i;
+ for (i = 0; i < numPos - pos; i++)
+ *s++ = '0';
+ do
+ *s++ = temp[--pos];
+ while (pos > 0);
+ *s = '\0';
+ return s;
+}
+#endif
+
+bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool includeSeconds)
+{
+#ifdef _WIN32
+ s[0] = '\0';
+ SYSTEMTIME st;
+ if (!BOOLToBool(FileTimeToSystemTime(&ft, &st)))
+ return false;
+ s = UIntToStringSpec(0, st.wYear, s, 4);
+ s = UIntToStringSpec('-', st.wMonth, s, 2);
+ s = UIntToStringSpec('-', st.wDay, s, 2);
+ if (includeTime)
+ {
+ s = UIntToStringSpec(' ', st.wHour, s, 2);
+ s = UIntToStringSpec(':', st.wMinute, s, 2);
+ if (includeSeconds)
+ UIntToStringSpec(':', st.wSecond, s, 2);
+ }
+ /*
+ sprintf(s, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay);
+ if (includeTime)
+ {
+ sprintf(s + strlen(s), " %02d:%02d", st.wHour, st.wMinute);
+ if (includeSeconds)
+ sprintf(s + strlen(s), ":%02d", st.wSecond);
+ }
+ */
+#else
+ BOOLEAN WINAPI RtlTimeToSecondsSince1970( const LARGE_INTEGER *Time, DWORD *Seconds );
+
+ FILETIME filetime;
+ LocalFileTimeToFileTime(&ft, &filetime);
+
+ LARGE_INTEGER ltime;
+
+ ltime.QuadPart = filetime.dwHighDateTime;
+ ltime.QuadPart = (ltime.QuadPart << 32) | filetime.dwLowDateTime;
+
+ DWORD dw;
+ RtlTimeToSecondsSince1970(&ltime, &dw );
+ time_t timep = (time_t)dw;
+
+ struct tm * date = localtime(&timep);
+
+ sprintf(s, "%04d-%02d-%02d", date->tm_year+1900, date->tm_mon+1,date->tm_mday);
+ if (includeTime)
+ {
+ sprintf(s + strlen(s), " %02d:%02d", date->tm_hour,date->tm_min);
+ if (includeSeconds)
+ sprintf(s + strlen(s), ":%02d", date->tm_sec);
+ }
+#endif
+ return true;
+}
+
+UString ConvertFileTimeToString(const FILETIME &fileTime, bool includeTime, bool includeSeconds)
+{
+ char s[32];
+ ConvertFileTimeToString(fileTime, s, includeTime, includeSeconds);
+ return GetUnicodeString(s);
+}
+
+
+UString ConvertPropVariantToString(const PROPVARIANT &prop)
+{
+ switch (prop.vt)
+ {
+ case VT_EMPTY: return UString();
+ case VT_BSTR: return prop.bstrVal;
+ case VT_UI1: return ConvertUInt64ToString(prop.bVal);
+ case VT_UI2: return ConvertUInt64ToString(prop.uiVal);
+ case VT_UI4: return ConvertUInt64ToString(prop.ulVal);
+ case VT_UI8: return ConvertUInt64ToString(prop.uhVal.QuadPart);
+ case VT_FILETIME: return ConvertFileTimeToString(prop.filetime, true, true);
+ // case VT_I1: return ConvertInt64ToString(prop.cVal);
+ case VT_I2: return ConvertInt64ToString(prop.iVal);
+ case VT_I4: return ConvertInt64ToString(prop.lVal);
+ case VT_I8: return ConvertInt64ToString(prop.hVal.QuadPart);
+ case VT_BOOL: return VARIANT_BOOLToBool(prop.boolVal) ? L"+" : L"-";
+ default:
+ #ifndef _WIN32_WCE
+ throw 150245;
+ #else
+ return UString();
+ #endif
+ }
+}
+
+UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &prop)
+{
+ switch (prop.vt)
+ {
+ case VT_UI1: return prop.bVal;
+ case VT_UI2: return prop.uiVal;
+ case VT_UI4: return prop.ulVal;
+ case VT_UI8: return (UInt64)prop.uhVal.QuadPart;
+ default:
+ #ifndef _WIN32_WCE
+ throw 151199;
+ #else
+ return 0;
+ #endif
+ }
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantConversions.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantConversions.h
new file mode 100644
index 000000000..68ad96129
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantConversions.h
@@ -0,0 +1,14 @@
+// Windows/PropVariantConversions.h
+
+#ifndef __PROPVARIANTCONVERSIONS_H
+#define __PROPVARIANTCONVERSIONS_H
+
+#include "Common/Types.h"
+#include "Common/MyString.h"
+
+bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime = true, bool includeSeconds = true);
+UString ConvertFileTimeToString(const FILETIME &ft, bool includeTime = true, bool includeSeconds = true);
+UString ConvertPropVariantToString(const PROPVARIANT &propVariant);
+UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &propVariant);
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantUtils.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantUtils.cpp
new file mode 100644
index 000000000..0c9e8f341
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantUtils.cpp
@@ -0,0 +1,77 @@
+// PropVariantUtils.cpp
+
+#include "StdAfx.h"
+
+#include "PropVariantUtils.h"
+#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
+
+using namespace NWindows;
+
+static AString GetHex(UInt32 v)
+{
+ char sz[32] = { '0', 'x' };
+ ConvertUInt64ToString(v, sz + 2, 16);
+ return sz;
+}
+
+void StringToProp(const AString &s, NCOM::CPropVariant &prop)
+{
+ prop = MultiByteToUnicodeString(s);
+}
+
+void PairToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 value, NCOM::CPropVariant &prop)
+{
+ AString s;
+ for (unsigned i = 0; i < num; i++)
+ {
+ const CUInt32PCharPair &p = pairs[i];
+ if (p.Value == value)
+ s = p.Name;
+ }
+ if (s.IsEmpty())
+ s = GetHex(value);
+ StringToProp(s, prop);
+}
+
+AString TypeToString(const char *table[], unsigned num, UInt32 value)
+{
+ if (value < num)
+ return table[value];
+ return GetHex(value);
+}
+
+void TypeToProp(const char *table[], unsigned num, UInt32 value, NCOM::CPropVariant &prop)
+{
+ StringToProp(TypeToString(table, num, value), prop);
+}
+
+
+AString FlagsToString(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags)
+{
+ AString s;
+ for (unsigned i = 0; i < num; i++)
+ {
+ const CUInt32PCharPair &p = pairs[i];
+ if ((flags & p.Value) != 0)
+ {
+ if (!s.IsEmpty())
+ s += ' ';
+ s += p.Name;
+ }
+ flags &= ~p.Value;
+ }
+ if (flags != 0)
+ {
+ if (!s.IsEmpty())
+ s += ' ';
+ s += GetHex(flags);
+ }
+ return s;
+}
+
+void FlagsToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags, NCOM::CPropVariant &prop)
+{
+ StringToProp(FlagsToString(pairs, num, flags), prop);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantUtils.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantUtils.h
new file mode 100644
index 000000000..5aaf65cb9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/PropVariantUtils.h
@@ -0,0 +1,28 @@
+// Windows/PropVariantUtils.h
+
+#ifndef __PROP_VARIANT_UTILS_H
+#define __PROP_VARIANT_UTILS_H
+
+#include "Common/MyString.h"
+#include "PropVariant.h"
+
+struct CUInt32PCharPair
+{
+ UInt32 Value;
+ const char *Name;
+};
+
+void StringToProp(const AString &s, NWindows::NCOM::CPropVariant &prop);
+void PairToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 value, NWindows::NCOM::CPropVariant &prop);
+
+AString FlagsToString(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags);
+void FlagsToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags, NWindows::NCOM::CPropVariant &prop);
+
+AString TypeToString(const char *table[], unsigned num, UInt32 value);
+void TypeToProp(const char *table[], unsigned num, UInt32 value, NWindows::NCOM::CPropVariant &prop);
+
+#define PAIR_TO_PROP(pairs, value, prop) PairToProp(pairs, sizeof(pairs) / sizeof(pairs[0]), value, prop)
+#define FLAGS_TO_PROP(pairs, value, prop) FlagsToProp(pairs, sizeof(pairs) / sizeof(pairs[0]), value, prop)
+#define TYPE_TO_PROP(table, value, prop) TypeToProp(table, sizeof(table) / sizeof(table[0]), value, prop)
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Registry.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Registry.cpp
new file mode 100644
index 000000000..8df1e7459
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Registry.cpp
@@ -0,0 +1,252 @@
+// Windows/Registry.cpp
+
+#include "StdAfx.h"
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+#include "Windows/Registry.h"
+
+#include <wx/config.h>
+
+class HKEY_Impl
+{
+ public:
+ wxString path;
+ HKEY_Impl(wxString a) : path(a) {}
+};
+
+namespace NWindows {
+namespace NRegistry {
+
+#define ERROR_SET_VALUE (E_INVALIDARG) // FIXME
+#define ERROR_GET_VALUE (E_INVALIDARG) // FIXME
+#define PROGRAM_NAME L"p7zip"
+
+static wxConfig * g_config = 0;
+static int g_config_ref = 0;
+
+static void configAddRef() {
+ if (g_config == 0) {
+ g_config = new wxConfig(PROGRAM_NAME);
+ g_config->Flush(true);
+ wxConfigBase::Set(g_config);
+ }
+ g_config_ref++;
+}
+
+static void configSubRef() {
+ if (g_config_ref >= 1)
+ {
+ g_config_ref--;
+ if (g_config_ref == 0) {
+ delete g_config;
+ g_config = 0;
+ wxConfigBase::Set(NULL);
+ } else {
+ g_config->Flush(true);
+ }
+ }
+}
+
+ LONG CKey::Close()
+ {
+ if (_object)
+ {
+ configSubRef();
+ delete _object;
+ }
+ _object = 0;
+ return ERROR_SUCCESS;
+ }
+
+ CKey::~CKey()
+ {
+ Close();
+ }
+
+ LONG CKey::Create(HKEY parentKey, LPCTSTR keyName)
+ {
+ Close();
+
+ configAddRef();
+
+ wxString path;
+
+ if (parentKey == HKEY_CURRENT_USER) {
+ path=L"/" + wxString(keyName);
+ } else {
+ path = parentKey->path + L"/" + wxString(keyName);
+ }
+ _object = new HKEY_Impl(path);
+ return ERROR_SUCCESS;
+ }
+ LONG CKey::Open(HKEY parentKey, LPCTSTR keyName, REGSAM accessMask)
+ {
+ Close();
+
+ configAddRef();
+
+ wxString path;
+
+ if (parentKey == HKEY_CURRENT_USER) {
+ path=L"/" + wxString(keyName);
+ } else {
+ path = parentKey->path + L"/" + wxString(keyName);
+ }
+ _object = new HKEY_Impl(path);
+ return ERROR_SUCCESS;
+ }
+
+ LONG CKey::RecurseDeleteKey(LPCTSTR subKeyName)
+ {
+ g_config->SetPath(_object->path);
+ bool ret = g_config->DeleteGroup(subKeyName);
+ if (ret) return ERROR_SUCCESS;
+ return ERROR_GET_VALUE;
+ }
+
+ LONG CKey::DeleteValue(LPCTSTR name)
+ {
+ g_config->SetPath(_object->path);
+ bool ret = g_config->DeleteEntry(name);
+ if (ret) return ERROR_SUCCESS;
+ return ERROR_GET_VALUE;
+ }
+
+ LONG CKey::QueryValue(LPCTSTR name, UInt32 &value)
+ {
+ g_config->SetPath(_object->path);
+ long val;
+ bool ret = g_config->Read(name,&val);
+ if (ret) {
+ value = (UInt32)val;
+ return ERROR_SUCCESS;
+ }
+ return ERROR_GET_VALUE;
+ }
+
+ LONG CKey::QueryValue(LPCTSTR name, bool &value)
+ {
+ g_config->SetPath(_object->path);
+ bool ret = g_config->Read(name,&value);
+ if (ret) return ERROR_SUCCESS;
+ return ERROR_GET_VALUE;
+ }
+
+ LONG CKey::QueryValue(LPCTSTR name, CSysString &value)
+ {
+ g_config->SetPath(_object->path);
+ wxString val;
+ bool ret = g_config->Read(name,&val);
+ if (ret) {
+ value = val;
+ return ERROR_SUCCESS;
+ }
+ return ERROR_GET_VALUE;
+ }
+
+ LONG CKey::SetValue(LPCTSTR valueName, UInt32 value)
+ {
+ g_config->SetPath(_object->path);
+ bool ret = g_config->Write(valueName,(long)value);
+ if (ret == true) return ERROR_SUCCESS;
+ return ERROR_SET_VALUE;
+ }
+ LONG CKey::SetValue(LPCTSTR valueName, bool value)
+ {
+ g_config->SetPath(_object->path);
+ bool ret = g_config->Write(valueName,value);
+ if (ret == true) return ERROR_SUCCESS;
+ return ERROR_SET_VALUE;
+ }
+ LONG CKey::SetValue(LPCTSTR valueName, LPCTSTR value)
+ {
+ g_config->SetPath(_object->path);
+ bool ret = g_config->Write(valueName,value);
+ if (ret == true) return ERROR_SUCCESS;
+ return ERROR_SET_VALUE;
+ }
+
+ LONG CKey::SetValue(LPCTSTR name, const void *value, UInt32 size)
+ {
+ static char hexa[] = "0123456789ABCDEF";
+ /* FIXME
+ MYASSERT(value != NULL);
+ MYASSERT(_object != NULL);
+ return RegSetValueEx(_object, name, NULL, REG_BINARY, (const BYTE *)value, size);
+ */
+ BYTE *buf = (BYTE *)value;
+ wxString str;
+ for(UInt32 i=0;i<size;i++)
+ {
+ str += hexa[ (buf[i]>>4) & 0x0f];
+ str += hexa[ buf[i] & 0x0f];
+ }
+ return SetValue(name,str);
+ }
+
+ LONG CKey::EnumKeys(CSysStringVector &keyNames)
+ {
+ g_config->SetPath(_object->path);
+ keyNames.Clear();
+ // enumeration variables
+ wxString str;
+ long dummy;
+ bool bCont = g_config->GetFirstEntry(str, dummy);
+ while ( bCont ) {
+ keyNames.Add((const TCHAR *)str);
+ bCont = g_config->GetNextEntry(str, dummy);
+ }
+
+ // now all groups...
+ bCont = g_config->GetFirstGroup(str, dummy);
+ while ( bCont ) {
+ keyNames.Add((const TCHAR *)str);
+ bCont = g_config->GetNextGroup(str, dummy);
+ }
+ return ERROR_SUCCESS;
+ }
+
+ LONG CKey::QueryValue(LPCTSTR name, void *value, UInt32 &dataSize)
+ {
+ g_config->SetPath(_object->path);
+ wxString str;
+ bool ret = g_config->Read(name,&str);
+ if (ret == false) return ERROR_GET_VALUE;
+
+ size_t l = str.Len() / 2;
+ if (l > dataSize) l = dataSize;
+ else dataSize=l;
+
+ BYTE *buf = (BYTE *)value;
+ for(UInt32 i=0;i<dataSize;i++)
+ {
+ char cval[3];
+ cval[0] = (char)str[2*i];
+ cval[1] = (char)str[2*i+1];
+ cval[2] = 0;
+ unsigned uval = 0;
+ sscanf(cval,"%x",&uval);
+ buf[i]=(BYTE)uval;
+ }
+
+ return ERROR_SUCCESS;
+ }
+
+
+ LONG CKey::QueryValue(LPCTSTR name, CByteBuffer &value, UInt32 &dataSize)
+ {
+ g_config->SetPath(_object->path);
+ wxString str;
+ bool ret = g_config->Read(name,&str);
+ if (ret == false) return ERROR_GET_VALUE;
+
+ dataSize = str.Len() / 2;
+ value.SetCapacity(dataSize);
+ return QueryValue(name, (BYTE *)value, dataSize);
+ }
+
+}
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Registry.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Registry.h
new file mode 100644
index 000000000..b2ffb9643
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Registry.h
@@ -0,0 +1,107 @@
+// Windows/Registry.h
+
+#ifndef __WINDOWS_REGISTRY_H
+#define __WINDOWS_REGISTRY_H
+
+#include "Common/Buffer.h"
+#include "Common/MyString.h"
+#include "Common/Types.h"
+
+#ifndef _WIN32
+class HKEY_Impl;
+
+typedef HKEY_Impl * HKEY;
+
+/*
+#define HKEY_CLASSES_ROOT ((HKEY) 0x80000000)
+#define HKEY_LOCAL_MACHINE ((HKEY) 0x80000002)
+#define HKEY_USERS ((HKEY) 0x80000003)
+#define HKEY_PERFORMANCE_DATA ((HKEY) 0x80000004)
+#define HKEY_CURRENT_CONFIG ((HKEY) 0x80000005)
+#define HKEY_DYN_DATA ((HKEY) 0x80000006)
+*/
+#define HKEY_CURRENT_USER ((HKEY) 0x80000001)
+
+
+typedef DWORD REGSAM;
+#define ERROR_SUCCESS (0)
+#define KEY_READ (0x1234) // FIXME
+#define KEY_ALL_ACCESS (~0) // FIXME
+
+/* ------------------------------ end registry ------------------------------ */
+
+#endif
+
+namespace NWindows {
+namespace NRegistry {
+
+const TCHAR kKeyNameDelimiter = TEXT(CHAR_PATH_SEPARATOR);
+
+// LONG SetValue(HKEY parentKey, LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value);
+
+class CKey
+{
+ HKEY _object;
+public:
+ CKey(): _object(NULL) {}
+ ~CKey();
+
+ operator HKEY() const { return _object; }
+
+ #if 0
+ HKEY Detach();
+ void Attach(HKEY key);
+ LONG Create(HKEY parentKey, LPCTSTR keyName,
+ LPTSTR keyClass = REG_NONE, DWORD options = REG_OPTION_NON_VOLATILE,
+ REGSAM accessMask = KEY_ALL_ACCESS,
+ LPSECURITY_ATTRIBUTES securityAttributes = NULL,
+ LPDWORD disposition = NULL);
+ LONG Open(HKEY parentKey, LPCTSTR keyName,
+ REGSAM accessMask = KEY_ALL_ACCESS);
+#endif // #if 0
+ LONG Create(HKEY parentKey, LPCTSTR keyName);
+ LONG Open(HKEY parentKey, LPCTSTR keyName,
+ REGSAM accessMask = KEY_ALL_ACCESS);
+
+ LONG Close();
+
+ LONG DeleteSubKey(LPCTSTR subKeyName);
+ LONG RecurseDeleteKey(LPCTSTR subKeyName);
+
+ LONG DeleteValue(LPCTSTR name);
+ #ifndef _UNICODE
+ LONG DeleteValue(LPCWSTR name);
+ #endif
+
+ LONG SetValue(LPCTSTR valueName, UInt32 value);
+ LONG SetValue(LPCTSTR valueName, bool value);
+ LONG SetValue(LPCTSTR valueName, LPCTSTR value);
+ // LONG SetValue(LPCTSTR valueName, const CSysString &value);
+ #ifndef _UNICODE
+ LONG SetValue(LPCWSTR name, LPCWSTR value);
+ // LONG SetValue(LPCWSTR name, const UString &value);
+ #endif
+
+ LONG SetValue(LPCTSTR name, const void *value, UInt32 size);
+
+ LONG SetKeyValue(LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value);
+
+ LONG QueryValue(LPCTSTR name, UInt32 &value);
+ LONG QueryValue(LPCTSTR name, bool &value);
+ LONG QueryValue(LPCTSTR name, LPTSTR value, UInt32 &dataSize);
+ LONG QueryValue(LPCTSTR name, CSysString &value);
+
+ #ifndef _UNICODE
+ LONG QueryValue(LPCWSTR name, LPWSTR value, UInt32 &dataSize);
+ LONG QueryValue(LPCWSTR name, UString &value);
+ #endif
+
+ LONG QueryValue(LPCTSTR name, void *value, UInt32 &dataSize);
+ LONG QueryValue(LPCTSTR name, CByteBuffer &value, UInt32 &dataSize);
+
+ LONG EnumKeys(CSysStringVector &keyNames);
+};
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/ResourceString.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/ResourceString.h
new file mode 100644
index 000000000..ac9c5cd5d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/ResourceString.h
@@ -0,0 +1,22 @@
+// Windows/ResourceString.h
+
+#ifndef __WINDOWS_RESOURCESTRING_H
+#define __WINDOWS_RESOURCESTRING_H
+
+#include "Common/MyString.h"
+
+namespace NWindows {
+
+CSysString MyLoadString(HINSTANCE hInstance, UINT resourceID);
+CSysString MyLoadString(UINT resourceID);
+#ifdef _UNICODE
+inline UString MyLoadStringW(HINSTANCE hInstance, UINT resourceID) { return MyLoadString(hInstance, resourceID); }
+inline UString MyLoadStringW(UINT resourceID) { return MyLoadString(resourceID); }
+#else
+UString MyLoadStringW(HINSTANCE hInstance, UINT resourceID);
+UString MyLoadStringW(UINT resourceID);
+#endif
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Shell.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Shell.h
new file mode 100644
index 000000000..f116b772b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Shell.h
@@ -0,0 +1,21 @@
+// Windows/Shell.h
+
+#ifndef __WINDOWS_SHELL_H
+#define __WINDOWS_SHELL_H
+
+#include <windows.h>
+// #include <shlobj.h>
+
+#include "Common/MyString.h"
+#include "Windows/Defs.h"
+
+
+namespace NWindows{
+namespace NShell{
+
+bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath);
+
+}}
+
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization.cpp
new file mode 100644
index 000000000..a0b123032
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization.cpp
@@ -0,0 +1,159 @@
+// Windows/Synchronization.cpp
+
+#include "StdAfx.h"
+
+#include "Synchronization.h"
+
+#ifdef ENV_UNIX
+// #define TRACEN(u) u;
+#define TRACEN(u) /* */
+
+#define MAGIC 0x1234CAFE
+class CSynchroTest
+{
+ int _magic;
+ public:
+ CSynchroTest() {
+ _magic = MAGIC;
+ }
+ void testConstructor() {
+ if (_magic != MAGIC) {
+ printf("ERROR : no constructors called during loading of plugins (please look at LINK_SHARED in makefile.machine)\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+};
+
+static CSynchroTest gbl_synchroTest;
+
+extern "C" void sync_TestConstructor(void) {
+ gbl_synchroTest.testConstructor();
+}
+
+
+namespace NWindows {
+namespace NSynchronization {
+
+
+#ifndef ENV_BEOS
+#ifdef DEBUG_SYNCHRO
+ void CSynchro::dump_error(int ligne,int ret,const char *text,void *param)
+ {
+ printf("\n##T%d#ERROR2 (l=%d) %s : param=%p ret = %d (%s)##\n",(int)pthread_self(),ligne,text,param,ret,strerror(ret));
+ // abort();
+ }
+ CSynchro::CSynchro() {
+ TRACEN((printf("\nT%d : E1-CSynchro(this=%p,m=%p,cond=%p)\n",(int)pthread_self(),(void *)this,(void *)&_object,(void *)&_cond)))
+ _isValid = false;
+ }
+
+ void CSynchro::Create() {
+ TRACEN((printf("\nT%d : E1-CSynchro::Create(this=%p,m=%p,cond=%p)\n",(int)pthread_self(),(void *)this,(void *)&_object,(void *)&_cond)))
+ pthread_mutexattr_t mutexattr;
+ memset(&mutexattr,0,sizeof(mutexattr));
+ int ret = pthread_mutexattr_init(&mutexattr);
+ if (ret != 0) {
+ dump_error(__LINE__,ret,"pthread_mutexattr_init",&mutexattr);
+ }
+ ret = pthread_mutexattr_settype(&mutexattr,PTHREAD_MUTEX_ERRORCHECK);
+ if (ret != 0) dump_error(__LINE__,ret,"pthread_mutexattr_settype",&mutexattr);
+ ret = ::pthread_mutex_init(&_object,&mutexattr);
+ if (ret != 0) dump_error(__LINE__,ret,"pthread_mutex_init",&_object);
+ ret = ::pthread_cond_init(&_cond,0);
+ if (ret != 0) dump_error(__LINE__,ret,"pthread_cond_init",&_cond);
+ TRACEN((printf("\nT%d : E2-CSynchro::Create(m=%p,cond=%p)\n",(int)pthread_self(),(void *)&_object,(void *)&_cond)))
+ }
+ CSynchro::~CSynchro() {
+ TRACEN((printf("\nT%d : E1-~CSynchro(this=%p,m=%p,cond=%p)\n",(int)pthread_self(),(void *)this,(void *)&_object,(void *)&_cond)))
+ if (_isValid) {
+ int ret = ::pthread_mutex_destroy(&_object);
+ if (ret != 0) dump_error(__LINE__,ret,"pthread_mutex_destroy",&_object);
+ ret = ::pthread_cond_destroy(&_cond);
+ if (ret != 0) dump_error(__LINE__,ret,"pthread_cond_destroy",&_cond);
+ TRACEN((printf("\nT%d : E2-~CSynchro(m=%p,cond=%p)\n",(int)pthread_self(),(void *)&_object,(void *)&_cond)))
+ }
+ _isValid = false;
+ }
+ void CSynchro::Enter() {
+ TRACEN((printf("\nT%d : E1-CSynchro::Enter(%p)\n",(int)pthread_self(),(void *)&_object)))
+ int ret = ::pthread_mutex_lock(&_object);
+ if (ret != 0) {
+ dump_error(__LINE__,ret,"CSynchro::Enter-pthread_mutex_lock",&_object);
+ }
+ TRACEN((printf("\nT%d : E2-CSynchro::Enter(%p)\n",(int)pthread_self(),(void *)&_object)))
+ }
+ void CSynchro::Leave() {
+ TRACEN((printf("\nT%d : E1-CSynchro::Leave(%p)\n",(int)pthread_self(),(void *)&_object)))
+ int ret = ::pthread_mutex_unlock(&_object);
+ if (ret != 0) dump_error(__LINE__,ret,"Leave::pthread_mutex_unlock",&_object);
+ TRACEN((printf("\nT%d : E2-CSynchro::Leave(%p)\n",(int)pthread_self(),(void *)&_object)))
+ }
+ void CSynchro::WaitCond() {
+ TRACEN((printf("\nT%d : E1-CSynchro::WaitCond(%p,%p)\n",(int)pthread_self(),(void *)&_cond,(void *)&_object)))
+ int ret = ::pthread_cond_wait(&_cond, &_object);
+ if (ret != 0) dump_error(__LINE__,ret,"pthread_cond_wait",&_cond);
+ TRACEN((printf("\nT%d : E2-CSynchro::WaitCond(%p,%p)\n",(int)pthread_self(),(void *)&_cond,(void *)&_object)))
+ }
+ void CSynchro::LeaveAndSignal() {
+ TRACEN((printf("\nT%d : E1-CSynchro::LeaveAndSignal(%p)\n",(int)pthread_self(),(void *)&_cond)))
+ int ret = ::pthread_cond_broadcast(&_cond);
+ if (ret != 0) dump_error(__LINE__,ret,"pthread_cond_broadcast",&_cond);
+ TRACEN((printf("\nT%d : E2-CSynchro::LeaveAndSignal(%p)\n",(int)pthread_self(),(void *)&_object)))
+ ret = ::pthread_mutex_unlock(&_object);
+ if (ret != 0) dump_error(__LINE__,ret,"LeaveAndSignal::pthread_mutex_unlock",&_object);
+ TRACEN((printf("\nT%d : E3-CSynchro::LeaveAndSignal(%p)\n",(int)pthread_self(),(void *)&_cond)))
+ }
+#endif
+#endif
+
+}}
+
+DWORD WINAPI WaitForMultipleObjects( DWORD count, const HANDLE *handles, BOOL wait_all, DWORD timeout )
+{
+ TRACEN((printf("\nT%d : E1-WaitForMultipleObjects(%d)\n",(int)pthread_self(),(int)count)))
+ if (wait_all != FALSE) {
+ printf("\n\n INTERNAL ERROR - WaitForMultipleObjects(...) wait_all(%d) != FALSE\n\n",(unsigned)wait_all);
+ abort();
+ }
+
+ if (timeout != INFINITE) {
+ printf("\n\n INTERNAL ERROR - WaitForMultipleObjects(...) timeout(%u) != INFINITE\n\n",(unsigned)timeout);
+ abort();
+ }
+
+ if (count < 1) {
+ printf("\n\n INTERNAL ERROR - WaitForMultipleObjects(...) count(%u) < 1\n\n",(unsigned)count);
+ abort();
+ }
+
+ NWindows::NSynchronization::CSynchro *synchro = handles[0]->_sync;
+
+ TRACEN((printf("\nT%d : E2-WaitForMultipleObjects(%d)\n",(int)pthread_self(),(int)count)))
+ synchro->Enter();
+ TRACEN((printf("\nT%d : E3-WaitForMultipleObjects(%d)\n",(int)pthread_self(),(int)count)))
+
+#ifdef DEBUG_SYNCHRO
+ for(DWORD i=1;i<count;i++) {
+ if (synchro != handles[i]->_sync) {
+ printf("\n\n INTERNAL ERROR - WaitForMultipleObjects(...) synchro(%p) != handles[%d]->_sync(%p)\n\n",
+ synchro,(unsigned)i,handles[i]->_sync);
+ abort();
+ }
+ }
+#endif
+
+ while(1) {
+ for(DWORD i=0;i<count;i++) {
+ if (handles[i]->IsSignaledAndUpdate()) {
+ synchro->Leave();
+ TRACEN((printf("\nT%d : E4-WaitForMultipleObjects(%d)\n",(int)pthread_self(),(int)count)))
+ return WAIT_OBJECT_0+i;
+ }
+ }
+ synchro->WaitCond();
+ }
+ synchro->Leave();
+ return ETIMEDOUT; // WAIT_TIMEOUT;
+}
+
+#endif \ No newline at end of file
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization.h
new file mode 100644
index 000000000..9525bdf2e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization.h
@@ -0,0 +1,187 @@
+// Windows/Synchronization.h
+
+#ifndef __WINDOWS_SYNCHRONIZATION_H
+#define __WINDOWS_SYNCHRONIZATION_H
+
+#include "Defs.h"
+
+extern "C"
+{
+#include "../../C/Threads.h"
+}
+
+#ifdef _WIN32
+#include "Handle.h"
+#endif
+
+namespace NWindows {
+namespace NSynchronization {
+
+class Uncopyable {
+protected:
+ Uncopyable() {} // allow construction
+ ~Uncopyable() {} // and destruction of derived objects...
+private:
+ Uncopyable(const Uncopyable&); // ...but prevent copying
+ Uncopyable& operator=(const Uncopyable&);
+};
+
+
+class CBaseEvent // FIXME : private Uncopyable
+{
+protected:
+ ::CEvent _object;
+public:
+ bool IsCreated() { return Event_IsCreated(&_object) != 0; }
+#ifdef _WIN32
+ operator HANDLE() { return _object.handle; }
+#endif
+ CBaseEvent() { Event_Construct(&_object); }
+ ~CBaseEvent() { Close(); }
+ WRes Close() { return Event_Close(&_object); }
+ #ifdef _WIN32
+ WRes Create(bool manualReset, bool initiallyOwn, LPCTSTR name = NULL,
+ LPSECURITY_ATTRIBUTES securityAttributes = NULL)
+ {
+ _object.handle = ::CreateEvent(securityAttributes, BoolToBOOL(manualReset),
+ BoolToBOOL(initiallyOwn), name);
+ if (_object.handle != 0)
+ return 0;
+ return ::GetLastError();
+ }
+ WRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name)
+ {
+ _object.handle = ::OpenEvent(desiredAccess, BoolToBOOL(inheritHandle), name);
+ if (_object.handle != 0)
+ return 0;
+ return ::GetLastError();
+ }
+ #endif
+
+ WRes Set() { return Event_Set(&_object); }
+ // bool Pulse() { return BOOLToBool(::PulseEvent(_handle)); }
+ WRes Reset() { return Event_Reset(&_object); }
+ WRes Lock() { return Event_Wait(&_object); }
+};
+
+class CManualResetEvent: public CBaseEvent
+{
+public:
+ WRes Create(bool initiallyOwn = false)
+ {
+ return ManualResetEvent_Create(&_object, initiallyOwn ? 1: 0);
+ }
+ WRes CreateIfNotCreated()
+ {
+ if (IsCreated())
+ return 0;
+ return ManualResetEvent_CreateNotSignaled(&_object);
+ }
+ #ifdef _WIN32
+ WRes CreateWithName(bool initiallyOwn, LPCTSTR name)
+ {
+ return CBaseEvent::Create(true, initiallyOwn, name);
+ }
+ #endif
+};
+
+class CAutoResetEvent: public CBaseEvent
+{
+public:
+ WRes Create()
+ {
+ return AutoResetEvent_CreateNotSignaled(&_object);
+ }
+ WRes CreateIfNotCreated()
+ {
+ if (IsCreated())
+ return 0;
+ return AutoResetEvent_CreateNotSignaled(&_object);
+ }
+};
+
+#ifdef _WIN32
+class CObject: public CHandle
+{
+public:
+ WRes Lock(DWORD timeoutInterval = INFINITE)
+ { return (::WaitForSingleObject(_handle, timeoutInterval) == WAIT_OBJECT_0 ? 0 : ::GetLastError()); }
+};
+class CMutex: public CObject
+{
+public:
+ WRes Create(bool initiallyOwn, LPCTSTR name = NULL,
+ LPSECURITY_ATTRIBUTES securityAttributes = NULL)
+ {
+ _handle = ::CreateMutex(securityAttributes, BoolToBOOL(initiallyOwn), name);
+ if (_handle != 0)
+ return 0;
+ return ::GetLastError();
+ }
+ WRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name)
+ {
+ _handle = ::OpenMutex(desiredAccess, BoolToBOOL(inheritHandle), name);
+ if (_handle != 0)
+ return 0;
+ return ::GetLastError();
+ }
+ WRes Release()
+ {
+ return ::ReleaseMutex(_handle) ? 0 : ::GetLastError();
+ }
+};
+class CMutexLock
+{
+ CMutex *_object;
+public:
+ CMutexLock(CMutex &object): _object(&object) { _object->Lock(); }
+ ~CMutexLock() { _object->Release(); }
+};
+#endif
+
+class CSemaphore : private Uncopyable
+{
+ ::CSemaphore _object;
+public:
+ CSemaphore() { Semaphore_Construct(&_object); }
+ ~CSemaphore() { Close(); }
+ WRes Close() { return Semaphore_Close(&_object); }
+#ifdef _WIN32
+ operator HANDLE() { return _object.handle; }
+#endif
+ WRes Create(UInt32 initiallyCount, UInt32 maxCount)
+ {
+ return Semaphore_Create(&_object, initiallyCount, maxCount);
+ }
+ WRes Release() { return Semaphore_Release1(&_object); }
+ WRes Release(UInt32 releaseCount) { return Semaphore_ReleaseN(&_object, releaseCount); }
+ WRes Lock() { return Semaphore_Wait(&_object); }
+};
+
+class CCriticalSection : private Uncopyable
+{
+ ::CCriticalSection _object;
+public:
+ CCriticalSection() { CriticalSection_Init(&_object); }
+ ~CCriticalSection() { CriticalSection_Delete(&_object); }
+ void Enter() { CriticalSection_Enter(&_object); }
+ void Leave() { CriticalSection_Leave(&_object); }
+};
+
+class CCriticalSectionLock : private Uncopyable
+{
+ CCriticalSection *_object;
+ void Unlock() { _object->Leave(); }
+public:
+ CCriticalSectionLock(CCriticalSection &object): _object(&object) {_object->Enter(); }
+ ~CCriticalSectionLock() { Unlock(); }
+};
+
+}}
+
+//#ifndef _WIN32
+#include "Synchronization2.h"
+//#endif
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization2.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization2.h
new file mode 100644
index 000000000..6b6f06345
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Synchronization2.h
@@ -0,0 +1,264 @@
+// Windows/Synchronization.h
+
+#ifdef ENV_BEOS
+#include <Locker.h>
+#include <kernel/OS.h>
+#include <list>
+#endif
+
+/* Remark : WFMO = WaitForMultipleObjects */
+
+namespace NWindows { namespace NSynchronization { struct CBaseHandleWFMO; } }
+
+#ifdef ENV_UNIX
+typedef NWindows::NSynchronization::CBaseHandleWFMO *HANDLE;
+
+DWORD WINAPI WaitForMultipleObjects( DWORD count, const HANDLE *handles, BOOL wait_all, DWORD timeout );
+#endif
+
+namespace NWindows {
+namespace NSynchronization {
+
+#ifdef ENV_BEOS
+class CSynchro : BLocker, private Uncopyable
+{
+#define MAX_THREAD 256
+ thread_id _waiting[MAX_THREAD]; // std::list<thread_id> _waiting;
+ int index_waiting;
+public:
+ CSynchro() { index_waiting = 0; }
+ void Create() { index_waiting = 0; }
+ ~CSynchro() {}
+ void Enter() { Lock(); }
+ void Leave() { Unlock(); }
+ void WaitCond() {
+ _waiting[index_waiting++] = find_thread(NULL); // _waiting.push_back(find_thread(NULL));
+ thread_id sender;
+ Unlock();
+ int msg = receive_data(&sender, NULL, 0);
+ Lock();
+ }
+ void LeaveAndSignal() {
+ // Unlock();
+ // Lock();
+ // for (std::list<thread_id>::iterator index = _waiting.begin(); index != _waiting.end(); index++)
+ for(int index = 0 ; index < index_waiting ; index++)
+ {
+ send_data(_waiting[index], '7zCN', NULL, 0);
+ }
+ index_waiting = 0; // _waiting.clear();
+ Unlock();
+ }
+};
+#else // #ifdef ENV_BEOS
+#ifdef DEBUG_SYNCHRO
+class CSynchro: private Uncopyable
+{
+ pthread_mutex_t _object;
+ pthread_cond_t _cond;
+ bool _isValid;
+ void dump_error(int ligne,int ret,const char *text,void *param);
+public:
+ CSynchro();
+ ~CSynchro();
+ void Create();
+ void Enter();
+ void Leave();
+ void WaitCond();
+ void LeaveAndSignal();
+};
+#else // #ifdef DEBUG_SYNCHRO
+#ifdef ENV_UNIX
+class CSynchro : private Uncopyable
+{
+ pthread_mutex_t _object;
+ pthread_cond_t _cond;
+ bool _isValid;
+public:
+ CSynchro() { _isValid = false; }
+ ~CSynchro() {
+ if (_isValid) {
+ ::pthread_mutex_destroy(&_object);
+ ::pthread_cond_destroy(&_cond);
+ }
+ _isValid = false;
+ }
+ void Create() {
+ ::pthread_mutex_init(&_object,0);
+ ::pthread_cond_init(&_cond,0);
+ }
+ void Enter() {
+ ::pthread_mutex_lock(&_object);
+ }
+ void Leave() {
+ ::pthread_mutex_unlock(&_object);
+ }
+ void WaitCond() {
+ ::pthread_cond_wait(&_cond, &_object);
+ }
+ void LeaveAndSignal() {
+ ::pthread_cond_broadcast(&_cond);
+ ::pthread_mutex_unlock(&_object);
+ }
+};
+#else
+class CSynchro : private Uncopyable
+{
+ HANDLE mutex;
+ HANDLE event;
+public:
+ CSynchro()
+ : mutex( 0 )
+ {
+ }
+ ~CSynchro()
+ {
+ if( mutex != 0 )
+ CloseHandle( mutex );
+ if( event != 0 )
+ CloseHandle( event );
+ }
+
+ void Create()
+ {
+ mutex = CreateMutex( NULL, false, NULL );
+ event = CreateEvent( NULL, true, false, NULL );
+ }
+ void Enter()
+ {
+ WaitForSingleObject( mutex, INFINITE );
+ }
+ void Leave()
+ {
+ ReleaseMutex( mutex );
+ }
+ void WaitCond()
+ {
+ WaitForSingleObject( event, INFINITE );
+ }
+ void LeaveAndSignal()
+ {
+ SetEvent( event );
+ Leave();
+ }
+};
+#endif
+#endif // #ifdef DEBUG_SYNCHRO
+#endif // #ifdef ENV_BEOS
+
+struct CBaseHandleWFMO // FIXME : private Uncopyable
+{
+ CSynchro *_sync;
+
+ CBaseHandleWFMO() { }
+ virtual ~CBaseHandleWFMO() {}
+
+ operator HANDLE() { return this; }
+ virtual bool IsSignaledAndUpdate() = 0;
+};
+
+class CBaseEventWFMO : public CBaseHandleWFMO
+{
+ bool _manual_reset;
+ bool _state;
+
+public:
+
+ bool IsCreated() { return (this->_sync != 0); }
+ CBaseEventWFMO() { this->_sync = 0; }
+ ~CBaseEventWFMO() { Close(); }
+
+ WRes Close() { this->_sync = 0; return S_OK; }
+
+ WRes Create(CSynchro *sync,bool manualReset, bool initiallyOwn)
+ {
+ this->_sync = sync;
+ this->_manual_reset = manualReset;
+ this->_state = initiallyOwn;
+ return S_OK;
+ }
+
+ WRes Set() {
+ this->_sync->Enter();
+ this->_state = true;
+ this->_sync->LeaveAndSignal();
+ return S_OK;
+ }
+
+ WRes Reset() {
+ this->_sync->Enter();
+ this->_state = false;
+ this->_sync->Leave();
+ return S_OK;
+ }
+ virtual bool IsSignaledAndUpdate() {
+ if (this->_state == true) {
+ if (this->_manual_reset == false) this->_state = false;
+ return true;
+ }
+ return false;
+ }
+};
+
+class CManualResetEventWFMO: public CBaseEventWFMO
+{
+public:
+ WRes Create(CSynchro *sync,bool initiallyOwn = false) { return CBaseEventWFMO::Create(sync,true, initiallyOwn); }
+};
+
+class CAutoResetEventWFMO: public CBaseEventWFMO
+{
+public:
+ WRes Create(CSynchro *sync) { return CBaseEventWFMO::Create(sync,false, false); }
+ WRes CreateIfNotCreated(CSynchro *sync)
+ {
+ if (IsCreated())
+ return 0;
+ return CBaseEventWFMO::Create(sync,false, false);
+ }
+};
+
+class CSemaphoreWFMO : public CBaseHandleWFMO
+{
+ LONG _count;
+ LONG _maxCount;
+
+public:
+ CSemaphoreWFMO() : _count(0), _maxCount(0) { this->_sync=0;}
+ WRes Create(CSynchro *sync,LONG initiallyCount, LONG maxCount)
+ {
+ if ((initiallyCount < 0) || (initiallyCount > maxCount) || (maxCount < 1)) return S_FALSE;
+ this->_sync = sync;
+ this->_count = initiallyCount;
+ this->_maxCount = maxCount;
+ return S_OK;
+ }
+ WRes Release(LONG releaseCount = 1) {
+ if (releaseCount < 1) return S_FALSE;
+
+ this->_sync->Enter();
+ LONG newCount = this->_count + releaseCount;
+ if (newCount > this->_maxCount)
+ {
+ this->_sync->Leave();
+ return S_FALSE;
+ }
+ this->_count = newCount;
+
+ this->_sync->LeaveAndSignal();
+
+ return S_OK;
+ }
+ WRes Close() { this->_sync=0; return S_OK; }
+
+ virtual bool IsSignaledAndUpdate() {
+ if (this->_count > 0) {
+ this->_count--;
+ return true;
+ }
+ return false;
+ }
+};
+
+}}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/System.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/System.cpp
new file mode 100644
index 000000000..e3f06b0db
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/System.cpp
@@ -0,0 +1,178 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#if defined (__NetBSD__) || defined(__OpenBSD__) || defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#elif defined(__linux__) || defined(__CYGWIN__) || defined(sun) || defined(__NETWARE__)
+#include <unistd.h>
+#elif defined(hpux) || defined(__hpux)
+#include <sys/param.h>
+#include <sys/pstat.h>
+#endif
+
+#if defined(__NETWARE__)
+#include <sys/sysinfo.h>
+#endif
+
+#if defined(ENV_BEOS)
+#include <be/kernel/OS.h>
+#endif
+
+
+#include "Common/Types.h"
+
+namespace NWindows
+{
+ namespace NSystem
+ {
+ /************************ GetNumberOfProcessors ************************/
+
+ #if defined (__NetBSD__) || defined(__OpenBSD__)
+ UInt32 GetNumberOfProcessors() {
+ int mib[2], value;
+ int nbcpu = 1;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+ size_t len = sizeof(size_t);
+ if (sysctl(mib, 2, &value, &len, NULL, 0) >= 0)
+ if (value > nbcpu)
+ nbcpu = value;
+ return nbcpu;
+ }
+ #elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+ UInt32 GetNumberOfProcessors() {
+ int nbcpu = 1;
+ size_t value;
+ size_t len = sizeof(value);
+ if (sysctlbyname("hw.ncpu", &value, &len, NULL, 0) == 0)
+ nbcpu = value;
+ return nbcpu;
+ }
+ #elif defined (__APPLE__)
+ UInt32 GetNumberOfProcessors() {
+ int nbcpu = 1,value;
+ size_t valSize = sizeof(value);
+ if (sysctlbyname ("hw.ncpu", &value, &valSize, NULL, 0) == 0)
+ nbcpu = value;
+ return nbcpu;
+ }
+
+ #elif defined(__linux__) || defined(__CYGWIN__) || defined(sun)
+ UInt32 GetNumberOfProcessors() {
+ int nbcpu = sysconf (_SC_NPROCESSORS_CONF);
+ if (nbcpu < 1) nbcpu = 1;
+ return nbcpu;
+ }
+ #elif defined(hpux) || defined(__hpux)
+ UInt32 GetNumberOfProcessors() {
+ struct pst_dynamic psd;
+ if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) != -1)
+ return (UInt32)psd.psd_proc_cnt;
+ return 1;
+ }
+ #elif defined(__NETWARE__)
+ UInt32 GetNumberOfProcessors() {
+ // int nbcpu = get_nprocs_conf();
+ int nbcpu = get_nprocs();
+ if (nbcpu < 1) nbcpu = 1;
+ return nbcpu;
+ }
+ #elif defined(ENV_BEOS)
+ UInt32 GetNumberOfProcessors() {
+ system_info info;
+ get_system_info(&info);
+ int nbcpu = info.cpu_count;
+ if (nbcpu < 1) nbcpu = 1;
+ return nbcpu;
+ }
+ #elif defined(WIN32)
+ UInt32 GetNumberOfProcessors()
+ {
+ SYSTEM_INFO systemInfo;
+ GetSystemInfo( &systemInfo );
+ return (UInt32)systemInfo.dwNumberOfProcessors;
+ }
+ #else
+ #warning Generic GetNumberOfProcessors
+ UInt32 GetNumberOfProcessors() {
+ return 1;
+ }
+ #endif
+
+ /************************ GetRamSize ************************/
+ UInt64 GetRamSize() {
+ UInt64 ullTotalPhys = 128 * 1024 * 1024; // default : 128MB
+
+#ifdef linux
+ FILE * f = fopen( "/proc/meminfo", "r" );
+ if (f)
+ {
+ char buffer[256];
+ unsigned long total;
+
+ ullTotalPhys = 0;
+
+ while (fgets( buffer, sizeof(buffer), f ))
+ {
+ /* old style /proc/meminfo ... */
+ if (sscanf( buffer, "Mem: %lu", &total))
+ {
+ ullTotalPhys += total;
+ }
+
+ /* new style /proc/meminfo ... */
+ if (sscanf(buffer, "MemTotal: %lu", &total))
+ ullTotalPhys = ((UInt64)total)*1024;
+ }
+ fclose( f );
+ }
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__APPLE__)
+#ifdef HW_MEMSIZE
+ uint64_t val = 0; // support 2Gb+ RAM
+ int mib[2] = { CTL_HW, HW_MEMSIZE };
+#else // HW_MEMSIZE
+ unsigned int val = 0; // For old system
+ int mib[2] = { CTL_HW, HW_PHYSMEM };
+#endif // HW_MEMSIZE
+ size_t size_sys = sizeof(val);
+
+ sysctl(mib, 2, &val, &size_sys, NULL, 0);
+ if (val) ullTotalPhys = val;
+#elif defined(__CYGWIN__)
+ unsigned long pagesize=4096; // FIXME - sysconf(_SC_PAGESIZE) returns 65536 !?
+ // see http://readlist.com/lists/cygwin.com/cygwin/0/3313.html
+ unsigned long maxpages=sysconf(_SC_PHYS_PAGES);
+ ullTotalPhys = ((UInt64)pagesize)*maxpages;
+#elif defined ( sun ) || defined(__NETWARE__)
+ unsigned long pagesize=sysconf(_SC_PAGESIZE);
+ unsigned long maxpages=sysconf(_SC_PHYS_PAGES);
+ ullTotalPhys = ((UInt64)pagesize)*maxpages;
+#elif defined(hpux) || defined(__hpux)
+ struct pst_static pst;
+ union pstun pu;
+
+ pu.pst_static = &pst;
+ if ( pstat( PSTAT_STATIC, pu, (size_t)sizeof(pst), (size_t)0, 0 ) != -1 ) {
+ ullTotalPhys = ((UInt64)pst.physical_memory)*pst.page_size;
+ }
+#elif defined(ENV_BEOS)
+ system_info info;
+ get_system_info(&info);
+ ullTotalPhys = info.max_pages;
+ ullTotalPhys *= 4096;
+#elif defined(WIN32)
+ MEMORYSTATUSEX stat;
+ stat.dwLength = sizeof(stat);
+ GlobalMemoryStatusEx(&stat);
+ return stat.ullTotalPhys;
+#else
+#warning Generic GetRamSize
+#endif
+ return ullTotalPhys;
+ }
+
+ }
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/System.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/System.h
new file mode 100644
index 000000000..e0067158f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/System.h
@@ -0,0 +1,16 @@
+// Windows/System.h
+
+#ifndef __WINDOWS_SYSTEM_H
+#define __WINDOWS_SYSTEM_H
+
+#include "../Common/Types.h"
+
+namespace NWindows {
+namespace NSystem {
+
+UInt32 GetNumberOfProcessors();
+UInt64 GetRamSize();
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Thread.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Thread.h
new file mode 100644
index 000000000..9c4276084
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Thread.h
@@ -0,0 +1,38 @@
+// Windows/Thread.h
+
+#ifndef __WINDOWS_THREAD_H
+#define __WINDOWS_THREAD_H
+
+#include "Defs.h"
+
+extern "C"
+{
+#include "../../C/Threads.h"
+}
+
+namespace NWindows {
+
+class CThread
+{
+ ::CThread thread;
+public:
+ CThread() { Thread_Construct(&thread); }
+ ~CThread() { Close(); }
+ bool IsCreated() { return Thread_WasCreated(&thread) != 0; }
+ WRes Close() { return Thread_Close(&thread); }
+ WRes Create(THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
+ { return Thread_Create(&thread, startAddress, parameter); }
+ WRes Wait() { return Thread_Wait(&thread); }
+
+ #ifdef _WIN32
+ DWORD Resume() { return ::ResumeThread(thread.handle); }
+ DWORD Suspend() { return ::SuspendThread(thread.handle); }
+ bool Terminate(DWORD exitCode) { return BOOLToBool(::TerminateThread(thread.handle, exitCode)); }
+ int GetPriority() { return ::GetThreadPriority(thread.handle); }
+ bool SetPriority(int priority) { return BOOLToBool(::SetThreadPriority(thread.handle, priority)); }
+ #endif
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Time.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Time.cpp
new file mode 100644
index 000000000..810dcbe23
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Time.cpp
@@ -0,0 +1,86 @@
+// Windows/Time.cpp
+
+#include "StdAfx.h"
+
+#include "Time.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NTime {
+
+bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime)
+{
+ return BOOLToBool(::DosDateTimeToFileTime((UInt16)(dosTime >> 16), (UInt16)(dosTime & 0xFFFF), &fileTime));
+}
+
+static const UInt32 kHighDosTime = 0xFF9FBF7D;
+static const UInt32 kLowDosTime = 0x210000;
+
+bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime)
+{
+ WORD datePart, timePart;
+ if (!::FileTimeToDosDateTime(&fileTime, &datePart, &timePart))
+ {
+ dosTime = (fileTime.dwHighDateTime >= 0x01C00000) ? kHighDosTime : kLowDosTime;
+ return false;
+ }
+ dosTime = (((UInt32)datePart) << 16) + timePart;
+ return true;
+}
+
+static const UInt32 kNumTimeQuantumsInSecond = 10000000;
+static const UInt64 kUnixTimeStartValue = ((UInt64)kNumTimeQuantumsInSecond) * 60 * 60 * 24 * 134774;
+
+void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime)
+{
+ UInt64 v = kUnixTimeStartValue + ((UInt64)unixTime) * kNumTimeQuantumsInSecond;
+ fileTime.dwLowDateTime = (DWORD)v;
+ fileTime.dwHighDateTime = (DWORD)(v >> 32);
+}
+
+bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime)
+{
+ UInt64 winTime = (((UInt64)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime;
+ if (winTime < kUnixTimeStartValue)
+ {
+ unixTime = 0;
+ return false;
+ }
+ winTime = (winTime - kUnixTimeStartValue) / kNumTimeQuantumsInSecond;
+ if (winTime > 0xFFFFFFFF)
+ {
+ unixTime = 0xFFFFFFFF;
+ return false;
+ }
+ unixTime = (UInt32)winTime;
+ return true;
+}
+
+bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day,
+ unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds)
+{
+ resSeconds = 0;
+ if (year < 1601 || year >= 10000 || month < 1 || month > 12 ||
+ day < 1 || day > 31 || hour > 23 || min > 59 || sec > 59)
+ return false;
+ UInt32 numYears = year - 1601;
+ UInt32 numDays = numYears * 365 + numYears / 4 - numYears / 100 + numYears / 400;
+ Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+ if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
+ ms[1] = 29;
+ month--;
+ for (unsigned i = 0; i < month; i++)
+ numDays += ms[i];
+ numDays += day - 1;
+ resSeconds = ((UInt64)(numDays * 24 + hour) * 60 + min) * 60 + sec;
+ return true;
+}
+
+void GetCurUtcFileTime(FILETIME &ft)
+{
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st, &ft);
+}
+
+}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Time.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Time.h
new file mode 100644
index 000000000..6f510b22b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Time.h
@@ -0,0 +1,21 @@
+// Windows/Time.h
+
+#ifndef __WINDOWS_TIME_H
+#define __WINDOWS_TIME_H
+
+#include "Common/Types.h"
+
+namespace NWindows {
+namespace NTime {
+
+bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime);
+bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime);
+void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime);
+bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime);
+bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day,
+ unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds);
+void GetCurUtcFileTime(FILETIME &ft);
+
+}}
+
+#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Window.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Window.cpp
new file mode 100644
index 000000000..5f6d2f3e9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Window.cpp
@@ -0,0 +1,92 @@
+// Windows/Window.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+#include "Windows/Window.h"
+
+class LockGUI
+{
+ bool _IsMain;
+ public:
+ LockGUI() {
+ _IsMain = wxThread::IsMain();
+ if (!_IsMain) wxMutexGuiEnter();
+ }
+ ~LockGUI() { if (!_IsMain) wxMutexGuiLeave(); }
+};
+
+namespace NWindows {
+
+HWND GetDlgItem(HWND dialogWindow, int ControlID)
+{
+ LockGUI lock;
+ if (dialogWindow) return dialogWindow->FindWindow(ControlID);
+ return 0;
+}
+
+void MySetWindowText(HWND wnd, LPCWSTR s)
+{
+ if (wnd == 0) return;
+
+ LockGUI lock;
+
+ wxString str = s;
+ /*
+ int id = wnd->GetId();
+ if ( (id != wxID_OK) && (id != wxID_CANCEL) && (id != wxID_HELP) && (id != wxID_YES) && (id != wxID_NO))
+ */
+ {
+ wnd->SetLabel(str);
+ }
+}
+
+ bool CWindow::GetText(CSysString &s)
+ {
+ wxString str;
+ {
+ LockGUI lock;
+ str = _window->GetLabel();
+ }
+ s = str;
+ return true;
+ }
+
+ bool CWindow::IsEnabled()
+ {
+ LockGUI lock;
+ return _window->IsEnabled();
+ }
+}
+
+////////////////////////////////// Windows Compatibility
+#include <sys/resource.h>
+
+void Sleep(unsigned millisec)
+{
+ wxMilliSleep(millisec);
+}
+
+t_processID GetCurrentProcess(void) {
+ return getpid();
+}
+
+void SetPriorityClass(t_processID pid , int priority) {
+ setpriority(PRIO_PROCESS,pid,priority);
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Window.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Window.h
new file mode 100644
index 000000000..1970fe62d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/Windows/Window.h
@@ -0,0 +1,43 @@
+// Windows/Window.h
+
+#ifndef __WINDOWS_WINDOW_H
+#define __WINDOWS_WINDOW_H
+
+#include "Windows/Defs.h"
+#include "Common/MyString.h"
+
+namespace NWindows {
+
+HWND GetDlgItem(HWND dialogWindow, int ControlID);
+void MySetWindowText(HWND wnd, LPCWSTR s);
+
+class CWindow
+{
+private:
+ // bool ModifyStyleBase(int styleOffset, DWORD remove, DWORD add, UINT flags);
+protected:
+ HWND _window;
+public:
+ CWindow(HWND newWindow = NULL): _window(newWindow){};
+ CWindow& operator=(HWND newWindow)
+ {
+ _window = newWindow;
+ return *this;
+ }
+ operator HWND() const { return _window; }
+ void Attach(HWND newWindow) { _window = newWindow; }
+ HWND Detach()
+ {
+ HWND window = _window;
+ _window = NULL;
+ return window;
+ }
+ virtual void SetText(LPCWSTR s) { MySetWindowText(_window, s); }
+ virtual bool GetText(CSysString &s);
+ bool IsEnabled();
+};
+
+}
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/basetyps.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/basetyps.h
new file mode 100644
index 000000000..365785253
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/basetyps.h
@@ -0,0 +1,19 @@
+#ifndef _BASETYPS_H
+#define _BASETYPS_H
+
+#ifdef HAVE_GCCVISIBILITYPATCH
+ #define DLLEXPORT __attribute__ ((visibility("default")))
+ #else
+ #define DLLEXPORT
+ #endif
+
+#ifdef __cplusplus
+#define STDAPI extern "C" DLLEXPORT HRESULT
+#else
+#define STDAPI extern DLLEXPORT HRESULT
+#endif /* __cplusplus */
+
+typedef GUID IID;
+typedef GUID CLSID;
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/tchar.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/tchar.h
new file mode 100644
index 000000000..4aa1a4f8e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/tchar.h
@@ -0,0 +1,89 @@
+/*
+ * tchar.h
+ *
+ * Unicode mapping layer for the standard C library. By including this
+ * file and using the 't' names for string functions
+ * (eg. _tprintf) you can make code which can be easily adapted to both
+ * Unicode and non-unicode environments. In a unicode enabled compile define
+ * _UNICODE before including tchar.h, otherwise the standard non-unicode
+ * library functions will be used.
+ *
+ * Note that you still need to include string.h or stdlib.h etc. to define
+ * the appropriate functions. Also note that there are several defines
+ * included for non-ANSI functions which are commonly available (but using
+ * the convention of prepending an underscore to non-ANSI library function
+ * names).
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAIMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $Revision: 1.11 $
+ * $Author: earnie $
+ * $Date: 2003/05/03 13:48:46 $
+ *
+ */
+
+#ifndef _TCHAR_H_
+#define _TCHAR_H_
+
+/* All the headers include this file. */
+#ifndef __int64
+#define __int64 long long
+#endif
+
+#ifndef __cdecl
+#define __cdecl /* */
+#endif
+
+/*
+ * NOTE: This tests _UNICODE, which is different from the UNICODE define
+ * used to differentiate Win32 API calls.
+ */
+#ifdef _UNICODE
+
+
+/*
+ * Use TCHAR instead of char or wchar_t. It will be appropriately translated
+ * if _UNICODE is correctly defined (or not).
+ */
+#ifndef _TCHAR_DEFINED
+typedef wchar_t TCHAR;
+#define _TCHAR_DEFINED
+#endif
+
+/*
+ * Unicode functions
+ */
+/*
+#define _tfopen _wfopen
+FILE *_wfopen( const wchar_t *filename, const wchar_t *mode );
+*/
+
+#else /* Not _UNICODE */
+
+#define _tfopen fopen
+
+/*
+ * TCHAR, the type you should use instead of char.
+ */
+#ifndef _TCHAR_DEFINED
+typedef char TCHAR;
+#define _TCHAR_DEFINED
+#endif
+
+#endif /* Not _UNICODE */
+
+#endif /* Not _TCHAR_H_ */
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/windows.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/windows.h
new file mode 100644
index 000000000..ef0ca3d19
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/include_windows/windows.h
@@ -0,0 +1,194 @@
+/*
+ windows.h - main header file for the Win32 API
+
+ Written by Anders Norlander <anorland@hem2.passagen.se>
+
+ This file is part of a free library for the Win32 API.
+
+ This library 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.
+
+*/
+#ifndef _WINDOWS_H
+#define _WINDOWS_H
+
+#include <stdarg.h>
+
+/* BEGIN #include <windef.h> */
+
+#include "Common/MyWindows.h" // FIXED
+
+#ifndef CONST
+#define CONST const
+#endif
+
+#undef MAX_PATH
+#define MAX_PATH 4096 /* Linux : 4096 - Windows : 260 */
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#define WINAPI
+
+#undef BOOL
+typedef int BOOL;
+
+/* BEGIN #include <winnt.h> */
+/* BEGIN <winerror.h> */
+#define NO_ERROR 0L
+#define ERROR_ALREADY_EXISTS EEXIST
+#define ERROR_FILE_EXISTS EEXIST
+#define ERROR_INVALID_HANDLE EBADF
+#define ERROR_PATH_NOT_FOUND ENOENT
+#define ERROR_DISK_FULL ENOSPC
+#define ERROR_NO_MORE_FILES 0x100123 // FIXME
+
+/* see Common/WyWindows.h
+#define S_OK ((HRESULT)0x00000000L)
+#define S_FALSE ((HRESULT)0x00000001L)
+#define E_INVALIDARG ((HRESULT)0x80070057L)
+#define E_NOTIMPL ((HRESULT)0x80004001L)
+#define E_NOINTERFACE ((HRESULT)0x80004002L)
+#define E_ABORT ((HRESULT)0x80004004L)
+#define E_FAIL ((HRESULT)0x80004005L)
+#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
+#define STG_E_INVALIDFUNCTION ((HRESULT)0x80030001L)
+#define SUCCEEDED(Status) ((HRESULT)(Status) >= 0)
+#define FAILED(Status) ((HRESULT)(Status)<0)
+*/
+#ifndef VOID
+#define VOID void
+#endif
+typedef void *PVOID,*LPVOID;
+typedef WCHAR *LPWSTR;
+typedef CHAR *LPSTR;
+typedef TCHAR *LPTSTR;
+
+#ifdef UNICODE
+/*
+ * P7ZIP_TEXT is a private macro whose specific use is to force the expansion of a
+ * macro passed as an argument to the macro TEXT. DO NOT use this
+ * macro within your programs. It's name and function could change without
+ * notice.
+ */
+#define P7ZIP_TEXT(q) L##q
+#else
+#define P7ZIP_TEXT(q) q
+#endif
+/*
+ * UNICODE a constant string when UNICODE is defined, else returns the string
+ * unmodified.
+ * The corresponding macros _TEXT() and _T() for mapping _UNICODE strings
+ * passed to C runtime functions are defined in mingw/tchar.h
+ */
+#define TEXT(q) P7ZIP_TEXT(q)
+
+typedef BYTE BOOLEAN;
+
+/* BEGIN #include <basetsd.h> */
+#ifndef __int64
+#define __int64 long long
+#endif
+typedef unsigned __int64 UINT64;
+typedef __int64 INT64;
+/* END #include <basetsd.h> */
+
+#define FILE_ATTRIBUTE_READONLY 1
+#define FILE_ATTRIBUTE_HIDDEN 2
+#define FILE_ATTRIBUTE_SYSTEM 4
+#define FILE_ATTRIBUTE_DIRECTORY 16
+#define FILE_ATTRIBUTE_ARCHIVE 32
+#define FILE_ATTRIBUTE_DEVICE 64
+#define FILE_ATTRIBUTE_NORMAL 128
+#define FILE_ATTRIBUTE_TEMPORARY 256
+#define FILE_ATTRIBUTE_SPARSE_FILE 512
+#define FILE_ATTRIBUTE_REPARSE_POINT 1024
+#define FILE_ATTRIBUTE_COMPRESSED 2048
+#define FILE_ATTRIBUTE_OFFLINE 0x1000
+#define FILE_ATTRIBUTE_ENCRYPTED 0x4000
+#define FILE_ATTRIBUTE_UNIX_EXTENSION 0x8000 /* trick for Unix */
+
+/* END <winerror.h> */
+
+#include <string.h>
+#include <stddef.h>
+
+/* END #include <winnt.h> */
+
+/* END #include <windef.h> */
+
+/* BEGIN #include <winbase.h> */
+
+#define WAIT_OBJECT_0 0
+#define INFINITE 0xFFFFFFFF
+
+typedef struct _SYSTEMTIME {
+ WORD wYear;
+ WORD wMonth;
+ WORD wDayOfWeek;
+ WORD wDay;
+ WORD wHour;
+ WORD wMinute;
+ WORD wSecond;
+ WORD wMilliseconds;
+} SYSTEMTIME;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+BOOL WINAPI DosDateTimeToFileTime(WORD,WORD,FILETIME *);
+BOOL WINAPI FileTimeToDosDateTime(CONST FILETIME *,WORD *, WORD *);
+BOOL WINAPI FileTimeToLocalFileTime(CONST FILETIME *,FILETIME *);
+BOOL WINAPI FileTimeToSystemTime(CONST FILETIME *,SYSTEMTIME *);
+BOOL WINAPI LocalFileTimeToFileTime(CONST FILETIME *,FILETIME *);
+VOID WINAPI GetSystemTime(SYSTEMTIME *);
+BOOL WINAPI SystemTimeToFileTime(const SYSTEMTIME*,FILETIME *);
+
+DWORD WINAPI GetTickCount(VOID);
+
+#ifdef __cplusplus
+}
+#endif
+/* END #include <winbase.h> */
+
+/* BEGIN #include <winnls.h> */
+
+#define CP_ACP 0
+#define CP_OEMCP 1
+#define CP_UTF8 65001
+
+/* #include <unknwn.h> */
+#include <basetyps.h>
+struct IEnumSTATPROPSTG;
+
+typedef struct tagSTATPROPSTG {
+ LPOLESTR lpwstrName;
+ PROPID propid;
+ VARTYPE vt;
+} STATPROPSTG;
+
+#ifdef __cplusplus
+extern "C" const IID IID_ISequentialStream;
+struct ISequentialStream : public IUnknown
+{
+ STDMETHOD(QueryInterface)(REFIID,PVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(void) PURE;
+ STDMETHOD_(ULONG,Release)(void) PURE;
+ STDMETHOD(Read)(void*,ULONG,ULONG*) PURE;
+ STDMETHOD(Write)(void const*,ULONG,ULONG*) PURE;
+};
+#else
+extern const IID IID_ISequentialStream;
+#endif /* __cplusplus */
+
+
+/* END #include <ole2.h> */
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/StdAfx.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/StdAfx.h
new file mode 100644
index 000000000..df7bd621e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/StdAfx.h
@@ -0,0 +1,109 @@
+// stdafx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#ifdef ENV_UNIX
+
+#include "config.h"
+
+
+#define NO_INLINE /* FIXME */
+
+#ifdef HAVE_PTHREAD
+#include <pthread.h>
+#endif
+
+#include "Common/MyWindows.h"
+#include "Common/Types.h"
+
+#include <windows.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <tchar.h>
+#include <wchar.h>
+#include <stddef.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <errno.h>
+#include <math.h>
+
+#ifdef __NETWARE__
+#include <sys/types.h>
+#endif
+
+#undef CS /* fix for Solaris 10 x86 */
+
+/***************************/
+
+#define CLASS_E_CLASSNOTAVAILABLE ((HRESULT)0x80040111L)
+
+/************************* LastError *************************/
+inline DWORD WINAPI GetLastError(void) { return errno; }
+inline void WINAPI SetLastError( DWORD err ) { errno = err; }
+
+#define AreFileApisANSI() (1)
+
+void Sleep(unsigned millisleep);
+
+typedef pid_t t_processID;
+
+t_processID GetCurrentProcess(void);
+
+#define NORMAL_PRIORITY_CLASS (0)
+#define IDLE_PRIORITY_CLASS (10)
+void SetPriorityClass(t_processID , int priority);
+
+#ifdef __cplusplus
+class wxWindow;
+typedef wxWindow *HWND;
+
+#define MB_ICONERROR (0x00000200) // wxICON_ERROR
+#define MB_YESNOCANCEL (0x00000002 | 0x00000008 | 0x00000010) // wxYES | wxNO | wxCANCEL
+#define MB_ICONQUESTION (0x00000400) // wxICON_QUESTION
+#define MB_TASKMODAL (0) // FIXME
+#define MB_SYSTEMMODAL (0) // FIXME
+
+#define MB_OK (0) // FIXME !
+#define MB_ICONSTOP (0) // FIXME !
+#define MB_OKCANCEL (0) // FIXME !
+
+#define MessageBox MessageBoxW
+int MessageBoxW(wxWindow * parent, const TCHAR * mes, const TCHAR * title,int flag);
+
+typedef void *HINSTANCE;
+
+typedef int INT_PTR; // FIXME 64 bits ?
+typedef unsigned int UINT_PTR; // FIXME 64 bits ?
+typedef long LONG_PTR; // FIXME 64 bits ?
+typedef long DWORD_PTR; // FIXME 64 bits ?
+typedef UINT_PTR WPARAM;
+
+/* WARNING
+ LPARAM shall be 'long' because of CListView::SortItems and wxListCtrl::SortItems :
+*/
+typedef LONG_PTR LPARAM;
+typedef LONG_PTR LRESULT;
+
+#define CALLBACK /* */
+
+/************ LANG ***********/
+typedef WORD LANGID;
+
+LANGID GetUserDefaultLangID(void);
+LANGID GetSystemDefaultLangID(void);
+
+#define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
+#define SUBLANGID(l) ((WORD)(l) >> 10)
+
+#endif
+
+#else
+
+//#include "afxv_w32.h"
+#include "windows.h"
+#endif
+
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/config.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/config.h
new file mode 100644
index 000000000..0683b6a13
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/config.h
@@ -0,0 +1,61 @@
+
+#if !defined(__DJGPP__)
+
+#ifndef __CYGWIN__
+ #define FILESYSTEM_IS_CASE_SENSITIVE 1
+#endif
+
+ #if !defined(ENV_MACOSX) && !defined(ENV_BEOS)
+
+ /* <wchar.h> */
+ /* HAVE_WCHAR__H and not HAVE_WCHAR_H to avoid warning with wxWidgets */
+ #define HAVE_WCHAR__H
+
+ /* <wctype.h> */
+ #define HAVE_WCTYPE_H
+
+ /* mbrtowc */
+/* #ifndef __hpux */
+/* #define HAVE_MBRTOWC */
+/* #endif */
+
+ /* towupper */
+ #define HAVE_TOWUPPER
+
+ #endif /* !ENV_MACOSX && !ENV_BEOS */
+
+ #if !defined(ENV_BEOS)
+ #define HAVE_GETPASS
+ #endif
+
+ /* lstat, readlink and S_ISLNK */
+ #define HAVE_LSTAT
+
+ /* <locale.h> */
+ #define HAVE_LOCALE
+
+ /* mbstowcs */
+ #define HAVE_MBSTOWCS
+
+ /* wcstombs */
+ #define HAVE_WCSTOMBS
+
+#endif /* !__DJGPP__ */
+
+#ifndef ENV_BEOS
+#define HAVE_PTHREAD
+#endif
+
+#if defined(ENV_MACOSX)
+#define LOCALE_IS_UTF8
+#endif
+
+#ifdef LOCALE_IS_UTF8
+#undef HAVE_LOCALE
+#undef HAVE_MBSTOWCS
+#undef HAVE_WCSTOMBS
+/* #undef HAVE_MBRTOWC */
+#endif
+
+#define MAX_PATHNAME_LEN 1024
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/initguid.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/initguid.h
new file mode 100644
index 000000000..f7580d571
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/initguid.h
@@ -0,0 +1,4 @@
+// initguid.h
+
+#include "Common/MyInitGuid.h"
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myAddExeFlag.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myAddExeFlag.cpp
new file mode 100644
index 000000000..8a468fca7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myAddExeFlag.cpp
@@ -0,0 +1,25 @@
+#include "StdAfx.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <windows.h>
+
+#define NEED_NAME_WINDOWS_TO_UNIX
+#include "myPrivate.h"
+
+#include "Common/StringConvert.h"
+
+
+void myAddExeFlag(LPCTSTR filename)
+{
+ const char * name = nameWindowToUnix(filename);
+ // printf("myAddExeFlag(%s)\n",name);
+ chmod(name,0700);
+}
+
+void myAddExeFlag(const UString &u_name)
+{
+ myAddExeFlag(UnicodeStringToMultiByte(u_name, CP_ACP));
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myGetTickCount.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myGetTickCount.cpp
new file mode 100644
index 000000000..6a6080b35
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myGetTickCount.cpp
@@ -0,0 +1,8 @@
+#include "StdAfx.h"
+
+#include <time.h>
+
+DWORD WINAPI GetTickCount(VOID) {
+ return (DWORD)time(0); // FIXME : but only for the seed of the random generator
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myPrivate.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myPrivate.h
new file mode 100644
index 000000000..aa7217cc1
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/myPrivate.h
@@ -0,0 +1,17 @@
+
+void WINAPI RtlSecondsSince1970ToFileTime( DWORD Seconds, FILETIME * ft );
+
+extern "C" int global_use_utf16_conversion;
+#ifdef HAVE_LSTAT
+extern "C" int global_use_lstat;
+#endif
+
+const char *my_getlocale(void);
+
+#ifdef NEED_NAME_WINDOWS_TO_UNIX
+static inline const char * nameWindowToUnix(const char * lpFileName) {
+ if ((lpFileName[0] == 'c') && (lpFileName[1] == ':')) return lpFileName+2;
+ return lpFileName;
+}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/mySplitCommandLine.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/mySplitCommandLine.cpp
new file mode 100644
index 000000000..84b00a8b7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/mySplitCommandLine.cpp
@@ -0,0 +1,82 @@
+#include "StdAfx.h"
+
+#include "../Common/StringConvert.h"
+
+#include "myPrivate.h"
+
+#ifdef HAVE_LOCALE
+#include <locale.h>
+#endif
+
+extern void my_windows_split_path(const AString &p_path, AString &dir , AString &base);
+
+void mySplitCommandLine(int numArguments,const char *arguments[],UStringVector &parts) {
+
+ { // define P7ZIP_HOME_DIR
+ static char p7zip_home_dir[MAX_PATH];
+ AString dir,name;
+ my_windows_split_path(arguments[0],dir,name);
+ snprintf(p7zip_home_dir,sizeof(p7zip_home_dir),"P7ZIP_HOME_DIR=%s/",(const char *)dir);
+ p7zip_home_dir[sizeof(p7zip_home_dir)-1] = 0;
+ putenv(p7zip_home_dir);
+ }
+
+#ifdef HAVE_LOCALE
+ // set the program's current locale from the user's environment variables
+ setlocale(LC_ALL,"");
+
+
+ // auto-detect which conversion p7zip should use
+ char *locale = setlocale(LC_CTYPE,0);
+ if (locale) {
+ size_t len = strlen(locale);
+ char *locale_upper = (char *)malloc(len+1);
+ if (locale_upper) {
+ strcpy(locale_upper,locale);
+
+ for(size_t i=0;i<len;i++)
+ locale_upper[i] = toupper(locale_upper[i] & 255);
+
+ if ( (strcmp(locale_upper,"") != 0)
+ && (strcmp(locale_upper,"C") != 0)
+ && (strcmp(locale_upper,"POSIX") != 0) ) {
+ global_use_utf16_conversion = 1;
+ }
+ free(locale_upper);
+ }
+ }
+#elif defined(LOCALE_IS_UTF8)
+ global_use_utf16_conversion = 1; // assume LC_CTYPE="utf8"
+#else
+ global_use_utf16_conversion = 0; // assume LC_CTYPE="C"
+#endif
+
+ parts.Clear();
+ for(int ind=0;ind < numArguments; ind++) {
+ if ((ind <= 2) && (strcmp(arguments[ind],"-no-utf16") == 0)) {
+ global_use_utf16_conversion = 0;
+ } else if ((ind <= 2) && (strcmp(arguments[ind],"-utf16") == 0)) {
+ global_use_utf16_conversion = 1;
+ } else {
+ UString tmp = MultiByteToUnicodeString(arguments[ind]);
+ // tmp.Trim(); " " is a valid filename ...
+ if (!tmp.IsEmpty()) {
+ parts.Add(tmp);
+ }
+ }
+ }
+}
+
+const char *my_getlocale(void) {
+#ifdef HAVE_LOCALE
+ const char* ret = setlocale(LC_CTYPE,0);
+ if (ret == 0)
+ ret ="C";
+ return ret;
+#elif defined(LOCALE_IS_UTF8)
+ return "utf8";
+#else
+ return "C";
+#endif
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/test_emul.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/test_emul.cpp
new file mode 100644
index 000000000..e3dd3e475
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/test_emul.cpp
@@ -0,0 +1,385 @@
+#undef BIG_ENDIAN
+#undef LITTLE_ENDIAN
+
+#include "StdAfx.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+
+#ifdef HAVE_WCHAR__H
+#include <wchar.h>
+#endif
+#ifdef HAVE_LOCALE
+#include <locale.h>
+#endif
+
+#include <windows.h>
+
+#define NEED_NAME_WINDOWS_TO_UNIX
+// #include "myPrivate.h"
+
+#include "Common/StringConvert.h"
+#include "Common/StdOutStream.h"
+
+#undef NDEBUG
+#include <assert.h>
+
+#include "Common/StringConvert.cpp"
+#include "Common/StdOutStream.cpp"
+#include "Common/IntToString.cpp"
+
+#include "Windows/Synchronization.cpp"
+#include "Windows/FileFind.cpp"
+#include "Windows/Time.cpp"
+#include "../C/Threads.c"
+
+using namespace NWindows;
+
+#if defined(HAVE_WCHAR__H) && defined(HAVE_MBSTOWCS) && defined(HAVE_WCSTOMBS)
+void test_mbs(void) {
+ wchar_t wstr1[256] = {
+ L'e',
+ 0xE8, // latin small letter e with grave
+ 0xE9, // latin small letter e with acute
+ L'a',
+ 0xE0, // latin small letter a with grave
+ 0x20AC, // euro sign
+ L'b',
+ 0 };
+ wchar_t wstr2[256];
+ char astr[256];
+
+ global_use_utf16_conversion = 1;
+
+ size_t len1 = wcslen(wstr1);
+
+ printf("wstr1 - %d - '%ls'\n",(int)len1,wstr1);
+
+ size_t len0 = wcstombs(astr,wstr1,sizeof(astr));
+ printf("astr - %d - '%s'\n",(int)len0,astr);
+
+ size_t len2 = mbstowcs(wstr2,astr,sizeof(wstr2)/sizeof(*wstr2));
+ printf("wstr - %d - '%ls'\n",(int)len2,wstr2);
+
+ if (wcscmp(wstr1,wstr2) != 0) {
+ printf("ERROR during conversions wcs -> mbs -> wcs\n");
+ exit(EXIT_FAILURE);
+ }
+
+ char *ptr = astr;
+ size_t len = 0;
+ while (*ptr) {
+ ptr = CharNextA(ptr);
+ len += 1;
+ }
+ if ((len != len1) && (len != 12)) { // 12 = when locale is UTF8 instead of ISO8859-15
+ printf("ERROR CharNextA : len=%d, len1=%d\n",(int)len,(int)len1);
+ exit(EXIT_FAILURE);
+ }
+
+ UString ustr(wstr1);
+ assert(ustr.Length() == (int)len1);
+
+ AString ansistr(astr);
+ assert(ansistr.Length() == (int)len0);
+
+ ansistr = UnicodeStringToMultiByte(ustr);
+ assert(ansistr.Length() == (int)len0);
+
+ assert(strcmp(ansistr,astr) == 0);
+ assert(wcscmp(ustr,wstr1) == 0);
+
+ UString ustr2 = MultiByteToUnicodeString(astr);
+ assert(ustr2.Length() == (int)len1);
+ assert(wcscmp(ustr2,wstr1) == 0);
+}
+#endif
+
+static void test_astring(int num) {
+ AString strResult;
+
+ strResult = "first part : ";
+ char number[256];
+ sprintf(number,"%d",num);
+ strResult += AString(number);
+
+ strResult += " : last part";
+
+ printf("strResult -%s-\n",(const char *)strResult);
+
+}
+
+
+extern void my_windows_split_path(const AString &p_path, AString &dir , AString &base);
+
+static struct {
+ const char *path;
+ const char *dir;
+ const char *base;
+}
+tabSplit[]=
+ {
+ { "",".","." },
+ { "/","/","/" },
+ { ".",".","." },
+ { "//","/","/" },
+ { "///","/","/" },
+ { "dir",".","dir" },
+ { "/dir","/","dir" },
+ { "/dir/","/","dir" },
+ { "/dir/base","/dir","base" },
+ { "/dir//base","/dir","base" },
+ { "/dir///base","/dir","base" },
+ { "//dir/base","//dir","base" },
+ { "///dir/base","///dir","base" },
+ { "/dir/base/","/dir","base" },
+ { 0,0,0 }
+ };
+
+static void test_split_astring() {
+ int ind = 0;
+ while (tabSplit[ind].path) {
+ AString path(tabSplit[ind].path);
+ AString dir;
+ AString base;
+
+ my_windows_split_path(path,dir,base);
+
+ if ((dir != tabSplit[ind].dir) || (base != tabSplit[ind].base)) {
+ printf("ERROR : '%s' '%s' '%s'\n",(const char *)path,(const char *)dir,(const char *)base);
+ }
+ ind++;
+ }
+ printf("test_split_astring : done\n");
+}
+
+ // Number of 100 nanosecond units from 1/1/1601 to 1/1/1970
+#define EPOCH_BIAS 116444736000000000LL
+static LARGE_INTEGER UnixTimeToUL(time_t tps_unx)
+{
+ LARGE_INTEGER ul;
+ ul.QuadPart = tps_unx * 10000000LL + EPOCH_BIAS;
+ return ul;
+}
+
+static LARGE_INTEGER FileTimeToUL(FILETIME fileTime)
+{
+ LARGE_INTEGER lFileTime;
+ lFileTime.QuadPart = fileTime.dwHighDateTime;
+ lFileTime.QuadPart = (lFileTime.QuadPart << 32) | fileTime.dwLowDateTime;
+ return lFileTime;
+}
+
+static void display(const char *txt,SYSTEMTIME systime)
+{
+ FILETIME fileTime;
+ BOOL ret = SystemTimeToFileTime(&systime,&fileTime);
+ assert(ret == TRUE);
+ LARGE_INTEGER ulFileTime = FileTimeToUL(fileTime);
+
+ const char * day="";
+ switch (systime.wDayOfWeek)
+ {
+ case 0:day = "Sunday";break;
+ case 1:day = "Monday";break;
+ case 2:day = "Tuesday";break;
+ case 3:day = "Wednesday";break;
+ case 4:day = "Thursday";break;
+ case 5:day = "Friday";break;
+ case 6:day = "Saturday";break;
+ }
+ g_StdOut<< txt << day << " "
+ << (int)systime.wYear << "/" << (int)systime.wMonth << "/" << (int)systime.wDay << " "
+ << (int)systime.wHour << ":" << (int)systime.wMinute << ":" << (int)systime.wSecond << ":"
+ << (int)systime.wMilliseconds
+ << " (" << (UInt64)ulFileTime.QuadPart << ")\n";
+}
+
+static void test_time()
+{
+ time_t tps_unx = time(0);
+
+ printf("Test Time (1):\n");
+ printf("===========\n");
+ SYSTEMTIME systimeGM;
+ GetSystemTime(&systimeGM);
+
+ LARGE_INTEGER ul = UnixTimeToUL(tps_unx);
+ g_StdOut<<" unix time = " << (UInt64)tps_unx << " (" << (UInt64)ul.QuadPart << ")\n";
+
+ g_StdOut<<" gmtime : " << asctime(gmtime(&tps_unx))<<"\n";
+ g_StdOut<<" localtime : " << asctime(localtime(&tps_unx))<<"\n";
+
+ display(" GetSystemTime : ", systimeGM);
+}
+
+static void test_time2()
+{
+ printf("Test Time (2):\n");
+ printf("===========\n");
+ /* DosTime To utcFileTime */
+ UInt32 dosTime = 0x30d0094C;
+ FILETIME utcFileTime;
+ FILETIME localFileTime;
+
+ if (NTime::DosTimeToFileTime(dosTime, localFileTime))
+ {
+ if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
+ utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
+ }
+
+ printf(" - 0x%x => 0x%x 0x%x => 0x%x 0x%x\n",(unsigned)dosTime,
+ (unsigned)localFileTime.dwHighDateTime,(unsigned)localFileTime.dwLowDateTime,
+ (unsigned)utcFileTime.dwHighDateTime,(unsigned)utcFileTime.dwLowDateTime);
+
+
+ /* utcFileTime to DosTime */
+ FILETIME localFileTime2 = { 0, 0 };
+ UInt32 dosTime2 = 0;
+ FileTimeToLocalFileTime(&utcFileTime, &localFileTime2);
+ NTime::FileTimeToDosTime(localFileTime2, dosTime2);
+
+ printf(" - 0x%x <= 0x%x 0x%x <= 0x%x 0x%x\n",(unsigned)dosTime2,
+ (unsigned)localFileTime2.dwHighDateTime,(unsigned)localFileTime2.dwLowDateTime,
+ (unsigned)utcFileTime.dwHighDateTime,(unsigned)utcFileTime.dwLowDateTime);
+
+ assert(dosTime == dosTime2);
+ assert(localFileTime.dwHighDateTime == localFileTime2.dwHighDateTime);
+ assert(localFileTime.dwLowDateTime == localFileTime2.dwLowDateTime);
+}
+
+static void test_semaphore()
+{
+ g_StdOut << "\nTEST SEMAPHORE :\n";
+
+ NWindows::NSynchronization::CSynchro sync;
+ NWindows::NSynchronization::CSemaphoreWFMO sema;
+ bool bres;
+ DWORD waitResult;
+ int i;
+
+ sync.Create();
+ sema.Create(&sync,2,10);
+
+ g_StdOut << " - Release(1)\n";
+ for(i = 0 ;i < 8;i++)
+ {
+ // g_StdOut << " - Release(1) : "<< i << "\n";
+ bres = sema.Release(1);
+ assert(bres == S_OK);
+ }
+ // g_StdOut << " - Release(1) : done\n";
+ bres = sema.Release(1);
+ assert(bres == S_FALSE);
+
+ g_StdOut << " - WaitForMultipleObjects(INFINITE)\n";
+ HANDLE events[1] = { sema };
+ for(i=0;i<10;i++)
+ {
+ waitResult = ::WaitForMultipleObjects(1, events, FALSE, INFINITE);
+ assert(waitResult == WAIT_OBJECT_0);
+ }
+
+ g_StdOut << " Done\n";
+}
+
+
+/****************************************************************************************/
+
+
+static int threads_count = 0;
+
+static THREAD_FUNC_RET_TYPE thread_fct(void *param) {
+ threads_count++;
+ return 0;
+}
+
+#define MAX_THREADS 100000
+
+int test_thread(void) {
+ ::CThread thread;
+
+ Thread_Construct(&thread);
+
+ threads_count = 0;
+
+ printf("test_thread : %d threads\n",MAX_THREADS);
+
+ for(int i=0;i<MAX_THREADS;i++) {
+ Thread_Create(&thread, thread_fct, 0);
+
+ Thread_Wait(&thread);
+
+ Thread_Close(&thread);
+ }
+
+ assert(threads_count == MAX_THREADS);
+
+ return 0;
+}
+
+/****************************************************************************************/
+int main() {
+
+ // return test_thread();
+
+
+#ifdef HAVE_LOCALE
+ setlocale(LC_ALL,"");
+#endif
+
+#if defined(BIG_ENDIAN)
+ printf("BIG_ENDIAN : %d\n",(int)BIG_ENDIAN);
+#endif
+#if defined(LITTLE_ENDIAN)
+ printf("LITTLE_ENDIAN : %d\n",(int)LITTLE_ENDIAN);
+#endif
+
+ printf("sizeof(Byte) : %d\n",(int)sizeof(Byte));
+ printf("sizeof(UInt16) : %d\n",(int)sizeof(UInt16));
+ printf("sizeof(UInt32) : %d\n",(int)sizeof(UInt32));
+ printf("sizeof(UINT32) : %d\n",(int)sizeof(UINT32));
+ printf("sizeof(UInt64) : %d\n",(int)sizeof(UInt64));
+ printf("sizeof(UINT64) : %d\n",(int)sizeof(UINT64));
+ printf("sizeof(void *) : %d\n",(int)sizeof(void *));
+ printf("sizeof(size_t) : %d\n",(int)sizeof(size_t));
+ printf("sizeof(ptrdiff_t) : %d\n",(int)sizeof(ptrdiff_t));
+ printf("sizeof(off_t) : %d\n",(int)sizeof(off_t));
+
+ union {
+ Byte b[2];
+ UInt16 s;
+ } u;
+ u.s = 0x1234;
+
+ if ((u.b[0] == 0x12) && (u.b[1] == 0x34)) {
+ printf("CPU : big endian\n");
+ } else if ((u.b[0] == 0x34) && (u.b[1] == 0x12)) {
+ printf("CPU : little endian\n");
+ } else {
+ printf("CPU : unknown endianess\n");
+ }
+
+#if defined(HAVE_WCHAR__H) && defined(HAVE_MBSTOWCS) && defined(HAVE_WCSTOMBS)
+ test_mbs();
+#endif
+
+ test_astring(12345);
+ test_split_astring();
+
+
+ test_time();
+
+ test_time2();
+
+ test_semaphore();
+
+ printf("\n### All Done ###\n\n");
+
+ return 0;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/wine_GetXXXDefaultLangID.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/wine_GetXXXDefaultLangID.cpp
new file mode 100644
index 000000000..65e24e01e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/wine_GetXXXDefaultLangID.cpp
@@ -0,0 +1,731 @@
+
+#include "StdAfx.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <wchar.h>
+#include <ctype.h>
+#include <string.h>
+
+typedef DWORD LCID;
+typedef void * ULONG_PTR; /* typedef unsigned long ULONG_PTR; */
+
+#define SORT_DEFAULT 0x0
+
+#define LANG_NEUTRAL 0x00
+#define LANG_ENGLISH 0x09
+
+#define SUBLANG_DEFAULT 0x01 /* user default */
+
+#define MAKELCID(l, s) ( (l & 0xFFFF) | ((s & 0xFFFF)<<16))
+#define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
+
+#define LANGIDFROMLCID(lcid) ((WORD)(lcid))
+
+static LCID lcid_LC_MESSAGES = 0;
+static LCID lcid_LC_CTYPE = 0;
+
+struct locale_name
+{
+ WCHAR win_name[128]; /* Windows name ("en-US") */
+ WCHAR lang[128]; /* language ("en") (note: buffer contains the other strings too) */
+ WCHAR *country; /* country ("US") */
+ WCHAR *charset; /* charset ("UTF-8") for Unix format only */
+ WCHAR *script; /* script ("Latn") for Windows format only */
+ WCHAR *modifier; /* modifier or sort order */
+ LCID lcid; /* corresponding LCID */
+ int matches; /* number of elements matching LCID (0..4) */
+ UINT codepage; /* codepage corresponding to charset */
+};
+#define WINE_UNICODE_INLINE static
+
+/***********************************************************/
+typedef struct {
+ const WCHAR * LOCALE_SNAME;
+ const WCHAR * LOCALE_SISO639LANGNAME;
+ const WCHAR * LOCALE_SISO3166CTRYNAME;
+ unsigned int LOCALE_IDEFAULTUNIXCODEPAGE;
+ unsigned int LOCALE_ILANGUAGE;
+} t_info;
+
+static t_info g_langInfo[] = {
+ { L"af-ZA" , L"af" , L"ZA" , 28591 , 0x0436 }, /* afk.nls */
+ { L"ar-SA" , L"ar" , L"SA" , 28596 , 0x0401 }, /* ara.nls */
+ { L"ar-LB" , L"ar" , L"LB" , 28596 , 0x3001 }, /* arb.nls */
+ { L"ar-EG" , L"ar" , L"EG" , 28596 , 0x0c01 }, /* are.nls */
+ { L"ar-DZ" , L"ar" , L"DZ" , 28596 , 0x1401 }, /* arg.nls */
+ { L"ar-BH" , L"ar" , L"BH" , 28596 , 0x3c01 }, /* arh.nls */
+ { L"ar-IQ" , L"ar" , L"IQ" , 28596 , 0x0801 }, /* ari.nls */
+ { L"ar-JO" , L"ar" , L"JO" , 28596 , 0x2c01 }, /* arj.nls */
+ { L"ar-KW" , L"ar" , L"KW" , 28596 , 0x3401 }, /* ark.nls */
+ { L"ar-LY" , L"ar" , L"LY" , 28596 , 0x1001 }, /* arl.nls */
+ { L"ar-MA" , L"ar" , L"MA" , 28596 , 0x1801 }, /* arm.nls */
+ { L"ar-OM" , L"ar" , L"OM" , 28596 , 0x2001 }, /* aro.nls */
+ { L"ar-QA" , L"ar" , L"QA" , 28596 , 0x4001 }, /* arq.nls */
+ { L"ar-SY" , L"ar" , L"SY" , 28596 , 0x2801 }, /* ars.nls */
+ { L"ar-TN" , L"ar" , L"TN" , 28596 , 0x1c01 }, /* art.nls */
+ { L"ar-AE" , L"ar" , L"AE" , 28596 , 0x3801 }, /* aru.nls */
+ { L"ar-YE" , L"ar" , L"YE" , 28596 , 0x2401 }, /* ary.nls */
+ { L"az-AZ" , L"az" , L"AZ" , 28595 , 0x082c }, /* aze.nls */
+ { L"az-Latn-AZ" , L"az" , L"AZ" , 28599 , 0x042c }, /* azl.nls */
+ { L"be-BY" , L"be" , L"BY" , 1251 , 0x0423 }, /* bel.nls */
+ { L"bg-BG" , L"bg" , L"BG" , 1251 , 0x0402 }, /* bgr.nls */
+ { L"br-FR" , L"br" , L"FR" , 28605 , 0x0493 }, /* brf.nls */
+ { L"ca-ES" , L"ca" , L"ES" , 28605 , 0x0403 }, /* cat.nls */
+ { L"zh-CN" , L"zh" , L"CN" , 936 , 0x0804 }, /* chs.nls */
+ { L"zh-TW" , L"zh" , L"TW" , 950 , 0x0404 }, /* cht.nls */
+ { L"kw-GB" , L"kw" , L"GB" , 28605 , 0x04891 }, /* cor.nls */
+ { L"cs-CZ" , L"cs" , L"CZ" , 28592 , 0x0405 }, /* csy.nls */
+ { L"cy-GB" , L"cy" , L"GB" , 28604 , 0x0492 }, /* cym.nls */
+ { L"da-DK" , L"da" , L"DK" , 28605 , 0x0406 }, /* dan.nls */
+ { L"de-AT" , L"de" , L"AT" , 28605 , 0x0c07 }, /* dea.nls */
+ { L"de-LI" , L"de" , L"LI" , 28605 , 0x1407 }, /* dec.nls */
+ { L"de-LU" , L"de" , L"LU" , 28605 , 0x1007 }, /* del.nls */
+ { L"de-CH" , L"de" , L"CH" , 28605 , 0x0807 }, /* des.nls */
+ { L"de-DE" , L"de" , L"DE" , 28605 , 0x0407 }, /* deu.nls */
+ { L"dv-MV" , L"dv" , L"MV" , 65001 , 0x0465 }, /* div.nls */
+ { L"el-GR" , L"el" , L"GR" , 28597 , 0x0408 }, /* ell.nls */
+ { L"en-AU" , L"en" , L"AU" , 28591 , 0x0c09 }, /* ena.nls */
+ { L"en-CB" , L"en" , L"CB" , 28591 , 0x2409 }, /* enb.nls */
+ { L"en-CA" , L"en" , L"CA" , 28591 , 0x1009 }, /* enc.nls */
+ { L"en-GB" , L"en" , L"GB" , 28605 , 0x0809 }, /* eng.nls */
+ { L"en-IE" , L"en" , L"IE" , 28605 , 0x1809 }, /* eni.nls */
+ { L"en-JM" , L"en" , L"JM" , 28591 , 0x2009 }, /* enj.nls */
+ { L"en-BZ" , L"en" , L"BZ" , 28591 , 0x2809 }, /* enl.nls */
+ { L"en-PH" , L"en" , L"PH" , 28591 , 0x3409 }, /* enp.nls */
+ { L"en-ZA" , L"en" , L"ZA" , 28591 , 0x1c09 }, /* ens.nls */
+ { L"en-TT" , L"en" , L"TT" , 28591 , 0x2c09 }, /* ent.nls */
+ { L"en-US" , L"en" , L"US" , 28591 , 0x0409 }, /* enu.nls */
+ { L"en-ZW" , L"en" , L"ZW" , 28591 , 0x3009 }, /* enw.nls */
+ { L"en-NZ" , L"en" , L"NZ" , 28591 , 0x1409 }, /* enz.nls */
+ { L"eo" , L"eo" , L"" , 65001 , 0x048f }, /* eox.nls */
+ { L"es-PA" , L"es" , L"PA" , 28591 , 0x180a }, /* esa.nls */
+ { L"es-BO" , L"es" , L"BO" , 28591 , 0x400a }, /* esb.nls */
+ { L"es-CR" , L"es" , L"CR" , 28591 , 0x140a }, /* esc.nls */
+ { L"es-DO" , L"es" , L"DO" , 28591 , 0x1c0a }, /* esd.nls */
+ { L"es-SV" , L"es" , L"SV" , 28591 , 0x440a }, /* ese.nls */
+ { L"es-EC" , L"es" , L"EC" , 28591 , 0x300a }, /* esf.nls */
+ { L"es-GT" , L"es" , L"GT" , 28591 , 0x100a }, /* esg.nls */
+ { L"es-HN" , L"es" , L"HN" , 28591 , 0x480a }, /* esh.nls */
+ { L"es-NI" , L"es" , L"NI" , 28591 , 0x4c0a }, /* esi.nls */
+ { L"es-C" , L"es" , L"C" , 28591 , 0x340a }, /* esl.nls */
+ { L"es-MX" , L"es" , L"MX" , 28591 , 0x080a }, /* esm.nls */
+ { L"es-ES_modern" , L"es" , L"ES" , 28605 , 0x0c0a }, /* esn.nls */
+ { L"es-CO" , L"es" , L"CO" , 28591 , 0x240a }, /* eso.nls */
+ { L"es-ES" , L"es" , L"ES" , 28605 , 0x040a }, /* esp.nls */
+ { L"es-PE" , L"es" , L"PE" , 28591 , 0x280a }, /* esr.nls */
+ { L"es-AR" , L"es" , L"AR" , 28591 , 0x2c0a }, /* ess.nls */
+ { L"es-PR" , L"es" , L"PR" , 28591 , 0x500a }, /* esu.nls */
+ { L"es-VE" , L"es" , L"VE" , 28591 , 0x200a }, /* esv.nls */
+ { L"es-UY" , L"es" , L"UY" , 28591 , 0x380a }, /* esy.nls */
+ { L"es-PY" , L"es" , L"PY" , 28591 , 0x3c0a }, /* esz.nls */
+ { L"et-EE" , L"et" , L"EE" , 28605 , 0x0425 }, /* eti.nls */
+ { L"eu-ES" , L"eu" , L"ES" , 28605 , 0x042d }, /* euq.nls */
+ { L"fa-IR" , L"fa" , L"IR" , 65001 , 0x0429 }, /* far.nls */
+ { L"fi-FI" , L"fi" , L"FI" , 28605 , 0x040b }, /* fin.nls */
+ { L"fo-FO" , L"fo" , L"FO" , 28605 , 0x0438 }, /* fos.nls */
+ { L"fr-FR" , L"fr" , L"FR" , 28605 , 0x040c }, /* fra.nls */
+ { L"fr-BE" , L"fr" , L"BE" , 28605 , 0x080c }, /* frb.nls */
+ { L"fr-CA" , L"fr" , L"CA" , 28591 , 0x0c0c }, /* frc.nls */
+ { L"fr-LU" , L"fr" , L"LU" , 28605 , 0x140c }, /* frl.nls */
+ { L"fr-MC" , L"fr" , L"MC" , 28605 , 0x180c }, /* frm.nls */
+ { L"fr-CH" , L"fr" , L"CH" , 28605 , 0x100c }, /* frs.nls */
+ { L"ga-IE" , L"ga" , L"IE" , 28605 , 0x043c }, /* gae.nls */
+ { L"gd-GB" , L"gd" , L"GB" , 28605 , 0x083c }, /* gdh.nls */
+ { L"gv-GB" , L"gv" , L"GB" , 28605 , 0x0c3c }, /* gdv.nls */
+ { L"gl-ES" , L"gl" , L"ES" , 28605 , 0x0456 }, /* glc.nls */
+ { L"gu-IN" , L"gu" , L"IN" , 65001 , 0x0447 }, /* guj.nls */
+ { L"he-I" , L"he" , L"I" , 28598 , 0x040d }, /* heb.nls */
+ { L"hi-IN" , L"hi" , L"IN" , 65001 , 0x0439 }, /* hin.nls */
+ { L"hr-HR" , L"hr" , L"HR" , 28592 , 0x041a }, /* hrv.nls */
+ { L"hu-HU" , L"hu" , L"HU" , 28592 , 0x040e }, /* hun.nls */
+ { L"hy-AM" , L"hy" , L"AM" , 65001 , 0x042b }, /* hye.nls */
+ { L"id-ID" , L"id" , L"ID" , 28591 , 0x0421 }, /* ind.nls */
+ { L"is-IS" , L"is" , L"IS" , 28605 , 0x040f }, /* isl.nls */
+ { L"it-IT" , L"it" , L"IT" , 28605 , 0x0410 }, /* ita.nls */
+ { L"it-CH" , L"it" , L"CH" , 28605 , 0x0810 }, /* its.nls */
+ { L"ja-JP" , L"ja" , L"JP" , 20932 , 0x0411 }, /* jpn.nls */
+ { L"kn-IN" , L"kn" , L"IN" , 65001 , 0x044b }, /* kan.nls */
+ { L"ka-GE" , L"ka" , L"GE" , 65001 , 0x0437 }, /* kat.nls */
+ { L"kk-KZ" , L"kk" , L"KZ" , 28595 , 0x043f }, /* kkz.nls */
+ { L"kok-IN" , L"kok" , L"IN" , 65001 , 0x0457 }, /* knk.nls */
+ { L"ko-KR" , L"ko" , L"KR" , 949 , 0x0412 }, /* kor.nls */
+ { L"ky-KG" , L"ky" , L"KG" , 28595 , 0x0440 }, /* kyr.nls */
+ { L"lt-LT" , L"lt" , L"LT" , 28603 , 0x0427 }, /* lth.nls */
+ { L"lv-LV" , L"lv" , L"LV" , 28603 , 0x0426 }, /* lvi.nls */
+ { L"mr-IN" , L"mr" , L"IN" , 65001 , 0x044e }, /* mar.nls */
+ { L"mk-MK" , L"mk" , L"MK" , 28595 , 0x042f }, /* mki.nls */
+ { L"mn-MN" , L"mn" , L"MN" , 28595 , 0x0450 }, /* mon.nls */
+ { L"ms-BN" , L"ms" , L"BN" , 28591 , 0x083e }, /* msb.nls */
+ { L"ms-MY" , L"ms" , L"MY" , 28591 , 0x043e }, /* msl.nls */
+ { L"nl-BE" , L"nl" , L"BE" , 28605 , 0x0813 }, /* nlb.nls */
+ { L"nl-N" , L"nl" , L"N" , 28605 , 0x0413 }, /* nld.nls */
+ { L"nl-SR" , L"nl" , L"SR" , 28605 , 0x0c13 }, /* nls.nls */
+ { L"nn-NO" , L"nn" , L"NO" , 28605 , 0x0814 }, /* non.nls */
+ { L"nb-NO" , L"nb" , L"NO" , 28605 , 0x0414 }, /* nor.nls */
+ { L"pa-IN" , L"pa" , L"IN" , 65001 , 0x0446 }, /* pan.nls */
+ { L"pl-P" , L"pl" , L"P" , 28592 , 0x0415 }, /* plk.nls */
+ { L"pt-BR" , L"pt" , L"BR" , 28591 , 0x0416 }, /* ptb.nls */
+ { L"pt-PT" , L"pt" , L"PT" , 28605 , 0x0816 }, /* ptg.nls */
+ { L"rm-CH" , L"rm" , L"CH" , 28605 , 0x0417 }, /* rmc.nls */
+ { L"ro-RO" , L"ro" , L"RO" , 28592 , 0x0418 }, /* rom.nls */
+ { L"ru-RU" , L"ru" , L"RU" , 20866 , 0x0419 }, /* rus.nls */
+ { L"sa-IN" , L"sa" , L"IN" , 65001 , 0x044f }, /* san.nls */
+ { L"sk-SK" , L"sk" , L"SK" , 28592 , 0x041b }, /* sky.nls */
+ { L"sl-SI" , L"sl" , L"SI" , 28592 , 0x0424 }, /* slv.nls */
+ { L"sq-A" , L"sq" , L"A" , 28592 , 0x041c }, /* sqi.nls */
+ { L"sr-SP" , L"sr" , L"SP" , 28595 , 0x0c1a }, /* srb.nls */
+ { L"sr-Latn-SP" , L"sr" , L"SP" , 28592 , 0x081a }, /* srl.nls */
+ { L"sv-SE" , L"sv" , L"SE" , 28605 , 0x041d }, /* sve.nls */
+ { L"sv-FI" , L"sv" , L"FI" , 28605 , 0x081d }, /* svf.nls */
+ { L"sw-KE" , L"sw" , L"KE" , 28591 , 0x0441 }, /* swk.nls */
+ { L"syr-SY" , L"syr" , L"SY" , 65001 , 0x045a }, /* syr.nls */
+ { L"ta-IN" , L"ta" , L"IN" , 65001 , 0x0449 }, /* tam.nls */
+ { L"te-IN" , L"te" , L"IN" , 65001 , 0x044a }, /* tel.nls */
+ { L"th-TH" , L"th" , L"TH" , 874 , 0x041e }, /* tha.nls */
+ { L"tr-TR" , L"tr" , L"TR" , 28599 , 0x041f }, /* trk.nls */
+ { L"tt-TA" , L"tt" , L"TA" , 28595 , 0x0444 }, /* ttt.nls */
+ { L"uk-UA" , L"uk" , L"UA" , 21866 , 0x0422 }, /* ukr.nls */
+ { L"ur-PK" , L"ur" , L"PK" , 1256 , 0x0420 }, /* urd.nls */
+ { L"uz-UZ" , L"uz" , L"UZ" , 28595 , 0x0843 }, /* uzb.nls */
+ { L"uz-Latn-UZ" , L"uz" , L"UZ" , 28605 , 0x0443 }, /* uzl.nls */
+ { L"vi-VN" , L"vi" , L"VN" , 1258 , 0x042a }, /* vit.nls */
+ { L"wa-BE" , L"wa" , L"BE" , 28605 , 0x0490 }, /* wal.nls */
+ { L"zh-HK" , L"zh" , L"HK" , 950 , 0x0c04 }, /* zhh.nls */
+ { L"zh-SG" , L"zh" , L"SG" , 936 , 0x1004 }, /* zhi.nls */
+ { L"zh-MO" , L"zh" , L"MO" , 950 , 0x1404 }, /* zhm.nls */
+ { 0 , 0 , 0 , 0, 0 }
+};
+
+/***********************************************************/
+WINE_UNICODE_INLINE WCHAR *strchrW( const WCHAR *str, WCHAR ch )
+{
+ do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
+ return NULL;
+}
+
+WINE_UNICODE_INLINE WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept )
+{
+ for ( ; *str; str++) if (strchrW( accept, *str )) return (WCHAR *)(ULONG_PTR)str;
+ return NULL;
+}
+
+
+/***********************************************************/
+
+WINE_UNICODE_INLINE unsigned int strlenW( const WCHAR *str )
+{
+ const WCHAR *s = str;
+ while (*s) s++;
+ return s - str;
+}
+
+WINE_UNICODE_INLINE WCHAR *strcpyW( WCHAR *dst, const WCHAR *src )
+{
+ WCHAR *p = dst;
+ while ((*p++ = *src++));
+ return dst;
+}
+
+WINE_UNICODE_INLINE WCHAR *strcatW( WCHAR *dst, const WCHAR *src )
+{
+ strcpyW( dst + strlenW(dst), src );
+ return dst;
+}
+
+WINE_UNICODE_INLINE int strcmpW( const WCHAR *str1, const WCHAR *str2 )
+{
+ while (*str1 && (*str1 == *str2)) { str1++; str2++; }
+ return *str1 - *str2;
+}
+
+
+WINE_UNICODE_INLINE LPWSTR lstrcpynW( LPWSTR dst, LPCWSTR src, int n )
+{
+ {
+ LPWSTR d = dst;
+ LPCWSTR s = src;
+ UINT count = n;
+
+ while ((count > 1) && *s)
+ {
+ count--;
+ *d++ = *s++;
+ }
+ if (count) *d = 0;
+ }
+ return dst;
+}
+
+/* Copy Ascii string to Unicode without using codepages */
+static inline void strcpynAtoW( WCHAR *dst, const char *src, size_t n )
+{
+ while (n > 1 && *src)
+ {
+ *dst++ = (unsigned char)*src++;
+ n--;
+ }
+ if (n) *dst = 0;
+}
+
+/*******************************************************/
+
+/* Charset to codepage map, sorted by name. */
+static const struct charset_entry
+{
+ const char *charset_name;
+ UINT codepage;
+} charset_names[] =
+{
+ { "BIG5", 950 },
+ { "CP1250", 1250 },
+ { "CP1251", 1251 },
+ { "CP1252", 1252 },
+ { "CP1253", 1253 },
+ { "CP1254", 1254 },
+ { "CP1255", 1255 },
+ { "CP1256", 1256 },
+ { "CP1257", 1257 },
+ { "CP1258", 1258 },
+ { "CP932", 932 },
+ { "CP936", 936 },
+ { "CP949", 949 },
+ { "CP950", 950 },
+ { "EUCJP", 20932 },
+ { "GB2312", 936 },
+ { "IBM037", 37 },
+ { "IBM1026", 1026 },
+ { "IBM424", 424 },
+ { "IBM437", 437 },
+ { "IBM500", 500 },
+ { "IBM850", 850 },
+ { "IBM852", 852 },
+ { "IBM855", 855 },
+ { "IBM857", 857 },
+ { "IBM860", 860 },
+ { "IBM861", 861 },
+ { "IBM862", 862 },
+ { "IBM863", 863 },
+ { "IBM864", 864 },
+ { "IBM865", 865 },
+ { "IBM866", 866 },
+ { "IBM869", 869 },
+ { "IBM874", 874 },
+ { "IBM875", 875 },
+ { "ISO88591", 28591 },
+ { "ISO885910", 28600 },
+ { "ISO885913", 28603 },
+ { "ISO885914", 28604 },
+ { "ISO885915", 28605 },
+ { "ISO885916", 28606 },
+ { "ISO88592", 28592 },
+ { "ISO88593", 28593 },
+ { "ISO88594", 28594 },
+ { "ISO88595", 28595 },
+ { "ISO88596", 28596 },
+ { "ISO88597", 28597 },
+ { "ISO88598", 28598 },
+ { "ISO88599", 28599 },
+ { "KOI8R", 20866 },
+ { "KOI8U", 21866 },
+ { "UTF8", CP_UTF8 }
+};
+
+static int charset_cmp( const void *name, const void *entry )
+{
+ const struct charset_entry *charset = (const struct charset_entry *)entry;
+ return strcasecmp( (const char *)name, charset->charset_name );
+}
+
+static UINT find_charset( const WCHAR *name )
+{
+ const struct charset_entry *entry;
+ char charset_name[16];
+ size_t i, j;
+
+ /* remove punctuation characters from charset name */
+ for (i = j = 0; name[i] && j < sizeof(charset_name)-1; i++)
+ if (isalnum((unsigned char)name[i])) charset_name[j++] = name[i];
+ charset_name[j] = 0;
+
+ entry = (const struct charset_entry *)bsearch( charset_name, charset_names,
+ sizeof(charset_names)/sizeof(charset_names[0]),
+ sizeof(charset_names[0]), charset_cmp );
+ if (entry) return entry->codepage;
+
+ return 0;
+}
+/*******************************************************/
+
+static BOOL find_locale_id_callback(/* LPCWSTR name, ? */ const t_info * tab, struct locale_name *data)
+{
+ // WCHAR buffer[128];
+ int matches = 0;
+ WORD LangID = tab->LOCALE_ILANGUAGE & 0xFFFF; /* FIXME */
+ LCID lcid = MAKELCID( LangID, SORT_DEFAULT ); /* FIXME: handle sort order */
+
+ if (PRIMARYLANGID(LangID) == LANG_NEUTRAL) return TRUE; /* continue search */
+
+ /* first check exact name */
+ if (data->win_name[0] && tab->LOCALE_SNAME[0])
+ /* GetLocaleInfoW( lcid, LOCALE_SNAME | LOCALE_NOUSEROVERRIDE,
+ buffer, sizeof(buffer)/sizeof(WCHAR) )) */
+ {
+ if (!strcmpW( data->win_name, tab->LOCALE_SNAME ))
+ {
+ matches = 4; /* everything matches */
+ goto done;
+ }
+ }
+
+ /*if (!GetLocaleInfoW( lcid, LOCALE_SISO639LANGNAME | LOCALE_NOUSEROVERRIDE,
+ buffer, sizeof(buffer)/sizeof(WCHAR) )) */
+ if (tab->LOCALE_SISO639LANGNAME[0] == 0)
+ return TRUE;
+
+ if (strcmpW( tab->LOCALE_SISO639LANGNAME , data->lang )) return TRUE;
+ matches++; /* language name matched */
+
+ if (data->country)
+ {
+ /* if (GetLocaleInfoW( lcid, LOCALE_SISO3166CTRYNAME|LOCALE_NOUSEROVERRIDE,
+ buffer, sizeof(buffer)/sizeof(WCHAR) )) */
+ if (tab->LOCALE_SISO3166CTRYNAME[0])
+ {
+ if (strcmpW(tab->LOCALE_SISO3166CTRYNAME , data->country )) goto done;
+ matches++; /* country name matched */
+ }
+ }
+ else /* match default language */
+ {
+ if (SUBLANGID(LangID) == SUBLANG_DEFAULT) matches++;
+ }
+
+ if (data->codepage)
+ {
+ UINT unix_cp;
+ /* if (GetLocaleInfoW( lcid, LOCALE_IDEFAULTUNIXCODEPAGE | LOCALE_RETURN_NUMBER,
+ (LPWSTR)&unix_cp, sizeof(unix_cp)/sizeof(WCHAR) )) */
+ unix_cp = tab->LOCALE_IDEFAULTUNIXCODEPAGE;
+ {
+ if (unix_cp == data->codepage) matches++;
+ }
+ }
+
+ /* FIXME: check sort order */
+
+done:
+ if (matches > data->matches)
+ {
+ data->lcid = lcid;
+ data->matches = matches;
+ }
+ return (data->matches < 4); /* no need to continue for perfect match */
+}
+
+
+/***********************************************************************
+ * parse_locale_name
+ *
+ * Parse a locale name into a struct locale_name, handling both Windows and Unix formats.
+ * Unix format is: lang[_country][.charset][@modifier]
+ * Windows format is: lang[-script][-country][_modifier]
+ */
+static void parse_locale_name( const WCHAR *str, struct locale_name *name )
+{
+ static const WCHAR sepW[] = {'-','_','.','@',0};
+ static const WCHAR winsepW[] = {'-','_',0};
+ static const WCHAR posixW[] = {'P','O','S','I','X',0};
+ static const WCHAR cW[] = {'C',0};
+ static const WCHAR latinW[] = {'l','a','t','i','n',0};
+ static const WCHAR latnW[] = {'-','L','a','t','n',0};
+ WCHAR *p;
+ int ind;
+
+ // TRACE("%s\n", debugstr_w(str));
+
+ name->country = name->charset = name->script = name->modifier = NULL;
+ name->lcid = MAKELCID( MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT), SORT_DEFAULT );
+ name->matches = 0;
+ name->codepage = 0;
+ name->win_name[0] = 0;
+ lstrcpynW( name->lang, str, sizeof(name->lang)/sizeof(WCHAR) );
+
+ if (!(p = strpbrkW( name->lang, sepW )))
+ {
+ if (!strcmpW( name->lang, posixW ) || !strcmpW( name->lang, cW ))
+ {
+ name->matches = 4; /* perfect match for default English lcid */
+ return;
+ }
+ strcpyW( name->win_name, name->lang );
+ }
+ else if (*p == '-') /* Windows format */
+ {
+ strcpyW( name->win_name, name->lang );
+ *p++ = 0;
+ name->country = p;
+ if (!(p = strpbrkW( p, winsepW ))) goto done;
+ if (*p == '-')
+ {
+ *p++ = 0;
+ name->script = name->country;
+ name->country = p;
+ if (!(p = strpbrkW( p, winsepW ))) goto done;
+ }
+ *p++ = 0;
+ name->modifier = p;
+ }
+ else /* Unix format */
+ {
+ if (*p == '_')
+ {
+ *p++ = 0;
+ name->country = p;
+ p = strpbrkW( p, sepW + 2 );
+ }
+ if (p && *p == '.')
+ {
+ *p++ = 0;
+ name->charset = p;
+ p = strchrW( p, '@' );
+ }
+ if (p)
+ {
+ *p++ = 0;
+ name->modifier = p;
+ }
+
+ if (name->charset)
+ name->codepage = find_charset( name->charset );
+
+ /* rebuild a Windows name if possible */
+
+ if (name->charset) goto done; /* can't specify charset in Windows format */
+ if (name->modifier && strcmpW( name->modifier, latinW ))
+ goto done; /* only Latn script supported for now */
+ strcpyW( name->win_name, name->lang );
+ if (name->modifier) strcatW( name->win_name, latnW );
+ if (name->country)
+ {
+ p = name->win_name + strlenW(name->win_name);
+ *p++ = '-';
+ strcpyW( p, name->country );
+ }
+ }
+done:
+ ;
+
+/* DEBUG
+ printf("EnumResourceLanguagesW(...):\n");
+ printf(" name->win_name=%ls\n", name->win_name);
+ printf(" name->lang=%ls\n", name->lang);
+ printf(" name->country=%ls\n", name->country);
+ printf(" name->codepage=%d\n", name->codepage);
+*/
+// EnumResourceLanguagesW( kernel32_handle, (LPCWSTR)RT_STRING, (LPCWSTR)LOCALE_ILANGUAGE,
+// find_locale_id_callback, (LPARAM)name );
+
+ ind = 0;
+ while (g_langInfo[ind].LOCALE_SNAME)
+ {
+ BOOL ret = find_locale_id_callback(&g_langInfo[ind],name);
+ if (ret == FALSE)
+ break;
+
+ ind++;
+ }
+}
+
+
+
+
+/********************************/
+
+static UINT setup_unix_locales(void)
+{
+ struct locale_name locale_name;
+ // WCHAR buffer[128];
+ WCHAR ctype_buff[128];
+ char *locale;
+ UINT unix_cp = 0;
+
+ if ((locale = setlocale( LC_CTYPE, NULL )))
+ {
+ strcpynAtoW( ctype_buff, locale, sizeof(ctype_buff)/sizeof(WCHAR) );
+ parse_locale_name( ctype_buff, &locale_name );
+ lcid_LC_CTYPE = locale_name.lcid;
+ unix_cp = locale_name.codepage;
+ }
+ if (!lcid_LC_CTYPE) /* this one needs a default value */
+ lcid_LC_CTYPE = MAKELCID( MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT), SORT_DEFAULT );
+
+#if 0
+ TRACE( "got lcid %04x (%d matches) for LC_CTYPE=%s\n",
+ locale_name.lcid, locale_name.matches, debugstr_a(locale) );
+
+#define GET_UNIX_LOCALE(cat) do \
+ if ((locale = setlocale( cat, NULL ))) \
+ { \
+ strcpynAtoW( buffer, locale, sizeof(buffer)/sizeof(WCHAR) ); \
+ if (!strcmpW( buffer, ctype_buff )) lcid_##cat = lcid_LC_CTYPE; \
+ else { \
+ parse_locale_name( buffer, &locale_name ); \
+ lcid_##cat = locale_name.lcid; \
+ TRACE( "got lcid %04x (%d matches) for " #cat "=%s\n", \
+ locale_name.lcid, locale_name.matches, debugstr_a(locale) ); \
+ } \
+ } while (0)
+
+ GET_UNIX_LOCALE( LC_COLLATE );
+ GET_UNIX_LOCALE( LC_MESSAGES );
+ GET_UNIX_LOCALE( LC_MONETARY );
+ GET_UNIX_LOCALE( LC_NUMERIC );
+ GET_UNIX_LOCALE( LC_TIME );
+#ifdef LC_PAPER
+ GET_UNIX_LOCALE( LC_PAPER );
+#endif
+#ifdef LC_MEASUREMENT
+ GET_UNIX_LOCALE( LC_MEASUREMENT );
+#endif
+#ifdef LC_TELEPHONE
+ GET_UNIX_LOCALE( LC_TELEPHONE );
+#endif
+
+#undef GET_UNIX_LOCALE
+
+#endif // #if 0
+
+ return unix_cp;
+}
+
+/********************************/
+
+static void LOCALE_Init(void)
+{
+ /*
+ extern void __wine_init_codepages( const union cptable *ansi_cp, const union cptable *oem_cp,
+ const union cptable *unix_cp );
+ */
+
+ // UINT ansi_cp = 1252, oem_cp = 437, mac_cp = 10000, unix_cp;
+ UINT unix_cp = 0;
+
+#ifdef __APPLE__
+ /* MacOS doesn't set the locale environment variables so we have to do it ourselves */
+ CFArrayRef preferred_locales, all_locales;
+ CFStringRef user_language_string_ref = NULL;
+ char user_locale[50];
+
+ CFLocaleRef user_locale_ref = CFLocaleCopyCurrent();
+ CFStringRef user_locale_string_ref = CFLocaleGetIdentifier( user_locale_ref );
+
+ CFStringGetCString( user_locale_string_ref, user_locale, sizeof(user_locale), kCFStringEncodingUTF8 );
+ CFRelease( user_locale_ref );
+ if (!strchr( user_locale, '.' )) strcat( user_locale, ".UTF-8" );
+ unix_cp = CP_UTF8; /* default to utf-8 even if we don't get a valid locale */
+ setenv( "LANG", user_locale, 0 );
+ // TRACE( "setting locale to '%s'\n", user_locale );
+
+ /* We still want to set the retrieve the preferred language as chosen in
+ System Preferences.app, because it can differ from CFLocaleCopyCurrent().
+ */
+ all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
+ preferred_locales = CFBundleCopyLocalizationsForPreferences( all_locales, NULL );
+ if (preferred_locales && CFArrayGetCount( preferred_locales ))
+ user_language_string_ref = CFArrayGetValueAtIndex( preferred_locales, 0 );
+ CFRelease( all_locales );
+#endif /* __APPLE__ */
+
+ // FIXME setlocale( LC_ALL, "" );
+
+ unix_cp = setup_unix_locales();
+ if (!lcid_LC_MESSAGES) lcid_LC_MESSAGES = lcid_LC_CTYPE;
+#if 0
+#ifdef __APPLE__
+ /* Override lcid_LC_MESSAGES with user_language if LC_MESSAGES is set to default */
+ if (lcid_LC_MESSAGES == lcid_LC_CTYPE && user_language_string_ref)
+ {
+ struct locale_name locale_name;
+ WCHAR buffer[128];
+ CFStringGetCString( user_language_string_ref, user_locale, sizeof(user_locale), kCFStringEncodingUTF8 );
+ strcpynAtoW( buffer, user_locale, sizeof(buffer)/sizeof(WCHAR) );
+ parse_locale_name( buffer, &locale_name );
+ lcid_LC_MESSAGES = locale_name.lcid;
+ TRACE( "setting lcid_LC_MESSAGES to '%s'\n", user_locale );
+ }
+ if (preferred_locales)
+ CFRelease( preferred_locales );
+#endif
+
+ NtSetDefaultUILanguage( LANGIDFROMLCID(lcid_LC_MESSAGES) );
+ NtSetDefaultLocale( TRUE, lcid_LC_MESSAGES );
+ NtSetDefaultLocale( FALSE, lcid_LC_CTYPE );
+
+ ansi_cp = get_lcid_codepage( LOCALE_USER_DEFAULT );
+ GetLocaleInfoW( LOCALE_USER_DEFAULT, LOCALE_IDEFAULTMACCODEPAGE | LOCALE_RETURN_NUMBER,
+ (LPWSTR)&mac_cp, sizeof(mac_cp)/sizeof(WCHAR) );
+ GetLocaleInfoW( LOCALE_USER_DEFAULT, LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER,
+ (LPWSTR)&oem_cp, sizeof(oem_cp)/sizeof(WCHAR) );
+ if (!unix_cp)
+ GetLocaleInfoW( LOCALE_USER_DEFAULT, LOCALE_IDEFAULTUNIXCODEPAGE | LOCALE_RETURN_NUMBER,
+ (LPWSTR)&unix_cp, sizeof(unix_cp)/sizeof(WCHAR) );
+
+ if (!(ansi_cptable = wine_cp_get_table( ansi_cp )))
+ ansi_cptable = wine_cp_get_table( 1252 );
+ if (!(oem_cptable = wine_cp_get_table( oem_cp )))
+ oem_cptable = wine_cp_get_table( 437 );
+ if (!(mac_cptable = wine_cp_get_table( mac_cp )))
+ mac_cptable = wine_cp_get_table( 10000 );
+ if (unix_cp != CP_UTF8)
+ {
+ if (!(unix_cptable = wine_cp_get_table( unix_cp )))
+ unix_cptable = wine_cp_get_table( 28591 );
+ }
+
+ __wine_init_codepages( ansi_cptable, oem_cptable, unix_cptable );
+
+ TRACE( "ansi=%03d oem=%03d mac=%03d unix=%03d\n",
+ ansi_cptable->info.codepage, oem_cptable->info.codepage,
+ mac_cptable->info.codepage, unix_cp );
+
+ setlocale(LC_NUMERIC, "C"); /* FIXME: oleaut32 depends on this */
+#endif
+}
+
+LANGID GetUserDefaultLangID(void)
+{
+ // return LANGIDFROMLCID(GetUserDefaultLCID());
+ if (lcid_LC_MESSAGES == 0) LOCALE_Init();
+ return LANGIDFROMLCID(lcid_LC_MESSAGES);
+}
+
+LANGID GetSystemDefaultLangID(void)
+{
+ // return LANGIDFROMLCID(GetSystemDefaultLCID());
+ if (lcid_LC_MESSAGES == 0) LOCALE_Init();
+ return LANGIDFROMLCID(lcid_LC_MESSAGES);
+}
+
+#ifdef TEST
+int main()
+{
+ LANGID langID;
+ WORD primLang;
+ WORD subLang;
+
+ setlocale( LC_ALL, "" );
+
+ langID = GetUserDefaultLangID();
+ printf("langID=0x%x\n",langID);
+
+ primLang = (WORD)(PRIMARYLANGID(langID));
+ subLang = (WORD)(SUBLANGID(langID));
+
+ printf("primLang=%d subLang=%d\n",(unsigned)primLang,(unsigned)subLang);
+
+ return 0;
+}
+#endif
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/wine_date_and_time.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/wine_date_and_time.cpp
new file mode 100644
index 000000000..a26b0f9c3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/myWindows/wine_date_and_time.cpp
@@ -0,0 +1,397 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h> /* gettimeofday */
+#include <dirent.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <windows.h>
+
+// #define TRACEN(u) u;
+#define TRACEN(u) /* */
+
+typedef LONG NTSTATUS;
+#define STATUS_SUCCESS 0x00000000
+
+#define TICKSPERSEC 10000000
+#define TICKSPERMSEC 10000
+#define SECSPERDAY 86400
+#define SECSPERHOUR 3600
+#define SECSPERMIN 60
+#define MINSPERHOUR 60
+#define HOURSPERDAY 24
+#define EPOCHWEEKDAY 1 /* Jan 1, 1601 was Monday */
+#define DAYSPERWEEK 7
+#define EPOCHYEAR 1601
+#define DAYSPERNORMALYEAR 365
+#define DAYSPERLEAPYEAR 366
+#define MONSPERYEAR 12
+#define DAYSPERQUADRICENTENNIUM (365 * 400 + 97)
+#define DAYSPERNORMALCENTURY (365 * 100 + 24)
+#define DAYSPERNORMALQUADRENNIUM (365 * 4 + 1)
+
+/* 1601 to 1970 is 369 years plus 89 leap days */
+#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
+#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
+/* 1601 to 1980 is 379 years plus 91 leap days */
+#define SECS_1601_TO_1980 ((379 * 365 + 91) * (ULONGLONG)SECSPERDAY)
+#define TICKS_1601_TO_1980 (SECS_1601_TO_1980 * TICKSPERSEC)
+typedef short CSHORT;
+
+static LONG TIME_GetBias() {
+ time_t utc = time(NULL);
+ struct tm *ptm = localtime(&utc);
+ int localdaylight = ptm->tm_isdst; /* daylight for local timezone */
+ ptm = gmtime(&utc);
+ ptm->tm_isdst = localdaylight; /* use local daylight, not that of Greenwich */
+ LONG bias = (int)(mktime(ptm)-utc);
+ TRACEN((printf("TIME_GetBias %ld\n",(long)bias)))
+ return bias;
+}
+
+static inline void RtlSystemTimeToLocalTime( const LARGE_INTEGER *SystemTime,
+ LARGE_INTEGER *LocalTime ) {
+ LONG bias = TIME_GetBias();
+ LocalTime->QuadPart = SystemTime->QuadPart - bias * (LONGLONG)TICKSPERSEC;
+}
+
+void WINAPI RtlSecondsSince1970ToFileTime( DWORD Seconds, FILETIME * ft ) {
+ ULONGLONG secs = Seconds * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
+ ft->dwLowDateTime = (DWORD)secs;
+ ft->dwHighDateTime = (DWORD)(secs >> 32);
+ TRACEN((printf("RtlSecondsSince1970ToFileTime %lx => %lx %lx\n",(long)Seconds,(long)ft->dwHighDateTime,(long)ft->dwLowDateTime)))
+}
+
+/*
+void WINAPI RtlSecondsSince1970ToTime( DWORD Seconds, LARGE_INTEGER *Time )
+{
+ ULONGLONG secs = Seconds * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
+ // Time->u.LowPart = (DWORD)secs; Time->u.HighPart = (DWORD)(secs >> 32);
+ Time->QuadPart = secs;
+}
+*/
+
+
+BOOL WINAPI DosDateTimeToFileTime( WORD fatdate, WORD fattime, FILETIME * ft) {
+ struct tm newtm;
+
+ TRACEN((printf("DosDateTimeToFileTime\n")))
+ // memset(&newtm,0,sizeof(newtm));
+ newtm.tm_sec = (fattime & 0x1f) * 2;
+ newtm.tm_min = (fattime >> 5) & 0x3f;
+ newtm.tm_hour = (fattime >> 11);
+ newtm.tm_mday = (fatdate & 0x1f);
+ newtm.tm_mon = ((fatdate >> 5) & 0x0f) - 1;
+ newtm.tm_year = (fatdate >> 9) + 80;
+ newtm.tm_isdst = -1;
+
+ time_t time1 = mktime(&newtm);
+ LONG bias = TIME_GetBias();
+ RtlSecondsSince1970ToFileTime( time1 - bias, ft );
+
+ TRACEN((printf("DosDateTimeToFileTime(%ld,%ld) t1=%ld bias=%ld => %lx %lx\n",
+ (long)fatdate,(long)fattime,(long)time1,(long)bias,
+ (long)ft->dwHighDateTime,(long)ft->dwLowDateTime)))
+
+ return TRUE;
+}
+
+BOOLEAN WINAPI RtlTimeToSecondsSince1970( const LARGE_INTEGER *Time, DWORD *Seconds ) {
+ ULONGLONG tmp = Time->QuadPart;
+ TRACEN((printf("RtlTimeToSecondsSince1970-1 %llx\n",tmp)))
+ tmp /= TICKSPERSEC;
+ tmp -= SECS_1601_TO_1970;
+ TRACEN((printf("RtlTimeToSecondsSince1970-2 %llx\n",tmp)))
+ if (tmp > 0xffffffff) return FALSE;
+ *Seconds = (DWORD)tmp;
+ return TRUE;
+}
+
+BOOL WINAPI FileTimeToDosDateTime( const FILETIME *ft, WORD *fatdate, WORD *fattime ) {
+ LARGE_INTEGER li;
+ ULONG t;
+ time_t unixtime;
+ struct tm* tm;
+ WORD fat_d,fat_t;
+
+ TRACEN((printf("FileTimeToDosDateTime\n")))
+ li.QuadPart = ft->dwHighDateTime;
+ li.QuadPart = (li.QuadPart << 32) | ft->dwLowDateTime;
+ RtlTimeToSecondsSince1970( &li, &t );
+ unixtime = t; /* FIXME unixtime = t - TIME_GetBias(); */
+ tm = gmtime( &unixtime );
+
+ fat_t = (tm->tm_hour << 11) + (tm->tm_min << 5) + (tm->tm_sec / 2);
+ fat_d = ((tm->tm_year - 80) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday;
+ if (fattime)
+ *fattime = fat_t;
+ if (fatdate)
+ *fatdate = fat_d;
+
+ TRACEN((printf("FileTimeToDosDateTime : %lx %lx => %d %d\n",
+ (long)ft->dwHighDateTime,(long)ft->dwLowDateTime,(unsigned)fat_d,(unsigned)fat_t)))
+
+ return TRUE;
+}
+
+BOOL WINAPI FileTimeToLocalFileTime( const FILETIME *utcft, FILETIME * localft ) {
+ LARGE_INTEGER local, utc;
+
+ TRACEN((printf("FileTimeToLocalFileTime\n")))
+ utc.QuadPart = utcft->dwHighDateTime;
+ utc.QuadPart = (utc.QuadPart << 32) | utcft->dwLowDateTime;
+ RtlSystemTimeToLocalTime( &utc, &local );
+ localft->dwLowDateTime = (DWORD)local.QuadPart;
+ localft->dwHighDateTime = (DWORD)(local.QuadPart >> 32);
+
+ return TRUE;
+}
+
+typedef struct _TIME_FIELDS {
+ CSHORT Year;
+ CSHORT Month;
+ CSHORT Day;
+ CSHORT Hour;
+ CSHORT Minute;
+ CSHORT Second;
+ CSHORT Milliseconds;
+ CSHORT Weekday;
+} TIME_FIELDS;
+
+static const int MonthLengths[2][MONSPERYEAR] =
+{
+ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+ { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
+};
+
+static inline int IsLeapYear(int Year) {
+ return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 1 : 0;
+}
+
+static inline VOID WINAPI RtlTimeToTimeFields(
+ const LARGE_INTEGER *liTime,
+ TIME_FIELDS * TimeFields) {
+ int SecondsInDay;
+ long int cleaps, years, yearday, months;
+ long int Days;
+ LONGLONG Time;
+
+ /* Extract millisecond from time and convert time into seconds */
+ TimeFields->Milliseconds =
+ (CSHORT) (( liTime->QuadPart % TICKSPERSEC) / TICKSPERMSEC);
+ Time = liTime->QuadPart / TICKSPERSEC;
+
+ /* The native version of RtlTimeToTimeFields does not take leap seconds
+ * into account */
+
+ /* Split the time into days and seconds within the day */
+ Days = Time / SECSPERDAY;
+ SecondsInDay = Time % SECSPERDAY;
+
+ /* compute time of day */
+ TimeFields->Hour = (CSHORT) (SecondsInDay / SECSPERHOUR);
+ SecondsInDay = SecondsInDay % SECSPERHOUR;
+ TimeFields->Minute = (CSHORT) (SecondsInDay / SECSPERMIN);
+ TimeFields->Second = (CSHORT) (SecondsInDay % SECSPERMIN);
+
+ /* compute day of week */
+ TimeFields->Weekday = (CSHORT) ((EPOCHWEEKDAY + Days) % DAYSPERWEEK);
+
+ /* compute year, month and day of month. */
+ cleaps=( 3 * ((4 * Days + 1227) / DAYSPERQUADRICENTENNIUM) + 3 ) / 4;
+ Days += 28188 + cleaps;
+ years = (20 * Days - 2442) / (5 * DAYSPERNORMALQUADRENNIUM);
+ yearday = Days - (years * DAYSPERNORMALQUADRENNIUM)/4;
+ months = (64 * yearday) / 1959;
+ /* the result is based on a year starting on March.
+ * To convert take 12 from Januari and Februari and
+ * increase the year by one. */
+ if( months < 14 ) {
+ TimeFields->Month = months - 1;
+ TimeFields->Year = years + 1524;
+ } else {
+ TimeFields->Month = months - 13;
+ TimeFields->Year = years + 1525;
+ }
+ /* calculation of day of month is based on the wonderful
+ * sequence of INT( n * 30.6): it reproduces the
+ * 31-30-31-30-31-31 month lengths exactly for small n's */
+ TimeFields->Day = yearday - (1959 * months) / 64 ;
+}
+
+
+BOOL WINAPI FileTimeToSystemTime( const FILETIME *ft, SYSTEMTIME * syst ) {
+ TIME_FIELDS tf;
+ LARGE_INTEGER t;
+
+ TRACEN((printf("FileTimeToSystemTime\n")))
+ t.QuadPart = ft->dwHighDateTime;
+ t.QuadPart = (t.QuadPart << 32) | ft->dwLowDateTime;
+ RtlTimeToTimeFields(&t, &tf);
+
+ syst->wYear = tf.Year;
+ syst->wMonth = tf.Month;
+ syst->wDay = tf.Day;
+ syst->wHour = tf.Hour;
+ syst->wMinute = tf.Minute;
+ syst->wSecond = tf.Second;
+ syst->wMilliseconds = tf.Milliseconds;
+ syst->wDayOfWeek = tf.Weekday;
+ return TRUE;
+}
+
+
+static inline NTSTATUS WINAPI RtlLocalTimeToSystemTime( const LARGE_INTEGER *LocalTime,
+ LARGE_INTEGER *SystemTime) {
+
+ TRACEN((printf("RtlLocalTimeToSystemTime\n")))
+ LONG bias = TIME_GetBias();
+ SystemTime->QuadPart = LocalTime->QuadPart + bias * (LONGLONG)TICKSPERSEC;
+ return STATUS_SUCCESS;
+}
+
+BOOL WINAPI LocalFileTimeToFileTime( const FILETIME *localft, FILETIME * utcft ) {
+ LARGE_INTEGER local, utc;
+
+ TRACEN((printf("LocalFileTimeToFileTime\n")))
+ local.QuadPart = localft->dwHighDateTime;
+ local.QuadPart = (local.QuadPart << 32) | localft->dwLowDateTime;
+ RtlLocalTimeToSystemTime( &local, &utc );
+ utcft->dwLowDateTime = (DWORD)utc.QuadPart;
+ utcft->dwHighDateTime = (DWORD)(utc.QuadPart >> 32);
+
+ return TRUE;
+}
+
+/*********************************************************************
+ * GetSystemTime (KERNEL32.@)
+ *
+ * Get the current system time.
+ *
+ * RETURNS
+ * Nothing.
+ */
+VOID WINAPI GetSystemTime(SYSTEMTIME * systime) /* [O] Destination for current time */
+{
+ FILETIME ft;
+ LARGE_INTEGER t;
+
+ TRACEN((printf("GetSystemTime\n")))
+
+ struct timeval now;
+ gettimeofday( &now, 0 );
+ t.QuadPart = now.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
+ t.QuadPart += now.tv_usec * 10;
+
+ ft.dwLowDateTime = (DWORD)(t.QuadPart);
+ ft.dwHighDateTime = (DWORD)(t.QuadPart >> 32);
+ FileTimeToSystemTime(&ft, systime);
+}
+
+/******************************************************************************
+ * RtlTimeFieldsToTime [NTDLL.@]
+ *
+ * Convert a TIME_FIELDS structure into a time.
+ *
+ * PARAMS
+ * ftTimeFields [I] TIME_FIELDS structure to convert.
+ * Time [O] Destination for the converted time.
+ *
+ * RETURNS
+ * Success: TRUE.
+ * Failure: FALSE.
+ */
+static BOOLEAN WINAPI RtlTimeFieldsToTime(
+ TIME_FIELDS * tfTimeFields,
+ LARGE_INTEGER *Time)
+{
+ int month, year, cleaps, day;
+
+ TRACEN((printf("RtlTimeFieldsToTime\n")))
+
+ /* FIXME: normalize the TIME_FIELDS structure here */
+ /* No, native just returns 0 (error) if the fields are not */
+ if( tfTimeFields->Milliseconds< 0 || tfTimeFields->Milliseconds > 999 ||
+ tfTimeFields->Second < 0 || tfTimeFields->Second > 59 ||
+ tfTimeFields->Minute < 0 || tfTimeFields->Minute > 59 ||
+ tfTimeFields->Hour < 0 || tfTimeFields->Hour > 23 ||
+ tfTimeFields->Month < 1 || tfTimeFields->Month > 12 ||
+ tfTimeFields->Day < 1 ||
+ tfTimeFields->Day > MonthLengths
+ [ tfTimeFields->Month ==2 || IsLeapYear(tfTimeFields->Year)]
+ [ tfTimeFields->Month - 1] ||
+ tfTimeFields->Year < 1601 )
+ return FALSE;
+
+ /* now calculate a day count from the date
+ * First start counting years from March. This way the leap days
+ * are added at the end of the year, not somewhere in the middle.
+ * Formula's become so much less complicate that way.
+ * To convert: add 12 to the month numbers of Jan and Feb, and
+ * take 1 from the year */
+ if(tfTimeFields->Month < 3) {
+ month = tfTimeFields->Month + 13;
+ year = tfTimeFields->Year - 1;
+ } else {
+ month = tfTimeFields->Month + 1;
+ year = tfTimeFields->Year;
+ }
+ cleaps = (3 * (year / 100) + 3) / 4; /* nr of "century leap years"*/
+ day = (36525 * year) / 100 - cleaps + /* year * dayperyr, corrected */
+ (1959 * month) / 64 + /* months * daypermonth */
+ tfTimeFields->Day - /* day of the month */
+ 584817 ; /* zero that on 1601-01-01 */
+ /* done */
+
+ Time->QuadPart = (((((LONGLONG) day * HOURSPERDAY +
+ tfTimeFields->Hour) * MINSPERHOUR +
+ tfTimeFields->Minute) * SECSPERMIN +
+ tfTimeFields->Second ) * 1000 +
+ tfTimeFields->Milliseconds ) * TICKSPERMSEC;
+
+ return TRUE;
+}
+
+/*********************************************************************
+ * SystemTimeToFileTime (KERNEL32.@)
+ */
+BOOL WINAPI SystemTimeToFileTime( const SYSTEMTIME *syst, FILETIME * ft ) {
+ TIME_FIELDS tf;
+ LARGE_INTEGER t;
+
+ TRACEN((printf("SystemTimeToFileTime\n")))
+
+ tf.Year = syst->wYear;
+ tf.Month = syst->wMonth;
+ tf.Day = syst->wDay;
+ tf.Hour = syst->wHour;
+ tf.Minute = syst->wMinute;
+ tf.Second = syst->wSecond;
+ tf.Milliseconds = syst->wMilliseconds;
+
+ RtlTimeFieldsToTime(&tf, &t);
+ ft->dwLowDateTime = (DWORD)t.QuadPart;
+ ft->dwHighDateTime = (DWORD)(t.QuadPart>>32);
+ return TRUE;
+}
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/ChangeLog b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/ChangeLog
new file mode 100644
index 000000000..bae16fbaf
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/ChangeLog
@@ -0,0 +1,780 @@
+
+Version 9.04 (Major bugfixes and Major enhancements)
+============
+
+ - From Windows version of 7-zip 9.04 :
+ - 7-Zip now can update solid .7z archives.
+ - 7-Zip now supports LZMA2 compression method.
+ - 7-Zip now supports XZ archives.
+ - 7-Zip now can unpack NTFS, FAT, VHD and MBR archives.
+ - 7-Zip now can unpack GZip, BZip2, LZMA, XZ and TAR archives from stdin.
+ - New -scrc switch to calculate total CRC-32 during extracting / testing.
+ - Some bugs were fixed.
+
+ - #2799966 " A newly created 7z archive (by p7zip 4.65) is broken and cannot be unpacked / listed / tested"
+ Fixed : now "7za a -mx=9 archive.7z directory" creates a good archive even
+ if there are a lot of executable files.
+
+ - Fixed : the RAM size was reported incorrectly on MacOSX 64bits (with 2Gb+ RAM)
+
+ - #2798023 "segfault handling very large multivolume .7z file"
+ p7zip now displays the following error "Error: Too many open files"
+ if you don't have enough rights to open all the splitted files
+ ( on Linux : ulimit -n)
+
+
+
+Version 4.65
+============
+ - From Windows version of 7-zip 4.62 to 4.65
+ - The bug in 7-Zip 4.63 was fixed: 7-Zip could not decrypt .ZIP archives encrypted with WinZip-AES method.
+ - 7-Zip now can unpack ZIP archives encrypted with PKWARE-AES.
+ - Some bugs were fixed.
+
+ - Fixed : the RAM size was reported incorrectly on MacOSX 64bits
+
+ - Fixed : makefile.linux_amd64_asm_icc
+
+ - DJGPP :
+ makefile.djgpp becomes makefile.djgpp_old
+ makefile.djgpp_watt added (thank to Rugxulo)
+
+
+ - you can now compile 7za with a cmake project (see README)
+ the cmake project can build a codeblock project ;)
+ Remark : the kdevelop3 or Eclipse/CDT4 project don't work :(
+
+Version 4.61
+============
+ - From Windows version of 7-zip 4.61 :
+ - 7-Zip now supports LZMA compression for .ZIP archives.
+ - Some bugs were fixed.
+
+ - #2199036 : Ask for password twice when creating encrypted archive
+
+ - 7zG added (read GUI/readme.txt)
+
+
+Version 4.60 (never published)
+============
+
+ - From Windows version of 7-zip 4.60 :
+ - Some bugs were fixed
+
+ - p7zip didn't use the BCJ /BCJ2 filters for executables (:
+ - makefile.linux_amd64_asm_icc added (tested with Intel Compiler 11 on Ubuntu 8.04 x64)
+
+
+Version 4.59 (never published)
+============
+
+ - From Windows version of 7-zip 4.59 :
+ - 7-Zip now can unpack UDF, XAR and DMG/HFS archives.
+ - It's allowed to use -t switch for "list" and "extract" commands.
+ - Some bugs were fixed.
+
+ - Bug : wrong timestamp for files extracted from .zip or .rar archives
+
+
+Version 4.58
+============
+ - From Windows version of 7-zip 4.58 :
+ - Some speed optimizations.
+ - 7-Zip now can unpack .lzma archives.
+ - Unicode (UTF-8) support for filenames in .ZIP archives. Now there are 3 modes:
+ 1) Default mode: 7-Zip uses UTF-8, if the local code page doesn't contain required symbols.
+ 2) -mcu switch: 7-Zip uses UTF-8, if there are non-ASCII symbols.
+ 3) -mcl switch: 7-Zip uses local code page.
+ - Now it's possible to store file creation time in 7z and ZIP archives (-mtc switch).
+ - 7-Zip now can unpack multivolume RAR archives created with
+ "old style volume names" scheme and names *.001, *.002, ...
+ - Now it's possible to use -mSW- and -mSW+ switches instead of -mSW=off and -mSW=on
+ - Some bugs were fixed.
+
+ - Bug #1898410 : Timestamp error in archive listing
+ now "7za l .." and "ls -l just_extracted_file" give the same date and time.
+
+ - Bug #1860938 : unix file rights only 600 instead of 644
+
+ - Bug #1941574 : gzip files always marked as OS FAT, Now p7zip uses "Unix".
+
+ - Bug #1947700 : file containing excluded files not read
+ When using the -xr <filename> flag to list files not to be included in the
+ archive the file <filename> is not read if it is a symbolic link.
+
+ - Feature Requests #1868080 : add support to compile for NetWare (makefile.netware_asm_gcc_3.X)
+
+ - Patch #1883893 : Incorrect path ref to docs in man pages (When using the last ($DEST_DIR) argument with install.sh)
+
+ - now "install.sh" supports filenames with spaces.
+
+ - some code cleanup (Synchronization)
+
+ - some minor fix in the BZip2 codec.
+
+ - fix with the define "__TEXT" for s390
+
+
+Version 4.57
+============
+ - From Windows version of 7-zip 4.57 :
+ - The BUG in command line version was fixed: -up3 switch could work incorrectly.
+ - Minor improvement in ZIP compression.
+
+
+Version 4.56 (never published)
+============
+ - From Windows version of 7-zip 4.56 :
+ - Some bugs were fixed
+
+ - On HPUX : fixed "Can't load '../bin/7z.dll'"
+ (Unsatisfied data symbol '_ZTVN10__cxxabiv121__vmi_class_type_infoE' in load module '../bin/7z.so'.)
+
+ - bug : p7zip used to build a zip file with an "FAT" header instead of "Unix" header
+ If LANG was set, "unzip" tried to translate the filenames from "FAT" to locale ...
+
+ - On AIX : fixed "HugeFiles=off" (thank kuriath)
+
+ - bug #1800180 : LZMAlone compilation error in COutFile
+
+ - Patch #1796569 : Fix FreeBSD FTBFS
+
+ - Patch #1796575 : fix man1/7za.1 man1/7zr.1 man1/7z.1
+
+
+Version 4.55
+============
+ - From Windows version of 7-zip 4.55 :
+ - Some bugs were fixed
+
+ - fixed #1783007 : when make p7-zip 4.51 under hp-ux 11.11 error
+
+ - fixed #1789154 : 7z use default or -m0=LZMA runtime error under HP-UX IA11.23
+
+ - support added for HPUX on Itanium.
+ (makefile.hpux-acc and makefile.hpux-acc_64)
+
+
+Version 4.54 (never published)
+============
+ - From Windows version of 7-zip 4.54 :
+ - Decompression speed was increased
+
+Version 4.53
+============
+ - From Windows version of 7-zip 4.53 :
+ - The bug in 7-Zip 4.48 - 4.52 beta was fixed:
+ 7-Zip could create .ZIP archives with broken files.
+ - Some bugs were fixed.
+
+Version 4.52 (never published)
+============
+ - From Windows version of 7-zip 4.52 :
+ - 7z now can unpack Compound files (msi, doc, ...).
+ - Some bugs were fixed (CAB decompressing)
+
+ - lzma (CPP/7zip/Compress/LZMA_Alone) is now multi-threaded.
+
+ - fixed #632912 : Extracting large directories takes quadratic time
+ (this bug was not fully fixed ...)
+
+ - fixed : "7za x -odirectory archive.7z" now works even if "directory" is a symbolic link.
+
+ - makefile.linux_s390x added : support for Linux on IBM z/Series Mainframe with s390x CPU
+ (thank y_stephen)
+
+ - fixed crashes on BeOs with the flag "@filename"
+
+ - cleanup in the makefile : defining LITTLE_ENDIAN or BIG_ENDIAN is not needed anymore
+
+ - ppmd.exe added (CPP/7zip/Compress/PPMD_Alone)
+
+Version 4.51
+============
+ - From Windows version of 7-zip 4.51 :
+ - Bug was fixed: 7-Zip 4.50 beta could not open some .7z archives.
+
+ - fix built of test_emul
+
+Version 4.50 (never published)
+============
+ - From Windows version of 7-zip 4.50 :
+ - New switch for command line version:
+ -ssc[-] enables/disables case-sensitive mode for file names.
+ - Speed optimizations for AES encryption.
+ - Some bugs were fixed.
+
+ - contrib/gzip-like_CLI_wrapper_for_7z/p7zip now supports commands like :
+ p7zip -- -name
+ p7zip "file name"
+ p7zip file1 file2 file3
+ p7zip -d file1.7z file2.7z file3.7z
+
+ never published because this version does not pass my tests.
+
+Version 4.49
+============
+ - From Windows version of 7-zip 4.49 :
+ - 7-Zip (7z) now can unpack WIM archives
+
+ - fixed : On Sparc Solaris, core dump during "7z a -sfx exe.x dir" with p7zip compiled with makefile.solaris_sparc_CC_32
+
+ - some code cleanup
+
+ - On HPUX, p7zip can get the number of CPU and the size of the memory.
+
+
+Version 4.48
+============
+ - From Windows version of 7-zip 4.48 :
+ - Encryption strength for .7z format was increased.
+ Now it uses random initialization vectors.
+ - Some bugs were fixed.
+
+ - fixed #1729236 : Makefile infrastructure not safe for parallel compilation
+ (if your make command understands -C and -j4, copy makefile.parallel_jobs over makefile)
+
+ - Now the executables are not built with the PIC (position-independent code) flag.
+ 7z.so are still built with the PIC flag.
+ 7za and 7zr are now faster than 7z with 7z.so.
+ 7za, 7zr and 7r are now smaller.
+
+ - contrib/gzip-like_CLI_wrapper_for_7z/p7zip now supports spaces in filename
+ and use 7za instead of 7z.
+
+ - contrib/qnx630sp3 added to support QNX built (thank termterm)
+
+
+Version 4.47
+============
+ - From Windows version of 7-zip 4.47 :
+ - Bugs of 7-Zip 4.46 beta were fixed: BZip2 could work incorrectly
+
+Version 4.46 (never published)
+============
+
+ - From Windows version of 7-zip 4.46 :
+ - New fast compression mode for Deflate method in Zip and GZip.
+ - Some bugs were fixed.
+
+ - LZMA Benchmark :
+ - cygwin : RAM size detection
+ - computation of the CPU %
+
+ - fixed #1721827 : install.sh now copies 7z.so
+
+ - Client7z now uses 7z.so instead of 7za.so
+
+ - new target : cygwin with asm
+
+ - LZMA SDK added in the source package (CPP/7zip/Compress/LZMA_Alone)
+
+ - fixed #1716987 : 7zr removed from 4.45 binary distribution
+
+ - fixed #1706002 : make and install.sh use the same variables in the same order.
+
+
+Version 4.45
+============
+
+ - From Windows version of 7-zip 4.45 :
+ - Default dictionary size was increased: Normal: 16 MB, Max: 32 MB.
+ - Speed optimizations.
+ - Benchmark was improved (new "b" command in command line version).
+ - The number of DLL files was reduced.
+ - switch -mhcf=off is not supported now.
+ - If -t{Type} switch is not specified, 7-Zip now uses extension of archive to detect the type of archive.
+ - Some bugs were fixed (BZip2 in multithread)
+ - x86 or x86_64 : ASM version of crc32 available
+
+ - better detection of executable file (scripts do not need BCJ/BCJ2 filter)
+
+ - default permissions are now :
+ - for a file : -rw-------
+ - for a directory : drwx------
+
+ - on MacOSX, locale is always utf8 (because the MacOSX filesystem supports only utf8 filenames)
+
+ - makefile.qnx_static and makefile.qnx_shared added (Thank to termterm)
+
+
+Version 4.44
+============
+
+ - From Windows version of 7-zip 4.44 :
+ - 7za : Cab support
+ - Speed optimizations for LZMA, Deflate, BZip2 and unRAR.
+ - fix : now, updating a crypted header archive keeps the crypted header
+
+ - fixes in the help displayed by 7za/7z/7zr.
+
+ - code cleanup
+ - remove of mySetModuleFileNameA (and its memory leak), GetModuleFileName ...
+
+ - fixed : p7zip for DJGPP can now update an archive (thank stranix)
+
+ - fixed : in the plugins of 7z, the "Utf16" state was always off.
+
+ - fixed : support for directory names that are not encoded with the current locale.
+ (ex : directory name is in "iso 8859-15" whereas the locale is "utf8")
+
+ - patch #1581907 : fix for FreeBSD in contrib/gzip-like_CLI_wrapper_for_7z/p7zip
+
+ - fixed : p7zip can now restore a symbolic link from a Zip archive (archive.zip made with "zip -y")
+ remark/todo : p7zip stores, in a zip archive, the linked file instead of the symbolic link
+
+ - fixed #1630452 : small fix in the output of the script install.sh
+
+ - fixed #632912 : Extracting large directories takes quadratic time
+
+ - preliminary support of HP-UX : remove of RTLD_GROUP for dlopen in DLL.cpp
+ makefile.hpux-acc should be able to build 7za for HP-UX (thank furiol)
+
+ - Client7z added.
+
+Version 4.43
+============
+ - From Windows version of 7-zip 4.43 :
+ - 7-Zip now can use multi-threading mode for compressing to .ZIP archives.
+ - ZIP format supporting was improved.
+ - 7-Zip now supports WinZip-compatible AES-256 encryption for .ZIP archives.
+ - 7-Zip now uses order list (list of extensions) for files sorting for compressing
+ to .7z archives. It can slightly increase compression ratio in some cases.
+ - 7-Zip now restores modification time of folders during .7z archives extracting.
+ - Some bugs were fixed.
+
+ - fixed : the user can now see the percentage indicator.
+
+ - fix "Bugs item #1612285" : doesn't preserve directory timestamps
+
+ - support added for Tru64 / OSF 5.1 (makefile.tru64)
+
+ - small fix "Bugs item #1533765" in install.sh (7zr install)
+
+ - fix "Bugs item #1507913" : "make all" now build 7za and 7zCon.sfx
+ following the README.
+
+ - manpage updated "bugs item #1509098" : exit codes added
+
+ - manpage updated :-mhe=on (Header encryption) added
+
+ - install.sh now can install the file README, ChangeLog and the directory DOCS
+
+
+Version 4.42
+============
+ - From Windows version of 7-zip 4.42 :
+ - Some bugs were fixed
+
+ - the binaries provided by p7zip_4.XY_x86_linux_bin.tar.bz2
+ can now run on Fedora x86_64,
+ and should now run on any 64bits Linux.
+
+ - patch #1473746 - gzip-like CLI wrapper (for 7z)
+ see the directory "contrib/gzip-like_CLI_wrapper_for_7z".
+
+ - patch #471478 - Support for OPTFLAGS
+ This patch allows to use system specific opt flags.
+ example : make OPTFLAGS="-O2 -march=athlon-xp"
+
+ - the djgpp and cygwin makefile now build "7za" with case insensitive filenames
+ (Windows filesystem is case insensitive).
+
+
+Version 4.41
+============
+ - From Windows version of 7-zip 4.41 :
+ - Some bugs were fixed
+
+
+Version 4.40
+============
+
+ - From Windows version of 7-zip 4.40 :
+ - 7-Zip now can unpack some installers created by NSIS
+ - Some bugs were fixed
+
+ - format LZH/LHA : fixed directory display during listing or extracting
+ (a directory does not end with the path separator)
+
+ - patch #1470817 - Handle 7zr in install.sh
+
+ - code cleanup
+
+
+Version 4.39
+============
+
+ - From Windows version of 7-zip 4.39 :
+ - Bug in versions 4.33:4.38 was fixed:
+ 7-Zip could not correctly compress files larger than 2 GB
+ to 7z archive in fast/fastest modes (HC4 match finder).
+
+
+Version 4.38
+============
+
+ - From Windows version of 7-zip 4.38 :
+ - Some bugs were fixed.
+
+ - new manpage : 7zr.1
+ - update manpages : 7z.1 and 7za.1
+ - new switch : --help
+
+ - patch #1465026 - Patch for install.sh for packagers
+
+ - DosDateTimeToFileTime fixed (rar format)
+
+ - contrib/VirtualFileSystemForMidnightCommander/u7z updated
+ (thank sgh_punk)
+
+
+Version 4.37
+============
+ - From Windows version of 7-zip 4.37 :
+ - Some bugs were fixed.
+
+ - fix build for Solaris sparc with CC instead of g++.
+
+ - fix build for Solaris 9 x86
+ - fix build for Solaris 10 x86
+ - fix build for OpenBSD
+ - p7zip can now be build with djgpp.
+ - new target : 7zr (light version of 7za)
+ - new machine : IBM AIX
+
+Version 4.36
+============
+ - From Windows version of 7-zip 4.36 :
+ - 7-zip now can unpack ISO archives
+
+ - GCC 4.X : add C++ visibility support to reduce the size of the *.so
+ (see makefile.linux_x86_ppc_alpha__gcc_4.X)
+
+ - cygwin now supports '-o/tmp'
+
+Version 4.35
+============
+ - From Windows version of 7-zip 4.35 :
+ - New switch : -slt ("l" (list) command with -slt shows technical information for archive).
+ - Some bugs were fixed.
+
+ - From Windows version of 7-zip 4.34 :
+ - BZip2 compressing / decompressing now can work in multi-threading mode
+ - Multi-threading mode now is default for multi-processor systems
+
+Version 4.33
+============
+ - From Windows version of 7-zip 4.33 :
+ - Compressing speed and Memory requirements were increased.
+ Default dictionary size was increased: Fastest: 64 KB, Fast: 1 MB,
+ Normal: 4 MB, Max: 16 MB, Ultra: 64 MB.
+ - 64-bit version now supports 1 GB dictionary
+ - 7z/LZMA now can use only these match finders: HC4, BT2, BT3, BT4
+ - Compression ratio in Zip/GZip/Deflate in Ultra mode was increased
+ - Some bugs were fixed
+
+ - fix "Bugs item #1407358" : Passwords entered are not visible on command line
+ if the target has the system function "getpass".
+
+ - fix "BCJ2" : now p7zip uses the "BCJ2" filter when the file has execute permission
+ (7-zip uses the "BCJ2" filter when the filename ends with ".dll", ".exe", ".ocx", ".sfx" or ".sys")
+
+ - patch #1390722 : no new line at end of file
+
+ - patch #1390716 : allow compiling with gcc-4.1
+
+ - patch #1425862 : allow other make programs than GNU make
+
+ - Testing framework added ("make test" and "make test_7z")
+
+ - fix 'lstat' : p7zip can compile if 'lstat' is not available
+
+Version 4.30
+============
+ - From Windows version of 7-zip 4.30 :
+ - Speed optimizations in LZMA maximum/ultra compressing.
+ - LZMA now supports word size up to 273
+ - 7-Zip now reduces dictionary size for LZMA, if you compress files
+ smaller than specified dictionary size.
+ - Some bugs were fixed
+
+ - fix minor build trouble with MacOS X
+ - fix "Bugs item #1349229" : 7-zip now displays "e: Extract files from archive (without using directory names)"
+
+Version 4.29
+============
+
+ - fix "Bugs item #1305781" : "7z a -sfx" sets the execute-flag
+ and does not add ".exe" extension.
+
+ - fix "Bugs item #1306783" : "7za a /tmp/t.7z /etc/passwd"
+
+ - fix "Bugs item #1304797" : @lists don't handle files starting with ./
+
+ - fix "Bugs item #1309287" : man 7za fails after install
+
+Version 4.27
+============
+ - From Windows version of 7-zip 4.27 :
+ - new plugin for 7z : 7-Zip can unpack CHM/HXS (MS HTML HELP) archives
+ - cab plugin for 7z : 7-Zip can unpack multivolume CAB archives
+ - Some bugs were fixed
+ - better support for 64bits (PPMD coder/decoder)
+
+Version 4.26
+============
+ - From Windows version of 7-zip 4.26 :
+ - new plugin for 7z : LZH format support (extracting only)
+
+ - fix (courtesy from Robert Millan) to make p7zip compile on GNU/kFreeBSD.
+
+ - fix "Bug item #1273057", now "7z -so -t7z a dummy.7z file >output.7z" does not
+ finish with a "Segmentation fault (core dumped)".
+
+ - fix "Bug item #1221056", now, makefile for p7zip use the flag "-O" to
+ support compilers that build invalid programs with the flag "-O2".
+
+Version 4.25
+============
+ - From Windows version of 7-zip 4.25 :
+ - Some bugs were fixed
+ - DOCS/MANUAL/exit_codes.htm added
+
+ - new plugin for 7z : RAR format support (extracting only)
+
+ - better dependencies in makefile
+
+Version 4.23
+============
+ - From Windows version of 7-zip 4.23 :
+ - Some bugs were fixed
+
+ - manpages for 7za and 7z updated by Mohammed Adnene Trojette.
+
+ - little fix for the help message of 7za or 7z.
+
+ - bug #1224304 : Files and directories with \ in name not handled properly.
+
+ - fix for tar archives that have pax header.
+
+Version 4.20
+============
+
+ - From Windows version of 7-zip 4.19 and 4.20 :
+ - BZip2 code was rewritten. Now it supports 3 modes: Normal, Maximum and
+ Ultra. In Normal mode it compresses almost as original BZip2 compressor.
+ Compression ratio in Maximum and Ultra modes is 1-3% better for some files,
+ but Maximum Mode is about 3 times slower and Ultra Mode is about 8 times
+ slower than Normal mode.
+ - Console version now prints all messages to stdout by default,
+ and if -so switch is specified, 7-Zip prints messages to stderr.
+ - Some bugs were fixed
+
+ - Updating "contrib/VirtualFileSystemForMidnightCommander/" with u7z-4.16beta.tar.bz2
+
+ - bug #1204993 (does not find broken filenames)
+
+ - bug #1201244 (Missing files in p7zip_4.18_x86_linux_bin.tar.bz2)
+
+ - makefile.linux_x86_ppc_alpha : flag "-fPIC" added
+
+ - flag "-l" added.
+ without : p7zip stores symlinks (like p7zip 4.18)
+ with "-l" : p7zip stores the files/directories pointed by symlinks (like before p7zip 4.18)
+ CAUTION : the scanning stage can never end because of symlinks like ".."
+ (ex: ln -s .. ldir)
+
+Version 4.18
+============
+
+ - From Windows version of 7-zip 4.18 and 4.17 :
+ - minor fixes
+
+ - p7zip can now store and restore :
+ - symbolic links,
+ - file permission bits
+ Remark : for directory, restored_perm = stored_perm | 0700 .
+
+ - fix in install.sh
+
+ - On MacOSX, p7zip now restore times of a file.
+
+ - more detailed errors during scanning stage.
+
+
+Version 4.16
+============
+
+ - From Windows version of 7-zip 4.16 :
+ - Speed optimization (5%) for 7z / LZMA
+ - 7za now supports .Z archives
+ - -r- switch in command line now is default for all commands
+ - Some bugs were fixed
+ - bug #1119193 (list mode output confusing/wrong)
+
+ - From Windows version of 7-zip 4.15 :
+ - Z format supporting (extracting only)
+ - 7-Zip now can extract ZIP archives compressed with "Shrink" method
+ - 7-Zip now doesn't interrupt the compressing when it can not open file.
+ 7-Zip just skips that file and shows warning.
+ - Some bugs were fixed
+
+ - man pages added (thank Mohammed Adnene Trojette)
+ - bug #1112167 fixed (Temporary directory must be on same partition as target)
+ p7zip failed moving the temporary file at the end of
+ compressing to target file if the directories don't reside
+ on the same partition (or network path).
+ - bug #1164659 fixed (Invalid file date for "big endian" machine)
+ - p7zip now uses ".so" instead of ".dll"
+ - p7zip now handles "ctrl-c" and "kill" to cleanup temporary files before exiting
+ - p7zip now runs on BeOS.
+ - better support of filenames with spaces.
+ - some code cleanup
+ - "myWindows/myFiles.cpp" is now in "Windows/FileIO.cpp"
+ - "myWindows/myFindFile.cpp" is now in "Windows/FileFind.cpp"
+ - "myWindows/myDirectoryAndPath.cpp" is now in "Windows/FileDir.cpp"
+ - "myWindows/myEvents.cpp" is now in "Windows/Synchronization.cpp"
+ - "myWindows/wine_strings.cpp" is now in "Windows/String.cpp"
+
+
+Version 4.14.01
+===============
+ - huge speed up for multi CPUs machines (Thanks to loderunner - http://sourceforge.net/users/loderunner/).
+ - some code cleanup
+ - Fix problems with link files or directories.
+ - "7z a dummy -tgzip -so Doc.txt > archive.gz" now works.
+ - in the messages, the path separator is now '/' instead of '\'.
+
+Version 4.14
+============
+
+ - From Windows version of 7-zip 4.14 :
+ - STL using was reduced
+ - 7za now supports Split(001) archives
+ - "7za | more" now works
+ - Bugs item #1093095 : Usage banner now says "7za" (instead of "7z") when the binary is "7za"
+
+ - use of AString instead of std::string (no more need of #include <string>")
+ - makefile.linux_gcc_2.95_no_need_for_libstdc added to build 7za for the
+ p7zip*_bin.tar.bz2 package.
+ 7za provided by p7zip*_bin.tar.bz2 is build on Debian 3.0 with gcc 2.95.4
+ and should now find the locale on all kinds of Linux (Debian, Fedora, Mandrake, ...).
+
+Version 4.13
+============
+ - new port of 7za from the source of 7za 4.13Beta for Windows
+
+ - From Windows version of 7-zip 4.13 :
+ - Switch "--" stops switches parsing
+ - Some bugs were fixed
+ - User's manual updated (DOCS/MANUAL/index.htm)
+
+ - makefile.netbsd_x86 added [Bug #1069055].
+
+ - new method to install 7z and its plugins (the "link" method do no work)
+
+ - installer added (install.sh).
+
+ - makefile.macosx_with_fink becomes makefile.macosx
+ and makefile.macosx uses c++ instead of CC
+ (on some MacOSX, CC is a link to gcc instead of g++)
+
+ - new flag "-utf16" to enable "utf16" conversion [Bug #1075229].
+
+ - new logic to automatically enable or disable "utf16" conversion :
+ no locale, locale=="C" or locale=="POSIX" implies utf16=off
+ else utf16=on
+ uses "-utf16" or "-no-utf16" to change this behaviour.
+ [Bug #1075229]
+
+ - 7z (compiled with -O2) works now on Sparc Solaris.
+
+Version 4.12
+============
+ - new port of 7za from the source of 7za 4.12Beta for Windows
+
+ - From Windows version of 7-zip 4.11 and 4.12 :
+ - 7-Zip now supports Zip64 extension of ZIP format. So now it's
+ possible to compress files bigger than 4 GB to ZIP archives.
+ - Some bugs were fixed
+
+ - fix "7za a archive.7z file" that added all the files and directories
+ with filename "file", "FILE", "File" ...
+
+ - p7zip now displays the locale (ex : en_US.UTF-8) in the banner.
+
+ - new flag "-no-utf16" to avoid lossly conversion in filenames.
+ CAUTION : use this flag when you do not plan to export your archive.
+
+ - support creation of self extracting archive.
+
+ - better support of symbolic link (now, an invalid symbolic link
+ do not stop archiving but displays a warning).
+
+ - better support of files that the user cannot read.
+ (now this kind of file is not added to the archive, and p7zip displays a warning).
+
+ - return of 7z and its plugins.
+
+ - support of listing/testing/extracting files from a splitted archive (only with 7z).
+
+ - support of MacOX X 10.X.
+
+ - creation of Gzip/Tar archives didn't work on Linux Alpha.
+
+ - see "contrib/VirtualFileSystemForMidnightCommander/readme" to use 7za with "mc".
+
+Version 4.10
+============
+ - new port of 7za from the source of 7za 4.10Beta for Windows
+ => p7zip now work on big endian CPU.
+
+ - 7z for Unix is not maintain anymore (because as the source of unrar plugin for 7z
+ is not available, 7z is unless on Unix).
+
+Version 0.91
+============
+ - add support for FreeBSD 5.2.1
+ In Windows/Time.h add "#include <time.h>"
+ and prototype change for FileTimeToUnixTime()
+
+ - bug 990684 Corrected : support of filesystem
+ that support case sensitive filenames.
+ Example, since version 0.91 :
+ "7z a glibc -r glibc-2.3.2"
+ does not terminate with error :
+ Duplicate filename:
+ glibc-2.3.2\sysdeps\m88k\m88100\add_n.S
+ glibc-2.3.2\sysdeps\m88k\m88100\add_n.s
+
+Version 0.90
+============
+ - build of 7z.exe and its DLL.
+ 7z.exe support more archive formats than 7za.exe
+ thanks to DLL in Formats and Codecs directories
+ - "#pragma once" is now in comments
+ - mainly For OpenBSD :
+ - add #include <wchar.h> in include_windows/winnt.h
+ - remove stuff for GUID_SECTION and GUID_SECT in include_windows/basetyps.h
+ and include_windows/initguid.h
+ - some changes in 7zip/Crypto/aesopt.h because of endian.h
+
+Version 0.81
+============
+ - add a copy of the help of 7-zip (see html directory)
+ - "7z a -r tmp.7z directory" works as expected.
+ no more need for commands like : 7z a -r tmp.7z "directory/*"
+ - 7z restores the date of each files (but not directories)
+ - 7z supports UNICODE filenames (version 0.80 supports only ASCII/Latin1 filenames)
+ - support of gcc 2.95
+ - support of gcc 3.4
+ - 7z needs no more libgen.h (dirname() and basename())
+ - less "Internal Error #7" during arguments parsing
+ - minor change in class CThread
+
+Version 0.80
+============
+ - First public release
+ - support of gcc 3.2 and 3.3
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/7zC.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/7zC.txt
new file mode 100644
index 000000000..5d5d06d7b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/7zC.txt
@@ -0,0 +1,194 @@
+7z ANSI-C Decoder 4.62
+----------------------
+
+7z ANSI-C provides 7z/LZMA decoding.
+7z ANSI-C version is simplified version ported from C++ code.
+
+LZMA is default and general compression method of 7z format
+in 7-Zip compression program (www.7-zip.org). LZMA provides high
+compression ratio and very fast decompression.
+
+
+LICENSE
+-------
+
+7z ANSI-C Decoder is part of the LZMA SDK.
+LZMA SDK is written and placed in the public domain by Igor Pavlov.
+
+Files
+---------------------
+
+7zDecode.* - Low level 7z decoding
+7zExtract.* - High level 7z decoding
+7zHeader.* - .7z format constants
+7zIn.* - .7z archive opening
+7zItem.* - .7z structures
+7zMain.c - Test application
+
+
+How To Use
+----------
+
+You must download 7-Zip program from www.7-zip.org.
+
+You can create .7z archive with 7z.exe or 7za.exe:
+
+ 7za.exe a archive.7z *.htm -r -mx -m0fb=255
+
+If you have big number of files in archive, and you need fast extracting,
+you can use partly-solid archives:
+
+ 7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K
+
+In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only
+512KB for extracting one file from such archive.
+
+
+Limitations of current version of 7z ANSI-C Decoder
+---------------------------------------------------
+
+ - It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive.
+ - It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters.
+ - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names.
+
+These limitations will be fixed in future versions.
+
+
+Using 7z ANSI-C Decoder Test application:
+-----------------------------------------
+
+Usage: 7zDec <command> <archive_name>
+
+<Command>:
+ e: Extract files from archive
+ l: List contents of archive
+ t: Test integrity of archive
+
+Example:
+
+ 7zDec l archive.7z
+
+lists contents of archive.7z
+
+ 7zDec e archive.7z
+
+extracts files from archive.7z to current folder.
+
+
+How to use .7z Decoder
+----------------------
+
+Memory allocation
+~~~~~~~~~~~~~~~~~
+
+7z Decoder uses two memory pools:
+1) Temporary pool
+2) Main pool
+Such scheme can allow you to avoid fragmentation of allocated blocks.
+
+
+Steps for using 7z decoder
+--------------------------
+
+Use code at 7zMain.c as example.
+
+1) Declare variables:
+ inStream /* implements ILookInStream interface */
+ CSzArEx db; /* 7z archive database structure */
+ ISzAlloc allocImp; /* memory functions for main pool */
+ ISzAlloc allocTempImp; /* memory functions for temporary pool */
+
+2) call CrcGenerateTable(); function to initialize CRC structures.
+
+3) call SzArEx_Init(&db); function to initialize db structures.
+
+4) call SzArEx_Open(&db, inStream, &allocMain, &allocTemp) to open archive
+
+This function opens archive "inStream" and reads headers to "db".
+All items in "db" will be allocated with "allocMain" functions.
+SzArEx_Open function allocates and frees temporary structures by "allocTemp" functions.
+
+5) List items or Extract items
+
+ Listing code:
+ ~~~~~~~~~~~~~
+ {
+ UInt32 i;
+ for (i = 0; i < db.db.NumFiles; i++)
+ {
+ CFileItem *f = db.db.Files + i;
+ printf("%10d %s\n", (int)f->Size, f->Name);
+ }
+ }
+
+ Extracting code:
+ ~~~~~~~~~~~~~~~~
+
+ SZ_RESULT SzAr_Extract(
+ CArchiveDatabaseEx *db,
+ ILookInStream *inStream,
+ UInt32 fileIndex, /* index of file */
+ UInt32 *blockIndex, /* index of solid block */
+ Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
+ size_t *outBufferSize, /* buffer size for output buffer */
+ size_t *offset, /* offset of stream for required file in *outBuffer */
+ size_t *outSizeProcessed, /* size of file in *outBuffer */
+ ISzAlloc *allocMain,
+ ISzAlloc *allocTemp);
+
+ If you need to decompress more than one file, you can send these values from previous call:
+ blockIndex,
+ outBuffer,
+ outBufferSize,
+ You can consider "outBuffer" as cache of solid block. If your archive is solid,
+ it will increase decompression speed.
+
+ After decompressing you must free "outBuffer":
+ allocImp.Free(outBuffer);
+
+6) call SzArEx_Free(&db, allocImp.Free) to free allocated items in "db".
+
+
+
+
+Memory requirements for .7z decoding
+------------------------------------
+
+Memory usage for Archive opening:
+ - Temporary pool:
+ - Memory for uncompressed .7z headers
+ - some other temporary blocks
+ - Main pool:
+ - Memory for database:
+ Estimated size of one file structures in solid archive:
+ - Size (4 or 8 Bytes)
+ - CRC32 (4 bytes)
+ - LastWriteTime (8 bytes)
+ - Some file information (4 bytes)
+ - File Name (variable length) + pointer + allocation structures
+
+Memory usage for archive Decompressing:
+ - Temporary pool:
+ - Memory for LZMA decompressing structures
+ - Main pool:
+ - Memory for decompressed solid block
+ - Memory for temprorary buffers, if BCJ2 fileter is used. Usually these
+ temprorary buffers can be about 15% of solid block size.
+
+
+7z Decoder doesn't allocate memory for compressed blocks.
+Instead of this, you must allocate buffer with desired
+size before calling 7z Decoder. Use 7zMain.c as example.
+
+
+Defines
+-------
+
+_SZ_ALLOC_DEBUG - define it if you want to debug alloc/free operations to stderr.
+
+
+---
+
+http://www.7-zip.org
+http://www.7-zip.org/sdk.html
+http://www.7-zip.org/support.html
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/7zFormat.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/7zFormat.txt
new file mode 100644
index 000000000..a82c12e50
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/7zFormat.txt
@@ -0,0 +1,469 @@
+7z Format description (4.59)
+----------------------------
+
+This file contains description of 7z archive format.
+7z archive can contain files compressed with any method.
+See "Methods.txt" for description for defined compressing methods.
+
+
+Format structure Overview
+-------------------------
+
+Some fields can be optional.
+
+Archive structure
+~~~~~~~~~~~~~~~~~
+SignatureHeader
+[PackedStreams]
+[PackedStreamsForHeaders]
+[
+ Header
+ or
+ {
+ Packed Header
+ HeaderInfo
+ }
+]
+
+
+
+Header structure
+~~~~~~~~~~~~~~~~
+{
+ ArchiveProperties
+ AdditionalStreams
+ {
+ PackInfo
+ {
+ PackPos
+ NumPackStreams
+ Sizes[NumPackStreams]
+ CRCs[NumPackStreams]
+ }
+ CodersInfo
+ {
+ NumFolders
+ Folders[NumFolders]
+ {
+ NumCoders
+ CodersInfo[NumCoders]
+ {
+ ID
+ NumInStreams;
+ NumOutStreams;
+ PropertiesSize
+ Properties[PropertiesSize]
+ }
+ NumBindPairs
+ BindPairsInfo[NumBindPairs]
+ {
+ InIndex;
+ OutIndex;
+ }
+ PackedIndices
+ }
+ UnPackSize[Folders][Folders.NumOutstreams]
+ CRCs[NumFolders]
+ }
+ SubStreamsInfo
+ {
+ NumUnPackStreamsInFolders[NumFolders];
+ UnPackSizes[]
+ CRCs[]
+ }
+ }
+ MainStreamsInfo
+ {
+ (Same as in AdditionalStreams)
+ }
+ FilesInfo
+ {
+ NumFiles
+ Properties[]
+ {
+ ID
+ Size
+ Data
+ }
+ }
+}
+
+HeaderInfo structure
+~~~~~~~~~~~~~~~~~~~~
+{
+ (Same as in AdditionalStreams)
+}
+
+
+
+Notes about Notation and encoding
+---------------------------------
+
+7z uses little endian encoding.
+
+7z archive format has optional headers that are marked as
+[]
+Header
+[]
+
+REAL_UINT64 means real UINT64.
+
+UINT64 means real UINT64 encoded with the following scheme:
+
+ Size of encoding sequence depends from first byte:
+ First_Byte Extra_Bytes Value
+ (binary)
+ 0xxxxxxx : ( xxxxxxx )
+ 10xxxxxx BYTE y[1] : ( xxxxxx << (8 * 1)) + y
+ 110xxxxx BYTE y[2] : ( xxxxx << (8 * 2)) + y
+ ...
+ 1111110x BYTE y[6] : ( x << (8 * 6)) + y
+ 11111110 BYTE y[7] : y
+ 11111111 BYTE y[8] : y
+
+
+
+Property IDs
+------------
+
+0x00 = kEnd
+
+0x01 = kHeader
+
+0x02 = kArchiveProperties
+
+0x03 = kAdditionalStreamsInfo
+0x04 = kMainStreamsInfo
+0x05 = kFilesInfo
+
+0x06 = kPackInfo
+0x07 = kUnPackInfo
+0x08 = kSubStreamsInfo
+
+0x09 = kSize
+0x0A = kCRC
+
+0x0B = kFolder
+
+0x0C = kCodersUnPackSize
+0x0D = kNumUnPackStream
+
+0x0E = kEmptyStream
+0x0F = kEmptyFile
+0x10 = kAnti
+
+0x11 = kName
+0x12 = kCTime
+0x13 = kATime
+0x14 = kMTime
+0x15 = kWinAttributes
+0x16 = kComment
+
+0x17 = kEncodedHeader
+
+0x18 = kStartPos
+0x19 = kDummy
+
+
+7z format headers
+-----------------
+
+SignatureHeader
+~~~~~~~~~~~~~~~
+ BYTE kSignature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
+
+ ArchiveVersion
+ {
+ BYTE Major; // now = 0
+ BYTE Minor; // now = 2
+ };
+
+ UINT32 StartHeaderCRC;
+
+ StartHeader
+ {
+ REAL_UINT64 NextHeaderOffset
+ REAL_UINT64 NextHeaderSize
+ UINT32 NextHeaderCRC
+ }
+
+
+...........................
+
+
+ArchiveProperties
+~~~~~~~~~~~~~~~~~
+BYTE NID::kArchiveProperties (0x02)
+for (;;)
+{
+ BYTE PropertyType;
+ if (aType == 0)
+ break;
+ UINT64 PropertySize;
+ BYTE PropertyData[PropertySize];
+}
+
+
+Digests (NumStreams)
+~~~~~~~~~~~~~~~~~~~~~
+ BYTE AllAreDefined
+ if (AllAreDefined == 0)
+ {
+ for(NumStreams)
+ BIT Defined
+ }
+ UINT32 CRCs[NumDefined]
+
+
+PackInfo
+~~~~~~~~~~~~
+ BYTE NID::kPackInfo (0x06)
+ UINT64 PackPos
+ UINT64 NumPackStreams
+
+ []
+ BYTE NID::kSize (0x09)
+ UINT64 PackSizes[NumPackStreams]
+ []
+
+ []
+ BYTE NID::kCRC (0x0A)
+ PackStreamDigests[NumPackStreams]
+ []
+
+ BYTE NID::kEnd
+
+
+Folder
+~~~~~~
+ UINT64 NumCoders;
+ for (NumCoders)
+ {
+ BYTE
+ {
+ 0:3 CodecIdSize
+ 4: Is Complex Coder
+ 5: There Are Attributes
+ 6: Reserved
+ 7: There are more alternative methods. (Not used anymore, must be 0).
+ }
+ BYTE CodecId[CodecIdSize]
+ if (Is Complex Coder)
+ {
+ UINT64 NumInStreams;
+ UINT64 NumOutStreams;
+ }
+ if (There Are Attributes)
+ {
+ UINT64 PropertiesSize
+ BYTE Properties[PropertiesSize]
+ }
+ }
+
+ NumBindPairs = NumOutStreamsTotal - 1;
+
+ for (NumBindPairs)
+ {
+ UINT64 InIndex;
+ UINT64 OutIndex;
+ }
+
+ NumPackedStreams = NumInStreamsTotal - NumBindPairs;
+ if (NumPackedStreams > 1)
+ for(NumPackedStreams)
+ {
+ UINT64 Index;
+ };
+
+
+
+
+Coders Info
+~~~~~~~~~~~
+
+ BYTE NID::kUnPackInfo (0x07)
+
+
+ BYTE NID::kFolder (0x0B)
+ UINT64 NumFolders
+ BYTE External
+ switch(External)
+ {
+ case 0:
+ Folders[NumFolders]
+ case 1:
+ UINT64 DataStreamIndex
+ }
+
+
+ BYTE ID::kCodersUnPackSize (0x0C)
+ for(Folders)
+ for(Folder.NumOutStreams)
+ UINT64 UnPackSize;
+
+
+ []
+ BYTE NID::kCRC (0x0A)
+ UnPackDigests[NumFolders]
+ []
+
+
+
+ BYTE NID::kEnd
+
+
+
+SubStreams Info
+~~~~~~~~~~~~~~
+ BYTE NID::kSubStreamsInfo; (0x08)
+
+ []
+ BYTE NID::kNumUnPackStream; (0x0D)
+ UINT64 NumUnPackStreamsInFolders[NumFolders];
+ []
+
+
+ []
+ BYTE NID::kSize (0x09)
+ UINT64 UnPackSizes[]
+ []
+
+
+ []
+ BYTE NID::kCRC (0x0A)
+ Digests[Number of streams with unknown CRC]
+ []
+
+
+ BYTE NID::kEnd
+
+
+Streams Info
+~~~~~~~~~~~~
+
+ []
+ PackInfo
+ []
+
+
+ []
+ CodersInfo
+ []
+
+
+ []
+ SubStreamsInfo
+ []
+
+ BYTE NID::kEnd
+
+
+FilesInfo
+~~~~~~~~~
+ BYTE NID::kFilesInfo; (0x05)
+ UINT64 NumFiles
+
+ for (;;)
+ {
+ BYTE PropertyType;
+ if (aType == 0)
+ break;
+
+ UINT64 Size;
+
+ switch(PropertyType)
+ {
+ kEmptyStream: (0x0E)
+ for(NumFiles)
+ BIT IsEmptyStream
+
+ kEmptyFile: (0x0F)
+ for(EmptyStreams)
+ BIT IsEmptyFile
+
+ kAnti: (0x10)
+ for(EmptyStreams)
+ BIT IsAntiFile
+
+ case kCTime: (0x12)
+ case kATime: (0x13)
+ case kMTime: (0x14)
+ BYTE AllAreDefined
+ if (AllAreDefined == 0)
+ {
+ for(NumFiles)
+ BIT TimeDefined
+ }
+ BYTE External;
+ if(External != 0)
+ UINT64 DataIndex
+ []
+ for(Definded Items)
+ UINT32 Time
+ []
+
+ kNames: (0x11)
+ BYTE External;
+ if(External != 0)
+ UINT64 DataIndex
+ []
+ for(Files)
+ {
+ wchar_t Names[NameSize];
+ wchar_t 0;
+ }
+ []
+
+ kAttributes: (0x15)
+ BYTE AllAreDefined
+ if (AllAreDefined == 0)
+ {
+ for(NumFiles)
+ BIT AttributesAreDefined
+ }
+ BYTE External;
+ if(External != 0)
+ UINT64 DataIndex
+ []
+ for(Definded Attributes)
+ UINT32 Attributes
+ []
+ }
+ }
+
+
+Header
+~~~~~~
+ BYTE NID::kHeader (0x01)
+
+ []
+ ArchiveProperties
+ []
+
+ []
+ BYTE NID::kAdditionalStreamsInfo; (0x03)
+ StreamsInfo
+ []
+
+ []
+ BYTE NID::kMainStreamsInfo; (0x04)
+ StreamsInfo
+ []
+
+ []
+ FilesInfo
+ []
+
+ BYTE NID::kEnd
+
+
+HeaderInfo
+~~~~~~~~~~
+ []
+ BYTE NID::kEncodedHeader; (0x17)
+ StreamsInfo for Encoded Header
+ []
+
+
+---
+End of document
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/License.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/License.txt
new file mode 100644
index 000000000..a2f6df0b9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/License.txt
@@ -0,0 +1,52 @@
+ 7-Zip source code
+ ~~~~~~~~~~~~~~~~~
+ License for use and distribution
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ 7-Zip Copyright (C) 1999-2009 Igor Pavlov.
+
+ Licenses for files are:
+
+ 1) CPP/7zip/Compress/Rar* files: GNU LGPL + unRAR restriction
+ 2) All other files: GNU LGPL
+
+ The GNU LGPL + unRAR restriction means that you must follow both
+ GNU LGPL rules and unRAR restriction rules.
+
+
+ GNU LGPL information
+ --------------------
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+ unRAR restriction
+ -----------------
+
+ The decompression engine for RAR archives was developed using source
+ code of unRAR program.
+ All copyrights to original unRAR code are owned by Alexander Roshal.
+
+ The license for original unRAR code has the following restriction:
+
+ The unRAR sources cannot be used to re-create the RAR compression algorithm,
+ which is proprietary. Distribution of modified unRAR sources in separate form
+ or as a part of other software is permitted, provided that it is clearly
+ stated in the documentation and source comments that the code may
+ not be used to develop a RAR (WinRAR) compatible archiver.
+
+
+ --
+ Igor Pavlov
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/add.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/add.htm
new file mode 100644
index 000000000..7bc5ea22f
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/add.htm
@@ -0,0 +1,87 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>a (Add) command</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>a (Add) command</H1>
+
+<P>Adds files to archive.</P>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z a archive1.zip subdir\
+</PRE>
+
+<P>adds all files and subfolders from folder <SPAN class="filename">subdir</SPAN> to archive
+ <SPAN class="filename">archive1.zip</SPAN>.
+ The filenames in archive will contain <SPAN class="filename">subdir\</SPAN> prefix.</P>
+
+<PRE class="example">
+7z a archive2.zip .\subdir\*
+</PRE>
+
+<P>adds all files and subfolders from folder <SPAN class="filename">subdir</SPAN> to archive
+ <SPAN class="filename">archive2.zip</SPAN>.
+ The filenames in archive will not contain <SPAN class="filename">subdir\</SPAN> prefix.</P>
+
+
+<PRE class="example">
+cd /D c:\dir1\
+7z a c:\archive3.zip dir2\dir3\
+</PRE>
+
+The filenames in archive <SPAN class="filename">c:\archive3.zip</SPAN>
+will contain <SPAN class="filename">dir2\dir3\</SPAN> prefix,
+but they will not contain <SPAN class="filename">c:\dir1\</SPAN> prefix.
+
+<PRE class="example">
+7z a Files.7z *.txt -r
+</PRE>
+
+<P>adds all *.txt files from current folder and its subfolders to archive
+ <SPAN class="filename">Files.7z</SPAN>.</P>
+
+
+<H4>Notes</H4>
+
+<P>7-Zip doesn't uses the system wildcard parser. 7-Zip doesn't
+follow the archaic rule by which *.* means any file. 7-Zip treats
+*.* as matching the name of any file that has an extension. To process
+all files, you must use a * wildcard.</P>
+
+
+<H4>Switches that can be used with this command</H4>
+
+<P>
+ <A href="../switches/include.htm">-i (Include)</A><BR>
+ <A href="../switches/method.htm">-m (Method)</A><BR>
+ <A href="../switches/password.htm">-p (Set Password)</A><BR>
+ <A href="../switches/recurse.htm">-r (Recurse)</A><BR>
+ <A href="../switches/sfx.htm">-sfx (create SFX)</A><BR>
+ <A href="../switches/stdin.htm">-si (use StdIn)</A><BR>
+ <A href="../switches/stdout.htm">-so (use StdOut)</A><BR>
+ <A href="../switches/type.htm">-t (Type of archive)</A><BR>
+ <A href="../switches/update.htm">-u (Update)</A><BR>
+ <A href="../switches/volume.htm">-v (Volumes)</A><BR>
+ <A href="../switches/working_dir.htm">-w (Working Dir)</A><BR>
+ <A href="../switches/exclude.htm">-x (Exclude)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Commands:</B>
+ <A href="delete.htm">d (Delete)</A>,
+ <A href="update.htm">u (Update)</A><BR>
+ <B>Switches:</B>
+ <A href="../switches/update.htm">-u (Update)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/bench.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/bench.htm
new file mode 100644
index 000000000..14f456cd3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/bench.htm
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>b (Benchmark) command</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>b (Benchmark) command</H1>
+
+<P>Measures speed of the CPU and checks RAM for errors.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+b [number_of_iterations] [-mmt{N}] [-md{N}] [-mm={Method}]
+</PRE>
+
+<P>There are two tests:<P>
+<OL>
+ <LI>Compressing with LZMA method
+ <LI>Decompressing with LZMA method
+</OL>
+
+<P>The benchmark shows a rating in MIPS (million instructions per second).
+The rating value is calculated from the measured CPU speed and it
+is normalized with results of Intel Core 2 CPU with multi-threading option
+switched off. So if you have Intel Core 2 Duo,
+rating values must be close to real CPU frequency.</P>
+
+<P>You can change the upper dictionary size to increase memory usage by -md{N} switch.
+Also, you can change the number of threads by -mmt{N} switch.</P>
+
+<P>The <B>Dict</B> column shows dictionary size. For example, 21 means 2^21 = 2 MB.</P>
+
+<P>The <B>Usage</B> column shows the percentage of time the processor is working.
+It's normalized for a one-thread load. For example, 180% CPU Usage for 2 threads
+can mean that average CPU usage is about 90% for each thread.</P>
+
+<P>The <B>R / U</B> column shows the rating normalized for 100% of CPU usage.
+That column shows the performance of one average CPU thread.</P>
+
+<P><B>Avr</B> shows averages for different dictionary sizes.</P>
+<P><B>Tot</B> shows averages of the compression and decompression ratings.</P>
+
+<P>Compression speed and rating strongly depend on memory (RAM) latency.
+
+<P>Decompression speed and rating strongly depend on the integer performance of the CPU.
+For example, the Intel Pentium 4 has big branch
+misprediction penalty (which is an effect of its long pipeline) and pretty slow
+multiply and shift operations. So, the Pentium 4 has pretty low decompressing ratings.</P>
+
+<P>You can run a CRC calculation benchmark by specifying -mm=crc.
+That test shows the speed of CRC calculation in MB/s. The first column shows the size of the block.
+The next column shows the speed of CRC calculation for one thread. The other columns are results
+for multi-threaded CRC calculation.</P>
+
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z b
+</PRE>
+runs benchmarking.
+
+<PRE class="example">
+7z b -mmt1 -md26
+</PRE>
+runs benchmarking with one thread and 64 MB dictionary.
+
+<PRE class="example">
+7z b 30
+</PRE>
+<P>runs benchmarking with default settings for 30 iterations.</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/delete.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/delete.htm
new file mode 100644
index 000000000..845b8d899
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/delete.htm
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>d (Delete) command</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>d (Delete) command</H1>
+
+<P>Deletes files from archive.</P>
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z d archive.zip *.bak -r
+</PRE>
+
+<P>deletes <SPAN class="filename">*.bak</SPAN> files from archive
+ <SPAN class="filename">archive.zip</SPAN>.</P>
+
+
+<H4>Notes</H4>
+
+<P>7-Zip doesn't uses the system wildcard parser. 7-Zip doesn't
+follow the archaic rule by which *.* means any file. 7-Zip treats
+*.* as matching the name of any file that has an extension. To process
+all files, you must use a * wildcard.</P>
+
+
+<H4>Switches that can be used with this command</H4>
+
+<P>
+ <A href="../switches/include.htm">-i (Include)</A><BR>
+ <A href="../switches/method.htm">-m (Method)</A><BR>
+ <A href="../switches/password.htm">-p (Set Password)</A><BR>
+ <A href="../switches/recurse.htm">-r (Recurse)</A><BR>
+ <A href="../switches/update.htm">-u (Update)</A><BR>
+ <A href="../switches/working_dir.htm">-w (Working Dir)</A><BR>
+ <A href="../switches/exclude.htm">-x (Exclude)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Commands:</B>
+ <A href="add.htm">a (Add)</A>,
+ <A href="update.htm">u (Update)</A>
+</P>
+
+<P>
+ <B>Switches:</B>
+ <A href="../switches/update.htm">-u (Update)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/extract.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/extract.htm
new file mode 100644
index 000000000..dad6b2b0b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/extract.htm
@@ -0,0 +1,91 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>e (Extract) command</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>e (Extract) command</H1>
+
+<P>Extracts files from an archive to the current
+directory or to the output directory. The output directory can be specified by
+<A href="../switches/output_dir.htm">-o (Set Output Directory)</A> switch.</P>
+
+<P>This command copies all extracted files to one directory.
+If you want extract files with full paths, you must use
+<A href="extract_full.htm">x (Extract with full paths)</A> command.
+
+<P>7-Zip will prompt the user before overwriting existing files unless
+the user specifies the <A href="../switches/yes.htm">-y (Assume Yes on all queries)</A>
+switch. If the user gives a <B>no</B> answer, 7-Zip will prompt for the file to be
+extracted to a new filename. Then a <B>no</B> answer skips that file; or, <B>yes</B>
+prompts for new filename.</P>
+
+<P>7-Zip accepts the following responses:</P>
+
+<TABLE>
+ <TR> <TH>Answer</TH> <TH>Abbr.</TH> <TH>Action</TH> </TR>
+ <TR> <TD>Yes</TD> <TD>y</TD> <TD>&nbsp;</TD> </TR>
+ <TR> <TD>No</TD> <TD>n</TD> <TD>&nbsp;</TD> </TR>
+ <TR> <TD>Always</TD> <TD>a</TD> <TD>Assume YES for ALL subsequent queries of the same class</TD> </TR>
+ <TR> <TD>Skip</TD> <TD>s</TD> <TD>Assume NO for ALL subsequent queries of the same class</TD> </TR>
+ <TR> <TD>Quit</TD> <TD>q</TD> <TD>Quit the program</TD> </TR>
+
+</TABLE>
+
+<P>Abbreviated responses are allowed.</P>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z e archive.zip
+</PRE>
+
+<P>extracts all files from archive
+ <SPAN class="filename">archive.zip</SPAN> to the current directory.</P>
+
+<PRE class="example">
+7z e archive.zip -oc:\soft *.cpp -r
+</PRE>
+
+<P>extracts all <SPAN class="filename">*.cpp</SPAN> files from archive
+ <SPAN class="filename">archive.zip</SPAN> to <SPAN class="filename">c:\soft</SPAN> folder.</P>
+
+
+<H4>Notes</H4>
+
+<P>7-Zip doesn't uses the system wildcard parser. 7-Zip doesn't
+follow the archaic rule by which *.* means any file. 7-Zip treats
+*.* as matching the name of any file that has an extension. To process
+all files, you must use a * wildcard.</P>
+
+
+<H4>Switches that can be used with this command</H4>
+
+<P>
+ <A href="../switches/ar_include.htm">-ai (Include archives)</A><BR>
+ <A href="../switches/ar_no.htm">-an (Disable parsing of archive_name)</A><BR>
+ <A href="../switches/overwrite.htm">-ao (Overwrite mode)</A><BR>
+ <A href="../switches/ar_exclude.htm">-ax (Exclude archives)</A><BR>
+ <A href="../switches/include.htm">-i (Include)</A><BR>
+ <A href="../switches/output_dir.htm">-o (Set Output Directory)</A><BR>
+ <A href="../switches/password.htm">-p (Set Password)</A><BR>
+ <A href="../switches/recurse.htm">-r (Recurse)</A><BR>
+ <A href="../switches/stdout.htm">-so (use StdOut)</A><BR>
+ <A href="../switches/type.htm">-t (Type of archive)</A><BR>
+ <A href="../switches/exclude.htm">-x (Exclude)</A><BR>
+ <A href="../switches/yes.htm">-y (Assume Yes on all queries)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Commands:</B>
+ <A href="extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/extract_full.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/extract_full.htm
new file mode 100644
index 000000000..03b447c85
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/extract_full.htm
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>x (Extract with full paths) command</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>x (Extract with full paths) command</H1>
+
+<P>Extracts files from an archive with their full
+paths in the current directory, or in an output directory if specified.</P>
+
+<P>See the <A href="extract.htm">e (Extract)</A> command description for more deatails.</P>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z x archive.zip
+</PRE>
+
+<P>extracts all files from the archive
+ <SPAN class="filename">archive.zip</SPAN> to the current directory.</P>
+
+<PRE class="example">
+7z x archive.zip -oc:\soft *.cpp -r
+</PRE>
+
+<P>extracts all <SPAN class="filename">*.cpp</SPAN> files from the archive
+ <SPAN class="filename">archive.zip</SPAN> to <SPAN class="filename">c:\soft</SPAN> folder.</P>
+
+
+<H4>Notes</H4>
+
+<P>7-Zip doesn't uses the system wildcard parser. 7-Zip doesn't
+follow the archaic rule by which *.* means any file. 7-Zip treats
+*.* as matching the name of any file that has an extension. To process
+all files, you must use a * wildcard.</P>
+
+
+<H4>Switches that can be used with this command</H4>
+
+<P>
+ <A href="../switches/ar_include.htm">-ai (Include archives)</A><BR>
+ <A href="../switches/ar_no.htm">-an (Disable parsing of archive_name)</A><BR>
+ <A href="../switches/overwrite.htm">-ao (Overwrite mode)</A><BR>
+ <A href="../switches/ar_exclude.htm">-ax (Exclude archives)</A><BR>
+ <A href="../switches/include.htm">-i (Include)</A><BR>
+ <A href="../switches/output_dir.htm">-o (Set Output Directory)</A><BR>
+ <A href="../switches/password.htm">-p (Set Password)</A><BR>
+ <A href="../switches/recurse.htm">-r (Recurse)</A><BR>
+ <A href="../switches/stdout.htm">-so (use StdOut)</A><BR>
+ <A href="../switches/type.htm">-t (Type of archive)</A><BR>
+ <A href="../switches/exclude.htm">-x (Exclude)</A><BR>
+ <A href="../switches/yes.htm">-y (Assume Yes on all queries)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Commands:</B>
+ <A href="extract.htm">e (Extract)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/index.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/index.htm
new file mode 100644
index 000000000..579ea2931
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/index.htm
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>Command Line Commands</TITLE>
+ <LINK href="style.css" rel=stylesheet type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>Command Line Commands</H1>
+
+<P>The command is the first non-switch argument on the command line.</P>
+<P>Command names are not case sensitive.</P>
+<P>See also <A href ="../syntax.htm">Command Line Syntax</A> for more details about using the command line.</P>
+
+<H2>Commands quick reference</H2>
+
+<TABLE border="1" cellpadding="3" cellspacing="0">
+<TR><TH>Command</TH><TH>Description</TH></TR>
+<TR> <TD><A href="add.htm">a</A></TD> <TD><A href="add.htm">Add</A></TD></TR>
+<TR> <TD><A href="bench.htm">b</A></TD> <TD><A href="bench.htm">Benchmark</A></TD></TR>
+<TR> <TD><A href="delete.htm">d</A></TD> <TD><A href="delete.htm">Delete</A></TD></TR>
+<TR> <TD><A href="extract.htm">e</A></TD> <TD><A href="extract.htm">Extract</A></TD></TR>
+<TR> <TD><A href="list.htm">l</A></TD> <TD><A href="list.htm">List</A></TD></TR>
+<TR> <TD><A href="test.htm">t</A></TD> <TD><A href="test.htm">Test</A></TD></TR>
+<TR> <TD><A href="update.htm">u</A></TD> <TD><A href="update.htm">Update</A></TD></TR>
+<TR> <TD><A href="extract_full.htm">x</A></TD> <TD><A href="extract_full.htm">eXtract with full paths</A></TD></TR>
+</TABLE>
+
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/list.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/list.htm
new file mode 100644
index 000000000..1eba758e9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/list.htm
@@ -0,0 +1,77 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>l (List contents of archive) command</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>l (List contents of archive) command</H1>
+
+
+
+<!--
+<H4>Syntax</H4>
+<P><PRE class="syntax">
+l[a | t][f]
+</PRE></P>
+
+-->
+
+<P>Lists contents of archive.</P>
+
+<!--
+<P>The following options can be used:</P>
+<TABLE>
+<TR> <TH>Option</TH> <TH>Description</TH> </TR>
+<TR> <TD>a</TD> <TD>List with Additional fields</TD> </TR>
+<TR> <TD>t</TD> <TD>List with all fields, including Technical</TD> </TR>
+<TR> <TD>f</TD> <TD>List with Full pathnames</TD> </TR>
+</TABLE>
+-->
+
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z l archive.zip
+</PRE>
+
+<P>lists all files from archive <SPAN class="filename">archive.zip</SPAN>.</P>
+
+<!--
+<PRE class="example">
+7z lf archive.zip *.txt
+</PRE>
+
+<P>lists <SPAN class="filename">*.txt</SPAN> files from archive
+ <SPAN class="filename">archive.zip</SPAN> with full pathnames.</P>
+-->
+
+
+<H4>Notes</H4>
+
+<P>7-Zip doesn't uses the system wildcard parser. 7-Zip doesn't
+follow the archaic rule by which *.* means any file. 7-Zip treats
+*.* as matching the name of any file that has an extension. To process
+all files, you must use a * wildcard.</P>
+
+
+<H4>Switches that can be used with this command</H4>
+
+<P>
+ <A href="../switches/ar_include.htm">-ai (Include archives)</A><BR>
+ <A href="../switches/ar_no.htm">-an (Disable parsing of archive_name)</A><BR>
+ <A href="../switches/ar_exclude.htm">-ax (Exclude archives)</A><BR>
+ <A href="../switches/include.htm">-i (Include)</A><BR>
+ <A href="../switches/list_tech.htm">-slt (Show technical information)</A><BR>
+ <A href="../switches/password.htm">-p (Set Password)</A><BR>
+ <A href="../switches/recurse.htm">-r (Recurse)</A><BR>
+ <A href="../switches/type.htm">-t (Type of archive)</A><BR>
+ <A href="../switches/exclude.htm">-x (Exclude)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/style.css b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/style.css
new file mode 100644
index 000000000..13ebb79ce
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/style.css
@@ -0,0 +1,232 @@
+body
+ {
+ padding: 0px 0px 0px 26px;
+ background: #ffffff;
+ color: #000000;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 80%;
+ }
+
+div
+ {
+ width: 90%;
+ border: 2px solid #999999;
+ padding: 4px 8px;
+ background: #cccccc;
+ }
+
+h1, h2, h3, h4
+ {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ margin-left: -26px;
+ }
+
+h1
+ {
+ font-size: 145%;
+ margin-top: .5em;
+ margin-bottom: 1em;
+ }
+
+h2
+ {
+ font-size: 130%;
+ margin-top: 1.5em;
+ margin-bottom: .6em;
+ }
+
+h3
+ {
+ font-size: 115%;
+ margin-top: 1.5em;
+ margin-bottom: .6em;
+ }
+
+h4
+ {
+ font-size: 100%;
+ margin-top: 1.5em;
+ margin-bottom: .6em;
+ }
+
+ul p, ol p, dl p
+ {
+ margin-left: 0em;
+ }
+
+p
+ {
+ margin-top: .6em;
+ margin-bottom: .6em;
+ }
+
+dl
+ {
+ /*margin-top: 0em; */
+ }
+
+dt
+ {
+ margin-top: .76em;
+ margin-bottom: .5em;
+ font-weight: bold;
+ }
+
+dd
+ {
+ margin-top: .5em;
+ margin-bottom: .5em;
+ margin-left: 1.9em;
+ }
+
+
+ul, ol
+ {
+ margin-top: .6em;
+ margin-bottom: 0em;
+ }
+
+ol
+ {
+ margin-left: 3.6em;
+ }
+
+ul
+ {
+ list-style-type: disc;
+ margin-left: 1.9em;
+ }
+
+li
+ {
+ margin-bottom: .6em;
+ }
+
+ul ol, ol ol
+ {
+ list-style-type: lower-alpha;
+ {
+
+ /*
+pre
+ {
+ margin-top: .6em;
+ margin-bottom: .6em;
+ }
+ */
+
+pre,code
+ {
+ font: 100% Courier New, Courier, mono;
+ color: #000000;
+ cursor: text;
+ }
+
+pre.syntax
+ {
+ background: #dddddd;
+ padding: 2pt,4pt
+ }
+
+pre.syntax
+ {
+ color: #000000;
+ }
+
+pre.example
+ {
+ margin-left: 2.0em;
+ /*margin-top: 12.0em;*/
+ /*margin-bottom: 1.0em;*/
+ color: #C00000;
+ /*padding: 10pt,20pt*/
+ }
+
+table
+ {
+ /* width: 90%; */
+ background: #999999;
+ margin-top: .6em;
+ margin-bottom: .3em;
+ }
+
+th
+ {
+ padding: 4px 8px;
+ background: #cccccc;
+ text-align: left;
+ font-size: 80%;
+ vertical-align: bottom;
+ }
+
+th.cc
+ {
+ text-align: center;
+ vertical-align: middle;
+ }
+
+td
+ {
+ padding: 4px 8px;
+ background: #ffffff;
+ vertical-align: top;
+ font-size: 80%;
+ }
+
+td.cc
+ {
+ text-align: center;
+ vertical-align: middle;
+ }
+
+
+blockquote
+ {
+ margin-left: 3.8em;
+ margin-right: 3.8em;
+ margin-top: .6em;
+ margin-bottom: .6em;
+ }
+
+a:link
+ {
+ color: #0066ff;
+ }
+
+a:visited
+ {
+ color: #996600;
+ }
+
+a:hover
+ {
+ color: #cc9900;
+ }
+
+a.parameter:link
+ {
+ color: #0066ff;
+ text-decoration:none;
+ }
+
+a.parameter:visited
+ {
+ text-decoration:none;
+ }
+
+div.footer
+ {
+ width: 100%;
+ border: none;
+ background: #ffffff;
+ margin-top: 18pt;
+ padding-bottom: 12pt;
+ color: #228B22;
+ text-align: center;
+ font-size: 70%;
+ }
+
+span.filename
+{
+ color: #F00000;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/test.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/test.htm
new file mode 100644
index 000000000..b09f8a497
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/test.htm
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>t (Test integrity of archive) command</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>t (Test integrity of archive) command</H1>
+
+<P>Tests archive files.</P>
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z t archive.zip *.doc -r
+</PRE>
+
+<P>tests <SPAN class="filename">*.doc</SPAN> files in archive
+ <SPAN class="filename">archive.zip</SPAN>.</P>
+
+
+<H4>Notes</H4>
+
+<P>7-Zip doesn't uses the system wildcard parser. 7-Zip doesn't
+follow the archaic rule by which *.* means any file. 7-Zip treats
+*.* as matching the name of any file that has an extension. To process
+all files, you must use a * wildcard.</P>
+
+
+<H4>Switches that can be used with this command</H4>
+
+<P>
+ <A href="../switches/ar_include.htm">-ai (Include archives)</A><BR>
+ <A href="../switches/ar_no.htm">-an (Disable parsing of archive_name)</A><BR>
+ <A href="../switches/ar_exclude.htm">-ax (Exclude archives)</A><BR>
+ <A href="../switches/include.htm">-i (Include)</A><BR>
+ <A href="../switches/password.htm">-p (Set Password)</A><BR>
+ <A href="../switches/recurse.htm">-r (Recurse)</A><BR>
+ <A href="../switches/exclude.htm">-x (Exclude)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/update.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/update.htm
new file mode 100644
index 000000000..860080109
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/commands/update.htm
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>u (Update) command</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>u (Update) command</H1>
+
+<P>Update older files in the archive and add files that are not already in the archive.</P>
+
+<P>Note: the updating of solid .7z archives can be slow, since it
+can require some recompression.</P>
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z u archive.zip *.doc
+</PRE>
+
+<P>updates <SPAN class="filename">*.doc</SPAN> files to archive
+ <SPAN class="filename">archive.zip</SPAN>.</P>
+
+
+<H4>Notes</H4>
+
+<P>7-Zip doesn't uses the system wildcard parser. 7-Zip doesn't
+follow the archaic rule by which *.* means any file. 7-Zip treats
+*.* as matching the name of any file that has an extension. To process
+all files, you must use a * wildcard.</P>
+
+
+<H4>Switches that can be used with this command</H4>
+
+<P>
+ <A href="../switches/include.htm">-i (Include)</A><BR>
+ <A href="../switches/method.htm">-m (Method)</A><BR>
+ <A href="../switches/password.htm">-p (Set Password)</A><BR>
+ <A href="../switches/recurse.htm">-r (Recurse)</A><BR>
+ <A href="../switches/sfx.htm">-sfx (create SFX)</A><BR>
+ <A href="../switches/stdin.htm">-si (use StdIn)</A><BR>
+ <A href="../switches/stdout.htm">-so (use StdOut)</A><BR>
+ <A href="../switches/type.htm">-t (Type of archive)</A><BR>
+ <A href="../switches/update.htm">-u (Update)</A><BR>
+ <A href="../switches/working_dir.htm">-w (Working Dir)</A><BR>
+ <A href="../switches/exclude.htm">-x (Exclude)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Commands:</B>
+ <A href="add.htm">a (Add)</A>,
+ <A href="delete.htm">d (Delete)</A>,
+</P>
+
+<P>
+ <B>Switches:</B>
+ <A href="../switches/update.htm">-u (Update)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/exit_codes.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/exit_codes.htm
new file mode 100644
index 000000000..4cdc74a5b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/exit_codes.htm
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>Exit Codes from 7-Zip</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>Exit Codes from 7-Zip</H1>
+
+<P>7-Zip returns the following exit codes:</P>
+
+<TABLE>
+ <TR><TH>Code</TH><TH>Meaning</TH></TR>
+ <TR><TD>0</TH><TD>No error</TD></TR>
+ <TR><TD>1</TH><TD>Warning (Non fatal error(s)). For example, one or more files were
+ locked by some other application, so they were not compressed.</TD></TR>
+ <TR><TD>2</TH><TD>Fatal error</TD></TR>
+ <TR><TD>7</TH><TD>Command line error</TD></TR>
+ <TR><TD>8</TH><TD>Not enough memory for operation</TD></TR>
+ <TR><TD>255</TH><TD>User stopped the process</TD></TR>
+</TABLE>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/index.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/index.htm
new file mode 100644
index 000000000..5bf8aae61
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/index.htm
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>Command Line Version User's Guide</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>Command Line Version User's Guide</H1>
+
+
+<P>7z.exe is the command line version of 7-Zip. 7z.exe uses 7z.dll
+from the 7-Zip package. 7z.dll is used by the 7-Zip File Manager also.</LI>
+
+<P>7za.exe (a = alone) is a standalone version of 7-Zip.
+7za.exe supports only 7z, lzma, cab, zip, gzip, bzip2, Z and tar formats.
+7za.exe doesn't use external modules.</LI>
+
+<UL>
+ <LI><A href = "syntax.htm">Command Line syntax</A></LI>
+ <LI><A href = "exit_codes.htm">Exit Codes</A></LI>
+ <LI><A href = "commands/index.htm">Commands</A></LI>
+ <LI><A href = "switches/index.htm">Switches</A></LI>
+</UL>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/style.css b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/style.css
new file mode 100644
index 000000000..13ebb79ce
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/style.css
@@ -0,0 +1,232 @@
+body
+ {
+ padding: 0px 0px 0px 26px;
+ background: #ffffff;
+ color: #000000;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 80%;
+ }
+
+div
+ {
+ width: 90%;
+ border: 2px solid #999999;
+ padding: 4px 8px;
+ background: #cccccc;
+ }
+
+h1, h2, h3, h4
+ {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ margin-left: -26px;
+ }
+
+h1
+ {
+ font-size: 145%;
+ margin-top: .5em;
+ margin-bottom: 1em;
+ }
+
+h2
+ {
+ font-size: 130%;
+ margin-top: 1.5em;
+ margin-bottom: .6em;
+ }
+
+h3
+ {
+ font-size: 115%;
+ margin-top: 1.5em;
+ margin-bottom: .6em;
+ }
+
+h4
+ {
+ font-size: 100%;
+ margin-top: 1.5em;
+ margin-bottom: .6em;
+ }
+
+ul p, ol p, dl p
+ {
+ margin-left: 0em;
+ }
+
+p
+ {
+ margin-top: .6em;
+ margin-bottom: .6em;
+ }
+
+dl
+ {
+ /*margin-top: 0em; */
+ }
+
+dt
+ {
+ margin-top: .76em;
+ margin-bottom: .5em;
+ font-weight: bold;
+ }
+
+dd
+ {
+ margin-top: .5em;
+ margin-bottom: .5em;
+ margin-left: 1.9em;
+ }
+
+
+ul, ol
+ {
+ margin-top: .6em;
+ margin-bottom: 0em;
+ }
+
+ol
+ {
+ margin-left: 3.6em;
+ }
+
+ul
+ {
+ list-style-type: disc;
+ margin-left: 1.9em;
+ }
+
+li
+ {
+ margin-bottom: .6em;
+ }
+
+ul ol, ol ol
+ {
+ list-style-type: lower-alpha;
+ {
+
+ /*
+pre
+ {
+ margin-top: .6em;
+ margin-bottom: .6em;
+ }
+ */
+
+pre,code
+ {
+ font: 100% Courier New, Courier, mono;
+ color: #000000;
+ cursor: text;
+ }
+
+pre.syntax
+ {
+ background: #dddddd;
+ padding: 2pt,4pt
+ }
+
+pre.syntax
+ {
+ color: #000000;
+ }
+
+pre.example
+ {
+ margin-left: 2.0em;
+ /*margin-top: 12.0em;*/
+ /*margin-bottom: 1.0em;*/
+ color: #C00000;
+ /*padding: 10pt,20pt*/
+ }
+
+table
+ {
+ /* width: 90%; */
+ background: #999999;
+ margin-top: .6em;
+ margin-bottom: .3em;
+ }
+
+th
+ {
+ padding: 4px 8px;
+ background: #cccccc;
+ text-align: left;
+ font-size: 80%;
+ vertical-align: bottom;
+ }
+
+th.cc
+ {
+ text-align: center;
+ vertical-align: middle;
+ }
+
+td
+ {
+ padding: 4px 8px;
+ background: #ffffff;
+ vertical-align: top;
+ font-size: 80%;
+ }
+
+td.cc
+ {
+ text-align: center;
+ vertical-align: middle;
+ }
+
+
+blockquote
+ {
+ margin-left: 3.8em;
+ margin-right: 3.8em;
+ margin-top: .6em;
+ margin-bottom: .6em;
+ }
+
+a:link
+ {
+ color: #0066ff;
+ }
+
+a:visited
+ {
+ color: #996600;
+ }
+
+a:hover
+ {
+ color: #cc9900;
+ }
+
+a.parameter:link
+ {
+ color: #0066ff;
+ text-decoration:none;
+ }
+
+a.parameter:visited
+ {
+ text-decoration:none;
+ }
+
+div.footer
+ {
+ width: 100%;
+ border: none;
+ background: #ffffff;
+ margin-top: 18pt;
+ padding-bottom: 12pt;
+ color: #228B22;
+ text-align: center;
+ font-size: 70%;
+ }
+
+span.filename
+{
+ color: #F00000;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_exclude.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_exclude.htm
new file mode 100644
index 000000000..697891880
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_exclude.htm
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-ax (Exclude archive filenames) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-ax (Exclude archive filenames) switch</H1>
+
+<P>Specifies archives to be excluded from the operation.</P>
+<P>Multiple exclude archive switches are supported.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-ax[&lt;recurse_type>]&lt;file_ref>
+
+&lt;recurse_type> ::= r[- | 0]
+&lt;file_ref> ::= @{listfile} | !{wildcard}
+</PRE>
+
+<P>See <A href="include.htm">-xi (Include archive filenames)</A> switch description
+for information about option parameters.</P>
+
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z t -an -ai!*.7z -ax!a*.7z
+</PRE>
+
+<P>tests all <SPAN class="filename">*.7z</SPAN> archives,
+ except <SPAN class="filename">a*.7z</SPAN> archives.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/list.htm">l (List)</A>,
+ <A href="../commands/test.htm">t (Test)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Switches:</B>
+ <A href="include.htm">-ai (Include archives)</A>
+ <A href="ar_no.htm">-an (Disable parsing of archive_name)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_include.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_include.htm
new file mode 100644
index 000000000..30a5a9b69
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_include.htm
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-ai (Include archive filenames) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-ai (Include archive filenames) switch</H1>
+
+<P>Specifies additional include archive filenames and wildcards.</P>
+<P>Multiple include switches are supported.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-ai[<A class="parameter" href="#recurse_type">&lt;recurse_type></A>]<A class="parameter" href="#file_ref">&lt;file_ref></A>
+
+<A class="parameter" href="#recurse_type">&lt;recurse_type></A> ::= r[- | 0]
+<A class="parameter" href="#file_ref">&lt;file_ref></A> ::= @{listfile} | !{wildcard}
+</PRE>
+
+<H4>Parameters</H4>
+
+<DL>
+ <DT><A name="recurse_type"></A>&lt;recurse_type></DT>
+ <DD><P>Specifies how wildcards and file names in this switch must
+ be used. If this option is not given, recursion will be not used.
+ For more details see specification of the
+ <A href="recurse.htm">-r (Recurse)</A> switch.</P>
+<PRE class="syntax">
+&lt;recurse_type> ::= r[- | 0]
+</PRE>
+
+ </DD>
+ <DT><A name="file_ref"></A>&lt;file_ref></DT>
+ <DD>
+ <P>Specifies filenames and wildcards or list file that specify processed files.</P>
+<PRE class="syntax">
+&lt;file_ref> ::= @{listfile} | !{wildcard}
+</PRE>
+ <TABLE>
+ <TR> <TH width="120">Option</TH> <TH>Description</TH> </TR>
+ <TR> <TD>{listfile}</TD> <TD>Specifies name of list file. See
+ <A href = ../syntax.htm#ListFile>List file</A> description.</TD> </TR>
+ <TR> <TD>{wildcard}</TD> <TD>Specifies wildcard or filename.</TD> </TR>
+ </TABLE>
+ </DD>
+</DL>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z t -an -air!*.7z
+</PRE>
+
+<P>tests <SPAN class="filename">*.7z</SPAN> archives in current directory and all it's
+subdirectories.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/list.htm">l (List)</A>,
+ <A href="../commands/test.htm">t (Test)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Switches:</B>
+ <A href="ar_exclude.htm">-ax (Exclude archives)</A>
+ <A href="ar_no.htm">-an (Disable parsing of archive_name)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_no.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_no.htm
new file mode 100644
index 000000000..d925f13d3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ar_no.htm
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-an (Disable parsing of archive_name) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-an (Disable parsing of archive_name) switch</H1>
+
+<P>Disables parsing of the archive_name field on the command line.
+This switch must be used with the
+<A href="include.htm">-ai (Include archives) switch</A>.
+If you use a file list for your archives, you specify it with the -ai switch,
+so you need to disable parsing of archive_name field from command line.
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-an
+</PRE>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z t -an -ai!*.7z -ax!a*.7z
+</PRE>
+
+<P>tests all <SPAN class="filename">*.7z</SPAN> archives,
+ except <SPAN class="filename">a*.7z</SPAN> archives.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/list.htm">l (List)</A>,
+ <A href="../commands/test.htm">t (Test)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Switches:</B>
+ <A href="include.htm">-ai (Include archives)</A>
+ <A href="exclude.htm">-ax (Exclude archives)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/charset.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/charset.htm
new file mode 100644
index 000000000..e30802652
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/charset.htm
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-scs (Set charset for list files) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-scs (Set charset for list files) switch</H1>
+
+<P>Sets charset for list files.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-scs{UTF-8 | WIN | DOS}
+</PRE>
+
+<P>Default charset is UTF-8.</P>
+
+<DL>
+ <DT>UTF-8</DT>
+ <DD>Unicode UTF-8 character set.</DD>
+ <DT>WIN</DT>
+ <DD>Default character set of Windows.</DD>
+ <DT>DOS</DT>
+ <DD>Default DOS (OEM) character set of Windows.</DD>
+</DL>
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z a archive.7z @listfile.txt -scsWIN
+</PRE>
+
+<P>compresses files from <SPAN class="filename">listfile.txt</SPAN> list, that contains
+list of files in default character set of Windows.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/update.htm">u (Update)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/exclude.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/exclude.htm
new file mode 100644
index 000000000..faf8768e2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/exclude.htm
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-x (Exclude filenames) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-x (Exclude filenames) switch</H1>
+
+<P>Specifies which filenames or wildcarded names must be excluded from the operation.</P>
+<P>Multiple exclude switches are supported.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-x[&lt;recurse_type>]&lt;file_ref>
+
+&lt;recurse_type> ::= r[- | 0]
+&lt;file_ref> ::= @{listfile} | !{wildcard}
+</PRE>
+
+<P>See <A href="include.htm">-i (Include)</A> switch description for information about
+ option parameters.</P>
+
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z a -tzip archive.zip *.txt -x!temp.*
+</PRE>
+
+<P>adds to the archive <SPAN class="filename">archive.zip</SPAN> all
+ <SPAN class="filename">*.txt</SPAN> files,
+ except <SPAN class="filename">temp.*</SPAN> files.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/list.htm">l (List)</A>,
+ <A href="../commands/test.htm">t (Test)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Switches:</B>
+ <A href="recurse.htm">-r (Recurse)</A>,
+ <A href="include.htm">-i (Include)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/include.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/include.htm
new file mode 100644
index 000000000..009f5efcb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/include.htm
@@ -0,0 +1,87 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-i (Include filenames) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-i (Include filenames) switch</H1>
+
+<P>Specifies additional include filenames and wildcards.</P>
+<P>Multiple include switches are supported.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-i[<A class="parameter" href="#recurse_type">&lt;recurse_type></A>]<A class="parameter" href="#file_ref">&lt;file_ref></A>
+
+<A class="parameter" href="#recurse_type">&lt;recurse_type></A> ::= r[- | 0]
+<A class="parameter" href="#file_ref">&lt;file_ref></A> ::= @{listfile} | !{wildcard}
+</PRE>
+
+<H4>Parameters</H4>
+
+<DL>
+ <DT><A name="recurse_type"></A>&lt;recurse_type></DT>
+ <DD><P>Specifies how wildcards and file names in this switch must
+ be used. If this option is not given, then the global value, assigned
+ by the <A href="recurse.htm">-r (Recurse)</A> switch will be used. For
+ more details see specification of the
+ <A href="recurse.htm">-r (Recurse)</A> switch.</P>
+<PRE class="syntax">
+&lt;recurse_type> ::= r[- | 0]
+</PRE>
+
+ </DD>
+ <DT><A name="file_ref"></A>&lt;file_ref></DT>
+ <DD>
+ <P>Specifies filenames and wildcards, or a list file, for files to be processed.</P>
+<PRE class="syntax">
+&lt;file_ref> ::= @{listfile} | !{wildcard}
+</PRE>
+ <TABLE>
+ <TR> <TH width="120">Option</TH> <TH>Description</TH> </TR>
+ <TR> <TD>{listfile}</TD> <TD>Specifies name of list file. See
+ <A href = ../syntax.htm#ListFile>List file</A> description.</TD> </TR>
+ <TR> <TD>{wildcard}</TD> <TD>Specifies wildcard or filename.</TD> </TR>
+ </TABLE>
+ </DD>
+</DL>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z a -tzip src.zip *.txt -ir!DIR1\*.cpp
+</PRE>
+
+<P>adds to <SPAN class="filename">src.zip</SPAN> archive all
+ <SPAN class="filename">*.txt</SPAN> files from current directory
+ and all <SPAN class="filename">*.cpp</SPAN>
+ files from directory <SPAN class="filename">DIR1</SPAN>
+ and from all it's subdirectories.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/list.htm">l (List)</A>,
+ <A href="../commands/test.htm">t (Test)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Switches:</B>
+ <A href="recurse.htm">-r (Recurse)</A>,
+ <A href="exclude.htm">-x (Exclude)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/index.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/index.htm
new file mode 100644
index 000000000..8729487b3
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/index.htm
@@ -0,0 +1,63 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>Command Line Switches</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>Command Line Switches</H1>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+&ltswitch>::= &lt;switch_symbol>&lt;switch_characters>[&lt;option>]
+&lt;switch_symbol> ::= '/' | '-'
+
+</PRE>
+<P>On the command line, a switch consists of a switch specifier,
+either a dash (-) or a forward slash (/), followed by the name of
+the switch. Switch names cannot be abbreviated.</P>
+
+<P>Some switches take an argument after the switch name.
+No spaces or tabs are allowed within a switch specification.
+Switch names are not case sensitive, but arguments can be case sensitive.
+</P>
+
+<P>Switch can be used in any place in command line.</B>
+
+<P>See also <A href ="../syntax.htm">Command Line Syntax</A> for more details
+ about using the command line.</P>
+
+<H2>Switch quick reference</H2>
+
+<TABLE border="1" cellpadding="3" cellspacing="0">
+<TR><TH>Switch</TH><TH>Description</TH></TR>
+<TR> <TD><A href="stop_switch.htm">--</A></TD> <TD><A href="stop_switch.htm">Stop switches parsing</A></TD></TR>
+<TR> <TD><A href="ar_include.htm">-ai</A></TD> <TD><A href="ar_include.htm">Include archive filenames</A></TD></TR>
+<TR> <TD><A href="ar_no.htm">-an</A></TD> <TD><A href="ar_no.htm">Disable parsing of archive_name</A></TD></TR>
+<TR> <TD><A href="overwrite.htm">-ao</A></TD> <TD><A href="overwrite.htm">Overwrite mode</A></TD></TR>
+<TR> <TD><A href="ar_exclude.htm">-ax</A></TD> <TD><A href="ar_exclude.htm">Exclude archive filenames</A></TD></TR>
+<TR> <TD><A href="include.htm">-i</A></TD> <TD><A href="include.htm">Include filenames</A></TD></TR>
+<TR> <TD><A href="method.htm">-m</A></TD> <TD><A href="method.htm">Set Compression Method</A></TD></TR>
+<TR> <TD><A href="output_dir.htm">-o</A></TD> <TD><A href="output_dir.htm">Set Output directory</A></TD></TR>
+<TR> <TD><A href="password.htm">-p</A></TD> <TD><A href="password.htm">Set Password</A></TD></TR>
+<TR> <TD><A href="recurse.htm">-r</A></TD> <TD><A href="recurse.htm">Recurse subdirectories</A></TD></TR>
+<TR> <TD><A href="charset.htm">-scs</A></TD> <TD><A href="charset.htm">Set charset for list files</A></TD></TR>
+<TR> <TD><A href="list_tech.htm">-slt</A></TD> <TD><A href="list_tech.htm">Show technical information</A></TD></TR>
+<TR> <TD><A href="sfx.htm">-sfx</A></TD> <TD><A href="sfx.htm">Create SFX archive</A></TD></TR>
+<TR> <TD><A href="stdin.htm">-si</A></TD> <TD><A href="stdin.htm">Read data from StdIn</A></TD></TR>
+<TR> <TD><A href="stdout.htm">-so</A></TD> <TD><A href="stdout.htm">Write data to StdOut</A></TD></TR>
+<TR> <TD><A href="ssc.htm">-ssc</A></TD> <TD><A href="ssc.htm">Set Sensitive Case mode</A></TD></TR>
+<TR> <TD><A href="type.htm">-t</A></TD> <TD><A href="type.htm">Type of archive</A></TD></TR>
+<TR> <TD><A href="update.htm">-u</A></TD> <TD><A href="update.htm">Update options</A></TD></TR>
+<TR> <TD><A href="volume.htm">-v</A></TD> <TD><A href="volume.htm">Create Volumes</A></TD></TR>
+<TR> <TD><A href="working_dir.htm">-w</A></TD> <TD><A href="working_dir.htm">Set Working directory</A></TD></TR>
+<TR> <TD><A href="exclude.htm">-x</A></TD> <TD><A href="exclude.htm">Exclude filenames</A></TD></TR>
+<TR> <TD><A href="yes.htm">-y</A></TD> <TD><A href="yes.htm">Assume Yes on all queries</A></TD></TR>
+</TABLE>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/list_tech.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/list_tech.htm
new file mode 100644
index 000000000..aa8e522da
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/list_tech.htm
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-slt (Show technical information) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-slt (Show technical information) switch</H1>
+
+<P>Sets technical mode for <A href="../commands/list.htm">l (List)</A> command.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-slt
+</PRE>
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z l -slt archive.7z
+</PRE>
+
+<P>shows detailed technical information for the files in <SPAN class="filename">archive.7z</SPAN>.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/list.htm">l (List)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/method.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/method.htm
new file mode 100644
index 000000000..0ed75b2d8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/method.htm
@@ -0,0 +1,587 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-m (Set compression Method) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-m (Set compression Method) switch</H1>
+
+<P>Specifies the compression method.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-m&lt;method_parameters>
+
+</PRE>
+
+<P>The format for this switch depends on the archive type.</P>
+
+<UL>
+<LI><TD><A class="parameter" href="#Zip">Zip</A></TD>
+<LI><TD><A class="parameter" href="#GZ">GZip</A></TD>
+<LI><TD><A class="parameter" href="#BZ2">BZip2</A></TD>
+<LI><TD><A class="parameter" href="#7Z">7z</A></TD>
+<LI><TD><A class="parameter" href="#XZ">XZ</A></TD>
+</UL>
+
+<H2><A name="Zip"></A>Zip</H2>
+<TABLE>
+ <TR>
+ <TH width="160">Parameter</TH>
+ <TH align="center">Default</TH>
+ <TH>Description</TH> </TR>
+ <TR>
+ <TD><A class="parameter" href="#ZipX">x=[0 | 1 | 3 | 5 | 7 | 9 ]</A></TD>
+ <TD align="center">5</TD>
+ <TD>Sets level of compression.</TD> </TR>
+ <TR>
+ <TD>m={MethodID}</TD>
+ <TD align="center">Deflate</TD>
+ <TD>Sets a method: Copy, Deflate, Deflate64, BZip2, LZMA.</TD> </TR>
+ <TR>
+ <TD><A class="parameter" href="#Deflate_FastBytes">fb={NumFastBytes}</A></TD>
+ <TD align="center">32</TD>
+ <TD>Sets number of Fast Bytes for Deflate encoder.</TD> </TR>
+ <TR>
+ <TD><A class="parameter" href="#Zip_Pass">pass={NumPasses}</A></TD>
+ <TD align="center">1</TD>
+ <TD>Sets number of Passes for Deflate encoder.</TD></TR>
+ <TR>
+ <TD><A class="parameter" href="#ZipDictionarySize">d={Size}[b|k|m]</A></TD>
+ <TD align="center">900000</TD>
+ <TD>Sets Dictionary size for BZip2</TD></TR>
+ <TR>
+ <TD><A class="parameter" href="#ZipMultiThread">mt=[off | on | {N}]</A></TD>
+ <TD align="center">on</TD>
+ <TD>Sets multithreading mode.</TD></TR>
+ <TR>
+ <TD>em={EncryptionMethodID}</TD>
+ <TD align="center">ZipCrypto</TD>
+ <TD>Sets a encryption method: ZipCrypto, AES128, AES192, AES256</TD> </TR>
+ <TR> <TD><A class="parameter">tc=[off | on]</A></TD>
+ <TD align="center">off</TD> <TD>Stores NTFS timestamps for files: Modification time, Creation time, Last access time.</TD> </TR>
+ <TR> <TD><A class="parameter">cl=[off | on]</A></TD>
+ <TD align="center">off</TD> <TD>7-Zip always uses local code page for file names.</TD> </TR>
+ <TR> <TD><A class="parameter">cu=[off | on]</A></TD>
+ <TD align="center">off</TD> <TD>7-Zip uses UTF-8 for file names that contain non-ASCII symbols.</TD> </TR>
+</TABLE>
+
+<P>By default (if <B>cl</B> and <B>cu</B> switches are not specified), 7-Zip uses UTF-8 encoding
+only for file names that contain symbols unsupported by local code page.</P>
+
+<DL>
+ <DT><A name="ZipX"></A>x=[0 | 1 | 3 | 5 | 7 | 9 ]</DT>
+ <DD>
+ <P>Sets level of compression. x=0 means Copy mode (no compression).</P>
+ <P>Deflate / Deflate64 settings:</P>
+ <TABLE>
+ <TR> <TH>Level</TH> <TH>NumFastBytes</TH> <TH>NumPasses</TH> <TH>Description</TH> </TR>
+ <TR> <TD class="cc">1</TD> <TD class="cc" rowspan=3>32</TD> <TD class="cc" rowspan=3>1</TD> <TD>Fastest</TD> </TR>
+ <TR> <TD class="cc">3</TD> <TD>Fast</TR>
+ <TR> <TD class="cc">5</TD> <TD>Normal</TR>
+ <TR> <TD class="cc">7</TD> <TD class="cc">64</TD> <TD class="cc">3</TD> <TD>Maximum</TD> </TR>
+ <TR> <TD class="cc">9</TD> <TD class="cc">128</TD> <TD class="cc">10</TD> <TD>Ultra</TD> </TR>
+ </TABLE>
+
+ <P>x=1 and x=3 with Deflate method set fast mode for compression.</P>
+
+ <P>BZip2 settings:</P>
+ <TABLE>
+ <TR> <TH>Level</TH> <TH>Dictionary</TH> <TH>NumPasses</TH> <TH>Description</TH> </TR>
+ <TR> <TD class="cc">1</TD> <TD class="cc">100000</TD> <TD class="cc" rowspan=3>1</TD> <TD>Fastest</TD> </TR>
+ <TR> <TD class="cc">3</TD> <TD class="cc">500000</TD> <TD>Fast</TD> </TR>
+ <TR> <TD class="cc">5</TD> <TD class="cc" rowspan=3>900000</TD> <TD>Normal</TD> </TR>
+ <TR> <TD class="cc">7</TD> <TD align="center">2</TD> <TD>Maximum</TD> </TR>
+ <TR> <TD class="cc">9</TD> <TD align="center">7</TD> <TD>Ultra</TD> </TR>
+ </TABLE>
+ </DD>
+
+ <DT><A name="Deflate_FastBytes"></A>fb={NumFastBytes}</DT>
+ <DD>
+ <P>Sets the number of fast bytes for the Deflate/Deflate64 encoder.
+ It can be in the range from 3 to 258 (257 for Deflate64).
+ Usually, a big number gives a little bit better
+ compression ratio and a slower compression process.
+ A large fast bytes parameter can significantly increase the compression ratio
+ for files which contain long identical sequences of bytes.</P>
+ </DD>
+ <DT><A name="Zip_Pass"></A>pass={NumPasses}</DT>
+ <DD>
+ <P>Sets number of passes for Deflate encoder. It can be in the range from 1 to 15 for Deflate and
+ from 1 to 10 for BZip2. Usually, a big number gives a little bit better
+ compression ratio and a slower compression process.
+ </P>
+ </DD>
+ <DT><A name="ZipDictionarySize"></A>d={Size}[b|k|m]</DT>
+ <DD>
+ <P> Sets the Dictionary size for BZip2. You must specify the size in bytes, kilobytes, or megabytes.
+ The maximum value for the Dictionary size is 900000b. If you do not specify any symbol
+ from set [b|k|m], dictionary size will be calculated as DictionarySize = 2^Size bytes.</P>
+ </DD>
+ <DT><A name="ZipMultiThread"></A>mt=[off | on | {N}]</DT>
+ <DD>
+ <P>Sets multithread mode. If you have a multiprocessor or multicore system,
+ you can get a speed increase with
+ this switch. This option affects only compression (with any method) and
+ decompression of BZip2 streams.
+ Each thread in the multithread mode uses 32 MB of RAM for buffering.
+ If you specify {N}, 7-Zip tries to use N threads.</P>
+ </DD>
+</DL>
+
+<H2><A name="GZ"></A>GZip</H2>
+GZip uses the same parameters as Zip, but GZip compresses only with Deflate method.
+
+<H2><A name="BZ2"></A>BZip2</H2>
+<TABLE>
+ <TR>
+ <TH width="160">Parameter</TH>
+ <TH align="center">Default</TH>
+ <TH>Description</TH> </TR>
+ <TR>
+ <TD><A class="parameter" href="#BZip2X">x=[1 | 3 | 5 | 7 | 9 ]</A></TD>
+ <TD align="center">5</TD>
+ <TD>Sets level of compression.</TD> </TR>
+ <TR>
+ <TD><A class="parameter" href="#BZip2Pass">pass={NumPasses}</A></TD>
+ <TD align="center">1</TD>
+ <TD>Sets number of Passes for Bzip2 encoder.</TD></TR>
+ <TR>
+ <TD><A class="parameter" href="#BZip2MultiThread">mt=[off | on | {N}]</A></TD>
+ <TD align="center">on</TD>
+ <TD>Sets multithreading mode.</TD></TR>
+</TABLE>
+
+<DL>
+ <DT><A name="BZip2"></A>x=[1 | 3 | 5 | 7 | 9 ]</DT>
+ <DD>
+ <P>Sets level of compression</P>
+ <TABLE>
+ <TR> <TH>Level</TH> <TH>NumPasses</TH> <TH>Description</TH> </TR>
+ <TR> <TD>5</TD> <TD align="center">1</TD> <TD>Default compression method.</TD> </TR>
+ <TR> <TD>7</TD> <TD align="center">2</TD> <TD>Maximum compression method.</TD> </TR>
+ <TR> <TD>9</TD> <TD align="center">7</TD> <TD>Ultra compression method.</TD> </TR>
+ </TABLE>
+ </DD>
+
+ <DT><A name="#BZip2Pass"></A>pass={NumPasses}</DT>
+ <DD>
+ <P>Sets the number of passes. It can be in the range from 1 to 10.
+ The default value is 1 for normal mode, 2 for maximum mode and 7 for ultra mode.
+ A bigger number can give a little bit better compression ratio and a slower compression process.
+ </P>
+ </DD>
+ <DT><A name="BZip2MultiThread"></A>mt=[off | on | {N}]</DT>
+ <DD>
+ <P>Sets multithread mode. If you have a multiprocessor or multicore system,
+ you can get a speed increase with
+ this switch. If you specify {N}, for example mt=4, 7-Zip tries to use 4 threads.</P>
+ </DD>
+</DL>
+
+<H2><A name="7Z"></A>7z</H2>
+<TABLE>
+ <TR> <TH width="80">Parameter</TH> <TH align="center">Default</TH> <TH>Description</TH> </TR>
+ <TR> <TD><A class="parameter" href="#SevenZipX">x=[0 | 1 | 3 | 5 | 7 | 9 ]</A></TD>
+ <TD align="center">5</TD><TD>Sets level of compression.</TD> </TR>
+ <TR> <TD><A class="parameter" href="#Solid">s=[off | on | [e] [{N}f] [{N}b | {N}k | {N}m | {N}g]</A></TD>
+ <TD align="center">on</TD> <TD>Sets solid mode.</TD> </TR>
+ <TR> <TD><A class="parameter" href="#Filter">f=[off | on]</A></TD>
+ <TD align="center">on</TD> <TD>Enables or disables compression filters for executable files.</TD> </TR>
+ <TR> <TD><A class="parameter" href="#HeaderCompress">hc=[off | on]</A></TD>
+ <TD align="center">on</TD> <TD>Enables or disables archive header compressing.</TD> </TR>
+ <TR> <TD><A class="parameter" href="#HeaderEncrypt">he=[off | on]</A></TD>
+ <TD align="center">off</TD> <TD>Enables or disables archive header encryption.</TD> </TR>
+ <TR> <TD><A class="parameter" href="#Bind">b{C1}[s{S1}]:{C2}[s{S2}]</A></TD>
+ <TD align="center"> </TD> <TD>Sets binding beetwen coders.</TD> </TR>
+ <TR> <TD><A class="parameter" href="#MethodID">{N}={MethodID}[:param1][:param2][..]</A></TD>
+ <TD align="center">LZMA</TD> <TD>Sets a method: LZMA, LZMA2, PPMd, BZip2, Deflate, Delta, BCJ, BCJ2, Copy.</TD> </TR>
+ <TR> <TD><A class="parameter" href="#MultiThread">mt=[off | on | {N}]</A></TD>
+ <TD align="center">on</TD> <TD>Sets multithreading mode.</TD> </TR>
+ <TR> <TD><A class="parameter">tc=[off | on]</A></TD>
+ <TD align="center">off</TD> <TD>Stores file creation timestamps.</TD> </TR>
+</TABLE>
+
+<DL>
+ <DT><A name="SevenZipX"></A>x=[0 | 1 | 3 | 5 | 7 | 9 ]</DT>
+ <DD>
+ <P>Sets level of compression</P>
+ <TABLE>
+ <TR> <TH>Level</TH> <TH>Method</TH> <TH>Dictionary</TH> <TH>FastBytes</TH> <TH>MatchFinder</TH> <TH>Filter</TH> <TH>Description</TH> </TR>
+ <TR> <TD align="center">0</TD> <TD align="center">Copy</TD> <TD align="center"></TD> <TD align="center"></TD> <TD align="center"></TD> <TD align="center"></TD> <TD>No compression.</TD> </TR>
+ <TR> <TD align="center">1</TD> <TD align="center">LZMA</TD> <TD align="center">64 KB</TD> <TD align="center">32</TD> <TD align="center">HC4</TD> <TD align="center">BCJ</TD> <TD>Fastest compressing</TD> </TR>
+ <TR> <TD align="center">3</TD> <TD align="center">LZMA</TD> <TD align="center">1 MB</TD> <TD align="center">32</TD> <TD align="center">HC4</TD> <TD align="center">BCJ</TD> <TD>Fast compressing</TD> </TR>
+ <TR> <TD align="center">5</TD> <TD align="center">LZMA</TD> <TD align="center">16 MB</TD> <TD align="center">32</TD> <TD align="center">BT4</TD> <TD align="center">BCJ</TD> <TD>Normal compressing</TD> </TR>
+ <TR> <TD align="center">7</TD> <TD align="center">LZMA</TD> <TD align="center">32 MB</TD> <TD align="center">64</TD> <TD align="center">BT4</TD> <TD align="center">BCJ</TD> <TD>Maximum compressing</TD> </TR>
+ <TR> <TD align="center">9</TD> <TD align="center">LZMA</TD> <TD align="center">64 MB</TD> <TD align="center">64</TD> <TD align="center">BT4</TD> <TD align="center">BCJ2</TD><TD>Ultra compressing</TD> </TR>
+ </TABLE>
+ </DD>
+
+ <DT><A name="Solid"></A>s=[off | on | [e] [{N}f] [{N}b | {N}k | {N}m | {N}g)]</DT>
+ <DD>
+ <P> Enables or disables solid mode. The default mode is s=on.
+ In solid mode, files are grouped together. Usually, compressing in
+ solid mode improves the compression ratio.</P>
+
+ <TABLE>
+ <TR> <TD>e</TD> <TD>Use a separate solid block for each new file extension</TD> </TR>
+ <TR> <TD>{N}f</TD> <TD>Set the limit for number of files in one solid block</TD> </TR>
+ <TR> <TD>{N}b | {N}k | {N}m | {N}g</TD> <TD>Set a limit for the total size of a solid block in bytes</TD> </TR>
+ </TABLE>
+
+ <P>These are the default limits for the solid block size:</P>
+
+ <TABLE>
+ <TR> <TH width="150">Compression Level</TH> <TH>Solid block size</TH> </TR>
+ <TR> <TD>Store</TD> <TD>0 B</TD> </TR>
+ <TR> <TD>Fastest</TD> <TD>16 MB</TD> </TR>
+ <TR> <TD>Fast</TD> <TD>128 MB</TD> </TR>
+ <TR> <TD>Normal</TD> <TD>2 GB</TD> </TR>
+ <TR> <TD>Maximum</TD> <TD>4 GB</TD> </TR>
+ <TR> <TD>Ultra</TD> <TD>4 GB</TD> </TR>
+ </TABLE>
+
+
+ <P>Limitation of the solid block size usually decreases compression ratio but gives the following advantages:</P>
+ <UL>
+ <LI>Decreases losses in case of future archive damage.
+ <LI>Decreases extraction time of a group of files (or just one
+ file), so long as the group doesn't contain the entire archive.</LI></LI>
+ </UL>
+ <P>The updating of solid .7z archives can be slow, since it
+ can require some recompression.</P>
+
+ <P>Example:</P>
+ <PRE class="example">
+ s=100f10m
+ </PRE>
+ <P>set solid mode with 100 files & 10 MB limits per one solid block.</P>
+
+ <DT><A name="Filter"></A>f=[off | on]</DT>
+ <DD>
+ <P>Enables or disables compression filters for executable files:
+ dll, exe, ocx, sfx, sys. It uses BCJ2 filter in Ultra mode and BCJ
+ filter in other modes. The default mode is f=on.
+ </P>
+ <DT><A name="HeaderCompress"></A>hc=[off | on]</DT>
+ <DD>
+ <P> Enables or disables archive header compressing. The default mode is hc=on.
+ If archive header compressing is enabled, some parts of archive header will
+ be compressed with LZMA method.
+ </P>
+ <DT><A name="HeaderEncrypt"></A>he=[off | on]</DT>
+ <DD>
+ <P> Enables or disables archive header encryption. The default mode is he=off.
+ </P>
+ <DT>{N}</DT>
+ <DD>
+ <P>Sets order of methods. It is used also to associate parameters with
+ methods. Numbers must begin from 0. Methods that have smaller numbers will be used
+ before others.</P>
+ </DD>
+
+ <DT><A name="Bind"></A>b{C1}[s{S1}]:{C2}[s{S2}]</DT>
+ <DD>
+ <P> Binds output stream S1 in coder C1 with input stream S2 in coder C2.
+ If stream number is not specified, stream with number 0 will be used.
+ </P>
+ <P> Usally coder has one input stream and
+ one output stream. In 7z some coders can have multiple input and output streams.</P>
+
+ <P>For example, <A class="parameter" href="#BCJ2">BCJ2</A> encoder has one
+ input stream and four output streams.</P>
+ </DD>
+
+ <DT><A name="MultiThread"></A>mt=[off | on | {N}]</DT>
+ <DD>
+ <P>Sets multithread mode. If you have a multiprocessor or multicore system,
+ you can get a increase with this switch.
+ 7-Zip supports multithread mode only for LZMA / LZMA2 compression and
+ BZip2 compression / decompression. If you specify {N}, for example mt=4,
+ 7-Zip tries to use 4 threads. LZMA compression uses only 2 threads.
+ </P>
+ </DD>
+
+ <DT><A name="MethodID"></A>{N}={MethodID}[:param1][:param2] ... [:paramN]</DT>
+ <DD>
+ <P>Sets compression method. You can use any number of methods.
+ The default method is LZMA. </P>
+ <P>Parameters must be in one of the following forms:</P>
+ <UL>
+ <LI>{ParamName}={ParamValue}.
+ <LI>{ParamName}{ParamValue}, if {ParamValue}
+ is number and {ParamName} doesn't contain numbers.
+ </UL>
+
+ <P>Supported methods:</P>
+ <TABLE>
+ <TR> <TH width="60">MethodID</TH> <TH>Description</TH> </TR>
+ <TR> <TD><A class="parameter" href="#LZMA">LZMA</A></TD> <TD>LZ-based algorithm</TD> </TR>
+ <TR> <TD><A class="parameter" href="#LZMA2">LZMA2</A></TD> <TD>LZMA-based algorithm</TD> </TR>
+ <TR> <TD><A class="parameter" href="#PPMd">PPMd</A></TD> <TD>Dmitry Shkarin's PPMdH with small changes</TD> </TR>
+ <TR> <TD>BZip2</TD> <TD>BWT algorithm</TD> </TR>
+ <TR> <TD>Deflate</TD> <TD>LZ+Huffman</TD> </TR>
+ <TR> <TD>Copy</TD> <TD>No compression</TD> </TR>
+ </TABLE>
+
+ <P>Supported filters:</P>
+ <TABLE>
+ <TR> <TH width="60">MethodID</TH> <TH>Description</TH> </TR>
+ <TR> <TD><A class="parameter" href="#Delta">Delta</A></TD> <TD>Delta filter</TD> </TR>
+ <TR> <TD>BCJ</TD> <TD>converter for x86 executables</TD> </TR>
+ <TR> <TD><A class="parameter" href="#BCJ2">BCJ2</A></TD> <TD>converter for x86 executables (version 2)</TD> </TR>
+ <TR> <TD>ARM</TD> <TD>converter for ARM (little endian) executables</TD> </TR>
+ <TR> <TD>ARMT</TD> <TD>converter for ARM Thumb (little endian) executables</TD> </TR>
+ <TR> <TD>IA64</TD> <TD>converter for IA-64 executables</TD> </TR>
+ <TR> <TD>PPC</TD> <TD>converter for PowerPC (big endian) executables</TD> </TR>
+ <TR> <TD>SPARC</TD> <TD>converter for SPARC executables</TD> </TR>
+ </TABLE>
+ <P>Filters increase the compression ratio for some types of files. Filters
+ must be used with one of the compression method (for example, BCJ + LZMA).</P>
+ </DD>
+
+ <H4><A name="LZMA"></A>LZMA</H4>
+ <P> LZMA is an algorithm based on Lempel-Ziv algorithm.
+ It provides very fast decompression (about 10-20 times faster than compression).
+ Memory requirements for compression and decompression also are different (see
+ <A class="parameter" href="#DictionarySize">d={Size}[b|k|m]</A> switch for details).</P>
+
+ <TABLE>
+ <TR> <TH width="80">Parameter</TH> <TH align="center">Default</TH> <TH>Description</TH> </TR>
+
+ <TR> <TD><A class="parameter" href="#LZMAMode">a=[0|1]</A></TD>
+ <TD align="center">1</TD> <TD>Sets compressing mode</TD> </TR>
+ <TR> <TD><A class="parameter" href="#DictionarySize">d={Size}[b|k|m]</A></TD>
+ <TD align="center">24</TD> <TD>Sets Dictionary size</TD> </TR>
+ <TR> <TD><A class="parameter" href="#MatchFinder">mf={MF_ID}</A></TD>
+ <TD align="center">bt4</TD> <TD>Sets Match Finder</TD> </TR>
+ <TR> <TD><A class="parameter" href="#FastBytes">fb={N}</A></TD>
+ <TD align="center">32</TD> <TD>Sets number of Fast Bytes</TD></TR>
+ <TR> <TD><A class="parameter" href="#MatchFinderCycles">mc={N}</A></TD>
+ <TD align="center">32</TD><TD>Sets Number of Cycles for Match Finder</TD> </TR>
+ <TR> <TD><A class="parameter" href="#LitContext">lc={N}</A></TD>
+ <TD align="center">3</TD> <TD>Sets number of Literal Context bits - [0, 8]</TD></TR>
+ <TR> <TD><A class="parameter" href="#LitPos">lp={N}</A></TD>
+ <TD align="center">0</TD> <TD>Sets number of Literal Pos bits - [0, 4]</TD></TR>
+ <TR> <TD><A class="parameter" href="#PosBits">pb={N}</A></TD>
+ <TD align="center">2</TD> <TD>Set number of Pos Bits - [0, 4]</TD></TR>
+ </TABLE>
+
+
+ <DL>
+ <DT><A name="#LZMAMode"></A>a=[0|1]</DT>
+ <DD>
+ <P> Sets compression mode: 0 = fast, 1 = normal.
+ Default value is 1.</P>
+ </DD>
+ <DT><A name="DictionarySize"></A>d={Size}[b|k|m]</DT>
+ <DD>
+ <P> Sets Dictionary size for LZMA. You must specify the size in bytes, kilobytes, or megabytes.
+ The maximum value for dictionary size is 1 GB = 2^30 bytes. Default values for LZMA
+ are 24 (16 MB) in normal mode, 25 (32 MB) in maximum mode (-mx=7)
+ and 26 (64 MB) in ultra mode (-mx=9).
+ If you do not specify any symbol from the set [b|k|m], the
+ dictionary size will be calculated as DictionarySize = 2^Size bytes.
+ For decompressing a file compressed by LZMA method with dictionary size N, you need
+ about N bytes of memory (RAM) available.
+ </P>
+ </DD>
+ <DT><A name="MatchFinder"></A>mf={MF_ID}</DT>
+ <DD>
+ <P> Sets Match Finder for LZMA. Default method is bt4.
+ Algorithms from hc* group don't provide a good compression ratio,
+ but they often work pretty fast in combination with fast mode (a=0).
+ Memory requirements depend on dictionary size (parameter "d" in table below).
+ </P>
+ <TABLE>
+ <TR> <TH width="60">MF_ID</TH> <TH width="120">Memory</TH> <TH>Description</TH> </TR>
+ <TR> <TD>bt2</TD> <TD>d*9.5 + 4 MB</TD> <TD>Binary Tree with 2 bytes hashing.</TD> </TR>
+ <TR> <TD>bt3</TD> <TD>d*11.5 + 4 MB</TD> <TD>Binary Tree with 3 bytes hashing.</TD> </TR>
+ <TR> <TD>bt4</TD> <TD>d*11.5 + 4 MB</TD> <TD>Binary Tree with 4 bytes hashing.</TD> </TR>
+ <TR> <TD>hc4</TD> <TD>d*7.5 + 4 MB</TD> <TD>Hash Chain with 4 bytes hashing.</TD> </TR>
+ </TABLE>
+ <P>Note: Your operation system also needs some amount of physical memory for internal purposes.
+ So keep at least 32MB of physical memory unused.</P>
+ </DD>
+
+ <DT><A name="FastBytes"></A>fb={N}</DT>
+ <DD>
+ <P>Sets number of fast bytes for LZMA. It can be in the range from 5 to 273.
+ The default value is 32 for normal mode and 64 for maximum and ultra modes.
+ Usually, a big number gives a little bit better
+ compression ratio and slower compression process.
+ </P>
+ </DD>
+ <DT><A name="MatchFinderCycles"></A>mc={N}</DT>
+ <DD>
+ <P>Sets number of cycles (passes) for match finder. It can be in range from 0 to 1000000000.
+ Default value is (16 + number_of_fast_bytes / 2) for BT* match finders and
+ (8 + number_of_fast_bytes / 4) for HC4 match finder.
+ If you specify mc=0, LZMA will use default value.
+ Usually, a big number gives a little bit better compression ratio and slower
+ compression process. For example, mf=HC4 and mc=10000 can provide almost the same
+ compression ratio as mf=BT4.</P>
+ </DD>
+ <DT><A name="LitContext"></A>lc={N}</DT>
+ <DD>
+ <P>Sets the number of literal context bits (high bits of previous literal).
+ It can be in range from 0 to 8.
+ Default value is 3. Sometimes lc=4 gives gain for big files.</P>
+ </DD>
+ <DT><A name="LitPos"></A>lp={N}</DT>
+ <DD>
+ <P>Sets the number of literal pos bits (low bits of current position for literals).
+ It can be in the range from 0 to 4.
+ The default value is 0. The lp switch is intended for periodical data when the
+ period is equal to 2^value (where lp=value). For example, for 32-bit (4 bytes)
+ periodical data you can use lp=2. Often it's better to set lc=0,
+ if you change lp switch.</P>
+ </DD>
+ <DT><A name="PosBits"></A>pb={N}</DT>
+ <DD>
+ <P>Sets the number of pos bits (low bits of current position).
+ It can be in the range from 0 to 4.
+ The default value is 2. The pb switch is intended for periodical data when the
+ period is equal 2^value (where lp=value). </P>
+ </DD>
+
+ </DL>
+
+ <H4><A name="LZMA2"></A>LZMA2</H4>
+ <P>LZMA2 is modified version of LZMA. it provides the following advantages over LZMA:</P>
+ <UL>
+ <LI>Better compression ratio for data than can't be compressed. LZMA2 can store such
+ blocks of data in uncompressed form. Also it decompresses such data faster.
+ <LI>Better multithreading support. If you compress big file, LZMA2 can split
+ that file to chunks and compress these chunks in multiple threads.
+ </UL>
+
+ <TABLE>
+ <TR> <TH width="80">Parameter</TH> <TH align="center">Default</TH> <TH>Description</TH> </TR>
+
+ <TR> <TD><A class="parameter" href="#ChunkSize">c={Size}[b|k|m]</A></TD>
+ <TD align="center">dictSize * 4</TD> <TD>Sets Chunk size</TD> </TR>
+ </TABLE>
+
+ <P>If you don't specify ChunkSize, LZMA2 sets it to DictionarySize * 4.</P>
+
+ <P>LZMA2 also supports all LZMA parameters, but lp+lc cannot be larger than 4.</P>
+
+ <P>LZMA2 uses: 1 thread for each chunk in x1 and x3 modes; and
+ 2 threads for each chunk in x5, x7 and x9 modes.
+ If LZMA2 is set to use only such number of threads required for one chunk,
+ it doesn't split stream to chunks. So you can get different compression
+ ratio for different number of threads. You can get the best compression
+ ratio, when you use 1 or 2 threads.</P>
+
+ <H4><A name="PPMd"></A>PPMd</H4>
+ <P> PPMd is a PPM-based algorithm. This algorithm is mostly based
+ on Dmitry Shkarin's PPMdH source code. PPMd provides very good compression ratio for
+ plain text files. There is no difference between compression speed and
+ decompression speed. Memory requirements for compression and decompression
+ also are the same.</P>
+ <TABLE>
+ <TR> <TH width="80">Parameter</TH> <TH align="center">Default</TH> <TH>Description</TH> </TR>
+ <TR> <TD><A class="parameter" href="#MemorySize">mem={Size}[b|k|m]</A></TD>
+ <TD align="center">24</TD> <TD>Sets size of used memory for PPMd.</TD> </TR>
+ <TR> <TD><A class="parameter" href="#Order">o={Size}</A></TD>
+ <TD align="center">6</TD> <TD>Sets model order for PPMd.</TD> </TR>
+ </TABLE>
+ <DL>
+ <DT><A name="MemorySize"></A>mem={Size}[b|k|m]</DT>
+ <DD>
+ <P> Sets the size of memory used for PPMd. You must specify the size in bytes, kilobytes, or megabytes.
+ The maximum value is 2GB = 2^31 bytes. The default value
+ is 24 (16MB). If you do not specify any symbol from the set [b|k|m], the
+ memory size will be calculated as (2^Size) bytes. PPMd uses the same
+ amount of memory for compression and decompression.</P>
+ </DD>
+
+ <DT><A name="Order"></A>o={Size}</DT>
+ <DD>
+ <P>Sets the model order for PPMd. The size must be in the range [2,32]. The default value is 6.</P>
+ </DD>
+ </DL>
+
+ <H4><A name="BCJ2"></A>BCJ2</H4>
+ <P>BCJ2 is a Branch converter for 32-bit x86 executables (version 2).
+ It converts some branch instructions for increasing further compression.</P>
+ <P>A BCJ2 encoder has one input stream and four output streams:</P>
+ <UL>
+ <LI>s0: main stream. It requires further compression.</LI>
+ <LI>s1: stream for converted CALL values. It requires further compression.</LI>
+ <LI>s2: stream for converted JUMP values. It requires further compression.</LI>
+ <LI>s3: service stream. It is already compressed.</LI>
+ </UL>
+ <P>If LZMA is used, the size of the dictionary for streams
+ s1 and s2 can be much smaller (512 KB is enough for most cases)
+ than the dictionary size for stream s0.</P>
+
+ <H4><A name="Delta"></A>Delta</H4>
+ <P>It's possible to set delta offset in bytes. For example, to compress 16-bit stereo
+ WAV files, you can set "0=Delta:4". Default delta offset is 1.</P>
+</DL>
+
+<H2><A name="XZ"></A>XZ</H2>
+XZ supports only LZMA2 codec now. The switches are similar to switches for 7z format.
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z a -tzip archive.zip *.jpg -mx0
+</PRE>
+
+<P>adds <SPAN class="filename">*.jpg</SPAN> files to
+ <SPAN class="filename">archive.zip</SPAN> archive without compression.</P>
+
+<PRE class="example">
+7z a -t7z archive.7z *.exe *.dll -m0=BCJ -m1=LZMA:d=21 -ms -mmt
+</PRE>
+
+<P>adds <SPAN class="filename">*.exe</SPAN> and <SPAN class="filename">*.dll</SPAN>
+files to solid archive <SPAN class="filename">archive.7z</SPAN> using LZMA method with
+2 MB dictionary and BCJ converter. Compression will use multithreading optimization.</P>
+
+<PRE class="example">
+7z a -t7z archive.7z *.exe *.dll -m0=BCJ2 -m1=LZMA:d23 -m2=LZMA:d19 -m3=LZMA:d19
+ -mb0:1 -mb0s1:2 -mb0s2:3
+</PRE>
+
+<P>adds <SPAN class="filename">*.exe</SPAN> and <SPAN class="filename">*.dll</SPAN>
+ files to archive <SPAN class="filename">archive.7z</SPAN> using BCJ2 converter,
+ LZMA with 8 MB dictionary for main output stream (s0),
+ and LZMA with 512 KB dictionary for s1 and s2 output streams of BCJ2.</P>
+
+
+<PRE class="example">
+7z a -t7z archive.7z *.txt -m0=PPMd
+</PRE>
+
+<P>adds <SPAN class="filename">*.txt</SPAN> files to archive
+<SPAN class="filename">archive.7z</SPAN> using PPMd method.</P>
+
+
+
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Switches:</B>
+ <A href="type.htm">-t (set Type of archive)</A>,
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/output_dir.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/output_dir.htm
new file mode 100644
index 000000000..f9e35ea22
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/output_dir.htm
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-o (set Output directory) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-o (set Output directory) switch</H1>
+
+<P>Specifies a destination directory where files are to be extracted.</P>
+<P>This switch can be used only with extraction commands.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-o{dir_path}
+</PRE>
+
+<DL>
+ <DT>{dir_path}</DT>
+ <DD>This is the destination directory path. It's not required to end with a backslash.</DD>
+</DL>
+
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z x archive.zip -oc:\Doc
+</PRE>
+
+<P>extracts all files from the <SPAN class="filename">archive.zip</SPAN> archive
+to the <SPAN class="filename">c:\Doc</SPAN> directory.</P>
+
+<PRE class="example">
+7z x *.zip -o*
+</PRE>
+
+<P>extracts all <SPAN class="filename">*.zip</SPAN> archives to subfolders
+with names of these archives.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/overwrite.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/overwrite.htm
new file mode 100644
index 000000000..c71ae40d8
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/overwrite.htm
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-ao (Overwrite mode) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-ao (Overwrite mode) switch</H1>
+
+<P>Specifies the overwrite mode during extraction, to overwrite files already present on disk.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-ao[a | s | t | u ]
+</PRE>
+
+
+<TABLE>
+ <TR> <TH width="80">Switch</TH> <TH>Description</TH> </TR>
+ <TR> <TD>-aoa</TD> <TD>Overwrite All existing files without prompt.</TD> </TR>
+ <TR> <TD>-aos</TD> <TD>Skip extracting of existing files.</TD> </TR>
+ <TR> <TD>-aou</TD> <TD>aUto rename extracting file (for example, name.txt will
+ be renamed to name_1.txt).</TD> </TR>
+ <TR> <TD>-aot</TD> <TD>auto rename existing file (for example, name.txt will
+ be renamed to name_1.txt).</TD> </TR>
+</TABLE>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z x test.zip -aoa
+</PRE>
+
+<P>extracts all files from <SPAN class="filename">test.zip</SPAN> archive and overwrites
+existing files without any prompt.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Switches:</B>
+ <A href="yes.htm">-y (assume Yes on all queries)</A>,
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/password.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/password.htm
new file mode 100644
index 000000000..733dfc4a7
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/password.htm
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-p (set Password) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-p (set Password) switch</H1>
+
+<P>Specifies password.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-p{password}
+</PRE>
+
+<DL>
+ <DT>{password}</DT>
+ <DD>Specifies password.</DD>
+</DL>
+
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z a archive.7z -psecret -mhe *.txt
+</PRE>
+<P>compresses *.txt files to <SPAN class="filename">archive.7z</SPAN> using password
+"secret". Also it encrypts archive headers (-mhe switch), so filenames will be encrypted.
+</P>
+
+<PRE class="example">
+7z x archive.zip -psecret
+</PRE>
+<P>extracts all files from <SPAN class="filename">archive.zip</SPAN> using password
+"secret".</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/test.htm">t (Test)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/recurse.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/recurse.htm
new file mode 100644
index 000000000..08dba2a4a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/recurse.htm
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-r (Recurse subdirectories) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-r (Recurse subdirectories) switch</H1>
+
+<P>Specifies the method of treating wildcards and filenames on the command line.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-r[- | 0]
+</PRE>
+
+
+<TABLE>
+ <TR><TH width="80">Switch</TH> <TH>Description</TH></TR>
+ <TR><TD>-r</TD> <TD>Enable recurse subdirectories.</TD></TR>
+ <TR><TD>-r-</TD> <TD>Disable recurse subdirectories. This option is default for all commands.</TD></TR>
+ <TR><TD>-r0</TD> <TD>Enable recurse subdirectories only for wildcard names.</TD></TR>
+</TABLE>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z l archive.zip *.doc -r-
+</PRE>
+
+<P>lists all <SPAN class="filename">*.doc</SPAN> files
+ that belong to the archived root directory
+ in the <SPAN class="filename">archive.zip</SPAN> archive.
+ </P>
+
+<PRE class="example">
+7z a -tzip archive.zip -r src\*.cpp src\*.h
+</PRE>
+
+<P>adds all <SPAN class="filename">*.cpp</SPAN> and <SPAN class="filename">*.h</SPAN>
+ files from directory <SPAN class="filename">src</SPAN> and all it's subdirectories
+ to the <SPAN class="filename">archive.zip</SPAN> archive.</P>
+
+<PRE class="example">
+7z a archive.7z folder1\
+</PRE>
+
+<P>adds all files from directory <SPAN class="filename">folder1</SPAN> and all it's subdirectories
+ to the <SPAN class="filename">archive.7z</SPAN> archive.</P>
+
+<PRE class="example">
+7z a archive.7z -r folder2\
+</PRE>
+
+<P>searches all <SPAN class="filename">folder2</SPAN> directories in all subdirectories,
+ and adds them (including all subdirectories) to the <SPAN class="filename">archive.7z</SPAN> archive.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/list.htm">l (List)</A>,
+ <A href="../commands/test.htm">t (Test)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Switches:</B>
+ <A href="include.htm">-i (Include)</A>,
+ <A href="exclude.htm">-x (Exclude)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/sfx.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/sfx.htm
new file mode 100644
index 000000000..126028963
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/sfx.htm
@@ -0,0 +1,156 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-sfx (Create SFX archive) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-sfx (Create SFX archive) switch</H1>
+
+<P>Creates self extracting archive.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-sfx[<A class="parameter" href="#SFX_Module">{SFX_Module}</A>]
+</PRE>
+
+<DL>
+ <DT><A name="SFX_Module"></A>{SFX_Module}</DT>
+ <DD>
+ <P>Specifies the SFX module that will be combined with the archive.
+ This module must be placed in the same directory as the 7z.exe.
+ If {SFX_Module} is not assigned, 7-Zip will use standard console
+ SFX module 7zCon.sfx.</P>
+ <TABLE>
+ <TR> <TH width="60">SFX_Module</TH> <TH>Description</TH> </TR>
+ <TR> <TD>7z.sfx</TD> <TD>Windows version.</TD> </TR>
+ <TR> <TD>7zCon.sfx</TD> <TD>Console version.</TD> </TR>
+ <TR> <TD>7zS.sfx</TD> <TD>Windows version for installers.</TD> </TR>
+ <TR> <TD>7zSD.sfx</TD> <TD>Windows version for installers (uses MSVCRT.dll).</TD> </TR>
+ </TABLE>
+ </DD>
+</DL>
+
+<P>
+All SFX modules are uncompressed. You can use UPX program
+(http://upx.sourceforge.net)
+to compresss such modules. After compressing by the UPX program, the size of the
+sfx module will be reduced to 40-50% of its original size.
+</P>
+
+<H4>SFX modules for installers</H4>
+<P>SFX modules for installers are included in an external package (7z_extra). You can download
+these modules from www.7-zip.org. SFX modules for installers (7zS.sfx and 7zSD.sfx)
+allow you to create your own installation program.
+Such a module extracts the archive to the user's temp folder, and runs a specified program,
+and removes the temp files after the program finishes.
+A self-extracting archive for installers must be created as joining 3 files:
+SFX_Module, Installer_Config, 7z_Archive.
+In addition, an optional file, Installer_Config, is allowed. You can use the following command to
+create an installer self-extracting archive:</P>
+<PRE class="example">
+copy /b 7zS.sfx + config.txt + archive.7z archive.exe
+</PRE>
+
+<P>An optimally small installation package size can be achieved,
+if the installation files are uncompressed before including them in the 7z archive.</P>
+
+<P><SPAN class="filename">-y</SPAN> switch for installer module specifies quiet mode extraction.</P>
+
+<H4>Installer Config file format</H4>
+<P>
+This config file contains commands for the Installer. The file begins with the string
+<B>;!@Install@!UTF-8!</B> and ends with <B>;!@InstallEnd@!</B>.
+The file must be written in UTF-8 encoding.
+The file contains any or all these string pairs:
+<P>ID_String="Value"</P>
+<P>
+ <TABLE>
+ <TR> <TH width="60">ID_String</TH> <TH>Description</TH> </TR>
+ <TR> <TD>Title</TD> <TD>Title for messages</TD> </TR>
+ <TR> <TD>BeginPrompt</TD> <TD>Begin Prompt message</TD> </TR>
+ <TR> <TD>Progress</TD> <TD>Value can be "yes" or "no". Default value is "yes".</TD> </TR>
+ <TR> <TD>RunProgram</TD> <TD>Command for executing. Default value is "setup.exe". Substring <B>%%T</B>
+ will be replaced with path to temporary folder, where files were extracted</TD> </TR>
+ <TR> <TD>Directory</TD> <TD>Directory prefix for "RunProgram". Default value is ".\\"</TD> </TR>
+ <TR> <TD>ExecuteFile</TD> <TD>Name of file for executing</TD> </TR>
+ <TR> <TD>ExecuteParameters</TD> <TD>Parameters for "ExecuteFile"</TD> </TR>
+ </TABLE>
+</P>
+<P>You may omit any pair.</P>
+
+<P>There are two ways to run a installation program: <B>RunProgram</B> and <B>ExecuteFile</B>.
+Use <B>RunProgram</B>, if you want to run a program from the .7z archive.
+Use <B>ExecuteFile</B>, if you want to open a document from the .7z archive, or
+if you want to execute a command from Windows.</P>
+
+<P>If you use <B>RunProgram</B>, and if you specify empty directory prefix: <B>Directory</B>="",
+the system searches for the executable file in the following sequence:</P>
+<OL>
+<LI>The directory from which the application (installer) loaded.
+<LI>The temporary folder, where files were extracted.
+<LI>The Windows system directory.
+</OL>
+
+<H4>Config file Examples</H4>
+
+<PRE class="example">
+;!@Install@!UTF-8!
+Title="7-Zip 4.00"
+BeginPrompt="Do you want to install the 7-Zip 4.00?"
+RunProgram="setup.exe"
+;!@InstallEnd@!
+</PRE>
+
+<BR>
+
+
+<PRE class="example">
+;!@Install@!UTF-8!
+Title="7-Zip 4.00"
+BeginPrompt="Do you want to install the 7-Zip 4.00?"
+ExecuteFile="7zip.msi"
+;!@InstallEnd@!
+</PRE>
+
+<BR>
+
+<PRE class="example">
+;!@Install@!UTF-8!
+Title="7-Zip 4.01 Update"
+BeginPrompt="Do you want to install the 7-Zip 4.01 Update?"
+ExecuteFile="msiexec.exe"
+ExecuteParameters="/i 7zip.msi REINSTALL=ALL REINSTALLMODE=vomus"
+;!@InstallEnd@!
+</PRE>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z a -sfx a.exe *.txt
+</PRE>
+
+<P>adds <SPAN class="filename">*.txt</SPAN> files to self extracting
+ archive <SPAN class="filename">a.exe</SPAN> using the default console SFX module.</P>
+
+<PRE class="example">
+7z a -sfx7z.sfx a.exe *
+</PRE>
+
+<P>adds all files to self extracting archive <SPAN class="filename">a.exe</SPAN>
+with module <SPAN class="filename">7z.sfx</SPAN> using windows version of SFX mudule.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ssc.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ssc.htm
new file mode 100644
index 000000000..023dbf88b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/ssc.htm
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-ssc (Set Sensitive Case mode) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-ssc (Set Sensitive Case mode) switch</H1>
+
+<P>Sets sensitive case mode for file names.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-scs[-]
+</PRE>
+
+<TABLE>
+ <TR><TH width="80">Switch</TH> <TH>Description</TH></TR>
+ <TR><TD>-ssc</TD> <TD>Set case-sensitive mode. It's default for Posix/Linux systems.</TD></TR>
+ <TR><TD>-ssc-</TD> <TD>Set case-insensitive mode. It's default for Windows systems.</TD></TR>
+</TABLE>
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z a archive.7z A*.txt -ssc -r
+</PRE>
+
+<P>compresses all <SPAN class="filename">A*.txt</SPAN> files
+ from current directory and all it's subdirectories. That command doesn't compress
+ <SPAN class="filename">a*.txt</SPAN> files.
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/list.htm">l (List)</A>,
+ <A href="../commands/test.htm">t (Test)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stdin.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stdin.htm
new file mode 100644
index 000000000..d1be8563c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stdin.htm
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-si (read data from stdin) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-si (read data from stdin) switch</H1>
+
+<P>Causes 7-Zip to read data from stdin (standard input) instead of from disc files.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-si{file_name}
+</PRE>
+
+<DL>
+ <DT>{file_name}</DT>
+ <DD>Specifies a name that will be stored in the archive for the compressed data.
+ If file_name is not specified, data will be stored without a name.</DD>
+</DL>
+
+<P>Note: The current version of 7-Zip does not support reading of archives from stdin.</P>
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z a archive.gz -tgzip -siDoc2.txt < Doc.txt
+</PRE>
+
+<P>compresses input stream from file Doc.txt to
+<SPAN class="filename">archive.gz</SPAN> archive
+using <SPAN class="filename">Doc2.txt</SPAN> file name.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/update.htm">u (Update)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stdout.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stdout.htm
new file mode 100644
index 000000000..62e5a662a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stdout.htm
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-so (write data to stdout) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-so (write data to stdout) switch</H1>
+
+<P>Causes 7-Zip to write output data to stdout (standard output stream).</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-so
+</PRE>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z x archive.gz -so > Doc.txt
+</PRE>
+
+<P>decompresses <SPAN class="filename">archive.gz</SPAN>
+archive to output stream and then redirects that stream to
+<SPAN class="filename">Doc.txt</SPAN> file.</P>
+
+
+<PRE class="example">
+7z a dummy -tgzip -so Doc.txt > archive.gz
+</PRE>
+
+<P>compresses the <SPAN class="filename">Doc.txt</SPAN> file to the 7-Zip standard
+output stream and writes that stream to
+<SPAN class="filename">archive.gz</SPAN> file.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stop_switch.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stop_switch.htm
new file mode 100644
index 000000000..12383e507
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/stop_switch.htm
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-- (Stop switches parsing) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-- (Stop switches parsing) switch</H1>
+
+<P>Disables switch parsing after "--" on the command line.
+This is to allow 7-Zip to use file names that start with "-".
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+--
+</PRE>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z t -- -ArchiveName.7z
+</PRE>
+
+<P>tests <SPAN class="filename">-ArchiveName.7z</SPAN> archive.</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/style.css b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/style.css
new file mode 100644
index 000000000..13ebb79ce
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/style.css
@@ -0,0 +1,232 @@
+body
+ {
+ padding: 0px 0px 0px 26px;
+ background: #ffffff;
+ color: #000000;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 80%;
+ }
+
+div
+ {
+ width: 90%;
+ border: 2px solid #999999;
+ padding: 4px 8px;
+ background: #cccccc;
+ }
+
+h1, h2, h3, h4
+ {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ margin-left: -26px;
+ }
+
+h1
+ {
+ font-size: 145%;
+ margin-top: .5em;
+ margin-bottom: 1em;
+ }
+
+h2
+ {
+ font-size: 130%;
+ margin-top: 1.5em;
+ margin-bottom: .6em;
+ }
+
+h3
+ {
+ font-size: 115%;
+ margin-top: 1.5em;
+ margin-bottom: .6em;
+ }
+
+h4
+ {
+ font-size: 100%;
+ margin-top: 1.5em;
+ margin-bottom: .6em;
+ }
+
+ul p, ol p, dl p
+ {
+ margin-left: 0em;
+ }
+
+p
+ {
+ margin-top: .6em;
+ margin-bottom: .6em;
+ }
+
+dl
+ {
+ /*margin-top: 0em; */
+ }
+
+dt
+ {
+ margin-top: .76em;
+ margin-bottom: .5em;
+ font-weight: bold;
+ }
+
+dd
+ {
+ margin-top: .5em;
+ margin-bottom: .5em;
+ margin-left: 1.9em;
+ }
+
+
+ul, ol
+ {
+ margin-top: .6em;
+ margin-bottom: 0em;
+ }
+
+ol
+ {
+ margin-left: 3.6em;
+ }
+
+ul
+ {
+ list-style-type: disc;
+ margin-left: 1.9em;
+ }
+
+li
+ {
+ margin-bottom: .6em;
+ }
+
+ul ol, ol ol
+ {
+ list-style-type: lower-alpha;
+ {
+
+ /*
+pre
+ {
+ margin-top: .6em;
+ margin-bottom: .6em;
+ }
+ */
+
+pre,code
+ {
+ font: 100% Courier New, Courier, mono;
+ color: #000000;
+ cursor: text;
+ }
+
+pre.syntax
+ {
+ background: #dddddd;
+ padding: 2pt,4pt
+ }
+
+pre.syntax
+ {
+ color: #000000;
+ }
+
+pre.example
+ {
+ margin-left: 2.0em;
+ /*margin-top: 12.0em;*/
+ /*margin-bottom: 1.0em;*/
+ color: #C00000;
+ /*padding: 10pt,20pt*/
+ }
+
+table
+ {
+ /* width: 90%; */
+ background: #999999;
+ margin-top: .6em;
+ margin-bottom: .3em;
+ }
+
+th
+ {
+ padding: 4px 8px;
+ background: #cccccc;
+ text-align: left;
+ font-size: 80%;
+ vertical-align: bottom;
+ }
+
+th.cc
+ {
+ text-align: center;
+ vertical-align: middle;
+ }
+
+td
+ {
+ padding: 4px 8px;
+ background: #ffffff;
+ vertical-align: top;
+ font-size: 80%;
+ }
+
+td.cc
+ {
+ text-align: center;
+ vertical-align: middle;
+ }
+
+
+blockquote
+ {
+ margin-left: 3.8em;
+ margin-right: 3.8em;
+ margin-top: .6em;
+ margin-bottom: .6em;
+ }
+
+a:link
+ {
+ color: #0066ff;
+ }
+
+a:visited
+ {
+ color: #996600;
+ }
+
+a:hover
+ {
+ color: #cc9900;
+ }
+
+a.parameter:link
+ {
+ color: #0066ff;
+ text-decoration:none;
+ }
+
+a.parameter:visited
+ {
+ text-decoration:none;
+ }
+
+div.footer
+ {
+ width: 100%;
+ border: none;
+ background: #ffffff;
+ margin-top: 18pt;
+ padding-bottom: 12pt;
+ color: #228B22;
+ text-align: center;
+ font-size: 70%;
+ }
+
+span.filename
+{
+ color: #F00000;
+}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/type.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/type.htm
new file mode 100644
index 000000000..ad92800b0
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/type.htm
@@ -0,0 +1,77 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-o (set Output directory) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-t (set Type of archive) switch</H1>
+
+<P>Specifies the type of archive.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-t{archive_type}
+</PRE>
+
+<DL>
+ <DT>{archive_type}</DT>
+ <DD>Specifies the type of archive. It can be: 7z, split, zip, gzip, bzip2, tar, ....
+ 7z format is the default.
+</DD>
+</DL>
+
+<P>If -t{archive_type} switch is not specified, 7-Zip uses extension of archive to
+ detect the type of archive.</P>
+
+<P>Note: gzip or bzip2 formats support only one file per archive.
+If you want to compress more than one file to these formats,
+create a tar archive first, and then compress it with your selected format.</P>
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z a -tzip archive.zip *.txt
+</PRE>
+
+<P>adds all <SPAN class="filename">*.txt</SPAN> files from current directory
+to zip archive <SPAN class="filename">archive.zip</SPAN>.</P>
+
+<PRE class="example">
+7z t -t7z.split archive.7z.001
+</PRE>
+
+<P>tests all files in <SPAN class="filename">archive.7z.001</SPAN>. It also checks
+that archive is multivolume .7z archive.</P>
+
+<PRE class="example">
+7z x -tiso archive.iso
+</PRE>
+
+<P>extracts files from <SPAN class="filename">archive.iso</SPAN> open as ISO archive.
+
+<PRE class="example">
+7z x -tudf archive.iso
+</PRE>
+
+<P>extracts files from <SPAN class="filename">archive.iso</SPAN> open as UDF archive.
+
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/list.htm">l (List)</A>,
+ <A href="../commands/test.htm">t (Test)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/update.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/update.htm
new file mode 100644
index 000000000..4bed753ee
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/update.htm
@@ -0,0 +1,176 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-u (Update options) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-u (Update options) switch</H1>
+
+<P>Specifies how to update files in an archive and (or) how to create new archives.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-u<A class="parameter" href="#disable_base_archive">[-]</A>&lt;action_set><A class="parameter" href="#new_archive_name">[!{new_archive_name}]</A>
+
+ &lt;action_set> ::= &lt;state_action>...
+
+ &lt;state_action> ::= <A class="parameter" href="#state">&lt;state></A><A class="parameter" href="#state">&lt;action></A>
+
+ <A class="parameter" href="#action">&lt;state></A> ::= p | q | r | x | y | z | w
+
+ <A class="parameter" href="#action">&lt;action></A> ::= 0 | 1 | 2 | 3
+</PRE>
+
+
+<H4>Parameters</H4>
+
+<DL>
+ <DT><A name="disable_base_archive"></A>dash (-)</DT>
+ <DD><P>Disables any updates in the base archive.</P>
+
+ <P>The term <B>base archive</B> means the archive assigned by "base_archive_name"
+ on the command line. See <A href="../syntax.htm">Command line syntax</A>
+ for more details.</P>
+ </DD>
+ <DT><A name="new_archive_name"></A>{new_archive_name}</DT>
+ <DD><P>Specifies the path name of the new archive to be created.
+ All options in this switch will refer to this new archive.</P>
+ <P>If not assigned, then all options in this switch will
+ refer to the base archive of the command.</P>
+ </DD>
+ <DT><A name="state"></A>&lt;state></DT>
+ <DD><P>Specifies the state of a particular file to be processed.</P>
+ <PRE class="syntax">&lt;state> ::= p | q | r | x | y | z | w</PRE>
+ <P>For each unique filename there are 6 variants of state:</P>
+ <TABLE>
+ <TR> <TH>&lt;state></TH> <TH>State condition</TH>
+ <TH width="20%">File on Disk</TH> <TH width="20%">File in Archive</TH> </TR>
+
+ <TR> <TD align="center">p</TD> <TD>File exists in archive, but is not matched with wildcard.</TD>
+ <TD>&nbsp;</TD> <TD>Exists, but is not matched</TD> </TR>
+
+ <TR> <TD align="center">q</TD> <TD>File exists in archive, but doesn't exist on disk.</TD>
+ <TD>Doesn't exist</TD> <TD>Exists</TD> </TR>
+
+ <TR> <TD align="center">r</TD> <TD>File doesn't exist in archive, but exists on disk.</TD>
+ <TD>Exists</TD> <TD>Doesn't exist</TD> </TR>
+
+ <TR> <TD align="center">x</TD> <TD>File in archive is newer than the file on disk.</TD>
+ <TD>Older</TD> <TD>Newer</TD> </TR>
+
+ <TR> <TD align="center">y</TD> <TD>File in archive is older than the file on disk.</TD>
+ <TD>Newer</TD> <TD>Older</TD> </TR>
+
+ <TR> <TD align="center">z</TD> <TD>File in archive is same as the file on disk</TD>
+ <TD>Same</TD> <TD>Same</TD> </TR>
+
+ <TR> <TD align="center">w</TD> <TD>Can not be detected what file is newer
+ (times are the same, sizes are different)</TD>
+ <TD>?</TD> <TD>?</TD> </TR>
+ </TABLE>
+ </DD>
+
+ <DT><A name="action"></A>&lt;action></DT>
+ <DD><P>Specifies the action for a given <A class="parameter" href="#state">&lt;state></A>.</P>
+ <PRE class="syntax">&lt;action> ::= 0 | 1 | 2 | 3</PRE>
+ <P>For each state you can specify one of the three variants of actions:</P>
+ <TABLE>
+ <TR> <TH>&lt;action></TH> <TH>Description</TH></TR>
+ <TR> <TD align="center">0</TD> <TD>Ignore file (don't create item in new archive for this file)</TD></TR>
+ <TR> <TD align="center">1</TD> <TD>Copy file (copy from old archive to new)</TD></TR>
+ <TR> <TD align="center">2</TD> <TD>Compress (compress file from disk to new archive)</TD></TR>
+ <TR> <TD align="center">3</TD> <TD>Create Anti-item (item that will delete file or directory during extracting). This feature is supported only in 7z format.</TD></TR>
+ </TABLE>
+ </DD>
+</DL>
+
+
+<H4>Remarks</H4>
+
+<P>Any update command (such as <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/update.htm">u (Update)</A>) can be assigned in these terms.</P>
+<P>The following table shows action sets for update commands.</P>
+
+<TABLE>
+ <TR> <TH>command \ <A class="parameter" href="#state">&lt;state></A></TH>
+ <TH>p</TH> <TH>q</TH> <TH>r</TH> <TH>x</TH> <TH>y</TH> <TH>z</TH> <TH>w</TH></TR>
+ <TR> <TH><A href="../commands/delete.htm">d (Delete)</A></TH> <TD>1</TD> <TD>0</TD> <TD>0</TD> <TD>0</TD> <TD>0</TD> <TD>0</TD> <TD>0</TD></TR>
+ <TR> <TH><A href="../commands/add.htm">a (Add)</A></TH> <TD>1</TD> <TD>1</TD> <TD>2</TD> <TD>2</TD> <TD>2</TD> <TD>2</TD> <TD>2</TD></TR>
+ <TR> <TH><A href="../commands/update.htm">u (Update)</A></TH> <TD>1</TD> <TD>1</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD></TR>
+ <TR> <TH><A href="../commands/update.htm">Freshen</A></TH> <TD>1</TD> <TD>1</TD> <TD>0</TD> <TD>1</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD></TR>
+ <TR> <TH><A href="../commands/update.htm">Synchronize</A></TH> <TD>1</TD> <TD>0</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD></TR>
+</TABLE>
+
+
+<P>If you don't specify a
+<A class="parameter" href="#new_archive_name"><I>!{new_archive_name}</I></A> option, then
+all options will refer to the main archive (the archive assigned on the command line after the 7z command).
+If you specify <A class="parameter" href="#new_archive_name"><I>!{new_archive_name}</I></A>
+option, then 7-Zip also will create a new archive with the specified name and all options
+will refer to that new archive.</P>
+
+<P>Multiple update switches are supported.
+7-Zip can create any number of new archives during one operation.</P>
+
+<P>By default, the action set for each new archive is assigned
+as the action set of the main command. There are 3 different
+action sets for commands: <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/update.htm">u (Update)</A>.
+You can overload any &lt;state_action> pair.</P>
+
+<H4>Time zone notes</H4>
+<P>If you change time zone (when you move your computer to another time zone
+or if there are clock changes for daylight saving in your zone), you can have some problems
+with update commands that depend from file's modification time. It's strongly recommended to use only
+file system that uses Coordinated Universal Time (UTC) and archive format that also uses UTC.
+In that case you will have no problems with time zone changes.
+Also it's recommended to use only UTC formats in other cases, for example, if you send files to
+someone in another time zone.</P>
+
+<P>Also in some cases there are no problems, if both file system and archive format use local time, for example, FAT file system and ZIP format.</P>
+<UL>
+<LI>UTC file systems: NTFS
+<LI>UTC archive formats: .zip with -mtc switch, 7z, tar, gzip2, iso, wim
+<LI>Local time file systems : FAT, FAT32
+<LI>Local time archive formats : rar, zip, cab
+</UL>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z u c:\1\exist.7z -u- -up0q3x2z0!c:\1\update.7z *
+</PRE>
+
+<P>creates a new archive <SPAN class="filename">update.7z</SPAN> and
+writes to this archive all files from current directory which differ from
+files in <SPAN class="filename">exist.7z</SPAN> archive.
+<SPAN class="filename">exist.7z</SPAN> archive will not be changed.</P>
+
+<PRE class="example">
+7z u c:\1\exist.7z -up0q3x2z0!c:\1\update.7z * -ms=off
+</PRE>
+
+<P>creates a new archive <SPAN class="filename">update.7z</SPAN> and
+writes to this archive all files from the current directory which differ from
+files in <SPAN class="filename">exist.7z</SPAN> archive.
+
+<P>Note: the updating of solid .7z archives can be slow, since it
+can require some recompression.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/volume.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/volume.htm
new file mode 100644
index 000000000..91ddc2924
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/volume.htm
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-v (Create Volumes) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-v (Create Volumes) switch</H1>
+
+<P>Specifies volume sizes.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-v{Size}[b | k | m | g]
+
+</PRE>
+<DL>
+ <DT>{Size}[b | k | m | g]</DT>
+ <DD>Specifies volume size in Bytes, Kilobytes (1 Kilobyte = 1024 bytes),
+ Megabytes (1 Megabyte = 1024 Kilobytes) or Gigabytes (1 Gigabyte = 1024 Megabytes).
+ if you specify only {Size}, 7-zip will treat it as bytes.</DD>
+</DL>
+
+<P>It's possible to specify several -v switches.</P>
+
+<P><B>NOTE:</B> Please don't use volumes (and don't copy volumes) before finishing archiving.
+7-Zip can change any volume (including first volume) at the end of archiving operation.</P>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z a a.7z *.txt -v10k -v15k -v2m
+</PRE>
+
+<P>creates multivolume <SPAN class="filename">a.7z</SPAN> archive.
+First volume will be 10 KB, second will be 15 KB, and all others will be 2 MB.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/working_dir.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/working_dir.htm
new file mode 100644
index 000000000..415c3971b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/working_dir.htm
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-w (set Working directory) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-w (set Working directory) switch</H1>
+
+<P>Sets the working directory for the temporary base archive. By
+default, 7-Zip builds a new base archive file in the same directory as the
+old base archive file. By specifying this switch, you can set the
+working directory where the temporary base archive file will be built.
+After the temporary base archive file is built, it is copied over the
+original archive; then, the temporary file is deleted.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">
+-w[<A class="parameter" href="#dir_path">{dir_path}</A>]
+</PRE>
+
+<DL>
+ <DT><A name="dir_path"></A>{dir_path}</DT>
+ <DD>
+ <P>Specifies the destination directory path. It's not required that
+ a path end with a backslash.</P>
+ <P>If &lt;dir_path> is not assigned, then 7-Zip will use the Windows temporary directory.</P>
+ </DD>
+</DL>
+
+
+<H4>Example</H4>
+
+<PRE class="example">
+7z a -tzip archive.zip *.cpp -wc:\temp
+</PRE>
+
+<P>adds <SPAN class="filename">*.cpp</SPAN> files to the
+<SPAN class="filename">archive.zip</SPAN> archive, creating a temporary archive
+in <SPAN class="filename">c:\temp</SPAN> folder.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/add.htm">a (Add)</A>,
+ <A href="../commands/delete.htm">d (Delete)</A>,
+ <A href="../commands/update.htm">u (Update)</A>,
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/yes.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/yes.htm
new file mode 100644
index 000000000..142ffd20c
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/switches/yes.htm
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>-y (assume Yes on all queries) switch</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>-y (assume Yes on all queries) switch</H1>
+
+<P>Disables most of the normal user queries during 7-Zip
+execution. You can use this switch to suppress overwrite queries in the
+<A href="../commands/extract.htm">e (Extract)</A> and
+<A href="../commands/extract_full.htm">x (Extract with full paths)</A> commands.</P>
+
+<H4>Syntax</H4>
+
+<PRE class="syntax">-y</PRE>
+
+<H4>Examples</H4>
+
+<PRE class="example">
+7z x src.zip -y
+</PRE>
+
+<P>extracts all files from
+ <SPAN class="filename">src.zip</SPAN> archive. All overwrite queries will be
+suppressed and files on disk with same filenames as in archive will be
+overwritten.</P>
+
+<H4>Commands that can be used with this switch</H4>
+
+<P>
+ <A href="../commands/extract.htm">e (Extract)</A>,
+ <A href="../commands/extract_full.htm">x (Extract with full paths)</A>
+</P>
+
+<H4>See also</H4>
+
+<P>
+ <B>Switches:</B>
+ <A href="overwrite.htm">-ao (Overwrite mode)</A>,
+</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/syntax.htm b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/syntax.htm
new file mode 100644
index 000000000..63822e03b
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/MANUAL/syntax.htm
@@ -0,0 +1,120 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+ <META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
+ <TITLE>Command Line Syntax</TITLE>
+ <LINK href="style.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
+
+<H1>Command Line Syntax</H1>
+
+<PRE class = "syntax">
+7z <A href = "commands/index.htm">&lt;command></A> [<A href = "switches/index.htm">&lt;switch></A>...] &lt;base_archive_name> [&lt;arguments>...]
+</PRE>
+<PRE class = "syntax">
+&lt;arguments> ::= <A href = "switches/index.htm">&lt;switch></A> | &lt;wildcard> | &lt;filename> | &lt;list_file>
+<A href = "switches/index.htm">&lt;switch></A>::= &lt;switch_symbol>&lt;switch_characters>[&lt;option>]
+&lt;switch_symbol> ::= '/' | '-'
+&lt;list_file> ::= @{filename}
+</PRE>
+
+
+<P>Expressions in square brackets (between '[' and ']') are optional.</P>
+
+<P>Expressions in curly braces ('{' and '}') mean that instead of that
+Expression (including braces), the user must substitute some string.</P>
+
+<P>Expression</P>
+
+<PRE class = "syntax">
+expression1 | expression2 | ... | expressionN</DT>
+</PRE>
+
+<P>
+means that any (but only one) from these expressions must be specified.
+
+<P><A href = "commands/index.htm">Commands</A> and
+<A href = "switches/index.htm">switches</A> can be entered in upper or lower case.</P>
+
+<P>Command is the first non-switch argument.</P>
+
+<P>The "base_archive_name" must be the first filename on the command line
+after the command.</P>
+
+<P>The switches and other filenames can be in any order.</P>
+
+<P>Wildcards or filenames with spaces must be quoted:</P>
+
+<PRE>
+ "Dir\Program files\*"
+ Dir\"Program files"\*
+</PRE>
+
+<P>Switch options can be combined to save command line length. However, some
+switch options take optional string arguments and therefore, must be the
+last option in a combined argument token string because 7-Zip accepts the
+rest of the argument token as the optional argument.</P>
+
+<P>7-Zip uses wild name matching similar to Windows 95:</P>
+<UL>
+ <LI><B>'*'</B> means a sequence of arbitrary characters.</LI>
+ <LI><B>'?'</B> means any character.</LI>
+</UL>
+
+<P><B>
+7-Zip doesn't uses the system wildcard parser. 7-Zip doesn't
+follow the archaic rule by which *.* means any file. 7-Zip treats
+*.* as matching the name of any file that has an extension. To process all files, you must
+use a * wildcard.</B></P>
+
+<P>Examples:</P>
+<TABLE border = "0">
+ <TR><TD>*.txt</TD><TD>means all files with an extension of ".txt"</TD></TR>
+ <TR><TD>?a*</TD><TD>means all files with a second character of "a"</TD></TR>
+ <TR><TD>*1*</TD><TD>means all names that contains character "1"</TD></TR>
+ <TR><TD>*.*.*</TD><TD>means all names that contain two at least "." characters</TD></TR>
+</TABLE>
+
+
+<P>The default wildcard "*" will be used if there is no filename/wildcard in the
+command line.</P>
+
+<P>Slash ('\') at the end of a path means a directory. Without a Slash ('\') at
+the end of the path, the path can refer either to a file or a directory.
+
+
+<H2><A name = "ListFile"></A>List file</H2>
+
+<P>You can supply one or more filenames or wildcards for special list files
+(files containing lists of files). The filenames in such list file must be
+separated by new line symbol(s).</P>
+
+<P>For list files, 7-Zip uses UTF-8 encoding by default. You can change encoding
+using <A href = "switches/charset.htm">-scs</A> switch.</P>
+
+<P>Multiple list files are supported.</P>
+
+<P>For example, if the file "listfile.txt" contains the following:</P>
+
+<PRE>
+ My programs\*.cpp
+ Src\*.cpp
+</PRE>
+<P>then the command</P>
+
+<PRE>
+ 7z a -tzip archive.zip @listfile.txt
+</PRE>
+
+<P>adds to the archive "archive.zip" all "*.cpp" files from directories "My
+programs" and "Src".</P>
+
+<H2><A name = "ListFile"></A>Short and Long File Names</H2>
+
+<P>7-Zip supports short file names (like FILENA~1.TXT) in some cases.
+However, it's strongly recommended to use only the real (long) file names.</P>
+
+</BODY>
+</HTML>
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/Methods.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/Methods.txt
new file mode 100644
index 000000000..5b5cb931a
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/Methods.txt
@@ -0,0 +1,137 @@
+7-Zip method IDs (4.65)
+-----------------------
+
+Each compression or crypto method in 7z has unique binary value (ID).
+The length of ID in bytes is arbitrary but it can not exceed 63 bits (8 bytes).
+
+If you want to add some new ID, you have two ways:
+1) Write request for allocating IDs to 7-zip developers.
+2) Generate 8-bytes ID:
+
+ 3F ZZ ZZ ZZ ZZ ZZ MM MM
+
+ 3F - Prefix for random IDs (1 byte)
+ ZZ ZZ ZZ ZZ ZZ - Developer ID (5 bytes). Use real random bytes.
+
+ MM MM - Method ID (2 bytes)
+
+ You can notify 7-Zip developers about your Developer ID / Method ID.
+
+ Note: Use new ID only if old codec can not decode data encoded with new version.
+
+
+List of defined IDs
+-------------------
+
+00 - Copy
+
+02 - Common
+ 03 Swap
+ - 2 Swap2
+ - 4 Swap4
+
+03 - 7z
+ 01 - LZMA
+ 01 - Version
+
+ 03 - Branch
+ 01 - x86
+ 03 - BCJ
+ 1B - BCJ2
+ 02 - PPC
+ 05 - PPC (Big Endian)
+ 03 - Alpha
+ 01 - Alpha
+ 04 - IA64
+ 01 - IA64
+ 05 - ARM
+ 01 - ARM
+ 06 - M68
+ 05 - M68 (Big Endian)
+ 07 - ARM Thumb
+ 01 - ARMT
+ 08 - SPARC
+ 05 - SPARC
+
+ 04 - PPMD
+ 01 - Version
+
+ 7F -
+ 01 - experimental methods.
+
+
+04 - Misc
+ 00 - Reserved
+ 01 - Zip
+ 00 - Copy (not used). Use {00} instead
+ 01 - Shrink
+ 06 - Implode
+ 08 - Deflate
+ 09 - Deflate64
+ 12 - BZip2 (not used). Use {04 02 02} instead
+ 02 - BZip
+ 02 - BZip2
+ 03 - Rar
+ 01 - Rar15
+ 02 - Rar20
+ 03 - Rar29
+ 04 - Arj
+ 01 - Arj (1,2,3)
+ 02 - Arj 4
+ 05 - Z
+ 06 - Lzh
+ 07 - Reserved for 7z
+ 08 - Cab
+ 09 - NSIS
+ 01 - DeflateNSIS
+ 02 - BZip2NSIS
+
+
+06 - Crypto
+ 00 -
+ 01 - AES
+ 0x - AES-128
+ 4x - AES-192
+ 8x - AES-256
+ Cx - AES
+
+ x0 - ECB
+ x1 - CBC
+ x2 - CFB
+ x3 - OFB
+
+ 07 - Reserved
+ 0F - Reserved
+
+ F0 - Misc Ciphers (Real Ciphers without hashing algo)
+
+ F1 - Misc Ciphers (Combine)
+ 01 - Zip
+ 01 - Main Zip crypto algo
+ 03 - RAR
+ 02 -
+ 03 - Rar29 AES-128 + (modified SHA-1)
+ 07 - 7z
+ 01 - AES-256 + SHA-256
+
+07 - Hash (subject to change)
+ 00 -
+ 01 - CRC
+ 02 - SHA-1
+ 03 - SHA-256
+ 04 - SHA-384
+ 05 - SHA-512
+
+ F0 - Misc Hash
+
+ F1 - Misc
+ 03 - RAR
+ 03 - Rar29 Password Hashing (modified SHA1)
+ 07 - 7z
+ 01 - SHA-256 Password Hashing
+
+
+
+
+---
+End of document
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/copying.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/copying.txt
new file mode 100644
index 000000000..4c3890127
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/copying.txt
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/history.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/history.txt
new file mode 100644
index 000000000..bf2b4ca4e
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/history.txt
@@ -0,0 +1,431 @@
+Sources history of the 7-Zip
+----------------------------
+
+9.04 2009-05-30
+-------------------------
+- ICoder.h: NCoderPropID::EEnum values were changed
+
+
+9.02 2009-04-23
+-------------------------
+- Bug was fixed: if swap2 filter was requests at compression,
+ 7-zip used swap4 filter instead (but id was swap2), so archives were incorrect.
+
+4.61 2008-11-23
+-------------------------
+- Bug in ver. 4.58+ was fixed:
+ 7-Zip didn't use any -m* switch after -mtc, -mcl or -mcu for .zip archives.
+- Bug in .CAB code was fixed. 7-Zip didn't show some empty files,
+ if .CAB archive contains more than one empty file.
+
+
+4.59 2008-07-27
+-------------------------
+- Bug was fixed:
+ LZMA Encoder in fast compression mode could access memory outside of
+ allocated range in some rare cases.
+
+
+4.59 alpha 2008-05-30
+-------------------------
+- BUGS was fixed:
+ 7zOut.cpp: 7-Zip incorrectly wrote size of property records in some cases.
+ 7zIn.cpp: 7-Zip incorrectly work with archive, containg archive properties.
+
+4.58 alpha 9 2008-04-29
+-------------------------
+- BUG was fixed: 7-Zip showed incorrect timestamps in ISO files.
+
+
+4.58 alpha 8 2008-04-15
+-------------------------
+- BUG in 4.58 alpha 5/6/7 was fixed:
+ LZMA encoder worked incorrectly, if lp != 0.
+- Unicode (UTF-8) support for filenames in .ZIP archives. Now there are 3 modes:
+ 1) Default mode: 7-Zip uses UTF-8, if the local code page doesn't contain required symbols.
+ 2) -mcu switch: 7-Zip uses UTF-8, if there are non-ASCII symbols.
+ 3) -mcl switch: 7-Zip uses local code page.
+- Now it's possible to use -mSW- and -mSW+ switches instead of -mSW=off and -mSW=on
+
+
+4.58 alpha 7 2008-04-08
+-------------------------
+- BUG was fixed: BZip2Encoder and BZip2Decoder used CEvent objects without
+ creating, when BZip2 code was called with one thread (with -mmt1 switch or with
+ default switches on single thread CPU).
+- .lzma support.
+- RPM and NSIS support was improved.
+- LZMA now stores only (2 << n) or (3 << n) dictionary size value to LZMA properties.
+
+
+4.58 alpha 6 2008-03-27
+-------------------------
+- NTFS time extra in ZIP.
+- New item property - kpidTimeType - VT_UI4 (0 - NTFS, 1 - Unix, 2 - DOS).
+- Static CRC table is not required now for Lzma Encoder (in Lz MatchFinder).
+
+
+4.58 alpha 5 2008-03-19
+-------------------------
+- Creation time (-mtc switch) for .7z archives
+- LZMA encoder was converted to ANSI-C
+
+
+4.58 alpha 3 2008-02-25
+-------------------------
+- Speed optimizations for LZMA decoding. Now it uses C code instead of C++.
+- 7-Zip now has 128 MB dictionary limit for 32-bit version:
+ It's for speed optimization: kNumLogBits = 9 + sizeof(size_t) / 2;
+- TAR: 'D' link flag support.
+- 7-Zip now can unpack multivolume RAR archives created with
+ "old style volume names" scheme (-vn switch) and names *.001, *.002, ...
+- Fixed bugs:
+ - 7-Zip FM could not copy / move files to root network folders like \\COMPNAME\FOLDERNAME\
+ In case of move it removed original files.
+ - SFX-WIN: if there are errors, it still could return 0.
+ - ZIP (.XPS file) isZip64 && thisDiskNumber16 == 0xFFFF.
+ - ZIP name updating:
+ If zip file contains extra field and you try to change properties of files,
+ 7-zip tries to delete all extra fileds (except for WzAES).
+ And that code could hang.
+ - 7-Zip GUI didn't suggest BZip2 dictionary size used in previous run.
+ - If creation time stamp was included in .RAR archive, 7-zip used creation time stamp
+ as modification time stamp.
+
+4.58 alpha 2 2007-12-31
+-------------------------
+- Small changes in Deflate and LZMA compression.
+- Some speed optimizations.
+
+
+4.57
+----
+- Bug was fixed:
+ Anti item is created for wrong file:
+ http://sourceforge.net/forum/forum.php?thread_id=1880366&forum_id=45798
+
+
+4.52 beta 2007-07-32
+-------------------------
+- 7-Zip could not decompress some cab files
+- "." dir creating at FAT was fixed / long names
+
+
+4.50 beta 2007-07-24
+-------------------------
+- 7-Zip now replaces unsupported filenames (like "nul", "com1") during extracting.
+- New switch for command line version:
+ -ssc[-] enables/disables case-sensitive mode.
+- 7z.exe l shows archive comment for zip archives
+- Some bugs were fixed: long paths names shorter than 4.
+- Speed optimizations for AES encryption.
+
+
+
+4.56 beta 2007-09-13
+-------------------------
+- some fixes in LZ encoder (LZMA and Deflate) code.
+ size_t was replaces to ptrdiff_t.
+ size_t version worked incorrectly with some compilers.
+
+
+4.46 beta 2007-05-25
+-------------------------
+- CPP Synchronization objects now return HRes (error code) instead of bool.
+
+
+4.45 beta 2007-04-16
+-------------------------
+- 7-Zip now uses C version of CRC, so you must call CrcGenerateTable at
+ stratup code, or you must add CPP/Common/CRC.cpp to your project.
+- Method ID in .7z now is 63-bit integer (UInt64).
+- Open error messages
+- unRar 1.5 fixed
+- unShrink fixed
+- BUG of 4.43 beta and 4.44 beta was fixed.
+ 7-Zip compressing to .zip in multi-threading mode didn't work in some cases.
+
+
+4.44 beta 2007-01-20
+-------------------------
+
+- Bug was fixed: LZMAEncoder.cpp::CEncoder::GetOptimumFast
+ it was:
+ data++
+ fixed version:
+ data = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
+ It could lead to very small cpmpression ratio decreasing when block needs move.
+
+
+4.30 beta 2005-11-18
+-------------------------
+- Security.h::AddLockMemoryPrivilege - installs "Large pages" feature
+- MemoryLock.h::EnableLockMemoryPrivilege - enables "Large pages" feature
+- Alloc.h::SetLargePageSize - sets optimal LargePageSize size
+
+
+4.27 2005-09-21
+-------------------------
+- Some GUIDs/interfaces were changed.
+ IStream.h:
+ ISequentialInStream::Read now works as old ReadPart
+ ISequentialOutStream::Write now works as old WritePart
+
+
+4.26 beta 2005-08-05
+-------------------------
+- MyAlloc(0)/BigAlloc(0) now return 0
+
+
+4.25 beta 2005-07-31
+-------------------------
+- More 64-bit compatibilty
+
+
+4.24 beta 2005-07-06
+-------------------------
+- Common\NewHandler.h: using throw() for code size optimization.
+
+
+4.23 2005-06-29
+-------------------------
+- Bug was fixed: memory leak in Cab decoder.
+
+
+4.19 beta 2005-05-21
+-------------------------
+- BZip2 code was rewritten. Now 7-Zip doesn't use original BZip2 code.
+ Old (original) version was moved to folder 7zip/Compress/BZip2Original/
+
+
+4.14 beta 2005-01-11
+-------------------------
+- STL using was reduced
+- 7za now supports Split(001) archves
+
+
+4.10 beta 2004-10-21
+-------------------------
+- Codecs now use new interface: ICompressSetDecoderProperties2
+
+
+4.07 beta 2004-10-03
+-------------------------
+- some interfaces were changed slightly to support
+ -stdin -stdout mode.
+- FilterCoder for simple filters
+- Wildcard censor class was changed.
+- Bug was fixed: when encrypted stream was multiple 16,
+ it used additional 16 empty bytes.
+
+
+3.11 2003-10-06
+-------------------------
+ File functions support unicode strings even
+ on Windows 95/98/ME.
+
+
+3.08.02 2003-09-20
+-------------------------
+ More compatible with GCC.
+
+
+3.08.02 beta 2003-08-20
+-------------------------
+ Extracting bug in 7zExtract.cpp was fixed.
+
+
+3.08 beta 2003-08-19
+-------------------------
+ Big source code reconstruction.
+
+
+2.30 Beta 32 2003-05-15
+-------------------------
+ Small changes in Deflate decoder.
+
+
+2.30 Beta 31 2003-04-29
+-------------------------
+ Common/NewHandler.cpp
+ HeapAlloc in (included to beta 30) was changed to malloc.
+ HeapAlloc worked slower in Win95/98/Me.
+
+
+2.30 Beta 30 2003-04-21
+-------------------------
+ new file: Common/String.cpp
+ Common/NewHandler.* were changed
+
+
+2.30 Beta 29 2003-04-07
+-------------------------
+ Small changes in LZMA code.
+
+
+2.30 Beta 28 2003-02-16
+-------------------------
+ Processing anti-files was corrected.
+
+
+2.30 Beta 27 2003-01-24
+-------------------------
+ Project/Archiver/Format/Common/ArchiveInterface.h:
+ new IArchiveOpenVolumeCallback interface.
+
+
+2.30 Beta 26 2003-01-12
+-------------------------
+ SDK/Interface/PropID.h:
+ kpidComment now is kpidCommented
+
+
+2.30 Beta 25 2003-01-02
+-------------------------
+ Main archive interfaces were changed.
+
+
+2.30 Beta 24 2002-11-01
+-------------------------
+ SDK/Windows/Synchronization.h
+ SDK/Windows/Synchronization.cpp
+ - some changes.
+
+
+2.30 Beta 23 2002-09-07
+-------------------------
+ Project/FileManager folder was added.
+ Notation of some source files was changed.
+
+
+2.30 Beta 22 2002-08-28
+-------------------------
+ Project/FileManager folder was added.
+ Notation of some source files was changed.
+
+
+
+2.30 Beta 21 2002-07-08
+-------------------------
+ Project/Compress/LZ/MatchFinder/BinTree/BinTree.h
+ Project/Compress/LZ/MatchFinder/BinTree/BinTreeMain.h
+ Project/Compress/LZ/MatchFinder/BinTree/HC.h
+ Project/Compress/LZ/MatchFinder/BinTree/HCMain.h
+ - RAM requirements for LZMA (7z) compression were reduced.
+
+
+2.30 Beta 20 2002-07-01
+-------------------------
+- SDK/Stream/WindowOut.h
+ now it uses only required memory (dictionary size).
+- Project/Archiver/Resource
+ contains common resurces
+
+
+2.30 Beta 19 2002-04-11
+-------------------------
+- SDK/Archive/Rar/Handler.cpp
+ supporting RAR29
+
+2.30 Beta 18 2002-03-25
+-------------------------
+- SDK/Archive/Cab/MSZipDecoder.cpp
+ SDK/Archive/Cab/LZXDecoder.cpp:
+ bug with corrupted archives was fixed
+- Project/Compress/LZ/MatchFinder/BinTree/BinTree.h
+- Project/Compress/LZ/MatchFinder/BinTree/BinTreeMain.h
+ some speed optimization (using prefetching)
+
+
+2.30 Beta 17 2002-03-03
+-------------------------
+- ARJ suppport.
+
+
+2.30 Beta 16 2002-02-24
+-------------------------
+- Project/Compress/LZ/LZMA/Decoder.cpp:
+ Bug was fixed: LZMA could not extract more than 4 GB.
+- RPM and CPIO formats.
+- Project/Compress/LZ/LZMA/Encoder.*
+ Project/Archiver/Format/7z/OutHandler.cpp
+ New fast compression mode for LZMA: -m0a=0.
+- New match finders for LZMA: bt4b, hc3, hc4.
+
+
+2.30 Beta 15 2002-02-17
+-------------------------
+- Compression ratio in LZMA was slightly improved:
+ Project/Compress/LZ/LZMA/Encoder.*
+ Project/Archiver/Format/7z/OutHandler.cpp
+
+
+2.30 Beta 14 2002-02-10
+-------------------------
+- Supporting multithreading for LZMA:
+ Project/Compress/LZ/MatchFinder/MT
+- Common/String.h:
+ CStringBase::Replace function was fixed.
+
+
+2.30 Beta 13 2002-01-27
+-------------------------
+- Compress/LZ/MatchFinder/BinTree3.h:
+ method
+- Compress/LZ/MatchFinder/BinTreemain.h:
+ - one VirtualAlloc array was splitted to
+ the for 3 arrays.
+ - Hash-functions were changed.
+
+
+
+2.30 Beta 12 2002-01-16
+-------------------------
+- Compress/LZ/MatchFinder/BinTreemain.h:
+ Compress/LZ/MatchFinder/Patricia.h:
+ Compress/PPM/PPMd/SubAlloc.h:
+ Beta 11 bugs were fixed:
+ - VirtualFree was used incorrectly
+ - checking WIN32 instead _WINDOWS.
+ Compress/LZ/MatchFinder/Patricia.h:
+ Beta 11 bug with deleting m_Hash2Descendants was fixed.
+
+
+2.30 Beta 11 2002-01-15
+-------------------------
+- Compress/LZ/MatchFinder/BinTreemain.h:
+ Compress/LZ/MatchFinder/Patricia.h:
+ Compress/PPM/PPMd/SubAlloc.h:
+ using VirtualAlloc for memory allocating
+- Exlorer/ContextMenu.cpp:
+ Testing supporting.
+ CreateProcess instead WinExec
+- Format/Common/IArchiveHandler.h:
+ Exlorer/ProxyHandler.cpp:
+ FAR/Plugin.cpp:
+ New properties names: Method, HostOS.
+- Exlorer/OverwriteDialog.cpp:
+ FAR/OverwriteDialog.cpp:
+ Windows/PropVariantConversions.h
+ Using National time format was eliminated.
+
+
+
+2.30 Beta 10 2002-01-11
+-------------------------
+- Exlorer/ContextMenu.cpp: bug with context menu on
+ Windows NT4 in Unicode version was fixed.
+- Format/7z/UpdateArchiveEngine.cpp: bug was fixed -
+ Updating in Beta 8 and 9 didn't work.
+- Exlorer/CCompressDialog.cpp: history growing bug was fixed.
+
+
+2.30 Beta 9 2002-01-08
+-------------------------
+- SDK/Common/Vector.h: sopporting sorted object vectors .
+- Lang features.
+- Two new match finders: pat3h and pat4h.
+- SDK/Archive/Zip/InEngine.cpp: bug was fixed.
+- SDK/Windows/FileDir.cpp: function CreateComplexDirectory
+ was changed.
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/lzma.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/lzma.txt
new file mode 100644
index 000000000..026b850d2
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/lzma.txt
@@ -0,0 +1,591 @@
+LZMA SDK 9.04
+-------------
+
+LZMA SDK provides the documentation, samples, header files, libraries,
+and tools you need to develop applications that use LZMA compression.
+
+LZMA is default and general compression method of 7z format
+in 7-Zip compression program (www.7-zip.org). LZMA provides high
+compression ratio and very fast decompression.
+
+LZMA is an improved version of famous LZ77 compression algorithm.
+It was improved in way of maximum increasing of compression ratio,
+keeping high decompression speed and low memory requirements for
+decompressing.
+
+
+
+LICENSE
+-------
+
+LZMA SDK is written and placed in the public domain by Igor Pavlov.
+
+
+LZMA SDK Contents
+-----------------
+
+LZMA SDK includes:
+
+ - ANSI-C/C++/C#/Java source code for LZMA compressing and decompressing
+ - Compiled file->file LZMA compressing/decompressing program for Windows system
+
+
+UNIX/Linux version
+------------------
+To compile C++ version of file->file LZMA encoding, go to directory
+C++/7zip/Compress/LZMA_Alone
+and call make to recompile it:
+ make -f makefile.gcc clean all
+
+In some UNIX/Linux versions you must compile LZMA with static libraries.
+To compile with static libraries, you can use
+LIB = -lm -static
+
+
+Files
+---------------------
+lzma.txt - LZMA SDK description (this file)
+7zFormat.txt - 7z Format description
+7zC.txt - 7z ANSI-C Decoder description
+methods.txt - Compression method IDs for .7z
+lzma.exe - Compiled file->file LZMA encoder/decoder for Windows
+7zr.exe - 7-Zip with 7z/lzma/xz support.
+history.txt - history of the LZMA SDK
+
+
+Source code structure
+---------------------
+
+C/ - C files
+ 7zCrc*.* - CRC code
+ Alloc.* - Memory allocation functions
+ Bra*.* - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
+ LzFind.* - Match finder for LZ (LZMA) encoders
+ LzFindMt.* - Match finder for LZ (LZMA) encoders for multithreading encoding
+ LzHash.h - Additional file for LZ match finder
+ LzmaDec.* - LZMA decoding
+ LzmaEnc.* - LZMA encoding
+ LzmaLib.* - LZMA Library for DLL calling
+ Types.h - Basic types for another .c files
+ Threads.* - The code for multithreading.
+
+ LzmaLib - LZMA Library (.DLL for Windows)
+
+ LzmaUtil - LZMA Utility (file->file LZMA encoder/decoder).
+
+ Archive - files related to archiving
+ 7z - 7z ANSI-C Decoder
+
+CPP/ -- CPP files
+
+ Common - common files for C++ projects
+ Windows - common files for Windows related code
+
+ 7zip - files related to 7-Zip Project
+
+ Common - common files for 7-Zip
+
+ Compress - files related to compression/decompression
+
+ LZMA_Alone - file->file LZMA compression/decompression
+
+ Archive - files related to archiving
+
+ Common - common files for archive handling
+ 7z - 7z C++ Encoder/Decoder
+
+ Bundles - Modules that are bundles of other modules
+
+ Alone7z - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2
+ Format7zR - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2
+ Format7zExtractR - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2.
+
+ UI - User Interface files
+
+ Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll
+ Common - Common UI files
+ Console - Code for console archiver
+
+
+
+CS/ - C# files
+ 7zip
+ Common - some common files for 7-Zip
+ Compress - files related to compression/decompression
+ LZ - files related to LZ (Lempel-Ziv) compression algorithm
+ LZMA - LZMA compression/decompression
+ LzmaAlone - file->file LZMA compression/decompression
+ RangeCoder - Range Coder (special code of compression/decompression)
+
+Java/ - Java files
+ SevenZip
+ Compression - files related to compression/decompression
+ LZ - files related to LZ (Lempel-Ziv) compression algorithm
+ LZMA - LZMA compression/decompression
+ RangeCoder - Range Coder (special code of compression/decompression)
+
+
+C/C++ source code of LZMA SDK is part of 7-Zip project.
+7-Zip source code can be downloaded from 7-Zip's SourceForge page:
+
+ http://sourceforge.net/projects/sevenzip/
+
+
+
+LZMA features
+-------------
+ - Variable dictionary size (up to 1 GB)
+ - Estimated compressing speed: about 2 MB/s on 2 GHz CPU
+ - Estimated decompressing speed:
+ - 20-30 MB/s on 2 GHz Core 2 or AMD Athlon 64
+ - 1-2 MB/s on 200 MHz ARM, MIPS, PowerPC or other simple RISC
+ - Small memory requirements for decompressing (16 KB + DictionarySize)
+ - Small code size for decompressing: 5-8 KB
+
+LZMA decoder uses only integer operations and can be
+implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).
+
+Some critical operations that affect the speed of LZMA decompression:
+ 1) 32*16 bit integer multiply
+ 2) Misspredicted branches (penalty mostly depends from pipeline length)
+ 3) 32-bit shift and arithmetic operations
+
+The speed of LZMA decompressing mostly depends from CPU speed.
+Memory speed has no big meaning. But if your CPU has small data cache,
+overall weight of memory speed will slightly increase.
+
+
+How To Use
+----------
+
+Using LZMA encoder/decoder executable
+--------------------------------------
+
+Usage: LZMA <e|d> inputFile outputFile [<switches>...]
+
+ e: encode file
+
+ d: decode file
+
+ b: Benchmark. There are two tests: compressing and decompressing
+ with LZMA method. Benchmark shows rating in MIPS (million
+ instructions per second). Rating value is calculated from
+ measured speed and it is normalized with Intel's Core 2 results.
+ Also Benchmark checks possible hardware errors (RAM
+ errors in most cases). Benchmark uses these settings:
+ (-a1, -d21, -fb32, -mfbt4). You can change only -d parameter.
+ Also you can change the number of iterations. Example for 30 iterations:
+ LZMA b 30
+ Default number of iterations is 10.
+
+<Switches>
+
+
+ -a{N}: set compression mode 0 = fast, 1 = normal
+ default: 1 (normal)
+
+ d{N}: Sets Dictionary size - [0, 30], default: 23 (8MB)
+ The maximum value for dictionary size is 1 GB = 2^30 bytes.
+ Dictionary size is calculated as DictionarySize = 2^N bytes.
+ For decompressing file compressed by LZMA method with dictionary
+ size D = 2^N you need about D bytes of memory (RAM).
+
+ -fb{N}: set number of fast bytes - [5, 273], default: 128
+ Usually big number gives a little bit better compression ratio
+ and slower compression process.
+
+ -lc{N}: set number of literal context bits - [0, 8], default: 3
+ Sometimes lc=4 gives gain for big files.
+
+ -lp{N}: set number of literal pos bits - [0, 4], default: 0
+ lp switch is intended for periodical data when period is
+ equal 2^N. For example, for 32-bit (4 bytes)
+ periodical data you can use lp=2. Often it's better to set lc0,
+ if you change lp switch.
+
+ -pb{N}: set number of pos bits - [0, 4], default: 2
+ pb switch is intended for periodical data
+ when period is equal 2^N.
+
+ -mf{MF_ID}: set Match Finder. Default: bt4.
+ Algorithms from hc* group doesn't provide good compression
+ ratio, but they often works pretty fast in combination with
+ fast mode (-a0).
+
+ Memory requirements depend from dictionary size
+ (parameter "d" in table below).
+
+ MF_ID Memory Description
+
+ bt2 d * 9.5 + 4MB Binary Tree with 2 bytes hashing.
+ bt3 d * 11.5 + 4MB Binary Tree with 3 bytes hashing.
+ bt4 d * 11.5 + 4MB Binary Tree with 4 bytes hashing.
+ hc4 d * 7.5 + 4MB Hash Chain with 4 bytes hashing.
+
+ -eos: write End Of Stream marker. By default LZMA doesn't write
+ eos marker, since LZMA decoder knows uncompressed size
+ stored in .lzma file header.
+
+ -si: Read data from stdin (it will write End Of Stream marker).
+ -so: Write data to stdout
+
+
+Examples:
+
+1) LZMA e file.bin file.lzma -d16 -lc0
+
+compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K)
+and 0 literal context bits. -lc0 allows to reduce memory requirements
+for decompression.
+
+
+2) LZMA e file.bin file.lzma -lc0 -lp2
+
+compresses file.bin to file.lzma with settings suitable
+for 32-bit periodical data (for example, ARM or MIPS code).
+
+3) LZMA d file.lzma file.bin
+
+decompresses file.lzma to file.bin.
+
+
+Compression ratio hints
+-----------------------
+
+Recommendations
+---------------
+
+To increase the compression ratio for LZMA compressing it's desirable
+to have aligned data (if it's possible) and also it's desirable to locate
+data in such order, where code is grouped in one place and data is
+grouped in other place (it's better than such mixing: code, data, code,
+data, ...).
+
+
+Filters
+-------
+You can increase the compression ratio for some data types, using
+special filters before compressing. For example, it's possible to
+increase the compression ratio on 5-10% for code for those CPU ISAs:
+x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC.
+
+You can find C source code of such filters in C/Bra*.* files
+
+You can check the compression ratio gain of these filters with such
+7-Zip commands (example for ARM code):
+No filter:
+ 7z a a1.7z a.bin -m0=lzma
+
+With filter for little-endian ARM code:
+ 7z a a2.7z a.bin -m0=arm -m1=lzma
+
+It works in such manner:
+Compressing = Filter_encoding + LZMA_encoding
+Decompressing = LZMA_decoding + Filter_decoding
+
+Compressing and decompressing speed of such filters is very high,
+so it will not increase decompressing time too much.
+Moreover, it reduces decompression time for LZMA_decoding,
+since compression ratio with filtering is higher.
+
+These filters convert CALL (calling procedure) instructions
+from relative offsets to absolute addresses, so such data becomes more
+compressible.
+
+For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.
+
+
+LZMA compressed file format
+---------------------------
+Offset Size Description
+ 0 1 Special LZMA properties (lc,lp, pb in encoded form)
+ 1 4 Dictionary size (little endian)
+ 5 8 Uncompressed size (little endian). -1 means unknown size
+ 13 Compressed data
+
+
+ANSI-C LZMA Decoder
+~~~~~~~~~~~~~~~~~~~
+
+Please note that interfaces for ANSI-C code were changed in LZMA SDK 4.58.
+If you want to use old interfaces you can download previous version of LZMA SDK
+from sourceforge.net site.
+
+To use ANSI-C LZMA Decoder you need the following files:
+1) LzmaDec.h + LzmaDec.c + Types.h
+LzmaUtil/LzmaUtil.c is example application that uses these files.
+
+
+Memory requirements for LZMA decoding
+-------------------------------------
+
+Stack usage of LZMA decoding function for local variables is not
+larger than 200-400 bytes.
+
+LZMA Decoder uses dictionary buffer and internal state structure.
+Internal state structure consumes
+ state_size = (4 + (1.5 << (lc + lp))) KB
+by default (lc=3, lp=0), state_size = 16 KB.
+
+
+How To decompress data
+----------------------
+
+LZMA Decoder (ANSI-C version) now supports 2 interfaces:
+1) Single-call Decompressing
+2) Multi-call State Decompressing (zlib-like interface)
+
+You must use external allocator:
+Example:
+void *SzAlloc(void *p, size_t size) { p = p; return malloc(size); }
+void SzFree(void *p, void *address) { p = p; free(address); }
+ISzAlloc alloc = { SzAlloc, SzFree };
+
+You can use p = p; operator to disable compiler warnings.
+
+
+Single-call Decompressing
+-------------------------
+When to use: RAM->RAM decompressing
+Compile files: LzmaDec.h + LzmaDec.c + Types.h
+Compile defines: no defines
+Memory Requirements:
+ - Input buffer: compressed size
+ - Output buffer: uncompressed size
+ - LZMA Internal Structures: state_size (16 KB for default settings)
+
+Interface:
+ int LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+ ELzmaStatus *status, ISzAlloc *alloc);
+ In:
+ dest - output data
+ destLen - output data size
+ src - input data
+ srcLen - input data size
+ propData - LZMA properties (5 bytes)
+ propSize - size of propData buffer (5 bytes)
+ finishMode - It has meaning only if the decoding reaches output limit (*destLen).
+ LZMA_FINISH_ANY - Decode just destLen bytes.
+ LZMA_FINISH_END - Stream must be finished after (*destLen).
+ You can use LZMA_FINISH_END, when you know that
+ current output buffer covers last bytes of stream.
+ alloc - Memory allocator.
+
+ Out:
+ destLen - processed output size
+ srcLen - processed input size
+
+ Output:
+ SZ_OK
+ status:
+ LZMA_STATUS_FINISHED_WITH_MARK
+ LZMA_STATUS_NOT_FINISHED
+ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
+ SZ_ERROR_DATA - Data error
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_UNSUPPORTED - Unsupported properties
+ SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
+
+ If LZMA decoder sees end_marker before reaching output limit, it returns OK result,
+ and output value of destLen will be less than output buffer size limit.
+
+ You can use multiple checks to test data integrity after full decompression:
+ 1) Check Result and "status" variable.
+ 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
+ 3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
+ You must use correct finish mode in that case. */
+
+
+Multi-call State Decompressing (zlib-like interface)
+----------------------------------------------------
+
+When to use: file->file decompressing
+Compile files: LzmaDec.h + LzmaDec.c + Types.h
+
+Memory Requirements:
+ - Buffer for input stream: any size (for example, 16 KB)
+ - Buffer for output stream: any size (for example, 16 KB)
+ - LZMA Internal Structures: state_size (16 KB for default settings)
+ - LZMA dictionary (dictionary size is encoded in LZMA properties header)
+
+1) read LZMA properties (5 bytes) and uncompressed size (8 bytes, little-endian) to header:
+ unsigned char header[LZMA_PROPS_SIZE + 8];
+ ReadFile(inFile, header, sizeof(header)
+
+2) Allocate CLzmaDec structures (state + dictionary) using LZMA properties
+
+ CLzmaDec state;
+ LzmaDec_Constr(&state);
+ res = LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc);
+ if (res != SZ_OK)
+ return res;
+
+3) Init LzmaDec structure before any new LZMA stream. And call LzmaDec_DecodeToBuf in loop
+
+ LzmaDec_Init(&state);
+ for (;;)
+ {
+ ...
+ int res = LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
+ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode);
+ ...
+ }
+
+
+4) Free all allocated structures
+ LzmaDec_Free(&state, &g_Alloc);
+
+For full code example, look at C/LzmaUtil/LzmaUtil.c code.
+
+
+How To compress data
+--------------------
+
+Compile files: LzmaEnc.h + LzmaEnc.c + Types.h +
+LzFind.c + LzFind.h + LzFindMt.c + LzFindMt.h + LzHash.h
+
+Memory Requirements:
+ - (dictSize * 11.5 + 6 MB) + state_size
+
+Lzma Encoder can use two memory allocators:
+1) alloc - for small arrays.
+2) allocBig - for big arrays.
+
+For example, you can use Large RAM Pages (2 MB) in allocBig allocator for
+better compression speed. Note that Windows has bad implementation for
+Large RAM Pages.
+It's OK to use same allocator for alloc and allocBig.
+
+
+Single-call Compression with callbacks
+--------------------------------------
+
+Check C/LzmaUtil/LzmaUtil.c as example,
+
+When to use: file->file decompressing
+
+1) you must implement callback structures for interfaces:
+ISeqInStream
+ISeqOutStream
+ICompressProgress
+ISzAlloc
+
+static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
+static void SzFree(void *p, void *address) { p = p; MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+ CFileSeqInStream inStream;
+ CFileSeqOutStream outStream;
+
+ inStream.funcTable.Read = MyRead;
+ inStream.file = inFile;
+ outStream.funcTable.Write = MyWrite;
+ outStream.file = outFile;
+
+
+2) Create CLzmaEncHandle object;
+
+ CLzmaEncHandle enc;
+
+ enc = LzmaEnc_Create(&g_Alloc);
+ if (enc == 0)
+ return SZ_ERROR_MEM;
+
+
+3) initialize CLzmaEncProps properties;
+
+ LzmaEncProps_Init(&props);
+
+ Then you can change some properties in that structure.
+
+4) Send LZMA properties to LZMA Encoder
+
+ res = LzmaEnc_SetProps(enc, &props);
+
+5) Write encoded properties to header
+
+ Byte header[LZMA_PROPS_SIZE + 8];
+ size_t headerSize = LZMA_PROPS_SIZE;
+ UInt64 fileSize;
+ int i;
+
+ res = LzmaEnc_WriteProperties(enc, header, &headerSize);
+ fileSize = MyGetFileLength(inFile);
+ for (i = 0; i < 8; i++)
+ header[headerSize++] = (Byte)(fileSize >> (8 * i));
+ MyWriteFileAndCheck(outFile, header, headerSize)
+
+6) Call encoding function:
+ res = LzmaEnc_Encode(enc, &outStream.funcTable, &inStream.funcTable,
+ NULL, &g_Alloc, &g_Alloc);
+
+7) Destroy LZMA Encoder Object
+ LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc);
+
+
+If callback function return some error code, LzmaEnc_Encode also returns that code.
+
+
+Single-call RAM->RAM Compression
+--------------------------------
+
+Single-call RAM->RAM Compression is similar to Compression with callbacks,
+but you provide pointers to buffers instead of pointers to stream callbacks:
+
+HRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
+ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+
+Return code:
+ SZ_OK - OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_PARAM - Incorrect paramater
+ SZ_ERROR_OUTPUT_EOF - output buffer overflow
+ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
+
+
+
+LZMA Defines
+------------
+
+_LZMA_SIZE_OPT - Enable some optimizations in LZMA Decoder to get smaller executable code.
+
+_LZMA_PROB32 - It can increase the speed on some 32-bit CPUs, but memory usage for
+ some structures will be doubled in that case.
+
+_LZMA_UINT32_IS_ULONG - Define it if int is 16-bit on your compiler and long is 32-bit.
+
+_LZMA_NO_SYSTEM_SIZE_T - Define it if you don't want to use size_t type.
+
+
+C++ LZMA Encoder/Decoder
+~~~~~~~~~~~~~~~~~~~~~~~~
+C++ LZMA code use COM-like interfaces. So if you want to use it,
+you can study basics of COM/OLE.
+C++ LZMA code is just wrapper over ANSI-C code.
+
+
+C++ Notes
+~~~~~~~~~~~~~~~~~~~~~~~~
+If you use some C++ code folders in 7-Zip (for example, C++ code for .7z handling),
+you must check that you correctly work with "new" operator.
+7-Zip can be compiled with MSVC 6.0 that doesn't throw "exception" from "new" operator.
+So 7-Zip uses "CPP\Common\NewHandler.cpp" that redefines "new" operator:
+operator new(size_t size)
+{
+ void *p = ::malloc(size);
+ if (p == 0)
+ throw CNewException();
+ return p;
+}
+If you use MSCV that throws exception for "new" operator, you can compile without
+"NewHandler.cpp". So standard exception will be used. Actually some code of
+7-Zip catches any exception in internal code and converts it to HRESULT code.
+So you don't need to catch CNewException, if you call COM interfaces of 7-Zip.
+
+---
+
+http://www.7-zip.org
+http://www.7-zip.org/sdk.html
+http://www.7-zip.org/support.html
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/readme.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/readme.txt
new file mode 100644
index 000000000..f8706e4cb
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/readme.txt
@@ -0,0 +1,181 @@
+7-Zip 9.04 Sources
+------------------
+
+7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP/Vista.
+
+7-Zip Copyright (C) 1999-2009 Igor Pavlov.
+
+
+License Info
+------------
+
+7-Zip is free software distributed under the GNU LGPL
+(except for unRar code).
+read License.txt for more infomation about license.
+
+Notes about unRAR license:
+
+Please check main restriction from unRar license:
+
+ 2. The unRAR sources may be used in any software to handle RAR
+ archives without limitations free of charge, but cannot be used
+ to re-create the RAR compression algorithm, which is proprietary.
+ Distribution of modified unRAR sources in separate form or as a
+ part of other software is permitted, provided that it is clearly
+ stated in the documentation and source comments that the code may
+ not be used to develop a RAR (WinRAR) compatible archiver.
+
+In brief it means:
+1) You can compile and use compiled files under GNU LGPL rules, since
+ unRAR license almost has no restrictions for compiled files.
+ You can link these compiled files to LGPL programs.
+2) You can fix bugs in source code and use compiled fixed version.
+3) You can not use unRAR sources to re-create the RAR compression algorithm.
+
+
+LZMA SDK
+--------
+
+Also this package contains files from LZMA SDK
+you can download LZMA SDK from this page:
+http://www.7-zip.org/sdk.html
+read about addtional licenses for LZMA SDK in file
+DOC/lzma.txt
+
+
+How to compile
+--------------
+To compile sources you need Visual C++ 6.0.
+For compiling some files you also need
+new Platform SDK from Microsoft' Site:
+http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
+or
+http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm
+or
+http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
+
+If you use MSVC6, specify SDK directories at top of directories lists:
+Tools / Options / Directories
+ - Include files
+ - Library files
+
+
+To compile 7-Zip for AMD64 and IA64 you need:
+ Windows Server 2003 SP1 Platform SDK from microsoft.com
+
+Also you need Microsoft Macro Assembler:
+ - ml.exe for x86
+ - ml64.exe for AMD64
+You can use ml.exe from Windows SDK for Windows Vista or some other version.
+
+
+Compiling under Unix/Linux
+--------------------------
+Check this site for Posix/Linux version:
+http://sourceforge.net/projects/p7zip/
+
+
+Notes:
+------
+7-Zip consists of COM modules (DLL files).
+But 7-Zip doesn't use standard COM interfaces for creating objects.
+Look at
+7zip\UI\Client7z folder for example of using DLL files of 7-Zip.
+Some DLL files can use other DLL files from 7-Zip.
+If you don't like it, you must use standalone version of DLL.
+To compile standalone version of DLL you must include all used parts
+to project and define some defs.
+For example, 7zip\Bundles\Format7z is a standalone version of 7z.dll
+that works with 7z format. So you can use such DLL in your project
+without additional DLL files.
+
+
+Description of 7-Zip sources package
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+DOC Documentation
+---
+ 7zFormat.txt - 7z format description
+ copying.txt - GNU LGPL license
+ unRarLicense.txt - License for unRAR part of source code
+ history.txt - Sources history
+ Methods.txt - Compression method IDs
+ readme.txt - Readme file
+ lzma.txt - LZMA SDK description
+ 7zip.nsi - installer script for NSIS
+
+
+C - Source code in C
+CPP - Source code in CPP
+
+Common Common modules
+Windows Win32 wrappers
+
+7zip
+-------
+ Common Common modules for 7-zip
+
+ Archive 7-Zip Archive Format Plugins
+ --------
+ Common
+ 7z
+ Arj
+ BZip2
+ Cab
+ Cpio
+ GZip
+ Rar
+ Rpm
+ Split
+ Tar
+ Zip
+
+ Bundle Modules that are bundles of other modules
+ ------
+ Alone 7za.exe: Standalone version of 7z
+ Alone7z 7zr.exe: Standalone version of 7z that supports only 7z/LZMA/BCJ/BCJ2
+ SFXCon 7zCon.sfx: Console 7z SFX module
+ SFXWin 7z.sfx: Windows 7z SFX module
+ SFXSetup 7zS.sfx: Windows 7z SFX module for Installers
+ Format7z 7za.dll: .7z support
+ Format7zExtract 7zxa.dll: .7z support, extracting only
+ Format7zR 7zr.dll: .7z support, LZMA/BCJ* only
+ Format7zExtractR 7zxr.dll: .7z support, LZMA/BCJ* only, extracting only
+ Format7zF 7z.dll: all formats
+
+ UI
+ --
+ Agent Intermediary modules for FAR plugin and Explorer plugin
+ Console 7z.exe Console version
+ Explorer Explorer plugin
+ Resource Resources
+ Far FAR plugin
+ Client7z Test application for 7za.dll
+
+ Compress
+ --------
+ BZip2 BZip2 compressor
+ Branch Branch converter
+ ByteSwap Byte Swap converter
+ Copy Copy coder
+ Deflate
+ Implode
+ Arj
+ LZMA
+ PPMd Dmitry Shkarin's PPMdH with small changes.
+ LZ Lempel - Ziv
+
+ Crypto Crypto modules
+ ------
+ 7zAES Cipher for 7z
+ AES AES Cipher
+ Rar20 Cipher for Rar 2.0
+ RarAES Cipher for Rar 3.0
+ Zip Cipher for Zip
+
+ FileManager File Manager
+
+
+---
+Igor Pavlov
+http://www.7-zip.org
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/unRarLicense.txt b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/unRarLicense.txt
new file mode 100644
index 000000000..5f78b728d
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/DOCS/unRarLicense.txt
@@ -0,0 +1,41 @@
+ ****** ***** ****** unRAR - free utility for RAR archives
+ ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ****** ******* ****** License for use and distribution of
+ ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ** ** ** ** ** ** FREE portable version
+ ~~~~~~~~~~~~~~~~~~~~~
+
+ The source code of unRAR utility is freeware. This means:
+
+ 1. All copyrights to RAR and the utility unRAR are exclusively
+ owned by the author - Alexander Roshal.
+
+ 2. The unRAR sources may be used in any software to handle RAR
+ archives without limitations free of charge, but cannot be used
+ to re-create the RAR compression algorithm, which is proprietary.
+ Distribution of modified unRAR sources in separate form or as a
+ part of other software is permitted, provided that it is clearly
+ stated in the documentation and source comments that the code may
+ not be used to develop a RAR (WinRAR) compatible archiver.
+
+ 3. The unRAR utility may be freely distributed. No person or company
+ may charge a fee for the distribution of unRAR without written
+ permission from the copyright holder.
+
+ 4. THE RAR ARCHIVER AND THE UNRAR UTILITY ARE DISTRIBUTED "AS IS".
+ NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. YOU USE AT
+ YOUR OWN RISK. THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS,
+ DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING
+ OR MISUSING THIS SOFTWARE.
+
+ 5. Installing and using the unRAR utility signifies acceptance of
+ these terms and conditions of the license.
+
+ 6. If you don't agree with terms of the license you must remove
+ unRAR files from your storage devices and cease to use the
+ utility.
+
+ Thank you for your interest in RAR and unRAR.
+
+
+ Alexander L. Roshal \ No newline at end of file
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/README b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/README
new file mode 100644
index 000000000..3a3b01e09
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/README
@@ -0,0 +1,263 @@
+ p7zip 9.04
+ ==========
+
+Homepage : http://p7zip.sourceforge.net/
+
+p7zip is a port of the Windows programs 7z.exe and 7za.exe provided by 7-zip.
+
+7-zip is a file archiver with the highest compression ratio.
+Homepage : www.7-zip.org
+
+ 7z uses plugins (7z.so and Codecs/Rar29.so) to handle archives.
+ 7za is a stand-alone executable.
+ 7za handles less archive formats than 7z.exe.
+ 7zr is a light stand-alone executable that supports only 7z/LZMA/BCJ/BCJ2.
+
+NEW:
+ 7zG : see GUI/readme.txt
+
+CAUTION :
+---------
+
+- FIRST : DO NOT USE the 7-zip format for backup purpose on Linux/Unix because :
+ - 7-zip does not store the owner/group of the file
+
+ On Linux/Unix, in order to backup directories you must use tar !
+ to backup a directory : tar cf - directory | 7za a -si directory.tar.7z
+ to restore your backup : 7za x -so directory.tar.7z | tar xf -
+
+- if you want to send files and directories (not the owner of file)
+ to others Unix/MacOS/Windows users, you can use the 7-zip format.
+
+ example : 7za a directory.7z directory
+
+ do not use "-r" because this flag does not do what you think
+ do not use directory/* because of ".*" files
+ (example : "directory/*" does not match "directory/.profile")
+
+
+BUILD :
+-------
+
+ If you have downloaded the "bin" package,
+ use directly the program bin/7za.
+ (tested on Redhat 9.0, Fedora 2, Mandrake 10.0, Debian 3.0)
+ As the program is statically linked, its should run on many x86 linux.
+
+ If you have downloaded the "source" package,
+
+ According to your OS, copy makefile.linux,
+ makefile.freebsd, makefile.cygwin, ...
+ over makefile.machine
+
+ If you want to make a parallel build : make -j4 -f makefile.parallel_jobs TARGET
+
+ make clean : to clean all directories
+ make : to build bin/7za
+ make sfx : to build bin/7zCon.sfx (7za can now create SFX archive)
+ make 7z : to build bin/7z and its plugins :
+ - "bin/7z.so" (GNU LGPL + AES code license)
+ - "bin/Codecs/Rar29.so" (GNU LGPL + unRAR restriction)
+ make 7zr : to build bin/7zr
+ make all : to build bin/7za and bin/7zCon.sfx
+ make all2 : to build bin/7za, bin/7z (with its plugins) and bin/7zCon.sfx
+ make all3 : to build bin/7za, bin/7z (with its plugins), bin/7zr and bin/7zCon.sfx
+ make test : to test bin/7za (extracting, archiving, password ...)
+ make test_7z : to test bin/7z (extracting, archiving, password ...)
+ make test_7zr : to test bin/7zr (extracting, archiving, ...)
+
+ make 7zG : to build bin/7zG and its plugins :
+ - "bin/7z.so" (GNU LGPL + AES code license)
+ - "bin/Codecs/Rar29.so" (GNU LGPL + unRAR restriction)
+ make test_7zG : to test bin/7zG (extracting, archiving, ...)
+
+
+ this procedure has been tested on :
+ - x86 CPU :
+ DOS - (built with DJGPP, see http://blairdude.googlepages.com/p7zip )
+ Linux - Redhat 9.0 Standart
+ Linux - Fedora 2 (Redhat) (gcc 3.3.3 and gcc-3.4.1 with
+ stack-smashing protector from www.trl.ibm.com/projects/security/ssp/)
+ Linux - Mandrake 10.0 Official
+ Linux - Debian 3.0 Stable
+ Linux - Ubuntu 8.04
+ FreeBSD 5.2.1 (gcc 3.3.3)
+ MacOS 10.4.8
+ NetBSD
+ CYGWIN_NT-5.1 1.5.9(0.112/4/2) 2004-03-18 23:05 i686 Cygwin
+ Solaris 9 (x86) with gcc 3.3.2
+ Solaris 10 (x86)
+
+ - alpha CPU :
+ Linux - Debian 3.0 (alpha) with gcc 2.95.4
+
+ - AMD64 CPU :
+ Linux - SuSE 8 ES (AMD64 Opteron) with gcc 3.2.2
+ Linux - Fedora 4 (AMD64 Turion) with gcc 4.0.1
+ Linux - Ubuntu 8.10
+
+ - Itanium CPU :
+ HP-UX B.11.31 U ia64 with aCC (HP C/aC++ B3910B A.06.14 [Feb 22 2007])
+
+ - s390x CPU :
+ Linux - SUSE Enterprise Linux 10 - with gcc 4.1.2
+ ( only the 32bits built works, the 64bits built does not pass the tests )
+
+ - sparc CPU :
+ Solaris 8 (sparc) with gcc 2.95.2
+ Solaris 9 (sparc) with gcc 3.3.2
+
+ - powerpc CPU :
+ MacOS X 10.1/darwin 5.5 with gcc 932.1 (gcc 2.95.2)
+ MacOS X 10.3 with XCode 1.5
+
+ - openpower CPU :
+ Linux openpower-linux1 2.6.5-7.97-pseries64 (ppc64) with gcc 3.3.3
+
+ - IBM :
+ AIX 5.3 with gcc 4.1.0
+
+ - Tru64 :
+ OSF 5.1 with gcc 3.4.2
+
+ - PA-RISC :
+ HP-UX 11.11 with aCC (HP ANSI C++ B3910B A.03.73)
+ HP-UX 11.11 with gcc 3.4.2 (7za and 7zr : OK, 7z : failed because of a buggy gcc for HP-UX,
+ plugins don't work because C++ constructors are not called !)
+
+
+BUILD with cmake
+----------------
+ You can only build 7za.
+
+ cd CPP/7zip/CMAKE
+
+ edit generate.sh to choose your target
+
+ ./generate.sh
+
+ the cmake project for the target is in "CPP/7zip/CMAKE/Alone".
+
+ For the target "Unix Makefiles", use "make" to compile
+
+ For others target, use the IDE (CodeBlocks, KDevelop3, Eclipse CDT4)
+
+INSTALL :
+---------
+
+ method 1
+ --------
+ - edit install.sh to change DEST_HOME
+ - ./install.sh : to install
+ Remark : you must be "root" to install 7za in the directory "/usr/local"
+
+ method 2
+ --------
+ - 7za is a stand-alone program, you can put this program where you want.
+ example : cp bin/7za /usr/local/bin/7za
+
+ - 7z needs its plugins. You must copy the file 7z, 7z.so
+ and the directory Codecs in the same destination directory.
+
+ - if you want to be able to create SFX archive, copy bin/7zCon.sfx
+ to the directory where 7za or 7z can be found.
+
+
+USAGE:
+------
+ Remark : you can replace 7za with 7z.
+
+ 7za t archive.7z : tests files in the archive archive.7z
+ 7za l archive.7z : lists all files from archive archive.7z
+ 7za x archive.7z : extracts all files from archive archive.7z
+ to the current directory
+
+ 7za a archive.7z file1 fileN : add files to the archive archive.7z
+
+ 7za a archive.7z dir1 : add all files and subdirectories from directory "dir1" to archive archive.7z
+
+ CAUTION : do not use the flag "-r" unless you know what you are doing ...
+
+ 7za a -sfx archive.exe dir1 : add all files from directory "dir1" to SFX archive archive.exe
+ (Remark : SFX archive MUST end with ".exe")
+
+ You can also add or extract files to/from .zip or .tar archives.
+ You can also compress/uncompress .gz or .bz2 files.
+
+ 7za a -tzip archive.zip file file2 file3
+ 7za a -ttar archive.tar file
+ 7za a -tgzip file.gz file
+ 7za a -tbzip2 archive.bz2 file
+
+ You can use password for archives:
+ 7za a -pmy_password archive.7z dir1
+
+ For .7z archive only, you can enable archive header encryption with "-mhe"
+ 7za a -mhe=on -pmy_password archive.7z dir1
+
+ For more, see the documentation of 7za.exe in DOCS/MANUAL directory
+ 7za a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1
+ adds all files from directory "dir1" to archive archive.7z
+ using "ultra settings".
+ -t7z : 7z archive
+ -m0=lzma : lzma method
+ -mx=9 : level of compression = 9 (Ultra)
+ -mfb=64 : number of fast bytes for LZMA = 64
+ -md=32m : dictionary size = 32 megabytes
+ -ms=on : solid archive = on
+
+ To use the new codec "lzma2"
+ 7za a -m0=lzma2 archive.7z directory
+
+
+BENCHMARKS :
+------------
+ 7za b : bench LZMA codec
+ 7z b -mm=crc : make internal crc check.
+
+LICENSE :
+---------
+ please read DOCS/License.txt.
+
+LIMITATIONS from 7-zip :
+------------------------
+
+ - does not support uid/gid for the .tar format (so, use tar on Unix)
+
+LIMITATIONS for Unix version only :
+-----------------------------------
+
+ - can handle properly UNICODE filenames only if the environment is UTF-8.
+ Example : export LANG=en_US.UTF-8 ; unset LC_CTYPE
+ Remark : see the possible values for LANG in the directory
+ - /usr/lib/locale : Fedora 2 / Solaris 8
+ - /usr/share/locale : OpenBSD / Debian / FreeBSD / MacOS X / Mandrake 10.1 / NetBSD
+
+ On Linux, to display the available locales : locale -a
+
+ p7zip relies on LC_CTYPE and then on LANG to convert name to/from UNICODE.
+ the command "locale" should display these environment variables.
+ you can also do "echo $LC_CTYPE" and "echo $LANG".
+
+ If you do not plan to export your archive, you can use the flag "-no-utf16".
+ Usage :
+ 7za a -no-utf16 archive.7z dirOrFile1 ... dirOrFileN
+ 7za t -no-utf16 archive.7z
+ 7za l -no-utf16 archive.7z
+ 7za x -no-utf16 archive.7z
+
+ - ignores Windows file access permissions (files are created with default permissions)
+
+ see also TODO file.
+
+DEVELOPPER CORNER:
+------------------
+
+ - WaitForMultipleObject has no equivalence on Unix.
+ - Events don't exist.
+ - sizeof(wchar_t) = 4 with GCC (2 with MS VC++)
+ - "FIXME" in source code indicates that you should add codes to better handle all cases.
+
+ - "FIXED" in source code indicates that the original code has been changed to work in Unix environment.
+
+ see also TODO file.
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/TODO b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/TODO
new file mode 100644
index 000000000..e2cb708de
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/TODO
@@ -0,0 +1,30 @@
+
+7za/7z
+======
+- auto-generate config.h (use a configure script ...)
+
+- suppress all exit(EXIT_FAILURE), FIXME, ...
+
+- no chmod for TAR (should restore the rights set)
+
+- no chown(uid,gid) for TAR
+
+- Use a more portable "String.h"
+
+- UTF16 : try to test with Complex Unicode filenames
+
+- KNOWN BUGS
+
+ - date (format arj/rar/chm) ?
+
+ - absolute path ?
+
+- zip format : better support of symbolic links
+
+7zG / p7zipForFilemanager
+==========================
+
+- better help displaying
+
+- better support for space in filenames
+
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/unix.pri b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/unix.pri
new file mode 100644
index 000000000..a31eab3dc
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/unix.pri
@@ -0,0 +1,217 @@
+DEFINES += FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE NDEBUG _REENTRANT COMPRESS_MT COMPRESS_BZIP2_MT COMPRESS_MF_MT BREAK_HANDLER BENCH_MT
+
+unix:DEFINES += ENV_UNIX
+#macx:DEFINES += _LZMA_UINT32_IS_ULONG
+win32:DEFINES += _UNICODE _CRT_SECURE_NO_WARNINGS
+
+INCLUDEPATH += $$P7ZIP_BASE/ $$P7ZIP_BASE/unix/CPP $$P7ZIP_BASE/unix/CPP/myWindows
+unix:INCLUDEPATH += $$P7ZIP_BASE/unix/CPP/include_windows
+
+SOURCES += $$P7ZIP_BASE/lib7z_facade.cpp
+HEADERS += $$P7ZIP_BASE/lib7z_facade.h
+
+unix:SOURCES += $$P7ZIP_BASE/unix/CPP/myWindows/myGetTickCount.cpp \
+ $$P7ZIP_BASE/unix/CPP/myWindows/wine_date_and_time.cpp \
+ $$P7ZIP_BASE/unix/CPP/myWindows/myAddExeFlag.cpp \
+ $$P7ZIP_BASE/unix/CPP/myWindows/mySplitCommandLine.cpp \
+
+win32:SOURCES += $$P7ZIP_BASE/unix/C/Alloc.c
+
+win32:LIBS += -loleaut32 -luser32
+
+SOURCES += \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Console/ConsoleClose.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Console/List.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Console/OpenCallbackConsole.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Console/PercentPrinter.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Console/UserInputUtils.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/CommandLineParser.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/CRC.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/IntToString.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/ListFileUtils.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/StdInStream.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/StdOutStream.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/MyString.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/StringToInt.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/UTFConvert.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/StringConvert.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/MyWindows.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/MyVector.cpp \
+$$P7ZIP_BASE/unix/CPP/Common/Wildcard.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/Error.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/FileDir.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/FileFind.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/FileIO.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/FileName.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/PropVariant.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/PropVariantConversions.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/Synchronization.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/System.cpp \
+$$P7ZIP_BASE/unix/CPP/Windows/Time.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/CreateCoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/CWrappers.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/FilePathAutoRename.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/FileStreams.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/FilterCoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/InBuffer.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/InOutTempBuffer.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/LimitedStreams.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/LockedStream.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/MemBlocks.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/MethodId.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/MethodProps.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/OffsetStream.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/OutBuffer.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/OutMemStream.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/ProgressMt.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/ProgressUtils.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/StreamBinder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/StreamObjects.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/StreamUtils.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Common/VirtThread.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/ArchiveCommandLine.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/DefaultName.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/EnumDirItems.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/Extract.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/ExtractingFilePath.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/LoadCodecs.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/OpenArchive.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/PropIDUtils.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/SetProperties.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/SortUtils.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/TempFiles.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/Update.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/UpdateAction.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/UpdateCallback.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/UpdatePair.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/UI/Common/UpdateProduce.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Bz2Handler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/GzHandler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/LzmaHandler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/SplitHandler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/XzHandler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/ZHandler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/CoderMixer2.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/CoderMixer2MT.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/CrossThreadProgress.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/DummyOutStream.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/FindSignature.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/HandlerOut.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/InStreamWithCRC.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/ItemNameUtils.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/MultiStream.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Common/ParseProperties.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zCompressionMode.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zDecode.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zEncode.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zExtract.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zFolderInStream.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zFolderOutStream.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zHandler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zHandlerOut.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zHeader.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zIn.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zOut.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zProperties.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zSpecStream.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zUpdate.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Cab/CabBlockInStream.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Cab/CabHandler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Cab/CabHeader.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Cab/CabIn.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Tar/TarHandler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Tar/TarHandlerOut.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Tar/TarHeader.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Tar/TarIn.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Tar/TarOut.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Tar/TarUpdate.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Zip/ZipAddCommon.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Zip/ZipHandler.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Zip/ZipHeader.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Zip/ZipIn.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Zip/ZipItem.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Zip/ZipOut.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Zip/ZipUpdate.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BcjCoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/Bcj2Coder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BitlDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BranchCoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BranchMisc.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/ByteSwap.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BZip2Crc.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BZip2Decoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BZip2Encoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/CopyCoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/DeflateDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/DeflateEncoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/DeltaFilter.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/ImplodeDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/Lzma2Decoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/Lzma2Encoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/LzmaDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/LzmaEncoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/LzOutWindow.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/Lzx86Converter.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/LzxDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/PpmdDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/PpmdEncoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/QuantumDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/ShrinkDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/ZDecoder.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/7zAes.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/HmacSha1.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/MyAes.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/RandGen.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/Sha1.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/WzAes.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/ZipCrypto.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/ZipStrong.cpp \
+$$P7ZIP_BASE/unix/C/7zStream.c \
+$$P7ZIP_BASE/unix/C/Aes.c \
+$$P7ZIP_BASE/unix/C/Bra.c \
+$$P7ZIP_BASE/unix/C/Bra86.c \
+$$P7ZIP_BASE/unix/C/BraIA64.c \
+$$P7ZIP_BASE/unix/C/BwtSort.c \
+$$P7ZIP_BASE/unix/C/Delta.c \
+$$P7ZIP_BASE/unix/C/HuffEnc.c \
+$$P7ZIP_BASE/unix/C/LzFind.c \
+$$P7ZIP_BASE/unix/C/LzFindMt.c \
+$$P7ZIP_BASE/unix/C/Lzma2Dec.c \
+$$P7ZIP_BASE/unix/C/Lzma2Enc.c \
+$$P7ZIP_BASE/unix/C/LzmaDec.c \
+$$P7ZIP_BASE/unix/C/LzmaEnc.c \
+$$P7ZIP_BASE/unix/C/MtCoder.c \
+$$P7ZIP_BASE/unix/C/Sha256.c \
+$$P7ZIP_BASE/unix/C/Sort.c \
+$$P7ZIP_BASE/unix/C/Threads.c \
+$$P7ZIP_BASE/unix/C/Xz.c \
+$$P7ZIP_BASE/unix/C/XzCrc64.c \
+$$P7ZIP_BASE/unix/C/XzDec.c \
+$$P7ZIP_BASE/unix/C/XzEnc.c \
+$$P7ZIP_BASE/unix/C/XzIn.c \
+$$P7ZIP_BASE/unix/C/7zCrc.c \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/7z/7zRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Cab/CabRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Tar/TarRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Archive/Zip/ZipRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/Bcj2Register.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BcjRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BranchRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/BZip2Register.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/CopyRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/Deflate64Register.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/DeflateRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/Lzma2Register.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/LzmaRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Compress/PpmdRegister.cpp \
+$$P7ZIP_BASE/unix/CPP/7zip/Crypto/7zAesRegister.cpp
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/unix.pro b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/unix.pro
new file mode 100644
index 000000000..c908e11ed
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/unix.pro
@@ -0,0 +1,232 @@
+pk7zip_library {
+ TEMPLATE = lib
+ CONFIG += static staticlib
+ DESTDIR=../lib
+ SOURCES += ../lib7z_facade.cpp
+} else {
+ TEMPLATE = app
+}
+
+TARGET = 7za
+
+QT -= gui
+CONFIG += console
+
+DEFINES += FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE NDEBUG _REENTRANT COMPRESS_BZIP2_MT COMPRESS_MT COMPRESS_MF_MT BREAK_HANDLER BENCH_MT
+
+unix:DEFINES += ENV_UNIX
+win32:DEFINES += _UNICODE _CRT_SECURE_NO_WARNINGS
+
+INCLUDEPATH += .. CPP CPP/myWindows
+unix:INCLUDEPATH += CPP/include_windows
+
+unix:SOURCES += CPP/myWindows/myGetTickCount.cpp \
+ CPP/myWindows/wine_date_and_time.cpp \
+ CPP/myWindows/myAddExeFlag.cpp \
+ CPP/myWindows/mySplitCommandLine.cpp \
+
+ win32:SOURCES += C/Alloc.c
+
+
+SOURCES += \
+ CPP/7zip/UI/Console/ConsoleClose.cpp \
+ CPP/7zip/UI/Console/ExtractCallbackConsole.cpp \
+ CPP/7zip/UI/Console/List.cpp \
+ CPP/7zip/UI/Console/Main.cpp \
+ CPP/7zip/UI/Console/MainAr.cpp \
+ CPP/7zip/UI/Console/OpenCallbackConsole.cpp \
+ CPP/7zip/UI/Console/PercentPrinter.cpp \
+ CPP/7zip/UI/Console/UpdateCallbackConsole.cpp \
+ CPP/7zip/UI/Console/UserInputUtils.cpp \
+ CPP/Common/CommandLineParser.cpp \
+ CPP/Common/CRC.cpp \
+ CPP/Common/IntToString.cpp \
+ CPP/Common/ListFileUtils.cpp \
+ CPP/Common/StdInStream.cpp \
+ CPP/Common/StdOutStream.cpp \
+ CPP/Common/MyString.cpp \
+ CPP/Common/StringToInt.cpp \
+ CPP/Common/UTFConvert.cpp \
+ CPP/Common/StringConvert.cpp \
+ CPP/Common/MyWindows.cpp \
+ CPP/Common/MyVector.cpp \
+ CPP/Common/Wildcard.cpp \
+ CPP/Windows/Error.cpp \
+ CPP/Windows/FileDir.cpp \
+ CPP/Windows/FileFind.cpp \
+ CPP/Windows/FileIO.cpp \
+ CPP/Windows/FileName.cpp \
+ CPP/Windows/PropVariant.cpp \
+ CPP/Windows/PropVariantConversions.cpp \
+ CPP/Windows/Synchronization.cpp \
+ CPP/Windows/System.cpp \
+ CPP/Windows/Time.cpp \
+ CPP/7zip/Common/CreateCoder.cpp \
+ CPP/7zip/Common/CWrappers.cpp \
+ CPP/7zip/Common/FilePathAutoRename.cpp \
+ CPP/7zip/Common/FileStreams.cpp \
+ CPP/7zip/Common/FilterCoder.cpp \
+ CPP/7zip/Common/InBuffer.cpp \
+ CPP/7zip/Common/InOutTempBuffer.cpp \
+ CPP/7zip/Common/LimitedStreams.cpp \
+ CPP/7zip/Common/LockedStream.cpp \
+ CPP/7zip/Common/MemBlocks.cpp \
+ CPP/7zip/Common/MethodId.cpp \
+ CPP/7zip/Common/MethodProps.cpp \
+ CPP/7zip/Common/OffsetStream.cpp \
+ CPP/7zip/Common/OutBuffer.cpp \
+ CPP/7zip/Common/OutMemStream.cpp \
+ CPP/7zip/Common/ProgressMt.cpp \
+ CPP/7zip/Common/ProgressUtils.cpp \
+ CPP/7zip/Common/StreamBinder.cpp \
+ CPP/7zip/Common/StreamObjects.cpp \
+ CPP/7zip/Common/StreamUtils.cpp \
+ CPP/7zip/Common/VirtThread.cpp \
+ CPP/7zip/UI/Common/ArchiveCommandLine.cpp \
+ CPP/7zip/UI/Common/ArchiveExtractCallback.cpp \
+ CPP/7zip/UI/Common/ArchiveOpenCallback.cpp \
+ CPP/7zip/UI/Common/DefaultName.cpp \
+ CPP/7zip/UI/Common/EnumDirItems.cpp \
+ CPP/7zip/UI/Common/Extract.cpp \
+ CPP/7zip/UI/Common/ExtractingFilePath.cpp \
+ CPP/7zip/UI/Common/LoadCodecs.cpp \
+ CPP/7zip/UI/Common/OpenArchive.cpp \
+ CPP/7zip/UI/Common/PropIDUtils.cpp \
+ CPP/7zip/UI/Common/SetProperties.cpp \
+ CPP/7zip/UI/Common/SortUtils.cpp \
+ CPP/7zip/UI/Common/TempFiles.cpp \
+ CPP/7zip/UI/Common/Update.cpp \
+ CPP/7zip/UI/Common/UpdateAction.cpp \
+ CPP/7zip/UI/Common/UpdateCallback.cpp \
+ CPP/7zip/UI/Common/UpdatePair.cpp \
+ CPP/7zip/UI/Common/UpdateProduce.cpp \
+ CPP/7zip/Archive/Bz2Handler.cpp \
+ CPP/7zip/Archive/GzHandler.cpp \
+ CPP/7zip/Archive/LzmaHandler.cpp \
+ CPP/7zip/Archive/SplitHandler.cpp \
+ CPP/7zip/Archive/XzHandler.cpp \
+ CPP/7zip/Archive/ZHandler.cpp \
+ CPP/7zip/Archive/Common/CoderMixer2.cpp \
+ CPP/7zip/Archive/Common/CoderMixer2MT.cpp \
+ CPP/7zip/Archive/Common/CrossThreadProgress.cpp \
+ CPP/7zip/Archive/Common/DummyOutStream.cpp \
+ CPP/7zip/Archive/Common/FindSignature.cpp \
+ CPP/7zip/Archive/Common/HandlerOut.cpp \
+ CPP/7zip/Archive/Common/InStreamWithCRC.cpp \
+ CPP/7zip/Archive/Common/ItemNameUtils.cpp \
+ CPP/7zip/Archive/Common/MultiStream.cpp \
+ CPP/7zip/Archive/Common/OutStreamWithCRC.cpp \
+ CPP/7zip/Archive/Common/ParseProperties.cpp \
+ CPP/7zip/Archive/7z/7zCompressionMode.cpp \
+ CPP/7zip/Archive/7z/7zDecode.cpp \
+ CPP/7zip/Archive/7z/7zEncode.cpp \
+ CPP/7zip/Archive/7z/7zExtract.cpp \
+ CPP/7zip/Archive/7z/7zFolderInStream.cpp \
+ CPP/7zip/Archive/7z/7zFolderOutStream.cpp \
+ CPP/7zip/Archive/7z/7zHandler.cpp \
+ CPP/7zip/Archive/7z/7zHandlerOut.cpp \
+ CPP/7zip/Archive/7z/7zHeader.cpp \
+ CPP/7zip/Archive/7z/7zIn.cpp \
+ CPP/7zip/Archive/7z/7zOut.cpp \
+ CPP/7zip/Archive/7z/7zProperties.cpp \
+ CPP/7zip/Archive/7z/7zSpecStream.cpp \
+ CPP/7zip/Archive/7z/7zUpdate.cpp \
+ CPP/7zip/Archive/Cab/CabBlockInStream.cpp \
+ CPP/7zip/Archive/Cab/CabHandler.cpp \
+ CPP/7zip/Archive/Cab/CabHeader.cpp \
+ CPP/7zip/Archive/Cab/CabIn.cpp \
+ CPP/7zip/Archive/Tar/TarHandler.cpp \
+ CPP/7zip/Archive/Tar/TarHandlerOut.cpp \
+ CPP/7zip/Archive/Tar/TarHeader.cpp \
+ CPP/7zip/Archive/Tar/TarIn.cpp \
+ CPP/7zip/Archive/Tar/TarOut.cpp \
+ CPP/7zip/Archive/Tar/TarUpdate.cpp \
+ CPP/7zip/Archive/Zip/ZipAddCommon.cpp \
+ CPP/7zip/Archive/Zip/ZipHandler.cpp \
+ CPP/7zip/Archive/Zip/ZipHandlerOut.cpp \
+ CPP/7zip/Archive/Zip/ZipHeader.cpp \
+ CPP/7zip/Archive/Zip/ZipIn.cpp \
+ CPP/7zip/Archive/Zip/ZipItem.cpp \
+ CPP/7zip/Archive/Zip/ZipOut.cpp \
+ CPP/7zip/Archive/Zip/ZipUpdate.cpp \
+ CPP/7zip/Compress/Bcj2Coder.cpp \
+ CPP/7zip/Compress/BitlDecoder.cpp \
+ CPP/7zip/Compress/BranchCoder.cpp \
+ CPP/7zip/Compress/BranchMisc.cpp \
+ CPP/7zip/Compress/ByteSwap.cpp \
+ CPP/7zip/Compress/BZip2Crc.cpp \
+ CPP/7zip/Compress/BZip2Decoder.cpp \
+ CPP/7zip/Compress/BZip2Encoder.cpp \
+ CPP/7zip/Compress/CopyCoder.cpp \
+ CPP/7zip/Compress/DeflateDecoder.cpp \
+ CPP/7zip/Compress/DeflateEncoder.cpp \
+ CPP/7zip/Compress/DeltaFilter.cpp \
+ CPP/7zip/Compress/ImplodeDecoder.cpp \
+ CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp \
+ CPP/7zip/Compress/Lzma2Decoder.cpp \
+ CPP/7zip/Compress/Lzma2Encoder.cpp \
+ CPP/7zip/Compress/LzmaDecoder.cpp \
+ CPP/7zip/Compress/LzmaEncoder.cpp \
+ CPP/7zip/Compress/LzOutWindow.cpp \
+ CPP/7zip/Compress/Lzx86Converter.cpp \
+ CPP/7zip/Compress/LzxDecoder.cpp \
+ CPP/7zip/Compress/PpmdDecoder.cpp \
+ CPP/7zip/Compress/PpmdEncoder.cpp \
+ CPP/7zip/Compress/QuantumDecoder.cpp \
+ CPP/7zip/Compress/ShrinkDecoder.cpp \
+ CPP/7zip/Compress/ZDecoder.cpp \
+ CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp \
+ CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp \
+ CPP/7zip/Crypto/7zAes.cpp \
+ CPP/7zip/Crypto/HmacSha1.cpp \
+ CPP/7zip/Crypto/MyAes.cpp \
+ CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp \
+ CPP/7zip/Crypto/RandGen.cpp \
+ CPP/7zip/Crypto/Sha1.cpp \
+ CPP/7zip/Crypto/WzAes.cpp \
+ CPP/7zip/Crypto/ZipCrypto.cpp \
+ CPP/7zip/Crypto/ZipStrong.cpp \
+ C/7zStream.c \
+ C/Aes.c \
+ C/Bra.c \
+ C/Bra86.c \
+ C/BraIA64.c \
+ C/BwtSort.c \
+ C/Delta.c \
+ C/HuffEnc.c \
+ C/LzFind.c \
+ C/LzFindMt.c \
+ C/Lzma2Dec.c \
+ C/Lzma2Enc.c \
+ C/LzmaDec.c \
+ C/LzmaEnc.c \
+ C/MtCoder.c \
+ C/Sha256.c \
+ C/Sort.c \
+ C/Threads.c \
+ C/Xz.c \
+ C/XzCrc64.c \
+ C/XzDec.c \
+ C/XzEnc.c \
+ C/XzIn.c \
+ C/7zCrc.c \
+
+!pk7zip_library {
+SOURCES += CPP/7zip/Archive/7z/7zRegister.cpp \
+ CPP/7zip/Archive/Cab/CabRegister.cpp \
+ CPP/7zip/Archive/Tar/TarRegister.cpp \
+ CPP/7zip/Archive/Zip/ZipRegister.cpp \
+ CPP/7zip/Compress/Bcj2Register.cpp \
+ #CPP/7zip/Compress/BcjRegister.cpp \
+ CPP/7zip/Compress/BranchRegister.cpp \
+ CPP/7zip/Compress/BZip2Register.cpp \
+ CPP/7zip/Compress/CopyRegister.cpp \
+ CPP/7zip/Compress/Deflate64Register.cpp \
+ CPP/7zip/Compress/DeflateRegister.cpp \
+ CPP/7zip/Compress/Lzma2Register.cpp \
+ CPP/7zip/Compress/LzmaRegister.cpp \
+ CPP/7zip/Compress/PpmdRegister.cpp \
+ CPP/7zip/Crypto/7zAesRegister.cpp
+
+ win32:LIBS += ole32.lib oleaut32.lib user32.lib
+}
diff --git a/installerbuilder/libinstaller/NQSDevAgreement.txt b/installerbuilder/libinstaller/NQSDevAgreement.txt
new file mode 100644
index 000000000..27a865f7d
--- /dev/null
+++ b/installerbuilder/libinstaller/NQSDevAgreement.txt
@@ -0,0 +1,204 @@
+
+
+NOKIA CORPORATION DEVELOPER SOFTWARE AGREEMENT
+Version 1.0
+
+This Nokia Corporation Developer Software Agreement ("Agreement") is between You (either an individual or an entity), the developer, and Nokia Corporation ("Nokia"). The Agreement authorizes You to use the Software specified in Clause 1 below, which may be stored on a CD-ROM, sent to You by electronic mail, or downloaded from Nokia's web pages or servers or from other sources under the terms and conditions set forth below.
+
+This is an agreement on end-user rights and not an agreement for sale. Nokia continues to own the copy of the Software and the physical media contained in the sales package and any other copy that You are authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before accessing, downloading, installing or using the Software or any part of it. By accessing, downloading, installing or using the Software, You agree to the terms and conditions of this Agreement. If You do not agree to all of the terms and conditions of this Agreement, promptly cancel the installation or downloading, or destroy or return the Software and accompanying documentation to Nokia.
+
+1. SOFTWARE
+
+As used in this Agreement, the term "Software" means, collectively: (i) the Qt SDK software product with the exception of Open Source Software (as defined below), (ii) all the contents of the disk(s), CD-ROM(s), electronic mail and its file attachments, or other media with which this Agreement is provided, including the object code form of the software delivered via a CD-ROM, electronic mail, or web page (iii) related explanatory written materials and any other possible documentation related thereto ("Documentation"); (v) fonts, and (vi) upgrades, modified versions, updates, additions, and copies of the Software (collectively "Updates"), if any, provided to You by Nokia under this Agreement.
+
+"Open Source Software" means any software, which is, as included in the Qt SDK, subject to a license terms and conditions currently listed at http://opensource.org/licenses/ or meeting the criteria listed at http://www.opensource.org/docs/definition.php or which is subject to any similar free or open source license terms. Open Source Software contained in the Qt SDK is licensed under the license terms accompanying such Open Source Software and not the terms of this Agreement.
+
+2. USE OF THE SOFTWARE
+
+The Software is made accessible to You for the sole purpose of developing and testing Applications by installing a reasonable number of copies of the Software on computers owned or controlled by You to be used by You or Your authorized users. "Application" means one or more software programs developed by or for You in compliance with the Documentation, including any bug fixes, updates, upgrades, modifications, enhancements, supplements to, revisions, new releases and new versions of such software programs.
+
+You acknowledge that the use of the Software may require licenses to third party patents and that Nokia does not grant any licenses to such third party patents under this Agreement to the You. Also, any and all standards related licenses with respect to Essential Patents (as defined below) are specifically excluded from the scope of this Agreement, and those licenses need to be acquired separately from Nokia or the respective right holders, as the case may be. "Essential Patent" means any patent claiming a feature necessarily and unavoidably required for compliance with industry standards (usually GSM, WCDMA or other similar mobile communications standard), to the limited extent only that infringement or use of such claims of a patent cannot be avoided in remaining compliant with industry standard either for technological reasons or for lack of commercially viable technical alternatives.
+
+No patent licenses to any patents of Nokia and/ or its Affiliates are granted under this Agreement.
+
+3. LIMITATIONS ON END USER RIGHTS
+
+You may not copy, distribute, or make derivative works of the Software except as follows:
+
+(a) You may not use, modify, translate, reproduce, or transfer the right to use the Software or copy the Software except as expressly provided in this Agreement.
+
+(b) You may not resell, sublicense, rent, lease, or lend the Software.
+
+(c) You may not reverse engineer, reverse compile, disassemble, or otherwise attempt to discover the source code of the Software (except to the extent that this restriction is expressly prohibited by law) or create derivative works based on the Software.
+
+(d) You agree that You shall only use the Software in a manner that complies with all applicable laws in the jurisdiction in which You use the Software, including, but not limited to, applicable restrictions concerning copyright and other intellectual property rights.
+
+4. INTELLECTUAL PROPERTY RIGHTS
+
+The Software and all rights, without limitation including title and intellectual property rights therein, are owned by Nokia and/or its licensors and affiliates and are protected by international treaty provisions and all other applicable national laws of the country in which it is being used. The structure, organization, and code of the Software are the valuable trade secrets and confidential information of Nokia and/or its licensors and affiliates. You must not copy the Software, except as set forth in clause 3 (Limitations On End-User Rights). Any copies which You are permitted to make pursuant to this Agreement must contain the same copyright and other proprietary notices that appear on the Software.
+
+5. FEEDBACK
+
+By submitting feedback ("Feedback") to Nokia related to the Software, including but not limited to information on bug fixes or error corrections, you acknowledge and agree that (1) Nokia may have similar development ideas to the Feedback; (2) your Feedback does not contain confidential or proprietary information related to your own activities or those of any third party; (3) Nokia is not under any obligation of confidentiality with respect to the Feedback; and (4) you are not entitled to any compensation of any kind from Nokia. You hereby grant Nokia a worldwide non-exclusive, assignable, fully paid, royalty-free, perpetual and irrevocable license to use, exploit, copy, publicly perform, display, distribute, further develop and modify for any purpose such Feedback, and to prepare derivative works thereof, or incorporate such Feedback into other works as well as sublicense products and services resulting from such works.
+
+6. SUPPORT AND MAINTENANCE
+
+Nokia has no obligation to furnish You with technical or other support unless separately agreed in writing between You and Nokia. In case of such support given by Nokia You understand and agree that the support has been given on "as is" and "as available" basis and Nokia will have no obligations or liabilities related to such support.
+
+Nokia, may, from time to time, make Updates available to You. You may use the previous version for ninety (90) days after You receive the Update in order to assist You in the transition to the Update. After such time You no longer have a right to use the previous version, except for the sole purpose of enabling You to install the Update. However, Nokia may provide You with Updates that are considered as important or critical by Nokia, and in such case You may not continue using the previous version of the Software and the use of the previous version of the Software may be prevented without installation of the Update.
+
+7. COMMENCEMENT & TERMINATION
+
+This Agreement is effective from the first date You install the Software. You may terminate this Agreement at any time by permanently deleting, destroying, and returning, at Your own costs, the Software, all backup copies, and all related materials provided by Nokia. Your end-user rights automatically and immediately terminate without notice from Nokia if You fail to comply with any provision of this Agreement. In such an event, You must immediately delete, destroy, or return at Your own cost, the Software, all backup copies, and all related material to Nokia.
+
+8. NO WARRANTIES
+
+YOU ACKNOWLEDGE THAT THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, AND TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW NEITHER NOKIA, ITS LICENSORS OR AFFILIATES, NOR THE COPYRIGHT HOLDERS MAKE ANY REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR THAT THE SOFTWARE WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS, OR OTHER RIGHTS. THERE IS NO WARRANTY BY NOKIA OR BY ANY OTHER PARTY THAT THE FUNCTIONS CONTAINED IN THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE. YOU ASSUME ALL RESPONSIBILITY AND RISK FOR THE SELECTION OF THE SOFTWARE TO ACHIEVE YOUR INTENDED RESULTS AND FOR THE INSTALLATION, USE, AND RESULTS OBTAINED FROM IT.
+
+9. NO OTHER OBLIGATIONS
+
+This Agreement creates no obligations on the part of Nokia other than as specifically set forth herein.
+
+10. LIMITATION OF LIABILITY
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL NOKIA, ITS EMPLOYEES OR LICENSORS OR AFFILIATES BE LIABLE FOR ANY LOST PROFITS, REVENUE, SALES, DATA, OR COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, PROPERTY DAMAGE, PERSONAL INJURY, INTERRUPTION OF BUSINESS, LOSS OF BUSINESS INFORMATION, OR FOR ANY SPECIAL, DIRECT, INDIRECT, INCIDENTAL, ECONOMIC, COVER, PUNITIVE, SPECIAL, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND WHETHER ARISING UNDER CONTRACT, TORT, NEGLIGENCE, OR OTHER THEORY OF LIABILITY ARISING OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF NOKIA OR ITS LICENSORS OR AFFILIATES ARE ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME COUNTRIES/STATES/JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF LIABILITY, BUT MAY ALLOW LIABILITY TO BE LIMITED, IN SUCH CASES, NOKIA, ITS EMPLOYEES OR LICENSORS OR AFFILIATES' LIABILITY SHALL BE LIMITED TO U.S. $50. Nothing contained in this Agreement shall prejudice the statutory rights of any party dealing as a consumer. Nothing contained in this Agreement limits Nokia's liability to You in the event of death or personal injury resulting from Nokia's negligence. Nokia is acting on behalf of its employees and licensors or affiliates for the purpose of disclaiming, excluding, and/or restricting obligations, warranties, and liability as provided in this clause 9, but in no other respects and for no other purpose.
+
+11. INDEMNITY
+
+You shall defend, indemnify and hold Nokia and its licensors harmless against any claims, damages, liabilities, losses, costs, suits or expenditures incurred by Nokia, its Affiliates, or licensors as a result of any infringement or alleged infringement of intellectual property rights of a third party caused by Your development or exploitation of the Software.
+
+12. EXPORT CONTROL
+
+You acknowledge that the Software may be subject to export control restrictions of various countries. You shall fully comply with all applicable export license restrictions and requirements as well as with all laws and regulations relating to the importation of the Software and/or Applications and shall procure all necessary governmental authorizations, including without limitation, all necessary licenses, approvals, permissions or consents, where necessary for the re-exportation of the Software or Applications.
+
+
+13. GOVERNMENT END USERS
+
+A "U.S. Government End User" shall mean any agency or entity of the government of the United States. The following shall apply if You are a U.S. Government End User. The Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire the Software with only those rights set forth herein. The Software (including related documentation) is provided to U.S. Government End Users: (a) only as a commercial end item; and (b) only pursuant to this Agreement.
+
+
+14. NOTICES
+
+All notices and return of the Software and Documentation should be delivered to:
+
+NOKIA CORPORATION
+P.O. Box 100
+FIN-00045 NOKIA GROUP
+FINLAND
+
+15. APPLICABLE LAW AND GENERAL PROVISIONS
+
+This Agreement is governed by the laws of Finland. All disputes arising from or relating to this Agreement shall be settled by a single arbitrator appointed by the Central Chamber of Commerce of Finland. The arbitration procedure shall take place in Helsinki, Finland in the English language. If any part of this Agreement is found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms. This Agreement may only be modified by a writing signed by an authorized officer of Nokia, although Nokia may vary the terms of this Agreement.
+
+This is the entire agreement between Nokia and You relating to the Software, and it supersedes any prior representations, discussions, undertakings, end-user agreements, communications, or advertising relating to the Software.
+
+There are no implied licenses or other implied rights granted under this Agreement, and all rights, save for those expressly granted hereunder, shall remain with Nokia and its licensors. In addition, no licenses or immunities are granted to the combination of the Software with any other software or hardware not delivered by Nokia under this Agreement.
+
+
+OVI MAPS API ADDITIONAL TERMS
+
+In addition to the terms set forth above, the Nokia Privacy Policy and following additional terms shall apply to Your use of the Ovi Maps and related services ("Service"):
+
+
+1. DEFINITIONS
+
+"Ovi Maps Content" means the maps content available from Nokia from time to time for the purpose of being rendered on the Ovi Maps, including data provided by Nokia that originates from third parties.
+
+"Ovi Maps API Service" means the service offered by Nokia that enables You to incorporate the Ovi Maps For Developers and the Ovi Maps Content, as made available by Nokia from time to time, into Your Applications and to have end-users access and use it on such Applications
+
+"Ovi Maps For Developers" means the software, as made available by Nokia from time to time that allows the rendering of Ovi Maps Content within Applications. For clarity, the Ovi Maps For Developers may include software components that are downloaded and installed on the users' mobile device(s) and/or JavaScript libraries that are invoked and downloaded by the Ovi Maps API.
+
+"Ovi Maps API Developer Package" means the Ovi Maps API, documentation and any and all other material made accessible to You by Nokia from time to time that enables You to incorporate the Ovi Maps For Developers into Your Applications and is designated by Nokia as being a part of the Ovi Maps API Developer Package.
+
+"Ovi Maps API(s)" means the interface information made accessible to You by Nokia from time to time that enables You to incorporate the Ovi Maps For Developers into Your Applications.
+
+2. REGISTRATION AND TERMINATION
+
+If registration is required, You agree to provide truthful and complete information when registering for the Service and to keep that information updated. Providing misleading information about Your identity is forbidden. Depending on the use of the Ovi Maps API(s), You may receive an identifier code or developer key in order to use the Service. You are personally responsible for any use of the Ovi Maps API Service. You agree to take due care in protecting Your Application using Ovi Maps API, Your identifier code and/or developer key against misuse by others and promptly notify Nokia about any misuse. Where requested by Nokia, You agree to include and use the identifier code and/or developer key, as applicable, in each request You make to access to the Ovi Maps API(s).
+
+You may terminate Your registration if You no longer wish to use the Service. After termination, You may not access the Service. Nokia may terminate Your registration or restrict Your access to certain parts of the Service if there is an indication that You have breached these terms or with a prior notice if You have not signed into the Service with Your identifier code in the past three (3) months.
+
+3. SERVICE CHANGES
+
+Nokia may, in its sole discretion, change, improve and correct the Service from time to time. Nokia may also provide with updates to the Service that are considered as important or critical by Nokia, and in such case You may not continue using the previous version of the Service and the use of the previous version of the Service may be prevented without installation of the update. The Service may not be available during maintenance breaks and other times. Nokia may also decide to discontinue the Service or any part thereof in its sole discretion. In such case You will be provided a prior notification and Nokia may terminate the Agreement accordingly.
+
+Except as set forth in Privacy Policy, Nokia shall not be responsible for any removal or loss of the information or content You have submitted ("Material") to the Service when Your registration is terminated. After the Material is removed from the Service by either You or Nokia, traces and copies of the Material may still remain.
+
+
+4. USE OF OVI MAPS API DEVELOPER PACKAGE
+
+The Ovi Maps API Developer Package is made accessible to You for the purposes of incorporating the Ovi Maps Service into Your Application and for the limited purposes of evaluating, testing, and controlling the Ovi Maps For Developers during the term of this Agreement.
+
+When using the Ovi Maps API Developer Package and/or the Ovi Maps Service, You hereby agree that You will not:
+
+(i) use or incorporate the Ovi Maps Service, Ovi Maps API Developer Package or any part thereof, in connection with any Application or other service (a) which has the primary functionality of providing turn-by-turn navigation services, real time navigation or route guidance; or (b) where such Application's functionality is substantially similar to the Ovi Maps or navigation/location-based products distributed by Nokia or its affiliates; or (c) which has the primary purpose of capturing or collecting end user data;
+
+(ii) use, without Nokia's prior written permission, the Ovi Maps Service or Ovi Maps For Developers, or any part thereof, in connection with any internal business Application the purpose of which is directly related to the operation of Your core business and where the users of such Application are Your employees or contractors (e.g. fleet or asset management and tracking);
+
+(iii)remove or obscure any copyright or trademark notices or other similar notices or markings or legends or branding requirements from the Ovi Maps API Developer Package, Ovi Maps For Developers or the Ovi Maps Content whether such notices, markings or legends or other branding requirements originate from Nokia or a third party;
+
+(iv) alter the order of search, geo-coding and/or reverse geo-coding results delivered by or through any Ovi Maps API to or as part of the Application (where applicable);
+
+(v) alter, delete or otherwise change any Ovi Maps Content, including third party content contained in the Ovi Maps Content, that is displayed through the use of the Ovi Maps Service or Ovi Maps For Developers;
+
+(vi) use the Ovi Maps API(s) or Ovi Maps Service to exceed any transaction volume limits (if any) set by Nokia for Applications, Ovi Maps APIs and/or Ovi Maps Services. The amount of the possible transaction volume limit is as set forth in the documentation included in the Ovi Maps API. Nokia may change the limit from time to time in its sole discretion, but will provide You with ninety (90) days' advance notice of a change in the volume limit. Any programmatic methods or other actions intended to circumvent the transaction volume limits shall be considered a material breach of this Agreement;
+
+(vii) access or use the Ovi Maps Service or any Ovi Maps Content through any technology or means other than those provided by the Ovi Maps Service or Ovi Maps API, or through other explicitly authorized means Nokia may designate;
+
+(viii) use the Ovi Maps Service, Ovi Maps API or Ovi Maps For Developers in a manner that gives You or any other person access to mass downloads or bulk fees of any Ovi Maps Content, including but not limited to numerical latitude or longitude coordinates;
+
+(ix) pre-fetch, cache, or store any Ovi Maps Content except that You may store limited amounts of Ovi Maps Content for the purpose of testing your Application, if You do so temporarily, securely, and in a manner that does not permit use of the Ovi Maps Content outside of the Ovi Maps Service; or
+
+(x) use the Ovi Maps API Developer Package, including the Ovi Maps For Developers, or the Ovi Maps Service in any manner or for any purpose that violates this Agreement or any law or regulation, including without limitation, any intellectual property or other proprietary rights, any right of any person, rights of privacy, or rights of personality.
+
+You also agree (i) to comply with these terms, applicable laws and good manners; (ii) not to distribute or post spam, unreasonably large files, chain letters, pyramid schemes, viruses or any other technologies that may harm the Ovi Maps Service, or the interest or property of the Ovi Maps Service users; (iii) not to use the Service in connection with any unlawful, offensive, abusive, pornographic, harassing, libelous or otherwise inappropriate Material and comply with Nokia Content Guidelines as may be provided by Nokia from time to time; and (iv) to respect the privacy of others. You agree to comply with Nokia Technical Guidelines and other guidelines as Nokia may provide from time to time.
+
+5. OVI MAPS CONTENT AND PUBLICATION
+
+Ovi Maps Content is provided to You and Your end users for planning purposes only and Nokia does not guarantee the accuracy or availability of any Ovi Maps Content. You may find that weather conditions, construction projects, closures or other events may cause road conditions, directions, positioning coordinates or other location information to differ from the results depicted in the Ovi Maps Content. All use of Ovi Maps Content is at Your own risk.
+
+6. PRIVACY AND OVI STORE PUBLICATION
+
+You agree that Your use of the Ovi Maps Services and Ovi Maps API will comply with the Nokia Privacy Policy (http://www.nokia.com/privacy-policy).
+
+If your Application enables You or any party to gain access to information about users, including but not limited to personally identifiable information, non-personally identifiable usage information or location information ("Information"), You must provide users with notice about what Information is accessible and how such Information will be used or disclosed so that users may make informed decisions about whether or not to use Your Application. Furthermore, you must make Your privacy policy regarding the use of Information publicly available.
+
+If You intend to publish your Application on Nokia's Ovi Store, please note that Your Application must comply with the Ovi Store Publication Requirements (https://publish.ovi.com/info/).
+
+7. FEES
+
+Your use of the Ovi Maps Service may be or may become subject to charges. Nokia reserves the right to charge for the Ovi Maps Service and to change its fees from time to time, at its discretion, but Nokia will provide You with ninety (90) days' advance notice if charges will be implemented for use of the Ovi Maps Service.
+
+8. AVAILABILITY
+
+The Ovi Maps Service may not be available in all countries and may be provided only in selected languages. The Ovi Maps Service may be network dependent, contact Your network service provider for more information.
+
+9. YOUR SERVICES
+
+You may interact with users, including consumers, on or through the Ovi Maps Service. You agree that any such interactions by You do not involve Nokia and are solely between You and the other user(s).
+
+10. LINKS TO THIRD PARTY SITES, CONTENT AND ADVERTISING
+
+Nokia may include links to sites on the Internet that are owned or operated by third parties and that are not part of the Ovi Maps Service. Upon following a link to such a third-party site, You shall review and agree to that site's rules of use before using such site.
+
+You agree that Nokia has no control over the content of third-party sites and cannot assume any responsibility for services provided or material created or published by such sites. A link to a third-party site does not imply that Nokia endorses the site or the products or services referenced in the site.
+
+In addition, users may create links within the Ovi Maps Service to content that has not otherwise been submitted to the Ovi Maps Service. You agree that Nokia is neither responsible nor liable for any such links. Moreover, Ovi Maps Content made available to You by Nokia, may include content and data that originates from third parties.
+
+Nokia reserves the right, in its sole discretion, to implement advertising in the Ovi Maps For Developers. If Nokia implements advertising, You agree not to remove or otherwise alter or tamper with such advertising. Nokia will provide You with ninety (90) days' advance written notice prior to implementing advertising in the Ovi Maps For Developers.
+
+11. REPORTING
+
+You agree to implement those reporting mechanisms specified by Nokia (if any). For example, if specified by Nokia, You agree to provide Nokia with reports if your Application which utilizes the Ovi Maps API detects its own location through the use of a sensor (including, but not limited to GPS, cell triangulation, WiFi or similar functionality) to display the location of the device on a map or to calculate a route.
+
+12. ADDITIONAL EXPORT CONTROL RESTRICTIONS
+
+The Ovi Maps Service and Ovi Maps API Developer Package, including technical data, includes cryptographic software subject to export controls under the U.S. Export Administration Regulations ("EAR") and may be subject to import or export controls in other countries. The EAR prohibits the use of the Ovi Maps Service and the Ovi Maps API Developer Package and technical data by a Government End User, as defined hereafter, without a license from the U.S. government. A Government End User is defined in Part 772 of the EAR as "any foreign central, regional, or local government department, agency, or other entity performing governmental functions; including governmental research institutions, governmental corporations, or their separate business units (as defined in part 772 of the EAR) which are engaged in the manufacture or distribution of items or services controlled on the Wassenaar Munitions List, and international governmental organizations. This term does not include: utilities, telecommunications companies and Internet service providers; banks and financial institutions; transportation; broadcast or entertainment; educational organizations; civil health and medical organizations; retail or wholesale firms; and manufacturing or industrial entities not engaged in the manufacture or distribution of items or services controlled on the Wassenaar Munitions List. You agree to strictly comply with all applicable import and export regulations and acknowledge that You have the responsibility to obtain licenses to export, re-export, transfer, or import the Ovi Maps Service and the Ovi Maps API Developer Package. You further represent that You are not a Government End User as defined above, and You will not transfer the Ovi Maps Service and the Ovi Maps API Developer Package to any Government End User without a license.
+
+
+Copyright (c) 2010 Nokia Corporation.
+
+ Company Confidential
+
diff --git a/installerbuilder/libinstaller/NQSThirdPartyAgreement.txt b/installerbuilder/libinstaller/NQSThirdPartyAgreement.txt
new file mode 100644
index 000000000..9c25bd3fa
--- /dev/null
+++ b/installerbuilder/libinstaller/NQSThirdPartyAgreement.txt
@@ -0,0 +1,1019 @@
+Qt SDK Version 1.1
+Open Source Components
+
+The Qt SDK includes several components licensed under the terms of the GNU Lesser General Public License version 2.1. These components are as follows:
+
+Qt libraries
+ *Qt for Symbian and Qt for Maemo versions 4.6.3, 4.7.0 and 4.7.1
+ *Qt for Desktop (Windows, X11 and Mac OS X) version 4.7.1
+Qt Creator 2.0 and 2.1
+Qt Mobility APIs version 1.1.0
+Madde Tools
+Qt Simulator
+MinGW Maemo USB Networking Driver for Windows
+Installer Framework
+Symbian ^3 with 5.0 support and labelled "Symbian Complementary Package"
+
+----------
+
+The GNU LGPL version 2.1 license:
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.]
+
+ Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+
+GNU LESSER GENERAL PUBLIC LICENSE
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+ a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+ 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+
+ b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
+
+To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+<one line to give the library's name and a brief idea of what it does.> Copyright (C) <year> <name of author>
+
+This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+
+This library 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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
+
+Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+<signature of Ty Coon>, 1 April 1990
+Ty Coon, President of Vice
+
+That's all there is to it!
+___________
+
+In addition, some of the Qt components, as document in the source files, also include the Qt LGPL Exception version 1.1
+
+Nokia Qt LGPL Exception version 1.1
+
+As an additional permission to the GNU Lesser General Public License version 2.1, the object code form of a "work that uses the Library" may incorporate material from a header file that is part of the Library. You may distribute such object code under terms of your choice, provided that:
+(i) the header files of the Library have not been modified; and
+(ii) the incorporated material is limited to numerical parameters, data structure layouts, accessors, macros, inline functions and templates; and
+(iii) you comply with the terms of Section 6 of the GNU Lesser General Public License version 2.1.
+
+Moreover, you may apply this exception to a modified version of the Library, provided that such modification does not involve copying material from the Library into the modified Library's header files unless such material is limited to (i) numerical parameters; (ii) data structure layouts; (iii) accessors; and (iv) small macros, templates and inline functions of five lines or less in length.
+
+Furthermore, you are not required to apply this additional permission to a modified version of the Library.
+____________
+In addition, the above components, as well as some other components included in the Qt SDK, include third party open source components. These components are identified below:
+___________
+Qt Third Party Components:
+FreeType 2 (freetype) version 2.3.6
+The FreeType project is a team of volunteers who develop free, portable and high-quality software solutions for digital typography. We specifically target embedded systems and focus on bringing small, efficient and ubiquitous products. -- quoted from 3rdparty/freetype/docs/freetype2.html.
+See src/3rdparty/freetype/docs/FTL.txt and src/3rdparty/freetype/docs/GPL.txt for license details.
+See also the files in src/3rdparty/opentype, which are used by FreeType.
+Parts of the FreeType projects have been modified and put into Qt for use in the painting subsystem. These files are ftraster.h, ftraster.c, ftgrays.h and ftgrays.c. The following modifications has been made to these files:
+Renamed FT_ and ft_ symbols to QT_FT_ and qt_ft_ to avoid name conflicts.
+Removed parts of code not relevant when compiled with _STANDALONE_ defined.
+Changed behavior in ftraster.c to follow X polygon filling rules.
+Implemented support in ftraster.c for winding / odd even polygon fill rules.
+Replaced bitmap generation with span generation in ftraster.c
+Renamed: ftraster.h to qblackraster_p.h
+Renamed: ftraster.c to qblackraster.c
+Renamed: ftgrays.h to qgrayraster_p.h
+Renamed: ftgrays.c to qgrayraster.c
+
+
+__________
+
+The FreeType Project LICENSE
+
+ 2006-Jan-27
+
+ Copyright 1996-2002, 2006 by
+ David Turner, Robert Wilhelm, and Werner Lemberg
+
+Introduction
+============
+
+ The FreeType Project is distributed in several archive packages;
+ some of them may contain, in addition to the FreeType font engine,
+ various tools and contributions which rely on, or relate to, the
+ FreeType Project.
+
+ This license applies to all files found in such packages, and
+ which do not fall under their own explicit license. The license
+ affects thus the FreeType font engine, the test programs,
+ documentation and makefiles, at the very least.
+
+ This license was inspired by the BSD, Artistic, and IJG
+ (Independent JPEG Group) licenses, which all encourage inclusion
+ and use of free software in commercial and freeware products
+ alike. As a consequence, its main points are that:
+
+ o We don't promise that this software works. However, we will be
+ interested in any kind of bug reports. (`as is' distribution)
+
+ o You can use this software for whatever you want, in parts or
+ full form, without having to pay us. (`royalty-free' usage)
+
+ o You may not pretend that you wrote this software. If you use
+ it, or only parts of it, in a program, you must acknowledge
+ somewhere in your documentation that you have used the
+ FreeType code. (`credits')
+
+ We specifically permit and encourage the inclusion of this
+ software, with or without modifications, in commercial products.
+ We disclaim all warranties covering The FreeType Project and
+ assume no liability related to The FreeType Project.
+
+
+ Finally, many people asked us for a preferred form for a
+ credit/disclaimer to use in compliance with this license. We thus
+ encourage you to use the following text:
+
+ """
+ Portions of this software are copyright <year> The FreeType
+ Project (www.freetype.org). All rights reserved.
+ """
+
+ Please replace <year> with the value from the FreeType version you
+ actually use.
+
+
+Legal Terms
+===========
+
+0. Definitions
+--------------
+
+ Throughout this license, the terms `package', `FreeType Project',
+ and `FreeType archive' refer to the set of files originally
+ distributed by the authors (David Turner, Robert Wilhelm, and
+ Werner Lemberg) as the `FreeType Project', be they named as alpha,
+ beta or final release.
+
+ `You' refers to the licensee, or person using the project, where
+ `using' is a generic term including compiling the project's source
+ code as well as linking it to form a `program' or `executable'.
+ This program is referred to as `a program using the FreeType
+ engine'.
+
+ This license applies to all files distributed in the original
+ FreeType Project, including all source code, binaries and
+ documentation, unless otherwise stated in the file in its
+ original, unmodified form as distributed in the original archive.
+ If you are unsure whether or not a particular file is covered by
+ this license, you must contact us to verify this.
+
+ The FreeType Project is copyright (C) 1996-2000 by David Turner,
+ Robert Wilhelm, and Werner Lemberg. All rights reserved except as
+ specified below.
+
+1. No Warranty
+--------------
+
+ THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
+ USE, OF THE FREETYPE PROJECT.
+
+2. Redistribution
+-----------------
+
+ This license grants a worldwide, royalty-free, perpetual and
+ irrevocable right and license to use, execute, perform, compile,
+ display, copy, create derivative works of, distribute and
+ sublicense the FreeType Project (in both source and object code
+ forms) and derivative works thereof for any purpose; and to
+ authorize others to exercise some or all of the rights granted
+ herein, subject to the following conditions:
+
+ o Redistribution of source code must retain this license file
+ (`FTL.TXT') unaltered; any additions, deletions or changes to
+ the original files must be clearly indicated in accompanying
+ documentation. The copyright notices of the unaltered,
+ original files must be preserved in all copies of source
+ files.
+
+ o Redistribution in binary form must provide a disclaimer that
+ states that the software is based in part of the work of the
+ FreeType Team, in the distribution documentation. We also
+ encourage you to put an URL to the FreeType web page in your
+ documentation, though this isn't mandatory.
+
+ These conditions apply to any software derived from or based on
+ the FreeType Project, not just the unmodified files. If you use
+ our work, you must acknowledge us. However, no fee need be paid
+ to us.
+
+3. Advertising
+--------------
+
+ Neither the FreeType authors and contributors nor you shall use
+ the name of the other for commercial, advertising, or promotional
+ purposes without specific prior written permission.
+
+ We suggest, but do not require, that you use one or more of the
+ following phrases to refer to this software in your documentation
+ or advertising materials: `FreeType Project', `FreeType Engine',
+ `FreeType library', or `FreeType Distribution'.
+
+ As you have not signed this license, you are not required to
+ accept it. However, as the FreeType Project is copyrighted
+ material, only this license, or another one contracted with the
+ authors, grants you the right to use, distribute, and modify it.
+ Therefore, by using, distributing, or modifying the FreeType
+ Project, you indicate that you understand and accept all the terms
+ of this license.
+
+4. Contacts
+-----------
+
+ There are two mailing lists related to FreeType:
+
+ o freetype@nongnu.org
+
+ Discusses general use and applications of FreeType, as well as
+ future and wanted additions to the library and distribution.
+ If you are looking for support, start in this list if you
+ haven't found anything to help you in the documentation.
+
+ o freetype-devel@nongnu.org
+
+ Discusses bugs, as well as engine internals, design issues,
+ specific licenses, porting, etc.
+
+ Our home page can be found at
+
+ http://www.freetype.org
+
+__________
+
+Libmng License
+/* ************************************************************************** */
+/* * * */
+/* * COPYRIGHT NOTICE: * */
+/* * * */
+/* * Copyright (c) 2000-2007 Gerard Juyn (gerard@libmng.com) * */
+/* * [You may insert additional notices after this sentence if you modify * */
+/* * this source] * */
+/* * * */
+/* * For the purposes of this copyright and license, "Contributing Authors" * */
+/* * is defined as the following set of individuals: * */
+/* * * */
+/* * Gerard Juyn * */
+/* * Glenn Randers-Pehrson * */
+/* * * */
+/* * The MNG Library is supplied "AS IS". The Contributing Authors * */
+/* * disclaim all warranties, expressed or implied, including, without * */
+/* * limitation, the warranties of merchantability and of fitness for any * */
+/* * purpose. The Contributing Authors assume no liability for direct, * */
+/* * indirect, incidental, special, exemplary, or consequential damages, * */
+/* * which may result from the use of the MNG Library, even if advised of * */
+/* * the possibility of such damage. * */
+/* * * */
+/* * Permission is hereby granted to use, copy, modify, and distribute this * */
+/* * source code, or portions hereof, for any purpose, without fee, subject * */
+/* * to the following restrictions: * */
+/* * * */
+/* * 1. The origin of this source code must not be misrepresented; * */
+/* * you must not claim that you wrote the original software. * */
+/* * * */
+/* * 2. Altered versions must be plainly marked as such and must not be * */
+/* * misrepresented as being the original source. * */
+/* * * */
+/* * 3. This Copyright notice may not be removed or altered from any source * */
+/* * or altered source distribution. * */
+/* * * */
+/* * The Contributing Authors specifically permit, without fee, and * */
+/* * encourage the use of this source code as a component to supporting * */
+/* * the MNG and JNG file format in commercial products. If you use this * */
+/* * source code in a product, acknowledgment would be highly appreciated. * */
+/* * * */
+/* ************************************************************************** */
+/* * * */
+/* * Parts of this software have been adapted from the libpng package. * */
+/* * Although this library supports all features from the PNG specification * */
+/* * (as MNG descends from it) it does not require the libpng package. * */
+/* * It does require the zlib library and optionally the IJG jpeg library, * */
+/* * and/or the "little-cms" library by Marti Maria (depending on the * */
+/* * inclusion of support for JNG and Full-Color-Management respectively. * */
+/* * * */
+/* * This library's function is primarily to read and display MNG * */
+/* * animations. It is not meant as a full-featured image-editing * */
+/* * component! It does however offer creation and editing functionality * */
+/* * at the chunk level. * */
+/* * (future modifications may include some more support for creation * */
+/* * and or editing) * */
+/* * * */
+/* ************************************************************************** */
+
+__________
+Libjpeg License
+In plain English:
+1. We don't promise that this software works. (But if you find any bugs, please let us know!)
+2. You can use this software for whatever you want. You don't have to pay us.
+3. You may not pretend that you wrote this software. If you use it in a program, you must acknowledge somewhere in your documentation that you've used the IJG code.
+In legalese:
+The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy.
+This software is copyright (C) 1991-1998, Thomas G. Lane.
+All Rights Reserved except as specified below.
+Permission is hereby granted to use, copy, modify, and distribute this software (or portions thereof) for any purpose, without fee, subject to these conditions:
+(1) If any part of the source code for this software is distributed, then this README file must be included, with this copyright and no-warranty notice unaltered; and any additions, deletions, or changes to the original files must be clearly indicated in accompanying documentation.
+(2) If only executable code is distributed, then the accompanying
+documentation must state that "this software is based in part on the work of the Independent JPEG Group".
+(3) Permission for use of this software is granted only if the user accepts full responsibility for any undesirable consequences; the authors accept NO LIABILITY for damages of any kind.
+These conditions apply to any software derived from or based on the IJG code, not just to the unmodified library. If you use our work, you ought to acknowledge us.
+Permission is NOT granted for the use of any IJG author's name or company name in advertising or publicity relating to this software or products derived from it. This software may be referred to only as "the Independent JPEG Group's software".
+We specifically permit and encourage the use of this software as the basis of commercial products, provided that all warranty or liability claims are assumed by the product vendor.
+ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. ansi2knr.c is NOT covered by the above copyright and conditions, but instead by the usual distribution terms of the Free Software Foundation; principally,that you must include source code if you redistribute it. (See the file ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part of any program generated from the IJG code, this does not limit you more than the foregoing paragraphs do.
+The Unix configuration script "configure" was produced with GNU Autoconf. It is copyright by the Free Software Foundation but is freely distributable. The same holds for its supporting scripts (config.guess, config.sub,
+ltconfig, ltmain.sh). Another support script, install-sh, is copyright by M.I.T. but is also freely distributable.
+It appears that the arithmetic coding option of the JPEG spec is covered by patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot legally be used without obtaining one or more licenses. For this reason, support for arithmetic coding has been removed from the free JPEG software.
+(Since arithmetic coding provides only a marginal gain over the unpatented Huffman mode, it is unlikely that very many implementations will support it.)
+So far as we are aware, there are no patent restrictions on the remaining code.
+The IJG distribution formerly included code to read and write GIF files.
+To avoid entanglement with the Unisys LZW patent, GIF reading support has been removed altogether, and the GIF writer has been simplified to produce "uncompressed GIFs". This technique does not use the LZW algorithm; the resulting GIF files are larger than usual, but are readable by all standard GIF decoders.
+We are required to state that
+ "The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. GIF(sm) is a Service Mark property of CompuServe Incorporated."
+__________
+Libpng License
+This copy of the libpng notices is provided for your convenience. In case of any discrepancy between this copy and the notices in the file png.h that is included in the libpng distribution, the latter shall prevail.
+
+COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
+
+If you modify libpng you may insert additional notices immediately following this sentence.
+
+libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and are
+distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors
+
+ Cosmin Truta
+
+libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
+distributed according to the same disclaimer and license as libpng-1.0.6 with the following individuals added to the list of Contributing Authors
+
+ Simon-Pierre Cadieux
+ Eric S. Raymond
+ Gilles Vollant
+
+and with the following additions to the disclaimer:
+
+There is no warranty against interference with your enjoyment of the library or against infringement. There is no warranty that our efforts or the library will fulfill any of your particular purposes or needs. This library is provided with all faults, and the entire risk of satisfactory quality, performance, accuracy, and effort is with the user.
+
+libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
+distributed according to the same disclaimer and license as libpng-0.96, with the following individuals added to the list of Contributing Authors:
+
+ Tom Lane
+ Glenn Randers-Pehrson
+ Willem van Schaik
+
+libpng versions 0.89, June 1996, through 0.96, May 1997, are
+Copyright (c) 1996, 1997 Andreas Dilger
+
+Distributed according to the same disclaimer and license as libpng-0.88, with the following individuals added to the list of Contributing Authors:
+
+ John Bowler
+ Kevin Bracey
+ Sam Bushell
+ Magnus Holmgren
+ Greg Roelofs
+ Tom Tanner
+
+libpng versions 0.5, May 1995, through 0.88, January 1996, are
+Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
+
+For the purposes of this copyright and license, "Contributing Authors" is defined as the following set of individuals:
+
+ Andreas Dilger
+ Dave Martindale
+ Guy Eric Schalnat
+ Paul Schmidt
+ Tim Wegner
+
+The PNG Reference Library is supplied "AS IS". The Contributing Authors and Group 42, Inc. disclaim all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose. The Contributing Authors and Group 42, Inc. assume no liability for direct, indirect, incidental, special, exemplary, or consequential damages, which may result from the use of the PNG Reference Library, even if advised of the possibility of such damage.
+
+Permission is hereby granted to use, copy, modify, and distribute this source code, or portions hereof, for any purpose, without fee, subject to the following restrictions:
+
+1. The origin of this source code must not be misrepresented.
+
+2. Altered versions must be plainly marked as such and must not
+ be misrepresented as being the original source.
+
+3. This Copyright notice may not be removed or altered from any
+ source or altered source distribution.
+
+The Contributing Authors and Group 42, Inc. specifically permit, without fee, and encourage the use of this source code as a component to supporting the PNG file format in commercial products. If you use this source code in a product, acknowledgment is not required but would be appreciated.
+
+
+A "png_get_copyright" function is available, for convenient use in "about" boxes and the like:
+
+ printf("%s",png_get_copyright(NULL));
+
+Also, the PNG logo (in PNG format, of course) is supplied in the files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
+
+Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a certification mark of the Open Source Initiative.
+
+Glenn Randers-Pehrson
+glennrp at users.sourceforge.net
+May 8, 2008
+__________
+Zlib License
+
+ Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
+
+This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly jloup@gzip.org
+ Mark Adler madler@alumni.caltech.edu
+
+*/
+__________
+Sqlite
+1. 2001 September 15
+2. The author disclaims copyright to this source code. In place of a legal notice, here is a blessing:
+3. May you do good and not eviL.
+4. May you find forgiveness for yourself and forgive others.
+5. May you share freely, never taking more than you give.
+__________
+Wintab
+The text and information contained in this file may be freely used, Copied, or distributed without compensation or licensing restrictions.
+This file is copyright 1991-1998 by LCS/Telegraphics.
+__________
+HarfBuzz (harfbuzz)
+This is HarfBuzz, an OpenType Layout engine.
+It was derived originally from the OpenType code in FreeType-1.x, ported to FreeType2. (This code has been abandoned for FreeType2, but until something better comes along, should serve our purposes.) In addition to porting to FreeType-2, it has been modified in various other ways.
+Please see licensing terms and conditions set forth in Section a) above (i.e. the FreeType License).
+___________
+MD5 (md5.cpp and md5.h)
+This code implements the MD5 message-digest algorithm. The algorithm is due to Ron Rivest. This code was written by Colin Plumb in 1993, no copyright is claimed.
+This code is in the public domain; do with it what you wish.
+___________
+LibTiff
+Copyright (c) 1988-1997 Sam Leffler
+Copyright (c) 1991-1997 Silicon Graphics, Inc.
+Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
+Copyright (c) 1997 Greg Ward Larson
+
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Sam Leffler and Silicon Graphics.
+
+THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+
+IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+______________
+Copyright (c) 1996-1997 Sam Leffler
+Copyright (c) 1996 Pixar
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Pixar, Sam Leffler and Silicon Graphics.
+THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+____________
+PTMalloc Version 1.8
+ptmcalloc3 is a scalable concurrent memory allocator suitable for use in multi-threaded programs.
+Copyright (c) 2001-2006 Wolfram Gloger
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the name of Wolfram Gloger may not be used in any advertising or publicity relating to the software.
+THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+___________
+
+Copyright (C) 1999 Serika Kurusugawa. All rights reserved.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS". 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 REGENTS OR CONTRIBUTORS 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.
+* Shift-JIS Text Codec
+* ISO 2022-JP (JIS) Text Codec
+* EUC-JP Text Codec
+__________
+Copyright (C) 1999-2000 Mizi Research Inc. All rights reserved.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "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 REGENTS OR CONTRIBUTORS 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.
+* EUC-KR Text Codec
+___________
+Copyright (C) 2000 TurboLinux, Inc. Written by Justin Yu and Sean Chen.
+Copyright (C) 2001, 2002 Turbolinux, Inc. Written by James Su.
+Copyright (C) 2001, 2002 ThizLinux Laboratory Ltd. Written by Anthony Fok.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "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 REGENTS OR CONTRIBUTORS 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.
+* GBK Text Codec
+____________
+Copyright (C) 2000 Ming-Che Chuang
+Copyright (C) 2001, 2002 James Su, Turbolinux Inc.
+Copyright (C) 2002 WU Yi, HancomLinux Inc.
+Copyright (C) 2001, 2002 Anthony Fok, ThizLinux Laboratory Ltd.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "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 REGENTS OR CONTRIBUTORS 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.
+* Big5-HKSCS Text Codec
+____________
+Copyright (C) 2000 Ming-Che Chuang
+Copyright (C) 2002 James Su, Turbolinux Inc.
+Copyright (C) 2002 Anthony Fok, ThizLinux Laboratory Ltd.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "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 REGENTS OR CONTRIBUTORS 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.
+* Big5 Text Codec
+__________
+Copyright (C) 2005-2006 Trolltech ASA. All rights reserved.
+Copyright (C) 2005 Bjoern Bergstroem
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, modify, market, reproduce, grant sublicenses and distribute subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. These files are provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+* Implementation of the Recursive Shadow Casting Algorithm in Qt Designer
+___________
+Copyright (C) 2005-2006 Trolltech ASA. All rights reserved.
+Copyright (C) 2005 Roberto Raggi
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, modify, market, reproduce, grant sublicenses and distribute subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. These files are provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+* Contributions to the Following qt3to4 Files: treewalker.h, treedump.cpp, treedump.h, treewalker.cpp
+___________
+Copyright (c) 1987 X Consortium
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+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 X CONSORTIUM 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.
+Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium.
+* QRegion
+___________
+Copyright (c) 1989 The Regents of the University of California. All rights reserved.
+Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, advertising materials, and other materials related to such distribution and use acknowledge that the software was developed by the University of California, Berkeley. The name of the University may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+* QDate::weekNumber()
+___________
+Copyright (c) 1991 by AT&T.
+Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software.
+THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+This product includes software developed by the University of California, Berkeley and its contributors.
+* QLocale
+___________
+Copyright (c) 2000 Hans Petter Bieker. All rights reserved.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "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 REGENTS OR CONTRIBUTORS 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.
+* TSCII Text Codec
+____________
+Copyright 1996 Daniel Dardailler.
+Permission to use, copy, modify, distribute, and sell this software for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Daniel Dardailler not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Daniel Dardailler makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
+Modifications Copyright 1999 Matt Koss, under the same license as above.
+* Drag and Drop
+____________
+Copyright 2002 USC/Information Sciences Institute
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Information Sciences Institute not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Information Sciences Institute makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
+INFORMATION SCIENCES INSTITUTE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL INFORMATION SCIENCES INSTITUTE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+* QtSvg Module
+___________
+Copyright (C) The Internet Society (2001). All Rights Reserved.
+This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.
+This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+* Torrent Example
+___________
+Copyright (c) 1998 by Bjorn Reese <breese@imada.ou.dk>
+Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
+* Parts of the QCrashHandler Class
+___________
+Parts of the FreeType projects have been modified and put into Qt and Qtopia Core for use in the painting subsystem. These files are ftraster.h, ftraster.c, ftgrays.h and ftgrays.c. The following modifications has been made to these files:
+* Renamed FT and ft_symbols to QT_FT_and qt_ft to avoid name conflicts in qrasterdefs_p.h.
+* Removed parts of code not relevant when compiled with _STANDALONE_ defined.
+* Changed behavior in ftraster.c to follow X polygon filling rules.
+* Implemented support in ftraster.c for winding / odd even polygon fill rules.
+* Replaced bitmap generation with span generation in ftraster.c.
+* Renamed ftraster.h as qblackraster_p.h.
+* Renamed ftraster.c as qblackraster.c.
+* Renamed ftgrays.h as qgrayraster_p.h.
+* Renamed ftgrays.c as qgrayraster.c.
+See src/3rdparty/freetype/docs/FTL.txt and src/3rdparty/freetype/docs/GPL.txt for license details.
+__________
+Copyright (c) 1985, 1986, 1987 X Consortium
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+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 X CONSORTIUM 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.
+Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium.
+* Parts of the Q3PolygonScanner Class Used in Qt for Embedded Linux
+__________
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+All Rights Reserved
+Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+* Parts of the Q3PolygonScanner class used in Qt for Embedded Linux
+__________
+OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.
+* QGLFormat
+___________
+WebKit is licensed under the GNU Library General Public License. Individual contributor names and copyright dates can be found inline in the code.
+This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+This library 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 Library General Public License for more details.
+You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+* QtWebKit Module
+____________
+Copyright (C) 2000-2004, International Business Machines
+Corporation and others. All Rights Reserved.
+Copyright (C) 2007 Apple Inc. All rights reserved.
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
+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 OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
+* Parts of WebKit used by the QtWebKit module
+_____________
+Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+Changes are Copyright(C) 2007 by Trolltech ASA, all rights reserved.
+This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+This library 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 Lesser General Public License for more details.
+You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+* QtHelp Module
+_____________
+Copyright (C) 2004, 2005 Daniel M. Duley
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+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.
+* QImage
+____________
+This file is part of the KDE project
+Copyright (C) 2005-2007 Matthias Kretz <kretz@kde.org>
+Copyright (C) 2007-2008 Trolltech ASA.
+This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation.
+This library 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 Library General Public License for more details.
+You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+* Phonon Module
+____________
+Copyright (C) 2007-2008, Apple, Inc.
+All rights reserved.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of Apple, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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.
+Contributions to the Following QtGui Files:
+* qapplication_cocoa_p.h
+* qapplication_mac.mm
+* qdesktopwidget_mac.mm
+* qeventdispatcher_mac.mm
+* qeventdispatcher_mac_p.h
+* qmacincludes_mac.h
+* qt_cocoa_helpers.mm
+* qt_cocoa_helpers_p.h
+* qwidget_mac.mm
+* qsystemtrayicon_mac.mm
+
+____________
+Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
+This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own license. You may use this file under your Qt license. Following description is copied from their original file headers. Contact immodule-qt@freedesktop.org if any conditions of this licensing are not clear to you.
+* QInputContextFactory
+* QInputContext
+* QInputContextPlugin
+____________
+Copyright (c) 2003, 2006 Matteo Frigo
+Copyright (c) 2003, 2006 Massachusetts Institute of Technology
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+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 OR COPYRIGHT HOLDERS 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.
+* QTestLib Manual
+____________
+Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+All rights reserved.
+Contact: Qt Development Frameworks Information (qt-info@nokia.com)
+You may use this file under the terms of the BSD license as follows:
+"Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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."
+* QAxServer Module
+* The qtmain Library
+* QAxContainer Module
+_____________
+Copyright 1985, 1987, 1998 The Open Group
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+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 OPEN GROUP 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.
+Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group.
+* Parts of the internal QKeyMapper class on X11 platforms
+____________
+pnmscale.c - read a portable anymap and scale it
+Copyright (C) 1989, 1991 by Jef Poskanzer.
+Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty.
+* Parts of the internal QImageSmoothScaler::scale() function use code based on pnmscale.c by Jef Poskanzer.
+____________
+Qt Creator 3rd Party Components
+___________
+Open Source front-end for C++ (license MIT), enhanced for use in Qt Creator.
+Roberto Raggi <roberto.raggi@gmail.com>
+QtCreator/src/shared/cplusplus
+___________
+Botan, a C++ crypto library. Version 1.8.8
+Copyright (C) 1999-2004 The Botan Project. All rights reserved.
+Copyright (C) 1999-2009 Jack Lloyd
+2001 Peter J Jones
+2004-2007 Justin Karneges
+2005 Matthew Gregan
+2005-2006 Matt Johnston
+2006 Luca Piccarreta
+2007 Yves Jerschow
+2007-2008 FlexSecure GmbH
+2007-2008 Technische Universitat Darmstadt
+2007-2008 Falko Strenzke
+2007-2008 Martin Doering
+2007 Manuel Hartl
+2007 Christoph Ludwig
+2007 Patrick Sona
+All rights reserved.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "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(S) OR CONTRIBUTOR(S) 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.
+
+The source code of Botan C++ crypto library can be found here:
+QtCreator/src/libs/3rdparty
+http://qt.gitorious.org/qt-creator/qt-creator/trees/master/src/libs/3rdparty
+_________
+NetSieben SSH Library is a Secure Shell client library for C++. Version 1.3.2
+Commercial License: For organizations who do not want to release the source code for their applications as open source/ free software; in other words they do not want to comply with the GNU General Public License (GPL) or Q Public License.
+Non Commercial / Open Source License: NetSieben believes in contributing back to the open source community, thus it has released the SSH Library under Q Public License as it is defined by Trolltech AS of Norway. The Open Source License allows the user to use software under an open source / free software license, and distribute it freely. The software can be used at no charge with the condition that if the user uses the SSH Library in an application they wish to redistribute, then the complete source code for your application must be available and freely redistributable under reasonable conditions. For more information on the used QPL License see: QtCreator/src/libs/3rdparty/net7ssh/LICENSE.QPL
+The source code of NetSieben Secure Shell C++ Library can be found here:
+QtCreator/src/libs/3rdparty
+http://qt.gitorious.org/qt-creator/qt-creator/trees/master/src/libs/3rdparty
+src/plugins/imageviewer/imageview.cpp and src/plugins/imageviewer/imageview.h
+All rights reserved.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "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(S) OR CONTRIBUTOR(S) 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.
+______________
+Qt Mobility API's
+_____________
+Copyright (c) 2001-2006 Wolfram Gloger
+
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the name of Wolfram Gloger may not be used in any advertising or publicity relating to the software.
+
+THE SOFTWARE IS PROVIDED "AS-IS"; AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.</p>
+IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+See <tt>src/3rdparty/ptmalloc/COPYRIGHT</tt> for license details.
+
+___________
+Copyright (c) 1988-1997 Sam Leffler
+Copyright (c) 1991-1997 Silicon Graphics, Inc.
+Copyright (C) 2004, Andrey Kiselev &lt;dron@ak4719.spb.edu&gt;
+Copyright (c) 1997 Greg Ward Larson
+
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Sam Leffler and Silicon Graphics.
+
+THE SOFTWARE IS PROVIDED "AS-IS"; AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+____________
+Copyright (c) 1996-1997 Sam Leffler
+Copyright (c) 1996 Pixar
+
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Pixar, Sam Leffler and Silicon Graphics.
+
+THE SOFTWARE IS PROVIDED "AS-IS"; AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.</p>
+IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+See <tt>src/3rdparty/libtiff/COPYRIGHT</tt> for license details.</p>
+
+______________
+Copyright (C) 2000-2004, International Business Machines Corporation and others. All Rights Reserved.
+Copyright (C) 2007 Apple Inc. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
+
+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 OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
+
+__________
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+____________
+ Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+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 OPEN GROUP 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.
+
+Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group.
+___________
+
+Copyright (C) 1989, 1991 by Jef Poskanzer.
+Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is"; without express or implied warranty.
+
+____________
+
+Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
+
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+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 KDEVELOP TEAM 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.
+____________
+Madde Tools
+
+Copyright (C) 1999-2004 The Botan Project. All rights reserved.
+Copyright (C) 1999-2009 Jack Lloyd
+ 2001 Peter J Jones
+ 2004-2007 Justin Karneges
+ 2005 Matthew Gregan
+ 2005-2006 Matt Johnston
+ 2006 Luca Piccarreta
+ 2007 Yves Jerschow
+ 2007-2008 FlexSecure GmbH
+ 2007-2008 Technische Universitat Darmstadt
+ 2007-2008 Falko Strenzke
+ 2007-2008 Martin Doering
+ 2007 Manuel Hartl
+ 2007 Christoph Ludwig
+ 2007 Patrick Sona
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "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(S) OR CONTRIBUTOR(S) 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.
+
+____________
+Symbian ^3 with 5.0 support and labelled "Symbian Complementary Package"
+
+This package is under the terms of the Eclipse Public License version 1.0. Open source software contained in this package is licensed under the terms specific in such files included in the source code.
+
+
+
+
+1
+
+
diff --git a/installerbuilder/libinstaller/adminauthorization.cpp b/installerbuilder/libinstaller/adminauthorization.cpp
new file mode 100644
index 000000000..fa2a091b1
--- /dev/null
+++ b/installerbuilder/libinstaller/adminauthorization.cpp
@@ -0,0 +1,70 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "adminauthorization.h"
+
+class AdminAuthorizationBase::Private
+{
+public:
+ Private()
+ : authorized( false )
+ {
+ }
+
+ bool authorized;
+};
+
+AdminAuthorizationBase::AdminAuthorizationBase()
+{
+}
+
+AdminAuthorizationBase::~AdminAuthorizationBase()
+{
+}
+
+bool AdminAuthorizationBase::isAuthorized() const
+{
+ return d->authorized;
+}
+
+void AdminAuthorizationBase::setAuthorized()
+{
+ d->authorized = true;
+}
+
+#ifdef Q_WS_MAC
+bool AdminAuthorization::hasAdminRights()
+{
+ // as this is only required on Windows
+ return false;
+}
+#endif
diff --git a/installerbuilder/libinstaller/adminauthorization.h b/installerbuilder/libinstaller/adminauthorization.h
new file mode 100644
index 000000000..d1a20d31e
--- /dev/null
+++ b/installerbuilder/libinstaller/adminauthorization.h
@@ -0,0 +1,75 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef ADMINAUTHORIZATION_H
+#define ADMINAUTHORIZATION_H
+
+#include <QtCore/QObject>
+
+#include <KDToolsCore/pimpl_ptr>
+
+class AdminAuthorizationBase
+{
+protected:
+ AdminAuthorizationBase();
+
+public:
+ virtual ~AdminAuthorizationBase();
+
+ virtual bool authorize() = 0;
+ bool isAuthorized() const;
+
+protected:
+ void setAuthorized();
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+class AdminAuthorization : public QObject, public AdminAuthorizationBase
+{
+ Q_OBJECT
+ Q_PROPERTY( bool authorized READ isAuthorized )
+public:
+ AdminAuthorization();
+ ~AdminAuthorization();
+
+ bool execute( QWidget* dialogParent, const QString& programs, const QStringList& arguments );
+
+ static bool hasAdminRights();
+
+public Q_SLOTS:
+ bool authorize();
+
+Q_SIGNALS:
+ void authorized();
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/adminauthorization_mac.cpp b/installerbuilder/libinstaller/adminauthorization_mac.cpp
new file mode 100644
index 000000000..50ba63a25
--- /dev/null
+++ b/installerbuilder/libinstaller/adminauthorization_mac.cpp
@@ -0,0 +1,104 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "adminauthorization.h"
+
+#include <Security/Authorization.h>
+#include <Security/AuthorizationTags.h>
+
+#include <unistd.h>
+
+#include <QStringList>
+#include <QVector>
+
+class AdminAuthorization::Private
+{
+public:
+ Private()
+ : auth( 0 )
+ {
+ }
+
+ AuthorizationRef auth;
+};
+
+AdminAuthorization::AdminAuthorization()
+{
+ AuthorizationCreate( 0, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &d->auth );
+}
+
+AdminAuthorization::~AdminAuthorization()
+{
+ AuthorizationFree( d->auth, kAuthorizationFlagDestroyRights );
+}
+
+bool AdminAuthorization::authorize()
+{
+ if( geteuid() == 0 )
+ setAuthorized();
+
+ if( isAuthorized() )
+ return true;
+
+ AuthorizationItem item = { kAuthorizationRightExecute, 0, NULL, 0 };
+ const AuthorizationRights rights = { 1, &item };
+
+ const AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights;
+
+ const int result = AuthorizationCopyRights( d->auth, &rights, 0, flags, 0 );
+ if( result != 0 )
+ return false;
+
+ seteuid( 0 );
+ setAuthorized();
+ emit authorized();
+ return true;
+}
+
+bool AdminAuthorization::execute( QWidget*, const QString& program, const QStringList& arguments )
+{
+ const QByteArray utf8Program = program.toUtf8();
+ const char* const prog = utf8Program.data();
+ QVector< QByteArray > utf8Args;
+ QVector< char* > args;
+ for( QStringList::const_iterator it = arguments.begin(); it != arguments.end(); ++it )
+ {
+ utf8Args.push_back( it->toUtf8() );
+ args.push_back( utf8Args.last().data() );
+ }
+ args.push_back( 0 );
+
+ const AuthorizationFlags flags = kAuthorizationFlagDefaults;
+
+ const int result = AuthorizationExecuteWithPrivileges( d->auth, prog, flags, args.data(), 0 );
+ return result == 0;
+}
diff --git a/installerbuilder/libinstaller/adminauthorization_win.cpp b/installerbuilder/libinstaller/adminauthorization_win.cpp
new file mode 100644
index 000000000..99820d160
--- /dev/null
+++ b/installerbuilder/libinstaller/adminauthorization_win.cpp
@@ -0,0 +1,154 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "adminauthorization.h"
+
+#include "windows.h"
+
+#include <QDir>
+#include <QStringList>
+#include <QVector>
+#include <QDebug>
+
+// from qprocess_win.cpp
+static QString qt_create_commandline(const QString &program, const QStringList &arguments)
+{
+ QString args;
+ if (!program.isEmpty()) {
+ QString programName = program;
+ if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
+ programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
+ programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
+
+ // add the prgram as the first arg ... it works better
+ args = programName + QLatin1Char(' ');
+ }
+
+ for (int i=0; i<arguments.size(); ++i) {
+ QString tmp = arguments.at(i);
+ // in the case of \" already being in the string the \ must also be escaped
+ tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
+ // escape a single " because the arguments will be parsed
+ tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
+ if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
+ // The argument must not end with a \ since this would be interpreted
+ // as escaping the quote -- rather put the \ behind the quote: e.g.
+ // rather use "foo"\ than "foo\"
+ QString endQuote(QLatin1Char('\"'));
+ int i = tmp.length();
+ while (i>0 && tmp.at(i-1) == QLatin1Char('\\')) {
+ --i;
+ endQuote += QLatin1Char('\\');
+ }
+ args += QLatin1String(" \"") + tmp.left(i) + endQuote;
+ } else {
+ args += QLatin1Char(' ') + tmp;
+ }
+ }
+ return args;
+}
+
+
+class AdminAuthorization::Private
+{
+public:
+ Private()
+ {
+ }
+};
+
+AdminAuthorization::AdminAuthorization()
+{
+}
+
+AdminAuthorization::~AdminAuthorization()
+{
+}
+
+bool AdminAuthorization::authorize()
+{
+ setAuthorized();
+ emit authorized();
+ return true;
+}
+
+bool AdminAuthorization::hasAdminRights()
+{
+ SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY;
+ PSID adminGroup;
+ // Initialize SID.
+ if( !AllocateAndInitializeSid( &authority,
+ 2,
+ SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_ADMINS,
+ 0, 0, 0, 0, 0, 0,
+ &adminGroup))
+ return false;
+
+ BOOL isInAdminGroup = FALSE;
+ if( !CheckTokenMembership( 0, adminGroup, &isInAdminGroup ))
+ isInAdminGroup = FALSE;
+
+ FreeSid( adminGroup );
+ return isInAdminGroup;
+}
+
+bool AdminAuthorization::execute( QWidget*, const QString& program, const QStringList& arguments )
+{
+ qDebug() << Q_FUNC_INFO;
+ //const QString file = qt_create_commandline( program, QStringList() );
+ const QString args = qt_create_commandline( QString(), arguments );
+ const QString file = QDir::toNativeSeparators( program );
+
+ const int len = GetShortPathNameW( (wchar_t*)file.utf16(), 0, 0 );
+ if( len == 0 )
+ return false;
+ wchar_t* const buffer = new wchar_t[ len ];
+ GetShortPathName( (wchar_t*)file.utf16(), buffer, len );
+
+ SHELLEXECUTEINFOW TempInfo = { 0 };
+ TempInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
+ TempInfo.fMask = 0;
+ TempInfo.hwnd = 0;
+ TempInfo.lpVerb = L"runas";
+ TempInfo.lpFile = buffer;
+ TempInfo.lpParameters = (wchar_t*)args.utf16();
+ TempInfo.lpDirectory = 0;
+ TempInfo.nShow = SW_NORMAL;
+
+
+ qDebug() << QLatin1String("\t starting elevated process with ::ShellExecuteExW( &TempInfo );");
+ const bool result = ::ShellExecuteExW( &TempInfo );
+ qDebug() << QLatin1String("\t after starting elevated process");
+ delete[] buffer;
+ return result;
+}
diff --git a/installerbuilder/libinstaller/adminauthorization_x11.cpp b/installerbuilder/libinstaller/adminauthorization_x11.cpp
new file mode 100644
index 000000000..e6e9d832e
--- /dev/null
+++ b/installerbuilder/libinstaller/adminauthorization_x11.cpp
@@ -0,0 +1,279 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "adminauthorization.h"
+
+#include <QtCore/QFile>
+#include <QtCore/QProcess>
+
+#include <QtGui/QApplication>
+#include <QtGui/QInputDialog>
+#include <QtGui/QMessageBox>
+
+#include <cstdlib>
+#include <unistd.h>
+#include <fcntl.h>
+
+#ifdef Q_OS_LINUX
+#include <linux/limits.h>
+#include <pty.h>
+#else
+#include <util.h>
+#endif
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <iostream>
+
+#define SU_COMMAND "/usr/bin/sudo"
+//#define SU_COMMAND "/bin/echo"
+
+class AdminAuthorization::Private
+{
+public:
+};
+
+AdminAuthorization::AdminAuthorization()
+{
+}
+
+AdminAuthorization::~AdminAuthorization()
+{
+}
+
+bool AdminAuthorization::authorize()
+{
+ return true;
+}
+
+static QString getPassword( QWidget* parent )
+{
+ if( QApplication::type() == QApplication::GuiClient )
+ {
+ bool ok = false;
+ const QString result = QInputDialog::getText( 0, QObject::tr( "Authorization required" ), QObject::tr( "Enter your password to authorize for sudo:" ), QLineEdit::Password, QString(), &ok );
+ return ok ? result : QString();
+ }
+ else
+ {
+ std::cout << QObject::tr( "Authorization required" ).toStdString() << std::endl;
+ std::cout << QObject::tr( "Enter your password to authorize for sudo:" ).toStdString() << std::endl;
+ std::string password;
+ std::cin >> password;
+ return QString::fromStdString( password );
+ }
+}
+
+static void printError( QWidget* parent, const QString& value )
+{
+ if( QApplication::type() == QApplication::GuiClient )
+ {
+ QMessageBox::critical( parent, QObject::tr( "Error acquiring admin rights" ), value, QMessageBox::Ok, QMessageBox::Ok );
+ }
+ else
+ {
+ std::cout << value.toStdString() << std::endl;
+ }
+}
+
+bool AdminAuthorization::execute( QWidget* parent, const QString& program, const QStringList& arguments )
+{
+ // as we cannot pipe the password to su in QProcess, we need to setup a pseudo-terminal for it
+ int masterFD = -1;
+ int slaveFD = -1;
+ char ptsn[ PATH_MAX ];
+
+ if( ::openpty( &masterFD, &slaveFD, ptsn, 0, 0 ) )
+ return false;
+
+ masterFD = ::posix_openpt( O_RDWR | O_NOCTTY );
+ if( masterFD < 0 )
+ return false;
+
+ const QByteArray ttyName = ::ptsname( masterFD );
+
+ if( ::grantpt( masterFD ) )
+ {
+ ::close( masterFD );
+ return false;
+ }
+
+ ::revoke( ttyName );
+ ::unlockpt( masterFD );
+
+ slaveFD = ::open( ttyName, O_RDWR | O_NOCTTY );
+ if( slaveFD < 0 )
+ {
+ ::close( masterFD );
+ return false;
+ }
+
+ ::fcntl( masterFD, F_SETFD, FD_CLOEXEC );
+ ::fcntl( slaveFD, F_SETFD, FD_CLOEXEC );
+ int pipedData[ 2 ];
+ if ( pipe( pipedData ) != 0)
+ return false;
+ int flags = ::fcntl( pipedData[ 0 ], F_GETFD );
+ if ( flags != -1 )
+ ::fcntl( pipedData[ 0 ], F_SETFL, flags | O_NONBLOCK );
+
+ pid_t child = fork();
+
+ if( child < -1 )
+ {
+ ::close( masterFD );
+ ::close( slaveFD );
+ ::close( pipedData[ 0 ]);
+ ::close( pipedData[ 1 ]);
+ return false;
+ }
+
+ // parent process
+ else if( child > 0 )
+ {
+ ::close( slaveFD );
+ //close writing end of pipe
+ ::close( pipedData[1]);
+
+ QRegExp re( QLatin1String( "[Pp]assword.*:" ) );
+ QByteArray errData;
+ flags = ::fcntl( masterFD, F_GETFD );
+// if ( flags != -1 )
+// ::fcntl( masterFD, F_SETFL, flags | O_NONBLOCK );
+ int bytes = 0;
+ int errBytes = 0;
+ char buf[ 1024 ];
+ while( bytes >= 0 )
+ {
+ int state;
+ if( ::waitpid( child, &state, WNOHANG ) == -1 )
+ break;
+ bytes = ::read( masterFD, buf, 1023 );
+ errBytes = ::read( pipedData[ 0 ], buf, 1023 );
+ if ( errBytes > 0 )
+ errData.append( buf, errBytes );
+ if( bytes > 0 )
+ {
+ const QString line = QString::fromLatin1( buf, bytes );
+ if( re.indexIn( line ) != -1 )
+ {
+ const QString password = getPassword( parent );
+ if ( password == QString() )
+ {
+ QByteArray pwd = password.toLatin1();
+ for ( int i = 0; i < 3; ++i )
+ {
+ ::write( masterFD, pwd.data(), pwd.length() );
+ ::write( masterFD, "\n", 1 );
+ }
+ return false;
+ }
+ QByteArray pwd = password.toLatin1();
+ ::write( masterFD, pwd.data(), pwd.length() );
+ ::write( masterFD, "\n", 1 );
+ ::read( masterFD, buf, pwd.length() + 1 );
+ }
+ }
+ if( bytes == 0 )
+ ::usleep( 100000 );
+ }
+ if ( !errData.isEmpty() )
+ {
+ printError( parent, QString::fromLocal8Bit( errData.constData() ) );
+ return false;
+ }
+
+ int status;
+ child = ::wait( &status );
+ const int exited = WIFEXITED( status );
+ const int exitStatus = WEXITSTATUS( status );
+ ::close( pipedData[1]);
+ if( exited )
+ return exitStatus == 0;
+
+ return false;
+ }
+
+ // child process
+ else
+ {
+ ::close( pipedData[ 0 ] );
+ // Reset signal handlers
+ for( int sig = 1; sig < NSIG; ++sig )
+ signal( sig, SIG_DFL );
+ signal( SIGHUP, SIG_IGN );
+
+ ::setsid();
+
+ ::ioctl( slaveFD, TIOCSCTTY, 1 );
+ int pgrp = ::getpid();
+ ::tcsetpgrp( slaveFD, pgrp );
+
+ ::dup2( slaveFD, 0 );
+ ::dup2( slaveFD, 1 );
+ ::dup2( pipedData[ 1 ], 2 );
+
+ // close all file descriptors
+ struct rlimit rlp;
+ getrlimit( RLIMIT_NOFILE, &rlp );
+ for( int i = 3; i < static_cast< int >( rlp.rlim_cur ); ++i )
+ ::close( i );
+
+ char** argp = (char**) ::malloc( arguments.count() + 4 * sizeof( char* ) );
+ QList< QByteArray > args;
+ args.push_back( SU_COMMAND );
+ args.push_back( "-b" );
+ args.push_back( program.toLocal8Bit() );
+ for( QStringList::const_iterator it = arguments.begin(); it != arguments.end(); ++it )
+ args.push_back( it->toLocal8Bit() );
+
+ int i = 0;
+ for( QList< QByteArray >::iterator it = args.begin(); it != args.end(); ++it, ++i )
+ argp[ i ] = it->data();
+ argp[ i ] = 0;
+
+ ::unsetenv( "LANG" );
+ ::unsetenv( "LC_ALL" );
+
+ ::execv( SU_COMMAND, argp );
+ _exit( 0 );
+ return false;
+ }
+}
+
+// has no guarantee to work, its implemented as discussed with Tim Jenssen and Niels Weber
+bool AdminAuthorization::hasAdminRights()
+{
+ return getuid() == 0;
+}
diff --git a/installerbuilder/libinstaller/componentselectiondialog.cpp b/installerbuilder/libinstaller/componentselectiondialog.cpp
new file mode 100644
index 000000000..a45524ee0
--- /dev/null
+++ b/installerbuilder/libinstaller/componentselectiondialog.cpp
@@ -0,0 +1,210 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "componentselectiondialog.h"
+#include "ui_componentselectiondialog.h"
+
+#include <QPushButton>
+#include <QHeaderView>
+
+#include "qinstaller.h"
+#include "qinstallercomponent.h"
+#include "qinstallercomponentmodel.h"
+
+using namespace QInstaller;
+
+class ComponentSelectionDialog::Private : public QObject
+{
+ Q_OBJECT
+public:
+ Private( ComponentSelectionDialog* qq, Installer* inst )
+ : q( qq ),
+ installer( inst )
+ {
+ }
+
+ void selectionChanged()
+ {
+ // no component selected disables the ok button
+ const QList< Component* > components = installer->components( true, UpdaterMode );
+ int selectionCount = 0;
+ for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
+ {
+ if( (*it)->isSelected( UpdaterMode ) )
+ ++selectionCount;
+ }
+
+ installBtn->setEnabled( selectionCount > 0 );
+ installBtn->setText( selectionCount > 1 ? tr( "Install %1 Items" ).arg( selectionCount ) :
+ selectionCount == 1 ? tr( "Install 1 Item" ) : tr( "Install" ) );
+
+ if (selectionCount > 0) {
+ ui.buttonBox->button( QDialogButtonBox::Cancel )->setText(tr("Cancel"));
+ } else {
+ ui.buttonBox->button( QDialogButtonBox::Cancel )->setText(tr("Close"));
+ }
+
+ const QModelIndex index = ui.treeView->currentIndex();
+ if( !index.isValid() )
+ {
+ ui.textBrowser->clear();
+ return;
+ }
+
+ ui.textBrowser->setHtml( index.sibling( index.row(), 0 ).data( Qt::ToolTipRole ).toString() );
+ }
+
+ void modelReset()
+ {
+ ui.treeView->header()->resizeSection( 0, ui.labelTitle->sizeHint().width() / 1.5 );
+ ui.treeView->header()->setStretchLastSection( true );
+ for ( int i = 0; i < ui.treeView->model()->columnCount(); ++i )
+ ui.treeView->resizeColumnToContents( i );
+
+ bool hasChildren = false;
+ const int rowCount = ui.treeView->model()->rowCount();
+ for( int row = 0; row < rowCount && !hasChildren; ++row )
+ hasChildren = ui.treeView->model()->hasChildren( ui.treeView->model()->index( row, 0 ) );
+ ui.treeView->setRootIsDecorated( hasChildren );
+ ui.treeView->expandToDepth( 0 );
+ selectionChanged();
+ }
+
+private:
+ ComponentSelectionDialog* const q;
+
+public:
+ Ui::ComponentSelectionDialog ui;
+ Installer* const installer;
+ ComponentModel* componentModel;
+ QPushButton* installBtn;
+
+public Q_SLOTS:
+ void selectAll();
+ void deselectAll();
+};
+
+void ComponentSelectionDialog::Private::selectAll()
+{
+ QList< Component* > updaterComponents = installer->components( false, UpdaterMode );
+ Q_FOREACH( Component* comp, updaterComponents )
+ {
+ comp->setSelected( true, UpdaterMode );
+ }
+}
+
+void ComponentSelectionDialog::Private::deselectAll()
+{
+ QList< Component* > updaterComponents = installer->components( false, UpdaterMode );
+ Q_FOREACH( Component* comp, updaterComponents )
+ {
+ comp->setSelected( false, UpdaterMode );
+ }
+}
+
+void ComponentSelectionDialog::refreshDialog()
+{
+ d->selectionChanged();
+}
+
+ComponentSelectionDialog::ComponentSelectionDialog( Installer* installer, QWidget* parent )
+ : QDialog( parent ),
+ d( new Private( this, installer ) )
+{
+ d->ui.setupUi( this );
+ d->componentModel = new ComponentModel( installer, UpdaterMode );
+ d->ui.treeView->setModel( d->componentModel );
+
+ d->ui.labelLicenseBlurb->setAttribute( Qt::WA_MacSmallSize );
+ d->ui.labelSubTitle->setAttribute( Qt::WA_MacSmallSize );
+ d->ui.treeView->setAttribute( Qt::WA_MacShowFocusRect, false );
+ d->ui.textBrowser->setAttribute( Qt::WA_MacShowFocusRect, false );
+ d->ui.splitter->setCollapsible( 0, false );
+ d->installBtn = d->ui.buttonBox->addButton( tr( "Install" ), QDialogButtonBox::AcceptRole ) ;
+ if ( !d->ui.buttonBox->button( QDialogButtonBox::Cancel )->icon().isNull() )
+ d->installBtn->setIcon( style()->standardIcon( QStyle::SP_DialogOkButton ) );
+
+ d->ui.icon->setPixmap( windowIcon().pixmap( 48, 48 ) );
+
+ connect( d->ui.treeView->model(), SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
+ this, SLOT( selectionChanged() ) );
+ connect( d->ui.treeView->model(), SIGNAL( modelReset() ),
+ this, SLOT( modelReset() ) );
+ connect( d->ui.treeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ),
+ this, SLOT( selectionChanged() ) );
+ connect( d->installBtn, SIGNAL( clicked() ), this, SIGNAL( requestUpdate() ) );
+ connect( d->ui.selectAll, SIGNAL( clicked() ), d.get(), SLOT( selectAll() ), Qt::QueuedConnection );
+ connect( d->ui.deselectAll, SIGNAL( clicked() ), d.get(), SLOT( deselectAll() ), Qt::QueuedConnection );
+
+
+ d->ui.treeView->setCurrentIndex( d->ui.treeView->model()->index( 0, 0 ) );
+ d->ui.splitter->setStretchFactor( 0, 2 );
+ d->ui.splitter->setStretchFactor( 1, 1 );
+ d->ui.treeView->header()->setStretchLastSection( true );
+ for ( int i = 0; i < d->ui.treeView->model()->columnCount(); ++i )
+ d->ui.treeView->resizeColumnToContents( i );
+ d->selectionChanged();
+ d->modelReset();
+}
+
+ComponentSelectionDialog::~ComponentSelectionDialog()
+{
+}
+
+void ComponentSelectionDialog::selectAll() {
+ d->selectAll();
+}
+
+void ComponentSelectionDialog::deselectAll() {
+ d->deselectAll();
+}
+
+void ComponentSelectionDialog::install() {
+ emit requestUpdate();
+}
+
+void ComponentSelectionDialog::selectComponent( const QString& id ) {
+ const QModelIndex idx = d->componentModel->findComponent( id );
+ if ( !idx.isValid() )
+ return;
+ d->componentModel->setData( idx, Qt::Checked );
+}
+
+void ComponentSelectionDialog::deselectComponent( const QString& id ) {
+ const QModelIndex idx = d->componentModel->findComponent( id );
+ if ( !idx.isValid() )
+ return;
+ d->componentModel->setData( idx, Qt::Unchecked );
+}
+
+#include "moc_componentselectiondialog.cpp"
+#include "componentselectiondialog.moc"
diff --git a/installerbuilder/libinstaller/componentselectiondialog.h b/installerbuilder/libinstaller/componentselectiondialog.h
new file mode 100644
index 000000000..0b67084c6
--- /dev/null
+++ b/installerbuilder/libinstaller/componentselectiondialog.h
@@ -0,0 +1,67 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef COMPONENTSELECTIONDIALOG_H
+#define COMPONENTSELECTIONDIALOG_H
+
+#include <QtGui/QDialog>
+
+#include <KDToolsCore/pimpl_ptr>
+
+#include "installer_global.h"
+
+namespace QInstaller
+{
+class Installer;
+
+class INSTALLER_EXPORT ComponentSelectionDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ explicit ComponentSelectionDialog( QInstaller::Installer* installer, QWidget* parent = 0 );
+ ~ComponentSelectionDialog();
+ Q_INVOKABLE void selectComponent( const QString& compoenent );
+ Q_INVOKABLE void deselectComponent( const QString& component );
+ Q_INVOKABLE void selectAll();
+ Q_INVOKABLE void deselectAll();
+ Q_INVOKABLE void install();
+
+public Q_SLOTS:
+ void refreshDialog();
+
+Q_SIGNALS:
+ void requestUpdate();
+
+private:
+ Q_PRIVATE_SLOT( d, void selectionChanged() );
+ Q_PRIVATE_SLOT( d, void modelReset() );
+
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/componentselectiondialog.ui b/installerbuilder/libinstaller/componentselectiondialog.ui
new file mode 100644
index 000000000..a161612ac
--- /dev/null
+++ b/installerbuilder/libinstaller/componentselectiondialog.ui
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ComponentSelectionDialog</class>
+ <widget class="QDialog" name="ComponentSelectionDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>656</width>
+ <height>406</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Software Update</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" rowspan="3">
+ <widget class="QLabel" name="icon">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="pixmap">
+ <pixmap>:/logo.png</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelTitle">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>All available updates are shown below.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" rowspan="2">
+ <widget class="QLabel" name="labelSubTitle">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Installing this software may take some time. If you're not ready to install now, you can choose Software Update from the menu later.</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QSplitter" name="splitter">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QTreeView" name="treeView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QTextBrowser" name="textBrowser">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
+ <item>
+ <widget class="QPushButton" name="selectAll">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>SelectAll</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="deselectAll">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Deselect All</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelLicenseBlurb">
+ <property name="text">
+ <string>Note: Use of this software is subject to the original Software License Agreement(s) that accompanied the software being updated.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ComponentSelectionDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/installerbuilder/libinstaller/content.qrc b/installerbuilder/libinstaller/content.qrc
new file mode 100644
index 000000000..82e0f67df
--- /dev/null
+++ b/installerbuilder/libinstaller/content.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/licensepart">
+ <file>NQSDevAgreement.txt</file>
+ <file>NQSThirdPartyAgreement.txt</file>
+ </qresource>
+</RCC>
diff --git a/installerbuilder/libinstaller/copydirectoryoperation.cpp b/installerbuilder/libinstaller/copydirectoryoperation.cpp
new file mode 100644
index 000000000..49f9db99e
--- /dev/null
+++ b/installerbuilder/libinstaller/copydirectoryoperation.cpp
@@ -0,0 +1,229 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "copydirectoryoperation.h"
+
+#include <QFileInfo>
+#include <QDir>
+#include <QDirIterator>
+#include <QEventLoop>
+#include <QFutureWatcher>
+#include <QtConcurrentRun>
+
+#include <QDebug>
+
+using namespace QInstaller;
+
+/*
+TRANSLATOR QInstaller::CopyDirectoryOperation
+*/
+
+CopyDirectoryOperation::CopyDirectoryOperation()
+{
+ setName( QLatin1String( "CopyDirectory" ) );
+}
+
+CopyDirectoryOperation::~CopyDirectoryOperation()
+{
+}
+
+void CopyDirectoryOperation::letTheUiRunTillFinished(const QFuture<void> &future)
+{
+ if (!future.isFinished()) {
+ QFutureWatcher<void> futureWatcher;
+ futureWatcher.setFuture(future);
+ QEventLoop loop;
+ connect(&futureWatcher, SIGNAL(finished()), &loop, SLOT(quit()), Qt::QueuedConnection);
+ if (!future.isFinished())
+ loop.exec();
+ }
+ Q_ASSERT(future.isFinished());
+}
+
+QList< QPair<QString,QString> > CopyDirectoryOperation::fileList()
+{
+ Q_ASSERT(arguments().count() == 2);
+ Q_ASSERT(!arguments().at(0).isEmpty());
+ Q_ASSERT(!arguments().at(1).isEmpty());
+ if (m_fileList.isEmpty()) {
+ const QString sourcePath = arguments().at( 0 );
+ const QString targetPath = arguments().at( 1 );
+
+ m_fileList = generateFileList(sourcePath, targetPath);
+ }
+ return m_fileList;
+}
+
+QList< QPair<QString,QString> > CopyDirectoryOperation::generateFileList(const QString &sourcePath, const QString &targetPath)
+{
+ Q_ASSERT( QFileInfo( sourcePath ).isDir() );
+ Q_ASSERT( !QFileInfo( targetPath ).exists() || QFileInfo( targetPath ).isDir() );
+ if ( !QDir().mkpath( targetPath ) ) {
+ qWarning() << QLatin1String("Could not create folder ") << targetPath;
+ } else {
+ addDirectoryToDirectoryList(targetPath);
+ }
+
+
+ QDirIterator it( sourcePath, QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden | QDir::System);
+ while( it.hasNext() )
+ {
+ const QFileInfo currentFileInfo( it.next() );
+ if( currentFileInfo.isDir() && !currentFileInfo.isSymLink() )
+ {
+ generateFileList( currentFileInfo.absoluteFilePath(), QDir( targetPath ).absoluteFilePath( currentFileInfo.fileName() ) );
+ }
+ else
+ {
+ const QString source = currentFileInfo.absoluteFilePath();
+ const QString target = QDir( targetPath ).absoluteFilePath( currentFileInfo.fileName() );
+ m_fileList.append(QPair<QString, QString>(source, target));
+ }
+ }
+ return m_fileList;
+}
+
+bool CopyDirectoryOperation::copyFilesFromInternalFileList()
+{
+ QList< QPair<QString, QString> > sourceDestinationFileList(fileList());
+
+ QList< QPair<QString, QString> >::iterator i;
+ for (i = sourceDestinationFileList.begin(); i != sourceDestinationFileList.end(); ++i) {
+ QString source = (*i).first;
+ QString dest = (*i).second;
+
+ // If destination file exists, then we cannot use QFile::copy()
+ // because it does not overwrite an existing file. So we remove
+ // the destination file.
+ if( QFile::exists(dest) )
+ {
+ QFile file( dest );
+ if( !file.remove() ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not remove destination file %1: %2.").arg( dest, file.errorString() ) );
+ return false;
+ }
+ }
+
+ QFile file( source );
+ const bool copied = file.copy( dest );
+ if ( !copied ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not copy %1 to %2: %3.").arg( source, dest, file.errorString() ) );
+ return false;
+ } else {
+ addFileToFileList( dest );
+ }
+ }
+ return true;
+}
+
+bool CopyDirectoryOperation::removeFilesFromInternalFileList()
+{
+ const QStringList fileNameList = value( QLatin1String( "files" ) ).toStringList();
+
+ bool result = true;
+ foreach(const QString fileName, fileNameList) {
+ result = result & deleteFileNowOrLater( fileName );
+ }
+
+ const QStringList directoryList = value( QLatin1String( "directories" ) ).toStringList();
+
+ foreach(const QString directory, directoryList) {
+ QDir().rmdir(directory);
+ }
+
+ return result;
+}
+
+void CopyDirectoryOperation::backup()
+{
+
+}
+bool CopyDirectoryOperation::performOperation()
+{
+ const QStringList args = arguments();
+ if( args.count() != 2 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg( args.count() ) );
+ return false;
+ }
+ const QString sourcePath = args.at( 0 );
+ const QString targetPath = args.at( 1 );
+
+
+ typedef QList< QPair< QString, QString > > FileList;
+ QFuture< FileList > fileListFuture = QtConcurrent::run(this, &CopyDirectoryOperation::fileList);
+ letTheUiRunTillFinished(fileListFuture);
+
+ QFuture< bool > allCopied = QtConcurrent::run(this, &CopyDirectoryOperation::copyFilesFromInternalFileList);
+ letTheUiRunTillFinished(allCopied);
+
+ return allCopied.result();
+}
+
+bool CopyDirectoryOperation::undoOperation()
+{
+ Q_ASSERT( arguments().count() == 2 );
+
+ QFuture< bool > allRemoved = QtConcurrent::run(this, &CopyDirectoryOperation::removeFilesFromInternalFileList);
+ letTheUiRunTillFinished(allRemoved);
+
+ return allRemoved.result();
+}
+
+void CopyDirectoryOperation::addFileToFileList( const QString& fileName )
+{
+ QStringList files = value( QLatin1String( "files" ) ).toStringList();
+ files.push_front( fileName );
+ setValue( QLatin1String( "files" ), files );
+ emit outputTextChanged( fileName );
+}
+
+void CopyDirectoryOperation::addDirectoryToDirectoryList( const QString& directory )
+{
+ QStringList directories = value( QLatin1String( "directories" ) ).toStringList();
+ directories.push_front( directory );
+ setValue( QLatin1String( "directories" ), directories );
+ emit outputTextChanged( directory );
+}
+
+bool CopyDirectoryOperation::testOperation()
+{
+ return true;
+}
+
+CopyDirectoryOperation* CopyDirectoryOperation::clone() const
+{
+ return new CopyDirectoryOperation();
+}
diff --git a/installerbuilder/libinstaller/copydirectoryoperation.h b/installerbuilder/libinstaller/copydirectoryoperation.h
new file mode 100644
index 000000000..ad31207a1
--- /dev/null
+++ b/installerbuilder/libinstaller/copydirectoryoperation.h
@@ -0,0 +1,72 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef COPYDIRECTORYOPERATION_H
+#define COPYDIRECTORYOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+#include "installer_global.h"
+#include <QtCore/QObject>
+#include <QFuture>
+
+
+namespace QInstaller {
+
+class INSTALLER_EXPORT CopyDirectoryOperation : public QObject, public KDUpdater::UpdateOperation
+{
+ Q_OBJECT
+
+ friend class WorkerThread;
+public:
+ CopyDirectoryOperation();
+ ~CopyDirectoryOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ CopyDirectoryOperation* clone() const;
+
+Q_SIGNALS:
+ void outputTextChanged( const QString& progress );
+ //TODO: needs progress signal
+
+private Q_SLOTS:
+
+private:
+ void addFileToFileList( const QString& fileName );
+ void addDirectoryToDirectoryList( const QString& directory );
+ void letTheUiRunTillFinished(const QFuture<void> &_future);
+ bool copyFilesFromInternalFileList();
+ bool removeFilesFromInternalFileList();
+ QList< QPair<QString,QString> > fileList();
+ QList< QPair<QString,QString> > generateFileList(const QString &sourcePath, const QString &targetPath);
+ QList< QPair<QString,QString> > m_fileList;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/createdesktopentryoperation.cpp b/installerbuilder/libinstaller/createdesktopentryoperation.cpp
new file mode 100644
index 000000000..57fe6e36f
--- /dev/null
+++ b/installerbuilder/libinstaller/createdesktopentryoperation.cpp
@@ -0,0 +1,210 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "createdesktopentryoperation.h"
+#include "common/errors.h"
+#include "common/fileutils.h"
+
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+#include <QTextStream>
+#if QT_VERSION >= 0x040600
+#include <QProcessEnvironment>
+#else
+#include <QProcess>
+#endif
+
+#include <QProcess>
+
+using namespace QInstaller;
+
+QString CreateDesktopEntryOperation::absoluteFileName()
+{
+ const QString filename = arguments().first();
+
+ // give filename is already absolute
+ if( QFileInfo( filename ).isAbsolute() )
+ return filename;
+
+ // we're not searching for the first time, let's re-use the old value
+ if( hasValue( QLatin1String( "directory" ) ) )
+ return QDir( value( QLatin1String( "directory" ) ).toString() ).absoluteFilePath( filename );
+
+ const QProcessEnvironment env;
+ QStringList XDG_DATA_DIRS = env.value( QLatin1String( "XDG_DATA_DIRS" ) ).split( QLatin1Char( ':' ), QString::SkipEmptyParts );
+ QStringList XDG_DATA_HOME = env.value( QLatin1String( "XDG_DATA_HOME" ) ).split( QLatin1Char( ':' ), QString::SkipEmptyParts );
+
+ XDG_DATA_DIRS.push_back( QLatin1String( "/usr/share" ) ); // default path
+ XDG_DATA_HOME.push_back( QDir::home().absoluteFilePath( QLatin1String( ".local/share" ) ) ); // default path
+
+ const QStringList directories = XDG_DATA_DIRS + XDG_DATA_HOME;
+ QString directory;
+ for( QStringList::const_iterator it = directories.begin(); it != directories.end(); ++it )
+ {
+ if( it->isEmpty() )
+ continue;
+
+ directory = QDir( *it ).absoluteFilePath( QLatin1String( "applications" ) );
+ QDir dir( directory );
+
+ // let's see wheter this dir exists or we're able to create it
+ if( !dir.exists() && !QDir().mkpath( directory ) )
+ continue;
+
+ // we just try wheter we're able to open the file in ReadWrite
+ QFile file( QDir( directory ).absoluteFilePath( filename ) );
+ const bool existed = file.exists();
+ if( !file.open( QIODevice::ReadWrite ) )
+ continue;
+ file.close();
+ if( !existed )
+ file.remove();
+ break;
+ }
+
+ if( !QDir( directory ).exists() )
+ QDir().mkpath( directory );
+
+ setValue( QLatin1String( "directory" ), directory );
+
+ return QDir( directory ).absoluteFilePath( filename );
+}
+
+/*
+TRANSLATOR QInstaller::CreateDesktopEntryOperation
+*/
+
+CreateDesktopEntryOperation::CreateDesktopEntryOperation()
+{
+ setName( QLatin1String( "CreateDesktopEntry" ) );
+}
+
+CreateDesktopEntryOperation::~CreateDesktopEntryOperation()
+{
+ deleteFileNowOrLater( value( QLatin1String( "backupOfExistingDesktopEntry" ) ).toString() );
+}
+
+void CreateDesktopEntryOperation::backup()
+{
+ const QString filename = absoluteFileName();
+ if( !QFile::exists( filename ) )
+ return;
+
+ try {
+ setValue( QLatin1String( "backupOfExistingDesktopEntry" ), generateTemporaryFileName( filename ) );
+ } catch ( const QInstaller::Error& e ) {
+ setErrorString( e.message() );
+ return;
+ }
+
+ if( !QFile::copy( filename, value( QLatin1String( "backupOfExistingDesktopEntry" ) ).toString() ) )
+ setErrorString( QObject::tr( "Could not backup file %1" ).arg( filename ) );
+}
+
+bool CreateDesktopEntryOperation::performOperation()
+{
+ const QStringList args = arguments();
+ if( args.count() != 2 )
+ {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg( args.count() ) );
+ return false;
+ }
+
+ const QString filename = absoluteFileName();
+ const QString& values = args[ 1 ];
+
+ if( QFile::exists( filename ) && !deleteFileNowOrLater( filename ) )
+ {
+ setError( UserDefinedError );
+ setErrorString( tr( "Failed to overwrite %1" ).arg( filename ) );
+ return false;
+ }
+
+ QFile file( filename );
+ if( !file.open( QIODevice::WriteOnly ) )
+ {
+ setError( UserDefinedError );
+ setErrorString( tr( "Could not write Desktop Entry at %1" ).arg( filename ) );
+ return false;
+ }
+
+ QFile::setPermissions(filename, QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther);
+
+ QTextStream stream( &file );
+ stream.setCodec( "UTF-8" );
+ stream << QLatin1String( "[Desktop Entry]" ) << endl;
+ stream << QLatin1String( "Encoding=UTF-8" ) << endl;
+
+ // Type=Application\nExec=qtcreator\nPath=...
+ const QStringList pairs = values.split( QLatin1Char( '\n' ) );
+ for( QStringList::const_iterator it = pairs.begin(); it != pairs.end(); ++it )
+ {
+ stream << *it << endl;
+ }
+
+ return true;
+}
+
+bool CreateDesktopEntryOperation::undoOperation()
+{
+ const QString filename = absoluteFileName();
+
+ // first remove the link
+ if( !deleteFileNowOrLater( filename ) )
+ {
+ setErrorString( QObject::tr( "Could not delete file %1" ).arg( filename ) );
+ return false;
+ }
+
+ if( !hasValue( QLatin1String( "backupOfExistingDesktopEntry" ) ) )
+ return true;
+
+ const QString backupOfExistingDesktopEntry = value( QLatin1String( "backupOfExistingDesktopEntry" ) ).toString();
+ const bool success = QFile::copy( backupOfExistingDesktopEntry, filename ) && deleteFileNowOrLater( backupOfExistingDesktopEntry );
+ if( !success )
+ setErrorString( QObject::tr( "Could not restore backup file into %1" ).arg( filename ) );
+
+ return success;
+}
+
+bool CreateDesktopEntryOperation::testOperation()
+{
+ return true;
+}
+
+CreateDesktopEntryOperation* CreateDesktopEntryOperation::clone() const
+{
+ return new CreateDesktopEntryOperation();
+}
diff --git a/installerbuilder/libinstaller/createdesktopentryoperation.h b/installerbuilder/libinstaller/createdesktopentryoperation.h
new file mode 100644
index 000000000..853c96c2d
--- /dev/null
+++ b/installerbuilder/libinstaller/createdesktopentryoperation.h
@@ -0,0 +1,50 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef CREATEDESKTOPENTRYOPERATION_H
+#define CREATEDESKTOPENTRYOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class CreateDesktopEntryOperation : public KDUpdater::UpdateOperation
+{
+public:
+ CreateDesktopEntryOperation();
+ ~CreateDesktopEntryOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ CreateDesktopEntryOperation* clone() const;
+
+ QString absoluteFileName();
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/createshortcutoperation.cpp b/installerbuilder/libinstaller/createshortcutoperation.cpp
new file mode 100644
index 000000000..0aea4af63
--- /dev/null
+++ b/installerbuilder/libinstaller/createshortcutoperation.cpp
@@ -0,0 +1,344 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+//#include "kdupdaterupdateoperations.h"
+#include <KDUpdater/kdupdaterapplication.h>
+#include <KDUpdater/kdupdaterpackagesinfo.h>
+
+#include "createshortcutoperation.h"
+#include "common/errors.h"
+#include "common/fileutils.h"
+#include "common/utils.h"
+
+#include <QDir>
+#include <QFileInfo>
+#include <QTemporaryFile>
+
+#include <algorithm>
+#include <cerrno>
+
+#ifdef Q_WS_WIN
+#include <windows.h>
+#include <shlobj.h>
+#endif
+
+using namespace QInstaller;
+
+static bool createLink( QString fileName, QString linkName, QString workingDir, QString arguments = QString() )
+{
+#ifdef Q_WS_WIN
+ bool ret = false;
+ fileName = QDir::toNativeSeparators(fileName);
+ linkName = QDir::toNativeSeparators(linkName);
+ if ( workingDir.isEmpty() )
+ workingDir = QFileInfo(fileName).absolutePath();
+ workingDir = QDir::toNativeSeparators(workingDir);
+
+ //### assume that they add .lnk
+
+ IShellLink *psl;
+ bool neededCoInit = false;
+
+ HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
+
+ if (hres == CO_E_NOTINITIALIZED) { // COM was not initialized
+ neededCoInit = true;
+ CoInitialize(NULL);
+ hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
+ }
+
+ if (SUCCEEDED(hres)) {
+ hres = psl->SetPath((wchar_t *)fileName.utf16());
+ if( SUCCEEDED( hres ) && !arguments.isNull() )
+ hres = psl->SetArguments((wchar_t*)arguments.utf16() );
+ if (SUCCEEDED(hres)) {
+ hres = psl->SetWorkingDirectory((wchar_t *)workingDir.utf16());
+ if (SUCCEEDED(hres)) {
+ IPersistFile *ppf;
+ hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
+ if (SUCCEEDED(hres)) {
+ hres = ppf->Save((wchar_t*)linkName.utf16(), TRUE);
+ if (SUCCEEDED(hres))
+ ret = true;
+ ppf->Release();
+ }
+ }
+ }
+ psl->Release();
+ }
+
+ if (neededCoInit)
+ CoUninitialize();
+
+ return ret;
+#else
+ Q_UNUSED( workingDir )
+ Q_UNUSED( arguments )
+ return QFile::link( fileName, linkName );
+#endif
+}
+
+/*
+TRANSLATOR QInstaller::CreateShortcutOperation
+*/
+
+CreateShortcutOperation::CreateShortcutOperation()
+{
+ setName( QLatin1String( "CreateShortcut" ) );
+}
+
+CreateShortcutOperation::~CreateShortcutOperation()
+{
+ deleteFileNowOrLater( value( QLatin1String( "backupOfExistingShortcut" ) ).toString() );
+}
+
+static bool isWorkingDirOption( const QString& s ) {
+ return s.startsWith( QLatin1String("workingDirectory=") );
+}
+
+static QString getWorkingDir( QStringList& args ) {
+ QString workingDir;
+ // if the args contain an option in the form "workingDirectory=...", find it and consume it
+ QStringList::iterator wdiropt = std::find_if( args.begin(), args.end(), isWorkingDirOption );
+ if ( wdiropt != args.end() ) {
+ workingDir = wdiropt->mid( QString::fromLatin1("workingDirectory=").size() );
+ args.erase( wdiropt );
+ }
+ return workingDir;
+}
+
+void CreateShortcutOperation::backup()
+{
+ QStringList args = this->arguments();
+ getWorkingDir( args ); //consume workingDirectory= option
+
+ const QString path = QDir::fromNativeSeparators( QFileInfo( args.at( 1 ) ).absolutePath() );
+
+ //verbose() << "dir to create shortcut in " << path << std::endl;
+
+ QDir createdDir = QDir::root();
+
+ // find out, which part of the path is the first one we actually need to create
+ int end = 0;
+ QStringList directoriesToCreate;
+ while( true )
+ {
+ QString p = path.section( QLatin1String("/"), 0, ++end );
+ createdDir = QDir( p );
+ if( !createdDir.exists() )
+ {
+ directoriesToCreate.push_back( QDir::toNativeSeparators( createdDir.absolutePath() ) );
+ verbose() << " backup created dir_pre " << QDir::toNativeSeparators( createdDir.absolutePath() ) << std::endl;
+ if ( p == path)
+ break;
+
+ }
+ else if( p == path )
+ {
+ // everything did already exist -> nothing to do for us (nothing to revert then, either)
+ createdDir = QDir::root();
+ break;
+ }
+ }
+ verbose() << " backup created dir " << createdDir.absolutePath() << std::endl;
+
+ setValue( QLatin1String( "createddirs" ), directoriesToCreate );
+
+ //link creation context
+ const QString linkLocation = arguments()[ 1 ];
+ if( !QFile::exists( linkLocation ) )
+ return;
+
+ try {
+ setValue( QLatin1String( "backupOfExistingShortcut" ), generateTemporaryFileName( linkLocation ) );
+ } catch ( const QInstaller::Error& e ) {
+ setErrorString( e.message() );
+ return;
+ }
+
+ QFile f( linkLocation );
+ if( !f.copy( value( QLatin1String( "backupOfExistingShortcut" ) ).toString() ) )
+ setErrorString( QObject::tr( "Could not backup file %1: %2" ).arg( linkLocation, f.errorString() ) );
+}
+
+bool CreateShortcutOperation::performOperation()
+{
+ QStringList args = this->arguments();
+ const QString workingDir = getWorkingDir( args );
+
+ if( args.count() != 2 && args.count() != 3 )
+ {
+ setError( InvalidArguments );
+ setErrorString( QObject::tr("Invalid arguments: %1 arguments given, 2 or 3 expected (optional: \"workingDirectory=...\").").arg( args.count() ) );
+ return false;
+ }
+
+ const QString& linkTarget = args.at( 0 );
+ const QString& linkLocation = args.at( 1 );
+ const QString targetArguments = args.count() == 3 ? args[ 2 ] : QString();
+
+ const QString dirName = QFileInfo( linkLocation ).absolutePath();
+
+ //verbose() << "dir to create shortcut in " << dirName << std::endl;
+
+ errno = 0;
+
+ const bool dirAlreadyExists = QDir( dirName ).exists();
+ const bool created = dirAlreadyExists || QDir::root().mkpath(dirName);
+
+ if ( !created ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not create folder %1: %2.").arg( QDir::toNativeSeparators( dirName ), QLatin1String(strerror(errno)) ) );
+ return false;
+ }
+
+ TempDirDeleter deleter( dirName );
+
+ if( dirAlreadyExists )
+ deleter.releaseAll();
+
+#if 0 // disabled for now, isDir() also returns true if the link exists and points to a folder, then removing it fails
+ // link creation
+ if ( QFileInfo( linkLocation ).isDir() ) {
+ errno = 0;
+ if ( !QDir().rmdir( linkLocation ) ) {
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Could not create link: failed to remove folder %1: %2" ).arg( QDir::toNativeSeparators( linkLocation ), QLatin1String(strerror(errno)) ) );
+ return false;
+ }
+ }
+#endif
+
+ QString err;
+
+ if( QFile::exists( linkLocation ) && !deleteFileNowOrLater( linkLocation, &err ) )
+ {
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Failed to overwrite %1: %2" ).arg( QDir::toNativeSeparators( linkLocation ), err ) );
+ return false;
+ }
+
+ const bool linked = createLink( linkTarget, linkLocation, workingDir, targetArguments );
+ if ( !linked ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not create link %1: %2").arg( QDir::toNativeSeparators( linkLocation ), qt_error_string() ) );
+ return false;
+ }
+ deleter.releaseAll();
+ return true;
+}
+
+bool CreateShortcutOperation::undoOperation()
+{
+ const QString linkLocation = arguments()[ 1 ];
+ const QStringList args = this->arguments();
+ verbose() << " undo Shortcutoperation with arguments ";
+ Q_FOREACH( const QString& val, args )
+ verbose() << val << " ";
+ verbose() << std::endl;
+
+ // first remove the link
+ if( !deleteFileNowOrLater( linkLocation ) )
+ {
+ setErrorString( QObject::tr( "Could not delete file %1" ).arg( linkLocation ) );
+ return false;
+ }
+ verbose() << " link has been deleted " << std::endl;
+
+ if( hasValue( QLatin1String( "backupOfExistingShortcut" ) ) ){
+
+ const QString backupOfExistingShortcut = value( QLatin1String( "backupOfExistingShortcut" ) ).toString();
+ const bool success = QFile::copy( backupOfExistingShortcut, linkLocation ) && deleteFileNowOrLater( backupOfExistingShortcut );
+ if( !success ){
+ setErrorString( QObject::tr( "Could not restore backup file into %1" ).arg( linkLocation ) );
+ return success;
+ }
+ }
+ verbose() << " got behin backup " << std::endl;
+
+ const QStringList createdDirsPaths = value( QLatin1String( "createddirs" ) ).toStringList();
+ if ( createdDirsPaths.isEmpty() ) //no dir to delete (QDir( createdDirPath ) would return the current working directory -> never do that
+ return true;
+
+ const bool forceremoval = QVariant( value( QLatin1String( "forceremoval" ) ) ).toBool();
+ QListIterator<QString> it( createdDirsPaths );
+ for ( it.toBack(); it.hasPrevious(); )
+ {
+ const QString createdDirPath = it.previous();
+ const QDir createdDir = QDir( createdDirPath );
+ verbose() << createdDir.absolutePath() << std::endl;
+ if( createdDir == QDir::root() )
+ return true;
+ QString errorString;
+ if( forceremoval )
+ {
+ verbose() << " forced removal of path " << createdDir.path() << std::endl;
+ try{
+ removeDirectory( createdDir.path(), false );
+ }catch(const QInstaller::Error e){
+ setError( UserDefinedError, e.message() );
+ return false;
+ }
+ }
+ else
+ {
+ // even remove some hidden, OS-created files in there
+#if defined Q_WS_MAC
+ QFile::remove( createdDir.path() + QLatin1String( "/.DS_Store" ) );
+#elif defined Q_WS_WIN
+ QFile::remove( createdDir.path() + QLatin1String( "/Thumbs.db" ) );
+#endif
+
+ errno = 0;
+ verbose() << " removal of path " << createdDir.path() << std::endl;
+ const bool result = QDir::root().rmdir( createdDir.path() );
+ if ( !result ) {
+ if ( errorString.isEmpty() )
+ setError( UserDefinedError, tr("Cannot remove directory %1: %2").arg( createdDir.path(), errorString ) );
+ else
+ setError( UserDefinedError, tr("Cannot remove directory %1: %2").arg( createdDir.path(), QLatin1String(strerror(errno)) ) );
+ return result;
+ }
+ }
+ }
+ return true;
+}
+
+bool CreateShortcutOperation::testOperation()
+{
+ return true;
+}
+
+CreateShortcutOperation* CreateShortcutOperation::clone() const
+{
+ return new CreateShortcutOperation();
+}
diff --git a/installerbuilder/libinstaller/createshortcutoperation.h b/installerbuilder/libinstaller/createshortcutoperation.h
new file mode 100644
index 000000000..f479a5529
--- /dev/null
+++ b/installerbuilder/libinstaller/createshortcutoperation.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef CREATESHORTCUTOPERATION_H
+#define CREATESHORTCUTOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class CreateShortcutOperation : public KDUpdater::UpdateOperation
+{
+public:
+ CreateShortcutOperation();
+ ~CreateShortcutOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ CreateShortcutOperation* clone() const;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/cryptosignatureverifier.h b/installerbuilder/libinstaller/cryptosignatureverifier.h
new file mode 100644
index 000000000..978ac8e44
--- /dev/null
+++ b/installerbuilder/libinstaller/cryptosignatureverifier.h
@@ -0,0 +1,64 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef CRYPTOSIGNATUREVERIFIER_H
+#define CRYPTOSIGNATUREVERIFIER_H
+
+#include <KDUpdater/SignatureVerifier>
+#include <KDUpdater/SignatureVerificationResult>
+
+#include "KDUpdater/kdupdatercrypto.h"
+
+class CryptoSignatureVerifier : public KDUpdater::SignatureVerifier
+{
+public:
+ explicit CryptoSignatureVerifier( const QByteArray& publicKey )
+ : m_publicKey( publicKey )
+ {
+ }
+ SignatureVerifier* clone() const
+ {
+ return new CryptoSignatureVerifier( m_publicKey );
+ }
+ KDUpdater::SignatureVerificationResult verify( const QByteArray &data, const QByteArray& signature ) const
+ {
+ KDUpdaterCrypto crypto;
+ crypto.setPublicKey( m_publicKey );
+ KDUpdater::SignatureVerificationResult r;
+ r.setValidity( crypto.verify( data, signature ) ? KDUpdater::SignatureVerificationResult::ValidSignature : KDUpdater::SignatureVerificationResult::BadSignature );
+ r.setErrorString( QObject::tr( "Bad signature" ) );
+ return r;
+ }
+ QString type() const
+ {
+ return QLatin1String( "CryptoSignature" );
+ }
+
+private:
+ const QByteArray m_publicKey;
+ KDUpdaterCrypto *m_crypto;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/de_de.ts b/installerbuilder/libinstaller/de_de.ts
new file mode 100644
index 000000000..b9a078ffd
--- /dev/null
+++ b/installerbuilder/libinstaller/de_de.ts
@@ -0,0 +1,742 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1">
+<context>
+ <name>GetMetaInfoProgressWidget</name>
+ <message>
+ <location filename="installer.cpp" line="441"/>
+ <source>Retrieving information from remote installation sources...</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>Installer::Private</name>
+ <message>
+ <location filename="qinstaller.cpp" line="488"/>
+ <source>Could not write uninstaller to %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="501"/>
+ <source>ProductName should be set</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="548"/>
+ <source>Variable &apos;TargetDir&apos; not set.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="595"/>
+ <source>Preparing the installation...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="617"/>
+ <source>Installing component %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="623"/>
+ <source>Installation canceled by user</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="663"/>
+ <source>Installation finished!</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="679"/>
+ <source>Installation aborted</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="701"/>
+ <source>Cannot prepare uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="737"/>
+ <source>Cannot start uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="754"/>
+ <source>Deinstallation finished</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller</name>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="152"/>
+ <source>Cannot map file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="155"/>
+ <source>Cannot unmap file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::Component</name>
+ <message>
+ <location filename="qinstallercomponent.cpp" line="264"/>
+ <source>Could not open the requested UI file at %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::ComponentSelectionPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="451"/>
+ <source>This component will occupy approximately %1 %2 on your harddisk.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="453"/>
+ <source>Bytes</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="455"/>
+ <source>kBytes</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="456"/>
+ <source>MBytes</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="533"/>
+ <source>Select Components</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="534"/>
+ <source>Please select the components you want to install.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::CreateShortcutOperation</name>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="70"/>
+ <source>Could not create link: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::EnvironmentVariablesOperation</name>
+ <message>
+ <location filename="environmentvariablesoperation.cpp" line="45"/>
+ <source>Invalid arguments: %1 arguments given, 2-3 expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="environmentvariablesoperation.cpp" line="61"/>
+ <source>Registry is not writable</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="environmentvariablesoperation.cpp" line="77"/>
+ <source>Failed to write to the Registry</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="environmentvariablesoperation.cpp" line="105"/>
+ <source>Failed to set the envrionment variable %1 to %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::ExtractArchiveOperation</name>
+ <message>
+ <location filename="extractarchiveoperation.cpp" line="33"/>
+ <source>Invalid arguments: %1 arguments given, 2 expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::ExtractArchiveOperation::Runnable</name>
+ <message>
+ <location filename="extractarchiveoperation_p.h" line="77"/>
+ <source>Could not open %1 for reading: %2.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="extractarchiveoperation_p.h" line="84"/>
+ <source>Error while extracting %1: %2.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="extractarchiveoperation_p.h" line="86"/>
+ <source>Unknown exception caught while extracting %1.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::FinishedPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="927"/>
+ <source>Completing the %1 Setup Wizard</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="934"/>
+ <source>Click Finish to exit the Setup Wizard</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="961"/>
+ <source>Run %1 now.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="966"/>
+ <source>The %1 Setup Wizard failed</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::GetRepositoryMetaInfoJob</name>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="40"/>
+ <source>empty repository URL</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="44"/>
+ <source>invalid repository URL</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="113"/>
+ <source>Retrieving component information from remote repositories...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="117"/>
+ <source>canceled</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="121"/>
+ <source>Could not fetch Updates.xml: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="128"/>
+ <source>Could not move Updates.xml to target location: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="137"/>
+ <source>Could not open Updates.xml for reading: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="145"/>
+ <source>Could not parse component index: %1:%2: %3</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="169"/>
+ <source>Retrieving component meta information...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="191"/>
+ <source>Could not open meta info archive %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::GlobalSettingsOperation</name>
+ <message>
+ <location filename="globalsettingsoperation.cpp" line="46"/>
+ <source>Invalid arguments: %1 arguments given, 4 expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::Gui</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="165"/>
+ <source>%1 Setup</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="195"/>
+ <source>Go Back</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="196"/>
+ <source>Continue</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="197"/>
+ <source>Done</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="199"/>
+ <source>Back</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="200"/>
+ <source>Next</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="201"/>
+ <source>Finish</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="203"/>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="282"/>
+ <source>Warning</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="255"/>
+ <source>Do you want to abort the installation process?</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="262"/>
+ <source>Do you want to abort the installer application?</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::InstallerSettings</name>
+ <message>
+ <location filename="../common/installersettings.cpp" line="70"/>
+ <source>Could not open settings file %1 for reading: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/installersettings.cpp" line="75"/>
+ <source>Could not parse settings file %1: %2:%3: %4</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/installersettings.cpp" line="81"/>
+ <source>%1 is not valid: Installer root node expected</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/installersettings.cpp" line="98"/>
+ <source>Multiple RemoteRepositories elements found, but only one allowed.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::IntroductionPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="370"/>
+ <source>Setup - %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="378"/>
+ <source>Welcome to the %1 Setup Wizard.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::LicenseAgreementPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="394"/>
+ <source>License Agreement</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="397"/>
+ <source>Please read the following License Agreement. You must accept the terms of this agreement before continuing with the installation.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="409"/>
+ <source>I accept the agreement</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="410"/>
+ <source>I do not accept the agreement</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="420"/>
+ <source>Do you accept this license?</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::PerformInstallationPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="808"/>
+ <source>Uninstalling %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="809"/>
+ <source>Uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="812"/>
+ <source>Installing %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="813"/>
+ <source>Install</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="906"/>
+ <source>Show Details</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="906"/>
+ <source>Hide Details</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::QInstaller</name>
+ <message>
+ <location filename="qinstallerglobal.h" line="31"/>
+ <source>Cannot map file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallerglobal.h" line="34"/>
+ <source>Cannot unmap file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::ReadyForInstallationPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="775"/>
+ <source>Ready to Uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="777"/>
+ <source>Uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="779"/>
+ <source>Setup is now ready to begin removing %1 from your computer.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="782"/>
+ <source>Ready to Install</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="784"/>
+ <source>Install</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="786"/>
+ <source>Setup is now ready to begin installing %1 on your computer.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::StartMenuDirectoryPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="666"/>
+ <source>Start Menu shortcuts</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="673"/>
+ <source>Select the Start Menu in which you would like to create the program&apos;s shortcuts. You can also enter a name to create a new folder.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::TargetDirectoryPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="567"/>
+ <source>Installation Folder</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="573"/>
+ <source>Please specify the folder where %1 will be installed.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="582"/>
+ <source>Browse...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="627"/>
+ <source>Warning</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="628"/>
+ <source>The folder you selected exists already.
+Do you want to continue?</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="651"/>
+ <source>Select Installation Folder</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstallerCreator::Archive</name>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="404"/>
+ <source>Could not open archive file %1 for reading.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="409"/>
+ <source>Not in a supported archive format: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="432"/>
+ <source>Could not create archive from %1: Not a file.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="454"/>
+ <source>Error while packing directory at %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstallerCreator::Component</name>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="573"/>
+ <source>Could not open archive %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="49"/>
+ <source>Cannot open file %1 for writing: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="56"/>
+ <source>Cannot open file %1 for reading: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="65"/>
+ <source>Write failed after %1 bytes: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="84"/>
+ <source>Read failed after %1 bytes: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="237"/>
+ <source>Searched whole file, no marker found</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="239"/>
+ <source>Could not seek to %1 in file %2: %3.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="247"/>
+ <source>No marker found, stopped after %1 bytes</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="253"/>
+ <source>No marker found, unknown exception caught.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="479"/>
+ <source>Cannot create zipped file for path %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/installersettings.cpp" line="46"/>
+ <source>Multiple %1 elements found, but only one allowed.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="45"/>
+ <source>Could not backup file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="52"/>
+ <source>Invalid arguments: %1 arguments given, 2 expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="62"/>
+ <source>Failed to overwrite %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="82"/>
+ <source>Could not delete file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="91"/>
+ <source>Could not restore backup file into %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="72"/>
+ <source>Could not create temporary folder: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="80"/>
+ <source>Could not create temporary folder %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="102"/>
+ <source>Could not mmap in-binary resource. (offset=%1, length=%2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="105"/>
+ <source>Could not register in-binary resource.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="225"/>
+ <source>Could not open binary %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="231"/>
+ <source>Could not seek to binary layout section</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="250"/>
+ <source>Could not seek to metadata index</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="257"/>
+ <source>Could not seek to operation list</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="275"/>
+ <source>Could not seek to component index information</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="279"/>
+ <source>Could not seek to component index</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="606"/>
+ <source>Error</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="142"/>
+ <source>Invalid arguments: %1 arguments given, 2 or more expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="423"/>
+ <source>Can not find the magic cookie in file %1. Are you sure this is a valid installer?</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="450"/>
+ <source>Failed to seek in file %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallercomponent.cpp" line="210"/>
+ <source>Could not open the requested script file at %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallercomponent.cpp" line="214"/>
+ <source>Exception while loading the component script %1:%2 %3
+%4</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="registerfiletypeoperation.cpp" line="93"/>
+ <source>Register File Type: Invalid arguments</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="registerfiletypeoperation.cpp" line="154"/>
+ <source>Registering file types in only supported on Windows.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TargetDirectoryPageImpl</name>
+ <message>
+ <location filename="installer.cpp" line="324"/>
+ <source>The installation path must not contain any space.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="330"/>
+ <source>Cannot write to folder %1.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="350"/>
+ <source>Warning</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="365"/>
+ <source>The folder you selected exists already and contains an installation.
+Do you want to overwrite it?</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="368"/>
+ <source>The folder you selected exists already.
+Do you want to overwrite it and continue?</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/installerbuilder/libinstaller/downloadarchivesjob.cpp b/installerbuilder/libinstaller/downloadarchivesjob.cpp
new file mode 100644
index 000000000..3365a317e
--- /dev/null
+++ b/installerbuilder/libinstaller/downloadarchivesjob.cpp
@@ -0,0 +1,341 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "downloadarchivesjob.h"
+
+#include <QFile>
+#include <QTimer>
+#include <QMessageBox>
+#include <QDebug>
+#include <QTimerEvent>
+
+#include <KDUpdater/FileDownloader>
+#include <KDUpdater/FileDownloaderFactory>
+
+#include "common/binaryformatenginehandler.h"
+#include "common/utils.h"
+
+#include "cryptosignatureverifier.h"
+#include "qinstaller.h"
+#include "qinstallercomponent.h"
+#include "messageboxhandler.h"
+
+using namespace QInstaller;
+using namespace KDUpdater;
+
+/*
+TRANSLATOR QInstaller::DownloadArchivesJob
+*/
+
+/**
+ * Creates a new DownloadArchivesJob with \a parent.
+ */
+DownloadArchivesJob::DownloadArchivesJob(const QByteArray& publicKey, Installer* parent )
+ : KDJob( parent ),
+ cancelled( false ),
+ publicKey( publicKey ),
+ downloader( 0 ),
+ filesToDownload( 0 ),
+ filesDownloaded( 0 ),
+ parent( parent ),
+ lastFileProgress(0),
+ progressChangedTimerId(0)
+{
+ setCapabilities( Cancelable );
+}
+
+/**
+ * Destroys the DownloadArchivesJob.
+ * All temporary files get deleted.
+ */
+DownloadArchivesJob::~DownloadArchivesJob()
+{
+ for( QStringList::const_iterator it = temporaryFiles.constBegin(); it != temporaryFiles.constEnd(); ++it ) {
+ QFile f( *it );
+ if ( !f.remove() )
+ qWarning( "Could not delete file %s: %s", qPrintable(*it), qPrintable(f.errorString()) );
+ }
+ if( downloader != 0 )
+ downloader->deleteLater();
+}
+
+/**
+ * Sets the archives to download. The first value of each pair contains the file name to register
+ * the file in the installer's internal file system, the second one the source url.
+ */
+void DownloadArchivesJob::setArchivesToDownload( const QList< QPair< QString, QString > >& archs )
+{
+ filesToDownload = archs.count();
+ archives = archs;
+}
+
+/**
+ * \reimp
+ */
+void DownloadArchivesJob::doStart()
+{
+ filesDownloaded = 0;
+ fetchNextArchiveHash();
+}
+
+/**
+ * \reimp
+ */
+void DownloadArchivesJob::doCancel()
+{
+ cancelled = true;
+ if( downloader != 0 )
+ downloader->cancelDownload();
+}
+
+void DownloadArchivesJob::fetchNextArchiveHash()
+{
+ if ( parent->testChecksum() )
+ {
+ if( cancelled )
+ {
+ finishWithError( tr( "Canceled" ) );
+ return;
+ }
+
+ if( archives.isEmpty() )
+ {
+ emitFinished();
+ return;
+ }
+
+ if( downloader != 0 )
+ downloader->deleteLater();
+
+ QString hashUrl = archives.first().second;
+ hashUrl += QLatin1String( ".sha1" );
+ const QUrl url( hashUrl );
+ const QUrl sigUrl = publicKey.isEmpty() ? QUrl() : QUrl( archives.first().second + QLatin1String( ".sig" ) );
+ const CryptoSignatureVerifier verifier( publicKey );
+ downloader = FileDownloaderFactory::instance().create( url.scheme(), publicKey.isEmpty() ? 0 : &verifier, sigUrl, this );
+
+ if ( !downloader ) {
+ archives.pop_front();
+ const QString errMsg = tr("Scheme not supported: %1 (%2)").arg( url.scheme(), url.toString() );
+ verbose() << errMsg << std::endl;
+ emit outputTextChanged( errMsg );
+ QMetaObject::invokeMethod( this, "fetchNextArchiveHash", Qt::QueuedConnection );
+ return;
+ }
+
+ connect( downloader, SIGNAL( downloadCompleted() ), this, SLOT( finishedHashDownload() ), Qt::QueuedConnection );
+ connect( downloader, SIGNAL( downloadCanceled() ), this, SLOT( downloadCanceled() ) );
+ connect( downloader, SIGNAL( downloadAborted( QString ) ), this, SLOT( downloadFailed( QString ) ), Qt::QueuedConnection );
+ //hashes are not registered as files - so we can't handle this as a normal progress
+ //connect( downloader, SIGNAL( downloadProgress( double ) ), this, SLOT( emitDownloadProgress( double ) ) );
+ downloader->setUrl( url );
+ downloader->setAutoRemoveDownloadedFile( false );
+
+ const QString comp = QFileInfo( QFileInfo( archives.first().first ).path() ).fileName();
+ const Component* const component = parent->componentByName( comp );
+
+ emit outputTextChanged( tr( "Downloading archive hash for component %1" ).arg( component->displayName() ) );
+ downloader->download();
+ }
+ else
+ QMetaObject::invokeMethod( this, "fetchNextArchive", Qt::QueuedConnection );
+}
+
+void DownloadArchivesJob::finishedHashDownload()
+{
+ Q_ASSERT( downloader != 0 );
+
+ const QString tempFile = downloader->downloadedFileName();
+ QFile sha1HashFile( tempFile );
+ if ( sha1HashFile.open( QFile::ReadOnly ) )
+ currentHash = sha1HashFile.readAll();
+ else
+ finishWithError( tr( "Downloading hash signature failed" ) );
+
+ temporaryFiles.push_back( tempFile );
+
+ fetchNextArchive();
+}
+
+/**
+ * Fetches the next archive and registers it in the installer.
+ */
+void DownloadArchivesJob::fetchNextArchive()
+{
+ if( cancelled )
+ {
+ finishWithError( tr( "Canceled" ) );
+ return;
+ }
+
+ if( archives.isEmpty() )
+ {
+ emitFinished();
+ return;
+ }
+
+ if( downloader != 0 )
+ downloader->deleteLater();
+
+ const QUrl url( archives.first().second );
+ const QUrl sigUrl = publicKey.isEmpty() ? QUrl() : QUrl( archives.first().second + QLatin1String( ".sig" ) );
+ const CryptoSignatureVerifier verifier( publicKey );
+ downloader = FileDownloaderFactory::instance().create( url.scheme(), publicKey.isEmpty() ? 0 : &verifier, sigUrl, this );
+
+ if ( !downloader ) {
+ archives.pop_front();
+ const QString errMsg = tr("Scheme not supported: %1 (%2)").arg( url.scheme(), url.toString() );
+ verbose() << errMsg;
+ emit outputTextChanged( errMsg );
+ QMetaObject::invokeMethod( this, "fetchNextArchive", Qt::QueuedConnection );
+ return;
+ }
+
+ connect( downloader, SIGNAL( downloadCompleted() ), this, SLOT( registerFile() ), Qt::QueuedConnection );
+ connect( downloader, SIGNAL( downloadCanceled() ), this, SLOT( downloadCanceled() ) );
+ connect( downloader, SIGNAL( downloadAborted( QString ) ), this, SLOT( downloadFailed( QString ) ), Qt::QueuedConnection );
+ connect( downloader, SIGNAL( downloadProgress( double ) ), this, SLOT( emitDownloadProgress( double ) ) );
+ downloader->setUrl( url );
+ downloader->setAutoRemoveDownloadedFile( false );
+
+ const QString archive = QFileInfo( archives.first().first ).fileName();
+ const QString comp = QFileInfo( QFileInfo( archives.first().first ).path() ).fileName();
+ const Component* const component = parent->componentByName( comp );
+
+ emit outputTextChanged( tr( "Downloading archive for component %1" ).arg( component->displayName() ) );
+ emit progressChanged( double(filesDownloaded) / filesToDownload );
+ downloader->download();
+}
+
+
+/**
+ * Emits the global download progress during a single download in a lazy way(uses a timer to reduce to much processChanged).
+ */
+void DownloadArchivesJob::emitDownloadProgress( double progress )
+{
+ lastFileProgress = progress;
+ if (!progressChangedTimerId) {
+ progressChangedTimerId = startTimer(5);
+ }
+}
+
+/**
+ * this is used to reduce the progressChanged signals
+ */
+void DownloadArchivesJob::timerEvent(QTimerEvent *event)
+{
+ if (event->timerId() == progressChangedTimerId) {
+ killTimer(progressChangedTimerId);
+ progressChangedTimerId = 0;
+ emit progressChanged( ( double(filesDownloaded) + lastFileProgress ) / filesToDownload );
+ }
+}
+
+
+/**
+ * Registers the just downloaded file in the intaller's file system.
+ */
+void DownloadArchivesJob::registerFile()
+{
+ Q_ASSERT( downloader != 0 );
+ ++filesDownloaded;
+ if (progressChangedTimerId) {
+ killTimer(progressChangedTimerId);
+ progressChangedTimerId = 0;
+ emit progressChanged( double(filesDownloaded) / filesToDownload );
+ }
+
+ const QString tempFile = downloader->downloadedFileName();
+ QFile archiveFile( tempFile );
+ if ( archiveFile.open( QFile::ReadOnly ) )
+ {
+ if ( parent->testChecksum() )
+ {
+ const QByteArray archiveHash = QCryptographicHash::hash( archiveFile.readAll(), QCryptographicHash::Sha1 ).toHex();
+ if ( archiveHash != currentHash )
+ {
+ const QMessageBox::Button res = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String( "DownloadError" ),
+ tr( "Download Error" ), tr( "Hash verification failed for %1: Hashes do not match" ).arg( tempFile ),
+ QMessageBox::Retry | QMessageBox::Cancel, QMessageBox::Cancel );
+ if ( res == QMessageBox::Cancel )
+ {
+ finishWithError( tr( "Could not verify Hash") );
+ return;
+ }
+ else
+ {
+ fetchNextArchiveHash();
+ return;
+ }
+ }
+ }
+ }
+ else
+ {
+ finishWithError( tr( "Could not open %1" ).arg( tempFile ) );
+ }
+ const QString path = archives.first().first;
+ archives.pop_front();
+ temporaryFiles.push_back( tempFile );
+
+ QInstallerCreator::BinaryFormatEngineHandler::instance()->registerArchive( path, tempFile );
+
+ fetchNextArchiveHash();
+}
+
+void DownloadArchivesJob::downloadCanceled()
+{
+ emitFinishedWithError( Canceled, downloader->errorString() );
+}
+
+void DownloadArchivesJob::downloadFailed( const QString& error )
+{
+ const QMessageBox::StandardButton b = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("archiveDownloadError"),
+ tr("Download Error"),
+ tr("Could not download archive %1: %2").arg( archives.first().second, error ),
+ QMessageBox::Retry | QMessageBox::Cancel );
+ if ( b == QMessageBox::Retry )
+ QMetaObject::invokeMethod( this, "fetchNextArchive", Qt::QueuedConnection );
+ else
+ downloadCanceled();
+}
+
+void DownloadArchivesJob::finishWithError( const QString& error )
+{
+ const FileDownloader* const dl = dynamic_cast< const FileDownloader* >( sender() );
+ if( dl != 0 )
+ emitFinishedWithError( DownloadError, tr( "Could not fetch archives: %1\nError while loading %2" ).arg( error, dl->url().toString() ) );
+ else
+ emitFinishedWithError( DownloadError, tr( "Could not fetch archives: %1\nError while loading %2" ).arg( error, downloader->url().toString() ) );
+}
diff --git a/installerbuilder/libinstaller/downloadarchivesjob.h b/installerbuilder/libinstaller/downloadarchivesjob.h
new file mode 100644
index 000000000..6b4246574
--- /dev/null
+++ b/installerbuilder/libinstaller/downloadarchivesjob.h
@@ -0,0 +1,98 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef DOWNLOADARCHIVESJOB_H
+#define DOWNLOADARCHIVESJOB_H
+
+#include <KDToolsCore/KDJob>
+
+#include <QPair>
+#include <QStringList>
+
+namespace KDUpdater
+{
+ class FileDownloader;
+}
+
+class QTimer;
+
+namespace QInstaller
+{
+
+class MessageBoxHandler;
+class Installer;
+
+class DownloadArchivesJob : public KDJob
+{
+ Q_OBJECT
+public:
+ enum Error
+ {
+ InvalidUrl = KDJob::UserDefinedError,
+ Timeout,
+ DownloadError
+ };
+
+ explicit DownloadArchivesJob(const QByteArray& publicKey, Installer* parent = 0 );
+ ~DownloadArchivesJob();
+
+ void setArchivesToDownload( const QList< QPair< QString, QString > >& archives );
+
+Q_SIGNALS:
+ void progressChanged( double progress );
+ void outputTextChanged( const QString& progress );
+
+protected:
+ void doStart();
+ void doCancel();
+ void timerEvent(QTimerEvent *event);
+
+protected Q_SLOTS:
+ void registerFile();
+ void downloadCanceled();
+ void downloadFailed( const QString& error );
+ void finishWithError( const QString& error );
+ void fetchNextArchive();
+ void fetchNextArchiveHash();
+ void finishedHashDownload();
+ void emitDownloadProgress( double progress );
+
+private:
+ bool cancelled;
+ QList< QPair< QString, QString > > archives;
+ const QByteArray publicKey;
+ KDUpdater::FileDownloader* downloader;
+ QStringList temporaryFiles;
+ int filesToDownload;
+ int filesDownloaded;
+ Installer* parent;
+ QByteArray currentHash;
+ double lastFileProgress;
+ int progressChangedTimerId;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/elevatedexecuteoperation.cpp b/installerbuilder/libinstaller/elevatedexecuteoperation.cpp
new file mode 100644
index 000000000..c255a28af
--- /dev/null
+++ b/installerbuilder/libinstaller/elevatedexecuteoperation.cpp
@@ -0,0 +1,235 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "elevatedexecuteoperation.h"
+
+#include "environment.h"
+#include "fsengineclient.h"
+#include "common/utils.h"
+
+#include <QThread>
+
+#include <QProcessEnvironment>
+
+using namespace QInstaller;
+
+class ElevatedExecuteOperation::Private
+{
+public:
+ explicit Private( ElevatedExecuteOperation* qq )
+ : q( qq ), process(0), showStandardError(false)
+ {
+ }
+ ~Private()
+ {
+ }
+
+private:
+ ElevatedExecuteOperation* const q;
+
+public:
+ void readProcessOutput();
+
+ QProcessWrapper* process;
+ bool showStandardError;
+};
+
+ElevatedExecuteOperation::ElevatedExecuteOperation()
+ : d( new Private( this ) )
+{
+ // this operation has to "overwrite" the Execute operation from KDUpdater
+ setName( QLatin1String( "Execute" ) );
+}
+
+ElevatedExecuteOperation::~ElevatedExecuteOperation()
+{
+}
+
+bool ElevatedExecuteOperation::performOperation()
+{
+ // This operation receives only one argument. It is the complete
+ // command line of the external program to execute.
+ QStringList args = arguments();
+ if( args.isEmpty() )
+ {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %1: %2 arguments given, at least 1 expected.").arg( name(), QString::number( args.count() ) ) );
+ return false;
+ }
+
+ QString workingDirectory;
+ QStringList filteredWorkingDirectoryArgs = args.filter(QLatin1String("workingdirectory="), Qt::CaseInsensitive);
+ if (!filteredWorkingDirectoryArgs.isEmpty()) {
+ QString workingDirectoryArgument = filteredWorkingDirectoryArgs.at(0);
+ workingDirectory = workingDirectoryArgument;
+ workingDirectory.replace(QLatin1String("workingdirectory="), QString(), Qt::CaseInsensitive);
+ args.removeAll(workingDirectoryArgument);
+ }
+
+
+ if ( args.last().endsWith( QLatin1String("showStandardError") ) ) {
+ d->showStandardError = true;
+ args.pop_back();
+ }
+
+ QList< int > allowedExitCodes;
+
+ QRegExp re( QLatin1String( "^\\{((-?\\d+,)*-?\\d+)\\}$" ) );
+ if( re.exactMatch( args.first() ) )
+ {
+ const QStringList numbers = re.cap( 1 ).split( QLatin1Char( ',' ) );
+ for( QStringList::const_iterator it = numbers.constBegin(); it != numbers.constEnd(); ++it )
+ allowedExitCodes.push_back( it->toInt() );
+ args.pop_front();
+ }
+ else
+ {
+ allowedExitCodes.push_back( 0 );
+ }
+
+ const QString callstr = args.join( QLatin1String( " " ) );
+
+ // unix style: when there's an ampersand after the command, it's started detached
+ if( args.count() >= 2 && args.last() == QLatin1String( "&" ) )
+ {
+ args.pop_back();
+ const bool success = QProcess::startDetached( args.front(), args.mid( 1 ) );
+ if ( !success ) {
+ setError( UserDefinedError );
+ setErrorString( tr( "Execution failed: Could not start detached: \"%1\"" ).arg( callstr ) );
+ }
+ return success;
+ }
+
+ d->process = new QProcessWrapper();
+ if (!workingDirectory.isEmpty()) {
+ d->process->setWorkingDirectory( workingDirectory );
+ QInstaller::verbose() << " ElevatedExecuteOperation setWorkingDirectory: " << workingDirectory << std::endl;
+ }
+
+ QProcessEnvironment penv;
+ //there is no way to serialize a QProcessEnvironment properly other than per mangled QStringList :/ (i.e. no other way to list all keys)
+ d->process->setEnvironment( KDUpdater::Environment::instance()->applyTo( penv ).toStringList() );
+
+ if (d->showStandardError)
+ d->process->setProcessChannelMode(QProcess::MergedChannels);
+
+ connect(this, SIGNAL(cancelProcess()), d->process, SLOT(cancel()));
+
+ //we still like the none blocking possibility to perform this operation without threads
+ QEventLoop loop;
+ if (QThread::currentThread() == qApp->thread()) {
+ QObject::connect( d->process, SIGNAL( finished( int, QProcess::ExitStatus ) ), &loop, SLOT( quit() ) );
+ }
+ //readProcessOutput should only called from this current Thread -> Qt::DirectConnection
+ QObject::connect( d->process, SIGNAL( readyRead() ), this, SLOT( readProcessOutput() ), Qt::DirectConnection );
+#ifdef Q_OS_WIN
+ if (args.count() == 1) {
+ d->process->setNativeArguments( args.front() );
+ QInstaller::verbose() << " ElevatedExecuteOperation setNativeArguments to start: " << args.front() << std::endl;
+ d->process->start(QString(), QStringList());
+ } else
+#endif
+ d->process->start( args.front(), args.mid( 1 ) );
+ QInstaller::verbose() << args.front() << " started, arguments: " << QStringList(args.mid( 1 )).join(QLatin1String(" ")) << std::endl;
+
+ bool success = false;
+ //we still like the none blocking possibility to perform this operation without threads
+ if (QThread::currentThread() == qApp->thread()) {
+ success = d->process->waitForStarted();
+ } else {
+ success = d->process->waitForFinished(-1);
+ }
+
+ bool returnValue = true;
+ if ( !success )
+ {
+ setError( UserDefinedError );
+ //TODO: pass errorString() through the wrapper */
+ setErrorString( tr( "Execution failed: Could not start: \"%1\"" ).arg( callstr ) );
+ returnValue = false;
+ }
+
+ if (QThread::currentThread() == qApp->thread()) {
+ if (d->process->state() != QProcess::NotRunning) {
+ loop.exec();
+ }
+ d->readProcessOutput();
+ }
+
+ setValue( QLatin1String( "ExitCode" ), d->process->exitCode() );
+
+ if ( d->process->exitStatus() == QProcess::CrashExit )
+ {
+ setError( UserDefinedError );
+ setErrorString( tr( "Execution failed (Crash): \"%1\"" ).arg( callstr ) );
+ returnValue = false;
+ }
+
+ if ( !allowedExitCodes.contains( d->process->exitCode() ) )
+ {
+ setError( UserDefinedError );
+ setErrorString( tr( "Execution failed (Unexpected exit code: %1): \"%2\"" ).arg( QString::number( d->process->exitCode() ), callstr ) );
+ returnValue = false;
+ }
+
+ Q_ASSERT(d->process);
+ d->process->deleteLater();
+ d->process = 0;
+
+ return returnValue;
+}
+
+/*!
+ Cancels the ElevatedExecuteOperation. This methods tries to terminate the process
+ gracefully by calling QProcess::terminate. After 10 seconds, the process gets killed.
+ */
+void ElevatedExecuteOperation::cancelOperation()
+{
+ emit cancelProcess();
+}
+
+void ElevatedExecuteOperation::Private::readProcessOutput()
+{
+ Q_ASSERT(process);
+ Q_ASSERT(QThread::currentThread() == process->thread());
+ if (QThread::currentThread() != process->thread()) {
+ QInstaller::verbose() << Q_FUNC_INFO << QLatin1String(" can only be called from the same thread as the process is.") << std::endl;
+ }
+ const QByteArray output = process->readAll();
+ if( !output.isEmpty() ) {
+ QInstaller::verbose() << QString::fromLocal8Bit( output ) << std::endl;
+ emit q->outputTextChanged( QString::fromLocal8Bit( output ) );
+ }
+}
+
+#include "moc_elevatedexecuteoperation.cpp"
diff --git a/installerbuilder/libinstaller/elevatedexecuteoperation.h b/installerbuilder/libinstaller/elevatedexecuteoperation.h
new file mode 100644
index 000000000..6fcb5e8de
--- /dev/null
+++ b/installerbuilder/libinstaller/elevatedexecuteoperation.h
@@ -0,0 +1,60 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef ELEVATEDEXECUTEOPERATION_H
+#define ELEVATEDEXECUTEOPERATION_H
+
+#include <KDUpdater/kdupdaterupdateoperations.h>
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include "installer_global.h"
+
+namespace QInstaller {
+
+class INSTALLER_EXPORT ElevatedExecuteOperation : public KDUpdater::ExecuteOperation
+{
+ Q_OBJECT
+public:
+ ElevatedExecuteOperation();
+ ~ElevatedExecuteOperation();
+
+ bool performOperation();
+
+Q_SIGNALS:
+ void cancelProcess();
+
+public Q_SLOTS:
+ void cancelOperation();
+
+private:
+ Q_PRIVATE_SLOT( d, void readProcessOutput() );
+
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+}; // namespace
+
+#endif
diff --git a/installerbuilder/libinstaller/environmentvariablesoperation.cpp b/installerbuilder/libinstaller/environmentvariablesoperation.cpp
new file mode 100644
index 000000000..1c2bde7bc
--- /dev/null
+++ b/installerbuilder/libinstaller/environmentvariablesoperation.cpp
@@ -0,0 +1,239 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "environmentvariablesoperation.h"
+
+#include <stdlib.h>
+
+#include <QtCore/QSettings>
+
+#include "KDUpdater/environment.h"
+
+// this makes us use QSettingsWrapper
+#include "fsengineclient.h"
+
+#ifdef Q_WS_WIN
+# include <windows.h>
+#endif
+
+using namespace QInstaller;
+
+/*
+TRANSLATOR QInstaller::EnvironmentVariablesOperation
+*/
+
+EnvironmentVariableOperation::EnvironmentVariableOperation()
+{
+ setName(QLatin1String("EnvironmentVariable"));
+}
+
+EnvironmentVariableOperation::~EnvironmentVariableOperation()
+{
+}
+
+void EnvironmentVariableOperation::backup()
+{
+}
+
+using namespace KDUpdater;
+
+#ifdef Q_WS_WIN
+static bool broadcastChange() {
+ // Use SendMessageTimeout to Broadcast a message to the whole system to update settings of all
+ // running applications. This is needed to activate the changes done above without logout+login.
+ // Note that cmd.exe does not respond to any WM_SETTINGCHANGE messages...
+ DWORD aResult = 0;
+ LRESULT sendresult = SendMessageTimeout( HWND_BROADCAST, WM_SETTINGCHANGE,
+ 0, (LPARAM) "Environment", SMTO_BLOCK | SMTO_ABORTIFHUNG, 5000, &aResult );
+ if( sendresult == 0 || aResult != 0 ) {
+ qWarning( "Failed to broadcast a WM_SETTINGCHANGE message\n" );
+ return false;
+ }
+
+ return true;
+}
+#endif
+
+namespace {
+
+template <typename SettingsType>
+UpdateOperation::Error writeSetting(const QString &regPath,
+ const QString &name,
+ const QString &value,
+ QString *errorString,
+ QString *oldValue) {
+ oldValue->clear();
+ SettingsType registry(regPath, QSettings::NativeFormat);
+ if (!registry.isWritable()) {
+ *errorString = QObject::tr("Registry path %1 is not writable").arg(regPath);
+ return UpdateOperation::UserDefinedError;
+ }
+
+ // remember old value for undo
+ *oldValue = registry.value(name).toString();
+
+ // set the new value
+ registry.setValue(name, value);
+ registry.sync();
+
+ if(registry.status() != QSettings::NoError) {
+ *errorString = QObject::tr("Could not write to registry path %1").arg(regPath);
+ return UpdateOperation::UserDefinedError;
+ }
+
+ return UpdateOperation::NoError;
+}
+
+template <typename SettingsType>
+UpdateOperation::Error undoSetting(const QString &regPath,
+ const QString &name,
+ const QString &value,
+ const QString &oldValue,
+ QString *errorString) {
+ QString actual;
+ {
+ SettingsType registry(regPath, QSettings::NativeFormat);
+ actual = registry.value(name).toString();
+ }
+ if (actual != value) //key changed, don't undo
+ return UpdateOperation::UserDefinedError;
+ else {
+ QString dontcare;
+ return writeSetting<SettingsType>(regPath, name, oldValue, errorString, &dontcare);
+ }
+}
+
+}
+
+bool EnvironmentVariableOperation::performOperation()
+{
+ if (arguments().count() < 2 || arguments().count() > 4) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2-3 expected.")
+ .arg(name()).arg( arguments().count() ) );
+ return false;
+ }
+
+ const QString name = arguments().at(0);
+ const QString value = arguments().at(1);
+ bool isPersistent = false;
+
+#ifdef Q_WS_WIN
+ isPersistent = arguments().count() >= 3 ? arguments().at(2) == QLatin1String("true") : true;
+ const bool isSystemWide = arguments().count() >= 4 ? arguments().at(3) == QLatin1String("true") : false;
+ QString oldvalue;
+ if (isPersistent)
+ {
+ const QString regPath = isSystemWide ? QLatin1String( "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" )
+ : QLatin1String( "HKEY_CURRENT_USER\\Environment" );
+
+ // write the name=value pair to the global environment
+ QString errorString;
+
+ Error err = NoError;
+
+ err = isSystemWide
+ ? writeSetting<QSettingsWrapper>(regPath, name, value, &errorString, &oldvalue)
+ : writeSetting<QSettings>(regPath, name, value, &errorString, &oldvalue);
+ if (err != NoError) {
+ setError(err);
+ setErrorString(errorString);
+ return false;
+ }
+ const bool bret = broadcastChange();
+ Q_UNUSED(bret); // this is not critical, so fall-through
+ setValue( QLatin1String( "oldvalue" ), oldvalue );
+ return true;
+ }
+#endif
+ Q_ASSERT( !isPersistent );
+
+ setValue( QLatin1String( "oldvalue" ), Environment::instance()->value( name ) );
+ Environment::instance()->setTemporaryValue( name, value );
+
+ return true;
+}
+
+bool EnvironmentVariableOperation::undoOperation()
+{
+ if (arguments().count() < 2 || arguments().count() > 4)
+ return false;
+
+ const QString name = arguments().at(0);
+ const QString value = arguments().at(1);
+ const QString oldvalue = this->value( QLatin1String("oldvalue") ).toString();
+
+#ifdef Q_WS_WIN
+ const bool isPersistent = arguments().count() >= 3 ? arguments().at(2) == QLatin1String("true") : true;
+#else
+ const bool isPersistent = false;
+#endif
+
+ if ( !isPersistent ) {
+ const QString actual = Environment::instance()->value( name );
+ const bool doUndo = actual == value;
+ if ( doUndo )
+ Environment::instance()->setTemporaryValue( name, oldvalue );
+ return doUndo;
+ }
+
+#ifdef Q_WS_WIN
+ const bool isSystemWide = arguments().count() >= 4 ? arguments().at(3) == QLatin1String("true") : false;
+
+ const QString regPath = isSystemWide ? QLatin1String( "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" )
+ : QLatin1String( "HKEY_CURRENT_USER\\Environment" );
+
+ QString errorString;
+
+ const Error err = isSystemWide
+ ? undoSetting<QSettingsWrapper>(regPath, name, value, oldvalue, &errorString)
+ : undoSetting<QSettings>(regPath, name, value, oldvalue, &errorString);
+
+ if (err != NoError) {
+ setError(err);
+ setErrorString(errorString);
+ return false;
+ }
+#endif
+
+ return true;
+}
+
+bool EnvironmentVariableOperation::testOperation()
+{
+ return true;
+}
+
+EnvironmentVariableOperation* EnvironmentVariableOperation::clone() const
+{
+ return new EnvironmentVariableOperation();
+}
diff --git a/installerbuilder/libinstaller/environmentvariablesoperation.h b/installerbuilder/libinstaller/environmentvariablesoperation.h
new file mode 100644
index 000000000..dedfa095d
--- /dev/null
+++ b/installerbuilder/libinstaller/environmentvariablesoperation.h
@@ -0,0 +1,53 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef ENVIRONMENTVARIABLESOPERATION_H
+#define ENVIRONMENTVARIABLESOPERATION_H
+
+#include "installer_global.h"
+
+#include <KDUpdater/UpdateOperation>
+#include <QtCore/QObject>
+#include <QtCore/QString>
+
+namespace QInstaller {
+
+class INSTALLER_EXPORT EnvironmentVariableOperation : public QObject, public KDUpdater::UpdateOperation
+{
+ Q_OBJECT
+public:
+ EnvironmentVariableOperation();
+ ~EnvironmentVariableOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ EnvironmentVariableOperation* clone() const;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/extractarchiveoperation.cpp b/installerbuilder/libinstaller/extractarchiveoperation.cpp
new file mode 100644
index 000000000..9c2121f7b
--- /dev/null
+++ b/installerbuilder/libinstaller/extractarchiveoperation.cpp
@@ -0,0 +1,198 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "extractarchiveoperation.h"
+#include "extractarchiveoperation_p.h"
+
+#include <QEventLoop>
+#include <QThread>
+#include <QThreadPool>
+
+#include <QDebug>
+
+using namespace QInstaller;
+
+/*
+TRANSLATOR QInstaller::ExtractArchiveOperation
+*/
+
+ExtractArchiveOperation::ExtractArchiveOperation()
+{
+ setName( QLatin1String( "Extract" ) );
+}
+
+ExtractArchiveOperation::~ExtractArchiveOperation()
+{
+}
+
+void ExtractArchiveOperation::backup()
+{
+ // we need to backup on the fly...
+}
+
+bool ExtractArchiveOperation::performOperation()
+{
+ const QStringList args = arguments();
+ if( args.count() != 2 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg( args.count() ) );
+ return false;
+ }
+
+ const QString archivePath = args.first();
+ const QString targetDir = args.at( 1 );
+
+ Receiver receiver;
+ Callback callback;
+
+ connect( &callback, SIGNAL(progressChanged(QString)), this, SLOT(slotProgressChanged(QString)), Qt::QueuedConnection );
+ connect( &callback, SIGNAL(progressChanged(int)), this, SIGNAL(progressChanged(int)), Qt::QueuedConnection );
+
+ if(QInstaller::Installer *installer = this->value( QLatin1String( "installer" )).value<QInstaller::Installer*>()) {
+ connect( installer, SIGNAL( statusChanged( QInstaller::Installer::Status ) ), &callback,
+ SLOT( statusChanged( QInstaller::Installer::Status ) ), Qt::QueuedConnection );
+ }
+
+ //Runnable is derived from QRunable which will be deleted by the ThreadPool -> no parent is needed
+ Runnable* runnable = new Runnable( archivePath, targetDir, &callback );
+ connect( runnable, SIGNAL(finished(bool,QString)), &receiver, SLOT(runnableFinished(bool,QString)), Qt::QueuedConnection );
+ QEventLoop loop;
+ connect( &receiver, SIGNAL( finished() ), &loop, SLOT( quit() ) );
+ if (QThreadPool::globalInstance()->tryStart(runnable)) {
+ loop.exec();
+ } else {
+ //in case there is no availabe thread we should call it directly
+ //this is more a hack
+ runnable->run();
+ receiver.runnableFinished(true, QString());
+ }
+
+ typedef QPair<QString, QString> StringPair;
+ QVector<StringPair> backupFiles = callback.backupFiles;
+
+ //TODO use backups for rollback, too? doesn't work for uninstallation though
+
+ //delete all backups we can delete right now, remember the rest
+ Q_FOREACH( const StringPair& i, backupFiles )
+ deleteFileNowOrLater( i.second );
+
+ if ( !receiver.success ) {
+ setError( UserDefinedError );
+ setErrorString( receiver.errorString );
+ return false;
+ }
+ return true;
+}
+
+WorkerThread::WorkerThread( ExtractArchiveOperation *op, const QStringList &files, QObject* parent )
+ : QThread( parent )
+ , m_files( files )
+ , m_op( op )
+{
+}
+
+/*!
+ \reimp
+*/
+void WorkerThread::run()
+{
+ ExtractArchiveOperation* const op = m_op;//dynamic_cast< ExtractArchiveOperation* >( parent() );
+ Q_ASSERT( op != 0 );
+
+ int progress = -1;
+ int index = 0;
+ const int count = m_files.count();
+ Q_FOREACH( const QString &file, m_files )
+ {
+ const QFileInfo fi( file );
+ emit outputTextChanged( file );
+ if( fi.isFile() || fi.isSymLink() )
+ {
+ op->deleteFileNowOrLater( fi.absoluteFilePath() );
+ }
+ else if( fi.isDir() )
+ {
+ const QDir d = fi.dir();
+ // even remove some hidden, OS-created files in there
+#if defined Q_WS_MAC
+ op->deleteFileNowOrLater( file + QLatin1String( "/.DS_Store" ) );
+#elif defined Q_WS_WIN
+ op->deleteFileNowOrLater( file + QLatin1String( "/Thumbs.db" ) );
+#endif
+ d.rmdir( file ); // directory may not exist
+ }
+ const int newProgress = (index++) * 100 / count;
+ if( progress != newProgress )
+ emit progressChanged( newProgress );
+ progress = newProgress;
+ }
+}
+
+bool ExtractArchiveOperation::undoOperation()
+{
+ Q_ASSERT( arguments().count() == 2 );
+ //const QString archivePath = arguments().first();
+ //const QString targetDir = arguments().last();
+
+ const QStringList m_files = value( QLatin1String( "files" ) ).toStringList();
+
+ WorkerThread* const thread = new WorkerThread( this, m_files );
+ connect(thread, SIGNAL(outputTextChanged(QString)),
+ this, SIGNAL(outputTextChanged(QString)), Qt::QueuedConnection);
+ connect( thread, SIGNAL( progressChanged( int ) ), this, SIGNAL( progressChanged( int ) ), Qt::QueuedConnection );
+
+ QEventLoop loop;
+ connect( thread, SIGNAL(finished()), &loop, SLOT( quit() ), Qt::QueuedConnection );
+ thread->start();
+ loop.exec();
+ thread->deleteLater();
+ return true;
+}
+
+bool ExtractArchiveOperation::testOperation()
+{
+ return true;
+}
+
+ExtractArchiveOperation* ExtractArchiveOperation::clone() const
+{
+ return new ExtractArchiveOperation();
+}
+
+void ExtractArchiveOperation::slotProgressChanged( const QString& filename )
+{
+ QStringList m_files = value( QLatin1String( "files" ) ).toStringList();
+ m_files.push_front( filename );
+ setValue( QLatin1String( "files" ), m_files );
+ emit outputTextChanged( filename );
+}
diff --git a/installerbuilder/libinstaller/extractarchiveoperation.h b/installerbuilder/libinstaller/extractarchiveoperation.h
new file mode 100644
index 000000000..faf1e64df
--- /dev/null
+++ b/installerbuilder/libinstaller/extractarchiveoperation.h
@@ -0,0 +1,66 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef EXTRACTARCHIVEOPERATION_H
+#define EXTRACTARCHIVEOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+#include <QtCore/QObject>
+
+#include "installer_global.h"
+
+namespace QInstaller {
+
+class INSTALLER_EXPORT ExtractArchiveOperation : public QObject, public KDUpdater::UpdateOperation
+{
+ Q_OBJECT
+
+ friend class WorkerThread;
+public:
+ ExtractArchiveOperation();
+ ~ExtractArchiveOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ ExtractArchiveOperation* clone() const;
+
+Q_SIGNALS:
+ void progressChanged( int progress );
+ void outputTextChanged( const QString& progress );
+
+private Q_SLOTS:
+ void slotProgressChanged( const QString& progress );
+
+private:
+ class Callback;
+ class Runnable;
+ class Receiver;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/extractarchiveoperation_p.h b/installerbuilder/libinstaller/extractarchiveoperation_p.h
new file mode 100644
index 000000000..e23b34dff
--- /dev/null
+++ b/installerbuilder/libinstaller/extractarchiveoperation_p.h
@@ -0,0 +1,207 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef EXTRACTARCHIVEOPERATION_P_H
+#define EXTRACTARCHIVEOPERATION_P_H
+
+#include "extractarchiveoperation.h"
+#include "lib7z_facade.h"
+#include "qinstaller.h"
+
+#include <QDir>
+#include <QFile>
+#include <QPair>
+#include <QThread>
+#include <QVector>
+
+#include <cassert>
+
+namespace QInstaller {
+
+class WorkerThread : public QThread
+{
+ Q_OBJECT
+public:
+ WorkerThread( ExtractArchiveOperation *op, const QStringList &files, QObject* parent = NULL );
+
+ void run();
+
+Q_SIGNALS:
+ void outputTextChanged( const QString& filename );
+ void progressChanged( int progress );
+
+
+private:
+ QStringList m_files;
+ ExtractArchiveOperation* m_op;
+};
+
+
+class ExtractArchiveOperation::Callback : public QObject, public Lib7z::ExtractCallback
+{
+ Q_OBJECT
+public:
+ int lastProgress;
+ HRESULT state;
+ bool createBackups;
+ QVector<QPair<QString, QString> > backupFiles;
+
+ explicit Callback()
+ : lastProgress( -1 ),
+ state( S_OK ),
+ createBackups( true )
+ {
+ }
+
+Q_SIGNALS:
+ void progressChanged( const QString& filename );
+ void progressChanged( int );
+
+public Q_SLOTS:
+ void statusChanged( QInstaller::Installer::Status status )
+ {
+ switch( status ) {
+ case Installer::InstallerCanceledByUser:
+ state = E_ABORT;
+ break;
+ case Installer::InstallerFailed:
+ state = E_FAIL;
+ break;
+ case Installer::InstallerUnfinished: // fall through
+ case Installer::InstallerSucceeded:
+ case Installer::InstallerRunning:
+ //state = S_OK;
+ break;
+ }
+ }
+
+protected:
+ /* reimp */ void setCurrentFile( const QString& filename )
+ {
+ emit progressChanged( QDir::toNativeSeparators( filename ) );
+ }
+
+ static QString generateBackupName( const QString& fn ) {
+ const QString bfn = fn + QLatin1String(".tmpUpdate" );
+ QString res = bfn;
+ int i = 0;
+ while ( QFile::exists( res ) )
+ res = bfn + QString::fromLatin1(".%1").arg( i++ );
+ return res;
+ }
+
+ /* reimp */
+ bool prepareForFile( const QString& filename )
+ {
+ if ( !createBackups )
+ return true;
+ if ( !QFile::exists( filename ) )
+ return true;
+ const QString backup = generateBackupName( filename );
+ QFile f( filename );
+ const bool renamed = f.rename( backup );
+ if ( f.exists() && !renamed ) {
+ qCritical("Could not rename %s to %s: %s", qPrintable(filename), qPrintable(backup), qPrintable(f.errorString()) );
+ return false;
+ }
+ backupFiles.push_back( qMakePair( filename, backup ) );
+ return true;
+ }
+
+ /* reimp */ HRESULT setCompleted( quint64 completed, quint64 total )
+ {
+ assert( total != 0 );
+ const int progress = ( 100 * completed ) / total;
+ if( progress != lastProgress )
+ emit progressChanged( progress );
+ lastProgress = progress;
+ return state;
+ }
+};
+
+class ExtractArchiveOperation::Runnable : public QObject, public QRunnable
+{
+ Q_OBJECT
+public:
+ Runnable( const QString& archivePath_, const QString& targetDir_, ExtractArchiveOperation::Callback* callback_ )
+ : QObject(), QRunnable(), archivePath( archivePath_ ),
+ targetDir( targetDir_ ),
+ callback( callback_ )
+ {
+ }
+
+ /* reimp */ void run()
+ {
+ QFile archive( archivePath );
+ if ( !archive.open( QIODevice::ReadOnly ) ) {
+
+ emit finished( false, tr("Could not open %1 for reading: %2.").arg( archivePath, archive.errorString() ) );
+ return;
+ }
+ try {
+ Lib7z::extractArchive( &archive, targetDir, callback );
+ emit finished( true, QString() );
+ } catch ( const Lib7z::SevenZipException& e ) {
+ #ifdef Q_WS_WIN
+ emit finished( false, tr("Error while extracting %1: %2. (Maybe the target dir(%3) is blocked by another process.)").arg( archivePath, e.message(), targetDir ) );
+ #else
+ emit finished( false, tr("Error while extracting %1: %2.").arg( archivePath, e.message() ) );
+ #endif
+ } catch ( ... ) {
+ emit finished( false, tr("Unknown exception caught while extracting %1.").arg( archivePath ) );
+ }
+ }
+
+Q_SIGNALS:
+ void finished( bool success, const QString& errorString );
+
+private:
+ const QString archivePath;
+ const QString targetDir;
+ ExtractArchiveOperation::Callback* const callback;
+};
+
+class ExtractArchiveOperation::Receiver : public QObject {
+ Q_OBJECT
+public:
+ explicit Receiver( QObject* parent=0 ) : QObject( parent ), success( false ) {}
+
+public Q_SLOTS:
+ void runnableFinished( bool ok, const QString& msg ) {
+ success = ok;
+ errorString = msg;
+ emit finished();
+ }
+
+Q_SIGNALS:
+ void finished();
+public:
+ bool success;
+ QString errorString;
+};
+
+}
+
+#endif // EXTRACTARCHIVEOPERATION_P_H
diff --git a/installerbuilder/libinstaller/fakestopprocessforupdateoperation.cpp b/installerbuilder/libinstaller/fakestopprocessforupdateoperation.cpp
new file mode 100644
index 000000000..1457a48b6
--- /dev/null
+++ b/installerbuilder/libinstaller/fakestopprocessforupdateoperation.cpp
@@ -0,0 +1,138 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "fakestopprocessforupdateoperation.h"
+#include <QtCore/QDir>
+
+#include <KDToolsCore/KDSysInfo>
+
+#include <algorithm>
+
+/*!
+ Copied from QInstaller with some adjustments
+ Return true, if a process with \a name is running. On Windows, the comparision is case-insensitive.
+ */
+static bool isProcessRunning( const QString& name, const QList< KDSysInfo::ProcessInfo > &processes )
+{
+ for( QList< KDSysInfo::ProcessInfo >::const_iterator it = processes.constBegin(); it != processes.constEnd(); ++it )
+ {
+ if (it->name.isEmpty()) {
+ continue;
+ }
+#ifndef Q_WS_WIN
+ if( it->name == name )
+ return true;
+ const QFileInfo fi( it->name );
+ if( fi.fileName() == name || fi.baseName() == name )
+ return true;
+#else
+ if( it->name.toLower() == name.toLower() )
+ return true;
+ if( it->name.toLower() == QDir::toNativeSeparators(name.toLower()) )
+ return true;
+ const QFileInfo fi( it->name );
+ if( fi.fileName().toLower() == name.toLower() || fi.baseName().toLower() == name.toLower() )
+ return true;
+#endif
+ }
+ return false;
+}
+
+static QStringList checkRunningProcessesFromList(const QStringList &processList)
+{
+ const QList< KDSysInfo::ProcessInfo > allProcesses = KDSysInfo::runningProcesses();
+ QStringList stillRunningProcesses;
+ foreach(const QString process, processList) {
+ if (!process.isEmpty() && isProcessRunning(process, allProcesses)) {
+ stillRunningProcesses.append(process);
+ }
+ }
+ return stillRunningProcesses;
+}
+
+using namespace QInstaller;
+
+FakeStopProcessForUpdateOperation::FakeStopProcessForUpdateOperation()
+{
+ setName( QLatin1String( "FakeStopProcessForUpdate" ) );
+}
+
+FakeStopProcessForUpdateOperation::~FakeStopProcessForUpdateOperation()
+{
+
+}
+
+void FakeStopProcessForUpdateOperation::backup()
+{
+
+}
+
+bool FakeStopProcessForUpdateOperation::performOperation()
+{
+ return true;
+}
+
+bool FakeStopProcessForUpdateOperation::undoOperation()
+{
+ setError( KDUpdater::UpdateOperation::NoError );
+ if ( arguments().size() != 1)
+ {
+ setError( KDUpdater::UpdateOperation::InvalidArguments, QObject::tr( "Number of arguments does not match : one is required" ) );
+ return false;
+ }
+
+ QStringList processList = arguments()[0].split( QLatin1String( "," ), QString::SkipEmptyParts );
+ qSort( processList );
+ processList.erase( std::unique( processList.begin(), processList.end() ), processList.end() );
+ if ( !processList.isEmpty() )
+ {
+ const QStringList processes = checkRunningProcessesFromList( processList );
+ if ( !processes.isEmpty() )
+ {
+ setError( KDUpdater::UpdateOperation::UserDefinedError,
+ tr( "These processes should be stopped to continue:\n\n%1" )
+ .arg( QDir::toNativeSeparators( processes.join( QLatin1String("\n") ) ) ) );
+ }
+ return false;
+ }
+ return true;
+}
+
+bool FakeStopProcessForUpdateOperation::testOperation()
+{
+ return true;
+}
+
+FakeStopProcessForUpdateOperation* FakeStopProcessForUpdateOperation::clone() const
+{
+ return new FakeStopProcessForUpdateOperation();
+}
diff --git a/installerbuilder/libinstaller/fakestopprocessforupdateoperation.h b/installerbuilder/libinstaller/fakestopprocessforupdateoperation.h
new file mode 100644
index 000000000..f7a6a8e60
--- /dev/null
+++ b/installerbuilder/libinstaller/fakestopprocessforupdateoperation.h
@@ -0,0 +1,49 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef FAKESTOPPROCESSFORUPDATEOPERATION_H
+#define FAKESTOPPROCESSFORUPDATEOPERATION_H
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class FakeStopProcessForUpdateOperation : public KDUpdater::UpdateOperation
+{
+
+public:
+ FakeStopProcessForUpdateOperation();
+ ~FakeStopProcessForUpdateOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ FakeStopProcessForUpdateOperation* clone() const;
+
+};
+
+}
+
+#endif // FAKESTOPPROCESSFORUPDATEOPERATION_H
diff --git a/installerbuilder/libinstaller/files-to-patch-linux b/installerbuilder/libinstaller/files-to-patch-linux
new file mode 100644
index 000000000..9c7b39f4a
--- /dev/null
+++ b/installerbuilder/libinstaller/files-to-patch-linux
@@ -0,0 +1,72 @@
+bin/qmake
+bin/lrelease
+lib/libQtCore.so
+%%
+lib/libQtCore.la
+lib/libQt3Support.la
+lib/libQtCLucene.la
+lib/libQtDBus.la
+lib/libQtDeclarative.la
+lib/libQtGui.la
+lib/libQtHelp.la
+lib/libQtMultimedia.la
+lib/libQtNetwork.la
+lib/libQtOpenGL.la
+lib/libphonon.la
+lib/libQtScript.la
+lib/libQtScriptTools.la
+lib/libQtSql.la
+lib/libQtSvg.la
+lib/libQtTest.la
+lib/libQtWebKit.la
+lib/libQtXml.la
+lib/libQtXmlPatterns.la
+demos/shared/libdemo_shared.prl
+lib/libQt3Support.prl
+lib/libQtAssistantClient.prl
+lib/libQtCLucene.prl
+lib/libQtCore.prl
+lib/libQtDBus.prl
+lib/libQtDesignerComponents.prl
+lib/libQtDesigner.prl
+lib/libQtDeclarative.prl
+lib/libQtGui.prl
+lib/libQtHelp.prl
+lib/libQtMultimedia.prl
+lib/libQtNetwork.prl
+lib/libQtOpenGL.prl
+lib/libQtScript.prl
+lib/libQtScriptTools.prl
+lib/libQtSql.prl
+lib/libQtSvg.prl
+lib/libQtTest.prl
+lib/libQtUiTools.prl
+lib/libQtWebKit.prl
+lib/libQtXmlPatterns.prl
+lib/libQtXml.prl
+lib/libphonon.prl
+lib/libqtmain.prl
+lib/pkgconfig/phonon.pc
+lib/pkgconfig/Qt3Support.pc
+lib/pkgconfig/QtAssistantClient.pc
+lib/pkgconfig/QtCLucene.pc
+lib/pkgconfig/QtCore.pc
+lib/pkgconfig/QtDBus.pc
+lib/pkgconfig/QtDeclarative.pc
+lib/pkgconfig/QtDesignerComponents.pc
+lib/pkgconfig/QtDesigner.pc
+lib/pkgconfig/QtGui.pc
+lib/pkgconfig/QtHelp.pc
+lib/pkgconfig/QtMultimedia.pc
+lib/pkgconfig/QtNetwork.pc
+lib/pkgconfig/QtOpenGL.pc
+lib/pkgconfig/QtScript.pc
+lib/pkgconfig/QtScriptTools.pc
+lib/pkgconfig/QtSql.pc
+lib/pkgconfig/QtSvg.pc
+lib/pkgconfig/QtTest.pc
+lib/pkgconfig/QtUiTools.pc
+lib/pkgconfig/QtWebKit.pc
+lib/pkgconfig/QtXmlPatterns.pc
+lib/pkgconfig/QtXml.pc
+mkspecs/qconfig.pri
diff --git a/installerbuilder/libinstaller/files-to-patch-macx b/installerbuilder/libinstaller/files-to-patch-macx
new file mode 100644
index 000000000..7f8deda14
--- /dev/null
+++ b/installerbuilder/libinstaller/files-to-patch-macx
@@ -0,0 +1,61 @@
+bin/qmake
+bin/lrelease
+bin/lconvert
+bin/lupdate
+bin/macdeployqt
+bin/qcollectiongenerator
+bin/qdoc3
+bin/qhelpgenerator
+bin/qt3to4
+bin/xmlpatterns
+bin/xmlpatternsvalidator
+lib/QtCore.framework/QtCore
+bin/Designer.app/Contents/MacOS/Designer
+bin/Linguist.app/Contents/MacOS/Linguist
+bin/qhelpconverter.app/Contents/MacOS/qhelpconverter
+bin/QMLViewer.app/Contents/MacOS/QMLViewer
+bin/qttracereplay.app/Contents/MacOS/qttracereplay
+%%
+lib/QtCore.la
+lib/libQtCLucene.la
+lib/QtDeclarative.la
+lib/QtGui.la
+lib/QtHelp.la
+lib/QtMultimedia.la
+lib/QtNetwork.la
+lib/QtOpenGL.la
+lib/phonon.la
+lib/QtScript.la
+lib/QtScriptTools.la
+lib/QtSql.la
+lib/QtSvg.la
+lib/QtTest.la
+lib/QtWebKit.la
+lib/QtXml.la
+lib/QtXmlPatterns.la
+lib/libQtCLucene.prl
+lib/libQtUiTools.prl
+lib/pkgconfig/phonon.pc
+lib/pkgconfig/Qt3Support.pc
+lib/pkgconfig/QtAssistantClient.pc
+lib/pkgconfig/QtCLucene.pc
+lib/pkgconfig/QtCore.pc
+lib/pkgconfig/QtDBus.pc
+lib/pkgconfig/QtDeclarative.pc
+lib/pkgconfig/QtDesignerComponents.pc
+lib/pkgconfig/QtDesigner.pc
+lib/pkgconfig/QtGui.pc
+lib/pkgconfig/QtHelp.pc
+lib/pkgconfig/QtMultimedia.pc
+lib/pkgconfig/QtNetwork.pc
+lib/pkgconfig/QtOpenGL.pc
+lib/pkgconfig/QtScript.pc
+lib/pkgconfig/QtScriptTools.pc
+lib/pkgconfig/QtSql.pc
+lib/pkgconfig/QtSvg.pc
+lib/pkgconfig/QtTest.pc
+lib/pkgconfig/QtUiTools.pc
+lib/pkgconfig/QtWebKit.pc
+lib/pkgconfig/QtXmlPatterns.pc
+lib/pkgconfig/QtXml.pc
+mkspecs/qconfig.pri
diff --git a/installerbuilder/libinstaller/files-to-patch-windows b/installerbuilder/libinstaller/files-to-patch-windows
new file mode 100644
index 000000000..845a299ce
--- /dev/null
+++ b/installerbuilder/libinstaller/files-to-patch-windows
@@ -0,0 +1,60 @@
+bin/qmake.exe
+bin/lrelease.exe
+bin/QtCore4.dll
+bin/QtCored4.dll
+lib/QtCore4.dll
+lib/QtCored4.dll
+%%
+mkspecs/default/qmake.conf
+demos/shared/libdemo_shared.prl
+lib/Qt3Support.prl
+lib/QtAssistantClient.prl
+lib/QtCLucene.prl
+lib/QtCore.prl
+lib/QtDesignerComponents.prl
+lib/QtDesigner.prl
+lib/QtGui.prl
+lib/QtHelp.prl
+lib/QtMultimedia.prl
+lib/QtNetwork.prl
+lib/QtOpenGL.prl
+lib/QtScript.prl
+lib/QtScriptTools.prl
+lib/QtSql.prl
+lib/QtSvg.prl
+lib/QtTest.prl
+lib/QtUiTools.prl
+lib/QtWebKit.prl
+lib/QtXmlPatterns.prl
+lib/QtXml.prl
+lib/Qt3Supportd.prl
+lib/QtAssistantClientd.prl
+lib/QtCLucened.prl
+lib/QtCored.prl
+lib/QtDesignerComponentsd.prl
+lib/QtDesignerd.prl
+lib/QtGuid.prl
+lib/QtHelpd.prl
+lib/QtMultimediad.prl
+lib/QtNetworkd.prl
+lib/QtOpenGLd.prl
+lib/QtScriptd.prl
+lib/QtScriptToolsd.prl
+lib/QtSqld.prl
+lib/QtSvgd.prl
+lib/QtTestd.prl
+lib/QtUiToolsd.prl
+lib/QtWebKitd.prl
+lib/QtXmlPatternsd.prl
+lib/QtXmld.prl
+lib/phonon.prl
+lib/phonond.prl
+lib/QtDeclarative.prl
+lib/QtDeclaratived.prl
+lib/qtmain.prl
+lib/qtmaind.prl
+lib/QAxContainer.prl
+lib/QAxContainerd.prl
+lib/QAxServer.prl
+lib/QAxServerd.prl
+.qmake.cache
diff --git a/installerbuilder/libinstaller/fsengineclient.cpp b/installerbuilder/libinstaller/fsengineclient.cpp
new file mode 100644
index 000000000..9b322900d
--- /dev/null
+++ b/installerbuilder/libinstaller/fsengineclient.cpp
@@ -0,0 +1,1634 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "fsengineclient.h"
+
+#undef QSettings
+#undef QProcess
+
+#include "adminauthorization.h"
+
+#include <QAbstractFileEngineHandler>
+#include <QCoreApplication>
+#include <QFSFileEngine>
+#include <QHostAddress>
+#include <QTcpSocket>
+#include <QLocalSocket>
+#include <QDataStream>
+#include <QProcess>
+#include <QMutex>
+#include <QUuid>
+#include <QEventLoop>
+#include <QThread>
+#include <QTimer>
+#include <QDebug>
+
+#include <KDToolsCore/KDMetaMethodIterator>
+
+/*!
+ This thread convinces the watchdog in the running server that the client has
+ not crashed yet.
+ */
+class StillAliveThread : public QThread
+{
+ Q_OBJECT
+public:
+ void run()
+ {
+ QTimer stillAliveTimer;
+ connect( &stillAliveTimer, SIGNAL( timeout() ), this, SLOT( stillAlive() ) );
+ stillAliveTimer.start( 1000 );
+ exec();
+ }
+
+public Q_SLOTS:
+ void stillAlive()
+ {
+ if( !FSEngineClientHandler::instance()->isServerRunning() )
+ return;
+
+ // in case of the server not running, this will simply fail
+#ifdef FSENGINE_TCP
+ QTcpSocket socket;
+#else
+ QLocalSocket socket;
+#endif
+ FSEngineClientHandler::instance()->connect( &socket );
+ }
+};
+
+class FSEngineClient : public QAbstractFileEngine
+{
+public:
+ FSEngineClient();
+ ~FSEngineClient();
+
+ bool atEnd() const;
+ Iterator* beginEntryList( QDir::Filters filters, const QStringList& filterNames );
+ bool caseSensitive() const;
+ bool close();
+ bool copy( const QString& newName );
+ QStringList entryList( QDir::Filters filters, const QStringList& filterNames ) const;
+ QFile::FileError error() const;
+ QString errorString() const;
+ bool extension( Extension extension, const ExtensionOption* option = 0, ExtensionReturn* output = 0 );
+ FileFlags fileFlags( FileFlags type = FileInfoAll ) const;
+ QString fileName( FileName file = DefaultName ) const;
+ bool flush();
+ int handle() const;
+ bool isRelativePath() const;
+ bool isSequential() const;
+ bool link( const QString& newName );
+ bool mkdir( const QString& dirName, bool createParentDirectories ) const;
+ bool open( QIODevice::OpenMode mode );
+ QString owner( FileOwner owner ) const;
+ uint ownerId( FileOwner owner ) const;
+ qint64 pos() const;
+ qint64 read( char* data, qint64 maxlen );
+ qint64 readLine( char* data, qint64 maxlen );
+ bool remove();
+ bool rename( const QString& newName );
+ bool rmdir( const QString& dirName, bool recurseParentDirectories ) const;
+ bool seek( qint64 offset );
+ void setFileName( const QString& fileName );
+ bool setPermissions( uint perms );
+ bool setSize( qint64 size );
+ qint64 size() const;
+ bool supportsExtension( Extension extension ) const;
+ qint64 write( const char* data, qint64 len );
+
+private:
+ friend class FSEngineClientHandler;
+#ifdef FSENGINE_TCP
+ mutable QTcpSocket* socket;
+#else
+ mutable QLocalSocket* socket;
+#endif
+ mutable QDataStream stream;
+};
+
+
+
+#define RETURN( T ) { \
+ socket->flush(); \
+ if( !socket->bytesAvailable() ) \
+ socket->waitForReadyRead(); \
+ quint32 test;\
+ stream >> test;\
+ T result; \
+ stream >> result; \
+ return result; \
+}
+
+#define RETURN_VOID { \
+ socket->flush(); \
+ if( !socket->bytesAvailable() ) \
+ socket->waitForReadyRead(); \
+ quint32 test;\
+ stream >> test;\
+ return; \
+}
+
+
+#define RETURN_CASTED( T ) { \
+ socket->flush(); \
+ if( !socket->bytesAvailable() ) \
+ socket->waitForReadyRead(); \
+ quint32 test;\
+ stream >> test;\
+ int result; \
+ stream >> result; \
+ return static_cast< T >( result ); \
+}
+
+#define RETURN_METHOD( T, NAME ) T FSEngineClient::NAME() const { \
+stream << QString::fromLatin1( "QFSFileEngine::"#NAME ); \
+RETURN( T ); \
+}
+
+#define ENUM_RETURN_METHOD( T, NAME ) T FSEngineClient::NAME() const { \
+stream << QString::fromLatin1( "QFSFileEngine::"#NAME ); \
+RETURN_CASTED( T ) \
+}
+
+/*!
+ \internal
+ */
+class FSEngineClientIterator : public QAbstractFileEngineIterator
+{
+public:
+ FSEngineClientIterator( QDir::Filters filters, const QStringList& nameFilters, const QStringList& files )
+ : QAbstractFileEngineIterator( filters, nameFilters ),
+ entries( files ),
+ index( -1 )
+ {
+ }
+
+ /*!
+ \reimp
+ */
+ bool hasNext() const
+ {
+ return index < entries.size() - 1;
+ }
+
+ /*!
+ \reimp
+ */
+ QString next()
+ {
+ if( !hasNext() )
+ return QString();
+ ++index;
+ return currentFilePath();
+ }
+
+ /*!
+ \reimp
+ */
+ QString currentFileName() const
+ {
+ return entries.at( index );
+ }
+
+private:
+ const QStringList entries;
+ int index;
+};
+
+#ifdef FSENGINE_TCP
+FSEngineClient::FSEngineClient()
+ : socket( new QTcpSocket )
+{
+ FSEngineClientHandler::instance()->connect( socket );
+ stream.setDevice( socket );
+ stream.setVersion( QDataStream::Qt_4_2 );
+}
+#else
+FSEngineClient::FSEngineClient()
+ : socket( new QLocalSocket )
+{
+ FSEngineClientHandler::instance()->connect( socket );
+ stream.setDevice( socket );
+ stream.setVersion( QDataStream::Qt_4_2 );
+}
+#endif
+
+FSEngineClient::~FSEngineClient()
+{
+ if( QThread::currentThread() == socket->thread() )
+ {
+ socket->close();
+ delete socket;
+ }
+ else
+ {
+ socket->deleteLater();
+ }
+}
+
+/*!
+ \reimp
+ */
+RETURN_METHOD( bool, atEnd )
+
+/*!
+ \reimp
+ */
+QAbstractFileEngine::Iterator* FSEngineClient::beginEntryList( QDir::Filters filters, const QStringList& filterNames )
+{
+ QStringList entries = entryList( filters, filterNames );
+ entries.removeAll( QString() );
+ return new FSEngineClientIterator( filters, filterNames, entries );
+}
+
+/*!
+ \reimp
+ */
+RETURN_METHOD( bool, caseSensitive )
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::close()
+{
+ stream << QString::fromLatin1( "QFSFileEngine::close" );
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::copy( const QString& newName )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::copy" );
+ stream << newName;
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+QStringList FSEngineClient::entryList( QDir::Filters filters, const QStringList& filterNames ) const
+{
+ stream << QString::fromLatin1( "QFSFileEngine::entryList" );
+ stream << static_cast< int >( filters );
+ stream << filterNames;
+ RETURN( QStringList )
+}
+
+/*!
+ \reimp
+ */
+ENUM_RETURN_METHOD( QFile::FileError, error )
+
+/*!
+ \reimp
+ */
+RETURN_METHOD( QString, errorString )
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::extension( Extension extension, const ExtensionOption* option, ExtensionReturn* output )
+{
+ Q_UNUSED( extension )
+ Q_UNUSED( option )
+ Q_UNUSED( output )
+ return false;
+}
+
+/*!
+ \reimp
+ */
+QAbstractFileEngine::FileFlags FSEngineClient::fileFlags( FileFlags type ) const
+{
+ stream << QString::fromLatin1( "QFSFileEngine::fileFlags" );
+ stream << static_cast< int >( type );
+ RETURN_CASTED( FileFlags )
+}
+
+/*!
+ \reimp
+ */
+QString FSEngineClient::fileName( FileName file ) const
+{
+ stream << QString::fromLatin1( "QFSFileEngine::fileName" );
+ stream << static_cast< int >( file );
+ RETURN( QString )
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::flush()
+{
+ stream << QString::fromLatin1( "QFSFileEngine::flush" );
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+int FSEngineClient::handle() const
+{
+ stream << QString::fromLatin1( "QFSFileEngine::handle" );
+ RETURN( int )
+}
+
+/*!
+ \reimp
+ */
+RETURN_METHOD( bool, isRelativePath )
+
+/*!
+ \reimp
+ */
+RETURN_METHOD( bool, isSequential )
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::link( const QString& newName )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::link" );
+ stream << newName;
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::mkdir( const QString& dirName, bool createParentDirectories ) const
+{
+ stream << QString::fromLatin1( "QFSFileEngine::mkdir" );
+ stream << dirName;
+ stream << createParentDirectories;
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::open( QIODevice::OpenMode mode )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::open" );
+ stream << static_cast< int >( mode );
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+QString FSEngineClient::owner( FileOwner owner ) const
+{
+ stream << QString::fromLatin1( "QFSFileEngine::owner" );
+ stream << static_cast< int >( owner );
+ RETURN( QString )
+}
+
+/*!
+ \reimp
+ */
+uint FSEngineClient::ownerId( FileOwner owner ) const
+{
+ stream << QString::fromLatin1( "QFSFileEngine::ownerId" );
+ stream << static_cast< int >( owner );
+ RETURN( uint )
+}
+
+/*!
+ \reimp
+ */
+RETURN_METHOD( qint64, pos )
+
+/*!
+ \reimp
+ */
+qint64 FSEngineClient::read( char* data, qint64 maxlen )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::read" );
+ stream << maxlen;
+ socket->flush();
+ if( !socket->bytesAvailable() )
+ socket->waitForReadyRead();
+ quint32 size;
+ stream >> size;
+ qint64 result;
+ stream >> result;
+ qint64 read = 0;
+ while( read < result )
+ {
+ if( !socket->bytesAvailable() )
+ socket->waitForReadyRead();
+ read += socket->read( data + read, result - read );
+ }
+ return result;
+}
+
+/*!
+ \reimp
+ */
+qint64 FSEngineClient::readLine( char* data, qint64 maxlen )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::readLine" );
+ stream << maxlen;
+ socket->flush();
+ if( !socket->bytesAvailable() )
+ socket->waitForReadyRead();
+ quint32 size;
+ stream >> size;
+ qint64 result;
+ stream >> result;
+ qint64 read = 0;
+ while( read < result )
+ {
+ if( !socket->bytesAvailable() )
+ socket->waitForReadyRead();
+ read += socket->read( data + read, result - read );
+ }
+ return result;
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::remove()
+{
+ stream << QString::fromLatin1( "QFSFileEngine::remove" );
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::rename( const QString& newName )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::rename" );
+ stream << newName;
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::rmdir( const QString& dirName, bool recurseParentDirectories ) const
+{
+ stream << QString::fromLatin1( "QFSFileEngine::rmdir" );
+ stream << dirName;
+ stream << recurseParentDirectories;
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::seek( qint64 offset )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::seek" );
+ stream << offset;
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+void FSEngineClient::setFileName( const QString& fileName )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::setFileName" );
+ stream << fileName;
+ RETURN_VOID
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::setPermissions( uint perms )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::setPermissions" );
+ stream << perms;
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::setSize( qint64 size )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::setSize" );
+ stream << size;
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+RETURN_METHOD( qint64, size )
+
+/*!
+ \reimp
+ */
+bool FSEngineClient::supportsExtension( Extension extension ) const
+{
+ stream << QString::fromLatin1( "QFSFileEngine::supportsExtension" );
+ stream << static_cast< int >( extension );
+ RETURN( bool )
+}
+
+/*!
+ \reimp
+ */
+qint64 FSEngineClient::write( const char* data, qint64 len )
+{
+ stream << QString::fromLatin1( "QFSFileEngine::write" );
+ stream << len;
+ qint64 written = 0;
+ while( written < len )
+ {
+ written += socket->write( data, len - written );
+ socket->waitForBytesWritten();
+ }
+ RETURN( qint64 )
+}
+
+class FSEngineClientHandler::Private
+{
+public:
+ Private()
+ : mutex( QMutex::Recursive ),
+ port( 0 ),
+ startServerAsAdmin( false ),
+ serverStarted( false ),
+ serverStarting( false ),
+ active( false ),
+ thread( new StillAliveThread )
+ {
+ thread->moveToThread( thread );
+ }
+
+ void maybeStartServer();
+ void maybeStopServer();
+
+ static FSEngineClientHandler* instance;
+
+ QMutex mutex;
+ QHostAddress address;
+ quint16 port;
+ QString socket;
+ bool startServerAsAdmin;
+ bool serverStarted;
+ bool serverStarting;
+ bool active;
+ QString serverCommand;
+ QStringList serverArguments;
+ QString key;
+
+ StillAliveThread* const thread;
+};
+
+FSEngineClientHandler* FSEngineClientHandler::Private::instance = 0;
+
+/*!
+ Creates a new FSEngineClientHandler with no connection.
+ */
+FSEngineClientHandler::FSEngineClientHandler()
+ : d( new Private )
+{
+ //don't do this in the Private ctor as createUuid() accesses QFileEngine, which accesses this half-constructed handler -> Crash
+ //KDNDK-248
+ d->key = QUuid::createUuid().toString();
+ Private::instance = this;
+}
+
+#ifdef FSENGINE_TCP
+/*!
+ Creates a new FSEngineClientHandler connection to \a port on address \a.
+ */
+FSEngineClientHandler::FSEngineClientHandler( quint16 port, const QHostAddress& a )
+ : d( new Private )
+{
+ d->address = a;
+ d->port = port;
+ d->key = QUuid::createUuid().toString(); //moved from Private() ctor, see above
+ Private::instance = this;
+}
+
+void FSEngineClientHandler::init( quint16 port, const QHostAddress& a )
+{
+ d->address = a;
+ d->port = port;
+ d->thread->start();
+}
+#else
+/*!
+ Creates a new FSEngineClientHandler connecting to \a socket.
+ */
+FSEngineClientHandler::FSEngineClientHandler( const QString& socket )
+ : d( new Private )
+{
+ d->socket = socket;
+ Private::instance = this;
+}
+
+void FSEngineClientHandler::init( const QString& socket )
+{
+ d->socket = socket;
+ d->thread->start();
+}
+#endif
+
+#ifdef FSENGINE_TCP
+bool FSEngineClientHandler::connect( QTcpSocket* socket )
+{
+ int tries = 3;
+ while ( tries > 0 )
+ {
+ socket->connectToHost( d->address, d->port );
+#else
+bool FSEngineClientHandler::connect( QLocalSocket* socket )
+{
+ int tries = 5;
+ while ( tries > 0 )
+ {
+ socket->connectToServer( d->socket );
+#endif
+
+ if( !socket->waitForConnected( 10000 ) )
+ {
+ if( static_cast< QAbstractSocket::SocketError >( socket->error() ) != QAbstractSocket::UnknownSocketError )
+ --tries;
+ qApp->processEvents();
+ continue;
+ }
+
+ QDataStream stream( socket );
+ stream << QString::fromLatin1( "authorize" );
+ stream << d->key;
+ socket->flush();
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Destroys the FSEngineClientHandler. If the handler started a server instance, it gets shut down.
+ */
+FSEngineClientHandler::~FSEngineClientHandler()
+{
+ QMetaObject::invokeMethod( d->thread, "quit" );
+ //d->maybeStopServer();
+ delete d;
+ Private::instance = 0;
+}
+
+/*!
+ Returns a previously created FSEngineClientHandler instance.
+ */
+FSEngineClientHandler* FSEngineClientHandler::instance()
+{
+ if (!Private::instance) {
+ Private::instance = new FSEngineClientHandler();
+ }
+ return Private::instance;
+}
+
+/*!
+ Returns a created authorization key which is sent to the server when connecting via the "authorize" command
+ after the server was started.
+ */
+QString FSEngineClientHandler::authorizationKey() const
+{
+ return d->key;
+}
+
+/*!
+ Sets \a command as the command to be executed to startup the server. If \a startAsAdmin is set,
+ it is executed with admin privilegies.
+ */
+void FSEngineClientHandler::setStartServerCommand( const QString& command, bool startAsAdmin )
+{
+ setStartServerCommand( command, QStringList(), startAsAdmin );
+}
+
+/*!
+ Sets \a command as the command to be executed to startup the server. If \a startAsAdmin is set,
+ it is executed with admin privilegies. A list of \a arguments is passed to the process.
+ */
+void FSEngineClientHandler::setStartServerCommand( const QString& command, const QStringList& arguments, bool startAsAdmin )
+{
+ d->maybeStopServer();
+
+ d->startServerAsAdmin = startAsAdmin;
+ d->serverCommand = command;
+ d->serverArguments = arguments;
+}
+
+/*!
+ \reimp
+ */
+QAbstractFileEngine* FSEngineClientHandler::create( const QString& fileName ) const
+{
+ if( d->serverStarting || !d->active )
+ return 0;
+
+ d->maybeStartServer();
+
+ static QRegExp re( QLatin1String( "^[a-z0-9]*://.*$" ) );
+ if( re.exactMatch( fileName ) ) // stuff like installer:// 7z:// and so on
+ return 0;
+ if( fileName.isEmpty() || fileName.startsWith( QLatin1String( ":" ) ) )
+ return 0; // empty filename or Qt resource
+
+ FSEngineClient* const client = new FSEngineClient;
+ // authorize
+ client->stream << QString::fromLatin1( "authorize" );
+ client->stream << d->key;
+ client->socket->flush();
+
+ client->setFileName( fileName );
+ return client;
+}
+
+/*!
+ Sets the FSEngineClientHandler to \a active. I.e. to actually return FSEngineClients if asked for.
+ */
+void FSEngineClientHandler::setActive( bool active )
+{
+ d->active = active;
+ if( active )
+ {
+ d->maybeStartServer();
+ d->active = d->serverStarted;
+ }
+}
+
+/*!
+ Returns, wheter this FSEngineClientHandler is active or not.
+ */
+bool FSEngineClientHandler::isActive() const
+{
+ return d->active;
+}
+
+/*!
+ Returns true, when the server already has been started.
+ */
+bool FSEngineClientHandler::isServerRunning() const
+{
+ return d->serverStarted;
+}
+
+/*!
+ Starts the server if a command was set and it isn't already started.
+ \internal
+*/
+void FSEngineClientHandler::Private::maybeStartServer()
+{
+ if( serverStarted || serverCommand.isEmpty() )
+ return;
+
+ const QMutexLocker ml( &mutex );
+ if( serverStarted )
+ return;
+
+ serverStarting = true;
+
+ if( startServerAsAdmin )
+ {
+ AdminAuthorization auth;
+ serverStarted = auth.authorize() && auth.execute( 0, serverCommand, serverArguments );
+ }
+ else
+ {
+ serverStarted = QProcess::startDetached( serverCommand, serverArguments );
+ }
+
+ // now wait for the socket to arrive
+#ifdef FSENGINE_TCP
+ QTcpSocket s;
+ while( serverStarting && serverStarted )
+ {
+ if( instance->connect( &s ) )
+ serverStarting = false;
+ }
+
+#else
+ QLocalSocket s;
+ while( serverStarting && serverStarted )
+ {
+ if( instance->connect( &s ) )
+ serverStarting = false;
+ }
+#endif
+
+ serverStarting = false;
+}
+
+/*!
+ Stops the server if it was started before.
+ */
+void FSEngineClientHandler::Private::maybeStopServer()
+{
+ if( !serverStarted )
+ return;
+
+ const QMutexLocker ml( &mutex );
+ if( !serverStarted )
+ return;
+
+#ifdef FSENGINE_TCP
+ QTcpSocket s;
+#else
+ QLocalSocket s;
+#endif
+ if( instance->connect( &s ) )
+ {
+ QDataStream stream( &s );
+ stream.setVersion( QDataStream::Qt_4_2 );
+ stream << QString::fromLatin1( "authorize" );
+ stream << key;
+ stream << QString::fromLatin1( "shutdown" );
+ s.flush();
+ }
+
+ serverStarted = false;
+}
+
+class QSettingsWrapper::Private
+{
+public:
+ Private( const QString& organization, const QString& application )
+ : native( true ),
+ settings( organization, application ),
+ socket( 0 )
+ {
+ }
+ Private( QSettings::Scope scope, const QString& organization, const QString& application )
+ : native( true ),
+ settings( scope, organization, application ),
+ socket( 0 )
+ {
+ }
+ Private( QSettings::Format format, QSettings::Scope scope, const QString& organization, const QString& application )
+ : native( format == QSettings::NativeFormat ),
+ settings( format, scope, organization, application ),
+ socket( 0 )
+ {
+ }
+ Private( const QString& fileName, QSettings::Format format )
+ : native( format == QSettings::NativeFormat ),
+ fileName( fileName ),
+ settings( fileName, format ),
+ socket( 0 )
+ {
+ }
+ Private()
+ : native( true ),
+ socket( 0 )
+ {
+ }
+
+ bool createSocket()
+ {
+ if( !native || !FSEngineClientHandler::instance()->isActive() )
+ return false;
+ if( socket != 0 && socket->state() == static_cast< int >( QLocalSocket::ConnectedState ) )
+ return true;
+ if( socket != 0 )
+ delete socket;
+#ifdef FSENGINE_TCP
+ socket = new QTcpSocket;
+#else
+ socket = new QLocalSocket;
+#endif
+ if( !FSEngineClientHandler::instance()->connect( socket ) )
+ return false;
+ stream.setDevice( socket );
+ stream.setVersion( QDataStream::Qt_4_2 );
+
+ stream << QString::fromLatin1( "createQSettings" );
+ stream << this->fileName;
+ socket->flush();
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return true;
+ }
+
+ const bool native;
+ const QString fileName;
+ QSettings settings;
+#ifdef FSENGINE_TCP
+ mutable QTcpSocket* socket;
+#else
+ mutable QLocalSocket* socket;
+#endif
+ mutable QDataStream stream;
+};
+
+QSettingsWrapper::QSettingsWrapper( const QString& organization, const QString& application, QObject* parent )
+ : QObject( parent ),
+ d( new Private( organization, application ) )
+{
+}
+
+QSettingsWrapper::QSettingsWrapper( QSettingsWrapper::Scope scope, const QString& organization, const QString& application, QObject* parent )
+ : QObject( parent ),
+ d( new Private( static_cast< QSettings::Scope >( scope ), organization, application ) )
+{
+}
+
+QSettingsWrapper::QSettingsWrapper( QSettingsWrapper::Format format, QSettingsWrapper::Scope scope, const QString& organization, const QString& application, QObject* parent )
+ : QObject( parent ),
+ d( new Private( static_cast< QSettings::Format >( format ), static_cast< QSettings::Scope >( scope ), organization, application ) )
+{
+}
+
+QSettingsWrapper::QSettingsWrapper( const QString& fileName, QSettingsWrapper::Format format, QObject* parent )
+ : QObject( parent ),
+ d( new Private( fileName, static_cast< QSettings::Format >( format ) ) )
+{
+}
+
+QSettingsWrapper::QSettingsWrapper( QObject* parent )
+ : QObject( parent ),
+ d( new Private )
+{
+}
+
+QSettingsWrapper::~QSettingsWrapper()
+{
+ if( d->socket != 0 )
+ {
+ d->stream << QString::fromLatin1( "destroyQSettings" );
+ d->socket->flush();
+ quint32 result;
+ d->stream >> result;
+
+ if( QThread::currentThread() == d->socket->thread() )
+ {
+ d->socket->close();
+ delete d->socket;
+ }
+ else
+ {
+ d->socket->deleteLater();
+ }
+ }
+ delete d;
+}
+
+void callRemoteVoidMethod( QDataStream& stream, const QString& name )
+{
+ stream.device()->readAll();
+ stream << name;
+ stream.device()->waitForBytesWritten( -1 );
+ if( !stream.device()->bytesAvailable() )
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return;
+}
+
+template< typename T >
+void callRemoteVoidMethod( QDataStream& stream, const QString& name, const T& param1 )
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream.device()->waitForBytesWritten( -1 );
+ if( !stream.device()->bytesAvailable() )
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return;
+}
+
+template< typename T1, typename T2 >
+void callRemoteVoidMethod( QDataStream& stream, const QString& name, const T1& param1, const T2& param2 )
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream << param2;
+ stream.device()->waitForBytesWritten( -1 );
+ if( !stream.device()->bytesAvailable() )
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return;
+}
+
+template< typename T1, typename T2, typename T3 >
+void callRemoteVoidMethod( QDataStream& stream, const QString& name, const T1& param1, const T2& param2, const T3& param3 )
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream << param2;
+ stream << param3;
+ stream.device()->waitForBytesWritten( -1 );
+ if( !stream.device()->bytesAvailable() )
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+ return;
+}
+
+template< typename RESULT >
+RESULT callRemoteMethod( QDataStream& stream, const QString& name )
+{
+ stream.device()->readAll();
+ stream << name;
+ stream.device()->waitForBytesWritten( -1 );
+ if( !stream.device()->bytesAvailable() )
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ RESULT result;
+ stream >> result;
+ stream.device()->readAll();
+ return result;
+}
+
+template< typename RESULT, typename T >
+RESULT callRemoteMethod( QDataStream& stream, const QString& name, const T& param1 )
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream.device()->waitForBytesWritten( -1 );
+ if( !stream.device()->bytesAvailable() )
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ RESULT result;
+ stream >> result;
+ stream.device()->readAll();
+ return result;
+}
+
+template< typename RESULT, typename T1, typename T2 >
+RESULT callRemoteMethod( QDataStream& stream, const QString& name, const T1& param1, const T2& param2 )
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream << param2;
+ stream.device()->waitForBytesWritten( -1 );
+ if( !stream.device()->bytesAvailable() )
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ RESULT result;
+ stream >> result;
+ stream.device()->readAll();
+ return result;
+}
+
+template< typename RESULT, typename T1, typename T2, typename T3 >
+RESULT callRemoteMethod( QDataStream& stream, const QString& name, const T1& param1, const T2& param2, const T3& param3 )
+{
+ stream.device()->readAll();
+ stream << name;
+ stream << param1;
+ stream << param2;
+ stream << param3;
+ stream.device()->waitForBytesWritten( -1 );
+ if( !stream.device()->bytesAvailable() )
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ RESULT result;
+ stream >> result;
+ stream.device()->readAll();
+ return result;
+}
+
+static QDataStream& operator>>( QDataStream& stream, QSettingsWrapper::Status& status )
+{
+ int s;
+ stream >> s;
+ status = static_cast< QSettingsWrapper::Status >( s );
+ return stream;
+}
+
+#define RETURN_NO_ARGS_CONST( RESULT, NAME ) \
+RESULT QSettingsWrapper::NAME() const \
+{ \
+ if( d->createSocket() ) \
+ return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QSettings::"#NAME ) ); \
+ else \
+ return static_cast< RESULT >( d->settings.NAME() ); \
+}
+
+#define RETURN_ONE_ARG( RESULT, NAME, TYPE1 ) \
+RESULT QSettingsWrapper::NAME( TYPE1 param1 ) \
+{ \
+ if( d->createSocket() ) \
+ return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QSettings::"#NAME ), param1 ); \
+ else \
+ return d->settings.NAME( param1 ); \
+}
+
+#define RETURN_ONE_ARG_CONST( RESULT, NAME, TYPE1 ) \
+RESULT QSettingsWrapper::NAME( TYPE1 param1 ) const \
+{ \
+ if( d->createSocket() ) \
+ return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QSettings::"#NAME ), param1 ); \
+ else \
+ return d->settings.NAME( param1 ); \
+}
+
+#define RETURN_TWO_ARGS_CONST( RESULT, NAME, TYPE1, TYPE2 ) \
+RESULT QSettingsWrapper::NAME( TYPE1 param1, TYPE2 param2 ) const \
+{ \
+ if( d->createSocket() ) \
+ return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QSettings::"#NAME ), param1, param2 ); \
+ else \
+ return d->settings.NAME( param1, param2 ); \
+}
+
+#define VOID_NO_ARGS( NAME ) \
+void QSettingsWrapper::NAME() \
+{ \
+ if( d->createSocket() ) \
+ callRemoteVoidMethod( d->stream, QLatin1String( "QSettings::"#NAME ) ); \
+ else \
+ d->settings.NAME(); \
+}
+
+#define VOID_ONE_ARG( NAME, TYPE1 ) \
+void QSettingsWrapper::NAME( TYPE1 param1 ) \
+{ \
+ if( d->createSocket() ) \
+ callRemoteVoidMethod( d->stream, QLatin1String( "QSettings::"#NAME ), param1 ); \
+ else \
+ d->settings.NAME( param1 ); \
+}
+
+#define VOID_TWO_ARGS( NAME, TYPE1, TYPE2 ) \
+void QSettingsWrapper::NAME( TYPE1 param1, TYPE2 param2 ) \
+{ \
+ if( d->createSocket() ) \
+ callRemoteVoidMethod( d->stream, QLatin1String( "QSettings::"#NAME ), param1, param2 ); \
+ else \
+ d->settings.NAME( param1, param2 ); \
+}
+
+RETURN_NO_ARGS_CONST( QStringList, allKeys )
+RETURN_NO_ARGS_CONST( QString, applicationName )
+VOID_ONE_ARG( beginGroup, const QString& )
+RETURN_ONE_ARG( int, beginReadArray, const QString& )
+VOID_TWO_ARGS( beginWriteArray, const QString&, int )
+RETURN_NO_ARGS_CONST( QStringList, childGroups )
+RETURN_NO_ARGS_CONST( QStringList, childKeys )
+VOID_NO_ARGS( clear )
+RETURN_ONE_ARG_CONST( bool, contains, const QString& )
+VOID_NO_ARGS( endArray )
+VOID_NO_ARGS( endGroup )
+RETURN_NO_ARGS_CONST( bool, fallbacksEnabled )
+RETURN_NO_ARGS_CONST( QString, fileName )
+
+QSettingsWrapper::Format QSettingsWrapper::format() const
+{
+ return static_cast< QSettingsWrapper::Format >( d->settings.format() );
+}
+
+RETURN_NO_ARGS_CONST( QString, group )
+
+QTextCodec* QSettingsWrapper::iniCodec() const
+{
+ return d->settings.iniCodec();
+}
+
+RETURN_NO_ARGS_CONST( bool, isWritable )
+RETURN_NO_ARGS_CONST( QString, organizationName )
+VOID_ONE_ARG( remove, const QString& )
+
+QSettingsWrapper::Scope QSettingsWrapper::scope() const
+{
+ return static_cast< QSettingsWrapper::Scope >( d->settings.scope() );
+}
+
+VOID_ONE_ARG( setArrayIndex, int )
+VOID_ONE_ARG( setFallbacksEnabled, bool )
+
+void QSettingsWrapper::setIniCodec( QTextCodec* codec )
+{
+ d->settings.setIniCodec( codec );
+}
+
+void QSettingsWrapper::setIniCodec( const char* codecName )
+{
+ d->settings.setIniCodec( codecName );
+}
+
+VOID_TWO_ARGS( setValue, const QString&, const QVariant& )
+RETURN_NO_ARGS_CONST( QSettingsWrapper::Status, status );
+VOID_NO_ARGS( sync )
+RETURN_TWO_ARGS_CONST( QVariant, value, const QString&, const QVariant& )
+
+class QProcessWrapper::Private
+{
+public:
+ Private( QProcessWrapper* qq )
+ : q( qq ),
+ ignoreTimer( false ),
+ socket( 0 )
+ {
+ }
+
+ bool createSocket()
+ {
+ if( !FSEngineClientHandler::instance()->isActive() )
+ return false;
+ if( socket != 0 && socket->state() == static_cast< int >( QLocalSocket::ConnectedState ) )
+ return true;
+ if( socket != 0 )
+ delete socket;
+#ifdef FSENGINE_TCP
+ socket = new QTcpSocket;
+#else
+ socket = new QLocalSocket;
+#endif
+ if( !FSEngineClientHandler::instance()->connect( socket ) )
+ return false;
+ stream.setDevice( socket );
+ stream.setVersion( QDataStream::Qt_4_2 );
+
+ stream << QString::fromLatin1( "createQProcess" );
+ socket->flush();
+ stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ stream >> test;
+ stream.device()->readAll();
+
+ q->startTimer( 250 );
+
+ return true;
+ }
+
+ class TimerBlocker
+ {
+ public:
+ explicit TimerBlocker( const QProcessWrapper* wrapper )
+ : w( const_cast< QProcessWrapper* >( wrapper ) )
+ {
+ w->d->ignoreTimer = true;
+ }
+ ~TimerBlocker()
+ {
+ w->d->ignoreTimer = false;
+ }
+
+ private:
+ QProcessWrapper* const w;
+ };
+
+private:
+ QProcessWrapper* const q;
+
+public:
+ bool ignoreTimer;
+
+ QProcess process;
+#ifdef FSENGINE_TCP
+ mutable QTcpSocket* socket;
+#else
+ mutable QLocalSocket* socket;
+#endif
+ mutable QDataStream stream;
+};
+
+QProcessWrapper::QProcessWrapper( QObject* parent )
+ : QObject( parent ),
+ d( new Private( this ) )
+{
+ KDMetaMethodIterator it( QProcess::staticMetaObject, KDMetaMethodIterator::Signal, KDMetaMethodIterator::IgnoreQObjectMethods );
+ while( it.hasNext() )
+ {
+ it.next();
+ connect( &d->process, it.connectableSignature(), this, it.connectableSignature() );
+ }
+}
+
+QProcessWrapper::~QProcessWrapper()
+{
+ if( d->socket != 0 )
+ {
+ d->stream << QString::fromLatin1( "destroyQProcess" );
+ d->socket->flush();
+ quint32 result;
+ d->stream >> result;
+
+ if( QThread::currentThread() == d->socket->thread() )
+ {
+ d->socket->close();
+ delete d->socket;
+ }
+ else
+ {
+ d->socket->deleteLater();
+ }
+ }
+ delete d;
+}
+
+void QProcessWrapper::timerEvent( QTimerEvent* event )
+{
+ Q_UNUSED( event )
+
+ if( d->ignoreTimer )
+ return;
+
+ QList< QVariant > receivedSignals;
+
+ {
+ const Private::TimerBlocker blocker( this );
+
+ d->stream << QString::fromLatin1( "getQProcessSignals" );
+ d->socket->flush();
+ d->stream.device()->waitForReadyRead( -1 );
+ quint32 test;
+ d->stream >> test;
+ d->stream >> receivedSignals;
+ d->stream.device()->readAll();
+ }
+
+ while( !receivedSignals.isEmpty() )
+ {
+ const QString name = receivedSignals.takeFirst().toString();
+ if( name == QLatin1String( "started" ) )
+ {
+ emit started();
+ }
+ else if( name == QLatin1String( "readyRead" ) )
+ {
+ emit readyRead();
+ }
+ else if( name == QLatin1String( "stateChanged" ) )
+ {
+ const QProcess::ProcessState newState = static_cast< QProcess::ProcessState >( receivedSignals.takeFirst().toInt() );
+ emit stateChanged( newState );
+ }
+ else if( name == QLatin1String( "finished" ) )
+ {
+ const int exitCode = receivedSignals.takeFirst().toInt();
+ const QProcess::ExitStatus exitStatus = static_cast< QProcess::ExitStatus >( receivedSignals.takeFirst().toInt() );
+ emit finished( exitCode );
+ emit finished( exitCode, exitStatus );
+ }
+ }
+}
+
+static QDataStream& operator>>( QDataStream& stream, QProcessWrapper::ProcessState& state )
+{
+ int s;
+ stream >> s;
+ state = static_cast< QProcessWrapper::ProcessState >( s );
+ return stream;
+}
+
+static QDataStream& operator>>( QDataStream& stream, QProcessWrapper::ExitStatus& status )
+{
+ int s;
+ stream >> s;
+ status = static_cast< QProcessWrapper::ExitStatus >( s );
+ return stream;
+}
+
+static QDataStream& operator>>( QDataStream& stream, QProcessWrapper::ProcessChannelMode& status )
+{
+ int s;
+ stream >> s;
+ status = static_cast< QProcessWrapper::ProcessChannelMode >( s );
+ return stream;
+}
+
+static QDataStream& operator>>( QDataStream& stream, QProcessWrapper::ProcessChannel& status )
+{
+ int s;
+ stream >> s;
+ status = static_cast< QProcessWrapper::ProcessChannel >( s );
+ return stream;
+}
+
+#undef RETURN_NO_ARGS_CONST
+#define RETURN_NO_ARGS_CONST( RESULT, NAME ) \
+RESULT QProcessWrapper::NAME() const \
+{ \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ) ); \
+ else \
+ return static_cast< RESULT >( d->process.NAME() ); \
+}
+
+#define RETURN_NO_ARGS( RESULT, NAME ) \
+RESULT QProcessWrapper::NAME() \
+{ \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ) ); \
+ else \
+ return d->process.NAME(); \
+}
+
+#undef RETURN_ONE_ARG
+#define RETURN_ONE_ARG( RESULT, NAME, TYPE1 ) \
+RESULT QProcessWrapper::NAME( TYPE1 param1 ) \
+{ \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ), param1 ); \
+ else \
+ return d->process.NAME( param1 ); \
+}
+
+#undef RETURN_ONE_ARG_CONST
+#define RETURN_ONE_ARG_CONST( RESULT, NAME, TYPE1 ) \
+RESULT QProcessWrapper::NAME( TYPE1 param1 ) const \
+{ \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ), param1 ); \
+ else \
+ return d->process.NAME( param1 ); \
+}
+
+#undef RETURN_TWO_ARGS_CONST
+#define RETURN_TWO_ARGS_CONST( RESULT, NAME, TYPE1, TYPE2 ) \
+RESULT QProcessWrapper::NAME( TYPE1 param1, TYPE2 param2 ) const \
+{ \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ return callRemoteMethod< RESULT >( d->stream, QLatin1String( "QProcess::"#NAME ), param1, param2 ); \
+ else \
+ return d->process.NAME( param1, param2 ); \
+}
+
+#undef VOID_NO_ARGS
+#define VOID_NO_ARGS( NAME ) \
+void QProcessWrapper::NAME() \
+{ \
+ qDebug() << Q_FUNC_INFO; \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::"#NAME ) ); \
+ else \
+ d->process.NAME(); \
+}
+
+#undef VOID_ONE_ARG
+#define VOID_ONE_ARG( NAME, TYPE1 ) \
+void QProcessWrapper::NAME( TYPE1 param1 ) \
+{ \
+ qDebug() << Q_FUNC_INFO; \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::"#NAME ), param1 ); \
+ else \
+ d->process.NAME( param1 ); \
+}
+
+#undef VOID_TWO_ARGS
+#define VOID_TWO_ARGS( NAME, TYPE1, TYPE2 ) \
+void QProcessWrapper::NAME( TYPE1 param1, TYPE2 param2 ) \
+{ \
+ qDebug() << Q_FUNC_INFO; \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::"#NAME ), param1, param2 ); \
+ else \
+ d->process.NAME( param1, param2 ); \
+}
+
+#define VOID_THREE_ARGS( NAME, TYPE1, TYPE2, TYPE3 ) \
+void QProcessWrapper::NAME( TYPE1 param1, TYPE2 param2, TYPE3 param3 ) \
+{ \
+ qDebug() << Q_FUNC_INFO; \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::"#NAME ), param1, param2, param3 ); \
+ else \
+ d->process.NAME( param1, param2, param3 ); \
+}
+
+VOID_NO_ARGS( closeWriteChannel );
+RETURN_NO_ARGS_CONST( int, exitCode );
+RETURN_NO_ARGS_CONST( QProcessWrapper::ExitStatus, exitStatus );
+VOID_NO_ARGS( kill )
+RETURN_NO_ARGS( QByteArray, readAll );
+RETURN_NO_ARGS( QByteArray, readAllStandardOutput );
+VOID_THREE_ARGS( start, const QString&, const QStringList&, QIODevice::OpenMode )
+VOID_ONE_ARG( start, const QString& )
+
+bool startDetached( const QString& program, const QStringList& args, const QString& workingDirectory, qint64* pid );
+
+bool QProcessWrapper::startDetached( const QString& program, const QStringList& arguments, const QString& workingDirectory, qint64* pid )
+{
+ QProcessWrapper w;
+ if( w.d->createSocket() )
+ {
+ const QPair< bool, qint64 > result = callRemoteMethod< QPair< bool, qint64 > >( w.d->stream, QLatin1String( "QProcess::startDetached" ), program, arguments, workingDirectory );
+ if( pid != 0 )
+ *pid = result.second;
+ return result.first;
+ }
+ else
+ {
+ return ::startDetached( program, arguments, workingDirectory, pid );
+ }
+}
+
+bool QProcessWrapper::startDetached( const QString& program, const QStringList& arguments )
+{
+ return startDetached( program, arguments, QDir::currentPath() );
+}
+
+bool QProcessWrapper::startDetached( const QString& program )
+{
+ return startDetached( program, QStringList() );
+}
+
+void QProcessWrapper::setProcessChannelMode( QProcessWrapper::ProcessChannelMode mode )
+{ \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::setProcessChannelMode" ), static_cast<QProcess::ProcessChannelMode>( mode ) ); \
+ else \
+ d->process.setProcessChannelMode( static_cast<QProcess::ProcessChannelMode>( mode ) ); \
+}
+
+/*!
+ Cancels the process. This methods tries to terminate the process
+ gracefully by calling QProcess::terminate. After 10 seconds, the process gets killed.
+ */
+void QProcessWrapper::cancel()
+{
+ if( state() == QProcessWrapper::Running )
+ terminate();
+ if( !waitForFinished( 10000 ) )
+ kill();
+}
+
+void QProcessWrapper::setReadChannel( QProcessWrapper::ProcessChannel chan )
+{ \
+ const Private::TimerBlocker blocker( this );\
+ if( d->createSocket() ) \
+ callRemoteVoidMethod( d->stream, QLatin1String( "QProcess::setReadChannel" ), static_cast<QProcess::ProcessChannel>( chan ) ); \
+ else \
+ d->process.setReadChannel( static_cast<QProcess::ProcessChannel>( chan ) ); \
+}
+
+RETURN_NO_ARGS_CONST( QProcessWrapper::ProcessState, state )
+VOID_NO_ARGS( terminate )
+RETURN_ONE_ARG( bool, waitForFinished, int )
+RETURN_ONE_ARG( bool, waitForStarted, int )
+RETURN_NO_ARGS_CONST( QProcessWrapper::ProcessChannel, readChannel )
+RETURN_NO_ARGS_CONST( QProcessWrapper::ProcessChannelMode, processChannelMode )
+RETURN_NO_ARGS_CONST( QString, workingDirectory )
+RETURN_ONE_ARG( qint64, write, const QByteArray& )
+VOID_ONE_ARG( setEnvironment, const QStringList& )
+#ifdef Q_OS_WIN
+VOID_ONE_ARG( setNativeArguments, const QString& )
+#endif
+VOID_ONE_ARG( setWorkingDirectory, const QString& )
+
+#include "moc_fsengineclient.cpp"
+#include "fsengineclient.moc"
diff --git a/installerbuilder/libinstaller/fsengineclient.h b/installerbuilder/libinstaller/fsengineclient.h
new file mode 100644
index 000000000..9065f3741
--- /dev/null
+++ b/installerbuilder/libinstaller/fsengineclient.h
@@ -0,0 +1,234 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef FSENGINECLIENT_H
+#define FSENGINECLIENT_H
+
+#include <QtCore/QAbstractFileEngineHandler>
+#include <QtCore/QProcess>
+#include <QtCore/QSettings>
+
+#ifdef FSENGINE_TCP
+#include <QtNetwork/QHostAddress>
+class QTcpSocket;
+#else
+class QLocalSocket;
+#endif
+
+#include "installer_global.h"
+
+class INSTALLER_EXPORT FSEngineClientHandler : public QAbstractFileEngineHandler
+{
+public:
+ FSEngineClientHandler();
+#ifdef FSENGINE_TCP
+ FSEngineClientHandler( quint16 port, const QHostAddress& a = QHostAddress::LocalHost );
+ void init( quint16 port, const QHostAddress& a = QHostAddress::LocalHost );
+
+#else
+ FSEngineClientHandler( const QString& socket );
+ void init( const QString& socket );
+#endif
+ ~FSEngineClientHandler();
+
+ static FSEngineClientHandler* instance();
+
+ QAbstractFileEngine* create( const QString& fileName ) const;
+
+ void setActive( bool active );
+ bool isActive() const;
+ bool isServerRunning() const;
+
+ QString authorizationKey() const;
+
+ void setStartServerCommand( const QString& command, bool startAsAdmin = false );
+ void setStartServerCommand( const QString& command, const QStringList& arguments, bool startAsAdmin = false );
+
+#ifdef FSENGINE_TCP
+ bool connect( QTcpSocket* socket );
+#else
+ bool connect( QLocalSocket* socket );
+#endif
+
+private:
+ class Private;
+ Private* d;
+};
+
+class INSTALLER_EXPORT QSettingsWrapper : public QObject
+{
+ Q_OBJECT
+public:
+ enum Format
+ {
+ NativeFormat,
+ IniFormat,
+ InvalidFormat
+ };
+
+ enum Status
+ {
+ NoError,
+ AccessError,
+ FormatError
+ };
+
+ enum Scope
+ {
+ UserScope,
+ SystemScope
+ };
+
+ explicit QSettingsWrapper( const QString& organization, const QString& application = QString(), QObject* parent = 0 );
+ QSettingsWrapper( QSettingsWrapper::Scope scope, const QString& organization, const QString& application = QString(), QObject* parent = 0 );
+ QSettingsWrapper( QSettingsWrapper::Format format, QSettingsWrapper::Scope scope, const QString& organization, const QString& application = QString(), QObject* parent = 0 );
+ QSettingsWrapper( const QString& fileName, QSettingsWrapper::Format format, QObject* parent = 0 );
+ explicit QSettingsWrapper( QObject* parent = 0 );
+ ~QSettingsWrapper();
+
+ QStringList allKeys() const;
+ QString applicationName() const;
+ void beginGroup( const QString& prefix );
+ int beginReadArray( const QString& prefix );
+ void beginWriteArray( const QString& prefix, int size = -1 );
+ QStringList childGroups() const;
+ QStringList childKeys() const;
+ void clear();
+ bool contains( const QString& key ) const;
+ void endArray();
+ void endGroup();
+ bool fallbacksEnabled() const;
+ QString fileName() const;
+ QSettingsWrapper::Format format() const;
+ QString group() const;
+ QTextCodec* iniCodec() const;
+ bool isWritable() const;
+ QString organizationName() const;
+ void remove( const QString& key );
+ QSettingsWrapper::Scope scope() const;
+ void setArrayIndex( int i );
+ void setFallbacksEnabled( bool b );
+ void setIniCodec( QTextCodec* codec );
+ void setIniCodec( const char* codecName );
+ void setValue( const QString& key, const QVariant& value );
+ QSettingsWrapper::Status status() const;
+ void sync();
+ QVariant value( const QString& key, const QVariant& defaultValue = QVariant() ) const;
+
+private:
+ class Private;
+ Private* d;
+};
+
+#define QSettings QSettingsWrapper
+
+class INSTALLER_EXPORT QProcessWrapper : public QObject
+{
+ Q_OBJECT
+public:
+ enum ProcessState
+ {
+ NotRunning,
+ Starting,
+ Running
+ };
+
+ enum ExitStatus
+ {
+ NormalExit,
+ CrashExit
+ };
+
+ enum ProcessChannel
+ {
+ StandardOutput = 0,
+ StandardError = 1
+ };
+
+ enum ProcessChannelMode
+ {
+ SeparateChannels = 0,
+ MergedChannels = 1,
+ ForwardedChannels = 2
+ };
+
+ explicit QProcessWrapper( QObject* parent = 0 );
+ ~QProcessWrapper();
+
+ void closeWriteChannel();
+ int exitCode() const;
+ ExitStatus exitStatus() const;
+ void kill();
+ QByteArray readAll();
+ QByteArray readAllStandardOutput();
+ void setWorkingDirectory( const QString& dir );
+ void start( const QString& program, const QStringList& arguments, QIODevice::OpenMode mode = QIODevice::ReadWrite );
+ void start( const QString& program );
+ static bool startDetached( const QString& program, const QStringList& arguments, const QString& workingDirectory, qint64* pid = 0 );
+ static bool startDetached( const QString& program, const QStringList& arguments );
+ static bool startDetached( const QString& program );
+
+ ProcessState state() const;
+ void terminate();
+ bool waitForFinished( int msecs = 30000 );
+ bool waitForStarted( int msecs = 30000 );
+ void setEnvironment( const QStringList& environment );
+ QString workingDirectory() const;
+ qint64 write( const QByteArray& byteArray );
+ QProcessWrapper::ProcessChannel readChannel() const;
+ void setReadChannel( QProcessWrapper::ProcessChannel channel );
+ QProcessWrapper::ProcessChannelMode processChannelMode() const;
+ void setProcessChannelMode( QProcessWrapper::ProcessChannelMode channel );
+#ifdef Q_OS_WIN
+ void setNativeArguments(const QString& arguments);
+#endif
+
+Q_SIGNALS:
+ void bytesWritten( qint64 );
+ void aboutToClose();
+ void readChannelFinished();
+ void error( QProcess::ProcessError );
+ void readyReadStandardOutput();
+ void readyReadStandardError();
+ void finished( int exitCode );
+ void finished( int exitCode, QProcess::ExitStatus exitStatus );
+ void readyRead();
+ void started();
+ void stateChanged( QProcess::ProcessState newState );
+
+public Q_SLOTS:
+ void cancel();
+
+protected:
+ void timerEvent( QTimerEvent* event );
+
+private:
+ class Private;
+ Private* d;
+};
+
+#define QProcess QProcessWrapper
+
+#endif
diff --git a/installerbuilder/libinstaller/fsengineserver.cpp b/installerbuilder/libinstaller/fsengineserver.cpp
new file mode 100644
index 000000000..1be880156
--- /dev/null
+++ b/installerbuilder/libinstaller/fsengineserver.cpp
@@ -0,0 +1,830 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "fsengineserver.h"
+
+#include <QCoreApplication>
+#include <QFSFileEngine>
+#include <QLocalSocket>
+#include <QDataStream>
+#include <QProcess>
+#include <QSettings>
+#include <QTcpSocket>
+#include <QThread>
+#include <QVariant>
+
+#ifdef FSENGINE_TCP
+typedef int descriptor_t;
+#else
+typedef quintptr descriptor_t;
+#endif
+
+#ifdef Q_WS_WIN
+#include <windows.h>
+
+// stolen from qprocess_win.cpp
+static QString qt_create_commandline(const QString &program, const QStringList &arguments)
+{
+ QString args;
+ if (!program.isEmpty()) {
+ QString programName = program;
+ if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
+ programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
+ programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
+
+ // add the prgram as the first arg ... it works better
+ args = programName + QLatin1Char(' ');
+ }
+
+ for (int i=0; i<arguments.size(); ++i) {
+ QString tmp = arguments.at(i);
+ // in the case of \" already being in the string the \ must also be escaped
+ tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
+ // escape a single " because the arguments will be parsed
+ tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
+ if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
+ // The argument must not end with a \ since this would be interpreted
+ // as escaping the quote -- rather put the \ behind the quote: e.g.
+ // rather use "foo"\ than "foo\"
+ QString endQuote(QLatin1Char('\"'));
+ int i = tmp.length();
+ while (i>0 && tmp.at(i-1) == QLatin1Char('\\')) {
+ --i;
+ endQuote += QLatin1Char('\\');
+ }
+ args += QLatin1String(" \"") + tmp.left(i) + endQuote;
+ } else {
+ args += QLatin1Char(' ') + tmp;
+ }
+ }
+ return args;
+}
+#endif
+
+bool startDetached( const QString& program, const QStringList& args, const QString& workingDirectory, qint64* pid )
+{
+#ifdef Q_WS_WIN
+ const QString arguments = qt_create_commandline( program, args );
+
+ PROCESS_INFORMATION pinfo;
+
+ STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
+ static_cast< ulong >( CW_USEDEFAULT ), static_cast< ulong >( CW_USEDEFAULT ),
+ static_cast< ulong >( CW_USEDEFAULT ), static_cast< ulong >( CW_USEDEFAULT ),
+ 0, 0, 0, STARTF_USESHOWWINDOW, SW_HIDE, 0, 0, 0, 0, 0
+ };
+ const bool success = CreateProcess( 0, const_cast< wchar_t* >( static_cast< const wchar_t* >( arguments.utf16() ) ),
+ 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE,
+ 0, (wchar_t*)workingDirectory.utf16(),
+ &startupInfo, &pinfo );
+ if( success )
+ {
+ CloseHandle( pinfo.hThread );
+ CloseHandle( pinfo.hProcess );
+ if( pid )
+ *pid = pinfo.dwProcessId;
+ }
+
+ return success;
+
+#else
+ return QProcess::startDetached( program, args, workingDirectory, pid );
+#endif
+}
+
+class QProcessSignalReceiver : public QObject
+{
+ Q_OBJECT
+public:
+ QProcessSignalReceiver( QObject* parent = 0 )
+ : QObject( parent )
+ {
+ connect( parent, SIGNAL( finished( int, QProcess::ExitStatus ) ),
+ this, SLOT( processFinished( int, QProcess::ExitStatus ) ) );
+ connect( parent, SIGNAL( error( QProcess::ProcessError ) ),
+ this, SLOT( processError( QProcess::ProcessError ) ) );
+ connect( parent, SIGNAL( readyRead() ),
+ this, SLOT( processReadyRead() ) );
+ connect( parent, SIGNAL( started() ),
+ this, SLOT( processStarted() ) );
+ connect( parent, SIGNAL( stateChanged( QProcess::ProcessState ) ),
+ this, SLOT( processStateChanged( QProcess::ProcessState ) ) );
+ }
+ ~QProcessSignalReceiver()
+ {
+ }
+
+ QList< QVariant > receivedSignals;
+
+private Q_SLOTS:
+ void processError( QProcess::ProcessError error );
+ void processFinished( int exitCode, QProcess::ExitStatus exitStatus );
+ void processReadyRead();
+ void processStarted();
+ void processStateChanged( QProcess::ProcessState newState );
+
+};
+
+/*!
+ \internal
+ */
+class FSEngineConnectionThread : public QThread
+{
+ Q_OBJECT
+public:
+ FSEngineConnectionThread( descriptor_t socketDescriptor, QObject* parent )
+ : QThread( parent ),
+ descriptor( socketDescriptor ),
+ settings( 0 ),
+ process( 0 ),
+ signalReceiver( 0 )
+ {
+ }
+
+ ~FSEngineConnectionThread()
+ {
+ }
+
+protected:
+ void run();
+
+private:
+ QByteArray handleCommand( const QString& command );
+
+ QFSFileEngine engine;
+ const descriptor_t descriptor;
+ QDataStream receivedStream;
+ QSettings* settings;
+
+ QProcess* process;
+ QProcessSignalReceiver* signalReceiver;
+};
+
+#ifdef FSENGINE_TCP
+FSEngineServer::FSEngineServer( quint16 port, QObject* parent )
+ : QTcpServer( parent )
+{
+ listen( QHostAddress::LocalHost, port );
+ watchdog.setTimeoutInterval( 30000 );
+ connect( &watchdog, SIGNAL( timeout() ), qApp, SLOT( quit() ) );
+}
+
+FSEngineServer::FSEngineServer( const QHostAddress& address, quint16 port, QObject* parent )
+ : QTcpServer( parent )
+{
+ listen( address, port );
+ watchdog.setTimeoutInterval( 30000 );
+ connect( &watchdog, SIGNAL( timeout() ), qApp, SLOT( quit() ) );
+}
+
+#else
+/*!
+ Creates a new FSEngineServer with \a parent. The server will listen on \a socket.
+ */
+FSEngineServer::FSEngineServer( const QString& socket, QObject* parent )
+ : QLocalServer( parent )
+{
+ removeServer( socket );
+ listen( socket );
+ QFile( socket ).setPermissions( static_cast< QFile::Permissions >( 0x6666 ) );
+ watchdog.setTimeoutInterval( 30000 );
+ connect( &watchdog, SIGNAL( timeout() ), qApp, SLOT( quit() ) );
+}
+
+#endif
+
+/*!
+ Destroys the FSEngineServer.
+ */
+FSEngineServer::~FSEngineServer()
+{
+ const QList< QThread* > threads = findChildren< QThread* >();
+ for( QList< QThread* >::const_iterator it = threads.begin(); it != threads.end(); ++it )
+ (*it)->wait();
+}
+
+#ifdef FSENGINE_TCP
+/*!
+ \reimp
+ */
+void FSEngineServer::incomingConnection( int socketDescriptor )
+{
+ qApp->processEvents();
+ QThread* const thread = new FSEngineConnectionThread( socketDescriptor, this );
+ connect( thread, SIGNAL( finished() ), thread, SLOT( deleteLater() ) );
+ thread->start();
+ watchdog.resetTimeoutTimer();
+}
+
+#else
+
+/*!
+ \reimp
+ */
+void FSEngineServer::incomingConnection( quintptr socketDescriptor )
+{
+ qApp->processEvents();
+ QThread* const thread = new FSEngineConnectionThread( socketDescriptor, this );
+ connect( thread, SIGNAL( finished() ), thread, SLOT( deleteLater() ) );
+ thread->start();
+ watchdog.resetTimeoutTimer();
+}
+#endif
+
+/*!
+ Sets the authorization key this server is asking the clients for to \a authorizationKey.
+ */
+void FSEngineServer::setAuthorizationKey( const QString& authorizationKey )
+{
+ key = authorizationKey;
+}
+
+QString FSEngineServer::authorizationKey() const
+{
+ return key;
+}
+
+void QProcessSignalReceiver::processError( QProcess::ProcessError error )
+{
+ receivedSignals.push_back( QLatin1String( "error" ) );
+ receivedSignals.push_back( static_cast< int >( error ) );
+}
+
+void QProcessSignalReceiver::processFinished( int exitCode, QProcess::ExitStatus exitStatus )
+{
+ receivedSignals.push_back( QLatin1String( "finished" ) );
+ receivedSignals.push_back( exitCode );
+ receivedSignals.push_back( static_cast< int >( exitStatus ) );
+}
+
+void QProcessSignalReceiver::processStarted()
+{
+ receivedSignals.push_back( QLatin1String( "started" ) );
+}
+
+void QProcessSignalReceiver::processReadyRead()
+{
+ receivedSignals.push_back( QLatin1String( "readyRead" ) );
+}
+
+void QProcessSignalReceiver::processStateChanged( QProcess::ProcessState newState )
+{
+ receivedSignals.push_back( QLatin1String( "stateChanged" ) );
+ receivedSignals.push_back( static_cast< int >( newState ) );
+}
+
+/*!
+ \reimp
+ */
+void FSEngineConnectionThread::run()
+{
+#ifdef FSENGINE_TCP
+ QTcpSocket socket;
+#else
+ QLocalSocket socket;
+#endif
+ socket.setSocketDescriptor( descriptor );
+
+ receivedStream.setDevice( &socket );
+ receivedStream.setVersion( QDataStream::Qt_4_2 );
+
+ bool authorized = false;
+
+ while( static_cast< QLocalSocket::LocalSocketState >( socket.state() ) == QLocalSocket::ConnectedState )
+ {
+ if( !socket.bytesAvailable() && !socket.waitForReadyRead( 250 ) )
+ continue;
+
+ QString command;
+ receivedStream >> command;
+
+ if( authorized && command == QLatin1String( "shutdown" ) )
+ {
+ // this is a graceful shutdown
+ socket.close();
+ parent()->deleteLater();
+ return;
+ }
+ else if( command == QLatin1String( "authorize" ) )
+ {
+ QString k;
+ receivedStream >> k;
+ if( k != dynamic_cast< FSEngineServer* >( parent() )->authorizationKey() )
+ {
+ // this is closing the connection... auth failed
+ socket.close();
+ return;
+ }
+ authorized = true;
+ }
+ else if( authorized )
+ {
+ if( command.isEmpty() )
+ continue;
+ const QByteArray result = handleCommand( command );
+ receivedStream << static_cast< quint32 >( result.size() );
+ if( !result.isEmpty() )
+ receivedStream.writeRawData( result.data(), result.size() );
+ }
+ else
+ {
+ // authorization failed, connection not wanted
+ socket.close();
+ return;
+ }
+ }
+}
+
+static QDataStream& operator<<( QDataStream& stream, const QSettings::Status& status )
+{
+ return stream << static_cast< int >( status );
+}
+
+/*!
+ Handles \a command and returns a QByteArray which has the result streamed into it.
+ */
+QByteArray FSEngineConnectionThread::handleCommand( const QString& command )
+{
+ QByteArray block;
+ QDataStream returnStream( &block, QIODevice::WriteOnly );
+ returnStream.setVersion( QDataStream::Qt_4_2 );
+
+ // first, QSettings handling
+ if( command == QLatin1String( "createQSettings" ) )
+ {
+ QString fileName;
+ receivedStream >> fileName;
+ settings = new QSettings( fileName, QSettings::NativeFormat );
+ }
+ else if( command == QLatin1String( "destroyQSettings" ) )
+ {
+ delete settings;
+ settings = 0;
+ }
+ else if( command == QLatin1String( "QSettings::allKeys" ) )
+ {
+ returnStream << settings->allKeys();
+ }
+ else if( command == QLatin1String( "QSettings::beginGroup" ) )
+ {
+ QString prefix;
+ receivedStream >> prefix;
+ settings->beginGroup( prefix );
+ }
+ else if( command == QLatin1String( "QSettings::beginReadArray" ) )
+ {
+ QString prefix;
+ int size;
+ receivedStream >> prefix;
+ receivedStream >> size;
+ settings->beginWriteArray( prefix, size );
+ }
+ else if( command == QLatin1String( "QSettings::beginWriteArray" ) )
+ {
+ QString prefix;
+ receivedStream >> prefix;
+ returnStream << settings->beginReadArray( prefix );
+ }
+ else if( command == QLatin1String( "QSettings::childGroups" ) )
+ {
+ returnStream << settings->childGroups();
+ }
+ else if( command == QLatin1String( "QSettings::childKeys" ) )
+ {
+ returnStream << settings->childKeys();
+ }
+ else if( command == QLatin1String( "QSettings::clear" ) )
+ {
+ settings->clear();
+ }
+ else if( command == QLatin1String( "QSettings::contains" ) )
+ {
+ QString key;
+ receivedStream >> key;
+ returnStream << settings->contains( key );
+ }
+ else if( command == QLatin1String( "QSettings::endArray" ) )
+ {
+ settings->endArray();
+ }
+ else if( command == QLatin1String( "QSettings::endGroup" ) )
+ {
+ settings->endGroup();
+ }
+ else if( command == QLatin1String( "QSettings::fallbacksEnabled" ) )
+ {
+ returnStream << settings->fallbacksEnabled();
+ }
+ else if( command == QLatin1String( "QSettings::fileName" ) )
+ {
+ returnStream << settings->fileName();
+ }
+ else if( command == QLatin1String( "QSettings::group" ) )
+ {
+ returnStream << settings->group();
+ }
+ else if( command == QLatin1String( "QSettings::isWritable" ) )
+ {
+ returnStream << settings->isWritable();
+ }
+ else if( command == QLatin1String( "QSettings::remove" ) )
+ {
+ QString key;
+ receivedStream >> key;
+ settings->remove( key );
+ }
+ else if( command == QLatin1String( "QSettings::setArrayIndex" ) )
+ {
+ int i;
+ receivedStream >> i;
+ settings->setArrayIndex( i );
+ }
+ else if( command == QLatin1String( "QSettings::setFallbacksEnabled" ) )
+ {
+ bool b;
+ receivedStream >> b;
+ settings->setFallbacksEnabled( b );
+ }
+ else if( command == QLatin1String( "QSettings::status" ) )
+ {
+ returnStream << settings->status();
+ }
+ else if( command == QLatin1String( "QSettings::sync" ) )
+ {
+ settings->sync();
+ }
+ else if( command == QLatin1String( "QSettings::setValue" ) )
+ {
+ QString key;
+ QVariant value;
+ receivedStream >> key;
+ receivedStream >> value;
+ settings->setValue( key, value );
+ }
+ else if( command == QLatin1String( "QSettings::value" ) )
+ {
+ QString key;
+ QVariant defaultValue;
+ receivedStream >> key;
+ receivedStream >> defaultValue;
+ returnStream << settings->value( key, defaultValue );
+ }
+
+ // from here, QProcess handling
+ else if( command == QLatin1String( "createQProcess" ) )
+ {
+ process = new QProcess;
+ signalReceiver = new QProcessSignalReceiver( process );
+ }
+ else if( command == QLatin1String( "destroyQProcess" ) )
+ {
+ signalReceiver->receivedSignals.clear();
+ process->deleteLater();
+ process = 0;
+ }
+ else if( command == QLatin1String( "getQProcessSignals" ) )
+ {
+ returnStream << signalReceiver->receivedSignals;
+ signalReceiver->receivedSignals.clear();
+ qApp->processEvents();
+ }
+ else if( command == QLatin1String( "QProcess::closeWriteChannel" ) )
+ {
+ process->closeWriteChannel();
+ }
+ else if( command == QLatin1String( "QProcess::exitCode" ) )
+ {
+ returnStream << process->exitCode();
+ }
+ else if( command == QLatin1String( "QProcess::exitStatus" ) )
+ {
+ returnStream << static_cast< int >( process->exitStatus() );
+ }
+ else if( command == QLatin1String( "QProcess::kill" ) )
+ {
+ process->kill();
+ }
+ else if( command == QLatin1String( "QProcess::readAll" ) )
+ {
+ returnStream << process->readAll();
+ }
+ else if( command == QLatin1String( "QProcess::readAllStandardOutput" ) )
+ {
+ returnStream << process->readAllStandardOutput();
+ }
+ else if( command == QLatin1String( "QProcess::startDetached" ) )
+ {
+ QString program;
+ QStringList arguments;
+ QString workingDirectory;
+ receivedStream >> program;
+ receivedStream >> arguments;
+ receivedStream >> workingDirectory;
+ qint64 pid;
+ const bool result = startDetached( program, arguments, workingDirectory, &pid );
+ returnStream << qMakePair< bool, qint64 >( result, pid );
+ }
+ else if( command == QLatin1String( "QProcess::setWorkingDirectory" ) )
+ {
+ QString dir;
+ receivedStream >> dir;
+ process->setWorkingDirectory( dir );
+ }
+ else if( command == QLatin1String( "QProcess::setEnvironment" ) )
+ {
+ QStringList env;
+ receivedStream >> env;
+ process->setEnvironment( env );
+ }
+ else if( command == QLatin1String( "QProcess::start" ) )
+ {
+ QString program;
+ QStringList arguments;
+ int mode;
+ receivedStream >> program;
+ receivedStream >> arguments;
+ receivedStream >> mode;
+ process->start( program, arguments, static_cast< QIODevice::OpenMode >( mode ) );
+ }
+ else if( command == QLatin1String( "QProcess::state" ) )
+ {
+ returnStream << static_cast< int >( process->state() );
+ }
+ else if( command == QLatin1String( "QProcess::terminate" ) )
+ {
+ process->terminate();
+ }
+ else if( command == QLatin1String( "QProcess::waitForFinished" ) )
+ {
+ int msecs;
+ receivedStream >> msecs;
+ returnStream << process->waitForFinished( msecs );
+ }
+ else if( command == QLatin1String( "QProcess::waitForStarted" ) )
+ {
+ int msecs;
+ receivedStream >> msecs;
+ returnStream << process->waitForStarted( msecs );
+ }
+ else if( command == QLatin1String( "QProcess::workingDirectory" ) )
+ {
+ returnStream << process->workingDirectory();
+ }
+ else if( command == QLatin1String( "QProcess::write" ) )
+ {
+ QByteArray byteArray;
+ receivedStream >> byteArray;
+ returnStream << process->write( byteArray );
+ }
+ else if( command == QLatin1String( "QProcess::readChannel" ) )
+ {
+ returnStream << static_cast< int >( process->readChannel() );
+ }
+ else if( command == QLatin1String( "QProcess::setReadChannel" ) )
+ {
+ int processChannel;
+ receivedStream >> processChannel;
+ process->setReadChannel( static_cast<QProcess::ProcessChannel>(processChannel) );
+ }
+ else if( command == QLatin1String( "QProcess::write" ) )
+ {
+ QByteArray byteArray;
+ receivedStream >> byteArray;
+ returnStream << process->write( byteArray );
+ }
+
+ // from here, QFSEngine handling
+ else if( command == QLatin1String( "QFSFileEngine::atEnd" ) )
+ {
+ returnStream << engine.atEnd();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::caseSensitive" ) )
+ {
+ returnStream << engine.caseSensitive();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::close" ) )
+ {
+ returnStream << engine.close();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::copy" ) )
+ {
+ QString newName;
+ receivedStream >> newName;
+ returnStream << engine.copy( newName );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::entryList" ) )
+ {
+ int filters;
+ QStringList filterNames;
+ receivedStream >> filters;
+ receivedStream >> filterNames;
+ returnStream << engine.entryList( static_cast< QDir::Filters >( filters ), filterNames );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::error" ) )
+ {
+ returnStream << static_cast< int >( engine.error() );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::errorString" ) )
+ {
+ returnStream << engine.errorString();
+ }
+ // extension
+ else if( command == QLatin1String( "QFSFileEngine::fileFlags" ) )
+ {
+ int flags;
+ receivedStream >> flags;
+ returnStream << static_cast< int >( engine.fileFlags( static_cast< QAbstractFileEngine::FileFlags >( flags ) ) );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::fileName" ) )
+ {
+ int file;
+ receivedStream >> file;
+ returnStream << engine.fileName( static_cast< QAbstractFileEngine::FileName >( file ) );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::flush" ) )
+ {
+ returnStream << engine.flush();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::handle" ) )
+ {
+ returnStream << engine.handle();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::isRelativePath" ) )
+ {
+ returnStream << engine.isRelativePath();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::isSequential" ) )
+ {
+ returnStream << engine.isSequential();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::link" ) )
+ {
+ QString newName;
+ receivedStream >> newName;
+ returnStream << engine.link( newName );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::mkdir" ) )
+ {
+ QString dirName;
+ bool createParentDirectories;
+ receivedStream >> dirName;
+ receivedStream >> createParentDirectories;
+ returnStream << engine.mkdir( dirName, createParentDirectories );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::open" ) )
+ {
+ int openMode;
+ receivedStream >> openMode;
+ returnStream << engine.open( static_cast< QIODevice::OpenMode >( openMode ) );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::owner" ) )
+ {
+ int owner;
+ receivedStream >> owner;
+ returnStream << engine.owner( static_cast< QAbstractFileEngine::FileOwner >( owner ) );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::ownerId" ) )
+ {
+ int owner;
+ receivedStream >> owner;
+ returnStream << engine.ownerId( static_cast< QAbstractFileEngine::FileOwner >( owner ) );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::pos" ) )
+ {
+ returnStream << engine.pos();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::read" ) )
+ {
+ qint64 maxlen;
+ receivedStream >> maxlen;
+ QByteArray ba( maxlen, '\0' );
+ const qint64 result = engine.read( ba.data(), maxlen );
+ returnStream << result;
+ int written = 0;
+ while( written < result )
+ written += returnStream.writeRawData( ba.data() + written, result - written );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::readLine" ) )
+ {
+ qint64 maxlen;
+ receivedStream >> maxlen;
+ QByteArray ba( maxlen, '\0' );
+ const qint64 result = engine.readLine( ba.data(), maxlen );
+ returnStream << result;
+ int written = 0;
+ while( written < result )
+ written += returnStream.writeRawData( ba.data() + written, result - written );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::remove" ) )
+ {
+ returnStream << engine.remove();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::rename" ) )
+ {
+ QString newName;
+ receivedStream >> newName;
+ returnStream << engine.rename( newName );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::rmdir" ) )
+ {
+ QString dirName;
+ bool recurseParentDirectories;
+ receivedStream >> dirName;
+ receivedStream >> recurseParentDirectories;
+ returnStream << engine.rmdir( dirName, recurseParentDirectories );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::seek" ) )
+ {
+ quint64 offset;
+ receivedStream >> offset;
+ returnStream << engine.seek( offset );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::setFileName" ) )
+ {
+ QString fileName;
+ receivedStream >> fileName;
+ engine.setFileName( fileName );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::setPermissions" ) )
+ {
+ uint perms;
+ receivedStream >> perms;
+ returnStream << engine.setPermissions( perms );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::setSize" ) )
+ {
+ qint64 size;
+ receivedStream >> size;
+ returnStream << engine.setSize( size );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::size" ) )
+ {
+ returnStream << engine.size();
+ }
+ else if( command == QLatin1String( "QFSFileEngine::supportsExtension" ) )
+ {
+ int extension;
+ receivedStream >> extension;
+ returnStream << false;//engine.supportsExtension( static_cast< QAbstractFileEngine::Extension >( extension ) );
+ }
+ else if( command == QLatin1String( "QFSFileEngine::write" ) )
+ {
+ qint64 length;
+ receivedStream >> length;
+ qint64 read = 0;
+ qint64 written = 0;
+ QByteArray buffer( 65536, '\0' );
+ while( read < length )
+ {
+ if( !receivedStream.device()->bytesAvailable() )
+ receivedStream.device()->waitForReadyRead( -1 );
+ const qint64 r = receivedStream.readRawData( buffer.data(), qMin( length - read, static_cast< qint64 >( buffer.length() ) ) );
+ read += r;
+ qint64 w = 0;
+ while( w < r )
+ w += engine.write( buffer.data(), r );
+ written += r;
+ }
+
+ returnStream << written;
+ }
+ else if( !command.isEmpty() )
+ {
+ qDebug() << "unknown command:" << command;
+ // unknown command...
+ }
+
+ return block;
+}
+
+#include "fsengineserver.moc"
+#include "moc_fsengineserver.cpp"
diff --git a/installerbuilder/libinstaller/fsengineserver.h b/installerbuilder/libinstaller/fsengineserver.h
new file mode 100644
index 000000000..20909f9e9
--- /dev/null
+++ b/installerbuilder/libinstaller/fsengineserver.h
@@ -0,0 +1,80 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef FSENGINESERVER_H
+#define FSENGINESERVER_H
+
+#include "installer_global.h"
+
+#include <KDToolsCore/KDWatchdog>
+
+#ifdef FSENGINE_TCP
+
+#include <QtNetwork/QTcpServer>
+
+class INSTALLER_EXPORT FSEngineServer : public QTcpServer
+{
+ Q_OBJECT
+public:
+ explicit FSEngineServer( quint16 port, QObject* parent = 0 );
+ FSEngineServer( const QHostAddress& address, quint16 port, QObject* parent = 0 );
+ ~FSEngineServer();
+
+ void setAuthorizationKey( const QString& key );
+ QString authorizationKey() const;
+
+protected:
+ void incomingConnection( int socketDescriptor );
+
+private:
+ QString key;
+ KDWatchdog watchdog;
+};
+
+#else
+
+
+#include <QtNetwork/QLocalServer>
+
+class INSTALLER_EXPORT FSEngineServer : public QLocalServer
+{
+ Q_OBJECT
+public:
+ explicit FSEngineServer( const QString& socket, QObject* parent = 0 );
+ ~FSEngineServer();
+
+ void setAuthorizationKey( const QString& key );
+ QString authorizationKey() const;
+
+protected:
+ void incomingConnection( quintptr socketDescriptor );
+
+private:
+ QString key;
+ KDWatchdog watchdog;
+};
+#endif
+
+#endif
diff --git a/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp b/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp
new file mode 100644
index 000000000..6c8b2f545
--- /dev/null
+++ b/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp
@@ -0,0 +1,183 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "getrepositoriesmetainfojob.h"
+#include "getrepositorymetainfojob.h"
+
+#include <cassert>
+
+using namespace KDUpdater;
+using namespace QInstaller;
+
+GetRepositoriesMetaInfoJob::GetRepositoriesMetaInfoJob(const QByteArray &publicKey,
+ bool packageManager, QObject *parent)
+ : KDJob(parent),
+ m_publicKey(publicKey),
+ m_canceled(false),
+ m_silentRetries(3),
+ m_packageManager(packageManager),
+ m_haveIgnoredError(false)
+{
+ setCapabilities(Cancelable);
+}
+
+QList< Repository > GetRepositoriesMetaInfoJob::repositories() const
+{
+ return m_repositories;
+}
+
+void GetRepositoriesMetaInfoJob::setRepositories(const QList<Repository>& repos)
+{
+ m_repositories = repos;
+}
+
+QStringList GetRepositoriesMetaInfoJob::temporaryDirectories() const
+{
+ return m_repositoryByTemporaryDirectory.keys();
+}
+
+QStringList GetRepositoriesMetaInfoJob::releaseTemporaryDirectories() const
+{
+ m_tempDirDeleter.releaseAll();
+ return m_repositoryByTemporaryDirectory.keys();
+}
+
+Repository GetRepositoriesMetaInfoJob::repositoryForTemporaryDirectory(const QString &tmpDir) const
+{
+ return m_repositoryByTemporaryDirectory.value(tmpDir);
+}
+
+int GetRepositoriesMetaInfoJob::numberOfRetrievedRepositories() const
+{
+ return m_repositoryByTemporaryDirectory.size();
+}
+
+int GetRepositoriesMetaInfoJob::silentRetries() const
+{
+ return m_silentRetries;
+}
+
+void GetRepositoriesMetaInfoJob::setSilentRetries(int retries)
+{
+ m_silentRetries = retries;
+}
+
+bool GetRepositoriesMetaInfoJob::isCanceled() const
+{
+ return m_canceled;
+}
+
+void GetRepositoriesMetaInfoJob::doStart()
+{
+ fetchNextRepo();
+}
+
+void GetRepositoriesMetaInfoJob::doCancel()
+{
+ m_canceled = true;
+ if (m_job)
+ m_job->cancel();
+}
+
+void GetRepositoriesMetaInfoJob::fetchNextRepo()
+{
+ if (m_job) {
+ m_job->deleteLater();
+ m_job = 0;
+ }
+
+ if (m_canceled) {
+ emitFinished();
+ return;
+ }
+ if (m_repositories.isEmpty()) {
+ if (m_haveIgnoredError)
+ emitFinishedWithError(UserIgnoreError, m_errorString);
+ else
+ emitFinished();
+ return;
+ }
+ const Repository r = m_repositories.back();
+ m_repositories.pop_back();
+ m_job = new GetRepositoryMetaInfoJob(m_publicKey, m_packageManager, this);
+ m_job->setRepository(r);
+ m_job->setSilentRetries(silentRetries());
+ connect(m_job, SIGNAL(finished(KDJob*)), this, SLOT(jobFinished(KDJob*)));
+ m_job->start();
+}
+
+void GetRepositoriesMetaInfoJob::slotInfoMessage(KDJob*, const QString& msg)
+{
+ emit infoMessage(this, msg);
+}
+
+void GetRepositoriesMetaInfoJob::jobFinished(KDJob* j)
+{
+ const GetRepositoryMetaInfoJob* const job = qobject_cast<const GetRepositoryMetaInfoJob*>(j);
+ assert(job);
+ if(job->error() != KDJob::NoError && !job->temporaryDirectory().isEmpty()) {
+ try {
+ removeDirectory(job->temporaryDirectory());
+ } catch(...) {
+ }
+ }
+
+ if (job->error() == KDJob::Canceled) {
+ emitFinishedWithError(job->error(), job->errorString());
+ return;
+ }
+
+ if (job->error() == GetRepositoryMetaInfoJob::UserIgnoreError) {
+ m_haveIgnoredError = true;
+ m_errorString = job->errorString();
+ QMetaObject::invokeMethod(this, "fetchNextRepo", Qt::QueuedConnection);
+ return;
+ }
+
+ if (job->error() == GetRepositoryMetaInfoJob::InvalidMetaInfo) {
+ emitFinishedWithError(KDJob::UserDefinedError, tr("Error while accessing online "
+ "repository: %1. Please try again later").arg(job->errorString()));
+ return;
+ }
+
+ if (job->error() != KDJob::NoError && job->repository().required()) {
+ emitFinishedWithError(KDJob::UserDefinedError, tr("Error while accessing online "
+ "repository: %1").arg(job->errorString()));
+ return;
+ }
+
+ const QString tmpdir = job->releaseTemporaryDirectory();
+ job->m_tempDirDeleter.passAndRelease(m_tempDirDeleter, tmpdir);
+ m_repositoryByTemporaryDirectory.insert(tmpdir, job->repository());
+
+ QMetaObject::invokeMethod(this, "fetchNextRepo", Qt::QueuedConnection);
+}
diff --git a/installerbuilder/libinstaller/getrepositoriesmetainfojob.h b/installerbuilder/libinstaller/getrepositoriesmetainfojob.h
new file mode 100644
index 000000000..4391dc151
--- /dev/null
+++ b/installerbuilder/libinstaller/getrepositoriesmetainfojob.h
@@ -0,0 +1,98 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef GETREPOSITORIESMETAINFOJOB_H
+#define GETREPOSITORIESMETAINFOJOB_H
+
+#include <KDToolsCore/KDJob>
+
+#include <QtCore/QList>
+#include <QtCore/QPointer>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+
+#include <common/fileutils.h>
+#include <common/repository.h>
+
+#include "installer_global.h"
+
+namespace KDUpdater {
+ class FileDownloader;
+}
+
+namespace QInstaller {
+
+class GetRepositoryMetaInfoJob;
+
+class INSTALLER_EXPORT GetRepositoriesMetaInfoJob : public KDJob
+{
+ Q_OBJECT
+
+public:
+ enum Error {
+ UserIgnoreError=KDJob::UserDefinedError + 1
+ };
+
+ explicit GetRepositoriesMetaInfoJob(const QByteArray &publicKey, bool packageManager = false,
+ QObject *parent = 0);
+
+ QList< Repository > repositories() const;
+ void setRepositories(const QList<Repository> &repos);
+
+ QStringList temporaryDirectories() const;
+ QStringList releaseTemporaryDirectories() const;
+ Repository repositoryForTemporaryDirectory(const QString &tmpDir) const;
+
+ int numberOfRetrievedRepositories() const;
+
+ int silentRetries() const;
+ void setSilentRetries(int retries);
+
+ bool isCanceled() const;
+
+private Q_SLOTS:
+ /* reimp */ void doStart();
+ /* reimp */ void doCancel();
+
+ void fetchNextRepo();
+ void jobFinished(KDJob*);
+ void slotInfoMessage(KDJob*, const QString&);
+
+private:
+ QPointer<GetRepositoryMetaInfoJob> m_job;
+ const QByteArray m_publicKey;
+ bool m_canceled;
+ int m_silentRetries;
+ bool m_packageManager;
+ QList<Repository> m_repositories;
+ QHash<QString, Repository> m_repositoryByTemporaryDirectory;
+ bool m_haveIgnoredError;
+ QString m_errorString;
+ mutable TempDirDeleter m_tempDirDeleter;
+};
+
+} // namespace QInstaller
+
+#endif // GETREPOSITORIESMETAINFOJOB_H
diff --git a/installerbuilder/libinstaller/getrepositorymetainfojob.cpp b/installerbuilder/libinstaller/getrepositorymetainfojob.cpp
new file mode 100644
index 000000000..ffeace700
--- /dev/null
+++ b/installerbuilder/libinstaller/getrepositorymetainfojob.cpp
@@ -0,0 +1,425 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "getrepositorymetainfojob.h"
+
+#include "common/errors.h"
+#include "common/utils.h"
+#include "cryptosignatureverifier.h"
+#include "lib7z_facade.h"
+#include "messageboxhandler.h"
+
+#include <KDUpdater/FileDownloader>
+#include <KDUpdater/FileDownloaderFactory>
+#include <KDUpdater/SignatureVerifier>
+#include <KDUpdater/SignatureVerificationResult>
+#include <KDUpdater/kdupdatercrypto.h>
+
+#include <QtCore/QFile>
+#include <QtCore/QTimer>
+#include <QtCore/QUrl>
+
+#include <QtGui/QMessageBox>
+
+#include <QtXml/QDomDocument>
+#include <QtXml/QDomElement>
+
+#include <cassert>
+
+using namespace KDUpdater;
+using namespace QInstaller;
+
+GetRepositoryMetaInfoJob::GetRepositoryMetaInfoJob(const QByteArray &publicKey,
+ bool packageManager, QObject *parent)
+ : KDJob(parent),
+ m_canceled(false),
+ m_silentRetries(3),
+ m_retriesLeft(m_silentRetries),
+ m_packageManager(packageManager),
+ m_publicKey(publicKey),
+ m_downloader()
+{
+ setCapabilities(Cancelable);
+}
+
+GetRepositoryMetaInfoJob::~GetRepositoryMetaInfoJob()
+{
+ delete m_downloader;
+}
+
+Repository GetRepositoryMetaInfoJob::repository() const
+{
+ return m_repository;
+}
+
+void GetRepositoryMetaInfoJob::setRepository(const Repository &r)
+{
+ m_repository = r;
+ verbose() << "Setting repository with URL : " << r.url().toString() << std::endl;
+}
+
+int GetRepositoryMetaInfoJob::silentRetries() const
+{
+ return m_silentRetries;
+}
+
+void GetRepositoryMetaInfoJob::setSilentRetries(int retries)
+{
+ m_silentRetries = retries;
+}
+
+void GetRepositoryMetaInfoJob::doStart()
+{
+ m_retriesLeft = m_silentRetries;
+ startUpdatesXmlDownload();
+}
+
+void GetRepositoryMetaInfoJob::doCancel()
+{
+ m_canceled = true;
+ if (m_downloader)
+ m_downloader->cancelDownload();
+}
+
+QString GetRepositoryMetaInfoJob::temporaryDirectory() const
+{
+ return m_temporaryDirectory;
+}
+
+QString GetRepositoryMetaInfoJob::releaseTemporaryDirectory() const
+{
+ m_tempDirDeleter.releaseAll();
+ return m_temporaryDirectory;
+}
+
+// updates.xml download
+
+void GetRepositoryMetaInfoJob::startUpdatesXmlDownload()
+{
+ if (m_downloader) {
+ m_downloader->deleteLater();
+ m_downloader = 0;
+ }
+
+ const QUrl url = m_repository.url();
+ if (url.isEmpty()) {
+ emitFinishedWithError(InvalidUrl, tr("empty repository URL"));
+ return;
+ }
+ if (!url.isValid()) {
+ emitFinishedWithError(InvalidUrl, tr("invalid repository URL"));
+ return;
+ }
+ m_downloader = FileDownloaderFactory::instance().create(url.scheme(), 0, QUrl(), this);
+ if (!m_downloader) {
+ emitFinishedWithError(InvalidUrl, tr("URL scheme not supported: %1 (%2)").arg(url.scheme(),
+ url.toString()));
+ return;
+ }
+
+ m_downloader->setUrl(QUrl(url.toString() + QLatin1String("/Updates.xml")));
+ m_downloader->setAutoRemoveDownloadedFile(false);
+ connect(m_downloader, SIGNAL(downloadCompleted()), this, SLOT(updatesXmlDownloadFinished()));
+ connect(m_downloader, SIGNAL(downloadCanceled()), this, SLOT(updatesXmlDownloadCanceled()));
+ connect(m_downloader, SIGNAL(downloadAborted(QString)), this,
+ SLOT(updatesXmlDownloadError(QString)), Qt::QueuedConnection);
+ m_downloader->download();
+}
+
+void GetRepositoryMetaInfoJob::updatesXmlDownloadCanceled()
+{
+ emitFinishedWithError(Canceled, m_downloader->errorString());
+}
+
+void GetRepositoryMetaInfoJob::updatesXmlDownloadFinished()
+{
+ const QString fn = m_downloader->downloadedFileName();
+
+ assert(!fn.isEmpty());
+ assert(QFile::exists(fn));
+ try {
+ m_temporaryDirectory = createTemporaryDirectory(QLatin1String("remoterepo"));
+ m_tempDirDeleter.add(m_temporaryDirectory);
+ } catch (const QInstaller::Error& e) {
+ emitFinishedWithError(ExtractionError, e.message());
+ return;
+ }
+ QFile file(fn);
+ const QString updatesXmlPath = m_temporaryDirectory + QLatin1String("/Updates.xml");
+ if (!file.rename(updatesXmlPath)) {
+ emitFinishedWithError(DownloadError,
+ tr("Could not move Updates.xml to target location: %1").arg(file.errorString()));
+ return;
+ }
+
+ QFile updatesFile(updatesXmlPath);
+ if (!updatesFile.open(QIODevice::ReadOnly)) {
+ emitFinishedWithError(DownloadError,
+ tr("Could not open Updates.xml for reading: %1").arg(updatesFile.errorString()));
+ return;
+ }
+
+ QDomDocument doc;
+ QString err;
+ int line = 0;
+ int col = 0;
+ if (!doc.setContent(&updatesFile, &err, &line, &col)) {
+ QMessageBox::StandardButtons buttons = QMessageBox::Cancel;
+ QString packageManagerMessage;
+ if (m_packageManager) {
+ buttons |= QMessageBox::Ok;
+ packageManagerMessage = tr("\nOnly uninstallation is possible.");
+ }
+ const QMessageBox::StandardButton b =
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("updatesXmlDownloadError"), tr("Download Error"), tr("Could not fetch a "
+ "valid version of Updates.xml: %1%2").arg(err, packageManagerMessage), buttons);
+
+ if (b == QMessageBox::Cancel) {
+ emitFinishedWithError(KDJob::Canceled, tr("Could not fetch Updates.xml: %1").arg(err));
+ return;
+ }
+
+ if (b == QMessageBox::Ok) {
+ emitFinishedWithError(GetRepositoryMetaInfoJob::UserIgnoreError, tr("Could not fetch "
+ "Updates.xml: %1").arg(err));
+ return;
+ }
+ //emitFinishedWithError(InvalidMetaInfo, tr("Could not parse component index: %1:%2: %3")
+ // .arg(QString::number(line), QString::number(col), err));
+ }
+
+ const QDomElement root = doc.documentElement();
+ const QDomNodeList children = root.childNodes();
+ for (int i = 0; i < children.count(); ++i) {
+ const QDomElement el = children.at(i).toElement();
+ if (el.isNull())
+ continue;
+ if (el.tagName() == QLatin1String("PackageUpdate")) {
+ const QDomNodeList c2 = el.childNodes();
+ for (int j = 0; j < c2.count(); ++j)
+ if (c2.at(j).toElement().tagName() == QLatin1String("Name"))
+ m_packageNames << c2.at(j).toElement().text();
+ else if (c2.at(j).toElement().tagName() == QLatin1String("Version"))
+ m_packageVersions << c2.at(j).toElement().text();
+ else if (c2.at(j).toElement().tagName() == QLatin1String("SHA1"))
+ m_packageHash << c2.at(j).toElement().text();
+ }
+ }
+
+ setTotalAmount(m_packageNames.count() + 1);
+ setProcessedAmount(1);
+ if (m_packageNames.isEmpty()) {
+ emitFinished();
+ return;
+ }
+ emit infoMessage(this, tr("Retrieving component meta information..."));
+ fetchNextMetaInfo();
+}
+
+void GetRepositoryMetaInfoJob::updatesXmlDownloadError(const QString &err)
+{
+ if (m_retriesLeft == 0) {
+ QMessageBox::StandardButtons buttons = QMessageBox::Retry | QMessageBox::Cancel;
+ QString packageManagerMessage;
+ if (m_packageManager) {
+ buttons |= QMessageBox::Ok;
+ packageManagerMessage = tr("\nOnly uninstallation is possible.");
+ }
+ const QMessageBox::StandardButton b =
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("updatesXmlDownloadError"), tr("Download Error"), tr("Could not fetch "
+ "Updates.xml: %1%2").arg(err, packageManagerMessage), buttons);
+
+ if (b == QMessageBox::Cancel || b == QMessageBox::NoButton) {
+ emitFinishedWithError(KDJob::Canceled, tr("Could not fetch Updates.xml: %1").arg(err));
+ return;
+ }
+
+ if (b == QMessageBox::Ok) {
+ emitFinishedWithError(GetRepositoryMetaInfoJob::UserIgnoreError, tr("Could not fetch "
+ "Updates.xml: %1").arg(err));
+ return;
+ }
+ }
+
+ m_retriesLeft--;
+ QTimer::singleShot(1500, this, SLOT(startUpdatesXmlDownload()));
+}
+
+// meta data download
+
+void GetRepositoryMetaInfoJob::fetchNextMetaInfo()
+{
+ if (m_canceled)
+ return;
+
+ if (m_packageNames.isEmpty() && m_currentPackageName.isEmpty()) {
+ emitFinished();
+ return;
+ }
+
+ QString next = m_currentPackageName;
+ QString nextVersion = m_currentPackageVersion;
+ if (next.isEmpty()) {
+ next = m_packageNames.back();
+ m_packageNames.pop_back();
+ m_retriesLeft = m_silentRetries;
+ nextVersion = m_packageVersions.back();
+ m_packageVersions.pop_back();
+ }
+
+ verbose() << "fetching metadata of " << next << " in version " << nextVersion << std::endl;
+
+ bool online = true;
+ if (m_repository.url().scheme().isEmpty())
+ online = false;
+
+ const QString repoUrl = m_repository.url().toString();
+ const QUrl url = QString::fromLatin1("%1/%2/%3meta.7z").arg(repoUrl, next,
+ online ? nextVersion : QLatin1String(""));
+
+ // must be deleteLater: this code is executed from slots listening to m_downloader, avoid
+ // reentrancy issues
+ m_downloader->deleteLater();
+ if (!m_publicKey.isEmpty()) {
+ const CryptoSignatureVerifier verifier(m_publicKey);
+ const QUrl sigUrl = QString::fromLatin1("%1/%2/meta.7z.sig").arg(repoUrl, next);
+ m_downloader = FileDownloaderFactory::instance().create(url.scheme(), &verifier, sigUrl, this);
+ } else {
+ m_downloader = FileDownloaderFactory::instance().create(url.scheme(), this);
+ }
+
+ if (!m_downloader) {
+ qWarning() << "Scheme not supported:" << next;
+ m_currentPackageName.clear();
+ m_currentPackageVersion.clear();
+ QMetaObject::invokeMethod(this, "fetchNextMetaInfo", Qt::QueuedConnection);
+ return;
+ }
+
+ m_currentPackageName = next;
+ m_currentPackageVersion = nextVersion;
+ m_downloader->setUrl(url);
+ m_downloader->setAutoRemoveDownloadedFile(true);
+
+ connect(m_downloader, SIGNAL(downloadCanceled()), this, SLOT(metaDownloadCanceled()));
+ connect(m_downloader, SIGNAL(downloadCompleted()), this, SLOT(metaDownloadFinished()));
+ connect(m_downloader, SIGNAL(downloadAborted(QString)), this, SLOT(metaDownloadError(QString)),
+ Qt::QueuedConnection);
+
+ m_downloader->download();
+
+ emit infoMessage(this, tr("Retrieving component information from remote repositories..."));
+}
+
+void GetRepositoryMetaInfoJob::metaDownloadCanceled()
+{
+ updatesXmlDownloadCanceled();
+}
+
+void GetRepositoryMetaInfoJob::metaDownloadFinished()
+{
+ const QString fn = m_downloader->downloadedFileName();
+ assert(!fn.isEmpty());
+
+ QFile arch(fn);
+ if (!arch.open(QIODevice::ReadOnly)) {
+ emitFinishedWithError(ExtractionError, tr("Could not open meta info archive %1: %2").arg(fn,
+ arch.errorString()));
+ return;
+ }
+
+ if (!m_packageHash.isEmpty()) {
+ //verify file hash
+ QByteArray expectedFileHash = m_packageHash.back().toLatin1();
+ QByteArray archContent = arch.readAll();
+ QByteArray realFileHash = QString::fromLatin1(QCryptographicHash::hash(archContent,
+ QCryptographicHash::Sha1).toHex()).toLatin1();
+ if (expectedFileHash != realFileHash) {
+ metaDownloadError(tr("Bad hash"));
+ return;
+ }
+ m_currentPackageName.clear();
+ m_packageHash.pop_back();
+ }
+
+ try {
+ // TODO: make this threaded
+ Lib7z::extractArchive(&arch, m_temporaryDirectory);
+ if (!arch.remove())
+ qWarning("Could not delete file %s: %s", qPrintable(fn), qPrintable(arch.errorString()));
+ } catch (const Lib7z::SevenZipException& e) {
+ emitFinishedWithError(ExtractionError, tr("Could not open meta info archive %1: %2").arg(fn,
+ e.message()));
+ return;
+ }
+
+ fetchNextMetaInfo();
+}
+
+void GetRepositoryMetaInfoJob::metaDownloadError(const QString &err)
+{
+ if (err == QObject::tr("Bad signature"))
+ emit infoMessage(this, tr("The RSA signature of one component could not be verified."));
+
+ if (err == QObject::tr("Bad hash"))
+ emit infoMessage(this, tr("The hash of one component does not match the expected one."));
+
+ if (m_retriesLeft == 0) {
+ QMessageBox::StandardButtons buttons = QMessageBox::Retry | QMessageBox::Cancel;
+ QString packageManagerMessage;
+ if (m_packageManager) {
+ buttons |= QMessageBox::Ok;
+ packageManagerMessage = tr("\nOnly uninstallation is possible.");
+ }
+
+ const QMessageBox::StandardButton b =
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("updatesXmlDownloadError"), tr("Download Error"), tr("Could not download "
+ "information for component %1: %2%3") .arg(m_currentPackageName, err,
+ packageManagerMessage), buttons);
+
+ if (b == QMessageBox::Cancel) {
+ emitFinishedWithError(Canceled, tr("Canceled"));
+ return;
+ }
+
+ if (b == QMessageBox::Ok) {
+ emitFinishedWithError(GetRepositoryMetaInfoJob::UserIgnoreError, tr("%1").arg(err));
+ return;
+ }
+ }
+
+ m_retriesLeft--;
+ QTimer::singleShot(1500, this, SLOT(fetchNextMetaInfo()));
+}
diff --git a/installerbuilder/libinstaller/getrepositorymetainfojob.h b/installerbuilder/libinstaller/getrepositorymetainfojob.h
new file mode 100644
index 000000000..a428f3b20
--- /dev/null
+++ b/installerbuilder/libinstaller/getrepositorymetainfojob.h
@@ -0,0 +1,110 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef GETREPOSITORYMETAINFOJOB_H
+#define GETREPOSITORYMETAINFOJOB_H
+
+#include <KDToolsCore/KDJob>
+
+#include <QtCore/QPointer>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+
+#include <common/fileutils.h>
+#include <common/repository.h>
+
+#include "installer_global.h"
+
+namespace KDUpdater {
+ class FileDownloader;
+}
+
+namespace QInstaller {
+
+class GetRepositoriesMetaInfoJob;
+
+class INSTALLER_EXPORT GetRepositoryMetaInfoJob : public KDJob
+{
+ Q_OBJECT
+ friend class ::QInstaller::GetRepositoriesMetaInfoJob;
+
+public:
+ enum Error {
+ InvalidUrl = KDJob::UserDefinedError,
+ DownloadError,
+ InvalidUpdatesXml,
+ InvalidMetaInfo,
+ ExtractionError,
+ UserIgnoreError
+ };
+
+ explicit GetRepositoryMetaInfoJob(const QByteArray &publicKey = QByteArray(),
+ bool packageManager = false, QObject *parent = 0);
+ ~GetRepositoryMetaInfoJob();
+
+ Repository repository() const;
+ void setRepository(const Repository &r);
+
+ int silentRetries() const;
+ void setSilentRetries(int retries);
+
+ QString temporaryDirectory() const;
+ QString releaseTemporaryDirectory() const;
+
+private:
+ /* reimp */ void doStart();
+ /* reimp */ void doCancel();
+
+private Q_SLOTS:
+ void startUpdatesXmlDownload();
+ void updatesXmlDownloadCanceled();
+ void updatesXmlDownloadFinished();
+ void updatesXmlDownloadError(const QString &error);
+
+ void fetchNextMetaInfo();
+ void metaDownloadCanceled();
+ void metaDownloadFinished();
+ void metaDownloadError(const QString &error);
+
+private:
+ bool m_canceled;
+ int m_silentRetries;
+ int m_retriesLeft;
+ bool m_packageManager;
+ const QByteArray m_publicKey;
+ Repository m_repository;
+ QStringList m_packageNames;
+ QStringList m_packageVersions;
+ QStringList m_packageHash;
+ QPointer<KDUpdater::FileDownloader> m_downloader;
+ QString m_currentPackageName;
+ QString m_currentPackageVersion;
+ QString m_temporaryDirectory;
+ mutable TempDirDeleter m_tempDirDeleter;
+};
+
+} // namespace QInstaller
+
+#endif // GETREPOSITORYMETAINFOJOB_H
diff --git a/installerbuilder/libinstaller/globalsettingsoperation.cpp b/installerbuilder/libinstaller/globalsettingsoperation.cpp
new file mode 100644
index 000000000..d3cf99797
--- /dev/null
+++ b/installerbuilder/libinstaller/globalsettingsoperation.cpp
@@ -0,0 +1,128 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "globalsettingsoperation.h"
+#include "fsengineclient.h"
+
+using namespace QInstaller;
+
+GlobalSettingsOperation::GlobalSettingsOperation()
+{
+ setName(QLatin1String("GlobalConfig"));
+}
+
+GlobalSettingsOperation::~GlobalSettingsOperation()
+{
+}
+
+void GlobalSettingsOperation::backup()
+{
+}
+
+bool GlobalSettingsOperation::performOperation()
+{
+ QString key, value;
+ QScopedPointer<QSettingsWrapper> settings(setup(&key, &value, arguments()));
+ if (settings.isNull())
+ return false;
+
+ if (!settings->isWritable()) {
+ setError(UserDefinedError);
+ setErrorString(tr("Settings are not writable"));
+ return false;
+ }
+
+ const QVariant oldValue = settings->value(key);
+ settings->setValue(key, value);
+ settings->sync();
+
+ if (settings->status() != QSettings::NoError) {
+ setError(UserDefinedError);
+ setErrorString(tr("Failed to write settings"));
+ return false;
+ }
+
+ setValue(QLatin1String("oldvalue"), oldValue);
+ return true;
+}
+
+bool GlobalSettingsOperation::undoOperation()
+{
+ QString key, val;
+ QScopedPointer<QSettingsWrapper> settings(setup(&key, &val, arguments()));
+ if (settings.isNull())
+ return false;
+
+ // be sure it's still our value and nobody changed it in between
+ const QVariant oldValue = value(QLatin1String("oldvalue"));
+ if (settings->value(key) == val) {
+ // restore the previous state
+ if (oldValue.isNull())
+ settings->remove(key);
+ else
+ settings->setValue(key, oldValue);
+ }
+
+ return true;
+}
+
+bool GlobalSettingsOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* GlobalSettingsOperation::clone() const
+{
+ return new GlobalSettingsOperation();
+}
+
+QSettingsWrapper* GlobalSettingsOperation::setup(QString *key, QString *value,
+ const QStringList &arguments)
+{
+ if (arguments.count() == 4) {
+ const QString &company = arguments.at(0);
+ const QString &application = arguments.at(1);
+ *key = arguments.at(2);
+ *value = arguments.at(3);
+ return new QSettingsWrapper(company, application);
+ } else if (arguments.count() == 3) {
+ const QString &filename = arguments.at(0);
+ *key = arguments.at(1);
+ *value = arguments.at(2);
+ return new QSettingsWrapper(filename, QSettings::NativeFormat);
+ }
+
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in 0%: %1 arguments given, at least 3 expected.")
+ .arg(name()).arg(arguments.count()));
+ return 0;
+}
diff --git a/installerbuilder/libinstaller/globalsettingsoperation.h b/installerbuilder/libinstaller/globalsettingsoperation.h
new file mode 100644
index 000000000..a8eab3473
--- /dev/null
+++ b/installerbuilder/libinstaller/globalsettingsoperation.h
@@ -0,0 +1,53 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef GLOBALSETTINGSOPERATION_H
+#define GLOBALSETTINGSOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+class QSettingsWrapper;
+class QStringList;
+
+namespace QInstaller {
+
+class GlobalSettingsOperation : public KDUpdater::UpdateOperation
+{
+public:
+ GlobalSettingsOperation();
+ ~GlobalSettingsOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+
+private:
+ QSettingsWrapper* setup(QString *key, QString *value, const QStringList &args);
+};
+
+}; // namespace
+#endif // GLOBALSETTINGSOPERATION_H
diff --git a/installerbuilder/libinstaller/init.cpp b/installerbuilder/libinstaller/init.cpp
new file mode 100644
index 000000000..07512808a
--- /dev/null
+++ b/installerbuilder/libinstaller/init.cpp
@@ -0,0 +1,204 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "init.h"
+
+#include "createshortcutoperation.h"
+#include "createdesktopentryoperation.h"
+#include "extractarchiveoperation.h"
+#include "globalsettingsoperation.h"
+#include "environmentvariablesoperation.h"
+#include "registerfiletypeoperation.h"
+#include "selfrestartoperation.h"
+#include "installiconsoperation.h"
+#include "elevatedexecuteoperation.h"
+#include "fakestopprocessforupdateoperation.h"
+
+//added for NDK
+#include "copydirectoryoperation.h"
+#include "qtpatchoperation.h"
+#include "setdemospathonqtoperation.h"
+#include "setexamplespathonqtoperation.h"
+#include "setpluginpathonqtcoreoperation.h"
+#include "setimportspathonqtcoreoperation.h"
+#include "replaceoperation.h"
+#include "licenseoperation.h"
+#include "linereplaceoperation.h"
+#include "registerdocumentationoperation.h"
+#include "registerqtoperation.h"
+#include "setqtcreatorvalueoperation.h"
+#include "simplemovefileoperation.h"
+
+#include "minimumprogressoperation.h"
+
+#ifdef Q_OS_MAC
+ #include "macreplaceinstallnamesoperation.h"
+#endif // Q_OS_MAC
+
+#include "common/utils.h"
+
+
+#include <QtPlugin>
+
+#include <KDUpdater/UpdateOperation>
+#include <KDUpdater/UpdateOperationFactory>
+#include <KDUpdater/FileDownloaderFactory>
+
+#include <QNetworkProxyFactory>
+
+#include <unix/C/7zCrc.h>
+
+namespace NArchive
+{
+namespace NBz2{void registerArcBZip2();}
+namespace NGz{void registerArcGZip();}
+namespace NLzma{ namespace NLzmaAr { void registerArcLzma();}}
+namespace NLzma{ namespace NLzma86Ar { void registerArcLzma86();}}
+namespace NSplit{void registerArcSplit();}
+namespace NXz{void registerArcxz();}
+namespace NZ{void registerArcZ();}
+}
+void registerArc7z();
+void registerArcCab();
+void registerArcTar();
+void registerArcZip();
+
+void registerCodecBCJ2();
+void registerCodecBCJ();
+void registerCodecBCJ();
+void registerCodecByteSwap();
+void registerCodecBZip2();
+void registerCodecCopy();
+void registerCodecDeflate64();
+void registerCodecDeflate();
+void registerCodecDelta();
+void registerCodecLZMA2();
+void registerCodecLZMA();
+void registerCodecPPMD();
+void registerCodec7zAES();
+
+using namespace NArchive;
+
+static void initArchives()
+{
+ NBz2::registerArcBZip2();
+ NGz::registerArcGZip();
+ NLzma::NLzmaAr::registerArcLzma();
+ NLzma::NLzma86Ar::registerArcLzma86();
+ NArchive::NSplit::registerArcSplit();
+ NArchive::NXz::registerArcxz();
+ NArchive::NZ::registerArcZ();
+ registerArc7z();
+ registerArcCab();
+ registerArcTar();
+ registerArcZip();
+
+ registerCodecBCJ2();
+ registerCodecBCJ();
+ registerCodecBCJ();
+ registerCodecByteSwap();
+ registerCodecBZip2();
+ registerCodecCopy();
+ registerCodecDeflate64();
+ registerCodecDeflate();
+ registerCodecDelta();
+ registerCodecLZMA2();
+ registerCodecLZMA();
+ registerCodecPPMD();
+ registerCodec7zAES();
+
+ CrcGenerateTable();
+}
+
+static void initResources()
+{
+ Q_INIT_RESOURCE( openssl );
+ Q_INIT_RESOURCE( patch_file_lists );
+#if !defined( QT_SHARED ) && !defined( QT_DLL )
+ Q_IMPORT_PLUGIN( qsqlite ); //RegisterDocumentationOperation needs this
+#endif
+}
+
+static void messageHandler( QtMsgType type, const char* msg )
+{
+ QInstaller::verbose() << msg << std::endl;
+ if (type != QtFatalMsg && QString::fromLatin1(msg).contains(QLatin1String("Object::connect: "))) {
+ //qFatal(msg);
+ }
+}
+
+void QInstaller::init()
+{
+ ::initResources();
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::CreateShortcutOperation >( QLatin1String( "CreateShortcut" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::CreateDesktopEntryOperation >( QLatin1String( "CreateDesktopEntry" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::ExtractArchiveOperation >( QLatin1String( "Extract" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::GlobalSettingsOperation >( QLatin1String( "GlobalConfig" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::EnvironmentVariableOperation >( QLatin1String( "EnvironmentVariable" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterFileTypeOperation >( QLatin1String( "RegisterFileType" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SelfRestartOperation >( QLatin1String( "SelfRestart" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::InstallIconsOperation >( QLatin1String( "InstallIcons" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::ElevatedExecuteOperation >( QLatin1String( "Execute" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::FakeStopProcessForUpdateOperation >( QLatin1String( "FakeStopProcessForUpdate" ) );
+
+ //added for NDK
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SimpleMoveFileOperation >( QLatin1String( "SimpleMoveFile") );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::CopyDirectoryOperation >( QLatin1String( "CopyDirectory") );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterDocumentationOperation >( QLatin1String( "RegisterDocumentation") );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterQtInCreatorOperation>( QLatin1String( "RegisterQtInCreator") );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetDemosPathOnQtOperation>( QLatin1String( "SetDemosPathOnQt") );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetExamplesPathOnQtOperation>( QLatin1String( "SetExamplesPathOnQt") );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetPluginPathOnQtCoreOperation>( QLatin1String( "SetPluginPathOnQtCore") );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetImportsPathOnQtCoreOperation>( QLatin1String( "SetImportsPathOnQtCore") );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetQtCreatorValueOperation>( QLatin1String( "SetQtCreatorValue") );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::QtPatchOperation >( QLatin1String( "QtPatch" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::ReplaceOperation >( QLatin1String( "Replace" ) );
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::LineReplaceOperation >( QLatin1String( "LineReplace" ) );
+
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::MinimumProgressOperation>(QLatin1String("MinimumProgress"));
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::LicenseOperation>(QLatin1String("License"));
+
+ KDUpdater::FileDownloaderFactory::setFollowRedirects( true );
+
+#ifdef Q_OS_MAC
+ KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::MacReplaceInstallNamesOperation >( QLatin1String( "ReplaceInstallNames" ) );
+#endif // Q_OS_MAC
+
+ // load 7z stuff, if we're a static lib
+ ::initArchives();
+
+ // proxy settings
+ //QNetworkProxyFactory::setUseSystemConfiguration( true );
+
+ // qDebug -> verbose()
+ qInstallMsgHandler( messageHandler );
+}
diff --git a/installerbuilder/libinstaller/init.h b/installerbuilder/libinstaller/init.h
new file mode 100644
index 000000000..3d979bbdb
--- /dev/null
+++ b/installerbuilder/libinstaller/init.h
@@ -0,0 +1,35 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_INIT_H
+#define QINSTALLER_INIT_H
+
+#include "installer_global.h"
+
+namespace QInstaller {
+ void INSTALLER_EXPORT init();
+}
+
+#endif // QINSTALLER_INIT_H
diff --git a/installerbuilder/libinstaller/installationprogressdialog.cpp b/installerbuilder/libinstaller/installationprogressdialog.cpp
new file mode 100644
index 000000000..44bfb1966
--- /dev/null
+++ b/installerbuilder/libinstaller/installationprogressdialog.cpp
@@ -0,0 +1,87 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "installationprogressdialog.h"
+#include "performinstallationform.h"
+#include "progresscoordinator.h"
+#include "common/utils.h"
+
+#include <QtGui/QDialogButtonBox>
+#include <QtGui/QLayout>
+#include <QtGui/QPushButton>
+
+using namespace QInstaller;
+
+InstallationProgressDialog::InstallationProgressDialog(QWidget *parent)
+ : QDialog(parent),
+ m_performInstallationForm(new PerformInstallationForm(this))
+{
+ m_performInstallationForm->setupUi(this);
+ connect(ProgressCoordninator::instance(), SIGNAL( detailTextChanged( QString ) ),
+ m_performInstallationForm, SLOT( appendProgressDetails( QString ) ) );
+ connect(ProgressCoordninator::instance(), SIGNAL(detailTextResetNeeded()),
+ m_performInstallationForm, SLOT(clearDetailsBrowser()));
+
+ m_dialogBtns = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal, this);
+ m_dialogBtns->button(QDialogButtonBox::Ok)->setEnabled(false);
+ layout()->addWidget( m_dialogBtns );
+
+ connect(m_dialogBtns, SIGNAL( rejected() ), this, SIGNAL( canceled() ) );
+ connect(m_dialogBtns, SIGNAL( rejected() ), this, SLOT( reject() ) );
+ connect(m_dialogBtns, SIGNAL( accepted() ), this, SLOT( close() ) );
+
+ m_dialogBtns->button( QDialogButtonBox::Ok )->setEnabled( false );
+ m_dialogBtns->button( QDialogButtonBox::Cancel )->setEnabled( true );
+
+ m_performInstallationForm->enableDetails();
+ m_performInstallationForm->startUpdateProgress();
+}
+
+InstallationProgressDialog::~InstallationProgressDialog()
+{
+ delete m_performInstallationForm;
+}
+
+
+//bool InstallationProgressDialog::isShowingDetails() const
+//{
+// return m_performInstallationForm->isShowingDetails();
+//}
+
+void InstallationProgressDialog::finished()
+{
+ m_performInstallationForm->stopUpdateProgress();
+ m_performInstallationForm->scrollDetailsToTheEnd();
+ m_performInstallationForm->setDetailsButtonEnabled(false);
+ m_dialogBtns->button(QDialogButtonBox::Ok)->setEnabled( true );
+ m_dialogBtns->button(QDialogButtonBox::Cancel)->setEnabled( false );
+}
diff --git a/installerbuilder/libinstaller/installationprogressdialog.h b/installerbuilder/libinstaller/installationprogressdialog.h
new file mode 100644
index 000000000..5523b28f3
--- /dev/null
+++ b/installerbuilder/libinstaller/installationprogressdialog.h
@@ -0,0 +1,53 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef INSTALLATIONPROGRESSDIALOG_H
+#define INSTALLATIONPROGRESSDIALOG_H
+
+#include <QtGui/QDialog>
+
+class QDialogButtonBox;
+
+namespace QInstaller {
+
+class PerformInstallationForm;
+
+class InstallationProgressDialog : public QDialog{
+ Q_OBJECT
+public:
+ explicit InstallationProgressDialog( QWidget* parent=0 );
+ ~InstallationProgressDialog();
+ //bool isShowingDetails() const;
+Q_SIGNALS:
+ void canceled();
+
+private Q_SLOTS:
+ void finished();
+private:
+ PerformInstallationForm *m_performInstallationForm;
+ QDialogButtonBox* m_dialogBtns;
+};
+} //namespace QInstaller
+#endif
diff --git a/installerbuilder/libinstaller/installer_global.h b/installerbuilder/libinstaller/installer_global.h
new file mode 100644
index 000000000..691cfe26e
--- /dev/null
+++ b/installerbuilder/libinstaller/installer_global.h
@@ -0,0 +1,51 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef INSTALLER_GLOBAL_H
+#define INSTALLER_GLOBAL_H
+
+#include <QtCore/QtGlobal>
+
+#ifdef LIB_INSTALLER_SHARED
+#ifdef BUILD_LIB_INSTALLER
+#define INSTALLER_EXPORT Q_DECL_EXPORT
+#else
+#define INSTALLER_EXPORT Q_DECL_IMPORT
+#endif
+#else
+#define INSTALLER_EXPORT
+#endif
+
+namespace QInstaller {
+ enum RunModes
+ {
+ UpdaterMode,
+ InstallerMode,
+ AllMode //this is a kind of doesn't matter mode
+ };
+ //Q_ENUMS(InstallerMode)
+}
+
+#endif //INSTALLER_GLOBAL_H
diff --git a/installerbuilder/libinstaller/installerbase.qrc b/installerbuilder/libinstaller/installerbase.qrc
new file mode 100644
index 000000000..f863bd93f
--- /dev/null
+++ b/installerbuilder/libinstaller/installerbase.qrc
@@ -0,0 +1,8 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>translations/qt_de.qm</file>
+ <file>translations/de_de.qm</file>
+ <file>translations/qt_sv.qm</file>
+ <file>translations/sv_se.qm</file>
+</qresource>
+</RCC>
diff --git a/installerbuilder/libinstaller/installiconsoperation.cpp b/installerbuilder/libinstaller/installiconsoperation.cpp
new file mode 100644
index 000000000..c847b0343
--- /dev/null
+++ b/installerbuilder/libinstaller/installiconsoperation.cpp
@@ -0,0 +1,327 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "installiconsoperation.h"
+
+#include "qinstaller.h"
+
+#include "common/errors.h"
+#include "common/fileutils.h"
+
+#include <QDir>
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QTemporaryFile>
+
+#if QT_VERSION >= 0x040600
+#include <QProcessEnvironment>
+#else
+#include <QProcess>
+#endif
+
+using namespace QInstaller;
+
+/*
+TRANSLATOR QInstaller::InstallIconsOperation
+*/
+
+QString InstallIconsOperation::targetDirectory()
+{
+ // we're not searching for the first time, let's re-use the old value
+ if( hasValue( QLatin1String( "targetdirectory" ) ) )
+ return value( QLatin1String( "targetdirectory" ) ).toString();
+
+#if QT_VERSION >= 0x040600
+ const QProcessEnvironment env;
+ QStringList XDG_DATA_DIRS = env.value( QLatin1String( "XDG_DATA_DIRS" ) ).split( QLatin1Char( ':' ), QString::SkipEmptyParts );
+#else
+ const QStringList env = QProcess::systemEnvironment();
+ QStringList XDG_DATA_DIRS;
+ for( QStringList::const_iterator it = env.begin(); it != env.end(); ++it )
+ {
+ if( it->startsWith( QLatin1String( "XDG_DATA_DIRS=" ) ) )
+ XDG_DATA_DIRS = it->mid( it->indexOf( QLatin1Char( '=' ) ) + 1 ).split( QLatin1Char( ':' ) );
+ }
+#endif
+
+ XDG_DATA_DIRS.push_back( QLatin1String( "/usr/share" ) ); // default path
+ XDG_DATA_DIRS.push_back( QDir::home().absoluteFilePath( QLatin1String( ".icons" ) ) ); // default path
+
+ const QStringList& directories = XDG_DATA_DIRS;
+ QString directory;
+ for( QStringList::const_iterator it = directories.begin(); it != directories.end(); ++it )
+ {
+ if( it->isEmpty() )
+ continue;
+
+ if( it + 1 == directories.end() )
+ directory = QDir( *it ).absolutePath();
+ else
+ directory = QDir( *it ).absoluteFilePath( QLatin1String( "icons" ) );
+ QDir dir( directory );
+
+ // let's see wheter this dir exists or we're able to create it
+ if( !dir.exists() && !QDir().mkpath( directory ) )
+ continue;
+
+ // we just try wheter we're able to open the file in ReadWrite
+ QFile file( QDir( directory ).absoluteFilePath( QLatin1String( "tmpfile" ) ) );
+ const bool existed = file.exists();
+ if( !file.open( QIODevice::ReadWrite ) )
+ continue;
+ file.close();
+ if( !existed )
+ file.remove();
+ break;
+ }
+
+ if( !QDir( directory ).exists() )
+ QDir().mkpath( directory );
+
+ setValue( QLatin1String( "directory" ), directory );
+
+
+ return directory;
+}
+
+InstallIconsOperation::InstallIconsOperation()
+{
+ setName( QLatin1String( "InstallIcons" ) );
+}
+
+InstallIconsOperation::~InstallIconsOperation()
+{
+ const QStringList backupFiles = value( QLatin1String( "backupfiles" ) ).toStringList();
+ for( QStringList::const_iterator it = backupFiles.begin(); it != backupFiles.end(); it += 2 )
+ {
+ const QString& backup = *( it + 1 );
+ deleteFileNowOrLater( backup );
+ }
+}
+
+void InstallIconsOperation::backup()
+{
+ // we backup on the fly
+}
+
+bool InstallIconsOperation::performOperation()
+{
+ const QStringList args = arguments();
+ if( args.count() != 1 )
+ {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 1 expected.")
+ .arg(name()).arg( args.count() ) );
+ return false;
+ }
+
+ const QString source = args.first();
+ if( source.isEmpty() )
+ {
+ setError( InvalidArguments );
+ setErrorString( QObject::tr("Invalid Argument: source folder must not be empty.") );
+ return false;
+ }
+
+ const QDir sourceDir = QDir( source );
+ const QDir targetDir = QDir( targetDirectory() );
+
+ QStringList files;
+ QStringList backupFiles;
+ QStringList createdDirectories;
+
+ int numItems = 0;
+ int currentItem = 0;
+
+ // iterate a first time to count the items (for proper progress)
+ QDirIterator itCount( sourceDir.path(), QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories );
+ while( itCount.hasNext() )
+ {
+ itCount.next();
+ ++numItems;
+ }
+
+ Installer* const installer = qVariantValue< Installer* >( value( QLatin1String( "installer" ) ) );
+
+ // iterate a second time to get the actual work done
+ QDirIterator it( sourceDir.path(), QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories );
+ while( it.hasNext() )
+ {
+ qApp->processEvents();
+
+ const int status = installer->status();
+ if( status == Installer::InstallerCanceledByUser || status == Installer::InstallerFailed )
+ return true;
+
+ const QString source = it.next();
+ const QString target = targetDir.absoluteFilePath( sourceDir.relativeFilePath( source ) );
+
+ emit outputTextChanged( target );
+ emit progressChanged( ++currentItem * 100 / numItems );
+
+ const QFileInfo fi = it.fileInfo();
+
+ if( !fi.isDir() )
+ {
+ if( QFile( target ).exists() )
+ {
+ // first backup...
+ const QString backup = generateTemporaryFileName( target + QLatin1String("XXXXXX") );
+ QFile bf( target );
+ if( !bf.copy( backup ) )
+ {
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Could not backup file %1: %2" ).arg( target, bf.errorString() ) );
+ undoOperation();
+ return false;
+ }
+
+ backupFiles.push_back( target );
+ backupFiles.push_back( backup );
+ setValue( QLatin1String( "backupfiles" ), backupFiles );
+
+ // then delete it
+ QString errStr;
+ if( !deleteFileNowOrLater( target, &errStr ) )
+ {
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Failed to overwrite %1: %2" ).arg( target, errStr ) );
+ undoOperation();
+ return false;
+ }
+
+ }
+
+ // copy the file to its new location
+ QFile cf( source );
+ if( !cf.copy( target ) )
+ {
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Failed to copy file %1: %2" ).arg( target, cf.errorString() ) );
+ undoOperation();
+ return false;
+ }
+ deleteFileNowOrLater( source );
+ files.push_back( source );
+ files.push_back( target );
+ setValue( QLatin1String( "files" ), files );
+ }
+ else if( fi.isDir() && !QDir( target ).exists() )
+ {
+ if( !QDir().mkpath( target ) )
+ {
+ setErrorString( QObject::tr( "Could not create folder at %1: %2" ).arg( target, qt_error_string() ) );
+ undoOperation();
+ return false;
+ }
+ createdDirectories.push_front( target );
+ setValue( QLatin1String( "createddirectories" ), createdDirectories );
+ }
+ }
+
+ // this should work now if not, it's not _that_ problematic...
+ try
+ {
+ removeDirectory( source );
+ }
+ catch( ... )
+ {
+ }
+
+ // reached this? cool :-)
+ return true;
+}
+
+bool InstallIconsOperation::undoOperation()
+{
+ bool success = true;
+
+ // first copy back all files to their origin
+ const QStringList files = value( QLatin1String( "files" ) ).toStringList();
+ for( QStringList::const_iterator it = files.begin(); it != files.end(); it += 2 )
+ {
+ qApp->processEvents();
+
+ const QString& source = *it;
+ const QString& target = *( it + 1 );
+
+ // first make sure the "source" path is valid
+ QDir().mkpath( QFileInfo( source ).absolutePath() );
+
+ // now copy target to source (feels weird, I know...)
+ success = QFile::copy( target, source ) && success;
+ // and remove target
+ success = QFile::remove( target ) && success;
+ }
+
+ // then copy back and remove all backuped files
+ const QStringList backupFiles = value( QLatin1String( "backupfiles" ) ).toStringList();
+ for( QStringList::const_iterator it = backupFiles.begin(); it != backupFiles.end(); it += 2 )
+ {
+ const QString& target = *it;
+ const QString& backup = *( it + 1 );
+
+ // remove the target
+ if( QFile::exists( target ) )
+ success = deleteFileNowOrLater( target ) && success;
+ // then copy the backup onto the target
+ success = QFile::copy( backup, target ) && success;
+ // finally remove the backp
+ success = deleteFileNowOrLater( backup ) && success;
+ }
+
+ // then remove all directories created by us
+ const QStringList createdDirectories = value( QLatin1String( "createddirectories" ) ).toStringList();
+ for( QStringList::const_iterator it = createdDirectories.begin(); it != createdDirectories.end(); ++it )
+ {
+ const QDir dir( *it );
+ // even remove some hidden, OS-created files in there
+#if defined Q_WS_MAC
+ QFile::remove( dir.absoluteFilePath( QLatin1String( ".DS_Store" ) ) );
+#elif defined Q_WS_WIN
+ QFile::remove( dir.absoluteFilePath( QLatin1String( "/Thumbs.db" ) ) );
+#endif
+ success = QDir::root().rmdir( dir.path() );
+ }
+
+ return success;
+}
+
+bool InstallIconsOperation::testOperation()
+{
+ return true;
+}
+
+InstallIconsOperation* InstallIconsOperation::clone() const
+{
+ return new InstallIconsOperation();
+}
diff --git a/installerbuilder/libinstaller/installiconsoperation.h b/installerbuilder/libinstaller/installiconsoperation.h
new file mode 100644
index 000000000..dc31f28d9
--- /dev/null
+++ b/installerbuilder/libinstaller/installiconsoperation.h
@@ -0,0 +1,57 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef INSTALLICONSOPERATION_H
+#define INSTALLICONSOPERATION_H
+
+#include <QtCore/QObject>
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class InstallIconsOperation : public QObject, public KDUpdater::UpdateOperation
+{
+ Q_OBJECT
+public:
+ InstallIconsOperation();
+ ~InstallIconsOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ InstallIconsOperation* clone() const;
+
+Q_SIGNALS:
+ void progressChanged( int progress );
+ void outputTextChanged( const QString& progress );
+
+private:
+ QString targetDirectory();
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdmmappedfileiodevice.cpp b/installerbuilder/libinstaller/kdmmappedfileiodevice.cpp
new file mode 100644
index 000000000..888f1e803
--- /dev/null
+++ b/installerbuilder/libinstaller/kdmmappedfileiodevice.cpp
@@ -0,0 +1,108 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "kdmmappedfileiodevice.h"
+
+#include <cassert>
+
+#include <QFile>
+
+KDMMappedFileIODevice::KDMMappedFileIODevice( QFile* file, qint64 offset, qint64 length, QObject* parent )
+ : QIODevice( parent )
+ , m_file( file )
+ , m_ownsFile( false )
+ , m_offset( offset )
+ , m_length( length )
+ , m_data( 0 ) {
+ assert( m_file );
+}
+
+KDMMappedFileIODevice::KDMMappedFileIODevice( const QString& filename, qint64 offset, qint64 length, QObject* parent )
+ : QIODevice( parent )
+ , m_file( new QFile( filename ) )
+ , m_ownsFile( true )
+ , m_offset( offset )
+ , m_length( length )
+ , m_data( 0 ) {
+ if ( !open( QIODevice::ReadOnly ) )
+ assert( !"Could not open device" );
+}
+
+KDMMappedFileIODevice::~KDMMappedFileIODevice() {
+ assert( m_file );
+ if ( m_ownsFile )
+ delete m_file;
+}
+
+qint64 KDMMappedFileIODevice::readData( char* data, qint64 maxSize ) {
+ ensureMapped();
+ if ( maxSize < 0 )
+ return 0;
+ const qint64 actual = std::min( maxSize, m_length - pos() );
+ memcpy( data, m_data + pos(), actual );
+ return actual;
+}
+
+qint64 KDMMappedFileIODevice::writeData( const char* data, qint64 maxSize ) {
+ Q_UNUSED( data )
+ Q_UNUSED( maxSize )
+ ensureMapped();
+ assert( !"not implemented" );
+ return -1;
+}
+
+bool KDMMappedFileIODevice::ensureMapped() {
+ if ( m_data )
+ return true;
+ assert( m_file );
+ m_data = m_file->map( m_offset, m_length );
+ return m_data != false;
+}
+
+bool KDMMappedFileIODevice::open( QIODevice::OpenMode openMode ) {
+ if ( openMode != QIODevice::ReadOnly )
+ qWarning( "%s: Write not supported\n", Q_FUNC_INFO );
+ if ( openMode == QIODevice::WriteOnly )
+ return false;
+ const bool opened = m_file->open( openMode );
+ if ( opened )
+ setOpenMode( openMode );
+ return opened;
+}
+
+void KDMMappedFileIODevice::close() {
+ if ( m_data )
+ m_file->unmap( m_data );
+ m_data = 0;
+ m_file->close();
+}
+
diff --git a/installerbuilder/libinstaller/kdmmappedfileiodevice.h b/installerbuilder/libinstaller/kdmmappedfileiodevice.h
new file mode 100644
index 000000000..06aa18819
--- /dev/null
+++ b/installerbuilder/libinstaller/kdmmappedfileiodevice.h
@@ -0,0 +1,60 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef KDMMAPPEDFILEIODEVICE_H
+#define KDMMAPPEDFILEIODEVICE_H
+
+#include <QtCore/QIODevice>
+
+#include "installer_global.h"
+
+class QFile;
+
+class INSTALLER_EXPORT KDMMappedFileIODevice : public QIODevice {
+ Q_OBJECT
+public:
+ KDMMappedFileIODevice( QFile* file, qint64 offset, qint64 length, QObject* parent=0 );
+ KDMMappedFileIODevice( const QString& filename, qint64 offset, qint64 length, QObject* parent=0 );
+ ~KDMMappedFileIODevice();
+
+ /* reimp */ bool open( QIODevice::OpenMode openMode );
+ /* reimp */ void close();
+
+private:
+ /* reimp */ qint64 readData( char* data, qint64 maxSize );
+ /* reimp */ qint64 writeData( const char* data, qint64 maxSize );
+
+private:
+ bool ensureMapped();
+
+private:
+ QFile* const m_file;
+ const bool m_ownsFile;
+ const qint64 m_offset;
+ const qint64 m_length;
+ unsigned char* m_data;
+};
+
+#endif // KDMMAPPEDFILEIODEVICE_H
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDAutoPointer b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDAutoPointer
new file mode 100644
index 000000000..5203ea2db
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDAutoPointer
@@ -0,0 +1 @@
+#include "kdautopointer.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDByteSize b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDByteSize
new file mode 100644
index 000000000..e0ee65f30
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDByteSize
@@ -0,0 +1 @@
+#include "kdbytesize.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDGenericFactory b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDGenericFactory
new file mode 100644
index 000000000..42f06640a
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDGenericFactory
@@ -0,0 +1 @@
+#include "kdgenericfactory.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDJob b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDJob
new file mode 100644
index 000000000..79fd1dde9
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDJob
@@ -0,0 +1 @@
+#include "kdjob.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDLockfile b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDLockfile
new file mode 100644
index 000000000..afd9f7ad1
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDLockfile
@@ -0,0 +1 @@
+#include "kdlockfile.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDMetaMethodIterator b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDMetaMethodIterator
new file mode 100644
index 000000000..cfb58d054
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDMetaMethodIterator
@@ -0,0 +1 @@
+#include "kdmetamethoditerator.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDRunOnceChecker b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDRunOnceChecker
new file mode 100644
index 000000000..d5ccad881
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDRunOnceChecker
@@ -0,0 +1 @@
+#include "kdrunoncechecker.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSaveFile b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSaveFile
new file mode 100644
index 000000000..f7df3f1b5
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSaveFile
@@ -0,0 +1 @@
+#include "kdsavefile.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSelfRestarter b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSelfRestarter
new file mode 100644
index 000000000..7de1c2779
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSelfRestarter
@@ -0,0 +1 @@
+#include "kdselfrestarter.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSysInfo b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSysInfo
new file mode 100644
index 000000000..7d5cec1e4
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDSysInfo
@@ -0,0 +1 @@
+#include "kdsysinfo.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDToolsCore.pri b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDToolsCore.pri
new file mode 100644
index 000000000..213c8343d
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDToolsCore.pri
@@ -0,0 +1,42 @@
+DEPENDPATH += $$PWD
+INCLUDEPATH += $$PWD
+
+CONFIG( shared, static|shared) {
+ DEFINES += BUILD_SHARED_KDTOOLSCORE
+}
+
+HEADERS += $$PWD/pimpl_ptr.h \
+ $$PWD/kdtoolsglobal.h \
+ $$PWD/kdbytesize.h \
+ $$PWD/kdjob.h \
+ $$PWD/kdwatchdog.h \
+ $$PWD/kdgenericfactory.h \
+ $$PWD/kdautopointer.h \
+ $$PWD/kdselfrestarter.h \
+ $$PWD/kdsavefile.h \
+ $$PWD/kdmetamethoditerator.h \
+ $$PWD/kdrunoncechecker.h \
+ $$PWD/kdlockfile.h \
+ $$PWD/kdsysinfo.h \
+ $$PWD/kdversion.h
+
+SOURCES += $$PWD/pimpl_ptr.cpp \
+ $$PWD/kdtoolsglobal.cpp \
+ $$PWD/kdbytesize.cpp \
+ $$PWD/kdjob.cpp \
+ $$PWD/kdwatchdog.cpp \
+ $$PWD/kdgenericfactory.cpp \
+ $$PWD/kdautopointer.cpp \
+ $$PWD/kdselfrestarter.cpp \
+ $$PWD/kdsavefile.cpp \
+ $$PWD/kdmetamethoditerator.cpp \
+ $$PWD/kdrunoncechecker.cpp \
+ $$PWD/kdlockfile.cpp \
+ $$PWD/kdsysinfo.cpp \
+ $$PWD/kdversion.cpp
+
+unix:SOURCES += $$PWD/kdlockfile_unix.cpp
+win32:SOURCES += $$PWD/kdlockfile_win.cpp
+win32:SOURCES += $$PWD/kdsysinfo_win.cpp
+macx:SOURCES += $$PWD/kdsysinfo_mac.cpp
+unix:!macx:SOURCES += $$PWD/kdsysinfo_x11.cpp
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/KDWatchdog b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDWatchdog
new file mode 100644
index 000000000..3032c2a37
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/KDWatchdog
@@ -0,0 +1 @@
+#include "kdwatchdog.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.cpp
new file mode 100644
index 000000000..3398ac8b8
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.cpp
@@ -0,0 +1,577 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdautopointer.h"
+
+/*!
+ \class KDAutoPointer
+ \ingroup core smartptr
+ \brief Owning version of QPointer
+ \since_c 2.1
+
+ (The exception safety of this class has not been evaluated yet.)
+
+ KDAutoPointer is a fusion of std::auto_ptr and QPointer, ie. it owns the
+ contained object, but if that object is otherwise deleted, it sets
+ itself to null, just like QPointer does.
+
+ Like std::auto_ptr, ownership is never shared between instances of
+ KDAutoPointer. Copying and copy assignment \em transfer ownership,
+ ie. in the following code
+
+ \code
+ KDAutoPointer<MyDialog> myDialog( new MyDialog );
+ KDAutoPointer<QObject> monitor( myDialog ); // Probably WRONG!
+ \endcode
+
+ \c monitor will end up owning the \c MyDialog instance, and \c
+ myDialog will be NULL, which is probably not what the programmer
+ intended.
+
+ Like QPointer, KDAutoPointer can only hold objects of a class derived
+ from QObject. If you need this functionality for arbitrary types,
+ consider using std::tr1::shared_ptr together with
+ std::tr1::weak_ptr.
+
+ \section overview Overview
+
+ You construct a KDAutoPointer by passing a pointer to the object to be
+ owned in \link KDAutoPointer(T*) the constructor\endlink, or, after the
+ fact, by calling reset(). Neither of these operations happen
+ implicitly, since they entail a change of ownership that should be
+ visible in code.
+
+ For the same reason, if you need to get a pointer to the contained
+ (owned) object, the conversion is not implicit, either. You have to
+ explicitly call get() (if you want to leave ownership to the
+ KDAutoPointer) or release() (if you want to transfer ownership out of
+ KDAutoPointer).
+
+ Use \link swap(KDAutoPointer&,KDAutoPointer&) swap()\endlink to quickly
+ exchange the contents of two \link KDAutoPointer KDAutoPointers\endlink, and
+ operator unspecified_bool_type() to test whether KDAutoPointer (still)
+ contains an object:
+
+ \code
+ KDAutoPointer w1( new QWidget ), w2();
+ assert( w1 ); assert( !w2 );
+ swap( w1, s2 );
+ assert( !w1 ); assert( w2 );
+ \endcode
+
+ \section general-use General Use
+
+ The general use case of KDAutoPointer is that of holding objects that
+ have unclear ownership semantics. E.g. classes that implement the
+ Command Pattern are sometimes implemented as deleting themselves
+ after the command finished. By holding instances of such classes in
+ KDAutoPointers, you do not have to care about whether or now the object
+ deletes itself. If it deletes itself, then KDAutoPointer will set itself
+ to NULL, if not, KDAutoPointer will delete the object when it goes out
+ of scope.
+
+ \section child-creation Esp.: Child Creation
+
+ You can also use KDAutoPointer for temporarily storing \link QObject
+ QObjects\endlink for exception safety. This is esp. useful when
+ following the Trolltech-recommended style of dialog creation (create
+ parent-less children up-front, add to layouts later):
+
+ \code
+ QLabel * lb = new QLabel( tr("Name:" );
+ QLineEdit * le = new QLineEdit;
+
+ QHBoxLayout * hbox = new QHBoxLayout;
+ hbox->addWidget( lb );
+ hbox->addWidget( le );
+ // if somethings throws an exception here,
+ // all of the above will be leaked
+ setLayout( hbox );
+ \endcode
+
+ Rewriting this as (granted, cumbersome):
+ \code
+ KDAutoPointer<QLabel> lb( new QLabel( tr("Name:" );
+ KDAutoPointer<QLineEdit> le( new QLineEdit );
+
+ KDAutoPointer<QHBoxLayout> hbox( new QHBoxLayout );
+ hbox->addWidget( lb.get() );
+ hbox->addWidget( le.get() );
+ // if somethings throws an exception here,
+ // all of the above will be properly cleaned up
+ setLayout( hbox.release() );
+ lb.release();
+ le.release();
+ \endcode
+ takes care of the leak.
+
+ Since this is so cumbersome, you should instead always pass parents
+ to children as part of construction.
+
+ \section model-dialogs Esp.: Modal Dialogs
+
+ A more specific use case is (modal) dialogs.
+
+ Traditionally, most programmers allocate these on the stack:
+
+ \code
+ MyDialog dialog( parent );
+ // set up 'dialog'...
+ if ( !dialog.exec() )
+ return;
+ // extract information from 'dialog'...
+ return;
+ \endcode
+
+ This is usually ok. Even though \c dialog has a parent, the parent
+ will usually live longer than the dialog. The dialog is modal, after
+ all, so the user is not supposed to be able to quit the application
+ while that dialog is on screen.
+
+ There are some applications, however, that have other ways to
+ terminate than explicit user request. Whether the application exits
+ timer-driven, or by an IPC call, what will happen is that \c dialog
+ is deleted as a child of \c parent \em and \em then \em again by the
+ compiler as part of cleaning up the stack once \c exec() returns.
+
+ This is where KDAutoPointer comes in. Instead of allocating modal
+ dialogs on the stack, allocate them into a KDAutoPointer:
+
+ \code
+ const KDAutoPointer<MyDialog> dialog( new MyDialog( parent ) );
+ // set up 'dialog'...
+ if ( !dialog->exec() || !dialog )
+ return;
+ // extract information from 'dialog'...
+ return;
+ \endcode
+
+ Note the use of \c const to prevent accidental copying of \c dialog,
+ and the additional check for \c dialog to catch the case where after
+ exec() returns, the dialog has been deleted.
+*/
+
+/*!
+ \typedef KDAutoPointer::element_type
+
+ A typedef for \c T. For STL compatibility.
+*/
+
+/*!
+ \typedef KDAutoPointer::value_type
+
+ A typedef for \c T. For STL compatibility.
+*/
+
+/*!
+ \typedef KDAutoPointer<T>::pointer
+
+ A typedef for \c T*. For STL compatibility.
+*/
+
+/*!
+ \fn KDAutoPointer::KDAutoPointer()
+
+ Default constructor. Constructs a NULL KDAutoPointer.
+
+ \post get() == 0
+*/
+
+/*!
+ \fn KDAutoPointer::KDAutoPointer( T * obj )
+
+ Constructor. Constructs a KDAutoPointer that contains (owns) \a obj.
+
+ \post get() == obj
+*/
+
+/*!
+ \fn KDAutoPointer::KDAutoPointer( KDAutoPointer & other )
+
+ Move constructor. Constructs a KDAutoPointer that takes over ownership
+ of the object contained (owned) by \a other.
+
+ \post this->get() == (the object previously owned by 'other')
+ \post other.get() == 0
+*/
+
+/*!
+ \fn KDAutoPointer::KDAutoPointer( KDAutoPointer<U> & other )
+
+ \overload
+*/
+
+/*!
+ \fn KDAutoPointer & KDAutoPointer::operator=( KDAutoPointer & other )
+
+ Copy assignment operator. Equivalent to
+ \code
+ reset( other.release() );
+ \endcode
+
+ \post this->get() == (the object previously owned by 'other')
+ \post other.get() == 0
+ \post The object previously owned by \c *this has been deleted.
+*/
+
+/*!
+ \fn KDAutoPointer & KDAutoPointer::operator=( KDAutoPointer<U> & other )
+
+ \overload
+*/
+
+/*!
+ \fn KDAutoPointer::~KDAutoPointer()
+
+ Destructor.
+
+ \post The object previously owned by \c *this has been deleted.
+*/
+
+/*!
+ \fn void KDAutoPointer::swap( KDAutoPointer & other )
+
+ Swaps the contents of \a *this and \a other. You probably want to
+ use the free function swap(KDAutoPointer&,KDAutoPointer&) instead. Also
+ qSwap() has been specialized to use this function internally.
+
+ \post get() == (previous value of other.get())
+ \post other.get() == (previous value of this->get())
+*/
+
+/*!
+ \fn T * KDAutoPointer::get() const
+
+ \returns a pointer to the contained (owned) object.
+*/
+
+/*!
+ \fn T * KDAutoPointer::release()
+
+ Yields ownership of the contained object and returns a pointer to it.
+
+ \post get() == 0
+ \post The object previously owned by \c *this had \em not been deleted.
+*/
+
+/*!
+ \fn T * KDAutoPointer::data() const
+
+ Equivalent to get(). Provided for consistency with Qt naming
+ conventions.
+*/
+
+/*!
+ \fn T * KDAutoPointer::take()
+
+ Equivalent to release(). Provided for consistency with Qt naming
+ conventions.
+*/
+
+/*!
+ \fn void KDAutoPointer::reset( T * other )
+
+ Yields ownership of the contained object (if any) and and takes over
+ ownership of \a other.
+
+ \post get() == other
+ \post The object previously owned by \c *this has been deleted.
+*/
+
+/*!
+ \fn T & KDAutoPointer::operator*() const
+
+ Dereference operator. Returns \link get() *get()\endlink.
+*/
+
+/*!
+ \fn T * KDAutoPointer::operator->() const
+
+ Member-by-pointer operator. Returns get().
+*/
+
+/*!
+ \fn bool KDAutoPointer::operator==( const KDAutoPointer<S> & other ) const
+
+ Equal-to operator. Returns get() == other.get().
+
+ \note Due to the fact that two \link KDAutoPointer KDAutoPointers\endlink
+ cannot contain the same object, the relational operators are not
+ very useful.
+*/
+
+/*!
+ \fn bool KDAutoPointer::operator!=( const KDAutoPointer<S> & other ) const
+
+ Not-Equal-to operator. Returns get() != other.get().
+
+ \note Due to the fact that two \link KDAutoPointer KDAutoPointers\endlink
+ cannot contain the same object, the relational operators are not
+ very useful.
+*/
+
+/*!
+ \fn KDAutoPointer::operator unspecified_bool_type() const
+
+ \returns \c true if \c *this contains an object, otherwise \c false.
+*/
+
+/*!
+ \fn void swap( KDAutoPointer<T> & lhs, KDAutoPointer<T> & rhs )
+ \relates KDAutoPointer
+
+ Equivalent to
+ \code
+ lhs.swap( rhs );
+ \endcode
+
+ Provided for generic code that uses the standard swap idiom:
+ \code
+ using std::swap;
+ swap( a, b );
+ \endcode
+ to find through <a href="http://en.wikipedia.org/wiki/Argument_dependent_name_lookup">ADL</a>,
+ enabling such code to automatically use the more efficient
+ \link KDAutoPointer::swap() member swap\endlink instead of the default
+ implementation (which uses a temporary).
+*/
+
+/*!
+ \fn void qSwap( KDAutoPointer<T> & lhs, KDAutoPointer<S> & rhs )
+ \relates KDAutoPointer
+
+ Equivalent to
+ \code
+ swap( lhs, rhs );
+ \endcode
+ except for code using %qSwap() instead of (std::)swap.
+*/
+
+/*!
+ \fn bool operator==( const KDAutoPointer<S> & lhs, const T * rhs )
+ \relates KDAutoPointer
+
+ Equal-to operator. Equivalent to
+ \code
+ lhs.get() == rhs
+ \endcode
+*/
+
+/*!
+ \fn bool operator==( const S * lhs, const KDAutoPointer<T> & rhs )
+ \relates KDAutoPointer
+ \overload
+*/
+
+/*!
+ \fn bool operator==( const KDAutoPointer<S> & lhs, const QPointer<T> & rhs )
+ \relates KDAutoPointer
+ \overload
+*/
+
+/*!
+ \fn bool operator==( const QPointer<S> & lhs, const KDAutoPointer<T> & rhs )
+ \relates KDAutoPointer
+ \overload
+*/
+
+
+/*!
+ \fn bool operator!=( const KDAutoPointer<S> & lhs, const T * rhs )
+ \relates KDAutoPointer
+
+ Not-equal-to operator. Equivalent to
+ \code
+ lhs.get() != rhs
+ \endcode
+*/
+
+/*!
+ \fn bool operator!=( const S * lhs, const KDAutoPointer<T> & rhs )
+ \relates KDAutoPointer
+ \overload
+*/
+
+/*!
+ \fn bool operator!=( const KDAutoPointer<S> & lhs, const QPointer<T> & rhs )
+ \relates KDAutoPointer
+ \overload
+*/
+
+/*!
+ \fn bool operator!=( const QPointer<S> & lhs, const KDAutoPointer<T> & rhs )
+ \relates KDAutoPointer
+ \overload
+*/
+
+#ifdef KDTOOLSCORE_UNITTESTS
+
+#include <KDUnitTest/Test>
+
+namespace {
+
+ struct A : QObject {};
+ struct B : QObject {};
+
+}
+
+KDAB_UNITTEST_SIMPLE( KDAutoPointer, "kdcoretools" ) {
+
+ {
+ QPointer<QObject> o;
+ {
+ const KDAutoPointer<QObject> qobject( new QObject );
+ o = qobject.get();
+ }
+ assertNull( o );
+ }
+
+ {
+ // check that conversion to bool works
+ KDAutoPointer<A> a( new A );
+ const bool b1 = a;
+ assertTrue( b1 );
+ const bool b2 = !a;
+ assertFalse( b2 );
+ a.reset();
+ const bool b3 = a;
+ assertFalse( b3 );
+ const bool b4 = !a;
+ assertTrue( b4 );
+ }
+
+ {
+ KDAutoPointer<QObject> o;
+ assertNull( o.get() );
+ assertFalse( o );
+ QObject * obj;
+ o.reset( obj = new QObject );
+ assertNotNull( o.get() );
+ assertTrue( o );
+ assertEqual( o.get(), obj );
+
+ KDAutoPointer<QObject> o2 = o;
+ assertNull( o.get() );
+ assertNotNull( o2.get() );
+ assertEqual( o2.get(), obj );
+
+ delete obj;
+ assertNull( o2.get() );
+ }
+
+ {
+ QPointer<QObject> obj = new QObject;
+ KDAutoPointer<QObject> o( obj );
+ o = o; // self-assignment
+ assertNotNull( obj );
+ o.reset( o.get() ); // self-assignment-ish
+ assertNotNull( obj );
+
+ o.reset( new QObject );
+ assertNull( obj );
+ assertNotNull( o.get() );
+ }
+
+ {
+ QPointer<A> ap;
+ {
+ KDAutoPointer<A> a( new A );
+ ap = a.get();
+ KDAutoPointer<QObject> o1( a );
+ assertNull( a.get() );
+ assertNotNull( o1.get() );
+ KDAutoPointer<QObject> o2;
+ o2 = a;
+ // doesn't compile (but doesn't compile for std::auto_ptr,
+ // either, so it's ok, I think
+ //KDAutoPointer<QObject> o3 = a
+ }
+ assertNull( ap );
+ }
+
+ {
+ // test swapping
+ KDAutoPointer<A> a1( new A ), a2( new A );
+
+ A * A1 = a1.get();
+ A * A2 = a2.get();
+
+ using std::swap;
+ swap( a1, a2 );
+
+ assertNotNull( a1.get() );
+ assertNotNull( a2.get() );
+
+ assertEqual( a1.get(), A2 );
+ assertEqual( a2.get(), A1 );
+
+ qSwap( a1, a2 );
+ assertEqual( a1.get(), A1 );
+ assertEqual( a2.get(), A2 );
+
+ }
+
+ {
+ KDAutoPointer<A> apa( new A );
+ QPointer<A> qpa( apa.get() );
+ A * pa = apa.get();
+ const A * cpa = pa;
+
+ assertEqual( apa.get(), apa.get() );
+ assertEqual( apa.get(), qpa );
+ assertEqual( apa.get(), pa );
+ assertEqual( apa.get(), cpa );
+ assertEqual( qpa, apa.get() );
+ assertEqual( pa, apa.get() );
+ assertEqual( cpa, apa.get() );
+
+ KDAutoPointer<QObject> apq; cpa = pa = qpa = 0;
+
+ assertNotEqual( apa.get(), qpa );
+ assertNotEqual( apa.get(), pa );
+ assertNotEqual( apa.get(), cpa );
+ assertNotEqual( qpa, apa.get() );
+ assertNotEqual( pa, apa.get() );
+ assertNotEqual( cpa, apa.get() );
+
+ assertNotEqual( apq.get(), apa.get() );
+ assertNotEqual( apa.get(), apq.get() );
+
+ assertNotNull( apa.get() );
+
+ apq.reset( new QObject );
+
+ assertNotEqual( apa.get(), qpa );
+ assertNotEqual( apa.get(), pa );
+ assertNotEqual( apa.get(), cpa );
+ assertNotEqual( qpa, apa.get() );
+ assertNotEqual( pa, apa.get() );
+ assertNotEqual( cpa, apa.get() );
+
+ assertNotEqual( apq.get(), apa.get() );
+ assertNotEqual( apa.get(), apq.get() );
+
+ assertNotNull( apa.get() );
+ }
+}
+
+#endif // KDTOOLSCORE_UNITTESTS
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.h
new file mode 100644
index 000000000..7a0558db0
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdautopointer.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLS_CORE_KDAUTOPOINTER_H__
+#define __KDTOOLS_CORE_KDAUTOPOINTER_H__
+
+#include <KDToolsCore/kdtoolsglobal.h>
+
+#include <QtCore/QPointer>
+#include <QtCore/QObject>
+
+class KDAutoPointerBase {
+protected:
+ QPointer<QObject> o;
+
+ KDAutoPointerBase() : o() {}
+ explicit KDAutoPointerBase( QObject * obj ) : o( obj ) {}
+ KDAutoPointerBase( KDAutoPointerBase & other ) : o( other.release() ) {}
+ ~KDAutoPointerBase() { delete o; }
+
+ void swap( KDAutoPointerBase & other ) {
+ const QPointer<QObject> copy( o );
+ o = other.o;
+ other.o = copy;
+ }
+
+ QObject * release() { QObject * copy = o; o = 0 ; return copy; }
+ void reset( QObject * other ) { if ( o != other ) { delete o; o = other; } }
+
+ KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( o );
+};
+
+template <typename T>
+class MAKEINCLUDES_EXPORT KDAutoPointer : KDAutoPointerBase {
+public:
+ friend inline void swap( KDAutoPointer & lhs, KDAutoPointer & rhs ) { lhs.swap( rhs ); }
+
+ typedef T element_type;
+ typedef T value_type;
+ typedef T * pointer;
+
+ KDAutoPointer() : KDAutoPointerBase() {}
+ explicit KDAutoPointer( T * obj ) : KDAutoPointerBase( obj ) {}
+ KDAutoPointer( KDAutoPointer & other ) : KDAutoPointerBase( other.release() ) {}
+ template <typename U>
+ KDAutoPointer( KDAutoPointer<U> & other ) : KDAutoPointerBase( other.release() ) { T * t = other.get(); ( void )t; }
+
+ KDAutoPointer & operator=( KDAutoPointer & other ) {
+ this->reset( other.release() );
+ return *this;
+ }
+
+ template <typename U>
+ KDAutoPointer & operator=( KDAutoPointer<U> & other ) {
+ this->reset( other.release() );
+ return *this;
+ }
+
+ ~KDAutoPointer() {}
+
+ void swap( KDAutoPointer & other ) {
+ KDAutoPointerBase::swap( other );
+ }
+
+ T * get() const { QObject * obj = o; return static_cast<T*>( obj ); }
+ T * release() { return static_cast<T*>( KDAutoPointerBase::release() ); }
+
+ T * data() const { return get(); }
+ T * take() { return release(); }
+
+ void reset( T * other=0 ) { KDAutoPointerBase::reset( other ); }
+
+ T & operator*() const { return *get(); }
+ T * operator->() const { return get(); }
+
+ template <typename S>
+ bool operator==( const KDAutoPointer<S> & other ) const {
+ return get() == other.get();
+ }
+ template <typename S>
+ bool operator!=( const KDAutoPointer<S> & other ) const {
+ return get() != other.get();
+ }
+
+ KDAB_USING_SAFE_BOOL_OPERATOR( KDAutoPointerBase )
+};
+
+template <typename T>
+inline void swap( KDAutoPointer<T> & lhs, KDAutoPointer<T> & rhs ) { lhs.swap( rhs ); }
+template <typename T>
+inline void qSwap( KDAutoPointer<T> & lhs, KDAutoPointer<T> & rhs ) { lhs.swap( rhs ); }
+
+template <typename S, typename T>
+inline bool operator==( const KDAutoPointer<S> & lhs, const T * rhs ) {
+ return lhs.get() == rhs;
+}
+template <typename S, typename T>
+inline bool operator==( const S * lhs, const KDAutoPointer<T> & rhs ) {
+ return lhs == rhs.get();
+}
+template <typename S, typename T>
+inline bool operator==( const KDAutoPointer<S> & lhs, const QPointer<T> & rhs ) {
+ return lhs.get() == rhs;
+}
+template <typename S, typename T>
+inline bool operator==( const QPointer<S> & lhs, const KDAutoPointer<T> & rhs ) {
+ return lhs == rhs.get();
+}
+
+template <typename S, typename T>
+inline bool operator!=( const KDAutoPointer<S> & lhs, const T * rhs ) {
+ return !operator==( lhs, rhs );
+}
+template <typename S, typename T>
+inline bool operator!=( const S * lhs, const KDAutoPointer<T> & rhs ) {
+ return !operator==( lhs, rhs );
+}
+template <typename S, typename T>
+inline bool operator!=( const KDAutoPointer<S> & lhs, const QPointer<T> & rhs ) {
+ return !operator==( lhs, rhs );
+}
+template <typename S, typename T>
+inline bool operator!=( const QPointer<S> & lhs, const KDAutoPointer<T> & rhs ) {
+ return !operator==( lhs, rhs );
+}
+
+
+#endif /* __KDTOOLS_CORE_KDAUTOPOINTER_H__ */
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.cpp
new file mode 100644
index 000000000..0cf06f233
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+#include "kdbytesize.h"
+
+#include <QStringList>
+#include <QTextStream>
+
+KDByteSize::KDByteSize( quint64 size )
+ : m_size( size )
+{
+}
+
+KDByteSize::~KDByteSize()
+{
+}
+
+KDByteSize::operator quint64() const
+{
+ return m_size;
+}
+
+quint64 KDByteSize::size() const
+{
+ return m_size;
+}
+
+QString KDByteSize::toString() const
+{
+ static const QStringList units = QStringList() << QObject::tr( "B" )
+ << QObject::tr( "kB" )
+ << QObject::tr( "MB" )
+ << QObject::tr( "GB" )
+ << QObject::tr( "TB" );
+
+ double s = m_size;
+ quint64 factor = 1;
+ int unit = 0;
+ while( s >= 1024.0 && unit + 1 < units.count() )
+ {
+ ++unit;
+ factor *= 1024;
+ s = 1.0 * m_size / factor;
+ }
+
+ // only one digit after the decimal point is wanted
+ s = qRound( s * 10 ) / 10.0;
+
+ return QString::fromLatin1( "%L1 %2" ).arg( s, 0, 'g', 4 ).arg( units[ unit ] );
+}
+
+bool operator==( const KDByteSize& lhs, const KDByteSize& rhs )
+{
+ return lhs.size() == rhs.size();
+}
+
+bool operator<( const KDByteSize& lhs, const KDByteSize& rhs )
+{
+ return lhs.size() < rhs.size();
+}
+
+KDByteSize operator*( const KDByteSize& lhs, int rhs )
+{
+ return KDByteSize( lhs.size() * rhs );
+}
+
+#include <QDebug>
+
+QDebug operator<<( QDebug dbg, const KDByteSize& size )
+{
+ return dbg << "KDByteSize(" << size.size() << ")";
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.h
new file mode 100644
index 000000000..cc8f5a770
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdbytesize.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+#ifndef KDBYTESIZE_H
+#define KDBYTESIZE_H
+
+#include <KDToolsCore/kdtoolsglobal.h>
+
+class KDTOOLSCORE_EXPORT KDByteSize
+{
+public:
+ explicit KDByteSize( quint64 size = 0 );
+ virtual ~KDByteSize();
+
+ operator quint64() const;
+ quint64 size() const;
+
+ QString toString() const;
+
+private:
+ quint64 m_size;
+};
+
+KDTOOLSCORE_EXPORT bool operator==( const KDByteSize& lhs, const KDByteSize& rhs );
+KDTOOLSCORE_EXPORT bool operator<( const KDByteSize& lhs, const KDByteSize& rhs );
+KDTOOLSCORE_EXPORT KDByteSize operator*( const KDByteSize& lhs, int rhs );
+
+KDTOOLS_MAKE_RELATION_OPERATORS( KDByteSize, static inline )
+
+class QDebug;
+KDTOOLSCORE_EXPORT QDebug operator<<( QDebug dbg, const KDByteSize& size );
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.cpp
new file mode 100644
index 000000000..9352f83cd
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.cpp
@@ -0,0 +1,250 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdgenericfactory.h"
+
+/*!
+ \class KDGenericFactory
+ \ingroup core
+ \brief Template based generic factory implementation
+ \since_c 2.1
+
+ (The exception safety of this class has not been evaluated yet.)
+
+ KDGenericFactory is an implemention of of the factory pattern. It can be used to
+ "produce" instances of different classes having a common superclass
+ T_Product. The user of the
+ factory registers those producable classes in the factory by using an identifier
+ (T_Identifier, defaulting to QString). That identifer can then be used to
+ produce as many instances of the registered product as he wants.
+
+ The advanced user can even choose the type of the map the factory is using to store its
+ FactoryFunctions by passing a T_Map template parameter. It defaults to QHash. KDGenericFactory
+ expects it to be a template class accepting T_Identifier and FactoryFunction as parameters.
+ Additionally it needs to provide:
+
+ \li\link QHash::const_iterator a nested %const_iterator \endlink typedef for an iterator type that when dereferenced has type ((const) reference to) FactoryFunction (Qt convention),
+ \li\link QHash::insert %insert( T_Identifier, FactoryFunction ) \endlink, which must overwrite any existing entries with the same identifier.
+ \li\link QHash::find %find( T_Identifier ) \endlink,
+ \li\link QHash::end %end() \endlink,
+ \li\link QHash::size %size() \endlink,
+ \li\link QHash::remove %remove( T_Identifier ) \endlink, and
+ \li\link QHash::keys %keys ) \endlink, returning a QList<T_Identifier>.
+
+ The only two class templates that currently match this concept are
+ QHash and QMap. QMultiHash and QMulitMap do not work, since they
+ violate the requirement on insert() above, and std::map and
+ std::unordered_map do not match because they don't have keys() and
+ because a dereferenced iterator has type
+ std::pair<const T_Identifier,FactoryFunction>
+ instead of just FactoryFunction.
+
+ \section general-use General Use
+
+ The following example shows how the general use case of KDGenericFactory looks like:
+
+ \code
+
+ class Fruit
+ {
+ };
+
+ class Apple : public Fruit
+ {
+ };
+
+ class Pear : public Fruit
+ {
+ };
+
+ int main()
+ {
+ // creates a common fruit "factory"
+ KDGenericFactory< Fruit > fruitPlantation;
+ // registers the product "Apple"
+ fruitPlantation.registerProduct< Apple >( "Apple" );
+ // registers the product "Pear"
+ fruitPlantation.registerProduct< Pear >( "Pear" );
+
+ // lets create some stuff - here comes our tasty apple:
+ Fruit* myApple = fruitPlantation.create( "Apple" );
+
+ // and a pear, please:
+ Fruit* myPear = fruitPlantation.create( "Pear" );
+
+ // ohh - that doesn't work, returns a null pointer:
+ Fruit* myCherry = fruitPlantation.create( "Cherry" );
+ }
+
+ \endcode
+*/
+
+/*!
+ \fn KDGenericFactory::~KDGenericFactory
+
+ Destructor.
+*/
+
+/*!
+ \typedef KDGenericFactory::FactoryFunction
+
+ This typedef defines a factory function producing an object of type T_Product.
+*/
+
+/*!
+ \fn KDGenericFactory::registerProduct( const T_Identifier& name )
+
+ Registers a product of type T, identified by \a name in the factory.
+ Any type with the same name gets unregistered.
+
+ If a product was registered via this method, it will be created using its
+ default constructor.
+*/
+
+/*!
+ \fn KDGenericFactory::unregisterProduct( const T_Identifier& name )
+
+ Unregisters the previously registered product identified by \a name from the factory.
+ If no such product is known, nothing is done.
+*/
+
+/*!
+ \fn KDGenericFactory::productCount() const
+
+ Returns the number of different products known to the factory.
+*/
+
+/*!
+ \fn KDGenericFactory::availableProducts() const
+
+ Returns the list of products known to the factory.
+*/
+
+/*!
+ \fn KDGenericFactory::create( const T_Identifier& name ) const
+
+ Creates and returns a product of the type identified by \a name.
+ Ownership of the product is transferred to the caller.
+*/
+
+/*!
+ \fn KDGenericFactory::registerProductionFunction( const T_Identifier& name, FactoryFunction create )
+
+ Subclasses can use this method to register their own FactoryFunction \a create to create products of
+ type T, identified by \a name. When a product is registered via this method, it will be created
+ by calling create().
+*/
+
+#ifdef KDTOOLSCORE_UNITTESTS
+
+#include <KDUnitTest/test.h>
+
+#include <QStringList>
+#include <QMap>
+
+class Fruit
+{
+public:
+ virtual ~Fruit() {}
+};
+
+class Apple : public Fruit
+{
+};
+
+class Pear : public Fruit
+{
+};
+
+std::ostream& operator<<( std::ostream& stream, const QStringList& list )
+{
+ stream << "QStringList(";
+ for( QStringList::const_iterator it = list.begin(); it != list.end(); ++it )
+ {
+ stream << " " << it->toLocal8Bit().data();
+ if( it + 1 != list.end() )
+ stream << ",";
+ }
+ stream << " )";
+ return stream;
+}
+
+class KDGenericFactoryTest : public KDUnitTest::Test {
+public:
+ KDGenericFactoryTest() : Test( "KDGenericFactory" ) {}
+ void run() {
+ doRun<QHash>();
+ doRun<QMap>();
+ }
+
+ template <template <typename U, typename V> class T_Map>
+ void doRun();
+};
+
+KDAB_EXPORT_UNITTEST( KDGenericFactoryTest, "kdcoretools" )
+
+template <template <typename U, typename V> class T_Map>
+void KDGenericFactoryTest::doRun() {
+
+ {
+ KDGenericFactory< Fruit, QString, T_Map > fruitPlantation;
+ assertEqual( fruitPlantation.productCount(), 0U );
+ assertEqual( fruitPlantation.availableProducts(), QStringList() );
+
+ fruitPlantation.template registerProduct< Apple >( QLatin1String( "Apple" ) );
+ assertEqual( fruitPlantation.productCount(), 1U );
+ assertEqual( fruitPlantation.availableProducts(), QStringList( QLatin1String( "Apple" ) ) );
+
+ fruitPlantation.template registerProduct< Pear >( QLatin1String( "Pear" ) );
+ assertEqual( fruitPlantation.productCount(), 2U );
+
+ Fruit* fruit = 0;
+ fruit = fruitPlantation.create( QLatin1String( "Apple" ) );
+ assertNotNull( fruit );
+ assertNotNull( dynamic_cast< Apple* >( fruit ) );
+
+ fruit = fruitPlantation.create( QLatin1String( "Pear" ) );
+ assertNotNull( fruit );
+ assertNotNull( dynamic_cast< Pear* >( fruit ) );
+
+ fruit = fruitPlantation.create( QLatin1String( "Cherry" ) );
+ assertNull( fruit );
+
+ fruitPlantation.unregisterProduct( QLatin1String( "Apple" ) );
+ assertEqual( fruitPlantation.productCount(), 1U );
+ assertEqual( fruitPlantation.availableProducts(), QStringList( QLatin1String( "Pear" ) ) );
+ fruit = fruitPlantation.create( QLatin1String( "Apple" ) );
+ assertNull( fruit );
+
+ fruit = fruitPlantation.create( QLatin1String( "Pear" ) );
+ assertNotNull( fruit );
+ assertNotNull( dynamic_cast< Pear* >( fruit ) );
+
+
+ fruitPlantation.unregisterProduct( QLatin1String( "Pear" ) );
+ assertEqual( fruitPlantation.productCount(), 0U );
+ fruit = fruitPlantation.create( QLatin1String( "Pear" ) );
+ assertNull( fruit );
+ }
+
+}
+#endif // KDTOOLSCORE_UNITTESTS
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.h
new file mode 100644
index 000000000..1a0d7f854
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdgenericfactory.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLSCORE__KDGENERICFACTORY_H__
+#define __KDTOOLSCORE__KDGENERICFACTORY_H__
+
+#include <KDToolsCore/kdtoolsglobal.h>
+
+#include <QtCore/QHash>
+
+template< typename T_Product, typename T_Identifier = QString, template< typename U, typename V > class T_Map = QHash >
+class MAKEINCLUDES_EXPORT KDGenericFactory
+{
+public:
+ virtual ~KDGenericFactory()
+ {
+ }
+
+ typedef T_Product* (*FactoryFunction)();
+
+ template< typename T >
+ void registerProduct( const T_Identifier& name )
+ {
+#ifdef Q_CC_MSVC
+ FactoryFunction function = &KDGenericFactory::create<T>;
+ registerProductionFunction( name, function );
+#else
+ registerProductionFunction( name, &create<T> );
+#endif
+ }
+
+ void unregisterProduct( const T_Identifier& name )
+ {
+ map.remove( name );
+ }
+
+ unsigned int productCount() const
+ {
+ return map.size();
+ }
+
+ QList< T_Identifier > availableProducts() const
+ {
+ return map.keys();
+ }
+
+ T_Product* create( const T_Identifier& name ) const
+ {
+ const typename T_Map< T_Identifier, FactoryFunction >::const_iterator it = map.find( name );
+ if( it == map.end() )
+ return 0;
+ return (*it)();
+ }
+
+protected:
+ void registerProductionFunction( const T_Identifier& name, FactoryFunction create )
+ {
+ map.insert( name, create );
+ }
+
+private:
+ template< typename T >
+ static T_Product* create()
+ {
+ return new T;
+ }
+
+ T_Map< T_Identifier, FactoryFunction > map;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.cpp
new file mode 100644
index 000000000..d88380ffb
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdjob.h"
+
+#include <QEventLoop>
+
+class KDJob::Private {
+ KDJob* const q;
+public:
+ explicit Private( KDJob* qq ) : q( qq ), error( KDJob::NoError ), errorString(), caps( KDJob::NoCapabilities ), autoDelete( true ), totalAmount( 100 ), processedAmount( 0 ) {}
+
+ void delayedStart() {
+ q->doStart();
+ emit q->started( q );
+ }
+
+ void waitForSignal( const char* sig ) {
+ QEventLoop loop;
+ q->connect( q, sig, &loop, SLOT(quit()) );
+ loop.exec();
+ }
+
+ int error;
+ QString errorString;
+ KDJob::Capabilities caps;
+ bool autoDelete : 1;
+ quint64 totalAmount;
+ quint64 processedAmount;
+};
+
+KDJob::KDJob( QObject* parent ) : QObject( parent ), d( new Private( this ) ) {
+}
+
+KDJob::~KDJob() {
+ //delete d;
+}
+
+bool KDJob::autoDelete() const {
+ return d->autoDelete;
+}
+
+void KDJob::setAutoDelete( bool autoDelete ) {
+ d->autoDelete = autoDelete;
+}
+
+int KDJob::error() const {
+ return d->error;
+}
+
+QString KDJob::errorString() const {
+ return d->errorString;
+}
+
+void KDJob::emitFinished() {
+ emit finished( this );
+ if ( d->autoDelete )
+ deleteLater();
+}
+
+void KDJob::emitFinishedWithError( int error, const QString& errorString ) {
+ d->error = error;
+ d->errorString = errorString;
+ emitFinished();
+}
+
+void KDJob::setError( int error ) {
+ d->error = error;
+}
+
+void KDJob::setErrorString( const QString& errorString ) {
+ d->errorString = errorString;
+}
+
+void KDJob::waitForStarted() {
+ d->waitForSignal( SIGNAL(started(KDJob*)) );
+}
+
+void KDJob::waitForFinished() {
+ d->waitForSignal( SIGNAL(finished(KDJob*)) );
+}
+
+KDJob::Capabilities KDJob::capabilities() const {
+ return d->caps;
+}
+
+bool KDJob::hasCapability( Capability c ) const {
+ return d->caps.testFlag( c );
+}
+
+void KDJob::setCapabilities( Capabilities c ) {
+ d->caps = c;
+}
+
+void KDJob::start() {
+ QMetaObject::invokeMethod( this, "delayedStart", Qt::QueuedConnection );
+}
+
+void KDJob::doCancel() {
+}
+
+void KDJob::cancel() {
+ doCancel();
+ setError( Canceled );
+}
+
+quint64 KDJob::totalAmount() const {
+ return d->totalAmount;
+}
+
+quint64 KDJob::processedAmount() const {
+ return d->processedAmount;
+}
+
+void KDJob::setTotalAmount( quint64 amount ) {
+ if ( d->totalAmount == amount )
+ return;
+ d->totalAmount = amount;
+ emit progress( this, d->processedAmount, d->totalAmount );
+}
+
+void KDJob::setProcessedAmount( quint64 amount ) {
+ if ( d->processedAmount == amount )
+ return;
+ d->processedAmount = amount;
+ emit progress( this, d->processedAmount, d->totalAmount );
+}
+
+#include "moc_kdjob.cpp"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.h
new file mode 100644
index 000000000..10cdd6899
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdjob.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLS_CORE_KDJOB_H__
+#define __KDTOOLS_CORE_KDJOB_H__
+
+#include <QObject>
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+class KDTOOLSCORE_EXPORT KDJob : public QObject {
+ Q_OBJECT
+ Q_PROPERTY( bool autoDelete READ autoDelete WRITE setAutoDelete )
+
+public:
+ explicit KDJob( QObject* parent=0 );
+ ~KDJob();
+
+ enum Error {
+ NoError=0,
+ Canceled=1,
+ UserDefinedError=128
+ };
+
+ enum Capability {
+ NoCapabilities=0x0,
+ Cancelable=0x1
+ };
+
+ Q_DECLARE_FLAGS(Capabilities, Capability)
+
+ int error() const;
+ QString errorString() const;
+
+ bool autoDelete() const;
+ void setAutoDelete( bool autoDelete );
+
+ Capabilities capabilities() const;
+ bool hasCapability( Capability c ) const;
+
+ void waitForStarted();
+ void waitForFinished();
+
+ quint64 totalAmount() const;
+ quint64 processedAmount() const;
+
+public Q_SLOTS:
+ void start();
+ void cancel();
+
+Q_SIGNALS:
+ void infoMessage( KDJob*, const QString& );
+
+Q_SIGNALS:
+#ifndef Q_MOC_RUN
+private: // make signals private unless moc runs
+#endif
+ void started( KDJob* );
+ void finished( KDJob* );
+ void progress( KDJob* job, quint64 processed, quint64 total );
+
+protected:
+ virtual void doStart() = 0;
+ virtual void doCancel();
+
+ void setCapabilities( Capabilities c );
+ void setTotalAmount( quint64 amount );
+ void setProcessedAmount( quint64 amount );
+
+ void setError( int error );
+ void setErrorString( const QString& errorString );
+
+ void emitFinished();
+ void emitFinishedWithError( int error, const QString& errorString );
+
+private:
+ class Private;
+ friend class ::KDJob::Private;
+ kdtools::pimpl_ptr<Private> d;
+ Q_PRIVATE_SLOT( d, void delayedStart() )
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(KDJob::Capabilities)
+
+#endif // __KDTOOLS_CORE_KDJOB_H__
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.cpp
new file mode 100644
index 000000000..234bc448e
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdlockfile.h"
+
+#include "kdlockfile_p.h"
+
+KDLockFile::Private::Private( const QString& filename_ )
+ : filename( filename_ )
+ , handle( 0 )
+ , locked( false )
+{
+}
+
+KDLockFile::KDLockFile( const QString& name )
+ : d( new Private( name ) )
+{
+}
+
+KDLockFile::~KDLockFile()
+{
+}
+
+bool KDLockFile::lock()
+{
+ return d->lock();
+}
+
+QString KDLockFile::errorString() const
+{
+ return d->errorString;
+}
+
+bool KDLockFile::unlock()
+{
+ return d->unlock();
+}
+
+
+#ifdef KDTOOLSCORE_UNITTESTS
+
+#include <KDUnitTest/Test>
+#include <QDebug>
+#include <QDir>
+
+KDAB_UNITTEST_SIMPLE( KDLockFile, "kdcoretools" ) {
+ {
+ KDLockFile f( QLatin1String("/jlksdfdsfjkldsf-doesnotexist/file") );
+ const bool locked = f.lock();
+ assertFalse( locked );
+ qDebug() << f.errorString();
+ assertTrue( !f.errorString().isEmpty() );
+ if ( !locked )
+ assertTrue( f.unlock() );
+ }
+ {
+ KDLockFile f( QDir::currentPath() + QLatin1String("/kdlockfile-test") );
+ const bool locked = f.lock();
+ assertTrue( locked );
+ if ( !locked )
+ qDebug() << f.errorString();
+ assertEqual( locked, f.errorString().isEmpty() );
+ const bool unlocked = f.unlock();
+ assertTrue( unlocked );
+ if ( !unlocked )
+ qDebug() << f.errorString();
+ assertEqual( unlocked, f.errorString().isEmpty() );
+ }
+}
+
+#endif // KDTOOLSCORE_UNITTESTS
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.h
new file mode 100644
index 000000000..cecbc5cbd
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLSCORE_KDLOCKFILE_H__
+#define __KDTOOLSCORE_KDLOCKFILE_H__
+
+#include <pimpl_ptr.h>
+
+class QString;
+
+class KDTOOLSCORE_EXPORT KDLockFile
+{
+public:
+ explicit KDLockFile( const QString & name );
+ ~KDLockFile();
+
+ QString errorString() const;
+
+ bool lock();
+ bool unlock();
+
+private:
+ Q_DISABLE_COPY(KDLockFile)
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+#endif // __KDTOOLSCORE_KDLOCKFILE_H__
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_p.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_p.h
new file mode 100644
index 000000000..da4c4dc4c
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_p.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLSCORE_KDLOCKFILE_P_H__
+#define __KDTOOLSCORE_KDLOCKFILE_P_H__
+
+#include "kdlockfile.h"
+#include <QtCore/QString>
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
+
+class KDLockFile::Private
+{
+public:
+ explicit Private( const QString& filename );
+ ~Private();
+ bool lock();
+ bool unlock();
+
+ QString errorString;
+
+private:
+ QString filename;
+#ifdef Q_OS_WIN
+ HANDLE handle;
+#else
+ int handle;
+#endif
+ bool locked;
+};
+
+#endif // LOCKFILE_P_H
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_unix.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_unix.cpp
new file mode 100644
index 000000000..e3d187cbf
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_unix.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdlockfile_p.h"
+
+#include <QtCore/QCoreApplication>
+
+#include <cerrno>
+
+#include <sys/file.h>
+
+KDLockFile::Private::~Private()
+{
+ unlock();
+}
+
+bool KDLockFile::Private::lock()
+{
+ if ( locked )
+ return true;
+
+ errorString.clear();
+ errno = 0;
+ handle = open( filename.toLatin1().constData(), O_CREAT | O_RDWR | O_NONBLOCK );
+ if ( handle == -1 ) {
+ errorString = QObject::tr("Could not create lock file %1: %2").arg( filename, QLatin1String( strerror( errno ) ) );
+ return false;
+ }
+ const QString pid = QString::number( qApp->applicationPid() );
+ const QByteArray data = pid.toLatin1();
+ errno = 0;
+ qint64 written = 0;
+ while ( written < data.size() ) {
+ const qint64 n = write( handle, data.constData() + written, data.size() - written );
+ if ( n < 0 ) {
+ errorString = QObject::tr("Could not write PID to lock file %1: %2").arg( filename, QLatin1String( strerror( errno ) ) );
+ return false;
+ }
+ written += n;
+ }
+ errno = 0;
+ locked = flock( handle, LOCK_NB | LOCK_EX ) != -1;
+ if ( !locked )
+ errorString = QObject::tr("Could not lock lock file %1: %2").arg( filename, QLatin1String( strerror( errno ) ) );
+ return locked;
+}
+
+bool KDLockFile::Private::unlock()
+{
+ errorString.clear();
+ if ( !locked )
+ return true;
+ errno = 0;
+ locked = flock( handle, LOCK_UN | LOCK_NB ) == -1;
+ if ( locked )
+ errorString = QObject::tr("Could not unlock lock file %1: %2").arg( filename, QLatin1String( strerror( errno ) ) );
+ return !locked;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_win.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_win.cpp
new file mode 100644
index 000000000..f7fed60ab
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdlockfile_win.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdlockfile.h"
+#include "kdlockfile_p.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QFileInfo>
+
+KDLockFile::Private::~Private()
+{
+ unlock();
+}
+
+bool KDLockFile::Private::lock()
+{
+ const QFileInfo fi( filename );
+ handle = CreateFile( filename.toStdWString().data(),
+ GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
+ NULL, fi.exists() ? OPEN_EXISTING : CREATE_NEW,
+ FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL );
+
+ if ( !handle )
+ return false;
+ QString pid = QString::number( qApp->applicationPid() );
+ QByteArray data = pid.toLatin1();
+ DWORD bytesWritten;
+ const bool wrotePid = WriteFile( handle, data.data(), data.size(), &bytesWritten, NULL );
+ if ( !wrotePid )
+ return false;
+ FlushFileBuffers( handle );
+
+ const bool locked = LockFile( handle, 0, 0, fi.size(), 0 );
+
+ this->locked = locked;
+ return locked;
+}
+
+bool KDLockFile::Private::unlock()
+{
+ const QFileInfo fi( filename );
+ if ( locked )
+ {
+ const bool success = UnlockFile( handle, 0, 0, 0, fi.size() );
+ this->locked = !success;
+ CloseHandle( handle );
+ return success;
+ }
+ return true;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.cpp
new file mode 100644
index 000000000..1a0b863c7
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.cpp
@@ -0,0 +1,493 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdmetamethoditerator.h"
+
+/*!
+ \class KDMetaMethodIterator
+ \ingroup core
+ \brief Iterator over methods of QObjects
+ \since_c 2.3
+
+ KDMetaMethodIterator provides a way over all methods of a QObject which can be accessed via Qt's meta
+ object system. It is possible to filter on types of methods (Q_INVOKABLE methods, signals, slots,
+ constructors) and on access types (public, protected, private). Furthermore, KDMetaMethodIterator can
+ be configured to filter methods of the given object's base class or all methods provided by QObject.
+
+ \section general-use General Use
+
+ The following example shows a general use case of KDMetaMethodIterator:
+
+ \code
+
+ class QIODeviceWrapper : public QIODevice
+ {
+ Q_OBJECT
+ public:
+ QIODeviceWrapper( QIODevice* nestedDevice )
+ : nested( nestedDevice )
+ {
+ // make sure all signals of the nested QIODevice are forwarded,
+ // but make sure not to connect QObject's own destroyed() signal,
+ // therefore use KDMetaMethodIterator::IgnoreQObjectMethods
+ KDMetaMethodIterator it( QIODevice::staticMetaObject, KDMetaMethodIterator::Signal, KDMetaMethodIterator::IgnoreQObjectMethods );
+ while( it.hasNext() )
+ {
+ it.next();
+ connect( nested, it.connectableSignature(), this, it.connectableSignature() );
+ }
+ }
+
+ protected:
+ // virtual methods needed to access the contents...
+
+ private:
+ QIODevice* const nested;
+ };
+
+ \endcode
+*/
+
+/*!
+ \enum KDMetaMethodIterator::AccessType
+ This enum describes the access type of methods to iterate:
+*/
+
+/*!
+ \var KDMetaMethodIterator::Private
+ Iterate over private methods.
+*/
+
+/*!
+ \var KDMetaMethodIterator::Protected
+ Iterate over protected methods.
+*/
+
+/*!
+ \var KDMetaMethodIterator::Public
+ Iterate over public methods.
+*/
+
+/*!
+ \var KDMetaMethodIterator::AllAccessTypes
+ Iterate over methods of all access types.
+*/
+
+/*!
+ \enum KDMetaMethodIterator::MethodType
+ This enum describes the type of methods to iterate:
+*/
+
+/*!
+ \var KDMetaMethodIterator::Method
+ Iterate over methods marked with Q_INVOKABLE
+*/
+
+/*!
+ \var KDMetaMethodIterator::Signal
+ Iterate over signals.
+*/
+
+/*!
+ \var KDMetaMethodIterator::Slot
+ Iterate over slots.
+*/
+
+/*!
+ \var KDMetaMethodIterator::Constructor
+ Iterate over constructors marked with Q_INVOKABLE.
+*/
+
+/*!
+ \var KDMetaMethodIterator::AllMethodTypes
+ Iterate over all supported method types.
+*/
+
+/*!
+ \enum KDMetaMethodIterator::IteratorFlag
+ This enum describes flags which can be passed to KDMetaMethodIterator:
+*/
+
+/*!
+ \var KDMetaMethodIterator::NoFlags
+ No flags set, only type filtering takes place.
+*/
+
+/*!
+ \var KDMetaMethodIterator::IgnoreQObjectMethods
+ KDMetaMethodIterator will not iterate over methods provided by QObject itself.
+*/
+
+/*!
+ \var KDMetaMethodIterator::IgnoreSuperClassMethods
+ KDMetaMethodIterator will only iterate over methods provided by the passed class instance itself, ignoring any base classes.
+*/
+
+/*!
+ \internal
+ */
+class KDMetaMethodIterator::Priv
+{
+public:
+ Priv( const QMetaObject* object, MethodTypes types, AccessTypes access, IteratorFlags flags )
+ : index( -1 ),
+ m( types ),
+ a( access ),
+ f( flags ),
+ metaObject( object )
+ {
+ }
+
+ Priv( const QMetaObject* object, MethodTypes types, IteratorFlags flags )
+ : index( -1 ),
+ m( types ),
+ a( ( types & Signal ) ? ( Protected | Public ) : Public ),
+ f( flags ),
+ metaObject( object )
+ {
+ }
+
+ bool filterMatches( const QMetaMethod& method, int index ) const;
+
+ int index;
+ const MethodTypes m;
+ const AccessTypes a;
+ const IteratorFlags f;
+ const QMetaObject* const metaObject;
+
+ mutable QByteArray connectableSignature;
+};
+
+/*!
+ Creates a new KDMetaMethodIterator iterating over \a metaObject. The iterator will only return methods of the given \a types.
+ By default, only public methods will be returned. If \a types contains Signal, the access type filter will automatically set
+ to return protected and public.
+
+ By default, \a flags is NoFlags, which lists all methods.
+ */
+KDMetaMethodIterator::KDMetaMethodIterator( const QMetaObject& metaObject, MethodTypes types, IteratorFlags flags )
+ : d( new Priv( &metaObject, types, flags ) )
+{
+}
+
+/*!
+ Creates a new KDMetaMethodIterator iterating over \a metaObject. The iterator will only return methods of the given \a types,
+ matching the \a access mode.
+
+ By default, \a flags is NoFlags, which lists all methods.
+
+ \overload
+ */
+KDMetaMethodIterator::KDMetaMethodIterator( const QMetaObject& metaObject, MethodTypes types, AccessType access, IteratorFlags flags )
+ : d( new Priv( &metaObject, types, access, flags ) )
+{
+}
+
+/*!
+ Creates a new KDMetaMethodIterator iterating over \a metaObject. The iterator will only return methods matching the \a access mode.
+
+ By default, \a flags is NoFlags, which lists all methods.
+
+ \overload
+ */
+KDMetaMethodIterator::KDMetaMethodIterator( const QMetaObject& metaObject, AccessType access, IteratorFlags flags )
+ : d( new Priv( &metaObject, AllMethodTypes, access, flags ) )
+{
+}
+
+/*!
+ Creates a new KDMetaMethodIterator iterating over \a metaObject. The iterator will only return methods of the given \a types.
+ By default, only public methods will be returned. If \a types contains Signal, the access type filter will automatically set
+ to return protected and public.
+
+ By default, \a flags is NoFlags, which lists all methods.
+
+ \overload
+ */
+KDMetaMethodIterator::KDMetaMethodIterator( const QMetaObject* metaObject, MethodTypes types, IteratorFlags flags )
+ : d( new Priv( metaObject, types, flags ) )
+{
+}
+
+/*!
+ Creates a new KDMetaMethodIterator iterating over \a metaObject. The iterator will only return methods of the given \a types,
+ matching the \a access mode.
+
+ By default, \a flags is NoFlags, which lists all methods.
+
+ \overload
+ */
+KDMetaMethodIterator::KDMetaMethodIterator( const QMetaObject* metaObject, MethodTypes types, AccessType access, IteratorFlags flags )
+ : d( new Priv( metaObject, types, access, flags ) )
+{
+}
+
+/*!
+ Creates a new KDMetaMethodIterator iterating over \a metaObject. The iterator will only return methods matching the \a access mode.
+
+ By default, \a flags is NoFlags, which lists all methods.
+
+ \overload
+ */
+KDMetaMethodIterator::KDMetaMethodIterator( const QMetaObject* metaObject, AccessType access, IteratorFlags flags )
+ : d( new Priv( metaObject, AllMethodTypes, access, flags ) )
+{
+}
+
+/*!
+ Creates a new KDMetaMethodIterator iterating over \a object. The iterator will only return methods of the given \a types.
+ By default, only public methods will be returned. If \a types contains Signal, the access type filter will automatically set
+ to return protected and public.
+
+ By default, \a flags is NoFlags, which lists all methods.
+
+ \overload
+ */
+KDMetaMethodIterator::KDMetaMethodIterator( const QObject* object, MethodTypes types, IteratorFlags flags )
+ : d( new Priv( object->metaObject(), types, flags ) )
+{
+}
+
+/*!
+ Creates a new KDMetaMethodIterator iterating over \a object. The iterator will only return methods of the given \a types,
+ matching the \a access mode.
+
+ By default, \a flags is NoFlags, which lists all methods.
+
+ \overload
+ */
+KDMetaMethodIterator::KDMetaMethodIterator( const QObject* object, MethodTypes types, AccessType access, IteratorFlags flags )
+ : d( new Priv( object->metaObject(), types, access, flags ) )
+{
+}
+
+/*!
+ Creates a new KDMetaMethodIterator iterating over \a object. The iterator will only return methods matching the \a access mode.
+
+ By default, \a flags is NoFlags, which lists all methods.
+
+ \overload
+ */
+KDMetaMethodIterator::KDMetaMethodIterator( const QObject* object, AccessType access, IteratorFlags flags )
+ : d( new Priv( object->metaObject(), AllMethodTypes, access, flags ) )
+{
+}
+
+/*!
+ Destroys the KDMetaMethodIterator.
+ */
+KDMetaMethodIterator::~KDMetaMethodIterator()
+{
+}
+
+/*!
+ Returns true if there is at least one item ahead of the iterator, i.e. the iterator is not at the back of the method list; otherwise returns false.
+ */
+bool KDMetaMethodIterator::hasNext() const
+{
+ for( int i = d->index + 1; i < d->metaObject->methodCount(); ++i )
+ {
+ const QMetaMethod method = d->metaObject->method( i );
+ if( d->filterMatches( method, i ) )
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Returns the next method and advances the iterator by one position.
+ */
+QMetaMethod KDMetaMethodIterator::next()
+{
+ Q_ASSERT( hasNext() );
+ d->connectableSignature.clear();
+ for( ++d->index; d->index < d->metaObject->methodCount(); ++d->index )
+ {
+ const QMetaMethod method = d->metaObject->method( d->index );
+ if( d->filterMatches( method, d->index ) )
+ return method;
+ }
+ return QMetaMethod();
+}
+
+/*!
+ Returns the current method's signature ready to be passed to QObject::connect, i.e. already passed through the SIGNAL or SLOT macro.
+ The return value stays valid up to the following next() call. This is only valid for signals and slots.
+ */
+const char* KDMetaMethodIterator::connectableSignature() const
+{
+ if( d->connectableSignature.isEmpty() )
+ {
+ const QMetaMethod method = d->metaObject->method( d->index );
+ d->connectableSignature = method.signature();
+ d->connectableSignature.push_front( QString::number( ( static_cast< int >( method.methodType() ) - 3 ) * -1 ).toLocal8Bit() );
+ }
+ return d->connectableSignature.constData();
+}
+
+/*!
+ Returns true if \a method matches the filters set on the iterator, currently pointing to \a index.
+ \internal
+ */
+bool KDMetaMethodIterator::Priv::filterMatches( const QMetaMethod& method, int index ) const
+{
+ // filter QObject's own methods
+ if( ( f & IgnoreQObjectMethods ) && index < QObject::staticMetaObject.methodCount() )
+ return false;
+
+ // filter any super classes methods
+ if( ( f & IgnoreSuperClassMethods ) && index < metaObject->methodOffset() )
+ return false;
+
+ // filter any methods with unwanted access types
+ if( ( ( 1 << method.access() ) & a ) == 0 )
+ return false;
+
+ // filter any methods with unwanted method types
+ return ( ( 1 << method.methodType() ) & m ) != 0;
+}
+
+#ifdef KDTOOLSCORE_UNITTESTS
+
+#include <KDUnitTest/Test>
+
+class TestClass : public QObject
+{
+ Q_OBJECT
+public:
+ TestClass(){}
+
+public Q_SLOTS:
+ void publicSlot( int ) {}
+
+protected Q_SLOTS:
+ void protectedSlot( int ) {}
+
+private Q_SLOTS:
+ void privateSlot( int ) {}
+
+private:
+ Q_PRIVATE_SLOT( d, void veryPrivateSlot() )
+
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+class TestClassDerived : public TestClass
+{
+ Q_OBJECT
+public:
+ TestClassDerived(){}
+};
+
+class TestClass::Private
+{
+public:
+ void veryPrivateSlot() {}
+};
+
+KDAB_UNITTEST_SIMPLE( KDMetaMethodIterator, "kdcoretools" ) {
+
+ QObject o;
+ {
+ KDMetaMethodIterator it( &o, KDMetaMethodIterator::Signal );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "destroyed(QObject*)" );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "destroyed()" );
+ assertFalse( it.hasNext() );
+ }
+ {
+ KDMetaMethodIterator it( QObject::staticMetaObject, KDMetaMethodIterator::Signal );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "destroyed(QObject*)" );
+ }
+ {
+ KDMetaMethodIterator it( o.metaObject(), KDMetaMethodIterator::Signal );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "destroyed(QObject*)" );
+ }
+
+ {
+ KDMetaMethodIterator it( TestClass::staticMetaObject, KDMetaMethodIterator::Signal );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "destroyed(QObject*)" );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "destroyed()" );
+ assertEqual( std::string( it.connectableSignature() ), "2destroyed()" );
+ assertFalse( it.hasNext() );
+ }
+
+ {
+ KDMetaMethodIterator it( TestClass::staticMetaObject, KDMetaMethodIterator::Signal, KDMetaMethodIterator::IgnoreQObjectMethods );
+ assertFalse( it.hasNext() );
+ }
+ {
+ KDMetaMethodIterator it( TestClass::staticMetaObject, KDMetaMethodIterator::Signal, KDMetaMethodIterator::IgnoreSuperClassMethods );
+ assertFalse( it.hasNext() );
+ }
+ {
+ KDMetaMethodIterator it( TestClass::staticMetaObject, KDMetaMethodIterator::Slot );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "deleteLater()" );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "publicSlot(int)" );
+ assertEqual( std::string( it.connectableSignature() ), "1publicSlot(int)" );
+ assertFalse( it.hasNext() );
+ }
+ {
+ KDMetaMethodIterator it( TestClass::staticMetaObject, KDMetaMethodIterator::Slot, KDMetaMethodIterator::IgnoreQObjectMethods );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "publicSlot(int)" );
+ assertFalse( it.hasNext() );
+ }
+ {
+ KDMetaMethodIterator it( TestClass::staticMetaObject, KDMetaMethodIterator::Slot, KDMetaMethodIterator::Protected, KDMetaMethodIterator::IgnoreQObjectMethods );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "protectedSlot(int)" );
+ assertFalse( it.hasNext() );
+ }
+ {
+ KDMetaMethodIterator it( TestClass::staticMetaObject, KDMetaMethodIterator::Slot, KDMetaMethodIterator::Private, KDMetaMethodIterator::IgnoreQObjectMethods );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "privateSlot(int)" );
+ assertEqual( std::string( it.next().signature() ), "veryPrivateSlot()" );
+ assertFalse( it.hasNext() );
+ }
+
+ {
+ KDMetaMethodIterator it( TestClassDerived::staticMetaObject, KDMetaMethodIterator::Slot, KDMetaMethodIterator::Private, KDMetaMethodIterator::IgnoreQObjectMethods );
+ assertTrue( it.hasNext() );
+ assertEqual( std::string( it.next().signature() ), "privateSlot(int)" );
+ assertEqual( std::string( it.next().signature() ), "veryPrivateSlot()" );
+ assertFalse( it.hasNext() );
+ }
+ {
+ KDMetaMethodIterator it( TestClassDerived::staticMetaObject, KDMetaMethodIterator::Slot, KDMetaMethodIterator::Private, KDMetaMethodIterator::IgnoreSuperClassMethods );
+ assertFalse( it.hasNext() );
+ }
+
+}
+
+#include "kdmetamethoditerator.moc"
+
+#endif // KDTOOLSCORE_UNITTESTS
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.h
new file mode 100644
index 000000000..94bb8f707
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdmetamethoditerator.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLSCORE_KDMETAMETHODITERATOR_H__
+#define __KDTOOLSCORE_KDMETAMETHODITERATOR_H__
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include <QtCore/QMetaMethod>
+
+class KDTOOLSCORE_EXPORT KDMetaMethodIterator
+{
+public:
+ enum AccessType
+ {
+ Private = 1 << QMetaMethod::Private,
+ Protected = 1 << QMetaMethod::Protected,
+ Public = 1 << QMetaMethod::Public,
+ AllAccessTypes = Private | Protected | Public
+ };
+ Q_DECLARE_FLAGS( AccessTypes, AccessType )
+
+ enum MethodType
+ {
+ Method = 0x1,
+ Signal = 0x2,
+ Slot = 0x4,
+ Constructor = 0x8,
+ AllMethodTypes = Method | Signal | Slot | Constructor
+ };
+ Q_DECLARE_FLAGS( MethodTypes, MethodType )
+
+ enum IteratorFlag
+ {
+ NoFlags = 0x00,
+ IgnoreQObjectMethods = 0x01,
+ IgnoreSuperClassMethods = 0x02
+ };
+ Q_DECLARE_FLAGS( IteratorFlags, IteratorFlag )
+
+ explicit KDMetaMethodIterator( const QMetaObject& metaObject, MethodTypes types = AllMethodTypes, IteratorFlags flags = NoFlags );
+ KDMetaMethodIterator( const QMetaObject& metaObject, MethodTypes types, AccessType access, IteratorFlags flags = NoFlags );
+ KDMetaMethodIterator( const QMetaObject& metaObject, AccessType access, IteratorFlags flags = NoFlags );
+
+ explicit KDMetaMethodIterator( const QMetaObject* metaObject, MethodTypes types = AllMethodTypes, IteratorFlags flags = NoFlags );
+ KDMetaMethodIterator( const QMetaObject* metaObject, MethodTypes types, AccessType access, IteratorFlags flags = NoFlags );
+ KDMetaMethodIterator( const QMetaObject* metaObject, AccessType access, IteratorFlags flags = NoFlags );
+
+ explicit KDMetaMethodIterator( const QObject* object, MethodTypes types = AllMethodTypes, IteratorFlags flags = NoFlags );
+ KDMetaMethodIterator( const QObject* object, MethodTypes types, AccessType access, IteratorFlags flags = NoFlags );
+ KDMetaMethodIterator( const QObject* object, AccessType access, IteratorFlags flags = NoFlags );
+
+ ~KDMetaMethodIterator();
+
+ bool hasNext() const;
+ QMetaMethod next();
+
+ const char* connectableSignature() const;
+
+private:
+ class Priv;
+ kdtools::pimpl_ptr< Priv > d;
+};
+
+
+#endif // __KDTOOLSCORE_KDMETAMETHODITERATOR_H__
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.cpp
new file mode 100644
index 000000000..457a6215a
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdrunoncechecker.h"
+#include "kdlockfile.h"
+#include "kdsysinfo.h"
+
+#include <QtCore/QList>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+
+#include <algorithm>
+
+class KDRunOnceChecker::Private
+{
+public:
+ Private( const QString& filename );
+ ~Private();
+ KDLockFile m_lockfile;
+ bool m_hasLock;
+};
+
+KDRunOnceChecker::Private::Private( const QString& filename )
+ : m_lockfile( filename )
+ , m_hasLock( false )
+{
+
+}
+
+KDRunOnceChecker::Private::~Private()
+{
+
+}
+
+KDRunOnceChecker::KDRunOnceChecker( const QString& filename )
+ :d( new Private( filename ) )
+{
+
+}
+
+KDRunOnceChecker::~KDRunOnceChecker()
+{
+
+}
+
+class ProcessnameEquals
+{
+public:
+ ProcessnameEquals( const QString& name ): m_name( name ){}
+ bool operator()( const KDSysInfo::ProcessInfo& info )
+ {
+#ifndef Q_WS_WIN
+ if( info.name == m_name )
+ return true;
+ const QFileInfo fi( info.name );
+ if( fi.fileName() == m_name || fi.baseName() == m_name )
+ return true;
+ return false;
+#else
+ if( info.name.toLower() == m_name.toLower() )
+ return true;
+ if( info.name.toLower() == QDir::toNativeSeparators(m_name.toLower()) )
+ return true;
+ const QFileInfo fi( info.name );
+ if( fi.fileName().toLower() == m_name.toLower() || fi.baseName().toLower() == m_name.toLower() )
+ return true;
+ return info.name == m_name;
+#endif
+ }
+
+private:
+ QString m_name;
+};
+
+bool KDRunOnceChecker::isRunning( Dependencies depends )
+{
+ bool running = false;
+ switch ( depends )
+ {
+ case( Lockfile ):
+ {
+ const bool locked = d->m_hasLock || d->m_lockfile.lock();
+ if ( locked )
+ d->m_hasLock = true;
+ running = running || ! locked;
+ }
+ break;
+ case( ProcessList ):
+ {
+ const QList< KDSysInfo::ProcessInfo > allProcesses = KDSysInfo::runningProcesses();
+ const QString appName = qApp->applicationFilePath();
+ //QList< KDSysInfo::ProcessInfo >::const_iterator it = std::find_if( allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals( appName ) );
+ const int count = std::count_if( allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals( appName ) );
+ running = running || /*it != allProcesses.constEnd()*/count > 1;
+ }
+ break;
+ case( BOTH ):
+ {
+ const QList< KDSysInfo::ProcessInfo > allProcesses = KDSysInfo::runningProcesses();
+ const QString appName = qApp->applicationFilePath();
+ //QList< KDSysInfo::ProcessInfo >::const_iterator it = std::find_if( allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals( appName ) );
+ const int count = std::count_if( allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals( appName ) );
+ const bool locked = d->m_hasLock || d->m_lockfile.lock();
+ if ( locked )
+ d->m_hasLock = true;
+ running = running || ( /*it != allProcesses.constEnd()*/count > 1 && !locked );
+
+ }
+ break;
+ }
+
+ return running;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.h
new file mode 100644
index 000000000..9e562d3cf
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdrunoncechecker.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLS_RUNONCECHECKER_H__
+#define __KDTOOLS_RUNONCECHECKER_H__
+
+#include <KDToolsCore/pimpl_ptr>
+
+#include <QtCore/QString>
+
+class KDTOOLSCORE_EXPORT KDRunOnceChecker
+{
+
+public:
+ enum Dependencies{ ProcessList, Lockfile, BOTH };
+ explicit KDRunOnceChecker( const QString& filename = QString() );
+ ~KDRunOnceChecker();
+ bool isRunning( Dependencies depends );
+
+private:
+ Q_DISABLE_COPY(KDRunOnceChecker)
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.cpp
new file mode 100644
index 000000000..38a4b87bf
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.cpp
@@ -0,0 +1,476 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdsavefile.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QPointer>
+#include <QtCore/QTemporaryFile>
+
+#ifdef Q_OS_WIN
+# include <io.h>
+#endif
+#include <memory>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+static int permissionsToMode( QFile::Permissions p, bool* ok ) {
+ Q_ASSERT( ok );
+ int m = 0;
+#ifdef Q_OS_WIN
+ //following qfsfileengine_win.cpp: QFSFileEngine::setPermissions()
+ if ( p & QFile::ReadOwner || p & QFile::ReadUser || p & QFile::ReadGroup || p & QFile::ReadOther )
+ m |= _S_IREAD;
+ if ( p & QFile::WriteOwner || p & QFile::WriteUser || p & QFile::WriteGroup || p & QFile::WriteOther )
+ m |= _S_IWRITE;
+ *ok = m != 0;
+#else
+ if ( p & QFile::ReadUser )
+ m |= S_IRUSR;
+ if ( p & QFile::WriteUser )
+ m |= S_IWUSR;
+ if ( p & QFile::ExeUser)
+ m |= S_IXUSR;
+ if ( p & QFile::ReadGroup )
+ m |= S_IRGRP;
+ if ( p & QFile::WriteGroup )
+ m |= S_IWGRP;
+ if ( p & QFile::ExeGroup )
+ m |= S_IXGRP;
+ if ( p & QFile::ReadOther )
+ m |= S_IROTH;
+ if ( p & QFile::WriteOther )
+ m |= S_IWOTH;
+ if ( p & QFile::ExeOther )
+ m |= S_IXOTH;
+ *ok = true;
+#endif
+ return m;
+}
+
+static bool sync( int fd ) {
+#ifdef Q_OS_WIN
+ return _commit( fd ) == 0;
+#else
+ return fsync( fd ) == 0;
+#endif
+}
+
+static QString makeAbsolute( const QString& path ) {
+ if ( QDir::isAbsolutePath( path ) )
+ return path;
+ return QDir::currentPath() + QLatin1String("/") + path;
+}
+
+static int myOpen( const QString& path, int flags, int mode ) {
+#ifdef Q_OS_WIN
+ int fd;
+ _wsopen_s( &fd, reinterpret_cast<const wchar_t*>( path.utf16() ), flags, _SH_DENYRW, mode );
+ return fd;
+#else
+ return open( QFile::encodeName( path ).constData(), flags, mode );
+#endif
+}
+
+static void myClose( int fd ) {
+#ifdef Q_OS_WIN
+ _close( fd );
+#else
+ close( fd );
+#endif
+}
+
+static bool touchFile( const QString& path, QFile::Permissions p ) {
+ bool ok;
+ const int mode = permissionsToMode( p, &ok );
+ if ( !ok )
+ return false;
+ const int fd = myOpen( QDir::toNativeSeparators( path ), O_WRONLY|O_CREAT, mode );
+ if ( fd < 0 )
+ {
+ QFile file( path );
+ if( !file.open( QIODevice::WriteOnly ) )
+ return false;
+ if( !file.setPermissions( p ) ) {
+ QFile::remove( path );
+ return false;
+ }
+ return true;
+ }
+ sync( fd );
+ myClose( fd );
+ return true;
+}
+
+static QFile* createFile( const QString& path, QIODevice::OpenMode m, QFile::Permissions p, bool* openOk ) {
+ Q_ASSERT( openOk );
+ if ( !touchFile( path, p ) )
+ return 0;
+ std::auto_ptr<QFile> file( new QFile( path ) );
+ *openOk = file->open( m | QIODevice::Append );
+ if ( !*openOk )
+ QFile::remove( path ); // try to remove empty file
+ return file.release();
+}
+
+/*!
+ Generates a temporary file name based on template \a path
+ \internal
+ */
+static QString generateTempFileName( const QString& path )
+{
+ const QString tmp = path + QLatin1String( "tmp.dsfdf.%1" ); //TODO: use random suffix
+ int count = 1;
+ while ( QFile::exists( tmp.arg( count ) ) )
+ ++count;
+ return tmp.arg( count );
+}
+
+/*!
+ \class KDSaveFile KDSaveFile
+ \ingroup core
+ \brief Secure and robust writing to a file
+
+*/
+
+class KDSaveFile::Private {
+ KDSaveFile* const q;
+public:
+ explicit Private( const QString& fname, KDSaveFile* qq ) : q( qq ),
+#ifdef Q_OS_WIN
+ backupExtension( QLatin1String(".bak") ),
+#else
+ backupExtension( QLatin1String("~") ),
+#endif
+ permissions( QFile::ReadUser|QFile::WriteUser), filename( fname ), tmpFile() {
+ //TODO respect umask instead of hardcoded default permissions
+ }
+
+ ~Private() {
+ deleteTempFile();
+ }
+
+ bool deleteTempFile() {
+ if ( !tmpFile )
+ return true;
+ const QString name = tmpFile->fileName();
+ delete tmpFile;
+ //force a real close by deleting the object, before deleting the actual file. Needed on Windows
+ QFile tmp( name );
+ return tmp.remove();
+ }
+
+ bool recreateTemporaryFile( QIODevice::OpenMode mode ) {
+ deleteTempFile();
+ bool ok;
+ tmpFile = createFile( generateTempFileName( filename ), mode, permissions, &ok );
+ QObject::connect( tmpFile, SIGNAL(aboutToClose()), q, SIGNAL(aboutToClose()) );
+ QObject::connect( tmpFile, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64)) );
+ QObject::connect( tmpFile, SIGNAL(readChannelFinished()), q, SIGNAL(readChannelFinished()) );
+ QObject::connect( tmpFile, SIGNAL(readyRead()), q, SIGNAL(readyRead()) );
+ return ok;
+ }
+
+ QString generateBackupName() const {
+ const QString bf = filename + backupExtension;
+ if ( !QFile::exists( bf ) )
+ return bf;
+ int count = 1;
+ while ( QFile::exists( bf + QString::number( count ) ) )
+ ++count;
+ return bf + QString::number( count );
+ }
+
+ void propagateErrors() {
+ if ( !tmpFile )
+ return;
+ q->setErrorString( tmpFile->errorString() );
+ }
+ QString backupExtension;
+ QFile::Permissions permissions;
+ QString filename;
+ QPointer<QFile> tmpFile;
+};
+
+KDSaveFile::KDSaveFile( const QString& filename, QObject* parent ) : QIODevice( parent ), d( new Private( makeAbsolute( filename ), this ) ) {
+}
+
+KDSaveFile::~KDSaveFile() {
+}
+
+void KDSaveFile::close() {
+ d->deleteTempFile();
+ QIODevice::close();
+}
+
+bool KDSaveFile::open( OpenMode mode ) {
+ setOpenMode( QIODevice::NotOpen );
+ if ( mode & QIODevice::Append ) {
+ setErrorString( tr("Append mode not supported.") );
+ return false;
+ }
+
+ if ( ( mode & QIODevice::WriteOnly ) == 0 ) {
+ setErrorString( tr("Read-only access not supported.") );
+ return false;
+ }
+
+ // for some reason this seems to be problematic... let's remove it for now, will break in commit anyhow, if it's serious
+ //if ( QFile::exists( d->filename ) && !QFileInfo( d->filename ).isWritable() ) {
+ // setErrorString( tr("The target file %1 exists and is not writable").arg( d->filename ) );
+ // return false;
+ //}
+ const bool opened = d->recreateTemporaryFile( mode );
+ if ( opened ) {
+ setOpenMode( mode );
+ }
+
+ //if target file already exists, apply permissions of existing file to temp file
+ return opened;
+}
+
+bool KDSaveFile::atEnd() {
+ return d->tmpFile ? d->tmpFile->atEnd() : QIODevice::atEnd();
+}
+
+qint64 KDSaveFile::bytesAvailable() const {
+ return d->tmpFile ? d->tmpFile->bytesAvailable() : QIODevice::bytesAvailable();
+}
+
+qint64 KDSaveFile::bytesToWrite() const {
+ return d->tmpFile ? d->tmpFile->bytesToWrite() : QIODevice::bytesToWrite();
+}
+
+bool KDSaveFile::canReadLine() const {
+ return d->tmpFile ? d->tmpFile->canReadLine() : QIODevice::canReadLine();
+}
+
+bool KDSaveFile::isSequential() const {
+ return d->tmpFile ? d->tmpFile->isSequential() : QIODevice::isSequential();
+}
+
+qint64 KDSaveFile::pos() const {
+ return d->tmpFile ? d->tmpFile->pos() : QIODevice::pos();
+}
+
+bool KDSaveFile::reset() {
+ return d->tmpFile ? d->tmpFile->reset() : QIODevice::reset();
+}
+
+bool KDSaveFile::seek( qint64 pos ) {
+ const bool ret = d->tmpFile ? d->tmpFile->seek( pos ) : QIODevice::seek( pos );
+ if ( !ret )
+ d->propagateErrors();
+ return ret;
+}
+
+qint64 KDSaveFile::size() const {
+ return d->tmpFile ? d->tmpFile->size() : QIODevice::size();
+}
+
+bool KDSaveFile::waitForBytesWritten( int msecs ) {
+ return d->tmpFile ? d->tmpFile->waitForBytesWritten( msecs ) : QIODevice::waitForBytesWritten( msecs );
+}
+
+bool KDSaveFile::waitForReadyRead( int msecs ) {
+ return d->tmpFile ? d->tmpFile->waitForReadyRead( msecs ) : QIODevice::waitForReadyRead( msecs );
+}
+
+bool KDSaveFile::commit( KDSaveFile::CommitMode mode ) {
+ if ( !d->tmpFile )
+ return false;
+ const QString tmpfname = d->tmpFile->fileName();
+ d->tmpFile->flush();
+ delete d->tmpFile;
+ QFile orig( d->filename );
+ QString backup;
+ if ( orig.exists() ) {
+ backup = d->generateBackupName();
+ if ( !orig.rename( backup ) ) {
+ setErrorString( tr("Could not backup existing file %1: %2").arg( d->filename, orig.errorString() ) );
+ QFile tmp( tmpfname );
+ if ( !tmp.remove() ) // TODO how to report this error?
+ qWarning() << "Could not remove temp file" << tmpfname << tmp.errorString();
+ if ( mode != OverwriteExistingFile )
+ return false;
+ }
+ }
+ QFile target( tmpfname );
+ if ( !target.rename( d->filename ) ) {
+ setErrorString( target.errorString() );
+ return false;
+ }
+ if ( mode == OverwriteExistingFile ) {
+ QFile tmp( backup );
+ const bool removed = !tmp.exists() || tmp.remove( backup );
+ if ( !removed )
+ qWarning() << "Could not remove the backup: " << tmp.errorString();
+ }
+
+ return true;
+}
+
+QString KDSaveFile::fileName() const {
+ return d->filename;
+}
+
+void KDSaveFile::setFileName( const QString& filename ) {
+ const QString fn = makeAbsolute( filename );
+ if ( fn == d->filename )
+ return;
+ close();
+ delete d->tmpFile;
+ d->filename = fn;
+}
+
+qint64 KDSaveFile::readData( char* data, qint64 maxSize ) {
+ if ( !d->tmpFile ) {
+ setErrorString( tr("TODO") );
+ return -1;
+ }
+ const qint64 ret = d->tmpFile->read( data, maxSize );
+ d->propagateErrors();
+ return ret;
+}
+
+qint64 KDSaveFile::readLineData( char* data, qint64 maxSize ) {
+ if ( !d->tmpFile ) {
+ setErrorString( tr("TODO") );
+ return -1;
+ }
+ const qint64 ret = d->tmpFile->readLine( data, maxSize );
+ d->propagateErrors();
+ return ret;
+}
+
+qint64 KDSaveFile::writeData( const char* data, qint64 maxSize ) {
+ if ( !d->tmpFile ) {
+ setErrorString( tr("TODO") );
+ return -1;
+ }
+ const qint64 ret = d->tmpFile->write( data, maxSize );
+ d->propagateErrors();
+ return ret;
+}
+
+bool KDSaveFile::flush() {
+ return d->tmpFile ? d->tmpFile->flush() : false;
+}
+
+bool KDSaveFile::resize( qint64 sz ) {
+ return d->tmpFile ? d->tmpFile->resize( sz ) : false;
+}
+
+int KDSaveFile::handle() const {
+ return d->tmpFile ? d->tmpFile->handle() : -1;
+}
+
+QFile::Permissions KDSaveFile::permissions() const {
+ return d->tmpFile ? d->tmpFile->permissions() : d->permissions;
+}
+
+bool KDSaveFile::setPermissions( QFile::Permissions p ) {
+ d->permissions = p;
+ if ( d->tmpFile )
+ return d->tmpFile->setPermissions( p );
+ return false;
+}
+
+void KDSaveFile::setBackupExtension( const QString& ext ) {
+ d->backupExtension = ext;
+}
+
+QString KDSaveFile::backupExtension() const {
+ return d->backupExtension;
+}
+
+/**
+ * TODO
+ *
+ *
+ */
+
+#ifdef KDTOOLSCORE_UNITTESTS
+
+#include <KDUnitTest/Test>
+
+KDAB_UNITTEST_SIMPLE( KDSaveFile, "kdcoretools" ) {
+ //TODO test contents (needs blocking and checked write() )
+ {
+ const QString testfile1 = QLatin1String("kdsavefile-test1");
+ QByteArray testData("lalalala");
+ KDSaveFile saveFile( testfile1 );
+ assertTrue( saveFile.open( QIODevice::WriteOnly ) );
+ saveFile.write( testData.constData(), testData.size() );
+ assertTrue( saveFile.commit() );
+ assertTrue( QFile::exists( testfile1 ) );
+ assertTrue( QFile::remove( testfile1 ) );
+ }
+ {
+ const QString testfile1 = QLatin1String("kdsavefile-test1");
+ QByteArray testData("lalalala");
+ KDSaveFile saveFile( testfile1 );
+ assertTrue( saveFile.open( QIODevice::WriteOnly ) );
+ saveFile.write( testData.constData(), testData.size() );
+ saveFile.close();
+ assertFalse( QFile::exists( testfile1 ) );
+ }
+ {
+ const QString testfile1 = QLatin1String("kdsavefile-test1");
+ QByteArray testData("lalalala");
+ KDSaveFile saveFile( testfile1 );
+ assertTrue( saveFile.open( QIODevice::WriteOnly ) );
+ saveFile.write( testData.constData(), testData.size() );
+ assertTrue( saveFile.commit() );
+ assertTrue( QFile::exists( testfile1 ) );
+
+ KDSaveFile sf2( testfile1 );
+ sf2.setBackupExtension( QLatin1String(".bak") );
+ assertTrue( sf2.open( QIODevice::WriteOnly ) );
+ sf2.write( testData.constData(), testData.size() );
+ sf2.commit(); //commit in backup mode (default)
+ const QString backup = testfile1 + sf2.backupExtension();
+ assertTrue( QFile::exists( backup ) );
+ assertTrue( QFile::remove( backup ) );
+
+ KDSaveFile sf3( testfile1 );
+ sf3.setBackupExtension( QLatin1String(".bak") );
+ assertTrue( sf3.open( QIODevice::WriteOnly ) );
+ sf3.write( testData.constData(), testData.size() );
+ sf3.commit( KDSaveFile::OverwriteExistingFile );
+ const QString backup2 = testfile1 + sf3.backupExtension();
+ assertFalse( QFile::exists( backup2 ) );
+
+ assertTrue( QFile::remove( testfile1 ) );
+ }
+ {
+ const QString testfile1 = QLatin1String("kdsavefile-test1");
+ KDSaveFile sf( testfile1 );
+ assertFalse( sf.open( QIODevice::ReadOnly ) );
+ assertFalse( sf.open( QIODevice::WriteOnly|QIODevice::Append ) );
+ assertTrue( sf.open( QIODevice::ReadWrite ) );
+ }
+}
+
+#endif // KDTOOLSCORE_UNITTESTS
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.h
new file mode 100644
index 000000000..94170608c
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsavefile.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLSCORE_KDSAVEFILE_H__
+#define __KDTOOLSCORE_KDSAVEFILE_H__
+
+#include <KDToolsCore/kdtoolsglobal.h>
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include <QtCore/QIODevice>
+#include <QtCore/QFile>
+#include <QtCore/QString>
+
+class KDTOOLSCORE_EXPORT KDSaveFile : public QIODevice {
+ Q_OBJECT
+public:
+ explicit KDSaveFile( const QString& filename=QString(), QObject* parent=0 );
+ ~KDSaveFile();
+
+ enum CommitMode {
+ BackupExistingFile=0x1,
+ OverwriteExistingFile=0x2
+ };
+
+ bool commit( CommitMode=BackupExistingFile );
+
+ QString fileName() const;
+ void setFileName( const QString& filename );
+
+ QFile::Permissions permissions() const;
+ bool setPermissions( QFile::Permissions );
+
+ QString backupExtension() const;
+ void setBackupExtension( const QString& extension );
+
+ bool flush();
+ bool resize( qint64 sz );
+ int handle() const;
+
+ /* reimp */ bool atEnd();
+ /* reimp */ qint64 bytesAvailable() const;
+ /* reimp */ qint64 bytesToWrite() const;
+ /* reimp */ bool canReadLine() const;
+ /* reimp */ void close();
+ /* reimp */ bool isSequential() const;
+ /* reimp */ bool open( OpenMode mode=QIODevice::ReadWrite ); //only valid: WriteOnly, ReadWrite
+ /* reimp */ qint64 pos() const;
+ /* reimp */ bool reset();
+ /* reimp */ bool seek( qint64 pos );
+ /* reimp */ qint64 size() const;
+ /* reimp */ bool waitForBytesWritten( int msecs );
+ /* reimp */ bool waitForReadyRead( int msecs );
+
+private:
+ /* reimp */ qint64 readData( char* data, qint64 maxSize );
+ /* reimp */ qint64 readLineData( char* data, qint64 maxSize );
+ /* reimp */ qint64 writeData( const char* data, qint64 maxSize );
+
+private:
+ class Private;
+ kdtools::pimpl_ptr<Private> d;
+};
+
+#endif // __KDTOOLSCORE_KDSAVEFILE_H__
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.cpp
new file mode 100644
index 000000000..fcd66f238
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdselfrestarter.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QProcess>
+
+class KDSelfRestarter::Private {
+public:
+ Private( int argc, char** argv ) : restartOnQuit( false ) {
+ executable = QString::fromLocal8Bit( argv[0] );
+ workingPath = QDir::currentPath();
+ for ( int i = 1; i < argc; ++i )
+ args << QString::fromLocal8Bit( argv[i] );
+ }
+
+ Private()
+ {
+ executable = qApp->applicationFilePath();
+ workingPath = QDir::currentPath();
+ args = qApp->arguments().mid( 1 );
+ }
+
+ ~Private() {
+ if ( restartOnQuit )
+ QProcess::startDetached( executable, args, workingPath );
+ }
+
+ QString executable;
+ QStringList args;
+ bool restartOnQuit;
+ QString workingPath;
+ static KDSelfRestarter* instance;
+};
+
+KDSelfRestarter* KDSelfRestarter::Private::instance = 0;
+
+KDSelfRestarter::KDSelfRestarter( int argc, char** argv ) : d( new Private( argc, argv ) ) {
+ Q_ASSERT_X( !Private::instance, Q_FUNC_INFO, "Cannot create more than one KDSelfRestarter instance" );
+ Private::instance = this;
+}
+
+KDSelfRestarter::~KDSelfRestarter()
+{
+ Q_ASSERT_X( Private::instance == this, Q_FUNC_INFO, "Cannot create more than one KDSelfRestarter instance" );
+ Private::instance = 0;
+}
+
+void KDSelfRestarter::setRestartOnQuit( bool restart ) {
+ Q_ASSERT_X( Private::instance, Q_FUNC_INFO, "KDSelfRestarter instance must be created in main()" );
+ if ( Private::instance )
+ Private::instance->d->restartOnQuit = restart;
+}
+
+bool KDSelfRestarter::restartOnQuit() {
+ return Private::instance ? Private::instance->d->restartOnQuit : false;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.h
new file mode 100644
index 000000000..0582c778d
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdselfrestarter.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLSCORE_KDSELFRESTARTER_H__
+#define __KDTOOLSCORE_KDSELFRESTARTER_H__
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+class KDTOOLSCORE_EXPORT KDSelfRestarter {
+public:
+ KDSelfRestarter( int argc, char** argv );
+ ~KDSelfRestarter();
+
+ static bool restartOnQuit();
+ static void setRestartOnQuit( bool restart );
+
+private:
+ Q_DISABLE_COPY(KDSelfRestarter);
+ class Private;
+ kdtools::pimpl_ptr<Private> d;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.cpp
new file mode 100644
index 000000000..e694d79fa
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdsysinfo.h"
+
+#include <algorithm>
+
+KDSysInfo::KDSysInfo()
+{
+}
+
+KDSysInfo::~KDSysInfo()
+{
+}
+
+#include <QDir>
+#include <QDebug>
+
+QDebug operator<<( QDebug dbg, KDSysInfo::OperatingSystemType type )
+{
+ switch( type )
+ {
+ case KDSysInfo::Linux:
+ return dbg << "Linux";
+ case KDSysInfo::MacOSX:
+ return dbg << "Mac OS X";
+ case KDSysInfo::Windows:
+ return dbg << "Windows";
+ default:
+ return dbg << "<unknown>";
+ }
+}
+
+QDebug operator<<( QDebug dbg, KDSysInfo::ArchitectureType type )
+{
+ switch( type )
+ {
+ case KDSysInfo::ARM:
+ return dbg << "ARM";
+ case KDSysInfo::Intel:
+ return dbg << "Intel";
+ case KDSysInfo::AMD64:
+ return dbg << "AMD64";
+ case KDSysInfo::IA64:
+ return dbg << "IA64";
+ case KDSysInfo::PowerPC:
+ return dbg << "Power PC";
+ case KDSysInfo::Motorola68k:
+ return dbg << "Motorola 68k";
+ default:
+ return dbg << "<unknown>";
+ }
+}
+
+QDebug operator<<( QDebug dbg, KDSysInfo::Volume volume )
+{
+ return dbg << "KDSysInfo::Volume(" << volume.path() << ")";
+}
+
+QPair< KDByteSize, KDByteSize > volumeSpace( const QString& volume );
+QString volumeName( const QString& volume );
+
+class KDSysInfo::Volume::Private : public QSharedData
+{
+public:
+ QString p;
+ QString name;
+ KDByteSize size;
+ KDByteSize availableSpace;
+};
+
+
+KDSysInfo::Volume::Volume()
+ : d( new Private )
+{
+}
+
+KDSysInfo::Volume::Volume( const Volume& other )
+ : d( other.d )
+{
+}
+
+KDSysInfo::Volume::~Volume()
+{
+}
+
+void KDSysInfo::Volume::swap( KDSysInfo::Volume& other )
+{
+ std::swap( d, other.d );
+}
+
+KDSysInfo::Volume& KDSysInfo::Volume::operator=( const KDSysInfo::Volume& other )
+{
+ KDSysInfo::Volume tmp( other );
+ swap( tmp );
+ return *this;
+}
+
+void KDSysInfo::Volume::setPath( const QString& path )
+{
+ d->p = path;
+}
+
+bool KDSysInfo::Volume::operator == ( const Volume& other ) const
+{
+ return d->name == other.d->name && d->p == other.d->p;
+}
+
+void KDSysInfo::Volume::setName( const QString& name )
+{
+ d->name = name;
+}
+
+QString KDSysInfo::Volume::name() const
+{
+ return d->name;
+}
+
+QString KDSysInfo::Volume::path() const
+{
+ return d->p;
+}
+
+KDByteSize KDSysInfo::Volume::size() const
+{
+ return d->size;
+}
+
+void KDSysInfo::Volume::setSize( const KDByteSize& size )
+{
+ d->size = size;
+}
+
+KDByteSize KDSysInfo::Volume::availableSpace() const
+{
+ return d->availableSpace;
+}
+
+void KDSysInfo::Volume::setAvailableSpace( const KDByteSize& available )
+{
+ d->availableSpace = available;
+}
+
+struct PathLongerThan
+{
+ bool operator()( const KDSysInfo::Volume& lhs, const KDSysInfo::Volume& rhs ) const
+ {
+ return lhs.path().length() > rhs.path().length();
+ }
+};
+
+KDSysInfo::Volume KDSysInfo::Volume::fromPath( const QString& path )
+{
+ QList< KDSysInfo::Volume > volumes = mountedVolumes();
+ // sort by length to get the longest mount point (not just "/") first
+ std::sort( volumes.begin(), volumes.end(), PathLongerThan() );
+ for( QList< KDSysInfo::Volume >::const_iterator it = volumes.constBegin(); it != volumes.constEnd(); ++it )
+ {
+#ifdef Q_WS_WIN
+ if( QDir::toNativeSeparators( path ).toLower().startsWith( it->path().toLower() ) )
+#else
+ if( path.startsWith( it->path() ) )
+#endif
+ return *it;
+ }
+ return KDSysInfo::Volume();
+}
+
+QDebug operator<<( QDebug dbg, KDSysInfo::ProcessInfo process )
+{
+ return dbg << "KDSysInfo::ProcessInfo(" << process.id << ", " << process.name << ")";
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.h
new file mode 100644
index 000000000..2324ccfc8
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KDSYSINFO_H
+#define KDSYSINFO_H
+
+#include <KDToolsCore/kdtoolsglobal.h>
+
+#include <QtCore/QString>
+#include <QtCore/QSysInfo>
+#include <QtCore/QSharedDataPointer>
+
+#include "kdbytesize.h"
+
+class KDVersion;
+
+class KDTOOLSCORE_EXPORT KDSysInfo : public QSysInfo
+{
+private:
+ KDSysInfo();
+
+public:
+ ~KDSysInfo();
+
+ enum OperatingSystemType
+ {
+ UnknownOperatingSystem = -1,
+ Linux,
+ MacOSX,
+ Windows
+ };
+
+ enum ArchitectureType
+ {
+ UnknownArchitecture = -1,
+ ARM,
+ Intel,
+ AMD64,
+ IA64,
+ PowerPC,
+ Motorola68k
+ };
+
+ class KDTOOLSCORE_EXPORT Volume
+ {
+ friend class ::KDSysInfo;
+ public:
+ static Volume fromPath( const QString& path );
+
+ Volume();
+ Volume( const Volume& other );
+ ~Volume();
+
+ QString name() const;
+ QString path() const;
+ KDByteSize size() const;
+ KDByteSize availableSpace() const;
+
+ void swap( Volume& other );
+ Volume& operator=( const Volume& other );
+ bool operator == ( const Volume& other ) const;
+
+ private:
+ void setPath( const QString& path );
+ void setName( const QString& name );
+ void setSize( const KDByteSize& size );
+ void setAvailableSpace( const KDByteSize& available );
+
+ private:
+ class Private;
+ QSharedDataPointer<Private> d;
+ };
+
+ struct ProcessInfo
+ {
+ quint32 id;
+ QString name;
+ };
+
+ static OperatingSystemType osType();
+ static KDVersion osVersion();
+ static QString osDescription();
+ static ArchitectureType architecture();
+
+ static KDByteSize installedMemory();
+ static QList< Volume > mountedVolumes();
+ static QList< ProcessInfo > runningProcesses();
+};
+
+class QDebug;
+
+QDebug operator<<( QDebug dbg, KDSysInfo::OperatingSystemType type );
+QDebug operator<<( QDebug dbg, KDSysInfo::ArchitectureType type );
+QDebug operator<<( QDebug dbg, KDSysInfo::Volume volume );
+QDebug operator<<( QDebug dbg, KDSysInfo::ProcessInfo process );
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_mac.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_mac.cpp
new file mode 100644
index 000000000..024d1dd4d
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_mac.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdsysinfo.h"
+
+#include "kdbytesize.h"
+#include "kdversion.h"
+
+#include <Carbon/Carbon.h>
+
+static QString qt_mac_hfsunistr_to_qstring( const HFSUniStr255* hfs )
+{
+ const QChar* const charPointer = reinterpret_cast< const QChar* >( hfs->unicode );
+ return QString( charPointer, hfs->length );
+}
+
+KDSysInfo::OperatingSystemType KDSysInfo::osType()
+{
+ return MacOSX;
+}
+
+KDVersion KDSysInfo::osVersion()
+{
+ SInt32 major = 0;
+ SInt32 minor = 0;
+ SInt32 bugfix = 0;
+ Gestalt( gestaltSystemVersionMajor, &major );
+ Gestalt( gestaltSystemVersionMinor, &minor );
+ Gestalt( gestaltSystemVersionBugFix, &bugfix );
+
+ QStringList result;
+ result << QString::number( major );
+ result << QString::number( minor );
+ result << QString::number( bugfix );
+
+ return KDVersion::fromString( result.join( QChar::fromLatin1( '.' ) ) );
+}
+
+QString KDSysInfo::osDescription()
+{
+ return QObject::tr( "Mac OS X Version %1" ).arg( osVersion().toString() );
+}
+
+KDByteSize KDSysInfo::installedMemory()
+{
+ SInt32 mb = 0;
+ Gestalt( gestaltPhysicalRAMSizeInMegabytes, &mb );
+ return KDByteSize( static_cast< quint64 >( mb ) * 1024LL * 1024LL );
+}
+
+KDSysInfo::ArchitectureType KDSysInfo::architecture()
+{
+ SInt32 arch = 0;
+ Gestalt( gestaltSysArchitecture, &arch );
+ switch( arch )
+ {
+ case gestalt68k:
+ return Motorola68k;
+ case gestaltPowerPC:
+ return PowerPC;
+ case gestaltIntel:
+ return Intel;
+ default:
+ return UnknownArchitecture;
+ }
+}
+
+QList< KDSysInfo::Volume > KDSysInfo::mountedVolumes()
+{
+ QList< KDSysInfo::Volume > result;
+ FSVolumeRefNum volume;
+ FSVolumeInfo info;
+ HFSUniStr255 volName;
+ FSRef ref;
+ int i = 0;
+
+ while( FSGetVolumeInfo( kFSInvalidVolumeRefNum, ++i, &volume, kFSVolInfoFSInfo, &info, &volName, &ref ) == 0 )
+ {
+ UInt8 path[ PATH_MAX + 1 ];
+ if( FSRefMakePath( &ref, path, PATH_MAX ) == 0 )
+ {
+ const QString name = qt_mac_hfsunistr_to_qstring( &volName );
+ const QString mount = QString::fromLocal8Bit( reinterpret_cast< char* >( path ) );
+ FSGetVolumeInfo( volume, 0, 0, kFSVolInfoSizes, &info, 0, 0 );
+ Volume v;
+ v.setName( name );
+ v.setPath( mount );
+ v.setSize( KDByteSize( info.totalBytes ) );
+ v.setAvailableSpace( KDByteSize( info.freeBytes ) );
+ result.push_back( v );
+ }
+ }
+
+ return result;
+}
+
+QList< KDSysInfo::ProcessInfo > KDSysInfo::runningProcesses()
+{
+ return QList< KDSysInfo::ProcessInfo >();
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_win.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_win.cpp
new file mode 100644
index 000000000..3456b89cb
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_win.cpp
@@ -0,0 +1,323 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdsysinfo.h"
+
+#include "kdbytesize.h"
+#include "kdversion.h"
+
+#include <windows.h>
+#include <Tlhelp32.h>
+#include <Psapi.h>
+
+#include <QDir>
+#include <QPair>
+
+#include <QtCore/QLibrary>
+
+#define KDSYSINFO_PROCESS_QUERY_LIMITED_INFORMATION (0x1000)
+
+KDSysInfo::OperatingSystemType KDSysInfo::osType()
+{
+ return Windows;
+}
+
+KDVersion KDSysInfo::osVersion()
+{
+ OSVERSIONINFO info;
+ memset( &info, 0, sizeof( info ) );
+ info.dwOSVersionInfoSize = sizeof( info );
+ GetVersionEx( &info );
+ return KDVersion::fromString( QString::fromLatin1( "%1.%2" ).arg( info.dwMajorVersion ).arg( info.dwMinorVersion ) );
+}
+
+QString KDSysInfo::osDescription()
+{
+ switch( QSysInfo::windowsVersion() )
+ {
+ case QSysInfo::WV_32s:
+ return QObject::tr( "Windows 3.1" );
+ case QSysInfo::WV_95:
+ return QObject::tr( "Windows 95" );
+ case QSysInfo::WV_98:
+ return QObject::tr( "Windows 98" );
+ case QSysInfo::WV_Me:
+ return QObject::tr( "Windows ME" );
+ case QSysInfo::WV_NT:
+ return QObject::tr( "Windows NT" );
+ case QSysInfo::WV_2000:
+ return QObject::tr( "Windows 2000" );
+ case QSysInfo::WV_XP:
+ return QObject::tr( "Windows XP" );
+ case QSysInfo::WV_2003:
+ return QObject::tr( "Windows 2003" );
+ case QSysInfo::WV_VISTA:
+ return QObject::tr( "Windows Vista" );
+ case QSysInfo::WV_WINDOWS7:
+ return QObject::tr( "Windows 7" );
+ case QSysInfo::WV_CE:
+ return QObject::tr( "Windows CE" );
+ case QSysInfo::WV_CENET:
+ return QObject::tr( "Windows CE .NET" );
+ case QSysInfo::WV_CE_5:
+ return QObject::tr( "Windows CE 5" );
+ case QSysInfo::WV_CE_6:
+ return QObject::tr( "Windows CE 6" );
+ default:
+ return QObject::tr( "Windows" );
+ }
+}
+
+KDByteSize KDSysInfo::installedMemory()
+{
+ MEMORYSTATUSEX status;
+ status.dwLength = sizeof( status );
+ GlobalMemoryStatusEx( &status );
+ return KDByteSize( status.ullTotalPhys );
+}
+
+KDSysInfo::ArchitectureType KDSysInfo::architecture()
+{
+#if defined( _M_X64 )
+ return AMD64;
+#elif defined( _M_IX86 )
+ return Intel;
+#elif defined( _M_IA64 )
+ return IA64;
+#elif defined( _M_PPC )
+ return PowerPC;
+#elif defined( _M_ARM )
+ return ARM;
+#else
+ return UnknownArchitecture;
+#endif
+}
+
+QPair< KDByteSize, KDByteSize > volumeSpace( const QString& volume )
+{
+ QPair< KDByteSize, KDByteSize > result;
+ ULARGE_INTEGER bytes;
+ ULARGE_INTEGER freebytes;
+ if( GetDiskFreeSpaceExA( qPrintable( volume ), 0, &bytes, &freebytes ) != 0 )
+ {
+ result.first = KDByteSize( bytes.QuadPart );
+ result.second = KDByteSize( freebytes.QuadPart );
+ }
+ return result;
+}
+
+QString volumeName( const QString& volume )
+{
+ char name[ MAX_PATH + 1 ] = "";
+ DWORD dummy;
+ char dummy2[ MAX_PATH + 1 ] = "";
+ GetVolumeInformationA( qPrintable( volume ), name, MAX_PATH + 1, &dummy, &dummy, &dummy, dummy2, MAX_PATH + 1 );
+ QString vName = QString::fromLatin1( name );
+ if( vName.isEmpty() )
+ {
+ const uint driveType = GetDriveTypeA( qPrintable( volume ) );
+ switch( driveType )
+ {
+ case DRIVE_REMOVABLE:
+ vName = QObject::tr( "Removable Disk" );
+ break;
+ case DRIVE_CDROM:
+ vName = QObject::tr( "CD Drive" );
+ break;
+ case DRIVE_FIXED:
+ vName = QObject::tr( "Local Disk" );
+ break;
+ default:
+ return volume.left( 2 );
+ }
+ }
+ return QString::fromLatin1( "%2 (%1)" ).arg( volume.left( 2 ), vName );
+}
+
+QList< KDSysInfo::Volume > KDSysInfo::mountedVolumes()
+{
+ QList< Volume > result;
+ const QFileInfoList drives = QDir::drives();
+ for( QFileInfoList::const_iterator it = drives.constBegin(); it != drives.constEnd(); ++it )
+ {
+ Volume volume;
+ const QString path = QDir::toNativeSeparators( it->path() );
+ volume.setPath( path );
+ volume.setName( volumeName( path ) );
+ const QPair< KDByteSize, KDByteSize > sizes = volumeSpace( path );
+ volume.setSize( sizes.first );
+ volume.setAvailableSpace( sizes.second );
+ result.push_back( volume );
+ }
+ return result;
+}
+
+struct EnumWindowsProcParam
+{
+ QList< KDSysInfo::ProcessInfo > processes;
+ QList< quint32 > seenIDs;
+};
+
+//BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam )
+//{
+// EnumWindowsProcParam* const list = reinterpret_cast< EnumWindowsProcParam* >( lParam );
+
+// KDSysInfo::ProcessInfo info;
+
+// // process id
+// DWORD procID = 0;
+// GetWindowThreadProcessId( hWnd, &procID );
+// info.id = procID;
+
+// if( list->seenIDs.contains( info.id ) )
+// return TRUE;
+// list->seenIDs.push_back( info.id );
+
+// HINSTANCE inst = (HINSTANCE)GetWindowLongA( hWnd, GWL_HINSTANCE );
+// // process name
+// HANDLE process = OpenProcess( PROCESS_ALL_ACCESS, FALSE, procID );
+
+// static char buffer[ 1024 ];
+// if( GetModuleFileNameExA( process, inst, buffer, sizeof( buffer ) ) )
+// info.name = QString::fromLocal8Bit( buffer );
+// CloseHandle( process );
+
+// list->processes.push_back( info );
+// return TRUE;
+//}
+
+//QList< KDSysInfo::ProcessInfo > KDSysInfo::runningProcesses()
+//{
+// EnumWindowsProcParam param;
+// HANDLE snapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
+// if ( !snapshot )
+// return param.processes;
+// PROCESSENTRY32 processStruct;
+// processStruct.dwSize = sizeof( PROCESSENTRY32 );
+// bool foundProcess = Process32First( snapshot, &processStruct );
+// while ( foundProcess )
+// {
+// //const QString executableName = QString::fromWCharArray( processStruct.szExeFile );
+// KDSysInfo::ProcessInfo info;
+// HANDLE procHandle = OpenProcess( PROCESS_QUERY_LIMITED_INFORMATION, false, processStruct.th32ProcessID );
+// char buffer[ 1024 ];
+// DWORD bufferSize = 1024;
+// const bool succ = QueryFullProcessImageNameA( procHandle, 0, buffer, &bufferSize );
+// if ( succ )
+// {
+// const QString executablepath = QString::fromLatin1( buffer );
+// const quint32 pid = processStruct.th32ProcessID;
+// param.seenIDs.append( pid );
+
+// info.id = pid;
+// info.name = executablepath;
+// param.processes.append( info );
+// }
+// CloseHandle( procHandle );
+
+// foundProcess = Process32Next( snapshot, &processStruct );
+// }
+// if ( snapshot )
+// CloseHandle( snapshot );
+//// EnumDesktopWindows( 0, &EnumWindowsProc, reinterpret_cast< LPARAM >( &param ) );
+// return param.processes;
+//}
+typedef BOOL ( WINAPI *QueryFullProcessImageNamePtr )( HANDLE, DWORD, char*, PDWORD );
+typedef DWORD ( WINAPI *GetProcessImageFileNamePtr )( HANDLE, char*, DWORD );
+QList< KDSysInfo::ProcessInfo > KDSysInfo::runningProcesses()
+{
+ EnumWindowsProcParam param;
+ HANDLE snapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
+ if ( !snapshot )
+ return param.processes;
+ PROCESSENTRY32 processStruct;
+ processStruct.dwSize = sizeof( PROCESSENTRY32 );
+ bool foundProcess = Process32First( snapshot, &processStruct );
+ const DWORD bufferSize = 1024;
+ char driveBuffer[ bufferSize ];
+ QStringList deviceList;
+ if ( QSysInfo::windowsVersion() <= QSysInfo::WV_5_2 )
+ {
+ DWORD size = GetLogicalDriveStringsA( bufferSize, driveBuffer );
+ deviceList = QString::fromLatin1( driveBuffer, size ).split( QLatin1Char( (char)0 ), QString::SkipEmptyParts );
+ }
+
+ QLibrary kernel32( QLatin1String( "Kernel32.dll" ) );
+ kernel32.load();
+ void* pQueryFullProcessImageNameA = kernel32.resolve( "QueryFullProcessImageNameA" );
+
+ QLibrary psapi( QLatin1String ( "Psapi.dll" ) );
+ psapi.load();
+ void* pGetProcessImageFileNamePtr = psapi.resolve( "GetProcessImageFileNameA" );
+ QueryFullProcessImageNamePtr callPtr = ( QueryFullProcessImageNamePtr ) pQueryFullProcessImageNameA;
+ GetProcessImageFileNamePtr callPtrXp = ( GetProcessImageFileNamePtr ) pGetProcessImageFileNamePtr;
+ while ( foundProcess )
+ {
+ HANDLE procHandle = OpenProcess( QSysInfo::windowsVersion() > QSysInfo::WV_5_2 ?
+ KDSYSINFO_PROCESS_QUERY_LIMITED_INFORMATION :
+ PROCESS_QUERY_INFORMATION
+ , false,
+ processStruct.th32ProcessID );
+
+ char buffer[ 1024 ];
+ DWORD bufferSize = 1024;
+ bool succ = false;
+ QString whichFailed;
+ QString executablePath;
+ KDSysInfo::ProcessInfo info;
+ if ( QSysInfo::windowsVersion() > QSysInfo::WV_5_2 )
+ {
+ succ = callPtr( procHandle, 0, buffer, &bufferSize );
+ executablePath = QString::fromLatin1( buffer );
+ }
+ else
+ {
+ if (pGetProcessImageFileNamePtr) {
+ succ = callPtrXp( procHandle, buffer, bufferSize );
+ executablePath = QString::fromLatin1( buffer );
+ for ( int i = 0; i < deviceList.count(); ++i )
+ {
+ executablePath.replace( QString::fromLatin1( "\\Device\\HarddiskVolume%1\\" ).arg( i + 1 ), deviceList.at( i ) );
+ }
+ }
+
+ }
+ if ( succ )
+ {
+ const quint32 pid = processStruct.th32ProcessID;
+ param.seenIDs.append( pid );
+
+ info.id = pid;
+ info.name = executablePath;
+ param.processes.append( info );
+ }
+
+ CloseHandle( procHandle );
+ foundProcess = Process32Next( snapshot, &processStruct );
+
+ }
+ if ( snapshot )
+ CloseHandle( snapshot );
+
+ kernel32.unload();
+ return param.processes;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_x11.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_x11.cpp
new file mode 100644
index 000000000..a9d609d4d
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdsysinfo_x11.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdsysinfo.h"
+
+#include "kdbytesize.h"
+#include "kdversion.h"
+
+#include <sys/utsname.h>
+#include <sys/statvfs.h>
+
+#include <QtCore/QFile>
+#include <QtCore/QTextStream>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+
+KDSysInfo::OperatingSystemType KDSysInfo::osType()
+{
+#if defined( Q_OS_LINUX )
+ return Linux;
+#else
+ UnknownOperatingSystem;
+#endif
+}
+
+KDVersion KDSysInfo::osVersion()
+{
+#if defined( Q_OS_LINUX )
+ struct utsname info;
+ uname( &info );
+ QString v = QString::fromLatin1( info.release );
+ if( v.contains( QString::fromLatin1( "-" ) ) )
+ v = v.mid( 0, v.indexOf( QString::fromLatin1( "-" ) ) );
+
+ return KDVersion::fromString( v );
+#else
+ return KDVersion();
+#endif
+}
+
+QString KDSysInfo::osDescription()
+{
+#if defined( Q_OS_LINUX )
+ return QObject::tr( "Linux %1" ).arg( osVersion().toString() );
+#else
+ return QString();
+#endif
+}
+
+KDByteSize KDSysInfo::installedMemory()
+{
+#ifdef Q_OS_LINUX
+ QFile f( QLatin1String( "/proc/meminfo" ) );
+ f.open( QIODevice::ReadOnly );
+ QTextStream stream( &f );
+ while( true )
+ {
+ const QString s = stream.readLine();
+ if( !s.startsWith( QLatin1String( "MemTotal:" ) ) )
+ continue;
+ else if( s.isEmpty() )
+ return KDByteSize();
+
+ const QStringList parts = s.split( QLatin1Char( ' ' ), QString::SkipEmptyParts );
+ return KDByteSize( parts.at(1).toInt() * 1024LL );
+ }
+#else
+ quint64 physmem;
+ size_t len = sizeof physmem;
+ static int mib[2] = { CTL_HW, HW_MEMSIZE };
+ sysctl( mib, 2, &physmem, &len, 0, 0 );
+ return KDByteSize( physmem );
+#endif
+ return KDByteSize();
+}
+
+KDSysInfo::ArchitectureType KDSysInfo::architecture()
+{
+ return UnknownArchitecture;
+}
+
+QList< KDSysInfo::Volume > KDSysInfo::mountedVolumes()
+{
+ QList< Volume > result;
+
+ QFile f( QLatin1String( "/etc/mtab" ) );
+ if ( !f.open( QIODevice::ReadOnly ) ) {
+ qCritical( "%s: Could not open %s: %s", Q_FUNC_INFO, qPrintable(f.fileName()), qPrintable(f.errorString()) );
+ return QList<KDSysInfo::Volume>(); //better error-handling?
+ }
+
+ QTextStream stream( &f );
+ while( true )
+ {
+ const QString s = stream.readLine();
+ if ( s.isNull() )
+ return result;
+
+ if( !s.startsWith( QLatin1Char( '/' ) ) )
+ continue;
+
+ const QStringList parts = s.split( QLatin1Char( ' ' ), QString::SkipEmptyParts );
+
+ Volume v;
+ v.setName( parts.at( 1 ) );
+ v.setPath( parts.at( 1 ) );
+
+ struct statvfs data;
+ if( statvfs( qPrintable( v.name() ), &data ) == 0 )
+ {
+ v.setSize( KDByteSize( static_cast< quint64 >( data.f_blocks ) * data.f_bsize ) );
+ v.setAvailableSpace( KDByteSize( static_cast< quint64> ( data.f_bfree ) * data.f_bsize ) );
+ }
+
+ result.push_back( v );
+ }
+
+ return result;
+}
+
+QList< KDSysInfo::ProcessInfo > KDSysInfo::runningProcesses()
+{
+ QList< KDSysInfo::ProcessInfo > processes;
+ QDir procDir( QLatin1String( "/proc" ) );
+ const QFileInfoList procCont = procDir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable );
+ QRegExp validator( QLatin1String( "[0-9]+" ) );
+ Q_FOREACH( const QFileInfo& info, procCont )
+ {
+ if ( validator.exactMatch( info.fileName() ) )
+ {
+ const QString linkPath = QDir( info.absoluteFilePath() ).absoluteFilePath( QLatin1String( "exe" ) );
+ const QFileInfo linkInfo( linkPath );
+ if ( linkInfo.exists() )
+ {
+ KDSysInfo::ProcessInfo processInfo;
+ processInfo.name = linkInfo.symLinkTarget();
+ processInfo.id = info.fileName().toInt();
+ processes.append( processInfo );
+ }
+ }
+ }
+ return processes;
+}
+
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.cpp
new file mode 100644
index 000000000..f41d7974e
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdtoolsglobal.h"
+
+#include <QByteArray>
+
+#include <algorithm>
+
+namespace {
+ struct Version {
+ unsigned char v[3];
+ };
+
+ static inline bool operator<( const Version & lhs, const Version & rhs ) {
+ return std::lexicographical_compare( lhs.v, lhs.v + 3, rhs.v, rhs.v + 3 );
+ }
+ static inline bool operator==( const Version & lhs, const Version & rhs ) {
+ return std::equal( lhs.v, lhs.v + 3, rhs.v );
+ }
+ KDTOOLS_MAKE_RELATION_OPERATORS( Version, static inline )
+}
+
+static Version kdParseQtVersion( const char * const version ) {
+ if ( !version || qstrlen( version ) < 5 || version[1] != '.' || version[3] != '.' || ( version[5] != 0 && version[5] != '.' && version[5] != '-' ) )
+ return Version(); // parse error
+ const Version result = { { version[0] - '0', version[2] - '0', version[4] - '0' } };
+ return result;
+}
+
+bool _kdCheckQtVersion_impl( int major, int minor, int patchlevel ) {
+ static const Version actual = kdParseQtVersion( qVersion() ); // do this only once each run...
+ const Version requested = { { major, minor, patchlevel } };
+ return actual >= requested;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.h
new file mode 100644
index 000000000..3d687da39
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLS_KDTOOLSGLOBAL_H__
+#define __KDTOOLS_KDTOOLSGLOBAL_H__
+
+#include <QtCore/QtGlobal>
+
+#define KDAB_DISABLE_COPY( x ) private: x( const x & ); x & operator=( const x & )
+
+#ifdef KDTOOLS_SHARED
+# ifdef BUILD_SHARED_KDTOOLSCORE
+# define KDTOOLSCORE_EXPORT Q_DECL_EXPORT
+# else
+# define KDTOOLSCORE_EXPORT Q_DECL_IMPORT
+# endif
+# ifdef BUILD_SHARED_KDTOOLSGUI
+# define KDTOOLSGUI_EXPORT Q_DECL_EXPORT
+# else
+# define KDTOOLSGUI_EXPORT Q_DECL_IMPORT
+# endif
+# ifdef BUILD_SHARED_KDTOOLSXML
+# define KDTOOLSXML_EXPORT Q_DECL_EXPORT
+# else
+# define KDTOOLSXML_EXPORT Q_DECL_IMPORT
+# endif
+# ifdef BUILD_SHARED_KDUPDATER
+# define KDTOOLS_UPDATER_EXPORT Q_DECL_EXPORT
+# else
+# define KDTOOLS_UPDATER_EXPORT Q_DECL_IMPORT
+# endif
+#else // KDTOOLS_SHARED
+# define KDTOOLSCORE_EXPORT
+# define KDTOOLSGUI_EXPORT
+# define KDTOOLSXML_EXPORT
+# define KDTOOLS_UPDATER_EXPORT
+#endif // KDTOOLS_SHARED
+
+#define MAKEINCLUDES_EXPORT
+
+#define DOXYGEN_PROPERTY( x )
+#ifdef DOXYGEN_RUN
+# define KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( func ) operator unspecified_bool_type() const { return func; }
+# define KDAB_USING_SAFE_BOOL_OPERATOR( Class ) operator unspecified_bool_type() const;
+#else
+# define KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( func ) \
+ private: struct __safe_bool_dummy__ { void nonnull() {} }; \
+ typedef void ( __safe_bool_dummy__::*unspecified_bool_type )(); \
+ public: \
+ operator unspecified_bool_type() const { \
+ return ( func ) ? &__safe_bool_dummy__::nonnull : 0 ; \
+ }
+#define KDAB_USING_SAFE_BOOL_OPERATOR( Class ) \
+ using Class::operator Class::unspecified_bool_type;
+#endif
+
+#define KDTOOLS_MAKE_RELATION_OPERATORS( Class, linkage ) \
+ linkage bool operator>( const Class & lhs, const Class & rhs ) { \
+ return operator<( rhs, lhs ); \
+ } \
+ linkage bool operator!=( const Class & lhs, const Class & rhs ) { \
+ return !operator==( lhs, rhs ); \
+ } \
+ linkage bool operator<=( const Class & lhs, const Class & rhs ) { \
+ return !operator>( lhs, rhs ); \
+ } \
+ linkage bool operator>=( const Class & lhs, const Class & rhs ) { \
+ return !operator<( lhs, rhs ); \
+ }
+
+template <typename T>
+inline T & __kdtools__dereference_for_methodcall( T & o ) {
+ return o;
+}
+
+template <typename T>
+inline T & __kdtools__dereference_for_methodcall( T * o ) {
+ return *o;
+}
+
+#define KDAB_SET_OBJECT_NAME( x ) __kdtools__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )
+
+KDTOOLSCORE_EXPORT bool _kdCheckQtVersion_impl( int major, int minor=0, int patchlevel=0 );
+static inline bool kdCheckQtVersion( unsigned int major, unsigned int minor=0, unsigned int patchlevel=0 ) {
+ return (major<<16|minor<<8|patchlevel) <= static_cast<unsigned int>(QT_VERSION)
+ || _kdCheckQtVersion_impl( major, minor, patchlevel );
+}
+
+#define KDTOOLS_DECLARE_PRIVATE_BASE( Class ) \
+protected: \
+ class Private; \
+ Private * d_func() { return _d; } \
+ const Private * d_func() const { return _d; } \
+ Class( Private * _d_, bool b ) : _d( _d_ ) { init(b); } \
+private: \
+ void init(bool); \
+private: \
+ Private * _d
+
+#define KDTOOLS_DECLARE_PRIVATE_DERIVED( Class, Base ) \
+protected: \
+ class Private; \
+ Private * d_func() { \
+ return reinterpret_cast<Private*>( Base::d_func() ); \
+ } \
+ const Private * d_func() const { \
+ return reinterpret_cast<const Private*>( Base::d_func() ); \
+ } \
+ Class( Private * _d_, bool b ) \
+ : Base( reinterpret_cast<Base::Private*>(_d_), b ) { init(b); } \
+private: \
+ void init(bool)
+
+
+#endif /* __KDTOOLS_KDTOOLSGLOBAL_H__ */
+
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.cpp
new file mode 100644
index 000000000..53f91412f
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdversion.h"
+
+#include <QDebug>
+
+KDVersion::KDVersion()
+{
+}
+
+KDVersion::~KDVersion()
+{
+}
+
+bool KDVersion::isNull() const
+{
+ return parts.isEmpty();
+}
+
+QString KDVersion::toString() const
+{
+ return parts.join( QChar::fromLatin1( '.' ) );
+}
+
+KDVersion KDVersion::fromString( const QString& string )
+{
+ KDVersion result;
+ result.parts = string.split( QChar::fromLatin1( '.' ) );
+ return result;
+}
+
+bool operator<( const KDVersion& lhs, const KDVersion& rhs )
+{
+ for( int i = 0; i < lhs.parts.count(); ++i )
+ {
+ if( i == rhs.parts.count() )
+ return false;
+
+ const QString& l = lhs.parts[ i ];
+ const QString& r = lhs.parts[ i ];
+
+ bool okl = false;
+ bool okr = false;
+ const int li = l.toInt( &okl );
+ const int ri = r.toInt( &okr );
+
+ if( okl && okr )
+ {
+ if( li < ri )
+ return true;
+ }
+ else if( QString::localeAwareCompare( l, r ) < 0 )
+ {
+ return true;
+ }
+ }
+ return true;
+}
+
+bool operator==( const KDVersion& lhs, const KDVersion& rhs )
+{
+ return lhs.parts == rhs.parts;
+}
+
+QDebug operator<<( QDebug debug, const KDVersion& version )
+{
+ return debug << "KDVersion(" << version.toString().toLatin1().data() << ")";
+ return debug;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.h
new file mode 100644
index 000000000..b71cb1933
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdversion.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KDVERSION_H
+#define KDVERSION_H
+
+#include <KDToolsCore/kdtoolsglobal.h>
+
+#include <QtCore/QStringList>
+
+class KDTOOLSCORE_EXPORT KDVersion
+{
+ friend bool operator<( const KDVersion& lhs, const KDVersion& rhs );
+ friend bool operator==( const KDVersion& lhs, const KDVersion& rhs );
+public:
+ KDVersion();
+ virtual ~KDVersion();
+
+ bool isNull() const;
+
+ QString toString() const;
+ static KDVersion fromString( const QString& string );
+
+private:
+ QStringList parts;
+};
+
+bool operator<( const KDVersion& lhs, const KDVersion& rhs );
+bool operator==( const KDVersion& lhs, const KDVersion& rhs );
+
+QDebug operator<<( QDebug debug, const KDVersion& version );
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.cpp
new file mode 100644
index 000000000..7c0abd486
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdwatchdog.h"
+
+#include <QTimer>
+
+/*!
+ \internal
+ */
+class KDWatchdog::Private
+{
+public:
+ Private()
+ : active( true )
+ {
+ }
+
+ bool active;
+ QTimer timer;
+};
+
+/*!
+ Creates a new KDWatchdog with \a parent.
+ */
+KDWatchdog::KDWatchdog( QObject* parent )
+ : QObject( parent )
+{
+ d->timer.setSingleShot( true );
+ connect( &d->timer, SIGNAL( timeout() ), this, SIGNAL( timeout() ) );
+ setTimeoutInterval( 30000 );
+ activate();
+}
+
+/*!
+ Destroys the KDWatchdog.
+ */
+KDWatchdog::~KDWatchdog()
+{
+}
+
+bool KDWatchdog::isActive() const
+{
+ return d->active;
+}
+
+int KDWatchdog::timeoutInterval() const
+{
+ return d->timer.interval();
+}
+
+void KDWatchdog::setTimeoutInterval( int interval )
+{
+ d->timer.setInterval( interval );
+ resetTimeoutTimer();
+}
+
+void KDWatchdog::setActive( bool active )
+{
+ if( d->active == active )
+ return;
+ d->active = active;
+ if( d->active )
+ d->timer.start();
+ else
+ d->timer.stop();
+}
+
+/*!
+ Activates the watchdog.
+ */
+void KDWatchdog::activate()
+{
+ setActive( true );
+}
+
+/*!
+ Deactivates the watchdog.
+ */
+void KDWatchdog::deactivate()
+{
+ setActive( false );
+}
+
+/*!
+ Resets the watchdog timer. This slot should be called whenever
+ the watched event occures.
+ If the watchdog has been stop()'ed, nothing happens.
+ */
+void KDWatchdog::resetTimeoutTimer()
+{
+ if( d->active )
+ d->timer.start();
+}
+
+#include "moc_kdwatchdog.cpp"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.h
new file mode 100644
index 000000000..4319b0e8b
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/kdwatchdog.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLS__CORE__KDWATCHDOG_H__
+#define __KDTOOLS__CORE__KDWATCHDOG_H__
+
+#include <QtCore/QObject>
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+class KDTOOLSCORE_EXPORT KDWatchdog : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY( bool active READ isActive WRITE setActive )
+ Q_PROPERTY( int timeoutInterval READ timeoutInterval WRITE setTimeoutInterval )
+
+public:
+ explicit KDWatchdog( QObject* parent = 0 );
+ ~KDWatchdog();
+
+ bool isActive() const;
+ int timeoutInterval() const;
+
+public Q_SLOTS:
+ void setTimeoutInterval( int interval );
+
+ void setActive( bool active );
+ void activate();
+ void deactivate();
+
+ void resetTimeoutTimer();
+
+Q_SIGNALS:
+ void timeout();
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+#endif /* __KDTOOLS__CORE__KDWATCHDOG_H__ */
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr b/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr
new file mode 100644
index 000000000..aa2f3984a
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr
@@ -0,0 +1 @@
+#include "pimpl_ptr.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.cpp b/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.cpp
new file mode 100644
index 000000000..1a7f017a1
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.cpp
@@ -0,0 +1,225 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "pimpl_ptr.h"
+
+/*!
+ \class pimpl_ptr:
+ \ingroup core smartptr
+ \brief Owning pointer for private implementations
+ \since_c 2.1
+
+ (The exception safety of this class has not been evaluated yet.)
+
+ pimpl_ptr is a smart immutable pointer, which owns the contained object. Unlike other smart pointers,
+ it creates a standard constructed object when instanciated via the
+ \link pimpl_ptr() standard constructor\endlink.
+ Additionally, pimpl_ptr respects constness of the pointer object and returns \c const \c T* for
+ a const pimpl_ptr object.
+
+ The content of a pimpl_ptr cannot be changed during it's lifetime.
+
+ \section general-use General Use
+
+ The general use case of pimpl_ptr is the "Pimpl Idiom", i.e. hiding the private implementation of a class
+ from the user's compiler which see \c MyClass as
+
+ \code
+ class MyClass
+ {
+ public:
+ MyClass();
+ ~MyClass();
+
+ // public class API
+ int value() const;
+
+ private:
+ class Private; // defined later
+ kdtools::pimpl_ptr< Private > d;
+ };
+ \endcode
+
+ but not the private parts of it. These can only be seen (and accessed) by the code knowing \c MyClass::Private:
+
+ \code
+ class MyClass::Private
+ {
+ public:
+ int value;
+ };
+
+ MyClass::MyClass()
+ {
+ // d was automatically filled with new Private
+ d->value = 42;
+ }
+
+ MyClass::~MyClass()
+ {
+ // the content of d gets deleted automatically
+ }
+
+ int MyClass::value() const
+ {
+ // access the private part:
+ // since MyClass::value() is const, the returned pointee is const, too
+ return d->value;
+ }
+ \endcode
+
+*/
+
+/*!
+ \fn pimpl_ptr::pimpl_ptr()
+
+ Default constructor. Constructs a pimpl_tr that contains (owns) a standard constructed
+ instance of \c T.
+
+ \post \c *this owns a new object.
+*/
+
+/*!
+ \fn pimpl_ptr::pimpl_ptr( T * t )
+
+ Constructor. Constructs a pimpl_ptr that contains (owns) \a t.
+
+ \post get() == obj
+*/
+
+/*!
+ \fn pimpl_ptr::~pimpl_ptr()
+
+ Destructor.
+
+ \post The object previously owned by \c *this has been deleted.
+*/
+
+/*!
+ \fn const T * pimpl_ptr::get() const
+
+ \returns a const pointer to the contained (owned) object.
+ \overload
+*/
+
+/*!
+ \fn T * pimpl_ptr::get()
+
+ \returns a pointer to the contained (owned) object.
+*/
+
+/*!
+ \fn const T & pimpl_ptr::operator*() const
+
+ Dereference operator. Returns \link get() *get()\endlink.
+ \overload
+*/
+
+/*!
+ \fn T & pimpl_ptr::operator*()
+
+ Dereference operator. Returns \link get() *get()\endlink.
+*/
+
+/*!
+ \fn const T * pimpl_ptr::operator->() const
+
+ Member-by-pointer operator. Returns get().
+ \overload
+*/
+
+/*!
+ \fn T * pimpl_ptr::operator->()
+
+ Member-by-pointer operator. Returns get().
+*/
+
+#ifdef KDTOOLSCORE_UNITTESTS
+
+#include <KDUnitTest/test.h>
+
+#include <QObject>
+#include <QPointer>
+
+namespace
+{
+ struct ConstTester
+ {
+ bool isConst()
+ {
+ return false;
+ }
+
+ bool isConst() const
+ {
+ return true;
+ }
+ };
+}
+
+KDAB_UNITTEST_SIMPLE( pimpl_ptr, "kdcoretools" ) {
+
+ {
+ kdtools::pimpl_ptr< QObject > p;
+ assertNotNull( p.get() );
+ assertNull( p->parent() );
+ }
+
+
+ {
+ QPointer< QObject > o;
+ {
+ kdtools::pimpl_ptr< QObject > qobject( new QObject );
+ o = qobject.get();
+ assertEqual( o, qobject.operator->() );
+ assertEqual( o, &(qobject.operator*()) );
+ }
+ assertNull( o );
+ }
+
+ {
+ const kdtools::pimpl_ptr< QObject > qobject( new QObject );
+ const QObject* o = qobject.get();
+ assertEqual( o, qobject.operator->() );
+ assertEqual( o, &(qobject.operator*()) );
+ }
+
+ {
+ kdtools::pimpl_ptr< QObject > o1;
+ assertTrue( o1 );
+ kdtools::pimpl_ptr< QObject > o2( 0 );
+ assertFalse( o2 );
+ }
+
+ {
+ const kdtools::pimpl_ptr< ConstTester > o1;
+ kdtools::pimpl_ptr< ConstTester > o2;
+ assertTrue( o1->isConst() );
+ assertFalse( o2->isConst() );
+ assertTrue( (*o1).isConst() );
+ assertFalse( (*o2).isConst() );
+ assertTrue( o1.get()->isConst() );
+ assertFalse( o2.get()->isConst() );
+ }
+}
+
+#endif // KDTOOLSCORE_UNITTESTS
diff --git a/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.h b/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.h
new file mode 100644
index 000000000..195b967d1
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDToolsCore/pimpl_ptr.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLSCORE__PIMPL_PTR_H__
+#define __KDTOOLSCORE__PIMPL_PTR_H__
+
+#include <KDToolsCore/kdtoolsglobal.h>
+
+#ifndef DOXYGEN_RUN
+namespace kdtools {
+#endif
+
+ template <typename T>
+ class MAKEINCLUDES_EXPORT pimpl_ptr {
+ KDAB_DISABLE_COPY( pimpl_ptr );
+ T * d;
+ public:
+ pimpl_ptr() : d( new T ) {}
+ explicit pimpl_ptr( T * t ) : d( t ) {}
+ ~pimpl_ptr() { delete d; d = 0; }
+
+ T * get() { return d; }
+ const T * get() const { return d; }
+
+ T * operator->() { return get(); }
+ const T * operator->() const { return get(); }
+
+ T & operator*() { return *get(); }
+ const T & operator*() const { return *get(); }
+
+ KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( get() )
+ };
+
+ // these are not implemented, so's we can catch their use at
+ // link-time. Leaving them undeclared would open up a comparison
+ // via operator unspecified-bool-type().
+ template <typename T, typename S>
+ void operator==( const pimpl_ptr<T> &, const pimpl_ptr<S> & );
+ template <typename T, typename S>
+ void operator!=( const pimpl_ptr<T> &, const pimpl_ptr<S> & );
+
+#ifndef DOXYGEN_RUN
+} // namespace kdtools
+#endif
+
+#endif /* __KDTOOLSCORE__PIMPL_PTR_H__ */
+
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/Application b/installerbuilder/libinstaller/kdtools/KDUpdater/Application
new file mode 100644
index 000000000..7545e9447
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/Application
@@ -0,0 +1 @@
+#include "kdupdaterapplication.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloader b/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloader
new file mode 100644
index 000000000..beca4f9c1
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloader
@@ -0,0 +1 @@
+#include "kdupdaterfiledownloader.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloaderFactory b/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloaderFactory
new file mode 100644
index 000000000..65dbb7a4e
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/FileDownloaderFactory
@@ -0,0 +1 @@
+#include "kdupdaterfiledownloaderfactory.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater b/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater
new file mode 100644
index 000000000..a327ece5b
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater
@@ -0,0 +1,20 @@
+#include "kdupdater.h"
+#include "kdupdaterapplication.h"
+#include "kdupdatercrypto.h"
+#include "kdupdaterfiledownloader.h"
+#include "kdupdaterfiledownloaderfactory.h"
+#include "kdupdaterpackagesinfo.h"
+#include "kdupdaterpackagesview.h"
+#include "kdupdatersignatureverificationresult.h"
+#include "kdupdatersignatureverificationrunnable.h"
+#include "kdupdatersignatureverifier.h"
+#include "kdupdatertask.h"
+#include "kdupdaterupdate.h"
+#include "kdupdaterupdatefinder.h"
+#include "kdupdaterupdateinstaller.h"
+#include "kdupdaterupdateoperation.h"
+#include "kdupdaterupdateoperationfactory.h"
+#include "kdupdaterupdateoperations.h"
+#include "kdupdaterupdatesdialog.h"
+#include "kdupdaterupdatesourcesinfo.h"
+#include "kdupdaterupdatesourcesview.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater.pri b/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater.pri
new file mode 100644
index 000000000..d97399040
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/KDUpdater.pri
@@ -0,0 +1,73 @@
+DEPENDPATH += $$PWD
+INCLUDEPATH += $$PWD
+
+CONFIG( shared, static|shared) {
+ DEFINES += BUILD_SHARED_KDUPDATER
+}
+
+HEADERS += $$PWD/kdupdater.h \
+ $$PWD/kdupdaterapplication.h \
+ $$PWD/kdupdatercrypto.h \
+ $$PWD/kdupdaterfiledownloader.h \
+ $$PWD/kdupdaterfiledownloader_p.h \
+ $$PWD/kdupdaterfiledownloaderfactory.h \
+ $$PWD/kdupdaterpackagesinfo.h \
+ $$PWD/kdupdaterpackagesview.h \
+ $$PWD/kdupdatersignatureverificationresult.h \
+ $$PWD/kdupdatersignatureverifier.h \
+ $$PWD/kdupdaterupdate.h \
+ $$PWD/kdupdaterupdateoperation.h \
+ $$PWD/kdupdaterupdateoperationfactory.h \
+ $$PWD/kdupdaterupdateoperations.h \
+ $$PWD/kdupdaterupdatesourcesinfo.h \
+ $$PWD/kdupdatertask.h \
+ $$PWD/kdupdatersignatureverificationrunnable.h \
+ $$PWD/kdupdaterupdatefinder.h \
+ $$PWD/kdupdaterupdatesinfo_p.h \
+ $$PWD/kdupdaterupdateinstaller.h \
+ $$PWD/kdupdaterufuncompressor_p.h \
+ $$PWD/kdupdaterupdatesdialog.h \
+ $$PWD/kdupdaterupdatesourcesview.h \
+ $$PWD/kdupdaterufcompresscommon_p.h \
+ $$PWD/environment.h
+
+SOURCES += $$PWD/kdupdaterapplication.cpp \
+ $$PWD/kdupdatercrypto.cpp \
+ $$PWD/kdupdaterfiledownloader.cpp \
+ $$PWD/kdupdaterfiledownloaderfactory.cpp \
+ $$PWD/kdupdaterpackagesinfo.cpp \
+ $$PWD/kdupdaterpackagesview.cpp \
+ $$PWD/kdupdatersignatureverificationresult.cpp \
+ $$PWD/kdupdatersignatureverifier.cpp \
+ $$PWD/kdupdaterupdate.cpp \
+ $$PWD/kdupdaterupdateoperation.cpp \
+ $$PWD/kdupdaterupdateoperationfactory.cpp \
+ $$PWD/kdupdaterupdateoperations.cpp \
+ $$PWD/kdupdaterupdatesourcesinfo.cpp \
+ $$PWD/kdupdatertask.cpp \
+ $$PWD/kdupdatersignatureverificationrunnable.cpp \
+ $$PWD/kdupdaterupdatefinder.cpp \
+ $$PWD/kdupdaterupdatesinfo.cpp \
+ $$PWD/kdupdaterupdateinstaller.cpp \
+ $$PWD/kdupdaterufuncompressor.cpp \
+ $$PWD/kdupdaterupdatesdialog.cpp \
+ $$PWD/kdupdaterupdatesourcesview.cpp \
+ $$PWD/kdupdaterufcompresscommon.cpp \
+ $$PWD/environment.cpp
+
+
+
+FORMS += $$PWD/updatesdialog.ui \
+ $$PWD/addupdatesourcedialog.ui
+
+DEFINES += KDUPDATERGUITEXTBROWSER \
+ KDUPDATERVIEW=QTextBrowser
+QT += gui
+
+TRY_INCLUDEPATHS = /include /usr/include /usr/local/include $$QMAKE_INCDIR $$INCLUDEPATH
+win32:TRY_INCLUDEPATHS += $$PWD/../../3rdparty/openssl-0.9.8k/src/include
+linux-lsb-g++:TRY_INCLUDEPATHS = $$QMAKE_INCDIR $$INCLUDEPATH
+for(p, TRY_INCLUDEPATHS) {
+ pp = $$join(p, "", "", "/openssl")
+ exists($$pp):INCLUDEPATH *= $$p
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/PackagesInfo b/installerbuilder/libinstaller/kdtools/KDUpdater/PackagesInfo
new file mode 100644
index 000000000..8e709882d
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/PackagesInfo
@@ -0,0 +1 @@
+#include "kdupdaterpackagesinfo.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerificationResult b/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerificationResult
new file mode 100644
index 000000000..5a71cdfde
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerificationResult
@@ -0,0 +1 @@
+#include "kdupdatersignatureverificationresult.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerifier b/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerifier
new file mode 100644
index 000000000..3d9d7f946
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/SignatureVerifier
@@ -0,0 +1 @@
+#include "kdupdatersignatureverifier.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/Update b/installerbuilder/libinstaller/kdtools/KDUpdater/Update
new file mode 100644
index 000000000..8328b020b
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/Update
@@ -0,0 +1 @@
+#include "kdupdaterupdate.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateFinder b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateFinder
new file mode 100644
index 000000000..71666b90d
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateFinder
@@ -0,0 +1 @@
+#include "kdupdaterupdatefinder.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperation b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperation
new file mode 100644
index 000000000..fd82bafdb
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperation
@@ -0,0 +1 @@
+#include "kdupdaterupdateoperation.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperationFactory b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperationFactory
new file mode 100644
index 000000000..bd13c19c5
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateOperationFactory
@@ -0,0 +1 @@
+#include "kdupdaterupdateoperationfactory.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateSourcesInfo b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateSourcesInfo
new file mode 100644
index 000000000..b422ec594
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdateSourcesInfo
@@ -0,0 +1 @@
+#include "kdupdaterupdatesourcesinfo.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/UpdatesDialog b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdatesDialog
new file mode 100644
index 000000000..b1fbb7803
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/UpdatesDialog
@@ -0,0 +1 @@
+#include "kdupdaterupdatesdialog.h"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/addupdatesourcedialog.ui b/installerbuilder/libinstaller/kdtools/KDUpdater/addupdatesourcedialog.ui
new file mode 100644
index 000000000..c0de05109
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/addupdatesourcedialog.ui
@@ -0,0 +1,193 @@
+<ui version="4.0" >
+ <class>AddUpdateSourceDialog</class>
+ <widget class="QDialog" name="AddUpdateSourceDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>239</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Add Update Source</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <item>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>&amp;Name</string>
+ </property>
+ <property name="buddy" >
+ <cstring>txtName</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="txtName" >
+ <property name="font" >
+ <font>
+ <pointsize>10</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>&amp;Title</string>
+ </property>
+ <property name="buddy" >
+ <cstring>txtTitle</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QLineEdit" name="txtTitle" >
+ <property name="font" >
+ <font>
+ <pointsize>9</pointsize>
+ <italic>false</italic>
+ </font>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>&amp;Description</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="buddy" >
+ <cstring>txtDescription</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QTextEdit" name="txtDescription" />
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>&amp;URL</string>
+ </property>
+ <property name="buddy" >
+ <cstring>txtUrl</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QLineEdit" name="txtUrl" >
+ <property name="palette" >
+ <palette>
+ <active>
+ <colorrole role="Text" >
+ <brush brushstyle="SolidPattern" >
+ <color alpha="255" >
+ <red>0</red>
+ <green>45</green>
+ <blue>195</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="Text" >
+ <brush brushstyle="SolidPattern" >
+ <color alpha="255" >
+ <red>0</red>
+ <green>45</green>
+ <blue>195</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="Text" >
+ <brush brushstyle="SolidPattern" >
+ <color alpha="255" >
+ <red>106</red>
+ <green>104</green>
+ <blue>100</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font" >
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>AddUpdateSourceDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>257</x>
+ <y>229</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>AddUpdateSourceDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>325</x>
+ <y>229</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/environment.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/environment.cpp
new file mode 100644
index 000000000..c1ddc11f1
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/environment.cpp
@@ -0,0 +1,55 @@
+#include "environment.h"
+
+#include <QHash>
+#include <QProcess>
+#include <QProcessEnvironment>
+
+using namespace KDUpdater;
+
+class Environment::Private {
+public:
+ static Environment* s_instance;
+ QHash<QString, QString> tempValues;
+};
+
+Environment* Environment::Private::s_instance = 0;
+
+Environment::Environment()
+ : d( new Private )
+{
+}
+
+Environment::~Environment() {
+ delete d;
+}
+
+Environment* Environment::instance() {
+ if ( !Private::s_instance )
+ Private::s_instance = new Environment;
+ return Private::s_instance;
+}
+
+QString Environment::value( const QString& key, const QString& defvalue ) const {
+ const QHash<QString,QString>::ConstIterator it = d->tempValues.constFind( key );
+ if ( it != d->tempValues.constEnd() )
+ return *it;
+ else
+ return QProcessEnvironment::systemEnvironment().value( key, defvalue );
+}
+
+void Environment::setTemporaryValue( const QString& key, const QString& value ) {
+ d->tempValues.insert( key, value );
+}
+
+QProcessEnvironment Environment::applyTo( const QProcessEnvironment& qpe_ ) const {
+ QProcessEnvironment qpe( qpe_ );
+ QHash<QString, QString>::ConstIterator it = d->tempValues.constBegin();
+ const QHash<QString, QString>::ConstIterator end = d->tempValues.constEnd();
+ for ( ; it != end; ++it )
+ qpe.insert( it.key(), it.value() );
+ return qpe;
+}
+
+void Environment::applyTo( QProcess* proc ) {
+ proc->setProcessEnvironment( applyTo( proc->processEnvironment() ) );
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/environment.h b/installerbuilder/libinstaller/kdtools/KDUpdater/environment.h
new file mode 100644
index 000000000..001afbbc2
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/environment.h
@@ -0,0 +1,36 @@
+#ifndef LIBINSTALLER_ENVIRONMENT_H
+#define LIBINSTALLER_ENVIRONMENT_H
+
+#include "kdupdaterupdateoperation.h"
+
+#include <QString>
+
+class QProcess;
+class QProcessEnvironment;
+
+namespace KDUpdater {
+
+class KDTOOLS_UPDATER_EXPORT Environment {
+ public:
+ static Environment* instance();
+
+ ~Environment();
+
+ QString value( const QString& key, const QString& defaultValue=QString() ) const;
+ void setTemporaryValue( const QString& key, const QString& value );
+
+ QProcessEnvironment applyTo( const QProcessEnvironment& qpe ) const;
+ void applyTo( QProcess* process );
+
+ private:
+ Environment();
+
+ private:
+ Q_DISABLE_COPY(Environment)
+ class Private;
+ Private* const d;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdater.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdater.h
new file mode 100644
index 000000000..9e0007155
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdater.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_H
+#define KD_UPDATER_H
+
+#include <QtGlobal>
+
+#ifdef KDTOOLS_SHARED
+ #if defined(BUILD_SHARED_KDUPDATER)
+ #define KDTOOLS_UPDATER_EXPORT Q_DECL_EXPORT
+ #else
+ #define KDTOOLS_UPDATER_EXPORT Q_DECL_IMPORT
+ #endif
+#else
+ #define KDTOOLS_UPDATER_EXPORT
+#endif
+
+namespace KDUpdater
+{
+ enum Error
+ {
+ ENoError = 0,
+ ECannotStartTask,
+ ECannotPauseTask,
+ ECannotResumeTask,
+ ECannotStopTask,
+ EUnknown
+ };
+
+ enum UpdateType {
+ PackageUpdate = 0x1,
+ CompatUpdate = 0x2,
+ NewPackage = 0x4,
+ AllUpdate = PackageUpdate | CompatUpdate
+ };
+ Q_DECLARE_FLAGS( UpdateTypes, UpdateType )
+ Q_DECLARE_OPERATORS_FOR_FLAGS( UpdateTypes )
+
+ KDTOOLS_UPDATER_EXPORT int compareVersion(const QString& v1, const QString& v2);
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.cpp
new file mode 100644
index 000000000..cf4379c90
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.cpp
@@ -0,0 +1,324 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterapplication.h"
+#include "kdupdaterpackagesinfo.h"
+#include "kdupdatersignatureverifier.h"
+#include "kdupdaterupdatesourcesinfo.h"
+
+#include <QCoreApplication>
+#include <QDebug>
+#include <QDir>
+#include <QSettings>
+
+using namespace KDUpdater;
+
+/*!
+ \defgroup kdupdater KD Updater
+ \since_l 2.1
+
+ "KD Updater" is a library from KDAB that helps in enabling automatic updates for your applications.
+ All classes belonging to the "KD Updater" library are defined in the \ref KDUpdater namespace.
+
+ TODO: this comes from the former mainpage:
+KD Updater is a tool to automatically detect, retrieve, install and activate updates to software
+applications and libraries. It is intended to be used with Qt based applications, and developed
+against the Qt 4 series. It is a library that users link to their application. It uses only accepted
+standard protocols, and does not require any other 3rd party libraries that are not shipped with
+Qt.
+
+KD Updater is generic in that it is not developed for one specific application. The first version is
+experimental. If it proves successful and useful, it will be integrated into KDAB's KD Tools
+package. It is part of KDAB's strategy to provide functionality missing in Qt that is required for
+medium-to-large scale software systems.
+*/
+
+/*!
+ \namespace KDUpdater
+*/
+
+ConfigurationInterface::~ConfigurationInterface()
+{
+}
+
+namespace {
+ class DefaultConfigImpl : public ConfigurationInterface
+ {
+ public:
+ QVariant value( const QString& key ) const
+ {
+ QSettings settings;
+ settings.beginGroup( QLatin1String("KDUpdater") );
+ return settings.value( key );
+ }
+
+ void setValue( const QString& key, const QVariant& value )
+ {
+ QSettings settings;
+ settings.beginGroup( QLatin1String("KDUpdater") );
+ settings.setValue( key, value );
+ }
+ };
+}
+
+/*!
+ \class KDUpdater::Application kdupdaterapplication.h KDUpdaterApplication
+ \ingroup kdupdater
+ \brief This class represents an application that can be updated.
+
+ A KDUpdater application is an application that needs to interact with one or more update servers and
+ downloads/installs updates This class helps in describing an application in terms of:
+ \li application Directory
+ \li packages XML file name and its corresponding KDUpdater::PackagesInfo object
+ \li update Sources XML file name and its corresponding KDUpdater::UpdateSourcesInfo object
+
+ User can also retrieve some informations from this class:
+ \li application name
+ \li application version
+ \li compat level
+*/
+
+struct Application::ApplicationData
+{
+ explicit ApplicationData( ConfigurationInterface* config ) :
+ packagesInfo(0),
+ updateSourcesInfo(0),
+ configurationInterface( config ? config : new DefaultConfigImpl )
+ {
+ const QStringList oldFiles = configurationInterface->value( QLatin1String("FilesForDelayedDeletion") ).toStringList();
+ Q_FOREACH( const QString& i, oldFiles ) { //TODO this should happen asnyc and report errors, I guess
+ QFile f( i );
+ if ( f.exists() && !f.remove() ) {
+ qWarning( "Could not delete file %s: %s", qPrintable(i), qPrintable(f.errorString()) );
+ filesForDelayedDeletion << i; // try again next time
+ }
+ }
+ configurationInterface->setValue( QLatin1String("FilesForDelayedDeletion"), filesForDelayedDeletion );
+ }
+
+ ~ApplicationData()
+ {
+ delete packagesInfo;
+ delete updateSourcesInfo;
+ qDeleteAll( verifiers );
+ delete configurationInterface;
+ }
+
+ static Application* instance;
+
+ QString applicationDirectory;
+ PackagesInfo* packagesInfo;
+ UpdateSourcesInfo* updateSourcesInfo;
+ QMap<Application::SignatureTarget, const SignatureVerifier*> verifiers;
+ QStringList filesForDelayedDeletion;
+ ConfigurationInterface* configurationInterface;
+};
+
+Application* Application::ApplicationData::instance = 0;
+
+/*!
+ Constructor of the Application class. The class will be constructed and configured to
+ assume the application directory to be the directory in which the application exists. The
+ application name is assumed to be QCoreApplication::applicationName()
+*/
+Application::Application(ConfigurationInterface* config, QObject* p) : QObject(p)
+{
+ d = new Application::ApplicationData( config );
+ d->packagesInfo = new PackagesInfo(this);
+ d->updateSourcesInfo = new UpdateSourcesInfo(this);
+
+ setApplicationDirectory( QCoreApplication::applicationDirPath() );
+
+ ApplicationData::instance = this;
+}
+
+/*!
+ Destructor
+*/
+Application::~Application()
+{
+ if( this == ApplicationData::instance )
+ ApplicationData::instance = 0;
+ delete d;
+}
+
+/*!
+ Returns a previousle created Application instance.
+ */
+Application* Application::instance()
+{
+ return ApplicationData::instance;
+}
+
+/*!
+ Changes the applicationDirPath directory to \c dir. Packages.xml and UpdateSources.xml found in the new
+ application directory will be used.
+*/
+void Application::setApplicationDirectory(const QString& dir)
+{
+ if( d->applicationDirectory == dir )
+ return;
+
+ QDir dirObj(dir);
+
+ // FIXME: Perhaps we should check whether dir exists on the local file system or not
+ d->applicationDirectory = dirObj.absolutePath();
+ setPackagesXMLFileName( QString::fromLatin1( "%1/Packages.xml" ).arg(dir) );
+ setUpdateSourcesXMLFileName( QString::fromLatin1( "%1/UpdateSources.xml" ).arg(dir) );
+}
+
+/*!
+ Returns path to the application directory.
+*/
+QString Application::applicationDirectory() const
+{
+ return d->applicationDirectory;
+}
+
+/*!
+ Returns the application name.
+*/
+QString Application::applicationName() const
+{
+ if( d->packagesInfo->isValid() )
+ return d->packagesInfo->applicationName();
+
+ return QCoreApplication::applicationName();
+}
+
+/*!
+ Returns the application version.
+*/
+QString Application::applicationVersion() const
+{
+ if( d->packagesInfo->isValid() )
+ return d->packagesInfo->applicationVersion();
+
+ return QString();
+}
+
+const SignatureVerifier* Application::signatureVerifier( SignatureTarget target ) const
+{
+ return d->verifiers.value( target );
+}
+
+void Application::setSignatureVerifier( SignatureTarget target, const SignatureVerifier* v )
+{
+ delete d->verifiers.value( target );
+ d->verifiers.remove( target );
+ if ( v )
+ d->verifiers.insert( target, v->clone() );
+}
+
+/*!
+ Returns the compat level that this application is in.
+*/
+int Application::compatLevel() const
+{
+ if(d->packagesInfo->isValid())
+ return d->packagesInfo->compatLevel();
+
+ return -1;
+}
+
+void Application::addUpdateSource( const QString& name, const QString& title,
+ const QString& description, const QUrl& url, int priority )
+{
+ UpdateSourceInfo info;
+ info.name = name;
+ info.title = title;
+ info.description = description;
+ info.url = url;
+ info.priority = priority;
+ d->updateSourcesInfo->addUpdateSourceInfo( info );
+}
+
+
+/*!
+ Sets the file name of the Package XML file for this application. By default this is assumed to be
+ Packages.xml in the application directory.
+
+ \sa KDUpdater::PackagesInfo::setFileName()
+*/
+void Application::setPackagesXMLFileName(const QString& fileName)
+{
+ d->packagesInfo->setFileName( fileName );
+}
+
+/*!
+ Returns the Package XML file name.
+*/
+QString Application::packagesXMLFileName() const
+{
+ return d->packagesInfo->fileName();
+}
+
+/*!
+ Returns the \ref PackagesInfo object associated with this application.
+*/
+PackagesInfo* Application::packagesInfo() const
+{
+ return d->packagesInfo;
+}
+
+/*!
+ Sets the file name of the Package XML file for this application. By default this is assumed to be
+ Packages.xml in the application directory.
+
+ \sa KDUpdater::UpdateSourcesInfo::setFileName()
+*/
+void Application::setUpdateSourcesXMLFileName(const QString& fileName)
+{
+ d->updateSourcesInfo->setFileName( fileName );
+}
+
+/*!
+ Returns the Update Sources XML file name.
+*/
+QString Application::updateSourcesXMLFileName() const
+{
+ return d->updateSourcesInfo->fileName();
+}
+
+/*!
+ Returns the \ref UpdateSourcesInfo object associated with this application.
+*/
+UpdateSourcesInfo* Application::updateSourcesInfo() const
+{
+ return d->updateSourcesInfo;
+}
+
+void Application::printError( int errorCode, const QString& error )
+{
+ qDebug() << errorCode << error;
+}
+
+QStringList Application::filesForDelayedDeletion() const
+{
+ return d->filesForDelayedDeletion;
+}
+
+void Application::addFilesForDelayedDeletion( const QStringList& files )
+{
+ d->filesForDelayedDeletion << files;
+ d->configurationInterface->setValue( QLatin1String("FilesForDelayedDeletion"), d->filesForDelayedDeletion );
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.h
new file mode 100644
index 000000000..3970236d3
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterapplication.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_APPLICATION_H
+#define KD_UPDATER_APPLICATION_H
+
+#include "kdupdater.h"
+#include <QObject>
+
+class QUrl;
+
+namespace KDUpdater
+{
+ class PackagesInfo;
+ class SignatureVerifier;
+ class UpdateSourcesInfo;
+
+ class ConfigurationInterface {
+ public:
+ virtual ~ConfigurationInterface();
+ virtual QVariant value( const QString& key ) const = 0;
+ virtual void setValue( const QString& key, const QVariant& value ) = 0;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT Application : public QObject
+ {
+ Q_OBJECT
+
+ public:
+ enum SignatureTarget {
+ Metadata,
+ Packages
+ };
+
+ explicit Application( ConfigurationInterface* config=0, QObject* parent=0);
+ ~Application();
+
+ static Application* instance();
+
+ void setApplicationDirectory(const QString& dir);
+ QString applicationDirectory() const;
+
+ QString applicationName() const;
+ QString applicationVersion() const;
+ int compatLevel() const;
+
+ const SignatureVerifier* signatureVerifier( SignatureTarget target ) const;
+ void setSignatureVerifier( SignatureTarget target, const SignatureVerifier* verifier );
+
+ void setPackagesXMLFileName(const QString& fileName);
+ QString packagesXMLFileName() const;
+ PackagesInfo* packagesInfo() const;
+
+ void addUpdateSource( const QString& name, const QString& title,
+ const QString& description, const QUrl& url, int priority = -1 );
+
+ void setUpdateSourcesXMLFileName(const QString& fileName);
+ QString updateSourcesXMLFileName() const;
+ UpdateSourcesInfo* updateSourcesInfo() const;
+
+ QStringList filesForDelayedDeletion() const;
+ void addFilesForDelayedDeletion( const QStringList& files );
+
+ public Q_SLOTS:
+ void printError( int errorCode, const QString& error );
+
+ private:
+ struct ApplicationData;
+ ApplicationData* d;
+ };
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.cpp
new file mode 100644
index 000000000..8e5832084
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.cpp
@@ -0,0 +1,743 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdatercrypto.h"
+
+#include <openssl/ssl.h>
+#include <openssl/rsa.h>
+
+#include <QCoreApplication>
+#include <QCryptographicHash>
+#include <QDebug>
+#include <QStringList>
+#include <QFile>
+#include <QMutex>
+#include <QLibrary>
+#include <QDir>
+#include <QTemporaryFile>
+
+//BEGIN code taken from qsslsocket_openssl_symbols.cpp
+
+#define DUMMYARG
+
+#define CLEARFUNC(func) \
+ _kd_##func = 0;
+
+#define RESOLVEFUNC(func) \
+ if (!(_kd_##func = _kd_PTR_##func(libs->resolve(#func)))) \
+ qWarning("QSslSocket: cannot resolve "#func);
+
+#define DEFINEFUNC(ret, func, arg, a, err, funcret) \
+ typedef ret (*_kd_PTR_##func)(arg); \
+ _kd_PTR_##func _kd_##func; \
+ ret kd_##func(arg) { \
+ Q_ASSERT(_kd_##func); \
+ funcret _kd_##func(a); \
+ }
+
+#define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret) \
+ typedef ret (*_kd_PTR_##func)(arg1, arg2, arg3); \
+ _kd_PTR_##func _kd_##func; \
+ ret kd_##func(arg1, arg2, arg3) { \
+ Q_ASSERT(_kd_##func); \
+ funcret _kd_##func(a, b, c); \
+ }
+
+#define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret) \
+ typedef ret (*_kd_PTR_##func)(arg1, arg2, arg3, arg4); \
+ _kd_PTR_##func _kd_##func; \
+ ret kd_##func(arg1, arg2, arg3, arg4) { \
+ Q_ASSERT(_kd_##func); \
+ funcret _kd_##func(a, b, c, d); \
+ }
+
+#define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret) \
+ typedef ret (*_kd_PTR_##func)(arg1, arg2, arg3, arg4, arg5); \
+ _kd_PTR_##func _kd_##func; \
+ ret kd_##func(arg1, arg2, arg3, arg4, arg5) { \
+ Q_ASSERT(_kd_##func); \
+ funcret _kd_##func(a, b, c, d, e); \
+ }
+
+#define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret) \
+ typedef ret (*_kd_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6); \
+ _kd_PTR_##func _kd_##func; \
+ ret kd_##func(arg1, arg2, arg3, arg4, arg5, arg6) { \
+ Q_ASSERT(_kd_##func); \
+ funcret _kd_##func(a, b, c, d, e, f); \
+ }
+
+
+# ifdef Q_OS_UNIX
+static bool libGreaterThan(const QString &lhs, const QString &rhs)
+{
+ QStringList lhsparts = lhs.split(QLatin1Char('.'));
+ QStringList rhsparts = rhs.split(QLatin1Char('.'));
+ Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);
+
+ for (int i = 1; i < rhsparts.count(); ++i) {
+ if (lhsparts.count() <= i)
+ // left hand side is shorter, so it's less than rhs
+ return false;
+
+ bool ok = false;
+ int b = 0;
+ int a = lhsparts.at(i).toInt(&ok);
+ if (ok)
+ b = rhsparts.at(i).toInt(&ok);
+ if (ok) {
+ // both toInt succeeded
+ if (a == b)
+ continue;
+ return a > b;
+ } else {
+ // compare as strings;
+ if (lhsparts.at(i) == rhsparts.at(i))
+ continue;
+ return lhsparts.at(i) > rhsparts.at(i);
+ }
+ }
+
+ // they compared strictly equally so far
+ // lhs cannot be less than rhs
+ return true;
+}
+static QStringList findAllLibSsl()
+{
+ QStringList paths;
+# ifdef Q_OS_DARWIN
+ paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH"))
+ .split(QLatin1Char(':'), QString::SkipEmptyParts);
+# else
+ paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH"))
+ .split(QLatin1Char(':'), QString::SkipEmptyParts);
+# endif
+ paths << QLatin1String("/usr/lib") << QLatin1String("/usr/local/lib");
+
+ QStringList foundSsls;
+ Q_FOREACH (const QString &path, paths) {
+ QDir dir = QDir(path);
+ QStringList entryList = dir.entryList(QStringList() << QLatin1String("libssl.*"), QDir::Files);
+
+ qSort(entryList.begin(), entryList.end(), libGreaterThan);
+ Q_FOREACH (const QString &entry, entryList)
+ foundSsls << path + QLatin1Char('/') + entry;
+ }
+
+ return foundSsls;
+}
+#endif
+
+class KDLibraryLoader : public QObject
+{
+ static QMutex* mutex;
+public:
+ KDLibraryLoader()
+ {
+ const QMutexLocker ml( mutex );
+ if( tempDir.isEmpty() )
+ {
+ QTemporaryFile file( QDir::temp().absoluteFilePath( QString::fromLatin1( "templibsXXXXXX" ) ) );
+ file.open();
+ tempDir = file.fileName();
+ file.close();
+ file.remove();
+ }
+ QDir::temp().mkdir( QFileInfo( tempDir ).fileName() );
+ }
+
+ ~KDLibraryLoader()
+ {
+ const QMutexLocker ml( mutex );
+ for( QVector< QLibrary* >::const_iterator it = loadedLibraries.begin(); it != loadedLibraries.end(); ++it )
+ {
+ QLibrary* const lib = *it;
+ lib->unload();
+ delete lib;
+ }
+
+ for( QStringList::const_iterator it = temporaryFiles.begin(); it != temporaryFiles.end(); ++it )
+ {
+ QFile file( *it );
+ file.setPermissions( file.permissions() | QFile::WriteOwner | QFile::WriteUser );
+ file.remove();
+ }
+
+ QDir::temp().rmdir( QFileInfo( tempDir ).fileName() );
+ }
+
+ bool load( const QString& filename )
+ {
+ const QMutexLocker ml( mutex );
+ // does it work out of the box? great!
+ QLibrary* const lib = new QLibrary;
+ loadedLibraries.push_back( lib );
+ lib->setFileName( filename );
+ if( lib->load() )
+ return true;
+
+ // if this failed, we copy the filename to a different place
+ // it might as well come from a resource
+ const QString realFilename = QFileInfo( QDir( tempDir ), QFileInfo( filename ).fileName() ).absoluteFilePath();
+
+ QFile::copy( filename, realFilename );
+ temporaryFiles.push_back( realFilename );
+
+ lib->setFileName( realFilename );
+ if( lib->load() )
+ return true;
+
+ // if all fails... sorry, we can't perform magic. Seriously!
+ QFile::remove( realFilename );
+ temporaryFiles.pop_back();
+
+ delete lib;
+ loadedLibraries.pop_back();
+
+ return false;
+ }
+
+ template< typename VERSION >
+ bool load( const QString& filename, VERSION version )
+ {
+ const QMutexLocker ml( mutex );
+ // does it work out of the box? great!
+ QLibrary* const lib = new QLibrary;
+ loadedLibraries.push_back( lib );
+ lib->setFileNameAndVersion( filename, version );
+ if( lib->load() )
+ return true;
+
+ // if this failed, we copy the filename to a different place
+ // it might as well come from a resource
+ const QString realFilename = QFileInfo( QDir( tempDir ), QFileInfo( filename ).fileName() ).absoluteFilePath();
+
+ QFile::copy( filename, realFilename );
+ temporaryFiles.push_back( realFilename );
+
+ lib->setFileNameAndVersion( realFilename, version );
+ if( lib->load() )
+ return true;
+
+ // if all fails... sorry, we can't perform magic. Seriously!
+ QFile::remove( realFilename );
+ temporaryFiles.pop_back();
+
+ delete lib;
+ loadedLibraries.pop_back();
+
+ return false;
+
+ }
+
+ void* resolve( const char* symbol )
+ {
+ const QMutexLocker ml( mutex );
+ for( QVector< QLibrary* >::const_iterator it = loadedLibraries.begin(); it != loadedLibraries.end(); ++it )
+ {
+ QLibrary* const lib = *it;
+ void* const ptr = lib->resolve( symbol );
+ if( ptr != 0 )
+ return ptr;
+ }
+ return 0;
+ }
+
+private:
+ QVector< QLibrary* > loadedLibraries;
+ QStringList temporaryFiles;
+ static QString tempDir;
+};
+
+QString KDLibraryLoader::tempDir;
+
+// TODO: this one get leaked
+QMutex* KDLibraryLoader::mutex = new QMutex;
+
+static KDLibraryLoader* loadOpenSsl()
+{
+ KDLibraryLoader* result = new KDLibraryLoader;
+#ifdef Q_OS_WIN
+ if( result->load( QLatin1String( ":/openssllibs/libeay32.dll" ) ) && result->load( QLatin1String( ":/openssllibs/libssl32.dll" ) ) )
+ return result;
+
+ delete result;
+ return 0;
+
+# elif defined(Q_OS_UNIX)
+ // Try to find the libssl library on the system.
+ //
+ // Up until Qt 4.3, this only searched for the "ssl" library at version -1, that
+ // is, libssl.so on most Unix systems. However, the .so file isn't present in
+ // user installations because it's considered a development file.
+ //
+ // The right thing to do is to load the library at the major version we know how
+ // to work with: the SHLIB_VERSION_NUMBER version (macro defined in opensslv.h)
+ //
+ // However, OpenSSL is a well-known case of binary-compatibility breakage. To
+ // avoid such problems, many system integrators and Linux distributions change
+ // the soname of the binary, letting the full version number be the soname. So
+ // we'll find libssl.so.0.9.7, libssl.so.0.9.8, etc. in the system. For that
+ // reason, we will search a few common paths (see findAllLibSsl() above) in hopes
+ // we find one that works.
+ //
+ // It is important, however, to try the canonical name and the unversioned name
+ // without going through the loop. By not specifying a path, we let the system
+ // dlopen(3) function determine it for us. This will include any DT_RUNPATH or
+ // DT_RPATH tags on our library header as well as other system-specific search
+ // paths. See the man page for dlopen(3) on your system for more information.
+
+#ifdef SHLIB_VERSION_NUMBER
+ // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
+
+ if( result->load( QLatin1String( "ssl" ), QLatin1String( SHLIB_VERSION_NUMBER ) ) &&
+ result->load( QLatin1String( "crypto" ), QLatin1String( SHLIB_VERSION_NUMBER ) ) ) {
+ // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
+ return result;
+ } else {
+ delete result;
+ result = new KDLibraryLoader;
+ }
+#endif
+
+ // second attempt: find the development files libssl.so and libcrypto.so
+ if( result->load( QLatin1String( "ssl" ), -1 ) &&
+ result->load( QLatin1String( "crypto" ), -1 ) ) {
+ // libssl.so.0 and libcrypto.so.0 found
+ return result;
+ } else {
+ delete result;
+ result = new KDLibraryLoader;
+ }
+
+ // third attempt: loop on the most common library paths and find libssl
+ QStringList sslList = findAllLibSsl();
+ Q_FOREACH (const QString &ssl, sslList) {
+ QString crypto = ssl;
+ crypto.replace(QLatin1String("ssl"), QLatin1String("crypto"));
+ if( result->load( ssl, -1 ) &&
+ result->load( crypto ), -1 ) {
+ // libssl.so.0 and libcrypto.so.0 found
+ return result;
+ } else {
+ delete result;
+ result = new KDLibraryLoader;
+ }
+ }
+
+ // failed to load anything
+ delete result;
+ return 0;
+
+# else
+ // not implemented for this platform yet
+ return 0;
+# endif
+}
+
+//END code taken from qsslsocket_openssl_symbols.cpp
+
+class KDUpdaterCrypto::Private
+{
+ public:
+ KDUpdaterCrypto *q;
+
+ QByteArray m_privateKey;
+ QByteArray m_privatePassword;
+ RSA *m_private_key;
+ BIO *m_private_key_bio;
+
+ QByteArray m_publicKey;
+ RSA *m_public_key;
+ BIO *m_public_key_bio;
+
+ KDLibraryLoader* libLoader;
+
+ const PasswordProvider* passwordProvider;
+
+ DEFINEFUNC(int, SSL_library_init, void, DUMMYARG, return -1, return)
+ DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return)
+ DEFINEFUNC(BIO *, BIO_new, BIO_METHOD *a, a, return 0, return)
+ DEFINEFUNC(BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
+ DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)
+ DEFINEFUNC(RSA*, RSA_new, void, DUMMYARG, return 0, return)
+ DEFINEFUNC(void, RSA_free, RSA *a, a, return, DUMMYARG)
+ DEFINEFUNC(int, RSA_size, RSA *a, a, return 0, return)
+ DEFINEFUNC5(int, RSA_public_encrypt, int flen, flen, unsigned char *from, from, unsigned char *to, to, RSA *rsa, rsa, int padding, padding, return -1, return)
+ DEFINEFUNC5(int, RSA_private_decrypt, int flen, flen, unsigned char *from, from, unsigned char *to, to, RSA *rsa, rsa, int padding, padding, return -1, return)
+ DEFINEFUNC6(int, RSA_sign, int type, type, const unsigned char *m, m, unsigned int m_len, m_len, unsigned char *sigret, sigret, unsigned int *siglen, siglen, RSA *rsa, rsa, return 0, return)
+ DEFINEFUNC6(int, RSA_verify, int type, type, const unsigned char *m, m, unsigned int m_len, m_len, unsigned char *sigret, sigret, unsigned int siglen, siglen, RSA *rsa, rsa, return 0, return)
+ DEFINEFUNC4(RSA*, PEM_read_bio_RSAPrivateKey, BIO *bp, bp, RSA **x, x, pem_password_cb *cb, cb, void *u, u, return 0, return)
+ DEFINEFUNC4(RSA*, PEM_read_bio_RSA_PUBKEY, BIO *bp, bp, RSA **x, x, pem_password_cb *cb, cb, void *u, u, return 0, return)
+
+ explicit Private( KDUpdaterCrypto* q )
+ : q( q ),
+ m_private_key( 0 ),
+ m_private_key_bio( 0 ),
+ m_public_key( 0 ),
+ m_public_key_bio( 0 ),
+ libLoader( 0 ),
+ passwordProvider( 0 )
+ {
+ CLEARFUNC(SSL_library_init)
+ CLEARFUNC(BIO_free)
+ CLEARFUNC(BIO_new)
+ CLEARFUNC(BIO_s_mem)
+ CLEARFUNC(BIO_write)
+ CLEARFUNC(RSA_new)
+ CLEARFUNC(RSA_free)
+ CLEARFUNC(RSA_size)
+ CLEARFUNC(PEM_read_bio_RSAPrivateKey)
+ CLEARFUNC(PEM_read_bio_RSA_PUBKEY)
+ CLEARFUNC(RSA_public_encrypt)
+ CLEARFUNC(RSA_private_decrypt)
+ CLEARFUNC(RSA_sign)
+ CLEARFUNC(RSA_verify)
+ }
+ ~Private()
+ {
+ finish();
+ CLEARFUNC(SSL_library_init)
+ CLEARFUNC(BIO_free)
+ CLEARFUNC(BIO_new)
+ CLEARFUNC(BIO_s_mem)
+ CLEARFUNC(BIO_write)
+ CLEARFUNC(RSA_new)
+ CLEARFUNC(RSA_free)
+ CLEARFUNC(RSA_size)
+ CLEARFUNC(PEM_read_bio_RSAPrivateKey)
+ CLEARFUNC(PEM_read_bio_RSA_PUBKEY)
+ CLEARFUNC(RSA_public_encrypt)
+ CLEARFUNC(RSA_private_decrypt)
+ CLEARFUNC(RSA_sign)
+ CLEARFUNC(RSA_verify)
+ delete libLoader;
+ }
+
+ bool resolveOpenSslSymbols()
+ {
+ volatile bool symbolsResolved = false;
+ volatile bool triedToResolveSymbols = false;
+ //QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&kd_SSL_library_init));
+ if (symbolsResolved)
+ return true;
+ if (triedToResolveSymbols)
+ return false;
+ if( libLoader != 0 )
+ return true;
+ triedToResolveSymbols = true;
+
+ KDLibraryLoader* const libs = loadOpenSsl();
+ if( libs == 0 )
+ // failed to load them
+ return false;
+
+ RESOLVEFUNC(SSL_library_init)
+ RESOLVEFUNC(BIO_free)
+ RESOLVEFUNC(BIO_new)
+ RESOLVEFUNC(BIO_s_mem)
+ RESOLVEFUNC(BIO_write)
+ RESOLVEFUNC(RSA_new)
+ RESOLVEFUNC(RSA_free)
+ RESOLVEFUNC(RSA_size)
+ RESOLVEFUNC(PEM_read_bio_RSAPrivateKey)
+ RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY)
+ RESOLVEFUNC(RSA_public_encrypt)
+ RESOLVEFUNC(RSA_private_decrypt)
+ RESOLVEFUNC(RSA_sign)
+ RESOLVEFUNC(RSA_verify)
+
+ symbolsResolved = true;
+ libLoader = libs;
+ return true;
+ }
+
+ void init()
+ {
+ resolveOpenSslSymbols();
+ const int inited = kd_SSL_library_init();
+ Q_UNUSED( inited );
+ Q_ASSERT(inited);
+ //OpenSSL_add_all_algorithms();
+ }
+
+ void finish()
+ {
+ finishPrivateKey();
+ finishPublicKey();
+ }
+
+ void finishPrivateKey()
+ {
+ if( m_private_key ) {
+ kd_RSA_free(m_private_key);
+ m_private_key = 0;
+ }
+ if( m_private_key_bio ) {
+ kd_BIO_free(m_private_key_bio);
+ m_private_key_bio = 0;
+ }
+ }
+
+ void finishPublicKey()
+ {
+ if( m_public_key ) {
+ kd_RSA_free(m_public_key);
+ m_public_key = 0;
+ }
+ if( m_public_key_bio ) {
+ kd_BIO_free(m_public_key_bio);
+ m_public_key_bio = 0;
+ }
+ }
+
+ static int password_callback(char *buf, int bufsiz, int verify, void *userdata)
+ {
+ Q_UNUSED( verify );
+ //qDebug()<<"KDUpdaterCrypto::password_callback verify="<<verify;
+ KDUpdaterCrypto *crypto = static_cast<KDUpdaterCrypto*>(userdata);
+ const QByteArray password = crypto->d->passwordProvider == 0 ? crypto->privatePassword()
+ : crypto->d->passwordProvider->password();
+ int len = password.length();
+ if (len <= 0)
+ return 0;
+ if (len > bufsiz)
+ len = bufsiz;
+ memcpy(buf, password.constData(), len);
+ return len;
+ }
+
+ bool initPrivateKey()
+ {
+ finishPrivateKey();
+
+ m_private_key_bio = kd_BIO_new(kd_BIO_s_mem());
+ Q_ASSERT(m_private_key_bio);
+
+ Q_ASSERT( ! m_privateKey.isNull());
+ const int priv_bio_size = kd_BIO_write(m_private_key_bio, m_privateKey.constData(), m_privateKey.length());
+ Q_UNUSED( priv_bio_size );
+ Q_ASSERT(priv_bio_size >= 1);
+
+ m_private_key = kd_RSA_new();
+ Q_ASSERT(m_private_key);
+ if( ! kd_PEM_read_bio_RSAPrivateKey(m_private_key_bio, &m_private_key, Private::password_callback, q)) {
+ qWarning() << "PEM_read_bio_RSAPrivateKey failed";
+ kd_RSA_free( m_private_key );
+ m_private_key = 0;
+ return false;
+ }
+ return true;
+ }
+
+ bool initPublicKey()
+ {
+ finishPublicKey();
+
+ m_public_key_bio = kd_BIO_new(kd_BIO_s_mem());
+ Q_ASSERT(m_public_key_bio);
+
+ Q_ASSERT( ! m_publicKey.isNull());
+ const int pub_bio_size = kd_BIO_write(m_public_key_bio, m_publicKey.constData(), m_publicKey.length());
+ Q_UNUSED( pub_bio_size );
+ Q_ASSERT(pub_bio_size >= 1);
+
+ m_public_key = kd_RSA_new();
+ Q_ASSERT(m_public_key);
+ if( ! kd_PEM_read_bio_RSA_PUBKEY(m_public_key_bio, &m_public_key, password_callback, q)) {
+ qWarning() << "PEM_read_bio_RSAPublicKey failed";
+ kd_RSA_free( m_public_key );
+ m_public_key = 0;
+ return false;
+ }
+ return true;
+ }
+};
+
+KDUpdaterCrypto::KDUpdaterCrypto()
+ : d(new Private(this))
+{
+ d->init();
+}
+
+KDUpdaterCrypto::~KDUpdaterCrypto()
+{
+}
+
+QByteArray KDUpdaterCrypto::privateKey() const
+{
+ return d->m_privateKey;
+}
+
+void KDUpdaterCrypto::setPrivateKey(const QByteArray &key)
+{
+ d->m_privateKey = key;
+ d->finish();
+}
+
+QByteArray KDUpdaterCrypto::privatePassword() const
+{
+ return d->m_privatePassword;
+}
+
+void KDUpdaterCrypto::setPrivatePassword(const QByteArray &passwd)
+{
+ d->m_privatePassword = passwd;
+ d->finish();
+}
+
+void KDUpdaterCrypto::setPrivatePasswordProvider( const PasswordProvider* provider )
+{
+ d->passwordProvider = provider;
+}
+
+QByteArray KDUpdaterCrypto::publicKey() const
+{
+ return d->m_publicKey;
+}
+
+void KDUpdaterCrypto::setPublicKey(const QByteArray &key)
+{
+ d->m_publicKey = key;
+ d->finish();
+}
+
+QByteArray KDUpdaterCrypto::encrypt(const QByteArray &plaintext)
+{
+ if( !d->m_public_key && !d->initPublicKey() )
+ return QByteArray();
+
+ Q_ASSERT(d->m_public_key);
+ unsigned char *encrypted = new unsigned char[ d->kd_RSA_size(d->m_public_key) ];
+ const int encryptedlen = d->kd_RSA_public_encrypt(plaintext.length(), (unsigned char *) plaintext.constData(), encrypted, d->m_public_key, RSA_PKCS1_PADDING);
+ const QByteArray ret = encryptedlen>=0 ? QByteArray( (const char*) encrypted, encryptedlen ) : QByteArray();
+ Q_ASSERT(!ret.isNull());
+ delete [] encrypted;
+ return ret;
+}
+
+QByteArray KDUpdaterCrypto::decrypt(const QByteArray &encryptedtext)
+{
+ if( !d->m_private_key && !d->initPrivateKey() )
+ return QByteArray();
+
+ Q_ASSERT(d->m_private_key);
+ unsigned char *decrypted = new unsigned char[ d->kd_RSA_size(d->m_private_key) ];
+ const int decryptedlen = d->kd_RSA_private_decrypt(encryptedtext.length(), (unsigned char *) encryptedtext.constData(), decrypted, d->m_private_key, RSA_PKCS1_PADDING);
+ const QByteArray ret = decryptedlen>=0 ? QByteArray( (const char*) decrypted, decryptedlen ) : QByteArray();
+ delete [] decrypted;
+ return ret;
+}
+
+bool KDUpdaterCrypto::verify(const QByteArray &data, const QByteArray &signature)
+{
+ if( !d->m_public_key && !d->initPublicKey() )
+ return false;
+
+ unsigned char *sigret = (unsigned char*) signature.constData();
+ unsigned int siglen = signature.length();
+ const int verifyresult = d->kd_RSA_verify(NID_sha1, (const unsigned char*) data.constData(), data.length(), sigret, siglen, d->m_public_key);
+ return verifyresult == 1;
+}
+
+static QByteArray hash( QIODevice* dev, QCryptographicHash::Algorithm method )
+{
+ QByteArray buffer;
+ buffer.resize( 8192 );
+ QCryptographicHash h( method );
+ while( !dev->atEnd() )
+ {
+ const int read = dev->read( buffer.data(), buffer.length() );
+ h.addData( buffer.constData(), read );
+ }
+ return h.result();
+}
+
+bool KDUpdaterCrypto::verify( QIODevice* dev, const QByteArray& signature )
+{
+ const bool wasOpen = dev->isOpen();
+ if( !wasOpen && !dev->open( QIODevice::ReadOnly ) )
+ {
+ qWarning() << "KDUpdaterCrypto::verify: could not open the device";
+ return false;
+ }
+
+ const qint64 pos = dev->pos();
+ const bool result = verify( hash( dev, QCryptographicHash::Sha1 ), signature );
+ dev->seek( pos );
+ if( !wasOpen )
+ dev->close();
+ return result;
+
+}
+
+bool KDUpdaterCrypto::verify( const QString& dataPath, const QByteArray& signature )
+{
+ QFile dFile( dataPath );
+ return verify( &dFile, signature );
+}
+
+bool KDUpdaterCrypto::verify( const QString& dataPath, const QString& signaturePath )
+{
+ QFile sFile( signaturePath );
+ if( !sFile.open( QIODevice::ReadOnly ) )
+ {
+ qWarning() << "KDUpdaterCrypto::veryfi: could not open the signature file";
+ return false;
+ }
+
+ return verify( dataPath, sFile.readAll() );
+}
+
+QByteArray KDUpdaterCrypto::sign( QIODevice* dev )
+{
+ const bool wasOpen = dev->isOpen();
+ if( !wasOpen && !dev->open( QIODevice::ReadOnly ) )
+ return QByteArray();
+
+ const qint64 pos = dev->pos();
+ const QByteArray signature = sign( hash( dev, QCryptographicHash::Sha1 ) );
+ dev->seek( pos );
+ if( !wasOpen )
+ dev->close();
+ return signature;
+}
+
+QByteArray KDUpdaterCrypto::sign( const QString& path )
+{
+ QFile file( path );
+ return sign( &file );
+}
+
+QByteArray KDUpdaterCrypto::sign(const QByteArray &data)
+{
+ if( !d->m_private_key && !d->initPrivateKey() )
+ return QByteArray();
+
+ const char *msg = data.constData();
+ unsigned char *sigret = new unsigned char[ d->kd_RSA_size(d->m_private_key) ];
+ unsigned int siglen;
+ const int signresult = d->kd_RSA_sign(NID_sha1, (const unsigned char*) msg, strlen(msg), sigret, &siglen, d->m_private_key);
+ const QByteArray ret = signresult == 1 ? QByteArray( (const char*) sigret, siglen) : QByteArray();
+ delete [] sigret;
+ return ret;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.h
new file mode 100644
index 000000000..15d0011a0
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatercrypto.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLS_KDUPDATERCRYPTO_H__
+#define __KDTOOLS_KDUPDATERCRYPTO_H__
+
+#include "kdupdater.h"
+
+class QByteArray;
+class QIODevice;
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+/**
+ * Class that provides cryptographic functionality like signing and verifying
+ * or encrypting and decrypting content.
+ */
+class KDTOOLS_UPDATER_EXPORT KDUpdaterCrypto {
+ public:
+ class PasswordProvider
+ {
+ public:
+ virtual ~PasswordProvider() {}
+ virtual QByteArray password() const = 0;
+ };
+
+ KDUpdaterCrypto();
+ virtual ~KDUpdaterCrypto();
+
+ /**
+ * The private key.
+ */
+ QByteArray privateKey() const;
+ void setPrivateKey(const QByteArray &key);
+
+ /**
+ * The password for the private key.
+ */
+ QByteArray privatePassword() const;
+ void setPrivatePassword(const QByteArray &passwd);
+
+ void setPrivatePasswordProvider( const PasswordProvider* provider );
+
+ /**
+ * The public key.
+ */
+ QByteArray publicKey() const;
+ void setPublicKey(const QByteArray &key);
+
+ /**
+ * Encrypt content using the public key.
+ */
+ QByteArray encrypt(const QByteArray &plaintext);
+
+ /**
+ * Decript encrypted content using the private key.
+ */
+ QByteArray decrypt(const QByteArray &encryptedtext);
+
+ /**
+ * Sign content with the private key.
+ */
+ QByteArray sign(const QByteArray &data);
+ QByteArray sign( const QString& path );
+ QByteArray sign( QIODevice* dev );
+
+ /**
+ * Verify signed content with the public key.
+ */
+ bool verify(const QByteArray &data, const QByteArray &signature);
+ bool verify( const QString& dataPath, const QString& signaturePath );
+ bool verify( const QString& dataPath, const QByteArray& signature );
+ bool verify( QIODevice* dev, const QByteArray& signature );
+
+ private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.cpp
new file mode 100644
index 000000000..c23badb5b
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.cpp
@@ -0,0 +1,1165 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterfiledownloader_p.h"
+#include "kdupdaterfiledownloaderfactory.h"
+#include "kdupdatersignatureverifier.h"
+#include "kdupdatersignatureverificationresult.h"
+
+#include <KDToolsCore/KDAutoPointer>
+
+#include <QFile>
+#include <QFtp>
+#include <QNetworkAccessManager>
+#include <QNetworkProxyFactory>
+#include <QPointer>
+#include <QUrl>
+#include <QTemporaryFile>
+#include <QFileInfo>
+#include <QCryptographicHash>
+#include <QThreadPool>
+#include <QDebug>
+
+using namespace KDUpdater;
+
+static double calcProgress(qint32 done, qint32 total)
+{
+ return total ? (double(done) / double(total)) : 0 ;
+}
+
+QByteArray KDUpdater::calculateHash( QIODevice* device, QCryptographicHash::Algorithm algo ) {
+ Q_ASSERT( device );
+ QCryptographicHash hash( algo );
+ QByteArray buffer;
+ buffer.resize( 512 * 1024 );
+ while ( true ) {
+ const qint64 numRead = device->read( buffer.data(), buffer.size() );
+ if ( numRead <= 0 )
+ return hash.result();
+ hash.addData( buffer.constData(), numRead );
+ }
+ return QByteArray(); // never reached
+}
+
+QByteArray KDUpdater::calculateHash( const QString& path, QCryptographicHash::Algorithm algo ) {
+ QFile file( path );
+ if ( !file.open( QIODevice::ReadOnly ) )
+ return QByteArray();
+ return calculateHash( &file, algo );
+}
+
+class HashVerificationJob::Private {
+public:
+ Private() : hash( QCryptographicHash::Sha1 ), error( HashVerificationJob::ReadError ), timerId( -1 ) {
+ }
+
+ QPointer<QIODevice> device;
+ QByteArray sha1Sum;
+ QCryptographicHash hash;
+ HashVerificationJob::Error error;
+ int timerId;
+};
+
+HashVerificationJob::HashVerificationJob( QObject* parent ) : QObject( parent ), d( new Private )
+{
+}
+
+HashVerificationJob::~HashVerificationJob()
+{
+}
+
+void HashVerificationJob::setDevice( QIODevice* dev )
+{
+ d->device = dev;
+}
+
+void HashVerificationJob::setSha1Sum( const QByteArray& sum )
+{
+ d->sha1Sum = sum;
+}
+
+int HashVerificationJob::error() const
+{
+ return d->error;
+}
+
+bool HashVerificationJob::hasError() const
+{
+ return d->error != NoError;
+}
+
+void HashVerificationJob::start()
+{
+ Q_ASSERT( d->device );
+ d->timerId = startTimer( 0 );
+}
+
+void HashVerificationJob::emitFinished()
+{
+ emit finished( this );
+ deleteLater();
+}
+
+void HashVerificationJob::timerEvent( QTimerEvent* )
+{
+ Q_ASSERT( d->timerId >= 0 );
+ if ( d->sha1Sum.isEmpty() ) {
+ killTimer( d->timerId );
+ d->timerId = -1;
+ d->error = NoError;
+ d->device->close();
+ emitFinished();
+ return;
+ }
+
+ QByteArray buf;
+ buf.resize( 128 * 1024 );
+ const qint64 read = d->device->read( buf.data(), buf.size() );
+ if ( read > 0 ) {
+ d->hash.addData( buf.constData(), read );
+ return;
+ }
+
+ d->error = d->hash.result() == d->sha1Sum ? NoError : SumsDifferError;
+ killTimer( d->timerId );
+ d->timerId = -1;
+ emitFinished();
+}
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::FileDownloader
+////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \internal
+ \ingroup kdupdater
+ \class KDUpdater::FileDownloader kdupdaterfiledownloader.h
+
+ Base class for file downloaders used in KDUpdater. File downloaders are used by
+ the KDUpdater::Update class to download update files. Each subclass of FileDownloader
+ can download file from a specific category of sources (eg. local, ftp, http etc).
+
+ This is an internal class, not a part of the public API. Currently we have three
+ subclasses of FileDownloader
+ \li LocalFileDownloader - downloads from the local file system
+ \li FtpDownloader - downloads from a FTP site
+ \li HttpDownloader - downloads from a HTTP site
+
+ Usage
+
+ \code
+ KDUpdater::FileDownloader* downloader = new KDUpdater::(some subclass name)
+
+ downloader->setUrl( url );
+ downloader->download();
+
+// wait for downloadCompleted() signal
+
+QString downloadedFile = downloader->downloadedFileName();
+\endcode
+*/
+
+struct KDUpdater::FileDownloader::FileDownloaderData
+{
+ FileDownloaderData() : autoRemove( true ) {
+ }
+
+ QUrl url;
+ QString scheme;
+ QByteArray sha1Sum;
+ QString errorString;
+ bool autoRemove;
+ bool followRedirect;
+};
+
+KDUpdater::FileDownloader::FileDownloader(const QString& scheme, QObject* parent)
+ : QObject(parent),
+ d( new FileDownloaderData )
+{
+ d->scheme = scheme;
+ d->followRedirect = false;
+}
+
+KDUpdater::FileDownloader::~FileDownloader()
+{
+}
+
+void KDUpdater::FileDownloader::setUrl(const QUrl& url)
+{
+ d->url = url;
+}
+
+QUrl KDUpdater::FileDownloader::url() const
+{
+ return d->url;
+}
+
+void KDUpdater::FileDownloader::setSha1Sum( const QByteArray& sum )
+{
+ d->sha1Sum = sum;
+}
+
+QByteArray KDUpdater::FileDownloader::sha1Sum() const
+{
+ return d->sha1Sum;
+}
+
+QString FileDownloader::errorString() const
+{
+ return d->errorString;
+}
+
+void FileDownloader::setDownloadAborted( const QString& error )
+{
+ d->errorString = error;
+ emit downloadAborted( error );
+}
+
+void KDUpdater::FileDownloader::setDownloadCompleted( const QString& path )
+{
+ KDAutoPointer<HashVerificationJob> job( new HashVerificationJob );
+ QFile* file = new QFile( path, job.get() );
+ if ( !file->open( QIODevice::ReadOnly ) ) {
+ emit downloadProgress( 1 );
+ onError();
+ setDownloadAborted( tr("Could not reopen downloaded file %1 for reading: %2").arg( path, file->errorString() ) );
+ return;
+ }
+
+ job->setDevice( file );
+ job->setSha1Sum( d->sha1Sum );
+ connect( job.get(), SIGNAL(finished(KDUpdater::HashVerificationJob*)), this, SLOT(sha1SumVerified(KDUpdater::HashVerificationJob*)) );
+ job.release()->start();
+}
+
+void KDUpdater::FileDownloader::sha1SumVerified( KDUpdater::HashVerificationJob* job )
+{
+ if ( job->hasError() ) {
+ onError();
+ setDownloadAborted( tr("Cryptographic hashes do not match.") );
+ }
+ else {
+ onSuccess();
+ emit downloadCompleted();
+ }
+}
+
+QString KDUpdater::FileDownloader::scheme() const
+{
+ return d->scheme;
+}
+
+void KDUpdater::FileDownloader::setAutoRemoveDownloadedFile(bool val)
+{
+ d->autoRemove = val;
+}
+
+void KDUpdater::FileDownloader::setFollowRedirects( bool val )
+{
+ d->followRedirect = val;
+}
+
+bool KDUpdater::FileDownloader::followRedirects() const
+{
+ return d->followRedirect;
+}
+
+bool KDUpdater::FileDownloader::isAutoRemoveDownloadedFile() const
+{
+ return d->autoRemove;
+}
+
+void KDUpdater::FileDownloader::download() {
+ QMetaObject::invokeMethod( this, "doDownload", Qt::QueuedConnection );
+}
+
+void KDUpdater::FileDownloader::cancelDownload()
+{
+ // Do nothing
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::FileDownloader
+////////////////////////////////////////////////////////////////////////////
+
+/*
+ Even though QFile::copy() does the task of copying local files from one place
+ to another, I prefer to use the timer and copy one block of data per unit time.
+
+ This is because, it is possible that the user of KDUpdater is simultaneously
+ downloading several files. Sometimes in tandem with other file downloaders.
+ If the local file that is being downloaded takes a long time; then that will
+ hang the other downloads.
+
+ On the otherhand, local downloads need not actually download the file. It can
+ simply pass on the source file as destination file. At this moment however,
+ I think the user of LocalFileDownloader will assume that the downloaded file
+ can be fiddled around with without worrying about whether it would mess up
+ the original source or not.
+*/
+
+struct KDUpdater::LocalFileDownloader::LocalFileDownloaderData
+{
+ LocalFileDownloaderData() : source(0), destination(0),
+ downloaded(false), timerId(-1) { }
+
+ QFile* source;
+ QTemporaryFile* destination;
+ QString destFileName;
+ bool downloaded;
+ int timerId;
+};
+
+KDUpdater::LocalFileDownloader::LocalFileDownloader(QObject* parent)
+ :KDUpdater::FileDownloader(QLatin1String( "file" ), parent),
+ d ( new LocalFileDownloaderData )
+{
+}
+
+KDUpdater::LocalFileDownloader::~LocalFileDownloader()
+{
+ if( this->isAutoRemoveDownloadedFile() && !d->destFileName.isEmpty() )
+ QFile::remove(d->destFileName);
+
+ delete d;
+}
+
+bool KDUpdater::LocalFileDownloader::canDownload() const
+{
+ const QString localFile = url().toLocalFile();
+ QFileInfo fi( localFile );
+ return fi.exists() && fi.isReadable();
+}
+
+bool KDUpdater::LocalFileDownloader::isDownloaded() const
+{
+ return d->downloaded;
+}
+
+void KDUpdater::LocalFileDownloader::doDownload()
+{
+ // Already downloaded
+ if( d->downloaded )
+ return;
+
+ // Already started downloading
+ if( d->timerId >= 0 )
+ return;
+
+ // Open source and destination files
+ QString localFile = this->url().toLocalFile();
+ d->source = new QFile(localFile, this);
+ d->destination = new QTemporaryFile(this);
+
+ if( !d->source->open(QFile::ReadOnly) )
+ {
+ onError();
+ setDownloadAborted(tr("Cannot open source file for reading."));
+ return;
+ }
+
+ if( !d->destination->open() )
+ {
+ onError();
+ setDownloadAborted(tr("Cannot open destination file for writing."));
+ return;
+ }
+
+ // Start a timer and kickoff the copy process
+ d->timerId = startTimer(0); // as fast as possible
+ emit downloadStarted();
+ emit downloadProgress(0);
+}
+
+QString KDUpdater::LocalFileDownloader::downloadedFileName() const
+{
+ return d->destFileName;
+}
+
+KDUpdater::LocalFileDownloader* KDUpdater::LocalFileDownloader::clone( QObject* parent ) const
+{
+ return new LocalFileDownloader( parent );
+}
+
+void KDUpdater::LocalFileDownloader::cancelDownload()
+{
+ if( d->timerId < 0 )
+ return;
+
+ killTimer( d->timerId );
+ d->timerId = -1;
+
+ onError();
+ emit downloadCanceled();
+}
+
+void KDUpdater::LocalFileDownloader::timerEvent(QTimerEvent*)
+{
+ if( !d->source || !d->destination )
+ return;
+
+ const qint64 blockSize = 32768;
+ QByteArray buffer;
+ buffer.resize( blockSize );
+ const qint64 numRead = d->source->read( buffer.data(), buffer.size() );
+ qint64 toWrite = numRead;
+ while ( toWrite > 0 ) {
+ const qint64 numWritten = d->destination->write( buffer.constData() + numRead - toWrite, toWrite );
+ if ( numWritten < 0 ) {
+ killTimer( d->timerId );
+ d->timerId = -1;
+ onError();
+ setDownloadAborted( tr("Writing to %1 failed: %2").arg( d->destination->fileName(), d->destination->errorString() ) );
+ return;
+ }
+ toWrite -= numWritten;
+ }
+
+ if( numRead > 0 ) {
+ emit downloadProgress( calcProgress(d->source->pos(), d->source->size()) );
+ return;
+ }
+
+ d->destination->flush();
+
+ killTimer( d->timerId );
+ d->timerId = -1;
+
+ setDownloadCompleted( d->destination->fileName() );
+}
+
+void LocalFileDownloader::onSuccess()
+{
+ d->downloaded = true;
+ d->destFileName = d->destination->fileName();
+ d->destination->setAutoRemove( false );
+ d->destination->close();
+ delete d->destination;
+ d->destination = 0;
+ delete d->source;
+ d->source = 0;
+}
+
+void LocalFileDownloader::onError()
+{
+ d->downloaded = false;
+ d->destFileName.clear();
+ delete d->destination;
+ d->destination = 0;
+ delete d->source;
+ d->source = 0;
+}
+
+struct KDUpdater::ResourceFileDownloader::ResourceFileDownloaderData
+{
+ ResourceFileDownloaderData()
+ : downloaded( false ),
+ timerId( -1 )
+ {
+ }
+
+ QString destFileName;
+ bool downloaded;
+ int timerId;
+};
+
+KDUpdater::ResourceFileDownloader::ResourceFileDownloader(QObject* parent)
+ :KDUpdater::FileDownloader(QLatin1String( "resource" ), parent),
+ d ( new ResourceFileDownloaderData )
+{
+}
+
+KDUpdater::ResourceFileDownloader::~ResourceFileDownloader()
+{
+ delete d;
+}
+
+bool KDUpdater::ResourceFileDownloader::canDownload() const
+{
+ QUrl url = this->url();
+ url.setScheme( QString::fromLatin1( "file" ) );
+ QString localFile = QString::fromLatin1( ":%1" ).arg( url.toLocalFile() );
+ QFileInfo fi(localFile);
+ return fi.exists() && fi.isReadable();
+}
+
+bool KDUpdater::ResourceFileDownloader::isDownloaded() const
+{
+ return d->downloaded;
+}
+
+void KDUpdater::ResourceFileDownloader::doDownload()
+{
+ // Already downloaded
+ if( d->downloaded )
+ return;
+
+ // Already started downloading
+ if( d->timerId >= 0 )
+ return;
+
+ // Open source and destination files
+ QUrl url = this->url();
+ url.setScheme( QString::fromLatin1( "file" ) );
+ d->destFileName = QString::fromLatin1( ":%1" ).arg( url.toLocalFile() );
+
+ // Start a timer and kickoff the copy process
+ d->timerId = startTimer(0); // as fast as possible
+ emit downloadStarted();
+ emit downloadProgress(0);
+}
+
+QString KDUpdater::ResourceFileDownloader::downloadedFileName() const
+{
+ return d->destFileName;
+}
+
+KDUpdater::ResourceFileDownloader* KDUpdater::ResourceFileDownloader::clone( QObject* parent ) const
+{
+ return new ResourceFileDownloader( parent );
+}
+
+void KDUpdater::ResourceFileDownloader::cancelDownload()
+{
+ if( d->timerId < 0 )
+ return;
+
+ killTimer( d->timerId );
+ d->timerId = -1;
+
+ emit downloadCanceled();
+}
+
+void KDUpdater::ResourceFileDownloader::timerEvent(QTimerEvent*)
+{
+ killTimer( d->timerId );
+ d->timerId = -1;
+ setDownloadCompleted( d->destFileName );
+}
+
+void KDUpdater::ResourceFileDownloader::onSuccess()
+{
+ d->downloaded = true;
+}
+
+void KDUpdater::ResourceFileDownloader::onError()
+{
+ d->downloaded = false;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::FileDownloader
+////////////////////////////////////////////////////////////////////////////
+
+struct KDUpdater::FtpDownloader::FtpDownloaderData
+{
+ FtpDownloaderData() : ftp(0), destination(0),
+ downloaded(false), ftpCmdId(-1), aborted(false) { }
+
+ QFtp* ftp;
+ QTemporaryFile* destination;
+ QString destFileName;
+ bool downloaded;
+ int ftpCmdId;
+ bool aborted;
+};
+
+KDUpdater::FtpDownloader::FtpDownloader(QObject* parent)
+ : KDUpdater::FileDownloader(QLatin1String( "ftp" ), parent),
+ d ( new FtpDownloaderData )
+{
+}
+
+KDUpdater::FtpDownloader::~FtpDownloader()
+{
+ if( this->isAutoRemoveDownloadedFile() && !d->destFileName.isEmpty() )
+ QFile::remove(d->destFileName);
+
+ delete d;
+}
+
+bool KDUpdater::FtpDownloader::canDownload() const
+{
+ // TODO: Check whether the ftp file actually exists or not.
+ return true;
+}
+
+bool KDUpdater::FtpDownloader::isDownloaded() const
+{
+ return d->downloaded;
+}
+
+void KDUpdater::FtpDownloader::doDownload()
+{
+ if( d->downloaded )
+ return;
+
+ if( d->ftp )
+ return;
+
+ d->ftp = new QFtp(this);
+ connect(d->ftp, SIGNAL(done(bool)), this, SLOT(ftpDone(bool)));
+ connect(d->ftp, SIGNAL(commandStarted(int)), this, SLOT(ftpCmdStarted(int)));
+ connect(d->ftp, SIGNAL(commandFinished(int,bool)), this, SLOT(ftpCmdFinished(int,bool)));
+ connect(d->ftp, SIGNAL(stateChanged(int)), this, SLOT(ftpStateChanged(int)));
+ connect(d->ftp, SIGNAL(dataTransferProgress(qint64,qint64)), this, SLOT(ftpDataTransferProgress(qint64,qint64)));
+
+ d->ftp->connectToHost( url().host(), url().port(21) );
+ d->ftp->login();
+}
+
+QString KDUpdater::FtpDownloader::downloadedFileName() const
+{
+ return d->destFileName;
+}
+
+KDUpdater::FtpDownloader* KDUpdater::FtpDownloader::clone( QObject* parent ) const
+{
+ return new FtpDownloader( parent );
+}
+
+
+void KDUpdater::FtpDownloader::cancelDownload()
+{
+ if( d->ftp )
+ {
+ d->aborted = true;
+ d->ftp->abort();
+ }
+}
+
+void KDUpdater::FtpDownloader::ftpDone(bool error)
+{
+ if( error )
+ {
+ d->ftp->deleteLater();
+ d->ftp = 0;
+ d->ftpCmdId = -1;
+
+ onError();
+
+ if( d->aborted )
+ {
+ d->aborted = false;
+ emit downloadCanceled();
+ }
+ else
+ setDownloadAborted( d->ftp->errorString() );
+ }
+ //PENDING what about the non-error case??
+}
+
+void KDUpdater::FtpDownloader::ftpCmdStarted(int id)
+{
+ if( id != d->ftpCmdId )
+ return;
+
+ emit downloadStarted();
+ emit downloadProgress(0);
+}
+
+void KDUpdater::FtpDownloader::ftpCmdFinished(int id, bool error)
+{
+ if( id != d->ftpCmdId || error ) // PENDING why error -> return??
+ return;
+
+ disconnect(d->ftp, 0, this, 0);
+ d->ftp->deleteLater();
+ d->ftp = 0;
+ d->ftpCmdId = -1;
+ d->destination->flush();
+
+ setDownloadCompleted( d->destination->fileName() );
+}
+
+void FtpDownloader::onSuccess()
+{
+ d->downloaded = true;
+ d->destFileName = d->destination->fileName();
+ d->destination->setAutoRemove( false );
+ delete d->destination;
+ d->destination = 0;
+
+}
+
+void FtpDownloader::onError()
+{
+ d->downloaded = false;
+ d->destFileName.clear();
+ delete d->destination;
+ d->destination = 0;
+
+}
+
+void KDUpdater::FtpDownloader::ftpStateChanged(int state)
+{
+ switch(state)
+ {
+ case QFtp::Connected:
+ // begin the download
+ d->destination = new QTemporaryFile(this);
+ d->destination->open(); //PENDING handle error
+ d->ftpCmdId = d->ftp->get( url().path(), d->destination );
+ break;
+ case QFtp::Unconnected:
+ // download was unconditionally aborted
+ disconnect(d->ftp, 0, this, 0);
+ d->ftp->deleteLater();
+ d->ftp = 0;
+ d->ftpCmdId = -1;
+ onError();
+ setDownloadAborted(tr("Download was aborted due to network errors."));
+ break;
+ }
+}
+
+void KDUpdater::FtpDownloader::ftpDataTransferProgress(qint64 done, qint64 total)
+{
+ emit downloadProgress( calcProgress(done, total) );
+}
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::FileDownloader
+////////////////////////////////////////////////////////////////////////////
+
+struct KDUpdater::HttpDownloader::HttpDownloaderData
+{
+ explicit HttpDownloaderData( HttpDownloader* qq ) : q( qq ), http(0), destination(0), downloaded(false),
+ aborted(false), retrying(false) { }
+
+ HttpDownloader* const q;
+ QNetworkAccessManager manager;
+ QNetworkReply* http;
+ QTemporaryFile* destination;
+ QString destFileName;
+ bool downloaded;
+ bool aborted;
+ bool retrying;
+
+ void shutDown() {
+ disconnect( http, SIGNAL( finished() ), q, SLOT( httpReqFinished() ) );
+ http->deleteLater();
+ http = 0;
+ destination->close();
+ destination->deleteLater();
+ destination = 0;
+
+ }
+};
+
+KDUpdater::HttpDownloader::HttpDownloader(QObject* parent)
+ : KDUpdater::FileDownloader(QLatin1String( "http" ), parent),
+ d ( new HttpDownloaderData( this ) )
+{
+}
+
+KDUpdater::HttpDownloader::~HttpDownloader()
+{
+ if( this->isAutoRemoveDownloadedFile() && !d->destFileName.isEmpty() )
+ QFile::remove(d->destFileName);
+ delete d;
+}
+
+bool KDUpdater::HttpDownloader::canDownload() const
+{
+ // TODO: Check whether the ftp file actually exists or not.
+ return true;
+}
+
+bool KDUpdater::HttpDownloader::isDownloaded() const
+{
+ return d->downloaded;
+}
+
+void KDUpdater::HttpDownloader::doDownload()
+{
+ if( d->downloaded )
+ return;
+
+ if( d->http )
+ return;
+
+ d->http = d->manager.get( QNetworkRequest( url() ) );
+
+ connect( d->http, SIGNAL( readyRead() ), this, SLOT( httpReadyRead() ) );
+ connect( d->http, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( httpReadProgress( qint64, qint64) ) );
+ connect( d->http, SIGNAL( finished() ), this, SLOT( httpReqFinished() ) );
+ connect( d->http, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( httpError( QNetworkReply::NetworkError ) ) );
+
+ /*
+ // In a future update, authentication should also be supported.
+
+ connect(d->http, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
+ this, SLOT(httpProxyAuth(QNetworkProxy,QAuthenticator*)));
+ connect(d->http, SIGNAL(authenticationRequired(QString,QAuthenticator*)),
+ this, SLOT(httpAuth(QString,QAuthenticator*)));
+ */
+
+ // Begin the download
+ d->destination = new QTemporaryFile(this);
+ if ( !d->destination->open() ) {
+ const QString err = d->destination->errorString();
+ d->shutDown();
+ setDownloadAborted( tr("Cannot download %1: Could not create temporary file: %2").arg( url().toString(), err ) );
+ return;
+ }
+}
+
+QString KDUpdater::HttpDownloader::downloadedFileName() const
+{
+ return d->destFileName;
+}
+
+KDUpdater::HttpDownloader* KDUpdater::HttpDownloader::clone( QObject* parent ) const
+{
+ return new HttpDownloader( parent );
+}
+
+void KDUpdater::HttpDownloader::httpReadyRead()
+{
+ static QByteArray buffer( 16384, '\0' );
+ while( d->http->bytesAvailable() )
+ {
+ const qint64 read = d->http->read( buffer.data(), buffer.size() );
+ qint64 written = 0;
+ while( written < read ) {
+ const qint64 numWritten = d->destination->write( buffer.data() + written, read - written );
+ if ( numWritten < 0 ) {
+ const QString err = d->destination->errorString();
+ d->shutDown();
+ setDownloadAborted( tr("Cannot download %1: Writing to temporary file failed: %2").arg( url().toString(), err ) );
+ return;
+ }
+ written += numWritten;
+ }
+ }
+}
+
+void KDUpdater::HttpDownloader::httpError( QNetworkReply::NetworkError )
+{
+ static bool setProxySettings = false;
+ if( !d->retrying && !setProxySettings )
+ {
+ d->shutDown();
+ d->retrying = true;
+ setProxySettings = true;
+
+ // silently force retry with global proxy settings
+ QNetworkProxyFactory::setUseSystemConfiguration( true );
+
+ doDownload();
+ return;
+ }
+ httpDone( true );
+}
+
+void KDUpdater::HttpDownloader::cancelDownload()
+{
+ d->aborted = true;
+ if( d->http )
+ {
+ d->http->abort();
+ httpDone( true );
+ }
+}
+
+void KDUpdater::HttpDownloader::httpDone( bool error )
+{
+ if( error )
+ {
+ QString err;
+ if( d->http )
+ {
+ err = d->http->errorString();
+ d->http->deleteLater();
+ d->http = 0;
+ onError();
+ }
+
+ if( d->aborted )
+ {
+ d->aborted = false;
+ emit downloadCanceled();
+ }
+ else
+ setDownloadAborted( err );
+ }
+ //PENDING: what about the non-error case??
+}
+
+void KDUpdater::HttpDownloader::onError()
+{
+ d->downloaded = false;
+ d->destFileName.clear();
+ delete d->destination;
+ d->destination = 0;
+}
+
+void KDUpdater::HttpDownloader::onSuccess()
+{
+ d->downloaded = true;
+ d->destFileName = d->destination->fileName();
+ d->destination->setAutoRemove( false );
+ delete d->destination;
+ d->destination = 0;
+}
+
+void KDUpdater::HttpDownloader::httpReqFinished()
+{
+ const QVariant redirect = d->http == 0 ? QVariant() : d->http->attribute( QNetworkRequest::RedirectionTargetAttribute );
+ const QUrl redirectUrl = redirect.toUrl();
+ //if ( redirect.isValid() )
+ // redirectUrl = redirect.toUrl();
+ if ( followRedirects() && redirectUrl.isValid() )
+ {
+ // clean the previous download
+ d->http->deleteLater();
+ d->http = 0;
+ d->destination->close();
+ d->destination->deleteLater();
+ d->destination = 0;
+
+ d->http = d->manager.get( QNetworkRequest( redirectUrl ) );
+
+ connect( d->http, SIGNAL( readyRead() ), this, SLOT( httpReadyRead() ) );
+ connect( d->http, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( httpReadProgress( qint64, qint64) ) );
+ connect( d->http, SIGNAL( finished() ), this, SLOT( httpReqFinished() ) );
+ connect( d->http, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( httpError( QNetworkReply::NetworkError ) ) );
+
+ // Begin the download
+ d->destination = new QTemporaryFile(this);
+ d->destination->open(); //PENDING handle error
+ }
+ else
+ {
+ if( d->http == 0 )
+ return;
+ httpReadyRead();
+ d->destination->flush();
+ setDownloadCompleted( d->destination->fileName() );
+ d->http->deleteLater();
+ d->http = 0;
+ }
+}
+
+void KDUpdater::HttpDownloader::httpReadProgress( qint64 done, qint64 total)
+{
+ emit downloadProgress( calcProgress( done, total ) );
+}
+
+class SignatureVerificationDownloader::Private
+{
+ SignatureVerificationDownloader* const q;
+public:
+ explicit Private( FileDownloader* dl, SignatureVerificationDownloader* qq ) : q( qq ), verifier( 0 ), downloader( dl ), sigDownloader( 0 ), actualDownloadDone( false )
+ {
+ Q_ASSERT( downloader );
+ q->connect( downloader.get(), SIGNAL( downloadProgress( double ) ), q, SIGNAL( downloadProgress( double ) ) );
+ q->connect( downloader.get(), SIGNAL(downloadStarted()), q, SLOT(dataDownloadStarted()) );
+ q->connect( downloader.get(), SIGNAL(downloadCompleted()), q, SLOT(dataDownloadCompleted()) );
+ q->connect( downloader.get(), SIGNAL(downloadCanceled()), q, SLOT(dataDownloadCanceled()) );
+ q->connect( downloader.get(), SIGNAL(downloadAborted(QString)), q, SLOT(dataDownloadAborted(QString)) );
+ }
+
+ ~Private()
+ {
+ delete verifier;
+ }
+
+ const SignatureVerifier* verifier;
+ KDAutoPointer< FileDownloader > downloader;
+ KDAutoPointer< FileDownloader > sigDownloader;
+ QUrl signatureUrl;
+ SignatureVerificationResult result;
+ QString downloadedFileName;
+ bool actualDownloadDone : 1;
+};
+
+SignatureVerificationDownloader::SignatureVerificationDownloader( FileDownloader* downloader, QObject* parent ) : FileDownloader( downloader->scheme(), parent ), d( new Private( downloader, this ) )
+{
+}
+
+SignatureVerificationDownloader::~SignatureVerificationDownloader()
+{
+}
+
+QUrl SignatureVerificationDownloader::signatureUrl() const
+{
+ return d->signatureUrl;
+}
+
+void SignatureVerificationDownloader::setSignatureUrl( const QUrl& url )
+{
+ d->signatureUrl = url;
+}
+
+const SignatureVerifier* SignatureVerificationDownloader::signatureVerifier() const {
+ return d->verifier;
+}
+
+void SignatureVerificationDownloader::setSignatureVerifier( const SignatureVerifier* verifier ) {
+ delete d->verifier;
+ d->verifier = verifier ? verifier->clone() : 0;
+}
+
+SignatureVerificationResult SignatureVerificationDownloader::result() const
+{
+ return d->result;
+}
+
+bool SignatureVerificationDownloader::canDownload() const
+{
+ return d->downloader->canDownload();
+}
+
+bool SignatureVerificationDownloader::isDownloaded() const
+{
+ return d->downloader->isDownloaded();
+}
+
+QString SignatureVerificationDownloader::downloadedFileName() const
+{
+ return d->downloadedFileName;
+}
+
+FileDownloader* SignatureVerificationDownloader::clone( QObject* parent ) const
+{
+ return new SignatureVerificationDownloader( d->downloader->clone(), parent );
+}
+
+void SignatureVerificationDownloader::onError()
+{
+ d->sigDownloader.reset();
+ if ( QFile::exists( d->downloadedFileName ) )
+ QFile::remove( d->downloadedFileName );
+}
+
+void SignatureVerificationDownloader::onSuccess()
+{
+ d->sigDownloader.reset();
+}
+
+void SignatureVerificationDownloader::cancelDownload()
+{
+ if ( !d->actualDownloadDone ) {
+ d->downloader->cancelDownload();
+ return;
+ }
+ if ( d->sigDownloader ) {
+ d->sigDownloader->cancelDownload();
+ }
+}
+
+void SignatureVerificationDownloader::doDownload()
+{
+ Q_ASSERT( d->verifier );
+ Q_ASSERT( d->downloader );
+ d->downloader->setUrl( url() );
+ d->downloader->setSha1Sum( sha1Sum() );
+ d->downloader->download();
+}
+
+void SignatureVerificationDownloader::dataDownloadStarted()
+{
+ emit downloadStarted();
+}
+
+void SignatureVerificationDownloader::dataDownloadAborted( const QString& err )
+{
+ setDownloadAborted( err );
+}
+
+void SignatureVerificationDownloader::dataDownloadCanceled()
+{
+ emit downloadCanceled();
+}
+
+static QUrl suggestSignatureUrl( const QUrl& url ) {
+ return url.toString() + QLatin1String(".sig");
+}
+
+void SignatureVerificationDownloader::dataDownloadCompleted()
+{
+ d->downloadedFileName = d->downloader->downloadedFileName();
+ d->actualDownloadDone = true;
+
+ QUrl url = d->signatureUrl;
+ if ( url.isEmpty() )
+ url = suggestSignatureUrl( d->downloader->url() );
+ d->sigDownloader.reset( FileDownloaderFactory::instance().create( url.scheme(), this ) );
+ if ( !d->sigDownloader ) {
+ setDownloadAborted( tr("Could not download signature: scheme %1 not supported").arg( url.scheme() ) );
+ return;
+ }
+ d->sigDownloader->setUrl( url );
+ connect( d->sigDownloader.get(), SIGNAL(downloadCompleted()), this, SLOT(signatureDownloadCompleted()) );
+ connect( d->sigDownloader.get(), SIGNAL(downloadCanceled()), this, SLOT(signatureDownloadCanceled()) );
+ connect( d->sigDownloader.get(), SIGNAL(downloadAborted(QString)), this, SLOT(signatureDownloadAborted(QString)) );
+ d->sigDownloader->download();
+}
+
+void SignatureVerificationDownloader::signatureDownloadAborted( const QString& err )
+{
+ setDownloadAborted( tr("Downloading signature: %1").arg( err ) );
+}
+
+void SignatureVerificationDownloader::signatureDownloadCanceled()
+{
+ emit downloadCanceled();
+}
+
+void SignatureVerificationDownloader::signatureDownloadCompleted()
+{
+ QFile sigFile( d->sigDownloader->downloadedFileName() );
+ if ( !sigFile.open( QIODevice::ReadOnly ) ) {
+ setDownloadAborted( tr("Could not open signature file: %1").arg( sigFile.errorString() ) );
+ return;
+ }
+
+ const QByteArray signature = sigFile.readAll();
+
+ QFile dataFile( d->downloadedFileName );
+ if ( !dataFile.open( QIODevice::ReadOnly ) ) {
+ setDownloadAborted( tr("Could not open file for verification: %1").arg( dataFile.errorString() ) );
+ return;
+ }
+ const QByteArray dataHash = calculateHash(&dataFile, QCryptographicHash::Sha1);
+
+ //const QString sigPath = d->sigDownloader->downloadedFileName();
+ d->result = d->verifier->verify( dataHash, signature );
+ if( ! d->result.isValid() ) {
+ setDownloadAborted( d->result.errorString() );
+ return;
+ }
+ setDownloadCompleted( d->downloadedFileName );
+
+#if 0
+ SignatureVerificationRunnable* runnable = new SignatureVerificationRunnable;
+ runnable->setSignature( signature );
+ runnable->setData( dataFile.release() );
+ runnable->setVerifier( d->verifier );
+ runnable->addResultListener( this, "verificationResult" );
+ QThreadPool::globalInstance()->start( runnable );
+#endif
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.h
new file mode 100644
index 000000000..754917aa8
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_FILE_DOWNLOADER_H
+#define KD_UPDATER_FILE_DOWNLOADER_H
+
+#include "kdupdater.h"
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QUrl>
+#include <QtCore/QCryptographicHash>
+
+namespace KDUpdater
+{
+ KDTOOLS_UPDATER_EXPORT QByteArray calculateHash( QIODevice* device, QCryptographicHash::Algorithm algo );
+ KDTOOLS_UPDATER_EXPORT QByteArray calculateHash( const QString& path, QCryptographicHash::Algorithm algo );
+
+ class HashVerificationJob;
+
+ class KDTOOLS_UPDATER_EXPORT FileDownloader : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY( bool autoRemoveDownloadedFile READ isAutoRemoveDownloadedFile WRITE setAutoRemoveDownloadedFile )
+ Q_PROPERTY( QUrl url READ url WRITE setUrl )
+ Q_PROPERTY( QString scheme READ scheme )
+
+ public:
+ explicit FileDownloader(const QString& scheme, QObject* parent=0);
+ ~FileDownloader();
+
+ void setUrl(const QUrl& url);
+ QUrl url() const;
+
+ void setSha1Sum( const QByteArray& sha1 );
+ QByteArray sha1Sum() const;
+
+ QString errorString() const;
+ QString scheme() const;
+
+ virtual bool canDownload() const = 0;
+ virtual bool isDownloaded() const = 0;
+ virtual QString downloadedFileName() const = 0;
+ virtual FileDownloader* clone( QObject* parent=0 ) const = 0;
+
+ void download();
+
+ void setAutoRemoveDownloadedFile(bool val);
+ bool isAutoRemoveDownloadedFile() const;
+
+ void setFollowRedirects( bool val );
+ bool followRedirects() const;
+
+ public Q_SLOTS:
+ virtual void cancelDownload();
+ void sha1SumVerified( KDUpdater::HashVerificationJob* job );
+
+ protected:
+ virtual void onError() = 0;
+ virtual void onSuccess() = 0;
+
+ Q_SIGNALS:
+ void downloadProgress(double);
+ void downloadStarted();
+ void downloadCanceled();
+
+#ifndef Q_MOC_RUN
+ private:
+#endif
+ void downloadCompleted();
+ void downloadAborted(const QString& errorMessage);
+
+ protected:
+ void setDownloadCompleted( const QString& filepath );
+ void setDownloadAborted( const QString& error );
+
+ private Q_SLOTS:
+ virtual void doDownload() = 0;
+
+ private:
+ struct FileDownloaderData;
+ kdtools::pimpl_ptr<FileDownloaderData> d;
+ };
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader_p.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader_p.h
new file mode 100644
index 000000000..516bc3c3d
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloader_p.h
@@ -0,0 +1,243 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_FILE_DOWNLOADER_P_H
+#define KD_UPDATER_FILE_DOWNLOADER_P_H
+
+#include "kdupdaterfiledownloader.h"
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include <QtCore/QCryptographicHash>
+#include <QtNetwork/QNetworkReply>
+
+class QIODevice;
+
+// these classes are not a part of the public API
+
+namespace KDUpdater
+{
+
+ //TODO make it a KDJob once merged
+ class HashVerificationJob : public QObject
+ {
+ Q_OBJECT
+ public:
+ enum Error {
+ NoError=0,
+ ReadError=128,
+ SumsDifferError
+ };
+
+ explicit HashVerificationJob( QObject* parent=0 );
+ ~HashVerificationJob();
+
+ void setDevice( QIODevice* dev );
+ void setSha1Sum( const QByteArray& data );
+
+ bool hasError() const;
+ int error() const;
+
+ void start();
+
+ Q_SIGNALS:
+ void finished( KDUpdater::HashVerificationJob* );
+
+ private:
+ void emitFinished();
+ /* reimp */ void timerEvent( QTimerEvent* te );
+
+ private:
+ class Private;
+ kdtools::pimpl_ptr<Private> d;
+ };
+
+ class LocalFileDownloader : public FileDownloader
+ {
+ Q_OBJECT
+
+ public:
+ explicit LocalFileDownloader(QObject* parent=0);
+ ~LocalFileDownloader();
+
+ bool canDownload() const;
+ bool isDownloaded() const;
+ QString downloadedFileName() const;
+ /* reimp */ LocalFileDownloader* clone( QObject* parent=0 ) const;
+
+ public Q_SLOTS:
+ void cancelDownload();
+
+ protected:
+ void timerEvent(QTimerEvent* te);
+ /* reimp */ void onError();
+ /* reimp */ void onSuccess();
+
+ private Q_SLOTS:
+ /* reimp */ void doDownload();
+
+ private:
+ struct LocalFileDownloaderData;
+ LocalFileDownloaderData* d;
+ };
+
+ class ResourceFileDownloader : public FileDownloader
+ {
+ Q_OBJECT
+
+ public:
+ explicit ResourceFileDownloader(QObject* parent=0);
+ ~ResourceFileDownloader();
+
+ bool canDownload() const;
+ bool isDownloaded() const;
+ QString downloadedFileName() const;
+ /* reimp */ ResourceFileDownloader* clone( QObject* parent=0 ) const;
+
+ public Q_SLOTS:
+ void cancelDownload();
+
+ protected:
+ void timerEvent(QTimerEvent* te);
+ /* reimp */ void onError();
+ /* reimp */ void onSuccess();
+
+ private Q_SLOTS:
+ /* reimp */ void doDownload();
+
+ private:
+ struct ResourceFileDownloaderData;
+ ResourceFileDownloaderData* d;
+ };
+
+ class FtpDownloader : public FileDownloader
+ {
+ Q_OBJECT
+
+ public:
+ explicit FtpDownloader(QObject* parent=0);
+ ~FtpDownloader();
+
+ bool canDownload() const;
+ bool isDownloaded() const;
+ QString downloadedFileName() const;
+ /* reimp */ FtpDownloader* clone( QObject* parent=0 ) const;
+
+ public Q_SLOTS:
+ void cancelDownload();
+
+ protected:
+ /* reimp */ void onError();
+ /* reimp */ void onSuccess();
+
+ private Q_SLOTS:
+ /* reimp */ void doDownload();
+ void ftpDone(bool error);
+ void ftpCmdStarted(int id);
+ void ftpCmdFinished(int id, bool error);
+ void ftpStateChanged(int state);
+ void ftpDataTransferProgress(qint64 done, qint64 total);
+
+ private:
+ struct FtpDownloaderData;
+ FtpDownloaderData* d;
+ };
+
+ class HttpDownloader : public FileDownloader
+ {
+ Q_OBJECT
+
+ public:
+ explicit HttpDownloader(QObject* parent=0);
+ ~HttpDownloader();
+
+ bool canDownload() const;
+ bool isDownloaded() const;
+ QString downloadedFileName() const;
+ /* reimp */ HttpDownloader* clone( QObject* parent=0 ) const;
+
+ public Q_SLOTS:
+ void cancelDownload();
+
+ protected:
+ /* reimp */ void onError();
+ /* reimp */ void onSuccess();
+
+ private Q_SLOTS:
+ /* reimp */ void doDownload();
+ void httpReadyRead();
+ void httpReadProgress( qint64 done, qint64 total );
+ void httpError( QNetworkReply::NetworkError );
+ void httpDone( bool error );
+ void httpReqFinished();
+
+ private:
+ struct HttpDownloaderData;
+ HttpDownloaderData* d;
+ };
+
+ class SignatureVerificationResult;
+ class SignatureVerifier;
+
+ class SignatureVerificationDownloader : public FileDownloader
+ {
+ Q_OBJECT
+ public:
+ explicit SignatureVerificationDownloader( FileDownloader* downloader, QObject* parent=0 );
+ ~SignatureVerificationDownloader();
+
+ QUrl signatureUrl() const;
+ void setSignatureUrl( const QUrl& url );
+
+ const SignatureVerifier* signatureVerifier() const;
+ void setSignatureVerifier( const SignatureVerifier* verifier );
+
+ SignatureVerificationResult result() const;
+
+ /* reimp */ bool canDownload() const;
+ /* reimp */ bool isDownloaded() const;
+ /* reimp */ QString downloadedFileName() const;
+ /* reimp */ FileDownloader* clone( QObject* parent=0 ) const;
+
+ public Q_SLOTS:
+ /* reimp */ void cancelDownload();
+
+ protected:
+ /* reimp */ void onError();
+ /* reimp */ void onSuccess();
+
+ private Q_SLOTS:
+ /* reimp */ void doDownload();
+ void dataDownloadStarted();
+ void dataDownloadCanceled();
+ void dataDownloadCompleted();
+ void dataDownloadAborted(const QString& errorMessage);
+ void signatureDownloadCanceled();
+ void signatureDownloadCompleted();
+ void signatureDownloadAborted(const QString& errorMessage);
+
+ private:
+ class Private;
+ kdtools::pimpl_ptr<Private> d;
+ };
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp
new file mode 100644
index 000000000..cba271e96
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterfiledownloaderfactory.h"
+#include "kdupdaterfiledownloader_p.h"
+
+#include <cassert>
+
+/*!
+ \internal
+ \ingroup kdupdater
+ \class KDUpdater::FileDownloaderFactory kdupdaterfiledownloaderfactory.h
+ \brief Factory for \ref KDUpdater::FileDownloader
+
+ This class acts as a factory for \ref KDUpdater::FileDownloader. You can register
+ one or more file downloaders with this factory and query them based on their scheme.
+
+ This class follows the singleton design pattern. Only one instance of this class can
+ be created and its reference can be fetched from the \ref instance() method.
+*/
+
+using namespace KDUpdater;
+
+struct FileDownloaderFactory::FileDownloaderFactoryData
+{
+ bool m_followRedirects;
+};
+
+FileDownloaderFactory& FileDownloaderFactory::instance()
+{
+ static KDUpdater::FileDownloaderFactory theFactory;
+ return theFactory;
+}
+
+/*!
+ Constructor
+*/
+FileDownloaderFactory::FileDownloaderFactory()
+ : d ( new FileDownloaderFactoryData )
+{
+ // Register the default file downloader set
+ registerFileDownloader< LocalFileDownloader >( QLatin1String( "file" ) );
+ registerFileDownloader< FtpDownloader >( QLatin1String( "ftp" ) );
+ registerFileDownloader< HttpDownloader >( QLatin1String( "http" ) );
+ registerFileDownloader< ResourceFileDownloader >( QLatin1String( "resource" ) );
+ d->m_followRedirects = false;
+}
+
+void FileDownloaderFactory::setFollowRedirects( bool val )
+{
+ FileDownloaderFactory::instance().d->m_followRedirects = val;
+}
+
+bool FileDownloaderFactory::followRedirects()
+{
+ return FileDownloaderFactory::instance().d->m_followRedirects;
+}
+
+FileDownloaderFactory::~FileDownloaderFactory()
+{
+}
+
+/*!
+ Returns a new instance to the \ref KDUpdater::FileDownloader based whose scheme is equal to the string
+ passed as parameter to this function.
+ \note Ownership of this object remains to the programmer.
+*/
+FileDownloader* FileDownloaderFactory::create( const QString& scheme, QObject* parent ) const
+{
+ return create( scheme, 0, QUrl(), parent );
+}
+
+FileDownloader* FileDownloaderFactory::create( const QString& scheme, const SignatureVerifier* verifier, const QUrl& signatureUrl, QObject* parent ) const
+{
+ FileDownloader* const downloader = KDGenericFactory< FileDownloader >::create( scheme );
+ if( downloader != 0 ) {
+ downloader->setFollowRedirects( d->m_followRedirects );
+ downloader->setParent( parent );
+ }
+ if( !verifier )
+ return downloader;
+
+ SignatureVerificationDownloader* const svdl = new SignatureVerificationDownloader( downloader, parent );
+ svdl->setSignatureVerifier( verifier );
+ svdl->setSignatureUrl( signatureUrl );
+ return svdl;
+}
+
+/*!
+ KDUpdater::FileDownloaderFactory::registerFileDownlooader
+ Registers a new file downloader with the factory. If there is already a downloader with the same scheme,
+ the downloader is replaced. The ownership of the downloader is transfered to the factory.
+*/
+
+/*!
+ Returns the number of file downloaders in the factory.
+*/
+int FileDownloaderFactory::fileDownloaderCount() const
+{
+ return productCount();
+}
+
+/*!
+ Returns a list of schemes supported by this factory, i.e. for which a
+ FileDownloader was registered.
+*/
+QStringList FileDownloaderFactory::supportedSchemes() const
+{
+ return availableProducts();
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h
new file mode 100644
index 000000000..b4c284640
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterfiledownloaderfactory.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_FILE_DOWNLOADER_FACTORY_H
+#define KD_UPDATER_FILE_DOWNLOADER_FACTORY_H
+
+#include "kdupdater.h"
+#include <KDToolsCore/pimpl_ptr.h>
+#include <KDToolsCore/kdgenericfactory.h>
+
+#include <QtCore/QStringList>
+#include <QtCore/QUrl>
+
+class QObject;
+
+namespace KDUpdater
+{
+ class FileDownloader;
+ class SignatureVerifier;
+
+ class KDTOOLS_UPDATER_EXPORT FileDownloaderFactory : public KDGenericFactory< FileDownloader >
+ {
+ Q_DISABLE_COPY( FileDownloaderFactory )
+ public:
+ static FileDownloaderFactory& instance();
+ ~FileDownloaderFactory();
+
+ template< typename T >
+ void registerFileDownloader( const QString& scheme )
+ {
+ registerProduct< T >( scheme );
+ }
+ QStringList supportedSchemes() const;
+
+ int fileDownloaderCount() const;
+ FileDownloader* create( const QString& scheme, QObject* parent ) const;
+ FileDownloader* create( const QString& scheme, const SignatureVerifier* verifier = 0, const QUrl& signatureUrl = QUrl(), QObject* parent = 0 ) const;
+ static void setFollowRedirects( bool val );
+ static bool followRedirects();
+
+ private:
+ FileDownloaderFactory();
+
+ private:
+ struct FileDownloaderFactoryData;
+ kdtools::pimpl_ptr<FileDownloaderFactoryData> d;
+ };
+}
+
+
+#endif
+
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp
new file mode 100644
index 000000000..c6ce195ea
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.cpp
@@ -0,0 +1,566 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterpackagesinfo.h"
+#include "kdupdaterapplication.h"
+
+#include <QFileInfo>
+#include <QDomDocument>
+#include <QDomElement>
+#include <QVector>
+
+using namespace KDUpdater;
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::PackagesInfo kdupdaterpackagesinfo.h KDUpdaterPackagesInfo
+ \brief Provides access to information about packages installed on the application side.
+
+ This class parses the XML package file specified via the setFileName() method and
+ provides access to the the information defined within the package file through an
+ easy to use API. You can:
+ \li get application name via the \ref applicationName() method
+ \li get application version via the \ref applicationVersion() method
+ \li get information about the number of packages installed and their meta-data via the
+ \ref packageInfoCount() and \ref packageInfo() methods.
+
+ Instances of this class cannot be created. Each instance of \ref KDUpdater::Application
+ has one instance of this class associated with it. You can fetch a pointer to an instance
+ of this class for an application via the \ref KDUpdater::Application::packagesInfo()
+ method.
+*/
+
+/*! \enum UpdatePackagesInfo::Error
+ * Error codes related to retrieving update sources
+ */
+
+/*! \var UpdatePackagesInfo::Error UpdatePackagesInfo::NoError
+ * No error occurred
+ */
+
+/*! \var UpdatePackagesInfo::Error UpdatePackagesInfo::NotYetReadError
+ * The package information was not parsed yet from the XML file
+ */
+
+/*! \var UpdatePackagesInfo::Error UpdatePackagesInfo::CouldNotReadPackageFileError
+ * the specified update source file could not be read (does not exist or not readable)
+ */
+
+/*! \var UpdatePackagesInfo::Error UpdatePackagesInfo::InvalidXmlError
+ * The source file contains invalid XML.
+ */
+
+/*! \var UpdatePackagesInfo::Error UpdatePackagesInfo::InvalidContentError
+ * The source file contains valid XML, but does not match the expected format for package descriptions
+ */
+
+struct PackagesInfo::PackagesInfoData
+{
+ PackagesInfoData( PackagesInfo* qq ) :
+ q( qq ),
+ application(0),
+ error(PackagesInfo::NotYetReadError),
+ compatLevel(-1),
+ modified( false )
+ {}
+ PackagesInfo* q;
+ Application* application;
+ QString errorMessage;
+ PackagesInfo::Error error;
+ QString fileName;
+ QString applicationName;
+ QString applicationVersion;
+ int compatLevel;
+ bool modified;
+
+ QVector<PackageInfo> packageInfoList;
+
+ void addPackageFrom(const QDomElement& packageE);
+ void setInvalidContentError( const QString& detail );
+};
+
+void PackagesInfo::PackagesInfoData::setInvalidContentError(const QString& detail)
+{
+ error = PackagesInfo::InvalidContentError;
+ errorMessage = tr("%1 contains invalid content: %2").arg(fileName, detail);
+}
+
+/*!
+ \internal
+*/
+PackagesInfo::PackagesInfo(Application* application)
+ : QObject(application),
+ d( new PackagesInfoData( this ) )
+{
+ d->application = application;
+}
+
+/*!
+ \internal
+*/
+PackagesInfo::~PackagesInfo()
+{
+ writeToDisk();
+ delete d;
+}
+
+/*!
+ Returns a pointer to the application, whose package information this class provides
+ access to.
+*/
+Application* PackagesInfo::application() const
+{
+ return d->application;
+}
+
+/*!
+ Returns true if the PackagesInfo are valid else false is returned in which case
+ the \a errorString() method can be used to receive a describing error message.
+*/
+bool PackagesInfo::isValid() const
+{
+ return d->error == NoError;
+}
+
+/*!
+ Returns a human-readable error message.
+*/
+QString PackagesInfo::errorString() const
+{
+ return d->errorMessage;
+}
+
+PackagesInfo::Error PackagesInfo::error() const
+{
+ return d->error;
+}
+
+/*!
+ Sets the complete file name of the Packages.xml file. The function also issues a call to
+ \ref refresh() to reload package information from the XML file.
+
+ \sa KDUpdater::Application::setPackagesXMLFileName()
+*/
+void PackagesInfo::setFileName(const QString& fileName)
+{
+ if( d->fileName == fileName )
+ return;
+
+ d->fileName = fileName;
+ refresh();
+}
+
+/*!
+ Returns the name of the Packages.xml file that this class referred to.
+*/
+QString PackagesInfo::fileName() const
+{
+ return d->fileName;
+}
+
+/*!
+ Sets the application name. By default this is the name specified in
+ the ApplicationName XML element of the Packages.xml file.
+*/
+void PackagesInfo::setApplicationName(const QString& name)
+{
+ d->applicationName = name;
+ d->modified = true;
+}
+
+/*!
+ Returns the application name.
+*/
+QString PackagesInfo::applicationName() const
+{
+ return d->applicationName;
+}
+
+/*!
+ Sets the application version. By default this is the version specified
+ in the ApplicationVersion XML element of Packages.xml.
+*/
+void PackagesInfo::setApplicationVersion(const QString& version)
+{
+ d->applicationVersion = version;
+ d->modified = true;
+}
+
+/*!
+ Returns the application version.
+*/
+QString PackagesInfo::applicationVersion() const
+{
+ return d->applicationVersion;
+}
+
+/*!
+ Returns the number of \ref KDUpdater::PackageInfo objects contained in this class.
+*/
+int PackagesInfo::packageInfoCount() const
+{
+ return d->packageInfoList.count();
+}
+
+/*!
+ Returns the package info structure (\ref KDUpdater::PackageInfo) at index. If index is
+ out of range then an empty package info structure is returned.
+*/
+PackageInfo PackagesInfo::packageInfo(int index) const
+{
+ if( index < 0 || index >= d->packageInfoList.count() )
+ return PackageInfo();
+
+ return d->packageInfoList[index];
+}
+
+/*!
+ Returns the compat level of the application.
+*/
+int PackagesInfo::compatLevel() const
+{
+ return d->compatLevel;
+}
+
+/*!
+ This function returns the index of the package whose name is \c pkgName. If no such
+ package was found, this function returns -1.
+*/
+int PackagesInfo::findPackageInfo(const QString& pkgName) const
+{
+ for(int i=0; i<d->packageInfoList.count(); i++)
+ {
+ if( d->packageInfoList[i].name == pkgName )
+ return i;
+ }
+
+ return -1;
+}
+
+/*!
+ Returns all package info structures.
+*/
+QVector<PackageInfo> PackagesInfo::packageInfos() const
+{
+ return d->packageInfoList;
+}
+
+/*!
+ This function re-reads the Packages.xml file and updates itself. Changes to \ref applicationName()
+ and \ref applicationVersion() are lost after this function returns. The function emits a reset()
+ signal after completion.
+*/
+void PackagesInfo::refresh()
+{
+ // First clear internal variables
+ d->applicationName.clear();
+ d->applicationVersion.clear();
+ d->packageInfoList.clear();
+ d->modified = false;
+
+ QFile file( d->fileName );
+
+ // if the file does not exist then we just skip the reading
+ if( !file.exists() )
+ {
+ d->error = NoError;
+ d->errorMessage.clear();
+ emit reset();
+ return;
+ }
+
+ // Open Packages.xml
+ if( !file.open(QFile::ReadOnly) )
+ {
+ d->error = CouldNotReadPackageFileError;
+ d->errorMessage = tr("Could not read \"%1\"").arg(d->fileName);
+ emit reset();
+ return;
+ }
+
+ // Parse the XML document
+ QDomDocument doc;
+ QString parseErrorMessage;
+ int parseErrorLine;
+ int parseErrorColumn;
+ if( !doc.setContent( &file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn ) )
+ {
+ d->error = InvalidXmlError;
+ d->errorMessage = tr("Parse error in %1 at %2, %3: %4")
+ .arg(d->fileName,
+ QString::number(parseErrorLine),
+ QString::number(parseErrorColumn),
+ parseErrorMessage);
+ emit reset();
+ return;
+ }
+ file.close();
+
+ // Now populate information from the XML file.
+ QDomElement rootE = doc.documentElement();
+ if( rootE.tagName() != QLatin1String( "Packages" ) )
+ {
+ d->setInvalidContentError(tr("root element %1 unexpected, should be \"Packages\"").arg(rootE.tagName()));
+ emit reset();
+ return;
+ }
+
+ QDomNodeList childNodes = rootE.childNodes();
+ for(int i=0; i<childNodes.count(); i++)
+ {
+ QDomNode childNode = childNodes.item(i);
+ QDomElement childNodeE = childNode.toElement();
+ if( childNodeE.isNull() )
+ continue;
+
+ if( childNodeE.tagName() == QLatin1String( "ApplicationName" ) )
+ d->applicationName = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "ApplicationVersion" ) )
+ d->applicationVersion = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "Package" ) )
+ d->addPackageFrom( childNodeE );
+ else if( childNodeE.tagName() == QLatin1String( "CompatLevel" ) )
+ d->compatLevel = childNodeE.text().toInt();
+ }
+
+ d->error = NoError;
+ d->errorMessage.clear();
+ emit reset();
+}
+
+/*!
+ Sets the application compat level.
+*/
+void PackagesInfo::setCompatLevel(int level)
+{
+ d->compatLevel = level;
+ d->modified = true;
+}
+
+/*!
+ Marks the package with \a name as installed in \a version.
+ */
+bool PackagesInfo::installPackage( const QString& name, const QString& version, const QString& title, const QString& description
+ , const QStringList& dependencies, bool forcedInstallation, bool virtualComp, quint64 uncompressedSize )
+{
+ if( findPackageInfo( name ) != -1 )
+ return updatePackage( name, version, QDate::currentDate() );
+
+ PackageInfo info;
+ info.name = name;
+ info.version = version;
+ info.installDate = QDate::currentDate();
+ info.title = title;
+ info.description = description;
+ info.dependencies = dependencies;
+ info.forcedInstallation = forcedInstallation;
+ info.virtualComp = virtualComp;
+ info.uncompressedSize = uncompressedSize;
+ d->packageInfoList.push_back( info );
+ d->modified = true;
+ return true;
+}
+
+/*!
+ Update the package.
+*/
+bool PackagesInfo::updatePackage(const QString &name,
+ const QString &version,
+ const QDate &date)
+{
+ int index = findPackageInfo(name);
+
+ if (index==-1) return false;
+
+ d->packageInfoList[index].version = version;
+ d->packageInfoList[index].lastUpdateDate = date;
+ d->modified = true;
+ return true;
+}
+
+/*!
+ Remove the package with \a name.
+ */
+bool PackagesInfo::removePackage( const QString& name )
+{
+ const int index = findPackageInfo( name );
+ if( index == -1 )
+ return false;
+
+ d->packageInfoList.remove( index );
+ d->modified = true;
+ return true;
+}
+
+static void addTextChildHelper(QDomNode *node,
+ const QString &tag,
+ const QString &text)
+{
+ QDomElement domElement = node->ownerDocument().createElement(tag);
+ QDomText domText = node->ownerDocument().createTextNode(text);
+
+ domElement.appendChild(domText);
+ node->appendChild(domElement);
+}
+
+void PackagesInfo::writeToDisk()
+{
+ if( d->modified && ( !d->packageInfoList.isEmpty() || QFile::exists( d->fileName ) ) )
+ {
+ QDomDocument doc;
+ QDomElement root = doc.createElement(QLatin1String( "Packages") ) ;
+ doc.appendChild(root);
+
+ addTextChildHelper(&root, QLatin1String( "ApplicationName" ), d->applicationName);
+ addTextChildHelper(&root, QLatin1String( "ApplicationVersion" ), d->applicationVersion);
+ if (d->compatLevel!=-1) {
+ addTextChildHelper(&root, QLatin1String( "CompatLevel" ), QString::number(d->compatLevel));
+ }
+
+ Q_FOREACH (const PackageInfo &info, d->packageInfoList) {
+ QDomElement package = doc.createElement( QLatin1String( "Package" ) );
+
+ addTextChildHelper( &package, QLatin1String( "Name" ), info.name );
+ addTextChildHelper( &package, QLatin1String( "Pixmap" ), info.pixmap );
+ addTextChildHelper( &package, QLatin1String( "Title" ), info.title );
+ addTextChildHelper( &package, QLatin1String( "Description" ), info.description );
+ addTextChildHelper( &package, QLatin1String( "Version" ), info.version );
+ addTextChildHelper( &package, QLatin1String( "LastUpdateDate" ), info.lastUpdateDate.toString( Qt::ISODate ) );
+ addTextChildHelper( &package, QLatin1String( "InstallDate" ), info.installDate.toString( Qt::ISODate) );
+ addTextChildHelper( &package, QLatin1String( "Size" ), QString::number( info.uncompressedSize ) );
+ QString assembledDependencies = QLatin1String( "" );
+ Q_FOREACH( const QString & val, info.dependencies ){
+ assembledDependencies += val + QLatin1String( "," );
+ }
+ if ( info.dependencies.count() > 0 )
+ assembledDependencies.chop( 1 );
+ addTextChildHelper( &package, QLatin1String( "Dependencies" ), assembledDependencies );
+ if ( info.forcedInstallation )
+ addTextChildHelper( &package, QLatin1String( "ForcedInstallation" ), QLatin1String( "true" ) );
+ if ( info.virtualComp )
+ addTextChildHelper( &package, QLatin1String( "Virtual" ), QLatin1String( "true" ) );
+
+ root.appendChild(package);
+ }
+
+ // Open Packages.xml
+ QFile file( d->fileName );
+ if( !file.open(QFile::WriteOnly) ) {
+ return;
+ }
+
+ file.write(doc.toByteArray(4));
+ file.close();
+ d->modified = false;
+ }
+}
+
+void PackagesInfo::PackagesInfoData::addPackageFrom(const QDomElement& packageE)
+{
+ if( packageE.isNull() )
+ return;
+
+ QDomNodeList childNodes = packageE.childNodes();
+ if(childNodes.count() == 0)
+ return;
+
+ PackageInfo info;
+ info.forcedInstallation = false;
+ info.virtualComp = false;
+ for(int i=0; i<childNodes.count(); i++)
+ {
+ QDomNode childNode = childNodes.item(i);
+ QDomElement childNodeE = childNode.toElement();
+ if( childNodeE.isNull() )
+ continue;
+
+ if( childNodeE.tagName() == QLatin1String( "Name" ) )
+ info.name = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "Pixmap" ) )
+ info.pixmap = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "Title" ) )
+ info.title = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "Description" ) )
+ info.description = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "Version" ) )
+ info.version = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "Virtual" ) )
+ info.virtualComp = childNodeE.text().toLower() == QLatin1String( "true" ) ? true : false;
+ else if( childNodeE.tagName() == QLatin1String( "Size" ) )
+ info.uncompressedSize = childNodeE.text().toULongLong();
+ else if( childNodeE.tagName() == QLatin1String( "Dependencies" ) )
+ info.dependencies = childNodeE.text().split( QLatin1String( "," ) );
+ else if( childNodeE.tagName() == QLatin1String( "ForcedInstallation" ) )
+ info.forcedInstallation = childNodeE.text().toLower() == QLatin1String( "true" ) ? true : false;
+ else if( childNodeE.tagName() == QLatin1String( "LastUpdateDate" ) )
+ info.lastUpdateDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
+ else if( childNodeE.tagName() == QLatin1String( "InstallDate" ) )
+ info.installDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
+ }
+
+ this->packageInfoList.append( info );
+}
+
+/*!
+ \fn void KDUpdater::PackagesInfo::reset()
+
+ This signal is emitted whenever the contents of this class is refreshed, usually from within
+ the \ref refresh() slot.
+*/
+
+/*!
+ \ingroup kdupdater
+ \struct KDUpdater::PackageInfo kdupdaterpackagesinfo.h KDUpdaterPackageInfo
+ \brief Describes a single installed package in the application.
+
+ This structure contains information about a single installed package in the application.
+ The information contained in this structure corresponds to the information described
+ by the Package XML element in Packages.xml
+*/
+
+/*!
+ \var QString KDUpdater::PackageInfo::name
+*/
+
+/*!
+ \var QString KDUpdater::PackageInfo::pixmap
+*/
+
+/*!
+ \var QString KDUpdater::PackageInfo::title
+*/
+
+/*!
+ \var QString KDUpdater::PackageInfo::description
+*/
+
+/*!
+ \var QString KDUpdater::PackageInfo::version
+*/
+
+/*!
+ \var QDate KDUpdater::PackageInfo::lastUpdateDate
+*/
+
+/*!
+ \var QDate KDUpdater::PackageInfo::installDate
+*/
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.h
new file mode 100644
index 000000000..8b38dd8d2
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesinfo.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_PACKAGES_INFO_H
+#define KD_UPDATER_PACKAGES_INFO_H
+
+#include "kdupdater.h"
+#include <QObject>
+#include <QDate>
+#include <QString>
+#include <QStringList>
+#include <QVariant>
+
+namespace KDUpdater
+{
+ class Application;
+ class UpdateInstaller;
+
+ struct KDTOOLS_UPDATER_EXPORT PackageInfo
+ {
+ QString name;
+ QString pixmap;
+ QString title;
+ QString description;
+ QString version;
+ QStringList dependencies;
+ QStringList translations;
+ QDate lastUpdateDate;
+ QDate installDate;
+ bool forcedInstallation;
+ bool virtualComp;
+ quint64 uncompressedSize;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT PackagesInfo : public QObject
+ {
+ Q_OBJECT
+
+ public:
+ ~PackagesInfo();
+
+ enum Error
+ {
+ NoError=0,
+ NotYetReadError,
+ CouldNotReadPackageFileError,
+ InvalidXmlError,
+ InvalidContentError
+ };
+
+ Application* application() const;
+
+ bool isValid() const;
+ QString errorString() const;
+ Error error() const;
+
+ void setFileName(const QString& fileName);
+ QString fileName() const;
+
+ void setApplicationName(const QString& name);
+ QString applicationName() const;
+
+ void setApplicationVersion(const QString& version);
+ QString applicationVersion() const;
+
+ int packageInfoCount() const;
+ PackageInfo packageInfo(int index) const;
+ int findPackageInfo(const QString& pkgName) const;
+ QVector<KDUpdater::PackageInfo> packageInfos() const;
+ void writeToDisk();
+
+ int compatLevel() const;
+ void setCompatLevel(int level);
+
+ bool installPackage( const QString& pkgName, const QString& version, const QString& title = QString(), const QString& description = QString()
+ , const QStringList& dependencies = QStringList(), bool forcedInstallation = false, bool virtualComp = false, quint64 uncompressedSize = 0 );
+ bool updatePackage(const QString &pkgName, const QString &version, const QDate &date );
+ bool removePackage( const QString& pkgName );
+
+ public Q_SLOTS:
+ void refresh();
+
+ Q_SIGNALS:
+ void reset();
+
+ protected:
+ explicit PackagesInfo( Application * application=0 );
+
+ private:
+ friend class Application;
+ friend class UpdateInstaller;
+ struct PackagesInfoData;
+ PackagesInfoData* d;
+ };
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.cpp
new file mode 100644
index 000000000..4943c7b72
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterpackagesview.h"
+#include "kdupdaterpackagesinfo.h"
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::PackagesView kdupdaterpackagesview.h KDUpdaterPackagesView
+ \brief A widget that can show packages contained in \ref KDUpdater::PackagesInfo
+
+ \ref KDUpdater::PackagesInfo, associated with \ref KDUpdater::Application, contains
+ information about all the packages installed in the application. This widget helps view the packages
+ in a list.
+
+ \image html packagesview.jpg
+
+ To use this widget, just create an instance and pass to \ref setPackageInfo() a pointer to
+ \ref KDUpdater::PackagesInfo whose information you want this widget to show.
+*/
+
+struct KDUpdater::PackagesView::PackagesViewData
+{
+ PackagesViewData( PackagesView* qq ) :
+ q( qq ),
+ packagesInfo(0)
+ {}
+
+ PackagesView* q;
+ PackagesInfo* packagesInfo;
+};
+
+/*!
+ Constructor.
+*/
+KDUpdater::PackagesView::PackagesView(QWidget* parent)
+ : QTreeWidget(parent),
+ d ( new PackagesViewData( this ) )
+{
+
+ setColumnCount(5);
+ setHeaderLabels( QStringList() << tr("Name") << tr("Title")
+ << tr("Description") << tr("Version")
+ << tr("Last Updated") );
+ setRootIsDecorated(false);
+}
+
+/*!
+ Destructor
+*/
+KDUpdater::PackagesView::~PackagesView()
+{
+ delete d;
+}
+
+/*!
+ Sets the package info whose information this widget should show.
+
+ \code
+ KDUpdater::Application application;
+
+ KDUpdater::PackagesView packageView;
+ packageView.setPackageInfo( application.packagesInfo() );
+ packageView.show();
+ \endcode
+
+*/
+void KDUpdater::PackagesView::setPackageInfo(KDUpdater::PackagesInfo* packagesInfo)
+{
+ if( d->packagesInfo == packagesInfo )
+ return;
+
+ if(d->packagesInfo)
+ disconnect(d->packagesInfo, 0, this, 0);
+
+ d->packagesInfo = packagesInfo;
+ if(d->packagesInfo)
+ connect(d->packagesInfo, SIGNAL(reset()), this, SLOT(refresh()));
+
+ refresh();
+}
+
+/*!
+ Returns a pointer to the package info whose information this widget is showing.
+*/
+KDUpdater::PackagesInfo* KDUpdater::PackagesView::packagesInfo() const
+{
+ return d->packagesInfo;
+}
+
+/*!
+ This slot reloads package information from the \ref KDUpdater::PackagesInfo associated
+ with this widget.
+
+ \note By default, this slot is connected to the \ref KDUpdater::PackagesInfo::reset()
+ signal in \ref setPackageInfo()
+*/
+void KDUpdater::PackagesView::refresh()
+{
+ this->clear();
+ if( !d->packagesInfo )
+ return;
+
+ Q_FOREACH(const KDUpdater::PackageInfo& info, d->packagesInfo->packageInfos())
+ {
+ QTreeWidgetItem* item = new QTreeWidgetItem(this);
+ item->setText(0, info.name);
+ item->setText(1, info.title);
+ item->setText(2, info.description);
+ item->setText(3, info.version);
+ item->setText(4, info.lastUpdateDate.toString());
+ }
+
+ resizeColumnToContents(0);
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.h
new file mode 100644
index 000000000..8f42b1e19
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterpackagesview.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_PACKAGES_VIEW_H
+#define KD_UPDATER_PACKAGES_VIEW_H
+
+#include "kdupdater.h"
+#include <QTreeWidget>
+
+namespace KDUpdater
+{
+ class PackagesInfo;
+
+ class KDTOOLS_UPDATER_EXPORT PackagesView : public QTreeWidget
+ {
+ Q_OBJECT
+
+ public:
+ explicit PackagesView(QWidget* parent=0);
+ ~PackagesView();
+
+ void setPackageInfo(PackagesInfo* packageInfo);
+ PackagesInfo* packagesInfo() const;
+
+ public Q_SLOTS:
+ void refresh();
+
+ private:
+ struct PackagesViewData;
+ PackagesViewData* d;
+ };
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp
new file mode 100644
index 000000000..0b1f61a57
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdatersignatureverificationresult.h"
+
+#include <QSharedData>
+#include <QString>
+
+#include <algorithm>
+
+using namespace KDUpdater;
+
+class SignatureVerificationResult::Private : public QSharedData {
+public:
+ Private() : QSharedData(), validity( SignatureVerificationResult::UnknownValidity ) {
+ }
+ Private( const Private& other ) : QSharedData( other ), validity( other.validity ), errorString( other.errorString ) {
+ }
+
+ bool operator==( const Private& other ) const {
+ return validity == other.validity && errorString == other.errorString;
+ }
+
+ SignatureVerificationResult::Validity validity;
+ QString errorString;
+};
+
+SignatureVerificationResult::SignatureVerificationResult( Validity validity )
+ : d( new Private )
+{
+ setValidity( validity );
+}
+
+SignatureVerificationResult::SignatureVerificationResult( const SignatureVerificationResult& other ) : d( other.d ) {
+}
+
+SignatureVerificationResult::~SignatureVerificationResult() {
+}
+
+SignatureVerificationResult& SignatureVerificationResult::operator=( const SignatureVerificationResult& other ) {
+ SignatureVerificationResult copy( other );
+ std::swap( d, copy.d );
+ return *this;
+}
+
+bool SignatureVerificationResult::operator==( const SignatureVerificationResult& other ) const {
+ return *d == *other.d;
+}
+
+bool SignatureVerificationResult::isValid() const {
+ return d->validity == ValidSignature;
+}
+
+SignatureVerificationResult::Validity SignatureVerificationResult::validity() const {
+ return d->validity;
+}
+
+void SignatureVerificationResult::setValidity( Validity validity ) {
+ d->validity = validity;
+}
+
+QString SignatureVerificationResult::errorString() const {
+ return d->errorString;
+}
+
+void SignatureVerificationResult::setErrorString( const QString& errorString ) {
+ d->errorString = errorString;
+}
+
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.h
new file mode 100644
index 000000000..5319d35f3
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationresult.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_SIGNATUREVERIFICATIONRESULT_H
+#define KD_UPDATER_SIGNATUREVERIFICATIONRESULT_H
+
+#include "kdupdater.h"
+
+#include <QtCore/QMetaType>
+#include <QtCore/QSharedDataPointer>
+
+class QString;
+
+namespace KDUpdater {
+ class KDTOOLS_UPDATER_EXPORT SignatureVerificationResult {
+ public:
+ enum Validity {
+ ValidSignature=0,
+ UnknownValidity,
+ InvalidSignature,
+ BadSignature
+ };
+
+ explicit SignatureVerificationResult( Validity validity = UnknownValidity );
+ SignatureVerificationResult( const SignatureVerificationResult& other );
+ ~SignatureVerificationResult();
+
+ SignatureVerificationResult& operator=( const SignatureVerificationResult& other );
+ bool operator==( const SignatureVerificationResult& other ) const;
+
+ bool isValid() const;
+ Validity validity() const;
+ void setValidity( Validity validity );
+
+ QString errorString() const;
+ void setErrorString( const QString& errorString );
+
+ private:
+ class Private;
+ QSharedDataPointer<Private> d;
+ };
+}
+
+Q_DECLARE_METATYPE( KDUpdater::SignatureVerificationResult )
+
+#endif // KD_UPDATER_SIGNATUREVERIFICATIONRESULT_H
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp
new file mode 100644
index 000000000..19c6337e4
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdatersignatureverificationrunnable.h"
+#include "kdupdatersignatureverifier.h"
+#include "kdupdatersignatureverificationresult.h"
+
+#include <QByteArray>
+#include <QIODevice>
+#include <QMetaObject>
+#include <QObject>
+#include <QPointer>
+#include <QThreadPool>
+#include <QVariant>
+#include <QVector>
+
+#include <cassert>
+
+using namespace KDUpdater;
+
+class Runnable::Private {
+public:
+ QVector<QObject*> receivers;
+ QVector<QByteArray> methods;
+};
+
+Runnable::Runnable() : QRunnable(), d( new Private ) {
+}
+
+Runnable::~Runnable() {
+}
+
+
+void Runnable::addResultListener( QObject* receiver, const char* method ) {
+ d->receivers.push_back( receiver );
+ d->methods.push_back( QByteArray( method ) );
+}
+
+void Runnable::emitResult( const QGenericArgument& arg0,
+ const QGenericArgument& arg1,
+ const QGenericArgument& arg2,
+ const QGenericArgument& arg3,
+ const QGenericArgument& arg4,
+ const QGenericArgument& arg5,
+ const QGenericArgument& arg6,
+ const QGenericArgument& arg7,
+ const QGenericArgument& arg8,
+ const QGenericArgument& arg9 ) {
+ assert( d->receivers.size() == d->methods.size() );
+ for ( int i = 0; i < d->receivers.size(); ++i ) {
+ QMetaObject::invokeMethod( d->receivers[i],
+ d->methods[i].constData(),
+ Qt::QueuedConnection,
+ arg0,
+ arg1,
+ arg2,
+ arg3,
+ arg4,
+ arg5,
+ arg6,
+ arg7,
+ arg8,
+ arg9 );
+ }
+}
+
+class SignatureVerificationRunnable::Private {
+public:
+ Private() : verifier( 0 ) {}
+ const SignatureVerifier* verifier;
+ QPointer<QIODevice> device;
+ QByteArray signature;
+};
+
+SignatureVerificationRunnable::SignatureVerificationRunnable() : Runnable(), d( new Private ) {
+}
+
+SignatureVerificationRunnable::~SignatureVerificationRunnable() {
+}
+
+const SignatureVerifier* SignatureVerificationRunnable::verifier() const {
+ return d->verifier;
+}
+
+void SignatureVerificationRunnable::setVerifier( const SignatureVerifier* verifier ) {
+ delete d->verifier;
+ d->verifier = verifier ? verifier->clone() : 0;
+}
+
+QByteArray SignatureVerificationRunnable::signature() const {
+ return d->signature;
+}
+
+void SignatureVerificationRunnable::setSignature( const QByteArray& sig ) {
+ d->signature = sig;
+}
+
+QIODevice* SignatureVerificationRunnable::data() const {
+ return d->device;
+}
+
+void SignatureVerificationRunnable::setData( QIODevice* device ) {
+ d->device = device;
+}
+
+
+void SignatureVerificationRunnable::run() {
+ QThreadPool::globalInstance()->releaseThread();
+ const SignatureVerificationResult result = d->verifier->verify( d->device->readAll(), d->signature );
+ QThreadPool::globalInstance()->reserveThread();
+ delete d->verifier;
+ delete d->device;
+ emitResult( Q_ARG( KDUpdater::SignatureVerificationResult, result ) );
+}
+
+
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h
new file mode 100644
index 000000000..afc201bea
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverificationrunnable.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KDUPDATERSIGNATUREVERIFICATIONJOB_H
+#define KDUPDATERSIGNATUREVERIFICATIONJOB_H
+
+#include <KDToolsCore/pimpl_ptr.h>
+#include <QtCore/QGenericArgument>
+#include <QtCore/QRunnable>
+
+class QByteArray;
+class QIODevice;
+class QObject;
+template <typename T> class QVector;
+
+namespace KDUpdater {
+ class SignatureVerifier;
+ class SignatureVerificationResult;
+
+ class Runnable : public QRunnable {
+ public:
+ Runnable();
+ ~Runnable();
+
+ void addResultListener( QObject* receiver, const char* method );
+
+ protected:
+ void emitResult( const QGenericArgument& arg0=QGenericArgument( 0 ),
+ const QGenericArgument& arg1=QGenericArgument(),
+ const QGenericArgument& arg2=QGenericArgument(),
+ const QGenericArgument& arg3=QGenericArgument(),
+ const QGenericArgument& arg4=QGenericArgument(),
+ const QGenericArgument& arg5=QGenericArgument(),
+ const QGenericArgument& arg6=QGenericArgument(),
+ const QGenericArgument& arg7=QGenericArgument(),
+ const QGenericArgument& arg8=QGenericArgument(),
+ const QGenericArgument& arg9=QGenericArgument() );
+
+ private:
+ class Private;
+ kdtools::pimpl_ptr<Private> d;
+ };
+
+ class SignatureVerificationRunnable : public Runnable {
+ public:
+ explicit SignatureVerificationRunnable();
+ ~SignatureVerificationRunnable();
+
+ const SignatureVerifier* verifier() const;
+ void setVerifier( const SignatureVerifier* verifier );
+
+ QByteArray signature() const;
+ void setSignature( const QByteArray& sig );
+
+ QIODevice* data() const;
+ void setData( QIODevice* device );
+
+ /* reimp */ void run();
+
+ private:
+ class Private;
+ kdtools::pimpl_ptr<Private> d;
+ };
+}
+
+#endif // KDUPDATERSIGNATUREVERIFICATIONJOB_H
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.cpp
new file mode 100644
index 000000000..28cba7098
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdatersignatureverifier.h"
+#include "kdupdatersignatureverificationresult.h"
+
+#include <QFile>
+
+using namespace KDUpdater;
+
+SignatureVerifier::~SignatureVerifier()
+{
+}
+
+SignatureVerificationResult SignatureVerifier::verify( const QString& dataFile, const QString& signatureFile ) const
+{
+ QFile dFile( dataFile );
+ QFile sFile( signatureFile );
+
+ if( !dFile.open( QIODevice::ReadOnly ) )
+ return SignatureVerificationResult();
+
+ if( !sFile.open( QIODevice::ReadOnly ) )
+ return SignatureVerificationResult( SignatureVerificationResult::BadSignature );
+
+ return verify( dFile.readAll(), sFile.readAll() );
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.h
new file mode 100644
index 000000000..dfb8cbddb
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatersignatureverifier.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_SIGNATUREVERIFIER_H
+#define KD_UPDATER_SIGNATUREVERIFIER_H
+
+#include "kdupdater.h"
+
+class QByteArray;
+class QIODevice;
+class QString;
+
+namespace KDUpdater {
+
+ class SignatureVerificationResult;
+
+ class KDTOOLS_UPDATER_EXPORT SignatureVerifier {
+ public:
+ virtual ~SignatureVerifier();
+ virtual SignatureVerifier* clone() const = 0;
+ virtual SignatureVerificationResult verify( const QByteArray &data, const QByteArray& signature ) const = 0;
+ virtual SignatureVerificationResult verify( const QString& dataFile, const QString& signatureFile ) const;
+ virtual QString type() const = 0;
+ };
+}
+
+#endif // KD_UPDATER_SIGNATUREVERIFIER_H
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.cpp
new file mode 100644
index 000000000..ee8d5aca8
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.cpp
@@ -0,0 +1,440 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdatertask.h"
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::Task kdupdatertask.h KDUpdaterTask
+ \brief Base class for all task classes in KDUpdater
+
+ This class is the base class for all task classes in KDUpdater. Task is an activity that
+ occupies certain amount of execution time. It can be started, stopped (or canceled), paused and
+ resumed. Tasks can report progress and error messages which an application can show in any
+ sort of UI. The KDUpdater::Task class provides a common interface for dealing with all kinds of
+ tasks in KDUpdater. The class diagram show in this class documentation will help in pointing out
+ the task classes in KDUpdater.
+
+ User should be carefull of these points:
+ \li Instances of this class cannot be created. Only instance of the subclasses can be created
+ \li Task classes can be started only once.
+*/
+
+struct KDUpdater::Task::TaskData
+{
+ TaskData( Task* qq) :
+ q( qq )
+ {
+ caps = KDUpdater::Task::NoCapability;
+ errorCode = 0;
+ started = false;
+ finished = false;
+ paused = false;
+ stopped = false;
+ progressPc = 0;
+ }
+
+ Task* q;
+ int caps;
+ QString name;
+ int errorCode;
+ QString errorText;
+ bool started;
+ bool finished;
+ bool paused;
+ bool stopped;
+ int progressPc;
+ QString progressText;
+};
+
+/*!
+ \internal
+*/
+KDUpdater::Task::Task(const QString& name, int caps, QObject* parent)
+ : QObject(parent),
+ d( new TaskData( this ) )
+{
+ d->caps = caps;
+ d->name = name;
+};
+
+/*!
+ \internal
+*/
+KDUpdater::Task::~Task()
+{
+ delete d;
+}
+
+/*!
+ Returns the name of the task.
+*/
+QString KDUpdater::Task::name() const
+{
+ return d->name;
+}
+
+/*!
+ Returns the capabilities of the task. It is a combination of one or more
+ Capability flags. Defined as follows
+ \code
+ enum KDUpdater::Task::Capability
+ {
+ NoCapability = 0,
+ Pausable = 1,
+ Stoppable = 2
+ };
+ \endcode
+*/
+int KDUpdater::Task::capabilities() const
+{
+ return d->caps;
+}
+
+/*!
+ Returns the last reported error code.
+*/
+int KDUpdater::Task::error() const
+{
+ return d->errorCode;
+}
+
+/*!
+ Returns the last reported error message text.
+*/
+QString KDUpdater::Task::errorString() const
+{
+ return d->errorText;
+}
+
+/*!
+ Returns whether the task has started and is running or not.
+*/
+bool KDUpdater::Task::isRunning() const
+{
+ return d->started;
+}
+
+/*!
+ Returns whether the task has finished or not.
+
+ \note Stopped (or canceled) tasks are not finished tasks.
+*/
+bool KDUpdater::Task::isFinished() const
+{
+ return d->finished;
+}
+
+/*!
+ Returns whether the task is paused or not.
+*/
+bool KDUpdater::Task::isPaused() const
+{
+ return d->paused;
+}
+
+/*!
+ Returns whether the task is stopped or not.
+
+ \note Finished tasks are not stopped classes.
+*/
+bool KDUpdater::Task::isStopped() const
+{
+ return d->stopped;
+}
+
+/*!
+ Returns the progress in percentage made by this task.
+*/
+int KDUpdater::Task::progressPercent() const
+{
+ return d->progressPc;
+}
+
+/*!
+ Returns a string that describes the progress made by this task as a string.
+*/
+QString KDUpdater::Task::progressText() const
+{
+ return d->progressText;
+}
+
+/*!
+ Starts the task.
+*/
+void KDUpdater::Task::run()
+{
+ if(d->started)
+ {
+ qDebug("Trying to start an already started task");
+ return;
+ }
+
+ if(d->finished || d->stopped)
+ {
+ qDebug("Trying to start a finished or canceled task");
+ return;
+ }
+
+ d->stopped = false;
+ d->finished = false; // for the sake of completeness
+ d->started = true;
+ emit started();
+ reportProgress(0, tr("%1 started").arg(d->name));
+
+ doRun();
+}
+
+/*!
+ Stops the task, provided the task has \ref Stoppable capability.
+
+ \note Once the task is stopped, it cannot be restarted.
+*/
+void KDUpdater::Task::stop()
+{
+ if( !(d->caps & Stoppable) )
+ {
+ const QString errorMsg = tr("'%1' cannot be stopped").arg(d->name);
+ reportError(KDUpdater::ECannotStopTask, errorMsg);
+ return;
+ }
+
+ if(!d->started)
+ {
+ qDebug("Trying to stop an unstarted task");
+ return;
+ }
+
+ if(d->finished || d->stopped)
+ {
+ qDebug("Trying to stop a finished or canceled task");
+ return;
+ }
+
+ d->stopped = doStop();
+ if(!d->stopped)
+ {
+ const QString errorMsg = tr("Cannot stop task '%1'").arg(d->name);
+ reportError(KDUpdater::ECannotStopTask, errorMsg);
+ return;
+ }
+
+ d->started = false; // the task is not running
+ d->finished = false; // the task is not finished, but was canceled half-way through
+
+ emit stopped();
+ deleteLater();
+}
+
+/*!
+ Paused the task, provided the task has \ref Pausable capability.
+*/
+void KDUpdater::Task::pause()
+{
+ if( !(d->caps & Pausable) )
+ {
+ const QString errorMsg = tr("'%1' cannot be paused").arg(d->name);
+ reportError(KDUpdater::ECannotPauseTask, errorMsg);
+ return;
+ }
+
+ if(!d->started)
+ {
+ qDebug("Trying to pause an unstarted task");
+ return;
+ }
+
+ if(d->finished || d->stopped)
+ {
+ qDebug("Trying to pause a finished or canceled task");
+ return;
+ }
+
+ d->paused = doPause();
+ if(!d->paused)
+ {
+ const QString errorMsg = tr("Cannot pause task '%1'").arg(d->name);
+ reportError(KDUpdater::ECannotPauseTask, errorMsg);
+ return;
+ }
+
+ // The task state has to be started, paused but not finished or stopped.
+ // We need not set the flags below, but just in case.
+ // Perhaps we should do Q_ASSERT() ???
+ d->started = true;
+ d->finished = false;
+ d->stopped = false;
+
+ emit paused();
+}
+
+/*!
+ Resumes the task if it was paused.
+*/
+void KDUpdater::Task::resume()
+{
+ if(!d->paused)
+ {
+ qDebug("Trying to resume an unpaused task");
+ return;
+ }
+
+ const bool val = doResume();
+ if(!val)
+ {
+ const QString errorMsg = tr("Cannot resume task '%1'").arg(d->name);
+ reportError(KDUpdater::ECannotResumeTask, errorMsg);
+ return;
+ }
+
+ // The task state should be started, but not paused, finished or stopped.
+ // We need not set the flags below, but just in case.
+ // Perhaps we should do Q_ASSERT() ???
+ d->started = true;
+ d->paused = false;
+ d->finished = false;
+ d->stopped = false;
+
+ emit resumed();
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::Task::reportProgress(int percent, const QString& text)
+{
+ if(d->progressPc == percent)
+ return;
+
+ d->progressPc = percent;
+ d->progressText = text;
+ emit progressValue( d->progressPc );
+ emit progressText( d->progressText );
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::Task::reportError(int errorCode, const QString& errorText)
+{
+ d->errorCode = errorCode;
+ d->errorText = errorText;
+
+ emit error(d->errorCode, d->errorText);
+ deleteLater();
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::Task::reportDone()
+{
+ QString msg = tr("%1 done");
+ reportProgress(100, msg);
+
+ // State should be finished, but not started, paused or stopped.
+ d->finished = true;
+ d->started = false;
+ d->paused = false;
+ d->stopped = false;
+ d->errorCode = 0;
+ d->errorText.clear();
+
+ emit finished();
+ deleteLater();
+}
+
+/*!
+ \fn virtual bool KDUpdater::Task::doStart() = 0;
+*/
+
+/*!
+ \fn virtual bool KDUpdater::Task::doStop() = 0;
+*/
+
+/*!
+ \fn virtual bool KDUpdater::Task::doPause() = 0;
+*/
+
+/*!
+ \fn virtual bool KDUpdater::Task::doResume() = 0;
+*/
+
+/*!
+ \signal void KDUpdater::Task::error(int code, const QString& errorText)
+
+ This signal is emitted to notify an error during the execution of this task.
+ \param code Error code
+ \param errorText A string describing the error.
+
+ Error codes are just integers, there are however built in errors represented
+ by the KDUpdater::Error enumeration
+ \code
+ enum Error
+ {
+ ECannotStartTask,
+ ECannotPauseTask,
+ ECannotResumeTask,
+ ECannotStopTask,
+ EUnknown
+ };
+ \endcode
+*/
+
+/*!
+ \signal void KDUpdater::Task::progress(int percent, const QString& progressText)
+
+ This signal is emitted to nofity progress made by the task.
+
+ \param percent Percentage of progress made
+ \param progressText A string describing the progress made
+*/
+
+/*!
+ \signal void KDUpdater::Task::started()
+
+ This signal is emitted when the task has started.
+*/
+
+/*!
+ \signal void KDUpdater::Task::paused()
+
+ This signal is emitted when the task has paused.
+*/
+
+/*!
+ \signal void KDUpdater::Task::resumed()
+
+ This signal is emitted when the task has resumed.
+*/
+
+/*!
+ \signal void KDUpdater::Task::stopped()
+
+ This signal is emitted when the task has stopped (or canceled).
+*/
+
+/*!
+ \signal void KDUpdater::Task::finished()
+
+ This signal is emitted when the task has finished.
+*/
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.h
new file mode 100644
index 000000000..84dada516
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdatertask.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_TASK_H
+#define KD_UPDATER_TASK_H
+
+#include "kdupdater.h"
+#include <QObject>
+
+namespace KDUpdater
+{
+ class KDTOOLS_UPDATER_EXPORT Task : public QObject
+ {
+ Q_OBJECT
+
+ public:
+ enum Capability
+ {
+ NoCapability = 0,
+ Pausable = 1,
+ Stoppable = 2
+ };
+
+ virtual ~Task();
+
+ QString name() const;
+ int capabilities() const;
+
+ int error() const;
+ QString errorString() const;
+
+ bool isRunning() const;
+ bool isFinished() const;
+ bool isPaused() const;
+ bool isStopped() const;
+
+ int progressPercent() const;
+ QString progressText() const;
+
+ public Q_SLOTS:
+ void run();
+ void stop();
+ void pause();
+ void resume();
+
+ Q_SIGNALS:
+ void error(int code, const QString& errorText);
+ void progressValue(int percent);
+ void progressText(const QString& progressText);
+ void started();
+ void paused();
+ void resumed();
+ void stopped();
+ void finished();
+
+ protected:
+ explicit Task(const QString& name, int caps=NoCapability, QObject* parent=0);
+ void reportProgress(int percent, const QString& progressText);
+ void reportError(int errorCode, const QString& errorText);
+ void reportDone();
+
+ void reportError(const QString& errorText)
+ {
+ reportError(EUnknown, errorText);
+ }
+
+ protected:
+ // Task interface
+ virtual void doRun() = 0;
+ virtual bool doStop() = 0;
+ virtual bool doPause() = 0;
+ virtual bool doResume() = 0;
+
+ private:
+ struct TaskData;
+ TaskData* d;
+ };
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp
new file mode 100644
index 000000000..4a93b92c2
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterufcompresscommon_p.h"
+
+#include <QCryptographicHash>
+#include <QDataStream>
+
+using namespace KDUpdater;
+
+bool UFHeader::isValid() const
+{
+ return magic == QLatin1String( KD_UPDATER_UF_HEADER_MAGIC ) &&
+ fileList.count() == permList.count() &&
+ fileList.count() == isDirList.count();
+}
+
+void UFHeader::addToHash(QCryptographicHash& hash) const
+{
+ QByteArray data;
+ QDataStream stream( &data, QIODevice::WriteOnly );
+ stream << *this;
+ hash.addData(data);
+}
+
+UFEntry::UFEntry()
+ : permissions( 0 )
+{
+}
+
+bool UFEntry::isValid() const
+{
+ return !fileName.isEmpty();
+}
+
+void UFEntry::addToHash(QCryptographicHash& hash) const
+{
+ QByteArray data;
+ QDataStream stream( &data, QIODevice::WriteOnly );
+ stream.setVersion( QDataStream::Qt_4_2 );
+ stream << *this;
+ hash.addData(data);
+}
+
+namespace KDUpdater
+{
+
+QDataStream& operator<<( QDataStream& stream, const UFHeader& hdr )
+{
+ stream << hdr.magic;
+ stream << hdr.fileList;
+ stream << hdr.permList;
+ stream << hdr.isDirList;
+ return stream;
+}
+
+QDataStream& operator>>( QDataStream& stream, UFHeader& hdr )
+{
+ const QDataStream::Status oldStatus = stream.status();
+ stream >> hdr.magic;
+ if( stream.status() == QDataStream::Ok && hdr.magic != QLatin1String( KD_UPDATER_UF_HEADER_MAGIC ) )
+ stream.setStatus( QDataStream::ReadCorruptData );
+
+ if( stream.status() == QDataStream::Ok )
+ stream >> hdr.fileList;
+
+ if( stream.status() == QDataStream::Ok )
+ stream >> hdr.permList;
+
+ if( stream.status() == QDataStream::Ok )
+ stream >> hdr.isDirList;
+
+ if( stream.status() == QDataStream::Ok && ( hdr.fileList.count() != hdr.permList.count() || hdr.permList.count() != hdr.isDirList.count() ) )
+ stream.setStatus( QDataStream::ReadCorruptData );
+
+ if( stream.status() != QDataStream::Ok )
+ hdr = UFHeader();
+
+ if( oldStatus != QDataStream::Ok )
+ stream.setStatus( oldStatus );
+
+ return stream;
+}
+
+QDataStream& operator<<( QDataStream& stream, const UFEntry& entry )
+{
+ stream << entry.fileName;
+ stream << entry.permissions;
+ stream << entry.fileData;
+ return stream;
+}
+
+QDataStream& operator>>( QDataStream& stream, UFEntry& entry )
+{
+ const QDataStream::Status oldStatus = stream.status();
+ if( stream.status() == QDataStream::Ok )
+ stream >> entry.fileName;
+ if( stream.status() == QDataStream::Ok )
+ stream >> entry.permissions;
+ if( stream.status() == QDataStream::Ok )
+ stream >> entry.fileData;
+
+ if( stream.status() != QDataStream::Ok )
+ entry = UFEntry();
+
+ if( oldStatus != QDataStream::Ok )
+ stream.setStatus( oldStatus );
+
+ return stream;
+}
+
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h
new file mode 100644
index 000000000..65f6ea5cb
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufcompresscommon_p.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLS_KDUPDATE_UFCOMPRESSCOMMON_P_H__
+#define __KDTOOLS_KDUPDATE_UFCOMPRESSCOMMON_P_H__
+
+#define KD_UPDATER_UF_HEADER_MAGIC "KDVCLZ"
+
+#include <KDToolsCore/kdtoolsglobal.h>
+
+#include <QtCore/QStringList>
+#include <QtCore/QByteArray>
+#include <QtCore/QVector>
+
+class QCryptographicHash;
+class QDataStream;
+
+namespace KDUpdater
+{
+ struct KDTOOLS_UPDATER_EXPORT UFHeader
+ {
+ QString magic;
+ QStringList fileList;
+ QVector<quint64> permList;
+ QList<bool> isDirList;
+
+ bool isValid() const;
+
+ void addToHash( QCryptographicHash& hash ) const;
+ };
+
+ struct KDTOOLS_UPDATER_EXPORT UFEntry
+ {
+ QString fileName;
+ quint64 permissions;
+ QByteArray fileData;
+
+ UFEntry();
+
+ bool isValid() const;
+
+ void addToHash(QCryptographicHash& hash) const;
+ };
+
+ KDTOOLS_UPDATER_EXPORT QDataStream& operator<<( QDataStream& stream, const UFHeader& hdr );
+ KDTOOLS_UPDATER_EXPORT QDataStream& operator>>( QDataStream& stream, UFHeader& hdr );
+
+ KDTOOLS_UPDATER_EXPORT QDataStream& operator<<( QDataStream& stream, const UFEntry& entry );
+ KDTOOLS_UPDATER_EXPORT QDataStream& operator>>( QDataStream& stream, UFEntry& entry );
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor.cpp
new file mode 100644
index 000000000..f5c36e44f
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterufuncompressor_p.h"
+#include "kdupdaterufcompresscommon_p.h"
+
+#include <QCryptographicHash>
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+#include <QFSFileEngine>
+#include <QDebug>
+
+using namespace KDUpdater;
+
+class UFUncompressor::Private
+{
+public:
+ QString ufFileName;
+ QString destination;
+ QString errorMessage;
+
+ void setError(const QString& msg);
+};
+
+void UFUncompressor::Private::setError(const QString& msg)
+{
+ errorMessage = msg;
+}
+
+UFUncompressor::UFUncompressor()
+{
+}
+
+UFUncompressor::~UFUncompressor()
+{
+}
+
+QString UFUncompressor::errorString() const
+{
+ return d->errorMessage;
+}
+
+void UFUncompressor::setFileName(const QString& fileName)
+{
+ d->ufFileName = fileName;
+}
+
+QString UFUncompressor::fileName() const
+{
+ return d->ufFileName;
+}
+
+void UFUncompressor::setDestination(const QString& dest)
+{
+ d->destination = dest;
+}
+
+QString UFUncompressor::destination() const
+{
+ return d->destination;
+}
+
+bool UFUncompressor::uncompress()
+{
+ d->errorMessage.clear();
+
+ // First open the uf file for reading
+ QFile ufFile( d->ufFileName );
+ if( !ufFile.open(QFile::ReadOnly) ) {
+ d->setError(tr("Couldn't open file for reading: %1").arg( ufFile.errorString() ));
+ return false;
+ }
+
+ QDataStream ufDS( &ufFile );
+ ufDS.setVersion( QDataStream::Qt_4_2 );
+ QCryptographicHash hash( QCryptographicHash::Md5 );
+
+ // Now read the header.
+ UFHeader header;
+ ufDS >> header;
+ if( ufDS.status() != QDataStream::Ok || !header.isValid() )
+ {
+ d->setError( tr( "Couldn't read the file header." ) );
+ return false;
+ }
+ header.addToHash(hash);
+
+ // Some basic checks.
+ if( header.magic != QLatin1String( KD_UPDATER_UF_HEADER_MAGIC ) ) {
+ d->setError(tr("Wrong file format (magic number not found)"));
+ return false;
+ }
+
+ // Lets get to the destination directory
+ const QDir dir(d->destination);
+ QFSFileEngine fileEngine;
+
+ // Lets create the required directory structure
+ int numExpectedFiles = 0;
+ for(int i=0; i<header.fileList.count(); i++)
+ {
+ const QString fileName = header.fileList[i];
+ // qDebug("ToUncompress %s", qPrintable(fileName));
+ if( header.isDirList[i] )
+ {
+ if ( !dir.mkpath( fileName ) )
+ {
+ d->setError(tr("Could not create folder: %1/%2").arg( d->destination, fileName ));
+ return false;
+ }
+ fileEngine.setFileName( QString(QLatin1String( "%1/%2" )).arg(d->destination, fileName) );
+ fileEngine.setPermissions( header.permList[i] | QAbstractFileEngine::ExeOwnerPerm );
+ } else {
+ ++numExpectedFiles;
+ }
+ }
+
+ // Lets now create files within these directories
+ int numActualFiles = 0;
+ while( !ufDS.atEnd() && numActualFiles < numExpectedFiles )
+ {
+ UFEntry ufEntry;
+ ufDS >> ufEntry;
+ if( ufDS.status() != QDataStream::Ok || !ufEntry.isValid() )
+ {
+ d->setError( tr( "Could not read information for entry %1." ).arg( numActualFiles ) );
+ return false;
+ }
+ ufEntry.addToHash(hash);
+
+ const QString completeFileName = QString(QLatin1String( "%1/%2" )).arg(d->destination, ufEntry.fileName);
+
+ const QByteArray ba = qUncompress( ufEntry.fileData );
+ // check the size
+ QDataStream stream( ufEntry.fileData );
+ stream.setVersion( QDataStream::Qt_4_2 );
+ qint32 length = 0;
+ stream >> length;
+ if( ba.length() != length ) // uncompress failed
+ {
+ d->setError(tr("Could not uncompress entry %1, corrupt data").arg( ufEntry.fileName ) );
+ return false;
+
+ }
+
+
+ QFile ufeFile( completeFileName );
+ if ( !ufeFile.open( QFile::WriteOnly ) )
+ {
+ d->setError(tr("Could not open file %1 for writing: %2").arg( completeFileName, ufeFile.errorString() ));
+ return false;
+ }
+
+
+ const char* const data = ba.constData();
+ const qint64 total = ba.size();
+ qint64 written = 0;
+
+ while ( written < total )
+ {
+ const qint64 num = ufeFile.write( data+written, total-written );
+ if ( num == -1 )
+ {
+ d->setError( tr("Failed writing uncompressed data to %1: %2").arg( completeFileName, ufeFile.errorString() ) );
+ return false;
+ }
+ written += num;
+ }
+
+ ufeFile.close();
+
+ const QFile::Permissions perm = static_cast< QFile::Permissions >( ufEntry.permissions );
+ ufeFile.setPermissions( perm );
+
+ if ( ufeFile.error() != QFile::NoError )
+ {
+ ufeFile.remove();
+ d->setError( tr("Failed writing uncompressed data to %1: %2").arg( completeFileName, ufeFile.errorString() ) );
+ return false;
+ }
+
+ qDebug("Uncompressed %s", qPrintable(completeFileName));
+ ++numActualFiles;
+ }
+
+ if( numExpectedFiles != numActualFiles ) {
+ d->errorMessage = tr("Corrupt file (wrong number of files)");
+ return false;
+ }
+
+ QByteArray hashdata;
+ ufDS >> hashdata;
+
+ if( hashdata != hash.result() ) {
+ d->errorMessage = tr("Corrupt file (wrong hash)");
+ return false;
+ }
+
+ return true;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor_p.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor_p.h
new file mode 100644
index 000000000..5800887fc
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterufuncompressor_p.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef __KDTOOLS_KDUPDATERUFUNCOMPRESSOR_P_H__
+#define __KDTOOLS_KDUPDATERUFUNCOMPRESSOR_P_H__
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include <QtCore/QCoreApplication>
+
+class QString;
+
+namespace KDUpdater
+{
+ class KDTOOLS_UPDATER_EXPORT UFUncompressor
+ {
+ Q_DECLARE_TR_FUNCTIONS(KDUpdater::UFUncompressor)
+
+ public:
+ UFUncompressor();
+ ~UFUncompressor();
+
+ QString errorString() const;
+
+ void setFileName(const QString& fileName);
+ QString fileName() const;
+
+ void setDestination(const QString& dest);
+ QString destination() const;
+
+ bool uncompress();
+
+ private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+ };
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.cpp
new file mode 100644
index 000000000..a84f3799c
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.cpp
@@ -0,0 +1,313 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdate.h"
+#include "kdupdaterapplication.h"
+#include "kdupdaterupdatesourcesinfo.h"
+#include "kdupdaterfiledownloader_p.h"
+#include "kdupdaterfiledownloaderfactory.h"
+#include "kdupdaterupdateoperations.h"
+#include "kdupdaterupdateoperationfactory.h"
+
+#include <QFile>
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::Update kdupdaterupdate.h KDUpdaterUpdate
+ \brief Represents a single update
+
+ The KDUpdater::Update class contains information and mechanisms to download one update. It is
+ created by KDUpdater::UpdateFinder and is used by KDUpdater::UpdateInstaller to download the UpdateFile
+ corresponding to the update.
+
+ The class makes use of appropriate network protocols (HTTP, HTTPS, FTP, or Local File Copy) to
+ download the UpdateFile.
+
+ The constructor of the KDUpdater::Update class is made protected, because it can be instantiated only by
+ KDUpdater::UpdateFinder (which is a friend class). The destructor however is public.
+*/
+
+struct KDUpdater::Update::UpdateData
+{
+ UpdateData( Update* qq ) :
+ q( qq ),
+ application( 0 ),
+ compressedSize( 0 ),
+ uncompressedSize( 0 )
+ {}
+
+ Update* q;
+ Application* application;
+ KDUpdater::UpdateSourceInfo sourceInfo;
+ QMap<QString, QVariant> data;
+ QUrl updateUrl;
+ UpdateType type;
+ QList<UpdateOperation*> operations;
+ QByteArray sha1sum;
+
+ quint64 compressedSize;
+ quint64 uncompressedSize;
+
+ KDUpdater::FileDownloader* fileDownloader;
+};
+
+
+/*!
+ \internal
+*/
+KDUpdater::Update::Update(KDUpdater::Application* application, const KDUpdater::UpdateSourceInfo& sourceInfo,
+ UpdateType type, const QUrl& updateUrl, const QMap<QString, QVariant>& data, quint64 compressedSize, quint64 uncompressedSize, const QByteArray& sha1sum )
+ : KDUpdater::Task(QLatin1String( "Update" ), Stoppable, application),
+ d( new UpdateData( this ) )
+{
+ d->application = application;
+ d->sourceInfo = sourceInfo;
+ d->data = data;
+ d->updateUrl = updateUrl;
+ d->type = type;
+
+ d->compressedSize = compressedSize;
+ d->uncompressedSize = uncompressedSize;
+ d->sha1sum = sha1sum;
+
+ const SignatureVerifier* verifier = d->application->signatureVerifier( Application::Packages );
+
+ d->fileDownloader = FileDownloaderFactory::instance().create( updateUrl.scheme(), verifier, QUrl(), this);
+ if(d->fileDownloader)
+ {
+ d->fileDownloader->setUrl(d->updateUrl);
+ d->fileDownloader->setSha1Sum( d->sha1sum );
+ connect(d->fileDownloader, SIGNAL(downloadProgress(double)), this, SLOT(downloadProgress(double)));
+ connect(d->fileDownloader, SIGNAL(downloadCanceled()), this, SIGNAL(stopped()));
+ connect(d->fileDownloader, SIGNAL(downloadCompleted()), this, SIGNAL(finished()));
+ }
+
+ switch( type ) {
+ case NewPackage:
+ case PackageUpdate:
+ {
+ KDUpdater::UpdateOperation* packageOperation = UpdateOperationFactory::instance().create( QLatin1String( "UpdatePackage" ) );
+ QStringList args;
+ args << data.value( QLatin1String( "Name" ) ).toString()
+ << data.value( QLatin1String( "Version" ) ).toString()
+ << data.value( QLatin1String( "ReleaseDate" ) ).toString();
+ packageOperation->setArguments(args);
+ packageOperation->setApplication( application );
+ d->operations.append( packageOperation );
+ break;
+ }
+ case CompatUpdate:
+ {
+ KDUpdater::UpdateOperation* compatOperation = UpdateOperationFactory::instance().create( QLatin1String( "UpdateCompatLevel" ) );
+ QStringList args;
+ args << data.value( QLatin1String( "CompatLevel" ) ).toString();
+ compatOperation->setArguments(args);
+ compatOperation->setApplication( application );
+ d->operations.append( compatOperation );
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+/*!
+ Destructor
+*/
+KDUpdater::Update::~Update()
+{
+ const QString fileName = this->downloadedFileName();
+ if( !fileName.isEmpty() )
+ QFile::remove( fileName );
+ qDeleteAll( d->operations );
+ d->operations.clear();
+ delete d;
+}
+
+/*!
+ Returns the application for which this class is downloading the UpdateFile
+*/
+KDUpdater::Application* KDUpdater::Update::application() const
+{
+ return d->application;
+}
+
+/*!
+ Returns the release date of the update downloaded by this class
+*/
+QDate KDUpdater::Update::releaseDate() const
+{
+ return d->data.value( QLatin1String( "ReleaseDate" ) ).toDate();
+}
+
+/*!
+ Returns data whose name is given in parameter, or an invalid QVariant if the data doesn't exist.
+*/
+QVariant KDUpdater::Update::data( const QString& name ) const
+{
+ if ( d->data.contains( name ) )
+ return d->data.value( name );
+ return QVariant();
+}
+
+/*!
+ Returns the complete URL of the UpdateFile downloaded by this class.
+*/
+QUrl KDUpdater::Update::updateUrl() const
+{
+ return d->updateUrl;
+}
+
+/*!
+ Returns the update source info on which this update was created.
+*/
+KDUpdater::UpdateSourceInfo KDUpdater::Update::sourceInfo() const
+{
+ return d->sourceInfo;
+}
+
+/*!
+ * Returns the type of update
+ */
+KDUpdater::UpdateType KDUpdater::Update::type() const
+{
+ return d->type;
+}
+
+/*!
+ Returns true of the update can be downloaded, false otherwise. The function
+ returns false if the URL scheme is not supported by this class.
+*/
+bool KDUpdater::Update::canDownload() const
+{
+ return d->fileDownloader && d->fileDownloader->canDownload();
+}
+
+/*!
+ Returns true of the update has been downloaded. If this function returns true
+ the you can use the \ref downloadedFileName() method to get the complete name
+ of the downloaded UpdateFile.
+
+ \note: The downloaded UpdateFile will be deleted when this class is destroyed
+*/
+bool KDUpdater::Update::isDownloaded() const
+{
+ return d->fileDownloader && d->fileDownloader->isDownloaded();
+}
+
+/*!
+ Returns the name of the downloaded UpdateFile after the download is complete, ie
+ when \ref isDownloaded() returns true.
+*/
+QString KDUpdater::Update::downloadedFileName() const
+{
+ if(d->fileDownloader)
+ return d->fileDownloader->downloadedFileName();
+
+ return QString();
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::Update::downloadProgress(double value)
+{
+ Q_ASSERT(value <= 1);
+ reportProgress(value * 100, tr("Downloading update..."));
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::Update::downloadCompleted()
+{
+ reportProgress(100, tr("Update downloaded"));
+ reportDone();
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::Update::downloadAborted(const QString& msg)
+{
+ reportError(msg);
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::Update::doRun()
+{
+ if(d->fileDownloader)
+ d->fileDownloader->download();
+}
+
+/*!
+ \internal
+*/
+bool KDUpdater::Update::doStop()
+{
+ if(d->fileDownloader)
+ d->fileDownloader->cancelDownload();
+ return true;
+}
+
+/*!
+ \internal
+*/
+bool KDUpdater::Update::doPause()
+{
+ return false;
+}
+
+/*!
+ \internal
+*/
+bool KDUpdater::Update::doResume()
+{
+ return false;
+}
+
+/*!
+ Returns a list of operations needed by this update. For example, package update needs to change
+ the package version, compat update needs to change the compat level...
+ */
+QList<KDUpdater::UpdateOperation*> KDUpdater::Update::operations() const
+{
+ return d->operations;
+}
+
+/*!
+ * Returns the compressed size of this update's data file.
+ */
+quint64 KDUpdater::Update::compressedSize() const
+{
+ return d->compressedSize;
+}
+
+/*!
+ * Returns the uncompressed size of this update's data file.
+ */
+quint64 KDUpdater::Update::uncompressedSize() const
+{
+ return d->uncompressedSize;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.h
new file mode 100644
index 000000000..8ea4728b9
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdate.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_H
+#define KD_UPDATER_UPDATE_H
+
+#include "kdupdater.h"
+#include "kdupdatertask.h"
+#include <QUrl>
+#include <QDate>
+#include <QMap>
+#include <QVariant>
+#include <QList>
+
+namespace KDUpdater
+{
+ class Application;
+ struct UpdateSourceInfo;
+ class UpdateFinder;
+ class UpdateOperation;
+
+ class KDTOOLS_UPDATER_EXPORT Update : public Task
+ {
+ Q_OBJECT
+
+ public:
+ ~Update();
+
+ Application* application() const;
+
+ UpdateType type() const;
+ QUrl updateUrl() const;
+ QDate releaseDate() const;
+ QVariant data( const QString& name ) const;
+ UpdateSourceInfo sourceInfo() const;
+
+ bool canDownload() const;
+ bool isDownloaded() const;
+ void download() { run(); }
+ QString downloadedFileName() const;
+
+ QList<UpdateOperation*> operations() const;
+
+ quint64 compressedSize() const;
+ quint64 uncompressedSize() const;
+
+ private Q_SLOTS:
+ void downloadProgress(double);
+ void downloadAborted(const QString& msg);
+ void downloadCompleted();
+
+ private:
+ friend class UpdateFinder;
+ struct UpdateData;
+ UpdateData* d;
+
+ void doRun();
+ bool doStop();
+ bool doPause();
+ bool doResume();
+
+ Update(Application* application, const UpdateSourceInfo& sourceInfo,
+ UpdateType type, const QUrl& updateUrl, const QMap<QString, QVariant>& data, quint64 compressedSize, quint64 uncompressedSize, const QByteArray& sha1sum );
+ };
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.cpp
new file mode 100644
index 000000000..8d34586e8
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.cpp
@@ -0,0 +1,892 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdatefinder.h"
+#include "kdupdaterapplication.h"
+#include "kdupdaterupdatesourcesinfo.h"
+#include "kdupdaterpackagesinfo.h"
+#include "kdupdaterupdate.h"
+#include "kdupdaterfiledownloader_p.h"
+#include "kdupdaterfiledownloaderfactory.h"
+#include "kdupdaterupdatesinfo_p.h"
+#include "kdupdatersignatureverifier.h"
+
+#include <QCoreApplication>
+#include <QDebug>
+
+using namespace KDUpdater;
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::UpdateFinder kdupdaterupdatefinder KDUpdaterUpdateFinder
+ \brief Finds updates applicable for a \ref KDUpdater::Application
+
+ The KDUpdater::UpdateFinder class helps in searching for updates and installing it on the application. The
+ class basically processes the application's \ref KDUpdater::PackagesInfo and the UpdateXMLs it aggregates
+ from all the update sources described in KDUpdater::UpdateSourcesInfo and populates a list of
+ \ref KDUpdater::Update objects. This list can then be passed to \ref KDUpdater::UpdateInstaller for
+ actually downloading and installing the updates.
+
+
+ Usage:
+ \code
+ KDUpdater::UpdateFinder updateFinder( application );
+ QProgressDialog finderProgressDlg;
+
+ QObject::connect( &updateFinder, SIGNAL(progressValue(int)),
+ &finderProgressDlg, SLOT(setValue(int)));
+ QObject::connect( &updateFinder, SIGNAL(computeUpdatesCompleted()),
+ &finderProgressDlg, SLOT(accept()));
+ QObject::connect( &updateFinder, SIGNAL(computeUpdatesCanceled()),
+ &finderProgressDlg, SLOT(reject()));
+
+ QObject::connect( &finderProgressDlg, SIGNAL(canceled()),
+ &updateFinder, SLOT(cancelComputeUpdates()));
+
+ updateFinder.run();
+ finderProgressDlg.exec();
+
+// Control comes here after update finding is done or canceled.
+
+QList<KDUpdater::Update*> updates = updateFinder.updates();
+KDUpdater::UpdateInstaller updateInstaller;
+updateInstaller.installUpdates( updates );
+
+\endcode
+*/
+
+
+//
+// Private
+//
+class KDUpdater::UpdateFinder::Private
+{
+public:
+ Private( UpdateFinder* qq ) :
+ q( qq ),
+ application(0),
+ updateType(KDUpdater::PackageUpdate)
+ {}
+
+ ~Private()
+ {
+ qDeleteAll( updates );
+ qDeleteAll( updatesInfoList );
+ qDeleteAll( updateXmlFDList );
+ }
+
+ UpdateFinder* q;
+ KDUpdater::Application* application;
+ QList<KDUpdater::Update*> updates;
+ UpdateTypes updateType;
+
+ // Temporary structure that notes down information about updates.
+ bool cancel;
+ int downloadCompleteCount;
+ QList<KDUpdater::UpdateSourceInfo> updateSourceInfoList;
+ QList<KDUpdater::UpdatesInfo*> updatesInfoList;
+ QList<KDUpdater::FileDownloader*> updateXmlFDList;
+
+ void clear();
+ void computeUpdates();
+ void cancelComputeUpdates();
+ bool downloadUpdateXMLFiles();
+ bool computeApplicableUpdates();
+
+ QList<KDUpdater::UpdateInfo> applicableUpdates(KDUpdater::UpdatesInfo* updatesInfo, bool addNewPackages = false );
+ void createUpdateObjects(const KDUpdater::UpdateSourceInfo& sourceInfo,
+ const QList<KDUpdater::UpdateInfo>& updateInfoList);
+ bool checkForUpdatePriority(const KDUpdater::UpdateSourceInfo& sourceInfo,
+ const KDUpdater::UpdateInfo& updateInfo);
+ int pickUpdateFileInfo(const QList<KDUpdater::UpdateFileInfo>& updateFiles);
+ void slotDownloadDone();
+};
+
+
+static int computeProgressPercentage(int min, int max, int percent)
+{
+ return min + qint64(max-min) * percent / 100;
+}
+
+static int computePercent(int done, int total)
+{
+ return total ? done * Q_INT64_C(100) / total : 0 ;
+}
+
+/*!
+ \internal
+
+ Releases all internal resources consumed while downloading and computing updates.
+*/
+void KDUpdater::UpdateFinder::Private::clear()
+{
+ qDeleteAll( updates );
+ updates.clear();
+ qDeleteAll( updatesInfoList );
+ updatesInfoList.clear();
+ qDeleteAll( updateXmlFDList );
+ updateXmlFDList.clear();
+ updateSourceInfoList.clear();
+
+ downloadCompleteCount = 0;
+}
+
+/*!
+ \internal
+
+ This method computes the updates that can be applied on the application by
+ studying the application's \ref KDUpdater::PackagesInfo object and the UpdateXML files
+ from each of the update sources described in \ref KDUpdater::UpdateSourcesInfo.
+
+ This function can take a long time to complete. The following signals are emitted
+ during the execution of this function
+
+ The function creates \ref KDUpdater::Update objects on the stack. All KDUpdater::Update objects
+ are made children of the application associated with this finder.
+
+ The update sources are fetched from the \ref KDUpdater::UpdateSourcesInfo object associated with
+ the application. Package information is extracted from the \ref KDUpdater::PackagesInfo object
+ associated with the application.
+
+ \note Each time this function is called, all the previously computed updates are discarded
+and its resources are freed.
+*/
+void KDUpdater::UpdateFinder::Private::computeUpdates()
+{
+ // Computing updates is done in two stages
+ // 1. Downloading Update XML files from all the update sources
+ // 2. Matching updates with Package XML and figuring out available updates
+
+ cancel = false;
+ clear();
+
+ // First do some quick sanity checks on the packages info
+ KDUpdater::PackagesInfo* packages = application->packagesInfo();
+ if( !packages ) {
+ q->reportError(tr("Could not access the package information of this application"));
+ return;
+ }
+ if( !packages->isValid() ) {
+ q->reportError(packages->errorString());
+ return;
+ }
+
+ // Now do some quick sanity checks on the update sources info
+ KDUpdater::UpdateSourcesInfo* sources = application->updateSourcesInfo();
+ if( !sources ) {
+ q->reportError(tr("Could not access the update sources information of this application"));
+ return;
+ }
+ if( !sources->isValid() ) {
+ q->reportError(sources->errorString());
+ return;
+ }
+
+ // Now we can start...
+
+ // Step 1: 0 - 49 percent
+ if(!downloadUpdateXMLFiles() || cancel)
+ {
+ clear();
+ return;
+ }
+
+ // Step 2: 50 - 100 percent
+ if(!computeApplicableUpdates() || cancel)
+ {
+ clear();
+ return;
+ }
+
+ // All done
+ q->reportProgress( 100, tr("%1 updates found").arg(updates.count()) );
+ q->reportDone();
+}
+
+/*!
+ \internal
+
+ Cancels the computation of updates.
+
+ \sa \ref computeUpdates()
+*/
+void KDUpdater::UpdateFinder::Private::cancelComputeUpdates()
+{
+ cancel = true;
+}
+
+/*!
+ \internal
+
+ This function downloads Updates.xml from all the update sources. A single application can potentially
+ have several update sources, hence we need to be asynchronous in downloading updates from different
+ sources.
+
+ The function basically does this for each update source
+ a) Create a KDUpdater::FileDownloader and KDUpdater::UpdatesInfo for each update
+ b) Triggers the download of Updates.xml from each file downloader.
+ c) The downloadCompleted(), downloadCanceled() and downloadAborted() signals are connected
+ in each of the downloaders. Once all the downloads are complete and/or aborted, the next stage
+ would be done.
+
+ The function gets into an event loop until all the downloads are complete.
+*/
+bool KDUpdater::UpdateFinder::Private::downloadUpdateXMLFiles()
+{
+ if( !application )
+ return false;
+
+ KDUpdater::UpdateSourcesInfo* updateSources = application->updateSourcesInfo();
+ if( !updateSources )
+ return false;
+
+ // Create KDUpdater::FileDownloader and KDUpdater::UpdatesInfo for each update
+ for(int i=0; i<updateSources->updateSourceInfoCount(); i++)
+ {
+ KDUpdater::UpdateSourceInfo info = updateSources->updateSourceInfo(i);
+ QUrl updateXmlUrl = QString::fromLatin1("%1/Updates.xml").arg(info.url.toString());
+
+ const SignatureVerifier* verifier = application->signatureVerifier( Application::Metadata );
+ KDUpdater::FileDownloader* downloader = FileDownloaderFactory::instance().create(updateXmlUrl.scheme(), verifier, QUrl(), q);
+ if( !downloader )
+ continue;
+
+ downloader->setUrl(updateXmlUrl);
+ downloader->setAutoRemoveDownloadedFile(true);
+
+ KDUpdater::UpdatesInfo* updatesInfo = new KDUpdater::UpdatesInfo;
+ updateSourceInfoList.append(info);
+ updateXmlFDList.append(downloader);
+ updatesInfoList.append(updatesInfo);
+
+ connect(downloader, SIGNAL(downloadCompleted()),
+ q, SLOT(slotDownloadDone()));
+ connect(downloader, SIGNAL(downloadCanceled()),
+ q, SLOT(slotDownloadDone()));
+ connect(downloader, SIGNAL(downloadAborted(QString)),
+ q, SLOT(slotDownloadDone()));
+ }
+
+ // Trigger download of Updates.xml file
+ downloadCompleteCount = 0;
+ for(int i=0; i<updateXmlFDList.count(); i++)
+ {
+ KDUpdater::FileDownloader* downloader = updateXmlFDList[i];
+ downloader->download();
+ }
+
+ // Wait until all downloaders have completed their downloads.
+ while(1)
+ {
+ QCoreApplication::processEvents();
+ if( cancel )
+ return false;
+ if( downloadCompleteCount == updateXmlFDList.count())
+ break;
+
+ int pc = computePercent(downloadCompleteCount, updateXmlFDList.count());
+ q->reportProgress(pc, tr("Downloading Updates.xml from update-sources"));
+ }
+
+ // All the downloaders have now either downloaded or aborted the
+ // donwload of update XML files.
+
+ // Lets now get rid of update sources whose Updates.xml could not be downloaded
+ for(int i=0; i<updateXmlFDList.count(); i++)
+ {
+ KDUpdater::FileDownloader* downloader = updateXmlFDList[i];
+ if( downloader->isDownloaded() )
+ continue;
+
+ KDUpdater::UpdateSourceInfo info = updateSourceInfoList[i];
+ QString msg = tr("Could not download updates from %1 ('%2')").arg(info.name, info.url.toString());
+ q->reportError(msg);
+
+ delete updatesInfoList[i];
+ delete downloader;
+ updateXmlFDList.removeAt(i);
+ updatesInfoList.removeAt(i);
+ updateSourceInfoList.removeAt(i);
+ --i;
+ }
+
+ if (updatesInfoList.isEmpty()) {
+ return false;
+ }
+
+ // Lets parse the downloaded update XML files and get rid of the downloaders.
+ for(int i=0; i<updateXmlFDList.count(); i++)
+ {
+ KDUpdater::FileDownloader* downloader = updateXmlFDList[i];
+ KDUpdater::UpdatesInfo* updatesInfo = updatesInfoList[i];
+
+ updatesInfo->setFileName( downloader->downloadedFileName() );
+
+ if (!updatesInfo->isValid()) {
+ QString msg = updatesInfo->errorString();
+ q->reportError(msg);
+
+ delete updatesInfoList[i];
+ delete downloader;
+ updateXmlFDList.removeAt(i);
+ updatesInfoList.removeAt(i);
+ --i;
+ }
+ }
+ qDeleteAll( updateXmlFDList );
+ updateXmlFDList.clear();
+
+ if (updatesInfoList.isEmpty()) {
+ return false;
+ }
+
+ q->reportProgress( 49, tr("Updates.xml file(s) downloaded from update sources") );
+ return true;
+}
+
+/*!
+ \internal
+
+ This function runs through all the KDUpdater::UpdatesInfo objects created during
+ the downloadUpdateXMLFiles() method and compares it with the data contained in
+ KDUpdater::PackagesInfo. There by figures out whether an update is applicable for
+ this application or not.
+*/
+bool KDUpdater::UpdateFinder::Private::computeApplicableUpdates()
+{
+ if( updateType & KDUpdater::CompatUpdate )
+ {
+ KDUpdater::UpdateInfo compatUpdateInfo;
+ KDUpdater::UpdateSourceInfo compatUpdateSourceInfo;
+
+ // Required compat level
+ int reqCompatLevel = application->compatLevel()+1;
+
+ q->reportProgress(60, tr("Looking for compatibility update..."));
+
+ // We are only interested in compat updates.
+ for(int i=0; i<updatesInfoList.count(); i++)
+ {
+ KDUpdater::UpdatesInfo* info = updatesInfoList[i];
+ KDUpdater::UpdateSourceInfo updateSource = updateSourceInfoList[i];
+
+ // If we already have a compat update, just check if the source currently being
+ // considered has a higher priority or not.
+ if(compatUpdateInfo.data.contains( QLatin1String( "CompatLevel" ) ) && updateSource.priority < compatUpdateSourceInfo.priority)
+ continue;
+
+ // Lets look for comapt updates that provide compat level one-higher than
+ // the application's current compat level.
+ QList<KDUpdater::UpdateInfo> updatesInfo = info->updatesInfo( KDUpdater::CompatUpdate, reqCompatLevel );
+
+ if( updatesInfo.count() == 0 )
+ continue;
+
+ compatUpdateInfo = updatesInfo.at( 0 );
+ compatUpdateSourceInfo = updateSource;
+ }
+
+ bool found = (compatUpdateInfo.data.contains( QLatin1String( "CompatLevel" ) ));
+ if(found)
+ {
+ q->reportProgress(80, tr("Found compatibility update.."));
+
+ // Lets create an update for this compat update.
+ QString updateName = tr("Compatibility level %1 update").arg(reqCompatLevel);
+ QUrl url;
+
+ // Pick a update file based on arch and OS.
+ int pickUpdateFileIndex = pickUpdateFileInfo(compatUpdateInfo.updateFiles);
+ if(pickUpdateFileIndex < 0)
+ {
+ q->reportError(tr("Compatibility update for the required architecture and hardware configuration was not found"));
+ q->reportProgress(100, tr("Compatibility update not found"));
+ return false;
+ }
+
+ KDUpdater::UpdateFileInfo fileInfo = compatUpdateInfo.updateFiles.at( pickUpdateFileIndex );
+
+ // Create an update for this entry
+ url = QString::fromLatin1( "%1/%2" ).arg( compatUpdateSourceInfo.url.toString(), fileInfo.fileName );
+ KDUpdater::Update* update = q->constructUpdate(application,
+ compatUpdateSourceInfo,
+ KDUpdater::CompatUpdate, url,
+ compatUpdateInfo.data, fileInfo.compressedSize, fileInfo.uncompressedSize, fileInfo.sha1sum );
+
+ // Register the update
+ updates.append(update);
+
+ // Done
+ q->reportProgress(100, tr("Compatibility update found"));
+ }
+ else
+ q->reportProgress(100, tr("No compatibility updates found"));
+ }
+ if ( updateType & PackageUpdate )
+ {
+ // We are not looking for normal updates, not compat ones.
+ for(int i=0; i<updatesInfoList.count(); i++)
+ {
+ // Fetch updates applicable to this application.
+ KDUpdater::UpdatesInfo* info = updatesInfoList[i];
+ QList<KDUpdater::UpdateInfo> updates = applicableUpdates(info , updateType & NewPackage );
+ if( !updates.count() )
+ continue;
+
+ if( cancel )
+ return false;
+ KDUpdater::UpdateSourceInfo updateSource = updateSourceInfoList[i];
+
+ // Create KDUpdater::Update objects for updates that have a valid
+ // UpdateFile
+ createUpdateObjects(updateSource, updates);
+ if( cancel )
+ return false;
+
+ // Report progress
+ int pc = computePercent(i, updatesInfoList.count());
+ pc = computeProgressPercentage(51, 100, pc);
+ q->reportProgress( pc, tr("Computing applicable updates") );
+ }
+ }
+
+ q->reportProgress( 99, tr("Application updates computed") );
+ return true;
+}
+
+QList<KDUpdater::UpdateInfo> KDUpdater::UpdateFinder::Private::applicableUpdates( KDUpdater::UpdatesInfo* updatesInfo, bool addNewPackages )
+{
+ QList<KDUpdater::UpdateInfo> retList;
+
+ if( !updatesInfo || updatesInfo->updateInfoCount( PackageUpdate ) == 0 )
+ return retList;
+
+ KDUpdater::PackagesInfo* packages = this->application->packagesInfo();
+ if( !packages )
+ return retList;
+
+ // Check to see if the updates info contains updates for any application
+ bool anyApp = updatesInfo->applicationName() == QLatin1String( "{AnyApplication}" );
+ int appNameIndex = -1;
+
+ if( !anyApp )
+ {
+ // updatesInfo->applicationName() describes one application or a series of
+ // application names separated by commas.
+ QString appName = updatesInfo->applicationName();
+ appName = appName.replace(QLatin1String( ", " ),
+ QLatin1String( "," ));
+ appName = appName.replace(QLatin1String( " ," ),
+ QLatin1String( "," ));
+
+ // Catch hold of app names contained updatesInfo->applicationName()
+ QStringList apps = appName.split(QLatin1String( "," ), QString::SkipEmptyParts);
+ appNameIndex = apps.indexOf(this->application->applicationName());
+
+ // If the application appName isnt one of the app names, then
+ // the updates are not applicable.
+ if( appNameIndex < 0 )
+ return retList;
+ }
+
+#if 0 //Nokia-SDK: ignore ApplicationVersion, it has no purpose and just causes problems if someone bumps the config.xml application version accidentally
+ // Check to see if the update repository versions match with app version
+ if( !anyApp )
+ {
+ QString appVersion = updatesInfo->applicationVersion();
+ appVersion = appVersion.replace(QLatin1String( ", " ), QLatin1String( "," ));
+ appVersion = appVersion.replace(QLatin1String( " ," ), QLatin1String( "," ));
+ QStringList versions = appVersion.split(QLatin1String( "," ), QString::SkipEmptyParts);
+
+ if( appNameIndex >= versions.count() )
+ return retList; // please give us well formatted Updates.xml files.
+
+ QString version = versions[appNameIndex];
+ if( KDUpdater::compareVersion(this->application->applicationVersion(), version) != 0 )
+ return retList;
+ }
+#endif
+
+ // Check to see if version numbers match. This means that the version
+ // number of the update should be greater than the version number of
+ // the package that is currently installed.
+ QList<KDUpdater::UpdateInfo> updateList = updatesInfo->updatesInfo( KDUpdater::PackageUpdate );
+ for(int i=0; i<updatesInfo->updateInfoCount( PackageUpdate ); i++)
+ {
+ KDUpdater::UpdateInfo updateInfo = updateList.at( i );
+ if( !addNewPackages )
+ {
+ int pkgInfoIdx = packages->findPackageInfo( updateInfo.data.value( QLatin1String( "Name" ) ).toString() );
+ if( pkgInfoIdx < 0 )
+ continue;
+
+ KDUpdater::PackageInfo pkgInfo = packages->packageInfo( pkgInfoIdx );
+
+ // First check to see if the update version is more than package version
+ QString updateVersion = updateInfo.data.value( QLatin1String( "Version" ) ).toString();
+ QString pkgVersion = pkgInfo.version;
+ if( KDUpdater::compareVersion(updateVersion, pkgVersion) <= 0 )
+ continue;
+
+ // It is quite possible that we may have already installed the update.
+ // Lets check the last update date of the package and the release date
+ // of the update. This way we can compare and figure out if the update
+ // has been installed or not.
+ QDate pkgDate = pkgInfo.lastUpdateDate;
+ QDate updateDate = updateInfo.data.value( QLatin1String( "ReleaseDate" ) ).toDate();
+ if( pkgDate > updateDate )
+ continue;
+ }
+
+ // Bingo!, we found an update :-)
+ retList.append(updateInfo);
+ }
+
+ return retList;
+}
+
+void KDUpdater::UpdateFinder::Private::createUpdateObjects(const KDUpdater::UpdateSourceInfo& sourceInfo, const QList<KDUpdater::UpdateInfo>& updateInfoList)
+{
+ for(int i=0; i<updateInfoList.count(); i++)
+ {
+ KDUpdater::UpdateInfo info = updateInfoList[i];
+ // Compat level checks
+ if( info.data.contains( QLatin1String( "RequiredCompatLevel" ) ) &&
+ info.data.value( QLatin1String( "RequiredCompatLevel" ) ).toInt() != application->compatLevel() )
+ {
+ qDebug() << "Update \"" << info.data.value( QLatin1String( "Name" ) ).toString() << "\" at \""
+ << sourceInfo.name << "\"(\"" << sourceInfo.url.toString() << "\") requires a different compat level";
+ continue; // Compatibility level mismatch
+ }
+
+ // If another update of the same name exists, then use the update coming from
+ // a higher priority.
+ if( !checkForUpdatePriority(sourceInfo, info) )
+ {
+ qDebug() << "Skipping Update \""
+ << info.data.value( QLatin1String( "Name" ) ).toString()
+ << "\" from \""
+ << sourceInfo.name
+ << "\"(\""
+ << sourceInfo.url.toString()
+ << "\") because an update with the same name was found from a higher priority location";
+
+ continue;
+ }
+
+ // Pick a update file based on arch and OS.
+ int pickUpdateFileIndex = this->pickUpdateFileInfo(info.updateFiles);
+ if(pickUpdateFileIndex < 0)
+ continue;
+
+ KDUpdater::UpdateFileInfo fileInfo = info.updateFiles.at( pickUpdateFileIndex );
+
+ // Create an update for this entry
+ QUrl url( QString::fromLatin1("%1/%2").arg( sourceInfo.url.toString(), fileInfo.fileName ) );
+ KDUpdater::Update* update = q->constructUpdate(application, sourceInfo, KDUpdater::PackageUpdate, url, info.data, fileInfo.compressedSize, fileInfo.uncompressedSize, fileInfo.sha1sum );
+
+ // Register the update
+ this->updates.append(update);
+ }
+}
+
+bool KDUpdater::UpdateFinder::Private::checkForUpdatePriority(const KDUpdater::UpdateSourceInfo& sourceInfo, const KDUpdater::UpdateInfo& updateInfo)
+{
+ for(int i=0; i<this->updates.count(); i++)
+ {
+ KDUpdater::Update* update = this->updates[i];
+ if( update->data( QLatin1String( "Name" ) ).toString() != updateInfo.data.value( QLatin1String( "Name" ) ).toString() )
+ continue;
+
+ // Bingo, update was previously found elsewhere.
+
+ // If the existing update comes from a higher priority server, then cool :)
+ if( update->sourceInfo().priority > sourceInfo.priority )
+ return false;
+
+ // If the existing update has a higher version number, keep it
+ if ( KDUpdater::compareVersion(update->data( QLatin1String( "Version" ) ).toString(),
+ updateInfo.data.value( QLatin1String( "Version" ) ).toString()) > 0)
+ return false;
+
+ // Otherwise the old update must be deleted.
+ this->updates.removeAll(update);
+ delete update;
+
+ return true;
+ }
+
+ // No update by that name was found, so what we have is a priority update.
+ return true;
+}
+
+int KDUpdater::UpdateFinder::Private::pickUpdateFileInfo(const QList<KDUpdater::UpdateFileInfo>& updateFiles)
+{
+#ifdef Q_WS_MAC
+ QString os = QLatin1String( "MacOSX" );
+#endif
+#ifdef Q_WS_WIN
+ QString os = QLatin1String( "Windows" );
+#endif
+#ifdef Q_WS_X11
+ QString os = QLatin1String( "Linux" );
+#endif
+
+ QString arch = QLatin1String( "i386" ); // only one architecture considered for now.
+
+ for(int i=0; i<updateFiles.count(); i++)
+ {
+ KDUpdater::UpdateFileInfo fileInfo = updateFiles[i];
+
+ if( fileInfo.arch != arch )
+ continue;
+
+ if( fileInfo.os != QLatin1String( "Any" ) && fileInfo.os != os )
+ continue;
+
+ return i;
+ }
+
+ return -1;
+}
+
+
+
+//
+// UpdateFinder
+//
+
+/*!
+ Constructs a update finder for a given \ref KDUpdater::Application.
+*/
+KDUpdater::UpdateFinder::UpdateFinder(KDUpdater::Application* application)
+ : KDUpdater::Task(QLatin1String( "UpdateFinder" ), Stoppable, application),
+ d( new Private( this ) )
+{
+ d->application = application;
+}
+
+/*!
+ Destructor
+*/
+KDUpdater::UpdateFinder::~UpdateFinder()
+{
+ delete d;
+}
+
+/*!
+ Returns a pointer to the update application for which this function computes all
+ the updates.
+*/
+KDUpdater::Application* KDUpdater::UpdateFinder::application() const
+{
+ return d->application;
+}
+
+/*!
+ Returns a list of KDUpdater::Update objects. The update objects returned in this list
+ are made children of the \ref KDUpdater::Application object associated with this class.
+*/
+QList<KDUpdater::Update*> KDUpdater::UpdateFinder::updates() const
+{
+ return d->updates;
+}
+
+/*!
+ Looks only for a certain type of update. By default, only package update
+*/
+void KDUpdater::UpdateFinder::setUpdateType(UpdateTypes type)
+{
+ d->updateType = type;
+}
+
+/*!
+ Returns the type of updates searched
+*/
+KDUpdater::UpdateTypes KDUpdater::UpdateFinder::updateType() const
+{
+ return d->updateType;
+}
+
+/*!
+ \internal
+
+ Implemented from \ref KDUpdater::Task::doStart().
+*/
+void KDUpdater::UpdateFinder::doRun()
+{
+ d->computeUpdates();
+}
+
+/*!
+ \internal
+
+ Implemented form \ref KDUpdater::Task::doStop()
+*/
+bool KDUpdater::UpdateFinder::doStop()
+{
+ d->cancelComputeUpdates();
+
+ // Wait until the cancel has actually happened, and then return.
+ // Thinking of using QMutex for this. Frank/Till any suggestions?
+
+ return true;
+}
+
+/*!
+ \internal
+
+ Implemented form \ref KDUpdater::Task::doStop()
+*/
+bool KDUpdater::UpdateFinder::doPause()
+{
+ // Not a pausable task
+ return false;
+}
+
+/*!
+ \internal
+
+ Implemented form \ref KDUpdater::Task::doStop()
+*/
+bool KDUpdater::UpdateFinder::doResume()
+{
+ // Not a pausable task, hence it is not resumable as well
+ return false;
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::UpdateFinder::Private::slotDownloadDone()
+{
+ ++downloadCompleteCount;
+
+ int pc = computePercent(downloadCompleteCount, updateXmlFDList.count());
+ pc = computeProgressPercentage(0, 45, pc);
+ q->reportProgress( pc, tr("Downloading Updates.xml from update sources") );
+}
+
+/*!
+ \internal
+ */
+KDUpdater::Update* KDUpdater::UpdateFinder::constructUpdate( Application* application, const UpdateSourceInfo& sourceInfo,
+ UpdateType type, const QUrl& updateUrl, const QMap< QString, QVariant >& data, quint64 compressedSize, quint64 uncompressedSize, const QByteArray& sha1sum )
+{
+ return new Update( application, sourceInfo, type, updateUrl, data, compressedSize, uncompressedSize, sha1sum );
+}
+
+
+/*!
+ \ingroup kdupdater
+
+ This function compares two version strings \c v1 and \c v2 and returns
+ -1, 0 or +1 based on the following rule
+
+ \li Returns 0 if v1 == v2
+ \li Returns -1 if v1 < v2
+ \li Returns +1 if v1 > v2
+
+ The function is very similar to \c strcmp(), except that it works on version strings.
+
+ Example:
+ \code
+
+ KDUpdater::compareVersion("2.0", "2.1"); // Returns -1
+ KDUpdater::compareVersion("2.1", "2.0"); // Returns +1
+ KDUpdater::compareVersion("2.0", "2.0"); // Returns 0
+ KDUpdater::compareVersion("2.1", "2.1"); // Returns 0
+
+ KDUpdater::compareVersion("2.0", "2.x"); // Returns 0
+ KDUpdater::compareVersion("2.x", "2.0"); // Returns 0
+
+ KDUpdater::compareVersion("2.0.12.4", "2.1.10.4"); // Returns -1
+ KDUpdater::compareVersion("2.0.12.x", "2.0.x"); // Returns 0
+ KDUpdater::compareVersion("2.1.12.x", "2.0.x"); // Returns +1
+ KDUpdater::compareVersion("2.1.12.x", "2.x"); // Returns 0
+ KDUpdater::compareVersion("2.x", "2.1.12.x"); // Returns 0
+
+ \endcode
+*/
+int KDUpdater::compareVersion(const QString& v1, const QString& v2)
+{
+ // For tests refer VersionCompareFnTest testcase.
+
+ // Check for equality
+ if( v1 == v2 )
+ return 0;
+
+ // Split version numbers across .
+ const QStringList v1_comps = v1.split( QRegExp( QLatin1String( "\\.|-" ) ) );
+ const QStringList v2_comps = v2.split( QRegExp( QLatin1String( "\\.|-" ) ) );
+
+ // Check each component of the version
+ int index = 0;
+ while(1)
+ {
+ if( index == v1_comps.count() && index < v2_comps.count() )
+ return -1;
+ else if( index < v1_comps.count() && index == v2_comps.count() )
+ return +1;
+ else if( index >= v1_comps.count() || index >= v2_comps.count() )
+ break;
+
+ bool v1_ok, v2_ok;
+ int v1_comp = v1_comps[index].toInt(&v1_ok);
+ int v2_comp = v2_comps[index].toInt(&v2_ok);
+
+ if(!v1_ok)
+ {
+ if(v1_comps[index] == QLatin1String( "x" ) )
+ return 0;
+ }
+ if(!v2_ok)
+ {
+ if(v2_comps[index] == QLatin1String( "x") )
+ return 0;
+ }
+ if( !v1_ok && !v2_ok )
+ {
+ return v1_comps[ index ].compare( v2_comps[ index ] );
+ }
+
+ if( v1_comp < v2_comp )
+ return -1;
+
+ if( v1_comp > v2_comp )
+ return +1;
+
+ // v1_comp == v2_comp
+ ++index;
+ }
+
+ if( index < v2_comps.count() )
+ return +1;
+
+ if( index < v1_comps.count() )
+ return -1;
+
+ // Controversial return. I hope this never happens.
+ return 0;
+}
+
+#include "moc_kdupdaterupdatefinder.cpp"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.h
new file mode 100644
index 000000000..14ebb9c97
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatefinder.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_FINDER_H
+#define KD_UPDATER_UPDATE_FINDER_H
+
+#include "kdupdater.h"
+#include "kdupdatertask.h"
+#include <QList>
+#include <QMap>
+
+class QUrl;
+
+namespace KDUpdater
+{
+ class Application;
+ class Update;
+ struct UpdateSourceInfo;
+
+ class KDTOOLS_UPDATER_EXPORT UpdateFinder : public Task
+ {
+ Q_OBJECT
+
+ public:
+ explicit UpdateFinder(Application* application);
+ ~UpdateFinder();
+
+ Application* application() const;
+ QList<Update*> updates() const;
+
+ void setUpdateType( UpdateTypes type );
+ UpdateTypes updateType() const;
+
+ private:
+ void doRun();
+ bool doStop();
+ bool doPause();
+ bool doResume();
+
+ Update* constructUpdate( Application* application, const UpdateSourceInfo& sourceInfo,
+ UpdateType type, const QUrl& updateUrl, const QMap< QString, QVariant >& data, quint64 compressedSize, quint64 uncompressedSize, const QByteArray& sha1sum );
+
+
+ private:
+ class Private;
+ Private* const d;
+ Q_PRIVATE_SLOT( d, void slotDownloadDone() )
+ };
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp
new file mode 100644
index 000000000..3b8d2dbd4
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.cpp
@@ -0,0 +1,481 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdateinstaller.h"
+#include "kdupdaterpackagesinfo.h"
+#include "kdupdaterapplication.h"
+#include "kdupdaterupdate.h"
+#include "kdupdaterupdateoperationfactory.h"
+#include "kdupdaterupdateoperation.h"
+#include "kdupdaterufuncompressor_p.h"
+
+#include <QCoreApplication>
+#include <QFileInfo>
+#include <QDir>
+#include <QDomDocument>
+#include <QDomElement>
+#include <QDate>
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::UpdateInstaller kdupdaterupdateinstaller.h KDUpdaterUpdateInstaller
+ \brief Installs updates, given a list of \ref KDUpdater::Update objects
+
+ This class installs updates, given a list of \ref KDUpdater::Update objects via the
+ \ref installUpdates() method. To install the updates this class performs the following
+ for each update
+
+ \li Downloads the update files from its source
+ \li Unpacks update files into a temporary directory
+ \li Parses and executes UpdateInstructions.xml by making use of \ref KDUpdater::UpdateOperation
+ objects sourced via \ref KDUpdater::UpdateOperationFactory
+
+ \note All temporary files created during the installation of the update will be destroyed
+ immediately after the installation is complete.
+*/
+class KDUpdater::UpdateInstaller::Private
+{
+ public:
+ Private( UpdateInstaller* qq ) :
+ q( qq )
+ {}
+
+ UpdateInstaller* q;
+
+ KDUpdater::Application* application;
+ int updateDownloadDoneCount;
+ int updateDownloadProgress;
+ int totalUpdates;
+ QStringList toRemoveDirs;
+
+ int totalProgressPc;
+ int currentProgressPc;
+ QList<KDUpdater::Update*> updates;
+
+ void resolveArguments(QStringList& args);
+
+ void removeDirectory(const QDir & dir);
+ void slotUpdateDownloadProgress(int percent);
+ void slotUpdateDownloadDone();
+};
+
+// next two are duplicated from kdupdaterupdatefinder.cpp:
+
+static int computeProgressPercentage(int min, int max, int percent)
+{
+ return min + qint64(max-min) * percent / 100 ;
+}
+
+static int computePercent(int done, int total)
+{
+ return total ? done * Q_INT64_C(100) / total : 0 ;
+}
+
+/*!
+ Constructs an instance of this class for the \ref KDUpdater::Application passed as
+ parameter. Only updates meant for the specified application will be installed by this class.
+*/
+KDUpdater::UpdateInstaller::UpdateInstaller(KDUpdater::Application* application)
+ : KDUpdater::Task(QLatin1String( "UpdateInstaller" ), NoCapability, application),
+ d( new Private( this ) )
+{
+ d->application = application;
+}
+
+/*!
+ Destructor
+*/
+KDUpdater::UpdateInstaller::~UpdateInstaller()
+{
+ delete d;
+}
+
+/*!
+ Returns the update application for which the update is being installed
+*/
+KDUpdater::Application* KDUpdater::UpdateInstaller::application() const
+{
+ return d->application;
+}
+
+/*!
+ Use this function to let the installer know what updates are to be installed. The
+ updates are actually installed when the \ref start() method is called on this class.
+*/
+void KDUpdater::UpdateInstaller::setUpdatesToInstall(const QList<KDUpdater::Update*>& updates)
+{
+ d->updates = updates;
+}
+
+/*!
+ Returns the updates that would be installed when the next time \ref the start) method is called.
+*/
+QList<KDUpdater::Update*> KDUpdater::UpdateInstaller::updatesToInstall() const
+{
+ return d->updates;
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::UpdateInstaller::doRun()
+{
+ QList<KDUpdater::Update*>& updates = d->updates;
+
+ // First download all the updates
+ d->updateDownloadDoneCount = 0;
+ d->totalUpdates = updates.count();
+
+ for(int i=0; i<updates.count(); i++)
+ {
+ KDUpdater::Update* update = updates[i];
+ if( update->application() != d->application )
+ continue;
+
+ update->setProperty("_ProgressPc_", 0);
+ connect(update, SIGNAL(progressValue(int)), this, SLOT(slotUpdateDownloadProgress(int)));
+ connect(update, SIGNAL(finished()), this, SLOT(slotUpdateDownloadDone()));
+ connect(update, SIGNAL(stopped()), this, SLOT(slotUpdateDownloadDone()));
+ update->download();
+ }
+
+ d->totalProgressPc = updates.count() * 100;
+ d->currentProgressPc = 0;
+
+ // Wait until all updates have been downloaded
+ while(d->updateDownloadDoneCount != updates.count())
+ {
+ QCoreApplication::processEvents();
+
+ // Normalized progress
+ int progressPc = computePercent(d->currentProgressPc, d->totalProgressPc);
+
+ // Bring the progress to within 50 percent
+ progressPc = (progressPc>>1);
+
+ // Report the progress
+ reportProgress(progressPc, tr("Downloading updates..."));
+ }
+
+ // Global progress
+ reportProgress(50, tr("Updates downloaded..."));
+
+ // Save the current working directory of the application
+ QDir oldCWD = QDir::current();
+
+ int pcDiff = computePercent(1, updates.count());
+ pcDiff = computeProgressPercentage(50, 95, pcDiff) - 50;
+
+ // Now install one update after another.
+ for(int i=0; i<updates.count(); i++)
+ {
+ KDUpdater::Update* update = updates[i];
+
+ // Global progress
+ QString msg = tr("Installing %1..").arg(update->name());
+ int minPc = pcDiff*i + 50;
+ int maxPc = minPc + pcDiff;
+ reportProgress(minPc, msg);
+
+ if( update->application() != d->application )
+ continue;
+
+ QDir::setCurrent(oldCWD.absolutePath());
+ if (!installUpdate(update, minPc, maxPc)) {
+ d->application->packagesInfo()->writeToDisk();
+ return;
+ }
+ }
+
+ d->application->packagesInfo()->writeToDisk();
+
+ // Global progress
+ reportProgress(95, tr("Finished installing updates. Now removing temporary files and directories.."));
+
+ // Restore the current working directory of the application
+ QDir::setCurrent(oldCWD.absolutePath());
+
+ // Remove all the toRemoveDirs
+ for(int i=0; i<d->toRemoveDirs.count(); i++)
+ {
+ QDir dir( d->toRemoveDirs[i] );
+ d->removeDirectory( dir );
+
+ QString dirName = dir.dirName();
+ dir.cdUp();
+ dir.rmdir( dirName );
+ }
+ d->toRemoveDirs.clear();
+
+ // Global progress
+ reportProgress(100, tr("Removed temporary files and directories"));
+ reportDone();
+}
+
+/*!
+ \internal
+*/
+bool KDUpdater::UpdateInstaller::doStop()
+{
+ return false;
+}
+
+/*!
+ \internal
+*/
+bool KDUpdater::UpdateInstaller::doPause()
+{
+ return false;
+}
+
+/*!
+ \internal
+*/
+bool KDUpdater::UpdateInstaller::doResume()
+{
+ return false;
+}
+
+bool KDUpdater::UpdateInstaller::installUpdate(KDUpdater::Update* update, int minPc, int maxPc)
+{
+ QString updateName( update->name() );
+
+ // Sanity checks
+ if( !update->isDownloaded() )
+ {
+ QString msg = tr("Could not download update '%1'").arg(update->name());
+ reportError(msg);
+ return false;
+ }
+
+ // Step 1: Prepare a directory into which the UpdateFile will be unpacked.
+ // If update file is C:/Users/PRASHA~1/AppData/Local/Temp/qt_temp.Hp1204 and
+ // the applicationn name "MyApplication"
+ // Then the directory would be %USERDIR%/AppData/Local/Temp/MyApplication_Update1
+ static int count = 0;
+ QString dirName = QString::fromLatin1("%1_Update%2").arg(d->application->applicationName(), QString::number(count++));
+ QString updateFile = update->downloadedFileName();
+ QFileInfo fi(updateFile);
+ QDir dir( fi.absolutePath() );
+ dir.mkdir( dirName );
+ dir.cd( dirName );
+ d->toRemoveDirs << dir.absolutePath();
+
+ // Step 2: Unpack the update file into the update directory
+ KDUpdater::UFUncompressor uncompressor;
+ uncompressor.setFileName( updateFile );
+ uncompressor.setDestination( dir.absolutePath() );
+
+ if (!uncompressor.uncompress()) {
+ reportError(tr("Couldn't uncompress update: %1")
+ .arg(uncompressor.errorString()));
+ return false;
+ }
+
+ // Step 3: Find out the directory in which UpdateInstructions.xml can be found
+ QDir updateDir = dir;
+ while( !updateDir.exists(QLatin1String( "UpdateInstructions.xml" )) )
+ {
+ QString path = updateDir.absolutePath();
+ QFileInfoList fiList = updateDir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot);
+ if( !fiList.count() ) // || fiList.count() >= 2 )
+ {
+ QString msg = tr("Could not find UpdateInstructions.xml for %1").arg(update->name());
+ reportError(msg);
+ return false;
+ }
+
+ updateDir.cd(fiList.first().fileName());
+ }
+
+ // Set the application's current working directory as updateDir
+ QDir::setCurrent(updateDir.absolutePath());
+
+ // Step 4: Now load the UpdateInstructions.xml file
+ QDomDocument doc;
+ QFile file(updateDir.absoluteFilePath(QLatin1String( "UpdateInstructions.xml" )));
+ if( !file.open(QFile::ReadOnly) )
+ {
+ QString msg = tr("Could not read UpdateInstructions.xml of %1").arg(update->name());
+ reportError(msg);
+ return false;
+ }
+ if( !doc.setContent(&file) )
+ {
+ QString msg = tr("Could not read UpdateInstructions.xml of %1").arg(update->name());
+ reportError(msg);
+ return false;
+ }
+
+ // Now parse and execute update operations
+ QDomNodeList operEList = doc.elementsByTagName(QLatin1String( "UpdateOperation" ));
+ QString msg = tr("Installing %1").arg(updateName);
+
+ for(int i=0; i<operEList.count(); i++)
+ {
+ int pc = computePercent(i+1, operEList.count());
+ pc = computeProgressPercentage(minPc, maxPc, pc);
+ reportProgress(pc, msg);
+
+ // Fetch the important XML elements in UpdateOperation
+ QDomElement operE = operEList.at(i).toElement();
+ QDomElement nameE = operE.firstChildElement(QLatin1String( "Name" ));
+ QDomElement errorE = operE.firstChildElement(QLatin1String( "OnError" ));
+ QDomElement argE = operE.firstChildElement(QLatin1String( "Arg" ));
+
+ // Figure out information about the update operation to perform
+ QString operName = nameE.text();
+ QString onError = errorE.attribute(QLatin1String( "Action" ), QLatin1String( "Abort" ) );
+ QStringList args;
+ while( !argE.isNull() )
+ {
+ args << argE.text();
+ argE = argE.nextSiblingElement(QLatin1String( "Arg" ));
+ }
+
+ //QString operSignature = QString::fromLatin1("%1(%2)").arg(operName, args.join( QLatin1String( ", ") ) );
+
+ // Fetch update operation
+ KDUpdater::UpdateOperation* const updateOperation = KDUpdater::UpdateOperationFactory::instance().create(operName);
+ if( !updateOperation )
+ {
+ QString errMsg = tr("Update operation %1 not supported").arg(operName);
+ reportError(errMsg);
+
+ if( onError == QLatin1String( "Continue" ) )
+ continue;
+
+ if( onError == QLatin1String( "Abort" ) )
+ return false;
+
+ if( onError == QLatin1String( "AskUser" ) )
+ {
+ // TODO:
+ continue;
+ }
+ }
+
+ // Now resolve special fields in arguments
+ d->resolveArguments(args);
+
+ // Now set the arguments to the update operation and execute the update operation
+ updateOperation->setArguments(args);
+ updateOperation->setApplication( d->application );
+ const bool success = updateOperation->performOperation();
+
+ updateOperation->clear();
+
+ if( !success )
+ {
+ QString errMsg = tr("Cannot execute '%1'").arg(updateOperation->operationCommand());
+ reportError(errMsg);
+
+ if( onError == QLatin1String( "Continue" ) )
+ continue;
+
+ if( onError == QLatin1String( "Abort" ) )
+ return false;
+
+ if( onError == QLatin1String( "AskUser" ) )
+ {
+ // TODO:
+ continue;
+ }
+ }
+ delete updateOperation;
+ }
+
+ Q_FOREACH( UpdateOperation* updateOperation, update->operations() ) {
+ updateOperation->performOperation();
+ }
+
+ msg = tr("Finished installing update %1").arg(update->name());
+ reportProgress(maxPc, msg);
+ return true;
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::UpdateInstaller::Private::slotUpdateDownloadProgress(int percent)
+{
+ // 0-49 percent progress is dedicated for the download of updates
+ KDUpdater::Update* update = qobject_cast<KDUpdater::Update*>(q->sender());
+ if( !update )
+ return;
+
+ int oldPc = update->property("_ProgressPc_").toInt();
+ int diffPc = percent-oldPc;
+ if(diffPc <= 0)
+ return;
+
+ currentProgressPc += diffPc;
+ update->setProperty("_ProgressPc_", percent);
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::UpdateInstaller::Private::slotUpdateDownloadDone()
+{
+ ++updateDownloadDoneCount;
+}
+
+void KDUpdater::UpdateInstaller::Private::resolveArguments(QStringList& args)
+{
+ for(int i=0; i<args.count(); i++)
+ {
+ QString arg = args[i];
+
+ arg = arg.replace(QLatin1String( "{APPDIR}" ), application->applicationDirectory());
+ arg = arg.replace(QLatin1String( "{HOME}" ), QDir::homePath());
+ arg = arg.replace(QLatin1String( "{APPNAME}" ), application->applicationName());
+ arg = arg.replace(QLatin1String( "{APPVERSION}" ), application->applicationVersion());
+ arg = arg.replace(QLatin1String( "{CURPATH}" ), QDir::currentPath());
+ arg = arg.replace(QLatin1String( "{ROOT}" ), QDir::rootPath());
+ arg = arg.replace(QLatin1String( "{TEMP}" ), QDir::tempPath());
+
+ args[i] = arg;
+ }
+}
+
+void KDUpdater::UpdateInstaller::Private::removeDirectory(const QDir & dir)
+{
+ QFileInfoList fiList = dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot);
+ if( !fiList.count() )
+ return;
+
+ for(int i=0; i<fiList.count(); i++)
+ {
+ QFileInfo fi = fiList[i];
+ if( fi.isDir() )
+ {
+ QDir childDir = fi.absoluteFilePath();
+ removeDirectory( childDir );
+ dir.rmdir( childDir.dirName() );
+ }
+ else if( fi.isFile() )
+ QFile::remove( fi.absoluteFilePath() );
+ }
+}
+
+#include "moc_kdupdaterupdateinstaller.cpp"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.h
new file mode 100644
index 000000000..dc3e58e48
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateinstaller.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_INSTALLER_H
+#define KD_UPDATER_UPDATE_INSTALLER_H
+
+#include "kdupdater.h"
+#include "kdupdatertask.h"
+#include <QList>
+
+namespace KDUpdater
+{
+ class Application;
+ class Update;
+
+ class KDTOOLS_UPDATER_EXPORT UpdateInstaller : public Task
+ {
+ Q_OBJECT
+
+ public:
+ explicit UpdateInstaller(Application* application);
+ ~UpdateInstaller();
+
+ Application* application() const;
+
+ void setUpdatesToInstall(const QList<Update*>& updates);
+ QList<Update*> updatesToInstall() const;
+
+ private:
+ void doRun();
+ bool doStop();
+ bool doPause();
+ bool doResume();
+
+ bool installUpdate(Update* update, int minPc, int maxPc);
+
+ class Private;
+ Private * const d;
+
+ Q_PRIVATE_SLOT( d, void slotUpdateDownloadProgress(int) )
+ Q_PRIVATE_SLOT( d, void slotUpdateDownloadDone() )
+ };
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.cpp
new file mode 100644
index 000000000..7c4121e8e
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.cpp
@@ -0,0 +1,417 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdateoperation.h"
+
+#include "kdupdaterapplication.h"
+
+#include <QDebug>
+#include <QDir>
+#include <QFileInfo>
+#include <QTemporaryFile>
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::UpdateOperation kdupdaterupdateoperation.h KDUpdaterUpdateOperation
+ \brief Abstract base class for update operations.
+
+ The \ref KDUpdater::UpdateOperation is an abstract class that specifies an interface for
+ update operations. Concrete implementations of this class must perform a single update
+ operation like copy, move, delete etc.
+
+ \note Two seperate threads cannot be using a single instance of KDUpdater::UpdateOperation
+ at the same time.
+*/
+
+/*
+ * \internal
+ * Returns a filename for a temporary file based on \a templateName
+ */
+static QString backupFileName( const QString& templateName = QString() )
+{
+ const QFileInfo templ( templateName );
+ QTemporaryFile file( QDir::temp().absoluteFilePath( templ.fileName() ) );
+ file.open();
+ const QString name = file.fileName();
+ file.close();
+ file.remove();
+ return name;
+}
+
+using namespace KDUpdater;
+
+struct UpdateOperation::UpdateOperationData
+{
+ UpdateOperationData( UpdateOperation* qq ) :
+ q( qq ),
+ error( 0 ),
+ application(0)
+ {}
+
+ UpdateOperation* q;
+ QString name;
+ QStringList args;
+ QString errorString;
+ int error;
+ Application* application;
+ QVariantMap values;
+ QStringList delayedDeletionFiles;
+};
+
+
+/*!
+ Constructor
+*/
+UpdateOperation::UpdateOperation()
+ : d ( new UpdateOperationData( this ) )
+{
+}
+
+/*!
+ Destructor
+*/
+UpdateOperation::~UpdateOperation()
+{
+ Application* const app = Application::instance();
+ if( app )
+ app->addFilesForDelayedDeletion( filesForDelayedDeletion() );
+ delete d;
+}
+
+/*!
+ Returns the update operation name.
+
+ \sa setName()
+*/
+QString UpdateOperation::name() const
+{
+ return d->name;
+}
+
+/*!
+ Returns a command line string that describes the update operation. The returned
+ string would be of the form
+
+ <name> <arg1> <arg2> <arg3> ....
+*/
+QString UpdateOperation::operationCommand() const
+{
+ QString argsStr = d->args.join(QLatin1String( " " ));
+ return QString::fromLatin1( "%1 %2" ).arg(d->name, argsStr);
+}
+
+/*!
+ Returns true if there exists a setting called \a name. Otherwise returns false.
+*/
+bool UpdateOperation::hasValue( const QString& name ) const
+{
+ return d->values.contains( name );
+}
+
+/*!
+ Clears the value of setting \a name and removes it.
+ \post hasValue( \a name ) returns false.
+*/
+void UpdateOperation::clearValue( const QString& name )
+{
+ d->values.remove( name );
+}
+
+/*!
+ Returns the value of setting \a name. If the setting does not exists,
+ this returns an empty QVariant.
+*/
+QVariant UpdateOperation::value( const QString& name ) const
+{
+ return hasValue( name ) ? d->values[ name ] : QVariant();
+}
+
+/*!
+ Sets the value of setting \a name to \a value.
+*/
+void UpdateOperation::setValue( const QString& name, const QVariant& value )
+{
+ d->values[ name ] = value;
+}
+
+/*!
+ Sets a update operation name. Subclasses will have to provide a unique
+ name to describe this operation.
+*/
+void UpdateOperation::setName(const QString& name)
+{
+ d->name = name;
+}
+
+/*!
+ Through this function, arguments to the update operation can be specified
+ to the update operation.
+*/
+void UpdateOperation::setArguments(const QStringList& args)
+{
+ d->args = args;
+}
+
+/*!
+ Sets the Application for this operation.
+ This may be used by some operations
+*/
+void UpdateOperation::setApplication( Application* application )
+{
+ d->application = application;
+}
+
+/*!
+ Returns the last set function arguments.
+*/
+QStringList UpdateOperation::arguments() const
+{
+ return d->args;
+}
+
+/*!
+ Returns error details in case performOperation() failed.
+*/
+QString UpdateOperation::errorString() const
+{
+ return d->errorString;
+}
+
+/*!
+ * Can be used by subclasses to report more detailed error codes (optional).
+ * To check if an operation was successful, use the return value of performOperation().
+ */
+int UpdateOperation::error() const
+{
+ return d->error;
+}
+
+/*!
+ * Used by subclasses to set the error string.
+ */
+void UpdateOperation::setErrorString( const QString& str )
+{
+ d->errorString = str;
+}
+
+/*!
+ * Used by subclasses to set the error code.
+ */
+void UpdateOperation::setError( int error, const QString& errorString )
+{
+ d->error = error;
+ if( !errorString.isNull() )
+ d->errorString = errorString;
+}
+
+/*!
+ Clears the previously set argument list and application
+*/
+void UpdateOperation::clear()
+{
+ d->args.clear();
+ d->application = 0;
+}
+
+QStringList UpdateOperation::filesForDelayedDeletion() const
+{
+ return d->delayedDeletionFiles;
+}
+
+/*!
+ Registers a file to be deleted later, once the application was restarted
+ (and the file isn't used anymore for sure).
+ @param files the files to be registered
+*/
+void UpdateOperation::registerForDelayedDeletion( const QStringList& files )
+{
+ d->delayedDeletionFiles << files;
+}
+
+/*!
+ Tries to delete \a file. If \a file can't be deleted, it gets registered for delayed deletion.
+*/
+bool UpdateOperation::deleteFileNowOrLater( const QString& file, QString* errorString )
+{
+ if( file.isEmpty() || QFile::remove( file ) )
+ return true;
+
+ if( !QFile::exists( file ) )
+ return true;
+
+ const QString backup = backupFileName( file );
+ QFile f( file );
+ if( !f.rename( backup ) )
+ {
+ if ( errorString )
+ *errorString = f.errorString();
+ return false;
+ }
+ registerForDelayedDeletion( QStringList( backup ) );
+ return true;
+}
+
+/*!
+ Returns a pointer to the current Application
+*/
+Application* UpdateOperation::application() const
+{
+ return d->application;
+}
+
+/*!
+ \fn virtual void KDUpdater::UpdateOperation::backup() = 0;
+
+ Subclasses must implement this function to backup any data before performing the action.
+*/
+
+/*!
+ \fn virtual bool KDUpdater::UpdateOperation::performOperation() = 0;
+
+ Subclasses must implement this function to perform the update operation
+*/
+
+/*!
+ \fn virtual bool KDUpdater::UpdateOperation::undoOperation() = 0;
+
+ Subclasses must implement this function to perform the reverse of the operation.
+*/
+
+/*!
+ \fn virtual bool KDUpdater::UpdateOperation::testOperation() = 0;
+
+ Subclasses must implement this function to perform the test operation.
+*/
+
+/*!
+ \fn virtual bool KDUpdater::UpdateOperation::clone() = 0;
+
+ Subclasses must implement this function to clone the current operation.
+*/
+
+/*!
+ Saves this UpdateOperation in XML. You can override this method to store your own extra-data.
+ The default implementation is taking care of arguments and values set via setValue.
+*/
+QDomDocument UpdateOperation::toXml() const
+{
+ QDomDocument doc;
+ QDomElement root = doc.createElement( QLatin1String("operation") );
+ doc.appendChild( root );
+ QDomElement args = doc.createElement( QLatin1String("arguments") );
+ Q_FOREACH( const QString &s, arguments() ) {
+ QDomElement arg = doc.createElement( QLatin1String("argument") );
+ arg.appendChild( doc.createTextNode(s) );
+ args.appendChild( arg );
+ }
+ root.appendChild( args );
+ if( d->values.isEmpty() )
+ return doc;
+
+ // append all values set with setValue
+ QDomElement values = doc.createElement( QLatin1String( "values" ) );
+ for( QVariantMap::const_iterator it = d->values.begin(); it != d->values.end(); ++it )
+ {
+ QDomElement value = doc.createElement( QLatin1String( "value" ) );
+ const QVariant& variant = it.value();
+ value.setAttribute( QLatin1String( "name" ), it.key() );
+ value.setAttribute( QLatin1String( "type" ), QLatin1String( QVariant::typeToName( variant.type() ) ) );
+
+ if( variant.type() != QVariant::List && variant.type() != QVariant::StringList && qVariantCanConvert< QString >( variant ) )
+ {
+ // it can convert to string? great!
+ value.appendChild( doc.createTextNode( variant.toString() ) );
+ }
+ else
+ {
+ // no? then we have to go the hard way...
+ QByteArray data;
+ QDataStream stream( &data, QIODevice::WriteOnly );
+ stream << variant;
+ value.appendChild( doc.createTextNode( QLatin1String( data.toBase64().data() ) ) );
+ }
+ values.appendChild( value );
+ }
+ root.appendChild( values );
+ return doc;
+}
+
+/*!
+ Restores UpdateOperation's arguments and values from the XML document \a doc.
+ Returns true on success, otherwise false.
+*/
+bool UpdateOperation::fromXml( const QDomDocument &doc )
+{
+ QStringList args;
+ const QDomElement root = doc.documentElement();
+ const QDomElement argsElem = root.firstChildElement( QLatin1String("arguments") );
+ Q_ASSERT( ! argsElem.isNull() );
+ for( QDomNode n = argsElem.firstChild(); ! n.isNull(); n = n.nextSibling() ) {
+ const QDomElement e = n.toElement();
+ if( !e.isNull() && e.tagName() == QLatin1String("argument") )
+ args << e.text();
+ }
+ setArguments(args);
+
+ d->values.clear();
+ const QDomElement values = root.firstChildElement( QLatin1String( "values" ) );
+ for( QDomNode n = values.firstChild(); !n.isNull(); n = n.nextSibling() )
+ {
+ const QDomElement v = n.toElement();
+ if( v.isNull() || v.tagName() != QLatin1String( "value" ) )
+ continue;
+
+ const QString name = v.attribute( QLatin1String( "name" ) );
+ const QString type = v.attribute( QLatin1String( "type" ) );
+ const QString value = v.text();
+
+ const QVariant::Type t = QVariant::nameToType( type.toLatin1().data() );
+ QVariant var = qVariantFromValue( value );
+ if( t == QVariant::List || t == QVariant::StringList || !var.convert( t ) )
+ {
+ QDataStream stream( QByteArray::fromBase64( value.toLatin1() ) );
+ stream >> var;
+ }
+
+ d->values[ name ] = var;
+ }
+
+ return true;
+}
+
+/*!
+ Restores UpdateOperation's arguments and values from the XML document at path \a xml.
+ Returns true on success, otherwise false.
+ \overload
+*/
+bool UpdateOperation::fromXml( const QString &xml )
+{
+ QDomDocument doc;
+ QString errorMsg;
+ int errorLine;
+ int errorColumn;
+ if ( ! doc.setContent( xml, &errorMsg, &errorLine, &errorColumn ) ) {
+ qWarning() << "Error parsing xml error=" << errorMsg << "line=" << errorLine << "column=" << errorColumn;
+ return false;
+ }
+ return fromXml(doc);
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.h
new file mode 100644
index 000000000..53111d23a
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperation.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_OPERATION_H
+#define KD_UPDATER_UPDATE_OPERATION_H
+
+#include "kdupdater.h"
+
+#include <QCoreApplication>
+#include <QStringList>
+#include <QVariant>
+#include <QDomDocument>
+
+namespace KDUpdater
+{
+ class Application;
+
+ class KDTOOLS_UPDATER_EXPORT UpdateOperation
+ {
+ Q_DECLARE_TR_FUNCTIONS(UpdateOperation)
+
+ public:
+ enum Error {
+ NoError=0,
+ InvalidArguments=1,
+ UserDefinedError=128
+ };
+
+ UpdateOperation();
+ virtual ~UpdateOperation();
+
+ QString name() const;
+ QString operationCommand() const;
+
+ bool hasValue( const QString& name ) const;
+ void clearValue( const QString& name );
+ QVariant value( const QString& name ) const;
+ void setValue( const QString& name, const QVariant &value );
+
+ void setArguments(const QStringList& args);
+ void setApplication( Application* application );
+ QStringList arguments() const;
+ void clear();
+ QString errorString() const;
+ int error() const;
+ QStringList filesForDelayedDeletion() const;
+
+ virtual void backup() = 0;
+ virtual bool performOperation() = 0;
+ virtual bool undoOperation() = 0;
+ virtual bool testOperation() = 0;
+ virtual UpdateOperation* clone() const = 0;
+
+ virtual QDomDocument toXml() const;
+ virtual bool fromXml( const QString &xml );
+ virtual bool fromXml( const QDomDocument &doc );
+
+ protected:
+ void setName(const QString& name);
+ Application* application() const;
+ void setErrorString( const QString& errorString );
+ void setError( int error, const QString& errorString = QString() );
+ void registerForDelayedDeletion( const QStringList& files );
+ bool deleteFileNowOrLater( const QString& file, QString* errorString=0 );
+
+ private:
+ struct UpdateOperationData;
+ UpdateOperationData* d;
+ };
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp
new file mode 100644
index 000000000..076af5273
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdateoperationfactory.h"
+#include "kdupdaterupdateoperations.h"
+
+#include <QHash>
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::UpdateOperationFactory kdupdaterupdateoperationfactory.h KDUpdaterUpdateOperationFactory
+ \brief Factory for \ref KDUpdater::UpdateOperation
+
+ This class acts as a factory for \ref KDUpdater::UpdateOperation. You can register
+ one or more update operations with this factory and query operations based on their name.
+
+ This class follows the singleton design pattern. Only one instance of this class can
+ be created and its reference can be fetched from the \ref instance() method.
+*/
+
+/*!
+ \fn KDUpdater::UpdateOperationFactory::registerUpdateOperation( const QString& name )
+
+ Registers T as new UpdateOperation with \a name. When create() is called with that \a name,
+ T is constructed using its default constructor.
+*/
+
+using namespace KDUpdater;
+
+struct UpdateOperationFactory::UpdateOperationFactoryData
+{
+};
+
+/*!
+ Returns the UpdateOperationFactory instance. The instance is created if needed.
+*/
+UpdateOperationFactory& UpdateOperationFactory::instance()
+{
+ static UpdateOperationFactory theFactory;
+ return theFactory;
+}
+
+/*!
+ Constructor
+*/
+UpdateOperationFactory::UpdateOperationFactory()
+ : d ( new UpdateOperationFactoryData )
+{
+ // Register the default update operation set
+ registerUpdateOperation< CopyOperation >( QLatin1String( "Copy" ) );
+ registerUpdateOperation< MoveOperation >( QLatin1String( "Move" ) );
+ registerUpdateOperation< DeleteOperation >( QLatin1String( "Delete" ) );
+ registerUpdateOperation< MkdirOperation >( QLatin1String( "Mkdir" ) );
+ registerUpdateOperation< RmdirOperation >( QLatin1String( "Rmdir" ) );
+ registerUpdateOperation< AppendFileOperation >( QLatin1String( "AppendFile" ) );
+ registerUpdateOperation< PrependFileOperation >( QLatin1String( "PrependFile" ) );
+ registerUpdateOperation< ExecuteOperation >( QLatin1String( "Execute" ) );
+ registerUpdateOperation< UpdatePackageOperation >( QLatin1String( "UpdatePackage" ) );
+ registerUpdateOperation< UpdateCompatOperation >( QLatin1String( "UpdateCompat" ) );
+}
+
+UpdateOperationFactory::~UpdateOperationFactory()
+{
+}
+
+/*!
+ Returns the number of update operations in the factory.
+*/
+int UpdateOperationFactory::updateOperationCount() const
+{
+ return productCount();
+}
+
+/*!
+ Returns a list containing the names of all available UpdateOperations.
+*/
+QStringList UpdateOperationFactory::availableUpdateOperations() const
+{
+ return availableProducts();
+}
+
+/*
+ Unregisters the update operation previously registered with \a name.
+*/
+void UpdateOperationFactory::unregisterUpdateOperation( const QString& name )
+{
+ unregisterProduct( name );
+}
+
+/*!
+ Registers \a create to be a factory function to create an UpdateOperation with \a name.
+ \sa registerUpdateOperation
+*/
+void UpdateOperationFactory::registerUpdateOperationFactory( const QString& name, UpdateOperationFactoryFunction create )
+{
+ registerProductionFunction( name, create );
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h
new file mode 100644
index 000000000..d42a871c3
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperationfactory.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_OPERATION_FACTORY_H
+#define KD_UPDATER_UPDATE_OPERATION_FACTORY_H
+
+#include <KDToolsCore/kdgenericfactory.h>
+
+#include "kdupdater.h"
+#include <KDToolsCore/pimpl_ptr.h>
+
+namespace KDUpdater
+{
+ class UpdateOperation;
+
+ typedef KDGenericFactory< UpdateOperation >::FactoryFunction UpdateOperationFactoryFunction;
+
+ class KDTOOLS_UPDATER_EXPORT UpdateOperationFactory : public KDGenericFactory< UpdateOperation >
+ {
+ Q_DISABLE_COPY( UpdateOperationFactory )
+ public:
+ static UpdateOperationFactory& instance();
+ ~UpdateOperationFactory();
+
+ template< class T >
+ void registerUpdateOperation( const QString& name )
+ {
+ registerProduct< T >( name );
+ }
+ void registerUpdateOperationFactory( const QString& name, UpdateOperationFactoryFunction create );
+
+ void unregisterUpdateOperation( const QString& name );
+
+ int updateOperationCount() const;
+ QStringList availableUpdateOperations() const;
+
+ protected:
+ UpdateOperationFactory();
+
+ private:
+ struct UpdateOperationFactoryData;
+ kdtools::pimpl_ptr<UpdateOperationFactoryData> d;
+ };
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.cpp
new file mode 100644
index 000000000..a1486d34d
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.cpp
@@ -0,0 +1,1120 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdateoperations.h"
+#include "kdupdaterapplication.h"
+#include "kdupdaterpackagesinfo.h"
+#include "environment.h"
+
+#include <QFile>
+#include <QDir>
+#include <QDirIterator>
+#include <QProcess>
+#include <QTextStream>
+#include <QDebug>
+#include <QTemporaryFile>
+
+
+#include <cerrno>
+
+#define SUPPORT_DETACHED_PROCESS_EXECUTION
+
+#ifdef SUPPORT_DETACHED_PROCESS_EXECUTION
+#ifdef Q_WS_WIN
+#include <windows.h>
+#endif
+#endif
+
+using namespace KDUpdater;
+
+static bool removeDirectory( const QString& path, QString* errorString )
+{
+ Q_ASSERT( errorString );
+ const QFileInfoList entries = QDir( path ).entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden );
+ for( QFileInfoList::const_iterator it = entries.constBegin(); it != entries.constEnd(); ++it )
+ {
+ if( it->isDir() && !it->isSymLink() )
+ {
+ removeDirectory( it->filePath(), errorString );
+ }
+ else
+ {
+ QFile f( it->filePath() );
+ if( !f.remove() )
+ return false;
+ }
+ }
+
+ errno = 0;
+ const bool success = QDir().rmdir( path );
+ if ( errno )
+ *errorString = QLatin1String( strerror(errno) );
+ return success;
+}
+/*
+ * \internal
+ * Returns a filename for a temporary file based on \a templateName
+ */
+static QString backupFileName( const QString& templateName = QString() )
+{
+ QTemporaryFile file( templateName );
+ file.open();
+ const QString name = file.fileName();
+ file.close();
+ file.remove();
+ return name;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::CopyOperation
+////////////////////////////////////////////////////////////////////////////
+
+CopyOperation::CopyOperation()
+{
+ setName(QLatin1String( "Copy" ));
+}
+
+CopyOperation::~CopyOperation()
+{
+ deleteFileNowOrLater( value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
+}
+
+void CopyOperation::backup()
+{
+ const QString dest = arguments().last();
+ if( !QFile::exists( dest ) )
+ {
+ clearValue( QLatin1String( "backupOfExistingDestination" ) );
+ return;
+ }
+
+ setValue( QLatin1String( "backupOfExistingDestination" ), backupFileName( dest ) );
+
+ // race condition: The backup file could get created
+ // by another process right now. But this is the same
+ // in QFile::copy...
+ const bool success = QFile::rename( dest, value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
+ if(!success)
+ setError( UserDefinedError, tr("Could not backup file %1").arg(dest) );
+}
+
+bool CopyOperation::performOperation()
+{
+ // We need two args to complete the copy operation.
+ // First arg provides the complete file name of source
+ // Second arg provides the complete file name of dest
+ QStringList args = this->arguments();
+ if( args.count() != 2 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ return false;
+ }
+ QString source = args.first();
+ QString dest = args.last();
+
+ // If destination file exists, then we cannot use QFile::copy()
+ // because it does not overwrite an existing file. So we remove
+ // the destination file.
+ if( QFile::exists(dest) )
+ {
+ QFile file( dest );
+ if( !file.remove() ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not remove destination file %1: %2.").arg( dest, file.errorString() ) );
+ return false;
+ }
+ }
+
+ QFile file( source );
+ const bool copied = file.copy( dest );
+ if ( !copied ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not copy %1 to %2: %3.").arg( source, dest, file.errorString() ) );
+ }
+ return copied;
+}
+
+bool CopyOperation::undoOperation()
+{
+ const QString dest = arguments().last();
+
+ QFile destF( dest );
+ // first remove the dest
+ if( !destF.remove() )
+ {
+ setError( UserDefinedError, tr("Could not delete file %1: %2").arg(dest, destF.errorString()) );
+ return false;
+ }
+
+ // no backup was done:
+ // the copy destination file wasn't existing yet - that's no error
+ if( !hasValue( QLatin1String( "backupOfExistingDestination" ) ) )
+ return true;
+
+ QFile backupF( value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
+ // otherwise we have to copy the backup back:
+ const bool success = backupF.rename( dest );
+ if(!success) {
+ setError( UserDefinedError, tr("Could not restore backup file into %1: %2").arg(dest, backupF.errorString()) );
+ }
+ return success;
+}
+
+/*!
+ \reimp
+ */
+QDomDocument CopyOperation::toXml() const
+{
+ // we don't want to save the backupOfExistingDestination
+ if( !hasValue( QLatin1String( "backupOfExistingDestination" ) ) )
+ return UpdateOperation::toXml();
+
+ CopyOperation* const me = const_cast< CopyOperation* >( this );
+
+ const QVariant v = value( QLatin1String( "backupOfExistingDestination" ) );
+ me->clearValue( QLatin1String( "backupOfExistingDestination" ) );
+ const QDomDocument xml = UpdateOperation::toXml();
+ me->setValue( QLatin1String( "backupOfExistingDestination" ), v );
+ return xml;
+}
+
+bool CopyOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+CopyOperation* CopyOperation::clone() const
+{
+ return new CopyOperation();
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::MoveOperation
+////////////////////////////////////////////////////////////////////////////
+
+MoveOperation::MoveOperation()
+{
+ setName(QLatin1String( "Move" ));
+}
+
+MoveOperation::~MoveOperation()
+{
+ deleteFileNowOrLater( value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
+}
+
+void MoveOperation::backup()
+{
+ const QString dest = arguments().last();
+ if( !QFile::exists( dest ) )
+ {
+ clearValue( QLatin1String( "backupOfExistingDestination" ) );
+ return;
+ }
+
+ setValue( QLatin1String( "backupOfExistingDestination" ), backupFileName( dest ) );
+
+ // race condition: The backup file could get created
+ // by another process right now. But this is the same
+ // in QFile::copy...
+ const bool success = QFile::rename( dest, value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
+ if(!success)
+ setError( UserDefinedError, tr("Could not backup file %1").arg(dest) );
+}
+
+bool MoveOperation::performOperation()
+{
+ // We need two args to complete the copy operation.
+ // First arg provides the complete file name of source
+ // Second arg provides the complete file name of dest
+ QStringList args = this->arguments();
+ if( args.count() != 2 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ return false;
+ }
+
+ QString source = args.first();
+ QString dest = args.last();
+
+ // If destination file exists, then we cannot use QFile::copy()
+ // because it does not overwrite an existing file. So we remove
+ // the destination file.
+ if( QFile::exists(dest) )
+ {
+ QFile file( dest );
+ if( !file.remove(dest) ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not remove destination file %1: %2.").arg( dest, file.errorString() ) );
+ return false;
+ }
+ }
+
+ // Copy source to destination.
+ QFile file( source );
+ const bool copied = file.copy( source, dest );
+ if ( !copied ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not copy %1 to %2: %3.").arg( source, dest, file.errorString() ) );
+ return false;
+ }
+
+ return deleteFileNowOrLater( source );
+}
+
+bool MoveOperation::undoOperation()
+{
+ const QStringList args = arguments();
+ const QString& source = args.first();
+ const QString& dest = args.last();
+
+ // first: copy back the destination to source
+ QFile destF( dest );
+ if( !destF.copy( source ) )
+ {
+ setError( UserDefinedError, tr("Cannot copy %1 to %2: %3").arg( dest, source, destF.errorString() ) );
+ return false;
+ }
+
+ // second: delete the move destination
+ if( !deleteFileNowOrLater( dest ) )
+ {
+ setError( UserDefinedError, tr( "Cannot remove file %1" ) );
+ return false;
+ }
+
+ // no backup was done:
+ // the move destination file wasn't existing yet - that's no error
+ if( !hasValue( QLatin1String( "backupOfExistingDestination" ) ) )
+ return true;
+
+ // otherwise we have to copy the backup back:
+ QFile backupF( value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
+ const bool success = backupF.rename( dest );
+ if(!success)
+ setError( UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(dest, backupF.errorString()) );
+
+ return success;
+}
+
+bool MoveOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+MoveOperation* MoveOperation::clone() const
+{
+ return new MoveOperation;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::DeleteOperation
+////////////////////////////////////////////////////////////////////////////
+
+DeleteOperation::DeleteOperation()
+{
+ setName(QLatin1String( "Delete" ));
+}
+
+DeleteOperation::~DeleteOperation()
+{
+ deleteFileNowOrLater( value( QLatin1String( "backupOfExistingFile" ) ).toString() );
+}
+
+void DeleteOperation::backup()
+{
+ const QString fileName = arguments().first();
+ setValue( QLatin1String( "backupOfExistingFile" ), backupFileName( fileName ) );
+ QFile file( fileName );
+ const bool success = file.copy( value( QLatin1String( "backupOfExistingFile" ) ).toString() );
+ if(!success)
+ setError( UserDefinedError, tr("Cannot create backup of %1: %2").arg(fileName, file.errorString()) );
+}
+
+bool DeleteOperation::performOperation()
+{
+ // Requires only one parameter. That is the name of
+ // the file to remove.
+ QStringList args = this->arguments();
+ if( args.count() != 1 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments: %1 arguments given, 1 expected.").arg( args.count() ) );
+ return false;
+ }
+
+ const QString fName = args.first();
+ return deleteFileNowOrLater( fName );
+}
+
+bool DeleteOperation::undoOperation()
+{
+ if( !hasValue( QLatin1String( "backupOfExistingFile" ) ) )
+ return true;
+
+ const QString fileName = arguments().first();
+ QFile backupF( value( QLatin1String( "backupOfExistingFile" ) ).toString() );
+ const bool success = backupF.copy( fileName ) && deleteFileNowOrLater( backupF.fileName() );
+ if(!success)
+ setError( UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(fileName, backupF.errorString()) );
+
+ return success;
+}
+
+bool DeleteOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+DeleteOperation* DeleteOperation::clone() const
+{
+ return new DeleteOperation;
+}
+
+/*!
+ \reimp
+ */
+QDomDocument DeleteOperation::toXml() const
+{
+ // we don't want to save the backupOfExistingFile
+ if( !hasValue( QLatin1String( "backupOfExistingFile" ) ) )
+ return UpdateOperation::toXml();
+
+ DeleteOperation* const me = const_cast< DeleteOperation* >( this );
+
+ const QVariant v = value( QLatin1String( "backupOfExistingFile" ) );
+ me->clearValue( QLatin1String( "backupOfExistingFile" ) );
+ const QDomDocument xml = UpdateOperation::toXml();
+ me->setValue( QLatin1String( "backupOfExistingFile" ), v );
+ return xml;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::MkdirOperation
+////////////////////////////////////////////////////////////////////////////
+
+MkdirOperation::MkdirOperation()
+{
+ setName(QLatin1String( "Mkdir" ));
+}
+
+MkdirOperation::~MkdirOperation()
+{
+
+}
+
+void MkdirOperation::backup()
+{
+ static const QRegExp re( QLatin1String( "\\\\|/" ) );
+ static const QLatin1String sep( "/" );
+
+ QString path = arguments().first();
+ path.replace( re, sep );
+
+ QDir createdDir = QDir::root();
+
+ // find out, which part of the path is the first one we actually need to create
+ int end = 0;
+ while( true )
+ {
+ QString p = path.section( sep, 0, ++end );
+ createdDir = QDir( p );
+ if( !createdDir.exists() )
+ break;
+ else if( p == path )
+ {
+ // everything did already exist -> nothing to do for us (nothing to revert then, either)
+ createdDir = QDir::root();
+ break;
+ }
+ }
+
+ setValue( QLatin1String( "createddir" ), createdDir.absolutePath() );
+}
+
+bool MkdirOperation::performOperation()
+{
+ // Requires only one parameter. That is the name of
+ // the file to remove.
+ QStringList args = this->arguments();
+ if( args.count() != 1 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments: %1 arguments given, 1 expected.").arg( args.count() ) );
+ return false;
+ }
+ QString dirName = args.first();
+ const bool created = QDir::root().mkpath(dirName);
+ if ( !created ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not create folder %1: Unknown error.").arg( dirName ) );
+ }
+ return created;
+}
+
+bool MkdirOperation::undoOperation()
+{
+ Q_ASSERT( arguments().count() == 1 );
+ QString dirName = arguments().first();
+
+ const QDir createdDir = QDir( value( QLatin1String( "createddir" ) ).toString() );
+ const bool forceremoval = QVariant( value( QLatin1String( "forceremoval" ) ) ).toBool();
+
+ if( createdDir == QDir::root() )
+ return true;
+
+ QString errorString;
+ if( forceremoval )
+ {
+ return removeDirectory( createdDir.path(), &errorString );
+ }
+
+ // even remove some hidden, OS-created files in there
+#if defined Q_WS_MAC
+ QFile::remove( createdDir.path() + QLatin1String( "/.DS_Store" ) );
+#elif defined Q_WS_WIN
+ QFile::remove( createdDir.path() + QLatin1String( "/Thumbs.db" ) );
+#endif
+
+ errno = 0;
+ const bool result = QDir::root().rmdir( createdDir.path() );
+ if ( !result ) {
+ if ( errorString.isEmpty() )
+ setError( UserDefinedError, tr("Cannot remove directory %1: %2").arg( createdDir.path(), errorString ) );
+ else
+ setError( UserDefinedError, tr("Cannot remove directory %1: %2").arg( createdDir.path(), QLatin1String(strerror(errno)) ) );
+ }
+ return result;
+}
+
+bool KDUpdater::MkdirOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+MkdirOperation* MkdirOperation::clone() const
+{
+ return new MkdirOperation;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::RmdirOperation
+////////////////////////////////////////////////////////////////////////////
+
+RmdirOperation::RmdirOperation()
+{
+ setValue( QLatin1String( "removed" ), false );
+ setName(QLatin1String( "Rmdir" ));
+}
+
+RmdirOperation::~RmdirOperation()
+{
+
+}
+
+void RmdirOperation::backup()
+{
+ // nothing to backup - rollback will just create the directory
+}
+
+bool RmdirOperation::performOperation()
+{
+ // Requires only one parameter. That is the name of
+ // the file to remove.
+ QStringList args = this->arguments();
+ if( args.count() != 1 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments: %1 arguments given, 1 expected.").arg( args.count() ) );
+ return false;
+ }
+
+ QString dirName = args.first();
+ QDir dir( dirName );
+ if( !dir.exists() ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not remove folder %1: The folder does not exist.").arg( dirName ) );
+ return false;
+ }
+
+ errno = 0;
+ const bool removed = dir.rmdir( dirName );
+ setValue( QLatin1String( "removed" ), removed );
+ if ( !removed ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not remove folder %1: %2.").arg( dirName, QLatin1String(strerror(errno)) ) );
+ }
+ return removed;
+}
+
+bool RmdirOperation::undoOperation()
+{
+ if( !value( QLatin1String( "removed" ) ).toBool() )
+ return true;
+
+ const QFileInfo fi( arguments().first() );
+ errno = 0;
+ const bool success = fi.dir().mkdir( fi.fileName() );
+ if(!success)
+ setError( UserDefinedError, tr("Cannot recreate directory %1: %2").arg( fi.fileName(), QLatin1String(strerror(errno)) ) );
+
+ return success;
+}
+
+bool RmdirOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+RmdirOperation* RmdirOperation::clone() const
+{
+ return new RmdirOperation;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::AppendFileOperation
+////////////////////////////////////////////////////////////////////////////
+
+AppendFileOperation::AppendFileOperation()
+{
+ setName(QLatin1String( "AppendFile" ));
+}
+
+AppendFileOperation::~AppendFileOperation()
+{
+
+}
+
+void AppendFileOperation::backup()
+{
+ const QString filename = arguments().first();
+
+ QFile file( filename );
+ if( !file.exists() )
+ return; // nothing to backup
+
+ setValue( QLatin1String( "backupOfFile" ), backupFileName( filename ) );
+ if( !file.copy( value( QLatin1String( "backupOfFile" ) ).toString() ) )
+ {
+ setError( UserDefinedError, tr("Cannot backup file %1: %2").arg(filename, file.errorString()) );
+ clearValue( QLatin1String( "backupOfFile" ) );
+ }
+}
+
+bool AppendFileOperation::performOperation()
+{
+ // This operation takes two arguments. First argument is the name
+ // of the file into which a text has to be appended. Second argument
+ // is the text to append.
+ QStringList args = this->arguments();
+ if( args.count() != 2 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ return false;
+ }
+
+ QString fName = args.first();
+ QString text = args.last();
+
+ QFile file(fName);
+ if( !file.open(QFile::Append) )
+ {
+ // first we rename the file, then we copy it to the real target and open the copy - the renamed original is then marked for deletion
+ const QString newName = backupFileName( fName );
+ if( !QFile::rename( fName, newName ) && QFile::copy( newName, fName ) && file.open( QFile::Append ) )
+ {
+ QFile::rename( newName, fName );
+ setError( UserDefinedError );
+ setErrorString( tr("Could not open file %1 for writing: %2.").arg( file.fileName(), file.errorString() ) );
+ return false;
+ }
+ deleteFileNowOrLater( newName );
+ }
+
+ QTextStream ts(&file);
+ ts << text;
+ file.close();
+
+ return true;
+}
+
+bool AppendFileOperation::undoOperation()
+{
+ // backupOfFile being empty -> file didn't exist before -> no error
+ const QString filename = arguments().first();
+ const QString backupOfFile = value( QLatin1String( "backupOfFile" ) ).toString();
+ if( !backupOfFile.isEmpty() && !QFile::exists( backupOfFile ) )
+ {
+ setError( UserDefinedError, tr("Cannot find backup file for %1").arg(filename) );
+ return false;
+ }
+
+ const bool removed = deleteFileNowOrLater( filename );
+ if ( !removed ) {
+ setError( UserDefinedError, tr("Could not restore backup file for %1.").arg( filename ) );
+ return false;
+ }
+
+ // got deleted? We might be done, if it didn't exist before
+ if( backupOfFile.isEmpty() )
+ return true;
+
+ QFile backupFile( backupOfFile );
+ const bool success = backupFile.rename( filename );
+ if ( !success )
+ setError( UserDefinedError, tr("Could not restore backup file for %1: %2").arg(filename, backupFile.errorString()) );
+ return success;
+}
+
+bool AppendFileOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+AppendFileOperation* AppendFileOperation::clone() const
+{
+ return new AppendFileOperation;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::PrependFileOperation
+////////////////////////////////////////////////////////////////////////////
+
+PrependFileOperation::PrependFileOperation()
+{
+ setName(QLatin1String( "PrependFile" ));
+}
+
+PrependFileOperation::~PrependFileOperation()
+{
+
+}
+
+void PrependFileOperation::backup()
+{
+ const QString filename = arguments().first();
+
+ QFile file( filename );
+ if( !file.exists() )
+ return; // nothing to backup
+
+ setValue( QLatin1String( "backupOfFile" ), backupFileName( filename ) );
+ if( !file.copy( value( QLatin1String( "backupOfFile" ) ).toString() ) )
+ {
+ setError( UserDefinedError, tr("Cannot backup file %1: %2").arg(filename, file.errorString()) );
+ clearValue( QLatin1String( "backupOfFile" ) );
+ }
+}
+
+bool PrependFileOperation::performOperation()
+{
+ // This operation takes two arguments. First argument is the name
+ // of the file into which a text has to be appended. Second argument
+ // is the text to append.
+ QStringList args = this->arguments();
+ if( args.count() != 2 ) {\
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ return false;
+ }
+
+ QString fName = args.first();
+ QString text = args.last();
+
+ // Load the file first.
+ QFile file(fName);
+ if( !file.open(QFile::ReadOnly) ) {
+ setError( UserDefinedError );
+ setErrorString( tr("Could not open file %1 for reading: %2.").arg( file.fileName(), file.errorString() ) );
+ return false;
+ }
+ QString fContents( QLatin1String( file.readAll() ) );
+ file.close();
+
+ // Prepend text to the file text
+ fContents = text + fContents;
+
+ // Now re-open the file in write only mode.
+ if( !file.open(QFile::WriteOnly) ) {
+ // first we rename the file, then we copy it to the real target and open the copy - the renamed original is then marked for deletion
+ const QString newName = backupFileName( fName );
+ if( !QFile::rename( fName, newName ) && QFile::copy( newName, fName ) && file.open( QFile::WriteOnly ) )
+ {
+ QFile::rename( newName, fName );
+ setError( UserDefinedError );
+ setErrorString( tr("Could not open file %1 for writing: %2.").arg( file.fileName(), file.errorString() ) );
+ return false;
+ }
+ deleteFileNowOrLater( newName );
+ }
+ QTextStream ts(&file);
+ ts << fContents;
+ file.close();
+
+ return true;
+}
+
+bool PrependFileOperation::undoOperation()
+{
+ // bockupOfFile being empty -> file didn't exist before -> no error
+ const QString filename = arguments().first();
+ const QString backupOfFile = value( QLatin1String( "backupOfFile" ) ).toString();
+ if( !backupOfFile.isEmpty() && !QFile::exists( backupOfFile ) )
+ {
+ setError( UserDefinedError, tr("Cannot find backup file for %1").arg(filename) );
+ return false;
+ }
+
+ if( !deleteFileNowOrLater( filename ) )
+ {
+ setError( UserDefinedError, tr("Cannot restore backup file for %1").arg( filename ) );
+ return false;
+ }
+
+ // got deleted? We might be done, if it didn't exist before
+ if( backupOfFile.isEmpty() )
+ return true;
+
+ QFile backupF( backupOfFile );
+ const bool success = backupF.rename( filename );
+ if(!success)
+ setError( UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(filename, backupF.errorString()) );
+
+ return success;
+}
+
+bool PrependFileOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+PrependFileOperation* PrependFileOperation::clone() const
+{
+ return new PrependFileOperation;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::ExecuteOperation
+////////////////////////////////////////////////////////////////////////////
+
+ExecuteOperation::ExecuteOperation()
+ : QObject()
+{
+ setName(QLatin1String( "Execute" ));
+}
+
+ExecuteOperation::~ExecuteOperation()
+{
+
+}
+
+void ExecuteOperation::backup()
+{
+ // this is not possible, since the process can do whatever...
+}
+
+#if defined( SUPPORT_DETACHED_PROCESS_EXECUTION ) && defined( Q_WS_WIN )
+// stolen from qprocess_win.cpp
+static QString qt_create_commandline(const QString &program, const QStringList &arguments)
+{
+ QString args;
+ if (!program.isEmpty()) {
+ QString programName = program;
+ if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
+ programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
+ programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
+
+ // add the prgram as the first arg ... it works better
+ args = programName + QLatin1Char(' ');
+ }
+
+ for (int i=0; i<arguments.size(); ++i) {
+ QString tmp = arguments.at(i);
+ // in the case of \" already being in the string the \ must also be escaped
+ tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
+ // escape a single " because the arguments will be parsed
+ tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
+ if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
+ // The argument must not end with a \ since this would be interpreted
+ // as escaping the quote -- rather put the \ behind the quote: e.g.
+ // rather use "foo"\ than "foo\"
+ QString endQuote(QLatin1Char('\"'));
+ int i = tmp.length();
+ while (i>0 && tmp.at(i-1) == QLatin1Char('\\')) {
+ --i;
+ endQuote += QLatin1Char('\\');
+ }
+ args += QLatin1String(" \"") + tmp.left(i) + endQuote;
+ } else {
+ args += QLatin1Char(' ') + tmp;
+ }
+ }
+ return args;
+}
+#endif
+
+bool ExecuteOperation::performOperation()
+{
+ // This operation receives only one argument. It is the complete
+ // command line of the external program to execute.
+ QStringList args = this->arguments();
+ if( args.isEmpty() )
+ {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ return false;
+ }
+
+ QList< int > allowedExitCodes;
+
+ QRegExp re( QLatin1String( "^\\{((-?\\d+,)*-?\\d+)\\}$" ) );
+ if( re.exactMatch( args.first() ) )
+ {
+ const QStringList numbers = re.cap( 1 ).split( QLatin1Char( ',' ) );
+ for( QStringList::const_iterator it = numbers.begin(); it != numbers.end(); ++it )
+ allowedExitCodes.push_back( it->toInt() );
+ args.pop_front();
+ }
+ else
+ {
+ allowedExitCodes.push_back( 0 );
+ }
+
+ bool success = false;
+#ifdef SUPPORT_DETACHED_PROCESS_EXECUTION
+ // unix style: when there's an ampersand after the command, it's started detached
+ if( args.count() >= 2 && args.last() == QLatin1String( "&" ) )
+ {
+ args.pop_back();
+#ifdef Q_WS_WIN
+ QString arguments = qt_create_commandline( args.front(), args.mid( 1 ) );
+
+ PROCESS_INFORMATION pinfo;
+
+ STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
+ static_cast< ulong >( CW_USEDEFAULT ), static_cast< ulong >( CW_USEDEFAULT ),
+ static_cast< ulong >( CW_USEDEFAULT ), static_cast< ulong >( CW_USEDEFAULT ),
+ 0, 0, 0, STARTF_USESHOWWINDOW, SW_HIDE, 0, 0, 0, 0, 0
+ };
+ success = CreateProcess( 0, const_cast< wchar_t* >( static_cast< const wchar_t* >( arguments.utf16() ) ),
+ 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
+ 0,
+ &startupInfo, &pinfo );
+
+#else
+ success = QProcess::startDetached( args.front(), args.mid( 1 ) );
+#endif
+ }
+ else
+#endif
+ {
+ Environment::instance()->applyTo( &process ); //apply non-persistent variables
+ process.start( args.front(), args.mid( 1 ) );
+
+ QEventLoop loop;
+ QObject::connect( &process, SIGNAL( finished( int, QProcess::ExitStatus ) ), &loop, SLOT( quit() ) );
+ QObject::connect( &process, SIGNAL(readyRead()), this, SLOT(readProcessOutput()));
+ success = process.waitForStarted( -1 );
+ if( success )
+ {
+ loop.exec();
+ setValue( QLatin1String( "ExitCode" ), process.exitCode() );
+ success = allowedExitCodes.contains( process.exitCode() );
+ }
+ }
+ if(!success)
+ {
+ setError( UserDefinedError );
+ setErrorString( tr("Execution failed: \"%1\"").arg( args.join( QLatin1String( " " ) ) ) );
+ }
+
+ return success;
+}
+
+/*!
+ Cancels the ExecuteOperation. This methods tries to terminate the process
+ gracefully by calling QProcess::terminate. After 10 seconds, the process gets killed.
+ */
+void ExecuteOperation::cancelOperation()
+{
+ if( process.state() == QProcess::Running )
+ process.terminate();
+ if( !process.waitForFinished( 10000 ) )
+ process.kill();
+}
+
+void ExecuteOperation::readProcessOutput()
+{
+ QByteArray output = process.readAll();
+ if (!output.isEmpty())
+ emit outputTextChanged(QString::fromLocal8Bit(output));
+}
+
+bool ExecuteOperation::undoOperation()
+{
+ // this is not possible, since the process can do whatever...
+ return false;
+}
+
+bool ExecuteOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+ExecuteOperation* ExecuteOperation::clone() const
+{
+ return new ExecuteOperation;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::UpdatePackageOperation
+////////////////////////////////////////////////////////////////////////////
+
+UpdatePackageOperation::UpdatePackageOperation()
+{
+ setName(QLatin1String( "UpdatePackage" ));
+}
+
+UpdatePackageOperation::~UpdatePackageOperation()
+{
+
+}
+
+void UpdatePackageOperation::backup()
+{
+ const PackageInfo info = application()->packagesInfo()->packageInfo( application()->packagesInfo()->findPackageInfo( arguments().first() ) );
+ setValue( QLatin1String( "oldVersion" ), info.version );
+ setValue( QLatin1String( "oldDate" ), info.lastUpdateDate );
+}
+
+bool UpdatePackageOperation::performOperation()
+{
+ // This operation receives three arguments : the name of the package
+ // the new version and the release date
+ const QStringList args = this->arguments();
+ if( args.count() != 3 )
+ {
+ setError( InvalidArguments, tr("Invalid arguments: %1 arguments given, 3 expected.").arg( args.count() ) );
+ return false;
+ }
+
+ const QString& packageName = args.at( 0 );
+ const QString& version = args.at( 1 );
+ const QDate date = QDate::fromString( args.at( 2 ) );
+ const bool success = application()->packagesInfo()->updatePackage( packageName, version, date );
+ if(!success)
+ setError( UserDefinedError, tr("Cannot update %1-%2").arg( packageName, version ) );
+
+ return success;
+}
+
+bool UpdatePackageOperation::undoOperation()
+{
+ const QString packageName = arguments().first();
+ const QString version = arguments().at( 1 );
+ const QString oldVersion = value( QLatin1String( "oldVersion" ) ).toString();
+ const QDate oldDate = value( QLatin1String( "oldDate" ) ).toDate();
+ const bool success = application()->packagesInfo()->updatePackage( packageName, oldVersion, oldDate );
+ if(!success)
+ setError( UserDefinedError, tr("Cannot restore %1-%2").arg( packageName, version ) );
+
+ return success;
+}
+
+bool UpdatePackageOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+UpdatePackageOperation* UpdatePackageOperation::clone() const
+{
+ return new UpdatePackageOperation;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+// KDUpdater::UpdateCompatOperation
+////////////////////////////////////////////////////////////////////////////
+
+UpdateCompatOperation::UpdateCompatOperation()
+{
+ setName(QLatin1String( "UpdateCompatLevel" ));
+}
+
+UpdateCompatOperation::~UpdateCompatOperation()
+{
+
+}
+
+void UpdateCompatOperation::backup()
+{
+ setValue( QLatin1String( "oldCompatLevel" ), application()->packagesInfo()->compatLevel() );
+}
+
+bool UpdateCompatOperation::performOperation()
+{
+ // This operation receives one argument : the new compat level
+ const QStringList args = this->arguments();
+ if( args.count() != 1 )
+ {
+ setError( InvalidArguments, tr("Invalid arguments: %1 arguments given, 1 expected.").arg( args.count() ) );
+ return false;
+ }
+
+ const int level = args.first().toInt();
+ application()->packagesInfo()->setCompatLevel( level );
+ return true;
+}
+
+bool UpdateCompatOperation::undoOperation()
+{
+ if( !hasValue( QLatin1String( "oldCompatLevel" ) ) )
+ {
+ setError( UserDefinedError, tr("Cannot restore previous compat-level") );
+ return false;
+ }
+
+ application()->packagesInfo()->setCompatLevel( value( QLatin1String( "oldCompatLevel" ) ).toInt() );
+ return true;
+}
+
+bool UpdateCompatOperation::testOperation()
+{
+ // TODO
+ return true;
+}
+
+UpdateCompatOperation* UpdateCompatOperation::clone() const
+{
+ return new UpdateCompatOperation;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.h
new file mode 100644
index 000000000..4f1a2563e
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdateoperations.h
@@ -0,0 +1,184 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_OPERATIONS_H
+#define KD_UPDATER_UPDATE_OPERATIONS_H
+
+#include "kdupdaterupdateoperation.h"
+
+#include <QDir>
+#include <QObject>
+#include <QProcess>
+
+namespace KDUpdater
+{
+
+ class KDTOOLS_UPDATER_EXPORT CopyOperation : public UpdateOperation
+ {
+ public:
+ CopyOperation();
+ ~CopyOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ CopyOperation* clone() const;
+
+ QDomDocument toXml() const;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT MoveOperation : public UpdateOperation
+ {
+ public:
+ MoveOperation();
+ ~MoveOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ MoveOperation* clone() const;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT DeleteOperation : public UpdateOperation
+ {
+ public:
+ DeleteOperation();
+ ~DeleteOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ DeleteOperation* clone() const;
+
+ QDomDocument toXml() const;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT MkdirOperation : public UpdateOperation
+ {
+ public:
+ MkdirOperation();
+ ~MkdirOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ MkdirOperation* clone() const;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT RmdirOperation : public UpdateOperation
+ {
+ public:
+ RmdirOperation();
+ ~RmdirOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ RmdirOperation* clone() const;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT AppendFileOperation : public UpdateOperation
+ {
+ public:
+ AppendFileOperation();
+ ~AppendFileOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ AppendFileOperation* clone() const;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT PrependFileOperation : public UpdateOperation
+ {
+ public:
+ PrependFileOperation();
+ ~PrependFileOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ PrependFileOperation* clone() const;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT ExecuteOperation : public QObject, public UpdateOperation
+ {
+ Q_OBJECT
+ public:
+ ExecuteOperation();
+ ~ExecuteOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ ExecuteOperation* clone() const;
+
+ public Q_SLOTS:
+ void cancelOperation();
+
+ private Q_SLOTS:
+ void readProcessOutput();
+
+ Q_SIGNALS:
+ void outputTextChanged(const QString &text);
+
+ private:
+ QProcess process;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT UpdatePackageOperation : public UpdateOperation
+ {
+ public:
+ UpdatePackageOperation();
+ ~UpdatePackageOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ UpdatePackageOperation* clone() const;
+ };
+
+ class KDTOOLS_UPDATER_EXPORT UpdateCompatOperation : public UpdateOperation
+ {
+ public:
+ UpdateCompatOperation();
+ ~UpdateCompatOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ UpdateCompatOperation* clone() const;
+ };
+
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp
new file mode 100644
index 000000000..2b8d54a6b
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.cpp
@@ -0,0 +1,305 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdatesdialog.h"
+#include "kdupdaterpackagesinfo.h"
+#include "kdupdaterupdate.h"
+#include "kdupdaterapplication.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QHash>
+#include <QtCore/QSet>
+
+#if defined( KDUPDATERGUIWEBVIEW )
+#include <QtWebKit/QWebView>
+#elif defined( KDUPDATERGUITEXTBROWSER )
+#include <QtGui/QTextBrowser>
+#endif
+
+#include "ui_updatesdialog.h"
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::UpdatesDialog kdupdaterupdatesdialog.h KDUpdaterUpdatesDialog
+ \brief A dialog that let the user chooses which updates he wants to install
+
+ After \ref KDUpdater::UpdateFinder class finds all updates available for an application,
+ this dialog can be used to help the user select which update he wants to install.
+
+ Usage:
+ \code
+ QList<KDUpdater::Update*> updates = updateFinder.updates();
+
+ KDUpdater::UpdatesDialog updatesDialog(this);
+ updatesDialog.setUpdates(updates);
+
+ if( updatesDialog.exec() != QDialog::Accepted )
+ {
+ qDeleteAll(updates);
+ updates.clear();
+ return;
+ }
+
+ QList<KDUpdater::Update*> reqUpdates;
+ for(int i=0; i<updates.count(); i++)
+ {
+ if( !updatesDialog.isUpdateAllowed(updates[i]) )
+ continue;
+ reqUpdates.append(updates[i]);
+ }
+ \endcode
+*/
+
+class KDUpdater::UpdatesDialog::Private
+{
+ Q_DECLARE_TR_FUNCTIONS(KDUpdater::Private)
+
+public:
+ explicit Private( UpdatesDialog* qq ) :
+ q( qq )
+ {}
+
+ UpdatesDialog* q;
+
+ Ui::UpdatesDialog ui;
+
+ int currentUpdate;
+ QList<Update*> updates;
+ QSet<const Update*> status;
+
+ void setCurrentUpdate(int index);
+
+ QString packageDescription( Update* update );
+ QString compatDescription( Update* update );
+ void slotStateChanged();
+ void slotPreviousClicked();
+ void slotNextClicked();
+};
+
+/*!
+ Constructor.
+*/
+KDUpdater::UpdatesDialog::UpdatesDialog(QWidget *parent)
+ : QDialog(parent),
+ d( new Private( this ) )
+{
+ d->ui.setupUi(this);
+ d->currentUpdate = -1;
+
+ connect(d->ui.packageUpdateCheckBox, SIGNAL(stateChanged(int)),
+ this, SLOT(slotStateChanged()));
+ connect(d->ui.nextPackageButton, SIGNAL(clicked()),
+ this, SLOT(slotNextClicked()));
+ connect(d->ui.previousPackageButton, SIGNAL(clicked()),
+ this, SLOT(slotPreviousClicked()));
+}
+
+
+/*!
+ Destructor.
+*/
+KDUpdater::UpdatesDialog::~UpdatesDialog()
+{
+ delete d;
+}
+
+
+/*!
+ Sets the list of updates available to the user.
+*/
+void KDUpdater::UpdatesDialog::setUpdates(const QList<Update*> &updates)
+{
+ d->updates = updates;
+ d->status.clear();
+
+ d->ui.packageSwitchBar->setVisible( d->updates.size()>1 );
+
+ if (d->updates.isEmpty()) {
+ d->ui.descriptionLabel->setText(tr("<b>No update available...</b>"));
+ d->ui.descriptionLabel->setFixedSize(d->ui.descriptionLabel->sizeHint());
+ d->ui.releaseNotesGroup->hide();
+ d->ui.pixmapLabel->hide();
+ } else if (d->updates.size()==1) {
+ //Only one update, so pre-accept it.
+ //OK/Cancel will do from the user POV
+ d->status.insert( d->updates.front() );
+ }
+
+ d->ui.totalPackageLabel->setText(QString::number(d->updates.size()));
+ d->setCurrentUpdate(0);
+}
+
+
+/*!
+ returns the list of updates available to the user.
+*/
+QList<KDUpdater::Update*> KDUpdater::UpdatesDialog::updates() const
+{
+ return d->updates;
+}
+
+
+/*!
+ Returns true if the update needs to be installed.
+*/
+bool KDUpdater::UpdatesDialog::isUpdateAllowed(const KDUpdater::Update *update) const
+{
+ return d->status.contains( update );
+}
+
+void KDUpdater::UpdatesDialog::Private::slotStateChanged()
+{
+ if (currentUpdate<0 || currentUpdate>=updates.size()) {
+ return;
+ }
+
+ if ( ui.packageUpdateCheckBox->isChecked() )
+ status.insert( updates[currentUpdate] );
+ else
+ status.remove( updates[currentUpdate] );
+}
+
+void KDUpdater::UpdatesDialog::Private::slotPreviousClicked()
+{
+ setCurrentUpdate(currentUpdate-1);
+}
+
+void KDUpdater::UpdatesDialog::Private::slotNextClicked()
+{
+ setCurrentUpdate(currentUpdate+1);
+}
+
+void KDUpdater::UpdatesDialog::Private::setCurrentUpdate(int index)
+{
+ if (updates.isEmpty()) {
+ if (currentUpdate == -1)
+ return;
+
+ currentUpdate = -1;
+ return;
+ }
+
+ if (index<0 || index>=updates.size()) {
+ return;
+ }
+
+ currentUpdate = index;
+
+ KDUpdater::Update *update = updates.at( index );
+
+ QString description;
+
+ switch ( update->type() ) {
+ case PackageUpdate:
+ case NewPackage:
+ description = packageDescription( update );
+ break;
+ case CompatUpdate:
+ description = compatDescription( update );
+ break;
+ default:
+ description = tr( "<unkown>" );
+ }
+
+ ui.descriptionLabel->setText(description);
+ ui.descriptionLabel->setMinimumHeight(ui.descriptionLabel->heightForWidth(400));
+
+ ui.packageUpdateCheckBox->setChecked( status.contains( update ) );
+
+ ui.currentPackageLabel->setText(QString::number(index+1));
+ ui.nextPackageButton->setEnabled( index!=(updates.size()-1) );
+ ui.previousPackageButton->setEnabled( index!=0 );
+
+ QDir appdir(update->application()->applicationDirectory());
+ if (update->data( QLatin1String( "ReleaseNotes" ) ).isValid()) {
+ ui.releaseNotesGroup->show();
+#if defined( KDUPDATERGUIWEBVIEW )
+ ui.releaseNotesView->setUrl( update->data( QLatin1String( "ReleaseNotes" ) ).toUrl() );
+#elif defined( KDUPDATERGUITEXTBROWSER )
+ ui.releaseNotesView->setSource( update->data( QLatin1String( "ReleaseNotes" ) ).toUrl());
+#endif
+ }
+ else {
+ ui.releaseNotesGroup->hide();
+ }
+}
+
+
+QString KDUpdater::UpdatesDialog::Private::packageDescription( KDUpdater::Update* update )
+{
+ KDUpdater::PackagesInfo *packages = update->application()->packagesInfo();
+ KDUpdater::PackageInfo info = packages->packageInfo(
+ packages->findPackageInfo(update->data( QLatin1String( "Name" ) ).toString()));
+
+ QDir appdir(update->application()->applicationDirectory());
+ QPixmap pixmap(appdir.filePath(info.pixmap));
+ if (!pixmap.isNull()) {
+ ui.pixmapLabel->setPixmap(pixmap.scaled(96, 96));
+ }
+
+
+ QString description = tr("<b>A new package update is available for %1!</b><br/><br/>"
+ "The package %2 %3 is now available -- you have version %4")
+ .arg(packages->applicationName(),
+ update->data( QLatin1String( "Name" ) ).toString(),
+ update->data( QLatin1String( "Version" ) ).toString(),
+ info.version);
+
+ if (!info.title.isEmpty() || !info.description.isEmpty() ) {
+ description += QLatin1String( "<br/><br/>" );
+ description += tr("<b>Package Details:</b>" );
+ if ( !info.title.isEmpty() ) {
+ description += tr( "<br/><i>Title:</i> %1" ).arg( info.title );
+ }
+ if ( !info.description.isEmpty() ) {
+ description += tr( "<br/><i>Description:</i> %1" ).arg( info.description );
+ }
+ }
+
+ if ( update->data( QLatin1String( "Description" ) ).isValid() ) {
+ description += QLatin1String( "<br/><br/>" );
+ description += tr( "<b>Update description:</b><br/>%1" )
+ .arg( update->data( QLatin1String( "Description" ) ).toString() );
+ }
+ return description;
+}
+
+QString KDUpdater::UpdatesDialog::Private::compatDescription( Update* update )
+{
+ KDUpdater::PackagesInfo *packages = update->application()->packagesInfo();
+
+ QString description = tr("<b>A new compatibility update is available for %1!</b><br/><br/>"
+ "The compatibility level %2 is now available -- you have level %3")
+ .arg(packages->applicationName(),
+ QString::number(update->data( QLatin1String( "CompatLevel" ) ).toInt()),
+ QString::number(packages->compatLevel()));
+
+ if ( update->data( QLatin1String( "Description" ) ).isValid() ) {
+ description += QLatin1String( "<br/><br/>" );
+ description += tr( "<b>Update description:</b> %1" )
+ .arg( update->data( QLatin1String( "Description" ) ).toString() );
+ }
+ return description;
+}
+
+#include "moc_kdupdaterupdatesdialog.cpp"
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.h
new file mode 100644
index 000000000..85a90a595
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesdialog.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATES_DIALOG_H
+#define KD_UPDATER_UPDATES_DIALOG_H
+
+#include "kdupdater.h"
+#include <QtCore/QList>
+#include <QtGui/QDialog>
+
+namespace KDUpdater
+{
+ class Update;
+
+ class KDTOOLS_UPDATER_EXPORT UpdatesDialog : public QDialog
+ {
+ Q_OBJECT
+
+ public:
+ explicit UpdatesDialog(QWidget *parent = 0);
+ ~UpdatesDialog();
+
+ void setUpdates(const QList<Update*> &updates);
+ QList<Update*> updates() const;
+
+ bool isUpdateAllowed( const Update * update ) const;
+
+ private:
+ class Private;
+ Private * const d;
+
+ Q_PRIVATE_SLOT( d, void slotStateChanged() )
+ Q_PRIVATE_SLOT( d, void slotPreviousClicked() )
+ Q_PRIVATE_SLOT( d, void slotNextClicked() )
+ };
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp
new file mode 100644
index 000000000..4e9f60195
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo.cpp
@@ -0,0 +1,372 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdatesinfo_p.h"
+
+#include <QCoreApplication>
+#include <QDomDocument>
+#include <QDomElement>
+#include <QFile>
+#include <QSharedData>
+
+//
+// KDUpdater::UpdatesInfo::UpdatesInfoData
+//
+struct KDUpdater::UpdatesInfo::UpdatesInfoData : public QSharedData
+{
+ Q_DECLARE_TR_FUNCTIONS(KDUpdater::UpdatesInfoData)
+
+public:
+ UpdatesInfoData() : error(UpdatesInfo::NotYetReadError), compatLevel(-1) { }
+
+ QString errorMessage;
+ UpdatesInfo::Error error;
+ QString updateXmlFile;
+ QString applicationName;
+ QString applicationVersion;
+ int compatLevel;
+ QList<KDUpdater::UpdateInfo> updateInfoList;
+
+ void parseFile(const QString& updateXmlFile);
+ bool parsePackageUpdateElement(const QDomElement & updateE);
+ bool parseCompatUpdateElement(const QDomElement & updateE);
+
+ void setInvalidContentError( const QString& detail );
+};
+
+void KDUpdater::UpdatesInfo::UpdatesInfoData::setInvalidContentError(const QString& detail)
+{
+ error = UpdatesInfo::InvalidContentError;
+ errorMessage = tr("Updates.Xml contains invalid content: %1").arg(detail);
+}
+
+void KDUpdater::UpdatesInfo::UpdatesInfoData::parseFile(const QString& updateXmlFile)
+{
+ QFile file( updateXmlFile );
+ if( !file.open(QFile::ReadOnly) )
+ {
+ error = UpdatesInfo::CouldNotReadUpdateInfoFileError;
+ errorMessage = tr("Could not read \"%1\"").arg(updateXmlFile);
+ return;
+ }
+
+ QDomDocument doc;
+ QString parseErrorMessage;
+ int parseErrorLine;
+ int parseErrorColumn;
+ if( !doc.setContent( &file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn ) )
+ {
+ error = UpdatesInfo::InvalidXmlError;
+ errorMessage = tr("Parse error in %1 at %2, %3: %4")
+ .arg( updateXmlFile,
+ QString::number( parseErrorLine ),
+ QString::number( parseErrorColumn ),
+ parseErrorMessage );
+ return;
+ }
+
+ QDomElement rootE = doc.documentElement();
+ if( rootE.tagName() != QLatin1String( "Updates" ) )
+ {
+ setInvalidContentError(tr("root element %1 unexpected, should be \"Updates\"").arg(rootE.tagName()));
+ return;
+ }
+
+ QDomNodeList childNodes = rootE.childNodes();
+ for(int i=0; i<childNodes.count(); i++)
+ {
+ QDomNode childNode = childNodes.at(i);
+ QDomElement childE = childNode.toElement();
+ if( childE.isNull() )
+ continue;
+
+ if( childE.tagName() == QLatin1String( "ApplicationName" ) )
+ applicationName = childE.text();
+ else if( childE.tagName() == QLatin1String( "ApplicationVersion" ) )
+ applicationVersion = childE.text();
+ else if( childE.tagName() == QLatin1String( "RequiredCompatLevel" ) )
+ compatLevel = childE.text().toInt();
+ else if( childE.tagName() == QLatin1String( "PackageUpdate" ) ) {
+ const bool res = parsePackageUpdateElement( childE );
+ if (!res) {
+ //error handled in subroutine
+ return;
+ }
+ } else if( childE.tagName() == QLatin1String( "CompatUpdate" ) ) {
+ const bool res = parseCompatUpdateElement( childE );
+ if (!res) {
+ //error handled in subroutine
+ return;
+ }
+ }
+ }
+
+ if (applicationName.isEmpty())
+ {
+ setInvalidContentError(tr("ApplicationName element is missing"));
+ return;
+ }
+
+ if (applicationVersion.isEmpty())
+ {
+ setInvalidContentError(tr("ApplicationVersion element is missing"));
+ return;
+ }
+
+ error = UpdatesInfo::NoError;
+ errorMessage.clear();
+}
+
+bool KDUpdater::UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QDomElement & updateE)
+{
+ if( updateE.isNull() )
+ return false;
+
+ KDUpdater::UpdateInfo info;
+ info.type = KDUpdater::PackageUpdate;
+
+ QDomNodeList childNodes = updateE.childNodes();
+ for(int i=0; i<childNodes.count(); i++)
+ {
+ QDomNode childNode = childNodes.at(i);
+ QDomElement childE = childNode.toElement();
+ if( childE.isNull() )
+ continue;
+
+ if( childE.tagName() == QLatin1String( "ReleaseNotes" ) ) {
+ info.data[childE.tagName()] = QUrl(childE.text());
+ }
+ else if( childE.tagName() == QLatin1String( "UpdateFile" ) )
+ {
+ KDUpdater::UpdateFileInfo ufInfo;
+ ufInfo.arch = childE.attribute(QLatin1String( "Arch" ), QLatin1String( "i386" ));
+ ufInfo.os = childE.attribute(QLatin1String( "OS" ));
+ ufInfo.compressedSize = childE.attribute( QLatin1String( "CompressedSize" ) ).toLongLong();
+ ufInfo.uncompressedSize = childE.attribute( QLatin1String( "UncompressedSize" ) ).toLongLong();
+ ufInfo.sha1sum = QByteArray::fromHex( childE.attribute( QLatin1String( "sha1sum" ) ).toAscii() );
+ ufInfo.fileName = childE.text();
+ info.updateFiles.append(ufInfo);
+ }
+ else if (childE.tagName() == QLatin1String("Licenses")) {
+ QHash<QString, QVariant> licenseHash;
+ const QDomNodeList licenseNodes = childE.childNodes();
+ for (int i = 0; i < licenseNodes.count(); ++i) {
+ const QDomNode licenseNode = licenseNodes.at(i);
+ if (licenseNode.nodeName() == QLatin1String("License")) {
+ QDomElement element = licenseNode.toElement();
+ licenseHash.insert(element.attributeNode(QLatin1String("name")).value(),
+ element.attributeNode(QLatin1String("file")).value());
+ }
+ }
+ if (!licenseHash.isEmpty())
+ info.data.insert(QLatin1String("Licenses"), licenseHash);
+ }
+ else {
+ info.data[childE.tagName()] = childE.text();
+ }
+ }
+
+ if (!info.data.contains( QLatin1String( "Name" ) ))
+ {
+ setInvalidContentError(tr("PackageUpdate element without Name"));
+ return false;
+ }
+ else if (!info.data.contains( QLatin1String( "Version" ) ))
+ {
+ setInvalidContentError(tr("PackageUpdate element without Version"));
+ return false;
+ }
+ else if (!info.data.contains( QLatin1String( "ReleaseDate" ) ))
+ {
+ setInvalidContentError(tr("PackageUpdate element without ReleaseDate"));
+ return false;
+ }
+ else if (info.updateFiles.isEmpty())
+ {
+ setInvalidContentError(tr("PackageUpdate element without UpdateFile"));
+ return false;
+ }
+
+ updateInfoList.append(info);
+ return true;
+}
+
+bool KDUpdater::UpdatesInfo::UpdatesInfoData::parseCompatUpdateElement(const QDomElement & updateE)
+{
+ if( updateE.isNull() )
+ return false;
+
+ KDUpdater::UpdateInfo info;
+ info.type = KDUpdater::CompatUpdate;
+
+ QDomNodeList childNodes = updateE.childNodes();
+ for(int i=0; i<childNodes.count(); i++)
+ {
+ QDomNode childNode = childNodes.at(i);
+ QDomElement childE = childNode.toElement();
+ if( childE.isNull() )
+ continue;
+
+ if( childE.tagName() == QLatin1String( "ReleaseNotes" ) ) {
+ info.data[childE.tagName()] = QUrl(childE.text());
+ }
+ else if( childE.tagName() == QLatin1String( "UpdateFile" ) )
+ {
+ KDUpdater::UpdateFileInfo ufInfo;
+ ufInfo.arch = childE.attribute(QLatin1String( "Arch" ), QLatin1String( "i386" ));
+ ufInfo.os = childE.attribute(QLatin1String( "OS" ));
+ ufInfo.fileName = childE.text();
+ info.updateFiles.append(ufInfo);
+ }
+ else {
+ info.data[childE.tagName()] = childE.text();
+ }
+ }
+
+ if (!info.data.contains( QLatin1String( "CompatLevel" ) ))
+ {
+ setInvalidContentError(tr("CompatUpdate element without CompatLevel"));
+ return false;
+ }
+
+ if (!info.data.contains( QLatin1String( "ReleaseDate" ) ))
+ {
+ setInvalidContentError(tr("CompatUpdate element without ReleaseDate"));
+ return false;
+ }
+
+ if (info.updateFiles.isEmpty())
+ {
+ setInvalidContentError(tr("CompatUpdate element without UpdateFile"));
+ return false;
+ }
+
+ updateInfoList.append(info);
+ return true;
+}
+
+
+//
+// KDUpdater::UpdatesInfo
+//
+KDUpdater::UpdatesInfo::UpdatesInfo()
+ : d(new KDUpdater::UpdatesInfo::UpdatesInfoData)
+{
+}
+
+KDUpdater::UpdatesInfo::~UpdatesInfo()
+{
+}
+
+bool KDUpdater::UpdatesInfo::isValid() const
+{
+ return d->error == NoError;
+}
+
+QString KDUpdater::UpdatesInfo::errorString() const
+{
+ return d->errorMessage;
+}
+
+void KDUpdater::UpdatesInfo::setFileName(const QString& updateXmlFile)
+{
+ if( d->updateXmlFile == updateXmlFile )
+ return;
+
+ d->applicationName.clear();
+ d->applicationVersion.clear();
+ d->updateInfoList.clear();
+
+ d->updateXmlFile = updateXmlFile;
+ d->parseFile( d->updateXmlFile );
+}
+
+QString KDUpdater::UpdatesInfo::fileName() const
+{
+ return d->updateXmlFile;
+}
+
+QString KDUpdater::UpdatesInfo::applicationName() const
+{
+ return d->applicationName;
+}
+
+QString KDUpdater::UpdatesInfo::applicationVersion() const
+{
+ return d->applicationVersion;
+}
+
+int KDUpdater::UpdatesInfo::compatLevel() const
+{
+ return d->compatLevel;
+}
+
+int KDUpdater::UpdatesInfo::updateInfoCount( int type) const
+{
+ if ( type == KDUpdater::AllUpdate ) {
+ return d->updateInfoList.count();
+ }
+ int count = 0;
+ for ( int i=0; i<d->updateInfoList.count(); ++i ) {
+ if ( d->updateInfoList.at( i ).type == type )
+ ++count;
+ }
+ return count;
+}
+
+KDUpdater::UpdateInfo KDUpdater::UpdatesInfo::updateInfo(int index) const
+{
+ if(index < 0 || index >= d->updateInfoList.count())
+ return KDUpdater::UpdateInfo();
+
+ return d->updateInfoList.at( index );
+}
+
+QList<KDUpdater::UpdateInfo> KDUpdater::UpdatesInfo::updatesInfo( int type, int compatLevel ) const
+{
+ QList<KDUpdater::UpdateInfo> list;
+ if ( compatLevel == -1 ) {
+ if ( type == KDUpdater::AllUpdate ) {
+ return d->updateInfoList;
+ }
+ for ( int i=0; i<d->updateInfoList.count(); ++i ) {
+ if ( d->updateInfoList.at( i ).type == type )
+ list.append( d->updateInfoList.at( i ) );
+ }
+ }
+ else {
+ for ( int i=0; i<d->updateInfoList.count(); ++i ) {
+ UpdateInfo updateInfo = d->updateInfoList.at( i );
+ if ( updateInfo.type == type ) {
+ if ( updateInfo.type == CompatUpdate ) {
+ if ( updateInfo.data.value( QLatin1String( "CompatLevel" ) ) == compatLevel )
+ list.append( updateInfo );
+ }
+ else {
+ if ( updateInfo.data.value( QLatin1String( "RequiredCompatLevel" ) ) == compatLevel )
+ list.append( updateInfo );
+ }
+ }
+ }
+ }
+ return list;
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h
new file mode 100644
index 000000000..4179e3d8d
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesinfo_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_PACKAGES_INFO_H
+#define KD_UPDATER_UPDATE_PACKAGES_INFO_H
+
+#include "kdupdater.h"
+#include <QSharedDataPointer>
+#include <QString>
+#include <QDate>
+#include <QList>
+#include <QStringList>
+#include <QUrl>
+#include <QMap>
+#include <QVariant>
+
+// Classes and structures in this header file are for internal use only.
+// They are not a part of the public API
+
+namespace KDUpdater
+{
+ struct UpdateFileInfo
+ {
+ UpdateFileInfo()
+ : compressedSize( 0 ),
+ uncompressedSize( 0 )
+ {
+ }
+ QString arch;
+ QString os;
+ QString fileName;
+ QByteArray sha1sum;
+ quint64 compressedSize;
+ quint64 uncompressedSize;
+ };
+
+ struct UpdateInfo
+ {
+ int type;
+ QMap<QString, QVariant> data;
+ QList<UpdateFileInfo> updateFiles;
+ };
+
+ class UpdatesInfo
+ {
+ public:
+ enum Error
+ {
+ NoError=0,
+ NotYetReadError,
+ CouldNotReadUpdateInfoFileError,
+ InvalidXmlError,
+ InvalidContentError
+ };
+
+ UpdatesInfo();
+ ~UpdatesInfo();
+
+ bool isValid() const;
+ QString errorString() const;
+ Error error() const;
+
+ void setFileName(const QString& updateXmlFile);
+ QString fileName() const;
+
+ QString applicationName() const;
+ QString applicationVersion() const;
+ int compatLevel() const;
+
+ int updateInfoCount( int type=AllUpdate ) const;
+ UpdateInfo updateInfo(int index) const;
+ QList<UpdateInfo> updatesInfo( int type=AllUpdate, int compatLevel=-1 ) const;
+
+ private:
+ struct UpdatesInfoData;
+ QSharedDataPointer<UpdatesInfoData> d;
+ };
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp
new file mode 100644
index 000000000..14a765a5b
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.cpp
@@ -0,0 +1,511 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdatesourcesinfo.h"
+#include "kdupdaterapplication.h"
+
+#include <QDomElement>
+#include <QDomDocument>
+#include <QDomText>
+#include <QDomCDATASection>
+#include <QFileInfo>
+#include <QFile>
+#include <QTextStream>
+
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::UpdateSourcesInfo kdupdaterupdatesourcesinfo.h KDUpdaterUpdateSourcesInfo
+ \brief Provides access to information about the update sources set for the application.
+
+ An update source is a repository that contains updates applicable for the application.
+ Applications can download updates from the update source and install them locally.
+
+ Each application can have one or more update sources from which it can download updates.
+ Information about update source is stored in a file called UpdateSources.xml. This class helps
+ access and modify the UpdateSources.xml file.
+
+ The complete file name of the UpdateSources.xml file can be specified via the \ref setFileName()
+ method. The class then parses the XML file and makes available information contained in
+ that XML file through an easy to use API. You can
+
+ \li Get update sources information via the \ref updateSourceInfoCount() and \ref updateSourceInfo()
+ methods.
+ \li You can add/remove/change update source information via the \ref addUpdateSourceInfo(),
+ \ref removeUpdateSource(), \ref setUpdateSourceAt() methods.
+
+ The class emits appropriate signals to inform listeners about changes in the update application.
+*/
+
+/*! \enum UpdateSourcesInfo::Error
+ * Error codes related to retrieving update sources
+ */
+
+/*! \var UpdateSourcesInfo::Error UpdateSourcesInfo::NoError
+ * No error occurred
+ */
+
+/*! \var UpdateSourcesInfo::Error UpdateSourcesInfo::NotYetReadError
+ * The package information was not parsed yet from the XML file
+ */
+
+/*! \var UpdateSourcesInfo::Error UpdateSourcesInfo::CouldNotReadSourceFileError
+ * the specified update source file could not be read (does not exist or not readable)
+ */
+
+/*! \var UpdateSourcesInfo::Error UpdateSourcesInfo::InvalidXmlError
+ * The source file contains invalid XML.
+ */
+
+/*! \var UpdateSourcesInfo::Error UpdateSourcesInfo::InvalidContentError
+ * The source file contains valid XML, but does not match the expected format for source descriptions
+ */
+
+/*! \var UpdateSourcesInfo::Error UpdateSourcesInfo::CouldNotSaveChangesError
+ * Changes made to the object could be saved back to the source file
+ */
+
+namespace KDUpdater
+{
+struct UpdateSourceInfoPriorityHigherThan
+{
+ bool operator()( const UpdateSourceInfo& lhs, const UpdateSourceInfo& rhs ) const
+ {
+ return lhs.priority > rhs.priority;
+ }
+};
+}
+
+struct KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData
+{
+ UpdateSourcesInfoData( UpdateSourcesInfo* qq ) :
+ q( qq ),
+ error(UpdateSourcesInfo::NotYetReadError),
+ application(0),
+ modified(false)
+ {}
+
+ UpdateSourcesInfo* q;
+
+ QString errorMessage;
+ UpdateSourcesInfo::Error error;
+ KDUpdater::Application* application;
+ bool modified;
+ QString fileName;
+ QList<KDUpdater::UpdateSourceInfo> updateSourceInfoList;
+
+ void addUpdateSourceFrom( const QDomElement & element );
+ void addChildElement( QDomDocument & doc, QDomElement & parentE, const QString & tagName, const QString & text, bool htmlText=false );
+ void setInvalidContentError( const QString& detail );
+ void clearError();
+ void saveChanges();
+};
+
+void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::setInvalidContentError(const QString& detail)
+{
+ error = UpdateSourcesInfo::InvalidContentError;
+ errorMessage = tr("%1 contains invalid content: %2").arg(fileName, detail);
+}
+
+void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::clearError()
+{
+ error = UpdateSourcesInfo::NoError;
+ errorMessage.clear();
+}
+
+/*!
+ \internal
+*/
+KDUpdater::UpdateSourcesInfo::UpdateSourcesInfo(Application* application)
+ : QObject(application),
+ d( new KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData( this ) )
+{
+ d->application = application;
+}
+
+/*!
+ \internal
+*/
+KDUpdater::UpdateSourcesInfo::~UpdateSourcesInfo()
+{
+ d->saveChanges();
+ delete d;
+}
+
+/*!
+ Returns a pointer to the update application for which this class manages update sources.
+*/
+KDUpdater::Application* KDUpdater::UpdateSourcesInfo::application() const
+{
+ return d->application;
+}
+
+/*!
+ \internal
+*/
+bool KDUpdater::UpdateSourcesInfo::isValid() const
+{
+ return d->error == NoError;
+}
+
+/*!
+ returns a human-readable description of the error
+ */
+QString KDUpdater::UpdateSourcesInfo::errorString() const
+{
+ return d->errorMessage;
+}
+
+/*!
+ returns the last error
+ */
+KDUpdater::UpdateSourcesInfo::Error KDUpdater::UpdateSourcesInfo::error() const
+{
+ return d->error;
+}
+
+bool KDUpdater::UpdateSourcesInfo::isModified() const
+{
+ return d->modified;
+}
+
+void KDUpdater::UpdateSourcesInfo::setModified(bool modified)
+{
+ d->modified = modified;
+}
+
+/*!
+ Sets the complete file name of the UpdateSources.xml file. The function also issues a call
+ to refresh() to reload package information from the XML file.
+
+ \sa KDUpdater::Application::setUpdateSourcesXMLFileName()
+*/
+void KDUpdater::UpdateSourcesInfo::setFileName(const QString& fileName)
+{
+ if( d->fileName == fileName )
+ return;
+
+ d->fileName = fileName;
+ refresh(); // load new file
+}
+
+/*!
+ Returns the name of the UpdateSources.xml file that this class referred to.
+*/
+QString KDUpdater::UpdateSourcesInfo::fileName() const
+{
+ return d->fileName;
+}
+
+/*!
+ Returns the number of update source info structures contained in this class.
+*/
+int KDUpdater::UpdateSourcesInfo::updateSourceInfoCount() const
+{
+ return d->updateSourceInfoList.count();
+}
+
+/*!
+ Returns the update source info structure at \c index. If an invalid index is passed
+ the function returns a dummy constructor.
+*/
+KDUpdater::UpdateSourceInfo KDUpdater::UpdateSourcesInfo::updateSourceInfo(int index) const
+{
+ if( index < 0 || index >= d->updateSourceInfoList.count() )
+ return KDUpdater::UpdateSourceInfo();
+
+ return d->updateSourceInfoList[index];
+}
+
+/*!
+ Adds an update source info to this class. Upon successful addition, the class emits a
+ \ref updateSourceInfoAdded() signal.
+*/
+void KDUpdater::UpdateSourcesInfo::addUpdateSourceInfo(const KDUpdater::UpdateSourceInfo& info)
+{
+ if( d->updateSourceInfoList.contains( info ) )
+ return;
+ d->updateSourceInfoList.push_back( info );
+ qSort( d->updateSourceInfoList.begin(), d->updateSourceInfoList.end(), KDUpdater::UpdateSourceInfoPriorityHigherThan() );
+ emit updateSourceInfoAdded(info);
+ d->modified = true;
+}
+
+/*!
+ Removes an update source info from this class. Upon successful removal, the class emits a
+ \ref updateSourceInfoRemoved() signal.
+*/
+void KDUpdater::UpdateSourcesInfo::removeUpdateSourceInfo(const KDUpdater::UpdateSourceInfo& info)
+{
+ if( !d->updateSourceInfoList.contains(info) )
+ return;
+ d->updateSourceInfoList.removeAll(info);
+ emit updateSourceInfoRemoved(info);
+ d->modified = true;
+}
+
+/*!
+ Removes an update source info at \index in this class. Upon successful removal, the class emits a
+ \ref updateSourceInfoRemoved() signal.
+*/
+void KDUpdater::UpdateSourcesInfo::removeUpdateSourceInfoAt(int index)
+{
+ if( index < 0 || index >= d->updateSourceInfoList.count() )
+ return;
+ KDUpdater::UpdateSourceInfo info = d->updateSourceInfoList[index];
+ d->updateSourceInfoList.removeAt(index);
+ emit updateSourceInfoRemoved(info);
+ d->modified = true;
+}
+
+/*!
+ Changes the update source info at \c index to \c info. If \c index is equal to the number of
+ source info structures in this class (\ref updateSourceInfoCount()) then \c info is appended;
+ otherwise the existing info at \c index will be changed.
+
+ Depending on what the function does \ref updateSourceInfoAdded() or \ref updateSourceInfoChanged()
+ signal is emitted.
+*/
+void KDUpdater::UpdateSourcesInfo::setUpdateSourceInfoAt(int index, const KDUpdater::UpdateSourceInfo& info)
+{
+ if( index < 0 || index > d->updateSourceInfoList.count() )
+ return;
+
+ if( index == d->updateSourceInfoList.count() )
+ {
+ d->updateSourceInfoList.append(info);
+ emit updateSourceInfoAdded(info);
+ }
+ else
+ {
+ KDUpdater::UpdateSourceInfo oldInfo = d->updateSourceInfoList[index];
+ if( info == oldInfo )
+ return;
+
+ d->updateSourceInfoList[index] = info;
+ emit updateSourceInfoChanged(info, oldInfo);
+ }
+ d->modified = true;
+}
+
+/*!
+ This slot reloads the update source information from UpdateSources.xml.
+*/
+void KDUpdater::UpdateSourcesInfo::refresh()
+{
+ d->saveChanges(); // save changes done in the previous file
+ d->updateSourceInfoList.clear();
+
+ QFile file( d->fileName );
+
+ // if the file does not exist then we just skip the reading
+ if( !file.exists() )
+ {
+ d->clearError();
+ emit reset();
+ return;
+ }
+
+ // Open the XML file
+ if( !file.open(QFile::ReadOnly) )
+ {
+ d->errorMessage = tr("Could not read \"%1\"").arg(d->fileName);
+ d->error = CouldNotReadSourceFileError;
+ emit reset();
+ return;
+ }
+
+ QDomDocument doc;
+ QString parseErrorMessage;
+ int parseErrorLine;
+ int parseErrorColumn;
+ if( !doc.setContent( &file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn ) )
+ {
+ d->error = InvalidXmlError;
+ d->errorMessage = tr("XML Parse error in %1 at %2, %3: %4")
+ .arg( d->fileName,
+ QString::number( parseErrorLine ),
+ QString::number( parseErrorColumn ),
+ parseErrorMessage );
+ emit reset();
+ return;
+ }
+
+ // Now parse the XML file.
+ QDomElement rootE = doc.documentElement();
+ if( rootE.tagName() != QLatin1String( "UpdateSources" ) )
+ {
+ d->setInvalidContentError(tr("Root element %1 unexpected, should be \"UpdateSources\"").arg(rootE.tagName()));
+ emit reset();
+ return;
+ }
+
+ QDomNodeList childNodes = rootE.childNodes();
+ for(int i=0; i<childNodes.count(); i++)
+ {
+ QDomNode childNode = childNodes.item(i);
+ QDomElement childNodeE = childNode.toElement();
+ if( childNodeE.isNull() )
+ continue;
+
+ if( childNodeE.tagName() == QLatin1String( "UpdateSource" ) )
+ d->addUpdateSourceFrom(childNodeE);
+ }
+
+ d->clearError();
+ emit reset();
+}
+
+void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::saveChanges()
+{
+ if( !modified || fileName.isEmpty() )
+ return;
+
+ const bool hadSaveError = error == UpdateSourcesInfo::CouldNotSaveChangesError;
+
+ QDomDocument doc;
+
+ QDomElement rootE = doc.createElement( QLatin1String( "UpdateSources") );
+ doc.appendChild(rootE);
+
+ for(int i=0; i<updateSourceInfoList.count(); i++)
+ {
+ KDUpdater::UpdateSourceInfo info = updateSourceInfoList[i];
+
+ QDomElement infoE = doc.createElement( QLatin1String( "UpdateSource" ) );
+ rootE.appendChild(infoE);
+ addChildElement(doc, infoE, QLatin1String( "Name" ), info.name);
+ addChildElement(doc, infoE, QLatin1String( "Title" ), info.title);
+ addChildElement(doc, infoE, QLatin1String( "Description" ), info.description,
+ (info.description.length() && info.description[0] == QLatin1Char( '<' ) ) );
+ addChildElement(doc, infoE, QLatin1String( "Url" ), info.url.toString());
+ }
+
+ QFile file( fileName );
+ if ( !file.open( QFile::WriteOnly ) )
+ {
+ error = UpdateSourcesInfo::CouldNotSaveChangesError;
+ errorMessage = tr("Could not save changes to \"%1\": %2").arg(fileName, file.errorString());
+ return;
+ }
+
+ QTextStream stream( &file );
+ doc.save( stream, 2 );
+ stream.flush();
+ file.close();
+
+ if ( file.error() != QFile::NoError )
+ {
+ error = UpdateSourcesInfo::CouldNotSaveChangesError;
+ errorMessage = tr("Could not save changes to \"%1\": %2").arg(fileName, file.errorString());
+ return;
+ }
+
+ //if there was a write error before, clear the error, as the write was successful now
+ if ( hadSaveError )
+ clearError();
+
+ modified = false;
+}
+
+void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::addUpdateSourceFrom( const QDomElement & element )
+{
+ if( element.tagName() != QLatin1String( "UpdateSource" ) )
+ return;
+
+ QDomNodeList childNodes = element.childNodes();
+ if(!childNodes.count())
+ return;
+
+ KDUpdater::UpdateSourceInfo info;
+
+ for(int i=0; i<childNodes.count(); i++)
+ {
+ QDomNode childNode = childNodes.item(i);
+ QDomElement childNodeE = childNode.toElement();
+ if( childNodeE.isNull() )
+ continue;
+
+ if( childNodeE.tagName() == QLatin1String( "Name" ) )
+ info.name = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "Title" ) )
+ info.title = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "Description" ) )
+ info.description = childNodeE.text();
+ else if( childNodeE.tagName() == QLatin1String( "Url" ) )
+ info.url = childNodeE.text();
+ }
+
+ this->updateSourceInfoList.append(info);
+}
+
+void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::addChildElement( QDomDocument & doc, QDomElement & parentE, const QString & tagName, const QString & text, bool htmlText )
+{
+ QDomElement childE = doc.createElement(tagName);
+ parentE.appendChild(childE);
+
+ if( htmlText )
+ {
+ QDomCDATASection textE = doc.createCDATASection(text);
+ childE.appendChild(textE);
+ }
+ else
+ {
+ QDomText textE = doc.createTextNode(text);
+ childE.appendChild(textE);
+ }
+}
+
+/*!
+ \ingroup kdupdater
+ \struct KDUpdater::UpdateSourceInfo kdupdaterupdatesourcesinfo.h KDUpdaterUpdateSourcesInfo
+ \brief Describes a single update source
+
+ An update source is a repository that contains updates applicable for the application.
+ This structure describes a single update source in terms of name, title, description, url and priority.
+*/
+
+/*!
+ \var QString KDUpdater::UpdateSourceInfo::name
+*/
+
+/*!
+ \var QString KDUpdater::UpdateSourceInfo::title
+*/
+
+/*!
+ \var QString KDUpdater::UpdateSourceInfo::description
+*/
+
+/*!
+ \var QUrl KDUpdater::UpdateSourceInfo::url
+*/
+
+/*!
+ \var QUrl KDUpdater::UpdateSourceInfo::priority
+*/
+
+bool KDUpdater::operator==( const UpdateSourceInfo & lhs, const UpdateSourceInfo & rhs )
+{
+ return (lhs.name == rhs.name) && (lhs.title == rhs.title) &&
+ (lhs.description == rhs.description) && (lhs.url == rhs.url);
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h
new file mode 100644
index 000000000..231002ee0
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesinfo.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_SOURCES_INFO_H
+#define KD_UPDATER_UPDATE_SOURCES_INFO_H
+
+#include "kdupdater.h"
+
+#include <QObject>
+#include <QVariant>
+#include <QUrl>
+
+namespace KDUpdater
+{
+ class Application;
+
+ struct KDTOOLS_UPDATER_EXPORT UpdateSourceInfo
+ {
+ UpdateSourceInfo() : priority(-1) { }
+
+ QString name;
+ QString title;
+ QString description;
+ QUrl url;
+ int priority;
+
+ };
+
+ KDTOOLS_UPDATER_EXPORT bool operator==( const UpdateSourceInfo & lhs, const UpdateSourceInfo & rhs );
+ inline bool operator!= ( const UpdateSourceInfo & lhs, const UpdateSourceInfo & rhs ) {
+ return !operator==( lhs, rhs );
+ }
+
+ class KDTOOLS_UPDATER_EXPORT UpdateSourcesInfo : public QObject
+ {
+ Q_OBJECT
+
+ public:
+ ~UpdateSourcesInfo();
+
+ enum Error
+ {
+ NoError=0,
+ NotYetReadError,
+ CouldNotReadSourceFileError,
+ InvalidXmlError,
+ InvalidContentError,
+ CouldNotSaveChangesError
+ };
+
+ Application* application() const;
+
+ bool isValid() const;
+ QString errorString() const;
+ Error error() const;
+
+ bool isModified() const;
+ void setModified(bool modified);
+
+ void setFileName(const QString& fileName);
+ QString fileName() const;
+
+ int updateSourceInfoCount() const;
+ UpdateSourceInfo updateSourceInfo(int index) const;
+
+ void addUpdateSourceInfo(const UpdateSourceInfo& info);
+ void removeUpdateSourceInfo(const UpdateSourceInfo& info);
+ void removeUpdateSourceInfoAt(int index);
+ void setUpdateSourceInfoAt(int index, const UpdateSourceInfo& info);
+
+ protected:
+ explicit UpdateSourcesInfo(Application* application);
+
+ public Q_SLOTS:
+ void refresh();
+
+ Q_SIGNALS:
+ void reset();
+ void updateSourceInfoAdded(const UpdateSourceInfo& info);
+ void updateSourceInfoRemoved(const UpdateSourceInfo& info);
+ void updateSourceInfoChanged(const UpdateSourceInfo& newInfo,
+ const UpdateSourceInfo& oldInfo);
+
+ private:
+ friend class Application;
+ struct UpdateSourcesInfoData;
+ UpdateSourcesInfoData* d;
+ };
+}
+
+Q_DECLARE_METATYPE(KDUpdater::UpdateSourceInfo)
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp
new file mode 100644
index 000000000..aec942614
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.cpp
@@ -0,0 +1,375 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "kdupdaterupdatesourcesview.h"
+#include "kdupdaterupdatesourcesinfo.h"
+#include "ui_addupdatesourcedialog.h"
+
+#include <QMessageBox>
+#include <QContextMenuEvent>
+#include <QAction>
+#include <QMenu>
+
+/*!
+ \ingroup kdupdater
+ \class KDUpdater::UpdateSourcesView kdupdaterupdatesourcesview.h KDUpdaterUpdateSourcesView
+ \brief A widget that helps view and/or edit \ref KDUpdater::UpdateSourcesInfo
+
+ \ref KDUpdater::UpdateSourcesInfo, associated with \ref KDUpdater::Application, contains information
+ about all the update sources from which the application can download and install updates.
+ This widget helps view and edit update sources information.
+
+ \image html updatesourcesview.jpg
+
+ The widget provides the following slots for editing update sources information
+ \ref addNewSource()
+ \ref editCurrentSource()
+ \ref removeCurrentSource()
+
+ You can include this widget within another form or dialog and connect to these slots which make
+ use of an inbuilt dialog box to add/edit update sources. Shown below is a screenshot of the
+ inbuilt dialog box.
+
+ \image html editupdatesource.jpg
+
+ Alternatively you can also use your own dialog box and directly update \ref KDUpdater::UpdateSourcesInfo.
+ This widget connects to \ref KDUpdater::UpdateSourcesInfo signals and ensures that the data it displays
+ is always kept updated.
+
+ The widget provides a context menu using which you can add/remove/edit update sources. Shown below is a
+ screenshot of the context menu.
+
+ \image html updatesourcesview_contextmenu.jpg
+*/
+
+struct KDUpdater::UpdateSourcesView::UpdateSourcesViewData
+{
+ UpdateSourcesViewData( UpdateSourcesView* qq ) :
+ q( qq ),
+ updateSourcesInfo(0)
+ {}
+
+ UpdateSourcesView* q;
+ UpdateSourcesInfo* updateSourcesInfo;
+};
+
+/*!
+ Constructor
+*/
+KDUpdater::UpdateSourcesView::UpdateSourcesView(QWidget* parent)
+ : QTreeWidget(parent),
+ d(new KDUpdater::UpdateSourcesView::UpdateSourcesViewData( this ) )
+{
+ setColumnCount(3);
+ setHeaderLabels( QStringList() << tr("Name") << tr("Title") << tr("URL") );
+ setRootIsDecorated(false);
+
+ connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(editCurrentSource()));
+}
+
+/*!
+ Destructor
+*/
+KDUpdater::UpdateSourcesView::~UpdateSourcesView()
+{
+ delete d;
+}
+
+/*!
+ Sets the \ref KDUpdater::UpdateSourcesInfo object whose information this widget should show.
+
+ \code
+ KDUpdater::Application application;
+
+ KDUpdater::UpdateSourcesView updatesView;
+ updatesView.setUpdateSourcesInfo( application.updateSourcesInfo() );
+ updatesView.show();
+ \endcode
+*/
+void KDUpdater::UpdateSourcesView::setUpdateSourcesInfo(KDUpdater::UpdateSourcesInfo* info)
+{
+ if( d->updateSourcesInfo == info )
+ return;
+
+ if(d->updateSourcesInfo)
+ disconnect(d->updateSourcesInfo, 0, this, 0);
+
+ d->updateSourcesInfo = info;
+ if(d->updateSourcesInfo)
+ {
+ connect(d->updateSourcesInfo, SIGNAL(reset()), this, SLOT(refresh()));
+ connect(d->updateSourcesInfo, SIGNAL(updateSourceInfoAdded(UpdateSourceInfo)),
+ this, SLOT(slotUpdateSourceInfoAdded(UpdateSourceInfo)));
+ connect(d->updateSourcesInfo, SIGNAL(updateSourceInfoRemoved(UpdateSourceInfo)),
+ this, SLOT(slotUpdateSourceInfoRemoved(UpdateSourceInfo)));
+ connect(d->updateSourcesInfo, SIGNAL(updateSourceInfoChanged(UpdateSourceInfo,UpdateSourceInfo)),
+ this, SLOT(slotUpdateSourceInfoChanged(UpdateSourceInfo,UpdateSourceInfo)));
+ }
+
+ refresh();
+}
+
+/*!
+ Returns a pointer to the \ref KDUpdater::UpdateSourcesInfo object whose information this
+ widget is showing.
+*/
+KDUpdater::UpdateSourcesInfo* KDUpdater::UpdateSourcesView::updateSourcesInfo() const
+{
+ return d->updateSourcesInfo;
+}
+
+/*!
+ Returns the index of the currently selected update source in the widget. You can use this
+ index along with \ref KDUpdater::UpdateSourcesInfo::updateSourceInfo() method to get hold
+ of the update source info.
+*/
+int KDUpdater::UpdateSourcesView::currentUpdateSourceInfoIndex() const
+{
+ if( !d->updateSourcesInfo )
+ return -1;
+
+ QTreeWidgetItem* item = this->currentItem();
+ if( !item )
+ return -1;
+
+ int index = this->indexOfTopLevelItem(item);
+ if( index < 0 )
+ return -1;
+
+ return index;
+}
+
+/*!
+ Call this slot to reload the updates information. By default this slot is connected to
+ \ref KDUpdater::UpdateSourcesInfo::reset() signal in \ref setUpdateSourcesInfo().
+*/
+void KDUpdater::UpdateSourcesView::refresh()
+{
+ this->clear();
+
+ if( !d->updateSourcesInfo )
+ return;
+
+ for(int i=0; i<d->updateSourcesInfo->updateSourceInfoCount(); i++)
+ {
+ KDUpdater::UpdateSourceInfo info = d->updateSourcesInfo->updateSourceInfo(i);
+ QTreeWidgetItem* item = new QTreeWidgetItem(this);
+ item->setText(0, info.name);
+ item->setText(1, info.title);
+ item->setText(2, info.url.toString());
+ item->setData(0, Qt::UserRole, qVariantFromValue<KDUpdater::UpdateSourceInfo>(info));
+ }
+
+ resizeColumnToContents(0);
+}
+
+/*!
+ Call this slot to make use of the in-built dialog box to add a new update source. Shown
+ below is a screenshot of the in-built dialog box.
+
+ \image html addupdatesource.jpg
+*/
+void KDUpdater::UpdateSourcesView::addNewSource()
+{
+ if( !d->updateSourcesInfo )
+ return;
+
+ QDialog dialog(this);
+ Ui::AddUpdateSourceDialog ui;
+ ui.setupUi(&dialog);
+
+ while(1)
+ {
+ if( dialog.exec() == QDialog::Rejected )
+ return;
+
+ if(ui.txtName->text().isEmpty() || ui.txtUrl->text().isEmpty())
+ {
+ QMessageBox::information(this, tr("Invalid Update Source Info"),
+ tr("A valid update source name and url has to be provided"));
+ continue;
+ }
+
+ break;
+ }
+
+ KDUpdater::UpdateSourceInfo newInfo;
+ newInfo.name = ui.txtName->text();
+ newInfo.title = ui.txtTitle->text();
+ newInfo.description = ui.txtDescription->toPlainText(); // FIXME: This should perhaps be toHtml
+ newInfo.url = QUrl(ui.txtUrl->text());
+
+ d->updateSourcesInfo->addUpdateSourceInfo(newInfo);
+}
+
+/*!
+ Call this slot to delete the currently selected update source.
+*/
+void KDUpdater::UpdateSourcesView::removeCurrentSource()
+{
+ if( !d->updateSourcesInfo )
+ return;
+
+ QTreeWidgetItem* item = this->currentItem();
+ if( !item )
+ return;
+
+ int index = this->indexOfTopLevelItem(item);
+ if( index < 0 )
+ return;
+
+ d->updateSourcesInfo->removeUpdateSourceInfoAt(index);
+}
+
+/*!
+ Call this slot to edit the currently selected update source, using the in-built edit
+ update source dialog box. Shown below is a screenshot of the edit update source dialog
+ box.
+
+ \image html editupdatesource.jpg
+*/
+void KDUpdater::UpdateSourcesView::editCurrentSource()
+{
+ if( !d->updateSourcesInfo )
+ return;
+
+ QTreeWidgetItem* item = this->currentItem();
+ if( !item )
+ return;
+
+ int index = this->indexOfTopLevelItem(item);
+ if( index < 0 )
+ return;
+
+ KDUpdater::UpdateSourceInfo info = item->data(0, Qt::UserRole).value<KDUpdater::UpdateSourceInfo>();
+
+ QDialog dialog(this);
+ Ui::AddUpdateSourceDialog ui;
+ ui.setupUi(&dialog);
+ ui.txtName->setText(info.name);
+ ui.txtTitle->setText(info.title);
+ ui.txtDescription->setPlainText(info.description); // FIXME: This should perhaps be setHtml
+ ui.txtUrl->setText(info.url.toString());
+ dialog.setWindowTitle(tr("Edit Update Source"));
+
+ if( dialog.exec() == QDialog::Rejected )
+ return;
+
+ KDUpdater::UpdateSourceInfo newInfo;
+ newInfo.name = ui.txtName->text();
+ newInfo.title = ui.txtTitle->text();
+ newInfo.description = ui.txtDescription->toPlainText(); // FIXME: This should perhaps be setHtml
+ newInfo.url = QUrl(ui.txtUrl->text());
+
+ d->updateSourcesInfo->setUpdateSourceInfoAt(index, newInfo);
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::UpdateSourcesView::slotUpdateSourceInfoAdded(const KDUpdater::UpdateSourceInfo &info)
+{
+ if( !d->updateSourcesInfo )
+ return;
+
+ QTreeWidgetItem* item = new QTreeWidgetItem(this);
+ item->setText(0, info.name);
+ item->setText(1, info.title);
+ item->setText(2, info.url.toString());
+ item->setData(0, Qt::UserRole, qVariantFromValue<KDUpdater::UpdateSourceInfo>(info));
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::UpdateSourcesView::slotUpdateSourceInfoRemoved(const KDUpdater::UpdateSourceInfo &info)
+{
+ if( !d->updateSourcesInfo )
+ return;
+
+ QTreeWidgetItem* item = 0;
+ for(int i=0; i<topLevelItemCount(); i++)
+ {
+ item = topLevelItem(i);
+ KDUpdater::UpdateSourceInfo itemInfo = item->data(0, Qt::UserRole).value<KDUpdater::UpdateSourceInfo>();
+ if(itemInfo == info)
+ break;
+ item = 0;
+ }
+
+ if( !item )
+ return;
+
+ delete item;
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::UpdateSourcesView::slotUpdateSourceInfoChanged (const KDUpdater::UpdateSourceInfo &newInfo,
+ const KDUpdater::UpdateSourceInfo &oldInfo)
+{
+ if( !d->updateSourcesInfo )
+ return;
+
+ QTreeWidgetItem* item = 0;
+ for(int i=0; i<topLevelItemCount(); i++)
+ {
+ item = topLevelItem(i);
+ KDUpdater::UpdateSourceInfo itemInfo = item->data(0, Qt::UserRole).value<KDUpdater::UpdateSourceInfo>();
+ if(itemInfo == oldInfo)
+ break;
+ item = 0;
+ }
+
+ if( !item )
+ return;
+
+ item->setText(0, newInfo.name);
+ item->setText(1, newInfo.title);
+ item->setText(2, newInfo.url.toString());
+ item->setData(0, Qt::UserRole, qVariantFromValue<KDUpdater::UpdateSourceInfo>(newInfo));
+}
+
+/*!
+ \internal
+*/
+void KDUpdater::UpdateSourcesView::contextMenuEvent(QContextMenuEvent* e)
+{
+ QTreeWidgetItem* item = this->itemAt( e->pos() );
+
+ QMenu menu;
+ QAction* addAction = menu.addAction(tr("&Add Source"));
+ QAction* editAction = item ? menu.addAction(tr("&Edit Source")) : 0;
+ QAction* remAction = item ? menu.addAction(tr("&Remove Source")) : 0;
+
+ QAction* result = menu.exec( QCursor::pos() );
+ if( !result )
+ return;
+
+ if( result == addAction )
+ this->addNewSource();
+ else if( result == remAction )
+ this->removeCurrentSource();
+ else if( result == editAction )
+ this->editCurrentSource();
+}
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.h b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.h
new file mode 100644
index 000000000..c2c840d72
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/kdupdaterupdatesourcesview.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_SOURCES_VIEW_H
+#define KD_UPDATER_UPDATE_SOURCES_VIEW_H
+
+#include "kdupdater.h"
+#include <QTreeWidget>
+
+namespace KDUpdater
+{
+ struct UpdateSourceInfo;
+ class UpdateSourcesInfo;
+
+ class KDTOOLS_UPDATER_EXPORT UpdateSourcesView : public QTreeWidget
+ {
+ Q_OBJECT
+
+ public:
+ explicit UpdateSourcesView(QWidget* parent=0);
+ ~UpdateSourcesView();
+
+ void setUpdateSourcesInfo(UpdateSourcesInfo* info);
+ UpdateSourcesInfo* updateSourcesInfo() const;
+
+ int currentUpdateSourceInfoIndex() const;
+
+ public Q_SLOTS:
+ void refresh();
+ void addNewSource();
+ void removeCurrentSource();
+ void editCurrentSource();
+
+ protected:
+ void contextMenuEvent(QContextMenuEvent* e);
+
+ private Q_SLOTS:
+ void slotUpdateSourceInfoAdded(const UpdateSourceInfo &info);
+ void slotUpdateSourceInfoRemoved(const UpdateSourceInfo &info);
+ void slotUpdateSourceInfoChanged(const UpdateSourceInfo &newInfo,
+ const UpdateSourceInfo &oldInfo);
+
+ private:
+ struct UpdateSourcesViewData;
+ UpdateSourcesViewData* d;
+ };
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/kdtools/KDUpdater/updatesdialog.ui b/installerbuilder/libinstaller/kdtools/KDUpdater/updatesdialog.ui
new file mode 100644
index 000000000..52162109e
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/KDUpdater/updatesdialog.ui
@@ -0,0 +1,245 @@
+<ui version="4.0" >
+ <class>UpdatesDialog</class>
+ <widget class="QDialog" name="UpdatesDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>555</width>
+ <height>478</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Update</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <property name="sizeConstraint" >
+ <enum>QLayout::SetMinAndMaxSize</enum>
+ </property>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="pixmapLabel" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>96</width>
+ <height>96</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2" colspan="2" >
+ <widget class="QLabel" name="descriptionLabel" >
+ <property name="minimumSize" >
+ <size>
+ <width>400</width>
+ <height>96</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::RichText</enum>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" colspan="2" >
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QWidget" native="1" name="releaseNotesGroup" >
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <property name="leftMargin" >
+ <number>0</number>
+ </property>
+ <property name="rightMargin" >
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>&lt;b>Release Notes:&lt;/b></string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::RichText</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KDUPDATERVIEW" native="1" name="releaseNotesView" >
+ <property name="minimumSize" >
+ <size>
+ <width>400</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" native="1" name="packageSwitchBar" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="packageUpdateCheckBox" >
+ <property name="text" >
+ <string>Update the current package</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>296</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="previousPackageButton" >
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="iconSize" >
+ <size>
+ <width>8</width>
+ <height>8</height>
+ </size>
+ </property>
+ <property name="autoRaise" >
+ <bool>true</bool>
+ </property>
+ <property name="arrowType" >
+ <enum>Qt::LeftArrow</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="currentPackageLabel" >
+ <property name="text" >
+ <string>N</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>/</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="totalPackageLabel" >
+ <property name="text" >
+ <string>M</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="nextPackageButton" >
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="iconSize" >
+ <size>
+ <width>8</width>
+ <height>8</height>
+ </size>
+ </property>
+ <property name="autoRaise" >
+ <bool>true</bool>
+ </property>
+ <property name="arrowType" >
+ <enum>Qt::RightArrow</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="3" >
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KDUPDATERVIEW</class>
+ <extends>QWidget</extends>
+ <header>qwidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>UpdatesDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>UpdatesDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/installerbuilder/libinstaller/kdtools/LICENSE.LGPL b/installerbuilder/libinstaller/kdtools/LICENSE.LGPL
new file mode 100644
index 000000000..ea164db15
--- /dev/null
+++ b/installerbuilder/libinstaller/kdtools/LICENSE.LGPL
@@ -0,0 +1,488 @@
+
+ The KD Tools Library is Copyright (C) 2001-2009 Klarälvdalens Datakonsult AB.
+
+ You may use, distribute and copy the KD Tools Library under the terms of
+ GNU Library General Public License version 2, which is displayed below.
+
+-------------------------------------------------------------------------
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/installerbuilder/libinstaller/lazyplaintextedit.cpp b/installerbuilder/libinstaller/lazyplaintextedit.cpp
new file mode 100644
index 000000000..930e05ca8
--- /dev/null
+++ b/installerbuilder/libinstaller/lazyplaintextedit.cpp
@@ -0,0 +1,89 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "lazyplaintextedit.h"
+
+#include <QScrollBar>
+
+#define TIMER_TIME 10
+
+LazyPlainTextEdit::LazyPlainTextEdit(QWidget *parent) :
+ QPlainTextEdit(parent), m_timerId(0)
+{
+}
+
+void LazyPlainTextEdit::timerEvent(QTimerEvent *event)
+{
+ if (event->timerId() == m_timerId) {
+ killTimer(m_timerId);
+ m_timerId = 0;
+ m_chachedOutput.chop(1); //removes the last \n
+ appendPlainText(m_chachedOutput);
+ horizontalScrollBar()->setValue( 0 );
+ m_chachedOutput.clear();
+ }
+}
+
+void LazyPlainTextEdit::append(const QString &text)
+{
+ if (m_timerId) {
+ killTimer(m_timerId);
+ m_timerId = 0;
+ }
+ m_chachedOutput.append(text + QLatin1String("\n"));
+ if (isVisible()) {
+ m_timerId = startTimer(TIMER_TIME);
+ }
+}
+
+void LazyPlainTextEdit::clear()
+{
+ if (m_timerId) {
+ killTimer(m_timerId);
+ m_timerId = 0;
+ m_chachedOutput.clear();
+ }
+ QPlainTextEdit::clear();
+}
+
+
+void LazyPlainTextEdit::setVisible ( bool visible )
+{
+ if (m_timerId) {
+ killTimer(m_timerId);
+ m_timerId = 0;
+ }
+ if (visible) {
+ m_timerId = startTimer(TIMER_TIME);
+ }
+ QPlainTextEdit::setVisible(visible);
+}
diff --git a/installerbuilder/libinstaller/lazyplaintextedit.h b/installerbuilder/libinstaller/lazyplaintextedit.h
new file mode 100644
index 000000000..0afcd3bb0
--- /dev/null
+++ b/installerbuilder/libinstaller/lazyplaintextedit.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef LAZYPLAINTEXTEDIT_H
+#define LAZYPLAINTEXTEDIT_H
+
+#include <QPlainTextEdit>
+
+class LazyPlainTextEdit : public QPlainTextEdit
+{
+ Q_OBJECT
+public:
+ explicit LazyPlainTextEdit(QWidget *parent = 0);
+
+public slots:
+ void append(const QString &text);
+ virtual void clear();
+ virtual void setVisible ( bool visible );
+protected:
+ void timerEvent(QTimerEvent *event);
+private:
+ QString m_chachedOutput;
+ int m_timerId;
+};
+
+#endif // LAZYPLAINTEXTEDIT_H
diff --git a/installerbuilder/libinstaller/libinstaller.pri b/installerbuilder/libinstaller/libinstaller.pri
new file mode 100644
index 000000000..c5b537c76
--- /dev/null
+++ b/installerbuilder/libinstaller/libinstaller.pri
@@ -0,0 +1,48 @@
+macx:DEFINES += _LZMA_UINT32_IS_ULONG
+
+DEFINES += FSENGINE_TCP
+
+INCLUDEPATH += $$PWD \
+ $$PWD/.. \
+ $$PWD/kdtools
+
+DEPENDPATH += $$PWD \
+ $$PWD/.. \
+ $$PWD/kdtools/KDToolsCore \
+ $$PWD/kdtools/KDUpdater
+
+
+INCLUDEPATH += $$PWD/3rdparty/p7zip_9.04/unix/CPP \
+ $$PWD/3rdparty/p7zip_9.04
+
+DEPENDPATH += $$PWD/3rdparty/p7zip_9.04/unix/CPP \
+ $$PWD/3rdparty/p7zip_9.04
+
+CONFIG( shared, static|shared ):DEFINES += LIB_INSTALLER_SHARED
+CONFIG( shared, static|shared ):DEFINES += KDTOOLS_SHARED
+
+CONFIG += uitools help
+QTPLUGIN += qsqlite
+
+QT += script
+QT += gui # gui needed for KDUpdater include (compareVersion), which indirectly include QTreeWidget
+
+LIBS = -L$$OUT_PWD/../lib -L$$OUT_PWD/../../lib -linstaller $$LIBS
+
+win32:LIBS += -lole32 -lUser32 -loleaut32 -lshell32
+macx:LIBS += -framework Security
+unix:!macx:LIBS += -lutil
+
+static {
+ unix {
+ exists($$OUT_PWD/../lib/libinstaller.a):POST_TARGETDEPS += $$OUT_PWD/../lib/libinstaller.a
+ exists($$OUT_PWD/../../lib/libinstaller.a):POST_TARGETDEPS += $$OUT_PWD/../../lib/libinstaller.a
+ }
+ win32 {
+ exists($$OUT_PWD/../lib/installer.lib):POST_TARGETDEPS += $$OUT_PWD/../lib/installer.lib
+ exists($$OUT_PWD/../../lib/installer.lib):POST_TARGETDEPS += $$OUT_PWD/../../lib/installer.lib
+ }
+}
+
+RESOURCES += content.qrc
+
diff --git a/installerbuilder/libinstaller/libinstaller.pro b/installerbuilder/libinstaller/libinstaller.pro
new file mode 100644
index 000000000..6f9bc3e1a
--- /dev/null
+++ b/installerbuilder/libinstaller/libinstaller.pro
@@ -0,0 +1,186 @@
+TEMPLATE = lib
+TARGET = installer
+DEPENDPATH += . \
+ .. \
+ ../common \
+ kdtools/KDToolsCore \
+ kdtools/KDUpdater
+INCLUDEPATH += . \
+ .. \
+ kdtools
+
+DESTDIR = $$OUT_PWD/../lib
+DLLDESTDIR = $$OUT_PWD/../bin
+
+DEFINES += QT_NO_CAST_FROM_ASCII \
+ BUILD_LIB_INSTALLER \
+ FSENGINE_TCP
+
+CONFIG( shared, static|shared ){
+ DEFINES += KDTOOLS_SHARED
+}
+
+QT += script \
+ network \
+ sql
+CONFIG += help uitools
+
+QTPLUGIN += qsqlite
+
+include(3rdparty/p7zip_9.04/p7zip.pri)
+include(kdtools/KDToolsCore/KDToolsCore.pri)
+include(kdtools/KDUpdater/KDUpdater.pri)
+
+HEADERS += $$PWD/qinstaller.h \
+ $$PWD/qinstallergui.h \
+ ../common/binaryformat.h \
+ ../common/binaryformatengine.h \
+ ../common/binaryformatenginehandler.h \
+ ../common/repository.h \
+ ../common/zipjob.h \
+ ../common/kd7zengine.h \
+ ../common/kd7zenginehandler.h \
+ ../common/utils.h \
+ ../common/errors.h \
+ kdmmappedfileiodevice.h \
+ qinstallercomponent.h \
+ qinstallercomponentmodel.h \
+ qinstallerglobal.h \
+ qtpatch.h \
+ qtpatchoperation.h \
+ setdemospathonqtoperation.h \
+ setexamplespathonqtoperation.h \
+ setpluginpathonqtcoreoperation.h \
+ setimportspathonqtcoreoperation.h \
+ replaceoperation.h \
+ linereplaceoperation.h \
+ registerdocumentationoperation.h \
+ registerqtoperation.h \
+ setqtcreatorvalueoperation.h \
+ copydirectoryoperation.h \
+ simplemovefileoperation.h \
+ extractarchiveoperation.h \
+ extractarchiveoperation_p.h \
+ globalsettingsoperation.h \
+ createshortcutoperation.h \
+ createdesktopentryoperation.h \
+ registerfiletypeoperation.h \
+ environmentvariablesoperation.h \
+ installiconsoperation.h \
+ selfrestartoperation.h \
+ installersettings.h \
+ getrepositorymetainfojob.h \
+ downloadarchivesjob.h \
+ init.h \
+ updater.h \
+ updateagent.h \
+ updatesettings.h \
+ updatesettingsdialog.h \
+ updatesettingswidget.h \
+ componentselectiondialog.h \
+ adminauthorization.h \
+ fsengineclient.h \
+ fsengineserver.h \
+ elevatedexecuteoperation.h \
+ installationprogressdialog.h \
+ fakestopprocessforupdateoperation.h \
+ lazyplaintextedit.h \
+ progresscoordinator.h \
+ minimumprogressoperation.h \
+ performinstallationform.h \
+ messageboxhandler.h \
+ getrepositoriesmetainfojob.h \
+ licenseoperation.h
+
+SOURCES += $$PWD/qinstaller.cpp \
+ $$PWD/qinstallergui.cpp \
+ ../common/binaryformat.cpp \
+ ../common/binaryformatengine.cpp \
+ ../common/binaryformatenginehandler.cpp \
+ ../common/repository.cpp \
+ ../common/zipjob.cpp \
+ ../common/kd7zengine.cpp \
+ ../common/kd7zenginehandler.cpp \
+ ../common/installersettings.cpp \
+ ../common/fileutils.cpp \
+ ../common/utils.cpp \
+ kdmmappedfileiodevice.cpp \
+ qinstallercomponent.cpp \
+ qinstallercomponentmodel.cpp \
+ qtpatch.cpp \
+ qtpatchoperation.cpp \
+ setdemospathonqtoperation.cpp \
+ setexamplespathonqtoperation.cpp \
+ setpluginpathonqtcoreoperation.cpp \
+ setimportspathonqtcoreoperation.cpp \
+ replaceoperation.cpp \
+ linereplaceoperation.cpp \
+ registerdocumentationoperation.cpp \
+ registerqtoperation.cpp \
+ setqtcreatorvalueoperation.cpp \
+ copydirectoryoperation.cpp \
+ simplemovefileoperation.cpp \
+ extractarchiveoperation.cpp \
+ globalsettingsoperation.cpp \
+ createshortcutoperation.cpp \
+ createdesktopentryoperation.cpp \
+ registerfiletypeoperation.cpp \
+ environmentvariablesoperation.cpp \
+ installiconsoperation.cpp \
+ selfrestartoperation.cpp \
+ getrepositorymetainfojob.cpp \
+ downloadarchivesjob.cpp \
+ init.cpp \
+ updater.cpp \
+ updateagent.cpp \
+ updatesettings.cpp \
+ updatesettingsdialog.cpp \
+ updatesettingswidget.cpp \
+ componentselectiondialog.cpp \
+ adminauthorization.cpp \
+ fsengineclient.cpp \
+ fsengineserver.cpp \
+ elevatedexecuteoperation.cpp \
+ installationprogressdialog.cpp \
+ fakestopprocessforupdateoperation.cpp \
+ lazyplaintextedit.cpp \
+ progresscoordinator.cpp \
+ minimumprogressoperation.cpp \
+ performinstallationform.cpp \
+ messageboxhandler.cpp \
+ getrepositoriesmetainfojob.cpp \
+ licenseoperation.cpp
+
+macx {
+ HEADERS += macrelocateqt.h \
+ macreplaceinstallnamesoperation.h
+ SOURCES += macrelocateqt.cpp \
+ macreplaceinstallnamesoperation.cpp
+}
+
+win32:SOURCES += adminauthorization_win.cpp
+macx:SOURCES += adminauthorization_mac.cpp
+unix:!macx: SOURCES += adminauthorization_x11.cpp
+
+win32:OBJECTS_DIR = .obj
+win32:LIBS += ole32.lib \
+ oleaut32.lib \
+ user32.lib
+
+# Needed by KDToolsCore (in kdlog_win.cpp):
+win32:LIBS += advapi32.lib psapi.lib
+macx:LIBS += -framework Carbon
+
+CONFIG( shared, static|shared ): {
+ DEFINES += LIB_INSTALLER_SHARED
+ win32: LIBS += shell32.lib
+}
+
+macx: LIBS += -framework Security
+
+TRANSLATIONS += de_de.ts \
+ sv_se.ts
+RESOURCES += ../common/openssl.qrc \
+ patch_file_lists.qrc
+
+FORMS += componentselectiondialog.ui updatesettingsdialog.ui updatesettingswidget.ui
diff --git a/installerbuilder/libinstaller/licenseoperation.cpp b/installerbuilder/libinstaller/licenseoperation.cpp
new file mode 100644
index 000000000..406ae2a17
--- /dev/null
+++ b/installerbuilder/libinstaller/licenseoperation.cpp
@@ -0,0 +1,117 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "licenseoperation.h"
+
+#include "qinstaller.h"
+#include "common/installersettings.h"
+
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QtCore/QTextStream>
+
+using namespace QInstaller;
+
+LicenseOperation::LicenseOperation()
+{
+ setName(QLatin1String("License"));
+}
+
+LicenseOperation::~LicenseOperation()
+{
+}
+
+void LicenseOperation::backup()
+{
+}
+
+bool LicenseOperation::performOperation()
+{
+ QVariantMap licenses = value(QLatin1String("licenses")).toMap();
+ if (licenses.isEmpty()) {
+ setError(UserDefinedError);
+ setErrorString(tr("No license files found to copy."));
+ return false;
+ }
+
+ Installer *installer = qVariantValue<Installer*>(value(QLatin1String("installer")));
+ QString targetDir = QString::fromLatin1("%1/%2").arg(installer->value(QLatin1String("TargetDir")),
+ QLatin1String("Licenses"));
+
+ QDir dir;
+ dir.mkpath(targetDir);
+ setArguments(QStringList(targetDir));
+
+ for (QVariantMap::const_iterator it = licenses.begin(); it != licenses.end(); ++it) {
+ QFile file(targetDir + QDir::separator() + it.key());
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
+ setError(UserDefinedError);
+ setErrorString(tr("Can not write license file: %1.").arg(targetDir + QDir::separator()
+ + it.key()));
+ return false;
+ }
+
+ QTextStream stream(&file);
+ stream << it.value().toString();
+ }
+
+ return true;
+}
+
+bool LicenseOperation::undoOperation()
+{
+ QVariantMap licenses = value(QLatin1String("licenses")).toMap();
+ if (licenses.isEmpty()) {
+ setError(UserDefinedError);
+ setErrorString(tr("No license files found to delete."));
+ return false;
+ }
+
+ QString targetDir = arguments().value(0);
+ for (QVariantMap::const_iterator it = licenses.begin(); it != licenses.end(); ++it)
+ QFile::remove(targetDir + QDir::separator() + it.key());
+
+ QDir dir;
+ dir.rmdir(targetDir);
+
+ return true;
+}
+
+bool LicenseOperation::testOperation()
+{
+ return true;
+}
+
+LicenseOperation* LicenseOperation::clone() const
+{
+ return new LicenseOperation();
+}
diff --git a/installerbuilder/libinstaller/licenseoperation.h b/installerbuilder/libinstaller/licenseoperation.h
new file mode 100644
index 000000000..4444bcf3c
--- /dev/null
+++ b/installerbuilder/libinstaller/licenseoperation.h
@@ -0,0 +1,54 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef LICENSEOPERATION_H
+#define LICENSEOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+#include "installer_global.h"
+#include <QtCore/QObject>
+
+namespace QInstaller {
+
+class INSTALLER_EXPORT LicenseOperation : public QObject, public KDUpdater::UpdateOperation
+{
+ Q_OBJECT
+
+public:
+ LicenseOperation();
+ ~LicenseOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ LicenseOperation* clone() const;
+
+};
+
+} // namespace QInstaller
+
+#endif //LICENSEOPERATION_H
diff --git a/installerbuilder/libinstaller/linereplaceoperation.cpp b/installerbuilder/libinstaller/linereplaceoperation.cpp
new file mode 100644
index 000000000..b0e5da52c
--- /dev/null
+++ b/installerbuilder/libinstaller/linereplaceoperation.cpp
@@ -0,0 +1,125 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "linereplaceoperation.h"
+#include <qinstaller.h>
+#include "common/utils.h"
+
+#include <QFile>
+#include <QDir>
+#include <QDebug>
+#include <QBuffer>
+
+using namespace QInstaller;
+
+LineReplaceOperation::LineReplaceOperation()
+{
+ setName(QLatin1String("LineReplace"));
+}
+
+LineReplaceOperation::~LineReplaceOperation()
+{
+}
+
+void LineReplaceOperation::backup()
+{
+}
+
+bool LineReplaceOperation::performOperation()
+{
+ const QStringList args = arguments();
+
+ // Arguments:
+ // 1. filename
+ // 2. startsWith Search-String
+ // 3. Replace-Line-String
+ if ( args.count() != 3 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 3 expected.")
+ .arg(name()).arg( args.count() ) );
+ return false;
+ }
+ const QString currentFileName = args.at(0);
+ const QString searchString = args.at(1);
+ const QString replaceString = args.at(2);
+ QString debugString( QLatin1String("Replacing lines with %1 to %2 in %3") );
+ debugString = debugString.arg(searchString);
+ debugString = debugString.arg(replaceString);
+ debugString = debugString.arg(currentFileName);
+ verbose() << debugString;
+
+ QFile file(currentFileName);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Failed to open %1 for reading" ).arg( currentFileName ) );
+ return false;
+ }
+
+ QByteArray memorybyteArray;
+
+ while (!file.atEnd()) {
+ QByteArray line = file.readLine();
+ if (QString::fromLatin1(line).trimmed().startsWith(searchString)) {
+ memorybyteArray.append(replaceString.toLatin1()).append("\n");
+ } else {
+ memorybyteArray.append(line);
+ }
+ }
+ file.close();
+
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Failed to open %1 for writing" ).arg( currentFileName ) );
+ return false;
+ }
+
+ file.write( memorybyteArray );
+ file.close();
+
+ return true;
+}
+
+bool LineReplaceOperation::undoOperation()
+{
+ // Need to remove settings again
+ return true;
+}
+
+bool LineReplaceOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* LineReplaceOperation::clone() const
+{
+ return new LineReplaceOperation();
+}
diff --git a/installerbuilder/libinstaller/linereplaceoperation.h b/installerbuilder/libinstaller/linereplaceoperation.h
new file mode 100644
index 000000000..2c2c7cb68
--- /dev/null
+++ b/installerbuilder/libinstaller/linereplaceoperation.h
@@ -0,0 +1,47 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef LINEREPLACEOPERATION_H
+#define LINEREPLACEOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class LineReplaceOperation : public KDUpdater::UpdateOperation
+{
+public:
+ LineReplaceOperation();
+ ~LineReplaceOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+#endif // LINEREPLACEOPERATION_H
diff --git a/installerbuilder/libinstaller/macrelocateqt.cpp b/installerbuilder/libinstaller/macrelocateqt.cpp
new file mode 100644
index 000000000..4f59e9f2f
--- /dev/null
+++ b/installerbuilder/libinstaller/macrelocateqt.cpp
@@ -0,0 +1,224 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "macrelocateqt.h"
+#include "common/utils.h"
+#include "fsengineclient.h"
+
+#include <QtCore/QDirIterator>
+#include <QtCore/QDebug>
+#include <QtCore/QBuffer>
+#include <QtCore/QProcess>
+
+using namespace QInstaller;
+
+Relocator::Relocator()
+{
+}
+
+bool Relocator::apply(const QString &qtInstallDir, const QString &targetDir)
+{
+ verbose() << "Relocator::apply(" << qtInstallDir << ')' << std::endl;
+
+ mErrorMessage.clear();
+ mOriginalInstallDir.clear();
+
+ {
+ QFile buildRootFile(qtInstallDir + QLatin1String("/.orig_build_root"));
+ if (buildRootFile.exists() && buildRootFile.open(QFile::ReadOnly)) {
+ mOriginalInstallDir = QString::fromLocal8Bit(buildRootFile.readAll()).trimmed();
+ if (!mOriginalInstallDir.endsWith(QLatin1Char('/')))
+ mOriginalInstallDir += QLatin1Char('/');
+ }
+ }
+
+ mInstallDir = targetDir;
+ if (!mInstallDir.endsWith(QLatin1Char('/')))
+ mInstallDir.append(QLatin1Char('/'));
+ if (!QFile::exists(qtInstallDir + QLatin1String("/bin/qmake"))) {
+ mErrorMessage = QLatin1String("This is not a Qt installation directory.");
+ return false;
+ }
+
+ {
+ QDirIterator dirIterator(qtInstallDir + QLatin1String("/lib"), QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+ while (dirIterator.hasNext()) {
+ QString dirName = dirIterator.next();
+ if (dirName.endsWith(QLatin1String(".framework")))
+ relocateFramework(dirName);
+ }
+ }
+
+ QStringList dyLibDirs;
+ dyLibDirs << QLatin1String("/plugins") << QLatin1String("/lib") << QLatin1String("/imports");
+ foreach (QString dylibItem, dyLibDirs){
+ QDirIterator dirIterator(qtInstallDir + dylibItem, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+ while (dirIterator.hasNext()) {
+ QString fileName = dirIterator.next();
+ if (fileName.endsWith(QLatin1String(".dylib"))) {
+ relocateBinary(fileName);
+ }
+ }
+ }
+
+ // We should not iterate over each file, but to be sure check each of those in relocate
+ {
+ QDirIterator dirIterator(qtInstallDir + QLatin1String("/bin"), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+ while (dirIterator.hasNext()) {
+ QString fileName = dirIterator.next();
+ if (fileName.contains(QLatin1String("app/Contents")) && !fileName.contains(QLatin1String("/MacOS")))
+ continue;
+ relocateBinary(fileName);
+ }
+ }
+
+ return mErrorMessage.isNull();
+}
+
+bool Relocator::containsOriginalBuildDir(const QString &dirName)
+{
+ int idx = dirName.indexOf(QLatin1String("_BUILD_"));
+ if (idx < 0)
+ return false;
+ return dirName.indexOf(QLatin1String("_PADDED_"), idx) >= 0;
+}
+
+void Relocator::extractExecutableInfo(const QString& fileName, QStringList& frameworks)
+{
+ verbose() << "Relocator calling otool -l for " << fileName << std::endl;
+ QProcess otool;
+ otool.start(QLatin1String("otool"), QStringList() << QLatin1String("-l") << fileName);
+ if (!otool.waitForStarted()) {
+ mErrorMessage = QLatin1String("Can't start otool. Is Xcode installed?");
+ return;
+ }
+ otool.waitForFinished();
+ enum State {
+ State_Start,
+ State_LC_ID_DYLIB,
+ State_LC_LOAD_DYLIB
+ };
+ State state = State_Start;
+ QByteArray outputData = otool.readAllStandardOutput();
+ QBuffer output(&outputData);
+ output.open(QBuffer::ReadOnly);
+ while (!output.atEnd()) {
+ QString line = QString::fromLocal8Bit(output.readLine());
+ line = line.trimmed();
+// qDebug() << line;
+ if (line.startsWith(QLatin1String("cmd "))) {
+ line.remove(0, 4);
+ if (line == QLatin1String("LC_LOAD_DYLIB"))
+ state = State_LC_LOAD_DYLIB;
+ else if (line == QLatin1String("LC_ID_DYLIB"))
+ state = State_LC_ID_DYLIB;
+ else
+ state = State_Start;
+ } else if (state == State_LC_LOAD_DYLIB && line.startsWith(QLatin1String("name "))) {
+ line.remove(0, 5);
+ int idx = line.indexOf(QLatin1String("(offset"));
+ if (idx > 0)
+ line.truncate(idx);
+ line = line.trimmed();
+ if (containsOriginalBuildDir(line))
+ frameworks.append(line);
+ } else if (state == State_LC_ID_DYLIB && mOriginalInstallDir.isNull() && line.startsWith(QLatin1String("name "))) {
+ line.remove(0, 5);
+ if (containsOriginalBuildDir(line)) {
+ mOriginalInstallDir = line;
+ const QString lastBuildDirPart = QLatin1String("/ndk/");
+ int idx = mOriginalInstallDir.indexOf(lastBuildDirPart);
+ if (idx < 0)
+ continue;
+ mOriginalInstallDir.truncate(idx + lastBuildDirPart.length());
+ }
+ }
+ }
+}
+
+void Relocator::relocateBinary(const QString& fileName)
+{
+ QStringList frameworks;
+ extractExecutableInfo(fileName, frameworks);
+
+ QStringList args;
+ args << QLatin1String("-id") << fileName << fileName;
+ if (!execCommand(QLatin1String("install_name_tool"), args))
+ return;
+
+ foreach (const QString& fw, frameworks) {
+ if (!fw.startsWith(mOriginalInstallDir))
+ continue;
+
+ QString newPath = mInstallDir;
+ newPath += fw.mid(mOriginalInstallDir.length());
+
+ args.clear();
+ args << QLatin1String("-change") << fw << newPath << fileName;
+ if (!execCommand(QLatin1String("install_name_tool"), args))
+ return;
+ }
+}
+
+void Relocator::relocateFramework(const QString& directoryName)
+{
+ QFileInfo fi(directoryName);
+ QString frameworkName = fi.baseName();
+ fi.setFile(directoryName + QLatin1String("/Versions/Current/") + frameworkName);
+ if (fi.exists()) {
+ QString fileName = fi.isSymLink() ? fi.symLinkTarget() : fi.absoluteFilePath();
+ relocateBinary(fileName);
+ }
+ fi.setFile(directoryName + QLatin1String("/Versions/Current/") + frameworkName + QLatin1String("_debug"));
+ if (fi.exists()) {
+ QString fileName = fi.isSymLink() ? fi.symLinkTarget() : fi.absoluteFilePath();
+ relocateBinary(fileName);
+ }
+}
+
+bool Relocator::execCommand(const QString& cmd, const QStringList& args)
+{
+ verbose() << "Relocator::execCommand " << cmd << " " << args << std::endl;
+ QProcessWrapper process;
+ process.start(cmd, args);
+ if (!process.waitForStarted()) {
+ mErrorMessage = QLatin1String("Can't start process ") + cmd + QLatin1String(".");
+ return false;
+ }
+ process.waitForFinished();
+ if (process.exitCode() != 0) {
+ mErrorMessage = QLatin1String("Command %1 failed.\nArguments: %2\nOutput: %3\n");
+ mErrorMessage = mErrorMessage.arg(cmd, args.join(QLatin1String(" ")), QString::fromLocal8Bit(process.readAll()));
+ return false;
+ }
+ return true;
+}
diff --git a/installerbuilder/libinstaller/macrelocateqt.h b/installerbuilder/libinstaller/macrelocateqt.h
new file mode 100644
index 000000000..977385463
--- /dev/null
+++ b/installerbuilder/libinstaller/macrelocateqt.h
@@ -0,0 +1,56 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef RELOCATOR_H
+#define RELOCATOR_H
+
+#include <QStringList>
+
+namespace QInstaller {
+
+class Relocator
+{
+public:
+ Relocator();
+
+ bool apply(const QString &qtInstallDir, const QString &targetDir);
+ QString errorMessage() const { return mErrorMessage; }
+
+private:
+ bool containsOriginalBuildDir(const QString &dirName);
+ void extractExecutableInfo(const QString& fileName, QStringList& frameworks);
+ void relocateFramework(const QString& directoryName);
+ void relocateBinary(const QString& fileName);
+ bool execCommand(const QString& cmd, const QStringList& args);
+
+private:
+ QString mErrorMessage;
+ QString mOriginalInstallDir;
+ QString mInstallDir;
+};
+
+} // namespace QInstaller
+
+#endif // RELOCATOR_H
diff --git a/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp
new file mode 100644
index 000000000..377b58688
--- /dev/null
+++ b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp
@@ -0,0 +1,217 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "macreplaceinstallnamesoperation.h"
+#include "fsengineclient.h"
+
+#include <QtCore/QDirIterator>
+#include <QtCore/QDebug>
+#include <QtCore/QBuffer>
+#include <QtCore/QProcess>
+
+using namespace QInstaller;
+
+MacReplaceInstallNamesOperation::MacReplaceInstallNamesOperation()
+{
+ setName(QLatin1String("ReplaceInstallNames"));
+}
+
+void MacReplaceInstallNamesOperation::backup()
+{
+}
+
+bool MacReplaceInstallNamesOperation::performOperation()
+{
+ // Arguments:
+ // 1. indicator to find the original build directory
+ // 2. new build directory
+ // 3. directory containing frameworks
+
+ if( arguments().count() != 3 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 3 expected.")
+ .arg(name()).arg( arguments().count() ) );
+ return false;
+ }
+
+ QString indicator = arguments().at(0);
+ QString installationDir = arguments().at(1);
+ QString searchDir = arguments().at(2);
+ return apply(indicator, installationDir, searchDir);
+}
+
+bool MacReplaceInstallNamesOperation::undoOperation()
+{
+ return true;
+}
+
+bool MacReplaceInstallNamesOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* MacReplaceInstallNamesOperation::clone() const
+{
+ return new MacReplaceInstallNamesOperation;
+}
+
+bool MacReplaceInstallNamesOperation::apply(const QString& indicator, const QString& installationDir, const QString& searchDir)
+{
+ mOriginalBuildDir.clear();
+ mIndicator = indicator;
+ mInstallationDir = installationDir;
+
+ {
+ QDirIterator dirIterator(searchDir, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+ while (dirIterator.hasNext()) {
+ QString dirName = dirIterator.next();
+ if (dirName.endsWith(QLatin1String(".framework")))
+ relocateFramework(dirName);
+ }
+ }
+
+ return error() == NoError;
+}
+
+void MacReplaceInstallNamesOperation::extractExecutableInfo(const QString& fileName, QString& frameworkId, QStringList& frameworks)
+{
+ QProcess otool;
+ otool.start(QLatin1String("otool"), QStringList() << QLatin1String("-l") << fileName);
+ if (!otool.waitForStarted()) {
+ setError(UserDefinedError, tr("Can't invoke otool."));
+ return;
+ }
+ otool.waitForFinished();
+ enum State {
+ State_Start,
+ State_LC_ID_DYLIB,
+ State_LC_LOAD_DYLIB
+ };
+ State state = State_Start;
+ QByteArray outputData = otool.readAllStandardOutput();
+ QBuffer output(&outputData);
+ output.open(QBuffer::ReadOnly);
+ while (!output.atEnd()) {
+ QString line = QString::fromLocal8Bit(output.readLine());
+ line = line.trimmed();
+// qDebug() << line;
+ if (line.startsWith(QLatin1String("cmd "))) {
+ line.remove(0, 4);
+ if (line == QLatin1String("LC_LOAD_DYLIB"))
+ state = State_LC_LOAD_DYLIB;
+ else if (line == QLatin1String("LC_ID_DYLIB"))
+ state = State_LC_ID_DYLIB;
+ else
+ state = State_Start;
+ } else if (state == State_LC_LOAD_DYLIB && line.startsWith(QLatin1String("name "))) {
+ line.remove(0, 5);
+ int idx = line.indexOf(QLatin1String("(offset"));
+ if (idx > 0)
+ line.truncate(idx);
+ line = line.trimmed();
+ frameworks.append(line);
+ } else if (state == State_LC_ID_DYLIB && line.startsWith(QLatin1String("name "))) {
+ line.remove(0, 5);
+ int idx = line.indexOf(QLatin1String("(offset"));
+ if (idx > 0)
+ line.truncate(idx);
+ line = line.trimmed();
+ frameworkId = line;
+
+ mOriginalBuildDir = frameworkId;
+ idx = mOriginalBuildDir.indexOf(mIndicator);
+ if (idx < 0) {
+ mOriginalBuildDir.clear();
+ } else {
+ mOriginalBuildDir.truncate(idx);
+ }
+ if (mOriginalBuildDir.endsWith(QLatin1Char('/')))
+ mOriginalBuildDir.chop(1);
+ }
+ }
+}
+
+void MacReplaceInstallNamesOperation::relocateBinary(const QString& fileName)
+{
+ QString frameworkId;
+ QStringList frameworks;
+ extractExecutableInfo(fileName, frameworkId, frameworks);
+
+ QStringList args;
+ if (frameworkId.contains(mIndicator)) {
+ args << QLatin1String("-id") << fileName << fileName;
+ execCommand(QLatin1String("install_name_tool"), args);
+ }
+
+ foreach (const QString& fw, frameworks) {
+ if (!fw.contains(mOriginalBuildDir))
+ continue;
+
+ QString newPath = fw;
+ newPath.replace(mOriginalBuildDir, mInstallationDir);
+
+ args.clear();
+ args << QLatin1String("-change") << fw << newPath << fileName;
+ execCommand(QLatin1String("install_name_tool"), args);
+ }
+}
+
+void MacReplaceInstallNamesOperation::relocateFramework(const QString& directoryName)
+{
+ //qDebug() << "relocateFramework" << directoryName;
+ QFileInfo fi(directoryName);
+ QString frameworkName = fi.baseName();
+ fi.setFile(directoryName + QLatin1String("/Versions/Current/") + frameworkName);
+ if (fi.exists()) {
+ QString fileName = fi.isSymLink() ? fi.symLinkTarget() : fi.absoluteFilePath();
+ relocateBinary(fileName);
+ }
+ fi.setFile(directoryName + QLatin1String("/Versions/Current/") + frameworkName + QLatin1String("_debug"));
+ if (fi.exists()) {
+ QString fileName = fi.isSymLink() ? fi.symLinkTarget() : fi.absoluteFilePath();
+ relocateBinary(fileName);
+ }
+}
+
+bool MacReplaceInstallNamesOperation::execCommand(const QString& cmd, const QStringList& args)
+{
+ //qDebug() << cmd << args;
+
+ QProcessWrapper process;
+ process.start(cmd, args);
+ if (!process.waitForStarted()) {
+ setError(UserDefinedError, tr("Can't start process %0.").arg(cmd));
+ return false;
+ }
+ process.waitForFinished();
+ return true;
+}
diff --git a/installerbuilder/libinstaller/macreplaceinstallnamesoperation.h b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.h
new file mode 100644
index 000000000..1e4f6acb1
--- /dev/null
+++ b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.h
@@ -0,0 +1,61 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef MACREPLACEINSTALLNAMEOPERATION_H
+#define MACREPLACEINSTALLNAMEOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+#include <QStringList>
+
+namespace QInstaller {
+
+class MacReplaceInstallNamesOperation : public KDUpdater::UpdateOperation
+{
+public:
+ MacReplaceInstallNamesOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+
+ bool apply(const QString& oldString, const QString& newString, const QString& frameworkDir);
+
+private:
+ void extractExecutableInfo(const QString& fileName, QString& frameworkId, QStringList& frameworks);
+ void relocateFramework(const QString& directoryName);
+ void relocateBinary(const QString& fileName);
+ bool execCommand(const QString& cmd, const QStringList& args);
+
+private:
+ QString mIndicator;
+ QString mInstallationDir;
+ QString mOriginalBuildDir;
+};
+
+} // namespace QInstaller
+
+#endif // MACREPLACEINSTALLNAMEOPERATION_H
diff --git a/installerbuilder/libinstaller/messageboxhandler.cpp b/installerbuilder/libinstaller/messageboxhandler.cpp
new file mode 100644
index 000000000..2428843cd
--- /dev/null
+++ b/installerbuilder/libinstaller/messageboxhandler.cpp
@@ -0,0 +1,216 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "messageboxhandler.h"
+
+#include <QApplication>
+#include <QScriptValue>
+#include <QScriptEngine>
+#include <QDebug>
+
+QScriptValue QInstaller::registerMessageBox( QScriptEngine* scriptEngine ) {
+ QScriptValue messageBox = scriptEngine->newQObject(MessageBoxHandler::instance());
+ // register QMessageBox::StandardButton enum in the script connection
+ messageBox.setProperty( QLatin1String( "Ok" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Yes ) ) );
+ messageBox.setProperty( QLatin1String( "Open" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Open ) ) );
+ messageBox.setProperty( QLatin1String( "Save" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Save ) ) );
+ messageBox.setProperty( QLatin1String( "Cancel" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Cancel ) ) );
+ messageBox.setProperty( QLatin1String( "Close" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Close ) ) );
+ messageBox.setProperty( QLatin1String( "Discard" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Discard ) ) );
+ messageBox.setProperty( QLatin1String( "Apply" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Apply ) ) );
+ messageBox.setProperty( QLatin1String( "Reset" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Reset ) ) );
+ messageBox.setProperty( QLatin1String( "RestoreDefaults" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::RestoreDefaults ) ) );
+ messageBox.setProperty( QLatin1String( "Help" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Help ) ) );
+ messageBox.setProperty( QLatin1String( "SaveAll" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::SaveAll ) ) );
+ messageBox.setProperty( QLatin1String( "Yes" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Yes ) ) );
+ messageBox.setProperty( QLatin1String( "YesToAll" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::YesToAll ) ) );
+ messageBox.setProperty( QLatin1String( "No" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::No ) ) );
+ messageBox.setProperty( QLatin1String( "NoToAll" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::NoToAll ) ) );
+ messageBox.setProperty( QLatin1String( "Abort" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Abort ) ) );
+ messageBox.setProperty( QLatin1String( "Retry" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Retry ) ) );
+ messageBox.setProperty( QLatin1String( "Ignore" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::Ignore ) ) );
+ messageBox.setProperty( QLatin1String( "NoButton" ), scriptEngine->newVariant( static_cast< int >( QMessageBox::NoButton ) ) );
+ scriptEngine->globalObject().setProperty( QLatin1String("QMessageBox"), messageBox );
+ return messageBox;
+}
+
+using namespace QInstaller;
+
+MessageBoxHandler *MessageBoxHandler::m_instance = 0;
+
+MessageBoxHandler::MessageBoxHandler(QObject *parent)
+ : QObject(parent), m_defaultAction( MessageBoxHandler::AskUser )
+{
+
+}
+
+
+MessageBoxHandler::~MessageBoxHandler()
+{
+
+}
+
+MessageBoxHandler* MessageBoxHandler::instance()
+{
+ if (m_instance == 0)
+ m_instance = new MessageBoxHandler(qApp);
+ return m_instance;
+}
+
+void MessageBoxHandler::setAutomaticAnswer(const QString& identifier, QMessageBox::StandardButton answer)
+{
+ m_automaticAnswers.insert( identifier, answer );
+}
+
+template <typename T>
+static QList<T> reversed( const QList<T>& list ) {
+ QList<T> res = list;
+ qCopyBackward( list.begin(), list.end(), res.end() );
+ return res;
+}
+
+void MessageBoxHandler::setDefaultAction(DefaultAction defaultAction)
+{
+ if ( m_defaultAction == defaultAction )
+ return;
+ m_defaultAction = defaultAction;
+ m_buttonOrder.clear();
+ if ( m_defaultAction != AskUser )
+ m_buttonOrder << QMessageBox::YesToAll << QMessageBox::Yes << QMessageBox::Ok << QMessageBox::Apply
+ << QMessageBox::SaveAll << QMessageBox::Save <<QMessageBox::Retry << QMessageBox::Ignore
+ << QMessageBox::Help << QMessageBox::RestoreDefaults << QMessageBox::Reset << QMessageBox::Open
+ << QMessageBox::Cancel << QMessageBox::Close << QMessageBox::Abort << QMessageBox::Discard
+ << QMessageBox::No << QMessageBox::NoToAll;
+ if ( m_defaultAction == Reject ) {
+ //if we want to reject everything, we need the lowest button
+ //for example if Cancel existing it could use Cancel, but if Close existing
+ //it will use Close
+ m_buttonOrder = reversed( m_buttonOrder );
+ }
+}
+
+QMessageBox::StandardButton MessageBoxHandler::autoReply( QMessageBox::StandardButtons buttons ) const {
+ if ( buttons == QMessageBox::NoButton )
+ return QMessageBox::NoButton;
+ foreach (const QMessageBox::StandardButton& currentButton, m_buttonOrder)
+ if ( (buttons & currentButton) != 0 )
+ return currentButton;
+ Q_ASSERT( !"the list must have all possible buttons" );
+ return QMessageBox::NoButton;
+}
+
+QWidget* MessageBoxHandler::currentBestSuitParent()
+{
+ if (QApplication::type() == QApplication::Tty) {
+ Q_ASSERT_X(false, Q_FUNC_INFO, "We can't find a parent widget if we are a console application.");
+ return 0;
+ }
+ if (qApp->activeModalWidget())
+ return qApp->activeModalWidget();
+
+ return qApp->activeWindow();
+}
+
+QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messageType, QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+{
+ if (QApplication::type() == QApplication::Tty)
+ return button;
+ if ( m_automaticAnswers.contains( identifier ) )
+ return m_automaticAnswers.value( identifier );
+ if ( m_defaultAction == AskUser ) {
+ if (!identifier.isEmpty())
+ qDebug() << QString(QLatin1String("create message box with identifier: '%1'")).arg(identifier);
+ switch( messageType ) {
+ case criticalType:
+ return QMessageBox::critical( parent, title, text, buttons, button );
+ case informationType:
+ return QMessageBox::information( parent, title, text, buttons, button );
+ case questionType:
+ return QMessageBox::question( parent, title, text, buttons, button );
+ case warningType:
+ return QMessageBox::warning( parent, title, text, buttons, button );
+ }
+ }
+ else
+ return autoReply( buttons );
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Something went realy wrong.");
+ return button;
+}
+
+QMessageBox::StandardButton MessageBoxHandler::critical(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button)
+{
+ return instance()->showMessageBox(criticalType, parent, identifier, title, text, buttons, button);
+}
+
+QMessageBox::StandardButton MessageBoxHandler::information(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button)
+{
+ return instance()->showMessageBox(informationType, parent, identifier, title, text, buttons, button);
+}
+
+QMessageBox::StandardButton MessageBoxHandler::question(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button)
+{
+ return instance()->showMessageBox(questionType, parent, identifier, title, text, buttons, button);
+}
+
+QMessageBox::StandardButton MessageBoxHandler::warning(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button)
+{
+ return instance()->showMessageBox(warningType, parent, identifier, title, text, buttons, button);
+}
+
+int MessageBoxHandler::critical(const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+{
+ return showMessageBox(criticalType, currentBestSuitParent(), identifier, title, text, buttons, button);
+}
+
+int MessageBoxHandler::information(const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+{
+ return showMessageBox(informationType, currentBestSuitParent(), identifier, title, text, buttons, button);
+}
+
+int MessageBoxHandler::question(const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+{
+ return showMessageBox(questionType, currentBestSuitParent(), identifier, title, text, buttons, button);
+}
+
+int MessageBoxHandler::warning(const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) const
+{
+ return showMessageBox(warningType, currentBestSuitParent(), identifier, title, text, buttons, button);
+}
diff --git a/installerbuilder/libinstaller/messageboxhandler.h b/installerbuilder/libinstaller/messageboxhandler.h
new file mode 100644
index 000000000..43e4ac93d
--- /dev/null
+++ b/installerbuilder/libinstaller/messageboxhandler.h
@@ -0,0 +1,110 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_MESSAGEBOXHANDLER_H
+#define QINSTALLER_MESSAGEBOXHANDLER_H
+
+#include <installer_global.h>
+
+#include <QObject>
+#include <QScriptable>
+#include <QMessageBox>
+#include <QHash>
+
+class QString;
+
+namespace QInstaller {
+
+QScriptValue registerMessageBox( QScriptEngine* scriptEngine );
+
+class INSTALLER_EXPORT MessageBoxHandler : public QObject, private QScriptable
+{
+ Q_OBJECT
+
+public:
+ enum DefaultAction {
+ AskUser,
+ Accept,
+ Reject
+ };
+ enum MessageType{
+ criticalType,
+ informationType,
+ questionType,
+ warningType
+ };
+
+ ~MessageBoxHandler();
+ static MessageBoxHandler* instance();
+ static QWidget* currentBestSuitParent();
+
+ void setAutomaticAnswer(const QString& identifier, QMessageBox::StandardButton answer);
+ void setDefaultAction(DefaultAction defaultAction);
+
+ static QMessageBox::StandardButton critical(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton );
+ static QMessageBox::StandardButton information(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button=QMessageBox::NoButton );
+ static QMessageBox::StandardButton question(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Yes|QMessageBox::No,
+ QMessageBox::StandardButton button = QMessageBox::NoButton );
+ static QMessageBox::StandardButton warning(QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton);
+
+ Q_INVOKABLE int critical(const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ Q_INVOKABLE int information(const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ Q_INVOKABLE int question(const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Yes|QMessageBox::No,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ Q_INVOKABLE int warning(const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+//this removes the slot from the script area
+private Q_SLOTS:
+ virtual void deleteLater() {QObject::deleteLater();}
+
+private:
+ MessageBoxHandler(QObject *parent);
+ QMessageBox::StandardButton showMessageBox(MessageType messageType, QWidget* parent, const QString& identifier, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ QMessageBox::StandardButton autoReply( QMessageBox::StandardButtons buttons ) const;
+
+ static MessageBoxHandler *m_instance;
+ QList<QMessageBox::Button> m_buttonOrder;
+ DefaultAction m_defaultAction;
+ QHash<QString,QMessageBox::StandardButton> m_automaticAnswers;
+};
+
+}
+
+#endif // QINSTALLER_MESSAGEBOXHANDLER_H
diff --git a/installerbuilder/libinstaller/minimumprogressoperation.cpp b/installerbuilder/libinstaller/minimumprogressoperation.cpp
new file mode 100644
index 000000000..03aeb0128
--- /dev/null
+++ b/installerbuilder/libinstaller/minimumprogressoperation.cpp
@@ -0,0 +1,72 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "minimumprogressoperation.h"
+
+using namespace QInstaller;
+
+MinimumProgressOperation::MinimumProgressOperation()
+{
+ //this shouldn't be call able by script, but we need a name for the binary format
+ setName(QLatin1String("MinimumProgress"));
+}
+
+MinimumProgressOperation::~MinimumProgressOperation()
+{
+}
+
+void MinimumProgressOperation::backup()
+{
+}
+
+bool MinimumProgressOperation::performOperation()
+{
+ progressChanged(1);
+ return true;
+}
+
+bool MinimumProgressOperation::undoOperation()
+{
+ progressChanged(1);
+ return true;
+}
+
+bool MinimumProgressOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* MinimumProgressOperation::clone() const
+{
+ return new MinimumProgressOperation();
+}
+
diff --git a/installerbuilder/libinstaller/minimumprogressoperation.h b/installerbuilder/libinstaller/minimumprogressoperation.h
new file mode 100644
index 000000000..cb24309dc
--- /dev/null
+++ b/installerbuilder/libinstaller/minimumprogressoperation.h
@@ -0,0 +1,54 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef MINIMUMPROGRESSOPERATION_H
+#define MINIMUMPROGRESSOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+#include <QtCore/QObject>
+
+namespace QInstaller {
+
+//Is only for progress calculation safeness and not for external use.
+class MinimumProgressOperation : public QObject, public KDUpdater::UpdateOperation
+{
+ Q_OBJECT
+public:
+ MinimumProgressOperation();
+ ~MinimumProgressOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+
+signals:
+ void progressChanged( double progress );
+};
+
+}; // namespace
+
+#endif // MINIMUMPROGRESSOPERATION_H
diff --git a/installerbuilder/libinstaller/patch_file_lists.qrc b/installerbuilder/libinstaller/patch_file_lists.qrc
new file mode 100644
index 000000000..a51500369
--- /dev/null
+++ b/installerbuilder/libinstaller/patch_file_lists.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>files-to-patch-linux</file>
+ <file>files-to-patch-windows</file>
+ <file>files-to-patch-macx</file>
+ </qresource>
+</RCC>
diff --git a/installerbuilder/libinstaller/performinstallationform.cpp b/installerbuilder/libinstaller/performinstallationform.cpp
new file mode 100644
index 000000000..ce3ef6586
--- /dev/null
+++ b/installerbuilder/libinstaller/performinstallationform.cpp
@@ -0,0 +1,177 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+
+#include "performinstallationform.h"
+#include "lazyplaintextedit.h"
+#include "progresscoordinator.h"
+#include <common/utils.h>
+
+#include <QProgressBar>
+#include <QPushButton>
+#include <QLabel>
+#include <QVBoxLayout>
+#include <QTimer>
+#include <QScrollBar>
+
+using namespace QInstaller;
+
+PerformInstallationForm::PerformInstallationForm(QObject *parent)
+ : QObject(parent),
+ m_detailsWidget(0),
+ m_detailsButton(0),
+ m_progressBar(0),
+ m_progressLabel(0),
+ m_detailsBrowser(0),
+ m_updateTimer(0)
+{
+}
+
+PerformInstallationForm::~PerformInstallationForm()
+{
+}
+
+void PerformInstallationForm::setupUi(QWidget *widget)
+{
+ m_progressBar = new QProgressBar(widget);
+ m_progressBar->setObjectName( QLatin1String( "ProgressBar" ) );
+ m_progressBar->setRange(1, 100);
+
+ m_progressLabel = new QLabel(widget);
+ m_progressLabel->setObjectName( QLatin1String( "ProgressLabel" ) );
+
+ m_detailsButton = new QPushButton(widget);
+ connect(m_detailsButton, SIGNAL(clicked()), this, SLOT(toggleDetails()));
+ m_detailsButton->setText( tr("Show Details") );
+ m_detailsButton->setObjectName( QLatin1String("button") );
+ m_detailsBrowser = new LazyPlainTextEdit(widget);
+ m_detailsBrowser->setWordWrapMode(QTextOption::NoWrap);
+ m_detailsBrowser->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ QVBoxLayout *layout = new QVBoxLayout(widget);
+ layout->addWidget(m_progressBar);
+ layout->addWidget(m_progressLabel);
+
+ m_detailsWidget = new QWidget(widget);
+ m_detailsWidget->setObjectName( QLatin1String("details") );
+ QHBoxLayout* detailsLayout = new QHBoxLayout( m_detailsWidget );
+ detailsLayout->addWidget(m_detailsButton);
+ detailsLayout->addStretch();
+ layout->addWidget(m_detailsWidget);
+ layout->addWidget(m_detailsBrowser);
+
+ m_detailsBrowser->setVisible(false);
+ layout->addStretch();
+ widget->setLayout(layout);
+
+ m_updateTimer = new QTimer(widget);
+ connect(m_updateTimer, SIGNAL(timeout()),
+ this, SLOT(updateProgress())); //updateProgress includes the label
+ m_updateTimer->setInterval(30);
+}
+
+void PerformInstallationForm::setDetailsWidgetVisible(bool visible)
+{
+ m_detailsWidget->setVisible(visible);
+}
+
+void PerformInstallationForm::appendProgressDetails( const QString &details)
+{
+ m_detailsBrowser->append( details );
+}
+
+void PerformInstallationForm::updateProgress()
+{
+ QInstaller::ProgressCoordninator *progressCoordninator = QInstaller::ProgressCoordninator::instance();
+ const int progressPercentage = progressCoordninator->progressInPercentage();
+ if( progressPercentage == 0 )
+ m_progressBar->setRange( 0, 0 );
+ else
+ m_progressBar->setRange( 0, 100 );
+ if ( progressPercentage != m_progressBar->value() )
+ m_progressBar->setValue( progressPercentage );
+ if (m_progressLabel->text() != progressCoordninator->labelText())
+ m_progressLabel->setText(progressCoordninator->labelText());
+}
+
+void PerformInstallationForm::toggleDetails()
+{
+ const bool willShow = !isShowingDetails();
+ m_detailsButton->setText( willShow ? tr( "Hide Details" ) : tr( "Show Details" ) );
+
+ if (willShow) {
+ scrollDetailsToTheEnd();
+ }
+
+ m_detailsBrowser->setVisible( willShow );
+ emit showDetailsChanged();
+}
+
+void PerformInstallationForm::clearDetailsBrowser()
+{
+ m_detailsBrowser->clear();
+}
+
+void PerformInstallationForm::enableDetails()
+{
+ m_detailsButton->setEnabled( true );
+ m_detailsButton->setText( QObject::tr( "Show Details" ) );
+ m_detailsBrowser->setVisible( false );
+}
+
+void PerformInstallationForm::startUpdateProgress()
+{
+ m_updateTimer->start();
+ updateProgress();
+}
+
+void PerformInstallationForm::stopUpdateProgress()
+{
+ m_updateTimer->stop();
+ updateProgress();
+}
+
+void PerformInstallationForm::setDetailsButtonEnabled(bool enable)
+{
+ m_detailsButton->setEnabled(enable);
+}
+
+void PerformInstallationForm::scrollDetailsToTheEnd()
+{
+ m_detailsBrowser->horizontalScrollBar()->setValue(0);
+ m_detailsBrowser->verticalScrollBar()->setValue( m_detailsBrowser->verticalScrollBar()->maximum() );
+}
+
+bool PerformInstallationForm::isShowingDetails() const
+{
+ return m_detailsBrowser->isVisible();
+}
diff --git a/installerbuilder/libinstaller/performinstallationform.h b/installerbuilder/libinstaller/performinstallationform.h
new file mode 100644
index 000000000..35f894a46
--- /dev/null
+++ b/installerbuilder/libinstaller/performinstallationform.h
@@ -0,0 +1,75 @@
+/**************************************************************************
+**
+** This file is part of Nokia Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef PERFORMINSTALLATIONFORM_H
+#define PERFORMINSTALLATIONFORM_H
+
+#include <QObject>
+
+class LazyPlainTextEdit;
+
+class QWidget;
+class QPushButton;
+class QProgressBar;
+class QLabel;
+class QTimer;
+
+namespace QInstaller {
+
+class PerformInstallationForm : public QObject
+{
+ Q_OBJECT
+public:
+ PerformInstallationForm(QObject *parent);
+ ~PerformInstallationForm();
+ void setupUi(QWidget *widget);
+ void setDetailsWidgetVisible(bool visible);
+ void enableDetails();
+ void startUpdateProgress();
+ void stopUpdateProgress();
+ void setDetailsButtonEnabled(bool enable);
+ void scrollDetailsToTheEnd();
+ bool isShowingDetails() const;
+
+signals:
+ void showDetailsChanged();
+
+public slots:
+ void appendProgressDetails( const QString &details);
+ void updateProgress();
+ void toggleDetails();
+ void clearDetailsBrowser();
+private:
+ QWidget* m_detailsWidget;
+ QPushButton *m_detailsButton;
+ QProgressBar *m_progressBar;
+ QLabel *m_progressLabel;
+ LazyPlainTextEdit *m_detailsBrowser;
+ QTimer *m_updateTimer;
+};
+
+} //namespace QInstaller
+
+#endif // PERFORMINSTALLATIONFORM_H
diff --git a/installerbuilder/libinstaller/progresscoordinator.cpp b/installerbuilder/libinstaller/progresscoordinator.cpp
new file mode 100644
index 000000000..e0cc9ff1f
--- /dev/null
+++ b/installerbuilder/libinstaller/progresscoordinator.cpp
@@ -0,0 +1,267 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "progresscoordinator.h"
+
+#include <QCoreApplication>
+#include <QDebug>
+
+using namespace QInstaller;
+
+uint qHash(QPointer<QObject> key)
+{
+ return qHash(key.data());
+}
+
+
+ProgressCoordninator::ProgressCoordninator(QObject *parent) :
+ QObject(parent),
+ m_currentCompletePercentage(0),
+ m_currentBasePercentage(0),
+ m_manualAddedPercentage(0),
+ m_reservedPercentage(0),
+ m_undoMode(false),
+ m_reachedPercentageBeforeUndo(0)
+{
+ //it have to be in the main thread
+ //to be able refresh the ui with processEvents
+ Q_ASSERT(thread() == qApp->thread());
+}
+
+ProgressCoordninator::~ProgressCoordninator()
+{
+}
+
+ProgressCoordninator* ProgressCoordninator::instance()
+{
+ static ProgressCoordninator* instance = 0;
+ if (instance == 0) {
+ instance = new ProgressCoordninator(qApp);
+ }
+ return instance;
+}
+
+void ProgressCoordninator::reset()
+{
+ disconnectAllSenders();
+ m_senderPendingCalculatedPercentageHash.clear();
+ m_senderPartProgressSizeHash.clear();
+ m_installationLabelText.clear();
+ m_currentCompletePercentage = 0;
+ m_currentBasePercentage = 0;
+ m_manualAddedPercentage = 0;
+ m_reservedPercentage = 0;
+ m_undoMode = false;
+ m_reachedPercentageBeforeUndo = 0;
+ emit detailTextResetNeeded();
+}
+
+void ProgressCoordninator::registerPartProgress(QObject *sender, const char *signal, double partProgressSize)
+{
+ Q_ASSERT(sender);
+ Q_ASSERT(QString::fromLatin1(signal).contains(QLatin1String("(double)")));
+ Q_ASSERT(partProgressSize <= 1);
+
+ m_senderPartProgressSizeHash.insert(sender, partProgressSize);
+ bool isConnected = connect(sender, signal, this, SLOT(partProgressChanged(double)));
+ Q_UNUSED(isConnected);
+ Q_ASSERT(isConnected);
+}
+
+void ProgressCoordninator::partProgressChanged(double fraction)
+{
+ if (fraction < 0 || fraction > 1) {
+ qWarning() << QString(QLatin1String("The fraction is outside from possible value ")) << QString::number(fraction);
+ return;
+ }
+ double partProgressSize = m_senderPartProgressSizeHash.value(sender(), 0);
+ if (partProgressSize == 0) {
+ qWarning() << QString(QLatin1String("it seems that this sender was not registered in the right way: ")) << sender();
+ return;
+ }
+
+ if (m_undoMode) {
+ //qDebug() << "fraction: " << fraction;
+ double maxSize = m_reachedPercentageBeforeUndo * partProgressSize;
+ double pendingCalculatedPartPercentage = maxSize * fraction;
+
+ double newCurrentCompletePercentage = m_currentBasePercentage - pendingCalculatedPartPercentage + allPendingCalculatedPartPercentages(sender()); //allPendingCalculatedPartPercentages has negative values
+
+ //we can't check this here, because some round issues can make it little bit under 0 or over 100
+ //Q_ASSERT(newCurrentCompletePercentage >= 0);
+ //Q_ASSERT(newCurrentCompletePercentage <= 100);
+ if (newCurrentCompletePercentage < 0) {
+ qDebug() << newCurrentCompletePercentage << " is smaller then 0 - this should happen max once";
+ newCurrentCompletePercentage = 0;
+ }
+ if (newCurrentCompletePercentage > 100) {
+ qDebug() << newCurrentCompletePercentage << " is bigger then 100 - this should happen max once";
+ newCurrentCompletePercentage = 100;
+ }
+ if (qRound(m_currentCompletePercentage) < qRound(newCurrentCompletePercentage)) {
+ qFatal("This should not happen!");
+ }
+
+ m_currentCompletePercentage = newCurrentCompletePercentage;
+ if (fraction == 1) {
+ m_currentBasePercentage = m_currentBasePercentage - pendingCalculatedPartPercentage;
+ m_senderPendingCalculatedPercentageHash.insert(sender(), 0);
+ } else {
+ m_senderPendingCalculatedPercentageHash.insert(sender(), pendingCalculatedPartPercentage);
+ }
+
+ } else { //if (m_undoMode)
+ int availablePercentagePoints = 100 - m_manualAddedPercentage - m_reservedPercentage;
+ double pendingCalculatedPartPercentage = availablePercentagePoints * partProgressSize * fraction;
+ //double checkValue = allPendingCalculatedPartPercentages(sender());
+
+ double newCurrentCompletePercentage = m_manualAddedPercentage +
+ m_currentBasePercentage +
+ pendingCalculatedPartPercentage +
+ allPendingCalculatedPartPercentages(sender());
+
+ //we can't check this here, because some round issues can make it little bit under 0 or over 100
+ //Q_ASSERT(newCurrentCompletePercentage >= 0);
+ //Q_ASSERT(newCurrentCompletePercentage <= 100);
+ if (newCurrentCompletePercentage < 0) {
+ qDebug() << newCurrentCompletePercentage << " is smaller then 0 - this should happen max once";
+ newCurrentCompletePercentage = 0;
+ }
+ if (newCurrentCompletePercentage > 100) {
+ qDebug() << newCurrentCompletePercentage << " is bigger then 100 - this should happen max once";
+ newCurrentCompletePercentage = 100;
+ }
+ if (qRound(m_currentCompletePercentage) > qRound(newCurrentCompletePercentage)) {
+ qFatal("This should not happen!");
+ }
+ m_currentCompletePercentage = newCurrentCompletePercentage;
+
+ if (fraction == 1 || fraction == 0) {
+ m_currentBasePercentage = m_currentBasePercentage + pendingCalculatedPartPercentage;
+ m_senderPendingCalculatedPercentageHash.insert(sender(), 0);
+ } else {
+ m_senderPendingCalculatedPercentageHash.insert(sender(), pendingCalculatedPartPercentage);
+ }
+ } //if (m_undoMode)
+}
+
+
+/*!
+ * Contains the installation progress percentage.
+ */
+int ProgressCoordninator::progressInPercentage() const
+{
+ int currentValue = qRound(m_currentCompletePercentage);
+ Q_ASSERT( currentValue <= 100);
+ Q_ASSERT( currentValue >= 0);
+ return currentValue;
+}
+
+void ProgressCoordninator::disconnectAllSenders()
+{
+ foreach(QPointer<QObject> sender, m_senderPartProgressSizeHash.keys()) {
+ if (!sender.isNull()) {
+ bool isDisconnected = sender->disconnect(this);
+ Q_UNUSED(isDisconnected);
+ Q_ASSERT(isDisconnected);
+ }
+ }
+}
+
+void ProgressCoordninator::setUndoMode()
+{
+ Q_ASSERT(!m_undoMode);
+ m_undoMode = true;
+
+ disconnectAllSenders();
+ m_senderPendingCalculatedPercentageHash.clear();
+
+ m_reachedPercentageBeforeUndo = progressInPercentage();
+ m_currentBasePercentage = m_reachedPercentageBeforeUndo;
+}
+
+void ProgressCoordninator::addManualPercentagePoints(int value)
+{
+ m_manualAddedPercentage = m_manualAddedPercentage + value;
+ if (m_undoMode) {
+ //we don't do other things in the undomode, maybe later if the last percentage point comes to early
+ return;
+ }
+ m_currentCompletePercentage = m_currentCompletePercentage + value;
+ qApp->processEvents(); //makes the result available in the ui
+}
+
+void ProgressCoordninator::addReservePercentagePoints(int value)
+{
+ m_reservedPercentage = m_reservedPercentage + value;
+}
+
+void ProgressCoordninator::setLabelText(const QString &text)
+{
+ if (m_installationLabelText == text)
+ return;
+ m_installationLabelText = text;
+}
+
+/*!
+ * Contains the installation progress label text.
+ */
+QString ProgressCoordninator::labelText() const
+{
+ return m_installationLabelText;
+}
+
+void ProgressCoordninator::emitDetailTextChanged(const QString &text)
+{
+ emit detailTextChanged(text);
+}
+
+void ProgressCoordninator::emitLabelAndDetailTextChanged(const QString &text)
+{
+ emit detailTextChanged(text);
+ m_installationLabelText = QString(text).remove(QLatin1String("\n"));
+ qApp->processEvents(); //makes the result available in the ui
+}
+
+double ProgressCoordninator::allPendingCalculatedPartPercentages(QObject *excludeKeyObject)
+{
+ double result = 0;
+
+ QHash<QPointer<QObject>, double>::iterator it = m_senderPendingCalculatedPercentageHash.begin();
+ while ( it != m_senderPendingCalculatedPercentageHash.end() ) {
+ if (it.key() != excludeKeyObject) {
+ result = result + it.value();
+ }
+ it++;
+ }
+ return result;
+}
diff --git a/installerbuilder/libinstaller/progresscoordinator.h b/installerbuilder/libinstaller/progresscoordinator.h
new file mode 100644
index 000000000..89c7b925a
--- /dev/null
+++ b/installerbuilder/libinstaller/progresscoordinator.h
@@ -0,0 +1,79 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef PROGRESSCOORDNINATOR_H
+#define PROGRESSCOORDNINATOR_H
+
+#include <QObject>
+#include <QHash>
+#include <QPointer>
+
+namespace QInstaller {
+
+class ProgressCoordninator : public QObject
+{
+ Q_OBJECT
+public:
+ static ProgressCoordninator* instance();
+ ~ProgressCoordninator();
+
+ void registerPartProgress(QObject *sender, const char *signal, double partProgressSize);
+
+signals:
+ void detailTextChanged(const QString &text);
+ void detailTextResetNeeded();
+public slots:
+ void reset();
+ int progressInPercentage() const;
+
+ void setUndoMode();
+ void addManualPercentagePoints(int value);
+ void addReservePercentagePoints(int value);
+ void setLabelText(const QString &text);
+ QString labelText() const;
+ void emitDetailTextChanged(const QString &text);
+ void emitLabelAndDetailTextChanged(const QString &text);
+ void partProgressChanged(double fraction);
+
+protected:
+ explicit ProgressCoordninator(QObject *parent);
+private:
+ double allPendingCalculatedPartPercentages(QObject *excludeKeyObject = 0);
+ void disconnectAllSenders();
+
+ QHash<QPointer<QObject>, double> m_senderPendingCalculatedPercentageHash;
+ QHash<QPointer<QObject>, double> m_senderPartProgressSizeHash;
+ QString m_installationLabelText;
+ double m_currentCompletePercentage;
+ double m_currentBasePercentage;
+ int m_manualAddedPercentage;
+ int m_reservedPercentage;
+ bool m_undoMode;
+ double m_reachedPercentageBeforeUndo;
+};
+
+} //namespace QInstaller
+
+#endif //PROGRESSCOORDNINATOR_H
diff --git a/installerbuilder/libinstaller/qinstaller.cpp b/installerbuilder/libinstaller/qinstaller.cpp
new file mode 100644
index 000000000..c41734979
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstaller.cpp
@@ -0,0 +1,3356 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "qinstaller.h"
+#include "qinstallergui.h"
+#include "qinstallerglobal.h"
+#include "qinstallercomponent.h"
+#include "downloadarchivesjob.h"
+#include "getrepositoriesmetainfojob.h"
+#include "adminauthorization.h"
+#include "messageboxhandler.h"
+#include "progresscoordinator.h"
+
+#include "common/installersettings.h"
+#include "common/binaryformat.h"
+#include "common/utils.h"
+
+#include "fsengineclient.h"
+#include "fsengineserver.h"
+
+#include <QtCore/QBuffer>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDateTime>
+#include <QtCore/QDir>
+#include <QtCore/QDirIterator>
+#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QtCore/QHash>
+#include <QtCore/QLocale>
+#include <QtCore/QPointer>
+#include <QtCore/QProcess>
+#include <QtCore/QResource>
+#include <QtCore/QSettings>
+#include <QtCore/QVector>
+#include <QtCore/QTemporaryFile>
+#include <QtCore/QTranslator>
+#include <QtCore/QUrl>
+#include <QtCore/QThread>
+#include <QtCore/QSet>
+#include <QtGui/QDesktopServices>
+#include <QtGui/QMessageBox>
+#include <QtUiTools/QUiLoader>
+#include <QtScript/QScriptEngine>
+#include <QtScript/QScriptContext>
+#include <QtScript/QScriptContextInfo>
+#include <QFuture>
+#include <QFutureWatcher>
+#include <QtConcurrentRun>
+
+#include <KDUpdater/KDUpdater>
+#include <KDUpdater/Application>
+#include <KDUpdater/PackagesInfo>
+
+#include <KDToolsCore/KDSaveFile>
+#include <KDToolsCore/KDSysInfo>
+#include <KDToolsCore/KDSelfRestarter>
+
+#include "common/errors.h"
+#include "common/fileutils.h"
+
+#include <cassert>
+#include <cerrno>
+#include <functional>
+#include <memory>
+#include <algorithm>
+
+#ifdef Q_OS_WIN
+#include "qt_windows.h"
+#endif
+
+using namespace QInstaller;
+
+namespace {
+ enum OperationType {
+ Backup,
+ Perform,
+ Undo
+ };
+
+ static bool runOperation(KDUpdater::UpdateOperation *op, OperationType type) {
+ switch (type)
+ {
+ case(Backup):
+ op->backup();
+ return true;
+ case (Perform):
+ return op->performOperation();
+ case (Undo) :
+ return op->undoOperation();
+ }
+ Q_ASSERT(!"unexpected operation type");
+ return false;
+ }
+
+ template <typename T>
+ void letTheUiRunTillFinished(const QFuture<T>& f) {
+ QFutureWatcher<T> futureWatcher;
+ futureWatcher.setFuture(f);
+ QEventLoop loop;
+ loop.connect(&futureWatcher, SIGNAL(finished()), SLOT(quit()), Qt::QueuedConnection);
+ if (!f.isFinished())
+ loop.exec();
+ }
+
+}
+
+static bool performOperationThreaded(KDUpdater::UpdateOperation *op, OperationType type=Perform)
+{
+ QFuture<bool> future = QtConcurrent::run(runOperation, op, type);
+ letTheUiRunTillFinished(future);
+ return future.result();
+}
+
+static QScriptValue checkArguments(QScriptContext* context, int amin, int amax)
+{
+ if (context->argumentCount() < amin || context->argumentCount() > amax) {
+ if (amin != amax) {
+ return context->throwError(QObject::tr("Invalid arguments: %1 arguments given, %2 to "
+ "%3 expected.").arg(QString::number(context->argumentCount()),
+ QString::number(amin), QString::number(amax)));
+ }
+ return context->throwError(QObject::tr("Invalid arguments: %1 arguments given, %2 expected.")
+ .arg(QString::number(context->argumentCount()), QString::number(amin)));
+ }
+ return QScriptValue();
+}
+
+#ifdef Q_WS_WIN
+static void deferredRename(const QString& oldName, const QString& newName, bool restart = false)
+{
+ QString batchfile;
+
+ QStringList arguments;
+ arguments << QDir::toNativeSeparators(batchfile)
+ << QDir::toNativeSeparators(oldName)
+ << QDir::toNativeSeparators(QFileInfo(oldName).dir().absoluteFilePath(newName));
+
+ {
+ QTemporaryFile f(QDir::temp().absoluteFilePath(QLatin1String("deferredrenameXXXXXX.vbs")));
+ openForWrite(&f, f.fileName());
+ f.setAutoRemove(false);
+
+ batchfile = f.fileName();
+
+ QTextStream batch(&f);
+ batch << "Set fso = WScript.CreateObject(\"Scripting.FileSystemObject\")\n";
+ batch << "Set tmp = WScript.CreateObject(\"WScript.Shell\")\n";
+ batch << QString::fromLatin1("file = \"%1\"\n").arg(arguments[2]);
+ batch << "on error resume next\n";
+
+ batch << "while fso.FileExists(file)\n";
+ batch << " fso.DeleteFile(file)\n";
+ batch << " WScript.Sleep(1000)\n";
+ batch << "wend\n";
+ batch << QString::fromLatin1("fso.MoveFile \"%1\", file\n").arg(arguments[1]);
+ if (restart)
+ batch << QString::fromLatin1("tmp.exec \"%1 --updater\"\n").arg(arguments[2]);
+ batch << "fso.DeleteFile(WScript.ScriptFullName)\n";
+ }
+
+ QProcess::startDetached(QLatin1String("cscript"), QStringList() << QLatin1String("//Nologo")
+ << QDir::toNativeSeparators(batchfile));
+}
+#endif // Q_WS_WIN
+
+/*!
+ Appends \a comp preceded by its dependencies to \a components. Makes sure components contains
+ every component only once.
+ \internal
+*/
+static void appendComponentAndMissingDependencies(QList<Component*>& components, Component* comp)
+{
+ if (comp == 0)
+ return;
+
+ const QList<Component*> deps = comp->installer()->missingDependencies(comp);
+ for (QList<Component*>::const_iterator it = deps.begin(); it != deps.end(); ++it)
+ appendComponentAndMissingDependencies(components, *it);
+ if (!components.contains(comp))
+ components.push_back(comp);
+}
+
+/*!
+ Scriptable version of Installer::componentByName(QString).
+ \sa Installer::componentByName
+ */
+QScriptValue QInstaller::qInstallerComponentByName(QScriptContext* context, QScriptEngine* engine)
+{
+ const QScriptValue check = checkArguments(context, 1, 1);
+ if (check.isError())
+ return check;
+
+ // well... this is our "this" pointer
+ Installer* const installer = dynamic_cast< Installer* >(engine->globalObject()
+ .property(QLatin1String("installer")).toQObject());
+
+ const QString name = context->argument(0).toString();
+ Component* const c = installer->componentByName(name);
+ return engine->newQObject(c);
+}
+
+QScriptValue QInstaller::qDesktopServicesOpenUrl(QScriptContext* context, QScriptEngine* engine)
+{
+ Q_UNUSED(engine);
+ const QScriptValue check = checkArguments(context, 1, 1);
+ if (check.isError())
+ return check;
+ const QString url = context->argument(0).toString();
+ return QDesktopServices::openUrl(QUrl(url));
+}
+
+QScriptValue QInstaller::qDesktopServicesDisplayName(QScriptContext* context, QScriptEngine* engine)
+{
+ Q_UNUSED(engine);
+ const QScriptValue check = checkArguments(context, 1, 1);
+ if (check.isError())
+ return check;
+ const QDesktopServices::StandardLocation location =
+ static_cast< QDesktopServices::StandardLocation >(context->argument(0).toInt32());
+ return QDesktopServices::displayName(location);
+}
+
+QScriptValue QInstaller::qDesktopServicesStorageLocation(QScriptContext* context, QScriptEngine* engine)
+{
+ Q_UNUSED(engine);
+ const QScriptValue check = checkArguments(context, 1, 1);
+ if (check.isError())
+ return check;
+ const QDesktopServices::StandardLocation location =
+ static_cast< QDesktopServices::StandardLocation >(context->argument(0).toInt32());
+ return QDesktopServices::storageLocation(location);
+}
+
+QString QInstaller::uncaughtExceptionString(QScriptEngine *scriptEngine/*, const QString &context*/)
+{
+ //QString errorString(QLatin1String("%1 %2\n%3"));
+ QString errorString(QLatin1String("\t\t%1\n%2"));
+ //if (!context.isEmpty())
+ // errorString.prepend(context + QLatin1String(": "));
+
+ //usually the linenumber is in the backtrace
+ errorString = errorString.arg(/*QString::number(scriptEngine->uncaughtExceptionLineNumber()),*/
+ scriptEngine->uncaughtException().toString(),
+ scriptEngine->uncaughtExceptionBacktrace().join(QLatin1String("\n")));
+ return errorString;
+}
+
+
+/*!
+ \class QInstaller::Installer
+ Installer forms the core of the installation and uninstallation system.
+ */
+
+/*!
+ \enum QInstaller::Installer::WizardPage
+ WizardPage is used to number the different pages known to the Installer GUI.
+ */
+
+/*!
+ \var QInstaller::Installer::Introduction
+ Introduction page.
+ */
+
+/*!
+ \var QInstaller::Installer::LicenseCheck
+ License check page
+ */
+/*!
+ \var QInstaller::Installer::TargetDirectory
+ Target directory selection page
+ */
+/*!
+ \var QInstaller::Installer::ComponentSelection
+ %Component selection page
+ */
+/*!
+ \var QInstaller::Installer::StartMenuSelection
+ Start menu directory selection page - Microsoft Windows only
+ */
+/*!
+ \var QInstaller::Installer::ReadyForInstallation
+ "Ready for Installation" page
+ */
+/*!
+ \var QInstaller::Installer::PerformInstallation
+ Page shown while performing the installation
+ */
+/*!
+ \var QInstaller::Installer::InstallationFinished
+ Page shown when the installation was finished
+ */
+/*!
+ \var QInstaller::Installer::End
+ Non-existing page - this value has to be used if you want to insert a page after \a InstallationFinished
+ */
+
+/*!
+ Initializes the created FSEngineClientHandler instance \a handler.
+ \internal
+ */
+static void initEngineHandler(FSEngineClientHandler* handler)
+{
+#ifdef FSENGINE_TCP
+ const int port = 30000 + qrand() % 1000;
+ handler->init(port);
+ handler->setStartServerCommand(qApp->applicationFilePath(), QStringList()
+ << QLatin1String("--startserver") << QString::number(port) << handler->authorizationKey(),
+ true);
+#else
+ const QString name = QInstaller::generateTemporaryFileName();
+ handler->init(name);
+ handler->setStartServerCommand(qApp->applicationFilePath(), QStringList()
+ << QLatin1String("--startserver") << name << handler->authorizationKey(), true);
+#endif
+}
+
+
+
+/*!
+ Creates and initializes a FSEngineClientHandler -> makes us get admin rights for QFile
+ operations.
+ \internal
+ */
+static FSEngineClientHandler* createEngineClientHandler()
+{
+ static FSEngineClientHandler* clientHandlerInstance = 0;
+ if (clientHandlerInstance == 0)
+ {
+ clientHandlerInstance = new FSEngineClientHandler;
+ initEngineHandler(clientHandlerInstance);
+ }
+ return clientHandlerInstance;
+}
+
+
+// -- Installer::Private
+
+
+class QInstaller::Installer::Private : public QObject
+{
+ Q_OBJECT;
+
+private:
+ Installer* const q;
+
+public:
+ explicit Private(Installer *q, qint64 magicmaker,
+ QVector<KDUpdater::UpdateOperation*> performedOperations);
+ ~Private();
+
+ void initialize();
+
+ bool statusCanceledOrFailed() const;
+ void setStatus(Installer::Status);
+
+ void writeUninstaller(QVector<KDUpdater::UpdateOperation*> performedOperations);
+ QString targetDir() const { return q->value(QLatin1String("TargetDir")); }
+
+ QString componentsXmlPath() const
+ {
+ return QDir::toNativeSeparators(QDir(QDir::cleanPath(targetDir()))
+ .absoluteFilePath(QLatin1String("components.xml")));
+ }
+
+ QString localComponentsXmlPath() const
+ {
+ const QString &appDirPath = QCoreApplication::applicationDirPath();
+ if (QFileInfo(appDirPath + QLatin1String("/../..")).isBundle()) {
+ return QDir::toNativeSeparators(QFileInfo(QDir::cleanPath(appDirPath
+ + QLatin1String("/../../../components.xml"))).absoluteFilePath());
+ }
+ return componentsXmlPath();
+ }
+
+ void runInstaller();
+ void runUninstaller();
+ void runPackageUpdater();
+ void deleteUninstaller();
+ QString uninstallerName() const;
+ QString replaceVariables(const QString &str) const;
+ QByteArray replaceVariables(const QByteArray &str) const;
+ QString registerPath() const;
+ void registerInstaller();
+ void unregisterInstaller();
+ QString installerBinaryPath() const;
+ bool isInstaller() const;
+ bool isUninstaller() const;
+ bool isPackageManager() const;
+ Installer *installer() const { return q; }
+ KDUpdater::UpdateOperation* createOwnedOperation(const QString& type);
+ void readUninstallerIniFile(const QString& targetDir);
+ void stopProcessesForUpdates(const QList<Component*>& components);
+ int countProgressOperations(const QList<Component*>& components);
+ int countProgressOperations(const QList<KDUpdater::UpdateOperation*>& operations);
+ void connectOperationToInstaller(KDUpdater::UpdateOperation* const operation,
+ double progressOperationPartSize);
+ void registerPathesForUninstallation(const QList<QPair<QString, bool> > &pathesForUninstallation,
+ const QString& componentName);
+
+ void addPerformed(KDUpdater::UpdateOperation* op) {
+ m_performedOperationsCurrentSession.push_back(op);
+ }
+
+ void commitSessionOperations() {
+ m_performedOperationsOld += m_performedOperationsCurrentSession;
+ m_performedOperationsCurrentSession.clear();
+ }
+
+signals:
+ void installationStarted();
+ void installationFinished();
+ void uninstallationStarted();
+ void uninstallationFinished();
+
+public:
+ TempDirDeleter tempDirDeleter;
+
+ FSEngineClientHandler* const engineClientHandler;
+
+ QHash<QString, QString> m_vars;
+ QHash<QString, bool> m_sharedFlags;
+ Installer::Status m_status;
+
+ bool packageManagingMode;
+ bool m_completeUninstall;
+
+ qint64 m_firstComponentStart;
+ qint64 m_componentsCount;
+ qint64 m_componentOffsetTableStart;
+
+ qint64 m_firstComponentDictStart;
+ qint64 m_componentsDictCount;
+ qint64 m_componentDictOffsetTableStart;
+
+ qint64 m_globalDictOffset;
+ qint64 m_magicInstallerMarker;
+
+ KDUpdater::Application * m_app;
+
+ // Owned. Indexed by component name
+ QList<Component*> m_components;
+ QHash<QString, Component*> m_componentHash;
+
+ QList<Component*> m_updaterComponents;
+ QList<Component*> m_packageManagerComponents;
+
+ QList<KDUpdater::UpdateOperation*> ownedOperations;
+ QVector<KDUpdater::UpdateOperation*> m_performedOperationsOld;
+ QVector<KDUpdater::UpdateOperation*> m_performedOperationsCurrentSession;
+ InstallerSettings m_settings;
+ QString installerBaseBinaryUnreplaced;
+ bool linearComponentList;
+ bool m_launchedAsRoot;
+ int m_silentRetries;
+ bool m_forceRestart;
+ bool m_needToWriteUninstaller;
+ bool m_testChecksum;
+};
+
+Installer::Private::Private(Installer *q, qint64 magicmaker,
+ QVector<KDUpdater::UpdateOperation*> performedOperations)
+ : q(q),
+ engineClientHandler(createEngineClientHandler()),
+ m_status(Installer::InstallerUnfinished),
+ packageManagingMode(false),
+ m_completeUninstall(false),
+ m_magicInstallerMarker(magicmaker),//? magicmaker : MagicInstallerMarker),
+ m_performedOperationsOld(performedOperations),
+ linearComponentList(false),
+ m_launchedAsRoot(AdminAuthorization::hasAdminRights()),
+ m_silentRetries(3),
+ m_forceRestart (false),
+ m_needToWriteUninstaller(false),
+ m_testChecksum(false)
+{
+ connect(this, SIGNAL(installationStarted()), q, SIGNAL(installationStarted()));
+ connect(this, SIGNAL(installationFinished()), q, SIGNAL(installationFinished()));
+ connect(this, SIGNAL(uninstallationStarted()), q, SIGNAL(uninstallationStarted()));
+ connect(this, SIGNAL(uninstallationFinished()), q, SIGNAL(uninstallationFinished()));
+ verbose() << "has admin rights ? : " << engineClientHandler->isActive() << std::endl;
+}
+
+Installer::Private::~Private()
+{
+ qDeleteAll(m_components);
+ qDeleteAll(m_updaterComponents);
+ m_components.clear();
+ qDeleteAll(m_performedOperationsOld);
+ qDeleteAll(m_performedOperationsCurrentSession);
+}
+
+KDUpdater::Application& Installer::updaterApplication() const
+{
+ return *d->m_app;
+}
+
+void Installer::setUpdaterApplication(KDUpdater::Application *app)
+{
+ d->m_app = app;
+}
+
+void Installer::writeUninstaller()
+{
+ if (d->m_needToWriteUninstaller) {
+ bool error = false;
+ QString errorMsg;
+ try {
+ d->writeUninstaller(d->m_performedOperationsOld + d->m_performedOperationsCurrentSession);
+
+ bool gainedAdminRights = false;
+ QTemporaryFile tempAdminFile(d->targetDir()
+ + QLatin1String("/testjsfdjlkdsjflkdsjfldsjlfds") + QString::number(qrand() % 1000));
+ if (!tempAdminFile.open() || !tempAdminFile.isWritable()) {
+ gainAdminRights();
+ gainedAdminRights = true;
+ }
+ d->m_app->packagesInfo()->writeToDisk();
+ if (gainedAdminRights)
+ dropAdminRights();
+ d->m_needToWriteUninstaller = false;
+ } catch (const Error& e) {
+ error = true;
+ errorMsg = e.message();
+ }
+
+ if (error) {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("WriteError"), tr("Error writing Uninstaller"), errorMsg,
+ QMessageBox::Ok, QMessageBox::Ok);
+ }
+ }
+}
+
+void Installer::reset(const QHash<QString, QString> &params)
+{
+ d->m_completeUninstall = false;
+ d->m_forceRestart = false;
+ d->m_status = Installer::InstallerUnfinished;
+ d->installerBaseBinaryUnreplaced.clear();
+ d->m_vars.clear();
+ d->m_vars = params;
+ d->initialize();
+}
+
+void Installer::Private::initialize()
+{
+ try {
+ m_settings = InstallerSettings::fromFileAndPrefix(
+ QLatin1String(":/metadata/installer-config/config.xml"),
+ QLatin1String(":/metadata/installer-config/"));
+ } catch (const Error &e) {
+ qCritical("Could not parse Config: %s", qPrintable(e.message()));
+ //TODO try better error handling
+ return;
+ }
+
+ // first set some common variables that may used e.g. as placeholder
+ // in some of the settings variables or in a script or...
+ m_vars.insert(QLatin1String("rootDir"), QDir::rootPath());
+ m_vars.insert(QLatin1String("homeDir"), QDir::homePath());
+
+#ifdef Q_WS_WIN
+ m_vars.insert(QLatin1String("os"), QLatin1String("win"));
+#elif defined(Q_WS_MAC)
+ m_vars.insert(QLatin1String("os"), QLatin1String("mac"));
+#elif defined(Q_WS_X11)
+ m_vars.insert(QLatin1String("os"), QLatin1String("x11"));
+#elif defined(Q_WS_QWS)
+ m_vars.insert(QLatin1String("os"), QLatin1String("Qtopia"));
+#else
+ //TODO add more platforms as needed...
+#endif
+
+ // fill the variables defined in the settings
+ m_vars.insert(QLatin1String("ProductName"), m_settings.applicationName());
+ m_vars.insert(QLatin1String("ProductVersion"), m_settings.applicationVersion());
+ m_vars.insert(QLatin1String("Title"), m_settings.title());
+ m_vars.insert(QLatin1String("MaintenanceTitle"), m_settings.maintenanceTitle());
+ m_vars.insert(QLatin1String("Publisher"), m_settings.publisher());
+ m_vars.insert(QLatin1String("Url"), m_settings.url());
+ m_vars.insert(QLatin1String("StartMenuDir"), m_settings.startMenuDir());
+
+ m_vars.insert(QLatin1String("LogoPixmap"), m_settings.logo());
+ m_vars.insert(QLatin1String("LogoSmallPixmap"), m_settings.logoSmall());
+ m_vars.insert(QLatin1String("WatermarkPixmap"), m_settings.watermark());
+
+ m_vars.insert(QLatin1String("RunProgram"), replaceVariables(m_settings.runProgram()));
+ const QString desc = m_settings.runProgramDescription();
+ if (!desc.isEmpty())
+ m_vars.insert(QLatin1String("RunProgramDescription"), desc);
+#ifdef Q_WS_X11
+ if (m_launchedAsRoot)
+ m_vars.insert(QLatin1String("TargetDir"), replaceVariables(m_settings.adminTargetDir()));
+ else
+#endif
+ m_vars.insert(QLatin1String("TargetDir"), replaceVariables(m_settings.targetDir()));
+
+ QSettings creatorSettings(QSettings::IniFormat, QSettings::UserScope, QLatin1String("Nokia"),
+ QLatin1String("QtCreator"));
+ QFileInfo info(creatorSettings.fileName());
+ if (info.exists())
+ m_vars.insert(QLatin1String("QtCreatorSettingsFile"), info.absoluteFilePath());
+
+ if (!q->isInstaller()) {
+#ifdef Q_WS_MAC
+ readUninstallerIniFile(QCoreApplication::applicationDirPath() + QLatin1String("/../../.."));
+#else
+ readUninstallerIniFile(QCoreApplication::applicationDirPath());
+#endif
+ }
+
+ connect(this, SIGNAL(installationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
+ connect(this, SIGNAL(uninstallationStarted()), ProgressCoordninator::instance(), SLOT(reset()));
+}
+
+/*!
+ * Sets the uninstallation to be \a complete. If \a complete is false, only components deselected
+ * by the user will be uninstalled.
+ * This option applies only on uninstallation.
+ */
+void Installer::setCompleteUninstallation(bool complete)
+{
+ d->m_completeUninstall = complete;
+ d->packageManagingMode = !d->m_completeUninstall;
+}
+
+QString Installer::Private::installerBinaryPath() const
+{
+ return qApp->applicationFilePath();
+}
+
+bool Installer::Private::isInstaller() const
+{
+ return m_magicInstallerMarker == MagicInstallerMarker;
+}
+
+bool Installer::Private::isUninstaller() const
+{
+ return m_magicInstallerMarker == MagicUninstallerMarker && !packageManagingMode;
+}
+
+bool Installer::Private::isPackageManager() const
+{
+ return m_magicInstallerMarker == MagicUninstallerMarker && packageManagingMode;
+}
+
+bool Installer::Private::statusCanceledOrFailed() const
+{
+ return m_status == Installer::InstallerCanceledByUser
+ || m_status == Installer::InstallerFailed;
+}
+
+void Installer::Private::setStatus(Installer::Status status)
+{
+ if (m_status != status) {
+ m_status = status;
+ emit q->statusChanged(m_status);
+ }
+}
+
+QString Installer::Private::replaceVariables(const QString &str) const
+{
+ static const QChar at = QLatin1Char('@');
+ QString res;
+ int pos = 0;
+ while (true) {
+ const int pos1 = str.indexOf(at, pos);
+ if (pos1 == -1)
+ break;
+ const int pos2 = str.indexOf(at, pos1 + 1);
+ if (pos2 == -1)
+ break;
+ res += str.mid(pos, pos1 - pos);
+ const QString name = str.mid(pos1 + 1, pos2 - pos1 - 1);
+ res += q->value(name);
+ pos = pos2 + 1;
+ }
+ res += str.mid(pos);
+ return res;
+}
+
+QByteArray Installer::Private::replaceVariables(const QByteArray &ba) const
+{
+ static const QChar at = QLatin1Char('@');
+ QByteArray res;
+ int pos = 0;
+ while (true) {
+ const int pos1 = ba.indexOf(at, pos);
+ if (pos1 == -1)
+ break;
+ const int pos2 = ba.indexOf(at, pos1 + 1);
+ if (pos2 == -1)
+ break;
+ res += ba.mid(pos, pos1 - pos);
+ const QString name = QString::fromLocal8Bit(ba.mid(pos1 + 1, pos2 - pos1 - 1));
+ res += q->value(name).toLocal8Bit();
+ pos = pos2 + 1;
+ }
+ res += ba.mid(pos);
+ return res;
+}
+
+/*!
+ Creates an update operation owned by the installer, not by any component.
+ \internal
+ */
+KDUpdater::UpdateOperation* Installer::Private::createOwnedOperation(const QString &type)
+{
+ KDUpdater::UpdateOperation* const op = KDUpdater::UpdateOperationFactory::instance().create(type);
+ ownedOperations.push_back(op);
+ return op;
+}
+
+QString Installer::Private::uninstallerName() const
+{
+ QString filename = m_settings.uninstallerName();
+#if defined(Q_WS_MAC)
+ if (QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle())
+ filename += QLatin1String(".app/Contents/MacOS/") + filename;
+#elif defined(Q_OS_WIN)
+ filename += QLatin1String(".exe");
+#endif
+ return QString::fromLatin1("%1/%2").arg(targetDir()).arg(filename);
+}
+
+void Installer::Private::readUninstallerIniFile(const QString &targetDir)
+{
+ const QString iniPath = targetDir + QLatin1Char('/') + m_settings.uninstallerIniFile();
+ QSettings cfg(iniPath, QSettings::IniFormat);
+ const QVariantHash vars = cfg.value(QLatin1String("Variables")).toHash();
+ QHash<QString, QVariant>::ConstIterator it = vars.constBegin();
+ while (it != vars.constEnd()) {
+ m_vars.insert(it.key(), it.value().toString());
+ ++it;
+ }
+}
+
+/*!
+ Copied from QInstaller with some adjustments
+ Return true, if a process with \a name is running. On Windows, the comparision is case-insensitive.
+*/
+static bool isProcessRunning(const QString& name, const QList<KDSysInfo::ProcessInfo> &processes)
+{
+ QList<KDSysInfo::ProcessInfo>::const_iterator it;
+ for (it = processes.constBegin(); it != processes.constEnd(); ++it) {
+ if (it->name.isEmpty())
+ continue;
+
+#ifndef Q_WS_WIN
+ if (it->name == name)
+ return true;
+ const QFileInfo fi(it->name);
+ if (fi.fileName() == name || fi.baseName() == name)
+ return true;
+#else
+ if (it->name.toLower() == name.toLower())
+ return true;
+ if (it->name.toLower() == QDir::toNativeSeparators(name.toLower()))
+ return true;
+ const QFileInfo fi(it->name);
+ if (fi.fileName().toLower() == name.toLower() || fi.baseName().toLower() == name.toLower())
+ return true;
+#endif
+ }
+ return false;
+}
+
+static QStringList checkRunningProcessesFromList(const QStringList &processList)
+{
+ const QList<KDSysInfo::ProcessInfo> allProcesses = KDSysInfo::runningProcesses();
+ QStringList stillRunningProcesses;
+ foreach (const QString &process, processList) {
+ if (!process.isEmpty() && isProcessRunning(process, allProcesses)) {
+ stillRunningProcesses.append(process);
+ }
+ }
+ return stillRunningProcesses;
+}
+
+void Installer::Private::stopProcessesForUpdates(const QList<Component*> &components)
+{
+ QStringList processList;
+ foreach (const Component* const i, components)
+ processList << q->replaceVariables(i->stopProcessForUpdateRequests());
+
+ qSort(processList);
+ processList.erase(std::unique(processList.begin(), processList.end()), processList.end());
+ if (processList.isEmpty())
+ return;
+
+ while (true) {
+ const QStringList processes = checkRunningProcessesFromList(processList);
+ if (processes.isEmpty())
+ return;
+
+ const QMessageBox::StandardButton button =
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("stopProcessesForUpdates"), tr("Stop Processes"), tr("These processes "
+ "should be stopped to continue:\n\n%1").arg(QDir::toNativeSeparators(processes
+ .join(QLatin1String("\n")))), QMessageBox::Retry | QMessageBox::Ignore
+ | QMessageBox::Cancel, QMessageBox::Retry);
+ if (button == QMessageBox::Ignore)
+ return;
+ if (button == QMessageBox::Cancel) {
+ q->setCanceled();
+ throw Error(tr("Installation canceled by user"));
+ }
+ }
+}
+
+int Installer::Private::countProgressOperations(const QList<KDUpdater::UpdateOperation*> &operations)
+{
+ int operationCount = 0;
+ QList<KDUpdater::UpdateOperation*>::const_iterator oIt;
+ for (oIt = operations.constBegin(); oIt != operations.constEnd(); oIt++) {
+ KDUpdater::UpdateOperation* const operation = *oIt;
+ QObject* const operationObject = dynamic_cast< QObject* >(operation);
+ if (operationObject != 0) {
+ const QMetaObject* const mo = operationObject->metaObject();
+ if (mo->indexOfSignal(QMetaObject::normalizedSignature("progressChanged(double)")) > -1)
+ operationCount++;
+ }
+ }
+ return operationCount;
+}
+
+int Installer::Private::countProgressOperations(const QList<Component*> &components)
+{
+ int operationCount = 0;
+ for (QList<Component*>::const_iterator It = components.begin(); It != components.end(); ++It)
+ operationCount = operationCount + countProgressOperations((*It)->operations());
+
+ return operationCount;
+}
+
+void Installer::Private::connectOperationToInstaller(KDUpdater::UpdateOperation* const operation,
+ double progressOperationPartSize)
+{
+ Q_ASSERT(progressOperationPartSize);
+ QObject* const operationObject = dynamic_cast< QObject* >(operation);
+ if (operationObject != 0) {
+ const QMetaObject* const mo = operationObject->metaObject();
+ if (mo->indexOfSignal(QMetaObject::normalizedSignature("outputTextChanged(QString)")) > -1) {
+ connect(operationObject, SIGNAL(outputTextChanged(QString)),
+ ProgressCoordninator::instance(), SLOT(emitDetailTextChanged(QString)));
+ }
+
+ if (mo->indexOfSlot(QMetaObject::normalizedSignature("cancelOperation()")) > -1)
+ connect(q, SIGNAL(installationInterrupted()), operationObject, SLOT(cancelOperation()));
+
+ if (mo->indexOfSignal(QMetaObject::normalizedSignature("progressChanged(double)")) > -1) {
+ ProgressCoordninator::instance()->registerPartProgress(operationObject,
+ SIGNAL(progressChanged(double)), progressOperationPartSize);
+ }
+ }
+}
+
+/*!
+ This creates fake operations which remove stuff which was registered for uninstallation afterwards
+*/
+void Installer::Private::registerPathesForUninstallation(
+ const QList<QPair<QString, bool> > &pathesForUninstallation, const QString &componentName)
+{
+ if (pathesForUninstallation.isEmpty())
+ return;
+
+ QList<QPair<QString, bool> >::const_iterator it;
+ for (it = pathesForUninstallation.begin(); it != pathesForUninstallation.end(); ++it) {
+ const QString path = replaceVariables(it->first);
+ const bool wipe = it->second;
+ const QFileInfo fi(path);
+
+ // create a copy operation with the file as target -> it will get deleted on undo
+ KDUpdater::UpdateOperation* const op = createOwnedOperation(QLatin1String(fi.isDir()
+ ? "Mkdir" : "Copy"));
+ if (fi.isDir()) {
+ op->setValue(QLatin1String("createddir"), fi.absoluteFilePath());
+ op->setValue(QLatin1String("forceremoval"), wipe ? QLatin1String("true")
+ : QLatin1String("false"));
+ }
+ op->setArguments(fi.isDir() ? QStringList() << fi.absoluteFilePath()
+ : QStringList() << QString() << fi.absoluteFilePath());
+ op->setValue(QLatin1String("component"), componentName);
+ addPerformed(op);
+
+ // get recursive afterwards
+ if (fi.isDir() && !wipe) {
+ QDirIterator dirIt(path, QDir::Hidden | QDir::AllEntries | QDir::System
+ | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
+ while (dirIt.hasNext()) {
+ dirIt.next();
+ const QFileInfo fi = dirIt.fileInfo();
+ if (fi.isDir()) {
+ // create an mkdir operation with the dir as target -> it will get deleted on undo
+ KDUpdater::UpdateOperation* const op = createOwnedOperation(QLatin1String("Mkdir"));
+ op->setArguments(QStringList() << fi.absoluteFilePath());
+ op->setValue(QLatin1String("createddir"), fi.absoluteFilePath());
+ op->setValue(QLatin1String("component"), componentName);
+ addPerformed(op);
+ } else {
+ // create a copy operation with the file as target -> it will get deleted on undo
+ KDUpdater::UpdateOperation* const op = createOwnedOperation(QLatin1String("Copy"));
+ op->setArguments(QStringList() << QString() << fi.absoluteFilePath());
+ op->setValue(QLatin1String("component"), componentName);
+ addPerformed(op);
+ }
+ }
+ }
+ }
+}
+
+void Installer::Private::writeUninstaller(QVector<KDUpdater::UpdateOperation*> performedOperations)
+{
+ bool gainedAdminRights = false;
+ QTemporaryFile tempAdminFile(targetDir() + QString::fromLatin1("/testjsfdjlkdsjflkdsjfldsjlfds")
+ + QString::number(qrand() % 1000));
+ if (!tempAdminFile.open() || !tempAdminFile.isWritable()) {
+ q->gainAdminRights();
+ gainedAdminRights = true;
+ }
+
+ verbose() << "QInstaller::Installer::Private::writeUninstaller uninstaller=" << uninstallerName()
+ << std::endl;
+
+ // create the directory containing the uninstaller (like a bundle structor, on Mac...)
+ KDUpdater::UpdateOperation* op = createOwnedOperation(QLatin1String("Mkdir"));
+ op->setArguments(QStringList() << QFileInfo(uninstallerName()).path());
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+ performedOperations.push_back(op);
+
+ {
+ // write current state (variables) to the uninstaller ini file
+ const QString iniPath = targetDir() + QLatin1Char('/') + m_settings.uninstallerIniFile();
+ QSettings cfg(iniPath, QSettings::IniFormat);
+ QVariantHash vars;
+ QHash<QString, QString>::ConstIterator it = m_vars.constBegin();
+ while (it != m_vars.constEnd()) {
+ const QString &key = it.key();
+ if (key != QLatin1String("RunProgramDescription") && key != QLatin1String("RunProgram"))
+ vars.insert(key, it.value());
+ ++it;
+ }
+ cfg.setValue(QLatin1String("Variables"), vars);
+ cfg.sync();
+ if (cfg.status() != QSettings::NoError) {
+ const QString reason = cfg.status() == QSettings::AccessError ? tr("Access error")
+ : tr("Format error");
+ throw Error(tr("Could not write installer configuration to %1: %2").arg(iniPath, reason));
+ }
+ }
+
+#ifdef Q_WS_MAC
+ // if it is a bundle, we need some stuff in it...
+ if (isInstaller()
+ && QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle()) {
+ op = createOwnedOperation(QLatin1String("Copy"));
+ op->setArguments(QStringList() << (QCoreApplication::applicationDirPath()
+ + QLatin1String("/../PkgInfo")) << (QFileInfo(uninstallerName()).path()
+ + QLatin1String("/../PkgInfo")));
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+
+ op = createOwnedOperation(QLatin1String("Copy"));
+ op->setArguments(QStringList() << (QCoreApplication::applicationDirPath()
+ + QLatin1String("/../Info.plist")) << (QFileInfo(uninstallerName()).path()
+ + QLatin1String("/../Info.plist")));
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+
+ verbose() << "Checking for qt_menu.nib" << std::endl;
+ QString sourceDirName = QCoreApplication::applicationDirPath()
+ + QLatin1String("/../Resources/qt_menu.nib");
+ if (QFileInfo(sourceDirName).exists()) {
+ verbose() << "qt_menu.nib has been found. Isn't it great?" << std::endl;
+ QString targetDirName = QFileInfo(QFileInfo(uninstallerName()).path()
+ + QLatin1String("/../Resources/qt_menu.nib")).absoluteFilePath();
+
+ // IFW has been built with a static Cocoa Qt. The app bundle must contain the qt_menu.nib.
+ // ### use the CopyDirectory operation in 1.1
+ op = createOwnedOperation(QLatin1String("Mkdir"));
+ op->setArguments(QStringList() << targetDirName);
+ if (!op->performOperation()) {
+ verbose() << "ERROR in Mkdir operation: " << op->errorString() << std::endl;
+ }
+
+ QDir sourceDir(sourceDirName);
+ foreach (const QString &filename, sourceDir.entryList(QDir::Files)) {
+ QString src = sourceDirName + QLatin1String("/") + filename;
+ QString dst = targetDirName + QLatin1String("/") + filename;
+ op = createOwnedOperation(QLatin1String("Copy"));
+ op->setArguments(QStringList() << src << dst);
+ if (!op->performOperation())
+ verbose() << "ERROR in Copy operation: copy " << src << " to " << dst << std::endl
+ << "error message: " << op->errorString() << std::endl;
+ }
+ }
+
+ // patch the Info.plist while copying it
+ QFile sourcePlist(QCoreApplication::applicationDirPath() + QLatin1String("/../Info.plist"));
+ openForRead(&sourcePlist, sourcePlist.fileName());
+ QFile targetPlist(QFileInfo(uninstallerName()).path() + QLatin1String("/../Info.plist"));
+ openForWrite(&targetPlist, targetPlist.fileName());
+
+ QTextStream in(&sourcePlist);
+ QTextStream out(&targetPlist);
+
+ while (!in.atEnd())
+ {
+ QString line = in.readLine();
+ line = line.replace(QLatin1String("<string>")
+ + QFileInfo(QCoreApplication::applicationFilePath()).baseName()
+ + QLatin1String("</string>"), QLatin1String("<string>")
+ + QFileInfo(uninstallerName()).baseName() + QLatin1String("</string>"));
+ out << line << endl;
+ }
+
+ op = createOwnedOperation(QLatin1String("Mkdir"));
+ op->setArguments(QStringList() << (QFileInfo(QFileInfo(uninstallerName()).path()).path()
+ + QLatin1String("/Resources")));
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+
+ const QString icon = QFileInfo(QCoreApplication::applicationFilePath()).baseName()
+ + QLatin1String(".icns");
+ op = createOwnedOperation(QLatin1String("Copy"));
+ op->setArguments(QStringList() << (QCoreApplication::applicationDirPath()
+ + QLatin1String("/../Resources/") + icon) << (QFileInfo(uninstallerName()).path()
+ + QLatin1String("/../Resources/") + icon));
+ performOperationThreaded(op, Backup);
+ performOperationThreaded(op);
+
+ // finally, copy everything within Frameworks and plugins
+ if (QDir(QCoreApplication::applicationDirPath() + QLatin1String("/../Frameworks")).exists()) {
+ copyDirectoryContents(QCoreApplication::applicationDirPath()
+ + QLatin1String("/../Frameworks"), QFileInfo(uninstallerName()).path()
+ + QLatin1String("/../Frameworks"));
+ }
+
+ if (QDir(QCoreApplication::applicationDirPath() + QLatin1String("/../plugins")).exists()) {
+ copyDirectoryContents(QCoreApplication::applicationDirPath()
+ + QLatin1String("/../plugins"), QFileInfo(uninstallerName()).path()
+ + QLatin1String("/../plugins"));
+ }
+ }
+#endif
+
+ QFile in;
+ if (isInstaller() || isUninstaller() || isPackageManager())
+ in.setFileName(installerBinaryPath());
+ else
+ in.setFileName(uninstallerName()); // we're the updater
+
+ const QString installerBaseBinary = q->replaceVariables(installerBaseBinaryUnreplaced);
+ if (!installerBaseBinary.isEmpty())
+ verbose() << "Got a replacement installer base binary: " << installerBaseBinary << std::endl;
+
+ const bool haveSeparateExec = QFile::exists(installerBaseBinary) && !installerBaseBinary.isEmpty();
+ verbose() << "Need to restart after exit: " << haveSeparateExec << " "
+ << qPrintable(installerBaseBinary) << std::endl;
+
+#ifdef Q_WS_WIN
+ KDSaveFile out(uninstallerName() + QLatin1String(".org"));
+#else
+ KDSaveFile out(uninstallerName());
+#endif
+
+ try {
+ ifVerbose("CREATING UNINSTALLER " << performedOperations.size());
+
+ QFile* execIn = &in;
+ qint64 execSize = 0;
+ QFile ibbIn;
+ if (haveSeparateExec) {
+ ibbIn.setFileName(installerBaseBinary);
+ openForRead(&ibbIn, ibbIn.fileName());
+ execIn = &ibbIn;
+ execSize = ibbIn.size();
+ }
+
+ openForRead(&in, in.fileName());
+ openForWrite(&out, out.fileName());
+
+ const qint64 magicCookiePos = findMagicCookie(&in);
+ if (magicCookiePos < 0) {
+ throw Error(QObject::tr("Can not find the magic cookie in file %1. Are you sure this "
+ "is a valid installer?").arg(installerBinaryPath()));
+ }
+
+ if (!in.seek(magicCookiePos - 7 * sizeof(qint64))) {
+ throw Error(QObject::tr("Failed to seek in file %1: %2").arg(installerBinaryPath(),
+ in.errorString()));
+ }
+
+ qint64 resourceStart = retrieveInt64(&in);
+ const qint64 resourceLength = retrieveInt64(&in);
+ Q_ASSERT(resourceLength >= 0);
+ const qint64 _operationsStart = retrieveInt64(&in);
+ Q_UNUSED(_operationsStart);
+ Q_ASSERT(_operationsStart >= 0);
+ const qint64 _operationsLength = retrieveInt64(&in);
+ Q_UNUSED(_operationsLength);
+ Q_ASSERT(_operationsLength >= 0);
+ const qint64 count = retrieveInt64(&in); // atm always "1"
+ Q_ASSERT(count == 1); // we have just 1 resource atm
+ const qint64 dataBlockSize = retrieveInt64(&in);
+ const qint64 dataBlockStart = magicCookiePos + sizeof(qint64) - dataBlockSize;
+ resourceStart += dataBlockStart;
+ if (!haveSeparateExec)
+ execSize = dataBlockStart;
+
+ // consider size difference between old and new installerbase executable (if updated)
+ const qint64 newResourceStart = execSize;
+ const qint64 magicmarker = retrieveInt64(&in);
+ Q_UNUSED(magicmarker);
+ Q_ASSERT(magicmarker == MagicInstallerMarker || magicmarker == MagicUninstallerMarker);
+
+
+
+ if (!execIn->seek(0)) {
+ throw Error(QObject::tr("Failed to seek in file %1: %2").arg(execIn->fileName(),
+ execIn->errorString()));
+ }
+ appendData(&out, execIn, execSize);
+
+ // copy the first few bytes to take the executable+resources over to the uninstaller.
+ if (! in.seek(resourceStart)) {
+ throw Error(QObject::tr("Failed to seek in file %1: %2").arg(in.fileName(),
+ in.errorString()));
+ }
+ Q_ASSERT(in.pos() == resourceStart && out.pos() == execSize);
+
+ appendData(&out, &in, resourceLength);
+ const qint64 uninstallerDataBlockStart = out.pos();
+ // compared to the installer we do not have component data but details about
+ // the performed operations during the installation to allow to undo them.
+ const qint64 operationsStart = out.pos();
+ appendInt64(&out, performedOperations.count());
+ foreach (KDUpdater::UpdateOperation *op, performedOperations) {
+ // the installer can't be put into XML, remove it first
+ op->clearValue(QLatin1String("installer"));
+
+ appendString(&out, op->name());
+ appendString(&out, op->toXml().toString());
+
+ // for the ui not to get blocked
+ qApp->processEvents();
+ }
+ appendInt64(&out, performedOperations.count());
+ const qint64 operationsEnd = out.pos();
+
+ // we dont save any component-indexes.
+ const qint64 numComponents = 0;
+ appendInt64(&out, numComponents); // for the indexes
+ // we dont save any components.
+ const qint64 compIndexStart = out.pos();
+ appendInt64(&out, numComponents); // and 2 times number of components,
+ appendInt64(&out, numComponents); // one before and one after the components
+ const qint64 compIndexEnd = out.pos();
+
+ appendInt64Range(&out, Range<qint64>::fromStartAndEnd(compIndexStart, compIndexEnd)
+ .moved(-uninstallerDataBlockStart));
+ appendInt64Range(&out, Range<qint64>::fromStartAndLength(newResourceStart, resourceLength)
+ .moved(-uninstallerDataBlockStart));
+ appendInt64Range(&out, Range<qint64>::fromStartAndEnd(operationsStart, operationsEnd)
+ .moved(-uninstallerDataBlockStart));
+ appendInt64(&out, count);
+ //data block size, from end of .exe to end of file
+ appendInt64(&out, out.pos() + 3 * sizeof(qint64) - uninstallerDataBlockStart);
+ appendInt64(&out, MagicUninstallerMarker);
+ appendInt64(&out, MagicCookie);
+
+ out.setPermissions(out.permissions() | QFile::WriteUser | QFile::ReadGroup | QFile::ReadOther
+ | QFile::ExeOther | QFile::ExeGroup | QFile::ExeUser);
+
+ if (!out.commit(KDSaveFile::OverwriteExistingFile)) {
+ throw Error(tr("Could not write uninstaller to %1: %2").arg(uninstallerName(),
+ out.errorString()));
+ }
+
+ //delete the installerbase binary temporarily installed for the uninstaller update
+ if (haveSeparateExec) {
+ QFile tmp(installerBaseBinary);
+ // Is there anything more sensible we can do with this error? I think not.
+ // It's not serious enough for throwing/aborting.
+ if (!tmp.remove()) {
+ verbose() << "Could not remove installerbase binary (" << installerBaseBinary
+ << ") after updating the uninstaller: " << tmp.errorString() << std::endl;
+ }
+ installerBaseBinaryUnreplaced.clear();
+ }
+
+#ifdef Q_WS_WIN
+ deferredRename(out.fileName(), QFileInfo(uninstallerName()).fileName(),
+ haveSeparateExec && !isInstaller());
+#else
+ verbose() << " preparing restart " << std::endl;
+ if (haveSeparateExec && !isInstaller())
+ KDSelfRestarter::setRestartOnQuit(true);
+#endif
+ } catch (const Error &err) {
+ setStatus(InstallerFailed);
+ if (gainedAdminRights)
+ q->dropAdminRights();
+ m_needToWriteUninstaller = false;
+ throw err;
+ }
+
+ if (gainedAdminRights)
+ q->dropAdminRights();
+
+ commitSessionOperations();
+
+ m_needToWriteUninstaller = false;
+}
+
+QString Installer::Private::registerPath() const
+{
+ QString productName = m_vars.value(QLatin1String("ProductName"));
+ if (productName.isEmpty())
+ throw Error(tr("ProductName should be set"));
+
+ QString path = QLatin1String("HKEY_CURRENT_USER");
+ if (m_vars.value(QLatin1String("AllUsers")) == QLatin1String("true"))
+ path = QLatin1String("HKEY_LOCAL_MACHINE");
+
+ return path + QLatin1String("\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\")
+ + productName;
+}
+
+void Installer::Private::registerInstaller()
+{
+#ifdef Q_OS_WIN
+ QSettings settings(registerPath(), QSettings::NativeFormat);
+ settings.setValue(QLatin1String("DisplayName"), m_vars.value(QLatin1String("ProductName")));
+ settings.setValue(QLatin1String("DisplayVersion"), m_vars.value(QLatin1String("ProductVersion")));
+ const QString uninstaller = QDir::toNativeSeparators(uninstallerName());
+ settings.setValue(QLatin1String("DisplayIcon"), uninstaller);
+ settings.setValue(QLatin1String("Publisher"), m_vars.value(QLatin1String("Publisher")));
+ settings.setValue(QLatin1String("UrlInfoAbout"), m_vars.value(QLatin1String("Url")));
+ settings.setValue(QLatin1String("Comments"), m_vars.value(QLatin1String("Title")));
+ settings.setValue(QLatin1String("InstallDate"), QDateTime::currentDateTime().toString());
+ settings.setValue(QLatin1String("InstallLocation"), QDir::toNativeSeparators(targetDir()));
+ settings.setValue(QLatin1String("UninstallString"), uninstaller);
+ settings.setValue(QLatin1String("ModifyPath"), uninstaller + QLatin1String(" --manage-packages"));
+ settings.setValue(QLatin1String("EstimatedSize"), QFileInfo(installerBinaryPath()).size());
+ settings.setValue(QLatin1String("NoModify"), 1); // TODO: set to 0 and support modify
+ settings.setValue(QLatin1String("NoRepair"), 1);
+#endif
+}
+
+void Installer::Private::unregisterInstaller()
+{
+#ifdef Q_OS_WIN
+ QSettings settings(registerPath(), QSettings::NativeFormat);
+ settings.remove(QString());
+#endif
+}
+
+void Installer::autoAcceptMessageBoxes()
+{
+ MessageBoxHandler::instance()->setDefaultAction(MessageBoxHandler::Accept);
+}
+
+void Installer::autoRejectMessageBoxes()
+{
+ MessageBoxHandler::instance()->setDefaultAction(MessageBoxHandler::Reject);
+}
+
+void Installer::setMessageBoxAutomaticAnswer(const QString &identifier, int button)
+{
+ MessageBoxHandler::instance()->setAutomaticAnswer(identifier,
+ static_cast<QMessageBox::Button>(button));
+}
+
+void Installer::installSelectedComponents()
+{
+ d->setStatus(InstallerRunning);
+ // download
+
+ double downloadPartProgressSize = double(1)/3;
+ double componentsInstallPartProgressSize = double(2)/3;
+ // get the list of packages we need to install in proper order and do it for the updater
+ downloadNeededArchives(UpdaterMode, downloadPartProgressSize);
+ // get the list of packages we need to install in proper order
+ const QList<Component*> components = calculateComponentOrder(UpdaterMode);
+
+ if (!isInstaller() && !QFileInfo(installerBinaryPath()).isWritable())
+ gainAdminRights();
+
+ d->stopProcessesForUpdates(components);
+ int progressOperationCount = d->countProgressOperations(components);
+ double progressOperationSize = componentsInstallPartProgressSize / progressOperationCount;
+
+ //TODO: devide this in undo steps and install steps (2 "for" loops) for better progress calculation
+ for (QList<Component*>::const_iterator it = components.begin(); it != components.end(); ++it) {
+ if (d->statusCanceledOrFailed())
+ throw Error(tr("Installation canceled by user"));
+ Component* const currentComponent = *it;
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nRemoving the old "
+ "version of: %1").arg(currentComponent->name()));
+ if (isUpdater() && currentComponent->removeBeforeUpdate()) {
+ // undo all operations done by this component upon installation
+ for (int i = d->m_performedOperationsOld.count() - 1; i >= 0; --i) {
+ KDUpdater::UpdateOperation* const op = d->m_performedOperationsOld[i];
+ if (op->value(QLatin1String("component")) != currentComponent->name())
+ continue;
+ const bool becameAdmin = !d->engineClientHandler->isActive()
+ && op->value(QLatin1String("admin")).toBool() && gainAdminRights();
+ performOperationThreaded(op, Undo);
+ if (becameAdmin)
+ dropAdminRights();
+ d->m_performedOperationsOld.remove(i);
+ delete op;
+ }
+ d->m_app->packagesInfo()->removePackage(currentComponent->name());
+ d->m_app->packagesInfo()->writeToDisk();
+ }
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(
+ tr("\nInstalling the new version of: %1").arg(currentComponent->name()));
+ installComponent(currentComponent, progressOperationSize);
+ //commit all operations for this allready updated/installed component
+ //so an undo during the installComponent function only undos the uncomplete installed one
+ d->commitSessionOperations();
+ d->m_needToWriteUninstaller = true;
+ }
+
+ d->setStatus(InstallerSucceeded);
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nUpdate finished!"));
+ emit updateFinished();
+}
+
+quint64 Installer::requiredDiskSpace() const
+{
+ quint64 result = 0;
+ QList<Component*>::const_iterator it;
+ const QList<Component*> availableComponents = components(true);
+ for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
+ Component* const comp = *it;
+ if (!comp->isSelected())
+ continue;
+ if (comp->value(QLatin1String("PreviousState")) == QLatin1String("Installed"))
+ continue;
+ result += comp->value(QLatin1String("UncompressedSize")).toLongLong();
+ }
+ return result;
+}
+
+quint64 Installer::requiredTemporaryDiskSpace() const
+{
+ quint64 result = 0;
+ QList<Component*>::const_iterator it;
+ const QList<Component*> availableComponents = components(true);
+ for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
+ Component* const comp = *it;
+ if (!comp->isSelected())
+ continue;
+ if (comp->value(QLatin1String("PreviousState")) == QLatin1String("Installed"))
+ continue;
+ result += comp->value(QLatin1String("CompressedSize")).toLongLong();
+ }
+ return result;
+}
+
+/*!
+ Returns the will be downloaded archives count
+*/
+int Installer::downloadNeededArchives(RunModes runMode, double partProgressSize)
+{
+ Q_ASSERT(partProgressSize >= 0 && partProgressSize <= 1);
+
+ QList<Component*> neededComponents;
+ QList<QPair<QString, QString> > archivesToDownload;
+
+ QList<Component*>::const_iterator it;
+ const QList<Component*> availableComponents = components(true, runMode);
+ for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
+ Component* const comp = *it;
+ if (!comp->isSelected(runMode))
+ continue;
+ if (comp->value(QLatin1String("PreviousState")) == QLatin1String("Installed")
+ && runMode == InstallerMode) {
+ continue;
+ }
+ appendComponentAndMissingDependencies(neededComponents, comp);
+ }
+
+ for (it = neededComponents.begin(); it != neededComponents.end(); ++it) {
+ Component* const comp = *it;
+
+ // collect all archives to be downloaded
+ const QStringList toDownload = comp->downloadableArchives();
+ for (QStringList::const_iterator it2 = toDownload.begin(); it2 != toDownload.end(); ++it2) {
+ QString versionFreeString(*it2);
+ archivesToDownload.push_back(qMakePair(QString::fromLatin1("installer://%1/%2")
+ .arg(comp->name(), versionFreeString), QString::fromLatin1("%1/%2/%3")
+ .arg(comp->repositoryUrl().toString(), comp->name(), versionFreeString)));
+ }
+ }
+
+ if (archivesToDownload.isEmpty())
+ return 0;
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nDownloading packages..."));
+
+ // don't have it on the stack, since it keeps the temporary files
+ DownloadArchivesJob* const archivesJob = new DownloadArchivesJob(d->m_settings.publicKey(), this);
+ archivesJob->setArchivesToDownload(archivesToDownload);
+ archivesJob->setAutoDelete(false);
+ connect(archivesJob, SIGNAL(outputTextChanged(QString)), ProgressCoordninator::instance(),
+ SLOT(emitLabelAndDetailTextChanged(QString)));
+ ProgressCoordninator::instance()->registerPartProgress(archivesJob,
+ SIGNAL(progressChanged(double)), partProgressSize);
+ connect(this, SIGNAL(installationInterrupted()), archivesJob, SLOT(cancel()));
+ archivesJob->start();
+ archivesJob->waitForFinished();
+
+ if (archivesJob->error() == KDJob::Canceled)
+ interrupt();
+ else if (archivesJob->error() != DownloadArchivesJob::NoError)
+ throw Error(archivesJob->errorString());
+ if (d->statusCanceledOrFailed())
+ throw Error(tr("Installation canceled by user"));
+
+ return archivesToDownload.count();
+}
+
+QList<Component*> Installer::calculateComponentOrder(RunModes runMode) const
+{
+ return componentsToInstall(true, true, runMode);
+}
+
+void Installer::installComponent(Component* comp, double progressOperationSize)
+{
+ Q_ASSERT(progressOperationSize);
+
+ d->setStatus(InstallerRunning);
+ const QList<KDUpdater::UpdateOperation*> operations = comp->operations();
+
+ // show only component which are doing something, MinimumProgress is only for progress
+ // calculation safeness
+ if (operations.count() > 1
+ || (operations.count() == 1 && operations.at(0)->name() != QLatin1String("MinimumProgress"))) {
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nInstalling component %1")
+ .arg(comp->displayName()));
+ }
+
+ if (!comp->operationsCreatedSuccessfully())
+ setCanceled();
+
+ QList<KDUpdater::UpdateOperation*>::const_iterator op;
+ for (op = operations.begin(); op != operations.end(); ++op) {
+ if (d->statusCanceledOrFailed())
+ throw Error(tr("Installation canceled by user"));
+
+ KDUpdater::UpdateOperation* const operation = *op;
+ d->connectOperationToInstaller(operation, progressOperationSize);
+
+ // maybe this operations wants us to be admin...
+ const bool becameAdmin = !d->engineClientHandler->isActive()
+ && operation->value(QLatin1String("admin")).toBool() && gainAdminRights();
+ // perform the operation
+ if (becameAdmin)
+ verbose() << operation->name() << " as admin: " << becameAdmin << std::endl;
+
+ // allow the operation to backup stuff before performing the operation
+ performOperationThreaded(operation, Backup);
+
+ bool ignoreError = false;
+ bool ok = performOperationThreaded(operation);
+ while (!ok && !ignoreError && status() != InstallerCanceledByUser) {
+ verbose() << QString(QLatin1String("operation '%1' with arguments: '%2' failed: %3"))
+ .arg(operation->name(), operation->arguments().join(QLatin1String("; ")),
+ operation->errorString()) << std::endl;;
+ const QMessageBox::StandardButton button =
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationErrorWithRetry"), tr("Installer Error"),
+ tr("Error during installation process:\n%1").arg(operation->errorString()),
+ QMessageBox::Retry | QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Retry);
+
+ if (button == QMessageBox::Retry)
+ ok = performOperationThreaded(operation);
+ else if (button == QMessageBox::Ignore)
+ ignoreError = true;
+ else if (button == QMessageBox::Cancel)
+ interrupt();
+ }
+
+ if (ok || operation->error() > KDUpdater::UpdateOperation::InvalidArguments) {
+ // remember that the operation was performed what allows us to undo it if a
+ // following operaton fails or if this operation failed but still needs
+ // an undo call to cleanup.
+ d->addPerformed(operation);
+ operation->setValue(QLatin1String("component"), comp->name());
+ }
+
+ if (becameAdmin)
+ dropAdminRights();
+
+ if (!ok && !ignoreError)
+ throw Error(operation->errorString());
+
+ if (comp->value(QLatin1String("Important"), QLatin1String("false")) == QLatin1String("true"))
+ d->m_forceRestart = true;
+ }
+
+ d->registerPathesForUninstallation(comp->pathesForUninstallation(), comp->name());
+
+ if (!comp->stopProcessForUpdateRequests().isEmpty()) {
+ KDUpdater::UpdateOperation *stopProcessForUpdatesOp =
+ KDUpdater::UpdateOperationFactory::instance().create(QLatin1String("FakeStopProcessForUpdate"));
+ const QStringList arguments(comp->stopProcessForUpdateRequests().join(QLatin1String(",")));
+ stopProcessForUpdatesOp->setArguments(arguments);
+ d->addPerformed(stopProcessForUpdatesOp);
+ stopProcessForUpdatesOp->setValue(QLatin1String("component"), comp->name());
+ }
+
+ // now mark the component as installed
+ KDUpdater::PackagesInfo* const packages = d->m_app->packagesInfo();
+ const bool forcedInstall =
+ comp->value(QLatin1String("ForcedInstallation")).toLower() == QLatin1String("true")
+ ? true : false;
+ const bool virtualComponent =
+ comp->value(QLatin1String ("Virtual")).toLower() == QLatin1String("true") ? true : false;
+ packages->installPackage(comp->value(QLatin1String("Name")),
+ comp->value(QLatin1String("Version")), comp->value(QLatin1String("DisplayName")),
+ comp->value(QLatin1String("Description")), comp->dependencies(), forcedInstall,
+ virtualComponent, comp->value(QLatin1String ("UncompressedSize")).toULongLong());
+
+ comp->setValue(QLatin1String("CurrentState"), QLatin1String("Installed"));
+ comp->markAsPerformedInstallation();
+}
+
+/*!
+ If a component marked as important was installed during update
+ process true is returned.
+*/
+bool Installer::needsRestart() const
+{
+ return d->m_forceRestart;
+}
+
+void Installer::rollBackInstallation()
+{
+ emit titleMessageChanged(tr("Cancelling the Installer"));
+ // rolling back
+
+ //this unregisters all operation progressChanged connects
+ ProgressCoordninator::instance()->setUndoMode();
+ int progressOperationCount =
+ d->countProgressOperations(d->m_performedOperationsCurrentSession.toList());
+ double progressOperationSize = double(1) / progressOperationCount;
+
+ //reregister all the undooperations with the new size to the ProgressCoordninator
+ foreach (KDUpdater::UpdateOperation* const operation, d->m_performedOperationsCurrentSession) {
+ QObject* const operationObject = dynamic_cast<QObject*>(operation);
+ if (operationObject != 0) {
+ const QMetaObject* const mo = operationObject->metaObject();
+ if (mo->indexOfSignal(QMetaObject::normalizedSignature("progressChanged(double)")) > -1) {
+ ProgressCoordninator::instance()->registerPartProgress(operationObject,
+ SIGNAL(progressChanged(double)), progressOperationSize);
+ }
+ }
+ }
+
+ while (!d->m_performedOperationsCurrentSession.isEmpty()) {
+ try {
+ KDUpdater::UpdateOperation* const operation = d->m_performedOperationsCurrentSession.last();
+ d->m_performedOperationsCurrentSession.pop_back();
+
+ const bool becameAdmin = !d->engineClientHandler->isActive()
+ && operation->value(QLatin1String("admin")).toBool() && gainAdminRights();
+ performOperationThreaded(operation, Undo);
+ if (becameAdmin)
+ dropAdminRights();
+ } catch(const Error &e) {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("ElevationError"), tr("Authentication Error"), tr("Some components "
+ "could not be removed completely because admin rights could not be acquired: %1.")
+ .arg(e.message()));
+ }
+ }
+}
+
+void Installer::Private::runInstaller()
+{
+ try {
+ setStatus(InstallerRunning);
+ emit installationStarted(); //resets also the ProgressCoordninator
+
+ //to have some progress for writeUninstaller
+ ProgressCoordninator::instance()->addReservePercentagePoints(1);
+
+ const QString target = targetDir();
+ if (target.isEmpty())
+ throw Error(tr("Variable 'TargetDir' not set."));
+
+ // add the operation to create the target directory
+ bool installToAdminDirectory = false;
+ if (!QDir(target).exists()) {
+ QScopedPointer<KDUpdater::UpdateOperation> mkdirOp(createOwnedOperation(QLatin1String("Mkdir")));
+ mkdirOp->setValue(QLatin1String("forceremoval"), true);
+ Q_ASSERT(mkdirOp.data());
+ mkdirOp->setArguments(QStringList() << target);
+ performOperationThreaded(mkdirOp.data(), Backup);
+ if (!performOperationThreaded(mkdirOp.data())) {
+ // if we cannot create the target dir, we try to activate the admin rights
+ installToAdminDirectory = true;
+ if (!q->gainAdminRights() || !performOperationThreaded(mkdirOp.data()))
+ throw Error(mkdirOp->errorString());
+ }
+ addPerformed(mkdirOp.take());
+ } else {
+ QTemporaryFile tempAdminFile(target + QLatin1String("/adminrights"));
+ if (!tempAdminFile.open() || !tempAdminFile.isWritable())
+ installToAdminDirectory = q->gainAdminRights();
+ }
+
+ // to show that there was some work
+ ProgressCoordninator::instance()->addManualPercentagePoints(1);
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Preparing the installation..."));
+ const QList<Component*> componentsToInstall = q->calculateComponentOrder();
+ verbose() << "Install size: " << componentsToInstall.size() << " components" << std::endl;
+
+ // check if we need admin rights and ask before the action happens
+ for (QList<Component*>::const_iterator it = componentsToInstall.begin();
+ it != componentsToInstall.end() && !installToAdminDirectory; ++it) {
+ Component* const component = *it;
+ bool requiredAdmin = false;
+
+ if (component->value(QLatin1String("RequiresAdminRights"),
+ QLatin1String("false")) == QLatin1String("true")) {
+ requiredAdmin = q->gainAdminRights();
+ }
+
+ if (requiredAdmin) {
+ q->dropAdminRights();
+ break;
+ }
+ }
+
+ const double downloadPartProgressSize = double(1) / 3;
+ double componentsInstallPartProgressSize = double(2) / 3;
+ const int downloadedArchivesCount = q->downloadNeededArchives(InstallerMode,
+ downloadPartProgressSize);
+
+ //if there was no download we have the whole progress for installing components
+ if (!downloadedArchivesCount) {
+ //componentsInstallPartProgressSize + downloadPartProgressSize;
+ componentsInstallPartProgressSize = double(1);
+ }
+
+ // put the installed packages info into the target dir
+ KDUpdater::PackagesInfo* const packages = m_app->packagesInfo();
+ packages->setFileName(componentsXmlPath());
+ packages->setApplicationName(m_settings.applicationName());
+ packages->setApplicationVersion(m_settings.applicationVersion());
+
+ stopProcessesForUpdates(componentsToInstall);
+
+ const int progressOperationCount = countProgressOperations(componentsToInstall);
+ double progressOperationSize = componentsInstallPartProgressSize / progressOperationCount;
+
+ QList<Component*>::const_iterator it;
+ for (it = componentsToInstall.begin(); it != componentsToInstall.end(); ++it)
+ q->installComponent(*it, progressOperationSize);
+
+ registerInstaller();
+
+ emit q->titleMessageChanged(tr("Creating Uninstaller"));
+
+ m_app->packagesInfo()->writeToDisk();
+ writeUninstaller(m_performedOperationsOld + m_performedOperationsCurrentSession);
+
+ //this is the reserved one from the beginning
+ ProgressCoordninator::instance()->addManualPercentagePoints(1);
+
+ setStatus(InstallerSucceeded);
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nInstallation finished!"));
+
+ emit installationFinished();
+
+ // disable the FSEngineClientHandler afterwards
+ engineClientHandler->setActive(false);
+ } catch (const Error &err) {
+ if (q->status() != InstallerCanceledByUser) {
+ setStatus(InstallerFailed);
+ verbose() << "INSTALLER FAILED: " << err.message() << std::endl;
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationError"), tr("Error"), err.message());
+ verbose() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count()
+ << std::endl;
+ }
+
+ q->rollBackInstallation();
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Installation aborted"));
+ emit installationFinished();
+
+ // disable the FSEngineClientHandler afterwards
+ engineClientHandler->setActive(false);
+ throw;
+ }
+}
+
+void Installer::Private::deleteUninstaller()
+{
+#ifdef Q_OS_WIN
+ // Since Windows does not support that the uninstaller deletes itself we have to go with a
+ // rather dirty hack. What we do is to create a batchfile that will try to remove the uninstaller
+ // once per second. Then we start that batchfile detached, finished our job and close outself.
+ // Once that's done the batchfile will succeed in deleting our uninstall.exe and, if the
+ // installation directory was created but us and if it's empty after the uninstall, deletes
+ // the installation-directory.
+ const QString batchfile = QDir::toNativeSeparators(QFileInfo(QDir::tempPath(),
+ QLatin1String("uninstall.vbs")).absoluteFilePath());
+ QFile f(batchfile);
+ if (!f.open(QIODevice::WriteOnly | QIODevice::Text))
+ throw Error(tr("Cannot prepare uninstall"));
+
+ QTextStream batch(&f);
+ batch << "Set fso = WScript.CreateObject(\"Scripting.FileSystemObject\")\n";
+ batch << "file = WScript.Arguments.Item(0)\n";
+ batch << "folderpath = WScript.Arguments.Item(1)\n";
+ batch << "Set folder = fso.GetFolder(folderpath)\n";
+ batch << "on error resume next\n";
+
+ batch << "while fso.FileExists(file)\n";
+ batch << " fso.DeleteFile(file)\n";
+ batch << " WScript.Sleep(1000)\n";
+ batch << "wend\n";
+// batch << "if folder.SubFolders.Count = 0 and folder.Files.Count = 0 then\n";
+ batch << " Set folder = Nothing\n";
+ batch << " fso.DeleteFolder folderpath, true\n";
+// batch << "end if\n";
+ batch << "fso.DeleteFile(WScript.ScriptFullName)\n";
+
+ f.close();
+
+ QStringList arguments;
+ arguments << QLatin1String("//Nologo") << batchfile; // execute the batchfile
+ arguments << QDir::toNativeSeparators(QFileInfo(installerBinaryPath()).absoluteFilePath());
+ if (!m_performedOperationsOld.isEmpty()) {
+ const KDUpdater::UpdateOperation* const op = m_performedOperationsOld.first();
+ if (op->name() == QLatin1String("Mkdir")) // the target directory name
+ arguments << QDir::toNativeSeparators(QFileInfo(op->arguments().first()).absoluteFilePath());
+ }
+
+ if (!QProcess::startDetached(QLatin1String("cscript"), arguments, QDir::rootPath()))
+ throw Error(tr("Cannot start uninstall"));
+#else
+ // every other platform has no problem if we just delete ourself now
+ QFile uninstaller(QFileInfo(installerBinaryPath()).absoluteFilePath());
+ uninstaller.remove();
+#ifdef Q_WS_MAC
+ const QLatin1String cdUp("/../../..");
+ if (QFileInfo(QFileInfo(installerBinaryPath() + cdUp).absoluteFilePath()).isBundle()) {
+ removeDirectoryThreaded(QFileInfo(installerBinaryPath() + cdUp).absoluteFilePath());
+ QFile::remove(QFileInfo(installerBinaryPath() + cdUp).absolutePath()
+ + QLatin1String("/components.xml"));
+ }
+ else
+#endif
+#endif
+ {
+ // finally remove the components.xml, since it still exists now
+ QFile::remove(QFileInfo(installerBinaryPath()).absolutePath() + QLatin1String("/components.xml"));
+ }
+}
+
+bool Installer::isFileExtensionRegistered(const QString& extension) const
+{
+ QSettings settings(QLatin1String("HKEY_CLASSES_ROOT"), QSettings::NativeFormat);
+ return settings.value(QString::fromLatin1(".%1/Default").arg(extension)).isValid();
+}
+
+void Installer::Private::runPackageUpdater()
+{
+ try {
+ if (m_completeUninstall) {
+ // well... I guess we would call that an uninstall, no? :-)
+ packageManagingMode = !m_completeUninstall;
+ runUninstaller();
+ return;
+ }
+
+ setStatus(InstallerRunning);
+ emit installationStarted(); //resets also the ProgressCoordninator
+
+ //to have some progress for the cleanup/write component.xml step
+ ProgressCoordninator::instance()->addReservePercentagePoints(1);
+
+ if (!QFileInfo(installerBinaryPath()).isWritable())
+ q->gainAdminRights();
+
+ KDUpdater::PackagesInfo* const packages = m_app->packagesInfo();
+ packages->setFileName(componentsXmlPath());
+ packages->setApplicationName(m_settings.applicationName());
+ packages->setApplicationVersion(m_settings.applicationVersion());
+
+ const QString packagesXml = componentsXmlPath();
+ if (!QFile(packagesXml).open(QIODevice::Append))
+ q->gainAdminRights();
+
+ // first check, if we need admin rights for the installation part
+ QList<Component*>::const_iterator it;
+ QList<Component*> availableComponents = q->components(true, InstallerMode);
+ for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
+ // check if we need admin rights and ask before the action happens
+ Component* const currentComponent = *it;
+ if (!currentComponent->isSelected(InstallerMode))
+ continue;
+
+ // we only need the uninstalled components
+ if (currentComponent->value(QLatin1String("PreviousState")) == QLatin1String("Installed"))
+ continue;
+
+ bool requiredAdmin = false;
+ if (currentComponent->value(QLatin1String("RequiresAdminRights"),
+ QLatin1String("false")) == QLatin1String("true")) {
+ requiredAdmin = q->gainAdminRights();
+ }
+
+ if (requiredAdmin) {
+ q->dropAdminRights();
+ break;
+ }
+ }
+
+ //to have 1/5 for undoOperationProgressSize and 2/5 for componentsInstallPartProgressSize
+ const double downloadPartProgressSize = double(2) / 5;
+ // following, we download the needed archives
+ q->downloadNeededArchives(InstallerMode, downloadPartProgressSize);
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Removing deselected components..."));
+ QVector< KDUpdater::UpdateOperation* > nonRevertedOperations;
+
+ QList<KDUpdater::UpdateOperation*> undoOperations;
+ for (int i = m_performedOperationsOld.count() - 1; i >= 0; --i) {
+ KDUpdater::UpdateOperation* const currentOperation = m_performedOperationsOld[i];
+
+ const QString componentName = currentOperation->value(QLatin1String("component")).toString();
+ Component* comp = q->componentByName(componentName);
+
+ // if we're _not_ removing everything an this component is still selected, -> next
+ if (comp == 0 || comp->isSelected()) {
+ nonRevertedOperations.push_front(currentOperation);
+ continue;
+ }
+ undoOperations.append(currentOperation);
+ }
+
+ double undoOperationProgressSize = 0;
+ int progressUndoOperationCount = 0;
+ double progressUndoOperationSize = 0;
+ double componentsInstallPartProgressSize = double(2) / 5;
+ if (undoOperations.count() > 0) {
+ componentsInstallPartProgressSize = double(2) / 5;
+ undoOperationProgressSize = double(1) / 5;
+ progressUndoOperationCount = countProgressOperations(undoOperations);
+ progressUndoOperationSize = undoOperationProgressSize / progressUndoOperationCount;
+ } else {
+ componentsInstallPartProgressSize = double(3) / 5;
+ }
+
+ QSet<Component*> uninstalledComponents;
+ foreach (KDUpdater::UpdateOperation* const currentOperation, undoOperations) {
+ if (statusCanceledOrFailed())
+ throw Error(tr("Installation canceled by user"));
+ connectOperationToInstaller(currentOperation, progressUndoOperationSize);
+
+ const QString componentName = currentOperation->value(QLatin1String("component")).toString();
+ Component* comp = q->componentByName(componentName);
+
+ verbose() << "undo operation=" << currentOperation->name() << std::endl;
+ uninstalledComponents |= comp;
+
+ const bool becameAdmin = !engineClientHandler->isActive()
+ && currentOperation->value(QLatin1String("admin")).toBool() && q->gainAdminRights();
+
+ bool ignoreError = false;
+ performOperationThreaded(currentOperation, Undo);
+ bool ok = currentOperation->error() == KDUpdater::UpdateOperation::NoError
+ || componentName == QLatin1String("");
+ while (!ok && !ignoreError && q->status() != InstallerCanceledByUser) {
+ verbose() << QString(QLatin1String("operation '%1' with arguments: '%2' failed: %3"))
+ .arg(currentOperation->name(), currentOperation->arguments()
+ .join(QLatin1String("; ")), currentOperation->errorString()) << std::endl;;
+
+ const QMessageBox::StandardButton button =
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationErrorWithRetry"), tr("Installer Error"),
+ tr("Error during installation process:\n%1").arg(currentOperation->errorString()),
+ QMessageBox::Retry | QMessageBox::Ignore, QMessageBox::Retry);
+
+ if (button == QMessageBox::Retry) {
+ performOperationThreaded(currentOperation, Undo);
+ ok = currentOperation->error() == KDUpdater::UpdateOperation::NoError;
+ }
+ else if (button == QMessageBox::Ignore)
+ ignoreError = true;
+ }
+
+ if (becameAdmin)
+ q->dropAdminRights();
+
+ delete currentOperation;
+ }
+
+ const QList<Component*> allComponents = q->components(true, InstallerMode);
+ foreach (Component *comp, allComponents) {
+ if (!comp->isSelected())
+ uninstalledComponents |= comp;
+ }
+
+ QSet<Component*>::const_iterator it2;
+ for (it2 = uninstalledComponents.begin(); it2 != uninstalledComponents.end(); ++it2) {
+ packages->removePackage((*it2)->name());
+ (*it2)->setValue(QLatin1String("CurrentState"), QLatin1String("Uninstalled"));
+ }
+
+ // these are all operations left: those which were not reverted
+ m_performedOperationsOld = nonRevertedOperations;
+
+ //write components.xml in case the user cancels the update
+ packages->writeToDisk();
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Preparing the installation..."));
+
+ const QList<Component*> componentsToInstall = q->calculateComponentOrder();
+
+ verbose() << "Install size: " << componentsToInstall.size() << " components " << std::endl;
+
+ stopProcessesForUpdates(componentsToInstall);
+
+ int progressOperationCount = countProgressOperations(componentsToInstall);
+ double progressOperationSize = componentsInstallPartProgressSize / progressOperationCount;
+
+ for (it = componentsToInstall.begin(); it != componentsToInstall.end(); ++it)
+ q->installComponent(*it, progressOperationSize);
+
+ packages->writeToDisk();
+
+ emit q->titleMessageChanged(tr("Creating Uninstaller"));
+
+ commitSessionOperations(); //end session, move ops to "old"
+ m_needToWriteUninstaller = true;
+
+ //this is the reserved one from the beginning
+ ProgressCoordninator::instance()->addManualPercentagePoints(1);
+
+ setStatus(InstallerSucceeded);
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nInstallation finished!"));
+ emit installationFinished();
+
+ // disable the FSEngineClientHandler afterwards
+ engineClientHandler->setActive(false);
+ } catch(const Error &err) {
+ if (q->status() != InstallerCanceledByUser) {
+ setStatus(InstallerFailed);
+ verbose() << "INSTALLER FAILED: " << err.message() << std::endl;
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationError"), tr("Error"), err.message());
+ verbose() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count()
+ << std::endl;
+ }
+
+ q->rollBackInstallation();
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Installation aborted"));
+ emit installationFinished();
+
+ // disable the FSEngineClientHandler afterwards
+ engineClientHandler->setActive(false);
+ throw;
+ }
+}
+
+void Installer::Private::runUninstaller()
+{
+ try {
+ emit uninstallationStarted();
+
+ if (!QFileInfo(installerBinaryPath()).isWritable())
+ q->gainAdminRights();
+
+ const QString packagesXml = componentsXmlPath();
+ if (!QFile(packagesXml).open(QIODevice::Append))
+ q->gainAdminRights();
+
+ KDUpdater::PackagesInfo* const packages = m_app->packagesInfo();
+ packages->setFileName(componentsXmlPath());
+ packages->setApplicationName(m_settings.applicationName());
+ packages->setApplicationVersion(m_settings.applicationVersion());
+
+ // iterate over all components - if they're all marked for uninstall, it's a complete uninstall
+ const QList<Component*> allComponents = q->components(true);
+ bool allMarkedForUninstall = true;
+
+ QList<KDUpdater::UpdateOperation*> uninstallOperations;
+ QVector<KDUpdater::UpdateOperation*> nonRevertedOperations;
+
+ // just rollback all operations done before
+ for (int i = m_performedOperationsOld.count() - 1; i >= 0; --i) {
+ KDUpdater::UpdateOperation* const operation = m_performedOperationsOld[i];
+
+ const QString componentName = operation->value(QLatin1String("component")).toString();
+ const Component* const comp = q->componentByName(componentName);
+
+ // if we're _not_ removing everything an this component is still selected, -> next
+ if (!m_completeUninstall && (comp == 0 || !comp->isSelected())) {
+ nonRevertedOperations.push_front(operation);
+ continue;
+ }
+ uninstallOperations.append(operation);
+ }
+
+ const int progressUninstallOperationCount = countProgressOperations(uninstallOperations);
+ const double progressUninstallOperationSize = double(1) / progressUninstallOperationCount;
+
+ foreach (KDUpdater::UpdateOperation* const currentOperation, uninstallOperations) {
+ if (statusCanceledOrFailed())
+ throw Error(tr("Installation canceled by user"));
+
+ connectOperationToInstaller(currentOperation, progressUninstallOperationSize);
+ verbose() << "undo operation=" << currentOperation->name() << std::endl;
+
+ const QString componentName = currentOperation->value(QLatin1String("component")).toString();
+
+ const bool becameAdmin = !engineClientHandler->isActive()
+ && currentOperation->value(QLatin1String("admin")).toBool() && q->gainAdminRights();
+
+ bool ignoreError = false;
+ performOperationThreaded(currentOperation, Undo);
+ bool ok = currentOperation->error() == KDUpdater::UpdateOperation::NoError
+ || componentName == QLatin1String("");
+ while (!ok && !ignoreError && q->status() != InstallerCanceledByUser) {
+ verbose() << QString(QLatin1String("operation '%1' with arguments: '%2' failed: %3"))
+ .arg(currentOperation->name(), currentOperation->arguments()
+ .join(QLatin1String("; ")), currentOperation->errorString()) << std::endl;;
+ const QMessageBox::StandardButton button =
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationErrorWithRetry"), tr("Installer Error"),
+ tr("Error during installation process:\n%1").arg(currentOperation->errorString()),
+ QMessageBox::Retry | QMessageBox::Ignore, QMessageBox::Retry);
+
+ if (button == QMessageBox::Retry) {
+ performOperationThreaded(currentOperation, Undo);
+ ok = currentOperation->error() == KDUpdater::UpdateOperation::NoError;
+ } else if (button == QMessageBox::Ignore)
+ ignoreError = true;
+ }
+
+ if (becameAdmin)
+ q->dropAdminRights();
+
+ if (!m_completeUninstall)
+ delete currentOperation;
+ }
+
+ if (!m_completeUninstall) {
+ QList<Component*>::const_iterator it;
+ for (it = allComponents.begin(); it != allComponents.end(); ++it) {
+ Component* const comp = *it;
+ if (comp->isSelected()) {
+ allMarkedForUninstall = false;
+ } else {
+ packages->removePackage(comp->name());
+ comp->setValue(QLatin1String("CurrentState"), QLatin1String("Uninstalled"));
+ }
+ }
+ m_completeUninstall = m_completeUninstall || allMarkedForUninstall;
+ packageManagingMode = ! m_completeUninstall;
+ }
+
+ const QString startMenuDir = m_vars.value(QLatin1String("StartMenuDir"));
+ if (!startMenuDir.isEmpty()) {
+ errno = 0;
+ if (!QDir().rmdir(startMenuDir)) {
+ verbose() << "Could not remove " << startMenuDir << " : "
+ << QLatin1String(strerror(errno)) << std::endl;
+ } else {
+ verbose() << "Startmenu dir not set" << std::endl;
+ }
+ }
+
+ if (m_completeUninstall) {
+ // this will also delete the TargetDir on Windows
+ deleteUninstaller();
+ QList<Component*>::const_iterator it;
+ for (it = allComponents.begin(); it != allComponents.end(); ++it) {
+ packages->removePackage((*it)->name());
+ (*it)->setValue(QLatin1String("CurrentState"), QLatin1String("Uninstalled"));
+ }
+
+ // on !Windows, we need to remove TargetDir manually
+ packageManagingMode = ! m_completeUninstall;
+ verbose() << "Complete Uninstallation is chosen" << std::endl;
+ const QString target = targetDir();
+ if (!target.isEmpty()) {
+ if (engineClientHandler->isServerRunning() && !engineClientHandler->isActive()) {
+ // we were root at least once, so we remove the target dir as root
+ q->gainAdminRights();
+ removeDirectoryThreaded(target, true);
+ q->dropAdminRights();
+ } else {
+ removeDirectoryThreaded(target, true);
+ }
+ }
+
+ unregisterInstaller();
+ m_needToWriteUninstaller = false;
+ } else {
+ // rewrite the uninstaller with the operation we did not undo
+ writeUninstaller(nonRevertedOperations);
+ }
+
+ setStatus(InstallerSucceeded);
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("\nDeinstallation finished"));
+
+ engineClientHandler->setActive(false);
+ } catch (const Error &err) {
+ if (q->status() != InstallerCanceledByUser) {
+ setStatus(InstallerFailed);
+ verbose() << "INSTALLER FAILED: " << err.message() << std::endl;
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("installationError"), tr("Error"), err.message());
+ verbose() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count()
+ << std::endl;
+ }
+
+ ProgressCoordninator::instance()->emitLabelAndDetailTextChanged(tr("Installation aborted"));
+ emit installationFinished();
+
+ // disable the FSEngineClientHandler afterwards
+ engineClientHandler->setActive(false);
+ throw;
+ }
+ emit uninstallationFinished();
+}
+
+
+// -- QInstaller
+
+
+Installer::Installer(qint64 magicmaker,
+ const QVector<KDUpdater::UpdateOperation*>& performedOperations)
+ : d(new Private(this, magicmaker, performedOperations))
+{
+ qRegisterMetaType< QInstaller::Installer::Status >("QInstaller::Installer::Status");
+ qRegisterMetaType< QInstaller::Installer::WizardPage >("QInstaller::Installer::WizardPage");
+
+ d->initialize();
+}
+
+Installer::~Installer()
+{
+ if (!isUninstaller() && !(isInstaller() && status() == InstallerCanceledByUser)) {
+ QDir targetDir(value(QLatin1String("TargetDir")));
+ QString logFileName = targetDir.absoluteFilePath(value(QLatin1String("LogFileName"),
+ QLatin1String("InstallationLog.txt")));
+ QInstaller::VerboseWriter::instance()->setOutputStream(logFileName);
+ }
+
+ d->engineClientHandler->setActive(false);
+ delete d;
+}
+
+/*!
+ Adds the widget with objectName() \a name registered by \a component as a new page
+ into the installer's GUI wizard. The widget is added before \a page.
+ \a page has to be a value of \ref QInstaller::Installer::WizardPage "WizardPage".
+*/
+bool Installer::addWizardPage(Component* component, const QString &name, int page)
+{
+ if (QWidget* const widget = component->userInterface(name)) {
+ emit wizardPageInsertionRequested(widget, static_cast<WizardPage>(page));
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Removes the widget with objectName() \a name previously added to the installer's wizard
+ by \a component.
+*/
+bool Installer::removeWizardPage(Component *component, const QString &name)
+{
+ if (QWidget* const widget = component->userInterface(name)) {
+ emit wizardPageRemovalRequested(widget);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Sets the visibility of the default page with id \a page to \a visible, i.e.
+ removes or adds it from/to the wizard. This works only for pages which have been
+ in the installer when it was started.
+ */
+bool Installer::setDefaultPageVisible(int page, bool visible)
+{
+ emit wizardPageVisibilityChangeRequested(visible, page);
+ return true;
+}
+
+/*!
+ Adds the widget with objectName() \a name registered by \a component as an GUI element
+ into the installer's GUI wizard. The widget is added on \a page.
+ \a page has to be a value of \ref QInstaller::Installer::WizardPage "WizardPage".
+*/
+bool Installer::addWizardPageItem(Component *component, const QString &name, int page)
+{
+ if (QWidget* const widget = component->userInterface(name)) {
+ emit wizardWidgetInsertionRequested(widget, static_cast<WizardPage>(page));
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Removes the widget with objectName() \a name previously added to the installer's wizard
+ by \a component.
+*/
+bool Installer::removeWizardPageItem(Component *component, const QString &name)
+{
+ if (QWidget* const widget = component->userInterface(name)) {
+ emit wizardWidgetRemovalRequested(widget);
+ return true;
+ }
+ return false;
+}
+
+void Installer::setRemoteRepositories(const QList<Repository> &repositories)
+{
+ GetRepositoriesMetaInfoJob metaInfoJob(d->m_settings.publicKey(), isPackageManager());
+ metaInfoJob.setRepositories(repositories);
+
+ // start...
+ metaInfoJob.setAutoDelete(false);
+ metaInfoJob.start();
+ metaInfoJob.waitForFinished();
+
+ if (metaInfoJob.isCanceled())
+ return;
+
+ if (metaInfoJob.error() != KDJob::NoError)
+ throw Error(tr("Could not retrieve updates: %1").arg(metaInfoJob.errorString()));
+
+ KDUpdater::Application &updaterApp = *d->m_app;
+
+ const QStringList tempDirs = metaInfoJob.temporaryDirectories();
+ d->tempDirDeleter.add(tempDirs);
+ foreach (const QString &tmpDir, tempDirs) {
+ if (tmpDir.isEmpty())
+ continue;
+ const QString &applicationName = d->m_settings.applicationName();
+ updaterApp.addUpdateSource(applicationName, applicationName, QString(),
+ QUrl::fromLocalFile(tmpDir), 1);
+ }
+
+ if (updaterApp.updateSourcesInfo()->updateSourceInfoCount() == 0)
+ throw Error(tr("Could not reach any update sources."));
+
+ if (!setAndParseLocalComponentsFile(*updaterApp.packagesInfo()))
+ return;
+
+ // The changes done above by adding update source don't count as modification that
+ // need to be saved cause they will be re-set on the next start anyway. This does
+ // prevent creating of xml files not needed atm. We can still set the modified
+ // state later once real things changed that we like to restore at the next startup.
+ updaterApp.updateSourcesInfo()->setModified(false);
+
+ // create the packages info
+ KDUpdater::UpdateFinder* const updateFinder = new KDUpdater::UpdateFinder(&updaterApp);
+ connect(updateFinder, SIGNAL(error(int, QString)), &updaterApp, SLOT(printError(int, QString)));
+ updateFinder->setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage);
+ updateFinder->run();
+
+ // now create installable componets
+ createComponents(updateFinder->updates(), metaInfoJob);
+}
+
+/*!
+ Sets additional repository for this instance of the installer or updater
+ Will be removed after invoking it again
+*/
+void Installer::setTemporaryRepositories(const QList<Repository> &repositories, bool replace)
+{
+ d->m_settings.setTemporaryRepositories(repositories, replace);
+}
+
+/*!
+ Defines if the downloader should try to download sha1 checksums for archives
+*/
+void Installer::setTestChecksum(bool test)
+{
+ d->m_testChecksum = test;
+}
+
+/*!
+ checks if the downloader should try to download sha1 checksums for archives
+*/
+bool Installer::testChecksum()
+{
+ return d->m_testChecksum;
+}
+
+/*!
+ Creates components from the \a updates found by KDUpdater.
+*/
+void Installer::createComponents(const QList<KDUpdater::Update*> &updates,
+ const GetRepositoriesMetaInfoJob &metaInfoJob)
+{
+ verbose() << "entered create components in installer" << std::endl;
+
+ emit componentsAboutToBeCleared();
+
+ qDeleteAll(d->m_components);
+ qDeleteAll(d->m_updaterComponents);
+ d->m_components.clear();
+ d->m_updaterComponents.clear();
+ d->m_packageManagerComponents.clear();
+ d->m_componentHash.clear();
+
+ KDUpdater::Application &updaterApp = *d->m_app;
+ KDUpdater::PackagesInfo &packagesInfo = *updaterApp.packagesInfo();
+
+ if (isUninstaller() || isPackageManager()) {
+ if (!setAndParseLocalComponentsFile(packagesInfo))
+ return;
+ packagesInfo.setApplicationName(d->m_settings.applicationName());
+ packagesInfo.setApplicationVersion(d->m_settings.applicationVersion());
+ }
+
+ bool containsImportantUpdates = false;
+ QMap<QInstaller::Component*, QString> scripts;
+ QMap<QString, QInstaller::Component*> components;
+ QList<Component*> componentsToSelectUpdater, componentsToSelectInstaller;
+
+ if (metaInfoJob.error() == KDJob::UserDefinedError) {
+ foreach (const KDUpdater::PackageInfo &info, packagesInfo.packageInfos()) {
+ QScopedPointer<QInstaller::Component> component(new QInstaller::Component(this));
+ component->setValue(QLatin1String("Name"), info.name);
+ component->setValue(QLatin1String("DisplayName"), info.title);
+ component->setValue(QLatin1String("Description"), info.description);
+ component->setValue(QLatin1String("UncompressedSize"),
+ QString::number(info.uncompressedSize));
+ component->setValue(QLatin1String("Version"), info.version);
+ component->setValue(QLatin1String("Virtual"),
+ info.virtualComp ? QLatin1String ("true") : QLatin1String ("false"));
+ QString dependstr = QLatin1String("");
+ foreach (const QString& val, info.dependencies)
+ dependstr += val + QLatin1String(",");
+ if (info.dependencies.count() > 0)
+ dependstr.chop(1);
+ component->setValue(QLatin1String("Dependencies"), dependstr);
+ if (info.forcedInstallation)
+ component->setValue(QLatin1String("ForcedInstallation"),
+ info.forcedInstallation ? QLatin1String ("true") : QLatin1String ("false"));
+
+ if (components.contains(info.name)) {
+ qCritical("Could not register component! Component with identifier %s already "
+ "registered", qPrintable(info.name));
+ } else {
+ components.insert(info.name, component.take());
+ }
+ }
+ } else {
+ foreach (KDUpdater::Update * const update, updates) {
+ const QString newComponentName = update->data(QLatin1String("Name")).toString();
+ const int indexOfPackage = packagesInfo.findPackageInfo(newComponentName);
+
+ const QString localPath = QInstaller::pathFromUrl(update->sourceInfo().url);
+ static QString lastLocalPath;
+ if (lastLocalPath != localPath)
+ verbose() << "Url is : " << localPath << std::endl;
+
+ lastLocalPath = localPath;
+ QScopedPointer<QInstaller::Component> component(new QInstaller::Component(update, this));
+ if (indexOfPackage > -1) {
+ component->setValue(QLatin1String("InstalledVersion"),
+ packagesInfo.packageInfo(indexOfPackage).version);
+ }
+
+ const Repository repo = metaInfoJob.repositoryForTemporaryDirectory(localPath);
+ component->setRepositoryUrl(repo.url());
+
+ component->setValue(QLatin1String("Important"),
+ update->data(QLatin1String("Important")).toString());
+
+ component->setValue(QLatin1String("ForcedInstallation"),
+ update->data(QLatin1String("ForcedInstallation")).toString());
+
+ component->setValue(QLatin1String("UpdateText"),
+ update->data(QLatin1String("UpdateText")).toString());
+
+ component->setValue(QLatin1String("RequiresAdminRights"),
+ update->data(QLatin1String("RequiresAdminRights")).toString());
+
+ component->setValue(QLatin1String("NewComponent"),
+ update->data(QLatin1String("NewComponent")).toString());
+
+ const QStringList uis = update->data(QLatin1String("UserInterfaces")).toString()
+ .split(QString::fromLatin1(","), QString::SkipEmptyParts);
+ if (!uis.isEmpty()) {
+ verbose() << "Loading User Interface definitions for component " << newComponentName
+ << std::endl;
+ component->loadUserInterfaces(QDir(QString::fromLatin1("%1/%2").arg(localPath,
+ newComponentName)), uis);
+ }
+
+ const QStringList qms = update->data(QLatin1String("Translations")).toString()
+ .split(QString::fromLatin1(","), QString::SkipEmptyParts);
+ if (!qms.isEmpty()) {
+ verbose() << "Loading translations for component " << newComponentName << std::endl;
+ component->loadTranslations(QDir(QString::fromLatin1("%1/%2").arg(localPath,
+ newComponentName)), qms);
+ }
+
+ QHash<QString, QVariant> licenseHash = update->data(QLatin1String("Licenses")).toHash();
+ if (!licenseHash.isEmpty()) {
+ verbose() << "Loading licenses for component " << newComponentName << std::endl;
+ component->loadLicenses(QString::fromLatin1("%1/%2/").arg(localPath,
+ newComponentName), licenseHash);
+ }
+
+ bool isUpdate = true;
+ // the package manager should preselect the currently installed packages
+ if (isPackageManager()) {
+ const bool selected = indexOfPackage > -1;
+
+ component->setValue(QLatin1String("PreviousState"),
+ selected ? QLatin1String("Installed") : QLatin1String("Uninstalled"));
+ component->setValue(QLatin1String("CurrentState"),
+ component->value(QLatin1String("PreviousState")));
+
+ if (selected)
+ componentsToSelectInstaller.append(component.data());
+
+ const QString pkgVersion = packagesInfo.packageInfo(indexOfPackage).version;
+ const QString updateVersion = update->data(QLatin1String("Version")).toString();
+ if (KDUpdater::compareVersion(updateVersion, pkgVersion) <= 0)
+ isUpdate = false;
+
+ // It is quite possible that we may have already installed the update.
+ // Lets check the last update date of the package and the release date
+ // of the update. This way we can compare and figure out if the update
+ // has been installed or not.
+ const QDate updateDate = update->data(QLatin1String("ReleaseDate")).toDate();
+ const QDate pkgDate = packagesInfo.packageInfo(indexOfPackage).lastUpdateDate;
+ if (pkgDate > updateDate)
+ isUpdate = false;
+ }
+
+ if (!components.contains(newComponentName)) {
+ const QString script = update->data(QLatin1String("Script")).toString();
+ if (!script.isEmpty()) {
+ scripts.insert(component.data(), QString::fromLatin1("%1/%2/%3").arg(localPath,
+ newComponentName, script) );
+ }
+
+ Component *tmpComponent = component.data();
+ const bool isInstalled = tmpComponent->value(QLatin1String("PreviousState"))
+ == QLatin1String("Installed");
+ const bool isNewComponent = tmpComponent->value(QLatin1String("NewComponent"))
+ == QLatin1String("true") ? true : false;
+ const bool newPackageForUpdater = !isInstalled && isNewComponent;
+ isUpdate = isUpdate && isInstalled;
+
+ if (newPackageForUpdater) {
+ d->m_updaterComponents.push_back(component.take());
+ d->m_componentHash[newComponentName] = tmpComponent;
+ } else {
+ components.insert(newComponentName, component.take());
+ }
+
+ if (isPackageManager() && (isUpdate || newPackageForUpdater)) {
+ if (update->data(QLatin1String("Important")).toBool())
+ containsImportantUpdates = true;
+ componentsToSelectUpdater.append(tmpComponent);
+ d->m_packageManagerComponents.push_back(tmpComponent);
+ }
+ } else {
+ qCritical("Could not register component! Component with identifier %s already "
+ "registered", qPrintable(newComponentName));
+ }
+ }
+ }
+
+ if (containsImportantUpdates) {
+ foreach (QInstaller::Component *c, d->m_packageManagerComponents) {
+ if (c->value(QLatin1String("Important")).toLower() == QLatin1String ("false")
+ || c->value(QLatin1String("Important")).isEmpty()) {
+ if (isPackageManager())
+ d->m_packageManagerComponents.removeAll(c);
+ componentsToSelectUpdater.removeAll(c);
+ }
+ }
+ }
+
+ // now append all components to their respective parents
+ QMap<QString, QInstaller::Component*>::const_iterator it;
+ for (it = components.begin(); !d->linearComponentList && it != components.end(); ++it) {
+ QInstaller::Component* const comp = *it;
+ QString id = it.key();
+ while (!id.isEmpty() && comp->parentComponent() == 0) {
+ id = id.section(QChar::fromLatin1('.'), 0, -2);
+ if (components.contains(id))
+ components[id]->appendComponent(comp);
+ }
+ }
+
+ // append all components w/o parent to the direct list
+ for (it = components.begin(); it != components.end(); ++it) {
+ if (d->linearComponentList || (*it)->parentComponent() == 0)
+ appendComponent(*it);
+ }
+
+ // after everything is set up, load the scripts
+ QMapIterator< QInstaller::Component*, QString > scriptIt(scripts);
+ while (scriptIt.hasNext()) {
+ scriptIt.next();
+ QInstaller::Component* const component = scriptIt.key();
+ const QString script = scriptIt.value();
+ verbose() << "Loading script for component " << component->name() << " (" << script << ")"
+ << std::endl;
+ component->loadComponentScript(script);
+ }
+
+ // select all components in the updater model
+ foreach (QInstaller::Component* const i, componentsToSelectUpdater)
+ i->setSelected(true, UpdaterMode, Component::InitializeComponentTreeSelectMode);
+
+ // select all components in the package manager model
+ foreach (QInstaller::Component* const i, componentsToSelectInstaller)
+ i->setSelected(true, InstallerMode, Component::InitializeComponentTreeSelectMode);
+
+ emit updaterComponentsAdded(d->m_packageManagerComponents);
+ emit componentsAdded(d->m_components);
+}
+
+void Installer::appendComponent(Component *component)
+{
+ d->m_components.append(component);
+ d->m_componentHash[component->name()] = component;
+ emit componentAdded(component);
+}
+
+int Installer::componentCount(RunModes runMode) const
+{
+ if (runMode == UpdaterMode)
+ return d->m_packageManagerComponents.size();
+ return d->m_components.size();
+}
+
+Component *Installer::component(int i, RunModes runMode) const
+{
+ if (runMode == UpdaterMode)
+ return d->m_packageManagerComponents.at(i);
+ return d->m_components.at(i);
+}
+
+Component *Installer::component(const QString &name) const
+{
+ return d->m_componentHash.contains(name) ? d->m_componentHash[name] : 0;
+}
+
+QList<Component*> Installer::components(bool recursive, RunModes runMode) const
+{
+ if (runMode == UpdaterMode)
+ return d->m_packageManagerComponents;
+
+ if (!recursive)
+ return d->m_components;
+
+ QList<Component*> result;
+ QList<Component*>::const_iterator it;
+ for (it = d->m_components.begin(); it != d->m_components.end(); ++it) {
+ result.push_back(*it);
+ result += (*it)->components(true);
+ }
+
+ if (runMode == AllMode) {
+ for (it = d->m_updaterComponents.begin(); it != d->m_updaterComponents.end(); ++it) {
+ result.push_back(*it);
+ result += (*it)->components(false);
+ }
+ }
+
+ return result;
+}
+
+QList<Component*> Installer::componentsToInstall(bool recursive, bool sort, RunModes runMode) const
+{
+ QList<Component*> availableComponents = components(recursive, runMode);
+ if (sort) {
+ std::sort(availableComponents.begin(), availableComponents.end(),
+ Component::PriorityLessThan());
+ }
+
+ QList<Component*>::const_iterator it;
+ QList<Component*> componentsToInstall;
+ for (it = availableComponents.begin(); it != availableComponents.end(); ++it) {
+ Component* const comp = *it;
+ if (!comp->isSelected(runMode))
+ continue;
+
+ // it was already installed before, so don't add it
+ if (comp->value(QLatin1String("PreviousState")) == QLatin1String("Installed")
+ && runMode == InstallerMode) // TODO: is the last condition right ????
+ continue;
+
+ appendComponentAndMissingDependencies(componentsToInstall, comp);
+ }
+
+ return componentsToInstall;
+}
+
+static bool componentMatches(const Component *component, const QString &name,
+ const QString& version = QString())
+{
+ if (!name.isEmpty() && component->name() != name)
+ return false;
+
+ if (version.isEmpty())
+ return true;
+
+ return Installer::versionMatches(component->value(QLatin1String("Version")), version);
+}
+
+static Component* subComponentByName(const Installer *installer, const QString &name,
+ const QString &version = QString(), Component *check = 0)
+{
+ if (check != 0 && componentMatches(check, name, version))
+ return check;
+
+ const QList<Component*> comps = check == 0 ? installer->components() : check->components();
+ for (QList<Component*>::const_iterator it = comps.begin(); it != comps.end(); ++it) {
+ Component* const result = subComponentByName(installer, name, version, *it);
+ if (result != 0)
+ return result;
+ }
+
+ const QList<Component*> uocomps =
+ check == 0 ? installer->components(false, UpdaterMode) : check->components(false, UpdaterMode);
+ for (QList<Component*>::const_iterator it = uocomps.begin(); it != uocomps.end(); ++it) {
+ Component* const result = subComponentByName(installer, name, version, *it);
+ if (result != 0)
+ return result;
+ }
+
+ return 0;
+}
+
+void Installer::setLinearComponentList(bool showlinear)
+{
+ d->linearComponentList = showlinear;
+}
+
+bool Installer::hasLinearComponentList() const
+{
+ return d->linearComponentList;
+}
+
+/*!
+ Returns a component matching \a name. \a name can also contains a version requirement.
+ E.g. "com.nokia.sdk.qt" returns any component with that name, "com.nokia.sdk.qt->=4.5" requires
+ the returned component to have at least version 4.5.
+ If no component matches the requirement, 0 is returned.
+*/
+Component* Installer::componentByName(const QString &name) const
+{
+ if (name.contains(QChar::fromLatin1('-'))) {
+ // the last part is considered to be the version, then
+ const QString version = name.section(QLatin1Char('-'), 1);
+ return subComponentByName(this, name.section(QLatin1Char('-'), 0, 0), version);
+ }
+
+ QHash< QString, QInstaller::Component* >::ConstIterator it = d->m_componentHash.constFind(name);
+ Component * comp = 0;
+ if (it != d->m_componentHash.constEnd())
+ comp = *it;
+ if (d->m_updaterComponents.contains(comp))
+ return comp;
+
+ return subComponentByName(this, name);
+}
+
+/*!
+ Returns a list of packages depending on \a component.
+*/
+QList<Component*> Installer::dependees(const Component *component) const
+{
+ QList<Component*> result;
+
+ const QList<Component*> allComponents = components(true, AllMode);
+ for (QList<Component*>::const_iterator it = allComponents.begin(); it != allComponents.end(); ++it) {
+ Component* const c = *it;
+
+ const QStringList deps = c->value(QString::fromLatin1("Dependencies"))
+ .split(QChar::fromLatin1(','), QString::SkipEmptyParts);
+
+ const QLatin1Char dash('-');
+ for (QStringList::const_iterator it2 = deps.begin(); it2 != deps.end(); ++it2) {
+ // the last part is considered to be the version, then
+ const QString id = it2->contains(dash) ? it2->section(dash, 0, 0) : *it2;
+ const QString version = it2->contains(dash) ? it2->section(dash, 1) : QString();
+ if (componentMatches(component, id, version))
+ result.push_back(c);
+ }
+ }
+
+ return result;
+}
+
+InstallerSettings Installer::settings() const
+{
+ return d->m_settings;
+}
+
+/*!
+ Returns a list of dependencies for \a component.
+ If there's a dependency which cannot be fullfilled, the list contains 0 values.
+*/
+QList<Component*> Installer::dependencies(const Component *component,
+ QStringList *missingPackageNames) const
+{
+ QList<Component*> result;
+ const QStringList deps = component->value(QString::fromLatin1("Dependencies"))
+ .split(QChar::fromLatin1(','), QString::SkipEmptyParts);
+
+ for (QStringList::const_iterator it = deps.begin(); it != deps.end(); ++it) {
+ const QString name = *it;
+ Component* comp = componentByName(*it);
+ if (!comp && missingPackageNames)
+ missingPackageNames->append(name);
+ else
+ result.push_back(comp);
+ }
+ return result;
+}
+
+/*!
+ Returns the list of all missing (not installed) dependencies for \a component.
+*/
+QList<Component*> Installer::missingDependencies(const Component *component) const
+{
+ QList<Component*> result;
+ const QStringList deps = component->value(QString::fromLatin1("Dependencies"))
+ .split(QChar::fromLatin1(','), QString::SkipEmptyParts);
+
+ const QLatin1Char dash('-');
+ for (QStringList::const_iterator it = deps.begin(); it != deps.end(); ++it) {
+ const bool containsVersionString = it->contains(dash);
+ const QString version = containsVersionString ? it->section(dash, 1) : QString();
+ const QString name = containsVersionString ? it->section(dash, 0, 0) : *it;
+
+ bool installed = false;
+ const QList<Component*> compList = components(true);
+ foreach (const Component* comp, compList) {
+ if (!name.isEmpty() && comp->name() == name && !version.isEmpty()) {
+ if (Installer::versionMatches(comp->value(QLatin1String("InstalledVersion")), version))
+ installed = true;
+ } else if (comp->name() == name) {
+ installed = true;
+ }
+ }
+
+ foreach (const Component *comp, d->m_updaterComponents) {
+ if (!name.isEmpty() && comp->name() == name && !version.isEmpty()) {
+ if (Installer::versionMatches(comp->value(QLatin1String("InstalledVersion")), version))
+ installed = true;
+ } else if (comp->name() == name) {
+ installed = true;
+ }
+ }
+
+ if (!installed) {
+ if (Component *comp = componentByName(name))
+ result.push_back(comp);
+ }
+ }
+ return result;
+}
+
+/*!
+ This method tries to gain admin rights. On success, it returns true.
+*/
+bool Installer::gainAdminRights()
+{
+ if (AdminAuthorization::hasAdminRights())
+ return true;
+
+ d->engineClientHandler->setActive(true);
+ if (!d->engineClientHandler->isActive())
+ throw Error(QObject::tr("Error while elevating access rights."));
+ return true;
+}
+
+/*!
+ This method drops gained admin rights.
+*/
+void Installer::dropAdminRights()
+{
+ d->engineClientHandler->setActive(false);
+}
+
+/*!
+ Return true, if a process with \a name is running. On Windows, the comparision is case-insensitive.
+*/
+bool Installer::isProcessRunning(const QString &name) const
+{
+ QList<KDSysInfo::ProcessInfo>::const_iterator it;
+ const QList<KDSysInfo::ProcessInfo> processes = KDSysInfo::runningProcesses();
+ for (it = processes.begin(); it != processes.end(); ++it) {
+#ifndef Q_WS_WIN
+ if (it->name == name)
+ return true;
+ const QFileInfo fi(it->name);
+ if (fi.fileName() == name || fi.baseName() == name)
+ return true;
+#else
+ if (it->name.toLower() == name.toLower())
+ return true;
+ const QFileInfo fi(it->name);
+ if (fi.fileName().toLower() == name.toLower() || fi.baseName().toLower() == name.toLower())
+ return true;
+#endif
+ }
+ return false;
+}
+
+/*!
+ Executes a program.
+
+ \param program The program that should be executed.
+ \param arguments Optional list of arguments.
+ \param stdIn Optional stdin the program reads.
+ \return If the command could not be executed, an empty QList, otherwise the output of the
+ command as first item, the return code as second item.
+ \note On Unix, the output is just the output to stdout, not to stderr.
+*/
+QList<QVariant> Installer::execute(const QString &program, const QStringList &arguments,
+ const QString &stdIn) const
+{
+ QProcess p;
+ p.start(program, arguments, stdIn.isNull() ? QIODevice::ReadOnly : QIODevice::ReadWrite);
+ if (!p.waitForStarted())
+ return QList< QVariant >();
+
+ if (!stdIn.isNull()) {
+ p.write(stdIn.toLatin1());
+ p.closeWriteChannel();
+ }
+
+ QEventLoop loop;
+ connect(&p, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
+ loop.exec();
+
+ return QList< QVariant >() << QString::fromLatin1(p.readAllStandardOutput()) << p.exitCode();
+}
+
+/*!
+ Returns an environment variable.
+*/
+QString Installer::environmentVariable(const QString &name) const
+{
+#ifdef Q_WS_WIN
+ const LPCWSTR n = (LPCWSTR) name.utf16();
+ LPTSTR buff = (LPTSTR) malloc(4096 * sizeof(TCHAR));
+ DWORD getenvret = GetEnvironmentVariable(n, buff, 4096);
+ const QString actualValue = getenvret != 0
+ ? QString::fromUtf16((const unsigned short *) buff) : QString();
+ free(buff);
+ return actualValue;
+#else
+ const char *pPath = name.isEmpty() ? 0 : getenv(name.toLatin1());
+ return pPath ? QLatin1String(pPath) : QString();
+#endif
+}
+
+/*!
+ Instantly performns an operation \a name with \a arguments.
+ \sa Component::addOperation
+*/
+bool Installer::performOperation(const QString &name, const QStringList &arguments)
+{
+ QScopedPointer<KDUpdater::UpdateOperation> op(KDUpdater::UpdateOperationFactory::instance()
+ .create(name));
+ if (!op.data())
+ return false;
+
+ op->setArguments(arguments);
+ op->backup();
+ if (!performOperationThreaded(op.data())) {
+ performOperationThreaded(op.data(), Undo);
+ return false;
+ }
+ return true;
+}
+
+/*!
+ Returns true when \a version matches the \a requirement.
+ \a requirement can be a fixed version number or it can be prefix by the comparaters '>', '>=',
+ '<', '<=' and '='.
+*/
+bool Installer::versionMatches(const QString &version, const QString &requirement)
+{
+ QRegExp compEx(QLatin1String("([<=>]+)(.*)"));
+ const QString comparator = compEx.exactMatch(requirement) ? compEx.cap(1) : QString::fromLatin1("=");
+ const QString ver = compEx.exactMatch(requirement) ? compEx.cap(2) : requirement;
+
+ const bool allowEqual = comparator.contains(QLatin1Char('='));
+ const bool allowLess = comparator.contains(QLatin1Char('<'));
+ const bool allowMore = comparator.contains(QLatin1Char('>'));
+
+ if (allowEqual && version == ver)
+ return true;
+
+ if (allowLess && KDUpdater::compareVersion(ver, version) > 0)
+ return true;
+
+ if (allowMore && KDUpdater::compareVersion(ver, version) < 0)
+ return true;
+
+ return false;
+}
+
+/*!
+ Finds a library named \a name in \a pathes.
+ If \a pathes is empty, it gets filled with platform dependent default pathes.
+ The resulting path is stored in \a library.
+ This method can be used by scripts to check external dependencies.
+*/
+QString Installer::findLibrary(const QString &name, const QStringList &pathes)
+{
+ QStringList findPathes = pathes;
+#if defined(Q_WS_WIN)
+ return findPath(QString::fromLatin1("%1.lib").arg(name), findPathes);
+#elif defined(Q_WS_MAC)
+ if (findPathes.isEmpty()) {
+ findPathes.push_back(QLatin1String("/lib"));
+ findPathes.push_back(QLatin1String("/usr/lib"));
+ findPathes.push_back(QLatin1String("/usr/local/lib"));
+ findPathes.push_back(QLatin1String("/opt/local/lib"));
+ }
+
+ const QString dynamic = findPath(QString::fromLatin1("lib%1.dylib").arg(name), findPathes);
+ if (!dynamic.isEmpty())
+ return dynamic;
+ return findPath(QString::fromLatin1("lib%1.a").arg(name), findPathes);
+#else
+ if (findPathes.isEmpty()) {
+ findPathes.push_back(QLatin1String("/lib"));
+ findPathes.push_back(QLatin1String("/usr/lib"));
+ findPathes.push_back(QLatin1String("/usr/local/lib"));
+ findPathes.push_back(QLatin1String("/opt/local/lib"));
+ }
+ const QString dynamic = findPath(QString::fromLatin1("lib%1.so*").arg(name), findPathes);
+ if (!dynamic.isEmpty())
+ return dynamic;
+ return findPath(QString::fromLatin1("lib%1.a").arg(name), findPathes);
+#endif
+}
+
+/*!
+ Tries to find a file name \a name in one of \a pathes.
+ The resulting path is stored in \a path.
+ This method can be used by scripts to check external dependencies.
+*/
+QString Installer::findPath(const QString &name, const QStringList &pathes)
+{
+ for (QStringList::const_iterator it = pathes.begin(); it != pathes.end(); ++it) {
+ const QDir dir(*it);
+ const QStringList entries = dir.entryList(QStringList() << name, QDir::Files | QDir::Hidden);
+ if (entries.isEmpty())
+ continue;
+
+ return dir.absoluteFilePath(entries.first());
+ }
+ return QString();
+}
+
+/*!
+ sets the "installerbase" binary to use when writing the package manager/uninstaller.
+ Set this if an update to installerbase is available.
+ If not set, the executable segment of the running un/installer will be used.
+*/
+void Installer::setInstallerBaseBinary(const QString &path)
+{
+ d->m_forceRestart = true;
+ d->installerBaseBinaryUnreplaced = path;
+}
+
+/*!
+ Returns the installer value for \a key. If \a key is not known to the system, \a defaultValue is
+ returned. Additionally, on Windows, \a key can be a registry key.
+*/
+QString Installer::value(const QString &key, const QString &defaultValue) const
+{
+#ifdef Q_WS_WIN
+ if (!d->m_vars.contains(key)) {
+ static const QRegExp regex(QLatin1String("\\\\|/"));
+ const QString filename = key.section(regex, 0, -2);
+ const QString regKey = key.section(regex, -1);
+ const QSettings registry(filename, QSettings::NativeFormat);
+ if (!filename.isEmpty() && !regKey.isEmpty() && registry.contains(regKey))
+ return registry.value(regKey).toString();
+ }
+#else
+ if (key == QLatin1String("TargetDir")) {
+ const QString dir = d->m_vars.value(key, defaultValue);
+ if (dir.startsWith(QLatin1String("~/")))
+ return QDir::home().absoluteFilePath(dir.mid(2));
+ else
+ return dir;
+ }
+#endif
+ return d->m_vars.value(key, defaultValue);
+}
+
+/*!
+ Sets the installer value for \a key to \a value.
+*/
+void Installer::setValue(const QString &key, const QString &value)
+{
+ if (d->m_vars.value(key) == value)
+ return;
+
+ d->m_vars.insert(key, value);
+ emit valueChanged(key, value);
+}
+
+/*!
+ Returns true, when the installer contains a value for \a key.
+*/
+bool Installer::containsValue(const QString &key) const
+{
+ return d->m_vars.contains(key);
+}
+
+void Installer::setSharedFlag(const QString &key, bool value)
+{
+ d->m_sharedFlags.insert(key, value);
+}
+
+bool Installer::sharedFlag(const QString &key) const
+{
+ return d->m_sharedFlags.value(key, false);
+}
+
+bool Installer::isVerbose() const
+{
+ return QInstaller::isVerbose();
+}
+
+void Installer::setVerbose(bool on)
+{
+ QInstaller::setVerbose(on);
+}
+
+int Installer::status() const
+{
+ return d->m_status;
+}
+/*!
+ returns true if at least one complete installation/update
+ was successfull, even if the user cancelled the newest
+ installation process.
+*/
+bool Installer::finishedWithSuccess() const
+{
+ return (d->m_status == InstallerSucceeded) || d->m_needToWriteUninstaller;
+}
+
+void Installer::interrupt()
+{
+ verbose() << "INTERRUPT INSTALLER" << std::endl;
+ d->setStatus(InstallerCanceledByUser);
+ emit installationInterrupted();
+}
+
+void Installer::setCanceled()
+{
+ d->setStatus(InstallerCanceledByUser);
+}
+
+/*!
+ Replaces all variables within \a str by their respective values and
+ returns the result.
+*/
+QString Installer::replaceVariables(const QString &str) const
+{
+ return d->replaceVariables(str);
+}
+
+/*!
+ Replaces all variables in any of \a str by their respective values and
+ returns the results.
+ \overload
+*/
+QStringList Installer::replaceVariables(const QStringList &str) const
+{
+ QStringList result;
+ for (QStringList::const_iterator it = str.begin(); it != str.end(); ++it)
+ result.push_back(d->replaceVariables(*it));
+
+ return result;
+}
+
+/*!
+ Replaces all variables within \a ba by their respective values and
+ returns the result.
+ \overload
+*/
+QByteArray Installer::replaceVariables(const QByteArray &ba) const
+{
+ return d->replaceVariables(ba);
+}
+
+/*!
+ Returns the path to the installer binary.
+*/
+QString Installer::installerBinaryPath() const
+{
+ return d->installerBinaryPath();
+}
+
+/*!
+ Returns true when this is the installer running.
+*/
+bool Installer::isInstaller() const
+{
+ return d->isInstaller();
+}
+
+/*!
+ Returns true when this is the uninstaller running.
+*/
+bool Installer::isUninstaller() const
+{
+ return d->isUninstaller();
+}
+
+/*!
+ Returns true when this is the package manager running.
+*/
+bool Installer::isPackageManager() const
+{
+ return d->isPackageManager();
+}
+
+
+/*!
+ Returns true if this is an offline-only installer.
+*/
+bool Installer::isOfflineOnly() const
+{
+ QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
+ return confInternal.value(QLatin1String("offlineOnly")).toBool();
+}
+
+void Installer::setPackageManager()
+{
+ d->packageManagingMode = true;
+}
+
+/*!
+ Returns thrue when this is neither an installer nor an uninstaller running.
+ Must be an updater, then.
+*/
+bool Installer::isUpdater() const
+{
+ return !d->isInstaller() && !d->isUninstaller();
+}
+
+/*!
+ Runs the installer. Returns true on success, false otherwise.
+*/
+bool Installer::runInstaller()
+{
+ try {
+ d->runInstaller();
+ return true;
+ } catch (...) {
+ return false;
+ }
+}
+
+/*!
+ Runs the uninstaller. Returns true on success, false otherwise.
+*/
+bool Installer::runUninstaller()
+{
+ try {
+ d->runUninstaller();
+ return true;
+ } catch (...) {
+ return false;
+ }
+}
+
+/*!
+ Runs the package updater. Returns true on success, false otherwise.
+*/
+bool Installer::runPackageUpdater()
+{
+ try {
+ d->runPackageUpdater();
+ return true;
+ } catch (...) {
+ return false;
+ }
+}
+
+/*!
+ \internal
+ Calls languangeChanged on all components.
+*/
+void Installer::languageChanged()
+{
+ const QList<Component*> comps = components(true);
+ foreach (Component* component, comps)
+ component->languageChanged();
+}
+
+/*!
+ Runs the installer or uninstaller, depending on the type of this binary.
+*/
+bool Installer::run()
+{
+ try {
+ if (isInstaller())
+ d->runInstaller();
+ else if (isUninstaller())
+ d->runUninstaller();
+ else if (isPackageManager())
+ d->runPackageUpdater();
+ return true;
+ } catch (const Error &err) {
+ verbose() << "Caught Installer Error: " << err.message() << std::endl;
+ return false;
+ }
+}
+
+/*!
+ Returns the path name of the ininstaller binary.
+*/
+QString Installer::uninstallerName() const
+{
+ return d->uninstallerName();
+}
+
+bool Installer::setAndParseLocalComponentsFile(KDUpdater::PackagesInfo &packagesInfo)
+{
+ packagesInfo.setFileName(d->localComponentsXmlPath());
+ const QString localComponentsXml = d->localComponentsXmlPath();
+
+ // handle errors occured by loading components.xml
+ QFileInfo componentFileInfo(localComponentsXml);
+ int silentRetries = d->m_silentRetries;
+ while (!componentFileInfo.exists()) {
+ if (silentRetries > 0) {
+ --silentRetries;
+ } else {
+ Status status = handleComponentsFileSetOrParseError(localComponentsXml);
+ if (status == InstallerCanceledByUser)
+ return false;
+ }
+ packagesInfo.setFileName(localComponentsXml);
+ }
+
+ silentRetries = d->m_silentRetries;
+ while (packagesInfo.error() != KDUpdater::PackagesInfo::NoError) {
+ if (silentRetries > 0) {
+ --silentRetries;
+ } else {
+ Status status = handleComponentsFileSetOrParseError(localComponentsXml);
+ if (status == InstallerCanceledByUser)
+ return false;
+ }
+ packagesInfo.setFileName(localComponentsXml);
+ }
+
+ silentRetries = d->m_silentRetries;
+ while (packagesInfo.error() != KDUpdater::PackagesInfo::NoError) {
+ if (silentRetries > 0) {
+ --silentRetries;
+ } else {
+ bool retry = false;
+ if (packagesInfo.error() != KDUpdater::PackagesInfo::InvalidContentError
+ && packagesInfo.error() != KDUpdater::PackagesInfo::InvalidXmlError) {
+ retry = true;
+ }
+ Status status = handleComponentsFileSetOrParseError(componentFileInfo.fileName(),
+ packagesInfo.errorString(), retry);
+ if (status == InstallerCanceledByUser)
+ return false;
+ }
+ packagesInfo.setFileName(localComponentsXml);
+ }
+
+ return true;
+}
+
+Installer::Status Installer::handleComponentsFileSetOrParseError(const QString &arg1,
+ const QString &arg2, bool withRetry)
+{
+ QMessageBox::StandardButtons buttons = QMessageBox::Cancel;
+ if (withRetry)
+ buttons |= QMessageBox::Retry;
+
+ const QMessageBox::StandardButton button =
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("Error loading component.xml"), tr("Loading error"),
+ tr(arg2.isEmpty() ? "Could not load %1" : "Could not load %1 : %2").arg(arg1, arg2),
+ buttons);
+
+ if (button == QMessageBox::Cancel) {
+ d->m_status = InstallerFailed;
+ return InstallerCanceledByUser;
+ }
+ return InstallerUnfinished;
+}
+
+#include "qinstaller.moc"
diff --git a/installerbuilder/libinstaller/qinstaller.h b/installerbuilder/libinstaller/qinstaller.h
new file mode 100644
index 000000000..008d6b6f0
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstaller.h
@@ -0,0 +1,266 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_H
+#define QINSTALLER_H
+
+#include <QtCore/QAbstractItemModel>
+#include <QtCore/QObject>
+#include <QtCore/QStringList>
+#include <QtCore/QVector>
+#include <QtCore/QHash>
+
+#include <QtGui/QMessageBox>
+
+#include <QtScript/QScriptable>
+#include <QtScript/QScriptValue>
+
+#include "common/repository.h"
+
+#include "installer_global.h"
+
+namespace KDUpdater {
+ class Application;
+ class PackagesInfo;
+ class Update;
+ class UpdateOperation;
+}
+
+class QDir;
+class QFile;
+class QIODevice;
+
+class KDJob;
+
+#define INSTALLERBASE_VERSION "2"
+
+/*
+ * TRANSLATOR QInstaller::Installer
+ */
+namespace QInstaller {
+
+class Component;
+class GetRepositoriesMetaInfoJob;
+class InstallerSettings;
+class MessageBoxHandler;
+
+class INSTALLER_EXPORT Installer : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int status READ status NOTIFY statusChanged)
+ Q_ENUMS(Status WizardPage)
+
+public:
+ explicit Installer(qint64 magicmaker = 0,
+ const QVector<KDUpdater::UpdateOperation*> &performedOperations
+ = QVector< KDUpdater::UpdateOperation*>());
+ ~Installer();
+
+ void writeUninstaller();
+
+ bool run();
+ void reset(const QHash<QString, QString> &params);
+
+ Q_INVOKABLE QList<QVariant> execute(const QString &program,
+ const QStringList &arguments = QStringList(), const QString &stdIn = QString()) const;
+ Q_INVOKABLE QString environmentVariable(const QString &name) const;
+
+ Q_INVOKABLE bool performOperation(const QString &name, const QStringList &arguments);
+
+ Q_INVOKABLE static bool versionMatches(const QString &version, const QString &requirement);
+
+ Q_INVOKABLE static QString findLibrary(const QString &name, const QStringList &pathes = QStringList());
+ Q_INVOKABLE static QString findPath(const QString &name, const QStringList &pathes = QStringList());
+
+ Q_INVOKABLE void setInstallerBaseBinary(const QString &path);
+
+ // parameter handling
+ Q_INVOKABLE void setValue(const QString &key, const QString &value);
+ Q_INVOKABLE QString value(const QString &key, const QString &defaultValue = QString()) const;
+ Q_INVOKABLE bool containsValue(const QString &key) const;
+
+ //a way to have global flags share able from a component script to another one
+ Q_INVOKABLE void setSharedFlag(const QString &key, bool value = true);
+ Q_INVOKABLE bool sharedFlag(const QString &key) const;
+
+ QString replaceVariables(const QString &str) const;
+ QStringList replaceVariables(const QStringList &str) const;
+ QByteArray replaceVariables(const QByteArray &str) const;
+ QString installerBinaryPath() const;
+ QString uninstallerName() const;
+
+ bool isRemoteRepositoryMetaInfoRetrieved() const;
+
+ void setTestChecksum(bool test);
+ bool testChecksum();
+
+ KDUpdater::Application &updaterApplication() const;
+ void setUpdaterApplication(KDUpdater::Application *app);
+
+ void setRemoteRepositories(const QList<Repository> &repositories);
+ void setTemporaryRepositories(const QList<Repository> &repositories, bool replace = false);
+
+ void createComponents(const QList<KDUpdater::Update*> &updates,
+ const GetRepositoriesMetaInfoJob& metaInfoJob);
+
+ Q_INVOKABLE void autoAcceptMessageBoxes();
+ Q_INVOKABLE void autoRejectMessageBoxes();
+ Q_INVOKABLE void setMessageBoxAutomaticAnswer(const QString &identifier, int button);
+
+ Q_INVOKABLE bool isFileExtensionRegistered(const QString &extension) const;
+
+public:
+ // component handling
+ void appendComponent(Component *components);
+ int componentCount(RunModes runMode = InstallerMode) const;
+ Component *component(int i, RunModes runMode = InstallerMode) const;
+ Component *component(const QString &name) const;
+ QList<Component*> components(bool recursive = false, RunModes runMode = InstallerMode) const;
+ QList<Component*> componentsToInstall(bool recursive = false, bool sort = true,
+ RunModes runMode = InstallerMode) const;
+
+ Component *componentByName(const QString &identifier) const;
+ QList<Component*> dependencies(const Component *component,
+ QStringList *missingPackageNames = 0) const;
+ QList<Component*> missingDependencies (const Component *component) const;
+ QList<Component*> dependees(const Component *component) const;
+
+ // convenience
+ Q_INVOKABLE bool isInstaller() const;
+ Q_INVOKABLE bool isUninstaller() const;
+ Q_INVOKABLE bool isUpdater() const;
+ Q_INVOKABLE bool isPackageManager() const;
+ Q_INVOKABLE bool isOfflineOnly() const;
+
+ void setPackageManager();
+
+ bool isVerbose() const;
+ void setVerbose(bool on);
+
+ Q_INVOKABLE bool gainAdminRights();
+ Q_INVOKABLE void dropAdminRights();
+
+ Q_INVOKABLE quint64 requiredDiskSpace() const;
+ Q_INVOKABLE quint64 requiredTemporaryDiskSpace() const;
+
+ Q_INVOKABLE bool isProcessRunning(const QString &name) const;
+
+ InstallerSettings settings() const;
+
+ // status
+ enum Status {
+ InstallerUnfinished,
+ InstallerCanceledByUser,
+ InstallerRunning,
+ InstallerFailed,
+ InstallerSucceeded,
+ };
+ int status() const;
+
+ enum WizardPage {
+ Introduction = 0x1000,
+ TargetDirectory = 0x2000,
+ ComponentSelection = 0x3000,
+ LicenseCheck = 0x4000,
+ StartMenuSelection = 0x5000,
+ ReadyForInstallation = 0x6000,
+ PerformInstallation = 0x7000,
+ InstallationFinished = 0x8000,
+ End = 0xffff
+ };
+
+ Q_INVOKABLE bool addWizardPage(QInstaller::Component *component, const QString &name, int page);
+ Q_INVOKABLE bool removeWizardPage(QInstaller::Component *component, const QString &name);
+ Q_INVOKABLE bool addWizardPageItem(QInstaller::Component *component, const QString &name, int page);
+ Q_INVOKABLE bool removeWizardPageItem(QInstaller::Component *component, const QString &name);
+ Q_INVOKABLE bool setDefaultPageVisible(int page, bool visible);
+
+ void installSelectedComponents();
+ void rollBackInstallation();
+
+ int downloadNeededArchives(RunModes runMode, double partProgressSize/* = double(1)/3 */);
+ QList<Component*> calculateComponentOrder(RunModes runMode = InstallerMode) const;
+ void installComponent(Component *comp, double progressOperationSize);
+
+ void setLinearComponentList(bool showlinear);
+ bool hasLinearComponentList() const;
+
+ bool finishedWithSuccess() const;
+ bool needsRestart() const;
+
+public Q_SLOTS:
+ bool runInstaller();
+ bool runUninstaller();
+ bool runPackageUpdater();
+ void interrupt();
+ void setCanceled();
+ void languageChanged();
+
+ void setCompleteUninstallation(bool complete);
+
+Q_SIGNALS:
+ void componentAdded(QInstaller::Component *comp);
+ void componentsAdded(QList<QInstaller::Component*> components);
+ void updaterComponentsAdded(QList<QInstaller::Component*> components);
+ void componentsAboutToBeCleared();
+ void valueChanged(const QString &key, const QString &value);
+ void statusChanged(QInstaller::Installer::Status);
+ void currentPageChanged(int page);
+ void finishButtonClicked();
+
+
+ void installationStarted();
+ void installationInterrupted();
+ void installationFinished();
+ void updateFinished();
+ void uninstallationStarted();
+ void uninstallationFinished();
+ void titleMessageChanged(const QString &title);
+
+ void wizardPageInsertionRequested(QWidget *widget, Installer::WizardPage page);
+ void wizardPageRemovalRequested(QWidget *widget);
+ void wizardWidgetInsertionRequested(QWidget *widget, Installer::WizardPage page);
+ void wizardWidgetRemovalRequested(QWidget *widget);
+ void wizardPageVisibilityChangeRequested(bool visible, int page);
+
+ void setAutomatedPageSwitchEnabled(bool request);
+
+private:
+ bool setAndParseLocalComponentsFile(KDUpdater::PackagesInfo &packagesInfo);
+ Installer::Status handleComponentsFileSetOrParseError(const QString &arg1,
+ const QString &arg2 = QString(), bool withRetry = true);
+
+private:
+ class Private;
+ Private* const d;
+ friend class Component;
+};
+
+}
+
+Q_DECLARE_METATYPE(QInstaller::Installer*)
+
+#endif // QINSTALLER_H
diff --git a/installerbuilder/libinstaller/qinstallercomponent.cpp b/installerbuilder/libinstaller/qinstallercomponent.cpp
new file mode 100644
index 000000000..78fc94f84
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstallercomponent.cpp
@@ -0,0 +1,1103 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "qinstallercomponent.h"
+#include "qinstallerglobal.h"
+#include "messageboxhandler.h"
+
+#include "common/errors.h"
+
+#include "lib7z_facade.h"
+
+#include <KDUpdater/Update>
+#include <KDUpdater/UpdateOperation>
+#include <KDUpdater/UpdateOperationFactory>
+
+#include <QApplication>
+#include <QDesktopServices>
+#include <QDir>
+#include <QDirIterator>
+#include <QHash>
+#include <QMessageBox>
+#include <QtCore/QPair>
+#include <QScriptEngine>
+#include <QScriptValue>
+#include <QTextStream>
+#include <QTranslator>
+#include <QUiLoader>
+
+#include <memory>
+
+#include "common/utils.h"
+#include "fsengineclient.h"
+
+using namespace QInstaller;
+
+/*
+TRANSLATOR QInstaller::Component
+*/
+
+/*!
+ \class QInstaller::Component
+ Component describes a component within the installer.
+*/
+
+class QInstaller::Component::Private
+{
+ QInstaller::Component* const q;
+public:
+ Private( Installer* installer, QInstaller::Component* qq )
+ : q( qq ),
+ m_installer( installer ),
+ m_parent( 0 ),
+ m_offsetInInstaller( 0 ),
+ autoCreateOperations( true ),
+ operationsCreated( false ),
+ removeBeforeUpdate( true ),
+ enabled( true ),
+ isCheckedFromUpdater( false ),
+ m_newlyInstalled ( false ),
+ operationsCreatedSuccessfully( true ),
+ minimumProgressOperation(0),
+ m_licenseOperation(0)
+ {
+ }
+
+ static QMap< const Component*, Qt::CheckState > cachedCheckStates;
+
+ Installer *m_installer;
+ QHash<QString,QString> m_vars;
+ QList< Component* > m_components;
+ QList< KDUpdater::UpdateOperation* > operations;
+
+ QList< QPair< QString, bool > > pathesForUninstallation;
+
+ QMap< QString, QWidget* > userInterfaces;
+
+ QUrl repositoryUrl;
+ QStringList downloadableArchives;
+ QStringList stopProcessForUpdateRequests;
+
+ Component* m_parent;
+
+ // filled before intaller runs
+ qint64 m_offsetInInstaller;
+
+ bool autoCreateOperations;
+ bool operationsCreated;
+
+ bool removeBeforeUpdate;
+
+ bool enabled;
+ bool isCheckedFromUpdater;
+
+ bool m_newlyInstalled;
+
+ bool operationsCreatedSuccessfully;
+
+ QScriptEngine scriptEngine;
+ QScriptValue scriptComponent;
+
+ QHash< QString, bool > unexistingScriptMethods;
+
+ void init();
+ void setSelectedOnComponentList(const QList<Component*> &componentList,
+ bool selected, RunModes runMode, SelectMode selectMode);
+ KDUpdater::UpdateOperation* minimumProgressOperation;
+
+ // < display name, < file name, file content > >
+ QHash<QString, QPair<QString, QString> > m_licenses;
+ KDUpdater::UpdateOperation *m_licenseOperation;
+};
+
+QMap< const Component*, Qt::CheckState > Component::Private::cachedCheckStates;
+
+void Component::Private::init()
+{
+ // register translation stuff
+ scriptEngine.installTranslatorFunctions();
+
+ // register QMessageBox::StandardButton enum in the script connection
+ registerMessageBox( &scriptEngine );
+
+ // register QDesktopServices in the script cennoction
+ QScriptValue desktopServices = scriptEngine.newArray();
+ desktopServices.setProperty( QLatin1String( "DesktopLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::DesktopLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "DocumentsLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::DocumentsLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "FontsLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::FontsLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "ApplicationsLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::ApplicationsLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "MusicLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::MusicLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "MoviesLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::MoviesLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "PicturesLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::PicturesLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "TempLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::TempLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "HomeLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::HomeLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "DataLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::DataLocation ) ) );
+ desktopServices.setProperty( QLatin1String( "CacheLocation" ), scriptEngine.newVariant( static_cast< int >( QDesktopServices::CacheLocation ) ) );
+
+ desktopServices.setProperty( QLatin1String( "openUrl" ), scriptEngine.newFunction( qDesktopServicesOpenUrl ) );
+ desktopServices.setProperty( QLatin1String( "displayName" ), scriptEngine.newFunction( qDesktopServicesDisplayName ) );
+ desktopServices.setProperty( QLatin1String( "storageLocation" ), scriptEngine.newFunction( qDesktopServicesStorageLocation ) );
+ scriptEngine.globalObject().setProperty( QLatin1String( "QDesktopServices" ), desktopServices );
+
+ // register ::WizardPage enum in the script connection
+ QScriptValue qinstaller = scriptEngine.newArray();
+ qinstaller.setProperty( QLatin1String( "Introduction" ), scriptEngine.newVariant( static_cast< int >( Installer::Introduction ) ) );
+ qinstaller.setProperty( QLatin1String( "LicenseCheck" ), scriptEngine.newVariant( static_cast< int >( Installer::LicenseCheck ) ) );
+ qinstaller.setProperty( QLatin1String( "TargetDirectory" ), scriptEngine.newVariant( static_cast< int >( Installer::TargetDirectory ) ) );
+ qinstaller.setProperty( QLatin1String( "ComponentSelection" ), scriptEngine.newVariant( static_cast< int >( Installer::ComponentSelection ) ) );
+ qinstaller.setProperty( QLatin1String( "StartMenuSelection" ), scriptEngine.newVariant( static_cast< int >( Installer::StartMenuSelection ) ) );
+ qinstaller.setProperty( QLatin1String( "ReadyForInstallation" ), scriptEngine.newVariant( static_cast< int >( Installer::ReadyForInstallation ) ) );
+ qinstaller.setProperty( QLatin1String( "PerformInstallation" ), scriptEngine.newVariant( static_cast< int >( Installer::PerformInstallation ) ) );
+ qinstaller.setProperty( QLatin1String( "InstallationFinished" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallationFinished ) ) );
+ qinstaller.setProperty( QLatin1String( "End" ), scriptEngine.newVariant( static_cast< int >( Installer::End ) ) );
+
+ // register ::Status enum in the script connection
+ qinstaller.setProperty( QLatin1String( "InstallerUnfinished" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallerUnfinished ) ) );
+ qinstaller.setProperty( QLatin1String( "InstallerCanceledByUser" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallerCanceledByUser ) ) );
+ qinstaller.setProperty( QLatin1String( "InstallerFailed" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallerFailed ) ) );
+ qinstaller.setProperty( QLatin1String( "InstallerSucceeded" ), scriptEngine.newVariant( static_cast< int >( Installer::InstallerSucceeded ) ) );
+
+ scriptEngine.globalObject().setProperty( QLatin1String( "QInstaller" ), qinstaller );
+
+ scriptEngine.globalObject().setProperty( QLatin1String( "component" ), scriptEngine.newQObject( q ) );
+ QScriptValue installerObject = scriptEngine.newQObject( m_installer );
+ installerObject.setProperty( QLatin1String( "componentByName" ), scriptEngine.newFunction( qInstallerComponentByName, 1 ) );
+ scriptEngine.globalObject().setProperty( QLatin1String( "installer" ), installerObject );
+}
+
+void Component::Private::setSelectedOnComponentList(const QList<Component*> &componentList,
+ bool selected, RunModes runMode, SelectMode selectMode)
+{
+ for( QList< Component* >::const_iterator it = componentList.begin(); it != componentList.end(); ++it )
+ {
+ Component* const comp = *it;
+ if( !comp->isSelected( runMode ) )
+ comp->setSelected( selected, runMode, selectMode );
+ }
+}
+
+/*!
+ Constructor. Creates a new Component inside of \a installer.
+*/
+Component::Component(Installer *installer)
+ : d(new Component::Private( installer, this ) )
+{
+ d->init();
+}
+
+Component::Component( KDUpdater::Update* update, Installer* installer )
+ : d( new Private( installer, this ) ) {
+ Q_ASSERT( update );
+ d->init();
+ setValue( QLatin1String( "Name" ), update->data( QLatin1String( "Name" ) ).toString() );
+ setValue( QLatin1String( "DisplayName" ), update->data( QLatin1String( "DisplayName" ) ).toString() );
+ setValue( QLatin1String( "Description" ), update->data( QLatin1String( "Description" ) ).toString() );
+ setValue( QLatin1String( "UncompressedSize" ), QString::number( update->uncompressedSize() ) );
+ setValue( QLatin1String( "Version" ), update->data( QLatin1String( "Version" ) ).toString() );
+ setValue( QLatin1String( "Dependencies" ), update->data( QLatin1String( "Dependencies" ) ).toString() );
+ setValue( QLatin1String( "Virtual" ), update->data( QLatin1String( "Virtual" ) ).toString() );
+ setValue( QLatin1String( "SortingPriority" ), update->data( QLatin1String( "SortingPriority" ) ).toString() );
+ setValue( QLatin1String( "InstallPriority" ), update->data( QLatin1String( "InstallPriority" ) ).toString() );
+ setValue( QLatin1String( "AutoSelectOn" ), update->data( QLatin1String( "AutoSelectOn" ) ).toString() );
+}
+
+/*!
+ Destroys the Component.
+*/
+Component::~Component()
+{
+ if( parentComponent() != 0 )
+ d->m_parent->d->m_components.removeAll( this );
+
+ if (!d->m_newlyInstalled)
+ qDeleteAll(d->operations);
+
+ qDeleteAll( d->m_components );
+ delete d;
+}
+
+void Component::markAsPerformedInstallation()
+{
+ d->m_newlyInstalled = true;
+}
+
+/*!
+ \property Component::removeBeforeUpdate
+ Specifies wheter this component gets removed by the installer system before it gets updated.
+ Get this property's value by using %removeBeforeUpdate(), and set it
+ using %setRemoveBeforeUpdate(). The default value is true.
+ */
+bool Component::removeBeforeUpdate() const
+{
+ return d->removeBeforeUpdate;
+}
+
+void Component::setRemoveBeforeUpdate( bool removeBeforeUpdate )
+{
+ d->removeBeforeUpdate = removeBeforeUpdate;
+}
+
+QList<Component*> Component::dependees() const
+{
+ return d->m_installer->dependees( this );
+}
+
+/*
+ Returns a key/value based hash of all variables set for this component.
+ */
+QHash<QString,QString> Component::variables() const
+{
+ return d->m_vars;
+}
+
+/*!
+ Returns the value of variable name \a key. If \a key is not known yet, \a defaultValue is returned.
+ */
+QString Component::value(const QString &key,
+ const QString &defaultValue) const
+{
+ return d->m_vars.value(key, defaultValue);
+}
+
+/*!
+ Sets the value of the variable with \a key to \a value.
+*/
+void Component::setValue(const QString &key, const QString &value)
+{
+ if( d->m_vars[ key ] == value )
+ return;
+
+ d->m_vars[ key ] = value;
+ emit valueChanged( key, value );
+}
+
+/*!
+ Returnst the installer this component belongs to.
+*/
+Installer* Component::installer() const
+{
+ return d->m_installer;
+}
+
+/*!
+ Returns the parent of this component. If this component is com.nokia.sdk.qt, its
+ parent is com.nokia.sdk, as far as this exists.
+ */
+Component* Component::parentComponent( RunModes runMode ) const
+{
+ if ( runMode == UpdaterMode )
+ return 0;
+ else
+ return d->m_parent;
+}
+
+/*!
+ Appends \a component as a child of this component. If \a component already has a parent,
+ it is removed from the previous parent.
+ */
+void Component::appendComponent( Component* component )
+{
+ d->m_components.append( component );
+ if( component->parentComponent() != 0 )
+ component->d->m_parent->d->m_components.removeAll( component );
+ component->d->m_parent = this;
+}
+
+/*!
+ Returns a list of child components. If \a recursive is set to true, the returned list
+ contains not only the direct children, but all ancestors.
+ */
+QList< Component* > Component::components( bool recursive, RunModes runMode ) const
+{
+ if ( runMode == UpdaterMode )
+ return QList < Component* >();
+ if( !recursive )
+ return d->m_components;
+
+ QList< Component* > result;
+ for( QList< Component* >::const_iterator it = d->m_components.begin(); it != d->m_components.end(); ++it )
+ {
+ result.append( *it );
+ result += (*it)->components( true );
+ }
+ return result;
+}
+
+/*!
+ Contains this component's name (unique identifier).
+ */
+QString Component::name() const
+{
+ return value( QLatin1String( "Name" ) );
+}
+
+/*!
+ Contains this component's display name (as visible to the user).
+ */
+QString Component::displayName() const
+{
+ return value( QLatin1String( "DisplayName" ) );
+}
+
+/*!
+ Loads the script at \a fileName into this component's script engine.
+ The installer and all its components as well as other useful stuff are being exported into the script.
+ Read \link componentscripting Component Scripting \endlink for details.
+ \throws Error when either the script at \a fileName couldn't be opened, or the QScriptEngine couldn't evaluate the script.
+ */
+void Component::loadComponentScript( const QString& fileName )
+{
+ QFile file( fileName );
+ if( !file.open( QIODevice::ReadOnly ) )
+ throw Error( QObject::tr( "Could not open the requested script file at %1: %2" ).arg( fileName, file.errorString() ) );
+ d->scriptEngine.evaluate( QLatin1String( file.readAll() ), fileName );
+ if( d->scriptEngine.hasUncaughtException() ) {
+ throw Error( QObject::tr( "Exception while loading the component script %1" )
+ .arg(uncaughtExceptionString(&(d->scriptEngine)/*, QFileInfo(file).absoluteFilePath()*/)) );
+ }
+
+ const QList< Component* > components = d->m_installer->components( true );
+ QScriptValue comps = d->scriptEngine.newArray( components.count() );
+ for( int i = 0; i < components.count(); ++i ) {
+ comps.setProperty( i, d->scriptEngine.newQObject( components[ i ] ) );
+ }
+ d->scriptEngine.globalObject().property( QLatin1String( "installer" ) ).setProperty( QLatin1String( "components" ), comps );
+
+ QScriptValue comp = d->scriptEngine.evaluate( QLatin1String( "Component" ) );
+ if( !d->scriptEngine.hasUncaughtException() )
+ {
+ d->scriptComponent = comp;
+ d->scriptComponent.construct();
+ }
+
+ emit loaded();
+ languageChanged();
+}
+
+/*!
+ \internal
+ Calls the script method \link retranslateUi() \endlink, if any. This is done whenever a QTranslator file is being loaded.
+ */
+void Component::languageChanged()
+{
+ callScriptMethod( QLatin1String( "retranslateUi" ) );
+}
+
+/*!
+ Tries to call the method with \a name within the script and returns the result.
+ If the method doesn't exist, an invalid result is returned. If the method has an uncaught exception, its string
+ representation is thrown as an Error exception.
+ \note The method is not called, if the current script context is the same method, to avoid infinite recursion.
+ */
+QScriptValue Component::callScriptMethod( const QString& methodName, const QScriptValueList& arguments )
+{
+ if( !d->unexistingScriptMethods.value( methodName, true ) )
+ return QScriptValue();
+
+ // don't allow such a recursion
+ if( d->scriptEngine.currentContext()->backtrace().first().startsWith( methodName ) )
+ return QScriptValue();
+
+ QScriptValue method = d->scriptComponent.property( QString::fromLatin1( "prototype" ) ).property( methodName );
+
+ if( !method.isValid() ) // this marks the method to be called not any longer
+ d->unexistingScriptMethods[ methodName ] = false;
+
+ const QScriptValue result = method.call( d->scriptComponent, arguments );
+
+ if( !result.isValid() )
+ return result;
+
+ if( d->scriptEngine.hasUncaughtException() )
+ throw Error( uncaughtExceptionString(&(d->scriptEngine)/*, name()*/) );
+
+ return result;
+}
+
+/*!
+ Loads the translations matching the name filters \a qms inside \a directory.
+ Only translations with a \link QFileInfo::baseName() baseName \endlink matching the
+ current locales \link QLocale::name() name \endlink are loaded.
+ Read \ref componenttranslation for details.
+ */
+void Component::loadTranslations( const QDir& directory, const QStringList& qms )
+{
+ QDirIterator it( directory.path(), qms, QDir::Files );
+ while( it.hasNext() )
+ {
+ const QString filename = it.next();
+ if( QFileInfo( filename ).baseName().toLower() != QLocale().name().toLower() )
+ continue;
+
+ std::auto_ptr<QTranslator> translator( new QTranslator( this ) );
+ if( !translator->load( filename ) )
+ throw Error( tr( "Could not open the requested translation file at %1" ).arg( filename ) );
+ qApp->installTranslator( translator.release() );
+ }
+}
+
+/*!
+ Loads the user interface files matching the name filters \a uis inside \a directory.
+ The loaded interface can be accessed via userInterfaces by using the class name set in the ui file.
+ Read \ref componentuserinterfaces for details.
+ */
+void Component::loadUserInterfaces( const QDir& directory, const QStringList& uis )
+{
+ if( QApplication::type() == QApplication::Tty )
+ return;
+
+ QDirIterator it( directory.path(), uis, QDir::Files );
+ while( it.hasNext() )
+ {
+ QFile file( it.next() );
+ if( !file.open( QIODevice::ReadOnly ) )
+ throw Error( tr( "Could not open the requested UI file at %1: %2" ).arg( it.fileName(), file.errorString() ) );
+
+ static QUiLoader loader;
+ loader.setTranslationEnabled( true );
+ loader.setLanguageChangeEnabled( true );
+ QWidget* const w = loader.load( &file );
+ d->userInterfaces[ w->objectName() ] = w;
+ }
+}
+
+
+void Component::loadLicenses(const QString &directory, const QHash<QString, QVariant> &licenseHash)
+{
+ QHash<QString, QVariant>::const_iterator it;
+ for (it = licenseHash.begin(); it != licenseHash.end(); ++it) {
+ const QString &fileName = it.value().toString();
+ QFile file(directory + fileName);
+ if(!file.open(QIODevice::ReadOnly)) {
+ throw Error(tr("Could not open the requested license file at %1: %2" ).arg(fileName,
+ file.errorString()));
+ }
+ d->m_licenses.insert(it.key(), qMakePair(fileName, QTextStream(&file).readAll()));
+ }
+}
+
+/*!
+ Contains a list of all user interface class names known to this component.
+ */
+QStringList Component::userInterfaces() const
+{
+ return d->userInterfaces.keys();
+}
+
+QHash<QString, QPair<QString, QString> > Component::licenses() const
+{
+ return d->m_licenses;
+}
+
+/*!
+ Returns the QWidget created for class \a name.
+ */
+QWidget* Component::userInterface( const QString& name ) const
+{
+ return d->userInterfaces.value( name );
+}
+
+/*!
+ Creates all operations needed to install this component's \a path.
+ \a path is a full qualified filename including the component's name.
+ This metods gets called from Component::createOperationsForArchive.
+ You can override this method by providing a method with the same name in the component script.
+ \note If you call this method from a script, it won't call the scripts method with the same name.
+ \note RSA signature files are omitted by this method.
+
+ The default implemention is recursively creating Copy and Mkdir operations for all files
+ and folders within \a path.
+ */
+void Component::createOperationsForPath( const QString& path )
+{
+ const QFileInfo fi( path );
+
+ // don't copy over a signature
+ if( fi.suffix() == QLatin1String( "sig" ) && QFileInfo( fi.dir(), fi.completeBaseName() ).exists() )
+ return;
+
+ // the script can override this method
+ if( callScriptMethod( QLatin1String( "createOperationsForPath" ), QScriptValueList() << path ).isValid() )
+ return;
+
+ static const QString zipPrefix = QString::fromLatin1( "7z://installer://" );
+ static const QString prefix = QString::fromLatin1( "installer://" );
+ QString target;
+ if ( path.startsWith( zipPrefix ) ) { // if the path is an archive, remove the archive file name from the target path
+ target = path.mid( zipPrefix.length() + name().length() + 1 ); // + 1 for the /
+ const int nextSlash = target.indexOf( QLatin1Char('/') );
+ if ( nextSlash != -1 )
+ target = target.mid( nextSlash );
+ else
+ target.clear();
+ target.prepend(QLatin1String("@TargetDir@"));
+ }
+ else
+ target = QString::fromLatin1( "@TargetDir@%1" ).arg( path.mid( prefix.length() + name().length() ) );
+ static const QString copy = QString::fromLatin1( "Copy" );
+ static const QString mkdir = QString::fromLatin1( "Mkdir" );
+ if( fi.isFile() )
+ {
+ addOperation( copy, fi.filePath(), target );
+ }
+ else if( fi.isDir() )
+ {
+ qApp->processEvents();
+ addOperation( mkdir, target );
+ QDirIterator it( fi.filePath() );
+ while( it.hasNext() )
+ createOperationsForPath( it.next() );
+ }
+
+}
+
+/*!
+ Creates all operations needed to install this component's \a archive.
+ This metods gets called from Component::createOperations.
+ You can override this method by providing a method with the same name in the component script.
+ \note If you call this method from a script, it won't call the scripts method with the same name.
+
+ The default implementation calls createOperationsForPath for everything contained in the archive.
+ If \a archive is a compressed archive known to the installer system, an Extract operation is created, instead.
+ */
+void Component::createOperationsForArchive( const QString& archive )
+{
+ // the script can override this method
+ if( callScriptMethod( QLatin1String( "createOperationsForArchive" ), QScriptValueList() << archive ).isValid() )
+ return;
+
+ const QFileInfo fi( QString::fromLatin1( "installer://%1/%2").arg( name(), archive ) );
+ const bool isZip = Lib7z::isSupportedArchive( fi.filePath() );
+
+ if( !isZip )
+ createOperationsForPath( fi.filePath() );
+ else
+ // archives get completely extracted per default (if the script isn't doing other stuff)
+ addOperation( QLatin1String( "Extract" ), fi.filePath(), QLatin1String( "@TargetDir@" ) );
+}
+
+/*!
+ Creates all operations needed to install this component.
+ You can override this method by providing a method with the same name in the component script.
+ \note If you call this method from a script, it won't call the scripts method with the same name.
+
+ The default implementation calls createOperationsForArchive for all archives in this component.
+*/
+void Component::createOperations()
+{
+ // the script can override this method
+ if( callScriptMethod( QLatin1String( "createOperations" ) ).isValid() )
+ {
+ d->operationsCreated = true;
+ return;
+ }
+
+ const QDir dir( QString::fromLatin1( "installer://%1/" ).arg( name() ) );
+ const QStringList archives = dir.entryList();
+ for( QStringList::const_iterator it = archives.begin(); it != archives.end(); ++it )
+ createOperationsForArchive( *it );
+
+ d->operationsCreated = true;
+}
+
+/*!
+ Registers the file or directory at \a path for being removed when this component gets uninstalled.
+ In case of a directory, this will be recursive.
+ If \a wipe is set to true, the directory will also be deleted if it contains changes done by the user
+ after installation.
+*/
+void Component::registerPathForUninstallation( const QString& path, bool wipe )
+{
+ d->pathesForUninstallation.append( qMakePair( path, wipe ) );
+}
+
+/*!
+ Returns the list of pathes previously registered for uninstallation with #registerPathForUninstallation.
+*/
+QList< QPair< QString, bool > > Component::pathesForUninstallation() const
+{
+ return d->pathesForUninstallation;
+}
+
+/*!
+ Contains the names of all archives known to this component. This does not contain archives added
+ with #addDownloadableArchive.
+ */
+QStringList Component::archives() const
+{
+ return QDir( QString::fromLatin1( "installer://%1/" ).arg( name() ) ).entryList();
+}
+
+/*!
+ Adds the archive \a path to this component. This can only be called when this component was downloaded from
+ an online repository. When adding \a path, it will be downloaded from the repository when the installation starts.
+ Read \ref sec_repogen for details.
+ \sa fromOnlineRepository
+ */
+void Component::addDownloadableArchive( const QString& path )
+{
+ Q_ASSERT( isFromOnlineRepository() );
+ const QString versionPrefix = value( QLatin1String( "Version" ) );
+ verbose() << "addDownloadable " << path << std::endl;
+ d->downloadableArchives.append( versionPrefix + path );
+}
+
+/*!
+ Removes the archive \a path previously added via addDownloadableArchive from this component. This can oly be
+ called when this component was downloaded from an online repository. Read \ref sec_repogen for details.
+ */
+void Component::removeDownloadableArchive( const QString& path )
+{
+ Q_ASSERT( isFromOnlineRepository() );
+ d->downloadableArchives.removeAll( path );
+}
+
+/*!
+ Returns the archives to be downloaded from the online repository before installation.
+ */
+QStringList Component::downloadableArchives() const
+{
+ return d->downloadableArchives;
+}
+
+/*!
+ * Adds a request for quitting the process @p process before installing/updating/uninstalling the
+ * component.
+ */
+void Component::addStopProcessForUpdateRequest( const QString& process )
+{
+ d->stopProcessForUpdateRequests.append( process );
+}
+
+/*!
+* Removes the request for quitting the process @p process again.
+*/
+void Component::removeStopProcessForUpdateRequest( const QString& process )
+{
+ d->stopProcessForUpdateRequests.removeAll( process );
+}
+
+/*!
+* Convenience: Add/remove request depending on @p requested (add if @p true, remove if @p false).
+*/
+void Component::setStopProcessForUpdateRequest( const QString& process, bool requested )
+{
+ if ( requested )
+ addStopProcessForUpdateRequest( process );
+ else
+ removeStopProcessForUpdateRequest( process );
+}
+
+/*!
+ * The list of processes this component needs to be closed before installing/updating/uninstalling
+ */
+QStringList Component::stopProcessForUpdateRequests() const
+{
+ return d->stopProcessForUpdateRequests;
+}
+
+/*!
+ Returns the operations needed to install this component. If autoCreateOperations is true, createOperations
+ is called, if no operations have been auto-created yet.
+ */
+QList< KDUpdater::UpdateOperation* > Component::operations() const
+{
+ if (d->autoCreateOperations && !d->operationsCreated) {
+ const_cast< Component* >( this )->createOperations();
+
+ if (!d->minimumProgressOperation) {
+ d->minimumProgressOperation = KDUpdater::UpdateOperationFactory::instance()
+ .create(QLatin1String("MinimumProgress"));
+ d->operations.append(d->minimumProgressOperation);
+ }
+
+ if (!d->m_licenses.isEmpty()) {
+ d->m_licenseOperation = KDUpdater::UpdateOperationFactory::instance()
+ .create(QLatin1String("License"));
+ d->m_licenseOperation->setValue(QLatin1String("installer"),
+ QVariant::fromValue(d->m_installer));
+
+ QVariantMap licenses;
+ const QList<QPair<QString, QString> > values = d->m_licenses.values();
+ for (int i = 0; i < values.count(); ++i)
+ licenses.insert(values.at(i).first, values.at(i).second);
+ d->m_licenseOperation->setValue(QLatin1String("licenses"), licenses);
+ d->operations.append(d->m_licenseOperation);
+ }
+ }
+ return d->operations;
+}
+
+/*!
+ Adds \a operation to the list of operations needed to install this component.
+ */
+void Component::addOperation( KDUpdater::UpdateOperation* operation )
+{
+ d->operations.append( operation );
+ if( FSEngineClientHandler::instance()->isActive() )
+ operation->setValue( QLatin1String( "admin" ), true );
+}
+
+/*!
+ Adds \a operation to the list of operations needed to install this component. \a operation
+ is executed with elevated rights.
+ */
+void Component::addElevatedOperation( KDUpdater::UpdateOperation* operation )
+{
+ addOperation( operation );
+ operation->setValue( QLatin1String( "admin" ), true );
+}
+
+bool Component::operationsCreatedSuccessfully() const
+{
+ return d->operationsCreatedSuccessfully;
+}
+
+/*!
+ Creates and adds an installation operation for \a operation. Add any number of \a parameter1, \a parameter2, \a parameter3, \a parameter4, \a parameter5 and \a parameter6
+ The contents of the parameters get variables like "@TargetDir@" replaced with their values, if contained.
+ \sa installeroperations
+ */
+bool Component::addOperation( const QString& operation, const QString& parameter1, const QString& parameter2, const QString& parameter3, const QString& parameter4, const QString& parameter5, const QString& parameter6, const QString& parameter7, const QString& parameter8, const QString& parameter9, const QString& parameter10 )
+{
+ KDUpdater::UpdateOperation* const op = KDUpdater::UpdateOperationFactory::instance().create( operation );
+ if( op == 0 )
+ {
+ const QMessageBox::StandardButton button = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String( "operationDoesNotExistError" ), tr( "Error" ),
+ tr( "Error: Operation %1 does not exist" ).arg( operation ),
+ QMessageBox::Abort | QMessageBox::Ignore );
+ if ( button == QMessageBox::Abort )
+ {
+ d->operationsCreatedSuccessfully = false;
+ }
+ return false;
+ }
+ if ( op->name() == QLatin1String( "Delete" ) )
+ op->setValue( QLatin1String( "performUndo" ), false );
+ op->setValue( QLatin1String( "installer" ), qVariantFromValue( d->m_installer ) );
+
+ QStringList arguments;
+ if( !parameter1.isNull() )
+ arguments.append( parameter1 );
+ if( !parameter2.isNull() )
+ arguments.append( parameter2 );
+ if( !parameter3.isNull() )
+ arguments.append( parameter3 );
+ if( !parameter4.isNull() )
+ arguments.append( parameter4 );
+ if( !parameter5.isNull() )
+ arguments.append( parameter5 );
+ if( !parameter6.isNull() )
+ arguments.append( parameter6 );
+ if( !parameter7.isNull() )
+ arguments.append( parameter7 );
+ if( !parameter8.isNull() )
+ arguments.append( parameter8 );
+ if( !parameter9.isNull() )
+ arguments.append( parameter9 );
+ if( !parameter10.isNull() )
+ arguments.append( parameter10 );
+ op->setArguments( d->m_installer->replaceVariables( arguments ) );
+
+ addOperation( op );
+
+ return true;
+}
+
+/*!
+ Creates and adds an installation operation for \a operation. Add any number of \a parameter1, \a parameter2, \a parameter3, \a parameter4, \a parameter5 and \a parameter6
+ The contents of the parameters get variables like "@TargetDir@" replaced with their values, if contained. \a operation is executed with
+ elevated rights.
+ \sa installeroperations
+ */
+bool Component::addElevatedOperation( const QString& operation, const QString& parameter1, const QString& parameter2, const QString& parameter3, const QString& parameter4, const QString& parameter5, const QString& parameter6, const QString& parameter7, const QString& parameter8, const QString& parameter9, const QString& parameter10 )
+{
+ KDUpdater::UpdateOperation* const op = KDUpdater::UpdateOperationFactory::instance().create( operation );
+ if( op == 0 )
+ return false;
+
+ op->setValue( QLatin1String( "installer" ), qVariantFromValue( d->m_installer ) );
+
+ QStringList arguments;
+ if( !parameter1.isNull() )
+ arguments.append( parameter1 );
+ if( !parameter2.isNull() )
+ arguments.append( parameter2 );
+ if( !parameter3.isNull() )
+ arguments.append( parameter3 );
+ if( !parameter4.isNull() )
+ arguments.append( parameter4 );
+ if( !parameter5.isNull() )
+ arguments.append( parameter5 );
+ if( !parameter6.isNull() )
+ arguments.append( parameter6 );
+ if( !parameter7.isNull() )
+ arguments.append( parameter7 );
+ if( !parameter8.isNull() )
+ arguments.append( parameter8 );
+ if( !parameter9.isNull() )
+ arguments.append( parameter9 );
+ if( !parameter10.isNull() )
+ arguments.append( parameter10 );
+ op->setArguments( d->m_installer->replaceVariables( arguments ) );
+
+ addElevatedOperation( op );
+
+ return true;
+}
+
+
+/*!
+ Specifies wheter operations should be automatically created when the installation starts. This would be done by calling #createOperations.
+ If you set this to false, it's completely up to the component's script to create all operations.
+ */
+bool Component::autoCreateOperations() const
+{
+ return d->autoCreateOperations;
+}
+
+void Component::setAutoCreateOperations( bool autoCreateOperations )
+{
+ d->autoCreateOperations = autoCreateOperations;
+}
+
+Qt::CheckState Component::checkState( RunModes runMode ) const
+{
+ if ( runMode == UpdaterMode )
+ return d->isCheckedFromUpdater ? Qt::Checked : Qt::Unchecked;
+ const QMap< const Component*, Qt::CheckState >::const_iterator it = Private::cachedCheckStates.find( this );
+ if( it != Private::cachedCheckStates.end() )
+ return *it;
+ const Qt::CheckState state = componentCheckState( this, runMode );
+ Private::cachedCheckStates[ this ] = state;
+ return state;
+}
+
+/*!
+ \property Component::selected
+ Specifies wheter this component is selected for installation.
+ Get this property's value by using %isSelected(), and set it
+ using %setSelected().
+ */
+bool Component::isSelected( RunModes runMode ) const
+{
+ const Qt::CheckState state = checkState( runMode );
+ return state != Qt::Unchecked;
+}
+
+//SelectMode means:
+//NormalSelectMode - dependency errors and selectionChanged SIGNAL are emitted
+//InitializeComponentTreeSelectMode - no dependency errors(maybe some components are not ready initialized),
+// no selectionChanged SIGNAL needed and no recursion
+void Component::setSelected(bool selected, RunModes runMode, SelectMode selectMode)
+{
+ if ( runMode == UpdaterMode )
+ {
+ verbose() << "Update selection" << std::endl;
+ QStringList missingNames;
+ d->m_installer->dependencies( this, &missingNames );
+
+ if ( !missingNames.isEmpty() )
+ {
+ const QString missingPackages = missingNames.join( QLatin1String( " " ) );
+ if ( selectMode == NormalSelectMode ) {
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String( "DependenciesMissingError" ), tr( "Dependencies Missing" ),
+ tr( "The following required packages could not be found : %1!" ).arg( missingPackages ),
+ QMessageBox::Ok );
+ }
+ verbose() << "Error occured missing dependencies" << missingPackages << std::endl;
+ return;
+ } else {
+ verbose() << "No Error occured" << std::endl;
+ }
+ const Qt::CheckState previousState = checkState( UpdaterMode );
+ const Qt::CheckState newState = selected ? Qt::Checked : Qt::Unchecked;
+ d->isCheckedFromUpdater = selected;
+ // we have to select all dependees as well
+ if ( selected )
+ {
+ verbose() << "Update selected for " << name() <<std::endl;
+ const QList< Component* > dependees = d->m_installer->missingDependencies( this );
+ d->setSelectedOnComponentList(dependees, true, runMode, selectMode);
+ }
+ if( !selected )
+ {
+ // if it got deselected, we have to deselect all dependees as well
+ verbose() << "Update deselected" << name() << std::endl;
+ const QList< Component* > dependees = d->m_installer->dependees( this );
+ d->setSelectedOnComponentList(dependees, false, runMode, selectMode);
+ }
+ //we need selectedChanged even it is not in the NormalSelectMode to check the running processes from script side
+ //for installpart it is working because we are selecting the components in the script as well
+ //TODO: change this ^ behaviour in scripts and code
+ if( /*selectMode == NormalSelectMode && */newState != previousState )
+ QMetaObject::invokeMethod( this, "selectedChanged", Qt::QueuedConnection, Q_ARG( bool, newState == Qt::Checked ) );
+
+ } else {
+ QMap< Component*, Qt::CheckState > previousStates;
+ const QList< Component* > allComponents = d->m_installer->components( true );
+ for( QList< Component* >::const_iterator it = allComponents.begin(); it != allComponents.end(); ++it )
+ previousStates[ *it ] = (*it)->checkState();
+
+ setValue( QString::fromLatin1( "WantedState" ), selected ? QString::fromLatin1( "Installed" ) : QString::fromLatin1( "Uninstalled" ) );
+ Private::cachedCheckStates.clear();
+
+ if ( selected )
+ {
+ verbose() << "Update selected for " << name() << std::endl;
+ const QList< Component* > dependees = d->m_installer->missingDependencies( this );
+ d->setSelectedOnComponentList(dependees, true, runMode, selectMode);
+ }
+
+ if( !selected )
+ {
+ // if it got deselected, we have to deselect all dependees as well
+ const QList< Component* > dependees = d->m_installer->dependees( this );
+ d->setSelectedOnComponentList(dependees, false, runMode, selectMode);
+ }
+
+ // and all children
+ if ( selectMode == NormalSelectMode )
+ {
+ const QList< Component* > children = components( true );
+ for( QList< Component* >::const_iterator it = children.begin(); it != children.end(); ++it )
+ {
+ Component* const comp = *it;
+ comp->setValue( QString::fromLatin1( "WantedState" ), selected ? QString::fromLatin1( "Installed" ) : QString::fromLatin1( "Uninstalled" ) );
+ }
+
+ //now all needed components are selected so we can emit the signals
+ for( QList< Component* >::const_iterator it = allComponents.begin(); it != allComponents.end(); ++it )
+ {
+ const Qt::CheckState newCheckState = (*it)->checkState();
+ if( previousStates[ *it ] != newCheckState )
+ QMetaObject::invokeMethod( *it, "selectedChanged", Qt::QueuedConnection, Q_ARG( bool, newCheckState == Qt::Checked ) );
+ //emit (*it)->selectedChanged( state == Qt::Checked );
+ }
+ }
+ }
+}
+
+/*!
+ * Contains this component dependencies.
+ * Read \ref componentdependencies for details.
+ */
+QStringList Component::dependencies() const
+{
+ return value( QLatin1String( "Dependencies" ) ).split( QLatin1Char( ',' ) );
+}
+
+/*!
+ * Determines if the component is installed
+ */
+bool Component::isInstalled() const
+{
+ return QLatin1String( "Installed" ) == value( QLatin1String( "CurrentState" ) );
+}
+
+/*!
+ * Determines if the user wants to install the component
+ */
+bool Component::installationRequested() const
+{
+ return ( QLatin1String( "Installed" ) == value( QLatin1String( "WantedState" ) ) && ( !isInstalled() || isSelected( UpdaterMode ) ) );
+}
+
+/*!
+ * Determines if the user wants to install the component
+ */
+bool Component::uninstallationRequested() const
+{
+ return QLatin1String( "Uninstalled" ) == value( QLatin1String( "WantedState" ) ) && isInstalled();
+}
+
+/*!
+ * Determines if the component was installed recently
+ */
+bool Component::wasInstalled() const
+{
+ return QLatin1String( "Uninstalled" ) == value( QLatin1String( "PreviousState" ) ) && isInstalled();
+}
+
+/*!
+ * Determines if the component was removed recently
+ */
+bool Component::wasUninstalled() const
+{
+ return QLatin1String( "Installed" ) == value( QLatin1String( "PreviousState" ) ) && !isInstalled();
+}
+
+/*!
+ * Determines if the components installations status can be changed.
+ */
+bool Component::isEnabled() const
+{
+ return d->enabled;
+}
+/*!
+ * Enables oder disables ability to change the components installations status.
+ */
+void Component::setEnabled( bool enabled )
+{
+ d->enabled = enabled;
+}
+
+/*!
+ * \property Component::fromOnlineRepository
+ * Determines wheter this component has been loaded from an online repository.
+ * Get this property's value by usinng %isFromOnlineRepository.
+ * \sa addDownloadableArchive
+ */
+bool Component::isFromOnlineRepository() const
+{
+ return !repositoryUrl().isEmpty();
+}
+
+/*!
+ * Contains the repository Url this component is downloaded from.
+ * When this component is not downloaded from an online repository, returns an empty #QUrl.
+ */
+QUrl Component::repositoryUrl() const
+{
+ return d->repositoryUrl;
+}
+
+/*!
+ \internal
+ Sets this components #repositoryUrl.
+*/
+void Component::setRepositoryUrl( const QUrl& url )
+{
+ d->repositoryUrl = url;
+}
diff --git a/installerbuilder/libinstaller/qinstallercomponent.h b/installerbuilder/libinstaller/qinstallercomponent.h
new file mode 100644
index 000000000..e021de46c
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstallercomponent.h
@@ -0,0 +1,197 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_COMPONENT_H
+#define QINSTALLER_COMPONENT_H
+
+#include <QObject>
+#include <QScriptable>
+#include <QUrl>
+
+#include "qinstaller.h" // friend QInstaller::Private
+
+class QDir;
+
+namespace KDUpdater {
+ class Update;
+ class UpdateOperation;
+}
+
+namespace QInstaller {
+
+class Installer;
+
+class INSTALLER_EXPORT Component : public QObject, public QScriptable
+{
+ Q_OBJECT
+ Q_PROPERTY( QString name READ name )
+ Q_PROPERTY( QString displayName READ displayName )
+ Q_PROPERTY( bool selected READ isSelected WRITE setSelected )
+ Q_PROPERTY( bool autoCreateOperations READ autoCreateOperations WRITE setAutoCreateOperations )
+ Q_PROPERTY( QStringList archives READ archives )
+ Q_PROPERTY( QStringList userInterfaces READ userInterfaces )
+ Q_PROPERTY( QStringList dependencies READ dependencies )
+ Q_PROPERTY( bool fromOnlineRepository READ isFromOnlineRepository )
+ Q_PROPERTY( QUrl repositoryUrl READ repositoryUrl )
+ Q_PROPERTY( bool removeBeforeUpdate READ removeBeforeUpdate WRITE setRemoveBeforeUpdate )
+ Q_PROPERTY( bool installed READ isInstalled )
+ Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled)
+
+public:
+ enum SelectMode{NormalSelectMode, InitializeComponentTreeSelectMode};
+ explicit Component( Installer *installer );
+ Component( KDUpdater::Update* update, Installer* installer );
+ ~Component();
+
+ struct PriorityLessThan
+ {
+ bool operator()( const Component* lhs, const Component* rhs )
+ {
+ return lhs->value( QLatin1String( "InstallPriority" ) ).toInt() < rhs->value( QLatin1String( "InstallPriority" ) ).toInt();
+ }
+ };
+
+ Q_INVOKABLE void setValue(const QString &key, const QString &value);
+ Q_INVOKABLE QString value(const QString &key,
+ const QString &defaultValue = QString()) const;
+ QHash<QString, QString> variables() const;
+
+ QStringList archives() const;
+
+ Installer* installer() const;
+ Component* parentComponent( RunModes runMode = InstallerMode ) const;
+ void appendComponent( Component* component );
+ QList<Component*> components( bool recursive = false, RunModes runMode = InstallerMode ) const;
+
+ void loadComponentScript( const QString& fileName );
+ void loadTranslations( const QDir& directory, const QStringList& qms );
+ void loadUserInterfaces( const QDir& directory, const QStringList& uis );
+ void loadLicenses(const QString &directory, const QHash<QString, QVariant> &hash);
+ void markAsPerformedInstallation();
+
+ QStringList userInterfaces() const;
+ QHash<QString, QPair<QString, QString> > licenses() const;
+ Q_INVOKABLE QWidget* userInterface( const QString& name ) const;
+ Q_INVOKABLE virtual void createOperations();
+ Q_INVOKABLE virtual void createOperationsForArchive( const QString& archive );
+ Q_INVOKABLE virtual void createOperationsForPath( const QString& path );
+
+ Q_INVOKABLE void registerPathForUninstallation( const QString& path, bool wipe = false );
+ Q_INVOKABLE QList< QPair< QString, bool > > pathesForUninstallation() const;
+
+ QList< KDUpdater::UpdateOperation* > operations() const;
+ void addOperation( KDUpdater::UpdateOperation* operation );
+ void addElevatedOperation( KDUpdater::UpdateOperation* operation );
+ Q_INVOKABLE bool addOperation( const QString& operation, const QString& parameter1 = QString(),
+ const QString& parameter2 = QString(),
+ const QString& parameter3 = QString(),
+ const QString& parameter4 = QString(),
+ const QString& parameter5 = QString(),
+ const QString& parameter6 = QString(),
+ const QString& parameter7 = QString(),
+ const QString& parameter8 = QString(),
+ const QString& parameter9 = QString(),
+ const QString& parameter10 = QString() );
+
+ Q_INVOKABLE bool addElevatedOperation( const QString& operation, const QString& parameter1 = QString(),
+ const QString& parameter2 = QString(),
+ const QString& parameter3 = QString(),
+ const QString& parameter4 = QString(),
+ const QString& parameter5 = QString(),
+ const QString& parameter6 = QString(),
+ const QString& parameter7 = QString(),
+ const QString& parameter8 = QString(),
+ const QString& parameter9 = QString(),
+ const QString& parameter10 = QString() );
+
+
+ Q_INVOKABLE void addDownloadableArchive( const QString& path );
+ Q_INVOKABLE void removeDownloadableArchive( const QString& path );
+
+ QStringList downloadableArchives() const;
+
+ Q_INVOKABLE void addStopProcessForUpdateRequest( const QString& process );
+ Q_INVOKABLE void removeStopProcessForUpdateRequest( const QString& process );
+ Q_INVOKABLE void setStopProcessForUpdateRequest( const QString& process, bool requested );
+
+ QStringList stopProcessForUpdateRequests() const;
+
+ QString name() const;
+ QString displayName() const;
+
+ QUrl repositoryUrl() const;
+ void setRepositoryUrl( const QUrl& url );
+
+ bool removeBeforeUpdate() const;
+ void setRemoveBeforeUpdate( bool removeBeforeUpdate );
+
+ Q_INVOKABLE bool isFromOnlineRepository() const;
+
+ QStringList dependencies() const;
+
+ bool autoCreateOperations() const;
+ bool isSelected( RunModes runMode = InstallerMode ) const;
+ Q_INVOKABLE bool isInstalled() const;
+ Q_INVOKABLE bool installationRequested() const;
+ Q_INVOKABLE bool uninstallationRequested() const;
+ Q_INVOKABLE bool wasInstalled() const;
+ Q_INVOKABLE bool wasUninstalled() const;
+ bool isEnabled() const;
+ void setEnabled( bool enabled );
+
+ bool operationsCreatedSuccessfully() const;
+
+ Qt::CheckState checkState( RunModes runMode = InstallerMode ) const;
+
+ void languageChanged();
+
+ QList<Component*> dependees() const;
+
+ friend class ::QInstaller::Installer;
+ friend class ::QInstaller::Installer::Private;
+
+Q_SIGNALS:
+ void valueChanged( const QString& key, const QString& value );
+ void selectedChanged( bool selected );
+ void loaded();
+
+public Q_SLOTS:
+ void setAutoCreateOperations( bool autoCreateOperations );
+ void setSelected(bool selected, RunModes runMode = InstallerMode, SelectMode selectMode = NormalSelectMode );
+
+protected:
+ QScriptValue callScriptMethod( const QString& name, const QScriptValueList& parameters = QScriptValueList() );
+
+private:
+ Q_DISABLE_COPY(Component);
+ class Private;
+ Private* const d;
+};
+
+}
+
+Q_DECLARE_METATYPE( QInstaller::Component* );
+
+#endif // QINSTALLER_COMPONENT_H
diff --git a/installerbuilder/libinstaller/qinstallercomponentmodel.cpp b/installerbuilder/libinstaller/qinstallercomponentmodel.cpp
new file mode 100644
index 000000000..60f023878
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstallercomponentmodel.cpp
@@ -0,0 +1,522 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "qinstallercomponentmodel.h"
+
+#include <algorithm>
+
+#include "qinstallercomponent.h"
+#include "qinstallerglobal.h"
+
+#include "common/utils.h"
+
+#include <QApplication>
+#include <QFont>
+#include <QScriptEngine>
+
+using namespace QInstaller;
+
+struct ComponentIsVirtual
+{
+ bool operator()( const Component* comp ) const
+ {
+ return comp->value( QLatin1String( "Virtual" ), QLatin1String( "false" ) ).toLower() == QLatin1String( "true" );
+ }
+};
+
+struct ComponentPriorityLessThan
+{
+ bool operator()( const Component* lhs, const Component* rhs ) const
+ {
+ return lhs->value( QLatin1String( "SortingPriority" ) ).toInt() <
+ rhs->value( QLatin1String( "SortingPriority" ) ).toInt();
+ }
+};
+
+bool checkCompleteUninstallation( const QInstaller::Component* component )
+{
+ const QList< QInstaller::Component* > components = component->components( true );
+ bool nonSelected = true;
+ Q_FOREACH( const QInstaller::Component* comp, components )
+ {
+ if ( comp->isSelected() )
+ nonSelected = false;
+ if ( !checkCompleteUninstallation( comp ) )
+ nonSelected = false;
+ }
+ return nonSelected;
+}
+
+bool checkWorkRequest( const QInstaller::Component* component )
+{
+ //first check the component itself
+ QString componentName = component->name();
+ QString wantedState = component->value( QLatin1String( "WantedState" ) );
+ QString currentState = component->value( QLatin1String( "CurrentState" ) );
+ if (!wantedState.isEmpty() && !currentState.isEmpty() && wantedState != currentState ) {
+ verbose() << QLatin1String("request work for ") << componentName << QString(QLatin1String(" because WantedState(%1)!=CurrentState(%2)")).arg(wantedState, currentState)<<std::endl;
+ return true;
+ }
+
+ //now checkWorkRequest for all childs
+ const QList< QInstaller::Component* > components = component->components( true );
+ Q_FOREACH( const QInstaller::Component* currentComponent, components )
+ {
+ if ( checkWorkRequest( currentComponent ) )
+ return true;
+ }
+ return false;
+}
+
+ComponentModel::ComponentModel( Installer* parent, RunModes runMode )
+ : QAbstractItemModel( parent ), m_runMode( runMode )
+{
+
+ if ( runMode == InstallerMode )
+ connect( parent, SIGNAL( componentsAdded( QList< QInstaller::Component* > ) ), this, SLOT( addComponents(QList< QInstaller::Component* > ) ) );
+ else
+ connect( parent, SIGNAL( updaterComponentsAdded( QList< QInstaller::Component* > ) ), this, SLOT( addComponents(QList< QInstaller::Component* > ) ) );
+ connect( parent, SIGNAL( componentsAboutToBeCleared() ), this, SLOT( clear() ) );
+ connect( parent, SIGNAL( componentAdded( QInstaller::Component* ) ), this, SLOT( componentAdded( QInstaller::Component* ) ) );
+}
+
+void ComponentModel::addComponents( QList< Component* > components )
+{
+ beginResetModel();
+ bool requestWork = false;
+ Q_FOREACH( Component* currentComponent, components )
+ {
+ if ( !this->components.contains( currentComponent ) )
+ this->components.push_back( currentComponent );
+ if ( checkWorkRequest( currentComponent ) ) {
+ requestWork = true;
+ break;
+ }
+ }
+ endResetModel();
+ emit workRequested( requestWork );
+}
+void ComponentModel::clear()
+{
+ beginResetModel();
+ components.clear();
+ seenComponents.clear();
+ endResetModel();
+}
+
+ComponentModel::~ComponentModel()
+{
+}
+
+void ComponentModel::selectedChanged( bool checked )
+{
+ Q_UNUSED( checked )
+ Component *comp = dynamic_cast<Component*>( QObject::sender() );
+ Q_ASSERT( comp );
+ bool requestWork = false;
+ Q_FOREACH( Component *c, comp->components( false, m_runMode ) ) {
+ if( !seenComponents.contains( c ) )
+ {
+ connect( c, SIGNAL( selectedChanged( bool ) ), this, SLOT( selectedChanged( bool ) ) );
+ seenComponents.push_back( c );
+ }
+ }
+ Q_FOREACH( const Component * currentComponent, components )
+ {
+ if ( checkWorkRequest( currentComponent ) ) {
+ requestWork = true;
+ break;
+ }
+ }
+ emit workRequested( requestWork );
+ emit dataChanged( this->index( 0, 0 ), QModelIndex() );
+}
+
+void ComponentModel::componentAdded( Component* comp )
+{
+ Q_UNUSED( comp )
+ reset();
+}
+
+/*!
+ \reimpl
+*/
+QModelIndex ComponentModel::index( int row, int column, const QModelIndex& parent ) const
+{
+ if( row < 0 || row >= rowCount( parent ) )
+ return QModelIndex();
+ if( column < 0 || column >= columnCount( parent ) )
+ return QModelIndex();
+
+ QList< Component* > components = !parent.isValid() ? this->components
+ : reinterpret_cast< Component* >( parent.internalPointer() )->components( false, m_runMode );
+ // don't count virtual components
+ if( !virtualComponentsVisible() && m_runMode == InstallerMode )
+ components.erase( std::remove_if( components.begin(), components.end(), ComponentIsVirtual() ), components.end() );
+
+ // sort by priority
+ std::sort( components.begin(), components.end(), ComponentPriorityLessThan() );
+
+ Component* const comp = components[ row ];
+
+ QModelIndex index = createIndex( row, column, comp );
+
+ if( !seenComponents.contains( comp ) )
+ {
+ connect( comp, SIGNAL( selectedChanged( bool ) ), this, SLOT( selectedChanged( bool ) ) );
+ seenComponents.push_back( comp );
+ }
+
+ return index;
+}
+
+/*!
+ \reimpl
+*/
+QModelIndex ComponentModel::parent( const QModelIndex& index ) const
+{
+ if( !index.isValid() )
+ return QModelIndex();
+ const Component* const component = reinterpret_cast< Component* >( index.internalPointer() );
+ Component* const parentComponent = component->parentComponent( m_runMode );
+ if( parentComponent == 0 )
+ return QModelIndex();
+ QList< Component* > parentSiblings = parentComponent->parentComponent() == 0 ? this->components
+ : parentComponent->parentComponent()->components( false, m_runMode );
+ // don't count virtual components
+ if( !virtualComponentsVisible() && m_runMode == InstallerMode )
+ parentSiblings.erase( std::remove_if( parentSiblings.begin(), parentSiblings.end(), ComponentIsVirtual() ), parentSiblings.end() );
+
+ // sort by priority
+ std::sort( parentSiblings.begin(), parentSiblings.end(), ComponentPriorityLessThan() );
+
+ return createIndex( parentSiblings.indexOf( parentComponent ), 0, parentComponent );
+}
+
+/*!
+ \reimpl
+*/
+int ComponentModel::columnCount( const QModelIndex& parent ) const
+{
+ Q_UNUSED( parent );
+ return 4;
+}
+
+/*!
+ \reimpl
+*/
+int ComponentModel::rowCount( const QModelIndex& parent ) const
+{
+ if( parent.column() > 0 )
+ return 0;
+
+ QList< Component* > components = !parent.isValid() ? this->components
+ : reinterpret_cast< Component* >( parent.internalPointer() )->components( false, m_runMode );
+
+ // don't count virtual components
+ if( !virtualComponentsVisible() && m_runMode == InstallerMode )
+ components.erase( std::remove_if( components.begin(), components.end(), ComponentIsVirtual() ), components.end() );
+
+ return components.count();
+}
+
+/*!
+ \reimpl
+*/
+Qt::ItemFlags ComponentModel::flags( const QModelIndex& index ) const
+{
+ Qt::ItemFlags result = QAbstractItemModel::flags( index );
+ if ( !index.isValid() )
+ return result;
+ const Component* const component = reinterpret_cast< Component* >( index.internalPointer() );
+ const bool forcedInstallation = QVariant( component->value( QLatin1String( "ForcedInstallation" ) ) ).toBool();
+
+ if (m_runMode == UpdaterMode || !forcedInstallation)
+ result |= Qt::ItemIsUserCheckable;
+ if ( !component->isEnabled() )
+ result &= Qt::ItemIsDropEnabled;
+ if (m_runMode == InstallerMode && forcedInstallation) {
+ result &= ~Qt::ItemIsEnabled; //now it should look like a disabled item
+ }
+ return result;
+}
+
+/*!
+ \reimpl
+*/
+bool ComponentModel::setData( const QModelIndex& index, const QVariant& data, int role )
+{
+ if( !index.isValid() )
+ return false;
+
+ Component* const component = reinterpret_cast< Component* >( index.internalPointer() );
+ switch( role )
+ {
+ case Qt::CheckStateRole: {
+ if( !( flags( index ) & Qt::ItemIsUserCheckable ) )
+ return false;
+ const bool check = data.toInt() == Qt::Checked;
+ component->setSelected( check, m_runMode );
+ bool requestWork = false;
+ bool nonSelected = true;
+ Q_FOREACH( const QInstaller::Component* currentComponent, components )
+ {
+ if ( checkWorkRequest( currentComponent ) ) {
+ requestWork |= true;
+ }
+ if ( currentComponent->isSelected() )
+ nonSelected = false;
+ if ( !checkCompleteUninstallation( currentComponent ) )
+ nonSelected = false;
+ }
+ if ( m_runMode == InstallerMode )
+ {
+ Installer* installer = dynamic_cast< Installer* > ( QObject::parent() );
+ installer->setCompleteUninstallation( nonSelected );
+ }
+ emit workRequested( requestWork );
+ return true;
+ }
+ default:
+ return false;
+ }
+}
+
+Qt::CheckState QInstaller::componentCheckState( const Component* component, RunModes runMode )
+{
+ if( QVariant( component->value( QLatin1String( "ForcedInstallation" ) ) ).toBool() )
+ return Qt::Checked;
+
+ QString autoSelect = component->value( QLatin1String( "AutoSelectOn" ) );
+ // check the auto select expression
+ if( !autoSelect.isEmpty() )
+ {
+ QScriptEngine engine;
+ const QList< Component* > components = component->installer()->components( true, runMode );
+ for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
+ {
+ const Component* const c = *it;
+ if( c == component )
+ continue;
+ QString name = c->name();
+ name.replace( QLatin1String( "." ), QLatin1String( "___" ) );
+ engine.evaluate( QString::fromLatin1( "%1 = %2;" ).arg( name, QVariant( c ->isSelected() ).toString() ) );
+ }
+ autoSelect.replace( QLatin1String( "." ), QLatin1String( "___" ) );
+ if( engine.evaluate( autoSelect ).toBool() )
+ return Qt::Checked;
+ }
+
+ // if one of our dependees is checked, we are checked
+ const QList< Component* > dependees = component->dependees();
+ for( QList< Component* >::const_iterator it = dependees.begin(); it != dependees.end(); ++it )
+ {
+ if( *it == component )
+ {
+ verbose() << "Infinite loop in dependencies detected, bailing out..." << std::endl;
+ return Qt::Unchecked;
+ }
+ const Qt::CheckState state = (*it)->checkState();
+ if( state == Qt::Checked )
+ return state;
+ }
+
+ // if the component has children then we need to check if all children are selected
+ // to set the state to either checked if all children are selected or to unchecked
+ // if no children are selected or otherwise to partially checked.
+ bool foundChecked = false;
+ bool foundUnchecked = false;
+ QList< Component* > children = component->components( true, runMode );
+ // don't count virtual components
+ children.erase( std::remove_if( children.begin(), children.end(), ComponentIsVirtual() ), children.end() );
+ if( !children.isEmpty() )
+ {
+ for( QList< Component* >::const_iterator it = children.begin(); it != children.end(); ++it )
+ {
+ const Qt::CheckState state = (*it)->checkState();
+ foundChecked = foundChecked || state == Qt::Checked || state == Qt::PartiallyChecked;
+ foundUnchecked = foundUnchecked || state == Qt::Unchecked;
+ }
+ if( foundChecked && foundUnchecked )
+ return Qt::PartiallyChecked;
+ else if( foundChecked && ! foundUnchecked )
+ return Qt::Checked;
+ else if( foundUnchecked && ! foundChecked )
+ return Qt::Unchecked;
+ //else fall through
+ }
+
+ // explicitely selected
+ if( component->value( QString::fromLatin1( "WantedState" ) ) == QString::fromLatin1( "Installed" ) )
+ return Qt::Checked;
+
+ // explicitely unselected
+ else if ( component->value( QString::fromLatin1( "WantedState" ) ) == QString::fromLatin1( "Uninstalled" ) )
+ return Qt::Unchecked;
+
+ // no decision made, use the predefined:
+ const QString suggestedState = component->value( QString::fromLatin1( "SuggestedState" ) );
+ if( suggestedState == QString::fromLatin1( "Installed" ) )
+ return Qt::Checked;
+ return Qt::Unchecked;
+}
+
+/*!
+ \reimp
+*/
+QVariant ComponentModel::data( const QModelIndex& index, int role ) const
+{
+ if( !index.isValid() )
+ return QVariant();
+
+ Component* const component = reinterpret_cast< Component* >( index.internalPointer() );
+
+ switch( index.column() )
+ {
+ case NameColumn:
+ switch( role )
+ {
+ case Qt::EditRole:
+ case Qt::DisplayRole:
+ return component->displayName();
+ case Qt::CheckStateRole:
+ return component->checkState( m_runMode );
+ case Qt::ToolTipRole:
+ return component->value( QString::fromLatin1( "Description" ) ) + QLatin1String( "<br><br> Update Info: " ) + component->value( QLatin1String ( "UpdateText" ) ) ;
+ case Qt::FontRole:
+ return component->value( QLatin1String( "Virtual" ), QLatin1String( "false" ) ).toLower() == QLatin1String( "true" ) ? virtualComponentsFont() : QFont();
+ case ComponentRole:
+ return qVariantFromValue( component );
+ case IdRole:
+ return component->name();
+ default:
+ return QVariant();
+ }
+ case VersionColumn:
+ if( role == Qt::DisplayRole )
+ return component->value( QLatin1String( "Version" ) );
+ break;
+ case InstalledVersionColumn:
+ if( role == Qt::DisplayRole )
+ return component->value( QLatin1String( "InstalledVersion" ) );
+ break;
+ case SizeColumn:
+ if( role == Qt::DisplayRole )
+ {
+ double size = component->value( QLatin1String( "UncompressedSize" ) ).toDouble();
+ if( size < 10000.0 )
+ return tr( "%L1 Bytes" ).arg( size );
+ size /= 1024.0;
+ if( size < 10000.0 )
+ return tr( "%L1 kB" ).arg( size, 0, 'f', 1 );
+ size /= 1024.0;
+ if( size < 10000.0 )
+ return tr( "%L1 MB" ).arg( size, 0, 'f', 1 );
+ size /= 1024.0;
+ return tr( "%L1 GB" ).arg( size, 0, 'f', 1 );
+ }
+ break;
+ }
+ return QVariant();
+}
+
+/*!
+ \reimp
+*/
+QVariant ComponentModel::headerData( int section, Qt::Orientation orientation, int role ) const
+{
+ if( orientation != Qt::Horizontal || role != Qt::DisplayRole )
+ return QAbstractItemModel::headerData( section, orientation, role );
+
+ switch( section )
+ {
+ case NameColumn:
+ return tr( "Name" );
+ case InstalledVersionColumn:
+ return tr( "Installed Version" );
+ case VersionColumn:
+ return tr( "New Version" );
+ case SizeColumn:
+ return tr( "Size" );
+ default:
+ return QAbstractItemModel::headerData( section, orientation, role );
+ }
+}
+
+static bool s_virtualComponentsVisible = false;
+
+bool ComponentModel::virtualComponentsVisible()
+{
+ return s_virtualComponentsVisible;
+}
+
+void ComponentModel::setVirtualComponentsVisible( bool visible )
+{
+ s_virtualComponentsVisible = visible;
+}
+
+static QFont s_virtualComponentsFont;
+
+QFont ComponentModel::virtualComponentsFont()
+{
+ return s_virtualComponentsFont;
+}
+
+void ComponentModel::setVirtualComponentsFont( const QFont& f )
+{
+ s_virtualComponentsFont = f;
+}
+
+QModelIndex ComponentModel::findComponent( const QString& id ) const
+{
+ QModelIndex idx = index( 0, NameColumn );
+ while ( idx.isValid() && idx.data( IdRole ).toString() != id ) {
+ if ( rowCount( idx ) > 0 ) {
+ idx = idx.child( 0, NameColumn );
+ continue;
+ }
+
+ bool foundNext = false;
+
+ while ( !foundNext ) {
+ const int oldRow = idx.row();
+ idx = idx.parent();
+ const int rc = rowCount( idx );
+ if ( oldRow < rc - 1 ) {
+ idx = index( oldRow + 1, NameColumn, idx );
+ foundNext = true;
+ } else if ( !idx.isValid() )
+ return idx;
+ }
+ }
+ return idx;
+}
diff --git a/installerbuilder/libinstaller/qinstallercomponentmodel.h b/installerbuilder/libinstaller/qinstallercomponentmodel.h
new file mode 100644
index 000000000..1894bd02b
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstallercomponentmodel.h
@@ -0,0 +1,95 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_COMPONENTMODEL_H
+#define QINSTALLER_COMPONENTMODEL_H
+
+#include <QAbstractItemModel>
+#include <QList>
+
+#include "installer_global.h"
+
+namespace QInstaller {
+class Installer;
+class Component;
+
+class INSTALLER_EXPORT ComponentModel : public QAbstractItemModel
+{
+ Q_OBJECT
+public:
+ enum Role {
+ ComponentRole=Qt::UserRole,
+ IdRole
+ };
+
+ enum Column {
+ NameColumn=0,
+ InstalledVersionColumn,
+ VersionColumn,
+ SizeColumn
+ };
+
+ explicit ComponentModel( Installer* parent, RunModes runMode = InstallerMode);
+ ~ComponentModel();
+
+ QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const;
+ QModelIndex parent( const QModelIndex& index ) const;
+
+ int columnCount( const QModelIndex& parent = QModelIndex() ) const;
+ int rowCount( const QModelIndex& parent = QModelIndex() ) const;
+
+ Qt::ItemFlags flags( const QModelIndex& index ) const;
+
+ bool setData( const QModelIndex& index, const QVariant& data, int role = Qt::CheckStateRole );
+ QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
+ QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
+
+ static bool virtualComponentsVisible();
+ static void setVirtualComponentsVisible( bool visible );
+
+ static QFont virtualComponentsFont();
+ static void setVirtualComponentsFont( const QFont& f );
+
+ QModelIndex findComponent( const QString& id ) const;
+Q_SIGNALS:
+ void workRequested( bool value );
+
+public Q_SLOTS:
+ void addComponents(QList< QInstaller::Component* > components );
+ void clear();
+
+private Q_SLOTS:
+ void componentAdded( QInstaller::Component* comp );
+ void selectedChanged( bool checked );
+
+private:
+ mutable QList< Component* > seenComponents;
+ QList< Component* > components;
+ RunModes m_runMode;
+};
+
+}
+
+#endif // QINSTALLER_COMPONENTMODEL_H
diff --git a/installerbuilder/libinstaller/qinstallerglobal.h b/installerbuilder/libinstaller/qinstallerglobal.h
new file mode 100644
index 000000000..4f23af95f
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstallerglobal.h
@@ -0,0 +1,76 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_GLOBAL_H
+#define QINSTALLER_GLOBAL_H
+
+#include <installer_global.h>
+
+#include <QtGlobal>
+#include <qnamespace.h>
+
+#define ifVerbose(s) if (!installer()->isVerbose()) {} else { qDebug() << s; }
+
+class QIODevice;
+class QFile;
+template <typename T> class QList;
+class QScriptContext;
+class QScriptEngine;
+class QScriptValue;
+
+namespace QInstaller {
+
+class Component;
+
+#if 0
+// Faster or not?
+static void appendFileData(QIODevice *out, const QString &fileName)
+{
+ QFile file(fileName);
+ openForRead(file);
+ qint64 size = file.size();
+ QInstaller::appendInt(out, size);
+ if (size == 0)
+ return;
+ uchar *data = file.map(0, size);
+ if (!data)
+ throw Error(QInstaller::tr("Cannot map file %1").arg(file.fileName()));
+ rawWrite(out, (const char *)data, size);
+ if (!file.unmap(data))
+ throw Error(QInstaller::tr("Cannot unmap file %1").arg(file.fileName()));
+}
+#endif
+
+ QScriptValue qDesktopServicesOpenUrl( QScriptContext* context, QScriptEngine* engine );
+ QScriptValue qDesktopServicesDisplayName( QScriptContext* context, QScriptEngine* engine );
+ QScriptValue qDesktopServicesStorageLocation( QScriptContext* context, QScriptEngine* engine );
+
+ QScriptValue qInstallerComponentByName( QScriptContext* context, QScriptEngine* engine );
+
+ Qt::CheckState componentCheckState( const Component* component, RunModes runMode = InstallerMode );
+ QString uncaughtExceptionString(QScriptEngine *scriptEngine/*, const QString &context*/);
+}
+
+#endif // QINSTALLER_GLOBAL_H
diff --git a/installerbuilder/libinstaller/qinstallergui.cpp b/installerbuilder/libinstaller/qinstallergui.cpp
new file mode 100644
index 000000000..8f34a5a9f
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstallergui.cpp
@@ -0,0 +1,1721 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+
+#include "qinstallergui.h"
+
+#include "qinstaller.h"
+#include "qinstallerglobal.h"
+#include "qinstallercomponent.h"
+#include "qinstallercomponentmodel.h"
+#include "progresscoordinator.h"
+#include "performinstallationform.h"
+
+#include "common/errors.h"
+#include "common/utils.h"
+#include "common/installersettings.h"
+#include "common/fileutils.h"
+
+#include <KDToolsCore/KDByteSize>
+#include <KDToolsCore/KDSysInfo>
+
+#include <QtCore/QDir>
+#include <QtCore/QDynamicPropertyChangeEvent>
+#include <QtCore/QPair>
+#include <QtCore/QProcess>
+#include <QtCore/QRegExp>
+#include <QtCore/QSettings>
+#include <QtCore/QTimer>
+
+#include <QtGui/QApplication>
+#include <QtGui/QCheckBox>
+#include <QtGui/QDesktopServices>
+#include <QtGui/QFileDialog>
+#include <QtGui/QGridLayout>
+#include <QtGui/QFormLayout>
+#include <QtGui/QHBoxLayout>
+#include <QtGui/QHeaderView>
+#include <QtGui/QGroupBox>
+#include <QtGui/QLabel>
+#include <QtGui/QLineEdit>
+#include <QtGui/QListWidget>
+#include <QtGui/QListWidgetItem>
+#include <QtGui/QMessageBox>
+#include <QtGui/QProgressBar>
+#include <QtGui/QPushButton>
+#include <QtGui/QRadioButton>
+#include <QtGui/QTextBrowser>
+#include <QtGui/QTreeWidget>
+#include <QtGui/QTreeView>
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QScrollBar>
+
+#include <QtScript/QScriptEngine>
+
+using namespace QInstaller;
+
+/*
+TRANSLATOR QInstaller::Installer;
+*/
+/*
+TRANSLATOR QInstaller::Gui
+*/
+/*
+TRANSLATOR QInstaller::Page
+*/
+/*
+TRANSLATOR QInstaller::IntroductionPage
+*/
+/*
+TRANSLATOR QInstaller::LicenseAgreementPage
+*/
+/*
+TRANSLATOR QInstaller::ComponentSelectionPage
+*/
+/*
+TRANSLATOR QInstaller::TargetDirectoryPage
+*/
+/*
+TRANSLATOR QInstaller::StartMenuDirectoryPage
+*/
+/*
+TRANSLATOR QInstaller::ReadyForInstallationPage
+*/
+/*
+TRANSLATOR QInstaller::PerformInstallationPage
+*/
+/*
+TRANSLATOR QInstaller::FinishedPage
+*/
+
+
+class DynamicInstallerPage : public Page
+{
+public:
+ explicit DynamicInstallerPage( QWidget* widget, Installer* parent = 0 )
+ : Page( parent ),
+ m_widget( widget )
+ {
+ setObjectName( QLatin1String("Dynamic") + widget->objectName() );
+ setPixmap(QWizard::LogoPixmap, logoPixmap());
+ setPixmap(QWizard::WatermarkPixmap, QPixmap());
+
+ setLayout( new QVBoxLayout );
+ setTitle( widget->windowTitle() );
+ m_widget->setProperty( "complete", true );
+ m_widget->setProperty( "final", false );
+ widget->installEventFilter( this );
+ layout()->addWidget( widget );
+ }
+
+ QWidget* widget() const
+ {
+ return m_widget;
+ }
+
+ bool isComplete() const
+ {
+ return m_widget->property( "complete" ).toBool();
+ }
+
+protected:
+ bool eventFilter( QObject* obj, QEvent* event )
+ {
+ if( obj == m_widget )
+ {
+ switch( event->type() )
+ {
+ case QEvent::WindowTitleChange:
+ setTitle( m_widget->windowTitle() );
+ break;
+ case QEvent::DynamicPropertyChange:
+ emit completeChanged();
+ if( m_widget->property( "final" ).toBool() != isFinalPage() )
+ setFinalPage( m_widget->property( "final" ).toBool() );
+ break;
+ default:
+ break;
+ }
+ }
+ return Page::eventFilter( obj, event );
+ }
+
+private:
+ QWidget* const m_widget;
+};
+
+////////////////////////////////////////////////////////////////////
+//
+// Gui
+//
+////////////////////////////////////////////////////////////////////
+
+
+class Gui::Private
+{
+public:
+ Private()
+ : autoSwitchPage(true),
+ modified( false )
+ {
+
+ }
+
+ QScriptEngine controlScriptEngine;
+ QScriptValue controlScript;
+ bool autoSwitchPage;
+ bool modified;
+};
+
+QScriptEngine* Gui::controlScriptEngine() const
+{
+ return &d->controlScriptEngine;
+}
+
+/*!
+ \class QInstaller::Gui
+ Is the "gui" object in a none interactive installation
+ */
+
+Gui::Gui(Installer *installer, QWidget *parent)
+ : QWizard(parent)
+ , m_installer( installer )
+ , d( new Private )
+ , m_introPage( new IntroductionPage( installer ) )
+{
+ if ( installer->isInstaller() )
+ setWindowTitle(tr("%1 Setup").arg(m_installer->value(QLatin1String( "Title" ) ) ) );
+ else
+ setWindowTitle(tr("%1").arg(m_installer->value(QLatin1String( "maintenanceTitle") ) ) );
+
+#ifndef Q_WS_MAC
+ setWindowIcon( QIcon( m_installer->settings().icon() ) );
+ setWizardStyle( QWizard::ModernStyle );
+#else
+ setPixmap( QWizard::BackgroundPixmap, m_installer->settings().background() );
+#endif
+ setOption(QWizard::NoBackButtonOnStartPage);
+ setOption(QWizard::NoBackButtonOnLastPage);
+// setOption(QWizard::IndependentPages);
+ setLayout( new QVBoxLayout( this ) );
+ if ( installer->isInstaller() )
+ setPage( Installer::Introduction, m_introPage );
+
+ connect(this, SIGNAL(interrupted()), installer, SLOT(interrupt()));
+ connect(this, SIGNAL(rejected()), installer, SLOT(setCanceled()) );
+ // both queued to show the finished page once everything is done
+ connect(installer, SIGNAL(installationFinished()), this,
+ SLOT(showFinishedPage()), Qt::QueuedConnection);
+ connect(installer, SIGNAL(uninstallationFinished()), this,
+ SLOT(showFinishedPage()), Qt::QueuedConnection);
+
+ connect( this, SIGNAL( currentIdChanged( int ) ), this, SLOT( slotCurrentPageChanged( int ) ) );
+ connect( this, SIGNAL( currentIdChanged( int ) ), m_installer, SIGNAL( currentPageChanged( int ) ) );
+ connect( button( QWizard::FinishButton ), SIGNAL( clicked() ), this, SIGNAL( finishButtonClicked() ) );
+ connect( this, SIGNAL( finishButtonClicked() ), installer, SIGNAL( finishButtonClicked() ) );
+
+ // make sure the QUiLoader's retranslateUi is executed first, then the script
+ connect( this, SIGNAL( languageChanged() ),
+ installer, SLOT( languageChanged() ), Qt::QueuedConnection );
+
+ connect( installer, SIGNAL( wizardPageInsertionRequested( QWidget*, Installer::WizardPage ) ),
+ this, SLOT( wizardPageInsertionRequested( QWidget*, Installer::WizardPage ) ) );
+ connect( installer, SIGNAL( wizardPageRemovalRequested( QWidget* ) ),
+ this, SLOT( wizardPageRemovalRequested( QWidget* ) ) );
+ connect( installer, SIGNAL( wizardWidgetInsertionRequested( QWidget*, Installer::WizardPage ) ),
+ this, SLOT( wizardWidgetInsertionRequested( QWidget*, Installer::WizardPage ) ) );
+ connect( installer, SIGNAL( wizardWidgetRemovalRequested( QWidget* ) ),
+ this, SLOT( wizardWidgetRemovalRequested( QWidget* ) ) );
+ connect( installer, SIGNAL( wizardPageVisibilityChangeRequested( bool, int ) ),
+ this, SLOT( wizardPageVisibilityChangeRequested( bool, int ) ), Qt::QueuedConnection );
+
+ connect( installer, SIGNAL( setAutomatedPageSwitchEnabled( bool ) ),
+ this, SLOT( setAutomatedPageSwitchEnabled( bool ) ) );
+
+#ifdef Q_WS_MAC
+ setButtonText( QWizard::BackButton, tr( "Go Back" ) );
+ setButtonText( QWizard::NextButton, tr( "Continue" ) );
+ setButtonText( QWizard::FinishButton, tr( "Done" ) );
+#else
+ setButtonText( QWizard::BackButton, tr( "Back" ) );
+ setButtonText( QWizard::NextButton, tr( "Next" ) );
+ setButtonText( QWizard::FinishButton, tr( "Finish" ) );
+#endif
+ setButtonText( QWizard::CancelButton, tr( "Cancel" ) );
+
+ dynamic_cast< QPushButton* >( button( QWizard::NextButton ) )->setDefault( true );
+
+#ifdef Q_WS_MAC
+ resize( sizeHint() * 1.25 );
+#else
+ resize( sizeHint() );
+#endif
+}
+
+Gui::~Gui()
+{
+ delete d;
+}
+
+void Gui::setAutomatedPageSwitchEnabled( bool request )
+{
+ d->autoSwitchPage = request;
+}
+
+
+void Gui::clickButton( int wb, int delay )
+{
+ if ( QAbstractButton* b = button( static_cast<QWizard::WizardButton>( wb ) ) )
+ QTimer::singleShot( delay, b, SLOT(click()) );
+ else {
+ //TODO we should probably abort immediately here (faulty test script)
+ verbose() << "Button " << wb << " not found!" << std::endl;
+ }
+}
+
+/*!
+ * Loads a script to perform the installation non-interactively.
+ *
+ * @throws QInstaller::Error if the script is not readable/cannot be parsed
+ */
+void Gui::loadControlScript( const QString& scriptPath )
+{
+ QFile file( scriptPath );
+ if( !file.open( QIODevice::ReadOnly ) )
+ throw Error( QObject::tr( "Could not open the requested script file at %1: %2" ).arg( scriptPath, file.errorString() ) );
+
+ d->controlScriptEngine.globalObject().setProperty( QLatin1String( "installer" ), d->controlScriptEngine.newQObject( m_installer ) );
+ d->controlScriptEngine.globalObject().setProperty( QLatin1String( "gui" ), d->controlScriptEngine.newQObject( this ) );
+ registerMessageBox( &d->controlScriptEngine );
+
+#undef REGISTER_BUTTON
+#define REGISTER_BUTTON(x) buttons.setProperty( QLatin1String( #x ), d->controlScriptEngine.newVariant( static_cast<int>( QWizard::x ) ) );
+
+ QScriptValue buttons = d->controlScriptEngine.newArray();
+ REGISTER_BUTTON( BackButton )
+ REGISTER_BUTTON( NextButton )
+ REGISTER_BUTTON( CommitButton )
+ REGISTER_BUTTON( FinishButton )
+ REGISTER_BUTTON( CancelButton )
+ REGISTER_BUTTON( HelpButton )
+ REGISTER_BUTTON( CustomButton1 )
+ REGISTER_BUTTON( CustomButton2 )
+ REGISTER_BUTTON( CustomButton3 )
+
+#undef REGISTER_BUTTON
+
+ d->controlScriptEngine.globalObject().setProperty( QLatin1String( "buttons" ), buttons );
+
+ d->controlScriptEngine.evaluate( QLatin1String( file.readAll() ), scriptPath );
+ if( d->controlScriptEngine.hasUncaughtException() ) {
+ throw Error( QObject::tr( "Exception while loading the control script %1" )
+ .arg(uncaughtExceptionString(&(d->controlScriptEngine)/*, scriptPath*/)) );
+ }
+
+ QScriptValue comp = d->controlScriptEngine.evaluate( QLatin1String( "Controller" ) );
+ if( d->controlScriptEngine.hasUncaughtException() ) {
+ throw Error( QObject::tr( "Exception while loading the control script %1" )
+ .arg(uncaughtExceptionString(&(d->controlScriptEngine)/*, scriptPath*/)) );
+ }
+
+ d->controlScript = comp;
+ d->controlScript.construct();
+
+ verbose() << "Loaded control script " << qPrintable(scriptPath) << std::endl;
+}
+
+void Gui::triggerControlScriptForCurrentPage()
+{
+ slotCurrentPageChanged( currentId() );
+}
+
+void Gui::slotCurrentPageChanged( int id )
+{
+ QMetaObject::invokeMethod( this, "delayedControlScriptExecution", Qt::QueuedConnection, Q_ARG( int, id ) );
+}
+
+void Gui::callControlScriptMethod( const QString& methodName )
+{
+ QScriptValue method = d->controlScript.property( QLatin1String( "prototype" ) ).property( methodName );
+
+ if ( !method.isValid() ) {
+ verbose() << "Control script callback " << qPrintable(methodName) << " does not exist." << std::endl;
+ return;
+ }
+
+ verbose() << "Calling control script callback " << qPrintable(methodName) << std::endl;
+
+ method.call( d->controlScript );
+
+ if( d->controlScriptEngine.hasUncaughtException() )
+ qCritical() << uncaughtExceptionString(&(d->controlScriptEngine)/*, QLatin1String("control script")*/);
+ //TODO handle error
+}
+
+void Gui::delayedControlScriptExecution( int id )
+{
+ Page* const p = qobject_cast<Page*>( page( id ) );
+ if ( !p )
+ return;
+ const QString methodName = p->objectName() + QLatin1String("Callback");
+ callControlScriptMethod( methodName );
+}
+
+
+IntroductionPage* Gui::introductionPage() const
+{
+ return m_introPage;
+}
+
+bool Gui::event( QEvent* event )
+{
+ switch( event->type() )
+ {
+ case QEvent::LanguageChange:
+ emit languageChanged();
+ break;
+ default:
+ break;
+ }
+ return QWizard::event( event );
+}
+
+void Gui::wizardPageInsertionRequested( QWidget* widget, Installer::WizardPage page )
+{
+ // just in case it was already in there...
+ wizardPageRemovalRequested( widget );
+
+ // now find a suitable ID lower than page
+ int p = static_cast< int >( page ) - 1;
+ while( QWizard::page( p ) != 0 )
+ --p;
+ // ad it
+ setPage( p, new DynamicInstallerPage( widget, m_installer ) );
+}
+
+void Gui::wizardPageRemovalRequested( QWidget* widget )
+{
+ const QList< int > pages = pageIds();
+ for( QList< int >::const_iterator it = pages.begin(); it != pages.end(); ++it )
+ {
+ QWizardPage* const p = page( *it );
+ DynamicInstallerPage* const dynamicPage = dynamic_cast< DynamicInstallerPage* >( p );
+ if( dynamicPage == 0 )
+ continue;
+ if( dynamicPage->widget() != widget )
+ continue;
+ removePage( *it );
+ }
+}
+
+void Gui::wizardWidgetInsertionRequested( QWidget* widget, Installer::WizardPage page )
+{
+ Q_ASSERT(widget);
+ QWizardPage* const p = QWizard::page( page );
+ if (p)
+ p->layout()->addWidget( widget );
+}
+
+void Gui::wizardWidgetRemovalRequested( QWidget* widget )
+{
+ Q_ASSERT(widget);
+ widget->setParent( 0 );
+}
+
+void Gui::wizardPageVisibilityChangeRequested( bool visible, int p )
+{
+ if( visible && page( p ) == 0 )
+ {
+ setPage( p, defaultPages[ p ] );
+ }
+ else if( !visible && page( p ) != 0 )
+ {
+ defaultPages[ p ] = page( p );
+ removePage( p );
+ }
+}
+
+QWidget* Gui::pageWidgetByObjectName( const QString& name ) const
+{
+ const QList<int> ids = pageIds();
+ Q_FOREACH( const int i, ids ) {
+ Page* const p = qobject_cast<Page*>( page( i ) );
+ if ( p && p->objectName() == name ) {
+ // For dynamic pages, return the contained widget (as read from the UI file), not the wrapper page
+ if ( DynamicInstallerPage* dp = dynamic_cast<DynamicInstallerPage*>( p ) )
+ return dp->widget();
+ else
+ return p;
+ }
+ }
+ verbose() << "No page found for object name " << name << std::endl;
+ return 0;
+}
+
+QWidget* Gui::currentPageWidget() const
+{
+ return currentPage();
+}
+
+void Gui::cancelButtonClicked()
+{
+ const bool doIgnore = m_installer->isInstaller()
+ ? m_installer->status() == Installer::InstallerCanceledByUser || m_installer->status() == Installer::InstallerSucceeded
+ : m_installer->status() == Installer::InstallerCanceledByUser;
+
+ //if the user canceled (all modes) or the installation is finished (installer mode only), ignore
+ //clicks on cancel.
+ if ( doIgnore )
+ return;
+
+ //close the manager without asking if nothing was modified, always ask for the installer
+ if ( !m_installer->isInstaller() && !d->modified ) {
+ QDialog::reject();
+ return;
+ }
+
+ Page* const page = qobject_cast< Page* >( currentPage() );
+ verbose() << "CANCEL CLICKED" << currentPage() << page << std::endl;
+ if (page && page->isInterruptible()) {
+ const QMessageBox::StandardButton bt = MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("cancelInstallation"),
+ tr("Warning"),
+ tr("Do you want to abort the %1 process?").arg( m_installer->isUninstaller() ? tr( "uninstallation" ) : tr( "installation" ) ),
+ QMessageBox::Yes | QMessageBox::No);
+ if (bt == QMessageBox::Yes)
+ emit interrupted();
+ } else {
+ const QMessageBox::StandardButton bt = MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("cancelInstallation"),
+ tr("Warning"),
+ tr("Do you want to abort the %1 application?").arg( m_installer->isUninstaller() ? tr( "uninstaller" ) : tr( "installer" ) ),
+ QMessageBox::Yes | QMessageBox::No);
+ if (bt == QMessageBox::Yes)
+ QDialog::reject();
+ }
+}
+
+void Gui::rejectWithoutPrompt()
+{
+ m_installer->setCanceled();
+ QDialog::reject();
+}
+
+void Gui::reject()
+{
+ cancelButtonClicked();
+}
+void Gui::setModified( bool value )
+{
+ d->modified = value;
+}
+
+void Gui::showFinishedPage()
+{
+ verbose() << "SHOW FINISHED PAGE" << std::endl;
+ if (d->autoSwitchPage){
+ next();
+ }else{
+ dynamic_cast< QPushButton* >( button( QWizard::CancelButton ) )->setEnabled( false );
+ }
+}
+
+////////////////////////////////////////////////////////////////////
+//
+// Page
+//
+////////////////////////////////////////////////////////////////////
+
+Page::Page(Installer *installer)
+ : m_installer(installer), m_fresh(true), m_complete(true)
+{
+ setSubTitle( QLatin1String( " " ) ); // otherwise the colors will screw up
+}
+
+Installer *Page::installer() const
+{
+ return m_installer;
+}
+
+QPixmap Page::watermarkPixmap() const
+{
+ return QPixmap(m_installer->value( QLatin1String( "WatermarkPixmap" ) ) );
+}
+
+QPixmap Page::logoPixmap() const
+{
+ return QPixmap(m_installer->value( QLatin1String( "LogoPixmap" ) ) );
+}
+
+QString Page::productName() const
+{
+ return m_installer->value( QLatin1String( "ProductName" ) );
+}
+
+bool Page::isComplete() const
+{
+ return m_complete;
+}
+
+void Page::setComplete(bool complete)
+{
+ m_complete = complete;
+ emit completeChanged();
+ if( wizard() == 0 )
+ return;
+ if( wizard()->button( QWizard::CancelButton ) == 0 )
+ return;
+ if( wizard()->button( QWizard::NextButton ) == 0 )
+ return;
+ if( wizard()->button( QWizard::CancelButton )->hasFocus() )
+ wizard()->button( QWizard::NextButton )->setFocus();
+}
+
+void Page::insertWidget(QWidget *widget, const QString &siblingName,
+ int offset)
+{
+ QWidget *sibling = findChild<QWidget *>(siblingName);
+ QWidget *parent = sibling ? sibling->parentWidget() : 0;
+ QLayout *layout = parent ? parent->layout() : 0;
+ QBoxLayout *blayout = qobject_cast<QBoxLayout *>(layout);
+ //qDebug() << "FOUND: " << sibling << parent << layout << blayout;
+ if (blayout) {
+ int index = blayout->indexOf(sibling) + offset;
+ blayout->insertWidget(index, widget);
+ }
+}
+
+QWidget *Page::findWidget(const QString &objectName) const
+{
+ return findChild<QWidget *>(objectName);
+}
+
+void Page::setVisible(bool visible)
+{
+ QWizardPage::setVisible(visible);
+ qApp->processEvents();
+ //qDebug() << "VISIBLE: " << visible << objectName() << installer();
+ if (m_fresh && !visible) {
+ //qDebug() << "SUPRESSED...";
+ m_fresh = false;
+ return;
+ }
+ if (visible)
+ entering();
+ else
+ leaving();
+}
+
+int Page::nextId() const
+{
+ //qDebug() << "NEXTID";
+ return QWizardPage::nextId();
+}
+
+////////////////////////////////////////////////////////////////////
+//
+// QInstallerIntroductionPage
+//
+////////////////////////////////////////////////////////////////////
+
+IntroductionPage::IntroductionPage(Installer *inst)
+ : Page(inst), m_widget(0)
+{
+ setObjectName( QLatin1String( "IntroductionPage" ) );
+ setTitle(tr("Setup - %1").arg(productName()));
+ setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
+ setSubTitle(QString());
+
+ m_msgLabel = new QLabel(this);
+ m_msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
+ m_msgLabel->setWordWrap(true);
+ m_msgLabel->setText(tr("Welcome to the %1 Setup Wizard.")
+ .arg(productName()));
+
+ QVBoxLayout *layout = new QVBoxLayout( this );
+ setLayout(layout);
+ layout->addWidget( m_msgLabel );
+}
+
+void IntroductionPage::setText(const QString &text)
+{
+ m_msgLabel->setText(text);
+}
+
+void IntroductionPage::setWidget(QWidget *w)
+{
+ if(m_widget) {
+ layout()->removeWidget(m_widget);
+ delete m_widget;
+ }
+ m_widget = w;
+ if(m_widget) {
+ static_cast<QVBoxLayout*>(layout())->addWidget(m_widget, 1);
+ }
+}
+
+////////////////////////////////////////////////////////////////////
+//
+// LicenseAgreementPage
+//
+////////////////////////////////////////////////////////////////////
+
+LicenseAgreementPage::LicenseAgreementPage(Installer *inst)
+ : Page(inst)
+{
+ setTitle(tr("License Agreement"));
+ setPixmap(QWizard::LogoPixmap, logoPixmap());
+ setPixmap(QWizard::WatermarkPixmap, QPixmap());
+ setObjectName(QLatin1String("LicenseAgreementPage"));
+
+ QLabel *msgLabel = new QLabel(tr("Please read the following license agreement(s). You must "
+ "accept the terms contained in these agreement(s) before continuing with the installation."));
+ msgLabel->setWordWrap(true);
+
+ QGroupBox *licenseBox = new QGroupBox(this);
+ licenseBox->setObjectName(QString::fromUtf8("licenseBox"));
+
+ m_licenseListWidget = new QListWidget(licenseBox);
+ connect(m_licenseListWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
+ this, SLOT(currentItemChanged(QListWidgetItem *)));
+
+ QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
+ sizePolicy.setHeightForWidth(m_licenseListWidget->sizePolicy().hasHeightForWidth());
+ m_licenseListWidget->setSizePolicy(sizePolicy);
+
+ m_textBrowser = new QTextBrowser(licenseBox);
+ m_textBrowser->setReadOnly(true);
+ m_textBrowser->setOpenExternalLinks(true);
+ m_textBrowser->setOpenLinks(false);
+ connect(m_textBrowser, SIGNAL(anchorClicked(QUrl)), this, SLOT(openLicenseUrl(QUrl)));
+
+ QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Expanding);
+ sizePolicy2.setHeightForWidth(m_textBrowser->sizePolicy().hasHeightForWidth());
+ m_textBrowser->setSizePolicy(sizePolicy2);
+
+ QHBoxLayout *licenseBoxLayout = new QHBoxLayout(licenseBox);
+ licenseBoxLayout->addWidget(m_licenseListWidget);
+ licenseBoxLayout->addWidget(m_textBrowser);
+
+ m_acceptRadioButton = new QRadioButton(this);
+ QLabel *acceptLabel = new QLabel(tr("I have read and agree to the following terms contained in "
+ "the license agreements accompanying the Qt SDK and additional items. I agree that my use of "
+ "the Qt SDK is governed by the terms and conditions contained in these license agreements."));
+ acceptLabel->setWordWrap(true);
+
+ m_rejectRadioButton = new QRadioButton(this);
+ QLabel *rejectLabel = new QLabel(tr("I do not accept the terms and conditions of the above "
+ "listed license agreements. Please note by checking the box, you must cancel the "
+ "installation or downloading the Qt SDK and must destroy all copies, or portions thereof, "
+ "of the Qt SDK in your possessions."));
+ rejectLabel->setWordWrap(true);
+
+ QSizePolicy sizePolicy3(QSizePolicy::Preferred, QSizePolicy::Minimum);
+ sizePolicy3.setHeightForWidth(rejectLabel->sizePolicy().hasHeightForWidth());
+ sizePolicy3.setVerticalStretch(0);
+ sizePolicy3.setHorizontalStretch(0);
+
+ acceptLabel->setSizePolicy(sizePolicy3);
+ rejectLabel->setSizePolicy(sizePolicy3);
+
+#if defined(Q_WS_X11) || defined(Q_WS_MAC)
+ QFont labelFont(font());
+ labelFont.setPixelSize(9);
+
+ msgLabel->setFont(labelFont);
+ acceptLabel->setFont(labelFont);
+ rejectLabel->setFont(labelFont);
+#endif
+
+ QGridLayout *gridLayout = new QGridLayout;
+ gridLayout->setColumnStretch(1, 1);
+ gridLayout->addWidget(m_acceptRadioButton, 0, 0);
+ gridLayout->addWidget(acceptLabel, 0, 1);
+ gridLayout->addWidget(m_rejectRadioButton, 1, 0);
+ gridLayout->addWidget(rejectLabel, 1, 1);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(msgLabel);
+ layout->addWidget(licenseBox);
+ layout->addLayout(gridLayout);
+
+ connect(m_acceptRadioButton, SIGNAL(toggled(bool)), this,
+ SIGNAL(completeChanged()));
+ connect(m_rejectRadioButton, SIGNAL(toggled(bool)), this,
+ SIGNAL(completeChanged()));
+
+ m_rejectRadioButton->setChecked(true);
+}
+
+void LicenseAgreementPage::initializePage()
+{
+ m_licenseListWidget->clear();
+ m_textBrowser->setText(QLatin1String(""));
+
+ // TODO: this needs to be fixed once we support several root components
+ QInstaller::Component *rootComponent = 0;
+ foreach (QInstaller::Component* root, installer()->components()) {
+ if (root->isInstalled())
+ continue;
+
+ const QHash<QString, QPair<QString, QString> > &hash = root->licenses();
+ if (!hash.isEmpty()) {
+ addLicenseItem(hash);
+ rootComponent = root;
+ }
+ }
+
+ QList<QInstaller::Component*> components = installer()->componentsToInstall(true);
+ foreach (QInstaller::Component* component, components) {
+ if (rootComponent != component && !component->isInstalled())
+ addLicenseItem(component->licenses());
+ }
+
+ if (m_licenseListWidget->count() > 0)
+ m_licenseListWidget->setCurrentItem(m_licenseListWidget->item(0));
+}
+
+bool LicenseAgreementPage::isComplete() const
+{
+ return m_acceptRadioButton->isChecked();
+}
+
+void LicenseAgreementPage::openLicenseUrl(const QUrl &url)
+{
+ QDesktopServices::openUrl(url);
+}
+
+void LicenseAgreementPage::currentItemChanged(QListWidgetItem *current)
+{
+ if (current)
+ m_textBrowser->setText(current->data(Qt::UserRole).toString());
+}
+
+void LicenseAgreementPage::addLicenseItem(const QHash<QString, QPair<QString, QString> > &hash)
+{
+ for (QHash<QString, QPair<QString, QString> >::const_iterator it = hash.begin();
+ it != hash.end(); ++it) {
+ QListWidgetItem *item = new QListWidgetItem(it.key(), m_licenseListWidget);
+ item->setData(Qt::UserRole, it.value().second);
+ }
+}
+
+////////////////////////////////////////////////////////////////////
+//
+// ComponentSelectionPage
+//
+////////////////////////////////////////////////////////////////////
+
+inline QString unitSizeText(const qint64 size) {
+ if (size < 10000)
+ return QString::number(size) + QLatin1Char(' ') + ComponentSelectionPage::tr("Bytes");
+ if (size < 1024 * 10000)
+ return QString::number(size / 1024) + QLatin1Char(' ') + ComponentSelectionPage::tr("kBytes");
+ return QString::number(size / 1024 / 1024) + QLatin1Char(' ') + ComponentSelectionPage::tr("MBytes");
+}
+
+static QString niceSizeText(const QString &str)
+{
+ const qint64 size = str.toLongLong();
+ if( size == 0 )
+ return QString();
+
+ QString msg = ComponentSelectionPage::tr(
+ "This component will occupy approximately %1 on your harddisk.");
+ return msg.arg(unitSizeText(size));
+}
+
+class ComponentSelectionPage::Private : public QObject
+{
+ Q_OBJECT
+
+public:
+ Private(ComponentSelectionPage *qq, Installer *installer)
+ : q( qq ),
+ wasshown( false ),
+ modified( false ),
+ connected( false ),
+ m_model( new ComponentModel( installer ) ),
+ m_installer( installer ),
+ m_treeView( new QTreeView( q ) )
+ {
+ m_treeView->setObjectName( QLatin1String( "TreeView" ) );
+ m_treeView->setMouseTracking(true);
+ m_treeView->setHeaderHidden( true );
+
+ m_treeView->setModel( m_model );
+ for( int i = 1; i < m_treeView->model()->columnCount(); ++i )
+ m_treeView->setColumnHidden( i, true );
+
+ m_descriptionLabel = new QLabel(q);
+ m_descriptionLabel->setWordWrap(true);
+
+ m_sizeLabel = new QLabel(q);
+ m_sizeLabel->setWordWrap(true);
+
+ QVBoxLayout *layout = new QVBoxLayout( q );
+ if( !installer->isInstaller() )
+ {
+ QRadioButton* const uninstallAll = new QRadioButton( tr( "Remove all components" ) );
+ uninstallAll->setObjectName( QLatin1String("uninstallAllComponentsRB") );
+ QRadioButton* const keepChecked = new QRadioButton( installer->isUninstaller() ? tr( "Keep selected components" ) : tr( "Install selected components" ) );
+ keepChecked->setObjectName( QLatin1String("keepSelectedComponentsRB") );
+ layout->addWidget( uninstallAll );
+ layout->addWidget( keepChecked );
+ connect( uninstallAll, SIGNAL( toggled( bool ) ), m_treeView, SLOT( setDisabled( bool ) ) );
+ connect( uninstallAll, SIGNAL( toggled( bool ) ), m_descriptionLabel, SLOT( setDisabled( bool ) ) );
+ connect( uninstallAll, SIGNAL( toggled( bool ) ), m_installer, SLOT( setCompleteUninstallation( bool ) ) );
+ connect( uninstallAll, SIGNAL( toggled( bool ) ), q, SIGNAL( completeChanged() ), Qt::QueuedConnection );
+ connect( uninstallAll, SIGNAL( toggled( bool ) ), this, SLOT( fullUninstallToggled( bool ) ), Qt::QueuedConnection );
+ uninstallAll->setChecked( installer->isUninstaller() );
+ keepChecked->setChecked( installer->isPackageManager() );
+ m_installer->setCompleteUninstallation( installer->isUninstaller() );
+ }
+ //layout->addWidget(msgLabel);
+ QHBoxLayout *hlayout = new QHBoxLayout;
+ hlayout->addWidget(m_treeView, 3);
+ QVBoxLayout *vlayout = new QVBoxLayout;
+ vlayout->addWidget(m_descriptionLabel);
+ vlayout->addWidget(m_sizeLabel);
+ vlayout->addSpacerItem(new QSpacerItem(1, 1,
+ QSizePolicy::MinimumExpanding,
+ QSizePolicy::MinimumExpanding));
+ hlayout->addLayout(vlayout, 2);
+ layout->addLayout(hlayout);
+
+ connect( m_treeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ),
+ this, SLOT( selectionChanged() ) );
+
+ connect( m_treeView->model(), SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
+ q, SIGNAL( completeChanged() ), Qt::QueuedConnection );
+ }
+
+protected Q_SLOTS:
+ void selectionChanged()
+ {
+ const QModelIndex index = m_treeView->currentIndex();
+ if( !index.isValid() )
+ {
+ m_descriptionLabel->clear();
+ m_sizeLabel->clear();
+ return;
+ }
+
+ m_descriptionLabel->setText( index.data( Qt::ToolTipRole ).toString() );
+ if( !m_installer->isUninstaller() )
+ m_sizeLabel->setText( niceSizeText( qVariantValue< Component* >( index.data( Qt::UserRole ) )->value( QString::fromLatin1( "UncompressedSize" ) ) ) );
+ }
+ void fullUninstallToggled( bool value )
+ {
+ if ( value )
+ {
+ emit workRequested( value );
+ q->setModified( value );
+ }
+ else
+ {
+ const QModelIndex index = m_model->index( 0, 0 );
+ const QVariant data = m_model->data( index, Qt::CheckStateRole );
+ m_model->setData( index, data, Qt::CheckStateRole );
+ }
+ }
+
+Q_SIGNALS:
+ void workRequested( bool );
+
+public:
+ ComponentSelectionPage* const q;
+
+ bool wasshown;
+ bool modified;
+ bool connected;
+ ComponentModel* const m_model;
+ Installer* const m_installer;
+ QTreeView* const m_treeView;
+ QLabel *m_descriptionLabel;
+ QLabel *m_sizeLabel;
+};
+
+void ComponentSelectionPage::entering()
+{
+ wizard()->button( QWizard::CancelButton )->setEnabled( true );
+ if( !d->connected )
+ {
+ Gui* par = dynamic_cast< Gui* > ( wizard() );
+ if ( par )
+ {
+ verbose() << "connect Models" << std::endl;
+ connect( d->m_model, SIGNAL( workRequested( bool ) ), par, SLOT( setModified( bool ) ), Qt::QueuedConnection );
+ connect( d->m_model, SIGNAL( workRequested( bool ) ), this, SLOT( setModified( bool ) ), Qt::QueuedConnection );
+ connect( d.get(), SIGNAL( workRequested( bool) ), par, SLOT( setModified( bool ) ), Qt::QueuedConnection );
+ connect( d->m_model, SIGNAL( modelReset() ), this, SLOT( modelWasReseted() ), Qt::QueuedConnection );
+ d->connected = true;
+ }
+ if ( !d->m_installer->isInstaller() )
+ setButtonText( QWizard::CancelButton, tr( "Close" ) );
+ }
+}
+
+/*!
+ \class QInstaller::ComponentSelectionPage
+ On this page the user can select and deselect what he wants to be installed.
+ */
+ComponentSelectionPage::ComponentSelectionPage( Installer* installer )
+ : Page( installer ),
+ d( new Private( this, installer ) )
+{
+ setObjectName( QLatin1String( "ComponentSelectionPage" ) );
+ if( !installer->isUninstaller() )
+ {
+ setTitle( tr( "Select Components" ) );
+ setSubTitle( tr( "Please select the components you want to install." ) );
+ }
+ else
+ {
+ setTitle( tr( "Select Components" ) );
+ setSubTitle( tr( "Please select the components you want to uninstall." ) );
+ }
+ setPixmap( QWizard::LogoPixmap, logoPixmap() );
+ setPixmap( QWizard::WatermarkPixmap, QPixmap() );
+}
+
+ComponentSelectionPage::~ComponentSelectionPage()
+{
+}
+
+void ComponentSelectionPage::modelWasReseted()
+{
+ if( d->m_treeView->model()->rowCount() == 1 )
+ {
+ d->m_treeView->setExpanded( d->m_treeView->model()->index( 0, 0 ), true );
+ d->wasshown = true;
+ }
+}
+
+void ComponentSelectionPage::showEvent( QShowEvent* event )
+{
+ if( !d->wasshown && d->m_treeView->model()->rowCount() == 1 )
+ {
+ d->m_treeView->setExpanded( d->m_treeView->model()->index( 0, 0 ), true );
+ d->wasshown = true;
+ }
+ Page::showEvent( event );
+}
+
+
+/*!
+ Selects the component with /a id in the component tree.
+ */
+void ComponentSelectionPage::selectComponent( const QString& id ) {
+ const QModelIndex idx = d->m_model->findComponent( id );
+ if ( !idx.isValid() )
+ return;
+ d->m_model->setData( idx, Qt::Checked );
+}
+
+/*!
+ Deselects the component with /a id in the component tree.
+ */
+void ComponentSelectionPage::deselectComponent( const QString& id ) {
+ const QModelIndex idx = d->m_model->findComponent( id );
+ if ( !idx.isValid() )
+ return;
+ d->m_model->setData( idx, Qt::Unchecked );
+}
+
+void ComponentSelectionPage::setModified( bool value )
+{
+ d->modified = value;
+ if (d->m_installer->isInstaller() || value)
+ setButtonText( QWizard::CancelButton, tr( "Cancel" ) );
+ else
+ setButtonText( QWizard::CancelButton, tr( "Close" ) );
+}
+
+bool ComponentSelectionPage::isComplete() const
+{
+ // uninstall all
+ if( !d->m_treeView->isEnabled() )
+ return true;
+
+ if( d->m_installer->isPackageManager() )
+ {
+ // at least component should be different from its previous state
+ if ( d->modified )
+ return true;
+ else
+ return false;
+ }
+ // at least one component needs to be selected for (un)installation
+ const QList< Component* > components = d->m_installer->components( true );
+ for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
+ {
+ if( (*it)->isSelected() == d->m_installer->isInstaller() )
+ return true;
+ }
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////
+//
+// TargetDirectoryPage
+//
+////////////////////////////////////////////////////////////////////
+
+TargetDirectoryPage::TargetDirectoryPage(Installer *installer)
+ : Page(installer)
+{
+ setObjectName( QLatin1String( "TargetDirectoryPage" ) );
+ setTitle(tr("Installation Folder"));
+ setPixmap(QWizard::LogoPixmap, logoPixmap());
+ setPixmap(QWizard::WatermarkPixmap, QPixmap());
+
+ QLabel *msgLabel = new QLabel(this);
+ msgLabel->setText(tr("Please specify the folder where %1 "
+ "will be installed.").arg(productName()));
+ msgLabel->setWordWrap(true);
+ msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
+
+ m_lineEdit = new QLineEdit(this);
+ m_lineEdit->setObjectName( QLatin1String("targetDirectoryLE") );
+
+ QPushButton *browseButton = new QPushButton(this);
+ browseButton->setObjectName( QLatin1String( "BrowseButton" ) );
+ browseButton->setText( tr( "Browse..." ) );
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(msgLabel);
+ QHBoxLayout *hlayout = new QHBoxLayout;
+ hlayout->addWidget(m_lineEdit);
+ hlayout->addWidget(browseButton);
+ layout->addLayout(hlayout);
+ setLayout(layout);
+
+ connect(browseButton, SIGNAL(clicked()), this, SLOT(dirRequested()));
+ connect(m_lineEdit, SIGNAL(textChanged(QString)), this,
+ SIGNAL(completeChanged()));
+}
+
+QString TargetDirectoryPage::targetDir() const
+{
+ return m_lineEdit->text();
+}
+
+void TargetDirectoryPage::setTargetDir(const QString &dirName)
+{
+ m_lineEdit->setText(dirName);
+}
+
+void TargetDirectoryPage::initializePage()
+{
+ QString targetDir = installer()->value( QLatin1String( "TargetDir" ) );
+ if( targetDir.isEmpty() )
+ {
+ targetDir = QDir::homePath() + QDir::separator();
+ if( targetDir.contains( QLatin1Char( ' ' ) ) ) // prevent spaces in the default target directory
+ targetDir = QDir::rootPath();
+ targetDir += productName().remove( QLatin1Char( ' ' ) );
+ }
+ m_lineEdit->setText( QDir::toNativeSeparators( QDir( targetDir ).absolutePath() ) );
+
+ Page::initializePage();
+}
+
+bool TargetDirectoryPage::validatePage()
+{
+ const QDir dir( targetDir() );
+
+ if( dir.exists() && dir.entryList( QDir::NoDotAndDotDot ).isEmpty() ) // it exists, but is empty (might be created by the Browse button (getExistingDirectory)
+ {
+ return true;
+ }
+ else if( dir.exists() && dir.isReadable() ) // it exists, but is not empty
+ {
+ if ( dir == QDir::root() )
+ {
+ MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("forbiddenTargetDirectory"), tr( "Error" ),
+ tr( "As the install directory is completely deleted installing in %1 is forbidden" ).arg( QDir::rootPath() ),
+ QMessageBox::Ok);
+ return false;
+ }
+
+ return MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("overwriteTargetDirectory"), tr( "Warning" ),
+ tr( "You have selected an existing, non-empty folder for installation.\n"
+ "Note that it will be completely wiped on uninstallation of this application.\n"
+ "It is not advisable to install into this folder as installation might fail.\n"
+ "Do you want to continue?" ),
+ QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes;
+ }
+ else
+ {
+ return true;
+ }
+}
+
+void TargetDirectoryPage::entering()
+{
+}
+
+void TargetDirectoryPage::leaving()
+{
+ installer()->setValue( QLatin1String( "TargetDir" ), targetDir());
+}
+
+void TargetDirectoryPage::targetDirSelected()
+{
+}
+
+void TargetDirectoryPage::dirRequested()
+{
+ //qDebug() << "DIR REQUESTED";
+ QString newDirName = QFileDialog::getExistingDirectory(this,
+ tr("Select Installation Folder"), targetDir()
+ /*, Options options = ShowDirsOnly*/);
+ if (newDirName.isEmpty() || newDirName == targetDir())
+ return;
+ m_lineEdit->setText( QDir::toNativeSeparators( newDirName ) );
+}
+
+
+// #pragma mark -- StartMenuDirectoryPage
+
+
+StartMenuDirectoryPage::StartMenuDirectoryPage(Installer *installer)
+ : Page(installer)
+{
+ setObjectName( QLatin1String( "StartMenuDirectoryPage" ) );
+ setTitle(tr("Start Menu shortcuts"));
+
+ setPixmap(QWizard::LogoPixmap, logoPixmap());
+ setPixmap(QWizard::WatermarkPixmap, QPixmap());
+
+ QString msg = tr("Select the Start Menu in which you would like to "
+ "create the program's shortcuts. You can also enter a name to "
+ "create a new folder.");
+
+ QLabel *msgLabel = new QLabel(this);
+ msgLabel->setText(msg);
+ msgLabel->setWordWrap(true);
+ msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
+
+ m_lineEdit = new QLineEdit(this);
+ m_lineEdit->setObjectName( QLatin1String( "LineEdit" ) );
+
+ QString startMenuDir = installer->value( QLatin1String( "StartMenuDir" ) );
+ if (startMenuDir.isEmpty())
+ startMenuDir = productName();
+ m_lineEdit->setText(startMenuDir);
+
+ // grab existing start menu folders
+ QSettings user(QLatin1String("HKEY_CURRENT_USER\\Software\\Microsoft\\"
+ "Windows\\CurrentVersion\\Explorer\\User Shell Folders"),
+ QSettings::NativeFormat);
+ //User Shell Folders uses %USERPROFILE%
+ startMenuPath = replaceWindowsEnvironmentVariables( user.value(QLatin1String("Programs"), QString()).toString() );
+ installer->setValue( QLatin1String( "DesktopDir" ), replaceWindowsEnvironmentVariables( user.value( QLatin1String( "Desktop" ) ).toString() ) );
+
+ QDir dir(startMenuPath); // user only dirs
+ QStringList dirs = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
+
+ if (installer->value(QLatin1String("AllUsers")) == QLatin1String( "true" ) ) {
+ verbose() << "AllUsers set. Using HKEY_LOCAL_MACHINE" << std::endl;
+ QSettings system(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\"
+ "Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"),
+ QSettings::NativeFormat);
+ startMenuPath = system.value(QLatin1String("Common Programs"),
+ QString()).toString();
+ installer->setValue( QLatin1String( "DesktopDir" ), system.value( QLatin1String( "Desktop" ) ).toString() );
+
+ dir.setPath(startMenuPath); // system only dirs
+ dirs += dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
+ }
+ verbose() << "StartMenuPath: " << startMenuPath;
+ verbose() << "DesktopDir:" << installer->value( QLatin1String("DesktopDir") ) << std::endl;
+
+ m_listWidget = new QListWidget(this);
+ if (!dirs.isEmpty()) {
+ dirs.removeDuplicates();
+ foreach (const QString &dir, dirs)
+ new QListWidgetItem(dir, m_listWidget);
+ }
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(msgLabel);
+ layout->addWidget(m_lineEdit);
+ layout->addWidget(m_listWidget);
+
+ setLayout(layout);
+
+ connect(m_listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
+ QListWidgetItem*)), this, SLOT(currentItemChanged(QListWidgetItem*)));
+}
+
+QString
+StartMenuDirectoryPage::startMenuDir() const
+{
+ return m_lineEdit->text();
+}
+
+void
+StartMenuDirectoryPage::setStartMenuDir(const QString &startMenuDir)
+{
+ m_lineEdit->setText(startMenuDir);
+}
+
+void
+StartMenuDirectoryPage::leaving()
+{
+ installer()->setValue( QLatin1String( "StartMenuDir" ), startMenuPath + QDir::separator() + startMenuDir());
+}
+
+void
+StartMenuDirectoryPage::currentItemChanged(QListWidgetItem* current)
+{
+ if (current) {
+ QString dir = current->data(Qt::DisplayRole).toString();
+ if (!dir.isEmpty())
+ dir += QDir::separator();
+ setStartMenuDir(dir + installer()->value( QLatin1String( "StartMenuDir" ) ) );
+ }
+}
+
+
+////////////////////////////////////////////////////////////////////
+//
+// ReadyForInstallationPage
+//
+////////////////////////////////////////////////////////////////////
+
+ReadyForInstallationPage::ReadyForInstallationPage( Installer* installer )
+ : Page(installer),
+ msgLabel( new QLabel )
+{
+ setPixmap(QWizard::LogoPixmap, logoPixmap());
+ setPixmap(QWizard::WatermarkPixmap, QPixmap());
+
+ setObjectName( QLatin1String( "ReadyForInstallationPage" ) );
+
+ msgLabel->setWordWrap( true );
+ msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
+
+ QLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(msgLabel);
+ setLayout(layout);
+}
+
+/*!
+ \reimp
+ */
+void ReadyForInstallationPage::initializePage()
+{
+ setCommitPage( true );
+
+ if( installer()->isUninstaller() )
+ {
+ setTitle(tr("Ready to Uninstall"));
+ setButtonText(QWizard::CommitButton, tr("Uninstall"));
+ msgLabel->setText( tr( "Setup is now ready to begin removing %1 "
+ "from your computer.\n"
+ "The program dir %2 will be deleted completely, including "
+ "all content in that directory!").arg( productName(),
+ QDir::toNativeSeparators( QDir( installer()->value( QLatin1String( "TargetDir" ) ) ).absolutePath() ) ) );
+ }
+ else if( installer()->isPackageManager() )
+ {
+ setTitle( tr( "Ready to Update Packages" ) );
+ setButtonText( QWizard::CommitButton, tr( "Update" ) );
+ msgLabel->setText( tr( "Setup is now ready to begin installing the additional components you selected." ) );
+ }
+ else
+ {
+ Q_ASSERT(installer()->isInstaller());
+ setTitle(tr("Ready to Install"));
+ setButtonText(QWizard::CommitButton, tr("Install"));
+ msgLabel->setText(tr("Setup is now ready to begin installing %1 "
+ "on your computer.").arg(productName()));
+ }
+ }
+
+
+/*!
+ \reimp
+ */
+void ReadyForInstallationPage::entering()
+{
+ initializePage();
+
+ if( installer()->isUninstaller() )
+ return;
+
+ const QString target = installer()->value( QLatin1String( "TargetDir" ) );
+
+ const KDSysInfo::Volume vol = KDSysInfo::Volume::fromPath( target );
+ const KDSysInfo::Volume tempVolume = KDSysInfo::Volume::fromPath( QInstaller::generateTemporaryFileName() );
+ const bool tempOnSameVolume = vol == tempVolume;
+
+ if ( vol.size().size() == 0 && vol.availableSpace().size() == 0 ) { //there is no better way atm to check this
+ verbose() << "Could not determine available space on device " << target << ". Continue silently." << std::endl;
+ return;
+ }
+
+ const KDByteSize required( installer()->requiredDiskSpace() );
+ const KDByteSize tempRequired( installer()->requiredTemporaryDiskSpace() );
+
+ const KDByteSize available = vol.availableSpace();
+ const KDByteSize tempAvailable = tempVolume.availableSpace();
+ const KDByteSize realRequiredTempSpace = KDByteSize( 0.1 * tempRequired + tempRequired );
+ const KDByteSize realRequiredSpace = KDByteSize( 0.5 * required + required );
+
+ const bool tempInstFailure = tempOnSameVolume && available < realRequiredSpace + realRequiredTempSpace;
+
+ verbose() << "Disk space check on " << target << ": required=" << required.size() << " available=" << available.size() << " size=" << vol.size().size() << std::endl;
+
+ QString tempString;
+ if ( tempAvailable < realRequiredTempSpace || tempInstFailure )
+ {
+ if ( tempOnSameVolume )
+ {
+ tempString = tr( "Not enough diskspace to store temporary files and the installation, at least %1 are required" ).arg( unitSizeText(realRequiredTempSpace + realRequiredSpace) );
+ }
+ else
+ {
+ tempString = tr( "Not enough diskspace to store temporary files, at least %1 are required" ).arg( unitSizeText(realRequiredTempSpace.size()) );
+ }
+ }
+
+ // error on not enough space
+ if( available < required || tempInstFailure )
+ {
+ if ( tempOnSameVolume )
+ msgLabel->setText( tempString );
+ else
+ msgLabel->setText( tr( "The volume you selected for installation has insufficient space for the selected components.\n\n"
+ "The installation requires approximately %1." ).arg( required.toString() ) + tempString );
+ setCommitPage( false );
+ }
+ // warn for less than 1% of the volume's space being free
+ else if( available - required < 0.01 * vol.size() )
+ {
+ msgLabel->setText( tr( "The volume you selected for installation seems to have sufficient space for installation,\n"
+ "but there will not more than 1% of the volume's space available afterwards.\n\n%1" ).arg( msgLabel->text() ) );
+ }
+ // warn for less than 100MB being free
+ else if( available - required < 100*1024*1024LL )
+ {
+ msgLabel->setText( tr( "The volume you selected for installation seems to have sufficient space for installation,\n"
+ "but there will not more than 100 MB available afterwards.\n\n%1" ).arg( msgLabel->text() ) );
+ }
+}
+
+/*!
+ \reimp
+ */
+bool ReadyForInstallationPage::isComplete() const
+{
+ return isCommitPage();
+}
+
+/*!
+ \class QInstaller::PerformInstallationPage
+ On this page the user can see on a progressbar how far the current installation is.
+ */
+PerformInstallationPage::PerformInstallationPage(Installer *gui)
+ : Page(gui),
+ m_performInstallationForm(new PerformInstallationForm(this))
+{
+ setPixmap(QWizard::LogoPixmap, logoPixmap());
+ setPixmap(QWizard::WatermarkPixmap, QPixmap());
+
+ setObjectName( QLatin1String( "PerformInstallationPage" ) );
+ setCommitPage(true);
+
+ m_performInstallationForm->setupUi(this);
+
+ m_performInstallationForm->setDetailsWidgetVisible( installer()->isInstaller() || installer()->isPackageManager() );
+ connect(ProgressCoordninator::instance(), SIGNAL( detailTextChanged( QString ) ),
+ m_performInstallationForm, SLOT( appendProgressDetails( QString ) ) );
+ connect(ProgressCoordninator::instance(), SIGNAL(detailTextResetNeeded()),
+ m_performInstallationForm, SLOT(clearDetailsBrowser()));
+
+ connect(m_performInstallationForm, SIGNAL(showDetailsChanged()),
+ this, SLOT(toggleDetailsWereChanged()));
+
+ connect(installer(), SIGNAL(installationStarted()),
+ this, SLOT(installationStarted()));
+ connect(installer(), SIGNAL(uninstallationStarted()),
+ this, SLOT(installationStarted()));
+ connect(installer(), SIGNAL(installationFinished()),
+ this, SLOT(installationFinished()));
+ connect(installer(), SIGNAL(uninstallationFinished()),
+ this, SLOT(installationFinished()));
+ connect( installer(), SIGNAL( titleMessageChanged( QString ) ),
+ this, SLOT( setTitleMessage( QString ) ) );
+ connect( this, SIGNAL( setAutomatedPageSwitchEnabled( bool ) ),
+ installer(), SIGNAL( setAutomatedPageSwitchEnabled( bool ) ) );
+}
+
+PerformInstallationPage::~PerformInstallationPage()
+{
+ delete m_performInstallationForm;
+}
+
+void PerformInstallationPage::entering()
+{
+ setComplete(false);
+
+ if( installer()->isUninstaller() )
+ {
+ setTitle(tr("Uninstalling %1").arg(installer()->value( QLatin1String( "ProductName" ) )));
+ setButtonText(QWizard::CommitButton, tr("Uninstall"));
+ }
+ else if( installer()->isPackageManager() )
+ {
+ setTitle( tr( "Updating component configuration of %1" ).arg( installer()->value( QLatin1String( "ProductName" ) ) ) );
+ setButtonText( QWizard::CommitButton, tr( "Update" ) );
+ }
+ else
+ {
+ Q_ASSERT(installer()->isInstaller());
+ setTitle(tr("Installing %1").arg(installer()->value( QLatin1String( "ProductName" ) )));
+ setButtonText(QWizard::CommitButton, tr("Install"));
+ }
+ m_performInstallationForm->enableDetails();
+ emit setAutomatedPageSwitchEnabled( true );
+}
+
+void PerformInstallationPage::initializePage()
+{
+ QWizardPage::initializePage();
+ if( installer()->isUninstaller() )
+ {
+ wizard()->removePage( QInstaller::Installer::InstallationFinished + 1 );
+ wizard()->removePage( QInstaller::Installer::InstallationFinished + 2 );
+ setTitle( tr( "Uninstalling %1" ).arg( installer()->value( QLatin1String( "ProductName" ) ) ) );
+ m_commitBtnText = tr( "Uninstall" );
+ setButtonText( QWizard::CommitButton, m_commitBtnText );
+ QTimer::singleShot( 30, installer(), SLOT( runUninstaller() ) );
+ }
+ else if( installer()->isPackageManager() )
+ {
+ setTitle(tr("Updating components of %1").arg( installer()->value( QLatin1String( "ProductName" ) )));
+ m_commitBtnText = tr ( "Update" );
+ setButtonText( QWizard::CommitButton, m_commitBtnText );
+ QTimer::singleShot( 30, installer(), SLOT( runPackageUpdater() ) );
+ }
+ else
+ {
+ Q_ASSERT( installer()->isInstaller() );
+ setTitle( tr( "Installing %1" ).arg( installer()->value( QLatin1String( "ProductName" ) ) ) );
+ m_commitBtnText = tr( "Install" );
+ setButtonText( QWizard::CommitButton, m_commitBtnText );
+ QTimer::singleShot( 30, installer(), SLOT( runInstaller() ) );
+ }
+}
+
+void PerformInstallationPage::installationStarted()
+{
+ m_performInstallationForm->startUpdateProgress();
+}
+
+void PerformInstallationPage::installationFinished()
+{
+ m_performInstallationForm->stopUpdateProgress();
+ if (!isAutoSwitching()){
+ m_performInstallationForm->scrollDetailsToTheEnd();
+ m_performInstallationForm->setDetailsButtonEnabled( false );
+ setButtonText( QWizard::NextButton, tr( "Next" ) );
+ setButtonText( QWizard::CommitButton, tr( "Next" ) );
+ setComplete( true );
+ }
+}
+
+bool PerformInstallationPage::isAutoSwitching() const
+{
+ return !m_performInstallationForm->isShowingDetails();
+}
+
+void PerformInstallationPage::toggleDetailsWereChanged()
+{
+ const bool needAutoSwitching = isAutoSwitching();
+ setButtonText( QWizard::CommitButton, needAutoSwitching ? m_commitBtnText : tr( "Next" ) );
+ emit setAutomatedPageSwitchEnabled( needAutoSwitching );
+}
+
+void PerformInstallationPage::setTitleMessage( const QString& title )
+{
+ setTitle( title );
+}
+
+////////////////////////////////////////////////////////////////////
+//
+// FinishedPage
+//
+////////////////////////////////////////////////////////////////////
+
+FinishedPage::FinishedPage(Installer *installer)
+ : Page(installer)
+{
+ //setCommitPage( true );
+ setObjectName( QLatin1String( "FinishedPage" ) );
+ setTitle(tr("Completing the %1 Setup Wizard").arg(productName()));
+ setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
+ setSubTitle(QString());
+
+ m_msgLabel = new QLabel(this);
+ m_msgLabel->setObjectName( QLatin1String( "MessageLabel" ) );
+ m_msgLabel->setWordWrap(true);
+#ifdef Q_WS_MAC
+ m_msgLabel->setText(tr("Click Done to exit the Setup Wizard"));
+#else
+ m_msgLabel->setText(tr("Click Finish to exit the Setup Wizard"));
+#endif
+
+ m_runItCheckBox = new QCheckBox(this);
+ m_runItCheckBox->setObjectName( QLatin1String( "RunItCheckBox" ) );
+ m_runItCheckBox->setChecked(true);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(m_msgLabel);
+ layout->addWidget(m_runItCheckBox);
+ setLayout(layout);
+}
+
+void FinishedPage::entering()
+{
+ if ( wizard()->button( QWizard::BackButton ) )
+ wizard()->button( QWizard::BackButton )->setVisible( false );
+ if ( installer()->isPackageManager() )
+ {
+ setButtonText( QWizard::CommitButton, QLatin1String( "Finish" ) );
+ wizard()->button( QWizard::CommitButton )->disconnect( this );
+ connect( wizard()->button( QWizard::CommitButton ), SIGNAL( clicked() ),
+ this, SLOT( handleFinishClicked() ) );
+ Gui* par = dynamic_cast< Gui* > ( wizard() );
+ if ( par )
+ {
+ connect( this, SIGNAL( finishClicked() ), par, SIGNAL( finishButtonClicked() ) );
+ }
+ }
+ verbose() << "FINISHED ENTERING: " << std::endl;
+ connect( wizard()->button( QWizard::FinishButton ), SIGNAL( clicked() ),
+ this, SLOT( handleFinishClicked() ) );
+ wizard()->setOption(QWizard::NoCancelButton, true);
+
+ if (installer()->status() == Installer::InstallerSucceeded) {
+
+ const QString finishedtext = installer()->value( QLatin1String( "FinishedText" ) );
+ if( ! finishedtext.isEmpty() )
+ m_msgLabel->setText( finishedtext );
+
+ if ( ! installer()->value( QLatin1String( "RunProgram" ) ).isEmpty() ) {
+ m_runItCheckBox->show();
+ m_runItCheckBox->setText( installer()->value( QLatin1String( "RunProgramDescription" ), tr( "Run %1 now." ).arg( productName() ) ) );
+ return; // job done
+ }
+
+ } else {
+ setTitle(tr("The %1 Setup Wizard failed").arg(productName()));
+ }
+ m_runItCheckBox->hide();
+ m_runItCheckBox->setChecked( false );
+}
+
+void FinishedPage::initializePage()
+{
+ setCommitPage( true );
+ if ( wizard()->button( QWizard::BackButton ) )
+ wizard()->button( QWizard::BackButton )->setVisible( false );
+ if ( installer()->isPackageManager() )
+ {
+ setButtonText( QWizard::CommitButton, QLatin1String( "Finish" ) );
+ setButtonText( QWizard::NextButton, QLatin1String( "Finish" ) );
+ }
+}
+
+void FinishedPage::leaving()
+{
+ disconnect( wizard(), SIGNAL( customButtonClicked( int ) ),
+ this, SLOT( handleFinishClicked() ) );
+ if ( installer()->isPackageManager() )
+ {
+ disconnect( wizard()->button( QWizard::CommitButton ), SIGNAL( clicked() ),
+ this, SLOT( handleFinishClicked() ) );
+ Gui* par = dynamic_cast< Gui* > ( wizard() );
+ if ( par )
+ {
+ disconnect( this, SIGNAL( finishClicked() ), par, SIGNAL( finishButtonClicked() ) );
+ }
+ }
+}
+
+void FinishedPage::handleFinishClicked()
+{
+ QString program = installer()->value( QLatin1String( "RunProgram" ) );
+ if ( !m_runItCheckBox->isChecked() || program.isEmpty() )
+ return;
+ program = installer()->replaceVariables( program );
+ verbose() << "STARTING " << program << std::endl;
+ QProcess::startDetached( program );
+}
+
+////////////////////////////////////////////////////////////////////
+//
+// RestartPage
+//
+////////////////////////////////////////////////////////////////////
+
+RestartPage::RestartPage(Installer *installer)
+ : Page(installer)
+{
+ setObjectName( QLatin1String( "RestartPage" ) );
+ setTitle(tr("Completing the %1 Setup Wizard").arg( productName() ) );
+ setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
+ setSubTitle( QString() );
+ setFinalPage( false );
+}
+
+void RestartPage::entering()
+{
+ emit restart();
+ wizard()->restart();
+ if ( wizard()->button( QWizard::FinishButton ) )
+ wizard()->button( QWizard::FinishButton )->setVisible( false );
+ wizard()->setOption(QWizard::NoCancelButton, false);
+}
+
+void RestartPage::leaving()
+{
+}
+
+#include "qinstallergui.moc"
diff --git a/installerbuilder/libinstaller/qinstallergui.h b/installerbuilder/libinstaller/qinstallergui.h
new file mode 100644
index 000000000..fb35d1850
--- /dev/null
+++ b/installerbuilder/libinstaller/qinstallergui.h
@@ -0,0 +1,374 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QINSTALLER_GUI_H
+#define QINSTALLER_GUI_H
+
+#include <QtGui/QWizard>
+#include <QtCore/QMetaType>
+
+#include <KDToolsCore/pimpl_ptr>
+
+#include "qinstaller.h"
+#include "messageboxhandler.h"
+
+// FIXME: move to private classes
+class QCheckBox;
+class QLabel;
+class QLineEdit;
+class QListWidget;
+class QListWidgetItem;
+class QProgressBar;
+class QRadioButton;
+class QTextBrowser;
+class QTreeView;
+class QScriptEngine;
+
+namespace QInstaller {
+
+class Installer;
+class Page;
+class IntroductionPage;
+class PerformInstallationForm;
+
+class INSTALLER_EXPORT MessageBoxHandlerImpl : public MessageBoxHandler {
+public:
+ explicit MessageBoxHandlerImpl( QWidget* parentWidget );
+ void setAutomaticAnswer( const QString& identifier, QMessageBox::StandardButton answer );
+ void setDefaultAction( DefaultAction da );
+
+ QMessageBox::StandardButton critical( const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
+ QMessageBox::StandardButton information( const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
+ QMessageBox::StandardButton question( const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Yes|QMessageBox::No, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
+ QMessageBox::StandardButton warning( const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
+ QMessageBox::StandardButton critical( QWidget* parent, const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
+ QMessageBox::StandardButton information( QWidget* parent, const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
+ QMessageBox::StandardButton question( QWidget* parent, const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Yes|QMessageBox::No, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
+ QMessageBox::StandardButton warning( QWidget* parent, const QString& identifier, const QString& title, const QString& text, QMessageBox::StandardButtons buttons=QMessageBox::Ok, QMessageBox::StandardButton button=QMessageBox::NoButton ) const;
+
+private:
+ QMessageBox::StandardButton autoReply( QMessageBox::StandardButtons buttons ) const;
+
+private:
+ QList<QMessageBox::Button> m_buttonOrder;
+ QWidget* m_parentWidget;
+ DefaultAction m_defaultAction;
+ QHash<QString,QMessageBox::StandardButton> m_automaticAnswers;
+};
+
+class INSTALLER_EXPORT Gui : public QWizard
+{
+ Q_OBJECT
+
+public:
+ explicit Gui(Installer *installer, QWidget *parent = 0);
+ ~Gui();
+ virtual void init() = 0;
+ IntroductionPage* introductionPage() const;
+
+ void loadControlScript( const QString& scriptPath );
+ void callControlScriptMethod( const QString& methodName );
+ void triggerControlScriptForCurrentPage();
+
+ QScriptEngine* controlScriptEngine() const;
+
+ Q_INVOKABLE QWidget* pageWidgetByObjectName( const QString& name ) const;
+ Q_INVOKABLE QWidget* currentPageWidget() const;
+ Q_INVOKABLE void clickButton( int wizardButton, int delayInMs=0 );
+
+Q_SIGNALS:
+ void interrupted();
+ void languageChanged();
+ void finishButtonClicked();
+ void gotRestarted();
+
+public slots:
+ void cancelButtonClicked();
+ void reject();
+ void rejectWithoutPrompt();
+ void showFinishedPage();
+ void setModified( bool value );
+
+protected Q_SLOTS:
+ void wizardPageInsertionRequested( QWidget* widget, Installer::WizardPage page );
+ void wizardPageRemovalRequested( QWidget* widget );
+ void wizardWidgetInsertionRequested( QWidget* widget, Installer::WizardPage page );
+ void wizardWidgetRemovalRequested( QWidget* widget );
+ void wizardPageVisibilityChangeRequested( bool visible, int page );
+ void slotCurrentPageChanged( int id );
+ void delayedControlScriptExecution( int id );
+
+ void setAutomatedPageSwitchEnabled( bool request );
+
+protected:
+ bool event( QEvent* event );
+ Installer *m_installer;
+
+
+private:
+ class Private;
+ Private* const d;
+ QInstaller::IntroductionPage *m_introPage;
+ QMap< int, QWizardPage* > defaultPages;
+};
+
+
+class INSTALLER_EXPORT Page : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ explicit Page(Installer *installer);
+
+ virtual bool isInterruptible() const { return false; }
+ virtual QPixmap watermarkPixmap() const;
+ virtual QPixmap logoPixmap() const;
+ virtual QString productName() const;
+
+ virtual bool isComplete() const;
+ void setComplete(bool complete);
+
+protected:
+ Installer *installer() const;
+
+ // Inserts widget into the same layout like a sibling identified
+ // by its name. Default position is just behind the sibling.
+ virtual void insertWidget(QWidget *widget, const QString &siblingName,
+ int offset = 1);
+ virtual QWidget *findWidget(const QString &objectName) const;
+
+ virtual void setVisible(bool visible); // reimp
+ virtual int nextId() const; // reimp
+
+ virtual void entering() {} // called on entering
+ virtual void leaving() {} // called on leaving
+
+ virtual void forward() const {} // called when going forwards
+ //virtual void backward() const {} // called when going back
+ bool isConstructing() const { return m_fresh; }
+
+private:
+ Installer *m_installer;
+ bool m_fresh;
+ bool m_complete;
+};
+
+
+class INSTALLER_EXPORT IntroductionPage : public Page
+{
+ Q_OBJECT
+public:
+ explicit IntroductionPage(Installer *installer);
+ void setText(const QString &text);
+ void setWidget(QWidget *w);
+private:
+ QLabel *m_msgLabel;
+ QWidget *m_widget;
+};
+
+
+class INSTALLER_EXPORT LicenseAgreementPage : public Page
+{
+ Q_OBJECT
+
+public:
+ explicit LicenseAgreementPage(Installer *installer);
+ void initializePage();
+ bool isComplete() const;
+
+private Q_SLOTS:
+ void openLicenseUrl(const QUrl &url);
+ void currentItemChanged(QListWidgetItem *current);
+
+private:
+ void addLicenseItem(const QHash<QString, QPair<QString, QString> > &hash);
+
+private:
+ QTextBrowser *m_textBrowser;
+ QListWidget *m_licenseListWidget;
+
+ QRadioButton *m_acceptRadioButton;
+ QRadioButton *m_rejectRadioButton;
+};
+
+
+class INSTALLER_EXPORT ComponentSelectionPage : public Page
+{
+ Q_OBJECT
+
+public:
+ explicit ComponentSelectionPage(Installer *installer);
+ ~ComponentSelectionPage();
+ bool isComplete() const;
+
+ Q_INVOKABLE void selectComponent( const QString& id );
+ Q_INVOKABLE void deselectComponent( const QString& id );
+
+protected:
+ void showEvent( QShowEvent* event );
+ void entering();
+private Q_SLOTS:
+ void setModified( bool value );
+ void modelWasReseted();
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+class INSTALLER_EXPORT TargetDirectoryPage : public Page
+{
+ Q_OBJECT
+
+public:
+ explicit TargetDirectoryPage(Installer *installer);
+ QString targetDir() const;
+ void setTargetDir(const QString &dirName);
+
+ void initializePage();
+ bool validatePage();
+
+protected:
+ void entering();
+ void leaving();
+
+private Q_SLOTS:
+ void targetDirSelected();
+ void dirRequested();
+
+private:
+ QLineEdit *m_lineEdit;
+};
+
+
+class INSTALLER_EXPORT StartMenuDirectoryPage : public Page
+{
+ Q_OBJECT
+
+public:
+ explicit StartMenuDirectoryPage(Installer *installer);
+
+ QString startMenuDir() const;
+ void setStartMenuDir(const QString &startMenuDir);
+
+protected:
+ void leaving();
+
+private Q_SLOTS:
+ void currentItemChanged(QListWidgetItem* current);
+
+private:
+ QString startMenuPath;
+ QLineEdit *m_lineEdit;
+ QListWidget *m_listWidget;
+};
+
+
+class INSTALLER_EXPORT ReadyForInstallationPage : public Page
+{
+ Q_OBJECT
+
+public:
+ explicit ReadyForInstallationPage(Installer *installer);
+ void initializePage();
+ void entering();
+ bool isComplete() const;
+
+private:
+ QLabel* const msgLabel;
+};
+
+
+class INSTALLER_EXPORT PerformInstallationPage : public Page
+{
+ Q_OBJECT
+
+public:
+ explicit PerformInstallationPage(Installer *installer);
+ ~PerformInstallationPage();
+ bool isAutoSwitching() const;
+
+protected:
+ void entering();
+ void initializePage();
+ bool isInterruptible() const { return true; }
+
+public Q_SLOTS:
+ void setTitleMessage( const QString& title );
+
+Q_SIGNALS:
+ void installationRequested();
+ void setAutomatedPageSwitchEnabled( bool request );
+
+private Q_SLOTS:
+ void installationStarted();
+ void installationFinished();
+ void toggleDetailsWereChanged();
+
+private:
+ QString m_commitBtnText;
+ PerformInstallationForm *m_performInstallationForm;
+};
+
+class INSTALLER_EXPORT FinishedPage : public Page
+{
+ Q_OBJECT
+
+public:
+ explicit FinishedPage(Installer *installer);
+
+Q_SIGNALS:
+ void finishClicked();
+
+public Q_SLOTS:
+ void handleFinishClicked();
+
+protected:
+ void initializePage();
+ void entering();
+ void leaving();
+
+private:
+ QLabel *m_msgLabel;
+ QCheckBox *m_runItCheckBox;
+};
+
+class INSTALLER_EXPORT RestartPage : public Page
+{
+ Q_OBJECT
+
+public:
+ explicit RestartPage(Installer *installer);
+
+protected:
+ void entering();
+ void leaving();
+Q_SIGNALS:
+ void restart();
+};
+
+} //namespace QInstaller
+
+#endif // QINSTALLER_GUI_H
diff --git a/installerbuilder/libinstaller/qtpatch.cpp b/installerbuilder/libinstaller/qtpatch.cpp
new file mode 100644
index 000000000..4f5ad160e
--- /dev/null
+++ b/installerbuilder/libinstaller/qtpatch.cpp
@@ -0,0 +1,237 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "qtpatch.h"
+
+#include "common/utils.h"
+
+#include <QString>
+#include <QStringList>
+#include <QFileInfo>
+#include <QProcess>
+#include <QTextStream>
+#include <QVector>
+#include <QTime>
+#include <QDebug>
+#include <QCoreApplication>
+#include <QByteArrayMatcher>
+
+
+#ifdef Q_OS_WIN
+#include <windows.h> // for Sleep
+#endif
+#ifdef Q_OS_UNIX
+#include <errno.h>
+#include <signal.h>
+#include <time.h>
+#endif
+
+//"anonymous" namespace to make clear that this is only for inside use
+namespace {
+ void sleepCopiedFromQTest(int ms)
+ {
+ if (ms < 0) {
+ return;
+ }
+ #ifdef Q_OS_WIN
+ Sleep(uint(ms));
+ #else
+ struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
+ nanosleep(&ts, NULL);
+ #endif
+ }
+
+ void uiDetachedWait(int ms)
+ {
+ QTime timer;
+ timer.start();
+ do {
+ QCoreApplication::processEvents(QEventLoop::AllEvents, ms);
+ sleepCopiedFromQTest(10);
+ } while (timer.elapsed() < ms);
+ }
+
+
+}//"anonymous" namespace
+
+
+QHash<QString, QByteArray> QtPatch::qmakeValues(const QString & qmakePath, QByteArray * qmakeOutput)
+{
+
+ QHash<QString, QByteArray> qmakeValueHash;
+
+ // in some cases qmake is not runable, because another process is blocking it(filewatcher ...)
+ int waitCount = 0;
+ while (qmakeValueHash.isEmpty() && waitCount < 60) {
+ QFileInfo qmake(qmakePath);
+
+ if (!qmake.exists() || !qmake.isExecutable()) {
+ QInstaller::verbose() << qPrintable( QString(QLatin1String("%1 is not existing or not executable")).arg(qmakePath) ) << std::endl;
+ return qmakeValueHash;
+ }
+
+ QStringList args;
+ args << QLatin1String("-query");
+
+ QProcess process;
+ process.start(qmake.absoluteFilePath(), args, QIODevice::ReadOnly);
+ if (process.waitForFinished(2000)) {
+ if (process.exitStatus() == QProcess::CrashExit) {
+ QInstaller::verbose() << qPrintable( QString(QLatin1String("%1 was crashed")).arg(qmakePath) ) << std::endl;
+ return qmakeValueHash;
+ }
+ QByteArray output = process.readAllStandardOutput();
+ qmakeOutput->append(output);
+ QTextStream stream(&output);
+ while (!stream.atEnd()) {
+ const QString line = stream.readLine();
+ const int index = line.indexOf(QLatin1Char(':'));
+ if (index != -1) {
+ QString value = line.mid(index+1);
+ if (value != QLatin1String("**Unknown**") )
+ qmakeValueHash.insert(line.left(index), value.toUtf8());
+ }
+ }
+ }
+ if (qmakeValueHash.isEmpty()) {
+ ++waitCount;
+ static const int waitTimeInMilliSeconds = 500;
+ uiDetachedWait(waitTimeInMilliSeconds);
+ }
+ } //while (qmakeValueHash.isEmpty() && waitCount < 60)
+ return qmakeValueHash;
+}
+
+bool QtPatch::patchBinaryFile( const QString & fileName,
+ const QByteArray & oldQtPath,
+ const QByteArray & newQtPath )
+{
+ QFile file(fileName);
+ if ( !file.exists() ) {
+ QInstaller::verbose() << "qpatch: warning: file `" << qPrintable(fileName) << "' not found" << std::endl;
+ return false;
+ }
+
+ openFileForPatching(&file);
+ if (! file.isOpen()) {
+ QInstaller::verbose() << "qpatch: warning: file `" << qPrintable(fileName) << "' can not open." << std::endl;
+ QInstaller::verbose() << qPrintable(file.errorString()) << std::endl;
+ return false;
+ }
+
+ bool isPatched = patchBinaryFile(&file, oldQtPath, newQtPath);
+
+ file.close();
+ return isPatched;
+}
+
+// device must be open
+bool QtPatch::patchBinaryFile( QIODevice* device,
+ const QByteArray & oldQtPath,
+ const QByteArray & newQtPath )
+{
+ if (!(device->openMode() == QIODevice::ReadWrite)) {
+ QInstaller::verbose() << "qpatch: warning: This function needs an open device for writing." << std::endl;
+ return false;
+ }
+ const QByteArray source = device->readAll();
+ device->seek(0);
+
+ int offset = 0;
+ QByteArray overwritePath(newQtPath);
+ if(overwritePath.size() < oldQtPath.size()) {
+ QByteArray fillByteArray(oldQtPath.size() - overwritePath.size(), '\0');
+ overwritePath.append(fillByteArray);
+ }
+
+ QByteArrayMatcher byteArrayMatcher(oldQtPath);
+ forever {
+ offset = byteArrayMatcher.indexIn(source, offset);
+ if(offset == -1)
+ break;
+ device->seek(offset);
+ device->write(overwritePath);
+ offset += overwritePath.size();
+ }
+ device->seek(0); //for next reading we should be at the beginning
+ return true;
+}
+
+bool QtPatch::patchTextFile( const QString & fileName,
+ const QHash<QByteArray, QByteArray> &searchReplacePairs)
+{
+ QFile file(fileName);
+
+ if (! file.open(QFile::ReadOnly)) {
+ QInstaller::verbose() << "qpatch: warning: Open the file '"
+ << qPrintable(fileName) << "' stopped: "
+ << qPrintable(file.errorString()) << std::endl;
+ return false;
+ }
+
+ QByteArray source = file.readAll();
+ file.close();
+
+ qDebug() << Q_FUNC_INFO;
+ QHashIterator<QByteArray, QByteArray> it(searchReplacePairs);
+ while(it.hasNext()) {
+ it.next();
+ qDebug() << "it.key(): " << it.key();
+ qDebug() << "it.value(): " << it.value();
+ source.replace(it.key(), it.value());
+ }
+
+ if (! file.open(QFile::WriteOnly | QFile::Truncate)) {
+ QInstaller::verbose() << "qpatch: error: file `" << qPrintable(fileName) << "' not writable" << std::endl;
+ return false;
+ }
+
+ file.write(source);
+ return true;
+}
+
+
+bool QtPatch::openFileForPatching(QFile* file)
+{
+ if (file->openMode() == QIODevice::NotOpen) {
+ // in some cases the file can not open, because another process is blocking it(filewatcher ...)
+ int waitCount = 0;
+ while (! file->open(QFile::ReadWrite) && waitCount < 60) {
+ ++waitCount;
+ static const int waitTimeInMilliSeconds = 500;
+ uiDetachedWait(waitTimeInMilliSeconds);
+ }
+ return file->openMode() == QFile::ReadWrite;
+ }
+ QInstaller::verbose() << "qpatch: error: File `" << qPrintable(file->fileName()) << "' is open, so it can not open it again." << std::endl;
+ return false;
+}
diff --git a/installerbuilder/libinstaller/qtpatch.h b/installerbuilder/libinstaller/qtpatch.h
new file mode 100644
index 000000000..73170917e
--- /dev/null
+++ b/installerbuilder/libinstaller/qtpatch.h
@@ -0,0 +1,52 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QTPATCH_H
+#define QTPATCH_H
+
+#include "installer_global.h"
+#include <QString>
+#include <QByteArray>
+#include <QHash>
+#include <QFile>
+
+namespace QtPatch
+{
+ QHash<QString, QByteArray> INSTALLER_EXPORT qmakeValues(const QString &qmakePath, QByteArray * qmakeOutput);
+
+ bool INSTALLER_EXPORT patchBinaryFile( const QString &fileName,
+ const QByteArray &oldQtPath,
+ const QByteArray &newQtPath );
+
+ bool INSTALLER_EXPORT patchBinaryFile( QIODevice* device,
+ const QByteArray &oldQtPath,
+ const QByteArray &newQtPath );
+
+ bool INSTALLER_EXPORT patchTextFile( const QString &fileName,
+ const QHash<QByteArray, QByteArray> &searchReplacePairs);
+ bool INSTALLER_EXPORT openFileForPatching(QFile* file);
+};
+
+#endif // QTPATCH_H
diff --git a/installerbuilder/libinstaller/qtpatchoperation.cpp b/installerbuilder/libinstaller/qtpatchoperation.cpp
new file mode 100644
index 000000000..4017626cb
--- /dev/null
+++ b/installerbuilder/libinstaller/qtpatchoperation.cpp
@@ -0,0 +1,349 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "qtpatchoperation.h"
+#include "qtpatch.h"
+#ifdef Q_OS_MAC
+#include "macrelocateqt.h"
+#endif
+
+#include "common/utils.h"
+#include <qinstaller.h>
+
+#include <QMap>
+#include <QSet>
+#include <QFile>
+#include <QTextStream>
+#include <QDir>
+#include <QDebug>
+
+
+
+using namespace QInstaller;
+
+//"anonymous" namespace to make clear that this is only for inside use
+namespace {
+ QMap<QByteArray, QByteArray> generatePatchValueMap( const QByteArray & newQtPath,
+ const QHash<QString, QByteArray> & qmakeValueHash )
+ {
+ QMap<QByteArray, QByteArray> replaceMap; //first == searchstring: second == replace string
+ char nativeSeperator = QDir::separator().toAscii();
+ QByteArray oldValue;
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_PREFIX") );
+ replaceMap.insert( QByteArray("qt_prfxpath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_prfxpath=%1/").replace( "%1/", newQtPath ) );
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_DOCS") );
+ replaceMap.insert( QByteArray("qt_docspath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_docspath=%1/doc").replace( "%1/", newQtPath + nativeSeperator ) );
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_HEADERS") );
+ replaceMap.insert( QByteArray("qt_hdrspath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_hdrspath=%1/include").replace( "%1/", newQtPath + nativeSeperator ) );
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_LIBS") );
+ replaceMap.insert( QByteArray("qt_libspath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_libspath=%1/lib").replace( "%1/", newQtPath + nativeSeperator ) );
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_BINS") );
+ replaceMap.insert( QByteArray("qt_binspath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_binspath=%1/bin").replace( "%1/", newQtPath + nativeSeperator ) );
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_PLUGINS") );
+ replaceMap.insert( QByteArray("qt_plugpath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_plugpath=%1/plugins").replace( "%1/", newQtPath + nativeSeperator ) );
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_IMPORTS") );
+ replaceMap.insert( QByteArray("qt_impspath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_impspath=%1/imports").replace( "%1/", newQtPath + nativeSeperator ) );
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_DATA") );
+ replaceMap.insert( QByteArray("qt_datapath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_datapath=%1/").replace( "%1/", newQtPath + nativeSeperator ) );
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_TRANSLATIONS") );
+ replaceMap.insert( QByteArray("qt_trnspath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_trnspath=%1/translations").replace( "%1/", newQtPath + nativeSeperator ) );
+
+// This must not be patched. Commenting out to fix QTSDK-429
+// oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_CONFIGURATION"));
+// replaceMap.insert( QByteArray("qt_stngpath=%1").replace( "%1", oldValue),
+// QByteArray("qt_stngpath=%1").replace( "%1", newQtPath));
+
+ //examples and demoes can patched outside separately,
+ //but for cosmetic reasons - if the qt version gets no examples later.
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_EXAMPLES") );
+ replaceMap.insert( QByteArray("qt_xmplpath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_xmplpath=%1/examples").replace( "%1/", newQtPath + nativeSeperator ) );
+
+ oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_DEMOS") );
+ replaceMap.insert( QByteArray("qt_demopath=%1").replace( "%1", oldValue ),
+ QByteArray("qt_demopath=%1/demos").replace( "%1/", newQtPath + nativeSeperator ) );
+
+ return replaceMap;
+ }
+
+}//"anonymous" namespace
+
+QtPatchOperation::QtPatchOperation()
+{
+ setName(QLatin1String("QtPatch"));
+}
+
+QtPatchOperation::~QtPatchOperation()
+{
+}
+
+void QtPatchOperation::backup()
+{
+}
+
+bool QtPatchOperation::performOperation()
+{
+ // Arguments:
+ // 1. type
+ // 2. new/target qtpath
+
+ if( arguments().count() != 2 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg( arguments().count() ) );
+ return false;
+ }
+
+ QString type = arguments().at(0);
+
+ bool isPlatformSupported = type.contains(QLatin1String("linux"), Qt::CaseInsensitive) ||
+ type.contains(QLatin1String("windows"), Qt::CaseInsensitive) ||
+ type.contains(QLatin1String("mac"), Qt::CaseInsensitive);
+ if (!isPlatformSupported)
+ {
+ setError( InvalidArguments );
+ setErrorString( tr("First argument should be 'linux', 'mac' or 'windows'. No other type is supported at this time.") );
+ return false;
+ }
+ const QString newQtPathStr = QDir::toNativeSeparators( arguments().at(1) );
+ const QByteArray newQtPath = newQtPathStr.toUtf8();
+
+ QString qmakePath = QString::fromUtf8(newQtPath) + QLatin1String("/bin/qmake");
+#ifdef Q_OS_WIN
+ qmakePath = qmakePath + QLatin1String(".exe");
+#endif
+
+ if (!QFile::exists(qmakePath))
+ {
+ setError( UserDefinedError );
+ setErrorString( tr("QMake from the current Qt version \n(%1)" \
+ "is not existing. Please make a bugreport with this dialog at http://bugreports.qt.nokia.com.\n" \
+ ).arg(QDir::toNativeSeparators(qmakePath)));
+ return false;
+ }
+
+ QByteArray qmakeOutput;
+ QHash<QString, QByteArray> qmakeValueHash = QtPatch::qmakeValues(qmakePath, &qmakeOutput);
+
+ if (qmakeValueHash.isEmpty())
+ {
+ setError( UserDefinedError );
+ setErrorString( tr("The output of \n%1 -query\n" \
+ "is not parseable. Please make a bugreport with this dialog http://bugreports.qt.nokia.com.\n" \
+ "output: \"%2\"").arg(QDir::toNativeSeparators(qmakePath), QString::fromUtf8(qmakeOutput)));
+ return false;
+ }
+
+ const QByteArray oldQtPath = qmakeValueHash.value( QLatin1String("QT_INSTALL_PREFIX") );
+ bool oldQtPathFromQMakeIsEmpty = oldQtPath.isEmpty();
+
+ //maybe we don't need this, but I 255 should be a rational limit
+ if (255 < newQtPath.size()) {
+ setError( UserDefinedError );
+ setErrorString( tr("Qt patch error: new Qt dir(%1)\n" \
+ "needs to be less than 255 characters.").arg(newQtPathStr) );
+ return false;
+ }
+
+ QFile patchFileListFile;
+ if( type == QLatin1String("windows") )
+ patchFileListFile.setFileName( QLatin1String(":/files-to-patch-windows") );
+ else if( type == QLatin1String("linux") )
+ patchFileListFile.setFileName( QLatin1String(":/files-to-patch-linux") );
+ else if (type == QLatin1String("mac"))
+ patchFileListFile.setFileName( QLatin1String(":/files-to-patch-macx") );
+
+ if (! patchFileListFile.open(QFile::ReadOnly)) {
+ setError( UserDefinedError );
+ setErrorString( tr("Qt patch error: Can not open %1.").arg(patchFileListFile.fileName()) );
+ return false;
+ }
+
+ QStringList filesToPatch, textFilesToPatch;
+ bool readingTextFilesToPatch = false;
+
+ // read the input file
+ QTextStream in(&patchFileListFile);
+
+ forever {
+ const QString line = in.readLine();
+
+ if (line.isNull())
+ break;
+
+ else if (line.isEmpty())
+ continue;
+
+ else if (line.startsWith(QLatin1String("%%")))
+ readingTextFilesToPatch = true;
+
+ //with empty old path we don't know what we want to replace
+ else if (readingTextFilesToPatch && !oldQtPathFromQMakeIsEmpty)
+ textFilesToPatch.append(line);
+
+ else
+ filesToPatch.append(line);
+ }
+
+ QString prefix = QFile::decodeName(newQtPath);
+
+ if (! prefix.endsWith(QLatin1Char('/')) )
+ prefix += QLatin1Char('/');
+
+//BEGIN - patch binary files
+ QMap<QByteArray, QByteArray> patchValueMap = generatePatchValueMap(newQtPath, qmakeValueHash);
+
+ foreach (QString fileName, filesToPatch) {
+ fileName.prepend(prefix);
+ QFile file(fileName);
+
+ //without a file we can't do anything
+ if (!file.exists()) {
+ continue;
+ }
+
+ if (!QtPatch::openFileForPatching(&file)) {
+ setError( UserDefinedError );
+ setErrorString( tr("Qt patch error: Can not open %1(%2).").arg(file.fileName()).arg(file.errorString()) );
+ return false;
+ }
+
+ QMapIterator<QByteArray, QByteArray> it(patchValueMap);
+ while(it.hasNext()) {
+ it.next();
+ bool isPatched = QtPatch::patchBinaryFile(&file, it.key(), it.value());
+ if (!isPatched) {
+ QInstaller::verbose() << "qpatch: warning: file '" << qPrintable(fileName) << "' could not patched" << std::endl;
+ }
+ }
+ } //foreach (QString fileName, filesToPatch)
+//END - patch binary files
+
+//BEGIN - patch text files
+ QByteArray newQtPathWithNormalSlashes = QDir::fromNativeSeparators(newQtPathStr).toUtf8();
+
+ QHash<QByteArray, QByteArray> searchReplacePairs;
+ searchReplacePairs.insert(oldQtPath, newQtPathWithNormalSlashes);
+ searchReplacePairs.insert(QByteArray(oldQtPath).replace("/", "\\"), newQtPathWithNormalSlashes);
+ searchReplacePairs.insert(QByteArray(oldQtPath).replace("\\", "/"), newQtPathWithNormalSlashes);
+
+#ifdef Q_OS_WIN
+ QByteArray newQtPathWithDoubleBackSlashes = QByteArray(newQtPathWithNormalSlashes).replace("/", "\\\\");
+ searchReplacePairs.insert(QByteArray(oldQtPath).replace("/", "\\\\"), newQtPathWithDoubleBackSlashes);
+ searchReplacePairs.insert(QByteArray(oldQtPath).replace("\\", "\\\\"), newQtPathWithDoubleBackSlashes);
+
+ //this is checking for a possible drive letter, which could be upper or lower
+ if (oldQtPath.mid(1,1) == ":")
+ {
+ QHash<QByteArray, QByteArray> tempSearchReplacePairs;
+ QHashIterator<QByteArray, QByteArray> it(searchReplacePairs);
+ QByteArray driveLetter = oldQtPath.left(1);
+ while(it.hasNext()) {
+ it.next();
+ QByteArray currentPossibleSearchByteArrayWithoutDriveLetter = QByteArray(it.key()).remove(0, 1);
+ tempSearchReplacePairs.insert(driveLetter.toLower() + currentPossibleSearchByteArrayWithoutDriveLetter, it.value());
+ tempSearchReplacePairs.insert(driveLetter.toUpper() + currentPossibleSearchByteArrayWithoutDriveLetter, it.value());
+ }
+ searchReplacePairs = tempSearchReplacePairs;
+ }
+#endif
+
+ foreach (QString fileName, textFilesToPatch) {
+ fileName.prepend(prefix);
+
+ if (QFile::exists(fileName)) {
+ //TODO: use the return value for an error message at the end of the operation
+ QtPatch::patchTextFile(fileName, searchReplacePairs);
+ }
+ }
+//END - patch text files
+
+#ifdef Q_OS_MAC
+ Relocator relocator;
+ bool successMacRelocating = false;
+ QInstaller::Installer *installer = value(QLatin1String("installer")).value<QInstaller::Installer*>();
+ Q_CHECK_PTR(installer);
+ successMacRelocating = relocator.apply(newQtPathStr, installer->value(QLatin1String("TargetDir")));
+ if (!successMacRelocating)
+ {
+ setError( UserDefinedError );
+ setErrorString(tr("Error while relocating Qt: %1").arg(relocator.errorMessage()));
+ return false;
+ }
+#endif
+ if (oldQtPathFromQMakeIsEmpty)
+ {
+ setError( UserDefinedError );
+ setErrorString( tr("The installer was not able to get the unpatched path from \n%1.(maybe it is broken or removed)\n" \
+ "It tried to patch the Qt binaries, but all other files in Qt are unpatched.\n" \
+ "This could result in a broken Qt version.\n" \
+ "Sometimes it helps to restart the installer with a switched off antivirus software."
+ ).arg(QDir::toNativeSeparators(qmakePath)));
+ return false;
+ }
+
+ return true;
+}
+
+bool QtPatchOperation::undoOperation()
+{
+ return true;
+}
+
+bool QtPatchOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* QtPatchOperation::clone() const
+{
+ return new QtPatchOperation();
+}
+
diff --git a/installerbuilder/libinstaller/qtpatchoperation.h b/installerbuilder/libinstaller/qtpatchoperation.h
new file mode 100644
index 000000000..99a94fd40
--- /dev/null
+++ b/installerbuilder/libinstaller/qtpatchoperation.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef QTPATCHOPERATION_H
+#define QTPATCHOPERATION_H
+#include <KDUpdater/UpdateOperation>
+#include <QtCore/QObject>
+
+namespace QInstaller {
+
+class QtPatchOperation : public QObject, public KDUpdater::UpdateOperation
+{
+ Q_OBJECT
+public:
+ QtPatchOperation();
+ ~QtPatchOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+#endif // QTPATCHOPERATION_H
diff --git a/installerbuilder/libinstaller/registerdocumentationoperation.cpp b/installerbuilder/libinstaller/registerdocumentationoperation.cpp
new file mode 100644
index 000000000..3b8352e92
--- /dev/null
+++ b/installerbuilder/libinstaller/registerdocumentationoperation.cpp
@@ -0,0 +1,154 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "registerdocumentationoperation.h"
+#include "fsengineclient.h"
+
+#include <QHelpEngine>
+#include <QString>
+#include <QFileInfo>
+#include <QDir>
+#include <QSettings>
+#include <QDebug>
+
+using namespace QInstaller;
+
+RegisterDocumentationOperation::RegisterDocumentationOperation()
+{
+ setName(QLatin1String("RegisterDocumentation"));
+}
+
+RegisterDocumentationOperation::~RegisterDocumentationOperation()
+{
+}
+
+void RegisterDocumentationOperation::backup()
+{
+}
+
+namespace {
+ // get the right filename of the qsettingsfile (root/user)
+ QString settingsFileName()
+ {
+ #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
+ // If the system settings are writable, don't touch the user settings.
+ // The reason is that a doc registered while running with sudo could otherwise create
+ // a root-owned configuration file a user directory.
+ QScopedPointer<QSettings> settings(new QSettings(QSettings::IniFormat, QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtCreator")));
+
+ // QSettings::isWritable isn't reliable enough in 4.7, determine writability experimentally
+ settings->setValue(QLatin1String("iswritable"), QLatin1String("accomplished"));
+ settings->sync();
+ if (settings->status() == QSettings::NoError) {
+ // we can use the system settings
+ if (settings->contains(QLatin1String("iswritable")))
+ settings->remove(QLatin1String("iswritable"));
+ } else {
+ // we have to use user settings
+ settings.reset(new QSettings(QSettings::IniFormat, QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("QtCreator")));
+ }
+
+ #else
+ QScopedPointer<QSettings> settings(new QSettings(QSettings::IniFormat, QSettings::UserScope,
+ QLatin1String("Nokia"), QLatin1String("QtCreator")));
+ #endif
+ return settings->fileName();
+ }
+}
+
+bool RegisterDocumentationOperation::performOperation()
+{
+ const QStringList args = arguments();
+
+ if( args.count() != 1 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 1 expected.")
+ .arg(name()).arg( args.count() ) );
+ return false;
+ }
+ const QString helpFile = args.at(0);
+
+
+ QFileInfo fileInfo(settingsFileName());
+ QDir settingsDir(fileInfo.absolutePath() + QLatin1String("/qtcreator"));
+
+ if (!settingsDir.exists())
+ settingsDir.mkpath(settingsDir.absolutePath());
+ const QString collectionFile = settingsDir.absolutePath() + QLatin1String("/helpcollection.qhc");
+ qDebug() << "collectionFile: " << collectionFile;
+
+ if ( !QFileInfo( helpFile ).exists() ) {
+ setError ( UserDefinedError );
+ setErrorString( tr("Could not register help file %1: File not found.").arg( helpFile ) );
+ return false;
+ }
+
+ QHelpEngineCore help(collectionFile);
+ QString oldData = help.customValue(QLatin1String("AddedDocs")).toString();
+ if (!oldData.isEmpty())
+ oldData.append(QLatin1String(";"));
+ const QString newData = oldData + QFileInfo(helpFile).absoluteFilePath();
+ return help.setCustomValue(QLatin1String("AddedDocs"), newData);
+}
+
+bool RegisterDocumentationOperation::undoOperation()
+{
+ const QString helpFile = arguments().first();
+
+ QFileInfo fileInfo(settingsFileName());
+ QDir settingsDir(fileInfo.absolutePath() + QLatin1String("/qtcreator"));
+
+ if (!settingsDir.exists())
+ settingsDir.mkpath(settingsDir.absolutePath());
+ const QString collectionFile = settingsDir.absolutePath() + QLatin1String("/helpcollection.qhc");
+
+ if ( !QFileInfo( helpFile ).exists() ) {
+ setError ( UserDefinedError );
+ setErrorString( tr("Could not unregister help file %1: File not found.").arg( helpFile ) );
+ return false;
+ }
+
+ QHelpEngineCore help(collectionFile);
+ const QString nsName = help.namespaceName(helpFile);
+ return help.unregisterDocumentation(nsName);
+}
+
+bool RegisterDocumentationOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* RegisterDocumentationOperation::clone() const
+{
+ return new RegisterDocumentationOperation();
+}
+
diff --git a/installerbuilder/libinstaller/registerdocumentationoperation.h b/installerbuilder/libinstaller/registerdocumentationoperation.h
new file mode 100644
index 000000000..c6d64c751
--- /dev/null
+++ b/installerbuilder/libinstaller/registerdocumentationoperation.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef REGISTERDOCUMENTATIONOPERATION_H
+#define REGISTERDOCUMENTATIONOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class RegisterDocumentationOperation : public KDUpdater::UpdateOperation
+{
+public:
+ RegisterDocumentationOperation();
+ ~RegisterDocumentationOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+
+#endif // REGISTERDOCUMENTATIONOPERATION_H
diff --git a/installerbuilder/libinstaller/registerfiletypeoperation.cpp b/installerbuilder/libinstaller/registerfiletypeoperation.cpp
new file mode 100644
index 000000000..c2c2c88db
--- /dev/null
+++ b/installerbuilder/libinstaller/registerfiletypeoperation.cpp
@@ -0,0 +1,215 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "registerfiletypeoperation.h"
+
+#include <QSettings>
+
+// this makes us use QSettingsWrapper
+#include "fsengineclient.h"
+
+using namespace QInstaller;
+
+RegisterFileTypeOperation::RegisterFileTypeOperation()
+{
+ setName( QLatin1String( "RegisterFileType" ) );
+}
+
+RegisterFileTypeOperation::~RegisterFileTypeOperation()
+{
+}
+
+void RegisterFileTypeOperation::backup()
+{
+}
+
+bool RegisterFileTypeOperation::performOperation()
+{
+ // extension
+ // command
+ // (description)
+ // (content type)
+ // (icon)
+#ifdef Q_WS_WIN
+ if( arguments().count() < 2 || arguments().count() > 5 )
+ {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0").arg(name()) );
+ return false;
+ }
+ const QString extension = arguments()[ 0 ];
+ const QString command = arguments()[ 1 ];
+ const QString description = arguments().count() > 2 ? arguments()[ 2 ] : QString(); // optional
+ const QString contentType = arguments().count() > 3 ? arguments()[ 3 ] : QString(); // optional
+ const QString icon = arguments().count() > 4 ? arguments()[ 4 ] : QString(); // optional
+ const QString className = QString::fromLatin1( "%1_auto_file" ).arg( extension );
+ const QString settingsPrefix = QString::fromLatin1( "Software/Classes/" );
+
+ //QSettings settings( QLatin1String( "HKEY_CLASSES_ROOT" ), QSettings::NativeFormat );
+ QSettings settings( QLatin1String( "HKEY_CURRENT_USER" ), QSettings::NativeFormat );
+ // first backup the old values
+ setValue( QLatin1String( "oldClass" ), settings.value( QString::fromLatin1( "%1.%2/Default" ).arg( settingsPrefix, extension ) ) );
+ setValue( QLatin1String( "oldContentType" ), settings.value( QString::fromLatin1( "%1.%2/Content Type" ).arg( settingsPrefix, extension ) ) );
+
+ // the file extension was not yet registered. Let's do so now
+ settings.setValue( QString::fromLatin1( "%1.%2/Default" ).arg( settingsPrefix, extension ),
+ className );
+
+ // register the content type, if given
+ if( !contentType.isEmpty() )
+ settings.setValue( QString::fromLatin1( "%1.%2/Content Type" ).arg( settingsPrefix, extension ),
+ contentType );
+
+ //const QString className = settings.value( QString::fromLatin1( ".%1/Default" ).arg( extension ) ).toString();
+ //const QString oldClassName = value( QString::fromLatin1( ".%1/Default" ).arg( extension ) ).toString();
+ setValue( QLatin1String( "className" ), className );
+
+// setValue( QLatin1String( "oldDescription" ), settings.value( QString::fromLatin1( "%1/Default" ).arg( oldClassName ) ) );
+// setValue( QLatin1String( "oldIcon" ), settings.value( QString::fromLatin1( "%1/DefaultIcon/Default" ).arg( oldClassName ) ) );
+// setValue( QLatin1String( "oldCommand" ), settings.value( QString::fromLatin1( "%1/shell/Open/Command/Default" ).arg( oldClassName ) ) );
+
+ // register the description, if given
+ if( !description.isEmpty() )
+ settings.setValue( QString::fromLatin1( "%1%2/Default" ).arg( settingsPrefix, className ),
+ description );
+
+ // register the icon, if given
+ if( !icon.isEmpty() )
+ settings.setValue( QString::fromLatin1( "%1%2/DefaultIcon/Default" ).arg( settingsPrefix, className ),
+ icon );
+
+ // register the command to open the file
+ settings.setValue( QString::fromLatin1( "%1%2/shell/Open/Command/Default" ).arg( settingsPrefix, className ),
+ command );
+
+ return true;
+#else
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Registering file types in only supported on Windows." ) );
+ return false;
+#endif
+}
+
+bool RegisterFileTypeOperation::undoOperation()
+{
+ // extension
+ // command
+ // (description)
+ // (content type)
+ // (icon)
+#ifdef Q_WS_WIN
+ if( arguments().count() < 2 || arguments().count() > 5 )
+ {
+ setErrorString( tr("Register File Type: Invalid arguments") );
+ return false;
+ }
+ const QString extension = arguments()[ 0 ];
+ const QString command = arguments()[ 1 ];
+ const QString description = arguments().count() > 2 ? arguments()[ 2 ] : QString(); // optional
+ const QString contentType = arguments().count() > 3 ? arguments()[ 3 ] : QString(); // optional
+ const QString icon = arguments().count() > 4 ? arguments()[ 4 ] : QString(); // optional
+ const QString className = QString::fromLatin1( "%1_auto_file" ).arg( extension );
+ const QString settingsPrefix = QString::fromLatin1( "Software/Classes/" );
+
+ QSettings settings( QLatin1String( "HKEY_CURRENT_USER" ), QSettings::NativeFormat );
+
+ const QString restoredClassName = value( QLatin1String( "oldClassName" ) ).toString();
+ // register the command to open the file
+ if( settings.value( QString::fromLatin1( "%1%2/shell/Open/Command/Default" ).arg( settingsPrefix, className ) ).toString() != command )
+ return false;
+ if( settings.value( QString::fromLatin1( "%1%2/DefaultIcon/Default" ).arg( settingsPrefix, className ) ).toString() != icon )
+ return false;
+ if( settings.value( QString::fromLatin1( "%1%2/Default" ).arg( settingsPrefix, className ) ).toString() != description )
+ return false;
+ if( settings.value( QString::fromLatin1( "%1.%2/Content Type" ).arg( settingsPrefix, extension ) ).toString() != contentType )
+ return false;
+ if( settings.value( QString::fromLatin1( "%1.%2/Default" ).arg( settingsPrefix, extension ) ).toString() != className )
+ return false;
+
+ const QVariant oldCommand = value( QLatin1String( "oldCommand" ) );
+ if( !oldCommand.isNull() )
+ settings.setValue( QString::fromLatin1( "%1%2/shell/Open/Command/Default" ).arg( settingsPrefix, restoredClassName ),
+ oldCommand );
+ else
+ settings.remove( QString::fromLatin1( "%1%2/shell/Open/Command/Default" ).arg( settingsPrefix, className ) );
+
+ // register the icon, if given
+
+ const QVariant oldIcon = value( QLatin1String( "oldIcon" ) );
+ if( !oldIcon.isNull() )
+ settings.setValue( QString::fromLatin1( "%1%2/DefaultIcon/Default" ).arg( settingsPrefix, restoredClassName ),
+ oldIcon );
+ else
+ settings.remove( QString::fromLatin1( "%1%2/DefaultIcon/Default" ).arg( settingsPrefix, className ) );
+
+ // register the description, if given
+
+ const QVariant oldDescription = value( QLatin1String( "oldDescription" ) );
+ if( !oldDescription.isNull() )
+ settings.setValue( QString::fromLatin1( "%1%2/Default" ).arg( settingsPrefix, restoredClassName ),
+ oldDescription );
+ else
+ settings.remove( QString::fromLatin1( "%1%2/Default" ).arg( settingsPrefix, className ) );
+
+ // content type
+ settings.remove( QString::fromLatin1( "%1%2" ).arg( settingsPrefix, className ) );
+
+ const QVariant oldContentType = value( QLatin1String( "oldContentType" ) );
+ if( !oldContentType.isNull() )
+ settings.setValue( QString::fromLatin1( "%1.%2/Content Type" ).arg( settingsPrefix, extension ), oldContentType );
+ else
+ settings.remove( QString::fromLatin1( "%1.%2/Content Type" ).arg( settingsPrefix, extension ) );
+
+ // class
+
+ const QVariant oldClass = value( QLatin1String( "oldClass" ) );
+ if( !oldClass.isNull() )
+ settings.setValue( QString::fromLatin1( "%1.%2/Default" ).arg( settingsPrefix, extension ), oldClass );
+ else
+ settings.remove( QString::fromLatin1( "%1.%2" ).arg( settingsPrefix, extension ) );
+
+ return true;
+#else
+ setErrorString( QObject::tr( "Registering file types in only supported on Windows." ) );
+ return false;
+#endif
+}
+
+bool RegisterFileTypeOperation::testOperation()
+{
+ return true;
+}
+
+RegisterFileTypeOperation* RegisterFileTypeOperation::clone() const
+{
+ return new RegisterFileTypeOperation();
+}
diff --git a/installerbuilder/libinstaller/registerfiletypeoperation.h b/installerbuilder/libinstaller/registerfiletypeoperation.h
new file mode 100644
index 000000000..a6b2eb5ba
--- /dev/null
+++ b/installerbuilder/libinstaller/registerfiletypeoperation.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef REGISTERFILETYPEOPERATION_H
+#define REGISTERFILETYPEOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class RegisterFileTypeOperation : public KDUpdater::UpdateOperation
+{
+public:
+ RegisterFileTypeOperation();
+ ~RegisterFileTypeOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ RegisterFileTypeOperation* clone() const;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/registerqtoperation.cpp b/installerbuilder/libinstaller/registerqtoperation.cpp
new file mode 100644
index 000000000..786e8cdbe
--- /dev/null
+++ b/installerbuilder/libinstaller/registerqtoperation.cpp
@@ -0,0 +1,134 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "registerqtoperation.h"
+
+#include <QString>
+#include <QFileInfo>
+#include <QDir>
+#include <QSettings>
+#include <QDebug>
+
+using namespace QInstaller;
+
+RegisterQtInCreatorOperation::RegisterQtInCreatorOperation()
+{
+ setName(QLatin1String("RegisterQtInCreator"));
+}
+
+RegisterQtInCreatorOperation::~RegisterQtInCreatorOperation()
+{
+}
+
+void RegisterQtInCreatorOperation::backup()
+{
+}
+
+bool RegisterQtInCreatorOperation::performOperation()
+{
+ const QStringList args = arguments();
+
+ if( args.count() < 3) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, minimum 3 expected.")
+ .arg(name()).arg( args.count() ) );
+ return false;
+ }
+
+ const QString &rootInstallPath = args.at(0); //for example "C:\\Nokia_SDK\\"
+ const QString &versionName = args.at(1);
+ const QString &path = args.at(2);
+ QString mingwPath;
+ QString s60SdkPath;
+ QString gccePath;
+ QString carbidePath;
+ QString msvcPath;
+ QString sbsPath;
+ if (args.count() >= 4)
+ mingwPath = args.at(3);
+ if (args.count() >= 5)
+ s60SdkPath = args.at(4);
+ if (arguments().count() >= 6)
+ gccePath = args.at(5);
+ if (args.count() >= 7)
+ carbidePath = args.at(6);
+ if (args.count() >= 8)
+ msvcPath = args.at(7);
+ if (args.count() >= 9)
+ sbsPath = args.at(8);
+
+#if defined ( Q_OS_MAC )
+ QSettings settings( QString( QLatin1String("%1/Qt Creator.app/Contents/Resources/Nokia/QtCreator.ini")
+ ).arg(rootInstallPath),
+ QSettings::IniFormat );
+#else
+ QSettings settings( QString( QLatin1String("%1/QtCreator/share/qtcreator/Nokia/QtCreator.ini")
+ ).arg(rootInstallPath),
+ QSettings::IniFormat );
+#endif
+
+ QString newVersions = settings.value(QLatin1String("NewQtVersions")).toString();
+ if (!newVersions.isEmpty())
+ newVersions.append(QLatin1Char(';'));
+#if defined ( Q_OS_WIN )
+ QString addedVersion = versionName + QLatin1Char('=') +
+ QDir(path).absoluteFilePath(QLatin1String("bin/qmake.exe")).replace(QLatin1String("/"), QLatin1String("\\"));
+ addedVersion += QLatin1Char('=') + mingwPath.replace(QLatin1String("/"), QLatin1String("\\"));
+ addedVersion += QLatin1Char('=') + s60SdkPath.replace(QLatin1String("/"), QLatin1String("\\"));
+ addedVersion += QLatin1Char('=') + gccePath.replace(QLatin1String("/"), QLatin1String("\\"));
+ addedVersion += QLatin1Char('=') + carbidePath.replace(QLatin1String("/"), QLatin1String("\\"));
+ addedVersion += QLatin1Char('=') + msvcPath.replace(QLatin1String("/"), QLatin1String("\\"));
+ addedVersion += QLatin1Char('=') + sbsPath.replace(QLatin1String("/"), QLatin1String("\\"));
+#elif defined( Q_OS_UNIX )
+ QString addedVersion = versionName + QLatin1Char('=') +
+ QDir(path).absoluteFilePath(QLatin1String("bin/qmake"));
+#endif
+ newVersions += addedVersion;
+ settings.setValue(QLatin1String("NewQtVersions"), newVersions);
+
+ return true;
+}
+
+bool RegisterQtInCreatorOperation::undoOperation()
+{
+ return true;
+}
+
+bool RegisterQtInCreatorOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* RegisterQtInCreatorOperation::clone() const
+{
+ return new RegisterQtInCreatorOperation();
+}
diff --git a/installerbuilder/libinstaller/registerqtoperation.h b/installerbuilder/libinstaller/registerqtoperation.h
new file mode 100644
index 000000000..0caa0f5aa
--- /dev/null
+++ b/installerbuilder/libinstaller/registerqtoperation.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef REGISTERQTINCREATOROPERATION_H
+#define REGISTERQTINCREATOROPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class RegisterQtInCreatorOperation : public KDUpdater::UpdateOperation
+{
+public:
+ RegisterQtInCreatorOperation();
+ ~RegisterQtInCreatorOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+
+#endif // REGISTERQTINCREATOROPERATION_H
diff --git a/installerbuilder/libinstaller/replaceoperation.cpp b/installerbuilder/libinstaller/replaceoperation.cpp
new file mode 100644
index 000000000..4b9f31260
--- /dev/null
+++ b/installerbuilder/libinstaller/replaceoperation.cpp
@@ -0,0 +1,117 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "replaceoperation.h"
+#include <qinstaller.h>
+#include "common/utils.h"
+
+#include <QFile>
+#include <QDir>
+#include <QDebug>
+
+using namespace QInstaller;
+
+ReplaceOperation::ReplaceOperation()
+{
+ setName(QLatin1String("Replace"));
+}
+
+ReplaceOperation::~ReplaceOperation()
+{
+}
+
+void ReplaceOperation::backup()
+{
+}
+
+bool ReplaceOperation::performOperation()
+{
+ const QStringList args = arguments();
+
+ // Arguments:
+ // 1. filename
+ // 2. Source-String
+ // 3. Replace-String
+ if( args.count() != 3 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 3 expected.")
+ .arg(name()).arg( args.count() ) );
+ return false;
+ }
+ const QString currentFileName = args.at(0);
+ const QString beforeString = args.at(1);
+ const QString afterString = args.at(2);
+// QString debugString( QLatin1String("Replacing %1 to %2 in %3") );
+// debugString = debugString.arg(beforeString);
+// debugString = debugString.arg(afterString);
+// debugString = debugString.arg(currentFileName);
+// verbose() << debugString;
+
+ QFile file(currentFileName);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Failed to open %1 for reading" ).arg( currentFileName ) );
+ return false;
+ }
+
+ QString replacedFileContent = QString::fromLocal8Bit(file.readAll());
+ replacedFileContent.replace(beforeString, afterString);
+ file.close();
+
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ setError( UserDefinedError );
+ setErrorString( QObject::tr( "Failed to open %1 for writing" ).arg( currentFileName ) );
+ return false;
+ }
+
+ //TODO: check that toAscii is right(?)
+ file.write( replacedFileContent.toLocal8Bit() );
+ file.close();
+
+ return true;
+}
+
+bool ReplaceOperation::undoOperation()
+{
+ // Need to remove settings again
+ return true;
+}
+
+bool ReplaceOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* ReplaceOperation::clone() const
+{
+ return new ReplaceOperation();
+}
diff --git a/installerbuilder/libinstaller/replaceoperation.h b/installerbuilder/libinstaller/replaceoperation.h
new file mode 100644
index 000000000..d7231cf71
--- /dev/null
+++ b/installerbuilder/libinstaller/replaceoperation.h
@@ -0,0 +1,47 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef REPLACEOPERATION_H
+#define REPLACEOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class ReplaceOperation : public KDUpdater::UpdateOperation
+{
+public:
+ ReplaceOperation();
+ ~ReplaceOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+#endif // REPLACEOPERATION_H
diff --git a/installerbuilder/libinstaller/selfrestartoperation.cpp b/installerbuilder/libinstaller/selfrestartoperation.cpp
new file mode 100644
index 000000000..caf51c3f0
--- /dev/null
+++ b/installerbuilder/libinstaller/selfrestartoperation.cpp
@@ -0,0 +1,88 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "selfrestartoperation.h"
+#include "qinstaller.h"
+
+#include <KDToolsCore/KDSelfRestarter>
+
+using namespace QInstaller;
+
+SelfRestartOperation::SelfRestartOperation()
+{
+ setName( QLatin1String( "SelfRestart" ) );
+}
+
+SelfRestartOperation::~SelfRestartOperation()
+{
+}
+
+void SelfRestartOperation::backup()
+{
+ setValue( QLatin1String( "PreviousSelfRestart" ), KDSelfRestarter::restartOnQuit() );
+}
+
+bool SelfRestartOperation::performOperation()
+{
+ const Installer* const installer = qVariantValue< Installer* >( value( QLatin1String( "installer" ) ) );
+ if( !installer->isUpdater() )
+ {
+ setError( UserDefinedError );
+ setErrorString ( tr("Self Restart: Only valid within Updater.") );
+ return false;
+ }
+
+ if( !arguments().isEmpty() )
+ {
+ setError( InvalidArguments );
+ setErrorString( tr("Self Restart: Invalid arguments") );
+ return false;
+ }
+ KDSelfRestarter::setRestartOnQuit( true );
+ return KDSelfRestarter::restartOnQuit();
+}
+
+bool SelfRestartOperation::undoOperation()
+{
+ KDSelfRestarter::setRestartOnQuit( value( QLatin1String( "PreviousSelfRestart" ) ).toBool() );
+ return true;
+}
+
+bool SelfRestartOperation::testOperation()
+{
+ return true;
+}
+
+SelfRestartOperation* SelfRestartOperation::clone() const
+{
+ return new SelfRestartOperation();
+}
diff --git a/installerbuilder/libinstaller/selfrestartoperation.h b/installerbuilder/libinstaller/selfrestartoperation.h
new file mode 100644
index 000000000..96c1e6666
--- /dev/null
+++ b/installerbuilder/libinstaller/selfrestartoperation.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef SELFRESTARTOPERATION_H
+#define SELFRESTARTOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+namespace QInstaller {
+
+class SelfRestartOperation : public KDUpdater::UpdateOperation
+{
+public:
+ SelfRestartOperation();
+ ~SelfRestartOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ SelfRestartOperation* clone() const;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/setdemospathonqtoperation.cpp b/installerbuilder/libinstaller/setdemospathonqtoperation.cpp
new file mode 100644
index 000000000..575c5ddad
--- /dev/null
+++ b/installerbuilder/libinstaller/setdemospathonqtoperation.cpp
@@ -0,0 +1,132 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "setdemospathonqtoperation.h"
+
+#include "qtpatch.h"
+#include "qinstallerglobal.h"
+#include "common/utils.h"
+
+#include <QDir>
+#include <QSettings>
+
+using namespace QInstaller;
+
+SetDemosPathOnQtOperation::SetDemosPathOnQtOperation()
+{
+ setName(QLatin1String("SetDemosPathOnQt"));
+}
+
+SetDemosPathOnQtOperation::~SetDemosPathOnQtOperation()
+{
+}
+
+void SetDemosPathOnQtOperation::backup()
+{
+}
+
+bool SetDemosPathOnQtOperation::performOperation()
+{
+ const QStringList args = arguments();
+
+ if( args.count() != 2) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
+ .arg(name()).arg( arguments().count() ) );
+ return false;
+ }
+
+ const QString qtDir = args.at(0);
+ QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8();
+
+ QString qmakePath = qtDir + QLatin1String("/bin/qmake");
+#ifdef Q_OS_WIN
+ qmakePath = qmakePath + QLatin1String(".exe");
+#endif
+
+ QByteArray qmakeOutput;
+ QHash<QString, QByteArray> qmakeValueHash = QtPatch::qmakeValues(qmakePath, &qmakeOutput);
+
+ if (qmakeValueHash.isEmpty())
+ {
+ setError( UserDefinedError );
+ setErrorString( tr("The output of \n%1 -query\n" \
+ "is not parseable. Please make a bugreport with this dialog http://bugreports.qt.nokia.com.\n" \
+ "output: \"%2\"").arg(QDir::toNativeSeparators(qmakePath), QString::fromUtf8(qmakeOutput)));
+ return false;
+ }
+
+ QByteArray oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_DEMOS") );
+ bool oldQtPathFromQMakeIsEmpty = oldValue.isEmpty();
+ if (oldQtPathFromQMakeIsEmpty) {
+ verbose() << "qpatch: warning: It was not able to get the old values from " << qPrintable(qmakePath) << std::endl;
+ }
+
+ if (255 < newValue.size()) {
+ setError( UserDefinedError );
+ setErrorString( tr("Qt patch error: new Qt demo path(%1)\n" \
+ "needs to be less than 255 characters.").arg(QString::fromLocal8Bit(newValue)) );
+ return false;
+ }
+
+ QString qtConfPath = qtDir + QLatin1String("/bin/qt.conf");
+ if (QFile::exists(qtConfPath)) {
+ QSettings settings(qtConfPath, QSettings::IniFormat);
+ settings.setValue( QLatin1String("Paths/Demos"), QString::fromUtf8(newValue));
+ }
+
+ oldValue = QByteArray("qt_demopath=%1").replace("%1", oldValue);
+ newValue = QByteArray("qt_demopath=%1").replace("%1", newValue);
+
+ bool isPatched = QtPatch::patchBinaryFile(qmakePath, oldValue, newValue);
+ if (!isPatched) {
+ QInstaller::verbose() << "qpatch: warning: could not patched the demo path in " << qPrintable(qmakePath) << std::endl;
+ }
+
+ return true;
+}
+
+bool SetDemosPathOnQtOperation::undoOperation()
+{
+ return true;
+}
+
+bool SetDemosPathOnQtOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* SetDemosPathOnQtOperation::clone() const
+{
+ return new SetDemosPathOnQtOperation();
+}
+
diff --git a/installerbuilder/libinstaller/setdemospathonqtoperation.h b/installerbuilder/libinstaller/setdemospathonqtoperation.h
new file mode 100644
index 000000000..bf87eb36f
--- /dev/null
+++ b/installerbuilder/libinstaller/setdemospathonqtoperation.h
@@ -0,0 +1,49 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef SETDEMOSPATHONQTOPERATION_H
+#define SETDEMOSPATHONQTOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+#include <QtCore/QObject>
+
+namespace QInstaller {
+
+class SetDemosPathOnQtOperation : public KDUpdater::UpdateOperation
+{
+public:
+ SetDemosPathOnQtOperation();
+ ~SetDemosPathOnQtOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+
+#endif // SETDEMOSPATHONQTOPERATION_H
diff --git a/installerbuilder/libinstaller/setexamplespathonqtoperation.cpp b/installerbuilder/libinstaller/setexamplespathonqtoperation.cpp
new file mode 100644
index 000000000..17b668d38
--- /dev/null
+++ b/installerbuilder/libinstaller/setexamplespathonqtoperation.cpp
@@ -0,0 +1,133 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "setexamplespathonqtoperation.h"
+
+#include "qtpatch.h"
+#include "qinstallerglobal.h"
+#include "common/utils.h"
+
+#include <QDir>
+#include <QSettings>
+
+using namespace QInstaller;
+
+SetExamplesPathOnQtOperation::SetExamplesPathOnQtOperation()
+{
+ setName(QLatin1String("SetExamplesPathOnQt"));
+}
+
+SetExamplesPathOnQtOperation::~SetExamplesPathOnQtOperation()
+{
+}
+
+void SetExamplesPathOnQtOperation::backup()
+{
+}
+
+bool SetExamplesPathOnQtOperation::performOperation()
+{
+ const QStringList args = arguments();
+
+ if( args.count() != 2) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
+ .arg(name()).arg( arguments().count() ) );
+ return false;
+ }
+
+ const QString qtDir = args.at(0);
+ QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8();
+
+ QString qmakePath = qtDir + QLatin1String("/bin/qmake");
+#ifdef Q_OS_WIN
+ qmakePath = qmakePath + QLatin1String(".exe");
+#endif
+
+ QByteArray qmakeOutput;
+ QHash<QString, QByteArray> qmakeValueHash = QtPatch::qmakeValues(qmakePath, &qmakeOutput);
+
+ if (qmakeValueHash.isEmpty())
+ {
+ setError( UserDefinedError );
+ setErrorString( tr("The output of \n%1 -query\n" \
+ "is not parseable. Please make a bugreport with this dialog http://bugreports.qt.nokia.com.\n" \
+ "output: \"%2\"").arg(QDir::toNativeSeparators(qmakePath), QString::fromUtf8(qmakeOutput)));
+ return false;
+ }
+
+ QByteArray oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_EXAMPLES") );
+ bool oldQtPathFromQMakeIsEmpty = oldValue.isEmpty();
+ if (oldQtPathFromQMakeIsEmpty) {
+ verbose() << "qpatch: warning: It was not able to get the old values from " << qPrintable(qmakePath) << std::endl;
+ }
+
+ if (255 < newValue.size()) {
+ setError( UserDefinedError );
+ setErrorString( tr("Qt patch error: new Qt example path(%1)\n" \
+ "needs to be less than 255 characters.").arg(QString::fromLocal8Bit(newValue)) );
+ return false;
+ }
+
+ QString qtConfPath = qtDir + QLatin1String("/bin/qt.conf");
+
+ if (QFile::exists(qtConfPath)) {
+ QSettings settings(qtConfPath, QSettings::IniFormat);
+ settings.setValue( QLatin1String("Paths/Examples"), QString::fromUtf8(newValue));
+ }
+
+ oldValue = QByteArray("qt_xmplpath=%1").replace("%1", oldValue);
+ newValue = QByteArray("qt_xmplpath=%1").replace("%1", newValue);
+
+ bool isPatched = QtPatch::patchBinaryFile(qmakePath, oldValue, newValue);
+ if (!isPatched) {
+ QInstaller::verbose() << "qpatch: warning: could not patched the example path in " << qPrintable(qmakePath) << std::endl;
+ }
+
+ return true;
+}
+
+bool SetExamplesPathOnQtOperation::undoOperation()
+{
+ return true;
+}
+
+bool SetExamplesPathOnQtOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* SetExamplesPathOnQtOperation::clone() const
+{
+ return new SetExamplesPathOnQtOperation();
+}
+
diff --git a/installerbuilder/libinstaller/setexamplespathonqtoperation.h b/installerbuilder/libinstaller/setexamplespathonqtoperation.h
new file mode 100644
index 000000000..3a6db9a08
--- /dev/null
+++ b/installerbuilder/libinstaller/setexamplespathonqtoperation.h
@@ -0,0 +1,49 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef SETEXAMPLESPATHONQTOPERATION_H
+#define SETEXAMPLESPATHONQTOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+#include <QtCore/QObject>
+
+namespace QInstaller {
+
+class SetExamplesPathOnQtOperation : public KDUpdater::UpdateOperation
+{
+public:
+ SetExamplesPathOnQtOperation();
+ ~SetExamplesPathOnQtOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+
+#endif // SETEXAMPLESPATHONQTOPERATION_H
diff --git a/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp b/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp
new file mode 100644
index 000000000..0f3d237ce
--- /dev/null
+++ b/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp
@@ -0,0 +1,155 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "setimportspathonqtcoreoperation.h"
+
+#include "qtpatch.h"
+#include "qinstallerglobal.h"
+#include "common/utils.h"
+
+#include <QByteArrayMatcher>
+#include <QDir>
+
+using namespace QInstaller;
+
+namespace {
+QByteArray getOldValue(const QString & binaryPath)
+{
+ QFileInfo fileInfo(binaryPath);
+
+ if ( !fileInfo.exists() ) {
+ verbose() << "qpatch: warning: file `" << qPrintable(binaryPath) << "' not found" << std::endl;
+ return QByteArray();
+ }
+
+
+ QFile file(binaryPath);
+ int readOpenCount = 0;
+ while (! file.open(QFile::ReadOnly) && readOpenCount < 20000) {
+ ++readOpenCount;
+ qApp->processEvents();
+ }
+ Q_ASSERT(file.isOpen());
+ if (! file.isOpen()) {
+ verbose() << "qpatch: warning: file `" << qPrintable(binaryPath) << "' can not open as ReadOnly." << std::endl;
+ verbose() << file.errorString() << std::endl;
+ return QByteArray();
+ }
+
+ const QByteArray source = file.readAll();
+ file.close();
+
+ int offset = 0;
+ QByteArray searchValue("qt_impspath=");
+ QByteArrayMatcher byteArrayMatcher(searchValue);
+ offset = byteArrayMatcher.indexIn(source, offset);
+ Q_ASSERT(offset > 0);
+ if(offset == -1)
+ return QByteArray();
+
+ int stringEndPosition = offset;
+ while(source.at(stringEndPosition++) != '\0'){}
+ //after search string till the first \0 it should be our looking for QByteArray
+ return source.mid(offset + searchValue.size(), stringEndPosition - offset);
+}
+}
+
+SetImportsPathOnQtCoreOperation::SetImportsPathOnQtCoreOperation()
+{
+ setName(QLatin1String("SetImportsPathOnQtCore"));
+}
+
+SetImportsPathOnQtCoreOperation::~SetImportsPathOnQtCoreOperation()
+{
+}
+
+void SetImportsPathOnQtCoreOperation::backup()
+{
+}
+
+bool SetImportsPathOnQtCoreOperation::performOperation()
+{
+ const QStringList args = arguments();
+
+ if( args.count() != 2) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
+ .arg(name()).arg( arguments().count() ) );
+ return false;
+ }
+
+ const QString qtCoreLibraryDir = args.at(0);
+ const QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8();
+
+ if (255 < newValue.size()) {
+ verbose() << "qpatch: error: newQtDir needs to be less than 255 characters." << std::endl;
+ return false;
+ }
+ QStringList libraryFiles;
+ #ifdef Q_OS_WIN
+ libraryFiles << QString( QLatin1String("%1/QtCore4.dll") ).arg(qtCoreLibraryDir);
+ libraryFiles << QString( QLatin1String("%1/QtCore4d.dll") ).arg(qtCoreLibraryDir);
+ #else
+ libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so");
+ #endif
+ foreach(const QString coreLibrary, libraryFiles) {
+ if( QFile::exists(coreLibrary) ) {
+ QByteArray oldValue(getOldValue(coreLibrary));
+ Q_ASSERT(!oldValue.isEmpty());
+ oldValue = QByteArray("qt_impspath=%1").replace("%1", oldValue);
+ QByteArray adjutedNewValue = QByteArray("qt_impspath=%1").replace("%1", newValue);
+
+ bool isPatched = QtPatch::patchBinaryFile(coreLibrary, oldValue, adjutedNewValue);
+ if (!isPatched) {
+ QInstaller::verbose() << "qpatch: warning: could not patched the imports path in " << qPrintable(coreLibrary) << std::endl;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool SetImportsPathOnQtCoreOperation::undoOperation()
+{
+ return true;
+}
+
+bool SetImportsPathOnQtCoreOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* SetImportsPathOnQtCoreOperation::clone() const
+{
+ return new SetImportsPathOnQtCoreOperation();
+}
+
diff --git a/installerbuilder/libinstaller/setimportspathonqtcoreoperation.h b/installerbuilder/libinstaller/setimportspathonqtcoreoperation.h
new file mode 100644
index 000000000..c23a08863
--- /dev/null
+++ b/installerbuilder/libinstaller/setimportspathonqtcoreoperation.h
@@ -0,0 +1,49 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef SETIMPORTSPATHONQTCOREOPERATION_H
+#define SETIMPORTSPATHONQTCOREOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+#include <QtCore/QObject>
+
+namespace QInstaller {
+
+class SetImportsPathOnQtCoreOperation : public KDUpdater::UpdateOperation
+{
+public:
+ SetImportsPathOnQtCoreOperation();
+ ~SetImportsPathOnQtCoreOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+
+#endif // SETIMPORTSPATHONQTCOREOPERATION_H
diff --git a/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp b/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp
new file mode 100644
index 000000000..d531d37f7
--- /dev/null
+++ b/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp
@@ -0,0 +1,155 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "setpluginpathonqtcoreoperation.h"
+
+#include "qtpatch.h"
+#include "qinstallerglobal.h"
+#include "common/utils.h"
+
+#include <QByteArrayMatcher>
+#include <QDir>
+
+using namespace QInstaller;
+
+namespace {
+QByteArray getOldValue(const QString & binaryPath)
+{
+ QFileInfo fileInfo(binaryPath);
+
+ if ( !fileInfo.exists() ) {
+ verbose() << "qpatch: warning: file `" << qPrintable(binaryPath) << "' not found" << std::endl;
+ return QByteArray();
+ }
+
+
+ QFile file(binaryPath);
+ int readOpenCount = 0;
+ while (! file.open(QFile::ReadOnly) && readOpenCount < 20000) {
+ ++readOpenCount;
+ qApp->processEvents();
+ }
+ Q_ASSERT(file.isOpen());
+ if (! file.isOpen()) {
+ verbose() << "qpatch: warning: file `" << qPrintable(binaryPath) << "' can not open as ReadOnly." << std::endl;
+ verbose() << file.errorString() << std::endl;
+ return QByteArray();
+ }
+
+ const QByteArray source = file.readAll();
+ file.close();
+
+ int offset = 0;
+ QByteArray searchValue("qt_plugpath=");
+ QByteArrayMatcher byteArrayMatcher(searchValue);
+ offset = byteArrayMatcher.indexIn(source, offset);
+ Q_ASSERT(offset > 0);
+ if(offset == -1)
+ return QByteArray();
+
+ int stringEndPosition = offset;
+ while(source.at(stringEndPosition++) != '\0'){}
+ //after search string till the first \0 it should be our looking for QByteArray
+ return source.mid(offset + searchValue.size(), stringEndPosition - offset);
+}
+}
+
+SetPluginPathOnQtCoreOperation::SetPluginPathOnQtCoreOperation()
+{
+ setName(QLatin1String("SetPluginPathOnQtCore"));
+}
+
+SetPluginPathOnQtCoreOperation::~SetPluginPathOnQtCoreOperation()
+{
+}
+
+void SetPluginPathOnQtCoreOperation::backup()
+{
+}
+
+bool SetPluginPathOnQtCoreOperation::performOperation()
+{
+ const QStringList args = arguments();
+
+ if( args.count() != 2) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
+ .arg(name()).arg( arguments().count() ) );
+ return false;
+ }
+
+ const QString qtCoreLibraryDir = args.at(0);
+ const QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8();
+
+ if (255 < newValue.size()) {
+ verbose() << "qpatch: error: newQtDir needs to be less than 255 characters." << std::endl;
+ return false;
+ }
+ QStringList libraryFiles;
+ #ifdef Q_OS_WIN
+ libraryFiles << QString( QLatin1String("%1/QtCore4.dll") ).arg(qtCoreLibraryDir);
+ libraryFiles << QString( QLatin1String("%1/QtCore4d.dll") ).arg(qtCoreLibraryDir);
+ #else
+ libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so");
+ #endif
+ foreach(const QString coreLibrary, libraryFiles) {
+ if( QFile::exists(coreLibrary) ) {
+ QByteArray oldValue(getOldValue(coreLibrary));
+ Q_ASSERT(!oldValue.isEmpty());
+ oldValue = QByteArray("qt_plugpath=%1").replace("%1", oldValue);
+ QByteArray adjutedNewValue = QByteArray("qt_plugpath=%1").replace("%1", newValue);
+
+ bool isPatched = QtPatch::patchBinaryFile(coreLibrary, oldValue, adjutedNewValue);
+ if (!isPatched) {
+ QInstaller::verbose() << "qpatch: warning: could not patched the plugin path in " << qPrintable(coreLibrary) << std::endl;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool SetPluginPathOnQtCoreOperation::undoOperation()
+{
+ return true;
+}
+
+bool SetPluginPathOnQtCoreOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* SetPluginPathOnQtCoreOperation::clone() const
+{
+ return new SetPluginPathOnQtCoreOperation();
+}
+
diff --git a/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.h b/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.h
new file mode 100644
index 000000000..9351f00e3
--- /dev/null
+++ b/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.h
@@ -0,0 +1,49 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef SETPLUGINPATHONQTCOREOPERATION_H
+#define SETPLUGINPATHONQTCOREOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+#include <QtCore/QObject>
+
+namespace QInstaller {
+
+class SetPluginPathOnQtCoreOperation : public KDUpdater::UpdateOperation
+{
+public:
+ SetPluginPathOnQtCoreOperation();
+ ~SetPluginPathOnQtCoreOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+
+#endif // SETPLUGINPATHONQTCOREOPERATION_H
diff --git a/installerbuilder/libinstaller/setqtcreatorvalueoperation.cpp b/installerbuilder/libinstaller/setqtcreatorvalueoperation.cpp
new file mode 100644
index 000000000..47bd92462
--- /dev/null
+++ b/installerbuilder/libinstaller/setqtcreatorvalueoperation.cpp
@@ -0,0 +1,120 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "setqtcreatorvalueoperation.h"
+
+#include <QString>
+#include <QFileInfo>
+#include <QDir>
+#include <QSettings>
+#include <QDebug>
+
+using namespace QInstaller;
+
+SetQtCreatorValueOperation::SetQtCreatorValueOperation()
+{
+ setName(QLatin1String("SetQtCreatorValue"));
+}
+
+SetQtCreatorValueOperation::~SetQtCreatorValueOperation()
+{
+}
+
+void SetQtCreatorValueOperation::backup()
+{
+}
+
+namespace {
+ QString groupName(const QString & groupName)
+ {
+ if(groupName == QLatin1String("General")) {
+ return QString();
+ } else {
+ return groupName;
+ }
+ }
+}
+
+bool SetQtCreatorValueOperation::performOperation()
+{
+ const QStringList args = arguments();
+
+ if( args.count() != 4) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 4 expected(rootInstallPath,group,key,value).")
+ .arg(name()).arg( arguments().count() ) );
+ return false;
+ }
+
+ const QString &rootInstallPath = args.at(0); //for example "C:\\Nokia_SDK\\"
+
+ const QString &group = groupName(args.at(1));
+ const QString &key = args.at(2);
+ const QString &value = args.at(3);
+
+#if defined(Q_OS_MAC)
+ QString iniFileLocation = QLatin1String("%1/Qt Creator.app/Contents/Resources/Nokia/QtCreator.ini");
+#else
+ QString iniFileLocation = QLatin1String("%1/QtCreator/share/qtcreator/Nokia/QtCreator.ini");
+#endif
+
+ QSettings settings( iniFileLocation.arg(rootInstallPath),
+ QSettings::IniFormat );
+
+ if(!group.isEmpty()) {
+ settings.beginGroup(group);
+ }
+
+ settings.setValue(key, value);
+
+ if(!group.isEmpty()) {
+ settings.endGroup();
+ }
+
+ return true;
+}
+
+bool SetQtCreatorValueOperation::undoOperation()
+{
+ return true;
+}
+
+bool SetQtCreatorValueOperation::testOperation()
+{
+ return true;
+}
+
+KDUpdater::UpdateOperation* SetQtCreatorValueOperation::clone() const
+{
+ return new SetQtCreatorValueOperation();
+}
+
diff --git a/installerbuilder/libinstaller/setqtcreatorvalueoperation.h b/installerbuilder/libinstaller/setqtcreatorvalueoperation.h
new file mode 100644
index 000000000..5c2663fb9
--- /dev/null
+++ b/installerbuilder/libinstaller/setqtcreatorvalueoperation.h
@@ -0,0 +1,49 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef SETQTCREATORVALUEOPERATION_H
+#define SETQTCREATORVALUEOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+#include <QtCore/QObject>
+
+namespace QInstaller {
+
+class SetQtCreatorValueOperation : public KDUpdater::UpdateOperation
+{
+public:
+ SetQtCreatorValueOperation();
+ ~SetQtCreatorValueOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ KDUpdater::UpdateOperation* clone() const;
+};
+
+}; // namespace
+
+#endif // SETQTCREATORVALUEOPERATION_H
diff --git a/installerbuilder/libinstaller/simplemovefileoperation.cpp b/installerbuilder/libinstaller/simplemovefileoperation.cpp
new file mode 100644
index 000000000..5abea0437
--- /dev/null
+++ b/installerbuilder/libinstaller/simplemovefileoperation.cpp
@@ -0,0 +1,124 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "simplemovefileoperation.h"
+
+#include <QFileInfo>
+#include <QDir>
+#include <QDirIterator>
+
+#include <QDebug>
+
+using namespace QInstaller;
+
+/*
+TRANSLATOR QInstaller::SimpleMoveFileOperation
+*/
+
+SimpleMoveFileOperation::SimpleMoveFileOperation()
+{
+ setName( QLatin1String( "SimpleMoveFile" ) );
+}
+
+SimpleMoveFileOperation::~SimpleMoveFileOperation()
+{
+}
+
+void SimpleMoveFileOperation::backup()
+{
+}
+
+bool SimpleMoveFileOperation::performOperation()
+{
+ const QStringList args = arguments();
+ if( args.count() != 2 ) {
+ setError( InvalidArguments );
+ setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg( args.count() ) );
+ return false;
+ }
+ const QString source = args.at( 0 );
+ const QString target = args.at( 1 );
+
+
+
+ if (source.isEmpty() || target.isEmpty() ) {
+ setError( UserDefinedError );
+ setErrorString( tr("None of the arguments can be empty: source(\"%1\"), target(\"%2\")")
+ .arg(source, target) );
+ return false;
+ }
+
+ // If destination file exists, then we cannot use QFile::copy()
+ // because it does not overwrite an existing file. So we remove
+ // the destination file.
+ if( QFile::exists( target ) )
+ {
+ QFile file( target );
+ if( !file.remove() ) {
+ setError( UserDefinedError );
+ setErrorString( tr("can not copy source(\"%1\") to target(\"%2\"), because target is existing and not removable.")
+ .arg(source, target) );
+ return false;
+ }
+ }
+
+ QFile file( source );
+ const bool moved = file.rename( target );
+ if ( !moved ) {
+ setError( UserDefinedError );
+ setErrorString( tr("can not move source(\"%1\") to target(\"%2\"), %3")
+ .arg(source, target, file.errorString()) );
+ return false;
+ }
+ return true;
+}
+
+bool SimpleMoveFileOperation::undoOperation()
+{
+ const QString source = arguments().at( 0 );
+ const QString target = arguments().at( 1 );
+ QFile file( target );
+ file.rename( source );
+
+ return true;
+}
+
+bool SimpleMoveFileOperation::testOperation()
+{
+ return true;
+}
+
+SimpleMoveFileOperation* SimpleMoveFileOperation::clone() const
+{
+ return new SimpleMoveFileOperation();
+}
diff --git a/installerbuilder/libinstaller/simplemovefileoperation.h b/installerbuilder/libinstaller/simplemovefileoperation.h
new file mode 100644
index 000000000..c2b86563c
--- /dev/null
+++ b/installerbuilder/libinstaller/simplemovefileoperation.h
@@ -0,0 +1,54 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef SIMPLEMOVEFILEOPERATION_H
+#define SIMPLEMOVEFILEOPERATION_H
+
+#include <KDUpdater/UpdateOperation>
+
+#include "installer_global.h"
+#include <QtCore/QObject>
+
+namespace QInstaller {
+
+class INSTALLER_EXPORT SimpleMoveFileOperation : public QObject, public KDUpdater::UpdateOperation
+{
+ Q_OBJECT
+
+public:
+ SimpleMoveFileOperation();
+ ~SimpleMoveFileOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ SimpleMoveFileOperation* clone() const;
+
+};
+
+}
+
+#endif //SIMPLEMOVEFILEOPERATION_H
diff --git a/installerbuilder/libinstaller/sv_se.ts b/installerbuilder/libinstaller/sv_se.ts
new file mode 100644
index 000000000..b9a078ffd
--- /dev/null
+++ b/installerbuilder/libinstaller/sv_se.ts
@@ -0,0 +1,742 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1">
+<context>
+ <name>GetMetaInfoProgressWidget</name>
+ <message>
+ <location filename="installer.cpp" line="441"/>
+ <source>Retrieving information from remote installation sources...</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>Installer::Private</name>
+ <message>
+ <location filename="qinstaller.cpp" line="488"/>
+ <source>Could not write uninstaller to %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="501"/>
+ <source>ProductName should be set</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="548"/>
+ <source>Variable &apos;TargetDir&apos; not set.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="595"/>
+ <source>Preparing the installation...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="617"/>
+ <source>Installing component %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="623"/>
+ <source>Installation canceled by user</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="663"/>
+ <source>Installation finished!</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="679"/>
+ <source>Installation aborted</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="701"/>
+ <source>Cannot prepare uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="737"/>
+ <source>Cannot start uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="754"/>
+ <source>Deinstallation finished</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller</name>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="152"/>
+ <source>Cannot map file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="155"/>
+ <source>Cannot unmap file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::Component</name>
+ <message>
+ <location filename="qinstallercomponent.cpp" line="264"/>
+ <source>Could not open the requested UI file at %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::ComponentSelectionPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="451"/>
+ <source>This component will occupy approximately %1 %2 on your harddisk.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="453"/>
+ <source>Bytes</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="455"/>
+ <source>kBytes</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="456"/>
+ <source>MBytes</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="533"/>
+ <source>Select Components</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="534"/>
+ <source>Please select the components you want to install.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::CreateShortcutOperation</name>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="70"/>
+ <source>Could not create link: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::EnvironmentVariablesOperation</name>
+ <message>
+ <location filename="environmentvariablesoperation.cpp" line="45"/>
+ <source>Invalid arguments: %1 arguments given, 2-3 expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="environmentvariablesoperation.cpp" line="61"/>
+ <source>Registry is not writable</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="environmentvariablesoperation.cpp" line="77"/>
+ <source>Failed to write to the Registry</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="environmentvariablesoperation.cpp" line="105"/>
+ <source>Failed to set the envrionment variable %1 to %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::ExtractArchiveOperation</name>
+ <message>
+ <location filename="extractarchiveoperation.cpp" line="33"/>
+ <source>Invalid arguments: %1 arguments given, 2 expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::ExtractArchiveOperation::Runnable</name>
+ <message>
+ <location filename="extractarchiveoperation_p.h" line="77"/>
+ <source>Could not open %1 for reading: %2.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="extractarchiveoperation_p.h" line="84"/>
+ <source>Error while extracting %1: %2.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="extractarchiveoperation_p.h" line="86"/>
+ <source>Unknown exception caught while extracting %1.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::FinishedPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="927"/>
+ <source>Completing the %1 Setup Wizard</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="934"/>
+ <source>Click Finish to exit the Setup Wizard</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="961"/>
+ <source>Run %1 now.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="966"/>
+ <source>The %1 Setup Wizard failed</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::GetRepositoryMetaInfoJob</name>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="40"/>
+ <source>empty repository URL</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="44"/>
+ <source>invalid repository URL</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="113"/>
+ <source>Retrieving component information from remote repositories...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="117"/>
+ <source>canceled</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="121"/>
+ <source>Could not fetch Updates.xml: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="128"/>
+ <source>Could not move Updates.xml to target location: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="137"/>
+ <source>Could not open Updates.xml for reading: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="145"/>
+ <source>Could not parse component index: %1:%2: %3</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="169"/>
+ <source>Retrieving component meta information...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="191"/>
+ <source>Could not open meta info archive %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::GlobalSettingsOperation</name>
+ <message>
+ <location filename="globalsettingsoperation.cpp" line="46"/>
+ <source>Invalid arguments: %1 arguments given, 4 expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::Gui</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="165"/>
+ <source>%1 Setup</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="195"/>
+ <source>Go Back</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="196"/>
+ <source>Continue</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="197"/>
+ <source>Done</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="199"/>
+ <source>Back</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="200"/>
+ <source>Next</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="201"/>
+ <source>Finish</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="203"/>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="282"/>
+ <source>Warning</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="255"/>
+ <source>Do you want to abort the installation process?</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="262"/>
+ <source>Do you want to abort the installer application?</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::InstallerSettings</name>
+ <message>
+ <location filename="../common/installersettings.cpp" line="70"/>
+ <source>Could not open settings file %1 for reading: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/installersettings.cpp" line="75"/>
+ <source>Could not parse settings file %1: %2:%3: %4</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/installersettings.cpp" line="81"/>
+ <source>%1 is not valid: Installer root node expected</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/installersettings.cpp" line="98"/>
+ <source>Multiple RemoteRepositories elements found, but only one allowed.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::IntroductionPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="370"/>
+ <source>Setup - %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="378"/>
+ <source>Welcome to the %1 Setup Wizard.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::LicenseAgreementPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="394"/>
+ <source>License Agreement</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="397"/>
+ <source>Please read the following License Agreement. You must accept the terms of this agreement before continuing with the installation.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="409"/>
+ <source>I accept the agreement</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="410"/>
+ <source>I do not accept the agreement</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="420"/>
+ <source>Do you accept this license?</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::PerformInstallationPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="808"/>
+ <source>Uninstalling %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="809"/>
+ <source>Uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="812"/>
+ <source>Installing %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="813"/>
+ <source>Install</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="906"/>
+ <source>Show Details</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="906"/>
+ <source>Hide Details</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::QInstaller</name>
+ <message>
+ <location filename="qinstallerglobal.h" line="31"/>
+ <source>Cannot map file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallerglobal.h" line="34"/>
+ <source>Cannot unmap file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::ReadyForInstallationPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="775"/>
+ <source>Ready to Uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="777"/>
+ <source>Uninstall</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="779"/>
+ <source>Setup is now ready to begin removing %1 from your computer.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="782"/>
+ <source>Ready to Install</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="784"/>
+ <source>Install</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="786"/>
+ <source>Setup is now ready to begin installing %1 on your computer.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::StartMenuDirectoryPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="666"/>
+ <source>Start Menu shortcuts</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="673"/>
+ <source>Select the Start Menu in which you would like to create the program&apos;s shortcuts. You can also enter a name to create a new folder.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstaller::TargetDirectoryPage</name>
+ <message>
+ <location filename="qinstallergui.cpp" line="567"/>
+ <source>Installation Folder</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="573"/>
+ <source>Please specify the folder where %1 will be installed.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="582"/>
+ <source>Browse...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="627"/>
+ <source>Warning</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="628"/>
+ <source>The folder you selected exists already.
+Do you want to continue?</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallergui.cpp" line="651"/>
+ <source>Select Installation Folder</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstallerCreator::Archive</name>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="404"/>
+ <source>Could not open archive file %1 for reading.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="409"/>
+ <source>Not in a supported archive format: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="432"/>
+ <source>Could not create archive from %1: Not a file.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="454"/>
+ <source>Error while packing directory at %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QInstallerCreator::Component</name>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="573"/>
+ <source>Could not open archive %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="49"/>
+ <source>Cannot open file %1 for writing: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="56"/>
+ <source>Cannot open file %1 for reading: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="65"/>
+ <source>Write failed after %1 bytes: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="84"/>
+ <source>Read failed after %1 bytes: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="237"/>
+ <source>Searched whole file, no marker found</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="239"/>
+ <source>Could not seek to %1 in file %2: %3.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="247"/>
+ <source>No marker found, stopped after %1 bytes</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="253"/>
+ <source>No marker found, unknown exception caught.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/binaryformat.cpp" line="479"/>
+ <source>Cannot create zipped file for path %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../common/installersettings.cpp" line="46"/>
+ <source>Multiple %1 elements found, but only one allowed.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="45"/>
+ <source>Could not backup file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="52"/>
+ <source>Invalid arguments: %1 arguments given, 2 expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="62"/>
+ <source>Failed to overwrite %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="82"/>
+ <source>Could not delete file %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="createshortcutoperation.cpp" line="91"/>
+ <source>Could not restore backup file into %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="72"/>
+ <source>Could not create temporary folder: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="getrepositorymetainfojob.cpp" line="80"/>
+ <source>Could not create temporary folder %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="102"/>
+ <source>Could not mmap in-binary resource. (offset=%1, length=%2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="105"/>
+ <source>Could not register in-binary resource.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="225"/>
+ <source>Could not open binary %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="231"/>
+ <source>Could not seek to binary layout section</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="250"/>
+ <source>Could not seek to metadata index</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="257"/>
+ <source>Could not seek to operation list</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="275"/>
+ <source>Could not seek to component index information</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="279"/>
+ <source>Could not seek to component index</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="606"/>
+ <source>Error</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="142"/>
+ <source>Invalid arguments: %1 arguments given, 2 or more expected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="423"/>
+ <source>Can not find the magic cookie in file %1. Are you sure this is a valid installer?</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstaller.cpp" line="450"/>
+ <source>Failed to seek in file %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallercomponent.cpp" line="210"/>
+ <source>Could not open the requested script file at %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="qinstallercomponent.cpp" line="214"/>
+ <source>Exception while loading the component script %1:%2 %3
+%4</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="registerfiletypeoperation.cpp" line="93"/>
+ <source>Register File Type: Invalid arguments</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="registerfiletypeoperation.cpp" line="154"/>
+ <source>Registering file types in only supported on Windows.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TargetDirectoryPageImpl</name>
+ <message>
+ <location filename="installer.cpp" line="324"/>
+ <source>The installation path must not contain any space.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="330"/>
+ <source>Cannot write to folder %1.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="350"/>
+ <source>Warning</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="365"/>
+ <source>The folder you selected exists already and contains an installation.
+Do you want to overwrite it?</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="installer.cpp" line="368"/>
+ <source>The folder you selected exists already.
+Do you want to overwrite it and continue?</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/installerbuilder/libinstaller/updateagent.cpp b/installerbuilder/libinstaller/updateagent.cpp
new file mode 100644
index 000000000..dad07373b
--- /dev/null
+++ b/installerbuilder/libinstaller/updateagent.cpp
@@ -0,0 +1,126 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updateagent.h"
+
+#include "updatesettings.h"
+
+#include <memory>
+
+#include <QDateTime>
+#include <QTimer>
+
+#include <KDUpdater/Application>
+
+#include "qinstaller.h"
+#include "qinstallercomponent.h"
+
+#include "common/binaryformatenginehandler.h"
+#include "common/binaryformat.h"
+
+using namespace QInstaller;
+
+class UpdateAgent::Private
+{
+public:
+ Private( UpdateAgent* qq )
+ : q( qq )
+ {
+ connect( &checkTimer, SIGNAL( timeout() ), q, SLOT( maybeCheck() ) );
+ checkTimer.start( 1000 );
+ }
+
+private:
+ UpdateAgent* const q;
+
+public:
+ void maybeCheck()
+ {
+ checkTimer.stop();
+
+ UpdateSettings settings;
+
+ try
+ {
+ if( settings.updateInterval() > 0 && settings.lastCheck().secsTo( QDateTime::currentDateTime() ) >= settings.updateInterval() )
+ {
+ std::auto_ptr< QInstallerCreator::BinaryFormatEngineHandler > handler( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
+ handler->setComponentIndex( QInstallerCreator::ComponentIndex() );
+
+ settings.setLastCheck( QDateTime::currentDateTime() );
+
+ Installer installer;
+ installer.setRemoteRepositories( settings.repositories() );
+ QList< Component* > components = installer.components();
+
+ // remove all unimportant updates
+ if( settings.checkOnlyImportantUpdates() )
+ {
+ for( int i = components.count() - 1; i >= 0; --i )
+ {
+ const Component* const comp = components[ i ];
+ if( comp->value( QLatin1String( "Important" ) ).toLower() != QLatin1String( "true" ) )
+ components.removeAt( i );
+ }
+ }
+
+ settings.setLastResult( tr( "Software Update run successfully." ) );
+
+ // no updates available
+ if( components.isEmpty() )
+ return;
+
+ emit q->updatesAvailable();
+ }
+ }
+ catch( ... )
+ {
+ settings.setLastResult( tr( "Software Update failed." ) );
+ }
+
+ checkTimer.start();
+ }
+
+ QTimer checkTimer;
+};
+
+UpdateAgent::UpdateAgent( QObject* parent )
+ : QObject( parent ),
+ d( new Private( this ) )
+{
+}
+
+UpdateAgent::~UpdateAgent()
+{
+}
+
+#include "moc_updateagent.cpp"
diff --git a/installerbuilder/libinstaller/updateagent.h b/installerbuilder/libinstaller/updateagent.h
new file mode 100644
index 000000000..34310b75d
--- /dev/null
+++ b/installerbuilder/libinstaller/updateagent.h
@@ -0,0 +1,56 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef UPDATEAGENT_H
+#define UPDATEAGENT_H
+
+#include <QtCore/QObject>
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include "installer_global.h"
+
+namespace QInstaller
+{
+
+class INSTALLER_EXPORT UpdateAgent : public QObject
+{
+ Q_OBJECT
+public:
+ explicit UpdateAgent( QObject* parent = 0 );
+ ~UpdateAgent();
+
+Q_SIGNALS:
+ void updatesAvailable();
+
+private:
+ Q_PRIVATE_SLOT( d, void maybeCheck() );
+
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/updater.cpp b/installerbuilder/libinstaller/updater.cpp
new file mode 100644
index 000000000..b4e301391
--- /dev/null
+++ b/installerbuilder/libinstaller/updater.cpp
@@ -0,0 +1,324 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updater.h"
+#include "messageboxhandler.h"
+
+#include <QDateTime>
+#include <QDomDocument>
+#include <QProgressDialog>
+#include <QSharedPointer>
+
+#include "common/binaryformat.h"
+#include "common/binaryformatenginehandler.h"
+#include "common/errors.h"
+#include "common/utils.h"
+
+#include "qinstaller.h"
+#include "qinstallercomponent.h"
+#include "qinstallercomponentmodel.h"
+#include "updatesettings.h"
+#include "init.h"
+
+#include "installationprogressdialog.h"
+#include "componentselectiondialog.h"
+
+#include <KDUpdater/Application>
+#include <KDUpdater/PackagesInfo>
+
+#include <KDToolsCore/KDAutoPointer>
+
+#include <memory>
+#include <iostream>
+
+using namespace QInstaller;
+
+class Updater::Private
+{
+public:
+ Private() : dialog( 0 ) {
+ }
+
+ Installer* installer_shared;
+ ComponentSelectionDialog * dialog;
+ QSharedPointer< QInstallerCreator::BinaryFormatEngineHandler > handler;
+ QSharedPointer< UpdateSettings > settings;
+ QList< Component* > components;
+};
+
+void Updater::init()
+{
+ //d->installer.setLinearComponentList( true );
+ d->handler = QSharedPointer< QInstallerCreator::BinaryFormatEngineHandler > ( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
+ d->settings = QSharedPointer< UpdateSettings > ( new UpdateSettings() );
+ //d->dialog = QSharedPointer< ComponentSelectionDialog >( new ComponentSelectionDialog( &d->installer ) );
+ //ComponentModel::setVirtualComponentsVisible( true );
+}
+
+Updater::Updater( QObject* parent )
+ : QObject( parent )
+{
+}
+
+void Updater::setInstaller( QInstaller::Installer * installer )
+{
+ d->installer_shared = installer;
+}
+
+//QInstaller::Installer * Updater::getInstaller()
+//{
+// return &d->installer;
+//}
+
+Updater::~Updater()
+{
+}
+
+ComponentSelectionDialog* Updater::updaterGui() const {
+ return d->dialog;
+}
+
+void Updater::setUpdaterGui( QInstaller::ComponentSelectionDialog * gui )
+{
+ if ( d->dialog )
+ disconnect( d->dialog, SIGNAL( requestUpdate() ), this, SLOT( update() ) );
+ //disconnect( d->dialog, SIGNAL( accepted() ), this, SLOT( update() ) );
+ d->dialog = gui;
+ //connect( gui, SIGNAL( accepted() ), this, SLOT( update() ) );
+ connect( gui, SIGNAL( requestUpdate() ), this, SLOT( update() ) );
+}
+
+bool Updater::searchForUpdates()
+{
+ try
+ {
+ KDAutoPointer< QProgressDialog > progress( new QProgressDialog( d->dialog ) );
+ progress->setLabelText( tr( "Checking for updates..." ) );
+ progress->setRange( 0, 0 );
+ connect (progress.get(), SIGNAL( canceled() ), d->dialog, SLOT( reject() ) );
+ progress->show();
+
+ d->settings->setLastCheck( QDateTime::currentDateTime() );
+ d->installer_shared->setRemoteRepositories( d->settings->repositories() );
+ d->installer_shared->setValue(QLatin1String("TargetDir"),
+ QFileInfo(d->installer_shared->updaterApplication().packagesInfo()->fileName())
+ .absolutePath());
+ }
+ catch( const Error& error )
+ {
+ QMessageBox::critical( d->dialog, tr( "Check for Updates" ), tr( "Error while checking for updates:\n%1" ).arg( QString::fromStdString( error.what() ) ) );
+ d->settings->setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+ catch( ... )
+ {
+ QMessageBox::critical( d->dialog, tr( "Check for Updates" ), tr( "Unknown error while checking for updates." ) );
+ d->settings->setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+
+ d->components = d->installer_shared->components( true );
+
+ // no updates for us
+ if( d->components.isEmpty() )
+ {
+ QMessageBox::information( d->dialog, tr( "Check for Updates" ), tr( "There are currently no updates available." ) );
+ return false;
+ }
+ return true;
+}
+
+bool Updater::update()
+{
+// if( d->dialog->exec() == QDialog::Rejected )
+// return false;
+
+ try
+ {
+ InstallationProgressDialog* dialog = new InstallationProgressDialog( d->dialog );
+ dialog->setAttribute( Qt::WA_DeleteOnClose, true );
+ dialog->setModal( true );
+ dialog->setFixedSize( 480, 360 );
+ dialog->show();
+ connect( dialog, SIGNAL( canceled() ), d->installer_shared, SLOT( interrupt() ) );
+ connect( d->installer_shared, SIGNAL( updateFinished() ), dialog, SLOT( finished() ) );
+ d->installer_shared->installSelectedComponents();
+ QEventLoop loop;
+ connect( dialog, SIGNAL( destroyed() ), &loop, SLOT( quit() ) );
+ loop.exec();
+ }
+ catch( const Error& error )
+ {
+ //if the user clicked the confirm cancel dialog he don't want to see another messagebox
+ if ( d->installer_shared->status() != Installer::InstallerCanceledByUser )
+ {
+ MessageBoxHandler::critical(d->dialog,
+ QLatin1String("updaterCriticalInstallError"), tr( "Check for Updates" ),
+ tr( "Error while installing updates:\n%1" ).arg( error.message() ) );
+ }
+ d->installer_shared->rollBackInstallation();
+ d->settings->setLastResult( tr( "Software Update failed." ) );
+ emit updateFinished( true );
+ return false;
+ }
+ catch( ... )
+ {
+ MessageBoxHandler::critical(d->dialog,
+ QLatin1String("updaterCriticalUnknownError"),
+ tr( "Check for Updates" ),
+ tr( "Unknown error while installing updates." ) );
+ d->installer_shared->rollBackInstallation();
+ d->settings->setLastResult( tr( "Software Update failed." ) );
+ emit updateFinished( true );
+ return false;
+ }
+ emit updateFinished( false );
+ return true;
+}
+
+bool Updater::checkForUpdates( bool checkonly )
+{
+ KDUpdater::Application updaterapp;
+ BinaryContent content = BinaryContent::readFromApplicationFile();
+ Installer installer( content.magicmaker, content.performedOperations );
+ QInstaller::init();
+ installer.setUpdaterApplication( &updaterapp );
+ installer.setPackageManager();
+ installer.setLinearComponentList( true );
+
+ std::auto_ptr< QInstallerCreator::BinaryFormatEngineHandler > handler( new QInstallerCreator::BinaryFormatEngineHandler( QInstallerCreator::ComponentIndex() ) );
+ handler->setComponentIndex( QInstallerCreator::ComponentIndex() );
+
+ UpdateSettings settings;
+ KDAutoPointer< ComponentSelectionDialog > dialog( checkonly ? 0 : new ComponentSelectionDialog( &installer ) );
+ if( !checkonly )
+ dialog->show();
+
+ ComponentModel::setVirtualComponentsVisible( true );
+
+ try
+ {
+ KDAutoPointer< QProgressDialog > progress( checkonly ? 0 : new QProgressDialog( dialog.get() ) );
+ if( !checkonly )
+ {
+ progress->setLabelText( tr( "Checking for updates..." ) );
+ progress->setRange( 0, 0 );
+ progress->show();
+ }
+
+ settings.setLastCheck( QDateTime::currentDateTime() );
+ installer.setRemoteRepositories( settings.repositories() );
+ if ( installer.status() == QInstaller::Installer::InstallerFailed )
+ return false;
+ installer.setValue( QLatin1String( "TargetDir" ), QFileInfo( updaterapp.packagesInfo()->fileName() ).absolutePath() );
+ }
+ catch( const Error& error )
+ {
+ if( !checkonly )
+ QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Error while checking for updates:\n%1" ).arg( QString::fromStdString( error.what() ) ) );
+ settings.setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+ catch( ... )
+ {
+ if( !checkonly )
+ QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Unknown error while checking for updates." ) );
+ settings.setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+
+ const QList< Component* > components = installer.components( true, UpdaterMode );
+
+ // no updates for us
+ if( components.isEmpty() && !checkonly )
+ {
+ QMessageBox::information( dialog.get(), tr( "Check for Updates" ), tr( "There are currently no updates available." ) );
+ return false;
+ }
+
+ if( checkonly )
+ {
+ QDomDocument doc;
+ QDomElement root = doc.createElement( QLatin1String( "updates" ) );
+ doc.appendChild( root );
+ for( QList< Component* >::const_iterator it = components.begin(); it != components.end(); ++it )
+ {
+ QDomElement update = doc.createElement( QLatin1String( "update" ) );
+ update.setAttribute( QLatin1String( "name" ), (*it)->value( QLatin1String( "DisplayName" ) ) );
+ update.setAttribute( QLatin1String( "version" ), (*it)->value( QLatin1String( "Version" ) ) );
+ update.setAttribute( QLatin1String( "size" ), (*it)->value( QLatin1String( "UncompressedSize" ) ) );
+ root.appendChild( update );
+ }
+ std::cout << doc.toString( 4 ).toStdString() << std::endl;
+ return true;
+ }
+
+ if( dialog->exec() == QDialog::Rejected )
+ return false;
+
+ try
+ {
+ InstallationProgressDialog* dialog = new InstallationProgressDialog();
+ dialog->setModal( true );
+ dialog->setAttribute( Qt::WA_DeleteOnClose, true );
+ dialog->setFixedSize( 480, 360 );
+ dialog->show();
+ connect( dialog, SIGNAL( canceled() ), &installer, SLOT( interrupt() ) );
+ connect( &installer, SIGNAL( installationProgressTextChanged( QString ) ), dialog, SLOT( changeInstallationProgressText( QString ) ) );
+ connect( &installer, SIGNAL( installationProgressChanged( int ) ), dialog, SLOT( changeInstallationProgress( int ) ) );
+ connect( &installer, SIGNAL( updateFinished() ), dialog, SLOT( finished() ) );
+ installer.installSelectedComponents();
+ QEventLoop loop;
+ connect( dialog, SIGNAL( destroyed() ), &loop, SLOT( quit() ) );
+ loop.exec();
+ }
+ catch( const Error& error )
+ {
+ //if the user clicked the confirm cancel dialog he don't want to see another messagebox
+ if ( installer.status() != Installer::InstallerCanceledByUser )
+ {
+ QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Error while installing updates:\n%1" ).arg( QString::fromStdString( error.what() ) ) );
+ }
+ installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+ catch( ... )
+ {
+ QMessageBox::critical( dialog.get(), tr( "Check for Updates" ), tr( "Unknown error while installing updates." ) );
+ installer.rollBackInstallation();
+ settings.setLastResult( tr( "Software Update failed." ) );
+ return false;
+ }
+
+ return true;
+}
diff --git a/installerbuilder/libinstaller/updater.h b/installerbuilder/libinstaller/updater.h
new file mode 100644
index 000000000..94076e6a0
--- /dev/null
+++ b/installerbuilder/libinstaller/updater.h
@@ -0,0 +1,64 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef UPDATER_H
+#define UPDATER_H
+
+#include "installer_global.h"
+
+#include <QtCore/QObject>
+#include <KDToolsCore/pimpl_ptr.h>
+#include <QSharedPointer>
+
+namespace QInstaller
+{
+ class ComponentSelectionDialog;
+ class Installer;
+}
+
+class INSTALLER_EXPORT Updater : public QObject
+{
+Q_OBJECT
+public:
+ explicit Updater( QObject* parent = 0 );
+ ~Updater();
+ void init();
+ QInstaller::ComponentSelectionDialog* updaterGui() const;
+ void setUpdaterGui( QInstaller::ComponentSelectionDialog * gui );
+// QInstaller::Installer* getInstaller();
+ void setInstaller( QInstaller::Installer * installer );
+ bool checkForUpdates( bool checkonly = false );
+public Q_SLOTS:
+ bool searchForUpdates();
+ bool update();
+Q_SIGNALS:
+ void updateFinished( bool error );
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+#endif
diff --git a/installerbuilder/libinstaller/updatesettings.cpp b/installerbuilder/libinstaller/updatesettings.cpp
new file mode 100644
index 000000000..a8045a471
--- /dev/null
+++ b/installerbuilder/libinstaller/updatesettings.cpp
@@ -0,0 +1,170 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updatesettings.h"
+
+#include <QDateTime>
+#include <QSettings>
+
+#include "common/errors.h"
+#include "common/installersettings.h"
+#include "common/repository.h"
+
+using namespace QInstaller;
+
+class UpdateSettings::Private
+{
+public:
+ Private( UpdateSettings* qq )
+ : q( qq )
+ {
+ }
+
+private:
+ UpdateSettings* const q;
+
+public:
+ QSettings& settings()
+ {
+ return externalSettings ? *externalSettings : internalSettings;
+ }
+
+ const QSettings& settings() const
+ {
+ return externalSettings ? *externalSettings : internalSettings;
+ }
+
+ QSettings internalSettings;
+ static QSettings* externalSettings;
+};
+
+QSettings* UpdateSettings::Private::externalSettings = 0;
+
+void UpdateSettings::setSettingsSource( QSettings* settings )
+{
+ Private::externalSettings = settings;
+}
+
+UpdateSettings::UpdateSettings()
+ : d( new Private( this ) )
+{
+ d->settings().sync();
+}
+
+UpdateSettings::~UpdateSettings()
+{
+ d->settings().sync();
+}
+
+int UpdateSettings::updateInterval() const
+{
+ return d->settings().value( QLatin1String( "updatesettings/interval" ), static_cast< int >( Weekly ) ).toInt();
+}
+
+void UpdateSettings::setUpdateInterval( int seconds )
+{
+ d->settings().setValue( QLatin1String( "updatesettings/interval" ), seconds );
+}
+
+QString UpdateSettings::lastResult() const
+{
+ return d->settings().value( QLatin1String( "updatesettings/lastresult" ) ).toString();
+}
+
+void UpdateSettings::setLastResult( const QString& lastResult )
+{
+ d->settings().setValue( QLatin1String( "updatesettings/lastresult" ), lastResult );
+}
+
+QDateTime UpdateSettings::lastCheck() const
+{
+ return d->settings().value( QLatin1String( "updatesettings/lastcheck" ) ).toDateTime();
+}
+
+void UpdateSettings::setLastCheck( const QDateTime& lastCheck )
+{
+ d->settings().setValue( QLatin1String( "updatesettings/lastcheck" ), lastCheck );
+}
+
+bool UpdateSettings::checkOnlyImportantUpdates() const
+{
+ return d->settings().value( QLatin1String( "updatesettings/onlyimportant" ), false ).toBool();
+}
+
+void UpdateSettings::setCheckOnlyImportantUpdates( bool checkOnlyImportantUpdates )
+{
+ d->settings().setValue( QLatin1String( "updatesettings/onlyimportant" ), checkOnlyImportantUpdates );
+}
+
+QList< Repository > UpdateSettings::repositories() const
+{
+ QList< Repository > result;
+
+ QSettings& settings = *(const_cast< QSettings* >( &d->settings() ) );
+
+ const int count = settings.beginReadArray( QLatin1String( "updatesettings/repositories" ) );
+ for( int i = 0; i < count; ++i )
+ {
+ Repository rep;
+ settings.setArrayIndex( i );
+ rep.setUrl( d->settings().value( QLatin1String( "url" ) ).toUrl() );
+ rep.setRequired( d->settings().value( QLatin1String( "required" ) ).toBool() );
+ result.push_back( rep );
+ }
+ settings.endArray();
+
+ if( !result.isEmpty() )
+ return result;
+
+ try
+ {
+ return InstallerSettings::fromFileAndPrefix( QLatin1String( ":/metadata/installer-config/config.xml" ), QLatin1String( ":/metadata/installer-config/" ) ).repositories();
+ }
+ catch( const Error& e )
+ {
+ qDebug( "Could not parse config: %s", qPrintable( e.message() ) );
+ }
+ return result;
+}
+
+void UpdateSettings::setRepositories( const QList< Repository >& repositories )
+{
+ d->settings().beginWriteArray( QLatin1String( "updatesettings/repositories" ) );
+ for( int i = 0; i < repositories.count(); ++i )
+ {
+ const Repository& rep = repositories[ i ];
+ d->settings().setArrayIndex( i );
+ d->settings().setValue( QLatin1String( "url" ), rep.url() );
+ d->settings().setValue( QLatin1String( "required" ), rep.required() );
+ }
+ d->settings().endArray();
+}
diff --git a/installerbuilder/libinstaller/updatesettings.h b/installerbuilder/libinstaller/updatesettings.h
new file mode 100644
index 000000000..4ba31be7f
--- /dev/null
+++ b/installerbuilder/libinstaller/updatesettings.h
@@ -0,0 +1,79 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef UPDATESETTINGS_H
+#define UPDATESETTINGS_H
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include "installer_global.h"
+
+class QDateTime;
+template< typename T >
+class QList;
+class QSettings;
+
+namespace QInstaller
+{
+class Repository;
+
+class INSTALLER_EXPORT UpdateSettings
+{
+public:
+ UpdateSettings();
+ ~UpdateSettings();
+
+ enum Interval
+ {
+ Daily = 86400,
+ Weekly = Daily * 7,
+ Monthly = Daily * 30
+ };
+
+ static void setSettingsSource( QSettings* settings );
+
+ int updateInterval() const;
+ void setUpdateInterval( int seconds );
+
+ QString lastResult() const;
+ void setLastResult( const QString& lastResult );
+
+ QDateTime lastCheck() const;
+ void setLastCheck( const QDateTime& lastCheck );
+
+ bool checkOnlyImportantUpdates() const;
+ void setCheckOnlyImportantUpdates( bool checkOnlyImportantUpdates );
+
+ QList< Repository > repositories() const;
+ void setRepositories( const QList< Repository >& repositories );
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/updatesettingsdialog.cpp b/installerbuilder/libinstaller/updatesettingsdialog.cpp
new file mode 100644
index 000000000..0c3c676cb
--- /dev/null
+++ b/installerbuilder/libinstaller/updatesettingsdialog.cpp
@@ -0,0 +1,83 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updatesettingsdialog.h"
+#include "ui_updatesettingsdialog.h"
+
+#include "common/repository.h"
+
+#include "updatesettings.h"
+
+#include <QDateTime>
+#include <QStringListModel>
+
+using namespace QInstaller;
+
+class UpdateSettingsDialog::Private
+{
+public:
+ Private( UpdateSettingsDialog* qq )
+ : q( qq )
+ {
+ ui.setupUi( q );
+ }
+
+private:
+ UpdateSettingsDialog* const q;
+
+public:
+ Ui::UpdateSettingsDialog ui;
+};
+
+UpdateSettingsDialog::UpdateSettingsDialog( QWidget* parent )
+ : QDialog( parent ),
+ d( new Private( this ) )
+{
+ connect( d->ui.buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
+ connect( d->ui.buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
+
+ connect( d->ui.widget, SIGNAL( checkForUpdates() ), this, SLOT( accept() ) );
+ connect( d->ui.widget, SIGNAL( checkForUpdates() ), this, SIGNAL( checkForUpdates() ) );
+ setFixedSize( size() );
+}
+
+UpdateSettingsDialog::~UpdateSettingsDialog()
+{
+}
+
+void UpdateSettingsDialog::accept()
+{
+ d->ui.widget->accept();
+ QDialog::accept();
+}
+
+#include "moc_updatesettingsdialog.cpp"
diff --git a/installerbuilder/libinstaller/updatesettingsdialog.h b/installerbuilder/libinstaller/updatesettingsdialog.h
new file mode 100644
index 000000000..35fe599e5
--- /dev/null
+++ b/installerbuilder/libinstaller/updatesettingsdialog.h
@@ -0,0 +1,58 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef UPDATESETTINGSDIALOG_H
+#define UPDATESETTINGSDIALOG_H
+
+#include <QtGui/QDialog>
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include "installer_global.h"
+
+namespace QInstaller
+{
+
+class INSTALLER_EXPORT UpdateSettingsDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ explicit UpdateSettingsDialog( QWidget* parent = 0 );
+ ~UpdateSettingsDialog();
+
+Q_SIGNALS:
+ void checkForUpdates();
+
+public Q_SLOTS:
+ void accept();
+
+private:
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/updatesettingsdialog.ui b/installerbuilder/libinstaller/updatesettingsdialog.ui
new file mode 100644
index 000000000..430f6c590
--- /dev/null
+++ b/installerbuilder/libinstaller/updatesettingsdialog.ui
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UpdateSettingsDialog</class>
+ <widget class="QWidget" name="UpdateSettingsDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>447</width>
+ <height>312</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Software Update Settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QInstaller::UpdateSettingsWidget" name="widget" native="true"/>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QInstaller::UpdateSettingsWidget</class>
+ <extends>QWidget</extends>
+ <header>updatesettingswidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/installerbuilder/libinstaller/updatesettingswidget.cpp b/installerbuilder/libinstaller/updatesettingswidget.cpp
new file mode 100644
index 000000000..d28a25168
--- /dev/null
+++ b/installerbuilder/libinstaller/updatesettingswidget.cpp
@@ -0,0 +1,161 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "updatesettingswidget.h"
+#include "ui_updatesettingswidget.h"
+
+#include "common/repository.h"
+
+#include "updatesettings.h"
+
+#include <QDateTime>
+#include <QStringListModel>
+
+using namespace QInstaller;
+
+class UpdateSettingsWidget::Private
+{
+public:
+ Private( UpdateSettingsWidget* qq )
+ : q( qq ),
+ initialized( false )
+ {
+ ui.setupUi( q );
+ }
+
+ void addUpdateSource()
+ {
+ const int newRow = model.rowCount();
+ if( model.insertRow( newRow ) )
+ ui.treeViewUpdateSources->edit( model.index( newRow, 0 ) );
+ }
+
+ void removeUpdateSource()
+ {
+ model.removeRow( ui.treeViewUpdateSources->currentIndex().row() );
+ }
+
+private:
+ UpdateSettingsWidget* const q;
+
+public:
+ bool initialized;
+ Ui::UpdateSettingsWidget ui;
+ UpdateSettings settings;
+ QStringListModel model;
+};
+
+UpdateSettingsWidget::UpdateSettingsWidget( QWidget* parent )
+ : QWidget( parent ),
+ d( new Private( this ) )
+{
+}
+
+UpdateSettingsWidget::~UpdateSettingsWidget()
+{
+}
+
+/*!
+ \reimpl
+*/
+void UpdateSettingsWidget::showEvent( QShowEvent* event )
+{
+ Q_UNUSED( event )
+ if( d->initialized )
+ return;
+
+ d->ui.checkBoxCheckForUpdates->setChecked( d->settings.updateInterval() > 0 );
+ d->ui.checkBoxCheckOnlyImportant->setChecked( d->settings.checkOnlyImportantUpdates() );
+ switch( qAbs( d->settings.updateInterval() ) )
+ {
+ case UpdateSettings::Daily:
+ d->ui.comboBoxFrequency->setCurrentIndex( 0 );
+ break;
+ case UpdateSettings::Weekly:
+ d->ui.comboBoxFrequency->setCurrentIndex( 1 );
+ break;
+ case UpdateSettings::Monthly:
+ d->ui.comboBoxFrequency->setCurrentIndex( 2 );
+ break;
+ }
+
+ connect( d->ui.buttonAddUpdateSource, SIGNAL( clicked() ), this, SLOT( addUpdateSource() ) );
+ connect( d->ui.buttonRemoveUpdateSource, SIGNAL( clicked() ), this, SLOT( removeUpdateSource() ) );
+
+ connect( d->ui.buttonCheckNow, SIGNAL( clicked() ), this, SIGNAL( checkForUpdates() ) );
+
+ QStringList reps;
+ const QList< Repository > repositories = d->settings.repositories();
+ for( QList< Repository >::const_iterator it = repositories.begin(); it != repositories.end(); ++it )
+ reps.push_back( it->url().toString() );
+ d->model.setStringList( reps );
+ d->ui.treeViewUpdateSources->setModel( &d->model );
+
+ d->ui.labelLastUpdateResult->clear();
+ if( d->settings.lastResult().isEmpty() )
+ d->ui.labelLastCheck->clear();
+ else
+ d->ui.labelLastUpdateResult->setText( d->settings.lastResult() + QLatin1Char( '\n' ) + d->settings.lastCheck().toString() );
+
+ d->initialized = true;
+}
+
+void UpdateSettingsWidget::accept()
+{
+ switch( d->ui.comboBoxFrequency->currentIndex() )
+ {
+ case 0:
+ d->settings.setUpdateInterval( UpdateSettings::Daily );
+ break;
+ case 1:
+ d->settings.setUpdateInterval( UpdateSettings::Weekly );
+ break;
+ case 2:
+ d->settings.setUpdateInterval( UpdateSettings::Monthly );
+ break;
+ }
+ if( !d->ui.checkBoxCheckForUpdates->isChecked() )
+ d->settings.setUpdateInterval( -d->settings.updateInterval() );
+ d->settings.setCheckOnlyImportantUpdates( d->ui.checkBoxCheckOnlyImportant->isChecked() );
+
+ const QStringList reps = d->model.stringList();
+ QList< Repository > repositories;
+ Repository rep;
+ for( QStringList::const_iterator it = reps.begin(); it != reps.end(); ++it )
+ {
+ rep.setUrl( QUrl( *it ) );
+ repositories.push_back( rep );
+ }
+ d->settings.setRepositories( repositories );
+}
+
+#include "moc_updatesettingswidget.cpp"
diff --git a/installerbuilder/libinstaller/updatesettingswidget.h b/installerbuilder/libinstaller/updatesettingswidget.h
new file mode 100644
index 000000000..7c7c125eb
--- /dev/null
+++ b/installerbuilder/libinstaller/updatesettingswidget.h
@@ -0,0 +1,64 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef UPDATESETTINGSWIDGET_H
+#define UPDATESETTINGSWIDGET_H
+
+#include <QtGui/QWidget>
+
+#include <KDToolsCore/pimpl_ptr.h>
+
+#include "installer_global.h"
+
+namespace QInstaller
+{
+
+class INSTALLER_EXPORT UpdateSettingsWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit UpdateSettingsWidget( QWidget* parent = 0 );
+ ~UpdateSettingsWidget();
+
+Q_SIGNALS:
+ void checkForUpdates();
+
+public Q_SLOTS:
+ void accept();
+
+protected:
+ void showEvent( QShowEvent* event );
+
+private:
+ Q_PRIVATE_SLOT( d, void addUpdateSource() );
+ Q_PRIVATE_SLOT( d, void removeUpdateSource() );
+
+ class Private;
+ kdtools::pimpl_ptr< Private > d;
+};
+
+}
+
+#endif
diff --git a/installerbuilder/libinstaller/updatesettingswidget.ui b/installerbuilder/libinstaller/updatesettingswidget.ui
new file mode 100644
index 000000000..49525e1b9
--- /dev/null
+++ b/installerbuilder/libinstaller/updatesettingswidget.ui
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UpdateSettingsWidget</class>
+ <widget class="QWidget" name="UpdateSettingsWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>438</width>
+ <height>247</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Software Update Settings</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <widget class="QTabWidget" name="tabWidget">
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Scheduled Check</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1" colspan="2">
+ <widget class="QCheckBox" name="checkBoxCheckForUpdates">
+ <property name="text">
+ <string>Check for updates:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QComboBox" name="comboBoxFrequency">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string>Daily</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Weekly</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Monthly</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="1">
+ <widget class="QWidget" name="widget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>8</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>8</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" colspan="2">
+ <widget class="QCheckBox" name="checkBoxCheckOnlyImportant">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Check only for important updates</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>11</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="2">
+ <widget class="QPushButton" name="buttonCheckNow">
+ <property name="text">
+ <string>Check Now</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelLastCheck">
+ <property name="text">
+ <string>Last check:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" colspan="2">
+ <widget class="QLabel" name="labelLastUpdateResult">
+ <property name="text">
+ <string>Software Update ran successfully.
+Monday, 2009 december 16 20.36</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>1</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="4">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>1</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>23</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Update Sources</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0" colspan="3">
+ <widget class="QTreeView" name="treeViewUpdateSources">
+ <property name="rootIsDecorated">
+ <bool>false</bool>
+ </property>
+ <property name="headerHidden">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QToolButton" name="buttonAddUpdateSource">
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>+</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QToolButton" name="buttonRemoveUpdateSource">
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>checkBoxCheckForUpdates</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>comboBoxFrequency</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>179</x>
+ <y>59</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>293</x>
+ <y>61</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>checkBoxCheckForUpdates</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>checkBoxCheckOnlyImportant</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>135</x>
+ <y>64</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>149</x>
+ <y>91</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/installerbuilder/operationrunner/operationrunner.cpp b/installerbuilder/operationrunner/operationrunner.cpp
new file mode 100644
index 000000000..242aa9866
--- /dev/null
+++ b/installerbuilder/operationrunner/operationrunner.cpp
@@ -0,0 +1,92 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <common/errors.h>
+#include <common/utils.h>
+#include <common/repositorygen.h>
+#include <common/installersettings.h>
+
+#include <init.h>
+#include <KDUpdater/UpdateOperation>
+#include <KDUpdater/UpdateOperationFactory>
+
+#include <QCoreApplication>
+#include <QFileInfo>
+#include <QString>
+#include <QStringList>
+
+#include <iostream>
+
+static void printUsage()
+{
+ std::cout << "Usage: " << std::endl;
+ std::cout << std::endl;
+ std::cout << "operationrunner \"Execute\" \"{0,1}\" \"C:\\Windows\\System32\\cmd.exe\" \"/A\" \"/Q\" \"/C\" \"magicmaemoscript.bat\" \"showStandardError\"" << std::endl;
+}
+
+int main(int argc, char **argv)
+{
+ try {
+ QCoreApplication app(argc, argv);
+
+ QStringList argumentList = app.arguments();
+
+ if( argumentList.count() < 2 || argumentList.contains("--help") )
+ {
+ printUsage();
+ return 1;
+ }
+ argumentList.removeFirst(); // we don't need the application name
+
+ QInstaller::init();
+
+ QInstaller::setVerbose( true );
+
+ QString operationName = argumentList.takeFirst();
+ KDUpdater::UpdateOperation* const operation = KDUpdater::UpdateOperationFactory::instance().create( operationName );
+ if (!operation) {
+ std::cerr << "Can not find the operation: " << qPrintable(operationName) << std::endl;
+ return 1;
+ }
+ operation->setArguments(argumentList);
+ bool readyPerformed = operation->performOperation();
+ if (readyPerformed) {
+ std::cout << "Operation was succesfully performed." << std::endl;
+ } else {
+ std::cerr << "There was a problem while performing the operation: " << qPrintable(operation->errorString()) << std::endl;
+ }
+ return 0;
+ } catch ( const QInstaller::Error& e ) {
+ std::cerr << qPrintable(e.message()) << std::endl;
+ }
+ return 1;
+}
diff --git a/installerbuilder/operationrunner/operationrunner.pro b/installerbuilder/operationrunner/operationrunner.pro
new file mode 100644
index 000000000..32cbd17e0
--- /dev/null
+++ b/installerbuilder/operationrunner/operationrunner.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = operationrunner
+DEPENDPATH += . .. ../common
+INCLUDEPATH += . ..
+
+DESTDIR = ../bin
+
+CONFIG += console
+CONFIG -= app_bundle
+
+QT += xml
+
+include(../libinstaller/libinstaller.pri)
+
+# Input
+SOURCES += operationrunner.cpp
+
+LIBS = -L../../installerbuilder/lib -linstaller $$LIBS
diff --git a/installerbuilder/repogen/repogen.cpp b/installerbuilder/repogen/repogen.cpp
new file mode 100644
index 000000000..79d80004a
--- /dev/null
+++ b/installerbuilder/repogen/repogen.cpp
@@ -0,0 +1,171 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include <common/errors.h>
+#include <common/fileutils.h>
+#include <common/utils.h>
+#include <common/repositorygen.h>
+#include <common/installersettings.h>
+
+#include "lib7z_facade.h"
+#include "init.h"
+
+#include <QCoreApplication>
+#include <QDir>
+#include <QFileInfo>
+#include <QString>
+#include <QStringList>
+
+#include <iostream>
+
+using namespace QInstaller;
+using namespace Lib7z;
+
+static void printUsage()
+{
+ const QString appName = QFileInfo( QCoreApplication::applicationFilePath() ).fileName();
+ std::cout << "Usage: " << appName << " packages-dir config-dir repository-dir component1 [component2 ...]" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Options:" << std::endl;
+ std::cout << " -e|--exclude p1,...,pn exclude the given packages and their dependencies from the repository" << std::endl;
+ std::cout << " -v|--verbose Verbose output" << std::endl;
+ std::cout << " --single Put only the given components (not their dependencies) into the (already existing) repository" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Example:" << std::endl;
+ std::cout << " " << appName << " ../examples/packages ../examples/config repository/ com.nokia.sdk" << std::endl;
+}
+
+static int printErrorAndUsageAndExit( const QString& err )
+{
+ std::cerr << qPrintable( err ) << std::endl << std::endl;
+ printUsage();
+ return 1;
+}
+
+static QString makeAbsolute( const QString& path ) {
+ QFileInfo fi( path );
+ if ( fi.isAbsolute() )
+ return path;
+ return QDir::current().absoluteFilePath( path );
+}
+
+static QVector<PackageInfo> filterBlacklisted( QVector< PackageInfo > packages, const QStringList& blacklist )
+{
+ for( int i = packages.size() - 1; i >= 0; --i )
+ if ( blacklist.contains( packages[i].name ) )
+ packages.remove( i );
+ return packages;
+}
+
+int main( int argc, char** argv ) {
+ try {
+ QCoreApplication app( argc, argv );
+
+ init();
+
+ QStringList args = app.arguments().mid( 1 );
+
+ QStringList excludedPackages;
+ bool replaceSingleComponent = false;
+
+ while( !args.isEmpty() && args.first().startsWith( QLatin1String( "-" ) ) )
+ {
+ if( args.first() == QLatin1String( "--verbose" ) || args.first() == QLatin1String( "-v" ) )
+ {
+ args.pop_front();
+ setVerbose( true );
+ }
+ else if( args.first() == QLatin1String( "--exclude" ) || args.first() == QLatin1String( "-e" ) )
+ {
+ args.pop_front();
+ if( args.isEmpty() || args.first().startsWith( QLatin1String( "-" ) ) )
+ return printErrorAndUsageAndExit( QObject::tr("Error: Package to exclude missing") );
+ excludedPackages = args.first().split( QLatin1Char( ',' ) );
+ args.pop_front();
+ }
+ else if( args.first() == QLatin1String( "--single" ) )
+ {
+ replaceSingleComponent = true;
+ args.pop_front();
+ }
+ else
+ {
+ printUsage();
+ return 1;
+ }
+ }
+
+ if( args.count() < 4 )
+ {
+ printUsage();
+ return 1;
+ }
+
+ const QString packageDir = makeAbsolute( args[0] );
+ const QString configDir = makeAbsolute( args[1] );
+ const QString repoDir = makeAbsolute( args[2] );
+ const QStringList components = args.mid( 3 );
+ const InstallerSettings cfg = InstallerSettings::fromFileAndPrefix( configDir + QLatin1String("/config.xml"), configDir );
+ const QString appName = cfg.applicationName();
+ const QString appVersion = cfg.applicationVersion();
+
+ if( !replaceSingleComponent && QFile::exists( repoDir ) )
+ throw QInstaller::Error( QObject::tr("Repository target folder %1 already exists!").arg( repoDir ) );
+
+ const QVector< PackageInfo > packages = filterBlacklisted( createListOfPackages( components, packageDir, !replaceSingleComponent ), excludedPackages );
+
+ QMap<QString, QString> pathToVersionMapping = buildPathToVersionMap(packages);
+
+ for( QVector< PackageInfo >::const_iterator it = packages.begin(); it != packages.end(); ++it )
+ {
+ const QFileInfo fi( repoDir, it->name );
+ if( fi.exists() )
+ removeDirectory( fi.absoluteFilePath() );
+ }
+
+ copyComponentData( packageDir, configDir, repoDir, packages );
+ const QString metaTmp = createTemporaryDirectory();
+ const TempDirDeleter tmpDeleter( metaTmp );
+ generateMetaDataDirectory( metaTmp, repoDir, packages, appName, appVersion );
+ compressMetaDirectories( configDir, metaTmp, metaTmp, pathToVersionMapping );
+
+ QFile::remove( QFileInfo( repoDir, QLatin1String( "Updates.xml" ) ).absoluteFilePath() );
+ moveDirectoryContents( metaTmp, repoDir );
+ return 0;
+ } catch ( const Lib7z::SevenZipException& e ) {
+ std::cerr << e.message() << std::endl;
+ } catch ( const QInstaller::Error& e ) {
+ std::cerr << e.message() << std::endl;
+ }
+ return 1;
+}
+
diff --git a/installerbuilder/repogen/repogen.pro b/installerbuilder/repogen/repogen.pro
new file mode 100644
index 000000000..7d656e656
--- /dev/null
+++ b/installerbuilder/repogen/repogen.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = repogen
+DEPENDPATH += . .. ../common
+INCLUDEPATH += . ..
+
+DESTDIR = ../bin
+
+CONFIG += console
+CONFIG -= app_bundle
+
+QT += xml
+
+include(../libinstaller/libinstaller.pri)
+
+# Input
+SOURCES += repogen.cpp \
+ ../common/repositorygen.cpp
+HEADERS += ../common/repositorygen.h
diff --git a/installerbuilder/tests/environmentvariable/environmentvariable.pro b/installerbuilder/tests/environmentvariable/environmentvariable.pro
new file mode 100644
index 000000000..704cf8ff6
--- /dev/null
+++ b/installerbuilder/tests/environmentvariable/environmentvariable.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+TARGET = tst_environmentvariable
+
+DESTDIR = bin
+
+CONFIG -= app_bundle
+
+QT += testlib script
+QT -= gui
+
+INCLUDEPATH += ../../libinstaller ..
+DEPENDPATH += ../../libinstaller ../../common
+
+include(../../libinstaller/libinstaller.pri)
+
+SOURCES = environmentvariabletest.cpp
+HEADERS = environmentvariabletest.h
+
+win32:LIBS += ole32.lib oleaut32.lib user32.lib
+win32:OBJECTS_DIR = .obj
diff --git a/installerbuilder/tests/environmentvariable/environmentvariabletest.cpp b/installerbuilder/tests/environmentvariable/environmentvariabletest.cpp
new file mode 100644
index 000000000..9b95f577e
--- /dev/null
+++ b/installerbuilder/tests/environmentvariable/environmentvariabletest.cpp
@@ -0,0 +1,99 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "environmentvariabletest.h"
+#include "environmentvariablesoperation.h"
+
+#include <QDir>
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QStack>
+#include <QSettings>
+
+#include <KDUpdater/Application>
+
+#include "init.h"
+
+EnvironmentVariableTest::EnvironmentVariableTest()
+{
+ QInstaller::init();
+}
+
+void EnvironmentVariableTest::testPersistentNonSystem() {
+#ifndef Q_OS_WIN
+ QSKIP("This operation only works on Windows",SkipSingle);
+#endif
+ KDUpdater::Application app;
+ QString key = QLatin1String("IFW_TestKey");
+ QString value = QLatin1String("IFW_TestValue");
+ QInstaller::EnvironmentVariableOperation op;
+ op.setArguments( QStringList() << key
+ << value
+ << QLatin1String("true")
+ << QLatin1String("false"));
+ const bool ok = op.performOperation();
+
+ QVERIFY2(ok, qPrintable(op.errorString()));
+
+ // Verify now...
+ QSettings settings("HKEY_CURRENT_USER\\Environment", QSettings::NativeFormat);
+ QVERIFY(value == settings.value(key).toString());
+
+ // Remove the setting
+ QEXPECT_FAIL("", "Undo Operation not implemented yet", Continue);
+ QVERIFY(op.undoOperation());
+
+ //QVERIFY(settings.value(key).toString().isEmpty());
+ settings.remove(key);
+}
+
+void EnvironmentVariableTest::testNonPersistentNonSystem() {
+#ifndef Q_OS_WIN
+ QSKIP("This operation only works on Windows",SkipSingle);
+#endif
+ KDUpdater::Application app;
+ QString key = QLatin1String("IFW_TestKey");
+ QString value = QLatin1String("IFW_TestValue");
+ QInstaller::EnvironmentVariableOperation op;
+ op.setArguments( QStringList() << key
+ << value
+ << QLatin1String("false")
+ << QLatin1String("false"));
+ const bool ok = op.performOperation();
+
+ QVERIFY2(ok, qPrintable(op.errorString()));
+
+ QString comp = qgetenv(qPrintable(key));
+ QCOMPARE(value, comp);
+}
+
+QTEST_MAIN(EnvironmentVariableTest)
diff --git a/installerbuilder/tests/environmentvariable/environmentvariabletest.h b/installerbuilder/tests/environmentvariable/environmentvariabletest.h
new file mode 100644
index 000000000..9028b051d
--- /dev/null
+++ b/installerbuilder/tests/environmentvariable/environmentvariabletest.h
@@ -0,0 +1,43 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef EXTRACTIONARCHIVEOPERATIONTEST_H
+#define EXTRACTIONARCHIVEOPERATIONTEST_H
+
+#include <QObject>
+
+#include <QtTest/QtTest>
+
+class EnvironmentVariableTest : public QObject {
+ Q_OBJECT
+public:
+ EnvironmentVariableTest();
+private Q_SLOTS:
+ void testPersistentNonSystem();
+ void testNonPersistentNonSystem();
+private:
+};
+
+#endif // EXTRACTARCHIVEOPERATIONTEST_H
diff --git a/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.cpp b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.cpp
new file mode 100644
index 000000000..adcaa6b9e
--- /dev/null
+++ b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.cpp
@@ -0,0 +1,162 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "extractarchiveoperationtest.h"
+#include "extractarchiveoperation.h"
+
+#include <QDir>
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QStack>
+
+#include <KDUpdater/Application>
+
+#include "init.h"
+
+ExtractArchiveOperationTest::ExtractArchiveOperationTest()
+{
+ QInstaller::init();
+}
+
+void ExtractArchiveOperationTest::init( const QString& outdir ) {
+ if ( QDir( outdir ).exists() ) {
+ QFAIL( "output directory already exists!" );
+ QVERIFY( false );
+ }
+ QDir cd( QDir::current() );
+ QVERIFY( cd.mkdir( outdir ) );
+}
+
+static bool recursiveRemove( const QString& path, QString* errorMsg ) {
+ if ( errorMsg )
+ errorMsg->clear();
+ if ( !QFileInfo( path ).exists() )
+ return true;
+ bool error = false;
+ QString msg;
+ //first, delete all non-dir files
+ QDirIterator it( path, QDirIterator::Subdirectories );
+ while ( it.hasNext() ) {
+ const QString n = it.next();
+ if ( !QFileInfo( n ).isDir() ) {
+ QFile file( n );
+ if ( !file.remove() ) {
+ error = true;
+ msg = file.errorString();
+ }
+ }
+ }
+
+ QStack<QString> dirs;
+ QDirIterator it2( path, QDirIterator::Subdirectories );
+ while ( it2.hasNext() ) {
+ const QString n = it2.next();
+ if ( !n.endsWith( QLatin1String( "/." ) ) && !n.endsWith( QLatin1String( "/.." ) ) )
+ dirs.push( n );
+ }
+ while ( !dirs.isEmpty() ) {
+ const QString n = dirs.top();
+ dirs.pop();
+ if ( !QDir( n ).rmdir( QDir::currentPath() + QLatin1String( "/" ) + n ) ) {
+ error = true;
+ msg = QObject::tr("Could not remove folder %1").arg( n );
+ qDebug() << msg;
+ }
+ }
+
+ if ( !QDir( path ).rmdir( QDir::currentPath() + QLatin1String( "/" ) + path ) ) {
+ error = true;
+ msg = QObject::tr("Could not remove folder %1: Unknown error").arg( path );
+ }
+
+ if ( errorMsg )
+ *errorMsg = msg;
+ return !error;
+}
+
+void ExtractArchiveOperationTest::cleanup( const QString& dir ) {
+ QDir d( dir );
+ QString msg;
+ const bool removed = recursiveRemove( dir, &msg );
+ if ( !removed )
+ qCritical() << msg;
+ QVERIFY( removed );
+}
+
+void ExtractArchiveOperationTest::testExtraction() {
+ const QString outdir = QLatin1String("test-extract-out" );
+ init( outdir );
+ KDUpdater::Application app;
+ QInstaller::ExtractArchiveOperation op;
+ op.setArguments( QStringList() << QLatin1String("qt-bin-test.7z") << outdir );
+ const bool ok = op.performOperation();
+ if ( !ok ) {
+ qCritical() << "Extraction failed:" << op.errorString();
+ QFAIL( "Extraction failed" );
+ }
+ cleanup( outdir );
+}
+
+void ExtractArchiveOperationTest::testExtractionErrors() {
+ const QString outdir = QLatin1String("test-extract-out" );
+ init( outdir );
+ KDUpdater::Application app;
+ QInstaller::ExtractArchiveOperation op;
+ op.setArguments( QStringList() << QLatin1String("qt-bin-test.7z") << outdir );
+ const bool ok = op.performOperation();
+ if ( !ok ) {
+ qCritical() << "Extraction failed:" << op.errorString();
+ QFAIL( "Extraction failed" );
+ }
+ cleanup( outdir );
+
+}
+
+void ExtractArchiveOperationTest::testInvalidArchive() {
+ const QString outdir = QLatin1String("test-extract-out" );
+ init( outdir );
+ KDUpdater::Application app;
+ QInstaller::ExtractArchiveOperation op;
+ op.setArguments( QStringList() << QLatin1String("test-noarchive.7z") << outdir );
+ const bool ok = op.performOperation();
+ if ( ok ) {
+ qCritical() << "ExtractArchiveOperation does not report error on extracting invalid archive";
+ QFAIL( "Extraction failed" );
+ }
+ QVERIFY( op.error() != QInstaller::ExtractArchiveOperation::NoError );
+ const QString str = op.errorString();
+ qDebug() << str;
+ QVERIFY( !str.isEmpty() );
+ cleanup( outdir );
+}
+
+QTEST_MAIN(ExtractArchiveOperationTest)
diff --git a/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.h b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.h
new file mode 100644
index 000000000..be5169426
--- /dev/null
+++ b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.h
@@ -0,0 +1,46 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef EXTRACTIONARCHIVEOPERATIONTEST_H
+#define EXTRACTIONARCHIVEOPERATIONTEST_H
+
+#include <QObject>
+
+#include <QtTest/QtTest>
+
+class ExtractArchiveOperationTest : public QObject {
+ Q_OBJECT
+public:
+ ExtractArchiveOperationTest();
+private Q_SLOTS:
+ void testExtraction();
+ void testInvalidArchive();
+ void testExtractionErrors();
+private:
+ void init( const QString& );
+ void cleanup( const QString& );
+};
+
+#endif // EXTRACTARCHIVEOPERATIONTEST_H
diff --git a/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.pro b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.pro
new file mode 100644
index 000000000..11ccc3474
--- /dev/null
+++ b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+TARGET = extractarchiveoperationtest
+
+DESTDIR = bin
+
+CONFIG -= app_bundle
+
+QT += testlib script
+QT -= gui
+
+INCLUDEPATH += ../../libinstaller ..
+DEPENDPATH += ../../libinstaller ../../common
+
+include(../../libinstaller/libinstaller.pri)
+
+SOURCES = extractarchiveoperationtest.cpp
+HEADERS = extractarchiveoperationtest.h
+
+win32:LIBS += ole32.lib oleaut32.lib user32.lib
+win32:OBJECTS_DIR = .obj
diff --git a/installerbuilder/tests/kd7zenginetest/kd7zenginetest.cpp b/installerbuilder/tests/kd7zenginetest/kd7zenginetest.cpp
new file mode 100644
index 000000000..4be28acc7
--- /dev/null
+++ b/installerbuilder/tests/kd7zenginetest/kd7zenginetest.cpp
@@ -0,0 +1,377 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "kd7zenginetest.h"
+
+#include "../common/kd7zengine.h"
+#include "../common/kd7zenginehandler.h"
+#include "kdmmappedfileiodevice.h"
+
+#include "init.h"
+#include "lib7z_facade.h"
+
+#include <QDateTime>
+#include <QDirIterator>
+#include <QString>
+#include <QStringList>
+#include <QVariant>
+
+#include <cassert>
+
+using namespace Lib7z;
+
+namespace QTest {
+ template<>
+ char* toString( const Lib7z::File& file ) {
+ QVariantList l;
+ l << "path" << file.path
+ << "mtime" << file.mtime
+ << "uncompressedSize" << file.uncompressedSize
+ << "compressedSize" << file.compressedSize
+ << "isDirectory" << file.isDirectory
+ << "permissions" << static_cast< quint32 >( file.permissions );
+ const QByteArray ba = "Lib7z::File( " + Lib7z::formatKeyValuePairs( l ) + " )";
+ return qstrdup( ba.constData() );
+ }
+}
+
+static void compareFileLists( QVector<File> v1, QVector<File> v2 ) {
+ QCOMPARE( v1.size(), v2.size() );
+ qSort( v1 );
+ qSort( v2 );
+ for ( int i = 0; i < v1.size(); ++ i )
+ QCOMPARE( v1[i], v2[i] );
+}
+
+static QDateTime makeDateTime( int y, int m, int d, int hh, int mm, int ss ) {
+ const QDate date( y, m, d );
+ const QTime time( hh, mm, ss );
+ return QDateTime( date, time );
+}
+
+static File makeFile( const QString& path, bool isDirectory, const QDateTime& mtime, quint64 compr, quint64 uncompressed) {
+ File f;
+ f.path = path;
+ f.isDirectory = isDirectory;
+ f.mtime = mtime;
+ f.compressedSize = compr;
+ f.uncompressedSize = uncompressed;
+ f.permissions = static_cast< QFile::Permissions >( -1 );
+ return f;
+}
+
+static QVector<File> waitForIndex( QIODevice* dev ) {
+ assert( dev );
+ ListArchiveJob* job = new ListArchiveJob;
+ job->setArchive( dev );
+ QEventLoop loop;
+ QObject::connect( job, SIGNAL(finished(Lib7z::Job*)), &loop, SLOT(quit()) );
+ job->start();
+ loop.exec();
+ job->deleteLater();
+ if ( job->hasError() )
+ throw SevenZipException( job->errorString() );
+ return job->index();
+}
+
+
+static void waitForExtract( QIODevice* dev, const File& item, const QString& outputDir ) {
+ assert( dev );
+ ExtractItemJob* job = new ExtractItemJob;
+ job->setArchive( dev );
+ job->setItem( item );
+ job->setTargetDirectory( outputDir );
+ QEventLoop loop;
+ QObject::connect( job, SIGNAL(finished(Lib7z::Job*)), &loop, SLOT(quit()) );
+ job->start();
+ loop.exec();
+ job->deleteLater();
+ QVERIFY2( !job->hasError(), qPrintable(job->errorString()) );
+}
+
+static void waitForExtract( QIODevice* dev, const QString& outputDir ) {
+ assert( dev );
+ ExtractItemJob* job = new ExtractItemJob;
+ job->setArchive( dev );
+ job->setTargetDirectory( outputDir );
+ QEventLoop loop;
+ QObject::connect( job, SIGNAL(finished(Lib7z::Job*)), &loop, SLOT(quit()) );
+ job->start();
+ loop.exec();
+ job->deleteLater();
+ QVERIFY2( !job->hasError(), qPrintable(job->errorString()) );
+}
+
+static File findFile( const QVector<File>& index, const QString& path ) {
+ Q_FOREACH( const File& i, index )
+ if( i.path == path )
+ return i;
+ throw SevenZipException(QObject::tr("File not found in index: %1").arg(path) );
+ return File();
+}
+
+KD7zEngineTest::KD7zEngineTest()
+{
+ QInstaller::init();
+}
+
+void KD7zEngineTest::testFileEngine()
+{
+ KD7zEngine engine( "7z://test1.7z" );
+ QCOMPARE( engine.entryList( QDir::AllEntries, QStringList() ), QStringList() << "tests-export" );
+ QCOMPARE( engine.fileTime( QAbstractFileEngine::CreationTime ), QFileInfo( "test1.7z" ).created() );
+ QVERIFY( engine.fileFlags() == ( QAbstractFileEngine::ExistsFlag | QAbstractFileEngine::DirectoryType ) );
+
+ KD7zEngine engine2( "7z://test1.7z/tests-export" );
+ QCOMPARE( engine2.entryList( QDir::AllEntries, QStringList() ), QStringList() << "tests.pro" );
+ QCOMPARE( engine2.fileTime( QAbstractFileEngine::CreationTime ), makeDateTime( 2009, 8, 4, 19, 5, 36 ) );
+ QVERIFY( engine2.fileFlags().testFlag( QAbstractFileEngine::ExistsFlag ) );
+ QVERIFY( engine2.fileFlags().testFlag( QAbstractFileEngine::DirectoryType ) );
+
+ engine2.setFileName( "7z://test1.7z/tests-export/tests.pro" );
+ QCOMPARE( engine2.fileTime( QAbstractFileEngine::CreationTime ), makeDateTime( 2009, 8, 4, 11, 0, 6 ) );
+ QVERIFY( engine2.size() == 122 );
+ QVERIFY( engine2.fileFlags().testFlag( QAbstractFileEngine::ExistsFlag ) );
+ QVERIFY( engine2.fileFlags().testFlag( QAbstractFileEngine::FileType ) );
+
+ KD7zEngineHandler handler;
+
+ QFileInfo fi( "7z://test1.7z" );
+ QVERIFY( fi.exists() );
+ QVERIFY( fi.isDir() );
+ QVERIFY( !fi.isFile() );
+
+ QFileInfo fi2( "7z://test2.7z/packages-export/qtcore/data/include" );
+ QVERIFY( fi2.exists() );
+ QVERIFY( fi2.isDir() );
+ QVERIFY( !fi2.isFile() );
+
+ QFileInfo fi3( "7z://test2.7z/packages-export/qtcore/data/include/QtCore" );
+ QVERIFY( fi3.exists() );
+ QVERIFY( fi3.isDir() );
+ QVERIFY( !fi3.isFile() );
+
+ QFileInfo fi4( "7z://test2.7z/packages-export/qtcore/data/include/QtCore/qobject.h" );
+ QVERIFY( fi4.exists() );
+ QVERIFY( !fi4.isDir() );
+ QVERIFY( fi4.isFile() );
+
+ QVector<File> expected;
+ expected << makeFile( "packages-export", true, makeDateTime( 2009, 8, 6, 12, 7, 11 ), 0, 0 );
+ expected << makeFile( "packages-export/qtcore", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected << makeFile( "packages-export/qtcore/meta", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected << makeFile( "packages-export/qtcore/meta/package.xml", false, makeDateTime( 2009, 8, 3, 14, 44, 2 ), 0, 276 );
+ expected << makeFile( "packages-export/qtcore/meta/installscript.qs", false, makeDateTime( 2009, 8, 3, 14, 44, 2 ), 0, 0 );
+ expected << makeFile( "packages-export/qtcore/data", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected << makeFile( "packages-export/qtcore/data/include", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected << makeFile( "packages-export/qtcore/data/include/QtCore", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected << makeFile( "packages-export/qtcore/data/include/QtCore/qobject.h", false, makeDateTime( 2009, 8, 3, 14, 44, 2 ), 309, 108 );
+ expected << makeFile( "packages-export/nokiasdk", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected << makeFile( "packages-export/nokiasdk/meta", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected << makeFile( "packages-export/nokiasdk/meta/package.xml", false, makeDateTime( 2009, 8, 3, 14, 44, 2 ), 0, 248 );
+
+ QDirIterator it( "7z://test2.7z", QDirIterator::Subdirectories );
+ while( it.hasNext() )
+ {
+ it.next();
+ QCOMPARE( "7z://test2.7z/" + expected.first().path, it.filePath() );
+ QCOMPARE( expected.first().mtime, it.fileInfo().lastModified() );
+ QVERIFY( expected.first().uncompressedSize == static_cast< quint32 >( it.fileInfo().size() ) );
+ QCOMPARE( expected.first().isDirectory, it.fileInfo().isDir() );
+ QCOMPARE( expected.first().isDirectory, !it.fileInfo().isFile() );
+ expected.pop_front();
+ }
+
+ QFile file( "7z://test2.7z/packages-export/qtcore/data/include/QtCore/qobject.h" );
+ QVERIFY( file.exists() );
+ QVERIFY( file.open( QIODevice::ReadOnly ) );
+ QVERIFY( file.size() == 108 );
+
+ QStringList lines;
+ lines << "#ifndef QOBJECT_H\n";
+ lines << "#define QOBJECT_H\n";
+ lines << "\n";
+ lines << "#error \"Sorry, this class is just fake...\"\n";
+ lines << "\n";
+ lines << "class QObject\n";
+ lines << "{\n";
+ lines << "};\n";
+ lines << "\n";
+ lines << "#endif\n";
+
+ int line = 0;
+ while( !file.atEnd() )
+ {
+ const QString expected = lines[ line++ ];
+ const QString actual = file.readLine();
+ QCOMPARE( actual, expected );
+ }
+
+ QTemporaryFile temp;
+ temp.open();
+ const QString tempName = temp.fileName();
+ temp.close();
+ QVERIFY( temp.remove() );
+
+ QVERIFY( file.copy( tempName ) );
+
+ QFile tempFile( tempName );
+ QVERIFY( tempFile.open( QIODevice::ReadOnly ) );
+ line = 0;
+ while( !tempFile.atEnd() )
+ {
+ const QString expected = lines[ line++ ];
+ const QString actual = tempFile.readLine();
+ QCOMPARE( actual, expected );
+ }
+
+ QVERIFY( tempFile.remove() );
+}
+
+void KD7zEngineTest::testIsSupportedArchive() {
+ KDMMappedFileIODevice in1( "test1.7z", 0, QFileInfo("test1.7z").size() );
+ KDMMappedFileIODevice in2( "test2.7z", 0, QFileInfo("test2.7z").size() );
+ KDMMappedFileIODevice in_noarchive( "test-noarchive.7z", 0, QFileInfo("test-noarchive.7z").size() );
+
+ try {
+ QVERIFY( isSupportedArchive( &in1 ) );
+ QVERIFY( isSupportedArchive( &in2 ) );
+ QVERIFY( !isSupportedArchive( &in_noarchive ) );
+ } catch ( const SevenZipException& e ) {
+ qDebug() << e.message();
+ QVERIFY( !"isSupportedArchive threw unexpected SevenZipException" );
+ } catch ( ... ) {
+ QVERIFY( !"isSupportedArchive threw unexpected unknown exception" );
+ }
+
+ const QString file( "MinGW-gcc440_1.zip" );
+ try
+ {
+ QVERIFY( isSupportedArchive( file ) );
+ }
+ catch( const SevenZipException& e )
+ {
+ qDebug() << e.message();
+ QVERIFY( !"isSupportedArchive threw unexpected SevenZipException" );
+ }
+ catch( ... )
+ {
+ QVERIFY( !"isSupportedArchive threw unexpected unknown exception" );
+ }
+}
+
+void KD7zEngineTest::testListing() {
+ QVector<File> expected1;
+ expected1 << makeFile( "tests-export", true, makeDateTime( 2009, 8, 4, 19, 5, 36 ), 0, 0 );
+ expected1 << makeFile( "tests-export/tests.pro", false, makeDateTime( 2009, 8, 4, 11, 0, 6 ), 104, 122 );
+
+ KDMMappedFileIODevice in1( "test1.7z", 0, QFileInfo("test1.7z").size() );
+ QVERIFY( isSupportedArchive( &in1 ) );
+ const QVector<File> actual1 = waitForIndex( &in1 );
+ compareFileLists( actual1, expected1 );
+
+ QVector<File> expected2;
+ expected2 << makeFile( "packages-export", true, makeDateTime( 2009, 8, 6, 12, 7, 11 ), 0, 0 );
+ expected2 << makeFile( "packages-export/nokiasdk", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected2 << makeFile( "packages-export/nokiasdk/meta", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected2 << makeFile( "packages-export/qtcore", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected2 << makeFile( "packages-export/qtcore/data", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected2 << makeFile( "packages-export/qtcore/data/include", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected2 << makeFile( "packages-export/qtcore/data/include/QtCore", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected2 << makeFile( "packages-export/qtcore/meta", true, makeDateTime( 2009, 8, 6, 10, 51, 43 ), 0, 0 );
+ expected2 << makeFile( "packages-export/qtcore/meta/installscript.qs", false, makeDateTime( 2009, 8, 3, 14, 44, 2 ), 0, 0 );
+ expected2 << makeFile( "packages-export/qtcore/data/include/QtCore/qobject.h", false, makeDateTime( 2009, 8, 3, 14, 44, 2 ), 309, 108 );
+ expected2 << makeFile( "packages-export/qtcore/meta/package.xml", false, makeDateTime( 2009, 8, 3, 14, 44, 2 ), 0, 276 );
+ expected2 << makeFile( "packages-export/nokiasdk/meta/package.xml", false, makeDateTime( 2009, 8, 3, 14, 44, 2 ), 0, 248 );
+
+ KDMMappedFileIODevice in2( "test2.7z", 0, QFileInfo("test2.7z").size() );
+ QVERIFY( isSupportedArchive( &in2 ) );
+ const QVector<File> actual2 = waitForIndex( &in2 );
+
+ compareFileLists( actual2, expected2 );
+
+ try {
+ KDMMappedFileIODevice in_noarchive( "test-noarchive.7z", 0, QFileInfo("test-noarchive.7z").size() );
+ QVERIFY( !isSupportedArchive( &in_noarchive ) );
+ const QVector<File> actual_noarchive = waitForIndex( &in_noarchive );
+ QVERIFY( !"reading an invalid archive must throw an exception, no exception thrown" );
+ } catch ( const SevenZipException& ) {
+ //all fine
+ } catch ( ... ) {
+ QVERIFY( !"reading an invalid archive throws, but not the expected SevenZipException" );
+ }
+
+ KDMMappedFileIODevice in3( "MinGW-gcc440_1.zip", 0, QFileInfo( "MinGW-gcc440_1.zip" ).size() );
+ const QVector< File > actual3 = waitForIndex( &in3 );
+ QCOMPARE( actual3.count(), 5556 );
+ QCOMPARE( actual3.first().path, QString::fromLatin1( "mingw" ) );
+ QCOMPARE( actual3.first().isDirectory, true );
+}
+
+void KD7zEngineTest::testExtract() {
+ KDMMappedFileIODevice in1( "test1.7z", 0, QFileInfo("test1.7z").size() );
+ const QVector<File> actual1 = waitForIndex( &in1 );
+ const File file = findFile( actual1, "tests-export/tests.pro" );
+ waitForExtract( &in1, file, QDir::currentPath() + "/extract-test" );
+
+ KDMMappedFileIODevice in3( "MinGW-gcc440_1.zip", 0, QFileInfo( "MinGW-gcc440_1.zip" ).size() );
+ waitForExtract( &in3, QDir::currentPath() + "/extract-test" );
+}
+
+void KD7zEngineTest::testCompress()
+{
+ QFile newArchive( "new.7z" );
+ newArchive.open( QIODevice::ReadWrite );
+ const QString dir = QDir::currentPath() + "/extract-test/tests-export";
+ qDebug() << dir;
+ createArchive( &newArchive, dir );
+ newArchive.seek( 0 );
+ QVERIFY( isSupportedArchive( &newArchive ) );
+ newArchive.close();
+
+ KD7zEngineHandler handler;
+
+ QFile file( "7z://new.7z/tests-export/tests.pro" );
+ QVERIFY( file.exists() );
+ QVERIFY( file.open( QIODevice::ReadOnly ) );
+ QVERIFY( file.size() == 122 );
+
+ newArchive.open( QIODevice::ReadOnly );
+ extractArchive( &newArchive, QDir::currentPath() + "/extract-test2" );
+
+ QFile file2( "extract-test2/tests-export/tests.pro" );
+ QVERIFY( file2.exists() );
+ QVERIFY( file2.open( QIODevice::ReadOnly ) );
+ QVERIFY( file2.size() == 122 );
+}
+
+QTEST_MAIN(KD7zEngineTest)
diff --git a/installerbuilder/tests/kd7zenginetest/kd7zenginetest.h b/installerbuilder/tests/kd7zenginetest/kd7zenginetest.h
new file mode 100644
index 000000000..29a5d8353
--- /dev/null
+++ b/installerbuilder/tests/kd7zenginetest/kd7zenginetest.h
@@ -0,0 +1,45 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#ifndef KD7ZENGINETEST_H
+#define KD7ZENGINETEST_H
+
+#include <QObject>
+
+#include <QtTest/QtTest>
+
+class KD7zEngineTest : public QObject {
+ Q_OBJECT
+public:
+ KD7zEngineTest();
+private Q_SLOTS:
+ void testIsSupportedArchive();
+ void testListing();
+ void testExtract();
+ void testCompress();
+ void testFileEngine();
+};
+
+#endif // KD7ZENGINETEST_H
diff --git a/installerbuilder/tests/kd7zenginetest/kd7zenginetest.pro b/installerbuilder/tests/kd7zenginetest/kd7zenginetest.pro
new file mode 100644
index 000000000..d6f60a92d
--- /dev/null
+++ b/installerbuilder/tests/kd7zenginetest/kd7zenginetest.pro
@@ -0,0 +1,16 @@
+TEMPLATE = app
+TARGET = kd7zenginetest
+
+DESTDIR = bin
+
+CONFIG -= app_bundle
+
+QT += testlib
+
+include(../../libinstaller/libinstaller.pri)
+
+SOURCES = kd7zenginetest.cpp
+HEADERS = kd7zenginetest.h
+
+win32:LIBS += ole32.lib oleaut32.lib user32.lib
+win32:OBJECTS_DIR = .obj
diff --git a/installerbuilder/tests/test-noarchive.7z b/installerbuilder/tests/test-noarchive.7z
new file mode 100644
index 000000000..963107aca
--- /dev/null
+++ b/installerbuilder/tests/test-noarchive.7z
@@ -0,0 +1,190 @@
+#!/bin/bash
+
+PRODUCT=SDKINSTALLER
+Product=SDKInstaller
+product=sdkinstaller
+
+VERSION=0.0.1
+
+default_prefix=/usr/local/KDAB/$Product-$VERSION
+
+hide_symbols=yes
+shared=yes
+debug=no
+release=yes
+prefix=
+unittests=no
+
+STATIC_BUILD_SUPPORTED=false
+
+function die {
+ echo "$1" 1>&2
+ exit 1
+}
+
+
+function usage {
+ [ -z "$1" ] || echo "$0: unknown option \"$1\"" 1>&2
+ echo "usage: $0 [options]" 1>&2
+ cat <<EOF 1>&2
+where options include:
+
+EOF
+if [ "$INSTALLATION_SUPPORTED" = "true" ]; then
+ cat <<EOF 1>&2
+ -prefix <path>
+ install $Product into <path>
+EOF
+fi
+cat <<EOF 1>&2
+
+ -release / -debug
+ build in debug/release mode
+EOF
+if [ "$STATIC_BUILD_SUPPORTED" = "true" ]; then
+ cat <<EOF 1>&2
+
+ -static / -shared
+ build static/shared libraries
+EOF
+fi
+cat <<EOF 1>&2
+
+ -[no-]hide-symbols (Unix only)
+ reduce the number of exported symbols
+
+ -[no-]unittests
+ enable/disable compiled-in unittests
+
+EOF
+ exit 1
+}
+
+if [ -z "$QTDIR" ] ; then
+ QTDIR="$(qmake -query QT_INSTALL_PREFIX)"
+ if [ $? -ne 0 ] ; then
+ QTDIR=
+ fi
+fi
+
+[ -z "$QTDIR" ] && die "You need QTDIR defined, or qmake in the PATH"
+
+while [ $# -ne 0 ] ; do
+ case "$1" in
+ -prefix)
+ shift
+ if [ $# -eq 0 ] ; then
+ echo "-prefix needs an argument" 2>&1
+ usage
+ fi
+ prefix="$1"
+ ;;
+ -no-hide-symbols)
+ hide_symbols=no
+ ;;
+ -hide-symbols)
+ hide_symbols=yes
+ ;;
+ -no-unittests)
+ unittests=no
+ ;;
+ -unittests)
+ unittests=yes
+ ;;
+ -shared)
+ shared=yes
+ ;;
+ -static)
+ if [ "$STATIC_BUILD_SUPPORTED" != "true" ]; then
+ echo "Static build not supported, -static option not allowed" 2>&1
+ usage
+ fi
+ shared=no
+ ;;
+ -debug)
+ debug=yes
+ release=no
+ ;;
+ -release)
+ debug=no
+ release=yes
+ ;;
+ *)
+ usage "$1"
+ ;;
+ esac
+ shift
+done
+
+find . -name debug -o -name release -o -name Makefile\* | xargs rm -rf
+
+if [ -f src/src.pro ] ; then
+ rm -rf lib bin
+fi
+
+if [ -z "$prefix" ] ; then
+ prefix="$default_prefix"
+fi
+
+echo -n > ".qmake.cache"
+(
+ echo "CONFIG += ${product}_target"
+
+# The following disabled to make debug builds work again:
+# echo '!contains($$list($$[QT_VERSION]), 4.2.*):CONFIG += debug_and_release build_all'
+# [ "$debug" = "yes" ] && echo "else:CONFIG -=release += debug"
+# [ "$release" = "yes" ] && echo "else:CONFIG -=debug += release"
+
+ if [ "$debug" = "yes" ]; then
+ echo "CONFIG -= release"
+ echo "CONFIG += debug"
+ echo "CONFIG -= debug_and_release"
+ fi
+
+ if [ "$release" = "yes" ]; then
+ echo "CONFIG += release"
+ echo "CONFIG -= debug"
+ echo "CONFIG -= debug_and_release"
+ fi
+
+ [ "$hide_symbols" = "yes" ] && echo "CONFIG += hide_symbols"
+ [ "$unittests" = "yes" ] && echo "CONFIG += unittests"
+
+ if [ "$shared" = "yes" ]; then
+ echo "CONFIG -= static"
+ echo "CONFIG -= staticlib"
+ echo "CONFIG += shared"
+ else
+ echo "CONFIG += static"
+ echo "CONFIG += staticlib"
+ echo "CONFIG -= shared"
+ fi
+
+ if [ -d "$QTDIR/include/Qt/private" ] ; then
+ echo "CONFIG += have_private_qt_headers"
+ echo "INCLUDEPATH += $QTDIR/include/Qt/private"
+ #else
+ #echo "QTDIR must point to an installation that has private headers installed."
+ #echo "Some features will not be available."
+ fi
+echo "${PRODUCT}_INSTALL_PREFIX = $prefix"
+echo "${PRODUCT}_BASE = `pwd`"
+
+) >> ".qmake.cache"
+
+cat <<EOF 1>&2
+$Product v$VERSION configuration:
+
+ Install Prefix.............: $prefix
+ (default: $default_prefix)
+ Debug......................: $debug (default: no)
+ Release....................: $release (default: yes)
+ Compiled-In Unit Tests.....: $unittests (default: no)
+ Restricted symbol export
+ (shared build only)......: $hide_symbols (default: yes)
+
+EOF
+
+$QTDIR/bin/qmake $product.pro -recursive "CONFIG+=pk7zip_library" || die "qmake failed"
+
+echo "Ok, now run make, then make install to install into $prefix"
diff --git a/installerbuilder/tests/test1.7z b/installerbuilder/tests/test1.7z
new file mode 100644
index 000000000..38a4c53ac
--- /dev/null
+++ b/installerbuilder/tests/test1.7z
Binary files differ
diff --git a/installerbuilder/tests/test2.7z b/installerbuilder/tests/test2.7z
new file mode 100644
index 000000000..99d199695
--- /dev/null
+++ b/installerbuilder/tests/test2.7z
Binary files differ
diff --git a/installerbuilder/tests/tests.pro b/installerbuilder/tests/tests.pro
new file mode 100644
index 000000000..ec57a0542
--- /dev/null
+++ b/installerbuilder/tests/tests.pro
@@ -0,0 +1,11 @@
+TEMPLATE=subdirs
+
+DESTDIR = bin
+SUBDIRS += kd7zenginetest extractarchiveoperationtest environmentvariable
+
+unix:test.commands=./bin/kd7zenginetest && ./bin/extractarchiveoperationtest
+win32:test.commands=bin\kd7zenginetest.exe && bin\extractarchiveoperationtest.exe
+
+test.target=test
+test.depends = $(TARGET)
+QMAKE_EXTRA_TARGETS += test
diff --git a/installerfw.pro b/installerfw.pro
new file mode 100644
index 000000000..7009c613f
--- /dev/null
+++ b/installerfw.pro
@@ -0,0 +1,10 @@
+TEMPLATE=subdirs
+CONFIG += ordered
+SUBDIRS += installerbuilder examples
+
+
+test.target=test
+test.commands=(cd installerbuilder && $(MAKE) test)
+test.depends = $(TARGET)
+QMAKE_EXTRA_TARGETS += test
+
diff --git a/maddehelper/maddehelper.pro b/maddehelper/maddehelper.pro
new file mode 100644
index 000000000..df9954eba
--- /dev/null
+++ b/maddehelper/maddehelper.pro
@@ -0,0 +1,12 @@
+QT += core
+
+QT -= gui
+
+TARGET = maddehelper
+CONFIG += console
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+
+SOURCES += main.cpp
diff --git a/maddehelper/main.cpp b/maddehelper/main.cpp
new file mode 100644
index 000000000..1f4ed555b
--- /dev/null
+++ b/maddehelper/main.cpp
@@ -0,0 +1,306 @@
+#include <QCoreApplication>
+#include <QProcess>
+#include <QDebug>
+#include <QDirIterator>
+#include <QDateTime>
+#include <iostream>
+
+//rebase to adress 0x20000000 results in crashing tools like perl on win7/64bit
+//which I used for testing
+bool rebaseDlls(const QString &maddeBinLocation,
+ const QString &rebaseBinaryLocation,
+ const QString &adressValue = "0x50000000",
+ const QString &dllFilter = "msys*.dll")
+{
+ QStringList dllStringList = QDir(maddeBinLocation).entryList(QStringList(dllFilter), QDir::Files, QDir::Size | QDir::Reversed);
+ QString dlls;
+ QString dllsEnd; //of an unknown issue msys-1.0.dll should be the last on my system
+ foreach (QString dll, dllStringList) {
+ dll.prepend(maddeBinLocation + "/");
+ if (dll.contains("msys-1")) {
+ dllsEnd.append(dll + " ");
+ } else {
+ dlls.append(dll + " ");
+ }
+ }
+ dlls = dlls.append(dllsEnd);
+
+ QProcess process;
+ process.setEnvironment(QStringList("EMPTY_ENVIRONMENT=true"));
+ QProcess::ProcessError initError(process.error());
+ process.setProcessChannelMode(QProcess::MergedChannels);
+ process.setNativeArguments(QString("-b %1 -o 0x10000 -v %2").arg(adressValue, dlls));
+ process.start(rebaseBinaryLocation);
+ process.waitForFinished();
+ if (process.exitCode() != 0 ||
+ initError != process.error() ||
+ process.exitStatus() == QProcess::CrashExit)
+ {
+ qWarning() << rebaseBinaryLocation + " " + process.nativeArguments();
+ qWarning() << QString("\t Adress rebasing failed! Maybe a process(bash.exe, ssh, ...) is using some of the dlls(%1).").arg(dllStringList.join(", "));
+ qWarning() << "\t Output: \n" << process.readAll();
+ if (initError != process.error()) {
+ qDebug() << QString("\tError(%1): ").arg(process.error()) << process.errorString();
+ }
+
+ if (process.exitStatus() == QProcess::CrashExit) {
+ qDebug() << "\tcrashed!!!";
+ }
+ return false;
+ }
+ qWarning() << rebaseBinaryLocation + " " + process.nativeArguments();
+ //qWarning() << "\t Output: \n" << process.readAll();
+ return true;
+}
+
+bool checkTools(const QString &maddeBinLocation, const QStringList &binaryCheckList)
+{
+ QDirIterator it( maddeBinLocation, binaryCheckList, QDir::Files );
+ while (it.hasNext()) {
+ QString processPath(it.next());
+ if (!QFileInfo(processPath).exists()) {
+ qDebug() << processPath << " is missing - so we don't need to check it";
+ continue;
+ }
+ bool testedToolState = true;
+ QProcess process;
+ process.setEnvironment(QStringList("EMPTY_ENVIRONMENT=true"));
+ QProcess::ProcessError initError(process.error());
+ process.setProcessChannelMode(QProcess::MergedChannels);
+ process.start(processPath, QStringList("--version"));
+ process.waitForFinished(1000);
+ QString processOutput = process.readAll();
+
+ //check for the unpossible load dll error
+ if (processOutput.contains("VirtualAlloc pointer is null") ||
+ processOutput.contains("Couldn't reserve space for") ||
+ process.exitStatus() == QProcess::CrashExit)
+ {
+ qWarning() << QString("found dll loading problem with(ExitCode: %1): ").arg(QString::number(process.exitCode())) << processPath;
+ qWarning() << processOutput;
+ testedToolState = false;
+ if (initError != process.error()) {
+ qWarning() << QString("\tError(%1): ").arg(process.error()) << process.errorString();
+ }
+
+ if (process.exitStatus() == QProcess::CrashExit) {
+ qWarning() << "\tcrashed!!!";
+ }
+ }
+ if ( process.state() == QProcess::Running )
+ process.terminate();
+ //again wait some time
+ if ( !process.waitForFinished( 1000 ) ) {
+ process.kill();
+ process.waitForFinished( 1000 ); //some more waittime
+ }
+ if (testedToolState == false) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool removeDirectory( const QString& path )
+{
+ if ( !QFileInfo(path).exists() )
+ return true;
+ if ( path.isEmpty() ) // QDir( "" ) points to the working directory! We never want to remove that one.
+ return true;
+
+ QDirIterator it(path, QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden | QDir::System);
+ while ( it.hasNext() )
+ {
+ it.next();
+ const QFileInfo currentFileInfo = it.fileInfo();
+
+ if ( currentFileInfo.isDir() && !currentFileInfo.isSymLink() )
+ {
+ removeDirectory( currentFileInfo.filePath() );
+ }
+ else
+ {
+ QFile f( currentFileInfo.filePath() );
+ if( !f.remove() )
+ qWarning() << "Can't remove: " << currentFileInfo.absoluteFilePath();
+ }
+ }
+
+ if ( !QDir().rmdir(path))
+ return QDir().rename(path, path + "_" + QDateTime::currentDateTime().toString());
+ return true;
+}
+
+bool cleanUpSubDirectories(const QString &maddeLocation, const QStringList &subDirectoryList, const QStringList &extraFiles)
+{
+ if (maddeLocation.isEmpty()) {
+ qWarning() << "Remove nothing could be result in a broken system ;)";
+ return false;
+ }
+ if (!QFileInfo(maddeLocation).exists()) {
+ qWarning() << QString("Ups, location '%1' is not existing.").arg(maddeLocation);
+ return false;
+ }
+
+ foreach (const QString &subDirectory, subDirectoryList) {
+ bool removed = removeDirectory(maddeLocation + "/" + subDirectory);
+ if (!removed) {
+ qWarning() << "Can't remove " << subDirectory <<" for a clean up step";
+ return false;
+ }
+ }
+ foreach (const QString &fileName, extraFiles) {
+ QFile file(fileName);
+ if (file.exists()) {
+ bool removed = QFile(fileName).remove();
+ if (!removed) {
+ qWarning() << "Can't remove " << extraFiles <<" for a clean up step";
+ }
+ }
+ }
+
+ return true;
+}
+
+bool runInstall(const QString &postinstallCommand, const QString &checkFileForAnOkInstallation)
+{
+ QProcess process;
+ process.setEnvironment(QStringList("EMPTY_ENVIRONMENT=true"));
+ QProcess::ProcessError initError(process.error());
+ process.setProcessChannelMode(QProcess::ForwardedChannels);
+ process.setNativeArguments(postinstallCommand);
+ process.start(QString(), QStringList());
+
+ process.waitForFinished(-1);
+ if (process.exitCode() != 0 ||
+ initError != process.error() ||
+ process.exitStatus() == QProcess::CrashExit)
+ {
+ qWarning() << QString("runInstall(ExitCode: %1) went wrong \n'%2'").arg(QString::number(process.exitCode()), postinstallCommand);
+ if (initError != process.error()) {
+ qDebug() << QString("\tError(%1): ").arg(process.error()) << process.errorString();
+ }
+
+ if (process.exitStatus() == QProcess::CrashExit) {
+ qDebug() << "\tcrashed!!!";
+ }
+ }
+ if ( process.state() == QProcess::Running )
+ process.terminate();
+ //again wait some time
+ if ( !process.waitForFinished( 1000 ) )
+ process.kill();
+
+ return QFileInfo(checkFileForAnOkInstallation).exists();
+}
+
+
+static void printUsage()
+{
+ const QString appName = QFileInfo( QCoreApplication::applicationFilePath() ).fileName();
+ std::cout << "Usage: " << qPrintable(appName) << " -r <rebase_binary> -m <MADDE_directory>" << std::endl;
+ std::cout << "Example:" << std::endl;
+ std::cout << " " << qPrintable(appName) << " -r D:/msysgit_rebase.exe -m D:/Maemo/4.6.2" << std::endl;
+}
+
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+
+ if ( app.arguments().count() != 5 ) //5. is app name
+ {
+ printUsage();
+ return 6;
+ }
+
+ QString rebaseBinaryLocation;
+ QString maddeLocation;
+ for ( int i = 1; i < app.arguments().size(); ++i ) {
+ if ( app.arguments().at( i ) == QLatin1String( "" ) )
+ continue;
+ if (app.arguments().at(i) == "-r") {
+ i++;
+ rebaseBinaryLocation = app.arguments().at(i);
+ }
+ if (app.arguments().at(i) == "-m") {
+ i++;
+ maddeLocation = app.arguments().at(i);
+ }
+ }
+ if (!QFileInfo(maddeLocation).isDir()) {
+ qDebug() << "MADDE location is not existing.";
+ return 4;
+ }
+ if (!QFileInfo(maddeLocation + "/bin").isDir()) {
+ qDebug() << "It seems that the madde location don't have a 'bin'' directory.";
+ return 5;
+ }
+ QString maddeBinLocation = maddeLocation + "/bin";
+
+ //from qs
+// var envExecutable = installer.value("TargetDir") + "/" + winMaddeSubPath + "/bin/env.exe";
+// var postShell = installer.value("TargetDir") + "/" + winMaddeSubPath + "/postinstall/postinstall.sh";
+// component.addOperation("Execute", "{0,1}", envExecutable, "-i" , "/bin/sh", "--login", postShell, "--nosleepontrap", "showStandardError");
+
+ QString postinstallShell = maddeLocation + "/postinstall/postinstall.sh";
+ //"--nosleepontrap" is not used in our Madde, but later maybe it is there again
+ QString postinstallCommand = maddeBinLocation + QString("/env.exe -i /bin/sh --login %1").arg(postinstallShell + " --nosleepontrap");
+ QString successFileCheck = maddeLocation + "/madbin/mad.cmd";
+ QString directoriesForCleanUpArgument = "sysroots, toolchains, targets, runtimes, wbin";
+ directoriesForCleanUpArgument.remove(" ");
+ QStringList directoriesForCleanUp(directoriesForCleanUpArgument.split(","));
+
+ //this was used for testings
+ //cleanUpSubDirectories(maddeLocation, directoriesForCleanUp, QStringList(successFileCheck));
+
+ bool installationWentFine = runInstall(postinstallCommand, successFileCheck);
+
+ if (installationWentFine)
+ return 0;
+
+
+ QString binaryCheckArgument = ("a2p.exe, basename.exe, bash.exe, bzip2.exe, cat.exe, chmod.exe, cmp.exe, comm.exe, cp.exe, cut.exe, " \
+ "date.exe, diff.exe, diff3.exe, dirname.exe, du.exe, env.exe, expr.exe, find.exe, fold.exe, gawk.exe, " \
+ "grep.exe, gzip.exe, head.exe, id.exe, install.exe, join.exe, less.exe, ln.exe, ls.exe, lzma.exe, m4.exe, " \
+ "make.exe, md5sum.exe, mkdir.exe, mv.exe, od.exe, paste.exe, patch.exe, perl.exe, perl5.6.1.exe, ps.exe, " \
+ "rm.exe, rmdir.exe, sed.exe, sh.exe, sleep.exe, sort.exe, split.exe, ssh-agent.exe, ssh-keygen.exe, " \
+ "stty.exe, tail.exe, tar.exe, tee.exe, touch.exe, tr.exe, true.exe, uname.exe, uniq.exe, vim.exe, wc.exe, xargs.exe");
+ binaryCheckArgument.remove(" ");
+ QStringList binaryCheckList(binaryCheckArgument.split(","));
+
+ QStringList possibleRebaseAdresses;
+ possibleRebaseAdresses << "0x5200000"; //this uses perl
+ possibleRebaseAdresses << "0x30000000";
+ possibleRebaseAdresses << "0x35000000";
+ possibleRebaseAdresses << "0x40000000";
+ possibleRebaseAdresses << "0x60000000";
+ possibleRebaseAdresses << "0x60800000";
+ possibleRebaseAdresses << "0x68000000"; //this uses git
+
+ foreach (const QString &newAdress, possibleRebaseAdresses) {
+ bool rebased = rebaseDlls(maddeBinLocation, rebaseBinaryLocation, newAdress);
+ if (!rebased) {
+ //rebasing is not working
+ return 2;
+ }
+ bool reseted = cleanUpSubDirectories(maddeLocation, directoriesForCleanUp, QStringList(successFileCheck));
+ if (!reseted) {
+ //Madde couldn't reseted to the starting position
+ return 3;
+ }
+ if (!checkTools(maddeBinLocation, binaryCheckList)) {
+ //we need another adress
+ continue;
+ }
+ bool installationWentFine = runInstall(postinstallCommand, successFileCheck);
+
+ if (installationWentFine) {
+ qDebug() << "Rebasing dlls to " << newAdress <<" helped to install MADDE";
+ return 0;
+ }
+ }
+
+ //means rebasing was not helping
+ return 1;
+}
diff --git a/repogenfromonlinerepo/downloadmanager.cpp b/repogenfromonlinerepo/downloadmanager.cpp
new file mode 100644
index 000000000..61bf7ea88
--- /dev/null
+++ b/repogenfromonlinerepo/downloadmanager.cpp
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "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 COPYRIGHT
+** OWNER OR CONTRIBUTORS 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."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "downloadmanager.h"
+
+#include <QFileInfo>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QString>
+#include <QStringList>
+#include <QTimer>
+#include <stdio.h>
+
+DownloadManager::DownloadManager(QObject *parent)
+ : QObject(parent), downloadedCount(0), totalCount(0)
+{
+}
+
+void DownloadManager::append(const QStringList &urlList)
+{
+ foreach (QString url, urlList)
+ append(QUrl::fromEncoded(url.toLocal8Bit()));
+
+ if (downloadQueue.isEmpty())
+ QTimer::singleShot(0, this, SIGNAL(finished()));
+}
+
+void DownloadManager::append(const QUrl &url)
+{
+ if (downloadQueue.isEmpty())
+ QTimer::singleShot(0, this, SLOT(startNextDownload()));
+
+ downloadQueue.enqueue(url);
+ ++totalCount;
+}
+
+QString DownloadManager::saveFileName(const QUrl &url)
+{
+ QString path = url.path();
+ QString basename = QFileInfo(path).fileName();
+
+ if (basename.isEmpty())
+ basename = "download";
+
+ if (QFile::exists(basename)) {
+ // already exists, rename the old one
+ int i = 0;
+ while (QFile::exists(basename + ".old_" + QString::number(i)))
+ ++i;
+
+ QFile::rename(basename, basename + ".old_" + QString::number(i));
+ //basename += QString::number(i);
+ }
+
+ return basename;
+}
+
+void DownloadManager::startNextDownload()
+{
+ if (downloadQueue.isEmpty()) {
+ printf("%d/%d files downloaded successfully\n", downloadedCount, totalCount);
+ emit finished();
+ return;
+ }
+
+ QUrl url = downloadQueue.dequeue();
+
+ QString filename = saveFileName(url);
+ output.setFileName(filename);
+ if (!output.open(QIODevice::WriteOnly)) {
+ fprintf(stderr, "Problem opening save file '%s' for download '%s': %s\n",
+ qPrintable(filename), url.toEncoded().constData(),
+ qPrintable(output.errorString()));
+
+ startNextDownload();
+ return; // skip this download
+ }
+
+ QNetworkRequest request(url);
+ currentDownload = manager.get(request);
+ connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)),
+ SLOT(downloadProgress(qint64,qint64)));
+ connect(currentDownload, SIGNAL(finished()),
+ SLOT(downloadFinished()));
+ connect(currentDownload, SIGNAL(readyRead()),
+ SLOT(downloadReadyRead()));
+
+ // prepare the output
+ printf("Downloading %s...\n", url.toEncoded().constData());
+ downloadTime.start();
+}
+
+void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
+{
+ progressBar.setStatus(bytesReceived, bytesTotal);
+
+ // calculate the download speed
+ double speed = bytesReceived * 1000.0 / downloadTime.elapsed();
+ QString unit;
+ if (speed < 1024) {
+ unit = "bytes/sec";
+ } else if (speed < 1024*1024) {
+ speed /= 1024;
+ unit = "kB/s";
+ } else {
+ speed /= 1024*1024;
+ unit = "MB/s";
+ }
+
+ progressBar.setMessage(QString::fromLatin1("%1 %2")
+ .arg(speed, 3, 'f', 1).arg(unit));
+ progressBar.update();
+}
+
+void DownloadManager::downloadFinished()
+{
+ progressBar.clear();
+ output.close();
+
+ if (currentDownload->error()) {
+ // download failed
+ fprintf(stderr, "Failed: %s\n", qPrintable(currentDownload->errorString()));
+ } else {
+ printf("Succeeded.\n");
+ ++downloadedCount;
+ }
+
+ currentDownload->deleteLater();
+ startNextDownload();
+}
+
+void DownloadManager::downloadReadyRead()
+{
+ output.write(currentDownload->readAll());
+}
diff --git a/repogenfromonlinerepo/downloadmanager.h b/repogenfromonlinerepo/downloadmanager.h
new file mode 100644
index 000000000..d6d1abd70
--- /dev/null
+++ b/repogenfromonlinerepo/downloadmanager.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "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 COPYRIGHT
+** OWNER OR CONTRIBUTORS 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."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DOWNLOADMANAGER_H
+#define DOWNLOADMANAGER_H
+
+#include <QFile>
+#include <QObject>
+#include <QQueue>
+#include <QTime>
+#include <QUrl>
+#include <QNetworkAccessManager>
+
+#include "textprogressbar.h"
+
+class DownloadManager: public QObject
+{
+ Q_OBJECT
+public:
+ DownloadManager(QObject *parent = 0);
+
+ void append(const QUrl &url);
+ void append(const QStringList &urlList);
+ QString saveFileName(const QUrl &url);
+
+signals:
+ void finished();
+
+private slots:
+ void startNextDownload();
+ void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
+ void downloadFinished();
+ void downloadReadyRead();
+
+private:
+ QNetworkAccessManager manager;
+ QQueue<QUrl> downloadQueue;
+ QNetworkReply *currentDownload;
+ QFile output;
+ QTime downloadTime;
+ TextProgressBar progressBar;
+
+ int downloadedCount;
+ int totalCount;
+};
+
+#endif
diff --git a/repogenfromonlinerepo/main.cpp b/repogenfromonlinerepo/main.cpp
new file mode 100644
index 000000000..b6a0db0c7
--- /dev/null
+++ b/repogenfromonlinerepo/main.cpp
@@ -0,0 +1,306 @@
+/**************************************************************************
+**
+** This file is part of Qt SDK**
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+**
+** Contact: Nokia Corporation qt-info@nokia.com**
+**
+** No Commercial Usage
+**
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception version
+** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you are unsure which license is appropriate for your use, please contact
+** (qt-info@nokia.com).
+**
+**************************************************************************/
+#include "downloadmanager.h"
+
+#include <QtCore/QCoreApplication>
+#include <QFile>
+#include <QString>
+#include <QDomDocument>
+#include <QDomElement>
+#include <QDomNodeList>
+#include <QStringList>
+#include <QDebug>
+#include <QFileInfo>
+#include <QDir>
+#include <iostream>
+
+static void printUsage()
+{
+ const QString appName = QFileInfo( QCoreApplication::applicationFilePath() ).fileName();
+ std::cout << "Usage: " << qPrintable(appName) << "--url <repository_url>" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Example:" << std::endl;
+ std::cout << " " << qPrintable(appName) << " someDirectory foobar.7z" << std::endl;
+}
+
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+
+ QString repoUrl = "http://www.forum.nokia.com/nokiaqtsdkrepository/oppdatering/windows/online_ndk_repo";
+
+ QStringList args = app.arguments();
+ for( QStringList::const_iterator it = args.constBegin(); it != args.constEnd(); ++it )
+ {
+ if( *it == QString::fromLatin1( "-h" ) || *it == QString::fromLatin1( "--help" ) )
+ {
+ printUsage();
+ return 0;
+ }
+ else if( *it == QString::fromLatin1( "-u" ) || *it == QString::fromLatin1( "--url" ) )
+ {
+ ++it;
+ if( it == args.end() ) {
+// printUsage();
+// return -1;
+ } else {
+ repoUrl = *it;
+ }
+ }
+ }
+
+ QEventLoop downloadEventLoop;
+
+ DownloadManager downloadManager;
+
+// get Updates.xml to get to know what we can download
+ downloadManager.append(QUrl(repoUrl + "/Updates.xml"));
+ QObject::connect( &downloadManager, SIGNAL( finished() ), &downloadEventLoop, SLOT( quit() ) );
+ downloadEventLoop.exec();
+// END - get Updates.xml to get to know what we can download
+
+ QFile batchFile("download.bat");
+ if (!batchFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ qDebug() << "can not open " << QFileInfo(batchFile).absoluteFilePath();
+ return app.exec();
+ }
+
+ QTextStream batchFileOut(&batchFile);
+
+ const QString updatesXmlPath = "Updates.xml";
+
+ Q_ASSERT( !updatesXmlPath.isEmpty() );
+ Q_ASSERT( QFile::exists( updatesXmlPath ) );
+
+ QFile updatesFile( updatesXmlPath );
+ if ( !updatesFile.open( QIODevice::ReadOnly ) ) {
+ //qDebug() << QString( "Could not open Updates.xml for reading: %1").arg( updatesFile.errorString() ) ;
+ return app.exec();
+ }
+
+ QDomDocument doc;
+ QString err;
+ int line = 0;
+ int col = 0;
+ if ( !doc.setContent( &updatesFile, &err, &line, &col ) ) {
+ //qDebug() << QString( "Could not parse component index: %1:%2: %3").arg( QString::number( line ), QString::number( col ), err );
+ return app.exec();
+ }
+
+ const QDomElement root = doc.documentElement();
+ const QDomNodeList children = root.childNodes();
+ for ( int i = 0; i < children.count(); ++i ) {
+ //qDebug() << children.count();
+ QString packageName;
+ QString packageDisplayName;
+ QString packageDescription;
+ QString packageUpdateText;
+ QString packageVersion;
+ QString packageReleaseDate;
+ QString packageHash;
+ QString packageUserinterfacesAsString;
+ QString packageInstallPriority;
+ QString packageScript;
+ QString packageDependencies;
+ QString packageForcedInstallation;
+ bool packageIsVirtual = false;
+ QString sevenZString;
+ const QDomElement el = children.at( i ).toElement();
+ if ( el.isNull() )
+ continue;
+ if ( el.tagName() == QString("PackageUpdate") ) {
+ const QDomNodeList c2 = el.childNodes();
+
+ for ( int j = 0; j < c2.count(); ++j ) {
+ if ( c2.at( j ).toElement().tagName() == QString("Name") )
+ packageName = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("DisplayName") )
+ packageDisplayName = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("Description") )
+ packageDescription = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("UpdateText") )
+ packageUpdateText = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("Version") )
+ packageVersion = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("ReleaseDate") )
+ packageReleaseDate = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("SHA1") )
+ packageHash = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("UserInterfaces") )
+ packageUserinterfacesAsString = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("Script") )
+ packageScript = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("Dependencies") )
+ packageDependencies = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("ForcedInstallation") )
+ packageForcedInstallation = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("InstallPriority") )
+ packageInstallPriority = c2.at( j ).toElement().text();
+ else if ( c2.at( j ).toElement().tagName() == QString("Virtual") && c2.at( j ).toElement().text() == "true")
+ packageIsVirtual = true;
+ }
+ }
+ if (packageName.isEmpty()) {
+ continue;
+ }
+
+ if ( !packageScript.isEmpty() ) {
+ // get Updates.xml to get to know what we can download
+ downloadManager.append(QUrl(repoUrl + "/" + packageName + "/" + packageScript));
+ QObject::connect( &downloadManager, SIGNAL( finished() ), &downloadEventLoop, SLOT( quit() ) );
+ downloadEventLoop.exec();
+ // END - get Updates.xml to get to know what we can download
+
+ QString localScriptFileName = packageScript;
+ Q_ASSERT( QFile::exists( localScriptFileName ) );
+
+ QFile file(localScriptFileName);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ //qDebug() << localScriptFileName << " was not readable";
+ continue;
+ }
+
+ QTextStream in(&file);
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ if(line.contains(".7z")) {
+ int firstPosition = line.indexOf("\"");
+ QString subString = line.right(line.count() - firstPosition - 1); //-1 means "
+ //qDebug() << subString;
+ int secondPosition = subString.indexOf("\"");
+ sevenZString = subString.left(secondPosition);
+ //qDebug() << sevenZString;
+ break;
+ }
+ }
+ file.remove();
+ }
+ QStringList packageUserinterfaces = packageUserinterfacesAsString.split(",");
+ packageUserinterfaces.removeAll(QString());
+ packageUserinterfaces.removeAll("");
+
+ QStringList fileList;
+
+ //fileList << packageVersion + sevenZString;
+ foreach(const QString file, packageUserinterfaces) {
+ if(!file.isEmpty()) {
+ fileList << file;
+ }/* else {
+ qDebug() << "There is something wrong with the userinterface string list.";
+ return a.exec();
+ }*/
+ }
+ if(!packageScript.isEmpty()) {
+ fileList << packageScript;
+ }
+
+ QFile packagesXml( QString( QCoreApplication::applicationDirPath() + "/" + packageName + ".xml" ));
+ packagesXml.open( QIODevice::WriteOnly );
+ QTextStream packageAsXmlStream( &packagesXml );
+ packageAsXmlStream << QString( "<?xml version=\"1.0\"?>" ) << endl;
+ packageAsXmlStream << QString( "<Package>" ) << endl;
+ packageAsXmlStream << QString( " <DisplayName>%1</DisplayName>" ).arg(packageDisplayName) << endl;
+
+ if (!packageDescription.isEmpty()) {
+ packageAsXmlStream << QString( " <Description>%1</Description>" ).arg(packageDescription) << endl;
+ }
+
+ if (!packageUpdateText.isEmpty()) {
+ packageAsXmlStream << QString( " <UpdateText>%1</UpdateText>" ).arg(packageUpdateText) << endl;
+ }
+
+ if (!packageVersion.isEmpty()) {
+ packageAsXmlStream << QString( " <Version>%1</Version>" ).arg(packageVersion) << endl;
+ }
+
+ if (!packageReleaseDate.isEmpty()) {
+ packageAsXmlStream << QString( " <ReleaseDate>%1</ReleaseDate>" ).arg(packageReleaseDate) << endl;
+ }
+ packageAsXmlStream << QString( " <Name>%1</Name>" ).arg(packageName) << endl;
+
+ if (!packageScript.isEmpty()) {
+ packageAsXmlStream << QString( " <Script>%1</Script>" ).arg(packageScript) << endl;
+ }
+
+ if (packageIsVirtual) {
+ packageAsXmlStream << QString( " <Virtual>true</Virtual>" ) << endl;
+ }
+
+ if (!packageInstallPriority.isEmpty())
+ packageAsXmlStream << QString( " <InstallPriority>%1</InstallPriority>" ).arg(packageInstallPriority) << endl;
+
+ if (!packageDependencies.isEmpty())
+ packageAsXmlStream << QString( " <Dependencies>%1</Dependencies>" ).arg(packageDependencies) << endl;
+
+ if (!packageForcedInstallation.isEmpty())
+ packageAsXmlStream << QString( " <ForcedInstallation>%1</ForcedInstallation>" ).arg(packageForcedInstallation) << endl;
+
+ if (!packageUserinterfaces.isEmpty()) {
+ packageAsXmlStream << QString( " <UserInterfaces>" ) << endl;
+ foreach(const QString userInterfaceFile, packageUserinterfaces) {
+ packageAsXmlStream << QString( " <UserInterface>%1</UserInterface>" ).arg(userInterfaceFile) << endl;
+ }
+ packageAsXmlStream << QString( " </UserInterfaces>" ) << endl;
+ }
+ packageAsXmlStream << QString( "</Package>" ) << endl;
+
+ batchFileOut << "rem download line BEGIN =============================================\n";
+
+ batchFileOut << "mkdir " << packageName << "\\meta\n";
+ batchFileOut << "move " << QDir::toNativeSeparators(QFileInfo(packagesXml).absoluteFilePath()) << " " << packageName << "\\meta\\package.xml\n";
+ if (!sevenZString.isEmpty()) {
+ batchFileOut << "mkdir " << packageName << "\\data\n";
+ batchFileOut << "cd " << packageName << "\\data\n";
+ batchFileOut << "wget " << repoUrl << "/" << packageName << "/" << QString(packageVersion + sevenZString) << " -O " << sevenZString << "\n";
+ batchFileOut << "cd ..\\..\n";
+ }
+ batchFileOut << "cd " << packageName << "\\meta\n";
+ foreach(const QString file, fileList) {
+ batchFileOut << "wget " << repoUrl << "/" << packageName << "/" << file << "\n";
+ }
+ batchFileOut << "cd ..\\..\n";
+
+ batchFileOut << "rem download line END =============================================\n";
+ } //for ( int i = 0; i < children.count(); ++i ) {
+
+ if ( children.count() == 0 ) {
+ qDebug() << "no packages found";
+ return app.exec();
+ } else {
+ qDebug() << "found packages and wrote batch file";
+ }
+
+
+ return 0;
+}
diff --git a/repogenfromonlinerepo/repogenfromonlinerepo.pro b/repogenfromonlinerepo/repogenfromonlinerepo.pro
new file mode 100644
index 000000000..63bb503a4
--- /dev/null
+++ b/repogenfromonlinerepo/repogenfromonlinerepo.pro
@@ -0,0 +1,16 @@
+QT += core network xml
+
+QT -= gui
+
+TARGET = repogenfromonlinerepo
+CONFIG += console
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+
+SOURCES += main.cpp
+HEADERS += downloadmanager.h
+SOURCES += downloadmanager.cpp
+HEADERS += textprogressbar.h
+SOURCES += textprogressbar.cpp
diff --git a/repogenfromonlinerepo/textprogressbar.cpp b/repogenfromonlinerepo/textprogressbar.cpp
new file mode 100644
index 000000000..ceba0922b
--- /dev/null
+++ b/repogenfromonlinerepo/textprogressbar.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "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 COPYRIGHT
+** OWNER OR CONTRIBUTORS 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."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textprogressbar.h"
+#include <QByteArray>
+#include <stdio.h>
+
+TextProgressBar::TextProgressBar()
+ : value(0), maximum(-1), iteration(0)
+{
+}
+
+void TextProgressBar::clear()
+{
+ printf("\n");
+ fflush(stdout);
+
+ iteration = 0;
+ value = 0;
+ maximum = -1;
+}
+
+void TextProgressBar::update()
+{
+ ++iteration;
+
+ if (maximum > 0) {
+ // we know the maximum
+ // draw a progress bar
+ int percent = value * 100 / maximum;
+ int hashes = percent / 2;
+
+ QByteArray progressbar(hashes, '#');
+ if (percent % 2)
+ progressbar += '>';
+
+ printf("\r[%-50s] %3d%% %s ",
+ progressbar.constData(),
+ percent,
+ qPrintable(message));
+ } else {
+ // we don't know the maximum, so we can't draw a progress bar
+ int center = (iteration % 48) + 1; // 50 spaces, minus 2
+ QByteArray before(qMax(center - 2, 0), ' ');
+ QByteArray after(qMin(center + 2, 50), ' ');
+
+ printf("\r[%s###%s] %s ",
+ before.constData(), after.constData(), qPrintable(message));
+ }
+}
+
+void TextProgressBar::setMessage(const QString &m)
+{
+ message = m;
+}
+
+void TextProgressBar::setStatus(qint64 val, qint64 max)
+{
+ value = val;
+ maximum = max;
+}
diff --git a/repogenfromonlinerepo/textprogressbar.h b/repogenfromonlinerepo/textprogressbar.h
new file mode 100644
index 000000000..91ea04dd1
--- /dev/null
+++ b/repogenfromonlinerepo/textprogressbar.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "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 COPYRIGHT
+** OWNER OR CONTRIBUTORS 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."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEXTPROGRESSBAR_H
+#define TEXTPROGRESSBAR_H
+
+#include <QString>
+
+class TextProgressBar
+{
+public:
+ TextProgressBar();
+
+ void clear();
+ void update();
+ void setMessage(const QString &message);
+ void setStatus(qint64 value, qint64 maximum);
+
+private:
+ QString message;
+ qint64 value;
+ qint64 maximum;
+ int iteration;
+};
+
+#endif
diff --git a/test-framework/README b/test-framework/README
new file mode 100644
index 000000000..caa0c00a9
--- /dev/null
+++ b/test-framework/README
@@ -0,0 +1,312 @@
+= Testing Framework =
+
+== Overview ==
+
+The "testing framework" was developed to continuously run automated, non-interactive tests for the Nokia NDK installers on a set of test systems.
+It uses remote-controlled VMWare virtual machines (VMs) to execute the tests on. Both the actual controlling process and the post installation checks on the VMs are implemented in Python.
+Additionally, a set of test cases is created and configured.
+A test case consists of a) a QtScript script specifying the user input for non-interactive installation and b) post-installation checks to perform after installation. This way various user behaviour can be tested (e.g. different component selections) and whether installation succeeds and certain post-conditions are met (e.g. files end up in in specific locations). A test case can also contain additional steps to test updating and package management.
+For each compatible VM/Test case combination, the VM is reset to a predefined state, the installer is run using the QtScript script and the post-installation checks are performed.
+The test results are aggregated and submitted to a CDash dashboard.
+
+== Setup at Nokia ==
+
+
+The VMs run on a VMWare server installation on bersrv16723. The VMWare server web frontend requires a IE (32-bit) plugin to get the guest system's shell.
+(Nokia internal: http://hegel.europe.nokia.com/binaries/vmware_client_plugin/vmware-vmrc-win32-x86.exe).
+As far as I know there is no way atm to get it running on other platforms.
+
+Web frontend URL: http://bersrv16723:8222/ui (redirect to https://bersrv16723:8333/ui, but in some cases it is not working without this redirection)
+
+The testing framework itself is configured and runs on the controller VM. It it supposed to be accessed via ssh.
+
+Controller VM: 172.25.167.111 [get a fixed IP/hostname].
+
+Attach/Start a screen session:
+
+ screen -D -R
+
+Start the test runner:
+
+ cd $HOME/test/installerfw/installer/test-framework
+ vmware/run.py -s 2010-05-17 site/host-config.cfg # insert your date here
+
+For more explanations on run.py see below.
+
+The CDash location presenting the build results is http://172.25.167.111/CDash (the controller VM). The project used is NDKInstallerTests (TODO: actually use that one).
+
+The current setup with working examples of configuration files is in $TODO:/home/kdab/test/ (TODO: commit to repo)
+
+
+== run.py ==
+
+The central python script executing test runs is vmware/run.py.
+
+Usage:run.py [options] host-config
+
+Options:
+ -s | --only-since YYYY-MM-DD when checking
+
+ /path/to/vmware/run.py -s 2010-05-14 host-config.cfg
+
+run.py does the following: It collects the information about configured VMs and test cases from the host configuration file.
+It then checks the configured installer sources for new installers, and sequentially executes the test for each new installer on all VM/test case combinations that apply to the installer (there can be specific tests cases for certain platforms only). For each installer x VM x test case run, the result is added to CDash.
+Once all installers on the FTP server (or the ones matching the --only-since restriction) were tested, the process goes to sleep and checks every hour for new installers.
+
+run.py only executes all test runs sequentially, with a single test at a time. If this turns out to be too much of a bottleneck, multiple run.py instances in different working directories and with different
+host-config files could be run in parallel (e.g. each one monitoring a different path on the FTP server).
+
+== Virtual Machine Setup ==
+
+Any VMWare virtual machine can be used for testing, if some preparations are made:
+
+ * Add a virtual CD/DVD drive (for VMWare Tools; Choose a random ISO file when asked)
+ * Install VMWare Tools (important: The test run might just hang and do nothing if the VM has no VMWare tools installed)
+ * Install Python 2.6
+ * Create a snapshot of the VM in the state that should be used as initial state for each test run [TODO: relate to UI]
+ * Create a configuration file for the VM. The configuration file provides information to run.py about the VM, such as the user/password combination to use to login, the location of the python installation or the
+ path in the VM to use for temporary files, such as the downloaded installer and result output files.
+ (See Virtual Machine Configuration File Options for details)
+ * To enable the VM, add the path to the VM config file to the host config file (See Host Configuration File Options).
+
+
+== Virtual Machine Configuration File Options ==
+
+Example:
+ TODO
+
+=== Section: General ===
+
+snapshot: identifier (Default: "base")
+
+The baseline snapshot to revert to when start a test run.
+This option is only relevant VMWare Fusion and Workstation (as Server/ESX only support a single unnamed snapshot)
+
+username: string
+password: string
+
+The username and password to authenticate with inside the VM.
+
+vmx: string
+
+The path to the VM's vmx file. Relative paths are understood relative to the configuration file.
+For remote setups, the name as listed by the TODO tool must be used.
+TODO: explain how to list snapshots.
+
+tempDir: guest path
+
+Path inside the VM to use for temporary data (installer, checker copy, test script...).
+It must be writable by the user.
+
+os: windows|linux|mac
+
+The OS running inside the VM
+
+python: guest path (Default: "python")
+
+The path to the installed python executable inside the VM.
+
+== Test Cases ==
+
+=== Configuration File ===
+
+General/platforms: string list
+
+comma-separated list of platforms the testcase should be run on.
+Valid platform names are "windows", "linux", "mac"
+
+General/targetDirectory: guest path
+
+The target directory to use for the post-installation checks (see below). Note that the actual installation directory is specified in the
+installscript and must be kept in sync.
+
+
+See the section on post-installation checks for details.
+
+General/maintenanceToolLocation
+
+The path to the maintenance tool (updater/package manager) after installation. Required for multi-step tests
+
+==== Steps ====
+
+Each test case can consist of of n steps and must have at least one.
+The first step is the actual installation and will execute the installer, the following steps will start the maintenance tool.
+Step section must be consecutive and start at 0: Step0, Step1, Step2 etc.
+
+StepN/installscript: path
+
+The path to the QtScript used for non-interactive execution of the installer/maintenance tool.
+relative paths are interpreted relative to the configuration file.
+
+StepN/checkerTestDir: string
+
+The path to a directory containing a set of tests to perform after a successful installer/maintenance tool run.
+relative paths are interpreted relative to the configuration file.
+
+Example:
+
+[General]
+
+platforms=windows,linux
+targetDirectory=c:\testinstall
+maintenanceToolLocation=c:\testInstall\TestUninstaller.exe
+
+[Step0]
+installscript=testscript.qs
+checkerTestDir=checker
+
+=== Install scripts ===
+
+see non-interactive installation section in installerbuilder/installerbuilder.dox
+TODO: merge
+
+=== Post-installation checks ===
+
+The framework can execute post-installation tests on the VM to check if the installation is in the expected state.
+The python code executing those checks is called "checker".
+Each testcase can contain a "checker test directory" to contain checks to be executed.
+The framework copies both the checker code and the test case into the VM, executes the checks and reports the results.
+
+Currently, the following checks are supported:
+
+==== Files ====
+
+It can be checked for files to exist in the installation and their file size and md5sum.
+To add such a check, place a file with extension .filelist in the test directory.
+
+The format of a .filelist file is:
+
+filename; file size; md5sum
+
+file size and md5sum are optional and can be empty.
+
+Example:
+
+components.xml; 2050; 6813144fd09f7d39764702e5adb91679wrong
+index.html; 46; fd40a94472ea1d13d93221c5ce62c321
+include\QtGui\qwidget.h; 108; 67dc776dd5aa66741dab6a2eeec4ac3c
+
+Relative paths are understood relative to the targetDirectory.
+Such files can be generated using the script test-framework/checker/scripts/generate-filelist.py
+
+==== Windows Registry ====
+
+Similar to .filelist, .registrylist files can be used to check for the existance and content of windows registry keys.
+
+The format is
+
+<path>; <key>; <value>
+
+HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion; SM_GamesName; Games
+
+==== Arbitrary python code ====
+
+Not yet done but easy to implement: Run tests from python code from .py files in the test dir.
+
+== Host Configuration File Options ==
+
+=== Section: General ===
+
+vmrun: path (Default: "vmrun")
+
+vmrun specifies the location of the vmrun executable to use. vmrun is part of VMRun Workstation, Fusion, Server and ESX. If the
+framework not on the same system as the VMWare server, you must sure that the executable installed supports the VMWare edition used
+(At the time of writing, this is VMWare Server).
+
+checkerInstallation: path
+
+The path to the "checker" python files which will be copied to each VM and executed to perform postinstallation checks.
+
+Example:
+
+checkerInstallation=/home/kdab/test/installerfw/installer/test-framework/checker
+
+testcase{0..n}: path
+
+The configuration files of the test cases to use.
+Relative paths are understood relative to the configuration file.
+
+vm{0..n}: path
+
+n configuration files of the virtual machines to use.
+Relative paths are understood relative to the configuration file.
+
+gui: True|False (default: False TODO: ensure)
+
+Whether VMWare/vmrun should bring up . Only relevant when used with VMWare Workstation or Fusion.
+
+createErrorSnapshots True|False (default: False TODO: ensure)
+
+Specifies if the framework should create error snapshots if the installation or post-installation checks fail.
+This is currently only supported for VMWare Workstation and Fusion (the server editions unfortunately only support a single snapshot per VM,
+which is reserved for the baseline.
+
+=== Section: Host ===
+
+This section is optional. It is used if the VMWare host is different from the local machine (VMWare Server or esx).
+
+type: string
+
+The VMWare edition to talk against, one of "server" and "esx"
+
+location: URL
+
+The URL of the server/esx installation to talk to
+
+Example:
+
+location=https://172.25.167.23:8333/sdk
+
+username: string
+
+The user used to login on the VMWare server
+
+password: string
+
+The user used to login on the VMWare server
+
+=== Section: CDash ===
+
+The framework is able to generate test reports in CDash format. If this section does not exist, the results are just printed to stdout.
+
+host: hostname
+
+The host of the CDash installation
+
+location:
+
+The path to the CDash installation on host
+
+
+project
+
+The CDash project to report the test results to.
+
+Example:
+
+[Host]
+
+host=localhost
+location=/CDash
+project=NokiaSDKInstallerTest
+
+=== Section: Source{0..n} ===
+
+
+Each source provides installers to be tested, for a specific platform.
+Currently, FTP is assumed and the only supported protocol.
+The
+
+Example:
+
+[Source0]
+host=hegel
+path=/projects/ndk/installers/windows
+platform=windows
+
+[Source1]
+host=hegel
+path=/projects/ndk/installers/linux
+platform=linux
+
+
diff --git a/test-framework/checker/run.py b/test-framework/checker/run.py
new file mode 100644
index 000000000..137fafb94
--- /dev/null
+++ b/test-framework/checker/run.py
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+import optparse, sys
+from testrunner import testrunner
+
+from xml.sax.saxutils import XMLGenerator
+from xml.sax.xmlreader import AttributesNSImpl
+
+class Writer:
+ def __init__( self, out ):
+ self._out = out
+ self.gen = XMLGenerator( out, 'utf-8' )
+ self.gen.startDocument()
+ self.gen.startElement( 'results', {} )
+
+ def addResult( self, name, status, errstr ):
+ self.gen.startElement('result', { 'name':name, 'status':status } )
+ self.gen.characters( errstr )
+ self.gen.endElement('result' )
+
+ def addFailed( self, name, errstr ):
+ self.addResult( name, "failed", errstr )
+
+ def addPassed( self, status, errstr ):
+ self.addResult( name, "passed", errstr )
+
+ def finalize( self ):
+ self.gen.endElement( 'results' )
+ self.gen.endDocument
+ self._out.write( '\n' )
+
+optionParser = optparse.OptionParser(usage="%prog [options] testcaseDir", version="%prog 0.1")
+optionParser.add_option("-p", "--omit-prefix", dest="prefix", help="for file checks, prefix relative paths with this prefix", metavar="PREFIX" )
+optionParser.add_option("-o", "--output", dest="output", help="write results to file (instead of stdout)", metavar="OUTPUT" )
+(options, args) = optionParser.parse_args()
+
+try:
+ testdir = args[0]
+except IndexError:
+ optionParser.print_usage( sys.stderr )
+ sys.exit( 1 )
+
+out = sys.stdout
+if options.output != None:
+ out = file( options.output, 'wb' )
+
+writer = Writer( out )
+try:
+ runner = testrunner.TestRunner( testdir, options.prefix, writer )
+ runner.run()
+finally:
+ writer.finalize() \ No newline at end of file
diff --git a/test-framework/checker/scripts/generate-filelist.py b/test-framework/checker/scripts/generate-filelist.py
new file mode 100644
index 000000000..ba4929304
--- /dev/null
+++ b/test-framework/checker/scripts/generate-filelist.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+import optparse, os, sys
+from testrunner import files, testrunner
+
+class GenerateException( Exception ):
+ def __init__( self, value ):
+ self.value = value
+ def __str__( self ):
+ return repr( self.value )
+
+def relpath( path, prefix ):
+ if prefix != None:
+ return os.path.relpath( path, prefix )
+ else:
+ return path;
+
+out = sys.stdout
+
+def walker( prefix, current_dir, children ):
+ for c in children:
+ child = current_dir + os.sep + c
+ if os.path.isdir( child ):
+ continue
+ fileObj = file( child, 'rb' )
+ md5 = files.md5sum( fileObj )
+ out.write( "{0}; {1}; {2}\n".format( relpath( child, prefix ), os.path.getsize( child ), md5 ) )
+
+optionParser = optparse.OptionParser(usage="%prog [options] directory", version="%prog 0.1")
+optionParser.add_option("-p", "--omit-prefix", dest="prefix", help="make entries relative to this prefix", metavar="PREFIX" )
+optionParser.add_option("-o", "--output", dest="output", help="save file list to file (instead of stdout)", metavar="OUTPUT" )
+(options, args) = optionParser.parse_args()
+
+try:
+ directory = args[0]
+except IndexError:
+ raise GenerateException( "No directory given.")
+
+if options.output != None:
+ out = file( options.output, 'wb' )
+
+os.path.walk( directory, walker, options.prefix )
diff --git a/test-framework/checker/testrunner/__init__.py b/test-framework/checker/testrunner/__init__.py
new file mode 100644
index 000000000..210f31223
--- /dev/null
+++ b/test-framework/checker/testrunner/__init__.py
@@ -0,0 +1 @@
+# init.py
diff --git a/test-framework/checker/testrunner/files.py b/test-framework/checker/testrunner/files.py
new file mode 100644
index 000000000..629bedd05
--- /dev/null
+++ b/test-framework/checker/testrunner/files.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+from testexception import TestException
+
+import fnmatch, hashlib, os
+
+def md5sum( fileObj ):
+ md5 = hashlib.md5()
+ while True:
+ chunk = fileObj.read( 4096 )
+ if not chunk:
+ break
+ md5.update( chunk )
+ return md5.hexdigest()
+
+def locateFiles( rootPath, pattern ):
+ for path, dirs, files in os.walk( os.path.abspath( rootPath ) ):
+ for filename in fnmatch.filter( files, pattern ):
+ yield os.path.join( path, filename )
+
+def checkFileImpl( path, expectedSize=-1, expectedMd5=None ):
+ #TODO: normalize path/convert to platform
+ if not os.path.exists( path ):
+ raise TestException( '{0}: file does not exist'.format( path ) )
+ size = os.path.getsize( path )
+ if expectedSize >= 0 and size != expectedSize:
+ raise TestException( '{0}: unexpected size. Actual: {1} Expected: {2}'.format( path, size, expectedSize ) )
+ if ( expectedMd5 != None ):
+ fileObj = file( path, 'rb' )
+ md5 = md5sum( fileObj )
+ fileObj.close()
+ if md5 != expectedMd5:
+ raise TestException( '{0}: md5sum mismatch. Actual: {1} Expected: {2}'.format( path, md5, expectedMd5 ) )
+
diff --git a/test-framework/checker/testrunner/logger.py b/test-framework/checker/testrunner/logger.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test-framework/checker/testrunner/logger.py
diff --git a/test-framework/checker/testrunner/registry.py b/test-framework/checker/testrunner/registry.py
new file mode 100644
index 000000000..854a029f3
--- /dev/null
+++ b/test-framework/checker/testrunner/registry.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+from testexception import TestException
+import _winreg
+
+_registry = dict()
+_registry["HKEY_CLASSES_ROOT"] = _winreg.HKEY_CLASSES_ROOT
+_registry["HKEY_CURRENT_USER"] = _winreg.HKEY_CURRENT_USER
+_registry["HKEY_LOCAL_MACHINE"] = _winreg.HKEY_LOCAL_MACHINE
+_registry["HKEY_USERS"] = _winreg.HKEY_USERS
+_registry["HKEY_CURRENT_CONFIG"] = _winreg.HKEY_CURRENT_CONFIG
+
+def splitKey( key ):
+ key, seperator, subKey = key.partition( '\\' )
+ return _registry[key], subKey
+
+def checkKey( key, value, expectedData ):
+ baseKey, subKey = splitKey( key )
+ keyHandle = _winreg.OpenKey( baseKey, subKey )
+ data, _ = _winreg.QueryValueEx( keyHandle, value )
+ if data != expectedData:
+ raise TestException( '{0}: unexpected registry data. Actual: {1} Expected: {2}'.format( key, data, expectedData ) )
diff --git a/test-framework/checker/testrunner/testexception.py b/test-framework/checker/testrunner/testexception.py
new file mode 100644
index 000000000..58254a599
--- /dev/null
+++ b/test-framework/checker/testrunner/testexception.py
@@ -0,0 +1,5 @@
+class TestException( Exception ):
+ def __init__( self, value ):
+ self.value = value
+ def __str__( self ):
+ return repr( self.value )
diff --git a/test-framework/checker/testrunner/testrunner.py b/test-framework/checker/testrunner/testrunner.py
new file mode 100644
index 000000000..fcef00b02
--- /dev/null
+++ b/test-framework/checker/testrunner/testrunner.py
@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+import files, os, string, platform
+from testexception import TestException
+
+if ( platform.system() == "Windows" ):
+ import registry
+
+def makeAbsolutePath( path, relativeTo ):
+ if os.path.isabs( path ) or relativeTo == None:
+ return path
+ else:
+ return relativeTo + os.sep + path
+
+
+class TestRunner:
+ def __init__( self, testDir, basedir, result ):
+ self._testDir = testDir
+ self._basedir = basedir
+ self._result = result
+
+ def checkFile( self, name, size=-1, expectedMd5=None ):
+ try:
+ files.checkFileImpl( name, size, expectedMd5 )
+ except TestException as e:
+ self._result.addFailed( name, e.value )
+
+ def checkFileList( self, path ):
+ lineNum = 0
+ haveError = False
+ with open( path, 'r' ) as f:
+ while True:
+ line = f.readline()
+ lineNum += 1
+ if not line:
+ break
+ line = string.strip( line )
+ if len( line ) == 0:
+ continue
+ segments = string.split( line, ';' )
+ if len( segments ) == 3:
+ fp = makeAbsolutePath( segments[0], self._basedir )
+ try:
+ fs = int( segments[1] )
+ except ValueError:
+ fs = -1 #TODO handle error
+ femd5 = segments[2]
+ femd5 = string.strip( femd5 )
+ self.checkFile( fp, fs, femd5 )
+ else:
+ self._result.addFailed( path + '_' + str( lineNum ), "Could not parse file list entry: " + line )
+ haveError = True
+ if not haveError:
+ self._result.addPassed( path, "" )
+
+ def checkRegistryList( self, path ):
+ haveError = False
+ lineNum = 0
+ with open( path, 'r' ) as f:
+ while True:
+ lineNum += 1
+ line = f.readline()
+ if not line:
+ break
+ line = string.strip( line )
+ if len( line ) == 0:
+ continue
+ segments = string.split( line, ';' )
+ if len( segments ) == 3:
+ key = segments[0].strip()
+ value = segments[1].strip()
+ expectedData = segments[2].strip()
+ registry.checkKey( key, value, expectedData )
+ else:
+ self._result.addFailed( path + '_' + str( lineNum ), "Could not parse registry list entry: " + line )
+ haveError = True
+ if not haveError:
+ self._result.addPassed( path, "" )
+
+ def run( self ):
+ fileLists = files.locateFiles( self._testDir, "*.filelist" )
+ for i in fileLists:
+ self.checkFileList( i )
+
+ if ( platform.system() == "Windows" ):
+ registryLists = files.locateFiles( self._testDir, "*.registrylist" )
+ for i in registryLists:
+ self.checkRegistryList( i )
+
+ # run all .py's in testdir
+ # execute all filelists
diff --git a/test-framework/site/TestCases/testcase-linux64/checker/testinstall.filelist b/test-framework/site/TestCases/testcase-linux64/checker/testinstall.filelist
new file mode 100644
index 000000000..30aecdabc
--- /dev/null
+++ b/test-framework/site/TestCases/testcase-linux64/checker/testinstall.filelist
@@ -0,0 +1,5 @@
+components.xml; 2050; 6813144fd09f7d39764702e5adb91679wrong
+index.html; 46; fd40a94472ea1d13d93221c5ce62c321
+uninstall.exe; 13598393; 44945e7d3507d294b5e9e096ac3269b1
+include\QtCore\qobject.h; 108; 9e50d789f32d1651e16b6ae55699eb71
+include\QtGui\qwidget.h; 108; 67dc776dd5aa66741dab6a2eeec4ac3c
diff --git a/test-framework/site/TestCases/testcase-linux64/testcase-linux64.cfg b/test-framework/site/TestCases/testcase-linux64/testcase-linux64.cfg
new file mode 100644
index 000000000..ffbc24556
--- /dev/null
+++ b/test-framework/site/TestCases/testcase-linux64/testcase-linux64.cfg
@@ -0,0 +1,5 @@
+[General]
+installscript=testscript.qs
+platforms=linux64
+targetDirectory=/home/kdab/testinstall
+checkerTestDir=checker
diff --git a/test-framework/site/TestCases/testcase-linux64/testscript.qs b/test-framework/site/TestCases/testcase-linux64/testscript.qs
new file mode 100644
index 000000000..3cc4bd4d6
--- /dev/null
+++ b/test-framework/site/TestCases/testcase-linux64/testscript.qs
@@ -0,0 +1,67 @@
+function Controller()
+{
+ installer.autoRejectMessageBoxes
+ installer.setMessageBoxAutomaticAnswer( "overwriteTargetDirectory", QMessageBox.Yes )
+}
+
+
+Controller.prototype.IntroductionPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.LicenseAgreementPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "LicenseAgreementPage" )
+ page.acceptLicenseRB.setChecked( true )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.TargetDirectoryPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "TargetDirectoryPage" )
+ page.targetDirectoryLE.setText( "/home/kdab/testinstall" )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.ComponentSelectionPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "ComponentSelectionPage" )
+ page.deselectComponent( "com.nokia.ndk.tools.maemo.usbdriver" )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.DynamicQtGuiPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "DynamicQtGuiPage" )
+ page.checkBoxLib.setChecked( false )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.DynamicErrorPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "DynamicErrorPage" )
+ page.checkBoxMakeSure.setChecked( true )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.ReadyForInstallationPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.StartMenuDirectoryPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.PerformInstallationPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "PerformInstallationPage" )
+ page.details.button.click
+}
+
+Controller.prototype.FinishedPageCallback = function()
+{
+ gui.clickButton( buttons.FinishButton )
+}
diff --git a/test-framework/site/TestCases/testcase1/checker/testinstall.filelist b/test-framework/site/TestCases/testcase1/checker/testinstall.filelist
new file mode 100644
index 000000000..30aecdabc
--- /dev/null
+++ b/test-framework/site/TestCases/testcase1/checker/testinstall.filelist
@@ -0,0 +1,5 @@
+components.xml; 2050; 6813144fd09f7d39764702e5adb91679wrong
+index.html; 46; fd40a94472ea1d13d93221c5ce62c321
+uninstall.exe; 13598393; 44945e7d3507d294b5e9e096ac3269b1
+include\QtCore\qobject.h; 108; 9e50d789f32d1651e16b6ae55699eb71
+include\QtGui\qwidget.h; 108; 67dc776dd5aa66741dab6a2eeec4ac3c
diff --git a/test-framework/site/TestCases/testcase1/testcase1.cfg b/test-framework/site/TestCases/testcase1/testcase1.cfg
new file mode 100644
index 000000000..178613640
--- /dev/null
+++ b/test-framework/site/TestCases/testcase1/testcase1.cfg
@@ -0,0 +1,5 @@
+[General]
+installscript=testscript.qs
+platforms=windows,linux
+targetDirectory=c:\testinstall
+checkerTestDir=checker
diff --git a/test-framework/site/TestCases/testcase1/testscript.qs b/test-framework/site/TestCases/testcase1/testscript.qs
new file mode 100644
index 000000000..59bf25e3c
--- /dev/null
+++ b/test-framework/site/TestCases/testcase1/testscript.qs
@@ -0,0 +1,67 @@
+function Controller()
+{
+ installer.autoRejectMessageBoxes
+ installer.setMessageBoxAutomaticAnswer( "overwriteTargetDirectory", QMessageBox.Yes )
+}
+
+
+Controller.prototype.IntroductionPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.LicenseAgreementPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "LicenseAgreementPage" )
+ page.acceptLicenseRB.setChecked( true )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.TargetDirectoryPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "TargetDirectoryPage" )
+ page.targetDirectoryLE.setText( "c:\\testinstall" )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.ComponentSelectionPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "ComponentSelectionPage" )
+ page.deselectComponent( "com.nokia.ndk.tools.maemo.usbdriver" )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.DynamicQtGuiPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "DynamicQtGuiPage" )
+ page.checkBoxLib.setChecked( false )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.DynamicErrorPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "DynamicErrorPage" )
+ page.checkBoxMakeSure.setChecked( true )
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.ReadyForInstallationPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.StartMenuDirectoryPageCallback = function()
+{
+ gui.clickButton( buttons.NextButton )
+}
+
+Controller.prototype.PerformInstallationPageCallback = function()
+{
+ var page = gui.pageWidgetByObjectName( "PerformInstallationPage" )
+ page.details.button.click
+}
+
+Controller.prototype.FinishedPageCallback = function()
+{
+ gui.clickButton( buttons.FinishButton )
+}
diff --git a/test-framework/site/VMConfigs/LinuxUbuntu9.1064Bit.cfg b/test-framework/site/VMConfigs/LinuxUbuntu9.1064Bit.cfg
new file mode 100644
index 000000000..a5c19e084
--- /dev/null
+++ b/test-framework/site/VMConfigs/LinuxUbuntu9.1064Bit.cfg
@@ -0,0 +1,8 @@
+[General]
+snapshot=base
+username=kdab
+password=kdab
+vmx=[standard] Linux Ubuntu 9.10 64 Bit/Linux Ubuntu 9.10 64 Bit.vmx
+tempDir=/home/kdab
+os=linux64
+python=/usr/bin/python
diff --git a/test-framework/site/VMConfigs/WindowsVista32Bit.cfg b/test-framework/site/VMConfigs/WindowsVista32Bit.cfg
new file mode 100644
index 000000000..40a49d2f1
--- /dev/null
+++ b/test-framework/site/VMConfigs/WindowsVista32Bit.cfg
@@ -0,0 +1,9 @@
+[General]
+snapshot=base
+username=kdab
+password=kdab
+vmx=[standard] Windows Vista 32 Bit/Windows Vista 32 Bit.vmx
+tempDir=c:\Users\kdab\Desktop
+os=windows
+python=c:\Python26\python.exe
+
diff --git a/test-framework/site/VMConfigs/WindowsVista64Bit.cfg b/test-framework/site/VMConfigs/WindowsVista64Bit.cfg
new file mode 100644
index 000000000..c46d8fba5
--- /dev/null
+++ b/test-framework/site/VMConfigs/WindowsVista64Bit.cfg
@@ -0,0 +1,9 @@
+[General]
+snapshot=base
+username=kdab
+password=kdab
+vmx=[standard] Windows XP 32 Bit/Windows XP 32 Bit.vmx
+tempDir=c:\Dokumente und Einstellungen\kdab\Desktop
+os=windows
+python=c:\Python26\python.exe
+
diff --git a/test-framework/site/VMConfigs/WindowsXp32Bit.cfg b/test-framework/site/VMConfigs/WindowsXp32Bit.cfg
new file mode 100644
index 000000000..c46d8fba5
--- /dev/null
+++ b/test-framework/site/VMConfigs/WindowsXp32Bit.cfg
@@ -0,0 +1,9 @@
+[General]
+snapshot=base
+username=kdab
+password=kdab
+vmx=[standard] Windows XP 32 Bit/Windows XP 32 Bit.vmx
+tempDir=c:\Dokumente und Einstellungen\kdab\Desktop
+os=windows
+python=c:\Python26\python.exe
+
diff --git a/test-framework/site/VMConfigs/WindowsXp64Bit.cfg b/test-framework/site/VMConfigs/WindowsXp64Bit.cfg
new file mode 100644
index 000000000..effbbd70d
--- /dev/null
+++ b/test-framework/site/VMConfigs/WindowsXp64Bit.cfg
@@ -0,0 +1,9 @@
+[General]
+snapshot=base
+username=kdab
+password=kdab
+vmx=[standard] Windows XP 64 Bit/Windows XP 64 Bit.vmx
+tempDir=c:\Documents and Settings\kdab\Desktop
+os=windows
+python=c:\Python26\python.exe
+
diff --git a/test-framework/site/host-config.cfg b/test-framework/site/host-config.cfg
new file mode 100644
index 000000000..f500e6fc9
--- /dev/null
+++ b/test-framework/site/host-config.cfg
@@ -0,0 +1,37 @@
+[General]
+vmrun=vmrun
+checkerInstallation=/home/kdab/test/installerfw/installer/test-framework/checker
+testcase0=TestCases/testcase1/testcase1.cfg
+testcase1=TestCases/testcase-linux64/testcase-linux64.cfg
+vm0=VMConfigs/WindowsXp32Bit.cfg
+vm1=VMConfigs/WindowsXp64Bit.cfg
+vm2=VMConfigs/WindowsVista32Bit.cfg
+vm3=VMConfigs/LinuxUbuntu9.1064Bit.cfg
+gui=False
+createErrorSnapshots=False
+
+[Host]
+type=server
+location=https://172.25.167.23:8333/sdk
+username=kdab
+password=kdab
+
+[CDash]
+host=localhost
+location=/CDash
+project=test1
+
+[Source0]
+host=hegel
+path=/projects/ndk/installers/windows
+platform=windows
+
+[Source1]
+host=hegel
+path=/projects/ndk/installers/linux/x32
+platform=linux32
+
+[Source2]
+host=hegel
+path=/projects/ndk/installers/linux/x64
+platform=linux64
diff --git a/test-framework/site/listVMs.sh b/test-framework/site/listVMs.sh
new file mode 100644
index 000000000..e9d5342d4
--- /dev/null
+++ b/test-framework/site/listVMs.sh
@@ -0,0 +1 @@
+vmrun -u kdab -p kdab -T server -h https://172.25.167.23:8333/sdk listRegisteredVM
diff --git a/test-framework/tests/simpletest.py b/test-framework/tests/simpletest.py
new file mode 100644
index 000000000..5a320191a
--- /dev/null
+++ b/test-framework/tests/simpletest.py
@@ -0,0 +1,11 @@
+import sys
+from testrunner import testrunner
+
+class Result:
+ def addError( self, errstr ):
+ print errstr
+
+
+result = Result()
+runner = testrunner.TestRunner( sys.argv[1], result )
+runner.run()
diff --git a/test-framework/tests/testfiles/test.filelist b/test-framework/tests/testfiles/test.filelist
new file mode 100644
index 000000000..fdeb8ee2f
--- /dev/null
+++ b/test-framework/tests/testfiles/test.filelist
@@ -0,0 +1,3 @@
+/home/frank/.ssh/id_dsa.pub; 1113; 1fddf250c364370b7936c1b7256c7eda
+/home/frank/.ssh/id_dsa.pub; 1113; 1fddf250c364370b7936c1b7256c7edb
+
diff --git a/test-framework/vmware/cdashreporter.py b/test-framework/vmware/cdashreporter.py
new file mode 100644
index 000000000..5acaa783e
--- /dev/null
+++ b/test-framework/vmware/cdashreporter.py
@@ -0,0 +1,156 @@
+# -*- coding: utf-8 -*-
+import datetime, socket, os, sys, traceback, time, tempfile, httplib, urllib
+from xml.sax.saxutils import XMLGenerator
+from xml.sax.xmlreader import AttributesNSImpl
+import result, utils
+from result import exitStatusAsString
+from xmlutils import startElement, endElement, writeElement
+
+checkerResultAsString = { result.CheckerResult.Passed:u"passed", result.CheckerResult.Failed:u"failed", result.CheckerResult.NotRun:u"notRun" }
+
+def formatDate( date ):
+ return date.strftime( '%Y%m%d-%H%M' )
+
+def writeExecutionResult( gen, name, r ):
+ if r == None or r.hasError():
+ stat = "failed"
+ else:
+ stat = "passed"
+
+ startElement( gen, None, "Test", { u"Status":stat } )
+ writeElement( gen, None, "Name", name )
+ writeElement( gen, None, "FullName", name )
+ startElement( gen, None, "NamedMeasurement", { u"type":u"text/string", u"name":u"Exit Code"} )
+ if r:
+ msg = "(Unexpected)"
+ ec = r.exitCode
+ if ec == 0:
+ msg = "(Success)"
+ elif ec == 1:
+ msg = "(Failed)"
+ elif ec == 2:
+ msg = "(Canceled)"
+
+ writeElement( gen, None, "Value", "Exit status: {0}; Installer exit code: {1} {2}".format( exitStatusAsString( r.exitStatus ), str( r.exitCode ), msg ) )
+ else:
+ writeElement( gen, None, "Value", "Could not determine installation result." )
+
+ endElement( gen, None, "NamedMeasurement" )
+
+
+ if r:
+ startElement( gen, None, "NamedMeasurement", { u"type":u"numeric/double", u"name":u"Execution Time"} )
+ writeElement( gen, None, "Value", str( r.executionTime ) )
+ endElement( gen, None, "NamedMeasurement" )
+
+
+ endElement( gen, None, "Test" )
+
+def writeInternalError( gen, errorstr, num ):
+ startElement( gen, None, "Test", { u"Status":u"failed"} )
+ name = "InternalError{0}".format( num )
+ writeElement( gen, None, "Name", name )
+ writeElement( gen, None, "FullName", name )
+ startElement( gen, None, "NamedMeasurement", { u"type":u"text/string", u"name":u"Completion Status"} )
+ writeElement( gen, None, "Value", errorstr )
+ endElement( gen, None, "NamedMeasurement" )
+ endElement( gen, None, "Test" )
+
+def writeTest( gen, test ):
+ startElement( gen, None, "Test", { u"Status":checkerResultAsString[test.result]} )
+ writeElement( gen, None, "Name", test.name )
+ writeElement( gen, None, "FullName", test.name )
+ startElement( gen, None, "NamedMeasurement", { u"type":u"text/string", u"name":u"Completion Status"} )
+ writeElement( gen, None, "Value", test.errorString )
+ endElement( gen, None, "NamedMeasurement" )
+ endElement( gen, None, "Test" )
+
+class CDashReporter:
+ def __init__( self, host, location, project ):
+ self._host = host
+ self._location = location
+ self._project = project
+
+ def reportException( self ):
+ sys.stderr.write( traceback.format_exc( 15 ) + '\n' )
+ #TODO
+
+ def reportResult( self, result ):
+ self._buildStamp = '{0}-Nightly'.format( datetime.datetime.now().strftime( '%Y%m%d-%H%M' ), utils.randomString( 4 ) )
+ try:
+ #generate XML
+ self.genXml( self.genTestXml, result )
+ #generate Tests.xml
+ #submitFile('Tests.xml')
+ except:
+ raise
+
+ def genTestXml( self, gen, result ):
+ name = "{0} on {1}".format( result._installer.sourceFilename, result._vm.name() )
+ startElement( gen, None, "Site", { u"BuildStamp":self._buildStamp, u"Name":name, u"Generator":u"VMTester 0.1" } )
+ startElement( gen, None, "Testing" )
+ writeElement( gen, None, "StartDateTime", formatDate( result._testStart ) )
+ startElement( gen, None, "TestList" )
+ internal = result._internalErrors
+ for i in range( 0, len( internal ) - 1 ):
+ writeElement( gen, None, "Test", "InternalError{0}".format( i ) )
+
+ for stepNum in range( len( result._stepResults ) ):
+ step = result._stepResults[stepNum]
+ writeElement( gen, None, "Test", "installer-run{0}".format( stepNum ) )
+ for i in step.checkerResults:
+ writeElement( gen, None, "Test", i.name )
+ endElement( gen, None, "TestList" )
+
+ for i in range( 0, len( internal ) - 1 ):
+ writeInternalError( gen, internal[i], i )
+ for stepNum in range( len( result._stepResults ) ):
+ step = result._stepResults[stepNum]
+ writeExecutionResult( gen, "installer-run{0}".format( stepNum ), step.executionResult )
+ for i in step.checkerResults:
+ writeTest( gen, i )
+ endElement( gen, None, "Testing" )
+ endElement( gen, None, "Site" )
+
+ def genXml( self, fillFunc, result ):
+ f = None
+ try:
+ f = tempfile.NamedTemporaryFile( delete=False )
+ gen = XMLGenerator( f, 'utf-8' )
+ gen.startDocument()
+ fillFunc( gen, result )
+ gen.endDocument()
+ f.close()
+ self.submitFile( f.name )
+ finally:
+ if f:
+ os.unlink( f.name )
+
+ def submitFile( self, path ):
+ f = file( path )
+ params = urllib.urlencode( {'project': self._project} )
+ conn = None
+ try:
+ try:
+ conn = httplib.HTTPConnection( self._host )
+ conn.request( "POST", "{0}/submit.php?project={1}".format( self._location, self._project ), f )
+ response = conn.getresponse()
+ print response.status, response.reason
+ #TODO check result
+ finally:
+ if conn:
+ conn.close()
+ except:
+ #TODO: if submitting to cdash fails, try to notify the admin (mail?)
+ raise
+
+if __name__ == "__main__":
+ r = result.Result()
+ r.testStarted()
+ r.addCheckerResult( result.CheckerResult( "test1", result.CheckerResult.Passed, "" ) )
+ r.addCheckerResult( result.CheckerResult( "test2", result.CheckerResult.Failed, "Something went wrong, dude!" ) )
+ time.sleep( 1 )
+ r.testFinished()
+ cr = CDashReporter( "http://localhost", "/CDash", "test1" )
+ cr.reportResult( r )
+
diff --git a/test-framework/vmware/control.py b/test-framework/vmware/control.py
new file mode 100644
index 000000000..b24c33ea9
--- /dev/null
+++ b/test-framework/vmware/control.py
@@ -0,0 +1,220 @@
+# -*- coding: utf-8 -*-
+import ConfigParser, datetime, os, string, sys, time, platform
+import testcase, utils, result, virtualmachine
+from virtualmachine import VMException
+from xml.sax import make_parser
+from xml.sax.handler import ContentHandler
+
+class ControlException( Exception ):
+ def __init__( self, value ):
+ self.value = value
+ def __str__( self ):
+ return repr( self.value )
+
+class Handler( ContentHandler ):
+ def __init__( self, res ):
+ self._res = res
+ self._inResult = False
+ self._buf = ""
+
+ def startElement( self, name, attrs ):
+ self._inResult = False
+ if name == "result":
+ self._inResult = True
+ self._name = attrs['name']
+ self._status = attrs['status']
+
+ def endElement( self, name ):
+ if name == 'result':
+ trimmed = string.strip( self._buf )
+ if self._status == "passed":
+ stat = result.CheckerResult.Passed
+ else:
+ stat = result.CheckerResult.Failed
+ self._res.addCheckerResult( result.CheckerResult( self._name, stat, trimmed ) )
+ self._inResult = False
+
+ self._buf = ""
+
+ def characters( self, ch ):
+ if self._inResult:
+ self._buf += ch
+
+class Control:
+ def __init__( self, vmrun, checkerDir, source, reporter ):
+ self._vmrun = vmrun
+ self._checkerDir = checkerDir
+ self._vms = []
+ self._testcases = []
+ self._source = source
+ self._reporter = reporter
+ self._guiEnabled = True
+ self._createErrorSnapshots = False
+ self._hostType = ""
+ self._hostLocation = ""
+ self._hostUsername = ""
+ self._hostPassword = ""
+
+ def setGuiEnabled( self, usegui ):
+ self._guiEnabled = usegui
+ for i in self._vms:
+ i.setGuiEnabled( usegui )
+
+ def setCreateErrorSnapshots( self, createSnapshots ):
+ self._createErrorSnapshots = createSnapshots
+
+ def setRemoteHost( self, type, loc, user, pw ):
+ self._hostType = type
+ self._hostLocation = loc
+ self._hostUsername = user
+ self._hostPassword = pw
+ for vm in self._vms:
+ if not vm.isRemote():
+ vm.setRemoteHost( self._hostType, self._hostLocation, self._hostUsername, self._hostPassword )
+
+ def addVM( self, cfgpath ):
+ config = ConfigParser.SafeConfigParser()
+ config.read( cfgpath )
+ vm = virtualmachine.fromVMRunAndPath( self._vmrun, cfgpath )
+ vm.setGuiEnabled( self._guiEnabled )
+ if len( self._hostType ) > 0 and not vm.isRemote():
+ vm.setRemoteHost( self._hostType, self._hostLocation, self._hostUsername, self._hostPassword )
+ self._vms.append( vm )
+ #TODO catch/transform exceptions
+
+ def addTestCase( self, path ):
+ self._testcases.append( testcase.TestCase( path ) )
+
+
+ def run( self ):
+ while True:
+ try:
+ inst = self._source.nextInstaller()
+ if inst == None:
+ print( "** Installer source returned None, aborting" )
+ return
+ if inst.error:
+ raise ControlException( inst.error )
+ print( "** New installer: {0}".format( inst.path ) )
+ self.testInstaller( inst, inst.platform )
+ except KeyboardInterrupt:
+ raise
+ except:
+ self._reporter.reportException()
+
+ def testInstaller( self, inst, platform ):
+ for vm in self._vms:
+ if vm.ostype() != platform:
+ continue
+ for case in self._testcases:
+ if not case.supportsPlatform( platform ):
+ continue
+ res = result.Result()
+ try:
+ try:
+ res.setInstaller( inst )
+ res.setTestCase( case )
+ res.setVirtualMachine( vm )
+ res.testStarted()
+ self.run_test( inst.path, vm, case, res )
+ res.testFinished()
+ inst.markAsTested()
+ except KeyboardInterrupt:
+ raise
+ except:
+ res.addException()
+ finally:
+ self._reporter.reportResult( res )
+
+ def convertCheckerResults( self, filename, res ):
+ parser = make_parser()
+ parser.setContentHandler( Handler( res ) )
+ f = file( filename, 'rb' )
+ parser.parse( f )
+
+ def run_test( self, installerPath, vm, testcase, res ):
+ steps = testcase.steps()
+ if len( steps ) == 0:
+ raise ControlException( "No steps found for testcase {0}".format( testcase.name() ) )
+
+ revertStatus, _ = vm.revertToSnapshot()
+ if revertStatus != 0:
+ raise VMException( "Failed to revert to snapshot '{0}'".format( vm.snapshot() ) )
+
+
+ time.sleep( 5 ) # Trying to avoid a possible race between restore and start
+
+ vm.start()
+
+ try:
+ try:
+ vm.checkPythonInstalled()
+ wrapperpath = vm.copyToTemp( utils.execution_path( 'guest.py' ) )
+
+ for stepNum in range( len( steps ) ):
+ needSnapshot = False
+ step = steps[stepNum]
+ if stepNum == 0:
+ executableguestpath = vm.copyToTemp( installerPath )
+ else:
+ executableguestpath = testcase.maintenanceToolLocation()
+
+ outputFileName = 'output{0}.log'.format( stepNum )
+ outputpath = vm.mkTempPath( outputFileName )
+ scriptguestpath = vm.copyToTemp( step.installscript() )
+ timeout = step.timeout()
+ checkerguestpath = vm.copyToTemp( step.checkerTestDir(), "checkerTestDir{0}".format( stepNum ) ) if len( string.strip( step.checkerTestDir() ) ) > 0 else None
+ vm.command( 'Execute installer', "runProgramInGuest", "'{0}' '{1}' '{2}' '{3}' '{4}' --script '{5}'".format( vm.python(), wrapperpath, outputpath, timeout, executableguestpath, scriptguestpath ) )
+ vm.copyFromTemp( outputFileName, outputFileName )
+ r = ConfigParser.SafeConfigParser()
+ r.read( outputFileName )
+ try:
+ s = r.get( 'Result', 'ExitCode' )
+ exitCode = int( s )
+ except ValueError:
+ res.addInternalError( "Could not parse integer exit code from '{0}'".format( r.get( 'Result', 'ExitCode' ) ) )
+ exitCode = -1
+ try:
+ s = r.get( 'Result', 'ExecutionTime' )
+ executionTime = float( s )
+ except ValueError:
+ res.addInternalError( "Could not parse float execution time from '{0}'".format( r.get( 'Result', 'ExecutionTime' ) ) )
+ executionTime = 0.0
+
+ exitStatus = result.exitStatusFromString( r.get( 'Result', 'ExitStatus' ) )
+ instR = result.ExecutionResult( exitCode, exitStatus, executionTime )
+
+ if instR.hasError():
+ needSnapshot = True
+
+ checkerResults = []
+ if checkerguestpath and not instR.hasError():
+ if ( platform.system() == "Darwin" ):
+ # Have to sleep to work around VMware Fusion bug
+ time.sleep( 30 )
+ run_py = vm.copyToTemp( self._checkerDir ) + vm.pathSep() + "run.py"
+ if ( platform.system() == "Darwin" ):
+ # Have to sleep to work around VMware Fusion bug
+ time.sleep( 30 )
+ checkeroutputFileName = 'checker-output{0}.xml'.format( stepNum )
+ checkeroutput = vm.mkTempPath( checkeroutputFileName )
+ vm.command( 'Execute checker tests', "runProgramInGuest", "'{0}' '{1}' '{2}' -o '{3}' -p '{4}'".format( vm.python(), run_py, checkerguestpath, checkeroutput, testcase.targetDirectory() ) )
+ vm.copyFromTemp( checkeroutputFileName, checkeroutputFileName )
+ self.convertCheckerResults( localcheckeroutput, checkerResults )
+ if res.hasCheckerErrors():
+ needSnapshot = True
+ if self._createErrorSnapshots and needSnapshot:
+ snapshot = 'error-{0}-{1}'.format( datetime.datetime.now().strftime( '%Y%m%d_%H%M%S' ), utils.randomString( 4 ) )
+ status, _ = vm.createSnapshot( snapshot )
+ if status == 0:
+ res.setErrorSnapshot( snapshot )
+ else:
+ res.addInternalError( 'Could not create error snapshot "{0}"'.format( snapshot ) )
+ res.addStepResult( result.StepResult( instR, checkerResults ) )
+ #TODO handle timeouts?
+ finally:
+ vm.kill()
+ except e:
+ print( e )
+ res.addInternalError( str( e ) )
+ \ No newline at end of file
diff --git a/test-framework/vmware/ftpsource.py b/test-framework/vmware/ftpsource.py
new file mode 100644
index 000000000..306c76b63
--- /dev/null
+++ b/test-framework/vmware/ftpsource.py
@@ -0,0 +1,117 @@
+# -*- coding: utf-8 -*-
+from ftplib import FTP
+import datetime, functools, os, time, tempfile
+from source import Installer
+import utils
+
+def _timestampFromFilename( platform, fn ):
+ # windows: assumed format is YYYY_mm_dd_HH_MM as prefix
+ # linux: assumed format is YYYY-mm-dd as suffix
+ if platform.startswith( 'windows' ):
+ format = '%Y_%m_%d_%H_%M'
+ length = len( 'YYYY_mm_dd_HH_MM' )
+ return datetime.datetime.strptime( fn[0:length], format )
+ else:
+ format = '%Y-%m-%d'
+ length = len( 'YYYY-mm-dd' )
+ return datetime.datetime.strptime( fn[-length:], format )
+
+
+
+def timestampFromFilename( platform, fn ):
+ try:
+ return _timestampFromFilename( platform, fn )
+ except ValueError:
+ return None
+
+def filesNewerThan( files, dt ):
+ if dt:
+ return filter( lambda (x,y): y >= dt, files )
+ else:
+ return files
+
+#internal to FtpSource
+class Location:
+ def __init__( self, host, path, platform ):
+ self.host = host
+ self.path = path
+ self.platform = platform
+ self.testedFiles = []
+
+ def ls( self ):
+ ftp = FTP( self.host )
+ ftp.login()
+ try:
+ return map( utils.basename, ftp.nlst( self.path ) )
+ finally:
+ ftp.close()
+
+ def filesSortedByTimestamp( self ):
+ files = self.ls()
+ withTS = [( i, timestampFromFilename( self.platform, i ) ) for i in files]
+ filtered = filter( lambda (x,y): y != None, withTS )
+ filtered.sort( key=lambda (x,y): y )
+ return filtered
+
+ def untestedFilesSortedByTimestamp( self ):
+ l = self.filesSortedByTimestamp()
+ return filter( lambda ( x, y ): not self.isTested( x ), l )
+
+ def markAsTested( self, filename ):
+ self.testedFiles.append( filename )
+
+ def isTested( self, filename ):
+ return filename in self.testedFiles
+
+ def description( self ):
+ return "host={0} path={1} platform={2}".format( self.host, self.path, self.platform )
+
+ def download( self, fn, target ):
+ ftp = FTP( self.host )
+ ftp.login()
+ try:
+ ftp.retrbinary( 'RETR {0}/{1}'.format( self.path, fn ), target.write )
+ finally:
+ ftp.close()
+
+class FtpSource:
+ def __init__( self, delay=60*60, tempdir='/tmp' ):
+ self._locations = []
+ self._delay = delay
+ self._tempdir = tempdir
+ self._startDate = None
+
+ def setStartDate( self, date ):
+ self._startDate = date
+
+ def addLocation( self, host, path, platform ):
+ self._locations.append( Location( host, path, platform ) )
+
+ def nextInstaller( self ):
+ while True:
+ for i in self._locations:
+ print( "** Checking FTP location: " + i.description() )
+ files = i.untestedFilesSortedByTimestamp()
+ if self._startDate != None:
+ files = filesNewerThan( files, self._startDate )
+ if len( files ) == 0:
+ continue;
+ fn, ts = files[0]
+ print( "** Downloading new installer: {0}...".format( fn ) )
+ tmp = tempfile.NamedTemporaryFile( dir=self._tempdir, prefix=fn )
+ i.download( fn, tmp )
+ print( "** Download completed. ({0})".format( tmp.name ) )
+ i.lastTested = ts
+ inst = Installer( tmp.name, i.platform, i, ts, tmp )
+ inst.sourceFilename = fn
+ return inst
+ print( "** No installers found. Going to sleep for {0} seconds...".format( self._delay ) )
+ time.sleep( self._delay )
+
+if __name__ == "__main__":
+ src = FtpSource()
+ src.addLocation( "hegel", "/projects/ndk/installers/windows", "windows" )
+ while True:
+ inst = src.nextInstaller()
+ print inst
+ inst.markAsTested()
diff --git a/test-framework/vmware/guest.py b/test-framework/vmware/guest.py
new file mode 100644
index 000000000..b410d366b
--- /dev/null
+++ b/test-framework/vmware/guest.py
@@ -0,0 +1,160 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+import sys, subprocess, ConfigParser, platform, os
+
+# begin Autobuild/helpers/runcommand.py
+
+import os
+import re
+import time
+import sys
+import signal
+from subprocess import Popen
+from threading import Thread
+from subprocess import PIPE
+import subprocess
+import platform
+
+def DebugN( l, m ):
+ pass
+
+def windowskill( pid ):
+ """ replace os.kill on Windows, where it is not available"""
+ Cmd = 'taskkill /PID ' + str( int( pid ) ) + ' /T /F'
+ if os.system( Cmd ) == 0:
+ DebugN( 4, 'windowskill: process ' + str( pid ) + ' killed.' )
+
+def kill( pid, signal ):
+ if 'Windows' in platform.platform():
+ windowskill( pid )
+ else:
+ os.kill( pid, signal )
+
+class CommandRunner( Thread ):
+ def __init__ ( self, Cmd ):
+ Thread.__init__( self )
+ self.__started = None
+ self.mCmd = Cmd
+ self.mOutput = ()
+ self.mPid = -1
+ self.mReturnCode = -1
+ self.mError = ()
+ self.__combinedOutput = False
+
+ def setCombinedOutput(self, combine):
+ if combine: # make sure combine is usable as a boolean
+ self.__combinedOutput = True
+ else:
+ self.__combinedOutput = False
+
+ def getCombineOutput(self):
+ return self.__combinedOutput
+
+ def run( self ):
+ DebugN( 4, 'RunCommand: ' + str( self.mCmd ) )
+ stderrValue = subprocess.PIPE
+ if self.__combinedOutput:
+ stderrValue = subprocess.STDOUT
+ self.__started = True
+#nokia-sdk: changed to shell=False, as shell=True requires manual quoting of args
+ p = Popen ( self.mCmd, shell = False, stdout=subprocess.PIPE, stderr=stderrValue )
+ self.mPid = p.pid
+ self.mOutput, self.mError = p.communicate()
+ self.mReturnCode = p.returncode
+ DebugN( 4, 'ReturnCode of RunCommand: ' + str( p.returncode ) )
+
+ def started(self):
+ return self.__started
+
+ def output( self ):
+ return self.mOutput, self.mError
+
+ def terminate( self ):
+ # FIXME logic?
+ if self.mPid != -1:
+ kill( self.mPid, signal.SIGTERM )
+ if self.mPid == True:
+ self.join( 5 )
+ kill( self.mPid, signal.SIGKILL )
+ self.mPid = -1
+
+
+def RunCommand( Cmd, TimeOutSeconds=-1, CombineOutput = False ):
+ timeoutString = ' without a timeout'
+ if TimeOutSeconds > 0:
+ timeoutString = ' with timeout of ' + str( TimeOutSeconds )
+ combinedOutputString = ' and separate output for stdout and stderr'
+ if CombineOutput:
+ combinedOutputString = ' and combined stdout and stderr output'
+ DebugN ( 3, 'RunCommand: executing ' + str( Cmd ) + timeoutString + combinedOutputString )
+ runner = CommandRunner ( Cmd )
+ runner.setCombinedOutput( CombineOutput )
+ runner.start()
+ # poor man's mutex:
+ while not runner.started():
+ time.sleep( 0.1 )
+# if "CYGWIN" in platform.platform() or 'Windows' in platform.platform():
+# time.sleep( 1 )
+ if TimeOutSeconds == -1:
+ runner.join()
+ else:
+ runner.join( TimeOutSeconds )
+ if runner.isAlive():
+ runner.terminate()
+# if "CYGWIN" in platform.platform() or 'Windows' in platform.platform():
+# time.sleep(1)
+ runner.join( 5 )
+ DebugN( 3, 'RunCommand: command timed out, returncode is ' + str( runner.mReturnCode ) )
+ return ( runner.mReturnCode, runner.output(), True )
+ else:
+ DebugN( 3, 'RunCommand: command completed, returncode is ' + str( runner.mReturnCode ) )
+ return ( runner.mReturnCode, runner.output(), False )
+
+# end Autobuild/helpers/runcommand.py
+
+
+def printUsage():
+ print( "Usage: {0} <outputfile> <timeout> <program> [<args>*]".format( sys.argv[0] ) )
+
+if len( sys.argv ) < 4:
+ printUsage()
+ sys.exit( 1 )
+
+output = sys.argv[1]
+timeout = int( sys.argv[2] )
+cmd = sys.argv[3:]
+
+start = time.clock()
+exitCode, pout, timedOut = RunCommand( cmd, timeout )
+end = time.clock()
+
+if timedOut:
+ exitStatus = 'Timeout'
+else:
+ exitStatus = 'Normal' #TODO: detect crash
+
+config = ConfigParser.SafeConfigParser()
+config.add_section( 'Result' )
+config.set( 'Result', 'ExitCode', str( exitCode ) )
+config.set( 'Result', 'ExitStatus', exitStatus )
+config.set( 'Result', 'Filename', cmd[0] )
+config.set( 'Result', 'Arguments', " ".join( cmd[1:] ) )
+config.set( 'Result', 'Timeout', str( timeout ) )
+config.set( 'Result', 'ExecutionTime', str( end - start ) )
+config.set( 'Result', 'Stdout', pout[0] )
+config.set( 'Result', 'Stderr', pout[1] )
+
+config.add_section( 'Platform' )
+config.set( 'Platform', 'system', platform.system() )
+config.set( 'Platform', 'release', platform.release() )
+config.set( 'Platform', 'version', platform.version() )
+config.set( 'Platform', 'machine', platform.machine() )
+
+with open( output, 'w' ) as configFile:
+ config.write(configFile )
+
+sys.exit( exitCode )
+
+
+
+
diff --git a/test-framework/vmware/guestconfig.py b/test-framework/vmware/guestconfig.py
new file mode 100644
index 000000000..f80b1c73d
--- /dev/null
+++ b/test-framework/vmware/guestconfig.py
@@ -0,0 +1,11 @@
+import os, ConfigParser, tempfile, platform
+config = ConfigParser.SafeConfigParser()
+config.add_section('Guest')
+config.set('Guest', 'temp_dir', str(tempfile.gettempdir()))
+config.set('Guest', 'path_sep', os.sep)
+config.set('Guest', 'system', platform.system())
+config.set('Guest', 'release', platform.release())
+config.set('Guest', 'version', platform.version())
+config.set('Guest', 'machine', platform.machine())
+with open('example.cfg', 'wb') as configFile:
+ config.write(configFile)
diff --git a/test-framework/vmware/reporter.py b/test-framework/vmware/reporter.py
new file mode 100644
index 000000000..57366a8fe
--- /dev/null
+++ b/test-framework/vmware/reporter.py
@@ -0,0 +1,96 @@
+import datetime, socket, sys, traceback
+from xml.sax.saxutils import XMLGenerator
+from xml.sax.xmlreader import AttributesNSImpl
+import result
+from result import exitStatusAsString
+from xmlutils import startElement, endElement, writeElement
+
+class Reporter:
+ def __init__( self ):
+ pass
+
+ def reportException( self ):
+ sys.stderr.write( traceback.format_exc( 15 ) + '\n' )
+
+ def reportResult( self, result ):
+ try:
+ self.toXml( result, sys.stdout )
+ finally:
+ sys.stdout.flush()
+
+ def toXml( self, result, out ):
+ atom = "http://www.w3.org/2005/Atom"
+ tf = "http://sdk.nokia.com/test-framework/ns/1.0"
+
+ gen = XMLGenerator( out, 'utf-8' )
+ gen.startDocument()
+ gen.startPrefixMapping( 'atom', atom)
+ gen.startPrefixMapping( 'tf', tf )
+
+ startElement( gen, atom, 'entry' )
+
+ writeElement( gen, atom, 'title', result.constructTitle() )
+ writeElement( gen, atom, 'updated', datetime.datetime.now().isoformat() )
+
+ writeElement( gen, tf, 'errorSummary', exitStatusAsString( result.status() ) )
+
+ writeElement( gen, tf, 'host', socket.gethostname() )
+ if result._testStart != None:
+ writeElement( gen, tf, 'testStart', result._testStart.isoformat() )
+ else:
+ result._internalErrors.append( "Result generator: no start timestamp found." )
+
+ if result._testEnd != None:
+ writeElement( gen, tf, 'testEnd', result._testEnd.isoformat() )
+ else:
+ result._internalErrors.append( "Result generator: no end timestamp found." )
+
+
+ startElement( gen, tf, 'installer' )
+ writeElement( gen, tf, 'sourceUrl', result._installerSourceLocation )
+ writeElement( gen, tf, 'platform', result._installerTargetPlatform )
+ #TODO revision
+ endElement( gen, tf, 'installer' )
+
+ if result._testcase != None:
+ startElement( gen, tf, 'testCase' )
+ writeElement( gen, tf, 'name', result._testcase.name() )
+ writeElement( gen, tf, 'path', result._testcase.path() )
+ writeElement( gen, tf, 'installScript', result._testcase.installscript() )
+ endElement( gen, tf, 'testCase' )
+ else:
+ result._internalErrors.append( "Result generator: No test case given." )
+
+ if result._installationResult != None:
+ startElement( gen, tf, 'installationResult' )
+ writeElement( gen, tf, 'exitCode', str( result._installationResult.exitCode ) )
+ writeElement( gen, tf, 'exitStatus', exitStatusAsString( result._installationResult.exitStatus ) )
+ endElement( gen, tf, 'installationResult' )
+ else:
+ result._internalErrors.append( "Result generator: No installation result given." )
+ startElement( gen, tf, 'checkerResult' )
+
+ for err in result._checkerErrors:
+ writeElement( gen, tf, 'error', err )
+ endElement( gen, tf, 'checkerResult' )
+
+ startElement( gen, tf, 'virtualMachine' )
+ writeElement( gen, tf, 'path', result._vm.vmxPath() )
+ writeElement( gen, tf, 'platform', result._vm.ostype() )
+ writeElement( gen, tf, 'snapshot', result._vm.snapshot() )
+ endElement( gen, tf, 'virtualMachine' )
+
+ startElement( gen, tf, 'internalErrors' )
+ for i in result._internalErrors:
+ writeElement( gen, tf, 'internalError', str( i ) )
+
+ endElement( gen, tf, 'internalErrors' )
+
+ if result._errorSnapshot != None:
+ writeElement( gen, tf, 'errorSnapshot', result._errorSnapshot )
+
+ endElement( gen, atom, 'entry' )
+
+ gen.endDocument()
+
+
diff --git a/test-framework/vmware/result.py b/test-framework/vmware/result.py
new file mode 100644
index 000000000..07d4832aa
--- /dev/null
+++ b/test-framework/vmware/result.py
@@ -0,0 +1,148 @@
+# -*- coding: utf-8 -*-
+import control, testcase, datetime, source, tempfile, traceback, utils
+from source import Installer
+
+class ExecutionResult:
+ #return codes:
+ Success = 0
+ InstallationFailed = 1
+ InstallationCanceled = 2
+
+ #exit status:
+ Normal = 0
+ Crash = 1
+ Timeout = 2
+
+ def __init__( self, exitCode, exitStatus, executionTime ):
+ self.exitCode = exitCode
+ self.exitStatus = exitStatus
+ self.executionTime = executionTime
+
+ def hasError( self ):
+ return self.exitCode != 0 or self.exitStatus != ExecutionResult.Normal
+
+class CheckerResult:
+ Passed = 0
+ Failed = 1
+ NotRun = 2
+
+ def hasError( list ):
+ #the following would more efficient with something find_if-like (stopping if test with error is found)
+ return len( [x for i in list if i.hasError() ] ) > 0
+
+ def __init__( self, name, result, errorString ):
+ self.name = utils.randomString( 3 ) + '_' + name
+ self.result = result
+ self.errorString = errorString
+
+ def hasError( self ):
+ return self.result != CheckerResult.Passed
+
+class StepResult:
+ def __init__( self, executionResult, checkerResults ):
+ self.executionResult = executionResult
+ self.checkerResults = checkerResults
+
+ def hasCheckerErrors( self ):
+ return CheckerResult.hasError( self.checkerResults )
+
+def exitStatusFromString( s ):
+ if s == 'Crash':
+ return ExecutionResult.Crash
+ if s == 'Timeout':
+ return ExecutionResult.Timeout
+ if s == 'Normal':
+ return ExecutionResult.Normal
+ raise control.ControlException( "Unknown exit status string: {0}".format( s ) )
+
+#there is probably a cooler way with introspection and stuff:
+def exitStatusAsString( status ):
+ if status == ExecutionResult.Crash:
+ return 'Crash'
+ if status == ExecutionResult.Normal:
+ return 'Normal'
+ if status == ExecutionResult.Timeout:
+ return 'Timeout'
+ raise control.ControlException( "Unknown exit status: {0}".format( status ) )
+
+class Result:
+
+ NoError=0 # Everything ok
+ InstallerError=1 #Installer failed, or post-conditions not met
+ InternalError=2 #Internal test framework error
+
+ def __init__( self ):
+ self._internalErrors = []
+ self._stepResults = []
+ self._installer = None
+ self._testStart = None
+ self._testEnd = None
+ self._testcase = None
+ self._vm = None
+ self._errorSnapshot = None
+ self._revision = "revision-todo"
+
+ def setInstaller( self, installer ):
+ self._installer = installer
+
+ def testStarted( self ):
+ self._testStart = datetime.datetime.now()
+
+ def testFinished( self ):
+ self._testEnd = datetime.datetime.now()
+
+ def setTestCase( self, testcase ):
+ self._testcase = testcase
+
+ def setErrorSnapshot( self, name ):
+ self._errorSnapshot = name
+
+ def setVirtualMachine( self, vm ):
+ self._vm = vm
+
+ def addInternalError( self, errstr ):
+ self._internalErrors.append( errstr )
+
+ def hasInternalErrors( self ):
+ return len( self._internalErrors ) > 0
+
+ def addException( self ):
+ s = 'Unexpected exception: {0}'.format( traceback.format_exc( 15 ) )
+ self._internalErrors.append( s )
+
+ def hasCheckerErrors( self ):
+ for step in self._stepResults:
+ if CheckerResult.hasError( step.checkerResults ):
+ return True
+ return False
+
+
+ def addStepResult( self, result ):
+ self._stepResults.append( result )
+
+ def status( self ):
+ if len( self._internalErrors ) > 0:
+ return Result.InternalError
+ if len( self._stepResults ) == 0:
+ return Result.InternalError
+ for step in self._stepResults:
+ if step.executionResult.exitCode != ExecutionResult.Success or step.exitStatus != ExecutionResult.Normal:
+ return Result.InstallerError
+ if step.hasCheckerErrors():
+ return Result.InstallerError
+ #TODO: check test results
+ return Result.NoError
+
+ def statusAsNiceString( self ):
+ s = self.status()
+ if s == Result.InternalError:
+ return "Internal framework errors"
+ if s == Result.InstallerError:
+ return "Installation error"
+ return "OK"
+
+ def constructTitle( self ):
+ smiley = ":-)" if self.status() == Result.NoError else ":-("
+
+ return "{0}: {1} on {2} testing {3} - {4} {5}".format( self._revision, utils.basename( self._installerSourceLocation ), self._vm.name(), self._testcase.name(), self.statusAsNiceString(), smiley )
+ \ No newline at end of file
diff --git a/test-framework/vmware/run-test.py b/test-framework/vmware/run-test.py
new file mode 100644
index 000000000..c063f3e70
--- /dev/null
+++ b/test-framework/vmware/run-test.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+import sys, os, ConfigParser, optparse, time, virtualmachine, utils
+
+# TODO: - Look in sensible locations for python in the guest VM
+# - Try and work-around VMware Fusion needing to be closed
+
+
+def check_option( option, optionName ):
+ if option:
+ return
+ print("** Could not find a value for {0}".format(optionName) )
+ print("** Please specify it on the commandline or configuration file.")
+ print
+ optionParser.print_help();
+ sys.exit(-1)
+
+def die(message):
+ print "** " + str(message)
+ sys.exit(1);
+
+#
+# Parse options
+#
+
+optionParser = optparse.OptionParser(usage="%prog [options] vmx-file", version="%prog 0.9")
+optionParser.add_option("-u", "--username", dest="username", help="username for VM", metavar="USERNAME" )
+optionParser.add_option("-p", "--password", dest="password", help="password for VM", metavar="PASSWORD" )
+optionParser.add_option("-S", "--script", dest="script", help="script for VM", metavar="SCRIPT" )
+optionParser.add_option("-s", "--snapshot", dest="snapshot", help="snapshot for VM", metavar="SNAPSHOT" )
+optionParser.add_option("-P", "--python", dest="python", help="python location in VM", metavar="PYTHON" )
+optionParser.add_option("-v", "--vmrun", dest="vmrun", help="vmrun command for VM", metavar="VMRUN")
+optionParser.add_option("-c", "--config", dest="config", help="configuration file for VM", metavar="CONFIG")
+optionParser.add_option("-i", "--installer", dest="installer", help="installer executable to command inside the VM", metavar="INSTALLER")
+optionParser.add_option("-e", "--installscript", dest="installscript", help="QtScript script to use for non-interactive installation", metavar="INSTALLSCRIPT")
+
+(options, args) = optionParser.parse_args()
+
+try:
+ options.vmx = args[0]
+except IndexError:
+ options.vmx = None
+
+options.ostype = None
+options.guestTempDir = None
+
+config = ConfigParser.SafeConfigParser()
+if options.config:
+ print("** Reading config: " + options.config )
+ config.read( options.config )
+else:
+ print("** No config given")
+
+options.username = utils.get_config_option( config, options.username, "username", "nokia" )
+options.password = utils.get_config_option( config, options.password, "password", "nokia" )
+options.script = utils.get_config_option( config, options.script, "script", "guest.py" )
+options.python = utils.get_config_option( config, options.python, "python", "c:/python26/python.exe" )
+options.snapshot = utils.get_config_option( config, options.snapshot, "snapshot", "base" )
+options.vmrun = utils.get_config_option( config, options.vmrun, "vmrun" )
+options.vmx = utils.get_config_option( config, options.vmx, "vmx" )
+options.guestTempDir = utils.get_config_option( config, options.guestTempDir, "tempDir", "c:\\windows\\temp" )
+options.ostype = utils.get_config_option( config, options.ostype, "os", "windows" )
+
+check_option( options.vmx, "vmx-file" )
+
+# Search the PATH and the a few extra locations for 'vmrun'
+if not options.vmrun:
+ options.vmrun = utils.findVMRun()
+
+check_option( options.vmrun, "VMRUN" )
+check_option( options.installer, "INSTALLER" )
+check_option( options.installscript, "INSTALLSCRIPT" )
+
+#
+# VM actions
+#
+
+vm = virtualmachine.VirtualMachine( options.vmrun, options.vmx, options.username, options.password, options.guestTempDir, options.ostype )
+
+snapshotExists = vm.snapshotExists( options.snapshot )
+if not snapshotExists:
+ die("Could not find '{0}' snapshot, please create it in the VM.".format( options.snapshot ) )
+
+revertStatus, _ = vm.revertToSnapshot( options.snapshot )
+if revertStatus != 0:
+ die("Failed to revert to snapshot")
+
+time.sleep( 5 ) # Trying to avoid a possible race between restore and start
+
+vm.start()
+
+try:
+ pythonStatus, _ = vm.command("Checking for guest installed Python", "fileExistsInGuest", options.python)
+ if pythonStatus != 0:
+ raise virtualmachine.VMException("Please install Python in the VM from http://www.python.org/download/")
+
+ wrapperpath = vm.copyToTemp( 'guest.py' )
+ installerpath = vm.copyToTemp( options.installer )
+ scriptpath = vm.copyToTemp( options.installscript )
+ outputpath = vm.mkTempPath( 'output.log' )
+ vm.command( 'Execute installer', "runProgramInGuest", "-interactive -activeWindow '{0}' '{1}' '{2}' '{3}' --script '{4}'".format( options.python, wrapperpath, outputpath, installerpath, scriptpath ) )
+
+ vm.copyFromTemp( 'output.log', 'output.log' )
+ result = ConfigParser.SafeConfigParser()
+ result.read( 'output.log' )
+ print( "Installer exit code: " + result.get( 'Result', 'ExitCode' ) )
+ #TODO parse output and do something with it
+
+except virtualmachine.VMException as exception:
+ die( exception )
+finally:
+ vm.kill()
diff --git a/test-framework/vmware/run.py b/test-framework/vmware/run.py
new file mode 100644
index 000000000..f02571051
--- /dev/null
+++ b/test-framework/vmware/run.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+import ConfigParser, datetime, optparse, os, sys
+from functools import partial
+import cdashreporter, control, ftpsource, source, reporter, utils
+
+def die( msg ):
+ sys.stderr( msg + '\n' )
+ sys.exit( 1 )
+
+optionParser = optparse.OptionParser(usage="%prog [options] configfile installer0 [installer1 ...]", version="%prog 0.1")
+optionParser.add_option("-r", "--vmrun", dest="vmrun", help="vmrun executable to use", metavar="VMRUN" )
+optionParser.add_option("-s", "--only-since", dest="since", help="test only installers newer than timestamp (YYYY-MM-DD or YYYY-MM-DD-hh-mm)", metavar="SINCE" )
+optionParser.add_option("-c", "--checkerInstallation", dest="checkerInstallation", help="checker installation to use for post-installation checks", metavar="CHECKERINSTALLATION" )
+(options, args) = optionParser.parse_args()
+
+try:
+ configpath = utils.makeAbsolutePath( args[0], os.getcwd() )
+except IndexError:
+ optionParser.print_usage( sys.stderr )
+ sys.exit( 1 )
+
+config = ConfigParser.SafeConfigParser()
+config.read( configpath )
+
+#make an unary functor to create absolute paths
+abspath = partial( utils.makeAbsolutePath, relativeTo=os.path.dirname( configpath ) )
+
+vmrun = utils.get_config_option( config, options.vmrun, "vmrun", utils.findVMRun() )
+useGui = utils.get_config_option( config, None, "gui", "true" ).lower() == "true"
+createErrorSnapshots = utils.get_config_option( config, None, "createErrorSnapshots", "true" ).lower() == "true"
+hostType = utils.get_config_option( config, None, "type", "", "Host" )
+hostLocation = utils.get_config_option( config, None, "location", "", "Host" )
+hostUsername = utils.get_config_option( config, None, "username", "", "Host" )
+hostPassword = utils.get_config_option( config, None, "password", "", "Host" )
+
+cdashHost = utils.get_config_option( config, None, "host", "", "CDash" )
+cdashLocation = utils.get_config_option( config, None, "location", "", "CDash" )
+cdashProject = utils.get_config_option( config, None, "project", "", "CDash" )
+
+if vmrun == None:
+ die( "Could not find vmrun executable. Please specify it in the config file (vmrun=...) or via the --vmrun option" )
+
+checkerInstallation = utils.get_config_option( config, options.checkerInstallation, "checkerInstallation" )
+if checkerInstallation == None:
+ die( "Could not find checker installation. Please specify it in the config file (checkerInstallation=...) or via the --checkerInstallation option" )
+
+#apply functor to list to get absolute paths:
+testcases = map( abspath, utils.get_enumerated_config_option( config, 'testcase' ) )
+if len( testcases ) == 0:
+ die( "No testcases specified. Please specify at least one test case in the configuration" )
+
+vms = map( abspath, utils.get_enumerated_config_option( config, 'vm' ) )
+if len( vms ) == 0:
+ die( "No VMs specified. Please specify at least one VM in the configuration" )
+
+installers = args[1:]
+
+if len( installers ) > 0:
+ source = source.Source()
+ for i in installers:
+ source.addDummy( 5, i )
+else:
+ source = ftpsource.FtpSource()
+ if options.since:
+ try:
+ sdt = datetime.datetime.strptime( options.since, '%Y-%m-%d' )
+ except ValueError:
+ sdt = datetime.datetime.strptime( options.since, '%Y-%m-%d-%H-%M' )
+ source.setStartDate( sdt )
+ found = True
+ nextsec = 0
+ while found:
+ sec = "Source{0}".format( nextsec )
+ nextsec += 1
+ try:
+ host = config.get( sec, "host" )
+ path = config.get( sec, "path" )
+ platform = config.get( sec, "platform" )
+ print( "** Add FTP location {0}:{1} ({2})".format( host, path, platform ) )
+ source.addLocation( host, path, platform )
+ except ConfigParser.NoSectionError:
+ found = False
+
+cdashHost = utils.get_config_option( config, None, "host", "", "CDash" )
+cdashLocation = utils.get_config_option( config, None, "location", "", "CDash" )
+cdashProject = utils.get_config_option( config, None, "project", "", "CDash" )
+
+if len( cdashHost ) > 0:
+ reporter = cdashreporter.CDashReporter( cdashHost, cdashLocation, cdashProject )
+else:
+ reporter = reporter.Reporter()
+
+control = control.Control( vmrun, checkerInstallation, source, reporter )
+control.setGuiEnabled( useGui )
+control.setCreateErrorSnapshots( createErrorSnapshots )
+
+if len( hostType ) > 0:
+ control.setRemoteHost( hostType, hostLocation, hostUsername, hostPassword )
+
+for i in vms:
+ control.addVM( i )
+for i in testcases:
+ control.addTestCase( i )
+
+control.run()
diff --git a/test-framework/vmware/source.py b/test-framework/vmware/source.py
new file mode 100644
index 000000000..fe067ab4e
--- /dev/null
+++ b/test-framework/vmware/source.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+import os, time
+
+class Installer:
+ def __init__( self, path, platform, location, timestamp=None, tempfile=None ):
+ self.path = path
+ self.platform = platform
+ self.error = None
+ self.timestamp = timestamp
+ self.tempfile = tempfile
+ self.sourceLocation = location
+
+ def markAsTested( self ):
+ self.sourceLocation.markAsTested( self.sourceFilename )
+
+class Source:
+ def __init__( self ):
+ self._dummies = []
+
+ def nextInstaller( self ):
+ if len( self._dummies ) == 0:
+ return None
+ delay, path = self._dummies.pop()
+ time.sleep( delay )
+ if os.path.exists( path ):
+ inst = Installer( path, "linux", None )
+ inst.sourceFilename = path
+ return inst
+ else:
+ inst = Installer( None, None )
+ #simulating download errors
+ inst.error = "Installer '{0}' does not exist".format( path )
+ return inst
+
+ def addDummy( self, delay, path ):
+ self._dummies.insert( 0, ( delay, path ) )
diff --git a/test-framework/vmware/testcase.py b/test-framework/vmware/testcase.py
new file mode 100644
index 000000000..65fd83880
--- /dev/null
+++ b/test-framework/vmware/testcase.py
@@ -0,0 +1,70 @@
+import ConfigParser, os, utils
+
+class Step:
+ def __init__( self, installscript, checkerTestDir, timeout ):
+ self._installscript = installscript
+ self._checkerTestDir = checkerTestDir
+ self._timeout = timeout
+
+ def installscript( self ):
+ return self._installscript
+
+ def checkerTestDir( self ):
+ return self._checkerTestDir
+
+ def timeout( self ):
+ return self._timeout
+
+class TestCase:
+ def __init__( self, path ):
+ self._steps = []
+ config = ConfigParser.SafeConfigParser()
+ config.read( path )
+ self._path = path
+ self._platforms = []
+ found = True
+ stepNum = 0
+ while found:
+ sec = "Step{0}".format( stepNum )
+ if not config.has_section( sec ):
+ found = False
+ continue
+
+ stepNum += 1
+ installscript = utils.makeAbsolutePath( utils.get_config_option( config, None, "installscript", None, sec ), os.path.dirname( path ) )
+ checkerTestDir = utils.get_config_option( config, None, "checkerTestDir", None, sec )
+ checkerTestDir = utils.makeAbsolutePath( checkerTestDir, os.path.dirname( path ) ) if checkerTestDir else ""
+ timeout = int( utils.get_config_option( config, None, "timeout", 60 * 60, sec ) )
+ self._steps.append( Step( installscript, checkerTestDir, timeout ) )
+
+ self._name = utils.get_config_option( config, None, "name", utils.basename( path ) )
+ self._targetDirectory = utils.get_config_option( config, None, "targetDirectory", "" )
+ self._maintenanceToolLocation = utils.get_config_option( config, None, "maintenanceToolLocation", "" )
+ platforms = utils.get_config_option( config, None, "platforms" )
+ if platforms != None:
+ self._platforms = platforms.split( ',' )
+
+ def supportsPlatform( self, platform ):
+ return platform in self._platforms
+
+ def installerTimeout( self ):
+ return self._installerTimeout
+
+ def platforms( self ):
+ return self._platforms
+
+ def name( self ):
+ return self._name
+
+ def targetDirectory( self ):
+ return self._targetDirectory
+
+ def steps( self ):
+ return self._steps
+
+ def path( self ):
+ return self._path
+
+ def maintenanceToolLocation( self ):
+ return self._maintenanceToolLocation
+ \ No newline at end of file
diff --git a/test-framework/vmware/utils.py b/test-framework/vmware/utils.py
new file mode 100644
index 000000000..24529be40
--- /dev/null
+++ b/test-framework/vmware/utils.py
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+import ConfigParser, inspect, os, string, sys
+from random import Random
+
+def findVMRun():
+ searchDirectories = os.environ['PATH'].split(os.pathsep)
+ searchDirectories.append("/Library/Application Support/VMware Fusion")
+ for directory in searchDirectories:
+ possibleFile = os.path.join(directory, 'vmrun')
+ if os.path.isfile(possibleFile):
+ return possibleFile
+ return None
+
+def basename( path ):
+ if path.endswith( os.path.sep ):
+ return os.path.basename( path[0,-1] )
+ else:
+ return os.path.basename( path )
+
+def makeAbsolutePath( path, relativeTo ):
+ if os.path.isabs( path ) or relativeTo == None:
+ return path
+ else:
+ return relativeTo + os.sep + path
+
+def execution_path( filename ):
+ return os.path.join( os.path.dirname( inspect.getfile( sys._getframe( 1 ) ) ), filename )
+
+def unixPathSep( s ):
+ return s.replace( '\\', '/' )
+
+def get_config_option( config, initial, option, default=None, section="General" ):
+ # If there's already a valid option from the commandline,
+ # override the value from the configuration file.
+ if initial != None:
+ print( "** Overridden {0}={1}".format( option, initial ) )
+ return initial
+ try:
+ tmp = config.get( section, option )
+ print( "** Read config value {0}={1}".format( option, tmp ) )
+ return tmp
+ except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
+ print( "** Using default value {0}={1}".format( option, default ) )
+ return default
+
+def get_enumerated_config_option( config, option ):
+ res = []
+ i = 0
+ while True:
+ key = option + str( i )
+ val = get_config_option( config, None, key )
+ if val == None:
+ print res
+ return res
+ res.append( val )
+ i += 1
+
+def randomString( length ):
+ return ''.join( Random().sample( string.letters + string.digits, length ) )
diff --git a/test-framework/vmware/virtualmachine.py b/test-framework/vmware/virtualmachine.py
new file mode 100644
index 000000000..7507cd531
--- /dev/null
+++ b/test-framework/vmware/virtualmachine.py
@@ -0,0 +1,177 @@
+# -*- coding: utf-8 -*-
+import commands, ConfigParser, os, string, utils, platform
+
+class VMException(Exception):
+ def __init__(self, value):
+ self.value = value
+ def __str__(self):
+ return repr(self.value)
+
+class VirtualMachine:
+ def __init__( self, vmrun, vmx, username, password, tempDir, ostype ):
+ self._vmrun = vmrun
+ self._vmx = vmx
+ self._username = username
+ self._password = password
+ self._tempDir = tempDir
+ self._ostype = ostype
+ self._useGui = True
+ self._name = "no name"
+ self._hostType = ""
+ self._hostLocation = None
+ self._hostUsername = None
+ self._hostPassword = None
+
+ def setGuiEnabled( self, usegui ):
+ self._useGui = usegui
+
+ def name( self ):
+ return self._name
+
+ def isRemote( self ):
+ return len( self._hostType ) > 0;
+
+ def setRemoteHost( self, type, loc, user, pw ):
+ self._hostType = type
+ self._hostLocation = loc
+ self._hostUsername = user
+ self._hostPassword = pw
+
+
+ def command( self, message, command, parameters=None ):
+ if len( self._hostType ) > 0:
+ remote = "-T {0} -h '{1}' -u {2} -p {3}".format( self._hostType, self._hostLocation, self._hostUsername, self._hostPassword )
+ else:
+ remote = ""
+ vmcommand = "'{0}' {1} -gu {2} -gp {3} {4} '{5}' ".format( self._vmrun, remote, self._username, self._password, command, self._vmx )
+ if parameters:
+ vmcommand += parameters
+ print "** " + message
+ status, output = commands.getstatusoutput(vmcommand)
+ if status != 0:
+ print "* Return code: {0}".format(status)
+ print "* Output:"
+ print output
+ print
+ return status, output
+
+ def copyFileToGuest( self, source, target ):
+ #TODO convert paths to guest system?
+ status, _ = self.command( 'Copying {0} to {1}'.format( source, target ), 'copyFileFromHostToGuest', "'{0}' '{1}'".format( source, target ) )
+ if status != 0:
+ raise VMException( "Could not copy from host to guest: source {0} target {1}".format( source, target ) )
+
+ def copyFileFromGuest( self, source, target ):
+ #TODO convert paths to guest system?
+ status, _ = self.command( 'Copying {0} to {1}'.format( source, target ), 'copyFileFromGuestToHost', "'{0}' '{1}'".format( source, target ) )
+ if status != 0:
+ raise VMException( "Could not copy from guest to host: source {0} target {1}".format( source, target ) )
+
+
+ def ostype( self ):
+ return self._ostype
+
+ def vmxPath( self ):
+ return self._vmx
+
+ def mkTempPath( self, filename ):
+ return self._tempDir + self.pathSep() + utils.basename( filename )
+
+ def pathSep( self ):
+ if self._ostype == "windows":
+ return "\\"
+ else:
+ return "/"
+
+ def copyToTemp( self, source, targetN=None ):
+ if source == None or len( string.strip( source ) ) == 0:
+ return None
+ if targetN == None:
+ targetN = source
+
+ target = self.mkTempPath( targetN )
+ self.copyFileToGuest( source, target )
+ return target
+
+ def copyFromTemp( self, filename, target ):
+ source = self.mkTempPath( filename )
+ self.copyFileFromGuest( source, target )
+ return target
+
+ def start( self ):
+ arg = "gui" if self._useGui else "nogui"
+ self.command("Starting VM ({0})".format( arg ), "start", arg )
+
+ def kill( self ):
+ self.command("Stopping VM", "stop", "hard" )
+
+ def isRunning( self ):
+ _, vmList = self.command("Checking running VMs", "list")
+ _, _, vmFilename = self._vmx.rpartition( os.sep )
+ return vmList.find(vmFilename) is not -1
+
+ def snapshotExists( self, snapshot ):
+ _, output = self.command("Checking snapshots", "listSnapshots")
+ snapshotList = output.split("\n")
+ # Remove first entry which contains number of snapshots
+ snapshotList.pop(0)
+ return snapshotList.count( snapshot ) > 0
+
+ def checkPythonInstalled( self ):
+ pp = utils.unixPathSep( self._python )
+ pythonStatus, _ = self.command("Checking for guest installed Python", "fileExistsInGuest", pp )
+ print pythonStatus
+ if pythonStatus != 0:
+ raise VMException("Could not find python in {0}: Please specify the path/install Python in the VM from http://www.python.org/download/".format( pp ) )
+ else:
+ print("Python found ({0})".format( pp ) )
+
+ def python( self ):
+ return self._python
+
+ def snapshot( self ):
+ return self._snapshot
+
+ def revertToSnapshot( self, snapshot=None ):
+ if snapshot != None:
+ snap = snapshot
+ else:
+ snap = self._snapshot
+ # VMware Fusion needs to be closed before you can restore snapshots so kill it
+ if ( platform.system() == "Darwin" ):
+ commands.getstatusoutput( "ps x|grep 'VMware Fusion'|cut -d ' ' -f1|xargs kill" )
+ return self.command("Reverting to '{0}' snapshot".format( snap ), "revertToSnapshot", snap )
+
+ def createSnapshot( self, name ):
+ return self.command("Creating error snapshot '{0}'".format( name ), "snapshot", name )
+
+
+def fromVMRunAndPath( vmrun, path ):
+ config = ConfigParser.SafeConfigParser()
+ config.read( path )
+
+ hostType = utils.get_config_option( config, None, "type", "", "Host" )
+ hostLocation = utils.get_config_option( config, None, "location", "", "Host" )
+ hostUsername = utils.get_config_option( config, None, "username", "", "Host" )
+ hostPassword = utils.get_config_option( config, None, "password", "", "Host" )
+
+ vmxVal = utils.get_config_option( config, None, "vmx" )
+ if not len( hostType ) == 0:
+ vmx = utils.makeAbsolutePath( vmxVal, os.path.dirname( path ) )
+ else:
+ vmx = vmxVal
+
+ username = utils.get_config_option( config, None, "username", "nokia" )
+ password = utils.get_config_option( config, None, "password", "nokia" )
+ tempDir = utils.get_config_option( config, None, "tempDir", "c:\\windows\\temp" )
+ ostype = utils.get_config_option( config, None, "os", "windows" )
+
+ vm = VirtualMachine( vmrun, vmx, username, password, tempDir, ostype )
+ vm._name = utils.get_config_option( config, None, "name", utils.basename( path ) )
+ vm._snapshot = utils.get_config_option( config, None, "snapshot", "base" )
+ vm._python = utils.get_config_option( config, None, "python", "c:/python26/python.exe" )
+ vm._hostType = hostType
+ vm._hostLocation = hostLocation
+ vm._hostUsername = hostUsername
+ vm._hostPassword = hostPassword
+ return vm
diff --git a/test-framework/vmware/xmlutils.py b/test-framework/vmware/xmlutils.py
new file mode 100644
index 000000000..609412309
--- /dev/null
+++ b/test-framework/vmware/xmlutils.py
@@ -0,0 +1,13 @@
+def startElement( gen, ns, name, attrsb={} ):
+ attrs = {}
+ for i in attrsb:
+ attrs[(None, i)] = attrsb[i]
+ gen.startElementNS( ( ns, name ), name, attrs )
+
+def endElement( gen, ns, name ):
+ gen.endElementNS( ( ns, name ), name )
+
+def writeElement( gen, ns, name, text, attrs={} ):
+ startElement( gen, ns, name, attrs )
+ gen.characters( text )
+ endElement( gen, ns, name )