


      GGGGEEEETTTTOOOOPPPPTTTT((((3333CCCC))))                  ((((UUUUNNNNIIIIXXXX 5555....0000))))                 GGGGEEEETTTTOOOOPPPPTTTT((((3333CCCC))))



      NNNNAAAAMMMMEEEE
           getopt - get option letter from argument vector

      SSSSYYYYNNNNTTTTAAAAXXXX
           iiiinnnntttt ggggeeeettttoooopppptttt ((((aaaarrrrggggcccc,,,, aaaarrrrggggvvvv,,,, ooooppppttttssssttttrrrriiiinnnngggg))))
           iiiinnnntttt aaaarrrrggggcccc;;;;
           cccchhhhaaaarrrr ********aaaarrrrggggvvvv;;;;
           cccchhhhaaaarrrr ****ooooppppttttssssttttrrrriiiinnnngggg;;;;

           eeeexxxxtttteeeerrrrnnnn cccchhhhaaaarrrr ****ooooppppttttaaaarrrrgggg;;;;
           eeeexxxxtttteeeerrrrnnnn iiiinnnntttt ooooppppttttiiiinnnndddd;;;;

      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
           _G_e_t_o_p_t returns the next option letter in _a_r_g_v that matches a
           letter in _o_p_t_s_t_r_i_n_g.  _O_p_t_s_t_r_i_n_g is a string of recognized
           option letters; if a letter is followed by a colon, the
           option is expected to have an argument that may or may not
           be separated from it by white space.  _O_p_t_a_r_g is set to point
           to the start of the option argument on return from _g_e_t_o_p_t.

           _G_e_t_o_p_t places in _o_p_t_i_n_d the _a_r_g_v index of the next argument
           to be processed.  Because _o_p_t_i_n_d is external, it is normally
           initialized to zero automatically before the first call to
           _g_e_t_o_p_t.

           When all options have been processed (i.e., up to the first
           non-option argument), _g_e_t_o_p_t returns EEEEOOOOFFFF.  The special
           option -------- may be used to delimit the end of the options; EEEEOOOOFFFF
           will be returned, and -------- will be skipped.

      DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
           _G_e_t_o_p_t prints an error message on _s_t_d_e_r_r and returns a
           question mark (????) when it encounters an option letter not
           included in _o_p_t_s_t_r_i_n_g.

      WWWWAAAARRRRNNNNIIIINNNNGGGG
           The above routine uses <<<<ssssttttddddiiiioooo....hhhh>>>>, which causes it to
           increase the size of programs, not otherwise using standard
           I/O, more than might be expected.

      EEEEXXXXAAAAMMMMPPPPLLLLEEEE
           The following code fragment shows how one might process the
           arguments for a command that can take the mutually exclusive
           options aaaa and bbbb, and the options ffff and oooo, both of which
           require arguments:

                main (argc, argv)
                int argc;
                char **argv;
                {
                     int c;
                     extern int optind;



      Page 1                                                   (9010-E)






      GGGGEEEETTTTOOOOPPPPTTTT((((3333CCCC))))                  ((((UUUUNNNNIIIIXXXX 5555....0000))))                 GGGGEEEETTTTOOOOPPPPTTTT((((3333CCCC))))



                     extern char *optarg;
8                     ....
8                     ....
8                     ....
                     while ((c = getopt (argc, argv, "abf:o:")) != EOF)
                          switch (c) {
                          case 'a':
                               if (bflg)
                                    errflg++;
                               else
                                    aflg++;
                               break;
                          case 'b':
                               if (aflg)
                                    errflg++;
                               else
                                    bproc( );
                               break;
                          case 'f':
                               ifile = optarg;
                               break;
                          case 'o':
                               ofile = optarg;
                               bufsiza = 512;
                               break;
                          case '?':
                               errflg++;
                          }
                     if (errflg) {
                          fprintf (stderr, "usage: . . . ");
                          exit  2);
                     }
                     for ( ; optind < argc; optind++) {
                          if (access (argv[optind], 4)) {
8                     ....
8                     ....
8                     ....
                }

      SSSSEEEEEEEE AAAALLLLSSSSOOOO
           getopt(1).

















      Page 2                                                   (9010-E)



