From d11014010764660f137a85407064e2a781ddf2a7 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Mon, 4 Sep 2023 17:53:55 +0200 Subject: [PATCH] update --- src/runtime/c/pgf/pgf.cxx | 51 +++++++++++++++------------------------ 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/src/runtime/c/pgf/pgf.cxx b/src/runtime/c/pgf/pgf.cxx index 1ece08df3..315b44dc8 100644 --- a/src/runtime/c/pgf/pgf.cxx +++ b/src/runtime/c/pgf/pgf.cxx @@ -280,10 +280,15 @@ end: fclose(out); } +#if defined(__linux__) || defined(__APPLE__) +PGF_API +void pgf_write_pgf_cookie + (void *cookie, #if defined(__linux__) -PGF_API -void pgf_write_pgf_cookie - (void *cookie, cookie_io_functions_t *io_funcs, + ssize_t (*writefn)(void *, const char *, size_t), +#else + int (*writefn)(void *, const char *, int), +#endif PgfDB *db, PgfRevision revision, PgfText **langs, // null terminated list or null PgfExn* err) @@ -291,36 +296,18 @@ void pgf_write_pgf_cookie FILE *out = NULL; PGF_API_BEGIN { - out = fopencookie(cookie, "wb", *io_funcs); - if (!out) { - throw pgf_systemerror(errno, ""); - } +#if defined(__linux__) + cookie_io_functions_t io_funcs = { + NULL, + writefn, + NULL, + NULL + }; - { - DB_scope scope(db, READER_SCOPE); - ref pgf = db->revision2pgf(revision); - - PgfWriter wtr(langs, out); - wtr.write_pgf(pgf); - } - } PGF_API_END - - if (out != NULL) - fclose(out); -} -#elif defined(__APPLE__) -PGF_API -void pgf_write_pgf_cookie - (void *cookie, int (*writefn)(void *, const char *, int), - int (*closefn)(void *), - PgfDB *db, PgfRevision revision, - PgfText **langs, // null terminated list or null - PgfExn* err) -{ - FILE *out = NULL; - - PGF_API_BEGIN { - out = funopen(cookie, NULL, writefn, NULL, closefn); + out = fopencookie(cookie, "wb", io_funcs); +#else + out = fwopen(cookie, writefn); +#endif if (!out) { throw pgf_systemerror(errno, ""); }