mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
make it possible to write grammars via a cookie in glibc
This commit is contained in:
@@ -280,6 +280,36 @@ end:
|
||||
fclose(out);
|
||||
}
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
PGF_API
|
||||
const char *pgf_file_path(PgfDB *db)
|
||||
{
|
||||
|
||||
@@ -291,6 +291,15 @@ void pgf_write_pgf(const char* fpath,
|
||||
PgfText **langs, // null terminated list or null
|
||||
PgfExn* err);
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
PGF_API_DECL
|
||||
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);
|
||||
#endif
|
||||
|
||||
PGF_API_DECL
|
||||
const char *pgf_file_path(PgfDB *db);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user