Index: scconfig/plugins.h =================================================================== --- scconfig/plugins.h (revision 6841) +++ scconfig/plugins.h (revision 6842) @@ -66,7 +66,8 @@ plugin_def("export_dsn", "specctra .dsn pcb_exporter", sbuildin, 1) plugin_def("export_ipcd356", "IPC-D-356 Netlist pcb_exporter",sdisable, 0) plugin_def("export_svg", "SVG pcb_exporter", sbuildin, 1) -plugin_def("export_stat", "exporter board statistics", sbuildin, 1) +plugin_def("export_stat", "export board statistics", sbuildin, 1) +plugin_def("export_fidocadj", "FidoCadJ .fcd pcb_exporter ", sdisable, 0) plugin_header("\nIO plugins (file formats):\n") plugin_def("io_lihata", "lihata board format", sbuildin, 1) Index: src_plugins/export_fidocadj/Makefile =================================================================== --- src_plugins/export_fidocadj/Makefile (nonexistent) +++ src_plugins/export_fidocadj/Makefile (revision 6842) @@ -0,0 +1,5 @@ +all: + cd ../../src && $(MAKE) mod_export_fidocadj + +clean: + rm *.o *.so 2>/dev/null ; true Index: src_plugins/export_fidocadj/Plug.tmpasm =================================================================== --- src_plugins/export_fidocadj/Plug.tmpasm (nonexistent) +++ src_plugins/export_fidocadj/Plug.tmpasm (revision 6842) @@ -0,0 +1,16 @@ +put /local/pcb/mod {export_fidocadj} +put /local/pcb/mod/OBJS [@ $(PLUGDIR)/export_fidocadj/fidocadj.o @] + +switch /local/pcb/export_fidocadj/controls + case {disable} end; + default + put /local/pcb/mod/LDFLAGS libs/gui/gd/ldflags + put /local/pcb/mod/CFLAGS libs/gui/gd/cflags + end +end + +switch /local/pcb/export_fidocadj/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: src_plugins/export_fidocadj/README =================================================================== --- src_plugins/export_fidocadj/README (nonexistent) +++ src_plugins/export_fidocadj/README (revision 6842) @@ -0,0 +1,5 @@ +Export to FidoCadJ format (.fcd) + +#state: WIP +#default: disable +#implements: export Index: src_plugins/export_fidocadj/fidocadj.c =================================================================== --- src_plugins/export_fidocadj/fidocadj.c (nonexistent) +++ src_plugins/export_fidocadj/fidocadj.c (revision 6842) @@ -0,0 +1,153 @@ + /* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2017 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* + * Based on the png exporter by Dan McMahill + */ + +#include "config.h" +#include "conf_core.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "math_helper.h" +#include "board.h" +#include "data.h" +#include "plugins.h" +#include "pcb-printf.h" +#include "compat_misc.h" +#include "plug_io.h" + +#include "hid.h" +#include "hid_nogui.h" +#include "hid_draw_helpers.h" + +#include "hid_init.h" +#include "hid_attrib.h" +#include "hid_color.h" +#include "hid_helper.h" +#include "hid_flags.h" + + +static pcb_hid_t fidocadj_hid; + +const char *fidocadj_cookie = "fidocadj HID"; + +pcb_hid_attribute_t fidocadj_attribute_list[] = { + /* other HIDs expect this to be first. */ + + {"outfile", "Output file name", + HID_String, 0, 0, {0, 0, 0}, 0, 0}, +#define HA_fidocadjfile 0 +}; + +#define NUM_OPTIONS (sizeof(fidocadj_attribute_list)/sizeof(fidocadj_attribute_list[0])) + +PCB_REGISTER_ATTRIBUTES(fidocadj_attribute_list, fidocadj_cookie) + +static pcb_hid_attr_val_t fidocadj_values[NUM_OPTIONS]; + +static pcb_hid_attribute_t *fidocadj_get_export_options(int *n) +{ + static char *last_made_filename = 0; + const char *suffix = ".fcd"; + + if (PCB) + pcb_derive_default_filename(PCB->Filename, &fidocadj_attribute_list[HA_fidocadjfile], suffix, &last_made_filename); + + if (n) + *n = NUM_OPTIONS; + return fidocadj_attribute_list; +} + +static void fidocadj_do_export(pcb_hid_attr_val_t * options) +{ + FILE *f; + const char *filename; + int n; + + if (!options) { + fidocadj_get_export_options(0); + for (n = 0; n < NUM_OPTIONS; n++) + fidocadj_values[n] = fidocadj_attribute_list[n].default_val; + options = fidocadj_values; + } + + filename = options[HA_fidocadjfile].str_value; + if (!filename) + filename = "pcb-rnd-default.fcd"; + + f = fopen(filename, "w"); + if (!f) { + perror(filename); + return; + } + + fprintf(f, "[FIDOCAD]\n"); + + fclose(f); +} + +static void fidocadj_parse_arguments(int *argc, char ***argv) +{ + pcb_hid_register_attributes(fidocadj_attribute_list, sizeof(fidocadj_attribute_list) / sizeof(fidocadj_attribute_list[0]), fidocadj_cookie, 0); + pcb_hid_parse_command_line(argc, argv); +} + +static int fidocadj_usage(const char *topic) +{ + fprintf(stderr, "\nfidocadj exporter command line arguments:\n\n"); + pcb_hid_usage(fidocadj_attribute_list, sizeof(fidocadj_attribute_list) / sizeof(fidocadj_attribute_list[0])); + fprintf(stderr, "\nUsage: pcb-rnd [generic_options] -x fidocadj foo.pcb [fidocadj options]\n\n"); + return 0; +} + +#include "dolists.h" + +pcb_uninit_t hid_export_fidocadj_init() +{ + memset(&fidocadj_hid, 0, sizeof(pcb_hid_t)); + + pcb_hid_nogui_init(&fidocadj_hid); + pcb_dhlp_draw_helpers_init(&fidocadj_hid); + + fidocadj_hid.struct_size = sizeof(pcb_hid_t); + fidocadj_hid.name = "fidocadj"; + fidocadj_hid.description = "export board in FidoCadJ .fcd format"; + fidocadj_hid.exporter = 1; + + fidocadj_hid.get_export_options = fidocadj_get_export_options; + fidocadj_hid.do_export = fidocadj_do_export; + fidocadj_hid.parse_arguments = fidocadj_parse_arguments; + + fidocadj_hid.usage = fidocadj_usage; + + pcb_hid_register_hid(&fidocadj_hid); + + return NULL; +} Index: src_plugins/plugins_io.tmpasm =================================================================== --- src_plugins/plugins_io.tmpasm (revision 6841) +++ src_plugins/plugins_io.tmpasm (revision 6842) @@ -25,6 +25,7 @@ include {../src_plugins/export_ipcd356/Plug.tmpasm} include {../src_plugins/export_svg/Plug.tmpasm} include {../src_plugins/export_stat/Plug.tmpasm} +include {../src_plugins/export_fidocadj/Plug.tmpasm} include {../src_plugins/hid_batch/Plug.tmpasm} include {../src_plugins/hid_gtk/Plug.tmpasm}