+ } else if (!strcmp("clean", argv[optind])) {
+ if (binary) {
+ result = read_openpgp_stream(stdin_getchar, NULL,
+ &packets, 0);
+ logthing(LOGTHING_INFO,
+ "read_openpgp_stream: %d", result);
+ } else {
+ dearmor_openpgp_stream(stdin_getchar, NULL, &packets);
+ }
+
+ if (packets != NULL) {
+ result = parse_keys(packets, &keys);
+ free_packet_list(packets);
+ packets = NULL;
+ logthing(LOGTHING_INFO, "Finished reading %d keys.",
+ result);
+
+ if (keys != NULL) {
+ result = cleankeys(keys);
+ logthing(LOGTHING_INFO, "%d keys cleaned.",
+ result);
+
+ flatten_publickey(keys,
+ &packets,
+ &list_end);
+
+ if (binary) {
+ write_openpgp_stream(stdout_putchar,
+ NULL,
+ packets);
+ } else {
+ armor_openpgp_stream(stdout_putchar,
+ NULL,
+ packets);
+ }
+ free_packet_list(packets);
+ packets = NULL;
+ }
+ } else {
+ rc = 1;
+ logthing(LOGTHING_NOTICE, "No keys read.");
+ }
+
+ if (keys != NULL) {
+ free_publickey(keys);
+ keys = NULL;
+ }