From 2eee382a62a909d5a3f2f5eda94f30fe68fd5335 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Fri, 20 Jan 2012 13:41:10 +0000 Subject: initial import of the C runtime --- src/runtime/c/utils/pgf2yaml.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/runtime/c/utils/pgf2yaml.c (limited to 'src/runtime/c/utils/pgf2yaml.c') diff --git a/src/runtime/c/utils/pgf2yaml.c b/src/runtime/c/utils/pgf2yaml.c new file mode 100644 index 000000000..32029aa75 --- /dev/null +++ b/src/runtime/c/utils/pgf2yaml.c @@ -0,0 +1,29 @@ +#include + +#include +#include +#include + +int main(void) { + GuPool* pool = gu_new_pool(); + GuExn* err = gu_exn(NULL, type, pool); + GuIn* in = gu_file_in(stdin, pool); + PgfPGF* pgf = pgf_read(in, pool, err); + int status = 0; + if (!gu_ok(err)) { + fprintf(stderr, "Reading PGF failed\n"); + status = 1; + goto fail_read; + } + GuOut* out = gu_file_out(stdout, pool); + GuOut* bout = gu_out_buffered(out, pool); + // GuWriter* wtr = gu_locale_writer(bout, pool); + GuWriter* wtr = gu_new_utf8_writer(bout, pool); + GuDump* ctx = gu_new_dump(wtr, NULL, err, pool); + gu_dump(gu_type(PgfPGF), pgf, ctx); + gu_writer_flush(wtr, err); +fail_read: + gu_pool_free(pool); + return status; +} + -- cgit v1.2.3