Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 30826) +++ trunk/src/plug_io.c (revision 30827) @@ -1037,7 +1037,41 @@ return res; } +void pcb_io_fp_map_append(pcb_plug_fp_map_t **tail, pcb_plug_fp_map_t *head, const char *filename, const char *fpname) +{ + pcb_plug_fp_map_t *m; + switch(head->type) { + case PCB_FP_INVALID: /* first append */ + (*tail)->type = PCB_FP_FILE; + (*tail)->name = pcb_strdup(fpname); + break; + case PCB_FP_FILE: /* second append */ + /* clone the existing head */ + m = calloc(sizeof(pcb_plug_fp_map_t), 1); + m->type = PCB_FP_FILE; + m->libtype = PCB_LIB_FOOTPRINT; + m->name = head->name; + + head->type = PCB_FP_DIR; + head->libtype = PCB_LIB_DIR; + head->name = pcb_strdup(filename); + head->next = m; + + *tail = m; + /* fall through adding the second */ + case PCB_FP_DIR: /* third append */ + m = calloc(sizeof(pcb_plug_fp_map_t), 1); + m->type = PCB_FP_FILE; + m->libtype = PCB_LIB_FOOTPRINT; + m->name = pcb_strdup(fpname); + + (*tail)->next = m; + *tail = m; + break; + } +} + void pcb_io_uninit(void) { pcb_view_list_free_fields(&pcb_io_incompat_lst); Index: trunk/src/plug_io.h =================================================================== --- trunk/src/plug_io.h (revision 30826) +++ trunk/src/plug_io.h (revision 30827) @@ -152,6 +152,12 @@ /* map a footprint file: always returns head with 0 or 1 or more mapping results */ pcb_plug_fp_map_t *pcb_io_map_footprint_file(pcb_hidlib_t *hl, const char *fn, pcb_plug_fp_map_t *head, int need_tags); +/* Append a file name to the footprint map at tail; the first item is appended + assuming there would be only one footprint in the file; from the second item + the head item is converted into a footprint library */ +void pcb_io_fp_map_append(pcb_plug_fp_map_t **tail, pcb_plug_fp_map_t *head, const char *filename, const char *fpname); + + /********** common function used to be part of file.[ch] and friends **********/ int pcb_save_pcb(const char *, const char *fmt); #define PCB_INHIBIT_BOARD_CHANGED 0x20 Index: trunk/src_plugins/io_bxl/read.c =================================================================== --- trunk/src_plugins/io_bxl/read.c (revision 30826) +++ trunk/src_plugins/io_bxl/read.c (revision 30827) @@ -810,45 +810,6 @@ return io_bxl_test_parse2(NULL, ctx, typ, filename, f, NULL, NULL); } -/* Append a file name to the footprint map at tail; the first item is appended - assuming there would be only one footprint in the file; from the second item - the head item is converted into a footprint library */ -void pcb_io_fp_map_append(pcb_plug_fp_map_t **tail, pcb_plug_fp_map_t *head, const char *filename, const char *fpname) -{ - pcb_plug_fp_map_t *m; - - switch(head->type) { - case PCB_FP_INVALID: /* first append */ - (*tail)->type = PCB_FP_FILE; - (*tail)->name = pcb_strdup(fpname); - break; - case PCB_FP_FILE: /* second append */ - /* clone the existing head */ - m = calloc(sizeof(pcb_plug_fp_map_t), 1); - m->type = PCB_FP_FILE; - m->libtype = PCB_LIB_FOOTPRINT; - m->name = head->name; - - head->type = PCB_FP_DIR; - head->libtype = PCB_LIB_DIR; - head->name = pcb_strdup(filename); - head->next = m; - - *tail = m; - /* fall through adding the second */ - case PCB_FP_DIR: /* third append */ - m = calloc(sizeof(pcb_plug_fp_map_t), 1); - m->type = PCB_FP_FILE; - m->libtype = PCB_LIB_FOOTPRINT; - m->name = pcb_strdup(fpname); - - (*tail)->next = m; - *tail = m; - break; - } -} - - typedef struct { int has_fp; const char *fn;