Commit 0bf8a181 authored by Aleksey Kravchenko's avatar Aleksey Kravchenko

New upstream version 1.3.7

parent 849913f7
Wed 14 Mar 2018 Aleksey
Sat Dec 22 2018 Aleksey
* === Version 1.3.7 ===
* new option `--message==<string>' to calculate a hash for string
* changed magnet link short option from '-m' to '-g'
Sat Sep 29 2018 Aleksey
* Bugfix: `--file-list=-' shall read a file list from stdin
Tue Sep 11 2018 Aleksey
* CRC32C hash function supported, option --crc32c
* speedup CRC32 hash function
Wed Mar 14 2018 Aleksey
* === Version 1.3.6 ===
* support --file-list option
Sun 11 Mar 2018 And Sch
Sun Mar 11 2018 And Sch
* librhash: speedup sha3
Sun Feb 18 2018 Aleksey
......
......@@ -3,7 +3,7 @@ include config.mak
HEADERS = calc_sums.h hash_print.h common_func.h hash_update.h file.h file_mask.h file_set.h find_file.h hash_check.h output.h parse_cmdline.h rhash_main.h win_utils.h platform.h version.h
SOURCES = calc_sums.c hash_print.c common_func.c hash_update.c file.c file_mask.c file_set.c find_file.c hash_check.c output.c parse_cmdline.c rhash_main.c win_utils.c
OBJECTS = calc_sums.o hash_print.o common_func.o hash_update.o file.o file_mask.o file_set.o find_file.o hash_check.o output.o parse_cmdline.o rhash_main.o win_utils.o
OBJECTS = $(SOURCES:.c=.o)
WIN_DIST_FILES = dist/MD5.bat dist/magnet.bat dist/rhashrc.sample
OTHER_FILES = configure Makefile ChangeLog INSTALL.md COPYING README \
dist/rhash.spec.in dist/rhash.1 dist/rhash.1.win.sed \
......@@ -85,8 +85,8 @@ install-conf:
# dependencies should be properly set, otherwise 'make -j<n>' can fail
install-symlinks: mkdir-bin install-man install-binary
cd $(BINDIR) && for f in $(SYMLINKS); do ln -fs $(RHASH_BINARY) $$f$(EXEC_EXT); done
cd $(MANDIR)/man1 && for f in $(SYMLINKS); do ln -fs rhash.1* $$f.1; done
cd $(BINDIR) && for f in $(SYMLINKS); do $(LN_S) $(RHASH_BINARY) $$f$(EXEC_EXT); done
cd $(MANDIR)/man1 && for f in $(SYMLINKS); do $(LN_S) rhash.1 $$f.1; done
install-pkg-config:
$(INSTALL) -d $(PKGCONFIGDIR)
......@@ -107,12 +107,15 @@ uninstall-pkg-config:
uninstall-lib:
+cd librhash && $(MAKE) uninstall-lib
install-lib-static: $(LIBRHASH_STATIC)
install-lib-static: $(LIBRHASH_STATIC) install-lib-headers
+cd librhash && $(MAKE) install-lib-static
install-lib-shared: $(LIBRHASH_SHARED)
+cd librhash && $(MAKE) install-lib-shared
install-lib-headers:
+cd librhash && $(MAKE) install-lib-headers
install-lib-so-link:
+cd librhash && $(MAKE) install-so-link
......@@ -225,9 +228,6 @@ dist/rhash.1.html: dist/rhash.1
dist/rhash.1.txt: dist/rhash.1
-which groff &>/dev/null && (groff -t -e -mandoc -Tascii dist/rhash.1 | sed -e 's/.\[[0-9]*m//g' > $@)
cpp-doc:
cppdoc_cmd -title=RHash -company=Akademgorodok -classdir=classdoc -module="cppdoc-standard" -overwrite -extensions="c,h" -languages="c=cpp,h=cpp" -generate-deprecations-list=false $(SOURCES) $(HEADERS) ./Documentation/CppDoc/index.html
permissions:
find . dist librhash po win32 win32/vc-2010 -maxdepth 1 -type f -exec chmod -x '{}' \;
chmod +x configure tests/test_rhash.sh
......@@ -309,7 +309,7 @@ update-po:
compile-gmo:
for f in $(I18N_FILES); do \
g=`basename $$f .po`; \
msgfmt $$f -o po/$$g.gmo; \
msgfmt -o po/$$g.gmo $$f; \
done
install-gmo: compile-gmo
......@@ -327,8 +327,8 @@ uninstall-gmo:
.PHONY: all build-shared build-static lib-shared lib-static clean clean-bindings distclean clean-local \
test test-shared test-static test-lib test-libs test-lib-shared test-lib-static \
install build-install-binary install-binary install-lib-shared install-lib-static \
install-lib-so-link install-conf install-data install-gmo install-man \
install-lib-headers install-lib-so-link install-conf install-data install-gmo install-man \
install-symlinks install-pkg-config uninstall-gmo uninstall-pkg-config \
uninstall uninstall-binary uninstall-data uninstall-lib uninstall-symlinks \
print-info check copy-dist update-po compile-gmo cpp-doc mkdir-bin permissions \
print-info check copy-dist update-po compile-gmo mkdir-bin permissions \
bzip dgz dist dist-full gzip gzip-bindings gzip-full rpm win-dist zip
=== RHash program ===
RHash is a console utility for calculation and verification of magnet links
and a wide range of hash sums like CRC32, MD4, MD5, SHA1, SHA256, SHA512,
SHA3, AICH, ED2K, Tiger, DC++ TTH, BitTorrent BTIH, GOST R 34.11-94,
RIPEMD-160, HAS-160, EDON-R, Whirlpool and Snefru.
Hash sums are used to ensure and verify integrity of large volumes of data
for a long-term storing or transferring.
Program features:
* Output in a predefined (SFV, BSD-like) or a user-defined format.
* Calculation of Magnet links.
* Ability to process directories recursively.
* Updating hash files (adding hash sums of files missing in the hash file).
* Calculates several hash sums in one pass.
* Portability: the program works the same on Linux, Unix, macOS or Windows.
=== The LibRHash library ===
LibRHash is a professional, portable, thread-safe C library for computing
a wide variety of hash sums, such as CRC32, MD4, MD5, SHA1, SHA256, SHA512,
SHA3, AICH, ED2K, Tiger, DC++ TTH, BitTorrent BTIH, GOST R 34.11-94,
RIPEMD-160, HAS-160, EDON-R, Whirlpool and Snefru.
Hash sums are used to ensure and verify integrity of large volumes of data
for a long-term storing or transferring.
Features:
* Small and easy to learn interface.
* Hi-level and Low-level API.
* Allows calculating of several hash functions simultaneously.
* Portability: the library works on Linux, *BSD and Windows.
=== Links ===
* Project Home Page: http://rhash.sourceforge.net/
* Official Releases: http://sf.net/projects/rhash/files/rhash/
* RHash hash functions descriptions http://rhash.anz.ru/hashes.php
* The table of the hash functions supported by RHash
https://sf.net/p/rhash/wiki/HashFunctions/
* ECRYPT: The Hash Function Zoo
http://ehash.iaik.tugraz.at/wiki/The_Hash_Function_Zoo
=== Getting latest source code ===
The latest source code can be obtained from Git repository by command:
git clone git://github.com/rhash/RHash.git
=== Notes on RHash License ===
The RHash program and LibRHash library are distributed under RHash License,
see the COPYING file for details. In particular, the program, the library
and source code can be used free of charge under the MIT, BSD, GPL,
commercial or freeware license without additional restrictions. In the case
the OSI-approved license is required the MIT license should be used.
# RHash
RHash is a console utility for calculation and verification of magnet links
and a wide range of hash sums like CRC32, CRC32C, MD4, MD5, SHA1, SHA256,
SHA512, SHA3, AICH, ED2K, Tiger, DC++ TTH, BitTorrent BTIH, GOST R 34.11-94,
RIPEMD-160, HAS-160, EDON-R, Whirlpool and Snefru.
Hash sums are used to ensure and verify integrity of large volumes of data
for a long-term storing or transferring.
### Program features:
* Ability to process directories recursively.
* Output in a predefined (SFV, BSD-like) or a user-defined format.
* Calculation of Magnet links.
* Updating hash files (adding hash sums of files missing in the hash file).
* Calculates several hash sums in one pass.
* Portability: the program works the same on Linux, Unix, macOS or Windows.
## Installation
```shell
./configure && make install
```
For more complicated cases of installation see the [INSTALL.md] file.
## Documentation
* RHash [Manual Page]
* RHash [ChangeLog]
* [The LibRHash Library] documentation
## Links
* Project Home Page: http://rhash.sourceforge.net/
* Official Releases: https://github.com/rhash/RHash/releases/
* The table of the supported by RHash [hash functions](http://sf.net/p/rhash/wiki/HashFunctions/)
* ECRYPT [The Hash Function Zoo](http://ehash.iaik.tugraz.at/wiki/The_Hash_Function_Zoo)
* ECRYPT [Benchmarking of hash functions](https://bench.cr.yp.to/results-hash.html)
## Contribution
Please read the [Contribution guidelines](docs/CONTRIBUTING.md) document.
## Notes on RHash License
The code is distributed under [RHash License](COPYING). Basically,
the program, the library and source code can be used free of charge under
the MIT, BSD, GPL, a commercial or a freeware license without additional
restrictions. In the case an OSI-approved license is required the
[MIT license] should be used.
[INSTALL.md]: INSTALL.md
[Manual Page]: http://rhash.anz.ru/manpage.php
[The LibRHash Library]: docs/LIBRHASH.md
[ChangeLog]: ChangeLog
[MIT license]: http://www.opensource.org/licenses/MIT
......@@ -132,7 +132,7 @@ namespace RHash {
throw new ArgumentException("This hasher does not support hash type "+type, "type");
}
StringBuilder sb = new StringBuilder(130);
Bindings.rhash_print(sb, ptr, (uint)type, BASE32);
Bindings.rhash_print(sb, ptr, (uint)type, BASE64);
return sb.ToString();
}
......
......@@ -7,15 +7,17 @@ my $libs = '';
my $inc = '';
my $obj = '';
my $clean = '';
my $local_librhash_dir = 'librhash';
my $has_builtin_librhash = (-f $local_librhash_dir . '/rhash.h');
# set the location of LibRHash headers and the linking flags
$inc = $ENV{'LIBRHASH_INC'} if defined($ENV{'LIBRHASH_INC'});
if(defined($ENV{'LIBRHASH_LD'}) && $ENV{'LIBRHASH_LD'} =~ /-L/) {
$libs = $ENV{'LIBRHASH_LD'} . ' ' . $libs;
$libs = $ENV{'LIBRHASH_LD'} . ' ' . $libs;
}
# use a system-wide librhash
$libs = '-lrhash' if (defined($ENV{'USE_SYSTEM_LIBRHASH'}));
$libs = '-lrhash' if (defined($ENV{'USE_SYSTEM_LIBRHASH'}) || ($libs eq '' && !$has_builtin_librhash));
# copy and rename *.c files by prepending underscore '_'
sub copy_c_files($) {
......@@ -37,12 +39,11 @@ sub copy_c_files($) {
return @result;
}
my $local_dir = 'librhash';
if($inc eq '' && $libs eq '' && -f $local_dir . '/rhash.h') {
if($inc eq '' && $libs eq '' && $has_builtin_librhash) {
# use the local version of librhash
print "Using builtin LibRHash\n";
$inc = '-I' . $local_dir;
my @c_files = copy_c_files($local_dir);
$inc = '-I' . $local_librhash_dir;
my @c_files = copy_c_files($local_librhash_dir);
$clean = join(' ', @c_files);
$obj = join(' ', map { s/\.c$/\$(OBJ_EXT)/; $_ } @c_files) . ' ';
}
......
package Crypt::Rhash;
use 5.008008;
use 5.006001;
use strict;
use warnings;
......@@ -10,8 +10,8 @@ our @ISA = (qw(Exporter));
# possible tags for export
our %EXPORT_TAGS = (
Functions => [qw(raw2hex raw2base32 raw2base64)],
Constants => [qw(RHASH_CRC32 RHASH_MD4 RHASH_MD5 RHASH_SHA1 RHASH_TIGER
RHASH_TTH RHASH_BTIH RHASH_ED2K RHASH_AICH RHASH_WHIRLPOOL
Constants => [qw(RHASH_CRC32 RHASH_CRC32C RHASH_MD4 RHASH_MD5 RHASH_SHA1
RHASH_TIGER RHASH_TTH RHASH_BTIH RHASH_ED2K RHASH_AICH RHASH_WHIRLPOOL
RHASH_RIPEMD160 RHASH_GOST RHASH_GOST_CRYPTOPRO RHASH_HAS160
RHASH_SNEFRU128 RHASH_SNEFRU256 RHASH_SHA224 RHASH_SHA256
RHASH_SHA384 RHASH_SHA512 RHASH_EDONR256 RHASH_EDONR512
......@@ -54,7 +54,8 @@ use constant RHASH_SHA3_224 => 0x0400000;
use constant RHASH_SHA3_256 => 0x0800000;
use constant RHASH_SHA3_384 => 0x1000000;
use constant RHASH_SHA3_512 => 0x2000000;
use constant RHASH_ALL => 0x3FFFFFF;
use constant RHASH_CRC32C => 0x4000000;
use constant RHASH_ALL => 0x7FFFFFF;
##############################################################################
# Rhash class methods
......@@ -274,6 +275,7 @@ Creates and returns new Crypt::Rhash object.
The $hash_id parameter can be union (via bitwise OR) of any of the following bit-flags:
RHASH_CRC32,
RHASH_CRC32C,
RHASH_MD4,
RHASH_MD5,
RHASH_SHA1,
......
......@@ -3,6 +3,7 @@
#include "XSUB.h"
#include <rhash.h>
#include <rhash_torrent.h>
typedef unsigned long long ulonglong;
......@@ -278,28 +279,6 @@ raw2base64(bytes)
OUTPUT:
RETVAL
# rhash_print_bytes should not be used directly
#SV *
#rhash_print_bytes(bytes, flags)
# PROTOTYPE: $;$
# PREINIT:
# STRLEN size;
# INPUT:
# unsigned char * bytes = SvPV(ST(0), size);
# int flags
# CODE:
# RETVAL = allocate_string_buffer(size * 2);
# rhash_print_bytes(SvPVX(RETVAL), bytes, size, flags);
# OUTPUT:
# RETVAL
#rhash_uptr_t
#rhash_transmit(msg_id, dst, ldata, rdata)
# unsigned msg_id
# void * dst
# rhash_uptr_t ldata
# rhash_uptr_t rdata
##############################################################################
# BTIH / BitTorrent support functions
......@@ -310,7 +289,7 @@ rhash_bt_add_filename(ctx, filename, filesize)
ulonglong filesize
PROTOTYPE: $$$
CODE:
rhash_transmit(RMSG_BT_ADD_FILE, ctx, RHASH_STR2UPTR(filename), (rhash_uptr_t)&filesize);
rhash_torrent_add_file(ctx, filename, filesize);
void
rhash_bt_set_piece_length(ctx, piece_length)
......@@ -318,27 +297,26 @@ rhash_bt_set_piece_length(ctx, piece_length)
unsigned piece_length
PROTOTYPE: $$
CODE:
rhash_transmit(RMSG_BT_SET_PIECE_LENGTH, ctx, RHASH_STR2UPTR(piece_length), 0);
rhash_torrent_set_piece_length(ctx, piece_length);
void
rhash_bt_set_private(ctx)
rhash_context * ctx
PROTOTYPE: $
CODE:
rhash_transmit(RMSG_BT_SET_OPTIONS, ctx, RHASH_BT_OPT_PRIVATE, 0);
rhash_torrent_set_options(ctx, RHASH_TORRENT_OPT_PRIVATE);
SV *
rhash_bt_get_torrent_text(ctx)
rhash_context * ctx
PROTOTYPE: $
PREINIT:
size_t len;
char *text;
const rhash_str* text;
CODE:
len = rhash_transmit(RMSG_BT_GET_TEXT, ctx, RHASH_STR2UPTR(&text), 0);
if(len == RHASH_ERROR) {
text = rhash_torrent_generate_content(ctx);
if(!text) {
XSRETURN_UNDEF;
}
RETVAL = newSVpv(text, len);
RETVAL = newSVpv(text->str, text->length);
OUTPUT:
RETVAL
use Test::More tests => 26;
use Test::More tests => 27;
use Crypt::Rhash;
#########################
......@@ -7,6 +7,7 @@ $r = new Crypt::Rhash(RHASH_ALL);
$r->update("a")->final();
is( $r->hash(RHASH_CRC32), "e8b7be43");
is( $r->hash(RHASH_CRC32C), "c1d04330");
is( $r->hash(RHASH_MD4), "bde52cb31de33e46245e05fbdbd6fb24");
is( $r->hash(RHASH_MD5), "0cc175b9c0f1b6a831c399e269772661");
is( $r->hash(RHASH_SHA1), "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8");
......
rhash_context * T_PTROBJ
rhash_uptr_t T_NV
ulonglong T_NV
const char * T_PV
......@@ -125,7 +125,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\librhash;..\..\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\librhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
......@@ -184,7 +184,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>..\..\librhash;..\..\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\librhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
......
This diff is collapsed.
......@@ -4,6 +4,7 @@
#include <stdint.h>
#include "common_func.h"
#include "file.h"
#include "hash_check.h"
#ifdef __cplusplus
......@@ -36,7 +37,7 @@ struct file_info {
void file_info_destroy(struct file_info*); /* free allocated memory */
const char* file_info_get_utf8_print_path(struct file_info*);
int save_torrent_to(const char* path, struct rhash_context* rctx);
int save_torrent_to(file_t* torrent_file, struct rhash_context* rctx);
int calculate_and_print_sums(FILE* out, struct file_t* file, const char *print_path);
int check_hash_file(struct file_t* file, int chdir);
int rename_file_by_embeding_crc32(struct file_info *info);
......
......@@ -59,7 +59,7 @@ typedef const rsh_tchar* ctstr_t;
#ifdef _WIN32
# define IF_WINDOWS(code) code
# define is_utf8() win_is_utf8()
# define to_utf8(str) win_to_utf8(str)
# define to_utf8(str) str_to_utf8(str)
#else /* non _WIN32 part */
# define IF_WINDOWS(code)
/* stub for utf8 */
......
......@@ -22,17 +22,6 @@ INSTALL_LIB_STATIC=auto
INSTALL_LIB_SHARED=auto
INSTALL_PKGCONFIGDIR="$PKG_INSTALLDIR"
case $(echo -n) in
-n) # SysV style
ECHO_N=
ECHO_C='\c'
;;
*) # BSD style
ECHO_N='-n '
ECHO_C=
;;
esac
# display error message and exit
die () {
echo
......@@ -233,9 +222,9 @@ remove_tmpdir()
}
trap remove_tmpdir EXIT
str_concat()
join_params()
{
echo ${ECHO_N} $@ ${ECHO_C}
printf '%s ' $@ | sed -e 's/ $//'
}
yn_nonempty()
......@@ -246,7 +235,7 @@ yn_nonempty()
# Use this before starting a check
start_check() {
echo "============ Checking for $1 ============" >> "$TMPLOG"
echo ${ECHO_N} "Checking for $1 ... ${ECHO_C}"
printf '%s' "Checking for $1 ... "
res_comment=""
}
......@@ -398,7 +387,7 @@ else
part=$(echo $BUILD_TARGET | cut -d '-' -f $component)
case "$(echo $part | tr '[A-Z]' '[a-z]')" in
linux) TARGET_OS=Linux ;;
freebsd) TARGET_OS=FreeBSD ;;
freebsd*) TARGET_OS=FreeBSD ;;
gnu/kfreebsd) TARGET_OS=FreeBSD ;;
netbsd) TARGET_OS=NetBSD ;;
bsd/os) TARGET_OS=BSD/OS ;;
......@@ -410,6 +399,7 @@ else
amigaos) TARGET_OS=AmigaOS ;;
mingw32*) TARGET_OS=MINGW32 ;;
wine) TARGET_OS=Wine ;;
darwin*) TARGET_OS=Darwin ;;
esac
}
TARGET_OS="UNKNOWN"
......@@ -480,13 +470,19 @@ if test "$(basename $CC)" = "icc" || test "$(basename $CC)" = "ecc"; then
else
CC_TMP="$CC"
for CC in "$CC_TMP" gcc cc ; do
if "$CC" -v >/dev/null 2>&1; then
if $CC -v >/dev/null 2>&1; then
cc_name_tmp=$($CC -v 2>&1 | tail -n 1 | cut -d ' ' -f 1)
if test "$cc_name_tmp" = "gcc"; then
cc_name=$cc_name_tmp
start_check "$CC version"
cc_vendor=gnu
cc_version=$($CC -dumpversion 2>&1)
if ! echo $cc_version | grep -q '^[0-9][0-9]*\.[0-9]'; then
cc_v2=$($CC -dumpfullversion -dumpversion 2>/dev/null)
if echo $cc_v2 | grep -q '^[0-9][0-9]*\.[0-9]'; then
cc_version=$cc_v2
fi
fi
case $cc_version in
2.96*)
cc_fail=yes
......@@ -497,7 +493,7 @@ else
_cc_mini=$(echo $cc_version | cut -d '.' -f 3)
;;
esac
finish_check "$cc_version"
finish_check "$cc_name $cc_version"
break
fi
if $CC -v 2>&1 | grep -q "clang"; then
......@@ -522,6 +518,10 @@ fi # icc
test -z "$cc_vendor" && die "compiler not found"
test "$cc_fail" = "yes" && die "unsupported compiler version"
if test "$cc_name" = "gcc" && test "$_cc_major" -gt 3; then
WARN_CFLAGS="$WARN_CFLAGS -Wdeclaration-after-statement"
fi
# select optimization flags
has_optimization()
{
......@@ -535,7 +535,7 @@ has_optimization()
}
has_optimization && OPTLEVEL= || OPTLEVEL="-O2"
OPTFLAGS="-pipe -DNDEBUG -fomit-frame-pointer -ffunction-sections -fdata-sections"
OPTFLAGS=$(str_concat $BUILD_DEBUG $OPTLEVEL $OPTFLAGS)
OPTFLAGS=$(join_params $BUILD_DEBUG $OPTLEVEL $OPTFLAGS)
# detect proper shared library name
SHARED_PREFIX="lib"
......@@ -547,7 +547,9 @@ EXEC_EXT=
NEED_IMPLIB=no
NEED_SOLINK=yes
INSTALL_SO_DIR=$INSTALL_LIBDIR
LN_S="ln -sf"
if win32; then
LN_S="cp -pR"
EXEC_EXT=".exe"
SHARED_EXT=".dll"
NEED_IMPLIB=yes
......@@ -637,7 +639,7 @@ else
LIBRHASH_SH_LDFLAGS="-shared -Wl${SHARED_VSCRIPT},-soname,\$(LIBRHASH_SHARED)"
test -n "$SHARED_VSCRIPT" && LIBRHASH_EXPORTS_TARGET=$LIBRHASH_EXPORTS_FILE
fi
LIBRHASH_RM_FILES=$(str_concat $LIBRHASH_RM_FILES $LIBRHASH_EXPORTS_TARGET $LIBRHASH_SOLINK_TARGET)
LIBRHASH_RM_FILES=$(join_params $LIBRHASH_RM_FILES $LIBRHASH_EXPORTS_TARGET $LIBRHASH_SOLINK_TARGET)
RHASH_DEFINES=
LIBRHASH_DEFINES=
......@@ -657,7 +659,7 @@ if test "$OPT_GETTEXT" != "no"; then
GETTEXT_FOUND=found
fi
fi
test "$GETTEXT_FOUND" = "found" && RHASH_DEFINES=$(str_concat $RHASH_DEFINES -DUSE_GETTEXT)
test "$GETTEXT_FOUND" = "found" && RHASH_DEFINES=$(join_params $RHASH_DEFINES -DUSE_GETTEXT)
finish_check $GETTEXT_FOUND
test "$OPT_GETTEXT" = "yes" && test "$GETTEXT_FOUND" = "no" && die "gettext library not found"
fi
......@@ -675,17 +677,17 @@ if test "$OPT_OPENSSL" != "no"; then
if cc_check_headers $OPENSSL_HEADERS; then
if test "$OPT_OPENSSL_RUNTIME" != "no"; then
OPENSSL_FOUND=runtime
LIBRHASH_DEFINES=$(str_concat $LIBRHASH_DEFINES -DOPENSSL_RUNTIME)
LIBRHASH_DEFINES=$(join_params $LIBRHASH_DEFINES -DOPENSSL_RUNTIME)
OPENSSL_LDFLAGS="$LIBDL_LDFLAGS"
# note: libdl should disable -static
test -n "$LIBDL_LDFLAGS" && LD_STATIC=
elif win32 && cc_check_statement "openssl/md5.h" "MD5_Init(NULL);" "-leay32"; then
OPENSSL_FOUND=found
LIBRHASH_DEFINES=$(str_concat $LIBRHASH_DEFINES -DUSE_OPENSSL)
LIBRHASH_DEFINES=$(join_params $LIBRHASH_DEFINES -DUSE_OPENSSL)
OPENSSL_LDFLAGS="-leay32"
elif cc_check_statement "openssl/md5.h" "MD5_Init(NULL);" "-lcrypto"; then
OPENSSL_FOUND=found
LIBRHASH_DEFINES=$(str_concat $LIBRHASH_DEFINES -DUSE_OPENSSL)
LIBRHASH_DEFINES=$(join_params $LIBRHASH_DEFINES -DUSE_OPENSSL)
OPENSSL_LDFLAGS="-lcrypto"
fi
fi
......@@ -715,7 +717,7 @@ else
test "$INSTALL_LIB_STATIC" = "yes" && RHASH_BUILD_TARGETS="$RHASH_BUILD_TARGETS \$(LIBRHASH_STATIC)"
fi
if test "$INSTALL_LIB_STATIC" = "yes"; then
RHASH_EXTRA_INSTALL=$(str_concat $RHASH_EXTRA_INSTALL install-lib-static)
RHASH_EXTRA_INSTALL=$(join_params $RHASH_EXTRA_INSTALL install-lib-static)
LIBRHASH_BUILD_TARGETS=$LIBRHASH_STATIC
LIBRHASH_TEST_TARGETS=test-static
fi
......@@ -724,9 +726,9 @@ if test "$NEED_IMPLIB" = "yes"; then
EXTRA_UNINSTALL_LIBSHARED="uninstall-implib"
fi
if test "$INSTALL_LIB_SHARED" = "yes"; then
RHASH_EXTRA_INSTALL=$(str_concat $RHASH_EXTRA_INSTALL install-lib-shared)
LIBRHASH_BUILD_TARGETS=$(str_concat $LIBRHASH_BUILD_TARGETS $LIBRHASH_SHARED)
LIBRHASH_TEST_TARGETS=$(str_concat $LIBRHASH_TEST_TARGETS test-shared)
RHASH_EXTRA_INSTALL=$(join_params $RHASH_EXTRA_INSTALL install-lib-shared)
LIBRHASH_BUILD_TARGETS=$(join_params $LIBRHASH_BUILD_TARGETS $LIBRHASH_SHARED)
LIBRHASH_TEST_TARGETS=$(join_params $LIBRHASH_TEST_TARGETS test-shared)
fi
# check for old POSIX make
......@@ -815,6 +817,7 @@ RHASH_SHARED = $RHASH_SHARED\$(EXEC_EXT)
BUILD_TARGETS = $RHASH_BUILD_TARGETS
EXTRA_INSTALL = $RHASH_EXTRA_INSTALL
SYMLINKS = $INSTALL_SYMLINKS
LN_S = $LN_S
OPTFLAGS = $OPTFLAGS
OPTLDFLAGS = $WIN_LDFLAGS
......@@ -823,7 +826,7 @@ ADDCFLAGS = $BUILD_EXTRA_CFLAGS
ADDLDFLAGS = $BUILD_EXTRA_LDFLAGS
CFLAGS = $RHASH_DEFINES \$(OPTFLAGS) \$(WARN_CFLAGS) \$(ADDCFLAGS)
LDFLAGS = \$(OPTLDFLAGS) \$(ADDLDFLAGS) $GETTEXT_LDFLAGS
BIN_STATIC_LDFLAGS = \$(LDFLAGS) $(str_concat $LD_STATIC $OPENSSL_LDFLAGS)
BIN_STATIC_LDFLAGS = \$(LDFLAGS) $(join_params $LD_STATIC $OPENSSL_LDFLAGS)
EOF
fi
......@@ -869,8 +872,8 @@ ADDLDFLAGS = $BUILD_EXTRA_LDFLAGS
CFLAGS = $LIBRHASH_DEFINES \$(OPTFLAGS) \$(WARN_CFLAGS) \$(ADDCFLAGS)
LDFLAGS = \$(OPTLDFLAGS) \$(ADDLDFLAGS)
SHARED_CFLAGS = \$(CFLAGS) $LIBRHASH_SH_CFLAGS
SHARED_LDFLAGS = \$(LDFLAGS) $(str_concat $OPENSSL_LDFLAGS $LIBRHASH_SH_LDFLAGS)
BIN_STATIC_LDFLAGS = \$(LDFLAGS) $(str_concat $LD_STATIC $OPENSSL_LDFLAGS)
SHARED_LDFLAGS = \$(LDFLAGS) $(join_params $OPENSSL_LDFLAGS $LIBRHASH_SH_LDFLAGS)
BIN_STATIC_LDFLAGS = \$(LDFLAGS) $(join_params $LD_STATIC $OPENSSL_LDFLAGS)
EOF
fi
......@@ -897,4 +900,4 @@ Libs: -L\${libdir} -lrhash
Libs.private: ${OPENSSL_LDFLAGS}
EOF
fi
\ No newline at end of file
fi
......@@ -10,9 +10,9 @@ rhash \- calculate/check CRC32, MD5, SHA1, GOST, TTH, BTIH or other hash sums.
.SH DESCRIPTION
.B RHash
(Recursive Hasher)
computes and verifies various message digests (hash sums) of files.
Supported message digests include CRC32, MD4, MD5, SHA1, SHA256, SHA512,
SHA3, Tiger, DC++ TTH, BitTorrent BTIH, AICH, ED2K, GOST R 34.11\-94,
computes and verifies various message digests (hash sums) of files or
strings. Supported message digests include CRC32, CRC32C, MD4, MD5, SHA1,
SHA256, SHA512, SHA3, Tiger, DC++ TTH, BTIH, AICH, ED2K, GOST R 34.11\-94,
RIPEMD\-160, HAS\-160, EDON\-R 256/512, Whirlpool, Snefru\-128/256.
The program can create and verify Magnet links
......@@ -27,11 +27,11 @@ The format can be changed by options \-\-bsd, \-\-magnet, \-\-simple,
\-\-printf, \-\-template.
To output all sums use the `\-a' option.
The default output format can also be changed by renaming the program or
placing a hardlink/symlink to it with a name containing strings `crc32',
`md4', `md5', `sha1', `sha256' `sha512', `tiger', `tth', `btih', `aich',
`ed2k', `ed2k\-link', `gost', `gost\-cryptopro', `ripemd160', `has160',
`whirlpool', `edonr256', `edonr512', `snefru128', `snefru256',
The default output format can be changed by renaming the program or placing
a hardlink/symlink to it with a filename containing strings `crc32',
`crc32c', `md4', `md5', `sha1', `sha256' `sha512', `tiger', `tth', `btih',
`aich', `ed2k', `ed2k\-link', `gost', `gost\-cryptopro', `ripemd160',
`has160', `whirlpool', `edonr256', `edonr512', `snefru128', `snefru256',
`sfv' or `magnet'.
.SH PROGRAM MODE OPTIONS
......@@ -64,6 +64,8 @@ Run benchmark for selected algorithm(s).
.SH HASH SUMS OPTIONS
.IP "\-C, \-\-crc32"
CRC32: calculate and print CRC32 hash sum.
.IP "\-\-crc32c"
CRC32C: calculate and print CRC32C hash sum.
.IP "\-\-md4"
MD4: calculate and print MD4 hash sum.
.IP "\-M, \-\-md5"
......@@ -112,8 +114,11 @@ List names of all supported hashes, one per line.
.IP "\-r, \-\-recursive"
Recursively process directories, specified by command line.
.IP "\-\-file\-list=<file>"
Process a file-list. File-list is a text file, containing paths to files,
one path per line.
Process given file as a file-list. Lines of this file are
interpreted as paths to files to be processed. Multiple
file lists can be specified at command line.
.IP "\-m, \-\-message=<text>"
Calculate hash sums of the text message.
.IP "\-\-follow"
Follow symbolic links when processing directories recursively.
.IP "\-v, \-\-verbose"
......@@ -186,7 +191,7 @@ so they will not look like options anymore.
Print hash sums in the SFV (Simple File Verification) output format (default).
But unlike common SFV file, not only CRC32, but any hash sums specified
by options can be printed.
.IP "\-m, \-\-magnet"
.IP "\-g, \-\-magnet"
Print hash sums formatted as magnet links.
.IP "\-\-bsd"
Use BSD output format. Each hash sum is printed on separate line
......@@ -269,7 +274,7 @@ base64 or raw (binary) format respectively, e.g. %b{md4}, %BH or %xT.
.SH CONFIG FILE
RHash looks for a config file
at $HOME/.rhashrc and /etc/rhashrc.
at $XDG_CONFIG_HOME/rhash/rhashrc, $HOME/.rhashrc and /etc/rhashrc.
The config file consists of lines formatted as
.RS
......
This diff is collapsed.
......@@ -34,7 +34,6 @@ char* make_path(const char* dir, const char* filename);
int are_paths_equal(ctpath_t a, ctpath_t b);
int is_regular_file(const char* path); /* shall be deprecated */
int if_file_exists(const char* path);
/**
* Portable file information.
......@@ -45,6 +44,7 @@ typedef struct file_t
#ifdef _WIN32
wchar_t* wpath;
#endif
char* data;
uint64_t size;
uint64_t mtime;
unsigned mode;
......@@ -61,19 +61,25 @@ typedef struct file_t
#define FILE_IFLNK 0x02
#define FILE_IFREG 0x04
#define FILE_IFROOT 0x10
#define FILE_IFSTDIN 0x20
#define FILE_IFDATA 0x20
#define FILE_IFLIST 0x40
#define FILE_IFSTDIN 0x80
#define FILE_IFSPEC_MASK (FILE_IFDATA | FILE_IFLIST | FILE_IFSTDIN)
#define FILE_OPT_DONT_FREE_PATH 0x200
#define FILE_OPT_DONT_FREE_WPATH 0x400
#define FILE_ISDIR(file) ((file)->mode & FILE_IFDIR)
#define FILE_ISLNK(file) ((file)->mode & FILE_IFLNK)
#define FILE_ISREG(file) ((file)->mode & FILE_IFREG)
#define FILE_ISDIR(file) ((file)->mode & FILE_IFDIR)
#define FILE_ISLNK(file) ((file)->mode & FILE_IFLNK)
#define FILE_ISREG(file) ((file)->mode & FILE_IFREG)
#define FILE_ISDATA(file) ((file)->mode & FILE_IFDATA)
#define FILE_ISLIST(file) ((file)->mode & FILE_IFLIST)
#define FILE_ISSTDIN(file) ((file)->mode & FILE_IFSTDIN)
#define FILE_ISSPECIAL(file) ((file)->mode & (FILE_IFSPEC_MASK))
/* file functions */
void file_init(file_t* file, const char* path, int finit_flags);
void file_cleanup(file_t* file);
void file_path_append(file_t* dst, file_t* src, const char* suffix);
void file_path_append(file_t* dst, const file_t* src, const char* suffix);
enum FileStatModes {
FNoMode = 0,
......@@ -89,14 +95,19 @@ enum FileFOpenModes {