-int opkg_download(opkg_conf_t *conf, const char *src, const char *dest_file_name)
-{
- int err = 0;
-
- char *src_basec = strdup(src);
- char *src_base = basename(src_basec);
- char *tmp_file_location;
-
- opkg_message(conf,OPKG_NOTICE,"Downloading %s\n", src);
-
- fflush(stdout);
-
- if (str_starts_with(src, "file:")) {
- int ret;
- const char *file_src = src + 5;
- opkg_message(conf,OPKG_INFO,"Copying %s to %s...", file_src, dest_file_name);
- ret = file_copy(src + 5, dest_file_name);
- opkg_message(conf,OPKG_INFO,"Done\n");
- return ret;
- }
-
- sprintf_alloc(&tmp_file_location, "%s/%s", conf->tmp_dir, src_base);
- err = unlink(tmp_file_location);
- if (err && errno != ENOENT) {
- opkg_message(conf,OPKG_ERROR, "%s: ERROR: failed to unlink %s: %s\n",
- __FUNCTION__, tmp_file_location, strerror(errno));
- free(tmp_file_location);
- return errno;
- }
-
- if (conf->http_proxy) {
- opkg_message(conf,OPKG_DEBUG,"Setting environment variable: http_proxy = %s\n", conf->http_proxy);
- setenv("http_proxy", conf->http_proxy, 1);
- }
- if (conf->ftp_proxy) {
- opkg_message(conf,OPKG_DEBUG,"Setting environment variable: ftp_proxy = %s\n", conf->ftp_proxy);
- setenv("ftp_proxy", conf->ftp_proxy, 1);
- }
- if (conf->no_proxy) {
- opkg_message(conf,OPKG_DEBUG,"Setting environment variable: no_proxy = %s\n", conf->no_proxy);
- setenv("no_proxy", conf->no_proxy, 1);
- }
-
- 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);
- curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0);
- curl_easy_setopt (curl, CURLOPT_PROGRESSDATA, src);
- curl_easy_setopt (curl, CURLOPT_PROGRESSFUNCTION, curl_progress_func);
- curl_easy_setopt (curl, CURLOPT_FAILONERROR, 1);
- if (conf->http_proxy || conf->ftp_proxy)
- {
- char *userpwd;
- sprintf_alloc (&userpwd, "%s:%s", conf->proxy_user,
- conf->proxy_passwd);
- curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
- free (userpwd);
+ if (conf->http_proxy) {
+ opkg_msg(DEBUG,
+ "Setting environment variable: http_proxy = %s.\n",
+ conf->http_proxy);
+ setenv("http_proxy", conf->http_proxy, 1);
+ }
+ if (conf->ftp_proxy) {
+ opkg_msg(DEBUG,
+ "Setting environment variable: ftp_proxy = %s.\n",
+ conf->ftp_proxy);
+ setenv("ftp_proxy", conf->ftp_proxy, 1);
+ }
+ if (conf->no_proxy) {
+ opkg_msg(DEBUG,
+ "Setting environment variable: no_proxy = %s.\n",
+ conf->no_proxy);
+ setenv("no_proxy", conf->no_proxy, 1);