aboutsummaryrefslogtreecommitdiff
path: root/src/vdf/tests/reparse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vdf/tests/reparse.c')
-rw-r--r--src/vdf/tests/reparse.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/vdf/tests/reparse.c b/src/vdf/tests/reparse.c
new file mode 100644
index 0000000..94da4ca
--- /dev/null
+++ b/src/vdf/tests/reparse.c
@@ -0,0 +1,35 @@
+/**
+ * a command line utility that parses a given
+ * vdf file and and output it pretty printed
+ * onto stdout or a specified file
+ *
+ * Used for testing to ensure we parse a VDF
+ * file correctly and can output the same
+ */
+#include <stdio.h>
+
+#include "vdf.h"
+
+int main(int argc, char** argv)
+{
+ if (argc < 2)
+ {
+ puts("vdf_reparse file [output]");
+ return 1;
+ }
+ else if (argc > 2)
+ {
+ freopen(argv[2], "w", stdout);
+ }
+
+ struct vdf_object* o = vdf_parse_file(argv[1]);
+
+ if (!o)
+ {
+ puts("Invalid File");
+ return 1;
+ }
+ vdf_print_object(o);
+
+ vdf_free_object(o);
+} \ No newline at end of file