Skip to content

Commit d12764e

Browse files
author
d06i
committed
cli: add seed parameter
1 parent 781482a commit d12764e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

cli/xxhsum.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ static int XSUM_algoBitmask_Accepts(XSUM_U32 algoBitmask, AlgoSelected parsedLin
210210
* File Hashing
211211
**********************************************************/
212212

213-
#define XXHSUM32_DEFAULT_SEED 0 /* Default seed for algo_xxh32 */
214-
#define XXHSUM64_DEFAULT_SEED 0 /* Default seed for algo_xxh64 */
213+
XSUM_U32 XXHSUM32_DEFAULT_SEED = 0; /* Default seed for algo_xxh32 */
214+
XSUM_U64 XXHSUM64_DEFAULT_SEED = 0; /* Default seed for algo_xxh64 */
215215

216216
/* for support of --little-endian display mode */
217217
static void XSUM_display_LittleEndian(const void* ptr, size_t length)
@@ -1395,7 +1395,7 @@ static int XSUM_usage(const char* exename)
13951395
XSUM_log( " 0: XXH32 \n");
13961396
XSUM_log( " 1: XXH64 \n");
13971397
XSUM_log( " 2: XXH128 (also called XXH3_128bits) \n");
1398-
XSUM_log( " 3: XXH3 (also called XXH3_64bits) \n");
1398+
XSUM_log( " 3: XXH3 (also called XXH3_64bits) \n");
13991399
XSUM_log( " -c, --check read xxHash checksum from [files] and check them \n");
14001400
XSUM_log( " --files-from generate hashes for files listed in [files] \n");
14011401
XSUM_log( " --filelist generate hashes for files listed in [files] \n");
@@ -1412,6 +1412,7 @@ static int XSUM_usage_advanced(const char* exename)
14121412
XSUM_log( " --tag Produce BSD-style checksum lines \n");
14131413
XSUM_log( " --little-endian Checksum values use little endian convention (default: big endian) \n");
14141414
XSUM_log( " --binary Read in binary mode \n");
1415+
XSUM_log( " -s#, Set seed (default: 0 [max: 2^32]) \n");
14151416
XSUM_log( " -b Run benchmark \n");
14161417
XSUM_log( " -b# Bench only algorithm variant # \n");
14171418
XSUM_log( " -i# Number of times to run the benchmark (default: %i) \n", NBLOOPS_DEFAULT);
@@ -1636,6 +1637,18 @@ XSUM_API int XSUM_main(int argc, const char* argv[])
16361637
XSUM_logLevel--;
16371638
break;
16381639

1640+
/* Modify seed */
1641+
case 's': argument++;
1642+
switch( algo ){
1643+
case algo_xxh32: XXHSUM32_DEFAULT_SEED = XSUM_readU32FromChar(&argument); break;
1644+
case algo_xxh64: XXHSUM64_DEFAULT_SEED = XSUM_readU32FromChar(&argument); break;
1645+
case algo_xxh3: break;
1646+
case algo_xxh128: break;
1647+
default:
1648+
return XSUM_badusage(exename);
1649+
}
1650+
break;
1651+
16391652
default:
16401653
return XSUM_badusage(exename);
16411654
}

0 commit comments

Comments
 (0)