Index: Makefile =================================================================== --- Makefile (nonexistent) +++ Makefile (revision 18662) @@ -0,0 +1,5 @@ +all: + cd ../../src && $(MAKE) mod_import_fpcb_nl + +clean: + rm *.o *.so 2>/dev/null ; true Index: Plug.tmpasm =================================================================== --- Plug.tmpasm (nonexistent) +++ Plug.tmpasm (revision 18662) @@ -0,0 +1,8 @@ +put /local/pcb/mod {import_fpcb_nl} +put /local/pcb/mod/OBJS [@ $(PLUGDIR)/import_fpcb_nl/fpcb_nl.o @] + +switch /local/pcb/import_fpcb_nl/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: fpcb_nl.c =================================================================== --- fpcb_nl.c (nonexistent) +++ fpcb_nl.c (revision 18662) @@ -0,0 +1,112 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * Freepcb netlist import + * pcb-rnd Copyright (C) 2018 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: email to pcb-rnd (at) igor2.repo.hu + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" + +#include +#include +#include +#include + +#include "board.h" +#include "data.h" +#include "error.h" +#include "pcb-printf.h" +#include "compat_misc.h" +#include "safe_fs.h" + +#include "actions.h" +#include "plugins.h" +#include "hid.h" + +static const char *fpcb_nl_cookie = "fpcb_nl importer"; + +/* remove leading whitespace */ +#define ltrim(s) while(isspace(*s)) s++ + +/* remove trailing newline */ +#define rtrim(s) \ + do { \ + char *end; \ + for(end = s + strlen(s) - 1; (end >= s) && ((*end == '\r') || (*end == '\n')); end--) \ + *end = '\0'; \ + } while(0) + +static int fpcb_nl_load(const char *fn) +{ + + return -1; +} + +static const char pcb_acts_LoadFpcbnlFrom[] = "LoadFpcbnlFrom(filename)"; +static const char pcb_acth_LoadFpcbnlFrom[] = "Loads the specified freepcb netlist."; +fgw_error_t pcb_act_LoadFpcbnlFrom(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + const char *fname = NULL, *end; + char *fname_asc, *fname_net, *fname_base; + static char *default_file = NULL; + int rs; + + PCB_ACT_MAY_CONVARG(1, FGW_STR, LoadFpcbnlFrom, fname = argv[1].val.str); + + if (!fname || !*fname) { + fname = pcb_gui->fileselect("Load freepcb netlist...", + "Picks a freepcb netlist file to load.\n", + default_file, ".net", "freepcb", HID_FILESELECT_READ); + if (fname == NULL) + return 1; + if (default_file != NULL) { + free(default_file); + default_file = NULL; + } + } + + PCB_ACT_IRES(fpcb_nl_load(fname)); + return 0; +} + +pcb_action_t fpcb_nl_action_list[] = { + {"LoadFpcbnlFrom", pcb_act_LoadFpcbnlFrom, pcb_acth_LoadFpcbnlFrom, pcb_acts_LoadFpcbnlFrom} +}; + +PCB_REGISTER_ACTIONS(fpcb_nl_action_list, fpcb_nl_cookie) + +int pplg_check_ver_import_fpcb_nl(int ver_needed) { return 0; } + +void pplg_uninit_import_fpcb_nl(void) +{ + pcb_remove_actions_by_cookie(fpcb_nl_cookie); +} + +#include "dolists.h" +int pplg_init_import_fpcb_nl(void) +{ + PCB_API_CHK_VER; + PCB_REGISTER_ACTIONS(fpcb_nl_action_list, fpcb_nl_cookie) + return 0; +} Index: import_fpcb_nl.pup =================================================================== --- import_fpcb_nl.pup (nonexistent) +++ import_fpcb_nl.pup (revision 18662) @@ -0,0 +1,9 @@ +$class import +$short import freepcb netlist +$long Import the netlist and footprints from freepcb format (exported by e.g. easyeda) +$state WIP +$fmt-native no +$fmt-feature-r import netlist and footprint names from freepcb netlist +$package import-net +default buildin +autoload 1