From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aHUzw-0003Kb-5Y for barebox@lists.infradead.ORg; Fri, 08 Jan 2016 11:14:55 +0000 From: Sascha Hauer Date: Fri, 8 Jan 2016 12:13:53 +0100 Message-Id: <1452251635-14689-7-git-send-email-s.hauer@pengutronix.de> In-Reply-To: <1452251635-14689-1-git-send-email-s.hauer@pengutronix.de> References: <1452251635-14689-1-git-send-email-s.hauer@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 6/8] host side for barebox remote control To: Barebox List Cc: =?UTF-8?q?Jan=20L=C3=BCbbe?= RnJvbTogSmFuIEx1ZWJiZSA8amx1QHBlbmd1dHJvbml4LmRlPgoKVGhpcyBjb250YWlucyB0aGUg aG9zdCB0b29sIGZvciBiYXJlYm94IHJlbW90ZSBjb250cm9sLiBJdCBpcyB3cml0dGVuIGluClBo eXRob24gd2l0aCBpdHMgb3duIGltcGxlbWVudGF0aW9uIG9mIHRoZSBSQVRQIHByb3RvY29sLiBD dXJyZW50bHkgdGhpcwppcyBhIHZlcnkgc2ltcGxlIHRvb2wgd2hpY2ggbmVlZHMgbW9yZSB3b3Jr LCBidXQgdGhlIGNvZGUgY2FuIGFsc28gYmUKdXNlZCBhcyBhIGxpYnJhcnkuCgpFeGFtcGxlIG91 dHB1dDoKCmNvbnNvbGU6ICcuICAgICAgJwpjb25zb2xlOiAnLi4gICAgICcKY29uc29sZTogJ2Rl diAgICAnCmNvbnNvbGU6ICdlbnYgICAgJwpjb25zb2xlOiAnbW50ICAgICcKY29uc29sZTogJ1xu JwpSZXN1bH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IoKQorCisgICAgZGVmIF9zZW5kKHNlbGYsIGJicGt0 KToKKyAgICAgICAgc2VsZi5jb25uLnNlbmQoYmJwa3QucGFjaygpKQorCisgICAgZGVmIF9oYW5k bGUoc2VsZiwgYmJwa3QpOgorICAgICAgICBpZiBpc2luc3RhbmNlKGJicGt0LCBCQlBhY2tldENv bnNvbGVNc2cpOgorICAgICAgICAgICAgb3Mud3JpdGUoc3lzLnN0ZG91dC5maWxlbm8oKSwgYmJw a3QudGV4dCkKKyAgICAgICAgZWxpZiBpc2luc3RhbmNlKGJicGt0LCBCQlBhY2tldFBvbmcpOgor ICAgICAgICAgICAgcHJpbnQoInBvbmciLCkKKyAgICAgICAgZWxpZiBpc2luc3RhbmNlKGJicGt0 LCBCQlBhY2tldEZTKToKKyAgICAgICAgICAgIGlmIHNlbGYuZnNzZXJ2ZXIgIT0gTm9uZToKKyAg ICAgICAgICAgICAgICBzZWxmLl9zZW5kKHNlbGYuZnNzZXJ2ZXIuaGFuZGxlKGJicGt0KSkKKwor ICAgIGRlZiBfZXhwZWN0KHNlbGYsIGJidHlwZSwgdGltZW91dD0xLjApOgorICAgICAgICBpZiB0 aW1lb3V0IGlzIG5vdCBOb25lOgorICAgICAgICAgICAgbGltaXQgPSBtb25vdG9uaWMoKSt0aW1l b3V0CisgICAgICAgIHdoaWxlIHRpbWVvdXQgaXMgTm9uZSBvciBsaW1pdCA+IG1vbm90b25pYygp OgorICAgICAgICAgICAgcGt0ID0gc2VsZi5jb25uLnJlY3YoMC4xKQorICAgICAgICAgICAgaWYg bm90IHBrdDoKKyAgICAgICAgICAgICAgICBjb250aW51ZQorICAgICAgICAgICAgYmJwa3QgPSB1 bnBhY2socGt0KQorICAgICAgICAgICAgaWYgaXNpbnN0YW5jZShiYnBrdCwgYmJ0eXBlKToKKyAg ICAgICAgICAgICAgICByZXR1cm4gYmJwa3QKKyAgICAgICAgICAgIGVsc2U6CisgICAgICAgICAg ICAgICAgc2VsZi5faGFuZGxlKGJicGt0KQorCisgICAgZGVmIGV4cG9ydChzZWxmLCBwYXRoKToK KyAgICAgICAgc2VsZi5mc3NlcnZlciA9IFJhdHBGU1NlcnZlcihwYXRoKQorCisgICAgZGVmIHBp bmcoc2VsZik6CisgICAgICAgIHNlbGYuX3NlbmQoQkJQYWNrZXRQaW5nKCkpCisgICAgICAgIHIg PSBzZWxmLl9leHBlY3QoQkJQYWNrZXRQb25nKQorICAgICAgICBsb2dnaW5nLmluZm8oIlBpbmc6 ICVyIiwgcikKKyAgICAgICAgaWYgbm90IHI6CisgICAgICAgICAgICByZXR1cm4gMQorICAgICAg ICBlbHNlOgorICAgICAgICAgICAgcHJpbnQoInBvbmciKQorICAgICAgICAgICAgcmV0dXJuIDAK KworICAgIGRlZiBjb21tYW5kKHNlbGYsIGNtZCk6CisgICAgICAgIHNlbGYuX3NlbmQoQkJQYWNr ZXRDb21tYW5kKGNtZD1jbWQpKQorICAgICAgICByID0gc2VsZi5fZXhwZWN0KEJCUGFja2V0Q29t bWFuZFJldHVybiwgdGltZW91dD1Ob25lKQorICAgICAgICBsb2dnaW5nLmluZm8oIkNvbW1hbmQ6 ICVyIiwgcikKKyAgICAgICAgcmV0dXJuIHIuZXhpdF9jb2RlCisKKyAgICBkZWYgZ2V0ZW52KHNl bGYsIHZhcm5hbWUpOgorICAgICAgICBzZWxmLl9zZW5kKEJCUGFja2V0R2V0ZW52KHZhcm5hbWU9 dmFybmFtZSkpCisgICAgICAgIHIgPSBzZWxmLl9leHBlY3QoQkJQYWNrZXRHZXRlbnZSZXR1cm4p CisgICAgICAgIHJldHVybiByLnRleHQKKworICAgIGRlZiBjbG9zZShzZWxmKToKKyAgICAgICAg c2VsZi5jb25uLmNsb3NlKCkKKworICAgIGRlZiBydW4oc2VsZik6CisgICAgICAgIGFzc2VydCBz ZWxmLnJ4cSBpcyBub3QgTm9uZQorICAgICAgICB0cnk6CisgICAgICAgICAgICB3aGlsZSBub3Qg c2VsZi5fc3RvcDoKKyAgICAgICAgICAgICAgICAjIHJlY2VpdmUKKyAgICAgICAgICAgICAgICBw a3QgPSBzZWxmLmNvbm4ucmVjdigpCisgICAgICAgICAgICAgICAgaWYgcGt0OgorICAgICAgICAg ICAgICAgICAgICBiYnBrdCA9IHVucGFjayhwa3QpCisgICAgICAgICAgICAgICAgICAgIGlmIGlz aW5zdGFuY2UoYmJwa3QsIEJCUGFja2V0Q29uc29sZU1zZyk6CisgICAgICAgICAgICAgICAgICAg ICAgICBzZWxmLnJ4cS5wdXQoKHNlbGYsIGJicGt0LnRleHQpKQorICAgICAgICAgICAgICAgICAg ICBlbHNlOgorICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5faGFuZGxlKGJicGt0KQorICAg ICAgICAgICAgICAgICMgc2VuZAorICAgICAgICAgICAgICAgIHRyeToKKyAgICAgICAgICAgICAg ICAgICAgcGt0ID0gc2VsZi5fdHhxLmdldChibG9jaz1GYWxzZSkKKyAgICAgICAgICAgICAgICBl eGNlcHQgRW1wdHk6CisgICAgICAgICAgICAgICAgICAgIHBrdCA9IE5vbmUKKyAgICAgICAgICAg ICAgICBpZiBwa3Q6CisgICAgICAgICAgICAgICAgICAgIHNlbGYuX3NlbmQocGt0KQorICAgICAg ICBleGNlcHQgUmF0cEVycm9yIGFzIGRldGFpbDoKKyAgICAgICAgICAgIHByaW50KCJSYXRwIGVy cm9yOiIsIGRldGFpbCwgZmlsZT1zeXMuc3RkZXJyKTsKKyAgICAgICAgICAgIHNlbGYucnhxLnB1 dCgoc2VsZiwgTm9uZSkpCisgICAgICAgICAgICByZXR1cm4KKworICAgIGRlZiBzdGFydChzZWxm LCBxdWV1ZSk6CisgICAgICAgIGFzc2VydCBzZWxmLnJ4cSBpcyBOb25lCisgICAgICAgIHNlbGYu cnhxID0gcXVldWUKKyAgICAgICAgVGhyZWFkLnN0YXJ0KHNlbGYpCisKKyAgICBkZWYgc3RvcChz ZWxmKToKKyAgICAgICAgc2VsZi5fc3RvcCA9IFRydWUKKyAgICAgICAgc2VsZi5qb2luK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gICAgICBi cmVhaworICAgICAgICBleGNlcHQgKFJhdHBFcnJvcik6CisgICAgICAgICAgICBpZiBhcmdzLndh aXQgPT0gVHJ1ZToKKyAgICAgICAgICAgICAgICBwYXNzCisgICAgICAgICAgICBlbHNlOgorICAg ICAgICAgICAgICAgIHJhaXNlCisKKyAgICByZXR1cm4gY3RybAorCisKK2RlZiBoYW5kbGVfcnVu KGFyZ3MpOgorICAgIGN0cmwgPSBnZXRfY29udHJvbGxlcihhcmdzKQorICAgIGN0cmwuZXhwb3J0 KGFyZ3MuZXhwb3J0KQorICAgIHJlcyA9IGN0cmwuY29tbWFuZCgnICcuam9pbihhcmdzLmFyZykp CisgICAgaWYgcmVzOgorICAgICAgICByZXMgPSAxCisgICAgY3RybC5jbG9zZSgpCisgICAgcmV0 dXJuIHJlcworCisKK2RlZiBoYW5kbGVfcGluZyhhcmdzKToKKyAgICBjdHJsID0gZ2V0X2NvbnRy b2xsZXIoYXJncykKKyAgICByZXMgPSBjdHJsLnBpbmcoKQorICAgIGlmIHJlczoKKyAgICAgICAg cmVzID0gMQorICAgIGN0cmwuY2xvc2UoKQorICAgIHJldHVybiByZXMKKworCitkZWYgaGFuZGxl X2dldGVudihhcmdzKToKKyAgICBjdHJsID0gZ2V0X2NvbnRyb2xsZXIoYXJncykKKyAgICB2YWx1 ZSA9IGN0cmwuZ2V0ZW52KCcgJy5qb2luKGFyZ3MuYXJnKSkKKyAgICBpZiBub3QgdmFsdWU6Cisg ICAgICAgIHJlcyA9IDEKKyAgICBlbHNlOgorICAgICAgICBwcmludCh2YWx1ZSkKKyAgICAgICAg cmVzID0gMAorICAgIGN0cmwuY2xvc2UoKQorICAgIHJldHVybiByZXMKKworCitkZWYgaGFuZGxl X2xpc3RlbihhcmdzKToKKyAgICBwb3J0ID0gc2VyaWFsLnNlcmlhbF9mb3JfdXJsKGFyZ3MucG9y dCwgYXJncy5iYXVkcmF0ZSkKKyAgICBjb25uID0gU2VyaWFsUmF0cENvbm5lY3Rpb24ocG9ydCkK KyAgICBjb25uLmxpc3RlbigpCisgICAgd2hpbGUgVHJ1ZToKKyAgICAgICAgY29ubi53YWl0KE5v bmUpCisgICAgY29ubi5jbG9zZSgpCisKKworZGVmIGhhbmRsZV9jb25zb2xlKGFyZ3MpOgorICAg IHF1ZXVlID0gUXVldWUoKQorICAgIGN0cmwgPSBnZXRfY29udHJvbGxlcihhcmdzKQorICAgIGN0 cmwuZXhwb3J0KGFyZ3MuZXhwb3J0KQorICAgIGN0cmwuc3RhcnQocXVldWUpCisgICAgY3RybC5z ZW5kX2FzeW5jX2NvbnNvbGUoJ1xyJykKKyAgICBjb25zID0gQ29uc29sZUlucHV0KHF1ZXVlLCBl eGl0PSdceDE0JykgICMgQ1RSTC1UCisgICAgY29ucy5zdGFydCgpCisgICAgdHJ5OgorICAgICAg ICB3aGlsZSBUcnVlOgorICAgICAgICAgICAgZXZlbnQgPSBxdWV1ZS5nZXQoYmxvY2s9VHJ1ZSkK KyAgICAgICAgICAgIHNyYywgZGF0YSA9IGV2ZW50CisgICAgICAgICAgICBpZiBzcmMgPT0gY29u czoKKyAgICAgICAgICAgICAgICBpZiBkYXRhIGlzIE5vbmU6ICAjIHNodXRkb3duCisgICAgICAg ICAgICAgICAgICAgIGNvbnMuam9pbigpCisgICAgICAgICAgICAgICAgICAgIGJyZWFrCisgICAg ICAgICAgICAgICAgZWxpZiBkYXRhID09ICdceDEwJzogICMgQ1RSTC1QCisgICAgICAgICAgICAg ICAgICAgIGN0cmwuc2VuZF9hc3luY19waW5nKCkKKyAgICAgICAgICAgICAgICBlbHNlOgorICAg ICAgICAgICAgICAgICAgICBjdHJsLnNlbmRfYXN5bmNfY29uc29sZShkYXRhKQorICAgICAgICAg ICAgZWxpZiBzcmMgPT0gY3RybDoKKyAgICAgICAgICAgICAgICBpZiBkYXRhIGlzIE5vbmU6ICAj IHNodXRkb3duCisgICAgICAgICAgICAgICAgICAgIHN5cy5leGl0KDEpCisgICAgICAgICAgICAg ICAgICAgIGJy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F9fZnV0dXJlX18gaW1wb3J0IGFic29sdXRlX2lt cG9ydCwgZGl2aXNpb24sIHByaW50X2Z1bmN0aW9uCisKK2ltcG9ydCBzdHJ1Y3QKKworCitjbGFz cyBCQlR5cGUob2JqZWN0KToKKyAgICBjb21tYW5kID0gMQorICAgIGNvbW1hbmRfcmV0dXJuID0g MgorICAgIGNvbnNvbGVtc2cgPSAzCisgICAgcGluZyA9IDQKKyAgICBwb25nID0gNQorICAgIGdl dGVudiA9IDYKKyAgICBnZXRlbnZfcmV0dXJuID0gNworICAgIGZzID0gOAorICAgIGZzX3JldHVy biA9IDkKKworCitjbGFzcyBCQlBhY2tldChvYmplY3QpOgorICAgIGRlZiBfX2luaXRfXyhzZWxm LCBwX3R5cGU9MCwgcF9mbGFncz0wLCBwYXlsb2FkPSIiLCByYXc9Tm9uZSk6CisgICAgICAgIHNl bGYucF90eXBlID0gcF90eXBlCisgICAgICAgIHNlbGYucF9mbGFncyA9IHBfZmxhZ3MKKyAgICAg ICAgaWYgcmF3IGlzIG5vdCBOb25lOgorICAgICAgICAgICAgc2VsZi51bnBhY2socmF3KQorICAg ICAgICBlbHNlOgorICAgICAgICAgICAgc2VsZi5wYXlsb2FkID0gcGF5bG9hZAorCisgICAgZGVm IF9fcmVwcl9fKHNlbGYpOgorICAgICAgICByZXR1cm4gIkJCUGFja2V0KCVpLCAlaSkiICUgKHNl bGYucF90eXBlLCBzZWxmLnBfZmxhZ3MpCisKKyAgICBkZWYgX3VucGFja19wYXlsb2FkKHNlbGYs IGRhdGEpOgorICAgICAgICBzZWxmLnBheWxvYWQgPSBkYXRhCisKKyAgICBkZWYgX3BhY2tfcGF5 bG9hZChzZWxmKToKKyAgICAgICAgcmV0dXJuIHNlbGYucGF5bG9hZAorCisgICAgZGVmIHVucGFj ayhzZWxmLCBkYXRhKToKKyAgICAgICAgc2VsZi5wX3R5cGUsIHNlbGYucF9mbGFncyA9IHN0cnVj dC51bnBhY2soIiFISCIsIGRhdGFbOjRdKQorICAgICAgICBzZWxmLl91bnBhY2tfcGF5bG9hZChk YXRhWzQ6XSkKKworICAgIGRlZiBwYWNrKHNlbGYpOgorICAgICAgICByZXR1cm4gc3RydWN0LnBh Y2soIiFISCIsIHNlbGYucF90eXBlLCBzZWxmLnBfZmxhZ3MpICsgXAorICAgICAgICAgICAgc2Vs Zi5fcGFja19wYXlsb2FkKCkKKworCitjbGFzcyBCQlBhY2tldENvbW1hbmQoQkJQYWNrZXQpOgor ICAgIGRlZiBfX2luaXRfXyhzZWxmLCByYXc9Tm9uZSwgY21kPU5vbmUpOgorICAgICAgICBzZWxm LmNtZCA9IGNtZAorICAgICAgICBzdXBlcihCQlBhY2tldENvbW1hbmQsIHNlbGYpLl9faW5pdF9f KEJCVHlwZS5jb21tYW5kLCByYXc9cmF3KQorCisgICAgZGVmIF9fcmVwcl9fKHNlbGYpOgorICAg ICAgICByZXR1cm4gIkJCUGFja2V0Q29tbWFuZChjbWQ9JXIpIiAlIHNlbGYuY21kCisKKyAgICBk ZWYgX3VucGFja19wYXlsb2FkKHNlbGYsIHBheWxvYWQpOgorICAgICAgICBzZWxmLmNtZCA9IHBh eWxvYWQKKworICAgIGRlZiBfcGFja19wYXlsb2FkKHNlbGYpOgorICAgICAgICByZXR1cm4gc2Vs Zi5jbWQKKworCitjbGFzcyBCQlBhY2tldENvbW1hbmRSZXR1cm4oQkJQYWNrZXQpOgorICAgIGRl ZiBfX2luaXRfXyhzZWxmLCByYXc9Tm9uZSwgZXhpdF9jb2RlPU5vbmUpOgorICAgICAgICBzZWxm LmV4aXRfY29kZSA9IGV4aXRfY29kZQorICAgICAgICBzdXBlcihCQlBhY2tldENvbW1hbmRSZXR1 cm4sIHNlbGYpLl9faW5pdF9fKEJCVHlwZS5jb21tYW5kX3JldHVybiwKKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXc9cmF3KQorCisgICAgZGVm IF9fcmVwcl9fKHNlbGYpOgorICAgICAgICByZXR1cm4gIkJCUGFja2V0Q29tbWFuZFJldHVybihl eGl0X2NvZGU9JWkpIiAlIHNlbGYuZXhpdF9jb2RlCisKKyAgICBkZWYgX3VucGFja19wYXlsb2Fk KHNlbGYsIGRhdGEpOgorICAgICAgICBzZWxmLmV4aXRfY29kZSwgPSBzdHJ1Y3QudW5wYWNrKCIh TCIsIGRhdGFbOjRdKQorCisgICAgZGVmIF9wYWNrX3BheWxvYWQoc2VsZik6CisgICAgICAgIHJl dHVybiBzdHJ1Y3QucGFjaygiIUwiLCBzZWxmLmV4aXRfY29kZSkKKworCitjbGFzcyBCQlBhY2tl dENvbnNvbGVNc2coQkJQYWNrZXQpOgorICAgIGRlZiBfX2luaXRfXyhzZWxmLCByYXc9Tm9uZSwg dGV4dD1Ob25lKToKKyAgICAgICAgc2VsZi50ZXh0ID0gdGV4dAorICAgICAgICBzdXBlcihCQlBh Y2tldENvbnNvbGVNc2csIHNlbGYpLl9faW5pdF9fKEJCVHlwZS5jb25zb2xlbXNnLCByYXc9cmF3 KQorCisgICAgZGVmIF9fcmVwcl9fKHNlbGYpOgorICAgICAgICByZXR1cm4gIkJCUGFja2V0Q29u c29sZU1zZyh0ZXh0PSVyKSIgJSBzZWxmLnRleHQKKworICAgIGRlZiBfdW5wYWNrX3BheWxvYWQo c2VsZiwgcGF5bG9hZCk6CisgICAgICAgIHNlbGYudGV4dCA9IHBheWxvYWQKKworICAgIGRlZiBf cGFja19wYXlsb2FkKHNlbGYpOgorICAgICAgICByZXR1cm4gc2VsZi50ZXh0CisKKworY2xhc3Mg QkJQYWNrZXRQaW5nKEJCUGFja2V0KToKKyAgICBkZWYgX19pbml0X18oc2VsZiwgcmF3PU5vbmUp OgorICAgICAgICBzdXBlcihCQlBhY2tldFBpbmcsIHNlbGYpLl9faW5pdF9fKEJCVHlwZS5waW5n LCByYXc9cmF3KQorCisgICAgZGVmIF9fcmVwcl9fKHNlbGYpOgorICAgICAgICByZXR1cm4gIkJC UGFja2V0UGluZygpIgorCisKK2NsYXNzIEJCUGFja2V0UG9uZyhCQlBhY2tldCk6CisgICAgZGVm IF9faW5pdF9fKHNlbGYsIHJhdz1Ob25lKToKKyAgICAgICAgc3VwZXIoQkJQYWNrZXRQb25nLCBz ZWxmKS5fX2luaXRfXyhCQlR5cGUucG9uZywgcmF3PXJhdykKKworICAgIGRlZiBfX3JlcHJfXyhz ZWxmKToKKyAgICAgICAgcmV0dXJuICJCQlBhY2tldFBvbmcoKSIKKworCitjbGFzcyBCQlBhY2tl dEdldGVudihCQlBhY2tldCk6CisgICAgZGVmIF9faW5pdF9fKHNlbGYsIHJhdz1Ob25lLCB2YXJu YW1lPU5vbmUpOgorICAgICAgICBzZWxmLnZhcm5hbWUgPSB2YXJuYW1lCisgICAgICAgIHN1cGVy KEJCUGFja2V0R2V0ZW52LCBzZWxmKS5fX2luaXRfXyhCQlR5cGUuZ2V0ZW52LCByYXc9cmF3KQor CisgICAgZGVmIF9fcmVwcl9fKHNlbGYpOgorICAgICAgICByZXR1cm4gIkJCUGFja2V0R2V0ZW52 KHZhcm5hbWU9JXIpIiAlIHNlbGYudmFybmFtZQorCisgICAgZGVmIF91bnBhY2tfcGF5bG9hZChz ZWxmLCBwYXlsb2FkKToKKyAgICAgICAgc2VsZi52YXJuYW1lID0gcGF5bG9hZAorCisgICAgZGVm IF9wYWNrX3BheWxvYWQoc2VsZik6CisgICAgICAgIHJldHVybiBzZWxmLnZhcm5hbWUKKworCitj bGFzcyBCQlBhY2tldEdldGVudlJldHVybihCQlBhY2tldCk6CisgICAgZGVmIF9faW5pdF9fKHNl bGYsIHJhdz1Ob25lLCB0ZXh0PU5vbmUpOgorICAgICAgICBzZWxmLnRleHQgPSB0ZXh0CisgICAg ICAgIHN1cGVyKEJCUGFja2V0R2V0ZW52UmV0dXJuLCBzZWxmKS5fX2luaXRfXyhCQlR5cGUuZ2V0 ZW52X3JldHVybiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgI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pOgorICAgIHBhc3MKKworCitjbGFz cyBSYXRwSW52YWxpZFBheWxvYWQoVmFsdWVFcnJvcik6CisgICAgcGFzcworCisKK2NsYXNzIFJh dHBFcnJvcihWYWx1ZUVycm9yKToKKyAgICBwYXNzCisKKworY2xhc3MgUmF0cFBhY2tldChvYmpl Y3QpOgorCisgICAgZGVmIF9faW5pdF9fKHNlbGYsIGRhdGE9Tm9uZSwgZmxhZ3M9JycpOgorICAg ICAgICBzZWxmLnBheWxvYWQgPSBOb25lCisgICAgICAgIHNlbGYuc3luY2ggPSAweDAxCisgICAg ICAgIHNlbGYuX2NvbnRyb2wgPSAwCisgICAgICAgIHNlbGYubGVuZ3RoID0gMAorICAgICAgICBz ZWxmLmNzdW0gPSAwCisgICAgICAgIHNlbGYuY19zeW4gPSBGYWxzZQorICAgICAgICBzZWxmLmNf YWNrID0gRmFsc2UKKyAgICAgICAgc2VsZi5jX2ZpbiA9IEZhbHNlCisgICAgICAgIHNlbGYuY19y c3QgPSBGYWxzZQorICAgICAgICBzZWxmLmNfc24gPSAwCisgICAgICAgIHNlbGYuY19hbiA9IDAK KyAgICAgICAgc2VsZi5jX2VvciA9IEZhbHNlCisgICAgICAgIHNlbGYuY19zbyA9IEZhbHNlCisg ICAgICAgIGlmIGRhdGE6CisgICAgICAgICAgICAoc2VsZi5zeW5jaCwgc2VsZi5fY29udHJvbCwg c2VsZi5sZW5ndGgsIHNlbGYuY3N1bSkgPSBcCisgICAgICAgICAgICAgICAgc3RydWN0LnVucGFj aygnIUJCQkInLCBkYXRhKQorICAgICAgICAgICAgaWYgc2VsZi5zeW5jaCAhPSAweDAxOgorICAg ICAgICAgICAgICAgIHJhaXNlIFJhdHBJbnZhbGlkSGVhZGVyKCJpbnZhbGlkIHN5bmNoIG9jdGV0 ICgleCAhPSAleCkiICUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAo c2VsZi5zeW5jaCwgMHgwMSkpCisgICAgICAgICAgICBjc3VtID0gKHNlbGYuX2NvbnRyb2wgKyBz ZWxmLmxlbmd0aCArIHNlbGYuY3N1bSkgJiAweGZmCisgICAgICAgICAgICBpZiBjc3VtICE9IDB4 ZmY6CisgICAgICAgICAgICAgICAgcmFpc2UgUmF0cEludmFsaWRIZWFkZXIoImludmFsaWQgY3N1 bSBvY3RldCAoJXggIT0gJXgpIiAlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgKGNzdW0sIDB4ZmYpKQorICAgICAgICAgICAgc2VsZi5fdW5wYWNrX2NvbnRyb2woKQor ICAgICAgICBlbGlmIGZsYWdzOgorICAgICAgICAgICAgaWYgJ1MnIGluIGZsYWdzOgorICAgICAg ICAgICAgICAgIHNlbGYuY19zeW4gPSBUcnVlCisgICAgICAgICAgICBpZiAnQScgaW4gZmxhZ3M6 CisgICAgICAgICAgICAgICAgc2VsZi5jX2FjayA9IFRydWUKKyAgICAgICAgICAgIGlmICdGJyBp biBmbGFnczoKKyAgICAgICAgICAgICAgICBzZWxmLmNfZmluID0gVHJ1ZQorICAgICAgICAgICAg aWYgJ1InIGluIGZsYWdzOgorICAgICAgICAgICAgICAgIHNlbGYuY19yc3QgPSBUcnVlCisgICAg ICAgICAgICBpZiAnRScgaW4gZmxhZ3M6CisgICAgICAgICAgICAgICAgc2VsZi5jX2VvciA9IFRy dWUKKworICAgIGRlZiBfX3JlcHJfXyhzZWxmKToKKyAgICAgICAgcyA9ICJSYXRwUGFja2V0KCIK KyAgICAgICAgaWYgc2VsZi5jX3N5bjoKKyAgICAgICAgICAgIHMgKz0gIlNZTiwiCisgICAgICAg IGlmIHNlbGYuY19hY2s6CisgICAgICAgICAgICBzICs9ICJBQ0ssIgorICAgICAgICBpZiBzZWxm LmNfZmluOgorICAgICAgICAgICAgcyArPSAiRklOLCIKKyAgICAgICAgaWYgc2VsZi5jX3JzdDoK KyAgICAgICAgICAgIHMgKz0gIlJTVCwiCisgICAgICAgIHMgKz0gIlNOPSVpLEFOPSVpLCIgJSAo c2VsZi5jX3NuLCBzZWxmLmNfYW4pCisgICAgICAgIGlmIHNlbGYuY19lb3I6CisgICAgICAgICAg ICBzICs9ICJFT1IsIgorICAgICAgICBpZiBzZWxmLmNfc286CisgICAgICAgICAgICBzICs9ICJT TyxEQVRBPSVpKSIgJSBzZWxmLmxlbmd0aAorICAgICAgICBlbHNlOgorICAgICAgICAgICAgcyAr PSAiREFUQT0laSkiICUgc2VsZi5sZW5ndGgKKyAgICAgICAgcmV0dXJuIHMKKworICAgIGRlZiBf cGFja19jb250cm9sKHNlbGYpOgorICAgICAgICBzZWxmLl9jb250cm9sID0gMCB8IFwKKyAgICAg ICAgICAgIHNlbGYuY19zeW4gPDwgNyB8IFwKKyAgICAgICAgICAgIHNlbGYuY19hY2sgPDwgNiB8 IFwKKyAgICAgICAgICAgIHNlbGYuY19maW4gPDwgNSB8IFwKKyAgICAgICAgICAgIHNlbGYuY19y c3QgPDwgNCB8IFwKKyAgICAgICAgICAgIHNlbGYuY19zbiA8PCAzIHwgXAorICAgICAgICAgICAg c2VsZi5jX2FuIDw8IDIgfCBcCisgICAgICAgICAgICBzZWxmLmNfZW9yIDw8IDEgfCBcCisgICAg ICAgICAgICBzZWxmLmNfc28gPDwgMAorCisgICAgZGVmIF91bnBhY2tfY29udHJvbChzZWxmKToK KyAgICAgICAgc2VsZi5jX3N5biA9IGJvb2woc2VsZi5fY29udHJvbCAmIDEgPDwgNykKKyAgICAg ICAgc2VsZi5jX2FjayA9IGJvb2woc2VsZi5fY29udHJvbCAmIDEgPDwgNikKKyAgICAgICAgc2Vs Zi5jX2ZpbiA9IGJvb2woc2VsZi5fY29udHJvbCAmIDEgPDwgNSkKKyAgICAgICAgc2VsZi5jX3Jz dCA9IGJvb2woc2VsZi5fY29udHJvbCAmIDEgPDwgNCkKKyAgICAgICAgc2VsZi5jX3NuID0gYm9v bChzZWxmLl9jb250cm9sICYgMSA8PCAzKQorICAgICAgICBzZWxmLmNfYW4gPSBib29sKHNlbGYu X2NvbnRyb2wgJiAxIDw8IDIpCisgICAgICAgIHNlbGYuY19lb3IgPSBib29sKHNlbGYuX2NvbnRy b2wgJiAxIDw8IDEpCisgICAgICAgIHNlbGYuY19zbyA9IGJvb2woc2VsZi5fY29udHJvbCAmIDEg PDwgMCkKKworICAgIGRlZiBwYWNrKHNlbGYpOgorICAgICAgICBzZWxmLl9wYWNrX2NvbnRyb2wo KQorICAgICAgICBzZWxmLmNzdW0gPSAwCisgICAgICAgIHNlbGYuY3N1bSA9IChzZWxmLl9jb250 cm9sICsgc2VsZi5sZW5ndGggKyBzZWxmLmNzdW0pCisgICAgICAgIHNlbGYuY3N1bSA9IChzZWxm LmNzdW0gJiAweGZmKSBeIDB4ZmYKKyAgICAgICAgcmV0dXJuIHN0cnVjdC5wYWNrKCchQkJCQics IHNlbGYuc3luY2gsIHNlbGYuX2NvbnRyb2wsIHNlbGYubGVuZ3RoLAorICAgICAgICAgICAgICAg ICAgICAgICAgICAgc2VsZi5jc3VtKQorCisgICAgZGVmIHVucGFja19wYXlsb2FkKHNlbGYsIHBh eWxvYWQpOgorICAgICAgICAoY19yZWN2LCkgPSBzdHJ1Y3QudW5wYWNrKCchSCcsIHBheWxvYWRb LTI6XSkKKyAgICAgICAgY19jYWxjID0gY3N1bV9mdW5jKHBheWxvYWRbOi0yXSkKKyAgICAgICAg aWYgY19yZWN2ICE9IGNfY2FsYzoKKyAgICAgICAgICAgIHJhaXNlIFJhdHBJbnZhbGlkUGF5bG9h ZCgiYmFkIGNoZWNrc3VtICglMDR4ICE9ICUwNHgpIiAlCisgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgKGNfcmVjdiwgY19jYWxjKSkKKyAgICAgICAgc2VsZi5wYXlsb2FkID0g cGF5bG9hZFs6LTJdCisKKyAgICBkZWYgcGFja19wYXlsb2FkKHNlbGYpOgorICAgICAgICBjX2Nh bGMgPSBjc3VtX2Z1bmMoc2VsZi5wYXlsb2FkKQorICAgICAgICByZXR1cm4gc2VsZi5wYXlsb2Fk K3N0cnVjdC5wYWNrKCchSCcsIGNfY2FsYykKKworCitjbGFzcyBSYXRwQ29ubmVjdGlvbihvYmpl Y3QpOgorICAgIGRlZiBfX2luaXRfXyhzZWxmKToKKyAgICAgICAgc2VsZi5fc3RhdGUgPSBSYXRw U3RhdGUuY2xvc2VkCisgICAgICAgIHNlbGYuX3Bhc3NpdmUgPSBUcnVlCisgICAgICAgIHNlbGYu X2lucHV0ID0gYicnCisgICAgICAgIHNlbGYuX3Nfc24gPSAwCisgICAgICAgIHNlbGYuX3Jfc24g PSAwCisgICAgICAgIHNlbGYuX3JldHJhbnMgPSBOb25lCisgICAgICAgIHNlbGYuX3JldHJhbnNf Y291bnRlciA9IE5vbmUKKyAgICAgICAgc2VsZi5fcmV0cmFuc19kZWFkbGluZSA9IE5vbmUKKyAg ICAgICAgc2VsZi5fcl9tZGwgPSBOb25lCisgICAgICAgIHNlbGYuX3NfbWRsID0gMHhmZgorICAg ICAgICBzZWxmLl9yeF9idWYgPSBbXSAjIHJlYXNzZW1ibHkgYnVmZmVyCisgICAgICAgIHNlbGYu X3J4X3F1ZXVlID0gW10KKyAgICAgICAgc2VsZi5fdHhfcXVldWUgPSBbXQorICAgICAgICBzZWxm Ll9ydHRfYWxwaGEgPSAwLjgKKyAgICAgICAgc2VsZi5fcnR0X2JldGEgPSAyLjAKKyAgICAgICAg c2VsZi5fc3J0dCA9IDAuMgorICAgICAgICBzZWxmLl9ydG9fbWluLCBzZWxmLl9ydG9fbWF4ID0g MC4yLCAxCisgICAgICAgIHNlbGYuX3R4X3RpbWVzdGFtcCA9IE5vbmUKKyAgICAgICAgc2VsZi50 b3RhbF9yZXRyYW5zbWl0cyA9IDAKKyAgICAgICAgc2VsZi50b3RhbF9jcmNfZXJyb3JzID0gMAor CisgICAgZGVmIF91cGRhdGVfc3J0dChzZWxmLCBydHQpOgorICAgICAgICBzZWxmLl9zcnR0ID0g KHNlbGYuX3J0dF9hbHBoYSAqIHNlbGYuX3NydHQpICsgXAorICAgICAgICAgICAgICAgICAgICAg KCgxLjAgLSBzZWxmLl9ydHRfYWxwaGEpICogcnR0KQorICAgICAgICBsb2dnaW5nLmluZm8oIlNS VFQ6ICVyIiwgc2VsZi5fc3J0dCkKKworICAgIGRlZiBfZ2V0X3J0byhzZWxmKToKKyAgICAgICAg cmV0dXJuIG1pbihzZWxmLl9ydG9fbWF4LAorICAgICAgICAgICAgICAgICAgIG1heChzZWxmLl9y dG9fbWluLCBzZWxmLl9ydHRfYmV0YSAqIHNlbGYuX3NydHQpKQorCisgICAgZGVmIF93cml0ZShz ZWxmLCBwa3QpOgorCisgICAgICAgIGlmIHBrdC5wYXlsb2FkIG9yIHBrdC5jX3NvIG9yIHBrdC5j X3N5biBvciBwa3QuY19yc3Qgb3IgcGt0LmNfZmluOgorICAgICAgICAgICAgc2VsZi5fc19zbiA9 IHBrdC5jX3NuCisgICAgICAgICAgICBpZiBub3Qgc2VsZi5fcmV0cmFuczoKKyAgICAgICAgICAg ICAgICBzZWxmLl9yZXRyYW5zID0gcGt0CisgICAgICAgICAgICAgICAgc2VsZi5fcmV0cmFuc19j b3VudGVyID0gMAorICAgICAgICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICBzZWxmLnRvdGFs X3JldHJhbnNtaXRzICs9IDEKKyAgICAgICAgICAgICAgICBzZWxmLl9yZXRyYW5zX2NvdW50ZXIg Kz0gMQorICAgICAgICAgICAgICAgIGlmIHNlbGYuX3JldHJhbnNfY291bnRlciA+IDEwOgorICAg ICAgICAgICAgICAgICAgICByYWlzZSBSYXRwRXJyb3IoIk1heGltdW0gcmV0cmFuc21pdCBjb3Vu dCBleGNlZWRlZCIpCisgICAgICAgICAgICBzZWxmLl9yZXRyYW5zX2RlYWRsaW5lID0gbW9ub3Rv bmljKCkrc2VsZi5fZ2V0X3J0bygpCisKKyAgICAgICAgbG9nZ2luZy5pbmZvKCJXcml0ZTogJXIi LCBwa3QpCisKKyAgICAgICAgc2VsZi5fd3JpdGVfcmF3KHBrdC5wYWNrKCkpCisgICAgICAgIGlm IHBrdC5wYXlsb2FkOgorICAgICAgICAgICAgc2VsZi5fd3JpdGVfcmF3KHBrdC5wYWNrX3BheWxv YWQoKSkKKyAgICAgICAgc2VsZi5fdHhfdGltZXN0YW1wID0gbW9ub3RvbmljKCkKKworICAgIGRl ZiBfY2hlY2tfcnRvKHNlbGYpOgorICAgICAgICBpZiBzZWxmLl9yZXRyYW5zIGlzIE5vbmU6Cisg ICAgICAgICAgICByZXR1cm4KKworICAgICAgICBpZiBzZWxmLl9yZXRyYW5zX2RlYWRsaW5lIDwg bW9ub3RvbmljKCk6CisgICAgICAgICAgICBsb2dnaW5nLmRlYnVnKCJSZXRyYW5zbWl0Li4uIikK KyAgICAgICAgICAgIHNlbGYuX3dyaXRlKHNlbGYuX3JldHJhbnMpCisKKyAgICBkZWYgX2NoZWNr X3RpbWVfd2FpdChzZWxmKToKKyAgICAgICAgaWYgbm90IHNlbGYuX3N0YXRlID09IFJhdHBTdGF0 ZS50aW1lX3dhaXQ6CisgICAgICAgICAgICByZXR1cm4KKworICAgICAgICByZW1haW5pbmcgPSBz ZWxmLl90aW1lX3dhaXRfZGVhZGxpbmUgLSBtb25vdG9uaWMoKQorICAgICAgICBpZiByZW1haW5p bmcgPCAwOgorICAgICAgICAgICAgc2VsZi5fc3RhdGUgPSBSYXRwU3RhdGUuY2xvc2VkCisgICAg ICAgIGVsc2U6CisgICAgICAgICAgICBsb2dnaW5nLmRlYnVnKCJUaW1lLVdhaXQ6ICUuMmYgcmVt YWluaW5nIiAlIHJlbWFpbmluZykKKyAgICAgICAgICAgIHNsZWVwKG1pbihyZW1haW5pbmcsIDAu MSkpCisKKyAgICBkZWYgX3JlYWQoc2VsZik6CisgICAgICAgIGlmIGxlbihzZWxmLl9pbnB1dCkg PCA0OgorICAgICAgICAgICAgc2VsZi5faW5wdXQgKz0gc2VsZi5fcmVhZF9yYXcoNC1sZW4oc2Vs Zi5faW5wdXQpKQorICAgICAgICBpZiBsZW4oc2VsZi5faW5wdXQpIDwgNDoKKyAgICAgICAgICAg IHJldHVybgorCisgICAgICAgIHRyeToKKyAgICAgICAgICAgIHBrdCA9IFJhdHBQYWNrZXQoZGF0 YT1zZWxmLl9pbnB1dFs6NF0pCisgICAgICAgIGV4Y2VwdCBSYXRwSW52YWxpZEhlYWRlciBhcyBl OgorICAgICAgICAgICAgbG9nZ2luZy5pbmZvKCIlciIsIGUpCisgICAgICAgICAgICBzZWxmLl9p bnB1dCA9IHNlbGYuX2lucHV0WzE6XQorICAgICAgICAgICAgcmV0dXJuCisKKyAgICAgICAgc2Vs Zi5faW5wdXQgPSBzZWxmLl9pbnB1dFs0Ol0KKworICAgICAgICBsb2dnaW5nLmluZm8oIlJlYWQ6 ICVyIiwgcGt0KQorCisgICAgICAgIGlmIHBrdC5jX3N5biBvciBwa3QuY19yc3Qgb3IgcGt0LmNf c28gb3IgcGt0LmNfZmluOgorICAgICAgICAgICAgcmV0dXJuIHBrdAorCisgICAgICAgIGlmIHBr dC5sZW5ndGggPT0gMDoKKyAgICAgICAgICAgIHJldHVybiBwa3QKKworICAgICAgICB3aGlsZSBs ZW4oc2VsZi5faW5wdXQpIDwgcGt0Lmxlbmd0aCsyOgorICAgICAgICAgICAgc2VsZi5faW5wdXQg Kz0gc2VsZi5fcmVhZF9yYXcoKQorCisgICAgICAgIHRyeToKKyAgICAgICAgICAgIHBrdC51bnBh Y2tfcGF5bG9hZChzZWxmLl9pbnB1dFs6cGt0Lmxlbmd0aCsyXSkKKyAgICAgICAgZXhjZXB0IFJh dHBJbnZhbGlkUGF5bG9hZCBhcyBlOgorICAgICAgICAgICAgc2VsZi50b3RhbF9jcmNfZXJyb3Jz ICs9IDEKKyAgICAgICAgICAgIHJldHVybgorICAgICAgICBmaW5hbGx5OgorICAgICAgICAgICAg c2VsZi5faW5wdXQgPSBzZWxmLl9pbnB1dFtwa3QubGVuZ3RoKzI6XQorCisgICAgICAgIHJldHVy biBwa3QKKworICAgIGRlZiBfY2xvc2Uoc2VsZik6CisgICAgICAgIHBhc3MKKworICAgIGRlZiBf YShzZWxmLCByKToKKyAgICAgICAgbG9nZ2luZy5pbmZvKCJBIikKKworICAgICAgICBpZiByLmNf cnN0OgorICAgICAgICAgICAgcmV0dXJuIFRydWUKKworICAgICAgICBpZiByLmNfYWNrOgorICAg ICAgICAgICAgcyA9IFJhdHBQYWNrZXQoZmxhZ3M9J1InKQorICAgICAgICAgICAgcy5jX3NuID0g ci5jX2FuCisgICAgICAgICAgICBzZWxmLl93cml0ZShzKQorICAgICAgICAgICAgcmV0dXJuIEZh bHNlCisKKyAgICAgICAgaWYgci5jX3N5bjoKKyAgICAgICAgICAgIHNlbGYuX3JfbWRsID0gci5s ZW5ndGgKKworICAgICAgICAgICAgcyA9IFJhdHBQYWNrZXQoZmxhZ3M9J1NBJykKKyAgICAgICAg ICAgIHMuY19zbiA9IDAKKyAgICAgICAgICAgIHMuY19hbiA9IChyLmNfc24gKyAxKSAlIDIKKyAg ICAgICAgICAgIHMubGVuZ3RoID0gc2VsZi5fc19tZGwKKyAgICAgICAgICAgIHNlbGYuX3dyaXRl KHMpCisgICAgICAgICAgICBzZWxmLl9zdGF0ZSA9IFJhdHBTdGF0ZS5zeW5fcmVjZWl2ZWQKKyAg ICAgICAgICAgIHJldHVybiBGYWxzZQorCisgICAgICAgIHJldHVybiBGYWxzZQorCisgICAgZGVm IF9iKHNlbGYsIHIpOgorICAgICAgICBsb2dnaW5nLmluZm8oIkIiKQorCisgICAgICAgIGlmIHIu Y19hY2sgYW5kIHIuY19hbiAhPSAoc2VsZi5fc19zbiArIDEpICUgMjoKKyAgICAgICAgICAgIGlm IHIuY19yc3Q6CisgICAgICAgICAgICAgICAgcmV0dXJuIEZhbHNlCisgICAgICAgICAgICBlbHNl OgorICAgICAgICAgICAgICAgIHMgPSBSYXRwUGFja2V0KGZsYWdzPSdSJykKKyAgICAgICAgICAg ICAgICBzLmNfc24gPSByLmNfYW4KKyAgICAgICAgICAgICAgICBzZWxmLl93cml0ZShzKQorICAg ICAgICAgICAgICAgIHJldHVybiBGYWxzZQorCisgICAgICAgIGlmIHIuY19yc3Q6CisgICAgICAg ICAgICBpZiByLmNfYWNrOgorICAgICAgICAgICAgICAgIHNlbGYuX3JldHJhbnMgPSBOb25lCisg ICAgICAgICAgICAgICAgIyBGSVhNRTogZGVsZXRlIHRoZSBUQ0IKKyAgICAgICAgICAgICAgICBz ZWxmLl9zdGF0ZSA9IFJhdHBTdGF0ZS5jbG9zZWQKKyAgICAgICAgICAgICAgICByZXR1cm4gRmFs c2UKKyAgICAgICAgICAgIGVsc2U6CisgICAgICAgICAgICAgICAgcmV0dXJuIEZhbHNlCisKKyAg ICAgICAgaWYgci5jX3N5bjoKKyAgICAgICAgICAgIGlmIHIuY19hY2s6CisgICAgICAgICAgICAg ICAgc2VsZi5fcl9tZGwgPSByLmxlbmd0aAorICAgICAgICAgICAgICAgIHNlbGYuX3JldHJhbnMg PSBOb25lCisgICAgICAgICAgICAgICAgc2VsZi5fcl9zbiA9IHIuY19zbgorICAgICAgICAgICAg ICAgIHMgPSBSYXRwUGFja2V0KGZsYWdzPSdBJykKKyAgICAgICAgICAgICAgICBzLmNfc24gPSBy LmNfYW4KKyAgICAgICAgICAgICAgICBzLmNfYW4gPSAoci5jX3NuICsgMSkgJSAyCisgICAgICAg ICAgICAgICAgc2VsZi5fd3JpdGUocykKKyAgICAgICAgICAgICAgICBzZWxmLl9zdGF0ZSA9IFJh dHBTdGF0ZS5lc3RhYmxpc2hlZAorICAgICAgICAgICAgICAgIHJldHVybiBGYWxzZQorICAgICAg ICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICBzZWxmLl9yZXRyYW5zID0gTm9uZQorICAgICAg ICAgICAgICAgIHMgPSBSYXRwUGFja2V0KGZsYWdzPSdTQScpCisgICAgICAgICAgICAgICAgcy5j X3NuID0gMAorICAgICAgICAgICAgICAgIHMuY19hbiA9IChyLmNfc24gKyAxKSAlIDIKKyAgICAg ICAgICAgICAgICBzLmxlbmd0aCA9IHNlbGYuX3NfbWRsCisgICAgICAgICAgICAgICAgc2VsZi5f d3JpdGUocykKKyAgICAgICAgICAgICAgICBzZWxmLl9zdGF0ZSA9IFJhdHBTdGF0ZS5zeW5fcmVj ZWl2ZWQKKyAgICAgICAgICAgICAgICByZXR1cm4gRmFsc2UKKworICAgICAgICByZXR1cm4gRmFs c2UKKworICAgIGRlZiBfYzEoc2VsZiwgcik6CisgICAgICAgIGxvZ2dpbmcuaW5mbygiQzEiKQor CisgICAgICAgIGlmIHIuY19zbiAhPSBzZWxmLl9yX3NuOgorICAgICAgICAgICAgcmV0dXJuIFRy dWUKKworICAgICAgICBpZiByLmNfcnN0IG9yIHIuY19maW46CisgICAgICAgICAgICByZXR1cm4g RmFsc2UKKworICAgICAgICBzID0gUmF0cFBhY2tldChmbGFncz0nQScpCisgICAgICAgIHMuY19z biA9IHIuY19hbgorICAgICAgICBzLmNfYW4gPSAoci5jX3NuICsgMSkgJSAyCisgICAgICAgIHNl bGYuX3dyaXRlKHMpCisgICAgICAgIHJldHVybiBGYWxzZQorCisgICAgZGVmIF9jMihzZWxmLCBy KToKKyAgICAgICAgbG9nZ2luZy5pbmZvKCJDMiIpCisKKyAgICAgICAgaWYgci5sZW5ndGggPT0g MCBhbmQgci5jX3NvID09IDA6CisgICAgICAgICAgICByZXR1cm4gVHJ1ZQorCisgICAgICAgIGlm IHIuY19zbiAhPSBzZWxmLl9yX3NuOgorICAgICAgICAgICAgcmV0dXJuIFRydWUKKworICAgICAg ICBpZiByLmNfcnN0IG9yIHIuY19maW46CisgICAgICAgICAgICByZXR1cm4gRmFsc2UKKworICAg ICAgICBpZiByLmNfc3luOgorICAgICAgICAgICAgcyA9IFJhdHBQYWNrZXQoZmxhZ3M9J1JBJykK KyAgICAgICAgICAgIHMuY19zbiA9IHIuY19hbgorICAgICAgICAgICAgcy5jX2FuID0gKHIuY19z biArIDEpICUgMgorICAgICAgICAgICAgc2VsZi5fd3JpdGUocykKKyAgICAgICAgICAgIHNlbGYu X3JldHJhbnMgPSBOb25lCisgICAgICAgICAgICAjIEZJWE1FOiBpbmZvcm0gdGhlIHVzZXIgIkVy cm9yOiBDb25uZWN0aW9uIHJlc2V0IgorICAgICAgICAgICAgc2VsZi5fc3RhdGUgPSBSYXRwU3Rh dGUuY2xvc2VkCisgICAgICAgICAgICByZXR1cm4gRmFsc2UKKworICAgICAgICAjIEZJWE1FOiBv bmx5IGFjayBkdXBsaWNhdGUgZGF0YSBwYWNrYWdlcz8KKyAgICAgICAgIyBUaGlzIGlzIG5vdCBk b2N1bWVudGVkIGluIFJGQyA5MTYKKyAgICAgICAgaWYgci5sZW5ndGggb3Igci5jX3NvOgorICAg ICAgICAgICAgbG9nZ2luZy5pbmZvKCJDMjogZHVwbGljYXRlIGRhdGEgcGFja2V0LCBkcm9wcGlu ZyIpCisgICAgICAgICAgICBzID0gUmF0cFBhY2tldChmbGFncz0nQScpCisgICAgICAgICAgICBz LmNfc24gPSByLmNfYW4KKyAgICAgICAgICAgIHMuY19hbiA9IChyLmNfc24gKyAxKSAlIDIKKyAg ICAgICAgICAgIHNlbGYuX3dyaXRlKHMpCisKKyAgICAgICAgcmV0dXJuIEZhbHNlCisKKyAgICBk ZWYgX2QxKHNlbGYsIHIpOgorICAgICAgICBsb2dnaW5nLmluZm8oIkQxIikKKworICAgICAgICBp ZiBub3Qgci5jX3JzdDoKKyAgICAgICAgICAgIHJldHVybiBUcnVlCisKKyAgICAgICAgaWYgc2Vs Zi5fcGFzc2l2ZToKKyAgICAgICAgICAgIHNlbGYuX3JldHJhbnMgPSBOb25lCisgICAgICAgICAg ICBzZWxmLl9zdGF0ZSA9IFJhdHBTdGF0ZS5saXN0ZW4KKyAgICAgICAgICAgIHJldHVybiBGYWxz ZQorICAgICAgICBlbHNlOgorICAgICAgICAgICAgc2VsZi5fcmV0cmFucyA9IE5vbmUKKworICAg ICAgICAgICAgc2VsZi5fc3RhdGUgPSBSYXRwU3RhdGUuY2xvc2VkCisgICAgICAgICAgICByYWlz ZSBSYXRwRXJyb3IoIkNvbm5lY3Rpb24gcmVmdXNlZCIpCisKKyAgICBkZWYgX2QyKHNlbGYsIHIp OgorICAgICAgICBsb2dnaW5nLmluZm8oIkQyIikKKworICAgICAgICBpZiBub3Qgci5jX3JzdDoK KyAgICAgICAgICAgIHJldHVybiBUcnVlCisKKyAgICAgICAgc2VsZi5fcmV0cmFucyA9IE5vbmUK KworICAgICAgICBzZWxmLl9zdGF0ZSA9IFJhdHBTdGF0ZS5jbG9zZWQKKworICAgICAgICByYWlz ZSBSYXRwRXJyb3IoIkNvbm5lY3Rpb24gcmVzZXQiKQorCisgICAgZGVmIF9kMyhzZWxmLCByKToK KyAgICAgICAgbG9nZ2luZy5pbmZvKCJDMyIpCisKKyAgICAgICAgaWYgbm90IHIuY19yc3Q6Cisg ICAgICAgICAgICByZXR1cm4gVHJ1ZQorCisgICAgICAgIHNlbGYuX3N0YXRlID0gUmF0cFN0YXRl LmNsb3NlZAorICAgICAgICByZXR1cm4gRmFsc2UKKworICAgIGRlZiBfZShzZWxmLCByKToKKyAg ICAgICAgbG9nZ2luZy5pbmZvKCJFIikKKworICAgICAgICBpZiBub3Qgci5jX3N5bjoKKyAgICAg ICAgICAgIHJldHVybiBUcnVlCisKKyAgICAgICAgc2VsZi5fcmV0cmFucyA9IE5vbmUKKyAgICAg ICAgcyA9IFJhdHBQYWNrZXQoZmxhZ3M9J1InKQorICAgICAgICBpZiByLmNfYWNrOgorICAgICAg ICAgICAgcy5jX3NuID0gci5jX2FuCisgICAgICAgIGVsc2U6CisgICAgICAgICAgICBzLmNfc24g PSAwCisgICAgICAgIHNlbGYuX3dyaXRlKHMpCisgICAgICAgIHNlbGYuX3N0YXRlID0gUmF0cFN0 YXRlLmNsb3NlZAorICAgICAgICByYWlzZSBSYXRwRXJyb3IoIkNvbm5lY3Rpb24gcmVzZXQiKQor CisgICAgZGVmIF9mMShzZWxmLCByKToKKyAgICAgICAgbG9nZ2luZy5pbmZvKCJGMSIpCisKKyAg ICAgICAgaWYgbm90IHIuY19hY2s6CisgICAgICAgICAgICByZXR1cm4gRmFsc2UKKworICAgICAg ICBpZiByLmNfYW4gPT0gKHNlbGYuX3Nfc24gKyAxKSAlIDI6CisgICAgICAgICAgICByZXR1cm4g VHJ1ZQorCisgICAgICAgIGlmIHNlbGYuX3Bhc3NpdmU6CisgICAgICAgICAgICBzZWxmLl9yZXRy YW5zID0gTm9uZQorICAgICAgICAgICAgcyA9IFJhdHBQYWNrZXQoZmxhZ3M9J1InKQorICAgICAg ICAgICAgcy5jX3NuID0gci5jX2FuCisgICAgICAgICAgICBzZWxmLl93cml0ZShzKQorICAgICAg ICAgICAgc2VsZi5fc3RhdGUgPSBSYXRwU3RhdGUubGlzdGVuCisgICAgICAgICAgICByZXR1cm4g RmFsc2UKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgIHNlbGYuX3JldHJhbnMgPSBOb25lCisg ICAgICAgICAgICBzID0gUmF0cFBhY2tldChmbGFncz0nUicpCisgICAgICAgICAgICBzLmNfc24g PSByLmNfYW4KKyAgICAgICAgICAgIHNlbGYuX3dyaXRlKHMpCisgICAgICAgICAgICBzZWxmLl9z dGF0ZSA9IFJhdHBTdGF0ZS5jbG9zZWQKKyAgICAgICAgICAgIHJhaXNlIFJhdHBFcnJvcigiQ29u bmVjdGlvbiByZWZ1c2VkIikKKworICAgIGRlZiBfZjIoc2VsZiwgcik6CisgICAgICAgIGxvZ2dp bmcuaW5mbygiRjIiKQorCisgICAgICAgIGlmIG5vdCByLmNfYWNrOgorICAgICAgICAgICAgcmV0 dXJuIEZhbHNlCisKKyAgICAgICAgaWYgci5jX2FuID09IChzZWxmLl9zX3NuICsgMSkgJSAyOgor ICAgICAgICAgICAgaWYgc2VsZi5fcmV0cmFuczoKKyAgICAgICAgICAgICAgICBzZWxmLl9yZXRy YW5zID0gTm9uZQorICAgICAgICAgICAgICAgIHNlbGYuX3VwZGF0ZV9zcnR0KG1vbm90b25pYygp LXNlbGYuX3R4X3RpbWVzdGFtcCkKKyAgICAgICAgICAgICAgICAjIEZJWE1FOiBpbmZvcm0gdGhl IHVzZXIgd2l0aCBhbiAiT2siIGlmIGEgYnVmZmVyIGhhcyBiZWVuCisgICAgICAgICAgICAgICAg IyBlbnRpcmVseSBhY2tub3dsZWRnZWQuICBBbm90aGVyIHBhY2tldCBjb250YWluaW5nIGRhdGEg bWF5CisgICAgICAgICAgICAgICAgIyBub3cgYmUgc2VudC4KKyAgICAgICAgICAgIHJldHVybiBU cnVlCisKKyAgICAgICAgcmV0dXJuIFRydWUKKworICAgIGRlZiBfZjMoc2VsZiwgcik6CisgICAg ICAgIGxvZ2dpbmcuaW5mbygiRjMiKQorCisgICAgICAgIGlmIG5vdCByLmNfYWNrOgorICAgICAg ICAgICAgcmV0dXJuIEZhbHNlCisKKyAgICAgICAgaWYgci5jX2FuID09IChzZWxmLl9zX3NuICsg MSkgJSAyOgorICAgICAgICAgICAgcmV0dXJuIFRydWUKKworICAgICAgICByZXR1cm4gVHJ1ZQor CisgICAgZGVmIF9nKHNlbGYsIHIpOgorICAgICAgICBsb2dnaW5nLmluZm8oIkciKQorCisgICAg ICAgIGlmIG5vdCByLmNfcnN0OgorICAgICAgICAgICAgcmV0dXJuIEZhbHNlCisKKyAgICAgICAg c2VsZi5fcmV0cmFucyA9IE5vbmUKKyAgICAgICAgaWYgci5jX2FjazoKKyAgICAgICAgICAgIHMg PSBSYXRwUGFja2V0KGZsYWdzPSdSJykKKyAgICAgICAgICAgIHMuY19zbiA9IHIuY19hbgorICAg ICAgICAgICAgc2VsZi5fd3JpdGUocykKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgIHMgPSBS YXRwUGFja2V0KGZsYWdzPSdSQScpCisgICAgICAgICAgICBzLmNfc24gPSByLmNfYW4KKyAgICAg ICAgICAgIHMuY19hbiA9IChyLmNfc24gKyAxKSAlIDIKKyAgICAgICAgICAgIHNlbGYuX3dyaXRl KHMpCisKKyAgICAgICAgcmV0dXJuIEZhbHNlCisKKyAgICBkZWYgX2gxKHNlbGYsIHIpOgorICAg ICAgICBsb2dnaW5nLmluZm8oIkgxIikKKworICAgICAgICAjIEZJWE1FOiBpbml0aWFsIGRhdGE/ CisgICAgICAgIHNlbGYuX3N0YXRlID0gUmF0cFN0YXRlLmVzdGFibGlzaGVkCisgICAgICAgIHNl bGYuX3Jfc24gPSByLmNfc24KKworICAgICAgICByZXR1cm4gRmFsc2UKKworICAgIGRlZiBfaDIo c2VsZiwgcik6CisgICAgICAgIGxvZ2dpbmcuaW5mbygiSDIiKQorCisgICAgICAgIGlmIG5vdCBy LmNfZmluOgorICAgICAgICAgICAgcmV0dXJuIFRydWUKKworICAgICAgICBpZiBzZWxmLl9yZXRy YW5zIGlzIG5vdCBOb25lOgorICAgICAgICAgICAgIyBGSVhNRTogaW5mb3JtIHRoZSB1c2VyICJX YXJuaW5nOiBEYXRhIGxlZnQgdW5zZW50LiIsICJDb25uZWN0aW9uIGNsb3NpbmcuIgorICAgICAg ICAgICAgc2VsZi5fcmV0cmFucyA9IE5vbmUKKyAgICAgICAgcyA9IFJhdHBQYWNrZXQoZmxhZ3M9 J0ZBJykKKyAgICAgICAgcy5jX3NuID0gci5jX2FuCisgICAgICAgIHMuY19hbiA9IChyLmNfc24g KyAxKSAlIDIKKyAgICAgICAgc2VsZi5fd3JpdGUocykKKyAgICAgICAgc2VsZi5fc3RhdGUgPSBS YXRwU3RhdGUubGFzdF9hY2sKKyAgICAgICAgcmFpc2UgUmF0cEVycm9yKCJDb25uZWN0aW9uIGNs b3NlZCBieSByZW1vdGUiKQorCisgICAgZGVmIF9oMyhzZWxmLCByKToKKyAgICAgICAgbG9nZ2lu Zy5pbmZvKCJIMyIpCisKKyAgICAgICAgaWYgbm90IHIuY19maW46CisgICAgICAgICAgICAjIE91 ciBmaW4gd2FzIGxvc3QsIHJlbHkgb24gcmV0cmFuc21pc3Npb24KKyAgICAgICAgICAgIHJldHVy biBGYWxzZQorCisgICAgICAgIGlmIHIubGVuZ3RoIG9yIHIuY19zbzoKKyAgICAgICAgICAgIHNl bGYuX3JldHJhbnMgPSBOb25lCisgICAgICAgICAgICBzID0gUmF0cFBhY2tldChmbGFncz0nUkEn KQorICAgICAgICAgICAgcy5jX3NuID0gci5jX2FuCisgICAgICAgICAgICBzLmNfYW4gPSAoci5j X3NuICsgMSkgJSAyCisgICAgICAgICAgICBzZWxmLl93cml0ZShzKQorICAgICAgICAgICAgc2Vs Zi5fc3RhdGUgPSBSYXRwU3RhdGUuY2xvc2VkCisgICAgICAgICAgICByYWlzZSBSYXRwRXJyb3Io IkNvbm5lY3Rpb24gcmVzZXQiKQorCisgICAgICAgIGlmIHIuY19hbiA9PSAoc2VsZi5fc19zbiAr IDEpICUgMjoKKyAgICAgICAgICAgIHNlbGYuX3JldHJhbnMgPSBOb25lCisgICAgICAgICAgICBz ID0gUmF0cFBhY2tldChmbGFncz0nQScpCisgICAgICAgICAgICBzLmNfc24gPSByLmNfYW4KKyAg ICAgICAgICAgIHMuY19hbiA9IChyLmNfc24gKyAxKSAlIDIKKyAgICAgICAgICAgIHNlbGYuX3dy aXRlKHMpCisgICAgICAgICAgICBzZWxmLl90aW1lX3dhaXRfZGVhZGxpbmUgPSBtb25vdG9uaWMo KSArIHNlbGYuX2dldF9ydG8oKQorICAgICAgICAgICAgc2VsZi5fc3RhdGUgPSBSYXRwU3RhdGUu dGltZV93YWl0CisgICAgICAgICAgICByZXR1cm4gRmFsc2UKKyAgICAgICAgZWxzZToKKyAgICAg ICAgICAgIHNlbGYuX3JldHJhbnMgPSBOb25lCisgICAgICAgICAgICBzID0gUmF0cFBhY2tldChm bGFncz0nQScpCisgICAgICAgICAgICBzLmNfc24gPSByLmNfYW4KKyAgICAgICAgICAgIHMuY19h biA9IChyLmNfc24gKyAxKSAlIDIKKyAgICAgICAgICAgIHNlbGYuX3dyaXRlKHMpCisgICAgICAg ICAgICBzZWxmLl9zdGF0ZSA9IFJhdHBTdGF0ZS5jbG9zaW5nCisgICAgICAgICAgICByZXR1cm4g RmFsc2UKKworICAgIGRlZiBfaDQoc2VsZiwgcik6CisgICAgICAgIGxvZ2dpbmcuaW5mbygiSDQi KQorCisgICAgICAgIGlmIHIuY19hbiA9PSAoc2VsZi5fc19zbiArIDEpICUgMjoKKyAgICAgICAg ICAgIHNlbGYuX3JldHJhbnMgPSBOb25lCisgICAgICAgICAgICBzZWxmLl90aW1lX3dhaXRfZGVh ZGxpbmUgPSBtb25vdG9uaWMoKSArIHNlbGYuX2dldF9ydG8oKQorICAgICAgICAgICAgc2VsZi5f c3RhdGUgPSBSYXRwU3RhdGUudGltZV93YWl0CisgICAgICAgICAgICByZXR1cm4gRmFsc2UKKwor ICAgICAgICByZXR1cm4gRmFsc2UKKworICAgIGRlZiBfaDUoc2VsZiwgcik6CisgICAgICAgIGxv Z2dpbmcuaW5mbygiSDUiKQorCisgICAgICAgIGlmIHIuY19hbiA9PSAoc2VsZi5fc19zbiArIDEp ICUgMjoKKyAgICAgICAgICAgIHNlbGYuX3RpbWVfd2FpdF9kZWFkbGluZSA9IG1vbm90b25pYygp ICsgc2VsZi5fZ2V0X3J0bygpCisgICAgICAgICAgICBzZWxmLl9zdGF0ZSA9IFJhdHBTdGF0ZS50 aW1lX3dhaXQKKyAgICAgICAgICAgIHJldHVybiBGYWxzZQorCisgICAgICAgIHJldHVybiBGYWxz ZQorCisgICAgZGVmIF9oNihzZWxmLCByKToKKyAgICAgICAgbG9nZ2luZy5pbmZvKCJINiIpCisK KyAgICAgICAgaWYgbm90IHIuY19hY2s6CisgICAgICAgICAgICByZXR1cm4gRmFsc2UKKworICAg ICAgICBpZiBub3Qgci5jX2ZpbjoKKyAgICAgICAgICAgIHJldHVybiBGYWxzZQorCisgICAgICAg IHNlbGYuX3JldHJhbnMgPSBOb25lCisgICAgICAgIHMgPSBSYXRwUGFja2V0KGZsYWdzPSdBJykK KyAgICAgICAgcy5jX3NuID0gci5jX2FuCisgICAgICAgIHMuY19hbiA9IChyLmNfc24gKyAxKSAl IDIKKyAgICAgICAgc2VsZi5fd3JpdGUocykKKyAgICAgICAgc2VsZi5fdGltZV93YWl0X2RlYWRs aW5lID0gbW9ub3RvbmljKCkgKyBzZWxmLl9nZXRfcnRvKCkKKyAgICAgICAgcmV0dXJuIEZhbHNl CisKKyAgICBkZWYgX2kxKHNlbGYsIHIpOgorICAgICAgICBsb2dnaW5nLmluZm8oIkkxIikKKwor ICAgICAgICBpZiByLmNfc286CisgICAgICAgICAgICBzZWxmLl9yX3NuID0gci5jX3NuCisgICAg ICAgICAgICBzZWxmLl9yeF9idWYuYXBwZW5kKGNocihyLmxlbmd0aCkpCisgICAgICAgIGVsaWYg ci5sZW5ndGg6CisgICAgICAgICAgICBzZWxmLl9yX3NuID0gci5jX3NuCisgICAgICAgICAgICBz ZWxmLl9yeF9idWYuYXBwZW5kKHIucGF5bG9hZCkKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAg IHJldHVybiBGYWxzZQorCisgICAgICAgICMgcmVhc3NlbWJsZQorICAgICAgICBpZiByLmNfZW9y OgorICAgICAgICAgICAgbG9nZ2luZy5pbmZvKCJSZWFzc2VtYmxpbmcgJWkgZnJhbWVzIiwgbGVu KHNlbGYuX3J4X2J1ZikpCisgICAgICAgICAgICBzZWxmLl9yeF9xdWV1ZS5hcHBlbmQoJycuam9p bihzZWxmLl9yeF9idWYpKQorICAgICAgICAgICAgc2VsZi5fcnhfYnVmID0gW10KKworICAgICAg ICBzID0gUmF0cFBhY2tldChmbGFncz0nQScpCisgICAgICAgIHMuY19zbiA9IHIuY19hbgorICAg ICAgICBzLmNfYW4gPSAoci5jX3NuICsgMSkgJSAyCisgICAgICAgIHNlbGYuX3dyaXRlKHMpCisg ICAgICAgIHJldHVybiBGYWxzZQorCisgICAgZGVmIF9tYWNoaW5lKHNlbGYsIHBrdCk6CisgICAg ICAgIGxvZ2dpbmcuaW5mbygiU3RhdGU6ICVyIiwgc2VsZi5fc3RhdGUpCisgICAgICAgIGlmIHNl bGYuX3N0YXRlID09IFJhdHBTdGF0ZS5saXN0ZW46CisgICAgICAgICAgICBzZWxmLl9hKHBrdCkK KyAgICAgICAgZWxpZiBzZWxmLl9zdGF0ZSA9PSBSYXRwU3RhdGUuc3luX3NlbnQ6CisgICAgICAg ICAgICBzZWxmLl9iKHBrdCkKKyAgICAgICAgZWxpZiBzZWxmLl9zdGF0ZSA9PSBSYXRwU3RhdGUu c3luX3JlY2VpdmVkOgorICAgICAgICAgICAgc2VsZi5fYzEocGt0KSBhbmQgXAorICAgICAgICAg ICAgICAgIHNlbGYuX2QxKHBrdCkgYW5kIFwKKyAgICAgICAgICAgICAgICBzZWxmLl9lKHBrdCkg YW5kIFwKKyAgICAgICAgICAgICAgICBzZWxmLl9mMShwa3QpIGFuZCBcCisgICAgICAgICAgICAg ICAgc2VsZi5faDEocGt0KQorICAgICAgICBlbGlmIHNlbGYuX3N0YXRlID09IFJhdHBTdGF0ZS5l c3RhYmxpc2hlZDoKKyAgICAgICAgICAgIHNlbGYuX2MyKHBrdCkgYW5kIFwKKyAgICAgICAgICAg ICAgICBzZWxmLl9kMihwa3QpIGFuZCBcCisgICAgICAgICAgICAgICAgc2VsZi5fZShwa3QpIGFu ZCBcCisgICAgICAgICAgICAgICAgc2VsZi5fZjIocGt0KSBhbmQgXAorICAgICAgICAgICAgICAg IHNlbGYuX2gyKHBrdCkgYW5kIFwKKyAgICAgICAgICAgICAgICBzZWxmLl9pMShwa3QpCisgICAg ICAgIGVsaWYgc2VsZi5fc3RhdGUgPT0gUmF0cFN0YXRlLmZpbl93YWl0OgorICAgICAgICAgICAg c2VsZi5fYzIocGt0KSBhbmQgXAorICAgICAgICAgICAgICAgIHNlbGYuX2QyKHBrdCkgYW5kIFwK KyAgICAgICAgICAgICAgICBzZWxmLl9lKHBrdCkgYW5kIFwKKyAgICAgICAgICAgICAgICBzZWxm Ll9mMyhwa3QpIGFuZCBcCisgICAgICAgICAgICAgICAgc2VsZi5faDMocGt0KQorICAgICAgICBl bGlmIHNlbGYuX3N0YXRlID09IFJhdHBTdGF0ZS5sYXN0X2FjazoKKyAgICAgICAgICAgIHNlbGYu X2MyKHBrdCkgYW5kIFwKKyAgICAgICAgICAgICAgICBzZWxmLl9kMyhwa3QpIGFuZCBcCisgICAg ICAgICAgICAgICAgc2VsZi5fZShwa3QpIGFuZCBcCisgICAgICAgICAgICAgICAgc2VsZi5fZjMo cGt0KSBhbmQgXAorICAgICAgICAgICAgICAgIHNlbGYuX2g0KHBrdCkKKyAgICAgICAgZWxpZiBz ZWxmLl9zdGF0ZSA9PSBSYXRwU3RhdGUuY2xvc2luZzoKKyAgICAgICAgICAgIHNlbGYuX2MyKHBr dCkgYW5kIFwKKyAgICAgICAgICAgICAgICBzZWxmLl9kMyhwa3QpIGFuZCBcCisgICAgICAgICAg ICAgICAgc2VsZi5fZShwa3QpIGFuZCBcCisgICAgICAgICAgICAgICAgc2VsZi5fZjMocGt0KSBh bmQgXAorICAgICAgICAgICAgICAgIHNlbGYuX2g1KHBrdCkKKyAgICAgICAgZWxpZiBzZWxmLl9z dGF0ZSA9PSBSYXRwU3RhdGUudGltZV93YWl0OgorICAgICAgICAgICAgc2VsZi5fZDMocGt0KSBh bmQgXAorICAgICAgICAgICAgICAgIHNlbGYuX2UocGt0KSBhbmQgXAorICAgICAgICAgICAgICAg IHNlbGYuX2YzKHBrdCkgYW5kIFwKKyAgICAgICAgICAgICAgICBzZWxmLl9oNihwa3QpCisgICAg ICAgIGVsaWYgc2VsZi5fc3RhdGUgPT0gUmF0cFN0YXRlLmNsb3NlZDoKKyAgICAgICAgICAgIHNl bGYuX2cocGt0KQorCisgICAgZGVmIHdhaXQoc2VsZiwgZGVhZGxpbmUpOgorICAgICAgICB3aGls ZSBkZWFkbGluZSBpcyBOb25lIG9yIGRlYWRsaW5lID4gbW9ub3RvbmljKCk6CisgICAgICAgICAg ICBwa3QgPSBzZWxmLl9yZWFkKCkKKyAgICAgICAgICAgIGlmIHBrdDoKKyAgICAgICAgICAgICAg ICBzZWxmLl9tYWNoaW5lKHBrdCkKKyAgICAgICAgICAgIGVsc2U6CisgICAgICAgICAgICAgICAg c2VsZi5fY2hlY2tfcnRvKCkKKyAgICAgICAgICAgICAgICBzZWxmLl9jaGVja190aW1lX3dhaXQo KQorICAgICAgICAgICAgaWYgbm90IHNlbGYuX3JldHJhbnMgb3Igc2VsZi5fcnhfcXVldWU6Cisg ICAgICAgICAgICAgICAgcmV0dXJuCisKKyAgICBkZWYgd2FpdDEoc2VsZiwgZGVhZGxpbmUpOgor ICAgICAgICB3aGlsZSBkZWFkbGluZSBpcyBOb25lIG9yIGRlYWRsaW5lID4gbW9ub3RvbmljKCk6 CisgICAgICAgICAgICBwa3QgPSBzZWxmLl9yZWFkKCkKKyAgICAgICAgICAgIGlmIHBrdDoKKyAg ICAgICAgICAgICAgICBzZWxmLl9tYWNoaW5lKHBrdCkKKyAgICAgICAgICAgIGVsc2U6CisgICAg ICAgICAgICAgICAgc2VsZi5fY2hlY2tfcnRvKCkKKyAgICAgICAgICAgICAgICBzZWxmLl9jaGVj a190aW1lX3dhaXQoKQorICAgICAgICAgICAgaWYgbm90IHNlbGYuX3JldHJhbnM6CisgICAgICAg ICAgICAgICAgcmV0dXJuCisKKyAgICBkZWYgbGlzdGVuKHNlbGYpOgorICAgICAgICBsb2dnaW5n LmluZm8oIkxJU1RFTiIpCisgICAgICAgIHNlbGYuX3N0YXRlID0gUmF0cFN0YXRlLmxpc3Rlbgor CisgICAgZGVmIGNvbm5lY3Qoc2VsZiwgdGltZW91dD01LjApOgorICAgICAgICBkZWFkbGluZSA9 IG1vbm90b25pYygpICsgdGltZW91dAorICAgICAgICBsb2dnaW5nLmluZm8oIkNPTk5FQ1QiKQor ICAgICAgICBzZWxmLl9yZXRyYW5zID0gTm9uZQorICAgICAgICBzeW4gPSBSYXRwUGFja2V0KGZs YWdzPSdTJykKKyAgICAgICAgc3luLmxlbmd0aCA9IHNlbGYuX3NfbWRsCisgICAgICAgIHNlbGYu X3dyaXRlKHN5bikKKyAgICAgICAgc2VsZi5fc3RhdGUgPSBSYXRwU3RhdGUuc3luX3NlbnQKKyAg ICAgICAgc2VsZi53YWl0KGRlYWRsaW5lKQorCisgICAgZGVmIHNlbmRfb25lKHNlbGYsIGRhdGEs IGVvcj1UcnVlLCB0aW1lb3V0PTEuMCk6CisgICAgICAgIGRlYWRsaW5lID0gbW9ub3RvbmljKCkg KyB0aW1lb3V0CisgICAgICAgIGxvZ2dpbmcuaW5mbygiU0VORF9PTkUgKGxlbj0laSwgZW9yPSVy KSIsIGxlbihkYXRhKSwgZW9yKQorICAgICAgICBhc3NlcnQgc2VsZi5fc3RhdGUgPT0gUmF0cFN0 YXRlLmVzdGFibGlzaGVkCisgICAgICAgIGFzc2VydCBzZWxmLl9yZXRyYW5zIGlzIE5vbmUKKyAg ICAgICAgc25kID0gUmF0cFBhY2tldChmbGFncz0nQScpCisgICAgICAgIHNuZC5jX2VvciA9IGVv cgorICAgICAgICBzbmQuY19zbiA9IChzZWxmLl9zX3NuICsgMSkgJSAyCisgICAgICAgIHNuZC5j X2FuID0gKHNlbGYuX3Jfc24gKyAxKSAlIDIKKyAgICAgICAgc25kLmxlbmd0aCA9IGxlbihkYXRh KQorICAgICAgICBzbmQucGF5bG9hZCA9IGRhdGEKKyAgICAgICAgc2VsZi5fd3JpdGUoc25kKQor ICAgICAgICBzZWxmLndhaXQxKGRlYWRsaW5lPU5vbmUpCisKKyAgICBkZWYgc2VuZChzZWxmLCBk YXRhLCB0aW1lb3V0PTEuMCk6CisgICAgICAgIGxvZ2dpbmcuaW5mbygiU0VORCAobGVuPSVpKSIs IGxlbihkYXRhKSkKKyAgICAgICAgd2hpbGUgbGVuKGRhdGEpID4gMjU1OgorICAgICAgICAgICAg c2VsZi5zZW5kX29uZShkYXRhWzoyNTVdLCBlb3I9RmFsc2UsIHRpbWVvdXQ9dGltZW91dCkKKyAg ICAgICAgICAgIGRhdGEgPSBkYXRhWzI1NTpdCisgICAgICAgIHNlbGYuc2V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ICAgc2VsZi53YWl0KGRlYWRsaW5lKQorICAgICAgICB3aGlsZSBzZWxmLl9zdGF0 ZSA9PSBSYXRwU3RhdGUudGltZV93YWl0OgorICAgICAgICAgICAgc2VsZi53YWl0KE5vbmUpCisg ICAgICAgIGlmIHNlbGYuX3N0YXRlID09IFJhdHBTdGF0ZS5jbG9zZWQ6CisgICAgICAgICAgICBs b2dnaW5nLmluZm8oIkNMT1NFOiBzdWNjZXNzIikKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAg IGxvZ2dpbmcuaW5mbygiQ0xPU0U6IGZhaWx1cmUiKQorCisKKyAgICBkZWYgYWJvcnQoc2VsZik6 CisgICAgICAgIGxvZ2dpbmcuaW5mbygiQUJPUlQiKQorCisgICAgZGVmIHN0YXR1cyhzZWxmKToK KyAgICAgICAgbG9nZ2luZy5pbmZvKCJTVEFUVVMiKQorICAgICAgICByZXR1cm4gc2VsZi5fc3Rh dGUKKworCitjbGFzcyBTZXJpYWxSYXRwQ29ubmVjdGlvbihSYXRwQ29ubmVjdGlvbik6CisgICAg ZGVmIF9faW5pdF9fKHNlbGYsIHBvcnQpOgorICAgICAgICBzdXBlcihTZXJpYWxSYXRwQ29ubmVj dGlvbiwgc2VsZikuX19pbml0X18oKQorICAgICAgICBzZWxmLl9fcG9ydCA9IHBvcnQKKyAgICAg ICAgc2VsZi5fX3BvcnQudGltZW91dCA9IDAuMDEKKyAgICAgICAgc2VsZi5fX3BvcnQud3JpdGVU aW1lb3V0ID0gTm9uZQorICAgICAgICBzZWxmLl9fcG9ydC5mbHVzaElucHV0KCkKKworICAgIGRl ZiBfd3JpdGVfcmF3KHNlbGYsIGRhdGEpOgorICAgICAgICBpZiBkYXRhOgorICAgICAgICAgICAg bG9nZ2luZy5kZWJ1ZygiLT4gJXIiLCBieXRlYXJyYXkoZGF0YSkpCisgICAgICAgIHJldHVybiBz ZWxmLl9fcG9ydC53cml0ZShkYXRhKQorCisgICAgZGVmIF9yZWFkX3JhdyhzZWxmLCBz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IHdyaXRlX2NhbGwgPSAxMQorICAgIHdyaXRlX3JldHVybiA9 IDEyCisgICAgY2xvc2VfY2FsbCA9IDEzCisgICAgY2xvc2VfcmV0dXJuID0gMTQKKyAgICB0cnVu Y2F0ZV9jYWxsID0gMTUKKyAgICB0cnVuY2F0ZV9yZXR1cm4gPSAxNgorCisKK2NsYXNzIFJhdHBG U0Vycm9yKFZhbHVlRXJyb3IpOgorICAgIHBhc3MKKworCitjbGFzcyBSYXRwRlNQYWNrZXQob2Jq ZWN0KToKKyAgICBkZWYgX19pbml0X18oc2VsZiwgdHlwZT1SYXRwRlNUeXBlLmludmFsaWQsIHBh eWxvYWQ9IiIsIHJhdz1Ob25lKToKKyAgICAgICAgaWYgcmF3IGlzIG5vdCBOb25lOgorICAgICAg ICAgICAgdHlwZSwgPSBzdHJ1Y3QudW5wYWNrKCchQicsIHJhd1s6MV0pCisgICAgICAgICAgICBz ZWxmLnR5cGUgPSBSYXRwRlNUeXBlKHR5cGUpCisgICAgICAgICAgICBzZWxmLnBheWxvYWQgPSBy YXdbMTpdCisgICAgICAgIGVsc2U6CisgICAgICAgICAgICBzZWxmLnR5cGUgPSB0eXBlCisgICAg ICAgICAgICBzZWxmLnBheWxvYWQgPSBwYXlsb2FkCisKKyAgICBkZWYgX19yZXByX18oc2VsZik6 CisgICAgICAgIHMgPSAiJXMoIiAlIHNlbGYuX19jbGFzc19fLl9fbmFtZV9fCisgICAgICAgIHMg Kz0gIlRZUEU9JWksIiAlIHNlbGYudHlwZQorICAgICAgICBzICs9ICJQQVlMT0FEPSVzKSIgJSBy ZXByKHNlbGYucGF5bG9hZCkKKyAgICAgICAgcmV0dXJuIHMKKworICAgIGRlZiBwYWNrKHNlbGYp OgorICAgICAgICByZXR1cm4gc3RydWN0LnBhY2soJyFCJywgaW50KHNlbGYudHlwZSkpK3NlbGYu cGF5bG9hZAorCisKK2NsYXNzIFJhdHBGU1NlcnZlcihvYmplY3QpOgorICAgIGRlZiBfX2luaXRf XyhzZWxmLCBwYXRoPU5vbmUpOgorICAgICAgICBzZWxmLnBhdGggPSBwYXRoCisgICAgICAgIGlm IHBhdGg6CisgICAgICAgICAgICBzZWxmLnBhdGggPSBvcy5wYXRoLmFic3BhdGgocGF0aCkKKyAg ICAgICAgc2VsZi5uZXh0X2hhbmRsZSA9IDEgICMgMCBpcyBpbnZhbGlkCisgICAgICAgIHNlbGYu ZmlsZXMgPSB7fQorICAgICAgICBzZWxmLm1vdW50ZWQgPSBGYWxzZQorICAgICAgICBsb2dnaW5n LmluZm8oImV4cG9ydGluZzogJXMiLCBzZWxmLnBhdGgpCisKKyAgICBkZWYgX2FsbG9jX2hhbmRs ZShzZWxmKToKKyAgICAgICAgaGFuZGxlID0gc2VsZi5uZXh0X2hhbmRsZQorICAgICAgICBzZWxm Lm5leHRfaGFuZGxlICs9IDEKKyAgICAgICAgcmV0dXJuIGhhbmRsZQorCisgICAgZGVmIF9yZXNv bHZlKHNlbGYsIHBhdGgpOgorICAgICAgICBjb21wb25lbnRzID0gcGF0aC5zcGxpdCgnLycpCisg ICAgICAgIGNvbXBvbmVudHMgPSBbeCBmb3IgeCBpbiBjb21wb25lbnRzIGlmIHggYW5kIHggIT0g Jy4uJ10KKyAgICAgICAgcmV0dXJuIG9zLnBhdGguam9pbihzZWxmLnBhdGgsICpjb21wb25lbnRz KQorCisgICAgZGVmIGhhbmRsZV9zdGF0KHNlbGYsIHBhdGgpOgorCisgICAgICAgIHRyeToKKyAg ICAgICAgICAgIGxvZ2dpbmcuaW5mbygicGF0aDogJXIiLCBwYXRoKQorICAgICAgICAgICAgcGF0 aCA9IHNlbGYuX3Jlc29sdmUocGF0aCkKKyAgICAgICAgICAgIGxvZ2dpbmcuaW5mbygicGF0aDE6 ICVyIiwgcGF0aCkKKyAgICAgICAgICAgIHMgPSBvcy5zdGF0KHBhdGgpCisgICAgICAgIGV4Y2Vw dCBPU0Vycm9yIGFzIGU6CisgICAgICAgICAgICByZXR1cm4gc3RydWN0LnBhY2soJyFCSScsIDAs IGUuZXJybm8pCisgICAgICAgIGlmIHN0YXQuU19JU1JFRyhzLnN0X21vZGUpOgorICAgICAgICAg ICAgcmV0dXJuIHN0cnVjdC5wYWNrKCchQkknLCAxLCBzLnN0X3NpemUpCisgICAgICAgIGVsaWYg c3RhdC5TX0lTRElSKHMuc3RfbW9kZSk6CisgICAgICAgICAgICByZXR1cm4gc3RydWN0LnBhY2so JyFCSScsIDIsIHMuc3Rfc2l6ZSkKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgIHJldHVybiBz dHJ1Y3QucGFjaygnIUJJJywgMCwgMCkKKworICAgIGRlZiBoYW5kbGVfb3BlbihzZWxmLCBwYXJh bXMpOgorICAgICAgICBmbGFncywgPSBzdHJ1Y3QudW5wYWNrKCchSScsIHBhcmFtc1s6NF0pCisg ICAgICAgIGZsYWdzID0gZmxhZ3MgJiAob3MuT19SRE9OTFkgfCBvcy5PX1dST05MWSB8IG9zLk9f UkRXUiB8IG9zLk9fQ1JFQVQgfAorICAgICAgICAgICAgICAgICAgICAgICAgIG9zLk9fVFJVTkMp CisgICAgICAgIHBhdGggPSBwYXJhbXNbNDpdCisgICAgICAgIHRyeToKKyAgICAgICAgICAgIGYg PSBvcy5vcGVuKHNlbGYuX3Jlc29sdmUocGF0aCksIGZsYWdzLCAwNjY2KQorICAgICAgICBleGNl cHQgT1NFcnJvciBhcyBlOgorICAgICAgICAgICAgcmV0dXJuIHN0cnVjdC5wYWNrKCchSUknLCAw LCBlLmVycm5vKQorICAgICAgICBoID0gc2VsZi5fYWxsb2NfaGFuZGxlKCkKKyAgICAgICAgc2Vs Zi5maWxlc1toXSA9IGYKKyAgICAgICAgc2l6ZSA9IG9zLmxzZWVrKGYsIDAsIG9zLlNFRUtfRU5E KQorICAgICAgICByZXR1cm4gc3RydWN0LnBhY2soJyFJSScsIGgsIHNpemUpCisKKyAgICBkZWYg aGFuZGxlX3JlYWQoc2VsZiwgcGFyYW1zKToKKyAgICAgICAgaCwgcG9zLCBzaXplID0gc3RydWN0 LnVucGFjaygnIUlJSScsIHBhcmFtcykKKyAgICAgICAgZiA9IHNlbGYuZmlsZXNbaF0KKyAgICAg ICAgb3MubHNlZWsoZiwgcG9zLCBvcy5TRUVLX1NFVCkKKyAgICAgICAgc2l6ZSA9IG1pbihzaXpl LCA0MDk2KQorICAgICAgICByZXR1cm4gb3MucmVhZChmLCBzaXplKQorCisgICAgZGVmIGhhbmRs ZV93cml0ZShzZWxmLCBwYXJhbXMpOgorICAgICAgICBoLCBwb3MgPSBzdHJ1Y3QudW5wYWNrKCch SUknLCBwYXJhbXNbOjhdKQorICAgICAgICBwYXlsb2FkID0gcGFyYW1zWzg6XQorICAgICAgICBm ID0gc2VsZi5maWxlc1toXQorICAgICAgICBwb3MgPSBvcy5sc2VlayhmLCBwb3MsIG9zLlNFRUtf U0VUKQorICAgICAgICBhc3NlcnQgb3Mud3JpdGUoZiwgcGF5bG9hZCkgPT0gbGVuKHBheWxvYWQp CisgICAgICAgIHJldHVybiAiIgorCisgICAgZGVmIGhhbmRsZV9yZWFkZGlyKHNlbGYsIHBhdGgp OgorICAgICAgICByZXMgPSAiIgorICAgICAgICBmb3IgeCBpbiBvcy5saXN0ZGlyKHNlbGYuX3Jl c29sdmUocGF0aCkpOgorICAgICAgICAgICAgcmVzICs9IHgrJ1wwJworICAgICAgICByZXR1cm4g cmVzCisKKyAgICBkZWYgaGFuZGxlX2Nsb3NlKHNlbGYsIHBhcmFtcyk6CisgICAgICAgIGgsID0g c3RydWN0LnVucGFjaygnIUknLCBwYXJhbXNbOjRdKQorICAgICAgICBvcy5jbG9zZShzZWxmLmZp bGVzLnBvcChoKSkKKyAgICAgICAgcmV0dXJuICIiCisKKyAgICBkZWYgaGFuZGxlX3RydW5jYXRl KHNlbGYsIHBhcmFtcyk6CisgICAgICAgIGgsIHNpemUgPSBzdHJ1Y3QudW5wYWNrKCchSUknLCBw YXJhbXMpCisgICAgICAgIGYgPSBzZWxmLmZpbGVzW2hdCisgICAgICA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gICAgICAgZnNyZXR1cm4gPSBSYXRwRlNQYWNrZXQodHlwZT1SYXRw RlNUeXBlLnJlYWRkaXJfcmV0dXJuLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgcGF5bG9hZD1wYXlsb2FkKQorICAgICAgICBlbGlmIGZzY2FsbC50eXBlID09IFJhdHBGU1R5 cGUuc3RhdF9jYWxsOgorICAgICAgICAgICAgcGF5bG9hZCA9IHNlbGYuaGFuZGxlX3N0YXQoZnNj YWxsLnBheWxvYWQpCisgICAgICAgICAgICBmc3JldHVybiA9IFJhdHBGU1BhY2tldCh0eXBlPVJh dHBGU1R5cGUuc3RhdF9yZXR1cm4sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBwYXlsb2FkPXBheWxvYWQpCisgICAgICAgIGVsaWYgZnNjYWxsLnR5cGUgPT0gUmF0cEZTVHlw ZS5vcGVuX2NhbGw6CisgICAgICAgICAgICBwYXlsb2FkID0gc2VsZi5oYW5kbGVfb3Blbihmc2Nh bGwucGF5bG9hZCkKKyAgICAgICAgICAgIGZzcmV0dXJuID0gUmF0cEZTUGFja2V0KHR5cGU9UmF0 cEZTVHlwZS5vcGVuX3JldHVybiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IHBheWxvYWQ9cGF5bG9hZCkKKyAgICAgICAgZWxpZiBmc2NhbGwudHlwZSA9PSBSYXRwRlNUeXBl LnJlYWRfY2FsbDoKKyAgICAgICAgICAgIHBheWxvYWQgPSBzZWxmLmhhbmRsZV9yZWFkKGZzY2Fs bC5wYXlsb2FkKQorICAgICAgICAgICAgZnNyZXR1cm4gPSBSYXRwRlNQYWNrZXQodHlwZT1SYXRw RlNUeXBlLnJlYWRfcmV0dXJuLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg cGF5bG9hZD1wYXlsb2FkKQorICAgICAgICBlbGlmIGZzY2FsbC50eXBlID09IFJhdHBGU1R5cGUu d3JpdGVfY2FsbDoKKyAgICAgICAgICAgIHBheWxvYWQgPSBzZWxmLmhhbmRsZV93cml0ZShmc2Nh bGwucGF5bG9hZCkKKyAgICAgICAgICAgIGZzcmV0dXJuID0gUmF0cEZTUGFja2V0KHR5cGU9UmF0 cEZTVHlwZS53cml0ZV9yZXR1cm4sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBwYXlsb2FkPXBheWxvYWQpCisgICAgICAgIGVsaWYgZnNjYWxsLnR5cGUgPT0gUmF0cEZTVHlw ZS5jbG9zZV9jYWxsOgorICAgICAgICAgICAgcGF5bG9hZCA9IHNlbGYuaGFuZGxlX2Nsb3NlKGZz Y2FsbC5wYXlsb2FkKQorICAgICAgICAgICAgZnNyZXR1cm4gPSBSYXRwRlNQYWNrZXQodHlwZT1S YXRwRlNUeXBlLmNsb3NlX3JldHVybiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIHBheWxvYWQ9cGF5bG9hZCkKKyAgICAgICAgZWxpZiBmc2NhbGwudHlwZSA9PSBSYXRwRlNU eXBlLnRydW5jYXRlX2NhbGw6CisgICAgICAgICAgICBwYXlsb2FkID0gc2VsZi5oYW5kbGVfdHJ1 bmNhdGUoZnNjYWxsLnBheWxvYWQpCisgICAgICAgICAgICBmc3JldHVybiA9IFJhdHBGU1BhY2tl dCh0eXBlPVJhdHBGU1R5cGUudHJ1bmNhdGVfcmV0dXJuLAorICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgcGF5bG9hZD1wYXlsb2FkKQorICAgICAgICBlbHNlOgorICAgICAgICAg ICAgcmFpc2UgUmF0cEZTRXJyb3IoKQorCisgICAgICAgIGxvZ2dpbmcuaW5mbygiZnMtcmV0dXJu OiAlcyIsIGZzcmV0dXJuKQorICAgICAgICBiYnJldHVybiA9IEJCUGFja2V0RlNSZXR1cm4ocGF5 bG9hZD1mc3JldHVybi5wYWNrKCkpCisgICAgICAgIGxvZ2dpbmcuZGVidWcoImJiLXJldHVybj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KKyAgICAgICAgdGVybWlvcy50Y3NldGF0dHIoc2VsZi5mZCwgdGVy bWlvcy5UQ1NBTk9XLCBuZXcpCisKKyAgICAgICAgZGVmIGNsZWFudXAoKToKKyAgICAgICAgICAg IHRlcm1pb3MudGNzZXRhdHRyKHNlbGYuZmQsIHRlcm1pb3MuVENTQUZMVVNILCBvbGQpCisgICAg ICAgIGF0ZXhpdC5yZWdpc3RlcihjbGVhbnVwKQorCisgICAgZGVmIHJ1bihzZWxmKToKKyAgICAg ICAgd2hpbGUgVHJ1ZToKKyAgICAgICAgICAgIGMgPSBvcy5yZWFkKHNlbGYuZmQsIDEpCisgICAg ICAgICAgICBpZiBjID09IHNlbGYuX2V4aXQ6CisgICAgICAgICAgICAgICAgc2VsZi5xLnB1dCgo c2VsZiwgTm9uZSkpCisgICAgICAgICAgICAgICAgcmV0dXJuCisgICAgICAgICAgICBlbHNlOgor ICAgICAgICAgICAgICAgIHNlbGYucS5wdXQoKHNlbGYsIGMpKQorCitpZiBfX25hbWVfXyA9PSAi X19tYWluX18iOgorICAgIHEgPSBRdWV1ZSgpCisgICAgaSA9IENvbnNvbGVJbnB1dChxKQorICAg IGkuc3RhcnQoKQorICAgIHdoaWxlIFRydWU6CisgICAgICAgIGV2ZW50ID0gcS5nZXQoYmxvY2s9 VHJ1ZSkKKyAgICAgICAgc3JjLCBjID0gZXZlbnQKKyAgICAgICAgaWYgYyA9PSAnXHgwNCc6Cisg ICAgICAgICAgICBicmVhaworICAgICAgICBvcy53cml0ZShzeXMuc3Rkb3V0LmZpbGVubygpLCBj LnVwcGVyKCkpCisKLS0gCjIuNi40CgoKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX18KYmFyZWJveCBtYWlsaW5nIGxpc3QKYmFyZWJveEBsaXN0cy5pbmZyYWRl YWQub3JnCmh0dHA6Ly9saXN0cy5pbmZyYWRlYWQub3JnL21haWxtYW4vbGlzdGluZm8vYmFyZWJv eAo=