abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change
on this file since aba6e07 was
06d7b3a,
checked in by Mike Ryan <mikeryan@…>, 14 years ago
|
forgot to add these d'oh
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | #include <getopt.h> |
---|
2 | #include <stdlib.h> |
---|
3 | #include <string.h> |
---|
4 | |
---|
5 | #include "options.h" |
---|
6 | |
---|
7 | static void _usage(char *name) { |
---|
8 | printf( |
---|
9 | "Usage: %s \\\n" |
---|
10 | " --keystore <keystore> \\\n" |
---|
11 | " --role <keyid.role> --principal <keyid>\n" |
---|
12 | " loads the keystore and runs the query role <-?- principal\n", |
---|
13 | name |
---|
14 | ); |
---|
15 | exit(1); |
---|
16 | } |
---|
17 | |
---|
18 | void get_options(int argc, char **argv, options_t *opts) { |
---|
19 | #define OPT_KEYSTORE 1 |
---|
20 | #define OPT_ROLE 2 |
---|
21 | #define OPT_PRINCIPAL 3 |
---|
22 | struct option options[] = { |
---|
23 | { "keystore", 1, 0, OPT_KEYSTORE }, |
---|
24 | { "role", 1, 0, OPT_ROLE }, |
---|
25 | { "principal", 1, 0, OPT_PRINCIPAL }, |
---|
26 | { 0 }, |
---|
27 | }; |
---|
28 | |
---|
29 | for ( ; ; ) { |
---|
30 | int c = getopt_long(argc, argv, "", options, NULL); |
---|
31 | if (c < 0) |
---|
32 | break; |
---|
33 | |
---|
34 | switch (c) { |
---|
35 | case OPT_KEYSTORE: |
---|
36 | opts->keystore = strdup(optarg); |
---|
37 | break; |
---|
38 | case OPT_ROLE: |
---|
39 | opts->role = strdup(optarg); |
---|
40 | break; |
---|
41 | case OPT_PRINCIPAL: |
---|
42 | opts->principal = strdup(optarg); |
---|
43 | break; |
---|
44 | |
---|
45 | default: |
---|
46 | _usage(argv[0]); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | if (!(opts->keystore && opts->role && opts->principal)) |
---|
51 | _usage(argv[0]); |
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.