Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
krangelov committed Sep 4, 2023
1 parent 295458a commit d110140
Showing 1 changed file with 19 additions and 32 deletions.
51 changes: 19 additions & 32 deletions src/runtime/c/pgf/pgf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -280,47 +280,34 @@ void pgf_write_pgf(const char* fpath,
fclose(out);
}

#if defined(__linux__)
PGF_API
void pgf_write_pgf_cookie
(void *cookie, cookie_io_functions_t *io_funcs,
PgfDB *db, PgfRevision revision,
PgfText **langs, // null terminated list or null
PgfExn* err)
{
FILE *out = NULL;

PGF_API_BEGIN {
out = fopencookie(cookie, "wb", *io_funcs);
if (!out) {
throw pgf_systemerror(errno, "<cookie>");
}

{
DB_scope scope(db, READER_SCOPE);
ref<PgfPGF> pgf = db->revision2pgf(revision);

PgfWriter wtr(langs, out);
wtr.write_pgf(pgf);
}
} PGF_API_END

if (out != NULL)
fclose(out);
}
#elif defined(__APPLE__)
#if defined(__linux__) || defined(__APPLE__)
PGF_API
void pgf_write_pgf_cookie
(void *cookie, int (*writefn)(void *, const char *, int),
int (*closefn)(void *),
(void *cookie,
#if defined(__linux__)
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)
{
FILE *out = NULL;

PGF_API_BEGIN {
out = funopen(cookie, NULL, writefn, NULL, closefn);
#if defined(__linux__)
cookie_io_functions_t io_funcs = {
NULL,
writefn,
NULL,
NULL
};

out = fopencookie(cookie, "wb", io_funcs);
#else
out = fwopen(cookie, writefn);
#endif
if (!out) {
throw pgf_systemerror(errno, "<cookie>");
}
Expand Down

0 comments on commit d110140

Please sign in to comment.