Index: io_kicad.c =================================================================== --- io_kicad.c (revision 29507) +++ io_kicad.c (revision 29508) @@ -61,6 +61,7 @@ /* Runs once when the plugin is unloaded. TODO: free plugin-globals here. */ pcb_remove_actions_by_cookie(kicad_cookie); PCB_HOOK_UNREGISTER(pcb_plug_io_t, pcb_plug_io_chain, &io_kicad); + pcb_eeschema_uninit(); } int pplg_init_io_kicad(void) @@ -91,6 +92,8 @@ PCB_REGISTER_ACTIONS(eeschema_action_list, kicad_cookie); + pcb_eeschema_init(); + /* TODO: Alloc plugin-globals here. */ return 0; Index: read_net.c =================================================================== --- read_net.c (revision 29507) +++ read_net.c (revision 29508) @@ -36,6 +36,7 @@ #include "board.h" #include "data.h" +#include "plug_import.h" #include #include #include @@ -238,3 +239,43 @@ return 0; } + +static int eeschema_support_prio(pcb_plug_import_t *ctx, unsigned int aspects, FILE *fp, const char *filename) +{ + if (aspects != IMPORT_ASPECT_NETLIST) + return 0; /* only pure netlist import is supported */ + return 20; +} + + +static int eeschema_import(pcb_plug_import_t *ctx, unsigned int aspects, const char **fns, int numfns) +{ + if (numfns != 1) { + pcb_message(PCB_MSG_ERROR, "import_eeschema: requires exactly 1 input file name\n"); + return -1; + } + return eeschema_load(fns[0]); +} + +static pcb_plug_import_t import_eeschema; + +void pcb_eeschema_uninit(void) +{ + PCB_HOOK_UNREGISTER(pcb_plug_import_t, pcb_plug_import_chain, &import_eeschema); +} + +void pcb_eeschema_init(void) +{ + /* register the IO hook */ + import_eeschema.plugin_data = NULL; + + import_eeschema.fmt_support_prio = eeschema_support_prio; + import_eeschema.import = eeschema_import; + import_eeschema.name = "KiCAD/eeschema"; + import_eeschema.desc = "schamtics from KiCAD's eeschema"; + import_eeschema.single_arg = 1; + import_eeschema.all_filenames = 1; + import_eeschema.ext_exec = 0; + + PCB_HOOK_REGISTER(pcb_plug_import_t, pcb_plug_import_chain, &import_eeschema); +} Index: read_net.h =================================================================== --- read_net.h (revision 29507) +++ read_net.h (revision 29508) @@ -5,3 +5,7 @@ extern const char pcb_acth_LoadeeschemaFrom[]; fgw_error_t pcb_act_LoadeeschemaFrom(fgw_arg_t *ores, int oargc, fgw_arg_t *oargv); + +void pcb_eeschema_init(void); +void pcb_eeschema_uninit(void); +