get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 810413,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/810413/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/swupdate/patch/20170906072324.15734-6-christian.storm@siemens.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": "<20170906072324.15734-6-christian.storm@siemens.com>",
    "list_archive_url": null,
    "date": "2017-09-06T07:23:24",
    "name": "[6/6] socket split: adapt tools",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "31d579d3fbef7f71552d192005ed56f8245317e0",
    "submitter": {
        "id": 72180,
        "url": "http://patchwork.ozlabs.org/api/1.2/people/72180/?format=api",
        "name": "Storm, Christian",
        "email": "christian.storm@siemens.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/swupdate/patch/20170906072324.15734-6-christian.storm@siemens.com/mbox/",
    "series": [
        {
            "id": 1707,
            "url": "http://patchwork.ozlabs.org/api/1.2/series/1707/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/swupdate/list/?series=1707",
            "date": "2017-09-06T07:23:24",
            "name": null,
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/1707/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/810413/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/810413/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<swupdate+bncBDD6BWV65QPBBEWGX3GQKGQEKQ6BNFY@googlegroups.com>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=googlegroups.com\n\t(client-ip=2a00:1450:400c:c09::238;\n\thelo=mail-wm0-x238.google.com;\n\tenvelope-from=swupdate+bncbdd6bwv65qpbbewgx3gqkgqekq6bnfy@googlegroups.com;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=googlegroups.com header.i=@googlegroups.com\n\theader.b=\"Zbgb+fsb\"; dkim-atps=neutral"
        ],
        "Received": [
            "from mail-wm0-x238.google.com (mail-wm0-x238.google.com\n\t[IPv6:2a00:1450:400c:c09::238])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xnFW92lyMz9t3f\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed,  6 Sep 2017 17:26:12 +1000 (AEST)",
            "by mail-wm0-x238.google.com with SMTP id x17sf922966wmd.0\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 06 Sep 2017 00:26:12 -0700 (PDT)",
            "by 10.28.214.213 with SMTP id n204ls2185731wmg.25.canary-gmail;\n\tWed, 06 Sep 2017 00:26:09 -0700 (PDT)",
            "from david.siemens.de (david.siemens.de. [192.35.17.14])\n\tby gmr-mx.google.com with ESMTPS id\n\tl133si45065wmb.3.2017.09.06.00.26.09\n\tfor <swupdate@googlegroups.com>\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 06 Sep 2017 00:26:09 -0700 (PDT)",
            "from mail1.siemens.de (mail1.siemens.de [139.23.33.14])\n\tby david.siemens.de (8.15.2/8.15.2) with ESMTPS id v867Q9m8021208\n\t(version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK)\n\tfor <swupdate@googlegroups.com>; Wed, 6 Sep 2017 09:26:09 +0200",
            "from MD1KR9XC.ad001.siemens.net ([139.25.69.251])\n\tby mail1.siemens.de (8.15.2/8.15.2) with ESMTP id v867Q9gP028166;\n\tWed, 6 Sep 2017 09:26:09 +0200"
        ],
        "ARC-Seal": [
            "i=2; a=rsa-sha256; t=1504682770; cv=pass;\n\td=google.com; s=arc-20160816;\n\tb=LCQS3M1r7NZCSbMYNLHOdCzAcazyPhNzx4zrXl6pukSf1IYzmTzJo/avq5EGr4473Q\n\tPDbhR+W4gWtbypkP6F04Y/z44HQJVvv7nn9tp2J5H0P9IkmCK64WU/qntxas4CzgOxQx\n\tiGROD7eURIZOhn4k4kcmAcccGlhpFXGFrjnzXOs05VYmWw6iBjMdEgUva+5CvqZrO7lq\n\tURw6yRmv9E53bihJgwT31eYbhBaPozJY5mlGcCb7mZfBmViwvRAa+UmMeCJ66Afhj48/\n\t5YNSVVECUu0OZZFEHvWjP+0KRl9jQPJMn+Te2T1Hln9b5qT3wUTwYh5guYkKLLjZSSYT\n\tBLSQ==",
            "i=1; a=rsa-sha256; t=1504682769; cv=none;\n\td=google.com; s=arc-20160816;\n\tb=LOg6yN/ggUweNk7AEzRwiGwkK5MxZL7MmKJlHJFGnL1cLQzRdV324+sNhj+m7uTNrQ\n\tHV1cE2rUVXZ+r3yTQk1KCb7+U+lprgSzLnrdxyEy3LoIFvzUNG72wkGzDtz6wl6fFEZ2\n\tS/nmvGPV+FJfCszIKVLRJUr8rRmTDjGKcrU+frcfZhjA1h01pKbxsWjQdKJp0B0vlCtv\n\tL11Y1DkpDUzheFz/x/J4YcMFXVXImEjr5GLNaof+aEW7uyAPcHfjccyRqPcHUQ9f+vhW\n\tWaIbinSRTTopP0L358JErdSomYfOXMKlc9+v9JO9chgGO56wtiAZO5wvPPPpDooSmIaO\n\tYisw=="
        ],
        "ARC-Message-Signature": [
            "i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20160816; \n\th=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n\t:list-id:mailing-list:precedence:references:in-reply-to:message-id\n\t:date:subject:cc:to:from:arc-authentication-results\n\t:arc-message-signature:mime-version:sender:dkim-signature\n\t:arc-authentication-results;\n\tbh=MeTjrxj1AKrnkYR26CyBZ/87oWV/nTx0Yg6j3D1TeOc=;\n\tb=tsk9/w7gDijejT6FuB6aKnvLdvjF2mh+7X92YkIxLZWnXMCcM2Lx24I2d+OLgfsqNC\n\tExoSis3jwnDXVpgRyanxfa4m//J7fTR8OH7skV09eIEAXVn9BbDPuOjmqp2FwkDNwtAP\n\tFaCBwqRIHx66/+nxJLYi4UPuJTIeLAHLSOB2MTCzHUkYhfIb8KSjh7ZCd+0khRq1vZ6P\n\tK1mKnYSr5lHPwh3GKiyarbyBcbNjvoWsd5JOB0UTQllsUc9Iiu72J4vgY8ZkARsaFVih\n\tiSDyxnwybxdJ7paq7/mZqain1OMPX8QNkZ3a/VPFQqNA3sxFTO8hcbu5uDIMfgWWb+kp\n\tHnsw==",
            "i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20160816; \n\th=references:in-reply-to:message-id:date:subject:cc:to:from\n\t:arc-authentication-results;\n\tbh=9x+7GUkHRq1R0Ib7j1ZTntFZ/Oobl4p1Jy/xDnciGGA=;\n\tb=XIkNjMp34gr4TdcETeKbgbq6I7B9tZ0aZ1JdnbCSk1mTFdVVgOLs2FmpQqv8NExgYe\n\td1QhGi4yK4ijOyRIQtm8tyPlKVgGJqCDrNUE08tD1bfc40/NqSFA95RWZsCrQZttz5fB\n\tn0xPBcQLMpipwzDb/Xd8LehrMMMZpP8d0YjDuZugDXZ0wPLu7L55F6PLH6crAwAfuY10\n\tv5PcClOdv3kHdjaBz2NTGlJeoRFpnmYj68x5mP2INGc1mYTXxcuscSSi4lrTBNgo7rGo\n\te5y1kPNO5+y3obI5VYyKSW5gllb8oGgYXY+e1cRFIigLXqlUij/rHrA9W69unTxSJDRR\n\t+Erg=="
        ],
        "ARC-Authentication-Results": [
            "i=2; gmr-mx.google.com;\n\tspf=neutral (google.com: 192.35.17.14 is neither permitted nor denied\n\tby best guess record for domain of\n\tchristian.storm@siemens.com)\n\tsmtp.mailfrom=christian.storm@siemens.com",
            "i=1; gmr-mx.google.com;\n\tspf=neutral (google.com: 192.35.17.14 is neither permitted nor denied\n\tby best guess record for domain of\n\tchristian.storm@siemens.com)\n\tsmtp.mailfrom=christian.storm@siemens.com"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=googlegroups.com; s=20161025;\n\th=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:x-original-sender:x-original-authentication-results\n\t:precedence:mailing-list:list-id:list-post:list-help:list-archive\n\t:list-subscribe:list-unsubscribe;\n\tbh=MeTjrxj1AKrnkYR26CyBZ/87oWV/nTx0Yg6j3D1TeOc=;\n\tb=Zbgb+fsb9GWV9hPeI/CsPktxhu+SJDebZ1aKYckQErOV+cck9u3gIY6eRYyHnLvNMX\n\t3g2jhpxaF6YFDrYWXcyluxL//ZRJLjw+rdeIm0Ed/7JjS6HuIZaClYnulUnjtkvd9l9J\n\t3EC3cDGZxicI8MwUWCvpODDWjWdsQcdv4hnSu0Plfdkn8C7F3FpIloeJ7WohKLYAP7c5\n\tm+TCNPlpj1nfYlXwW5fOtTT5OjLQVElKSEc+W/9+ooXkC8dNpyZIiKoowngvL8W22+sc\n\tR2Cb/+6U1aXqm3BuJvE1Ym4bH8GfG064L6C1UonKmOLZaHGx9wK4bZILTdqdFmli4enA\n\tOu8w==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=sender:x-gm-message-state:mime-version:from:to:cc:subject:date\n\t:message-id:in-reply-to:references:x-original-sender\n\t:x-original-authentication-results:precedence:mailing-list:list-id\n\t:x-spam-checked-in-group:list-post:list-help:list-archive\n\t:list-subscribe:list-unsubscribe;\n\tbh=MeTjrxj1AKrnkYR26CyBZ/87oWV/nTx0Yg6j3D1TeOc=;\n\tb=ReQimyOruVwpM4Q3JDX5+Ah9+/0e3b9QWcyTH9LHp7sTCGxgKmISq8PY9BT3PqJkVM\n\t5z4CA6FtfQ4imOyeOIWnDf2fjCIt+qvdtA5+K/TqJ3/qTiiqfDS5RRfMdfsL+i67Lc0L\n\tWOLeGweLnp0A9rJaR9E79kmp2JPh2wz3D6Sr/KNPbWFOOCWl2XhkSHh+Bp2iBtEKvivg\n\tqCdDGoPaCt9vfvBwfM7N0fra+gkeF2LZz4Bg5WjXG4h7o429AkVoQ2TQ9lXiXslHcsdg\n\tE2DMtTcjyhSymTa4qd5JLnieBG0MMUjx9+dFGNFjRJaPqonKIkxOVt+R+L/W6khh+6tZ\n\tgQ8w==",
        "Sender": "swupdate@googlegroups.com",
        "X-Gm-Message-State": "AHPjjUihZSb+K2KPtzcBP186rvVwY/yOfbnT4Dk2KSUst2rLWhYtIz4x\n\tc0VjDVxF4abg1Q==",
        "X-Google-Smtp-Source": "ADKCNb76C2ElHGC25739RQHirK6WkhlQ2holEwhbY+i9fffGvO3AX1jOBDBi3UPrEk7dE8ZkETLXdw==",
        "X-Received": [
            "by 10.28.60.133 with SMTP id j127mr1277wma.27.1504682770369;\n\tWed, 06 Sep 2017 00:26:10 -0700 (PDT)",
            "by 10.223.138.151 with SMTP id y23mr82928wry.21.1504682769902;\n\tWed, 06 Sep 2017 00:26:09 -0700 (PDT)"
        ],
        "MIME-Version": "1.0",
        "X-BeenThere": "swupdate@googlegroups.com",
        "Received-SPF": "neutral (google.com: 192.35.17.14 is neither permitted nor\n\tdenied by best guess record for domain of\n\tchristian.storm@siemens.com) client-ip=192.35.17.14; ",
        "From": "Christian Storm <christian.storm@siemens.com>",
        "To": "swupdate@googlegroups.com",
        "Cc": "Christian Storm <christian.storm@siemens.com>",
        "Subject": "[swupdate] [PATCH 6/6] socket split: adapt tools",
        "Date": "Wed,  6 Sep 2017 09:23:24 +0200",
        "Message-Id": "<20170906072324.15734-6-christian.storm@siemens.com>",
        "X-Mailer": "git-send-email 2.14.1",
        "In-Reply-To": "<20170906072324.15734-1-christian.storm@siemens.com>",
        "References": "<20170906072324.15734-1-christian.storm@siemens.com>",
        "X-Original-Sender": "christian.storm@siemens.com",
        "X-Original-Authentication-Results": "gmr-mx.google.com;       spf=neutral\n\t(google.com: 192.35.17.14 is neither permitted nor denied by best\n\tguess\n\trecord for domain of christian.storm@siemens.com)\n\tsmtp.mailfrom=christian.storm@siemens.com",
        "Content-Type": "text/plain; charset=\"UTF-8\"",
        "Precedence": "list",
        "Mailing-list": "list swupdate@googlegroups.com;\n\tcontact 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\t<mailto:swupdate@googlegroups.com>",
        "List-Help": "<https://groups.google.com/support/>,\n\t<mailto:swupdate+help@googlegroups.com>",
        "List-Archive": "<https://groups.google.com/group/swupdate",
        "List-Subscribe": "<https://groups.google.com/group/swupdate/subscribe>,\n\t<mailto:swupdate+subscribe@googlegroups.com>",
        "List-Unsubscribe": "<mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>,\n\t<https://groups.google.com/group/swupdate/subscribe>"
    },
    "content": "Adapt the tool executables to use the introduced\nprogress_ipc{.c,.h} and to respect a --socket command\nline switch to point them to the socket location in case\nthe configuration deviates from the default.\n\nSigned-off-by: Christian Storm <christian.storm@siemens.com>\n---\n tools/hawkbitcfg.c    | 32 ++++++++++++++++++++++++++---\n tools/progress.c      | 52 +++++++++--------------------------------------\n tools/sendtohawkbit.c | 56 +++++++++++++++++++++++++++++++++++----------------\n 3 files changed, 77 insertions(+), 63 deletions(-)",
    "diff": "diff --git a/tools/hawkbitcfg.c b/tools/hawkbitcfg.c\nindex b6c2122..6f0bc54 100644\n--- a/tools/hawkbitcfg.c\n+++ b/tools/hawkbitcfg.c\n@@ -32,12 +32,19 @@\n #include <fcntl.h>\n #include <sys/types.h>\n #include <sys/socket.h>\n+#include <getopt.h>\n #include \"network_ipc.h\"\n \n static void usage(char *program) {\n-\tprintf(\"%s <polling interval 0=from server> ..\\n\", program);\n+\tprintf(\"%s [-s <socket_path>] <polling interval 0=from server> ..\\n\", program);\n }\n \n+static struct option long_options[] = {\n+\t{\"help\", no_argument, NULL, 'h'},\n+\t{\"socket\", required_argument, NULL, 's'},\n+\t{NULL, 0, NULL, 0}\n+};\n+\n /*\n  * Simple example, it does nothing but calling the library\n  */\n@@ -47,7 +54,26 @@ int main(int argc, char *argv[]) {\n \tsize_t size;\n \tchar *buf;\n \n-\tif (argc < 2) {\n+\tint c;\n+\n+\twhile ((c = getopt_long(argc, argv, \"hs:\",\n+\t\t\t\tlong_options, NULL)) != EOF) {\n+\t\tswitch (c) {\n+\t\tcase 's':\n+\t\t\tSOCKET_CTRL_PATH = strdup(optarg);\n+\t\t\tbreak;\n+\t\tcase 'h':\n+\t\t\tusage(argv[0]);\n+\t\t\texit(0);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tusage(argv[0]);\n+\t\t\texit(1);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tif ((argc - optind) < 1) {\n \t\tusage(argv[0]);\n \t\texit(1);\n \t}\n@@ -67,7 +93,7 @@ int main(int argc, char *argv[]) {\n \t * case of failure\n \t */\n \n-\tsnprintf(buf, size, \"{ \\\"polling\\\" : \\\"%lu\\\"}\", strtoul(argv[1], NULL, 10));\n+\tsnprintf(buf, size, \"{ \\\"polling\\\" : \\\"%lu\\\"}\", strtoul(argv[optind], NULL, 10));\n \n \tfprintf(stdout, \"Sending: '%s'\", msg.data.instmsg.buf);\n \ndiff --git a/tools/progress.c b/tools/progress.c\nindex fe9f8ef..4db0b22 100644\n--- a/tools/progress.c\n+++ b/tools/progress.c\n@@ -36,7 +36,7 @@\n #include <pthread.h>\n #include <getopt.h>\n \n-#include <progress.h>\n+#include <progress_ipc.h>\n \n #define PSPLASH_MSG_SIZE\t64\n \n@@ -76,6 +76,7 @@ static struct option long_options[] = {\n \t{\"reboot\", no_argument, NULL, 'r'},\n \t{\"wait\", no_argument, NULL, 'w'},\n \t{\"color\", no_argument, NULL, 'c'},\n+\t{\"socket\", required_argument, NULL, 's'},\n \t{NULL, 0, NULL, 0}\n };\n \n@@ -89,6 +90,7 @@ static void usage(char *programname)\n \t\t\" -r, --reboot            : reboot after a successful update\\n\"\n \t\t\" -w, --wait              : wait for a connection with SWUpdate\\n\"\n \t\t\" -p, --psplash           : send info to the psplash process\\n\"\n+\t\t\" -s, --socket <path>     : path to progress IPC socket\\n\"\n \t\t\" -h, --help              : print this help and exit\\n\"\n \t\t);\n }\n@@ -177,45 +179,10 @@ static void psplash_progress(char *pipe, struct progress_msg *pmsg)\n \tfree(buf);\n }\n \n-static int connect_to_swupdate(int reconnect)\n-{\n-\tstruct sockaddr_un servaddr;\n-\tint fd, ret;\n-\n-\t/*\n-\t * The thread read from swupdate progress thread\n-\t * and forward messages to psplash\n-\t */\n-\tfd = socket(AF_LOCAL, SOCK_STREAM, 0);\n-\tbzero(&servaddr, sizeof(servaddr));\n-\tservaddr.sun_family = AF_LOCAL;\n-\tstrcpy(servaddr.sun_path, SOCKET_PROGRESS_PATH);\n-\n-\tfprintf(stdout, \"Trying to connect to SWUpdate...\\n\");\n-\n-\t/* Connection to SWUpdate */\n-\tdo {\n-\t\tret = connect(fd, (struct sockaddr *) &servaddr, sizeof(servaddr));\n-\t\tif (ret == 0)\n-\t\t\tbreak;\n-\t\tif (!reconnect) {\n-\t\t\tfprintf(stderr, \"no communication with swupdate\\n\");\n-\t\t\texit(1);\n-\t\t}\n-\n-\t\tusleep(10000);\n-\t} while (1);\n-\n-\tfprintf(stdout, \"Connected\\n\");\n-\n-\treturn fd;\n-}\n-\n int main(int argc, char **argv)\n {\n \tint connfd;\n \tstruct progress_msg msg;\n-\tint ret;\n \tconst char *tmpdir;\n \tchar psplash_pipe_path[256];\n \tint psplash_ok = 0;\n@@ -231,7 +198,7 @@ int main(int argc, char **argv)\n \tRECOVERY_STATUS\tstatus = IDLE;\t\t/* Update Status (Running, Failure) */\n \n \t/* Process options with getopt */\n-\twhile ((c = getopt_long(argc, argv, \"cwprh\",\n+\twhile ((c = getopt_long(argc, argv, \"cwprhs:\",\n \t\t\t\tlong_options, NULL)) != EOF) {\n \t\tswitch (c) {\n \t\tcase 'c':\n@@ -246,6 +213,9 @@ int main(int argc, char **argv)\n \t\tcase 'r':\n \t\t\topt_r = 1;\n \t\t\tbreak;\n+\t\tcase 's':\n+\t\t\tSOCKET_PROGRESS_PATH = strdup(optarg);\n+\t\t\tbreak;\n \t\tcase 'h':\n \t\t\tusage(argv[0]);\n \t\t\texit(0);\n@@ -266,14 +236,10 @@ int main(int argc, char **argv)\n \tconnfd = -1;\n \twhile (1) {\n \t\tif (connfd < 0) {\n-\t\t\tconnfd = connect_to_swupdate(opt_w);\n+\t\t\tconnfd = progress_ipc_connect(opt_w);\n \t\t}\n \n-\t\tret = read(connfd, &msg, sizeof(msg));\n-\t\tif (ret != sizeof(msg)) {\n-\t\t\tfprintf(stdout, \"Connection closing..\\n\");\n-\t\t\tclose(connfd);\n-\t\t\tconnfd = -1;\n+\t\tif (progress_ipc_receive(&connfd, &msg) == -1) {\n \t\t\tcontinue;\n \t\t}\n \ndiff --git a/tools/sendtohawkbit.c b/tools/sendtohawkbit.c\nindex c866507..2f8e34b 100644\n--- a/tools/sendtohawkbit.c\n+++ b/tools/sendtohawkbit.c\n@@ -32,15 +32,22 @@\n #include <fcntl.h>\n #include <sys/types.h>\n #include <sys/socket.h>\n+#include <getopt.h>\n #include \"network_ipc.h\"\n \n static void usage(char *program) {\n-\tprintf(\"%s <action id> <status> <finished> <execution> <detail 1> <detail 2> ..\\n\", program);\n+\tprintf(\"%s [-s <socket_path>] <action id> <status> <finished> <execution> <detail 1> <detail 2> ..\\n\", program);\n }\n \n int fd;\n int verbose = 1;\n \n+static struct option long_options[] = {\n+\t{\"help\", no_argument, NULL, 'h'},\n+\t{\"socket\", required_argument, NULL, 's'},\n+\t{NULL, 0, NULL, 0}\n+};\n+\n /*\n  * Simple example, it does nothing but calling the library\n  */\n@@ -49,8 +56,26 @@ int main(int argc, char *argv[]) {\n \tipc_message msg;\n \tsize_t size;\n \tchar *buf;\n+\tint c;\n+\n+\twhile ((c = getopt_long(argc, argv, \"hs:\",\n+\t\t\t\tlong_options, NULL)) != EOF) {\n+\t\tswitch (c) {\n+\t\tcase 's':\n+\t\t\tSOCKET_CTRL_PATH = strdup(optarg);\n+\t\t\tbreak;\n+\t\tcase 'h':\n+\t\t\tusage(argv[0]);\n+\t\t\texit(0);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tusage(argv[0]);\n+\t\t\texit(1);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n \n-\tif (argc < 3) {\n+\tif ((argc - optind) < 2) {\n \t\tusage(argv[0]);\n \t\texit(1);\n \t}\n@@ -69,26 +94,23 @@ int main(int argc, char *argv[]) {\n \t * An error or a NACK is returned in\n \t * case of failure\n \t */\n-\tfor (i = 1; i < argc; i++) {\n-\t\tswitch (i) {\n-\t\tcase 1:\n+\tfor (i = optind; i < argc; i++) {\n+\t\tif (i == optind) {\n \t\t\twritten = snprintf(buf, size, \"{ \\\"id\\\" : \\\"%lu\\\"\", strtoul(argv[i], NULL, 10));\n-\t\t\tbreak;\n-\t\tcase 2:\n+\t\t} else\n+\t\tif (i == optind+1) {\n \t\t\twritten = snprintf(buf, size, \", \\\"status\\\" : \\\"%s\\\"\", argv[i]);\n-\t\t\tbreak;\n-\t\tcase 3:\n+\t\t} else\n+\t\tif (i == optind+2) {\n \t\t\twritten = snprintf(buf, size, \",\\\"finished\\\" : \\\"%s\\\"\", argv[i]);\n-\t\t\tbreak;\n-\t\tcase 4:\n+\t\t} else\n+\t\tif (i == optind+3) {\n \t\t\twritten = snprintf(buf, size, \",\\\"execution\\\" : \\\"%s\\\"\", argv[i]);\n-\t\t\tbreak;\n-\t\tcase 5:\n+\t\t} else\n+\t\tif (i == optind+4) {\n \t\t\twritten = snprintf(buf, size, \",\\\"details\\\" : [ \\\"%s\\\"\", argv[i]);\n-\t\t\tbreak;\n-\t\tdefault:\n+\t\t} else {\n \t\t\twritten = snprintf(buf, size, \",\\\"%s\\\"\", argv[i]);\n-\t\t\tbreak;\n \t\t}\n \n \t\tbuf += written;\n@@ -98,7 +120,7 @@ int main(int argc, char *argv[]) {\n \t\t\tbreak;\n \t}\n \n-\tif (i > 4)\n+\tif (i > optind+4)\n \t\twritten = snprintf(buf, size, \"]}\");\n \telse\n \t\twritten = snprintf(buf, size, \"}\");\n",
    "prefixes": [
        "6/6"
    ]
}