{"id":299618,"date":"2020-03-03T15:00:43","date_gmt":"2020-03-03T15:00:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299618"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299618","title":{"rendered":"Zip-\u0444\u0430\u0439\u043b\u044b: \u0438\u0441\u0442\u043e\u0440\u0438\u044f, \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/mailru\/blog\/490790\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bo\/tw\/dr\/botwdrbtegpbnpnwmy7id56fbaa.jpeg\"><\/div>\n<p>  \u041c\u043d\u0435 \u0434\u0430\u0432\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u0441\u0436\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 Zip-\u0444\u0430\u0439\u043b\u0430\u0445. \u041e\u0434\u043d\u0430\u0436\u0434\u044b \u044f \u0440\u0435\u0448\u0438\u043b \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u0441\u0442\u0432\u043e: \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0436\u0430\u0442\u0438\u0435, \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e Zip-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c \u0432 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435 \u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u043b\u0430\u0436\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0435\u0440\u0451\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0431\u0438\u0442\u044b \u0432 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<p>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 Zip-\u0444\u0430\u0439\u043b\u044b \u0438 \u0441\u0445\u0435\u043c\u0430 \u0441\u0436\u0430\u0442\u0438\u044f: LZ77-\u0441\u0436\u0430\u0442\u0438\u0435, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c Deflate \u0438 \u043f\u0440\u043e\u0447\u0435\u0435. \u0412\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 \u0421. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043b\u0435\u0436\u0438\u0442 \u0442\u0443\u0442: <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/hwzip-1.0.zip\">hwzip-1.0.zip<\/a>.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u042f \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d<a href=\"https:\/\/twitter.com\/angealbertini\"> Ange Albertini<\/a>,<a href=\"https:\/\/gynvael.coldwind.pl\"> Gynvael Coldwind<\/a>,<a href=\"https:\/\/fgiesen.wordpress.com\"> Fabian Giesen<\/a>,<a href=\"https:\/\/www.instagram.com\/dr.jonas.skeppstedt\"> Jonas Skeppstedt<\/a> (<a href=\"https:\/\/www.jonasskeppstedt.net\">web<\/a>),<a href=\"https:\/\/primianotucci.com\"> Primiano Tucci<\/a> \u0438 <a href=\"https:\/\/twitter.com\/thakis\">Nico Weber<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043b\u0438 \u0446\u0435\u043d\u043d\u044b\u0435 \u043e\u0442\u0437\u044b\u0432\u044b \u043d\u0430 \u0447\u0435\u0440\u043d\u043e\u0432\u0438\u043a\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<h2>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"#1\">\u0418\u0441\u0442\u043e\u0440\u0438\u044f<\/a><br \/> \n<ul>\n<li><a href=\"#2\">PKZip<\/a><\/li>\n<li><a href=\"#3\">Info-ZIP and zlib<\/a><\/li>\n<li><a href=\"#4\">WinZip<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#5\">\u0421\u0436\u0430\u0442\u0438\u0435 Lempel-Ziv (LZ77)<\/a><\/li>\n<li><a href=\"#6\">\u041a\u043e\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/a><br \/> \n<ul>\n<li><a href=\"#7\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/a><\/li>\n<li><a href=\"#8\">\u041a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u0434\u044b \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/a><\/li>\n<li><a href=\"#9\">\u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#10\">Deflate<\/a><br \/> \n<ul>\n<li><a href=\"#11\">\u0411\u0438\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438<\/a><\/li>\n<li><a href=\"#12\">\u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 (Inflation)<\/a><br \/> \n<ul>\n<li><a href=\"#13\">\u041d\u0435\u0441\u0436\u0430\u0442\u044b\u0435 Deflate-\u0431\u043b\u043e\u043a\u0438<\/a><\/li>\n<li><a href=\"#14\">Deflate-\u0431\u043b\u043e\u043a\u0438 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/a><\/li>\n<li><a href=\"#15\">Deflate-\u0431\u043b\u043e\u043a\u0438 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u0434\u043e\u0432 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#16\">\u0421\u0436\u0430\u0442\u0438\u0435 (Deflation)<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#17\">\u0424\u043e\u0440\u043c\u0430\u0442 Zip-\u0444\u0430\u0439\u043b\u043e\u0432<\/a><br \/> \n<ul>\n<li><a href=\"#18\">\u041e\u0431\u0437\u043e\u0440<\/a><\/li>\n<li><a href=\"#19\">\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/a><br \/> \n<ul>\n<li><a href=\"#20\">\u041a\u043e\u043d\u0435\u0446 \u0437\u0430\u043f\u0438\u0441\u0438 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430<\/a><\/li>\n<li><a href=\"#21\">\u0426\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0430\u0439\u043b\u0430<\/a><\/li>\n<li><a href=\"#22\">\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0430\u0439\u043b\u0430<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#23\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Zip-\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f<\/a><\/li>\n<li><a href=\"#24\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Zip-\u0437\u0430\u043f\u0438\u0441\u0438<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#25\">HWZip<\/a><br \/> \n<ul>\n<li><a href=\"#26\">\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0438<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#27\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/a><\/li>\n<li><a href=\"#28\">\u0423\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f<\/a><\/li>\n<li><a href=\"#29\">\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b<\/a><\/li>\n<\/ul>\n<p>  <a name=\"1\"><\/a><\/p>\n<h2>\u0418\u0441\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>  <a name=\"2\"><\/a><\/p>\n<h3>PKZip<\/h3>\n<p>  \u0412 \u0432\u043e\u0441\u044c\u043c\u0438\u0434\u0435\u0441\u044f\u0442\u044b\u0445 \u0438 \u043d\u0430\u0447\u0430\u043b\u0435 \u0434\u0435\u0432\u044f\u043d\u043e\u0441\u0442\u044b\u0445, \u0434\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442\u044b-\u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0449\u0438\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 dial-up-\u043c\u043e\u0434\u0435\u043c\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u0443\u044e \u0441\u0435\u0442\u044c \u043a \u0441\u0435\u0442\u0438 Bulletin Board Systems (BBS). BBS \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0430 \u0441\u043e\u0431\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0438\u0433\u0440\u0430\u0442\u044c \u0432 \u0438\u0433\u0440\u044b \u0438 \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0444\u0430\u0439\u043b\u0430\u043c. \u0414\u043b\u044f \u0432\u044b\u0445\u043e\u0434\u0430 \u0432 \u043e\u043d\u043b\u0430\u0439\u043d \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u043b\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430, \u043c\u043e\u0434\u0435\u043c\u0430 \u0438 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u0445\u043e\u0440\u043e\u0448\u0435\u0439 BBS. \u041d\u043e\u043c\u0435\u0440\u0430 <a href=\"https:\/\/archive.org\/details\/Boardwatch_Magazine_Vol_06_10_1992_Dec\/page\/n81\">\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u044b\u0445 \u0436\u0443\u0440\u043d\u0430\u043b\u0430\u0445<\/a> \u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 BBS.<\/p>\n<p>  \u0412\u0430\u0436\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c, \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0449\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432, \u0431\u044b\u043b <i>\u0430\u0440\u0445\u0438\u0432\u0430\u0442\u043e\u0440<\/i>. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0435\u0434\u0438\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435-<i>\u0430\u0440\u0445\u0438\u0432\u0435<\/i>, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u0410 \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u0430\u0440\u0445\u0438\u0432 \u0435\u0449\u0451 \u0438 \u0441\u0436\u0438\u043c\u0430\u043b \u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043c\u0435\u0441\u0442\u0430 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043f\u043e \u0441\u0435\u0442\u0438. \u0412\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0430 BBS \u0431\u044b\u043b \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0435\u043d \u0430\u0440\u0445\u0438\u0432\u0430\u0442\u043e\u0440 Arc, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0422\u043e\u043c\u043e\u043c \u0425\u0435\u043d\u0434\u0435\u0440\u0441\u043e\u043d\u043e\u043c \u0438\u0437 System Enhancement Associates (SEA), \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d \u043e\u0441\u043d\u043e\u0432\u0430\u043b \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0448\u0443\u0440\u0438\u043d\u043e\u043c.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 1980-\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0424\u0438\u043b \u041a\u0430\u0442\u0446 \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Arc \u2014 PKArc. \u041e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430 \u0441 SWA Arc, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u0436\u0430\u0442\u0438\u044f. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0442\u0430\u043b\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439, \u041a\u0430\u0442\u0446 \u0443\u0448\u0451\u043b \u0441 \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e PKWare, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043b\u0435\u0433\u0435\u043d\u0434\u0435, \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b\u0430 \u043d\u0430 \u043a\u0443\u0445\u043d\u0435 \u0435\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438 \u0432 \u0413\u043b\u0435\u043d\u0434\u0435\u0439\u043b\u0435, \u0448\u0442\u0430\u0442 \u0412\u0438\u0441\u043a\u043e\u043d\u0441\u0438\u043d.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b1e\/50a\/990\/b1e50a990a86a05045dde9d2a819fbf0.jpg\"><\/div>\n<p>  <i>\u0424\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f \u0424\u0438\u043b\u0430 \u041a\u0430\u0442\u0446\u0430<a href=\"https:\/\/www.hanshq.net\/files\/katz_article.png\"> \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432 Milwaukee Sentinel<\/a>, 19 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f 1994.<\/i><\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e SEA \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u0442\u0438\u0432\u0430 \u041a\u0430\u0442\u0446\u0430. \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u043e\u0431\u0432\u0438\u043d\u0438\u043b\u0430 \u0435\u0433\u043e \u0432 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0438 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u0430 \u0438 \u0430\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u0432. \u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0438 \u0441\u043f\u043e\u0440\u044b \u0432 \u0441\u0435\u0442\u0438 BBS \u0438 \u043c\u0438\u0440\u0435 \u041f\u041a \u0441\u0442\u0430\u043b\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u043a\u0430\u043a <a href=\"http:\/\/catb.org\/jargon\/chaff.html#arc-wars\">Arc-\u0432\u043e\u0439\u043d\u044b<\/a>. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u0441\u043f\u043e\u0440 \u0431\u044b\u043b<a href=\"http:\/\/www.bbsdocumentary.com\/library\/CONTROVERSY\/LAWSUITS\/SEA\/release.txt\"> \u0443\u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d<\/a> \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 SEA.<\/p>\n<p>  \u041e\u0442\u043a\u0430\u0437\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0442 Arc, \u041a\u0430\u0442\u0446 \u0432 1989 \u0441\u043e\u0437\u0434\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u043d\u0430\u0437\u0432\u0430\u043b Zip \u0438 <a href=\"https:\/\/groups.google.com\/d\/msg\/comp.sys.ibm.pc\/0tun_9sqKYU\/RNeLTza9fAEJ\">\u043f\u0435\u0440\u0435\u0434\u0430\u043b \u0432 \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/a>:<\/p>\n<p>  \u0424\u043e\u0440\u043c\u0430\u0442 \u0444\u0430\u0439\u043b\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0435\u043b\u0438\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f, \u0438 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 &quot;.ZIP&quot;, \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u041f\u041e \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043b\u0438\u0437\u0435 \u044d\u0442\u043e\u0433\u043e \u041f\u041e, \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0441 \u0433\u043e\u0440\u044f\u0447\u0435\u0439 \u0438 \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435\u0439 \u043d\u0430\u0434\u0435\u0436\u0434\u043e\u0439, \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0430, \u0441\u043a\u043e\u0440\u0435\u0435, \u0447\u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u041f\u041e \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0442\u0430\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u043b\u0438 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0444\u0430\u0439\u043b\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u0432 \u0446\u0435\u043b\u043e\u043c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c \u041f\u041e.<\/p>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u041a\u0430\u0442\u0446\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 PKZip \u0438 \u0441\u043a\u043e\u0440\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u043b\u0430\u0441\u044c \u0432 \u043c\u0438\u0440\u0435 BBS \u0438 \u041f\u041a.<\/p>\n<p>  \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0443\u0441\u043f\u0435\u0445\u0443 Zip-\u0444\u043e\u0440\u043c\u0430\u0442\u0430, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0441 PKZip \u0448\u043b\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, <a href=\"https:\/\/www.pkware.com\/documents\/APPNOTE\/APPNOTE-2.0.txt\">Application Note<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u043b\u043e\u0441\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0444\u043e\u0440\u043c\u0430\u0442 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442 \u0438\u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u0438\u043d\u0430\u0447\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0441 Zip-\u0444\u0430\u0439\u043b\u0430\u043c\u0438.<\/p>\n<p>  Zip \u2014 \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442 \u0441\u0436\u0430\u0442\u0438\u044f <i>\u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c<\/i>: \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434 \u0441\u0436\u0430\u0442\u0438\u0435\u043c. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0449\u0435\u0442 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u0436\u0430\u0442\u0438\u044f <i>\u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445, \u043a\u0430\u043a JPEG \u0438 MP3: \u043f\u0440\u0438 \u0441\u0436\u0430\u0442\u0438\u0438 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u0430 \u0434\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0433\u043b\u0430\u0437\u0430 \u0438\u043b\u0438 \u0443\u0445\u0430.<\/p>\n<p>  PKZip \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u043b\u0430\u0441\u044c \u043a\u0430\u043a Shareware: \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u0430\u0432\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u00ab\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00bb \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u0417\u0430 $47 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u043d\u043d\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e, \u043f\u0440\u0435\u043c\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/031\/509\/4fc\/0315094fc6917b61db8f78b2f776ce13.jpg\"><\/div>\n<p>  \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 PKZip \u0441\u0442\u0430\u043b\u0430 2.04c, \u0432\u044b\u0448\u0435\u0434\u0448\u0430\u044f 28 \u0434\u0435\u043a\u0430\u0431\u0440\u044f 1992 (\u0432\u0441\u043a\u043e\u0440\u0435 \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0451 \u0432\u044b\u0448\u043b\u0430<a href=\"https:\/\/www.hanshq.net\/files\/pkz204g.exe\"> \u0432\u0435\u0440\u0441\u0438\u044f 2.04g<\/a>). \u0412 \u043d\u0435\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0436\u0430\u0442\u0438\u044f Deflate. \u0412\u0435\u0440\u0441\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0432 Zip-\u0444\u0430\u0439\u043b\u0430\u0445 (<a href=\"https:\/\/archive.org\/details\/Boardwatch1993-03\/page\/n21\">\u0441\u0442\u0430\u0442\u044c\u044f, \u043f\u043e\u0441\u0432\u044f\u0449\u0451\u043d\u043d\u0430\u044f \u0440\u0435\u043b\u0438\u0437\u0443<\/a>).<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/58e\/bd3\/69b\/58ebd369bf36c272d0c8c7c9515fc670.png\"><\/div>\n<p>  \u0421 \u0442\u0435\u0445 \u043f\u043e\u0440 Zip-\u0444\u043e\u0440\u043c\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Java-\u0430\u0440\u0445\u0438\u0432\u044b (.jar), Android Application Packages (.apk) \u0438 .docx-\u0444\u0430\u0439\u043b\u044b Microsoft Office \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 Zip-\u0444\u043e\u0440\u043c\u0430\u0442. \u0412\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445 \u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0436\u0430\u0442\u0438\u044f, Deflate. \u0421\u043a\u0430\u0436\u0435\u043c, \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0432 \u0432\u0438\u0434\u0435 gzip-\u0444\u0430\u0439\u043b\u0430, \u0444\u043e\u0440\u043c\u0430\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Deflate-\u0441\u0436\u0430\u0442\u0438\u0435.<\/p>\n<p>  \u0424\u0438\u043b \u041a\u0430\u0442\u0446 \u0443\u043c\u0435\u0440 \u0432 2000-\u043c. PKWare \u0432\u0441\u0451 \u0435\u0449\u0451 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 Zip-\u0444\u043e\u0440\u043c\u0430\u0442, \u0445\u043e\u0442\u044f \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0435\u043d\u0430 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430 \u041f\u041e \u0434\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <a name=\"3\"><\/a><\/p>\n<h3>Info-ZIP \u0438 zlib<\/h3>\n<p>  \u0412\u0441\u043a\u043e\u0440\u0435 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 PKZip \u0432 1989-\u043c \u043d\u0430\u0447\u0430\u043b\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 Zip-\u0444\u0430\u0439\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 <i>unzip<\/i>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0433\u043b\u0430 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0430 Unix-\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445. \u0412 \u043c\u0430\u0440\u0442\u0435 1990-\u0433\u043e \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Info-ZIP.<\/p>\n<p>  \u0413\u0440\u0443\u043f\u043f\u0430 <a href=\"http:\/\/www.info-zip.org\">Info-ZIP<\/a> \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c <i>unzip<\/i> \u0438 <i>zip<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f Zip-\u0444\u0430\u0439\u043b\u043e\u0432. \u041a\u043e\u0434 \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0438 \u043e\u043d \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c \u0434\u043b\u044f Zip-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043f\u043e\u0434 Unix-\u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041f\u043e\u0437\u0434\u043d\u0435\u0435 \u044d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u043b\u043e \u0440\u043e\u0441\u0442\u0443 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 Zip-\u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u0436\u0434\u044b \u043a\u043e\u0434 Info-ZIP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b Deflate-\u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0443, \u0431\u044b\u043b \u0432\u044b\u043d\u0435\u0441\u0435\u043d \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/www.zlib.net\/\">zlib<\/a>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 <a href=\"http:\/\/gailly.net\/\">Jean-loup Gailly<\/a> (\u0441\u0436\u0430\u0442\u0438\u0435) \u0438 <a href=\"https:\/\/madler.net\/madler\/\">Mark Adler<\/a> (\u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430).<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/68b\/216\/d1d\/68b216d1debaffdb2d890067e38bed47.jpg\"><\/div>\n<p>  <i>Jean-loup Gailly (\u0441\u043b\u0435\u0432\u0430) \u0438 Mark Adler (\u0441\u043f\u0440\u0430\u0432\u0430) \u043d\u0430 \u0432\u0440\u0443\u0447\u0435\u043d\u0438\u0438 \u0438\u043c \u043f\u0440\u0435\u043c\u0438\u0438 <a href=\"https:\/\/www.usenix.org\/about\/stug\">USENIX STUG Award<\/a> \u0432 2009-\u043c.<\/i><\/p>\n<p>  \u041e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u043b\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Deflate-\u0441\u0436\u0430\u0442\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043d\u043e\u0432\u044b\u0445 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Gzip\">gzip<\/a> \u0438<a href=\"https:\/\/ru.wikipedia.org\/wiki\/PNG\"> PNG<\/a>. \u042d\u0442\u0438 \u043d\u043e\u0432\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u0437\u0432\u0430\u043d\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Compress\">Compress<\/a> \u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/GIF\">GIF<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0441\u044f \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u044b\u0439 \u043f\u0430\u0442\u0435\u043d\u0442\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c LZW.<\/p>\n<p>  \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u041f\u0438\u0442\u0435\u0440 \u0414\u043e\u0439\u0447 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e Deflate \u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/tools.ietf.org\/html\/rfc1951\">Internet RFC 1951<\/a> \u0432 \u043c\u0430\u0435 1996-\u0433\u043e. \u042d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c PKZip Application Note.<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f zlib \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043d \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u0436\u0430\u0442\u0438\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0430 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438 \u0435\u0451 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 Zip-\u0444\u0430\u0439\u043b\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e zlib.<\/p>\n<p>  <a name=\"4\"><\/a><\/p>\n<h3>WinZip<\/h3>\n<p>  \u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u043b PKZip, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c WinZip. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u041f\u041a \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a\u0430\u043a \u0441 DOS \u043d\u0430 Windows, \u0442\u0430\u043a \u0438 \u0441 PKZip \u043d\u0430 WinZip.<\/p>\n<p>  \u0412\u0441\u0451 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u041d\u0438\u043a\u043e \u041c\u0430\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u041f\u041e \u0434\u043b\u044f OS\/2 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Mansfield Software Group \u0432 \u0433\u043e\u0440\u043e\u0434\u0435 \u0421\u0442\u043e\u0440\u0440\u0441-\u041c\u0430\u043d\u0441\u0444\u0438\u043b\u0434, \u0448\u0442\u0430\u0442 \u041a\u043e\u043d\u043d\u0435\u043a\u0442\u0438\u043a\u0443\u0442. \u041d\u0438\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b Presentation Manager, \u044d\u0442\u043e \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 OS\/2, \u0438 \u0435\u0433\u043e \u0440\u0430\u0441\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043a DOS-\u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0445\u043e\u0442\u0435\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c Zip-\u0444\u0430\u0439\u043b\u044b. <\/p>\n<p>  \u041c\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 Zip-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 Presentation Manager, \u043d\u0430\u0437\u0432\u0430\u043b \u0435\u0451 <a href=\"http:\/\/cd.textfiles.com\/sigserieswin\/0WINRUN\/2785\/PMZIP.TXT\">PMZip<\/a> \u0438 \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 shareware \u0432 1990-\u043c.<\/p>\n<p>  OS\/2 \u0442\u0430\u043a \u0438 \u043d\u0435 \u0434\u043e\u0431\u0438\u043b\u0430\u0441\u044c \u0443\u0441\u043f\u0435\u0445\u0430, \u0430 \u043c\u0438\u0440 \u041f\u041a \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u043b\u0430 Microsoft Windows. \u0412 1991-\u043c \u041c\u0430\u043a \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c Windows-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0438 \u0435\u0433\u043e \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e Zip-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434 \u043d\u043e\u0432\u0443\u044e \u041e\u0421. \u0412 \u0430\u043f\u0440\u0435\u043b\u0435 1991-\u0433\u043e \u0432\u044b\u0448\u043b\u0430 <a href=\"https:\/\/www.hanshq.net\/files\/winzip1.zip\">WinZip 1.00<\/a>. \u041e\u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u043b\u0430\u0441\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 shareware \u0441 21-\u0434\u043d\u0435\u0432\u043d\u044b\u043c \u043f\u0440\u043e\u0431\u043d\u044b\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 $29. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430 \u043e\u043d\u0430 \u0442\u0430\u043a:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0b1\/2f4\/bcd\/0b12f4bcd048691aa0487b9d3a445b39.png\"><\/div>\n<p>  \u0412 \u043f\u0435\u0440\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 WinZip \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c PKZip. \u041d\u043e \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 5.0 \u0432 1993-\u043c \u0434\u043b\u044f \u043f\u0440\u044f\u043c\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Zip-\u0444\u0430\u0439\u043b\u043e\u0432 \u0441\u0442\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u0434 \u0438\u0437 Info-ZIP. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u043e\u0436\u0435 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043b.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bf4\/273\/962\/bf427396212f63fba9c80db12fdd2132.png\"><\/div>\n<p>  <i><a href=\"https:\/\/ftp.sunet.se\/mirror\/archive\/ftp.sunet.se\/pub\/simtelnet\/win3\/compress\/wz16v_63.exe\">WinZip 6.3<\/a> \u043f\u043e\u0434 Windows 3.11 for Workgroups.<\/i><\/p>\n<p>  WinZip \u0431\u044b\u043b\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 shareware-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0432 1990-\u0435. \u041d\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u043e\u043d\u0430 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0437-\u0437\u0430 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 Zip-\u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. Windows \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043d\u0438\u043c\u0438 \u043a\u0430\u043a \u0441\u043e \u00ab\u0441\u0436\u0430\u0442\u044b\u043c\u0438 \u043f\u0430\u043f\u043a\u0430\u043c\u0438\u00bb \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 2001-\u0433\u043e (Windows XP), \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"http:\/\/www.innermedia.com\/\">DynaZip<\/a>.<\/p>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u041c\u0430\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u043b\u0430\u0441\u044c Nico Mak Computing. \u0412 2000-\u043c \u0435\u0451 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b\u0438 \u0432 WinZip Computing, \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0442\u0435 \u0433\u043e\u0434\u044b \u041c\u0430\u043a \u0435\u0451 \u043f\u043e\u043a\u0438\u043d\u0443\u043b. \u0412 2005-\u043c \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e <a href=\"https:\/\/www.businesswire.com\/news\/home\/20050718005297\/en\/Vector-Capital-Buys-WinZip-Private-Equity-Firm\">\u043f\u0440\u043e\u0434\u0430\u043b\u0438 Vector Capital<\/a>, \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u0435\u044e \u0441\u0442\u0430\u043b\u0430 \u0432\u043b\u0430\u0434\u0435\u0442\u044c <a href=\"https:\/\/www.corel.com\">Corel<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u0442 WinZip \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430.<\/p>\n<p>  <a name=\"5\"><\/a><\/p>\n<h2>\u0421\u0436\u0430\u0442\u0438\u0435 Lempel-Ziv (LZ77)<\/h2>\n<p>  Zip-\u0441\u0436\u0430\u0442\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438\u043d\u0433\u0440\u0435\u0434\u0438\u0435\u043d\u0442\u043e\u0432: \u0441\u0436\u0430\u0442\u0438\u044f Lempel-Ziv \u0438 \u043a\u043e\u0434\u0430 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430.<\/p>\n<p>  \u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u0436\u0430\u0442\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0447\u0430\u0441\u0442\u044b\u0445 \u0441\u043b\u043e\u0432 \u0438\u043b\u0438 \u0444\u0440\u0430\u0437 \u0441 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0435\u0439 \u044d\u0442\u0438\u0445 \u0441\u043b\u043e\u0432 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0435\u043a\u0441\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u00abcompression\u00bb \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a #1234, \u0433\u0434\u0435 1234 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0441\u043b\u043e\u0432\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>\u0441\u0436\u0430\u0442\u0438\u0435\u043c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044f<\/i>.<\/p>\n<p>  \u041d\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c? \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0430\u0436\u0435 \u043d\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0442\u0435\u043a\u0441\u0442. \u0418 \u0435\u0441\u043b\u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0435 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u0436\u0430\u0442\u0438\u0435\u043c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u043e\u0439, \u0442\u043e \u0435\u0433\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0441\u0436\u0430\u0442\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0432\u044b\u0433\u043e\u0434\u0443 \u043e\u0442 \u0441\u0436\u0430\u0442\u0438\u044f.<\/p>\n<p>  \u042d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441\u0430\u043c\u0438\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0440\u0430\u0431\u043e\u0442\u0435 \u00ab<a href=\"https:\/\/www2.cs.duke.edu\/courses\/spring03\/cps296.5\/papers\/ziv_lempel_1977_universal_algorithm.pdf\">A Universal Algorithm for Sequential Data Compression<\/a>\u00ab 1977 \u0433\u043e\u0434\u0430 \u042f\u043a\u043e\u0431 \u0417\u0438\u0432 \u0438 \u0410\u0431\u0440\u0430\u0445\u0430\u043c \u041b\u0435\u043c\u043f\u0435\u043b (\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0435 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Technion), \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b\u0438 \u0441\u0445\u0435\u043c\u0443 \u0441\u0436\u0430\u0442\u0438\u044f, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0440\u0438\u043f\u043b\u0435\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">(\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0434\u043b\u0438\u043d\u0430, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439) <\/code><\/pre>\n<p>  \u0433\u0434\u0435 <code>\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c<\/code> \u0438 <code>\u0434\u043b\u0438\u043d\u0430<\/code> \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435, \u0430 <code>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439<\/code> \u2014 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0432 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5e5\/21e\/fdb\/5e521efdb5649015f685e26ab308d1b9.jpg\"><\/div>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2ce\/cfa\/2e3\/2cecfa2e39798ce3302ff4b48e1a62ef.jpg\"><\/div>\n<p>  <i>\u0410\u0431\u0440\u0430\u0445\u0430\u043c \u041b\u0435\u043c\u043f\u0435\u043b \u0438 \u042f\u043a\u043e\u0431 \u0417\u0438\u0432.<\/i><\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code class=\"cpp\">It was the best of times, it was the worst of times, <\/code><\/pre>\n<p>  \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u00abt was the w\u00bb \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a (26, 10, w), \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0430 \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c 10 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 26 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043d\u0430\u0437\u0430\u0434 \u0438 \u0434\u043e \u0431\u0443\u043a\u0432\u044b \u00abw\u00bb. \u0414\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0435\u0449\u0451 \u043d\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u043b\u0438\u0441\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u00abI\u00bb \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a (0, 0, I).<\/p>\n<p>  \u042d\u0442\u0430 \u0441\u0445\u0435\u043c\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 Lempel-Ziv, \u0438\u043b\u0438 \u0441\u0436\u0430\u0442\u0438\u0435 LZ77. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c \u0442\u0440\u0438\u043f\u043b\u0435\u0442\u0430 <code>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u043e-\u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0435, \u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u044b (<code>\u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435<\/code>, <code>\u0434\u043b\u0438\u043d\u0430<\/code>) (\u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0436\u0430\u0442\u0438\u0435\u043c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/LZSS\">LZSS<\/a>). \u041a\u0430\u043a <i>\u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f<\/i> \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u2014 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043d\u0438\u0436\u0435, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c <a href=\"https:\/\/www.hanshq.net\/zip.html#deflate\">Deflate<\/a>.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u0442\u0435\u043a\u0441\u0442:<\/p>\n<pre><code class=\"cpp\">It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0441\u0436\u0430\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"cpp\">It was the best of times, i(26,10)wor(27,24)age(25,4)wisdom(26,20) foolishnes(57,14)epoch(33,4)belief(28,22)incredulity (33,13)season(34,4)Light(28,23)Dark(120,17) spring(31,4)hope(231,14)inter(27,4)despair, we had everyth(57,4)before us(29,9)no(26,20) we(12,3)all go(29,4)direct to Heaven (36,28)(139,3)(83,3)(138,3)way <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u0422\u0430\u043a\u043e\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">Fa-la-la-la-la <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0441\u0436\u0430\u0442\u044c \u0432:<\/p>\n<pre><code class=\"cpp\">Fa-la(3,9) <\/code><\/pre>\n<p>  \u0412\u0430\u043c \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u043d\u043e \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442: \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0431\u0430\u0439\u0442\u044b \u043f\u0435\u0440\u0432\u044b\u0445 \u0442\u0440\u0451\u0445 \u00ab-la\u00bb, \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432.<\/p>\n<p>  \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Run-length_encoding\">\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u0438\u043d \u0441\u0435\u0440\u0438\u0439<\/a>, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0447\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b.<\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0436\u0430\u0442\u0438\u044f Lempel-Ziv \u0434\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u043f\u0435\u0441\u0435\u043d \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u041a\u043e\u043b\u0438\u043d\u0430 \u041c\u043e\u0440\u0440\u0438\u0441\u0430 <a href=\"https:\/\/pudding.cool\/2017\/05\/song-repetition\/\">Are Pop Lyrics Getting More Repetitive?<\/a>.<\/p>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0438\u0437-\u0437\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044f \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>memcpy<\/code> \u0438\u043b\u0438 <code>memmove<\/code>.<\/p>\n<pre><code class=\"cpp\">\/* Output the (dist,len) backref at dst_pos in dst. *\/ static inline void lz77_output_backref(uint8_t *dst, size_t dst_pos,                                        size_t dist, size_t len) {         size_t i;          assert(dist &lt;= dst_pos &amp;&amp; &quot;cannot reference before beginning of dst&quot;);          for (i = 0; i &lt; len; i++) {                 dst[dst_pos] = dst[dst_pos - dist];                 dst_pos++;         } } <\/code><\/pre>\n<p>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b \u043b\u0435\u0433\u043a\u043e, \u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439:<\/p>\n<pre><code class=\"cpp\">\/* Output lit at dst_pos in dst. *\/ static inline void lz77_output_lit(uint8_t *dst, size_t dst_pos, uint8_t lit) {         dst[dst_pos] = lit; } <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432 <code>dst<\/code> \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0444\u0435\u0440\u0430.<\/p>\n<p>  \u0421\u043b\u043e\u0436\u043d\u043e \u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0432 \u0445\u043e\u0434\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438, \u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043f\u0440\u0438 \u0441\u0436\u0430\u0442\u0438\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u043d\u043e \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u043e\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446 \u0438\u0437 zlib, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 RFC 1951.<\/p>\n<p>  \u0411\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u043c\u0438 \u0442\u0440\u0451\u0445\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\u0441\u044c \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 (\u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u044b \u043d\u0435 \u043f\u0440\u0438\u043d\u043e\u0441\u044f\u0442). \u0412 Deflate \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 32 768 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u2014 \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>\u043e\u043a\u043d\u043e\u043c<\/i>. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435: \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0437\u0430 \u0440\u0430\u0437, \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u043e\u043a\u043d\u043e \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432\u0441\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u0445 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0437\u0430 \u0440\u0430\u0437. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0436\u0430\u0442\u0438\u0438, \u0430 \u043d\u0435 \u043d\u0430 \u0443\u0447\u0451\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>  \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u0432\u0443\u043c\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438: \u0432 <code>head<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0445\u044d\u0448-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0451\u0445\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 \u0434\u043b\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0432 <code>prev<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441 \u044d\u0442\u0438\u043c \u0445\u044d\u0448-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u041f\u043e \u0441\u0443\u0442\u0438, <code>head[h]<\/code> \u2014 \u044d\u0442\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432 \u0441 \u0445\u044d\u0448\u0435\u043c <code>h<\/code>, \u0430 <code>prev[x]<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <code>x<\/code> \u0432 \u0441\u043f\u0438\u0441\u043a\u0435.<\/p>\n<pre><code class=\"cpp\">#define LZ_WND_SIZE 32768 #define LZ_MAX_LEN  258  #define HASH_SIZE 15 #define NO_POS    SIZE_MAX  \/* Perform LZ77 compression on the len bytes in src. Returns false as soon as    either of the callback functions returns false, otherwise returns true when    all bytes have been processed. *\/ bool lz77_compress(const uint8_t *src, size_t len,                    bool (*lit_callback)(uint8_t lit, void *aux),                    bool (*backref_callback)(size_t dist, size_t len, void *aux),                    void *aux) {         size_t head[1U &lt;&lt; HASH_SIZE];         size_t prev[LZ_WND_SIZE];          uint16_t h;         size_t i, j, dist;         size_t match_len, match_pos;         size_t prev_match_len, prev_match_pos;          \/* Initialize the hash table. *\/         for (i = 0; i &lt; sizeof(head) \/ sizeof(head[0]); i++) {                 head[i] = NO_POS;         } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 <code>prev<\/code> \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e <code>head<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u0430 <code>head<\/code>:<\/p>\n<pre><code class=\"cpp\">static void insert_hash(uint16_t hash, size_t pos, size_t *head, size_t *prev) {         prev[pos % LZ_WND_SIZE] = head[hash];         head[hash] = pos; } <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u043f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 <code>prev<\/code>: \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043e\u043a\u043d\u043e.<\/p>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441 \u043d\u0443\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0445\u044d\u0448-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0440\u0451\u0445\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430, \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D0%BE%D0%BB%D1%8C%D1%86%D0%B5%D0%B2%D0%BE%D0%B9_%D1%85%D0%B5%D1%88\">\u043a\u043e\u043b\u044c\u0446\u0435\u0432\u044b\u043c \u0445\u044d\u0448\u0435\u043c<\/a> \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043e\u0442\u0440\u0430\u0436\u0430\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u0430:<\/p>\n<pre><code class=\"cpp\">static uint16_t update_hash(uint16_t hash, uint8_t c) {         hash &lt;&lt;= 5;                     \/* Shift out old bits. *\/         hash ^= c;                      \/* Include new bits. *\/         hash &amp;= (1U &lt;&lt; HASH_SIZE) - 1;  \/* Mask off excess bits. *\/          return hash; } <\/code><\/pre>\n<p>  \u0425\u044d\u0448-\u043a\u0430\u0440\u0442\u0443 \u043f\u043e\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435. \u041f\u043e\u0438\u0441\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u2014 \u0441\u0430\u043c\u0430\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0437\u0430\u0442\u0440\u0430\u0442\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u0436\u0430\u0442\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443.<\/p>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0432\u0440\u043e\u0434\u0435 \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043b\u0435\u043d\u0438\u0432\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0438\u0436\u0435, \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0437\u0430 \u0441\u0447\u0451\u0442 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0441\u0436\u0430\u0442\u0438\u044f. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0443\u0440\u043e\u0432\u043d\u044e \u0441\u0436\u0430\u0442\u0438\u044f \u0432 zlib. <\/p>\n<pre><code class=\"cpp\">\/* Find the longest most recent string which matches the string starting  * at src[pos]. The match must be strictly longer than prev_match_len and  * shorter or equal to max_match_len. Returns the length of the match if found  * and stores the match position in *match_pos, otherwise returns zero. *\/ static size_t find_match(const uint8_t *src, size_t pos, uint16_t hash,                          size_t prev_match_len, size_t max_match_len,                          const size_t *head, const size_t *prev,                          size_t *match_pos) {         size_t max_match_steps = 4096;         size_t i, l;         bool found;          if (prev_match_len == 0) {                 \/* We want backrefs of length 3 or longer. *\/                 prev_match_len = 2;         }          if (prev_match_len &gt;= max_match_len) {                 \/* A longer match would be too long. *\/                 return 0;         }          if (prev_match_len &gt;= 32) {                 \/* Do not try too hard if there is already a good match. *\/                 max_match_steps \/= 4;         }          found = false;         i = head[hash];          while (max_match_steps != 0) {                 if (i == NO_POS) {                         \/* No match. *\/                         break;                 }                  assert(i &lt; pos &amp;&amp; &quot;Matches should precede pos.&quot;);                 if (pos - i &gt; LZ_WND_SIZE) {                         \/* The match is outside the window. *\/                         break;                 }                  l = cmp(src, i, pos, prev_match_len, max_match_len);                  if (l != 0) {                         assert(l &gt; prev_match_len);                         assert(l &lt;= max_match_len);                          found = true;                         *match_pos = i;                         prev_match_len = l;                          if (l == max_match_len) {                                 \/* A longer match is not possible. *\/                                 return l;                         }                 }                  \/* Look further back in the prefix list. *\/                 i = prev[i % LZ_WND_SIZE];                 max_match_steps--;         }          if (!found) {                 return 0;         }          return prev_match_len; }  \/* Compare the substrings starting at src[i] and src[j], and return the length  * of the common prefix. The match must be strictly longer than prev_match_len  * and shorter or equal to max_match_len. *\/ static size_t cmp(const uint8_t *src, size_t i, size_t j,                   size_t prev_match_len, size_t max_match_len) {         size_t l;          assert(prev_match_len &lt; max_match_len);          \/* Check whether the first prev_match_len + 1 characters match. Do this          * backwards for a higher chance of finding a mismatch quickly. *\/         for (l = 0; l &lt; prev_match_len + 1; l++) {                 if (src[i + prev_match_len - l] !=                     src[j + prev_match_len - l]) {                         return 0;                 }         }          assert(l == prev_match_len + 1);          \/* Now check how long the full match is. *\/         for (; l &lt; max_match_len; l++) {                 if (src[i + l] != src[j + l]) {                         break;                 }         }          assert(l &gt; prev_match_len);         assert(l &lt;= max_match_len);         assert(memcmp(&amp;src[i], &amp;src[j], l) == 0);          return l; } <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>lz77_compress<\/code> \u044d\u0442\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"cpp\">       \/* h is the hash of the three-byte prefix starting at position i. *\/         h = 0;         if (len &gt;= 2) {                 h = update_hash(h, src[0]);                 h = update_hash(h, src[1]);         }          prev_match_len = 0;         prev_match_pos = 0;          for (i = 0; i + 2 &lt; len; i++) {                 h = update_hash(h, src[i + 2]);                  \/* Search for a match using the hash table. *\/                 match_len = find_match(src, i, h, prev_match_len,                                        min(LZ_MAX_LEN, len - i), head, prev,                                        &amp;match_pos);                  \/* Insert the current hash for future searches. *\/                 insert_hash(h, i, head, prev);                  \/* If the previous match is at least as good as the current. *\/                 if (prev_match_len != 0 &amp;&amp; prev_match_len &gt;= match_len) {                         \/* Output the previous match. *\/                         dist = (i - 1) - prev_match_pos;                         if (!backref_callback(dist, prev_match_len, aux)) {                                 return false;                         }                         \/* Move past the match. *\/                         for (j = i + 1; j &lt; min((i - 1) + prev_match_len,                                                 len - 2); j++) {                                 h = update_hash(h, src[j + 2]);                                 insert_hash(h, j, head, prev);                         }                         i = (i - 1) + prev_match_len - 1;                         prev_match_len = 0;                         continue;                 }                  \/* If no match (and no previous match), output literal. *\/                 if (match_len == 0) {                         assert(prev_match_len == 0);                         if (!lit_callback(src[i], aux)) {                                 return false;                         }                         continue;                 }                  \/* Otherwise the current match is better than the previous. *\/                  if (prev_match_len != 0) {                         \/* Output a literal instead of the previous match. *\/                         if (!lit_callback(src[i - 1], aux)) {                                 return false;                         }                 }                  \/* Defer this match and see if the next is even better. *\/                 prev_match_len = match_len;                 prev_match_pos = match_pos;         }          \/* Output any previous match. *\/         if (prev_match_len != 0) {                 dist = (i - 1) - prev_match_pos;                 if (!backref_callback(dist, prev_match_len, aux)) {                         return false;                 }                 i = (i - 1) + prev_match_len;         }          \/* Output any remaining literals. *\/         for (; i &lt; len; i++) {                 if (!lit_callback(src[i], aux)) {                         return false;                 }         }          return true; } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0438\u0449\u0435\u0442 \u0441\u0430\u043c\u0443\u044e \u0434\u043b\u0438\u043d\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0435\u0451 \u0432\u044b\u0434\u0430\u0442\u044c, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043d\u0430\u0439\u0442\u0438 \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435. \u0412 zlib \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>\u043e\u0446\u0435\u043d\u043a\u043e\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0435\u043d\u0438\u0432\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/i>. \u042d\u0442\u043e \u0432\u0441\u0451 \u0435\u0449\u0451 <i>\u0436\u0430\u0434\u043d\u044b\u0439<\/i> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c: \u043e\u043d \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0435\u0449\u0451 \u0434\u043b\u0438\u043d\u043d\u0435\u0435 \u0438 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0436\u0430\u0442\u0438\u044f.<\/p>\n<p>  \u0421\u0436\u0430\u0442\u0438\u0435 Lempel-Ziv \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e, \u0442\u0430\u043a \u0438 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. <a href=\"https:\/\/github.com\/google\/zopfli\">Zopfli<\/a> \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0436\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u044b \u0441\u0436\u0430\u0442\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0436\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438 \u0440\u0430\u0437 \u0438 \u043f\u043e\u0442\u043e\u043c \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u041d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0448\u043a\u0430\u043b\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u043e\u0440\u044b, \u043a\u0430\u043a <a href=\"https:\/\/github.com\/google\/snappy\">Snappy<\/a> \u0438 <a href=\"https:\/\/lz4.github.io\/lz4\/\">LZ4<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c 4-\u0431\u0430\u0439\u0442\u043d\u044b\u043c \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e. \u0422\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0441\u0436\u0430\u0442\u0438\u044f \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 RPC-\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0440\u0435\u043c\u044f, \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 \u0441\u0436\u0430\u0442\u0438\u0435, \u043e\u043a\u0443\u043f\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0435\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0441\u0435\u0442\u0438 \u0438\u043b\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a.<\/p>\n<p>  \u0418\u0434\u0435\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u043e\u0447\u0435\u043d\u044c \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u0430, \u043d\u043e \u0438 \u043e\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u0443. <a href=\"https:\/\/github.com\/google\/brotli\">Brotli<\/a> \u2014 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 LZ77, \u043d\u043e \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 <a href=\"https:\/\/gist.github.com\/klauspost\/2900d5ba6f9b65d69c8e\">\u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c<\/a> \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u0435\u0442\u0438.<\/p>\n<p>  \u041a\u043e\u0434 LZ77 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/lz77.h\"> \u0432 lz77.h<\/a> \u0438 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/lz77.c\">lz77.c<\/a>.<\/p>\n<p>  <a name=\"6\"><\/a><\/p>\n<h2>\u041a\u043e\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/h2>\n<p>  \u0412\u0442\u043e\u0440\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c Zip-\u0441\u0436\u0430\u0442\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430.<\/p>\n<p>  \u0422\u0435\u0440\u043c\u0438\u043d <i>\u043a\u043e\u0434<\/i> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0441\u044b\u043b\u043a\u043e\u0439 \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0435. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043a\u043e\u0434, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c Lempel-Ziv.<\/p>\n<p>  \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/ASCII\">American Standard Code for Information Interchange (ASCII)<\/a>. \u042d\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u0443 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 8-\u0431\u0438\u0442\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438. \u0412\u043e\u0442 ASCII-\u043a\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0431\u0443\u043a\u0432 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>A<\/strong><\/td>\n<td>01000001<\/td>\n<td><strong>N<\/strong><\/td>\n<td>01001110<\/td>\n<\/tr>\n<tr>\n<td><strong>B<\/strong><\/td>\n<td>01000010<\/td>\n<td><strong>O<\/strong><\/td>\n<td>01001111<\/td>\n<\/tr>\n<tr>\n<td><strong>C<\/strong><\/td>\n<td>01000011<\/td>\n<td><strong>P<\/strong><\/td>\n<td>01010000<\/td>\n<\/tr>\n<tr>\n<td><strong>D<\/strong><\/td>\n<td>01000100<\/td>\n<td><strong>Q<\/strong><\/td>\n<td>01010001<\/td>\n<\/tr>\n<tr>\n<td><strong>E<\/strong><\/td>\n<td>01000101<\/td>\n<td><strong>R<\/strong><\/td>\n<td>01010010<\/td>\n<\/tr>\n<tr>\n<td><strong>F<\/strong><\/td>\n<td>01000110<\/td>\n<td><strong>S<\/strong><\/td>\n<td>01010011<\/td>\n<\/tr>\n<tr>\n<td><strong>G<\/strong><\/td>\n<td>01000111<\/td>\n<td><strong>T<\/strong><\/td>\n<td>01010100<\/td>\n<\/tr>\n<tr>\n<td><strong>H<\/strong><\/td>\n<td>01001000<\/td>\n<td><strong>U<\/strong><\/td>\n<td>01010101<\/td>\n<\/tr>\n<tr>\n<td><strong>I<\/strong><\/td>\n<td>01001001<\/td>\n<td><strong>V<\/strong><\/td>\n<td>01010110<\/td>\n<\/tr>\n<tr>\n<td><strong>J<\/strong><\/td>\n<td>01001010<\/td>\n<td><strong>W<\/strong><\/td>\n<td>01010111<\/td>\n<\/tr>\n<tr>\n<td><strong>K<\/strong><\/td>\n<td>01001011<\/td>\n<td><strong>X<\/strong><\/td>\n<td>01011000<\/td>\n<\/tr>\n<tr>\n<td><strong>L<\/strong><\/td>\n<td>01001100<\/td>\n<td><strong>Y<\/strong><\/td>\n<td>01011001<\/td>\n<\/tr>\n<tr>\n<td><strong>M<\/strong><\/td>\n<td>01001101<\/td>\n<td><strong>Z<\/strong><\/td>\n<td>01011010<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b \u2014 \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0447\u0430\u0441\u0442\u044f\u043c \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445, \u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f N \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438\u043b\u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 N \u0431\u0430\u0439\u0442\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0451\u043c\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0431\u0443\u043a\u0432\u0430 E \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u0430 Z \u2014 \u0440\u0435\u0436\u0435 \u0432\u0441\u0435\u0433\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0451\u043c\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f E \u0438 \u0431\u043e\u043b\u0435\u0435 \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0434\u043b\u044f Z, \u0430 \u043d\u0435 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u0443 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432.<\/p>\n<p>  \u041a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u043d\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c \u0437\u0430\u0434\u0430\u0451\u0442 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0440\u0430\u0437\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>\u043a\u043e\u0434\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b<\/i>. \u0421\u0430\u043c\u044b\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%B7%D0%B1%D1%83%D0%BA%D0%B0_%D0%9C%D0%BE%D1%80%D0%B7%D0%B5\">\u0430\u0437\u0431\u0443\u043a\u0430 \u041c\u043e\u0440\u0437\u0435<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u0438 \u0442\u0438\u0440\u0435, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0432\u0448\u0438\u043c\u0438\u0441\u044f \u043f\u043e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u0444\u0443 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c\u0438 \u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u043c\u0438 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430\u043c\u0438:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>A<\/strong><\/td>\n<td><strong>\u2022 \u2212<\/strong><\/td>\n<td><strong>N<\/strong><\/td>\n<td><strong>\u2212 \u2022<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>B<\/strong><\/td>\n<td><strong>\u2212 \u2022 \u2022 \u2022<\/strong><\/td>\n<td><strong>O<\/strong><\/td>\n<td><strong>\u2212 \u2212 \u2212<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>C<\/strong><\/td>\n<td><strong>\u2212 \u2022 \u2212 \u2022<\/strong><\/td>\n<td><strong>P<\/strong><\/td>\n<td><strong>\u2022 \u2212 \u2212 \u2022<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>D<\/strong><\/td>\n<td><strong>\u2212 \u2022 \u2022<\/strong><\/td>\n<td><strong>Q<\/strong><\/td>\n<td><strong>\u2212 \u2212 \u2022 \u2212<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>E<\/strong><\/td>\n<td><strong>\u2022<\/strong><\/td>\n<td><strong>R<\/strong><\/td>\n<td><strong>\u2022 \u2212 \u2022<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>F<\/strong><\/td>\n<td><strong>\u2022 \u2022 \u2212 \u2022<\/strong><\/td>\n<td><strong>S<\/strong><\/td>\n<td><strong>\u2022 \u2022 \u2022<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>G<\/strong><\/td>\n<td><strong>\u2212 \u2212 \u2022<\/strong><\/td>\n<td><strong>T<\/strong><\/td>\n<td><strong>\u2212<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>H<\/strong><\/td>\n<td><strong>\u2022 \u2022 \u2022 \u2022<\/strong><\/td>\n<td><strong>U<\/strong><\/td>\n<td><strong>\u2022 \u2022 \u2212<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>I<\/strong><\/td>\n<td><strong>\u2022 \u2022<\/strong><\/td>\n<td><strong>V<\/strong><\/td>\n<td><strong>\u2022 \u2022 \u2022 \u2212<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>J<\/strong><\/td>\n<td><strong>\u2022 \u2212 \u2212 \u2212<\/strong><\/td>\n<td><strong>W<\/strong><\/td>\n<td><strong>\u2022 \u2212 \u2212<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>K<\/strong><\/td>\n<td><strong>\u2212 \u2022 \u2212<\/strong><\/td>\n<td><strong>X<\/strong><\/td>\n<td><strong>\u2212 \u2022 \u2022 \u2212<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>L<\/strong><\/td>\n<td><strong>\u2022 \u2212 \u2022 \u2022<\/strong><\/td>\n<td><strong>Y<\/strong><\/td>\n<td><strong>\u2212 \u2022 \u2212 \u2212<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>M<\/strong><\/td>\n<td><strong>\u2212 \u2212<\/strong><\/td>\n<td><strong>Z<\/strong><\/td>\n<td><strong>\u2212 \u2212 \u2022 \u2022<\/strong><\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u0430\u0437\u0431\u0443\u043a\u0438 \u041c\u043e\u0440\u0437\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u2022 \u2022 \u2212 \u2022 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c F \u0438\u043b\u0438 ER. \u042d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0443\u0437 (\u0434\u043b\u0438\u043d\u043e\u0439 \u0432 \u0442\u0440\u0438 \u0442\u043e\u0447\u043a\u0438) \u043c\u0435\u0436\u0434\u0443 \u0431\u0443\u043a\u0432\u0430\u043c\u0438 \u0432 \u0445\u043e\u0434\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0431\u044b \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430\u043c\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u043e\u0432. \u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>\u0431\u0435\u0441\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u043c<\/i>. ASCII-\u043a\u043e\u0434 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0441\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u041d\u043e \u043a\u043e\u0434\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0442\u043e\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0441\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u043c\u0438. \u0422\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u044b\u0435 \u043d\u043e\u043c\u0435\u0440\u0430 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0435\u0441\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0435. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432 \u0428\u0432\u0435\u0446\u0438\u0438 \u0432\u0432\u0435\u043b\u0438 \u0442\u0435\u043b\u0435\u0444\u043e\u043d \u044d\u043a\u0441\u0442\u0440\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u043c\u043e\u0449\u0438 112, \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u043d\u043e\u043c\u0435\u0440\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0441\u043e 112. \u0410 \u0432 \u0421\u0428\u0410 \u043d\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0441 911.<\/p>\n<p>  \u0414\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0441\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0439 \u043a\u043e\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0438\u043c\u0435\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430. \u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u0441\u0443\u043c\u043c\u0430 \u0434\u043b\u0438\u043d \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0438\u0445 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u0431\u0443\u0434\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>\u0431\u0435\u0441\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e<\/i>, \u0438\u043b\u0438 <i>\u043a\u043e\u0434\u043e\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/i>, \u0432 \u0447\u0435\u0441\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u0435\u043b\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043a\u043e\u0434\u043e\u0432.<\/p>\n<p>  <a name=\"7\"><\/a><\/p>\n<h3>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/h3>\n<p>  \u0418\u0437\u0443\u0447\u0430\u044f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0439 \u0434\u043e\u043a\u0442\u043e\u0440\u0441\u043a\u043e\u0439 \u0434\u0438\u0441\u0441\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043f\u043e \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0438\u0438 \u0432 MIT, \u0414\u044d\u0432\u0438\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0430\u043b \u043a\u0443\u0440\u0441 \u043f\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0438\u0442\u0430\u043b \u0420\u043e\u0431\u0435\u0440\u0442 \u0424\u0430\u043d\u043e. <a href=\"https:\/\/www.huffmancoding.com\/my-uncle\/scientific-american\">\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043b\u0435\u0433\u0435\u043d\u0434\u0435<\/a>, \u0424\u0430\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u0441\u0432\u043e\u0438\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c: \u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0437\u0430\u043c\u0435\u043d \u0438\u043b\u0438 \u043a\u0443\u0440\u0441\u043e\u0432\u0443\u044e. \u0425\u0430\u0444\u0444\u043c\u0430\u043d \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0438 \u0435\u043c\u0443 \u0434\u0430\u043b\u0438 \u0442\u0435\u043c\u0443 \u043f\u043e\u0438\u0441\u043a\u0430 \u0431\u0435c\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0437\u043d\u0430\u043b \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0434 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441\u0430\u043c \u0424\u0430\u043d\u043e (\u0441\u0430\u043c\u044b\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0432 \u0442\u0435 \u0433\u043e\u0434\u044b \u0431\u044b\u043b <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%A8%D0%B5%D0%BD%D0%BD%D0%BE%D0%BD%D0%B0_%E2%80%94_%D0%A4%D0%B0%D0%BD%D0%BE\">\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0428\u0435\u043d\u043d\u043e\u043d\u0430-\u0424\u0430\u043d\u043e<\/a>). \u0420\u0430\u0431\u043e\u0442\u0430 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0431\u044b\u043b\u0430 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u0430 \u0432 1952-\u043c \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/www.ic.tu-berlin.de\/fileadmin\/fg121\/Source-Coding_WS12\/selected-readings\/10_04051119.pdf\">A Method for the Construction of Minimum-Redundancy Codes<\/a> in 1952. \u0418 \u0441 \u0442\u0435\u0445 \u043f\u043e\u0440 \u0435\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0448\u0438\u0440\u043e\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cf0\/4fe\/003\/cf04fe00303a663594eea8e8db063002.jpg\"><\/div>\n<p>  <i>\u0414\u044d\u0432\u0438\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d <a href=\"https:\/\/www.cise.ufl.edu\/~manuel\/huffman\/press.release.html\">\u043f\u0440\u0435\u0441\u0441-\u0440\u0435\u043b\u0438\u0437<\/a> UC Santa Cruz.<\/i><\/p>\n<p>  \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0431\u0435\u0441\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043b\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u0438\u0445 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0432\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u2014 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0425 \u0438 Y \u2014 \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u0445 \u043d\u0430 <i>\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b<\/i>, \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0438\u0439 \u00abX \u0438\u043b\u0438 Y\u00bb. \u0427\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u0430 \u0447\u0430\u0441\u0442\u043e\u0442 \u0434\u0432\u0443\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u041a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0434\u043b\u044f X \u0438 Y \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c\u0438 \u043a\u043e\u0434\u043e\u0432\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u044b \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u043c\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u0443 \u00abX \u0438\u043b\u0438 Y\u00bb, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438\u0434\u0451\u0442 0 \u0438\u043b\u0438 1, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b. \u041a\u043e\u0433\u0434\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044e\u0442\u0441\u044f \u0434\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 (<a href=\"https:\/\/www.youtube.com\/watch?v=ZdooBTdW5bM\">\u0432\u0438\u0434\u0435\u043e\u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/a>).<\/p>\n<p>  \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>\u0421\u0438\u043c\u0432\u043e\u043b<\/strong><\/td>\n<td><strong>\u0427\u0430\u0441\u0442\u043e\u0442\u0430<\/strong><\/td>\n<\/tr>\n<tr>\n<td>A<\/td>\n<td>6<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>3<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e90\/a8f\/4e4\/e90a8f4e47c49cd14ca3a55f884d55e3.png\"><\/div>\n<p>  \u0414\u0432\u0430 \u0441\u0430\u043c\u044b\u0445 \u0440\u0435\u0434\u043a\u0438\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u0430, C \u0438 D, \u0443\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442 C \u0438 D:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7e9\/b0b\/aed\/7e9b0baeda34fc4d368c933bed7e1d15.png\"><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u044b\u043c\u0438 \u0440\u0435\u0434\u043a\u0438\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0441\u0442\u0430\u043b\u0438 B \u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 5. \u041e\u043d\u0438 \u0443\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 9:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bca\/94b\/ad6\/bca94bad698775402e8bab2c6a20f664.png\"><\/div>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, A \u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 9 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 15:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/260\/aa3\/800\/260aa38005cf701421881214915d859a.png\"><\/div>\n<p>  \u0412\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0441\u0432\u0451\u043b\u0441\u044f \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u0443, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430.<\/p>\n<p>  \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0437\u0434\u0430\u043b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>\u0434\u0435\u0440\u0435\u0432\u043e\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/i>. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u2014 \u044d\u0442\u043e \u043b\u0438\u0441\u0442\u044c\u044f, \u0430 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u0442\u0435\u043c \u0432\u044b\u0448\u0435 \u043e\u043d \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u043e\u0442 \u043a\u043e\u0440\u043d\u044f \u0434\u0435\u0440\u0435\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f 0 \u0438\u043b\u0438 1, \u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432\u043b\u0435\u0432\u043e \u0438\u043b\u0438 \u0432\u043f\u0440\u0430\u0432\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>\u0421\u0438\u043c\u0432\u043e\u043b<\/strong><\/td>\n<td><strong>\u041a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e<\/strong><\/td>\n<\/tr>\n<tr>\n<td>A<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>10<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>110<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>111<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041d\u0438 \u043e\u0434\u043d\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0427\u0435\u043c \u0447\u0430\u0449\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b, \u0442\u0435\u043c \u043a\u043e\u0440\u043e\u0447\u0435 \u0435\u0433\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<p>  \u0414\u0435\u0440\u0435\u0432\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u043b\u044f \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u043a\u043e\u0440\u043d\u044f \u0438 \u0438\u0434\u0451\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043e \u0438\u043b\u0438 \u043d\u0430\u043b\u0435\u0432\u043e \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 0 \u0438\u043b\u0438 1 \u043f\u0435\u0440\u0435\u0434 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u043e\u043a\u0430 010100 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 ABBA.<\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u0438\u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u0430 \u0433\u043b\u0443\u0431\u0438\u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u0434\u0435\u0440\u0435\u0432\u0430. \u041a\u0430\u043a \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0441\u0430\u043c\u0438\u0445 \u0441\u043b\u043e\u0432. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0431\u0443\u0434\u0443\u0442 \u0434\u043b\u0438\u043d\u044b \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432.<\/p>\n<p>  \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u0447\u0430\u0441\u0442\u043e\u0442 \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%B2%D0%BE%D0%B8%D1%87%D0%BD%D0%B0%D1%8F_%D0%BA%D1%83%D1%87%D0%B0\">\u0434\u0432\u043e\u0438\u0447\u043d\u0430\u044f \u043a\u0443\u0447\u0430<\/a>. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 <i>min-\u043a\u0443\u0447\u0430<\/i>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0430\u0432\u0435\u0440\u0445\u0443.<\/p>\n<pre><code class=\"cpp\">\/* Swap the 32-bit values pointed to by a and b. *\/ static void swap32(uint32_t *a, uint32_t *b) {         uint32_t tmp;          tmp = *a;         *a = *b;         *b = tmp; }  \/* Move element i in the n-element heap down to restore the minheap property. *\/ static void minheap_down(uint32_t *heap, size_t n, size_t i) {         size_t left, right, min;          assert(i &gt;= 1 &amp;&amp; i &lt;= n &amp;&amp; &quot;i must be inside the heap&quot;);          \/* While the ith element has at least one child. *\/         while (i * 2 &lt;= n) {                 left = i * 2;                 right = i * 2 + 1;                  \/* Find the child with lowest value. *\/                 min = left;                 if (right &lt;= n &amp;&amp; heap[right] &lt; heap[left]) {                         min = right;                 }                  \/* Move i down if it is larger. *\/                 if (heap[min] &lt; heap[i]) {                         swap32(&amp;heap[min], &amp;heap[i]);                         i = min;                 } else {                         break;                 }         } }  \/* Establish minheap property for heap[1..n]. *\/ static void minheap_heapify(uint32_t *heap, size_t n) {         size_t i;          \/* Floyd's algorithm. *\/         for (i = n \/ 2; i &gt;= 1; i--) {                 minheap_down(heap, n, i);         } } <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 <code>n<\/code> \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0443\u0447\u0443 \u0438\u0437 <code>n<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u00ab\u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u00bb \u0441 \u043d\u0438\u043c \u043e\u0431\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u00ab\u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0432\u044f\u0437\u0438\u00bb.<\/p>\n<p>  \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f <code>n<\/code>-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e\u0439 \u043a\u0443\u0447\u0438 \u0438 <code>n<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u0432\u044f\u0437\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 <code>n * 2 + 1<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432 \u043a\u0443\u0447\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <a href=\"https:\/\/people.eng.unimelb.edu.au\/ammoffat\/mg\/\">Managing Gigabytes<\/a> \u0423\u0438\u0442\u0442\u0435\u043d\u0430, \u041c\u043e\u0444\u0444\u0430\u0442\u0430 \u0438 \u0411\u0435\u043b\u043b\u0430.<\/p>\n<p>  \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0437\u043b\u0435 \u043a\u0443\u0447\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 16 \u0441\u0442\u0430\u0440\u0448\u0438\u0445 \u0431\u0438\u0442\u043e\u0432 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u0430 16 \u043c\u043b\u0430\u0434\u0448\u0438\u0445 \u2014 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0432\u044f\u0437\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430. \u0417\u0430 \u0441\u0447\u0451\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u0448\u0438\u0445 \u0431\u0438\u0442\u043e\u0432 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0447\u0430\u0441\u0442\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c 32-\u0431\u0438\u0442\u043d\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u0443\u0447\u0438.<\/p>\n<p>  \u0418\u0437-\u0437\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 16 \u0431\u0438\u0442\u043e\u0432. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c \u044d\u0442\u0430 \u0441\u0443\u043c\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0432 16 \u0431\u0438\u0442\u043e\u0432. \u041d\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Deflate \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e 64 535 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.<\/p>\n<p>  \u0421\u0438\u043c\u0432\u043e\u043b\u044b \u0441 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0438 \u043d\u0435 \u0441\u0442\u0430\u043d\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u044b, \u043c\u044b \u00ab\u0441\u0433\u043b\u0430\u0434\u0438\u043c\u00bb \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442, \u043d\u0430\u043b\u043e\u0436\u0438\u0432 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u043f\u044f\u0442\u044c (\u0434\u0430, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>goto<\/code>). \u0415\u0441\u0442\u044c \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e \u0433\u043b\u0443\u0431\u0438\u043d\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430, \u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0441\u0442 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d.<\/p>\n<pre><code class=\"cpp\">#define MAX_HUFFMAN_SYMBOLS 288      \/* Deflate uses max 288 symbols. *\/  \/* Construct a Huffman code for n symbols with the frequencies in freq, and  * codeword length limited to max_len. The sum of the frequencies must be &lt;=  * UINT16_MAX. max_len must be large enough that a code is always possible,  * i.e. 2 ** max_len &gt;= n. Symbols with zero frequency are not part of the code  * and get length zero. Outputs the codeword lengths in lengths[0..n-1]. *\/ static void compute_huffman_lengths(const uint16_t *freqs, size_t n,                                     uint8_t max_len, uint8_t *lengths) {         uint32_t nodes[MAX_HUFFMAN_SYMBOLS * 2 + 1], p, q;         uint16_t freq;         size_t i, h, l;         uint16_t freq_cap = UINT16_MAX;  #ifndef NDEBUG         uint32_t freq_sum = 0;         for (i = 0; i &lt; n; i++) {                 freq_sum += freqs[i];         }         assert(freq_sum &lt;= UINT16_MAX &amp;&amp; &quot;Frequency sum too large!&quot;); #endif          assert(n &lt;= MAX_HUFFMAN_SYMBOLS);         assert((1U &lt;&lt; max_len) &gt;= n &amp;&amp; &quot;max_len must be large enough&quot;);  try_again:         \/* Initialize the heap. h is the heap size. *\/         h = 0;         for (i = 0; i &lt; n; i++) {                 freq = freqs[i];                  if (freq == 0) {                         continue; \/* Ignore zero-frequency symbols. *\/                 }                 if (freq &gt; freq_cap) {                         freq = freq_cap; \/* Enforce the frequency cap. *\/                 }                  \/* High 16 bits: Symbol frequency.                    Low 16 bits:  Symbol link element index. *\/                 h++;                 nodes[h] = ((uint32_t)freq &lt;&lt; 16) | (uint32_t)(n + h);         }         minheap_heapify(nodes, h);          \/* Special case for less than two non-zero symbols. *\/         if (h &lt; 2) {                 for (i = 0; i &lt; n; i++) {                         lengths[i] = (freqs[i] == 0) ? 0 : 1;                 }                 return;         }          \/* Build the Huffman tree. *\/         while (h &gt; 1) {                 \/* Remove the lowest frequency node p from the heap. *\/                 p = nodes[1];                 nodes[1] = nodes[h--];                 minheap_down(nodes, h, 1);                  \/* Get q, the next lowest frequency node. *\/                 q = nodes[1];                  \/* Replace q with a new symbol with the combined frequencies of                    p and q, and with the no longer used h+1'th node as the                    link element. *\/                 nodes[1] = ((p &amp; 0xffff0000) + (q &amp; 0xffff0000))                            | (uint32_t)(h + 1);                  \/* Set the links of p and q to point to the link element of                    the new node. *\/                 nodes[p &amp; 0xffff] = nodes[q &amp; 0xffff] = (uint32_t)(h + 1);                  \/* Move the new symbol down to restore heap property. *\/                 minheap_down(nodes, h, 1);         }          \/* Compute the codeword length for each symbol. *\/         h = 0;         for (i = 0; i &lt; n; i++) {                 if (freqs[i] == 0) {                         lengths[i] = 0;                         continue;                 }                 h++;                  \/* Link element for the i'th symbol. *\/                 p = nodes[n + h];                  \/* Follow the links until we hit the root (link index 2). *\/                 l = 1;                 while (p != 2) {                         l++;                         p = nodes[p];                 }                  if (l &gt; max_len) {                         \/* Lower freq_cap to flatten the distribution. *\/                         assert(freq_cap != 1 &amp;&amp; &quot;Cannot lower freq_cap!&quot;);                         freq_cap \/= 2;                         goto try_again;                 }                  assert(l &lt;= UINT8_MAX);                 lengths[i] = (uint8_t)l;         } } <\/code><\/pre>\n<p>  \u042d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0443 \u0441 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u043a\u0443\u0447\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0434\u0432\u0443\u0445 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u0445. \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0435. \u041a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b, \u043e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0442\u043e\u0440\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u0438\u043c\u0432\u043e\u043b \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u043f\u0438\u0441\u0430\u043d <a href=\"https:\/\/www.staff.science.uu.nl\/~leeuw112\/\">Jan van Leeuwen<\/a> \u0432 <a href=\"https:\/\/www.staff.science.uu.nl\/~leeuw112\/huffman.pdf\">On the Construction of Huffman Trees<\/a> (1976).<\/p>\n<p>  \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0431\u0435\u0441\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432, \u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b: <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D1%80%D0%B8%D1%84%D0%BC%D0%B5%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%BE%D0%B5_%D0%BA%D0%BE%D0%B4%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5\">\u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a> \u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Asymmetric_numeral_systems\">\u0430\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/a>.<\/p>\n<p>  <a name=\"8\"><\/a><\/p>\n<h3>\u041a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u0434\u044b \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/h3>\n<p>  \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/260\/aa3\/800\/260aa38005cf701421881214915d859a.png\"><\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0438\u0434\u0442\u0438 \u043e\u0442 \u043a\u043e\u0440\u043d\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 0 \u0434\u043b\u044f \u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0442\u043a\u0438 \u0438 1 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u043e\u0439, \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u043a\u043e\u0434\u044b:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>\u0421\u0438\u043c\u0432\u043e\u043b<\/strong><\/td>\n<td><strong>\u041a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e<\/strong><\/td>\n<\/tr>\n<tr>\n<td>A<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>10<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>110<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>111<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 0 \u0434\u043b\u044f \u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0442\u043a\u0438 \u0438 1 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u043e\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c. \u0415\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>\u0421\u0438\u043c\u0432\u043e\u043b<\/strong><\/td>\n<td><strong>\u041a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e<\/strong><\/td>\n<\/tr>\n<tr>\n<td>A<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>01<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>001<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>000<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0442\u043a\u0438, \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0438\u0437 \u043d\u043e\u0434\u044b, \u043d\u0443\u043b\u0451\u043c \u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0435\u0439 (\u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0442\u043a\u0438 \u0431\u044b\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u043c\u0438), \u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/29b\/acb\/499\/29bacb4999e9a3f530f22634846a97b7.png\"><\/div>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>\u0421\u0438\u043c\u0432\u043e\u043b<\/strong><\/td>\n<td><strong>\u041a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e<\/strong><\/td>\n<\/tr>\n<tr>\n<td>A<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>11<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>100<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>101<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u0425\u043e\u0442\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0434\u0430\u0435\u0442 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u0438\u043d\u044b \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u0434\u043b\u044f \u0431\u0435\u0441\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432.<\/p>\n<p>  \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0434\u043b\u0438\u043d\u0443 \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430, \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043b\u0438\u043d\u044b \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u0441\u043e \u0441\u0436\u0430\u0442\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438: \u0434\u0435\u043a\u043e\u0434\u0435\u0440 \u0441\u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0445 \u0434\u043b\u0438\u043d. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430, \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. \u0414\u0440\u0443\u0433\u0438\u043c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u0434\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<p>  \u0418\u0434\u0435\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u0434 \u043e\u0434\u043d\u043e\u043c\u0443 \u0437\u0430 \u0440\u0430\u0437. \u041f\u0435\u0440\u0432\u044b\u043c \u043a\u043e\u0434\u043e\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f 0. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u043e\u0432\u043e \u0434\u043b\u0438\u043d\u043e\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0441\u043b\u043e\u0432\u043e + 1. \u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0434\u043b\u0438\u043d\u043e\u0439 N \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0434\u043b\u0438\u043d\u043e\u0439 N-1, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u044b (\u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043d\u043e\u0432\u043e\u0435 \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e) \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0434\u0438\u043d \u0448\u0430\u0433 \u0432\u043b\u0435\u0432\u043e (\u0434\u043b\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b).<\/p>\n<p>  \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0434\u0435\u0440\u0435\u0432\u0430 \u0425\u043e\u0444\u0444\u043c\u0430\u043d\u0430 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043b\u0438\u0441\u0442\u044c\u044f\u043c \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0441\u043b\u0435\u0432\u0430-\u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0443\u0440\u043e\u0432\u043d\u044e \u0437\u0430 \u0440\u0430\u0437, \u0441\u043c\u0435\u0449\u0430\u044f\u0441\u044c \u0432\u043b\u0435\u0432\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c.<\/p>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 A-B-C-D \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0441 \u0434\u043b\u0438\u043d\u0430\u043c\u0438 1, 2, 3 \u0438 3. \u041f\u0435\u0440\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f 0. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043b\u043e\u0432\u043e \u0434\u043b\u0438\u043d\u043e\u0439 1. \u0414\u043b\u044f \u0434\u043b\u0438\u043d\u044b 2 \u043c\u044b \u0431\u0435\u0440\u0451\u043c 0 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c 1 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c \u0434\u0432\u0443\u0445\u0431\u0438\u0442\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432, \u0441\u043c\u0435\u0449\u0430\u0435\u043c\u0441\u044f \u0432\u043b\u0435\u0432\u043e \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 10. \u042d\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043b\u043e\u0432\u043e \u0434\u043b\u0438\u043d\u043e\u0439 2. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b 3 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c 1 \u0438 \u0441\u043c\u0435\u0449\u0430\u0435\u043c\u0441\u044f: 110. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0434\u043b\u0438\u043d\u043e\u0439 3 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c 1: 111.<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>\u0421\u0438\u043c\u0432\u043e\u043b<\/strong><\/td>\n<td><strong>\u041a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e<\/strong><\/td>\n<\/tr>\n<tr>\n<td>A<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>10<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>110<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>111<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u0434\u043e\u0432. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c Deflate \u043e\u0436\u0438\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0431\u0443\u0434\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 LSB-first (\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043b\u0430\u0434\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0430\u0449\u0438\u043c \u0431\u0438\u0442\u043e\u043c). \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0438\u0442 \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u043c \u0437\u043d\u0430\u0447\u0430\u0449\u0435\u043c \u0431\u0438\u0442\u0435. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0438\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<pre><code class=\"cpp\">#define MAX_HUFFMAN_BITS 15          \/* Deflate uses max 15-bit codewords. *\/  static void compute_canonical_code(uint16_t *codewords, const uint8_t *lengths,                                    size_t n) {         size_t i;         uint16_t count[MAX_HUFFMAN_BITS + 1] = {0};         uint16_t code[MAX_HUFFMAN_BITS + 1];         int l;          \/* Count the number of codewords of each length. *\/         for (i = 0; i &lt; n; i++) {                 count[lengths[i]]++;         }         count[0] = 0; \/* Ignore zero-length codes. *\/          \/* Compute the first codeword for each length. *\/         code[0] = 0;         for (l = 1; l &lt;= MAX_HUFFMAN_BITS; l++) {                 code[l] = (uint16_t)((code[l - 1] + count[l - 1]) &lt;&lt; 1);         }          \/* Assign a codeword for each symbol. *\/         for (i = 0; i &lt; n; i++) {                 l = lengths[i];                 if (l == 0) {                         continue;                 }                  codewords[i] = reverse16(code[l]++, l); \/* Make it LSB-first. *\/         } }  \/* Reverse the n least significant bits of x.    The (16 - n) most significant bits of the result will be zero. *\/ static inline uint16_t reverse16(uint16_t x, int n) {         uint16_t lo, hi;         uint16_t reversed;          assert(n &gt; 0);         assert(n &lt;= 16);          lo = x &amp; 0xff;         hi = x &gt;&gt; 8;          reversed = (uint16_t)((reverse8_tbl[lo] &lt;&lt; 8) | reverse8_tbl[hi]);          return reversed &gt;&gt; (16 - n); } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430:<\/p>\n<pre><code class=\"cpp\">typedef struct huffman_encoder_t huffman_encoder_t; struct huffman_encoder_t {         uint16_t codewords[MAX_HUFFMAN_SYMBOLS]; \/* LSB-first codewords. *\/         uint8_t lengths[MAX_HUFFMAN_SYMBOLS];    \/* Codeword lengths. *\/ };  \/* Initialize a Huffman encoder based on the n symbol frequencies. *\/ void huffman_encoder_init(huffman_encoder_t *e, const uint16_t *freqs, size_t n,                           uint8_t max_codeword_len) {         assert(n &lt;= MAX_HUFFMAN_SYMBOLS);         assert(max_codeword_len &lt;= MAX_HUFFMAN_BITS);          compute_huffman_lengths(freqs, n, max_codeword_len, e-&gt;lengths);         compute_canonical_code(e-&gt;codewords, e-&gt;lengths, n); } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0436\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u0438\u043d \u043a\u043e\u0434\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">\/* Initialize a Huffman encoder based on the n codeword lengths. *\/ void huffman_encoder_init2(huffman_encoder_t *e, const uint8_t *lengths,                            size_t n) {         size_t i;          for (i = 0; i &lt; n; i++) {                 e-&gt;lengths[i] = lengths[i];         }         compute_canonical_code(e-&gt;codewords, e-&gt;lengths, n); } <\/code><\/pre>\n<p>  <a name=\"9\"><\/a><\/p>\n<h3>\u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/h3>\n<p>  \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u0445\u043e\u0434\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043a\u043e\u0440\u043d\u044f, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0431\u0438\u0442\u0443 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u0440\u0430\u0437 \u0438 \u0440\u0435\u0448\u0430\u044f, \u043a\u0430\u043a\u0443\u044e \u0432\u0435\u0442\u043a\u0443 \u0431\u0440\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439, \u043b\u0435\u0432\u0443\u044e \u0438\u043b\u0438 \u043f\u0440\u0430\u0432\u0443\u044e. \u041a\u043e\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0439 \u0443\u0437\u0435\u043b, \u044d\u0442\u043e \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b.<\/p>\n<p>  \u042d\u0442\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443 \u0447\u0430\u0441\u0442\u043e \u0443\u0447\u0430\u0442 \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0430\u0445 \u0438 \u043a\u043d\u0438\u0433\u0430\u0445. \u041e\u043d \u043f\u0440\u043e\u0441\u0442 \u0438 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u0435\u043d, \u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0431\u0438\u0442\u0443 \u0437\u0430 \u0440\u0430\u0437 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0414\u043b\u044f \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0440\u0430\u0432\u043d\u0430 \u0442\u0440\u0451\u043c \u0431\u0438\u0442\u0430\u043c, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>\u0411\u0438\u0442\u044b<\/strong><\/td>\n<td><strong>\u0421\u0438\u043c\u0432\u043e\u043b<\/strong><\/td>\n<td><strong>\u0414\u043b\u0438\u043d\u0430 \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>0<\/strong>00<\/td>\n<td>A<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td><strong>0<\/strong>01<\/td>\n<td>A<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td><strong>0<\/strong>10<\/td>\n<td>A<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td><strong>0<\/strong>11<\/td>\n<td>A<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td><strong>10<\/strong>0<\/td>\n<td>B<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td><strong>10<\/strong>1<\/td>\n<td>B<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td><strong>110<\/strong><\/td>\n<td>C<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td><strong>111<\/strong><\/td>\n<td>D<\/td>\n<td>3<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u0425\u043e\u0442\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432\u0441\u0435\u0433\u043e \u0447\u0435\u0442\u044b\u0440\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0432\u043e\u0441\u0435\u043c\u044c\u044e \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0442\u0440\u0451\u0445\u0431\u0438\u0442\u043d\u044b\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438. \u0421\u0438\u043c\u0432\u043e\u043b\u044b \u0441 \u043a\u043e\u0434\u043e\u0432\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043a\u043e\u0440\u043e\u0447\u0435 \u0442\u0440\u0451\u0445 \u0431\u0438\u0442\u043e\u0432 \u0438\u043c\u0435\u044e\u0442 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u043e\u0432\u043e 10 \u0431\u044b\u043b\u043e \u00ab\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043e\u00bb <strong>10<\/strong>0 \u0438 <strong>10<\/strong>1, \u0447\u0442\u043e\u0431\u044b \u043e\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u0440\u0451\u0445\u0431\u0438\u0442\u043d\u044b\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 10.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0442\u0440\u0451\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432 \u0438 \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0438 \u0434\u043b\u0438\u043d\u0443 \u0435\u0433\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430. \u0414\u043b\u0438\u043d\u0430 \u0432\u0430\u0436\u043d\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0438 \u0431\u0438\u0442\u0430, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432, \u043a\u0430\u043a\u043e\u0432\u0430 \u0434\u043b\u0438\u043d\u0430 \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0443\u0434\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0431\u0438\u0442\u0435 \u0432 \u0434\u043b\u0438\u043d\u0435 \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u044d\u0448 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u0410 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041a\u0430\u043a \u043f\u0440\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u044b\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430, \u0442\u0430\u043a \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>  <a href=\"https:\/\/github.com\/madler\/zlib\/blob\/v1.2.11\/doc\/algorithm.txt#L58\">\u0412 zlib<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446. \u0415\u0441\u043b\u0438 \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0442\u043e \u043f\u043e\u0438\u0441\u043a \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u0442 \u0432\u043e \u0432\u0442\u043e\u0440\u0438\u0447\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0431\u0438\u0442\u044b.<\/p>\n<p>  \u041d\u043e \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u043e\u0439, \u043e\u0447\u0435\u043d\u044c \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u0434\u043e\u0432 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430. \u041e\u043d \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <i>On the Implementation of Minimum Redundancy Prefix Codes<\/i> (\u041c\u043e\u0444\u0444\u0430\u0442 \u0438 \u0422\u0443\u0440\u043f\u0438\u043d, 1997-\u0439), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u0442\u044c\u0435<a href=\"http:\/\/cbloomrants.blogspot.com\/2010\/08\/08-12-10-lost-huffman-paper.html\"> The Lost Huffman Paper<\/a> \u0427\u0430\u0440\u043b\u044c\u0437\u0430 \u0411\u043b\u0443\u043c\u0430.<\/p>\n<p>  \u0412\u043e\u0437\u044c\u043c\u0451\u043c \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438\u0437 \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438: 0, 10, 110, 111. \u0411\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0434\u043b\u0438\u043d, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u043e\u043c\u0435\u0440 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0432 \u043e\u0431\u0449\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u2014 \u00ab\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u00bb.<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>\u0414\u043b\u0438\u043d\u0430 \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430<\/strong><\/td>\n<td><strong>\u041f\u0435\u0440\u0432\u043e\u0435 \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e<\/strong><\/td>\n<td><strong>\u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441<\/strong><\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>0<\/td>\n<td>1 (A)<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>10<\/td>\n<td>2 (B)<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>110<\/td>\n<td>3 &copy;<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0442\u043e \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0430\u0439\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u044d\u0442\u0438 \u0431\u0438\u0442\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0442\u0440\u0451\u0445\u0431\u0438\u0442\u043d\u043e\u0433\u043e 111 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u044d\u0442\u043e\u0439 \u0434\u043b\u0438\u043d\u044b (110). \u041f\u0435\u0440\u0432\u044b\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0442\u0430\u043a\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f 3, \u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0438\u043d\u0434\u0435\u043a\u0441 4. \u0414\u0440\u0443\u0433\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">sym_idx = d-&gt;first_symbol[len] + (bits - d-&gt;first_code[len]); sym = d-&gt;syms[sym_idx]; <\/code><\/pre>\n<p>  \u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f: \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043c\u0438\u043d\u0443\u0441 \u043f\u0435\u0440\u0432\u043e\u0435 \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/p>\n<pre><code class=\"cpp\">sym_idx = d-&gt;offset_first_sym_idx[len] + bits; sym = d-&gt;syms[sym_idx]; <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u0442\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c, \u043c\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u0441\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0435 \u043e\u0434\u043d\u043e\u0431\u0438\u0442\u043d\u044b\u0435 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0441\u0442\u0440\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 1, \u0434\u0432\u0443\u0445\u0431\u0438\u0442\u043d\u044b\u0435 \u2014 \u0441\u0442\u0440\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 11, \u0442\u0440\u0451\u0445\u0431\u0438\u0442\u043d\u044b\u0435 \u2014 \u043c\u0435\u043d\u044c\u0448\u0435 1000 (\u043f\u043e \u0441\u0443\u0442\u0438, \u0432\u0435\u0440\u043d\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0440\u0451\u0445\u0431\u0438\u0442\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439). \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0435 N-\u0431\u0438\u0442\u043d\u043e\u0435 \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e N-\u0431\u0438\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u043f\u043b\u044e\u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e N-\u0431\u0438\u0442\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043c\u0435\u0449\u0430\u0442\u044c \u0432\u043b\u0435\u0432\u043e \u044d\u0442\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u044b, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0442\u0440\u0451\u0445\u0431\u0438\u0442\u043d\u043e\u0439 \u0448\u0438\u0440\u0438\u043d\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u044d\u0442\u043e <i>\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0431\u0438\u0442\u0430\u043c\u0438<\/i> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0434\u043b\u0438\u043d \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>\u0414\u043b\u0438\u043d\u0430 \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430<\/strong><\/td>\n<td><strong>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0442\u044b<\/strong><\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>100<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>110<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>1000<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  <i>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044c \u0434\u043b\u044f \u0434\u043b\u0438\u043d\u044b 3 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f \u0434\u043e 4 \u0431\u0438\u0442\u043e\u0432, \u043d\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u043b\u044e\u0431\u043e\u0435 \u0442\u0440\u0451\u0445\u0431\u0438\u0442\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/i><\/p>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u0438 \u0442\u0440\u0451\u0445\u0431\u0438\u0442\u043d\u044b\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0431\u0438\u0442\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u043d\u0430\u0448\u0435 \u043a\u043e\u0434\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043c\u044b \u0441\u043c\u0435\u0449\u0430\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0431\u0438\u0442\u044b, \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441:<\/p>\n<pre><code class=\"cpp\">for (len = 1; len &lt;= 3; len++) {         if (bits &lt; d-&gt;sentinel_bits[len]) {                 bits &gt;&gt;= 3 - len;  \/* Get the len most significant bits. *\/                 sym_idx = d-&gt;offset_first_sym_idx[len] + bits;         } } <\/code><\/pre>\n<p>  \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0431\u0438\u0442\u043e\u0432 \u0432 \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u043d\u043e \u0437\u0430\u0442\u043e \u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0441\u0445\u043e\u0434\u0443\u0435\u0442\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435, \u0430 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0447\u0430\u0449\u0435, \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u0435 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">#define HUFFMAN_LOOKUP_TABLE_BITS 8  \/* Seems a good trade-off. *\/  typedef struct huffman_decoder_t huffman_decoder_t; struct huffman_decoder_t {         \/* Lookup table for fast decoding of short codewords. *\/         struct {                 uint16_t sym : 9;  \/* Wide enough to fit the max symbol nbr. *\/                 uint16_t len : 7;  \/* 0 means no symbol. *\/         } table[1U &lt;&lt; HUFFMAN_LOOKUP_TABLE_BITS];          \/* &quot;Sentinel bits&quot; value for each codeword length. *\/         uint16_t sentinel_bits[MAX_HUFFMAN_BITS + 1];          \/* First symbol index minus first codeword mod 2**16 for each length. *\/         uint16_t offset_first_sym_idx[MAX_HUFFMAN_BITS + 1];          \/* Map from symbol index to symbol. *\/         uint16_t syms[MAX_HUFFMAN_SYMBOLS]; #ifndef NDEBUG         size_t num_syms; #endif };  \/* Get the n least significant bits of x. *\/ static inline uint64_t lsb(uint64_t x, int n) {         assert(n &gt;= 0 &amp;&amp; n &lt;= 63);         return x &amp; (((uint64_t)1 &lt;&lt; n) - 1); }  \/* Use the decoder d to decode a symbol from the LSB-first zero-padded bits.  * Returns the decoded symbol number or -1 if no symbol could be decoded.  * *num_used_bits will be set to the number of bits used to decode the symbol,  * or zero if no symbol could be decoded. *\/ static inline int huffman_decode(const huffman_decoder_t *d, uint16_t bits,                                  size_t *num_used_bits) {         uint64_t lookup_bits;         size_t l;         size_t sym_idx;          \/* First try the lookup table. *\/         lookup_bits = lsb(bits, HUFFMAN_LOOKUP_TABLE_BITS);         assert(lookup_bits &lt; sizeof(d-&gt;table) \/ sizeof(d-&gt;table[0]));         if (d-&gt;table[lookup_bits].len != 0) {                 assert(d-&gt;table[lookup_bits].len &lt;= HUFFMAN_LOOKUP_TABLE_BITS);                 assert(d-&gt;table[lookup_bits].sym &lt; d-&gt;num_syms);                  *num_used_bits = d-&gt;table[lookup_bits].len;                 return d-&gt;table[lookup_bits].sym;         }          \/* Then do canonical decoding with the bits in MSB-first order. *\/         bits = reverse16(bits, MAX_HUFFMAN_BITS);         for (l = HUFFMAN_LOOKUP_TABLE_BITS + 1; l &lt;= MAX_HUFFMAN_BITS; l++) {                 if (bits &lt; d-&gt;sentinel_bits[l]) {                         bits &gt;&gt;= MAX_HUFFMAN_BITS - l;                          sym_idx = (uint16_t)(d-&gt;offset_first_sym_idx[l] + bits);                         assert(sym_idx &lt; d-&gt;num_syms);                          *num_used_bits = l;                         return d-&gt;syms[sym_idx];                 }         }          *num_used_bits = 0;         return -1; } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430 \u043c\u044b \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u0434\u044b, \u043a\u0430\u043a \u0434\u043b\u044f <a href=\"https:\/\/www.hanshq.net\/zip.html#huffman_encoder_init\">huffman_encoder_init<\/a>, \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"cpp\">\/* Initialize huffman decoder d for a code defined by the n codeword lengths.    Returns false if the codeword lengths do not correspond to a valid prefix    code. *\/ bool huffman_decoder_init(huffman_decoder_t *d, const uint8_t *lengths,                           size_t n) {         size_t i;         uint16_t count[MAX_HUFFMAN_BITS + 1] = {0};         uint16_t code[MAX_HUFFMAN_BITS + 1];         uint32_t s;         uint16_t sym_idx[MAX_HUFFMAN_BITS + 1];         int l;  #ifndef NDEBUG         assert(n &lt;= MAX_HUFFMAN_SYMBOLS);         d-&gt;num_syms = n; #endif          \/* Zero-initialize the lookup table. *\/         for (i = 0; i &lt; sizeof(d-&gt;table) \/ sizeof(d-&gt;table[0]); i++) {                 d-&gt;table[i].len = 0;         }          \/* Count the number of codewords of each length. *\/         for (i = 0; i &lt; n; i++) {                 assert(lengths[i] &lt;= MAX_HUFFMAN_BITS);                 count[lengths[i]]++;         }         count[0] = 0;  \/* Ignore zero-length codewords. *\/          \/* Compute sentinel_bits and offset_first_sym_idx for each length. *\/         code[0] = 0;         sym_idx[0] = 0;         for (l = 1; l &lt;= MAX_HUFFMAN_BITS; l++) {                 \/* First canonical codeword of this length. *\/                 code[l] = (uint16_t)((code[l - 1] + count[l - 1]) &lt;&lt; 1);                  if (count[l] != 0 &amp;&amp; code[l] + count[l] - 1 &gt; (1U &lt;&lt; l) - 1) {                         \/* The last codeword is longer than l bits. *\/                         return false;                 }                  s = (uint32_t)((code[l] + count[l]) &lt;&lt; (MAX_HUFFMAN_BITS - l));                 d-&gt;sentinel_bits[l] = (uint16_t)s;                 assert(d-&gt;sentinel_bits[l] == s &amp;&amp; &quot;No overflow.&quot;);                  sym_idx[l] = sym_idx[l - 1] + count[l - 1];                 d-&gt;offset_first_sym_idx[l] = sym_idx[l] - code[l];         }          \/* Build mapping from index to symbol and populate the lookup table. *\/         for (i = 0; i &lt; n; i++) {                 l = lengths[i];                 if (l == 0) {                         continue;                 }                  d-&gt;syms[sym_idx[l]] = (uint16_t)i;                 sym_idx[l]++;                  if (l &lt;= HUFFMAN_LOOKUP_TABLE_BITS) {                         table_insert(d, i, l, code[l]);                         code[l]++;                 }         }          return true; }  static void table_insert(huffman_decoder_t *d, size_t sym, int len,                          uint16_t codeword) {         int pad_len;         uint16_t padding, index;          assert(len &lt;= HUFFMAN_LOOKUP_TABLE_BITS);          codeword = reverse16(codeword, len); \/* Make it LSB-first. *\/         pad_len = HUFFMAN_LOOKUP_TABLE_BITS - len;          \/* Pad the pad_len upper bits with all bit combinations. *\/         for (padding = 0; padding &lt; (1U &lt;&lt; pad_len); padding++) {                 index = (uint16_t)(codeword | (padding &lt;&lt; len));                 d-&gt;table[index].sym = (uint16_t)sym;                 d-&gt;table[index].len = (uint16_t)len;                  assert(d-&gt;table[index].sym == sym &amp;&amp; &quot;Fits in bitfield.&quot;);                 assert(d-&gt;table[index].len == len &amp;&amp; &quot;Fits in bitfield.&quot;);         } } <\/code><\/pre>\n<p>  <a name=\"10\"><\/a><\/p>\n<h2>Deflate<\/h2>\n<p>  \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c Deflate, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 PKZip 2.04c \u0432 1993-\u043c, \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u0436\u0430\u0442\u0438\u044f \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 Zip-\u0444\u0430\u0439\u043b\u0430\u0445. \u041e\u043d \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 gzip, PNG \u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445. \u0412 \u043d\u0451\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0441\u0436\u0430\u0442\u0438\u044f LZ77 \u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435.<\/p>\n<p>  \u0414\u043e Deflate \u0432 PKZip \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0436\u0430\u0442\u0438\u044f Shrink, Reduce \u0438 Implode. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043e\u043d\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e, \u0445\u043e\u0442\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f Deflate \u0435\u0449\u0451 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0431\u044b\u043b\u0438 \u0432 \u0445\u043e\u0434\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u043e \u043c\u044b \u0438\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<p>  <a name=\"11\"><\/a><\/p>\n<h3>\u0411\u0438\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438<\/h3>\n<p>  Deflate \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0432 \u0431\u0438\u0442\u043e\u0432\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 LSB-first. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0438\u0442 \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u043c\u043b\u0430\u0434\u0448\u0435\u043c \u0437\u043d\u0430\u0447\u0430\u0449\u0435\u043c \u0431\u0438\u0442\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a (\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e) 1-0-0-1-1. \u041a\u043e\u0433\u0434\u0430 \u043e\u043d \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 LSB-first, \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0430\u0439\u0442\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f 0b00011001 (\u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435) \u0438\u043b\u0438 0x19 (\u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u0435). \u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0442\u043e\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0437\u0430\u0434\u043e\u043c \u043d\u0430\u043f\u0435\u0440\u0451\u0434 (\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0442\u0430\u043a \u0438 \u0435\u0441\u0442\u044c), \u043d\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a \u043d\u0430\u043c \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 N \u0431\u0438\u0442\u043e\u0432 \u0438\u0437 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430: \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c N \u043c\u043b\u0430\u0434\u0448\u0438\u0445 \u0431\u0438\u0442\u043e\u0432.<\/p>\n<p>  \u042d\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/bitstream.h\">bitstream.h<\/a>:<\/p>\n<pre><code class=\"cpp\">\/* Input bitstream. *\/ typedef struct istream_t istream_t; struct istream_t {         const uint8_t *src;  \/* Source bytes. *\/         const uint8_t *end;  \/* Past-the-end byte of src. *\/         size_t bitpos;       \/* Position of the next bit to read. *\/         size_t bitpos_end;   \/* Position of past-the-end bit. *\/ };  \/* Initialize an input stream to present the n bytes from src as an LSB-first  * bitstream. *\/ static inline void istream_init(istream_t *is, const uint8_t *src, size_t n) {         is-&gt;src = src;         is-&gt;end = src + n;         is-&gt;bitpos = 0;         is-&gt;bitpos_end = n * 8; } <\/code><\/pre>\n<p>  \u041d\u0430\u0448\u0435\u043c\u0443 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0443 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u0438\u0442\u044b \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 (\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0438\u0442\u043e\u0432 \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430), \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">#define ISTREAM_MIN_BITS (64 - 7)  \/* Get the next bits from the input stream. The number of bits returned is  * between ISTREAM_MIN_BITS and 64, depending on the position in the stream, or  * fewer if the end of stream is reached. The upper bits are zero-padded. *\/ static inline uint64_t istream_bits(const istream_t *is) {         const uint8_t *next;         uint64_t bits;         int i;          next = is-&gt;src + (is-&gt;bitpos \/ 8);          assert(next &lt;= is-&gt;end &amp;&amp; &quot;Cannot read past end of stream.&quot;);          if (is-&gt;end - next &gt;= 8) {                 \/* Common case: read 8 bytes in one go. *\/                 bits = read64le(next);         } else {                 \/* Read the available bytes and zero-pad. *\/                 bits = 0;                 for (i = 0; i &lt; is-&gt;end - next; i++) {                         bits |= (uint64_t)next[i] &lt;&lt; (i * 8);                 }         }          return bits &gt;&gt; (is-&gt;bitpos % 8); }  \/* Advance n bits in the bitstream if possible. Returns false if that many bits  * are not available in the stream. *\/ static inline bool istream_advance(istream_t *is, size_t n) {         if (is-&gt;bitpos + n &gt; is-&gt;bitpos_end) {                 return false;         }          is-&gt;bitpos += n;         return true; } <\/code><\/pre>\n<p>  \u0421\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430 64-\u0431\u0438\u0442\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 <code>istream_bits<\/code> \u043e\u0431\u044b\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>istream_t<\/code> \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445. read64le \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/bits.h\">bits.h<\/a> (\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u0443\u044e 64-\u0431\u0438\u0442\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 little-endian):<\/p>\n<pre><code class=\"cpp\">\/* Read a 64-bit value from p in little-endian byte order. *\/ static inline uint64_t read64le(const uint8_t *p) {         \/* The one true way, see          * https:\/\/commandcenter.blogspot.com\/2012\/04\/byte-order-fallacy.html *\/         return ((uint64_t)p[0] &lt;&lt; 0)  |                ((uint64_t)p[1] &lt;&lt; 8)  |                ((uint64_t)p[2] &lt;&lt; 16) |                ((uint64_t)p[3] &lt;&lt; 24) |                ((uint64_t)p[4] &lt;&lt; 32) |                ((uint64_t)p[5] &lt;&lt; 40) |                ((uint64_t)p[6] &lt;&lt; 48) |                ((uint64_t)p[7] &lt;&lt; 56); } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u043a \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0431\u0430\u0439\u0442\u0430:<\/p>\n<pre><code class=\"cpp\">\/* Round x up to the next multiple of m, which must be a power of 2. *\/ static inline size_t round_up(size_t x, size_t m) {         assert((m &amp; (m - 1)) == 0 &amp;&amp; &quot;m must be a power of two&quot;);         return (x + m - 1) &amp; (size_t)(-m); \/* Hacker's Delight (2nd), 3-1. *\/ }  \/* Align the input stream to the next 8-bit boundary and return a pointer to  * that byte, which may be the past-the-end-of-stream byte. *\/ static inline const uint8_t *istream_byte_align(istream_t *is) {         const uint8_t *byte;          assert(is-&gt;bitpos &lt;= is-&gt;bitpos_end &amp;&amp; &quot;Not past end of stream.&quot;);          is-&gt;bitpos = round_up(is-&gt;bitpos, 8);         byte = is-&gt;src + is-&gt;bitpos \/ 8;         assert(byte &lt;= is-&gt;end);          return byte; } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0431\u0438\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0447\u0442\u0435\u043d\u0438\u0435-\u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f-\u0437\u0430\u043f\u0438\u0441\u044c. \u0412 \u0431\u044b\u0441\u0442\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e 64-\u0431\u0438\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f, \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 64-\u0431\u0438\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<pre><code class=\"cpp\">\/* Output bitstream. *\/ typedef struct ostream_t ostream_t; struct ostream_t {         uint8_t *dst;         uint8_t *end;         size_t bitpos;         size_t bitpos_end; };  \/* Initialize an output stream to write LSB-first bits into dst[0..n-1]. *\/ static inline void ostream_init(ostream_t *os, uint8_t *dst, size_t n) {         os-&gt;dst = dst;         os-&gt;end = dst + n;         os-&gt;bitpos = 0;         os-&gt;bitpos_end = n * 8; }  \/* Get the current bit position in the stream. *\/ static inline size_t ostream_bit_pos(const ostream_t *os) {         return os-&gt;bitpos; }  \/* Return the number of bytes written to the output buffer. *\/ static inline size_t ostream_bytes_written(ostream_t *os) {         return round_up(os-&gt;bitpos, 8) \/ 8; }  \/* Write n bits to the output stream. Returns false if there is not enough room  * at the destination. *\/ static inline bool ostream_write(ostream_t *os, uint64_t bits, size_t n) {         uint8_t *p;         uint64_t x;         int shift, i;          assert(n &lt;= 57);         assert(bits &lt;= ((uint64_t)1 &lt;&lt; n) - 1 &amp;&amp; &quot;Must fit in n bits.&quot;);          if (os-&gt;bitpos_end - os-&gt;bitpos &lt; n) {                 \/* Not enough room. *\/                 return false;         }          p = &amp;os-&gt;dst[os-&gt;bitpos \/ 8];         shift = os-&gt;bitpos % 8;          if (os-&gt;end - p &gt;= 8) {                 \/* Common case: read and write 8 bytes in one go. *\/                 x = read64le(p);                 x = lsb(x, shift);                 x |= bits &lt;&lt; shift;                 write64le(p, x);         } else {                 \/* Slow case: read\/write as many bytes as are available. *\/                 x = 0;                 for (i = 0; i &lt; os-&gt;end - p; i++) {                         x |= (uint64_t)p[i] &lt;&lt; (i * 8);                 }                 x = lsb(x, shift);                 x |= bits &lt;&lt; shift;                 for (i = 0; i &lt; os-&gt;end - p; i++) {                         p[i] = (uint8_t)(x &gt;&gt; (i * 8));                 }         }          os-&gt;bitpos += n;          return true; }  \/* Write a 64-bit value x to dst in little-endian byte order. *\/ static inline void write64le(uint8_t *dst, uint64_t x) {         dst[0] = (uint8_t)(x &gt;&gt; 0);         dst[1] = (uint8_t)(x &gt;&gt; 8);         dst[2] = (uint8_t)(x &gt;&gt; 16);         dst[3] = (uint8_t)(x &gt;&gt; 24);         dst[4] = (uint8_t)(x &gt;&gt; 32);         dst[5] = (uint8_t)(x &gt;&gt; 40);         dst[6] = (uint8_t)(x &gt;&gt; 48);         dst[7] = (uint8_t)(x &gt;&gt; 56); } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u043f\u043e\u0442\u043e\u043a \u0431\u0430\u0439\u0442\u044b. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c 8-\u0431\u0438\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438, \u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>memcpy<\/code>:<\/p>\n<pre><code class=\"cpp\">\/* Align the bitstream to the next byte boundary, then write the n bytes from    src to it. Returns false if there is not enough room in the stream. *\/ static inline bool ostream_write_bytes_aligned(ostream_t *os,                                                const uint8_t *src,                                                size_t n) {         if (os-&gt;bitpos_end - round_up(os-&gt;bitpos, 8) &lt; n * 8) {                 return false;         }          os-&gt;bitpos = round_up(os-&gt;bitpos, 8);         memcpy(&amp;os-&gt;dst[os-&gt;bitpos \/ 8], src, n);         os-&gt;bitpos += n * 8;          return true; } <\/code><\/pre>\n<p>  <a name=\"12\"><\/a><\/p>\n<h3>\u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 (Inflation)<\/h3>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0436\u0430\u0442\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>Deflate<\/i> \u2014 \u0441\u0434\u0443\u0432\u0430\u043d\u0438\u0435, \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0434\u0443\u0445\u0430 \u0438\u0437 \u0447\u0435\u0433\u043e-\u043b\u0438\u0431\u043e, \u2014 \u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <i>Inflation<\/i> (\u043d\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435). \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0442\u043e \u043c\u044b \u043f\u043e\u0439\u043c\u0451\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442. \u041a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/deflate.h\">deflate.h<\/a> \u0438 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/deflate.c\">deflate.c<\/a>, <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/bits.h\">bits.h<\/a>, <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/tables.h\">tables.h<\/a> \u0438 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/tables.c\">tables.c<\/a> (\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/generate_tables.c\">generate_tables.c<\/a>).<\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0435, \u0441\u0436\u0430\u0442\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Deflate, \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0435\u0440\u0438\u0438 <i>\u0431\u043b\u043e\u043a\u043e\u0432<\/i>. \u041a\u0430\u0436\u0434\u044b\u0439 \u0431\u043b\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 3-\u0431\u0438\u0442\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0435\u0440\u0432\u044b\u0439 (\u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0439) \u0431\u0438\u0442 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u0441\u0435\u0440\u0438\u0438, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0432\u0430 \u0431\u0438\u0442\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0435\u0433\u043e \u0442\u0438\u043f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/875\/b36\/1fd\/875b361fd3414431d2a20d1ab0b6ef8b.png\"><\/div>\n<p>  \u0415\u0441\u0442\u044c \u0442\u0440\u0438 \u0442\u0438\u043f\u0430 \u0431\u043b\u043e\u043a\u043e\u0432: \u043d\u0435\u0441\u0436\u0430\u0442\u044b\u0439 (0), \u0441\u0436\u0430\u0442\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 (1) \u0438 \u0441\u0436\u0430\u0442\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u00ab\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445\u00bb \u043a\u043e\u0434\u043e\u0432 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 (2).<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0431\u043b\u043e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u0437\u0434\u043d\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">typedef enum {         HWINF_OK,   \/* Inflation was successful. *\/         HWINF_FULL, \/* Not enough room in the output buffer. *\/         HWINF_ERR   \/* Error in the input data. *\/ } inf_stat_t;  \/* Decompress (inflate) the Deflate stream in src. The number of input bytes    used, at most src_len, is stored in *src_used on success. Output is written    to dst. The number of bytes written, at most dst_cap, is stored in *dst_used    on success. src[0..src_len-1] and dst[0..dst_cap-1] must not overlap.    Returns a status value as defined above. *\/ inf_stat_t hwinflate(const uint8_t *src, size_t src_len, size_t *src_used,                      uint8_t *dst, size_t dst_cap, size_t *dst_used) {         istream_t is;         size_t dst_pos;         uint64_t bits;         bool bfinal;         inf_stat_t s;          istream_init(&amp;is, src, src_len);         dst_pos = 0;          do {                 \/* Read the 3-bit block header. *\/                 bits = istream_bits(&amp;is);                 if (!istream_advance(&amp;is, 3)) {                         return HWINF_ERR;                 }                 bfinal = bits &amp; 1;                 bits &gt;&gt;= 1;                  switch (lsb(bits, 2)) {                 case 0: \/* 00: No compression. *\/                         s = inf_noncomp_block(&amp;is, dst, dst_cap, &amp;dst_pos);                         break;                 case 1: \/* 01: Compressed with fixed Huffman codes. *\/                         s = inf_fixed_block(&amp;is, dst, dst_cap, &amp;dst_pos);                         break;                 case 2: \/* 10: Compressed with &quot;dynamic&quot; Huffman codes. *\/                         s = inf_dyn_block(&amp;is, dst, dst_cap, &amp;dst_pos);                         break;                 default: \/* Invalid block type. *\/                         return HWINF_ERR;                 }                  if (s != HWINF_OK) {                         return s;                 }         } while (!bfinal);          *src_used = (size_t)(istream_byte_align(&amp;is) - src);          assert(dst_pos &lt;= dst_cap);         *dst_used = dst_pos;          return HWINF_OK; } <\/code><\/pre>\n<p>  <a name=\"13\"><\/a><\/p>\n<h4>\u041d\u0435\u0441\u0436\u0430\u0442\u044b\u0435 Deflate-\u0431\u043b\u043e\u043a\u0438<\/h4>\n<p>  \u042d\u0442\u043e \u00ab\u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0435\u00bb \u0431\u043b\u043e\u043a\u0438, \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0442\u0438\u043f. \u041e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 8-\u0431\u0438\u0442\u043d\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0441 16 \u0431\u0438\u0442\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 (len), \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0434\u043b\u0438\u043d\u0443 \u0431\u043b\u043e\u043a\u0430. \u0417\u0430 \u043d\u0438\u043c \u0438\u0434\u0451\u0442 \u0434\u0440\u0443\u0433\u043e\u0435 16-\u0431\u0438\u0442\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e (nlen), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442 (\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0438\u0442\u043e\u0432 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d) \u0441\u043b\u043e\u0432 len. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e nlen \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430 len: \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0451\u043d, \u0442\u043e, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u043c\u0438 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0e1\/eb8\/15b\/0e1eb815b2dfec1edb50eeafd1291cc5.png\"><\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 len \u0438 nlen \u0438\u0434\u0443\u0442 \u043d\u0435\u0441\u0436\u0430\u0442\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u0438\u043d\u0430 \u0431\u043b\u043e\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 16-\u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d 65 535 \u0431\u0430\u0439\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"cpp\">static inf_stat_t inf_noncomp_block(istream_t *is, uint8_t *dst,                                     size_t dst_cap, size_t *dst_pos) {         const uint8_t *p;         uint16_t len, nlen;          p = istream_byte_align(is);          \/* Read len and nlen (2 x 16 bits). *\/         if (!istream_advance(is, 32)) {                 return HWINF_ERR; \/* Not enough input. *\/         }         len  = read16le(p);         nlen = read16le(p + 2);         p += 4;          if (nlen != (uint16_t)~len) {                 return HWINF_ERR;         }          if (!istream_advance(is, len * 8)) {                 return HWINF_ERR; \/* Not enough input. *\/         }          if (dst_cap - *dst_pos &lt; len) {                 return HWINF_FULL; \/* Not enough room to output. *\/         }          memcpy(&amp;dst[*dst_pos], p, len);         *dst_pos += len;          return HWINF_OK; } <\/code><\/pre>\n<p>  <a name=\"14\"><\/a><\/p>\n<h4>Deflate-\u0431\u043b\u043e\u043a\u0438 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/h4>\n<p>  \u0421\u0436\u0430\u0442\u044b\u0435 Deflate-\u0431\u043b\u043e\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043a\u043e\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 LZ77-\u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432. \u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u0440\u043a\u0435\u0440\u043e\u0432 \u043a\u043e\u043d\u0446\u0430 \u0431\u043b\u043e\u043a\u0430. \u0414\u043b\u044f \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432, \u0434\u043b\u0438\u043d \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0438 \u043c\u0430\u0440\u043a\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 <i>litlen<\/i>. \u0410 \u0434\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u0434 <i>dist<\/i>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c35\/0e1\/a8c\/c350e1a8c73f69203949ccc534141497.png\"><\/div>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e litlen \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 0-285. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f 0-255 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0431\u0430\u0439\u0442\u043e\u0432 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432, 256 \u2014 \u043c\u0430\u0440\u043a\u0435\u0440 \u043a\u043e\u043d\u0446\u0430 \u0431\u043b\u043e\u043a\u0430, \u0430 257-285 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0434\u043b\u0438\u043d \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a.<\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u043b\u0438\u043d\u043e\u0439 3-258 \u0431\u0430\u0439\u0442\u043e\u0432. Litlen-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0434\u043b\u0438\u043d\u0443, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u043b\u044c \u0438\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 <i>\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432<\/i>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043f\u043e\u043b\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, litlen-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 269 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0434\u043b\u0438\u043d\u0443 19 \u0438 \u0434\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442\u0430. \u041f\u0440\u0438\u0431\u0430\u0432\u043a\u0430 \u0434\u0432\u0443\u0445 \u0431\u0438\u0442\u043e\u0432 \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u0451\u0442 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u043e\u0442 19 \u0434\u043e 22.<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td width=\"200\"><strong>Litlen<\/strong><\/td>\n<td width=\"200\"><strong>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0442\u044b<\/strong><\/td>\n<td width=\"200\"><strong>\u0414\u043b\u0438\u043d\u044b<\/strong><\/td>\n<\/tr>\n<tr>\n<td>257<\/td>\n<td>0<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td>258<\/td>\n<td>0<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>259<\/td>\n<td>0<\/td>\n<td>5<\/td>\n<\/tr>\n<tr>\n<td>260<\/td>\n<td>0<\/td>\n<td>6<\/td>\n<\/tr>\n<tr>\n<td>261<\/td>\n<td>0<\/td>\n<td>7<\/td>\n<\/tr>\n<tr>\n<td>262<\/td>\n<td>0<\/td>\n<td>8<\/td>\n<\/tr>\n<tr>\n<td>263<\/td>\n<td>0<\/td>\n<td>9<\/td>\n<\/tr>\n<tr>\n<td>264<\/td>\n<td>0<\/td>\n<td>10<\/td>\n<\/tr>\n<tr>\n<td>265<\/td>\n<td>1<\/td>\n<td>11\u201312<\/td>\n<\/tr>\n<tr>\n<td>266<\/td>\n<td>1<\/td>\n<td>13\u201314<\/td>\n<\/tr>\n<tr>\n<td>267<\/td>\n<td>1<\/td>\n<td>15\u201316<\/td>\n<\/tr>\n<tr>\n<td>268<\/td>\n<td>1<\/td>\n<td>17\u201318<\/td>\n<\/tr>\n<tr>\n<td>269<\/td>\n<td>2<\/td>\n<td>19\u201322<\/td>\n<\/tr>\n<tr>\n<td>270<\/td>\n<td>2<\/td>\n<td>23\u201326<\/td>\n<\/tr>\n<tr>\n<td>271<\/td>\n<td>2<\/td>\n<td>27\u201330<\/td>\n<\/tr>\n<tr>\n<td>272<\/td>\n<td>2<\/td>\n<td>31\u201334<\/td>\n<\/tr>\n<tr>\n<td>273<\/td>\n<td>3<\/td>\n<td>35\u201342<\/td>\n<\/tr>\n<tr>\n<td>274<\/td>\n<td>3<\/td>\n<td>43\u201350<\/td>\n<\/tr>\n<tr>\n<td>275<\/td>\n<td>3<\/td>\n<td>51\u201358<\/td>\n<\/tr>\n<tr>\n<td>276<\/td>\n<td>3<\/td>\n<td>59\u201366<\/td>\n<\/tr>\n<tr>\n<td>277<\/td>\n<td>4<\/td>\n<td>67\u201382<\/td>\n<\/tr>\n<tr>\n<td>278<\/td>\n<td>4<\/td>\n<td>83\u201398<\/td>\n<\/tr>\n<tr>\n<td>279<\/td>\n<td>4<\/td>\n<td>99\u2013114<\/td>\n<\/tr>\n<tr>\n<td>280<\/td>\n<td>4<\/td>\n<td>115\u2013130<\/td>\n<\/tr>\n<tr>\n<td>281<\/td>\n<td>5<\/td>\n<td>131\u2013162<\/td>\n<\/tr>\n<tr>\n<td>282<\/td>\n<td>5<\/td>\n<td>163\u2013194<\/td>\n<\/tr>\n<tr>\n<td>283<\/td>\n<td>5<\/td>\n<td>195\u2013226<\/td>\n<\/tr>\n<tr>\n<td>284<\/td>\n<td>5<\/td>\n<td>227\u2013257<\/td>\n<\/tr>\n<tr>\n<td>285<\/td>\n<td>0<\/td>\n<td>258<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e litlen-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 284 \u043f\u043b\u044e\u0441 5 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u043b\u0438\u043d\u044b \u043e\u0442 227 \u0434\u043e 258, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u0434\u043b\u0438\u043d\u0430 258 \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 \u2014 \u0434\u043e\u043b\u0436\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e litlen-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430.<\/p>\n<p>  \u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u043e\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0437 litlen-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (\u043c\u0438\u043d\u0443\u0441 257) \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">\/* Table of litlen symbol values minus 257 with corresponding base length    and number of extra bits. *\/ struct litlen_tbl_t {         uint16_t base_len : 9;         uint16_t ebits : 7; }; const struct litlen_tbl_t litlen_tbl[29] = { \/* 257 *\/ { 3, 0 }, \/* 258 *\/ { 4, 0 },  ...  \/* 284 *\/ { 227, 5 }, \/* 285 *\/ { 258, 0 } }; <\/code><\/pre>\n<p>  \u0424\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 litlen-\u043a\u043e\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 (286\u2013287 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438 litlen-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043d\u043e \u043e\u043d\u0438 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u043e\u0432):<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><strong>Litlen-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong><\/td>\n<td><strong>\u0414\u043b\u0438\u043d\u0430 \u043a\u043e\u0434\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430<\/strong><\/td>\n<\/tr>\n<tr>\n<td>0\u2013143<\/td>\n<td>8<\/td>\n<\/tr>\n<tr>\n<td>144\u2013255<\/td>\n<td>9<\/td>\n<\/tr>\n<tr>\n<td>256\u2013279<\/td>\n<td>7<\/td>\n<\/tr>\n<tr>\n<td>280\u2013287<\/td>\n<td>8<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u043e\u0440 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u044d\u0442\u0438 \u0434\u043b\u0438\u043d\u044b \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 <code>huffman_decoder_init<\/code>:<\/p>\n<pre><code class=\"cpp\">const uint8_t fixed_litlen_lengths[288] = { \/*   0 *\/ 8, \/*   1 *\/ 8,  ...  \/* 287 *\/ 8, }; <\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u0442 1 \u0434\u043e 32 768. \u041e\u043d\u0438 \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0445\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430 \u0441\u0445\u0435\u043c\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u0438\u043d. \u041a\u043e\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 dist \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 0 \u0434\u043e 29, \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u043b\u0438\u043d\u0435, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td width=\"200\"><strong>Dist<\/strong><\/td>\n<td width=\"200\"><strong>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0442\u044b<\/strong><\/td>\n<td width=\"200\"><strong>\u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/strong><\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>0<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>0<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>0<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>1<\/td>\n<td>5\u20136<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>1<\/td>\n<td>7\u20138<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>2<\/td>\n<td>9\u201312<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>2<\/td>\n<td>13\u201316<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>3<\/td>\n<td>17\u201324<\/td>\n<\/tr>\n<tr>\n<td>9<\/td>\n<td>3<\/td>\n<td>25\u201332<\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td>4<\/td>\n<td>33\u201348<\/td>\n<\/tr>\n<tr>\n<td>11<\/td>\n<td>4<\/td>\n<td>49\u201364<\/td>\n<\/tr>\n<tr>\n<td>12<\/td>\n<td>5<\/td>\n<td>65\u201396<\/td>\n<\/tr>\n<tr>\n<td>13<\/td>\n<td>5<\/td>\n<td>97\u2013128<\/td>\n<\/tr>\n<tr>\n<td>14<\/td>\n<td>6<\/td>\n<td>129\u2013192<\/td>\n<\/tr>\n<tr>\n<td>15<\/td>\n<td>6<\/td>\n<td>193\u2013256<\/td>\n<\/tr>\n<tr>\n<td>16<\/td>\n<td>7<\/td>\n<td>257\u2013384<\/td>\n<\/tr>\n<tr>\n<td>17<\/td>\n<td>7<\/td>\n<td>385\u2013512<\/td>\n<\/tr>\n<tr>\n<td>18<\/td>\n<td>8<\/td>\n<td>513\u2013768<\/td>\n<\/tr>\n<tr>\n<td>19<\/td>\n<td>8<\/td>\n<td>769\u20131024<\/td>\n<\/tr>\n<tr>\n<td>20<\/td>\n<td>9<\/td>\n<td>1025\u20131536<\/td>\n<\/tr>\n<tr>\n<td>21<\/td>\n<td>9<\/td>\n<td>1537\u20132048<\/td>\n<\/tr>\n<tr>\n<td>22<\/td>\n<td>10<\/td>\n<td>2049\u20133072<\/td>\n<\/tr>\n<tr>\n<td>23<\/td>\n<td>10<\/td>\n<td>3073\u20134096<\/td>\n<\/tr>\n<tr>\n<td>24<\/td>\n<td>11<\/td>\n<td>4097\u20136144<\/td>\n<\/tr>\n<tr>\n<td>25<\/td>\n<td>11<\/td>\n<td>6145\u20138192<\/td>\n<\/tr>\n<tr>\n<td>26<\/td>\n<td>12<\/td>\n<td>8193\u201312288<\/td>\n<\/tr>\n<tr>\n<td>27<\/td>\n<td>12<\/td>\n<td>12289\u201316384<\/td>\n<\/tr>\n<tr>\n<td>28<\/td>\n<td>13<\/td>\n<td>16385\u201324576<\/td>\n<\/tr>\n<tr>\n<td>29<\/td>\n<td>13<\/td>\n<td>24577\u201332768<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u0424\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 dist \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u043c. \u0412\u0441\u0435 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0434\u043b\u0438\u043d\u043e\u0439 5 \u0431\u0438\u0442\u043e\u0432. \u041e\u043d \u043f\u0440\u043e\u0441\u0442, \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u043e\u0440 \u0445\u0440\u0430\u043d\u0438\u0442 \u043a\u043e\u0434\u044b \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 <code>huffman_decoder_init<\/code> (dist-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 30\u201331 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438. \u0423\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u043e\u0432 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430):<\/p>\n<pre><code class=\"cpp\">const uint8_t fixed_dist_lengths[32] = { \/*  0 *\/ 5, \/*  1 *\/ 5,  ...  \/* 31 *\/ 5, }; <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438, \u0438\u043b\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u2014 Deflate-\u0431\u043b\u043e\u043a \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430:<\/p>\n<pre><code class=\"cpp\">static inf_stat_t inf_fixed_block(istream_t *is, uint8_t *dst,                                   size_t dst_cap, size_t *dst_pos) {         huffman_decoder_t litlen_dec, dist_dec;          huffman_decoder_init(&amp;litlen_dec, fixed_litlen_lengths,                              sizeof(fixed_litlen_lengths) \/                              sizeof(fixed_litlen_lengths[0]));         huffman_decoder_init(&amp;dist_dec, fixed_dist_lengths,                              sizeof(fixed_dist_lengths) \/                              sizeof(fixed_dist_lengths[0]));          return inf_block(is, dst, dst_cap, dst_pos, &amp;litlen_dec, &amp;dist_dec); }  #define LITLEN_EOB 256 #define LITLEN_MAX 285 #define LITLEN_TBL_OFFSET 257 #define MIN_LEN 3 #define MAX_LEN 258  #define DISTSYM_MAX 29 #define MIN_DISTANCE 1 #define MAX_DISTANCE 32768  static inf_stat_t inf_block(istream_t *is, uint8_t *dst, size_t dst_cap,                             size_t *dst_pos,                             const huffman_decoder_t *litlen_dec,                             const huffman_decoder_t *dist_dec) {         uint64_t bits;         size_t used, used_tot, dist, len;         int litlen, distsym;         uint16_t ebits;          while (true) {                 \/* Read a litlen symbol. *\/                 bits = istream_bits(is);                 litlen = huffman_decode(litlen_dec, (uint16_t)bits, &amp;used);                 bits &gt;&gt;= used;                 used_tot = used;                  if (litlen &lt; 0 || litlen &gt; LITLEN_MAX) {                         \/* Failed to decode, or invalid symbol. *\/                         return HWINF_ERR;                 } else if (litlen &lt;= UINT8_MAX) {                         \/* Literal. *\/                         if (!istream_advance(is, used_tot)) {                                 return HWINF_ERR;                         }                         if (*dst_pos == dst_cap) {                                 return HWINF_FULL;                         }                         lz77_output_lit(dst, (*dst_pos)++, (uint8_t)litlen);                         continue;                 } else if (litlen == LITLEN_EOB) {                         \/* End of block. *\/                         if (!istream_advance(is, used_tot)) {                                 return HWINF_ERR;                         }                         return HWINF_OK;                 }                  \/* It is a back reference. Figure out the length. *\/                 assert(litlen &gt;= LITLEN_TBL_OFFSET &amp;&amp; litlen &lt;= LITLEN_MAX);                 len   = litlen_tbl[litlen - LITLEN_TBL_OFFSET].base_len;                 ebits = litlen_tbl[litlen - LITLEN_TBL_OFFSET].ebits;                 if (ebits != 0) {                         len += lsb(bits, ebits);                         bits &gt;&gt;= ebits;                         used_tot += ebits;                 }                 assert(len &gt;= MIN_LEN &amp;&amp; len &lt;= MAX_LEN);                  \/* Get the distance. *\/                 distsym = huffman_decode(dist_dec, (uint16_t)bits, &amp;used);                 bits &gt;&gt;= used;                 used_tot += used;                  if (distsym &lt; 0 || distsym &gt; DISTSYM_MAX) {                         \/* Failed to decode, or invalid symbol. *\/                         return HWINF_ERR;                 }                 dist  = dist_tbl[distsym].base_dist;                 ebits = dist_tbl[distsym].ebits;                 if (ebits != 0) {                         dist += lsb(bits, ebits);                         bits &gt;&gt;= ebits;                         used_tot += ebits;                 }                 assert(dist &gt;= MIN_DISTANCE &amp;&amp; dist &lt;= MAX_DISTANCE);                  assert(used_tot &lt;= ISTREAM_MIN_BITS);                 if (!istream_advance(is, used_tot)) {                         return HWINF_ERR;                 }                  \/* Bounds check and output the backref. *\/                 if (dist &gt; *dst_pos) {                         return HWINF_ERR;                 }                 if (round_up(len, 8) &lt;= dst_cap - *dst_pos) {                         output_backref64(dst, *dst_pos, dist, len);                 } else if (len &lt;= dst_cap - *dst_pos) {                         lz77_output_backref(dst, *dst_pos, dist, len);                 } else {                         return HWINF_FULL;                 }                 (*dst_pos) += len;         } } <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u0430\u043a\u0443\u044e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e: \u043a\u043e\u0433\u0434\u0430 \u0432 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c \u0431\u0443\u0444\u0435\u0440\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0435\u0441\u0442\u0430, \u043c\u044b \u0432\u044b\u0434\u0430\u0451\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u043e 64 \u0431\u0438\u0442\u0430 \u0437\u0430 \u0440\u0430\u0437. \u042d\u0442\u043e \u00ab\u043d\u0435\u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u00bb \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0447\u0430\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432 (\u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e 8). \u041d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 <code>lz77_output_backref<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u043e \u0441\u0443\u0442\u0438, \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430 \u043e\u0434\u043d\u0443 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cpp\">\/* Output the (dist,len) backref at dst_pos in dst using 64-bit wide writes.    There must be enough room for len bytes rounded to the next multiple of 8. *\/ static void output_backref64(uint8_t *dst, size_t dst_pos, size_t dist,                              size_t len) {         size_t i;         uint64_t tmp;          assert(len &gt; 0);         assert(dist &lt;= dst_pos &amp;&amp; &quot;cannot reference before beginning of dst&quot;);          if (len &gt; dist) {                 \/* Self-overlapping backref; fall back to byte-by-byte copy. *\/                 lz77_output_backref(dst, dst_pos, dist, len);                 return;         }          i = 0;         do {                 memcpy(&amp;tmp, &amp;dst[dst_pos - dist + i], 8);                 memcpy(&amp;dst[dst_pos + i], &amp;tmp, 8);                 i += 8;         } while (i &lt; len); } <\/code><\/pre>\n<p>  <a name=\"15\"><\/a><\/p>\n<h4>Deflate-\u0431\u043b\u043e\u043a\u0438 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u0434\u043e\u0432 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/h4>\n<p>  Deflate-\u0431\u043b\u043e\u043a\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u0434\u044b \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435. \u041d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u0434\u043b\u044f litlen \u0438 dist \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043a\u043e\u0434\u044b, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u0441\u0430\u043c\u043e\u043c Deflate-\u043f\u043e\u0442\u043e\u043a\u0435, \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0431\u043b\u043e\u043a\u0430. \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043a\u043e\u0434\u0430\u043c\u0438 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043a\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0445\u043e\u0434\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u044d\u0442\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%B4%D0%B0%D0%BF%D1%82%D0%B8%D0%B2%D0%BD%D1%8B%D0%B9_%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%A5%D0%B0%D1%84%D1%84%D0%BC%D0%B0%D0%BD%D0%B0\">\u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/a>. \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0437\u0434\u0435\u0441\u044c \u043a\u043e\u0434\u044b \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043a \u0442\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u041e\u043d\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043b\u0438\u0448\u044c \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u0434\u044b.<\/p>\n<p>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 litlen- \u0438 dist-\u043a\u043e\u0434\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e Deflate-\u0444\u043e\u0440\u043c\u0430\u0442\u0430. \u041d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>inf_block<\/code>:<\/p>\n<pre><code class=\"cpp\">static inf_stat_t inf_dyn_block(istream_t *is, uint8_t *dst,                                 size_t dst_cap, size_t *dst_pos) {         inf_stat_t s;         huffman_decoder_t litlen_dec, dist_dec;          s = init_dyn_decoders(is, &amp;litlen_dec, &amp;dist_dec);         if (s != HWINF_OK) {                 return s;         }          return inf_block(is, dst, dst_cap, dst_pos, &amp;litlen_dec, &amp;dist_dec); } <\/code><\/pre>\n<p>  Litlen- \u0438 dist-\u043a\u043e\u0434\u044b \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 Deflate-\u0431\u043b\u043e\u043a\u043e\u0432 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0435\u0440\u0438\u0439 \u0434\u043b\u0438\u043d \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432. \u0421\u0430\u043c\u0438 \u0434\u043b\u0438\u043d\u044b \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u2014 <i>codelen<\/i>. \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u0438\u043d\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 (<code>codelen_lens<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0431\u043b\u043e\u043a\u0435 (\u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e?).<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/84e\/1fc\/0e3\/84e1fc0e3d3cfcb56ff215702d14f73d.png\"><\/div>\n<p>  \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f 14 \u0431\u0438\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e litlen-, dist- \u0438 codelen-\u0434\u043b\u0438\u043d \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0431\u043b\u043e\u043a\u0430:<\/p>\n<pre><code class=\"cpp\">#define MIN_CODELEN_LENS 4 #define MAX_CODELEN_LENS 19  #define MIN_LITLEN_LENS 257 #define MAX_LITLEN_LENS 288  #define MIN_DIST_LENS 1 #define MAX_DIST_LENS 32  #define CODELEN_MAX_LIT 15  #define CODELEN_COPY 16 #define CODELEN_COPY_MIN 3 #define CODELEN_COPY_MAX 6  #define CODELEN_ZEROS 17 #define CODELEN_ZEROS_MIN 3 #define CODELEN_ZEROS_MAX 10  #define CODELEN_ZEROS2 18 #define CODELEN_ZEROS2_MIN 11 #define CODELEN_ZEROS2_MAX 138  \/* RFC 1951, 3.2.7 *\/ static const int codelen_lengths_order[MAX_CODELEN_LENS] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };  static inf_stat_t init_dyn_decoders(istream_t *is,                                     huffman_decoder_t *litlen_dec,                                     huffman_decoder_t *dist_dec) {         uint64_t bits;         size_t num_litlen_lens, num_dist_lens, num_codelen_lens;         uint8_t codelen_lengths[MAX_CODELEN_LENS];         uint8_t code_lengths[MAX_LITLEN_LENS + MAX_DIST_LENS];         size_t i, n, used;         int sym;         huffman_decoder_t codelen_dec;          bits = istream_bits(is);          \/* Number of litlen codeword lengths (5 bits + 257). *\/         num_litlen_lens = lsb(bits, 5) + MIN_LITLEN_LENS;         bits &gt;&gt;= 5;         assert(num_litlen_lens &lt;= MAX_LITLEN_LENS);          \/* Number of dist codeword lengths (5 bits + 1). *\/         num_dist_lens = lsb(bits, 5) + MIN_DIST_LENS;         bits &gt;&gt;= 5;         assert(num_dist_lens &lt;= MAX_DIST_LENS);          \/* Number of code length lengths (4 bits + 4). *\/         num_codelen_lens = lsb(bits, 4) + MIN_CODELEN_LENS;         bits &gt;&gt;= 4;         assert(num_codelen_lens &lt;= MAX_CODELEN_LENS);          if (!istream_advance(is, 5 + 5 + 4)) {                 return HWINF_ERR;         } <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0438\u0434\u0443\u0442 \u0434\u043b\u0438\u043d\u044b \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u0434\u043b\u044f codelen-\u043a\u043e\u0434\u0430. \u042d\u0442\u0438 \u0434\u043b\u0438\u043d\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0440\u0451\u0445\u0431\u0438\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0441\u043e\u0431\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0434\u0430\u043d \u0432 <code>codelen_lengths_order<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c 19 \u0434\u043b\u0438\u043d, \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e <code>num_codelen_lens<\/code>; \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u044f\u0432\u043d\u043e \u043d\u0443\u043b\u0435\u0432\u044b\u043c. \u0414\u043b\u0438\u043d\u044b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0434\u043b\u0438\u043d\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u0438 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u043b\u0438\u0441\u044c \u0432 \u0431\u043b\u043e\u043a\u0435.<\/p>\n<pre><code class=\"cpp\">       \/* Read the codelen codeword lengths (3 bits each)            and initialize the codelen decoder. *\/         for (i = 0; i &lt; num_codelen_lens; i++) {                 bits = istream_bits(is);                 codelen_lengths[codelen_lengths_order[i]] =                         (uint8_t)lsb(bits, 3);                 if (!istream_advance(is, 3)) {                         return HWINF_ERR;                 }         }         for (; i &lt; MAX_CODELEN_LENS; i++) {                 codelen_lengths[codelen_lengths_order[i]] = 0;         }         if (!huffman_decoder_init(&amp;codelen_dec, codelen_lengths,                                   MAX_CODELEN_LENS)) {                 return HWINF_ERR;         } <\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 codelen-\u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u043b\u0438\u043d\u044b \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 litlen \u0438 dist.<\/p>\n<pre><code class=\"cpp\">       \/* Read the litlen and dist codeword lengths. *\/         i = 0;         while (i &lt; num_litlen_lens + num_dist_lens) {                 bits = istream_bits(is);                 sym = huffman_decode(&amp;codelen_dec, (uint16_t)bits, &amp;used);                 bits &gt;&gt;= used;                 if (!istream_advance(is, used)) {                         return HWINF_ERR;                 }                  if (sym &gt;= 0 &amp;&amp; sym &lt;= CODELEN_MAX_LIT) {                         \/* A literal codeword length. *\/                         code_lengths[i++] = (uint8_t)sym;                 } <\/code><\/pre>\n<p>  16, 17 \u0438 18 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c\u0438 \u0434\u043b\u0438\u043d\u0430\u043c\u0438, \u044d\u0442\u043e \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u0438\u043b\u0438 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043d\u0443\u043b\u0435\u0432\u0443\u044e \u0434\u043b\u0438\u043d\u0443:<\/p>\n<pre><code class=\"cpp\">               else if (sym == CODELEN_COPY) {                         \/* Copy the previous codeword length 3--6 times. *\/                         if (i &lt; 1) {                                 return HWINF_ERR; \/* No previous length. *\/                         }                         n = lsb(bits, 2) + CODELEN_COPY_MIN; \/* 2 bits + 3 *\/                         if (!istream_advance(is, 2)) {                                 return HWINF_ERR;                         }                         assert(n &gt;= CODELEN_COPY_MIN &amp;&amp; n &lt;= CODELEN_COPY_MAX);                         if (i + n &gt; num_litlen_lens + num_dist_lens) {                                 return HWINF_ERR;                         }                         while (n--) {                                 code_lengths[i] = code_lengths[i - 1];                                 i++;                         }                 } else if (sym == CODELEN_ZEROS) {                         \/* 3--10 zeros. *\/                         n = lsb(bits, 3) + CODELEN_ZEROS_MIN; \/* 3 bits + 3 *\/                         if (!istream_advance(is, 3)) {                                 return HWINF_ERR;                         }                         assert(n &gt;= CODELEN_ZEROS_MIN &amp;&amp;                                n &lt;= CODELEN_ZEROS_MAX);                         if (i + n &gt; num_litlen_lens + num_dist_lens) {                                 return HWINF_ERR;                         }                         while (n--) {                                 code_lengths[i++] = 0;                         }                 } else if (sym == CODELEN_ZEROS2) {                         \/* 11--138 zeros. *\/                         n = lsb(bits, 7) + CODELEN_ZEROS2_MIN; \/* 7 bits +138 *\/                         if (!istream_advance(is, 7)) {                                 return HWINF_ERR;                         }                         assert(n &gt;= CODELEN_ZEROS2_MIN &amp;&amp;                                n &lt;= CODELEN_ZEROS2_MAX);                         if (i + n &gt; num_litlen_lens + num_dist_lens) {                                 return HWINF_ERR;                         }                         while (n--) {                                 code_lengths[i++] = 0;                         }                 } else {                         \/* Invalid symbol. *\/                         return HWINF_ERR;                 }         } <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e litlen- \u0438 dist-\u0434\u043b\u0438\u043d\u044b \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u0430 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 <code>code_lengths<\/code>. \u041e\u043d\u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044b \u0434\u043b\u0438\u043d \u043a\u043e\u0434\u0430 \u043c\u043e\u0433\u0443\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 litlen-\u0434\u043b\u0438\u043d \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0435 dist-\u0434\u043b\u0438\u043d\u044b.<\/p>\n<p>  \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0432 \u0434\u043b\u0438\u043d\u044b \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u044b \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0437\u0430\u0434\u0430\u0447\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a:<\/p>\n<pre><code class=\"cpp\">       if (!huffman_decoder_init(litlen_dec, &amp;code_lengths[0],                                   num_litlen_lens)) {                 return HWINF_ERR;         }         if (!huffman_decoder_init(dist_dec, &amp;code_lengths[num_litlen_lens],                                   num_dist_lens)) {                 return HWINF_ERR;         }          return HWINF_OK; } <\/code><\/pre>\n<p>  <a name=\"16\"><\/a><\/p>\n<h3>\u0421\u0436\u0430\u0442\u0438\u0435 (Deflation)<\/h3>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u0441\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f Deflate-\u0441\u0436\u0430\u0442\u0438\u044f: Lempel-Ziv, \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430, \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0440\u0451\u0445 \u0442\u0438\u043f\u043e\u0432 Deflate-\u0431\u043b\u043e\u043a\u043e\u0432. \u0410 \u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c Deflate-\u0441\u0436\u0430\u0442\u0438\u0435.<\/p>\n<p>  \u0421\u0436\u0430\u0442\u0438\u0435 Lempel-Ziv \u043f\u0430\u0440\u0441\u0438\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0438 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432. \u042d\u0442\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0438 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 Deflate-\u0431\u043b\u043e\u043a\u0438, \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438. \u0412\u044b\u0431\u043e\u0440 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <i>\u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0431\u043b\u043e\u043a\u0438<\/i>. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043a\u0430\u0436\u0434\u044b\u0439 \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b, \u043e\u0431\u044a\u0451\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0438\u043f\u0430 \u0431\u043b\u043e\u043a\u0430 \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e. \u041c\u0435\u043d\u044c\u0448\u0435 \u0431\u043b\u043e\u043a\u043e\u0432 \u2014 \u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u044d\u0442\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043c\u043e\u0433\u0443\u0442 \u043e\u043a\u0443\u043f\u0430\u0442\u044c\u0441\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043e\u0431\u044a\u0451\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>  \u0420\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043d\u0430 \u0431\u043b\u043e\u043a\u0438 \u2014 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u043e\u0440\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/github.com\/google\/zopfli\">Zopfli<\/a>) \u0441\u0442\u0430\u0440\u0430\u044e\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0435 \u0434\u0440\u0443\u0433\u0438\u0445, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0436\u0430\u0434\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: \u0432\u044b\u0434\u0430\u044e\u0442 \u0431\u043b\u043e\u043a\u0438, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.<\/p>\n<p>  \u0423 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0431\u043b\u043e\u043a\u043e\u0432 \u0441\u0432\u043e\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\u041d\u0435\u0441\u0436\u0430\u0442\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 65 535 \u0431\u0430\u0439\u0442\u043e\u0432.<\/li>\n<li>\u0424\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.<\/li>\n<li>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u0434\u044b \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u043d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 16-\u0431\u0438\u0442\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b 65 535 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438.<\/li>\n<\/ul>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043b\u043e\u043a\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c \u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440 65 534 \u0431\u0430\u0439\u0442\u0430\u043c\u0438:<\/p>\n<pre><code class=\"cpp\">\/* The largest number of bytes that will fit in any kind of block is 65,534.    It will fit in an uncompressed block (max 65,535 bytes) and a Huffman    block with only literals (65,535 symbols including end-of-block marker). *\/ #define MAX_BLOCK_LEN_BYTES 65534 <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0432 \u0445\u043e\u0434\u0435 \u0441\u0436\u0430\u0442\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443:<\/p>\n<pre><code class=\"cpp\">typedef struct deflate_state_t deflate_state_t; struct deflate_state_t {         ostream_t os;          const uint8_t *block_src; \/* First src byte in the block. *\/          size_t block_len;       \/* Number of symbols in the current block. *\/         size_t block_len_bytes; \/* Number of src bytes in the block. *\/          \/* Symbol frequencies for the current block. *\/         uint16_t litlen_freqs[LITLEN_MAX + 1];         uint16_t dist_freqs[DISTSYM_MAX + 1];          struct {                 uint16_t distance;    \/* Backref distance. *\/                 union {                         uint16_t lit; \/* Literal byte or end-of-block. *\/                         uint16_t len; \/* Backref length (distance != 0). *\/                 } u;         } block[MAX_BLOCK_LEN_BYTES + 1]; };  static void reset_block(deflate_state_t *s) {         s-&gt;block_len = 0;         s-&gt;block_len_bytes = 0;         memset(s-&gt;litlen_freqs, 0, sizeof(s-&gt;litlen_freqs));         memset(s-&gt;dist_freqs, 0, sizeof(s-&gt;dist_freqs)); } <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0431\u043b\u043e\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b <code>lz77_compress<\/code> \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430, \u0438 \u043f\u043e \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0431\u043b\u043e\u043a \u0432 \u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a:<\/p>\n<pre><code class=\"cpp\">static bool lit_callback(uint8_t lit, void *aux) {         deflate_state_t *s = aux;          if (s-&gt;block_len_bytes + 1 &gt; MAX_BLOCK_LEN_BYTES) {                 if (!write_block(s, false)) {                         return false;                 }                 s-&gt;block_src += s-&gt;block_len_bytes;                 reset_block(s);         }          assert(s-&gt;block_len &lt; sizeof(s-&gt;block) \/ sizeof(s-&gt;block[0]));         s-&gt;block[s-&gt;block_len  ].distance = 0;         s-&gt;block[s-&gt;block_len++].u.lit = lit;         s-&gt;block_len_bytes++;          s-&gt;litlen_freqs[lit]++;          return true; }  static bool backref_callback(size_t dist, size_t len, void *aux) {         deflate_state_t *s = aux;          if (s-&gt;block_len_bytes + len &gt; MAX_BLOCK_LEN_BYTES) {                 if (!write_block(s, false)) {                         return false;                 }                 s-&gt;block_src += s-&gt;block_len_bytes;                 reset_block(s);         }          assert(s-&gt;block_len &lt; sizeof(s-&gt;block) \/ sizeof(s-&gt;block[0]));         s-&gt;block[s-&gt;block_len  ].distance = (uint16_t)dist;         s-&gt;block[s-&gt;block_len++].u.len = (uint16_t)len;         s-&gt;block_len_bytes += len;          assert(len &gt;= MIN_LEN &amp;&amp; len &lt;= MAX_LEN);         assert(dist &gt;= MIN_DISTANCE &amp;&amp; dist &lt;= MAX_DISTANCE);         s-&gt;litlen_freqs[len2litlen[len]]++;         s-&gt;dist_freqs[distance2dist[dist]]++;          return true; } <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u0431\u043b\u043e\u043a\u043e\u0432. \u0415\u0441\u043b\u0438 \u0431\u043b\u043e\u043a \u043d\u0435 \u0441\u0436\u0430\u0442, \u0442\u043e \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"cpp\">static bool write_uncomp_block(deflate_state_t *s, bool final) {         uint8_t len_nlen[4];          \/* Write the block header. *\/         if (!ostream_write(&amp;s-&gt;os, (0x0 &lt;&lt; 1) | final, 3)) {                 return false;         }          len_nlen[0] = (uint8_t)(s-&gt;block_len_bytes &gt;&gt; 0);         len_nlen[1] = (uint8_t)(s-&gt;block_len_bytes &gt;&gt; 8);         len_nlen[2] = ~len_nlen[0];         len_nlen[3] = ~len_nlen[1];          if (!ostream_write_bytes_aligned(&amp;s-&gt;os, len_nlen, sizeof(len_nlen))) {                 return false;         }          if (!ostream_write_bytes_aligned(&amp;s-&gt;os, s-&gt;block_src,                                          s-&gt;block_len_bytes)) {                 return false;         }          return true; } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u0434\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u0438\u043d \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u0434\u043b\u044f litlen- \u0438 dist-\u043a\u043e\u0434\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0431\u043b\u043e\u043a, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u044d\u0442\u0438 \u043a\u043e\u0434\u044b:<\/p>\n<pre><code class=\"cpp\">static bool write_static_block(deflate_state_t *s, bool final) {         huffman_encoder_t litlen_enc, dist_enc;          \/* Write the block header. *\/         if (!ostream_write(&amp;s-&gt;os, (0x1 &lt;&lt; 1) | final, 3)) {                 return false;         }          huffman_encoder_init2(&amp;litlen_enc, fixed_litlen_lengths,                               sizeof(fixed_litlen_lengths) \/                               sizeof(fixed_litlen_lengths[0]));         huffman_encoder_init2(&amp;dist_enc, fixed_dist_lengths,                               sizeof(fixed_dist_lengths) \/                               sizeof(fixed_dist_lengths[0]));          return write_huffman_block(s, &amp;litlen_enc, &amp;dist_enc); }  static bool write_huffman_block(deflate_state_t *s,                                 const huffman_encoder_t *litlen_enc,                                 const huffman_encoder_t *dist_enc) {         size_t i, nbits;         uint64_t distance, dist, len, litlen, bits, ebits;          for (i = 0; i &lt; s-&gt;block_len; i++) {                 if (s-&gt;block[i].distance == 0) {                         \/* Literal or EOB. *\/                         litlen = s-&gt;block[i].u.lit;                         assert(litlen &lt;= LITLEN_EOB);                         if (!ostream_write(&amp;s-&gt;os,                                            litlen_enc-&gt;codewords[litlen],                                            litlen_enc-&gt;lengths[litlen])) {                                 return false;                         }                         continue;                 }                  \/* Back reference length. *\/                 len = s-&gt;block[i].u.len;                 litlen = len2litlen[len];                  \/* litlen bits *\/                 bits = litlen_enc-&gt;codewords[litlen];                 nbits = litlen_enc-&gt;lengths[litlen];                  \/* ebits *\/                 ebits = len - litlen_tbl[litlen - LITLEN_TBL_OFFSET].base_len;                 bits |= ebits &lt;&lt; nbits;                 nbits += litlen_tbl[litlen - LITLEN_TBL_OFFSET].ebits;                  \/* Back reference distance. *\/                 distance = s-&gt;block[i].distance;                 dist = distance2dist[distance];                  \/* dist bits *\/                 bits |= (uint64_t)dist_enc-&gt;codewords[dist] &lt;&lt; nbits;                 nbits += dist_enc-&gt;lengths[dist];                  \/* ebits *\/                 ebits = distance - dist_tbl[dist].base_dist;                 bits |= ebits &lt;&lt; nbits;                 nbits += dist_tbl[dist].ebits;                  if (!ostream_write(&amp;s-&gt;os, bits, nbits)) {                         return false;                 }         }          return true; } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0431\u043b\u043e\u043a\u0438 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0445\u0438\u0442\u0440\u043e\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 litlen- \u0438 dist-\u043a\u043e\u0434\u043e\u0432. \u0414\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439:<\/p>\n<pre><code class=\"cpp\">typedef struct codelen_sym_t codelen_sym_t; struct codelen_sym_t {         uint8_t sym;         uint8_t count; \/* For symbols 16, 17, 18. *\/ }; <\/code><\/pre>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0445\u0432\u043e\u0441\u0442 \u0438\u0445 \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0434\u043b\u0438\u043d \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 litlen \u0438 dist, \u0430 \u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0443\u043b\u0438: \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c Deflate-\u0431\u043b\u043e\u043a, \u0435\u0441\u043b\u0438 \u0432 \u043d\u0451\u043c \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e dist-\u043a\u043e\u0434\u0430. \u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 257 litlen-\u043a\u043e\u0434\u043e\u0432, \u043d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u043c\u0430\u0440\u043a\u0435\u0440 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0431\u0430\u0439\u0442\u0430, \u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 256.<\/p>\n<pre><code class=\"cpp\">\/* Encode litlen_lens and dist_lens into encoded. *num_litlen_lens and    *num_dist_lens will be set to the number of encoded litlen and dist lens,    respectively. Returns the number of elements in encoded. *\/ static size_t encode_dist_litlen_lens(const uint8_t *litlen_lens,                                       const uint8_t *dist_lens,                                       codelen_sym_t *encoded,                                       size_t *num_litlen_lens,                                       size_t *num_dist_lens) {         size_t i, n;         uint8_t lens[LITLEN_MAX + 1 + DISTSYM_MAX + 1];          *num_litlen_lens = LITLEN_MAX + 1;         *num_dist_lens = DISTSYM_MAX + 1;          \/* Drop trailing zero litlen lengths. *\/         assert(litlen_lens[LITLEN_EOB] != 0 &amp;&amp; &quot;EOB len should be non-zero.&quot;);         while (litlen_lens[*num_litlen_lens - 1] == 0) {                 (*num_litlen_lens)--;         }         assert(*num_litlen_lens &gt;= MIN_LITLEN_LENS);          \/* Drop trailing zero dist lengths, keeping at least one. *\/         while (dist_lens[*num_dist_lens - 1] == 0 &amp;&amp; *num_dist_lens &gt; 1) {                 (*num_dist_lens)--;         }         assert(*num_dist_lens &gt;= MIN_DIST_LENS);          \/* Copy the lengths into a unified array. *\/         n = 0;         for (i = 0; i &lt; *num_litlen_lens; i++) {                 lens[n++] = litlen_lens[i];         }         for (i = 0; i &lt; *num_dist_lens; i++) {                 lens[n++] = dist_lens[i];         }          return encode_lens(lens, n, encoded); } <\/code><\/pre>\n<p>  \u0421\u043b\u043e\u0436\u0438\u0432 \u0434\u043b\u0438\u043d\u044b \u043a\u043e\u0434\u043e\u0432 \u0432 \u043e\u0434\u0438\u043d \u043c\u0430\u0441\u0441\u0438\u0432, \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0434\u043b\u0438\u043d \u043a\u043e\u0434\u043e\u0432.<\/p>\n<pre><code class=\"cpp\">\/* Encode the n code lengths in lens into encoded, returning the number of    elements in encoded. *\/ static size_t encode_lens(const uint8_t *lens, size_t n, codelen_sym_t *encoded) {         size_t i, j, num_encoded;         uint8_t count;          i = 0;         num_encoded = 0;         while (i &lt; n) {                 if (lens[i] == 0) {                         \/* Scan past the end of this zero run (max 138). *\/                         for (j = i; j &lt; min(n, i + CODELEN_ZEROS2_MAX) &amp;&amp;                                     lens[j] == 0; j++);                         count = (uint8_t)(j - i);                          if (count &lt; CODELEN_ZEROS_MIN) {                                 \/* Output a single zero. *\/                                 encoded[num_encoded++].sym = 0;                                 i++;                                 continue;                         }                          \/* Output a repeated zero. *\/                         if (count &lt;= CODELEN_ZEROS_MAX) {                                 \/* Repeated zero 3--10 times. *\/                                 assert(count &gt;= CODELEN_ZEROS_MIN &amp;&amp;                                        count &lt;= CODELEN_ZEROS_MAX);                                 encoded[num_encoded].sym = CODELEN_ZEROS;                                 encoded[num_encoded++].count = count;                         } else {                                 \/* Repeated zero 11--138 times. *\/                                 assert(count &gt;= CODELEN_ZEROS2_MIN &amp;&amp;                                        count &lt;= CODELEN_ZEROS2_MAX);                                 encoded[num_encoded].sym = CODELEN_ZEROS2;                                 encoded[num_encoded++].count = count;                         }                         i = j;                         continue;                 }                  \/* Output len. *\/                 encoded[num_encoded++].sym = lens[i++];                  \/* Scan past the end of the run of this len (max 6). *\/                 for (j = i; j &lt; min(n, i + CODELEN_COPY_MAX) &amp;&amp;                             lens[j] == lens[i - 1]; j++);                 count = (uint8_t)(j - i);                  if (count &gt;= CODELEN_COPY_MIN) {                         \/* Repeat last len 3--6 times. *\/                         assert(count &gt;= CODELEN_COPY_MIN &amp;&amp;                                count &lt;= CODELEN_COPY_MAX);                         encoded[num_encoded].sym = CODELEN_COPY;                         encoded[num_encoded++].count = count;                         i = j;                         continue;                 }         }          return num_encoded; } <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0434\u0430 \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430 \u2014 codelen. \u0414\u043b\u0438\u043d\u044b \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u0438\u0437 \u043a\u043e\u0434\u0430 codelen \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0431\u043b\u043e\u043a \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0434\u043b\u0438\u043d\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u043a\u043e\u043d\u0446\u0435. \u0412\u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0430\u044f, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u0438\u043d \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c:<\/p>\n<pre><code class=\"cpp\">static const int codelen_lengths_order[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };  \/* Count the number of significant (not trailing zeros) codelen lengths. *\/ size_t count_codelen_lens(const uint8_t *codelen_lens) {         size_t n = MAX_CODELEN_LENS;          \/* Drop trailing zero lengths. *\/         while (codelen_lens[codelen_lengths_order[n - 1]] == 0) {                 n--;         }          \/* The first 4 lengths in the order (16, 17, 18, 0) cannot be used to            encode any non-zero lengths. Since there will always be at least            one non-zero codeword length (for EOB), n will be &gt;= 4. *\/         assert(n &gt;= MIN_CODELEN_LENS &amp;&amp; n &lt;= MAX_CODELEN_LENS);          return n; } <\/code><\/pre>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0443\u0436\u0435 \u0437\u0430\u0434\u0430\u043b\u0438 litlen- \u0438 dist-\u043a\u043e\u0434\u044b, \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u0438\u043d \u0438\u0445 \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u0438 \u043a\u043e\u0434 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0434\u043b\u0438\u043d. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u043b\u043e\u043a \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430:<\/p>\n<pre><code class=\"cpp\">static bool write_dynamic_block(deflate_state_t *s, bool final,                                 size_t num_litlen_lens, size_t num_dist_lens,                                 size_t num_codelen_lens,                                 const huffman_encoder_t *codelen_enc,                                 const codelen_sym_t *encoded_lens,                                 size_t num_encoded_lens,                                 const huffman_encoder_t *litlen_enc,                                 const huffman_encoder_t *dist_enc) {         size_t i;         uint8_t codelen, sym;         size_t nbits;         uint64_t bits, hlit, hdist, hclen, count;          \/* Block header. *\/         bits = (0x2 &lt;&lt; 1) | final;         nbits = 3;          \/* hlit (5 bits) *\/         hlit = num_litlen_lens - MIN_LITLEN_LENS;         bits |= hlit &lt;&lt; nbits;         nbits += 5;          \/* hdist (5 bits) *\/         hdist = num_dist_lens - MIN_DIST_LENS;         bits |= hdist &lt;&lt; nbits;         nbits += 5;          \/* hclen (4 bits) *\/         hclen = num_codelen_lens - MIN_CODELEN_LENS;         bits |= hclen &lt;&lt; nbits;         nbits += 4;          if (!ostream_write(&amp;s-&gt;os, bits, nbits)) {                 return false;         }          \/* Codelen lengths. *\/         for (i = 0; i &lt; num_codelen_lens; i++) {                 codelen = codelen_enc-&gt;lengths[codelen_lengths_order[i]];                 if (!ostream_write(&amp;s-&gt;os, codelen, 3)) {                         return false;                 }         }          \/* Litlen and dist code lengths. *\/         for (i = 0; i &lt; num_encoded_lens; i++) {                 sym = encoded_lens[i].sym;                  bits = codelen_enc-&gt;codewords[sym];                 nbits = codelen_enc-&gt;lengths[sym];                  count = encoded_lens[i].count;                 if (sym == CODELEN_COPY) { \/* 2 ebits *\/                         bits |= (count - CODELEN_COPY_MIN) &lt;&lt; nbits;                         nbits += 2;                 } else if (sym == CODELEN_ZEROS) { \/* 3 ebits *\/                         bits |= (count - CODELEN_ZEROS_MIN) &lt;&lt; nbits;                         nbits += 3;                 } else if (sym == CODELEN_ZEROS2) { \/* 7 ebits *\/                         bits |= (count - CODELEN_ZEROS2_MIN) &lt;&lt; nbits;                         nbits += 7;                 }                  if (!ostream_write(&amp;s-&gt;os, bits, nbits)) {                         return false;                 }         }          return write_huffman_block(s, litlen_enc, dist_enc); } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432. \u0414\u043b\u0438\u043d\u0443 \u043d\u0435\u0441\u0436\u0430\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e:<\/p>\n<pre><code class=\"cpp\">\/* Calculate the number of bits for an uncompressed block, including header. *\/ static size_t uncomp_block_len(const deflate_state_t *s) {         size_t bit_pos, padding;          \/* Bit position after writing the block header. *\/         bit_pos = ostream_bit_pos(&amp;s-&gt;os) + 3;         padding = round_up(bit_pos, 8) - bit_pos;          \/* Header + padding + len\/nlen + block contents. *\/         return 3 + padding + 2 * 16 + s-&gt;block_len_bytes * 8; } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0431\u043b\u043e\u043a\u043e\u0432, \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0443, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0442\u0435\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e litlen- \u0438 dist-\u0447\u0430\u0441\u0442\u043e\u0442 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u0434\u043b\u0438\u043d \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">\/* Calculate the number of bits for a Huffman encoded block body. *\/ static size_t huffman_block_body_len(const deflate_state_t *s,                                      const uint8_t *litlen_lens,                                      const uint8_t *dist_lens) {         size_t i, freq, len;          len = 0;          for (i = 0; i &lt;= LITLEN_MAX; i++) {                 freq = s-&gt;litlen_freqs[i];                 len += litlen_lens[i] * freq;                  if (i &gt;= LITLEN_TBL_OFFSET) {                         len += litlen_tbl[i - LITLEN_TBL_OFFSET].ebits * freq;                 }         }          for (i = 0; i &lt;= DISTSYM_MAX; i++) {                 freq = s-&gt;dist_freqs[i];                 len += dist_lens[i] * freq;                 len += dist_tbl[i].ebits * freq;         }          return len; } <\/code><\/pre>\n<p>  \u041e\u0431\u0449\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0440\u0430\u0432\u043d\u0430 3 \u0431\u0438\u0442\u0430\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u043f\u043b\u044e\u0441 \u0434\u043b\u0438\u043d\u0430 \u0442\u0435\u043b\u0430. \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<pre><code class=\"cpp\">\/* Calculate the number of bits for a dynamic Huffman block. *\/ static size_t dyn_block_len(const deflate_state_t *s, size_t num_codelen_lens,                             const uint16_t *codelen_freqs,                             const huffman_encoder_t *codelen_enc,                             const huffman_encoder_t *litlen_enc,                             const huffman_encoder_t *dist_enc) {         size_t len, i, freq;          \/* Block header. *\/         len = 3;          \/* Nbr of litlen, dist, and codelen lengths. *\/         len += 5 + 5 + 4;          \/* Codelen lengths. *\/         len += 3 * num_codelen_lens;          \/* Codelen encoding. *\/         for (i = 0; i &lt; MAX_CODELEN_LENS; i++) {                 freq = codelen_freqs[i];                 len += codelen_enc-&gt;lengths[i] * freq;                  \/* Extra bits. *\/                 if (i == CODELEN_COPY) {                         len += 2 * freq;                 } else if (i == CODELEN_ZEROS) {                         len += 3 * freq;                 } else if (i == CODELEN_ZEROS2) {                         len += 7 * freq;                 }         }          return len + huffman_block_body_len(s, litlen_enc-&gt;lengths,                                             dist_enc-&gt;lengths); } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0441\u0451 \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u043b\u043e\u043a\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">\/* Write the current deflate block, marking it final if that parameter is true,    returning false if there is not enough room in the output stream. *\/ static bool write_block(deflate_state_t *s, bool final) {         size_t old_bit_pos, uncomp_len, static_len, dynamic_len;         huffman_encoder_t dyn_litlen_enc, dyn_dist_enc, codelen_enc;         size_t num_encoded_lens, num_litlen_lens, num_dist_lens;         codelen_sym_t encoded_lens[LITLEN_MAX + 1 + DISTSYM_MAX + 1];         uint16_t codelen_freqs[MAX_CODELEN_LENS] = {0};         size_t num_codelen_lens;         size_t i;          old_bit_pos = ostream_bit_pos(&amp;s-&gt;os);          \/* Add the end-of-block marker in case we write a Huffman block. *\/         assert(s-&gt;block_len &lt; sizeof(s-&gt;block) \/ sizeof(s-&gt;block[0]));         assert(s-&gt;litlen_freqs[LITLEN_EOB] == 0);         s-&gt;block[s-&gt;block_len  ].distance = 0;         s-&gt;block[s-&gt;block_len++].u.lit = LITLEN_EOB;         s-&gt;litlen_freqs[LITLEN_EOB] = 1;          uncomp_len = uncomp_block_len(s);          static_len = 3 + huffman_block_body_len(s, fixed_litlen_lengths,                                                 fixed_dist_lengths);          \/* Compute &quot;dynamic&quot; Huffman codes. *\/         huffman_encoder_init(&amp;dyn_litlen_enc, s-&gt;litlen_freqs,                              LITLEN_MAX + 1, 15);         huffman_encoder_init(&amp;dyn_dist_enc, s-&gt;dist_freqs, DISTSYM_MAX + 1, 15);          \/* Encode the litlen and dist code lengths. *\/         num_encoded_lens = encode_dist_litlen_lens(dyn_litlen_enc.lengths,                                                    dyn_dist_enc.lengths,                                                    encoded_lens,                                                    &amp;num_litlen_lens,                                                    &amp;num_dist_lens);          \/* Compute the codelen code. *\/         for (i = 0; i &lt; num_encoded_lens; i++) {                 codelen_freqs[encoded_lens[i].sym]++;         }         huffman_encoder_init(&amp;codelen_enc, codelen_freqs, MAX_CODELEN_LENS, 7);         num_codelen_lens = count_codelen_lens(codelen_enc.lengths);          dynamic_len = dyn_block_len(s, num_codelen_lens, codelen_freqs,                                     &amp;codelen_enc, &amp;dyn_litlen_enc,                                     &amp;dyn_dist_enc);          if (uncomp_len &lt;= dynamic_len &amp;&amp; uncomp_len &lt;= static_len) {                 if (!write_uncomp_block(s, final)) {                         return false;                 }                 assert(ostream_bit_pos(&amp;s-&gt;os) - old_bit_pos == uncomp_len);         } else if (static_len &lt;= dynamic_len) {                 if (!write_static_block(s, final)) {                         return false;                 }                 assert(ostream_bit_pos(&amp;s-&gt;os) - old_bit_pos == static_len);         } else {                 if (!write_dynamic_block(s, final, num_litlen_lens,                                          num_dist_lens, num_codelen_lens,                                          &amp;codelen_enc, encoded_lens,                                          num_encoded_lens, &amp;dyn_litlen_enc,                                          &amp;dyn_dist_enc)) {                         return false;                 }                 assert(ostream_bit_pos(&amp;s-&gt;os) - old_bit_pos == dynamic_len);         }          return true; } <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0438\u043d\u0438\u0446\u0438\u0430\u0442\u043e\u0440 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u0435 Lempel-Ziv \u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0431\u043b\u043e\u043a:<\/p>\n<pre><code class=\"cpp\">\/* Compress (deflate) the data in src into dst. The number of bytes output, at    most dst_cap, is stored in *dst_used. Returns false if there is not enough    room in dst. src and dst must not overlap. *\/ bool hwdeflate(const uint8_t *src, size_t src_len, uint8_t *dst,                size_t dst_cap, size_t *dst_used) {         deflate_state_t s;          ostream_init(&amp;s.os, dst, dst_cap);         reset_block(&amp;s);         s.block_src = src;          if (!lz77_compress(src, src_len, &amp;lit_callback,                            &amp;backref_callback, &amp;s)) {                 return false;         }          if (!write_block(&amp;s, true)) {                 return false;         }          \/* The end of the final block should match the end of src. *\/         assert(s.block_src + s.block_len_bytes == src + src_len);          *dst_used = ostream_bytes_written(&amp;s.os);          return true; } <\/code><\/pre>\n<p>  <a name=\"17\"><\/a><\/p>\n<h2>\u0424\u043e\u0440\u043c\u0430\u0442 Zip-\u0444\u0430\u0439\u043b\u043e\u0432<\/h2>\n<p>  \u0412\u044b\u0448\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Deflate-\u0441\u0436\u0430\u0442\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 Zip-\u0444\u0430\u0439\u043b\u0430\u0445. \u0410 \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0451\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0444\u0430\u0439\u043b\u043e\u0432? \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. \u041a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/zip.h\">zip.h<\/a> \u0438 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/zip.c\">zip.c<\/a>.<\/p>\n<p>  <a name=\"18\"><\/a><\/p>\n<h3>\u041e\u0431\u0437\u043e\u0440<\/h3>\n<p>  \u0424\u043e\u0440\u043c\u0430\u0442 \u0444\u0430\u0439\u043b\u043e\u0432 \u043e\u043f\u0438\u0441\u0430\u043d \u0432 PKZip <a href=\"https:\/\/www.pkware.com\/documents\/APPNOTE\/APPNOTE-2.0.txt\">Application Note<\/a>:<\/p>\n<ol>\n<li>\u041a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b, \u0438\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0430\u0440\u0445\u0438\u0432\u0430, \u0432 Zip-\u0444\u0430\u0439\u043b\u0435 \u0438\u043c\u0435\u0435\u0442 <i>\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0430\u0439\u043b\u0430<\/i> \u0441 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e\u0431 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435.<\/li>\n<li><i>\u0426\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433<\/i> \u0441\u043b\u0443\u0436\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0430\u0440\u0445\u0438\u0432\u0430. \u041e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0430\u0440\u0445\u0438\u0432\u0430, \u043a\u043e\u043f\u0438\u044e \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u043a \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 Zip-\u0444\u0430\u0439\u043b\u0435.<\/li>\n<li>\u0412 \u043a\u043e\u043d\u0446\u0435 \u0444\u0430\u0439\u043b\u0430, \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 <i>\u043a\u043e\u043d\u0435\u0446 \u0437\u0430\u043f\u0438\u0441\u0438 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430<\/i>. \u041e\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043e\u0431\u043e \u0432\u0441\u0451\u043c \u0430\u0440\u0445\u0438\u0432\u0435. \u042d\u0442\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0447\u0442\u0435\u043d\u0438\u044f Zip-\u0444\u0430\u0439\u043b\u0430.<\/li>\n<\/ol>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/821\/bba\/6ce\/821bba6cede767c834da639e00d7d6ba.png\"><\/div>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0430\u0440\u0445\u0438\u0432\u0430 \u0441\u0436\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0432 \u0430\u0440\u0445\u0438\u0432\u0435 \u0435\u0441\u0442\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f, \u043e\u043d\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0441\u0436\u0430\u0442\u0438\u044f.<\/p>\n<p>  \u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0434\u043e\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432. \u041f\u043e \u043c\u0435\u0440\u0435 \u0441\u0436\u0430\u0442\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u043d\u0438 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0430\u0440\u0445\u0438\u0432. \u0418\u043d\u0434\u0435\u043a\u0441 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u0441\u0436\u0430\u0442\u044b\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0437\u043d\u0430\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0440\u0445\u0438\u0432 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e, \u043e\u043d \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0430 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432\u044b \u0431\u044b\u043b\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0438\u0441\u043a\u0435\u0442\u0430\u0445 \u0438\u043b\u0438 \u0442\u043e\u043c\u0430\u0445. \u041f\u043e \u043c\u0435\u0440\u0435 \u0441\u0436\u0430\u0442\u0438\u044f PKZip \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0434\u0438\u0441\u043a\u0435\u0442\u044b, \u0430 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435) \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433. \u0414\u043b\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u043c\u043d\u043e\u0433\u043e\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 PKZip \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u043b \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0434\u0438\u0441\u043a\u0435\u0442\u0443, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0438\u0441\u043a\u0435\u0442\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>  \u0412\u0430\u0441 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0443\u0434\u0438\u0432\u0438\u0442\u044c, \u043d\u043e \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u044e\u0449\u0435\u0433\u043e \u0438\u043c\u0435\u0442\u044c \u0432 \u0430\u0440\u0445\u0438\u0432\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438. \u042d\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u0435 \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0435: \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438, \u0442\u043e \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c? \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u044d\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c \u0432 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0418\u0437-\u0437\u0430 \u0431\u0430\u0433\u0430 \u00abMaster Key\u00bb \u0432 Android (<a href=\"https:\/\/nvd.nist.gov\/vuln\/detail\/CVE-2013-4787\">CVE-2013-4787<\/a>, <a href=\"https:\/\/media.blackhat.com\/us-13\/US-13-Forristal-Android-One-Root-to-Own-Them-All-Slides.pdf\">\u0441\u043b\u0430\u0439\u0434\u044b<\/a> \u0438 <a href=\"https:\/\/www.youtube.com\/watch?v=mCF5kaCt4NI\">\u0432\u0438\u0434\u0435\u043e<\/a> \u0441 \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u043d\u0430 Black Hat) \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0433 \u043f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043a\u0440\u0438\u043f\u0442\u043e\u043f\u043e\u0434\u043f\u0438\u0441\u0435\u0439. Android-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/APK\">APK<\/a>-\u0444\u0430\u0439\u043b\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 Zip-\u0444\u0430\u0439\u043b\u044b. \u041a\u0430\u043a \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0435\u0441\u043b\u0438 APK \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438, \u043a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u043b <i>\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439<\/i> \u0444\u0430\u0439\u043b \u0441 \u0442\u0430\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c, \u0430 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u044f\u0442\u043e\u0440 \u0432\u044b\u0431\u0438\u0440\u0430\u043b <i>\u043f\u0435\u0440\u0432\u044b\u0439<\/i> \u0444\u0430\u0439\u043b, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f Zip-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u0432\u0441\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<p>  \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432, Zip-\u0444\u0430\u0439\u043b\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0438\u043b\u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A4%D0%BE%D1%80%D0%BC%D0%B0%D1%82_%D1%84%D0%B0%D0%B9%D0%BB%D0%B0#%D0%9C%D0%B0%D0%B3%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B5_%D1%87%D0%B8%D1%81%D0%BB%D0%B0\">\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430<\/a>. \u0412\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e Zip-\u0444\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0435 \u0438 \u043a\u0430\u043a Zip, \u0438 \u043a\u0430\u043a \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u2014 <i>\u0444\u0430\u0439\u043b\u044b-\u043f\u043e\u043b\u0438\u0433\u043b\u043e\u0442\u044b<\/i>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0430\u043c\u043e\u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f Zip-\u0430\u0440\u0445\u0438\u0432\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/www.hanshq.net\/files\/pkz204g.exe\">pkz204g.exe<\/a>) \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435, \u0438 Zip-\u0444\u0430\u0439\u043b\u044b: \u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0439, \u0430 \u0437\u0430 \u043d\u0435 \u0438\u0434\u0451\u0442 Zip-\u0444\u0430\u0439\u043b (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e). \u041e\u0421 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439, \u043d\u043e Zip-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043e\u0442\u043a\u0440\u043e\u0435\u0442 \u0435\u0433\u043e \u043a\u0430\u043a Zip-\u0444\u0430\u0439\u043b. \u0422\u0430\u043a\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0433\u043b\u0430 \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u043d\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>  \u0425\u043e\u0442\u044f \u0442\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b-\u043f\u043e\u043b\u0438\u0433\u043b\u043e\u0442\u044b \u0438 \u0443\u043c\u043d\u044b, \u043d\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c \u0432 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u043e\u0431\u043c\u0430\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0441\u0442\u0430\u0440\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u043b\u043e\u0432\u0440\u0435\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043c\u0435\u0441\u0442\u0435 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u044d\u043a\u0441\u043f\u043b\u043e\u0439\u0442\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Gifar\">GIFAR<\/a>-\u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438 GIF-\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 Java-\u0430\u0440\u0445\u0438\u0432\u0430\u043c\u0438 (JAR, \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c Zip-\u0444\u0430\u0439\u043b\u043e\u0432). \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/www.alchemistowl.org\/pocorgtfo\/pocorgtfo07.pdf\">Abusing file formats<\/a> (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b 18).<\/p>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043d\u0438\u0436\u0435, Zip-\u0444\u0430\u0439\u043b\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 32-\u0431\u0438\u0442\u043d\u044b\u0435 \u043f\u043e\u043b\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0430\u0440\u0445\u0438\u0432\u0430 \u0438 \u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438. \u0412 <a href=\"https:\/\/pkware.cachefly.net\/webdocs\/APPNOTE\/APPNOTE-4.5.0.txt\">Application Note 4.5<\/a> PKWare \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 64-\u0431\u0438\u0442\u043d\u044b\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u044b. \u0424\u0430\u0439\u043b\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u044d\u0442\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043e\u0442\u043d\u043e\u0441\u044f\u0442 \u043a \u0444\u043e\u0440\u043c\u0430\u0442\u0443 Zip64, \u043d\u043e \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c.<\/p>\n<p>  <a name=\"19\"><\/a><\/p>\n<h3>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  <a name=\"20\"><\/a><\/p>\n<h4>\u041a\u043e\u043d\u0435\u0446 \u0437\u0430\u043f\u0438\u0441\u0438 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430<\/h4>\n<p>  \u041a\u043e\u043d\u0435\u0446 \u0437\u0430\u043f\u0438\u0441\u0438 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 (EOCDR) \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f Zip-\u0444\u0430\u0439\u043b\u0430. \u0412 \u043d\u0435\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043e\u0431\u043e \u0432\u0441\u0451\u043c \u0430\u0440\u0445\u0438\u0432\u0435.<\/p>\n<p>  \u0412 Zip-\u0444\u0430\u0439\u043b\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0438\u0441\u043a\u0435\u0442 \u2014 \u0438\u043b\u0438 \u0442\u043e\u043c\u043e\u0432, \u2014 EOCDR \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u043e\u0439 \u0434\u0438\u0441\u043a \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c, \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u0434\u0438\u0441\u043a\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0438 \u0442.\u0434. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e, \u0438 \u043a\u043e\u0434 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0442\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442.<\/p>\n<p>  EOCDR \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 &#8216;P&#8217; &#8216;K&#8217;, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0434\u0443\u0442 \u0431\u0430\u0439\u0442\u044b 5 \u0438 6. \u0417\u0430 \u043d\u0435\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0447\u0438\u0441\u043b\u0430 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 little-endian:<\/p>\n<pre><code class=\"cpp\">\/* End of Central Directory Record. *\/ struct eocdr {         uint16_t disk_nbr;        \/* Number of this disk. *\/         uint16_t cd_start_disk;   \/* Nbr. of disk with start of the CD. *\/         uint16_t disk_cd_entries; \/* Nbr. of CD entries on this disk. *\/         uint16_t cd_entries;      \/* Nbr. of Central Directory entries. *\/         uint32_t cd_size;         \/* Central Directory size in bytes. *\/         uint32_t cd_offset;       \/* Central Directory file offset. *\/         uint16_t comment_len;     \/* Archive comment length. *\/         const uint8_t *comment;   \/* Archive comment. *\/ }; <\/code><\/pre>\n<p>  EOCDR \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0444\u0430\u0439\u043b\u0430. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u0435\u0451 \u0445\u0432\u043e\u0441\u0442\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 16-\u0431\u0438\u0442\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e:<\/p>\n<pre><code class=\"cpp\">\/* Read 16\/32 bits little-endian and bump p forward afterwards. *\/ #define READ16(p) ((p) += 2, read16le((p) - 2)) #define READ32(p) ((p) += 4, read32le((p) - 4))  \/* Size of the End of Central Directory Record, not including comment. *\/ #define EOCDR_BASE_SZ 22 #define EOCDR_SIGNATURE 0x06054b50  \/* &quot;PK\\5\\6&quot; little-endian. *\/  static bool find_eocdr(struct eocdr *r, const uint8_t *src, size_t src_len) {         size_t comment_len;         const uint8_t *p;         uint32_t signature;          for (comment_len = 0; comment_len &lt;= UINT16_MAX; comment_len++) {                 if (src_len &lt; EOCDR_BASE_SZ + comment_len) {                         break;                 }                  p = &amp;src[src_len - EOCDR_BASE_SZ - comment_len];                 signature = READ32(p);                  if (signature == EOCDR_SIGNATURE) {                         r-&gt;disk_nbr = READ16(p);                         r-&gt;cd_start_disk = READ16(p);                         r-&gt;disk_cd_entries = READ16(p);                         r-&gt;cd_entries = READ16(p);                         r-&gt;cd_size = READ32(p);                         r-&gt;cd_offset = READ32(p);                         r-&gt;comment_len = READ16(p);                         r-&gt;comment = p;                         assert(p == &amp;src[src_len - comment_len] &amp;&amp;                                &quot;All fields read.&quot;);                          if (r-&gt;comment_len == comment_len) {                                 return true;                         }                 }         }          return false; } <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c EOCDR \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">\/* Write 16\/32 bits little-endian and bump p forward afterwards. *\/ #define WRITE16(p, x) (write16le((p), (x)), (p) += 2) #define WRITE32(p, x) (write32le((p), (x)), (p) += 4)  static size_t write_eocdr(uint8_t *dst, const struct eocdr *r) {         uint8_t *p = dst;          WRITE32(p, EOCDR_SIGNATURE);         WRITE16(p, r-&gt;disk_nbr);         WRITE16(p, r-&gt;cd_start_disk);         WRITE16(p, r-&gt;disk_cd_entries);         WRITE16(p, r-&gt;cd_entries);         WRITE32(p, r-&gt;cd_size);         WRITE32(p, r-&gt;cd_offset);         WRITE16(p, r-&gt;comment_len);         assert(p - dst == EOCDR_BASE_SZ);          if (r-&gt;comment_len != 0) {                 memcpy(p, r-&gt;comment, r-&gt;comment_len);                 p += r-&gt;comment_len;         }          return (size_t)(p - dst); } <\/code><\/pre>\n<p>  <a name=\"21\"><\/a><\/p>\n<h4>\u0426\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0430\u0439\u043b\u0430<\/h4>\n<p>  \u0426\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0444\u0430\u0439\u043b\u043e\u0432, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c, \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0430\u0440\u0445\u0438\u0432\u0430. \u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b &#8216;P&#8217;, &#8216;K&#8217;, 1, 2, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438\u0434\u0451\u0442 \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">#define EXT_ATTR_DIR (1U &lt;&lt; 4) #define EXT_ATTR_ARC (1U &lt;&lt; 5)  \/* Central File Header (Central Directory Entry) *\/ struct cfh {         uint16_t made_by_ver;    \/* Version made by. *\/         uint16_t extract_ver;    \/* Version needed to extract. *\/         uint16_t gp_flag;        \/* General purpose bit flag. *\/         uint16_t method;         \/* Compression method. *\/         uint16_t mod_time;       \/* Modification time. *\/         uint16_t mod_date;       \/* Modification date. *\/         uint32_t crc32;          \/* CRC-32 checksum. *\/         uint32_t comp_size;      \/* Compressed size. *\/         uint32_t uncomp_size;    \/* Uncompressed size. *\/         uint16_t name_len;       \/* Filename length. *\/         uint16_t extra_len;      \/* Extra data length. *\/         uint16_t comment_len;    \/* Comment length. *\/         uint16_t disk_nbr_start; \/* Disk nbr. where file begins. *\/         uint16_t int_attrs;      \/* Internal file attributes. *\/         uint32_t ext_attrs;      \/* External file attributes. *\/         uint32_t lfh_offset;     \/* Local File Header offset. *\/         const uint8_t *name;     \/* Filename. *\/         const uint8_t *extra;    \/* Extra data. *\/         const uint8_t *comment;  \/* File comment. *\/ }; <\/code><\/pre>\n<p>  <code>made_by_ver<\/code> \u0438 <code>extract_ver<\/code> \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u041e\u0421 \u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0435\u0433\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f. \u0421\u0430\u043c\u044b\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0438\u0442\u043e\u0432 \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 0 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 DOS, 3 \u2014 Unix, 10 \u2014 Windows NTFS), \u0430 \u043c\u043b\u0430\u0434\u0448\u0438\u0435 \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0438\u0442\u043e\u0432 \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442 \u0432\u0435\u0440\u0441\u0438\u044e \u041f\u041e. \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 20, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0441 PKZip 2.0.<\/p>\n<p>  <code>gp_flag<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438. \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442:<\/p>\n<ul>\n<li>\u0411\u0438\u0442 0, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0438\u0439 \u0444\u0430\u043a\u0442 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (\u043c\u044b \u044d\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c);<\/li>\n<li>\u0418 \u0431\u0438\u0442\u044b 1 \u0438 2, \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0443\u0440\u043e\u0432\u0435\u043d\u044c Deflate-\u0441\u0436\u0430\u0442\u0438\u044f (0 \u2014 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435, 1 \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435, 2 \u2014 \u0431\u044b\u0441\u0442\u0440\u043e\u0435, 3 \u2014 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e\u0435).<\/li>\n<\/ul>\n<p>  <code>method<\/code> \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0441\u0436\u0430\u0442\u0438\u044f. 0 \u2014 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0441\u0436\u0430\u0442\u044b, 8 \u2014 \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d Delate. \u0414\u0440\u0443\u0433\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0441\u0442\u0430\u0440\u044b\u043c \u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c, \u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 Zip-\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u044d\u0442\u0438 \u0434\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <code>mod_time<\/code> \u0438 <code>mod_date<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0434\u0430\u0442\u0443 \u0438 \u0432\u0440\u0435\u043c\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430, \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432 <a href=\"http:\/\/www.ctyme.com\/intr\/rb-2992.htm#table1665\">MS-DOS-\u0444\u043e\u0440\u043c\u0430\u0442\u0435<\/a>. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438 \u0421 <code>time_t<\/code> \u0432 MS-DOS-\u0444\u043e\u0440\u043c\u0430\u0442 \u0438 \u0438\u0437 \u043d\u0435\u0433\u043e:<\/p>\n<pre><code class=\"cpp\">\/* Convert DOS date and time to time_t. *\/ static time_t dos2ctime(uint16_t dos_date, uint16_t dos_time) {         struct tm tm = {0};          tm.tm_sec = (dos_time &amp; 0x1f) * 2;  \/* Bits 0--4:  Secs divided by 2. *\/         tm.tm_min = (dos_time &gt;&gt; 5) &amp; 0x3f; \/* Bits 5--10: Minute. *\/         tm.tm_hour = (dos_time &gt;&gt; 11);      \/* Bits 11-15: Hour (0--23). *\/          tm.tm_mday = (dos_date &amp; 0x1f);          \/* Bits 0--4: Day (1--31). *\/         tm.tm_mon = ((dos_date &gt;&gt; 5) &amp; 0xf) - 1; \/* Bits 5--8: Month (1--12). *\/         tm.tm_year = (dos_date &gt;&gt; 9) + 80;       \/* Bits 9--15: Year-1980. *\/          tm.tm_isdst = -1;          return mktime(&amp;tm); }  \/* Convert time_t to DOS date and time. *\/ static void ctime2dos(time_t t, uint16_t *dos_date, uint16_t *dos_time) {         struct tm *tm = localtime(&amp;t);          *dos_time = 0;         *dos_time |= tm-&gt;tm_sec \/ 2;    \/* Bits 0--4:  Second divided by two. *\/         *dos_time |= tm-&gt;tm_min &lt;&lt; 5;   \/* Bits 5--10: Minute. *\/         *dos_time |= tm-&gt;tm_hour &lt;&lt; 11; \/* Bits 11-15: Hour. *\/          *dos_date = 0;         *dos_date |= tm-&gt;tm_mday;             \/* Bits 0--4:  Day (1--31). *\/         *dos_date |= (tm-&gt;tm_mon + 1) &lt;&lt; 5;   \/* Bits 5--8:  Month (1--12). *\/         *dos_date |= (tm-&gt;tm_year - 80) &lt;&lt; 9; \/* Bits 9--15: Year from 1980. *\/ } <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0435 <code>crc32<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442<a href=\"https:\/\/en.wikipedia.org\/wiki\/Cyclic_redundancy_check\"> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/a> \u043d\u0435\u0441\u0436\u0430\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0434\u0435\u0441\u044c: <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/crc32.c\">crc32.c<\/a>.<\/p>\n<p>  <code>comp_size<\/code> \u0438 <code>uncomp_size<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u0436\u0430\u0442\u044b\u0439 \u0438 \u043d\u0435\u0441\u0436\u0430\u0442\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0438 \u043f\u043e\u043b\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0434\u043b\u0438\u043d\u044b \u0438\u043c\u0435\u043d\u0438, \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0434\u0443\u0442 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. <code>disk_nbr_start<\/code> \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u0434\u043b\u044f \u0430\u0440\u0445\u0438\u0432\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0438\u0441\u043a\u0435\u0442.<\/p>\n<p>  <code>int_attrs<\/code> \u0438 <code>ext_attrs<\/code> \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0444\u0430\u0439\u043b\u0430. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0438\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u0444\u0430\u0439\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0441\u0442. \u0412\u043d\u0435\u0448\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0444\u0430\u0439\u043b \u0441\u043a\u0440\u044b\u0442\u044b\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0442.\u0434. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u044d\u0442\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u041e\u0421, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043e\u0442 <code>made_by_ver<\/code>. \u0412 DOS \u043c\u043b\u0430\u0434\u0448\u0438\u0435 8 \u0431\u0438\u0442\u043e\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0431\u0430\u0439\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <a href=\"http:\/\/www.ctyme.com\/intr\/rb-2802.htm\">Int 21\/AX=4300h<\/a>. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0431\u0438\u0442 4 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f, \u0430 \u0431\u0438\u0442 5 \u2014 \u0447\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u00ab\u0430\u0440\u0445\u0438\u0432\u00bb (\u0432\u0435\u0440\u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 DOS). \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043d\u044f\u043b, \u0440\u0430\u0434\u0438 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u044d\u0442\u0438 \u0431\u0438\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u041e\u0421. \u0412 Unix \u0441\u0442\u0430\u0440\u0448\u0438\u0435 16 \u0431\u0438\u0442\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0431\u0438\u0442\u044b \u0440\u0435\u0436\u0438\u043c\u0430 \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f <a href=\"https:\/\/linux.die.net\/man\/2\/stat\">stat(2)<\/a> \u0432 <code>st_mode<\/code>.<\/p>\n<p>  <code>lfh_offset<\/code> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c, \u0433\u0434\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0430\u0439\u043b\u0430. <code>name<\/code> \u2014 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 (C-\u0441\u0442\u0440\u043e\u043a\u0430), \u0430 <code>comment<\/code> \u2014 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0430\u0440\u0445\u0438\u0432\u0430 (\u0421-\u0441\u0442\u0440\u043e\u043a\u0430). <code>extra<\/code> \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0440\u043e\u0434\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435 Unix-\u0444\u0430\u0439\u043b\u0430, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u0442\u0443 \u0438 \u0432\u0440\u0435\u043c\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043b\u0438 Zip64-\u043f\u043e\u043b\u044f.<\/p>\n<p>  \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">\/* Size of a Central File Header, not including name, extra, and comment. *\/ #define CFH_BASE_SZ 46 #define CFH_SIGNATURE 0x02014b50 \/* &quot;PK\\1\\2&quot; little-endian. *\/  static bool read_cfh(struct cfh *cfh, const uint8_t *src, size_t src_len,                      size_t offset) {         const uint8_t *p;         uint32_t signature;          if (offset &gt; src_len || src_len - offset &lt; CFH_BASE_SZ) {                 return false;         }          p = &amp;src[offset];         signature = READ32(p);         if (signature != CFH_SIGNATURE) {                 return false;         }          cfh-&gt;made_by_ver = READ16(p);         cfh-&gt;extract_ver = READ16(p);         cfh-&gt;gp_flag = READ16(p);         cfh-&gt;method = READ16(p);         cfh-&gt;mod_time = READ16(p);         cfh-&gt;mod_date = READ16(p);         cfh-&gt;crc32 = READ32(p);         cfh-&gt;comp_size = READ32(p);         cfh-&gt;uncomp_size = READ32(p);         cfh-&gt;name_len = READ16(p);         cfh-&gt;extra_len = READ16(p);         cfh-&gt;comment_len = READ16(p);         cfh-&gt;disk_nbr_start = READ16(p);         cfh-&gt;int_attrs = READ16(p);         cfh-&gt;ext_attrs = READ32(p);         cfh-&gt;lfh_offset = READ32(p);         cfh-&gt;name = p;         cfh-&gt;extra = cfh-&gt;name + cfh-&gt;name_len;         cfh-&gt;comment = cfh-&gt;extra + cfh-&gt;extra_len;         assert(p == &amp;src[offset + CFH_BASE_SZ] &amp;&amp; &quot;All fields read.&quot;);          if (src_len - offset - CFH_BASE_SZ &lt;             cfh-&gt;name_len + cfh-&gt;extra_len + cfh-&gt;comment_len) {                 return false;         }          return true; }  static size_t write_cfh(uint8_t *dst, const struct cfh *cfh) {         uint8_t *p = dst;          WRITE32(p, CFH_SIGNATURE);         WRITE16(p, cfh-&gt;made_by_ver);         WRITE16(p, cfh-&gt;extract_ver);         WRITE16(p, cfh-&gt;gp_flag);         WRITE16(p, cfh-&gt;method);         WRITE16(p, cfh-&gt;mod_time);         WRITE16(p, cfh-&gt;mod_date);         WRITE32(p, cfh-&gt;crc32);         WRITE32(p, cfh-&gt;comp_size);         WRITE32(p, cfh-&gt;uncomp_size);         WRITE16(p, cfh-&gt;name_len);         WRITE16(p, cfh-&gt;extra_len);         WRITE16(p, cfh-&gt;comment_len);         WRITE16(p, cfh-&gt;disk_nbr_start);         WRITE16(p, cfh-&gt;int_attrs);         WRITE32(p, cfh-&gt;ext_attrs);         WRITE32(p, cfh-&gt;lfh_offset);         assert(p - dst == CFH_BASE_SZ);          if (cfh-&gt;name_len != 0) {                 memcpy(p, cfh-&gt;name, cfh-&gt;name_len);                 p += cfh-&gt;name_len;         }          if (cfh-&gt;extra_len != 0) {                 memcpy(p, cfh-&gt;extra, cfh-&gt;extra_len);                 p += cfh-&gt;extra_len;         }          if (cfh-&gt;comment_len != 0) {                 memcpy(p, cfh-&gt;comment, cfh-&gt;comment_len);                 p += cfh-&gt;comment_len;         }          return (size_t)(p - dst); } <\/code><\/pre>\n<p>  <a name=\"22\"><\/a><\/p>\n<h4>\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0430\u0439\u043b\u0430<\/h4>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0430\u0440\u0445\u0438\u0432\u0430 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u044f\u044e\u0442\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. <\/p>\n<p>  \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u043c \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 \u0431\u044b\u043b\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b PKZip \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0435 \u043d\u0435 \u0434\u0435\u0440\u0436\u0430\u043b \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u0435\u0441\u044c \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0435\u0433\u043e \u0438\u043c\u044f \u0438 \u043f\u0440\u043e\u0447\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0447\u0438\u0442\u0430\u043d\u0430 \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437 Zip-\u0430\u0440\u0445\u0438\u0432\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u043b\u0438 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0451\u043d. <\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u0430 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0438\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u043c \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442? \u042d\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0431\u0430\u0433\u0430\u043c \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c \u0432 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0414\u0443\u0431\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0432\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u0437 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044f \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u043d \u0442\u0440\u0435\u0442\u0438\u0439 \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0439 \u0431\u0438\u0442 <code>gp_flags<\/code> (CRC-32), \u0442\u043e \u043f\u043e\u043b\u044f \u0441\u0436\u0430\u0442\u043e\u0433\u043e \u0438 \u043d\u0435\u0441\u0436\u0430\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u0443\u043b\u0435\u043d\u044b, \u0430 \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0442\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435 <i>Data Descriptor<\/i> \u043f\u043e\u0441\u043b\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0430\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 (\u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c). \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0435\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0434\u043e \u043a\u0430\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u0436\u0430\u0442.<\/p>\n<p>  \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b &#8216;P&#8217;, &#8216;K&#8217;, 3, 4, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438\u0434\u0451\u0442 \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">\/* Local File Header. *\/ struct lfh {         uint16_t extract_ver;         uint16_t gp_flag;         uint16_t method;         uint16_t mod_time;         uint16_t mod_date;         uint32_t crc32;         uint32_t comp_size;         uint32_t uncomp_size;         uint16_t name_len;         uint16_t extra_len;         const uint8_t *name;         const uint8_t *extra; }; <\/code><\/pre>\n<p>  \u042d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u043a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"cpp\">\/* Size of a Local File Header, not including name and extra. *\/ #define LFH_BASE_SZ 30 #define LFH_SIGNATURE 0x04034b50 \/* &quot;PK\\3\\4&quot; little-endian. *\/  static bool read_lfh(struct lfh *lfh, const uint8_t *src, size_t src_len,                      size_t offset) {         const uint8_t *p;         uint32_t signature;          if (offset &gt; src_len || src_len - offset &lt; LFH_BASE_SZ) {                 return false;         }          p = &amp;src[offset];         signature = READ32(p);         if (signature != LFH_SIGNATURE) {                 return false;         }          lfh-&gt;extract_ver = READ16(p);         lfh-&gt;gp_flag = READ16(p);         lfh-&gt;method = READ16(p);         lfh-&gt;mod_time = READ16(p);         lfh-&gt;mod_date = READ16(p);         lfh-&gt;crc32 = READ32(p);         lfh-&gt;comp_size = READ32(p);         lfh-&gt;uncomp_size = READ32(p);         lfh-&gt;name_len = READ16(p);         lfh-&gt;extra_len = READ16(p);         lfh-&gt;name = p;         lfh-&gt;extra = lfh-&gt;name + lfh-&gt;name_len;         assert(p == &amp;src[offset + LFH_BASE_SZ] &amp;&amp; &quot;All fields read.&quot;);          if (src_len - offset - LFH_BASE_SZ &lt; lfh-&gt;name_len + lfh-&gt;extra_len) {                 return false;         }          return true; }  static size_t write_lfh(uint8_t *dst, const struct lfh *lfh) {         uint8_t *p = dst;          WRITE32(p, LFH_SIGNATURE);         WRITE16(p, lfh-&gt;extract_ver);         WRITE16(p, lfh-&gt;gp_flag);         WRITE16(p, lfh-&gt;method);         WRITE16(p, lfh-&gt;mod_time);         WRITE16(p, lfh-&gt;mod_date);         WRITE32(p, lfh-&gt;crc32);         WRITE32(p, lfh-&gt;comp_size);         WRITE32(p, lfh-&gt;uncomp_size);         WRITE16(p, lfh-&gt;name_len);         WRITE16(p, lfh-&gt;extra_len);         assert(p - dst == LFH_BASE_SZ);          if (lfh-&gt;name_len != 0) {                 memcpy(p, lfh-&gt;name, lfh-&gt;name_len);                 p += lfh-&gt;name_len;         }          if (lfh-&gt;extra_len != 0) {                 memcpy(p, lfh-&gt;extra, lfh-&gt;extra_len);                 p += lfh-&gt;extra_len;         }          return (size_t)(p - dst); } <\/code><\/pre>\n<p>  <a name=\"23\"><\/a><\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Zip-\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0447\u0442\u0435\u043d\u0438\u0435 Zip-\u0444\u0430\u0439\u043b\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0430\u0440\u0445\u0438\u0432\u0430:<\/p>\n<pre><code class=\"cpp\">typedef size_t zipiter_t; \/* Zip archive member iterator. *\/  typedef struct zip_t zip_t; struct zip_t {         uint16_t num_members;    \/* Number of members. *\/         const uint8_t *comment;  \/* Zip file comment (not terminated). *\/         uint16_t comment_len;    \/* Zip file comment length. *\/         zipiter_t members_begin; \/* Iterator to the first member. *\/         zipiter_t members_end;   \/* Iterator to the end of members. *\/          const uint8_t *src;         size_t src_len; };  \/* Initialize zip based on the source data. Returns true on success, or false    if the data could not be parsed as a valid Zip file. *\/ bool zip_read(zip_t *zip, const uint8_t *src, size_t src_len) {         struct eocdr eocdr;         struct cfh cfh;         struct lfh lfh;         size_t i, offset;         const uint8_t *comp_data;          zip-&gt;src = src;         zip-&gt;src_len = src_len;          if (!find_eocdr(&amp;eocdr, src, src_len)) {                 return false;         }          if (eocdr.disk_nbr != 0 || eocdr.cd_start_disk != 0 ||             eocdr.disk_cd_entries != eocdr.cd_entries) {                 return false; \/* Cannot handle multi-volume archives. *\/         }          zip-&gt;num_members = eocdr.cd_entries;         zip-&gt;comment = eocdr.comment;         zip-&gt;comment_len = eocdr.comment_len;          offset = eocdr.cd_offset;         zip-&gt;members_begin = offset;          \/* Read the member info and do a few checks. *\/         for (i = 0; i &lt; eocdr.cd_entries; i++) {                 if (!read_cfh(&amp;cfh, src, src_len, offset)) {                         return false;                 }                  if (cfh.gp_flag &amp; 1) {                         return false; \/* The member is encrypted. *\/                 }                 if (cfh.method != ZIP_STORED &amp;&amp; cfh.method != ZIP_DEFLATED) {                         return false; \/* Unsupported compression method. *\/                 }                 if (cfh.method == ZIP_STORED &amp;&amp;                     cfh.uncomp_size != cfh.comp_size) {                         return false;                 }                 if (cfh.disk_nbr_start != 0) {                         return false; \/* Cannot handle multi-volume archives. *\/                 }                 if (memchr(cfh.name, '\\0', cfh.name_len) != NULL) {                         return false; \/* Bad filename. *\/                 }                  if (!read_lfh(&amp;lfh, src, src_len, cfh.lfh_offset)) {                         return false;                 }                  comp_data = lfh.extra + lfh.extra_len;                 if (cfh.comp_size &gt; src_len - (size_t)(comp_data - src)) {                         return false; \/* Member data does not fit in src. *\/                 }                  offset += CFH_BASE_SZ + cfh.name_len + cfh.extra_len +                           cfh.comment_len;         }          zip-&gt;members_end = offset;          return true; } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0432\u044b\u0448\u0435, \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u0430, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">typedef enum { ZIP_STORED = 0, ZIP_DEFLATED = 8 } method_t;  typedef struct zipmemb_t zipmemb_t; struct zipmemb_t {         const uint8_t *name;      \/* Member name (not null terminated). *\/         uint16_t name_len;        \/* Member name length. *\/         time_t mtime;             \/* Modification time. *\/         uint32_t comp_size;       \/* Compressed size. *\/         const uint8_t *comp_data; \/* Compressed data. *\/         method_t method;          \/* Compression method. *\/         uint32_t uncomp_size;     \/* Uncompressed size. *\/         uint32_t crc32;           \/* CRC-32 checksum. *\/         const uint8_t *comment;   \/* Comment (not null terminated). *\/         uint16_t comment_len;     \/* Comment length. *\/         bool is_dir;              \/* Whether this is a directory. *\/         zipiter_t next;           \/* Iterator to the next member. *\/ };  \/* Get the Zip archive member through iterator it. *\/ zipmemb_t zip_member(const zip_t *zip, zipiter_t it) {         struct cfh cfh;         struct lfh lfh;         bool ok;         zipmemb_t m;          assert(it &gt;= zip-&gt;members_begin &amp;&amp; it &lt; zip-&gt;members_end);          ok = read_cfh(&amp;cfh, zip-&gt;src, zip-&gt;src_len, it);         assert(ok);          ok = read_lfh(&amp;lfh, zip-&gt;src, zip-&gt;src_len, cfh.lfh_offset);         assert(ok);          m.name = cfh.name;         m.name_len = cfh.name_len;         m.mtime = dos2ctime(cfh.mod_date, cfh.mod_time);         m.comp_size = cfh.comp_size;         m.comp_data = lfh.extra + lfh.extra_len;         m.method = cfh.method;         m.uncomp_size = cfh.uncomp_size;         m.crc32 = cfh.crc32;         m.comment = cfh.comment;         m.comment_len = cfh.comment_len;         m.is_dir = (cfh.ext_attrs &amp; EXT_ATTR_DIR) != 0;          m.next = it + CFH_BASE_SZ +                  cfh.name_len + cfh.extra_len + cfh.comment_len;          assert(m.next &lt;= zip-&gt;members_end);          return m; } <\/code><\/pre>\n<p>  <a name=\"24\"><\/a><\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Zip-\u0437\u0430\u043f\u0438\u0441\u0438<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c Zip-\u0444\u0430\u0439\u043b \u0432 \u0431\u0443\u0444\u0435\u0440 \u043f\u0430\u043c\u044f\u0442\u0438, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c. \u0410 \u0440\u0430\u0437 \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0436\u043c\u0451\u043c, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043d\u0435\u0441\u0436\u0430\u0442\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">\/* Compute an upper bound on the dst size required by zip_write() for an  * archive with num_memb members with certain filenames, sizes, and archive  * comment. Returns zero on error, e.g. if a filename is longer than 2^16-1, or  * if the total file size is larger than 2^32-1. *\/ uint32_t zip_max_size(uint16_t num_memb, const char *const *filenames,                       const uint32_t *file_sizes, const char *comment) {         size_t comment_len, name_len;         uint64_t total;         uint16_t i;          comment_len = (comment == NULL ? 0 : strlen(comment));         if (comment_len &gt; UINT16_MAX) {                 return 0;         }          total = EOCDR_BASE_SZ + comment_len; \/* EOCDR *\/          for (i = 0; i &lt; num_memb; i++) {                 assert(filenames[i] != NULL);                 name_len = strlen(filenames[i]);                 if (name_len &gt; UINT16_MAX) {                         return 0;                 }                  total += CFH_BASE_SZ + name_len; \/* Central File Header *\/                 total += LFH_BASE_SZ + name_len; \/* Local File Header *\/                 total += file_sizes[i];          \/* Uncompressed data size. *\/         }          if (total &gt; UINT32_MAX) {                 return 0;         }          return (uint32_t)total; } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 Zip-\u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Deflate-\u0441\u0436\u0430\u0442\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">\/* Write a Zip file containing num_memb members into dst, which must be large    enough to hold the resulting data. Returns the number of bytes written, which    is guaranteed to be less than or equal to the result of zip_max_size() when    called with the corresponding arguments. comment shall be a null-terminated    string or null. callback shall be null or point to a function which will    get called after the compression of each member. *\/ uint32_t zip_write(uint8_t *dst, uint16_t num_memb,                    const char *const *filenames,                    const uint8_t *const *file_data,                    const uint32_t *file_sizes,                    const time_t *mtimes,                    const char *comment,                    void (*callback)(const char *filename, uint32_t size,                                     uint32_t comp_size)) {         uint16_t i;         uint8_t *p;         struct eocdr eocdr;         struct cfh cfh;         struct lfh lfh;         bool ok;         uint16_t name_len;         uint8_t *data_dst;         size_t comp_sz;         uint32_t lfh_offset, cd_offset, eocdr_offset;          p = dst;          \/* Write Local File Headers and deflated or stored data. *\/         for (i = 0; i &lt; num_memb; i++) {                 assert(filenames[i] != NULL);                 assert(strlen(filenames[i]) &lt;= UINT16_MAX);                 name_len = (uint16_t)strlen(filenames[i]);                  data_dst = p + LFH_BASE_SZ + name_len;                  if (hwdeflate(file_data[i], file_sizes[i], data_dst,                               file_sizes[i], &amp;comp_sz) &amp;&amp;                                 comp_sz &lt; file_sizes[i]) {                         lfh.method = ZIP_DEFLATED;                         assert(comp_sz &lt;= UINT32_MAX);                         lfh.comp_size = (uint32_t)comp_sz;                 } else {                         memcpy(data_dst, file_data[i], file_sizes[i]);                         lfh.method = ZIP_STORED;                         lfh.comp_size = file_sizes[i];                 }                  if (callback != NULL) {                         callback(filenames[i], file_sizes[i], lfh.comp_size);                 }                  lfh.extract_ver = (0 &lt;&lt; 8) | 20; \/* DOS | PKZIP 2.0 *\/                 lfh.gp_flag = (lfh.method == ZIP_DEFLATED ? (0x1 &lt;&lt; 1) : 0x0);                 ctime2dos(mtimes[i], &amp;lfh.mod_date, &amp;lfh.mod_time);                 lfh.crc32 = crc32(file_data[i], file_sizes[i]);                 lfh.uncomp_size = file_sizes[i];                 lfh.name_len = name_len;                 lfh.extra_len = 0;                 lfh.name = (const uint8_t*)filenames[i];                 p += write_lfh(p, &amp;lfh);                 p += lfh.comp_size;         }          assert(p - dst &lt;= UINT32_MAX);         cd_offset = (uint32_t)(p - dst);          \/* Write the Central Directory based on the Local File Headers. *\/         lfh_offset = 0;         for (i = 0; i &lt; num_memb; i++) {                 ok = read_lfh(&amp;lfh, dst, SIZE_MAX, lfh_offset);                 assert(ok);                  cfh.made_by_ver = lfh.extract_ver;                 cfh.extract_ver = lfh.extract_ver;                 cfh.gp_flag = lfh.gp_flag;                 cfh.method = lfh.method;                 cfh.mod_time = lfh.mod_time;                 cfh.mod_date = lfh.mod_date;                 cfh.crc32 = lfh.crc32;                 cfh.comp_size = lfh.comp_size;                 cfh.uncomp_size = lfh.uncomp_size;                 cfh.name_len = lfh.name_len;                 cfh.extra_len = 0;                 cfh.comment_len = 0;                 cfh.disk_nbr_start = 0;                 cfh.int_attrs = 0;                 cfh.ext_attrs = EXT_ATTR_ARC;                 cfh.lfh_offset = lfh_offset;                 cfh.name = lfh.name;                 p += write_cfh(p, &amp;cfh);                  lfh_offset += LFH_BASE_SZ + lfh.name_len + lfh.comp_size;         }          assert(p - dst &lt;= UINT32_MAX);         eocdr_offset = (uint32_t)(p - dst);          \/* Write the End of Central Directory Record. *\/         eocdr.disk_nbr = 0;         eocdr.cd_start_disk = 0;         eocdr.disk_cd_entries = num_memb;         eocdr.cd_entries = num_memb;         eocdr.cd_size = eocdr_offset - cd_offset;         eocdr.cd_offset = cd_offset;         eocdr.comment_len = (uint16_t)(comment == NULL ? 0 : strlen(comment));         eocdr.comment = (const uint8_t*)comment;         p += write_eocdr(p, &amp;eocdr);          assert(p - dst &lt;= zip_max_size(num_memb, filenames, file_sizes,                                        comment));          return (uint32_t)(p - dst); } <\/code><\/pre>\n<p>  <a name=\"25\"><\/a><\/p>\n<h2>HWZip<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c Zip-\u0444\u0430\u0439\u043b\u044b, \u043a\u0430\u043a \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e Zip-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u0432\u0441\u0435 \u044d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b. \u041a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/hwzip.c\">hwzip.c<\/a>.<\/p>\n<p>  \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438:<\/p>\n<pre><code class=\"cpp\">#define PERROR_IF(cond, msg) if (cond) { perror(msg); exit(1); }  static void *xmalloc(size_t size) {         void *ptr = malloc(size);         PERROR_IF(ptr == NULL, &quot;malloc&quot;);         return ptr; }  static void *xrealloc(void *ptr, size_t size) {         ptr = realloc(ptr, size);         PERROR_IF(ptr == NULL, &quot;realloc&quot;);         return ptr; } <\/code><\/pre>\n<p>  \u0414\u0440\u0443\u0433\u0438\u0435 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">static uint8_t *read_file(const char *filename, size_t *file_sz) {         FILE *f;         uint8_t *buf;         size_t buf_cap;          f = fopen(filename, &quot;rb&quot;);         PERROR_IF(f == NULL, &quot;fopen&quot;);          buf_cap = 4096;         buf = xmalloc(buf_cap);          *file_sz = 0;         while (feof(f) == 0) {                 if (buf_cap - *file_sz == 0) {                         buf_cap *= 2;                         buf = xrealloc(buf, buf_cap);                 }                  *file_sz += fread(&amp;buf[*file_sz], 1, buf_cap - *file_sz, f);                 PERROR_IF(ferror(f), &quot;fread&quot;);         }          PERROR_IF(fclose(f) != 0, &quot;fclose&quot;);         return buf; }  static void write_file(const char *filename, const uint8_t *data, size_t n) {         FILE *f;          f = fopen(filename, &quot;wb&quot;);         PERROR_IF(f == NULL, &quot;fopen&quot;);         PERROR_IF(fwrite(data, 1, n, f) != n, &quot;fwrite&quot;);         PERROR_IF(fclose(f) != 0, &quot;fclose&quot;); } <\/code><\/pre>\n<p>  \u041d\u0430\u0448\u0430 Zip-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438: \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e Zip-\u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0435\u0433\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c Zip-\u0444\u0430\u0439\u043b\u044b. \u0421\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u0440\u043e\u0449\u0435 \u043d\u0435\u043a\u0443\u0434\u0430:<\/p>\n<pre><code class=\"cpp\">static void list_zip(const char *filename) {         uint8_t *zip_data;         size_t zip_sz;         zip_t z;         zipiter_t it;         zipmemb_t m;          printf(&quot;Listing ZIP archive: %s\\n\\n&quot;, filename);          zip_data = read_file(filename, &amp;zip_sz);          if (!zip_read(&amp;z, zip_data, zip_sz)) {                 printf(&quot;Failed to parse ZIP file!\\n&quot;);                 exit(1);         }          if (z.comment_len != 0) {                 printf(&quot;%.*s\\n\\n&quot;, (int)z.comment_len, z.comment);         }          for (it = z.members_begin; it != z.members_end; it = m.next) {                 m = zip_member(&amp;z, it);                 printf(&quot;%.*s\\n&quot;, (int)m.name_len, m.name);         }          printf(&quot;\\n&quot;);          free(zip_data); } <\/code><\/pre>\n<p>  \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u0443\u043b\u044c-\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430 (\u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 <code>fopen<\/code>) \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438:<\/p>\n<pre><code class=\"cpp\">static char *terminate_str(const char *str, size_t n) {         char *p = xmalloc(n + 1);         memcpy(p, str, n);         p[n] = '\\0';         return p; }  static uint8_t *inflate_member(const zipmemb_t *m) {         uint8_t *p;         size_t src_used, dst_used;          assert(m-&gt;method == ZIP_DEFLATED);          p = xmalloc(m-&gt;uncomp_size);          if (hwinflate(m-&gt;comp_data, m-&gt;comp_size, &amp;src_used, p, m-&gt;uncomp_size,                       &amp;dst_used) != HWINF_OK) {                 free(p);                 return NULL;         }          if (src_used != m-&gt;comp_size || dst_used != m-&gt;uncomp_size) {                 free(p);                 return NULL;         }          return p; } <\/code><\/pre>\n<p>  \u041d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0430\u0440\u0445\u0438\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 <a href=\"https:\/\/www.owasp.org\/index.php\/Path_Traversal\">path traversal-\u0430\u0442\u0430\u043a<\/a>: \u0437\u043b\u043e\u0432\u0440\u0435\u0434\u043d\u044b\u0439 \u0430\u0440\u0445\u0438\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0444\u0430\u0439\u043b\u0430 \u0438\u0437\u0432\u043d\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0432 <a href=\"http:\/\/infozip.sourceforge.net\/FAQ.html#corruption\">Info-ZIP FAQ<\/a>.<\/p>\n<pre><code class=\"cpp\">static void extract_zip(const char *filename) {         uint8_t *zip_data;         size_t zip_sz;         zip_t z;         zipiter_t it;         zipmemb_t m;         char *tname;         uint8_t *inflated;         const uint8_t *uncomp_data;          printf(&quot;Extracting ZIP archive: %s\\n\\n&quot;, filename);          zip_data = read_file(filename, &amp;zip_sz);          if (!zip_read(&amp;z, zip_data, zip_sz)) {                 printf(&quot;Failed to read ZIP file!\\n&quot;);                 exit(1);         }          if (z.comment_len != 0) {                 printf(&quot;%.*s\\n\\n&quot;, (int)z.comment_len, z.comment);         }          for (it = z.members_begin; it != z.members_end; it = m.next) {                 m = zip_member(&amp;z, it);                  if (m.is_dir) {                         printf(&quot; (Skipping dir: %.*s)\\n&quot;,                                (int)m.name_len, m.name);                         continue;                 }                  if (memchr(m.name, '\/',  m.name_len) != NULL ||                     memchr(m.name, '\\\\', m.name_len) != NULL) {                         printf(&quot; (Skipping file in dir: %.*s)\\n&quot;,                                (int)m.name_len, m.name);                         continue;                 }                  assert(m.method == ZIP_STORED || m.method == ZIP_DEFLATED);                 printf(&quot; %s: %.*s&quot;,                        m.method == ZIP_STORED ? &quot;Extracting&quot; : &quot; Inflating&quot;,                        (int)m.name_len, m.name);                 fflush(stdout);                  if (m.method == ZIP_STORED) {                         assert(m.uncomp_size == m.comp_size);                         inflated = NULL;                         uncomp_data = m.comp_data;                 } else {                         inflated = inflate_member(&amp;m);                         if (inflated == NULL) {                                 printf(&quot;Error: inflation failed!\\n&quot;);                                 exit(1);                         }                         uncomp_data = inflated;                 }                  if (crc32(uncomp_data, m.uncomp_size) != m.crc32) {                         printf(&quot;Error: CRC-32 mismatch!\\n&quot;);                         exit(1);                 }                  tname = terminate_str((const char*)m.name, m.name_len);                 write_file(tname, uncomp_data, m.uncomp_size);                 printf(&quot;\\n&quot;);                  free(inflated);                 free(tname);         }          printf(&quot;\\n&quot;);         free(zip_data); } <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c Zip-\u0430\u0440\u0445\u0438\u0432, \u043c\u044b \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u0441\u043a\u043e\u0440\u043c\u0438\u043c \u0438\u0445 <code>zip_write<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 C \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430, \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c (\u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f).<\/p>\n<pre><code class=\"cpp\">void zip_callback(const char *filename, uint32_t size, uint32_t comp_size) {         bool deflated = comp_size &lt; size;          printf(&quot; %s: %s&quot;, deflated ? &quot;Deflated&quot; : &quot;  Stored&quot;, filename);         if (deflated) {                 printf(&quot; (%u%%)&quot;, 100 - 100 * comp_size \/ size);         }         printf(&quot;\\n&quot;); }  static void create_zip(const char *zip_filename, const char *comment,                        uint16_t n, const char *const *filenames) {         time_t mtime;         time_t *mtimes;         uint8_t **file_data;         uint32_t *file_sizes;         size_t file_size, zip_size;         uint8_t *zip_data;         uint16_t i;          printf(&quot;Creating ZIP archive: %s\\n\\n&quot;, zip_filename);          if (comment != NULL) {                 printf(&quot;%s\\n\\n&quot;, comment);         }          mtime = time(NULL);          file_data = xmalloc(sizeof(*file_data) * n);         file_sizes = xmalloc(sizeof(*file_sizes) * n);         mtimes = xmalloc(sizeof(*mtimes) * n);          for (i = 0; i &lt; n; i++) {                 file_data[i] = read_file(filenames[i], &amp;file_size);                 if (file_size &gt;= UINT32_MAX) {                         printf(&quot;%s is too large!\\n&quot;, filenames[i]);                         exit(1);                 }                 file_sizes[i] = (uint32_t)file_size;                 mtimes[i] = mtime;         }          zip_size = zip_max_size(n, filenames, file_sizes, comment);         if (zip_size == 0) {                 printf(&quot;zip writing not possible&quot;);                 exit(1);         }          zip_data = xmalloc(zip_size);         zip_size = zip_write(zip_data, n, filenames,                              (const uint8_t *const *)file_data,                              file_sizes, mtimes, comment, zip_callback);          write_file(zip_filename, zip_data, zip_size);         printf(&quot;\\n&quot;);          free(zip_data);         for (i = 0; i &lt; n; i++) {                 free(file_data[i]);         }         free(mtimes);         free(file_sizes);         free(file_data); } <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, <code>main<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<pre><code class=\"cpp\">static void print_usage(const char *argv0) {         printf(&quot;Usage:\\n\\n&quot;);         printf(&quot;  %s list &lt;zipfile&gt;\\n&quot;, argv0);         printf(&quot;  %s extract &lt;zipfile&gt;\\n&quot;, argv0);         printf(&quot;  %s create &lt;zipfile&gt; [-c &lt;comment&gt;] &lt;files...&gt;\\n&quot;, argv0);         printf(&quot;\\n&quot;); }  int main(int argc, char **argv) {         printf(&quot;\\n&quot;);         printf(&quot;HWZIP &quot; VERSION &quot; -- A very simple ZIP program &quot;);         printf(&quot;from https:\/\/www.hanshq.net\/zip.html\\n&quot;);         printf(&quot;\\n&quot;);          if (argc == 3 &amp;&amp; strcmp(argv[1], &quot;list&quot;) == 0) {                 list_zip(argv[2]);         } else if (argc == 3 &amp;&amp; strcmp(argv[1], &quot;extract&quot;) == 0) {                 extract_zip(argv[2]);         } else if (argc &gt;= 3 &amp;&amp; strcmp(argv[1], &quot;create&quot;) == 0) {                 if (argc &gt;= 5 &amp;&amp; strcmp(argv[3], &quot;-c&quot;) == 0) {                         create_zip(argv[2], argv[4], (uint16_t)(argc - 5),                                    (const char *const *)&amp;argv[5]);                 } else {                         create_zip(argv[2], NULL, (uint16_t)(argc - 3),                                    (const char *const *)&amp;argv[3]);                 }         } else {                 print_usage(argv[0]);                 return 1;         }          return 0; } <\/code><\/pre>\n<p>  <a name=\"26\"><\/a><\/p>\n<h3>\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435<\/h3>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/hwzip-1.0.zip\">hwzip-1.0.zip<\/a>. \u041a\u0430\u043a \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c HWZip \u043f\u043e\u0434 Linux \u0438\u043b\u0438 Mac:<\/p>\n<pre><code class=\"cpp\">$ clang generate_tables.c &amp;&amp; .\/a.out &gt; tables.c $ clang -O3 -DNDEBUG -march=native -o hwzip crc32.c deflate.c huffman.c \\         hwzip.c lz77.c tables.c zip.c <\/code><\/pre>\n<p>  \u041f\u043e\u0434 Windows, \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0432 Visual Studio (\u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 Visual Studio, \u0441\u043a\u0430\u0447\u0430\u0439\u0442\u0435 <a href=\"https:\/\/aka.ms\/buildtools\">\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438<\/a>):<\/p>\n<pre><code class=\"cpp\">cl \/TC generate_tables.c &amp;&amp; generate_tables &gt; tables.c cl \/O2 \/DNDEBUG \/MT \/Fehwzip.exe \/TC crc32.c deflate.c huffman.c hwzip.c         lz77.c tables.c zip.c \/link setargv.obj <\/code><\/pre>\n<p>  Setargv.obj \u0434\u043b\u044f <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/c-language\/expanding-wildcard-arguments\">\u0440\u0430\u0441\u0448\u0438\u0440\u044f\u044e\u0449\u0438\u0445 wildcard-\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438<\/a>.)<\/p>\n<p>  <a name=\"27\"><\/a><\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0423\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043a\u0430\u043a \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f. \u0424\u043e\u0440\u043c\u0430\u0442 Zip \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d 30 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u043f\u044f\u0442\u0438\u0434\u0435\u0441\u044f\u0442\u044b\u0445 \u0438 \u0441\u0435\u043c\u0438\u0434\u0435\u0441\u044f\u0442\u044b\u0445 \u0433\u043e\u0434\u043e\u0432. \u0418 \u0445\u043e\u0442\u044f \u0441 \u0442\u0435\u0445 \u043f\u043e\u0440 \u043c\u043d\u043e\u0433\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, Zip-\u0444\u0430\u0439\u043b\u044b, \u043f\u043e \u0441\u0443\u0442\u0438, \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0442\u0435\u043c\u0438 \u0436\u0435 \u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u044b, \u0447\u0435\u043c \u043a\u043e\u0433\u0434\u0430-\u043b\u0438\u0431\u043e. \u0414\u0443\u043c\u0430\u044e, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442.<\/p>\n<p>  <a name=\"28\"><\/a><\/p>\n<h2>\u0423\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<ul>\n<li>\u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b HWZip \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u0432\u0440\u0435\u043c\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0430 \u043d\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u0440\u0445\u0438\u0432\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <a href=\"https:\/\/linux.die.net\/man\/2\/stat\">stat(2)<\/a> \u043d\u0430 Linux \u0438\u043b\u0438 Mac \u0438 <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-getfiletime\">GetFileTime<\/a> \u043d\u0430 Windows. \u0418\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0444\u043b\u0430\u0433 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432.<\/li>\n<li>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0434\u0430 \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 gzip-\u0444\u0430\u0439\u043b\u043e\u0432. \u042d\u0442\u043e\u0442 \u0444\u043e\u0440\u043c\u0430\u0442 \u2014 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u0436\u0430\u0442\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Deflate (\u043e\u0431\u044b\u0447\u043d\u043e \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b). \u041e\u043d \u043e\u043f\u0438\u0441\u0430\u043d \u0432 <a href=\"https:\/\/tools.ietf.org\/html\/rfc1952\">RFC 1952<\/a>.<\/li>\n<li>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 Zip-\u0444\u0430\u0439\u043b\u043e\u0432 \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Memory-mapped_file\">\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438<\/a>. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 HWZip \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u043c\u0435\u0441\u0442\u043e <code>read_file<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/linux.die.net\/man\/2\/mmap\">mmap(2)<\/a> \u043f\u043e\u0434 Linux \u0438\u043b\u0438 Mac \u0438 <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/memory\/creating-a-file-mapping-object\">CreateFileMapping<\/a> \u043f\u043e\u0434 Windows.<\/li>\n<li>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 HWZip \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0440\u0445\u0438\u0432\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Zip64. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0438\u0449\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/pkware.cachefly.net\/webdocs\/APPNOTE\/APPNOTE-6.3.6.TXT\">\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c appnote.txt<\/a>.<\/li>\n<\/ul>\n<p>  <a name=\"29\"><\/a><\/p>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b<\/h2>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e BBS-\u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 <a href=\"http:\/\/www.bbsdocumentary.com\/\">BBS: The Documentary<\/a>. \u0412\u0438\u0434\u0435\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/www.youtube.com\/playlist?list=PLgE-9Sxs2IBVgJkY-1ZMj0tIFxsJ-vOkv\">\u043d\u0430 YouTube<\/a>. \u0412 <a href=\"https:\/\/www.youtube.com\/watch?v=MLNXmrF3a9c\">Part 8: Compression<\/a> \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 SEA \u0438 PKWare. \u041d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0435\u0441\u0442\u044c <a href=\"http:\/\/www.bbsdocumentary.com\/library\/CONTROVERSY\/LAWSUITS\/SEA\/\">\u0430\u0440\u0445\u0438\u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432<\/a>.<\/li>\n<li>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/www.bamsoftware.com\/hacks\/zipbomb\/\">A better Zip bomb<\/a> \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Zip-\u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0435 \u00ab\u0432\u0437\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00bb \u0432 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u043e\u0431\u044a\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<li>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/research.swtch.com\/zip\">Zip Files All The Way Down<\/a> \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c <i>Zip-\u043a\u0432\u0430\u0439\u043d<\/i> \u2014 \u0444\u0430\u0439\u043b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043a\u043e\u043f\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0431\u044f.<\/li>\n<li><a href=\"https:\/\/github.com\/molnarg\/ascii-zip\">ascii-zip<\/a> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0430\u044f Deflate-\u043f\u043e\u0442\u043e\u043a \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432 ASCII-\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0435. \u041e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0432 \u044d\u043a\u0441\u043f\u043b\u043e\u0439\u0442\u0435 <a href=\"https:\/\/blog.miki.it\/2014\/7\/8\/abusing-jsonp-with-rosetta-flash\/\">Rosetta Flash<\/a>.<\/li>\n<li><a href=\"https:\/\/gynvael.coldwind.pl\/?id=682\">Ten Thousand Security Pitfalls: the Zip File Format<\/a> \u2014 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430\u044f \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/li>\n<li><a href=\"https:\/\/fgiesen.wordpress.com\/2018\/02\/19\/reading-bits-in-far-too-many-ways-part-1\/\">Reading bits in far too many ways part 1<\/a>, <a href=\"https:\/\/fgiesen.wordpress.com\/2018\/02\/20\/reading-bits-in-far-too-many-ways-part-2\/\">part 2<\/a> \u0438 <a href=\"https:\/\/fgiesen.wordpress.com\/2018\/09\/27\/reading-bits-in-far-too-many-ways-part-3\/\">part 3<\/a> \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/li>\n<li>\u0421\u0442\u0430\u0442\u044c\u044f <a href=\"http:\/\/shop.oreilly.com\/product\/0636920052036.do\">Understanding Compression<\/a> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u0432 \u0442\u0435\u043c\u0443 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<\/ul>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/mailru\/blog\/490790\/\"> https:\/\/habr.com\/ru\/company\/mailru\/blog\/490790\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/mailru\/blog\/490790\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bo\/tw\/dr\/botwdrbtegpbnpnwmy7id56fbaa.jpeg\"><\/div>\n<p>  \u041c\u043d\u0435 \u0434\u0430\u0432\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u0441\u0436\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 Zip-\u0444\u0430\u0439\u043b\u0430\u0445. \u041e\u0434\u043d\u0430\u0436\u0434\u044b \u044f \u0440\u0435\u0448\u0438\u043b \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u0441\u0442\u0432\u043e: \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0436\u0430\u0442\u0438\u0435, \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e Zip-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c \u0432 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435 \u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u043b\u0430\u0436\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0435\u0440\u0451\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0431\u0438\u0442\u044b \u0432 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<p>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 Zip-\u0444\u0430\u0439\u043b\u044b \u0438 \u0441\u0445\u0435\u043c\u0430 \u0441\u0436\u0430\u0442\u0438\u044f: LZ77-\u0441\u0436\u0430\u0442\u0438\u0435, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c Deflate \u0438 \u043f\u0440\u043e\u0447\u0435\u0435. \u0412\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 \u0421. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043b\u0435\u0436\u0438\u0442 \u0442\u0443\u0442: <a href=\"https:\/\/www.hanshq.net\/files\/hwzip\/hwzip-1.0.zip\">hwzip-1.0.zip<\/a>.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-299618","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299618"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299618\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}