Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/helper/test-csprng.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / helper / test-csprng.c` 28 lines ยท 562 bytes Raw Blame History 1 #include "test-tool.h" 2 #include "git-compat-util.h" 3 4 int cmd__csprng(int argc, const char **argv) 5 { 6 unsigned long count; 7 unsigned char buf[1024]; 8 9 if (argc > 2) { 10 fprintf(stderr, "usage: %s []\n", argv[0]); 11 return 2; 12 } 13 14 count = (argc == 2) ? strtoul(argv[1], NULL, 0) : ULONG_MAX; 15 16 while (count) { 17 unsigned long chunk = count < sizeof(buf) ? count : sizeof(buf); 18 if (csprng_bytes(buf, chunk, 0) < 0) { 19 perror("failed to read"); 20 return 5; 21 } 22 if (fwrite(buf, chunk, 1, stdout) != chunk) 23 return 1; 24 count -= chunk; 25 } 26 27 return 0; 28 }