|
diff --git a/main.c b/main.c
|
| ... |
| 3 |
#include <stdarg.h> |
3 |
#include <stdarg.h> |
| 4 |
#include <getopt.h> |
4 |
#include <getopt.h> |
| 5 |
|
5 |
|
|
|
6 |
#include "version.h" |
|
|
7 |
|
| 6 |
void help(const char *argv0) { |
8 |
void help(const char *argv0) { |
| 7 |
printf("Usage: %s [options]\n" |
9 |
printf("Usage: %s [options]\n" |
| 8 |
"\nAvailable options:\n" |
10 |
"\nAvailable options:\n" |
| 9 |
" -h,--help this help\n" |
11 |
" -h,--help this help\n" |
| 10 |
" -v,--version show version\n" |
12 |
" -v,--version show version\n" |
|
|
13 |
" -l,--list list available devices\n" |
| 11 |
" -p,--port=client:port device port\n", |
14 |
" -p,--port=client:port device port\n", |
| 12 |
argv0); |
15 |
argv0); |
| 13 |
} |
16 |
} |
| ... |
| 15 |
int main(int argc, char *argv[]) { |
18 |
int main(int argc, char *argv[]) { |
| 16 |
const char short_options[] = "hvlp"; |
19 |
const char short_options[] = "hvlp"; |
| 17 |
const struct option long_options[] = { |
20 |
const struct option long_options[] = { |
| 18 |
{"help", 0, NULL, 'h'}, |
21 |
{ "help", 0, NULL, 'h' }, |
| 19 |
{"version", 0, NULL, 'v'}, |
22 |
{ "version", 0, NULL, 'v' }, |
| 20 |
{"list", 0, NULL, 'l'}, |
23 |
{ "list", 0, NULL, 'l' }, |
| 21 |
{"port", 1, NULL, 'p'}, |
24 |
{ "port", 1, NULL, 'p' }, |
| 22 |
{0}, |
25 |
{ 0 }, |
| 23 |
}; |
26 |
}; |
| 24 |
|
27 |
|
| 25 |
int c; |
28 |
int c; |
| ... |
| 29 |
help(argv[0]); |
32 |
help(argv[0]); |
| 30 |
return 0; |
33 |
return 0; |
| 31 |
case 'v': |
34 |
case 'v': |
| 32 |
fprintf(stdout, "Version\n"); |
35 |
fprintf(stdout, "ttdaw version %s\n", TTDAW_VERSION); |
|
|
36 |
fprintf(stdout, "Website: %s.\n", TTDAW_WEBSITE); |
|
|
37 |
fprintf(stdout, "%s\n", TTDAW_LICENSE); |
|
|
38 |
fprintf(stdout, "%s\n", TTDAW_WARRANTY); |
|
|
39 |
fprintf(stdout, "\n%s\n", TTDAW_AUTHOR); |
| 33 |
return 0; |
40 |
return 0; |
| 34 |
case 'l': |
41 |
case 'l': |
| 35 |
fprintf(stdout, "List\n"); |
42 |
fprintf(stderr, "List feature is NOT implemented yet.\n"); |
| 36 |
return 0; |
43 |
return 0; |
| 37 |
case 'p': |
44 |
case 'p': |
| 38 |
fprintf(stdout, "Port\n"); |
45 |
fprintf(stderr, "Port feature is NOT implemented yet.\n"); |
| 39 |
return 0; |
46 |
return 0; |
| 40 |
default: |
47 |
default: |
| 41 |
fprintf(stdout, "No option provided\n"); |
48 |
fprintf(stdout, "No option provided\n"); |
| ... |