aboutsummaryrefslogtreecommitdiff
path: root/src/hash.c
diff options
context:
space:
mode:
authorforever2k38 <forever2k38@forever2k38.net>2026-09-30 22:01:45 +0200
committerforever2k38 <forever2k38@forever2k38.net>2026-09-30 22:01:45 +0200
commitf113371523bc26e320e5ef8799e6ab123af9618e (patch)
treef5d095c4a4fff6e082a974a38ba06ecd2ce76bf3 /src/hash.c
parentdd064ca0270b15c728cf2061cf80b942ebe06ed9 (diff)
initial install support, better readme, relicense, and more!
Diffstat (limited to 'src/hash.c')
-rw-r--r--src/hash.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/hash.c b/src/hash.c
index 2cb0851..b302cb7 100644
--- a/src/hash.c
+++ b/src/hash.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 <blake2.h>
#include <stdint.h>
@@ -10,7 +32,7 @@ int pow_check_blake2b_hash(char *path, char *target_hash) {
FILE *fp = fopen(path, "rb");
if (!fp) {
- printf("failed to open file to check hash\n");
+ pow_log_error("failed to open file to check hash");
return 1;
}
@@ -20,7 +42,7 @@ int pow_check_blake2b_hash(char *path, char *target_hash) {
fseek(fp, 0, SEEK_SET);
if (fsize < 0) {
- printf("error: ftell\n");
+ pow_log_error("error: ftell");
fclose(fp);
@@ -33,13 +55,13 @@ int pow_check_blake2b_hash(char *path, char *target_hash) {
buf = malloc((size_t)fsize);
if (!buf) {
- fprintf(stderr, "out of memory\n");
+ pow_log_error("out of memory");
fclose(fp);
return 1;
}
if (fread(buf, 1, (size_t)fsize, fp) != (size_t)fsize) {
- fprintf(stderr, "read error\n");
+ pow_log_error("read error");
free(buf);
fclose(fp);
return 1;
@@ -50,7 +72,7 @@ int pow_check_blake2b_hash(char *path, char *target_hash) {
uint8_t digest[BLAKE2B_OUTBYTES];
if (blake2b(digest, buf, NULL, BLAKE2B_OUTBYTES, (size_t)fsize, 0) != 0) {
- fprintf(stderr, "blake2b failed\n");
+ pow_log_error("blake2b failed");
free(buf);
return 1;
}