diff options
Diffstat (limited to 'src/testing/list-keys.c')
-rw-r--r-- | src/testing/list-keys.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/testing/list-keys.c b/src/testing/list-keys.c index 9210486d3..39a48d071 100644 --- a/src/testing/list-keys.c +++ b/src/testing/list-keys.c | |||
@@ -15,7 +15,9 @@ static int result; | |||
15 | * @param cfg the configuration file handle | 15 | * @param cfg the configuration file handle |
16 | */ | 16 | */ |
17 | static void | 17 | static void |
18 | run (void *cls, char *const *args, const char *cfgfile, | 18 | run (void *cls, |
19 | char *const *args, | ||
20 | const char *cfgfile, | ||
19 | const struct GNUNET_CONFIGURATION_Handle *config) | 21 | const struct GNUNET_CONFIGURATION_Handle *config) |
20 | { | 22 | { |
21 | char *idfile; | 23 | char *idfile; |
@@ -30,7 +32,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
30 | 32 | ||
31 | if ((NULL == args) || (NULL == args[0])) | 33 | if ((NULL == args) || (NULL == args[0])) |
32 | { | 34 | { |
33 | FPRINTF (stderr, "Need the hostkey file\n"); | 35 | fprintf (stderr, "Need the hostkey file\n"); |
34 | return; | 36 | return; |
35 | } | 37 | } |
36 | idfile = args[0]; | 38 | idfile = args[0]; |
@@ -42,11 +44,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
42 | } | 44 | } |
43 | if (0 != (fsize % GNUNET_TESTING_HOSTKEYFILESIZE)) | 45 | if (0 != (fsize % GNUNET_TESTING_HOSTKEYFILESIZE)) |
44 | { | 46 | { |
45 | FPRINTF (stderr, | 47 | fprintf (stderr, _ ("Incorrect hostkey file format: %s\n"), idfile); |
46 | _("Incorrect hostkey file format: %s\n"), idfile); | ||
47 | return; | 48 | return; |
48 | } | 49 | } |
49 | f = GNUNET_DISK_file_open (idfile, GNUNET_DISK_OPEN_READ, | 50 | f = GNUNET_DISK_file_open (idfile, |
51 | GNUNET_DISK_OPEN_READ, | ||
50 | GNUNET_DISK_PERM_NONE); | 52 | GNUNET_DISK_PERM_NONE); |
51 | if (NULL == f) | 53 | if (NULL == f) |
52 | { | 54 | { |
@@ -65,14 +67,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
65 | { | 67 | { |
66 | if (nskip + cnt >= nmax) | 68 | if (nskip + cnt >= nmax) |
67 | { | 69 | { |
68 | PRINTF ("Max keys %u reached\n", nmax); | 70 | printf ("Max keys %u reached\n", nmax); |
69 | break; | 71 | break; |
70 | } | 72 | } |
71 | GNUNET_memcpy (&pkey, | 73 | GNUNET_memcpy (&pkey, |
72 | data + (cnt * GNUNET_TESTING_HOSTKEYFILESIZE), | 74 | data + (cnt * GNUNET_TESTING_HOSTKEYFILESIZE), |
73 | GNUNET_TESTING_HOSTKEYFILESIZE); | 75 | GNUNET_TESTING_HOSTKEYFILESIZE); |
74 | GNUNET_CRYPTO_eddsa_key_get_public (&pkey, &id.public_key); | 76 | GNUNET_CRYPTO_eddsa_key_get_public (&pkey, &id.public_key); |
75 | PRINTF ("Key %u: %s\n", cnt, GNUNET_i2s_full (&id)); | 77 | printf ("Key %u: %s\n", cnt, GNUNET_i2s_full (&id)); |
76 | } | 78 | } |
77 | result = GNUNET_OK; | 79 | result = GNUNET_OK; |
78 | GNUNET_DISK_file_unmap (map); | 80 | GNUNET_DISK_file_unmap (map); |
@@ -80,23 +82,28 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
80 | } | 82 | } |
81 | 83 | ||
82 | 84 | ||
83 | int main (int argc, char *argv[]) | 85 | int |
86 | main (int argc, char *argv[]) | ||
84 | { | 87 | { |
85 | struct GNUNET_GETOPT_CommandLineOption option[] = { | 88 | struct GNUNET_GETOPT_CommandLineOption option[] = |
86 | GNUNET_GETOPT_option_uint ('n', | 89 | {GNUNET_GETOPT_option_uint ('n', |
87 | "num-keys", | 90 | "num-keys", |
88 | "COUNT", | 91 | "COUNT", |
89 | gettext_noop ("list COUNT number of keys"), | 92 | gettext_noop ("list COUNT number of keys"), |
90 | &nkeys), | 93 | &nkeys), |
91 | GNUNET_GETOPT_OPTION_END | 94 | GNUNET_GETOPT_OPTION_END}; |
92 | }; | ||
93 | int ret; | 95 | int ret; |
94 | 96 | ||
95 | result = GNUNET_SYSERR; | 97 | result = GNUNET_SYSERR; |
96 | nkeys = 10; | 98 | nkeys = 10; |
97 | ret = | 99 | ret = |
98 | GNUNET_PROGRAM_run (argc, argv, "list-keys", "Lists the peer IDs corresponding to the given keys file\n", | 100 | GNUNET_PROGRAM_run (argc, |
99 | option, &run, NULL); | 101 | argv, |
102 | "list-keys", | ||
103 | "Lists the peer IDs corresponding to the given keys file\n", | ||
104 | option, | ||
105 | &run, | ||
106 | NULL); | ||
100 | if (GNUNET_OK != ret) | 107 | if (GNUNET_OK != ret) |
101 | return 1; | 108 | return 1; |
102 | if (GNUNET_SYSERR == result) | 109 | if (GNUNET_SYSERR == result) |