2 #include "git-compat-util.h"
5 int cmd__csprng(int argc
, const char **argv
)
8 unsigned char buf
[1024];
11 fprintf(stderr
, "usage: %s [<size>]\n", argv
[0]);
15 count
= (argc
== 2) ? strtoul(argv
[1], NULL
, 0) : -1L;
18 unsigned long chunk
= count
< sizeof(buf
) ? count
: sizeof(buf
);
19 if (csprng_bytes(buf
, chunk
) < 0) {
20 perror("failed to read");
23 if (fwrite(buf
, chunk
, 1, stdout
) != chunk
)