Panda3D

gnu_getopt.c

00001 /* Getopt for GNU.
00002    NOTE: getopt is now part of the C library, so if you don't know what
00003    "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
00004    before changing it!
00005 
00006    Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94
00007         Free Software Foundation, Inc.
00008 
00009    This program is free software; you can redistribute it and/or modify it
00010    under the terms of the GNU General Public License as published by the
00011    Free Software Foundation; either version 2, or (at your option) any
00012    later version.
00013 
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.  */
00018 
00019 
00020 #include "dtoolbase.h"
00021 
00022 #if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_LONG_ONLY)
00023 
00024 #ifdef WIN32_VC
00025 /* This file seems particularly egregious with this particular warning,
00026    but it's not clear why.  Disable. */
00027 /* C4028: formal parameter N different from declaration */
00028 #pragma warning (disable : 4028)
00029 #endif
00030 
00031 /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
00032    Ditto for AIX 3.2 and <stdlib.h>.  */
00033 #ifndef _NO_PROTO
00034 #define _NO_PROTO
00035 #endif
00036 
00037 #ifndef __STDC__
00038 /* This is a separate conditional since some stdc systems
00039    reject `defined (const)'.  */
00040 #ifndef const
00041 #define const
00042 #endif
00043 #endif
00044 
00045 #include <stdio.h>
00046 #include <string.h>
00047 
00048 /* Comment out all this code if we are using the GNU C Library, and are not
00049    actually compiling the library itself.  This code is part of the GNU C
00050    Library, but also included in many other GNU distributions.  Compiling
00051    and linking in this code is a waste when using the GNU C library
00052    (especially if it is a shared library).  Rather than having every GNU
00053    program understand `configure --with-gnu-libc' and omit the object files,
00054    it is simpler to just do this in the source for each such file.  */
00055 
00056 /* Actually, we may need to compile this anyway, even on a gnu platform. */
00057 #if 1 /* defined (_LIBC) || !defined (__GNU_LIBRARY__) */
00058 
00059 
00060 /* This needs to come after some library #include
00061    to get __GNU_LIBRARY__ defined.  */
00062 #ifdef  __GNU_LIBRARY__
00063 /* Don't include stdlib.h for non-GNU C libraries because some of them
00064    contain conflicting prototypes for getopt.  */
00065 #include <stdlib.h>
00066 #endif  /* GNU C library.  */
00067 
00068 /* This version of `getopt' appears to the caller like standard Unix `getopt'
00069    but it behaves differently for the user, since it allows the user
00070    to intersperse the options with the other arguments.
00071 
00072    As `getopt' works, it permutes the elements of ARGV so that,
00073    when it is done, all the options precede everything else.  Thus
00074    all application programs are extended to handle flexible argument order.
00075 
00076    Setting the environment variable POSIXLY_CORRECT disables permutation.
00077    Then the behavior is completely standard.
00078 
00079    GNU application programs can use a third alternative mode in which
00080    they can distinguish the relative order of options and other arguments.  */
00081 
00082 #include "gnu_getopt.h"
00083 
00084 /* For communication from `getopt' to the caller.
00085    When `getopt' finds an option that takes an argument,
00086    the argument value is returned here.
00087    Also, when `ordering' is RETURN_IN_ORDER,
00088    each non-option ARGV-element is returned here.  */
00089 
00090 char *optarg = NULL;
00091 
00092 /* Index in ARGV of the next element to be scanned.
00093    This is used for communication to and from the caller
00094    and for communication between successive calls to `getopt'.
00095 
00096    On entry to `getopt', zero means this is the first call; initialize.
00097 
00098    When `getopt' returns EOF, this is the index of the first of the
00099    non-option elements that the caller should itself scan.
00100 
00101    Otherwise, `optind' communicates from one call to the next
00102    how much of ARGV has been scanned so far.  */
00103 
00104 /* XXX 1003.2 says this must be 1 before any call.  */
00105 int optind = 0;
00106 
00107 /* The next char to be scanned in the option-element
00108    in which the last option character we returned was found.
00109    This allows us to pick up the scan where we left off.
00110 
00111    If this is zero, or a null string, it means resume the scan
00112    by advancing to the next ARGV-element.  */
00113 
00114 static char *nextchar;
00115 
00116 /* Callers store zero here to inhibit the error message
00117    for unrecognized options.  */
00118 
00119 int opterr = 1;
00120 
00121 /* Set to an option character which was unrecognized.
00122    This must be initialized on some systems to avoid linking in the
00123    system's own getopt implementation.  */
00124 
00125 int optopt = '?';
00126 
00127 /* Describe how to deal with options that follow non-option ARGV-elements.
00128 
00129    If the caller did not specify anything,
00130    the default is REQUIRE_ORDER if the environment variable
00131    POSIXLY_CORRECT is defined, PERMUTE otherwise.
00132 
00133    REQUIRE_ORDER means don't recognize them as options;
00134    stop option processing when the first non-option is seen.
00135    This is what Unix does.
00136    This mode of operation is selected by either setting the environment
00137    variable POSIXLY_CORRECT, or using `+' as the first character
00138    of the list of option characters.
00139 
00140    PERMUTE is the default.  We permute the contents of ARGV as we scan,
00141    so that eventually all the non-options are at the end.  This allows options
00142    to be given in any order, even with programs that were not written to
00143    expect this.
00144 
00145    RETURN_IN_ORDER is an option available to programs that were written
00146    to expect options and other ARGV-elements in any order and that care about
00147    the ordering of the two.  We describe each non-option ARGV-element
00148    as if it were the argument of an option with character code 1.
00149    Using `-' as the first character of the list of option characters
00150    selects this mode of operation.
00151 
00152    The special argument `--' forces an end of option-scanning regardless
00153    of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
00154    `--' can cause `getopt' to return EOF with `optind' != ARGC.  */
00155 
00156 static enum
00157 {
00158   REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
00159 } ordering;
00160 
00161 /* Value of POSIXLY_CORRECT environment variable.  */
00162 static char *posixly_correct;
00163 
00164 #ifdef  __GNU_LIBRARY__
00165 /* We want to avoid inclusion of string.h with non-GNU libraries
00166    because there are many ways it can cause trouble.
00167    On some systems, it contains special magic macros that don't work
00168    in GCC.  */
00169 #include <string.h>
00170 #define my_index        strchr
00171 #else
00172 
00173 /* Avoid depending on library functions or files
00174    whose names are inconsistent.  */
00175 
00176 char *getenv ();
00177 
00178 static char *
00179 my_index (const char *str, int chr) {
00180   while (*str)
00181     {
00182       if (*str == chr)
00183         return (char *) str;
00184       str++;
00185     }
00186   return 0;
00187 }
00188 
00189 /* If using GCC, we can safely declare strlen this way.
00190    If not using GCC, it is ok not to declare it.  */
00191 #ifdef __GNUC__
00192 /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
00193    That was relevant to code that was here before.  */
00194 #ifndef __STDC__
00195 /* gcc with -traditional declares the built-in strlen to return int,
00196    and has done so at least since version 2.4.5. -- rms.  */
00197 extern int strlen (const char *);
00198 #endif /* not __STDC__ */
00199 #endif /* __GNUC__ */
00200 
00201 #endif /* not __GNU_LIBRARY__ */
00202 
00203 /* Handle permutation of arguments.  */
00204 
00205 /* Describe the part of ARGV that contains non-options that have
00206    been skipped.  `first_nonopt' is the index in ARGV of the first of them;
00207    `last_nonopt' is the index after the last of them.  */
00208 
00209 static int first_nonopt;
00210 static int last_nonopt;
00211 
00212 /* Exchange two adjacent subsequences of ARGV.
00213    One subsequence is elements [first_nonopt,last_nonopt)
00214    which contains all the non-options that have been skipped so far.
00215    The other is elements [last_nonopt,optind), which contains all
00216    the options processed since those non-options were skipped.
00217 
00218    `first_nonopt' and `last_nonopt' are relocated so that they describe
00219    the new indices of the non-options in ARGV after they are moved.  */
00220 
00221 static void
00222 exchange (char **argv) {
00223   int bottom = first_nonopt;
00224   int middle = last_nonopt;
00225   int top = optind;
00226   char *tem;
00227 
00228   /* Exchange the shorter segment with the far end of the longer segment.
00229      That puts the shorter segment into the right place.
00230      It leaves the longer segment in the right place overall,
00231      but it consists of two parts that need to be swapped next.  */
00232 
00233   while (top > middle && middle > bottom)
00234     {
00235       if (top - middle > middle - bottom)
00236         {
00237           /* Bottom segment is the short one.  */
00238           int len = middle - bottom;
00239           register int i;
00240 
00241           /* Swap it with the top part of the top segment.  */
00242           for (i = 0; i < len; i++)
00243             {
00244               tem = argv[bottom + i];
00245               argv[bottom + i] = argv[top - (middle - bottom) + i];
00246               argv[top - (middle - bottom) + i] = tem;
00247             }
00248           /* Exclude the moved bottom segment from further swapping.  */
00249           top -= len;
00250         }
00251       else
00252         {
00253           /* Top segment is the short one.  */
00254           int len = top - middle;
00255           register int i;
00256 
00257           /* Swap it with the bottom part of the bottom segment.  */
00258           for (i = 0; i < len; i++)
00259             {
00260               tem = argv[bottom + i];
00261               argv[bottom + i] = argv[middle + i];
00262               argv[middle + i] = tem;
00263             }
00264           /* Exclude the moved top segment from further swapping.  */
00265           bottom += len;
00266         }
00267     }
00268 
00269   /* Update records for the slots the non-options now occupy.  */
00270 
00271   first_nonopt += (optind - last_nonopt);
00272   last_nonopt = optind;
00273 }
00274 
00275 /* Initialize the internal data when the first call is made.  */
00276 
00277 static const char *
00278 _getopt_initialize (const char *optstring) {
00279   /* Start processing options with ARGV-element 1 (since ARGV-element 0
00280      is the program name); the sequence of previously skipped
00281      non-option ARGV-elements is empty.  */
00282 
00283   first_nonopt = last_nonopt = optind = 1;
00284 
00285   nextchar = NULL;
00286 
00287   posixly_correct = getenv ("POSIXLY_CORRECT");
00288 
00289   /* Determine how to handle the ordering of options and nonoptions.  */
00290 
00291   if (optstring[0] == '-')
00292     {
00293       ordering = RETURN_IN_ORDER;
00294       ++optstring;
00295     }
00296   else if (optstring[0] == '+')
00297     {
00298       ordering = REQUIRE_ORDER;
00299       ++optstring;
00300     }
00301   else if (posixly_correct != NULL)
00302     ordering = REQUIRE_ORDER;
00303   else
00304     ordering = PERMUTE;
00305 
00306   return optstring;
00307 }
00308 
00309 /* Scan elements of ARGV (whose length is ARGC) for option characters
00310    given in OPTSTRING.
00311 
00312    If an element of ARGV starts with '-', and is not exactly "-" or "--",
00313    then it is an option element.  The characters of this element
00314    (aside from the initial '-') are option characters.  If `getopt'
00315    is called repeatedly, it returns successively each of the option characters
00316    from each of the option elements.
00317 
00318    If `getopt' finds another option character, it returns that character,
00319    updating `optind' and `nextchar' so that the next call to `getopt' can
00320    resume the scan with the following option character or ARGV-element.
00321 
00322    If there are no more option characters, `getopt' returns `EOF'.
00323    Then `optind' is the index in ARGV of the first ARGV-element
00324    that is not an option.  (The ARGV-elements have been permuted
00325    so that those that are not options now come last.)
00326 
00327    OPTSTRING is a string containing the legitimate option characters.
00328    If an option character is seen that is not listed in OPTSTRING,
00329    return '?' after printing an error message.  If you set `opterr' to
00330    zero, the error message is suppressed but we still return '?'.
00331 
00332    If a char in OPTSTRING is followed by a colon, that means it wants an arg,
00333    so the following text in the same ARGV-element, or the text of the following
00334    ARGV-element, is returned in `optarg'.  Two colons mean an option that
00335    wants an optional arg; if there is text in the current ARGV-element,
00336    it is returned in `optarg', otherwise `optarg' is set to zero.
00337 
00338    If OPTSTRING starts with `-' or `+', it requests different methods of
00339    handling the non-option ARGV-elements.
00340    See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
00341 
00342    Long-named options begin with `--' instead of `-'.
00343    Their names may be abbreviated as long as the abbreviation is unique
00344    or is an exact match for some defined option.  If they have an
00345    argument, it follows the option name in the same ARGV-element, separated
00346    from the option name by a `=', or else the in next ARGV-element.
00347    When `getopt' finds a long-named option, it returns 0 if that option's
00348    `flag' field is nonzero, the value of the option's `val' field
00349    if the `flag' field is zero.
00350 
00351    The elements of ARGV aren't really const, because we permute them.
00352    But we pretend they're const in the prototype to be compatible
00353    with other systems.
00354 
00355    LONGOPTS is a vector of `struct option' terminated by an
00356    element containing a name which is zero.
00357 
00358    LONGIND returns the index in LONGOPT of the long-named option found.
00359    It is only valid when a long-named option has been found by the most
00360    recent call.
00361 
00362    If LONG_ONLY is nonzero, '-' as well as '--' can introduce
00363    long-named options.  */
00364 
00365 int
00366 _getopt_internal (int argc, 
00367                   char *const *argv, 
00368                   const char *optstring, 
00369                   const struct option *longopts, 
00370                   int *longind, 
00371                   int long_only) {
00372   optarg = NULL;
00373 
00374   if (optind == 0)
00375     optstring = _getopt_initialize (optstring);
00376 
00377   if (nextchar == NULL || *nextchar == '\0')
00378     {
00379       /* Advance to the next ARGV-element.  */
00380 
00381       if (ordering == PERMUTE)
00382         {
00383           /* If we have just processed some options following some non-options,
00384              exchange them so that the options come first.  */
00385 
00386           if (first_nonopt != last_nonopt && last_nonopt != optind)
00387             exchange ((char **) argv);
00388           else if (last_nonopt != optind)
00389             first_nonopt = optind;
00390 
00391           /* Skip any additional non-options
00392              and extend the range of non-options previously skipped.  */
00393 
00394           while (optind < argc
00395                  && (argv[optind][0] != '-' || argv[optind][1] == '\0'))
00396             optind++;
00397           last_nonopt = optind;
00398         }
00399 
00400       /* The special ARGV-element `--' means premature end of options.
00401          Skip it like a null option,
00402          then exchange with previous non-options as if it were an option,
00403          then skip everything else like a non-option.  */
00404 
00405       if (optind != argc && !strcmp (argv[optind], "--"))
00406         {
00407           optind++;
00408 
00409           if (first_nonopt != last_nonopt && last_nonopt != optind)
00410             exchange ((char **) argv);
00411           else if (first_nonopt == last_nonopt)
00412             first_nonopt = optind;
00413           last_nonopt = argc;
00414 
00415           optind = argc;
00416         }
00417 
00418       /* If we have done all the ARGV-elements, stop the scan
00419          and back over any non-options that we skipped and permuted.  */
00420 
00421       if (optind == argc)
00422         {
00423           /* Set the next-arg-index to point at the non-options
00424              that we previously skipped, so the caller will digest them.  */
00425           if (first_nonopt != last_nonopt)
00426             optind = first_nonopt;
00427           return EOF;
00428         }
00429 
00430       /* If we have come to a non-option and did not permute it,
00431          either stop the scan or describe it to the caller and pass it by.  */
00432 
00433       if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
00434         {
00435           if (ordering == REQUIRE_ORDER)
00436             return EOF;
00437           optarg = argv[optind++];
00438           return 1;
00439         }
00440 
00441       /* We have found another option-ARGV-element.
00442          Skip the initial punctuation.  */
00443 
00444       nextchar = (argv[optind] + 1
00445                   + (longopts != NULL && argv[optind][1] == '-'));
00446     }
00447 
00448   /* Decode the current option-ARGV-element.  */
00449 
00450   /* Check whether the ARGV-element is a long option.
00451 
00452      If long_only and the ARGV-element has the form "-f", where f is
00453      a valid short option, don't consider it an abbreviated form of
00454      a long option that starts with f.  Otherwise there would be no
00455      way to give the -f short option.
00456 
00457      On the other hand, if there's a long option "fubar" and
00458      the ARGV-element is "-fu", do consider that an abbreviation of
00459      the long option, just like "--fu", and not "-f" with arg "u".
00460 
00461      This distinction seems to be the most useful approach.  */
00462 
00463   if (longopts != NULL
00464       && (argv[optind][1] == '-'
00465           || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
00466     {
00467       char *nameend;
00468       const struct option *p;
00469       const struct option *pfound = NULL;
00470       int exact = 0;
00471       int ambig = 0;
00472       int indfound = 0;
00473       int option_index;
00474 
00475       for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
00476         /* Do nothing.  */ ;
00477 
00478       /* Test all long options for either exact match
00479          or abbreviated matches.  */
00480       for (p = longopts, option_index = 0; p->name; p++, option_index++)
00481         if (!strncmp (p->name, nextchar, nameend - nextchar))
00482           {
00483             if (nameend - nextchar == (int) strlen (p->name))
00484               {
00485                 /* Exact match found.  */
00486                 pfound = p;
00487                 indfound = option_index;
00488                 exact = 1;
00489                 break;
00490               }
00491             else if (pfound == NULL)
00492               {
00493                 /* First nonexact match found.  */
00494                 pfound = p;
00495                 indfound = option_index;
00496               }
00497             else
00498               /* Second or later nonexact match found.  */
00499               ambig = 1;
00500           }
00501 
00502       if (ambig && !exact)
00503         {
00504           if (opterr)
00505             fprintf (stderr, "%s: option `%s' is ambiguous\n",
00506                      argv[0], argv[optind]);
00507           nextchar += strlen (nextchar);
00508           optind++;
00509           return '?';
00510         }
00511 
00512       if (pfound != NULL)
00513         {
00514           option_index = indfound;
00515           optind++;
00516           if (*nameend)
00517             {
00518               /* Don't test has_arg with >, because some C compilers don't
00519                  allow it to be used on enums.  */
00520               if (pfound->has_arg)
00521                 optarg = nameend + 1;
00522               else
00523                 {
00524                   if (opterr)
00525                     {
00526                       if (argv[optind - 1][1] == '-')
00527                         /* --option */
00528                         fprintf (stderr,
00529                                  "%s: option `--%s' doesn't allow an argument\n",
00530                                  argv[0], pfound->name);
00531                       else
00532                         /* +option or -option */
00533                         fprintf (stderr,
00534                              "%s: option `%c%s' doesn't allow an argument\n",
00535                              argv[0], argv[optind - 1][0], pfound->name);
00536                     }
00537                   nextchar += strlen (nextchar);
00538                   return '?';
00539                 }
00540             }
00541           else if (pfound->has_arg == 1)
00542             {
00543               if (optind < argc)
00544                 optarg = argv[optind++];
00545               else
00546                 {
00547                   if (opterr)
00548                     fprintf (stderr, "%s: option `%s' requires an argument\n",
00549                              argv[0], argv[optind - 1]);
00550                   nextchar += strlen (nextchar);
00551                   return optstring[0] == ':' ? ':' : '?';
00552                 }
00553             }
00554           nextchar += strlen (nextchar);
00555           if (longind != NULL)
00556             *longind = option_index;
00557           if (pfound->flag)
00558             {
00559               *(pfound->flag) = pfound->val;
00560               return 0;
00561             }
00562           return pfound->val;
00563         }
00564 
00565       /* Can't find it as a long option.  If this is not getopt_long_only,
00566          or the option starts with '--' or is not a valid short
00567          option, then it's an error.
00568          Otherwise interpret it as a short option.  */
00569       if (!long_only || argv[optind][1] == '-'
00570           || my_index (optstring, *nextchar) == NULL)
00571         {
00572           if (opterr)
00573             {
00574               if (argv[optind][1] == '-')
00575                 /* --option */
00576                 fprintf (stderr, "%s: unrecognized option `--%s'\n",
00577                          argv[0], nextchar);
00578               else
00579                 /* +option or -option */
00580                 fprintf (stderr, "%s: unrecognized option `%c%s'\n",
00581                          argv[0], argv[optind][0], nextchar);
00582             }
00583           nextchar = (char *) "";
00584           optind++;
00585           return '?';
00586         }
00587     }
00588 
00589   /* Look at and handle the next short option-character.  */
00590 
00591   {
00592     char c = *nextchar++;
00593     char *temp = my_index (optstring, c);
00594 
00595     /* Increment `optind' when we start to process its last character.  */
00596     if (*nextchar == '\0')
00597       ++optind;
00598 
00599     if (temp == NULL || c == ':')
00600       {
00601         if (opterr)
00602           {
00603             if (posixly_correct)
00604               /* 1003.2 specifies the format of this message.  */
00605               fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
00606             else
00607               fprintf (stderr, "%s: invalid option -- %c\n", argv[0], c);
00608           }
00609         optopt = c;
00610         return '?';
00611       }
00612     if (temp[1] == ':')
00613       {
00614         if (temp[2] == ':')
00615           {
00616             /* This is an option that accepts an argument optionally.  */
00617             if (*nextchar != '\0')
00618               {
00619                 optarg = nextchar;
00620                 optind++;
00621               }
00622             else
00623               optarg = NULL;
00624             nextchar = NULL;
00625           }
00626         else
00627           {
00628             /* This is an option that requires an argument.  */
00629             if (*nextchar != '\0')
00630               {
00631                 optarg = nextchar;
00632                 /* If we end this ARGV-element by taking the rest as an arg,
00633                    we must advance to the next element now.  */
00634                 optind++;
00635               }
00636             else if (optind == argc)
00637               {
00638                 if (opterr)
00639                   {
00640                     /* 1003.2 specifies the format of this message.  */
00641                     fprintf (stderr, "%s: option requires an argument -- %c\n",
00642                              argv[0], c);
00643                   }
00644                 optopt = c;
00645                 if (optstring[0] == ':')
00646                   c = ':';
00647                 else
00648                   c = '?';
00649               }
00650             else
00651               /* We already incremented `optind' once;
00652                  increment it again when taking next ARGV-elt as argument.  */
00653               optarg = argv[optind++];
00654             nextchar = NULL;
00655           }
00656       }
00657     return c;
00658   }
00659 }
00660 
00661 int
00662 getopt (int argc, char *const *argv, const char *optstring) {
00663   return _getopt_internal (argc, argv, optstring,
00664                            (const struct option *) 0,
00665                            (int *) 0,
00666                            0);
00667 }
00668 
00669 #endif  /* _LIBC or not __GNU_LIBRARY__.  */
00670 
00671 #ifdef TEST
00672 
00673 /* Compile with -DTEST to make an executable for use in testing
00674    the above definition of `getopt'.  */
00675 
00676 int
00677 main (int argc, char **argv) {
00678   int c;
00679   int digit_optind = 0;
00680 
00681   while (1)
00682     {
00683       int this_option_optind = optind ? optind : 1;
00684 
00685       c = getopt (argc, argv, "abc:d:0123456789");
00686       if (c == EOF)
00687         break;
00688 
00689       switch (c)
00690         {
00691         case '0':
00692         case '1':
00693         case '2':
00694         case '3':
00695         case '4':
00696         case '5':
00697         case '6':
00698         case '7':
00699         case '8':
00700         case '9':
00701           if (digit_optind != 0 && digit_optind != this_option_optind)
00702             printf ("digits occur in two different argv-elements.\n");
00703           digit_optind = this_option_optind;
00704           printf ("option %c\n", c);
00705           break;
00706 
00707         case 'a':
00708           printf ("option a\n");
00709           break;
00710 
00711         case 'b':
00712           printf ("option b\n");
00713           break;
00714 
00715         case 'c':
00716           printf ("option c with value `%s'\n", optarg);
00717           break;
00718 
00719         case '?':
00720           break;
00721 
00722         default:
00723           printf ("?? getopt returned character code 0%o ??\n", c);
00724         }
00725     }
00726 
00727   if (optind < argc)
00728     {
00729       printf ("non-option ARGV-elements: ");
00730       while (optind < argc)
00731         printf ("%s ", argv[optind++]);
00732       printf ("\n");
00733     }
00734 
00735   exit (0);
00736 }
00737 
00738 #endif /* TEST */
00739 
00740 #endif /* HAVE_GETOPT */
 All Classes Functions Variables Enumerations