libxbps: ABI/API break due to hash function changes

This commit is contained in:
Duncan Overbruck
2020-02-10 01:54:52 +01:00
parent aa4d726dca
commit 0d90534236
18 changed files with 141 additions and 118 deletions

View File

@@ -53,7 +53,7 @@ int
main(int argc, char **argv)
{
int c;
char *hash = NULL;
char sha256[XBPS_SHA256_SIZE];
const char *mode = NULL, *progname = argv[0];
const struct option longopts[] = {
{ NULL, 0, NULL, 0 }
@@ -84,23 +84,19 @@ main(int argc, char **argv)
}
if (argc < 1) {
hash = xbps_file_hash("/dev/stdin");
if (hash == NULL)
if (!xbps_file_sha256(sha256, sizeof sha256, "/dev/stdin"))
exit(EXIT_FAILURE);
printf("%s\n", hash);
free(hash);
printf("%s\n", sha256);
} else {
for (int i = 0; i < argc; i++) {
hash = xbps_file_hash(argv[i]);
if (hash == NULL) {
if (!xbps_file_sha256(sha256, sizeof sha256, argv[i])) {
fprintf(stderr,
"%s: couldn't get hash for %s (%s)\n",
progname, argv[i], strerror(errno));
exit(EXIT_FAILURE);
}
printf("%s\n", hash);
free(hash);
printf("%s\n", sha256);
}
}
exit(EXIT_SUCCESS);