Index: src_plugins/io_pads/read.c =================================================================== --- src_plugins/io_pads/read.c (revision 33767) +++ src_plugins/io_pads/read.c (revision 33768) @@ -33,6 +33,9 @@ #include #include +#include +#include +#include #include #include #include @@ -51,6 +54,12 @@ /* virtual layer ID for the non-existent board outline layer */ #define PADS_LID_BOARD 257 + +typedef struct pads_read_decal_s { + TODO("do we need swaps?") + char decal_name[1]; /* really as long as it needs to be */ +} pads_read_part_t; + typedef struct pads_read_ctx_s { pcb_board_t *pcb; FILE *f; @@ -58,6 +67,7 @@ double ver; pcb_dlcr_t dlcr; pcb_dlcr_layer_t *layer; + htsp_t parts; /* translate part to partdecal and swaps; key=partname value=(pads_read_part_t *) */ /* location */ const char *fn; @@ -287,6 +297,7 @@ pcb_dlcr_init(&rctx.dlcr); rctx.dlcr.flip_y = 1; + htsp_init(&rctx.parts, strhash, strkeyeq); /* read the header */ if (pads_parse_header(&rctx) != 0) { @@ -301,6 +312,13 @@ pads_assign_layers(&rctx); pcb_dlcr_create(pcb, &rctx.dlcr); pcb_dlcr_uninit(&rctx.dlcr); + + genht_uninit_deep(htsp, &rctx.parts, { + free(htent->key); + free(htent->value); + }); + + fclose(f); return ret; } Index: src_plugins/io_pads/read_high.c =================================================================== --- src_plugins/io_pads/read_high.c (revision 33767) +++ src_plugins/io_pads/read_high.c (revision 33768) @@ -722,14 +722,15 @@ static int pads_parse_part(pads_read_ctx_t *rctx) { - char refdes[64], ptype[64], glue[4], mirr[4]; + pads_read_part_t *part; + char partname[64], decalname[64], glue[4], mirr[4]; long n, altdeclnum, clustid = -1, clsattr = 0, brotherid = -1, num_labels; rnd_coord_t xo, yo; double rot; - int res; + int dnl, res; - if ((res = pads_read_word(rctx, refdes, sizeof(refdes), 0)) <= 0) return res; - if ((res = pads_read_word(rctx, ptype, sizeof(ptype), 0)) <= 0) return res; + if ((res = pads_read_word(rctx, partname, sizeof(partname), 0)) <= 0) return res; + if ((res = pads_read_word(rctx, decalname, sizeof(decalname), 0)) <= 0) return res; if ((res = pads_read_coord(rctx, &xo)) <= 0) return res; if ((res = pads_read_coord(rctx, &yo)) <= 0) return res; if ((res = pads_read_double(rctx, &rot)) <= 0) return res; @@ -746,7 +747,18 @@ pads_eatup_till_nl(rctx); - rnd_trace("part: '%s' of '%s' num_labels=%ld\n", refdes, ptype, num_labels); + rnd_trace("part: '%s' of '%s' num_labels=%ld\n", partname, decalname, num_labels); + part = htsp_get(&rctx->parts, partname); + if (part != NULL) { + PADS_ERROR((RND_MSG_ERROR, "*PART* called '%s' is defined multiple times\n", partname)); + return -1; + } + + dnl = strlen(decalname)+1; + part = calloc(sizeof(pads_read_part_t) + dnl, 1); + memcpy(part->decal_name, decalname, dnl); + htsp_set(&rctx->parts, rnd_strdup(partname), part); + for(n = 0; n < num_labels; n++) if ((res = pads_parse_label(rctx, xo, yo)) <= 0) return res; return 1;