[19809] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

[PATCH] Make the test_profile able to take multiple files

daemon@ATHENA.MIT.EDU (David Howells)
Thu Sep 6 13:10:36 2018

From: David Howells <dhowells@redhat.com>
To: krbdev@mit.edu
MIME-Version: 1.0
Content-ID: <6007.1536250466.1@warthog.procyon.org.uk>
Date: Thu, 06 Sep 2018 17:14:26 +0100
Message-ID: <6008.1536250466@warthog.procyon.org.uk>
Cc: dhowells@redhat.com
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: krbdev-bounces@mit.edu

Make the test_profile program able to take multiple files by sticking in
parameters called "{" and "}" around the set, e.g.:

	./src/util/profile/test_profile { foo.conf bar.conf } query cells openstack.org description

The original still works, but a single file named "{" is now unusable, unless
it is sandwiched with "{" and "}".

---
diff --git a/src/util/profile/test_profile.c b/src/util/profile/test_profile.c
index 6f6fcc7..02e9d0e 100644
--- a/src/util/profile/test_profile.c
+++ b/src/util/profile/test_profile.c
@@ -115,25 +115,48 @@ int main(argc, argv)
 {
     profile_t   profile;
     long        retval;
-    char        **values, *value, **cpp;
+    char        **values, *value, **cpp, **p;
     const char  **names;
     char        *cmd;
     int         print_value = 0;
 
     if (argc < 2) {
         fprintf(stderr, "Usage: %s filename [cmd argset]\n", program_name);
+        fprintf(stderr, "       %s { filename* } [cmd argset]\n", program_name);
         exit(1);
     }
 
     initialize_prof_error_table();
 
-    retval = profile_init_path(argv[1], &profile);
-    if (retval) {
-        com_err(program_name, retval, "while initializing profile");
-        exit(1);
+    if (strcmp(argv[1], "{") != 0) {
+        retval = profile_init_path(argv[1], &profile);
+        if (retval) {
+            com_err(program_name, retval, "while initializing profile");
+            exit(1);
+        }
+        cmd = *(argv+2);
+        names = (const char **) argv+3;
+    } else {
+        for (p = argv + 1; *p; p++)
+            if (strcmp(*p, "}") == 0)
+                break;
+        if (!p[0]) {
+            fprintf(stderr, "Missing closure of filename set.\n");
+            exit(1);
+        }
+        if (!p[1]) {
+            fprintf(stderr, "Missing command name.\n");
+            exit(1);
+        }
+        *p = NULL;
+        retval = profile_init((const char **)argv + 1, &profile);
+        if (retval) {
+            com_err(program_name, retval, "while initializing profile");
+            exit(1);
+        }
+        cmd = p[1];
+        names = (const char **) p + 2;
     }
-    cmd = *(argv+2);
-    names = (const char **) argv+3;
     if (!cmd || !strcmp(cmd, "batch"))
         do_batchmode(profile);
     if (!strcmp(cmd, "query")) {

_______________________________________________
krbdev mailing list             krbdev@mit.edu
https://mailman.mit.edu/mailman/listinfo/krbdev

home help back first fref pref prev next nref lref last post