From nobody Mon Nov 25 06:29:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+73888+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+73888+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1617929930120426.5485097586643; Thu, 8 Apr 2021 17:58:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Bb4HYY1788612xlSx0UMCEDN; Thu, 08 Apr 2021 17:58:49 -0700 X-Received: from esa.hc4959-67.iphmx.com (esa.hc4959-67.iphmx.com [139.138.35.140]) by mx.groups.io with SMTP id smtpd.web11.2068.1617912263260541164 for ; Thu, 08 Apr 2021 13:04:23 -0700 IronPort-SDR: eq31+DTGj3qUawMKmSxY4cdcj5AC+CWPz5uwxMSzHCXQFXuzf1Vg6B69u54H9PG+iHsD6pVIww /bQ7/Wvp0hifupQskAkT7UEcGL9lULy8Trt1C9H1QjJhFw4CZdr9S0HddzzoO185ArEfUdqdOv asvGErTV0XxrBJFTCk3aUSmjbSdZ/hlvR2BeJuBmX1dbSfrECIpbWCjO4hRRXrfy8fgzsXQyv2 IKYsyVxh4xwrFI9/AXGrGN2+30izSj3JhgZ/ArtCnge9spAmZ0LE6Pz/7IjqnM0AusMfYKYI7n nOo= X-Received: from mail-co1nam11lp2176.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.176]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2021 13:04:21 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=USifiHC10SKEawFYulZVUmzFTwHBHDhTw/tIS7DHmZXh8CR/6AjYcSv3trm0NdcCsYvOOSKt7ViIcmt4h8Y1oRtQesz57isN6+s9UPusHKs/Cb32iYkE1zOMlj2NXA55EFAim/mFELBHzTIhHA5dsnoA29kHtSg29Jx35XMZjFsbi3hd0vH9EqBAa94ytiSYLOIXZ1pTqRrZ5habnTI97uobSSgi+Mro7eMDCA8SRjDodO6GPCl48E50tK5oQ+WO7P0/7aMJbSwHNQ7rc8/wdjJVFdvrljJBvkMFNbryIHmYqnjCFJCDlo6G6lhj7kZtcCvzXEhzuBr8JEc6E2zPmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MF8vnDZERsGoBVtIaKqCelGBEeBFVM3di77b1hQDDy8=; b=K+Y7iuluEViMGUnv+OS92xi4FEKj2V0edq12IuwocbRBfxHErhuWzo1rG4DqVAS5jJc95q38ZD3MdwyD+r061+Plx2raCCsk19K8ZXrfsrrAyFO5yjr5lsbwnwZ9dJSad3992D1A/7gA0h5FHY3Ag80HxqajWikFssQxNoWbp1BTHT+VJRHz4C2JlxPiSkBWld1E1PfPbqB8ZVsLa4avq6KJQn42lpX/bc8KNtXwbe8YZN+M7zv5emUGrqdolITnBKFQJxGiHFQ4uyhV9wlHcxXoFOI4GqWgBe/BdLwOAc4pTbEdgWGl866fUUNVPHOA/Kp1/Gn3ZSW/5xX5NcIjLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 192.55.16.50) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none X-Received: from BN6PR11CA0005.namprd11.prod.outlook.com (2603:10b6:405:2::15) by SN1PR20MB2128.namprd20.prod.outlook.com (2603:10b6:802:28::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Thu, 8 Apr 2021 20:04:19 +0000 X-Received: from BN7NAM10FT057.eop-nam10.prod.protection.outlook.com (2603:10b6:405:2:cafe::8c) by BN6PR11CA0005.outlook.office365.com (2603:10b6:405:2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Thu, 8 Apr 2021 20:04:19 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 192.55.16.50) smtp.mailfrom=seagate.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=fail action=oreject header.from=seagate.com; X-Received: from sgspzesaa001.seagate.com (192.55.16.50) by BN7NAM10FT057.mail.protection.outlook.com (10.13.157.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 20:04:17 +0000 IronPort-SDR: CkYDzf1oQGRIQlhlfnNWjZbuwwYVkOxIHeMdch6T5KjPPo/o7xpHHp4g14Q89CSJinEiFIMQnh 0p/A7C1yve0ZsgNiMI6CWGASghj6u+azLdc9L+k/lg4TwgD4uPBPUcgie41QUihuodOlkL1tZq DpmqG0mPT6T+wMb8Xvo+zwaKBQgCJM4GkzBwKCdURO3pAxNgFnqcl96MziJ5eW7OlrmLUVK2zm hZOgLzs379G+W8lhK/lhe+i8tpiDuXhyeO1gWIWXhEUyxsePgMIl+WHhYkWjXcHbHkRM1O65N1 u0E= X-Received: from sgspiesaa001.seagate.com ([10.4.144.52]) by sgspzesaa001.seagate.com with ESMTP; 08 Apr 2021 13:04:55 -0700 IronPort-SDR: JBTal5HzHhZNmuNnf2yQuHZtXQvTY/SVhUNDcOa51KDCkjSYKOH121tBbUP5jXfbrJoqpViJgi JkfWbPVLPwD9GfG/NHfkQemaSDxHco+hMHlbo3L4/Op5WvwCUJiSdKIQAjXsM59O54icP9sZJL UwmcsN3miFRPJ5B5JqZB01NZnicCQFSKKQYN5eASj97pyt0XjkZxKAGLv7J/qMO+YGz20Eq1V8 wOKDJHtWsyx+Mt5/SNXwlhN95pe5/X2OCR47q0yEhJvfNE88a6j3SdUMdSmcaIbC3p5PBuQTJh XUg= X-IronPort-AV: E=Sophos;i="5.82,207,1613462400"; d="scan'208";a="19779265" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False STX-Internal-Mailhost: TRUE X-Received: from unknown (HELO ubuntu.localdomain) ([10.4.50.11]) by sgspiesaa001.seagate.com with ESMTP; 08 Apr 2021 13:02:10 -0700 From: "Tyler Erickson via groups.io" To: devel@edk2.groups.io Cc: Tyler Erickson Subject: [edk2-devel] [PATCH] StdLib: Add getopt_long support Date: Thu, 8 Apr 2021 14:03:46 -0600 Message-Id: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1f93724a-22e7-4eb1-11a8-08d8fac97e62 X-MS-TrafficTypeDiagnostic: SN1PR20MB2128: X-Microsoft-Antispam-PRVS: STX-Hosted-IronPort-Oubound: True X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: sFthoVVSLDOw2QlXDqxMkMruk7ZHpk4OQBuXHqL2amObrpZ96z9wGyQg/tRtCHHrIEKdxaSM1URKj+KOowHy/YMEvIUtj2odV806qeltA4Xf1oacAzpimgebUQB+ZhTAmB1cNpOqzyOkP/WfW11yr5MJu6nqZ7BhG1pVyQn6oUUprOA7B1ikpqcKeMvJ4F8VwNRWEyghm2NhIxcnTJsUn6ilSUu5UG9xysQi9kSNXUHJssPPorza1ZkS/BfBFAr8HSzX4XxaE17OnDc3o6q4SBcXxC/ca9dRWIm/nmOwNO/BVvoOwEQ0Z7lUd0ifOJaKjYeGoO740BDIUvxTaUJ0cTbZp++9/uTyosKzGc26o36EUN0OURN2nQCAMmcopV6g9Bi7CHXyCZ1u/hKEaMqsJd4BhyyzFwHBi7QnjNujhksgQzUbHIkFIhUW6jjammNgifLdvulz1DCyfassvXsEmByMCKrTn8LUU8invZcu8tB5EKIvn/ZQ0tZgOesvxSXJivUAg+hhEh/SE2mZTCFbzuGWX1YQByikSFSlg36+rkbVExwii3U8X802OGLrZrX0Nc7Hovkm4komo9Eu1LDLsoU/3ySK3yI+PepNGaLs5gUywKcLgwck/VuJ9VW4SIpnLP7OfyP7XxPteOCQ4c+FTBWNaCb/wqm9eF4PKUsN1EYbImdHI1GMarUPT1jdw4aN X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 20:04:17.9407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f93724a-22e7-4eb1-11a8-08d8fac97e62 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe;Ip=[192.55.16.50];Helo=[sgspzesaa001.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT057.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR20MB2128 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tyler.erickson@seagate.com X-Gm-Message-State: 580A4xkOYyw7zbI10tOtTuXAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1617929929; bh=WUullEKRExmG6yLMHQ1/XOWAuswoAyPKIDw9UzFHvjA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=MD0UHZAePhFRAE3lY5AJa82oqASsYNbrM4lu+L5TlTjD/Rw7U0lQcdN0H0dI8SHxsxh x25s0GUmKIGiF+nah1HXqM+VJqEa6zBokKscCwau7AI3mG1cS8ewY7eeGnPc6++efK1su 5HxwAOFFZyu+Kkb553IKr0QfXNXs+2qs2EQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Tyler Erickson Adding getopt_long support using the implementation in OpenBSD. Signed-off-by: Tyler Erickson --- StdLib/Include/unistd.h | 6 ------ StdLib/LibC/LibC.inf | 1 + StdLib/LibC/Uefi/Uefi.inf | 1 + StdLib/LibC/Uefi/compat.c | 43 +-------------------------------------- 4 files changed, 3 insertions(+), 48 deletions(-) diff --git a/StdLib/Include/unistd.h b/StdLib/Include/unistd.h index b2fd923..ca43c0b 100644 --- a/StdLib/Include/unistd.h +++ b/StdLib/Include/unistd.h @@ -37,9 +37,6 @@ int dup(int); int rename(const char *, const char *); =20 /* Functions implemented for compatibility. */ -int getopt(int, char * const [], const char *); -extern char *optarg; /* getopt(3) external variables */ -extern int optind; pid_t getpgrp(void); pid_t tcgetpgrp(int); char *getpass(const char *); @@ -156,9 +153,6 @@ long sysconf(int); int tcsetpgrp(int, pid_t); __aconst char *ttyname(int); =20 -extern int opterr; -extern int optopt; -extern int optreset; extern char *suboptarg; =20 int setegid(gid_t); diff --git a/StdLib/LibC/LibC.inf b/StdLib/LibC/LibC.inf index 5bb2053..6b6fa73 100644 --- a/StdLib/LibC/LibC.inf +++ b/StdLib/LibC/LibC.inf @@ -106,6 +106,7 @@ LibStdLib LibStdio LibString + LibErr DevConsole =20 ################################################################ diff --git a/StdLib/LibC/Uefi/Uefi.inf b/StdLib/LibC/Uefi/Uefi.inf index 1982dd9..817c985 100644 --- a/StdLib/LibC/Uefi/Uefi.inf +++ b/StdLib/LibC/Uefi/Uefi.inf @@ -31,6 +31,7 @@ Xform.c compat.c StubFunctions.c + getopt_long.c =20 [Packages] StdLib/StdLib.dec diff --git a/StdLib/LibC/Uefi/compat.c b/StdLib/LibC/Uefi/compat.c index 251863f..cb20e9c 100644 --- a/StdLib/LibC/Uefi/compat.c +++ b/StdLib/LibC/Uefi/compat.c @@ -95,48 +95,7 @@ #include #include #include - -#ifndef HAVE_GETOPT -char *optarg; -int optind =3D 1; -int -getopt(int argc, char **argv, char *args) -{ - size_t n; - size_t nlen =3D strlen(args); - char cmd; - char rv; - - if (argv[optind] && *argv[optind] =3D=3D '-') { - cmd =3D *(argv[optind] + 1); - - for (n =3D 0; n < nlen; n++) { - if (args[n] =3D=3D ':') - continue; - if (args[n] =3D=3D cmd) { - rv =3D *(argv[optind] + 1); - if (args[n+1] =3D=3D ':') { - if (*(argv[optind] + 2) !=3D '\0') { - optarg =3D argv[optind] + 2; - optind +=3D 1; - } else { - optarg =3D argv[optind + 1]; - optind +=3D 2; - } - if (!optarg) - optarg=3D""; - return rv; - } else { - optarg =3D NULL; - optind +=3D 1; - return rv; - } - } - } - } - return -1; -} -#endif +#include =20 #define ISPATHSEPARATOR(x) ((x =3D=3D '/') || (x =3D=3D '\\')) =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#73888): https://edk2.groups.io/g/devel/message/73888 Mute This Topic: https://groups.io/mt/81958045/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-