From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@seagate.com header.s=stxiport header.b=TkgcPi6x; spf=pass (domain: seagate.com, ip: 139.138.35.140, mailfrom: tyler.erickson@seagate.com) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1617912263; x=1649448263; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=5BIwXhZaciGfxdcp7cEGbAN2kKwQRPoGXnLUjAcg3TY=; b=TkgcPi6xuZ3gW1DgDQ03UrCQ1F+4o/BbYRhfqmMQHIzzkB9CIR6PfDUf sAqCQiDexuVCJsByVxjAuvm3JgsVaAHE6mqKZEl8xZsn+AlPifJELUs4R DLzgsd6SABdtha8wBvihz2TO7Doj7zoUlzI4xHdSr49x7ZhjDg82e4DQu Y=; IronPort-SDR: eq31+DTGj3qUawMKmSxY4cdcj5AC+CWPz5uwxMSzHCXQFXuzf1Vg6B69u54H9PG+iHsD6pVIww /bQ7/Wvp0hifupQskAkT7UEcGL9lULy8Trt1C9H1QjJhFw4CZdr9S0HddzzoO185ArEfUdqdOv asvGErTV0XxrBJFTCk3aUSmjbSdZ/hlvR2BeJuBmX1dbSfrECIpbWCjO4hRRXrfy8fgzsXQyv2 IKYsyVxh4xwrFI9/AXGrGN2+30izSj3JhgZ/ArtCnge9spAmZ0LE6Pz/7IjqnM0AusMfYKYI7n nOo= 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MF8vnDZERsGoBVtIaKqCelGBEeBFVM3di77b1hQDDy8=; b=B3XNqc0d+R48a09P1BhZ7D6RcsTkyn/HjPiy5aX3zTB7R6EZzll5pY+G7bleYCPXBYfPSiJqR8Edyz40/uw1ghlR3LH/F6bHgPIxlZao5G6eoh7VYUSxfE65vbcAE9uGaC2InadlaX02idcL7BtIBp4HYdwER95+f3lbPzGF2EA= 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 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; 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= 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 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" To: devel@edk2.groups.io Cc: Tyler Erickson Subject: [PATCH] StdLib: Add getopt_long support Date: Thu, 8 Apr 2021 14:03:46 -0600 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Return-Path: tyler.erickson@seagate.com 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: BCL:0; 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-Forefront-Antispam-Report: CIP:192.55.16.50;CTRY:SG;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:sgspzesaa001.seagate.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(39860400002)(346002)(396003)(376002)(136003)(36840700001)(46966006)(82740400003)(36906005)(336012)(47076005)(36860700001)(6666004)(478600001)(36756003)(83380400001)(426003)(2616005)(316002)(44832011)(82310400003)(6916009)(70586007)(8676002)(81166007)(4326008)(26005)(356005)(186003)(70206006)(8936002)(86362001)(5660300002)(107886003)(2906002)(36900700001);DIR:OUT;SFP:1101; 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 *);=0D =0D /* Functions implemented for compatibility. */=0D -int getopt(int, char * const [], const char *);=0D -extern char *optarg; /* getopt(3) external variables */=0D -extern int optind;=0D pid_t getpgrp(void);=0D pid_t tcgetpgrp(int);=0D char *getpass(const char *);=0D @@ -156,9 +153,6 @@ long sysconf(int); int tcsetpgrp(int, pid_t);=0D __aconst char *ttyname(int);=0D =0D -extern int opterr;=0D -extern int optopt;=0D -extern int optreset;=0D extern char *suboptarg;=0D =0D int setegid(gid_t);=0D 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=0D LibStdio=0D LibString=0D + LibErr=0D DevConsole=0D =0D ################################################################=0D 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=0D compat.c=0D StubFunctions.c=0D + getopt_long.c=0D =0D [Packages]=0D StdLib/StdLib.dec=0D 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 =0D #include =0D #include =0D -=0D -#ifndef HAVE_GETOPT=0D -char *optarg;=0D -int optind =3D 1;=0D -int=0D -getopt(int argc, char **argv, char *args)=0D -{=0D - size_t n;=0D - size_t nlen =3D strlen(args);=0D - char cmd;=0D - char rv;=0D -=0D - if (argv[optind] && *argv[optind] =3D=3D '-') {=0D - cmd =3D *(argv[optind] + 1);=0D -=0D - for (n =3D 0; n < nlen; n++) {=0D - if (args[n] =3D=3D ':')=0D - continue;=0D - if (args[n] =3D=3D cmd) {=0D - rv =3D *(argv[optind] + 1);=0D - if (args[n+1] =3D=3D ':') {=0D - if (*(argv[optind] + 2) !=3D '\0') {=0D - optarg =3D argv[optind] + 2;=0D - optind +=3D 1;=0D - } else {=0D - optarg =3D argv[optind + 1];=0D - optind +=3D 2;=0D - }=0D - if (!optarg)=0D - optarg=3D"";=0D - return rv;=0D - } else {=0D - optarg =3D NULL;=0D - optind +=3D 1;=0D - return rv;=0D - }=0D - }=0D - }=0D - }=0D - return -1;=0D -}=0D -#endif=0D +#include =0D =0D #define ISPATHSEPARATOR(x) ((x =3D=3D '/') || (x =3D=3D '\\'))=0D =0D --=20 2.25.1