Index: trunk/src_plugins/fp_wget/Makefile =================================================================== --- trunk/src_plugins/fp_wget/Makefile (revision 1571) +++ trunk/src_plugins/fp_wget/Makefile (revision 1572) @@ -1,2 +1,4 @@ -CFLAGS = -Wall -g -I../../src -tester: tester.o gedasymbols.o fp_wget.o +CFLAGS = -Wall -g -I../../src -I../.. -I../../src_3rd + +tester: tester.o gedasymbols.o fp_wget.o ../../src_3rd/genvector/gds_char.o + Index: trunk/src_plugins/fp_wget/fp_wget.c =================================================================== --- trunk/src_plugins/fp_wget/fp_wget.c (revision 1571) +++ trunk/src_plugins/fp_wget/fp_wget.c (revision 1572) @@ -10,7 +10,7 @@ }; const char *wget_cmd = "wget -U 'pcb-rnd-fp_wget'"; -int fp_wget_offline = 1; +int fp_wget_offline = 0; static int mkdirp(const char *dir) { @@ -93,3 +93,4 @@ return -1; } + Index: trunk/src_plugins/fp_wget/gedasymbols.c =================================================================== --- trunk/src_plugins/fp_wget/gedasymbols.c (revision 1571) +++ trunk/src_plugins/fp_wget/gedasymbols.c (revision 1572) @@ -1,12 +1,19 @@ #include #include #include +#include +#include "global.h" #include "fp_wget.h" #include "gedasymbols.h" +#include "plugins.h" +#include "plug_footprint.h" + #define REQUIRE_PATH_PREFIX "gedasymbols://" #define CGI_URL "http://www.gedasymbols.org/scripts/global_list.cgi" +#define FP_URL "http://www.gedasymbols.org/" +#define FP_DL "?dl" static const char *url_idx_md5 = CGI_URL "?md5"; static const char *url_idx_list = CGI_URL; static const char *gedasym_cache = "fp_wget_cache"; @@ -101,5 +108,47 @@ return 0; } +#define FIELD_WGET_CTX 0 +FILE *fp_gedasymbols_fopen(plug_fp_t *ctx, const char *path, const char *name, fp_fopen_ctx_t *fctx) +{ + gds_t s; + gds_init(&s); + FILE *f; + if (strncmp(path, "gedasymbols/", 12) == 0) + path+=12; + if (*path == '/') + path++; + + gds_append_str(&s, FP_URL); + gds_append_str(&s, path); + gds_append(&s, '/'); + gds_append_str(&s, name); + gds_append_str(&s, FP_DL); + + fp_wget_open(s.array, gedasym_cache, &f, &(fctx->field[FIELD_WGET_CTX].i), 1); + + gds_uninit(&s); + return f; +} + +void fp_gedasymbols_fclose(plug_fp_t *ctx, FILE * f, fp_fopen_ctx_t *fctx) +{ + fp_wget_close(&f, &(fctx->field[FIELD_WGET_CTX].i)); +} + + +static plug_fp_t fp_wget; + +void fp_gedasymbols_init(void) +{ + fp_wget.plugin_data = NULL; + fp_wget.load_dir = fp_gedasymbols_load_dir; + fp_wget.fopen = fp_gedasymbols_fopen; + fp_wget.fclose = fp_gedasymbols_fclose; + + HOOK_REGISTER(plug_fp_t, plug_fp_chain, &fp_wget); + + return NULL; +} Index: trunk/src_plugins/fp_wget/gedasymbols.h =================================================================== --- trunk/src_plugins/fp_wget/gedasymbols.h (revision 1571) +++ trunk/src_plugins/fp_wget/gedasymbols.h (revision 1572) @@ -1,3 +1,5 @@ #include "plug_footprint.h" int fp_gedasymbols_load_dir(plug_fp_t *ctx, const char *path); +FILE *fp_gedasymbols_fopen(plug_fp_t *ctx, const char *path, const char *name, fp_fopen_ctx_t *fctx); +void fp_gedasymbols_fclose(plug_fp_t *ctx, FILE * f, fp_fopen_ctx_t *fctx); Index: trunk/src_plugins/fp_wget/tester.c =================================================================== --- trunk/src_plugins/fp_wget/tester.c (revision 1571) +++ trunk/src_plugins/fp_wget/tester.c (revision 1572) @@ -1,6 +1,22 @@ #include +#include "global.h" #include "gedasymbols.h" + +plug_fp_t *plug_fp_chain = NULL; + int main() { - fp_gedasymbols_load_dir(NULL, "gedasymbols://"); + fp_fopen_ctx_t fctx; + FILE *f; + char line[1024]; + +// fp_gedasymbols_load_dir(NULL, "gedasymbols://"); + f = fp_gedasymbols_fopen(NULL, "user/sean_depagnier/footprints", "HDMI_CONN.fp", &fctx); + + while(fgets(line, sizeof(line), f) != NULL) + printf("|%s", line); + + fp_gedasymbols_fclose(NULL, f, &fctx); + } +