Index: trunk/src/plugins/io_easyeda/io_easyeda.c =================================================================== --- trunk/src/plugins/io_easyeda/io_easyeda.c (revision 10647) +++ trunk/src/plugins/io_easyeda/io_easyeda.c (revision 10648) @@ -78,6 +78,7 @@ easystd.name = "EasyEDA std sheets"; easystd.load_prio = io_easystd_load_prio; + easystd.test_parse = io_easystd_test_parse; /* for syms */ /* easystd.load_grp = io_easystd_load_grp; - TODO: check on the symbol format */ easystd.load_sheet_bundled = io_easystd_load_sheet_bundled; easystd.test_parse_bundled = io_easystd_test_parse_bundled; Index: trunk/src/plugins/io_easyeda/read.h =================================================================== --- trunk/src/plugins/io_easyeda/read.h (revision 10647) +++ trunk/src/plugins/io_easyeda/read.h (revision 10648) @@ -1,8 +1,14 @@ #include -csch_cgrp_t *io_easypro_load_grp(FILE *f, const char *fn, const char *fmt, csch_sheet_t *sheet); +/*** std ***/ +int io_easystd_test_parse(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type); + + +/*** pro ***/ int io_easypro_test_parse(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type); +csch_cgrp_t *io_easypro_load_grp(FILE *f, const char *fn, const char *fmt, csch_sheet_t *sheet); + void *io_easystd_test_parse_bundled(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type); int io_easystd_load_sheet_bundled(void *cookie, FILE *f, const char *fn, csch_sheet_t *dst); void io_easystd_end_bundled(void *cookie, const char *fn); Index: trunk/src/plugins/io_easyeda/read_hi_std.c =================================================================== --- trunk/src/plugins/io_easyeda/read_hi_std.c (revision 10647) +++ trunk/src/plugins/io_easyeda/read_hi_std.c (revision 10648) @@ -910,7 +910,7 @@ static int easystd_get_doctype(char *stray, FILE *f, char *buf, long buf_len) { - char *line = stray, *s, *end; + char *line = stray, *end; int n, res; /* don't re-read this line */ @@ -939,15 +939,13 @@ } /* verify easyeda json header */ -static int io_easystd_test_parse(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type) +static int io_easystd_test_parse_(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type, int *is_sym) { char buf[1024], *line; int n, doctype; unsigned found = 0; - /* can read only sheets, refuse anything else */ - if (type != CSCH_IOTYP_SHEET) - return -1; + *is_sym = 0; /* ensure all vital header fields are present in the first 32 lines */ for(n = 0; n < 32; n++) { @@ -966,8 +964,10 @@ if (strncmp(line, "docType\"", 8) == 0) { found |= 2; /* generic easyeda */ doctype = easystd_get_doctype(line + 8, f, line, sizeof(line)); - if ((doctype == 2) && (/*(type == CSCH_IOTYP_SHEET) ||*/ (type == CSCH_IOTYP_GROUP))) + if ((doctype == 2) && (/*(type == CSCH_IOTYP_SHEET) ||*/ (type == CSCH_IOTYP_GROUP))) { + *is_sym = 1; found |= 4; /* open symbols in sym edit mode or load from lib */ + } if (*line != '\0') goto got_line; @@ -1005,6 +1005,13 @@ int sheet_idx; } easystd_bundle_t; +int io_easystd_test_parse(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type) +{ + int is_sym; + return io_easystd_test_parse_(f, fn, fmt, type, &is_sym); +} + + /* load a single sheet from f/fn into preallocated empty sheet dst; fmt is an optional hint on the format (safe to ignore). Return 0 on success */ @@ -1051,9 +1058,9 @@ void *io_easystd_test_parse_bundled(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type) { - int res = io_easystd_test_parse(f, fn, fmt, type); + int is_sym, res = io_easystd_test_parse_(f, fn, fmt, type, &is_sym); - if (res == 0) { + if ((res == 0) && !is_sym) { easystd_bundle_t *bnd = calloc(sizeof(easystd_bundle_t), 1); rewind(f);