{"id":2224587,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2224587/?format=json","web_url":"http://patchwork.ozlabs.org/project/swupdate/patch/20260417155704.2758672-2-hyyoxhk@163.com/","project":{"id":58,"url":"http://patchwork.ozlabs.org/api/1.2/projects/58/?format=json","name":"swupdate development","link_name":"swupdate","list_id":"swupdate.googlegroups.com","list_email":"swupdate@googlegroups.com","web_url":"https://github.com/sbabic/swupdate","scm_url":"git://github.com/sbabic/swupdate","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260417155704.2758672-2-hyyoxhk@163.com>","list_archive_url":null,"date":"2026-04-17T15:57:01","name":"[v1,1/4] util: add compressed-string parser and img setter macros","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"12be7628e8a75baac4d1af0832f8cd6430480060","submitter":{"id":79707,"url":"http://patchwork.ozlabs.org/api/1.2/people/79707/?format=json","name":"He Yong","email":"hyyoxhk@163.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/swupdate/patch/20260417155704.2758672-2-hyyoxhk@163.com/mbox/","series":[{"id":500374,"url":"http://patchwork.ozlabs.org/api/1.2/series/500374/?format=json","web_url":"http://patchwork.ozlabs.org/project/swupdate/list/?series=500374","date":"2026-04-17T15:57:01","name":"Refactor image parsing and add LZ4 support","version":1,"mbox":"http://patchwork.ozlabs.org/series/500374/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224587/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2224587/checks/","tags":{},"related":[],"headers":{"Return-Path":"<swupdate+bncBAABB4OGRHHQMGQEILHTFNY@googlegroups.com>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=googlegroups.com header.i=@googlegroups.com\n header.a=rsa-sha256 header.s=20251104 header.b=AhcTkSHr;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com\n (client-ip=2607:f8b0:4864:20::f39; helo=mail-qv1-xf39.google.com;\n envelope-from=swupdate+bncbaabb4ogrhhqmgqeilhtfny@googlegroups.com;\n receiver=patchwork.ozlabs.org)"],"Received":["from mail-qv1-xf39.google.com (mail-qv1-xf39.google.com\n [IPv6:2607:f8b0:4864:20::f39])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fy1203yt6z1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 02:44:39 +1000 (AEST)","by mail-qv1-xf39.google.com with SMTP id\n 6a1803df08f44-8a22dbeeb96sf17611026d6.3\n        for <incoming@patchwork.ozlabs.org>;\n Fri, 17 Apr 2026 09:44:38 -0700 (PDT)","by 2002:a05:6214:27cd:b0:8ac:7f7d:4a02 with SMTP id\n 6a1803df08f44-8ae820ab4cals37369176d6.1.-pod-prod-03-us; Fri, 17 Apr 2026\n 09:44:32 -0700 (PDT)","by 2002:a05:620a:a389:b0:8d0:26c1:4847 with SMTP id\n af79cd13be357-8e7927564b3ms85a;\n        Fri, 17 Apr 2026 08:57:13 -0700 (PDT)","from m16.mail.163.com (m16.mail.163.com. [220.197.31.3])\n        by gmr-mx.google.com with ESMTPS id\n 6a1803df08f44-8b032082b57si35916d6.0.2026.04.17.08.57.10\n        for <swupdate@googlegroups.com>\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Fri, 17 Apr 2026 08:57:12 -0700 (PDT)","from nh50.. (unknown [])\n\tby gzga-smtp-mtada-g0-1 (Coremail) with SMTP id\n _____wAXpIlQWOJpw1HjAA--.43368S3;\n\tFri, 17 Apr 2026 23:57:04 +0800 (CST)"],"ARC-Seal":["i=2; a=rsa-sha256; t=1776444276; cv=pass;\n        d=google.com; s=arc-20240605;\n        b=CXQHzeoC1k778g31OkLIereuk6p5O8Q//DARB0Bi5SXhUPrt41J+++z4XKUcMkE+9D\n         /OGnOqA1cUUIlza2sceDQmJfplQPVzYbhlqy1QRIiuu+aZBNqBtCUdpG7neMgttbIyei\n         Q2uguK4nSoMpJPqi/dB+wlWTYhHcjWqJv8e3TeLH8DIMnuiufSk4KR6Cb+YshiczbjAa\n         xHf7zZ2nlCVve6xEwyJ6R3sZQ/QKmIu+idFsHxf8YvA1f0LlwC6QH0TT2zJ0z8OM4AYw\n         VKHs0It28q1OllJ0UmgaSw3MZzEF/Mv6mK6XhQJyNluoxiqSrzTRDJqBPaFQd4RR9Gem\n         I+ug==","i=1; a=rsa-sha256; t=1776441432; cv=none;\n        d=google.com; s=arc-20240605;\n        b=jiG7qbQYKndKunQZvxPeBIUiQrNyOPeGSF4wA7tGYxqtF7Bss5lE5xf/qamyUDQOGx\n         xAjiOOJjGjhwWdiUoTxiXuocJip9h7JsqiiYBKTMTd22v6ZV7mhD+lQagRv9RWxObYAo\n         y/ity/m3cPzel4ieKgdaInXZPryLmlEseigRy06sNyjptkIEuvYJdUQ6AfEqgUF4y7bx\n         I0mR/TDBvHY2Y1uUqjJOW1ZmjYj/tnfcTR4j/KxXP0+eQlZLFLh7ZvqHpi3G05AsB142\n         GMgvmmRmT7mKbweMVHA4wHc2aNCTvBEKSW7eiIl/HNUfb+oqhDJq2/EWyA4ifElAS65a\n         1O5w=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n         :list-id:mailing-list:precedence:mime-version:references:in-reply-to\n         :message-id:date:subject:to:from:sender:dkim-signature;\n        bh=MtBk+G7O/01SJaG+bipApy99iF5C6AT+FAfYnVKA0bA=;\n        fh=f0o+AiCii8bre4qpMX72JiKrK096psVhrPuvR0xmEP4=;\n        b=iF7MVvy+I/SeUme8KWWauOKc7rEd+vR/ZTbVEscJjR1Ny5AGbFPs1s18ZOgQSG9Sd5\n         DTguK1UEOKbK1oS0Tqm7fHVhBxO5HI96cEkApIeyHsgWZ6Lgp3xMJyHJFyIR+EIpQNDm\n         FGM2kBHA1RAljuTslN7nHWptMx8VH/oQ4VwfUIjHk07U2fnlPQzwyEA3URt6FV13FfNY\n         Yb6MtyWSDVSoD7osKemsYFPTSoA+ERahEYsLWU8lwwn0FMQn0x3ywEIagqw2gkSpaYGB\n         KC9eSQX18yf15f87o2BsE9Y+p4S1q3qeAMHZ5ZU3FkPN1/1hbeloToEaNDYXbIuZe0E8\n         9vwA==;\n        darn=patchwork.ozlabs.org","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:to:from:dkim-signature;\n        bh=qqBdEjsvJIICpGLP5zSJqqgffDLMT635Je+ON0qxisQ=;\n        fh=nvZsCFpxgpf+fsVXzjnWA8g1K3V/kNbRAKogjNDW4HY=;\n        b=KgLS+A9DDe/OEYzmgDwdmlIaRdCzG/ZjGVrTqbG2Ra05FEgirRUKVpZoDVYAsBHatI\n         m7NcNF9Ktb0wgEvz/E13bYTiVZpHizAqIQvkCafe/l0dsYIhxb0JGQyOh2sd8NuPBqui\n         4i6DVoIZRhK+/0J69kSjcYZcpxDYjGJgUBjpf1p7d9oKIcLT0pEY3J3FkXNUo1YmIz6b\n         yUg+aqsoOE9RCT8bvdi9MbE4417pUCKGzeqYN2VWLL3ugWqwfd6Tsf1egHrLKqfF7DBq\n         9vBsMcBpMjsA26kpdnzurayNw01AKzW3tgdRbCbrqF2Dtneh/GZHaIa+blrsbgCg+kDq\n         4L4w==;\n        dara=google.com"],"ARC-Authentication-Results":["i=2; gmr-mx.google.com;\n       dkim=pass header.i=@163.com header.s=s110527 header.b=kTB7pWPj;\n       spf=pass (google.com: domain of hyyoxhk@163.com designates 220.197.31.3\n as permitted sender) smtp.mailfrom=hyyoxhk@163.com;\n       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com","i=1; gmr-mx.google.com;\n       dkim=pass header.i=@163.com header.s=s110527 header.b=kTB7pWPj;\n       spf=pass (google.com: domain of hyyoxhk@163.com designates 220.197.31.3\n as permitted sender) smtp.mailfrom=hyyoxhk@163.com;\n       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=googlegroups.com; s=20251104; t=1776444276; x=1777049076;\n darn=patchwork.ozlabs.org;\n        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n         :list-id:mailing-list:precedence:x-original-authentication-results\n         :x-original-sender:mime-version:references:in-reply-to:message-id\n         :date:subject:to:from:sender:from:to:cc:subject:date:message-id\n         :reply-to;\n        bh=MtBk+G7O/01SJaG+bipApy99iF5C6AT+FAfYnVKA0bA=;\n        b=AhcTkSHrZRXnnMWYQoAcRkXOVYhek+d4ofZELgQhCyomll8I3qCg9d4JxLXslY+5dD\n         rI9byZCMid/UcsVd2QyrGQTDoQm8VGRPYPFj5OEIJHxPEO7mPGD5qHhxUhikFCyGs67i\n         mSZytRa+xTM3gHVGJyB1hCGNYbj2RYC9+21LLmCNhmvyzvFfHlpprY9ahZprtPT9isun\n         g3JaE+WObUKCVS+CJsqlFPZFaQFCQSL/Y61SSPrenxWh+YXjuyi5zJGV4lcHn2arnkeG\n         Mpq0zT4yo6R2Gtukh3aZpzlAXsoSuMX21yz/vUAvF2yIfXMWAx7hHBUW0jRt5YzBiwdd\n         11ag==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776444276; x=1777049076;\n        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n         :list-id:mailing-list:precedence:x-original-authentication-results\n         :x-original-sender:mime-version:references:in-reply-to:message-id\n         :date:subject:to:from:x-beenthere:x-gm-message-state:sender:from:to\n         :cc:subject:date:message-id:reply-to;\n        bh=MtBk+G7O/01SJaG+bipApy99iF5C6AT+FAfYnVKA0bA=;\n        b=TTuuXBtllq8V5fCHjra/2MNB74lvaZFr34KjxIqgylZHkfEhRJZGUtdqVeXKnQqBU9\n         ogdJXXzfEp0wbFcUPZQ9f+5GikbgDhAC5ayBu63YD7MRykxkMYpo/oRqdTMN5IXeSsR1\n         LI9LcPiyroFsMxXZLm2IpBjCPaoUlnA0+T/c+LqNOWuo4J8Ml/ljnLiA0VTcDPKDGOUd\n         KeNAw7rnBsu/2B+lDPkEgmke/QlpusyXnXWQMqDlliyVSTSTQURtRTx3qIvYPNtl6J8U\n         ZHhxMSFCJRWml0AUSzO83zPdUgsN3mAjVR+IZS1gkH3VFBXVI7pxSXGBSXC/3ocnEAcg\n         fj9A==","Sender":"swupdate@googlegroups.com","X-Forwarded-Encrypted":"i=2;\n AFNElJ/zbRctfVQxr4UWG0spYZ2DcgOvmStlm197FfMezOIodgEGKViHrCBkFLQ2IW9z+VmazK0qrvxjhA==@patchwork.ozlabs.org","X-Gm-Message-State":"AOJu0YyJbdhNlwv7D/c/RKalSDpp9T/ap3TcSNSQnDqHonRHcHOTojYd\n\tVD7+B4jF346UEa4VX4RpNGyh/nXf4zIB09f2286QAq1F1nXwjhWPwhca","X-Received":["by 2002:a05:6214:4019:b0:89c:da2b:4903 with SMTP id\n 6a1803df08f44-8b02822c9cfmr54542946d6.46.1776444274857;\n        Fri, 17 Apr 2026 09:44:34 -0700 (PDT)","by 2002:a05:620a:c54:b0:8db:86d:3cf5 with SMTP id\n af79cd13be357-8e78f82b3eamr477733185a.6.1776444272837;\n        Fri, 17 Apr 2026 09:44:32 -0700 (PDT)","by 2002:ad4:5d63:0:b0:89c:e371:2b3d with SMTP id\n 6a1803df08f44-8b028226f8cmr53997806d6.45.1776441432923;\n        Fri, 17 Apr 2026 08:57:12 -0700 (PDT)"],"X-BeenThere":"swupdate@googlegroups.com;\n h=\"AYAyTiLv9+yzvTCxGZYnPkNhHOCCQ5V1rsajoaaUZHE3zWpzDA==\"","Received-SPF":"pass (google.com: domain of hyyoxhk@163.com designates\n 220.197.31.3 as permitted sender) client-ip=220.197.31.3;","From":"He Yong <hyyoxhk@163.com>","To":"swupdate@googlegroups.com","Subject":"[swupdate] [PATCH v1 1/4] util: add compressed-string parser and img\n setter macros","Date":"Fri, 17 Apr 2026 23:57:01 +0800","Message-ID":"<20260417155704.2758672-2-hyyoxhk@163.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260417155704.2758672-1-hyyoxhk@163.com>","References":"<20260417155704.2758672-1-hyyoxhk@163.com>","MIME-Version":"1.0","X-CM-TRANSID":"_____wAXpIlQWOJpw1HjAA--.43368S3","X-Coremail-Antispam":"1Uf129KBjvJXoW7CrW3Ar43uF43tr13Gw1fCrg_yoW8tF4Upa\n\t1kXry5CF1fXFnruFW3tFnIga13Xr48Gry2k39rXr1qyF90q34vqrWxKF4YvFy5GrWvg39x\n\tZFsIg345Cw18tw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n\t9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U7cTQUUUUU=","X-Originating-IP":"[2408:8266:bb01:57f4:788f:a08d:bbc4:eabb]","X-CM-SenderInfo":"pk1105lkn6il2tof0z/xtbC8RA9EGniWFC22QAA3g","X-Original-Sender":"hyyoxhk@163.com","X-Original-Authentication-Results":"gmr-mx.google.com;       dkim=pass\n header.i=@163.com header.s=s110527 header.b=kTB7pWPj;       spf=pass\n (google.com: domain of hyyoxhk@163.com designates 220.197.31.3 as permitted\n sender) smtp.mailfrom=hyyoxhk@163.com;       dmarc=pass (p=NONE sp=NONE\n dis=NONE) header.from=163.com","Content-Type":"text/plain; charset=\"UTF-8\"","Precedence":"list","Mailing-list":"list swupdate@googlegroups.com;\n contact swupdate+owners@googlegroups.com","List-ID":"<swupdate.googlegroups.com>","X-Google-Group-Id":"605343134186","List-Post":"<https://groups.google.com/group/swupdate/post>,\n <mailto:swupdate@googlegroups.com>","List-Help":"<https://groups.google.com/support/>,\n <mailto:swupdate+help@googlegroups.com>","List-Archive":"<https://groups.google.com/group/swupdate","List-Subscribe":"<https://groups.google.com/group/swupdate/subscribe>,\n <mailto:swupdate+subscribe@googlegroups.com>","List-Unsubscribe":"\n <mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>,\n <https://groups.google.com/group/swupdate/subscribe>"},"content":"Add a shared helper to convert compressed strings to internal type values,\nand introduce reusable image setter macros used by parser and Lua mapping code.\n\nSigned-off-by: He Yong <hyyoxhk@163.com>\n---\n core/util.c    | 22 ++++++++++++++++++++++\n include/util.h | 18 ++++++++++++++++++\n 2 files changed, 40 insertions(+)","diff":"diff --git a/core/util.c b/core/util.c\nindex 3f62e070..89046f3c 100644\n--- a/core/util.c\n+++ b/core/util.c\n@@ -76,6 +76,28 @@ int ascii_to_bin(unsigned char *dest, size_t dstlen, const char *src)\n \treturn 0;\n }\n \n+static const struct {\n+\tconst char *name;\n+\tint type;\n+} compressed_by_name[] = {\n+\t{ \"zlib\", COMPRESSED_ZLIB },\n+\t{ \"xz\", COMPRESSED_XZ },\n+\t{ \"zstd\", COMPRESSED_ZSTD },\n+};\n+\n+int compressed_string_to_type(const char *s, int *out_type)\n+{\n+\tsize_t i;\n+\n+\tfor (i = 0; i < ARRAY_SIZE(compressed_by_name); i++) {\n+\t\tif (!strcmp(s, compressed_by_name[i].name)) {\n+\t\t\t*out_type = compressed_by_name[i].type;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\treturn -1;\n+}\n+\n static int countargc(char *args, char **argv)\n {\n \tint count = 0;\ndiff --git a/include/util.h b/include/util.h\nindex d4874f64..dcd0604c 100644\n--- a/include/util.h\n+++ b/include/util.h\n@@ -184,6 +184,23 @@ void notifier_set_color(int level, char *col);\n \tp = strdup(v); \\\n } while (0)\n \n+#define DEFINE_IMG_STRLCPY_SETTER(_name, _field) \\\n+static void _name(struct img_type *img, const char *value) \\\n+{ \\\n+\tstrlcpy(img->_field, value, sizeof(img->_field)); \\\n+}\n+\n+#define DEFINE_IMG_BOOL_SETTER(_name, _field) \\\n+static void _name(struct img_type *img, bool val) \\\n+{ \\\n+\timg->_field = (bool)val; \\\n+}\n+\n+#define DEFINE_IMG_NUMBER_SETTER(_name, _field, _type) \\\n+static void _name(struct img_type *img, double val) \\\n+{ \\\n+\timg->_field = (_type)val; \\\n+}\n \n #define IS_STR_EQUAL(s,s1) (s && s1 && !strcmp(s,s1))\n #define UNUSED __attribute__((__unused__))\n@@ -197,6 +214,7 @@ int ascii_to_bin(unsigned char *dest, size_t dstlen, const char *src);\n void hash_to_ascii(const unsigned char *hash, char *s);\n int IsValidHash(const unsigned char *hash);\n bool is_hex_str(const char *ascii);\n+int compressed_string_to_type(const char *s, int *out_type);\n \n #ifndef typeof\n #define typeof __typeof__\n","prefixes":["v1","1/4"]}