Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 34062) +++ trunk/scconfig/Rev.h (revision 34063) @@ -1 +1 @@ -static const int myrev = 33963; +static const int myrev = 34063; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 34062) +++ trunk/scconfig/Rev.tab (revision 34063) @@ -1,3 +1,4 @@ +34063 configure new infrastructure: anyload 33963 configure new plugin: low level pcb-rnd C code draw 33845 configure librnd separation: link librnd with -l 33689 configure new plugin: io_pads Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 34062) +++ trunk/src/Makefile.in (revision 34063) @@ -28,6 +28,7 @@ append /local/pcb/OBJS /local/pcb/OBJS_3RDLIB append /local/pcb/OBJS [@ actions_pcb.o + anyload.o attrib.o board.o brave.o Index: trunk/src/anyload.c =================================================================== --- trunk/src/anyload.c (nonexistent) +++ trunk/src/anyload.c (revision 34063) @@ -0,0 +1,95 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * 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 + +#include "anyload.h" + +typedef struct { + const pcb_anyload_t *al; + re_se_t *rx; + const char *rx_str; + gdl_elem_t link; +} pcb_aload_t; + +static gdl_list_t anyloads; + +int pcb_anyload_reg(const char *root_regex, const pcb_anyload_t *al_in) +{ + re_se_t *rx; + pcb_aload_t *al; + + rx = re_se_comp(root_regex); + if (rx == NULL) { + rnd_message(RND_MSG_ERROR, "pcb_anyload_reg: failed to compile regex '%s' for '%s'\n", root_regex, al_in->cookie); + return -1; + } + + al = calloc(sizeof(pcb_aload_t), 1); + al->al = al_in; + al->rx = rx; + al->rx_str = root_regex; + + gdl_append(&anyloads, al, link); + + return 0; +} + +static void pcb_anyload_free(pcb_aload_t *al) +{ + gdl_remove(&anyloads, al, link); + re_se_free(al->rx); + free(al); +} + +void pcb_anyload_unreg_by_cookie(const char *cookie) +{ + pcb_aload_t *al, *next; + for(al = gdl_first(&anyloads); al != NULL; al = next) { + next = al->link.next; + if (al->al->cookie == cookie) + pcb_anyload_free(al); + } +} + +void pcb_anyload_uninit(void) +{ + pcb_aload_t *al; + while((al = gdl_first(&anyloads)) != NULL) { + rnd_message(RND_MSG_ERROR, "pcb_anyload: '%s' left anyloader regs in\n", al->al->cookie); + pcb_anyload_free(al); + } +} + +void pcb_anyload_init2(void) +{ + +} + Index: trunk/src/anyload.h =================================================================== --- trunk/src/anyload.h (nonexistent) +++ trunk/src/anyload.h (revision 34063) @@ -0,0 +1,43 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * 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 +#include + +#include "board.h" + +typedef struct pcb_anyload_s pcb_anyload_t; + +struct pcb_anyload_s { + int (*load_subtree)(pcb_anyload_t *al, pcb_board_t *pcb, lht_node_t *root, rnd_conf_role_t install); + int (*load_file)(pcb_anyload_t *al, pcb_board_t *pcb, const char *filename, const char *type, rnd_conf_role_t install); + const char *cookie; +}; + + +int pcb_anyload_reg(const char *root_regex, const pcb_anyload_t *al); +void pcb_anyload_unreg_by_cookie(const char *cookie); + Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 34062) +++ trunk/src/main.c (revision 34063) @@ -298,6 +298,8 @@ extern void pcb_undo_act_init2(void); extern void pcb_draw_init(void); extern void pcb_draw_uninit(void); +extern void pcb_anyload_uninit(void); +extern void pcb_anyload_init2(void); void pcb_main_init_actions(void) { @@ -321,6 +323,7 @@ pcb_remove_act_init2(); pcb_select_act_init2(); pcb_undo_act_init2(); + pcb_anyload_init2(); } extern void pcb_poly_uninit(void); @@ -331,6 +334,8 @@ rnd_log_last->seen = 1; /* ignore anything unseen before the uninit */ conf_core_uninit_pre(); + + pcb_anyload_uninit(); pcb_draw_uninit(); pcb_brave_uninit(); pcb_polygon_uninit();