aboutsummaryrefslogtreecommitdiff
path: root/src/download.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/download.c')
-rw-r--r--src/download.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/download.c b/src/download.c
index 0554ee5..814fe36 100644
--- a/src/download.c
+++ b/src/download.c
@@ -1,4 +1,26 @@
+/*
+
+ pow! - the pow!erful package manager
+
+ Copyright (C) 2026 forever2k38
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+*/
+
#include "hash.h"
+#include "log.h"
#include "package.h"
#include "curl/curl.h"
@@ -17,7 +39,7 @@ int pow_download_file(char *path, char *url) {
CURL *curl = curl_easy_init();
if (!curl) {
- printf("failed to init curl\n");
+ pow_log_error("failed to init curl");
return 1;
}
@@ -32,7 +54,7 @@ int pow_download_file(char *path, char *url) {
pagefile = fopen(path, "wb");
if (!pagefile) {
- printf("failed to open file to download\n");
+ pow_log_error("failed to open file to download");
curl_easy_cleanup(curl);
@@ -56,10 +78,10 @@ int pow_download_source(pow_package_source *src, const char *prefix) {
snprintf(full_path, len, "%s/%s", prefix, src->out);
- printf("downloading source file: %s", src->in);
+ pow_log_info("downloading source file: %s", src->in);
if (pow_download_file(full_path, src->in)) {
- printf("failed to download sources, aborting\n");
+ pow_log_error("failed to download sources, aborting");
free(full_path);
@@ -67,15 +89,15 @@ int pow_download_source(pow_package_source *src, const char *prefix) {
}
if (pow_check_blake2b_hash(full_path, src->hash)) {
- printf("hash mismatch. something is going wrong with downloading the file "
- "or it may be tampered with.\n");
+ pow_log_error("hash mismatch. something is going wrong with downloading the file "
+ "or it may be tampered with.");
free(full_path);
return 1;
}
- printf("hash verification succeeded, going through.");
+ pow_log_info("hashes match, %s", src->hash);
free(full_path);