get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 129833,
    "url": "http://patchwork.dpdk.org/api/patches/129833/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230802170052.955323-2-bruce.richardson@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20230802170052.955323-2-bruce.richardson@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230802170052.955323-2-bruce.richardson@intel.com",
    "date": "2023-08-02T17:00:52",
    "name": "[RFC,1/1] cmdline/dpdk-cmdline-gen: generate boilerplate for simple cmds",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "17c4951b95387ca90c134756e75ea80024ca84d6",
    "submitter": {
        "id": 20,
        "url": "http://patchwork.dpdk.org/api/people/20/?format=api",
        "name": "Bruce Richardson",
        "email": "bruce.richardson@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230802170052.955323-2-bruce.richardson@intel.com/mbox/",
    "series": [
        {
            "id": 29095,
            "url": "http://patchwork.dpdk.org/api/series/29095/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29095",
            "date": "2023-08-02T17:00:51",
            "name": "make cmdline library easier to use",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/29095/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/129833/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/129833/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id ED1AC42FB8;\n\tWed,  2 Aug 2023 19:01:09 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id D93D642D0C;\n\tWed,  2 Aug 2023 19:01:09 +0200 (CEST)",
            "from mgamail.intel.com (unknown [192.55.52.120])\n by mails.dpdk.org (Postfix) with ESMTP id 4C50B40DDB\n for <dev@dpdk.org>; Wed,  2 Aug 2023 19:01:08 +0200 (CEST)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 02 Aug 2023 10:01:07 -0700",
            "from silpixa00401385.ir.intel.com ([10.237.214.162])\n by orsmga004.jf.intel.com with ESMTP; 02 Aug 2023 10:01:05 -0700"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1690995668; x=1722531668;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=X6ZI85gtwK8LfRQcNZRcc6dweP+cwOg8uiM3yUQHZRE=;\n b=Jx9r/Lu6LgDCwqW5f4uBt5iZDe4+gtcxNEd9fKO0WEbMJKJJlVEdhCm3\n 5Vvv1ekpmwovR8oFFbPKMwGXNApYlRGDlVfgqGJhsHutJ/XPQemllk/rt\n uhQCQMXolPir09O2VHmCaSus2Hzroi+5D6CJ6ErIQvWQUljG02mIxEShZ\n 3lnvq3IIEwvOV5FgnGpAaSTqtERVD6q5ElKShv+xiqnvEPxYM+V6mp54Q\n HwXmB17t5NawegPOwFJdmcvvwekWAibs0aWPxAczEChfzyr7L18FoUj99\n EgXhxnRe+BxdxEphRGEj8ek3uRN+v5ckfxrdlk/kqrA7douk0hMnPscRd A==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6600,9927,10790\"; a=\"368545988\"",
            "E=Sophos;i=\"6.01,249,1684825200\"; d=\"scan'208\";a=\"368545988\"",
            "E=McAfee;i=\"6600,9927,10790\"; a=\"852944035\"",
            "E=Sophos;i=\"6.01,249,1684825200\"; d=\"scan'208\";a=\"852944035\""
        ],
        "X-ExtLoop1": "1",
        "From": "Bruce Richardson <bruce.richardson@intel.com>",
        "To": "dev@dpdk.org,\n\tOlivier Matz <olivier.matz@6wind.com>",
        "Cc": "Bruce Richardson <bruce.richardson@intel.com>",
        "Subject": "[RFC PATCH 1/1] cmdline/dpdk-cmdline-gen: generate boilerplate for\n simple cmds",
        "Date": "Wed,  2 Aug 2023 18:00:52 +0100",
        "Message-Id": "<20230802170052.955323-2-bruce.richardson@intel.com>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20230802170052.955323-1-bruce.richardson@intel.com>",
        "References": "<20230802170052.955323-1-bruce.richardson@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Provide a script for application developers to quickly generate the\nboilerplate code necessary for using the cmdline library.\n\nThis initial version works only with commands using simple strings and\nnumbers, but this is sufficient for many use-cases. Future extensions\ncould, no doubt, expand support to expose more capabilities of the\nlibrary.\n\nExample of use:\nThe script takes an input file with a list of commands the user wants in\nthe app, where the parameter variables are tagged with the type.\nFor example:\n\n\t$ cat commands.list\n\tlist\n\tadd <UINT16>x <UINT16>y\n\techo <STRING>message\n\tadd socket <STRING>path\n\tquit\n\nWhen run through the script as \"./dpdk-cmdline-gen.py commands.list\",\nthe output will be the contents of a header file with all the\nboilerplate necessary for a commandline instance with those commands.\n\nIf the flag --stubs is passed, an output header filename must also be\npassed, in which case both a header file with the definitions and a C\nfile with function stubs in it is written to disk. The separation is so\nthat the header file can be rewritten at any future point to add more\ncommands, while the C file can be kept as-is and extended by the user\nwith any additional functions needed.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n lib/cmdline/dpdk-cmdline-gen.py | 143 ++++++++++++++++++++++++++++++++\n 1 file changed, 143 insertions(+)\n create mode 100755 lib/cmdline/dpdk-cmdline-gen.py",
    "diff": "diff --git a/lib/cmdline/dpdk-cmdline-gen.py b/lib/cmdline/dpdk-cmdline-gen.py\nnew file mode 100755\nindex 0000000000..1b81c4f9dc\n--- /dev/null\n+++ b/lib/cmdline/dpdk-cmdline-gen.py\n@@ -0,0 +1,143 @@\n+#!/usr/bin/env python3\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2023 Intel Corporation\n+#\n+\n+import sys\n+import os\n+import argparse\n+\n+PARSE_FN_PARAMS = \"void *parsed_result, struct cmdline *cl, void *data\"\n+PARSE_FN_BODY = \"\"\"\n+    /* TODO: command action */\n+    RTE_SET_USED(parsed_result);\n+    RTE_SET_USED(cl);\n+    RTE_SET_USED(data);\n+\"\"\"\n+\n+def process_command(tokens, cfile):\n+    name = []\n+\n+    if tokens[0].startswith('<'):\n+        print(\"Error: each command must start with at least one literal string\",\n+                file=sys.stderr)\n+        sys.exit(1)\n+    for t in tokens:\n+        if t.startswith('<'):\n+            break;\n+        name.append(t)\n+    name = \"_\".join(name)\n+\n+    result_struct = []\n+    initializers = []\n+    token_list = []\n+    for t in tokens:\n+        if t.startswith('<'):\n+            t_type, t_name = t[1:].split('>')\n+            t_val = \"NULL\"\n+        else:\n+            t_type = \"STRING\"\n+            t_name = t\n+            t_val = f'\"{t}\"'\n+\n+        if t_type == \"STRING\":\n+            result_struct.append(f\"\\tcmdline_fixed_string_t {t_name};\")\n+            initializers.append(f\"static cmdline_parse_token_string_t cmd_{name}_{t_name}_tok =\\n\"\n+                    + f\"\\tTOKEN_STRING_INITIALIZER(struct cmd_{name}_result, {t_name}, {t_val});\")\n+        elif t_type in ['UINT8', 'UINT16', 'UINT32', 'UINT64',\n+                    'INT8', 'INT16', 'INT32', 'INT64']:\n+            result_struct.append(f\"\\t{t_type.lower()}_t {t_name};\")\n+            initializers.append(f\"static cmdline_parse_token_num_t cmd_{name}_{t_name}_tok =\\n\"\n+                    + f\"\\tTOKEN_NUM_INITIALIZER(struct cmd_{name}_result, {t_name}, RTE_{t_type});\")\n+        else:\n+            print(f\"Error: unknown token-type {t}\", file=sys.stderr)\n+            sys.exit(1)\n+        token_list.append(f\"cmd_{name}_{t_name}_tok\")\n+\n+    print(f\"/* Auto-generated handling for command '{' '.join(tokens)}' */\")\n+    # output function prototype\n+    func_sig = f\"void\\ncmd_{name}_parsed({PARSE_FN_PARAMS})\"\n+    print(f\"extern {func_sig};\\n\")\n+    # output function template if C file being written\n+    if (cfile):\n+        print(f\"{func_sig}\\n{{{PARSE_FN_BODY}}}\\n\", file=cfile)\n+    # output result data structure\n+    print(f\"struct cmd_{name}_result {{\\n\"\n+            + '\\n'.join(result_struct)\n+            + \"\\n};\\n\")\n+    # output the initializer tokens\n+    print(\"\\n\".join(initializers) + '\\n')\n+    # output the instance structure\n+    print(f\"static cmdline_parse_inst_t cmd_{name} = {{\\n\"\n+            + f'\\t.f = cmd_{name}_parsed,\\n'\n+            + f'\\t.data = NULL,\\n'\n+            + f'\\t.help_str = \"\",\\n'\n+            + f'\\t.tokens = {{')\n+    for t in token_list:\n+        print(f\"\\t\\t(void *)&{t},\")\n+    print(\"\\t\\tNULL\\n\"\n+            + \"\\t}\\n\"\n+            + \"};\\n\")\n+\n+    # return the instance structure name\n+    return f\"cmd_{name}\"\n+\n+def process_commands(infile, hfile, cfile):\n+    instances = []\n+\n+    # redirect stdout to output the header, to save passing file= each print\n+    old_sys_stdout = sys.stdout\n+    sys.stdout = hfile\n+\n+    print(f\"/* File autogenerated by {sys.argv[0]} */\")\n+    print('#ifndef GENERATED_COMMANDS_H')\n+    print('#define GENERATED_COMMANDS_H')\n+    print(\"#include <cmdline.h>\")\n+    print(\"#include <cmdline_parse_string.h>\")\n+    print(\"#include <cmdline_parse_num.h>\")\n+    print(\"\")\n+\n+    for line in infile.readlines():\n+        if line.lstrip().startswith('#'):\n+            continue\n+        instances.append(process_command(line.strip().split(), cfile))\n+\n+    print('static cmdline_parse_ctx_t ctx[] = {')\n+    for inst in instances:\n+        print(f'\\t&{inst},')\n+    print('\\tNULL')\n+    print('};\\n')\n+    print('#endif /* GENERATED_COMMANDS_H */')\n+\n+    sys.stdout = old_sys_stdout\n+\n+def main():\n+    ap = argparse.ArgumentParser()\n+    ap.add_argument(\"--stubs\", action=\"store_true\",\n+            help=\"Produce C file with empty function stubs for each command\")\n+    ap.add_argument(\"--output-file\", \"-o\", default=\"-\",\n+            help=\"Output header filename [default to stdout]\")\n+    ap.add_argument(\"infile\", type=argparse.FileType('r'),\n+            help=\"File with list of commands\")\n+    args = ap.parse_args()\n+\n+    if not args.stubs:\n+        if args.output_file == '-':\n+            process_commands(args.infile, sys.stdout, None)\n+        else:\n+            with open(args.output_file, \"w\") as hfile:\n+                process_commands(args.infile, hfile, None)\n+    else:\n+        if not args.output_file.endswith('.h'):\n+            print(\"Error: output filename must end with '.h' extension when creating stubs\",\n+                    file=sys.stderr)\n+            sys.exit(1)\n+\n+        cfilename = args.output_file[:-2] + '.c'\n+        with open(args.output_file, \"w\") as hfile:\n+            with open(cfilename, \"w\") as cfile:\n+                print(f\"#include \\\"{args.output_file}\\\"\\n\", file=cfile)\n+                process_commands(args.infile, hfile, cfile)\n+\n+if __name__ == \"__main__\":\n+    main()\n",
    "prefixes": [
        "RFC",
        "1/1"
    ]
}