Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 29566) +++ trunk/scconfig/Rev.h (revision 29567) @@ -1 +1 @@ -static const int myrev = 29488; +static const int myrev = 29567; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 29566) +++ trunk/scconfig/Rev.tab (revision 29567) @@ -1,4 +1,4 @@ -29488 configure import_sch conf changes +29567 configure import_sch conf changes, new netlist import formats 29412 configure move generic actions from core to librnd 29385 configure remove build system special casing: generated lists for action registration 29375 configure librnd separation: stroke plugin API conversion from stub to event Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 29566) +++ trunk/scconfig/plugins.h (revision 29567) @@ -80,6 +80,7 @@ plugin_def("import_ltspice", "import ltspice .net+.asc", sbuildin, 1, 0) plugin_def("import_mentor_sch","import mentor graphics sch", sbuildin, 1, 0) plugin_def("import_mucs", "import mucs routing", sbuildin, 1, 0) +plugin_def("import_net_action","import net: action script", sbuildin, 1, 0) plugin_def("import_net_cmd", "sch/net import: run custom cmd", sbuildin, 1, 0) plugin_def("import_netlist", "import netlist", sbuildin, 1, 0) plugin_def("import_pxm_gd", "import pixmaps from png/gif/jpg", sbuildin, 1, 0) Index: trunk/src_plugins/import_net_action/Makefile =================================================================== --- trunk/src_plugins/import_net_action/Makefile (nonexistent) +++ trunk/src_plugins/import_net_action/Makefile (revision 29567) @@ -0,0 +1,5 @@ +all: + cd ../../src && $(MAKE) mod_import_net_action + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/import_net_action/Plug.tmpasm =================================================================== --- trunk/src_plugins/import_net_action/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/import_net_action/Plug.tmpasm (revision 29567) @@ -0,0 +1,8 @@ +put /local/pcb/mod {import_net_action} +put /local/pcb/mod/OBJS [@ $(PLUGDIR)/import_net_action/import_net_action.o @] + +switch /local/pcb/import_net_action/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/import_net_action/import_net_action.c =================================================================== --- trunk/src_plugins/import_net_action/import_net_action.c (nonexistent) +++ trunk/src_plugins/import_net_action/import_net_action.c (revision 29567) @@ -0,0 +1,125 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * netlist action import HID + * pcb-rnd Copyright (C) 2020 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; 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/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" + +#include +#include +#include + +#include "board.h" +#include "actions_pcb.h" +#include "plug_import.h" + +#include +#include +#include +#include + +#include +#include +#include + +static const char *net_action_cookie = "net_action importer"; + +static int net_action_support_prio(pcb_plug_import_t *ctx, unsigned int aspects, const char **args, int numargs) +{ + FILE *f; + unsigned int good = 0, l; + + if ((aspects != IMPORT_ASPECT_NETLIST) || (numargs != 1)) + return 0; /* only pure netlist import is supported from a single file*/ + + f = pcb_fopen(&PCB->hidlib, args[0], "r"); + if (f == NULL) + return 0; + + for(l = 0; l < 32; l++) { + char *s, *n, line[1024]; + s = fgets(line, sizeof(line), f); + for(n = s; *n != '\0'; n++) + *n = tolower(*n); + if (strstr(s, "netlist") != NULL) { + if (strstr(s, "freeze") != NULL) good |= 1; + if (strstr(s, "clear") != NULL) good |= 2; + if (strstr(s, "thaw") != NULL) good |= 2; + } + if (strstr(s, "elementlist") != NULL) { + if (strstr(s, "start") != NULL) good |= 1; + if (strstr(s, "need") != NULL) good |= 2; + } + if (good == (1|2)) { + fclose(f); + return 95; + } + } + + fclose(f); + return 0; +} + + +static int net_action_import(pcb_plug_import_t *ctx, unsigned int aspects, const char **args, int numargs) +{ + if (numargs != 1) { + pcb_message(PCB_MSG_ERROR, "import_net_action: requires exactly 1 input file name\n"); + return -1; + } + pcb_act_execute_file(&PCB->hidlib, args[0]); + return 0; /* some parts of the script may fail (e.g. footprint not found) - that doesn't mean a real error */ +} + +static pcb_plug_import_t import_net_action; + +int pplg_check_ver_import_net_action(int ver_needed) { return 0; } + +void pplg_uninit_import_net_action(void) +{ + PCB_HOOK_UNREGISTER(pcb_plug_import_t, pcb_plug_import_chain, &import_net_action); +} + +int pplg_init_import_net_action(void) +{ + PCB_API_CHK_VER; + + /* register the IO hook */ + import_net_action.plugin_data = NULL; + + import_net_action.fmt_support_prio = net_action_support_prio; + import_net_action.import = net_action_import; + import_net_action.name = "action"; + import_net_action.desc = "schamtics from pcb-rnd action script"; + import_net_action.ui_prio = 100; + import_net_action.single_arg = 1; + import_net_action.all_filenames = 1; + import_net_action.ext_exec = 0; + + PCB_HOOK_REGISTER(pcb_plug_import_t, pcb_plug_import_chain, &import_net_action); + + return 0; +} Index: trunk/src_plugins/import_net_action/import_net_action.pup =================================================================== --- trunk/src_plugins/import_net_action/import_net_action.pup (nonexistent) +++ trunk/src_plugins/import_net_action/import_net_action.pup (revision 29567) @@ -0,0 +1,9 @@ +$class import +$short import net: action script +$long Import the netlist and footprints from an action script. +$state works +$fmt-native no +$fmt-feature-r import netlist and footprint info from pcb-rnd action script +$package import-net +default buildin +autoload 1 Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 29566) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 29567) @@ -61,6 +61,7 @@ include {../src_plugins/import_ltspice/Plug.tmpasm} include {../src_plugins/import_mentor_sch/Plug.tmpasm} include {../src_plugins/import_mucs/Plug.tmpasm} +include {../src_plugins/import_net_action/Plug.tmpasm} include {../src_plugins/import_net_cmd/Plug.tmpasm} include {../src_plugins/import_netlist/Plug.tmpasm} include {../src_plugins/import_pxm_gd/Plug.tmpasm}