Index: trunk/src_plugins/fp_wget/wget_common.c =================================================================== --- trunk/src_plugins/fp_wget/wget_common.c (revision 26261) +++ trunk/src_plugins/fp_wget/wget_common.c (revision 26262) @@ -33,6 +33,10 @@ #include "safe_fs.h" #include "globalconst.h" +#include "../src_plugins/lib_wget/lib_wget.h" + +int fp_wget_offline = 0; + enum { FCTX_INVALID = 0, FCTX_POPEN, @@ -40,9 +44,6 @@ FCTX_NOP }; -const char *wget_cmd = "wget -U 'pcb-rnd-fp_wget'"; -int fp_wget_offline = 0; - static int mkdirp(const char *dir) { int len; @@ -53,39 +54,13 @@ return pcb_system(NULL, buff); } -static char *pcb_wget_command(const char *url, const char *ofn, int update) -{ - const char *upds = update ? "-c" : ""; - return pcb_strdup_printf("%s -O '%s' %s '%s'", wget_cmd, ofn, upds, url); -} - -int pcb_wget_disk(const char *url, const char *ofn, int update) -{ - int res; - char *cmd = pcb_wget_command(url, ofn, update); - - res = pcb_system(NULL, cmd); - free(cmd); - return res; -} - -FILE *pcb_wget_popen(const char *url, int update) -{ - FILE *f; - char *cmd = pcb_wget_command(url, "-", update); - - f = pcb_popen(NULL, cmd, "rb"); - free(cmd); - return f; -} - int fp_wget_open(const char *url, const char *cache_path, FILE **f, int *fctx, fp_get_mode mode) { char *cmd; - int wl = strlen(wget_cmd), ul = strlen(url), cl = strlen(cache_path); + int ul = strlen(url), cl = strlen(cache_path); int update = (mode & FP_WGET_UPDATE); - cmd = malloc(wl+ul*2+cl+32); + cmd = malloc(ul*2+cl+32); *fctx = FCTX_INVALID; if (cache_path == NULL) { Index: trunk/src_plugins/lib_wget/lib_wget.c =================================================================== --- trunk/src_plugins/lib_wget/lib_wget.c (revision 26261) +++ trunk/src_plugins/lib_wget/lib_wget.c (revision 26262) @@ -30,9 +30,38 @@ #include "pcb-printf.h" #include "plugins.h" +#include "safe_fs.h" +const char *wget_cmd = "wget -U 'pcb-rnd-fp_wget'"; +static char *pcb_wget_command(const char *url, const char *ofn, int update) +{ + const char *upds = update ? "-c" : ""; + return pcb_strdup_printf("%s -O '%s' %s '%s'", wget_cmd, ofn, upds, url); +} +int pcb_wget_disk(const char *url, const char *ofn, int update) +{ + int res; + char *cmd = pcb_wget_command(url, ofn, update); + + res = pcb_system(NULL, cmd); + free(cmd); + return res; +} + +FILE *pcb_wget_popen(const char *url, int update) +{ + FILE *f; + char *cmd = pcb_wget_command(url, "-", update); + + f = pcb_popen(NULL, cmd, "rb"); + free(cmd); + return f; +} + + + int pplg_check_ver_lib_wget(int ver_needed) { return 0; } void pplg_uninit_lib_wget(void) Index: trunk/src_plugins/lib_wget/lib_wget.h =================================================================== --- trunk/src_plugins/lib_wget/lib_wget.h (revision 26261) +++ trunk/src_plugins/lib_wget/lib_wget.h (revision 26262) @@ -24,3 +24,16 @@ * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") */ +#ifndef PCB_LIB_WGET +#define PCB_LIB_WGET + +/* download the document at url to a local file ofn; if update is non-zero, + try to continue the download or update the file */ +int pcb_wget_disk(const char *url, const char *ofn, int update); + + +/* download and stream the document at url; if update is non-zero, + try to continue the download or update the file */ +FILE *pcb_wget_popen(const char *url, int update); + +#endif