Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 3827) +++ trunk/scconfig/Rev.h (revision 3828) @@ -1 +1 @@ -static const int myrev = 3699; +static const int myrev = 3828; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 3827) +++ trunk/scconfig/Rev.tab (revision 3828) @@ -1,3 +1,4 @@ +3828 configure centralzie local lib support into libcschem 3699 configure expotr_lpr plugin for printing 3696 configure remove export_animator (it was used for debugging before the official export plugins arrived) 3675 configure upgrade export plugins for better layer visibility control Index: trunk/src/libcschem/Makefile.in =================================================================== --- trunk/src/libcschem/Makefile.in (revision 3827) +++ trunk/src/libcschem/Makefile.in (revision 3828) @@ -47,6 +47,7 @@ util_export.o util_grp.o util_lib_fs.o + util_loclib.o util_parse.o util_wirenet.o vtcoutline.o Index: trunk/src/libcschem/util_loclib.c =================================================================== --- trunk/src/libcschem/util_loclib.c (nonexistent) +++ trunk/src/libcschem/util_loclib.c (revision 3828) @@ -0,0 +1,60 @@ +/* + * COPYRIGHT + * + * cschem - modular/flexible schematics editor - libcschem (core library) + * Copyright (C) 2022 Tibor 'Igor2' Palinkas + * + * (Supported by NLnet NGI0 PET Fund in 2022) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version.* + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; 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/cschem + * lead developer: email to cschem (at) igor2.repo.hu + * mailing list: cschem (at) list.repo.hu (send "subscribe") + */ + +/* Utility functions for maintaining a local (per sheet) library */ + +#include "config.h" + +#include +#include + +#include "util_loclib.h" + +csch_cgrp_t *csch_loclib_get_root(csch_sheet_t *sheet, const char *purpose, csch_source_arg_t *src, int alloc, int *alloced) +{ + htip_entry_t *e; + + if (alloc) + *alloced = 0; + + for(e = htip_first(&sheet->indirect.id2obj); e != NULL; e = htip_next(&sheet->indirect.id2obj, e)) { + csch_cgrp_t *grp = e->value; + const char *gpurp = csch_attrib_get_str(&grp->attr, "purpose"); + if ((gpurp != NULL) && (strcmp(gpurp, purpose) == 0)) + return grp; + } + + if (alloc) { + csch_cgrp_t *grp = csch_cgrp_alloc(sheet, &sheet->indirect, csch_oid_new(sheet, &sheet->indirect)); + csch_attrib_set(&grp->attr, 0, "purpose", "symlib", *src, NULL); + *alloced = 1; + return grp; + } + + return NULL; +} Index: trunk/src/libcschem/util_loclib.h =================================================================== --- trunk/src/libcschem/util_loclib.h (nonexistent) +++ trunk/src/libcschem/util_loclib.h (revision 3828) @@ -0,0 +1,37 @@ +/* + * COPYRIGHT + * + * cschem - modular/flexible schematics editor - libcschem (core library) + * Copyright (C) 2022 Tibor 'Igor2' Palinkas + * + * (Supported by NLnet NGI0 PET Fund in 2022) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version.* + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; 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/cschem + * lead developer: email to cschem (at) igor2.repo.hu + * mailing list: cschem (at) list.repo.hu (send "subscribe") + */ + +/* Utility functions for maintaining a local (per sheet) library */ + +#include + +/* Return the group whose purpose matches purpose from under sheet's + indirect group. If alloc is 1, and the group does not exist, it is + created using src and *alloced is set to 1. */ +csch_cgrp_t *csch_loclib_get_root(csch_sheet_t *sheet, const char *purpose, csch_source_arg_t *src, int alloc, int *alloced); + Index: trunk/src/plugins/std_devmap/std_devmap.c =================================================================== --- trunk/src/plugins/std_devmap/std_devmap.c (revision 3827) +++ trunk/src/plugins/std_devmap/std_devmap.c (revision 3828) @@ -194,6 +194,7 @@ void devmap_set_sym_loclib(csch_sheet_t *sheet, const char *devmap_name, csch_attribs_t *dma) { + } /* Look up and return component attributes for the component's devmap name: Index: trunk/src/plugins/symlib_local/symlib_local.c =================================================================== --- trunk/src/plugins/symlib_local/symlib_local.c (revision 3827) +++ trunk/src/plugins/symlib_local/symlib_local.c (revision 3828) @@ -126,28 +126,17 @@ static csch_cgrp_t *get_sheet_local_symlib(csch_sheet_t *sheet, csch_lib_t *root_dir, int alloc) { - htip_entry_t *e; - for(e = htip_first(&sheet->indirect.id2obj); e != NULL; e = htip_next(&sheet->indirect.id2obj, e)) { - csch_cgrp_t *grp = e->value; - const char *purp = csch_attrib_get_str(&grp->attr, "purpose"); - if ((purp != NULL) && (strcmp(purp, "symlib") == 0)) - return grp; - } + static const csch_source_arg_t src = {'p', "symlib_local", NULL}; + int alloced = 0; + csch_cgrp_t *grp = csch_loclib_get_root(sheet, "symlib", &src, 1, &alloced); - if (alloc) { - csch_cgrp_t *grp = csch_cgrp_alloc(sheet, &sheet->indirect, csch_oid_new(sheet, &sheet->indirect)); - static const csch_source_arg_t src = {'p', "symlib_local", NULL}; - csch_attrib_set(&grp->attr, 0, "purpose", "symlib", src, NULL); - + if (alloced) { symlib_local_sheet_init(&sheet->hidlib, root_dir, grp); symlib_local_map_local_(&sheet->hidlib, root_dir, grp); - - return grp; } - - return NULL; } + static int symlib_local_map_local(rnd_hidlib_t *hl, csch_lib_t *root_dir, const csch_cgrp_t *indirect) { csch_cgrp_t *grp = get_sheet_local_symlib((csch_sheet_t *)hl, root_dir, 0);