From 236c6755d2532cc20e31f4ff4f19cdaa4bde078c Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 6 Aug 2006 02:13:36 +0000 Subject: Teach md5sum and sha1sum to work the way other applets do so I don't have to teach scripts/individual new tricks. And while I'm at it, teach scripts/individual other new tricks. Now builds 198 applets, some of which I should teach it to hardlink together because they're really the same app... --- coreutils/md5_sha1_sum.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'coreutils') diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 49766a925..6226e0988 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c @@ -81,12 +81,16 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo) return hash_value; } -/* This could become a common function for md5 as well, by using md5_stream */ -static int hash_files(int argc, char **argv, hash_algo_t hash_algo) +int md5_sha1_sum_main(int argc, char **argv) { int return_value = EXIT_SUCCESS; uint8_t *hash_value; unsigned int flags; + hash_algo_t hash_algo = ENABLE_MD5SUM ? + (ENABLE_SHA1SUM ? + (**argv=='m' ? HASH_MD5 : HASH_SHA1) + : HASH_MD5) + : HASH_SHA1; if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK) flags = bb_getopt_ulflags(argc, argv, "scw"); @@ -178,17 +182,3 @@ static int hash_files(int argc, char **argv, hash_algo_t hash_algo) } return (return_value); } - -#ifdef CONFIG_MD5SUM -int md5sum_main(int argc, char **argv) -{ - return (hash_files(argc, argv, HASH_MD5)); -} -#endif - -#ifdef CONFIG_SHA1SUM -int sha1sum_main(int argc, char **argv) -{ - return (hash_files(argc, argv, HASH_SHA1)); -} -#endif -- cgit v1.2.3