Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2224596/?format=api
{ "id": 2224596, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2224596/?format=api", "web_url": "http://patchwork.ozlabs.org/project/swupdate/patch/20260417155704.2758672-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": "<20260417155704.2758672-3-hyyoxhk@163.com>", "list_archive_url": null, "date": "2026-04-17T15:57:02", "name": "[v1,2/4] parser: refactor stream attribute parsing", "commit_ref": null, "pull_url": null, "state": "not-applicable", "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/20260417155704.2758672-3-hyyoxhk@163.com/mbox/", "series": [ { "id": 500374, "url": "http://patchwork.ozlabs.org/api/1.2/series/500374/?format=api", "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/2224596/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2224596/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=AsE4D33S;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com\n (client-ip=2607:f8b0:4864:20::83f; helo=mail-qt1-x83f.google.com;\n envelope-from=swupdate+bncbaabb4ogrhhqmgqeilhtfny@googlegroups.com;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from mail-qt1-x83f.google.com (mail-qt1-x83f.google.com\n [IPv6:2607:f8b0:4864:20::83f])\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 4fy1220GQ7z1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 02:44:41 +1000 (AEST)", "by mail-qt1-x83f.google.com with SMTP id\n d75a77b69052e-50e2eeebd33sf20226051cf.2\n for <incoming@patchwork.ozlabs.org>;\n Fri, 17 Apr 2026 09:44:41 -0700 (PDT)", "by 2002:a05:622a:15d1:b0:509:2a0e:163b with SMTP id\n d75a77b69052e-50e2580f0e2ls40261291cf.1.-pod-prod-07-us; Fri, 17 Apr 2026\n 09:44:33 -0700 (PDT)", "by 2002:a05:620a:2406:20b0:8cd:90d4:fad8 with SMTP id\n af79cd13be357-8e65762f81ems85a;\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 d75a77b69052e-50e3943ea6bsi780681cf.5.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--.43368S4;\n\tFri, 17 Apr 2026 23:57:05 +0800 (CST)" ], "ARC-Seal": [ "i=2; a=rsa-sha256; t=1776444275; cv=pass;\n d=google.com; s=arc-20240605;\n b=bl5ri8lG6dJm95URuD45lZudE5YGOQYAuxKA8nQorigIoiGUkmtRcOK7XedqzcdDVK\n xOLX+kvyqq1BW467cZnbOPze3g6XsgAmqnl8l+fgsiCNrS2ydwZnUOSJTqPLzXGo/Ixc\n +sOYR3T7eoeEM7Plvh2sd2SPnPdlFraQGecNcoEMEfxLU4S2zLn8zz4cNbV6tj7x6a3R\n gfuDi8KM0WimFrHyouws2fOWyVzz5pZUfoqLT0VN16ZHXKW3S+4JSz1ZdpB07RQmA+hc\n 1Jl2SnQ58KWFlfnFrHQJ5pqVTpDJIIS0i74Cw+Q4ZnFGm+KIgRn2Zw90qXNYsbQrRH4f\n Y32g==", "i=1; a=rsa-sha256; t=1776441432; cv=none;\n d=google.com; s=arc-20240605;\n b=fVf6SU/sWZqqz5LhqzG9a3sI90X8eN0ItlHXNbj4QaXA1s9XY6uSBUMdtVq6jsy+9r\n zkxgj4r15a4S55mXNDx6emHC2B8L+4SwntzPWv1MGU0pCGvbosm+nWlN6CwfRYPmTQ9M\n Jd7yv3t9S/FG+7tLSaiBh770FrtN80ecTxAxcXYqL4WWDFmrfxowDyvG6UK78si9LIgT\n GLV2NGvMCVUzIywP1WjHhDV3MbpSrT7GZZ6njwfP0ZaBbdeVGpVxQDh+auwpdpLXnU2Q\n Uliqzqr5r9I/OPIVTN1Pwwr1iBKtRO/ryq8O3ZHpl2ZoRyiVEr4683Onzn8SnCNLkxcS\n r5XQ==" ], "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=twkSLji7Xn2kDvtirRcUL867J+S2OE3Tiham7N5b8Yg=;\n fh=H9Hqh5lbF0mkokbYrOGrnfKuIzzljJC7bVR0iov5nUo=;\n b=EWgCLxB1ozWiDt7lmrtUHcqIpJ5rkb40JMpPPdOVYZ8bbn8H9fwD1vrcdMg+cHrx2P\n J94rM+zTeAc9Tf0jedbwT1yGUsSVQuwtVTGqOZ9vma+7zBeN8djNrgwYb7l6mIFzmdyZ\n XgcPGTLHwfXDexosKlqHVPoUwpmZIfTnvVlq/jWcTQdq2nQRlkxXidsaSdBkSiCJNRXv\n vAyOpIIpv8Yr8h8rYWOQl8B03cJFVz4Xr8hXw4sR2MtOzix4dNuDA/86egBXhzwhBUBO\n hhJtKd1394dBRUiCGHRYNX+QPC1PMABgesuOGbVjn5AlpTOS1T5ftY7QOZTEmMnp+UK6\n hUdg==;\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=QHEq0u4GSGIeOIOKdB/S4EW8YRbsY84rj/EApvybk85N3qdIk62rdy91ROEZSbirHO\n Injc2vLwYVjHXee2WGWlH25sX57AypIhhNQ/clxujLpHcZRU1BWcatqwokKN8SniPprq\n pGDzBsgvyTy7jqA2sxPwfdnLb+ia03sSfEjErS/2b9Utu0i5KR09+ZBF6TDwz/H4pvnH\n iqC/NuQ8/FkwRqgrztEFlH5InEiXkZz+9xkXh66mBoZMHZjuZwGZ93+SlLmfFVKaCpj1\n lPWNVU07Pelf8LXYdFwQzeoqE39oAzBpuDtK8zT0SQMn1e/jDHlqT5EukqWlG3gOEmPQ\n EJuw==;\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=NzwfgD5l;\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=NzwfgD5l;\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=twkSLji7Xn2kDvtirRcUL867J+S2OE3Tiham7N5b8Yg=;\n b=AsE4D33SjlfDj9b2doQx1VlQtE/RlUFdb1/nNPwRvW3z9wWSbDANkRiI4lMl6Xb+XB\n SDyXrTqLmSsjssmaF/6vbrmoOopjp47U7ifD8a7VaR7YvlxPV+baTN/4A9P4obQvZKFR\n 7xDBZX1wBRU/uJcRnDF/V8q6BKcC1sAG857Bg9ndAOkh1EBFMpAtzzCd3Yp9KBazTmeI\n IEuJQVpmCCn16B6tKl3ItBgFj1qdTqmboDrcpTBX/4DMp06/6dW7RY+RX1IUtrer2S04\n 8qs37JmYu5aimdPLUI24DiZd1497us1qH+xlrJ2JVj3vknJ1Ks7Z9SByqY0L3oga6kaO\n WpDg==", "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=twkSLji7Xn2kDvtirRcUL867J+S2OE3Tiham7N5b8Yg=;\n b=Ct5MM/1OczCLuAqpmO+5SgIGNE/QQMFAw5yUA1lq6/++CNoVpb0kBLXsmKVrkWTcQ7\n f8c8hx4DymoORXwKQEqfyVu44pzIooEAK6DRqiTgtRlokcwX91S68CaOsAv4EYZDUM0h\n 8QORZ1R0JuG91OwRBVdyGnSWTew8rucZC1TqcltUx2EtDmrdhw3Zpdp+wEgqoUcZQy/v\n eINlw/wrDljX4GD95d3iFJIYE2Z/S74+6sTTEHCpzk35OudF+R1Xcz3MUDpnurKI4Yxc\n VmEl/kmDzCGXm3piykHo3BoPf1dmNPNHko2fZlmyQC4Q+kToom35/kaTaV2QMgAzmT9+\n HXpQ==", "Sender": "swupdate@googlegroups.com", "X-Forwarded-Encrypted": "i=2;\n AFNElJ9e4JgwGZVa3ABNvx5eNpZTJr3PlfbYY8fmrjOnqhcKuTmocYzaGV+zok0K3DOCoe+N47rrUhWYIQ==@patchwork.ozlabs.org", "X-Gm-Message-State": "AOJu0YzoAVy7+f4dwpiNQDK7yl6vGvTAt3TPS5z0OJLS5C4di8+/lF2Y\n\t69MsP7dBpMDDa5oP+4EuQMlWKZkMoUMYXrtUY18l7vkezYGGl+iMv3Yz", "X-Received": [ "by 2002:a05:622a:1828:b0:50d:9073:f8e with SMTP id\n d75a77b69052e-50e36b6a9e7mr51627261cf.26.1776444274585;\n Fri, 17 Apr 2026 09:44:34 -0700 (PDT)", "by 2002:a05:620a:1a26:b0:8cf:c75d:29fa with SMTP id\n af79cd13be357-8e78f24ddf2mr503743385a.11.1776444272840;\n Fri, 17 Apr 2026 09:44:32 -0700 (PDT)", "by 2002:a05:622a:5914:b0:509:f36:496d with SMTP id\n d75a77b69052e-50e36c0cdf3mr47097901cf.33.1776441432578;\n Fri, 17 Apr 2026 08:57:12 -0700 (PDT)" ], "X-BeenThere": "swupdate@googlegroups.com;\n h=\"AYAyTiJEB+8E9Y58iuJ1O3LSCMipaspq9r4kc27BNKAzSvB4aw==\"", "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": "Fri, 17 Apr 2026 23:57:02 +0800", "Message-ID": "<20260417155704.2758672-3-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--.43368S4", "X-Coremail-Antispam": "1Uf129KBjvJXoWxKw4DWF4kGr45AF4xur1UAwb_yoW3Jr48pF\n\tWFg34FkrWxX3Z7Ga13Za97Cr1rWrs3J345Jr18Wwn0y3W3Krn5ta409rZIkF9rGryrZw1D\n\tua1YgFWY9w4UtF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n\t9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UdPEfUUUUU=", "X-Originating-IP": "[2408:8266:bb01:57f4:788f:a08d:bbc4:eabb]", "X-CM-SenderInfo": "pk1105lkn6il2tof0z/xtbC0BE9EGniWFEZhwAA3w", "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=NzwfgD5l; 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" ] }