File: io_pcb.c

package info (click to toggle)
pcb-rnd 3.1.7b-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,108 kB
  • sloc: ansic: 213,400; yacc: 6,241; sh: 4,698; awk: 3,016; makefile: 2,254; lex: 1,166; python: 519; xml: 261; lisp: 154; tcl: 67; perl: 34; javascript: 6; ruby: 5
file content (128 lines) | stat: -rw-r--r-- 4,543 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 *                            COPYRIGHT
 *
 *  pcb-rnd, interactive printed circuit board design
 *  Copyright (C) 2016 Tibor 'Igor2' Palinkas
 *
 *  This module, io_pcb, 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., 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 <librnd/core/plugins.h>
#include "parse_common.h"
#include "file.h"

static pcb_plug_io_t io_pcb[3];
static io_pcb_ctx_t ctx[3];

pcb_plug_io_t *pcb_preferred_io_pcb, *pcb_nanometer_io_pcb, *pcb_centimil_io_pcb;

int io_pcb_fmt(pcb_plug_io_t *ctx, pcb_plug_iot_t typ, int wr, const char *fmt)
{
	if (strcmp(ctx->description, fmt) == 0)
		return 200;

	/* All types are supported. */
	if (strcmp(fmt, "pcb") != 0)
		return 0;
	return 100; /* read-write */
}

extern void pcb_lex_destroy(void);
int pplg_check_ver_io_pcb(int ver_needed) { return 0; }

void pplg_uninit_io_pcb(void)
{
	int n;
	pcb_lex_destroy();

	for(n = 0; n < 3; n++)
		RND_HOOK_UNREGISTER(pcb_plug_io_t, pcb_plug_io_chain, &(io_pcb[n]));
}

int pplg_init_io_pcb(void)
{
	RND_API_CHK_VER;

	memset(&io_pcb, 0, sizeof(io_pcb));

	/* register the IO hook */
	ctx[0].write_coord_fmt = rnd_printf_slot[8];
	io_pcb[0].plugin_data = &ctx[0];
	io_pcb[0].fmt_support_prio = io_pcb_fmt;
	io_pcb[0].test_parse = io_pcb_test_parse;
	io_pcb[0].parse_pcb = io_pcb_ParsePCB;
	io_pcb[0].parse_footprint = io_pcb_ParseElement;
	io_pcb[0].map_footprint = io_pcb_map_footprint; /* it is enough to have this in [0] so the same checks are not done multiple times, per version */
	io_pcb[0].parse_font = io_pcb_ParseFont;
	io_pcb[0].write_buffer = NULL;
	io_pcb[0].write_subcs_head = io_pcb_write_subcs_head;
	io_pcb[0].write_subcs_subc = io_pcb_write_subcs_subc;
	io_pcb[0].write_subcs_tail = io_pcb_write_subcs_tail;
	io_pcb[0].write_pcb = io_pcb_WritePCB;
	io_pcb[0].default_fmt = "pcb";
	io_pcb[0].description = "geda/pcb - mainline (centimils)";
	io_pcb[0].save_preference_prio = 89;
	io_pcb[0].default_extension = ".pcb";
	io_pcb[0].fp_extension = ".fp";
	io_pcb[0].mime_type = "application/x-pcb-layout";
	RND_HOOK_REGISTER(pcb_plug_io_t, pcb_plug_io_chain, &(io_pcb[0]));
	pcb_centimil_io_pcb = &io_pcb[0];

	ctx[1].write_coord_fmt = rnd_printf_slot[9];
	io_pcb[1].plugin_data = &ctx[1];
	io_pcb[1].fmt_support_prio = io_pcb_fmt;
	io_pcb[1].write_buffer = NULL;
	io_pcb[1].write_subcs_head = io_pcb_write_subcs_head;
	io_pcb[1].write_subcs_subc = io_pcb_write_subcs_subc;
	io_pcb[1].write_subcs_tail = io_pcb_write_subcs_tail;
	io_pcb[1].write_pcb = io_pcb_WritePCB;
	io_pcb[1].default_fmt = "pcb";
	io_pcb[1].description = "geda/pcb - readable units";
	io_pcb[1].save_preference_prio = 90;
	io_pcb[1].default_extension = ".pcb";
	io_pcb[1].fp_extension = ".fp";
	io_pcb[1].mime_type = "application/x-pcb-layout";
	RND_HOOK_REGISTER(pcb_plug_io_t, pcb_plug_io_chain, &(io_pcb[1]));
	pcb_preferred_io_pcb = &io_pcb[1];

	ctx[2].write_coord_fmt = "%$$mn";
	io_pcb[2].plugin_data = &ctx[2];
	io_pcb[2].fmt_support_prio = io_pcb_fmt;
	io_pcb[2].write_buffer = NULL;
	io_pcb[2].write_subcs_head = io_pcb_write_subcs_head;
	io_pcb[2].write_subcs_subc = io_pcb_write_subcs_subc;
	io_pcb[2].write_subcs_tail = io_pcb_write_subcs_tail;
	io_pcb[2].write_pcb = io_pcb_WritePCB;
	io_pcb[2].default_fmt = "pcb";
	io_pcb[2].description = "geda/pcb - nanometer";
	io_pcb[2].save_preference_prio = 88;
	io_pcb[2].default_extension = ".pcb";
	io_pcb[2].fp_extension = ".fp";
	io_pcb[2].mime_type = "application/x-pcb-layout";
	RND_HOOK_REGISTER(pcb_plug_io_t, pcb_plug_io_chain, &(io_pcb[2]));
	pcb_nanometer_io_pcb = &io_pcb[2];


	return 0;
}