OSSP CVS Repository

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

ossp-pkg/cfg/cfg_test.c 1.4 -> 1.5

--- cfg_test.c   2002/07/05 18:32:37     1.4
+++ cfg_test.c   2002/07/10 14:46:28     1.5
@@ -12,30 +12,53 @@
 int main(int argc, char *argv[]) 
 {
     cfg_rc_t rc;
-    char *buf_ptr;
-    size_t buf_size;
-    cfg_node_t *node;
-    char err_buf[1024];
+    char *im_ptr;
+    size_t im_size;
+    char *ex_ptr;
+    char *error;
+    cfg_t *cfg;
 
     if (argc != 2) {
         fprintf(stderr, "USAGE: %s <file>\n", argv[0]);
         exit(1);
     }
-    if ((rc = cfg_util_readfile(argv[1], &buf_ptr, &buf_size)) != CFG_OK) {
+
+    if ((rc = cfg_util_readfile(argv[1], &im_ptr, &im_size)) != CFG_OK) {
         fprintf(stderr, "ERROR: reading file \"%s\"\n", argv[1]);
         exit(1);
     }
-    rc = cfg_syn_import(NULL, &node, buf_ptr, err_buf, sizeof(err_buf));
-    free(buf_ptr);
 
-    if (rc != CFG_OK)
-        fprintf(stderr, "ERROR: %s\n", err_buf);
-    else {
-        cfg_syn_export(NULL, node, &buf_ptr);
-        cfg_syn_destroy(NULL, node);
-        fprintf(stdout, "%s", buf_ptr);
+    if ((rc = cfg_create(&cfg)) != CFG_OK) {
+        cfg_error(cfg, rc, &error);
+        fprintf(stderr, "ERROR: cfg_create: %s\n", error);
+        free(im_ptr);
+        exit(1);
+    }
+
+    if ((rc = cfg_import(cfg, NULL, CFG_FMT_CFG, im_ptr, im_size)) != CFG_OK) {
+        cfg_error(cfg, rc, &error);
+        fprintf(stderr, "ERROR: cfg_import: %s\n", error);
+        free(im_ptr);
+        cfg_destroy(cfg);
+        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);
+        free(im_ptr);
+        cfg_destroy(cfg);
+        exit(1);
+    }
+
+    fprintf(stdout, "%s", ex_ptr);
+
+#if 0
+    cfg_syn_destroy(cfg, node);
+    cfg_destroy(cfg);
+#endif
+
     return 0;
 }
 

CVSTrac 2.0.1