Mercurial > hg > toybox
comparison toys/other/sha1sum.c @ 674:7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 08 Oct 2012 00:02:30 -0500 |
parents | b88859043af2 |
children | 522ec2aad996 |
comparison
equal
deleted
inserted
replaced
673:c102f31a753e | 674:7e846e281e38 |
---|---|
16 usage: sha1sum [file...] | 16 usage: sha1sum [file...] |
17 | 17 |
18 Calculate sha1 hash of files (or stdin). | 18 Calculate sha1 hash of files (or stdin). |
19 */ | 19 */ |
20 | 20 |
21 #define FOR_sha1sum | |
21 #include <toys.h> | 22 #include <toys.h> |
22 | 23 |
23 DEFINE_GLOBALS( | 24 GLOBALS( |
24 uint32_t state[5]; | 25 uint32_t state[5]; |
25 uint32_t oldstate[5]; | 26 uint32_t oldstate[5]; |
26 uint64_t count; | 27 uint64_t count; |
27 union { | 28 union { |
28 unsigned char c[64]; | 29 unsigned char c[64]; |
29 uint32_t i[16]; | 30 uint32_t i[16]; |
30 } buffer; | 31 } buffer; |
31 ) | 32 ) |
32 | |
33 #define TT this.sha1sum | |
34 | 33 |
35 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) | 34 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) |
36 | 35 |
37 // blk0() and blk() perform the initial expand. | 36 // blk0() and blk() perform the initial expand. |
38 // The idea of expanding during the round function comes from SSLeay | 37 // The idea of expanding during the round function comes from SSLeay |