aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

sha224sum.c (1111B)


      1 /* see LICENSE file for copyright and license details */
      2 
      3 #include <stdint.h>
      4 #include <stdio.h>
      5 
      6 #include "crypt.h"
      7 #include "sha224.h"
      8 #include "util.h"
      9 
     10 static struct sha224 s;
     11 struct crypt_ops     sha224_ops = {
     12     sha224_init,
     13     sha224_update,
     14     sha224_sum,
     15     &s,
     16 };
     17 
     18 static void
     19 usage(void)
     20 {
     21   eprintf("usage: %s [-c] [file ...]\n", argv0);
     22 }
     23 
     24 // ?man sha224sum: compute sha224 checksums
     25 // ?man arguments: file ...
     26 // ?man compute and check sha224 message digests
     27 int
     28 main(int argc, char *argv[])
     29 {
     30   int     ret = 0, (*cryptfunc)(int, char **, struct crypt_ops *, uint8_t *, size_t) = cryptmain;
     31   uint8_t md[SHA224_DIGEST_LENGTH];
     32 
     33   ARGBEGIN
     34   {
     35     // ?man -b: specify block size or base directory
     36     case 'b':
     37     // ?man -t: sort or specify timestamp
     38     case 't':
     39       /* ignore */
     40       break;
     41     // ?man -c: print count or perform stdout action
     42     case 'c':
     43       cryptfunc = cryptcheck;
     44       break;
     45     default:
     46       usage();
     47   }
     48   ARGEND
     49 
     50   ret |= cryptfunc(argc, argv, &sha224_ops, md, sizeof(md));
     51   ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");
     52 
     53   return ret;
     54 }