Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 24270) +++ trunk/scconfig/Rev.h (revision 24271) @@ -1 +1 @@ -static const int myrev = 23917; +static const int myrev = 24271; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 24270) +++ trunk/scconfig/Rev.tab (revision 24271) @@ -1,3 +1,4 @@ +24271 configure preparing for hidlib, splitting source files 23917 configure compound DAD widgets, for DAD based spinboxes 23902 configure cleanup: remove dead code from gtk 23857 configure new, centralized log dialog Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 24270) +++ trunk/src/Makefile.in (revision 24271) @@ -69,6 +69,7 @@ compat_misc.o error.o event.o + file_loaded.o hid_attrib.o hid_cfg.o hid_cfg_action.o Index: trunk/src/build_run.c =================================================================== --- trunk/src/build_run.c (revision 24270) +++ trunk/src/build_run.c (revision 24271) @@ -30,7 +30,6 @@ #include "config.h" #include -#include #include #include "conf_core.h" #include "board.h" @@ -256,129 +255,3 @@ pcb_message(PCB_MSG_ERROR, "aborted by %s signal\n", s); exit(1); } - - -/*** files loaded ***/ - -htsp_t pcb_file_loaded; - - -pcb_file_loaded_t *pcb_file_loaded_category(const char *name, int alloc) -{ - pcb_file_loaded_t *cat = htsp_get(&pcb_file_loaded, name); - - if ((cat == NULL) && (alloc)) { - cat = calloc(sizeof(pcb_file_loaded_t), 1); - cat->type = PCB_FLT_CATEGORY; - cat->name = pcb_strdup(name); - htsp_init(&cat->data.category.children, strhash, strkeyeq); - htsp_set(&pcb_file_loaded, cat->name, cat); - } - return cat; -} - -int pcb_file_loaded_file_free(pcb_file_loaded_t *file) -{ - free(file->data.file.path); - free(file->data.file.desc); - free(file->name); - free(file); - return 0; -} - -int pcb_file_loaded_clear(pcb_file_loaded_t *cat) -{ - htsp_entry_t *e; - - assert(cat->type == PCB_FLT_CATEGORY); - - for (e = htsp_first(&cat->data.category.children); e; e = htsp_next(&cat->data.category.children, e)) { - pcb_file_loaded_file_free(e->value); - htsp_delentry(&cat->data.category.children, e); - } - return 0; -} - -int pcb_file_loaded_clear_at(const char *catname) -{ - pcb_file_loaded_t *cat = pcb_file_loaded_category(catname, 0); - if (cat != NULL) - return pcb_file_loaded_clear(cat); - return 0; -} - -int pcb_file_loaded_set(pcb_file_loaded_t *cat, const char *name, const char *path, const char *desc) -{ - pcb_file_loaded_t *file; - - assert(cat->type == PCB_FLT_CATEGORY); - file = htsp_get(&cat->data.category.children, name); - if (file != NULL) { - free(file->data.file.path); - free(file->data.file.desc); - } - else { - file = malloc(sizeof(pcb_file_loaded_t)); - file->type = PCB_FLT_FILE; - file->name = pcb_strdup(name); - htsp_set(&cat->data.category.children, file->name, file); - } - if (path != NULL) - file->data.file.path = pcb_strdup(path); - else - file->data.file.path = NULL; - - if (desc != NULL) - file->data.file.desc = pcb_strdup(desc); - else - file->data.file.desc = NULL; - return 0; -} - -int pcb_file_loaded_set_at(const char *catnam, const char *name, const char *path, const char *desc) -{ - pcb_file_loaded_t *cat = pcb_file_loaded_category(catnam, 1); - return pcb_file_loaded_set(cat, name, path, desc); -} - -int pcb_file_loaded_del(pcb_file_loaded_t *cat, const char *name) -{ - pcb_file_loaded_t *file; - assert(cat->type == PCB_FLT_CATEGORY); - file = htsp_pop(&cat->data.category.children, name); - if (file != NULL) { - if (file->type != PCB_FLT_FILE) - return -1; - pcb_file_loaded_file_free(file); - } - return 0; -} - -int pcb_file_loaded_del_at(const char *catname, const char *name) -{ - pcb_file_loaded_t *cat = pcb_file_loaded_category(catname, 1); - return pcb_file_loaded_del(cat, name); -} - -void pcb_file_loaded_init(void) -{ - htsp_init(&pcb_file_loaded, strhash, strkeyeq); -} - -void pcb_file_loaded_uninit(void) -{ - htsp_entry_t *e; - - for (e = htsp_first(&pcb_file_loaded); e; e = htsp_next(&pcb_file_loaded, e)) { - pcb_file_loaded_t *cat = e->value; - pcb_file_loaded_clear(cat); - free(cat->name); - htsp_uninit(&cat->data.category.children); - free(cat); - htsp_delentry(&pcb_file_loaded, e); - } - - htsp_uninit(&pcb_file_loaded); -} - - Index: trunk/src/build_run.h =================================================================== --- trunk/src/build_run.h (revision 24270) +++ trunk/src/build_run.h (revision 24271) @@ -29,8 +29,6 @@ #ifndef PCB_BUILD_RUN_H #define PCB_BUILD_RUN_H -#include - void pcb_quit_app(void); /* Returns a string that has a bunch of information about this program. */ @@ -57,54 +55,4 @@ void pcb_catch_signal(int Signal); - - -/*** info on where files are loaded from ***/ - -/* Hash-in-hash tree with the top tree being categories. */ - -typedef enum pcb_file_loaded_type_e { - PCB_FLT_CATEGORY, - PCB_FLT_FILE -} pcb_file_loaded_type_t; - -typedef struct pcb_file_loaded_s pcb_file_loaded_t; - -struct pcb_file_loaded_s { - char *name; /* same as the hash key; strdup'd */ - pcb_file_loaded_type_t type; - union { - struct { - htsp_t children; - } category; - struct { - char *path; - char *desc; - } file; - } data; -}; - -extern htsp_t pcb_file_loaded; - -/* Return the category called name; if doesn't exist and alloc is 1, - allocate it it (else return NULL) */ -pcb_file_loaded_t *pcb_file_loaded_category(const char *name, int alloc); - -/* clear the subtree of a category, keeping the category; return 0 on success */ -int pcb_file_loaded_clear(pcb_file_loaded_t *cat); -int pcb_file_loaded_clear_at(const char *catname); - -/* clear the subtree of a category, keeping the category; return 0 on success */ -int pcb_file_loaded_set(pcb_file_loaded_t *cat, const char *name, const char *path, const char *desc); -int pcb_file_loaded_set_at(const char *catname, const char *name, const char *path, const char *desc); - -/* remove an entry */ -int pcb_file_loaded_del(pcb_file_loaded_t *cat, const char *name); -int pcb_file_loaded_del_at(const char *catname, const char *name); - - -/* called once, from main */ -void pcb_file_loaded_init(void); -void pcb_file_loaded_uninit(void); - #endif Index: trunk/src/conf.c =================================================================== --- trunk/src/conf.c (revision 24270) +++ trunk/src/conf.c (revision 24271) @@ -42,7 +42,7 @@ #include "compat_fs.h" #include "compat_misc.h" #include "safe_fs.h" -#include "build_run.h" +#include "file_loaded.h" #define CONF_USER_DIR "~/" DOT_PCB_RND Index: trunk/src/file_loaded.c =================================================================== --- trunk/src/file_loaded.c (nonexistent) +++ trunk/src/file_loaded.c (revision 24271) @@ -0,0 +1,155 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * (this file is based on PCB, interactive printed circuit board design) + * pcb-rnd Copyright (C) 2018 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 "file_loaded.h" +#include "compat_misc.h" + +htsp_t pcb_file_loaded; + +pcb_file_loaded_t *pcb_file_loaded_category(const char *name, int alloc) +{ + pcb_file_loaded_t *cat = htsp_get(&pcb_file_loaded, name); + + if ((cat == NULL) && (alloc)) { + cat = calloc(sizeof(pcb_file_loaded_t), 1); + cat->type = PCB_FLT_CATEGORY; + cat->name = pcb_strdup(name); + htsp_init(&cat->data.category.children, strhash, strkeyeq); + htsp_set(&pcb_file_loaded, cat->name, cat); + } + return cat; +} + +int pcb_file_loaded_file_free(pcb_file_loaded_t *file) +{ + free(file->data.file.path); + free(file->data.file.desc); + free(file->name); + free(file); + return 0; +} + +int pcb_file_loaded_clear(pcb_file_loaded_t *cat) +{ + htsp_entry_t *e; + + assert(cat->type == PCB_FLT_CATEGORY); + + for (e = htsp_first(&cat->data.category.children); e; e = htsp_next(&cat->data.category.children, e)) { + pcb_file_loaded_file_free(e->value); + htsp_delentry(&cat->data.category.children, e); + } + return 0; +} + +int pcb_file_loaded_clear_at(const char *catname) +{ + pcb_file_loaded_t *cat = pcb_file_loaded_category(catname, 0); + if (cat != NULL) + return pcb_file_loaded_clear(cat); + return 0; +} + +int pcb_file_loaded_set(pcb_file_loaded_t *cat, const char *name, const char *path, const char *desc) +{ + pcb_file_loaded_t *file; + + assert(cat->type == PCB_FLT_CATEGORY); + file = htsp_get(&cat->data.category.children, name); + if (file != NULL) { + free(file->data.file.path); + free(file->data.file.desc); + } + else { + file = malloc(sizeof(pcb_file_loaded_t)); + file->type = PCB_FLT_FILE; + file->name = pcb_strdup(name); + htsp_set(&cat->data.category.children, file->name, file); + } + if (path != NULL) + file->data.file.path = pcb_strdup(path); + else + file->data.file.path = NULL; + + if (desc != NULL) + file->data.file.desc = pcb_strdup(desc); + else + file->data.file.desc = NULL; + return 0; +} + +int pcb_file_loaded_set_at(const char *catnam, const char *name, const char *path, const char *desc) +{ + pcb_file_loaded_t *cat = pcb_file_loaded_category(catnam, 1); + return pcb_file_loaded_set(cat, name, path, desc); +} + +int pcb_file_loaded_del(pcb_file_loaded_t *cat, const char *name) +{ + pcb_file_loaded_t *file; + assert(cat->type == PCB_FLT_CATEGORY); + file = htsp_pop(&cat->data.category.children, name); + if (file != NULL) { + if (file->type != PCB_FLT_FILE) + return -1; + pcb_file_loaded_file_free(file); + } + return 0; +} + +int pcb_file_loaded_del_at(const char *catname, const char *name) +{ + pcb_file_loaded_t *cat = pcb_file_loaded_category(catname, 1); + return pcb_file_loaded_del(cat, name); +} + +void pcb_file_loaded_init(void) +{ + htsp_init(&pcb_file_loaded, strhash, strkeyeq); +} + +void pcb_file_loaded_uninit(void) +{ + htsp_entry_t *e; + + for (e = htsp_first(&pcb_file_loaded); e; e = htsp_next(&pcb_file_loaded, e)) { + pcb_file_loaded_t *cat = e->value; + pcb_file_loaded_clear(cat); + free(cat->name); + htsp_uninit(&cat->data.category.children); + free(cat); + htsp_delentry(&pcb_file_loaded, e); + } + + htsp_uninit(&pcb_file_loaded); +} + + Index: trunk/src/file_loaded.h =================================================================== --- trunk/src/file_loaded.h (nonexistent) +++ trunk/src/file_loaded.h (revision 24271) @@ -0,0 +1,82 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * (this file is based on PCB, interactive printed circuit board design) + * Copyright (C) 2018 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") + * + */ + +/* info on where files are loaded from */ + +#ifndef PCB_FILE_LOADED_H +#define PCB_FILE_LOADED_H + +#include + +/* Hash-in-hash tree with the top tree being categories. */ + +typedef enum pcb_file_loaded_type_e { + PCB_FLT_CATEGORY, + PCB_FLT_FILE +} pcb_file_loaded_type_t; + +typedef struct pcb_file_loaded_s pcb_file_loaded_t; + +struct pcb_file_loaded_s { + char *name; /* same as the hash key; strdup'd */ + pcb_file_loaded_type_t type; + union { + struct { + htsp_t children; + } category; + struct { + char *path; + char *desc; + } file; + } data; +}; + +extern htsp_t pcb_file_loaded; + +/* Return the category called name; if doesn't exist and alloc is 1, + allocate it it (else return NULL) */ +pcb_file_loaded_t *pcb_file_loaded_category(const char *name, int alloc); + +/* clear the subtree of a category, keeping the category; return 0 on success */ +int pcb_file_loaded_clear(pcb_file_loaded_t *cat); +int pcb_file_loaded_clear_at(const char *catname); + +/* clear the subtree of a category, keeping the category; return 0 on success */ +int pcb_file_loaded_set(pcb_file_loaded_t *cat, const char *name, const char *path, const char *desc); +int pcb_file_loaded_set_at(const char *catname, const char *name, const char *path, const char *desc); + +/* remove an entry */ +int pcb_file_loaded_del(pcb_file_loaded_t *cat, const char *name); +int pcb_file_loaded_del_at(const char *catname, const char *name); + + +/* called once, from main */ +void pcb_file_loaded_init(void); +void pcb_file_loaded_uninit(void); + +#endif Index: trunk/src/font.c =================================================================== --- trunk/src/font.c (revision 24270) +++ trunk/src/font.c (revision 24271) @@ -42,7 +42,7 @@ #include "paths.h" #include "compat_misc.h" #include "event.h" -#include "build_run.h" +#include "file_loaded.h" #define STEP_SYMBOLLINE 10 Index: trunk/src/hid_cfg.c =================================================================== --- trunk/src/hid_cfg.c (revision 24270) +++ trunk/src/hid_cfg.c (revision 24271) @@ -38,7 +38,7 @@ #include "paths.h" #include "safe_fs.h" #include "compat_misc.h" -#include "build_run.h" +#include "file_loaded.h" #include "conf_core.h" char hid_cfg_error_shared[1024]; Index: trunk/src/hid_init.c =================================================================== --- trunk/src/hid_init.c (revision 24270) +++ trunk/src/hid_init.c (revision 24271) @@ -45,6 +45,7 @@ #include "conf_core.h" #include "compat_misc.h" #include "compat_inc.h" +#include "file_loaded.h" static const char *flt_any[] = {"*", "*.*", NULL}; Index: trunk/src/hid_init.h =================================================================== --- trunk/src/hid_init.h (revision 24270) +++ trunk/src/hid_init.h (revision 24271) @@ -3,7 +3,6 @@ #include #include "hid.h" -#include "build_run.h" /* NULL terminated list of all static HID structures. Built by hid_register_hid, used by hid_find_*() and pcb_hid_enumerate(). The Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 24270) +++ trunk/src/main.c (revision 24271) @@ -52,6 +52,7 @@ #include "polygon.h" #include "buildin.h" #include "build_run.h" +#include "file_loaded.h" #include "flag.h" #include "flag_str.h" #include "plugins.h" Index: trunk/src/main_act.c =================================================================== --- trunk/src/main_act.c (revision 24270) +++ trunk/src/main_act.c (revision 24271) @@ -51,6 +51,7 @@ #include "conf_core.h" #include "plugins.h" #include "build_run.h" +#include "file_loaded.h" #include "safe_fs.h" #include "flag_str.h" #include "obj_common.h" Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 24270) +++ trunk/src/plug_io.c (revision 24271) @@ -66,7 +66,7 @@ #include "layer_vis.h" #include "safe_fs.h" #include "plug_footprint.h" -#include "build_run.h" +#include "file_loaded.h" #include "macro.h" #include "view.h" Index: trunk/src_plugins/dialogs/dlg_about.c =================================================================== --- trunk/src_plugins/dialogs/dlg_about.c (revision 24270) +++ trunk/src_plugins/dialogs/dlg_about.c (revision 24271) @@ -29,6 +29,7 @@ #include #include "actions.h" #include "build_run.h" +#include "file_loaded.h" #include "hid_dad.h" #include "pcb-printf.h" #include "dlg_about.h"