diff options
Diffstat (limited to 'apps/codecs/dumb/make/dumbask.c')
-rw-r--r-- | apps/codecs/dumb/make/dumbask.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/apps/codecs/dumb/make/dumbask.c b/apps/codecs/dumb/make/dumbask.c new file mode 100644 index 0000000000..da89fab97b --- /dev/null +++ b/apps/codecs/dumb/make/dumbask.c | |||
@@ -0,0 +1,30 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <ctype.h> | ||
3 | |||
4 | |||
5 | int main(int argc, const char *const argv[]) | ||
6 | { | ||
7 | const char *message = argv[1]; | ||
8 | const char *options; | ||
9 | |||
10 | if (!message) { | ||
11 | fprintf(stderr, | ||
12 | "dumbask: asks the user a question.\n" | ||
13 | "Specify a message as the first argument (quoted!).\n" | ||
14 | "You may optionally specify the choices as the second argument.\n" | ||
15 | "Default choices are YN. Exit code is 0 for first, 1 for second, etc.\n"); | ||
16 | return 0; | ||
17 | } | ||
18 | |||
19 | options = argv[2] ? : "YN"; /* I _had_ to use a GNU Extension _somewhere_! */ | ||
20 | |||
21 | printf("%s", argv[1]); | ||
22 | |||
23 | for (;;) { | ||
24 | char c = toupper(getchar()); | ||
25 | int i; | ||
26 | for (i = 0; options[i]; i++) | ||
27 | if (c == toupper(options[i])) | ||
28 | return i; | ||
29 | } | ||
30 | } | ||