Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2224592/?format=api
{ "id": 2224592, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2224592/?format=api", "web_url": "http://patchwork.ozlabs.org/project/swupdate/patch/20260417161524.2806435-3-hyyoxhk@163.com/", "project": { "id": 58, "url": "http://patchwork.ozlabs.org/api/1.2/projects/58/?format=api", "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": "<20260417161524.2806435-3-hyyoxhk@163.com>", "list_archive_url": null, "date": "2026-04-17T16:15:22", "name": "[v1,2/4] parser: refactor stream attribute parsing", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "8b737c0071a2a0d48f84f1f996debc34eb553065", "submitter": { "id": 79707, "url": "http://patchwork.ozlabs.org/api/1.2/people/79707/?format=api", "name": "He Yong", "email": "hyyoxhk@163.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/swupdate/patch/20260417161524.2806435-3-hyyoxhk@163.com/mbox/", "series": [ { "id": 500375, "url": "http://patchwork.ozlabs.org/api/1.2/series/500375/?format=api", "web_url": "http://patchwork.ozlabs.org/project/swupdate/list/?series=500375", "date": "2026-04-17T16:15:21", "name": "Refactor image parsing and add LZ4 support", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500375/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2224592/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2224592/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=jlfFpE3l;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com\n (client-ip=2607:f8b0:4864:20::f3d; helo=mail-qv1-xf3d.google.com;\n envelope-from=swupdate+bncbaabb4ogrhhqmgqeilhtfny@googlegroups.com;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from mail-qv1-xf3d.google.com (mail-qv1-xf3d.google.com\n [IPv6:2607:f8b0:4864:20::f3d])\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 4fy1215R3tz2128\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 02:44:41 +1000 (AEST)", "by mail-qv1-xf3d.google.com with SMTP id\n 6a1803df08f44-8aca29dcd69sf21281016d6.1\n for <incoming@patchwork.ozlabs.org>;\n Fri, 17 Apr 2026 09:44:41 -0700 (PDT)", "by 2002:a05:6214:411c:b0:8ac:aec9:19ed with SMTP id\n 6a1803df08f44-8ae81d1d674ls36224376d6.0.-pod-prod-03-us; Fri, 17 Apr 2026\n 09:44:33 -0700 (PDT)", "by 2002:a05:6808:286:b0:467:e362:ec8e with SMTP id\n 5614622812f47-4799cd50cf1msb6e;\n Fri, 17 Apr 2026 09:15:34 -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 af79cd13be357-8e7d8ce77d7si6263185a.5.2026.04.17.09.15.30\n for <swupdate@googlegroups.com>\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 17 Apr 2026 09:15:33 -0700 (PDT)", "from nh50.. (unknown [])\n\tby gzsmtp2 (Coremail) with SMTP id PSgvCgDnEgycXOJpPjUTAg--.9473S4;\n\tSat, 18 Apr 2026 00:15:25 +0800 (CST)" ], "ARC-Seal": [ "i=2; a=rsa-sha256; t=1776444275; cv=pass;\n d=google.com; s=arc-20240605;\n b=aoEF7uV26uV8yky2o6A2nI1Oh9NR1gHFruXXurSocZXQ7CIgYSz2q5FzSJs7OhYBRf\n rS1Uzj9QHmPB5uqsijgDqYHnYXkZwOt2WcENQDylyGsorsvEQr1FN/VDHe8TnDVgD5Ag\n SdBA8bTL1kWPuV4LWOeTt6crmD2q0l9sp95C6fET9bARCF1wNhab3LJVRwn2+vcoeWi4\n eh12ZXFcySmeF+/a4574FN8bz4vmmtL0Oo0Y00wiVgkw+wmvK2kA8BfavQmnpxmQDFRh\n c3fyN8U9eFdwk3swgmh4lp7PemQqeVUCK+mLQyPDPwQ5akw1BuJVh125+OHhA8VFJPmM\n H6eA==", "i=1; a=rsa-sha256; t=1776442534; cv=none;\n d=google.com; s=arc-20240605;\n b=LuIcWww5uWAlqtDGcBC8uEvNWkJeZemSbO8uZ9XrsIcXRKdq6lMHGf3WHn5ENVk4NK\n NrgegIMqzMzZH1RcEfZ/pjEUKPpgINPWN9Lg3ZtLwhe3kKoVwnZFjB1fnD8KwtOwKqxn\n irNtVLEusDnIEll79rw5nPmQi7vIvxnrRdsFR4FxdD6g7KjfG5tprwKyzVUu8Y7YzhyQ\n PKH1t1XMI6K3uGHGXitvEhgZZVwcfSxmD/gcn6fhK4L29miogJ9FmMglo+U39QDktio2\n n7K1xhP1E0voA47TEDaeBykzUnb19oqSrmTG83iswVm6PUS66nGWsyRk0/6/kMRyiAFe\n Gm9w==" ], "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=BtxfQQpHSjznyjBGY4IGc8vpYCLsUBlS+mm2cZ3QQoA=;\n fh=Y7L3UkBe7TXNRDLMqmlFua/1OQDWwbC6ZZpti3wbJP4=;\n b=H1RS54A5IYkutQuyJG8Y1nT9kT0MBy0scWDHUp+ZNfMWQB/slWNs/lrX7E0UB4LpAU\n 22Ld6XtGDgc1kO8sysn+rH/bYnjMWGrX1Hjv2alGCRcpZUKYv2CWKPBCoazZk562d/V0\n jfIF8e8ibFC5rmKdfQyz9TkLa5oTxGQn3tmj8pAcJ3Nh8RANPVVMslZHojYoLT+2ItSh\n 77bwJtL/5/fQH5PHAgWmwVW2q0PlrEUKmJGFxSgkOuhrFlJtRh02tZv5qTZJFPUxf5HL\n B4YMinU/lsSujkTEiLBnZjWyPcX8exdVIx2EWxC17ReSnDfjXqGk2f0DoTvyAKod//w9\n MKVA==;\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=YooX98SyPtoYLzrsaFSRgH4AJxnifZcMfFny+0Is/to=;\n fh=nvZsCFpxgpf+fsVXzjnWA8g1K3V/kNbRAKogjNDW4HY=;\n b=DVkCFBvDB0uUaurBOO4mJlSIlL8dTnmYCEB2NhlVQ9lNp3/ThZnJ4/PSbG4Wew+Wcc\n Ix4sqQhEW880lQTQlsLG13msUsmcPdILB3YuA5yn1lrVNvZ+V3N8G93wyuXFuDRssesu\n kL98OxMq71+lKRDTyZdya2lMW8nM4HlvB2FIkEKUZHvWR5luzDsCM0dzCA0Ethy8hLx2\n XR8qOV/rQmH8YapcBGaOQnEa9FVzDF0tONM5Y97pFyBt4YXSn9H02olGG6nJ2O5GxmKK\n WR5G9qny8siuQMigjA5Za/EkbY6D/prNlHcbQZFdq64hcdZ4zacpfXvbUjnmN9vbDRbs\n tp8Q==;\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=c4sU9Bqh;\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=c4sU9Bqh;\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=1776444275; x=1777049075;\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=BtxfQQpHSjznyjBGY4IGc8vpYCLsUBlS+mm2cZ3QQoA=;\n b=jlfFpE3l/x8RQ1nLG8FdAu5BSoYJDPwFyMGMMmASzDK5z//PmVkTvFRFHmXyARx0Yt\n pDImA1bTexazxRAtx6MOOG777ky/xkpcYFYpXFfa0vV6ZYZ8aDeDvJAA0u6+7we1XXRi\n F8emLqUufBuhw8wRASZXLvrW4S9uVEv8fHBnLv8hOpramwRp8xM51OYFAsWE7TTq0xpa\n qRBCF9FT4CGN6h5JL6oF/j/4uuxFdAuy0LYDgSPu/LYEiPD+qdr47HSjgZR5WTdlPb1r\n ehuTXtu+ghPq8fGRKtZG1Y+Y2JNo05YQesFJYOhBLW/g/LFyQY2ZX0OQ+lIKUhb1KpEX\n N5ug==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776444275; x=1777049075;\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=BtxfQQpHSjznyjBGY4IGc8vpYCLsUBlS+mm2cZ3QQoA=;\n b=ksBfS2LRyF9UGACEF7cok+qs7ol6vKBunIenJ5nKc698iLBBE5Xh40U1WAUtCPHQdI\n wIMx08HjY0ME7pBXnV4+luR5YhQcEdBSuBy2pHdI019coqzHfFsGZQ0enPMzuTbKD8wl\n Dd0JWaHU86NvMgtOsZQlInqsYKwDWSRnqO9h9PttWjwqK9dD8z5wO3GbJ4F4zxkDeHB9\n d5y+4S/K6G5Aun3GNmoz/giF2pbztZWtRkkHhYvXMbPMzptgpw7twr/EUckuImFQm+iz\n gyFfAlrCdeYl9oc5PacbTl5vLfjyISVZEj0Gp6IBQkxkSK/wKAiFIWSoakQMyqGKUsN0\n wfUQ==", "Sender": "swupdate@googlegroups.com", "X-Forwarded-Encrypted": "i=2;\n AFNElJ/XYjPVKlsaQuHn5w2EoYzZkgnPn/LQgK87Gy6dIjLvpAPn4KGn5pCSI7uLY2iyH70H+UM6m/12MQ==@patchwork.ozlabs.org", "X-Gm-Message-State": "AOJu0YwZCP+1ti1tz/p6tax3c/gobWwXAIZuYXVvmNHBLDYfwdOTDvbw\n\ty89KbbBY4qewk9RyEt2AD8d+8nD1XI6mK6eQ4jAef+tEGgu9ohKk04qA", "X-Received": [ "by 2002:a05:6214:519d:b0:89c:4f67:8d17 with SMTP id\n 6a1803df08f44-8b0280c9032mr55392966d6.8.1776444274674;\n Fri, 17 Apr 2026 09:44:34 -0700 (PDT)", "by 2002:a05:620a:44cd:b0:8cd:b317:a0b3 with SMTP id\n af79cd13be357-8e7902127cdmr550002985a.24.1776444272836;\n Fri, 17 Apr 2026 09:44:32 -0700 (PDT)", "by 2002:a05:6820:1989:b0:68f:1d67:7945 with SMTP id\n 006d021491bc7-69462f5c6d4mr1922418eaf.54.1776442534060;\n Fri, 17 Apr 2026 09:15:34 -0700 (PDT)" ], "X-BeenThere": "swupdate@googlegroups.com;\n h=\"AYAyTiKQSRqUkKSieA0OXXsfJQ207CGeMSXNTW2atj8Jm3Tc9Q==\"", "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 2/4] parser: refactor stream attribute parsing", "Date": "Sat, 18 Apr 2026 00:15:22 +0800", "Message-ID": "<20260417161524.2806435-3-hyyoxhk@163.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260417161524.2806435-1-hyyoxhk@163.com>", "References": "<20260417161524.2806435-1-hyyoxhk@163.com>", "MIME-Version": "1.0", "X-CM-TRANSID": "PSgvCgDnEgycXOJpPjUTAg--.9473S4", "X-Coremail-Antispam": "1Uf129KBjvJXoWxKw4DWF4kGr45AF4xur1UAwb_yoW3Jr48pF\n\tWFg34FkrWxX3Z7Ga13Za97Cr1rWrs3J345Jr18Wwn0y3W3Krn5ta409rZIkF9rGryrZw1D\n\tua1YgFWY9w4UtF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n\t9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UlQ6JUUUUU=", "X-Originating-IP": "[2408:8266:bb01:57f4:788f:a08d:bbc4:eabb]", "X-CM-SenderInfo": "pk1105lkn6il2tof0z/xtbC8R1RJGniXJ1PowAA3-", "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=c4sU9Bqh; 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": "External parser currently uses a long chain of key comparisons and\nduplicates compressed type mapping in multiple places. This makes\nattribute handling harder to maintain and easier to drift.\n\nReplace the if-chain with a key-to-handler dispatch table, introduce\nsmall dedicated setters for each attribute, and reuse\ncompressed_string_to_type() in both external and common parsing paths\nto keep compression conversion logic centralized.\n\nSigned-off-by: He Yong <hyyoxhk@163.com>\n---\n parser/parse_external.c | 175 ++++++++++++++++++++++++----------------\n parser/parser.c | 11 +--\n 2 files changed, 109 insertions(+), 77 deletions(-)", "diff": "diff --git a/parser/parse_external.c b/parser/parse_external.c\nindex d67bcca0..e63058f2 100644\n--- a/parser/parse_external.c\n+++ b/parser/parse_external.c\n@@ -28,82 +28,117 @@\n #define LUA_PARSER\t(CONFIG_EXTPARSERNAME)\n #endif\n \n-static void sw_append_stream(struct img_type *img, const char *key,\n-\t const char *value)\n+typedef void (*stream_handler_fn)(struct img_type *img, const char *value);\n+\n+struct stream_handler_entry {\n+\tconst char *key;\n+\tstream_handler_fn handler;\n+};\n+\n+DEFINE_IMG_STRLCPY_SETTER(sw_set_type, type)\n+DEFINE_IMG_STRLCPY_SETTER(sw_set_name, id.name)\n+DEFINE_IMG_STRLCPY_SETTER(sw_set_version, id.version)\n+DEFINE_IMG_STRLCPY_SETTER(sw_set_mtdname, mtdname)\n+DEFINE_IMG_STRLCPY_SETTER(sw_set_filesystem, filesystem)\n+DEFINE_IMG_STRLCPY_SETTER(sw_set_volume, volname)\n+DEFINE_IMG_STRLCPY_SETTER(sw_set_device, device)\n+DEFINE_IMG_STRLCPY_SETTER(sw_set_path, path)\n+\n+static void sw_set_filename(struct img_type *img, const char *value)\n+{\n+\tstrlcpy(img->fname, value, sizeof(img->fname));\n+\timg->skip = SKIP_NONE;\n+}\n+\n+static void sw_set_offset(struct img_type *img, const char *value)\n {\n-\tconst char offset[] = \"offset\";\n \tchar seek_str[MAX_SEEK_STRING_SIZE];\n \n-\tif (!strcmp(key, \"type\"))\n-\t\tstrlcpy(img->type, value,\n-\t\t\tsizeof(img->type));\n-\tif (!strcmp(key, \"filename\")) {\n-\t\tstrlcpy(img->fname, value,\n-\t\t\tsizeof(img->fname));\n-\t\timg->skip = SKIP_NONE;\n+\tstrlcpy(seek_str, value, sizeof(seek_str));\n+\t/* convert the offset handling multiplicative suffixes */\n+\timg->seek = ustrtoull(seek_str, NULL, 0);\n+\tif (errno) {\n+\t\tERROR(\"offset argument: ustrtoull failed\");\n \t}\n-\tif (!strcmp(key, \"name\")) {\n-\t\tstrlcpy(img->id.name, value,\n-\t\t\tsizeof(img->id.name));\n-\t}\n-\tif (!strcmp(key, \"version\")) {\n-\t\tstrlcpy(img->id.version, value,\n-\t\t\tsizeof(img->id.version));\n-\t}\n-\tif (!strcmp(key, \"mtdname\") || !strcmp(key, \"dest\"))\n-\t\tstrlcpy(img->mtdname, value,\n-\t\t\tsizeof(img->mtdname));\n-\tif (!strcmp(key, \"filesystem\"))\n-\t\tstrlcpy(img->filesystem, value,\n-\t\t\tsizeof(img->filesystem));\n-\tif (!strcmp(key, \"volume\"))\n-\t\tstrlcpy(img->volname, value,\n-\t\t\tsizeof(img->volname));\n-\tif (!strcmp(key, \"device_id\"))\n-\t\tstrlcpy(img->device, value,\n-\t\t\tsizeof(img->device));\n-\tif (!strcmp(key, \"device\"))\n-\t\tstrlcpy(img->device, value,\n-\t\t\tsizeof(img->device));\n-\tif (!strncmp(key, offset, sizeof(offset))) {\n-\t\tstrlcpy(seek_str, value,\n-\t\t\tsizeof(seek_str));\n-\t\t/* convert the offset handling multiplicative suffixes */\n-\t\timg->seek = ustrtoull(seek_str, NULL, 0);\n-\t\tif (errno){\n-\t\t\tERROR(\"offset argument: ustrtoull failed\");\n-\t\t}\n+}\n+\n+static void sw_set_script(struct img_type *img, const char *value)\n+{\n+\t(void)value;\n+\timg->is_script = 1;\n+}\n+\n+static void sw_set_sha256(struct img_type *img, const char *value)\n+{\n+\tascii_to_hash(img->sha256, value);\n+}\n+\n+static void sw_set_encrypted(struct img_type *img, const char *value)\n+{\n+\t(void)value;\n+\timg->is_encrypted = true;\n+}\n+\n+static void sw_set_compressed(struct img_type *img, const char *value)\n+{\n+\tif (value == NULL || compressed_string_to_type(value, &img->compressed) < 0) {\n+\t\timg->compressed = COMPRESSED_TRUE;\n \t}\n-\tif (!strcmp(key, \"script\"))\n-\t\timg->is_script = 1;\n-\tif (!strcmp(key, \"path\"))\n-\t\tstrlcpy(img->path, value,\n-\t\t\tsizeof(img->path));\n-\tif (!strcmp(key, \"sha256\"))\n-\t\tascii_to_hash(img->sha256, value);\n-\tif (!strcmp(key, \"encrypted\"))\n-\t\timg->is_encrypted = true;\n-\tif (!strcmp(key, \"compressed\")) {\n-\t\tif (value != NULL) {\n-\t\t\tif (!strcmp(value, \"zlib\")) {\n-\t\t\t\timg->compressed = COMPRESSED_ZLIB;\n-\t\t\t} else if (!strcmp(value, \"xz\")) {\n-\t\t\t\timg->compressed = COMPRESSED_XZ;\n-\t\t\t} else if (!strcmp(value, \"zstd\")) {\n-\t\t\t\timg->compressed = COMPRESSED_ZSTD;\n-\t\t\t} else {\n-\t\t\t\timg->compressed = COMPRESSED_TRUE;\n-\t\t\t}\n-\t\t} else {\n-\t\t\timg->compressed = COMPRESSED_TRUE;\n-\t\t}\n+\n+}\n+\n+static void sw_set_install_directly(struct img_type *img, const char *value)\n+{\n+\t(void)value;\n+\timg->install_directly = 1;\n+}\n+\n+static void sw_set_install_if_different(struct img_type *img, const char *value)\n+{\n+\t(void)value;\n+\timg->id.install_if_different = 1;\n+}\n+\n+static void sw_set_install_if_higher(struct img_type *img, const char *value)\n+{\n+\t(void)value;\n+\timg->id.install_if_higher = 1;\n+}\n+\n+static const struct stream_handler_entry handlers[] = {\n+\t{ \"type\", sw_set_type },\n+\t{ \"filename\", sw_set_filename },\n+\t{ \"name\", sw_set_name },\n+\t{ \"version\", sw_set_version },\n+\t{ \"mtdname\", sw_set_mtdname },\n+\t{ \"dest\", sw_set_mtdname },\n+\t{ \"filesystem\", sw_set_filesystem },\n+\t{ \"volume\", sw_set_volume },\n+\t{ \"device_id\", sw_set_device },\n+\t{ \"device\", sw_set_device },\n+\t{ \"offset\", sw_set_offset },\n+\t{ \"script\", sw_set_script },\n+\t{ \"path\", sw_set_path },\n+\t{ \"sha256\", sw_set_sha256 },\n+\t{ \"encrypted\", sw_set_encrypted },\n+\t{ \"compressed\", sw_set_compressed },\n+\t{ \"installed-directly\", sw_set_install_directly },\n+\t{ \"install-if-different\", sw_set_install_if_different },\n+\t{ \"install-if-higher\", sw_set_install_if_higher },\n+};\n+\n+static void sw_append_stream(struct img_type *img, const char *key,\n+\t const char *value)\n+{\n+\tsize_t i;\n+\n+\tfor (i = 0; i < sizeof(handlers) / sizeof(handlers[0]); i++) {\n+\t\tif (strcmp(key, handlers[i].key))\n+\t\t\tcontinue;\n+\n+\t\thandlers[i].handler(img, value);\n+\t\treturn;\n \t}\n-\tif (!strcmp(key, \"installed-directly\"))\n-\t\timg->install_directly = 1;\n-\tif (!strcmp(key, \"install-if-different\"))\n-\t\timg->id.install_if_different = 1;\n-\tif (!strcmp(key, \"install-if-higher\"))\n-\t\timg->id.install_if_higher = 1;\n }\n \n int parse_external(struct swupdate_cfg *software, const char *filename,\ndiff --git a/parser/parser.c b/parser/parser.c\nindex ea2dfef4..4613e032 100644\n--- a/parser/parser.c\n+++ b/parser/parser.c\n@@ -503,16 +503,13 @@ static int parse_common_attributes(parsertype p, void *elem, struct img_type *im\n \t}\n \n \tif ((compressed = get_field_string(p, elem, \"compressed\")) != NULL) {\n-\t\tif (!strcmp(compressed, \"zlib\")) {\n-\t\t\timage->compressed = COMPRESSED_ZLIB;\n-\t\t} else if (!strcmp(compressed, \"xz\")) {\n-\t\t\timage->compressed = COMPRESSED_XZ;\n-\t\t} else if (!strcmp(compressed, \"zstd\")) {\n-\t\t\timage->compressed = COMPRESSED_ZSTD;\n-\t\t} else {\n+\t\tint ctype;\n+\n+\t\tif (compressed_string_to_type(compressed, &ctype) < 0) {\n \t\t\tERROR(\"compressed argument: '%s' unknown\", compressed);\n \t\t\treturn -1;\n \t\t}\n+\t\timage->compressed = ctype;\n \t} else {\n \t\tbool img_compressed = false;\n \t\tGET_FIELD_BOOL(p, elem, \"compressed\", &img_compressed);\n", "prefixes": [ "v1", "2/4" ] }