mirror of
https://github.com/void-linux/void-packages.git
synced 2025-07-27 07:52:55 +02:00
xbps-digest: accept any number of arbitrary files in argv.
--HG-- extra : convert_revision : 42a96b8435a2508a06b48f327f25dc97e16db233
This commit is contained in:
parent
5803db23a3
commit
de67397983
1 changed files with 24 additions and 21 deletions
|
@ -39,6 +39,7 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <libgen.h>
|
||||
|
||||
typedef uint8_t sha2_byte; /* Exactly 1 byte */
|
||||
typedef uint32_t sha2_word32; /* Exactly 4 bytes */
|
||||
|
@ -414,7 +415,7 @@ SHA256_End(SHA256_CTX *ctx, uint8_t *buffer)
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: xbps-digest <file>\n");
|
||||
fprintf(stderr, "usage: xbps-digest <file> <file1+N> ...\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -424,13 +425,14 @@ main(int argc, char **argv)
|
|||
SHA256_CTX ctx;
|
||||
uint8_t buffer[BUFSIZ * 20], *digest;
|
||||
ssize_t bytes;
|
||||
int fd;
|
||||
int i, fd;
|
||||
|
||||
if (argc != 2)
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
if ((fd = open(argv[1], O_RDONLY)) == -1) {
|
||||
printf("xbps-digest: cannot open %s (%s)\n", argv[1],
|
||||
for (i = 1; i < argc; i++) {
|
||||
if ((fd = open(argv[i], O_RDONLY)) == -1) {
|
||||
printf("xbps-digest: cannot open %s (%s)\n", argv[i],
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
@ -448,6 +450,7 @@ main(int argc, char **argv)
|
|||
printf("%s\n", SHA256_End(&ctx, digest));
|
||||
free(digest);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue