forked from GitHub/gf-core
the reader now controls the PGF version
This commit is contained in:
@@ -119,8 +119,8 @@ PgfDB *pgf_read_ngf(const char *fpath,
|
|||||||
is_new = true;
|
is_new = true;
|
||||||
pgf = PgfDB::malloc<PgfPGF>(master.size+1);
|
pgf = PgfDB::malloc<PgfPGF>(master.size+1);
|
||||||
pgf->ref_count = 1;
|
pgf->ref_count = 1;
|
||||||
pgf->major_version = 2;
|
pgf->major_version = PGF_MAJOR_VERSION;
|
||||||
pgf->minor_version = 0;
|
pgf->minor_version = PGF_MINOR_VERSION;
|
||||||
pgf->gflags = 0;
|
pgf->gflags = 0;
|
||||||
pgf->abstract.name = PgfDB::malloc<PgfText>();
|
pgf->abstract.name = PgfDB::malloc<PgfText>();
|
||||||
pgf->abstract.name->size = 0;
|
pgf->abstract.name->size = 0;
|
||||||
|
|||||||
@@ -40,6 +40,9 @@
|
|||||||
#include<stdint.h>
|
#include<stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#define PGF_MAJOR_VERSION 2
|
||||||
|
#define PGF_MINOR_VERSION 1
|
||||||
|
|
||||||
/* A generic structure to store text. The last field is variable length */
|
/* A generic structure to store text. The last field is variable length */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|||||||
@@ -437,6 +437,11 @@ ref<PgfPGF> PgfReader::read_pgf()
|
|||||||
pgf->major_version = read_u16be();
|
pgf->major_version = read_u16be();
|
||||||
pgf->minor_version = read_u16be();
|
pgf->minor_version = read_u16be();
|
||||||
|
|
||||||
|
if (pgf->major_version != PGF_MAJOR_VERSION ||
|
||||||
|
pgf->minor_version != PGF_MINOR_VERSION) {
|
||||||
|
throw pgf_error("Unsupported format version");
|
||||||
|
}
|
||||||
|
|
||||||
pgf->gflags = read_namespace<PgfFlag>(&PgfReader::read_flag);
|
pgf->gflags = read_namespace<PgfFlag>(&PgfReader::read_flag);
|
||||||
|
|
||||||
read_abstract(ref<PgfAbstr>::from_ptr(&pgf->abstract));
|
read_abstract(ref<PgfAbstr>::from_ptr(&pgf->abstract));
|
||||||
|
|||||||
Reference in New Issue
Block a user