159db4265SNate Lawson /******************************************************************************
259db4265SNate Lawson *
359db4265SNate Lawson * Module Name: getopt
459db4265SNate Lawson *
559db4265SNate Lawson *****************************************************************************/
659db4265SNate Lawson
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim *
90d84335fSJung-uk Kim * 1. Copyright Notice
100d84335fSJung-uk Kim *
11*722b1667SJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp.
1259db4265SNate Lawson * All rights reserved.
1359db4265SNate Lawson *
140d84335fSJung-uk Kim * 2. License
150d84335fSJung-uk Kim *
160d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim * property rights.
200d84335fSJung-uk Kim *
210d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim *
280d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim *
370d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim * conditions are met:
390d84335fSJung-uk Kim *
400d84335fSJung-uk Kim * 3. Conditions
410d84335fSJung-uk Kim *
420d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim *
540d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim * make.
650d84335fSJung-uk Kim *
660d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim * distribution.
710d84335fSJung-uk Kim *
720d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim * Intel Code.
740d84335fSJung-uk Kim *
750d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim * without prior written authorization from Intel.
790d84335fSJung-uk Kim *
800d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim *
820d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim *
900d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim * LIMITED REMEDY.
980d84335fSJung-uk Kim *
990d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim * such license, approval or letter.
1130d84335fSJung-uk Kim *
1140d84335fSJung-uk Kim *****************************************************************************
1150d84335fSJung-uk Kim *
1160d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim * following license:
1180d84335fSJung-uk Kim *
119d244b227SJung-uk Kim * Redistribution and use in source and binary forms, with or without
120d244b227SJung-uk Kim * modification, are permitted provided that the following conditions
121d244b227SJung-uk Kim * are met:
122d244b227SJung-uk Kim * 1. Redistributions of source code must retain the above copyright
123d244b227SJung-uk Kim * notice, this list of conditions, and the following disclaimer,
124d244b227SJung-uk Kim * without modification.
125d244b227SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126d244b227SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below
127d244b227SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon
128d244b227SJung-uk Kim * including a substantially similar Disclaimer requirement for further
129d244b227SJung-uk Kim * binary redistribution.
130d244b227SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names
131d244b227SJung-uk Kim * of any contributors may be used to endorse or promote products derived
132d244b227SJung-uk Kim * from this software without specific prior written permission.
13359db4265SNate Lawson *
1340d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim *
1460d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the
147d244b227SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free
148d244b227SJung-uk Kim * Software Foundation.
14959db4265SNate Lawson *
1500d84335fSJung-uk Kim *****************************************************************************/
15159db4265SNate Lawson
152a9d8d09cSJung-uk Kim /*
153a9d8d09cSJung-uk Kim * ACPICA getopt() implementation
154a9d8d09cSJung-uk Kim *
155a9d8d09cSJung-uk Kim * Option strings:
156a9d8d09cSJung-uk Kim * "f" - Option has no arguments
157a9d8d09cSJung-uk Kim * "f:" - Option requires an argument
158f8146b88SJung-uk Kim * "f+" - Option has an optional argument
159a9d8d09cSJung-uk Kim * "f^" - Option has optional single-char sub-options
160a9d8d09cSJung-uk Kim * "f|" - Option has required single-char sub-options
161a9d8d09cSJung-uk Kim */
16259db4265SNate Lawson
163ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h>
164ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h>
165ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acapps.h>
16659db4265SNate Lawson
1674c52cad2SJung-uk Kim #define ACPI_OPTION_ERROR(msg, badchar) \
168493deb39SJung-uk Kim if (AcpiGbl_Opterr) {fprintf (stderr, "%s%c\n", msg, badchar);}
16959db4265SNate Lawson
17059db4265SNate Lawson
17159db4265SNate Lawson int AcpiGbl_Opterr = 1;
17259db4265SNate Lawson int AcpiGbl_Optind = 1;
173a9d8d09cSJung-uk Kim int AcpiGbl_SubOptChar = 0;
17459db4265SNate Lawson char *AcpiGbl_Optarg;
17559db4265SNate Lawson
176a9d8d09cSJung-uk Kim static int CurrentCharPtr = 1;
177a9d8d09cSJung-uk Kim
178a9d8d09cSJung-uk Kim
179a9d8d09cSJung-uk Kim /*******************************************************************************
180a9d8d09cSJung-uk Kim *
181a9d8d09cSJung-uk Kim * FUNCTION: AcpiGetoptArgument
182a9d8d09cSJung-uk Kim *
183a9d8d09cSJung-uk Kim * PARAMETERS: argc, argv - from main
184a9d8d09cSJung-uk Kim *
185a9d8d09cSJung-uk Kim * RETURN: 0 if an argument was found, -1 otherwise. Sets AcpiGbl_Optarg
186a9d8d09cSJung-uk Kim * to point to the next argument.
187a9d8d09cSJung-uk Kim *
188a9d8d09cSJung-uk Kim * DESCRIPTION: Get the next argument. Used to obtain arguments for the
189a9d8d09cSJung-uk Kim * two-character options after the original call to AcpiGetopt.
190a9d8d09cSJung-uk Kim * Note: Either the argument starts at the next character after
191a9d8d09cSJung-uk Kim * the option, or it is pointed to by the next argv entry.
192a9d8d09cSJung-uk Kim * (After call to AcpiGetopt, we need to backup to the previous
193a9d8d09cSJung-uk Kim * argv entry).
194a9d8d09cSJung-uk Kim *
195a9d8d09cSJung-uk Kim ******************************************************************************/
196a9d8d09cSJung-uk Kim
197a9d8d09cSJung-uk Kim int
AcpiGetoptArgument(int argc,char ** argv)198a9d8d09cSJung-uk Kim AcpiGetoptArgument (
199a9d8d09cSJung-uk Kim int argc,
200a9d8d09cSJung-uk Kim char **argv)
201a9d8d09cSJung-uk Kim {
202f8146b88SJung-uk Kim
203a9d8d09cSJung-uk Kim AcpiGbl_Optind--;
204a9d8d09cSJung-uk Kim CurrentCharPtr++;
205a9d8d09cSJung-uk Kim
206a9d8d09cSJung-uk Kim if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
207a9d8d09cSJung-uk Kim {
208a9d8d09cSJung-uk Kim AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
209a9d8d09cSJung-uk Kim }
210a9d8d09cSJung-uk Kim else if (++AcpiGbl_Optind >= argc)
211a9d8d09cSJung-uk Kim {
212493deb39SJung-uk Kim ACPI_OPTION_ERROR ("\nOption requires an argument", 0);
213a9d8d09cSJung-uk Kim
214a9d8d09cSJung-uk Kim CurrentCharPtr = 1;
215a9d8d09cSJung-uk Kim return (-1);
216a9d8d09cSJung-uk Kim }
217a9d8d09cSJung-uk Kim else
218a9d8d09cSJung-uk Kim {
219a9d8d09cSJung-uk Kim AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
220a9d8d09cSJung-uk Kim }
221a9d8d09cSJung-uk Kim
222a9d8d09cSJung-uk Kim CurrentCharPtr = 1;
223a9d8d09cSJung-uk Kim return (0);
224a9d8d09cSJung-uk Kim }
225a9d8d09cSJung-uk Kim
22659db4265SNate Lawson
22759db4265SNate Lawson /*******************************************************************************
22859db4265SNate Lawson *
22959db4265SNate Lawson * FUNCTION: AcpiGetopt
23059db4265SNate Lawson *
23159db4265SNate Lawson * PARAMETERS: argc, argv - from main
23259db4265SNate Lawson * opts - options info list
23359db4265SNate Lawson *
234313a0c13SJung-uk Kim * RETURN: Option character or ACPI_OPT_END
23559db4265SNate Lawson *
23659db4265SNate Lawson * DESCRIPTION: Get the next option
23759db4265SNate Lawson *
23859db4265SNate Lawson ******************************************************************************/
23959db4265SNate Lawson
24059db4265SNate Lawson int
AcpiGetopt(int argc,char ** argv,char * opts)24159db4265SNate Lawson AcpiGetopt(
24259db4265SNate Lawson int argc,
24359db4265SNate Lawson char **argv,
24459db4265SNate Lawson char *opts)
24559db4265SNate Lawson {
24659db4265SNate Lawson int CurrentChar;
24759db4265SNate Lawson char *OptsPtr;
24859db4265SNate Lawson
24959db4265SNate Lawson
25059db4265SNate Lawson if (CurrentCharPtr == 1)
25159db4265SNate Lawson {
25259db4265SNate Lawson if (AcpiGbl_Optind >= argc ||
25359db4265SNate Lawson argv[AcpiGbl_Optind][0] != '-' ||
25459db4265SNate Lawson argv[AcpiGbl_Optind][1] == '\0')
25559db4265SNate Lawson {
256313a0c13SJung-uk Kim return (ACPI_OPT_END);
25759db4265SNate Lawson }
2585ef50723SJung-uk Kim else if (strcmp (argv[AcpiGbl_Optind], "--") == 0)
25959db4265SNate Lawson {
26059db4265SNate Lawson AcpiGbl_Optind++;
261313a0c13SJung-uk Kim return (ACPI_OPT_END);
26259db4265SNate Lawson }
26359db4265SNate Lawson }
26459db4265SNate Lawson
26559db4265SNate Lawson /* Get the option */
26659db4265SNate Lawson
26742fecd12SJung-uk Kim CurrentChar = argv[AcpiGbl_Optind][CurrentCharPtr];
26859db4265SNate Lawson
26959db4265SNate Lawson /* Make sure that the option is legal */
27059db4265SNate Lawson
27159db4265SNate Lawson if (CurrentChar == ':' ||
2725ef50723SJung-uk Kim (OptsPtr = strchr (opts, CurrentChar)) == NULL)
27359db4265SNate Lawson {
2744c52cad2SJung-uk Kim ACPI_OPTION_ERROR ("Illegal option: -", CurrentChar);
27559db4265SNate Lawson
27659db4265SNate Lawson if (argv[AcpiGbl_Optind][++CurrentCharPtr] == '\0')
27759db4265SNate Lawson {
27859db4265SNate Lawson AcpiGbl_Optind++;
27959db4265SNate Lawson CurrentCharPtr = 1;
28059db4265SNate Lawson }
28159db4265SNate Lawson
28259db4265SNate Lawson return ('?');
28359db4265SNate Lawson }
28459db4265SNate Lawson
28559db4265SNate Lawson /* Option requires an argument? */
28659db4265SNate Lawson
28759db4265SNate Lawson if (*++OptsPtr == ':')
28859db4265SNate Lawson {
289f556842eSJung-uk Kim if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
29059db4265SNate Lawson {
291f556842eSJung-uk Kim AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
29259db4265SNate Lawson }
29359db4265SNate Lawson else if (++AcpiGbl_Optind >= argc)
29459db4265SNate Lawson {
295f8146b88SJung-uk Kim ACPI_OPTION_ERROR (
296f8146b88SJung-uk Kim "Option requires an argument: -", CurrentChar);
29759db4265SNate Lawson
29859db4265SNate Lawson CurrentCharPtr = 1;
29959db4265SNate Lawson return ('?');
30059db4265SNate Lawson }
30159db4265SNate Lawson else
30259db4265SNate Lawson {
30359db4265SNate Lawson AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
30459db4265SNate Lawson }
30559db4265SNate Lawson
30659db4265SNate Lawson CurrentCharPtr = 1;
30759db4265SNate Lawson }
30859db4265SNate Lawson
309bf6fac21SJung-uk Kim /* Option has an optional argument? */
310bf6fac21SJung-uk Kim
311bf6fac21SJung-uk Kim else if (*OptsPtr == '+')
312bf6fac21SJung-uk Kim {
313bf6fac21SJung-uk Kim if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
314bf6fac21SJung-uk Kim {
315bf6fac21SJung-uk Kim AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
316bf6fac21SJung-uk Kim }
317bf6fac21SJung-uk Kim else if (++AcpiGbl_Optind >= argc)
318bf6fac21SJung-uk Kim {
319bf6fac21SJung-uk Kim AcpiGbl_Optarg = NULL;
320bf6fac21SJung-uk Kim }
321bf6fac21SJung-uk Kim else
322bf6fac21SJung-uk Kim {
323bf6fac21SJung-uk Kim AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
324bf6fac21SJung-uk Kim }
325bf6fac21SJung-uk Kim
326bf6fac21SJung-uk Kim CurrentCharPtr = 1;
327bf6fac21SJung-uk Kim }
328bf6fac21SJung-uk Kim
32959db4265SNate Lawson /* Option has optional single-char arguments? */
33059db4265SNate Lawson
33159db4265SNate Lawson else if (*OptsPtr == '^')
33259db4265SNate Lawson {
333f556842eSJung-uk Kim if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
33459db4265SNate Lawson {
335f556842eSJung-uk Kim AcpiGbl_Optarg = &argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)];
33659db4265SNate Lawson }
33759db4265SNate Lawson else
33859db4265SNate Lawson {
33959db4265SNate Lawson AcpiGbl_Optarg = "^";
34059db4265SNate Lawson }
34159db4265SNate Lawson
342a9d8d09cSJung-uk Kim AcpiGbl_SubOptChar = AcpiGbl_Optarg[0];
34359db4265SNate Lawson AcpiGbl_Optind++;
34459db4265SNate Lawson CurrentCharPtr = 1;
34559db4265SNate Lawson }
34659db4265SNate Lawson
3474c52cad2SJung-uk Kim /* Option has a required single-char argument? */
3484c52cad2SJung-uk Kim
3494c52cad2SJung-uk Kim else if (*OptsPtr == '|')
3504c52cad2SJung-uk Kim {
3514c52cad2SJung-uk Kim if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
3524c52cad2SJung-uk Kim {
3534c52cad2SJung-uk Kim AcpiGbl_Optarg = &argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)];
3544c52cad2SJung-uk Kim }
3554c52cad2SJung-uk Kim else
3564c52cad2SJung-uk Kim {
357f8146b88SJung-uk Kim ACPI_OPTION_ERROR (
358f8146b88SJung-uk Kim "Option requires a single-character suboption: -",
359f8146b88SJung-uk Kim CurrentChar);
3604c52cad2SJung-uk Kim
3614c52cad2SJung-uk Kim CurrentCharPtr = 1;
3624c52cad2SJung-uk Kim return ('?');
3634c52cad2SJung-uk Kim }
3644c52cad2SJung-uk Kim
365a9d8d09cSJung-uk Kim AcpiGbl_SubOptChar = AcpiGbl_Optarg[0];
3664c52cad2SJung-uk Kim AcpiGbl_Optind++;
3674c52cad2SJung-uk Kim CurrentCharPtr = 1;
3684c52cad2SJung-uk Kim }
3694c52cad2SJung-uk Kim
37059db4265SNate Lawson /* Option with no arguments */
37159db4265SNate Lawson
37259db4265SNate Lawson else
37359db4265SNate Lawson {
37459db4265SNate Lawson if (argv[AcpiGbl_Optind][++CurrentCharPtr] == '\0')
37559db4265SNate Lawson {
37659db4265SNate Lawson CurrentCharPtr = 1;
37759db4265SNate Lawson AcpiGbl_Optind++;
37859db4265SNate Lawson }
37959db4265SNate Lawson
38059db4265SNate Lawson AcpiGbl_Optarg = NULL;
38159db4265SNate Lawson }
38259db4265SNate Lawson
38359db4265SNate Lawson return (CurrentChar);
38459db4265SNate Lawson }
385