2 #include "gnunet_util_lib.h"
3 #include "gnunet_testing_lib.h"
5 static unsigned int nkeys;
6 static unsigned int nskip;
13 * @param args arguments passed to GNUNET_PROGRAM_run
14 * @param cfgfile the path to configuration file
15 * @param cfg the configuration file handle
21 const struct GNUNET_CONFIGURATION_Handle *config)
24 struct GNUNET_DISK_FileHandle *f;
26 struct GNUNET_DISK_MapHandle *map;
27 struct GNUNET_CRYPTO_EddsaPrivateKey pkey;
28 struct GNUNET_PeerIdentity id;
33 if ((NULL == args) || (NULL == args[0]))
35 fprintf (stderr, "Need the hostkey file\n");
40 GNUNET_DISK_file_size (idfile, &fsize, GNUNET_YES, GNUNET_YES))
45 if (0 != (fsize % GNUNET_TESTING_HOSTKEYFILESIZE))
47 fprintf (stderr, _ ("Incorrect hostkey file format: %s\n"), idfile);
50 f = GNUNET_DISK_file_open (idfile,
51 GNUNET_DISK_OPEN_READ,
52 GNUNET_DISK_PERM_NONE);
58 data = GNUNET_DISK_file_map (f, &map, GNUNET_DISK_MAP_TYPE_READ, fsize);
62 GNUNET_DISK_file_close (f);
65 nmax = fsize / GNUNET_TESTING_HOSTKEYFILESIZE;
66 for (cnt = nskip; cnt < (nskip + nkeys); cnt++)
68 if (nskip + cnt >= nmax)
70 printf ("Max keys %u reached\n", nmax);
74 data + (cnt * GNUNET_TESTING_HOSTKEYFILESIZE),
75 GNUNET_TESTING_HOSTKEYFILESIZE);
76 GNUNET_CRYPTO_eddsa_key_get_public (&pkey, &id.public_key);
77 printf ("Key %u: %s\n", cnt, GNUNET_i2s_full (&id));
80 GNUNET_DISK_file_unmap (map);
81 GNUNET_DISK_file_close (f);
86 main (int argc, char *argv[])
88 struct GNUNET_GETOPT_CommandLineOption option[] =
89 { GNUNET_GETOPT_option_uint ('n',
92 gettext_noop ("list COUNT number of keys"),
94 GNUNET_GETOPT_OPTION_END };
97 result = GNUNET_SYSERR;
100 GNUNET_PROGRAM_run (argc,
103 "Lists the peer IDs corresponding to the given keys file\n",
107 if (GNUNET_OK != ret)
109 if (GNUNET_SYSERR == result)