diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.in | 3 | ||||
-rw-r--r-- | scripts/fetch.c | 38 |
2 files changed, 35 insertions, 6 deletions
diff --git a/scripts/Makefile.in b/scripts/Makefile.in index 891555dcd..b1a790b0e 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -263,6 +263,8 @@ nm_ca_dir = @nm_ca_dir@ oldincludedir = @oldincludedir@ openac_plugins = @openac_plugins@ p_plugins = @p_plugins@ +pcsclite_CFLAGS = @pcsclite_CFLAGS@ +pcsclite_LIBS = @pcsclite_LIBS@ pdfdir = @pdfdir@ piddir = @piddir@ pki_plugins = @pki_plugins@ @@ -286,6 +288,7 @@ soup_LIBS = @soup_LIBS@ srcdir = @srcdir@ strongswan_conf = @strongswan_conf@ sysconfdir = @sysconfdir@ +systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ diff --git a/scripts/fetch.c b/scripts/fetch.c index 57abce4ca..ad50d0cd6 100644 --- a/scripts/fetch.c +++ b/scripts/fetch.c @@ -19,6 +19,18 @@ #include <library.h> #include <debug.h> +static int count = 0; + +static bool cb(void *userdata, chunk_t chunk) +{ + if (write(1, chunk.ptr, chunk.len) == chunk.len) + { + count++; + return TRUE; + } + return FALSE; +} + int main(int argc, char *argv[]) { chunk_t res; @@ -27,15 +39,29 @@ int main(int argc, char *argv[]) atexit(library_deinit); lib->plugins->load(lib->plugins, NULL, PLUGINS); - if (argc != 2) + if (argc != 3 || (!streq(argv[1], "a") && !streq(argv[1], "s"))) + { + fprintf(stderr, "usage: %s a|s <url>\n", argv[0]); + return 1; + } + if (streq(argv[1], "a")) { - fprintf(stderr, "usage: %s <url>\n", argv[0]); + if (lib->fetcher->fetch(lib->fetcher, argv[2], &res, + FETCH_END) == SUCCESS) + { + ignore_result(write(1, res.ptr, res.len)); + free(res.ptr); + return 0; + } } - if (lib->fetcher->fetch(lib->fetcher, argv[1], &res, FETCH_END) == SUCCESS) + else { - ignore_result(write(1, res.ptr, res.len)); - free(res.ptr); - return 0; + if (lib->fetcher->fetch(lib->fetcher, argv[2], NULL, + FETCH_CALLBACK, cb, FETCH_END) == SUCCESS) + { + fprintf(stderr, "received %d chunks\n", count); + return 0; + } } return 1; } |