Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 8884) +++ trunk/scconfig/plugins.h (revision 8885) @@ -87,6 +87,7 @@ plugin_def("io_kicad_legacy", "Kicad's legacy format", sbuildin, 1) plugin_def("io_kicad", "Kicad's s-expr format", sbuildin, 1) plugin_def("io_lihata", "lihata board format", sbuildin, 1) +plugin_def("io_mentor_cell", "Mentor Graphics cell footprints", sdisable, 1) plugin_def("io_pcb", "the original pcb format", sbuildin, 1) plugin_header("\nHID plugins:\n") Index: trunk/src_plugins/io_mentor_cell/Makefile =================================================================== --- trunk/src_plugins/io_mentor_cell/Makefile (nonexistent) +++ trunk/src_plugins/io_mentor_cell/Makefile (revision 8885) @@ -0,0 +1,5 @@ +all: + cd ../../src && $(MAKE) mod_io_mentor_cell + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/io_mentor_cell/Plug.tmpasm =================================================================== --- trunk/src_plugins/io_mentor_cell/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/io_mentor_cell/Plug.tmpasm (revision 8885) @@ -0,0 +1,11 @@ +put /local/pcb/mod {io_mentor_cell} +put /local/pcb/mod/OBJS [@ + $(PLUGDIR)/io_mentor_cell/io_mentor_cell.o + $(PLUGDIR)/io_mentor_cell/read.o +@] + +switch /local/pcb/io_mentor_cell/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/io_mentor_cell/io_mentor_cell.c =================================================================== --- trunk/src_plugins/io_mentor_cell/io_mentor_cell.c (nonexistent) +++ trunk/src_plugins/io_mentor_cell/io_mentor_cell.c (revision 8885) @@ -0,0 +1,82 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2017 Tibor 'Igor2' Palinkas + * + * This module, io_mentor_cell, was written and is Copyright (C) 2016 by Tibor Palinkas + * this module is also subject to the GNU GPL as described below + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "config.h" +#include "plugins.h" +#include "plug_io.h" +#include "write.h" +#include "read.h" +#include "read_net.h" + +static pcb_plug_io_t io_mentor_cell; +static const char *mentor_cell_cookie = "mentor_cell plugin"; + +int io_mentor_cell_fmt(pcb_plug_io_t *ctx, pcb_plug_iot_t typ, int wr, const char *fmt) +{ + if (strcmp(ctx->description, fmt) == 0) + return 200; + + if ((strcmp(fmt, "mentor_cell") != 0) || + ((typ & (~(PCB_IOT_FOOTPRINT | PCB_IOT_BUFFER | PCB_IOT_PCB))) != 0)) + return 0; + + return 100; +} + +int pplg_check_ver_io_mentor_cell(int ver_needed) { return 0; } + +void pplg_uninit_io_mentor_cell(void) +{ + pcb_hid_remove_actions_by_cookie(mentor_cell_cookie); +} + +#include "dolists.h" + +int pplg_init_io_mentor_cell(void) +{ + + /* register the IO hook */ + io_mentor_cell.plugin_data = NULL; + io_mentor_cell.fmt_support_prio = io_mentor_cell_fmt; + io_mentor_cell.test_parse_pcb = io_mentor_cell_test_parse_pcb; + io_mentor_cell.parse_pcb = io_mentor_cell_read_pcb; + io_mentor_cell.parse_element = NULL; + io_mentor_cell.parse_font = NULL; + io_mentor_cell.write_buffer = NULL; + io_mentor_cell.write_element = NULL; + io_mentor_cell.write_pcb = NULL; + io_mentor_cell.default_fmt = "mentor_cell"; + io_mentor_cell.description = "Mentor graphics cell footprint lib"; + io_mentor_cell.save_preference_prio = 60; + io_mentor_cell.default_extension = ".hkp"; + io_mentor_cell.fp_extension = ".hkp"; + io_mentor_cell.mime_type = "application/x-mentor_cell"; + + + PCB_HOOK_REGISTER(pcb_plug_io_t, pcb_plug_io_chain, &io_mentor_cell); + + return 0; +} + Index: trunk/src_plugins/io_mentor_cell/io_mentor_cell.pup =================================================================== --- trunk/src_plugins/io_mentor_cell/io_mentor_cell.pup (nonexistent) +++ trunk/src_plugins/io_mentor_cell/io_mentor_cell.pup (revision 8885) @@ -0,0 +1,7 @@ +$class io +$short Mentor Graphics cell footprints +$long Load Mentor Graphics cell footprint library and make footprints available (e.g. for fp_board) +$state works +default disable + +autoload 1 Index: trunk/src_plugins/io_mentor_cell/read.c =================================================================== --- trunk/src_plugins/io_mentor_cell/read.c (nonexistent) +++ trunk/src_plugins/io_mentor_cell/read.c (revision 8885) @@ -0,0 +1,65 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2017 Tibor 'Igor2' Palinkas + * + * This module, io_mentor_cell, was written and is Copyright (C) 2016 by Tibor Palinkas + * this module is also subject to the GNU GPL as described below + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +typedef struct { + FILE *f; + pcb_board_t *pcb +} hkp_ctx_t; + +int io_mentor_cell_read_pcb(pcb_plug_io_t *ctx, pcb_board_t *pcb, const char *fn, conf_role_t settings_dest) +{ + hkp_ctx_t ctx; + + ctx.pcb = pcb; + ctx.f = fopen(fn, "r"); + if (ctx.f == NULL) + goto err; + + + err:; + fclose(ctx.f); + return -1; +} + +int io_mentor_cell_test_parse_pcb(pcb_plug_io_t *ctx, pcb_board_t *Ptr, const char *Filename, FILE *f) +{ + char line[1024], *s; + + while(!(feof(f))) { + if (fgets(line, sizeof(line), f) != NULL) { + s = line; + while(isspace(*s)) s++; /* strip leading whitespace */ + if (strncmp(s, ".FILETYPE CELL_LIBRARY", 22) == 0) /* valid root */ + return 1; + if ((*s == '\r') || (*s == '\n') || (*s == '\0')) /* ignore empty lines and comments */ + continue; + /* non-comment, non-empty line - and we don't have our root -> it's not an s-expression */ + return 0; + } + } + + /* hit eof before seeing a valid root -> bad */ + return 0; +} Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 8884) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 8885) @@ -54,6 +54,7 @@ include {../src_plugins/io_kicad/Plug.tmpasm} include {../src_plugins/io_kicad_legacy/Plug.tmpasm} include {../src_plugins/io_lihata/Plug.tmpasm} +include {../src_plugins/io_mentor_cell/Plug.tmpasm} include {../src_plugins/io_pcb/Plug.tmpasm} include {../src_plugins/io_tedax/Plug.tmpasm} include {../src_plugins/jostle/Plug.tmpasm}