diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2012-01-20 13:41:10 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2012-01-20 13:41:10 +0000 |
| commit | 2eee382a62a909d5a3f2f5eda94f30fe68fd5335 (patch) | |
| tree | b0b0d513535895f244214aebf6358e172b8dce6d /src/runtime/c/utils/pgf2yaml.c | |
| parent | b9728357126f8b9a6311cca17d9f0dcc2a7bfb9b (diff) | |
initial import of the C runtime
Diffstat (limited to 'src/runtime/c/utils/pgf2yaml.c')
| -rw-r--r-- | src/runtime/c/utils/pgf2yaml.c | 29 |
1 files changed, 29 insertions, 0 deletions
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 <pgf/pgf.h> + +#include <gu/dump.h> +#include <gu/file.h> +#include <gu/utf8.h> + +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; +} + |
