Index: trunk/src/plugins/io_easyeda/io_easyeda.c =================================================================== --- trunk/src/plugins/io_easyeda/io_easyeda.c (revision 10644) +++ trunk/src/plugins/io_easyeda/io_easyeda.c (revision 10645) @@ -38,15 +38,26 @@ conf_io_easyeda_t io_easyeda_conf; -static csch_plug_io_t easyeda; +static csch_plug_io_t easystd, easypro; static char easyeda_cookie[] = "io_easyeda"; -static int io_easyeda_load_prio(const char *fn, const char *fmt, csch_plug_io_type_t type) +static int io_easystd_load_prio(const char *fn, const char *fmt, csch_plug_io_type_t type) { if (fmt != NULL) { if (!strstr(fmt, "easyeda") && !strstr(fmt, "easyeda") && !strstr(fmt, "sch")) return 0; } + if (type == CSCH_IOTYP_SHEET) + return 90; + return 0; +} + +static int io_easypro_load_prio(const char *fn, const char *fmt, csch_plug_io_type_t type) +{ + if (fmt != NULL) { + if (!strstr(fmt, "easyeda") && !strstr(fmt, "easyeda") && !strstr(fmt, "sch")) + return 0; + } if ((type == CSCH_IOTYP_SHEET) || (type == CSCH_IOTYP_GROUP)) return 90; return 0; @@ -56,7 +67,8 @@ void pplg_uninit_io_easyeda(void) { - csch_plug_io_unregister(&easyeda); + csch_plug_io_unregister(&easystd); + csch_plug_io_unregister(&easypro); rnd_conf_plug_unreg("plugins/io_easyeda/", io_easyeda_conf_internal, easyeda_cookie); } @@ -64,23 +76,30 @@ { RND_API_CHK_VER; - easyeda.name = "EasyEDA std sheets, EasyEDA pro symbols"; - easyeda.load_prio = io_easyeda_load_prio; - easyeda.load_grp = io_easyeda_load_grp; + easystd.name = "EasyEDA std sheets"; + easystd.load_prio = io_easystd_load_prio; +/* 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; + easystd.end_bundled = io_easystd_end_bundled; + easystd.ext_save_sheet = "sch"; + easystd.ext_save_grp = "sym"; + csch_plug_io_register(&easystd); - /* for syms */ - easyeda.test_parse = io_easyeda_test_parse; + easystd.name = "EasyEDA pro sheets and symbols"; + easystd.load_prio = io_easypro_load_prio; + easystd.load_grp = io_easypro_load_grp; + easystd.test_parse = io_easypro_test_parse; /* for syms */ +/* + easystd.load_sheet_bundled = io_easypro_load_sheet_bundled; + easystd.test_parse_bundled = io_easypro_test_parse_bundled; + easystd.end_bundled = io_easypro_end_bundled; +*/ + easystd.ext_save_sheet = "sch"; + easystd.ext_save_grp = "sym"; + csch_plug_io_register(&easypro); - /* for sheets */ - easyeda.load_sheet_bundled = io_easyeda_load_sheet_bundled; - easyeda.test_parse_bundled = io_easyeda_test_parse_bundled; - easyeda.end_bundled = io_easyeda_end_bundled; - easyeda.ext_save_sheet = "sch"; - easyeda.ext_save_grp = "sym"; - csch_plug_io_register(&easyeda); - - rnd_conf_plug_reg(io_easyeda_conf, io_easyeda_conf_internal, easyeda_cookie); #define conf_reg(field,isarray,type_name,cpath,cname,desc,flags) \ rnd_conf_reg_field(io_easyeda_conf, field,isarray,type_name,cpath,cname,desc,flags); Index: trunk/src/plugins/io_easyeda/read.c =================================================================== --- trunk/src/plugins/io_easyeda/read.c (revision 10644) +++ trunk/src/plugins/io_easyeda/read.c (revision 10645) @@ -443,7 +443,7 @@ /* 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 */ -int io_easyeda_load_sheet_bundled(void *cookie, FILE *f, const char *fn, csch_sheet_t *dst) +int io_easystd_load_sheet_bundled(void *cookie, FILE *f, const char *fn, csch_sheet_t *dst) { int res = -1; gdom_node_t *root_sch; @@ -485,7 +485,7 @@ } /* IO API function (load symbol from lib) - symbols are in the pro format */ -csch_cgrp_t *io_easyeda_load_grp(FILE *f, const char *fn, const char *fmt, csch_sheet_t *sheet) +csch_cgrp_t *io_easypro_load_grp(FILE *f, const char *fn, const char *fmt, csch_sheet_t *sheet) { read_ctx_t ctx = {0}; csch_cgrp_t *grp; @@ -549,12 +549,15 @@ return -1; } -static int io_easypro_test_parse(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type) +int io_easypro_test_parse(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type) { char line_[256], *line; + /* sheets are loaded as bundles from zip */ + if (type == CSCH_IOTYP_SHEET) + return -1; + /* first line is: ["DOCTYPE","SYMBOL","1.1"] */ - line = fgets(line_, sizeof(line_), f); if ((line == NULL) || (*line != '[')) return -1; @@ -572,18 +575,8 @@ return -1; } -int io_easyeda_test_parse(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type) +void *io_easystd_test_parse_bundled(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type) { - /* sheets are loaded as bundles */ - if (type == CSCH_IOTYP_SHEET) - return -1; - - return io_easypro_test_parse(f, fn, fmt, type); -} - - -void *io_easyeda_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); if (res == 0) { @@ -609,7 +602,7 @@ } -void io_easyeda_end_bundled(void *cookie, const char *fn) +void io_easystd_end_bundled(void *cookie, const char *fn) { easyeda_bundle_t *bnd = cookie; Index: trunk/src/plugins/io_easyeda/read.h =================================================================== --- trunk/src/plugins/io_easyeda/read.h (revision 10644) +++ trunk/src/plugins/io_easyeda/read.h (revision 10645) @@ -1,11 +1,11 @@ #include -csch_cgrp_t *io_easyeda_load_grp(FILE *f, const char *fn, const char *fmt, csch_sheet_t *sheet); +csch_cgrp_t *io_easypro_load_grp(FILE *f, const char *fn, const char *fmt, csch_sheet_t *sheet); -int io_easyeda_test_parse(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type); +int io_easypro_test_parse(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type); -void *io_easyeda_test_parse_bundled(FILE *f, const char *fn, const char *fmt, csch_plug_io_type_t type); -int io_easyeda_load_sheet_bundled(void *cookie, FILE *f, const char *fn, csch_sheet_t *dst); -void io_easyeda_end_bundled(void *cookie, const char *fn); +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);