/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#include <stdlib.h>
#include <stdio.h>

int main (int argc, char **argv) {
        int c;
        extern char *optarg;
        extern int optind;
        int aflg = 0;
        int bflg = 0;
        int errflg = 0;
        char *ofile = NULL;

        while ((c = getopt(argc, argv, "abo:")) != EOF)
           switch (c) {
           case 'a':
              if (bflg)
                 errflg++;
              else
                 aflg++;
              break;
           case 'b':
              if (aflg)
                 errflg++;
              else
                 bflg++;
              break;
           case 'o':
              ofile = optarg;
              printf("ofile = %s\n", ofile);
              break;
           case '?':
              errflg++;
           }
        if (errflg) {
           fprintf(stderr,
              "usage: getopt.c [-a|-b] [-o <filename>] files...\n");
           exit (2);
        }
        while(optind < argc)
           printf("%s\n", argv[optind++]);   
         return 0;
}
