Commit 32cc4253 authored by Aleksey Kravchenko's avatar Aleksey Kravchenko

Imported Upstream version 1.3.5

parent bac593a6
/dist/rhash.spec
/dist/rhash.1.*
/librhash/exports.sym
po/*.gmo
/rhash
/rhash_shared
/librhash/test_shared
*.[ao]
*.exe
*.dll
*.def
*.so
*.so.0
*.log
Mon Aug 14 2017 Aleksey
* === Version 1.3.5 ===
* look for locales directory at PROGRAM_DIRECTORY\locale on Windows
* look for config at PROGRAM_DIRECTORY\rhashrc on Windows
Fri Aug 4 2017 Aleksey
* support LibRhash bindings to PHP7
Sun Jul 30 2017 Aleksey
* Bugfix: illegal instruction error on macOS
Sat Jul 29 2017 Aleksey
* improve utf-8 support on Windows
Thu Jul 27 2017 Aleksey
* Bugfix: fix access to long paths on Windows
Mon Jul 17 2017 Aleksey
* add ca, fr, ro translations
Sun Jul 16 2017 Darío Hereñú
* full Spanish translation
Mon Jul 10 2017 James Le Cuirot
* correct build/install command for freebsd
Mon Jul 10 2017 Przemyslaw Pawelczyk
* compilation fixes for aarch64 and musl
Mon Jul 10 2017 Aleksey
* improve support of clang on macOS
Sun Nov 6 2016 Aleksey
* === Version 1.3.4 ===
Tue Nov 17 2015 Alexey Dokuchaev, Kurt Jaeger
* Compilation fixes for FreeBSD
* compilation fixes for FreeBSD
Sat Aug 9 2014 Aleksey
* return non zero exit code if a file was not found
......@@ -212,7 +244,7 @@ Mon Mar 14 2011 Aleksey
* added printf modificator %{mtime} to print the last modified date of a file
Thu Feb 17 2011 Aleksey
* Bugfix: verification of base2-like formated md5 hash sums
* Bugfix: verification of base2-like formatted md5 hash sums
Fri Jan 14 2011 Aleksey
* === Version 1.2.2 ===
......@@ -587,7 +619,7 @@ Wed Apr 19 2006 Aleksey
Mon Apr 10 2006 Aleksey
* === Version 0.8.3 ===
* cheking of files in standart md5sum/sha1sum format supported
* cheking of files in standard md5sum/sha1sum format supported
* default output format for md5/sha1/ed2k sums changed
* man page rewrited
......
......@@ -2,7 +2,7 @@
# compile with debug info: make CFLAGS=-g
# compile for pentiumpro: make CFLAGS="-O2 -DNDEBUG -march=i586 -mcpu=pentiumpro -fomit-frame-pointer"
# create rpm with statically linked program: make rpm ADDLDFLAGS="-static -s -Wl,--gc-sections"
VERSION = 1.3.4
VERSION = 1.3.5
PREFIX ?= /usr/local
CC ?= gcc
# using OPTFLAGS/OPTLDFLAGS for compatibilty with old scripts using this makefile
......@@ -50,7 +50,7 @@ LIBRHASH_FILES = librhash/algorithms.c librhash/algorithms.h \
librhash/tiger_sbox.c librhash/tth.c librhash/tth.h librhash/whirlpool.c \
librhash/whirlpool.h librhash/whirlpool_sbox.c librhash/test_hashes.c \
librhash/test_hashes.h librhash/torrent.h librhash/torrent.c librhash/ustd.h \
librhash/util.c librhash/util.h librhash/config.h librhash/Makefile
librhash/util.h librhash/config.h librhash/Makefile
I18N_FILES = po/de.po po/en_AU.po po/es.po po/gl.po po/it.po po/ru.po
DIST_FILES = $(LIN_DIST_FILES) $(LIBRHASH_FILES) $(WIN_DIST_FILES) $(WIN_SRC_FILES) $(I18N_FILES)
DESTDIR =
......@@ -70,10 +70,10 @@ build-shared: $(SHARED_TRG)
lib-shared: $(SHAREDLIB)
lib-static: $(LIBRHASH)
install: all install-binary install-data install-symlinks
install-shared: $(SHARED_TRG) install-shared-binary install-data install-symlinks
install: build-install-binary install-data install-symlinks
install-shared: build-install-shared-binary install-data install-symlinks
install-data: install-man install-conf
uninstall: uninstall-binary uninstall-data uninstall-symlinks
uninstall: uninstall-binary uninstall-data uninstall-symlinks uninstall-lib
# creating archives
WIN_SUFFIX = win32
......@@ -87,18 +87,25 @@ WIN_ZIP_DIR = RHash-$(VERSION)-$(WIN_SUFFIX)
dist: gzip gzip-bindings
dist-full: gzip-full
win-dist: zip
zip : $(ARCHIVE_ZIP)
zip: $(ARCHIVE_ZIP)
dgz: check $(ARCHIVE_DEB_GZ)
build-install-binary: $(TARGET)
+$(MAKE) install-binary
build-install-shared-binary: $(SHARED_TRG)
+$(MAKE) install-shared-binary
mkdir-bin:
$(INSTALL) -d $(DESTDIR)$(BINDIR)
# install binary without (re-)compilation
install-binary: mkdir-bin
$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BINDIR)
$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BINDIR)/$(PROGNAME)
# install dynamically linked binary
# install dynamically linked binary without (re-)compilation
install-shared-binary: mkdir-bin
$(INSTALL_PROGRAM) $(SHARED_TRG) $(DESTDIR)$(BINDIR)/rhash
$(INSTALL_PROGRAM) $(SHARED_TRG) $(DESTDIR)$(BINDIR)/$(PROGNAME)
install-man:
$(INSTALL) -d $(DESTDIR)$(MANDIR)/man1
......@@ -121,28 +128,31 @@ uninstall-data:
rm -f $(DESTDIR)$(MANDIR)/man1/rhash.1
uninstall-symlinks:
for f in $(SYMLINKS); do rm -f $(DESTDIR)$(BINDIR)/$$f; done
for f in $(SYMLINKS); do rm -f $(DESTDIR)$(BINDIR)/$$f $(DESTDIR)$(MANDIR)/man1/$$f.1; done
uninstall-lib:
+$(MAKE) -C librhash uninstall-lib
install-lib-static: $(LIBRHASH)
+make -C librhash install-lib-static
+$(MAKE) -C librhash install-lib-static
install-lib-shared: $(SHAREDLIB)
+make -C librhash install-lib-shared
+$(MAKE) -C librhash install-lib-shared
$(SHAREDLIB):
+make -C librhash lib-shared
+$(MAKE) -C librhash lib-shared
$(LIBRHASH): $(LIBRHASH_FILES)
+make -C librhash lib-static
+$(MAKE) -C librhash lib-static
test-static-lib: $(LIBRHASH)
+make -C librhash test-static
+$(MAKE) -C librhash test-static
test-shared-lib: $(SHAREDLIB)
+make -C librhash test-shared
+$(MAKE) -C librhash test-shared
test-libs: $(LIBRHASH) $(SHAREDLIB)
+make -C librhash test-static test-shared
+$(MAKE) -C librhash test-static test-shared
test: test-static
test-static: $(TARGET)
......@@ -244,7 +254,7 @@ permissions:
chmod +x tests/test_rhash.sh
clean-bindings:
+make -C bindings distclean
+$(MAKE) -C bindings distclean
copy-dist: $(DIST_FILES) permissions
rm -rf $(PROGNAME)-$(VERSION)
......@@ -252,27 +262,27 @@ copy-dist: $(DIST_FILES) permissions
cp -rl --parents $(DIST_FILES) $(PROGNAME)-$(VERSION)/
gzip: check
+make copy-dist
tar czf $(ARCHIVE_GZIP) $(PROGNAME)-$(VERSION)/
+$(MAKE) copy-dist
tar czf $(ARCHIVE_GZIP) --owner=root:0 --group=root:0 $(PROGNAME)-$(VERSION)/
rm -rf $(PROGNAME)-$(VERSION)
gzip-bindings:
+make -C bindings gzip ARCHIVE_GZIP=../rhash-bindings-$(VERSION)-src.tar.gz
+$(MAKE) -C bindings gzip ARCHIVE_GZIP=../rhash-bindings-$(VERSION)-src.tar.gz
gzip-full: check clean-bindings
+make copy-dist
+make -C bindings copy-dist COPYDIR=../$(PROGNAME)-$(VERSION)/bindings
tar czf $(ARCHIVE_FULL) $(PROGNAME)-$(VERSION)/
+$(MAKE) copy-dist
+$(MAKE) -C bindings copy-dist COPYDIR=../$(PROGNAME)-$(VERSION)/bindings
tar czf $(ARCHIVE_FULL) --owner=root:0 --group=root:0 $(PROGNAME)-$(VERSION)/
rm -rf $(PROGNAME)-$(VERSION)
bzip: check
+make copy-dist
tar cjf $(ARCHIVE_BZIP) $(PROGNAME)-$(VERSION)/
+$(MAKE) copy-dist
tar cjf $(ARCHIVE_BZIP) --owner=root:0 --group=root:0 $(PROGNAME)-$(VERSION)/
rm -rf $(PROGNAME)-$(VERSION)
7z: check
+make copy-dist
tar cf - $(PROGNAME)-$(VERSION)/ | 7zr a -si $(ARCHIVE_7Z)
+$(MAKE) copy-dist
tar cf - --owner=root:0 --group=root:0 $(PROGNAME)-$(VERSION)/ | 7zr a -si $(ARCHIVE_7Z)
rm -rf $(PROGNAME)-$(VERSION)
$(ARCHIVE_ZIP): $(WIN_DIST_FILES) dist/rhash.1.win.html
......@@ -281,12 +291,11 @@ $(ARCHIVE_ZIP): $(WIN_DIST_FILES) dist/rhash.1.win.html
mkdir $(WIN_ZIP_DIR)
cp $(TARGET).exe ChangeLog $(WIN_DIST_FILES) $(WIN_ZIP_DIR)/
cp dist/rhash.1.win.html $(WIN_ZIP_DIR)/rhash-doc.html
# -[ -f $(OUTDIR)libeay32.dll ] && cp $(OUTDIR)libeay32.dll $(WIN_ZIP_DIR)/
zip -9r $(ARCHIVE_ZIP) $(WIN_ZIP_DIR)
rm -rf $(WIN_ZIP_DIR)
$(ARCHIVE_DEB_GZ) : $(DIST_FILES)
+make $(ARCHIVE_GZIP)
+$(MAKE) $(ARCHIVE_GZIP)
mv -f $(ARCHIVE_GZIP) $(ARCHIVE_DEB_GZ)
# rpm packaging
......@@ -303,7 +312,7 @@ rpm: gzip
distclean: clean
clean:
+make -C librhash clean
+$(MAKE) -C librhash clean
rm -f *.o $(SHARED_TRG) $(TARGET)
rm -f po/*.gmo po/*.po~
......@@ -324,10 +333,14 @@ install-gmo: compile-gmo
for f in po/*.gmo; do \
l=`basename $$f .gmo`; \
$(INSTALL) -d $(DESTDIR)$(LOCALEDIR)/$$l/LC_MESSAGES; \
$(INSTALL_DATA) -T $$f $(DESTDIR)$(LOCALEDIR)/$$l/LC_MESSAGES/rhash.mo; \
$(INSTALL_DATA) $$f $(DESTDIR)$(LOCALEDIR)/$$l/LC_MESSAGES/rhash.mo; \
done
.PHONY: all install uninstall lib-shared lib-static dist dist-full zip \
.PHONY: all build-shared lib-shared lib-static dist win-dist dist-full mkdir-bin \
test test-static test-shared test-libs test-static-lib test-shared-lib \
check copy-dist gzip gzip-bindings gzip-full bzip 7z zip clean clean-bindings \
update-po compile-gmo install-gmo
install build-install-binary install-binary install-lib-static \
install-shared build-install-shared-binary install-shared-binary \
install-lib-shared install-data install-man install-symlinks install-conf \
uninstall uninstall-binary uninstall-data uninstall-lib uninstall-symlinks \
check copy-dist permissions gzip gzip-bindings gzip-full bzip 7z zip dgz rpm \
update-po compile-gmo install-gmo cpp-doc clean distclean clean-bindings
......@@ -70,7 +70,7 @@ test-python:
install-ruby:
# clear MAKEFLAGS to overcome ruby1.8 mkmf concurrency bug
MAKEFLAGS= make -C ruby install DESTDIR=$(DESTDIR) sitedir=$(DESTDIR)/usr/lib/ruby
MAKEFLAGS= $(MAKE) -C ruby install DESTDIR=$(DESTDIR) sitedir=$(DESTDIR)/usr/lib/ruby
install-perl:
$(MAKE) -C perl install DESTDIR=$(DESTDIR)
......@@ -89,7 +89,7 @@ copy-dist:
gzip: distclean
rm -rf "$(COPYDIR)" $(ARCHIVE_GZIP)
$(MAKE) copy-dist
tar -czf $(ARCHIVE_GZIP) "$(COPYDIR)"
tar -czf $(ARCHIVE_GZIP) --owner=root:0 --group=root:0 "$(COPYDIR)"
rm -rf "$(COPYDIR)"
PERL_PKG_VER = $(shell [ -f perl/Rhash.pm ] && sed -ne "s/^our \+.VERSION *= *'\([0-9\.]*\)';/\1/p;" perl/Rhash.pm)
......@@ -106,7 +106,7 @@ cpan:
cp ../librhash/*.[hc] $(PERL_PKG)/librhash/
cp perl/MANIFEST $(PERL_PKG)/
find $(PERL_PKG)/librhash/ -type f -printf "librhash/%f\n" | sort >> $(PERL_PKG)/MANIFEST
tar -czf $(PERL_PKG).tar.gz --owner=0:0 $(PERL_PKG)/
tar -czf $(PERL_PKG).tar.gz --owner=root:0 --group=root:0 $(PERL_PKG)/
rm -rf $(PERL_PKG)/
distclean:
......
......@@ -16,7 +16,6 @@
# FOR A PARTICULAR PURPOSE. Use it at your own risk!
MAKE = make
JAVA = java
JAVAC = javac
JAVADOC = javadoc
......
......@@ -15,7 +15,6 @@
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. Use it at your own risk!
MAKE=make
CS=gmcs
MDOC=mdoc
SOURCES=AssemblyInfo.cs Bindings.cs Hasher.cs HashType.cs
......
......@@ -47,5 +47,5 @@
"url" : "https://github.com/rhash/RHash"
}
},
"version" : "0.91"
"version" : "0.93"
}
......@@ -23,4 +23,4 @@ resources:
homepage: http://rhash.sf.net/
license: http://rhash.anz.ru/license.php
repository: https://github.com/rhash/RHash
version: 0.91
version: 0.93
......@@ -21,7 +21,7 @@ our %EXPORT_TAGS = (
Exporter::export_tags( );
Exporter::export_ok_tags( qw(Functions Constants) );
our $VERSION = '0.91';
our $VERSION = '0.93';
require XSLoader;
XSLoader::load('Crypt::Rhash', $VERSION);
......
......@@ -4,34 +4,41 @@ dnl
PHP_ARG_WITH(rhash, for RHash support,
[ --with-rhash[=DIR] Include RHash support.])
dnl DIR is the RHash install prefix [BUNDLED]], yes, no)
if test "$PHP_RHASH" != "no"; then
if test -r $PHP_RHASH/include/rhash.h; then
RHASH_DIR=$PHP_RHASH
RHASH_INCLUDE_DIR=$PHP_RHASH/include
RHASH_LIB_DIR=$PHP_RHASH/lib
elif test -r $PHP_RHASH/rhash.h; then
RHASH_INCLUDE_DIR=$PHP_RHASH
RHASH_LIB_DIR=$PHP_RHASH
else
AC_MSG_CHECKING(for RHash in default path)
for i in /usr/local /usr; do
if test -r $i/include/rhash.h; then
RHASH_DIR=$i
AC_MSG_RESULT(found in $i)
RHASH_INCLUDE_DIR=$i/include
RHASH_LIB_DIR=$i/lib
AC_MSG_RESULT(found at $i)
break
fi
done
fi
if test -z "$RHASH_DIR"; then
if test -z "$RHASH_INCLUDE_DIR" -a -r ../../librhash/rhash.h; then
RHASH_INCLUDE_DIR=$(pwd)/../../librhash
RHASH_LIB_DIR=$RHASH_INCLUDE_DIR
AC_MSG_RESULT(found at $RHASH_INCLUDE_DIR)
fi
if test -z "$RHASH_INCLUDE_DIR"; then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Please reinstall the librhash -
rhash.h should be in <rhash-dir>/include/)
fi
dnl PHP_RHASH_CFLAGS="-I@ext_builddir@/lib"
AC_DEFINE(HAVE_RHASH, 1, [Whether you have RHash])
PHP_ADD_INCLUDE($RHASH_DIR/include)
PHP_ADD_LIBRARY_WITH_PATH(rhash, $RHASH_DIR/lib/librhash.so, RHASH_SHARED_LIBADD)
PHP_ADD_INCLUDE($RHASH_INCLUDE_DIR)
PHP_ADD_LIBRARY_WITH_PATH(rhash, $RHASH_LIB_DIR, RHASH_SHARED_LIBADD)
PHP_NEW_EXTENSION(rhash, php_rhash.c, $ext_shared)
PHP_SUBST(RHASH_SHARED_LIBADD)
dnl PHP_NEW_EXTENSION(rhash, php_rhash.c, $PHP_RHASH_CFLAGS)
fi
#ifndef PHP_PORTABLE_H
#define PHP_PORTABLE_H
#if PHP_MAJOR_VERSION < 7
struct _zend_string {
char *val;
int len;
int persistent;
};
typedef struct _zend_string zend_string;
#define RETURN_NEW_STR(s) RETURN_STRINGL(s->val,s->len,0);
static zend_always_inline zend_string *zend_string_alloc(int len, int persistent)
{
/* aligned to 8 bytes size of buffer to hold (len + 1) characters */
int alligned_size = (len + 1 + 7) & ~7;
/* single alloc, so free the buf, will also free the struct */
char *buf = safe_pemalloc(sizeof(zend_string) + alligned_size, 1, 0, persistent);
zend_string *str = (zend_string *)(buf + alligned_size);
str->val = buf;
str->len = len;
str->persistent = persistent;
return str;
}
/* compatibility macros */
# define _RETURN_STRING(str) RETURN_STRING(str, 1)
# define _RETURN_STRINGL(str, l) RETURN_STRINGL(str, l, 1)
typedef long zend_long;
typedef int strsize_t;
#else
# define _RETURN_STRING(str) RETURN_STRING(str)
# define _RETURN_STRINGL(str, l) RETURN_STRINGL(str, l)
typedef size_t strsize_t;
#endif
#endif /* PHP_PORTABLE_H */
This diff is collapsed.
......@@ -218,9 +218,10 @@ const char* file_info_get_utf8_print_path(struct file_info* info)
* @param crc32 pointer to integer to receive parsed hash sum.
* @return non zero if crc32 was found, zero otherwise.
*/
static int find_embedded_crc32(const char* filepath, unsigned* crc32_be)
static int find_embedded_crc32(const char* filepath, unsigned* crc32)
{
const char* e = filepath + strlen(filepath) - 10;
unsigned char raw[4];
/* search for the sum enclosed in brackets */
for (; e >= filepath && !IS_PATH_SEPARATOR(*e); e--) {
......@@ -228,7 +229,9 @@ static int find_embedded_crc32(const char* filepath, unsigned* crc32_be)
const char *p = e + 8;
for (; p > e && IS_HEX(*p); p--);
if (p == e) {
rhash_hex_to_byte(e + 1, (char unsigned*)crc32_be, 8);
rhash_hex_to_byte(e + 1, raw, 8);
*crc32 = ((unsigned)raw[0] << 24) | ((unsigned)raw[1] << 16) |
((unsigned)raw[2] << 8) | (unsigned)raw[3];
return 1;
}
e -= 9;
......@@ -251,18 +254,13 @@ int rename_file_by_embeding_crc32(struct file_info *info)
const char* c = p - 1;
char* new_path;
char* insertion_point;
unsigned crc32_be;
unsigned crc32;
assert((info->rctx->hash_id & RHASH_CRC32) != 0);
/* check if the filename contains a CRC32 hash sum */
if (find_embedded_crc32(info->print_path, &crc32_be)) {
unsigned char* c =
(unsigned char*)rhash_get_context_ptr(info->rctx, RHASH_CRC32);
unsigned actual_crc32 = ((unsigned)c[0] << 24) |
((unsigned)c[1] << 16) | ((unsigned)c[2] << 8) | (unsigned)c[3];
/* check if the filename contains a CRC32 sum */
if (find_embedded_crc32(info->print_path, &crc32)) {
/* compare with calculated CRC32 */
if (crc32_be != actual_crc32) {
if (crc32 != get_crc32(info->rctx)) {
char crc32_str[9];
rhash_print(crc32_str, info->rctx, RHASH_CRC32, RHPR_UPPERCASE);
/* TRANSLATORS: sample filename with embedded CRC32: file_[A1B2C3D4].mkv */
......@@ -479,7 +477,7 @@ static int verify_sums(struct file_info *info)
}
if ((opt.flags & OPT_EMBED_CRC) && find_embedded_crc32(
info->print_path, &info->hc.embedded_crc32_be)) {
info->print_path, &info->hc.embedded_crc32)) {
info->hc.flags |= HC_HAS_EMBCRC32;
assert(info->hc.hash_mask & RHASH_CRC32);
}
......@@ -518,8 +516,8 @@ int check_hash_file(file_t* file, int chdir)
/* process --check-embedded option */
if (opt.mode & MODE_CHECK_EMBEDDED) {
unsigned crc32_be;
if (find_embedded_crc32(hash_file_path, &crc32_be)) {
unsigned crc32;
if (find_embedded_crc32(hash_file_path, &crc32)) {
/* initialize file_info structure */
memset(&info, 0, sizeof(info));
info.full_path = rsh_strdup(hash_file_path);
......@@ -527,7 +525,7 @@ int check_hash_file(file_t* file, int chdir)
file_info_set_print_path(&info, info.full_path);
info.sums_flags = info.hc.hash_mask = RHASH_CRC32;
info.hc.flags = HC_HAS_EMBCRC32;
info.hc.embedded_crc32_be = crc32_be;
info.hc.embedded_crc32 = crc32;
res = verify_sums(&info);
fflush(rhash_data.out);
......@@ -560,7 +558,7 @@ int check_hash_file(file_t* file, int chdir)
pos = strlen(hash_file_path)+16;
ralign = str_set(buf, '-', (pos < 80 ? 80 - (int)pos : 2));
fprintf(rhash_data.out, _("\n--( Verifying %s )%s\n"), hash_file_path, ralign);
rsh_fprintf(rhash_data.out, _("\n--( Verifying %s )%s\n"), hash_file_path, ralign);
fflush(rhash_data.out);
rsh_timer_start(&timer);
......@@ -572,8 +570,7 @@ int check_hash_file(file_t* file, int chdir)
} else pos = 0;
/* read crc file line by line */
for (line_num = 0; fgets(buf, 2048, fd); line_num++)
{
for (line_num = 0; fgets(buf, 2048, fd); line_num++) {
char* line = buf;
char* path_without_ext = NULL;
......@@ -651,7 +648,7 @@ int check_hash_file(file_t* file, int chdir)
}
time = rsh_timer_stop(&timer);
fprintf(rhash_data.out, "%s\n", str_set(buf, '-', 80));
rsh_fprintf(rhash_data.out, "%s\n", str_set(buf, '-', 80));
print_check_stats();
if (rhash_data.processed != rhash_data.ok) rhash_data.error_flag = 1;
......@@ -761,7 +758,7 @@ void run_benchmark(unsigned hash_id, unsigned flags)
total_time += time;
if ((flags & BENCHMARK_RAW) == 0 && !rhash_data.interrupted) {
fprintf(rhash_data.out, "%s %u MiB calculated in %.3f sec, %.3f MBps\n", hash_name, (unsigned)sz_mb, time, (double)sz_mb / time);
rsh_fprintf(rhash_data.out, "%s %u MiB calculated in %.3f sec, %.3f MBps\n", hash_name, (unsigned)sz_mb, time, (double)sz_mb / time);
fflush(rhash_data.out);
}
}
......@@ -798,20 +795,20 @@ void run_benchmark(unsigned hash_id, unsigned flags)
if (flags & BENCHMARK_RAW) {
/* output result in a "raw" machine-readable format */
fprintf(rhash_data.out, "%s\t%u\t%.3f\t%.3f", hash_name, ((unsigned)sz_mb * rounds), total_time, (double)(sz_mb * rounds) / total_time);
rsh_fprintf(rhash_data.out, "%s\t%u\t%.3f\t%.3f", hash_name, ((unsigned)sz_mb * rounds), total_time, (double)(sz_mb * rounds) / total_time);
#if defined(HAVE_TSC)
if (flags & BENCHMARK_CPB) {
fprintf(rhash_data.out, "\t%.2f", cpb);
rsh_fprintf(rhash_data.out, "\t%.2f", cpb);
}
#endif /* HAVE_TSC */
fprintf(rhash_data.out, "\n");
rsh_fprintf(rhash_data.out, "\n");
} else {
fprintf(rhash_data.out, "%s %u MiB total in %.3f sec, %.3f MBps", hash_name, ((unsigned)sz_mb * rounds), total_time, (double)(sz_mb * rounds) / total_time);
rsh_fprintf(rhash_data.out, "%s %u MiB total in %.3f sec, %.3f MBps", hash_name, ((unsigned)sz_mb * rounds), total_time, (double)(sz_mb * rounds) / total_time);
#if defined(HAVE_TSC)
if (flags & BENCHMARK_CPB) {
fprintf(rhash_data.out, ", CPB=%.2f", cpb);
rsh_fprintf(rhash_data.out, ", CPB=%.2f", cpb);
}
#endif /* HAVE_TSC */
fprintf(rhash_data.out, "\n");
rsh_fprintf(rhash_data.out, "\n");
}
}
......@@ -323,14 +323,11 @@ int are_paths_equal(const rsh_tchar* a, const rsh_tchar* b)
if (a[0] == RSH_T('.') && IS_ANY_SLASH(a[1])) a += 2;
if (b[0] == RSH_T('.') && IS_ANY_SLASH(b[1])) b += 2;
for (; *a; ++a, ++b)
{
if (*a != *b && (!IS_ANY_SLASH(*b) || !IS_ANY_SLASH(*a)))
{
for (; *a; ++a, ++b) {
if (*a != *b && (!IS_ANY_SLASH(*b) || !IS_ANY_SLASH(*a))) {
/* paths are different */
return 0;
}
}
/* check if both paths terminated */
return (*a == *b);
......@@ -402,8 +399,7 @@ unsigned rhash_get_ticks(void)
void file_init(file_t* file, const char* path, int reuse_path)
{
memset(file, 0, sizeof(*file));
if (reuse_path)
{
if (reuse_path) {
file->path = (char*)path;
file->mode = FILE_OPT_DONT_FREE_PATH;
} else {
......@@ -414,9 +410,7 @@ void file_init(file_t* file, const char* path, int reuse_path)
void file_cleanup(file_t* file)
{
if ((file->mode & FILE_OPT_DONT_FREE_PATH) == 0)
{
free(file->path);
}
file->path = NULL;
#ifdef _WIN32
......@@ -438,9 +432,10 @@ void file_cleanup(file_t* file)
int file_statw(file_t* file)
{
WIN32_FILE_ATTRIBUTE_DATA data;
wchar_t* long_path = get_long_path_if_needed(file->wpath);
/* read file attributes */
if (GetFileAttributesExW(file->wpath, GetFileExInfoStandard, &data)) {
if (GetFileAttributesExW((long_path ? long_path : file->wpath), GetFileExInfoStandard, &data)) {
uint64_t u;
file->size = (((uint64_t)data.nFileSizeHigh) << 32) + data.nFileSizeLow;
file->mode &= FILE_OPT_DONT_FREE_PATH;
......@@ -450,8 +445,10 @@ int file_statw(file_t* file)
u = (((uint64_t)data.ftLastWriteTime.dwHighDateTime) << 32) + data.ftLastWriteTime.dwLowDateTime;
/* convert to second and subtract the epoch difference */
file->mtime = u / 10000000 - 11644473600LL;
free(long_path);
return 0;
}
free(long_path);
set_errno_from_last_file_error();
return -1;
}
......@@ -507,16 +504,17 @@ int file_stat2(file_t* file, int use_lstat)
res = stat(file->path, &st);
} while (0);
file->size = st.st_size;
file->mtime = st.st_mtime;
if (res == 0) {
file->size = st.st_size;
file->mtime = st.st_mtime;
if (S_ISDIR(st.st_mode)) {
file->mode |= FILE_IFDIR;
} else if (S_ISREG(st.st_mode)) {
/* it's a regular file or a symlink pointing to a regular file */
file->mode |= FILE_IFREG;
if (S_ISDIR(st.st_mode)) {
file->mode |= FILE_IFDIR;
} else if (S_ISREG(st.st_mode)) {
/* it's a regular file or a symlink pointing to a regular file */
file->mode |= FILE_IFREG;
}
}
return res;
#endif /* _WIN32 */
}
......@@ -592,9 +590,9 @@ void (*rsh_report_error)(const char* srcfile, int srcline,
static void report_error_default(const char* srcfile, int srcline, const char* format, ...)
{
va_list ap;
fprintf(stderr, "RHash: error at %s:%u: ", srcfile, srcline);
rsh_fprintf(stderr, "RHash: error at %s:%u: ", srcfile, srcline);
va_start(ap, format);
vfprintf(stderr, format, ap); /* report the error to stderr */
rsh_vfprintf(stderr, format, ap); /* report the error to stderr */
va_end(ap);
}
......
......@@ -11,11 +11,10 @@
#ifdef USE_GETTEXT
# include <libintl.h>
# define _(str) gettext(str)
# ifdef _WIN32
# define LOCALEDIR "./locale"
# else /* _WIN32 */
# define TEXT_DOMAIN "rhash"
# ifndef LOCALEDIR
# define LOCALEDIR "/usr/share/locale"
# endif /* _WIN32 */
# endif /* LOCALEDIR */
#else
# define _(str) (str)
#endif /* USE_GETTEXT */
......@@ -123,9 +122,15 @@ int if_file_exists(const char* path);
# define get_file_tpath(file) ((file)->wpath)
int file_statw(file_t* file);
# define rsh_fopen_bin(path, mode) win_fopen_bin(path, mode)
# define rsh_fprintf win_fprintf
# define rsh_vfprintf win_vfprintf
# define rsh_fwrite win_fwrite
#else
# define get_file_tpath(file) ((file)->path)
# define rsh_fopen_bin(path, mode) fopen(path, mode)
# define rsh_fprintf fprintf
# define rsh_vfprintf vfprintf
# define rsh_fwrite fwrite
#endif
......@@ -156,8 +161,8 @@ double rsh_timer_stop(timedelta_t* timer);
/**
* Return ticks in milliseconds for time intervals measurement.
* This function should be not precise but the fastest one
* to retrieve internal clock value.
* This function should be optimized for speed and retrieve
* internal clock value, if possible.
*
* @return ticks count in milliseconds
*/
......
......@@ -13,7 +13,7 @@ Use UTF\\-8 codepage for output.
/ looks for a config file/ {
a\
on Windows at\
%APPDATA%\\\\RHash\\\\rhashrc, %HOMEDRIVE%%HOMEPATH%\\\\rhashrc\
%APPDATA%\\\\RHash\\\\rhashrc, %HOMEDRIVE%%HOMEPATH%\\\\rhashrc, {PROGRAM_DIRECTORY}\\\\rhashrc\
\
and on Linux/Unix
}
......@@ -102,6 +102,7 @@ ldconfig
ldconfig
%changelog
* Mon Aug 14 2017 Aleksey <rhash.admin@gmail.com> 1.3.5-1mdk
* Sun Nov 6 2016 Aleksey <rhash.admin@gmail.com> 1.3.4-1mdk
* Tue Aug 5 2014 Aleksey <rhash.admin@gmail.com> 1.3.3-1mdk
* Wed Jul 2 2014 Aleksey <rhash.admin@gmail.com> 1.3.2-1mdk
......
......@@ -40,7 +40,7 @@
static int dir_scan(file_t* start_dir, file_search_data* data);
/* allocate and fill the file_search_data */
file_search_data* create_file_search_data(rsh_tchar** paths, size_t count, int max_depth)
file_search_data* file_search_data_new(rsh_tchar** paths, size_t count, int max_depth)
{
size_t i;
......@@ -187,16 +187,20 @@ file_search_data* create_file_search_data(rsh_tchar** paths, size_t count, int m
/**
* Free memory allocated by the file_search_data structure
*/
void destroy_file_search_data(file_search_data* data)
void file_search_data_free(file_search_data* data)
{
size_t i;
/* clean the memory allocated by file_t elements */
for (i = 0; i < data->root_files.size; i++)
if (data)
{
file_t* file = get_root_file(data, i);