/*
 * getopt-usage.c
 * 
 * sample program showing the usage of getopt.
 * of course, if you had bothered to do a "man" on getopt, you wouldn't
 * have needed to look this up. :P
 *
 * This compiles with a a hitch on freebsd using
 * gcc -Wall -pedantic -ansi getopt-usage.c -o getopt-usage
 *
 */

#include <unistd.h>
#include <stdio.h>

int main (int argc, char *argv[])
{
	int ch;

	if (argc == 1) {
		printf ("You specified no parameters.\n");
	}

	while ((ch = getopt(argc, argv, "bhf:")) != -1) {
		switch (ch) {
			case 'b':
				printf ("You specified the -b option.\n");
				break;
			case 'f':
				printf ("You specified the -f option ");
				printf ("with the parameter \"%s\".\n", optarg);
				break;
			case 'h':
				printf ("You specified the -h option.\n");
				break;
			default:
				printf ("You specified a parameter I don't "
					"know about.\n");
				break;
		}
	}
	argc -= optind;
	argv += optind;

	return 0;
}


