forked from GitHub/gf-core
update
This commit is contained in:
@@ -280,10 +280,15 @@ end:
|
|||||||
fclose(out);
|
fclose(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
|
PGF_API
|
||||||
|
void pgf_write_pgf_cookie
|
||||||
|
(void *cookie,
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
PGF_API
|
ssize_t (*writefn)(void *, const char *, size_t),
|
||||||
void pgf_write_pgf_cookie
|
#else
|
||||||
(void *cookie, cookie_io_functions_t *io_funcs,
|
int (*writefn)(void *, const char *, int),
|
||||||
|
#endif
|
||||||
PgfDB *db, PgfRevision revision,
|
PgfDB *db, PgfRevision revision,
|
||||||
PgfText **langs, // null terminated list or null
|
PgfText **langs, // null terminated list or null
|
||||||
PgfExn* err)
|
PgfExn* err)
|
||||||
@@ -291,36 +296,18 @@ void pgf_write_pgf_cookie
|
|||||||
FILE *out = NULL;
|
FILE *out = NULL;
|
||||||
|
|
||||||
PGF_API_BEGIN {
|
PGF_API_BEGIN {
|
||||||
out = fopencookie(cookie, "wb", *io_funcs);
|
#if defined(__linux__)
|
||||||
if (!out) {
|
cookie_io_functions_t io_funcs = {
|
||||||
throw pgf_systemerror(errno, "<cookie>");
|
NULL,
|
||||||
}
|
writefn,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
{
|
out = fopencookie(cookie, "wb", io_funcs);
|
||||||
DB_scope scope(db, READER_SCOPE);
|
#else
|
||||||
ref<PgfPGF> pgf = db->revision2pgf(revision);
|
out = fwopen(cookie, writefn);
|
||||||
|
#endif
|
||||||
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);
|
|
||||||
if (!out) {
|
if (!out) {
|
||||||
throw pgf_systemerror(errno, "<cookie>");
|
throw pgf_systemerror(errno, "<cookie>");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user