refactored attest database tool
authorAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 30 Oct 2011 21:20:20 +0000 (22:20 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 28 Nov 2011 18:48:31 +0000 (19:48 +0100)
src/libimcv/plugins/imv_attestation/attest.c

index d2aa52f..531cd53 100644 (file)
@@ -112,6 +112,12 @@ static void do_args(int argc, char *argv[])
                        case 'H':
                                operation = OP_HASHES;
                                continue;
+                       case 'D':
+                               if (!attest->set_directory(attest, optarg))
+                               {
+                                       exit(EXIT_FAILURE);
+                               }
+                               continue;
                        case 'F':
                                if (!attest->set_file(attest, optarg, op == OP_ADD))
                                {
@@ -176,33 +182,12 @@ static void do_args(int argc, char *argv[])
                        attest->delete(attest);
                        break;
                case OP_HASHES:
-                       if ((!product || *product == '\0') && (!file || *file == '\0'))
-                       {
-                               list_hashes(algo);
-                       }
-                       else if (product)
-                       {
-                               list_hashes_for_product(algo, product, pid);
-                       }
-                       else
-                       {
-                               list_hashes_for_file(algo, file, fid);
-                       }
+                       attest->list_hashes(attest);
                        break;
                default:
                        usage();
                        exit(EXIT_FAILURE);
        }
-
-       if (fid)
-       {
-               free(file);
-       }
-       if (pid)
-       {
-               free(product);
-       }
-
 }
 
 int main(int argc, char *argv[])