get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2195584/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2195584,
    "url": "http://patchwork.ozlabs.org/api/patches/2195584/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/swupdate/patch/20260211132740.597019-2-stefano.babic@swupdate.org/",
    "project": {
        "id": 58,
        "url": "http://patchwork.ozlabs.org/api/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": "<20260211132740.597019-2-stefano.babic@swupdate.org>",
    "list_archive_url": null,
    "date": "2026-02-11T13:27:32",
    "name": "[1/9] hawkbit: move out parsing of artifact",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "9338a54ad5577b9754f2e163a9866bdddb22d701",
    "submitter": {
        "id": 86869,
        "url": "http://patchwork.ozlabs.org/api/people/86869/?format=api",
        "name": "Stefano Babic",
        "email": "stefano.babic@swupdate.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/swupdate/patch/20260211132740.597019-2-stefano.babic@swupdate.org/mbox/",
    "series": [
        {
            "id": 491836,
            "url": "http://patchwork.ozlabs.org/api/series/491836/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/swupdate/list/?series=491836",
            "date": "2026-02-11T13:27:32",
            "name": "Introduce delta update with Hawkbit",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/491836/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2195584/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2195584/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<swupdate+bncBD2ZDGN6SEKRBUMHWLGAMGQEFYE47ZI@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=20230601 header.b=XYPdyXTl;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com\n (client-ip=2a00:1450:4864:20::53d; helo=mail-ed1-x53d.google.com;\n envelope-from=swupdate+bncbd2zdgn6sekrbumhwlgamgqefye47zi@googlegroups.com;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from mail-ed1-x53d.google.com (mail-ed1-x53d.google.com\n [IPv6:2a00:1450:4864:20::53d])\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 4f9zkw0p2Sz1xtr\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 12 Feb 2026 00:27:51 +1100 (AEDT)",
            "by mail-ed1-x53d.google.com with SMTP id\n 4fb4d7f45d1cf-65a408f232esf680875a12.0\n        for <incoming@patchwork.ozlabs.org>;\n Wed, 11 Feb 2026 05:27:51 -0800 (PST)",
            "by 2002:a05:6402:335:b0:659:84fa:678e with SMTP id\n 4fb4d7f45d1cf-65984fa6872ls3438707a12.2.-pod-prod-08-eu; Wed, 11 Feb 2026\n 05:27:44 -0800 (PST)",
            "from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.74])\n        by gmr-mx.google.com with ESMTPS id\n a640c23a62f3a-b8f6ec1a0bfsi5543866b.3.2026.02.11.05.27.43\n        for <swupdate@googlegroups.com>\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Wed, 11 Feb 2026 05:27:43 -0800 (PST)",
            "from paperello ([88.217.136.221]) by mrelayeu.kundenserver.de\n (mreue109 [212.227.17.181]) with ESMTPSA (Nemesis) id\n 1N7Qp1-1vijYo1MuT-011ZCW; Wed, 11 Feb 2026 14:27:43 +0100"
        ],
        "ARC-Seal": [
            "i=2; a=rsa-sha256; t=1770816468; cv=pass;\n        d=google.com; s=arc-20240605;\n        b=c9tHgQSHX+ymKImzEqj8XRKDJyd/w46GA3wL6zqfrcAcdA58SUuB57RD2Cu5ZLCDzl\n         Ew2wYpc6zcTRdcosjJQXFPH5A/WDU4I1sUtVxJUwwlnQFMUSlKaLFvNmA8PHvhuSF4ma\n         CtG88h/We8WuV426c8/pWHx4rxZ4be4iv7wZ/klaKx+5EQfGB3bS3e6nTqEiB/BKsYfH\n         gMZLFfO/X5LyrBG6Fm8mnYBMtJ31b99QqvvBVU4IISkfJYRsQE7pVMltXQsM5vTUDgG0\n         uy4o8D8SoxbaToomioHCRwrgGSOwJcPf9mBB8641m/326uU6rndc7trcb3yEHGpAuKDF\n         y+tw==",
            "i=1; a=rsa-sha256; t=1770816463; cv=none;\n        d=google.com; s=arc-20240605;\n        b=TIzgrntiickPTq4XlFU/PwOoXblzowrYCokFA1mlA/twZELp5Y+h0N7NbBCn+c7X1w\n         i6v1N6FhL1iMurnfslKJ1re2LU2xgL+jI0e8QJF5725DmrFbX/9cJRB6r6ifeyGncWDy\n         wMW5zUF/wAJdccLFrHmYTPTu8EJAlH2XfGW/W+nfo04Vz3ru6fG0dykI6h+bAM4Fad8o\n         uVbHkbnxUudByblvtt6IcxHdFSW0dblRr5rvQLXHxk8A6dzYjVgh64tTDFR8L4c2qxY2\n         4OIifGZwyaFooB4lRk3ZiCruKdNxCioT0PfIuKDC9+lhbnU6f2TzO6R5zppLAAitofo1\n         zjrA=="
        ],
        "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:ui-outboundreport:mime-version\n         :references:in-reply-to:message-id:date:subject:cc:to:from:sender\n         :dkim-signature;\n        bh=uiA1Rh87nV+HlB778H84s4c0rYW+/aVqZBmrEM8Lm/Q=;\n        fh=OvIIImSllS7oPV8pt9uVpKfCQjD9URQx6OLyuHd9FfY=;\n        b=OuSLCBVkxOVrIdTnmVYBbBlWeK9Cy6swhxcj6uml5hcykocnHyyeiWhOwfgb+u9gMd\n         Swx4DC8bEAzk1QobrCd1pzOQp68sCEho5x2HH00gcqGr1xLf+pZsbjcD64QWzQ5vWBIU\n         pU1CJ1Nlz+czpx41DDZ9YZKsQ7QJUlcQ1ynDnWvoJLjBcQTctjVdFTvuPyGl6S3IY6cu\n         S851oofJ4KOlZPin6xswHf7bhkdYQOlw6WppEsB7uNEts9tvzdnMddyugzX5bPm38iMf\n         SOWsVahnKoVDBu9cm/1uramoTDkCMNbOCz4SBq8eT+ISRBQ1pbJ22tlZa/szwlnTyRsG\n         +kUg==;\n        darn=patchwork.ozlabs.org",
            "i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n        h=ui-outboundreport:content-transfer-encoding:mime-version:references\n         :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature;\n        bh=66HuWCIS9sgwbsW/DUenQV840BWh17Tz8zqahxzY+ms=;\n        fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=;\n        b=adO3K+8xdOTLdAcFxgRUokwT4dIbhtWD6G31ZNoCwjkaq9fulfUTWopQlppXZqYcA6\n         T0rNSuCwP3wIUQJiUqW5XLpBcNJf8unIysG98oQb99HBLjM7fPav4aB5LpdPq1X8jds7\n         20Z85bq64qDDK1ZBektcu+fKortdCcz+tQ4NYbfEiR3wJ6yorSmEv12IEyU0nEz5gwWn\n         UCH+xKEteEhgfexvABjBJFIs+c3cCqw7YrghfBQXpdbRnWoFTGQBQHUaO/4maPnsV55B\n         xgqFcPD6iSBEtUlp7Oa1X2DS3OSuBO5oTAZgmU6E6WoE8AHGD99VThieSO5mlgxx3YUA\n         MVvw==;\n        dara=google.com"
        ],
        "ARC-Authentication-Results": [
            "i=2; gmr-mx.google.com;\n       dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=Fj87bkJi;\n       spf=pass (google.com: domain of stefano.babic@swupdate.org designates\n 217.72.192.74 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org;\n       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=swupdate.org",
            "i=1; gmr-mx.google.com;\n       dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=Fj87bkJi;\n       spf=pass (google.com: domain of stefano.babic@swupdate.org designates\n 217.72.192.74 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org;\n       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=swupdate.org"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=googlegroups.com; s=20230601; t=1770816468; x=1771421268;\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:ui-outboundreport:mime-version:references\n         :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc\n         :subject:date:message-id:reply-to;\n        bh=uiA1Rh87nV+HlB778H84s4c0rYW+/aVqZBmrEM8Lm/Q=;\n        b=XYPdyXTle9Dn3evm5nriRqEJTFwf6KDyyj9K8TbUfDOSRPv8Ibi1HDnBBarAO+KUbr\n         ANsyLCmwhFWi6xqDIK16edO1q9lJsnkCaHh+FlYWI63GpYtCeUEu/qsQ3hfGiEvYt+zC\n         zyd2Nx4wRsq+y3T+cG0DgfHbZE+J+G05/YLMHVwvgPuP8IkiVFRVYpHCrppV8F7L5rth\n         PH2OXHloRTttNUKYrZyiQDSo3RNs6XkT4hDNvzRUeAQMbZ4xYCYZrzfwC57zhMaEVoUd\n         6ZiCZfGIgvW6sHd0GkM/FGMKAVvRncx+y0WbvIvRIYud48GwJGjXKNaQKnBt1Xh/xfWB\n         9GHg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20230601; t=1770816468; x=1771421268;\n        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n         :x-spam-checked-in-group:list-id:mailing-list:precedence\n         :x-original-authentication-results:x-original-sender\n         :ui-outboundreport:mime-version:references:in-reply-to:message-id\n         :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=uiA1Rh87nV+HlB778H84s4c0rYW+/aVqZBmrEM8Lm/Q=;\n        b=ak4dJxkFq9tLO5/poRpNwAFoN9mnXpKbfDRU8QQ6Bp5EBuPaEYn4KXzZjvAHPcBpKF\n         yAs1HMXUtyK6c3U+MzAHszg6ajG6rqgawrBIo7V3EqqRQvkB6P3d40L/DKBFU385qMFp\n         1urhnG52hhs2Sukdg+e9bjEKbYRuLWte+n7csNaTKPBpupoqt/kYtOiffRP64FsNmIAd\n         e+vetnf5DtVXP14LGXNOwdmQ0QMs7XRuwMnQabU+E1KkLpFK4C4t8thkZX7l3bxItS2w\n         wbmMA6giOhnD/qY8YjYCPVDTwhiFrwS+AqjYKzkDUNQsD6oqv+yo9X+a7wKFvfNasl1G\n         YOsg==",
        "Sender": "swupdate@googlegroups.com",
        "X-Forwarded-Encrypted": "i=2;\n AJvYcCXN537k28vjqyTlpZRTIzRSlV7NtswvJQ2d1SAiX29/C3RWSFvd9QLAzQlWU1BCXFqj61O/iFvdWA==@patchwork.ozlabs.org",
        "X-Gm-Message-State": "AOJu0YxJIyG1OGz2Rlyck9tL7T9zdjPzowvNNDfKwiQ/yKcwTT90j/yo\n\tgbtLyqOh+sLuvdEaUk6MhpQl8t0RptxPON/vpcXhhkEpn7NvQGi7VatJ",
        "X-Received": [
            "by 2002:a05:6402:430b:b0:65a:cdfb:58a7 with SMTP id\n 4fb4d7f45d1cf-65acdfb6bc0mr468658a12.9.1770816468159;\n        Wed, 11 Feb 2026 05:27:48 -0800 (PST)",
            "by 2002:a17:906:c14d:b0:b88:16dd:d835 with SMTP id\n a640c23a62f3a-b8edf174489mr968429766b.1.1770816463971;\n        Wed, 11 Feb 2026 05:27:43 -0800 (PST)"
        ],
        "X-BeenThere": "swupdate@googlegroups.com;\n h=\"AV1CL+GjovfdUXw3b/UHWKTkvW0JKYUuaRZRwieWVVUtZal1Aw==\"",
        "Received-SPF": "pass (google.com: domain of stefano.babic@swupdate.org\n designates 217.72.192.74 as permitted sender) client-ip=217.72.192.74;",
        "X-UI-Sender-Class": "55c96926-9e95-11ee-ae09-1f7a4046a0f6",
        "From": "Stefano Babic <stefano.babic@swupdate.org>",
        "To": "swupdate@googlegroups.com",
        "Cc": "Stefano Babic <stefano.babic@swupdate.org>",
        "Subject": "[swupdate] [PATCH 1/9] hawkbit: move out parsing of artifact",
        "Date": "Wed, 11 Feb 2026 14:27:32 +0100",
        "Message-ID": "<20260211132740.597019-2-stefano.babic@swupdate.org>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20260211132740.597019-1-stefano.babic@swupdate.org>",
        "References": "<20260211132740.597019-1-stefano.babic@swupdate.org>",
        "MIME-Version": "1.0",
        "X-Provags-ID": "V03:K1:DtGHCRbEYiSN1an6qPUTK0PSPgCEh5VWY/FaqOUkLKktBQvAMf5\n q+2yqMtsNsFdlrAlA4AJsc1JWw63dceyLpCfs1Pd6jYJSixJN8KlWnIYT9Ay7Etu0OVqp9U\n QogOJa/bHR+2wXVKbjZn4v0cWPeINUzuK3CPGovhGO924JJADZX2upxsdEDdRdEm3YOYQVi\n t636v/F25yFe2VZmZE6+A==",
        "X-Spam-Flag": "NO",
        "UI-OutboundReport": "notjunk:1;M01:P0:y7kKYixKicA=;H1MlJxfrFvyE3b0ed4uaFVqV5cT\n ZpD6vdjBj3Uqqm2RDjos1Vj7Ur9M1lTj3ObC0eMzuUBria13TyzLaxayAvDCBra2hMr0Dmznm\n KjjYw0R97kcuUpxb8XQkeG069SOkFo27coTYfzZZw5EJRG48r8KlIN6smwLTDOWKXTalcrVcw\n FqYlz+fSi5kr/8F/B4j2TqNwX0S6Nl/1RNO2FR0y/OBEZnN1unpTlp1DmWQMTCkEXIEqhUc7q\n NyXChOmP6KkOq7i9/lNiB3bTrYYfakr/tjRnsNTaEDG/E59LI3ZNoJl3yCBNUaOSVNnQWR94H\n W1TwbST/1qAs58AbdC1arvNKwpy2t2zubJNTvRbStoU2kjuLa7TUYKirqHbW1KEgrH9/586Iq\n ZBleBICmGIWakemblSHBgG9P/bPGl4DOLv1ohL6aHwesVaKSpBqsNujPKxIrAkZcYBuZqZzF5\n 2XJBK5dYd9Jx2VvzT6KfGabZYX0yfqrl8TqMNaOUN05MaLMwKMR3AAw2ZCl1AP7GYSKrpxSbM\n +c2sUhxh/3Qh6sZMccR8U92QODhUooJLcx247nXsvb9CPFV0Hnz1qP3jPtDq6VtBb7Kcw37RH\n LMxzXx17DhDa/sH6mDA4y3MXEGiDKrK2Vm67i+caFmh8VdwfKlU+KOEheyWufqHsqrFBkvsvc\n LFxXepK2+mGYmlfehNtt7XxMhpXewN4v7XkbOC9l246y5rkpUhdUF+Ycr/wFtdtN2gC3dLrku\n VD1mzFI2i+O1f2PWNjU/AE/Lyn1M3DjP5XUZEXoUx3oKckObDZ3Ie3BrgVRt9/lQe3Mi259X4\n 7+NTSiEsZGa6jwgyX+UXgokNdNrHkqagS3elSm8tJmUUSKpB+qiQlZfxZ5FiA4fl50BNVoupO\n D/U1oKXC2k24kTWfenoXJD03iPyScrn8z1clWKsQiEJvltOMkv1oJMCY6ZKXnDELN0DmaTClS\n XrwRdOqFEyIfEr1NFaFSj5piTPHuv4OG1zWOMleOjB/nF2kU6yVL9ZTyKNwrCTJWoRJAWoWw1\n gCwfx4T0QC7F9VNt2xBeGro/QQmDQFk71PHZPZ7ycvOknfdlTVvXP1VPKN0lPoIY1nCXnqNOT\n SquaklfD8F3ZA7Si06/8UELd65uLHHYPm+U4QRicw4ul+Q/9n8shfC2nt8ZpvMBMQ17kHZnxW\n DMNo/DN2GfXUzoo3AQWLalpIblNwLhcPInIFYL2Gj61cKNtvU9djtqb4sWmXFBlReYJnQVTLP\n nwtIubeRU2Q/GzoigOisKq0KN3a8FHBpLiyMDYauffonSG1UZiGZNBOH+RPZsNDcZtQw39kQF\n AT3l2pFxyZlzL4cqJskiC+9xvF9sJzg5Wiqd5qFV3ZdJ+fXu2AwpoindHiABRRIKaSvrZDYHW\n Ly0KS9XLwdsBAO6R6uWA8B3GireaHSZPKJiIvVyVA+XYV+VcZbESR46ty/ca+tYgCXgDyxxA6\n pUfwTnbAQMgvYOAfRg8rEA92Ykb2Qzz6Zg9js234tDjmfny85Kr4k/m7DHSoRzHtXg54Esc4q\n /4YUVSnecfqcj41NqtgAhnTTDdLsznketP3Seizr8pCxFwDSM/ENYsk/ewvUPHXaRtxmpwXFG\n mVEnHvtoODL/FajBz0+JKHXvVX8OZazduT668YOFKs+z8LFsgPzBXEtCl+0+4Y0uCbdsB5Yz9\n D+heT6YEZP9ql/twfIRB4cWFwoUwoYqwO+HiBjll3kmG01HtQGdndxcwL514323y1U1d14qz8\n iwP0J9wVLxYo+x8BFC2lftB15jXX1MXUU60MYHjFvm9+HYRT0vn3gH2JvXv8E/YDZHZSCFnP+\n S6A3/YVzHXlz+HeKAidhndKQru9uAgG/ATGPA5bxpkWEIoCWx1MrA/j+/rMIGmORskqowejc2\n aXZidxtO+AWQaa7Yg==",
        "X-Original-Sender": "stefano.babic@swupdate.org",
        "X-Original-Authentication-Results": "gmr-mx.google.com;       dkim=pass\n header.i=@swupdate.org header.s=s1-ionos header.b=Fj87bkJi;       spf=pass\n (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as\n permitted sender) smtp.mailfrom=stefano.babic@swupdate.org;       dmarc=pass\n (p=NONE sp=NONE dis=NONE) header.from=swupdate.org",
        "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-Spam-Checked-In-Group": "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": "This is in preparation for adding special handling on depend of the\nartifact name. The parsing of the artifact (JSON message) is split from\nthe processing.\n\nSigned-off-by: Stefano Babic <stefano.babic@swupdate.org>\n---\n suricatta/server_hawkbit.c | 138 ++++++++++++++++++++++++-------------\n suricatta/server_hawkbit.h |   9 +++\n 2 files changed, 100 insertions(+), 47 deletions(-)",
    "diff": "diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c\nindex 519638c1..dbd3e63c 100644\n--- a/suricatta/server_hawkbit.c\n+++ b/suricatta/server_hawkbit.c\n@@ -1081,46 +1081,15 @@ static void *process_notification_thread(void *data)\n \treturn NULL;\n }\n \n-server_op_res_t server_process_update_artifact(int action_id,\n-\t\t\t\t\t\tjson_object *json_data_artifact,\n-\t\t\t\t\t\tconst char *update_action,\n-\t\t\t\t\t\tconst char *part,\n-\t\t\t\t\t\tconst char *version,\n-\t\t\t\t\t\tconst char *name)\n+static server_op_res_t json_extract_artifact(struct array_list *json_data_artifact_array, int json_data_artifact_max,\n+\t\t\t\t      artifact_t *artifacts)\n {\n-\tchannel_t *channel = server_hawkbit.channel;\n-\tassert(channel != NULL);\n-\tassert(json_data_artifact != NULL);\n-\tassert(json_object_get_type(json_data_artifact) == json_type_array);\n-\tserver_op_res_t result = SERVER_OK;\n-\tpthread_t notify_to_hawkbit_thread;\n \n-\t/* Initialize list of errors */\n-\tfor (int i = 0; i < HAWKBIT_MAX_REPORTED_ERRORS; i++)\n-\t\tserver_hawkbit.errors[i] = NULL;\n-\tserver_hawkbit.errorcnt = 0;\n-\n-\tstruct array_list *json_data_artifact_array =\n-\t    json_object_get_array(json_data_artifact);\n-\tint json_data_artifact_max =\n-\t    json_object_array_length(json_data_artifact);\n-\tint json_data_artifact_installed = 0;\n \tjson_object *json_data_artifact_item = NULL;\n \n-\tchar *action_id_str;\n-\tif (asprintf(&action_id_str, \"%d\", action_id) == ENOMEM_ASPRINTF) {\n-\t\tERROR(\"OOM reached when saving action_id\");\n-\t\treturn SERVER_EERR;\n-\t}\n-\tif (swupdate_vars_set(\"action_id\", action_id_str, NULL)) {\n-\t\tWARN(\"Action_id cannot be stored, do yourself\");\n-\t}\n-\tfree(action_id_str);\n-\n \tfor (int json_data_artifact_count = 0;\n \t     json_data_artifact_count < json_data_artifact_max;\n \t     json_data_artifact_count++) {\n-\t\tint thread_ret = -1;\n \t\tjson_data_artifact_item = array_list_get_idx(\n \t\t    json_data_artifact_array, json_data_artifact_count);\n \t\tTRACE(\"Iterating over JSON, key=%s\",\n@@ -1147,8 +1116,7 @@ server_op_res_t server_process_update_artifact(int action_id,\n \t\tif (json_data_artifact_url_http == NULL) {\n \t\t\tserver_hawkbit_error(\"No artifact download HTTP URL reported by \"\n \t\t\t      \"server.\");\n-\t\t\tresult = SERVER_EBADMSG;\n-\t\t\tgoto cleanup;\n+\t\t\treturn SERVER_EBADMSG;\n \t\t}\n #endif\n \t\t/* TODO fall-back to HTTP in case HTTPS isn't available? */\n@@ -1158,8 +1126,7 @@ server_op_res_t server_process_update_artifact(int action_id,\n \t\t\t: json_data_artifact_url_https;\n \t\tif (json_data_artifact_url == NULL) {\n \t\t\tserver_hawkbit_error(\"No artifact download URL reported by server.\\n\");\n-\t\t\tresult = SERVER_EBADMSG;\n-\t\t\tgoto cleanup;\n+\t\t\treturn SERVER_EBADMSG;\n \t\t}\n \n \t\tif (json_data_artifact_filename == NULL ||\n@@ -1170,8 +1137,7 @@ server_op_res_t server_process_update_artifact(int action_id,\n \t\t\t    \"'filename', 'hashes->sha1', or 'size' in JSON.\\n\");\n \t\t\tDEBUG(\"Got JSON: %s\", json_object_to_json_string(\n \t\t\t\t\t\t    json_data_artifact_item));\n-\t\t\tresult = SERVER_EBADMSG;\n-\t\t\tgoto cleanup;\n+\t\t\treturn SERVER_EBADMSG;\n \t\t}\n \t\tassert(json_object_get_type(json_data_artifact_filename) ==\n \t\t       json_type_string);\n@@ -1182,25 +1148,96 @@ server_op_res_t server_process_update_artifact(int action_id,\n \t\tassert(json_object_get_type(json_data_artifact_url) ==\n \t\t       json_type_string);\n \n+\t\tartifacts[json_data_artifact_count].url =\n+\t\t    strdup(json_object_get_string(json_data_artifact_url));\n+\t\tartifacts[json_data_artifact_count].filename = strdup(json_object_get_string(json_data_artifact_filename));\n+\t\tartifacts[json_data_artifact_count].sha1hash = strdup(json_object_get_string(json_data_artifact_sha1hash));\n+\t\tartifacts[json_data_artifact_count].skip = false;\n+\t\tartifacts[json_data_artifact_count].size = json_object_get_int(json_data_artifact_size);\n+\n \t\t/*\n \t\t * Check if the file is a .swu image\n \t\t * and skip if it not\n \t\t */\n-\t\tconst char *s = json_object_get_string(json_data_artifact_filename);\n+\t\tconst char *s = artifacts[json_data_artifact_count].filename;\n \t\tint endfilename = strlen(s) - strlen(\".swu\");\n \t\tif (endfilename <= 0 ||\n \t\t    strncmp(&s[endfilename], \".swu\", 4)) {\n \t\t\tDEBUG(\"File '%s' is not a SWU image, skipping\", s);\n-\t\t\tcontinue;\n+\t\t\tartifacts[json_data_artifact_count].skip = true;\n \t\t}\n+\t}\n+\n+\treturn SERVER_OK;\n+}\n+\n+server_op_res_t server_process_update_artifact(int action_id,\n+\t\t\t\t\t\tjson_object *json_data_artifact,\n+\t\t\t\t\t\tconst char *update_action,\n+\t\t\t\t\t\tconst char *part,\n+\t\t\t\t\t\tconst char *version,\n+\t\t\t\t\t\tconst char *name)\n+{\n+\tchannel_t *channel = server_hawkbit.channel;\n+\tassert(channel != NULL);\n+\tassert(json_data_artifact != NULL);\n+\tassert(json_object_get_type(json_data_artifact) == json_type_array);\n+\tserver_op_res_t result = SERVER_OK;\n+\tpthread_t notify_to_hawkbit_thread;\n+\n+\t/* Initialize list of errors */\n+\tfor (int i = 0; i < HAWKBIT_MAX_REPORTED_ERRORS; i++)\n+\t\tserver_hawkbit.errors[i] = NULL;\n+\tserver_hawkbit.errorcnt = 0;\n+\n+\tstruct array_list *json_data_artifact_array =\n+\t    json_object_get_array(json_data_artifact);\n+\tint json_data_artifact_max =\n+\t    json_object_array_length(json_data_artifact);\n+\tint json_data_artifact_installed = 0;\n+\n+\tchar *action_id_str;\n+\tif (asprintf(&action_id_str, \"%d\", action_id) == ENOMEM_ASPRINTF) {\n+\t\tERROR(\"OOM reached when saving action_id\");\n+\t\treturn SERVER_EERR;\n+\t}\n+\tif (swupdate_vars_set(\"action_id\", action_id_str, NULL)) {\n+\t\tWARN(\"Action_id cannot be stored, do yourself\");\n+\t}\n+\tfree(action_id_str);\n+\n+\t/*\n+\t * Allocate space for meta information extracted from JSON\n+\t */\n+\tartifact_t *artifacts = (artifact_t *)(calloc(json_data_artifact_max, sizeof(*artifacts)));\n+\tif (!artifacts) {\n+\t\tERROR(\"OOM reached when allocating artifacts metadata\");\n+\t\treturn SERVER_EERR;\n+\t}\n+\n+\t/*\n+\t * Elaborate aritifacts, extract URL for download\n+\t * and check if some of them need some extra work or should be skipped\n+\t */\n+\tif (json_extract_artifact(json_data_artifact_array, json_data_artifact_max, artifacts) != SERVER_OK)\n+\t\tgoto cleanup;\n+\n+\tfor (int json_data_artifact_count = 0;\n+\t     json_data_artifact_count < json_data_artifact_max;\n+\t     json_data_artifact_count++) {\n+\t\tint thread_ret = -1;\n+\t\tartifact_t *artifact = &artifacts[json_data_artifact_count];\n+\n+\t\tif (artifact->skip)\n+\t\t\tcontinue;\n \n \t\tDEBUG(\"Processing '%s' from '%s'\",\n-\t\t      json_object_get_string(json_data_artifact_filename),\n-\t\t      json_object_get_string(json_data_artifact_url));\n+\t\t      artifact->filename,\n+\t\t      artifact->url);\n \n \t\tchannel_data_t channel_data = channel_data_defaults;\n-\t\tchannel_data.url =\n-\t\t    strdup(json_object_get_string(json_data_artifact_url));\n+\t\tchannel_data.url = \n+\t\t    strdup(artifact->url);\n \n \t\tstatic const char* const update_info = STRINGIFY(\n \t\t{\n@@ -1273,12 +1310,12 @@ server_op_res_t server_process_update_artifact(int action_id,\n \n #ifdef CONFIG_SURICATTA_SSL\n \t\tif (strncmp((char *)&channel_data.sha1hash,\n-\t\t\t    json_object_get_string(json_data_artifact_sha1hash),\n+\t\t\t    artifact->sha1hash,\n \t\t\t    SWUPDATE_SHA_DIGEST_LENGTH) != 0) {\n \t\t\t\tERROR(\n \t\t\t    \"Checksum does not match: Should be '%s', but \"\n \t\t\t    \"actually is '%s'.\\n\",\n-\t\t\t    json_object_get_string(json_data_artifact_sha1hash),\n+\t\t\t    artifact->sha1hash,\n \t\t\t    channel_data.sha1hash);\n \t\t\tipc_wait_for_complete(server_update_status_callback);\n \t\t\tresult = SERVER_EBADMSG;\n@@ -1331,6 +1368,13 @@ cleanup:\n \t\tfree(server_hawkbit.cached_file);\n \t\tserver_hawkbit.cached_file = NULL;\n \t}\n+\tfor (int count = 0; count < json_data_artifact_max; count++) {\n+\t\tartifact_t *artifact = &artifacts[count];\n+\t\tfree(artifact->filename);\n+\t\tfree(artifact->url);\n+\t\tfree(artifact->sha1hash);\n+\t}\n+\tfree(artifacts);\n \n \treturn result;\n }\ndiff --git a/suricatta/server_hawkbit.h b/suricatta/server_hawkbit.h\nindex 5f995aca..69113b3f 100644\n--- a/suricatta/server_hawkbit.h\n+++ b/suricatta/server_hawkbit.h\n@@ -10,6 +10,7 @@\n #include <state.h>\n #include <swupdate_dict.h>\n #include <channel.h>\n+#include <json-c/json.h>\n #include \"suricatta/server.h\"\n \n /* Have a queue for errors reported by installer */\n@@ -81,3 +82,11 @@ static const struct {\n \tconst char *forced;\n } deployment_update_action = {\n     .skip = \"skip\", .attempt = \"attempt\", .forced = \"forced\"};\n+\n+typedef struct {\n+\tchar *filename;\n+\tchar *url;\n+\tchar *sha1hash; \n+\tssize_t size;\n+\tbool skip;\n+} artifact_t;\n",
    "prefixes": [
        "1/9"
    ]
}