Debian Codegraph @

utils/getopt.c

raw symbols SCIP
1 /* Getopt for GNU.
2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20 /* Reduced and amended for OpenSCAP by:
21 * Jan Černý <[email protected]m>
22 */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #ifndef HAVE_GETOPT_H
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33
34 #include "oscap-tool.h"
35
36
37 #ifdef _LIBC
38 /* When used as part of glibc, error printing must be done differently
39 for standards compliance. getopt is not a cancellation point, so
40 it must not call functions that are, and it is specified by an
41 older standard than stdio locking, so it must not refer to
42 functions in the "user namespace" related to stdio locking.
43 Finally, it must use glibc's internal message translation so that
44 the messages are looked up in the proper text domain. */
45 # include <libintl.h>
46 # define fprintf __fxprintf_nocancel
47 # define flockfile(fp) _IO_flockfile (fp)
48 # define funlockfile(fp) _IO_funlockfile (fp)
49 #else
50 # define _(msgid) (msgid)
51 /* When used standalone, flockfile and funlockfile might not be
52 available. */
53 # ifndef _POSIX_THREAD_SAFE_FUNCTIONS
54 # define flockfile(fp) /* nop */
55 # define funlockfile(fp) /* nop */
56 # endif
57 /* When used standalone, do not attempt to use alloca. */
58 # define __libc_use_alloca(size) 0
59 # undef alloca
60 # define alloca(size) (abort (), (void *)0)
61 #endif
62
63 enum __ord
64 {
65 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
66 };
67 #define _GETOPT_DATA_INITIALIZER { 1, 1 }
68
69
70
71 struct _getopt_data
72 {
73 /* These have exactly the same meaning as the corresponding global
74 variables, except that they are used for the reentrant
75 versions of getopt. */
76 int optind;
77 int opterr;
78 int optopt;
79 char *optarg;
80
81 /* Internal members. */
82
83 /* True if the internal members have been initialized. */
84 int __initialized;
85
86 /* The next char to be scanned in the option-element
87 in which the last option character we returned was found.
88 This allows us to pick up the scan where we left off.
89
90 If this is zero, or a null string, it means resume the scan
91 by advancing to the next ARGV-element. */
92 char *__nextchar;
93
94 /* See __ord above. */
95 enum __ord __ordering;
96
97 /* Handle permutation of arguments. */
98
99 /* Describe the part of ARGV that contains non-options that have
100 been skipped. 'first_nonopt' is the index in ARGV of the first
101 of them; 'last_nonopt' is the index after the last of them. */
102
103 int __first_nonopt;
104 int __last_nonopt;
105 };
106
107 /* This implementation of 'getopt' has three modes for handling
108 options interspersed with non-option arguments. It can stop
109 scanning for options at the first non-option argument encountered,
110 as POSIX specifies. It can continue scanning for options after the
111 first non-option argument, but permute 'argv' as it goes so that,
112 after 'getopt' is done, all the options precede all the non-option
113 arguments and 'optind' points to the first non-option argument.
114 Or, it can report non-option arguments as if they were arguments to
115 the option character '\x01'.
116
117 The default behavior of 'getopt_long' is to permute the argument list.
118 When this implementation is used standalone, the default behavior of
119 'getopt' is to stop at the first non-option argument, but when it is
120 used as part of GNU libc it also permutes the argument list. In both
121 cases, setting the environment variable POSIXLY_CORRECT to any value
122 disables permutation.
123
124 If the first character of the OPTSTRING argument to 'getopt' or
125 'getopt_long' is '+', both functions will stop at the first
126 non-option argument. If it is '-', both functions will report
127 non-option arguments as arguments to the option character '\x01'. */
128
129 /* For communication from 'getopt' to the caller.
130 When 'getopt' finds an option that takes an argument,
131 the argument value is returned here.
132 Also, when 'ordering' is RETURN_IN_ORDER,
133 each non-option ARGV-element is returned here. */
134
135 char *optarg;
136
137 /* Index in ARGV of the next element to be scanned.
138 This is used for communication to and from the caller
139 and for communication between successive calls to 'getopt'.
140
141 On entry to 'getopt', zero means this is the first call; initialize.
142
143 When 'getopt' returns -1, this is the index of the first of the
144 non-option elements that the caller should itself scan.
145
146 Otherwise, 'optind' communicates from one call to the next
147 how much of ARGV has been scanned so far. */
148
149 /* 1003.2 says this must be 1 before any call. */
150 int optind = 1;
151
152 /* Callers store zero here to inhibit the error message
153 for unrecognized options. */
154
155 int opterr = 1;
156
157 /* Set to an option character which was unrecognized.
158 This must be initialized on some systems to avoid linking in the
159 system's own getopt implementation. */
160
161 int optopt = '?';
162
163 /* Keep a global copy of all internal members of getopt_data. */
164
165 static struct _getopt_data getopt_data;
166
167 /* Exchange two adjacent subsequences of ARGV.
168 One subsequence is elements [first_nonopt,last_nonopt)
169 which contains all the non-options that have been skipped so far.
170 The other is elements [last_nonopt,optind), which contains all
171 the options processed since those non-options were skipped.
172
173 'first_nonopt' and 'last_nonopt' are relocated so that they describe
174 the new indices of the non-options in ARGV after they are moved. */
175
176 static void
177 exchange (char **argv, struct _getopt_data *d)
178 {
179 int bottom = d->__first_nonopt;
180 int middle = d->__last_nonopt;
181 int top = d->optind;
182 char *tem;
183
184 /* Exchange the shorter segment with the far end of the longer segment.
185 That puts the shorter segment into the right place.
186 It leaves the longer segment in the right place overall,
187 but it consists of two parts that need to be swapped next. */
188
189 while (top > middle && middle > bottom)
190 {
191 if (top - middle > middle - bottom)
192 {
193 /* Bottom segment is the short one. */
194 int len = middle - bottom;
195 int i;
196
197 /* Swap it with the top part of the top segment. */
198 for (i = 0; i < len; i++)
199 {
200 tem = argv[bottom + i];
201 argv[bottom + i] = argv[top - (middle - bottom) + i];
202 argv[top - (middle - bottom) + i] = tem;
203 }
204 /* Exclude the moved bottom segment from further swapping. */
205 top -= len;
206 }
207 else
208 {
209 /* Top segment is the short one. */
210 int len = top - middle;
211 int i;
212
213 /* Swap it with the bottom part of the bottom segment. */
214 for (i = 0; i < len; i++)
215 {
216 tem = argv[bottom + i];
217 argv[bottom + i] = argv[middle + i];
218 argv[middle + i] = tem;
219 }
220 /* Exclude the moved top segment from further swapping. */
221 bottom += len;
222 }
223 }
224
225 /* Update records for the slots the non-options now occupy. */
226
227 d->__first_nonopt += (d->optind - d->__last_nonopt);
228 d->__last_nonopt = d->optind;
229 }
230
231 /* Process the argument starting with d->__nextchar as a long option.
232 d->optind should *not* have been advanced over this argument.
233
234 If the value returned is -1, it was not actually a long option, the
235 state is unchanged, and the argument should be processed as a set
236 of short options (this can only happen when long_only is true).
237 Otherwise, the option (and its argument, if any) have been consumed
238 and the return value is the value to return from _getopt_internal_r. */
239 static int
240 process_long_option (int argc, char **argv, const char *optstring,
241 const struct option *longopts, int *longind,
242 int long_only, struct _getopt_data *d,
243 int print_errors, const char *prefix)
244 {
245 char *nameend;
246 size_t namelen;
247 const struct option *p;
248 const struct option *pfound = NULL;
249 int n_options;
250 int option_index;
251
252 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
253 /* Do nothing. */ ;
254 namelen = nameend - d->__nextchar;
255
256 /* First look for an exact match, counting the options as a side
257 effect. */
258 for (p = longopts, n_options = 0; p->name; p++, n_options++)
259 if (!strncmp (p->name, d->__nextchar, namelen)
260 && namelen == strlen (p->name))
261 {
262 /* Exact match found. */
263 pfound = p;
264 option_index = n_options;
265 break;
266 }
267
268 if (pfound == NULL)
269 {
270 /* Didn't find an exact match, so look for abbreviations. */
271 unsigned char *ambig_set = NULL;
272 int ambig_malloced = 0;
273 int ambig_fallback = 0;
274 int indfound = -1;
275
276 for (p = longopts, option_index = 0; p->name; p++, option_index++)
277 if (!strncmp (p->name, d->__nextchar, namelen))
278 {
279 if (pfound == NULL)
280 {
281 /* First nonexact match found. */
282 pfound = p;
283 indfound = option_index;
284 }
285 else if (long_only
286 || pfound->has_arg != p->has_arg
287 || pfound->flag != p->flag
288 || pfound->val != p->val)
289 {
290 /* Second or later nonexact match found. */
291 if (!ambig_fallback)
292 {
293 if (!print_errors)
294 /* Don't waste effort tracking the ambig set if
295 we're not going to print it anyway. */
296 ambig_fallback = 1;
297 else if (!ambig_set)
298 {
299 if (__libc_use_alloca (n_options))
300 ambig_set = alloca (n_options);
301 else if ((ambig_set = malloc (n_options)) == NULL)
302 /* Fall back to simpler error message. */
303 ambig_fallback = 1;
304 else
305 ambig_malloced = 1;
306
307 if (ambig_set)
308 {
309 memset (ambig_set, 0, n_options);
310 ambig_set[indfound] = 1;
311 }
312 }
313 if (ambig_set)
314 ambig_set[option_index] = 1;
315 }
316 }
317 }
318
319 if (ambig_set || ambig_fallback)
320 {
321 if (print_errors)
322 {
323 if (ambig_fallback)
324 fprintf (stderr, _("%s: option '%s%s' is ambiguous\n"),
325 argv[0], prefix, d->__nextchar);
326 else
327 {
328 flockfile (stderr);
329 fprintf (stderr,
330 _("%s: option '%s%s' is ambiguous; possibilities:"),
331 argv[0], prefix, d->__nextchar);
332
333 for (option_index = 0; option_index < n_options; option_index++)
334 if (ambig_set[option_index])
335 fprintf (stderr, " '%s%s'",
336 prefix, longopts[option_index].name);
337
338 /* This must use 'fprintf' even though it's only
339 printing a single character, so that it goes through
340 __fxprintf_nocancel when compiled as part of glibc. */
341 fprintf (stderr, "\n");
342 funlockfile (stderr);
343 }
344 }
345 if (ambig_malloced)
346 free (ambig_set);
347 d->__nextchar += strlen (d->__nextchar);
348 d->optind++;
349 d->optopt = 0;
350 return '?';
351 }
352
353 option_index = indfound;
354 }
355
356 if (pfound == NULL)
357 {
358 /* Can't find it as a long option. If this is not getopt_long_only,
359 or the option starts with '--' or is not a valid short option,
360 then it's an error. */
361 if (!long_only || argv[d->optind][1] == '-'
362 || strchr (optstring, *d->__nextchar) == NULL)
363 {
364 if (print_errors)
365 fprintf (stderr, _("%s: unrecognized option '%s%s'\n"),
366 argv[0], prefix, d->__nextchar);
367
368 d->__nextchar = NULL;
369 d->optind++;
370 d->optopt = 0;
371 return '?';
372 }
373
374 /* Otherwise interpret it as a short option. */
375 return -1;
376 }
377
378 /* We have found a matching long option. Consume it. */
379 d->optind++;
380 d->__nextchar = NULL;
381 if (*nameend)
382 {
383 /* Don't test has_arg with >, because some C compilers don't
384 allow it to be used on enums. */
385 if (pfound->has_arg)
386 d->optarg = nameend + 1;
387 else
388 {
389 if (print_errors)
390 fprintf (stderr,
391 _("%s: option '%s%s' doesn't allow an argument\n"),
392 argv[0], prefix, pfound->name);
393
394 d->optopt = pfound->val;
395 return '?';
396 }
397 }
398 else if (pfound->has_arg == 1)
399 {
400 if (d->optind < argc)
401 d->optarg = argv[d->optind++];
402 else
403 {
404 if (print_errors)
405 fprintf (stderr,
406 _("%s: option '%s%s' requires an argument\n"),
407 argv[0], prefix, pfound->name);
408
409 d->optopt = pfound->val;
410 return optstring[0] == ':' ? ':' : '?';
411 }
412 }
413
414 if (longind != NULL)
415 *longind = option_index;
416 if (pfound->flag)
417 {
418 *(pfound->flag) = pfound->val;
419 return 0;
420 }
421 return pfound->val;
422 }
423
424 /* Initialize internal data upon the first call to getopt. */
425
426 static const char *
427 _getopt_initialize (int argc,
428 char **argv, const char *optstring,
429 struct _getopt_data *d, int posixly_correct)
430 {
431 /* Start processing options with ARGV-element 1 (since ARGV-element 0
432 is the program name); the sequence of previously skipped
433 non-option ARGV-elements is empty. */
434 if (d->optind == 0)
435 d->optind = 1;
436
437 d->__first_nonopt = d->__last_nonopt = d->optind;
438 d->__nextchar = NULL;
439
440 /* Determine how to handle the ordering of options and nonoptions. */
441 if (optstring[0] == '-')
442 {
443 d->__ordering = RETURN_IN_ORDER;
444 ++optstring;
445 }
446 else if (optstring[0] == '+')
447 {
448 d->__ordering = REQUIRE_ORDER;
449 ++optstring;
450 }
451 else if (posixly_correct || !!getenv ("POSIXLY_CORRECT"))
452 d->__ordering = REQUIRE_ORDER;
453 else
454 d->__ordering = PERMUTE;
455
456 d->__initialized = 1;
457 return optstring;
458 }
459
460 /* Scan elements of ARGV (whose length is ARGC) for option characters
461 given in OPTSTRING.
462
463 If an element of ARGV starts with '-', and is not exactly "-" or "--",
464 then it is an option element. The characters of this element
465 (aside from the initial '-') are option characters. If 'getopt'
466 is called repeatedly, it returns successively each of the option characters
467 from each of the option elements.
468
469 If 'getopt' finds another option character, it returns that character,
470 updating 'optind' and 'nextchar' so that the next call to 'getopt' can
471 resume the scan with the following option character or ARGV-element.
472
473 If there are no more option characters, 'getopt' returns -1.
474 Then 'optind' is the index in ARGV of the first ARGV-element
475 that is not an option. (The ARGV-elements have been permuted
476 so that those that are not options now come last.)
477
478 OPTSTRING is a string containing the legitimate option characters.
479 If an option character is seen that is not listed in OPTSTRING,
480 return '?' after printing an error message. If you set 'opterr' to
481 zero, the error message is suppressed but we still return '?'.
482
483 If a char in OPTSTRING is followed by a colon, that means it wants an arg,
484 so the following text in the same ARGV-element, or the text of the following
485 ARGV-element, is returned in 'optarg'. Two colons mean an option that
486 wants an optional arg; if there is text in the current ARGV-element,
487 it is returned in 'optarg', otherwise 'optarg' is set to zero.
488
489 If OPTSTRING starts with '-' or '+', it requests different methods of
490 handling the non-option ARGV-elements.
491 See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
492
493 Long-named options begin with '--' instead of '-'.
494 Their names may be abbreviated as long as the abbreviation is unique
495 or is an exact match for some defined option. If they have an
496 argument, it follows the option name in the same ARGV-element, separated
497 from the option name by a '=', or else the in next ARGV-element.
498 When 'getopt' finds a long-named option, it returns 0 if that option's
499 'flag' field is nonzero, the value of the option's 'val' field
500 if the 'flag' field is zero.
501
502 The elements of ARGV aren't really const, because we permute them.
503 But we pretend they're const in the prototype to be compatible
504 with other systems.
505
506 LONGOPTS is a vector of 'struct option' terminated by an
507 element containing a name which is zero.
508
509 LONGIND returns the index in LONGOPT of the long-named option found.
510 It is only valid when a long-named option has been found by the most
511 recent call.
512
513 If LONG_ONLY is nonzero, '-' as well as '--' can introduce
514 long-named options. */
515
516 int
517 _getopt_internal_r (int argc, char **argv, const char *optstring,
518 const struct option *longopts, int *longind,
519 int long_only, struct _getopt_data *d, int posixly_correct)
520 {
521 int print_errors = d->opterr;
522
523 if (argc < 1)
524 return -1;
525
526 d->optarg = NULL;
527
528 if (d->optind == 0 || !d->__initialized)
529 optstring = _getopt_initialize (argc, argv, optstring, d, posixly_correct);
530 else if (optstring[0] == '-' || optstring[0] == '+')
531 optstring++;
532
533 if (optstring[0] == ':')
534 print_errors = 0;
535
536 /* Test whether ARGV[optind] points to a non-option argument. */
537 #define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
538
539 if (d->__nextchar == NULL || *d->__nextchar == '\0')
540 {
541 /* Advance to the next ARGV-element. */
542
543 /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
544 moved back by the user (who may also have changed the arguments). */
545 if (d->__last_nonopt > d->optind)
546 d->__last_nonopt = d->optind;
547 if (d->__first_nonopt > d->optind)
548 d->__first_nonopt = d->optind;
549
550 if (d->__ordering == PERMUTE)
551 {
552 /* If we have just processed some options following some non-options,
553 exchange them so that the options come first. */
554
555 if (d->__first_nonopt != d->__last_nonopt
556 && d->__last_nonopt != d->optind)
557 exchange (argv, d);
558 else if (d->__last_nonopt != d->optind)
559 d->__first_nonopt = d->optind;
560
561 /* Skip any additional non-options
562 and extend the range of non-options previously skipped. */
563
564 while (d->optind < argc && NONOPTION_P)
565 d->optind++;
566 d->__last_nonopt = d->optind;
567 }
568
569 /* The special ARGV-element '--' means premature end of options.
570 Skip it like a null option,
571 then exchange with previous non-options as if it were an option,
572 then skip everything else like a non-option. */
573
574 if (d->optind != argc && !strcmp (argv[d->optind], "--"))
575 {
576 d->optind++;
577
578 if (d->__first_nonopt != d->__last_nonopt
579 && d->__last_nonopt != d->optind)
580 exchange (argv, d);
581 else if (d->__first_nonopt == d->__last_nonopt)
582 d->__first_nonopt = d->optind;
583 d->__last_nonopt = argc;
584
585 d->optind = argc;
586 }
587
588 /* If we have done all the ARGV-elements, stop the scan
589 and back over any non-options that we skipped and permuted. */
590
591 if (d->optind == argc)
592 {
593 /* Set the next-arg-index to point at the non-options
594 that we previously skipped, so the caller will digest them. */
595 if (d->__first_nonopt != d->__last_nonopt)
596 d->optind = d->__first_nonopt;
597 return -1;
598 }
599
600 /* If we have come to a non-option and did not permute it,
601 either stop the scan or describe it to the caller and pass it by. */
602
603 if (NONOPTION_P)
604 {
605 if (d->__ordering == REQUIRE_ORDER)
606 return -1;
607 d->optarg = argv[d->optind++];
608 return 1;
609 }
610
611 /* We have found another option-ARGV-element.
612 Check whether it might be a long option. */
613 if (longopts)
614 {
615 if (argv[d->optind][1] == '-')
616 {
617 /* "--foo" is always a long option. The special option
618 "--" was handled above. */
619 d->__nextchar = argv[d->optind] + 2;
620 return process_long_option (argc, argv, optstring, longopts,
621 longind, long_only, d,
622 print_errors, "--");
623 }
624
625 /* If long_only and the ARGV-element has the form "-f",
626 where f is a valid short option, don't consider it an
627 abbreviated form of a long option that starts with f.
628 Otherwise there would be no way to give the -f short
629 option.
630
631 On the other hand, if there's a long option "fubar" and
632 the ARGV-element is "-fu", do consider that an
633 abbreviation of the long option, just like "--fu", and
634 not "-f" with arg "u".
635
636 This distinction seems to be the most useful approach. */
637 if (long_only && (argv[d->optind][2]
638 || !strchr (optstring, argv[d->optind][1])))
639 {
640 int code;
641 d->__nextchar = argv[d->optind] + 1;
642 code = process_long_option (argc, argv, optstring, longopts,
643 longind, long_only, d,
644 print_errors, "-");
645 if (code != -1)
646 return code;
647 }
648 }
649
650 /* It is not a long option. Skip the initial punctuation. */
651 d->__nextchar = argv[d->optind] + 1;
652 }
653
654 /* Look at and handle the next short option-character. */
655
656 {
657 char c = *d->__nextchar++;
658 const char *temp = strchr (optstring, c);
659
660 /* Increment 'optind' when we start to process its last character. */
661 if (*d->__nextchar == '\0')
662 ++d->optind;
663
664 if (temp == NULL || c == ':' || c == ';')
665 {
666 if (print_errors)
667 fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
668 d->optopt = c;
669 return '?';
670 }
671
672 /* Convenience. Treat POSIX -W foo same as long option --foo */
673 if (temp[0] == 'W' && temp[1] == ';' && longopts != NULL)
674 {
675 /* This is an option that requires an argument. */
676 if (*d->__nextchar != '\0')
677 d->optarg = d->__nextchar;
678 else if (d->optind == argc)
679 {
680 if (print_errors)
681 fprintf (stderr,
682 _("%s: option requires an argument -- '%c'\n"),
683 argv[0], c);
684
685 d->optopt = c;
686 if (optstring[0] == ':')
687 c = ':';
688 else
689 c = '?';
690 return c;
691 }
692 else
693 d->optarg = argv[d->optind];
694
695 d->__nextchar = d->optarg;
696 d->optarg = NULL;
697 return process_long_option (argc, argv, optstring, longopts, longind,
698 0 /* long_only */, d, print_errors, "-W ");
699 }
700 if (temp[1] == ':')
701 {
702 if (temp[2] == ':')
703 {
704 /* This is an option that accepts an argument optionally. */
705 if (*d->__nextchar != '\0')
706 {
707 d->optarg = d->__nextchar;
708 d->optind++;
709 }
710 else
711 d->optarg = NULL;
712 d->__nextchar = NULL;
713 }
714 else
715 {
716 /* This is an option that requires an argument. */
717 if (*d->__nextchar != '\0')
718 {
719 d->optarg = d->__nextchar;
720 /* If we end this ARGV-element by taking the rest as an arg,
721 we must advance to the next element now. */
722 d->optind++;
723 }
724 else if (d->optind == argc)
725 {
726 if (print_errors)
727 fprintf (stderr,
728 _("%s: option requires an argument -- '%c'\n"),
729 argv[0], c);
730
731 d->optopt = c;
732 if (optstring[0] == ':')
733 c = ':';
734 else
735 c = '?';
736 }
737 else
738 /* We already incremented 'optind' once;
739 increment it again when taking next ARGV-elt as argument. */
740 d->optarg = argv[d->optind++];
741 d->__nextchar = NULL;
742 }
743 }
744 return c;
745 }
746 }
747
748 int
749 _getopt_internal (int argc, char **argv, const char *optstring,
750 const struct option *longopts, int *longind, int long_only,
751 int posixly_correct)
752 {
753 int result;
754
755 getopt_data.optind = optind;
756 getopt_data.opterr = opterr;
757
758 result = _getopt_internal_r (argc, argv, optstring, longopts,
759 longind, long_only, &getopt_data,
760 posixly_correct);
761
762 optind = getopt_data.optind;
763 optarg = getopt_data.optarg;
764 optopt = getopt_data.optopt;
765
766 return result;
767 }
768
769 int
770 getopt_long(int argc, char *__getopt_argv_const *argv, const char *options,
771 const struct option *long_options, int *opt_index)
772 {
773 return _getopt_internal(argc, (char **)argv, options, long_options,
774 opt_index, 0, 0);
775 }
776
777 #endif