Index: trunk/src/libpcb_fp.c =================================================================== --- trunk/src/libpcb_fp.c (revision 851) +++ trunk/src/libpcb_fp.c (revision 852) @@ -84,9 +84,33 @@ #include #endif +#include "3rd/genht/htsp.h" +#include "3rd/genht/hash.h" + RCSID("$Id$"); +static htsp_t *pcb_fp_tags = NULL; +static int keyeq(char *a, char *b) { + return !strcmp(a,b); +} + +const void *pcb_fp_tag(const char *tag, int alloc) +{ + htsp_entry_t *e; + static int counter = 0; + + if (pcb_fp_tags == NULL) + pcb_fp_tags = htsp_alloc(strhash, keyeq); + e = htsp_getentry(pcb_fp_tags, tag); + if ((e == NULL) && alloc) { + htsp_set(pcb_fp_tags, strdup(tag), counter); + counter++; + e = htsp_getentry(pcb_fp_tags, tag); + } + return e; +} + /* Decide about the type of a footprint file: - it is a file element if the first non-comment is "Element(" or "Element[" - else it is a parametric element (footprint generator) if it contains @@ -166,6 +190,7 @@ if ((c == '\r') || (c == '\n')) { /* end of a tag */ tag[tused] = '\0'; /* printf("TAG: '%s' '%s'\n", fn, tag);*/ + pcb_fp_tag(tag, 1); tused = 0; state = ST_WS; break; Index: trunk/src/libpcb_fp.h =================================================================== --- trunk/src/libpcb_fp.h (revision 851) +++ trunk/src/libpcb_fp.h (revision 852) @@ -36,4 +36,8 @@ /* Close the footprint file opened by pcb_fp_fopen(). */ void pcb_fp_fclose(FILE *f, int *st); +/**** tag management ****/ +/* Resolve a tag name to an unique void * ID; create unknown tag if alloc != 0 */ +const void *pcb_fp_tag(const char *tag, int alloc); + #endif