]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - onak.c
cscvs to tla changeset 42
[onak.git] / onak.c
diff --git a/onak.c b/onak.c
index 8eccc9ce4472a75a07db4e4fe7f8f152234e7b1b..5c07a5b45e29a9182ad62ed9fe54330443912195 100644 (file)
--- a/onak.c
+++ b/onak.c
@@ -92,15 +92,19 @@ int main(int argc, char *argv[])
        uint64_t                         keyid = 0;
        bool                             ishex = false;
        bool                             verbose = false;
+       bool                             update = false;
        bool                             binary = false;
        int                              optchar;
 
 
-       while ((optchar = getopt(argc, argv, "bv")) != -1 ) {
+       while ((optchar = getopt(argc, argv, "buv")) != -1 ) {
                switch (optchar) {
                case 'b': 
                        binary = true;
                        break;
+               case 'u': 
+                       update = true;
+                       break;
                case 'v': 
                        verbose = true;
                        break;
@@ -128,6 +132,16 @@ int main(int argc, char *argv[])
                        initdb();
                        fprintf(stderr, "Got %d new keys.\n",
                                        update_keys(&keys, verbose));
+                       if (keys != NULL && update) {
+                               flatten_publickey(keys,
+                                       &packets,
+                                       &list_end);
+                               armor_openpgp_stream(stdout_putchar,
+                                       NULL,
+                                       packets);
+                               free_packet_list(packets);
+                               packets = NULL;
+                       }
                        cleanupdb();
                } else {
                        rc = 1;
@@ -169,6 +183,8 @@ int main(int argc, char *argv[])
                                armor_openpgp_stream(stdout_putchar,
                                                NULL,
                                                packets);
+                               free_packet_list(packets);
+                               packets = NULL;
                        } else {
                                puts("Key not found");
                        }
@@ -178,5 +194,7 @@ int main(int argc, char *argv[])
                usage();
        }
 
+       cleanupconfig();
+
        return rc;
 }