diff options
Diffstat (limited to 'src/hash.c')
| -rw-r--r-- | src/hash.c | 32 |
1 files changed, 27 insertions, 5 deletions
@@ -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; } |
