1e026a48cSDavid E. O'Brien #include <sys/cdefs.h>
259f31bb2SBrooks Davis /*
359f31bb2SBrooks Davis * This material, written by Henry Spencer, was released by him
459f31bb2SBrooks Davis * into the public domain and is thus not subject to any copyright.
559f31bb2SBrooks Davis */
659f31bb2SBrooks Davis
7cd1693d3SConrad Meyer #include <capsicum_helpers.h>
8cd1693d3SConrad Meyer #include <err.h>
9cd1693d3SConrad Meyer #include <errno.h>
10b37b9a6dSNate Williams #include <stdio.h>
11821df508SXin LI #include <stdlib.h>
1262f882d6SWarner Losh #include <unistd.h>
13b37b9a6dSNate Williams
14b2688868SDavid Malone int
main(int argc,char * argv[])15f4ac32deSDavid Malone main(int argc, char *argv[])
16b37b9a6dSNate Williams {
17b37b9a6dSNate Williams int c;
18b37b9a6dSNate Williams int status = 0;
19b37b9a6dSNate Williams
20*7672a014SMariusz Zaborski if (caph_limit_stdio() < 0 || caph_enter() < 0)
21cd1693d3SConrad Meyer err(1, "capsicum");
22cd1693d3SConrad Meyer
23b37b9a6dSNate Williams optind = 2; /* Past the program name and the option letters. */
241c8af878SWarner Losh while ((c = getopt(argc, argv, argv[1])) != -1)
25b37b9a6dSNate Williams switch (c) {
26b37b9a6dSNate Williams case '?':
27b37b9a6dSNate Williams status = 1; /* getopt routine gave message */
28b37b9a6dSNate Williams break;
29b37b9a6dSNate Williams default:
30b37b9a6dSNate Williams if (optarg != NULL)
310ab2a7aeSMartin Cracauer printf(" -%c %s", c, optarg);
32b37b9a6dSNate Williams else
33b37b9a6dSNate Williams printf(" -%c", c);
34b37b9a6dSNate Williams break;
35b37b9a6dSNate Williams }
36b37b9a6dSNate Williams printf(" --");
37b37b9a6dSNate Williams for (; optind < argc; optind++)
38b37b9a6dSNate Williams printf(" %s", argv[optind]);
39b37b9a6dSNate Williams printf("\n");
406c28b67bSMark Murray return status;
41b37b9a6dSNate Williams }
42