diff options
author | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-14 23:15:16 (EST) |
---|---|---|
committer | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-14 23:15:16 (EST) |
commit | eef75353e6b3cef736cce9f2199450b5c936d2a4 (patch) | |
tree | a42d28814dbd0b2ed05f3032ce85525a2b902632 | |
parent | d78a1ab67d0262d09cdcc34844cc3d96af737165 (diff) |
ipkg: replace wget with libcurl functions
git-svn-id: http://opkg.googlecode.com/svn/trunk@5 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | ipkg_download.c | 21 |
3 files changed, 25 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index d876dd5..4f820d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,7 +52,7 @@ libipkg_include_HEADERS= \ #\ replace/replace.h #libipkg_la_LIBADD = libbb/libbb.la replace/libreplace.a -libipkg_la_LIBADD = libbb/libbb.la +libipkg_la_LIBADD = libbb/libbb.la $(CURL_LIBS) ipkg_core_sources = args.c args.h ipkg.c \ user.c user.h @@ -97,9 +97,9 @@ libipkg_la_SOURCES = $(ipkg_libcore_sources) $(ipkg_cmd_sources) $(ipkg_db_sourc ipkg_cl_SOURCES = ipkg-frontend.c -libipkg_la_CFLAGS = -DIPKG_LIB $(ALL_CFLAGS) +libipkg_la_CFLAGS = -DIPKG_LIB $(ALL_CFLAGS) $(CURL_CFLAGS) -ipkg_CFLAGS = $(ALL_CFLAGS) +ipkg_CFLAGS = $(ALL_CFLAGS) $(CURL_CFLAGS) ipkg_cl_CFLAGS = -DIPKG_LIB $(ALL_CFLAGS) diff --git a/configure.ac b/configure.ac index a5615ca..810db5c 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,7 @@ AM_PROG_INSTALL_STRIP AC_PROG_LIBTOOL # Checks for libraries (hah! ipkg is pretty much self-contained) +PKG_CHECK_MODULES(CURL, libcurl) # Checks for header files AC_HEADER_DIRENT diff --git a/ipkg_download.c b/ipkg_download.c index 6369008..192c8b3 100644 --- a/ipkg_download.c +++ b/ipkg_download.c @@ -1,3 +1,4 @@ +/* vi: set noexpandtab sw=4 sts=4: */ /* ipkg_download.c - the itsy package management system Carl D. Worth @@ -15,6 +16,8 @@ General Public License for more details. */ +#include <curl/curl.h> + #include "ipkg.h" #include "ipkg_download.h" #include "ipkg_message.h" @@ -69,6 +72,7 @@ int ipkg_download(ipkg_conf_t *conf, const char *src, const char *dest_file_name } /* XXX: BUG rewrite to use execvp or else busybox's internal wget -Jamey 7/23/2002 */ +#if 0 sprintf_alloc(&cmd, "wget --passive-ftp %s %s%s %s%s %s -P %s %s", (conf->http_proxy || conf->ftp_proxy) ? "--proxy=on" : "", conf->proxy_user ? "--proxy-user=" : "", @@ -91,6 +95,23 @@ int ipkg_download(ipkg_conf_t *conf, const char *src, const char *dest_file_name return EINVAL; } free(cmd); +#endif + CURL *curl; + CURLcode res; + FILE * file = fopen (tmp_file_location, "w"); + + curl = curl_easy_init (); + if (curl) + { + curl_easy_setopt (curl, CURLOPT_URL, src); + curl_easy_setopt (curl, CURLOPT_WRITEDATA, file); + res = curl_easy_perform (curl); + curl_easy_cleanup (curl); + fclose (file); + + } + else + return -1; err = file_move(tmp_file_location, dest_file_name); |