get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 812149,
    "url": "http://patchwork.ozlabs.org/api/patches/812149/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20170910132236.14318-6-robdclark@gmail.com/",
    "project": {
        "id": 18,
        "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api",
        "name": "U-Boot",
        "link_name": "uboot",
        "list_id": "u-boot.lists.denx.de",
        "list_email": "u-boot@lists.denx.de",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20170910132236.14318-6-robdclark@gmail.com>",
    "list_archive_url": null,
    "date": "2017-09-10T13:22:26",
    "name": "[U-Boot,v1,05/12] efi_loader: flesh out unicode protocol",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "e1e4d9c7b7e37dcc00de737d70c20c4e9d5e10e6",
    "submitter": {
        "id": 18760,
        "url": "http://patchwork.ozlabs.org/api/people/18760/?format=api",
        "name": "Rob Clark",
        "email": "robdclark@gmail.com"
    },
    "delegate": {
        "id": 3400,
        "url": "http://patchwork.ozlabs.org/api/users/3400/?format=api",
        "username": "agraf",
        "first_name": "Alexander",
        "last_name": "Graf",
        "email": "agraf@suse.de"
    },
    "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20170910132236.14318-6-robdclark@gmail.com/mbox/",
    "series": [
        {
            "id": 2401,
            "url": "http://patchwork.ozlabs.org/api/series/2401/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=2401",
            "date": "2017-09-10T13:22:21",
            "name": "efi_loader+video: support for Shell.efi",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/2401/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/812149/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/812149/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<u-boot-bounces@lists.denx.de>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"KkTJEaTG\"; dkim-atps=neutral"
        ],
        "Received": [
            "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xqsNS3tLCz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 10 Sep 2017 23:29:28 +1000 (AEST)",
            "by lists.denx.de (Postfix, from userid 105)\n\tid 5070BC21E74; Sun, 10 Sep 2017 13:25:22 +0000 (UTC)",
            "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id BBEB6C21F51;\n\tSun, 10 Sep 2017 13:23:37 +0000 (UTC)",
            "by lists.denx.de (Postfix, from userid 105)\n\tid C3D22C21EE4; Sun, 10 Sep 2017 13:23:08 +0000 (UTC)",
            "from mail-qk0-f194.google.com (mail-qk0-f194.google.com\n\t[209.85.220.194])\n\tby lists.denx.de (Postfix) with ESMTPS id 4B0CDC21F28\n\tfor <u-boot@lists.denx.de>; Sun, 10 Sep 2017 13:22:59 +0000 (UTC)",
            "by mail-qk0-f194.google.com with SMTP id o77so4071065qke.2\n\tfor <u-boot@lists.denx.de>; Sun, 10 Sep 2017 06:22:59 -0700 (PDT)",
            "from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a])\n\tby smtp.gmail.com with ESMTPSA id\n\ts69sm4195296qka.95.2017.09.10.06.22.56\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 10 Sep 2017 06:22:56 -0700 (PDT)"
        ],
        "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de",
        "X-Spam-Level": "",
        "X-Spam-Status": "No, score=-0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=PzMhEq5X4ZXskTKlDOGsIWsSXJlR83KTYQp3klUDDsQ=;\n\tb=KkTJEaTGJBuC7KJI2A5xsjpMPvY3CK6cf2qm4iyKXdTn6VuuwfzQiSCLNZ92lOYcIW\n\tvYJk2SoYHtwNP7erP+9M0TDOz5iEucs52WNUntNmdroDGNDgIMdeBQcG6B1SCtAmT9CQ\n\txIn9jkrdpdYYOCwbiXJ6vaWWNHtVPCKoRVJpXUgK5g2vCPT8xt1bSpCVpVo+6Awd7i9A\n\twGPhD+q/s4lgFtiggFiE8h8gS0uQ4Ef+A/zBV8RiddxX2RN9cndWJfiZnYMxPiNpywNQ\n\tqc8c1FjQyWhCqJYCZUQbsJN8pTPOiakol4GaPTZlfhLz9DYKtepoNfdJoAbr7Ac/Ya+6\n\tbfdA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=PzMhEq5X4ZXskTKlDOGsIWsSXJlR83KTYQp3klUDDsQ=;\n\tb=EeM/dy0TDN21pKF/KfcGbFsSBP9oRMjfAehPj6e+dAT+AgagTTK2c6osNiqVQ3xoIq\n\tPhqTR994PRKJ9I9Fzy6CGQaiLli+OIaBaxCUkM24CUIV/zTlV+XvEnTVJCVWQHYNHAqE\n\tZAs/NGOd0ZqmfxnpefNxs+5s7SWyz9BBomtLlHwgym5RnuF0tdIvO1QNWdLooOjDMJba\n\t2p3MqiR+g1uouFAnJ8BUxqPjiDDPifpYrfGWmQCYqmFVDSWPEtmw3kKHrmCZna2f/g8R\n\t7JvaxQUKeseeLPPG3VbAN+kkJxa276tpWhGjbAgS2IZoWPmf9Qsa5icEcwSuH4v0XiRx\n\t/KyQ==",
        "X-Gm-Message-State": "AHPjjUjUii3fUAVLG8nkh3Kzq7IAUuZMXU/5btgyxdQm/gNaUtWsVZYC\n\tFSctlU27cL5DeIpk3v8=",
        "X-Google-Smtp-Source": "AOwi7QBug7XuUQuiZNyHHL6+k5fJh1V+sfXT3y88l+nSOVx+wxc5U6zHDGWNFkRka3tRnU3OSYMdrw==",
        "X-Received": "by 10.55.167.144 with SMTP id q138mr11134617qke.74.1505049777992;\n\tSun, 10 Sep 2017 06:22:57 -0700 (PDT)",
        "From": "Rob Clark <robdclark@gmail.com>",
        "To": "U-Boot Mailing List <u-boot@lists.denx.de>",
        "Date": "Sun, 10 Sep 2017 09:22:26 -0400",
        "Message-Id": "<20170910132236.14318-6-robdclark@gmail.com>",
        "X-Mailer": "git-send-email 2.13.5",
        "In-Reply-To": "<20170910132236.14318-1-robdclark@gmail.com>",
        "References": "<20170910132236.14318-1-robdclark@gmail.com>",
        "Cc": "Heinrich Schuchardt <xypron.glpk@gmx.de>, Peter Jones <pjones@redhat.com>,\n\tLeif Lindholm <leif.lindholm@linaro.org>",
        "Subject": "[U-Boot] [PATCH v1 05/12] efi_loader: flesh out unicode protocol",
        "X-BeenThere": "u-boot@lists.denx.de",
        "X-Mailman-Version": "2.1.18",
        "Precedence": "list",
        "List-Id": "U-Boot discussion <u-boot.lists.denx.de>",
        "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>",
        "List-Archive": "<http://lists.denx.de/pipermail/u-boot/>",
        "List-Post": "<mailto:u-boot@lists.denx.de>",
        "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>",
        "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "u-boot-bounces@lists.denx.de",
        "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>"
    },
    "content": "Not complete, but enough for Shell.efi and SCT.efi.\n\nSigned-off-by: Rob Clark <robdclark@gmail.com>\n---\n include/efi_api.h             |   9 +++\n include/efi_loader.h          |   1 +\n lib/efi_loader/efi_boottime.c |   5 +-\n lib/efi_loader/efi_unicode.c  | 143 +++++++++++++++++++++++++++++++++++-------\n 4 files changed, 134 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/include/efi_api.h b/include/efi_api.h\nindex 4853b71497..5612dfad49 100644\n--- a/include/efi_api.h\n+++ b/include/efi_api.h\n@@ -804,6 +804,15 @@ struct efi_hii_string_protocol\n \t\tUINTN *secondary_languages_size);\n };\n \n+/*\n+ * Both UNICODE_COLLATION protocols seem to be the same thing, but\n+ * advertised with two different GUID's because, why not?\n+ */\n+\n+#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \\\n+\tEFI_GUID(0x1d85cd7f, 0xf43d, 0x11d2, \\\n+\t\t 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)\n+\n #define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \\\n \tEFI_GUID(0xa4c751fc, 0x23ae, 0x4c3e, \\\n \t\t 0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49)\ndiff --git a/include/efi_loader.h b/include/efi_loader.h\nindex 6668338d0b..4864b3ac77 100644\n--- a/include/efi_loader.h\n+++ b/include/efi_loader.h\n@@ -77,6 +77,7 @@ extern const efi_guid_t efi_guid_device_path_utilities_protocol;\n extern const efi_guid_t efi_guid_hii_config_routing_protocol;\n extern const efi_guid_t efi_guid_hii_database_protocol;\n extern const efi_guid_t efi_guid_hii_string_protocol;\n+extern const efi_guid_t efi_guid_unicode_collation_protocol;\n extern const efi_guid_t efi_guid_unicode_collation_protocol2;\n \n extern unsigned int __efi_runtime_start, __efi_runtime_stop;\ndiff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\nindex 04358e8aca..7b53570354 100644\n--- a/lib/efi_loader/efi_boottime.c\n+++ b/lib/efi_loader/efi_boottime.c\n@@ -788,9 +788,12 @@ void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *ob\n \tobj->protocols[7].guid = &efi_guid_hii_config_routing_protocol;\n \tobj->protocols[7].protocol_interface = (void *)&efi_hii_config_routing;\n \n-\tobj->protocols[8].guid = &efi_guid_unicode_collation_protocol2;\n+\tobj->protocols[8].guid = &efi_guid_unicode_collation_protocol;\n \tobj->protocols[8].protocol_interface = (void *)&efi_unicode_collation;\n \n+\tobj->protocols[9].guid = &efi_guid_unicode_collation_protocol2;\n+\tobj->protocols[9].protocol_interface = (void *)&efi_unicode_collation;\n+\n \tinfo->file_path = file_path;\n \tinfo->device_handle = efi_dp_find_obj(device_path, NULL);\n \ndiff --git a/lib/efi_loader/efi_unicode.c b/lib/efi_loader/efi_unicode.c\nindex fdf1a99812..8d8edfb45a 100644\n--- a/lib/efi_loader/efi_unicode.c\n+++ b/lib/efi_loader/efi_unicode.c\n@@ -7,59 +7,155 @@\n  */\n \n #include <common.h>\n+#include <charset.h>\n+#include <linux/ctype.h>\n #include <efi_loader.h>\n \n+const efi_guid_t efi_guid_unicode_collation_protocol =\n+\tEFI_UNICODE_COLLATION_PROTOCOL_GUID;\n+\n const efi_guid_t efi_guid_unicode_collation_protocol2 =\n \tEFI_UNICODE_COLLATION_PROTOCOL2_GUID;\n \n-INTN stri_coll(struct efi_unicode_collation_protocol *this,\n-\t       efi_string_t s1,\n-\t       efi_string_t s2)\n+static int matchn(efi_string_t s1, unsigned n1, efi_string_t s2, unsigned n2)\n+{\n+\tchar u1[MAX_UTF8_PER_UTF16 * n1 + 1];\n+\tchar u2[MAX_UTF8_PER_UTF16 * n2 + 1];\n+\n+\t*utf16_to_utf8((u8 *)u1, s1, n1) = '\\0';\n+\t*utf16_to_utf8((u8 *)u2, s2, n2) = '\\0';\n+\n+\treturn strcasecmp(u1, u2);\n+}\n+\n+static INTN EFIAPI stri_coll(struct efi_unicode_collation_protocol *this,\n+\t\t\t     efi_string_t s1,\n+\t\t\t     efi_string_t s2)\n {\n \tEFI_ENTRY(\"%p, \\\"%ls\\\", \\\"%ls\\\"\", this, s1, s2);\n-\treturn EFI_EXIT(0);\n+\n+\tunsigned n1 = utf16_strlen(s1);\n+\tunsigned n2 = utf16_strlen(s2);\n+\n+\treturn EFI_EXIT(matchn(s1, n1, s2, n2));\n }\n \n-bool metai_match(struct efi_unicode_collation_protocol *this,\n-\t\t efi_string_t string,\n-\t\t efi_string_t pattern)\n+static bool match(efi_string_t string, efi_string_t pattern)\n+{\n+\twhile (true) {\n+\t\tuint16_t p = *pattern++;\n+\t\tbool matches = false;\n+\n+\t\tif (p == '\\0' || *string == '\\0') {\n+\t\t\t/*\n+\t\t\t * End of pattern or string, succeed if\n+\t\t\t * end of both:\n+\t\t\t */\n+\t\t\treturn *string == p;\n+\t\t}\n+\n+\t\tswitch (p) {\n+\t\tcase '*':\n+\t\t\t/* Match zero or more chars: */\n+\t\t\twhile (*string != '\\0') {\n+\t\t\t\tif (match(string, pattern))\n+\t\t\t\t\treturn true;\n+\t\t\t\tstring++;\n+\t\t\t}\n+\t\t\treturn match(string, pattern);\n+\t\tcase '?':\n+\t\t\t/* Match any one char: */\n+\t\t\tstring++;\n+\t\t\tbreak;\n+\t\tcase '[':\n+\t\t\t/* Match char set, either [abc] or [a-c]: */\n+\n+\t\t\tif (pattern[0] == '\\0' || pattern[0] == ']') {\n+\t\t\t\t/* invalid pattern */\n+\t\t\t\treturn false;\n+\t\t\t}\n+\n+\t\t\tif (pattern[1] == '-') {\n+\t\t\t\tuint16_t lo, hi, c;\n+\n+\t\t\t\t/* range: [a-c] */\n+\t\t\t\tlo = pattern[0];\n+\t\t\t\thi = pattern[2];\n+\n+\t\t\t\tif (hi == '\\0' || hi == ']' || pattern[3] != ']') {\n+\t\t\t\t\t/* invalid pattern */\n+\t\t\t\t\treturn false;\n+\t\t\t\t}\n+\n+\t\t\t\tc  = tolower(*string);\n+\t\t\t\tlo = tolower(lo);\n+\t\t\t\thi = tolower(hi);\n+\n+\t\t\t\tif (lo <= c && c <= hi)\n+\t\t\t\t\tmatches = true;\n+\n+\t\t\t\tpattern += 4;\n+\t\t\t} else {\n+\t\t\t\t/* set: [abc] */\n+\t\t\t\twhile ((p = *pattern++) && p != ']')\n+\t\t\t\t\tif (matchn(string, 1, &p, 1))\n+\t\t\t\t\t\tmatches = true;\n+\t\t\t}\n+\n+\t\t\tif (!matches)\n+\t\t\t\treturn false;\n+\n+\t\t\tstring++;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tif (matchn(string, 1, &p, 1))\n+\t\t\t\treturn false;\n+\t\t\tstring++;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+\n+static bool EFIAPI metai_match(struct efi_unicode_collation_protocol *this,\n+\t\t\t       efi_string_t string,\n+\t\t\t       efi_string_t pattern)\n {\n \tEFI_ENTRY(\"%p, \\\"%ls\\\", \\\"%ls\\\"\", this, string, pattern);\n-\treturn EFI_EXIT(false);\n+\treturn EFI_EXIT(match(string, pattern));\n }\n \n-void str_lwr(struct efi_unicode_collation_protocol *this,\n-\t     efi_string_t string)\n+static void EFIAPI str_lwr(struct efi_unicode_collation_protocol *this,\n+\t\t\t   efi_string_t string)\n {\n \tEFI_ENTRY(\"%p, \\\"%ls\\\"\", this, string);\n \tEFI_EXIT(0);\n \treturn;\n }\n \n-void str_upr(struct efi_unicode_collation_protocol *this,\n-\t     efi_string_t string)\n+static void EFIAPI str_upr(struct efi_unicode_collation_protocol *this,\n+\t\t\t   efi_string_t string)\n {\n \tEFI_ENTRY(\"%p, \\\"%ls\\\"\", this, string);\n \tEFI_EXIT(0);\n \treturn;\n }\n \n-void fat_to_str(struct efi_unicode_collation_protocol *this,\n-\t\tUINTN fat_size,\n-\t\tuint8_t *fat,\n-\t\tefi_string_t string)\n+static void EFIAPI fat_to_str(struct efi_unicode_collation_protocol *this,\n+\t\t\t      UINTN fat_size,\n+\t\t\t      uint8_t *fat,\n+\t\t\t      efi_string_t string)\n {\n-\tEFI_ENTRY(\"%p, %lu, \\\"%s\\\", %p\", this, fat_size, fat, string);\n+\tEFI_ENTRY(\"%p, %zu, \\\"%s\\\", %p\", this, fat_size, fat, string);\n \tEFI_EXIT(0);\n \treturn;\n }\n \n-bool str_to_fat(struct efi_unicode_collation_protocol *this,\n-\t\tefi_string_t string,\n-\t\tUINTN fat_size,\n-\t\tuint8_t *fat)\n+static bool EFIAPI str_to_fat(struct efi_unicode_collation_protocol *this,\n+\t\t\t      efi_string_t string,\n+\t\t\t      UINTN fat_size,\n+\t\t\t      uint8_t *fat)\n {\n-\tEFI_ENTRY(\"%p, \\\"%ls\\\", %lu, %p\", this, string, fat_size, fat);\n+\tEFI_ENTRY(\"%p, \\\"%ls\\\", %zu, %p\", this, string, fat_size, fat);\n \treturn EFI_EXIT(false);\n }\n \n@@ -69,5 +165,6 @@ const struct efi_unicode_collation_protocol efi_unicode_collation = {\n \t.str_lwr = str_lwr,\n \t.str_upr = str_upr,\n \t.fat_to_str = fat_to_str,\n-\t.str_to_fat = str_to_fat\n+\t.str_to_fat = str_to_fat,\n+\t.supported_languages = (uint8_t *)\"eng\",\n };\n",
    "prefixes": [
        "U-Boot",
        "v1",
        "05/12"
    ]
}