Index: src_plugins/fp_wget/edakrill.c =================================================================== --- src_plugins/fp_wget/edakrill.c (revision 36849) +++ src_plugins/fp_wget/edakrill.c (revision 36850) @@ -39,6 +39,7 @@ #include "plug_footprint.h" #include #include +#include #include "fp_wget_conf.h" #include "globalconst.h" @@ -142,12 +143,15 @@ fp_get_mode wmode = FP_WGET_OFFLINE; pcb_fplibrary_t *l; char last_sum_fn[RND_PATH_MAX]; + char *cache_dir; if (strncmp(path, REQUIRE_PATH_PREFIX, strlen(REQUIRE_PATH_PREFIX)) != 0) return -1; - rnd_snprintf(last_sum_fn, sizeof(last_sum_fn), "%s" RND_DIR_SEPARATOR_S "edakrill.last", conf_fp_wget.plugins.fp_wget.cache_dir); + cache_dir = rnd_build_fn(NULL, conf_fp_wget.plugins.fp_wget.cache_dir); + rnd_snprintf(last_sum_fn, sizeof(last_sum_fn), "%s" RND_DIR_SEPARATOR_S "edakrill.last", cache_dir); + gds_init(&vpath); gds_append_str(&vpath, REQUIRE_PATH_PREFIX); @@ -158,7 +162,7 @@ if (force || (conf_fp_wget.plugins.fp_wget.auto_update_edakrill)) wmode &= ~FP_WGET_OFFLINE; - if (fp_wget_open(url_idx_md5, conf_fp_wget.plugins.fp_wget.cache_dir, &f, &fctx, wmode) != 0) { + if (fp_wget_open(url_idx_md5, cache_dir, &f, &fctx, wmode) != 0) { if (wmode & FP_WGET_OFFLINE) /* accept that we don't have the index in offline mode */ goto quit; goto err; @@ -184,7 +188,7 @@ else mode = 0; - if (fp_wget_open(url_idx_list, conf_fp_wget.plugins.fp_wget.cache_dir, &f, &fctx, mode) != 0) { + if (fp_wget_open(url_idx_list, cache_dir, &f, &fctx, mode) != 0) { rnd_message(RND_MSG_ERROR, "edakrill: failed to download the new list\n"); rnd_remove(NULL, last_sum_fn); /* make sure it is downloaded next time */ goto err; @@ -235,10 +239,12 @@ fp_wget_close(&f, &fctx); quit:; + free(cache_dir); gds_uninit(&vpath); return 0; err:; + free(cache_dir); gds_uninit(&vpath); return -1; } @@ -287,7 +293,7 @@ FILE *fp_edakrill_fopen(pcb_plug_fp_t *ctx, const char *path, const char *name, pcb_fp_fopen_ctx_t *fctx, pcb_data_t *dst) { gds_t s; - char tmp[1024]; + char tmp[1024], *cache_dir; FILE *f = NULL; int from_path = (path != NULL) && (strcmp(path, REQUIRE_PATH_PREFIX) == 0); @@ -301,8 +307,10 @@ if (*name == '/') name++; + cache_dir = rnd_build_fn(NULL, conf_fp_wget.plugins.fp_wget.cache_dir); + if (from_path) { - if (fp_wget_search(tmp, sizeof(tmp), name, !conf_fp_wget.plugins.fp_wget.auto_update_edakrill, url_idx_list, conf_fp_wget.plugins.fp_wget.cache_dir, search_edakrill) != 0) + if (fp_wget_search(tmp, sizeof(tmp), name, !conf_fp_wget.plugins.fp_wget.auto_update_edakrill, url_idx_list, cache_dir, search_edakrill) != 0) goto bad; name = tmp; } @@ -311,7 +319,7 @@ gds_append_str(&s, FP_URL); gds_append_str(&s, name); - fp_wget_open(s.array, conf_fp_wget.plugins.fp_wget.cache_dir, &f, &(fctx->field[FIELD_WGET_CTX].i), FP_WGET_UPDATE); + fp_wget_open(s.array, cache_dir, &f, &(fctx->field[FIELD_WGET_CTX].i), FP_WGET_UPDATE); gds_uninit(&s); @@ -318,6 +326,7 @@ bad:; fctx->backend = ctx; + free(cache_dir); return f; } Index: src_plugins/fp_wget/fp_wget_conf.h =================================================================== --- src_plugins/fp_wget/fp_wget_conf.h (revision 36849) +++ src_plugins/fp_wget/fp_wget_conf.h (revision 36850) @@ -8,7 +8,7 @@ const struct { RND_CFT_BOOLEAN auto_update_gedasymbols; /* update the index of gedasymbols on startup automatically */ RND_CFT_BOOLEAN auto_update_edakrill; /* update the index of edakrill on startup automatically */ - RND_CFT_STRING cache_dir; /* where to build the cache */ + RND_CFT_STRING cache_dir; /* where to build the cache (template) */ } fp_wget; } plugins; } conf_fp_wget_t; Index: src_plugins/fp_wget/gedasymbols.c =================================================================== --- src_plugins/fp_wget/gedasymbols.c (revision 36849) +++ src_plugins/fp_wget/gedasymbols.c (revision 36850) @@ -39,6 +39,7 @@ #include "plug_footprint.h" #include #include +#include #include "fp_wget_conf.h" #include "globalconst.h" @@ -62,13 +63,15 @@ int vpath_base_len; fp_get_mode wmode = FP_WGET_OFFLINE; pcb_fplibrary_t *l; - char last_sum_fn[RND_PATH_MAX]; + char last_sum_fn[RND_PATH_MAX], *cache_dir; if (strncmp(path, REQUIRE_PATH_PREFIX, strlen(REQUIRE_PATH_PREFIX)) != 0) return -1; - rnd_snprintf(last_sum_fn, sizeof(last_sum_fn), "%s" RND_DIR_SEPARATOR_S "gedasymbols.last", conf_fp_wget.plugins.fp_wget.cache_dir); + cache_dir = rnd_build_fn(NULL, conf_fp_wget.plugins.fp_wget.cache_dir); + rnd_snprintf(last_sum_fn, sizeof(last_sum_fn), "%s" RND_DIR_SEPARATOR_S "gedasymbols.last", cache_dir); + gds_init(&vpath); gds_append_str(&vpath, REQUIRE_PATH_PREFIX); @@ -79,7 +82,7 @@ if (force || (conf_fp_wget.plugins.fp_wget.auto_update_gedasymbols)) wmode &= ~FP_WGET_OFFLINE; - if (fp_wget_open(url_idx_md5, conf_fp_wget.plugins.fp_wget.cache_dir, &f, &fctx, wmode) != 0) { + if (fp_wget_open(url_idx_md5, cache_dir, &f, &fctx, wmode) != 0) { if (wmode & FP_WGET_OFFLINE) /* accept that we don't have the index in offline mode */ goto quit; goto err; @@ -105,7 +108,7 @@ else mode = 0; - if (fp_wget_open(url_idx_list, conf_fp_wget.plugins.fp_wget.cache_dir, &f, &fctx, mode) != 0) { + if (fp_wget_open(url_idx_list, cache_dir, &f, &fctx, mode) != 0) { rnd_message(RND_MSG_ERROR, "gedasymbols: failed to download the new list\n"); rnd_remove(NULL, last_sum_fn); /* make sure it is downloaded next time */ goto err; @@ -143,10 +146,12 @@ fp_wget_close(&f, &fctx); quit:; + free(cache_dir); gds_uninit(&vpath); return 0; err:; + free(cache_dir); gds_uninit(&vpath); return -1; } @@ -180,7 +185,7 @@ FILE *fp_gedasymbols_fopen(pcb_plug_fp_t *ctx, const char *path, const char *name, pcb_fp_fopen_ctx_t *fctx, pcb_data_t *dst) { gds_t s; - char tmp[1024]; + char tmp[1024], *cache_dir; FILE *f = NULL; int from_path = (path != NULL) && (strcmp(path, REQUIRE_PATH_PREFIX) == 0); @@ -191,11 +196,13 @@ return NULL; } + cache_dir = rnd_build_fn(NULL, conf_fp_wget.plugins.fp_wget.cache_dir); + if (*name == '/') name++; if (from_path) { - if (fp_wget_search(tmp, sizeof(tmp), name, !conf_fp_wget.plugins.fp_wget.auto_update_gedasymbols, url_idx_list, conf_fp_wget.plugins.fp_wget.cache_dir, search_gedasyms) != 0) + if (fp_wget_search(tmp, sizeof(tmp), name, !conf_fp_wget.plugins.fp_wget.auto_update_gedasymbols, url_idx_list, cache_dir, search_gedasyms) != 0) goto bad; name = tmp; } @@ -205,7 +212,7 @@ gds_append_str(&s, name); gds_append_str(&s, FP_DL); - fp_wget_open(s.array, conf_fp_wget.plugins.fp_wget.cache_dir, &f, &(fctx->field[FIELD_WGET_CTX].i), FP_WGET_UPDATE); + fp_wget_open(s.array, cache_dir, &f, &(fctx->field[FIELD_WGET_CTX].i), FP_WGET_UPDATE); gds_uninit(&s); @@ -212,6 +219,7 @@ bad:; fctx->backend = ctx; + free(cache_dir); return f; }