OSSP CVS Repository

ossp - Difference in ossp-pkg/cfg/cfg_test.c versions 1.6 and 1.7
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/cfg/cfg_test.c 1.6 -> 1.7

--- cfg_test.c   2002/07/11 09:19:13     1.6
+++ cfg_test.c   2002/07/18 15:34:55     1.7
@@ -14,9 +14,12 @@
     char *ex_ptr;
     char *error;
     cfg_t *cfg;
+    cfg_node_t **vec;
+    cfg_node_t *n;
+    int i;
 
-    if (argc != 2) {
-        fprintf(stderr, "USAGE: %s <file>\n", argv[0]);
+    if (argc < 2 || argc > 3) {
+        fprintf(stderr, "USAGE: %s <file> [<select>]\n", argv[0]);
         exit(1);
     }
 
@@ -40,7 +43,6 @@
         exit(1);
     }
 
-
     if ((rc = cfg_export(cfg, NULL, CFG_FMT_CFG, &ex_ptr, 0)) != CFG_OK) {
         cfg_error(cfg, rc, &error);
         fprintf(stderr, "ERROR: cfg_export: %s\n", error);
@@ -50,6 +52,29 @@
     }
 
     fprintf(stdout, "%s", ex_ptr);
+    fflush(stdout);
+
+    if (argc == 3) {
+        if ((rc = cfg_node_select(cfg, NULL, &vec, "%s", argv[2])) != CFG_OK) {
+            cfg_error(cfg, rc, &error);
+            fprintf(stderr, "ERROR: cfg_node_select: %s\n", error);
+            free(im_ptr);
+            //cfg_destroy(cfg);
+            exit(1);
+        }
+        for (i = 1; vec[i] != NULL; i++) {
+            fprintf(stdout, "---- selection #%d ----\n", i);
+            if ((rc = cfg_export(cfg, vec[i], CFG_FMT_CFG, &ex_ptr, 0)) != CFG_OK) {
+                cfg_error(cfg, rc, &error);
+                fprintf(stderr, "ERROR: cfg_export: %s\n", error);
+                free(im_ptr);
+                //cfg_destroy(cfg);
+                exit(1);
+            }
+            fprintf(stdout, "%s", ex_ptr);
+            fprintf(stdout, "---- selection #%d ----\n", i);
+        }
+    }
 
 #if 0
     cfg_syn_destroy(cfg, node);

CVSTrac 2.0.1