Index: trunk/src/plug_footprint.c =================================================================== --- trunk/src/plug_footprint.c (revision 35756) +++ trunk/src/plug_footprint.c (revision 35757) @@ -198,7 +198,7 @@ return res; } -pcb_fplibrary_t *pcb_fp_append_entry(pcb_fplibrary_t *parent, const char *name, pcb_fptype_t type, void *tags[], rnd_bool dup_tags) +pcb_fplibrary_t *pcb_fp_append_entry(pcb_fplibrary_t *parent, const char *name, pcb_fptype_t type, void *tags[], rnd_bool dup_tags, const char *fmt) { pcb_fplibrary_t *entry; /* Pointer to individual menu entry */ @@ -223,6 +223,11 @@ entry->data.fp.tags = dup_tags ? pcb_fp_dup_tags(tags) : tags; entry->data.fp.loc_info = NULL; entry->data.fp.backend_data = NULL; + if (fmt != NULL) + entry->data.fp.fmt = rnd_strdup(fmt); + else + entry->data.fp.fmt = NULL; + return entry; } @@ -354,6 +359,7 @@ free(l->data.fp.loc_info); if (l->data.fp.tags != NULL) free(l->data.fp.tags); + free(l->data.fp.fmt); break; case PCB_LIB_INVALID: break; /* suppress compiler warning */ } Index: trunk/src/plug_footprint.h =================================================================== --- trunk/src/plug_footprint.h (revision 35756) +++ trunk/src/plug_footprint.h (revision 35757) @@ -43,6 +43,7 @@ locally allocated but values are stored in a central hash and must be allocated by pcb_fp_tag() and never free'd manually */ void **tags; + char *fmt; /* format found while mapping (may be NULL) */ } fp; } data; } ; @@ -123,8 +124,8 @@ pcb_fplibrary_t *pcb_fp_mkdir_len(pcb_fplibrary_t *parent, const char *name, int name_len); pcb_fplibrary_t *pcb_fp_lib_search(pcb_fplibrary_t *dir, const char *name); -/* Append a menu entry in the tree */ -pcb_fplibrary_t *pcb_fp_append_entry(pcb_fplibrary_t *parent, const char *name, pcb_fptype_t type, void *tags[], rnd_bool dup_tags); +/* Append a menu entry in the tree; fmt is optional (may be NULL) */ +pcb_fplibrary_t *pcb_fp_append_entry(pcb_fplibrary_t *parent, const char *name, pcb_fptype_t type, void *tags[], rnd_bool dup_tags, const char *fmt); /* walk through all lib paths and build the library menu */ int pcb_fp_read_lib_all(void); Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 35756) +++ trunk/src/plug_io.c (revision 35757) @@ -156,6 +156,7 @@ void (*f)(); switch(type) { case PCB_IOT_PCB: f = (void (*)())available[n].plug->parse_pcb; break; + case PCB_IOT_FOOTPRINT: f = (void (*)())available[n].plug->parse_footprint; break; default: assert(!"internal error: pcb_test_parse_all: wrong type"); f = NULL; } if (f != NULL) { @@ -1085,7 +1086,7 @@ return 0; } -pcb_plug_fp_map_t *pcb_io_map_footprint_file(rnd_hidlib_t *hl, const char *fn, pcb_plug_fp_map_t *head, int need_tags) +pcb_plug_fp_map_t *pcb_io_map_footprint_file(rnd_hidlib_t *hl, const char *fn, pcb_plug_fp_map_t *head, int need_tags, const char **fmt) { FILE *f = rnd_fopen(hl, fn, "r"); pcb_plug_fp_map_t *res = NULL; @@ -1104,8 +1105,11 @@ head->libtype = PCB_LIB_FOOTPRINT; res = plug->map_footprint(NULL, f, fn, head, need_tags); if (res == NULL) continue; - if (res->type != PCB_FP_INVALID) + if (res->type != PCB_FP_INVALID) { + if (fmt != NULL) + *fmt = plug->default_fmt; break; /* success */ + } vts0_uninit(&res->tags); } Index: trunk/src/plug_io.h =================================================================== --- trunk/src/plug_io.h (revision 35756) +++ trunk/src/plug_io.h (revision 35757) @@ -158,7 +158,7 @@ int pcb_write_font(pcb_font_t *Ptr, const char *Filename, const char *fmt); /* 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(rnd_hidlib_t *hl, const char *fn, pcb_plug_fp_map_t *head, int need_tags); +pcb_plug_fp_map_t *pcb_io_map_footprint_file(rnd_hidlib_t *hl, const char *fn, pcb_plug_fp_map_t *head, int need_tags, const char **fmt); /* 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 Index: trunk/src_plugins/dialogs/dlg_library.c =================================================================== --- trunk/src_plugins/dialogs/dlg_library.c (revision 35756) +++ trunk/src_plugins/dialogs/dlg_library.c (revision 35757) @@ -362,7 +362,7 @@ } } else { - if (pcb_buffer_load_footprint(PCB_PASTEBUFFER, l->data.fp.loc_info, NULL)) { + if (pcb_buffer_load_footprint(PCB_PASTEBUFFER, l->data.fp.loc_info, l->data.fp.fmt)) { rnd_tool_select_by_name(&PCB->hidlib, "buffer"); if (pcb_subclist_length(&PCB_PASTEBUFFER->Data->subc) != 0) library_update_preview(ctx, pcb_subclist_first(&PCB_PASTEBUFFER->Data->subc), l); Index: trunk/src_plugins/fp_board/fp_board.c =================================================================== --- trunk/src_plugins/fp_board/fp_board.c (revision 35756) +++ trunk/src_plugins/fp_board/fp_board.c (revision 35757) @@ -60,7 +60,7 @@ ename = subc->refdes; if (ename == NULL) ename = "anonymous"; - e = pcb_fp_append_entry(l, ename, PCB_FP_FILE, NULL, 0); + e = pcb_fp_append_entry(l, ename, PCB_FP_FILE, NULL, 0, NULL); /* remember location by ID - because of the dedup search by name is unsafe */ if (e != NULL) Index: trunk/src_plugins/fp_fs/fp_fs.c =================================================================== --- trunk/src_plugins/fp_fs/fp_fs.c (revision 35756) +++ trunk/src_plugins/fp_fs/fp_fs.c (revision 35757) @@ -70,16 +70,19 @@ char *path; /* also the key */ pcb_plug_fp_map_t map; time_t mtime; + const char *fmt; } pcb_fp_map_cache_t; htsp_t fp_fs_cache; -pcb_plug_fp_map_t *pcb_io_map_footprint_file_cached(rnd_hidlib_t *hl, htsp_t *cache, struct stat *st, const char *path) +pcb_plug_fp_map_t *pcb_io_map_footprint_file_cached(rnd_hidlib_t *hl, htsp_t *cache, struct stat *st, const char *path, const char **fmt) { pcb_fp_map_cache_t *c; c = htsp_get(cache, path); - if ((c != NULL) && (c->mtime >= st->st_mtime)) + if ((c != NULL) && (c->mtime >= st->st_mtime)) { + *fmt = c->fmt; return &c->map; + } if (c == NULL) { c = calloc(sizeof(pcb_fp_map_cache_t), 1); @@ -89,8 +92,9 @@ else pcb_io_fp_map_free_fields(&c->map); - pcb_io_map_footprint_file(hl, path, &c->map, 1); + pcb_io_map_footprint_file(hl, path, &c->map, 1, &c->fmt); c->mtime = st->st_mtime; + *fmt = c->fmt; return &c->map; } @@ -116,6 +120,7 @@ char *parent; char *subdir; pcb_plug_fp_map_t *children; + const char *fmt; list_dir_t *next; }; @@ -126,7 +131,7 @@ int is_virtual_dir; } list_st_t; -static int list_cb(void *cookie, const char *subdir, const char *name, pcb_fptype_t type, void *tags[], pcb_plug_fp_map_t *children) +static int list_cb(void *cookie, const char *subdir, const char *name, pcb_fptype_t type, void *tags[], pcb_plug_fp_map_t *children, const char *fmt) { list_st_t *l = (list_st_t *) cookie; pcb_fplibrary_t *e; @@ -141,12 +146,13 @@ d->parent = rnd_strdup(subdir); d->next = l->subdirs; d->children = children; + d->fmt = fmt; l->subdirs = d; return 0; } l->children++; - e = pcb_fp_append_entry(l->menu, name, type, tags, 1); + e = pcb_fp_append_entry(l->menu, name, type, tags, 1, fmt); /* Avoid using rnd_concat() - would be a new dependency for gsch2pcb-rnd */ { @@ -201,7 +207,7 @@ } static int fp_fs_list(pcb_fplibrary_t *pl, const char *subdir, int recurse, - int (*cb) (void *cookie, const char *subdir, const char *name, pcb_fptype_t type, void *tags[], pcb_plug_fp_map_t *children), + int (*cb)(void *cookie, const char *subdir, const char *name, pcb_fptype_t type, void *tags[], pcb_plug_fp_map_t *children, const char *fmt), void *cookie, int subdir_may_not_exist, int need_tags) { char olddir[RND_PATH_MAX + 1]; /* The directory we start out in (cwd) */ @@ -270,13 +276,14 @@ strcpy(fn_end, subdirentry->d_name); if ((S_ISREG(buffer.st_mode)) || (RND_WRAP_S_ISLNK(buffer.st_mode))) { pcb_plug_fp_map_t *res; - res = pcb_io_map_footprint_file_cached(&PCB->hidlib, &fp_fs_cache, &buffer, fn); + const char *fmt; + res = pcb_io_map_footprint_file_cached(&PCB->hidlib, &fp_fs_cache, &buffer, fn, &fmt); if (res->libtype == PCB_LIB_DIR) { - cb(cookie, new_subdir, subdirentry->d_name, PCB_FP_FILEDIR, NULL, res->next); + cb(cookie, new_subdir, subdirentry->d_name, PCB_FP_FILEDIR, NULL, res->next, fmt); } else if ((res->libtype == PCB_LIB_FOOTPRINT) && ((res->type == PCB_FP_FILE) || (res->type == PCB_FP_PARAMETRIC))) { n_footprints++; - if (cb(cookie, new_subdir, subdirentry->d_name, res->type, (void **)res->tags.array, NULL)) + if (cb(cookie, new_subdir, subdirentry->d_name, res->type, (void **)res->tags.array, NULL, fmt)) break; continue; } @@ -283,7 +290,7 @@ } if ((S_ISDIR(buffer.st_mode)) || (RND_WRAP_S_ISLNK(buffer.st_mode))) { - cb(cookie, new_subdir, subdirentry->d_name, PCB_FP_DIR, NULL, NULL); + cb(cookie, new_subdir, subdirentry->d_name, PCB_FP_DIR, NULL, NULL, NULL); if (recurse) { n_footprints += fp_fs_list(pl, fn, recurse, cb, cookie, 0, need_tags); } @@ -299,7 +306,7 @@ return n_footprints; } -static int fp_fs_load_dir_(pcb_fplibrary_t *pl, const char *subdir, const char *toppath, int is_root, pcb_plug_fp_map_t *children) +static int fp_fs_load_dir_(pcb_fplibrary_t *pl, const char *subdir, const char *toppath, int is_root, pcb_plug_fp_map_t *children, const char *parent_fmt) { list_st_t l; list_dir_t *d, *nextd; @@ -332,7 +339,7 @@ pcb_plug_fp_map_t *n; l.is_virtual_dir = 1; for(n = children; n != NULL; n = n->next) { - list_cb(&l, working, n->name, n->type, (void **)n->tags.array, NULL); + list_cb(&l, working, n->name, n->type, (void **)n->tags.array, NULL, parent_fmt); l.children++; } free(working); @@ -344,7 +351,7 @@ /* now recurse to each subdirectory mapped in the previous call; by now we don't care if menu is ruined by the realloc() in pcb_lib_menu_new() */ for (d = l.subdirs; d != NULL; d = nextd) { - l.children += fp_fs_load_dir_(l.menu, d->subdir, d->parent, 0, d->children); + l.children += fp_fs_load_dir_(l.menu, d->subdir, d->parent, 0, d->children, d->fmt); nextd = d->next; free(d->subdir); free(d->parent); @@ -361,7 +368,7 @@ { int res; - res = fp_fs_load_dir_(&pcb_library, ".", path, 1, NULL); + res = fp_fs_load_dir_(&pcb_library, ".", path, 1, NULL, NULL); if (res >= 0) { pcb_fplibrary_t *l = pcb_fp_lib_search(&pcb_library, path); if ((l != NULL) && (l->type == PCB_LIB_DIR)) @@ -378,7 +385,7 @@ char *real_name; } fp_search_t; -static int fp_search_cb(void *cookie, const char *subdir, const char *name, pcb_fptype_t type, void *tags[], pcb_plug_fp_map_t *children) +static int fp_search_cb(void *cookie, const char *subdir, const char *name, pcb_fptype_t type, void *tags[], pcb_plug_fp_map_t *children, const char *fmt) { fp_search_t *ctx = (fp_search_t *) cookie; if ((strncmp(ctx->target, name, ctx->target_len) == 0) && ((! !ctx->parametric) == (type == PCB_FP_PARAMETRIC))) { Index: trunk/src_plugins/fp_wget/edakrill.c =================================================================== --- trunk/src_plugins/fp_wget/edakrill.c (revision 35756) +++ trunk/src_plugins/fp_wget/edakrill.c (revision 35757) @@ -109,7 +109,7 @@ l = pcb_fp_mkdir_p(vpath->array); if (krill.tags != NULL) tag_add_(NULL); - l = pcb_fp_append_entry(l, fn, PCB_FP_FILE, krill.tags, 0); + l = pcb_fp_append_entry(l, fn, PCB_FP_FILE, krill.tags, 0, NULL); fn[-1] = '/'; l->data.fp.loc_info = rnd_strdup(vpath->array); Index: trunk/src_plugins/fp_wget/gedasymbols.c =================================================================== --- trunk/src_plugins/fp_wget/gedasymbols.c (revision 35756) +++ trunk/src_plugins/fp_wget/gedasymbols.c (revision 35757) @@ -136,7 +136,7 @@ /* add to the database */ l = pcb_fp_mkdir_p(vpath.array); - l = pcb_fp_append_entry(l, fn, PCB_FP_FILE, NULL, 0); + l = pcb_fp_append_entry(l, fn, PCB_FP_FILE, NULL, 0, NULL); fn[-1] = '/'; l->data.fp.loc_info = rnd_strdup(vpath.array); } Index: trunk/src_plugins/fp_wget/tester.c =================================================================== --- trunk/src_plugins/fp_wget/tester.c (revision 35756) +++ trunk/src_plugins/fp_wget/tester.c (revision 35757) @@ -15,7 +15,7 @@ return (library_t *)<mp; } -pcb_library_t *pcb_fp_append_entry(library_t *parent, const char *name, pcb_fp_type_t type, void *tags[], rnd_bool dup_tags) +pcb_library_t *pcb_fp_append_entry(library_t *parent, const char *name, pcb_fp_type_t type, void *tags[], rnd_bool dup_tags, const char *fmt) { printf("lib entry: '%s'\n", name); return (library_t *)<mp;