+ if (keys != NULL) {
+ free_publickey(keys);
+ keys = NULL;
+ } else {
+ rc = 1;
+ logthing(LOGTHING_NOTICE, "No changes.");
+ }
+ } else if ((argc - optind) == 2) {
+ search = argv[optind+1];
+ if (search != NULL) {
+ keyid = strtoul(search, &end, 16);
+ if (*search != 0 &&
+ end != NULL &&
+ *end == 0) {
+ ishex = true;
+ }
+ }
+ initdb();
+ if (!strcmp("index", argv[optind])) {
+ find_keys(search, keyid, ishex, fingerprint,
+ false, false);
+ } else if (!strcmp("vindex", argv[optind])) {
+ find_keys(search, keyid, ishex, fingerprint,
+ false, true);
+ } else if (!strcmp("delete", argv[optind])) {
+ delete_key(getfullkeyid(keyid), false);
+ } else if (!strcmp("get", argv[optind])) {
+ if (fetch_key(keyid, &keys, false)) {
+ logthing(LOGTHING_INFO, "Got key.");
+ flatten_publickey(keys,
+ &packets,
+ &list_end);
+ free_publickey(keys);
+ armor_openpgp_stream(stdout_putchar,
+ NULL,
+ packets);
+ free_packet_list(packets);
+ packets = NULL;
+ } else {
+ puts("Key not found");
+ }
+ }
+ cleanupdb();