get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 135238,
    "url": "http://patchwork.dpdk.org/api/patches/135238/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20231215172632.3102502-7-euan.bourke@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": "<20231215172632.3102502-7-euan.bourke@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231215172632.3102502-7-euan.bourke@intel.com",
    "date": "2023-12-15T17:26:30",
    "name": "[v4,6/8] arg_parser: added common core string and heuristic parsers",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "82f00b196802c5838f6c66fe1cd3a0d363ca5b67",
    "submitter": {
        "id": 3231,
        "url": "http://patchwork.dpdk.org/api/people/3231/?format=api",
        "name": "Euan Bourke",
        "email": "euan.bourke@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/20231215172632.3102502-7-euan.bourke@intel.com/mbox/",
    "series": [
        {
            "id": 30582,
            "url": "http://patchwork.dpdk.org/api/series/30582/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=30582",
            "date": "2023-12-15T17:26:24",
            "name": "add new command line argument parsing library",
            "version": 4,
            "mbox": "http://patchwork.dpdk.org/series/30582/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/135238/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/135238/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 CA9BF43700;\n\tFri, 15 Dec 2023 18:27:25 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 8EFB1433AC;\n\tFri, 15 Dec 2023 18:27:02 +0100 (CET)",
            "from mgamail.intel.com (mgamail.intel.com [192.198.163.10])\n by mails.dpdk.org (Postfix) with ESMTP id 30046433AC\n for <dev@dpdk.org>; Fri, 15 Dec 2023 18:27:01 +0100 (CET)",
            "from orviesa001.jf.intel.com ([10.64.159.141])\n by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 15 Dec 2023 09:27:01 -0800",
            "from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151])\n by orviesa001.jf.intel.com with ESMTP; 15 Dec 2023 09:27:00 -0800"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1702661221; x=1734197221;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=zfSPueyhYozZXaM0NV4BRRu14E9MVKrTRbt8MBI3Hr4=;\n b=hq8yXfum/uqGebwQWHGUu/jpsGveUY+OjYHm0pvxCq2dhLuof4nd4Lrq\n ebtg4YD2nNJ00U5ByMvP9nzd5hFmb9q5EsKZWZUjAbwiP5eXs3YiTpsUE\n 02gyghsUBTPJjZbeO0lC34bp66yEyYrrhELD9vggcM8BNHgGCge3Pk5JZ\n NqG/Dvm5e7Y6JXGRI/kdPTdAk/mvUWJekwxub0M3S+jq0a1Tm46X47OPy\n 4fisUbY3GaVS7FtjqwkreDe6tGe3hIsrxSbVWNjhEUgvfGy+oqYcy2vUX\n uXyfaThLj4s8QO77WLuYHsl8dg9nEHUZcVEGFNwj8CHdq2dXiy7It3zmn A==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6600,9927,10925\"; a=\"2474255\"",
            "E=Sophos;i=\"6.04,279,1695711600\";\n   d=\"scan'208\";a=\"2474255\"",
            "E=Sophos;i=\"6.04,279,1695711600\"; d=\"scan'208\";a=\"22914284\""
        ],
        "X-ExtLoop1": "1",
        "From": "Euan Bourke <euan.bourke@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Euan Bourke <euan.bourke@intel.com>,\n Bruce Richardson <bruce.richardson@intel.com>",
        "Subject": "[PATCH v4 6/8] arg_parser: added common core string and heuristic\n parsers",
        "Date": "Fri, 15 Dec 2023 17:26:30 +0000",
        "Message-Id": "<20231215172632.3102502-7-euan.bourke@intel.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20231215172632.3102502-1-euan.bourke@intel.com>",
        "References": "\n <https://inbox.dpdk.org/dev/20231207161818.2590661-1-euan.bourke@intel.com/>\n <20231215172632.3102502-1-euan.bourke@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": "Two new functions, the first is a 'heuristic parser' which examines a\nstring describing a set of cores and determines based off heuristics\nwhether its a coremask or a corelist.\n\nSecond is a 'combined parser' which calls the first function and then\nbased off the returned value will call the relevant core string parser.\nThis function also takes a 'default_type' int which corresponds to\nwhich parser should be used in the case of an ambiguous string.\n\nSigned-off-by: Euan Bourke <euan.bourke@intel.com>\n---\n lib/arg_parser/arg_parser.c     | 62 ++++++++++++++++++++++++++++++++\n lib/arg_parser/rte_arg_parser.h | 64 +++++++++++++++++++++++++++++++++\n lib/arg_parser/version.map      |  2 ++\n 3 files changed, 128 insertions(+)",
    "diff": "diff --git a/lib/arg_parser/arg_parser.c b/lib/arg_parser/arg_parser.c\nindex 8d86a7b618..1755ecb3b2 100644\n--- a/lib/arg_parser/arg_parser.c\n+++ b/lib/arg_parser/arg_parser.c\n@@ -157,3 +157,65 @@ rte_arg_parse_coremask(const char *coremask, uint16_t *cores, uint32_t cores_len\n \n \treturn corebits_to_array(&mask, cores, cores_len);\n }\n+\n+int\n+rte_arg_parse_arg_type(const char *core_string)\n+{\n+\t/* Remove leading whitespace */\n+\twhile (isblank(*core_string))\n+\t\tcore_string++;\n+\n+\t/* Check for 0x prefix */\n+\tif (core_string[0] == '0' && tolower(core_string[1]) == 'x') {\n+\t\tif (core_string[2] != '\\0')\n+\t\t\treturn RTE_ARG_PARSE_TYPE_COREMASK;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tint i = 0, idx = 0;\n+\t/* Check for ',' and '-' and check for A-F */\n+\tdo {\n+\t\twhile (isblank(core_string[idx]))\n+\t\t\tidx++;\n+\n+\t\tif (core_string[idx] == ',' || core_string[idx] == '-')\n+\t\t\treturn RTE_ARG_PARSE_TYPE_CORELIST;\n+\n+\t\tif (isalpha(core_string[idx])) {\n+\t\t\tif (isxdigit(core_string[idx]))\n+\t\t\t\treturn RTE_ARG_PARSE_TYPE_COREMASK;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tidx++;\n+\t\ti++;\n+\t} while (core_string[idx] != '\\0');\n+\n+\t/* Check length of core_string if ambiguous as max length of a uint16_t is 5 digits\n+\t * implying its a coremask.\n+\t */\n+\tif (i > 5)\n+\t\treturn RTE_ARG_PARSE_TYPE_COREMASK;\n+\n+\treturn -EINVAL;\n+}\n+\n+int\n+rte_arg_parse_core_string(const char *core_string, uint16_t *cores, uint32_t cores_len,\n+\t\tint default_type)\n+{\n+\tif (default_type != RTE_ARG_PARSE_TYPE_COREMASK &&\n+\t\t\tdefault_type != RTE_ARG_PARSE_TYPE_CORELIST) {\n+\t\treturn -EINVAL;\n+\t}\n+\tswitch (rte_arg_parse_arg_type(core_string)) {\n+\tcase RTE_ARG_PARSE_TYPE_COREMASK:\n+\t\treturn rte_arg_parse_coremask(core_string, cores, cores_len);\n+\tcase RTE_ARG_PARSE_TYPE_CORELIST:\n+\t\treturn rte_arg_parse_corelist(core_string, cores, cores_len);\n+\tdefault:\n+\t\treturn default_type == RTE_ARG_PARSE_TYPE_COREMASK ?\n+\t\t\trte_arg_parse_coremask(core_string, cores, cores_len) :\n+\t\t\trte_arg_parse_corelist(core_string, cores, cores_len);\n+\t\treturn -EINVAL;\n+\t}\n+}\ndiff --git a/lib/arg_parser/rte_arg_parser.h b/lib/arg_parser/rte_arg_parser.h\nindex 49d7daa204..3b2df74d10 100644\n--- a/lib/arg_parser/rte_arg_parser.h\n+++ b/lib/arg_parser/rte_arg_parser.h\n@@ -23,6 +23,9 @@ extern \"C\" {\n \n #include <rte_compat.h>\n \n+#define RTE_ARG_PARSE_TYPE_COREMASK 0\n+#define RTE_ARG_PARSE_TYPE_CORELIST 1\n+#define RTE_ARG_PARSE_TYPE_UNKNOWN 2\n \n /**\n  * Convert a string describing a list of core ids into an array of core ids.\n@@ -92,6 +95,67 @@ __rte_experimental\n int\n rte_arg_parse_coremask(const char *coremask, uint16_t *cores, uint32_t cores_len);\n \n+/**\n+ * Use heuristics to determine if a string contains a coremask or a corelist.\n+ *\n+ * This function will check a series of conditions and return an int representing which\n+ * core type (mask or list) the string represents or report the type as unknown if the\n+ * string is ambiguous.\n+ *\n+ * @param core_string\n+ *   A string describing the intended cores to be parsed\n+ * @return\n+ *   int representing the core type\n+ *   RTE_ARG_PARSE_TYPE_COREMASK: coremask.\n+ *   RTE_ARG_PARSE_TYPE_CORELIST: corelist.\n+ *   RTE_ARG_PARSE_TYPE_UNKNOWN: unknown (ambiguous).\n+ *   -EINVAL if the string was invalid.\n+ */\n+__rte_experimental\n+int\n+rte_arg_parse_arg_type(const char *core_string);\n+\n+/**\n+ * Convert a string describing either a corelist or coremask into an array of core ids.\n+ *\n+ * This function will fill the \"cores\" array up to \"cores_len\" with the core ids described\n+ * in the \"core_string\". The string can either describe a corelist or a coremask, and\n+ * will be parsed accordingly. The number of unique core ids in the string is then returned.\n+ * For example:\n+ * \"1-4\" is treated as a corelist and results in an array of [1,2,3,4] with 4 being returned\n+ * \"0xA1\" is treated as a coremask and results in an array of [0,5,7] with 3 being returned\n+ *\n+ * In the case of an ambiguous string, the function will use the default_type parameter to\n+ * decide.\n+ *\n+ * NOTE: if the length of the input array is insufficient to hold the number of core ids\n+ * in \"core_string\" the input array is filled to capacity but the return value is the\n+ * number of elements which would have been written to the array, had enough space been\n+ * available. [This is similar to the behaviour of the snprintf function]. Because of\n+ * this, the number of core values in the \"core_string\" may be determined by calling the\n+ * function with a NULL array pointer and array length given as 0.\n+ *\n+ * @param core_string\n+ *   A string describing the intended cores to be parsed.\n+ * @param cores\n+ *   An array where to store the core ids.\n+ *   Array can be NULL if \"cores_len\" is 0.\n+ * @param cores_len\n+ *   The length of the \"cores\" array.\n+ *   If the size is smaller than that needed to hold all cores from \"core_string\"\n+ * @param default_type\n+ *   How to treat ambiguous cases (e.g. '4' could be mask or list).\n+ *   RTE_ARG_PARSE_TYPE_COREMASK: coremask.\n+ *   RTE_ARG_PARSE_TYPE_CORELIST: corelist.\n+ * @return\n+ *   n: the number of unique cores present in \"core_string\".\n+ *   -EINVAL if the string was invalid.\n+ *   NOTE: if n > \"cores_len\", then only \"cores_len\" elements in the \"cores\" array are valid.\n+ */\n+__rte_experimental\n+int\n+rte_arg_parse_core_string(const char *core_string, uint16_t *cores, uint32_t cores_len,\n+\t\tint default_type);\n \n #ifdef __cplusplus\n }\ndiff --git a/lib/arg_parser/version.map b/lib/arg_parser/version.map\nindex b44d4b02b7..1e54b91dae 100644\n--- a/lib/arg_parser/version.map\n+++ b/lib/arg_parser/version.map\n@@ -6,6 +6,8 @@ EXPERIMENTAL {\n \tglobal:\n \n \t# added in 24.03\n+\trte_arg_parse_arg_type;\n \trte_arg_parse_corelist;\n \trte_arg_parse_coremask;\n+\trte_arg_parse_core_string;\n };\n",
    "prefixes": [
        "v4",
        "6/8"
    ]
}