Index: trunk/src/action_funchash.c =================================================================== --- trunk/src/action_funchash.c (revision 1350) +++ trunk/src/action_funchash.c (nonexistent) @@ -1,94 +0,0 @@ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * - * 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 St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact addresses for paper mail and Email: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ -#include "action.h" - -#define action_entry(x) { #x, F_ ## x}, -static FunctionType Functions[] = { -#include "action_funclist.h" - {"F_END", F_END} -}; - -/* --------------------------------------------------------------------------- - * get function ID of passed string - */ -#define HSIZE 257 -static char function_hash[HSIZE]; -static int hash_initted = 0; - -static int hashfunc(const char *s) -{ - int i = 0; - while (*s) { - i ^= i >> 16; - i = (i * 13) ^ (unsigned char) tolower((int) *s); - s++; - } - i = (unsigned int) i % HSIZE; - return i; -} - -FunctionID GetFunctionID(const char *Ident) -{ - int i, h; - - if (Ident == 0) - return -1; - - if (!hash_initted) { - hash_initted = 1; - if (HSIZE < ENTRIES(Functions) * 2) { - fprintf(stderr, _("Error: function hash size too small (%d vs %lu at %s:%d)\n"), - HSIZE, (unsigned long) ENTRIES(Functions) * 2, __FILE__, __LINE__); - exit(1); - } - if (ENTRIES(Functions) > 254) { - /* Change 'char' to 'int' and remove this when we get to 256 - strings to hash. */ - fprintf(stderr, _("Error: function hash type too small (%d vs %lu at %s:%d)\n"), - 256, (unsigned long) ENTRIES(Functions), __FILE__, __LINE__); - exit(1); - - } - for (i = ENTRIES(Functions) - 1; i >= 0; i--) { - h = hashfunc(Functions[i].Identifier); - while (function_hash[h]) - h = (h + 1) % HSIZE; - function_hash[h] = i + 1; - } - } - - i = hashfunc(Ident); - while (1) { - /* We enforce the "hash table bigger than function table" rule, - so we know there will be at least one zero entry to find. */ - if (!function_hash[i]) - return (-1); - if (!strcasecmp(Ident, Functions[function_hash[i] - 1].Identifier)) - return ((int) Functions[function_hash[i] - 1].ID); - i = (i + 1) % HSIZE; - } -} Index: trunk/src/action_funchash.h =================================================================== --- trunk/src/action_funchash.h (revision 1350) +++ trunk/src/action_funchash.h (nonexistent) @@ -1,34 +0,0 @@ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * - * 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 St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact addresses for paper mail and Email: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -typedef struct { /* used to identify subfunctions */ - char *Identifier; - FunctionID ID; -} FunctionType, *FunctionTypePtr; - -/* Convert function name to integer function id */ -FunctionID GetFunctionID(const char *Ident); Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 1350) +++ trunk/src/Makefile.dep (revision 1351) @@ -8,20 +8,11 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h action.h action_funclist.h action_funchash.h \ - buffer.h change.h copy.h create.h crosshair.h data.h draw.h error.h \ - find.h insert.h line.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ - move.h polygon.h rats.h remove.h rotate.h rubberband.h search.h select.h \ - set.h undo.h rtree.h stub_stroke.h -action_funchash.o: action_funchash.c action.h global.h ../config.h \ - ../config.manual.h ../config.auto.h const.h ../globalconst.h ../config.h \ - macro.h global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h \ - polyarea.h list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ - list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ - vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h action_funclist.h action_funchash.h + list_element.h libpcb_fp.h action.h buffer.h change.h copy.h create.h \ + crosshair.h data.h draw.h error.h find.h insert.h line.h misc.h \ + ../src_3rd/genvector/gds_char.h mymem.h move.h polygon.h rats.h remove.h \ + rotate.h rubberband.h search.h select.h set.h undo.h rtree.h \ + stub_stroke.h buffer.o: buffer.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -30,10 +21,11 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h action.h action_funclist.h action_funchash.h \ - buffer.h copy.h create.h crosshair.h data.h error.h file.h mymem.h \ - mirror.h misc.h ../src_3rd/genvector/gds_char.h parse_l.h polygon.h \ - rats.h rotate.h remove.h rtree.h search.h select.h set.h + list_element.h libpcb_fp.h action.h buffer.h copy.h create.h crosshair.h \ + data.h error.h file.h mymem.h mirror.h misc.h \ + ../src_3rd/genvector/gds_char.h parse_l.h polygon.h rats.h rotate.h \ + remove.h rtree.h search.h select.h set.h funchash_core.h funchash.h \ + action_funclist.h change.o: change.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -54,8 +46,8 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h crosshair.h draw.h search.h misc.h \ + list_element.h libpcb_fp.h data.h funchash_core.h funchash.h \ + action_funclist.h action.h change.h crosshair.h draw.h search.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h set.h error.h undo.h \ rubberband.h clip.o: clip.c ../config.h ../config.manual.h ../config.auto.h global.h \ @@ -75,9 +67,8 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h action.h action_funclist.h action_funchash.h \ - buffer.h command.h data.h error.h file.h mymem.h misc.h \ - ../src_3rd/genvector/gds_char.h rats.h set.h + list_element.h libpcb_fp.h action.h buffer.h command.h data.h error.h \ + file.h mymem.h misc.h ../src_3rd/genvector/gds_char.h rats.h set.h compat.o: compat.c ../config.h ../config.manual.h ../config.auto.h \ compat.h global.h const.h ../globalconst.h ../config.h macro.h \ global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ @@ -180,10 +171,9 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h crosshair.h set.h file.h \ - buffer.h mymem.h misc.h ../src_3rd/genvector/gds_char.h remove.h \ - create.h draw.h find.h search.h + list_element.h libpcb_fp.h data.h action.h change.h error.h undo.h \ + crosshair.h set.h file.h buffer.h mymem.h misc.h \ + ../src_3rd/genvector/gds_char.h remove.h create.h draw.h find.h search.h find.o: find.c ../config.h ../config.manual.h ../config.auto.h global.h \ const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -194,7 +184,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h crosshair.h data.h draw.h error.h find.h \ mymem.h misc.h ../src_3rd/genvector/gds_char.h rtree.h polygon.h \ - pcb-printf.h search.h set.h undo.h rats.h + pcb-printf.h search.h set.h undo.h rats.h file.h find_act.o: find_act.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -203,9 +193,8 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h find.h pcb-printf.h \ - ../src_3rd/genvector/gds_char.h + list_element.h libpcb_fp.h data.h action.h change.h error.h undo.h \ + find.h pcb-printf.h ../src_3rd/genvector/gds_char.h flags.o: flags.c ../config.h ../config.manual.h ../config.auto.h global.h \ const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -217,6 +206,7 @@ list_element.h libpcb_fp.h data.h pcb-printf.h \ ../src_3rd/genvector/gds_char.h free_atexit.o: free_atexit.c +funchash.o: funchash.c action_funclist.h gui_act.o: gui_act.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -225,8 +215,8 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h draw.h search.h crosshair.h \ + list_element.h libpcb_fp.h data.h action.h change.h error.h undo.h \ + funchash_core.h funchash.h action_funclist.h draw.h search.h crosshair.h \ find.h set.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ stub_stroke.h heap.o: heap.c ../config.h ../config.manual.h ../config.auto.h global.h \ @@ -323,10 +313,10 @@ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h buffer.h create.h crosshair.h draw.h \ - error.h file.h set.h action.h action_funclist.h action_funchash.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h lrealpath.h free_atexit.h \ - polygon.h pcb-printf.h buildin.h paths.h strflags.h plugins.h event.h \ - hid/common/actions.h hid/hidint.h dolists.h action_list.h + error.h file.h set.h action.h misc.h ../src_3rd/genvector/gds_char.h \ + mymem.h lrealpath.h free_atexit.h polygon.h pcb-printf.h buildin.h \ + paths.h strflags.h plugins.h event.h funchash.h hid/common/actions.h \ + hid/hidint.h dolists.h action_list.h mirror.o: mirror.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -349,7 +339,7 @@ list_element.h libpcb_fp.h box.h misc.h ../src_3rd/genvector/gds_char.h \ mymem.h crosshair.h create.h data.h draw.h file.h error.h move.h \ pcb-printf.h polygon.h remove.h rtree.h rotate.h rubberband.h search.h \ - set.h undo.h action.h action_funclist.h action_funchash.h portability.h + set.h undo.h action.h portability.h move.o: move.c ../config.h ../config.manual.h ../config.auto.h global.h \ const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -370,7 +360,7 @@ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h error.h mymem.h misc.h \ - ../src_3rd/genvector/gds_char.h rats.h rtree.h + ../src_3rd/genvector/gds_char.h rats.h rtree.h rats_patch.h netlist.o: netlist.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -379,9 +369,9 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h action.h action_funclist.h action_funchash.h \ - buffer.h command.h data.h error.h file.h find.h mymem.h misc.h \ - ../src_3rd/genvector/gds_char.h rats.h set.h create.h rats_patch.h + list_element.h libpcb_fp.h action.h buffer.h command.h data.h error.h \ + file.h find.h mymem.h misc.h ../src_3rd/genvector/gds_char.h rats.h \ + set.h create.h rats_patch.h object_act.o: object_act.c ../config.h ../config.manual.h \ ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ @@ -390,8 +380,8 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h search.h move.h draw.h \ + list_element.h libpcb_fp.h data.h action.h change.h error.h undo.h \ + funchash_core.h funchash.h action_funclist.h search.h move.h draw.h \ mirror.h rotate.h set.h copy.h misc.h ../src_3rd/genvector/gds_char.h \ mymem.h rubberband.h buffer.h remove.h create.h paths.o: paths.c paths.h error.h @@ -412,8 +402,8 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h ../src_3rd/genvector/gds_char.h + list_element.h libpcb_fp.h data.h action.h \ + ../src_3rd/genvector/gds_char.h polygon.o: polygon.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -442,8 +432,8 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h polygon.h draw.h search.h \ + list_element.h libpcb_fp.h data.h action.h change.h error.h undo.h \ + funchash_core.h funchash.h action_funclist.h polygon.h draw.h search.h \ crosshair.h print.o: print.c ../config.h ../config.manual.h ../config.auto.h global.h \ const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ @@ -475,9 +465,9 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h set.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h find.h remove.h rats.h draw.h + list_element.h libpcb_fp.h data.h action.h change.h error.h undo.h set.h \ + misc.h ../src_3rd/genvector/gds_char.h mymem.h find.h remove.h \ + funchash_core.h funchash.h action_funclist.h rats.h draw.h rats_patch.o: rats_patch.c rats_patch.h global.h ../config.h \ ../config.manual.h ../config.auto.h const.h ../globalconst.h ../config.h \ macro.h global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h \ @@ -488,8 +478,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ ../src_3rd/genht/ht_inlines.h ../src_3rd/genht/hash.h create.h data.h \ - action.h action_funclist.h action_funchash.h error.h buffer.h remove.h \ - copy.h + action.h error.h buffer.h remove.h copy.h remove.o: remove.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -509,8 +498,8 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h set.h remove.h + list_element.h libpcb_fp.h data.h action.h change.h error.h undo.h set.h \ + remove.h funchash_core.h funchash.h action_funclist.h report.o: report.c ../config.h ../config.manual.h ../config.auto.h \ report.h global.h const.h ../globalconst.h ../config.h macro.h \ global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ @@ -581,9 +570,9 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h search.h select.h crosshair.h \ - set.h buffer.h draw.h remove.h copy.h + list_element.h libpcb_fp.h data.h action.h change.h error.h undo.h \ + funchash_core.h funchash.h action_funclist.h search.h select.h \ + crosshair.h set.h buffer.h draw.h remove.h copy.h set.o: set.c ../config.h ../config.manual.h ../config.auto.h global.h \ const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -592,9 +581,9 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h action.h action_funclist.h action_funchash.h \ - buffer.h compat.h crosshair.h data.h draw.h error.h find.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h set.h undo.h + list_element.h libpcb_fp.h action.h buffer.h compat.h crosshair.h data.h \ + draw.h error.h find.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + set.h undo.h strflags.o: strflags.c ../config.h ../config.manual.h ../config.auto.h \ ../globalconst.h ../config.h global.h const.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -663,9 +652,10 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h action.h action_funclist.h \ - action_funchash.h change.h error.h crosshair.h undo.h polygon.h set.h \ - search.h draw.h misc.h ../src_3rd/genvector/gds_char.h mymem.h + list_element.h libpcb_fp.h data.h action.h change.h error.h \ + funchash_core.h funchash.h action_funclist.h crosshair.h undo.h \ + polygon.h set.h search.h draw.h misc.h ../src_3rd/genvector/gds_char.h \ + mymem.h vtonpoint.o: vtonpoint.c vtonpoint.h global_objs.h \ ../src_3rd/genlist/gendlist.h ../config.h ../config.manual.h \ ../config.auto.h ../globalconst.h ../config.h global_typedefs.h \ @@ -897,13 +887,13 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h action_funclist.h action_funchash.h \ - crosshair.h error.h hid/gtk/../hidint.h hid/gtk/gui.h global.h hid.h \ - hid/common/hid_resource.h resource.h data.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h hid/gtk/ghid-coord-entry.h \ - hid/gtk/ghid-main-menu.h hid/gtk/ghid-layer-selector.h \ - hid/gtk/ghid-route-style-selector.h hid/gtk/gui-pinout-preview.h \ - hid/common/hidnogui.h hid/common/draw_helpers.h pcb-printf.h dolists.h + list_element.h libpcb_fp.h crosshair.h error.h hid/gtk/../hidint.h \ + hid/gtk/gui.h global.h hid.h hid/common/hid_resource.h resource.h data.h \ + misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ + hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ + hid/gtk/gui-pinout-preview.h hid/common/hidnogui.h \ + hid/common/draw_helpers.h pcb-printf.h dolists.h gui-command-window.o: hid/gtk/gui-command-window.c ../config.h \ ../config.manual.h ../config.auto.h hid/gtk/gui.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -932,8 +922,7 @@ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ hid/gtk/gui-pinout-preview.h hid/gtk/../hidint.h hid/gtk/gtkhid.h \ - action.h action_funclist.h action_funchash.h change.h file.h error.h \ - draw.h portability.h pcb-printf.h set.h + action.h change.h file.h error.h draw.h portability.h pcb-printf.h set.h gui-dialog-print.o: hid/gtk/gui-dialog-print.c ../config.h \ ../config.manual.h ../config.auto.h hid/gtk/gui.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1028,11 +1017,11 @@ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h crosshair.h global.h data.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h action.h action_funclist.h \ - action_funchash.h set.h pcb-printf.h hid/gtk/gui.h hid.h \ - hid/common/hid_resource.h resource.h hid/gtk/ghid-coord-entry.h \ - hid/gtk/ghid-main-menu.h hid/gtk/ghid-layer-selector.h \ - hid/gtk/ghid-route-style-selector.h hid/gtk/gui-pinout-preview.h + ../src_3rd/genvector/gds_char.h mymem.h action.h set.h pcb-printf.h \ + hid/gtk/gui.h hid.h hid/common/hid_resource.h resource.h \ + hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ + hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ + hid/gtk/gui-pinout-preview.h gui-netlist-window.o: hid/gtk/gui-netlist-window.c ../config.h \ ../config.manual.h ../config.auto.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1061,9 +1050,8 @@ data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h hid/gtk/gtkhid.h action.h action_funclist.h \ - action_funchash.h crosshair.h draw.h error.h set.h find.h search.h \ - rats.h + hid/gtk/gui-pinout-preview.h hid/gtk/gtkhid.h action.h crosshair.h \ + draw.h error.h set.h find.h search.h rats.h gui-pinout-preview.o: hid/gtk/gui-pinout-preview.c ../config.h \ ../config.manual.h ../config.auto.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1106,12 +1094,11 @@ hid/common/hid_resource.h resource.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h hid/gtk/ghid-coord-entry.h \ hid/gtk/ghid-main-menu.h hid/gtk/gui-pinout-preview.h \ - hid/gtk/../hidint.h action.h action_funclist.h action_funchash.h \ - buffer.h change.h command.h copy.h create.h crosshair.h draw.h error.h \ - file.h find.h gpcb-menu.h insert.h line.h mymem.h move.h pcb-printf.h \ - polygon.h rats.h remove.h report.h rotate.h rubberband.h search.h \ - select.h set.h undo.h event.h free_atexit.h paths.h \ - hid/gtk/gui-icons-mode-buttons.data hid/gtk/gui-icons-misc.data + hid/gtk/../hidint.h action.h buffer.h change.h command.h copy.h create.h \ + crosshair.h draw.h error.h file.h find.h gpcb-menu.h insert.h line.h \ + mymem.h move.h pcb-printf.h polygon.h rats.h remove.h report.h rotate.h \ + rubberband.h search.h select.h set.h undo.h event.h free_atexit.h \ + paths.h hid/gtk/gui-icons-mode-buttons.data hid/gtk/gui-icons-misc.data gui-utils.o: hid/gtk/gui-utils.c ../config.h ../config.manual.h \ ../config.auto.h hid/gtk/gui.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1174,12 +1161,11 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h global.h action.h action_funclist.h \ - action_funchash.h crosshair.h mymem.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h pcb-printf.h resource.h clip.h \ - event.h error.h hid.h hid/lesstif/../hidint.h hid/common/hidnogui.h \ - hid/common/draw_helpers.h hid/common/hid_resource.h \ - hid/lesstif/lesstif.h dolists.h + list_element.h libpcb_fp.h data.h global.h action.h crosshair.h mymem.h \ + misc.h ../src_3rd/genvector/gds_char.h mymem.h pcb-printf.h resource.h \ + clip.h event.h error.h hid.h hid/lesstif/../hidint.h \ + hid/common/hidnogui.h hid/common/draw_helpers.h \ + hid/common/hid_resource.h hid/lesstif/lesstif.h dolists.h menu.o: hid/lesstif/menu.c ../config.h ../config.manual.h \ ../config.auto.h hid/lesstif/xincludes.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1293,8 +1279,8 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h ../src_plugins/autoroute/autoroute.h \ - plugins.h set.h global.h dolists.h + list_element.h libpcb_fp.h ../src_plugins/autoroute/autoroute.h action.h \ + global.h plugins.h set.h dolists.h ../src_plugins/autoroute/vector.o: ../src_plugins/autoroute/vector.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1373,17 +1359,6 @@ ../src_plugins/mincut/pcb-mincut/solve.c \ ../src_plugins/mincut/pcb-mincut/solve.h \ ../src_plugins/mincut/pcb-mincut/graph.h -../src_plugins/oldactions/oldactions.o: \ - ../src_plugins/oldactions/oldactions.c ../config.h ../config.manual.h \ - ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ - global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ - list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ - list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ - vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h global.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h plugins.h dolists.h ../src_plugins/fontmode/fontmode.o: ../src_plugins/fontmode/fontmode.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1406,8 +1381,7 @@ ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h hid.h global_element.h list_element.h libpcb_fp.h data.h \ - global.h action.h action_funclist.h action_funchash.h change.h error.h \ - undo.h plugins.h + global.h action.h change.h error.h undo.h plugins.h ../src_plugins/renumber/renumber.o: ../src_plugins/renumber/renumber.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1417,10 +1391,9 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h global.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h set.h plugins.h pcb-printf.h \ - dolists.h + list_element.h libpcb_fp.h data.h global.h action.h change.h error.h \ + undo.h misc.h ../src_3rd/genvector/gds_char.h mymem.h set.h plugins.h \ + pcb-printf.h dolists.h ../src_plugins/import_sch/import_sch.o: \ ../src_plugins/import_sch/import_sch.c ../config.h ../config.manual.h \ ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ @@ -1430,10 +1403,9 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h global.h action.h action_funclist.h \ - action_funchash.h change.h error.h undo.h plugins.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h portability.h pcb-printf.h \ - remove.h rats.h dolists.h + list_element.h libpcb_fp.h data.h global.h action.h change.h error.h \ + undo.h plugins.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + portability.h pcb-printf.h remove.h rats.h dolists.h ../src_plugins/export_ps/ps.o: ../src_plugins/export_ps/ps.c ../config.h \ ../config.manual.h ../config.auto.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1545,19 +1517,6 @@ ../src_3rd/genvector/gds_char.h mymem.h plugins.h hid.h \ hid/gtk/../hidint.h hid/common/hidnogui.h hid/common/draw_helpers.h \ ../src_plugins/export_png/png.h hid/common/hidinit.h dolists.h -../src_plugins/export_gerber/gerber.o: \ - ../src_plugins/export_gerber/gerber.c ../config.h ../config.manual.h \ - ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ - global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ - list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ - list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ - vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h global.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h error.h draw.h pcb-printf.h \ - plugins.h hid.h hid/gtk/../hidint.h hid/common/hidnogui.h \ - hid/common/draw_helpers.h hid/common/hidinit.h ../src_plugins/export_bom/bom.o: ../src_plugins/export_bom/bom.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1585,6 +1544,17 @@ ../src_3rd/genvector/gds_char.h mymem.h create.h draw.h error.h find.h \ heap.h rtree.h misc.h mymem.h polygon.h rats.h remove.h thermal.h undo.h \ ../src_3rd/gts/gts.h pcb-printf.h +../src_plugins/oldactions/oldactions.o: \ + ../src_plugins/oldactions/oldactions.c ../config.h ../config.manual.h \ + ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ + global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ + list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ + ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ + list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ + vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ + ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ + list_element.h libpcb_fp.h data.h global.h action.h change.h error.h \ + undo.h plugins.h dolists.h ../src_plugins/stroke/stroke.o: ../src_plugins/stroke/stroke.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 1350) +++ trunk/src/Makefile.in (revision 1351) @@ -11,7 +11,6 @@ # main: objects put /local/pcb/OBJS [@ action.o - action_funchash.o buffer.o change.o change_act.o @@ -32,6 +31,7 @@ find_act.o flags.o free_atexit.o + funchash.o gui_act.o heap.o insert.o @@ -98,6 +98,7 @@ buildin.o ../src_3rd/genht/hash.o ../src_3rd/genht/htsp.o + ../src_3rd/genht/htsi.o ../src_3rd/genvector/gds_char.o @] Index: trunk/src/action.c =================================================================== --- trunk/src/action.c (revision 1350) +++ trunk/src/action.c (revision 1351) @@ -57,8 +57,8 @@ #include "undo.h" #include "rtree.h" #include "stub_stroke.h" +#include "funchash_core.h" - /* --------------------------------------------------------------------------- */ /* %start-doc actions 00delta Index: trunk/src/action.h =================================================================== --- trunk/src/action.h (revision 1350) +++ trunk/src/action.h (revision 1351) @@ -46,15 +46,6 @@ bool ActionGetLocation(char *); void ActionGetXY(char *); -#define action_entry(x) F_ ## x, -typedef enum { -#include "action_funclist.h" -F_END -} FunctionID; -#undef action_entry - -#include "action_funchash.h" - #define ACTION_ARG(n) (argc > (n) ? argv[n] : NULL) int get_style_size(int funcid, Coord * out, int type, int size_id); @@ -85,10 +76,4 @@ int ActionExecuteFile(int argc, char **argv, Coord x, Coord y); void ReleaseMode(void); -#ifdef HAVE_LIBSTROKE -extern bool mid_stroke; -extern BoxType StrokeBox; -void FinishStroke(void); #endif - -#endif Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 1350) +++ trunk/src/buffer.c (revision 1351) @@ -57,8 +57,8 @@ #include "search.h" #include "select.h" #include "set.h" +#include "funchash_core.h" - RCSID("$Id$"); /* --------------------------------------------------------------------------- @@ -1317,7 +1317,7 @@ notify_crosshair_change(false); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { /* clear contents of paste buffer */ case F_Clear: ClearBuffer(PASTEBUFFER); Index: trunk/src/change_act.c =================================================================== --- trunk/src/change_act.c (revision 1350) +++ trunk/src/change_act.c (revision 1351) @@ -32,6 +32,7 @@ #include "global.h" #include "data.h" +#include "funchash_core.h" #include "action.h" #include "change.h" @@ -77,7 +78,7 @@ void *ptr1, *ptr2, *ptr3; if (function && delta) { - int funcid = GetFunctionID(function); + int funcid = funchash_get(function, NULL); if (funcid == F_Object) { gui->get_coords(_("Select an Object"), &x, &y); @@ -94,7 +95,7 @@ } else value = 2 * GetValue(delta, units, &absolute); - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Object: { if (type != NO_TYPE) @@ -188,7 +189,7 @@ return; } - switch (GetFunctionID(what)) { + switch (funchash_get(what, NULL)) { case F_Object: { int type; @@ -262,7 +263,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: { @@ -304,7 +305,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: { @@ -390,7 +391,7 @@ if (function && delta) { - int funcid = GetFunctionID(function); + int funcid = funchash_get(function, NULL); if (funcid == F_Object) type = SearchScreen(Crosshair.X, Crosshair.Y, CHANGESIZE_TYPES, &ptr1, &ptr2, &ptr3); @@ -492,7 +493,7 @@ Coord value; if (function && delta) { - int funcid = GetFunctionID(function); + int funcid = funchash_get(function, NULL); if (funcid == F_Object) { gui->get_coords(_("Select an Object"), &x, &y); @@ -507,7 +508,7 @@ else value = GetValue(delta, units, &absolute); - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Object: { @@ -649,7 +650,7 @@ int pinnum; if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { /* change the name of an object */ case F_Object: { @@ -726,7 +727,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: { @@ -779,7 +780,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: case F_Element: @@ -825,7 +826,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: { @@ -887,7 +888,7 @@ { char *function = ACTION_ARG(0); if (function && *function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: { @@ -939,7 +940,7 @@ { char *function = ACTION_ARG(0); if (function && *function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: { @@ -990,7 +991,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: { @@ -1045,7 +1046,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: { @@ -1101,7 +1102,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleObject: case F_Object: { @@ -1183,7 +1184,7 @@ kind = GetValue(style, NULL, &absolute); if (absolute) - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Object: if ((type = SearchScreen(Crosshair.X, Crosshair.Y, CHANGETHERMAL_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) { ChangeObjectThermal(type, ptr1, ptr2, ptr3, kind); @@ -1316,7 +1317,7 @@ if (function && val) { value = GetValue(val, units, &absolute); - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ViaDrillingHole: SetViaDrillingHole(absolute ? value : value + Settings.ViaDrillingHole, false); hid_action("RouteStylesChanged"); Index: trunk/src/funchash.c =================================================================== --- trunk/src/funchash.c (nonexistent) +++ trunk/src/funchash.c (revision 1351) @@ -0,0 +1,113 @@ +/* + * COPYRIGHT + * + * PCB-rnd, interactive printed circuit board design + * Copyright (C) 2016 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include "funchash_core.h" +#include "macro.h" + +#define MAXKEYLEN 256 + +#define action_entry(x) { #x, F_ ## x}, +static funchash_table_t Functions[] = { +#include "action_funclist.h" + {"F_END", F_END} +}; + +static htsi_t *funchash; + +static int keyeq(char *a, char *b) +{ + return !strcmp(a, b); +} + +void funchash_init(void) +{ + funchash = htsi_alloc(strhash, keyeq); + funchash_set_table(Functions, ENTRIES(Functions), NULL); +} + +void funchash_uninit(void) +{ + +} + +/* A key is either a plain string (cookie == NULL) or an aggregate of + cookie and the key - this guarantees each cookie has its own namespace */ +#define asm_key(dest, buff, key, cookie, badretval) \ +do { \ + if (cookie != NULL) { \ + int __lk__; \ + __lk__ = strlen(key); \ + if (strlen(key)+sizeof(int)*2+6 > sizeof(buff)) \ + return badretval; \ + sprintf(buff, "%p::%s", cookie, key); \ + new_key = buff; \ + } \ + else \ + new_key = (char *)key; \ +} while(0) + + +int funchash_get(const char *key, const char *cookie) +{ + char buff[MAXKEYLEN]; + char *new_key; + htsi_entry_t *e; + + if (key == NULL) + return -1; + + asm_key(new_key, buff, key, cookie, -1); + e = htsi_getentry(funchash, new_key); + if (e == NULL) + return -1; + return e->value; +} + +int funchash_set(const char *key, int val, const char *cookie) +{ + char buff[MAXKEYLEN]; + char *new_key; + htsi_entry_t *e; + + asm_key(new_key, buff, key, cookie, -1); + e = htsi_getentry(funchash, new_key); + if (e != NULL) + return -1; + + htsi_set(funchash, strdup(new_key), val); + return 0; +} + +int funchash_set_table(funchash_table_t *table, int numelem, const char *cookie) +{ + int i, rv = 0; + + for (i = 0; i < numelem; i++) + rv |= funchash_set(table[i].key, table[i].val, cookie); + + return rv; +} Index: trunk/src/funchash.h =================================================================== --- trunk/src/funchash.h (nonexistent) +++ trunk/src/funchash.h (revision 1351) @@ -0,0 +1,34 @@ +/* + * COPYRIGHT + * + * PCB-rnd, interactive printed circuit board design + * Copyright (C) 2016 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* Table entry format for funchash_set_table() */ +typedef struct { + char *key; + int val; +} funchash_table_t; + +int funchash_get(const char *key, const char *cookie); +int funchash_set(const char *key, int val, const char *cookie); +int funchash_set_table(funchash_table_t *table, int numelem, const char *cookie); + +void funchash_init(void); +void funchash_uninit(void); Index: trunk/src/funchash_core.h =================================================================== --- trunk/src/funchash_core.h (nonexistent) +++ trunk/src/funchash_core.h (revision 1351) @@ -0,0 +1,10 @@ +/* central, auto-generated enum of core function IDs */ + +#include "funchash.h" + +#define action_entry(x) F_ ## x, +typedef enum { +#include "action_funclist.h" +F_END +} FunctionID; +#undef action_entry Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 1350) +++ trunk/src/gui_act.c (revision 1351) @@ -31,6 +31,7 @@ #include "change.h" #include "error.h" #include "undo.h" +#include "funchash_core.h" #include "draw.h" #include "search.h" @@ -213,7 +214,7 @@ str_dir = ACTION_ARG(1); if (function && (!str_dir || !*str_dir)) { - switch (id = GetFunctionID(function)) { + switch (id = funchash_get(function, NULL)) { /* redraw layout */ case F_ClearAndRedraw: @@ -506,7 +507,7 @@ } } else if (function && str_dir) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_ToggleGrid: if (argc > 2) { PCB->GridOffsetX = GetValue(argv[1], NULL, NULL); @@ -596,7 +597,7 @@ Note.X = Crosshair.X; Note.Y = Crosshair.Y; notify_crosshair_change(false); - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Arc: SetMode(ARC_MODE); break; @@ -892,7 +893,7 @@ { char *function = ACTION_ARG(0); if (function && PCB->ElementOn) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Object: { int type; @@ -973,7 +974,7 @@ notify_mark_change(true); } } - else if (GetFunctionID(function) == F_Center) { + else if (funchash_get(function, NULL) == F_Center) { notify_mark_change(false); Marked.status = true; Marked.X = Crosshair.X; Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 1350) +++ trunk/src/main.c (revision 1351) @@ -61,6 +61,7 @@ #include "strflags.h" #include "plugins.h" #include "event.h" +#include "funchash.h" #include "hid/common/actions.h" @@ -1600,7 +1601,7 @@ FreeLibraryMemory(&Library); pcb_fp_uninit(); file_uninit(); - + funchash_uninit(); #define free0(ptr) \ do { \ @@ -1651,6 +1652,7 @@ srand(time(NULL)); /* Set seed for rand() */ + funchash_init(); initialize_units(); polygon_init(); hid_init(); Index: trunk/src/object_act.c =================================================================== --- trunk/src/object_act.c (revision 1350) +++ trunk/src/object_act.c (revision 1351) @@ -31,6 +31,7 @@ #include "change.h" #include "error.h" #include "undo.h" +#include "funchash_core.h" #include "search.h" #include "move.h" @@ -115,7 +116,7 @@ return 1; } - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Layout: { gui->edit_attributes("Layout Attributes", &(PCB->Attributes)); @@ -219,7 +220,7 @@ bad = 1; } else { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_All: all = 1; break; @@ -328,7 +329,7 @@ int err = 0; if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Object: if ((SearchScreen(x, y, ELEMENT_TYPE, &ptrtmp, &ptrtmp, &ptrtmp)) != NO_TYPE) { element = (ElementTypePtr) ptrtmp; @@ -417,7 +418,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Object: { int type; @@ -730,7 +731,7 @@ bool changed = false; if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_All: ALLLINE_LOOP(PCB->Data); { Index: trunk/src/polygon_act.c =================================================================== --- trunk/src/polygon_act.c (revision 1350) +++ trunk/src/polygon_act.c (revision 1351) @@ -31,6 +31,7 @@ #include "change.h" #include "error.h" #include "undo.h" +#include "funchash_core.h" #include "polygon.h" #include "draw.h" @@ -57,7 +58,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Object: { int type; @@ -116,7 +117,7 @@ char *function = ACTION_ARG(0); if (function && Settings.Mode == POLYGON_MODE) { notify_crosshair_change(false); - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { /* close open polygon if possible */ case F_Close: ClosePolygon(); Index: trunk/src/rats_act.c =================================================================== --- trunk/src/rats_act.c (revision 1350) +++ trunk/src/rats_act.c (revision 1351) @@ -35,6 +35,7 @@ #include "misc.h" #include "find.h" #include "remove.h" +#include "funchash_core.h" #include "rats.h" #include "draw.h" @@ -73,7 +74,7 @@ if (function) { if (Settings.RatWarn) ClearWarnings(); - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_AllRats: if (AddAllRats(false, NULL)) SetChangedFlag(true); @@ -143,7 +144,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_Find: { gui->get_coords(_("Click on a connection"), &x, &y); @@ -194,7 +195,7 @@ if (function) { if (Settings.RatWarn) ClearWarnings(); - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { case F_AllRats: if (DeleteRats(false)) SetChangedFlag(true); Index: trunk/src/remove_act.c =================================================================== --- trunk/src/remove_act.c (revision 1350) +++ trunk/src/remove_act.c (revision 1351) @@ -33,6 +33,7 @@ #include "undo.h" #include "set.h" #include "remove.h" +#include "funchash_core.h" /* --------------------------------------------------------------------------- */ @@ -47,7 +48,7 @@ static int ActionDelete(int argc, char **argv, Coord x, Coord y) { char *function = ACTION_ARG(0); - int id = GetFunctionID(function); + int id = funchash_get(function, NULL); Note.X = Crosshair.X; Note.Y = Crosshair.Y; Index: trunk/src/select_act.c =================================================================== --- trunk/src/select_act.c (revision 1350) +++ trunk/src/select_act.c (revision 1351) @@ -31,6 +31,7 @@ #include "change.h" #include "error.h" #include "undo.h" +#include "funchash_core.h" #include "search.h" #include "select.h" @@ -118,7 +119,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { #if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) int type; /* select objects by their names */ @@ -289,7 +290,7 @@ { char *function = ACTION_ARG(0); if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { #if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) int type; /* select objects by their names */ Index: trunk/src/undo_act.c =================================================================== --- trunk/src/undo_act.c (revision 1350) +++ trunk/src/undo_act.c (revision 1351) @@ -30,6 +30,7 @@ #include "action.h" #include "change.h" #include "error.h" +#include "funchash_core.h" #include "crosshair.h" #include "undo.h" @@ -82,7 +83,7 @@ if (argc != 1) AFAIL(atomic); - switch (GetFunctionID(argv[0])) { + switch (funchash_get(argv[0], NULL)) { case F_Save: SaveUndoSerialNumber(); break; @@ -231,7 +232,7 @@ SetChangedFlag(true); } else if (function) { - switch (GetFunctionID(function)) { + switch (funchash_get(function, NULL)) { /* clear 'undo objects' list */ case F_ClearList: ClearUndoList(false);