2000-07-03 06:51:12 +04:00
|
|
|
/* $NetBSD: getopt.c,v 1.6 2000/07/03 02:51:18 matt Exp $ */
|
1997-01-09 23:18:21 +03:00
|
|
|
|
1997-10-19 06:13:39 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-08-02 21:48:44 +04:00
|
|
|
#ifndef lint
|
2000-07-03 06:51:12 +04:00
|
|
|
__RCSID("$NetBSD: getopt.c,v 1.6 2000/07/03 02:51:18 matt Exp $");
|
1993-08-02 21:48:44 +04:00
|
|
|
#endif /* not lint */
|
|
|
|
|
1997-10-19 06:13:39 +04:00
|
|
|
#include <errno.h>
|
1993-06-21 16:43:56 +04:00
|
|
|
#include <stdio.h>
|
2000-07-03 06:51:12 +04:00
|
|
|
#include <stdlib.h>
|
1998-02-03 06:44:22 +03:00
|
|
|
#include <unistd.h>
|
1993-06-21 16:43:56 +04:00
|
|
|
|
1997-10-19 06:13:39 +04:00
|
|
|
int main __P((int, char **));
|
|
|
|
|
|
|
|
int
|
1993-06-21 16:43:56 +04:00
|
|
|
main(argc, argv)
|
1997-10-19 06:13:39 +04:00
|
|
|
int argc;
|
|
|
|
char *argv[];
|
1993-06-21 16:43:56 +04:00
|
|
|
{
|
|
|
|
int c;
|
|
|
|
int status = 0;
|
|
|
|
|
|
|
|
optind = 2; /* Past the program name and the option letters. */
|
1997-10-19 06:13:39 +04:00
|
|
|
while ((c = getopt(argc, argv, argv[1])) != -1)
|
1993-06-21 16:43:56 +04:00
|
|
|
switch (c) {
|
|
|
|
case '?':
|
|
|
|
status = 1; /* getopt routine gave message */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (optarg != NULL)
|
|
|
|
printf(" -%c %s", c, optarg);
|
|
|
|
else
|
|
|
|
printf(" -%c", c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf(" --");
|
|
|
|
for (; optind < argc; optind++)
|
|
|
|
printf(" %s", argv[optind]);
|
|
|
|
printf("\n");
|
|
|
|
exit(status);
|
|
|
|
}
|