2 #include "lib/getopt.h"
7 // Should work on GNU libc
13 parse(int argc, char **argv)
15 static struct option longopts[] = {
16 { "longa", 0, 0, 'a' },
17 { "longb", 0, 0, 'b' },
18 { "longc", 1, 0, 'c' },
19 { "longd", 1, 0, 'd' },
23 while ((opt = getopt_long(argc, argv, "abc:d:", longopts, NULL)) >= 0)
28 printf("option %c\n", opt);
32 printf("option %c with value `%s'\n", opt, optarg);
35 printf("unknown option\n");
38 printf("getopt returned unexpected char 0x%02x\n", opt);
42 printf("%d nonoption arguments\n", argc - optind);
46 main(int argc, char **argv)