Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/tests/getopttest.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 621 byte(s)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 621 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | /* |
2 | * getopttest.c |
3 | * |
4 | * Simple test for getopt, set the environment variable GETOPTTEST |
5 | * to give the argument string to getopt() |
6 | */ |
7 | |
8 | #include <stdlib.h> |
9 | #include <unistd.h> |
10 | #include <stdio.h> |
11 | |
12 | int main(int argc, char *const *argv) |
13 | { |
14 | const char *parser; |
15 | char showchar[] = "\'?\'"; |
16 | int c; |
17 | |
18 | parser = getenv("GETOPTTEST"); |
19 | if (!parser) |
20 | parser = "abzf:o:"; |
21 | |
22 | do { |
23 | c = getopt(argc, argv, parser); |
24 | showchar[1] = c; |
25 | printf |
26 | ("c = %s, optind = %d (%s), optarg = \"%s\", optopt = \'%c\'\n", |
27 | (c == EOF) ? "EOF" : showchar, optind, argv[optind], |
28 | optarg, optopt); |
29 | } while (c != -1); |
30 | |
31 | return 0; |
32 | } |