mirror of
https://github.com/xroche/httrack.git
synced 2026-05-18 08:56:14 +03:00
Compare commits
86 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b75488dec6 | ||
|
|
9285cfa1bb | ||
|
|
02eb2862d2 | ||
|
|
0ac9c0df32 | ||
|
|
da41e9a7a1 | ||
|
|
b9a35a5d9c | ||
|
|
f2ac631565 | ||
|
|
b5e08a8300 | ||
|
|
1d2d42eb4e | ||
|
|
d71237d177 | ||
|
|
7f8eb5f60f | ||
|
|
e1149999ce | ||
|
|
89a8c3134d | ||
|
|
5261673a4d | ||
|
|
1b5adaaa2d | ||
|
|
9f21da0f1b | ||
|
|
a68ec9ad2a | ||
|
|
f912d9f024 | ||
|
|
8b8cce197a | ||
|
|
e8188eb243 | ||
|
|
f59bc8a790 | ||
|
|
854b7fe18e | ||
|
|
920d51082c | ||
|
|
e35b329c50 | ||
|
|
1ff6c081f1 | ||
|
|
7503937d76 | ||
|
|
23fa293e9e | ||
|
|
25c278b599 | ||
|
|
721da33d81 | ||
|
|
c0165072d6 | ||
|
|
ebd4d34b7b | ||
|
|
047c6b726b | ||
|
|
aecd9a41ea | ||
|
|
46a9b89dd3 | ||
|
|
b6ba5073a5 | ||
|
|
5eb5b0891d | ||
|
|
afff7dc033 | ||
|
|
69a93698dc | ||
|
|
68d81080b3 | ||
|
|
a431fcf717 | ||
|
|
c722368dc0 | ||
|
|
b1367feade | ||
|
|
5882b122d1 | ||
|
|
f27a5f58be | ||
|
|
d0d62c0598 | ||
|
|
027fe3a5ee | ||
|
|
8b05179083 | ||
|
|
522af8962f | ||
|
|
96a727e4fb | ||
|
|
4c876451be | ||
|
|
c5003322b7 | ||
|
|
8e72bb5deb | ||
|
|
2e6a99ce09 | ||
|
|
218f6e2cd9 | ||
|
|
967932e75d | ||
|
|
42bb06703a | ||
|
|
3bb87c123a | ||
|
|
eeaa956588 | ||
|
|
7925eccecd | ||
|
|
60ee0687d5 | ||
|
|
8b3af0d585 | ||
|
|
028f23ca6f | ||
|
|
bf40691b62 | ||
|
|
dc21c7f595 | ||
|
|
4461278b80 | ||
|
|
95480e8d16 | ||
|
|
b10df97dd0 | ||
|
|
7a1e4b8265 | ||
|
|
6c2120e053 | ||
|
|
7a261eec39 | ||
|
|
dbd99bb365 | ||
|
|
e0fe304f0b | ||
|
|
84632e7bb6 | ||
|
|
a4f1156edc | ||
|
|
1e87dc455f | ||
|
|
c0a31f2656 | ||
|
|
2e59d67d7a | ||
|
|
713b83f7b4 | ||
|
|
82e61ae9d6 | ||
|
|
d2103fce8a | ||
|
|
93ae992d7b | ||
|
|
49dd329a09 | ||
|
|
185b664930 | ||
|
|
3a7441b57b | ||
|
|
eeee43acb7 | ||
|
|
91946b7834 |
@@ -6,6 +6,9 @@
|
||||
/* Check for ftime */
|
||||
#undef FTIME
|
||||
|
||||
/* Define if pointers to integers require aligned access */
|
||||
#undef HAVE_ALIGNED_ACCESS_REQUIRED
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
|
||||
308
configure
vendored
308
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for httrack 3.48.13.
|
||||
# Generated by GNU Autoconf 2.69 for httrack 3.48.19.
|
||||
#
|
||||
# Report bugs to <roche+packaging@httrack.com>.
|
||||
#
|
||||
@@ -616,8 +616,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='httrack'
|
||||
PACKAGE_TARNAME='httrack'
|
||||
PACKAGE_VERSION='3.48.13'
|
||||
PACKAGE_STRING='httrack 3.48.13'
|
||||
PACKAGE_VERSION='3.48.19'
|
||||
PACKAGE_STRING='httrack 3.48.19'
|
||||
PACKAGE_BUGREPORT='roche+packaging@httrack.com'
|
||||
PACKAGE_URL='http://www.httrack.com/'
|
||||
|
||||
@@ -1356,7 +1356,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures httrack 3.48.13 to adapt to many kinds of systems.
|
||||
\`configure' configures httrack 3.48.19 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -1426,7 +1426,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of httrack 3.48.13:";;
|
||||
short | recursive ) echo "Configuration of httrack 3.48.19:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@@ -1537,7 +1537,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
httrack configure 3.48.13
|
||||
httrack configure 3.48.19
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@@ -2169,7 +2169,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by httrack $as_me 3.48.13, which was
|
||||
It was created by httrack $as_me 3.48.19, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@@ -2990,7 +2990,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='httrack'
|
||||
VERSION='3.48.13'
|
||||
VERSION='3.48.19'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@@ -11778,8 +11778,9 @@ LT_CV_OBJDIR=$lt_cv_objdir
|
||||
|
||||
### Default CFLAGS
|
||||
DEFAULT_CFLAGS="-Wall -Wformat -Wformat-security \
|
||||
-Wmultichar -Wwrite-strings -Wcast-align -Wstrict-prototypes \
|
||||
-Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement \
|
||||
-Wmultichar -Wwrite-strings -Wcast-qual -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes \
|
||||
-Wmissing-declarations -Wdeclaration-after-statement \
|
||||
-Wpointer-arith -Wsequence-point -Wnested-externs \
|
||||
-D_REENTRANT"
|
||||
|
||||
@@ -11857,6 +11858,76 @@ else
|
||||
:
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wunused-but-set-parameter" >&5
|
||||
$as_echo_n "checking whether C compiler accepts -Wunused-but-set-parameter... " >&6; }
|
||||
if ${ax_cv_check_cflags___Wunused_but_set_parameter+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
ax_check_save_flags=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Wunused-but-set-parameter"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ax_cv_check_cflags___Wunused_but_set_parameter=yes
|
||||
else
|
||||
ax_cv_check_cflags___Wunused_but_set_parameter=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
CFLAGS=$ax_check_save_flags
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wunused_but_set_parameter" >&5
|
||||
$as_echo "$ax_cv_check_cflags___Wunused_but_set_parameter" >&6; }
|
||||
if test x"$ax_cv_check_cflags___Wunused_but_set_parameter" = xyes; then :
|
||||
DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wunused-but-set-parameter"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Waddress" >&5
|
||||
$as_echo_n "checking whether C compiler accepts -Waddress... " >&6; }
|
||||
if ${ax_cv_check_cflags___Waddress+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
ax_check_save_flags=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Waddress"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ax_cv_check_cflags___Waddress=yes
|
||||
else
|
||||
ax_cv_check_cflags___Waddress=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
CFLAGS=$ax_check_save_flags
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Waddress" >&5
|
||||
$as_echo "$ax_cv_check_cflags___Waddress" >&6; }
|
||||
if test x"$ax_cv_check_cflags___Waddress" = xyes; then :
|
||||
DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Waddress"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wuninitialized" >&5
|
||||
$as_echo_n "checking whether C compiler accepts -Wuninitialized... " >&6; }
|
||||
if ${ax_cv_check_cflags___Wuninitialized+:} false; then :
|
||||
@@ -11962,14 +12033,14 @@ else
|
||||
:
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fstrict-aliasing -Wstrict-aliasing=2" >&5
|
||||
$as_echo_n "checking whether C compiler accepts -fstrict-aliasing -Wstrict-aliasing=2... " >&6; }
|
||||
if ${ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2+:} false; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wmissing-parameter-type" >&5
|
||||
$as_echo_n "checking whether C compiler accepts -Wmissing-parameter-type... " >&6; }
|
||||
if ${ax_cv_check_cflags___Wmissing_parameter_type+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
ax_check_save_flags=$CFLAGS
|
||||
CFLAGS="$CFLAGS -fstrict-aliasing -Wstrict-aliasing=2"
|
||||
CFLAGS="$CFLAGS -Wmissing-parameter-type"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
@@ -11982,17 +12053,122 @@ main ()
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2=yes
|
||||
ax_cv_check_cflags___Wmissing_parameter_type=yes
|
||||
else
|
||||
ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2=no
|
||||
ax_cv_check_cflags___Wmissing_parameter_type=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
CFLAGS=$ax_check_save_flags
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2" >&5
|
||||
$as_echo "$ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2" >&6; }
|
||||
if test x"$ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2" = xyes; then :
|
||||
DEFAULT_CFLAGS="$DEFAULT_CFLAGS -fstrict-aliasing -Wstrict-aliasing=2"
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wmissing_parameter_type" >&5
|
||||
$as_echo "$ax_cv_check_cflags___Wmissing_parameter_type" >&6; }
|
||||
if test x"$ax_cv_check_cflags___Wmissing_parameter_type" = xyes; then :
|
||||
DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wmissing-parameter-type"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wold-style-definition" >&5
|
||||
$as_echo_n "checking whether C compiler accepts -Wold-style-definition... " >&6; }
|
||||
if ${ax_cv_check_cflags___Wold_style_definition+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
ax_check_save_flags=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Wold-style-definition"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ax_cv_check_cflags___Wold_style_definition=yes
|
||||
else
|
||||
ax_cv_check_cflags___Wold_style_definition=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
CFLAGS=$ax_check_save_flags
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wold_style_definition" >&5
|
||||
$as_echo "$ax_cv_check_cflags___Wold_style_definition" >&6; }
|
||||
if test x"$ax_cv_check_cflags___Wold_style_definition" = xyes; then :
|
||||
DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wold-style-definition"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wignored-qualifiers" >&5
|
||||
$as_echo_n "checking whether C compiler accepts -Wignored-qualifiers... " >&6; }
|
||||
if ${ax_cv_check_cflags___Wignored_qualifiers+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
ax_check_save_flags=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Wignored-qualifiers"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ax_cv_check_cflags___Wignored_qualifiers=yes
|
||||
else
|
||||
ax_cv_check_cflags___Wignored_qualifiers=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
CFLAGS=$ax_check_save_flags
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wignored_qualifiers" >&5
|
||||
$as_echo "$ax_cv_check_cflags___Wignored_qualifiers" >&6; }
|
||||
if test x"$ax_cv_check_cflags___Wignored_qualifiers" = xyes; then :
|
||||
DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wignored-qualifiers"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fstrict-aliasing -Wstrict-aliasing" >&5
|
||||
$as_echo_n "checking whether C compiler accepts -fstrict-aliasing -Wstrict-aliasing... " >&6; }
|
||||
if ${ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
ax_check_save_flags=$CFLAGS
|
||||
CFLAGS="$CFLAGS -fstrict-aliasing -Wstrict-aliasing"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing=yes
|
||||
else
|
||||
ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
CFLAGS=$ax_check_save_flags
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing" >&5
|
||||
$as_echo "$ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing" >&6; }
|
||||
if test x"$ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing" = xyes; then :
|
||||
DEFAULT_CFLAGS="$DEFAULT_CFLAGS -fstrict-aliasing -Wstrict-aliasing"
|
||||
else
|
||||
:
|
||||
fi
|
||||
@@ -12070,6 +12246,43 @@ else
|
||||
fi
|
||||
|
||||
|
||||
## Export all symbols for backtraces
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -rdynamic" >&5
|
||||
$as_echo_n "checking whether C compiler accepts -rdynamic... " >&6; }
|
||||
if ${ax_cv_check_cflags___rdynamic+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
ax_check_save_flags=$CFLAGS
|
||||
CFLAGS="$CFLAGS -rdynamic"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ax_cv_check_cflags___rdynamic=yes
|
||||
else
|
||||
ax_cv_check_cflags___rdynamic=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
CFLAGS=$ax_check_save_flags
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___rdynamic" >&5
|
||||
$as_echo "$ax_cv_check_cflags___rdynamic" >&6; }
|
||||
if test x"$ax_cv_check_cflags___rdynamic" = xyes; then :
|
||||
DEFAULT_CFLAGS="$DEFAULT_CFLAGS -rdynamic"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
|
||||
### Check for -fvisibility=hidden support
|
||||
|
||||
|
||||
@@ -12280,6 +12493,57 @@ $as_echo "#define sa_family_t uint16_t" >>confdefs.h
|
||||
fi
|
||||
|
||||
|
||||
# check wether misaligned access is possible or not
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if pointers to integers require aligned access" >&5
|
||||
$as_echo_n "checking if pointers to integers require aligned access... " >&6; }
|
||||
if ${ax_cv_have_aligned_access_required+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then :
|
||||
ax_cv_have_aligned_access_required=no
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char* string = malloc(40);
|
||||
int i;
|
||||
for (i=0; i < 40; i++) string[[i]] = i;
|
||||
{
|
||||
void* s = string;
|
||||
int* p = s+1;
|
||||
int* q = s+2;
|
||||
|
||||
if (*p == *q) { return 1; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
if ac_fn_c_try_run "$LINENO"; then :
|
||||
ax_cv_have_aligned_access_required=yes
|
||||
else
|
||||
ax_cv_have_aligned_access_required=no
|
||||
fi
|
||||
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
||||
conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_aligned_access_required" >&5
|
||||
$as_echo "$ax_cv_have_aligned_access_required" >&6; }
|
||||
if test "$ax_cv_have_aligned_access_required" = yes ; then
|
||||
|
||||
$as_echo "#define HAVE_ALIGNED_ACCESS_REQUIRED 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
|
||||
### zlib
|
||||
#
|
||||
# Handle user hints
|
||||
@@ -13760,7 +14024,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by httrack $as_me 3.48.13, which was
|
||||
This file was extended by httrack $as_me 3.48.19, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -13827,7 +14091,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
httrack config.status 3.48.13
|
||||
httrack config.status 3.48.19
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
||||
20
configure.ac
20
configure.ac
@@ -1,6 +1,6 @@
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
AC_INIT([httrack], [3.48.13], [roche+packaging@httrack.com], [httrack], [http://www.httrack.com/])
|
||||
AC_INIT([httrack], [3.48.19], [roche+packaging@httrack.com], [httrack], [http://www.httrack.com/])
|
||||
AC_COPYRIGHT([
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) 1998-2014 Xavier Roche and other contributors
|
||||
@@ -52,8 +52,9 @@ AC_SUBST(VERSION_INFO)
|
||||
|
||||
### Default CFLAGS
|
||||
DEFAULT_CFLAGS="-Wall -Wformat -Wformat-security \
|
||||
-Wmultichar -Wwrite-strings -Wcast-align -Wstrict-prototypes \
|
||||
-Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement \
|
||||
-Wmultichar -Wwrite-strings -Wcast-qual -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes \
|
||||
-Wmissing-declarations -Wdeclaration-after-statement \
|
||||
-Wpointer-arith -Wsequence-point -Wnested-externs \
|
||||
-D_REENTRANT"
|
||||
AC_SUBST(DEFAULT_CFLAGS)
|
||||
@@ -63,13 +64,21 @@ AC_SUBST(DEFAULT_LDFLAGS)
|
||||
### Additional flags (if supported)
|
||||
AX_CHECK_COMPILE_FLAG([-Wparentheses], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wparentheses"])
|
||||
AX_CHECK_COMPILE_FLAG([-Winit-self], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Winit-self"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wunused-but-set-parameter], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wunused-but-set-parameter"])
|
||||
AX_CHECK_COMPILE_FLAG([-Waddress], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Waddress"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wuninitialized], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wuninitialized"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wformat=2], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wformat=2"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wformat-nonliteral], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wformat-nonliteral"])
|
||||
AX_CHECK_COMPILE_FLAG([-fstrict-aliasing -Wstrict-aliasing=2], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -fstrict-aliasing -Wstrict-aliasing=2"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wmissing-parameter-type], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wmissing-parameter-type"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wold-style-definition], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wold-style-definition"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wignored-qualifiers], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wignored-qualifiers"])
|
||||
AX_CHECK_COMPILE_FLAG([-fstrict-aliasing -Wstrict-aliasing], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -fstrict-aliasing -Wstrict-aliasing"])
|
||||
AX_CHECK_LINK_FLAG([-Wl,--discard-all], [DEFAULT_LDLAGS="$DEFAULT_LDLAGS -Wl,--discard-all"])
|
||||
AX_CHECK_LINK_FLAG([-Wl,--no-undefined], [DEFAULT_LDLAGS="$DEFAULT_LDLAGS -Wl,--no-undefined"])
|
||||
|
||||
## Export all symbols for backtraces
|
||||
AX_CHECK_COMPILE_FLAG([-rdynamic], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -rdynamic"])
|
||||
|
||||
### Check for -fvisibility=hidden support
|
||||
gl_VISIBILITY
|
||||
AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
|
||||
@@ -107,6 +116,9 @@ AC_CHECK_TYPE(sa_family_t, [], [AC_DEFINE([sa_family_t], [uint16_t], [sa_family_
|
||||
#include <netinet/in.h>
|
||||
])
|
||||
|
||||
# check wether misaligned access is possible or not
|
||||
AX_CHECK_ALIGNED_ACCESS_REQUIRED
|
||||
|
||||
### zlib
|
||||
CHECK_ZLIB()
|
||||
|
||||
|
||||
40
debian/changelog
vendored
40
debian/changelog
vendored
@@ -1,3 +1,43 @@
|
||||
httrack (3.48.19-1) unstable; urgency=low
|
||||
|
||||
* Updated to 3.48.19 (3.48-19)
|
||||
closes:#756328
|
||||
|
||||
-- Xavier Roche <xavier@debian.org> Mon, 28 Jul 2014 22:52:19 +0200
|
||||
|
||||
httrack (3.48.18-1) unstable; urgency=low
|
||||
|
||||
* Updated to 3.48.18 (3.48-18)
|
||||
closes:#755107
|
||||
|
||||
-- Xavier Roche <xavier@debian.org> Thu, 17 Jul 2014 21:35:10 +0200
|
||||
|
||||
httrack (3.48.17-1) unstable; urgency=low
|
||||
|
||||
* Updated to 3.48.17 (3.48-17)
|
||||
|
||||
-- Xavier Roche <xavier@debian.org> Sat, 12 Jul 2014 15:21:14 +0200
|
||||
|
||||
httrack (3.48.16-1) unstable; urgency=low
|
||||
|
||||
* Updated to 3.48.16 (3.48-16)
|
||||
fixed FTBFS on ARM/MIPS again
|
||||
|
||||
-- Xavier Roche <xavier@debian.org> Wed, 09 Jul 2014 07:02:08 +0200
|
||||
|
||||
httrack (3.48.15-1) unstable; urgency=low
|
||||
|
||||
* Updated to 3.48.15 (3.48-15)
|
||||
fixed FTBFS on ARM/MIPS
|
||||
|
||||
-- Xavier Roche <xavier@debian.org> Tue, 08 Jul 2014 22:05:14 +0200
|
||||
|
||||
httrack (3.48.14-1) unstable; urgency=low
|
||||
|
||||
* Updated to 3.48.14 (3.48-14)
|
||||
|
||||
-- Xavier Roche <xavier@debian.org> Tue, 08 Jul 2014 20:36:55 +0200
|
||||
|
||||
httrack (3.48.13-1) unstable; urgency=low
|
||||
|
||||
* Updated to 3.48.13 (3.48-13)
|
||||
|
||||
13
history.txt
13
history.txt
@@ -4,7 +4,18 @@ HTTrack Website Copier release history:
|
||||
|
||||
This file lists all changes and fixes that have been made for HTTrack.
|
||||
|
||||
3.48-12
|
||||
3.48-19
|
||||
+ Fixed: assertion failure at htslib.c:3458 (strlen(copyBuff) == qLen) seen on Linux
|
||||
+ Fixed: infamous crashes inside the DNS cache due to a corruption within the option structure (E.Kalinowski/karbofos)
|
||||
+ New: added minimalistic crash reporting on Windows and Linux
|
||||
+ Fixed: URL list not working anymore (tom swift)
|
||||
+ Fixed: FTBFS on ARM
|
||||
+ Fixed: buggy FFFD (replacement character) in place of leading non-ascii character such as Chinese ones (aballboy)
|
||||
+ Fixed: FTBFS when compiling with zlib versions < 1.2.70 (sammyx)
|
||||
+ Fixed: buggy SVG (Smiling Spectre)
|
||||
+ Fixed: do not uncompress .tgz advertised as "streamed" (Smiling Spectre)
|
||||
+ Fixed: NULL pointer dereferencing in back_unserialize (htsback.c:976)
|
||||
+ Fixed: library development files
|
||||
+ Fixed: --advanced-maxlinks broken (Localhost)
|
||||
+ Fixed: -devel package should now be standalone
|
||||
+ Fixed: assertion failure at htscore.c:244 (len + liensbuf->string_buffer_size < liensbuf->string_buffer_capa)
|
||||
|
||||
@@ -100,9 +100,9 @@ EXTERNAL_FUNCTION int hts_plug(httrackp * opt, const char *argv) {
|
||||
if (arg == NULL)
|
||||
arg = "log-wrapper-info";
|
||||
hts_log(opt, arg, "* plugging functions");
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, (char *) arg);
|
||||
CHAIN_FUNCTION(opt, start, start_of_mirror, (char *) arg);
|
||||
CHAIN_FUNCTION(opt, end, end_of_mirror, (char *) arg);
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, (void *) (uintptr_t) arg);
|
||||
CHAIN_FUNCTION(opt, start, start_of_mirror, (void *) (uintptr_t) arg);
|
||||
CHAIN_FUNCTION(opt, end, end_of_mirror, (void *) (uintptr_t) arg);
|
||||
|
||||
hts_log(opt, arg, "* module successfully plugged");
|
||||
return 1; /* success */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii httrack.1
|
||||
.\"
|
||||
.TH httrack 1 "08 June 2014" "httrack website copier"
|
||||
.TH httrack 1 "17 July 2014" "httrack website copier"
|
||||
.SH NAME
|
||||
httrack \- offline browser : copy websites to a local directory
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -30,21 +30,22 @@ bin_PROGRAMS = proxytrack httrack htsserver
|
||||
httrack_LDADD = $(THREADS_LIBS) libhttrack.la
|
||||
htsserver_LDADD = $(THREADS_LIBS) $(SOCKET_LIBS) libhttrack.la
|
||||
proxytrack_LDADD = $(THREADS_LIBS) $(SOCKET_LIBS)
|
||||
proxytrack_CFLAGS = $(AM_CFLAGS) -DNO_MALLOCT
|
||||
proxytrack_CFLAGS = $(AM_CFLAGS) -DNO_MALLOCT -DZLIB_CONST -DHTS_INTHASH_USES_MD5
|
||||
htsserver_CFLAGS = $(AM_CFLAGS) -DZLIB_CONST -DHTS_INTHASH_USES_MD5
|
||||
|
||||
lib_LTLIBRARIES = libhttrack.la libhtsjava.la
|
||||
|
||||
htsserver_SOURCES = htsserver.c htsserver.h htsweb.c htsweb.h
|
||||
proxytrack_SOURCES = proxy/main.c \
|
||||
proxy/proxytrack.c proxy/store.c \
|
||||
htsinthash.c htsmd5.c md5.c \
|
||||
coucal.c htsmd5.c md5.c \
|
||||
minizip/ioapi.c minizip/mztools.c minizip/unzip.c minizip/zip.c
|
||||
|
||||
whttrackrundir = $(bindir)
|
||||
whttrackrun_SCRIPTS = webhttrack
|
||||
|
||||
libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
htscatchurl.c htsfilters.c htsftp.c htshash.c htsinthash.c \
|
||||
htscatchurl.c htsfilters.c htsftp.c htshash.c coucal.c \
|
||||
htshelp.c htslib.c htscoremain.c \
|
||||
htsname.c htsrobots.c htstools.c htswizard.c \
|
||||
htsalias.c htsthread.c htsindex.c htsbauth.c \
|
||||
@@ -55,7 +56,7 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
hts-indextmpl.h htsalias.h htsback.h htsbase.h htssafe.h \
|
||||
htsbasenet.h htsbauth.h htscache.h htscatchurl.h \
|
||||
htsconfig.h htscore.h htsparse.h htscoremain.h htsdefines.h \
|
||||
htsfilters.h htsftp.h htsglobal.h htshash.h htsinthash.h \
|
||||
htsfilters.h htsftp.h htsglobal.h htshash.h coucal.h \
|
||||
htshelp.h htsindex.h htslib.h htsmd5.h \
|
||||
htsmodules.h htsname.h htsnet.h \
|
||||
htsopt.h htsrobots.h htsthread.h \
|
||||
@@ -66,7 +67,7 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
md5.h murmurhash3.h \
|
||||
minizip/crypt.h minizip/ioapi.h minizip/mztools.h minizip/unzip.h minizip/zip.h
|
||||
libhttrack_la_LIBADD = $(THREADS_LIBS) $(ZLIB_LIBS) $(OPENSSL_LIBS) $(DL_LIBS) $(SOCKET_LIBS) $(ICONV_LIBS)
|
||||
libhttrack_la_CFLAGS = $(AM_CFLAGS) -DLIBHTTRACK_EXPORTS
|
||||
libhttrack_la_CFLAGS = $(AM_CFLAGS) -DLIBHTTRACK_EXPORTS -DZLIB_CONST
|
||||
libhttrack_la_LDFLAGS = -version-info $(VERSION_INFO)
|
||||
|
||||
libhtsjava_la_SOURCES = htsjava.c htsjava.h
|
||||
@@ -74,12 +75,20 @@ libhtsjava_la_LIBADD = $(THREADS_LIBS) $(DL_LIBS) libhttrack.la
|
||||
libhtsjava_la_LDFLAGS = -version-info $(VERSION_INFO)
|
||||
|
||||
EXTRA_DIST = httrack.h webhttrack \
|
||||
murmurhash3.h.diff \
|
||||
murmurhash3.h.orig \
|
||||
minizip/iowin32.c \
|
||||
minizip/iowin32.h \
|
||||
minizip/ioapi.c.diff \
|
||||
minizip/ioapi.h.diff \
|
||||
minizip/zip.c.diff \
|
||||
minizip/zip.h.diff \
|
||||
minizip/mztools.c.diff \
|
||||
minizip/ioapi.c.orig \
|
||||
minizip/ioapi.h.orig \
|
||||
minizip/mztools.c.orig \
|
||||
minizip/zip.c.orig \
|
||||
minizip/zip.h.orig \
|
||||
minizip/MiniZip64_Changes.txt \
|
||||
minizip/MiniZip64_info.txt \
|
||||
proxy/AUTHORS \
|
||||
|
||||
101
src/Makefile.in
101
src/Makefile.in
@@ -115,7 +115,7 @@ am_libhttrack_la_OBJECTS = libhttrack_la-htscore.lo \
|
||||
libhttrack_la-htsparse.lo libhttrack_la-htsback.lo \
|
||||
libhttrack_la-htscache.lo libhttrack_la-htscatchurl.lo \
|
||||
libhttrack_la-htsfilters.lo libhttrack_la-htsftp.lo \
|
||||
libhttrack_la-htshash.lo libhttrack_la-htsinthash.lo \
|
||||
libhttrack_la-htshash.lo libhttrack_la-coucal.lo \
|
||||
libhttrack_la-htshelp.lo libhttrack_la-htslib.lo \
|
||||
libhttrack_la-htscoremain.lo libhttrack_la-htsname.lo \
|
||||
libhttrack_la-htsrobots.lo libhttrack_la-htstools.lo \
|
||||
@@ -134,18 +134,22 @@ libhttrack_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libhttrack_la_CFLAGS) \
|
||||
$(CFLAGS) $(libhttrack_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_htsserver_OBJECTS = htsserver.$(OBJEXT) htsweb.$(OBJEXT)
|
||||
am_htsserver_OBJECTS = htsserver-htsserver.$(OBJEXT) \
|
||||
htsserver-htsweb.$(OBJEXT)
|
||||
htsserver_OBJECTS = $(am_htsserver_OBJECTS)
|
||||
htsserver_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
|
||||
libhttrack.la
|
||||
htsserver_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(htsserver_CFLAGS) \
|
||||
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
httrack_SOURCES = httrack.c
|
||||
httrack_OBJECTS = httrack.$(OBJEXT)
|
||||
httrack_DEPENDENCIES = $(am__DEPENDENCIES_1) libhttrack.la
|
||||
am_proxytrack_OBJECTS = proxy/proxytrack-main.$(OBJEXT) \
|
||||
proxy/proxytrack-proxytrack.$(OBJEXT) \
|
||||
proxy/proxytrack-store.$(OBJEXT) \
|
||||
proxytrack-htsinthash.$(OBJEXT) proxytrack-htsmd5.$(OBJEXT) \
|
||||
proxytrack-md5.$(OBJEXT) minizip/proxytrack-ioapi.$(OBJEXT) \
|
||||
proxy/proxytrack-store.$(OBJEXT) proxytrack-coucal.$(OBJEXT) \
|
||||
proxytrack-htsmd5.$(OBJEXT) proxytrack-md5.$(OBJEXT) \
|
||||
minizip/proxytrack-ioapi.$(OBJEXT) \
|
||||
minizip/proxytrack-mztools.$(OBJEXT) \
|
||||
minizip/proxytrack-unzip.$(OBJEXT) \
|
||||
minizip/proxytrack-zip.$(OBJEXT)
|
||||
@@ -343,18 +347,19 @@ AM_CPPFLAGS = \
|
||||
httrack_LDADD = $(THREADS_LIBS) libhttrack.la
|
||||
htsserver_LDADD = $(THREADS_LIBS) $(SOCKET_LIBS) libhttrack.la
|
||||
proxytrack_LDADD = $(THREADS_LIBS) $(SOCKET_LIBS)
|
||||
proxytrack_CFLAGS = $(AM_CFLAGS) -DNO_MALLOCT
|
||||
proxytrack_CFLAGS = $(AM_CFLAGS) -DNO_MALLOCT -DZLIB_CONST -DHTS_INTHASH_USES_MD5
|
||||
htsserver_CFLAGS = $(AM_CFLAGS) -DZLIB_CONST -DHTS_INTHASH_USES_MD5
|
||||
lib_LTLIBRARIES = libhttrack.la libhtsjava.la
|
||||
htsserver_SOURCES = htsserver.c htsserver.h htsweb.c htsweb.h
|
||||
proxytrack_SOURCES = proxy/main.c \
|
||||
proxy/proxytrack.c proxy/store.c \
|
||||
htsinthash.c htsmd5.c md5.c \
|
||||
coucal.c htsmd5.c md5.c \
|
||||
minizip/ioapi.c minizip/mztools.c minizip/unzip.c minizip/zip.c
|
||||
|
||||
whttrackrundir = $(bindir)
|
||||
whttrackrun_SCRIPTS = webhttrack
|
||||
libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
htscatchurl.c htsfilters.c htsftp.c htshash.c htsinthash.c \
|
||||
htscatchurl.c htsfilters.c htsftp.c htshash.c coucal.c \
|
||||
htshelp.c htslib.c htscoremain.c \
|
||||
htsname.c htsrobots.c htstools.c htswizard.c \
|
||||
htsalias.c htsthread.c htsindex.c htsbauth.c \
|
||||
@@ -365,7 +370,7 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
hts-indextmpl.h htsalias.h htsback.h htsbase.h htssafe.h \
|
||||
htsbasenet.h htsbauth.h htscache.h htscatchurl.h \
|
||||
htsconfig.h htscore.h htsparse.h htscoremain.h htsdefines.h \
|
||||
htsfilters.h htsftp.h htsglobal.h htshash.h htsinthash.h \
|
||||
htsfilters.h htsftp.h htsglobal.h htshash.h coucal.h \
|
||||
htshelp.h htsindex.h htslib.h htsmd5.h \
|
||||
htsmodules.h htsname.h htsnet.h \
|
||||
htsopt.h htsrobots.h htsthread.h \
|
||||
@@ -377,18 +382,26 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
minizip/crypt.h minizip/ioapi.h minizip/mztools.h minizip/unzip.h minizip/zip.h
|
||||
|
||||
libhttrack_la_LIBADD = $(THREADS_LIBS) $(ZLIB_LIBS) $(OPENSSL_LIBS) $(DL_LIBS) $(SOCKET_LIBS) $(ICONV_LIBS)
|
||||
libhttrack_la_CFLAGS = $(AM_CFLAGS) -DLIBHTTRACK_EXPORTS
|
||||
libhttrack_la_CFLAGS = $(AM_CFLAGS) -DLIBHTTRACK_EXPORTS -DZLIB_CONST
|
||||
libhttrack_la_LDFLAGS = -version-info $(VERSION_INFO)
|
||||
libhtsjava_la_SOURCES = htsjava.c htsjava.h
|
||||
libhtsjava_la_LIBADD = $(THREADS_LIBS) $(DL_LIBS) libhttrack.la
|
||||
libhtsjava_la_LDFLAGS = -version-info $(VERSION_INFO)
|
||||
EXTRA_DIST = httrack.h webhttrack \
|
||||
murmurhash3.h.diff \
|
||||
murmurhash3.h.orig \
|
||||
minizip/iowin32.c \
|
||||
minizip/iowin32.h \
|
||||
minizip/ioapi.c.diff \
|
||||
minizip/ioapi.h.diff \
|
||||
minizip/zip.c.diff \
|
||||
minizip/zip.h.diff \
|
||||
minizip/mztools.c.diff \
|
||||
minizip/ioapi.c.orig \
|
||||
minizip/ioapi.h.orig \
|
||||
minizip/mztools.c.orig \
|
||||
minizip/zip.c.orig \
|
||||
minizip/zip.h.orig \
|
||||
minizip/MiniZip64_Changes.txt \
|
||||
minizip/MiniZip64_info.txt \
|
||||
proxy/AUTHORS \
|
||||
@@ -531,7 +544,7 @@ clean-binPROGRAMS:
|
||||
rm -f $$list
|
||||
htsserver$(EXEEXT): $(htsserver_OBJECTS) $(htsserver_DEPENDENCIES) $(EXTRA_htsserver_DEPENDENCIES)
|
||||
@rm -f htsserver$(EXEEXT)
|
||||
$(LINK) $(htsserver_OBJECTS) $(htsserver_LDADD) $(LIBS)
|
||||
$(htsserver_LINK) $(htsserver_OBJECTS) $(htsserver_LDADD) $(LIBS)
|
||||
httrack$(EXEEXT): $(httrack_OBJECTS) $(httrack_DEPENDENCIES) $(EXTRA_httrack_DEPENDENCIES)
|
||||
@rm -f httrack$(EXEEXT)
|
||||
$(LINK) $(httrack_OBJECTS) $(httrack_LDADD) $(LIBS)
|
||||
@@ -616,9 +629,10 @@ distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htsjava.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htsserver.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htsweb.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htsserver-htsserver.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htsserver-htsweb.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httrack.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-coucal.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htsalias.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htsback.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htsbauth.Plo@am__quote@
|
||||
@@ -634,7 +648,6 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htshash.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htshelp.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htsindex.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htsinthash.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htslib.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htsmd5.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htsmodules.Plo@am__quote@
|
||||
@@ -648,7 +661,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htszlib.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-md5.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-punycode.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-htsinthash.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-coucal.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-htsmd5.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-md5.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@minizip/$(DEPDIR)/libhttrack_la-ioapi.Plo@am__quote@
|
||||
@@ -743,12 +756,12 @@ libhttrack_la-htshash.lo: htshash.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o libhttrack_la-htshash.lo `test -f 'htshash.c' || echo '$(srcdir)/'`htshash.c
|
||||
|
||||
libhttrack_la-htsinthash.lo: htsinthash.c
|
||||
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT libhttrack_la-htsinthash.lo -MD -MP -MF $(DEPDIR)/libhttrack_la-htsinthash.Tpo -c -o libhttrack_la-htsinthash.lo `test -f 'htsinthash.c' || echo '$(srcdir)/'`htsinthash.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libhttrack_la-htsinthash.Tpo $(DEPDIR)/libhttrack_la-htsinthash.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='htsinthash.c' object='libhttrack_la-htsinthash.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
libhttrack_la-coucal.lo: coucal.c
|
||||
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT libhttrack_la-coucal.lo -MD -MP -MF $(DEPDIR)/libhttrack_la-coucal.Tpo -c -o libhttrack_la-coucal.lo `test -f 'coucal.c' || echo '$(srcdir)/'`coucal.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libhttrack_la-coucal.Tpo $(DEPDIR)/libhttrack_la-coucal.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='coucal.c' object='libhttrack_la-coucal.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o libhttrack_la-htsinthash.lo `test -f 'htsinthash.c' || echo '$(srcdir)/'`htsinthash.c
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o libhttrack_la-coucal.lo `test -f 'coucal.c' || echo '$(srcdir)/'`coucal.c
|
||||
|
||||
libhttrack_la-htshelp.lo: htshelp.c
|
||||
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT libhttrack_la-htshelp.lo -MD -MP -MF $(DEPDIR)/libhttrack_la-htshelp.Tpo -c -o libhttrack_la-htshelp.lo `test -f 'htshelp.c' || echo '$(srcdir)/'`htshelp.c
|
||||
@@ -918,6 +931,34 @@ minizip/libhttrack_la-zip.lo: minizip/zip.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o minizip/libhttrack_la-zip.lo `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c
|
||||
|
||||
htsserver-htsserver.o: htsserver.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htsserver_CFLAGS) $(CFLAGS) -MT htsserver-htsserver.o -MD -MP -MF $(DEPDIR)/htsserver-htsserver.Tpo -c -o htsserver-htsserver.o `test -f 'htsserver.c' || echo '$(srcdir)/'`htsserver.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/htsserver-htsserver.Tpo $(DEPDIR)/htsserver-htsserver.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='htsserver.c' object='htsserver-htsserver.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htsserver_CFLAGS) $(CFLAGS) -c -o htsserver-htsserver.o `test -f 'htsserver.c' || echo '$(srcdir)/'`htsserver.c
|
||||
|
||||
htsserver-htsserver.obj: htsserver.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htsserver_CFLAGS) $(CFLAGS) -MT htsserver-htsserver.obj -MD -MP -MF $(DEPDIR)/htsserver-htsserver.Tpo -c -o htsserver-htsserver.obj `if test -f 'htsserver.c'; then $(CYGPATH_W) 'htsserver.c'; else $(CYGPATH_W) '$(srcdir)/htsserver.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/htsserver-htsserver.Tpo $(DEPDIR)/htsserver-htsserver.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='htsserver.c' object='htsserver-htsserver.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htsserver_CFLAGS) $(CFLAGS) -c -o htsserver-htsserver.obj `if test -f 'htsserver.c'; then $(CYGPATH_W) 'htsserver.c'; else $(CYGPATH_W) '$(srcdir)/htsserver.c'; fi`
|
||||
|
||||
htsserver-htsweb.o: htsweb.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htsserver_CFLAGS) $(CFLAGS) -MT htsserver-htsweb.o -MD -MP -MF $(DEPDIR)/htsserver-htsweb.Tpo -c -o htsserver-htsweb.o `test -f 'htsweb.c' || echo '$(srcdir)/'`htsweb.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/htsserver-htsweb.Tpo $(DEPDIR)/htsserver-htsweb.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='htsweb.c' object='htsserver-htsweb.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htsserver_CFLAGS) $(CFLAGS) -c -o htsserver-htsweb.o `test -f 'htsweb.c' || echo '$(srcdir)/'`htsweb.c
|
||||
|
||||
htsserver-htsweb.obj: htsweb.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htsserver_CFLAGS) $(CFLAGS) -MT htsserver-htsweb.obj -MD -MP -MF $(DEPDIR)/htsserver-htsweb.Tpo -c -o htsserver-htsweb.obj `if test -f 'htsweb.c'; then $(CYGPATH_W) 'htsweb.c'; else $(CYGPATH_W) '$(srcdir)/htsweb.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/htsserver-htsweb.Tpo $(DEPDIR)/htsserver-htsweb.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='htsweb.c' object='htsserver-htsweb.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htsserver_CFLAGS) $(CFLAGS) -c -o htsserver-htsweb.obj `if test -f 'htsweb.c'; then $(CYGPATH_W) 'htsweb.c'; else $(CYGPATH_W) '$(srcdir)/htsweb.c'; fi`
|
||||
|
||||
proxy/proxytrack-main.o: proxy/main.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxy/proxytrack-main.o -MD -MP -MF proxy/$(DEPDIR)/proxytrack-main.Tpo -c -o proxy/proxytrack-main.o `test -f 'proxy/main.c' || echo '$(srcdir)/'`proxy/main.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) proxy/$(DEPDIR)/proxytrack-main.Tpo proxy/$(DEPDIR)/proxytrack-main.Po
|
||||
@@ -960,19 +1001,19 @@ proxy/proxytrack-store.obj: proxy/store.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxy/proxytrack-store.obj `if test -f 'proxy/store.c'; then $(CYGPATH_W) 'proxy/store.c'; else $(CYGPATH_W) '$(srcdir)/proxy/store.c'; fi`
|
||||
|
||||
proxytrack-htsinthash.o: htsinthash.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-htsinthash.o -MD -MP -MF $(DEPDIR)/proxytrack-htsinthash.Tpo -c -o proxytrack-htsinthash.o `test -f 'htsinthash.c' || echo '$(srcdir)/'`htsinthash.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-htsinthash.Tpo $(DEPDIR)/proxytrack-htsinthash.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='htsinthash.c' object='proxytrack-htsinthash.o' libtool=no @AMDEPBACKSLASH@
|
||||
proxytrack-coucal.o: coucal.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-coucal.o -MD -MP -MF $(DEPDIR)/proxytrack-coucal.Tpo -c -o proxytrack-coucal.o `test -f 'coucal.c' || echo '$(srcdir)/'`coucal.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-coucal.Tpo $(DEPDIR)/proxytrack-coucal.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='coucal.c' object='proxytrack-coucal.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-htsinthash.o `test -f 'htsinthash.c' || echo '$(srcdir)/'`htsinthash.c
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-coucal.o `test -f 'coucal.c' || echo '$(srcdir)/'`coucal.c
|
||||
|
||||
proxytrack-htsinthash.obj: htsinthash.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-htsinthash.obj -MD -MP -MF $(DEPDIR)/proxytrack-htsinthash.Tpo -c -o proxytrack-htsinthash.obj `if test -f 'htsinthash.c'; then $(CYGPATH_W) 'htsinthash.c'; else $(CYGPATH_W) '$(srcdir)/htsinthash.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-htsinthash.Tpo $(DEPDIR)/proxytrack-htsinthash.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='htsinthash.c' object='proxytrack-htsinthash.obj' libtool=no @AMDEPBACKSLASH@
|
||||
proxytrack-coucal.obj: coucal.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-coucal.obj -MD -MP -MF $(DEPDIR)/proxytrack-coucal.Tpo -c -o proxytrack-coucal.obj `if test -f 'coucal.c'; then $(CYGPATH_W) 'coucal.c'; else $(CYGPATH_W) '$(srcdir)/coucal.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-coucal.Tpo $(DEPDIR)/proxytrack-coucal.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='coucal.c' object='proxytrack-coucal.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-htsinthash.obj `if test -f 'htsinthash.c'; then $(CYGPATH_W) 'htsinthash.c'; else $(CYGPATH_W) '$(srcdir)/htsinthash.c'; fi`
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-coucal.obj `if test -f 'coucal.c'; then $(CYGPATH_W) 'coucal.c'; else $(CYGPATH_W) '$(srcdir)/coucal.c'; fi`
|
||||
|
||||
proxytrack-htsmd5.o: htsmd5.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-htsmd5.o -MD -MP -MF $(DEPDIR)/proxytrack-htsmd5.Tpo -c -o proxytrack-htsmd5.o `test -f 'htsmd5.c' || echo '$(srcdir)/'`htsmd5.c
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
529
src/coucal.h
Normal file
529
src/coucal.h
Normal file
@@ -0,0 +1,529 @@
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
Coucal, Cuckoo hashing-based hashtable with stash area.
|
||||
Copyright (C) 2013-2014 Xavier Roche (http://www.httrack.com/)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Coucal, a Cuckoo-hashing-based hashtable with stash area C library.
|
||||
*
|
||||
* This hashtable library provides key/value hashtable, with by default a
|
||||
* string key, and integer/pointer value (with an associated optional
|
||||
* allocator). Both key and value can be of any type, using custom settings.
|
||||
* By default, the string key is dup'ed using a string pool, and the opaque
|
||||
* value is stored as-is (either the pointer, or an uintptr_t integer value).
|
||||
* It features O(1) average insertion, and guaranteed O(1) lookup, replace,
|
||||
* and delete operations.
|
||||
*
|
||||
* Implementation notes:
|
||||
* Implementation is auto-rehashable, and uses cuckoo hashing of size 2**n
|
||||
* with a Murmur or MD5 hash function, with one additional auxiliary hash
|
||||
* function.
|
||||
* It also uses a small stash area to handle rare cases of collisions.
|
||||
* Enumeration of all key/values is possible, deletion is also possible, but
|
||||
* currently without any auto-shrinking (ie. table will never shrink).
|
||||
* Overall, two main blocks are allocated: one for the items, and one for
|
||||
* the keys (pool).
|
||||
* If the string pool is being used (to store dup'ed keys), deleting is only
|
||||
* O(1) average, because the pool needs to be compacted time to time.
|
||||
* Currently the default maximum number of elements in the hashtable is
|
||||
* 2**31 - 1 (that is, 2,147,483,648 elements), but this default can be changed
|
||||
* by setting COUCAL_HASH_SIZE to a higher value (64 is the only higher value
|
||||
* currently supported), and rebuilding the library.
|
||||
*
|
||||
* References:
|
||||
*
|
||||
* Cuckoo Hashing, by Rasmus Pagh and Flemming Friche Rodler
|
||||
* http://www.it-c.dk/people/pagh/papers/cuckoo-jour.pdf
|
||||
*
|
||||
* Cuckoo Stash, by Adam Kirsch, Michael Mitzenmacher and Udi Wieder
|
||||
* http://research.microsoft.com/pubs/73856/stash-full.9-30.pdf
|
||||
*
|
||||
* MurmurHash3, by Austin Appleby
|
||||
* http://en.wikipedia.org/wiki/MurmurHash
|
||||
*
|
||||
* MD5 http://en.wikipedia.org/wiki/MD5
|
||||
* FNV http://www.isthe.com/chongo/tech/comp/fnv/
|
||||
**/
|
||||
|
||||
#ifndef COUCAL_DEFH
|
||||
#define COUCAL_DEFH
|
||||
|
||||
/* Includes */
|
||||
#ifdef _WIN32
|
||||
#include <stddef.h>
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#elif (defined(SOLARIS) || defined(sun) || defined(HAVE_INTTYPES_H) \
|
||||
|| defined(BSD) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD_kernel__))
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
/* External definitions */
|
||||
#ifndef COUCAL_EXTERN
|
||||
#ifdef _WIN32
|
||||
#ifdef COUCAL_BUILDING
|
||||
#define COUCAL_EXTERN __declspec(dllimport)
|
||||
#else
|
||||
#define COUCAL_EXTERN __declspec(dllexport)
|
||||
#endif
|
||||
#elif ( ( defined(__GNUC__) && ( __GNUC__ >= 4 ) ) \
|
||||
|| ( defined(HAVE_VISIBILITY) && HAVE_VISIBILITY ) )
|
||||
#define COUCAL_EXTERN extern __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define COUCAL_EXTERN extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Key opaque type. May be a regular 'const char*'. **/
|
||||
typedef void* coucal_key;
|
||||
|
||||
/** Key constant (can not be modified) opaque type. **/
|
||||
typedef const void* coucal_key_const;
|
||||
|
||||
/** Opaque user-defined pointer. **/
|
||||
typedef void* coucal_opaque;
|
||||
|
||||
/** Value (union of any value). **/
|
||||
typedef union coucal_value {
|
||||
/** Integer value. **/
|
||||
intptr_t intg;
|
||||
|
||||
/** Unsigned integer value. **/
|
||||
uintptr_t uintg;
|
||||
|
||||
/** Pointer value. **/
|
||||
void *ptr;
|
||||
} coucal_value;
|
||||
|
||||
/** Value constant. **/
|
||||
typedef const coucal_value coucal_value_const;
|
||||
|
||||
/** NULL Value. **/
|
||||
#define INTHASH_VALUE_NULL { 0 }
|
||||
|
||||
#ifndef HTS_DEF_FWSTRUCT_coucal_item
|
||||
#define HTS_DEF_FWSTRUCT_coucal_item
|
||||
typedef struct coucal_item coucal_item;
|
||||
#endif
|
||||
|
||||
/** Coucal primary hash size. Default is 32-bit. **/
|
||||
#ifndef COUCAL_HASH_SIZE
|
||||
#define COUCAL_HASH_SIZE 32
|
||||
#endif
|
||||
|
||||
/** Hash integer type. **/
|
||||
#if (COUCAL_HASH_SIZE == 32)
|
||||
|
||||
/** 32-bit hash key. **/
|
||||
typedef uint32_t coucal_hashkey;
|
||||
|
||||
#elif (COUCAL_HASH_SIZE == 64)
|
||||
|
||||
/** 64-bit hash key. **/
|
||||
typedef uint64_t coucal_hashkey;
|
||||
|
||||
#else
|
||||
#error "Unsupported COUCAL_HASH_SIZE"
|
||||
#endif
|
||||
|
||||
/** Pair of hashes **/
|
||||
typedef struct coucal_hashkeys {
|
||||
coucal_hashkey hash1;
|
||||
coucal_hashkey hash2;
|
||||
} coucal_hashkeys;
|
||||
|
||||
/** NULL pair of hashes. **/
|
||||
#define INTHASH_KEYS_NULL { 0, 0 }
|
||||
|
||||
/** Item holding a value. **/
|
||||
struct coucal_item {
|
||||
/** Key. **/
|
||||
coucal_key name;
|
||||
|
||||
/** Value. **/
|
||||
coucal_value value;
|
||||
|
||||
/** Hashes of the key. **/
|
||||
coucal_hashkeys hashes;
|
||||
};
|
||||
|
||||
/** Log level. **/
|
||||
typedef enum coucal_loglevel {
|
||||
coucal_log_critical,
|
||||
coucal_log_warning,
|
||||
coucal_log_info,
|
||||
coucal_log_debug,
|
||||
coucal_log_trace
|
||||
} coucal_loglevel;
|
||||
|
||||
/** free handler. Only used when values are markes as xxc **/
|
||||
typedef void (*t_coucal_key_freehandler)(coucal_opaque arg,
|
||||
coucal_key key);
|
||||
|
||||
/** Value free handler. Only used when values are markes as xxc **/
|
||||
typedef void (*t_coucal_value_freehandler)(coucal_opaque arg,
|
||||
coucal_value value);
|
||||
|
||||
/** Key dup handler. **/
|
||||
typedef coucal_key (*t_coucal_duphandler)(coucal_opaque arg,
|
||||
coucal_key_const name);
|
||||
|
||||
/** Key hash computation handler. **/
|
||||
typedef coucal_hashkeys (*t_coucal_hasheshandler)(coucal_opaque arg,
|
||||
coucal_key_const name);
|
||||
|
||||
/** Hashtable logging handler. **/
|
||||
typedef void (*t_coucal_loghandler)(coucal_opaque arg, coucal_loglevel level,
|
||||
const char* format, va_list args);
|
||||
|
||||
/** Hashtable fatal assertion failure. **/
|
||||
typedef void (*t_coucal_asserthandler)(coucal_opaque arg, const char* exp,
|
||||
const char* file, int line);
|
||||
|
||||
/** Key printer (debug) **/
|
||||
typedef const char* (*t_coucal_printkeyhandler)(coucal_opaque arg,
|
||||
coucal_key_const name);
|
||||
|
||||
/** Value printer (debug) **/
|
||||
typedef const char* (*t_coucal_printvaluehandler)(coucal_opaque arg,
|
||||
coucal_value_const value);
|
||||
|
||||
/**
|
||||
* Value comparison handler (returns non-zero value if strings are equal).
|
||||
**/
|
||||
typedef int (*t_coucal_cmphandler)(coucal_opaque arg,
|
||||
coucal_key_const a,
|
||||
coucal_key_const b);
|
||||
|
||||
/** Hashtable (opaque structure). **/
|
||||
#ifndef HTS_DEF_FWSTRUCT_struct_coucal
|
||||
#define HTS_DEF_FWSTRUCT_struct_coucal
|
||||
typedef struct struct_coucal struct_coucal, *coucal;
|
||||
#endif
|
||||
|
||||
/** Hashtable enumeration (opaque structure). **/
|
||||
#ifndef HTS_DEF_FWSTRUCT_struct_coucal_enum
|
||||
#define HTS_DEF_FWSTRUCT_struct_coucal_enum
|
||||
typedef struct struct_coucal_enum struct_coucal_enum;
|
||||
#endif
|
||||
|
||||
/** Enumeration. **/
|
||||
struct struct_coucal_enum {
|
||||
coucal table;
|
||||
size_t index;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create a new hashtable, with initial bucket size of 'size'.
|
||||
* If size is 0, use the default minimal bucket size.
|
||||
* Return a non-NULL pointer upon success.
|
||||
*
|
||||
* By default, keys are supposed to be '\0'-terminated strings, which are
|
||||
* duplicated by the library (the passed pointer does not need to be
|
||||
* persistent), and values are opaque pointers (or integers) which are copied
|
||||
* "as is", without further processing. Use coucal_value_set_key_handler()
|
||||
* and coucal_value_set_value_handler() to alter this default behavior.
|
||||
**/
|
||||
COUCAL_EXTERN coucal coucal_new(size_t size);
|
||||
|
||||
/**
|
||||
* Was the hashtable successfully created ?
|
||||
* Return non-zero value if the hashtable is valid.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_created(coucal hashtable);
|
||||
|
||||
/**
|
||||
* Delete a hashtable, freeing all entries.
|
||||
**/
|
||||
COUCAL_EXTERN void coucal_delete(coucal * hashtable);
|
||||
|
||||
/**
|
||||
* Return the number of items in the hashtable.
|
||||
**/
|
||||
COUCAL_EXTERN size_t coucal_nitems(coucal hashtable);
|
||||
|
||||
/**
|
||||
* Return the memory size taken by the hashtable.
|
||||
* (This does not take account of the possible memory taken by values)
|
||||
**/
|
||||
COUCAL_EXTERN size_t coucal_memory_size(coucal hashtable);
|
||||
|
||||
/**
|
||||
* Return the library hash size compiled.
|
||||
* The returned value MUST match COUCAL_HASH_SIZE.
|
||||
**/
|
||||
COUCAL_EXTERN size_t coucal_hash_size(void);
|
||||
|
||||
/**
|
||||
* If 'flag' is non-zero, calls coucal_value_set_value_handler() with
|
||||
* default system free() handler function, otherwise, free the value handlers.
|
||||
**/
|
||||
COUCAL_EXTERN void coucal_value_is_malloc(coucal hashtable, int flag);
|
||||
|
||||
/**
|
||||
* Set handlers for values.
|
||||
* free: this handler will be called when a value is to be removed from
|
||||
* the hashtable. if NULL, values won't be free'd.
|
||||
* arg: opaque custom argument to be used by functions.
|
||||
* Handler(s) MUST NOT be changed once elements have been added.
|
||||
**/
|
||||
COUCAL_EXTERN void coucal_value_set_value_handler(coucal hashtable,
|
||||
t_coucal_value_freehandler free,
|
||||
coucal_opaque arg);
|
||||
|
||||
/**
|
||||
* Set handlers for keys.
|
||||
* dup: handler called to duplicate a key. if NULL, the internal pool is used.
|
||||
* free: handler called to free a key. if NULL, the internal pool is used.
|
||||
* hash: hashing handler, called to hash a key. if NULL, the default hash
|
||||
* function is used.
|
||||
* equals: comparison handler, returning non-zero value when two keys are
|
||||
* identical. if NULL, the default comparison function is used.
|
||||
* arg: opaque custom argument to be used by functions.
|
||||
* Handler(s) MUST NOT be changed once elements have been added.
|
||||
**/
|
||||
COUCAL_EXTERN void coucal_value_set_key_handler(coucal hashtable,
|
||||
t_coucal_duphandler dup,
|
||||
t_coucal_key_freehandler free,
|
||||
t_coucal_hasheshandler hash,
|
||||
t_coucal_cmphandler equals,
|
||||
coucal_opaque arg);
|
||||
|
||||
/**
|
||||
* Set assertion failure handler.
|
||||
* log: handler called upon serious programming error
|
||||
* fatal: handler called upon serious programming error
|
||||
**/
|
||||
COUCAL_EXTERN void coucal_set_assert_handler(coucal hashtable,
|
||||
t_coucal_loghandler log,
|
||||
t_coucal_asserthandler fatal,
|
||||
coucal_opaque arg);
|
||||
|
||||
/**
|
||||
* Set pretty print loggers (debug). Both handlers must return a string
|
||||
* pointer which shall be valid until the next call. Both key and value
|
||||
* pointers shall be valid at the same time.
|
||||
* name: handler called to print the string representation of the name
|
||||
* value: handler called to print the string representation of the value
|
||||
**/
|
||||
COUCAL_EXTERN void coucal_set_print_handler(coucal hashtable,
|
||||
t_coucal_printkeyhandler key,
|
||||
t_coucal_printvaluehandler value,
|
||||
coucal_opaque arg);
|
||||
|
||||
/**
|
||||
* Set the hashtable name, for degugging purpose.
|
||||
* name: the hashtable name (ASCII or UTF-8)
|
||||
*/
|
||||
COUCAL_EXTERN void coucal_set_name(coucal hashtable, coucal_key_const name);
|
||||
|
||||
/**
|
||||
* Get the hashtable name, for degugging purpose.
|
||||
* Return NULL if no name was defined.
|
||||
**/
|
||||
COUCAL_EXTERN const char* coucal_get_name(coucal hashtable);
|
||||
|
||||
/**
|
||||
* Read an integer entry from the hashtable.
|
||||
* Return non-zero value upon success and sets intvalue.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_read(coucal hashtable, coucal_key_const name,
|
||||
intptr_t * intvalue);
|
||||
|
||||
/**
|
||||
* Same as coucal_read(), but return 0 is the value was zero.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_readptr(coucal hashtable, coucal_key_const name,
|
||||
intptr_t * intvalue);
|
||||
|
||||
/**
|
||||
* Read an integer entry from the hashtable.
|
||||
* Return 0 if the entry could not be found.
|
||||
**/
|
||||
COUCAL_EXTERN intptr_t coucal_get_intptr(coucal hashtable,
|
||||
coucal_key_const name);
|
||||
|
||||
/**
|
||||
* Return non-zero value if the given entry exists.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_exists(coucal hashtable, coucal_key_const name);
|
||||
|
||||
/**
|
||||
* Read an entry from the hashtable.
|
||||
* Return non-zero value upon success and sets value.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_read_value(coucal hashtable, coucal_key_const name,
|
||||
coucal_value *value);
|
||||
|
||||
/**
|
||||
* Write an entry to the hashtable.
|
||||
* Return non-zero value if the entry was added, zero if it was replaced.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_write_value(coucal hashtable, coucal_key_const name,
|
||||
coucal_value_const value);
|
||||
|
||||
/**
|
||||
* Read a pointer entry from the hashtable.
|
||||
* Return non-zero value upon success and sets value.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_read_pvoid(coucal hashtable, coucal_key_const name,
|
||||
void **value);
|
||||
|
||||
/**
|
||||
* Read a pointer entry from the hashtable and returns its value.
|
||||
* Return NULL if the entry could not be found.
|
||||
**/
|
||||
COUCAL_EXTERN void* coucal_get_pvoid(coucal hashtable, coucal_key_const name);
|
||||
|
||||
/**
|
||||
* Write a pointer entry to the hashtable.
|
||||
* Return non-zero value if the entry was added, zero if it was replaced.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_write_pvoid(coucal hashtable, coucal_key_const name,
|
||||
void *value);
|
||||
|
||||
/**
|
||||
* Alias to coucal_write_pvoid()
|
||||
**/
|
||||
COUCAL_EXTERN void coucal_add_pvoid(coucal hashtable, coucal_key_const name,
|
||||
void *value);
|
||||
|
||||
/**
|
||||
* Write an integer entry to the hashtable.
|
||||
* Return non-zero value if the entry was added, zero if it was replaced.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_write(coucal hashtable, coucal_key_const name,
|
||||
intptr_t value);
|
||||
|
||||
/**
|
||||
* Alias to coucal_write()
|
||||
**/
|
||||
COUCAL_EXTERN void coucal_add(coucal hashtable, coucal_key_const name,
|
||||
intptr_t value);
|
||||
|
||||
/**
|
||||
* Increment an entry value in the hashtable
|
||||
* (or create a new entry with value 1 if it does not yet exist)
|
||||
* Return non-zero value if the entry was added, zero if it was changed.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_inc(coucal hashtable, coucal_key_const name);
|
||||
|
||||
/**
|
||||
* Decrement an entry value in the hashtable
|
||||
* (or create a new entry with value -1 if it does not yet exist)
|
||||
* Return non-zero value if the entry was added, zero if it was changed.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_dec(coucal hashtable, coucal_key_const name);
|
||||
|
||||
/**
|
||||
* Fetch an entry value from the hashtable.
|
||||
* Returns NULL if the entry could not be found.
|
||||
* The returned pointer is only valid until next call to this library, and can
|
||||
* be used for read or write operations.
|
||||
**/
|
||||
COUCAL_EXTERN coucal_value* coucal_fetch_value(coucal hashtable,
|
||||
coucal_key_const name);
|
||||
|
||||
/**
|
||||
* Fetch an entry value from the hashtable, given a name, and its hashes.
|
||||
* Returns NULL if the entry could not be found.
|
||||
* The returned pointer is only valid until next call to this library, and can
|
||||
* be used for read or write operations.
|
||||
* The hashes MUST have been computed using coucal_calc_hashes(), or by
|
||||
* copying an existing hash during an enumeration.
|
||||
* The use of a non-matching hash is safe, but will return NULL.
|
||||
**/
|
||||
COUCAL_EXTERN coucal_value* coucal_fetch_value_hashes(coucal hashtable,
|
||||
coucal_key_const name,
|
||||
const coucal_hashkeys
|
||||
*hashes);
|
||||
|
||||
/**
|
||||
* Remove an entry from the hashtable
|
||||
* Return non-zero value if the entry was removed, zero otherwise.
|
||||
**/
|
||||
COUCAL_EXTERN int coucal_remove(coucal hashtable, coucal_key_const name);
|
||||
|
||||
/**
|
||||
* Return a new enumerator.
|
||||
* Note: deleting entries is safe while enumerating, but adding entries
|
||||
* lead to undefined enumeration behavior (yet safe).
|
||||
**/
|
||||
COUCAL_EXTERN struct_coucal_enum coucal_enum_new(coucal hashtable);
|
||||
|
||||
/**
|
||||
* Enumerate the next entry.
|
||||
**/
|
||||
COUCAL_EXTERN coucal_item *coucal_enum_next(struct_coucal_enum * e);
|
||||
|
||||
/**
|
||||
* Compute a hash of a key for the hashtable 'hashtable'.
|
||||
* The returned hash is suitable for use with coucal_fetch_value_hashes()
|
||||
* Note: the default implementation uses coucal_hash_string()
|
||||
**/
|
||||
COUCAL_EXTERN coucal_hashkeys coucal_calc_hashes(coucal hashtable,
|
||||
coucal_key_const value);
|
||||
|
||||
/**
|
||||
* Compute a hash, given a string. This is the default function used for
|
||||
* hashing keys, which are by default strings. This function uses
|
||||
* coucal_hash_data() as backend.
|
||||
**/
|
||||
COUCAL_EXTERN coucal_hashkeys coucal_hash_string(const char *value);
|
||||
|
||||
/**
|
||||
* Compute a hash, given an opaque buffer.
|
||||
**/
|
||||
COUCAL_EXTERN coucal_hashkeys coucal_hash_data(const void *data, size_t size);
|
||||
|
||||
/**
|
||||
* Set default global assertion failure handler.
|
||||
* The handler will be used if no specific handler was defined in the
|
||||
* hashtable itself.
|
||||
* log: handler called upon serious error log (opaque argument
|
||||
* is the hashtable itself)
|
||||
* fatal: handler called upon serious programming error (opaque argument
|
||||
* is the hashtable itself)
|
||||
**/
|
||||
COUCAL_EXTERN void coucal_set_global_assert_handler(t_coucal_loghandler log,
|
||||
t_coucal_asserthandler fatal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -73,11 +73,11 @@ struct_back *back_new(httrackp *opt, int back_max) {
|
||||
|
||||
sback->count = back_max;
|
||||
sback->lnk = (lien_back *) calloct((back_max + 1), sizeof(lien_back));
|
||||
sback->ready = inthash_new(0);
|
||||
sback->ready = coucal_new(0);
|
||||
hts_set_hash_handler(sback->ready, opt);
|
||||
inthash_set_name(sback->ready, "back_new");
|
||||
coucal_set_name(sback->ready, "back_new");
|
||||
sback->ready_size_bytes = 0;
|
||||
inthash_value_is_malloc(sback->ready, 1);
|
||||
coucal_value_is_malloc(sback->ready, 1);
|
||||
// init
|
||||
for(i = 0; i < sback->count; i++) {
|
||||
sback->lnk[i].r.location = sback->lnk[i].location_buffer;
|
||||
@@ -94,7 +94,7 @@ void back_free(struct_back ** sback) {
|
||||
(*sback)->lnk = NULL;
|
||||
}
|
||||
if ((*sback)->ready != NULL) {
|
||||
inthash_delete(&(*sback)->ready);
|
||||
coucal_delete(&(*sback)->ready);
|
||||
(*sback)->ready_size_bytes = 0;
|
||||
}
|
||||
freet(*sback);
|
||||
@@ -112,10 +112,10 @@ void back_delete_all(httrackp * opt, cache_back * cache, struct_back * sback) {
|
||||
}
|
||||
// delete stored slots
|
||||
if (sback->ready != NULL) {
|
||||
struct_inthash_enum e = inthash_enum_new(sback->ready);
|
||||
inthash_chain *item;
|
||||
struct_coucal_enum e = coucal_enum_new(sback->ready);
|
||||
coucal_item *item;
|
||||
|
||||
while((item = inthash_enum_next(&e))) {
|
||||
while((item = coucal_enum_next(&e))) {
|
||||
#ifndef HTS_NO_BACK_ON_DISK
|
||||
const char *filename = (char *) item->value.ptr;
|
||||
|
||||
@@ -130,7 +130,7 @@ void back_delete_all(httrackp * opt, cache_back * cache, struct_back * sback) {
|
||||
#endif
|
||||
}
|
||||
/* delete hashtable & content */
|
||||
inthash_delete(&sback->ready);
|
||||
coucal_delete(&sback->ready);
|
||||
sback->ready_size_bytes = 0;
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ static int back_index_ready(httrackp * opt, struct_back * sback, const char *adr
|
||||
lien_back *const back = sback->lnk;
|
||||
void *ptr = NULL;
|
||||
|
||||
if (inthash_read_pvoid(sback->ready, sav, &ptr)) {
|
||||
if (coucal_read_pvoid(sback->ready, sav, &ptr)) {
|
||||
if (!getIndex) { /* don't "pagefault" the entry */
|
||||
if (ptr != NULL) {
|
||||
return sback->count; /* (invalid but) positive result */
|
||||
@@ -228,7 +228,7 @@ static int back_index_ready(httrackp * opt, struct_back * sback, const char *adr
|
||||
back_clear_entry(itemback); /* delete entry content */
|
||||
freet(itemback); /* delete item */
|
||||
itemback = NULL;
|
||||
inthash_remove(sback->ready, sav); // delete item
|
||||
coucal_remove(sback->ready, sav); // delete item
|
||||
sback->ready_size_bytes -= back[q].r.size; /* substract for stats */
|
||||
back_set_locked(sback, q); /* locked */
|
||||
return q;
|
||||
@@ -309,7 +309,7 @@ int back_cleanup_background(httrackp * opt, cache_back * cache,
|
||||
/* Create file and serialize slot */
|
||||
if ((fp = filecreate(NULL, filename)) != NULL) {
|
||||
if (back_serialize(fp, &back[i]) == 0) {
|
||||
inthash_add_pvoid(sback->ready, back[i].url_sav, filename);
|
||||
coucal_add_pvoid(sback->ready, back[i].url_sav, filename);
|
||||
filename = NULL;
|
||||
sback->ready_size_bytes += back[i].r.size; /* add for stats */
|
||||
nclean++;
|
||||
@@ -340,7 +340,7 @@ int back_cleanup_background(httrackp * opt, cache_back * cache,
|
||||
#else
|
||||
itemback = calloct(1, sizeof(lien_back));
|
||||
back_move(&back[i], itemback);
|
||||
inthash_add_pvoid(sback->ready, itemback->url_sav, itemback);
|
||||
coucal_add_pvoid(sback->ready, itemback->url_sav, itemback);
|
||||
nclean++;
|
||||
#endif
|
||||
}
|
||||
@@ -375,10 +375,10 @@ LLint back_incache(const struct_back * sback) {
|
||||
// stored (ready) slots
|
||||
#ifdef HTS_NO_BACK_ON_DISK
|
||||
if (sback->ready != NULL) {
|
||||
struct_inthash_enum e = inthash_enum_new(sback->ready);
|
||||
inthash_chain *item;
|
||||
struct_coucal_enum e = coucal_enum_new(sback->ready);
|
||||
coucal_item *item;
|
||||
|
||||
while((item = inthash_enum_next(&e))) {
|
||||
while((item = coucal_enum_next(&e))) {
|
||||
lien_back *ritem = (lien_back *) item->value.ptr;
|
||||
|
||||
if (ritem->status != -1)
|
||||
@@ -403,12 +403,12 @@ int back_done_incache(const struct_back * sback) {
|
||||
// stored (ready) slots
|
||||
if (sback->ready != NULL) {
|
||||
#ifndef HTS_NO_BACK_ON_DISK
|
||||
n += (int) inthash_nitems(sback->ready);
|
||||
n += (int) coucal_nitems(sback->ready);
|
||||
#else
|
||||
struct_inthash_enum e = inthash_enum_new(sback->ready);
|
||||
inthash_chain *item;
|
||||
struct_coucal_enum e = coucal_enum_new(sback->ready);
|
||||
coucal_item *item;
|
||||
|
||||
while((item = inthash_enum_next(&e))) {
|
||||
while((item = coucal_enum_next(&e))) {
|
||||
lien_back *ritem = (lien_back *) item->value.ptr;
|
||||
|
||||
if (ritem->status == STATUS_READY)
|
||||
@@ -971,9 +971,10 @@ int back_unserialize(FILE * fp, lien_back ** dst) {
|
||||
if ((*dst)->r.adr != NULL)
|
||||
freet((*dst)->r.adr);
|
||||
}
|
||||
if (dst != NULL)
|
||||
freet(dst);
|
||||
*dst = NULL;
|
||||
if (dst != NULL) {
|
||||
freet(*dst);
|
||||
*dst = NULL;
|
||||
}
|
||||
return 1; /* error */
|
||||
}
|
||||
|
||||
@@ -1506,7 +1507,7 @@ int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char
|
||||
if (cache->cached_tests != NULL) {
|
||||
intptr_t ptr = 0;
|
||||
|
||||
if (inthash_read(cache->cached_tests,
|
||||
if (coucal_read(cache->cached_tests,
|
||||
concat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), adr, fil), &ptr)) { // gotcha
|
||||
if (ptr != 0) {
|
||||
char *text = (char *) ptr;
|
||||
@@ -1544,7 +1545,7 @@ int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char
|
||||
#if HTS_FAST_CACHE
|
||||
strcpybuff(buff, adr);
|
||||
strcatbuff(buff, fil);
|
||||
hash_pos_return = inthash_read(cache->hashtable, buff, &hash_pos);
|
||||
hash_pos_return = coucal_read(cache->hashtable, buff, &hash_pos);
|
||||
#else
|
||||
buff[0] = '\0';
|
||||
strcatbuff(buff, "\n");
|
||||
@@ -2131,7 +2132,7 @@ void back_solve(httrackp * opt, lien_back * back) {
|
||||
else
|
||||
a = back->r.req.proxy.name;
|
||||
assertf(a != NULL);
|
||||
a = jump_protocol(a);
|
||||
a = jump_protocol_const(a);
|
||||
if (check_hostname_dns(a)) {
|
||||
hts_log_print(opt, LOG_DEBUG, "resolved: %s", a);
|
||||
} else {
|
||||
@@ -2780,8 +2781,8 @@ void back_wait(struct_back * sback, httrackp * opt, cache_back * cache,
|
||||
back[i].r.is_write = 1; // écrire
|
||||
if (back[i].r.compressed &&
|
||||
/* .gz are *NOT* depacked!! */
|
||||
(strfield
|
||||
(get_ext(catbuff, sizeof(catbuff), back[i].url_sav), "gz") == 0)
|
||||
strfield(get_ext(catbuff, sizeof(catbuff), back[i].url_sav), "gz") == 0
|
||||
&& strfield(get_ext(catbuff, sizeof(catbuff), back[i].url_sav), "tgz") == 0
|
||||
) {
|
||||
if (create_back_tmpfile(opt, &back[i]) == 0) {
|
||||
assertf(back[i].tmpfile != NULL);
|
||||
@@ -3240,7 +3241,7 @@ void back_wait(struct_back * sback, httrackp * opt, cache_back * cache,
|
||||
fprintf(ioinfo,
|
||||
"[%d] response for %s%s:\r\ncode=%d\r\n",
|
||||
back[i].r.debugid,
|
||||
jump_identification(back[i].url_adr),
|
||||
jump_identification_const(back[i].url_adr),
|
||||
back[i].url_fil, back[i].r.statuscode);
|
||||
fprintfio(ioinfo, back[i].r.adr, ">>> ");
|
||||
fprintf(ioinfo, "\r\n");
|
||||
@@ -3978,10 +3979,10 @@ LLint back_transferred(LLint nb, struct_back * sback) {
|
||||
#ifndef HTS_NO_BACK_ON_DISK
|
||||
nb += sback->ready_size_bytes;
|
||||
#else
|
||||
struct_inthash_enum e = inthash_enum_new(sback->ready);
|
||||
inthash_chain *item;
|
||||
struct_coucal_enum e = coucal_enum_new(sback->ready);
|
||||
coucal_item *item;
|
||||
|
||||
while((item = inthash_enum_next(&e))) {
|
||||
while((item = coucal_enum_next(&e))) {
|
||||
lien_back *ritem = (lien_back *) item->value.ptr;
|
||||
|
||||
if ((ritem->status > 0) && (ritem->status < 99 || ritem->status >= 1000))
|
||||
|
||||
@@ -461,7 +461,7 @@ char *bauth_check(t_cookie * cookie, const char *adr, const char *fil) {
|
||||
char *bauth_prefix(char *prefix, const char *adr, const char *fil) {
|
||||
char *a;
|
||||
|
||||
strcpybuff(prefix, jump_identification(adr));
|
||||
strcpybuff(prefix, jump_identification_const(adr));
|
||||
strcatbuff(prefix, fil);
|
||||
a = strchr(prefix, '?');
|
||||
if (a)
|
||||
|
||||
@@ -145,7 +145,7 @@ void cache_mayadd(httrackp * opt, cache_back * cache, htsblk * r,
|
||||
// we just store statuscode + location (if any)
|
||||
if (url_save == NULL && r->statuscode / 100 >= 3) {
|
||||
// cached "fast" header doesn't yet exists
|
||||
if (inthash_read
|
||||
if (coucal_read
|
||||
(cache->cached_tests,
|
||||
concat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), url_adr, url_fil), NULL) == 0) {
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
@@ -158,7 +158,7 @@ void cache_mayadd(httrackp * opt, cache_back * cache, htsblk * r,
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"Cached fast-header response: %s%s is %d",
|
||||
url_adr, url_fil, (int) r->statuscode);
|
||||
inthash_add(cache->cached_tests,
|
||||
coucal_add(cache->cached_tests,
|
||||
concat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), url_adr, url_fil),
|
||||
(intptr_t) strdupt(tempo));
|
||||
}
|
||||
@@ -646,7 +646,7 @@ static htsblk cache_readex_new(httrackp * opt, cache_back * cache,
|
||||
strcpybuff(r.location, "");
|
||||
strcpybuff(buff, adr);
|
||||
strcatbuff(buff, fil);
|
||||
hash_pos_return = inthash_read(cache->hashtable, buff, &hash_pos);
|
||||
hash_pos_return = coucal_read(cache->hashtable, buff, &hash_pos);
|
||||
/* avoid errors on data entries */
|
||||
if (adr[0] == '/' && adr[1] == '/' && adr[2] == '[') {
|
||||
#if HTS_FAST_CACHE
|
||||
@@ -1029,7 +1029,7 @@ static htsblk cache_readex_old(httrackp * opt, cache_back * cache,
|
||||
#if HTS_FAST_CACHE
|
||||
strcpybuff(buff, adr);
|
||||
strcatbuff(buff, fil);
|
||||
hash_pos_return = inthash_read(cache->hashtable, buff, &hash_pos);
|
||||
hash_pos_return = coucal_read(cache->hashtable, buff, &hash_pos);
|
||||
#else
|
||||
buff[0] = '\0';
|
||||
strcatbuff(buff, "\n");
|
||||
@@ -1349,7 +1349,7 @@ int cache_readdata(cache_back * cache, const char *str1, const char *str2,
|
||||
|
||||
strcpybuff(buff, str1);
|
||||
strcatbuff(buff, str2);
|
||||
if (inthash_read(cache->hashtable, buff, &pos)) {
|
||||
if (coucal_read(cache->hashtable, buff, &pos)) {
|
||||
if (fseek(cache->olddat, (long) ((pos > 0) ? pos : (-pos)), SEEK_SET) ==
|
||||
0) {
|
||||
INTsys len;
|
||||
@@ -1642,9 +1642,9 @@ void cache_init(cache_back * cache, httrackp * opt) {
|
||||
}
|
||||
}
|
||||
if (dataincache)
|
||||
inthash_add(cache->hashtable, filenameIndex, pos);
|
||||
coucal_add(cache->hashtable, filenameIndex, pos);
|
||||
else
|
||||
inthash_add(cache->hashtable, filenameIndex, -pos);
|
||||
coucal_add(cache->hashtable, filenameIndex, -pos);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_WARNING,
|
||||
"Corrupted cache meta entry #%d",
|
||||
@@ -1810,7 +1810,7 @@ void cache_init(cache_back * cache, httrackp * opt) {
|
||||
/* read position */
|
||||
a += binput(a, linepos, 200);
|
||||
sscanf(linepos, "%d", &pos);
|
||||
inthash_add(cache->hashtable, line, pos);
|
||||
coucal_add(cache->hashtable, line, pos);
|
||||
}
|
||||
}
|
||||
/* Not needed anymore! */
|
||||
|
||||
@@ -35,6 +35,18 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "punycode.h"
|
||||
#include "htssafe.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <stddef.h>
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#elif (defined(SOLARIS) || defined(sun) || defined(HAVE_INTTYPES_H) \
|
||||
|| defined(BSD) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD_kernel__))
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
int hts_isStringAscii(const char *s, size_t size) {
|
||||
size_t i;
|
||||
|
||||
@@ -441,7 +453,7 @@ static char *hts_convertStringCharset(const char *s, size_t size,
|
||||
const iconv_t cp = iconv_open(to, from);
|
||||
|
||||
if (cp != (iconv_t) - 1) {
|
||||
char *inbuf = (char *) s;
|
||||
char *inbuf = (char*) (uintptr_t) s; /* ugly iconv api, sheesh */
|
||||
size_t inbytesleft = size;
|
||||
size_t outbufCapa = 0;
|
||||
char *outbuf = NULL;
|
||||
|
||||
@@ -149,8 +149,8 @@ RUN_CALLBACK0(opt, end); \
|
||||
if (maketrack_fp){ fclose(maketrack_fp); maketrack_fp=NULL; } \
|
||||
if (opt->accept_cookie) cookie_save(opt->cookie,fconcat(OPT_GET_BUFF(opt),OPT_GET_BUFF_SIZE(opt),StringBuff(opt->path_log),"cookies.txt")); \
|
||||
if (makeindex_fp) { fclose(makeindex_fp); makeindex_fp=NULL; } \
|
||||
if (cache_hashtable) { inthash_delete(&cache_hashtable); } \
|
||||
if (cache_tests) { inthash_delete(&cache_tests); } \
|
||||
if (cache_hashtable) { coucal_delete(&cache_hashtable); } \
|
||||
if (cache_tests) { coucal_delete(&cache_tests); } \
|
||||
if (template_header) { freet(template_header); template_header=NULL; } \
|
||||
if (template_body) { freet(template_body); template_body=NULL; } \
|
||||
if (template_footer) { freet(template_footer); template_footer=NULL; } \
|
||||
@@ -429,6 +429,14 @@ if (makeindex_fp) { \
|
||||
makeindex_done=1; /* ok c'est fait */ \
|
||||
} while(0)
|
||||
|
||||
/* does it look like XML ? (SVG et al.) */
|
||||
static int look_like_xml(const char *s) {
|
||||
return strncmp(s, "<?xml", 5) == 0
|
||||
|| strncmp(s, "<!-- ", 5) == 0
|
||||
|| strncmp(s, "<svg ", 5) == 0
|
||||
;
|
||||
}
|
||||
|
||||
// Début de httpmirror, robot
|
||||
// url1 peut être multiple
|
||||
int httpmirror(char *url1, httrackp * opt) {
|
||||
@@ -479,8 +487,8 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
//
|
||||
cache_back BIGSTK cache;
|
||||
robots_wizard BIGSTK robots; // gestion robots.txt
|
||||
inthash cache_hashtable = NULL;
|
||||
inthash cache_tests = NULL;
|
||||
coucal cache_hashtable = NULL;
|
||||
coucal cache_tests = NULL;
|
||||
|
||||
//
|
||||
char *template_header = NULL, *template_body = NULL, *template_footer = NULL;
|
||||
@@ -563,8 +571,8 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
cache.ptr_ant = cache.ptr_last = 0; // pointeur pour anticiper
|
||||
|
||||
// initialiser hash cache
|
||||
cache_hashtable = inthash_new(0);
|
||||
cache_tests = inthash_new(0);
|
||||
cache_hashtable = coucal_new(0);
|
||||
cache_tests = coucal_new(0);
|
||||
if (cache_hashtable == NULL || cache_tests == NULL) {
|
||||
printf("PANIC! : Not enough memory [%d]\n", __LINE__);
|
||||
filters[0] = NULL; // uniquement a cause du warning de XH_extuninit
|
||||
@@ -573,9 +581,9 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
}
|
||||
hts_set_hash_handler(cache_hashtable, opt);
|
||||
hts_set_hash_handler(cache_tests, opt);
|
||||
inthash_set_name(cache_hashtable, "cache_hashtable");
|
||||
inthash_set_name(cache_tests, "cache_tests");
|
||||
inthash_value_is_malloc(cache_tests, 1); /* malloc */
|
||||
coucal_set_name(cache_hashtable, "cache_hashtable");
|
||||
coucal_set_name(cache_tests, "cache_tests");
|
||||
coucal_value_is_malloc(cache_tests, 1); /* malloc */
|
||||
cache.hashtable = (void *) cache_hashtable; /* copy backcache hash */
|
||||
cache.cached_tests = (void *) cache_tests; /* copy of cache_tests */
|
||||
|
||||
@@ -609,7 +617,7 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
// initialiser hachage
|
||||
hash_init(opt, &hash, opt->urlhack);
|
||||
// note: we need a cast because of the const
|
||||
hash.liens = (const lien_url ***) &opt->liens;
|
||||
hash.liens = (const lien_url *const*const*) &opt->liens;
|
||||
|
||||
// copier adresse(s) dans liste des adresses
|
||||
{
|
||||
@@ -1180,8 +1188,13 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
if (!error) {
|
||||
if (r.statuscode == HTTP_OK) { // OK (ou 304 en backing)
|
||||
if (r.adr) { // Written file
|
||||
if ((is_hypertext_mime(opt, r.contenttype, urlfil()))
|
||||
|
||||
// Buggy SVG (Smiling Spectre)
|
||||
if (strcmp(r.contenttype, "image/svg+xml") == 0 && !look_like_xml(r.adr)) {
|
||||
// patch it
|
||||
strcpybuff(r.contenttype, "application/octet-stream");
|
||||
is_binary = 1;
|
||||
}
|
||||
else if ((is_hypertext_mime(opt, r.contenttype, urlfil()))
|
||||
/* Is HTML or Js, .. */
|
||||
/* NO - real media is real media, not HTML */
|
||||
/*|| (may_be_hypertext_mime(r.contenttype, urlfil()) && (r.adr) ) */
|
||||
@@ -2483,7 +2496,7 @@ void host_ban(httrackp * opt, int ptr,
|
||||
while((heap(i)->adr[l]) && (l < 1020))
|
||||
l++;
|
||||
if ((l > 0) && (l < 1020)) { // sécurité
|
||||
if (strfield2(jump_identification(heap(i)->adr), host)) { // host
|
||||
if (strfield2(jump_identification_const(heap(i)->adr), host)) { // host
|
||||
hts_log_print(opt, LOG_DEBUG, "Cancel: %s%s", heap(i)->adr,
|
||||
heap(i)->fil);
|
||||
hts_invalidate_link(opt, i); // invalidate hashtable entry
|
||||
@@ -3644,11 +3657,21 @@ HTSEXT_API int hts_setpause(httrackp * opt, int p) {
|
||||
HTSEXT_API int hts_request_stop(httrackp * opt, int force) {
|
||||
if (opt != NULL) {
|
||||
hts_log_print(opt, LOG_ERROR, "Exit requested by shell or user");
|
||||
hts_mutexlock(&opt->state.lock);
|
||||
opt->state.stop = 1;
|
||||
hts_mutexrelease(&opt->state.lock);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
HTSEXT_API int hts_has_stopped(httrackp * opt) {
|
||||
int ended;
|
||||
hts_mutexlock(&opt->state.lock);
|
||||
ended = opt->state.is_ended;
|
||||
hts_mutexrelease(&opt->state.lock);
|
||||
return ended;
|
||||
}
|
||||
|
||||
// régler en cours de route les paramètres réglables..
|
||||
// -1 : erreur
|
||||
//HTSEXT_API int hts_setopt(httrackp* set_opt) {
|
||||
|
||||
@@ -123,7 +123,7 @@ typedef struct filecreate_params filecreate_params;
|
||||
|
||||
// gestion hashage
|
||||
#include "htshash.h"
|
||||
#include "htsinthash.h"
|
||||
#include "coucal.h"
|
||||
|
||||
#include "htsdefines.h"
|
||||
|
||||
@@ -156,7 +156,7 @@ typedef struct struct_back struct_back;
|
||||
struct struct_back {
|
||||
lien_back *lnk;
|
||||
int count;
|
||||
inthash ready;
|
||||
coucal ready;
|
||||
LLint ready_size_bytes;
|
||||
};
|
||||
|
||||
@@ -178,9 +178,9 @@ struct cache_back {
|
||||
FILE *txt; // liste des fichiers (info)
|
||||
char lastmodified[256];
|
||||
// HASH
|
||||
inthash hashtable;
|
||||
coucal hashtable;
|
||||
// HASH for tests (naming subsystem)
|
||||
inthash cached_tests;
|
||||
coucal cached_tests;
|
||||
// fichiers log optionnels
|
||||
FILE *log;
|
||||
FILE *errlog;
|
||||
@@ -201,13 +201,13 @@ typedef struct hash_struct hash_struct;
|
||||
#endif
|
||||
struct hash_struct {
|
||||
/* Links big array reference */
|
||||
const lien_url ***liens;
|
||||
const lien_url *const*const*liens;
|
||||
/* Savename (case insensitive ; lowercased) */
|
||||
inthash sav;
|
||||
coucal sav;
|
||||
/* Address and path */
|
||||
inthash adrfil;
|
||||
coucal adrfil;
|
||||
/* Former address and path */
|
||||
inthash former_adrfil;
|
||||
coucal former_adrfil;
|
||||
/** Buffers **/
|
||||
int normalized;
|
||||
char normfil[HTS_URLMAXSIZE * 2];
|
||||
|
||||
@@ -86,7 +86,11 @@ extern int IPV6_resolver;
|
||||
ptr += (int) (strlen(argv[0])+2); \
|
||||
argc++
|
||||
|
||||
#define htsmain_free() do { if (url != NULL) { free(url); } } while(0)
|
||||
#define htsmain_free() do { \
|
||||
if (url != NULL) { \
|
||||
free(url); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ensureUrlCapacity(url, urlsize, size) do { \
|
||||
if (urlsize < size || url == NULL) { \
|
||||
@@ -126,8 +130,38 @@ HTSEXT_API int hts_main(int argc, char **argv) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// very minimalistic internal tests
|
||||
static void basic_selftests(void) {
|
||||
// BUG 756328
|
||||
const char *const source = "/intent/tweet?url=https%3A%2F%2Fwww.httrack.com%2Fvacatures%2F1562519%2Fmedewerker-data-services&text=Medewerker+Data+Services&via=httrackcom";
|
||||
char buffer[1024];
|
||||
fil_normalized(source, buffer);
|
||||
// MD5 selftests
|
||||
md5selftest();
|
||||
}
|
||||
|
||||
static int hts_main_internal(int argc, char **argv, httrackp * opt);
|
||||
|
||||
// Main, récupère les paramètres et appelle le robot
|
||||
HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
int code;
|
||||
|
||||
// Set ended state (3.48-14)
|
||||
hts_mutexlock(&opt->state.lock);
|
||||
opt->state.is_ended = 0;
|
||||
hts_mutexrelease(&opt->state.lock);
|
||||
|
||||
code = hts_main_internal(argc, argv, opt);
|
||||
|
||||
// Set ended state (3.48-14)
|
||||
hts_mutexlock(&opt->state.lock);
|
||||
opt->state.is_ended = 1;
|
||||
hts_mutexrelease(&opt->state.lock);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int hts_main_internal(int argc, char **argv, httrackp * opt) {
|
||||
char **x_argv = NULL; // Patch pour argv et argc: en cas de récupération de ligne de commande
|
||||
char *x_argvblk = NULL; // (reprise ou update)
|
||||
int x_ptr = 0; // offset
|
||||
@@ -1984,7 +2018,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
int found = 0;
|
||||
char *filter = NULL;
|
||||
cache_back cache;
|
||||
inthash cache_hashtable = inthash_new(0);
|
||||
coucal cache_hashtable = coucal_new(0);
|
||||
int sendb = 0;
|
||||
|
||||
if (isdigit((unsigned char) *(com + 1))) {
|
||||
@@ -2408,7 +2442,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
return 0;
|
||||
break;
|
||||
case '7': // hashtable selftest: httrack -#7 nb_entries
|
||||
md5selftest();
|
||||
basic_selftests();
|
||||
if (++na < argc) {
|
||||
char *const snum = strdup(argv[na]);
|
||||
unsigned long count = 0;
|
||||
@@ -2515,7 +2549,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
|
||||
/* successfully read */
|
||||
if (count > 0) {
|
||||
inthash hashtable = inthash_new(0);
|
||||
coucal hashtable = coucal_new(0);
|
||||
size_t loop;
|
||||
for(loop = 0 ; bench[loop].type != DO_END ; loop++) {
|
||||
size_t i;
|
||||
@@ -2526,9 +2560,9 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
if (bench[loop].type == DO_ADD
|
||||
|| bench[loop].type == DO_DRY_ADD) {
|
||||
size_t k;
|
||||
result = inthash_write(hashtable, name, (uintptr_t) expected);
|
||||
result = coucal_write(hashtable, name, (uintptr_t) expected);
|
||||
for(k = 0 ; k < /* stash_size*2 */ 32 ; k++) {
|
||||
(void) inthash_write(hashtable, name, (uintptr_t) expected);
|
||||
(void) coucal_write(hashtable, name, (uintptr_t) expected);
|
||||
}
|
||||
/* revert logic */
|
||||
if (bench[loop].type == DO_DRY_ADD) {
|
||||
@@ -2538,9 +2572,9 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
else if (bench[loop].type == DO_DEL
|
||||
|| bench[loop].type == DO_DRY_DEL) {
|
||||
size_t k;
|
||||
result = inthash_remove(hashtable, name);
|
||||
result = coucal_remove(hashtable, name);
|
||||
for(k = 0 ; k < /* stash_size*2 */ 32 ; k++) {
|
||||
(void) inthash_remove(hashtable, name);
|
||||
(void) coucal_remove(hashtable, name);
|
||||
}
|
||||
/* revert logic */
|
||||
if (bench[loop].type == DO_DRY_DEL) {
|
||||
@@ -2550,7 +2584,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
else if (bench[loop].type == TEST_ADD
|
||||
|| bench[loop].type == TEST_DEL) {
|
||||
intptr_t value = -1;
|
||||
result = inthash_readptr(hashtable, name, &value);
|
||||
result = coucal_readptr(hashtable, name, &value);
|
||||
if (bench[loop].type == TEST_ADD && result
|
||||
&& value != expected) {
|
||||
fprintf(stderr, "value failed for %s (expected %ld, got %ld)\n",
|
||||
@@ -2573,7 +2607,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
}
|
||||
}
|
||||
}
|
||||
inthash_delete(&hashtable);
|
||||
coucal_delete(&hashtable);
|
||||
fprintf(stderr, "all hashtable tests were successful!\n");
|
||||
} else {
|
||||
fprintf(stderr, "Malformed number\n");
|
||||
|
||||
@@ -270,7 +270,7 @@ int hts_unescapeUrlSpecial(const char *src, char *dest, const size_t max,
|
||||
/* First character */
|
||||
if (k == 0) {
|
||||
/* New destination-centric offset of utf-8 buffer beginning */
|
||||
if (i == lastI + 2) { /* just read a %xx */
|
||||
if (lastI != (size_t) -1 && i == lastI + 2) { /* just read a %xx */
|
||||
utfBufferJ = lastJ; /* position of % */
|
||||
} else {
|
||||
utfBufferJ = j; /* current position otherwise */
|
||||
|
||||
@@ -36,8 +36,8 @@ Please visit our Website: http://www.httrack.com
|
||||
#define HTTRACK_GLOBAL_DEFH
|
||||
|
||||
// Version (also check external version information)
|
||||
#define HTTRACK_VERSION "3.48-13"
|
||||
#define HTTRACK_VERSIONID "3.48.13"
|
||||
#define HTTRACK_VERSION "3.48-19"
|
||||
#define HTTRACK_VERSIONID "3.48.19"
|
||||
#define HTTRACK_AFF_VERSION "3.x"
|
||||
#define HTTRACK_LIB_VERSION "2.0"
|
||||
|
||||
|
||||
128
src/htshash.c
128
src/htshash.c
@@ -42,7 +42,7 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htsglobal.h"
|
||||
#include "htsmd5.h"
|
||||
#include "htscore.h"
|
||||
#include "htsinthash.h"
|
||||
#include "coucal.h"
|
||||
/* END specific definitions */
|
||||
|
||||
/* Specific macros */
|
||||
@@ -60,48 +60,55 @@ Please visit our Website: http://www.httrack.com
|
||||
// recherche dans la table selon nom1,nom2 et le no d'enregistrement
|
||||
|
||||
/* Key free handler (NOOP) ; addresses are kept */
|
||||
static void key_freehandler(void *arg, void *value) {
|
||||
static void key_freehandler(void *arg, coucal_key value) {
|
||||
}
|
||||
|
||||
/* Key strdup (pointer copy) */
|
||||
static char* key_duphandler(void *arg, const char *name) {
|
||||
static coucal_key key_duphandler(void *arg, coucal_key_const name) {
|
||||
union {
|
||||
const char *roname;
|
||||
char *name;
|
||||
coucal_key_const roname;
|
||||
coucal_key name;
|
||||
} u;
|
||||
u.roname = name;
|
||||
return u.name;
|
||||
}
|
||||
|
||||
/* Key sav hashes are using case-insensitive version */
|
||||
static inthash_keys key_sav_hashes(void *arg, const char *value) {
|
||||
static coucal_hashkeys key_sav_hashes(void *arg, coucal_key_const key) {
|
||||
hash_struct *const hash = (hash_struct*) arg;
|
||||
convtolower(hash->catbuff, value);
|
||||
return inthash_hash_value(hash->catbuff);
|
||||
convtolower(hash->catbuff, (const char*) key);
|
||||
return coucal_hash_string(hash->catbuff);
|
||||
}
|
||||
|
||||
/* Key sav comparison is case-insensitive */
|
||||
static int key_sav_equals(void *arg, const char *a, const char *b) {
|
||||
static int key_sav_equals(void *arg,
|
||||
coucal_key_const a_,
|
||||
coucal_key_const b_) {
|
||||
const char *const a = (const char*) a_;
|
||||
const char *const b = (const char*) b_;
|
||||
return strcasecmp(a, b) == 0;
|
||||
}
|
||||
|
||||
static const char* key_sav_debug_print(void *arg, const char *a) {
|
||||
return a;
|
||||
static const char* key_sav_debug_print(void *arg,
|
||||
coucal_key_const a) {
|
||||
return (const char*) a;
|
||||
}
|
||||
|
||||
static const char* value_sav_debug_print(void *arg, void *a) {
|
||||
return (char*) a;
|
||||
static const char* value_sav_debug_print(void *arg, coucal_value_const a) {
|
||||
return (char*) a.ptr;
|
||||
}
|
||||
|
||||
/* Pseudo-key (lien_url structure) hash function */
|
||||
static inthash_keys key_adrfil_hashes_generic(void *arg, const char *value_,
|
||||
static coucal_hashkeys key_adrfil_hashes_generic(void *arg,
|
||||
coucal_key_const value,
|
||||
const int former) {
|
||||
hash_struct *const hash = (hash_struct*) arg;
|
||||
const lien_url*const lien = (lien_url*) value_;
|
||||
const lien_url*const lien = (const lien_url*) value;
|
||||
const char *const adr = !former ? lien->adr : lien->former_adr;
|
||||
const char *const fil = !former ? lien->fil : lien->former_fil;
|
||||
const char *const adr_norm = adr != NULL ?
|
||||
( hash->normalized ? jump_normalized(adr) : jump_identification(adr) )
|
||||
( hash->normalized ? jump_normalized_const(adr)
|
||||
: jump_identification_const(adr) )
|
||||
: NULL;
|
||||
|
||||
// copy address
|
||||
@@ -117,16 +124,18 @@ static inthash_keys key_adrfil_hashes_generic(void *arg, const char *value_,
|
||||
}
|
||||
|
||||
// hash
|
||||
return inthash_hash_value(hash->normfil);
|
||||
return coucal_hash_string(hash->normfil);
|
||||
}
|
||||
|
||||
/* Pseudo-key (lien_url structure) comparison function */
|
||||
static int key_adrfil_equals_generic(void *arg, const char *a_, const char *b_,
|
||||
static int key_adrfil_equals_generic(void *arg,
|
||||
coucal_key_const a_,
|
||||
coucal_key_const b_,
|
||||
const int former) {
|
||||
hash_struct *const hash = (hash_struct*) arg;
|
||||
const int normalized = hash->normalized;
|
||||
const lien_url*const a = (lien_url*) a_;
|
||||
const lien_url*const b = (lien_url*) b_;
|
||||
const lien_url*const a = (const lien_url*) a_;
|
||||
const lien_url*const b = (const lien_url*) b_;
|
||||
const char *const a_adr = !former ? a->adr : a->former_adr;
|
||||
const char *const b_adr = !former ? b->adr : b->former_adr;
|
||||
const char *const a_fil = !former ? a->fil : a->former_fil;
|
||||
@@ -141,8 +150,10 @@ static int key_adrfil_equals_generic(void *arg, const char *a_, const char *b_,
|
||||
assertf(b_fil != NULL);
|
||||
|
||||
// skip scheme and authentication to the domain (possibly without www.)
|
||||
ja = normalized ? jump_normalized(a_adr) : jump_identification(a_adr);
|
||||
jb = normalized ? jump_normalized(b_adr) : jump_identification(b_adr);
|
||||
ja = normalized
|
||||
? jump_normalized_const(a_adr) : jump_identification_const(a_adr);
|
||||
jb = normalized
|
||||
? jump_normalized_const(b_adr) : jump_identification_const(b_adr);
|
||||
assertf(ja != NULL);
|
||||
assertf(jb != NULL);
|
||||
if (strcasecmp(ja, jb) != 0) {
|
||||
@@ -159,67 +170,74 @@ static int key_adrfil_equals_generic(void *arg, const char *a_, const char *b_,
|
||||
}
|
||||
}
|
||||
|
||||
static const char* key_adrfil_debug_print_(void *arg, const char *a_, const int former) {
|
||||
static const char* key_adrfil_debug_print_(void *arg,
|
||||
coucal_key_const a_,
|
||||
const int former) {
|
||||
hash_struct *const hash = (hash_struct*) arg;
|
||||
const lien_url*const a = (lien_url*) a_;
|
||||
const lien_url*const a = (const lien_url*) a_;
|
||||
const char *const a_adr = !former ? a->adr : a->former_adr;
|
||||
const char *const a_fil = !former ? a->fil : a->former_fil;
|
||||
snprintf(hash->normfil, sizeof(hash->normfil), "%s%s", a_adr, a_fil);
|
||||
return hash->normfil;
|
||||
}
|
||||
|
||||
static const char* key_adrfil_debug_print(void *arg, const char *a_) {
|
||||
static const char* key_adrfil_debug_print(void *arg,
|
||||
coucal_key_const a_) {
|
||||
return key_adrfil_debug_print_(arg, a_, 0);
|
||||
}
|
||||
|
||||
static const char* key_former_adrfil_debug_print(void *arg, const char *a_) {
|
||||
static const char* key_former_adrfil_debug_print(void *arg,
|
||||
coucal_key_const a_) {
|
||||
return key_adrfil_debug_print_(arg, a_, 1);
|
||||
}
|
||||
|
||||
static const char* value_adrfil_debug_print(void *arg, void *value) {
|
||||
static const char* value_adrfil_debug_print(void *arg,
|
||||
coucal_value_const value) {
|
||||
hash_struct *const hash = (hash_struct*) arg;
|
||||
inthash_value v;
|
||||
v.ptr = value;
|
||||
snprintf(hash->normfil2, sizeof(hash->normfil2), "%d", (int) v.intg);
|
||||
snprintf(hash->normfil2, sizeof(hash->normfil2), "%d", (int) value.intg);
|
||||
return hash->normfil2;
|
||||
}
|
||||
|
||||
/* "adr"/"fil" lien_url structure members hashing function */
|
||||
static inthash_keys key_adrfil_hashes(void *arg, const char *value_) {
|
||||
static coucal_hashkeys key_adrfil_hashes(void *arg, coucal_key_const value_) {
|
||||
return key_adrfil_hashes_generic(arg, value_, 0);
|
||||
}
|
||||
|
||||
/* "adr"/"fil" lien_url structure members comparison function */
|
||||
static int key_adrfil_equals(void *arg, const char *a, const char *b) {
|
||||
static int key_adrfil_equals(void *arg,
|
||||
coucal_key_const a,
|
||||
coucal_key_const b) {
|
||||
return key_adrfil_equals_generic(arg, a, b, 0);
|
||||
}
|
||||
|
||||
/* "former_adr"/"former_fil" lien_url structure members hashing function */
|
||||
static inthash_keys key_former_adrfil_hashes(void *arg, const char *value_) {
|
||||
static coucal_hashkeys key_former_adrfil_hashes(void *arg, coucal_key_const value_) {
|
||||
return key_adrfil_hashes_generic(arg, value_, 1);
|
||||
}
|
||||
|
||||
/* "former_adr"/"former_fil" lien_url structure members comparison function */
|
||||
static int key_former_adrfil_equals(void *arg, const char *a, const char *b) {
|
||||
static int key_former_adrfil_equals(void *arg,
|
||||
coucal_key_const a,
|
||||
coucal_key_const b) {
|
||||
return key_adrfil_equals_generic(arg, a, b, 1);
|
||||
}
|
||||
|
||||
void hash_init(httrackp *opt, hash_struct * hash, int normalized) {
|
||||
hash->sav = inthash_new(0);
|
||||
hash->adrfil = inthash_new(0);
|
||||
hash->former_adrfil = inthash_new(0);
|
||||
hash->sav = coucal_new(0);
|
||||
hash->adrfil = coucal_new(0);
|
||||
hash->former_adrfil = coucal_new(0);
|
||||
hash->normalized = normalized;
|
||||
|
||||
hts_set_hash_handler(hash->sav, opt);
|
||||
hts_set_hash_handler(hash->adrfil, opt);
|
||||
hts_set_hash_handler(hash->former_adrfil, opt);
|
||||
|
||||
inthash_set_name(hash->sav, "hash->sav");
|
||||
inthash_set_name(hash->adrfil, "hash->adrfil");
|
||||
inthash_set_name(hash->former_adrfil, "hash->former_adrfil");
|
||||
coucal_set_name(hash->sav, "hash->sav");
|
||||
coucal_set_name(hash->adrfil, "hash->adrfil");
|
||||
coucal_set_name(hash->former_adrfil, "hash->former_adrfil");
|
||||
|
||||
/* Case-insensitive comparison ; keys are direct char* filenames */
|
||||
inthash_value_set_key_handler(hash->sav,
|
||||
coucal_value_set_key_handler(hash->sav,
|
||||
key_duphandler,
|
||||
key_freehandler,
|
||||
key_sav_hashes,
|
||||
@@ -228,13 +246,13 @@ void hash_init(httrackp *opt, hash_struct * hash, int normalized) {
|
||||
|
||||
/* URL-style comparison ; keys are lien_url structure pointers casted
|
||||
to char* */
|
||||
inthash_value_set_key_handler(hash->adrfil,
|
||||
coucal_value_set_key_handler(hash->adrfil,
|
||||
key_duphandler,
|
||||
key_freehandler,
|
||||
key_adrfil_hashes,
|
||||
key_adrfil_equals,
|
||||
hash);
|
||||
inthash_value_set_key_handler(hash->former_adrfil,
|
||||
coucal_value_set_key_handler(hash->former_adrfil,
|
||||
key_duphandler,
|
||||
key_freehandler,
|
||||
key_former_adrfil_hashes,
|
||||
@@ -242,15 +260,15 @@ void hash_init(httrackp *opt, hash_struct * hash, int normalized) {
|
||||
hash);
|
||||
|
||||
/* pretty-printing */
|
||||
inthash_set_print_handler(hash->sav,
|
||||
coucal_set_print_handler(hash->sav,
|
||||
key_sav_debug_print,
|
||||
value_sav_debug_print,
|
||||
NULL);
|
||||
inthash_set_print_handler(hash->adrfil,
|
||||
coucal_set_print_handler(hash->adrfil,
|
||||
key_adrfil_debug_print,
|
||||
value_adrfil_debug_print,
|
||||
hash);
|
||||
inthash_set_print_handler(hash->former_adrfil,
|
||||
coucal_set_print_handler(hash->former_adrfil,
|
||||
key_former_adrfil_debug_print,
|
||||
value_adrfil_debug_print,
|
||||
hash);
|
||||
@@ -258,9 +276,9 @@ void hash_init(httrackp *opt, hash_struct * hash, int normalized) {
|
||||
|
||||
void hash_free(hash_struct *hash) {
|
||||
if (hash != NULL) {
|
||||
inthash_delete(&hash->sav);
|
||||
inthash_delete(&hash->adrfil);
|
||||
inthash_delete(&hash->former_adrfil);
|
||||
coucal_delete(&hash->sav);
|
||||
coucal_delete(&hash->adrfil);
|
||||
coucal_delete(&hash->former_adrfil);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +291,7 @@ int hash_read(const hash_struct * hash, const char *nom1, const char *nom2,
|
||||
/* read */
|
||||
switch(type) {
|
||||
case HASH_STRUCT_FILENAME:
|
||||
if (inthash_read(hash->sav, nom1, &intvalue)) {
|
||||
if (coucal_read(hash->sav, nom1, &intvalue)) {
|
||||
return (int) intvalue;
|
||||
} else {
|
||||
return -1;
|
||||
@@ -283,7 +301,7 @@ int hash_read(const hash_struct * hash, const char *nom1, const char *nom2,
|
||||
memset(&lien, 0, sizeof(lien));
|
||||
lien.adr = key_duphandler(NULL, nom1);
|
||||
lien.fil = key_duphandler(NULL, nom2);
|
||||
if (inthash_read(hash->adrfil, (char*) &lien, &intvalue)) {
|
||||
if (coucal_read(hash->adrfil, (char*) &lien, &intvalue)) {
|
||||
return (int) intvalue;
|
||||
} else {
|
||||
return -1;
|
||||
@@ -293,7 +311,7 @@ int hash_read(const hash_struct * hash, const char *nom1, const char *nom2,
|
||||
memset(&lien, 0, sizeof(lien));
|
||||
lien.former_adr = key_duphandler(NULL, nom1);
|
||||
lien.former_fil = key_duphandler(NULL, nom2);
|
||||
if (inthash_read(hash->former_adrfil, (char*) &lien, &intvalue)) {
|
||||
if (coucal_read(hash->former_adrfil, (char*) &lien, &intvalue)) {
|
||||
return (int) intvalue;
|
||||
} else {
|
||||
return -1;
|
||||
@@ -309,13 +327,13 @@ int hash_read(const hash_struct * hash, const char *nom1, const char *nom2,
|
||||
// enregistrement lien lpos dans les 3 tables hash1..3
|
||||
void hash_write(hash_struct * hash, size_t lpos) {
|
||||
/* first entry: destination filename (lowercased) */
|
||||
inthash_write(hash->sav, (*hash->liens)[lpos]->sav, lpos);
|
||||
coucal_write(hash->sav, (*hash->liens)[lpos]->sav, lpos);
|
||||
|
||||
/* second entry: URL address and path */
|
||||
inthash_write(hash->adrfil, (char*) (*hash->liens)[lpos], lpos);
|
||||
coucal_write(hash->adrfil, (*hash->liens)[lpos], lpos);
|
||||
|
||||
/* third entry: URL address and path before redirect */
|
||||
if ((*hash->liens)[lpos]->former_adr) { // former_adr existe?
|
||||
inthash_write(hash->former_adrfil, (char*) (*hash->liens)[lpos], lpos);
|
||||
coucal_write(hash->former_adrfil, (*hash->liens)[lpos], lpos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ void help_wizard(httrackp * opt) {
|
||||
if (strnotempty(str)) {
|
||||
while((a = strchr(str, ' ')))
|
||||
*a = ':'; // port
|
||||
if (!strchr(jump_identification(str), ':')) {
|
||||
if (!strchr(jump_identification_const(str), ':')) {
|
||||
char str2[256];
|
||||
|
||||
printf("\nProxy port (return=8080) :");
|
||||
|
||||
@@ -40,7 +40,7 @@ Please visit our Website: http://www.httrack.com
|
||||
|
||||
#if HTS_MAKE_KEYWORD_INDEX
|
||||
#include "htshash.h"
|
||||
#include "htsinthash.h"
|
||||
#include "coucal.h"
|
||||
|
||||
/* Keyword Indexer Parameters */
|
||||
|
||||
@@ -144,7 +144,7 @@ int index_keyword(const char *html_data, LLint size, const char *mime,
|
||||
|
||||
//
|
||||
//int WordIndexSize = 1024;
|
||||
inthash WordIndexHash = NULL;
|
||||
coucal WordIndexHash = NULL;
|
||||
FILE *tmpfp = NULL;
|
||||
|
||||
//
|
||||
@@ -190,7 +190,7 @@ int index_keyword(const char *html_data, LLint size, const char *mime,
|
||||
|
||||
// Create hash structure
|
||||
// Hash tables rulez da world!
|
||||
WordIndexHash = inthash_new(0);
|
||||
WordIndexHash = coucal_new(0);
|
||||
if (!WordIndexHash)
|
||||
return 0;
|
||||
|
||||
@@ -252,7 +252,7 @@ int index_keyword(const char *html_data, LLint size, const char *mime,
|
||||
/* Store it ? */
|
||||
if (len >= KEYW_MIN_LEN) {
|
||||
hts_primindex_words++;
|
||||
if (inthash_inc(WordIndexHash, keyword)) { /* added new */
|
||||
if (coucal_inc(WordIndexHash, keyword)) { /* added new */
|
||||
fprintf(tmpfp, "%s\n", keyword);
|
||||
}
|
||||
}
|
||||
@@ -285,13 +285,13 @@ int index_keyword(const char *html_data, LLint size, const char *mime,
|
||||
if (strnotempty(line)) {
|
||||
intptr_t e = 0;
|
||||
|
||||
if (inthash_read(WordIndexHash, line, &e)) {
|
||||
if (coucal_read(WordIndexHash, line, &e)) {
|
||||
//if (e) {
|
||||
char BIGSTK savelst[HTS_URLMAXSIZE * 2];
|
||||
|
||||
e++; /* 0 means "once" */
|
||||
|
||||
if (strncmp((const char *) fslash(catbuff, sizeof(catbuff), (char *) indexpath), filename, strlen(indexpath)) == 0) // couper
|
||||
if (strncmp((const char *) fslash(catbuff, sizeof(catbuff), (const char *) indexpath), filename, strlen(indexpath)) == 0) // couper
|
||||
strcpybuff(savelst, filename + strlen(indexpath));
|
||||
else
|
||||
strcpybuff(savelst, filename);
|
||||
@@ -313,7 +313,7 @@ int index_keyword(const char *html_data, LLint size, const char *mime,
|
||||
tmpfp = NULL;
|
||||
|
||||
// Clear hash table
|
||||
inthash_delete(&WordIndexHash);
|
||||
coucal_delete(&WordIndexHash);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -478,8 +478,8 @@ int strcpos(const char *adr, char c) {
|
||||
}
|
||||
|
||||
int mystrcmp(const void *_e1, const void *_e2) {
|
||||
char **e1 = (char **) _e1;
|
||||
char **e2 = (char **) _e2;
|
||||
const char *const*const e1 = (const char *const*) _e1;
|
||||
const char *const*const e2 = (const char *const*) _e2;
|
||||
|
||||
return strcmp(*e1, *e2);
|
||||
}
|
||||
|
||||
390
src/htsinthash.h
390
src/htsinthash.h
@@ -1,390 +0,0 @@
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) 1998-2014 Xavier Roche and other contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Important notes:
|
||||
|
||||
- We hereby ask people using this source NOT to use it in purpose of grabbing
|
||||
emails addresses, or collecting any other private information on persons.
|
||||
This would disgrace our work, and spoil the many hours we spent on it.
|
||||
|
||||
Please visit our Website: http://www.httrack.com
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* File: hash table system (fast index) */
|
||||
/* Author: Xavier Roche */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* Library notes:
|
||||
* This small hashtable library provides key/value hashtable, with a string
|
||||
* key, and integer/pointer value (with an associated optional allocator)
|
||||
* It features O(1) average insertion, O(1) lookup, and O(1) delete.
|
||||
*
|
||||
* Implementation notes:
|
||||
* Implementation is auto-rehashable, and uses cuckoo hashing of size 2**n
|
||||
* with a MD5 or FNV-1 hash function, with one additional auxiliary hash
|
||||
* function.
|
||||
* It also uses a small stash area to handle rare cases of collisions.
|
||||
* Enumeration of all key/values is possible, deletion is also possible, but
|
||||
* currently without any auto-shrinking (ie. table will never shrink).
|
||||
* Overall, two main blocks are allocated: one for the items, and one for
|
||||
* the keys (pool).
|
||||
*
|
||||
* References:
|
||||
* Cuckoo Hashing http://en.wikipedia.org/wiki/Cuckoo_hashing
|
||||
* Cuckoo Stash http://research.microsoft.com/pubs/73856/stash-full.9-30.pdf
|
||||
* FNV http://www.isthe.com/chongo/tech/comp/fnv/
|
||||
* MD5 http://en.wikipedia.org/wiki/MD5
|
||||
**/
|
||||
|
||||
#ifndef HTSINTHASH_DEFH
|
||||
#define HTSINTHASH_DEFH
|
||||
|
||||
/* Includes */
|
||||
#ifdef _WIN32
|
||||
#include <stddef.h>
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#elif (defined(SOLARIS) || defined(sun) || defined(HAVE_INTTYPES_H) \
|
||||
|| defined(BSD) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD_kernel__))
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
/** Value. **/
|
||||
typedef union inthash_value {
|
||||
/** Integer value. **/
|
||||
intptr_t intg;
|
||||
|
||||
/** Unsigned integer value. **/
|
||||
uintptr_t uintg;
|
||||
|
||||
/** Pointer value. **/
|
||||
void *ptr;
|
||||
} inthash_value;
|
||||
|
||||
/** NULL Value. **/
|
||||
#define INTHASH_VALUE_NULL { 0 }
|
||||
|
||||
#ifndef HTS_DEF_FWSTRUCT_inthash_item
|
||||
#define HTS_DEF_FWSTRUCT_inthash_item
|
||||
typedef struct inthash_item inthash_item;
|
||||
#endif
|
||||
|
||||
/** Hash key (32-bit) **/
|
||||
typedef uint32_t inthash_key;
|
||||
|
||||
/** Pair of hashes **/
|
||||
typedef struct inthash_keys {
|
||||
inthash_key hash1;
|
||||
inthash_key hash2;
|
||||
} inthash_keys;
|
||||
|
||||
/** NULL pair of hashes. **/
|
||||
#define INTHASH_KEYS_NULL { 0, 0 }
|
||||
|
||||
/** Item holding a value. **/
|
||||
struct inthash_item {
|
||||
/** Key. **/
|
||||
char *name;
|
||||
|
||||
/** Value. **/
|
||||
inthash_value value;
|
||||
|
||||
/** Hashes of the key. **/
|
||||
inthash_keys hashes;
|
||||
};
|
||||
|
||||
/** Log level. **/
|
||||
typedef enum inthash_loglevel {
|
||||
inthash_log_critical,
|
||||
inthash_log_warning,
|
||||
inthash_log_info,
|
||||
inthash_log_debug,
|
||||
inthash_log_trace
|
||||
} inthash_loglevel;
|
||||
|
||||
/** Alias for legacy code. **/
|
||||
typedef inthash_item inthash_chain;
|
||||
|
||||
/** Value free handler **/
|
||||
typedef void (*t_inthash_freehandler)(void *arg, void *value);
|
||||
|
||||
/** Name dup handler. **/
|
||||
typedef char* (*t_inthash_duphandler)(void *arg, const char *name);
|
||||
|
||||
/** Hash computation handler. **/
|
||||
typedef inthash_keys (*t_inthash_hasheshandler)(void *arg, const char *value);
|
||||
|
||||
/** Hashtable logging handler. **/
|
||||
typedef void (*t_inthash_loghandler)(void *arg, inthash_loglevel level,
|
||||
const char* format, va_list args);
|
||||
|
||||
/** Hashtable fatal assertion failure. **/
|
||||
typedef void (*t_inthash_asserthandler)(void *arg, const char* exp, const char* file, int line);
|
||||
|
||||
/** Key printer (debug) **/
|
||||
typedef const char* (*t_inthash_printkeyhandler)(void *arg, const char *name);
|
||||
|
||||
/** Value printer (debug) **/
|
||||
typedef const char* (*t_inthash_printvaluehandler)(void *arg, void *value);
|
||||
|
||||
/**
|
||||
* Value comparison handler (returns non-zero value if strings are equal).
|
||||
**/
|
||||
typedef int (*t_inthash_cmphandler)(void *arg, const char *a, const char *b);
|
||||
|
||||
/** Hashtable (opaque structure). **/
|
||||
#ifndef HTS_DEF_FWSTRUCT_struct_inthash
|
||||
#define HTS_DEF_FWSTRUCT_struct_inthash
|
||||
typedef struct struct_inthash struct_inthash, *inthash;
|
||||
#endif
|
||||
|
||||
/** Hashtable enumeration (opaque structure). **/
|
||||
#ifndef HTS_DEF_FWSTRUCT_struct_inthash_enum
|
||||
#define HTS_DEF_FWSTRUCT_struct_inthash_enum
|
||||
typedef struct struct_inthash_enum struct_inthash_enum;
|
||||
#endif
|
||||
|
||||
/** Enumeration. **/
|
||||
struct struct_inthash_enum {
|
||||
inthash table;
|
||||
size_t index;
|
||||
};
|
||||
|
||||
/* Library internal definictions */
|
||||
#ifdef HTS_INTERNAL_BYTECODE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create a new hashtable, with initial bucket size of 'size'.
|
||||
* If size is 0, use the default minimal bucket size.
|
||||
* Return a non-NULL pointer upon success.
|
||||
**/
|
||||
inthash inthash_new(size_t size);
|
||||
|
||||
/**
|
||||
* Was the hashtable successfully created ?
|
||||
* Return non-zero value if the hashtable is valid.
|
||||
**/
|
||||
int inthash_created(inthash hashtable);
|
||||
|
||||
/**
|
||||
* Delete a hashtable, freeing all entries.
|
||||
**/
|
||||
void inthash_delete(inthash * hashtable);
|
||||
|
||||
/**
|
||||
* Return the number of items in the hashtable.
|
||||
**/
|
||||
size_t inthash_nitems(inthash hashtable);
|
||||
|
||||
/**
|
||||
* Return the memory size taken by the hashtable.
|
||||
* (This does not take account of the possible memory taken by values)
|
||||
**/
|
||||
size_t inthash_memory_size(inthash hashtable);
|
||||
|
||||
/**
|
||||
* If 'flag' is non-zero, calls inthash_value_set_value_handler() with
|
||||
* default system free() handler function, otherwise, free the value handlers.
|
||||
**/
|
||||
void inthash_value_is_malloc(inthash hashtable, int flag);
|
||||
|
||||
/**
|
||||
* Set handlers for values.
|
||||
* free: this handler will be called when a value is to be removed from
|
||||
* the hashtable. if NULL, values won't be free'd.
|
||||
* arg: opaque custom argument to be used by functions.
|
||||
* Handler(s) MUST NOT be changed once elements have been added.
|
||||
**/
|
||||
void inthash_value_set_value_handler(inthash hashtable,
|
||||
t_inthash_freehandler free,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Set handlers for keys.
|
||||
* dup: handler called to duplicate a key. if NULL, the internal pool is used.
|
||||
* free: handler called to free a key. if NULL, the internal pool is used.
|
||||
* hash: hashing handler, called to hash a key. if NULL, the default hash
|
||||
* function is used.
|
||||
* equals: comparison handler, returning non-zero value when two keys are
|
||||
* identical. if NULL, the default comparison function is used.
|
||||
* arg: opaque custom argument to be used by functions.
|
||||
* Handler(s) MUST NOT be changed once elements have been added.
|
||||
**/
|
||||
void inthash_value_set_key_handler(inthash hashtable,
|
||||
t_inthash_duphandler dup,
|
||||
t_inthash_freehandler free,
|
||||
t_inthash_hasheshandler hash,
|
||||
t_inthash_cmphandler equals,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Set assertion failure handler.
|
||||
* log: handler called upon serious programming error
|
||||
* fatal: handler called upon serious programming error
|
||||
**/
|
||||
void inthash_set_assert_handler(inthash hashtable,
|
||||
t_inthash_loghandler log,
|
||||
t_inthash_asserthandler fatal,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Set pretty print loggers (debug). Both handlers must return a string
|
||||
* pointer which shall be valid until the next call. Both key and value
|
||||
* pointers shall be valid at the same time.
|
||||
* name: handler called to print the string representation of the name
|
||||
* value: handler called to print the string representation of the value
|
||||
**/
|
||||
void inthash_set_print_handler(inthash hashtable,
|
||||
t_inthash_printkeyhandler key,
|
||||
t_inthash_printvaluehandler value,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Set the hashtable name, for degugging purpose.
|
||||
* name: the hashtable name (ASCII or UTF-8)
|
||||
*/
|
||||
void inthash_set_name(inthash hashtable, const char *name);
|
||||
|
||||
/**
|
||||
* Get the hashtable name, for degugging purpose.
|
||||
* Return NULL if no name was defined.
|
||||
**/
|
||||
const char* inthash_get_name(inthash hashtable);
|
||||
|
||||
/**
|
||||
* Read an integer entry from the hashtable.
|
||||
* Return non-zero value upon success and sets intvalue.
|
||||
**/
|
||||
int inthash_read(inthash hashtable, const char *name, intptr_t * intvalue);
|
||||
|
||||
/**
|
||||
* Same as inthash_read(), but return 0 is the value was zero.
|
||||
**/
|
||||
int inthash_readptr(inthash hashtable, const char *name, intptr_t * intvalue);
|
||||
|
||||
/**
|
||||
* Return non-zero value if the given entry exists.
|
||||
**/
|
||||
int inthash_exists(inthash hashtable, const char *name);
|
||||
|
||||
/**
|
||||
* Read an entry from the hashtable.
|
||||
* Return non-zero value upon success and sets value.
|
||||
**/
|
||||
int inthash_read_value(inthash hashtable, const char *name,
|
||||
inthash_value * value);
|
||||
|
||||
/**
|
||||
* Write an entry to the hashtable.
|
||||
* Return non-zero value if the entry was added, zero if it was replaced.
|
||||
**/
|
||||
int inthash_write_value(inthash hashtable, const char *name,
|
||||
inthash_value value);
|
||||
/**
|
||||
* Read a pointer entry from the hashtable.
|
||||
* Return non-zero value upon success and sets value.
|
||||
**/
|
||||
int inthash_read_pvoid(inthash hashtable, const char *name, void **value);
|
||||
|
||||
/**
|
||||
* Write a pointer entry to the hashtable.
|
||||
* Return non-zero value if the entry was added, zero if it was replaced.
|
||||
**/
|
||||
int inthash_write_pvoid(inthash hashtable, const char *name, void *value);
|
||||
|
||||
/**
|
||||
* Alias to inthash_write_pvoid()
|
||||
**/
|
||||
void inthash_add_pvoid(inthash hashtable, const char *name, void *value);
|
||||
|
||||
/**
|
||||
* Write an integer entry to the hashtable.
|
||||
* Return non-zero value if the entry was added, zero if it was replaced.
|
||||
**/
|
||||
int inthash_write(inthash hashtable, const char *name, intptr_t value);
|
||||
|
||||
/**
|
||||
* Alias to inthash_write()
|
||||
**/
|
||||
void inthash_add(inthash hashtable, const char *name, intptr_t value);
|
||||
|
||||
/**
|
||||
* Increment an entry value in the hashtable
|
||||
* (or create a new entry with value 1 if it does not yet exist)
|
||||
* Return non-zero value if the entry was added, zero if it was changed.
|
||||
**/
|
||||
int inthash_inc(inthash hashtable, const char *name);
|
||||
|
||||
/**
|
||||
* Decrement an entry value in the hashtable
|
||||
* (or create a new entry with value -1 if it does not yet exist)
|
||||
* Return non-zero value if the entry was added, zero if it was changed.
|
||||
**/
|
||||
int inthash_dec(inthash hashtable, const char *name);
|
||||
|
||||
/**
|
||||
* Remove an entry from the hashtable
|
||||
* Return non-zero value if the entry was removed, zero otherwise.
|
||||
**/
|
||||
int inthash_remove(inthash hashtable, const char *name);
|
||||
|
||||
/**
|
||||
* Return a new enumerator.
|
||||
* Note: deleting entries is safe while enumerating, but adding entries
|
||||
* lead to undefined enumeration behavior (yet safe).
|
||||
**/
|
||||
struct_inthash_enum inthash_enum_new(inthash hashtable);
|
||||
|
||||
/**
|
||||
* Enumerate the next entry.
|
||||
**/
|
||||
inthash_item *inthash_enum_next(struct_inthash_enum * e);
|
||||
|
||||
/**
|
||||
* Compute a hash, given a string value.
|
||||
**/
|
||||
inthash_keys inthash_hash_value(const char *value);
|
||||
|
||||
/**
|
||||
* Set default global assertion failure handler.
|
||||
* The handler will be used if no specific handler was defined in the
|
||||
* hashtable itself.
|
||||
* log: handler called upon serious error log (opaque argument
|
||||
* is the hashtable itself)
|
||||
* fatal: handler called upon serious programming error (opaque argument
|
||||
* is the hashtable itself)
|
||||
**/
|
||||
void inthash_set_global_assert_handler(t_inthash_loghandler log,
|
||||
t_inthash_asserthandler fatal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
216
src/htslib.c
216
src/htslib.c
@@ -928,7 +928,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
printf("Proxy Use: for %s%s proxy %d port %d\n", adr, fil,
|
||||
retour->req.proxy.name, retour->req.proxy.port);
|
||||
#endif
|
||||
print_buffer(&bstr, "http://%s", jump_identification(adr));
|
||||
print_buffer(&bstr, "http://%s", jump_identification_const(adr));
|
||||
} else { // ftp:// en proxy http
|
||||
#if HDEBUG
|
||||
printf("Proxy Use for ftp: for %s%s proxy %d port %d\n", adr, fil,
|
||||
@@ -971,8 +971,8 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
// tester proxy authentication
|
||||
if (retour->req.proxy.active) {
|
||||
if (link_has_authorization(retour->req.proxy.name)) { // et hop, authentification proxy!
|
||||
const char *a = jump_identification(retour->req.proxy.name);
|
||||
const char *astart = jump_protocol(retour->req.proxy.name);
|
||||
const char *a = jump_identification_const(retour->req.proxy.name);
|
||||
const char *astart = jump_protocol_const(retour->req.proxy.name);
|
||||
char autorisation[1100];
|
||||
char user_pass[256];
|
||||
|
||||
@@ -1000,7 +1000,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
)
|
||||
) { // PAS file://
|
||||
print_buffer(&bstr, "Referer: http://%s%s"H_CRLF,
|
||||
jump_identification(referer_adr), referer_fil);
|
||||
jump_identification_const(referer_adr), referer_fil);
|
||||
}
|
||||
}
|
||||
// HTTP field: referer
|
||||
@@ -1025,7 +1025,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
int max_cookies = 8;
|
||||
|
||||
do {
|
||||
b = cookie_find(b, "", jump_identification(adr), fil); // prochain cookie satisfaisant aux conditions
|
||||
b = cookie_find(b, "", jump_identification_const(adr), fil); // prochain cookie satisfaisant aux conditions
|
||||
if (b != NULL) {
|
||||
max_cookies--;
|
||||
if (!cook) {
|
||||
@@ -1054,7 +1054,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
}
|
||||
|
||||
{
|
||||
const char *real_adr = jump_identification(adr);
|
||||
const char *real_adr = jump_identification_const(adr);
|
||||
|
||||
// Mandatory per RFC2616
|
||||
if (!direct_url) { // pas ftp:// par exemple
|
||||
@@ -1103,8 +1103,8 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
|
||||
autorisation[0] = '\0';
|
||||
if (link_has_authorization(adr)) { // ohh une authentification!
|
||||
const char *a = jump_identification(adr);
|
||||
const char *astart = jump_protocol(adr);
|
||||
const char *a = jump_identification_const(adr);
|
||||
const char *astart = jump_protocol_const(adr);
|
||||
|
||||
if (!direct_url) { // pas ftp:// par exemple
|
||||
char user_pass[256];
|
||||
@@ -1149,7 +1149,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
if (_DEBUG_HEAD) {
|
||||
if (ioinfo) {
|
||||
fprintf(ioinfo, "[%d] request for %s%s:\r\n", retour->debugid,
|
||||
jump_identification(adr), fil);
|
||||
jump_identification_const(adr), fil);
|
||||
fprintfio(ioinfo, bstr.buffer, "<<< ");
|
||||
fprintf(ioinfo, "\r\n");
|
||||
fflush(ioinfo);
|
||||
@@ -1528,7 +1528,7 @@ void treathead(t_cookie * cookie, const char *adr, const char *fil, htsblk * ret
|
||||
|
||||
// initialiser cookie lu actuellement
|
||||
if (adr)
|
||||
strcpybuff(domain, jump_identification(adr)); // domaine
|
||||
strcpybuff(domain, jump_identification_const(adr)); // domaine
|
||||
strcpybuff(path, "/"); // chemin (/)
|
||||
strcpybuff(cook_name, ""); // nom cookie (MYCOOK)
|
||||
strcpybuff(cook_value, ""); // valeur (ID=toto,S=1234)
|
||||
@@ -2103,7 +2103,7 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port,
|
||||
const char *error = "unknown error";
|
||||
|
||||
// tester un éventuel id:pass et virer id:pass@ si détecté
|
||||
const char *const iadr = jump_identification(_iadr);
|
||||
const char *const iadr = jump_identification_const(_iadr);
|
||||
|
||||
SOCaddr_clear(server);
|
||||
|
||||
@@ -2113,7 +2113,7 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port,
|
||||
|
||||
// tester un éventuel port
|
||||
if (port == -1) {
|
||||
char *a = jump_toport(iadr);
|
||||
const char *a = jump_toport_const(iadr);
|
||||
|
||||
#if HTS_USEOPENSSL
|
||||
if (retour->ssl)
|
||||
@@ -2362,9 +2362,9 @@ int ident_url_absolute(const char *url, lien_adrfil *adrfil) {
|
||||
p = url + pos;
|
||||
|
||||
// p pointe sur le début de l'adrfil->adresse, ex: www.truc.fr/sommaire/index.html
|
||||
q = strchr(jump_identification(p), '/');
|
||||
q = strchr(jump_identification_const(p), '/');
|
||||
if (q == 0)
|
||||
q = strchr(jump_identification(p), '?'); // http://www.foo.com?bar=1
|
||||
q = strchr(jump_identification_const(p), '?'); // http://www.foo.com?bar=1
|
||||
if (q == 0)
|
||||
q = p + strlen(p); // pointe sur \0
|
||||
// q pointe sur le chemin, ex: index.html?query=recherche
|
||||
@@ -3123,7 +3123,7 @@ void rawlinput(FILE * fp, char *s, int max) {
|
||||
}
|
||||
|
||||
//cherche chaine, case insensitive
|
||||
char *strstrcase(char *s, const char *o) {
|
||||
const char *strstrcase(const char *s, const char *o) {
|
||||
while(*s && strfield(s, o) == 0)
|
||||
s++;
|
||||
if (*s == '\0')
|
||||
@@ -3344,24 +3344,33 @@ int ishttperror(int err) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Declare a non-const version of FUN */
|
||||
#define DECLARE_NON_CONST_VERSION(FUN) \
|
||||
char *FUN(char *source) { \
|
||||
const char *const ret = FUN ##_const(source); \
|
||||
return ret != NULL ? source + ( ret - source ) : NULL; \
|
||||
}
|
||||
|
||||
// retourne le pointeur ou le pointeur + offset si il existe dans la chaine un @ signifiant
|
||||
// une identification
|
||||
HTSEXT_API char *jump_identification(const char *source) {
|
||||
HTSEXT_API const char *jump_identification_const(const char *source) {
|
||||
const char *a, *trytofind;
|
||||
|
||||
if (strcmp(source, "file://") == 0)
|
||||
return (char *) source;
|
||||
return source;
|
||||
// rechercher dernier @ (car parfois email transmise dans adresse!)
|
||||
// mais sauter ftp:// éventuel
|
||||
a = jump_protocol(source);
|
||||
a = jump_protocol_const(source);
|
||||
trytofind = strrchr_limit(a, '@', strchr(a, '/'));
|
||||
return (char *) ((trytofind != NULL) ? trytofind : a);
|
||||
return trytofind != NULL ? trytofind : a;
|
||||
}
|
||||
|
||||
HTSEXT_API char *jump_normalized(const char *source) {
|
||||
HTSEXT_API DECLARE_NON_CONST_VERSION(jump_identification)
|
||||
|
||||
HTSEXT_API const char *jump_normalized_const(const char *source) {
|
||||
if (strcmp(source, "file://") == 0)
|
||||
return (char *) source;
|
||||
source = jump_identification(source);
|
||||
return source;
|
||||
source = jump_identification_const(source);
|
||||
if (strfield(source, "www") && source[3] != '\0') {
|
||||
if (source[3] == '.') { // www.foo.com -> foo.com
|
||||
source += 4;
|
||||
@@ -3375,12 +3384,14 @@ HTSEXT_API char *jump_normalized(const char *source) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return (char *) source;
|
||||
return source;
|
||||
}
|
||||
|
||||
HTSEXT_API DECLARE_NON_CONST_VERSION(jump_normalized)
|
||||
|
||||
static int sortNormFnc(const void *a_, const void *b_) {
|
||||
char **a = (char **) a_;
|
||||
char **b = (char **) b_;
|
||||
const char *const*const a = (const char *const*) a_;
|
||||
const char *const*const b = (const char *const*) b_;
|
||||
|
||||
return strcmp(*a + 1, *b + 1);
|
||||
}
|
||||
@@ -3389,7 +3400,7 @@ HTSEXT_API char *fil_normalized(const char *source, char *dest) {
|
||||
char lastc = 0;
|
||||
int gotquery = 0;
|
||||
int ampargs = 0;
|
||||
int i, j;
|
||||
size_t i, j;
|
||||
char *query = NULL;
|
||||
|
||||
for(i = j = 0; source[i] != '\0'; i++) {
|
||||
@@ -3411,7 +3422,7 @@ HTSEXT_API char *fil_normalized(const char *source, char *dest) {
|
||||
if (ampargs > 1) {
|
||||
char **amps = malloct(ampargs * sizeof(char *));
|
||||
char *copyBuff = NULL;
|
||||
int qLen = 0;
|
||||
size_t qLen = 0;
|
||||
|
||||
assertf(amps != NULL);
|
||||
gotquery = 0;
|
||||
@@ -3420,13 +3431,14 @@ HTSEXT_API char *fil_normalized(const char *source, char *dest) {
|
||||
if (!gotquery) {
|
||||
gotquery = 1;
|
||||
query = &dest[i];
|
||||
qLen = (int) strlen(query);
|
||||
qLen = strlen(query);
|
||||
}
|
||||
assertf(j < ampargs);
|
||||
amps[j++] = &dest[i];
|
||||
dest[i] = '\0';
|
||||
}
|
||||
}
|
||||
assertf(gotquery);
|
||||
assertf(j == ampargs);
|
||||
|
||||
/* Sort 'em all */
|
||||
@@ -3443,7 +3455,7 @@ HTSEXT_API char *fil_normalized(const char *source, char *dest) {
|
||||
strcatbuff(copyBuff, "&");
|
||||
strcatbuff(copyBuff, amps[i] + 1);
|
||||
}
|
||||
assertf((int) strlen(copyBuff) <= qLen);
|
||||
assertf(strlen(copyBuff) == qLen);
|
||||
strcpybuff(query, copyBuff);
|
||||
|
||||
/* Cleanup */
|
||||
@@ -3457,7 +3469,7 @@ HTSEXT_API char *fil_normalized(const char *source, char *dest) {
|
||||
#define endwith(a) ( (len >= (sizeof(a)-1)) ? ( strncmp(dest, a+len-(sizeof(a)-1), sizeof(a)-1) == 0 ) : 0 );
|
||||
HTSEXT_API char *adr_normalized(const char *source, char *dest) {
|
||||
/* not yet too aggressive (no com<->net<->org checkings) */
|
||||
strcpybuff(dest, jump_normalized(source));
|
||||
strcpybuff(dest, jump_normalized_const(source));
|
||||
return dest;
|
||||
}
|
||||
|
||||
@@ -3465,52 +3477,37 @@ HTSEXT_API char *adr_normalized(const char *source, char *dest) {
|
||||
|
||||
// find port (:80) or NULL if not found
|
||||
// can handle IPV6 addresses
|
||||
HTSEXT_API char *jump_toport(const char *source) {
|
||||
HTSEXT_API const char *jump_toport_const(const char *source) {
|
||||
const char *a, *trytofind;
|
||||
|
||||
a = jump_identification(source);
|
||||
a = jump_identification_const(source);
|
||||
trytofind = strrchr_limit(a, ']', strchr(source, '/')); // find last ] (http://[3ffe:b80:1234::1]:80/foo.html)
|
||||
a = strchr((trytofind) ? trytofind : a, ':');
|
||||
return (char *) a;
|
||||
return a;
|
||||
}
|
||||
|
||||
HTSEXT_API DECLARE_NON_CONST_VERSION(jump_toport)
|
||||
|
||||
// strrchr, but not too far
|
||||
char *strrchr_limit(const char *s, char c, const char *limit) {
|
||||
const char *strrchr_limit(const char *s, char c, const char *limit) {
|
||||
if (limit == NULL) {
|
||||
const char *p = strrchr(s, c);
|
||||
|
||||
return (char *) (p ? (p + 1) : NULL);
|
||||
return p ? (p + 1) : NULL;
|
||||
} else {
|
||||
const char *a = NULL, *p;
|
||||
|
||||
for(;;) {
|
||||
p = strchr((a) ? a : s, c);
|
||||
if ((p >= limit) || (p == NULL))
|
||||
return (char *) a;
|
||||
return a;
|
||||
a = p + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// strrchr, but not too far
|
||||
char *strstr_limit(const char *s, const char *sub, const char *limit) {
|
||||
if (limit == NULL) {
|
||||
return strstr(s, sub);
|
||||
} else {
|
||||
const char *pos = strstr(s, sub);
|
||||
|
||||
if (pos != NULL) {
|
||||
const char *farpos = strstr(s, limit);
|
||||
|
||||
if (farpos == NULL || pos < farpos)
|
||||
return (char *) pos;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// retourner adr sans ftp://
|
||||
char *jump_protocol(const char *source) {
|
||||
const char *jump_protocol_const(const char *source) {
|
||||
int p;
|
||||
|
||||
// scheme
|
||||
@@ -3526,9 +3523,11 @@ char *jump_protocol(const char *source) {
|
||||
// net_path
|
||||
if (strncmp(source, "//", 2) == 0)
|
||||
source += 2;
|
||||
return (char *) source;
|
||||
return source;
|
||||
}
|
||||
|
||||
DECLARE_NON_CONST_VERSION(jump_protocol)
|
||||
|
||||
// codage base 64 a vers b
|
||||
void code64(unsigned char *a, int size_a, unsigned char *b, int crlf) {
|
||||
int i1 = 0, i2 = 0, i3 = 0, i4 = 0;
|
||||
@@ -4520,13 +4519,15 @@ int hts_read(htsblk * r, char *buff, int size) {
|
||||
// 'RX98
|
||||
|
||||
// 'capsule' contenant uniquement le cache
|
||||
t_dnscache *_hts_cache(httrackp * opt) {
|
||||
t_dnscache *hts_cache(httrackp * opt) {
|
||||
assertf(opt != NULL);
|
||||
if (opt->state.dns_cache == NULL) {
|
||||
opt->state.dns_cache = (t_dnscache *) malloct(sizeof(t_dnscache));
|
||||
memset(opt->state.dns_cache, 0, sizeof(t_dnscache));
|
||||
}
|
||||
assertf(opt->state.dns_cache != NULL);
|
||||
/* first entry is NULL */
|
||||
assertf(opt->state.dns_cache->iadr == NULL);
|
||||
return opt->state.dns_cache;
|
||||
}
|
||||
|
||||
@@ -4535,8 +4536,8 @@ void hts_cache_free(t_dnscache *const root) {
|
||||
if (root != NULL) {
|
||||
t_dnscache *cache;
|
||||
for(cache = root; cache != NULL; ) {
|
||||
t_dnscache *const next = cache->n;
|
||||
cache->n = NULL;
|
||||
t_dnscache *const next = cache->next;
|
||||
cache->next = NULL;
|
||||
freet(cache);
|
||||
cache = next;
|
||||
}
|
||||
@@ -4553,15 +4554,23 @@ void hts_cache_free(t_dnscache *const root) {
|
||||
// si h_length==0 alors le nom n'existe pas dans le dns
|
||||
static SOCaddr* hts_ghbn(const t_dnscache *cache, const char *const iadr, SOCaddr *const addr) {
|
||||
assertf(addr != NULL);
|
||||
for(; cache != NULL; cache = cache->n) {
|
||||
assertf(iadr != NULL);
|
||||
if (*iadr == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
/* first entry is empty */
|
||||
if (cache->iadr == NULL) {
|
||||
cache = cache->next;
|
||||
}
|
||||
for(; cache != NULL; cache = cache->next) {
|
||||
assertf(cache != NULL);
|
||||
assertf(iadr != NULL);
|
||||
if (cache->iadr != NULL && strcmp(cache->iadr, iadr) == 0) { // ok trouvé
|
||||
if (cache->host_length > 0) { // entrée valide
|
||||
assertf(cache->iadr != NULL);
|
||||
assertf(cache->iadr == (const char*) cache + sizeof(t_dnscache));
|
||||
if (strcmp(cache->iadr, iadr) == 0) { // ok trouvé
|
||||
if (cache->host_length != 0) { // entrée valide
|
||||
assertf(cache->host_length <= sizeof(cache->host_addr));
|
||||
SOCaddr_copyaddr2(*addr, cache->host_addr, cache->host_length);
|
||||
return addr;
|
||||
} else if (cache->host_length == 0) { // en cours
|
||||
return NULL;
|
||||
} else { // erreur dans le dns, déja vérifié
|
||||
SOCaddr_clear(*addr);
|
||||
return addr;
|
||||
@@ -4659,16 +4668,16 @@ HTSEXT_API int check_hostname_dns(const char *const hostname) {
|
||||
// Needs locking
|
||||
// cache dns interne à HTS // ** FREE A FAIRE sur la chaine
|
||||
static SOCaddr* hts_dns_resolve_(httrackp * opt, const char *_iadr,
|
||||
SOCaddr *const addr, const char **error) {
|
||||
SOCaddr *const addr, const char **error) {
|
||||
char BIGSTK iadr[HTS_URLMAXSIZE * 2];
|
||||
t_dnscache *cache = _hts_cache(opt); // adresse du cache
|
||||
t_dnscache *cache = hts_cache(opt); // adresse du cache
|
||||
SOCaddr *sa;
|
||||
|
||||
assertf(opt != NULL);
|
||||
assertf(_iadr != NULL);
|
||||
assertf(addr != NULL);
|
||||
|
||||
strcpybuff(iadr, jump_identification(_iadr));
|
||||
strcpybuff(iadr, jump_identification_const(_iadr));
|
||||
// couper éventuel :
|
||||
{
|
||||
char *a;
|
||||
@@ -4682,8 +4691,11 @@ static SOCaddr* hts_dns_resolve_(httrackp * opt, const char *_iadr,
|
||||
if (sa != NULL) {
|
||||
return SOCaddr_is_valid(*sa) ? sa : NULL;
|
||||
} else { // non présent dans le cache dns, tester
|
||||
const size_t iadr_len = strlen(iadr) + 1;
|
||||
char *block;
|
||||
|
||||
// find queue
|
||||
for(; cache->n != NULL; cache = cache->n) ;
|
||||
for(; cache->next != NULL; cache = cache->next) ;
|
||||
|
||||
#if DEBUGDNS
|
||||
printf("resolving (not cached) %s\n", iadr);
|
||||
@@ -4696,18 +4708,21 @@ static SOCaddr* hts_dns_resolve_(httrackp * opt, const char *_iadr,
|
||||
#endif
|
||||
|
||||
/* attempt to store new entry */
|
||||
cache->n = (t_dnscache *) calloct(1, sizeof(t_dnscache));
|
||||
if (cache->n != NULL) {
|
||||
strcpybuff(cache->n->iadr, iadr);
|
||||
block = malloct(sizeof(t_dnscache) + iadr_len);
|
||||
cache->next = (t_dnscache *) block;
|
||||
if (cache->next != NULL) {
|
||||
t_dnscache *const next = cache->next;
|
||||
char *str = block + sizeof(t_dnscache);
|
||||
memcpy(str, iadr, iadr_len);
|
||||
next->iadr = str;
|
||||
if (sa != NULL) {
|
||||
cache->n->host_length = SOCaddr_size(*sa);
|
||||
assertf(cache->n->host_length < sizeof(cache->n->host_addr));
|
||||
memcpy(cache->n->host_addr, &SOCaddr_sockaddr(*sa), cache->n->host_length);
|
||||
next->host_length = SOCaddr_size(*sa);
|
||||
assertf(next->host_length <= sizeof(next->host_addr));
|
||||
memcpy(next->host_addr, &SOCaddr_sockaddr(*sa), next->host_length);
|
||||
} else {
|
||||
cache->n->host_addr[0] = '\0';
|
||||
cache->n->host_length = 0; // non existant dans le dns
|
||||
next->host_length = 0; // non existant dans le dns
|
||||
}
|
||||
cache->n->n = NULL;
|
||||
next->next = NULL;
|
||||
return sa;
|
||||
}
|
||||
|
||||
@@ -5020,29 +5035,29 @@ HTSEXT_API void hts_set_error_callback(htsErrorCallback handler) {
|
||||
htsCallbackErr = handler;
|
||||
}
|
||||
|
||||
HTSEXT_API htsErrorCallback hts_get_error_callback() {
|
||||
HTSEXT_API htsErrorCallback hts_get_error_callback(void) {
|
||||
return htsCallbackErr;
|
||||
}
|
||||
|
||||
static void default_inthash_asserthandler(void *arg, const char* exp, const char* file, int line) {
|
||||
static void default_coucal_asserthandler(void *arg, const char* exp, const char* file, int line) {
|
||||
abortf_(exp, file, line);
|
||||
}
|
||||
|
||||
static int get_loglevel_from_inthash(inthash_loglevel level) {
|
||||
static int get_loglevel_from_coucal(coucal_loglevel level) {
|
||||
switch(level) {
|
||||
case inthash_log_critical:
|
||||
case coucal_log_critical:
|
||||
return LOG_PANIC;
|
||||
break;
|
||||
case inthash_log_warning:
|
||||
case coucal_log_warning:
|
||||
return LOG_WARNING;
|
||||
break;
|
||||
case inthash_log_info:
|
||||
case coucal_log_info:
|
||||
return LOG_INFO;
|
||||
break;
|
||||
case inthash_log_debug:
|
||||
case coucal_log_debug:
|
||||
return LOG_DEBUG;
|
||||
break;
|
||||
case inthash_log_trace:
|
||||
case coucal_log_trace:
|
||||
return LOG_TRACE;
|
||||
break;
|
||||
default:
|
||||
@@ -5052,10 +5067,10 @@ static int get_loglevel_from_inthash(inthash_loglevel level) {
|
||||
}
|
||||
|
||||
/* log to default console */
|
||||
static void default_inthash_loghandler(void *arg, inthash_loglevel level,
|
||||
static void default_coucal_loghandler(void *arg, coucal_loglevel level,
|
||||
const char* format, va_list args) {
|
||||
|
||||
if (level <= inthash_log_warning) {
|
||||
if (level <= coucal_log_warning) {
|
||||
fprintf(stderr, "** warning: ");
|
||||
}
|
||||
vfprintf(stderr, format, args);
|
||||
@@ -5063,23 +5078,23 @@ static void default_inthash_loghandler(void *arg, inthash_loglevel level,
|
||||
}
|
||||
|
||||
/* log to project log */
|
||||
static void htsopt_inthash_loghandler(void *arg, inthash_loglevel level,
|
||||
static void htsopt_coucal_loghandler(void *arg, coucal_loglevel level,
|
||||
const char* format, va_list args) {
|
||||
httrackp *const opt = (httrackp*) arg;
|
||||
if (opt != NULL && opt->log != NULL) {
|
||||
hts_log_vprint(opt, get_loglevel_from_inthash(level),
|
||||
hts_log_vprint(opt, get_loglevel_from_coucal(level),
|
||||
format, args);
|
||||
} else {
|
||||
default_inthash_loghandler(NULL, level, format, args);
|
||||
default_coucal_loghandler(NULL, level, format, args);
|
||||
}
|
||||
}
|
||||
|
||||
/* attach hashtable logger to project log */
|
||||
void hts_set_hash_handler(inthash hashtable, httrackp *opt) {
|
||||
void hts_set_hash_handler(coucal hashtable, httrackp *opt) {
|
||||
/* Init hashtable default assertion handler. */
|
||||
inthash_set_assert_handler(hashtable,
|
||||
htsopt_inthash_loghandler,
|
||||
default_inthash_asserthandler,
|
||||
coucal_set_assert_handler(hashtable,
|
||||
htsopt_coucal_loghandler,
|
||||
default_coucal_asserthandler,
|
||||
opt);
|
||||
}
|
||||
|
||||
@@ -5105,8 +5120,8 @@ HTSEXT_API int hts_init(void) {
|
||||
hts_debug_log_print("entering hts_init()"); /* debug */
|
||||
|
||||
/* Init hashtable default assertion handler. */
|
||||
inthash_set_global_assert_handler(default_inthash_loghandler,
|
||||
default_inthash_asserthandler);
|
||||
coucal_set_global_assert_handler(default_coucal_loghandler,
|
||||
default_coucal_asserthandler);
|
||||
|
||||
/* Init threads (lazy init) */
|
||||
htsthread_init();
|
||||
@@ -5477,6 +5492,8 @@ HTSEXT_API httrackp *hts_create_opt(void) {
|
||||
opt->bypass_limits = 0; // enforce limits by default
|
||||
opt->state.stop = 0; // stopper
|
||||
opt->state.exit_xh = 0; // abort
|
||||
//
|
||||
opt->state.is_ended = 0;
|
||||
|
||||
/* Alocated buffers */
|
||||
|
||||
@@ -5540,8 +5557,13 @@ HTSEXT_API void hts_free_opt(httrackp * opt) {
|
||||
|
||||
/* Cache */
|
||||
if (opt->state.dns_cache != NULL) {
|
||||
t_dnscache *const root = opt->state.dns_cache;
|
||||
t_dnscache *root;
|
||||
|
||||
hts_mutexlock(&opt->state.lock);
|
||||
root = opt->state.dns_cache;
|
||||
opt->state.dns_cache = NULL;
|
||||
hts_mutexrelease(&opt->state.lock);
|
||||
|
||||
hts_cache_free(root);
|
||||
}
|
||||
|
||||
|
||||
29
src/htslib.h
29
src/htslib.h
@@ -148,12 +148,10 @@ struct OLD_htsblk {
|
||||
typedef struct t_dnscache t_dnscache;
|
||||
#endif
|
||||
struct t_dnscache {
|
||||
struct t_dnscache *n;
|
||||
int host_length; // 4 normalement - ==0 alors en cours de résolution
|
||||
char host_addr[HTS_MAXADDRLEN]; // 4 octets (v4), ou 16 octets (v6)
|
||||
// ou >16 si sockaddr
|
||||
// ==-1 alors erreur (host n'éxiste pas)
|
||||
char iadr[1024];
|
||||
struct t_dnscache *next;
|
||||
const char *iadr;
|
||||
size_t host_length; // length ; (4 or 16) ; 0 for error
|
||||
char host_addr[HTS_MAXADDRLEN];
|
||||
};
|
||||
|
||||
/* Library internal definictions */
|
||||
@@ -163,7 +161,7 @@ struct t_dnscache {
|
||||
void hts_init_htsblk(htsblk * r);
|
||||
|
||||
// attach specific project log to hachtable logger
|
||||
void hts_set_hash_handler(inthash hashtable, httrackp *opt);
|
||||
void hts_set_hash_handler(coucal hashtable, httrackp *opt);
|
||||
|
||||
// version
|
||||
HTSEXT_API const char* hts_version(void);
|
||||
@@ -217,7 +215,7 @@ int ftp_available(void);
|
||||
|
||||
#if HTS_DNSCACHE
|
||||
void hts_cache_free(t_dnscache *const cache);
|
||||
t_dnscache *_hts_cache(httrackp * opt);
|
||||
t_dnscache *hts_cache(httrackp * opt);
|
||||
#endif
|
||||
|
||||
// outils divers
|
||||
@@ -243,7 +241,7 @@ int linputsoc_t(T_SOC soc, char *s, int max, int timeout);
|
||||
int linput_trim(FILE * fp, char *s, int max);
|
||||
int linput_cpp(FILE * fp, char *s, int max);
|
||||
void rawlinput(FILE * fp, char *s, int max);
|
||||
char *strstrcase(char *s, const char *o);
|
||||
const char *strstrcase(const char *s, const char *o);
|
||||
int ident_url_absolute(const char *url, lien_adrfil *adrfil);
|
||||
void fil_simplifie(char *f);
|
||||
int is_unicode_utf8(const char *buffer, const size_t size);
|
||||
@@ -259,9 +257,9 @@ void give_mimext(char *s, const char *st);
|
||||
int may_bogus_multiple(httrackp * opt, const char *mime, const char *filename);
|
||||
int may_unknown2(httrackp * opt, const char *mime, const char *filename);
|
||||
|
||||
char *strrchr_limit(const char *s, char c, const char *limit);
|
||||
char *strstr_limit(const char *s, const char *sub, const char *limit);
|
||||
HTS_INLINE char *jump_protocol(const char *source);
|
||||
const char *strrchr_limit(const char *s, char c, const char *limit);
|
||||
char *jump_protocol(char *source);
|
||||
const char *jump_protocol_const(const char *source);
|
||||
void code64(unsigned char *a, int size_a, unsigned char *b, int crlf);
|
||||
|
||||
#define copychar(catbuff,a) concat(catbuff,(a),NULL)
|
||||
@@ -444,7 +442,7 @@ HTS_STATIC int strfield(const char *f, const char *s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
HTS_STATIC int strcmpnocase(char *a, char *b) {
|
||||
HTS_STATIC int strcmpnocase(const char *a, const char *b) {
|
||||
while(*a) {
|
||||
int cmp = hichar(*a) - hichar(*b);
|
||||
|
||||
@@ -541,8 +539,9 @@ HTS_STATIC int compare_mime(httrackp * opt, const char *mime, const char *file,
|
||||
|
||||
// returns (size_t) -1 upon error
|
||||
static HTS_UNUSED size_t off_t_to_size_t(off_t o) {
|
||||
if (o >= 0 && o < ( (size_t) -1 ) / 2) {
|
||||
return (size_t) o;
|
||||
const size_t so = (size_t) o;
|
||||
if ((off_t) so == o) {
|
||||
return so;
|
||||
} else {
|
||||
return (size_t) -1;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ Please visit our Website: http://www.httrack.com
|
||||
int domd5mem(const char *buf, size_t len, char *digest, int asAscii) {
|
||||
int endian = 1;
|
||||
unsigned char bindigest[16];
|
||||
MD5_CTX ctx;
|
||||
struct MD5Context ctx;
|
||||
|
||||
MD5Init(&ctx, *((char *) &endian));
|
||||
MD5Update(&ctx, (const unsigned char *) buf, (unsigned int) len);
|
||||
@@ -80,7 +80,7 @@ unsigned long int md5sum32(const char *buff) {
|
||||
return u.hash;
|
||||
}
|
||||
|
||||
void md5selftest() {
|
||||
void md5selftest(void) {
|
||||
static const char str1[] = "The quick brown fox jumps over the lazy dog\n";
|
||||
static const char str1m[] = "37c4b87edffc5d198ff5a185cee7ee09";
|
||||
static const char str2[] = "Hello";
|
||||
|
||||
@@ -164,11 +164,11 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
static const char *protocol_str[] =
|
||||
{ "http", "https", "ftp", "file", "unknown" };
|
||||
int protocol = PROTOCOL_HTTP;
|
||||
const char *const adr = jump_identification(adr_complete);
|
||||
const char *const adr = jump_identification_const(adr_complete);
|
||||
// copy of fil, used for lookups (see urlhack)
|
||||
const char *normadr = adr;
|
||||
const char *normfil = fil_complete;
|
||||
const char *const print_adr = jump_protocol(adr);
|
||||
const char *const print_adr = jump_protocol_const(adr);
|
||||
const char *start_pos = NULL, *nom_pos = NULL, *dot_pos = NULL; // Position nom et point
|
||||
|
||||
// pour changement d'extension ou de nom (content-disposition)
|
||||
@@ -1239,7 +1239,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
// (plus la peine : masqué au début)
|
||||
/*
|
||||
{
|
||||
char* a=jump_identification(afs->save);
|
||||
char* a = jump_identification(afs->save);
|
||||
if (a!=afs->save) {
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE*2];
|
||||
char *b;
|
||||
@@ -1307,9 +1307,9 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
int i = 0;
|
||||
|
||||
while(hts_tbdev[i][0]) {
|
||||
char *a = afs->save;
|
||||
const char *a = afs->save;
|
||||
|
||||
while((a = strstrcase(a, (char *) hts_tbdev[i]))) {
|
||||
while((a = strstrcase(a, hts_tbdev[i]))) {
|
||||
switch ((int) a[strlen(hts_tbdev[i])]) {
|
||||
case '\0':
|
||||
case '/':
|
||||
@@ -1691,7 +1691,7 @@ void url_savename_addstr(char *d, const char *s) {
|
||||
/* "filename" should be at least 64 bytes. */
|
||||
void url_savename_refname(const char *adr, const char *fil, char *filename) {
|
||||
unsigned char bindigest[16];
|
||||
MD5_CTX ctx;
|
||||
struct MD5Context ctx;
|
||||
|
||||
MD5Init(&ctx, 0);
|
||||
MD5Update(&ctx, (const unsigned char *) adr, (int) strlen(adr));
|
||||
|
||||
@@ -205,9 +205,9 @@ typedef struct htsmutex_s htsmutex_s, *htsmutex;
|
||||
#endif
|
||||
|
||||
/* Hashtables */
|
||||
#ifndef HTS_DEF_FWSTRUCT_struct_inthash
|
||||
#define HTS_DEF_FWSTRUCT_struct_inthash
|
||||
typedef struct struct_inthash struct_inthash, *inthash;
|
||||
#ifndef HTS_DEF_FWSTRUCT_struct_coucal
|
||||
#define HTS_DEF_FWSTRUCT_struct_coucal
|
||||
typedef struct struct_coucal struct_coucal, *coucal;
|
||||
#endif
|
||||
|
||||
/* Structure état du miroir */
|
||||
@@ -251,6 +251,7 @@ struct htsoptstate {
|
||||
char HTbuff[2048];
|
||||
unsigned int debug_state;
|
||||
unsigned int tmpnameid; /* 3.41 */
|
||||
int is_ended; /* 3.48-14 */
|
||||
};
|
||||
|
||||
/* Library handles */
|
||||
|
||||
101
src/htsparse.c
101
src/htsparse.c
@@ -540,9 +540,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
p = -1; // noter, mais sans titre
|
||||
else if (strfield(html, "body"))
|
||||
p = -1; // noter, mais sans titre
|
||||
else if (((int) (html - r->adr)) >= (r->size - 1))
|
||||
else if (html - r->adr >= r->size - 1)
|
||||
p = -1; // noter, mais sans titre
|
||||
else if ((int) (html - r->adr) >= r->size - 2) // we got to hurry
|
||||
else if (html - r->adr >= r->size - 2) // we got to hurry
|
||||
p = -1; // xxc xxc xxc
|
||||
}
|
||||
} else
|
||||
@@ -617,8 +617,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
if (str->page_charset_ != NULL
|
||||
&& *str->page_charset_ != '\0') {
|
||||
char *const sUtf =
|
||||
hts_convertStringToUTF8(s, (int) strlen(s),
|
||||
str->page_charset_);
|
||||
hts_convertStringToUTF8(s, strlen(s), str->page_charset_);
|
||||
if (sUtf != NULL) {
|
||||
strcpy(s, sUtf);
|
||||
free(sUtf);
|
||||
@@ -726,7 +725,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
strcatbuff(tempo, eol);
|
||||
hts_template_format_str(tempo + strlen(tempo), sizeof(tempo) - strlen(tempo),
|
||||
StringBuff(opt->footer),
|
||||
jump_identification(urladr()), urlfil(), gmttime,
|
||||
jump_identification_const(urladr()), urlfil(), gmttime,
|
||||
HTTRACK_VERSIONID, /* EOF */ NULL);
|
||||
strcatbuff(tempo, eol);
|
||||
//fwrite(tempo,1,strlen(tempo),fp);
|
||||
@@ -1218,8 +1217,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
printf("robots.txt meta tag detected\n");
|
||||
#endif
|
||||
if (a) {
|
||||
if (((int) (a - html)) < 999) {
|
||||
strncatbuff(tempo, html, (int) (a - html));
|
||||
if (a - html < 999) {
|
||||
strncatbuff(tempo, html, a - html);
|
||||
if (strstrcase(tempo, "content")) {
|
||||
if (strstrcase(tempo, "robots")) {
|
||||
if (strstrcase(tempo, "nofollow")) {
|
||||
@@ -1807,11 +1806,11 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
if (ok != -1) { // continuer
|
||||
// découper le lien
|
||||
do {
|
||||
if ((*(unsigned char *) eadr) < 32) { // caractère de contrôle (ou \0)
|
||||
if ((unsigned char) *eadr < 32) { // caractère de contrôle (ou \0)
|
||||
if (!is_space(*eadr))
|
||||
ok = 0;
|
||||
}
|
||||
if ((((int) (eadr - html))) > HTS_URLMAXSIZE) // ** trop long, >HTS_URLMAXSIZE caractères (on prévoit HTS_URLMAXSIZE autres pour path)
|
||||
if (eadr - html > HTS_URLMAXSIZE) // ** trop long, >HTS_URLMAXSIZE caractères (on prévoit HTS_URLMAXSIZE autres pour path)
|
||||
ok = -1; // ne pas traiter ce lien
|
||||
|
||||
if (ok > 0) {
|
||||
@@ -1856,10 +1855,10 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
} while(ok == 1);
|
||||
|
||||
// Empty link detected
|
||||
if ((((int) (eadr - html))) <= 1) { // link empty
|
||||
if (eadr - html <= 1) { // link empty
|
||||
ok = -1; // No
|
||||
if (*html != '#') { // Not empty+unique #
|
||||
if ((((int) (eadr - html)) == 1)) { // 1=link empty with delim (end_adr-start_adr)
|
||||
if (eadr - html == 1) { // 1=link empty with delim (end_adr-start_adr)
|
||||
if (quote) {
|
||||
if ((opt->getmode & 1) && (ptr > 0)) {
|
||||
HT_ADD("#"); // We add this for a <href="">
|
||||
@@ -1883,9 +1882,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
//char* p;
|
||||
|
||||
// construire lien (découpage)
|
||||
if ((((int) (eadr - html)) - 1) < HTS_URLMAXSIZE) { // pas trop long?
|
||||
strncpy(lien, html, ((int) (eadr - html)) - 1);
|
||||
*(lien + (((int) (eadr - html))) - 1) = '\0';
|
||||
if (eadr - html - 1 < HTS_URLMAXSIZE) { // pas trop long?
|
||||
strncpy(lien, html, eadr - html - 1);
|
||||
lien[eadr - html - 1] = '\0';
|
||||
//printf("link: %s\n",lien);
|
||||
// supprimer les espaces
|
||||
while((lien[strlen(lien) - 1] == ' ') && (strnotempty(lien)))
|
||||
@@ -1941,13 +1940,13 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
if (!q)
|
||||
q = a + strlen(a) - 1;
|
||||
while((p = strstr(a, "//")) && (!done)) { // remplacer // par /
|
||||
if ((int) p > (int) q) { // après le ? (toto.cgi?param=1//2.3)
|
||||
if (p > q) { // après le ? (toto.cgi?param=1//2.3)
|
||||
done = 1; // stopper
|
||||
} else {
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
|
||||
tempo[0] = '\0';
|
||||
strncatbuff(tempo, a, (int) p - (int) a);
|
||||
strncatbuff(tempo, a, p - a);
|
||||
strcatbuff(tempo, p + 1);
|
||||
strcpybuff(a, tempo); // recopier
|
||||
}
|
||||
@@ -2019,7 +2018,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
// and not already UTF-8
|
||||
// (note: not for the query string!)
|
||||
if (hasCharset && !hts_isCharsetUTF8(charset)) {
|
||||
char *const s = hts_convertStringToUTF8(lien, (int) strlen(lien), charset);
|
||||
char *const s = hts_convertStringToUTF8(lien, strlen(lien), charset);
|
||||
if (s != NULL) {
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"engine: save-name: '%s' charset conversion from '%s' to '%s'",
|
||||
@@ -2092,7 +2091,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
char *a = lien + strlen(lien) - 1;
|
||||
|
||||
// éviter aussi index~1.html
|
||||
while(((int) a > (int) lien) && (*a != '~') && (*a != '/')
|
||||
while(a > lien && (*a != '~') && (*a != '/')
|
||||
&& (*a != '.'))
|
||||
a--;
|
||||
if (*a == '~') {
|
||||
@@ -2151,7 +2150,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
|
||||
tempo[0] = '\0';
|
||||
strncatbuff(tempo, lien, (int) (a - lien));
|
||||
strncatbuff(tempo, lien, a - lien);
|
||||
strcatbuff(tempo, a + 3); // sauter :80
|
||||
strcpybuff(lien, tempo);
|
||||
}
|
||||
@@ -2203,8 +2202,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
}
|
||||
|
||||
/* only one ending / (bug on some pages) */
|
||||
if ((int) strlen(lien) > 2) {
|
||||
int len = (int) strlen(lien);
|
||||
if (strlen(lien) > 2) {
|
||||
size_t len = strlen(lien);
|
||||
|
||||
while(len > 1 && lien[len - 1] == '/' && lien[len - 2] == '/') /* double // (bug) */
|
||||
lien[--len] = '\0';
|
||||
@@ -2296,8 +2295,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
if (strnotempty(_base)) { // considérer base
|
||||
if (!link_has_authority(lien)) { // non absolue
|
||||
if (*lien != '/') { // non absolu sur le site (/)
|
||||
if (((int) strlen(_base) + (int) strlen(lien)) <
|
||||
HTS_URLMAXSIZE) {
|
||||
if ((strlen(_base) + strlen(lien)) < HTS_URLMAXSIZE) {
|
||||
// mailto: and co: do NOT add base
|
||||
if (ident_url_relatif
|
||||
(lien, urladr(), urlfil(), &afs.af) >= 0) {
|
||||
@@ -2323,8 +2321,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
} else {
|
||||
lien_adrfil baseaf;
|
||||
if (ident_url_absolute(_base, &baseaf) >= 0) {
|
||||
if (((int) strlen(baseaf.adr) + (int) strlen(lien)) <
|
||||
HTS_URLMAXSIZE) {
|
||||
if ((strlen(baseaf.adr) + strlen(lien)) < HTS_URLMAXSIZE) {
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
|
||||
// base est absolue
|
||||
@@ -2415,8 +2412,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
}
|
||||
// calculer meme_adresse
|
||||
meme_adresse =
|
||||
strfield2(jump_identification(afs.af.adr),
|
||||
jump_identification(urladr()));
|
||||
strfield2(jump_identification_const(afs.af.adr),
|
||||
jump_identification_const(urladr()));
|
||||
|
||||
// Début partie sauvegarde
|
||||
|
||||
@@ -2453,8 +2450,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
url_savename(&afs, &former, heap(ptr)->adr, heap(ptr)->fil, opt,
|
||||
sback, cache, hash, ptr,
|
||||
numero_passe, NULL);
|
||||
if (strcmp(jump_identification(last_adr),
|
||||
jump_identification(afs.af.adr)) != 0) { // a changé
|
||||
if (strcmp(jump_identification_const(last_adr),
|
||||
jump_identification_const(afs.af.adr)) != 0) { // a changé
|
||||
|
||||
// 2e test si moved
|
||||
|
||||
@@ -2559,9 +2556,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
}
|
||||
|
||||
if (!opt->passprivacy) {
|
||||
HT_ADD_HTMLESCAPED(jump_protocol(afs.af.adr)); // Password
|
||||
HT_ADD_HTMLESCAPED(jump_protocol_const(afs.af.adr)); // Password
|
||||
} else {
|
||||
HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password
|
||||
HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password
|
||||
}
|
||||
if (afs.af.fil[0] != '/')
|
||||
HT_ADD("/");
|
||||
@@ -2582,7 +2579,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
if (!opt->passprivacy) {
|
||||
HT_ADD_HTMLESCAPED(afs.af.adr); // Password
|
||||
} else {
|
||||
HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password
|
||||
HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password
|
||||
}
|
||||
if (afs.af.fil[0] != '/')
|
||||
HT_ADD("/");
|
||||
@@ -2598,9 +2595,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
HT_ADD(tmp); // Protocol
|
||||
HT_ADD("//");
|
||||
if (!opt->passprivacy) {
|
||||
HT_ADD_HTMLESCAPED(jump_protocol(afs.af.adr)); // Password
|
||||
HT_ADD_HTMLESCAPED(jump_protocol_const(afs.af.adr)); // Password
|
||||
} else {
|
||||
HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password
|
||||
HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password
|
||||
}
|
||||
if (afs.af.fil[0] != '/')
|
||||
HT_ADD("/");
|
||||
@@ -2635,15 +2632,15 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
default: // inconnu
|
||||
// asp, cgi..
|
||||
if ((strfield2
|
||||
(afs.af.fil + max(0, (int) strlen(afs.af.fil) - 4),
|
||||
(afs.af.fil + max(0, strlen(afs.af.fil) - 4),
|
||||
".gif"))
|
||||
||
|
||||
(strfield2
|
||||
(afs.af.fil + max(0, (int) strlen(afs.af.fil) - 4),
|
||||
(afs.af.fil + max(0, strlen(afs.af.fil) - 4),
|
||||
".jpg"))
|
||||
||
|
||||
(strfield2
|
||||
(afs.af.fil + max(0, (int) strlen(afs.af.fil) - 4),
|
||||
(afs.af.fil + max(0, strlen(afs.af.fil) - 4),
|
||||
".xbm"))
|
||||
/*|| (ishtml(opt,fil)!=0) */
|
||||
) {
|
||||
@@ -2688,7 +2685,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
if (!opt->passprivacy) {
|
||||
HT_ADD_HTMLESCAPED(afs.af.adr); // Password
|
||||
} else {
|
||||
HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password
|
||||
HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password
|
||||
}
|
||||
if (afs.af.fil[0] != '/')
|
||||
HT_ADD("/");
|
||||
@@ -2703,9 +2700,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
strncatbuff(tmp, afs.af.adr, (aut - afs.af.adr) + 2); // scheme
|
||||
HT_ADD(tmp);
|
||||
if (!opt->passprivacy) {
|
||||
HT_ADD_HTMLESCAPED(jump_protocol(afs.af.adr)); // Password
|
||||
HT_ADD_HTMLESCAPED(jump_protocol_const(afs.af.adr)); // Password
|
||||
} else {
|
||||
HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password
|
||||
HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password
|
||||
}
|
||||
if (afs.af.fil[0] != '/')
|
||||
HT_ADD("/");
|
||||
@@ -2750,7 +2747,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
if (!opt->passprivacy) {
|
||||
HT_ADD_HTMLESCAPED(afs.af.adr); // Password
|
||||
} else {
|
||||
HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password
|
||||
HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password
|
||||
}
|
||||
if (afs.af.fil[0] != '/')
|
||||
HT_ADD("/");
|
||||
@@ -2805,7 +2802,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
if (!opt->passprivacy) {
|
||||
HT_ADD_HTMLESCAPED(afs.af.adr); // Password
|
||||
} else {
|
||||
HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password
|
||||
HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password
|
||||
}
|
||||
if (*tempo_pat != '/')
|
||||
HT_ADD("/");
|
||||
@@ -2813,8 +2810,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
HT_ADD("\" ");
|
||||
}
|
||||
|
||||
strncatbuff(tempo4, lastsaved,
|
||||
(int) (p_flush - lastsaved));
|
||||
strncatbuff(tempo4, lastsaved, p_flush - lastsaved);
|
||||
HT_ADD(tempo4); // refresh code="
|
||||
HT_ADD(tempo);
|
||||
}
|
||||
@@ -2951,7 +2947,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
char BIGSTK tempo2[HTS_URLMAXSIZE * 2];
|
||||
|
||||
strcpybuff(tempo2, a + 1);
|
||||
strncatbuff(tempo_pat, tempo, (int) (a - tempo) + 1); // chemin
|
||||
strncatbuff(tempo_pat, tempo, a - tempo + 1); // chemin
|
||||
strcpybuff(tempo, tempo2); // fichier
|
||||
}
|
||||
}
|
||||
@@ -2968,8 +2964,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
HT_ADD("\" ");
|
||||
}
|
||||
|
||||
strncatbuff(tempo4, lastsaved,
|
||||
(int) (p_flush - lastsaved));
|
||||
strncatbuff(tempo4, lastsaved, p_flush - lastsaved);
|
||||
HT_ADD(tempo4); // refresh code="
|
||||
}
|
||||
}
|
||||
@@ -3252,7 +3247,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
&&(!inscript_tag) /* Not in tag with script inside */
|
||||
) {
|
||||
/* Not at the end */
|
||||
if ((((int) (html - r->adr))) < r->size) {
|
||||
if (html - r->adr < r->size) {
|
||||
/* Not on a starting tag yet */
|
||||
if (*html != '<') {
|
||||
/* strchr does not well behave with null chrs.. */
|
||||
@@ -3264,8 +3259,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) {
|
||||
}
|
||||
/* Jump to near end (index hack) */
|
||||
if (!adr_next || *adr_next != '<') {
|
||||
if (((int) (html - r->adr) < (r->size - 4))
|
||||
&& (r->size > 4)
|
||||
if (html - r->adr < r->size - 4
|
||||
&& r->size > 4
|
||||
) {
|
||||
html = r->adr + r->size - 2;
|
||||
}
|
||||
@@ -3633,7 +3628,7 @@ int hts_mirror_check_moved(htsmoduleStruct * str,
|
||||
if (opt->hostcontrol) { // timeout et retry épuisés
|
||||
if ((opt->hostcontrol & 1) && (heap(ptr)->retry <= 0)) {
|
||||
hts_log_print(opt, LOG_DEBUG, "Link banned: %s%s", urladr(), urlfil());
|
||||
host_ban(opt, ptr, sback, jump_identification(urladr()));
|
||||
host_ban(opt, ptr, sback, jump_identification_const(urladr()));
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"Info: previous log - link banned: %s%s", urladr(),
|
||||
urlfil());
|
||||
@@ -3646,7 +3641,7 @@ int hts_mirror_check_moved(htsmoduleStruct * str,
|
||||
if ((opt->hostcontrol) && (heap(ptr)->retry <= 0)) { // too slow
|
||||
if (opt->hostcontrol & 2) {
|
||||
hts_log_print(opt, LOG_DEBUG, "Link banned: %s%s", urladr(), urlfil());
|
||||
host_ban(opt, ptr, sback, jump_identification(urladr()));
|
||||
host_ban(opt, ptr, sback, jump_identification_const(urladr()));
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"Info: previous log - link banned: %s%s", urladr(),
|
||||
urlfil());
|
||||
@@ -4611,7 +4606,7 @@ int hts_wait_delayed(htsmoduleStruct * str, lien_adrfilsave *afs,
|
||||
b = -1;
|
||||
|
||||
/* Handle redirect */
|
||||
if ((int) strnotempty(mov_url)) { // location existe!
|
||||
if (strnotempty(mov_url)) { // location existe!
|
||||
lien_adrfil moved;
|
||||
moved.adr[0] = moved.fil[0] = '\0';
|
||||
//
|
||||
|
||||
@@ -60,7 +60,7 @@ int checkrobots(robots_wizard * robots, const char *adr, const char *fil) {
|
||||
return -1; // interdit
|
||||
}
|
||||
} else { // relatif
|
||||
if (strstrcase((char*) fil, line)) {
|
||||
if (strstrcase(fil, line)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ Please visit our Website: http://www.httrack.com
|
||||
* Emergency logging.
|
||||
* Default is to use libhttrack one.
|
||||
*/
|
||||
#ifndef HTSSAFE_ABORT_FUNCTION
|
||||
#if (!defined(HTSSAFE_ABORT_FUNCTION) && defined(LIBHTTRACK_EXPORTS))
|
||||
|
||||
/** Assert error callback. **/
|
||||
#ifndef HTS_DEF_FWSTRUCT_htsErrorCallback
|
||||
@@ -93,7 +93,9 @@ static HTS_UNUSED void log_abort_(const char *msg, const char *file, int line) {
|
||||
}
|
||||
|
||||
static HTS_UNUSED void abortf_(const char *exp, const char *file, int line) {
|
||||
#ifdef HTSSAFE_ABORT_FUNCTION
|
||||
HTSSAFE_ABORT_FUNCTION(exp, file, line);
|
||||
#endif
|
||||
log_abort_(exp, file, line);
|
||||
abort();
|
||||
}
|
||||
@@ -128,11 +130,23 @@ static HTS_UNUSED void htssafe_compile_time_check_(void) {
|
||||
*/
|
||||
#define strncatbuff(A, B, N) \
|
||||
( HTS_IS_NOT_CHAR_BUFFER(A) \
|
||||
? strncat(A, B, N) \
|
||||
? ( (N) != (size_t) -1 ? strncat(A, B, N) : strcat(A, B) ) \
|
||||
: strncat_safe_(A, sizeof(A), B, \
|
||||
HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(B), N, \
|
||||
"overflow while appending '" #B "' to '"#A"'", __FILE__, __LINE__) )
|
||||
|
||||
/**
|
||||
* Append characters of "B" to "A".
|
||||
* If "A" is a char[] variable whose size is not sizeof(char*), then the size
|
||||
* is assumed to be the capacity of this array.
|
||||
*/
|
||||
#define strcatbuff(A, B) \
|
||||
( HTS_IS_NOT_CHAR_BUFFER(A) \
|
||||
? strcat(A, B) \
|
||||
: strncat_safe_(A, sizeof(A), B, \
|
||||
HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(B), (size_t) -1, \
|
||||
"overflow while appending '" #B "' to '"#A"'", __FILE__, __LINE__) )
|
||||
|
||||
/**
|
||||
* Copy characters from "B" to "A".
|
||||
* If "A" is a char[] variable whose size is not sizeof(char*), then the size
|
||||
@@ -145,15 +159,6 @@ static HTS_UNUSED void htssafe_compile_time_check_(void) {
|
||||
HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(B), \
|
||||
"overflow while copying '" #B "' to '"#A"'", __FILE__, __LINE__) )
|
||||
|
||||
/* note: "size_t is an unsigned integral type" */
|
||||
|
||||
/**
|
||||
* Append characters of "B" to "A".
|
||||
* If "A" is a char[] variable whose size is not sizeof(char*), then the size
|
||||
* is assumed to be the capacity of this array.
|
||||
*/
|
||||
#define strcatbuff(A, B) strncatbuff(A, B, (size_t) -1)
|
||||
|
||||
/**
|
||||
* Append characters of "B" to "A", "A" having a maximum capacity of "S".
|
||||
*/
|
||||
@@ -186,6 +191,7 @@ static HTS_INLINE HTS_UNUSED char* strncat_safe_(char *const dest, const size_t
|
||||
const char *exp, const char *file, int line) {
|
||||
const size_t source_len = strlen_safe_(source, sizeof_source, file, line);
|
||||
const size_t dest_len = strlen_safe_(dest, sizeof_dest, file, line);
|
||||
/* note: "size_t is an unsigned integral type" ((size_t) -1 is positive) */
|
||||
const size_t source_copy = source_len <= n ? source_len : n;
|
||||
const size_t dest_final_len = dest_len + source_copy;
|
||||
assertf__(dest_final_len < sizeof_dest, exp, file, line);
|
||||
|
||||
152
src/htsserver.c
152
src/htsserver.c
@@ -67,15 +67,15 @@ Please visit our Website: http://www.httrack.com
|
||||
|
||||
/* Bypass internal definition protection */
|
||||
#define HTS_INTERNAL_BYTECODE
|
||||
#include "htsinthash.h"
|
||||
#include "coucal.h"
|
||||
#undef HTS_INTERNAL_BYTECODE
|
||||
|
||||
int NewLangStrSz = 1024;
|
||||
inthash NewLangStr = NULL;
|
||||
coucal NewLangStr = NULL;
|
||||
int NewLangStrKeysSz = 1024;
|
||||
inthash NewLangStrKeys = NULL;
|
||||
coucal NewLangStrKeys = NULL;
|
||||
int NewLangListSz = 1024;
|
||||
inthash NewLangList = NULL;
|
||||
coucal NewLangList = NULL;
|
||||
|
||||
/* Language files */
|
||||
|
||||
@@ -296,7 +296,7 @@ typedef struct {
|
||||
} initStrElt;
|
||||
|
||||
#define SET_ERROR(err) do { \
|
||||
inthash_write(NewLangList, "error", (intptr_t)strdup(err)); \
|
||||
coucal_write(NewLangList, "error", (intptr_t)strdup(err)); \
|
||||
error_redirect = "/server/error.html"; \
|
||||
} while(0)
|
||||
|
||||
@@ -359,18 +359,18 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
char tmp[32];
|
||||
|
||||
sprintf(tmp, "%d", initInt[i].value);
|
||||
inthash_write(NewLangList, initInt[i].name, (intptr_t) strdup(tmp));
|
||||
coucal_write(NewLangList, initInt[i].name, (intptr_t) strdup(tmp));
|
||||
}
|
||||
for(i = 0; initOn[i]; i++) {
|
||||
inthash_write(NewLangList, initOn[i], (intptr_t) strdup("1")); /* "on" */
|
||||
coucal_write(NewLangList, initOn[i], (intptr_t) strdup("1")); /* "on" */
|
||||
}
|
||||
for(i = 0; initStr[i].name; i++) {
|
||||
inthash_write(NewLangList, initStr[i].name,
|
||||
coucal_write(NewLangList, initStr[i].name,
|
||||
(intptr_t) strdup(initStr[i].value));
|
||||
}
|
||||
strcpybuff(pth, gethomedir());
|
||||
strcatbuff(pth, "/websites");
|
||||
inthash_write(NewLangList, "path", (intptr_t) strdup(pth));
|
||||
coucal_write(NewLangList, "path", (intptr_t) strdup(pth));
|
||||
}
|
||||
|
||||
/* Lock */
|
||||
@@ -468,15 +468,15 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
char tmp[32];
|
||||
|
||||
sprintf(tmp, "%d", commandReturn);
|
||||
inthash_write(NewLangList, "commandReturn", (intptr_t) strdup(tmp));
|
||||
inthash_write(NewLangList, "commandReturnMsg",
|
||||
coucal_write(NewLangList, "commandReturn", (intptr_t) strdup(tmp));
|
||||
coucal_write(NewLangList, "commandReturnMsg",
|
||||
(intptr_t) commandReturnMsg);
|
||||
inthash_write(NewLangList, "commandReturnCmdl",
|
||||
coucal_write(NewLangList, "commandReturnCmdl",
|
||||
(intptr_t) commandReturnCmdl);
|
||||
} else {
|
||||
inthash_write(NewLangList, "commandReturn", (intptr_t) NULL);
|
||||
inthash_write(NewLangList, "commandReturnMsg", (intptr_t) NULL);
|
||||
inthash_write(NewLangList, "commandReturnCmdl", (intptr_t) NULL);
|
||||
coucal_write(NewLangList, "commandReturn", (intptr_t) NULL);
|
||||
coucal_write(NewLangList, "commandReturnMsg", (intptr_t) NULL);
|
||||
coucal_write(NewLangList, "commandReturnCmdl", (intptr_t) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,8 +484,8 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
{
|
||||
intptr_t adr = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, "_sid", &adr)) {
|
||||
if (inthash_write
|
||||
if (coucal_readptr(NewLangList, "_sid", &adr)) {
|
||||
if (coucal_write
|
||||
(NewLangList, "sid", (intptr_t) strdup((char *) adr))) {
|
||||
}
|
||||
}
|
||||
@@ -506,7 +506,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
if (strfield2(ua, "on")) /* hack : "on" == 1 */
|
||||
ua = "1";
|
||||
unescapehttp(ua, &sua);
|
||||
inthash_write(NewLangList, s, (intptr_t) StringAcquire(&sua));
|
||||
coucal_write(NewLangList, s, (intptr_t) StringAcquire(&sua));
|
||||
s = f + 1;
|
||||
}
|
||||
}
|
||||
@@ -516,8 +516,8 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
intptr_t adr = 0;
|
||||
intptr_t adr2 = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, "sid", &adr)) {
|
||||
if (inthash_readptr(NewLangList, "_sid", &adr2)) {
|
||||
if (coucal_readptr(NewLangList, "sid", &adr)) {
|
||||
if (coucal_readptr(NewLangList, "_sid", &adr2)) {
|
||||
if (strcmp((char *) adr, (char *) adr2) != 0) {
|
||||
meth = 0;
|
||||
}
|
||||
@@ -530,40 +530,40 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
int doLoad = 0;
|
||||
intptr_t adr = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, "lang", &adr)) {
|
||||
if (coucal_readptr(NewLangList, "lang", &adr)) {
|
||||
int n = 0;
|
||||
|
||||
if (sscanf((char *) adr, "%d", &n) == 1 && n > 0
|
||||
&& n - 1 != LANG_T(path, -1)) {
|
||||
LANG_T(path, n - 1);
|
||||
/* make a backup, because the GUI will override it */
|
||||
inthash_write(NewLangList, "lang_",
|
||||
coucal_write(NewLangList, "lang_",
|
||||
(intptr_t) strdup((char *) adr));
|
||||
}
|
||||
}
|
||||
|
||||
/* Load existing project settings */
|
||||
if (inthash_readptr(NewLangList, "loadprojname", &adr)) {
|
||||
if (coucal_readptr(NewLangList, "loadprojname", &adr)) {
|
||||
char *pname = (char *) adr;
|
||||
|
||||
if (*pname) {
|
||||
inthash_write(NewLangList, "projname", (intptr_t) strdup(pname));
|
||||
coucal_write(NewLangList, "projname", (intptr_t) strdup(pname));
|
||||
}
|
||||
inthash_write(NewLangList, "loadprojname", (intptr_t) NULL);
|
||||
coucal_write(NewLangList, "loadprojname", (intptr_t) NULL);
|
||||
doLoad = 1;
|
||||
} else if (inthash_readptr(NewLangList, "loadprojcateg", &adr)) {
|
||||
} else if (coucal_readptr(NewLangList, "loadprojcateg", &adr)) {
|
||||
char *pname = (char *) adr;
|
||||
|
||||
if (*pname) {
|
||||
inthash_write(NewLangList, "projcateg", (intptr_t) strdup(pname));
|
||||
coucal_write(NewLangList, "projcateg", (intptr_t) strdup(pname));
|
||||
}
|
||||
inthash_write(NewLangList, "loadprojcateg", (intptr_t) NULL);
|
||||
coucal_write(NewLangList, "loadprojcateg", (intptr_t) NULL);
|
||||
}
|
||||
|
||||
/* intial configuration */
|
||||
{
|
||||
if (!inthash_read(NewLangList, "conf_file_loaded", NULL)) {
|
||||
inthash_write(NewLangList, "conf_file_loaded",
|
||||
if (!coucal_read(NewLangList, "conf_file_loaded", NULL)) {
|
||||
coucal_write(NewLangList, "conf_file_loaded",
|
||||
(intptr_t) strdup("true"));
|
||||
doLoad = 2;
|
||||
}
|
||||
@@ -573,8 +573,8 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
if (!commandRunning) {
|
||||
intptr_t adrpath = 0, adrprojname = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, "path", &adrpath)
|
||||
&& inthash_readptr(NewLangList, "projname", &adrprojname)) {
|
||||
if (coucal_readptr(NewLangList, "path", &adrpath)
|
||||
&& coucal_readptr(NewLangList, "projname", &adrprojname)) {
|
||||
StringClear(fspath);
|
||||
StringCat(fspath, (char *) adrpath);
|
||||
StringCat(fspath, "/");
|
||||
@@ -614,7 +614,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
if (pos[0] == '0' && pos[1] == '\0')
|
||||
*pos = '\0'; /* 0 => empty */
|
||||
unescapeini(pos, &escline);
|
||||
inthash_write(NewLangList, line,
|
||||
coucal_write(NewLangList, line,
|
||||
(intptr_t) StringAcquire(&escline));
|
||||
}
|
||||
}
|
||||
@@ -630,7 +630,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
intptr_t adr = 0;
|
||||
int p = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, "command", &adr)) {
|
||||
if (coucal_readptr(NewLangList, "command", &adr)) {
|
||||
if (strcmp((char *) adr, "cancel") == 0) {
|
||||
if (commandRunning) {
|
||||
if (!commandEndRequested) {
|
||||
@@ -674,15 +674,15 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
if (!commandRunning) {
|
||||
intptr_t adrcd = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, "command_do", &adrcd)) {
|
||||
if (coucal_readptr(NewLangList, "command_do", &adrcd)) {
|
||||
intptr_t adrw = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, "winprofile", &adrw)) {
|
||||
if (coucal_readptr(NewLangList, "winprofile", &adrw)) {
|
||||
|
||||
/* User general profile */
|
||||
intptr_t adruserprofile = 0;
|
||||
|
||||
if (inthash_readptr
|
||||
if (coucal_readptr
|
||||
(NewLangList, "userprofile", &adruserprofile)
|
||||
&& adruserprofile != 0) {
|
||||
int count = (int) strlen((char *) adruserprofile);
|
||||
@@ -774,7 +774,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
} else if (strcmp((char *) adr, "quit") == 0) {
|
||||
willexit = 1;
|
||||
}
|
||||
inthash_write(NewLangList, "command", (intptr_t) NULL);
|
||||
coucal_write(NewLangList, "command", (intptr_t) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -827,7 +827,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
} else {
|
||||
intptr_t adr = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, "projpath", &adr)) {
|
||||
if (coucal_readptr(NewLangList, "projpath", &adr)) {
|
||||
sprintf(fsfile, "%s%s", (char *) adr, file + 9);
|
||||
}
|
||||
}
|
||||
@@ -848,7 +848,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
"Server: httrack small server\r\n" "Content-type: text/plain\r\n";
|
||||
|
||||
/* register current page */
|
||||
inthash_write(NewLangList, "thisfile", (intptr_t) strdup(file));
|
||||
coucal_write(NewLangList, "thisfile", (intptr_t) strdup(file));
|
||||
|
||||
/* Force GET for the last request */
|
||||
if (meth == 2 && willexit) {
|
||||
@@ -863,7 +863,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
intptr_t adr = 0;
|
||||
const char *newfile = file;
|
||||
|
||||
if (inthash_readptr(NewLangList, "redirect", &adr) && adr != 0) {
|
||||
if (coucal_readptr(NewLangList, "redirect", &adr) && adr != 0) {
|
||||
const char *newadr = (char *) adr;
|
||||
|
||||
if (*newadr) {
|
||||
@@ -879,7 +879,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
StringMemcat(headers, tmp, strlen(tmp));
|
||||
}
|
||||
}
|
||||
inthash_write(NewLangList, "redirect", (intptr_t) NULL);
|
||||
coucal_write(NewLangList, "redirect", (intptr_t) NULL);
|
||||
} else if (is_html(file)) {
|
||||
int outputmode = 0;
|
||||
|
||||
@@ -983,14 +983,14 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
} else if (strcmp(name, "if-not-empty") == 0) {
|
||||
intptr_t adr = 0;
|
||||
|
||||
if (!inthash_readptr(NewLangList, pos2, &adr)
|
||||
if (!coucal_readptr(NewLangList, pos2, &adr)
|
||||
|| *((char *) adr) == 0) {
|
||||
outputmode = -1;
|
||||
}
|
||||
} else if (strcmp(name, "if-empty") == 0) {
|
||||
intptr_t adr = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, pos2, &adr)
|
||||
if (coucal_readptr(NewLangList, pos2, &adr)
|
||||
&& *((char *) adr) != 0) {
|
||||
outputmode = -1;
|
||||
}
|
||||
@@ -999,7 +999,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
} else if (strcmp(name, "loadhash") == 0) {
|
||||
intptr_t adr = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, "path", &adr)) {
|
||||
if (coucal_readptr(NewLangList, "path", &adr)) {
|
||||
char *rpath = (char *) adr;
|
||||
|
||||
//find_handle h;
|
||||
@@ -1012,9 +1012,9 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
const char *profiles = hts_getcategories(rpath, 0);
|
||||
const char *categ = hts_getcategories(rpath, 1);
|
||||
|
||||
inthash_write(NewLangList, "winprofile",
|
||||
coucal_write(NewLangList, "winprofile",
|
||||
(intptr_t) profiles);
|
||||
inthash_write(NewLangList, "wincateg",
|
||||
coucal_write(NewLangList, "wincateg",
|
||||
(intptr_t) categ);
|
||||
}
|
||||
}
|
||||
@@ -1026,10 +1026,10 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
intptr_t adr = 0;
|
||||
|
||||
*pos3++ = '\0';
|
||||
if (inthash_readptr(NewLangList, pos2, &adr)) {
|
||||
inthash_write(NewLangList, pos3,
|
||||
if (coucal_readptr(NewLangList, pos2, &adr)) {
|
||||
coucal_write(NewLangList, pos3,
|
||||
(intptr_t) strdup((char *) adr));
|
||||
inthash_write(NewLangList, pos2, (intptr_t) NULL);
|
||||
coucal_write(NewLangList, pos2, (intptr_t) NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1039,10 +1039,10 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
|
||||
if (pos3) {
|
||||
*pos3++ = '\0';
|
||||
inthash_write(NewLangList, pos2,
|
||||
coucal_write(NewLangList, pos2,
|
||||
(intptr_t) strdup(pos3));
|
||||
} else {
|
||||
inthash_write(NewLangList, pos2, (intptr_t) NULL);
|
||||
coucal_write(NewLangList, pos2, (intptr_t) NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1063,7 +1063,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
pos2 = strchr(name, ':');
|
||||
if (pos2 != NULL) {
|
||||
*pos2 = '\0';
|
||||
if (inthash_readptr(NewLangList, name, &adr) || ztest) {
|
||||
if (coucal_readptr(NewLangList, name, &adr) || ztest) {
|
||||
const char *newadr = (char *) adr;
|
||||
|
||||
if (!newadr)
|
||||
@@ -1123,7 +1123,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
|
||||
dname[0] = '\0';
|
||||
strncatbuff(dname, name, n2);
|
||||
if (inthash_readptr(NewLangList, dname, &adr)) {
|
||||
if (coucal_readptr(NewLangList, dname, &adr)) {
|
||||
int n = 0;
|
||||
|
||||
if (sscanf((char *) adr, "%d", &n) == 1) {
|
||||
@@ -1148,7 +1148,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
if (langstr == NULL || *langstr == '\0') {
|
||||
intptr_t adr = 0;
|
||||
|
||||
if (inthash_readptr(NewLangList, name, &adr)) {
|
||||
if (coucal_readptr(NewLangList, name, &adr)) {
|
||||
char *newadr = (char *) adr;
|
||||
|
||||
langstr = newadr;
|
||||
@@ -1411,12 +1411,12 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
|
||||
int htslang_init(void) {
|
||||
if (NewLangList == NULL) {
|
||||
NewLangList = inthash_new(0);
|
||||
inthash_set_name(NewLangList, "NewLangList");
|
||||
NewLangList = coucal_new(0);
|
||||
coucal_set_name(NewLangList, "NewLangList");
|
||||
if (NewLangList == NULL) {
|
||||
abortLog("Error in lang.h: not enough memory");
|
||||
} else {
|
||||
inthash_value_is_malloc(NewLangList, 1);
|
||||
coucal_value_is_malloc(NewLangList, 1);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@@ -1424,26 +1424,26 @@ int htslang_init(void) {
|
||||
|
||||
int htslang_uninit(void) {
|
||||
if (NewLangList != NULL) {
|
||||
inthash_delete(&NewLangList);
|
||||
coucal_delete(&NewLangList);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smallserver_setkey(const char *key, const char *value) {
|
||||
return inthash_write(NewLangList, key, (intptr_t) strdup(value));
|
||||
return coucal_write(NewLangList, key, (intptr_t) strdup(value));
|
||||
}
|
||||
|
||||
int smallserver_setkeyint(const char *key, LLint value) {
|
||||
char tmp[256];
|
||||
|
||||
snprintf(tmp, sizeof(tmp), LLintP, value);
|
||||
return inthash_write(NewLangList, key, (intptr_t) strdup(tmp));
|
||||
return coucal_write(NewLangList, key, (intptr_t) strdup(tmp));
|
||||
}
|
||||
int smallserver_setkeyarr(const char *key, int id, const char *key2, const char *value) {
|
||||
char tmp[256];
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%s%d%s", key, id, key2);
|
||||
return inthash_write(NewLangList, tmp, (intptr_t) strdup(value));
|
||||
return coucal_write(NewLangList, tmp, (intptr_t) strdup(value));
|
||||
}
|
||||
|
||||
static int htslang_load(char *limit_to, const char *path) {
|
||||
@@ -1456,15 +1456,15 @@ static int htslang_load(char *limit_to, const char *path) {
|
||||
//
|
||||
if (!limit_to) {
|
||||
LANG_DELETE();
|
||||
NewLangStr = inthash_new(0);
|
||||
NewLangStrKeys = inthash_new(0);
|
||||
inthash_set_name(NewLangStr, "NewLangStr");
|
||||
inthash_set_name(NewLangStrKeys, "NewLangStrKeys");
|
||||
NewLangStr = coucal_new(0);
|
||||
NewLangStrKeys = coucal_new(0);
|
||||
coucal_set_name(NewLangStr, "NewLangStr");
|
||||
coucal_set_name(NewLangStrKeys, "NewLangStrKeys");
|
||||
if ((NewLangStr == NULL) || (NewLangStrKeys == NULL)) {
|
||||
abortLog("Error in lang.h: not enough memory");
|
||||
} else {
|
||||
inthash_value_is_malloc(NewLangStr, 1);
|
||||
inthash_value_is_malloc(NewLangStrKeys, 1);
|
||||
coucal_value_is_malloc(NewLangStr, 1);
|
||||
coucal_value_is_malloc(NewLangStrKeys, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1502,7 +1502,7 @@ static int htslang_load(char *limit_to, const char *path) {
|
||||
|
||||
if (buff) {
|
||||
strcpybuff(buff, intkey);
|
||||
inthash_add(NewLangStrKeys, key, (intptr_t) buff);
|
||||
coucal_add(NewLangStrKeys, key, (intptr_t) buff);
|
||||
}
|
||||
}
|
||||
} // if
|
||||
@@ -1599,7 +1599,7 @@ static int htslang_load(char *limit_to, const char *path) {
|
||||
char *const buff = (char *) malloc(len + 1);
|
||||
if (buff) {
|
||||
conv_printf(value, buff);
|
||||
inthash_add(NewLangStr, intkey, (intptr_t) buff);
|
||||
coucal_add(NewLangStr, intkey, (intptr_t) buff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1690,8 +1690,8 @@ static void conv_printf(const char *from, char *to) {
|
||||
}
|
||||
|
||||
static void LANG_DELETE(void) {
|
||||
inthash_delete(&NewLangStr);
|
||||
inthash_delete(&NewLangStrKeys);
|
||||
coucal_delete(&NewLangStr);
|
||||
coucal_delete(&NewLangStrKeys);
|
||||
}
|
||||
|
||||
// sélection de la langue
|
||||
@@ -1761,9 +1761,9 @@ static int QLANG_T(int l) {
|
||||
}
|
||||
|
||||
const char* LANGSEL(const char* name) {
|
||||
inthash_value value;
|
||||
coucal_value value;
|
||||
if (NewLangStr != NULL
|
||||
&& inthash_read_value(NewLangStr, name, &value) != 0
|
||||
&& coucal_read_value(NewLangStr, name, &value) != 0
|
||||
&& value.ptr != NULL) {
|
||||
return (char*) value.ptr;
|
||||
} else {
|
||||
@@ -1772,9 +1772,9 @@ const char* LANGSEL(const char* name) {
|
||||
}
|
||||
|
||||
const char* LANGINTKEY(const char* name) {
|
||||
inthash_value value;
|
||||
coucal_value value;
|
||||
if (NewLangStrKeys != NULL
|
||||
&& inthash_read_value(NewLangStrKeys, name, &value) != 0
|
||||
&& coucal_read_value(NewLangStrKeys, name, &value) != 0
|
||||
&& value.ptr != NULL) {
|
||||
return (char*) value.ptr;
|
||||
} else {
|
||||
|
||||
@@ -71,11 +71,11 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path);
|
||||
"\r\n"\
|
||||
|
||||
extern int NewLangStrSz;
|
||||
extern inthash NewLangStr;
|
||||
extern coucal NewLangStr;
|
||||
extern int NewLangStrKeysSz;
|
||||
extern inthash NewLangStrKeys;
|
||||
extern coucal NewLangStrKeys;
|
||||
extern int NewLangListSz;
|
||||
extern inthash NewLangList;
|
||||
extern coucal NewLangList;
|
||||
|
||||
extern httrackp *global_opt;
|
||||
|
||||
|
||||
@@ -194,15 +194,15 @@ int ident_url_relatif(const char *lien, const char *origin_adr,
|
||||
/* patch scheme if necessary */
|
||||
if (strfield(lien, "http:")) {
|
||||
lien += 5;
|
||||
strcpybuff(adrfil->adr, jump_protocol(origin_adr)); // même adresse ; protocole vide (http)
|
||||
strcpybuff(adrfil->adr, jump_protocol_const(origin_adr)); // même adresse ; protocole vide (http)
|
||||
} else if (strfield(lien, "https:")) {
|
||||
lien += 6;
|
||||
strcpybuff(adrfil->adr, "https://"); // même adresse forcée en https
|
||||
strcatbuff(adrfil->adr, jump_protocol(origin_adr));
|
||||
strcatbuff(adrfil->adr, jump_protocol_const(origin_adr));
|
||||
} else if (strfield(lien, "ftp:")) {
|
||||
lien += 4;
|
||||
strcpybuff(adrfil->adr, "ftp://"); // même adresse forcée en ftp
|
||||
strcatbuff(adrfil->adr, jump_protocol(origin_adr));
|
||||
strcatbuff(adrfil->adr, jump_protocol_const(origin_adr));
|
||||
} else {
|
||||
strcpybuff(adrfil->adr, origin_adr); // même adresse ; et même éventuel protocole
|
||||
}
|
||||
@@ -395,7 +395,7 @@ int link_has_authority(const char *lien) {
|
||||
}
|
||||
|
||||
int link_has_authorization(const char *lien) {
|
||||
const char *adr = jump_protocol(lien);
|
||||
const char *adr = jump_protocol_const(lien);
|
||||
const char *firstslash = strchr(adr, '/');
|
||||
const char *detect = strchr(adr, '@');
|
||||
|
||||
@@ -415,14 +415,15 @@ void long_to_83(int mode, char *n83, char *save) {
|
||||
|
||||
while(*save) {
|
||||
char fn83[256], fnl[256];
|
||||
int i = 0;
|
||||
size_t i, j;
|
||||
|
||||
fn83[0] = fnl[0] = '\0';
|
||||
while((save[i]) && (save[i] != '/')) {
|
||||
fnl[i] = save[i];
|
||||
i++;
|
||||
for(i = j = 0 ; save[i] && save[i] != '/' ; i++) {
|
||||
if (j + 1 < sizeof(fnl)) {
|
||||
fnl[j++] = save[i];
|
||||
}
|
||||
}
|
||||
fnl[i] = '\0';
|
||||
fnl[j] = '\0';
|
||||
// conversion
|
||||
longfile_to_83(mode, fn83, fnl);
|
||||
strcatbuff(n83, fn83);
|
||||
@@ -535,21 +536,20 @@ void longfile_to_83(int mode, char *n83, char *save) {
|
||||
// écrire backblue.gif
|
||||
/* Note: utf-8 */
|
||||
int verif_backblue(httrackp * opt, const char *base) {
|
||||
int *done = &opt->state.verif_backblue_done;
|
||||
int ret = 0;
|
||||
|
||||
//
|
||||
if (!base) { // init
|
||||
*done = 0;
|
||||
opt->state.verif_backblue_done = 0;
|
||||
return 0;
|
||||
}
|
||||
if ((!*done)
|
||||
if ((!opt->state.verif_backblue_done)
|
||||
|| (fsize_utf8(fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), base, "backblue.gif")) !=
|
||||
HTS_DATA_BACK_GIF_LEN)) {
|
||||
FILE *fp =
|
||||
filecreate(&opt->state.strc,
|
||||
fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), base, "backblue.gif"));
|
||||
*done = 1;
|
||||
opt->state.verif_backblue_done = 1;
|
||||
if (fp) {
|
||||
if (fwrite(HTS_DATA_BACK_GIF, HTS_DATA_BACK_GIF_LEN, 1, fp) !=
|
||||
HTS_DATA_BACK_GIF_LEN)
|
||||
@@ -578,12 +578,12 @@ int verif_backblue(httrackp * opt, const char *base) {
|
||||
|
||||
// flag
|
||||
int verif_external(httrackp * opt, int nb, int test) {
|
||||
int *status = &opt->state.verif_external_status;
|
||||
|
||||
const int flag = 1 << nb;
|
||||
int *const status = &opt->state.verif_external_status;
|
||||
if (!test)
|
||||
status[nb] = 0; // reset
|
||||
else if (!status[nb]) {
|
||||
status[nb] = 1;
|
||||
*status &= ~flag; // reset
|
||||
else if ((*status & flag) == 0) {
|
||||
*status |= flag;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -748,8 +748,8 @@ int istoobig(httrackp * opt, LLint size, LLint maxhtml, LLint maxnhtml,
|
||||
|
||||
static int sortTopIndexFnc(const void *a_, const void *b_) {
|
||||
int cmp;
|
||||
topindex_chain **a = (topindex_chain **) a_;
|
||||
topindex_chain **b = (topindex_chain **) b_;
|
||||
const topindex_chain *const*const a = (const topindex_chain *const*) a_;
|
||||
const topindex_chain *const*const b = (const topindex_chain *const*) b_;
|
||||
|
||||
/* Category first, then name */
|
||||
if ((cmp = (*a)->level - (*b)->level) == 0) {
|
||||
@@ -1079,7 +1079,7 @@ HTSEXT_API char *hts_getcategories(char *path, int type) {
|
||||
String profiles = STRING_EMPTY;
|
||||
char *rpath = path;
|
||||
find_handle h;
|
||||
inthash hashCateg = NULL;
|
||||
coucal hashCateg = NULL;
|
||||
|
||||
if (rpath[0]) {
|
||||
if (rpath[strlen(rpath) - 1] == '/') {
|
||||
@@ -1091,8 +1091,8 @@ HTSEXT_API char *hts_getcategories(char *path, int type) {
|
||||
String iname = STRING_EMPTY;
|
||||
|
||||
if (type == 1) {
|
||||
hashCateg = inthash_new(0);
|
||||
inthash_set_name(hashCateg, "hashCateg");
|
||||
hashCateg = coucal_new(0);
|
||||
coucal_set_name(hashCateg, "hashCateg");
|
||||
StringCat(categ, "Test category 1");
|
||||
StringCat(categ, "\r\nTest category 2");
|
||||
}
|
||||
@@ -1117,8 +1117,8 @@ HTSEXT_API char *hts_getcategories(char *path, int type) {
|
||||
if (n > 0) {
|
||||
if (strfield(line2, "category=")) {
|
||||
if (*(line2 + 9)) {
|
||||
if (!inthash_read(hashCateg, line2 + 9, NULL)) {
|
||||
inthash_write(hashCateg, line2 + 9, 0);
|
||||
if (!coucal_read(hashCateg, line2 + 9, NULL)) {
|
||||
coucal_write(hashCateg, line2 + 9, 0);
|
||||
if (StringLength(categ) > 0) {
|
||||
StringCat(categ, "\r\n");
|
||||
}
|
||||
@@ -1146,7 +1146,7 @@ HTSEXT_API char *hts_getcategories(char *path, int type) {
|
||||
StringFree(iname);
|
||||
}
|
||||
if (hashCateg) {
|
||||
inthash_delete(&hashCateg);
|
||||
coucal_delete(&hashCateg);
|
||||
hashCateg = NULL;
|
||||
}
|
||||
if (type == 1)
|
||||
|
||||
@@ -58,7 +58,7 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htsthread.h"
|
||||
|
||||
/* External modules */
|
||||
#include "htsinthash.c"
|
||||
#include "coucal.c"
|
||||
#include "htsmd5.c"
|
||||
#include "md5.c"
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
question = 0; // pas de question, résolu
|
||||
|
||||
// former URL complète du lien actuel
|
||||
strcpybuff(l, jump_identification(adr));
|
||||
strcpybuff(l, jump_identification_const(adr));
|
||||
if (*fil != '/')
|
||||
strcatbuff(l, "/");
|
||||
strcatbuff(l, fil);
|
||||
@@ -711,7 +711,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
forbidden_url = 1;
|
||||
HT_INSERT_FILTERS0; // insérer en 0
|
||||
strcpybuff(_FILTERS[0], "-");
|
||||
strcatbuff(_FILTERS[0], jump_identification(adr));
|
||||
strcatbuff(_FILTERS[0], jump_identification_const(adr));
|
||||
if (*fil != '/')
|
||||
strcatbuff(_FILTERS[0], "/");
|
||||
strcatbuff(_FILTERS[0], fil);
|
||||
@@ -727,7 +727,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
if (fil[i] == '/') {
|
||||
HT_INSERT_FILTERS0; // insérer en 0
|
||||
strcpybuff(_FILTERS[0], "-");
|
||||
strcatbuff(_FILTERS[0], jump_identification(adr));
|
||||
strcatbuff(_FILTERS[0], jump_identification_const(adr));
|
||||
if (*fil != '/')
|
||||
strcatbuff(_FILTERS[0], "/");
|
||||
strncatbuff(_FILTERS[0], fil, i);
|
||||
@@ -744,7 +744,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
forbidden_url = 1;
|
||||
HT_INSERT_FILTERS0; // insérer en 0
|
||||
strcpybuff(_FILTERS[0], "-");
|
||||
strcatbuff(_FILTERS[0], jump_identification(adr));
|
||||
strcatbuff(_FILTERS[0], jump_identification_const(adr));
|
||||
strcatbuff(_FILTERS[0], "*");
|
||||
break;
|
||||
|
||||
@@ -786,7 +786,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
if (fil[i] == '/') {
|
||||
HT_INSERT_FILTERS0; // insérer en 0
|
||||
strcpybuff(_FILTERS[0], "+");
|
||||
strcatbuff(_FILTERS[0], jump_identification(adr));
|
||||
strcatbuff(_FILTERS[0], jump_identification_const(adr));
|
||||
if (*fil != '/')
|
||||
strcatbuff(_FILTERS[0], "/");
|
||||
strncatbuff(_FILTERS[0], fil, i + 1);
|
||||
@@ -795,7 +795,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
} else { // autoriser domaine alors!!
|
||||
HT_INSERT_FILTERS0; // insérer en 0 strcpybuff(filters[filptr],"+");
|
||||
strcpybuff(_FILTERS[0], "+");
|
||||
strcatbuff(_FILTERS[0], jump_identification(adr));
|
||||
strcatbuff(_FILTERS[0], jump_identification_const(adr));
|
||||
strcatbuff(_FILTERS[0], "*");
|
||||
}
|
||||
break;
|
||||
@@ -803,7 +803,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
case 6: // same domain
|
||||
HT_INSERT_FILTERS0; // insérer en 0 strcpybuff(filters[filptr],"+");
|
||||
strcpybuff(_FILTERS[0], "+");
|
||||
strcatbuff(_FILTERS[0], jump_identification(adr));
|
||||
strcatbuff(_FILTERS[0], jump_identification_const(adr));
|
||||
strcatbuff(_FILTERS[0], "*");
|
||||
break;
|
||||
//
|
||||
@@ -816,7 +816,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
if (fil[i] == '/') {
|
||||
HT_INSERT_FILTERS0; // insérer en 0
|
||||
strcpybuff(_FILTERS[0], "+");
|
||||
strcatbuff(_FILTERS[0], jump_identification(adr));
|
||||
strcatbuff(_FILTERS[0], jump_identification_const(adr));
|
||||
if (*fil != '/')
|
||||
strcatbuff(_FILTERS[0], "/");
|
||||
strncatbuff(_FILTERS[0], fil, i + 1);
|
||||
@@ -915,7 +915,7 @@ int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint siz
|
||||
int size_flag = 0;
|
||||
|
||||
// former URL complète du lien actuel
|
||||
strcpybuff(l, jump_identification(adr));
|
||||
strcpybuff(l, jump_identification_const(adr));
|
||||
if (*fil != '/')
|
||||
strcatbuff(l, "/");
|
||||
strcatbuff(l, fil);
|
||||
|
||||
@@ -36,7 +36,7 @@ Please visit our Website: http://www.httrack.com
|
||||
|
||||
#include "htswrap.h"
|
||||
#include "htshash.h"
|
||||
#include "htsinthash.h"
|
||||
#include "coucal.h"
|
||||
#include "htslib.h"
|
||||
|
||||
HTSEXT_API int htswrap_init(void) { // LEGACY
|
||||
|
||||
@@ -38,7 +38,7 @@ Please visit our Website: http://www.httrack.com
|
||||
#ifdef HTS_INTERNAL_BYTECODE
|
||||
|
||||
#include "htsglobal.h"
|
||||
#include "htsinthash.h"
|
||||
#include "coucal.h"
|
||||
|
||||
/* Forward definitions */
|
||||
#ifndef HTS_DEF_FWSTRUCT_httrackp
|
||||
|
||||
@@ -186,6 +186,7 @@ HTSEXT_API void hts_cancel_test(httrackp * opt);
|
||||
HTSEXT_API void hts_cancel_parsing(httrackp * opt);
|
||||
HTSEXT_API void hts_cancel_test(httrackp * opt);
|
||||
HTSEXT_API void hts_cancel_parsing(httrackp * opt);
|
||||
HTSEXT_API int hts_has_stopped(httrackp * opt);
|
||||
|
||||
/* Tools */
|
||||
HTSEXT_API int structcheck(const char *path);
|
||||
@@ -198,9 +199,12 @@ HTSEXT_API char *int2char(strc_int2bytes2 * strc, int n);
|
||||
HTSEXT_API char *int2bytes(strc_int2bytes2 * strc, LLint n);
|
||||
HTSEXT_API char *int2bytessec(strc_int2bytes2 * strc, long int n);
|
||||
HTSEXT_API char **int2bytes2(strc_int2bytes2 * strc, LLint n);
|
||||
HTSEXT_API char *jump_identification(const char *);
|
||||
HTSEXT_API char *jump_normalized(const char *);
|
||||
HTSEXT_API char *jump_toport(const char *);
|
||||
HTSEXT_API char *jump_identification(char *);
|
||||
HTSEXT_API const char *jump_identification_const(const char *);
|
||||
HTSEXT_API char *jump_normalized(char *);
|
||||
HTSEXT_API const char *jump_normalized_const(const char *);
|
||||
HTSEXT_API char *jump_toport(char *);
|
||||
HTSEXT_API const char *jump_toport_const(const char *);
|
||||
HTSEXT_API char *fil_normalized(const char *source, char *dest);
|
||||
HTSEXT_API char *adr_normalized(const char *source, char *dest);
|
||||
HTSEXT_API const char *hts_rootdir(char *file);
|
||||
|
||||
@@ -69,6 +69,9 @@ static int linput(FILE * fp, char *s, int max);
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#ifdef __linux
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
/* END specific definitions */
|
||||
|
||||
static void __cdecl htsshow_init(t_hts_callbackarg * carg);
|
||||
@@ -833,6 +836,7 @@ static void sig_ask(int code) { // demander
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void sig_brpipe(int code) { // treat if necessary
|
||||
signal(code, sig_brpipe);
|
||||
}
|
||||
@@ -870,6 +874,63 @@ static void sig_doback(int blind) { // mettre en backing
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef FD_ERR
|
||||
#define FD_ERR 2
|
||||
|
||||
static void print_backtrace(void) {
|
||||
#ifdef __linux
|
||||
void *stack[256];
|
||||
const int size = backtrace(stack, sizeof(stack)/sizeof(stack[0]));
|
||||
if (size != 0) {
|
||||
backtrace_symbols_fd(stack, size, FD_ERR);
|
||||
}
|
||||
#else
|
||||
const char msg[] = "No stack trace available on this OS :(\n";
|
||||
write(FD_ERR, msg, sizeof(msg) - 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static size_t print_num(char *buffer, int num) {
|
||||
size_t i, j;
|
||||
if (num < 0) {
|
||||
*(buffer++) = '-';
|
||||
num = -num;
|
||||
}
|
||||
for(i = 0 ; num != 0 || i == 0 ; i++, num /= 10) {
|
||||
buffer[i] = '0' + ( num % 10 );
|
||||
}
|
||||
for(j = 0 ; j < i ; j++) {
|
||||
const char c = buffer[i - j - 1];
|
||||
buffer[i - j - 1] = buffer[j];
|
||||
buffer[j] = c;
|
||||
}
|
||||
buffer[i] = '\0';
|
||||
return i;
|
||||
}
|
||||
|
||||
static void sig_fatal(int code) {
|
||||
const char msg[] = "\nCaught signal ";
|
||||
const char msgreport[] =
|
||||
"\nPlease report the problem at http://forum.httrack.com\n";
|
||||
char buffer[256];
|
||||
size_t size;
|
||||
|
||||
signal(code, SIG_DFL);
|
||||
signal(SIGABRT, SIG_DFL);
|
||||
|
||||
memcpy(buffer, msg, sizeof(msg) - 1);
|
||||
size = sizeof(msg) - 1;
|
||||
size += print_num(&buffer[size], code);
|
||||
buffer[size++] = '\n';
|
||||
(void) (write(FD_ERR, buffer, size) == size);
|
||||
print_backtrace();
|
||||
(void) (write(FD_ERR, msgreport, sizeof(msgreport) - 1)
|
||||
== sizeof(msgreport) - 1);
|
||||
abort();
|
||||
}
|
||||
|
||||
#undef FD_ERR
|
||||
|
||||
static void sig_leave(int code) {
|
||||
if (global_opt != NULL && global_opt->state._hts_in_mirror) {
|
||||
signal(code, sig_term); // quitter si encore
|
||||
@@ -906,6 +967,21 @@ static void signal_handlers(void) {
|
||||
signal(SIGPIPE, sig_brpipe); // broken pipe (write into non-opened socket)
|
||||
signal(SIGCHLD, sig_ignore); // child change status
|
||||
#endif
|
||||
#ifdef SIGABRT
|
||||
signal(SIGABRT, sig_fatal); // abort
|
||||
#endif
|
||||
#ifdef SIGBUS
|
||||
signal(SIGBUS, sig_fatal); // bus error
|
||||
#endif
|
||||
#ifdef SIGILL
|
||||
signal(SIGILL, sig_fatal); // illegal instruction
|
||||
#endif
|
||||
#ifdef SIGSEGV
|
||||
signal(SIGSEGV, sig_fatal); // segmentation violation
|
||||
#endif
|
||||
#ifdef SIGSTKFLT
|
||||
signal(SIGSTKFLT, sig_fatal); // stack fault
|
||||
#endif
|
||||
}
|
||||
|
||||
// fin routines de détournement de SIGHUP & co
|
||||
|
||||
@@ -44,6 +44,6 @@ int mdbinfileBroken(char *fn, unsigned char *bindigest);
|
||||
/*
|
||||
* This is needed to make RSAREF happy on some MS-DOS compilers.
|
||||
*/
|
||||
typedef struct MD5Context MD5_CTX;
|
||||
typedef struct MD5Context MD5CTX;
|
||||
|
||||
#endif /* !MD5_H */
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(IOAPI_NO_64)
|
||||
#if defined(__APPLE__) || defined(__ANDROID__) || defined(IOAPI_NO_64)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
@@ -230,8 +230,7 @@ static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fill_fopen_filefunc (pzlib_filefunc_def)
|
||||
zlib_filefunc_def* pzlib_filefunc_def;
|
||||
void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||
{
|
||||
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
--- ioapi.c.orig 2012-01-21 20:58:45.000000000 +0100
|
||||
+++ ioapi.c 2014-05-24 13:27:22.516230485 +0200
|
||||
--- ioapi.c.orig 2014-06-10 18:55:32.778807408 +0200
|
||||
+++ ioapi.c 2014-06-22 12:22:06.606696274 +0200
|
||||
@@ -14,7 +14,7 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
-#if defined(__APPLE__) || defined(IOAPI_NO_64)
|
||||
+#if defined(__APPLE__) || defined(__ANDROID__) || defined(IOAPI_NO_64)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
@@ -73,6 +73,7 @@
|
||||
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
|
||||
@@ -30,7 +39,16 @@
|
||||
|
||||
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
@@ -229,6 +238,7 @@
|
||||
@@ -221,14 +230,14 @@
|
||||
return ret;
|
||||
}
|
||||
|
||||
-void fill_fopen_filefunc (pzlib_filefunc_def)
|
||||
- zlib_filefunc_def* pzlib_filefunc_def;
|
||||
+void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||
{
|
||||
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||
pzlib_filefunc_def->ztell_file = ftell_file_func;
|
||||
pzlib_filefunc_def->zseek_file = fseek_file_func;
|
||||
@@ -38,7 +56,7 @@
|
||||
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
@@ -241,6 +251,7 @@
|
||||
@@ -241,6 +250,7 @@
|
||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||
pzlib_filefunc_def->ztell64_file = ftell64_file_func;
|
||||
pzlib_filefunc_def->zseek64_file = fseek64_file_func;
|
||||
|
||||
247
src/minizip/ioapi.c.orig
Normal file
247
src/minizip/ioapi.c.orig
Normal file
@@ -0,0 +1,247 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Modifications for Zip64 support
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS)))
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(IOAPI_NO_64)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
|
||||
#else
|
||||
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello64(stream)
|
||||
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
|
||||
#endif
|
||||
|
||||
|
||||
#include "ioapi.h"
|
||||
|
||||
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
|
||||
{
|
||||
if (pfilefunc->zfile_func64.zopen64_file != NULL)
|
||||
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
|
||||
else
|
||||
{
|
||||
return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
|
||||
}
|
||||
}
|
||||
|
||||
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
|
||||
{
|
||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
|
||||
else
|
||||
{
|
||||
uLong offsetTruncated = (uLong)offset;
|
||||
if (offsetTruncated != offset)
|
||||
return -1;
|
||||
else
|
||||
return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
|
||||
}
|
||||
}
|
||||
|
||||
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
|
||||
{
|
||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
||||
else
|
||||
{
|
||||
uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||
if ((tell_uLong) == MAXU32)
|
||||
return (ZPOS64_T)-1;
|
||||
else
|
||||
return tell_uLong;
|
||||
}
|
||||
}
|
||||
|
||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
|
||||
{
|
||||
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
|
||||
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
|
||||
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
|
||||
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
|
||||
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
|
||||
p_filefunc64_32->zfile_func64.zseek64_file = NULL;
|
||||
p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
|
||||
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||
p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
|
||||
p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
|
||||
p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
|
||||
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
|
||||
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
|
||||
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
|
||||
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
|
||||
|
||||
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
|
||||
{
|
||||
FILE* file = NULL;
|
||||
const char* mode_fopen = NULL;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = "rb";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
mode_fopen = "r+b";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
mode_fopen = "wb";
|
||||
|
||||
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||
file = fopen(filename, mode_fopen);
|
||||
return file;
|
||||
}
|
||||
|
||||
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
|
||||
{
|
||||
FILE* file = NULL;
|
||||
const char* mode_fopen = NULL;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = "rb";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
mode_fopen = "r+b";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
mode_fopen = "wb";
|
||||
|
||||
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||
file = FOPEN_FUNC((const char*)filename, mode_fopen);
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
||||
{
|
||||
uLong ret;
|
||||
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
|
||||
{
|
||||
uLong ret;
|
||||
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
long ret;
|
||||
ret = ftell((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
ZPOS64_T ret;
|
||||
ret = FTELLO_FUNC((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
|
||||
{
|
||||
int fseek_origin=0;
|
||||
long ret;
|
||||
switch (origin)
|
||||
{
|
||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||
fseek_origin = SEEK_CUR;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_END :
|
||||
fseek_origin = SEEK_END;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_SET :
|
||||
fseek_origin = SEEK_SET;
|
||||
break;
|
||||
default: return -1;
|
||||
}
|
||||
ret = 0;
|
||||
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
|
||||
{
|
||||
int fseek_origin=0;
|
||||
long ret;
|
||||
switch (origin)
|
||||
{
|
||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||
fseek_origin = SEEK_CUR;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_END :
|
||||
fseek_origin = SEEK_END;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_SET :
|
||||
fseek_origin = SEEK_SET;
|
||||
break;
|
||||
default: return -1;
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
|
||||
ret = -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
int ret;
|
||||
ret = fclose((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
int ret;
|
||||
ret = ferror((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fill_fopen_filefunc (pzlib_filefunc_def)
|
||||
zlib_filefunc_def* pzlib_filefunc_def;
|
||||
{
|
||||
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||
pzlib_filefunc_def->ztell_file = ftell_file_func;
|
||||
pzlib_filefunc_def->zseek_file = fseek_file_func;
|
||||
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
|
||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||
pzlib_filefunc_def->ztell64_file = ftell64_file_func;
|
||||
pzlib_filefunc_def->zseek64_file = fseek64_file_func;
|
||||
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
@@ -67,6 +67,24 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* As reported by sammyx, z_crc_t and z_const are not defined in pre-1.2.70 releases of zlib */
|
||||
/* See <https://github.com/madler/zlib/commit/6c9bd474aa08312ef2e2e9655a80e18db24a1680#diff-d466aa66f7e453e0c8a7719229cff391R391> */
|
||||
#if ZLIB_VERNUM < 0x1270
|
||||
|
||||
#ifdef Z_U4
|
||||
typedef Z_U4 z_crc_t;
|
||||
#else
|
||||
typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||
# define z_const const
|
||||
#else
|
||||
# define z_const
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifndef ZPOS64_T
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -1,6 +1,31 @@
|
||||
--- ioapi.h.orig 2012-01-17 03:51:31.000000000 +0100
|
||||
+++ ioapi.h 2014-05-24 13:27:22.516230485 +0200
|
||||
@@ -135,6 +135,7 @@
|
||||
+++ ioapi.h 2014-06-08 21:54:18.326360527 +0200
|
||||
@@ -67,6 +67,24 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+/* As reported by sammyx, z_crc_t and z_const are not defined in pre-1.2.70 releases of zlib */
|
||||
+/* See <https://github.com/madler/zlib/commit/6c9bd474aa08312ef2e2e9655a80e18db24a1680#diff-d466aa66f7e453e0c8a7719229cff391R391> */
|
||||
+#if ZLIB_VERNUM < 0x1270
|
||||
+
|
||||
+#ifdef Z_U4
|
||||
+ typedef Z_U4 z_crc_t;
|
||||
+#else
|
||||
+ typedef unsigned long z_crc_t;
|
||||
+#endif
|
||||
+
|
||||
+#if defined(ZLIB_CONST) && !defined(z_const)
|
||||
+# define z_const const
|
||||
+#else
|
||||
+# define z_const
|
||||
+#endif
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
#ifndef ZPOS64_T
|
||||
#ifdef _WIN32
|
||||
@@ -135,6 +153,7 @@
|
||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
@@ -8,7 +33,7 @@
|
||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
|
||||
@@ -148,6 +149,7 @@
|
||||
@@ -148,6 +167,7 @@
|
||||
open_file_func zopen_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
@@ -16,7 +41,7 @@
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
close_file_func zclose_file;
|
||||
@@ -164,6 +166,7 @@
|
||||
@@ -164,6 +184,7 @@
|
||||
open64_file_func zopen64_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
@@ -24,7 +49,7 @@
|
||||
tell64_file_func ztell64_file;
|
||||
seek64_file_func zseek64_file;
|
||||
close_file_func zclose_file;
|
||||
@@ -186,6 +189,7 @@
|
||||
@@ -186,6 +207,7 @@
|
||||
|
||||
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||
|
||||
208
src/minizip/ioapi.h.orig
Normal file
208
src/minizip/ioapi.h.orig
Normal file
@@ -0,0 +1,208 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Modifications for Zip64 support
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
Changes
|
||||
|
||||
Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
|
||||
Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
|
||||
More if/def section may be needed to support other platforms
|
||||
Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
|
||||
(but you should use iowin32.c for windows instead)
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI64_H
|
||||
#define _ZLIBIOAPI64_H
|
||||
|
||||
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
|
||||
|
||||
// Linux needs this to support file operation on files larger then 4+GB
|
||||
// But might need better if/def to select just the platforms that needs them.
|
||||
|
||||
#ifndef __USE_FILE_OFFSET64
|
||||
#define __USE_FILE_OFFSET64
|
||||
#endif
|
||||
#ifndef __USE_LARGEFILE64
|
||||
#define __USE_LARGEFILE64
|
||||
#endif
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
#ifndef _FILE_OFFSET_BIT
|
||||
#define _FILE_OFFSET_BIT 64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "zlib.h"
|
||||
|
||||
#if defined(USE_FILE32API)
|
||||
#define fopen64 fopen
|
||||
#define ftello64 ftell
|
||||
#define fseeko64 fseek
|
||||
#else
|
||||
#ifdef __FreeBSD__
|
||||
#define fopen64 fopen
|
||||
#define ftello64 ftello
|
||||
#define fseeko64 fseeko
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#define fopen64 fopen
|
||||
#if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
|
||||
#define ftello64 _ftelli64
|
||||
#define fseeko64 _fseeki64
|
||||
#else // old MSC
|
||||
#define ftello64 ftell
|
||||
#define fseeko64 fseek
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifndef ZPOS64_T
|
||||
#ifdef _WIN32
|
||||
#define ZPOS64_T fpos_t
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#define ZPOS64_T uint64_t
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifdef HAVE_MINIZIP64_CONF_H
|
||||
#include "mz64conf.h"
|
||||
#endif
|
||||
|
||||
/* a type choosen by DEFINE */
|
||||
#ifdef HAVE_64BIT_INT_CUSTOM
|
||||
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
||||
#else
|
||||
#ifdef HAS_STDINT_H
|
||||
#include "stdint.h"
|
||||
typedef uint64_t ZPOS64_T;
|
||||
#else
|
||||
|
||||
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||
#define MAXU32 0xffffffff
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 ZPOS64_T;
|
||||
#else
|
||||
typedef unsigned long long int ZPOS64_T;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||
#define ZLIB_FILEFUNC_SEEK_END (2)
|
||||
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_READ (1)
|
||||
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
||||
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
||||
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
||||
|
||||
|
||||
#ifndef ZCALLBACK
|
||||
#if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
|
||||
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
||||
|
||||
|
||||
/* here is the "old" 32 bits structure structure */
|
||||
typedef struct zlib_filefunc_def_s
|
||||
{
|
||||
open_file_func zopen_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
voidpf opaque;
|
||||
} zlib_filefunc_def;
|
||||
|
||||
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
|
||||
|
||||
typedef struct zlib_filefunc64_def_s
|
||||
{
|
||||
open64_file_func zopen64_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell64_file_func ztell64_file;
|
||||
seek64_file_func zseek64_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
voidpf opaque;
|
||||
} zlib_filefunc64_def;
|
||||
|
||||
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
/* now internal definition, only for zip.c and unzip.h */
|
||||
typedef struct zlib_filefunc64_32_def_s
|
||||
{
|
||||
zlib_filefunc64_def zfile_func64;
|
||||
open_file_func zopen32_file;
|
||||
tell_file_func ztell32_file;
|
||||
seek_file_func zseek32_file;
|
||||
} zlib_filefunc64_32_def;
|
||||
|
||||
|
||||
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||
//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
|
||||
//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
|
||||
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||
|
||||
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
|
||||
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
|
||||
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
|
||||
|
||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
|
||||
|
||||
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
|
||||
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
|
||||
#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
66
src/minizip/mztools.c.diff
Normal file
66
src/minizip/mztools.c.diff
Normal file
@@ -0,0 +1,66 @@
|
||||
--- mztools.c.orig 2012-01-21 20:58:45.000000000 +0100
|
||||
+++ mztools.c 2014-05-24 13:27:22.516230485 +0200
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <string.h>
|
||||
#include "zlib.h"
|
||||
#include "unzip.h"
|
||||
+#include "mztools.h"
|
||||
|
||||
#define READ_8(adr) ((unsigned char)*(adr))
|
||||
#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) )
|
||||
@@ -27,12 +28,9 @@
|
||||
WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
|
||||
} while(0)
|
||||
|
||||
-extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
|
||||
-const char* file;
|
||||
-const char* fileOut;
|
||||
-const char* fileOutTmp;
|
||||
-uLong* nRecovered;
|
||||
-uLong* bytesRecovered;
|
||||
+int ZEXPORT unzRepair(const char* file, const char* fileOut,
|
||||
+ const char* fileOutTmp, uLong* nRecovered,
|
||||
+ uLong* bytesRecovered)
|
||||
{
|
||||
int err = Z_OK;
|
||||
FILE* fpZip = fopen(file, "rb");
|
||||
@@ -147,8 +145,8 @@
|
||||
/* Central directory entry */
|
||||
{
|
||||
char header[46];
|
||||
- char* comment = "";
|
||||
- int comsize = (int) strlen(comment);
|
||||
+ const char* comment = "";
|
||||
+ const size_t comsize = strlen(comment);
|
||||
WRITE_32(header, 0x02014b50);
|
||||
WRITE_16(header + 4, version);
|
||||
WRITE_16(header + 6, version);
|
||||
@@ -195,7 +193,7 @@
|
||||
|
||||
/* Comment field */
|
||||
if (comsize > 0) {
|
||||
- if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {
|
||||
+ if (fwrite(comment, 1, comsize, fpOutCD) == comsize) {
|
||||
offsetCD += comsize;
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
@@ -222,8 +220,8 @@
|
||||
{
|
||||
int entriesZip = entries;
|
||||
char header[22];
|
||||
- char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
|
||||
- int comsize = (int) strlen(comment);
|
||||
+ const char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
|
||||
+ const size_t comsize = strlen(comment);
|
||||
if (entriesZip > 0xffff) {
|
||||
entriesZip = 0xffff;
|
||||
}
|
||||
@@ -241,7 +239,7 @@
|
||||
|
||||
/* Comment field */
|
||||
if (comsize > 0) {
|
||||
- if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
|
||||
+ if (fwrite(comment, 1, comsize, fpOutCD) != comsize) {
|
||||
err = Z_ERRNO;
|
||||
}
|
||||
}
|
||||
291
src/minizip/mztools.c.orig
Normal file
291
src/minizip/mztools.c.orig
Normal file
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
Additional tools for Minizip
|
||||
Code: Xavier Roche '2004
|
||||
License: Same as ZLIB (www.gzip.org)
|
||||
*/
|
||||
|
||||
/* Code */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "zlib.h"
|
||||
#include "unzip.h"
|
||||
|
||||
#define READ_8(adr) ((unsigned char)*(adr))
|
||||
#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) )
|
||||
#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) )
|
||||
|
||||
#define WRITE_8(buff, n) do { \
|
||||
*((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \
|
||||
} while(0)
|
||||
#define WRITE_16(buff, n) do { \
|
||||
WRITE_8((unsigned char*)(buff), n); \
|
||||
WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \
|
||||
} while(0)
|
||||
#define WRITE_32(buff, n) do { \
|
||||
WRITE_16((unsigned char*)(buff), (n) & 0xffff); \
|
||||
WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
|
||||
} while(0)
|
||||
|
||||
extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
|
||||
const char* file;
|
||||
const char* fileOut;
|
||||
const char* fileOutTmp;
|
||||
uLong* nRecovered;
|
||||
uLong* bytesRecovered;
|
||||
{
|
||||
int err = Z_OK;
|
||||
FILE* fpZip = fopen(file, "rb");
|
||||
FILE* fpOut = fopen(fileOut, "wb");
|
||||
FILE* fpOutCD = fopen(fileOutTmp, "wb");
|
||||
if (fpZip != NULL && fpOut != NULL) {
|
||||
int entries = 0;
|
||||
uLong totalBytes = 0;
|
||||
char header[30];
|
||||
char filename[1024];
|
||||
char extra[1024];
|
||||
int offset = 0;
|
||||
int offsetCD = 0;
|
||||
while ( fread(header, 1, 30, fpZip) == 30 ) {
|
||||
int currentOffset = offset;
|
||||
|
||||
/* File entry */
|
||||
if (READ_32(header) == 0x04034b50) {
|
||||
unsigned int version = READ_16(header + 4);
|
||||
unsigned int gpflag = READ_16(header + 6);
|
||||
unsigned int method = READ_16(header + 8);
|
||||
unsigned int filetime = READ_16(header + 10);
|
||||
unsigned int filedate = READ_16(header + 12);
|
||||
unsigned int crc = READ_32(header + 14); /* crc */
|
||||
unsigned int cpsize = READ_32(header + 18); /* compressed size */
|
||||
unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */
|
||||
unsigned int fnsize = READ_16(header + 26); /* file name length */
|
||||
unsigned int extsize = READ_16(header + 28); /* extra field length */
|
||||
filename[0] = extra[0] = '\0';
|
||||
|
||||
/* Header */
|
||||
if (fwrite(header, 1, 30, fpOut) == 30) {
|
||||
offset += 30;
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Filename */
|
||||
if (fnsize > 0) {
|
||||
if (fnsize < sizeof(filename)) {
|
||||
if (fread(filename, 1, fnsize, fpZip) == fnsize) {
|
||||
if (fwrite(filename, 1, fnsize, fpOut) == fnsize) {
|
||||
offset += fnsize;
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
err = Z_STREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Extra field */
|
||||
if (extsize > 0) {
|
||||
if (extsize < sizeof(extra)) {
|
||||
if (fread(extra, 1, extsize, fpZip) == extsize) {
|
||||
if (fwrite(extra, 1, extsize, fpOut) == extsize) {
|
||||
offset += extsize;
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Data */
|
||||
{
|
||||
int dataSize = cpsize;
|
||||
if (dataSize == 0) {
|
||||
dataSize = uncpsize;
|
||||
}
|
||||
if (dataSize > 0) {
|
||||
char* data = malloc(dataSize);
|
||||
if (data != NULL) {
|
||||
if ((int)fread(data, 1, dataSize, fpZip) == dataSize) {
|
||||
if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) {
|
||||
offset += dataSize;
|
||||
totalBytes += dataSize;
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
}
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
}
|
||||
free(data);
|
||||
if (err != Z_OK) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
err = Z_MEM_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Central directory entry */
|
||||
{
|
||||
char header[46];
|
||||
char* comment = "";
|
||||
int comsize = (int) strlen(comment);
|
||||
WRITE_32(header, 0x02014b50);
|
||||
WRITE_16(header + 4, version);
|
||||
WRITE_16(header + 6, version);
|
||||
WRITE_16(header + 8, gpflag);
|
||||
WRITE_16(header + 10, method);
|
||||
WRITE_16(header + 12, filetime);
|
||||
WRITE_16(header + 14, filedate);
|
||||
WRITE_32(header + 16, crc);
|
||||
WRITE_32(header + 20, cpsize);
|
||||
WRITE_32(header + 24, uncpsize);
|
||||
WRITE_16(header + 28, fnsize);
|
||||
WRITE_16(header + 30, extsize);
|
||||
WRITE_16(header + 32, comsize);
|
||||
WRITE_16(header + 34, 0); /* disk # */
|
||||
WRITE_16(header + 36, 0); /* int attrb */
|
||||
WRITE_32(header + 38, 0); /* ext attrb */
|
||||
WRITE_32(header + 42, currentOffset);
|
||||
/* Header */
|
||||
if (fwrite(header, 1, 46, fpOutCD) == 46) {
|
||||
offsetCD += 46;
|
||||
|
||||
/* Filename */
|
||||
if (fnsize > 0) {
|
||||
if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) {
|
||||
offsetCD += fnsize;
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
err = Z_STREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Extra field */
|
||||
if (extsize > 0) {
|
||||
if (fwrite(extra, 1, extsize, fpOutCD) == extsize) {
|
||||
offsetCD += extsize;
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Comment field */
|
||||
if (comsize > 0) {
|
||||
if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {
|
||||
offsetCD += comsize;
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Success */
|
||||
entries++;
|
||||
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Final central directory */
|
||||
{
|
||||
int entriesZip = entries;
|
||||
char header[22];
|
||||
char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
|
||||
int comsize = (int) strlen(comment);
|
||||
if (entriesZip > 0xffff) {
|
||||
entriesZip = 0xffff;
|
||||
}
|
||||
WRITE_32(header, 0x06054b50);
|
||||
WRITE_16(header + 4, 0); /* disk # */
|
||||
WRITE_16(header + 6, 0); /* disk # */
|
||||
WRITE_16(header + 8, entriesZip); /* hack */
|
||||
WRITE_16(header + 10, entriesZip); /* hack */
|
||||
WRITE_32(header + 12, offsetCD); /* size of CD */
|
||||
WRITE_32(header + 16, offset); /* offset to CD */
|
||||
WRITE_16(header + 20, comsize); /* comment */
|
||||
|
||||
/* Header */
|
||||
if (fwrite(header, 1, 22, fpOutCD) == 22) {
|
||||
|
||||
/* Comment field */
|
||||
if (comsize > 0) {
|
||||
if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
|
||||
err = Z_ERRNO;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
err = Z_ERRNO;
|
||||
}
|
||||
}
|
||||
|
||||
/* Final merge (file + central directory) */
|
||||
fclose(fpOutCD);
|
||||
if (err == Z_OK) {
|
||||
fpOutCD = fopen(fileOutTmp, "rb");
|
||||
if (fpOutCD != NULL) {
|
||||
int nRead;
|
||||
char buffer[8192];
|
||||
while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) {
|
||||
if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) {
|
||||
err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fpOutCD);
|
||||
}
|
||||
}
|
||||
|
||||
/* Close */
|
||||
fclose(fpZip);
|
||||
fclose(fpOut);
|
||||
|
||||
/* Wipe temporary file */
|
||||
(void)remove(fileOutTmp);
|
||||
|
||||
/* Number of recovered entries */
|
||||
if (err == Z_OK) {
|
||||
if (nRecovered != NULL) {
|
||||
*nRecovered = entries;
|
||||
}
|
||||
if (bytesRecovered != NULL) {
|
||||
*bytesRecovered = totalBytes;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = Z_STREAM_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
|
||||
}
|
||||
|
||||
ldi = ll->last_block;
|
||||
from_copy = (unsigned char*)buf;
|
||||
from_copy = (const unsigned char*)buf;
|
||||
|
||||
while (len>0)
|
||||
{
|
||||
@@ -1416,7 +1416,7 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
|
||||
#ifdef HAVE_BZIP2
|
||||
if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw))
|
||||
{
|
||||
zi->ci.bstream.next_in = (void*)buf;
|
||||
zi->ci.bstream.next_in = buf;
|
||||
zi->ci.bstream.avail_in = len;
|
||||
err = BZ_RUN_OK;
|
||||
|
||||
@@ -1450,7 +1450,7 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
|
||||
else
|
||||
#endif
|
||||
{
|
||||
zi->ci.stream.next_in = (Bytef*)buf;
|
||||
zi->ci.stream.next_in = buf;
|
||||
zi->ci.stream.avail_in = len;
|
||||
|
||||
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--- zip.c.orig 2013-02-24 08:32:30.000000000 +0100
|
||||
+++ zip.c 2014-05-24 13:52:45.570151611 +0200
|
||||
--- zip.c.orig 2014-06-10 18:55:32.778807408 +0200
|
||||
+++ zip.c 2014-06-11 20:27:18.355848501 +0200
|
||||
@@ -186,7 +186,7 @@
|
||||
#include "crypt.h"
|
||||
#endif
|
||||
@@ -9,6 +9,15 @@
|
||||
{
|
||||
linkedlist_datablock_internal* ldi;
|
||||
ldi = (linkedlist_datablock_internal*)
|
||||
@@ -238,7 +238,7 @@
|
||||
}
|
||||
|
||||
ldi = ll->last_block;
|
||||
- from_copy = (unsigned char*)buf;
|
||||
+ from_copy = (const unsigned char*)buf;
|
||||
|
||||
while (len>0)
|
||||
{
|
||||
@@ -637,7 +637,7 @@
|
||||
return relativeOffset;
|
||||
}
|
||||
@@ -27,6 +36,24 @@
|
||||
{
|
||||
/* write the local header */
|
||||
int err;
|
||||
@@ -1416,7 +1416,7 @@
|
||||
#ifdef HAVE_BZIP2
|
||||
if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw))
|
||||
{
|
||||
- zi->ci.bstream.next_in = (void*)buf;
|
||||
+ zi->ci.bstream.next_in = buf;
|
||||
zi->ci.bstream.avail_in = len;
|
||||
err = BZ_RUN_OK;
|
||||
|
||||
@@ -1450,7 +1450,7 @@
|
||||
else
|
||||
#endif
|
||||
{
|
||||
- zi->ci.stream.next_in = (Bytef*)buf;
|
||||
+ zi->ci.stream.next_in = buf;
|
||||
zi->ci.stream.avail_in = len;
|
||||
|
||||
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
|
||||
@@ -1752,7 +1752,7 @@
|
||||
return zipCloseFileInZipRaw (file,0,0);
|
||||
}
|
||||
|
||||
2007
src/minizip/zip.c.orig
Normal file
2007
src/minizip/zip.c.orig
Normal file
File diff suppressed because it is too large
Load Diff
362
src/minizip/zip.h.orig
Normal file
362
src/minizip/zip.h.orig
Normal file
@@ -0,0 +1,362 @@
|
||||
/* zip.h -- IO on .zip files using zlib
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Modifications for Zip64 support
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Changes
|
||||
|
||||
See header of zip.h
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _zip12_H
|
||||
#define _zip12_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#define HAVE_BZIP2
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BZIP2
|
||||
#include "bzlib.h"
|
||||
#endif
|
||||
|
||||
#define Z_BZIP2ED 12
|
||||
|
||||
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagzipFile__ { int unused; } zipFile__;
|
||||
typedef zipFile__ *zipFile;
|
||||
#else
|
||||
typedef voidp zipFile;
|
||||
#endif
|
||||
|
||||
#define ZIP_OK (0)
|
||||
#define ZIP_EOF (0)
|
||||
#define ZIP_ERRNO (Z_ERRNO)
|
||||
#define ZIP_PARAMERROR (-102)
|
||||
#define ZIP_BADZIPFILE (-103)
|
||||
#define ZIP_INTERNALERROR (-104)
|
||||
|
||||
#ifndef DEF_MEM_LEVEL
|
||||
# if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
# else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
# endif
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
/* tm_zip contain date/time info */
|
||||
typedef struct tm_zip_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_zip;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tm_zip tmz_date; /* date in understandable format */
|
||||
uLong dosDate; /* if dos_date == 0, tmu_date is used */
|
||||
/* uLong flag; */ /* general purpose bit flag 2 bytes */
|
||||
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
} zip_fileinfo;
|
||||
|
||||
typedef const char* zipcharpc;
|
||||
|
||||
|
||||
#define APPEND_STATUS_CREATE (0)
|
||||
#define APPEND_STATUS_CREATEAFTER (1)
|
||||
#define APPEND_STATUS_ADDINZIP (2)
|
||||
|
||||
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
|
||||
extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
|
||||
/*
|
||||
Create a zipfile.
|
||||
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
|
||||
an Unix computer "zlib/zlib113.zip".
|
||||
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
|
||||
will be created at the end of the file.
|
||||
(useful if the file contain a self extractor code)
|
||||
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
|
||||
add files in existing zip (be sure you don't add file that doesn't exist)
|
||||
If the zipfile cannot be opened, the return value is NULL.
|
||||
Else, the return value is a zipFile Handle, usable with other function
|
||||
of this zip package.
|
||||
*/
|
||||
|
||||
/* Note : there is no delete function into a zipfile.
|
||||
If you want delete file into a zipfile, you must open a zipfile, and create another
|
||||
Of couse, you can use RAW reading and writing to copy the file you did not want delte
|
||||
*/
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level));
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int zip64));
|
||||
|
||||
/*
|
||||
Open a file in the ZIP for writing.
|
||||
filename : the filename in zip (if NULL, '-' without quote will be used
|
||||
*zipfi contain supplemental information
|
||||
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
|
||||
contains the extrafield data the the local header
|
||||
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
|
||||
contains the extrafield data the the local header
|
||||
if comment != NULL, comment contain the comment string
|
||||
method contain the compression method (0 for store, Z_DEFLATED for deflate)
|
||||
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
|
||||
zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
|
||||
this MUST be '1' if the uncompressed size is >= 0xffffffff.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw));
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int zip64));
|
||||
/*
|
||||
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting));
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
int zip64
|
||||
));
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip2, except
|
||||
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
|
||||
password : crypting password (NULL for no crypting)
|
||||
crcForCrypting : crc of file to compress (needed for crypting)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase
|
||||
));
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase,
|
||||
int zip64
|
||||
));
|
||||
/*
|
||||
Same than zipOpenNewFileInZip4, except
|
||||
versionMadeBy : value for Version made by field
|
||||
flag : value for flag field (compression level info will be added)
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||
const void* buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Write data in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||
/*
|
||||
Close the current file in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
|
||||
uLong uncompressed_size,
|
||||
uLong crc32));
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
|
||||
ZPOS64_T uncompressed_size,
|
||||
uLong crc32));
|
||||
|
||||
/*
|
||||
Close the current file in the zipfile, for file opened with
|
||||
parameter raw=1 in zipOpenNewFileInZip2
|
||||
uncompressed_size and crc32 are value for the uncompressed size
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipClose OF((zipFile file,
|
||||
const char* global_comment));
|
||||
/*
|
||||
Close the zipfile
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));
|
||||
/*
|
||||
zipRemoveExtraInfoBlock - Added by Mathias Svensson
|
||||
|
||||
Remove extra information block from a extra information data for the local file header or central directory header
|
||||
|
||||
It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.
|
||||
|
||||
0x0001 is the signature header for the ZIP64 extra information blocks
|
||||
|
||||
usage.
|
||||
Remove ZIP64 Extra information from a central director extra field data
|
||||
zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);
|
||||
|
||||
Remove ZIP64 Extra information from a Local File Header extra field data
|
||||
zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _zip64_H */
|
||||
@@ -7,7 +7,19 @@
|
||||
// compile and run any of them on any platform, but your performance with the
|
||||
// non-native version will be less than optimal.
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <stddef.h>
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#elif (defined(SOLARIS) || defined(sun) || defined(HAVE_INTTYPES_H) \
|
||||
|| defined(BSD) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD_kernel__))
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
static uint32_t rotl32 ( uint32_t x, int8_t r )
|
||||
{
|
||||
|
||||
22
src/murmurhash3.h.diff
Normal file
22
src/murmurhash3.h.diff
Normal file
@@ -0,0 +1,22 @@
|
||||
--- murmurhash3.h.orig 2014-06-14 14:29:11.562576736 +0200
|
||||
+++ murmurhash3.h 2014-06-14 14:39:43.989624584 +0200
|
||||
@@ -7,7 +7,19 @@
|
||||
// compile and run any of them on any platform, but your performance with the
|
||||
// non-native version will be less than optimal.
|
||||
|
||||
+#ifdef _WIN32
|
||||
+#include <stddef.h>
|
||||
+typedef __int8 int8_t;
|
||||
+typedef unsigned __int8 uint8_t;
|
||||
+typedef unsigned __int16 uint16_t;
|
||||
+typedef unsigned __int32 uint32_t;
|
||||
+typedef unsigned __int64 uint64_t;
|
||||
+#elif (defined(SOLARIS) || defined(sun) || defined(HAVE_INTTYPES_H) \
|
||||
+ || defined(BSD) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD_kernel__))
|
||||
+#include <inttypes.h>
|
||||
+#else
|
||||
#include <stdint.h>
|
||||
+#endif
|
||||
|
||||
static uint32_t rotl32 ( uint32_t x, int8_t r )
|
||||
{
|
||||
127
src/murmurhash3.h.orig
Normal file
127
src/murmurhash3.h.orig
Normal file
@@ -0,0 +1,127 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// MurmurHash3 was written by Austin Appleby, and is placed in the public
|
||||
// domain. The author hereby disclaims copyright to this source code.
|
||||
|
||||
// Note - The x86 and x64 versions do _not_ produce the same results, as the
|
||||
// algorithms are optimized for their respective platforms. You can still
|
||||
// compile and run any of them on any platform, but your performance with the
|
||||
// non-native version will be less than optimal.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static uint32_t rotl32 ( uint32_t x, int8_t r )
|
||||
{
|
||||
return (x << r) | (x >> (32 - r));
|
||||
}
|
||||
#define ROTL32(x,y) rotl32(x,y)
|
||||
static uint32_t getblock32 ( const uint32_t * p, int i )
|
||||
{
|
||||
return p[i];
|
||||
}
|
||||
static uint32_t fmix32 ( uint32_t h )
|
||||
{
|
||||
h ^= h >> 16;
|
||||
h *= 0x85ebca6b;
|
||||
h ^= h >> 13;
|
||||
h *= 0xc2b2ae35;
|
||||
h ^= h >> 16;
|
||||
|
||||
return h;
|
||||
}
|
||||
#define BIG_CONSTANT(x) (x##LLU)
|
||||
static void MurmurHash3_x86_128 ( const void * key, const int len,
|
||||
uint32_t seed, void * out ) {
|
||||
const uint8_t * data = (const uint8_t*)key;
|
||||
const int nblocks = len / 16;
|
||||
|
||||
uint32_t h1 = seed;
|
||||
uint32_t h2 = seed;
|
||||
uint32_t h3 = seed;
|
||||
uint32_t h4 = seed;
|
||||
|
||||
const uint32_t c1 = 0x239b961b;
|
||||
const uint32_t c2 = 0xab0e9789;
|
||||
const uint32_t c3 = 0x38b34ae5;
|
||||
const uint32_t c4 = 0xa1e38b93;
|
||||
|
||||
const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
|
||||
int i;
|
||||
|
||||
for(i = -nblocks; i; i++)
|
||||
{
|
||||
uint32_t k1 = getblock32(blocks,i*4+0);
|
||||
uint32_t k2 = getblock32(blocks,i*4+1);
|
||||
uint32_t k3 = getblock32(blocks,i*4+2);
|
||||
uint32_t k4 = getblock32(blocks,i*4+3);
|
||||
|
||||
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
|
||||
|
||||
h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b;
|
||||
|
||||
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
|
||||
|
||||
h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747;
|
||||
|
||||
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
|
||||
|
||||
h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35;
|
||||
|
||||
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
|
||||
|
||||
h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17;
|
||||
}
|
||||
|
||||
{
|
||||
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
|
||||
|
||||
uint32_t k1 = 0;
|
||||
uint32_t k2 = 0;
|
||||
uint32_t k3 = 0;
|
||||
uint32_t k4 = 0;
|
||||
|
||||
switch(len & 15)
|
||||
{
|
||||
case 15: k4 ^= tail[14] << 16;
|
||||
case 14: k4 ^= tail[13] << 8;
|
||||
case 13: k4 ^= tail[12] << 0;
|
||||
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
|
||||
|
||||
case 12: k3 ^= tail[11] << 24;
|
||||
case 11: k3 ^= tail[10] << 16;
|
||||
case 10: k3 ^= tail[ 9] << 8;
|
||||
case 9: k3 ^= tail[ 8] << 0;
|
||||
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
|
||||
|
||||
case 8: k2 ^= tail[ 7] << 24;
|
||||
case 7: k2 ^= tail[ 6] << 16;
|
||||
case 6: k2 ^= tail[ 5] << 8;
|
||||
case 5: k2 ^= tail[ 4] << 0;
|
||||
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
|
||||
|
||||
case 4: k1 ^= tail[ 3] << 24;
|
||||
case 3: k1 ^= tail[ 2] << 16;
|
||||
case 2: k1 ^= tail[ 1] << 8;
|
||||
case 1: k1 ^= tail[ 0] << 0;
|
||||
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
|
||||
};
|
||||
|
||||
|
||||
h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len;
|
||||
|
||||
h1 += h2; h1 += h3; h1 += h4;
|
||||
h2 += h1; h3 += h1; h4 += h1;
|
||||
|
||||
h1 = fmix32(h1);
|
||||
h2 = fmix32(h2);
|
||||
h3 = fmix32(h3);
|
||||
h4 = fmix32(h4);
|
||||
|
||||
h1 += h2; h1 += h3; h1 += h4;
|
||||
h2 += h1; h3 += h1; h4 += h1;
|
||||
|
||||
((uint32_t*)out)[0] = h1;
|
||||
((uint32_t*)out)[1] = h2;
|
||||
((uint32_t*)out)[2] = h3;
|
||||
((uint32_t*)out)[3] = h4;
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ Remark: If no cache newer than the added one is found, all entries can be added
|
||||
#include "htsglobal.h"
|
||||
|
||||
/* htsweb */
|
||||
#include "htsinthash.h"
|
||||
#include "coucal.h"
|
||||
|
||||
/* ProxyTrack */
|
||||
#include "proxytrack.h"
|
||||
|
||||
@@ -45,7 +45,7 @@ static long int timezone = 0;
|
||||
#include "htsglobal.h"
|
||||
|
||||
#define HTS_INTERNAL_BYTECODE
|
||||
#include "htsinthash.h"
|
||||
#include "coucal.h"
|
||||
#include "htsmd5.h"
|
||||
#undef HTS_INTERNAL_BYTECODE
|
||||
#include "../minizip/mztools.h"
|
||||
@@ -168,7 +168,7 @@ static _PT_Index_Functions _IndexFuncts[] = {
|
||||
|
||||
#define PT_INDEX_COMMON_STRUCTURE \
|
||||
time_t timestamp; \
|
||||
inthash hash; \
|
||||
coucal hash; \
|
||||
char startUrl[1024]
|
||||
|
||||
struct _PT_Index__New {
|
||||
@@ -216,7 +216,7 @@ struct _PT_Index {
|
||||
};
|
||||
|
||||
struct _PT_Indexes {
|
||||
inthash cil;
|
||||
coucal cil;
|
||||
struct _PT_Index **index;
|
||||
int index_size;
|
||||
};
|
||||
@@ -228,7 +228,7 @@ struct _PT_CacheItem {
|
||||
};
|
||||
|
||||
struct _PT_Cache {
|
||||
inthash index;
|
||||
coucal index;
|
||||
size_t maxSize;
|
||||
size_t totalSize;
|
||||
int count;
|
||||
@@ -237,8 +237,8 @@ struct _PT_Cache {
|
||||
PT_Indexes PT_New(void) {
|
||||
PT_Indexes index = (PT_Indexes) calloc(sizeof(_PT_Indexes), 1);
|
||||
|
||||
index->cil = inthash_new(0);
|
||||
inthash_set_name(index->cil, "index->cil");
|
||||
index->cil = coucal_new(0);
|
||||
coucal_set_name(index->cil, "index->cil");
|
||||
index->index_size = 0;
|
||||
index->index = NULL;
|
||||
return index;
|
||||
@@ -246,7 +246,7 @@ PT_Indexes PT_New(void) {
|
||||
|
||||
void PT_Delete(PT_Indexes index) {
|
||||
if (index != NULL) {
|
||||
inthash_delete(&index->cil);
|
||||
coucal_delete(&index->cil);
|
||||
free(index);
|
||||
}
|
||||
}
|
||||
@@ -322,7 +322,7 @@ static void PT_Index_Delete__New(PT_Index * pindex) {
|
||||
index->zFile = NULL;
|
||||
}
|
||||
if (index->hash != NULL) {
|
||||
inthash_delete(&index->hash);
|
||||
coucal_delete(&index->hash);
|
||||
index->hash = NULL;
|
||||
}
|
||||
MutexFree(&index->zFileLock);
|
||||
@@ -340,7 +340,7 @@ static void PT_Index_Delete__Old(PT_Index * pindex) {
|
||||
fclose(index->ndx);
|
||||
}
|
||||
if (index->hash != NULL) {
|
||||
inthash_delete(&index->hash);
|
||||
coucal_delete(&index->hash);
|
||||
index->hash = NULL;
|
||||
}
|
||||
MutexFree(&index->fileLock);
|
||||
@@ -429,13 +429,13 @@ char **PT_Enumerate(PT_Indexes indexes, const char *url, int subtree) {
|
||||
String listindexes = STRING_EMPTY;
|
||||
String subitem = STRING_EMPTY;
|
||||
unsigned int listCount = 0;
|
||||
struct_inthash_enum en = inthash_enum_new(indexes->cil);
|
||||
inthash_chain *chain;
|
||||
inthash hdupes = NULL;
|
||||
struct_coucal_enum en = coucal_enum_new(indexes->cil);
|
||||
coucal_item *chain;
|
||||
coucal hdupes = NULL;
|
||||
|
||||
if (!subtree) {
|
||||
hdupes = inthash_new(0);
|
||||
inthash_set_name(hdupes, "hdupes");
|
||||
hdupes = coucal_new(0);
|
||||
coucal_set_name(hdupes, "hdupes");
|
||||
}
|
||||
StringClear(list);
|
||||
StringClear(listindexes);
|
||||
@@ -443,12 +443,12 @@ char **PT_Enumerate(PT_Indexes indexes, const char *url, int subtree) {
|
||||
if (strncmp(url, "http://", 7) == 0)
|
||||
url += 7;
|
||||
urlSize = (unsigned int) strlen(url);
|
||||
while((chain = inthash_enum_next(&en))) {
|
||||
while((chain = coucal_enum_next(&en))) {
|
||||
long int index = (long int) chain->value.intg;
|
||||
|
||||
if (urlSize == 0 || strncmp(chain->name, url, urlSize) == 0) {
|
||||
if (index >= 0 && index < indexes->index_size) {
|
||||
char *item = chain->name + urlSize;
|
||||
char *item = (char*) chain->name + urlSize;
|
||||
|
||||
if (*item == '/')
|
||||
item++;
|
||||
@@ -462,7 +462,7 @@ char **PT_Enumerate(PT_Indexes indexes, const char *url, int subtree) {
|
||||
StringClear(subitem);
|
||||
if (len > 0)
|
||||
StringMemcat(subitem, item, len);
|
||||
if (len == 0 || !inthash_exists(hdupes, StringBuff(subitem))) {
|
||||
if (len == 0 || !coucal_exists(hdupes, StringBuff(subitem))) {
|
||||
char *ptr = NULL;
|
||||
|
||||
ptr += StringLength(list);
|
||||
@@ -473,7 +473,7 @@ char **PT_Enumerate(PT_Indexes indexes, const char *url, int subtree) {
|
||||
StringMemcat(list, "\0", 1); /* NULL terminated strings */
|
||||
StringMemcat(listindexes, (char*) &ptr, sizeof(ptr));
|
||||
listCount++;
|
||||
inthash_write(hdupes, StringBuff(subitem), 0);
|
||||
coucal_write(hdupes, StringBuff(subitem), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -484,7 +484,7 @@ char **PT_Enumerate(PT_Indexes indexes, const char *url, int subtree) {
|
||||
}
|
||||
}
|
||||
StringFree(subitem);
|
||||
inthash_delete(&hdupes);
|
||||
coucal_delete(&hdupes);
|
||||
if (listCount > 0) {
|
||||
unsigned int i;
|
||||
void *blk;
|
||||
@@ -553,8 +553,8 @@ PT_Index PT_LoadCache(const char *filename) {
|
||||
index->type = type;
|
||||
index->slots.common.timestamp = (time_t) time(NULL);
|
||||
index->slots.common.startUrl[0] = '\0';
|
||||
index->slots.common.hash = inthash_new(0);
|
||||
inthash_set_name(index->slots.common.hash, "index->slots.common.hash");
|
||||
index->slots.common.hash = coucal_new(0);
|
||||
coucal_set_name(index->slots.common.hash, "index->slots.common.hash");
|
||||
if (!_IndexFuncts[type].PT_LoadCache(index, filename)) {
|
||||
proxytrack_print_log(DEBUG,
|
||||
"reading httrack cache (format #%d) %s : error",
|
||||
@@ -569,12 +569,12 @@ PT_Index PT_LoadCache(const char *filename) {
|
||||
}
|
||||
/* default starting URL is the first hash entry */
|
||||
if (index->slots.common.startUrl[0] == '\0') {
|
||||
struct_inthash_enum en = inthash_enum_new(index->slots.common.hash);
|
||||
inthash_chain *chain;
|
||||
struct_coucal_enum en = coucal_enum_new(index->slots.common.hash);
|
||||
coucal_item *chain;
|
||||
|
||||
chain = inthash_enum_next(&en);
|
||||
chain = coucal_enum_next(&en);
|
||||
if (chain != NULL && strstr(chain->name, "/robots.txt") != NULL) {
|
||||
chain = inthash_enum_next(&en);
|
||||
chain = coucal_enum_next(&en);
|
||||
}
|
||||
if (chain != NULL) {
|
||||
if (!link_has_authority(chain->name))
|
||||
@@ -625,10 +625,10 @@ int PT_EnumCache(PT_Indexes indexes,
|
||||
int (*callback) (void *, const char *url, PT_Element),
|
||||
void *arg) {
|
||||
if (indexes != NULL && indexes->cil != NULL) {
|
||||
struct_inthash_enum en = inthash_enum_new(indexes->cil);
|
||||
inthash_chain *chain;
|
||||
struct_coucal_enum en = coucal_enum_new(indexes->cil);
|
||||
coucal_item *chain;
|
||||
|
||||
while((chain = inthash_enum_next(&en))) {
|
||||
while((chain = coucal_enum_next(&en))) {
|
||||
const long int index_id = (long int) chain->value.intg;
|
||||
const char *const url = chain->name;
|
||||
|
||||
@@ -677,7 +677,7 @@ static int PT_LookupCache__New_u(PT_Index index_, const char *url) {
|
||||
|
||||
if (strncmp(url, "http://", 7) == 0)
|
||||
url += 7;
|
||||
hash_pos_return = inthash_read(index->hash, url, NULL);
|
||||
hash_pos_return = coucal_read(index->hash, url, NULL);
|
||||
if (hash_pos_return)
|
||||
return 1;
|
||||
}
|
||||
@@ -689,8 +689,8 @@ int PT_IndexMerge(PT_Indexes indexes, PT_Index * pindex) {
|
||||
if (pindex != NULL && *pindex != NULL && (*pindex)->slots.common.hash != NULL
|
||||
&& indexes != NULL) {
|
||||
PT_Index index = *pindex;
|
||||
struct_inthash_enum en = inthash_enum_new(index->slots.common.hash);
|
||||
inthash_chain *chain;
|
||||
struct_coucal_enum en = coucal_enum_new(index->slots.common.hash);
|
||||
coucal_item *chain;
|
||||
int index_id = indexes->index_size++;
|
||||
int nMerged = 0;
|
||||
|
||||
@@ -699,13 +699,13 @@ int PT_IndexMerge(PT_Indexes indexes, PT_Index * pindex) {
|
||||
sizeof(struct _PT_Index) * indexes->index_size)) != NULL) {
|
||||
indexes->index[index_id] = index;
|
||||
*pindex = NULL;
|
||||
while((chain = inthash_enum_next(&en)) != NULL) {
|
||||
while((chain = coucal_enum_next(&en)) != NULL) {
|
||||
const char *url = chain->name;
|
||||
|
||||
if (url != NULL && url[0] != '\0') {
|
||||
intptr_t previous_index_id = 0;
|
||||
|
||||
if (inthash_read(indexes->cil, url, &previous_index_id)) {
|
||||
if (coucal_read(indexes->cil, url, &previous_index_id)) {
|
||||
if (previous_index_id >= 0
|
||||
&& previous_index_id < indexes->index_size) {
|
||||
if (indexes->index[previous_index_id]->slots.common.timestamp > index->slots.common.timestamp) // existing entry is newer
|
||||
@@ -715,7 +715,7 @@ int PT_IndexMerge(PT_Indexes indexes, PT_Index * pindex) {
|
||||
"PT_IndexMerge:Corrupted central index locator");
|
||||
}
|
||||
}
|
||||
inthash_write(indexes->cil, chain->name, index_id);
|
||||
coucal_write(indexes->cil, chain->name, index_id);
|
||||
nMerged++;
|
||||
}
|
||||
}
|
||||
@@ -756,7 +756,7 @@ PT_Element PT_ReadIndex(PT_Indexes indexes, const char *url, int flags) {
|
||||
|
||||
if (strncmp(url, "http://", 7) == 0)
|
||||
url += 7;
|
||||
if (inthash_read(indexes->cil, url, &index_id)) {
|
||||
if (coucal_read(indexes->cil, url, &index_id)) {
|
||||
if (index_id >= 0 && index_id <= indexes->index_size) {
|
||||
PT_Element item = PT_ReadCache(indexes->index[index_id], url, flags);
|
||||
|
||||
@@ -779,7 +779,7 @@ int PT_LookupIndex(PT_Indexes indexes, const char *url) {
|
||||
|
||||
if (strncmp(url, "http://", 7) == 0)
|
||||
url += 7;
|
||||
if (inthash_read(indexes->cil, url, &index_id)) {
|
||||
if (coucal_read(indexes->cil, url, &index_id)) {
|
||||
if (index_id >= 0 && index_id <= indexes->index_size) {
|
||||
return 1;
|
||||
} else {
|
||||
@@ -890,7 +890,7 @@ int PT_LoadCache__New(PT_Index index_, const char *filename) {
|
||||
if (zFile != NULL) {
|
||||
const char *abpath;
|
||||
int slashes;
|
||||
inthash hashtable = index->hash;
|
||||
coucal hashtable = index->hash;
|
||||
|
||||
/* Compute base path for this index - the filename MUST be absolute! */
|
||||
for(slashes = 2, abpath = filename + (int) strlen(filename) - 1;
|
||||
@@ -960,9 +960,9 @@ int PT_LoadCache__New(PT_Index index_, const char *filename) {
|
||||
}
|
||||
}
|
||||
if (dataincache)
|
||||
inthash_add(hashtable, filenameIndex, pos);
|
||||
coucal_add(hashtable, filenameIndex, pos);
|
||||
else
|
||||
inthash_add(hashtable, filenameIndex, -pos);
|
||||
coucal_add(hashtable, filenameIndex, -pos);
|
||||
|
||||
/* First link as starting URL */
|
||||
if (!firstSeen) {
|
||||
@@ -987,7 +987,7 @@ int PT_LoadCache__New(PT_Index index_, const char *filename) {
|
||||
} while(unzGoToNextFile(zFile) == Z_OK);
|
||||
return 1;
|
||||
} else {
|
||||
inthash_delete(&index->hash);
|
||||
coucal_delete(&index->hash);
|
||||
index = NULL;
|
||||
}
|
||||
} else {
|
||||
@@ -1020,7 +1020,7 @@ static PT_Element PT_ReadCache__New_u(PT_Index index_, const char *url,
|
||||
strcpy(r->location, "");
|
||||
if (strncmp(url, "http://", 7) == 0)
|
||||
url += 7;
|
||||
hash_pos_return = inthash_read(index->hash, url, &hash_pos);
|
||||
hash_pos_return = coucal_read(index->hash, url, &hash_pos);
|
||||
|
||||
if (hash_pos_return) {
|
||||
uLong posInZip;
|
||||
@@ -1523,7 +1523,7 @@ static int PT_LoadCache__Old(PT_Index index_, const char *filename) {
|
||||
sscanf(linepos, "%d", &pos);
|
||||
|
||||
/* Add entry */
|
||||
inthash_add(cache->hash, line, pos);
|
||||
coucal_add(cache->hash, line, pos);
|
||||
|
||||
/* First link as starting URL */
|
||||
if (!firstSeen) {
|
||||
@@ -1614,7 +1614,7 @@ static PT_Element PT_ReadCache__Old_u(PT_Index index_, const char *url,
|
||||
strcpy(r->location, "");
|
||||
if (strncmp(url, "http://", 7) == 0)
|
||||
url += 7;
|
||||
hash_pos_return = inthash_read(cache->hash, url, &hash_pos);
|
||||
hash_pos_return = coucal_read(cache->hash, url, &hash_pos);
|
||||
|
||||
if (hash_pos_return) {
|
||||
int pos = (int) hash_pos; /* simply */
|
||||
@@ -1848,7 +1848,7 @@ static int PT_LookupCache__Old_u(PT_Index index_, const char *url) {
|
||||
return 0;
|
||||
if (strncmp(url, "http://", 7) == 0)
|
||||
url += 7;
|
||||
if (inthash_read(cache->hash, url, NULL))
|
||||
if (coucal_read(cache->hash, url, NULL))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -2002,7 +2002,7 @@ int PT_LoadCache__Arc(PT_Index index_, const char *filename) {
|
||||
|
||||
// Opened ?
|
||||
if (index->file != NULL) {
|
||||
inthash hashtable = index->hash;
|
||||
coucal hashtable = index->hash;
|
||||
|
||||
if (readArcURLRecord(index) == 0) {
|
||||
int entries = 0;
|
||||
@@ -2046,7 +2046,7 @@ int PT_LoadCache__Arc(PT_Index index_, const char *filename) {
|
||||
}
|
||||
/*fprintf(stdout, "adding %s [%d]\n", filenameIndex, (int)fpos); */
|
||||
if (PT_CompatibleScheme(index->filenameIndexBuff)) {
|
||||
inthash_add(hashtable, filenameIndex, fpos); /* position of meta-data */
|
||||
coucal_add(hashtable, filenameIndex, fpos); /* position of meta-data */
|
||||
entries++;
|
||||
}
|
||||
} else {
|
||||
@@ -2123,7 +2123,7 @@ static PT_Element PT_ReadCache__Arc_u(PT_Index index_, const char *url,
|
||||
strcpy(r->location, "");
|
||||
if (strncmp(url, "http://", 7) == 0)
|
||||
url += 7;
|
||||
hash_pos_return = inthash_read(index->hash, url, &hash_pos);
|
||||
hash_pos_return = coucal_read(index->hash, url, &hash_pos);
|
||||
|
||||
if (hash_pos_return) {
|
||||
if (fseek(index->file, (long) hash_pos, SEEK_SET) == 0) {
|
||||
@@ -2266,7 +2266,7 @@ static int PT_LookupCache__Arc_u(PT_Index index_, const char *url) {
|
||||
return 0;
|
||||
if (strncmp(url, "http://", 7) == 0)
|
||||
url += 7;
|
||||
if (inthash_read(cache->hash, url, NULL))
|
||||
if (coucal_read(cache->hash, url, NULL))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user