Index: trunk/doc/TODO =================================================================== --- trunk/doc/TODO (revision 6293) +++ trunk/doc/TODO (revision 6294) @@ -6,8 +6,6 @@ - BUG: bug_files/TODO/undo-bug.rs load this sheet. select wire tool. start wire at 60,128, move cursor to 60,136, click, then move cursor to 72,136 and double click to finish new wire. Use wire tool to create wire between TP4 and TP5. Use {u u} and see two wires disappear. [report: Erich] - BUG: bug_files/TODO/intersect-fail.rs load this sheet. select connector CONN1 and attached wirenet with selection rectangle/cursor. move selection down 4 grid points so that CONN1 connected wire meets ground net wire. Ground net fails to have moved wire connected to CONN1 added to ground net. [report: Erich] - BUG: bug_files/TODO/edit-copy-crash.rs load sheet. use cursor to select area from 235k,175k down to 247k, 137k. {e c}. segfault ensues. [report: Erich] -- project export call: - - CLEANUP: move libcschem/export.h into util_export.h 2. 0.9.5 (Beta) ========================================================== - BUG: devmap output attributes are hardwired prio=250 instead of inheriting the plugin's prio [report: aron] Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 6293) +++ trunk/scconfig/Rev.h (revision 6294) @@ -1 +1 @@ -static const int myrev = 6180; +static const int myrev = 6294; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 6293) +++ trunk/scconfig/Rev.tab (revision 6294) @@ -1,3 +1,4 @@ +6294 configure remove excess export API 6180 configure move plug_io_act from lib to sch-rnd as it depends on sch-rnd assumptions on project file naming and file formats and other implementation-specific details 6070 configure rnd_printf support for %rc for printing 'k' coords properly 6035 configure switch over to librnd4's font engine (from local copy of pcb-rnd's) Index: trunk/src/libcschem/export.h =================================================================== --- trunk/src/libcschem/export.h (revision 6293) +++ trunk/src/libcschem/export.h (nonexistent) @@ -1,15 +0,0 @@ -#include -#include -#include - -#define CSCH_PATH_MAX 8192 - -/* Derive path name for get_export_options() */ -void csch_derive_default_filename(rnd_design_t *dsg, int exp_prj, rnd_hid_attr_val_t *filename_attrib, const char *suffix); - - -/*** internal ***/ -void csch_sheet_export_name(csch_sheet_t *sheet, int exp_prj, char epath[CSCH_PATH_MAX], long exp_idx); - -/* sheet is used if project name is not possible to figure; may be NULL */ -void csch_project_export_name(csch_project_t *prj, csch_sheet_t *sheet, char epath[CSCH_PATH_MAX], const char *exp_fmt, const char *view_name); Index: trunk/src/libcschem/export.c =================================================================== --- trunk/src/libcschem/export.c (revision 6293) +++ trunk/src/libcschem/export.c (nonexistent) @@ -1,157 +0,0 @@ -/* - * COPYRIGHT - * - * cschem - modular/flexible schematics editor - libcschem (core library) - * Copyright (C) 2020,2022 Tibor 'Igor2' Palinkas - * - * (Supported by NLnet NGI0 PET Fund in 2022) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version.* - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/sch-rnd - * contact lead developer: http://www.repo.hu/projects/sch-rnd/contact.html - * mailing list: http://www.repo.hu/projects/sch-rnd/contact.html - */ - -#include "config.h" - -#include - -#include "plug_io.h" - -#include "export.h" - -static int use_project_name(csch_sheet_t *sheet, int exp_prj) -{ - csch_project_t *prj = (csch_project_t *)sheet->hidlib.project; - - /* exporting a single sheet: always use sheet name */ - if (!exp_prj) - return 0; - - /* if there is an explicit project file, always export project by project name */ - if (!prj->dummy) - return 1; - - /* if we have an implicit project with a single file, use the file name */ - if (sheet->hidlib.project->designs.used < 2) - return 0; - - /* multiple files with implicit project file: use project name */ - return 1; -} - -void csch_sheet_export_name(csch_sheet_t *sheet, int exp_prj, char epath[CSCH_PATH_MAX], long exp_idx) -{ - if (use_project_name(sheet, exp_prj)) { - const char *pname = NULL, *sep; - sep = strrchr(sheet->hidlib.project->prjdir, '/'); - if (sep == NULL) - pname = sheet->hidlib.project->prjdir; - else - pname = sep+1; - sprintf(epath, "%s*", pname); - } - else if (sheet->hidlib.loadname != NULL) { - char *ext; - if (strlen(sheet->hidlib.loadname) >= CSCH_PATH_MAX) { - sprintf(epath, "long_named_sheet_%ld*", exp_idx); - return; - } - strcpy(epath, sheet->hidlib.loadname); - ext = strrchr(epath, '.'); - if ((strcmp(ext, ".rs") == 0) || (strcmp(ext, ".lht") == 0) || (strcmp(ext, ".csch") == 0)) - strcpy(ext, "*"); - } - else - sprintf(epath, "anon_sheet_%ld*", exp_idx); -} - -void csch_project_export_name(csch_project_t *prj, csch_sheet_t *sheet, char epath[CSCH_PATH_MAX], const char *exp_fmt, const char *view_name) -{ - - /* automatic view name */ - if (view_name == NULL) { - void **v = vtp0_get(&prj->views, prj->curr, 0); - - if ((v != NULL) && (*v != NULL)) { - csch_view_t *view = *v; - view_name = view->fgw_ctx.name; - } - else - view_name = "no_view"; - } - - if (prj->hdr.loadname != NULL) { - char *end; - if (strlen(prj->hdr.loadname) + strlen(view_name) >= CSCH_PATH_MAX) - goto fallback; - strcpy(epath, prj->hdr.loadname); - end = strrchr(epath, '/'); - if (strcmp(end, "/project.lht") == 0) - sprintf(end, "/netlist.%s*", view_name); - } - else { - fallback:; - if (sheet != NULL) { - if (sheet->hidlib.loadname != NULL) { - long len = strlen(sheet->hidlib.loadname); - char *s, *end; - - memcpy(epath, sheet->hidlib.loadname, len); - for(s = end = epath + len; s > sheet->hidlib.loadname+1; s--) { - if (*s == '.') { - end = s; - break; - } - } - *end = '.'; - end++; - len = strlen(view_name); - memcpy(end, view_name, len); - end += len; - end[0] = '*'; - end[1] = '\0'; - } - else - goto fallback2; - } - else { - fallback2:; - sprintf(epath, "netlist.%s*", view_name); - } - } -} - -void csch_derive_default_filename(rnd_design_t *dsg, int exp_prj, rnd_hid_attr_val_t *filename_attrib, const char *suffix) -{ - csch_sheet_t *sheet = (csch_sheet_t *)dsg; - char tmp[CSCH_PATH_MAX]; - char *e; - - csch_sheet_export_name(sheet, exp_prj, tmp, sheet->uid); - e = strchr(tmp, '*'); - if (e != NULL) { - if ((CSCH_PATH_MAX - (e - tmp)) > strlen(suffix)+1) - strcpy(e, suffix); - else - *e = '\0'; - } - - free((char *)filename_attrib->str); - filename_attrib->str = rnd_strdup(tmp); -} - Index: trunk/src/libcschem/Makefile.dep =================================================================== --- trunk/src/libcschem/Makefile.dep (revision 6293) +++ trunk/src/libcschem/Makefile.dep (revision 6294) @@ -170,14 +170,6 @@ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ ../libcschem/TODO.h ../libcschem/engine.h engine.h event.o: event.c event.h -export.o: export.c config.h plug_io.h ../libcschem/concrete.h \ - ../libcschem/common_types.h ../libcschem/config.h ../libcschem/rtree.h \ - ../libcschem/attrib.h ../libcschem/oidpath.h ../libcschem/vtoid.h \ - ../../src_3rd/libuundo/uundo.h ../../src_3rd/libminuid/libminuid.h \ - ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ - ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ - ../libcschem/TODO.h ../libcschem/abstract.h export.h \ - ../libcschem/project.h ../libcschem/engine.h htPo.o: htPo.c htPo.h config.h \ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h @@ -318,7 +310,7 @@ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h TODO.h \ compile.h ../libcschem/abstract.h ../libcschem/TODO.h \ ../libcschem/concrete.h ../libcschem/project.h ../libcschem/engine.h \ - util_export.h + plug_io.h util_export.h util_grp.o: util_grp.c config.h concrete.h ../libcschem/common_types.h \ ../libcschem/config.h ../libcschem/rtree.h ../libcschem/attrib.h \ ../libcschem/oidpath.h ../libcschem/vtoid.h \ Index: trunk/src/libcschem/Makefile.in =================================================================== --- trunk/src/libcschem/Makefile.in (revision 6293) +++ trunk/src/libcschem/Makefile.in (revision 6294) @@ -28,7 +28,6 @@ compile.o engine.o event.o - export.o htPo.o integrity.o intersect.o Index: trunk/src/libcschem/util_export.c =================================================================== --- trunk/src/libcschem/util_export.c (revision 6293) +++ trunk/src/libcschem/util_export.c (revision 6294) @@ -32,6 +32,7 @@ #include #include "concrete.h" #include "compile.h" +#include "plug_io.h" #include "util_export.h" @@ -163,3 +164,127 @@ *cookie = NULL; } + + + +static int use_project_name(csch_sheet_t *sheet, int exp_prj) +{ + csch_project_t *prj = (csch_project_t *)sheet->hidlib.project; + + /* exporting a single sheet: always use sheet name */ + if (!exp_prj) + return 0; + + /* if there is an explicit project file, always export project by project name */ + if (!prj->dummy) + return 1; + + /* if we have an implicit project with a single file, use the file name */ + if (sheet->hidlib.project->designs.used < 2) + return 0; + + /* multiple files with implicit project file: use project name */ + return 1; +} + +void csch_sheet_export_name(csch_sheet_t *sheet, int exp_prj, char epath[CSCH_PATH_MAX], long exp_idx) +{ + if (use_project_name(sheet, exp_prj)) { + const char *pname = NULL, *sep; + sep = strrchr(sheet->hidlib.project->prjdir, '/'); + if (sep == NULL) + pname = sheet->hidlib.project->prjdir; + else + pname = sep+1; + sprintf(epath, "%s*", pname); + } + else if (sheet->hidlib.loadname != NULL) { + char *ext; + if (strlen(sheet->hidlib.loadname) >= CSCH_PATH_MAX) { + sprintf(epath, "long_named_sheet_%ld*", exp_idx); + return; + } + strcpy(epath, sheet->hidlib.loadname); + ext = strrchr(epath, '.'); + if ((strcmp(ext, ".rs") == 0) || (strcmp(ext, ".lht") == 0) || (strcmp(ext, ".csch") == 0)) + strcpy(ext, "*"); + } + else + sprintf(epath, "anon_sheet_%ld*", exp_idx); +} + +void csch_project_export_name(csch_project_t *prj, csch_sheet_t *sheet, char epath[CSCH_PATH_MAX], const char *exp_fmt, const char *view_name) +{ + + /* automatic view name */ + if (view_name == NULL) { + void **v = vtp0_get(&prj->views, prj->curr, 0); + + if ((v != NULL) && (*v != NULL)) { + csch_view_t *view = *v; + view_name = view->fgw_ctx.name; + } + else + view_name = "no_view"; + } + + if (prj->hdr.loadname != NULL) { + char *end; + if (strlen(prj->hdr.loadname) + strlen(view_name) >= CSCH_PATH_MAX) + goto fallback; + strcpy(epath, prj->hdr.loadname); + end = strrchr(epath, '/'); + if (strcmp(end, "/project.lht") == 0) + sprintf(end, "/netlist.%s*", view_name); + } + else { + fallback:; + if (sheet != NULL) { + if (sheet->hidlib.loadname != NULL) { + long len = strlen(sheet->hidlib.loadname); + char *s, *end; + + memcpy(epath, sheet->hidlib.loadname, len); + for(s = end = epath + len; s > sheet->hidlib.loadname+1; s--) { + if (*s == '.') { + end = s; + break; + } + } + *end = '.'; + end++; + len = strlen(view_name); + memcpy(end, view_name, len); + end += len; + end[0] = '*'; + end[1] = '\0'; + } + else + goto fallback2; + } + else { + fallback2:; + sprintf(epath, "netlist.%s*", view_name); + } + } +} + +void csch_derive_default_filename(rnd_design_t *dsg, int exp_prj, rnd_hid_attr_val_t *filename_attrib, const char *suffix) +{ + csch_sheet_t *sheet = (csch_sheet_t *)dsg; + char tmp[CSCH_PATH_MAX]; + char *e; + + csch_sheet_export_name(sheet, exp_prj, tmp, sheet->uid); + e = strchr(tmp, '*'); + if (e != NULL) { + if ((CSCH_PATH_MAX - (e - tmp)) > strlen(suffix)+1) + strcpy(e, suffix); + else + *e = '\0'; + } + + free((char *)filename_attrib->str); + filename_attrib->str = rnd_strdup(tmp); +} + Index: trunk/src/libcschem/util_export.h =================================================================== --- trunk/src/libcschem/util_export.h (revision 6293) +++ trunk/src/libcschem/util_export.h (revision 6294) @@ -1,6 +1,13 @@ #include +#include #include +#include +#define CSCH_PATH_MAX 8192 + +/* Derive path name for get_export_options() */ +void csch_derive_default_filename(rnd_design_t *dsg, int exp_prj, rnd_hid_attr_val_t *filename_attrib, const char *suffix); + /* Allocate a new output file name; use explicit if available or construct the name from hl's filename replacing it's "extension". Optional base_suffix and/or base_prefix are prepended and/or appended to the base @@ -14,3 +21,10 @@ /* Restore project state after a compilation-for-export */ void cschem_export_compile_post(csch_project_t *prj, void **cookie); + + +/*** internal ***/ +void csch_sheet_export_name(csch_sheet_t *sheet, int exp_prj, char epath[CSCH_PATH_MAX], long exp_idx); + +/* sheet is used if project name is not possible to figure; may be NULL */ +void csch_project_export_name(csch_project_t *prj, csch_sheet_t *sheet, char epath[CSCH_PATH_MAX], const char *exp_fmt, const char *view_name); Index: trunk/src/plugins/export_abst/export_abst.c =================================================================== --- trunk/src/plugins/export_abst/export_abst.c (revision 6293) +++ trunk/src/plugins/export_abst/export_abst.c (revision 6294) @@ -34,7 +34,7 @@ #include #include #include -#include +#include static csch_plug_io_t eabst; Index: trunk/src/plugins/export_png/export_png.c =================================================================== --- trunk/src/plugins/export_png/export_png.c (revision 6293) +++ trunk/src/plugins/export_png/export_png.c (revision 6294) @@ -45,7 +45,6 @@ #include #include -#include #include #include Index: trunk/src/plugins/export_ps/eps.c =================================================================== --- trunk/src/plugins/export_ps/eps.c (revision 6293) +++ trunk/src/plugins/export_ps/eps.c (revision 6294) @@ -22,7 +22,6 @@ #include #include -#include #include #include Index: trunk/src/plugins/export_ps/ps.c =================================================================== --- trunk/src/plugins/export_ps/ps.c (revision 6293) +++ trunk/src/plugins/export_ps/ps.c (revision 6294) @@ -25,7 +25,6 @@ #include #include -#include #include #include Index: trunk/src/plugins/export_svg/export_svg.c =================================================================== --- trunk/src/plugins/export_svg/export_svg.c (revision 6293) +++ trunk/src/plugins/export_svg/export_svg.c (revision 6294) @@ -52,7 +52,6 @@ #include #include -#include #include #include Index: trunk/src/plugins/export_tedax/hid_impl.c =================================================================== --- trunk/src/plugins/export_tedax/hid_impl.c (revision 6293) +++ trunk/src/plugins/export_tedax/hid_impl.c (revision 6294) @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include static const char tedax_cookie[] = "tEDAx export hid"; Index: trunk/src/sch-rnd/Makefile.dep =================================================================== --- trunk/src/sch-rnd/Makefile.dep (revision 6293) +++ trunk/src/sch-rnd/Makefile.dep (revision 6294) @@ -96,7 +96,7 @@ ../../src_3rd/libuundo/uundo.h ../../src_3rd/libminuid/libminuid.h \ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ - ../libcschem/TODO.h ../libcschem/abstract.h ../libcschem/export.h \ + ../libcschem/TODO.h ../libcschem/abstract.h ../libcschem/util_export.h \ ../libcschem/project.h ../libcschem/engine.h \ ../plugins/export_abst/hid_impl.c ../sch-rnd/export.h ../sch-rnd/draw.h ../plugins/export_lpr/lpr.o: ../plugins/export_lpr/lpr.c \ @@ -108,8 +108,8 @@ ../../src_3rd/libuundo/uundo.h ../../src_3rd/libminuid/libminuid.h \ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ - ../libcschem/TODO.h ../libcschem/engine.h ../libcschem/export.h \ - ../sch-rnd/draw.h ../sch-rnd/export.h + ../libcschem/TODO.h ../libcschem/engine.h ../sch-rnd/draw.h \ + ../sch-rnd/export.h ../plugins/export_ps/eps.o: ../plugins/export_ps/eps.c \ ../libcschem/config.h ../libcschem/util_export.h ../libcschem/project.h \ ../libcschem/common_types.h ../libcschem/concrete.h ../libcschem/rtree.h \ @@ -117,8 +117,8 @@ ../../src_3rd/libuundo/uundo.h ../../src_3rd/libminuid/libminuid.h \ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ - ../libcschem/TODO.h ../libcschem/engine.h ../libcschem/export.h \ - ../sch-rnd/draw.h ../sch-rnd/export.h ../plugins/export_ps/export_ps.h + ../libcschem/TODO.h ../libcschem/engine.h ../sch-rnd/draw.h \ + ../sch-rnd/export.h ../plugins/export_ps/export_ps.h ../plugins/export_ps/export_ps.o: ../plugins/export_ps/export_ps.c \ ../libcschem/config.h ../plugins/export_ps/export_ps.h ../plugins/export_ps/ps.o: ../plugins/export_ps/ps.c \ @@ -129,8 +129,8 @@ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ ../libcschem/TODO.h ../libcschem/util_export.h ../libcschem/project.h \ - ../libcschem/engine.h ../libcschem/export.h ../sch-rnd/draw.h \ - ../sch-rnd/export.h ../plugins/export_ps/export_ps.h + ../libcschem/engine.h ../sch-rnd/draw.h ../sch-rnd/export.h \ + ../plugins/export_ps/export_ps.h ../plugins/export_svg/export_svg.o: ../plugins/export_svg/export_svg.c \ ../libcschem/config.h ../libcschem/concrete.h \ ../libcschem/common_types.h ../libcschem/rtree.h ../libcschem/attrib.h \ @@ -139,8 +139,7 @@ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ ../libcschem/TODO.h ../libcschem/util_export.h ../libcschem/project.h \ - ../libcschem/engine.h ../libcschem/export.h ../sch-rnd/draw.h \ - ../sch-rnd/export.h + ../libcschem/engine.h ../sch-rnd/draw.h ../sch-rnd/export.h ../plugins/export_tedax/export_tedax.o: \ ../plugins/export_tedax/export_tedax.c ../libcschem/config.h \ ../libcschem/plug_io.h ../libcschem/concrete.h \ @@ -151,7 +150,7 @@ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ ../libcschem/TODO.h ../libcschem/abstract.h \ ../plugins/export_tedax/hid_impl.c ../libcschem/project.h \ - ../libcschem/engine.h ../libcschem/export.h ../sch-rnd/export.h \ + ../libcschem/engine.h ../libcschem/util_export.h ../sch-rnd/export.h \ ../sch-rnd/draw.h ../plugins/gui/act.o: ../plugins/gui/act.c ../libcschem/config.h \ ../plugins/gui/act.h @@ -807,7 +806,7 @@ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ ../libcschem/TODO.h ../libcschem/abstract.h ../libcschem/plug_io.h \ - ../libcschem/export.h ../libcschem/project.h ../libcschem/engine.h \ + ../libcschem/util_export.h ../libcschem/project.h ../libcschem/engine.h \ ../libcschem/compile.h export.h ../sch-rnd/draw.h file_act.o: file_act.c ../libcschem/config.h ../libcschem/concrete.h \ ../libcschem/common_types.h ../libcschem/rtree.h ../libcschem/attrib.h \ @@ -881,7 +880,7 @@ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ ../libcschem/TODO.h ../libcschem/engine.h ../libcschem/abstract.h \ - ../libcschem/compile.h ../libcschem/export.h ../libcschem/event.h \ + ../libcschem/compile.h ../libcschem/util_export.h ../libcschem/event.h \ ../libcschem/csch_printf.h conf_core.h crosshair.h build_run.h sheet.h \ draw.h font.h ../libcschem/cnc_text.h ../libcschem/cnc_text_dyn.h \ emergency.h project.h multi.h plug_io_act.h export.h ../sch-rnd/draw.h \ Index: trunk/src/sch-rnd/export.c =================================================================== --- trunk/src/sch-rnd/export.c (revision 6293) +++ trunk/src/sch-rnd/export.c (revision 6294) @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include Index: trunk/src/sch-rnd/sch-rnd.c =================================================================== --- trunk/src/sch-rnd/sch-rnd.c (revision 6293) +++ trunk/src/sch-rnd/sch-rnd.c (revision 6294) @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #include