Index: work/alien_formats/altium_parser/Makefile =================================================================== --- work/alien_formats/altium_parser/Makefile (nonexistent) +++ work/alien_formats/altium_parser/Makefile (revision 35269) @@ -0,0 +1,3 @@ +CFLAGS = -Wall -g + +main: main.o pcbdoc_ascii.o Index: work/alien_formats/altium_parser/config.h =================================================================== --- work/alien_formats/altium_parser/config.h (nonexistent) +++ work/alien_formats/altium_parser/config.h (revision 35269) @@ -0,0 +1 @@ +/* blank */ Index: work/alien_formats/altium_parser/main.c =================================================================== --- work/alien_formats/altium_parser/main.c (nonexistent) +++ work/alien_formats/altium_parser/main.c (revision 35269) @@ -0,0 +1,22 @@ +#include +#include +#include "pcbdoc_ascii.h" + +int main() +{ + const char *fn = "A.PcbDoc"; + FILE *f; + + f = fopen(fn, "r"); + if (f == NULL) { + fprintf(stderr, "can't open %s for read\n", fn); + return -1; + } + + if (!pcbdoc_ascii_test_parse(NULL, 0, fn, f)) { + fprintf(stderr, "test parse says '%s' is not a PcbDoc\n", fn); + return -1; + } + + return 0; +} \ No newline at end of file Index: work/alien_formats/altium_parser/pcbdoc_ascii.c =================================================================== --- work/alien_formats/altium_parser/pcbdoc_ascii.c (nonexistent) +++ work/alien_formats/altium_parser/pcbdoc_ascii.c (revision 35269) @@ -0,0 +1,55 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * altium pcbdoc ASCII plugin - low level read: parse into a tree in mem + * pcb-rnd Copyright (C) 2021 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: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" + +#include +#include + +#include "pcbdoc_ascii.h" + +int pcbdoc_ascii_test_parse(pcb_plug_io_t *ctx, pcb_plug_iot_t typ, const char *file_name, FILE *f) +{ + char line[256], *s; + + /* first line should comply to the low level file format */ + fgets(line, sizeof(line), f); + + s = line; + if (*s == '|') s++; + + /* every line must start with a RECORD field, the first one too */ + if (strncmp(s,"RECORD=", 7) != 0) + return 0; + + /* there must be a field separator */ + if (strchr(s, '|') == NULL) + return 0; + + return 1; +} Index: work/alien_formats/altium_parser/pcbdoc_ascii.h =================================================================== --- work/alien_formats/altium_parser/pcbdoc_ascii.h (nonexistent) +++ work/alien_formats/altium_parser/pcbdoc_ascii.h (revision 35269) @@ -0,0 +1,4 @@ +#include "plug_io.h" + +int pcbdoc_ascii_test_parse(pcb_plug_io_t *ctx, pcb_plug_iot_t typ, const char *file_name, FILE *f); + Index: work/alien_formats/altium_parser/plug_io.h =================================================================== --- work/alien_formats/altium_parser/plug_io.h (nonexistent) +++ work/alien_formats/altium_parser/plug_io.h (revision 35269) @@ -0,0 +1,7 @@ +typedef struct { + int dummy; +} pcb_plug_io_t; + +typedef enum { + pcb_plug_iot_dummy +} pcb_plug_iot_t;