2 #include "ucw/getopt.h"
7 // Should work on GNU libc
15 parse(int argc, char **argv)
17 static struct option longopts[] = {
18 { "longa", 0, 0, 'a' },
19 { "longb", 0, 0, 'b' },
20 { "longc", 1, 0, 'c' },
21 { "longd", 1, 0, 'd' },
25 while ((opt = getopt_long(argc, argv, "abc:d:", longopts, NULL)) >= 0)
30 printf("option %c\n", opt);
34 printf("option %c with value `%s'\n", opt, optarg);
37 printf("unknown option\n");
40 printf("getopt returned unexpected char 0x%02x\n", opt);
44 printf("%d nonoption arguments\n", argc - optind);
48 main(int argc, char **argv)